From 60164a1a7b33ff3e74e1e071821e8a6cf3e479d3 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 20 May 2016 17:37:03 +0200 Subject: [PATCH 001/316] Remove VS database file Former-commit-id: 6eb1442b4c61a9647fd65db28dfdc121ba0eab1a --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 258594792..017840762 100644 --- a/.gitignore +++ b/.gitignore @@ -34,7 +34,7 @@ build/**/*.sln build/**/*.vcxprojResolveAssemblyReference.cache build/**/*.nativecodeanalysis.all.xml build/**/*.nativecodeanalysis.xml -build/**/*.VC.opendb +build/**/*.VC.* # Compiled Object files build/**/*.slo From baa0dc3e3d0dd450687756eba945e0a0dcf49f21 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 1 Jun 2016 20:59:39 +0200 Subject: [PATCH 002/316] Vulkan: Fix Destroy() method of object not resetting the internal pointer Leading to double-delete if Delete() was explictly called Former-commit-id: 0f42bc70913b64eb60193035ae15285fcc8c88ad [formerly 6d8b0e87e7b2edfb2052671a059863b3ce439fcc] Former-commit-id: 2806bd83474c0c12fb88b9562b6baf71cc7692c1 --- include/Nazara/Vulkan/VkDevice.inl | 2 ++ include/Nazara/Vulkan/VkDeviceObject.inl | 3 +++ include/Nazara/Vulkan/VkInstance.inl | 3 +++ include/Nazara/Vulkan/VkSurface.inl | 3 +++ 4 files changed, 11 insertions(+) diff --git a/include/Nazara/Vulkan/VkDevice.inl b/include/Nazara/Vulkan/VkDevice.inl index 77dc1e254..81b784ae2 100644 --- a/include/Nazara/Vulkan/VkDevice.inl +++ b/include/Nazara/Vulkan/VkDevice.inl @@ -29,6 +29,8 @@ namespace Nz { vkDeviceWaitIdle(m_device); vkDestroyDevice(m_device, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); + + m_device = nullptr; } } diff --git a/include/Nazara/Vulkan/VkDeviceObject.inl b/include/Nazara/Vulkan/VkDeviceObject.inl index a3136156c..24499a7d0 100644 --- a/include/Nazara/Vulkan/VkDeviceObject.inl +++ b/include/Nazara/Vulkan/VkDeviceObject.inl @@ -57,7 +57,10 @@ namespace Nz inline void DeviceObject::Destroy() { if (m_handle != VK_NULL_HANDLE) + { C::DestroyHelper(m_device, m_handle, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); + m_handle = VK_NULL_HANDLE; + } } template diff --git a/include/Nazara/Vulkan/VkInstance.inl b/include/Nazara/Vulkan/VkInstance.inl index 801691855..bea7164fb 100644 --- a/include/Nazara/Vulkan/VkInstance.inl +++ b/include/Nazara/Vulkan/VkInstance.inl @@ -50,7 +50,10 @@ namespace Nz inline void Instance::Destroy() { if (m_instance) + { vkDestroyInstance(m_instance, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); + m_instance = nullptr; + } } inline PFN_vkVoidFunction Instance::GetDeviceProcAddr(VkDevice device, const char* name) diff --git a/include/Nazara/Vulkan/VkSurface.inl b/include/Nazara/Vulkan/VkSurface.inl index f64c24af0..a79d9c65d 100644 --- a/include/Nazara/Vulkan/VkSurface.inl +++ b/include/Nazara/Vulkan/VkSurface.inl @@ -165,7 +165,10 @@ namespace Nz inline void Surface::Destroy() { if (m_surface != VK_NULL_HANDLE) + { m_instance.vkDestroySurfaceKHR(m_instance, m_surface, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); + m_surface = VK_NULL_HANDLE; + } } inline VkResult Surface::GetLastErrorCode() const From b9b5db734c5022d68d5abff095281112e92a4725 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 1 Jun 2016 21:00:00 +0200 Subject: [PATCH 003/316] Vulkan/Core: Add loader and instance initialization Former-commit-id: d0635e2727d1f2f52fe8a03ff0530134645f1b1d [formerly fc5f88194171efde1e68387154db661072bfdf90] Former-commit-id: 6e42212b86524334a8324b1e49230303b49f969f --- include/Nazara/Vulkan/Vulkan.hpp | 8 ++ src/Nazara/Vulkan/Vulkan.cpp | 122 +++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+) diff --git a/include/Nazara/Vulkan/Vulkan.hpp b/include/Nazara/Vulkan/Vulkan.hpp index 9d90202c2..59c1bb4f3 100644 --- a/include/Nazara/Vulkan/Vulkan.hpp +++ b/include/Nazara/Vulkan/Vulkan.hpp @@ -9,7 +9,9 @@ #include #include +#include #include +#include namespace Nz { @@ -19,13 +21,19 @@ namespace Nz Vulkan() = delete; ~Vulkan() = delete; + static Vk::Instance& GetInstance(); + static bool Initialize(); static bool IsInitialized(); + static void SetParameters(const ParameterList& parameters); + static void Uninitialize(); private: + static Vk::Instance s_instance; + static ParameterList s_initializationParameters; static unsigned int s_moduleReferenceCounter; }; } diff --git a/src/Nazara/Vulkan/Vulkan.cpp b/src/Nazara/Vulkan/Vulkan.cpp index 00bb55337..dc7a201ff 100644 --- a/src/Nazara/Vulkan/Vulkan.cpp +++ b/src/Nazara/Vulkan/Vulkan.cpp @@ -12,6 +12,11 @@ namespace Nz { + Vk::Instance& Vulkan::GetInstance() + { + return s_instance; + } + bool Vulkan::Initialize() { if (s_moduleReferenceCounter > 0) @@ -32,6 +37,113 @@ namespace Nz CallOnExit onExit(Vulkan::Uninitialize); // Initialize module here + if (!Vk::Loader::Initialize()) + { + NazaraError("Failed to load Vulkan API, it may be not installed on your system"); + return false; + } + + String appName = "Another application made with Nazara Engine"; + String engineName = "Nazara Engine - Vulkan Renderer"; + UInt32 apiVersion = VK_MAKE_VERSION(1, 0, 8); + UInt32 appVersion = VK_MAKE_VERSION(1, 0, 0); + UInt32 engineVersion = VK_MAKE_VERSION(1, 0, 0); + + s_initializationParameters.GetStringParameter("VkAppInfo_OverrideApplicationName", &appName); + s_initializationParameters.GetStringParameter("VkAppInfo_OverrideEngineName", &engineName); + + int iParam; + + if (s_initializationParameters.GetIntegerParameter("VkAppInfo_OverrideAPIVersion", &iParam)) + apiVersion = iParam; + + if (s_initializationParameters.GetIntegerParameter("VkAppInfo_OverrideApplicationVersion", &iParam)) + appVersion = iParam; + + if (s_initializationParameters.GetIntegerParameter("VkAppInfo_OverrideEngineVersion", &iParam)) + engineVersion = iParam; + + VkApplicationInfo appInfo = { + VK_STRUCTURE_TYPE_APPLICATION_INFO, + nullptr, + appName.GetConstBuffer(), + appVersion, + engineName.GetConstBuffer(), + engineVersion, + apiVersion + }; + + VkInstanceCreateFlags createFlags = 0; + + if (s_initializationParameters.GetIntegerParameter("VkInstanceInfo_OverrideCreateFlags", &iParam)) + createFlags = static_cast(iParam); + + std::vector enabledLayers; + std::vector enabledExtensions; + + bool bParam; + if (!s_initializationParameters.GetBooleanParameter("VkInstanceInfo_OverrideEnabledExtensions", &bParam) || !bParam) + { + enabledExtensions.push_back("VK_KHR_surface"); + + #ifdef VK_USE_PLATFORM_ANDROID_KHR + enabledExtensions.push_back("VK_KHR_android_surface"); + #endif + + #ifdef VK_USE_PLATFORM_MIR_KHR + enabledExtensions.push_back("VK_KHR_mir_surface"); + #endif + + #ifdef VK_USE_PLATFORM_XCB_KHR + enabledExtensions.push_back("VK_KHR_xcb_surface"); + #endif + + #ifdef VK_USE_PLATFORM_XLIB_KHR + enabledExtensions.push_back("VK_KHR_xlib_surface"); + #endif + + #ifdef VK_USE_PLATFORM_WAYLAND_KHR + enabledExtensions.push_back("VK_KHR_wayland_surface"); + #endif + + #ifdef VK_USE_PLATFORM_WIN32_KHR + enabledExtensions.push_back("VK_KHR_win32_surface"); + #endif + } + + std::vector additionalExtensions; // Just to keep the String alive + if (s_initializationParameters.GetIntegerParameter("VkInstanceInfo_EnabledExtensionCount", &iParam)) + { + for (int i = 0; i < iParam; ++i) + { + Nz::String parameterName = "VkInstanceInfo_EnabledExtension" + String::Number(i); + Nz::String extension; + if (s_initializationParameters.GetStringParameter(parameterName, &extension)) + { + additionalExtensions.emplace_back(std::move(extension)); + enabledExtensions.push_back(additionalExtensions.back().GetConstBuffer()); + } + else + NazaraWarning("Parameter " + parameterName + " expected"); + } + } + + VkInstanceCreateInfo instanceInfo = { + VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, + nullptr, + createFlags, + &appInfo, + UInt32(enabledLayers.size()), + enabledLayers.data(), + UInt32(enabledExtensions.size()), + enabledExtensions.data() + }; + + if (!s_instance.Create(instanceInfo)) + { + NazaraError("Failed to create instance"); + return false; + } onExit.Reset(); @@ -44,6 +156,11 @@ namespace Nz return s_moduleReferenceCounter != 0; } + void Vulkan::SetParameters(const ParameterList& parameters) + { + s_initializationParameters = parameters; + } + void Vulkan::Uninitialize() { if (s_moduleReferenceCounter != 1) @@ -58,6 +175,9 @@ namespace Nz s_moduleReferenceCounter = 0; // Uninitialize module here + s_instance.Destroy(); + + Vk::Loader::Uninitialize(); NazaraNotice("Uninitialized: Vulkan module"); @@ -65,6 +185,8 @@ namespace Nz Utility::Uninitialize(); } + Vk::Instance Vulkan::s_instance; + ParameterList Vulkan::s_initializationParameters; unsigned int Vulkan::s_moduleReferenceCounter = 0; } From f3f46b71fb5d785f4b292ef0593d56ca5a6d67cb Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 8 Jun 2016 12:57:06 +0200 Subject: [PATCH 004/316] Vulkan: Make device objects take a device handle at creation Former-commit-id: 985b9f5b04aef4d6de55ee6d360a2da92bed8940 [formerly e31d84225897da96b0438d49dbdf6473a7873a17] Former-commit-id: 82ed4eeccde614312fff717ab1f469335c861292 --- include/Nazara/Vulkan/VkCommandBuffer.inl | 8 ++++---- include/Nazara/Vulkan/VkCommandPool.hpp | 8 ++++---- include/Nazara/Vulkan/VkCommandPool.inl | 19 +++++++---------- include/Nazara/Vulkan/VkDevice.inl | 10 +++++---- include/Nazara/Vulkan/VkDeviceObject.hpp | 9 ++++---- include/Nazara/Vulkan/VkDeviceObject.inl | 16 +++++---------- include/Nazara/Vulkan/VkQueue.hpp | 6 +++--- include/Nazara/Vulkan/VkQueue.inl | 12 +++++------ include/Nazara/Vulkan/VkSemaphore.hpp | 8 ++++---- include/Nazara/Vulkan/VkSemaphore.inl | 17 ++++++--------- include/Nazara/Vulkan/VkSwapchain.hpp | 8 ++++---- include/Nazara/Vulkan/VkSwapchain.inl | 25 +++++++++-------------- src/Nazara/Vulkan/VkCommandPool.cpp | 4 ++-- 13 files changed, 65 insertions(+), 85 deletions(-) diff --git a/include/Nazara/Vulkan/VkCommandBuffer.inl b/include/Nazara/Vulkan/VkCommandBuffer.inl index d2d6f50d7..c1d0ec9bc 100644 --- a/include/Nazara/Vulkan/VkCommandBuffer.inl +++ b/include/Nazara/Vulkan/VkCommandBuffer.inl @@ -2,7 +2,7 @@ // 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 @@ -33,7 +33,7 @@ namespace Nz inline bool CommandBuffer::Begin(const VkCommandBufferBeginInfo& info) { - m_lastErrorCode = m_pool->GetDevice().vkBeginCommandBuffer(m_handle, &info); + m_lastErrorCode = m_pool->GetDevice()->vkBeginCommandBuffer(m_handle, &info); if (m_lastErrorCode != VkResult::VK_SUCCESS) { NazaraError("Failed to begin command buffer"); @@ -119,7 +119,7 @@ namespace Nz inline bool CommandBuffer::End() { - m_lastErrorCode = m_pool->GetDevice().vkEndCommandBuffer(m_handle); + m_lastErrorCode = m_pool->GetDevice()->vkEndCommandBuffer(m_handle); if (m_lastErrorCode != VkResult::VK_SUCCESS) { NazaraError("Failed to end command buffer"); @@ -132,7 +132,7 @@ namespace Nz inline void CommandBuffer::Free() { if (m_handle) - m_pool->GetDevice().vkFreeCommandBuffers(m_pool->GetDevice(), *m_pool, 1, &m_handle); + m_pool->GetDevice()->vkFreeCommandBuffers(*m_pool->GetDevice(), *m_pool, 1, &m_handle); } inline VkResult CommandBuffer::GetLastErrorCode() const diff --git a/include/Nazara/Vulkan/VkCommandPool.hpp b/include/Nazara/Vulkan/VkCommandPool.hpp index b51061bb2..1884e2b6c 100644 --- a/include/Nazara/Vulkan/VkCommandPool.hpp +++ b/include/Nazara/Vulkan/VkCommandPool.hpp @@ -25,7 +25,7 @@ namespace Nz friend DeviceObject; public: - inline CommandPool(Device& instance); + CommandPool() = default; CommandPool(const CommandPool&) = delete; CommandPool(CommandPool&&) = default; ~CommandPool() = default; @@ -34,7 +34,7 @@ namespace Nz std::vector AllocateCommandBuffers(UInt32 commandBufferCount, VkCommandBufferLevel level); using DeviceObject::Create; - inline bool Create(UInt32 queueFamilyIndex, VkCommandPoolCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(const DeviceHandle& device, UInt32 queueFamilyIndex, VkCommandPoolCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); inline bool Reset(VkCommandPoolResetFlags flags); @@ -42,8 +42,8 @@ namespace Nz 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); + static inline VkResult CreateHelper(const DeviceHandle& device, const VkCommandPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkCommandPool* handle); + static inline void DestroyHelper(const DeviceHandle& device, VkCommandPool handle, const VkAllocationCallbacks* allocator); }; } } diff --git a/include/Nazara/Vulkan/VkCommandPool.inl b/include/Nazara/Vulkan/VkCommandPool.inl index 61cfeaa43..b47b3481f 100644 --- a/include/Nazara/Vulkan/VkCommandPool.inl +++ b/include/Nazara/Vulkan/VkCommandPool.inl @@ -11,12 +11,7 @@ namespace Nz { namespace Vk { - inline CommandPool::CommandPool(Device& device) : - DeviceObject(device) - { - } - - inline bool CommandPool::Create(UInt32 queueFamilyIndex, VkCommandPoolCreateFlags flags, const VkAllocationCallbacks* allocator) + inline bool CommandPool::Create(const DeviceHandle& device, UInt32 queueFamilyIndex, VkCommandPoolCreateFlags flags, const VkAllocationCallbacks* allocator) { VkCommandPoolCreateInfo createInfo = { @@ -26,26 +21,26 @@ namespace Nz queueFamilyIndex }; - return Create(createInfo, allocator); + return Create(device, createInfo, allocator); } inline bool CommandPool::Reset(VkCommandPoolResetFlags flags) { - m_lastErrorCode = m_device.vkResetCommandPool(m_device, m_handle, 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) + inline VkResult CommandPool::CreateHelper(const DeviceHandle& device, const VkCommandPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkCommandPool* handle) { - return device.vkCreateCommandPool(device, createInfo, allocator, handle); + return device->vkCreateCommandPool(*device, createInfo, allocator, handle); } - inline void CommandPool::DestroyHelper(Device& device, VkCommandPool handle, const VkAllocationCallbacks* allocator) + inline void CommandPool::DestroyHelper(const DeviceHandle& device, VkCommandPool handle, const VkAllocationCallbacks* allocator) { - return device.vkDestroyCommandPool(device, handle, allocator); + return device->vkDestroyCommandPool(*device, handle, allocator); } } } diff --git a/include/Nazara/Vulkan/VkDevice.inl b/include/Nazara/Vulkan/VkDevice.inl index 81b784ae2..332012679 100644 --- a/include/Nazara/Vulkan/VkDevice.inl +++ b/include/Nazara/Vulkan/VkDevice.inl @@ -14,7 +14,8 @@ namespace Nz { inline Device::Device(Instance& instance) : m_instance(instance), - m_device(nullptr) + m_device(VK_NULL_HANDLE), + m_physicalDevice(VK_NULL_HANDLE) { } @@ -25,12 +26,13 @@ namespace Nz inline void Device::Destroy() { - if (m_device) + if (m_device != VK_NULL_HANDLE) { vkDeviceWaitIdle(m_device); vkDestroyDevice(m_device, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); - m_device = nullptr; + m_device = VK_NULL_HANDLE; + m_physicalDevice = VK_NULL_HANDLE; } } @@ -39,7 +41,7 @@ namespace Nz VkQueue queue; vkGetDeviceQueue(m_device, queueFamilyIndex, queueIndex, &queue); - return Queue(*this, queue); + return Queue(DeviceHandle(this), queue); } inline Instance& Device::GetInstance() diff --git a/include/Nazara/Vulkan/VkDeviceObject.hpp b/include/Nazara/Vulkan/VkDeviceObject.hpp index dd9da38c9..49d70171f 100644 --- a/include/Nazara/Vulkan/VkDeviceObject.hpp +++ b/include/Nazara/Vulkan/VkDeviceObject.hpp @@ -19,16 +19,15 @@ namespace Nz class DeviceObject { public: - inline DeviceObject(Device& instance); + inline DeviceObject(); DeviceObject(const DeviceObject&) = delete; DeviceObject(DeviceObject&&); inline ~DeviceObject(); - inline bool Create(const CreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(const DeviceHandle& device, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); inline void Destroy(); - inline Device& GetDevice(); - inline const Device& GetDevice() const; + inline const DeviceHandle& GetDevice() const; inline VkResult GetLastErrorCode() const; DeviceObject& operator=(const DeviceObject&) = delete; @@ -37,7 +36,7 @@ namespace Nz inline operator VkType(); protected: - Device& m_device; + DeviceHandle m_device; VkAllocationCallbacks m_allocator; VkType m_handle; VkResult m_lastErrorCode; diff --git a/include/Nazara/Vulkan/VkDeviceObject.inl b/include/Nazara/Vulkan/VkDeviceObject.inl index 24499a7d0..8bd9eebe6 100644 --- a/include/Nazara/Vulkan/VkDeviceObject.inl +++ b/include/Nazara/Vulkan/VkDeviceObject.inl @@ -12,15 +12,14 @@ namespace Nz namespace Vk { template - inline DeviceObject::DeviceObject(Device& device) : - m_device(device), + inline DeviceObject::DeviceObject() : m_handle(VK_NULL_HANDLE) { } template inline DeviceObject::DeviceObject(DeviceObject&& object) : - m_device(object.m_device), + m_device(std::move(object.m_device)), m_allocator(object.m_allocator), m_handle(object.m_handle), m_lastErrorCode(object.m_lastErrorCode) @@ -35,8 +34,9 @@ namespace Nz } template - inline bool DeviceObject::Create(const CreateInfo& createInfo, const VkAllocationCallbacks* allocator) + inline bool DeviceObject::Create(const DeviceHandle& device, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator) { + m_device = device; m_lastErrorCode = C::CreateHelper(m_device, &createInfo, allocator, &m_handle); if (m_lastErrorCode != VkResult::VK_SUCCESS) { @@ -64,13 +64,7 @@ namespace Nz } template - inline Device& DeviceObject::GetDevice() - { - return m_device; - } - - template - inline const Device& DeviceObject::GetDevice() const + inline const DeviceHandle& DeviceObject::GetDevice() const { return m_device; } diff --git a/include/Nazara/Vulkan/VkQueue.hpp b/include/Nazara/Vulkan/VkQueue.hpp index 35c8d16e0..b6253bc32 100644 --- a/include/Nazara/Vulkan/VkQueue.hpp +++ b/include/Nazara/Vulkan/VkQueue.hpp @@ -18,12 +18,12 @@ namespace Nz class Queue { public: - inline Queue(Device& device, VkQueue queue); + inline Queue(const DeviceHandle& device, VkQueue queue); inline Queue(const Queue& queue); inline Queue(Queue&& queue); inline ~Queue() = default; - inline Device& GetDevice(); + inline const DeviceHandle& GetDevice() const; inline VkResult GetLastErrorCode() const; inline bool Present(const VkPresentInfoKHR& presentInfo); @@ -40,7 +40,7 @@ namespace Nz inline operator VkQueue(); protected: - Device& m_device; + DeviceHandle m_device; VkQueue m_handle; VkResult m_lastErrorCode; }; diff --git a/include/Nazara/Vulkan/VkQueue.inl b/include/Nazara/Vulkan/VkQueue.inl index a47918da3..89273958f 100644 --- a/include/Nazara/Vulkan/VkQueue.inl +++ b/include/Nazara/Vulkan/VkQueue.inl @@ -2,7 +2,7 @@ // 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 @@ -11,7 +11,7 @@ namespace Nz { namespace Vk { - inline Queue::Queue(Device& device, VkQueue queue) : + inline Queue::Queue(const DeviceHandle& device, VkQueue queue) : m_device(device), m_handle(queue), m_lastErrorCode(VkResult::VK_SUCCESS) @@ -32,7 +32,7 @@ namespace Nz { } - inline Device& Queue::GetDevice() + inline const DeviceHandle& Queue::GetDevice() const { return m_device; } @@ -44,7 +44,7 @@ namespace Nz inline bool Queue::Present(const VkPresentInfoKHR& presentInfo) { - m_lastErrorCode = m_device.vkQueuePresentKHR(m_handle, &presentInfo); + m_lastErrorCode = m_device->vkQueuePresentKHR(m_handle, &presentInfo); if (m_lastErrorCode != VkResult::VK_SUCCESS) return false; @@ -75,7 +75,7 @@ namespace Nz inline bool Queue::Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence fence) { - m_lastErrorCode = m_device.vkQueueSubmit(m_handle, submitCount, submits, fence); + m_lastErrorCode = m_device->vkQueueSubmit(m_handle, submitCount, submits, fence); if (m_lastErrorCode != VkResult::VK_SUCCESS) return false; @@ -84,7 +84,7 @@ namespace Nz inline bool Queue::WaitIdle() { - m_lastErrorCode = m_device.vkQueueWaitIdle(m_handle); + m_lastErrorCode = m_device->vkQueueWaitIdle(m_handle); if (m_lastErrorCode != VkResult::VK_SUCCESS) return false; diff --git a/include/Nazara/Vulkan/VkSemaphore.hpp b/include/Nazara/Vulkan/VkSemaphore.hpp index 138d726be..06c5c8038 100644 --- a/include/Nazara/Vulkan/VkSemaphore.hpp +++ b/include/Nazara/Vulkan/VkSemaphore.hpp @@ -19,20 +19,20 @@ namespace Nz friend DeviceObject; public: - inline Semaphore(Device& instance); + Semaphore() = default; Semaphore(const Semaphore&) = delete; Semaphore(Semaphore&&) = default; ~Semaphore() = default; using DeviceObject::Create; - inline bool Create(VkSemaphoreCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(DeviceObject device, 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); + static VkResult CreateHelper(const DeviceHandle& device, const VkSemaphoreCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSemaphore* handle); + static void DestroyHelper(const DeviceHandle& device, VkSemaphore handle, const VkAllocationCallbacks* allocator); }; } } diff --git a/include/Nazara/Vulkan/VkSemaphore.inl b/include/Nazara/Vulkan/VkSemaphore.inl index fd2bf3427..b423fd4c0 100644 --- a/include/Nazara/Vulkan/VkSemaphore.inl +++ b/include/Nazara/Vulkan/VkSemaphore.inl @@ -9,12 +9,7 @@ namespace Nz { namespace Vk { - inline Semaphore::Semaphore(Device& device) : - DeviceObject(device) - { - } - - inline bool Semaphore::Create(VkSemaphoreCreateFlags flags, const VkAllocationCallbacks* allocator) + inline bool Semaphore::Create(const DeviceHandle& device, VkSemaphoreCreateFlags flags, const VkAllocationCallbacks* allocator) { VkSemaphoreCreateInfo createInfo = { @@ -23,17 +18,17 @@ namespace Nz flags }; - return Create(createInfo, allocator); + return Create(device, createInfo, allocator); } - VkResult Semaphore::CreateHelper(Device& device, const VkSemaphoreCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSemaphore* handle) + VkResult Semaphore::CreateHelper(const DeviceHandle& device, const VkSemaphoreCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSemaphore* handle) { - return device.vkCreateSemaphore(device, createInfo, allocator, handle); + return device->vkCreateSemaphore(*device, createInfo, allocator, handle); } - void Semaphore::DestroyHelper(Device& device, VkSemaphore handle, const VkAllocationCallbacks* allocator) + void Semaphore::DestroyHelper(const DeviceHandle& device, VkSemaphore handle, const VkAllocationCallbacks* allocator) { - return device.vkDestroySemaphore(device, handle, allocator); + return device->vkDestroySemaphore(*device, handle, allocator); } } } diff --git a/include/Nazara/Vulkan/VkSwapchain.hpp b/include/Nazara/Vulkan/VkSwapchain.hpp index 374ad88e6..fbe8d2118 100644 --- a/include/Nazara/Vulkan/VkSwapchain.hpp +++ b/include/Nazara/Vulkan/VkSwapchain.hpp @@ -19,14 +19,14 @@ namespace Nz friend DeviceObject; public: - inline Swapchain(Device& instance); + Swapchain() = default; 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 bool Create(const DeviceHandle& device, const VkSwapchainCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); inline VkImage GetImage(UInt32 index) const; inline const std::vector& GetImages() const; @@ -38,8 +38,8 @@ namespace Nz 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); + static VkResult CreateHelper(const DeviceHandle& device, const VkSwapchainCreateInfoKHR* createInfo, const VkAllocationCallbacks* allocator, VkSwapchainKHR* handle); + static void DestroyHelper(const DeviceHandle& device, VkSwapchainKHR handle, const VkAllocationCallbacks* allocator); std::vector m_images; }; diff --git a/include/Nazara/Vulkan/VkSwapchain.inl b/include/Nazara/Vulkan/VkSwapchain.inl index 8865012e4..e1f885045 100644 --- a/include/Nazara/Vulkan/VkSwapchain.inl +++ b/include/Nazara/Vulkan/VkSwapchain.inl @@ -11,14 +11,9 @@ 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); + m_lastErrorCode = m_device->vkAcquireNextImageKHR(*m_device, m_handle, timeout, semaphore, fence, imageIndex); switch (m_lastErrorCode) { case VkResult::VK_SUBOPTIMAL_KHR: @@ -30,13 +25,13 @@ namespace Nz } } - inline bool Swapchain::Create(const VkSwapchainCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) + inline bool Swapchain::Create(const DeviceHandle& device, const VkSwapchainCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) { - if (!DeviceObject::Create(createInfo, allocator)) + if (!DeviceObject::Create(device, createInfo, allocator)) return false; UInt32 imageCount = 0; - m_lastErrorCode = m_device.vkGetSwapchainImagesKHR(m_device, m_handle, &imageCount, nullptr); + 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"); @@ -44,7 +39,7 @@ namespace Nz } m_images.resize(imageCount); - m_lastErrorCode = m_device.vkGetSwapchainImagesKHR(m_device, m_handle, &imageCount, m_images.data()); + 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"); @@ -71,18 +66,18 @@ namespace Nz inline bool Swapchain::IsSupported() const { - if (!m_device.IsExtensionLoaded("VK_KHR_swapchain")) + if (!m_device->IsExtensionLoaded("VK_KHR_swapchain")) return false; } - VkResult Swapchain::CreateHelper(Device& device, const VkSwapchainCreateInfoKHR* createInfo, const VkAllocationCallbacks* allocator, VkSwapchainKHR* handle) + VkResult Swapchain::CreateHelper(const DeviceHandle& device, const VkSwapchainCreateInfoKHR* createInfo, const VkAllocationCallbacks* allocator, VkSwapchainKHR* handle) { - return device.vkCreateSwapchainKHR(device, createInfo, allocator, handle); + return device->vkCreateSwapchainKHR(*device, createInfo, allocator, handle); } - void Swapchain::DestroyHelper(Device& device, VkSwapchainKHR handle, const VkAllocationCallbacks* allocator) + void Swapchain::DestroyHelper(const DeviceHandle& device, VkSwapchainKHR handle, const VkAllocationCallbacks* allocator) { - return device.vkDestroySwapchainKHR(device, handle, allocator); + return device->vkDestroySwapchainKHR(*device, handle, allocator); } } } diff --git a/src/Nazara/Vulkan/VkCommandPool.cpp b/src/Nazara/Vulkan/VkCommandPool.cpp index 3ee53ab6f..e50904848 100644 --- a/src/Nazara/Vulkan/VkCommandPool.cpp +++ b/src/Nazara/Vulkan/VkCommandPool.cpp @@ -22,7 +22,7 @@ namespace Nz }; VkCommandBuffer handle = VK_NULL_HANDLE; - m_lastErrorCode = m_device.vkAllocateCommandBuffers(m_device, &createInfo, &handle); + m_lastErrorCode = m_device->vkAllocateCommandBuffers(*m_device, &createInfo, &handle); return CommandBuffer(*this, handle); } @@ -39,7 +39,7 @@ namespace Nz }; std::vector handles(commandBufferCount, VK_NULL_HANDLE); - m_lastErrorCode = m_device.vkAllocateCommandBuffers(m_device, &createInfo, handles.data()); + m_lastErrorCode = m_device->vkAllocateCommandBuffers(*m_device, &createInfo, handles.data()); if (m_lastErrorCode != VkResult::VK_SUCCESS) return std::vector(); From 99b6338aef3f2d53b1ecb8749183689918758fc4 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 8 Jun 2016 12:57:21 +0200 Subject: [PATCH 005/316] Vulkan/Device: Add getter for Physical Device Former-commit-id: c880f3681186f73e1a08088949906b8cd0c04665 [formerly ee7385031b738cc97ba3657d68d62083745d5e63] Former-commit-id: 34779bccda27d0c601240e1f3b0ad2f4e0afec6c --- include/Nazara/Vulkan/VkDevice.hpp | 2 ++ include/Nazara/Vulkan/VkDevice.inl | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/include/Nazara/Vulkan/VkDevice.hpp b/include/Nazara/Vulkan/VkDevice.hpp index 1b9d3a470..ad66887bb 100644 --- a/include/Nazara/Vulkan/VkDevice.hpp +++ b/include/Nazara/Vulkan/VkDevice.hpp @@ -39,6 +39,7 @@ namespace Nz inline Instance& GetInstance(); inline const Instance& GetInstance() const; inline VkResult GetLastErrorCode() const; + inline VkPhysicalDevice GetPhysicalDevice() const; inline bool IsExtensionLoaded(const String& extensionName); inline bool IsLayerLoaded(const String& layerName); @@ -190,6 +191,7 @@ namespace Nz Instance& m_instance; VkAllocationCallbacks m_allocator; VkDevice m_device; + VkPhysicalDevice m_physicalDevice; VkResult m_lastErrorCode; std::unordered_set m_loadedExtensions; std::unordered_set m_loadedLayers; diff --git a/include/Nazara/Vulkan/VkDevice.inl b/include/Nazara/Vulkan/VkDevice.inl index 332012679..29309536e 100644 --- a/include/Nazara/Vulkan/VkDevice.inl +++ b/include/Nazara/Vulkan/VkDevice.inl @@ -59,6 +59,11 @@ namespace Nz return m_lastErrorCode; } + inline VkPhysicalDevice Device::GetPhysicalDevice() const + { + return m_physicalDevice; + } + inline bool Device::IsExtensionLoaded(const String& extensionName) { return m_loadedExtensions.count(extensionName) > 0; From 405e87329471dcba2cae5a525e821f77f3981c19 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 13 Jun 2016 19:53:46 +0200 Subject: [PATCH 006/316] Vulkan: Make device objects take a DeviceHandle at creation Former-commit-id: 0c9724fac593d562dd0ef6fbdf10b2cad9494ac7 [formerly 05c1e582989afde033ac6cee4def19859246167b] Former-commit-id: 4730597d196d8841c395a1cfe101bca70caa4a5e --- include/Nazara/Vulkan/VkCommandBuffer.inl | 8 ++++---- include/Nazara/Vulkan/VkCommandPool.hpp | 8 ++++---- include/Nazara/Vulkan/VkCommandPool.inl | 19 +++++++---------- include/Nazara/Vulkan/VkDevice.inl | 8 ++++---- include/Nazara/Vulkan/VkDeviceObject.hpp | 9 ++++---- include/Nazara/Vulkan/VkDeviceObject.inl | 16 +++++---------- include/Nazara/Vulkan/VkQueue.hpp | 6 +++--- include/Nazara/Vulkan/VkQueue.inl | 12 +++++------ include/Nazara/Vulkan/VkSemaphore.hpp | 8 ++++---- include/Nazara/Vulkan/VkSemaphore.inl | 17 ++++++--------- include/Nazara/Vulkan/VkSwapchain.hpp | 8 ++++---- include/Nazara/Vulkan/VkSwapchain.inl | 25 +++++++++-------------- 12 files changed, 61 insertions(+), 83 deletions(-) diff --git a/include/Nazara/Vulkan/VkCommandBuffer.inl b/include/Nazara/Vulkan/VkCommandBuffer.inl index d2d6f50d7..c1d0ec9bc 100644 --- a/include/Nazara/Vulkan/VkCommandBuffer.inl +++ b/include/Nazara/Vulkan/VkCommandBuffer.inl @@ -2,7 +2,7 @@ // 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 @@ -33,7 +33,7 @@ namespace Nz inline bool CommandBuffer::Begin(const VkCommandBufferBeginInfo& info) { - m_lastErrorCode = m_pool->GetDevice().vkBeginCommandBuffer(m_handle, &info); + m_lastErrorCode = m_pool->GetDevice()->vkBeginCommandBuffer(m_handle, &info); if (m_lastErrorCode != VkResult::VK_SUCCESS) { NazaraError("Failed to begin command buffer"); @@ -119,7 +119,7 @@ namespace Nz inline bool CommandBuffer::End() { - m_lastErrorCode = m_pool->GetDevice().vkEndCommandBuffer(m_handle); + m_lastErrorCode = m_pool->GetDevice()->vkEndCommandBuffer(m_handle); if (m_lastErrorCode != VkResult::VK_SUCCESS) { NazaraError("Failed to end command buffer"); @@ -132,7 +132,7 @@ namespace Nz inline void CommandBuffer::Free() { if (m_handle) - m_pool->GetDevice().vkFreeCommandBuffers(m_pool->GetDevice(), *m_pool, 1, &m_handle); + m_pool->GetDevice()->vkFreeCommandBuffers(*m_pool->GetDevice(), *m_pool, 1, &m_handle); } inline VkResult CommandBuffer::GetLastErrorCode() const diff --git a/include/Nazara/Vulkan/VkCommandPool.hpp b/include/Nazara/Vulkan/VkCommandPool.hpp index b51061bb2..1884e2b6c 100644 --- a/include/Nazara/Vulkan/VkCommandPool.hpp +++ b/include/Nazara/Vulkan/VkCommandPool.hpp @@ -25,7 +25,7 @@ namespace Nz friend DeviceObject; public: - inline CommandPool(Device& instance); + CommandPool() = default; CommandPool(const CommandPool&) = delete; CommandPool(CommandPool&&) = default; ~CommandPool() = default; @@ -34,7 +34,7 @@ namespace Nz std::vector AllocateCommandBuffers(UInt32 commandBufferCount, VkCommandBufferLevel level); using DeviceObject::Create; - inline bool Create(UInt32 queueFamilyIndex, VkCommandPoolCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(const DeviceHandle& device, UInt32 queueFamilyIndex, VkCommandPoolCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); inline bool Reset(VkCommandPoolResetFlags flags); @@ -42,8 +42,8 @@ namespace Nz 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); + static inline VkResult CreateHelper(const DeviceHandle& device, const VkCommandPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkCommandPool* handle); + static inline void DestroyHelper(const DeviceHandle& device, VkCommandPool handle, const VkAllocationCallbacks* allocator); }; } } diff --git a/include/Nazara/Vulkan/VkCommandPool.inl b/include/Nazara/Vulkan/VkCommandPool.inl index 61cfeaa43..b47b3481f 100644 --- a/include/Nazara/Vulkan/VkCommandPool.inl +++ b/include/Nazara/Vulkan/VkCommandPool.inl @@ -11,12 +11,7 @@ namespace Nz { namespace Vk { - inline CommandPool::CommandPool(Device& device) : - DeviceObject(device) - { - } - - inline bool CommandPool::Create(UInt32 queueFamilyIndex, VkCommandPoolCreateFlags flags, const VkAllocationCallbacks* allocator) + inline bool CommandPool::Create(const DeviceHandle& device, UInt32 queueFamilyIndex, VkCommandPoolCreateFlags flags, const VkAllocationCallbacks* allocator) { VkCommandPoolCreateInfo createInfo = { @@ -26,26 +21,26 @@ namespace Nz queueFamilyIndex }; - return Create(createInfo, allocator); + return Create(device, createInfo, allocator); } inline bool CommandPool::Reset(VkCommandPoolResetFlags flags) { - m_lastErrorCode = m_device.vkResetCommandPool(m_device, m_handle, 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) + inline VkResult CommandPool::CreateHelper(const DeviceHandle& device, const VkCommandPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkCommandPool* handle) { - return device.vkCreateCommandPool(device, createInfo, allocator, handle); + return device->vkCreateCommandPool(*device, createInfo, allocator, handle); } - inline void CommandPool::DestroyHelper(Device& device, VkCommandPool handle, const VkAllocationCallbacks* allocator) + inline void CommandPool::DestroyHelper(const DeviceHandle& device, VkCommandPool handle, const VkAllocationCallbacks* allocator) { - return device.vkDestroyCommandPool(device, handle, allocator); + return device->vkDestroyCommandPool(*device, handle, allocator); } } } diff --git a/include/Nazara/Vulkan/VkDevice.inl b/include/Nazara/Vulkan/VkDevice.inl index 81b784ae2..a42bd8a87 100644 --- a/include/Nazara/Vulkan/VkDevice.inl +++ b/include/Nazara/Vulkan/VkDevice.inl @@ -14,7 +14,7 @@ namespace Nz { inline Device::Device(Instance& instance) : m_instance(instance), - m_device(nullptr) + m_device(VK_NULL_HANDLE), { } @@ -25,12 +25,12 @@ namespace Nz inline void Device::Destroy() { - if (m_device) + if (m_device != VK_NULL_HANDLE) { vkDeviceWaitIdle(m_device); vkDestroyDevice(m_device, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); - m_device = nullptr; + m_device = VK_NULL_HANDLE; } } @@ -39,7 +39,7 @@ namespace Nz VkQueue queue; vkGetDeviceQueue(m_device, queueFamilyIndex, queueIndex, &queue); - return Queue(*this, queue); + return Queue(CreateHandle(), queue); } inline Instance& Device::GetInstance() diff --git a/include/Nazara/Vulkan/VkDeviceObject.hpp b/include/Nazara/Vulkan/VkDeviceObject.hpp index dd9da38c9..49d70171f 100644 --- a/include/Nazara/Vulkan/VkDeviceObject.hpp +++ b/include/Nazara/Vulkan/VkDeviceObject.hpp @@ -19,16 +19,15 @@ namespace Nz class DeviceObject { public: - inline DeviceObject(Device& instance); + inline DeviceObject(); DeviceObject(const DeviceObject&) = delete; DeviceObject(DeviceObject&&); inline ~DeviceObject(); - inline bool Create(const CreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(const DeviceHandle& device, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); inline void Destroy(); - inline Device& GetDevice(); - inline const Device& GetDevice() const; + inline const DeviceHandle& GetDevice() const; inline VkResult GetLastErrorCode() const; DeviceObject& operator=(const DeviceObject&) = delete; @@ -37,7 +36,7 @@ namespace Nz inline operator VkType(); protected: - Device& m_device; + DeviceHandle m_device; VkAllocationCallbacks m_allocator; VkType m_handle; VkResult m_lastErrorCode; diff --git a/include/Nazara/Vulkan/VkDeviceObject.inl b/include/Nazara/Vulkan/VkDeviceObject.inl index 24499a7d0..8bd9eebe6 100644 --- a/include/Nazara/Vulkan/VkDeviceObject.inl +++ b/include/Nazara/Vulkan/VkDeviceObject.inl @@ -12,15 +12,14 @@ namespace Nz namespace Vk { template - inline DeviceObject::DeviceObject(Device& device) : - m_device(device), + inline DeviceObject::DeviceObject() : m_handle(VK_NULL_HANDLE) { } template inline DeviceObject::DeviceObject(DeviceObject&& object) : - m_device(object.m_device), + m_device(std::move(object.m_device)), m_allocator(object.m_allocator), m_handle(object.m_handle), m_lastErrorCode(object.m_lastErrorCode) @@ -35,8 +34,9 @@ namespace Nz } template - inline bool DeviceObject::Create(const CreateInfo& createInfo, const VkAllocationCallbacks* allocator) + inline bool DeviceObject::Create(const DeviceHandle& device, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator) { + m_device = device; m_lastErrorCode = C::CreateHelper(m_device, &createInfo, allocator, &m_handle); if (m_lastErrorCode != VkResult::VK_SUCCESS) { @@ -64,13 +64,7 @@ namespace Nz } template - inline Device& DeviceObject::GetDevice() - { - return m_device; - } - - template - inline const Device& DeviceObject::GetDevice() const + inline const DeviceHandle& DeviceObject::GetDevice() const { return m_device; } diff --git a/include/Nazara/Vulkan/VkQueue.hpp b/include/Nazara/Vulkan/VkQueue.hpp index 35c8d16e0..b6253bc32 100644 --- a/include/Nazara/Vulkan/VkQueue.hpp +++ b/include/Nazara/Vulkan/VkQueue.hpp @@ -18,12 +18,12 @@ namespace Nz class Queue { public: - inline Queue(Device& device, VkQueue queue); + inline Queue(const DeviceHandle& device, VkQueue queue); inline Queue(const Queue& queue); inline Queue(Queue&& queue); inline ~Queue() = default; - inline Device& GetDevice(); + inline const DeviceHandle& GetDevice() const; inline VkResult GetLastErrorCode() const; inline bool Present(const VkPresentInfoKHR& presentInfo); @@ -40,7 +40,7 @@ namespace Nz inline operator VkQueue(); protected: - Device& m_device; + DeviceHandle m_device; VkQueue m_handle; VkResult m_lastErrorCode; }; diff --git a/include/Nazara/Vulkan/VkQueue.inl b/include/Nazara/Vulkan/VkQueue.inl index a47918da3..89273958f 100644 --- a/include/Nazara/Vulkan/VkQueue.inl +++ b/include/Nazara/Vulkan/VkQueue.inl @@ -2,7 +2,7 @@ // 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 @@ -11,7 +11,7 @@ namespace Nz { namespace Vk { - inline Queue::Queue(Device& device, VkQueue queue) : + inline Queue::Queue(const DeviceHandle& device, VkQueue queue) : m_device(device), m_handle(queue), m_lastErrorCode(VkResult::VK_SUCCESS) @@ -32,7 +32,7 @@ namespace Nz { } - inline Device& Queue::GetDevice() + inline const DeviceHandle& Queue::GetDevice() const { return m_device; } @@ -44,7 +44,7 @@ namespace Nz inline bool Queue::Present(const VkPresentInfoKHR& presentInfo) { - m_lastErrorCode = m_device.vkQueuePresentKHR(m_handle, &presentInfo); + m_lastErrorCode = m_device->vkQueuePresentKHR(m_handle, &presentInfo); if (m_lastErrorCode != VkResult::VK_SUCCESS) return false; @@ -75,7 +75,7 @@ namespace Nz inline bool Queue::Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence fence) { - m_lastErrorCode = m_device.vkQueueSubmit(m_handle, submitCount, submits, fence); + m_lastErrorCode = m_device->vkQueueSubmit(m_handle, submitCount, submits, fence); if (m_lastErrorCode != VkResult::VK_SUCCESS) return false; @@ -84,7 +84,7 @@ namespace Nz inline bool Queue::WaitIdle() { - m_lastErrorCode = m_device.vkQueueWaitIdle(m_handle); + m_lastErrorCode = m_device->vkQueueWaitIdle(m_handle); if (m_lastErrorCode != VkResult::VK_SUCCESS) return false; diff --git a/include/Nazara/Vulkan/VkSemaphore.hpp b/include/Nazara/Vulkan/VkSemaphore.hpp index 138d726be..9fdd7d191 100644 --- a/include/Nazara/Vulkan/VkSemaphore.hpp +++ b/include/Nazara/Vulkan/VkSemaphore.hpp @@ -19,20 +19,20 @@ namespace Nz friend DeviceObject; public: - inline Semaphore(Device& instance); + Semaphore() = default; Semaphore(const Semaphore&) = delete; Semaphore(Semaphore&&) = default; ~Semaphore() = default; using DeviceObject::Create; - inline bool Create(VkSemaphoreCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(const DeviceHandle& device, 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); + static VkResult CreateHelper(const DeviceHandle& device, const VkSemaphoreCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSemaphore* handle); + static void DestroyHelper(const DeviceHandle& device, VkSemaphore handle, const VkAllocationCallbacks* allocator); }; } } diff --git a/include/Nazara/Vulkan/VkSemaphore.inl b/include/Nazara/Vulkan/VkSemaphore.inl index fd2bf3427..b423fd4c0 100644 --- a/include/Nazara/Vulkan/VkSemaphore.inl +++ b/include/Nazara/Vulkan/VkSemaphore.inl @@ -9,12 +9,7 @@ namespace Nz { namespace Vk { - inline Semaphore::Semaphore(Device& device) : - DeviceObject(device) - { - } - - inline bool Semaphore::Create(VkSemaphoreCreateFlags flags, const VkAllocationCallbacks* allocator) + inline bool Semaphore::Create(const DeviceHandle& device, VkSemaphoreCreateFlags flags, const VkAllocationCallbacks* allocator) { VkSemaphoreCreateInfo createInfo = { @@ -23,17 +18,17 @@ namespace Nz flags }; - return Create(createInfo, allocator); + return Create(device, createInfo, allocator); } - VkResult Semaphore::CreateHelper(Device& device, const VkSemaphoreCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSemaphore* handle) + VkResult Semaphore::CreateHelper(const DeviceHandle& device, const VkSemaphoreCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSemaphore* handle) { - return device.vkCreateSemaphore(device, createInfo, allocator, handle); + return device->vkCreateSemaphore(*device, createInfo, allocator, handle); } - void Semaphore::DestroyHelper(Device& device, VkSemaphore handle, const VkAllocationCallbacks* allocator) + void Semaphore::DestroyHelper(const DeviceHandle& device, VkSemaphore handle, const VkAllocationCallbacks* allocator) { - return device.vkDestroySemaphore(device, handle, allocator); + return device->vkDestroySemaphore(*device, handle, allocator); } } } diff --git a/include/Nazara/Vulkan/VkSwapchain.hpp b/include/Nazara/Vulkan/VkSwapchain.hpp index 374ad88e6..fbe8d2118 100644 --- a/include/Nazara/Vulkan/VkSwapchain.hpp +++ b/include/Nazara/Vulkan/VkSwapchain.hpp @@ -19,14 +19,14 @@ namespace Nz friend DeviceObject; public: - inline Swapchain(Device& instance); + Swapchain() = default; 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 bool Create(const DeviceHandle& device, const VkSwapchainCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); inline VkImage GetImage(UInt32 index) const; inline const std::vector& GetImages() const; @@ -38,8 +38,8 @@ namespace Nz 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); + static VkResult CreateHelper(const DeviceHandle& device, const VkSwapchainCreateInfoKHR* createInfo, const VkAllocationCallbacks* allocator, VkSwapchainKHR* handle); + static void DestroyHelper(const DeviceHandle& device, VkSwapchainKHR handle, const VkAllocationCallbacks* allocator); std::vector m_images; }; diff --git a/include/Nazara/Vulkan/VkSwapchain.inl b/include/Nazara/Vulkan/VkSwapchain.inl index 8865012e4..e1f885045 100644 --- a/include/Nazara/Vulkan/VkSwapchain.inl +++ b/include/Nazara/Vulkan/VkSwapchain.inl @@ -11,14 +11,9 @@ 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); + m_lastErrorCode = m_device->vkAcquireNextImageKHR(*m_device, m_handle, timeout, semaphore, fence, imageIndex); switch (m_lastErrorCode) { case VkResult::VK_SUBOPTIMAL_KHR: @@ -30,13 +25,13 @@ namespace Nz } } - inline bool Swapchain::Create(const VkSwapchainCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) + inline bool Swapchain::Create(const DeviceHandle& device, const VkSwapchainCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) { - if (!DeviceObject::Create(createInfo, allocator)) + if (!DeviceObject::Create(device, createInfo, allocator)) return false; UInt32 imageCount = 0; - m_lastErrorCode = m_device.vkGetSwapchainImagesKHR(m_device, m_handle, &imageCount, nullptr); + 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"); @@ -44,7 +39,7 @@ namespace Nz } m_images.resize(imageCount); - m_lastErrorCode = m_device.vkGetSwapchainImagesKHR(m_device, m_handle, &imageCount, m_images.data()); + 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"); @@ -71,18 +66,18 @@ namespace Nz inline bool Swapchain::IsSupported() const { - if (!m_device.IsExtensionLoaded("VK_KHR_swapchain")) + if (!m_device->IsExtensionLoaded("VK_KHR_swapchain")) return false; } - VkResult Swapchain::CreateHelper(Device& device, const VkSwapchainCreateInfoKHR* createInfo, const VkAllocationCallbacks* allocator, VkSwapchainKHR* handle) + VkResult Swapchain::CreateHelper(const DeviceHandle& device, const VkSwapchainCreateInfoKHR* createInfo, const VkAllocationCallbacks* allocator, VkSwapchainKHR* handle) { - return device.vkCreateSwapchainKHR(device, createInfo, allocator, handle); + return device->vkCreateSwapchainKHR(*device, createInfo, allocator, handle); } - void Swapchain::DestroyHelper(Device& device, VkSwapchainKHR handle, const VkAllocationCallbacks* allocator) + void Swapchain::DestroyHelper(const DeviceHandle& device, VkSwapchainKHR handle, const VkAllocationCallbacks* allocator) { - return device.vkDestroySwapchainKHR(device, handle, allocator); + return device->vkDestroySwapchainKHR(*device, handle, allocator); } } } From 113f99e2d1ca4ddc9484d9bd6b509f4ed61bf23c Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 13 Jun 2016 19:54:20 +0200 Subject: [PATCH 007/316] Vulkan/Surface: Make surface queriers const Former-commit-id: 960e80d25be4d7260eaec5d6cb47b1f4fa0f0dc3 [formerly 3b95cbb32b29f15765d2388afd3d6158ce2756dd] Former-commit-id: e1ffdc3b2ae7d113641f000beba6ce36543cf2f3 --- include/Nazara/Vulkan/VkSurface.hpp | 10 +++++----- include/Nazara/Vulkan/VkSurface.inl | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/Nazara/Vulkan/VkSurface.hpp b/include/Nazara/Vulkan/VkSurface.hpp index 03a57d2fe..53cb7fd5e 100644 --- a/include/Nazara/Vulkan/VkSurface.hpp +++ b/include/Nazara/Vulkan/VkSurface.hpp @@ -64,10 +64,10 @@ namespace Nz 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); + bool GetCapabilities(VkPhysicalDevice physicalDevice, VkSurfaceCapabilitiesKHR* surfaceCapabilities) const; + bool GetFormats(VkPhysicalDevice physicalDevice, std::vector* surfaceFormats) const; + bool GetPresentModes(VkPhysicalDevice physicalDevice, std::vector* presentModes) const; + bool GetSupportPresentation(VkPhysicalDevice physicalDevice, UInt32 queueFamilyIndex, bool* supported) const; inline bool IsSupported() const; @@ -84,7 +84,7 @@ namespace Nz Instance& m_instance; VkAllocationCallbacks m_allocator; VkSurfaceKHR m_surface; - VkResult m_lastErrorCode; + mutable VkResult m_lastErrorCode; }; } } diff --git a/include/Nazara/Vulkan/VkSurface.inl b/include/Nazara/Vulkan/VkSurface.inl index a79d9c65d..81b199d08 100644 --- a/include/Nazara/Vulkan/VkSurface.inl +++ b/include/Nazara/Vulkan/VkSurface.inl @@ -176,7 +176,7 @@ namespace Nz return m_lastErrorCode; } - inline bool Surface::GetCapabilities(VkPhysicalDevice physicalDevice, VkSurfaceCapabilitiesKHR* surfaceCapabilities) + inline bool Surface::GetCapabilities(VkPhysicalDevice physicalDevice, VkSurfaceCapabilitiesKHR* surfaceCapabilities) const { m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice, m_surface, surfaceCapabilities); if (m_lastErrorCode != VkResult::VK_SUCCESS) @@ -188,7 +188,7 @@ namespace Nz return true; } - inline bool Surface::GetFormats(VkPhysicalDevice physicalDevice, std::vector* surfaceFormats) + inline bool Surface::GetFormats(VkPhysicalDevice physicalDevice, std::vector* surfaceFormats) const { // First, query format count UInt32 surfaceCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t @@ -211,7 +211,7 @@ namespace Nz return true; } - inline bool Surface::GetPresentModes(VkPhysicalDevice physicalDevice, std::vector* presentModes) + inline bool Surface::GetPresentModes(VkPhysicalDevice physicalDevice, std::vector* presentModes) const { // First, query present modes count UInt32 presentModeCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t @@ -234,7 +234,7 @@ namespace Nz return true; } - inline bool Surface::GetSupportPresentation(VkPhysicalDevice physicalDevice, UInt32 queueFamilyIndex, bool* supported) + inline bool Surface::GetSupportPresentation(VkPhysicalDevice physicalDevice, UInt32 queueFamilyIndex, bool* supported) const { VkBool32 presentationSupported = VK_FALSE; m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfaceSupportKHR(physicalDevice, queueFamilyIndex, m_surface, &presentationSupported); From c0d8beb11b22d11acd2364bf8c78e5f2ac5a7831 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 13 Jun 2016 19:54:53 +0200 Subject: [PATCH 008/316] Forgot file Former-commit-id: 00488f8e71b9dc9127884e9bffae8dc8895fc589 [formerly 7401cef459b75700ed17e2374c9f564da7a233cf] Former-commit-id: 19b700504bb69f895694705d8a8168ad53f8d239 --- src/Nazara/Vulkan/VkCommandPool.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Vulkan/VkCommandPool.cpp b/src/Nazara/Vulkan/VkCommandPool.cpp index 3ee53ab6f..e50904848 100644 --- a/src/Nazara/Vulkan/VkCommandPool.cpp +++ b/src/Nazara/Vulkan/VkCommandPool.cpp @@ -22,7 +22,7 @@ namespace Nz }; VkCommandBuffer handle = VK_NULL_HANDLE; - m_lastErrorCode = m_device.vkAllocateCommandBuffers(m_device, &createInfo, &handle); + m_lastErrorCode = m_device->vkAllocateCommandBuffers(*m_device, &createInfo, &handle); return CommandBuffer(*this, handle); } @@ -39,7 +39,7 @@ namespace Nz }; std::vector handles(commandBufferCount, VK_NULL_HANDLE); - m_lastErrorCode = m_device.vkAllocateCommandBuffers(m_device, &createInfo, handles.data()); + m_lastErrorCode = m_device->vkAllocateCommandBuffers(*m_device, &createInfo, handles.data()); if (m_lastErrorCode != VkResult::VK_SUCCESS) return std::vector(); From c28995bc88e54426452f13ba52ead3b9b9ac9952 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 13 Jun 2016 19:55:26 +0200 Subject: [PATCH 009/316] Vulkan/Device: Add queue infos Former-commit-id: 36a260b1efa0f443b1c22c21060adbc7ff23a10f [formerly a9c073dfae57cde2c3b175c5f70e2fa47976bd82] Former-commit-id: a14c9a5283579dff978fffcca660e4974bf8e58d --- include/Nazara/Vulkan/VkDevice.hpp | 13 +++++++++++++ include/Nazara/Vulkan/VkDevice.inl | 5 +++++ src/Nazara/Vulkan/VkDevice.cpp | 26 ++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/include/Nazara/Vulkan/VkDevice.hpp b/include/Nazara/Vulkan/VkDevice.hpp index 1b9d3a470..680b8c998 100644 --- a/include/Nazara/Vulkan/VkDevice.hpp +++ b/include/Nazara/Vulkan/VkDevice.hpp @@ -27,6 +27,8 @@ namespace Nz class NAZARA_VULKAN_API Device : public HandledObject { public: + struct QueueFamilyInfo; + inline Device(Instance& instance); Device(const Device&) = delete; Device(Device&&) = delete; @@ -35,6 +37,7 @@ namespace Nz bool Create(VkPhysicalDevice device, const VkDeviceCreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); inline void Destroy(); + inline const std::vector& GetEnabledQueues() const; inline Queue GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex); inline Instance& GetInstance(); inline const Instance& GetInstance() const; @@ -184,6 +187,15 @@ namespace Nz #undef NAZARA_VULKAN_DEVICE_FUNCTION + struct QueueFamilyInfo + { + std::vector queues; + VkExtent3D minImageTransferGranularity; + VkQueueFlags flags; + UInt32 familyIndex; + UInt32 timestampValidBits; + }; + private: inline PFN_vkVoidFunction GetProcAddr(const char* name); @@ -193,6 +205,7 @@ namespace Nz VkResult m_lastErrorCode; std::unordered_set m_loadedExtensions; std::unordered_set m_loadedLayers; + std::vector m_enabledQueuesInfos; }; } } diff --git a/include/Nazara/Vulkan/VkDevice.inl b/include/Nazara/Vulkan/VkDevice.inl index a42bd8a87..f6fded6f5 100644 --- a/include/Nazara/Vulkan/VkDevice.inl +++ b/include/Nazara/Vulkan/VkDevice.inl @@ -34,6 +34,11 @@ namespace Nz } } + inline const std::vector& Device::GetEnabledQueues() const + { + return m_enabledQueuesInfos; + } + inline Queue Device::GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex) { VkQueue queue; diff --git a/src/Nazara/Vulkan/VkDevice.cpp b/src/Nazara/Vulkan/VkDevice.cpp index c2f39da76..73f6f6bdb 100644 --- a/src/Nazara/Vulkan/VkDevice.cpp +++ b/src/Nazara/Vulkan/VkDevice.cpp @@ -13,6 +13,13 @@ namespace Nz { bool Device::Create(VkPhysicalDevice device, const VkDeviceCreateInfo& createInfo, const VkAllocationCallbacks* allocator) { + std::vector queuesProperties; + if (!m_instance.GetPhysicalDeviceQueueFamilyProperties(device, &queuesProperties)) + { + NazaraError("Failed to query queue family properties"); + return false; + } + m_lastErrorCode = m_instance.vkCreateDevice(device, &createInfo, allocator, &m_device); if (m_lastErrorCode != VkResult::VK_SUCCESS) { @@ -33,6 +40,25 @@ namespace Nz for (UInt32 i = 0; i < createInfo.enabledLayerCount; ++i) m_loadedLayers.insert(createInfo.ppEnabledLayerNames[i]); + // And retains informations about queues + m_enabledQueuesInfos.resize(createInfo.queueCreateInfoCount); + for (UInt32 i = 0; i < createInfo.queueCreateInfoCount; ++i) + { + const VkDeviceQueueCreateInfo& queueCreateInfo = createInfo.pQueueCreateInfos[i]; + QueueFamilyInfo& info = m_enabledQueuesInfos[i]; + + info.familyIndex = queueCreateInfo.queueFamilyIndex; + + const VkQueueFamilyProperties& queueProperties = queuesProperties[info.familyIndex]; + info.flags = queueProperties.queueFlags; + info.minImageTransferGranularity = queueProperties.minImageTransferGranularity; + info.timestampValidBits = queueProperties.timestampValidBits; + + info.queues.resize(queueCreateInfo.queueCount); + for (UInt32 queueCount = 0; queueCount < queueCreateInfo.queueCount; ++queueCount) + info.queues[queueCount] = queueCreateInfo.pQueuePriorities[queueCount]; + } + #define NAZARA_VULKAN_LOAD_DEVICE(func) func = reinterpret_cast(GetProcAddr(#func)) try From 26e2f57c35914c6872bd1223f8175b6b28098b40 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 13 Jun 2016 19:55:42 +0200 Subject: [PATCH 010/316] Vulkan/Device: Add GetPhysicalDevice() Former-commit-id: 720b4a1a94e751ee70f9554173c600efb0cc1218 [formerly 0f3e615d1393dff4eb1c809a6ccf08ed6f384ccd] Former-commit-id: e84e98542b4ba69cf5c97a8cf4d76f4f9e9ae63f --- include/Nazara/Vulkan/VkDevice.hpp | 2 ++ include/Nazara/Vulkan/VkDevice.inl | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/include/Nazara/Vulkan/VkDevice.hpp b/include/Nazara/Vulkan/VkDevice.hpp index 680b8c998..a78b0ced5 100644 --- a/include/Nazara/Vulkan/VkDevice.hpp +++ b/include/Nazara/Vulkan/VkDevice.hpp @@ -42,6 +42,7 @@ namespace Nz inline Instance& GetInstance(); inline const Instance& GetInstance() const; inline VkResult GetLastErrorCode() const; + inline VkPhysicalDevice GetPhysicalDevice() const; inline bool IsExtensionLoaded(const String& extensionName); inline bool IsLayerLoaded(const String& layerName); @@ -202,6 +203,7 @@ namespace Nz Instance& m_instance; VkAllocationCallbacks m_allocator; VkDevice m_device; + VkPhysicalDevice m_physicalDevice; VkResult m_lastErrorCode; std::unordered_set m_loadedExtensions; std::unordered_set m_loadedLayers; diff --git a/include/Nazara/Vulkan/VkDevice.inl b/include/Nazara/Vulkan/VkDevice.inl index f6fded6f5..f97b06c13 100644 --- a/include/Nazara/Vulkan/VkDevice.inl +++ b/include/Nazara/Vulkan/VkDevice.inl @@ -15,6 +15,7 @@ namespace Nz inline Device::Device(Instance& instance) : m_instance(instance), m_device(VK_NULL_HANDLE), + m_physicalDevice(VK_NULL_HANDLE) { } @@ -31,6 +32,7 @@ namespace Nz vkDestroyDevice(m_device, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); m_device = VK_NULL_HANDLE; + m_physicalDevice = VK_NULL_HANDLE; } } @@ -62,6 +64,11 @@ namespace Nz return m_lastErrorCode; } + inline VkPhysicalDevice Device::GetPhysicalDevice() const + { + return m_physicalDevice; + } + inline bool Device::IsExtensionLoaded(const String& extensionName) { return m_loadedExtensions.count(extensionName) > 0; From a91085550de6aa49b853acf62f741a0ee96163cf Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 13 Jun 2016 19:56:38 +0200 Subject: [PATCH 011/316] Vulkan: Add CreateDevice/SelectDevice functions Former-commit-id: bb15b0f93fbc5a21c83178f13738976159044d9a [formerly 98145969e963560d9677ad24683189847511b5e6] Former-commit-id: 90348ef452c507387377c609bbb238d735342973 --- include/Nazara/Vulkan/Vulkan.hpp | 7 ++ src/Nazara/Vulkan/Vulkan.cpp | 124 +++++++++++++++++++++++++++++++ 2 files changed, 131 insertions(+) diff --git a/include/Nazara/Vulkan/Vulkan.hpp b/include/Nazara/Vulkan/Vulkan.hpp index 59c1bb4f3..97a58d7ee 100644 --- a/include/Nazara/Vulkan/Vulkan.hpp +++ b/include/Nazara/Vulkan/Vulkan.hpp @@ -11,7 +11,9 @@ #include #include #include +#include #include +#include namespace Nz { @@ -21,17 +23,22 @@ namespace Nz Vulkan() = delete; ~Vulkan() = delete; + static Vk::Device& CreateDevice(VkPhysicalDevice gpu, const Vk::Surface& surface, UInt32* presentableFamilyQueue); + static Vk::Instance& GetInstance(); static bool Initialize(); static bool IsInitialized(); + static Vk::Device& SelectDevice(VkPhysicalDevice gpu, const Vk::Surface& surface, UInt32* presentableFamilyQueue); + static void SetParameters(const ParameterList& parameters); static void Uninitialize(); private: + static std::list s_devices; static Vk::Instance s_instance; static ParameterList s_initializationParameters; static unsigned int s_moduleReferenceCounter; diff --git a/src/Nazara/Vulkan/Vulkan.cpp b/src/Nazara/Vulkan/Vulkan.cpp index dc7a201ff..4f8fd7c51 100644 --- a/src/Nazara/Vulkan/Vulkan.cpp +++ b/src/Nazara/Vulkan/Vulkan.cpp @@ -5,9 +5,11 @@ #include #include #include +#include #include #include #include +#include #include namespace Nz @@ -156,6 +158,127 @@ namespace Nz return s_moduleReferenceCounter != 0; } + Vk::Device& Vulkan::CreateDevice(VkPhysicalDevice gpu, const Vk::Surface& surface, UInt32* presentableFamilyQueue) + { + Nz::ErrorFlags errFlags(ErrorFlag_ThrowException, true); + + std::vector queueFamilies; + s_instance.GetPhysicalDeviceQueueFamilyProperties(gpu, &queueFamilies); + + // Find a queue that supports graphics operations + UInt32 graphicsQueueNodeIndex = UINT32_MAX; + UInt32 presentQueueNodeIndex = UINT32_MAX; + UInt32 transfertQueueNodeFamily = UINT32_MAX; + for (UInt32 i = 0; i < queueFamilies.size(); i++) + { + bool supportPresentation = false; + if (!surface.GetSupportPresentation(gpu, i, &supportPresentation)) + NazaraWarning("Failed to get presentation support of queue family #" + String::Number(i)); + + if (queueFamilies[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) + { + if (graphicsQueueNodeIndex == UINT32_MAX) + graphicsQueueNodeIndex = i; + + if (supportPresentation) + { + graphicsQueueNodeIndex = i; + presentQueueNodeIndex = i; + break; + } + } + else if (supportPresentation) + presentQueueNodeIndex = i; + } + + for (UInt32 i = 0; i < queueFamilies.size(); i++) + { + if (queueFamilies[i].queueFlags & VK_QUEUE_TRANSFER_BIT) + { + transfertQueueNodeFamily = i; + if (transfertQueueNodeFamily != graphicsQueueNodeIndex) + break; + } + } + + std::array usedQueueFamilies = {graphicsQueueNodeIndex, presentQueueNodeIndex, transfertQueueNodeFamily}; + float priority = 1.f; + + std::vector queueCreateInfos; + for (UInt32 queueFamily : usedQueueFamilies) + { + VkDeviceQueueCreateInfo createInfo = { + VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, + nullptr, + 0, + queueFamily, + 1, + &priority + }; + + queueCreateInfos.emplace_back(createInfo); + } + + std::array enabledExtensions = {VK_KHR_SWAPCHAIN_EXTENSION_NAME}; + std::array enabledLayers; + + VkDeviceCreateInfo createInfo = { + VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, + nullptr, + 0, + UInt32(queueCreateInfos.size()), + queueCreateInfos.data(), + UInt32(enabledLayers.size()), + enabledLayers.data(), + UInt32(enabledLayers.size()), + enabledLayers.data(), + nullptr + }; + + ///TODO: First create then move + s_devices.emplace_back(s_instance); + + Vk::Device& device = s_devices.back(); + device.Create(gpu, createInfo); + + *presentableFamilyQueue = presentQueueNodeIndex; + + return device; + } + + Vk::Device& Vulkan::SelectDevice(VkPhysicalDevice gpu, const Vk::Surface& surface, UInt32* presentableFamilyQueue) + { + // First, try to find a device compatible with that surface + for (Vk::Device& device : s_devices) + { + if (device.GetPhysicalDevice() == gpu) + { + const std::vector& queueFamilyInfo = device.GetEnabledQueues(); + UInt32 presentableQueueFamilyIndex = UINT32_MAX; + for (Vk::Device::QueueFamilyInfo queueInfo : queueFamilyInfo) + { + bool supported = false; + if (surface.GetSupportPresentation(gpu, queueInfo.familyIndex, &supported) && supported) + { + if (presentableQueueFamilyIndex == UINT32_MAX || queueInfo.flags & VK_QUEUE_GRAPHICS_BIT) + { + presentableQueueFamilyIndex = queueInfo.familyIndex; + if (queueInfo.flags & VK_QUEUE_GRAPHICS_BIT) + break; + } + } + } + + if (presentableQueueFamilyIndex != UINT32_MAX) + *presentableFamilyQueue = presentableQueueFamilyIndex; + } + } + + // No device had support for that surface, create one + return CreateDevice(gpu, surface, presentableFamilyQueue); + + } + void Vulkan::SetParameters(const ParameterList& parameters) { s_initializationParameters = parameters; @@ -185,6 +308,7 @@ namespace Nz Utility::Uninitialize(); } + std::list Vulkan::s_devices; Vk::Instance Vulkan::s_instance; ParameterList Vulkan::s_initializationParameters; unsigned int Vulkan::s_moduleReferenceCounter = 0; From 4c501320b8e1acf2caf91ff11aab55c2cb1e2b4f Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 13 Jun 2016 22:29:16 +0200 Subject: [PATCH 012/316] Vulkan: Make implicit conversion work on const Former-commit-id: f4ed2fb536c1cd49b786a7cc2f0db1b23888a24b [formerly 8fa97e865fb2e8cf9c3725fedee07eee3ff3ba0a] Former-commit-id: 4fbf84f1d35d008769750a3675fc9daa85bbe3cd --- include/Nazara/Vulkan/VkDeviceObject.hpp | 2 +- include/Nazara/Vulkan/VkDeviceObject.inl | 2 +- include/Nazara/Vulkan/VkSurface.hpp | 2 +- include/Nazara/Vulkan/VkSurface.inl | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/Nazara/Vulkan/VkDeviceObject.hpp b/include/Nazara/Vulkan/VkDeviceObject.hpp index 49d70171f..210980a17 100644 --- a/include/Nazara/Vulkan/VkDeviceObject.hpp +++ b/include/Nazara/Vulkan/VkDeviceObject.hpp @@ -33,7 +33,7 @@ namespace Nz DeviceObject& operator=(const DeviceObject&) = delete; DeviceObject& operator=(DeviceObject&&) = delete; - inline operator VkType(); + inline operator VkType() const; protected: DeviceHandle m_device; diff --git a/include/Nazara/Vulkan/VkDeviceObject.inl b/include/Nazara/Vulkan/VkDeviceObject.inl index 8bd9eebe6..ab08688bd 100644 --- a/include/Nazara/Vulkan/VkDeviceObject.inl +++ b/include/Nazara/Vulkan/VkDeviceObject.inl @@ -76,7 +76,7 @@ namespace Nz } template - inline DeviceObject::operator VkType() + inline DeviceObject::operator VkType() const { return m_handle; } diff --git a/include/Nazara/Vulkan/VkSurface.hpp b/include/Nazara/Vulkan/VkSurface.hpp index 53cb7fd5e..b4d6a019d 100644 --- a/include/Nazara/Vulkan/VkSurface.hpp +++ b/include/Nazara/Vulkan/VkSurface.hpp @@ -76,7 +76,7 @@ namespace Nz Surface& operator=(const Surface&) = delete; Surface& operator=(Surface&&) = delete; - inline operator VkSurfaceKHR(); + inline operator VkSurfaceKHR() const; private: inline bool Create(const VkAllocationCallbacks* allocator); diff --git a/include/Nazara/Vulkan/VkSurface.inl b/include/Nazara/Vulkan/VkSurface.inl index 81b199d08..dec897cec 100644 --- a/include/Nazara/Vulkan/VkSurface.inl +++ b/include/Nazara/Vulkan/VkSurface.inl @@ -287,7 +287,7 @@ namespace Nz return false; } - inline Surface::operator VkSurfaceKHR() + inline Surface::operator VkSurfaceKHR() const { return m_surface; } From 6531f6028a212dc888e2e9b4cc04d06992fba99b Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 13 Jun 2016 22:29:44 +0200 Subject: [PATCH 013/316] Vulkan: Fix crashs Former-commit-id: feb7e2a90be95b16cabe2777fc24ce7899525cb8 [formerly 8dfbc95cb7828e1767d9cf850f3de17c6d88c02f] Former-commit-id: af32212fb81b9a96b7cc001916e269144778d74f --- include/Nazara/Vulkan/Vulkan.hpp | 4 ++-- src/Nazara/Vulkan/Vulkan.cpp | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/Nazara/Vulkan/Vulkan.hpp b/include/Nazara/Vulkan/Vulkan.hpp index 97a58d7ee..d5667ce95 100644 --- a/include/Nazara/Vulkan/Vulkan.hpp +++ b/include/Nazara/Vulkan/Vulkan.hpp @@ -23,7 +23,7 @@ namespace Nz Vulkan() = delete; ~Vulkan() = delete; - static Vk::Device& CreateDevice(VkPhysicalDevice gpu, const Vk::Surface& surface, UInt32* presentableFamilyQueue); + static Vk::DeviceHandle CreateDevice(VkPhysicalDevice gpu, const Vk::Surface& surface, UInt32* presentableFamilyQueue); static Vk::Instance& GetInstance(); @@ -31,7 +31,7 @@ namespace Nz static bool IsInitialized(); - static Vk::Device& SelectDevice(VkPhysicalDevice gpu, const Vk::Surface& surface, UInt32* presentableFamilyQueue); + static Vk::DeviceHandle SelectDevice(VkPhysicalDevice gpu, const Vk::Surface& surface, UInt32* presentableFamilyQueue); static void SetParameters(const ParameterList& parameters); diff --git a/src/Nazara/Vulkan/Vulkan.cpp b/src/Nazara/Vulkan/Vulkan.cpp index 4f8fd7c51..d8062907b 100644 --- a/src/Nazara/Vulkan/Vulkan.cpp +++ b/src/Nazara/Vulkan/Vulkan.cpp @@ -158,7 +158,7 @@ namespace Nz return s_moduleReferenceCounter != 0; } - Vk::Device& Vulkan::CreateDevice(VkPhysicalDevice gpu, const Vk::Surface& surface, UInt32* presentableFamilyQueue) + Vk::DeviceHandle Vulkan::CreateDevice(VkPhysicalDevice gpu, const Vk::Surface& surface, UInt32* presentableFamilyQueue) { Nz::ErrorFlags errFlags(ErrorFlag_ThrowException, true); @@ -230,8 +230,8 @@ namespace Nz queueCreateInfos.data(), UInt32(enabledLayers.size()), enabledLayers.data(), - UInt32(enabledLayers.size()), - enabledLayers.data(), + UInt32(enabledExtensions.size()), + enabledExtensions.data(), nullptr }; @@ -243,10 +243,10 @@ namespace Nz *presentableFamilyQueue = presentQueueNodeIndex; - return device; + return device.CreateHandle(); } - Vk::Device& Vulkan::SelectDevice(VkPhysicalDevice gpu, const Vk::Surface& surface, UInt32* presentableFamilyQueue) + Vk::DeviceHandle Vulkan::SelectDevice(VkPhysicalDevice gpu, const Vk::Surface& surface, UInt32* presentableFamilyQueue) { // First, try to find a device compatible with that surface for (Vk::Device& device : s_devices) @@ -276,7 +276,6 @@ namespace Nz // No device had support for that surface, create one return CreateDevice(gpu, surface, presentableFamilyQueue); - } void Vulkan::SetParameters(const ParameterList& parameters) @@ -298,6 +297,7 @@ namespace Nz s_moduleReferenceCounter = 0; // Uninitialize module here + s_devices.clear(); s_instance.Destroy(); Vk::Loader::Uninitialize(); From e332f2f77eb162a29c1064c15e7a5fbb646add35 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 17 Jun 2016 18:12:19 +0200 Subject: [PATCH 014/316] Vulkan/Swapchain: Make Acquire Next Image constant Former-commit-id: 54d3fde63a01b138b8d391d9e318c618e69c5eed [formerly c44a46a3ca62d65f3279bd44f1647996fd03b38e] Former-commit-id: 25bf025b3853879b0eee577ad4bb7ffe9a96fd4a --- include/Nazara/Vulkan/VkDeviceObject.hpp | 2 +- include/Nazara/Vulkan/VkSwapchain.hpp | 2 +- include/Nazara/Vulkan/VkSwapchain.inl | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/Nazara/Vulkan/VkDeviceObject.hpp b/include/Nazara/Vulkan/VkDeviceObject.hpp index 210980a17..afa6a4c55 100644 --- a/include/Nazara/Vulkan/VkDeviceObject.hpp +++ b/include/Nazara/Vulkan/VkDeviceObject.hpp @@ -39,7 +39,7 @@ namespace Nz DeviceHandle m_device; VkAllocationCallbacks m_allocator; VkType m_handle; - VkResult m_lastErrorCode; + mutable VkResult m_lastErrorCode; }; } } diff --git a/include/Nazara/Vulkan/VkSwapchain.hpp b/include/Nazara/Vulkan/VkSwapchain.hpp index fbe8d2118..b55fad75e 100644 --- a/include/Nazara/Vulkan/VkSwapchain.hpp +++ b/include/Nazara/Vulkan/VkSwapchain.hpp @@ -24,7 +24,7 @@ namespace Nz Swapchain(Swapchain&&) = default; ~Swapchain() = default; - inline bool AcquireNextImage(Nz::UInt64 timeout, VkSemaphore semaphore, VkFence fence, UInt32* imageIndex); + inline bool AcquireNextImage(Nz::UInt64 timeout, VkSemaphore semaphore, VkFence fence, UInt32* imageIndex) const; inline bool Create(const DeviceHandle& device, const VkSwapchainCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); diff --git a/include/Nazara/Vulkan/VkSwapchain.inl b/include/Nazara/Vulkan/VkSwapchain.inl index e1f885045..32842d700 100644 --- a/include/Nazara/Vulkan/VkSwapchain.inl +++ b/include/Nazara/Vulkan/VkSwapchain.inl @@ -11,7 +11,7 @@ namespace Nz { namespace Vk { - inline bool Swapchain::AcquireNextImage(Nz::UInt64 timeout, VkSemaphore semaphore, VkFence fence, UInt32* imageIndex) + inline bool Swapchain::AcquireNextImage(Nz::UInt64 timeout, VkSemaphore semaphore, VkFence fence, UInt32* imageIndex) const { m_lastErrorCode = m_device->vkAcquireNextImageKHR(*m_device, m_handle, timeout, semaphore, fence, imageIndex); switch (m_lastErrorCode) From 1634311008326c3d988115d1afeb1ad5a19ad7bb Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 17 Jun 2016 18:12:38 +0200 Subject: [PATCH 015/316] Vulkan/Device: Allow to specify additionnal layers and extensions Former-commit-id: adad0618a4a7a93c246cc97297e69601ee7af24c [formerly e8a833ff02f357280d80910c5f983d379054f82a] Former-commit-id: d2cf201e725836a709b2c633ea5c1c155e9bbc4f --- src/Nazara/Vulkan/Vulkan.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Vulkan/Vulkan.cpp b/src/Nazara/Vulkan/Vulkan.cpp index d8062907b..f97cc635f 100644 --- a/src/Nazara/Vulkan/Vulkan.cpp +++ b/src/Nazara/Vulkan/Vulkan.cpp @@ -219,8 +219,31 @@ namespace Nz queueCreateInfos.emplace_back(createInfo); } - std::array enabledExtensions = {VK_KHR_SWAPCHAIN_EXTENSION_NAME}; - std::array enabledLayers; + + std::vector enabledLayers; + std::vector enabledExtensions; + + bool bParam; + if (!s_initializationParameters.GetBooleanParameter("VkDeviceInfo_OverrideEnabledExtensions", &bParam) || !bParam) + enabledExtensions.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME); + + int iParam; + std::vector additionalExtensions; // Just to keep the String alive + if (s_initializationParameters.GetIntegerParameter("VkDeviceInfo_EnabledExtensionCount", &iParam)) + { + for (int i = 0; i < iParam; ++i) + { + Nz::String parameterName = "VkDeviceInfo_EnabledExtension" + String::Number(i); + Nz::String extension; + if (s_initializationParameters.GetStringParameter(parameterName, &extension)) + { + additionalExtensions.emplace_back(std::move(extension)); + enabledExtensions.push_back(additionalExtensions.back().GetConstBuffer()); + } + else + NazaraWarning("Parameter " + parameterName + " expected"); + } + } VkDeviceCreateInfo createInfo = { VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, From a6f223a396141f384082cc3fa24b1dc7c04a4537 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 19 Jun 2016 15:30:35 +0200 Subject: [PATCH 016/316] Vulkan/Swapchain: Fix warnings Former-commit-id: 0f3511c6b678ad52c36880ae00c7dc39c78a259c [formerly 1ae9834f0f30ef38f7c8fbcb6b3d8b0f29a78ae8] Former-commit-id: 1cccb7159f6a4da20a48b9f7c7b01a709549a2dc --- include/Nazara/Vulkan/VkSwapchain.inl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Vulkan/VkSwapchain.inl b/include/Nazara/Vulkan/VkSwapchain.inl index 32842d700..6d31012a5 100644 --- a/include/Nazara/Vulkan/VkSwapchain.inl +++ b/include/Nazara/Vulkan/VkSwapchain.inl @@ -61,13 +61,15 @@ namespace Nz inline UInt32 Swapchain::GetImageCount() const { - return m_images.size(); + return static_cast(m_images.size()); } inline bool Swapchain::IsSupported() const { if (!m_device->IsExtensionLoaded("VK_KHR_swapchain")) return false; + + return true; } VkResult Swapchain::CreateHelper(const DeviceHandle& device, const VkSwapchainCreateInfoKHR* createInfo, const VkAllocationCallbacks* allocator, VkSwapchainKHR* handle) From 7d73f0dcadf5637c6041b602096fef8155a146ba Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 19 Jun 2016 15:31:53 +0200 Subject: [PATCH 017/316] Vulkan: Add physical device retrieval Former-commit-id: 5c0e8256123fcfe5d3563b224bdcc11efa645fd3 [formerly cecb3404e98b1be4a5176fe27c1dec533e16701a] Former-commit-id: a2fa7f6d96e3fe6f43af97b5c882d939a947fb9a --- include/Nazara/Vulkan/VkPhysicalDevice.hpp | 28 +++++++++++++++ include/Nazara/Vulkan/Vulkan.hpp | 6 ++++ src/Nazara/Vulkan/Vulkan.cpp | 41 ++++++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 include/Nazara/Vulkan/VkPhysicalDevice.hpp diff --git a/include/Nazara/Vulkan/VkPhysicalDevice.hpp b/include/Nazara/Vulkan/VkPhysicalDevice.hpp new file mode 100644 index 000000000..e62a9e684 --- /dev/null +++ b/include/Nazara/Vulkan/VkPhysicalDevice.hpp @@ -0,0 +1,28 @@ +// 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_VKPHYSICALDEVICE_HPP +#define NAZARA_VULKAN_VKPHYSICALDEVICE_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + struct PhysicalDevice + { + VkPhysicalDevice device; + VkPhysicalDeviceFeatures features; + VkPhysicalDeviceMemoryProperties memoryProperties; + VkPhysicalDeviceProperties properties; + std::vector queues; + }; + } +} + +#endif // NAZARA_VULKAN_VKPHYSICALDEVICE_HPP diff --git a/include/Nazara/Vulkan/Vulkan.hpp b/include/Nazara/Vulkan/Vulkan.hpp index d5667ce95..289a1b225 100644 --- a/include/Nazara/Vulkan/Vulkan.hpp +++ b/include/Nazara/Vulkan/Vulkan.hpp @@ -13,7 +13,10 @@ #include #include #include +#include #include +#include +#include namespace Nz { @@ -27,6 +30,8 @@ namespace Nz static Vk::Instance& GetInstance(); + static const std::vector& GetPhysicalDevices(); + static bool Initialize(); static bool IsInitialized(); @@ -39,6 +44,7 @@ namespace Nz private: static std::list s_devices; + static std::vector s_physDevices; static Vk::Instance s_instance; static ParameterList s_initializationParameters; static unsigned int s_moduleReferenceCounter; diff --git a/src/Nazara/Vulkan/Vulkan.cpp b/src/Nazara/Vulkan/Vulkan.cpp index f97cc635f..d73e2e21f 100644 --- a/src/Nazara/Vulkan/Vulkan.cpp +++ b/src/Nazara/Vulkan/Vulkan.cpp @@ -19,6 +19,11 @@ namespace Nz return s_instance; } + const std::vector& Vulkan::GetPhysicalDevices() + { + return s_physDevices; + } + bool Vulkan::Initialize() { if (s_moduleReferenceCounter > 0) @@ -147,6 +152,41 @@ namespace Nz return false; } + std::vector physDevices; + if (!s_instance.EnumeratePhysicalDevices(&physDevices)) + { + NazaraError("Failed to enumerate physical devices"); + return false; + } + + s_physDevices.reserve(physDevices.size()); + + for (std::size_t i = 0; i < physDevices.size(); ++i) + { + VkPhysicalDevice physDevice = physDevices[i]; + + Vk::PhysicalDevice deviceInfo; + if (!s_instance.GetPhysicalDeviceQueueFamilyProperties(physDevice, &deviceInfo.queues)) + { + NazaraWarning("Failed to query physical device queue family properties"); + continue; + } + + deviceInfo.device = physDevice; + + s_instance.GetPhysicalDeviceFeatures(physDevice, &deviceInfo.features); + s_instance.GetPhysicalDeviceMemoryProperties(physDevice, &deviceInfo.memoryProperties); + s_instance.GetPhysicalDeviceProperties(physDevice, &deviceInfo.properties); + + s_physDevices.emplace_back(std::move(deviceInfo)); + } + + if (s_physDevices.empty()) + { + NazaraError("No valid physical device found"); + return false; + } + onExit.Reset(); NazaraNotice("Initialized: Vulkan module"); @@ -332,6 +372,7 @@ namespace Nz } std::list Vulkan::s_devices; + std::vector Vulkan::s_physDevices; Vk::Instance Vulkan::s_instance; ParameterList Vulkan::s_initializationParameters; unsigned int Vulkan::s_moduleReferenceCounter = 0; From 7146ebcfbead97c6f5de9ca008659eb37970962a Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 4 Jul 2016 18:12:40 +0200 Subject: [PATCH 018/316] Vulkan/CommandPool: Fix mistake when allocating more than one command buffer Former-commit-id: 4cef29ea951e13e7b59ebf7f5f77a9d41a5f8b59 [formerly af52c81fb32875ef38fda0b86316010770ed2362] Former-commit-id: e88d9d327c3909cae49f78589c42218e79d5eed1 --- src/Nazara/Vulkan/VkCommandPool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Vulkan/VkCommandPool.cpp b/src/Nazara/Vulkan/VkCommandPool.cpp index e50904848..443920b3c 100644 --- a/src/Nazara/Vulkan/VkCommandPool.cpp +++ b/src/Nazara/Vulkan/VkCommandPool.cpp @@ -35,7 +35,7 @@ namespace Nz nullptr, m_handle, level, - 1U + commandBufferCount }; std::vector handles(commandBufferCount, VK_NULL_HANDLE); From 070251110826f5f382fec5aa036cac3aa19187d5 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 4 Jul 2016 18:13:51 +0200 Subject: [PATCH 019/316] Vulkan: Add Framebuffer, ImageView, Pipeline, PipelineCache, PipelineLayout, RenderPass and ShaderModule wrappers Former-commit-id: fc1269a25704d1b19192062277a3593a3e39a239 [formerly 5235f84349ba6edced65db7c60800b9b52ff1a16] Former-commit-id: 74e6cfc61f87d61e69ca20f2fd6187c2cd48c44a --- include/Nazara/Vulkan/VkFramebuffer.hpp | 39 ++++++++++ include/Nazara/Vulkan/VkFramebuffer.inl | 24 ++++++ include/Nazara/Vulkan/VkImageView.hpp | 39 ++++++++++ include/Nazara/Vulkan/VkImageView.inl | 24 ++++++ include/Nazara/Vulkan/VkPipeline.hpp | 50 +++++++++++++ include/Nazara/Vulkan/VkPipeline.inl | 85 ++++++++++++++++++++++ include/Nazara/Vulkan/VkPipelineCache.hpp | 39 ++++++++++ include/Nazara/Vulkan/VkPipelineCache.inl | 24 ++++++ include/Nazara/Vulkan/VkPipelineLayout.hpp | 39 ++++++++++ include/Nazara/Vulkan/VkPipelineLayout.inl | 24 ++++++ include/Nazara/Vulkan/VkRenderPass.hpp | 39 ++++++++++ include/Nazara/Vulkan/VkRenderPass.inl | 24 ++++++ include/Nazara/Vulkan/VkShaderModule.hpp | 42 +++++++++++ include/Nazara/Vulkan/VkShaderModule.inl | 38 ++++++++++ 14 files changed, 530 insertions(+) create mode 100644 include/Nazara/Vulkan/VkFramebuffer.hpp create mode 100644 include/Nazara/Vulkan/VkFramebuffer.inl create mode 100644 include/Nazara/Vulkan/VkImageView.hpp create mode 100644 include/Nazara/Vulkan/VkImageView.inl create mode 100644 include/Nazara/Vulkan/VkPipeline.hpp create mode 100644 include/Nazara/Vulkan/VkPipeline.inl create mode 100644 include/Nazara/Vulkan/VkPipelineCache.hpp create mode 100644 include/Nazara/Vulkan/VkPipelineCache.inl create mode 100644 include/Nazara/Vulkan/VkPipelineLayout.hpp create mode 100644 include/Nazara/Vulkan/VkPipelineLayout.inl create mode 100644 include/Nazara/Vulkan/VkRenderPass.hpp create mode 100644 include/Nazara/Vulkan/VkRenderPass.inl create mode 100644 include/Nazara/Vulkan/VkShaderModule.hpp create mode 100644 include/Nazara/Vulkan/VkShaderModule.inl diff --git a/include/Nazara/Vulkan/VkFramebuffer.hpp b/include/Nazara/Vulkan/VkFramebuffer.hpp new file mode 100644 index 000000000..9c93674b6 --- /dev/null +++ b/include/Nazara/Vulkan/VkFramebuffer.hpp @@ -0,0 +1,39 @@ +// 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_VKFRAMEBUFFER_HPP +#define NAZARA_VULKAN_VKFRAMEBUFFER_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class Framebuffer : public DeviceObject + { + friend DeviceObject; + + public: + Framebuffer() = default; + Framebuffer(const Framebuffer&) = delete; + Framebuffer(Framebuffer&&) = default; + ~Framebuffer() = default; + + Framebuffer& operator=(const Framebuffer&) = delete; + Framebuffer& operator=(Framebuffer&&) = delete; + + private: + static inline VkResult CreateHelper(const DeviceHandle& device, const VkFramebufferCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkFramebuffer* handle); + static inline void DestroyHelper(const DeviceHandle& device, VkFramebuffer handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_VULKAN_VKFRAMEBUFFER_HPP diff --git a/include/Nazara/Vulkan/VkFramebuffer.inl b/include/Nazara/Vulkan/VkFramebuffer.inl new file mode 100644 index 000000000..67790caa9 --- /dev/null +++ b/include/Nazara/Vulkan/VkFramebuffer.inl @@ -0,0 +1,24 @@ +// 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 VkResult Framebuffer::CreateHelper(const DeviceHandle& device, const VkFramebufferCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkFramebuffer* handle) + { + return device->vkCreateFramebuffer(*device, createInfo, allocator, handle); + } + + inline void Framebuffer::DestroyHelper(const DeviceHandle& device, VkFramebuffer handle, const VkAllocationCallbacks* allocator) + { + return device->vkDestroyFramebuffer(*device, handle, allocator); + } + } +} + +#include diff --git a/include/Nazara/Vulkan/VkImageView.hpp b/include/Nazara/Vulkan/VkImageView.hpp new file mode 100644 index 000000000..783477182 --- /dev/null +++ b/include/Nazara/Vulkan/VkImageView.hpp @@ -0,0 +1,39 @@ +// 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_VKIMAGEVIEW_HPP +#define NAZARA_VULKAN_VKIMAGEVIEW_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class ImageView : public DeviceObject + { + friend DeviceObject; + + public: + ImageView() = default; + ImageView(const ImageView&) = delete; + ImageView(ImageView&&) = default; + ~ImageView() = default; + + ImageView& operator=(const ImageView&) = delete; + ImageView& operator=(ImageView&&) = delete; + + private: + static inline VkResult CreateHelper(const DeviceHandle& device, const VkImageViewCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkImageView* handle); + static inline void DestroyHelper(const DeviceHandle& device, VkImageView handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_VULKAN_VKIMAGEVIEW_HPP diff --git a/include/Nazara/Vulkan/VkImageView.inl b/include/Nazara/Vulkan/VkImageView.inl new file mode 100644 index 000000000..ca7617b6e --- /dev/null +++ b/include/Nazara/Vulkan/VkImageView.inl @@ -0,0 +1,24 @@ +// 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 VkResult ImageView::CreateHelper(const DeviceHandle& device, const VkImageViewCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkImageView* handle) + { + return device->vkCreateImageView(*device, createInfo, allocator, handle); + } + + inline void ImageView::DestroyHelper(const DeviceHandle& device, VkImageView handle, const VkAllocationCallbacks* allocator) + { + return device->vkDestroyImageView(*device, handle, allocator); + } + } +} + +#include diff --git a/include/Nazara/Vulkan/VkPipeline.hpp b/include/Nazara/Vulkan/VkPipeline.hpp new file mode 100644 index 000000000..f788e4f70 --- /dev/null +++ b/include/Nazara/Vulkan/VkPipeline.hpp @@ -0,0 +1,50 @@ +// 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_VKPIPELINE_HPP +#define NAZARA_VULKAN_VKPIPELINE_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class Pipeline + { + public: + inline Pipeline(); + Pipeline(const Pipeline&) = delete; + Pipeline(Pipeline&&); + inline ~Pipeline(); + + inline bool CreateCompute(const DeviceHandle& device, const VkComputePipelineCreateInfo& createInfo, VkPipelineCache cache = VK_NULL_HANDLE, const VkAllocationCallbacks* allocator = nullptr); + inline bool CreateGraphics(const DeviceHandle& device, const VkGraphicsPipelineCreateInfo& createInfo, VkPipelineCache cache = VK_NULL_HANDLE, const VkAllocationCallbacks* allocator = nullptr); + inline void Destroy(); + + inline const DeviceHandle& GetDevice() const; + inline VkResult GetLastErrorCode() const; + + Pipeline& operator=(const Pipeline&) = delete; + Pipeline& operator=(Pipeline&&) = delete; + + inline operator VkPipeline() const; + + protected: + inline bool Create(const DeviceHandle& device, VkResult result, const VkAllocationCallbacks* allocator); + + DeviceHandle m_device; + VkAllocationCallbacks m_allocator; + VkPipeline m_handle; + mutable VkResult m_lastErrorCode; + }; + } +} + +#include + +#endif // NAZARA_VULKAN_VKPIPELINE_HPP diff --git a/include/Nazara/Vulkan/VkPipeline.inl b/include/Nazara/Vulkan/VkPipeline.inl new file mode 100644 index 000000000..4325c5f78 --- /dev/null +++ b/include/Nazara/Vulkan/VkPipeline.inl @@ -0,0 +1,85 @@ +// 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 Pipeline::Pipeline() : + m_handle(VK_NULL_HANDLE) + { + } + + inline Pipeline::Pipeline(Pipeline&& object) : + m_device(std::move(object.m_device)), + m_allocator(object.m_allocator), + m_handle(object.m_handle), + m_lastErrorCode(object.m_lastErrorCode) + { + object.m_handle = VK_NULL_HANDLE; + } + + inline Pipeline::~Pipeline() + { + Destroy(); + } + + inline bool Pipeline::CreateCompute(const DeviceHandle& device, const VkComputePipelineCreateInfo& createInfo, VkPipelineCache cache, const VkAllocationCallbacks* allocator) + { + return Create(device, device->vkCreateComputePipelines(*device, cache, 1U, &createInfo, allocator, &m_handle), allocator); + } + + inline bool Pipeline::CreateGraphics(const DeviceHandle& device, const VkGraphicsPipelineCreateInfo& createInfo, VkPipelineCache cache, const VkAllocationCallbacks* allocator) + { + return Create(device, device->vkCreateGraphicsPipelines(*device, cache, 1U, &createInfo, allocator, &m_handle), allocator); + } + + inline void Pipeline::Destroy() + { + if (m_handle != VK_NULL_HANDLE) + { + m_device->vkDestroyPipeline(*m_device, m_handle, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); + m_handle = VK_NULL_HANDLE; + } + } + + inline const DeviceHandle& Pipeline::GetDevice() const + { + return m_device; + } + + inline VkResult Pipeline::GetLastErrorCode() const + { + return m_lastErrorCode; + } + + inline Pipeline::operator VkPipeline() const + { + return m_handle; + } + + inline bool Pipeline::Create(const DeviceHandle& device, VkResult result, const VkAllocationCallbacks* allocator) + { + m_device = device; + 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; + } + } +} + +#include diff --git a/include/Nazara/Vulkan/VkPipelineCache.hpp b/include/Nazara/Vulkan/VkPipelineCache.hpp new file mode 100644 index 000000000..1dac25ce1 --- /dev/null +++ b/include/Nazara/Vulkan/VkPipelineCache.hpp @@ -0,0 +1,39 @@ +// 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_VKPIPELINECACHE_HPP +#define NAZARA_VULKAN_VKPIPELINECACHE_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class PipelineCache : public DeviceObject + { + friend DeviceObject; + + public: + PipelineCache() = default; + PipelineCache(const PipelineCache&) = delete; + PipelineCache(PipelineCache&&) = default; + ~PipelineCache() = default; + + PipelineCache& operator=(const PipelineCache&) = delete; + PipelineCache& operator=(PipelineCache&&) = delete; + + private: + static inline VkResult CreateHelper(const DeviceHandle& device, const VkPipelineCacheCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkPipelineCache* handle); + static inline void DestroyHelper(const DeviceHandle& device, VkPipelineCache handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_VULKAN_VKPIPELINECACHE_HPP diff --git a/include/Nazara/Vulkan/VkPipelineCache.inl b/include/Nazara/Vulkan/VkPipelineCache.inl new file mode 100644 index 000000000..9f272c41d --- /dev/null +++ b/include/Nazara/Vulkan/VkPipelineCache.inl @@ -0,0 +1,24 @@ +// 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 VkResult PipelineCache::CreateHelper(const DeviceHandle& device, const VkPipelineCacheCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkPipelineCache* handle) + { + return device->vkCreatePipelineCache(*device, createInfo, allocator, handle); + } + + inline void PipelineCache::DestroyHelper(const DeviceHandle& device, VkPipelineCache handle, const VkAllocationCallbacks* allocator) + { + return device->vkDestroyPipelineCache(*device, handle, allocator); + } + } +} + +#include diff --git a/include/Nazara/Vulkan/VkPipelineLayout.hpp b/include/Nazara/Vulkan/VkPipelineLayout.hpp new file mode 100644 index 000000000..0d78fa23d --- /dev/null +++ b/include/Nazara/Vulkan/VkPipelineLayout.hpp @@ -0,0 +1,39 @@ +// 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_VKPIPELINELAYOUT_HPP +#define NAZARA_VULKAN_VKPIPELINELAYOUT_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class PipelineLayout : public DeviceObject + { + friend DeviceObject; + + public: + PipelineLayout() = default; + PipelineLayout(const PipelineLayout&) = delete; + PipelineLayout(PipelineLayout&&) = default; + ~PipelineLayout() = default; + + PipelineLayout& operator=(const PipelineLayout&) = delete; + PipelineLayout& operator=(PipelineLayout&&) = delete; + + private: + static inline VkResult CreateHelper(const DeviceHandle& device, const VkPipelineLayoutCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkPipelineLayout* handle); + static inline void DestroyHelper(const DeviceHandle& device, VkPipelineLayout handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_VULKAN_VKPIPELINELAYOUT_HPP diff --git a/include/Nazara/Vulkan/VkPipelineLayout.inl b/include/Nazara/Vulkan/VkPipelineLayout.inl new file mode 100644 index 000000000..468bf7b0f --- /dev/null +++ b/include/Nazara/Vulkan/VkPipelineLayout.inl @@ -0,0 +1,24 @@ +// 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 VkResult PipelineLayout::CreateHelper(const DeviceHandle& device, const VkPipelineLayoutCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkPipelineLayout* handle) + { + return device->vkCreatePipelineLayout(*device, createInfo, allocator, handle); + } + + inline void PipelineLayout::DestroyHelper(const DeviceHandle& device, VkPipelineLayout handle, const VkAllocationCallbacks* allocator) + { + return device->vkDestroyPipelineLayout(*device, handle, allocator); + } + } +} + +#include diff --git a/include/Nazara/Vulkan/VkRenderPass.hpp b/include/Nazara/Vulkan/VkRenderPass.hpp new file mode 100644 index 000000000..92ab4f868 --- /dev/null +++ b/include/Nazara/Vulkan/VkRenderPass.hpp @@ -0,0 +1,39 @@ +// 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_VKRENDERPASS_HPP +#define NAZARA_VULKAN_VKRENDERPASS_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class RenderPass : public DeviceObject + { + friend DeviceObject; + + public: + RenderPass() = default; + RenderPass(const RenderPass&) = delete; + RenderPass(RenderPass&&) = default; + ~RenderPass() = default; + + RenderPass& operator=(const RenderPass&) = delete; + RenderPass& operator=(RenderPass&&) = delete; + + private: + static inline VkResult CreateHelper(const DeviceHandle& device, const VkRenderPassCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkRenderPass* handle); + static inline void DestroyHelper(const DeviceHandle& device, VkRenderPass handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_VULKAN_VKRENDERPASS_HPP diff --git a/include/Nazara/Vulkan/VkRenderPass.inl b/include/Nazara/Vulkan/VkRenderPass.inl new file mode 100644 index 000000000..5e826cba3 --- /dev/null +++ b/include/Nazara/Vulkan/VkRenderPass.inl @@ -0,0 +1,24 @@ +// 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 VkResult RenderPass::CreateHelper(const DeviceHandle& device, const VkRenderPassCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkRenderPass* handle) + { + return device->vkCreateRenderPass(*device, createInfo, allocator, handle); + } + + inline void RenderPass::DestroyHelper(const DeviceHandle& device, VkRenderPass handle, const VkAllocationCallbacks* allocator) + { + return device->vkDestroyRenderPass(*device, handle, allocator); + } + } +} + +#include diff --git a/include/Nazara/Vulkan/VkShaderModule.hpp b/include/Nazara/Vulkan/VkShaderModule.hpp new file mode 100644 index 000000000..588dc6a07 --- /dev/null +++ b/include/Nazara/Vulkan/VkShaderModule.hpp @@ -0,0 +1,42 @@ +// 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_VKSHADERMODULE_HPP +#define NAZARA_VULKAN_VKSHADERMODULE_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class ShaderModule : public DeviceObject + { + friend DeviceObject; + + public: + ShaderModule() = default; + ShaderModule(const ShaderModule&) = delete; + ShaderModule(ShaderModule&&) = default; + ~ShaderModule() = default; + + using DeviceObject::Create; + inline bool Create(const DeviceHandle& device, const UInt32* code, std::size_t size, VkShaderModuleCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + + ShaderModule& operator=(const ShaderModule&) = delete; + ShaderModule& operator=(ShaderModule&&) = delete; + + private: + static inline VkResult CreateHelper(const DeviceHandle& device, const VkShaderModuleCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkShaderModule* handle); + static inline void DestroyHelper(const DeviceHandle& device, VkShaderModule handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_VULKAN_VKSHADERMODULE_HPP diff --git a/include/Nazara/Vulkan/VkShaderModule.inl b/include/Nazara/Vulkan/VkShaderModule.inl new file mode 100644 index 000000000..77b189ba0 --- /dev/null +++ b/include/Nazara/Vulkan/VkShaderModule.inl @@ -0,0 +1,38 @@ +// 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 bool ShaderModule::Create(const DeviceHandle& device, const UInt32* code, std::size_t size, VkShaderModuleCreateFlags flags, const VkAllocationCallbacks* allocator) + { + VkShaderModuleCreateInfo createInfo = + { + VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO, + nullptr, + flags, + size, + code + }; + + return Create(device, createInfo, allocator); + } + + inline VkResult ShaderModule::CreateHelper(const DeviceHandle& device, const VkShaderModuleCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkShaderModule* handle) + { + return device->vkCreateShaderModule(*device, createInfo, allocator, handle); + } + + inline void ShaderModule::DestroyHelper(const DeviceHandle& device, VkShaderModule handle, const VkAllocationCallbacks* allocator) + { + return device->vkDestroyShaderModule(*device, handle, allocator); + } + } +} + +#include From 8bc7998b466588225c0b7691f991129861e5c773 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 4 Jul 2016 18:14:27 +0200 Subject: [PATCH 020/316] Vulkan/Swapchain: Make swapchain create imageview Former-commit-id: aba6fa6ca74eb1566d5203e12978c9be4731331e [formerly cb900a59afe3b8d9778a82b3302dc483b500083d] Former-commit-id: 5283d835a1560cbc6c5034563af262d8f33e6bfc --- include/Nazara/Vulkan/VkSwapchain.hpp | 23 ++++++++---- include/Nazara/Vulkan/VkSwapchain.inl | 54 ++++++++++++++++++++++----- 2 files changed, 60 insertions(+), 17 deletions(-) diff --git a/include/Nazara/Vulkan/VkSwapchain.hpp b/include/Nazara/Vulkan/VkSwapchain.hpp index b55fad75e..c19e365eb 100644 --- a/include/Nazara/Vulkan/VkSwapchain.hpp +++ b/include/Nazara/Vulkan/VkSwapchain.hpp @@ -9,6 +9,7 @@ #include #include +#include namespace Nz { @@ -19,6 +20,8 @@ namespace Nz friend DeviceObject; public: + struct Buffer; + Swapchain() = default; Swapchain(const Swapchain&) = delete; Swapchain(Swapchain&&) = default; @@ -28,20 +31,26 @@ namespace Nz inline bool Create(const DeviceHandle& device, const VkSwapchainCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); - inline VkImage GetImage(UInt32 index) const; - inline const std::vector& GetImages() const; - inline UInt32 GetImageCount() const; + inline const Buffer& GetBuffer(UInt32 index) const; + inline const std::vector& GetBuffers() const; + inline UInt32 GetBufferCount() const; inline bool IsSupported() const; Swapchain& operator=(const Swapchain&) = delete; Swapchain& operator=(Swapchain&&) = delete; - private: - static VkResult CreateHelper(const DeviceHandle& device, const VkSwapchainCreateInfoKHR* createInfo, const VkAllocationCallbacks* allocator, VkSwapchainKHR* handle); - static void DestroyHelper(const DeviceHandle& device, VkSwapchainKHR handle, const VkAllocationCallbacks* allocator); + struct Buffer + { + VkImage image; + ImageView view; + }; - std::vector m_images; + private: + static inline VkResult CreateHelper(const DeviceHandle& device, const VkSwapchainCreateInfoKHR* createInfo, const VkAllocationCallbacks* allocator, VkSwapchainKHR* handle); + static inline void DestroyHelper(const DeviceHandle& device, VkSwapchainKHR handle, const VkAllocationCallbacks* allocator); + + std::vector m_buffers; }; } } diff --git a/include/Nazara/Vulkan/VkSwapchain.inl b/include/Nazara/Vulkan/VkSwapchain.inl index 6d31012a5..c37e991d4 100644 --- a/include/Nazara/Vulkan/VkSwapchain.inl +++ b/include/Nazara/Vulkan/VkSwapchain.inl @@ -38,30 +38,64 @@ namespace Nz return false; } - m_images.resize(imageCount); - m_lastErrorCode = m_device->vkGetSwapchainImagesKHR(*m_device, m_handle, &imageCount, m_images.data()); + std::vector images(imageCount); + m_lastErrorCode = m_device->vkGetSwapchainImagesKHR(*m_device, m_handle, &imageCount, images.data()); if (m_lastErrorCode != VkResult::VK_SUCCESS) { NazaraError("Failed to query swapchain images"); return false; } + m_buffers.resize(imageCount); + for (UInt32 i = 0; i < imageCount; ++i) + { + m_buffers[i].image = images[i]; + + VkImageViewCreateInfo imageViewCreateInfo = { + VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + 0, // VkImageViewCreateFlags flags; + m_buffers[i].image, // VkImage image; + VK_IMAGE_VIEW_TYPE_2D, // VkImageViewType viewType; + createInfo.imageFormat, // VkFormat format; + { // VkComponentMapping components; + VK_COMPONENT_SWIZZLE_R, // VkComponentSwizzle .r; + VK_COMPONENT_SWIZZLE_G, // VkComponentSwizzle .g; + VK_COMPONENT_SWIZZLE_B, // VkComponentSwizzle .b; + VK_COMPONENT_SWIZZLE_A // VkComponentSwizzle .a; + }, + { // VkImageSubresourceRange subresourceRange; + VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags .aspectMask; + 0, // uint32_t .baseMipLevel; + 1, // uint32_t .levelCount; + 0, // uint32_t .baseArrayLayer; + 1 // uint32_t .layerCount; + } + }; + + if (!m_buffers[i].view.Create(m_device, imageViewCreateInfo)) + { + NazaraError("Failed to create image view for image #" + String::Number(i)); + return false; + } + } + return true; } - inline VkImage Swapchain::GetImage(UInt32 index) const + inline const Swapchain::Buffer& Swapchain::GetBuffer(UInt32 index) const { - return m_images[index]; + return m_buffers[index]; } - inline const std::vector& Swapchain::GetImages() const + inline const std::vector& Swapchain::GetBuffers() const { - return m_images; + return m_buffers; } - inline UInt32 Swapchain::GetImageCount() const + inline UInt32 Swapchain::GetBufferCount() const { - return static_cast(m_images.size()); + return static_cast(m_buffers.size()); } inline bool Swapchain::IsSupported() const @@ -72,12 +106,12 @@ namespace Nz return true; } - VkResult Swapchain::CreateHelper(const DeviceHandle& device, const VkSwapchainCreateInfoKHR* createInfo, const VkAllocationCallbacks* allocator, VkSwapchainKHR* handle) + inline VkResult Swapchain::CreateHelper(const DeviceHandle& device, const VkSwapchainCreateInfoKHR* createInfo, const VkAllocationCallbacks* allocator, VkSwapchainKHR* handle) { return device->vkCreateSwapchainKHR(*device, createInfo, allocator, handle); } - void Swapchain::DestroyHelper(const DeviceHandle& device, VkSwapchainKHR handle, const VkAllocationCallbacks* allocator) + inline void Swapchain::DestroyHelper(const DeviceHandle& device, VkSwapchainKHR handle, const VkAllocationCallbacks* allocator) { return device->vkDestroySwapchainKHR(*device, handle, allocator); } From 4ff36108b20f379cebc7e9996b54d76f497cab31 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 4 Jul 2016 18:14:40 +0200 Subject: [PATCH 021/316] Vulkan: Fix linking problem Former-commit-id: 8f4df471a2745a32e6b131a4bd83345bdb9b304e [formerly 479e6489039b511b08a63535845293a84460ed87] Former-commit-id: 064509430d76e54466709c3288db9443956759c9 --- include/Nazara/Vulkan/VkCommandBuffer.hpp | 9 +++++---- include/Nazara/Vulkan/VkCommandBuffer.inl | 21 ++++++++++++++++++++- include/Nazara/Vulkan/VkSemaphore.hpp | 4 ++-- include/Nazara/Vulkan/VkSemaphore.inl | 4 ++-- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/include/Nazara/Vulkan/VkCommandBuffer.hpp b/include/Nazara/Vulkan/VkCommandBuffer.hpp index 2dea341dd..67ec4f558 100644 --- a/include/Nazara/Vulkan/VkCommandBuffer.hpp +++ b/include/Nazara/Vulkan/VkCommandBuffer.hpp @@ -15,13 +15,14 @@ namespace Nz { namespace Vk { - class NAZARA_VULKAN_API CommandBuffer + class CommandBuffer { friend CommandPool; public: + inline CommandBuffer(); CommandBuffer(const CommandBuffer&) = delete; - CommandBuffer(CommandBuffer&& commandBuffer); + inline CommandBuffer(CommandBuffer&& commandBuffer); inline ~CommandBuffer(); inline bool Begin(const VkCommandBufferBeginInfo& info); @@ -37,9 +38,9 @@ namespace Nz inline VkResult GetLastErrorCode() const; CommandBuffer& operator=(const CommandBuffer&) = delete; - CommandBuffer& operator=(CommandBuffer&&) = delete; + CommandBuffer& operator=(CommandBuffer&& commandBuffer); - inline operator VkCommandBuffer(); + inline operator VkCommandBuffer() const; private: inline CommandBuffer(CommandPool& pool, VkCommandBuffer handle); diff --git a/include/Nazara/Vulkan/VkCommandBuffer.inl b/include/Nazara/Vulkan/VkCommandBuffer.inl index c1d0ec9bc..f3719b135 100644 --- a/include/Nazara/Vulkan/VkCommandBuffer.inl +++ b/include/Nazara/Vulkan/VkCommandBuffer.inl @@ -11,6 +11,12 @@ namespace Nz { namespace Vk { + inline CommandBuffer::CommandBuffer() : + m_pool(), + m_handle(VK_NULL_HANDLE) + { + } + inline CommandBuffer::CommandBuffer(CommandPool& pool, VkCommandBuffer handle) : m_pool(&pool), m_handle(handle) @@ -140,7 +146,20 @@ namespace Nz return m_lastErrorCode; } - inline CommandBuffer::operator VkCommandBuffer() + inline CommandBuffer& CommandBuffer::operator=(CommandBuffer&& commandBuffer) + { + m_allocator = commandBuffer.m_allocator; + m_handle = commandBuffer.m_handle; + m_lastErrorCode = commandBuffer.m_lastErrorCode; + m_pool = std::move(commandBuffer.m_pool); + m_handle = commandBuffer.m_handle; + + commandBuffer.m_handle = VK_NULL_HANDLE; + + return *this; + } + + inline CommandBuffer::operator VkCommandBuffer() const { return m_handle; } diff --git a/include/Nazara/Vulkan/VkSemaphore.hpp b/include/Nazara/Vulkan/VkSemaphore.hpp index 9fdd7d191..230a00983 100644 --- a/include/Nazara/Vulkan/VkSemaphore.hpp +++ b/include/Nazara/Vulkan/VkSemaphore.hpp @@ -31,8 +31,8 @@ namespace Nz Semaphore& operator=(Semaphore&&) = delete; private: - static VkResult CreateHelper(const DeviceHandle& device, const VkSemaphoreCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSemaphore* handle); - static void DestroyHelper(const DeviceHandle& device, VkSemaphore handle, const VkAllocationCallbacks* allocator); + static inline VkResult CreateHelper(const DeviceHandle& device, const VkSemaphoreCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSemaphore* handle); + static inline void DestroyHelper(const DeviceHandle& device, VkSemaphore handle, const VkAllocationCallbacks* allocator); }; } } diff --git a/include/Nazara/Vulkan/VkSemaphore.inl b/include/Nazara/Vulkan/VkSemaphore.inl index b423fd4c0..4744a12a9 100644 --- a/include/Nazara/Vulkan/VkSemaphore.inl +++ b/include/Nazara/Vulkan/VkSemaphore.inl @@ -21,12 +21,12 @@ namespace Nz return Create(device, createInfo, allocator); } - VkResult Semaphore::CreateHelper(const DeviceHandle& device, const VkSemaphoreCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSemaphore* handle) + inline VkResult Semaphore::CreateHelper(const DeviceHandle& device, const VkSemaphoreCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSemaphore* handle) { return device->vkCreateSemaphore(*device, createInfo, allocator, handle); } - void Semaphore::DestroyHelper(const DeviceHandle& device, VkSemaphore handle, const VkAllocationCallbacks* allocator) + inline void Semaphore::DestroyHelper(const DeviceHandle& device, VkSemaphore handle, const VkAllocationCallbacks* allocator) { return device->vkDestroySemaphore(*device, handle, allocator); } From a57b1781b6b93584f5d039d93644cc400d5ae576 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 4 Jul 2016 18:15:12 +0200 Subject: [PATCH 022/316] Vulkan/Device: Fix pipeline cache crash Former-commit-id: 70ddcabea8fa60597c4ab4898a79aedfed43b1ec [formerly 8a722dfbc97c8b8ff0ca957a8af2c1ffb14b8ffb] Former-commit-id: 86b119367a21f26384d640d8f80eb97f96cf6909 --- include/Nazara/Vulkan/VkDevice.hpp | 3 +++ src/Nazara/Vulkan/VkDevice.cpp | 2 ++ 2 files changed, 5 insertions(+) diff --git a/include/Nazara/Vulkan/VkDevice.hpp b/include/Nazara/Vulkan/VkDevice.hpp index a78b0ced5..4b861fe3b 100644 --- a/include/Nazara/Vulkan/VkDevice.hpp +++ b/include/Nazara/Vulkan/VkDevice.hpp @@ -38,6 +38,7 @@ namespace Nz inline void Destroy(); inline const std::vector& GetEnabledQueues() const; + inline Queue GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex); inline Instance& GetInstance(); inline const Instance& GetInstance() const; @@ -118,6 +119,7 @@ namespace Nz NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateGraphicsPipelines); NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateImage); NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateImageView); + NAZARA_VULKAN_DEVICE_FUNCTION(vkCreatePipelineCache); NAZARA_VULKAN_DEVICE_FUNCTION(vkCreatePipelineLayout); NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateRenderPass); NAZARA_VULKAN_DEVICE_FUNCTION(vkCreateSampler); @@ -134,6 +136,7 @@ namespace Nz NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyImage); NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyImageView); NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyPipeline); + NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyPipelineCache); NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyPipelineLayout); NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroyRenderPass); NAZARA_VULKAN_DEVICE_FUNCTION(vkDestroySampler); diff --git a/src/Nazara/Vulkan/VkDevice.cpp b/src/Nazara/Vulkan/VkDevice.cpp index 73f6f6bdb..ae0c6dfbe 100644 --- a/src/Nazara/Vulkan/VkDevice.cpp +++ b/src/Nazara/Vulkan/VkDevice.cpp @@ -125,6 +125,7 @@ namespace Nz NAZARA_VULKAN_LOAD_DEVICE(vkCreateGraphicsPipelines); NAZARA_VULKAN_LOAD_DEVICE(vkCreateImage); NAZARA_VULKAN_LOAD_DEVICE(vkCreateImageView); + NAZARA_VULKAN_LOAD_DEVICE(vkCreatePipelineCache); NAZARA_VULKAN_LOAD_DEVICE(vkCreatePipelineLayout); NAZARA_VULKAN_LOAD_DEVICE(vkCreateRenderPass); NAZARA_VULKAN_LOAD_DEVICE(vkCreateSampler); @@ -141,6 +142,7 @@ namespace Nz NAZARA_VULKAN_LOAD_DEVICE(vkDestroyImage); NAZARA_VULKAN_LOAD_DEVICE(vkDestroyImageView); NAZARA_VULKAN_LOAD_DEVICE(vkDestroyPipeline); + NAZARA_VULKAN_LOAD_DEVICE(vkDestroyPipelineCache); NAZARA_VULKAN_LOAD_DEVICE(vkDestroyPipelineLayout); NAZARA_VULKAN_LOAD_DEVICE(vkDestroyRenderPass); NAZARA_VULKAN_LOAD_DEVICE(vkDestroySampler); From bae3034a6199090bf037e6e78be3174dc73b1084 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 4 Jul 2016 18:16:04 +0200 Subject: [PATCH 023/316] Vulkan/Device: Update queue handling Former-commit-id: 72f6af81a54e73b3e49a7a2ca1abeae2dfcb3754 [formerly 8932248d5e816bfa294f0ad9f955ded7b5078c83] Former-commit-id: c8d2543428a0b1226bee28bda6141c2af4d82c77 --- include/Nazara/Vulkan/VkDevice.hpp | 14 ++++++- src/Nazara/Vulkan/VkDevice.cpp | 63 ++++++++++++++++++------------ 2 files changed, 49 insertions(+), 28 deletions(-) diff --git a/include/Nazara/Vulkan/VkDevice.hpp b/include/Nazara/Vulkan/VkDevice.hpp index 4b861fe3b..7a5e21247 100644 --- a/include/Nazara/Vulkan/VkDevice.hpp +++ b/include/Nazara/Vulkan/VkDevice.hpp @@ -28,6 +28,7 @@ namespace Nz { public: struct QueueFamilyInfo; + struct QueueInfo; inline Device(Instance& instance); Device(const Device&) = delete; @@ -191,9 +192,18 @@ namespace Nz #undef NAZARA_VULKAN_DEVICE_FUNCTION - struct QueueFamilyInfo + struct QueueInfo { - std::vector queues; + QueueFamilyInfo* familyInfo; + Queue queue; + float priority; + }; + + using QueueList = std::vector; + + struct QueueFamilyInfoi + { + QueueList queues; VkExtent3D minImageTransferGranularity; VkQueueFlags flags; UInt32 familyIndex; diff --git a/src/Nazara/Vulkan/VkDevice.cpp b/src/Nazara/Vulkan/VkDevice.cpp index ae0c6dfbe..c5b878361 100644 --- a/src/Nazara/Vulkan/VkDevice.cpp +++ b/src/Nazara/Vulkan/VkDevice.cpp @@ -27,38 +27,15 @@ namespace Nz return false; } + m_physicalDevice = device; + // 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 retains informations about queues - m_enabledQueuesInfos.resize(createInfo.queueCreateInfoCount); - for (UInt32 i = 0; i < createInfo.queueCreateInfoCount; ++i) - { - const VkDeviceQueueCreateInfo& queueCreateInfo = createInfo.pQueueCreateInfos[i]; - QueueFamilyInfo& info = m_enabledQueuesInfos[i]; - - info.familyIndex = queueCreateInfo.queueFamilyIndex; - - const VkQueueFamilyProperties& queueProperties = queuesProperties[info.familyIndex]; - info.flags = queueProperties.queueFlags; - info.minImageTransferGranularity = queueProperties.minImageTransferGranularity; - info.timestampValidBits = queueProperties.timestampValidBits; - - info.queues.resize(queueCreateInfo.queueCount); - for (UInt32 queueCount = 0; queueCount < queueCreateInfo.queueCount; ++queueCount) - info.queues[queueCount] = queueCreateInfo.pQueuePriorities[queueCount]; - } - + // Load all device-related functions #define NAZARA_VULKAN_LOAD_DEVICE(func) func = reinterpret_cast(GetProcAddr(#func)) try @@ -200,6 +177,40 @@ namespace Nz #undef NAZARA_VULKAN_LOAD_DEVICE + // 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 retains informations about queues + UInt32 maxFamilyIndex = 0; + m_enabledQueuesInfos.resize(createInfo.queueCreateInfoCount); + for (UInt32 i = 0; i < createInfo.queueCreateInfoCount; ++i) + { + const VkDeviceQueueCreateInfo& queueCreateInfo = createInfo.pQueueCreateInfos[i]; + QueueFamilyInfo& info = m_enabledQueuesInfos[i]; + + info.familyIndex = queueCreateInfo.queueFamilyIndex; + if (info.familyIndex > maxFamilyIndex) + maxFamilyIndex = info.familyIndex; + + const VkQueueFamilyProperties& queueProperties = queuesProperties[info.familyIndex]; + info.flags = queueProperties.queueFlags; + info.minImageTransferGranularity = queueProperties.minImageTransferGranularity; + info.timestampValidBits = queueProperties.timestampValidBits; + + info.queues.resize(queueCreateInfo.queueCount); + for (UInt32 queueIndex = 0; queueIndex < queueCreateInfo.queueCount; ++queueIndex) + { + QueueInfo queueInfo; + queueInfo.familyInfo = &info; + queueInfo.priority = queueCreateInfo.pQueuePriorities[queueIndex]; + queueInfo.queue = GetQueue(info.familyIndex, queueIndex); + } + } + return true; } } From 92a9662137ebf6e4e0b4180f7e02c11876a7a323 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 4 Jul 2016 18:16:35 +0200 Subject: [PATCH 024/316] Vulkan: Add Vulkan-compatible RenderWindow Former-commit-id: e7f457fbc42432b41be0e6ab8b7b2e1ee035ff0e [formerly 649f62d5522759a7676e247a571d04f8445c3a1a] Former-commit-id: 27f256593ecde5686a752b18fce4a3799375e509 --- include/Nazara/Vulkan/RenderTarget.hpp | 44 +++ include/Nazara/Vulkan/RenderWindow.hpp | 87 +++++ src/Nazara/Vulkan/RenderTarget.cpp | 14 + src/Nazara/Vulkan/RenderWindow.cpp | 421 +++++++++++++++++++++++++ 4 files changed, 566 insertions(+) create mode 100644 include/Nazara/Vulkan/RenderTarget.hpp create mode 100644 include/Nazara/Vulkan/RenderWindow.hpp create mode 100644 src/Nazara/Vulkan/RenderTarget.cpp create mode 100644 src/Nazara/Vulkan/RenderWindow.cpp diff --git a/include/Nazara/Vulkan/RenderTarget.hpp b/include/Nazara/Vulkan/RenderTarget.hpp new file mode 100644 index 000000000..65228c1c1 --- /dev/null +++ b/include/Nazara/Vulkan/RenderTarget.hpp @@ -0,0 +1,44 @@ +// Copyright (C) 201 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_RENDERTARGET_HPP +#define NAZARA_RENDERTARGET_HPP + +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class Renderer; + + class NAZARA_VULKAN_API RenderTarget + { + friend Renderer; + + public: + RenderTarget() = default; + RenderTarget(const RenderTarget&) = delete; + RenderTarget(RenderTarget&&) = delete; ///TOOD? + virtual ~RenderTarget(); + + virtual bool Acquire(const Vk::Framebuffer** framebuffer) const = 0; + + virtual void Present() = 0; + + RenderTarget& operator=(const RenderTarget&) = delete; + RenderTarget& operator=(RenderTarget&&) = delete; ///TOOD? + + // Signals: + NazaraSignal(OnRenderTargetRelease, const RenderTarget* /*renderTarget*/); + NazaraSignal(OnRenderTargetSizeChange, const RenderTarget* /*renderTarget*/); + }; +} + +#endif // NAZARA_RENDERTARGET_HPP diff --git a/include/Nazara/Vulkan/RenderWindow.hpp b/include/Nazara/Vulkan/RenderWindow.hpp new file mode 100644 index 000000000..f1e5b3215 --- /dev/null +++ b/include/Nazara/Vulkan/RenderWindow.hpp @@ -0,0 +1,87 @@ +// Copyright (C) 2015 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_RENDERWINDOW_HPP +#define NAZARA_RENDERWINDOW_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_VULKAN_API RenderWindow : public RenderTarget, public Window + { + public: + RenderWindow(); + RenderWindow(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default); + RenderWindow(WindowHandle handle); + RenderWindow(const RenderWindow&) = delete; + RenderWindow(RenderWindow&&) = delete; ///TODO + virtual ~RenderWindow(); + + bool Acquire(const Vk::Framebuffer** framebuffer) const override; + + bool Create(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default); + bool Create(WindowHandle handle); + + const Vk::DeviceHandle& GetDevice() const; + UInt32 GetPresentableFamilyQueue() const; + const Vk::Surface& GetSurface() const; + const Vk::Swapchain& GetSwapchain() const; + + void Present() override; + + bool IsValid() const; + + void SetPhysicalDevice(VkPhysicalDevice device); + + RenderWindow& operator=(const RenderWindow&) = delete; + RenderWindow& operator=(RenderWindow&&) = delete; ///TODO + + private: + bool OnWindowCreated() override; + void OnWindowDestroy() override; + void OnWindowResized() override; + + bool SetupRenderPass(VkFormat colorFormat, VkFormat depthFormat); + + struct ImageData + { + Vk::CommandBuffer drawToPresentCmd; + Vk::CommandBuffer presentToDrawCmd; + Vk::Framebuffer frameBuffer; + }; + + Clock m_clock; + VkPhysicalDevice m_forcedPhysicalDevice; + std::vector m_images; + Vk::CommandPool m_cmdPool; + Vk::DeviceHandle m_device; + Vk::Queue m_presentQueue; + Vk::RenderPass m_renderPass; + Vk::Semaphore m_imageReadySemaphore; + Vk::Surface m_surface; + Vk::Swapchain m_swapchain; + mutable UInt32 m_lastImageAcquired; + UInt32 m_presentableFamilyQueue; + }; +} + +#endif // NAZARA_RENDERWINDOW_HPP diff --git a/src/Nazara/Vulkan/RenderTarget.cpp b/src/Nazara/Vulkan/RenderTarget.cpp new file mode 100644 index 000000000..f2d038752 --- /dev/null +++ b/src/Nazara/Vulkan/RenderTarget.cpp @@ -0,0 +1,14 @@ +// 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 +{ + RenderTarget::~RenderTarget() + { + OnRenderTargetRelease(this); + } +} diff --git a/src/Nazara/Vulkan/RenderWindow.cpp b/src/Nazara/Vulkan/RenderWindow.cpp new file mode 100644 index 000000000..6350125e0 --- /dev/null +++ b/src/Nazara/Vulkan/RenderWindow.cpp @@ -0,0 +1,421 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + RenderWindow::RenderWindow() : + RenderTarget(), Window(), + m_surface(Nz::Vulkan::GetInstance()), + m_forcedPhysicalDevice(nullptr) + { + } + + RenderWindow::RenderWindow(VideoMode mode, const String& title, UInt32 style) : + RenderWindow() + { + ErrorFlags flags(ErrorFlag_ThrowException, true); + Create(mode, title, style); + } + + RenderWindow::RenderWindow(WindowHandle handle) : + RenderWindow() + { + ErrorFlags flags(ErrorFlag_ThrowException, true); + Create(handle); + } + + RenderWindow::~RenderWindow() + { + // Nécessaire si Window::Destroy est appelé par son destructeur + OnWindowDestroy(); + } + + bool RenderWindow::Acquire(const Vk::Framebuffer** framebuffer) const + { + UInt32 imageIndex; + if (!m_swapchain.AcquireNextImage(std::numeric_limits::max(), m_imageReadySemaphore, VK_NULL_HANDLE, &imageIndex)) + { + NazaraError("Failed to acquire next image"); + return false; + } + + VkSemaphore waitSemaphore = m_imageReadySemaphore; + VkCommandBuffer barrierBuffer = m_images[imageIndex].presentToDrawCmd; + + VkSubmitInfo submitInfo = { + VK_STRUCTURE_TYPE_SUBMIT_INFO, // VkStructureType sType + nullptr, // const void* pNext + 1, // uint32_t waitSemaphoreCount + &waitSemaphore, // const VkSemaphore* pWaitSemaphores + nullptr, // const VkPipelineStageFlags* pWaitDstStageMask + 1, // uint32_t commandBufferCount + &barrierBuffer, // const VkCommandBuffer* pCommandBuffers + 0, // uint32_t signalSemaphoreCount + nullptr // const VkSemaphore* pSignalSemaphores + }; + + if (!m_presentQueue.Submit(1, &submitInfo)) + { + NazaraError("Failed to submit memory barrier"); + return false; + } + + m_lastImageAcquired = imageIndex; + + if (framebuffer) + *framebuffer = &m_images[imageIndex].frameBuffer; + + return true; + } + + bool RenderWindow::Create(VideoMode mode, const String& title, UInt32 style) + { + return Window::Create(mode, title, style); + } + + bool RenderWindow::Create(WindowHandle handle) + { + return Window::Create(handle); + } + + const Vk::DeviceHandle& RenderWindow::GetDevice() const + { + return m_device; + } + + UInt32 RenderWindow::GetPresentableFamilyQueue() const + { + return m_presentableFamilyQueue; + } + + const Vk::Surface& RenderWindow::GetSurface() const + { + return m_surface; + } + + const Vk::Swapchain& RenderWindow::GetSwapchain() const + { + return m_swapchain; + } + + void RenderWindow::Present() + { + m_presentQueue.Present(m_swapchain, m_lastImageAcquired); + } + + bool RenderWindow::IsValid() const + { + return m_impl != nullptr; + } + + void RenderWindow::SetPhysicalDevice(VkPhysicalDevice device) + { + m_forcedPhysicalDevice = device; + } + + bool RenderWindow::OnWindowCreated() + { + OnRenderTargetSizeChange(this); + + #if defined(NAZARA_PLATFORM_WINDOWS) + HWND handle = reinterpret_cast(GetHandle()); + HINSTANCE instance = reinterpret_cast(GetWindowLongPtrW(handle, GWLP_HINSTANCE)); + bool success = m_surface.Create(instance, handle); + #else + #error This OS is not supported by Vulkan + #endif + + if (!success) + { + NazaraError("Failed to create Vulkan surface"); + return false; + } + + m_device = Vulkan::SelectDevice(m_forcedPhysicalDevice, m_surface, &m_presentableFamilyQueue); + if (!m_device) + { + NazaraError("Failed to get compatible Vulkan device"); + return false; + } + + m_presentQueue = m_device->GetQueue(m_presentableFamilyQueue, 0); + + std::vector surfaceFormats; + if (!m_surface.GetFormats(m_forcedPhysicalDevice, &surfaceFormats)) + { + NazaraError("Failed to query supported surface formats"); + return false; + } + + VkFormat colorFormat; + if (surfaceFormats.size() == 1 && surfaceFormats[0].format == VK_FORMAT_UNDEFINED) + colorFormat = VK_FORMAT_B8G8R8A8_UNORM; + else + colorFormat = surfaceFormats[0].format; + + VkColorSpaceKHR colorSpace = surfaceFormats[0].colorSpace; + + VkSurfaceCapabilitiesKHR surfaceCapabilities; + if (!m_surface.GetCapabilities(m_forcedPhysicalDevice, &surfaceCapabilities)) + { + NazaraError("Failed to query surface capabilities"); + return false; + } + + Nz::UInt32 imageCount = surfaceCapabilities.minImageCount + 1; + if (surfaceCapabilities.maxImageCount > 0 && imageCount > surfaceCapabilities.maxImageCount) + imageCount = surfaceCapabilities.maxImageCount; + + VkExtent2D extent; + if (surfaceCapabilities.currentExtent.width == -1) + { + extent.width = Nz::Clamp(GetWidth(), surfaceCapabilities.minImageExtent.width, surfaceCapabilities.maxImageExtent.width); + extent.height = Nz::Clamp(GetHeight(), surfaceCapabilities.minImageExtent.height, surfaceCapabilities.maxImageExtent.height); + } + else + extent = surfaceCapabilities.currentExtent; + + std::vector presentModes; + if (!m_surface.GetPresentModes(m_forcedPhysicalDevice, &presentModes)) + { + NazaraError("Failed to query supported present modes"); + return false; + } + + VkPresentModeKHR swapchainPresentMode = VK_PRESENT_MODE_FIFO_KHR; + for (VkPresentModeKHR presentMode : presentModes) + { + if (presentMode == VK_PRESENT_MODE_MAILBOX_KHR) + { + swapchainPresentMode = VK_PRESENT_MODE_MAILBOX_KHR; + break; + } + + if (presentMode == VK_PRESENT_MODE_IMMEDIATE_KHR) + swapchainPresentMode = VK_PRESENT_MODE_IMMEDIATE_KHR; + } + + VkSwapchainCreateInfoKHR swapchainInfo = { + VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR, + nullptr, + 0, + m_surface, + imageCount, + colorFormat, + colorSpace, + extent, + 1, + VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, + VK_SHARING_MODE_EXCLUSIVE, + 0, nullptr, + surfaceCapabilities.currentTransform, + VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR, + swapchainPresentMode, + VK_TRUE, + 0 + }; + + if (!m_swapchain.Create(m_device, swapchainInfo)) + { + NazaraError("Failed to create swapchain"); + return false; + } + + if (!SetupRenderPass(colorFormat, VK_FORMAT_MAX_ENUM)) + { + NazaraError("Failed to create render pass"); + return false; + } + + if (!m_cmdPool.Create(m_device, m_presentableFamilyQueue)) + { + NazaraError("Failed to create present command pool"); + return false; + } + + auto cmdBuffers = m_cmdPool.AllocateCommandBuffers(imageCount * 2, VK_COMMAND_BUFFER_LEVEL_PRIMARY); + + VkImageSubresourceRange imageRange = { + VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask + 0, // uint32_t baseMipLevel + 1, // uint32_t levelCount + 0, // uint32_t baseArrayLayer + 1 // uint32_t layerCount + }; + + m_images.resize(imageCount); + for (UInt32 i = 0; i < imageCount; ++i) + { + ImageData& imageData = m_images[i]; + imageData.presentToDrawCmd = std::move(cmdBuffers[i*2 + 0]); + imageData.drawToPresentCmd = std::move(cmdBuffers[i*2 + 1]); + + VkImage image = m_swapchain.GetBuffer(i).image; + + // Barriers + VkImageMemoryBarrier presentToDrawBarrier = { + VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType + nullptr, // const void* pNext + VK_ACCESS_MEMORY_READ_BIT, // VkAccessFlags srcAccessMask + VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask + VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout + VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout newLayout + VK_QUEUE_FAMILY_IGNORED, // uint32_t srcQueueFamilyIndex + VK_QUEUE_FAMILY_IGNORED, // uint32_t dstQueueFamilyIndex + image, // VkImage image + imageRange // VkImageSubresourceRange subresourceRange + }; + + imageData.presentToDrawCmd.Begin(0); + + m_device->vkCmdPipelineBarrier(imageData.presentToDrawCmd, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, &presentToDrawBarrier); + + if (!imageData.presentToDrawCmd.End()) + { + NazaraError("Failed to record present to draw barrier command buffer for image #" + String::Number(i)); + return false; + } + + VkImageMemoryBarrier drawToPresentBarrier = { + VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType + nullptr, // const void* pNext + VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask + VK_ACCESS_MEMORY_READ_BIT, // VkAccessFlags dstAccessMask + VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout + VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, // VkImageLayout newLayout + VK_QUEUE_FAMILY_IGNORED, // uint32_t srcQueueFamilyIndex + VK_QUEUE_FAMILY_IGNORED, // uint32_t dstQueueFamilyIndex + image, // VkImage image + imageRange // VkImageSubresourceRange subresourceRange + }; + + imageData.drawToPresentCmd.Begin(0); + + m_device->vkCmdPipelineBarrier(imageData.drawToPresentCmd, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, 0, nullptr, 0, nullptr, 1, &drawToPresentBarrier); + + if (!imageData.drawToPresentCmd.End()) + { + NazaraError("Failed to record draw to present barrier command buffer for image #" + String::Number(i)); + return false; + } + + // Framebuffer + std::array attachments = {m_swapchain.GetBuffer(i).view, VK_NULL_HANDLE}; + + VkFramebufferCreateInfo frameBufferCreate = { + VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + 0, // VkFramebufferCreateFlags flags; + m_renderPass, // VkRenderPass renderPass; + (attachments[1] != VK_NULL_HANDLE) ? 2U : 1U, // uint32_t attachmentCount; + attachments.data(), // const VkImageView* pAttachments; + extent.width, // uint32_t width; + extent.height, // uint32_t height; + 1U // uint32_t layers; + }; + + if (!imageData.frameBuffer.Create(m_device, frameBufferCreate)) + { + NazaraError("Failed to create framebuffer for image #" + String::Number(i)); + return false; + } + } + + m_imageReadySemaphore.Create(m_device); + + m_clock.Restart(); + + return true; + } + + void RenderWindow::OnWindowDestroy() + { + m_images.clear(); + m_renderPass.Destroy(); + m_cmdPool.Destroy(); + + m_swapchain.Destroy(); + m_surface.Destroy(); + } + + void RenderWindow::OnWindowResized() + { + OnRenderTargetSizeChange(this); + } + + bool RenderWindow::SetupRenderPass(VkFormat colorFormat, VkFormat depthFormat) + { + std::array attachments = { + { + { + 0, // VkAttachmentDescriptionFlags flags; + colorFormat, // VkFormat format; + VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples; + VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp loadOp; + VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp; + VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp; + VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp; + VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout initialLayout; + VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout finalLayout; + }, + { + 0, // VkAttachmentDescriptionFlags flags; + depthFormat, // VkFormat format; + VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples; + VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp loadOp; + VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp; + VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp; + VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp; + VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout initialLayout; + VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout finalLayout; + }, + } + }; + + VkAttachmentReference colorReference = { + 0, // uint32_t attachment; + VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout layout; + }; + + VkAttachmentReference depthReference = { + 1, // uint32_t attachment; + VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL // VkImageLayout layout; + }; + + VkSubpassDescription subpass = { + 0, // VkSubpassDescriptionFlags flags; + VK_PIPELINE_BIND_POINT_GRAPHICS, // VkPipelineBindPoint pipelineBindPoint; + 0U, // uint32_t inputAttachmentCount; + nullptr, // const VkAttachmentReference* pInputAttachments; + 1U, // uint32_t colorAttachmentCount; + &colorReference, // const VkAttachmentReference* pColorAttachments; + nullptr, // const VkAttachmentReference* pResolveAttachments; + (depthFormat != VK_FORMAT_MAX_ENUM) ? &depthReference : nullptr, // const VkAttachmentReference* pDepthStencilAttachment; + 0U, // uint32_t preserveAttachmentCount; + nullptr // const uint32_t* pPreserveAttachments; + }; + + VkRenderPassCreateInfo createInfo = { + VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + 0, // VkRenderPassCreateFlags flags; + (depthFormat != VK_FORMAT_MAX_ENUM) ? 2U : 1U, // uint32_t attachmentCount; + attachments.data(), // const VkAttachmentDescription* pAttachments; + 1U, // uint32_t subpassCount; + &subpass, // const VkSubpassDescription* pSubpasses; + 0U, // uint32_t dependencyCount; + nullptr // const VkSubpassDependency* pDependencies; + }; + + return m_renderPass.Create(m_device, createInfo); + } +} From f6b683eae20c312996ce983426badfb6b0e6b52e Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 4 Jul 2016 18:16:45 +0200 Subject: [PATCH 025/316] Vulkan/Queue: Fix const and move Former-commit-id: 503accc10d97b206bb0493b429327f1b739d0953 [formerly f87f3476138fd34f8e3dbaa3683eb5b9b70c60b8] Former-commit-id: 566e7f0d1140b2437036f324baaededbbd3d198a --- include/Nazara/Vulkan/VkQueue.hpp | 15 ++++++++------- include/Nazara/Vulkan/VkQueue.inl | 25 +++++++++++++++++++------ 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/include/Nazara/Vulkan/VkQueue.hpp b/include/Nazara/Vulkan/VkQueue.hpp index b6253bc32..e4223d30d 100644 --- a/include/Nazara/Vulkan/VkQueue.hpp +++ b/include/Nazara/Vulkan/VkQueue.hpp @@ -18,6 +18,7 @@ namespace Nz class Queue { public: + inline Queue(); inline Queue(const DeviceHandle& device, VkQueue queue); inline Queue(const Queue& queue); inline Queue(Queue&& queue); @@ -26,23 +27,23 @@ namespace Nz inline const DeviceHandle& GetDevice() const; inline VkResult GetLastErrorCode() const; - inline bool Present(const VkPresentInfoKHR& presentInfo); - inline bool Present(VkSwapchainKHR swapchain, UInt32 imageIndex, VkSemaphore waitSemaphore = VK_NULL_HANDLE); + inline bool Present(const VkPresentInfoKHR& presentInfo) const; + inline bool Present(VkSwapchainKHR swapchain, UInt32 imageIndex, VkSemaphore waitSemaphore = VK_NULL_HANDLE) const; - 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 Submit(const VkSubmitInfo& submit, VkFence fence = VK_NULL_HANDLE) const; + inline bool Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence fence = VK_NULL_HANDLE) const; - inline bool WaitIdle(); + inline bool WaitIdle() const; Queue& operator=(const Queue& queue) = delete; - Queue& operator=(Queue&&) = delete; + inline Queue& operator=(Queue&&); inline operator VkQueue(); protected: DeviceHandle m_device; VkQueue m_handle; - VkResult m_lastErrorCode; + mutable VkResult m_lastErrorCode; }; } } diff --git a/include/Nazara/Vulkan/VkQueue.inl b/include/Nazara/Vulkan/VkQueue.inl index 89273958f..0dd156312 100644 --- a/include/Nazara/Vulkan/VkQueue.inl +++ b/include/Nazara/Vulkan/VkQueue.inl @@ -11,6 +11,11 @@ namespace Nz { namespace Vk { + inline Queue::Queue() : + Queue(DeviceHandle(), VK_NULL_HANDLE) + { + } + inline Queue::Queue(const DeviceHandle& device, VkQueue queue) : m_device(device), m_handle(queue), @@ -42,7 +47,7 @@ namespace Nz return m_lastErrorCode; } - inline bool Queue::Present(const VkPresentInfoKHR& presentInfo) + inline bool Queue::Present(const VkPresentInfoKHR& presentInfo) const { m_lastErrorCode = m_device->vkQueuePresentKHR(m_handle, &presentInfo); if (m_lastErrorCode != VkResult::VK_SUCCESS) @@ -51,7 +56,7 @@ namespace Nz return true; } - inline bool Queue::Present(VkSwapchainKHR swapchain, UInt32 imageIndex, VkSemaphore waitSemaphore) + inline bool Queue::Present(VkSwapchainKHR swapchain, UInt32 imageIndex, VkSemaphore waitSemaphore) const { VkPresentInfoKHR presentInfo = { @@ -68,12 +73,12 @@ namespace Nz return Present(presentInfo); } - inline bool Queue::Submit(const VkSubmitInfo& submit, VkFence fence) + inline bool Queue::Submit(const VkSubmitInfo& submit, VkFence fence) const { return Submit(1, &submit, fence); } - inline bool Queue::Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence fence) + inline bool Queue::Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence fence) const { m_lastErrorCode = m_device->vkQueueSubmit(m_handle, submitCount, submits, fence); if (m_lastErrorCode != VkResult::VK_SUCCESS) @@ -82,7 +87,7 @@ namespace Nz return true; } - inline bool Queue::WaitIdle() + inline bool Queue::WaitIdle() const { m_lastErrorCode = m_device->vkQueueWaitIdle(m_handle); if (m_lastErrorCode != VkResult::VK_SUCCESS) @@ -91,11 +96,19 @@ namespace Nz return true; } + inline Queue& Queue::operator=(Queue&& queue) + { + m_device = std::move(queue.m_device); + m_handle = queue.m_handle; + m_lastErrorCode = queue.m_lastErrorCode; + + return *this; + } + inline Queue::operator VkQueue() { return m_handle; } - } } From 296680d32a45307ee0ec2dea51e91f1585049552 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 5 Jul 2016 18:09:37 +0200 Subject: [PATCH 026/316] Vulkan/Device: Fix Queue stuff Former-commit-id: 124691546da9e4ce867df931c97b828efef237ca [formerly 9ce524972a4ca15755b9b575560046251a8063f7] Former-commit-id: 2ac3db1c0c11573e3ea6439cb3bb8f8c8dec9451 --- include/Nazara/Vulkan/VkDevice.hpp | 9 +++++---- include/Nazara/Vulkan/VkDevice.inl | 7 +++++++ src/Nazara/Vulkan/VkDevice.cpp | 22 +++++++++++++--------- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/include/Nazara/Vulkan/VkDevice.hpp b/include/Nazara/Vulkan/VkDevice.hpp index 7a5e21247..c9044fb1c 100644 --- a/include/Nazara/Vulkan/VkDevice.hpp +++ b/include/Nazara/Vulkan/VkDevice.hpp @@ -29,6 +29,7 @@ namespace Nz public: struct QueueFamilyInfo; struct QueueInfo; + using QueueList = std::vector; inline Device(Instance& instance); Device(const Device&) = delete; @@ -39,6 +40,7 @@ namespace Nz inline void Destroy(); inline const std::vector& GetEnabledQueues() const; + inline const QueueList& GetEnabledQueues(UInt32 familyQueue) const; inline Queue GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex); inline Instance& GetInstance(); @@ -195,13 +197,11 @@ namespace Nz struct QueueInfo { QueueFamilyInfo* familyInfo; - Queue queue; + VkQueue queue; float priority; }; - using QueueList = std::vector; - - struct QueueFamilyInfoi + struct QueueFamilyInfo { QueueList queues; VkExtent3D minImageTransferGranularity; @@ -221,6 +221,7 @@ namespace Nz std::unordered_set m_loadedExtensions; std::unordered_set m_loadedLayers; std::vector m_enabledQueuesInfos; + std::vector m_queuesByFamily; }; } } diff --git a/include/Nazara/Vulkan/VkDevice.inl b/include/Nazara/Vulkan/VkDevice.inl index f97b06c13..700cf15db 100644 --- a/include/Nazara/Vulkan/VkDevice.inl +++ b/include/Nazara/Vulkan/VkDevice.inl @@ -41,6 +41,13 @@ namespace Nz return m_enabledQueuesInfos; } + inline const Device::QueueList& Device::GetEnabledQueues(UInt32 familyQueue) const + { + NazaraAssert(familyQueue < m_enabledQueuesInfos.size(), "Invalid family queue"); + + return *m_queuesByFamily[familyQueue]; + } + inline Queue Device::GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex) { VkQueue queue; diff --git a/src/Nazara/Vulkan/VkDevice.cpp b/src/Nazara/Vulkan/VkDevice.cpp index c5b878361..9ecbf57de 100644 --- a/src/Nazara/Vulkan/VkDevice.cpp +++ b/src/Nazara/Vulkan/VkDevice.cpp @@ -35,6 +35,13 @@ namespace Nz 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]); + // Load all device-related functions #define NAZARA_VULKAN_LOAD_DEVICE(func) func = reinterpret_cast(GetProcAddr(#func)) @@ -177,13 +184,6 @@ namespace Nz #undef NAZARA_VULKAN_LOAD_DEVICE - // 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 retains informations about queues UInt32 maxFamilyIndex = 0; m_enabledQueuesInfos.resize(createInfo.queueCreateInfoCount); @@ -204,13 +204,17 @@ namespace Nz info.queues.resize(queueCreateInfo.queueCount); for (UInt32 queueIndex = 0; queueIndex < queueCreateInfo.queueCount; ++queueIndex) { - QueueInfo queueInfo; + QueueInfo& queueInfo = info.queues[queueIndex]; queueInfo.familyInfo = &info; queueInfo.priority = queueCreateInfo.pQueuePriorities[queueIndex]; - queueInfo.queue = GetQueue(info.familyIndex, queueIndex); + vkGetDeviceQueue(m_device, info.familyIndex, queueIndex, &queueInfo.queue); } } + m_queuesByFamily.resize(maxFamilyIndex + 1); + for (const QueueFamilyInfo& familyInfo : m_enabledQueuesInfos) + m_queuesByFamily[familyInfo.familyIndex] = &familyInfo.queues; + return true; } } From 9d85ba6b1ce31ee2edf07b1cd77190ba2dfbd101 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 6 Jul 2016 13:46:14 +0200 Subject: [PATCH 027/316] Vulkan/CommandBuffer: Add PipelineBarrier wrapper Former-commit-id: 1f19b8428dabb90db9a28a5bfaa3a0c64c8b3004 [formerly a6dc98a271e1c95c6c6816cf99e2aa73347e1619] Former-commit-id: 539ac00717edd99126aaaa7765c1490a00ca35f5 --- include/Nazara/Vulkan/VkCommandBuffer.hpp | 4 ++ include/Nazara/Vulkan/VkCommandBuffer.inl | 15 ++++++ src/Nazara/Vulkan/RenderWindow.cpp | 59 ++++++++++++----------- 3 files changed, 49 insertions(+), 29 deletions(-) diff --git a/include/Nazara/Vulkan/VkCommandBuffer.hpp b/include/Nazara/Vulkan/VkCommandBuffer.hpp index 67ec4f558..9ded0cabd 100644 --- a/include/Nazara/Vulkan/VkCommandBuffer.hpp +++ b/include/Nazara/Vulkan/VkCommandBuffer.hpp @@ -35,6 +35,10 @@ namespace Nz inline void Free(); + inline void PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, const VkImageMemoryBarrier& imageMemoryBarrier); + inline void PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, const VkMemoryBarrier& memoryBarrier, const VkBufferMemoryBarrier& bufferMemoryBarrier, const VkImageMemoryBarrier& imageMemoryBarrier); + inline void PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, UInt32 memoryBarrierCount, const VkMemoryBarrier* memoryBarriers, UInt32 bufferMemoryBarrierCount, const VkBufferMemoryBarrier* bufferMemoryBarriers, UInt32 imageMemoryBarrierCount, const VkImageMemoryBarrier* imageMemoryBarriers); + inline VkResult GetLastErrorCode() const; CommandBuffer& operator=(const CommandBuffer&) = delete; diff --git a/include/Nazara/Vulkan/VkCommandBuffer.inl b/include/Nazara/Vulkan/VkCommandBuffer.inl index f3719b135..b2a2b42e5 100644 --- a/include/Nazara/Vulkan/VkCommandBuffer.inl +++ b/include/Nazara/Vulkan/VkCommandBuffer.inl @@ -141,6 +141,21 @@ namespace Nz m_pool->GetDevice()->vkFreeCommandBuffers(*m_pool->GetDevice(), *m_pool, 1, &m_handle); } + inline void CommandBuffer::PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, const VkImageMemoryBarrier& imageMemoryBarrier) + { + return PipelineBarrier(srcStageMask, dstStageMask, dependencyFlags, 0, nullptr, 0, nullptr, 1, &imageMemoryBarrier); + } + + inline void CommandBuffer::PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, const VkMemoryBarrier& memoryBarrier, const VkBufferMemoryBarrier& bufferMemoryBarrier, const VkImageMemoryBarrier& imageMemoryBarrier) + { + return PipelineBarrier(srcStageMask, dstStageMask, dependencyFlags, 1, &memoryBarrier, 1, &bufferMemoryBarrier, 1, &imageMemoryBarrier); + } + + inline void CommandBuffer::PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, UInt32 memoryBarrierCount, const VkMemoryBarrier* memoryBarriers, UInt32 bufferMemoryBarrierCount, const VkBufferMemoryBarrier* bufferMemoryBarriers, UInt32 imageMemoryBarrierCount, const VkImageMemoryBarrier* imageMemoryBarriers) + { + m_pool->GetDevice()->vkCmdPipelineBarrier(m_handle, srcStageMask, dstStageMask, dependencyFlags, memoryBarrierCount, memoryBarriers, bufferMemoryBarrierCount, bufferMemoryBarriers, imageMemoryBarrierCount, imageMemoryBarriers); + } + inline VkResult CommandBuffer::GetLastErrorCode() const { return m_lastErrorCode; diff --git a/src/Nazara/Vulkan/RenderWindow.cpp b/src/Nazara/Vulkan/RenderWindow.cpp index 6350125e0..18d90f432 100644 --- a/src/Nazara/Vulkan/RenderWindow.cpp +++ b/src/Nazara/Vulkan/RenderWindow.cpp @@ -261,23 +261,23 @@ namespace Nz VkImage image = m_swapchain.GetBuffer(i).image; - // Barriers - VkImageMemoryBarrier presentToDrawBarrier = { - VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType - nullptr, // const void* pNext - VK_ACCESS_MEMORY_READ_BIT, // VkAccessFlags srcAccessMask - VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask - VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout - VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout newLayout - VK_QUEUE_FAMILY_IGNORED, // uint32_t srcQueueFamilyIndex - VK_QUEUE_FAMILY_IGNORED, // uint32_t dstQueueFamilyIndex - image, // VkImage image - imageRange // VkImageSubresourceRange subresourceRange - }; - imageData.presentToDrawCmd.Begin(0); + { + VkImageMemoryBarrier presentToDrawBarrier = { + VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType + nullptr, // const void* pNext + VK_ACCESS_MEMORY_READ_BIT, // VkAccessFlags srcAccessMask + VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask + VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout + VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout newLayout + VK_QUEUE_FAMILY_IGNORED, // uint32_t srcQueueFamilyIndex + VK_QUEUE_FAMILY_IGNORED, // uint32_t dstQueueFamilyIndex + image, // VkImage image + imageRange // VkImageSubresourceRange subresourceRange + }; - m_device->vkCmdPipelineBarrier(imageData.presentToDrawCmd, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, &presentToDrawBarrier); + imageData.presentToDrawCmd.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, presentToDrawBarrier); + } if (!imageData.presentToDrawCmd.End()) { @@ -285,22 +285,23 @@ namespace Nz return false; } - VkImageMemoryBarrier drawToPresentBarrier = { - VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType - nullptr, // const void* pNext - VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask - VK_ACCESS_MEMORY_READ_BIT, // VkAccessFlags dstAccessMask - VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, // VkImageLayout oldLayout - VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, // VkImageLayout newLayout - VK_QUEUE_FAMILY_IGNORED, // uint32_t srcQueueFamilyIndex - VK_QUEUE_FAMILY_IGNORED, // uint32_t dstQueueFamilyIndex - image, // VkImage image - imageRange // VkImageSubresourceRange subresourceRange - }; - imageData.drawToPresentCmd.Begin(0); + { + VkImageMemoryBarrier drawToPresentBarrier = { + VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType + nullptr, // const void* pNext + VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask + VK_ACCESS_MEMORY_READ_BIT, // VkAccessFlags dstAccessMask + VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout oldLayout + VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, // VkImageLayout newLayout + VK_QUEUE_FAMILY_IGNORED, // uint32_t srcQueueFamilyIndex + VK_QUEUE_FAMILY_IGNORED, // uint32_t dstQueueFamilyIndex + image, // VkImage image + imageRange // VkImageSubresourceRange subresourceRange + }; - m_device->vkCmdPipelineBarrier(imageData.drawToPresentCmd, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, 0, nullptr, 0, nullptr, 1, &drawToPresentBarrier); + imageData.drawToPresentCmd.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, drawToPresentBarrier); + } if (!imageData.drawToPresentCmd.End()) { From a3f3e61501585fd21865e4851a7f6487e297dc70 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 7 Jul 2016 14:05:13 +0200 Subject: [PATCH 028/316] Vulkan/Pipeline: Fix last code not being set Former-commit-id: 3d997b2a47c3610c8b53059fd690aa9eb5b84785 [formerly e4c9b0aaa84427807e6c35d4bad4d88e68f1a019] Former-commit-id: 2b7c0c879364ef8a774fa0313b34ad30ca2e3f3a --- include/Nazara/Vulkan/VkPipeline.inl | 1 + 1 file changed, 1 insertion(+) diff --git a/include/Nazara/Vulkan/VkPipeline.inl b/include/Nazara/Vulkan/VkPipeline.inl index 4325c5f78..d621a9d2a 100644 --- a/include/Nazara/Vulkan/VkPipeline.inl +++ b/include/Nazara/Vulkan/VkPipeline.inl @@ -65,6 +65,7 @@ namespace Nz inline bool Pipeline::Create(const DeviceHandle& device, VkResult result, const VkAllocationCallbacks* allocator) { m_device = device; + m_lastErrorCode = result; if (m_lastErrorCode != VkResult::VK_SUCCESS) { NazaraError("Failed to create Vulkan object"); From 033c0581853f87f2d89ad2c4a7193ca255a1af2f Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 7 Jul 2016 14:09:16 +0200 Subject: [PATCH 029/316] Vulkan/CommandBuffer: Add some rendering wrappers Former-commit-id: 762ac8aba9d0998aa5e44f8df7832258d743a95f [formerly 30a7cabf1689a0ad96cef2c4c6d632c1118bd99c] Former-commit-id: a25c64c88b0812a4f5d6f641ba309a642c3ce2be --- include/Nazara/Vulkan/VkCommandBuffer.hpp | 16 ++++++ include/Nazara/Vulkan/VkCommandBuffer.inl | 66 ++++++++++++++++++++++- 2 files changed, 81 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Vulkan/VkCommandBuffer.hpp b/include/Nazara/Vulkan/VkCommandBuffer.hpp index 9ded0cabd..95381ef58 100644 --- a/include/Nazara/Vulkan/VkCommandBuffer.hpp +++ b/include/Nazara/Vulkan/VkCommandBuffer.hpp @@ -8,6 +8,7 @@ #define NAZARA_VULKAN_VKCOMMANDBUFFER_HPP #include +#include #include #include @@ -31,14 +32,29 @@ namespace Nz 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 void BeginRenderPass(const VkRenderPassBeginInfo& beginInfo, VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE); + + inline void BindPipeline(VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline); + + inline void Draw(UInt32 vertexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0); + inline bool End(); + inline void EndRenderPass(); + inline void Free(); inline void PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, const VkImageMemoryBarrier& imageMemoryBarrier); inline void PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, const VkMemoryBarrier& memoryBarrier, const VkBufferMemoryBarrier& bufferMemoryBarrier, const VkImageMemoryBarrier& imageMemoryBarrier); inline void PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, UInt32 memoryBarrierCount, const VkMemoryBarrier* memoryBarriers, UInt32 bufferMemoryBarrierCount, const VkBufferMemoryBarrier* bufferMemoryBarriers, UInt32 imageMemoryBarrierCount, const VkImageMemoryBarrier* imageMemoryBarriers); + inline void SetScissor(const Recti& scissorRegion); + inline void SetScissor(const VkRect2D& scissorRegion); + inline void SetScissor(UInt32 firstScissor, UInt32 scissorCount, const VkRect2D* scissors); + inline void SetViewport(const Rectf& viewport, float minDepth, float maxDepth); + inline void SetViewport(const VkViewport& viewport); + inline void SetViewport(UInt32 firstViewport, UInt32 viewportCount, const VkViewport* viewports); + inline VkResult GetLastErrorCode() const; CommandBuffer& operator=(const CommandBuffer&) = delete; diff --git a/include/Nazara/Vulkan/VkCommandBuffer.inl b/include/Nazara/Vulkan/VkCommandBuffer.inl index b2a2b42e5..682b9884c 100644 --- a/include/Nazara/Vulkan/VkCommandBuffer.inl +++ b/include/Nazara/Vulkan/VkCommandBuffer.inl @@ -123,6 +123,21 @@ namespace Nz return Begin(beginInfo); } + inline void CommandBuffer::BeginRenderPass(const VkRenderPassBeginInfo& beginInfo, VkSubpassContents contents) + { + return m_pool->GetDevice()->vkCmdBeginRenderPass(m_handle, &beginInfo, contents); + } + + inline void CommandBuffer::BindPipeline(VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline) + { + return m_pool->GetDevice()->vkCmdBindPipeline(m_handle, pipelineBindPoint, pipeline); + } + + inline void CommandBuffer::Draw(UInt32 vertexCount, UInt32 instanceCount, UInt32 firstVertex, UInt32 firstInstance) + { + return m_pool->GetDevice()->vkCmdDraw(m_handle, vertexCount, instanceCount, firstVertex, firstInstance); + } + inline bool CommandBuffer::End() { m_lastErrorCode = m_pool->GetDevice()->vkEndCommandBuffer(m_handle); @@ -135,6 +150,11 @@ namespace Nz return true; } + inline void CommandBuffer::EndRenderPass() + { + return m_pool->GetDevice()->vkCmdEndRenderPass(m_handle); + } + inline void CommandBuffer::Free() { if (m_handle) @@ -153,7 +173,51 @@ namespace Nz inline void CommandBuffer::PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, UInt32 memoryBarrierCount, const VkMemoryBarrier* memoryBarriers, UInt32 bufferMemoryBarrierCount, const VkBufferMemoryBarrier* bufferMemoryBarriers, UInt32 imageMemoryBarrierCount, const VkImageMemoryBarrier* imageMemoryBarriers) { - m_pool->GetDevice()->vkCmdPipelineBarrier(m_handle, srcStageMask, dstStageMask, dependencyFlags, memoryBarrierCount, memoryBarriers, bufferMemoryBarrierCount, bufferMemoryBarriers, imageMemoryBarrierCount, imageMemoryBarriers); + return m_pool->GetDevice()->vkCmdPipelineBarrier(m_handle, srcStageMask, dstStageMask, dependencyFlags, memoryBarrierCount, memoryBarriers, bufferMemoryBarrierCount, bufferMemoryBarriers, imageMemoryBarrierCount, imageMemoryBarriers); + } + + inline void CommandBuffer::SetScissor(const Recti& scissorRegion) + { + VkRect2D rect = { + {scissorRegion.x, scissorRegion.y}, // VkOffset2D offset + {scissorRegion.width, scissorRegion.height} // VkExtent2D extent + }; + + SetScissor(rect); + } + + inline void CommandBuffer::SetScissor(const VkRect2D& scissorRegion) + { + return SetScissor(0, 1, &scissorRegion); + } + + inline void CommandBuffer::SetScissor(UInt32 firstScissor, UInt32 scissorCount, const VkRect2D* scissors) + { + return m_pool->GetDevice()->vkCmdSetScissor(m_handle, firstScissor, scissorCount, scissors); + } + + inline void CommandBuffer::SetViewport(const Rectf& viewport, float minDepth, float maxDepth) + { + VkViewport rect = { + viewport.x, // float x; + viewport.y, // float y; + viewport.width, // float width; + viewport.height, // float height; + minDepth, // float minDepth; + maxDepth // float maxDepth; + }; + + SetViewport(rect); + } + + inline void CommandBuffer::SetViewport(const VkViewport& viewport) + { + return SetViewport(0, 1, &viewport); + } + + inline void CommandBuffer::SetViewport(UInt32 firstViewport, UInt32 viewportCount, const VkViewport* viewports) + { + return m_pool->GetDevice()->vkCmdSetViewport(m_handle, firstViewport, viewportCount, viewports); } inline VkResult CommandBuffer::GetLastErrorCode() const From 907676f7c65650bd54194a77aee69309e4375efb Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 7 Jul 2016 14:09:51 +0200 Subject: [PATCH 030/316] Vulkan/RenderWindow: Move RenderPass to RenderTarget Former-commit-id: a02917920c9cda7ab7cfcca924b1234041ac61b3 [formerly a85ebe44046d945f2b429eae5dee8344fa08e520] Former-commit-id: eebab1d2b76ed504392b66a199b99522095eca3e --- include/Nazara/Vulkan/RenderTarget.hpp | 6 ++++++ include/Nazara/Vulkan/RenderWindow.hpp | 2 -- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/Nazara/Vulkan/RenderTarget.hpp b/include/Nazara/Vulkan/RenderTarget.hpp index 65228c1c1..e25189b1b 100644 --- a/include/Nazara/Vulkan/RenderTarget.hpp +++ b/include/Nazara/Vulkan/RenderTarget.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -30,6 +31,8 @@ namespace Nz virtual bool Acquire(const Vk::Framebuffer** framebuffer) const = 0; + const Vk::RenderPass& GetRenderPass() const { return m_renderPass; } + virtual void Present() = 0; RenderTarget& operator=(const RenderTarget&) = delete; @@ -38,6 +41,9 @@ namespace Nz // Signals: NazaraSignal(OnRenderTargetRelease, const RenderTarget* /*renderTarget*/); NazaraSignal(OnRenderTargetSizeChange, const RenderTarget* /*renderTarget*/); + + protected: + Vk::RenderPass m_renderPass; }; } diff --git a/include/Nazara/Vulkan/RenderWindow.hpp b/include/Nazara/Vulkan/RenderWindow.hpp index f1e5b3215..332bdad39 100644 --- a/include/Nazara/Vulkan/RenderWindow.hpp +++ b/include/Nazara/Vulkan/RenderWindow.hpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -75,7 +74,6 @@ namespace Nz Vk::CommandPool m_cmdPool; Vk::DeviceHandle m_device; Vk::Queue m_presentQueue; - Vk::RenderPass m_renderPass; Vk::Semaphore m_imageReadySemaphore; Vk::Surface m_surface; Vk::Swapchain m_swapchain; From bf47347609850535d7a69063e874a17e1cfd3def Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 7 Jul 2016 14:10:35 +0200 Subject: [PATCH 031/316] Vulkan: Update global header Former-commit-id: 15375da0143966ab8ffb8eb1c56ef96c4db655a2 [formerly 316948619e32352e4601d2318bad9346d72452bd] Former-commit-id: 1157a827f3be5b7698649888564ea6db13c2aa81 --- include/Nazara/Vulkan.hpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Vulkan.hpp b/include/Nazara/Vulkan.hpp index a3e363272..eb8973dbe 100644 --- a/include/Nazara/Vulkan.hpp +++ b/include/Nazara/Vulkan.hpp @@ -1,4 +1,4 @@ -// This file was automatically generated on 15 May 2016 at 00:11:13 +// This file was automatically generated on 06 Jul 2016 at 14:00:09 /* Nazara Engine - Vulkan @@ -30,13 +30,24 @@ #define NAZARA_GLOBAL_VULKAN_HPP #include +#include +#include #include #include #include #include +#include +#include #include #include +#include +#include +#include +#include +#include +#include #include +#include #include #include #include From e588be1d179f8b793b6e6cc3a102f2620eb8da51 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 12:39:14 +0200 Subject: [PATCH 032/316] Vulkan/CommandBuffer: Fix warning Former-commit-id: 3d82e627f0c7e4281c1fd61034ebcfacf4c2672f [formerly 5c25e00727f30dd117e03e0b6fb71dffa472a1c0] Former-commit-id: f57c42a8ffbf8ea3d74d0827975a73906dfde312 --- include/Nazara/Vulkan/VkCommandBuffer.inl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/Nazara/Vulkan/VkCommandBuffer.inl b/include/Nazara/Vulkan/VkCommandBuffer.inl index 682b9884c..b373b502d 100644 --- a/include/Nazara/Vulkan/VkCommandBuffer.inl +++ b/include/Nazara/Vulkan/VkCommandBuffer.inl @@ -179,8 +179,8 @@ namespace Nz inline void CommandBuffer::SetScissor(const Recti& scissorRegion) { VkRect2D rect = { - {scissorRegion.x, scissorRegion.y}, // VkOffset2D offset - {scissorRegion.width, scissorRegion.height} // VkExtent2D extent + {scissorRegion.x, scissorRegion.y}, // VkOffset2D offset + {UInt32(scissorRegion.width), UInt32(scissorRegion.height)} // VkExtent2D extent }; SetScissor(rect); From f1c5f8d0b745fd0112454ca15726a7ad09570a6f Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 17:59:43 +0200 Subject: [PATCH 033/316] Vulkan/RenderTarget: Change interface to better suit needs Former-commit-id: cc61462eca9a4b73821eb0c9bd10b74366e5a6ce [formerly 8e64df958d6b9ccd61b9df22456cd566947fcb0b] Former-commit-id: 750ea64ee603b0c52058eb93045310db4977dfdb --- include/Nazara/Vulkan/RenderTarget.hpp | 14 +- include/Nazara/Vulkan/RenderWindow.hpp | 31 +- src/Nazara/Vulkan/RenderWindow.cpp | 423 ++++++++++++------------- 3 files changed, 232 insertions(+), 236 deletions(-) diff --git a/include/Nazara/Vulkan/RenderTarget.hpp b/include/Nazara/Vulkan/RenderTarget.hpp index e25189b1b..d12d90483 100644 --- a/include/Nazara/Vulkan/RenderTarget.hpp +++ b/include/Nazara/Vulkan/RenderTarget.hpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -29,11 +30,19 @@ namespace Nz RenderTarget(RenderTarget&&) = delete; ///TOOD? virtual ~RenderTarget(); - virtual bool Acquire(const Vk::Framebuffer** framebuffer) const = 0; + virtual bool Acquire(UInt32* imageIndex) const = 0; + + virtual void BuildPreRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) = 0; + virtual void BuildPostRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) = 0; + + virtual const Vk::Framebuffer& GetFrameBuffer(UInt32 imageIndex) const = 0; + virtual UInt32 GetFramebufferCount() const = 0; const Vk::RenderPass& GetRenderPass() const { return m_renderPass; } - virtual void Present() = 0; + const Vk::Semaphore& GetRenderSemaphore() const { return m_imageReadySemaphore; } + + virtual void Present(UInt32 imageIndex) = 0; RenderTarget& operator=(const RenderTarget&) = delete; RenderTarget& operator=(RenderTarget&&) = delete; ///TOOD? @@ -44,6 +53,7 @@ namespace Nz protected: Vk::RenderPass m_renderPass; + Vk::Semaphore m_imageReadySemaphore; }; } diff --git a/include/Nazara/Vulkan/RenderWindow.hpp b/include/Nazara/Vulkan/RenderWindow.hpp index 332bdad39..1651f1b9e 100644 --- a/include/Nazara/Vulkan/RenderWindow.hpp +++ b/include/Nazara/Vulkan/RenderWindow.hpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -35,7 +34,14 @@ namespace Nz RenderWindow(RenderWindow&&) = delete; ///TODO virtual ~RenderWindow(); - bool Acquire(const Vk::Framebuffer** framebuffer) const override; + bool Acquire(UInt32* index) const override; + + void BuildPreRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) override; + void BuildPostRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) override; + + const Vk::Framebuffer& GetFrameBuffer(UInt32 imageIndex) const override; + + UInt32 GetFramebufferCount() const; bool Create(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default); bool Create(WindowHandle handle); @@ -45,7 +51,7 @@ namespace Nz const Vk::Surface& GetSurface() const; const Vk::Swapchain& GetSwapchain() const; - void Present() override; + void Present(UInt32 imageIndex) override; bool IsValid() const; @@ -59,25 +65,20 @@ namespace Nz void OnWindowDestroy() override; void OnWindowResized() override; - bool SetupRenderPass(VkFormat colorFormat, VkFormat depthFormat); - - struct ImageData - { - Vk::CommandBuffer drawToPresentCmd; - Vk::CommandBuffer presentToDrawCmd; - Vk::Framebuffer frameBuffer; - }; + bool SetupCommandBuffers(); + bool SetupRenderPass(); + bool SetupSwapchain(); Clock m_clock; + VkFormat m_colorFormat; + VkFormat m_depthFormat; + VkColorSpaceKHR m_colorSpace; VkPhysicalDevice m_forcedPhysicalDevice; - std::vector m_images; - Vk::CommandPool m_cmdPool; + std::vector m_frameBuffers; Vk::DeviceHandle m_device; Vk::Queue m_presentQueue; - Vk::Semaphore m_imageReadySemaphore; Vk::Surface m_surface; Vk::Swapchain m_swapchain; - mutable UInt32 m_lastImageAcquired; UInt32 m_presentableFamilyQueue; }; } diff --git a/src/Nazara/Vulkan/RenderWindow.cpp b/src/Nazara/Vulkan/RenderWindow.cpp index 18d90f432..1a623e59c 100644 --- a/src/Nazara/Vulkan/RenderWindow.cpp +++ b/src/Nazara/Vulkan/RenderWindow.cpp @@ -39,42 +39,77 @@ namespace Nz OnWindowDestroy(); } - bool RenderWindow::Acquire(const Vk::Framebuffer** framebuffer) const + bool RenderWindow::Acquire(UInt32* imageIndex) const { - UInt32 imageIndex; - if (!m_swapchain.AcquireNextImage(std::numeric_limits::max(), m_imageReadySemaphore, VK_NULL_HANDLE, &imageIndex)) + if (!m_swapchain.AcquireNextImage(std::numeric_limits::max(), m_imageReadySemaphore, VK_NULL_HANDLE, imageIndex)) { NazaraError("Failed to acquire next image"); return false; } - VkSemaphore waitSemaphore = m_imageReadySemaphore; - VkCommandBuffer barrierBuffer = m_images[imageIndex].presentToDrawCmd; + return true; + } - VkSubmitInfo submitInfo = { - VK_STRUCTURE_TYPE_SUBMIT_INFO, // VkStructureType sType - nullptr, // const void* pNext - 1, // uint32_t waitSemaphoreCount - &waitSemaphore, // const VkSemaphore* pWaitSemaphores - nullptr, // const VkPipelineStageFlags* pWaitDstStageMask - 1, // uint32_t commandBufferCount - &barrierBuffer, // const VkCommandBuffer* pCommandBuffers - 0, // uint32_t signalSemaphoreCount - nullptr // const VkSemaphore* pSignalSemaphores + void RenderWindow::BuildPreRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) + { + VkImageSubresourceRange imageRange = { + VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask + 0, // uint32_t baseMipLevel + 1, // uint32_t levelCount + 0, // uint32_t baseArrayLayer + 1 // uint32_t layerCount }; - if (!m_presentQueue.Submit(1, &submitInfo)) - { - NazaraError("Failed to submit memory barrier"); - return false; - } + VkImageMemoryBarrier presentToDrawBarrier = { + VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType + nullptr, // const void* pNext + 0, // VkAccessFlags srcAccessMask + VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // VkAccessFlags dstAccessMask + VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout + VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout newLayout + VK_QUEUE_FAMILY_IGNORED, // uint32_t srcQueueFamilyIndex + VK_QUEUE_FAMILY_IGNORED, // uint32_t dstQueueFamilyIndex + m_swapchain.GetBuffer(imageIndex).image, // VkImage image + imageRange // VkImageSubresourceRange subresourceRange + }; - m_lastImageAcquired = imageIndex; + commandBuffer.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, presentToDrawBarrier); + } - if (framebuffer) - *framebuffer = &m_images[imageIndex].frameBuffer; + void RenderWindow::BuildPostRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) + { + VkImageSubresourceRange imageRange = { + VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask + 0, // uint32_t baseMipLevel + 1, // uint32_t levelCount + 0, // uint32_t baseArrayLayer + 1 // uint32_t layerCount + }; - return true; + VkImageMemoryBarrier drawToPresentBarrier = { + VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType + nullptr, // const void* pNext + VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // VkAccessFlags srcAccessMask + 0, // VkAccessFlags dstAccessMask + VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout oldLayout + VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, // VkImageLayout newLayout + VK_QUEUE_FAMILY_IGNORED, // uint32_t srcQueueFamilyIndex + VK_QUEUE_FAMILY_IGNORED, // uint32_t dstQueueFamilyIndex + m_swapchain.GetBuffer(imageIndex).image, // VkImage image + imageRange // VkImageSubresourceRange subresourceRange + }; + + commandBuffer.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, drawToPresentBarrier); + } + + const Vk::Framebuffer& RenderWindow::GetFrameBuffer(UInt32 imageIndex) const + { + return m_frameBuffers[imageIndex]; + } + + UInt32 RenderWindow::GetFramebufferCount() const + { + return static_cast(m_frameBuffers.size()); } bool RenderWindow::Create(VideoMode mode, const String& title, UInt32 style) @@ -107,9 +142,11 @@ namespace Nz return m_swapchain; } - void RenderWindow::Present() + void RenderWindow::Present(UInt32 imageIndex) { - m_presentQueue.Present(m_swapchain, m_lastImageAcquired); + NazaraAssert(imageIndex < m_frameBuffers.size(), "Invalid image index"); + + m_presentQueue.Present(m_swapchain, imageIndex); } bool RenderWindow::IsValid() const @@ -156,14 +193,149 @@ namespace Nz return false; } - VkFormat colorFormat; if (surfaceFormats.size() == 1 && surfaceFormats[0].format == VK_FORMAT_UNDEFINED) - colorFormat = VK_FORMAT_B8G8R8A8_UNORM; + m_colorFormat = VK_FORMAT_B8G8R8A8_UNORM; else - colorFormat = surfaceFormats[0].format; + m_colorFormat = surfaceFormats[0].format; - VkColorSpaceKHR colorSpace = surfaceFormats[0].colorSpace; + m_colorSpace = surfaceFormats[0].colorSpace; + m_depthFormat = VK_FORMAT_MAX_ENUM; + + if (!SetupSwapchain()) + { + NazaraError("Failed to create swapchain"); + return false; + } + + if (!SetupRenderPass()) + { + NazaraError("Failed to create render pass"); + return false; + } + + UInt32 imageCount = m_swapchain.GetBufferCount(); + + // Framebuffers + m_frameBuffers.resize(imageCount); + for (UInt32 i = 0; i < imageCount; ++i) + { + std::array attachments = {m_swapchain.GetBuffer(i).view, VK_NULL_HANDLE}; + + VkFramebufferCreateInfo frameBufferCreate = { + VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + 0, // VkFramebufferCreateFlags flags; + m_renderPass, // VkRenderPass renderPass; + (attachments[1] != VK_NULL_HANDLE) ? 2U : 1U, // uint32_t attachmentCount; + attachments.data(), // const VkImageView* pAttachments; + GetWidth(), // uint32_t width; + GetHeight(), // uint32_t height; + 1U // uint32_t layers; + }; + + if (!m_frameBuffers[i].Create(m_device, frameBufferCreate)) + { + NazaraError("Failed to create framebuffer for image #" + String::Number(i)); + return false; + } + } + + m_imageReadySemaphore.Create(m_device); + + m_clock.Restart(); + + return true; + } + + void RenderWindow::OnWindowDestroy() + { + m_frameBuffers.clear(); + m_renderPass.Destroy(); + + m_swapchain.Destroy(); + m_surface.Destroy(); + } + + void RenderWindow::OnWindowResized() + { + OnRenderTargetSizeChange(this); + } + + bool RenderWindow::SetupCommandBuffers() + { + return false; + } + + bool RenderWindow::SetupRenderPass() + { + std::array attachments = { + { + { + 0, // VkAttachmentDescriptionFlags flags; + m_colorFormat, // VkFormat format; + VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples; + VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp loadOp; + VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp; + VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp; + VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp; + VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout initialLayout; + VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout finalLayout; + }, + { + 0, // VkAttachmentDescriptionFlags flags; + m_depthFormat, // VkFormat format; + VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples; + VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp loadOp; + VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp; + VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp; + VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp; + VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout initialLayout; + VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout finalLayout; + }, + } + }; + + VkAttachmentReference colorReference = { + 0, // uint32_t attachment; + VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout layout; + }; + + VkAttachmentReference depthReference = { + 1, // uint32_t attachment; + VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL // VkImageLayout layout; + }; + + VkSubpassDescription subpass = { + 0, // VkSubpassDescriptionFlags flags; + VK_PIPELINE_BIND_POINT_GRAPHICS, // VkPipelineBindPoint pipelineBindPoint; + 0U, // uint32_t inputAttachmentCount; + nullptr, // const VkAttachmentReference* pInputAttachments; + 1U, // uint32_t colorAttachmentCount; + &colorReference, // const VkAttachmentReference* pColorAttachments; + nullptr, // const VkAttachmentReference* pResolveAttachments; + (m_depthFormat != VK_FORMAT_MAX_ENUM) ? &depthReference : nullptr, // const VkAttachmentReference* pDepthStencilAttachment; + 0U, // uint32_t preserveAttachmentCount; + nullptr // const uint32_t* pPreserveAttachments; + }; + + VkRenderPassCreateInfo createInfo = { + VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + 0, // VkRenderPassCreateFlags flags; + (m_depthFormat != VK_FORMAT_MAX_ENUM) ? 2U : 1U, // uint32_t attachmentCount; + attachments.data(), // const VkAttachmentDescription* pAttachments; + 1U, // uint32_t subpassCount; + &subpass, // const VkSubpassDescription* pSubpasses; + 0U, // uint32_t dependencyCount; + nullptr // const VkSubpassDependency* pDependencies; + }; + + return m_renderPass.Create(m_device, createInfo); + } + + bool RenderWindow::SetupSwapchain() + { VkSurfaceCapabilitiesKHR surfaceCapabilities; if (!m_surface.GetCapabilities(m_forcedPhysicalDevice, &surfaceCapabilities)) { @@ -210,8 +382,8 @@ namespace Nz 0, m_surface, imageCount, - colorFormat, - colorSpace, + m_colorFormat, + m_colorSpace, extent, 1, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, @@ -230,193 +402,6 @@ namespace Nz return false; } - if (!SetupRenderPass(colorFormat, VK_FORMAT_MAX_ENUM)) - { - NazaraError("Failed to create render pass"); - return false; - } - - if (!m_cmdPool.Create(m_device, m_presentableFamilyQueue)) - { - NazaraError("Failed to create present command pool"); - return false; - } - - auto cmdBuffers = m_cmdPool.AllocateCommandBuffers(imageCount * 2, VK_COMMAND_BUFFER_LEVEL_PRIMARY); - - VkImageSubresourceRange imageRange = { - VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask - 0, // uint32_t baseMipLevel - 1, // uint32_t levelCount - 0, // uint32_t baseArrayLayer - 1 // uint32_t layerCount - }; - - m_images.resize(imageCount); - for (UInt32 i = 0; i < imageCount; ++i) - { - ImageData& imageData = m_images[i]; - imageData.presentToDrawCmd = std::move(cmdBuffers[i*2 + 0]); - imageData.drawToPresentCmd = std::move(cmdBuffers[i*2 + 1]); - - VkImage image = m_swapchain.GetBuffer(i).image; - - imageData.presentToDrawCmd.Begin(0); - { - VkImageMemoryBarrier presentToDrawBarrier = { - VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType - nullptr, // const void* pNext - VK_ACCESS_MEMORY_READ_BIT, // VkAccessFlags srcAccessMask - VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags dstAccessMask - VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout - VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout newLayout - VK_QUEUE_FAMILY_IGNORED, // uint32_t srcQueueFamilyIndex - VK_QUEUE_FAMILY_IGNORED, // uint32_t dstQueueFamilyIndex - image, // VkImage image - imageRange // VkImageSubresourceRange subresourceRange - }; - - imageData.presentToDrawCmd.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, presentToDrawBarrier); - } - - if (!imageData.presentToDrawCmd.End()) - { - NazaraError("Failed to record present to draw barrier command buffer for image #" + String::Number(i)); - return false; - } - - imageData.drawToPresentCmd.Begin(0); - { - VkImageMemoryBarrier drawToPresentBarrier = { - VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType - nullptr, // const void* pNext - VK_ACCESS_TRANSFER_WRITE_BIT, // VkAccessFlags srcAccessMask - VK_ACCESS_MEMORY_READ_BIT, // VkAccessFlags dstAccessMask - VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout oldLayout - VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, // VkImageLayout newLayout - VK_QUEUE_FAMILY_IGNORED, // uint32_t srcQueueFamilyIndex - VK_QUEUE_FAMILY_IGNORED, // uint32_t dstQueueFamilyIndex - image, // VkImage image - imageRange // VkImageSubresourceRange subresourceRange - }; - - imageData.drawToPresentCmd.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, drawToPresentBarrier); - } - - if (!imageData.drawToPresentCmd.End()) - { - NazaraError("Failed to record draw to present barrier command buffer for image #" + String::Number(i)); - return false; - } - - // Framebuffer - std::array attachments = {m_swapchain.GetBuffer(i).view, VK_NULL_HANDLE}; - - VkFramebufferCreateInfo frameBufferCreate = { - VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, // VkStructureType sType; - nullptr, // const void* pNext; - 0, // VkFramebufferCreateFlags flags; - m_renderPass, // VkRenderPass renderPass; - (attachments[1] != VK_NULL_HANDLE) ? 2U : 1U, // uint32_t attachmentCount; - attachments.data(), // const VkImageView* pAttachments; - extent.width, // uint32_t width; - extent.height, // uint32_t height; - 1U // uint32_t layers; - }; - - if (!imageData.frameBuffer.Create(m_device, frameBufferCreate)) - { - NazaraError("Failed to create framebuffer for image #" + String::Number(i)); - return false; - } - } - - m_imageReadySemaphore.Create(m_device); - - m_clock.Restart(); - return true; } - - void RenderWindow::OnWindowDestroy() - { - m_images.clear(); - m_renderPass.Destroy(); - m_cmdPool.Destroy(); - - m_swapchain.Destroy(); - m_surface.Destroy(); - } - - void RenderWindow::OnWindowResized() - { - OnRenderTargetSizeChange(this); - } - - bool RenderWindow::SetupRenderPass(VkFormat colorFormat, VkFormat depthFormat) - { - std::array attachments = { - { - { - 0, // VkAttachmentDescriptionFlags flags; - colorFormat, // VkFormat format; - VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples; - VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp loadOp; - VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp; - VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp; - VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp; - VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout initialLayout; - VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout finalLayout; - }, - { - 0, // VkAttachmentDescriptionFlags flags; - depthFormat, // VkFormat format; - VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples; - VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp loadOp; - VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp; - VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp; - VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp; - VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout initialLayout; - VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout finalLayout; - }, - } - }; - - VkAttachmentReference colorReference = { - 0, // uint32_t attachment; - VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout layout; - }; - - VkAttachmentReference depthReference = { - 1, // uint32_t attachment; - VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL // VkImageLayout layout; - }; - - VkSubpassDescription subpass = { - 0, // VkSubpassDescriptionFlags flags; - VK_PIPELINE_BIND_POINT_GRAPHICS, // VkPipelineBindPoint pipelineBindPoint; - 0U, // uint32_t inputAttachmentCount; - nullptr, // const VkAttachmentReference* pInputAttachments; - 1U, // uint32_t colorAttachmentCount; - &colorReference, // const VkAttachmentReference* pColorAttachments; - nullptr, // const VkAttachmentReference* pResolveAttachments; - (depthFormat != VK_FORMAT_MAX_ENUM) ? &depthReference : nullptr, // const VkAttachmentReference* pDepthStencilAttachment; - 0U, // uint32_t preserveAttachmentCount; - nullptr // const uint32_t* pPreserveAttachments; - }; - - VkRenderPassCreateInfo createInfo = { - VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, // VkStructureType sType; - nullptr, // const void* pNext; - 0, // VkRenderPassCreateFlags flags; - (depthFormat != VK_FORMAT_MAX_ENUM) ? 2U : 1U, // uint32_t attachmentCount; - attachments.data(), // const VkAttachmentDescription* pAttachments; - 1U, // uint32_t subpassCount; - &subpass, // const VkSubpassDescription* pSubpasses; - 0U, // uint32_t dependencyCount; - nullptr // const VkSubpassDependency* pDependencies; - }; - - return m_renderPass.Create(m_device, createInfo); - } } From 992cd303a76cda6eba44469776050fd2d34290fc Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 17:59:52 +0200 Subject: [PATCH 034/316] 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" From 247efdc2cbb0bd93e4a1ebf4f48260ba2335eb4d Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 8 Jul 2016 18:01:45 +0200 Subject: [PATCH 035/316] Vulkan: Add possibility to set custom layers Former-commit-id: f40bed53ba11cc449586ee5bca9bdff0db18a967 [formerly 416333d7d0f3b516c6e0d78b34ff0f060d04a7ab] Former-commit-id: 050ee60750bb94cb007a7a450bdf2852a5d4a3c5 --- src/Nazara/Vulkan/Vulkan.cpp | 80 ++++++++++++++++++++++++++++++------ 1 file changed, 68 insertions(+), 12 deletions(-) diff --git a/src/Nazara/Vulkan/Vulkan.cpp b/src/Nazara/Vulkan/Vulkan.cpp index d73e2e21f..025e9e875 100644 --- a/src/Nazara/Vulkan/Vulkan.cpp +++ b/src/Nazara/Vulkan/Vulkan.cpp @@ -59,6 +59,7 @@ namespace Nz s_initializationParameters.GetStringParameter("VkAppInfo_OverrideApplicationName", &appName); s_initializationParameters.GetStringParameter("VkAppInfo_OverrideEngineName", &engineName); + bool bParam; int iParam; if (s_initializationParameters.GetIntegerParameter("VkAppInfo_OverrideAPIVersion", &iParam)) @@ -88,7 +89,29 @@ namespace Nz std::vector enabledLayers; std::vector enabledExtensions; - bool bParam; + if (!s_initializationParameters.GetBooleanParameter("VkInstanceInfo_OverrideEnabledLayers", &bParam) || !bParam) + { + //< Nazara default layers goes here + } + + std::vector additionalLayers; // Just to keep the String alive + if (s_initializationParameters.GetIntegerParameter("VkInstanceInfo_EnabledLayerCount", &iParam)) + { + additionalLayers.reserve(iParam); + for (int i = 0; i < iParam; ++i) + { + Nz::String parameterName = "VkInstanceInfo_EnabledLayer" + String::Number(i); + Nz::String layer; + if (s_initializationParameters.GetStringParameter(parameterName, &layer)) + { + additionalLayers.emplace_back(std::move(layer)); + enabledLayers.push_back(additionalLayers.back().GetConstBuffer()); + } + else + NazaraWarning("Parameter " + parameterName + " expected"); + } + } + if (!s_initializationParameters.GetBooleanParameter("VkInstanceInfo_OverrideEnabledExtensions", &bParam) || !bParam) { enabledExtensions.push_back("VK_KHR_surface"); @@ -121,6 +144,7 @@ namespace Nz std::vector additionalExtensions; // Just to keep the String alive if (s_initializationParameters.GetIntegerParameter("VkInstanceInfo_EnabledExtensionCount", &iParam)) { + additionalExtensions.reserve(iParam); for (int i = 0; i < iParam; ++i) { Nz::String parameterName = "VkInstanceInfo_EnabledExtension" + String::Number(i); @@ -242,21 +266,29 @@ namespace Nz } std::array usedQueueFamilies = {graphicsQueueNodeIndex, presentQueueNodeIndex, transfertQueueNodeFamily}; - float priority = 1.f; + std::array priorities = {1.f, 1.f, 1.f}; std::vector queueCreateInfos; for (UInt32 queueFamily : usedQueueFamilies) { - VkDeviceQueueCreateInfo createInfo = { - VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, - nullptr, - 0, - queueFamily, - 1, - &priority - }; + auto it = std::find_if(queueCreateInfos.begin(), queueCreateInfos.end(), [queueFamily] (const VkDeviceQueueCreateInfo& createInfo) + { + return createInfo.queueFamilyIndex == queueFamily; + }); - queueCreateInfos.emplace_back(createInfo); + if (it == queueCreateInfos.end()) + { + VkDeviceQueueCreateInfo createInfo = { + VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + 0, // VkDeviceQueueCreateFlags flags; + queueFamily, // uint32_t queueFamilyIndex; + 1, // uint32_t queueCount; + priorities.data() // const float* pQueuePriorities; + }; + + queueCreateInfos.emplace_back(createInfo); + } } @@ -264,10 +296,34 @@ namespace Nz std::vector enabledExtensions; bool bParam; + int iParam; + + if (!s_initializationParameters.GetBooleanParameter("VkDeviceInfo_OverrideEnabledLayers", &bParam) || !bParam) + { + //< Nazara default layers goes here + } + + std::vector additionalLayers; // Just to keep the String alive + if (s_initializationParameters.GetIntegerParameter("VkDeviceInfo_EnabledLayerCount", &iParam)) + { + additionalLayers.reserve(iParam); + for (int i = 0; i < iParam; ++i) + { + Nz::String parameterName = "VkDeviceInfo_EnabledLayer" + String::Number(i); + Nz::String layer; + if (s_initializationParameters.GetStringParameter(parameterName, &layer)) + { + additionalLayers.emplace_back(std::move(layer)); + enabledLayers.push_back(additionalLayers.back().GetConstBuffer()); + } + else + NazaraWarning("Parameter " + parameterName + " expected"); + } + } + if (!s_initializationParameters.GetBooleanParameter("VkDeviceInfo_OverrideEnabledExtensions", &bParam) || !bParam) enabledExtensions.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME); - int iParam; std::vector additionalExtensions; // Just to keep the String alive if (s_initializationParameters.GetIntegerParameter("VkDeviceInfo_EnabledExtensionCount", &iParam)) { From 1e7d82ceb526656364eb024a2b6ca188b06d0d19 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 11 Jul 2016 13:33:23 +0200 Subject: [PATCH 036/316] Vulkan/CommandBuffer: Add SetImageLayout shortcut Former-commit-id: ae936f1fedca28c5e9bf846da14f6f3c6a6b6aa7 [formerly 1df5bdf1684be416c0e6217184fead54be7adc90] Former-commit-id: 51f8797c05a5e3fead1558e30c698aa06d340879 --- include/Nazara/Vulkan/VkCommandBuffer.hpp | 5 + include/Nazara/Vulkan/VkCommandBuffer.inl | 106 ++++++++++++++++++++++ src/Nazara/Vulkan/RenderWindow.cpp | 46 +--------- 3 files changed, 113 insertions(+), 44 deletions(-) diff --git a/include/Nazara/Vulkan/VkCommandBuffer.hpp b/include/Nazara/Vulkan/VkCommandBuffer.hpp index 95381ef58..f496f90f2 100644 --- a/include/Nazara/Vulkan/VkCommandBuffer.hpp +++ b/include/Nazara/Vulkan/VkCommandBuffer.hpp @@ -55,6 +55,11 @@ namespace Nz inline void SetViewport(const VkViewport& viewport); inline void SetViewport(UInt32 firstViewport, UInt32 viewportCount, const VkViewport* viewports); + inline void SetImageLayout(VkImage image, VkImageLayout oldImageLayout, VkImageLayout newImageLayout); + inline void SetImageLayout(VkImage image, VkImageLayout oldImageLayout, VkImageLayout newImageLayout, const VkImageSubresourceRange& subresourceRange); + inline void SetImageLayout(VkImage image, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkImageLayout oldImageLayout, VkImageLayout newImageLayout); + inline void SetImageLayout(VkImage image, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkImageLayout oldImageLayout, VkImageLayout newImageLayout, const VkImageSubresourceRange& subresourceRange); + inline VkResult GetLastErrorCode() const; CommandBuffer& operator=(const CommandBuffer&) = delete; diff --git a/include/Nazara/Vulkan/VkCommandBuffer.inl b/include/Nazara/Vulkan/VkCommandBuffer.inl index b373b502d..ee543fd86 100644 --- a/include/Nazara/Vulkan/VkCommandBuffer.inl +++ b/include/Nazara/Vulkan/VkCommandBuffer.inl @@ -196,6 +196,112 @@ namespace Nz return m_pool->GetDevice()->vkCmdSetScissor(m_handle, firstScissor, scissorCount, scissors); } + inline void CommandBuffer::SetImageLayout(VkImage image, VkImageLayout oldImageLayout, VkImageLayout newImageLayout) + { + return SetImageLayout(image, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, oldImageLayout, newImageLayout); + } + + inline void CommandBuffer::SetImageLayout(VkImage image, VkImageLayout oldImageLayout, VkImageLayout newImageLayout, const VkImageSubresourceRange& subresourceRange) + { + return SetImageLayout(image, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, oldImageLayout, newImageLayout, subresourceRange); + } + + inline void CommandBuffer::SetImageLayout(VkImage image, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkImageLayout oldImageLayout, VkImageLayout newImageLayout) + { + VkImageSubresourceRange imageRange = { + VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask + 0, // uint32_t baseMipLevel + 1, // uint32_t levelCount + 0, // uint32_t baseArrayLayer + 1 // uint32_t layerCount + }; + + return SetImageLayout(image, srcStageMask, dstStageMask, oldImageLayout, newImageLayout, imageRange); + } + + inline void CommandBuffer::SetImageLayout(VkImage image, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkImageLayout oldImageLayout, VkImageLayout newImageLayout, const VkImageSubresourceRange& subresourceRange) + { + VkAccessFlags srcAccessMask; + switch (oldImageLayout) + { + case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL: + srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; + break; + case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL: + srcAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; + break; + case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL: + srcAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT; + break; + case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL: + srcAccessMask = VK_ACCESS_SHADER_READ_BIT; + break; + case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL: + srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT; + break; + case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL: + srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; + break; + case VK_IMAGE_LAYOUT_PREINITIALIZED: + srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; + break; + case VK_IMAGE_LAYOUT_GENERAL: + case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR: + case VK_IMAGE_LAYOUT_UNDEFINED: + default: + srcAccessMask = 0; + break; + } + + VkAccessFlags dstAccessMask; + switch (newImageLayout) + { + case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL: + if (oldImageLayout != VK_IMAGE_LAYOUT_UNDEFINED) + srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT; + + dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; + break; + case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL: + dstAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; + break; + case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL: + if (srcAccessMask == 0) + srcAccessMask = VK_ACCESS_HOST_WRITE_BIT | VK_ACCESS_TRANSFER_WRITE_BIT; + + dstAccessMask = VK_ACCESS_SHADER_READ_BIT; + break; + case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL: + dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; + break; + case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL: + srcAccessMask |= VK_ACCESS_TRANSFER_READ_BIT; + dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT; + break; + case VK_IMAGE_LAYOUT_GENERAL: + case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR: + case VK_IMAGE_LAYOUT_UNDEFINED: + default: + dstAccessMask = 0; + break; + } + + VkImageMemoryBarrier imageBarrier = { + VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType + nullptr, // const void* pNext + srcAccessMask, // VkAccessFlags srcAccessMask + dstAccessMask, // VkAccessFlags dstAccessMask + oldImageLayout, // VkImageLayout oldLayout + newImageLayout, // VkImageLayout newLayout + VK_QUEUE_FAMILY_IGNORED, // uint32_t srcQueueFamilyIndex + VK_QUEUE_FAMILY_IGNORED, // uint32_t dstQueueFamilyIndex + image, // VkImage image + subresourceRange // VkImageSubresourceRange subresourceRange + }; + + return PipelineBarrier(srcStageMask, dstStageMask, 0, imageBarrier); + } + inline void CommandBuffer::SetViewport(const Rectf& viewport, float minDepth, float maxDepth) { VkViewport rect = { diff --git a/src/Nazara/Vulkan/RenderWindow.cpp b/src/Nazara/Vulkan/RenderWindow.cpp index 1a623e59c..faca3f0d8 100644 --- a/src/Nazara/Vulkan/RenderWindow.cpp +++ b/src/Nazara/Vulkan/RenderWindow.cpp @@ -52,54 +52,12 @@ namespace Nz void RenderWindow::BuildPreRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) { - VkImageSubresourceRange imageRange = { - VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask - 0, // uint32_t baseMipLevel - 1, // uint32_t levelCount - 0, // uint32_t baseArrayLayer - 1 // uint32_t layerCount - }; - - VkImageMemoryBarrier presentToDrawBarrier = { - VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType - nullptr, // const void* pNext - 0, // VkAccessFlags srcAccessMask - VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // VkAccessFlags dstAccessMask - VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout oldLayout - VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout newLayout - VK_QUEUE_FAMILY_IGNORED, // uint32_t srcQueueFamilyIndex - VK_QUEUE_FAMILY_IGNORED, // uint32_t dstQueueFamilyIndex - m_swapchain.GetBuffer(imageIndex).image, // VkImage image - imageRange // VkImageSubresourceRange subresourceRange - }; - - commandBuffer.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, presentToDrawBarrier); + commandBuffer.SetImageLayout(m_swapchain.GetBuffer(imageIndex).image, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); } void RenderWindow::BuildPostRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) { - VkImageSubresourceRange imageRange = { - VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask - 0, // uint32_t baseMipLevel - 1, // uint32_t levelCount - 0, // uint32_t baseArrayLayer - 1 // uint32_t layerCount - }; - - VkImageMemoryBarrier drawToPresentBarrier = { - VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType - nullptr, // const void* pNext - VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, // VkAccessFlags srcAccessMask - 0, // VkAccessFlags dstAccessMask - VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout oldLayout - VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, // VkImageLayout newLayout - VK_QUEUE_FAMILY_IGNORED, // uint32_t srcQueueFamilyIndex - VK_QUEUE_FAMILY_IGNORED, // uint32_t dstQueueFamilyIndex - m_swapchain.GetBuffer(imageIndex).image, // VkImage image - imageRange // VkImageSubresourceRange subresourceRange - }; - - commandBuffer.PipelineBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, drawToPresentBarrier); + commandBuffer.SetImageLayout(m_swapchain.GetBuffer(imageIndex).image, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR); } const Vk::Framebuffer& RenderWindow::GetFrameBuffer(UInt32 imageIndex) const From a41954842e31e2e8841d9e573b045645bbd44e9d Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 11 Jul 2016 18:23:50 +0200 Subject: [PATCH 037/316] Vulkan/RenderWindow: Fix crash at window destruction Former-commit-id: a78546e762be474cbd10c882f671413877b62d5b [formerly a18932aaf9e9ac737fd949f84a5d3c6e41cbea40] Former-commit-id: 2cc105aae9f9b9d45a174ec2d1753fdb55692ef0 --- src/Nazara/Vulkan/RenderWindow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Nazara/Vulkan/RenderWindow.cpp b/src/Nazara/Vulkan/RenderWindow.cpp index faca3f0d8..f9b01672e 100644 --- a/src/Nazara/Vulkan/RenderWindow.cpp +++ b/src/Nazara/Vulkan/RenderWindow.cpp @@ -208,6 +208,7 @@ namespace Nz void RenderWindow::OnWindowDestroy() { + m_device->WaitForIdle(); m_frameBuffers.clear(); m_renderPass.Destroy(); From 90826e44679b0695683418ec57b2e9d003925509 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 13 Jul 2016 12:23:35 +0200 Subject: [PATCH 038/316] Vulkan: Add GetPhysicalDeviceInfo Former-commit-id: 613eaa539d90c2480b0c20e09561a45df01e8b9e [formerly 5302439064226b00d49fa8bf2680980eaf806e7a] Former-commit-id: 62e30089bf6d93d893e86dda3d6fcd89e6a2688b --- include/Nazara/Vulkan/Vulkan.hpp | 1 + src/Nazara/Vulkan/Vulkan.cpp | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/Nazara/Vulkan/Vulkan.hpp b/include/Nazara/Vulkan/Vulkan.hpp index 289a1b225..a024d271a 100644 --- a/include/Nazara/Vulkan/Vulkan.hpp +++ b/include/Nazara/Vulkan/Vulkan.hpp @@ -31,6 +31,7 @@ namespace Nz static Vk::Instance& GetInstance(); static const std::vector& GetPhysicalDevices(); + static const Vk::PhysicalDevice& GetPhysicalDeviceInfo(VkPhysicalDevice physDevice); static bool Initialize(); diff --git a/src/Nazara/Vulkan/Vulkan.cpp b/src/Nazara/Vulkan/Vulkan.cpp index 025e9e875..6af41d9b2 100644 --- a/src/Nazara/Vulkan/Vulkan.cpp +++ b/src/Nazara/Vulkan/Vulkan.cpp @@ -24,6 +24,21 @@ namespace Nz return s_physDevices; } + const Vk::PhysicalDevice& Vulkan::GetPhysicalDeviceInfo(VkPhysicalDevice physDevice) + { + for (const Vk::PhysicalDevice& info : s_physDevices) + { + if (info.device == physDevice) + return info; + } + + // This cannot happen if physDevice is valid, as we retrieved every physical device + NazaraInternalError("Invalid physical device: " + String::Pointer(physDevice)); + + static Vk::PhysicalDevice dummy; + return dummy; + } + bool Vulkan::Initialize() { if (s_moduleReferenceCounter > 0) From 80404cf32012605528ab01a6b8d3ddc1d5fb1ece Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 13 Jul 2016 12:24:27 +0200 Subject: [PATCH 039/316] Vulkan: Add VkBuffer wrapper Former-commit-id: 1038adae4a7ca619f0953cb305d14345b197f056 [formerly f03490e99245cb167e95057e80422908654d6644] Former-commit-id: aa5cf8a3d91db8a109504e542f255120a319d70b --- include/Nazara/Vulkan.hpp | 3 ++- include/Nazara/Vulkan/VkBuffer.hpp | 41 ++++++++++++++++++++++++++++++ include/Nazara/Vulkan/VkBuffer.inl | 34 +++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 include/Nazara/Vulkan/VkBuffer.hpp create mode 100644 include/Nazara/Vulkan/VkBuffer.inl diff --git a/include/Nazara/Vulkan.hpp b/include/Nazara/Vulkan.hpp index eb8973dbe..dc72ba4c5 100644 --- a/include/Nazara/Vulkan.hpp +++ b/include/Nazara/Vulkan.hpp @@ -1,4 +1,4 @@ -// This file was automatically generated on 06 Jul 2016 at 14:00:09 +// This file was automatically generated on 12 Jul 2016 at 17:44:44 /* Nazara Engine - Vulkan @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include diff --git a/include/Nazara/Vulkan/VkBuffer.hpp b/include/Nazara/Vulkan/VkBuffer.hpp new file mode 100644 index 000000000..cf1399de4 --- /dev/null +++ b/include/Nazara/Vulkan/VkBuffer.hpp @@ -0,0 +1,41 @@ +// 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_VKBUFFER_HPP +#define NAZARA_VULKAN_VKBUFFER_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class Buffer : public DeviceObject + { + friend DeviceObject; + + public: + Buffer() = default; + Buffer(const Buffer&) = delete; + Buffer(Buffer&&) = default; + ~Buffer() = default; + + VkMemoryRequirements GetMemoryRequirements() const; + + Buffer& operator=(const Buffer&) = delete; + Buffer& operator=(Buffer&&) = delete; + + private: + static inline VkResult CreateHelper(const DeviceHandle& device, const VkBufferCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkBuffer* handle); + static inline void DestroyHelper(const DeviceHandle& device, VkBuffer handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_VULKAN_VKBUFFER_HPP diff --git a/include/Nazara/Vulkan/VkBuffer.inl b/include/Nazara/Vulkan/VkBuffer.inl new file mode 100644 index 000000000..b2f0f07d4 --- /dev/null +++ b/include/Nazara/Vulkan/VkBuffer.inl @@ -0,0 +1,34 @@ +// 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 VkMemoryRequirements Buffer::GetMemoryRequirements() const + { + NazaraAssert(IsValid(), "Invalid buffer"); + + VkMemoryRequirements memoryRequirements; + m_device->vkGetBufferMemoryRequirements(*m_device, m_handle, &memoryRequirements); + + return memoryRequirements; + } + + inline VkResult Buffer::CreateHelper(const DeviceHandle& device, const VkBufferCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkBuffer* handle) + { + return device->vkCreateBuffer(*device, createInfo, allocator, handle); + } + + inline void Buffer::DestroyHelper(const DeviceHandle& device, VkBuffer handle, const VkAllocationCallbacks* allocator) + { + return device->vkDestroyBuffer(*device, handle, allocator); + } + } +} + +#include From 7bbc2f69929fbe139afa2efb38e360be1ccd6c42 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 13 Jul 2016 12:24:46 +0200 Subject: [PATCH 040/316] Vulkan: Add VkDeviceMemory wrapper Former-commit-id: a7ba192880bb034718a2a3d37022343ff32aae1a [formerly e6911d0772f7c2d4612bdbd97da195873f5a30f6] Former-commit-id: bf235ba9b59bfeb39da3b0fd0b89934cb21061b6 --- include/Nazara/Vulkan.hpp | 1 + include/Nazara/Vulkan/VkDeviceMemory.hpp | 43 +++++++++++++++++ include/Nazara/Vulkan/VkDeviceMemory.inl | 59 ++++++++++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 include/Nazara/Vulkan/VkDeviceMemory.hpp create mode 100644 include/Nazara/Vulkan/VkDeviceMemory.inl diff --git a/include/Nazara/Vulkan.hpp b/include/Nazara/Vulkan.hpp index dc72ba4c5..7a158c6f5 100644 --- a/include/Nazara/Vulkan.hpp +++ b/include/Nazara/Vulkan.hpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include diff --git a/include/Nazara/Vulkan/VkDeviceMemory.hpp b/include/Nazara/Vulkan/VkDeviceMemory.hpp new file mode 100644 index 000000000..67e37d4c3 --- /dev/null +++ b/include/Nazara/Vulkan/VkDeviceMemory.hpp @@ -0,0 +1,43 @@ +// 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_VKDEVICEMEMORY_HPP +#define NAZARA_VULKAN_VKDEVICEMEMORY_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class DeviceMemory : public DeviceObject + { + friend DeviceObject; + + public: + DeviceMemory() = default; + DeviceMemory(const DeviceMemory&) = delete; + DeviceMemory(DeviceMemory&&) = default; + ~DeviceMemory() = default; + + using DeviceObject::Create; + inline bool Create(const DeviceHandle& device, VkDeviceSize size, UInt32 memoryType, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(const DeviceHandle& device, VkDeviceSize size, UInt32 typeBits, VkFlags properties, const VkAllocationCallbacks* allocator = nullptr); + + DeviceMemory& operator=(const DeviceMemory&) = delete; + DeviceMemory& operator=(DeviceMemory&&) = delete; + + private: + static inline VkResult CreateHelper(const DeviceHandle& device, const VkMemoryAllocateInfo* allocInfo, const VkAllocationCallbacks* allocator, VkDeviceMemory* handle); + static inline void DestroyHelper(const DeviceHandle& device, VkDeviceMemory handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_VULKAN_VKDEVICEMEMORY_HPP diff --git a/include/Nazara/Vulkan/VkDeviceMemory.inl b/include/Nazara/Vulkan/VkDeviceMemory.inl new file mode 100644 index 000000000..2139c9e22 --- /dev/null +++ b/include/Nazara/Vulkan/VkDeviceMemory.inl @@ -0,0 +1,59 @@ +// 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 bool DeviceMemory::Create(const DeviceHandle& device, VkDeviceSize size, UInt32 memoryType, const VkAllocationCallbacks* allocator) + { + VkMemoryAllocateInfo allocInfo = + { + VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + size, // VkDeviceSize allocationSize; + memoryType // uint32_t memoryTypeIndex; + }; + + return Create(device, allocInfo, allocator); + } + + inline bool DeviceMemory::Create(const DeviceHandle& device, VkDeviceSize size, UInt32 typeBits, VkFlags properties, const VkAllocationCallbacks* allocator) + { + const Vk::PhysicalDevice& deviceInfo = Vulkan::GetPhysicalDeviceInfo(device->GetPhysicalDevice()); + + UInt32 typeMask = 1; + for (UInt32 i = 0; i < VK_MAX_MEMORY_TYPES; ++i) + { + if (typeBits & typeMask) + { + if ((deviceInfo.memoryProperties.memoryTypes[i].propertyFlags & properties) == properties) + return Create(device, size, i, allocator); + } + + typeMask <<= 1; + } + + NazaraError("Failed to find a memory type suitable for typeBits: " + String::Number(typeBits) + " and properties: 0x" + String::Number(properties, 16)); + return false; + } + + inline VkResult DeviceMemory::CreateHelper(const DeviceHandle& device, const VkMemoryAllocateInfo* allocInfo, const VkAllocationCallbacks* allocator, VkDeviceMemory* handle) + { + return device->vkAllocateMemory(*device, allocInfo, allocator, handle); + } + + inline void DeviceMemory::DestroyHelper(const DeviceHandle& device, VkDeviceMemory handle, const VkAllocationCallbacks* allocator) + { + return device->vkFreeMemory(*device, handle, allocator); + } + } +} + +#include From 96b745d6b8ed76104205a53569095c7a60c6e544 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 13 Jul 2016 12:47:35 +0200 Subject: [PATCH 041/316] Commit missing lines Former-commit-id: f132bf8dd03b58a4f97db030b39be890b955adfb [formerly 5aad066c0ad529922f09301db473d4a8f952b57d] Former-commit-id: d9c68d4607a669533d040125539c9ac9f161dfa5 --- include/Nazara/Vulkan/VkBuffer.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/Nazara/Vulkan/VkBuffer.hpp b/include/Nazara/Vulkan/VkBuffer.hpp index cf1399de4..d8c1725d5 100644 --- a/include/Nazara/Vulkan/VkBuffer.hpp +++ b/include/Nazara/Vulkan/VkBuffer.hpp @@ -24,6 +24,9 @@ namespace Nz Buffer(Buffer&&) = default; ~Buffer() = default; + using DeviceObject::Create; + inline bool Create(const DeviceHandle& device, VkDeviceSize size, UInt32 memoryType, const VkAllocationCallbacks* allocator = nullptr); + VkMemoryRequirements GetMemoryRequirements() const; Buffer& operator=(const Buffer&) = delete; From c78daeb8887c190c6455d6e107f7d5ec7fbb7a8d Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 13 Jul 2016 12:48:35 +0200 Subject: [PATCH 042/316] Revert "Commit missing lines" This reverts commit 1792bd15dd50a87f1b9e53d0c79c95d85f06c873. Former-commit-id: 795d8da0e170915e91826d56eabbe606781fe3fe [formerly 2e020939bfcc4aa52bcfa8f1e152d18256795709] Former-commit-id: a4add61ffb2a249da4279369bd0bdc0a690a4964 --- include/Nazara/Vulkan/VkBuffer.hpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/Nazara/Vulkan/VkBuffer.hpp b/include/Nazara/Vulkan/VkBuffer.hpp index d8c1725d5..cf1399de4 100644 --- a/include/Nazara/Vulkan/VkBuffer.hpp +++ b/include/Nazara/Vulkan/VkBuffer.hpp @@ -24,9 +24,6 @@ namespace Nz Buffer(Buffer&&) = default; ~Buffer() = default; - using DeviceObject::Create; - inline bool Create(const DeviceHandle& device, VkDeviceSize size, UInt32 memoryType, const VkAllocationCallbacks* allocator = nullptr); - VkMemoryRequirements GetMemoryRequirements() const; Buffer& operator=(const Buffer&) = delete; From a5690a0aef984920fc8ab2e69695837859f1d40e Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 13 Jul 2016 18:08:56 +0200 Subject: [PATCH 043/316] I can now render meshes ! Former-commit-id: 5f292c0f81730f8fa26d7c930130671da6c8a26d [formerly 2145d599592770fe9a6cf65c46e10400417c4726] Former-commit-id: c0740828e97fcb2a704d55f9d769a371f8d6a4d3 --- include/Nazara/Vulkan/VkBuffer.hpp | 5 +++ include/Nazara/Vulkan/VkBuffer.inl | 28 +++++++++++++++++ include/Nazara/Vulkan/VkCommandBuffer.hpp | 4 +++ include/Nazara/Vulkan/VkCommandBuffer.inl | 20 ++++++++++++ include/Nazara/Vulkan/VkDeviceMemory.hpp | 12 ++++++-- include/Nazara/Vulkan/VkDeviceMemory.inl | 37 +++++++++++++++++++++++ 6 files changed, 104 insertions(+), 2 deletions(-) diff --git a/include/Nazara/Vulkan/VkBuffer.hpp b/include/Nazara/Vulkan/VkBuffer.hpp index cf1399de4..389502b7b 100644 --- a/include/Nazara/Vulkan/VkBuffer.hpp +++ b/include/Nazara/Vulkan/VkBuffer.hpp @@ -24,6 +24,11 @@ namespace Nz Buffer(Buffer&&) = default; ~Buffer() = default; + bool BindBufferMemory(VkDeviceMemory memory, VkDeviceSize offset = 0); + + using DeviceObject::Create; + inline bool Create(const DeviceHandle& device, VkBufferCreateFlags flags, VkDeviceSize size, VkBufferUsageFlags usage, const VkAllocationCallbacks* allocator = nullptr); + VkMemoryRequirements GetMemoryRequirements() const; Buffer& operator=(const Buffer&) = delete; diff --git a/include/Nazara/Vulkan/VkBuffer.inl b/include/Nazara/Vulkan/VkBuffer.inl index b2f0f07d4..088c7cab3 100644 --- a/include/Nazara/Vulkan/VkBuffer.inl +++ b/include/Nazara/Vulkan/VkBuffer.inl @@ -9,6 +9,34 @@ namespace Nz { namespace Vk { + inline bool Buffer::BindBufferMemory(VkDeviceMemory memory, VkDeviceSize offset) + { + m_lastErrorCode = m_device->vkBindBufferMemory(*m_device, m_handle, memory, offset); + if (m_lastErrorCode != VK_SUCCESS) + { + NazaraError("Failed to bind buffer memory"); + return false; + } + + return true; + } + + inline bool Buffer::Create(const DeviceHandle& device, VkBufferCreateFlags flags, VkDeviceSize size, VkBufferUsageFlags usage, const VkAllocationCallbacks* allocator) + { + VkBufferCreateInfo createInfo = { + VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + flags, // VkBufferCreateFlags flags; + size, // VkDeviceSize size; + usage, // VkBufferUsageFlags usage; + VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode; + 0, // uint32_t queueFamilyIndexCount; + nullptr // const uint32_t* pQueueFamilyIndices; + }; + + return Create(device, createInfo, allocator); + } + inline VkMemoryRequirements Buffer::GetMemoryRequirements() const { NazaraAssert(IsValid(), "Invalid buffer"); diff --git a/include/Nazara/Vulkan/VkCommandBuffer.hpp b/include/Nazara/Vulkan/VkCommandBuffer.hpp index f496f90f2..639373d45 100644 --- a/include/Nazara/Vulkan/VkCommandBuffer.hpp +++ b/include/Nazara/Vulkan/VkCommandBuffer.hpp @@ -34,9 +34,13 @@ namespace Nz inline void BeginRenderPass(const VkRenderPassBeginInfo& beginInfo, VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE); + inline void BindIndexBuffer(VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType); inline void BindPipeline(VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline); + inline void BindVertexBuffer(UInt32 binding, const VkBuffer buffer, const VkDeviceSize offset); + inline void BindVertexBuffers(UInt32 firstBinding, UInt32 bindingCount, const VkBuffer* buffer, const VkDeviceSize* offset); inline void Draw(UInt32 vertexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0); + inline void DrawIndexed(UInt32 indexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, Int32 vertexOffset = 0, UInt32 firstInstance = 0); inline bool End(); diff --git a/include/Nazara/Vulkan/VkCommandBuffer.inl b/include/Nazara/Vulkan/VkCommandBuffer.inl index ee543fd86..11cb402b7 100644 --- a/include/Nazara/Vulkan/VkCommandBuffer.inl +++ b/include/Nazara/Vulkan/VkCommandBuffer.inl @@ -128,16 +128,36 @@ namespace Nz return m_pool->GetDevice()->vkCmdBeginRenderPass(m_handle, &beginInfo, contents); } + inline void CommandBuffer::BindIndexBuffer(VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType) + { + return m_pool->GetDevice()->vkCmdBindIndexBuffer(m_handle, buffer, offset, indexType); + } + inline void CommandBuffer::BindPipeline(VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline) { return m_pool->GetDevice()->vkCmdBindPipeline(m_handle, pipelineBindPoint, pipeline); } + inline void CommandBuffer::BindVertexBuffer(UInt32 binding, const VkBuffer buffer, const VkDeviceSize offset) + { + return BindVertexBuffers(binding, 1, &buffer, &offset); + } + + inline void CommandBuffer::BindVertexBuffers(UInt32 firstBinding, UInt32 bindingCount, const VkBuffer* buffer, const VkDeviceSize* offset) + { + return m_pool->GetDevice()->vkCmdBindVertexBuffers(m_handle, firstBinding, bindingCount, buffer, offset); + } + inline void CommandBuffer::Draw(UInt32 vertexCount, UInt32 instanceCount, UInt32 firstVertex, UInt32 firstInstance) { return m_pool->GetDevice()->vkCmdDraw(m_handle, vertexCount, instanceCount, firstVertex, firstInstance); } + inline void CommandBuffer::DrawIndexed(UInt32 indexCount, UInt32 instanceCount, UInt32 firstVertex, Int32 vertexOffset, UInt32 firstInstance) + { + return m_pool->GetDevice()->vkCmdDrawIndexed(m_handle, indexCount, instanceCount, firstVertex, vertexOffset, firstInstance); + } + inline bool CommandBuffer::End() { m_lastErrorCode = m_pool->GetDevice()->vkEndCommandBuffer(m_handle); diff --git a/include/Nazara/Vulkan/VkDeviceMemory.hpp b/include/Nazara/Vulkan/VkDeviceMemory.hpp index 67e37d4c3..c35ffc07d 100644 --- a/include/Nazara/Vulkan/VkDeviceMemory.hpp +++ b/include/Nazara/Vulkan/VkDeviceMemory.hpp @@ -19,21 +19,29 @@ namespace Nz friend DeviceObject; public: - DeviceMemory() = default; + DeviceMemory(); DeviceMemory(const DeviceMemory&) = delete; - DeviceMemory(DeviceMemory&&) = default; + DeviceMemory(DeviceMemory&& memory); ~DeviceMemory() = default; using DeviceObject::Create; inline bool Create(const DeviceHandle& device, VkDeviceSize size, UInt32 memoryType, const VkAllocationCallbacks* allocator = nullptr); inline bool Create(const DeviceHandle& device, VkDeviceSize size, UInt32 typeBits, VkFlags properties, const VkAllocationCallbacks* allocator = nullptr); + inline void* GetMappedPointer(); + + inline bool Map(VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags = 0); + + inline void Unmap(); + DeviceMemory& operator=(const DeviceMemory&) = delete; DeviceMemory& operator=(DeviceMemory&&) = delete; private: static inline VkResult CreateHelper(const DeviceHandle& device, const VkMemoryAllocateInfo* allocInfo, const VkAllocationCallbacks* allocator, VkDeviceMemory* handle); static inline void DestroyHelper(const DeviceHandle& device, VkDeviceMemory handle, const VkAllocationCallbacks* allocator); + + void* m_mappedPtr; }; } } diff --git a/include/Nazara/Vulkan/VkDeviceMemory.inl b/include/Nazara/Vulkan/VkDeviceMemory.inl index 2139c9e22..5327ff6bc 100644 --- a/include/Nazara/Vulkan/VkDeviceMemory.inl +++ b/include/Nazara/Vulkan/VkDeviceMemory.inl @@ -11,6 +11,18 @@ namespace Nz { namespace Vk { + inline DeviceMemory::DeviceMemory() : + m_mappedPtr(nullptr) + { + } + + DeviceMemory::DeviceMemory(DeviceMemory&& memory) : + DeviceObject(std::move(memory)) + { + m_mappedPtr = memory.m_mappedPtr; + memory.m_mappedPtr = nullptr; + } + inline bool DeviceMemory::Create(const DeviceHandle& device, VkDeviceSize size, UInt32 memoryType, const VkAllocationCallbacks* allocator) { VkMemoryAllocateInfo allocInfo = @@ -44,6 +56,31 @@ namespace Nz return false; } + inline void* DeviceMemory::GetMappedPointer() + { + return m_mappedPtr; + } + + inline bool DeviceMemory::Map(VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags) + { + m_lastErrorCode = m_device->vkMapMemory(*m_device, m_handle, offset, size, flags, &m_mappedPtr); + if (m_lastErrorCode != VK_SUCCESS) + { + NazaraError("Failed to map device memory"); + return false; + } + + return true; + } + + inline void DeviceMemory::Unmap() + { + NazaraAssert(m_mappedPtr != nullptr, "Memory is not mapped"); + + m_device->vkUnmapMemory(*m_device, m_handle); + m_mappedPtr = nullptr; + } + inline VkResult DeviceMemory::CreateHelper(const DeviceHandle& device, const VkMemoryAllocateInfo* allocInfo, const VkAllocationCallbacks* allocator, VkDeviceMemory* handle) { return device->vkAllocateMemory(*device, allocInfo, allocator, handle); From 6d737b07ccc6abb64724b6bca5c0aef11a29f693 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 21 Jul 2016 12:25:05 +0200 Subject: [PATCH 044/316] Vulkan: Add support for Descriptors Former-commit-id: 3aeb182030040b707dd2d98ddb2991a3b7f58b19 [formerly bf30ae4035d9855f493252bd7c1c95d97e7f4bf5] Former-commit-id: 8bdbc5f6ff1bec375c80b0974bdd1e269cfca675 --- include/Nazara/Vulkan.hpp | 5 +- include/Nazara/Vulkan/VkCommandBuffer.hpp | 3 + include/Nazara/Vulkan/VkCommandBuffer.inl | 15 +++ include/Nazara/Vulkan/VkDescriptorPool.hpp | 52 ++++++++ include/Nazara/Vulkan/VkDescriptorPool.inl | 54 ++++++++ include/Nazara/Vulkan/VkDescriptorSet.hpp | 59 +++++++++ include/Nazara/Vulkan/VkDescriptorSet.inl | 122 ++++++++++++++++++ .../Nazara/Vulkan/VkDescriptorSetLayout.hpp | 43 ++++++ .../Nazara/Vulkan/VkDescriptorSetLayout.inl | 43 ++++++ include/Nazara/Vulkan/VkDevice.hpp | 1 + src/Nazara/Vulkan/VkDescriptorPool.cpp | 53 ++++++++ src/Nazara/Vulkan/VkDevice.cpp | 1 + 12 files changed, 450 insertions(+), 1 deletion(-) create mode 100644 include/Nazara/Vulkan/VkDescriptorPool.hpp create mode 100644 include/Nazara/Vulkan/VkDescriptorPool.inl create mode 100644 include/Nazara/Vulkan/VkDescriptorSet.hpp create mode 100644 include/Nazara/Vulkan/VkDescriptorSet.inl create mode 100644 include/Nazara/Vulkan/VkDescriptorSetLayout.hpp create mode 100644 include/Nazara/Vulkan/VkDescriptorSetLayout.inl create mode 100644 src/Nazara/Vulkan/VkDescriptorPool.cpp diff --git a/include/Nazara/Vulkan.hpp b/include/Nazara/Vulkan.hpp index 7a158c6f5..a19279f89 100644 --- a/include/Nazara/Vulkan.hpp +++ b/include/Nazara/Vulkan.hpp @@ -1,4 +1,4 @@ -// This file was automatically generated on 12 Jul 2016 at 17:44:44 +// This file was automatically generated on 20 Jul 2016 at 13:49:17 /* Nazara Engine - Vulkan @@ -35,6 +35,9 @@ #include #include #include +#include +#include +#include #include #include #include diff --git a/include/Nazara/Vulkan/VkCommandBuffer.hpp b/include/Nazara/Vulkan/VkCommandBuffer.hpp index 639373d45..0c7ff6a75 100644 --- a/include/Nazara/Vulkan/VkCommandBuffer.hpp +++ b/include/Nazara/Vulkan/VkCommandBuffer.hpp @@ -34,6 +34,9 @@ namespace Nz inline void BeginRenderPass(const VkRenderPassBeginInfo& beginInfo, VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE); + inline void BindDescriptorSet(VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, UInt32 firstSet, const VkDescriptorSet& descriptorSets); + inline void BindDescriptorSets(VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, UInt32 firstSet, UInt32 descriptorSetCount, const VkDescriptorSet* descriptorSets); + inline void BindDescriptorSets(VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, UInt32 firstSet, UInt32 descriptorSetCount, const VkDescriptorSet* descriptorSets, UInt32 dynamicOffsetCount, const UInt32* dynamicOffsets); inline void BindIndexBuffer(VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType); inline void BindPipeline(VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline); inline void BindVertexBuffer(UInt32 binding, const VkBuffer buffer, const VkDeviceSize offset); diff --git a/include/Nazara/Vulkan/VkCommandBuffer.inl b/include/Nazara/Vulkan/VkCommandBuffer.inl index 11cb402b7..238113765 100644 --- a/include/Nazara/Vulkan/VkCommandBuffer.inl +++ b/include/Nazara/Vulkan/VkCommandBuffer.inl @@ -128,6 +128,21 @@ namespace Nz return m_pool->GetDevice()->vkCmdBeginRenderPass(m_handle, &beginInfo, contents); } + inline void CommandBuffer::BindDescriptorSet(VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, UInt32 firstSet, const VkDescriptorSet& descriptorSets) + { + return BindDescriptorSets(pipelineBindPoint, layout, firstSet, 1U, &descriptorSets); + } + + inline void CommandBuffer::BindDescriptorSets(VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, UInt32 firstSet, UInt32 descriptorSetCount, const VkDescriptorSet* descriptorSets) + { + return BindDescriptorSets(pipelineBindPoint, layout, firstSet, descriptorSetCount, descriptorSets, 0U, nullptr); + } + + inline void CommandBuffer::BindDescriptorSets(VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, UInt32 firstSet, UInt32 descriptorSetCount, const VkDescriptorSet* descriptorSets, UInt32 dynamicOffsetCount, const UInt32* dynamicOffsets) + { + return m_pool->GetDevice()->vkCmdBindDescriptorSets(m_handle, pipelineBindPoint, layout, firstSet, descriptorSetCount, descriptorSets, dynamicOffsetCount, dynamicOffsets); + } + inline void CommandBuffer::BindIndexBuffer(VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType) { return m_pool->GetDevice()->vkCmdBindIndexBuffer(m_handle, buffer, offset, indexType); diff --git a/include/Nazara/Vulkan/VkDescriptorPool.hpp b/include/Nazara/Vulkan/VkDescriptorPool.hpp new file mode 100644 index 000000000..f5f39d52d --- /dev/null +++ b/include/Nazara/Vulkan/VkDescriptorPool.hpp @@ -0,0 +1,52 @@ +// 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_VKDESCRIPTORPOOL_HPP +#define NAZARA_VULKAN_VKDESCRIPTORPOOL_HPP + +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + class DescriptorPool; + class DescriptorSet; + + using DescriptorPoolHandle = ObjectHandle; + + class NAZARA_VULKAN_API DescriptorPool : public DeviceObject, public HandledObject + { + friend DeviceObject; + + public: + DescriptorPool() = default; + DescriptorPool(const DescriptorPool&) = delete; + DescriptorPool(DescriptorPool&&) = default; + ~DescriptorPool() = default; + + DescriptorSet AllocateDescriptorSet(const VkDescriptorSetLayout& setLayouts); + std::vector AllocateDescriptorSets(UInt32 descriptorSetCount, const VkDescriptorSetLayout* setLayouts); + + using DeviceObject::Create; + inline bool Create(const DeviceHandle& device, UInt32 maxSets, const VkDescriptorPoolSize& poolSize, VkDescriptorPoolCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(const DeviceHandle& device, UInt32 maxSets, UInt32 poolSizeCount, const VkDescriptorPoolSize* poolSize, VkDescriptorPoolCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + + DescriptorPool& operator=(const DescriptorPool&) = delete; + DescriptorPool& operator=(DescriptorPool&&) = delete; + + private: + static inline VkResult CreateHelper(const DeviceHandle& device, const VkDescriptorPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkDescriptorPool* handle); + static inline void DestroyHelper(const DeviceHandle& device, VkDescriptorPool handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_VULKAN_VKDESCRIPTORPOOL_HPP diff --git a/include/Nazara/Vulkan/VkDescriptorPool.inl b/include/Nazara/Vulkan/VkDescriptorPool.inl new file mode 100644 index 000000000..7864a7b4a --- /dev/null +++ b/include/Nazara/Vulkan/VkDescriptorPool.inl @@ -0,0 +1,54 @@ +// 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 bool DescriptorPool::Create(const DeviceHandle& device, UInt32 maxSets, const VkDescriptorPoolSize& poolSize, VkDescriptorPoolCreateFlags flags, const VkAllocationCallbacks* allocator) + { + VkDescriptorPoolCreateInfo createInfo = + { + VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + flags, // VkDescriptorPoolCreateFlags flags; + maxSets, // uint32_t maxSets; + 1U, // uint32_t poolSizeCount; + &poolSize // const VkDescriptorPoolSize* pPoolSizes; + }; + + return Create(device, createInfo, allocator); + } + + inline bool DescriptorPool::Create(const DeviceHandle& device, UInt32 maxSets, UInt32 poolSizeCount, const VkDescriptorPoolSize* poolSize, VkDescriptorPoolCreateFlags flags, const VkAllocationCallbacks* allocator) + { + VkDescriptorPoolCreateInfo createInfo = + { + VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + flags, // VkDescriptorPoolCreateFlags flags; + maxSets, // uint32_t maxSets; + poolSizeCount, // uint32_t poolSizeCount; + poolSize // const VkDescriptorPoolSize* pPoolSizes; + }; + + return Create(device, createInfo, allocator); + } + + inline VkResult DescriptorPool::CreateHelper(const DeviceHandle& device, const VkDescriptorPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkDescriptorPool* handle) + { + return device->vkCreateDescriptorPool(*device, createInfo, allocator, handle); + } + + inline void DescriptorPool::DestroyHelper(const DeviceHandle& device, VkDescriptorPool handle, const VkAllocationCallbacks* allocator) + { + return device->vkDestroyDescriptorPool(*device, handle, allocator); + } + } +} + +#include diff --git a/include/Nazara/Vulkan/VkDescriptorSet.hpp b/include/Nazara/Vulkan/VkDescriptorSet.hpp new file mode 100644 index 000000000..d3f30f0b2 --- /dev/null +++ b/include/Nazara/Vulkan/VkDescriptorSet.hpp @@ -0,0 +1,59 @@ +// 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_VKDESCRIPTORSET_HPP +#define NAZARA_VULKAN_VKDESCRIPTORSET_HPP + +#include +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + class DescriptorSet + { + friend DescriptorPool; + + public: + inline DescriptorSet(); + DescriptorSet(const DescriptorSet&) = delete; + inline DescriptorSet(DescriptorSet&& descriptorSet); + inline ~DescriptorSet(); + + inline void Free(); + + inline VkResult GetLastErrorCode() const; + + inline void WriteUniformDescriptor(UInt32 binding, VkBuffer buffer, VkDeviceSize offset, VkDeviceSize range); + inline void WriteUniformDescriptor(UInt32 binding, const VkDescriptorBufferInfo& bufferInfo); + inline void WriteUniformDescriptor(UInt32 binding, UInt32 arrayElement, VkBuffer buffer, VkDeviceSize offset, VkDeviceSize range); + inline void WriteUniformDescriptor(UInt32 binding, UInt32 arrayElement, const VkDescriptorBufferInfo& bufferInfo); + inline void WriteUniformDescriptors(UInt32 binding, UInt32 descriptorCount, const VkDescriptorBufferInfo* bufferInfo); + inline void WriteUniformDescriptors(UInt32 binding, UInt32 arrayElement, UInt32 descriptorCount, const VkDescriptorBufferInfo* bufferInfo); + + DescriptorSet& operator=(const DescriptorSet&) = delete; + DescriptorSet& operator=(DescriptorSet&& descriptorSet); + + inline operator VkDescriptorSet() const; + + private: + inline DescriptorSet(DescriptorPool& pool, VkDescriptorSet handle); + + DescriptorPoolHandle m_pool; + VkAllocationCallbacks m_allocator; + VkDescriptorSet m_handle; + VkResult m_lastErrorCode; + + }; + } +} + +#include + +#endif // NAZARA_VULKAN_VKDESCRIPTORSET_HPP diff --git a/include/Nazara/Vulkan/VkDescriptorSet.inl b/include/Nazara/Vulkan/VkDescriptorSet.inl new file mode 100644 index 000000000..73e7fae03 --- /dev/null +++ b/include/Nazara/Vulkan/VkDescriptorSet.inl @@ -0,0 +1,122 @@ +// 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 DescriptorSet::DescriptorSet() : + m_pool(), + m_handle(VK_NULL_HANDLE) + { + } + + inline DescriptorSet::DescriptorSet(DescriptorPool& pool, VkDescriptorSet handle) : + m_pool(&pool), + m_handle(handle) + { + } + + inline DescriptorSet::DescriptorSet(DescriptorSet&& descriptorSet) : + m_pool(std::move(descriptorSet.m_pool)), + m_allocator(descriptorSet.m_allocator), + m_handle(descriptorSet.m_handle), + m_lastErrorCode(descriptorSet.m_lastErrorCode) + { + descriptorSet.m_handle = VK_NULL_HANDLE; + } + + inline DescriptorSet::~DescriptorSet() + { + Free(); + } + + inline void DescriptorSet::Free() + { + if (m_handle) + m_pool->GetDevice()->vkFreeDescriptorSets(*m_pool->GetDevice(), *m_pool, 1, &m_handle); + } + + inline VkResult DescriptorSet::GetLastErrorCode() const + { + return m_lastErrorCode; + } + + inline void DescriptorSet::WriteUniformDescriptor(UInt32 binding, VkBuffer buffer, VkDeviceSize offset, VkDeviceSize range) + { + return WriteUniformDescriptor(binding, 0U, buffer, offset, range); + } + + inline void DescriptorSet::WriteUniformDescriptor(UInt32 binding, const VkDescriptorBufferInfo& bufferInfo) + { + return WriteUniformDescriptors(binding, 0U, 1U, &bufferInfo); + } + + inline void DescriptorSet::WriteUniformDescriptor(UInt32 binding, UInt32 arrayElement, VkBuffer buffer, VkDeviceSize offset, VkDeviceSize range) + { + VkDescriptorBufferInfo bufferInfo = + { + buffer, // VkBuffer buffer; + offset, // VkDeviceSize offset; + range // VkDeviceSize range; + }; + + return WriteUniformDescriptor(binding, arrayElement, bufferInfo); + } + + inline void DescriptorSet::WriteUniformDescriptor(UInt32 binding, UInt32 arrayElement, const VkDescriptorBufferInfo& bufferInfo) + { + return WriteUniformDescriptors(binding, arrayElement, 1U, &bufferInfo); + } + + inline void DescriptorSet::WriteUniformDescriptors(UInt32 binding, UInt32 descriptorCount, const VkDescriptorBufferInfo* bufferInfo) + { + return WriteUniformDescriptors(binding, 0U, descriptorCount, bufferInfo); + } + + inline void DescriptorSet::WriteUniformDescriptors(UInt32 binding, UInt32 arrayElement, UInt32 descriptorCount, const VkDescriptorBufferInfo* bufferInfo) + { + VkWriteDescriptorSet writeDescriptorSet = + { + VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, // VkStructureType sType; + nullptr, // const void* pNext; + m_handle, // VkDescriptorSet dstSet; + binding, // uint32_t dstBinding; + arrayElement, // uint32_t dstArrayElement; + descriptorCount, // uint32_t descriptorCount; + VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, // VkDescriptorType descriptorType; + nullptr, // const VkDescriptorImageInfo* pImageInfo; + bufferInfo, // const VkDescriptorBufferInfo* pBufferInfo; + nullptr // const VkBufferView* pTexelBufferView; + }; + + return m_pool->GetDevice()->vkUpdateDescriptorSets(*m_pool->GetDevice(), 1U, &writeDescriptorSet, 0U, nullptr); + } + + inline DescriptorSet& DescriptorSet::operator=(DescriptorSet&& descriptorSet) + { + m_allocator = descriptorSet.m_allocator; + m_handle = descriptorSet.m_handle; + m_lastErrorCode = descriptorSet.m_lastErrorCode; + m_pool = std::move(descriptorSet.m_pool); + m_handle = descriptorSet.m_handle; + + descriptorSet.m_handle = VK_NULL_HANDLE; + + return *this; + } + + inline DescriptorSet::operator VkDescriptorSet() const + { + return m_handle; + } + } +} + +#include diff --git a/include/Nazara/Vulkan/VkDescriptorSetLayout.hpp b/include/Nazara/Vulkan/VkDescriptorSetLayout.hpp new file mode 100644 index 000000000..b4cdb8427 --- /dev/null +++ b/include/Nazara/Vulkan/VkDescriptorSetLayout.hpp @@ -0,0 +1,43 @@ +// 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_VKDESCRIPTORSETLAYOUT_HPP +#define NAZARA_VULKAN_VKDESCRIPTORSETLAYOUT_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class DescriptorSetLayout : public DeviceObject + { + friend DeviceObject; + + public: + DescriptorSetLayout() = default; + DescriptorSetLayout(const DescriptorSetLayout&) = delete; + DescriptorSetLayout(DescriptorSetLayout&&) = default; + ~DescriptorSetLayout() = default; + + using DeviceObject::Create; + inline bool Create(const DeviceHandle& device, const VkDescriptorSetLayoutBinding& binding, VkDescriptorSetLayoutCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(const DeviceHandle& device, UInt32 bindingCount, const VkDescriptorSetLayoutBinding* binding, VkDescriptorSetLayoutCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + + DescriptorSetLayout& operator=(const DescriptorSetLayout&) = delete; + DescriptorSetLayout& operator=(DescriptorSetLayout&&) = delete; + + private: + static inline VkResult CreateHelper(const DeviceHandle& device, const VkDescriptorSetLayoutCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkDescriptorSetLayout* handle); + static inline void DestroyHelper(const DeviceHandle& device, VkDescriptorSetLayout handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_VULKAN_VKDESCRIPTORSETLAYOUT_HPP diff --git a/include/Nazara/Vulkan/VkDescriptorSetLayout.inl b/include/Nazara/Vulkan/VkDescriptorSetLayout.inl new file mode 100644 index 000000000..1dde03e09 --- /dev/null +++ b/include/Nazara/Vulkan/VkDescriptorSetLayout.inl @@ -0,0 +1,43 @@ +// 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 bool DescriptorSetLayout::Create(const DeviceHandle& device, const VkDescriptorSetLayoutBinding& binding, VkDescriptorSetLayoutCreateFlags flags, const VkAllocationCallbacks* allocator) + { + return Create(device, 1U, &binding, flags, allocator); + } + + inline bool DescriptorSetLayout::Create(const DeviceHandle& device, UInt32 bindingCount, const VkDescriptorSetLayoutBinding* binding, VkDescriptorSetLayoutCreateFlags flags, const VkAllocationCallbacks* allocator) + { + VkDescriptorSetLayoutCreateInfo createInfo = + { + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + flags, // VkDescriptorSetLayoutCreateFlags flags; + bindingCount, // uint32_t bindingCount; + binding // const VkDescriptorSetLayoutBinding* pBindings; + }; + + return Create(device, createInfo, allocator); + } + + inline VkResult DescriptorSetLayout::CreateHelper(const DeviceHandle& device, const VkDescriptorSetLayoutCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkDescriptorSetLayout* handle) + { + return device->vkCreateDescriptorSetLayout(*device, createInfo, allocator, handle); + } + + inline void DescriptorSetLayout::DestroyHelper(const DeviceHandle& device, VkDescriptorSetLayout handle, const VkAllocationCallbacks* allocator) + { + return device->vkDestroyDescriptorSetLayout(*device, handle, allocator); + } + } +} + +#include diff --git a/include/Nazara/Vulkan/VkDevice.hpp b/include/Nazara/Vulkan/VkDevice.hpp index c9044fb1c..4fc7c7da2 100644 --- a/include/Nazara/Vulkan/VkDevice.hpp +++ b/include/Nazara/Vulkan/VkDevice.hpp @@ -63,6 +63,7 @@ namespace Nz // Vulkan core NAZARA_VULKAN_DEVICE_FUNCTION(vkAllocateCommandBuffers); + NAZARA_VULKAN_DEVICE_FUNCTION(vkAllocateDescriptorSets); NAZARA_VULKAN_DEVICE_FUNCTION(vkAllocateMemory); NAZARA_VULKAN_DEVICE_FUNCTION(vkBeginCommandBuffer); NAZARA_VULKAN_DEVICE_FUNCTION(vkBindBufferMemory); diff --git a/src/Nazara/Vulkan/VkDescriptorPool.cpp b/src/Nazara/Vulkan/VkDescriptorPool.cpp new file mode 100644 index 000000000..73e7325e3 --- /dev/null +++ b/src/Nazara/Vulkan/VkDescriptorPool.cpp @@ -0,0 +1,53 @@ +// 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 + { + DescriptorSet DescriptorPool::AllocateDescriptorSet(const VkDescriptorSetLayout& setLayouts) + { + VkDescriptorSetAllocateInfo createInfo = + { + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + m_handle, // VkDescriptorPool descriptorPool; + 1U, // uint32_t descriptorSetCount; + &setLayouts // const VkDescriptorSetLayout* pSetLayouts; + }; + + VkDescriptorSet handle = VK_NULL_HANDLE; + m_lastErrorCode = m_device->vkAllocateDescriptorSets(*m_device, &createInfo, &handle); + + return DescriptorSet(*this, handle); + } + + std::vector DescriptorPool::AllocateDescriptorSets(UInt32 descriptorSetCount, const VkDescriptorSetLayout* setLayouts) + { + VkDescriptorSetAllocateInfo createInfo = + { + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + m_handle, // VkDescriptorPool descriptorPool; + descriptorSetCount, // uint32_t descriptorSetCount; + setLayouts // const VkDescriptorSetLayout* pSetLayouts; + }; + + std::vector handles(descriptorSetCount, VK_NULL_HANDLE); + m_lastErrorCode = m_device->vkAllocateDescriptorSets(*m_device, &createInfo, handles.data()); + if (m_lastErrorCode != VkResult::VK_SUCCESS) + return std::vector(); + + std::vector descriptorSets; + for (UInt32 i = 0; i < descriptorSetCount; ++i) + descriptorSets.emplace_back(DescriptorSet(*this, handles[i])); + + return descriptorSets; + } + } +} diff --git a/src/Nazara/Vulkan/VkDevice.cpp b/src/Nazara/Vulkan/VkDevice.cpp index 9ecbf57de..3f82f503e 100644 --- a/src/Nazara/Vulkan/VkDevice.cpp +++ b/src/Nazara/Vulkan/VkDevice.cpp @@ -50,6 +50,7 @@ namespace Nz ErrorFlags flags(ErrorFlag_ThrowException, true); NAZARA_VULKAN_LOAD_DEVICE(vkAllocateCommandBuffers); + NAZARA_VULKAN_LOAD_DEVICE(vkAllocateDescriptorSets); NAZARA_VULKAN_LOAD_DEVICE(vkAllocateMemory); NAZARA_VULKAN_LOAD_DEVICE(vkBeginCommandBuffer); NAZARA_VULKAN_LOAD_DEVICE(vkBindBufferMemory); From 6e286ed2fe6910c262e83d3b308514923a6fd046 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 21 Jul 2016 13:04:02 +0200 Subject: [PATCH 045/316] Vulkan/CommandBuffer: Add clear commands Former-commit-id: 864dd930ae6514900eb28dfc19410ed4d02223ad [formerly 5f23a3dcf2387b85b606554e38e3809c25886139] Former-commit-id: 3f17750c2673273909752d1423422b5c9d8be164 --- include/Nazara/Vulkan/VkCommandBuffer.hpp | 9 +++++++ include/Nazara/Vulkan/VkCommandBuffer.inl | 30 +++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/include/Nazara/Vulkan/VkCommandBuffer.hpp b/include/Nazara/Vulkan/VkCommandBuffer.hpp index 0c7ff6a75..bff5d6db1 100644 --- a/include/Nazara/Vulkan/VkCommandBuffer.hpp +++ b/include/Nazara/Vulkan/VkCommandBuffer.hpp @@ -42,6 +42,15 @@ namespace Nz inline void BindVertexBuffer(UInt32 binding, const VkBuffer buffer, const VkDeviceSize offset); inline void BindVertexBuffers(UInt32 firstBinding, UInt32 bindingCount, const VkBuffer* buffer, const VkDeviceSize* offset); + inline void ClearAttachment(const VkClearAttachment& attachment, const VkClearRect& rect); + inline void ClearAttachments(UInt32 attachmentCount, const VkClearAttachment* attachments, UInt32 rectCount, const VkClearRect* rects); + + inline void ClearColorImage(VkImage image, VkImageLayout imageLayout, const VkClearColorValue& color, const VkImageSubresourceRange& range); + inline void ClearColorImage(VkImage image, VkImageLayout imageLayout, const VkClearColorValue& color, UInt32 rangeCount, const VkImageSubresourceRange* ranges); + + inline void ClearDepthStencilImage(VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue& depthStencil, const VkImageSubresourceRange& range); + inline void ClearDepthStencilImage(VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue& depthStencil, UInt32 rangeCount, const VkImageSubresourceRange* ranges); + inline void Draw(UInt32 vertexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0); inline void DrawIndexed(UInt32 indexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, Int32 vertexOffset = 0, UInt32 firstInstance = 0); diff --git a/include/Nazara/Vulkan/VkCommandBuffer.inl b/include/Nazara/Vulkan/VkCommandBuffer.inl index 238113765..16530d80e 100644 --- a/include/Nazara/Vulkan/VkCommandBuffer.inl +++ b/include/Nazara/Vulkan/VkCommandBuffer.inl @@ -163,6 +163,36 @@ namespace Nz return m_pool->GetDevice()->vkCmdBindVertexBuffers(m_handle, firstBinding, bindingCount, buffer, offset); } + inline void CommandBuffer::ClearAttachment(const VkClearAttachment& attachment, const VkClearRect& rect) + { + return ClearAttachments(1U, &attachment, 1U, &rect); + } + + inline void CommandBuffer::ClearAttachments(UInt32 attachmentCount, const VkClearAttachment* attachments, UInt32 rectCount, const VkClearRect* rects) + { + return m_pool->GetDevice()->vkCmdClearAttachments(m_handle, attachmentCount, attachments, rectCount, rects); + } + + inline void CommandBuffer::ClearColorImage(VkImage image, VkImageLayout imageLayout, const VkClearColorValue& color, const VkImageSubresourceRange& range) + { + return ClearColorImage(image, imageLayout, color, 1U, &range); + } + + inline void CommandBuffer::ClearColorImage(VkImage image, VkImageLayout imageLayout, const VkClearColorValue& color, UInt32 rangeCount, const VkImageSubresourceRange* ranges) + { + return m_pool->GetDevice()->vkCmdClearColorImage(m_handle, image, imageLayout, &color, rangeCount, ranges); + } + + inline void CommandBuffer::ClearDepthStencilImage(VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue& depthStencil, const VkImageSubresourceRange& range) + { + return ClearDepthStencilImage(image, imageLayout, depthStencil, 1U, &range); + } + + inline void CommandBuffer::ClearDepthStencilImage(VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue& depthStencil, UInt32 rangeCount, const VkImageSubresourceRange * ranges) + { + return m_pool->GetDevice()->vkCmdClearDepthStencilImage(m_handle, image, imageLayout, &depthStencil, rangeCount, ranges); + } + inline void CommandBuffer::Draw(UInt32 vertexCount, UInt32 instanceCount, UInt32 firstVertex, UInt32 firstInstance) { return m_pool->GetDevice()->vkCmdDraw(m_handle, vertexCount, instanceCount, firstVertex, firstInstance); From 16818fa7a3c949ec0a6c34dc4a3a27b762836dd6 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 9 Aug 2016 13:51:56 +0200 Subject: [PATCH 046/316] Vulkan: Simplify GetPhysicalDevice* functions if possible Former-commit-id: b988fa0aa44cd6a4901f2c3a186be36f7af4fa5b [formerly 078ffb29db688a5be9073a878c9097c1dd8d5b90] [formerly 4ec47c87662b2a5e9ce6552a136028fd38926137 [formerly 608a8dfadf1d4a28c83eaf7e8c7f1d68367ed311]] Former-commit-id: a648892c9de765f4ad831502650389ab134e932c [formerly 40666003fc56c12591937aae0de884904fe0a6cb] Former-commit-id: 6517c78c107dcded7b5a3dbcec860f1a3d74936d --- include/Nazara/Vulkan/VkInstance.hpp | 8 ++++---- include/Nazara/Vulkan/VkInstance.inl | 28 ++++++++++++++++++++-------- src/Nazara/Vulkan/Vulkan.cpp | 6 +++--- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/include/Nazara/Vulkan/VkInstance.hpp b/include/Nazara/Vulkan/VkInstance.hpp index ded2b0ef7..7b36ff14a 100644 --- a/include/Nazara/Vulkan/VkInstance.hpp +++ b/include/Nazara/Vulkan/VkInstance.hpp @@ -34,11 +34,11 @@ namespace Nz 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 VkPhysicalDeviceFeatures GetPhysicalDeviceFeatures(VkPhysicalDevice device); + inline VkFormatProperties GetPhysicalDeviceFormatProperties(VkPhysicalDevice device, VkFormat format); 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); + inline VkPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties(VkPhysicalDevice device); + inline VkPhysicalDeviceProperties GetPhysicalDeviceProperties(VkPhysicalDevice device); bool GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice device, std::vector* queueFamilyProperties); inline VkResult GetLastErrorCode() const; diff --git a/include/Nazara/Vulkan/VkInstance.inl b/include/Nazara/Vulkan/VkInstance.inl index bea7164fb..a8793ece7 100644 --- a/include/Nazara/Vulkan/VkInstance.inl +++ b/include/Nazara/Vulkan/VkInstance.inl @@ -85,14 +85,20 @@ namespace Nz return m_instance; } - inline void Instance::GetPhysicalDeviceFeatures(VkPhysicalDevice device, VkPhysicalDeviceFeatures* features) + inline VkPhysicalDeviceFeatures Instance::GetPhysicalDeviceFeatures(VkPhysicalDevice device) { - return vkGetPhysicalDeviceFeatures(device, features); + VkPhysicalDeviceFeatures features; + vkGetPhysicalDeviceFeatures(device, &features); + + return features; } - inline void Instance::GetPhysicalDeviceFormatProperties(VkPhysicalDevice device, VkFormat format, VkFormatProperties* formatProperties) + inline VkFormatProperties Instance::GetPhysicalDeviceFormatProperties(VkPhysicalDevice device, VkFormat format) { - return vkGetPhysicalDeviceFormatProperties(device, format, formatProperties); + VkFormatProperties formatProperties; + vkGetPhysicalDeviceFormatProperties(device, format, &formatProperties); + + return formatProperties; } inline bool Instance::GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* imageFormatProperties) @@ -107,14 +113,20 @@ namespace Nz return true; } - inline void Instance::GetPhysicalDeviceMemoryProperties(VkPhysicalDevice device, VkPhysicalDeviceMemoryProperties* memoryProperties) + inline VkPhysicalDeviceMemoryProperties Instance::GetPhysicalDeviceMemoryProperties(VkPhysicalDevice device) { - return vkGetPhysicalDeviceMemoryProperties(device, memoryProperties); + VkPhysicalDeviceMemoryProperties memoryProperties; + vkGetPhysicalDeviceMemoryProperties(device, &memoryProperties); + + return memoryProperties; } - inline void Instance::GetPhysicalDeviceProperties(VkPhysicalDevice device, VkPhysicalDeviceProperties* properties) + inline VkPhysicalDeviceProperties Instance::GetPhysicalDeviceProperties(VkPhysicalDevice device) { - return vkGetPhysicalDeviceProperties(device, properties); + VkPhysicalDeviceProperties properties; + vkGetPhysicalDeviceProperties(device, &properties); + + return properties; } inline PFN_vkVoidFunction Instance::GetProcAddr(const char* name) diff --git a/src/Nazara/Vulkan/Vulkan.cpp b/src/Nazara/Vulkan/Vulkan.cpp index 6af41d9b2..599728b35 100644 --- a/src/Nazara/Vulkan/Vulkan.cpp +++ b/src/Nazara/Vulkan/Vulkan.cpp @@ -213,9 +213,9 @@ namespace Nz deviceInfo.device = physDevice; - s_instance.GetPhysicalDeviceFeatures(physDevice, &deviceInfo.features); - s_instance.GetPhysicalDeviceMemoryProperties(physDevice, &deviceInfo.memoryProperties); - s_instance.GetPhysicalDeviceProperties(physDevice, &deviceInfo.properties); + deviceInfo.features = s_instance.GetPhysicalDeviceFeatures(physDevice); + deviceInfo.memoryProperties = s_instance.GetPhysicalDeviceMemoryProperties(physDevice); + deviceInfo.properties = s_instance.GetPhysicalDeviceProperties(physDevice); s_physDevices.emplace_back(std::move(deviceInfo)); } From 8776ffe953284155e07affd40309d2521b6a177f Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 9 Aug 2016 13:53:12 +0200 Subject: [PATCH 047/316] Vulkan/RenderWindow: Add support for depth buffer Former-commit-id: 42f113fcb7463c0f010fdc325b9024b08de3c667 [formerly 95040d268ff328f2d54459bf11c269dd5f042f73] [formerly 77c2d1139585cbf31f881ffddfb43b23284a7073 [formerly d235ff32fae4612d95d25524410bf1b43974d520]] Former-commit-id: bab56f18d034bade640bf023c97810adf2c717ff [formerly c62041abb56103d6c7aeac2b55f7bf66acd8882b] Former-commit-id: cef0ac55f6eaa54f17d3d0cc2030a4b9de7b166c --- include/Nazara/Vulkan/RenderWindow.hpp | 19 ++- include/Nazara/Vulkan/VkImage.hpp | 43 +++++ include/Nazara/Vulkan/VkImage.inl | 46 ++++++ src/Nazara/Vulkan/RenderWindow.cpp | 209 +++++++++++++++++++++---- 4 files changed, 277 insertions(+), 40 deletions(-) create mode 100644 include/Nazara/Vulkan/VkImage.hpp create mode 100644 include/Nazara/Vulkan/VkImage.inl diff --git a/include/Nazara/Vulkan/RenderWindow.hpp b/include/Nazara/Vulkan/RenderWindow.hpp index 1651f1b9e..59705cc7b 100644 --- a/include/Nazara/Vulkan/RenderWindow.hpp +++ b/include/Nazara/Vulkan/RenderWindow.hpp @@ -16,7 +16,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -39,13 +41,11 @@ namespace Nz void BuildPreRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) override; void BuildPostRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) override; - const Vk::Framebuffer& GetFrameBuffer(UInt32 imageIndex) const override; - - UInt32 GetFramebufferCount() const; - bool Create(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default); bool Create(WindowHandle handle); + const Vk::Framebuffer& GetFrameBuffer(UInt32 imageIndex) const override; + UInt32 GetFramebufferCount() const; const Vk::DeviceHandle& GetDevice() const; UInt32 GetPresentableFamilyQueue() const; const Vk::Surface& GetSurface() const; @@ -55,6 +55,7 @@ namespace Nz bool IsValid() const; + void SetDepthStencilFormats(std::vector pixelFormat); void SetPhysicalDevice(VkPhysicalDevice device); RenderWindow& operator=(const RenderWindow&) = delete; @@ -65,17 +66,21 @@ namespace Nz void OnWindowDestroy() override; void OnWindowResized() override; - bool SetupCommandBuffers(); + bool SetupDepthBuffer(); bool SetupRenderPass(); bool SetupSwapchain(); Clock m_clock; - VkFormat m_colorFormat; - VkFormat m_depthFormat; VkColorSpaceKHR m_colorSpace; + VkFormat m_colorFormat; + VkFormat m_depthStencilFormat; VkPhysicalDevice m_forcedPhysicalDevice; + std::vector m_wantedDepthStencilFormats; std::vector m_frameBuffers; Vk::DeviceHandle m_device; + Vk::DeviceMemory m_depthBufferMemory; + Vk::Image m_depthBuffer; + Vk::ImageView m_depthBufferView; Vk::Queue m_presentQueue; Vk::Surface m_surface; Vk::Swapchain m_swapchain; diff --git a/include/Nazara/Vulkan/VkImage.hpp b/include/Nazara/Vulkan/VkImage.hpp new file mode 100644 index 000000000..0eea6e5d9 --- /dev/null +++ b/include/Nazara/Vulkan/VkImage.hpp @@ -0,0 +1,43 @@ +// 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_VKIMAGE_HPP +#define NAZARA_VULKAN_VKIMAGE_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class Image : public DeviceObject + { + friend DeviceObject; + + public: + Image() = default; + Image(const Image&) = delete; + Image(Image&&) = default; + ~Image() = default; + + bool BindImageMemory(VkDeviceMemory memory, VkDeviceSize offset = 0); + + VkMemoryRequirements GetMemoryRequirements() const; + + Image& operator=(const Image&) = delete; + Image& operator=(Image&&) = delete; + + private: + static inline VkResult CreateHelper(const DeviceHandle& device, const VkImageCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkImage* handle); + static inline void DestroyHelper(const DeviceHandle& device, VkImage handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_VULKAN_VKIMAGE_HPP diff --git a/include/Nazara/Vulkan/VkImage.inl b/include/Nazara/Vulkan/VkImage.inl new file mode 100644 index 000000000..7e04a534f --- /dev/null +++ b/include/Nazara/Vulkan/VkImage.inl @@ -0,0 +1,46 @@ +// 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 bool Image::BindImageMemory(VkDeviceMemory memory, VkDeviceSize offset) + { + m_lastErrorCode = m_device->vkBindImageMemory(*m_device, m_handle, memory, offset); + if (m_lastErrorCode != VK_SUCCESS) + { + NazaraError("Failed to bind buffer memory"); + return false; + } + + return true; + } + + inline VkMemoryRequirements Image::GetMemoryRequirements() const + { + NazaraAssert(IsValid(), "Invalid image"); + + VkMemoryRequirements memoryRequirements; + m_device->vkGetImageMemoryRequirements(*m_device, m_handle, &memoryRequirements); + + return memoryRequirements; + } + + inline VkResult Image::CreateHelper(const DeviceHandle& device, const VkImageCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkImage* handle) + { + return device->vkCreateImage(*device, createInfo, allocator, handle); + } + + inline void Image::DestroyHelper(const DeviceHandle& device, VkImage handle, const VkAllocationCallbacks* allocator) + { + return device->vkDestroyImage(*device, handle, allocator); + } + } +} + +#include diff --git a/src/Nazara/Vulkan/RenderWindow.cpp b/src/Nazara/Vulkan/RenderWindow.cpp index f9b01672e..ae0833d44 100644 --- a/src/Nazara/Vulkan/RenderWindow.cpp +++ b/src/Nazara/Vulkan/RenderWindow.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -15,7 +16,8 @@ namespace Nz RenderWindow::RenderWindow() : RenderTarget(), Window(), m_surface(Nz::Vulkan::GetInstance()), - m_forcedPhysicalDevice(nullptr) + m_forcedPhysicalDevice(nullptr), + m_depthStencilFormat(VK_FORMAT_MAX_ENUM) { } @@ -53,6 +55,20 @@ namespace Nz void RenderWindow::BuildPreRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) { commandBuffer.SetImageLayout(m_swapchain.GetBuffer(imageIndex).image, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); + + // Temporary + if (m_depthBufferView != VK_FORMAT_MAX_ENUM) + { + VkImageSubresourceRange imageRange = { + VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, // VkImageAspectFlags aspectMask + 0, // uint32_t baseMipLevel + 1, // uint32_t levelCount + 0, // uint32_t baseArrayLayer + 1 // uint32_t layerCount + }; + + commandBuffer.SetImageLayout(m_depthBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, imageRange); + } } void RenderWindow::BuildPostRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) @@ -112,6 +128,11 @@ namespace Nz return m_impl != nullptr; } + void RenderWindow::SetDepthStencilFormats(std::vector pixelFormat) + { + m_wantedDepthStencilFormats = std::move(pixelFormat); + } + void RenderWindow::SetPhysicalDevice(VkPhysicalDevice device) { m_forcedPhysicalDevice = device; @@ -158,7 +179,58 @@ namespace Nz m_colorSpace = surfaceFormats[0].colorSpace; - m_depthFormat = VK_FORMAT_MAX_ENUM; + if (!m_wantedDepthStencilFormats.empty()) + { + const Vk::PhysicalDevice& deviceInfo = Vulkan::GetPhysicalDeviceInfo(m_forcedPhysicalDevice); + + for (PixelFormatType format : m_wantedDepthStencilFormats) + { + switch (format) + { + case PixelFormatType_Depth16: + m_depthStencilFormat = VK_FORMAT_D16_UNORM; + break; + + case PixelFormatType_Depth24: + case PixelFormatType_Depth24Stencil8: + m_depthStencilFormat = VK_FORMAT_D24_UNORM_S8_UINT; + break; + + case PixelFormatType_Depth32: + m_depthStencilFormat = VK_FORMAT_D32_SFLOAT; + break; + + case PixelFormatType_Stencil1: + case PixelFormatType_Stencil4: + case PixelFormatType_Stencil8: + m_depthStencilFormat = VK_FORMAT_S8_UINT; + break; + + case PixelFormatType_Stencil16: + m_depthStencilFormat = VK_FORMAT_MAX_ENUM; + break; + + default: + { + PixelFormatContent formatContent = PixelFormat::GetContent(format); + if (formatContent != PixelFormatContent_DepthStencil && formatContent != PixelFormatContent_Stencil) + NazaraWarning("Invalid format " + PixelFormat::GetName(format) + " for depth-stencil attachment"); + + m_depthStencilFormat = VK_FORMAT_MAX_ENUM; + break; + } + } + + if (m_depthStencilFormat != VK_FORMAT_MAX_ENUM) + { + VkFormatProperties formatProperties = m_device->GetInstance().GetPhysicalDeviceFormatProperties(m_forcedPhysicalDevice, m_depthStencilFormat); + if (formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) + break; //< Found it + + m_depthStencilFormat = VK_FORMAT_MAX_ENUM; + } + } + } if (!SetupSwapchain()) { @@ -166,6 +238,12 @@ namespace Nz return false; } + if (m_depthStencilFormat != VK_FORMAT_MAX_ENUM && !SetupDepthBuffer()) + { + NazaraError("Failed to create depth buffer"); + return false; + } + if (!SetupRenderPass()) { NazaraError("Failed to create render pass"); @@ -178,7 +256,7 @@ namespace Nz m_frameBuffers.resize(imageCount); for (UInt32 i = 0; i < imageCount; ++i) { - std::array attachments = {m_swapchain.GetBuffer(i).view, VK_NULL_HANDLE}; + std::array attachments = {m_swapchain.GetBuffer(i).view, m_depthBufferView}; VkFramebufferCreateInfo frameBufferCreate = { VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, // VkStructureType sType; @@ -221,9 +299,74 @@ namespace Nz OnRenderTargetSizeChange(this); } - bool RenderWindow::SetupCommandBuffers() + bool RenderWindow::SetupDepthBuffer() { - return false; + VkImageCreateInfo imageCreateInfo = { + VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + 0U, // VkImageCreateFlags flags; + VK_IMAGE_TYPE_2D, // VkImageType imageType; + m_depthStencilFormat, // VkFormat format; + {GetWidth(), GetHeight(), 1U}, // VkExtent3D extent; + 1U, // uint32_t mipLevels; + 1U, // uint32_t arrayLayers; + VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples; + VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling; + VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT, // VkImageUsageFlags usage; + VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode; + 0U, // uint32_t queueFamilyIndexCount; + nullptr, // const uint32_t* pQueueFamilyIndices; + VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout; + }; + + if (!m_depthBuffer.Create(m_device, imageCreateInfo)) + { + NazaraError("Failed to create depth buffer"); + return false; + } + + VkMemoryRequirements memoryReq = m_depthBuffer.GetMemoryRequirements(); + if (!m_depthBufferMemory.Create(m_device, memoryReq.size, memoryReq.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)) + { + NazaraError("Failed to allocate depth buffer memory"); + return false; + } + + if (!m_depthBuffer.BindImageMemory(m_depthBufferMemory)) + { + NazaraError("Failed to bind depth buffer to buffer"); + return false; + } + + VkImageViewCreateInfo imageViewCreateInfo = { + VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + 0, // VkImageViewCreateFlags flags; + m_depthBuffer, // VkImage image; + VK_IMAGE_VIEW_TYPE_2D, // VkImageViewType viewType; + m_depthStencilFormat, // VkFormat format; + { // VkComponentMapping components; + VK_COMPONENT_SWIZZLE_R, // VkComponentSwizzle .r; + VK_COMPONENT_SWIZZLE_G, // VkComponentSwizzle .g; + VK_COMPONENT_SWIZZLE_B, // VkComponentSwizzle .b; + VK_COMPONENT_SWIZZLE_A // VkComponentSwizzle .a; + }, + { // VkImageSubresourceRange subresourceRange; + VK_IMAGE_ASPECT_DEPTH_BIT, // VkImageAspectFlags .aspectMask; + 0, // uint32_t .baseMipLevel; + 1, // uint32_t .levelCount; + 0, // uint32_t .baseArrayLayer; + 1 // uint32_t .layerCount; + } + }; + + if (!m_depthBufferView.Create(m_device, imageViewCreateInfo)) + { + NazaraError("Failed to create depth buffer view"); + return false; + } + + return true; } bool RenderWindow::SetupRenderPass() @@ -242,15 +385,15 @@ namespace Nz VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout finalLayout; }, { - 0, // VkAttachmentDescriptionFlags flags; - m_depthFormat, // VkFormat format; - VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples; - VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp loadOp; - VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp; - VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp; - VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp; - VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout initialLayout; - VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout finalLayout; + 0, // VkAttachmentDescriptionFlags flags; + m_depthStencilFormat, // VkFormat format; + VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples; + VK_ATTACHMENT_LOAD_OP_CLEAR, // VkAttachmentLoadOp loadOp; + VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp storeOp; + VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp; + VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp; + VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, // VkImageLayout initialLayout; + VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL // VkImageLayout finalLayout; }, } }; @@ -266,28 +409,28 @@ namespace Nz }; VkSubpassDescription subpass = { - 0, // VkSubpassDescriptionFlags flags; - VK_PIPELINE_BIND_POINT_GRAPHICS, // VkPipelineBindPoint pipelineBindPoint; - 0U, // uint32_t inputAttachmentCount; - nullptr, // const VkAttachmentReference* pInputAttachments; - 1U, // uint32_t colorAttachmentCount; - &colorReference, // const VkAttachmentReference* pColorAttachments; - nullptr, // const VkAttachmentReference* pResolveAttachments; - (m_depthFormat != VK_FORMAT_MAX_ENUM) ? &depthReference : nullptr, // const VkAttachmentReference* pDepthStencilAttachment; - 0U, // uint32_t preserveAttachmentCount; - nullptr // const uint32_t* pPreserveAttachments; + 0, // VkSubpassDescriptionFlags flags; + VK_PIPELINE_BIND_POINT_GRAPHICS, // VkPipelineBindPoint pipelineBindPoint; + 0U, // uint32_t inputAttachmentCount; + nullptr, // const VkAttachmentReference* pInputAttachments; + 1U, // uint32_t colorAttachmentCount; + &colorReference, // const VkAttachmentReference* pColorAttachments; + nullptr, // const VkAttachmentReference* pResolveAttachments; + (m_depthStencilFormat != VK_FORMAT_MAX_ENUM) ? &depthReference : nullptr, // const VkAttachmentReference* pDepthStencilAttachment; + 0U, // uint32_t preserveAttachmentCount; + nullptr // const uint32_t* pPreserveAttachments; }; VkRenderPassCreateInfo createInfo = { - VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, // VkStructureType sType; - nullptr, // const void* pNext; - 0, // VkRenderPassCreateFlags flags; - (m_depthFormat != VK_FORMAT_MAX_ENUM) ? 2U : 1U, // uint32_t attachmentCount; - attachments.data(), // const VkAttachmentDescription* pAttachments; - 1U, // uint32_t subpassCount; - &subpass, // const VkSubpassDescription* pSubpasses; - 0U, // uint32_t dependencyCount; - nullptr // const VkSubpassDependency* pDependencies; + VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + 0, // VkRenderPassCreateFlags flags; + (m_depthStencilFormat != VK_FORMAT_MAX_ENUM) ? 2U : 1U, // uint32_t attachmentCount; + attachments.data(), // const VkAttachmentDescription* pAttachments; + 1U, // uint32_t subpassCount; + &subpass, // const VkSubpassDescription* pSubpasses; + 0U, // uint32_t dependencyCount; + nullptr // const VkSubpassDependency* pDependencies; }; return m_renderPass.Create(m_device, createInfo); From 228fd188eb81524d5a68aacf797ea241b4892d0a Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 10 Aug 2016 19:05:15 +0200 Subject: [PATCH 048/316] Vulkan/RenderWindow: Use subpass dependency to transition the images Former-commit-id: a0697c40a8581247158305edde55d56d1a3c7cb0 [formerly 50518f219a62d481ef76089c230de676f31a0d17] [formerly a8ec5a353213682c6661ac7e86b57d33ec0a32ba [formerly 3e58492aef5c12563357f9018f916b90db5887c1]] Former-commit-id: 35b547457fc0d040fb3d0dd10c959b38167c6406 [formerly 209ed1941bcde967533f49125078687f89ed004f] Former-commit-id: 53baf8d840c60141ccd3d01c6fa91d300e067bd1 --- src/Nazara/Vulkan/RenderWindow.cpp | 35 ++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/src/Nazara/Vulkan/RenderWindow.cpp b/src/Nazara/Vulkan/RenderWindow.cpp index ae0833d44..0b63728ad 100644 --- a/src/Nazara/Vulkan/RenderWindow.cpp +++ b/src/Nazara/Vulkan/RenderWindow.cpp @@ -54,10 +54,10 @@ namespace Nz void RenderWindow::BuildPreRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) { - commandBuffer.SetImageLayout(m_swapchain.GetBuffer(imageIndex).image, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); + //commandBuffer.SetImageLayout(m_swapchain.GetBuffer(imageIndex).image, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); // Temporary - if (m_depthBufferView != VK_FORMAT_MAX_ENUM) + if (m_depthStencilFormat != VK_FORMAT_MAX_ENUM) { VkImageSubresourceRange imageRange = { VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, // VkImageAspectFlags aspectMask @@ -73,7 +73,7 @@ namespace Nz void RenderWindow::BuildPostRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) { - commandBuffer.SetImageLayout(m_swapchain.GetBuffer(imageIndex).image, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR); + //commandBuffer.SetImageLayout(m_swapchain.GetBuffer(imageIndex).image, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR); } const Vk::Framebuffer& RenderWindow::GetFrameBuffer(UInt32 imageIndex) const @@ -381,8 +381,8 @@ namespace Nz VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp; VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp; VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp; - VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, // VkImageLayout initialLayout; - VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout finalLayout; + VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout; + VK_IMAGE_LAYOUT_PRESENT_SRC_KHR // VkImageLayout finalLayout; }, { 0, // VkAttachmentDescriptionFlags flags; @@ -421,6 +421,27 @@ namespace Nz nullptr // const uint32_t* pPreserveAttachments; }; + std::array dependencies; + // First dependency at the start of the renderpass + // Does the transition from final to initial layout + dependencies[0].srcSubpass = VK_SUBPASS_EXTERNAL; // Producer of the dependency + dependencies[0].dstSubpass = 0; // Consumer is our single subpass that will wait for the execution depdendency + dependencies[0].srcStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT; + dependencies[0].dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; + dependencies[0].srcAccessMask = VK_ACCESS_MEMORY_READ_BIT; + dependencies[0].dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; + dependencies[0].dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT; + + // Second dependency at the end the renderpass + // Does the transition from the initial to the final layout + dependencies[1].srcSubpass = 0; // Producer of the dependency is our single subpass + dependencies[1].dstSubpass = VK_SUBPASS_EXTERNAL; // Consumer are all commands outside of the renderpass + dependencies[1].srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; + dependencies[1].dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT; + dependencies[1].srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; + dependencies[1].dstAccessMask = VK_ACCESS_MEMORY_READ_BIT; + dependencies[1].dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT; + VkRenderPassCreateInfo createInfo = { VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, // VkStructureType sType; nullptr, // const void* pNext; @@ -429,8 +450,8 @@ namespace Nz attachments.data(), // const VkAttachmentDescription* pAttachments; 1U, // uint32_t subpassCount; &subpass, // const VkSubpassDescription* pSubpasses; - 0U, // uint32_t dependencyCount; - nullptr // const VkSubpassDependency* pDependencies; + dependencies.size(), // uint32_t dependencyCount; + dependencies.data() // const VkSubpassDependency* pDependencies; }; return m_renderPass.Create(m_device, createInfo); From bdedd05032e9c1db48fb1d42d80db27769554dc3 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 23 Aug 2016 12:52:34 +0200 Subject: [PATCH 049/316] Add new Renderer architecture (far from complete) Former-commit-id: 52226793d7a087dfe0523315d3303934daffee49 [formerly 9de1c04df6b371f861a2eee8bba38902ee5041cd] [formerly ecd3099df5498722f6390447f40bd3907b8e40c4 [formerly 3076df585565fc9759ab3e718270f2e5ef620840]] Former-commit-id: 92d52f967d0b088d1271afef26069e08cacd6b0f [formerly 5fe27e2ead104278951c772c2121a7b677f88d4d] Former-commit-id: fb6c2456d8edd3ec022d5d953f79fecdd4f2b8f4 --- build/scripts/tools/vulkanrenderer.lua | 50 + include/Nazara/Renderer/Context.hpp | 80 - include/Nazara/Renderer/ContextParameters.hpp | 60 - include/Nazara/Renderer/DebugDrawer.hpp | 61 - include/Nazara/Renderer/Enums.hpp | 119 +- include/Nazara/Renderer/GpuQuery.hpp | 46 - include/Nazara/Renderer/OpenGL.hpp | 346 --- include/Nazara/Renderer/RenderBuffer.hpp | 73 - include/Nazara/Renderer/RenderBuffer.inl | 20 - include/Nazara/Renderer/RenderDevice.hpp | 23 + include/Nazara/Renderer/RenderPipeline.hpp | 42 - include/Nazara/Renderer/RenderPipeline.inl | 48 - include/Nazara/Renderer/RenderStates.hpp | 82 - include/Nazara/Renderer/RenderStates.inl | 145 -- include/Nazara/Renderer/RenderTarget.hpp | 57 - .../Renderer/RenderTargetParameters.hpp | 29 - include/Nazara/Renderer/RenderTexture.hpp | 98 - include/Nazara/Renderer/RenderTexture.inl | 56 - include/Nazara/Renderer/RenderWindow.hpp | 3 - include/Nazara/Renderer/RenderWindow.inl | 81 + include/Nazara/Renderer/RenderWindowImpl.hpp | 81 + include/Nazara/Renderer/Renderer.hpp | 109 +- include/Nazara/Renderer/Renderer.inl | 21 + include/Nazara/Renderer/RendererImpl.hpp | 42 + include/Nazara/Renderer/Shader.hpp | 134 - include/Nazara/Renderer/Shader.inl | 20 - include/Nazara/Renderer/ShaderStage.hpp | 56 - include/Nazara/Renderer/Texture.hpp | 140 - include/Nazara/Renderer/Texture.inl | 20 - include/Nazara/Renderer/TextureSampler.hpp | 66 - include/Nazara/Renderer/UberShader.hpp | 53 - .../Nazara/Renderer/UberShaderInstance.hpp | 30 - .../UberShaderInstancePreprocessor.hpp | 25 - .../Renderer/UberShaderPreprocessor.hpp | 61 - .../Renderer/UberShaderPreprocessor.inl | 20 - include/Nazara/Vulkan.hpp | 60 - include/Nazara/VulkanRenderer.hpp | 61 + include/Nazara/VulkanRenderer/Config.hpp | 53 + include/Nazara/VulkanRenderer/ConfigCheck.hpp | 22 + include/Nazara/VulkanRenderer/Debug.hpp | 8 + include/Nazara/VulkanRenderer/DebugOff.hpp | 9 + .../Nazara/VulkanRenderer/RenderTarget.hpp | 60 + .../Nazara/VulkanRenderer/RenderWindow.hpp | 91 + include/Nazara/VulkanRenderer/VkBuffer.hpp | 46 + include/Nazara/VulkanRenderer/VkBuffer.inl | 62 + .../Nazara/VulkanRenderer/VkCommandBuffer.hpp | 100 + .../Nazara/VulkanRenderer/VkCommandBuffer.inl | 419 +++ .../Nazara/VulkanRenderer/VkCommandPool.hpp | 53 + .../Nazara/VulkanRenderer/VkCommandPool.inl | 48 + .../VulkanRenderer/VkDescriptorPool.hpp | 52 + .../VulkanRenderer/VkDescriptorPool.inl | 54 + .../Nazara/VulkanRenderer/VkDescriptorSet.hpp | 59 + .../Nazara/VulkanRenderer/VkDescriptorSet.inl | 122 + .../VulkanRenderer/VkDescriptorSetLayout.hpp | 43 + .../VulkanRenderer/VkDescriptorSetLayout.inl | 43 + include/Nazara/VulkanRenderer/VkDevice.hpp | 232 ++ include/Nazara/VulkanRenderer/VkDevice.inl | 117 + .../Nazara/VulkanRenderer/VkDeviceMemory.hpp | 51 + .../Nazara/VulkanRenderer/VkDeviceMemory.inl | 96 + .../Nazara/VulkanRenderer/VkDeviceObject.hpp | 51 + .../Nazara/VulkanRenderer/VkDeviceObject.inl | 93 + .../Nazara/VulkanRenderer/VkFramebuffer.hpp | 39 + .../Nazara/VulkanRenderer/VkFramebuffer.inl | 24 + include/Nazara/VulkanRenderer/VkImage.hpp | 43 + include/Nazara/VulkanRenderer/VkImage.inl | 46 + include/Nazara/VulkanRenderer/VkImageView.hpp | 39 + include/Nazara/VulkanRenderer/VkImageView.inl | 24 + include/Nazara/VulkanRenderer/VkInstance.hpp | 141 + include/Nazara/VulkanRenderer/VkInstance.inl | 143 + include/Nazara/VulkanRenderer/VkLoader.hpp | 52 + include/Nazara/VulkanRenderer/VkLoader.inl | 19 + .../VulkanRenderer/VkPhysicalDevice.hpp | 28 + include/Nazara/VulkanRenderer/VkPipeline.hpp | 50 + include/Nazara/VulkanRenderer/VkPipeline.inl | 86 + .../Nazara/VulkanRenderer/VkPipelineCache.hpp | 39 + .../Nazara/VulkanRenderer/VkPipelineCache.inl | 24 + .../VulkanRenderer/VkPipelineLayout.hpp | 39 + .../VulkanRenderer/VkPipelineLayout.inl | 24 + include/Nazara/VulkanRenderer/VkQueue.hpp | 53 + include/Nazara/VulkanRenderer/VkQueue.inl | 115 + .../Nazara/VulkanRenderer/VkRenderPass.hpp | 39 + .../Nazara/VulkanRenderer/VkRenderPass.inl | 24 + include/Nazara/VulkanRenderer/VkSemaphore.hpp | 42 + include/Nazara/VulkanRenderer/VkSemaphore.inl | 36 + .../Nazara/VulkanRenderer/VkShaderModule.hpp | 42 + .../Nazara/VulkanRenderer/VkShaderModule.inl | 38 + include/Nazara/VulkanRenderer/VkSurface.hpp | 94 + include/Nazara/VulkanRenderer/VkSurface.inl | 314 +++ include/Nazara/VulkanRenderer/VkSwapchain.hpp | 60 + include/Nazara/VulkanRenderer/VkSwapchain.inl | 121 + include/Nazara/VulkanRenderer/Vulkan.hpp | 55 + .../Nazara/VulkanRenderer/VulkanRenderer.hpp | 42 + src/Nazara/Renderer/Context.cpp | 376 --- src/Nazara/Renderer/ContextParameters.cpp | 35 - src/Nazara/Renderer/DebugDrawer.cpp | 741 ------ src/Nazara/Renderer/GLX/ContextImpl.cpp | 300 --- src/Nazara/Renderer/GLX/ContextImpl.hpp | 42 - src/Nazara/Renderer/GpuQuery.cpp | 122 - src/Nazara/Renderer/HardwareBuffer.cpp | 137 - src/Nazara/Renderer/HardwareBuffer.hpp | 43 - src/Nazara/Renderer/OpenGL.cpp | 2306 ----------------- src/Nazara/Renderer/RenderBuffer.cpp | 133 - src/Nazara/Renderer/RenderTarget.cpp | 35 - src/Nazara/Renderer/RenderTexture.cpp | 854 ------ src/Nazara/Renderer/RenderWindow.cpp | 3 +- src/Nazara/Renderer/Renderer.cpp | 1984 +------------- src/Nazara/Renderer/RendererImpl.cpp | 11 + .../Resources/Shaders/Debug/core.frag | 13 - .../Resources/Shaders/Debug/core.frag.h | 1 - .../Resources/Shaders/Debug/core.vert | 13 - .../Resources/Shaders/Debug/core.vert.h | 1 - src/Nazara/Renderer/Shader.cpp | 841 ------ src/Nazara/Renderer/ShaderStage.cpp | 234 -- src/Nazara/Renderer/Texture.cpp | 1347 ---------- src/Nazara/Renderer/TextureSampler.cpp | 393 --- src/Nazara/Renderer/UberShader.cpp | 32 - src/Nazara/Renderer/UberShaderInstance.cpp | 22 - .../UberShaderInstancePreprocessor.cpp | 24 - .../Renderer/UberShaderPreprocessor.cpp | 187 -- src/Nazara/Renderer/Win32/ContextImpl.cpp | 248 -- src/Nazara/Renderer/Win32/ContextImpl.hpp | 41 - .../VulkanRenderer/Debug/NewOverload.cpp | 31 + src/Nazara/VulkanRenderer/Export.cpp | 15 + src/Nazara/VulkanRenderer/RenderTarget.cpp | 14 + src/Nazara/VulkanRenderer/RenderWindow.cpp | 530 ++++ src/Nazara/VulkanRenderer/VkCommandPool.cpp | 53 + .../VulkanRenderer/VkDescriptorPool.cpp | 53 + src/Nazara/VulkanRenderer/VkDevice.cpp | 222 ++ src/Nazara/VulkanRenderer/VkInstance.cpp | 193 ++ src/Nazara/VulkanRenderer/VkLoader.cpp | 117 + src/Nazara/VulkanRenderer/Vulkan.cpp | 451 ++++ src/Nazara/VulkanRenderer/VulkanRenderer.cpp | 252 ++ 132 files changed, 6300 insertions(+), 12587 deletions(-) create mode 100644 build/scripts/tools/vulkanrenderer.lua delete mode 100644 include/Nazara/Renderer/Context.hpp delete mode 100644 include/Nazara/Renderer/ContextParameters.hpp delete mode 100644 include/Nazara/Renderer/DebugDrawer.hpp delete mode 100644 include/Nazara/Renderer/GpuQuery.hpp delete mode 100644 include/Nazara/Renderer/OpenGL.hpp delete mode 100644 include/Nazara/Renderer/RenderBuffer.hpp delete mode 100644 include/Nazara/Renderer/RenderBuffer.inl create mode 100644 include/Nazara/Renderer/RenderDevice.hpp delete mode 100644 include/Nazara/Renderer/RenderPipeline.hpp delete mode 100644 include/Nazara/Renderer/RenderPipeline.inl delete mode 100644 include/Nazara/Renderer/RenderStates.hpp delete mode 100644 include/Nazara/Renderer/RenderStates.inl delete mode 100644 include/Nazara/Renderer/RenderTarget.hpp delete mode 100644 include/Nazara/Renderer/RenderTargetParameters.hpp delete mode 100644 include/Nazara/Renderer/RenderTexture.hpp delete mode 100644 include/Nazara/Renderer/RenderTexture.inl create mode 100644 include/Nazara/Renderer/RenderWindow.inl create mode 100644 include/Nazara/Renderer/RenderWindowImpl.hpp create mode 100644 include/Nazara/Renderer/Renderer.inl create mode 100644 include/Nazara/Renderer/RendererImpl.hpp delete mode 100644 include/Nazara/Renderer/Shader.hpp delete mode 100644 include/Nazara/Renderer/Shader.inl delete mode 100644 include/Nazara/Renderer/ShaderStage.hpp delete mode 100644 include/Nazara/Renderer/Texture.hpp delete mode 100644 include/Nazara/Renderer/Texture.inl delete mode 100644 include/Nazara/Renderer/TextureSampler.hpp delete mode 100644 include/Nazara/Renderer/UberShader.hpp delete mode 100644 include/Nazara/Renderer/UberShaderInstance.hpp delete mode 100644 include/Nazara/Renderer/UberShaderInstancePreprocessor.hpp delete mode 100644 include/Nazara/Renderer/UberShaderPreprocessor.hpp delete mode 100644 include/Nazara/Renderer/UberShaderPreprocessor.inl delete mode 100644 include/Nazara/Vulkan.hpp create mode 100644 include/Nazara/VulkanRenderer.hpp create mode 100644 include/Nazara/VulkanRenderer/Config.hpp create mode 100644 include/Nazara/VulkanRenderer/ConfigCheck.hpp create mode 100644 include/Nazara/VulkanRenderer/Debug.hpp create mode 100644 include/Nazara/VulkanRenderer/DebugOff.hpp create mode 100644 include/Nazara/VulkanRenderer/RenderTarget.hpp create mode 100644 include/Nazara/VulkanRenderer/RenderWindow.hpp create mode 100644 include/Nazara/VulkanRenderer/VkBuffer.hpp create mode 100644 include/Nazara/VulkanRenderer/VkBuffer.inl create mode 100644 include/Nazara/VulkanRenderer/VkCommandBuffer.hpp create mode 100644 include/Nazara/VulkanRenderer/VkCommandBuffer.inl create mode 100644 include/Nazara/VulkanRenderer/VkCommandPool.hpp create mode 100644 include/Nazara/VulkanRenderer/VkCommandPool.inl create mode 100644 include/Nazara/VulkanRenderer/VkDescriptorPool.hpp create mode 100644 include/Nazara/VulkanRenderer/VkDescriptorPool.inl create mode 100644 include/Nazara/VulkanRenderer/VkDescriptorSet.hpp create mode 100644 include/Nazara/VulkanRenderer/VkDescriptorSet.inl create mode 100644 include/Nazara/VulkanRenderer/VkDescriptorSetLayout.hpp create mode 100644 include/Nazara/VulkanRenderer/VkDescriptorSetLayout.inl create mode 100644 include/Nazara/VulkanRenderer/VkDevice.hpp create mode 100644 include/Nazara/VulkanRenderer/VkDevice.inl create mode 100644 include/Nazara/VulkanRenderer/VkDeviceMemory.hpp create mode 100644 include/Nazara/VulkanRenderer/VkDeviceMemory.inl create mode 100644 include/Nazara/VulkanRenderer/VkDeviceObject.hpp create mode 100644 include/Nazara/VulkanRenderer/VkDeviceObject.inl create mode 100644 include/Nazara/VulkanRenderer/VkFramebuffer.hpp create mode 100644 include/Nazara/VulkanRenderer/VkFramebuffer.inl create mode 100644 include/Nazara/VulkanRenderer/VkImage.hpp create mode 100644 include/Nazara/VulkanRenderer/VkImage.inl create mode 100644 include/Nazara/VulkanRenderer/VkImageView.hpp create mode 100644 include/Nazara/VulkanRenderer/VkImageView.inl create mode 100644 include/Nazara/VulkanRenderer/VkInstance.hpp create mode 100644 include/Nazara/VulkanRenderer/VkInstance.inl create mode 100644 include/Nazara/VulkanRenderer/VkLoader.hpp create mode 100644 include/Nazara/VulkanRenderer/VkLoader.inl create mode 100644 include/Nazara/VulkanRenderer/VkPhysicalDevice.hpp create mode 100644 include/Nazara/VulkanRenderer/VkPipeline.hpp create mode 100644 include/Nazara/VulkanRenderer/VkPipeline.inl create mode 100644 include/Nazara/VulkanRenderer/VkPipelineCache.hpp create mode 100644 include/Nazara/VulkanRenderer/VkPipelineCache.inl create mode 100644 include/Nazara/VulkanRenderer/VkPipelineLayout.hpp create mode 100644 include/Nazara/VulkanRenderer/VkPipelineLayout.inl create mode 100644 include/Nazara/VulkanRenderer/VkQueue.hpp create mode 100644 include/Nazara/VulkanRenderer/VkQueue.inl create mode 100644 include/Nazara/VulkanRenderer/VkRenderPass.hpp create mode 100644 include/Nazara/VulkanRenderer/VkRenderPass.inl create mode 100644 include/Nazara/VulkanRenderer/VkSemaphore.hpp create mode 100644 include/Nazara/VulkanRenderer/VkSemaphore.inl create mode 100644 include/Nazara/VulkanRenderer/VkShaderModule.hpp create mode 100644 include/Nazara/VulkanRenderer/VkShaderModule.inl create mode 100644 include/Nazara/VulkanRenderer/VkSurface.hpp create mode 100644 include/Nazara/VulkanRenderer/VkSurface.inl create mode 100644 include/Nazara/VulkanRenderer/VkSwapchain.hpp create mode 100644 include/Nazara/VulkanRenderer/VkSwapchain.inl create mode 100644 include/Nazara/VulkanRenderer/Vulkan.hpp create mode 100644 include/Nazara/VulkanRenderer/VulkanRenderer.hpp delete mode 100644 src/Nazara/Renderer/Context.cpp delete mode 100644 src/Nazara/Renderer/ContextParameters.cpp delete mode 100644 src/Nazara/Renderer/DebugDrawer.cpp delete mode 100644 src/Nazara/Renderer/GLX/ContextImpl.cpp delete mode 100644 src/Nazara/Renderer/GLX/ContextImpl.hpp delete mode 100644 src/Nazara/Renderer/GpuQuery.cpp delete mode 100644 src/Nazara/Renderer/HardwareBuffer.cpp delete mode 100644 src/Nazara/Renderer/HardwareBuffer.hpp delete mode 100644 src/Nazara/Renderer/OpenGL.cpp delete mode 100644 src/Nazara/Renderer/RenderBuffer.cpp delete mode 100644 src/Nazara/Renderer/RenderTarget.cpp delete mode 100644 src/Nazara/Renderer/RenderTexture.cpp create mode 100644 src/Nazara/Renderer/RendererImpl.cpp delete mode 100644 src/Nazara/Renderer/Resources/Shaders/Debug/core.frag delete mode 100644 src/Nazara/Renderer/Resources/Shaders/Debug/core.frag.h delete mode 100644 src/Nazara/Renderer/Resources/Shaders/Debug/core.vert delete mode 100644 src/Nazara/Renderer/Resources/Shaders/Debug/core.vert.h delete mode 100644 src/Nazara/Renderer/Shader.cpp delete mode 100644 src/Nazara/Renderer/ShaderStage.cpp delete mode 100644 src/Nazara/Renderer/Texture.cpp delete mode 100644 src/Nazara/Renderer/TextureSampler.cpp delete mode 100644 src/Nazara/Renderer/UberShader.cpp delete mode 100644 src/Nazara/Renderer/UberShaderInstance.cpp delete mode 100644 src/Nazara/Renderer/UberShaderInstancePreprocessor.cpp delete mode 100644 src/Nazara/Renderer/UberShaderPreprocessor.cpp delete mode 100644 src/Nazara/Renderer/Win32/ContextImpl.cpp delete mode 100644 src/Nazara/Renderer/Win32/ContextImpl.hpp create mode 100644 src/Nazara/VulkanRenderer/Debug/NewOverload.cpp create mode 100644 src/Nazara/VulkanRenderer/Export.cpp create mode 100644 src/Nazara/VulkanRenderer/RenderTarget.cpp create mode 100644 src/Nazara/VulkanRenderer/RenderWindow.cpp create mode 100644 src/Nazara/VulkanRenderer/VkCommandPool.cpp create mode 100644 src/Nazara/VulkanRenderer/VkDescriptorPool.cpp create mode 100644 src/Nazara/VulkanRenderer/VkDevice.cpp create mode 100644 src/Nazara/VulkanRenderer/VkInstance.cpp create mode 100644 src/Nazara/VulkanRenderer/VkLoader.cpp create mode 100644 src/Nazara/VulkanRenderer/Vulkan.cpp create mode 100644 src/Nazara/VulkanRenderer/VulkanRenderer.cpp diff --git a/build/scripts/tools/vulkanrenderer.lua b/build/scripts/tools/vulkanrenderer.lua new file mode 100644 index 000000000..8ecca1f2b --- /dev/null +++ b/build/scripts/tools/vulkanrenderer.lua @@ -0,0 +1,50 @@ +TOOL.Name = "VulkanRenderer" + +TOOL.ClientOnly = true + +TOOL.Kind = "Library" +TOOL.TargetDirectory = "../lib" + +TOOL.Defines = { + "NAZARA_BUILD", + "NAZARA_VULKANRENDERER_BUILD" +} + +TOOL.Includes = { + "../include", + "../src/", + "../extlibs/include" +} + +TOOL.Files = { + "../include/Nazara/VulkanRenderer/**.hpp", + "../include/Nazara/VulkanRenderer/**.inl", + "../src/Nazara/VulkanRenderer/**.hpp", + "../src/Nazara/VulkanRenderer/**.inl", + "../src/Nazara/VulkanRenderer/**.cpp" +} + +TOOL.Libraries = { + "NazaraCore", + "NazaraRenderer", + "NazaraUtility" +} + +TOOL.OsDefines.Linux = { +-- "VK_USE_PLATFORM_MIR_KHR", + "VK_USE_PLATFORM_XCB_KHR" +-- "VK_USE_PLATFORM_XLIB_KHR", +-- "VK_USE_PLATFORM_WAYLAND_KHR" +} + +TOOL.OsDefines.BSD = TOOL.OsDefines.Linux +TOOL.OsDefines.Solaris = TOOL.OsDefines.Linux + +TOOL.OsDefines.Windows = { + "VK_USE_PLATFORM_WIN32_KHR" +} + +TOOL.OsFiles.Windows = { + "../src/Nazara/VulkanRenderer/Win32/**.hpp", + "../src/Nazara/VulkanRenderer/Win32/**.cpp" +} diff --git a/include/Nazara/Renderer/Context.hpp b/include/Nazara/Renderer/Context.hpp deleted file mode 100644 index 4bfb7b1b0..000000000 --- a/include/Nazara/Renderer/Context.hpp +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_CONTEXT_HPP -#define NAZARA_CONTEXT_HPP - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - class Context; - - using ContextConstRef = ObjectRef; - using ContextLibrary = ObjectLibrary; - using ContextRef = ObjectRef; - - class ContextImpl; - - class NAZARA_RENDERER_API Context : public RefCounted - { - friend ContextImpl; - friend ContextLibrary; - friend class OpenGL; - - public: - Context() = default; - Context(const Context&) = delete; - Context(Context&&) = delete; - ~Context(); - - bool Create(const ContextParameters& parameters = ContextParameters()); - - void Destroy(); - - void EnableVerticalSync(bool enabled); - - const ContextParameters& GetParameters() const; - - bool IsActive() const; - - bool SetActive(bool active) const; - void SwapBuffers(); - - Context& operator=(const Context&) = delete; - Context& operator=(Context&&) = delete; - - static bool EnsureContext(); - - static const Context* GetCurrent(); - static const Context* GetReference(); - static const Context* GetThreadContext(); - - // Signals: - NazaraSignal(OnContextDestroy, const Context* /*context*/); - NazaraSignal(OnContextRelease, const Context* /*context*/); - - private: - static bool Initialize(); - static void Uninitialize(); - - ContextParameters m_parameters; - ContextImpl* m_impl = nullptr; - - static std::unique_ptr s_reference; - static std::vector> s_contexts; - static ContextLibrary::LibraryMap s_library; - }; -} - -#endif // NAZARA_CONTEXT_HPP diff --git a/include/Nazara/Renderer/ContextParameters.hpp b/include/Nazara/Renderer/ContextParameters.hpp deleted file mode 100644 index ddfc76ea3..000000000 --- a/include/Nazara/Renderer/ContextParameters.hpp +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_CONTEXTPARAMETERS_HPP -#define NAZARA_CONTEXTPARAMETERS_HPP - -#include -#include -#include -#include - -namespace Nz -{ - class Context; - - struct NAZARA_RENDERER_API ContextParameters - { - ContextParameters(const RenderTargetParameters& parameters = RenderTargetParameters()) : - antialiasingLevel(parameters.antialiasingLevel), - bitsPerPixel(VideoMode::GetDesktopMode().bitsPerPixel), - depthBits(parameters.depthBits), - majorVersion(defaultMajorVersion), - minorVersion(defaultMinorVersion), - stencilBits(parameters.stencilBits), - shareContext(defaultShareContext), - window(0), - compatibilityProfile(defaultCompatibilityProfile), - debugMode(defaultDebugMode), - doubleBuffered(defaultDoubleBuffered), - shared(defaultShared) - { - } - - UInt8 antialiasingLevel; - UInt8 bitsPerPixel; - UInt8 depthBits; - UInt8 majorVersion; - UInt8 minorVersion; - UInt8 stencilBits; - const Context* shareContext; - WindowHandle window; - bool compatibilityProfile; - bool debugMode; - bool doubleBuffered; - bool shared; - - static UInt8 defaultMajorVersion; - static UInt8 defaultMinorVersion; - static const Context* defaultShareContext; - static bool defaultCompatibilityProfile; - static bool defaultDebugMode; - static bool defaultDoubleBuffered; - static bool defaultShared; - }; -} - -#endif // NAZARA_CONTEXTPARAMETERS_HPP diff --git a/include/Nazara/Renderer/DebugDrawer.hpp b/include/Nazara/Renderer/DebugDrawer.hpp deleted file mode 100644 index 7880a1ae4..000000000 --- a/include/Nazara/Renderer/DebugDrawer.hpp +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_DEBUGDRAWER_HPP -#define NAZARA_DEBUGDRAWER_HPP - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - class Skeleton; - - class NAZARA_RENDERER_API DebugDrawer - { - public: - static void Draw(const BoundingVolumef& volume); - static void Draw(const Boxf& box); - static void Draw(const Boxi& box); - static void Draw(const Boxui& box); - static void Draw(const Frustumf& frustum); - static void Draw(const OrientedBoxf& orientedBox); - static void Draw(const Skeleton* skeleton); - static void Draw(const Vector3f& position, float size = 0.1f); - static void DrawAxes(const Vector3f& position = Vector3f::Zero(), float size = 1.f); - static void DrawBinormals(const StaticMesh* subMesh); - static void DrawCone(const Vector3f& origin, const Quaternionf& rotation, float angle, float length); - static void DrawLine(const Vector3f& p1, const Vector3f& p2); - static void DrawPoints(const Vector3f* ptr, unsigned int pointCount); - static void DrawNormals(const StaticMesh* subMesh); - static void DrawTangents(const StaticMesh* subMesh); - - static void EnableDepthBuffer(bool depthBuffer); - - static float GetLineWidth(); - static float GetPointSize(); - static Color GetPrimaryColor(); - static Color GetSecondaryColor(); - - static bool Initialize(); - static bool IsDepthBufferEnabled(); - - static void SetLineWidth(float width); - static void SetPointSize(float size); - static void SetPrimaryColor(const Color& color); - static void SetSecondaryColor(const Color& color); - - static void Uninitialize(); - }; -} - -#endif // NAZARA_DEBUG_DRAWER_HPP diff --git a/include/Nazara/Renderer/Enums.hpp b/include/Nazara/Renderer/Enums.hpp index 2d0e6d3a7..b610d43b3 100644 --- a/include/Nazara/Renderer/Enums.hpp +++ b/include/Nazara/Renderer/Enums.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2016 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -9,114 +9,29 @@ namespace Nz { - enum AttachmentPoint + enum RenderAPI { - AttachmentPoint_Color, - AttachmentPoint_Depth, - AttachmentPoint_DepthStencil, - AttachmentPoint_Stencil, + RenderAPI_Direct3D, ///< Microsoft Render API, only works on MS platforms + RenderAPI_Mantle, ///< AMD Render API, Vulkan predecessor, only works on AMD GPUs + RenderAPI_Metal, ///< Apple Render API, only works on OS X platforms + RenderAPI_OpenGL, ///< Khronos Render API, works on Web/Desktop/Mobile and some consoles + RenderAPI_Vulkan, ///< New Khronos Render API, made to replace OpenGL, works on desktop (Windows/Linux) and mobile (Android) - AttachmentPoint_Max = AttachmentPoint_Stencil + RenderAPI_Other, ///< RenderAPI not corresponding to an entry of the enum, or result of a failed query + + RenderAPI_Max = RenderAPI_Other }; - enum GpuQueryCondition + enum RenderDeviceType { - GpuQueryCondition_Region_NoWait, - GpuQueryCondition_Region_Wait, - GpuQueryCondition_NoWait, - GpuQueryCondition_Wait, + RenderDeviceType_Integrated, ///< Hardware-accelerated chipset integrated to a CPU (ex: Intel Graphics HD 4000) + RenderDeviceType_Dedicated, ///< Hardware-accelerated GPU (ex: AMD R9 390) + RenderDeviceType_Software, ///< Software-renderer + RenderDeviceType_Virtual, ///< Proxy renderer relaying instructions to another unknown device - GpuQueryCondition_Max = GpuQueryCondition_Wait - }; + RenderDeviceType_Unknown, ///< Device type not corresponding to an entry of the enum, or result of a failed query - enum GpuQueryMode - { - GpuQueryMode_AnySamplesPassed, - GpuQueryMode_AnySamplesPassedConservative, - GpuQueryMode_PrimitiveGenerated, - GpuQueryMode_SamplesPassed, - GpuQueryMode_TimeElapsed, - GpuQueryMode_TransformFeedbackPrimitivesWritten, - - GpuQueryMode_Max = GpuQueryMode_TransformFeedbackPrimitivesWritten - }; - - enum MatrixType - { - // Matrices de base - MatrixType_Projection, - MatrixType_View, - MatrixType_World, - - // Matrices combinées - MatrixType_ViewProj, - MatrixType_WorldView, - MatrixType_WorldViewProj, - - // Matrice inversées - MatrixType_InvProjection, - MatrixType_InvView, - MatrixType_InvViewProj, - MatrixType_InvWorld, - MatrixType_InvWorldView, - MatrixType_InvWorldViewProj, - - MatrixType_Max = MatrixType_InvWorldViewProj - }; - - enum PixelBufferType - { - PixelBufferType_Pack, - PixelBufferType_Unpack, - - PixelBufferType_Max = PixelBufferType_Unpack - }; - - enum RendererCap - { - RendererCap_AnisotropicFilter, - RendererCap_FP64, - RendererCap_Instancing, - - RendererCap_Max = RendererCap_Instancing - }; - - enum RendererBufferFlags - { - RendererBuffer_Color = 0x1, - RendererBuffer_Depth = 0x2, - RendererBuffer_Stencil = 0x4, - - RendererBuffer_Max = RendererBuffer_Stencil*2-1 - }; - - enum ShaderUniform - { - ShaderUniform_InvProjMatrix, - ShaderUniform_InvTargetSize, - ShaderUniform_InvViewMatrix, - ShaderUniform_InvViewProjMatrix, - ShaderUniform_InvWorldMatrix, - ShaderUniform_InvWorldViewMatrix, - ShaderUniform_InvWorldViewProjMatrix, - ShaderUniform_ProjMatrix, - ShaderUniform_TargetSize, - ShaderUniform_ViewMatrix, - ShaderUniform_ViewProjMatrix, - ShaderUniform_WorldMatrix, - ShaderUniform_WorldViewMatrix, - ShaderUniform_WorldViewProjMatrix, - - ShaderUniform_Max = ShaderUniform_WorldViewProjMatrix - }; - - enum ShaderStageType - { - ShaderStageType_Fragment, - ShaderStageType_Geometry, - ShaderStageType_Vertex, - - ShaderStageType_Max = ShaderStageType_Vertex + RenderDeviceType_Max = RenderDeviceType_Unknown }; } diff --git a/include/Nazara/Renderer/GpuQuery.hpp b/include/Nazara/Renderer/GpuQuery.hpp deleted file mode 100644 index 87b758966..000000000 --- a/include/Nazara/Renderer/GpuQuery.hpp +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_GPUQUERY_HPP -#define NAZARA_GPUQUERY_HPP - -#include -#include -#include - -namespace Nz -{ - class NAZARA_RENDERER_API GpuQuery - { - public: - GpuQuery(); - GpuQuery(const GpuQuery&) = delete; - GpuQuery(GpuQuery&&) = delete; ///TODO - ~GpuQuery(); - - void Begin(GpuQueryMode mode); - void End(); - - unsigned int GetResult() const; - - bool IsResultAvailable() const; - - // Fonctions OpenGL - unsigned int GetOpenGLID() const; - - GpuQuery& operator=(const GpuQuery&) = delete; - GpuQuery& operator=(GpuQuery&&) = delete; ///TODO - - static bool IsModeSupported(GpuQueryMode mode); - static bool IsSupported(); - - private: - GpuQueryMode m_mode; - unsigned int m_id; - }; -} - -#endif // NAZARA_GPUQUERY_HPP diff --git a/include/Nazara/Renderer/OpenGL.hpp b/include/Nazara/Renderer/OpenGL.hpp deleted file mode 100644 index d008b52f4..000000000 --- a/include/Nazara/Renderer/OpenGL.hpp +++ /dev/null @@ -1,346 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_OPENGL_HPP -#define NAZARA_OPENGL_HPP - -#ifdef NAZARA_RENDERER_OPENGL - -#include -#include -#include -#include -#include -#include - -// Inclusion des headers OpenGL -#include -#include -#if defined(NAZARA_PLATFORM_WINDOWS) - #include -#elif defined(NAZARA_PLATFORM_GLX) -namespace GLX -{ - #include // Defined in a namespace to avoid conflict -} - #include -#endif - -namespace Nz -{ - enum OpenGLExtension - { - OpenGLExtension_AnisotropicFilter, - OpenGLExtension_DebugOutput, - OpenGLExtension_FP64, - OpenGLExtension_GetProgramBinary, - OpenGLExtension_SeparateShaderObjects, - OpenGLExtension_Shader_ImageLoadStore, - OpenGLExtension_TextureCompression_s3tc, - OpenGLExtension_TextureStorage, - - OpenGLExtension_Max = OpenGLExtension_TextureStorage - }; - - class Context; - class RenderTarget; - - using OpenGLFunc = void (*)(); - - class NAZARA_RENDERER_API OpenGL - { - friend Context; - - public: - enum FormatType - { - FormatType_RenderBuffer, -// FormatType_MultisampleTexture, - FormatType_Texture - }; - - struct Format - { - GLenum dataFormat; - GLenum dataType; - GLint internalFormat; - GLint swizzle[4]; - }; - - OpenGL() = delete; - ~OpenGL() = delete; - - static void ApplyStates(const RenderStates& states); - - static void BindBuffer(BufferType type, GLuint id); - static void BindProgram(GLuint id); - static void BindSampler(GLuint unit, GLuint id); - static void BindScissorBox(const Recti& scissorBox); - static void BindTexture(ImageType type, GLuint id); - static void BindTexture(unsigned int textureUnit, ImageType type, GLuint id); - static void BindTextureUnit(unsigned int textureUnit); - static void BindViewport(const Recti& viewport); - - static void DeleteBuffer(BufferType type, GLuint id); - static void DeleteFrameBuffer(const Context* context, GLuint id); - static void DeleteProgram(GLuint id); - static void DeleteSampler(GLuint id); - static void DeleteTexture(GLuint id); - static void DeleteVertexArray(const Context* context, GLuint id); - - static GLuint GetCurrentBuffer(BufferType type); - static GLuint GetCurrentProgram(); - static Recti GetCurrentScissorBox(); - static const RenderTarget* GetCurrentTarget(); - static GLuint GetCurrentTexture(); - static GLuint GetCurrentTexture(unsigned int textureUnit); - static unsigned int GetCurrentTextureUnit(); - static Recti GetCurrentViewport(); - - static OpenGLFunc GetEntry(const String& entryPoint); - static unsigned int GetGLSLVersion(); - static String GetRendererName(); - static String GetVendorName(); - static unsigned int GetVersion(); - - static bool Initialize(); - - static bool IsInitialized(); - static bool IsSupported(OpenGLExtension extension); - static bool IsSupported(const String& string); - - static void SetBuffer(BufferType type, GLuint id); - static void SetProgram(GLuint id); - static void SetScissorBox(const Recti& scissorBox); - static void SetTarget(const RenderTarget* renderTarget); - static void SetTexture(GLuint id); - static void SetTexture(unsigned int textureUnit, GLuint id); - static void SetTextureUnit(unsigned int textureUnit); - static void SetViewport(const Recti& viewport); - - static bool TranslateFormat(PixelFormatType pixelFormat, Format* format, FormatType target); - - static void Uninitialize(); - - static GLenum Attachment[AttachmentPoint_Max+1]; - static GLenum BlendFunc[BlendFunc_Max+1]; - static GLenum BufferLock[BufferAccess_Max+1]; - static GLenum BufferLockRange[BufferAccess_Max+1]; - static GLenum BufferTarget[BufferType_Max+1]; - static GLenum BufferTargetBinding[BufferType_Max+1]; - static GLenum BufferUsage[BufferUsage_Max+1]; - static GLenum ComponentType[ComponentType_Max+1]; - static GLenum CubemapFace[6]; // Un cube possède six faces et ça n'est pas près de changer - static GLenum FaceFilling[FaceFilling_Max+1]; - static GLenum FaceSide[FaceSide_Max+1]; - static GLenum PrimitiveMode[PrimitiveMode_Max+1]; - static GLenum QueryCondition[GpuQueryCondition_Max+1]; - static GLenum QueryMode[GpuQueryMode_Max+1]; - static GLenum RendererComparison[RendererComparison_Max+1]; - static GLenum RendererParameter[RendererParameter_Max+1]; - static GLenum SamplerWrapMode[SamplerWrap_Max+1]; - static GLenum ShaderStage[ShaderStageType_Max+1]; - static GLenum StencilOperation[StencilOperation_Max+1]; - static GLenum TextureTarget[ImageType_Max+1]; - static GLenum TextureTargetBinding[ImageType_Max+1]; - static GLenum TextureTargetProxy[ImageType_Max+1]; - static UInt8 VertexComponentIndex[VertexComponent_Max+1]; - - private: - static void OnContextChanged(const Context* newContext); - static void OnContextDestruction(const Context* context); - }; - -NAZARA_RENDERER_API extern PFNGLACTIVETEXTUREPROC glActiveTexture; -NAZARA_RENDERER_API extern PFNGLATTACHSHADERPROC glAttachShader; -NAZARA_RENDERER_API extern PFNGLBEGINCONDITIONALRENDERPROC glBeginConditionalRender; -NAZARA_RENDERER_API extern PFNGLBEGINQUERYPROC glBeginQuery; -NAZARA_RENDERER_API extern PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation; -NAZARA_RENDERER_API extern PFNGLBINDBUFFERPROC glBindBuffer; -NAZARA_RENDERER_API extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer; -NAZARA_RENDERER_API extern PFNGLBINDFRAGDATALOCATIONPROC glBindFragDataLocation; -NAZARA_RENDERER_API extern PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer; -NAZARA_RENDERER_API extern PFNGLBINDSAMPLERPROC glBindSampler; -NAZARA_RENDERER_API extern PFNGLBINDTEXTUREPROC glBindTexture; -NAZARA_RENDERER_API extern PFNGLBINDVERTEXARRAYPROC glBindVertexArray; -NAZARA_RENDERER_API extern PFNGLBLENDFUNCPROC glBlendFunc; -NAZARA_RENDERER_API extern PFNGLBLENDFUNCSEPARATEPROC glBlendFuncSeparate; -NAZARA_RENDERER_API extern PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer; -NAZARA_RENDERER_API extern PFNGLBUFFERDATAPROC glBufferData; -NAZARA_RENDERER_API extern PFNGLBUFFERSUBDATAPROC glBufferSubData; -NAZARA_RENDERER_API extern PFNGLCLEARPROC glClear; -NAZARA_RENDERER_API extern PFNGLCLEARCOLORPROC glClearColor; -NAZARA_RENDERER_API extern PFNGLCLEARDEPTHPROC glClearDepth; -NAZARA_RENDERER_API extern PFNGLCLEARSTENCILPROC glClearStencil; -NAZARA_RENDERER_API extern PFNGLCREATEPROGRAMPROC glCreateProgram; -NAZARA_RENDERER_API extern PFNGLCREATESHADERPROC glCreateShader; -NAZARA_RENDERER_API extern PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus; -NAZARA_RENDERER_API extern PFNGLCOLORMASKPROC glColorMask; -NAZARA_RENDERER_API extern PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glCompressedTexSubImage1D; -NAZARA_RENDERER_API extern PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glCompressedTexSubImage2D; -NAZARA_RENDERER_API extern PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glCompressedTexSubImage3D; -NAZARA_RENDERER_API extern PFNGLCULLFACEPROC glCullFace; -NAZARA_RENDERER_API extern PFNGLCOMPILESHADERPROC glCompileShader; -NAZARA_RENDERER_API extern PFNGLCOPYTEXSUBIMAGE2DPROC glCopyTexSubImage2D; -NAZARA_RENDERER_API extern PFNGLDEBUGMESSAGECALLBACKPROC glDebugMessageCallback; -NAZARA_RENDERER_API extern PFNGLDEBUGMESSAGECONTROLPROC glDebugMessageControl; -NAZARA_RENDERER_API extern PFNGLDEBUGMESSAGEINSERTPROC glDebugMessageInsert; -NAZARA_RENDERER_API extern PFNGLDELETEBUFFERSPROC glDeleteBuffers; -NAZARA_RENDERER_API extern PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers; -NAZARA_RENDERER_API extern PFNGLDELETEPROGRAMPROC glDeleteProgram; -NAZARA_RENDERER_API extern PFNGLDELETEQUERIESPROC glDeleteQueries; -NAZARA_RENDERER_API extern PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers; -NAZARA_RENDERER_API extern PFNGLDELETESAMPLERSPROC glDeleteSamplers; -NAZARA_RENDERER_API extern PFNGLDELETESHADERPROC glDeleteShader; -NAZARA_RENDERER_API extern PFNGLDELETETEXTURESPROC glDeleteTextures; -NAZARA_RENDERER_API extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays; -NAZARA_RENDERER_API extern PFNGLDEPTHFUNCPROC glDepthFunc; -NAZARA_RENDERER_API extern PFNGLDEPTHMASKPROC glDepthMask; -NAZARA_RENDERER_API extern PFNGLDISABLEPROC glDisable; -NAZARA_RENDERER_API extern PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray; -NAZARA_RENDERER_API extern PFNGLDRAWARRAYSPROC glDrawArrays; -NAZARA_RENDERER_API extern PFNGLDRAWARRAYSINSTANCEDPROC glDrawArraysInstanced; -NAZARA_RENDERER_API extern PFNGLDRAWBUFFERPROC glDrawBuffer; -NAZARA_RENDERER_API extern PFNGLDRAWBUFFERSPROC glDrawBuffers; -NAZARA_RENDERER_API extern PFNGLDRAWELEMENTSPROC glDrawElements; -NAZARA_RENDERER_API extern PFNGLDRAWELEMENTSINSTANCEDPROC glDrawElementsInstanced; -NAZARA_RENDERER_API extern PFNGLDRAWTEXTURENVPROC glDrawTexture; -NAZARA_RENDERER_API extern PFNGLENABLEPROC glEnable; -NAZARA_RENDERER_API extern PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray; -NAZARA_RENDERER_API extern PFNGLENDCONDITIONALRENDERPROC glEndConditionalRender; -NAZARA_RENDERER_API extern PFNGLENDQUERYPROC glEndQuery; -NAZARA_RENDERER_API extern PFNGLFLUSHPROC glFlush; -NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer; -NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERTEXTUREPROC glFramebufferTexture; -NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D; -NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D; -NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D; -NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer; -NAZARA_RENDERER_API extern PFNGLGENERATEMIPMAPPROC glGenerateMipmap; -NAZARA_RENDERER_API extern PFNGLGENBUFFERSPROC glGenBuffers; -NAZARA_RENDERER_API extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers; -NAZARA_RENDERER_API extern PFNGLGENQUERIESPROC glGenQueries; -NAZARA_RENDERER_API extern PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers; -NAZARA_RENDERER_API extern PFNGLGENSAMPLERSPROC glGenSamplers; -NAZARA_RENDERER_API extern PFNGLGENTEXTURESPROC glGenTextures; -NAZARA_RENDERER_API extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays; -NAZARA_RENDERER_API extern PFNGLGETACTIVEUNIFORMPROC glGetActiveUniform; -NAZARA_RENDERER_API extern PFNGLGETBOOLEANVPROC glGetBooleanv; -NAZARA_RENDERER_API extern PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv; -NAZARA_RENDERER_API extern PFNGLGETDEBUGMESSAGELOGPROC glGetDebugMessageLog; -NAZARA_RENDERER_API extern PFNGLGETERRORPROC glGetError; -NAZARA_RENDERER_API extern PFNGLGETFLOATVPROC glGetFloatv; -NAZARA_RENDERER_API extern PFNGLGETINTEGERVPROC glGetIntegerv; -NAZARA_RENDERER_API extern PFNGLGETPROGRAMBINARYPROC glGetProgramBinary; -NAZARA_RENDERER_API extern PFNGLGETPROGRAMIVPROC glGetProgramiv; -NAZARA_RENDERER_API extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog; -NAZARA_RENDERER_API extern PFNGLGETQUERYIVPROC glGetQueryiv; -NAZARA_RENDERER_API extern PFNGLGETQUERYOBJECTIVPROC glGetQueryObjectiv; -NAZARA_RENDERER_API extern PFNGLGETQUERYOBJECTUIVPROC glGetQueryObjectuiv; -NAZARA_RENDERER_API extern PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog; -NAZARA_RENDERER_API extern PFNGLGETSHADERIVPROC glGetShaderiv; -NAZARA_RENDERER_API extern PFNGLGETSHADERSOURCEPROC glGetShaderSource; -NAZARA_RENDERER_API extern PFNGLGETSTRINGPROC glGetString; -NAZARA_RENDERER_API extern PFNGLGETSTRINGIPROC glGetStringi; -NAZARA_RENDERER_API extern PFNGLGETTEXIMAGEPROC glGetTexImage; -NAZARA_RENDERER_API extern PFNGLGETTEXLEVELPARAMETERFVPROC glGetTexLevelParameterfv; -NAZARA_RENDERER_API extern PFNGLGETTEXLEVELPARAMETERIVPROC glGetTexLevelParameteriv; -NAZARA_RENDERER_API extern PFNGLGETTEXPARAMETERFVPROC glGetTexParameterfv; -NAZARA_RENDERER_API extern PFNGLGETTEXPARAMETERIVPROC glGetTexParameteriv; -NAZARA_RENDERER_API extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation; -NAZARA_RENDERER_API extern PFNGLINVALIDATEBUFFERDATAPROC glInvalidateBufferData; -NAZARA_RENDERER_API extern PFNGLISENABLEDPROC glIsEnabled; -NAZARA_RENDERER_API extern PFNGLLINEWIDTHPROC glLineWidth; -NAZARA_RENDERER_API extern PFNGLLINKPROGRAMPROC glLinkProgram; -NAZARA_RENDERER_API extern PFNGLMAPBUFFERPROC glMapBuffer; -NAZARA_RENDERER_API extern PFNGLMAPBUFFERRANGEPROC glMapBufferRange; -NAZARA_RENDERER_API extern PFNGLPIXELSTOREIPROC glPixelStorei; -NAZARA_RENDERER_API extern PFNGLPOINTSIZEPROC glPointSize; -NAZARA_RENDERER_API extern PFNGLPOLYGONMODEPROC glPolygonMode; -NAZARA_RENDERER_API extern PFNGLPROGRAMBINARYPROC glProgramBinary; -NAZARA_RENDERER_API extern PFNGLPROGRAMPARAMETERIPROC glProgramParameteri; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1DPROC glProgramUniform1d; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1FPROC glProgramUniform1f; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1IPROC glProgramUniform1i; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1DVPROC glProgramUniform1dv; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1FVPROC glProgramUniform1fv; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1IVPROC glProgramUniform1iv; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM2DVPROC glProgramUniform2dv; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM2FVPROC glProgramUniform2fv; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM2IVPROC glProgramUniform2iv; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM3DVPROC glProgramUniform3dv; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM3FVPROC glProgramUniform3fv; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM3IVPROC glProgramUniform3iv; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM4DVPROC glProgramUniform4dv; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM4FVPROC glProgramUniform4fv; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM4IVPROC glProgramUniform4iv; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORMMATRIX4DVPROC glProgramUniformMatrix4dv; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORMMATRIX4FVPROC glProgramUniformMatrix4fv; -NAZARA_RENDERER_API extern PFNGLREADPIXELSPROC glReadPixels; -NAZARA_RENDERER_API extern PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage; -NAZARA_RENDERER_API extern PFNGLSAMPLERPARAMETERFPROC glSamplerParameterf; -NAZARA_RENDERER_API extern PFNGLSAMPLERPARAMETERIPROC glSamplerParameteri; -NAZARA_RENDERER_API extern PFNGLSCISSORPROC glScissor; -NAZARA_RENDERER_API extern PFNGLSHADERSOURCEPROC glShaderSource; -NAZARA_RENDERER_API extern PFNGLSTENCILFUNCPROC glStencilFunc; -NAZARA_RENDERER_API extern PFNGLSTENCILFUNCSEPARATEPROC glStencilFuncSeparate; -NAZARA_RENDERER_API extern PFNGLSTENCILOPPROC glStencilOp; -NAZARA_RENDERER_API extern PFNGLSTENCILOPSEPARATEPROC glStencilOpSeparate; -NAZARA_RENDERER_API extern PFNGLTEXIMAGE1DPROC glTexImage1D; -NAZARA_RENDERER_API extern PFNGLTEXIMAGE2DPROC glTexImage2D; -NAZARA_RENDERER_API extern PFNGLTEXIMAGE3DPROC glTexImage3D; -NAZARA_RENDERER_API extern PFNGLTEXPARAMETERFPROC glTexParameterf; -NAZARA_RENDERER_API extern PFNGLTEXPARAMETERIPROC glTexParameteri; -NAZARA_RENDERER_API extern PFNGLTEXSTORAGE1DPROC glTexStorage1D; -NAZARA_RENDERER_API extern PFNGLTEXSTORAGE2DPROC glTexStorage2D; -NAZARA_RENDERER_API extern PFNGLTEXSTORAGE3DPROC glTexStorage3D; -NAZARA_RENDERER_API extern PFNGLTEXSUBIMAGE1DPROC glTexSubImage1D; -NAZARA_RENDERER_API extern PFNGLTEXSUBIMAGE2DPROC glTexSubImage2D; -NAZARA_RENDERER_API extern PFNGLTEXSUBIMAGE3DPROC glTexSubImage3D; -NAZARA_RENDERER_API extern PFNGLUNIFORM1DPROC glUniform1d; -NAZARA_RENDERER_API extern PFNGLUNIFORM1FPROC glUniform1f; -NAZARA_RENDERER_API extern PFNGLUNIFORM1IPROC glUniform1i; -NAZARA_RENDERER_API extern PFNGLUNIFORM1DVPROC glUniform1dv; -NAZARA_RENDERER_API extern PFNGLUNIFORM1FVPROC glUniform1fv; -NAZARA_RENDERER_API extern PFNGLUNIFORM1IVPROC glUniform1iv; -NAZARA_RENDERER_API extern PFNGLUNIFORM2DVPROC glUniform2dv; -NAZARA_RENDERER_API extern PFNGLUNIFORM2FVPROC glUniform2fv; -NAZARA_RENDERER_API extern PFNGLUNIFORM2IVPROC glUniform2iv; -NAZARA_RENDERER_API extern PFNGLUNIFORM3DVPROC glUniform3dv; -NAZARA_RENDERER_API extern PFNGLUNIFORM3FVPROC glUniform3fv; -NAZARA_RENDERER_API extern PFNGLUNIFORM3IVPROC glUniform3iv; -NAZARA_RENDERER_API extern PFNGLUNIFORM4DVPROC glUniform4dv; -NAZARA_RENDERER_API extern PFNGLUNIFORM4FVPROC glUniform4fv; -NAZARA_RENDERER_API extern PFNGLUNIFORM4IVPROC glUniform4iv; -NAZARA_RENDERER_API extern PFNGLUNIFORMMATRIX4DVPROC glUniformMatrix4dv; -NAZARA_RENDERER_API extern PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv; -NAZARA_RENDERER_API extern PFNGLUNMAPBUFFERPROC glUnmapBuffer; -NAZARA_RENDERER_API extern PFNGLUSEPROGRAMPROC glUseProgram; -NAZARA_RENDERER_API extern PFNGLVALIDATEPROGRAMPROC glValidateProgram; -NAZARA_RENDERER_API extern PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f; -NAZARA_RENDERER_API extern PFNGLVERTEXATTRIBDIVISORPROC glVertexAttribDivisor; -NAZARA_RENDERER_API extern PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer; -NAZARA_RENDERER_API extern PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer; -NAZARA_RENDERER_API extern PFNGLVERTEXATTRIBLPOINTERPROC glVertexAttribLPointer; -NAZARA_RENDERER_API extern PFNGLVIEWPORTPROC glViewport; -#if defined(NAZARA_PLATFORM_WINDOWS) -NAZARA_RENDERER_API extern PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormat; -NAZARA_RENDERER_API extern PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs; -NAZARA_RENDERER_API extern PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB; -NAZARA_RENDERER_API extern PFNWGLGETEXTENSIONSSTRINGEXTPROC wglGetExtensionsStringEXT; -NAZARA_RENDERER_API extern PFNWGLSWAPINTERVALEXTPROC wglSwapInterval; -#elif defined(NAZARA_PLATFORM_GLX) -NAZARA_RENDERER_API extern GLX::PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs; -NAZARA_RENDERER_API extern GLX::PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT; -NAZARA_RENDERER_API extern GLX::PFNGLXSWAPINTERVALMESAPROC NzglXSwapIntervalMESA; -NAZARA_RENDERER_API extern GLX::PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI; -#endif - -} - -#endif // NAZARA_RENDERER_OPENGL - -#endif // NAZARA_OPENGL_HPP diff --git a/include/Nazara/Renderer/RenderBuffer.hpp b/include/Nazara/Renderer/RenderBuffer.hpp deleted file mode 100644 index cfe66651e..000000000 --- a/include/Nazara/Renderer/RenderBuffer.hpp +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_RENDERBUFFER_HPP -#define NAZARA_RENDERBUFFER_HPP - -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - class RenderBuffer; - - using RenderBufferConstRef = ObjectRef; - using RenderBufferLibrary = ObjectLibrary; - using RenderBufferRef = ObjectRef; - - class NAZARA_RENDERER_API RenderBuffer : public RefCounted - { - friend RenderBufferLibrary; - friend class Renderer; - - public: - RenderBuffer(); - RenderBuffer(const RenderBuffer&) = delete; - RenderBuffer(RenderBuffer&&) = delete; - ~RenderBuffer(); - - bool Create(PixelFormatType format, unsigned int width, unsigned int height); - void Destroy(); - - unsigned int GetHeight() const; - PixelFormatType GetFormat() const; - unsigned int GetWidth() const; - - // Fonctions OpenGL - unsigned int GetOpenGLID() const; - - bool IsValid() const; - - RenderBuffer& operator=(const RenderBuffer&) = delete; - RenderBuffer& operator=(RenderBuffer&&) = delete; - - template static RenderBufferRef New(Args&&... args); - - // Signals: - NazaraSignal(OnRenderBufferDestroy, const RenderBuffer* /*renderBuffer*/); - NazaraSignal(OnRenderBufferRelease, const RenderBuffer* /*renderBuffer*/); - - private: - static bool Initialize(); - static void Uninitialize(); - - PixelFormatType m_pixelFormat; - unsigned int m_height; - unsigned int m_id; - unsigned int m_width; - - static RenderBufferLibrary::LibraryMap s_library; - }; -} - -#include - -#endif // NAZARA_RENDERBUFFER_HPP diff --git a/include/Nazara/Renderer/RenderBuffer.inl b/include/Nazara/Renderer/RenderBuffer.inl deleted file mode 100644 index bd81e7a17..000000000 --- a/include/Nazara/Renderer/RenderBuffer.inl +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include - -namespace Nz -{ - template - RenderBufferRef RenderBuffer::New(Args&&... args) - { - std::unique_ptr object(new RenderBuffer(std::forward(args)...)); - object->SetPersistent(false); - - return object.release(); - } -} - -#include diff --git a/include/Nazara/Renderer/RenderDevice.hpp b/include/Nazara/Renderer/RenderDevice.hpp new file mode 100644 index 000000000..4b1991085 --- /dev/null +++ b/include/Nazara/Renderer/RenderDevice.hpp @@ -0,0 +1,23 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_RENDERDEVICE_HPP +#define NAZARA_RENDERDEVICE_HPP + +#include +#include +#include + +namespace Nz +{ + struct RenderDevice + { + RenderDeviceType type; + String name; + }; +} + +#endif // NAZARA_RENDERER_HPP diff --git a/include/Nazara/Renderer/RenderPipeline.hpp b/include/Nazara/Renderer/RenderPipeline.hpp deleted file mode 100644 index aee5584b7..000000000 --- a/include/Nazara/Renderer/RenderPipeline.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_RENDERPIPELINE_HPP -#define NAZARA_RENDERPIPELINE_HPP - -#include -#include -#include - -namespace Nz -{ - struct RenderPipelineInfo : RenderStates - { - ShaderConstRef shader; - }; - - class RenderPipeline - { - public: - inline RenderPipeline(); - inline ~RenderPipeline(); - - inline bool Create(const RenderPipelineInfo& pipelineInfo); - inline void Destroy(); - - inline const RenderPipelineInfo& GetInfo() const; - - inline bool IsValid() const; - - private: - RenderPipelineInfo m_pipelineInfo; - bool m_valid; - }; -} - -#include - -#endif // NAZARA_RENDERPIPELINE_HPP diff --git a/include/Nazara/Renderer/RenderPipeline.inl b/include/Nazara/Renderer/RenderPipeline.inl deleted file mode 100644 index 5982b0562..000000000 --- a/include/Nazara/Renderer/RenderPipeline.inl +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include - -namespace Nz -{ - inline RenderPipeline::RenderPipeline() : - m_valid(false) - { - } - - inline RenderPipeline::~RenderPipeline() - { - } - - inline bool RenderPipeline::Create(const RenderPipelineInfo& pipelineInfo) - { - NazaraAssert(pipelineInfo.shader, "Invalid shader"); - - m_pipelineInfo = pipelineInfo; - m_valid = true; - - return true; - } - - inline void RenderPipeline::Destroy() - { - m_valid = false; - } - - inline const RenderPipelineInfo& RenderPipeline::GetInfo() const - { - NazaraAssert(m_valid, "Invalid pipeline info"); - - return m_pipelineInfo; - } - - inline bool RenderPipeline::IsValid() const - { - return m_valid; - } -} - -#include diff --git a/include/Nazara/Renderer/RenderStates.hpp b/include/Nazara/Renderer/RenderStates.hpp deleted file mode 100644 index fc4d10eeb..000000000 --- a/include/Nazara/Renderer/RenderStates.hpp +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_RENDERSTATES_HPP -#define NAZARA_RENDERSTATES_HPP - -#include -#include - -namespace Nz -{ - struct RenderStates - { - BlendFunc dstBlend = BlendFunc_Zero; - BlendFunc srcBlend = BlendFunc_One; - FaceFilling faceFilling = FaceFilling_Fill; - FaceSide cullingSide = FaceSide_Back; - RendererComparison depthFunc = RendererComparison_Less; - - struct - { - RendererComparison back = RendererComparison_Always; - RendererComparison front = RendererComparison_Always; - } stencilCompare; - - struct - { - UInt32 back = 0xFFFFFFFF; - UInt32 front = 0xFFFFFFFF; - } stencilCompareMask; - - struct - { - StencilOperation back = StencilOperation_Keep; - StencilOperation front = StencilOperation_Keep; - } stencilDepthFail; - - struct - { - StencilOperation back = StencilOperation_Keep; - StencilOperation front = StencilOperation_Keep; - } stencilFail; - - struct - { - StencilOperation back = StencilOperation_Keep; - StencilOperation front = StencilOperation_Keep; - } stencilPass; - - struct - { - UInt32 back = 0U; - UInt32 front = 0U; - } stencilReference; - - struct - { - UInt32 back = 0xFFFFFFFF; - UInt32 front = 0xFFFFFFFF; - } stencilWriteMask; - - bool blending = false; - bool colorWrite = true; - bool depthBuffer = false; - bool depthWrite = true; - bool faceCulling = false; - bool scissorTest = false; - bool stencilTest = false; - - float lineWidth = 1.f; - float pointSize = 1.f; - }; - - inline bool operator==(const RenderStates& lhs, const RenderStates& rhs); -} - -#include - -#endif // NAZARA_RENDERSTATES_HPP diff --git a/include/Nazara/Renderer/RenderStates.inl b/include/Nazara/Renderer/RenderStates.inl deleted file mode 100644 index 525491162..000000000 --- a/include/Nazara/Renderer/RenderStates.inl +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include - -namespace Nz -{ - bool operator==(const RenderStates& lhs, const RenderStates& rhs) - { - #define NazaraRenderStateMember(field) if (lhs.field != rhs.field) return false - #define NazaraRenderStateBoolMember NazaraRenderStateMember - #define NazaraRenderStateFloatMember(field, maxDiff) if (!NumberEquals(lhs.field, rhs.field, maxDiff)) return false - - NazaraRenderStateBoolMember(blending); - NazaraRenderStateBoolMember(colorWrite); - NazaraRenderStateBoolMember(depthBuffer); - NazaraRenderStateBoolMember(faceCulling); - NazaraRenderStateBoolMember(scissorTest); - NazaraRenderStateBoolMember(stencilTest); - - if (lhs.depthBuffer) - NazaraRenderStateBoolMember(depthWrite); - - NazaraRenderStateMember(faceFilling); - - if (lhs.blending) //< Remember, at this time we know lhs.blending == rhs.blending - { - NazaraRenderStateMember(dstBlend); - NazaraRenderStateMember(srcBlend); - } - - if (lhs.depthBuffer) - NazaraRenderStateMember(depthFunc); - - if (lhs.faceCulling) - NazaraRenderStateMember(cullingSide); - - if (lhs.stencilTest) - { - NazaraRenderStateMember(stencilCompare.back); - NazaraRenderStateMember(stencilCompare.front); - NazaraRenderStateMember(stencilCompareMask.back); - NazaraRenderStateMember(stencilCompareMask.front); - NazaraRenderStateMember(stencilDepthFail.back); - NazaraRenderStateMember(stencilDepthFail.front); - NazaraRenderStateMember(stencilFail.back); - NazaraRenderStateMember(stencilFail.front); - NazaraRenderStateMember(stencilPass.back); - NazaraRenderStateMember(stencilPass.front); - NazaraRenderStateMember(stencilReference.back); - NazaraRenderStateMember(stencilReference.front); - NazaraRenderStateMember(stencilWriteMask.back); - NazaraRenderStateMember(stencilWriteMask.front); - } - - NazaraRenderStateFloatMember(lineWidth, 0.001f); - NazaraRenderStateFloatMember(pointSize, 0.001f); - - #undef NazaraRenderStateMember - #undef NazaraRenderStateBoolMember - #undef NazaraRenderStateFloatMember - - return true; - } -} - -namespace std -{ - template<> - struct hash - { - size_t operator()(const Nz::RenderStates& pipelineInfo) const - { - std::size_t seed = 0; - - Nz::UInt8 parameterHash = 0; - Nz::UInt8 parameterIndex = 0; - - #define NazaraRenderStateBool(member) parameterHash |= ((pipelineInfo.member) ? 1U : 0U) << (parameterIndex++) - #define NazaraRenderStateBoolDep(dependency, member) parameterHash |= ((pipelineInfo.dependency && pipelineInfo.member) ? 1U : 0U) << (parameterIndex++) - #define NazaraRenderStateEnum(member) Nz::HashCombine(seed, static_cast(pipelineInfo.member)) - #define NazaraRenderStateFloat(member, maxDiff) Nz::HashCombine(seed, std::floor(pipelineInfo.member / maxDiff) * maxDiff) - - NazaraRenderStateBool(blending); - NazaraRenderStateBool(colorWrite); - NazaraRenderStateBool(depthBuffer); - NazaraRenderStateBool(faceCulling); - NazaraRenderStateBool(scissorTest); - NazaraRenderStateBool(stencilTest); - - NazaraRenderStateBoolDep(depthBuffer, depthWrite); - - NazaraRenderStateEnum(faceFilling); - - if (pipelineInfo.blending) //< Remember, at this time we know lhs.blending == rhs.blending - { - NazaraRenderStateEnum(dstBlend); - NazaraRenderStateEnum(srcBlend); - } - - if (pipelineInfo.depthBuffer) - NazaraRenderStateEnum(depthFunc); - - if (pipelineInfo.faceCulling) - NazaraRenderStateEnum(cullingSide); - - if (pipelineInfo.stencilTest) - { - NazaraRenderStateEnum(stencilCompare.back); - NazaraRenderStateEnum(stencilCompare.front); - NazaraRenderStateEnum(stencilCompareMask.back); - NazaraRenderStateEnum(stencilCompareMask.front); - NazaraRenderStateEnum(stencilDepthFail.back); - NazaraRenderStateEnum(stencilDepthFail.front); - NazaraRenderStateEnum(stencilFail.back); - NazaraRenderStateEnum(stencilFail.front); - NazaraRenderStateEnum(stencilPass.back); - NazaraRenderStateEnum(stencilPass.front); - NazaraRenderStateEnum(stencilReference.back); - NazaraRenderStateEnum(stencilReference.front); - NazaraRenderStateEnum(stencilWriteMask.back); - NazaraRenderStateEnum(stencilWriteMask.front); - } - - NazaraRenderStateFloat(lineWidth, 0.001f); - NazaraRenderStateFloat(pointSize, 0.001f); - - #undef NazaraRenderStateBool - #undef NazaraRenderStateBoolDep - #undef NazaraRenderStateEnum - #undef NazaraRenderStateFloat - - Nz::HashCombine(seed, parameterHash); - - return seed; - } - }; -} - -#include diff --git a/include/Nazara/Renderer/RenderTarget.hpp b/include/Nazara/Renderer/RenderTarget.hpp deleted file mode 100644 index d018cb952..000000000 --- a/include/Nazara/Renderer/RenderTarget.hpp +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_RENDERTARGET_HPP -#define NAZARA_RENDERTARGET_HPP - -#include -#include -#include -#include -#include - -namespace Nz -{ - class Renderer; - - class NAZARA_RENDERER_API RenderTarget - { - friend class Renderer; - - public: - RenderTarget() = default; - RenderTarget(const RenderTarget&) = delete; - RenderTarget(RenderTarget&&) = delete; ///TOOD? - virtual ~RenderTarget(); - - virtual unsigned int GetHeight() const = 0; - virtual RenderTargetParameters GetParameters() const = 0; - virtual unsigned int GetWidth() const = 0; - - bool IsActive() const; - virtual bool IsRenderable() const = 0; - - bool SetActive(bool active); - - // Fonctions OpenGL - virtual bool HasContext() const = 0; - - RenderTarget& operator=(const RenderTarget&) = delete; - RenderTarget& operator=(RenderTarget&&) = delete; ///TOOD? - - // Signals: - NazaraSignal(OnRenderTargetParametersChange, const RenderTarget* /*renderTarget*/); - NazaraSignal(OnRenderTargetRelease, const RenderTarget* /*renderTarget*/); - NazaraSignal(OnRenderTargetSizeChange, const RenderTarget* /*renderTarget*/); - - protected: - virtual bool Activate() const = 0; - virtual void Desactivate() const; - virtual void EnsureTargetUpdated() const = 0; - }; -} - -#endif // NAZARA_RENDERTARGET_HPP diff --git a/include/Nazara/Renderer/RenderTargetParameters.hpp b/include/Nazara/Renderer/RenderTargetParameters.hpp deleted file mode 100644 index 990848c53..000000000 --- a/include/Nazara/Renderer/RenderTargetParameters.hpp +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_RENDERTARGETPARAMETERS_HPP -#define NAZARA_RENDERTARGETPARAMETERS_HPP - -#include - -namespace Nz -{ - struct RenderTargetParameters - { - RenderTargetParameters(UInt8 antialiasing = 0, UInt8 depth = 24, UInt8 stencil = 0) : - antialiasingLevel(antialiasing), - depthBits(depth), - stencilBits(stencil) - { - } - - UInt8 antialiasingLevel; - UInt8 depthBits; - UInt8 stencilBits; - }; -} - -#endif // NAZARA_RENDERTARGETPARAMETERS_HPP diff --git a/include/Nazara/Renderer/RenderTexture.hpp b/include/Nazara/Renderer/RenderTexture.hpp deleted file mode 100644 index 798e441ee..000000000 --- a/include/Nazara/Renderer/RenderTexture.hpp +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_RENDERTEXTURE_HPP -#define NAZARA_RENDERTEXTURE_HPP - -#include -#include -#include -#include -#include -#include - -///TODO: Faire fonctionner les RenderTexture indépendamment du contexte (un FBO par instance et par contexte l'utilisant) - -namespace Nz -{ - - class Context; - class RenderBuffer; - class Texture; - - struct RenderTextureImpl; - - class NAZARA_RENDERER_API RenderTexture : public RenderTarget - { - public: - inline RenderTexture(); - RenderTexture(const RenderTexture&) = delete; - RenderTexture(RenderTexture&&) = delete; ///TODO? - inline ~RenderTexture(); - - bool AttachBuffer(AttachmentPoint attachmentPoint, UInt8 index, RenderBuffer* buffer); - bool AttachBuffer(AttachmentPoint attachmentPoint, UInt8 index, PixelFormatType format, unsigned int width, unsigned int height); - bool AttachTexture(AttachmentPoint attachmentPoint, UInt8 index, Texture* texture, unsigned int z = 0); - - bool Create(bool lock = false); - void Destroy(); - - void Detach(AttachmentPoint attachmentPoint, UInt8 index); - - unsigned int GetHeight() const override; - RenderTargetParameters GetParameters() const override; - Vector2ui GetSize() const; - unsigned int GetWidth() const override; - - bool IsComplete() const; - bool IsRenderable() const override; - inline bool IsValid() const; - - bool Lock() const; - - inline void SetColorTarget(UInt8 target) const; - void SetColorTargets(const UInt8* targets, unsigned int targetCount) const; - void SetColorTargets(const std::initializer_list& targets) const; - - void Unlock() const; - - // Fonctions OpenGL - unsigned int GetOpenGLID() const; - bool HasContext() const override; - - RenderTexture& operator=(const RenderTexture&) = delete; - RenderTexture& operator=(RenderTexture&&) = delete; ///TODO? - - static inline void Blit(RenderTexture* src, RenderTexture* dst, UInt32 buffers = RendererBuffer_Color | RendererBuffer_Depth | RendererBuffer_Stencil, bool bilinearFilter = false); - static void Blit(RenderTexture* src, Rectui srcRect, RenderTexture* dst, Rectui dstRect, UInt32 buffers = RendererBuffer_Color | RendererBuffer_Depth | RendererBuffer_Stencil, bool bilinearFilter = false); - - protected: - bool Activate() const override; - void Desactivate() const override; - void EnsureTargetUpdated() const override; - - private: - inline void InvalidateDrawBuffers() const; - inline void InvalidateSize() const; - inline void InvalidateTargets() const; - void OnContextDestroy(const Context* context); - void OnRenderBufferDestroy(const RenderBuffer* renderBuffer, unsigned int attachmentIndex); - void OnTextureDestroy(const Texture* texture, unsigned int attachmentIndex); - void UpdateDrawBuffers() const; - void UpdateSize() const; - void UpdateTargets() const; - - RenderTextureImpl* m_impl; - mutable bool m_checked ; - mutable bool m_drawBuffersUpdated; - mutable bool m_sizeUpdated; - mutable bool m_targetsUpdated; - }; -} - -#include - -#endif // NAZARA_RENDERTEXTURE_HPP diff --git a/include/Nazara/Renderer/RenderTexture.inl b/include/Nazara/Renderer/RenderTexture.inl deleted file mode 100644 index 7b8c32c68..000000000 --- a/include/Nazara/Renderer/RenderTexture.inl +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include - -namespace Nz -{ - inline RenderTexture::RenderTexture() : - m_impl(nullptr) - { - } - - inline RenderTexture::~RenderTexture() - { - Destroy(); - } - - inline bool RenderTexture::IsValid() const - { - return m_impl != nullptr; - } - - inline void RenderTexture::SetColorTarget(UInt8 target) const - { - SetColorTargets(&target, 1); - } - - inline void RenderTexture::Blit(RenderTexture* src, RenderTexture* dst, UInt32 buffers, bool bilinearFilter) - { - Blit(src, src->GetSize(), dst, dst->GetSize(), buffers, bilinearFilter); - } - - inline void RenderTexture::InvalidateDrawBuffers() const - { - m_drawBuffersUpdated = false; - } - - inline void RenderTexture::InvalidateSize() const - { - m_sizeUpdated = false; - - OnRenderTargetSizeChange(this); - } - - inline void RenderTexture::InvalidateTargets() const - { - m_checked = false; - m_drawBuffersUpdated = false; - m_targetsUpdated = false; - } -} - -#include diff --git a/include/Nazara/Renderer/RenderWindow.hpp b/include/Nazara/Renderer/RenderWindow.hpp index 1cda9d63d..5435cebaf 100644 --- a/include/Nazara/Renderer/RenderWindow.hpp +++ b/include/Nazara/Renderer/RenderWindow.hpp @@ -13,9 +13,6 @@ #include #include #include -#include -#include -#include #include #include diff --git a/include/Nazara/Renderer/RenderWindow.inl b/include/Nazara/Renderer/RenderWindow.inl new file mode 100644 index 000000000..1cda9d63d --- /dev/null +++ b/include/Nazara/Renderer/RenderWindow.inl @@ -0,0 +1,81 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +// Interface inspirée de la SFML par Laurent Gomila + +#pragma once + +#ifndef NAZARA_RENDERWINDOW_HPP +#define NAZARA_RENDERWINDOW_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class AbstractImage; + class Context; + class Texture; + struct ContextParameters; + + class NAZARA_RENDERER_API RenderWindow : public RenderTarget, public Window + { + public: + RenderWindow() = default; + RenderWindow(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default, const ContextParameters& parameters = ContextParameters()); + RenderWindow(WindowHandle handle, const ContextParameters& parameters = ContextParameters()); + RenderWindow(const RenderWindow&) = delete; + RenderWindow(RenderWindow&&) = delete; ///TODO + virtual ~RenderWindow(); + + bool CopyToImage(AbstractImage* image, const Vector3ui& dstPos = Vector3ui(0U)) const; + bool CopyToImage(AbstractImage* image, const Rectui& rect, const Vector3ui& dstPos = Vector3ui(0U)) const; + + bool Create(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default, const ContextParameters& parameters = ContextParameters()); + bool Create(WindowHandle handle, const ContextParameters& parameters = ContextParameters()); + + void Display(); + + void EnableVerticalSync(bool enabled); + + unsigned int GetHeight() const override; + RenderTargetParameters GetParameters() const override; + unsigned int GetWidth() const override; + + bool IsRenderable() const override; + bool IsValid() const; + + void SetFramerateLimit(unsigned int limit); + + // Fonctions OpenGL + ContextParameters GetContextParameters() const; + bool HasContext() const override; + + RenderWindow& operator=(const RenderWindow&) = delete; + RenderWindow& operator=(RenderWindow&&) = delete; ///TODO + + protected: + bool Activate() const override; + void EnsureTargetUpdated() const override; + bool OnWindowCreated() override; + void OnWindowDestroy() override; + void OnWindowResized() override; + + private: + mutable std::vector m_buffer; + Clock m_clock; + ContextParameters m_parameters; + mutable Context* m_context = nullptr; + unsigned int m_framerateLimit = 0; + }; +} + +#endif // NAZARA_RENDERWINDOW_HPP diff --git a/include/Nazara/Renderer/RenderWindowImpl.hpp b/include/Nazara/Renderer/RenderWindowImpl.hpp new file mode 100644 index 000000000..1cda9d63d --- /dev/null +++ b/include/Nazara/Renderer/RenderWindowImpl.hpp @@ -0,0 +1,81 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +// Interface inspirée de la SFML par Laurent Gomila + +#pragma once + +#ifndef NAZARA_RENDERWINDOW_HPP +#define NAZARA_RENDERWINDOW_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class AbstractImage; + class Context; + class Texture; + struct ContextParameters; + + class NAZARA_RENDERER_API RenderWindow : public RenderTarget, public Window + { + public: + RenderWindow() = default; + RenderWindow(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default, const ContextParameters& parameters = ContextParameters()); + RenderWindow(WindowHandle handle, const ContextParameters& parameters = ContextParameters()); + RenderWindow(const RenderWindow&) = delete; + RenderWindow(RenderWindow&&) = delete; ///TODO + virtual ~RenderWindow(); + + bool CopyToImage(AbstractImage* image, const Vector3ui& dstPos = Vector3ui(0U)) const; + bool CopyToImage(AbstractImage* image, const Rectui& rect, const Vector3ui& dstPos = Vector3ui(0U)) const; + + bool Create(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default, const ContextParameters& parameters = ContextParameters()); + bool Create(WindowHandle handle, const ContextParameters& parameters = ContextParameters()); + + void Display(); + + void EnableVerticalSync(bool enabled); + + unsigned int GetHeight() const override; + RenderTargetParameters GetParameters() const override; + unsigned int GetWidth() const override; + + bool IsRenderable() const override; + bool IsValid() const; + + void SetFramerateLimit(unsigned int limit); + + // Fonctions OpenGL + ContextParameters GetContextParameters() const; + bool HasContext() const override; + + RenderWindow& operator=(const RenderWindow&) = delete; + RenderWindow& operator=(RenderWindow&&) = delete; ///TODO + + protected: + bool Activate() const override; + void EnsureTargetUpdated() const override; + bool OnWindowCreated() override; + void OnWindowDestroy() override; + void OnWindowResized() override; + + private: + mutable std::vector m_buffer; + Clock m_clock; + ContextParameters m_parameters; + mutable Context* m_context = nullptr; + unsigned int m_framerateLimit = 0; + }; +} + +#endif // NAZARA_RENDERWINDOW_HPP diff --git a/include/Nazara/Renderer/Renderer.hpp b/include/Nazara/Renderer/Renderer.hpp index f93fe47e3..b23a5b284 100644 --- a/include/Nazara/Renderer/Renderer.hpp +++ b/include/Nazara/Renderer/Renderer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2016 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -8,120 +8,33 @@ #define NAZARA_RENDERER_HPP #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include namespace Nz { - class Color; - class Context; - class IndexBuffer; - class RenderTarget; - class Shader; - class Texture; - class VertexBuffer; - class NAZARA_RENDERER_API Renderer { - friend Texture; - public: - using DrawCall = void (*)(PrimitiveMode, unsigned int, unsigned int); - using DrawCallInstanced = void (*)(unsigned int, PrimitiveMode, unsigned int, unsigned int); - Renderer() = delete; ~Renderer() = delete; - - static void BeginCondition(const GpuQuery& query, GpuQueryCondition condition); - - static void Clear(UInt32 flags = RendererBuffer_Color | RendererBuffer_Depth); - - static void DrawFullscreenQuad(); - static void DrawIndexedPrimitives(PrimitiveMode mode, unsigned int firstIndex, unsigned int indexCount); - static void DrawIndexedPrimitivesInstanced(unsigned int instanceCount, PrimitiveMode mode, unsigned int firstIndex, unsigned int indexCount); - static void DrawPrimitives(PrimitiveMode mode, unsigned int firstVertex, unsigned int vertexCount); - static void DrawPrimitivesInstanced(unsigned int instanceCount, PrimitiveMode mode, unsigned int firstVertex, unsigned int vertexCount); - - static void Enable(RendererParameter parameter, bool enable); - - static void EndCondition(); - - static void Flush(); - - static RendererComparison GetDepthFunc(); - static VertexBuffer* GetInstanceBuffer(); - static float GetLineWidth(); - static Matrix4f GetMatrix(MatrixType type); - static UInt8 GetMaxAnisotropyLevel(); - static unsigned int GetMaxColorAttachments(); - static unsigned int GetMaxRenderTargets(); - static unsigned int GetMaxTextureSize(); - static unsigned int GetMaxTextureUnits(); - static unsigned int GetMaxVertexAttribs(); - static float GetPointSize(); - static const RenderStates& GetRenderStates(); - static Recti GetScissorRect(); - static const Shader* GetShader(); - static const RenderTarget* GetTarget(); - static Recti GetViewport(); - - static bool HasCapability(RendererCap capability); + + static inline RendererImpl* GetRendererImpl(); static bool Initialize(); - static bool IsComponentTypeSupported(ComponentType type); - static bool IsEnabled(RendererParameter parameter); - static bool IsInitialized(); - - static void SetBlendFunc(BlendFunc srcBlend, BlendFunc dstBlend); - static void SetClearColor(const Color& color); - static void SetClearColor(UInt8 r, UInt8 g, UInt8 b, UInt8 a = 255); - static void SetClearDepth(double depth); - static void SetClearStencil(unsigned int value); - static void SetDepthFunc(RendererComparison compareFunc); - static void SetFaceCulling(FaceSide faceSide); - static void SetFaceFilling(FaceFilling fillingMode); - static void SetIndexBuffer(const IndexBuffer* indexBuffer); - static void SetLineWidth(float size); - static void SetMatrix(MatrixType type, const Matrix4f& matrix); - static void SetPointSize(float size); - static void SetRenderStates(const RenderStates& states); - static void SetScissorRect(const Recti& rect); - static void SetShader(const Shader* shader); - static void SetStencilCompareFunction(RendererComparison compareFunc, FaceSide faceSide = FaceSide_FrontAndBack); - static void SetStencilFailOperation(StencilOperation failOperation, FaceSide faceSide = FaceSide_FrontAndBack); - static void SetStencilMask(UInt32 mask, FaceSide faceSide = FaceSide_FrontAndBack); - static void SetStencilPassOperation(StencilOperation passOperation, FaceSide faceSide = FaceSide_FrontAndBack); - static void SetStencilReferenceValue(unsigned int refValue, FaceSide faceSide = FaceSide_FrontAndBack); - static void SetStencilZFailOperation(StencilOperation zfailOperation, FaceSide faceSide = FaceSide_FrontAndBack); - static bool SetTarget(const RenderTarget* target); - static void SetTexture(UInt8 unit, const Texture* texture); - static void SetTextureSampler(UInt8 textureUnit, const TextureSampler& sampler); - static void SetVertexBuffer(const VertexBuffer* vertexBuffer); - static void SetViewport(const Recti& viewport); + static inline bool IsInitialized(); static void Uninitialize(); private: - static void EnableInstancing(bool instancing); - static bool EnsureStateUpdate(); - static void OnContextRelease(const Context* context); - static void OnIndexBufferRelease(const IndexBuffer* indexBuffer); - static void OnShaderReleased(const Shader* shader); - static void OnTextureReleased(const Texture* texture); - static void OnVertexBufferRelease(const VertexBuffer* vertexBuffer); - static void OnVertexDeclarationRelease(const VertexDeclaration* vertexDeclaration); - static void UpdateMatrix(MatrixType type); - + static DynLib s_rendererLib; + static std::unique_ptr s_rendererImpl; static unsigned int s_moduleReferenceCounter; }; } +#include + #endif // NAZARA_RENDERER_HPP diff --git a/include/Nazara/Renderer/Renderer.inl b/include/Nazara/Renderer/Renderer.inl new file mode 100644 index 000000000..16c3746db --- /dev/null +++ b/include/Nazara/Renderer/Renderer.inl @@ -0,0 +1,21 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline RendererImpl* Renderer::GetRendererImpl() + { + return s_rendererImpl.get(); + } + + inline bool Renderer::IsInitialized() + { + return s_moduleReferenceCounter != 0; + } +} + +#include diff --git a/include/Nazara/Renderer/RendererImpl.hpp b/include/Nazara/Renderer/RendererImpl.hpp new file mode 100644 index 000000000..f3f70d892 --- /dev/null +++ b/include/Nazara/Renderer/RendererImpl.hpp @@ -0,0 +1,42 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_RENDERER_RENDERERIMPL_HPP +#define NAZARA_RENDERER_RENDERERIMPL_HPP + +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class RendererImpl; + + using CreateRendererImplFunc = RendererImpl*(*)(); + + class NAZARA_RENDERER_API RendererImpl + { + public: + RendererImpl() = default; + virtual ~RendererImpl(); + + virtual bool IsBetterThan(const RendererImpl* other) const = 0; + + virtual RenderAPI QueryAPI() const = 0; + virtual String QueryAPIString() const = 0; + virtual UInt32 QueryAPIVersion() const = 0; + + virtual std::vector QueryRenderDevices() const = 0; + + virtual bool Prepare(const ParameterList& parameters) = 0; + }; +} + +#endif // NAZARA_RENDERER_RENDERERIMPL_HPP diff --git a/include/Nazara/Renderer/Shader.hpp b/include/Nazara/Renderer/Shader.hpp deleted file mode 100644 index aa9dabba8..000000000 --- a/include/Nazara/Renderer/Shader.hpp +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_SHADER_HPP -#define NAZARA_SHADER_HPP - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - class Shader; - class ShaderStage; - - using ShaderConstRef = ObjectRef; - using ShaderLibrary = ObjectLibrary; - using ShaderRef = ObjectRef; - - class NAZARA_RENDERER_API Shader : public RefCounted - { - friend ShaderLibrary; - friend class Renderer; - - public: - Shader(); - Shader(const Shader&) = delete; - Shader(Shader&&) = delete; - ~Shader(); - - void AttachStage(ShaderStageType stage, const ShaderStage& shaderStage); - bool AttachStageFromFile(ShaderStageType stage, const String& filePath); - bool AttachStageFromSource(ShaderStageType stage, const char* source, unsigned int length); - bool AttachStageFromSource(ShaderStageType stage, const String& source); - - void Bind() const; - - bool Create(); - void Destroy(); - - ByteArray GetBinary() const; - String GetLog() const; - String GetSourceCode(ShaderStageType stage) const; - int GetUniformLocation(const String& name) const; - int GetUniformLocation(ShaderUniform shaderUniform) const; - - bool HasStage(ShaderStageType stage) const; - - bool IsBinaryRetrievable() const; - bool IsLinked() const; - bool IsValid() const; - - bool Link(); - - bool LoadFromBinary(const void* buffer, unsigned int size); - bool LoadFromBinary(const ByteArray& byteArray); - - void SendBoolean(int location, bool value) const; - void SendColor(int location, const Color& color) const; - void SendDouble(int location, double value) const; - void SendDoubleArray(int location, const double* values, unsigned int count) const; - void SendFloat(int location, float value) const; - void SendFloatArray(int location, const float* values, unsigned int count) const; - void SendInteger(int location, int value) const; - void SendIntegerArray(int location, const int* values, unsigned int count) const; - void SendMatrix(int location, const Matrix4d& matrix) const; - void SendMatrix(int location, const Matrix4f& matrix) const; - void SendVector(int location, const Vector2d& vector) const; - void SendVector(int location, const Vector2f& vector) const; - void SendVector(int location, const Vector2i& vector) const; - void SendVector(int location, const Vector3d& vector) const; - void SendVector(int location, const Vector3f& vector) const; - void SendVector(int location, const Vector3i& vector) const; - void SendVector(int location, const Vector4d& vector) const; - void SendVector(int location, const Vector4f& vector) const; - void SendVector(int location, const Vector4i& vector) const; - void SendVectorArray(int location, const Vector2d* vectors, unsigned int count) const; - void SendVectorArray(int location, const Vector2f* vectors, unsigned int count) const; - void SendVectorArray(int location, const Vector2i* vectors, unsigned int count) const; - void SendVectorArray(int location, const Vector3d* vectors, unsigned int count) const; - void SendVectorArray(int location, const Vector3f* vectors, unsigned int count) const; - void SendVectorArray(int location, const Vector3i* vectors, unsigned int count) const; - void SendVectorArray(int location, const Vector4d* vectors, unsigned int count) const; - void SendVectorArray(int location, const Vector4f* vectors, unsigned int count) const; - void SendVectorArray(int location, const Vector4i* vectors, unsigned int count) const; - - bool Validate() const; - - // Fonctions OpenGL - unsigned int GetOpenGLID() const; - - Shader& operator=(const Shader&) = delete; - Shader& operator=(Shader&&) = delete; - - static bool IsStageSupported(ShaderStageType stage); - template static ShaderRef New(Args&&... args); - - // Signals: - NazaraSignal(OnShaderDestroy, const Shader* /*shader*/); - NazaraSignal(OnShaderRelease, const Shader* /*shader*/); - NazaraSignal(OnShaderUniformInvalidated, const Shader* /*shader*/); - - private: - bool PostLinkage(); - - static bool Initialize(); - static void Uninitialize(); - - std::vector m_attachedShaders[ShaderStageType_Max+1]; - bool m_linked; - int m_uniformLocations[ShaderUniform_Max+1]; - unsigned int m_program; - - static ShaderLibrary::LibraryMap s_library; - }; -} - -#include - -#endif // NAZARA_SHADER_HPP diff --git a/include/Nazara/Renderer/Shader.inl b/include/Nazara/Renderer/Shader.inl deleted file mode 100644 index b868c540e..000000000 --- a/include/Nazara/Renderer/Shader.inl +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include - -namespace Nz -{ - template - ShaderRef Shader::New(Args&&... args) - { - std::unique_ptr object(new Shader(std::forward(args)...)); - object->SetPersistent(false); - - return object.release(); - } -} - -#include diff --git a/include/Nazara/Renderer/ShaderStage.hpp b/include/Nazara/Renderer/ShaderStage.hpp deleted file mode 100644 index 1dfce1f51..000000000 --- a/include/Nazara/Renderer/ShaderStage.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_SHADERSTAGE_HPP -#define NAZARA_SHADERSTAGE_HPP - -#include -#include -#include -#include - -namespace Nz -{ - class NAZARA_RENDERER_API ShaderStage - { - public: - ShaderStage(); - ShaderStage(ShaderStageType stage); - ShaderStage(const ShaderStage&) = delete; - ShaderStage(ShaderStage&& stage); - ~ShaderStage(); - - bool Compile(); - - bool Create(ShaderStageType stage); - void Destroy(); - - String GetLog() const; - String GetSource() const; - - bool IsCompiled() const; - bool IsValid() const; - - void SetSource(const char* source, unsigned int length); - void SetSource(const String& source); - bool SetSourceFromFile(const String& filePath); - - ShaderStage& operator=(const ShaderStage&) = delete; - ShaderStage& operator=(ShaderStage&& shader); - - // Fonctions OpenGL - unsigned int GetOpenGLID() const; - - static bool IsSupported(ShaderStageType stage); - - private: - ShaderStageType m_stage; - bool m_compiled; - unsigned int m_id; - }; -} - -#endif // NAZARA_SHADERSTAGE_HPP diff --git a/include/Nazara/Renderer/Texture.hpp b/include/Nazara/Renderer/Texture.hpp deleted file mode 100644 index 2fd368b53..000000000 --- a/include/Nazara/Renderer/Texture.hpp +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_TEXTURE_HPP -#define NAZARA_TEXTURE_HPP - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - class Texture; - - using TextureConstRef = ObjectRef; - using TextureLibrary = ObjectLibrary; - using TextureManager = ResourceManager; - using TextureRef = ObjectRef; - - struct TextureImpl; - - class NAZARA_RENDERER_API Texture : public AbstractImage, public RefCounted, public Resource - { - friend TextureLibrary; - friend TextureManager; - friend class Renderer; - - public: - Texture() = default; - Texture(ImageType type, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth = 1, UInt8 levelCount = 1); - explicit Texture(const Image& image); - Texture(const Texture&) = delete; - Texture(Texture&&) = delete; - ~Texture(); - - bool Create(ImageType type, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth = 1, UInt8 levelCount = 1); - void Destroy(); - - bool Download(Image* image) const; - - bool EnableMipmapping(bool enable); - - void EnsureMipmapsUpdate() const; - - unsigned int GetDepth(UInt8 level = 0) const; - PixelFormatType GetFormat() const; - unsigned int GetHeight(UInt8 level = 0) const; - UInt8 GetLevelCount() const; - UInt8 GetMaxLevel() const; - std::size_t GetMemoryUsage() const; - std::size_t GetMemoryUsage(UInt8 level) const; - Vector3ui GetSize(UInt8 level = 0) const; - ImageType GetType() const; - unsigned int GetWidth(UInt8 level = 0) const; - - bool HasMipmaps() const; - - void InvalidateMipmaps(); - bool IsValid() const; - - // Load - bool LoadFromFile(const String& filePath, const ImageParams& params = ImageParams(), bool generateMipmaps = true); - bool LoadFromImage(const Image& image, bool generateMipmaps = true); - bool LoadFromMemory(const void* data, std::size_t size, const ImageParams& params = ImageParams(), bool generateMipmaps = true); - bool LoadFromStream(Stream& stream, const ImageParams& params = ImageParams(), bool generateMipmaps = true); - - // LoadArray - bool LoadArrayFromFile(const String& filePath, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2)); - bool LoadArrayFromImage(const Image& image, bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2)); - bool LoadArrayFromMemory(const void* data, std::size_t size, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2)); - bool LoadArrayFromStream(Stream& stream, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2)); - - // LoadCubemap - bool LoadCubemapFromFile(const String& filePath, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams()); - bool LoadCubemapFromImage(const Image& image, bool generateMipmaps = true, const CubemapParams& params = CubemapParams()); - bool LoadCubemapFromMemory(const void* data, std::size_t size, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams()); - bool LoadCubemapFromStream(Stream& stream, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams()); - - // LoadFace - bool LoadFaceFromFile(CubemapFace face, const String& filePath, const ImageParams& params = ImageParams()); - bool LoadFaceFromMemory(CubemapFace face, const void* data, std::size_t size, const ImageParams& params = ImageParams()); - bool LoadFaceFromStream(CubemapFace face, Stream& stream, const ImageParams& params = ImageParams()); - - // Save - bool SaveToFile(const String& filePath, const ImageParams& params = ImageParams()); - bool SaveToStream(Stream& stream, const String& format, const ImageParams& params = ImageParams()); - - bool SetMipmapRange(UInt8 minLevel, UInt8 maxLevel); - - bool Update(const Image& image, UInt8 level = 0); - bool Update(const Image& image, const Boxui& box, UInt8 level = 0); - bool Update(const Image& image, const Rectui& rect, unsigned int z = 0, UInt8 level = 0); - bool Update(const UInt8* pixels, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0); - bool Update(const UInt8* pixels, const Boxui& box, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0); - bool Update(const UInt8* pixels, const Rectui& rect, unsigned int z = 0, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0); - - // Fonctions OpenGL - unsigned int GetOpenGLID() const; - - Texture& operator=(const Texture&) = delete; - Texture& operator=(Texture&&) = delete; - - static bool IsFormatSupported(PixelFormatType format); - static bool IsMipmappingSupported(); - static bool IsTypeSupported(ImageType type); - template static TextureRef New(Args&&... args); - - // Signals: - NazaraSignal(OnTextureDestroy, const Texture* /*texture*/); - NazaraSignal(OnTextureRelease, const Texture* /*texture*/); - - private: - bool CreateTexture(bool proxy); - - static bool Initialize(); - static void Uninitialize(); - - TextureImpl* m_impl = nullptr; - - static TextureLibrary::LibraryMap s_library; - static TextureManager::ManagerMap s_managerMap; - static TextureManager::ManagerParams s_managerParameters; - }; -} - -#include - -#endif // NAZARA_TEXTURE_HPP diff --git a/include/Nazara/Renderer/Texture.inl b/include/Nazara/Renderer/Texture.inl deleted file mode 100644 index 4dc53464b..000000000 --- a/include/Nazara/Renderer/Texture.inl +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include - -namespace Nz -{ - template - TextureRef Texture::New(Args&&... args) - { - std::unique_ptr object(new Texture(std::forward(args)...)); - object->SetPersistent(false); - - return object.release(); - } - -} -#include diff --git a/include/Nazara/Renderer/TextureSampler.hpp b/include/Nazara/Renderer/TextureSampler.hpp deleted file mode 100644 index 21675e6c9..000000000 --- a/include/Nazara/Renderer/TextureSampler.hpp +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_TEXTURESAMPLER_HPP -#define NAZARA_TEXTURESAMPLER_HPP - -#include -#include -#include - -namespace Nz -{ - class Texture; - - class NAZARA_RENDERER_API TextureSampler - { - friend class Renderer; - - public: - TextureSampler(); - TextureSampler(const TextureSampler& sampler) = default; - - UInt8 GetAnisotropicLevel() const; - SamplerFilter GetFilterMode() const; - SamplerWrap GetWrapMode() const; - - void SetAnisotropyLevel(UInt8 anisotropyLevel); - void SetFilterMode(SamplerFilter filterMode); - void SetWrapMode(SamplerWrap wrapMode); - - TextureSampler& operator=(const TextureSampler& sampler) = default; - - static UInt8 GetDefaultAnisotropicLevel(); - static SamplerFilter GetDefaultFilterMode(); - static SamplerWrap GetDefaultWrapMode(); - - static void SetDefaultAnisotropyLevel(UInt8 anisotropyLevel); - static void SetDefaultFilterMode(SamplerFilter filterMode); - static void SetDefaultWrapMode(SamplerWrap wrapMode); - - private: - void Apply(const Texture* texture) const; - void Bind(unsigned int unit) const; - unsigned int GetOpenGLID() const; - void UpdateSamplerId() const; - bool UseMipmaps(bool mipmaps); - - static bool Initialize(); - static void Uninitialize(); - - SamplerFilter m_filterMode; - SamplerWrap m_wrapMode; - UInt8 m_anisotropicLevel; - bool m_mipmaps; - mutable unsigned int m_samplerId; - - static SamplerFilter s_defaultFilterMode; - static SamplerWrap s_defaultWrapMode; - static UInt8 s_defaultAnisotropyLevel; - }; -} - -#endif // NAZARA_TEXTURESAMPLER_HPP diff --git a/include/Nazara/Renderer/UberShader.hpp b/include/Nazara/Renderer/UberShader.hpp deleted file mode 100644 index 541715895..000000000 --- a/include/Nazara/Renderer/UberShader.hpp +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_UBERSHADER_HPP -#define NAZARA_UBERSHADER_HPP - -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - class UberShader; - - using UberShaderConstRef = ObjectRef; - using UberShaderLibrary = ObjectLibrary; - using UberShaderRef = ObjectRef; - - class NAZARA_RENDERER_API UberShader : public RefCounted - { - friend UberShaderLibrary; - friend class Renderer; - - public: - UberShader() = default; - UberShader(const UberShader&) = delete; - UberShader(UberShader&&) = delete; - virtual ~UberShader(); - - virtual UberShaderInstance* Get(const ParameterList& parameters) const = 0; - - UberShader& operator=(const UberShader&) = delete; - UberShader& operator=(UberShader&&) = delete; - - // Signals: - NazaraSignal(OnUberShaderRelease, const UberShader* /*uberShader*/); - - private: - static bool Initialize(); - static void Uninitialize(); - - static UberShaderLibrary::LibraryMap s_library; - }; -} - -#endif // NAZARA_UBERSHADER_HPP diff --git a/include/Nazara/Renderer/UberShaderInstance.hpp b/include/Nazara/Renderer/UberShaderInstance.hpp deleted file mode 100644 index 080cb8294..000000000 --- a/include/Nazara/Renderer/UberShaderInstance.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_UBERSHADERINSTANCE_HPP -#define NAZARA_UBERSHADERINSTANCE_HPP - -#include -#include - -namespace Nz -{ - class NAZARA_RENDERER_API UberShaderInstance - { - public: - UberShaderInstance(const Shader* shader); - virtual ~UberShaderInstance(); - - virtual bool Activate() const = 0; - - const Shader* GetShader() const; - - protected: - ShaderConstRef m_shader; - }; -} - -#endif // NAZARA_UBERSHADERINSTANCE_HPP diff --git a/include/Nazara/Renderer/UberShaderInstancePreprocessor.hpp b/include/Nazara/Renderer/UberShaderInstancePreprocessor.hpp deleted file mode 100644 index 9a0c8a6f9..000000000 --- a/include/Nazara/Renderer/UberShaderInstancePreprocessor.hpp +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_UBERSHADERINSTANCEPREPROCESSOR_HPP -#define NAZARA_UBERSHADERINSTANCEPREPROCESSOR_HPP - -#include -#include - -namespace Nz -{ - class NAZARA_RENDERER_API UberShaderInstancePreprocessor : public UberShaderInstance - { - public: - UberShaderInstancePreprocessor(const Shader* shader); - virtual ~UberShaderInstancePreprocessor(); - - bool Activate() const; - }; -} - -#endif // NAZARA_UBERSHADERINSTANCEPREPROCESSOR_HPP diff --git a/include/Nazara/Renderer/UberShaderPreprocessor.hpp b/include/Nazara/Renderer/UberShaderPreprocessor.hpp deleted file mode 100644 index 1411b731c..000000000 --- a/include/Nazara/Renderer/UberShaderPreprocessor.hpp +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_UBERSHADERPREPROCESSOR_HPP -#define NAZARA_UBERSHADERPREPROCESSOR_HPP - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - class UberShaderPreprocessor; - - using UberShaderPreprocessorConstRef = ObjectRef; - using UberShaderPreprocessorRef = ObjectRef; - - class NAZARA_RENDERER_API UberShaderPreprocessor : public UberShader - { - public: - UberShaderPreprocessor() = default; - ~UberShaderPreprocessor(); - - UberShaderInstance* Get(const ParameterList& parameters) const; - - void SetShader(ShaderStageType stage, const String& source, const String& shaderFlags, const String& requiredFlags = String()); - bool SetShaderFromFile(ShaderStageType stage, const String& filePath, const String& shaderFlags, const String& requiredFlags = String()); - - static bool IsSupported(); - template static UberShaderPreprocessorRef New(Args&&... args); - - // Signals: - NazaraSignal(OnUberShaderPreprocessorRelease, const UberShaderPreprocessor* /*uberShaderPreprocessor*/); - - private: - struct CachedShader - { - mutable std::unordered_map cache; - std::unordered_map flags; - UInt32 requiredFlags; - String source; - bool present = false; - }; - - mutable std::unordered_map m_cache; - std::unordered_map m_flags; - CachedShader m_shaders[ShaderStageType_Max+1]; - }; -} - -#include - -#endif // NAZARA_UBERSHADERPREPROCESSOR_HPP diff --git a/include/Nazara/Renderer/UberShaderPreprocessor.inl b/include/Nazara/Renderer/UberShaderPreprocessor.inl deleted file mode 100644 index 1e6528775..000000000 --- a/include/Nazara/Renderer/UberShaderPreprocessor.inl +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include - -namespace Nz -{ - template - UberShaderPreprocessorRef UberShaderPreprocessor::New(Args&&... args) - { - std::unique_ptr object(new UberShaderPreprocessor(std::forward(args)...)); - object->SetPersistent(false); - - return object.release(); - } -} - -#include diff --git a/include/Nazara/Vulkan.hpp b/include/Nazara/Vulkan.hpp deleted file mode 100644 index a19279f89..000000000 --- a/include/Nazara/Vulkan.hpp +++ /dev/null @@ -1,60 +0,0 @@ -// This file was automatically generated on 20 Jul 2016 at 13:49:17 - -/* - 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_GLOBAL_VULKAN_HPP -#define NAZARA_GLOBAL_VULKAN_HPP - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif // NAZARA_GLOBAL_VULKAN_HPP diff --git a/include/Nazara/VulkanRenderer.hpp b/include/Nazara/VulkanRenderer.hpp new file mode 100644 index 000000000..a2973a5fc --- /dev/null +++ b/include/Nazara/VulkanRenderer.hpp @@ -0,0 +1,61 @@ +// This file was automatically generated on 17 Aug 2016 at 14:07:55 + +/* + 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_GLOBAL_VULKANRENDERER_HPP +#define NAZARA_GLOBAL_VULKANRENDERER_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // NAZARA_GLOBAL_VULKANRENDERER_HPP diff --git a/include/Nazara/VulkanRenderer/Config.hpp b/include/Nazara/VulkanRenderer/Config.hpp new file mode 100644 index 000000000..12d6c6663 --- /dev/null +++ b/include/Nazara/VulkanRenderer/Config.hpp @@ -0,0 +1,53 @@ +/* + 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_VULKANRENDERER_HPP +#define NAZARA_CONFIG_VULKANRENDERER_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_VULKANRENDERER_MANAGE_MEMORY 0 + +// Active les tests de sécurité basés sur le code (Conseillé pour le développement) +#define NAZARA_VULKANRENDERER_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_VULKANRENDERER_BUILD + #define NAZARA_VULKANRENDERER_API NAZARA_EXPORT + #else + #define NAZARA_VULKANRENDERER_API NAZARA_IMPORT + #endif +#else + #define NAZARA_VULKANRENDERER_API +#endif + +#endif // NAZARA_CONFIG_MODULENAME_HPP diff --git a/include/Nazara/VulkanRenderer/ConfigCheck.hpp b/include/Nazara/VulkanRenderer/ConfigCheck.hpp new file mode 100644 index 000000000..600d214dd --- /dev/null +++ b/include/Nazara/VulkanRenderer/ConfigCheck.hpp @@ -0,0 +1,22 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// 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_VULKANRENDERER_MANAGE_MEMORY + #undef NAZARA_MODULENAME_MANAGE_MEMORY + #define NAZARA_MODULENAME_MANAGE_MEMORY 0 +#endif + +#endif // NAZARA_CONFIG_CHECK_VULKANRENDERER_HPP diff --git a/include/Nazara/VulkanRenderer/Debug.hpp b/include/Nazara/VulkanRenderer/Debug.hpp new file mode 100644 index 000000000..795aa7c7d --- /dev/null +++ b/include/Nazara/VulkanRenderer/Debug.hpp @@ -0,0 +1,8 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// 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/VulkanRenderer/DebugOff.hpp b/include/Nazara/VulkanRenderer/DebugOff.hpp new file mode 100644 index 000000000..a2e247323 --- /dev/null +++ b/include/Nazara/VulkanRenderer/DebugOff.hpp @@ -0,0 +1,9 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// 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/VulkanRenderer/RenderTarget.hpp b/include/Nazara/VulkanRenderer/RenderTarget.hpp new file mode 100644 index 000000000..c8e6b27fa --- /dev/null +++ b/include/Nazara/VulkanRenderer/RenderTarget.hpp @@ -0,0 +1,60 @@ +// Copyright (C) 201 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_RENDERTARGET_HPP +#define NAZARA_RENDERTARGET_HPP + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class Renderer; + + class NAZARA_VULKANRENDERER_API RenderTarget + { + friend Renderer; + + public: + RenderTarget() = default; + RenderTarget(const RenderTarget&) = delete; + RenderTarget(RenderTarget&&) = delete; ///TOOD? + virtual ~RenderTarget(); + + virtual bool Acquire(UInt32* imageIndex) const = 0; + + virtual void BuildPreRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) = 0; + virtual void BuildPostRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) = 0; + + virtual const Vk::Framebuffer& GetFrameBuffer(UInt32 imageIndex) const = 0; + virtual UInt32 GetFramebufferCount() const = 0; + + const Vk::RenderPass& GetRenderPass() const { return m_renderPass; } + + const Vk::Semaphore& GetRenderSemaphore() const { return m_imageReadySemaphore; } + + virtual void Present(UInt32 imageIndex) = 0; + + RenderTarget& operator=(const RenderTarget&) = delete; + RenderTarget& operator=(RenderTarget&&) = delete; ///TOOD? + + // Signals: + NazaraSignal(OnRenderTargetRelease, const RenderTarget* /*renderTarget*/); + NazaraSignal(OnRenderTargetSizeChange, const RenderTarget* /*renderTarget*/); + + protected: + Vk::RenderPass m_renderPass; + Vk::Semaphore m_imageReadySemaphore; + }; +} + +#endif // NAZARA_RENDERTARGET_HPP diff --git a/include/Nazara/VulkanRenderer/RenderWindow.hpp b/include/Nazara/VulkanRenderer/RenderWindow.hpp new file mode 100644 index 000000000..0b7f0878e --- /dev/null +++ b/include/Nazara/VulkanRenderer/RenderWindow.hpp @@ -0,0 +1,91 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_RENDERWINDOW_HPP +#define NAZARA_RENDERWINDOW_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_VULKANRENDERER_API RenderWindow : public RenderTarget, public Window + { + public: + RenderWindow(); + RenderWindow(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default); + RenderWindow(WindowHandle handle); + RenderWindow(const RenderWindow&) = delete; + RenderWindow(RenderWindow&&) = delete; ///TODO + virtual ~RenderWindow(); + + bool Acquire(UInt32* index) const override; + + void BuildPreRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) override; + void BuildPostRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) override; + + bool Create(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default); + bool Create(WindowHandle handle); + + const Vk::Framebuffer& GetFrameBuffer(UInt32 imageIndex) const override; + UInt32 GetFramebufferCount() const; + const Vk::DeviceHandle& GetDevice() const; + UInt32 GetPresentableFamilyQueue() const; + const Vk::Surface& GetSurface() const; + const Vk::Swapchain& GetSwapchain() const; + + void Present(UInt32 imageIndex) override; + + bool IsValid() const; + + void SetDepthStencilFormats(std::vector pixelFormat); + void SetPhysicalDevice(VkPhysicalDevice device); + + RenderWindow& operator=(const RenderWindow&) = delete; + RenderWindow& operator=(RenderWindow&&) = delete; ///TODO + + private: + bool OnWindowCreated() override; + void OnWindowDestroy() override; + void OnWindowResized() override; + + bool SetupDepthBuffer(); + bool SetupRenderPass(); + bool SetupSwapchain(); + + Clock m_clock; + VkColorSpaceKHR m_colorSpace; + VkFormat m_colorFormat; + VkFormat m_depthStencilFormat; + VkPhysicalDevice m_forcedPhysicalDevice; + std::vector m_wantedDepthStencilFormats; + std::vector m_frameBuffers; + Vk::DeviceHandle m_device; + Vk::DeviceMemory m_depthBufferMemory; + Vk::Image m_depthBuffer; + Vk::ImageView m_depthBufferView; + Vk::Queue m_presentQueue; + Vk::Surface m_surface; + Vk::Swapchain m_swapchain; + UInt32 m_presentableFamilyQueue; + }; +} + +#endif // NAZARA_RENDERWINDOW_HPP diff --git a/include/Nazara/VulkanRenderer/VkBuffer.hpp b/include/Nazara/VulkanRenderer/VkBuffer.hpp new file mode 100644 index 000000000..9f280f655 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkBuffer.hpp @@ -0,0 +1,46 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VKBUFFER_HPP +#define NAZARA_VULKANRENDERER_VKBUFFER_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class Buffer : public DeviceObject + { + friend DeviceObject; + + public: + Buffer() = default; + Buffer(const Buffer&) = delete; + Buffer(Buffer&&) = default; + ~Buffer() = default; + + bool BindBufferMemory(VkDeviceMemory memory, VkDeviceSize offset = 0); + + using DeviceObject::Create; + inline bool Create(const DeviceHandle& device, VkBufferCreateFlags flags, VkDeviceSize size, VkBufferUsageFlags usage, const VkAllocationCallbacks* allocator = nullptr); + + VkMemoryRequirements GetMemoryRequirements() const; + + Buffer& operator=(const Buffer&) = delete; + Buffer& operator=(Buffer&&) = delete; + + private: + static inline VkResult CreateHelper(const DeviceHandle& device, const VkBufferCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkBuffer* handle); + static inline void DestroyHelper(const DeviceHandle& device, VkBuffer handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_VULKANRENDERER_VKBUFFER_HPP diff --git a/include/Nazara/VulkanRenderer/VkBuffer.inl b/include/Nazara/VulkanRenderer/VkBuffer.inl new file mode 100644 index 000000000..2ac598738 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkBuffer.inl @@ -0,0 +1,62 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + namespace Vk + { + inline bool Buffer::BindBufferMemory(VkDeviceMemory memory, VkDeviceSize offset) + { + m_lastErrorCode = m_device->vkBindBufferMemory(*m_device, m_handle, memory, offset); + if (m_lastErrorCode != VK_SUCCESS) + { + NazaraError("Failed to bind buffer memory"); + return false; + } + + return true; + } + + inline bool Buffer::Create(const DeviceHandle& device, VkBufferCreateFlags flags, VkDeviceSize size, VkBufferUsageFlags usage, const VkAllocationCallbacks* allocator) + { + VkBufferCreateInfo createInfo = { + VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + flags, // VkBufferCreateFlags flags; + size, // VkDeviceSize size; + usage, // VkBufferUsageFlags usage; + VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode; + 0, // uint32_t queueFamilyIndexCount; + nullptr // const uint32_t* pQueueFamilyIndices; + }; + + return Create(device, createInfo, allocator); + } + + inline VkMemoryRequirements Buffer::GetMemoryRequirements() const + { + NazaraAssert(IsValid(), "Invalid buffer"); + + VkMemoryRequirements memoryRequirements; + m_device->vkGetBufferMemoryRequirements(*m_device, m_handle, &memoryRequirements); + + return memoryRequirements; + } + + inline VkResult Buffer::CreateHelper(const DeviceHandle& device, const VkBufferCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkBuffer* handle) + { + return device->vkCreateBuffer(*device, createInfo, allocator, handle); + } + + inline void Buffer::DestroyHelper(const DeviceHandle& device, VkBuffer handle, const VkAllocationCallbacks* allocator) + { + return device->vkDestroyBuffer(*device, handle, allocator); + } + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/VkCommandBuffer.hpp b/include/Nazara/VulkanRenderer/VkCommandBuffer.hpp new file mode 100644 index 000000000..dc88f13da --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkCommandBuffer.hpp @@ -0,0 +1,100 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VKCOMMANDBUFFER_HPP +#define NAZARA_VULKANRENDERER_VKCOMMANDBUFFER_HPP + +#include +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + class CommandBuffer + { + friend CommandPool; + + public: + inline CommandBuffer(); + CommandBuffer(const CommandBuffer&) = delete; + inline 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 void BeginRenderPass(const VkRenderPassBeginInfo& beginInfo, VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE); + + inline void BindDescriptorSet(VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, UInt32 firstSet, const VkDescriptorSet& descriptorSets); + inline void BindDescriptorSets(VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, UInt32 firstSet, UInt32 descriptorSetCount, const VkDescriptorSet* descriptorSets); + inline void BindDescriptorSets(VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, UInt32 firstSet, UInt32 descriptorSetCount, const VkDescriptorSet* descriptorSets, UInt32 dynamicOffsetCount, const UInt32* dynamicOffsets); + inline void BindIndexBuffer(VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType); + inline void BindPipeline(VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline); + inline void BindVertexBuffer(UInt32 binding, const VkBuffer buffer, const VkDeviceSize offset); + inline void BindVertexBuffers(UInt32 firstBinding, UInt32 bindingCount, const VkBuffer* buffer, const VkDeviceSize* offset); + + inline void ClearAttachment(const VkClearAttachment& attachment, const VkClearRect& rect); + inline void ClearAttachments(UInt32 attachmentCount, const VkClearAttachment* attachments, UInt32 rectCount, const VkClearRect* rects); + + inline void ClearColorImage(VkImage image, VkImageLayout imageLayout, const VkClearColorValue& color, const VkImageSubresourceRange& range); + inline void ClearColorImage(VkImage image, VkImageLayout imageLayout, const VkClearColorValue& color, UInt32 rangeCount, const VkImageSubresourceRange* ranges); + + inline void ClearDepthStencilImage(VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue& depthStencil, const VkImageSubresourceRange& range); + inline void ClearDepthStencilImage(VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue& depthStencil, UInt32 rangeCount, const VkImageSubresourceRange* ranges); + + inline void Draw(UInt32 vertexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0); + inline void DrawIndexed(UInt32 indexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, Int32 vertexOffset = 0, UInt32 firstInstance = 0); + + inline bool End(); + + inline void EndRenderPass(); + + inline void Free(); + + inline void PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, const VkImageMemoryBarrier& imageMemoryBarrier); + inline void PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, const VkMemoryBarrier& memoryBarrier, const VkBufferMemoryBarrier& bufferMemoryBarrier, const VkImageMemoryBarrier& imageMemoryBarrier); + inline void PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, UInt32 memoryBarrierCount, const VkMemoryBarrier* memoryBarriers, UInt32 bufferMemoryBarrierCount, const VkBufferMemoryBarrier* bufferMemoryBarriers, UInt32 imageMemoryBarrierCount, const VkImageMemoryBarrier* imageMemoryBarriers); + + inline void SetScissor(const Recti& scissorRegion); + inline void SetScissor(const VkRect2D& scissorRegion); + inline void SetScissor(UInt32 firstScissor, UInt32 scissorCount, const VkRect2D* scissors); + inline void SetViewport(const Rectf& viewport, float minDepth, float maxDepth); + inline void SetViewport(const VkViewport& viewport); + inline void SetViewport(UInt32 firstViewport, UInt32 viewportCount, const VkViewport* viewports); + + inline void SetImageLayout(VkImage image, VkImageLayout oldImageLayout, VkImageLayout newImageLayout); + inline void SetImageLayout(VkImage image, VkImageLayout oldImageLayout, VkImageLayout newImageLayout, const VkImageSubresourceRange& subresourceRange); + inline void SetImageLayout(VkImage image, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkImageLayout oldImageLayout, VkImageLayout newImageLayout); + inline void SetImageLayout(VkImage image, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkImageLayout oldImageLayout, VkImageLayout newImageLayout, const VkImageSubresourceRange& subresourceRange); + + inline VkResult GetLastErrorCode() const; + + CommandBuffer& operator=(const CommandBuffer&) = delete; + CommandBuffer& operator=(CommandBuffer&& commandBuffer); + + inline operator VkCommandBuffer() const; + + private: + inline CommandBuffer(CommandPool& pool, VkCommandBuffer handle); + + CommandPoolHandle m_pool; + VkAllocationCallbacks m_allocator; + VkCommandBuffer m_handle; + VkResult m_lastErrorCode; + + }; + } +} + +#include + +#endif // NAZARA_VULKANRENDERER_VKCOMMANDBUFFER_HPP diff --git a/include/Nazara/VulkanRenderer/VkCommandBuffer.inl b/include/Nazara/VulkanRenderer/VkCommandBuffer.inl new file mode 100644 index 000000000..1e425f114 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkCommandBuffer.inl @@ -0,0 +1,419 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + inline CommandBuffer::CommandBuffer() : + m_pool(), + m_handle(VK_NULL_HANDLE) + { + } + + 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 void CommandBuffer::BeginRenderPass(const VkRenderPassBeginInfo& beginInfo, VkSubpassContents contents) + { + return m_pool->GetDevice()->vkCmdBeginRenderPass(m_handle, &beginInfo, contents); + } + + inline void CommandBuffer::BindDescriptorSet(VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, UInt32 firstSet, const VkDescriptorSet& descriptorSets) + { + return BindDescriptorSets(pipelineBindPoint, layout, firstSet, 1U, &descriptorSets); + } + + inline void CommandBuffer::BindDescriptorSets(VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, UInt32 firstSet, UInt32 descriptorSetCount, const VkDescriptorSet* descriptorSets) + { + return BindDescriptorSets(pipelineBindPoint, layout, firstSet, descriptorSetCount, descriptorSets, 0U, nullptr); + } + + inline void CommandBuffer::BindDescriptorSets(VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, UInt32 firstSet, UInt32 descriptorSetCount, const VkDescriptorSet* descriptorSets, UInt32 dynamicOffsetCount, const UInt32* dynamicOffsets) + { + return m_pool->GetDevice()->vkCmdBindDescriptorSets(m_handle, pipelineBindPoint, layout, firstSet, descriptorSetCount, descriptorSets, dynamicOffsetCount, dynamicOffsets); + } + + inline void CommandBuffer::BindIndexBuffer(VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType) + { + return m_pool->GetDevice()->vkCmdBindIndexBuffer(m_handle, buffer, offset, indexType); + } + + inline void CommandBuffer::BindPipeline(VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline) + { + return m_pool->GetDevice()->vkCmdBindPipeline(m_handle, pipelineBindPoint, pipeline); + } + + inline void CommandBuffer::BindVertexBuffer(UInt32 binding, const VkBuffer buffer, const VkDeviceSize offset) + { + return BindVertexBuffers(binding, 1, &buffer, &offset); + } + + inline void CommandBuffer::BindVertexBuffers(UInt32 firstBinding, UInt32 bindingCount, const VkBuffer* buffer, const VkDeviceSize* offset) + { + return m_pool->GetDevice()->vkCmdBindVertexBuffers(m_handle, firstBinding, bindingCount, buffer, offset); + } + + inline void CommandBuffer::ClearAttachment(const VkClearAttachment& attachment, const VkClearRect& rect) + { + return ClearAttachments(1U, &attachment, 1U, &rect); + } + + inline void CommandBuffer::ClearAttachments(UInt32 attachmentCount, const VkClearAttachment* attachments, UInt32 rectCount, const VkClearRect* rects) + { + return m_pool->GetDevice()->vkCmdClearAttachments(m_handle, attachmentCount, attachments, rectCount, rects); + } + + inline void CommandBuffer::ClearColorImage(VkImage image, VkImageLayout imageLayout, const VkClearColorValue& color, const VkImageSubresourceRange& range) + { + return ClearColorImage(image, imageLayout, color, 1U, &range); + } + + inline void CommandBuffer::ClearColorImage(VkImage image, VkImageLayout imageLayout, const VkClearColorValue& color, UInt32 rangeCount, const VkImageSubresourceRange* ranges) + { + return m_pool->GetDevice()->vkCmdClearColorImage(m_handle, image, imageLayout, &color, rangeCount, ranges); + } + + inline void CommandBuffer::ClearDepthStencilImage(VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue& depthStencil, const VkImageSubresourceRange& range) + { + return ClearDepthStencilImage(image, imageLayout, depthStencil, 1U, &range); + } + + inline void CommandBuffer::ClearDepthStencilImage(VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue& depthStencil, UInt32 rangeCount, const VkImageSubresourceRange * ranges) + { + return m_pool->GetDevice()->vkCmdClearDepthStencilImage(m_handle, image, imageLayout, &depthStencil, rangeCount, ranges); + } + + inline void CommandBuffer::Draw(UInt32 vertexCount, UInt32 instanceCount, UInt32 firstVertex, UInt32 firstInstance) + { + return m_pool->GetDevice()->vkCmdDraw(m_handle, vertexCount, instanceCount, firstVertex, firstInstance); + } + + inline void CommandBuffer::DrawIndexed(UInt32 indexCount, UInt32 instanceCount, UInt32 firstVertex, Int32 vertexOffset, UInt32 firstInstance) + { + return m_pool->GetDevice()->vkCmdDrawIndexed(m_handle, indexCount, instanceCount, firstVertex, vertexOffset, firstInstance); + } + + 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::EndRenderPass() + { + return m_pool->GetDevice()->vkCmdEndRenderPass(m_handle); + } + + inline void CommandBuffer::Free() + { + if (m_handle) + m_pool->GetDevice()->vkFreeCommandBuffers(*m_pool->GetDevice(), *m_pool, 1, &m_handle); + } + + inline void CommandBuffer::PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, const VkImageMemoryBarrier& imageMemoryBarrier) + { + return PipelineBarrier(srcStageMask, dstStageMask, dependencyFlags, 0, nullptr, 0, nullptr, 1, &imageMemoryBarrier); + } + + inline void CommandBuffer::PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, const VkMemoryBarrier& memoryBarrier, const VkBufferMemoryBarrier& bufferMemoryBarrier, const VkImageMemoryBarrier& imageMemoryBarrier) + { + return PipelineBarrier(srcStageMask, dstStageMask, dependencyFlags, 1, &memoryBarrier, 1, &bufferMemoryBarrier, 1, &imageMemoryBarrier); + } + + inline void CommandBuffer::PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, UInt32 memoryBarrierCount, const VkMemoryBarrier* memoryBarriers, UInt32 bufferMemoryBarrierCount, const VkBufferMemoryBarrier* bufferMemoryBarriers, UInt32 imageMemoryBarrierCount, const VkImageMemoryBarrier* imageMemoryBarriers) + { + return m_pool->GetDevice()->vkCmdPipelineBarrier(m_handle, srcStageMask, dstStageMask, dependencyFlags, memoryBarrierCount, memoryBarriers, bufferMemoryBarrierCount, bufferMemoryBarriers, imageMemoryBarrierCount, imageMemoryBarriers); + } + + inline void CommandBuffer::SetScissor(const Recti& scissorRegion) + { + VkRect2D rect = { + {scissorRegion.x, scissorRegion.y}, // VkOffset2D offset + {UInt32(scissorRegion.width), UInt32(scissorRegion.height)} // VkExtent2D extent + }; + + SetScissor(rect); + } + + inline void CommandBuffer::SetScissor(const VkRect2D& scissorRegion) + { + return SetScissor(0, 1, &scissorRegion); + } + + inline void CommandBuffer::SetScissor(UInt32 firstScissor, UInt32 scissorCount, const VkRect2D* scissors) + { + return m_pool->GetDevice()->vkCmdSetScissor(m_handle, firstScissor, scissorCount, scissors); + } + + inline void CommandBuffer::SetImageLayout(VkImage image, VkImageLayout oldImageLayout, VkImageLayout newImageLayout) + { + return SetImageLayout(image, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, oldImageLayout, newImageLayout); + } + + inline void CommandBuffer::SetImageLayout(VkImage image, VkImageLayout oldImageLayout, VkImageLayout newImageLayout, const VkImageSubresourceRange& subresourceRange) + { + return SetImageLayout(image, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, oldImageLayout, newImageLayout, subresourceRange); + } + + inline void CommandBuffer::SetImageLayout(VkImage image, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkImageLayout oldImageLayout, VkImageLayout newImageLayout) + { + VkImageSubresourceRange imageRange = { + VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask + 0, // uint32_t baseMipLevel + 1, // uint32_t levelCount + 0, // uint32_t baseArrayLayer + 1 // uint32_t layerCount + }; + + return SetImageLayout(image, srcStageMask, dstStageMask, oldImageLayout, newImageLayout, imageRange); + } + + inline void CommandBuffer::SetImageLayout(VkImage image, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkImageLayout oldImageLayout, VkImageLayout newImageLayout, const VkImageSubresourceRange& subresourceRange) + { + VkAccessFlags srcAccessMask; + switch (oldImageLayout) + { + case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL: + srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; + break; + case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL: + srcAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; + break; + case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL: + srcAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT; + break; + case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL: + srcAccessMask = VK_ACCESS_SHADER_READ_BIT; + break; + case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL: + srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT; + break; + case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL: + srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; + break; + case VK_IMAGE_LAYOUT_PREINITIALIZED: + srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; + break; + case VK_IMAGE_LAYOUT_GENERAL: + case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR: + case VK_IMAGE_LAYOUT_UNDEFINED: + default: + srcAccessMask = 0; + break; + } + + VkAccessFlags dstAccessMask; + switch (newImageLayout) + { + case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL: + if (oldImageLayout != VK_IMAGE_LAYOUT_UNDEFINED) + srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT; + + dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; + break; + case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL: + dstAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; + break; + case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL: + if (srcAccessMask == 0) + srcAccessMask = VK_ACCESS_HOST_WRITE_BIT | VK_ACCESS_TRANSFER_WRITE_BIT; + + dstAccessMask = VK_ACCESS_SHADER_READ_BIT; + break; + case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL: + dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; + break; + case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL: + srcAccessMask |= VK_ACCESS_TRANSFER_READ_BIT; + dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT; + break; + case VK_IMAGE_LAYOUT_GENERAL: + case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR: + case VK_IMAGE_LAYOUT_UNDEFINED: + default: + dstAccessMask = 0; + break; + } + + VkImageMemoryBarrier imageBarrier = { + VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // VkStructureType sType + nullptr, // const void* pNext + srcAccessMask, // VkAccessFlags srcAccessMask + dstAccessMask, // VkAccessFlags dstAccessMask + oldImageLayout, // VkImageLayout oldLayout + newImageLayout, // VkImageLayout newLayout + VK_QUEUE_FAMILY_IGNORED, // uint32_t srcQueueFamilyIndex + VK_QUEUE_FAMILY_IGNORED, // uint32_t dstQueueFamilyIndex + image, // VkImage image + subresourceRange // VkImageSubresourceRange subresourceRange + }; + + return PipelineBarrier(srcStageMask, dstStageMask, 0, imageBarrier); + } + + inline void CommandBuffer::SetViewport(const Rectf& viewport, float minDepth, float maxDepth) + { + VkViewport rect = { + viewport.x, // float x; + viewport.y, // float y; + viewport.width, // float width; + viewport.height, // float height; + minDepth, // float minDepth; + maxDepth // float maxDepth; + }; + + SetViewport(rect); + } + + inline void CommandBuffer::SetViewport(const VkViewport& viewport) + { + return SetViewport(0, 1, &viewport); + } + + inline void CommandBuffer::SetViewport(UInt32 firstViewport, UInt32 viewportCount, const VkViewport* viewports) + { + return m_pool->GetDevice()->vkCmdSetViewport(m_handle, firstViewport, viewportCount, viewports); + } + + inline VkResult CommandBuffer::GetLastErrorCode() const + { + return m_lastErrorCode; + } + + inline CommandBuffer& CommandBuffer::operator=(CommandBuffer&& commandBuffer) + { + m_allocator = commandBuffer.m_allocator; + m_handle = commandBuffer.m_handle; + m_lastErrorCode = commandBuffer.m_lastErrorCode; + m_pool = std::move(commandBuffer.m_pool); + m_handle = commandBuffer.m_handle; + + commandBuffer.m_handle = VK_NULL_HANDLE; + + return *this; + } + + inline CommandBuffer::operator VkCommandBuffer() const + { + return m_handle; + } + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/VkCommandPool.hpp b/include/Nazara/VulkanRenderer/VkCommandPool.hpp new file mode 100644 index 000000000..178ec1fec --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkCommandPool.hpp @@ -0,0 +1,53 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VKCOMMANDPOOL_HPP +#define NAZARA_VULKANRENDERER_VKCOMMANDPOOL_HPP + +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + class CommandBuffer; + class CommandPool; + + using CommandPoolHandle = ObjectHandle; + + class NAZARA_VULKANRENDERER_API CommandPool : public DeviceObject, public HandledObject + { + friend DeviceObject; + + public: + CommandPool() = default; + 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(const DeviceHandle& device, 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(const DeviceHandle& device, const VkCommandPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkCommandPool* handle); + static inline void DestroyHelper(const DeviceHandle& device, VkCommandPool handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_VULKANRENDERER_VKCOMMANDPOOL_HPP diff --git a/include/Nazara/VulkanRenderer/VkCommandPool.inl b/include/Nazara/VulkanRenderer/VkCommandPool.inl new file mode 100644 index 000000000..cba47f66b --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkCommandPool.inl @@ -0,0 +1,48 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + inline bool CommandPool::Create(const DeviceHandle& device, UInt32 queueFamilyIndex, VkCommandPoolCreateFlags flags, const VkAllocationCallbacks* allocator) + { + VkCommandPoolCreateInfo createInfo = + { + VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, + nullptr, + flags, + queueFamilyIndex + }; + + return Create(device, 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(const DeviceHandle& device, const VkCommandPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkCommandPool* handle) + { + return device->vkCreateCommandPool(*device, createInfo, allocator, handle); + } + + inline void CommandPool::DestroyHelper(const DeviceHandle& device, VkCommandPool handle, const VkAllocationCallbacks* allocator) + { + return device->vkDestroyCommandPool(*device, handle, allocator); + } + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/VkDescriptorPool.hpp b/include/Nazara/VulkanRenderer/VkDescriptorPool.hpp new file mode 100644 index 000000000..b5c862ffe --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkDescriptorPool.hpp @@ -0,0 +1,52 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VKDESCRIPTORPOOL_HPP +#define NAZARA_VULKANRENDERER_VKDESCRIPTORPOOL_HPP + +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + class DescriptorPool; + class DescriptorSet; + + using DescriptorPoolHandle = ObjectHandle; + + class NAZARA_VULKANRENDERER_API DescriptorPool : public DeviceObject, public HandledObject + { + friend DeviceObject; + + public: + DescriptorPool() = default; + DescriptorPool(const DescriptorPool&) = delete; + DescriptorPool(DescriptorPool&&) = default; + ~DescriptorPool() = default; + + DescriptorSet AllocateDescriptorSet(const VkDescriptorSetLayout& setLayouts); + std::vector AllocateDescriptorSets(UInt32 descriptorSetCount, const VkDescriptorSetLayout* setLayouts); + + using DeviceObject::Create; + inline bool Create(const DeviceHandle& device, UInt32 maxSets, const VkDescriptorPoolSize& poolSize, VkDescriptorPoolCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(const DeviceHandle& device, UInt32 maxSets, UInt32 poolSizeCount, const VkDescriptorPoolSize* poolSize, VkDescriptorPoolCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + + DescriptorPool& operator=(const DescriptorPool&) = delete; + DescriptorPool& operator=(DescriptorPool&&) = delete; + + private: + static inline VkResult CreateHelper(const DeviceHandle& device, const VkDescriptorPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkDescriptorPool* handle); + static inline void DestroyHelper(const DeviceHandle& device, VkDescriptorPool handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_VULKANRENDERER_VKDESCRIPTORPOOL_HPP diff --git a/include/Nazara/VulkanRenderer/VkDescriptorPool.inl b/include/Nazara/VulkanRenderer/VkDescriptorPool.inl new file mode 100644 index 000000000..dc41a2ce8 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkDescriptorPool.inl @@ -0,0 +1,54 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + namespace Vk + { + inline bool DescriptorPool::Create(const DeviceHandle& device, UInt32 maxSets, const VkDescriptorPoolSize& poolSize, VkDescriptorPoolCreateFlags flags, const VkAllocationCallbacks* allocator) + { + VkDescriptorPoolCreateInfo createInfo = + { + VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + flags, // VkDescriptorPoolCreateFlags flags; + maxSets, // uint32_t maxSets; + 1U, // uint32_t poolSizeCount; + &poolSize // const VkDescriptorPoolSize* pPoolSizes; + }; + + return Create(device, createInfo, allocator); + } + + inline bool DescriptorPool::Create(const DeviceHandle& device, UInt32 maxSets, UInt32 poolSizeCount, const VkDescriptorPoolSize* poolSize, VkDescriptorPoolCreateFlags flags, const VkAllocationCallbacks* allocator) + { + VkDescriptorPoolCreateInfo createInfo = + { + VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + flags, // VkDescriptorPoolCreateFlags flags; + maxSets, // uint32_t maxSets; + poolSizeCount, // uint32_t poolSizeCount; + poolSize // const VkDescriptorPoolSize* pPoolSizes; + }; + + return Create(device, createInfo, allocator); + } + + inline VkResult DescriptorPool::CreateHelper(const DeviceHandle& device, const VkDescriptorPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkDescriptorPool* handle) + { + return device->vkCreateDescriptorPool(*device, createInfo, allocator, handle); + } + + inline void DescriptorPool::DestroyHelper(const DeviceHandle& device, VkDescriptorPool handle, const VkAllocationCallbacks* allocator) + { + return device->vkDestroyDescriptorPool(*device, handle, allocator); + } + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/VkDescriptorSet.hpp b/include/Nazara/VulkanRenderer/VkDescriptorSet.hpp new file mode 100644 index 000000000..3a4fba9dc --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkDescriptorSet.hpp @@ -0,0 +1,59 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VKDESCRIPTORSET_HPP +#define NAZARA_VULKANRENDERER_VKDESCRIPTORSET_HPP + +#include +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + class DescriptorSet + { + friend DescriptorPool; + + public: + inline DescriptorSet(); + DescriptorSet(const DescriptorSet&) = delete; + inline DescriptorSet(DescriptorSet&& descriptorSet); + inline ~DescriptorSet(); + + inline void Free(); + + inline VkResult GetLastErrorCode() const; + + inline void WriteUniformDescriptor(UInt32 binding, VkBuffer buffer, VkDeviceSize offset, VkDeviceSize range); + inline void WriteUniformDescriptor(UInt32 binding, const VkDescriptorBufferInfo& bufferInfo); + inline void WriteUniformDescriptor(UInt32 binding, UInt32 arrayElement, VkBuffer buffer, VkDeviceSize offset, VkDeviceSize range); + inline void WriteUniformDescriptor(UInt32 binding, UInt32 arrayElement, const VkDescriptorBufferInfo& bufferInfo); + inline void WriteUniformDescriptors(UInt32 binding, UInt32 descriptorCount, const VkDescriptorBufferInfo* bufferInfo); + inline void WriteUniformDescriptors(UInt32 binding, UInt32 arrayElement, UInt32 descriptorCount, const VkDescriptorBufferInfo* bufferInfo); + + DescriptorSet& operator=(const DescriptorSet&) = delete; + DescriptorSet& operator=(DescriptorSet&& descriptorSet); + + inline operator VkDescriptorSet() const; + + private: + inline DescriptorSet(DescriptorPool& pool, VkDescriptorSet handle); + + DescriptorPoolHandle m_pool; + VkAllocationCallbacks m_allocator; + VkDescriptorSet m_handle; + VkResult m_lastErrorCode; + + }; + } +} + +#include + +#endif // NAZARA_VULKANRENDERER_VKDESCRIPTORSET_HPP diff --git a/include/Nazara/VulkanRenderer/VkDescriptorSet.inl b/include/Nazara/VulkanRenderer/VkDescriptorSet.inl new file mode 100644 index 000000000..bc011005c --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkDescriptorSet.inl @@ -0,0 +1,122 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + inline DescriptorSet::DescriptorSet() : + m_pool(), + m_handle(VK_NULL_HANDLE) + { + } + + inline DescriptorSet::DescriptorSet(DescriptorPool& pool, VkDescriptorSet handle) : + m_pool(&pool), + m_handle(handle) + { + } + + inline DescriptorSet::DescriptorSet(DescriptorSet&& descriptorSet) : + m_pool(std::move(descriptorSet.m_pool)), + m_allocator(descriptorSet.m_allocator), + m_handle(descriptorSet.m_handle), + m_lastErrorCode(descriptorSet.m_lastErrorCode) + { + descriptorSet.m_handle = VK_NULL_HANDLE; + } + + inline DescriptorSet::~DescriptorSet() + { + Free(); + } + + inline void DescriptorSet::Free() + { + if (m_handle) + m_pool->GetDevice()->vkFreeDescriptorSets(*m_pool->GetDevice(), *m_pool, 1, &m_handle); + } + + inline VkResult DescriptorSet::GetLastErrorCode() const + { + return m_lastErrorCode; + } + + inline void DescriptorSet::WriteUniformDescriptor(UInt32 binding, VkBuffer buffer, VkDeviceSize offset, VkDeviceSize range) + { + return WriteUniformDescriptor(binding, 0U, buffer, offset, range); + } + + inline void DescriptorSet::WriteUniformDescriptor(UInt32 binding, const VkDescriptorBufferInfo& bufferInfo) + { + return WriteUniformDescriptors(binding, 0U, 1U, &bufferInfo); + } + + inline void DescriptorSet::WriteUniformDescriptor(UInt32 binding, UInt32 arrayElement, VkBuffer buffer, VkDeviceSize offset, VkDeviceSize range) + { + VkDescriptorBufferInfo bufferInfo = + { + buffer, // VkBuffer buffer; + offset, // VkDeviceSize offset; + range // VkDeviceSize range; + }; + + return WriteUniformDescriptor(binding, arrayElement, bufferInfo); + } + + inline void DescriptorSet::WriteUniformDescriptor(UInt32 binding, UInt32 arrayElement, const VkDescriptorBufferInfo& bufferInfo) + { + return WriteUniformDescriptors(binding, arrayElement, 1U, &bufferInfo); + } + + inline void DescriptorSet::WriteUniformDescriptors(UInt32 binding, UInt32 descriptorCount, const VkDescriptorBufferInfo* bufferInfo) + { + return WriteUniformDescriptors(binding, 0U, descriptorCount, bufferInfo); + } + + inline void DescriptorSet::WriteUniformDescriptors(UInt32 binding, UInt32 arrayElement, UInt32 descriptorCount, const VkDescriptorBufferInfo* bufferInfo) + { + VkWriteDescriptorSet writeDescriptorSet = + { + VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, // VkStructureType sType; + nullptr, // const void* pNext; + m_handle, // VkDescriptorSet dstSet; + binding, // uint32_t dstBinding; + arrayElement, // uint32_t dstArrayElement; + descriptorCount, // uint32_t descriptorCount; + VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, // VkDescriptorType descriptorType; + nullptr, // const VkDescriptorImageInfo* pImageInfo; + bufferInfo, // const VkDescriptorBufferInfo* pBufferInfo; + nullptr // const VkBufferView* pTexelBufferView; + }; + + return m_pool->GetDevice()->vkUpdateDescriptorSets(*m_pool->GetDevice(), 1U, &writeDescriptorSet, 0U, nullptr); + } + + inline DescriptorSet& DescriptorSet::operator=(DescriptorSet&& descriptorSet) + { + m_allocator = descriptorSet.m_allocator; + m_handle = descriptorSet.m_handle; + m_lastErrorCode = descriptorSet.m_lastErrorCode; + m_pool = std::move(descriptorSet.m_pool); + m_handle = descriptorSet.m_handle; + + descriptorSet.m_handle = VK_NULL_HANDLE; + + return *this; + } + + inline DescriptorSet::operator VkDescriptorSet() const + { + return m_handle; + } + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/VkDescriptorSetLayout.hpp b/include/Nazara/VulkanRenderer/VkDescriptorSetLayout.hpp new file mode 100644 index 000000000..6aff14fbe --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkDescriptorSetLayout.hpp @@ -0,0 +1,43 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VKDESCRIPTORSETLAYOUT_HPP +#define NAZARA_VULKANRENDERER_VKDESCRIPTORSETLAYOUT_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class DescriptorSetLayout : public DeviceObject + { + friend DeviceObject; + + public: + DescriptorSetLayout() = default; + DescriptorSetLayout(const DescriptorSetLayout&) = delete; + DescriptorSetLayout(DescriptorSetLayout&&) = default; + ~DescriptorSetLayout() = default; + + using DeviceObject::Create; + inline bool Create(const DeviceHandle& device, const VkDescriptorSetLayoutBinding& binding, VkDescriptorSetLayoutCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(const DeviceHandle& device, UInt32 bindingCount, const VkDescriptorSetLayoutBinding* binding, VkDescriptorSetLayoutCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + + DescriptorSetLayout& operator=(const DescriptorSetLayout&) = delete; + DescriptorSetLayout& operator=(DescriptorSetLayout&&) = delete; + + private: + static inline VkResult CreateHelper(const DeviceHandle& device, const VkDescriptorSetLayoutCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkDescriptorSetLayout* handle); + static inline void DestroyHelper(const DeviceHandle& device, VkDescriptorSetLayout handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_VULKANRENDERER_VKDESCRIPTORSETLAYOUT_HPP diff --git a/include/Nazara/VulkanRenderer/VkDescriptorSetLayout.inl b/include/Nazara/VulkanRenderer/VkDescriptorSetLayout.inl new file mode 100644 index 000000000..a53956b64 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkDescriptorSetLayout.inl @@ -0,0 +1,43 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + namespace Vk + { + inline bool DescriptorSetLayout::Create(const DeviceHandle& device, const VkDescriptorSetLayoutBinding& binding, VkDescriptorSetLayoutCreateFlags flags, const VkAllocationCallbacks* allocator) + { + return Create(device, 1U, &binding, flags, allocator); + } + + inline bool DescriptorSetLayout::Create(const DeviceHandle& device, UInt32 bindingCount, const VkDescriptorSetLayoutBinding* binding, VkDescriptorSetLayoutCreateFlags flags, const VkAllocationCallbacks* allocator) + { + VkDescriptorSetLayoutCreateInfo createInfo = + { + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + flags, // VkDescriptorSetLayoutCreateFlags flags; + bindingCount, // uint32_t bindingCount; + binding // const VkDescriptorSetLayoutBinding* pBindings; + }; + + return Create(device, createInfo, allocator); + } + + inline VkResult DescriptorSetLayout::CreateHelper(const DeviceHandle& device, const VkDescriptorSetLayoutCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkDescriptorSetLayout* handle) + { + return device->vkCreateDescriptorSetLayout(*device, createInfo, allocator, handle); + } + + inline void DescriptorSetLayout::DestroyHelper(const DeviceHandle& device, VkDescriptorSetLayout handle, const VkAllocationCallbacks* allocator) + { + return device->vkDestroyDescriptorSetLayout(*device, handle, allocator); + } + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/VkDevice.hpp b/include/Nazara/VulkanRenderer/VkDevice.hpp new file mode 100644 index 000000000..32928338c --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkDevice.hpp @@ -0,0 +1,232 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VKDEVICE_HPP +#define NAZARA_VULKANRENDERER_VKDEVICE_HPP + +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + class Device; + class Queue; + class Instance; + + using DeviceHandle = ObjectHandle; + + class NAZARA_VULKANRENDERER_API Device : public HandledObject + { + public: + struct QueueFamilyInfo; + struct QueueInfo; + using QueueList = std::vector; + + 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 const std::vector& GetEnabledQueues() const; + inline const QueueList& GetEnabledQueues(UInt32 familyQueue) const; + + inline Queue GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex); + inline Instance& GetInstance(); + inline const Instance& GetInstance() const; + inline VkResult GetLastErrorCode() const; + inline VkPhysicalDevice GetPhysicalDevice() 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_VULKANRENDERER_DEVICE_FUNCTION(func) PFN_##func func + + // Vulkan core + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkAllocateCommandBuffers); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkAllocateDescriptorSets); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkAllocateMemory); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkBeginCommandBuffer); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkBindBufferMemory); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkBindImageMemory); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdBeginQuery); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdBeginRenderPass); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdBindDescriptorSets); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdBindIndexBuffer); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdBindPipeline); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdBindVertexBuffers); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdBlitImage); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdClearAttachments); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdClearColorImage); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdClearDepthStencilImage); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdCopyBuffer); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdCopyBufferToImage); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdCopyImage); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdCopyImageToBuffer); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdCopyQueryPoolResults); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdDispatch); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdDispatchIndirect); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdDraw); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdDrawIndexed); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdDrawIndexedIndirect); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdDrawIndirect); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdEndQuery); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdEndRenderPass); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdExecuteCommands); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdFillBuffer); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdNextSubpass); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdPipelineBarrier); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdPushConstants); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdResetEvent); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdResetQueryPool); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdResolveImage); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdSetBlendConstants); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdSetDepthBias); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdSetDepthBounds); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdSetEvent); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdSetLineWidth); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdSetScissor); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdSetStencilCompareMask); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdSetStencilReference); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdSetStencilWriteMask); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdSetViewport); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdUpdateBuffer); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdWaitEvents); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdWriteTimestamp); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateBuffer); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateBufferView); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateCommandPool); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateComputePipelines); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateDescriptorPool); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateDescriptorSetLayout); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateEvent); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateFramebuffer); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateGraphicsPipelines); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateImage); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateImageView); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreatePipelineCache); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreatePipelineLayout); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateRenderPass); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateSampler); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateSemaphore); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateShaderModule); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyBuffer); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyBufferView); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyCommandPool); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyDescriptorPool); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyDescriptorSetLayout); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyDevice); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyEvent); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyFramebuffer); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyImage); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyImageView); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyPipeline); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyPipelineCache); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyPipelineLayout); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyRenderPass); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroySampler); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroySemaphore); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyShaderModule); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDeviceWaitIdle); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkEndCommandBuffer); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkFreeCommandBuffers); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkFreeDescriptorSets); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkFreeMemory); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkFlushMappedMemoryRanges); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetBufferMemoryRequirements); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetDeviceMemoryCommitment); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetDeviceQueue); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetEventStatus); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetFenceStatus); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetImageMemoryRequirements); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetImageSparseMemoryRequirements); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetImageSubresourceLayout); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetRenderAreaGranularity); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkInvalidateMappedMemoryRanges); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkMapMemory); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkMergePipelineCaches); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkQueueSubmit); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkQueueWaitIdle); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkResetCommandBuffer); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkResetCommandPool); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkResetDescriptorPool); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkResetFences); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkResetEvent); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkSetEvent); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkUnmapMemory); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkUpdateDescriptorSets); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkWaitForFences); + + // VK_KHR_display_swapchain + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateSharedSwapchainsKHR); + + // VK_KHR_surface + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroySurfaceKHR); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetPhysicalDeviceSurfaceCapabilitiesKHR); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetPhysicalDeviceSurfaceFormatsKHR); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetPhysicalDeviceSurfacePresentModesKHR); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetPhysicalDeviceSurfaceSupportKHR); + + // VK_KHR_swapchain + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkAcquireNextImageKHR); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateSwapchainKHR); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroySwapchainKHR); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetSwapchainImagesKHR); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkQueuePresentKHR); + + #undef NAZARA_VULKANRENDERER_DEVICE_FUNCTION + + struct QueueInfo + { + QueueFamilyInfo* familyInfo; + VkQueue queue; + float priority; + }; + + struct QueueFamilyInfo + { + QueueList queues; + VkExtent3D minImageTransferGranularity; + VkQueueFlags flags; + UInt32 familyIndex; + UInt32 timestampValidBits; + }; + + private: + inline PFN_vkVoidFunction GetProcAddr(const char* name); + + Instance& m_instance; + VkAllocationCallbacks m_allocator; + VkDevice m_device; + VkPhysicalDevice m_physicalDevice; + VkResult m_lastErrorCode; + std::unordered_set m_loadedExtensions; + std::unordered_set m_loadedLayers; + std::vector m_enabledQueuesInfos; + std::vector m_queuesByFamily; + }; + } +} + +#include + +#endif // NAZARA_VULKANRENDERER_VKDEVICE_HPP diff --git a/include/Nazara/VulkanRenderer/VkDevice.inl b/include/Nazara/VulkanRenderer/VkDevice.inl new file mode 100644 index 000000000..f18fde6a7 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkDevice.inl @@ -0,0 +1,117 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// 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(VK_NULL_HANDLE), + m_physicalDevice(VK_NULL_HANDLE) + { + } + + inline Device::~Device() + { + Destroy(); + } + + inline void Device::Destroy() + { + if (m_device != VK_NULL_HANDLE) + { + vkDeviceWaitIdle(m_device); + vkDestroyDevice(m_device, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); + + m_device = VK_NULL_HANDLE; + m_physicalDevice = VK_NULL_HANDLE; + } + } + + inline const std::vector& Device::GetEnabledQueues() const + { + return m_enabledQueuesInfos; + } + + inline const Device::QueueList& Device::GetEnabledQueues(UInt32 familyQueue) const + { + NazaraAssert(familyQueue < m_enabledQueuesInfos.size(), "Invalid family queue"); + + return *m_queuesByFamily[familyQueue]; + } + + inline Queue Device::GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex) + { + VkQueue queue; + vkGetDeviceQueue(m_device, queueFamilyIndex, queueIndex, &queue); + + return Queue(CreateHandle(), 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 VkPhysicalDevice Device::GetPhysicalDevice() const + { + return m_physicalDevice; + } + + 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/VulkanRenderer/VkDeviceMemory.hpp b/include/Nazara/VulkanRenderer/VkDeviceMemory.hpp new file mode 100644 index 000000000..c2a5b72c5 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkDeviceMemory.hpp @@ -0,0 +1,51 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VKDEVICEMEMORY_HPP +#define NAZARA_VULKANRENDERER_VKDEVICEMEMORY_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class DeviceMemory : public DeviceObject + { + friend DeviceObject; + + public: + DeviceMemory(); + DeviceMemory(const DeviceMemory&) = delete; + DeviceMemory(DeviceMemory&& memory); + ~DeviceMemory() = default; + + using DeviceObject::Create; + inline bool Create(const DeviceHandle& device, VkDeviceSize size, UInt32 memoryType, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(const DeviceHandle& device, VkDeviceSize size, UInt32 typeBits, VkFlags properties, const VkAllocationCallbacks* allocator = nullptr); + + inline void* GetMappedPointer(); + + inline bool Map(VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags = 0); + + inline void Unmap(); + + DeviceMemory& operator=(const DeviceMemory&) = delete; + DeviceMemory& operator=(DeviceMemory&&) = delete; + + private: + static inline VkResult CreateHelper(const DeviceHandle& device, const VkMemoryAllocateInfo* allocInfo, const VkAllocationCallbacks* allocator, VkDeviceMemory* handle); + static inline void DestroyHelper(const DeviceHandle& device, VkDeviceMemory handle, const VkAllocationCallbacks* allocator); + + void* m_mappedPtr; + }; + } +} + +#include + +#endif // NAZARA_VULKANRENDERER_VKDEVICEMEMORY_HPP diff --git a/include/Nazara/VulkanRenderer/VkDeviceMemory.inl b/include/Nazara/VulkanRenderer/VkDeviceMemory.inl new file mode 100644 index 000000000..2e0c26b30 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkDeviceMemory.inl @@ -0,0 +1,96 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + inline DeviceMemory::DeviceMemory() : + m_mappedPtr(nullptr) + { + } + + DeviceMemory::DeviceMemory(DeviceMemory&& memory) : + DeviceObject(std::move(memory)) + { + m_mappedPtr = memory.m_mappedPtr; + memory.m_mappedPtr = nullptr; + } + + inline bool DeviceMemory::Create(const DeviceHandle& device, VkDeviceSize size, UInt32 memoryType, const VkAllocationCallbacks* allocator) + { + VkMemoryAllocateInfo allocInfo = + { + VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + size, // VkDeviceSize allocationSize; + memoryType // uint32_t memoryTypeIndex; + }; + + return Create(device, allocInfo, allocator); + } + + inline bool DeviceMemory::Create(const DeviceHandle& device, VkDeviceSize size, UInt32 typeBits, VkFlags properties, const VkAllocationCallbacks* allocator) + { + const Vk::PhysicalDevice& deviceInfo = Vulkan::GetPhysicalDeviceInfo(device->GetPhysicalDevice()); + + UInt32 typeMask = 1; + for (UInt32 i = 0; i < VK_MAX_MEMORY_TYPES; ++i) + { + if (typeBits & typeMask) + { + if ((deviceInfo.memoryProperties.memoryTypes[i].propertyFlags & properties) == properties) + return Create(device, size, i, allocator); + } + + typeMask <<= 1; + } + + NazaraError("Failed to find a memory type suitable for typeBits: " + String::Number(typeBits) + " and properties: 0x" + String::Number(properties, 16)); + return false; + } + + inline void* DeviceMemory::GetMappedPointer() + { + return m_mappedPtr; + } + + inline bool DeviceMemory::Map(VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags) + { + m_lastErrorCode = m_device->vkMapMemory(*m_device, m_handle, offset, size, flags, &m_mappedPtr); + if (m_lastErrorCode != VK_SUCCESS) + { + NazaraError("Failed to map device memory"); + return false; + } + + return true; + } + + inline void DeviceMemory::Unmap() + { + NazaraAssert(m_mappedPtr != nullptr, "Memory is not mapped"); + + m_device->vkUnmapMemory(*m_device, m_handle); + m_mappedPtr = nullptr; + } + + inline VkResult DeviceMemory::CreateHelper(const DeviceHandle& device, const VkMemoryAllocateInfo* allocInfo, const VkAllocationCallbacks* allocator, VkDeviceMemory* handle) + { + return device->vkAllocateMemory(*device, allocInfo, allocator, handle); + } + + inline void DeviceMemory::DestroyHelper(const DeviceHandle& device, VkDeviceMemory handle, const VkAllocationCallbacks* allocator) + { + return device->vkFreeMemory(*device, handle, allocator); + } + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/VkDeviceObject.hpp b/include/Nazara/VulkanRenderer/VkDeviceObject.hpp new file mode 100644 index 000000000..3778a73ea --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkDeviceObject.hpp @@ -0,0 +1,51 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VKDEVICEOBJECT_HPP +#define NAZARA_VULKANRENDERER_VKDEVICEOBJECT_HPP + +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + template + class DeviceObject + { + public: + inline DeviceObject(); + DeviceObject(const DeviceObject&) = delete; + DeviceObject(DeviceObject&&); + inline ~DeviceObject(); + + 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; + + DeviceObject& operator=(const DeviceObject&) = delete; + DeviceObject& operator=(DeviceObject&&) = delete; + + inline operator VkType() const; + + protected: + DeviceHandle m_device; + VkAllocationCallbacks m_allocator; + VkType m_handle; + mutable VkResult m_lastErrorCode; + }; + } +} + +#include + +#endif // NAZARA_VULKANRENDERER_VKDEVICEOBJECT_HPP diff --git a/include/Nazara/VulkanRenderer/VkDeviceObject.inl b/include/Nazara/VulkanRenderer/VkDeviceObject.inl new file mode 100644 index 000000000..f238d199a --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkDeviceObject.inl @@ -0,0 +1,93 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + template + inline DeviceObject::DeviceObject() : + m_handle(VK_NULL_HANDLE) + { + } + + template + inline DeviceObject::DeviceObject(DeviceObject&& object) : + m_device(std::move(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 DeviceHandle& device, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator) + { + m_device = device; + 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 (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 + { + return m_device; + } + + template + inline VkResult DeviceObject::GetLastErrorCode() const + { + return m_lastErrorCode; + } + + template + inline DeviceObject::operator VkType() const + { + return m_handle; + } + } +} + +#include +#include "VkDeviceObject.hpp" diff --git a/include/Nazara/VulkanRenderer/VkFramebuffer.hpp b/include/Nazara/VulkanRenderer/VkFramebuffer.hpp new file mode 100644 index 000000000..606042371 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkFramebuffer.hpp @@ -0,0 +1,39 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VKFRAMEBUFFER_HPP +#define NAZARA_VULKANRENDERER_VKFRAMEBUFFER_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class Framebuffer : public DeviceObject + { + friend DeviceObject; + + public: + Framebuffer() = default; + Framebuffer(const Framebuffer&) = delete; + Framebuffer(Framebuffer&&) = default; + ~Framebuffer() = default; + + Framebuffer& operator=(const Framebuffer&) = delete; + Framebuffer& operator=(Framebuffer&&) = delete; + + private: + static inline VkResult CreateHelper(const DeviceHandle& device, const VkFramebufferCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkFramebuffer* handle); + static inline void DestroyHelper(const DeviceHandle& device, VkFramebuffer handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_VULKANRENDERER_VKFRAMEBUFFER_HPP diff --git a/include/Nazara/VulkanRenderer/VkFramebuffer.inl b/include/Nazara/VulkanRenderer/VkFramebuffer.inl new file mode 100644 index 000000000..961f3e0c6 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkFramebuffer.inl @@ -0,0 +1,24 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + namespace Vk + { + inline VkResult Framebuffer::CreateHelper(const DeviceHandle& device, const VkFramebufferCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkFramebuffer* handle) + { + return device->vkCreateFramebuffer(*device, createInfo, allocator, handle); + } + + inline void Framebuffer::DestroyHelper(const DeviceHandle& device, VkFramebuffer handle, const VkAllocationCallbacks* allocator) + { + return device->vkDestroyFramebuffer(*device, handle, allocator); + } + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/VkImage.hpp b/include/Nazara/VulkanRenderer/VkImage.hpp new file mode 100644 index 000000000..578662600 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkImage.hpp @@ -0,0 +1,43 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VKIMAGE_HPP +#define NAZARA_VULKANRENDERER_VKIMAGE_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class Image : public DeviceObject + { + friend DeviceObject; + + public: + Image() = default; + Image(const Image&) = delete; + Image(Image&&) = default; + ~Image() = default; + + bool BindImageMemory(VkDeviceMemory memory, VkDeviceSize offset = 0); + + VkMemoryRequirements GetMemoryRequirements() const; + + Image& operator=(const Image&) = delete; + Image& operator=(Image&&) = delete; + + private: + static inline VkResult CreateHelper(const DeviceHandle& device, const VkImageCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkImage* handle); + static inline void DestroyHelper(const DeviceHandle& device, VkImage handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_VULKANRENDERER_VKIMAGE_HPP diff --git a/include/Nazara/VulkanRenderer/VkImage.inl b/include/Nazara/VulkanRenderer/VkImage.inl new file mode 100644 index 000000000..b4e0332cb --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkImage.inl @@ -0,0 +1,46 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + namespace Vk + { + inline bool Image::BindImageMemory(VkDeviceMemory memory, VkDeviceSize offset) + { + m_lastErrorCode = m_device->vkBindImageMemory(*m_device, m_handle, memory, offset); + if (m_lastErrorCode != VK_SUCCESS) + { + NazaraError("Failed to bind buffer memory"); + return false; + } + + return true; + } + + inline VkMemoryRequirements Image::GetMemoryRequirements() const + { + NazaraAssert(IsValid(), "Invalid image"); + + VkMemoryRequirements memoryRequirements; + m_device->vkGetImageMemoryRequirements(*m_device, m_handle, &memoryRequirements); + + return memoryRequirements; + } + + inline VkResult Image::CreateHelper(const DeviceHandle& device, const VkImageCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkImage* handle) + { + return device->vkCreateImage(*device, createInfo, allocator, handle); + } + + inline void Image::DestroyHelper(const DeviceHandle& device, VkImage handle, const VkAllocationCallbacks* allocator) + { + return device->vkDestroyImage(*device, handle, allocator); + } + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/VkImageView.hpp b/include/Nazara/VulkanRenderer/VkImageView.hpp new file mode 100644 index 000000000..8362859cc --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkImageView.hpp @@ -0,0 +1,39 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VKIMAGEVIEW_HPP +#define NAZARA_VULKANRENDERER_VKIMAGEVIEW_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class ImageView : public DeviceObject + { + friend DeviceObject; + + public: + ImageView() = default; + ImageView(const ImageView&) = delete; + ImageView(ImageView&&) = default; + ~ImageView() = default; + + ImageView& operator=(const ImageView&) = delete; + ImageView& operator=(ImageView&&) = delete; + + private: + static inline VkResult CreateHelper(const DeviceHandle& device, const VkImageViewCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkImageView* handle); + static inline void DestroyHelper(const DeviceHandle& device, VkImageView handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_VULKANRENDERER_VKIMAGEVIEW_HPP diff --git a/include/Nazara/VulkanRenderer/VkImageView.inl b/include/Nazara/VulkanRenderer/VkImageView.inl new file mode 100644 index 000000000..8bf522c9e --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkImageView.inl @@ -0,0 +1,24 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + namespace Vk + { + inline VkResult ImageView::CreateHelper(const DeviceHandle& device, const VkImageViewCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkImageView* handle) + { + return device->vkCreateImageView(*device, createInfo, allocator, handle); + } + + inline void ImageView::DestroyHelper(const DeviceHandle& device, VkImageView handle, const VkAllocationCallbacks* allocator) + { + return device->vkDestroyImageView(*device, handle, allocator); + } + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/VkInstance.hpp b/include/Nazara/VulkanRenderer/VkInstance.hpp new file mode 100644 index 000000000..0e9f52f87 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkInstance.hpp @@ -0,0 +1,141 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VKINSTANCE_HPP +#define NAZARA_VULKANRENDERER_VKINSTANCE_HPP + +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + class NAZARA_VULKANRENDERER_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 VkPhysicalDeviceFeatures GetPhysicalDeviceFeatures(VkPhysicalDevice device); + inline VkFormatProperties GetPhysicalDeviceFormatProperties(VkPhysicalDevice device, VkFormat format); + inline bool GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* imageFormatProperties); + inline VkPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties(VkPhysicalDevice device); + inline VkPhysicalDeviceProperties GetPhysicalDeviceProperties(VkPhysicalDevice device); + 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_VULKANRENDERER_INSTANCE_FUNCTION(func) PFN_##func func + + // Vulkan core + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateDevice); + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkDestroyInstance); + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkEnumeratePhysicalDevices); + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetDeviceProcAddr); + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceFeatures); + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceFormatProperties); + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceImageFormatProperties); + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceMemoryProperties); + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceProperties); + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceQueueFamilyProperties); + + // VK_KHR_display + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateDisplayModeKHR); + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateDisplayPlaneSurfaceKHR); + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetDisplayModePropertiesKHR); + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetDisplayPlaneCapabilitiesKHR); + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetDisplayPlaneSupportedDisplaysKHR); + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceDisplayPlanePropertiesKHR); + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceDisplayPropertiesKHR); + + // VK_KHR_surface + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkDestroySurfaceKHR); + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfaceCapabilitiesKHR); + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfaceFormatsKHR); + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfacePresentModesKHR); + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfaceSupportKHR); + + // VK_EXT_debug_report + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateDebugReportCallbackEXT); + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkDestroyDebugReportCallbackEXT); + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkDebugReportMessageEXT); + + #ifdef VK_USE_PLATFORM_ANDROID_KHR + // VK_KHR_android_surface + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateAndroidSurfaceKHR); + #endif + + #ifdef VK_USE_PLATFORM_MIR_KHR + // VK_KHR_mir_surface + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateMirSurfaceKHR); + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceMirPresentationSupportKHR); + #endif + + #ifdef VK_USE_PLATFORM_XCB_KHR + // VK_KHR_xcb_surface + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateXcbSurfaceKHR); + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceXcbPresentationSupportKHR); + #endif + + #ifdef VK_USE_PLATFORM_XLIB_KHR + // VK_KHR_xlib_surface + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateXlibSurfaceKHR); + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceXlibPresentationSupportKHR); + #endif + + #ifdef VK_USE_PLATFORM_WAYLAND_KHR + // VK_KHR_wayland_surface + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateWaylandSurfaceKHR); + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceWaylandPresentationSupportKHR); + #endif + + #ifdef VK_USE_PLATFORM_WIN32_KHR + // VK_KHR_win32_surface + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateWin32SurfaceKHR); + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceWin32PresentationSupportKHR); + #endif + + #undef NAZARA_VULKANRENDERER_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_VULKANRENDERER_VKINSTANCE_HPP diff --git a/include/Nazara/VulkanRenderer/VkInstance.inl b/include/Nazara/VulkanRenderer/VkInstance.inl new file mode 100644 index 000000000..6de0929e9 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkInstance.inl @@ -0,0 +1,143 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// 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); + m_instance = 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 VkPhysicalDeviceFeatures Instance::GetPhysicalDeviceFeatures(VkPhysicalDevice device) + { + VkPhysicalDeviceFeatures features; + vkGetPhysicalDeviceFeatures(device, &features); + + return features; + } + + inline VkFormatProperties Instance::GetPhysicalDeviceFormatProperties(VkPhysicalDevice device, VkFormat format) + { + VkFormatProperties formatProperties; + vkGetPhysicalDeviceFormatProperties(device, format, &formatProperties); + + return 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 VkPhysicalDeviceMemoryProperties Instance::GetPhysicalDeviceMemoryProperties(VkPhysicalDevice device) + { + VkPhysicalDeviceMemoryProperties memoryProperties; + vkGetPhysicalDeviceMemoryProperties(device, &memoryProperties); + + return memoryProperties; + } + + inline VkPhysicalDeviceProperties Instance::GetPhysicalDeviceProperties(VkPhysicalDevice device) + { + VkPhysicalDeviceProperties properties; + vkGetPhysicalDeviceProperties(device, &properties); + + return 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/VulkanRenderer/VkLoader.hpp b/include/Nazara/VulkanRenderer/VkLoader.hpp new file mode 100644 index 000000000..a83eb58e1 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkLoader.hpp @@ -0,0 +1,52 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VKLOADER_HPP +#define NAZARA_VULKANRENDERER_VKLOADER_HPP + +#include +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + class NAZARA_VULKANRENDERER_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_VULKANRENDERER_GLOBAL_FUNCTION(func) static PFN_##func func + + NAZARA_VULKANRENDERER_GLOBAL_FUNCTION(vkCreateInstance); + NAZARA_VULKANRENDERER_GLOBAL_FUNCTION(vkEnumerateInstanceExtensionProperties); + NAZARA_VULKANRENDERER_GLOBAL_FUNCTION(vkEnumerateInstanceLayerProperties); + NAZARA_VULKANRENDERER_GLOBAL_FUNCTION(vkGetInstanceProcAddr); + + #undef NAZARA_VULKANRENDERER_GLOBAL_FUNCTION + + private: + static DynLib s_vulkanLib; + static VkResult s_lastErrorCode; + }; + } +} + +#include + +#endif // NAZARA_VULKANRENDERER_VKLOADER_HPP diff --git a/include/Nazara/VulkanRenderer/VkLoader.inl b/include/Nazara/VulkanRenderer/VkLoader.inl new file mode 100644 index 000000000..caad2bab3 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkLoader.inl @@ -0,0 +1,19 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// 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/VulkanRenderer/VkPhysicalDevice.hpp b/include/Nazara/VulkanRenderer/VkPhysicalDevice.hpp new file mode 100644 index 000000000..3caa8a179 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkPhysicalDevice.hpp @@ -0,0 +1,28 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VKPHYSICALDEVICE_HPP +#define NAZARA_VULKANRENDERER_VKPHYSICALDEVICE_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + struct PhysicalDevice + { + VkPhysicalDevice device; + VkPhysicalDeviceFeatures features; + VkPhysicalDeviceMemoryProperties memoryProperties; + VkPhysicalDeviceProperties properties; + std::vector queues; + }; + } +} + +#endif // NAZARA_VULKANRENDERER_VKPHYSICALDEVICE_HPP diff --git a/include/Nazara/VulkanRenderer/VkPipeline.hpp b/include/Nazara/VulkanRenderer/VkPipeline.hpp new file mode 100644 index 000000000..ec18dd416 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkPipeline.hpp @@ -0,0 +1,50 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VKPIPELINE_HPP +#define NAZARA_VULKANRENDERER_VKPIPELINE_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class Pipeline + { + public: + inline Pipeline(); + Pipeline(const Pipeline&) = delete; + Pipeline(Pipeline&&); + inline ~Pipeline(); + + inline bool CreateCompute(const DeviceHandle& device, const VkComputePipelineCreateInfo& createInfo, VkPipelineCache cache = VK_NULL_HANDLE, const VkAllocationCallbacks* allocator = nullptr); + inline bool CreateGraphics(const DeviceHandle& device, const VkGraphicsPipelineCreateInfo& createInfo, VkPipelineCache cache = VK_NULL_HANDLE, const VkAllocationCallbacks* allocator = nullptr); + inline void Destroy(); + + inline const DeviceHandle& GetDevice() const; + inline VkResult GetLastErrorCode() const; + + Pipeline& operator=(const Pipeline&) = delete; + Pipeline& operator=(Pipeline&&) = delete; + + inline operator VkPipeline() const; + + protected: + inline bool Create(const DeviceHandle& device, VkResult result, const VkAllocationCallbacks* allocator); + + DeviceHandle m_device; + VkAllocationCallbacks m_allocator; + VkPipeline m_handle; + mutable VkResult m_lastErrorCode; + }; + } +} + +#include + +#endif // NAZARA_VULKANRENDERER_VKPIPELINE_HPP diff --git a/include/Nazara/VulkanRenderer/VkPipeline.inl b/include/Nazara/VulkanRenderer/VkPipeline.inl new file mode 100644 index 000000000..42c758f46 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkPipeline.inl @@ -0,0 +1,86 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + namespace Vk + { + inline Pipeline::Pipeline() : + m_handle(VK_NULL_HANDLE) + { + } + + inline Pipeline::Pipeline(Pipeline&& object) : + m_device(std::move(object.m_device)), + m_allocator(object.m_allocator), + m_handle(object.m_handle), + m_lastErrorCode(object.m_lastErrorCode) + { + object.m_handle = VK_NULL_HANDLE; + } + + inline Pipeline::~Pipeline() + { + Destroy(); + } + + inline bool Pipeline::CreateCompute(const DeviceHandle& device, const VkComputePipelineCreateInfo& createInfo, VkPipelineCache cache, const VkAllocationCallbacks* allocator) + { + return Create(device, device->vkCreateComputePipelines(*device, cache, 1U, &createInfo, allocator, &m_handle), allocator); + } + + inline bool Pipeline::CreateGraphics(const DeviceHandle& device, const VkGraphicsPipelineCreateInfo& createInfo, VkPipelineCache cache, const VkAllocationCallbacks* allocator) + { + return Create(device, device->vkCreateGraphicsPipelines(*device, cache, 1U, &createInfo, allocator, &m_handle), allocator); + } + + inline void Pipeline::Destroy() + { + if (m_handle != VK_NULL_HANDLE) + { + m_device->vkDestroyPipeline(*m_device, m_handle, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); + m_handle = VK_NULL_HANDLE; + } + } + + inline const DeviceHandle& Pipeline::GetDevice() const + { + return m_device; + } + + inline VkResult Pipeline::GetLastErrorCode() const + { + return m_lastErrorCode; + } + + inline Pipeline::operator VkPipeline() const + { + return m_handle; + } + + inline bool Pipeline::Create(const DeviceHandle& device, VkResult result, const VkAllocationCallbacks* allocator) + { + m_device = device; + m_lastErrorCode = result; + 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; + } + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/VkPipelineCache.hpp b/include/Nazara/VulkanRenderer/VkPipelineCache.hpp new file mode 100644 index 000000000..cb60321b9 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkPipelineCache.hpp @@ -0,0 +1,39 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VKPIPELINECACHE_HPP +#define NAZARA_VULKANRENDERER_VKPIPELINECACHE_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class PipelineCache : public DeviceObject + { + friend DeviceObject; + + public: + PipelineCache() = default; + PipelineCache(const PipelineCache&) = delete; + PipelineCache(PipelineCache&&) = default; + ~PipelineCache() = default; + + PipelineCache& operator=(const PipelineCache&) = delete; + PipelineCache& operator=(PipelineCache&&) = delete; + + private: + static inline VkResult CreateHelper(const DeviceHandle& device, const VkPipelineCacheCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkPipelineCache* handle); + static inline void DestroyHelper(const DeviceHandle& device, VkPipelineCache handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_VULKANRENDERER_VKPIPELINECACHE_HPP diff --git a/include/Nazara/VulkanRenderer/VkPipelineCache.inl b/include/Nazara/VulkanRenderer/VkPipelineCache.inl new file mode 100644 index 000000000..d37f5c8c0 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkPipelineCache.inl @@ -0,0 +1,24 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + namespace Vk + { + inline VkResult PipelineCache::CreateHelper(const DeviceHandle& device, const VkPipelineCacheCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkPipelineCache* handle) + { + return device->vkCreatePipelineCache(*device, createInfo, allocator, handle); + } + + inline void PipelineCache::DestroyHelper(const DeviceHandle& device, VkPipelineCache handle, const VkAllocationCallbacks* allocator) + { + return device->vkDestroyPipelineCache(*device, handle, allocator); + } + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/VkPipelineLayout.hpp b/include/Nazara/VulkanRenderer/VkPipelineLayout.hpp new file mode 100644 index 000000000..4abb54e0a --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkPipelineLayout.hpp @@ -0,0 +1,39 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VKPIPELINELAYOUT_HPP +#define NAZARA_VULKANRENDERER_VKPIPELINELAYOUT_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class PipelineLayout : public DeviceObject + { + friend DeviceObject; + + public: + PipelineLayout() = default; + PipelineLayout(const PipelineLayout&) = delete; + PipelineLayout(PipelineLayout&&) = default; + ~PipelineLayout() = default; + + PipelineLayout& operator=(const PipelineLayout&) = delete; + PipelineLayout& operator=(PipelineLayout&&) = delete; + + private: + static inline VkResult CreateHelper(const DeviceHandle& device, const VkPipelineLayoutCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkPipelineLayout* handle); + static inline void DestroyHelper(const DeviceHandle& device, VkPipelineLayout handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_VULKANRENDERER_VKPIPELINELAYOUT_HPP diff --git a/include/Nazara/VulkanRenderer/VkPipelineLayout.inl b/include/Nazara/VulkanRenderer/VkPipelineLayout.inl new file mode 100644 index 000000000..22ceb988b --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkPipelineLayout.inl @@ -0,0 +1,24 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + namespace Vk + { + inline VkResult PipelineLayout::CreateHelper(const DeviceHandle& device, const VkPipelineLayoutCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkPipelineLayout* handle) + { + return device->vkCreatePipelineLayout(*device, createInfo, allocator, handle); + } + + inline void PipelineLayout::DestroyHelper(const DeviceHandle& device, VkPipelineLayout handle, const VkAllocationCallbacks* allocator) + { + return device->vkDestroyPipelineLayout(*device, handle, allocator); + } + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/VkQueue.hpp b/include/Nazara/VulkanRenderer/VkQueue.hpp new file mode 100644 index 000000000..59cf74e17 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkQueue.hpp @@ -0,0 +1,53 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VKQUEUE_HPP +#define NAZARA_VULKANRENDERER_VKQUEUE_HPP + +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + class Queue + { + public: + inline Queue(); + inline Queue(const DeviceHandle& device, VkQueue queue); + inline Queue(const Queue& queue); + inline Queue(Queue&& queue); + inline ~Queue() = default; + + inline const DeviceHandle& GetDevice() const; + inline VkResult GetLastErrorCode() const; + + inline bool Present(const VkPresentInfoKHR& presentInfo) const; + inline bool Present(VkSwapchainKHR swapchain, UInt32 imageIndex, VkSemaphore waitSemaphore = VK_NULL_HANDLE) const; + + inline bool Submit(const VkSubmitInfo& submit, VkFence fence = VK_NULL_HANDLE) const; + inline bool Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence fence = VK_NULL_HANDLE) const; + + inline bool WaitIdle() const; + + Queue& operator=(const Queue& queue) = delete; + inline Queue& operator=(Queue&&); + + inline operator VkQueue(); + + protected: + DeviceHandle m_device; + VkQueue m_handle; + mutable VkResult m_lastErrorCode; + }; + } +} + +#include + +#endif // NAZARA_VULKANRENDERER_VKQUEUE_HPP diff --git a/include/Nazara/VulkanRenderer/VkQueue.inl b/include/Nazara/VulkanRenderer/VkQueue.inl new file mode 100644 index 000000000..62b0c7984 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkQueue.inl @@ -0,0 +1,115 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + inline Queue::Queue() : + Queue(DeviceHandle(), VK_NULL_HANDLE) + { + } + + inline Queue::Queue(const DeviceHandle& 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 const DeviceHandle& Queue::GetDevice() const + { + return m_device; + } + + inline VkResult Queue::GetLastErrorCode() const + { + return m_lastErrorCode; + } + + inline bool Queue::Present(const VkPresentInfoKHR& presentInfo) const + { + 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) const + { + 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) const + { + return Submit(1, &submit, fence); + } + + inline bool Queue::Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence fence) const + { + m_lastErrorCode = m_device->vkQueueSubmit(m_handle, submitCount, submits, fence); + if (m_lastErrorCode != VkResult::VK_SUCCESS) + return false; + + return true; + } + + inline bool Queue::WaitIdle() const + { + m_lastErrorCode = m_device->vkQueueWaitIdle(m_handle); + if (m_lastErrorCode != VkResult::VK_SUCCESS) + return false; + + return true; + } + + inline Queue& Queue::operator=(Queue&& queue) + { + m_device = std::move(queue.m_device); + m_handle = queue.m_handle; + m_lastErrorCode = queue.m_lastErrorCode; + + return *this; + } + + inline Queue::operator VkQueue() + { + return m_handle; + } + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/VkRenderPass.hpp b/include/Nazara/VulkanRenderer/VkRenderPass.hpp new file mode 100644 index 000000000..2ea70a316 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkRenderPass.hpp @@ -0,0 +1,39 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VKRENDERPASS_HPP +#define NAZARA_VULKANRENDERER_VKRENDERPASS_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class RenderPass : public DeviceObject + { + friend DeviceObject; + + public: + RenderPass() = default; + RenderPass(const RenderPass&) = delete; + RenderPass(RenderPass&&) = default; + ~RenderPass() = default; + + RenderPass& operator=(const RenderPass&) = delete; + RenderPass& operator=(RenderPass&&) = delete; + + private: + static inline VkResult CreateHelper(const DeviceHandle& device, const VkRenderPassCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkRenderPass* handle); + static inline void DestroyHelper(const DeviceHandle& device, VkRenderPass handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_VULKANRENDERER_VKRENDERPASS_HPP diff --git a/include/Nazara/VulkanRenderer/VkRenderPass.inl b/include/Nazara/VulkanRenderer/VkRenderPass.inl new file mode 100644 index 000000000..7fde52a75 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkRenderPass.inl @@ -0,0 +1,24 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + namespace Vk + { + inline VkResult RenderPass::CreateHelper(const DeviceHandle& device, const VkRenderPassCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkRenderPass* handle) + { + return device->vkCreateRenderPass(*device, createInfo, allocator, handle); + } + + inline void RenderPass::DestroyHelper(const DeviceHandle& device, VkRenderPass handle, const VkAllocationCallbacks* allocator) + { + return device->vkDestroyRenderPass(*device, handle, allocator); + } + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/VkSemaphore.hpp b/include/Nazara/VulkanRenderer/VkSemaphore.hpp new file mode 100644 index 000000000..0f5e09d59 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkSemaphore.hpp @@ -0,0 +1,42 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VKSEMAPHORE_HPP +#define NAZARA_VULKANRENDERER_VKSEMAPHORE_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class Semaphore : public DeviceObject + { + friend DeviceObject; + + public: + Semaphore() = default; + Semaphore(const Semaphore&) = delete; + Semaphore(Semaphore&&) = default; + ~Semaphore() = default; + + using DeviceObject::Create; + inline bool Create(const DeviceHandle& device, VkSemaphoreCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + + Semaphore& operator=(const Semaphore&) = delete; + Semaphore& operator=(Semaphore&&) = delete; + + private: + static inline VkResult CreateHelper(const DeviceHandle& device, const VkSemaphoreCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSemaphore* handle); + static inline void DestroyHelper(const DeviceHandle& device, VkSemaphore handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_VULKANRENDERER_VKSEMAPHORE_HPP diff --git a/include/Nazara/VulkanRenderer/VkSemaphore.inl b/include/Nazara/VulkanRenderer/VkSemaphore.inl new file mode 100644 index 000000000..7220cfeb9 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkSemaphore.inl @@ -0,0 +1,36 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + namespace Vk + { + inline bool Semaphore::Create(const DeviceHandle& device, VkSemaphoreCreateFlags flags, const VkAllocationCallbacks* allocator) + { + VkSemaphoreCreateInfo createInfo = + { + VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO, + nullptr, + flags + }; + + return Create(device, createInfo, allocator); + } + + inline VkResult Semaphore::CreateHelper(const DeviceHandle& device, const VkSemaphoreCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSemaphore* handle) + { + return device->vkCreateSemaphore(*device, createInfo, allocator, handle); + } + + inline void Semaphore::DestroyHelper(const DeviceHandle& device, VkSemaphore handle, const VkAllocationCallbacks* allocator) + { + return device->vkDestroySemaphore(*device, handle, allocator); + } + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/VkShaderModule.hpp b/include/Nazara/VulkanRenderer/VkShaderModule.hpp new file mode 100644 index 000000000..e8b5f8fd1 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkShaderModule.hpp @@ -0,0 +1,42 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VKSHADERMODULE_HPP +#define NAZARA_VULKANRENDERER_VKSHADERMODULE_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class ShaderModule : public DeviceObject + { + friend DeviceObject; + + public: + ShaderModule() = default; + ShaderModule(const ShaderModule&) = delete; + ShaderModule(ShaderModule&&) = default; + ~ShaderModule() = default; + + using DeviceObject::Create; + inline bool Create(const DeviceHandle& device, const UInt32* code, std::size_t size, VkShaderModuleCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + + ShaderModule& operator=(const ShaderModule&) = delete; + ShaderModule& operator=(ShaderModule&&) = delete; + + private: + static inline VkResult CreateHelper(const DeviceHandle& device, const VkShaderModuleCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkShaderModule* handle); + static inline void DestroyHelper(const DeviceHandle& device, VkShaderModule handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_VULKANRENDERER_VKSHADERMODULE_HPP diff --git a/include/Nazara/VulkanRenderer/VkShaderModule.inl b/include/Nazara/VulkanRenderer/VkShaderModule.inl new file mode 100644 index 000000000..81f5177fc --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkShaderModule.inl @@ -0,0 +1,38 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + namespace Vk + { + inline bool ShaderModule::Create(const DeviceHandle& device, const UInt32* code, std::size_t size, VkShaderModuleCreateFlags flags, const VkAllocationCallbacks* allocator) + { + VkShaderModuleCreateInfo createInfo = + { + VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO, + nullptr, + flags, + size, + code + }; + + return Create(device, createInfo, allocator); + } + + inline VkResult ShaderModule::CreateHelper(const DeviceHandle& device, const VkShaderModuleCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkShaderModule* handle) + { + return device->vkCreateShaderModule(*device, createInfo, allocator, handle); + } + + inline void ShaderModule::DestroyHelper(const DeviceHandle& device, VkShaderModule handle, const VkAllocationCallbacks* allocator) + { + return device->vkDestroyShaderModule(*device, handle, allocator); + } + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/VkSurface.hpp b/include/Nazara/VulkanRenderer/VkSurface.hpp new file mode 100644 index 000000000..1f4db956f --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkSurface.hpp @@ -0,0 +1,94 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VKSURFACE_HPP +#define NAZARA_VULKANRENDERER_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) const; + bool GetFormats(VkPhysicalDevice physicalDevice, std::vector* surfaceFormats) const; + bool GetPresentModes(VkPhysicalDevice physicalDevice, std::vector* presentModes) const; + bool GetSupportPresentation(VkPhysicalDevice physicalDevice, UInt32 queueFamilyIndex, bool* supported) const; + + inline bool IsSupported() const; + + inline VkResult GetLastErrorCode() const; + + Surface& operator=(const Surface&) = delete; + Surface& operator=(Surface&&) = delete; + + inline operator VkSurfaceKHR() const; + + private: + inline bool Create(const VkAllocationCallbacks* allocator); + + Instance& m_instance; + VkAllocationCallbacks m_allocator; + VkSurfaceKHR m_surface; + mutable VkResult m_lastErrorCode; + }; + } +} + +#include + +#endif // NAZARA_VULKANRENDERER_VKSURFACE_HPP diff --git a/include/Nazara/VulkanRenderer/VkSurface.inl b/include/Nazara/VulkanRenderer/VkSurface.inl new file mode 100644 index 000000000..efec9a34c --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkSurface.inl @@ -0,0 +1,314 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// 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); + m_surface = VK_NULL_HANDLE; + } + } + + inline VkResult Surface::GetLastErrorCode() const + { + return m_lastErrorCode; + } + + inline bool Surface::GetCapabilities(VkPhysicalDevice physicalDevice, VkSurfaceCapabilitiesKHR* surfaceCapabilities) const + { + 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) const + { + // 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) const + { + // 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) const + { + 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() const + { + 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/VulkanRenderer/VkSwapchain.hpp b/include/Nazara/VulkanRenderer/VkSwapchain.hpp new file mode 100644 index 000000000..b896c6c58 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkSwapchain.hpp @@ -0,0 +1,60 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VKSWAPCHAIN_HPP +#define NAZARA_VULKANRENDERER_VKSWAPCHAIN_HPP + +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + class Swapchain : public DeviceObject + { + friend DeviceObject; + + public: + struct Buffer; + + Swapchain() = default; + Swapchain(const Swapchain&) = delete; + Swapchain(Swapchain&&) = default; + ~Swapchain() = default; + + inline bool AcquireNextImage(Nz::UInt64 timeout, VkSemaphore semaphore, VkFence fence, UInt32* imageIndex) const; + + inline bool Create(const DeviceHandle& device, const VkSwapchainCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); + + inline const Buffer& GetBuffer(UInt32 index) const; + inline const std::vector& GetBuffers() const; + inline UInt32 GetBufferCount() const; + + inline bool IsSupported() const; + + Swapchain& operator=(const Swapchain&) = delete; + Swapchain& operator=(Swapchain&&) = delete; + + struct Buffer + { + VkImage image; + ImageView view; + }; + + private: + static inline VkResult CreateHelper(const DeviceHandle& device, const VkSwapchainCreateInfoKHR* createInfo, const VkAllocationCallbacks* allocator, VkSwapchainKHR* handle); + static inline void DestroyHelper(const DeviceHandle& device, VkSwapchainKHR handle, const VkAllocationCallbacks* allocator); + + std::vector m_buffers; + }; + } +} + +#include + +#endif // NAZARA_VULKANRENDERER_VKSWAPCHAIN_HPP diff --git a/include/Nazara/VulkanRenderer/VkSwapchain.inl b/include/Nazara/VulkanRenderer/VkSwapchain.inl new file mode 100644 index 000000000..a8e0ead36 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkSwapchain.inl @@ -0,0 +1,121 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + inline bool Swapchain::AcquireNextImage(Nz::UInt64 timeout, VkSemaphore semaphore, VkFence fence, UInt32* imageIndex) const + { + 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 DeviceHandle& device, const VkSwapchainCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) + { + if (!DeviceObject::Create(device, 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; + } + + std::vector images(imageCount); + m_lastErrorCode = m_device->vkGetSwapchainImagesKHR(*m_device, m_handle, &imageCount, images.data()); + if (m_lastErrorCode != VkResult::VK_SUCCESS) + { + NazaraError("Failed to query swapchain images"); + return false; + } + + m_buffers.resize(imageCount); + for (UInt32 i = 0; i < imageCount; ++i) + { + m_buffers[i].image = images[i]; + + VkImageViewCreateInfo imageViewCreateInfo = { + VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + 0, // VkImageViewCreateFlags flags; + m_buffers[i].image, // VkImage image; + VK_IMAGE_VIEW_TYPE_2D, // VkImageViewType viewType; + createInfo.imageFormat, // VkFormat format; + { // VkComponentMapping components; + VK_COMPONENT_SWIZZLE_R, // VkComponentSwizzle .r; + VK_COMPONENT_SWIZZLE_G, // VkComponentSwizzle .g; + VK_COMPONENT_SWIZZLE_B, // VkComponentSwizzle .b; + VK_COMPONENT_SWIZZLE_A // VkComponentSwizzle .a; + }, + { // VkImageSubresourceRange subresourceRange; + VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags .aspectMask; + 0, // uint32_t .baseMipLevel; + 1, // uint32_t .levelCount; + 0, // uint32_t .baseArrayLayer; + 1 // uint32_t .layerCount; + } + }; + + if (!m_buffers[i].view.Create(m_device, imageViewCreateInfo)) + { + NazaraError("Failed to create image view for image #" + String::Number(i)); + return false; + } + } + + return true; + } + + inline const Swapchain::Buffer& Swapchain::GetBuffer(UInt32 index) const + { + return m_buffers[index]; + } + + inline const std::vector& Swapchain::GetBuffers() const + { + return m_buffers; + } + + inline UInt32 Swapchain::GetBufferCount() const + { + return static_cast(m_buffers.size()); + } + + inline bool Swapchain::IsSupported() const + { + if (!m_device->IsExtensionLoaded("VK_KHR_swapchain")) + return false; + + return true; + } + + inline VkResult Swapchain::CreateHelper(const DeviceHandle& device, const VkSwapchainCreateInfoKHR* createInfo, const VkAllocationCallbacks* allocator, VkSwapchainKHR* handle) + { + return device->vkCreateSwapchainKHR(*device, createInfo, allocator, handle); + } + + inline void Swapchain::DestroyHelper(const DeviceHandle& device, VkSwapchainKHR handle, const VkAllocationCallbacks* allocator) + { + return device->vkDestroySwapchainKHR(*device, handle, allocator); + } + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/Vulkan.hpp b/include/Nazara/VulkanRenderer/Vulkan.hpp new file mode 100644 index 000000000..619774e0f --- /dev/null +++ b/include/Nazara/VulkanRenderer/Vulkan.hpp @@ -0,0 +1,55 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// 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 +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_VULKANRENDERER_API Vulkan + { + public: + Vulkan() = delete; + ~Vulkan() = delete; + + static Vk::DeviceHandle CreateDevice(VkPhysicalDevice gpu, const Vk::Surface& surface, UInt32* presentableFamilyQueue); + + static Vk::Instance& GetInstance(); + + static const std::vector& GetPhysicalDevices(); + static const Vk::PhysicalDevice& GetPhysicalDeviceInfo(VkPhysicalDevice physDevice); + + static bool Initialize(); + + static bool IsInitialized(); + + static Vk::DeviceHandle SelectDevice(VkPhysicalDevice gpu, const Vk::Surface& surface, UInt32* presentableFamilyQueue); + + static void SetParameters(const ParameterList& parameters); + + static void Uninitialize(); + + private: + static std::list s_devices; + static std::vector s_physDevices; + static Vk::Instance s_instance; + static ParameterList s_initializationParameters; + static unsigned int s_moduleReferenceCounter; + }; +} + +#endif // NAZARA_VULKAN_HPP diff --git a/include/Nazara/VulkanRenderer/VulkanRenderer.hpp b/include/Nazara/VulkanRenderer/VulkanRenderer.hpp new file mode 100644 index 000000000..b77cb6935 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanRenderer.hpp @@ -0,0 +1,42 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_HPP +#define NAZARA_VULKANRENDERER_HPP + +#include +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_VULKANRENDERER_API VulkanRenderer : public RendererImpl + { + public: + VulkanRenderer() = default; + ~VulkanRenderer() = default; + + bool IsBetterThan(const RendererImpl* other) const override; + + RenderAPI QueryAPI() const override; + String QueryAPIString() const override; + UInt32 QueryAPIVersion() const override; + std::vector QueryRenderDevices() const override; + + bool Prepare(const ParameterList& parameters) override; + + static constexpr UInt32 APIVersion = VK_API_VERSION_1_0; + + private: + Vk::Instance m_instance; + std::vector m_physDevices; + UInt32 m_apiVersion; + }; +} + +#endif // NAZARA_VULKANRENDERER_HPP diff --git a/src/Nazara/Renderer/Context.cpp b/src/Nazara/Renderer/Context.cpp deleted file mode 100644 index 69919d094..000000000 --- a/src/Nazara/Renderer/Context.cpp +++ /dev/null @@ -1,376 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(NAZARA_PLATFORM_WINDOWS) - #include -#elif defined(NAZARA_PLATFORM_GLX) - #include - #define CALLBACK -#else - #error Lack of implementation: Context -#endif - -#include - -namespace Nz -{ - namespace - { - thread_local const Context* s_currentContext = nullptr; - thread_local const Context* s_threadContext = nullptr; - - void CALLBACK DebugCallback(unsigned int source, unsigned int type, unsigned int id, unsigned int severity, int length, const char* message, const void* userParam) - { - NazaraUnused(length); - - StringStream ss; - ss << "OpenGL debug message (ID: 0x" << String::Number(id, 16) << "):\n"; - ss << "Sent by context: " << userParam; - ss << "\n-Source: "; - switch (source) - { - case GL_DEBUG_SOURCE_API: - ss << "OpenGL API"; - break; - - case GL_DEBUG_SOURCE_WINDOW_SYSTEM: - ss << "Operating system"; - break; - - case GL_DEBUG_SOURCE_SHADER_COMPILER: - ss << "Shader compiler"; - break; - - case GL_DEBUG_SOURCE_THIRD_PARTY: - ss << "Third party"; - break; - - case GL_DEBUG_SOURCE_APPLICATION: - ss << "Application"; - break; - - case GL_DEBUG_SOURCE_OTHER: - ss << "Other"; - break; - - default: - // Peut être rajouté par une extension - ss << "Unknown"; - break; - } - ss << '\n'; - - ss << "-Type: "; - switch (type) - { - case GL_DEBUG_TYPE_ERROR: - ss << "Error"; - break; - - case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: - ss << "Deprecated behavior"; - break; - - case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: - ss << "Undefined behavior"; - break; - - case GL_DEBUG_TYPE_PORTABILITY: - ss << "Portability"; - break; - - case GL_DEBUG_TYPE_PERFORMANCE: - ss << "Performance"; - break; - - case GL_DEBUG_TYPE_OTHER: - ss << "Other"; - break; - - default: - // Peut être rajouté par une extension - ss << "Unknown"; - break; - } - ss << '\n'; - - ss << "-Severity: "; - switch (severity) - { - case GL_DEBUG_SEVERITY_HIGH: - ss << "High"; - break; - - case GL_DEBUG_SEVERITY_MEDIUM: - ss << "Medium"; - break; - - case GL_DEBUG_SEVERITY_LOW: - ss << "Low"; - break; - - default: - // Peut être rajouté par une extension - ss << "Unknown"; - break; - } - ss << '\n'; - - ss << "Message: " << message << '\n'; - - NazaraNotice(ss); - } - } - - Context::~Context() - { - OnContextRelease(this); - - Destroy(); - } - - bool Context::Create(const ContextParameters& parameters) - { - Destroy(); - - m_parameters = parameters; - if (m_parameters.shared && !m_parameters.shareContext) - m_parameters.shareContext = s_reference.get(); - - std::unique_ptr impl(new ContextImpl); - if (!impl->Create(m_parameters)) - { - NazaraError("Failed to create context implementation"); - return false; - } - - m_impl = impl.release(); - - CallOnExit onExit([this] () { Destroy(); }); - - if (!SetActive(true)) - { - NazaraError("Failed to activate context"); - return false; - } - - if (m_parameters.antialiasingLevel > 0) - glEnable(GL_MULTISAMPLE); - - if (m_parameters.debugMode && OpenGL::IsSupported(OpenGLExtension_DebugOutput)) - { - glDebugMessageCallback(&DebugCallback, this); - - #ifdef NAZARA_DEBUG - glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); - #endif - } - - onExit.Reset(); - - return true; - } - - void Context::Destroy() - { - if (m_impl) - { - OnContextDestroy(this); - - OpenGL::OnContextDestruction(this); - SetActive(false); - - m_impl->Destroy(); - delete m_impl; - m_impl = nullptr; - } - } - - void Context::EnableVerticalSync(bool enabled) - { - #ifdef NAZARA_RENDERER_SAFE - if (!m_impl) - { - NazaraError("No context has been created"); - return; - } - #endif - - m_impl->EnableVerticalSync(enabled); - } - - const ContextParameters& Context::GetParameters() const - { - #ifdef NAZARA_RENDERER_SAFE - if (!m_impl) - NazaraError("No context has been created"); - #endif - - return m_parameters; - } - - bool Context::IsActive() const - { - #ifdef NAZARA_RENDERER_SAFE - if (!m_impl) - { - NazaraError("No context has been created"); - return false; - } - #endif - - return s_currentContext == this; - } - - bool Context::SetActive(bool active) const - { - #ifdef NAZARA_RENDERER_SAFE - if (!m_impl) - { - NazaraError("No context has been created"); - return false; - } - #endif - - // Si le contexte est déjà activé/désactivé - if ((s_currentContext == this) == active) - return true; - - if (active) - { - if (!m_impl->Activate()) - return false; - - s_currentContext = this; - } - else - { - if (!ContextImpl::Desactivate()) - return false; - - s_currentContext = nullptr; - } - - OpenGL::OnContextChanged(s_currentContext); - - return true; - } - - void Context::SwapBuffers() - { - #ifdef NAZARA_RENDERER_SAFE - if (!m_impl) - { - NazaraError("No context has been created"); - return; - } - - if (!m_parameters.doubleBuffered) - { - NazaraError("Context is not double buffered"); - return; - } - #endif - - m_impl->SwapBuffers(); - } - - bool Context::EnsureContext() - { - if (!s_currentContext) - { - if (!s_threadContext) - { - std::unique_ptr context(new Context); - if (!context->Create()) - { - NazaraError("Failed to create context"); - return false; - } - - s_threadContext = context.get(); - - s_contexts.emplace_back(std::move(context)); - } - - if (!s_threadContext->SetActive(true)) - { - NazaraError("Failed to active thread context"); - return false; - } - } - - return true; - } - - const Context* Context::GetCurrent() - { - return s_currentContext; - } - - const Context* Context::GetReference() - { - return s_reference.get(); - } - - const Context* Context::GetThreadContext() - { - EnsureContext(); - - return s_threadContext; - } - - bool Context::Initialize() - { - if (!ContextLibrary::Initialize()) - { - NazaraError("Failed to initialise library"); - return false; - } - - ContextParameters parameters; - parameters.shared = false; // Difficile de partager le contexte de référence avec lui-même - - std::unique_ptr reference(new Context); - if (!reference->Create(parameters)) - { - NazaraError("Failed to create reference context"); - return false; - } - - // Le contexte de référence doit rester désactivé pour le partage - if (!reference->SetActive(false)) - { - NazaraError("Failed to desactive reference context"); - return false; - } - - s_reference = std::move(reference); - - // Le contexte de référence est partagé par défaut avec les autres contextes - ContextParameters::defaultShareContext = s_reference.get(); - return true; - } - - void Context::Uninitialize() - { - ContextLibrary::Uninitialize(); - s_contexts.clear(); // On supprime tous les contextes créés - s_reference.reset(); - } - - std::unique_ptr Context::s_reference; - std::vector> Context::s_contexts; - ContextLibrary::LibraryMap Context::s_library; -} diff --git a/src/Nazara/Renderer/ContextParameters.cpp b/src/Nazara/Renderer/ContextParameters.cpp deleted file mode 100644 index 9f85bc662..000000000 --- a/src/Nazara/Renderer/ContextParameters.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include - -namespace Nz -{ - // Version majeure d'OpenGL, initialisé par OpenGL::Initialize() - UInt8 ContextParameters::defaultMajorVersion; - - // Version majeure d'OpenGL, initialisé par OpenGL::Initialize() - UInt8 ContextParameters::defaultMinorVersion; - - // Contexte de partage par défaut, initialisé par OpenGL::Initialize() - const Context* ContextParameters::defaultShareContext = nullptr; - - // Si possible, garder la compatibilité avec les fonctionnalités dépréciées - bool ContextParameters::defaultCompatibilityProfile = false; - - // Mode debug d'OpenGL par défaut - #if NAZARA_RENDERER_OPENGL_DEBUG || defined(NAZARA_DEBUG) - bool ContextParameters::defaultDebugMode = true; - #else - bool ContextParameters::defaultDebugMode = false; - #endif - - // Active le double-buffering sur les contextes - bool ContextParameters::defaultDoubleBuffered = false; - - // Active le partage des ressources entre contextes (Via le defaultShareContext) - bool ContextParameters::defaultShared = true; -} diff --git a/src/Nazara/Renderer/DebugDrawer.cpp b/src/Nazara/Renderer/DebugDrawer.cpp deleted file mode 100644 index 9f06c880f..000000000 --- a/src/Nazara/Renderer/DebugDrawer.cpp +++ /dev/null @@ -1,741 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -///TODO: Améliorer - -namespace Nz -{ - namespace - { - static Shader* s_shader = nullptr; - static Color s_primaryColor; - static Color s_secondaryColor; - static RenderStates s_renderStates; - static VertexBuffer s_vertexBuffer; - static bool s_initialized = false; - static int s_colorLocation = -1; - } - - void DebugDrawer::Draw(const BoundingVolumef& volume) - { - if (!Initialize()) - { - NazaraError("Failed to initialize Debug Drawer"); - return; - } - - if (!volume.IsFinite()) - return; - - Color oldPrimaryColor = s_primaryColor; - - Draw(volume.aabb); - - s_primaryColor = s_secondaryColor; - Draw(volume.obb); - - s_primaryColor = oldPrimaryColor; - } - - void DebugDrawer::Draw(const Boxi& box) - { - Draw(Boxf(box)); - } - - void DebugDrawer::Draw(const Boxf& box) - { - if (!Initialize()) - { - NazaraError("Failed to initialize Debug Drawer"); - return; - } - - BufferMapper mapper(s_vertexBuffer, BufferAccess_DiscardAndWrite, 0, 24); - VertexStruct_XYZ* vertex = static_cast(mapper.GetPointer()); - - Vector3f max, min; - max = box.GetMaximum(); - min = box.GetMinimum(); - - vertex->position.Set(min.x, min.y, min.z); - vertex++; - vertex->position.Set(max.x, min.y, min.z); - vertex++; - - vertex->position.Set(min.x, min.y, min.z); - vertex++; - vertex->position.Set(min.x, max.y, min.z); - vertex++; - - vertex->position.Set(min.x, min.y, min.z); - vertex++; - vertex->position.Set(min.x, min.y, max.z); - vertex++; - - vertex->position.Set(max.x, max.y, max.z); - vertex++; - vertex->position.Set(min.x, max.y, max.z); - vertex++; - - vertex->position.Set(max.x, max.y, max.z); - vertex++; - vertex->position.Set(max.x, min.y, max.z); - vertex++; - - vertex->position.Set(max.x, max.y, max.z); - vertex++; - vertex->position.Set(max.x, max.y, min.z); - vertex++; - - vertex->position.Set(min.x, min.y, max.z); - vertex++; - vertex->position.Set(max.x, min.y, max.z); - vertex++; - - vertex->position.Set(min.x, min.y, max.z); - vertex++; - vertex->position.Set(min.x, max.y, max.z); - vertex++; - - vertex->position.Set(min.x, max.y, min.z); - vertex++; - vertex->position.Set(max.x, max.y, min.z); - vertex++; - - vertex->position.Set(min.x, max.y, min.z); - vertex++; - vertex->position.Set(min.x, max.y, max.z); - vertex++; - - vertex->position.Set(max.x, min.y, min.z); - vertex++; - vertex->position.Set(max.x, max.y, min.z); - vertex++; - - vertex->position.Set(max.x, min.y, min.z); - vertex++; - vertex->position.Set(max.x, min.y, max.z); - vertex++; - - mapper.Unmap(); - - Renderer::SetRenderStates(s_renderStates); - Renderer::SetShader(s_shader); - Renderer::SetVertexBuffer(&s_vertexBuffer); - - s_shader->SendColor(s_colorLocation, s_primaryColor); - - Renderer::DrawPrimitives(PrimitiveMode_LineList, 0, 24); - } - - void DebugDrawer::Draw(const Boxui& box) - { - Draw(Boxf(box)); - } - - void DebugDrawer::Draw(const Frustumf& frustum) - { - if (!Initialize()) - { - NazaraError("Failed to initialize Debug Drawer"); - return; - } - - BufferMapper mapper(s_vertexBuffer, BufferAccess_DiscardAndWrite, 0, 24); - VertexStruct_XYZ* vertex = static_cast(mapper.GetPointer()); - - vertex->position.Set(frustum.GetCorner(BoxCorner_NearLeftBottom)); - vertex++; - vertex->position.Set(frustum.GetCorner(BoxCorner_NearRightBottom)); - vertex++; - - vertex->position.Set(frustum.GetCorner(BoxCorner_NearLeftBottom)); - vertex++; - vertex->position.Set(frustum.GetCorner(BoxCorner_NearLeftTop)); - vertex++; - - vertex->position.Set(frustum.GetCorner(BoxCorner_NearLeftBottom)); - vertex++; - vertex->position.Set(frustum.GetCorner(BoxCorner_FarLeftBottom)); - vertex++; - - vertex->position.Set(frustum.GetCorner(BoxCorner_FarRightTop)); - vertex++; - vertex->position.Set(frustum.GetCorner(BoxCorner_FarLeftTop)); - vertex++; - - vertex->position.Set(frustum.GetCorner(BoxCorner_FarRightTop)); - vertex++; - vertex->position.Set(frustum.GetCorner(BoxCorner_FarRightBottom)); - vertex++; - - vertex->position.Set(frustum.GetCorner(BoxCorner_FarRightTop)); - vertex++; - vertex->position.Set(frustum.GetCorner(BoxCorner_NearRightTop)); - vertex++; - - vertex->position.Set(frustum.GetCorner(BoxCorner_FarLeftBottom)); - vertex++; - vertex->position.Set(frustum.GetCorner(BoxCorner_FarRightBottom)); - vertex++; - - vertex->position.Set(frustum.GetCorner(BoxCorner_FarLeftBottom)); - vertex++; - vertex->position.Set(frustum.GetCorner(BoxCorner_FarLeftTop)); - vertex++; - - vertex->position.Set(frustum.GetCorner(BoxCorner_NearLeftTop)); - vertex++; - vertex->position.Set(frustum.GetCorner(BoxCorner_NearRightTop)); - vertex++; - - vertex->position.Set(frustum.GetCorner(BoxCorner_NearLeftTop)); - vertex++; - vertex->position.Set(frustum.GetCorner(BoxCorner_FarLeftTop)); - vertex++; - - vertex->position.Set(frustum.GetCorner(BoxCorner_NearRightBottom)); - vertex++; - vertex->position.Set(frustum.GetCorner(BoxCorner_NearRightTop)); - vertex++; - - vertex->position.Set(frustum.GetCorner(BoxCorner_NearRightBottom)); - vertex++; - vertex->position.Set(frustum.GetCorner(BoxCorner_FarRightBottom)); - vertex++; - - mapper.Unmap(); - - Renderer::SetRenderStates(s_renderStates); - Renderer::SetShader(s_shader); - Renderer::SetVertexBuffer(&s_vertexBuffer); - - s_shader->SendColor(s_colorLocation, s_primaryColor); - - Renderer::DrawPrimitives(PrimitiveMode_LineList, 0, 24); - } - - void DebugDrawer::Draw(const OrientedBoxf& orientedBox) - { - if (!Initialize()) - { - NazaraError("Failed to initialize Debug Drawer"); - return; - } - - BufferMapper mapper(s_vertexBuffer, BufferAccess_DiscardAndWrite, 0, 24); - VertexStruct_XYZ* vertex = static_cast(mapper.GetPointer()); - - vertex->position.Set(orientedBox.GetCorner(BoxCorner_NearLeftBottom)); - vertex++; - vertex->position.Set(orientedBox.GetCorner(BoxCorner_NearRightBottom)); - vertex++; - - vertex->position.Set(orientedBox.GetCorner(BoxCorner_NearLeftBottom)); - vertex++; - vertex->position.Set(orientedBox.GetCorner(BoxCorner_NearLeftTop)); - vertex++; - - vertex->position.Set(orientedBox.GetCorner(BoxCorner_NearLeftBottom)); - vertex++; - vertex->position.Set(orientedBox.GetCorner(BoxCorner_FarLeftBottom)); - vertex++; - - vertex->position.Set(orientedBox.GetCorner(BoxCorner_FarRightTop)); - vertex++; - vertex->position.Set(orientedBox.GetCorner(BoxCorner_FarLeftTop)); - vertex++; - - vertex->position.Set(orientedBox.GetCorner(BoxCorner_FarRightTop)); - vertex++; - vertex->position.Set(orientedBox.GetCorner(BoxCorner_FarRightBottom)); - vertex++; - - vertex->position.Set(orientedBox.GetCorner(BoxCorner_FarRightTop)); - vertex++; - vertex->position.Set(orientedBox.GetCorner(BoxCorner_NearRightTop)); - vertex++; - - vertex->position.Set(orientedBox.GetCorner(BoxCorner_FarLeftBottom)); - vertex++; - vertex->position.Set(orientedBox.GetCorner(BoxCorner_FarRightBottom)); - vertex++; - - vertex->position.Set(orientedBox.GetCorner(BoxCorner_FarLeftBottom)); - vertex++; - vertex->position.Set(orientedBox.GetCorner(BoxCorner_FarLeftTop)); - vertex++; - - vertex->position.Set(orientedBox.GetCorner(BoxCorner_NearLeftTop)); - vertex++; - vertex->position.Set(orientedBox.GetCorner(BoxCorner_NearRightTop)); - vertex++; - - vertex->position.Set(orientedBox.GetCorner(BoxCorner_NearLeftTop)); - vertex++; - vertex->position.Set(orientedBox.GetCorner(BoxCorner_FarLeftTop)); - vertex++; - - vertex->position.Set(orientedBox.GetCorner(BoxCorner_NearRightBottom)); - vertex++; - vertex->position.Set(orientedBox.GetCorner(BoxCorner_NearRightTop)); - vertex++; - - vertex->position.Set(orientedBox.GetCorner(BoxCorner_NearRightBottom)); - vertex++; - vertex->position.Set(orientedBox.GetCorner(BoxCorner_FarRightBottom)); - vertex++; - - mapper.Unmap(); - - Renderer::SetRenderStates(s_renderStates); - Renderer::SetShader(s_shader); - Renderer::SetVertexBuffer(&s_vertexBuffer); - - s_shader->SendColor(s_colorLocation, s_primaryColor); - - Renderer::DrawPrimitives(PrimitiveMode_LineList, 0, 24); - } - - void DebugDrawer::Draw(const Skeleton* skeleton) - { - if (!Initialize()) - { - NazaraError("Failed to initialize Debug Drawer"); - return; - } - - unsigned int jointCount = skeleton->GetJointCount(); - if (s_vertexBuffer.GetVertexCount() < jointCount*2) - { - NazaraError("Debug buffer not large enougth to draw object"); - return; - } - - BufferMapper mapper(s_vertexBuffer, BufferAccess_DiscardAndWrite, 0, jointCount*2); - VertexStruct_XYZ* vertex = static_cast(mapper.GetPointer()); - - unsigned int vertexCount = 0; - for (unsigned int i = 0; i < jointCount; ++i) - { - const Node* joint = skeleton->GetJoint(i); - const Node* parent = joint->GetParent(); - if (parent) - { - vertex->position = joint->GetPosition(); - vertex++; - - vertex->position = parent->GetPosition(); - vertex++; - - vertexCount += 2; - } - } - - mapper.Unmap(); - - if (vertexCount > 0) - { - Renderer::SetRenderStates(s_renderStates); - Renderer::SetShader(s_shader); - Renderer::SetVertexBuffer(&s_vertexBuffer); - - s_shader->SendColor(s_colorLocation, s_primaryColor); - Renderer::DrawPrimitives(PrimitiveMode_LineList, 0, vertexCount); - - s_shader->SendColor(s_colorLocation, s_secondaryColor); - Renderer::DrawPrimitives(PrimitiveMode_PointList, 0, vertexCount); - } - } - - void DebugDrawer::Draw(const Vector3f& position, float size) - { - Draw(Boxf(position.x - size*0.5f, position.y - size*0.5f, position.z - size*0.5f, size, size, size)); - } - - void DebugDrawer::DrawAxes(const Vector3f& position, float size) - { - Color oldPrimaryColor = s_primaryColor; - s_primaryColor = Color::Red; - DrawLine(position, position + Vector3f::UnitX() * 3.f * size / 4.f); - s_primaryColor = Color::Green; - DrawLine(position, position + Vector3f::UnitY() * 3.f * size / 4.f); - s_primaryColor = Color::Blue; - DrawLine(position, position + Vector3f::UnitZ() * 3.f * size / 4.f); - - s_primaryColor = Color::Red; - DrawCone(position + Vector3f::UnitX() * size, EulerAnglesf(0.f, 90.f, 0.f), 15, size / 4.f); - s_primaryColor = Color::Green; - DrawCone(position + Vector3f::UnitY() * size, EulerAnglesf(-90.f, 0.f, 0.f), 15, size / 4.f); - s_primaryColor = Color::Blue; - DrawCone(position + Vector3f::UnitZ() * size, EulerAnglesf(0.f, 0.f, 0.f), 15, size / 4.f); - s_primaryColor = oldPrimaryColor; - } - - void DebugDrawer::DrawBinormals(const StaticMesh* subMesh) - { - if (!Initialize()) - { - NazaraError("Failed to initialize Debug Drawer"); - return; - } - - unsigned int normalCount = subMesh->GetVertexCount(); - unsigned int vertexCount = normalCount*2; - if (s_vertexBuffer.GetVertexCount() < vertexCount) - { - NazaraError("Debug buffer not large enougth to draw object"); - return; - } - - BufferMapper inputMapper(subMesh->GetVertexBuffer(), BufferAccess_ReadOnly); - BufferMapper outputMapper(s_vertexBuffer, BufferAccess_DiscardAndWrite, 0, vertexCount); - - MeshVertex* inputVertex = static_cast(inputMapper.GetPointer()); - VertexStruct_XYZ* outputVertex = static_cast(outputMapper.GetPointer()); - - for (unsigned int i = 0; i < normalCount; ++i) - { - outputVertex->position = inputVertex->position; - outputVertex++; - - outputVertex->position = inputVertex->position + Vector3f::CrossProduct(inputVertex->normal, inputVertex->tangent)*0.01f; - outputVertex++; - - inputVertex++; - } - - inputMapper.Unmap(); - outputMapper.Unmap(); - - if (vertexCount > 0) - { - Renderer::SetRenderStates(s_renderStates); - Renderer::SetShader(s_shader); - Renderer::SetVertexBuffer(&s_vertexBuffer); - - s_shader->SendColor(s_colorLocation, s_primaryColor); - Renderer::DrawPrimitives(PrimitiveMode_LineList, 0, vertexCount); - } - } - - void DebugDrawer::DrawCone(const Vector3f& origin, const Quaternionf& rotation, float angle, float length) - { - if (!Initialize()) - { - NazaraError("Failed to initialize Debug Drawer"); - return; - } - - Matrix4f transformMatrix; - transformMatrix.MakeIdentity(); - transformMatrix.SetRotation(rotation); - transformMatrix.SetTranslation(origin); - - BufferMapper mapper(s_vertexBuffer, BufferAccess_DiscardAndWrite, 0, 16); - VertexStruct_XYZ* vertex = static_cast(mapper.GetPointer()); - - // On calcule le reste des points - Vector3f base(Vector3f::Forward()*length); - - // Il nous faut maintenant le rayon du cercle projeté à cette distance - // Tangente = Opposé/Adjaçent <=> Opposé = Adjaçent*Tangente - float radius = length*std::tan(DegreeToRadian(angle)); - Vector3f lExtend = Vector3f::Left()*radius; - Vector3f uExtend = Vector3f::Up()*radius; - - vertex->position.Set(transformMatrix * Vector3f::Zero()); - vertex++; - vertex->position.Set(transformMatrix * (base + lExtend + uExtend)); - vertex++; - - vertex->position.Set(transformMatrix * (base + lExtend + uExtend)); - vertex++; - vertex->position.Set(transformMatrix * (base + lExtend - uExtend)); - vertex++; - - vertex->position.Set(transformMatrix * Vector3f::Zero()); - vertex++; - vertex->position.Set(transformMatrix * (base + lExtend - uExtend)); - vertex++; - - vertex->position.Set(transformMatrix * (base + lExtend - uExtend)); - vertex++; - vertex->position.Set(transformMatrix * (base - lExtend - uExtend)); - vertex++; - - vertex->position.Set(transformMatrix * Vector3f::Zero()); - vertex++; - vertex->position.Set(transformMatrix * (base - lExtend + uExtend)); - vertex++; - - vertex->position.Set(transformMatrix * (base - lExtend + uExtend)); - vertex++; - vertex->position.Set(transformMatrix * (base - lExtend - uExtend)); - vertex++; - - vertex->position.Set(transformMatrix * Vector3f::Zero()); - vertex++; - vertex->position.Set(transformMatrix * (base - lExtend - uExtend)); - vertex++; - - vertex->position.Set(transformMatrix * (base - lExtend + uExtend)); - vertex++; - vertex->position.Set(transformMatrix * (base + lExtend + uExtend)); - vertex++; - - mapper.Unmap(); - - Renderer::SetRenderStates(s_renderStates); - Renderer::SetShader(s_shader); - Renderer::SetVertexBuffer(&s_vertexBuffer); - - s_shader->SendColor(s_colorLocation, s_primaryColor); - - Renderer::DrawPrimitives(PrimitiveMode_LineList, 0, 16); - } - - void DebugDrawer::DrawLine(const Vector3f& p1, const Vector3f& p2) - { - if (!s_initialized && !Initialize()) - { - NazaraError("Failed to initialize Debug Drawer"); - return; - } - - VertexStruct_XYZ buffer[2]; - buffer[0].position = p1; - buffer[1].position = p2; - - s_vertexBuffer.Fill(&buffer[0], 0, 2); - - Renderer::SetRenderStates(s_renderStates); - Renderer::SetShader(s_shader); - Renderer::SetVertexBuffer(&s_vertexBuffer); - - s_shader->SendColor(s_colorLocation, s_primaryColor); - Renderer::DrawPrimitives(PrimitiveMode_LineList, 0, 2); - } - - void DebugDrawer::DrawPoints(const Vector3f* ptr, unsigned int pointCount) - { - static_assert(sizeof(VertexStruct_XYZ) == sizeof(Vector3f), "VertexStruct_XYZ is no longer equal to Vector3f, please rewrite this"); - - if (!s_initialized && !Initialize()) - { - NazaraError("Failed to initialize Debug Drawer"); - return; - } - - if (pointCount > 0) - { - s_vertexBuffer.Fill(ptr, 0, pointCount); - - Renderer::SetRenderStates(s_renderStates); - Renderer::SetShader(s_shader); - Renderer::SetVertexBuffer(&s_vertexBuffer); - - s_shader->SendColor(s_colorLocation, s_primaryColor); - Renderer::DrawPrimitives(PrimitiveMode_PointList, 0, pointCount); - } - } - - void DebugDrawer::DrawNormals(const StaticMesh* subMesh) - { - if (!s_initialized && !Initialize()) - { - NazaraError("Failed to initialize Debug Drawer"); - return; - } - - unsigned int normalCount = subMesh->GetVertexCount(); - unsigned int vertexCount = normalCount*2; - if (s_vertexBuffer.GetVertexCount() < vertexCount) - { - NazaraError("Debug buffer not large enougth to draw object"); - return; - } - - BufferMapper inputMapper(subMesh->GetVertexBuffer(), BufferAccess_ReadOnly); - BufferMapper outputMapper(s_vertexBuffer, BufferAccess_DiscardAndWrite, 0, vertexCount); - - MeshVertex* inputVertex = static_cast(inputMapper.GetPointer()); - VertexStruct_XYZ* outputVertex = static_cast(outputMapper.GetPointer()); - - for (unsigned int i = 0; i < normalCount; ++i) - { - outputVertex->position = inputVertex->position; - outputVertex++; - - outputVertex->position = inputVertex->position + inputVertex->normal*0.01f; - outputVertex++; - - inputVertex++; - } - - inputMapper.Unmap(); - outputMapper.Unmap(); - - if (vertexCount > 0) - { - Renderer::SetRenderStates(s_renderStates); - Renderer::SetShader(s_shader); - Renderer::SetVertexBuffer(&s_vertexBuffer); - - s_shader->SendColor(s_colorLocation, s_primaryColor); - Renderer::DrawPrimitives(PrimitiveMode_LineList, 0, vertexCount); - } - } - - void DebugDrawer::DrawTangents(const StaticMesh* subMesh) - { - if (!s_initialized && !Initialize()) - { - NazaraError("Failed to initialize Debug Drawer"); - return; - } - - unsigned int tangentCount = subMesh->GetVertexCount(); - unsigned int vertexCount = tangentCount*2; - if (s_vertexBuffer.GetVertexCount() < vertexCount) - { - NazaraError("Debug buffer not large enougth to draw object"); - return; - } - - BufferMapper inputMapper(subMesh->GetVertexBuffer(), BufferAccess_ReadOnly); - BufferMapper outputMapper(s_vertexBuffer, BufferAccess_DiscardAndWrite, 0, vertexCount); - - MeshVertex* inputVertex = static_cast(inputMapper.GetPointer()); - VertexStruct_XYZ* outputVertex = static_cast(outputMapper.GetPointer()); - - for (unsigned int i = 0; i < tangentCount; ++i) - { - outputVertex->position = inputVertex->position; - outputVertex++; - - outputVertex->position = inputVertex->position + inputVertex->tangent*0.01f; - outputVertex++; - - inputVertex++; - } - - inputMapper.Unmap(); - outputMapper.Unmap(); - - if (vertexCount > 0) - { - Renderer::SetRenderStates(s_renderStates); - Renderer::SetShader(s_shader); - Renderer::SetVertexBuffer(&s_vertexBuffer); - - s_shader->SendColor(s_colorLocation, s_primaryColor); - Renderer::DrawPrimitives(PrimitiveMode_LineList, 0, vertexCount); - } - } - - void DebugDrawer::EnableDepthBuffer(bool depthBuffer) - { - s_renderStates.depthBuffer = depthBuffer; - } - - float DebugDrawer::GetLineWidth() - { - return s_renderStates.lineWidth; - } - - float DebugDrawer::GetPointSize() - { - return s_renderStates.pointSize; - } - - Color DebugDrawer::GetPrimaryColor() - { - return s_primaryColor; - } - - Color DebugDrawer::GetSecondaryColor() - { - return s_secondaryColor; - } - - bool DebugDrawer::Initialize() - { - if (!s_initialized) - { - // s_shader - s_shader = ShaderLibrary::Get("DebugSimple"); - s_colorLocation = s_shader->GetUniformLocation("Color"); - - // s_vertexBuffer - try - { - ErrorFlags flags(ErrorFlag_ThrowException, true); - s_vertexBuffer.Reset(VertexDeclaration::Get(VertexLayout_XYZ), 65365, DataStorage_Hardware, BufferUsage_Dynamic); - } - catch (const std::exception& e) - { - NazaraError("Failed to create buffer: " + String(e.what())); - - Uninitialize(); - return false; - } - - s_primaryColor = Color::Red; - s_renderStates.depthBuffer = true; - s_secondaryColor = Color::Green; - - s_initialized = true; - } - - return true; - } - - bool DebugDrawer::IsDepthBufferEnabled() - { - return s_renderStates.depthBuffer; - } - - void DebugDrawer::SetLineWidth(float width) - { - s_renderStates.lineWidth = width; - } - - void DebugDrawer::SetPointSize(float size) - { - s_renderStates.pointSize = size; - } - - void DebugDrawer::SetPrimaryColor(const Color& color) - { - s_primaryColor = color; - } - - void DebugDrawer::SetSecondaryColor(const Color& color) - { - s_secondaryColor = color; - } - - void DebugDrawer::Uninitialize() - { - s_shader = nullptr; - s_vertexBuffer.Reset(); - s_initialized = false; - } -} diff --git a/src/Nazara/Renderer/GLX/ContextImpl.cpp b/src/Nazara/Renderer/GLX/ContextImpl.cpp deleted file mode 100644 index 8bff9793a..000000000 --- a/src/Nazara/Renderer/GLX/ContextImpl.cpp +++ /dev/null @@ -1,300 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -// Code inspiré de NeHe (Lesson1) et de la SFML par Laurent Gomila - -#include -#include -#include -#include -#include - -using namespace GLX; - -namespace Nz -{ - namespace - { - Display* m_display; - int m_sharedDisplay = 0; - - bool ctxErrorOccurred = false; - int ctxErrorHandler( Display* /*dpy*/, XErrorEvent* /*ev*/ ) - { - ctxErrorOccurred = true; - return 0; - } - } - - ContextImpl::ContextImpl() : - m_colormap(0), - m_context(0), - m_window(0), - m_ownsWindow(false) - { - if (m_sharedDisplay == 0) - m_display = XOpenDisplay(nullptr); - - ++m_sharedDisplay; - } - - ContextImpl::~ContextImpl() - { - Destroy(); - - if (--m_sharedDisplay == 0) - { - XCloseDisplay(m_display); - m_display = nullptr; - } - } - - bool ContextImpl::Activate() - { - return glXMakeCurrent(m_display, m_window, m_context) == true; - } - - bool ContextImpl::Create(ContextParameters& parameters) - { - // En cas d'exception, la ressource sera quand même libérée - CallOnExit onExit([this] () - { - Destroy(); - }); - - // Get a matching FB config - static int visual_attribs[] = - { - GLX_X_RENDERABLE, True, - GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, - GLX_RENDER_TYPE, GLX_RGBA_BIT, - GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR, - GLX_BUFFER_SIZE, parameters.bitsPerPixel, - GLX_ALPHA_SIZE, (parameters.bitsPerPixel == 32) ? 8 : 0, - GLX_DEPTH_SIZE, parameters.depthBits, - GLX_STENCIL_SIZE, parameters.stencilBits, - GLX_DOUBLEBUFFER, True, - GLX_SAMPLE_BUFFERS, (parameters.antialiasingLevel > 0) ? True : False, - GLX_SAMPLES, parameters.antialiasingLevel, - None - }; - - int glx_major = 0; - int glx_minor = 0; - // FBConfigs were added in GLX version 1.3. - if (!glXQueryVersion(m_display, &glx_major, &glx_minor) || ((glx_major == 1) && (glx_minor < 3)) || (glx_major < 1)) - { - NazaraError("Invalid GLX version, version > 1.3 is required."); - return false; - } - - int fbcount; - GLXFBConfig* fbc = glXChooseFBConfig(m_display, XDefaultScreen(m_display), visual_attribs, &fbcount); - if (!fbc) - { - NazaraError("Failed to retrieve a framebuffer config"); - return false; - } - - // Pick the FB config/visual with the most samples per pixel - int best_fbc = -1; - int worst_fbc = -1; - int best_num_samp = -1; - int worst_num_samp = 999; - - for (int i = 0; i < fbcount; ++i) - { - XVisualInfo* vi = glXGetVisualFromFBConfig(m_display, fbc[i]); - - if (vi) - { - int samp_buf = 0, samples = 0; - glXGetFBConfigAttrib(m_display, fbc[i], GLX_SAMPLE_BUFFERS, &samp_buf); - glXGetFBConfigAttrib(m_display, fbc[i], GLX_SAMPLES , &samples ); - - if ((best_fbc < 0) || (samp_buf && (samples > best_num_samp))) - { - best_fbc = i; - best_num_samp = samples; - } - if ((worst_fbc < 0) || !samp_buf || (samples < worst_num_samp)) - { - worst_fbc = i; - worst_num_samp = samples; - } - } - XFree(vi); - } - - GLXFBConfig bestFbc = fbc[best_fbc]; - - // Be sure to free the FBConfig list allocated by glXChooseFBConfig() - XFree(fbc); - - // Get a visual - XVisualInfo* vi = glXGetVisualFromFBConfig(m_display, bestFbc); - if (!vi) - { - NazaraError("Failed to get best VisualInfo"); - return false; - } - - // If context is shared by multiple windows - if (parameters.window) - { - m_window = parameters.window; - m_ownsWindow = false; - } - else - { - XSetWindowAttributes swa; - swa.colormap = m_colormap = XCreateColormap( - m_display, - XRootWindow( - m_display, - vi->screen), - vi->visual, - AllocNone - ); - - swa.background_pixmap = None; - swa.border_pixel = 0; - swa.event_mask = StructureNotifyMask; - - if (!m_colormap) - { - NazaraError("Failed to create colormap for context"); - return false; - } - - m_window = XCreateWindow( - m_display, - XRootWindow( - m_display, - vi->screen), - 0, 0, // X, Y - 1, 1, // W H - 0, - vi->depth, - InputOutput, - vi->visual, - CWBorderPixel | CWColormap | CWEventMask, - &swa - ); - - m_ownsWindow = true; - } - - if (!m_window) - { - NazaraError("Failed to create window"); - return false; - } - - // Done with the visual info data - XFree(vi); - - // Install an X error handler so the application won't exit if GL 3.0 - // context allocation fails. - // - // Note this error handler is global. All display connections in all threads - // of a process use the same error handler, so be sure to guard against other - // threads issuing X commands while this code is running. - ctxErrorOccurred = false; - int (*oldHandler)(Display*, XErrorEvent*) = - XSetErrorHandler(&ctxErrorHandler); - - // Check for the GLX_ARB_create_context extension string and the function. - // If either is not present, use GLX 1.3 context creation method. - if (!glXCreateContextAttribs) - { - NazaraWarning("glXCreateContextAttribs() not found. Using old-style GLX context"); - m_context = glXCreateNewContext(m_display, bestFbc, GLX_RGBA_TYPE, parameters.shared ? parameters.shareContext->m_impl->m_context : 0, True); - } - // If it does, try to get a GL 3.0 context! - else - { - int profile = parameters.compatibilityProfile ? GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB : GLX_CONTEXT_CORE_PROFILE_BIT_ARB; - int debug = parameters.debugMode ? GLX_CONTEXT_DEBUG_BIT_ARB : 0; - - int major = 3;//parameters.majorVersion; - int minor = 3;//parameters.minorVersion; - - int context_attribs[] = - { - GLX_CONTEXT_MAJOR_VERSION_ARB, major, - GLX_CONTEXT_MINOR_VERSION_ARB, minor, - GLX_CONTEXT_PROFILE_MASK_ARB, profile, - GLX_CONTEXT_FLAGS_ARB, debug, - None, None - }; - - m_context = glXCreateContextAttribs( - m_display, - bestFbc, - parameters.shared ? parameters.shareContext->m_impl->m_context : 0, - True, - context_attribs - ); - } - - // Sync to ensure any errors generated are processed. - XSync(m_display, False); - XSetErrorHandler(oldHandler); - if (ctxErrorOccurred || !m_context) - { - NazaraError("Failed to create context, check the version"); - return false; - } - - onExit.Reset(); - - return true; - } - - void ContextImpl::Destroy() - { - // Destroy the context - if (m_context) - { - if (glXGetCurrentContext() == m_context) - glXMakeCurrent(m_display, None, nullptr); - glXDestroyContext(m_display, m_context); - m_context = nullptr; - } - - // Destroy the window if we own it - if (m_ownsWindow && m_window) - { - XFreeColormap(m_display, m_colormap); - XDestroyWindow(m_display, m_window); - m_ownsWindow = false; - m_window = 0; - XFlush(m_display); - } - } - - void ContextImpl::EnableVerticalSync(bool enabled) - { - if (glXSwapIntervalEXT) - glXSwapIntervalEXT(m_display, glXGetCurrentDrawable(), enabled ? 1 : 0); - else if (NzglXSwapIntervalMESA) - NzglXSwapIntervalMESA(enabled ? 1 : 0); - else if (glXSwapIntervalSGI) - glXSwapIntervalSGI(enabled ? 1 : 0); - else - NazaraError("Vertical sync not supported"); - } - - void ContextImpl::SwapBuffers() - { - if (m_window) - glXSwapBuffers(m_display, m_window); - } - - bool ContextImpl::Desactivate() - { - return glXMakeCurrent(m_display, None, nullptr) == true; - } -} diff --git a/src/Nazara/Renderer/GLX/ContextImpl.hpp b/src/Nazara/Renderer/GLX/ContextImpl.hpp deleted file mode 100644 index 40bbd5fc7..000000000 --- a/src/Nazara/Renderer/GLX/ContextImpl.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_CONTEXTIMPL_HPP -#define NAZARA_CONTEXTIMPL_HPP - -#include - -namespace Nz -{ - class ContextParameters; - - class ContextImpl - { - public: - ContextImpl(); - ~ContextImpl(); - - bool Activate(); - - bool Create(ContextParameters& parameters); - - void Destroy(); - - void EnableVerticalSync(bool enabled); - - void SwapBuffers(); - - static bool Desactivate(); - - private: - GLX::Colormap m_colormap; - GLX::GLXContext m_context; - GLX::Window m_window; - bool m_ownsWindow; - }; -} - -#endif // NAZARA_CONTEXTIMPL_HPP diff --git a/src/Nazara/Renderer/GpuQuery.cpp b/src/Nazara/Renderer/GpuQuery.cpp deleted file mode 100644 index 4e7ff228f..000000000 --- a/src/Nazara/Renderer/GpuQuery.cpp +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - GpuQuery::GpuQuery() : - m_id(0) - { - Context::EnsureContext(); - - m_id = 0; - glGenQueries(1, static_cast(&m_id)); - - #ifdef NAZARA_DEBUG - if (!m_id) - { - NazaraError("Failed to create occlusion query"); - throw std::runtime_error("Constructor failed"); - } - #endif - } - - GpuQuery::~GpuQuery() - { - if (m_id) - { - Context::EnsureContext(); - - GLuint query = static_cast(m_id); - glDeleteQueries(1, &query); - } - } - - void GpuQuery::Begin(GpuQueryMode mode) - { - #ifdef NAZARA_DEBUG - if (Context::GetCurrent() == nullptr) - { - NazaraError("No active context"); - return; - } - #endif - - #if NAZARA_RENDERER_SAFE - if (!IsModeSupported(mode)) - { - NazaraError("Mode (0x" + String::Number(mode, 16) + ") not supported"); - return; - } - #endif - - m_mode = mode; - glBeginQuery(OpenGL::QueryMode[mode], m_id); - } - - void GpuQuery::End() - { - #ifdef NAZARA_DEBUG - if (Context::GetCurrent() == nullptr) - { - NazaraError("No active context"); - return; - } - #endif - - glEndQuery(OpenGL::QueryMode[m_mode]); - } - - unsigned int GpuQuery::GetResult() const - { - Context::EnsureContext(); - - GLuint result; - glGetQueryObjectuiv(m_id, GL_QUERY_RESULT, &result); - - return result; - } - - bool GpuQuery::IsResultAvailable() const - { - Context::EnsureContext(); - - GLint available; - glGetQueryObjectiv(m_id, GL_QUERY_RESULT_AVAILABLE, &available); - - return available == GL_TRUE; - } - - unsigned int GpuQuery::GetOpenGLID() const - { - return m_id; - } - - bool GpuQuery::IsModeSupported(GpuQueryMode mode) - { - switch (mode) - { - case GpuQueryMode_AnySamplesPassedConservative: - return OpenGL::GetVersion() >= 430; - - case GpuQueryMode_AnySamplesPassed: - case GpuQueryMode_PrimitiveGenerated: - case GpuQueryMode_SamplesPassed: - case GpuQueryMode_TimeElapsed: - case GpuQueryMode_TransformFeedbackPrimitivesWritten: - return true; - } - - NazaraError("Gpu Query mode not handled (0x" + String::Number(mode, 16) + ')'); - return false; - } -} diff --git a/src/Nazara/Renderer/HardwareBuffer.cpp b/src/Nazara/Renderer/HardwareBuffer.cpp deleted file mode 100644 index 4005b47a5..000000000 --- a/src/Nazara/Renderer/HardwareBuffer.cpp +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - HardwareBuffer::HardwareBuffer(Buffer* parent, BufferType type) : - m_type(type), - m_parent(parent) - { - } - - HardwareBuffer::~HardwareBuffer() = default; - - bool HardwareBuffer::Create(unsigned int size, BufferUsage usage) - { - Context::EnsureContext(); - - m_buffer = 0; - glGenBuffers(1, &m_buffer); - - OpenGL::BindBuffer(m_type, m_buffer); - - glBufferData(OpenGL::BufferTarget[m_type], size, nullptr, OpenGL::BufferUsage[usage]); - - return true; - } - - void HardwareBuffer::Destroy() - { - Context::EnsureContext(); - - OpenGL::DeleteBuffer(m_type, m_buffer); - } - - bool HardwareBuffer::Fill(const void* data, unsigned int offset, unsigned int size, bool forceDiscard) - { - Context::EnsureContext(); - - unsigned int totalSize = m_parent->GetSize(); - - if (!forceDiscard) - forceDiscard = (size == totalSize); - - OpenGL::BindBuffer(m_type, m_buffer); - - // Il semblerait que glBuffer(Sub)Data soit plus performant que glMapBuffer(Range) en dessous d'un certain seuil - // http://www.stevestreeting.com/2007/03/17/glmapbuffer-vs-glbuffersubdata-the-return/ - if (size < 32*1024) - { - // http://www.opengl.org/wiki/Buffer_Object_Streaming - if (forceDiscard) - glBufferData(OpenGL::BufferTarget[m_type], totalSize, nullptr, OpenGL::BufferUsage[m_parent->GetUsage()]); // Discard - - glBufferSubData(OpenGL::BufferTarget[m_type], offset, size, data); - } - else - { - void* ptr = Map((forceDiscard) ? BufferAccess_DiscardAndWrite : BufferAccess_WriteOnly, offset, size); - if (!ptr) - { - NazaraError("Failed to map buffer"); - return false; - } - - std::memcpy(ptr, data, size); - - Unmap(); - } - - return true; - } - - bool HardwareBuffer::IsHardware() const - { - return true; - } - - void* HardwareBuffer::Map(BufferAccess access, unsigned int offset, unsigned int size) - { - Context::EnsureContext(); - - OpenGL::BindBuffer(m_type, m_buffer); - - if (glMapBufferRange) - return glMapBufferRange(OpenGL::BufferTarget[m_type], offset, size, OpenGL::BufferLockRange[access]); - else - { - // http://www.opengl.org/wiki/Buffer_Object_Streaming - if (access == BufferAccess_DiscardAndWrite) - glBufferData(OpenGL::BufferTarget[m_type], m_parent->GetSize(), nullptr, OpenGL::BufferUsage[m_parent->GetUsage()]); // Discard - - UInt8* ptr = static_cast(glMapBuffer(OpenGL::BufferTarget[m_type], OpenGL::BufferLock[access])); - if (ptr) - ptr += offset; - - return ptr; - } - } - - bool HardwareBuffer::Unmap() - { - Context::EnsureContext(); - - OpenGL::BindBuffer(m_type, m_buffer); - - if (glUnmapBuffer(OpenGL::BufferTarget[m_type]) != GL_TRUE) - { - glBufferData(OpenGL::BufferTarget[m_type], m_parent->GetSize(), nullptr, OpenGL::BufferUsage[m_parent->GetUsage()]); - - // Une erreur rare est survenue, nous devons réinitialiser le buffer - NazaraError("Failed to unmap buffer, reinitialising content... (OpenGL error : 0x" + String::Number(glGetError(), 16) + ')'); - return false; - } - - return true; - } - - void HardwareBuffer::Bind() const - { - OpenGL::BindBuffer(m_type, m_buffer); - } - - unsigned int HardwareBuffer::GetOpenGLID() const - { - return m_buffer; -} -} diff --git a/src/Nazara/Renderer/HardwareBuffer.hpp b/src/Nazara/Renderer/HardwareBuffer.hpp deleted file mode 100644 index 608a1598d..000000000 --- a/src/Nazara/Renderer/HardwareBuffer.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_HARDWAREBUFFER_HPP -#define NAZARA_HARDWAREBUFFER_HPP - -#include -#include -#include - -namespace Nz -{ - class HardwareBuffer : public AbstractBuffer - { - public: - HardwareBuffer(Buffer* parent, BufferType type); - ~HardwareBuffer(); - - bool Create(unsigned int size, BufferUsage usage = BufferUsage_Static); - void Destroy(); - - bool Fill(const void* data, unsigned int offset, unsigned int size, bool forceDiscard); - - bool IsHardware() const; - - void* Map(BufferAccess access, unsigned int offset = 0, unsigned int size = 0); - bool Unmap(); - - // Fonctions OpenGL - void Bind() const; - unsigned int GetOpenGLID() const; - - private: - GLuint m_buffer; - BufferType m_type; - Buffer* m_parent; - }; -} - -#endif // NAZARA_HARDWAREBUFFER_HPP diff --git a/src/Nazara/Renderer/OpenGL.cpp b/src/Nazara/Renderer/OpenGL.cpp deleted file mode 100644 index ba17fe015..000000000 --- a/src/Nazara/Renderer/OpenGL.cpp +++ /dev/null @@ -1,2306 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include -#include -#if defined(NAZARA_PLATFORM_GLX) -#include -#endif // NAZARA_PLATFORM_GLX -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - namespace - { - #ifdef NAZARA_PLATFORM_WINDOWS - HMODULE openGLlibrary; - #endif - - OpenGLFunc LoadEntry(const char* name, bool launchException = true) - { - #if defined(NAZARA_PLATFORM_WINDOWS) - OpenGLFunc entry = reinterpret_cast(wglGetProcAddress(name)); - if (!entry) // wglGetProcAddress ne fonctionne pas sur les fonctions OpenGL <= 1.1 - entry = reinterpret_cast(GetProcAddress(openGLlibrary, name)); - #elif defined(NAZARA_PLATFORM_GLX) - OpenGLFunc entry = reinterpret_cast(GLX::glXGetProcAddress(reinterpret_cast(name))); - #else - #error OS not handled - #endif - - if (!entry && launchException) - { - std::ostringstream oss; - oss << "failed to load \"" << name << '"'; - - throw std::runtime_error(oss.str()); - } - - return entry; - } - - bool LoadLibrary() - { - #ifdef NAZARA_PLATFORM_WINDOWS - openGLlibrary = ::LoadLibraryA("opengl32.dll"); - - return openGLlibrary != nullptr; - #else - return true; - #endif - } - - void UnloadLibrary() - { - #ifdef NAZARA_PLATFORM_WINDOWS - FreeLibrary(openGLlibrary); - #endif - } - - enum GarbageResourceType - { - GarbageResourceType_FrameBuffer, - GarbageResourceType_VertexArray - }; - - struct ContextStates - { - std::vector> garbage; // Les ressources à supprimer dès que possible - GLuint buffersBinding[BufferType_Max + 1] = {0}; - GLuint currentProgram = 0; - GLuint samplers[32] = {0}; // 32 est pour l'instant la plus haute limite (GL_TEXTURE31) - GLuint texturesBinding[32] = {0}; // 32 est pour l'instant la plus haute limite (GL_TEXTURE31) - Recti currentScissorBox = Recti(0, 0, 0, 0); - Recti currentViewport = Recti(0, 0, 0, 0); - RenderStates renderStates; // Toujours synchronisé avec OpenGL - const RenderTarget* currentTarget = nullptr; - bool scissorBoxUpdated = true; - bool viewportUpdated = true; - unsigned int textureUnit = 0; - }; - - std::set s_openGLextensionSet; - std::unordered_map s_contexts; - thread_local ContextStates* s_contextStates = nullptr; - String s_rendererName; - String s_vendorName; - bool s_initialized = false; - bool s_openGLextensions[OpenGLExtension_Max + 1] = {false}; - unsigned int s_glslVersion = 0; - unsigned int s_openglVersion = 0; - - bool LoadExtensionsString(const String& extensionString) - { - if (extensionString.IsEmpty()) - { - NazaraError("Unable to get extension string"); - return false; - } - - // On peut sûrement faire plus rapide mais comme ça ne se fait qu'une fois et que String implémente le COW... - std::vector ext; - extensionString.Split(ext); - - for (std::vector::iterator it = ext.begin(); it != ext.end(); ++it) - s_openGLextensionSet.insert(*it); - - return true; - } - - bool LoadExtensions3() - { - GLint extensionCount = 0; - glGetIntegerv(GL_NUM_EXTENSIONS, &extensionCount); - - if (extensionCount <= 0) - { - NazaraError("Unable to get extension count"); - return false; - } - - for (int i = 0; i < extensionCount; ++i) - { - String extension(reinterpret_cast(glGetStringi(GL_EXTENSIONS, i))); - if (extension.IsEmpty()) - { - NazaraWarning("Unable to get extension #" + String::Number(i)); - continue; - } - - s_openGLextensionSet.insert(extension); - } - - return true; - } - } - - void OpenGL::ApplyStates(const RenderStates& states) - { - #ifdef NAZARA_DEBUG - if (!s_contextStates) - { - NazaraError("No context activated"); - return; - } - #endif - - RenderStates& currentRenderStates = s_contextStates->renderStates; - - // Les fonctions de blend n'a aucun intérêt sans blending - if (states.blending) - { - if (currentRenderStates.dstBlend != states.dstBlend || - currentRenderStates.srcBlend != states.srcBlend) - { - glBlendFunc(BlendFunc[states.srcBlend], BlendFunc[states.dstBlend]); - currentRenderStates.dstBlend = states.dstBlend; - currentRenderStates.srcBlend = states.srcBlend; - } - } - - if (states.depthBuffer) - { - // La comparaison de profondeur n'a aucun intérêt sans depth buffer - if (currentRenderStates.depthFunc != states.depthFunc) - { - glDepthFunc(RendererComparison[states.depthFunc]); - currentRenderStates.depthFunc = states.depthFunc; - } - - // Le DepthWrite n'a aucune importance si le DepthBuffer est désactivé - if (currentRenderStates.depthWrite != states.depthWrite) - { - glDepthMask((states.depthWrite) ? GL_TRUE : GL_FALSE); - currentRenderStates.depthWrite = states.depthWrite; - } - } - - // Inutile de changer le mode de face culling s'il n'est pas actif - if (states.faceCulling) - { - if (currentRenderStates.cullingSide != states.cullingSide) - { - glCullFace(FaceSide[states.cullingSide]); - currentRenderStates.cullingSide = states.cullingSide; - } - } - - if (currentRenderStates.faceFilling != states.faceFilling) - { - glPolygonMode(GL_FRONT_AND_BACK, FaceFilling[states.faceFilling]); - currentRenderStates.faceFilling = states.faceFilling; - } - - // Ici encore, ça ne sert à rien de se soucier des fonctions de stencil sans qu'il soit activé - if (states.stencilTest) - { - if (currentRenderStates.stencilCompare.back != states.stencilCompare.back || - currentRenderStates.stencilReference.back != states.stencilReference.back || - currentRenderStates.stencilWriteMask.back != states.stencilWriteMask.back) - { - glStencilFuncSeparate(GL_BACK, RendererComparison[states.stencilCompare.back], states.stencilReference.back, states.stencilWriteMask.back); - currentRenderStates.stencilCompare.back = states.stencilCompare.back; - currentRenderStates.stencilReference.back = states.stencilReference.back; - currentRenderStates.stencilWriteMask.back = states.stencilWriteMask.back; - } - - if (currentRenderStates.stencilDepthFail.back != states.stencilDepthFail.back || - currentRenderStates.stencilFail.back != states.stencilFail.back || - currentRenderStates.stencilPass.back != states.stencilPass.back) - { - glStencilOpSeparate(GL_BACK, StencilOperation[states.stencilFail.back], StencilOperation[states.stencilDepthFail.back], StencilOperation[states.stencilPass.back]); - currentRenderStates.stencilDepthFail.back = states.stencilDepthFail.back; - currentRenderStates.stencilFail.back = states.stencilFail.back; - currentRenderStates.stencilPass.back = states.stencilPass.back; - } - - if (currentRenderStates.stencilCompare.front != states.stencilCompare.front || - currentRenderStates.stencilReference.front != states.stencilReference.front || - currentRenderStates.stencilWriteMask.front != states.stencilWriteMask.front) - { - glStencilFuncSeparate(GL_FRONT, RendererComparison[states.stencilCompare.front], states.stencilReference.front, states.stencilWriteMask.front); - currentRenderStates.stencilCompare.front = states.stencilCompare.front; - currentRenderStates.stencilReference.front = states.stencilReference.front; - currentRenderStates.stencilWriteMask.front = states.stencilWriteMask.front; - } - - if (currentRenderStates.stencilDepthFail.front != states.stencilDepthFail.front || - currentRenderStates.stencilFail.front != states.stencilFail.front || - currentRenderStates.stencilPass.front != states.stencilPass.front) - { - glStencilOpSeparate(GL_FRONT, StencilOperation[states.stencilFail.front], StencilOperation[states.stencilDepthFail.front], StencilOperation[states.stencilPass.front]); - currentRenderStates.stencilDepthFail.front = states.stencilDepthFail.front; - currentRenderStates.stencilFail.front = states.stencilFail.front; - currentRenderStates.stencilPass.front = states.stencilPass.front; - } - } - - if (!NumberEquals(currentRenderStates.lineWidth, states.lineWidth, 0.001f)) - { - glLineWidth(states.lineWidth); - currentRenderStates.lineWidth = states.lineWidth; - } - - if (!NumberEquals(currentRenderStates.pointSize, states.pointSize, 0.001f)) - { - glPointSize(states.pointSize); - currentRenderStates.pointSize = states.pointSize; - } - - // Paramètres de rendu - if (currentRenderStates.blending != states.blending) - { - if (states.blending) - glEnable(GL_BLEND); - else - glDisable(GL_BLEND); - - currentRenderStates.blending = states.blending; - } - - if (currentRenderStates.colorWrite != states.colorWrite) - { - GLboolean param = (states.colorWrite) ? GL_TRUE : GL_FALSE; - glColorMask(param, param, param, param); - - currentRenderStates.colorWrite = states.colorWrite; - } - - if (currentRenderStates.depthBuffer != states.depthBuffer) - { - if (states.depthBuffer) - glEnable(GL_DEPTH_TEST); - else - glDisable(GL_DEPTH_TEST); - - currentRenderStates.depthBuffer = states.depthBuffer; - } - - if (currentRenderStates.faceCulling != states.faceCulling) - { - if (states.faceCulling) - glEnable(GL_CULL_FACE); - else - glDisable(GL_CULL_FACE); - - currentRenderStates.faceCulling = states.faceCulling; - } - - if (currentRenderStates.scissorTest != states.scissorTest) - { - if (states.scissorTest) - glEnable(GL_SCISSOR_TEST); - else - glDisable(GL_SCISSOR_TEST); - - currentRenderStates.scissorTest = states.scissorTest; - } - - if (currentRenderStates.stencilTest != states.stencilTest) - { - if (states.stencilTest) - glEnable(GL_STENCIL_TEST); - else - glDisable(GL_STENCIL_TEST); - - currentRenderStates.stencilTest = states.stencilTest; - } - } - - void OpenGL::BindBuffer(BufferType type, GLuint id) - { - #ifdef NAZARA_DEBUG - if (!s_contextStates) - { - NazaraError("No context activated"); - return; - } - #endif - - if (s_contextStates->buffersBinding[type] != id) - { - glBindBuffer(BufferTarget[type], id); - s_contextStates->buffersBinding[type] = id; - } - } - - void OpenGL::BindProgram(GLuint id) - { - #ifdef NAZARA_DEBUG - if (!s_contextStates) - { - NazaraError("No context activated"); - return; - } - #endif - - if (s_contextStates->currentProgram != id) - { - glUseProgram(id); - s_contextStates->currentProgram = id; - } - } - - void OpenGL::BindSampler(GLuint unit, GLuint id) - { - #ifdef NAZARA_DEBUG - if (!glBindSampler) - { - NazaraError("Sampler are not supported"); - return; - } - - if (!s_contextStates) - { - NazaraError("No context activated"); - return; - } - #endif - - if (s_contextStates->samplers[unit] != id) - { - glBindSampler(unit, id); - s_contextStates->samplers[unit] = id; - } - } - - void OpenGL::BindScissorBox(const Recti& scissorBox) - { - #ifdef NAZARA_DEBUG - if (!s_contextStates) - { - NazaraError("No context activated"); - return; - } - #endif - - #if NAZARA_RENDERER_SAFE - if (scissorBox.width < 0) - { - NazaraError("Scissor box width must be positive"); - return; - } - - if (scissorBox.height < 0) - { - NazaraError("Scissor box height must be positive"); - return; - } - #endif - - if (s_contextStates->currentScissorBox != scissorBox) - { - if (s_contextStates->currentTarget) - { - unsigned int height = s_contextStates->currentTarget->GetHeight(); - glScissor(scissorBox.x, height - scissorBox.height - scissorBox.y, scissorBox.width, scissorBox.height); - s_contextStates->scissorBoxUpdated = true; - } - else - s_contextStates->scissorBoxUpdated = false; // Sinon on attend d'avoir un target - - s_contextStates->currentScissorBox = scissorBox; - } - } - - void OpenGL::BindTexture(ImageType type, GLuint id) - { - #ifdef NAZARA_DEBUG - if (!s_contextStates) - { - NazaraError("No context activated"); - return; - } - #endif - - if (s_contextStates->texturesBinding[s_contextStates->textureUnit] != id) - { - glBindTexture(TextureTarget[type], id); - s_contextStates->texturesBinding[s_contextStates->textureUnit] = id; - } - } - - void OpenGL::BindTexture(unsigned int textureUnit, ImageType type, GLuint id) - { - #ifdef NAZARA_DEBUG - if (!s_contextStates) - { - NazaraError("No context activated"); - return; - } - #endif - - if (s_contextStates->texturesBinding[textureUnit] != id) - { - BindTextureUnit(textureUnit); - - glBindTexture(TextureTarget[type], id); - s_contextStates->texturesBinding[textureUnit] = id; - } - } - - void OpenGL::BindTextureUnit(unsigned int textureUnit) - { - #ifdef NAZARA_DEBUG - if (!s_contextStates) - { - NazaraError("No context activated"); - return; - } - #endif - - if (s_contextStates->textureUnit != textureUnit) - { - glActiveTexture(GL_TEXTURE0 + textureUnit); - s_contextStates->textureUnit = textureUnit; - } - } - - void OpenGL::BindViewport(const Recti& viewport) - { - #ifdef NAZARA_DEBUG - if (!s_contextStates) - { - NazaraError("No context activated"); - return; - } - #endif - - #if NAZARA_RENDERER_SAFE - if (viewport.width < 0) - { - NazaraError("Viewport width must be positive"); - return; - } - - if (viewport.height < 0) - { - NazaraError("Viewport height must be positive"); - return; - } - #endif - - if (s_contextStates->currentViewport != viewport) - { - if (s_contextStates->currentTarget) - { - unsigned int height = s_contextStates->currentTarget->GetHeight(); - glViewport(viewport.x, height - viewport.height - viewport.y, viewport.width, viewport.height); - s_contextStates->viewportUpdated = true; - } - else - s_contextStates->viewportUpdated = false; // Sinon on attend d'avoir un target - - s_contextStates->currentViewport = viewport; - } - } - - void OpenGL::DeleteBuffer(BufferType type, GLuint id) - { - #ifdef NAZARA_DEBUG - if (!s_contextStates) - { - NazaraError("No context activated"); - return; - } - #endif - - glDeleteBuffers(1, &id); - if (s_contextStates->buffersBinding[type] == id) - s_contextStates->buffersBinding[type] = 0; - } - - void OpenGL::DeleteFrameBuffer(const Context* context, GLuint id) - { - // Si le contexte est actif, ne nous privons pas - if (Context::GetCurrent() == context) - glDeleteFramebuffers(1, &id); - else - s_contexts[context].garbage.emplace_back(GarbageResourceType_FrameBuffer, id); - } - - void OpenGL::DeleteProgram(GLuint id) - { - #ifdef NAZARA_DEBUG - if (!s_contextStates) - { - NazaraError("No context activated"); - return; - } - #endif - - glDeleteProgram(id); - if (s_contextStates->currentProgram == id) - s_contextStates->currentProgram = 0; - } - - void OpenGL::DeleteSampler(GLuint id) - { - #ifdef NAZARA_DEBUG - if (!glDeleteSamplers) - { - NazaraError("Sampler are not supported"); - return; - } - - if (!s_contextStates) - { - NazaraError("No context activated"); - return; - } - #endif - - glDeleteSamplers(1, &id); - - for (GLuint& binding : s_contextStates->samplers) - { - if (binding == id) - binding = 0; - } - } - - void OpenGL::DeleteTexture(GLuint id) - { - #ifdef NAZARA_DEBUG - if (!s_contextStates) - { - NazaraError("No context activated"); - return; - } - #endif - - glDeleteTextures(1, &id); - - for (GLuint& binding : s_contextStates->texturesBinding) - { - if (binding == id) - binding = 0; - } - } - - void OpenGL::DeleteVertexArray(const Context* context, GLuint id) - { - // Si le contexte est actif, ne nous privons pas - if (Context::GetCurrent() == context) - glDeleteFramebuffers(1, &id); - else - s_contexts[context].garbage.emplace_back(GarbageResourceType_VertexArray, id); - } - - GLuint OpenGL::GetCurrentBuffer(BufferType type) - { - #ifdef NAZARA_DEBUG - if (!s_contextStates) - { - NazaraError("No context activated"); - return 0; - } - #endif - - return s_contextStates->buffersBinding[type]; - } - - GLuint OpenGL::GetCurrentProgram() - { - #ifdef NAZARA_DEBUG - if (!s_contextStates) - { - NazaraError("No context activated"); - return 0; - } - #endif - - return s_contextStates->currentProgram; - } - - Recti OpenGL::GetCurrentScissorBox() - { - #ifdef NAZARA_DEBUG - if (!s_contextStates) - { - NazaraError("No context activated"); - return Recti(); - } - #endif - - return s_contextStates->currentScissorBox; - } - - const RenderTarget* OpenGL::GetCurrentTarget() - { - #ifdef NAZARA_DEBUG - if (!s_contextStates) - { - NazaraError("No context activated"); - return nullptr; - } - #endif - - return s_contextStates->currentTarget; - } - - GLuint OpenGL::GetCurrentTexture() - { - #ifdef NAZARA_DEBUG - if (!s_contextStates) - { - NazaraError("No context activated"); - return 0; - } - #endif - - return s_contextStates->texturesBinding[s_contextStates->textureUnit]; - } - - GLuint OpenGL::GetCurrentTexture(unsigned int textureUnit) - { - #ifdef NAZARA_DEBUG - if (!s_contextStates) - { - NazaraError("No context activated"); - return 0; - } - #endif - - return s_contextStates->texturesBinding[textureUnit]; - } - - unsigned int OpenGL::GetCurrentTextureUnit() - { - #ifdef NAZARA_DEBUG - if (!s_contextStates) - { - NazaraError("No context activated"); - return 0; - } - #endif - - return s_contextStates->textureUnit; - } - - Recti OpenGL::GetCurrentViewport() - { - #ifdef NAZARA_DEBUG - if (!s_contextStates) - { - NazaraError("No context activated"); - return Recti(); - } - #endif - - return s_contextStates->currentViewport; - } - - OpenGLFunc OpenGL::GetEntry(const String& entryPoint) - { - return LoadEntry(entryPoint.GetConstBuffer(), false); - } - - unsigned int OpenGL::GetGLSLVersion() - { - return s_glslVersion; - } - - String OpenGL::GetRendererName() - { - return s_rendererName; - } - - String OpenGL::GetVendorName() - { - return s_vendorName; - } - - unsigned int OpenGL::GetVersion() - { - return s_openglVersion; - } - - bool OpenGL::Initialize() - { - if (s_initialized) - return true; - - #if defined(NAZARA_PLATFORM_GLX) - Initializer display; - if (!display) - { - NazaraError("Failed to load display library"); - return false; - } - #endif - - if (!LoadLibrary()) - { - NazaraError("Failed to load OpenGL library"); - return false; - } - - s_initialized = true; - - // En cas d'erreur, on libèrera OpenGL - CallOnExit onExit(OpenGL::Uninitialize); - - // Le chargement des fonctions OpenGL nécessite un contexte OpenGL - ContextParameters parameters; - parameters.majorVersion = 2; - parameters.minorVersion = 0; - parameters.shared = false; - - /* - Note: Même le contexte de chargement nécessite quelques fonctions de base pour correctement s'initialiser - Pour cette raison, deux contextes sont créés, le premier sert à récupérer les fonctions permetttant - de créer le second avec les bons paramètres. - - Non sérieusement si vous avez une meilleure idée, contactez-moi - */ - - /****************************Chargement OpenGL****************************/ - - ///FIXME: I'm really thinking this is a mistake and GLX has no need to be initialized differently (Lynix) - #if defined(NAZARA_PLATFORM_LINUX) - glXCreateContextAttribs = reinterpret_cast(LoadEntry("glXCreateContextAttribsARB", false)); - #endif - - Context loadContext; - if (!loadContext.Create(parameters)) - { - NazaraError("Failed to create load context"); - return false; - } - - #if defined(NAZARA_PLATFORM_WINDOWS) - wglCreateContextAttribs = reinterpret_cast(LoadEntry("wglCreateContextAttribsARB", false)); - wglChoosePixelFormat = reinterpret_cast(LoadEntry("wglChoosePixelFormatARB", false)); - if (!wglChoosePixelFormat) - wglChoosePixelFormat = reinterpret_cast(LoadEntry("wglChoosePixelFormatEXT", false)); - #endif - - // Récupération de la version d'OpenGL et du GLSL - // Ce code se base sur le fait que la carte graphique renverra un contexte de compatibilité avec la plus haute version supportée - // Ce qui semble vrai chez AMD, NVidia et Intel, mais j'aimerai une preuve que ça sera toujours le cas... - glGetString = reinterpret_cast(LoadEntry("glGetString", false)); - if (!glGetString) - { - NazaraError("Unable to load OpenGL: failed to load glGetString"); - return false; - } - - const GLubyte* version; - unsigned int major; - unsigned int minor; - - version = glGetString(GL_VERSION); - if (!version) - { - NazaraError("Unable to retrieve OpenGL version"); - return false; - } - - major = version[0] - '0'; - minor = version[2] - '0'; - - if (major == 0 || major > 9) - { - NazaraError("Unable to retrieve OpenGL major version"); - return false; - } - - if (minor > 9) // 0 est une valeur correcte ici (ex: OpenGL 3.0) - { - NazaraWarning("Unable to retrieve OpenGL minor version (assuming 0)"); - minor = 0; - } - - s_openglVersion = major * 100 + minor * 10; // Donnera 330 pour OpenGL 3.3, 410 pour OpenGL 4.1, bien plus facile à comparer - - NazaraDebug("OpenGL version: " + String::Number(major) + '.' + String::Number(minor)); - - // Le moteur nécessite OpenGL 3.3, autant s'arrêter là si ce n'est pas le cas - if (s_openglVersion < 330) - { - NazaraError("OpenGL " + String::Number(major) + '.' + String::Number(minor) + " detected (3.3 required). Please upgrade your drivers or your video card"); - return false; - } - - // Récupération de la version du GLSL, même technique - version = glGetString(GL_SHADING_LANGUAGE_VERSION); - if (!version) - { - NazaraError("Unable to retrieve GLSL version"); - return false; - } - - major = version[0] - '0'; - minor = version[2] - '0'; - - if (major == 0 || major > 9) - { - NazaraError("Unable to retrieve GLSL major version"); - return false; - } - - if (minor > 9) // 0 est une valeur correcte ici (ex: GLSL 4.0) - { - NazaraWarning("Unable to retrieve GLSL minor version (using 0)"); - minor = 0; - } - - s_glslVersion = major * 100 + minor * 10; // GLSL 3.3 => 330 - - // Normalement rejeté il y a un moment déjà, mais on doit s'attendre à tout de la part d'un driver... - if (s_glslVersion < 330) - { - NazaraError("GLSL version is too low, please upgrade your drivers or your video card"); - return false; - } - - parameters.debugMode = true; // Certaines extensions n'apparaissent qu'avec un contexte de debug (e.g. ARB_debug_output) - parameters.majorVersion = ContextParameters::defaultMajorVersion = major; - parameters.minorVersion = ContextParameters::defaultMinorVersion = minor; - - if (!loadContext.Create(parameters)) // Destruction implicite du premier contexte - { - NazaraError("Failed to create load context"); - return false; - } - - /****************************************Noyau****************************************/ - - try - { - glActiveTexture = reinterpret_cast(LoadEntry("glActiveTexture")); - glAttachShader = reinterpret_cast(LoadEntry("glAttachShader")); - glBeginConditionalRender = reinterpret_cast(LoadEntry("glBeginConditionalRender")); - glBeginQuery = reinterpret_cast(LoadEntry("glBeginQuery")); - glBindAttribLocation = reinterpret_cast(LoadEntry("glBindAttribLocation")); - glBindBuffer = reinterpret_cast(LoadEntry("glBindBuffer")); - glBindFragDataLocation = reinterpret_cast(LoadEntry("glBindFragDataLocation")); - glBindFramebuffer = reinterpret_cast(LoadEntry("glBindFramebuffer")); - glBindRenderbuffer = reinterpret_cast(LoadEntry("glBindRenderbuffer")); - glBindSampler = reinterpret_cast(LoadEntry("glBindSampler")); - glBindTexture = reinterpret_cast(LoadEntry("glBindTexture")); - glBindVertexArray = reinterpret_cast(LoadEntry("glBindVertexArray")); - glBlendFunc = reinterpret_cast(LoadEntry("glBlendFunc")); - glBlendFuncSeparate = reinterpret_cast(LoadEntry("glBlendFuncSeparate")); - glBlitFramebuffer = reinterpret_cast(LoadEntry("glBlitFramebuffer")); - glBufferData = reinterpret_cast(LoadEntry("glBufferData")); - glBufferSubData = reinterpret_cast(LoadEntry("glBufferSubData")); - glClear = reinterpret_cast(LoadEntry("glClear")); - glClearColor = reinterpret_cast(LoadEntry("glClearColor")); - glClearDepth = reinterpret_cast(LoadEntry("glClearDepth")); - glClearStencil = reinterpret_cast(LoadEntry("glClearStencil")); - glCheckFramebufferStatus = reinterpret_cast(LoadEntry("glCheckFramebufferStatus")); - glCreateProgram = reinterpret_cast(LoadEntry("glCreateProgram")); - glCreateShader = reinterpret_cast(LoadEntry("glCreateShader")); - glColorMask = reinterpret_cast(LoadEntry("glColorMask")); - glCompressedTexSubImage1D = reinterpret_cast(LoadEntry("glCompressedTexSubImage1D")); - glCompressedTexSubImage2D = reinterpret_cast(LoadEntry("glCompressedTexSubImage2D")); - glCompressedTexSubImage3D = reinterpret_cast(LoadEntry("glCompressedTexSubImage3D")); - glCullFace = reinterpret_cast(LoadEntry("glCullFace")); - glCompileShader = reinterpret_cast(LoadEntry("glCompileShader")); - glCopyTexSubImage2D = reinterpret_cast(LoadEntry("glCopyTexSubImage2D")); - glDeleteBuffers = reinterpret_cast(LoadEntry("glDeleteBuffers")); - glDeleteFramebuffers = reinterpret_cast(LoadEntry("glDeleteFramebuffers")); - glDeleteQueries = reinterpret_cast(LoadEntry("glDeleteQueries")); - glDeleteProgram = reinterpret_cast(LoadEntry("glDeleteProgram")); - glDeleteRenderbuffers = reinterpret_cast(LoadEntry("glDeleteRenderbuffers")); - glDeleteSamplers = reinterpret_cast(LoadEntry("glDeleteSamplers")); - glDeleteShader = reinterpret_cast(LoadEntry("glDeleteShader")); - glDeleteTextures = reinterpret_cast(LoadEntry("glDeleteTextures")); - glDeleteVertexArrays = reinterpret_cast(LoadEntry("glDeleteVertexArrays")); - glDepthFunc = reinterpret_cast(LoadEntry("glDepthFunc")); - glDepthMask = reinterpret_cast(LoadEntry("glDepthMask")); - glDisable = reinterpret_cast(LoadEntry("glDisable")); - glDisableVertexAttribArray = reinterpret_cast(LoadEntry("glDisableVertexAttribArray")); - glDrawArrays = reinterpret_cast(LoadEntry("glDrawArrays")); - glDrawArraysInstanced = reinterpret_cast(LoadEntry("glDrawArraysInstanced")); - glDrawBuffer = reinterpret_cast(LoadEntry("glDrawBuffer")); - glDrawBuffers = reinterpret_cast(LoadEntry("glDrawBuffers")); - glDrawElements = reinterpret_cast(LoadEntry("glDrawElements")); - glDrawElementsInstanced = reinterpret_cast(LoadEntry("glDrawElementsInstanced")); - glEnable = reinterpret_cast(LoadEntry("glEnable")); - glEnableVertexAttribArray = reinterpret_cast(LoadEntry("glEnableVertexAttribArray")); - glEndConditionalRender = reinterpret_cast(LoadEntry("glEndConditionalRender")); - glEndQuery = reinterpret_cast(LoadEntry("glEndQuery")); - glFlush = reinterpret_cast(LoadEntry("glFlush")); - glFramebufferRenderbuffer = reinterpret_cast(LoadEntry("glFramebufferRenderbuffer")); - glFramebufferTexture = reinterpret_cast(LoadEntry("glFramebufferTexture")); - glFramebufferTexture1D = reinterpret_cast(LoadEntry("glFramebufferTexture1D")); - glFramebufferTexture2D = reinterpret_cast(LoadEntry("glFramebufferTexture2D")); - glFramebufferTexture3D = reinterpret_cast(LoadEntry("glFramebufferTexture3D")); - glFramebufferTextureLayer = reinterpret_cast(LoadEntry("glFramebufferTextureLayer")); - glGenerateMipmap = reinterpret_cast(LoadEntry("glGenerateMipmap")); - glGenBuffers = reinterpret_cast(LoadEntry("glGenBuffers")); - glGenFramebuffers = reinterpret_cast(LoadEntry("glGenFramebuffers")); - glGenQueries = reinterpret_cast(LoadEntry("glGenQueries")); - glGenRenderbuffers = reinterpret_cast(LoadEntry("glGenRenderbuffers")); - glGenSamplers = reinterpret_cast(LoadEntry("glGenSamplers")); - glGenTextures = reinterpret_cast(LoadEntry("glGenTextures")); - glGenVertexArrays = reinterpret_cast(LoadEntry("glGenVertexArrays")); - glGetActiveUniform = reinterpret_cast(LoadEntry("glGetActiveUniform")); - glGetBooleanv = reinterpret_cast(LoadEntry("glGetBooleanv")); - glGetBufferParameteriv = reinterpret_cast(LoadEntry("glGetBufferParameteriv")); - glGetError = reinterpret_cast(LoadEntry("glGetError")); - glGetFloatv = reinterpret_cast(LoadEntry("glGetFloatv")); - glGetIntegerv = reinterpret_cast(LoadEntry("glGetIntegerv")); - glGetQueryiv = reinterpret_cast(LoadEntry("glGetQueryiv")); - glGetQueryObjectiv = reinterpret_cast(LoadEntry("glGetQueryObjectiv")); - glGetQueryObjectuiv = reinterpret_cast(LoadEntry("glGetQueryObjectuiv")); - glGetProgramiv = reinterpret_cast(LoadEntry("glGetProgramiv")); - glGetProgramInfoLog = reinterpret_cast(LoadEntry("glGetProgramInfoLog")); - glGetShaderInfoLog = reinterpret_cast(LoadEntry("glGetShaderInfoLog")); - glGetShaderiv = reinterpret_cast(LoadEntry("glGetShaderiv")); - glGetShaderSource = reinterpret_cast(LoadEntry("glGetShaderSource")); - glGetStringi = reinterpret_cast(LoadEntry("glGetStringi")); - glGetTexImage = reinterpret_cast(LoadEntry("glGetTexImage")); - glGetTexLevelParameterfv = reinterpret_cast(LoadEntry("glGetTexLevelParameterfv")); - glGetTexLevelParameteriv = reinterpret_cast(LoadEntry("glGetTexLevelParameteriv")); - glGetTexParameterfv = reinterpret_cast(LoadEntry("glGetTexParameterfv")); - glGetTexParameteriv = reinterpret_cast(LoadEntry("glGetTexParameteriv")); - glGetUniformLocation = reinterpret_cast(LoadEntry("glGetUniformLocation")); - glIsEnabled = reinterpret_cast(LoadEntry("glIsEnabled")); - glLineWidth = reinterpret_cast(LoadEntry("glLineWidth")); - glLinkProgram = reinterpret_cast(LoadEntry("glLinkProgram")); - glMapBuffer = reinterpret_cast(LoadEntry("glMapBuffer")); - glMapBufferRange = reinterpret_cast(LoadEntry("glMapBufferRange")); - glPixelStorei = reinterpret_cast(LoadEntry("glPixelStorei")); - glPointSize = reinterpret_cast(LoadEntry("glPointSize")); - glPolygonMode = reinterpret_cast(LoadEntry("glPolygonMode")); - glReadPixels = reinterpret_cast(LoadEntry("glReadPixels")); - glRenderbufferStorage = reinterpret_cast(LoadEntry("glRenderbufferStorage")); - glSamplerParameterf = reinterpret_cast(LoadEntry("glSamplerParameterf")); - glSamplerParameteri = reinterpret_cast(LoadEntry("glSamplerParameteri")); - glScissor = reinterpret_cast(LoadEntry("glScissor")); - glShaderSource = reinterpret_cast(LoadEntry("glShaderSource")); - glStencilFunc = reinterpret_cast(LoadEntry("glStencilFunc")); - glStencilFuncSeparate = reinterpret_cast(LoadEntry("glStencilFuncSeparate")); - glStencilOp = reinterpret_cast(LoadEntry("glStencilOp")); - glStencilOpSeparate = reinterpret_cast(LoadEntry("glStencilOpSeparate")); - glTexImage2D = reinterpret_cast(LoadEntry("glTexImage2D")); - glTexImage3D = reinterpret_cast(LoadEntry("glTexImage3D")); - glTexParameterf = reinterpret_cast(LoadEntry("glTexParameterf")); - glTexParameteri = reinterpret_cast(LoadEntry("glTexParameteri")); - glTexSubImage1D = reinterpret_cast(LoadEntry("glTexSubImage1D")); - glTexSubImage2D = reinterpret_cast(LoadEntry("glTexSubImage2D")); - glTexSubImage3D = reinterpret_cast(LoadEntry("glTexSubImage3D")); - glUniform1f = reinterpret_cast(LoadEntry("glUniform1f")); - glUniform1i = reinterpret_cast(LoadEntry("glUniform1i")); - glUniform1fv = reinterpret_cast(LoadEntry("glUniform1fv")); - glUniform1iv = reinterpret_cast(LoadEntry("glUniform1iv")); - glUniform2fv = reinterpret_cast(LoadEntry("glUniform2fv")); - glUniform2iv = reinterpret_cast(LoadEntry("glUniform2iv")); - glUniform3fv = reinterpret_cast(LoadEntry("glUniform3fv")); - glUniform3iv = reinterpret_cast(LoadEntry("glUniform3iv")); - glUniform4fv = reinterpret_cast(LoadEntry("glUniform4fv")); - glUniform4iv = reinterpret_cast(LoadEntry("glUniform4iv")); - glUniformMatrix4fv = reinterpret_cast(LoadEntry("glUniformMatrix4fv")); - glUnmapBuffer = reinterpret_cast(LoadEntry("glUnmapBuffer")); - glUseProgram = reinterpret_cast(LoadEntry("glUseProgram")); - glValidateProgram = reinterpret_cast(LoadEntry("glValidateProgram")); - glVertexAttrib4f = reinterpret_cast(LoadEntry("glVertexAttrib4f")); - glVertexAttribDivisor = reinterpret_cast(LoadEntry("glVertexAttribDivisor")); - glVertexAttribPointer = reinterpret_cast(LoadEntry("glVertexAttribPointer")); - glVertexAttribIPointer = reinterpret_cast(LoadEntry("glVertexAttribIPointer")); - glViewport = reinterpret_cast(LoadEntry("glViewport")); - } - catch (const std::exception& e) - { - NazaraError("Unable to load OpenGL: " + String(e.what())); - return false; - } - - /****************************************Extensions****************************************/ - - // Fonctions optionnelles - glBindFragDataLocation = reinterpret_cast(LoadEntry("glBindFragDataLocation")); - - glDrawTexture = reinterpret_cast(LoadEntry("glDrawTextureNV", false)); - glInvalidateBufferData = reinterpret_cast(LoadEntry("glInvalidateBufferData", false)); - glVertexAttribLPointer = reinterpret_cast(LoadEntry("glVertexAttribLPointer", false)); - - #if defined(NAZARA_PLATFORM_WINDOWS) - wglGetExtensionsStringARB = reinterpret_cast(LoadEntry("wglGetExtensionsStringARB", false)); - wglGetExtensionsStringEXT = reinterpret_cast(LoadEntry("wglGetExtensionsStringEXT", false)); - wglSwapInterval = reinterpret_cast(LoadEntry("wglSwapIntervalEXT", false)); - #elif defined(NAZARA_PLATFORM_GLX) - glXSwapIntervalEXT = reinterpret_cast(LoadEntry("glXSwapIntervalEXT", false)); - NzglXSwapIntervalMESA = reinterpret_cast(LoadEntry("glXSwapIntervalMESA", false)); - glXSwapIntervalSGI = reinterpret_cast(LoadEntry("glXSwapIntervalSGI", false)); - #endif - - if (!glGetStringi || !LoadExtensions3()) - { - NazaraWarning("Failed to load OpenGL 3 extension system, falling back to OpenGL 2 extension system..."); - - if (!LoadExtensionsString(reinterpret_cast(glGetString(GL_EXTENSIONS)))) - NazaraWarning("Failed to load extension system"); - } - - #ifdef NAZARA_PLATFORM_WINDOWS - { - bool loaded; - if (wglGetExtensionsStringARB) - loaded = LoadExtensionsString(reinterpret_cast(wglGetExtensionsStringARB(wglGetCurrentDC()))); - else if (wglGetExtensionsStringEXT) - loaded = LoadExtensionsString(reinterpret_cast(wglGetExtensionsStringEXT())); - else - loaded = false; - - if (!loaded) - NazaraWarning("Failed to load wgl extension string"); - } - #endif - - // AnisotropicFilter - s_openGLextensions[OpenGLExtension_AnisotropicFilter] = IsSupported("GL_EXT_texture_filter_anisotropic"); - - // DebugOutput - if (s_openglVersion >= 430 || IsSupported("GL_KHR_debug")) - { - try - { - glDebugMessageCallback = reinterpret_cast(LoadEntry("glDebugMessageCallback")); - glDebugMessageControl = reinterpret_cast(LoadEntry("glDebugMessageControl")); - glDebugMessageInsert = reinterpret_cast(LoadEntry("glDebugMessageInsert")); - glGetDebugMessageLog = reinterpret_cast(LoadEntry("glGetDebugMessageLog")); - - s_openGLextensions[OpenGLExtension_DebugOutput] = true; - } - catch (const std::exception& e) - { - NazaraWarning("Failed to load GL_KHR_debug: " + String(e.what())); - } - } - - if (!s_openGLextensions[OpenGLExtension_DebugOutput] && IsSupported("GL_ARB_debug_output")) - { - try - { - glDebugMessageCallback = reinterpret_cast(LoadEntry("glDebugMessageCallbackARB")); - glDebugMessageControl = reinterpret_cast(LoadEntry("glDebugMessageControlARB")); - glDebugMessageInsert = reinterpret_cast(LoadEntry("glDebugMessageInsertARB")); - glGetDebugMessageLog = reinterpret_cast(LoadEntry("glGetDebugMessageLogARB")); - - s_openGLextensions[OpenGLExtension_DebugOutput] = true; - } - catch (const std::exception& e) - { - NazaraWarning("Failed to load GL_ARB_debug_output: " + String(e.what())); - } - } - - // FP64 - if (s_openglVersion >= 400 || IsSupported("GL_ARB_gpu_shader_fp64")) - { - try - { - glUniform1d = reinterpret_cast(LoadEntry("glUniform1d")); - glUniform1dv = reinterpret_cast(LoadEntry("glUniform1dv")); - glUniform2dv = reinterpret_cast(LoadEntry("glUniform2dv")); - glUniform3dv = reinterpret_cast(LoadEntry("glUniform3dv")); - glUniform4dv = reinterpret_cast(LoadEntry("glUniform4dv")); - - s_openGLextensions[OpenGLExtension_FP64] = true; - } - catch (const std::exception& e) - { - NazaraWarning("Failed to load ARB_gpu_shader_fp64: " + String(e.what())); - } - } - - // GetProgramBinary - if (s_openglVersion >= 410 || IsSupported("GL_ARB_get_program_binary")) - { - try - { - glGetProgramBinary = reinterpret_cast(LoadEntry("glGetProgramBinary")); - glProgramBinary = reinterpret_cast(LoadEntry("glProgramBinary")); - glProgramParameteri = reinterpret_cast(LoadEntry("glProgramParameteri")); - - s_openGLextensions[OpenGLExtension_GetProgramBinary] = true; - } - catch (const std::exception& e) - { - NazaraWarning("Failed to load ARB_get_program_binary: (" + String(e.what()) + ")"); - } - } - - // SeparateShaderObjects - if (s_openglVersion >= 400 || IsSupported("GL_ARB_separate_shader_objects")) - { - try - { - glProgramUniform1f = reinterpret_cast(LoadEntry("glProgramUniform1f")); - glProgramUniform1i = reinterpret_cast(LoadEntry("glProgramUniform1i")); - glProgramUniform1fv = reinterpret_cast(LoadEntry("glProgramUniform1fv")); - glProgramUniform1iv = reinterpret_cast(LoadEntry("glProgramUniform1iv")); - glProgramUniform2fv = reinterpret_cast(LoadEntry("glProgramUniform2fv")); - glProgramUniform2iv = reinterpret_cast(LoadEntry("glProgramUniform2iv")); - glProgramUniform3fv = reinterpret_cast(LoadEntry("glProgramUniform3fv")); - glProgramUniform3iv = reinterpret_cast(LoadEntry("glProgramUniform3iv")); - glProgramUniform4fv = reinterpret_cast(LoadEntry("glProgramUniform4fv")); - glProgramUniform4iv = reinterpret_cast(LoadEntry("glProgramUniform4iv")); - glProgramUniformMatrix4fv = reinterpret_cast(LoadEntry("glProgramUniformMatrix4fv")); - - // Si ARB_gpu_shader_fp64 est supporté, alors cette extension donne également accès aux fonctions utilisant des double - if (s_openGLextensions[OpenGLExtension_FP64]) - { - glProgramUniform1d = reinterpret_cast(LoadEntry("glProgramUniform1d")); - glProgramUniform1dv = reinterpret_cast(LoadEntry("glProgramUniform1dv")); - glProgramUniform2dv = reinterpret_cast(LoadEntry("glProgramUniform2dv")); - glProgramUniform3dv = reinterpret_cast(LoadEntry("glProgramUniform3dv")); - glProgramUniform4dv = reinterpret_cast(LoadEntry("glProgramUniform4dv")); - glProgramUniformMatrix4dv = reinterpret_cast(LoadEntry("glProgramUniformMatrix4dv")); - } - - s_openGLextensions[OpenGLExtension_SeparateShaderObjects] = true; - } - catch (const std::exception& e) - { - NazaraWarning("Failed to load ARB_separate_shader_objects: (" + String(e.what()) + ")"); - } - } - - // Shader_ImageLoadStore - s_openGLextensions[OpenGLExtension_Shader_ImageLoadStore] = (s_openglVersion >= 420 || IsSupported("GL_ARB_shader_image_load_store")); - - // TextureCompression_s3tc - s_openGLextensions[OpenGLExtension_TextureCompression_s3tc] = IsSupported("GL_EXT_texture_compression_s3tc"); - - // TextureStorage - if (s_openglVersion >= 420 || IsSupported("GL_ARB_texture_storage")) - { - try - { - glTexStorage1D = reinterpret_cast(LoadEntry("glTexStorage1D")); - glTexStorage2D = reinterpret_cast(LoadEntry("glTexStorage2D")); - glTexStorage3D = reinterpret_cast(LoadEntry("glTexStorage3D")); - - s_openGLextensions[OpenGLExtension_TextureStorage] = true; - } - catch (const std::exception& e) - { - NazaraWarning("Failed to load ARB_texture_storage: " + String(e.what())); - } - } - - /******************************Initialisation*****************************/ - - s_contextStates = nullptr; - s_rendererName = reinterpret_cast(glGetString(GL_RENDERER)); - s_vendorName = reinterpret_cast(glGetString(GL_VENDOR)); - - // On initialise les vrais contextes OpenGL - if (!Context::Initialize()) - { - NazaraError("Failed to initialize contexts"); - return false; - } - - // Le contexte OpenGL n'est plus assuré à partir d'ici - onExit.Reset(); - - return true; - } - - bool OpenGL::IsInitialized() - { - return s_initialized; - } - - bool OpenGL::IsSupported(OpenGLExtension extension) - { - return s_openGLextensions[extension]; - } - - bool OpenGL::IsSupported(const String& string) - { - return s_openGLextensionSet.find(string) != s_openGLextensionSet.end(); - } - - void OpenGL::SetBuffer(BufferType type, GLuint id) - { - #ifdef NAZARA_DEBUG - if (!s_contextStates) - { - NazaraError("No context activated"); - return; - } - #endif - - s_contextStates->buffersBinding[type] = id; - } - - void OpenGL::SetScissorBox(const Recti& scissorBox) - { - #ifdef NAZARA_DEBUG - if (!s_contextStates) - { - NazaraError("No context activated"); - return; - } - #endif - - s_contextStates->currentScissorBox = scissorBox; - } - - void OpenGL::SetProgram(GLuint id) - { - #ifdef NAZARA_DEBUG - if (!s_contextStates) - { - NazaraError("No context activated"); - return; - } - #endif - - s_contextStates->currentProgram = id; - } - - void OpenGL::SetTarget(const RenderTarget* renderTarget) - { - #ifdef NAZARA_DEBUG - if (!s_contextStates) - { - NazaraError("No context activated"); - return; - } - #endif - - s_contextStates->currentTarget = renderTarget; - if (renderTarget) - { - if (!s_contextStates->scissorBoxUpdated) - { - const Recti& scissorBox = s_contextStates->currentViewport; - - unsigned int height = s_contextStates->currentTarget->GetHeight(); - glScissor(scissorBox.x, height - scissorBox.height - scissorBox.y, scissorBox.width, scissorBox.height); - - s_contextStates->scissorBoxUpdated = true; - } - - if (!s_contextStates->viewportUpdated) - { - const Recti& viewport = s_contextStates->currentViewport; - - unsigned int height = s_contextStates->currentTarget->GetHeight(); - glViewport(viewport.x, height - viewport.height - viewport.y, viewport.width, viewport.height); - - s_contextStates->viewportUpdated = true; - } - } - } - - void OpenGL::SetTexture(GLuint id) - { - #ifdef NAZARA_DEBUG - if (!s_contextStates) - { - NazaraError("No context activated"); - return; - } - #endif - - s_contextStates->texturesBinding[s_contextStates->textureUnit] = id; - } - - void OpenGL::SetTexture(unsigned int textureUnit, GLuint id) - { - #ifdef NAZARA_DEBUG - if (!s_contextStates) - { - NazaraError("No context activated"); - return; - } - #endif - - s_contextStates->texturesBinding[textureUnit] = id; - } - - void OpenGL::SetTextureUnit(unsigned int textureUnit) - { - #ifdef NAZARA_DEBUG - if (!s_contextStates) - { - NazaraError("No context activated"); - return; - } - #endif - - s_contextStates->textureUnit = textureUnit; - } - - void OpenGL::SetViewport(const Recti& viewport) - { - #ifdef NAZARA_DEBUG - if (!s_contextStates) - { - NazaraError("No context activated"); - return; - } - #endif - - s_contextStates->currentViewport = viewport; - } - - bool OpenGL::TranslateFormat(PixelFormatType pixelFormat, Format* format, FormatType type) - { - // Par défaut - format->swizzle[0] = GL_RED; - format->swizzle[1] = GL_GREEN; - format->swizzle[2] = GL_BLUE; - format->swizzle[3] = GL_ALPHA; - - switch (pixelFormat) - { - case PixelFormatType_A8: - if (type == FormatType_Texture) // Format supporté uniquement par les textures - { - if (GetVersion() >= 300) - { - format->dataFormat = GL_RED; - format->dataType = GL_UNSIGNED_BYTE; - format->internalFormat = GL_R8; - - // Simulation du format - format->swizzle[0] = GL_ONE; - format->swizzle[1] = GL_ONE; - format->swizzle[2] = GL_ONE; - format->swizzle[3] = GL_RED; - } - else - { - // Le bon vieux format GL_ALPHA - format->dataFormat = GL_ALPHA; - format->dataType = GL_UNSIGNED_BYTE; - format->internalFormat = GL_ALPHA; - } - - return true; - } - else - return false; - - case PixelFormatType_BGR8: - format->dataFormat = GL_BGR; - format->dataType = GL_UNSIGNED_BYTE; - format->internalFormat = GL_RGB8; - return true; - - case PixelFormatType_BGRA8: - format->dataFormat = GL_BGRA; - format->dataType = GL_UNSIGNED_BYTE; - format->internalFormat = GL_RGBA8; - return true; - - case PixelFormatType_DXT1: - format->dataFormat = GL_RGB; - format->dataType = GL_UNSIGNED_BYTE; - format->internalFormat = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; - return true; - - case PixelFormatType_DXT3: - format->dataFormat = GL_RGBA; - format->dataType = GL_UNSIGNED_BYTE; - format->internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; - return true; - - case PixelFormatType_DXT5: - format->dataFormat = GL_RGBA; - format->dataType = GL_UNSIGNED_BYTE; - format->internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; - return true; - - case PixelFormatType_L8: - if (type == FormatType_Texture) // Format supporté uniquement par les textures - { - if (GetVersion() >= 300) - { - format->dataFormat = GL_RED; - format->dataType = GL_UNSIGNED_BYTE; - format->internalFormat = GL_R8; - - // Simulation du format - format->swizzle[0] = GL_RED; - format->swizzle[1] = GL_RED; - format->swizzle[2] = GL_RED; - format->swizzle[3] = GL_ONE; - } - else - { - format->dataFormat = 0x1909; // GL_LUMINANCE - format->dataType = GL_UNSIGNED_BYTE; - format->internalFormat = 0x1909; // GL_LUMINANCE - } - - return true; - } - else - return false; - - case PixelFormatType_LA8: - if (type == FormatType_Texture) // Format supporté uniquement par les textures - { - if (GetVersion() >= 300) - { - format->dataFormat = GL_RG; - format->dataType = GL_UNSIGNED_BYTE; - format->internalFormat = GL_RG8; - - // Simulation du format - format->swizzle[0] = GL_RED; - format->swizzle[1] = GL_RED; - format->swizzle[2] = GL_RED; - format->swizzle[3] = GL_GREEN; - } - else - { - format->dataFormat = 0x190A; // GL_LUMINANCE_ALPHA - format->dataType = GL_UNSIGNED_BYTE; - format->internalFormat = 0x190A; // GL_LUMINANCE_ALPHA; - } - - return true; - } - else - return false; - - case PixelFormatType_R8: - format->dataFormat = GL_RED; - format->dataType = GL_UNSIGNED_BYTE; - format->internalFormat = GL_R8; - return true; - - case PixelFormatType_R8I: - format->dataFormat = GL_RED; - format->dataType = GL_BYTE; - format->internalFormat = GL_R8I; - return true; - - case PixelFormatType_R8UI: - format->dataFormat = GL_RED; - format->dataType = GL_UNSIGNED_BYTE; - format->internalFormat = GL_R8UI; - return true; - - case PixelFormatType_R16: - format->dataFormat = GL_RED; - format->dataType = GL_UNSIGNED_SHORT; - format->internalFormat = GL_R16; - return true; - - case PixelFormatType_R16F: - format->dataFormat = GL_RED; - format->dataType = GL_HALF_FLOAT; - format->internalFormat = GL_R16F; - return true; - - case PixelFormatType_R16I: - format->dataFormat = GL_RED; - format->dataType = GL_SHORT; - format->internalFormat = GL_R16I; - return true; - - case PixelFormatType_R16UI: - format->dataFormat = GL_RED; - format->dataType = GL_UNSIGNED_SHORT; - format->internalFormat = GL_R16UI; - return true; - - case PixelFormatType_R32F: - format->dataFormat = GL_RED; - format->dataType = GL_FLOAT; - format->internalFormat = GL_R32F; - return true; - - case PixelFormatType_R32I: - format->dataFormat = GL_RED; - format->dataType = GL_INT; - format->internalFormat = GL_R32I; - return true; - - case PixelFormatType_R32UI: - format->dataFormat = GL_RED; - format->dataType = GL_UNSIGNED_INT; - format->internalFormat = GL_R32UI; - return true; - - case PixelFormatType_RG8: - format->dataFormat = GL_RG; - format->dataType = GL_UNSIGNED_BYTE; - format->internalFormat = GL_RG8; - return true; - - case PixelFormatType_RG8I: - format->dataFormat = GL_RG; - format->dataType = GL_BYTE; - format->internalFormat = GL_RG8I; - return true; - - case PixelFormatType_RG8UI: - format->dataFormat = GL_RG; - format->dataType = GL_UNSIGNED_BYTE; - format->internalFormat = GL_RG8UI; - return true; - - case PixelFormatType_RG16: - format->dataFormat = GL_RG; - format->dataType = GL_UNSIGNED_SHORT; - format->internalFormat = GL_RG16; - return true; - - case PixelFormatType_RG16F: - format->dataFormat = GL_RG; - format->dataType = GL_HALF_FLOAT; - format->internalFormat = GL_RG16F; - return true; - - case PixelFormatType_RG16I: - format->dataFormat = GL_RG; - format->dataType = GL_SHORT; - format->internalFormat = GL_RG16I; - return true; - - case PixelFormatType_RG16UI: - format->dataFormat = GL_RG; - format->dataType = GL_UNSIGNED_SHORT; - format->internalFormat = GL_RG16UI; - return true; - - case PixelFormatType_RG32F: - format->dataFormat = GL_RG; - format->dataType = GL_FLOAT; - format->internalFormat = GL_RG32F; - return true; - - case PixelFormatType_RG32I: - format->dataFormat = GL_RG; - format->dataType = GL_INT; - format->internalFormat = GL_RG32I; - return true; - - case PixelFormatType_RG32UI: - format->dataFormat = GL_RG; - format->dataType = GL_UNSIGNED_INT; - format->internalFormat = GL_RG32UI; - return true; - - case PixelFormatType_RGB5A1: - format->dataFormat = GL_RGBA; - format->dataType = GL_UNSIGNED_SHORT_5_5_5_1; - format->internalFormat = GL_RGB5_A1; - return true; - - case PixelFormatType_RGB8: - format->dataFormat = GL_RGB; - format->dataType = GL_UNSIGNED_BYTE; - format->internalFormat = GL_RGB8; - return true; - - case PixelFormatType_RGB16F: - format->dataFormat = GL_RGB; - format->dataType = GL_HALF_FLOAT; - format->internalFormat = GL_RGB16F; - return true; - - case PixelFormatType_RGB16I: - format->dataFormat = GL_RGB; - format->dataType = GL_SHORT; - format->internalFormat = GL_RGB16I; - return true; - - case PixelFormatType_RGB16UI: - format->dataFormat = GL_RGB; - format->dataType = GL_UNSIGNED_SHORT; - format->internalFormat = GL_RGB16UI; - return true; - - case PixelFormatType_RGB32F: - format->dataFormat = GL_RGB; - format->dataType = GL_FLOAT; - format->internalFormat = GL_RGB32F; - return true; - - case PixelFormatType_RGB32I: - format->dataFormat = GL_RGB; - format->dataType = GL_INT; - format->internalFormat = GL_RGB32I; - return true; - - case PixelFormatType_RGB32UI: - format->dataFormat = GL_RGB; - format->dataType = GL_UNSIGNED_INT; - format->internalFormat = GL_RGB32UI; - return true; - - case PixelFormatType_RGBA4: - format->dataFormat = GL_RGBA; - format->dataType = GL_UNSIGNED_SHORT_4_4_4_4; - format->internalFormat = GL_RGBA4; - return true; - - case PixelFormatType_RGBA8: - format->dataFormat = GL_RGBA; - format->dataType = GL_UNSIGNED_BYTE; - format->internalFormat = GL_RGBA8; - return true; - - case PixelFormatType_RGBA16F: - format->dataFormat = GL_RGBA; - format->dataType = GL_HALF_FLOAT; - format->internalFormat = GL_RGBA16F; - return true; - - case PixelFormatType_RGBA16I: - format->dataFormat = GL_RGBA; - format->dataType = GL_SHORT; - format->internalFormat = GL_RGBA16I; - return true; - - case PixelFormatType_RGBA16UI: - format->dataFormat = GL_RGBA; - format->dataType = GL_INT; - format->internalFormat = GL_RGBA16UI; - return true; - - case PixelFormatType_RGBA32F: - format->dataFormat = GL_RGBA; - format->dataType = GL_FLOAT; - format->internalFormat = GL_RGBA32F; - return true; - - case PixelFormatType_RGBA32I: - format->dataFormat = GL_RGB; - format->dataType = GL_INT; - format->internalFormat = GL_RGB32I; - return true; - - case PixelFormatType_RGBA32UI: - format->dataFormat = GL_RGB; - format->dataType = GL_UNSIGNED_INT; - format->internalFormat = GL_RGB32UI; - return true; - - case PixelFormatType_Depth16: - format->dataFormat = GL_DEPTH_COMPONENT; - format->dataType = GL_UNSIGNED_SHORT; - format->internalFormat = GL_DEPTH_COMPONENT16; - - format->swizzle[0] = GL_RED; - format->swizzle[1] = GL_RED; - format->swizzle[2] = GL_RED; - format->swizzle[3] = GL_ONE; - return true; - - case PixelFormatType_Depth24: - format->dataFormat = GL_DEPTH_COMPONENT; - format->dataType = GL_UNSIGNED_INT; - format->internalFormat = GL_DEPTH_COMPONENT24; - - format->swizzle[0] = GL_RED; - format->swizzle[1] = GL_RED; - format->swizzle[2] = GL_RED; - format->swizzle[3] = GL_ONE; - return true; - - case PixelFormatType_Depth24Stencil8: - format->dataFormat = GL_DEPTH_STENCIL; - format->dataType = GL_UNSIGNED_INT_24_8; - format->internalFormat = GL_DEPTH24_STENCIL8; - - format->swizzle[0] = GL_RED; - format->swizzle[1] = GL_RED; - format->swizzle[2] = GL_RED; - format->swizzle[3] = GL_GREEN; - return true; - - case PixelFormatType_Depth32: - format->dataFormat = GL_DEPTH_COMPONENT; - format->dataType = GL_UNSIGNED_BYTE; - format->internalFormat = GL_DEPTH_COMPONENT32; - - format->swizzle[0] = GL_RED; - format->swizzle[1] = GL_RED; - format->swizzle[2] = GL_RED; - format->swizzle[3] = GL_ONE; - return true; - - case PixelFormatType_Stencil1: - if (type == FormatType_Texture) // Les formats de stencil ne sont pas supportés par les textures - return false; - else - { - format->dataFormat = GL_NONE; - format->dataType = GL_NONE; - format->internalFormat = GL_STENCIL_INDEX1; - return true; - } - - case PixelFormatType_Stencil4: - if (type == FormatType_Texture) - return false; - else - { - format->dataFormat = GL_NONE; - format->dataType = GL_NONE; - format->internalFormat = GL_STENCIL_INDEX4; - return true; - } - - case PixelFormatType_Stencil8: - if (type == FormatType_Texture) - return false; - else - { - format->dataFormat = GL_NONE; - format->dataType = GL_NONE; - format->internalFormat = GL_STENCIL_INDEX8; - return true; - } - - case PixelFormatType_Stencil16: - if (type == FormatType_Texture) - return false; - else - { - format->dataFormat = GL_NONE; - format->dataType = GL_NONE; - format->internalFormat = GL_STENCIL_INDEX16; - return true; - } - - case PixelFormatType_Undefined: - break; - } - - NazaraError("Invalid pixel format"); - return false; - } - - void OpenGL::Uninitialize() - { - if (s_initialized) - { - s_initialized = false; - - Context::Uninitialize(); - - for (bool& ext : s_openGLextensions) - ext = false; - - s_glslVersion = 0; - s_openGLextensionSet.clear(); - s_openglVersion = 0; - s_rendererName.Clear(false); - s_vendorName.Clear(false); - - UnloadLibrary(); - } - } - - void OpenGL::OnContextChanged(const Context* newContext) - { - s_contextStates = (newContext) ? &s_contexts[newContext] : nullptr; - if (s_contextStates) - { - // On supprime les éventuelles ressources mortes-vivantes (Qui ne peuvent être libérées que dans notre contexte) - for (std::pair& pair : s_contextStates->garbage) - { - switch (pair.first) - { - case GarbageResourceType_FrameBuffer: - glDeleteFramebuffers(1, &pair.second); - break; - - case GarbageResourceType_VertexArray: - glDeleteVertexArrays(1, &pair.second); - break; - } - } - s_contextStates->garbage.clear(); - } - } - - void OpenGL::OnContextDestruction(const Context* context) - { - /* - ** Il serait possible d'activer le contexte avant sa destruction afin de libérer les éventuelles ressources mortes-vivantes, - ** mais un driver bien conçu va libérer ces ressources de lui-même. - */ - s_contexts.erase(context); - } - - GLenum OpenGL::Attachment[] = - { - GL_COLOR_ATTACHMENT0, // AttachmentPoint_Color - GL_DEPTH_ATTACHMENT, // AttachmentPoint_Depth - GL_DEPTH_STENCIL_ATTACHMENT, // AttachmentPoint_DepthStencil - GL_STENCIL_ATTACHMENT // AttachmentPoint_Stencil - }; - - static_assert(AttachmentPoint_Max + 1 == 4, "Attachment array is incomplete"); - - GLenum OpenGL::BlendFunc[] = - { - GL_DST_ALPHA, // BlendFunc_DestAlpha - GL_DST_COLOR, // BlendFunc_DestColor - GL_SRC_ALPHA, // BlendFunc_SrcAlpha - GL_SRC_COLOR, // BlendFunc_SrcColor - GL_ONE_MINUS_DST_ALPHA, // BlendFunc_InvDestAlpha - GL_ONE_MINUS_DST_COLOR, // BlendFunc_InvDestColor - GL_ONE_MINUS_SRC_ALPHA, // BlendFunc_InvSrcAlpha - GL_ONE_MINUS_SRC_COLOR, // BlendFunc_InvSrcColor - GL_ONE, // BlendFunc_One - GL_ZERO // BlendFunc_Zero - }; - - static_assert(BlendFunc_Max + 1 == 10, "Blend func array is incomplete"); - - GLenum OpenGL::BufferLock[] = - { - GL_WRITE_ONLY, // BufferAccess_DiscardAndWrite - GL_READ_ONLY, // BufferAccess_ReadOnly - GL_READ_WRITE, // BufferAccess_ReadWrite - GL_WRITE_ONLY // BufferAccess_WriteOnly - }; - - static_assert(BufferAccess_Max + 1 == 4, "Buffer lock array is incomplete"); - - GLenum OpenGL::BufferLockRange[] = - { - // http://www.opengl.org/discussion_boards/showthread.php/170118-VBOs-strangely-slow?p=1198118#post1198118 - GL_MAP_INVALIDATE_BUFFER_BIT | GL_MAP_INVALIDATE_RANGE_BIT | GL_MAP_WRITE_BIT, // BufferAccess_DiscardAndWrite - GL_MAP_READ_BIT, // BufferAccess_ReadOnly - GL_MAP_READ_BIT | GL_MAP_WRITE_BIT, // BufferAccess_ReadWrite - GL_MAP_WRITE_BIT // BufferAccess_WriteOnly - }; - - static_assert(BufferAccess_Max + 1 == 4, "Buffer lock range array is incomplete"); - - GLenum OpenGL::BufferTarget[] = - { - GL_ELEMENT_ARRAY_BUFFER, // BufferType_Index, - GL_ARRAY_BUFFER, // BufferType_Vertex - }; - - static_assert(BufferType_Max + 1 == 2, "Buffer target array is incomplete"); - - GLenum OpenGL::BufferTargetBinding[] = - { - GL_ELEMENT_ARRAY_BUFFER_BINDING, // BufferType_Index, - GL_ARRAY_BUFFER_BINDING, // BufferType_Vertex - }; - - static_assert(BufferType_Max + 1 == 2, "Buffer target binding array is incomplete"); - - GLenum OpenGL::BufferUsage[] = - { - // D'après la documentation, GL_STREAM_DRAW semble être plus adapté à notre cas (ratio modification/rendu 1:2-3) - // Source: http://www.opengl.org/sdk/docs/man/html/glBufferData.xhtml - GL_STREAM_DRAW, // BufferUsage_Dynamic - GL_STATIC_DRAW // BufferUsage_Static - }; - - static_assert(BufferUsage_Max + 1 == 2, "Buffer usage array is incomplete"); - - GLenum OpenGL::ComponentType[] = - { - GL_UNSIGNED_BYTE, // ComponentType_Color - GL_DOUBLE, // ComponentType_Double1 - GL_DOUBLE, // ComponentType_Double2 - GL_DOUBLE, // ComponentType_Double3 - GL_DOUBLE, // ComponentType_Double4 - GL_FLOAT, // ComponentType_Float1 - GL_FLOAT, // ComponentType_Float2 - GL_FLOAT, // ComponentType_Float3 - GL_FLOAT, // ComponentType_Float4 - GL_INT, // ComponentType_Int1 - GL_INT, // ComponentType_Int2 - GL_INT, // ComponentType_Int3 - GL_INT, // ComponentType_Int4 - GL_FLOAT // ComponentType_Quaternion - }; - - static_assert(ComponentType_Max + 1 == 14, "Attribute type array is incomplete"); - - GLenum OpenGL::CubemapFace[] = - { - GL_TEXTURE_CUBE_MAP_POSITIVE_X, // CubemapFace_PositiveX - GL_TEXTURE_CUBE_MAP_NEGATIVE_X, // CubemapFace_NegativeX - GL_TEXTURE_CUBE_MAP_POSITIVE_Y, // CubemapFace_PositiveY - GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, // CubemapFace_NegativeY - GL_TEXTURE_CUBE_MAP_POSITIVE_Z, // CubemapFace_PositiveZ - GL_TEXTURE_CUBE_MAP_NEGATIVE_Z // CubemapFace_NegativeZ - }; - - static_assert(CubemapFace_Max + 1 == 6, "Cubemap face array is incomplete"); - - GLenum OpenGL::FaceFilling[] = - { - GL_FILL, // FaceFilling_Fill - GL_LINE, // FaceFilling_Line - GL_POINT // FaceFilling_Point - }; - - static_assert(FaceFilling_Max + 1 == 3, "Face filling array is incomplete"); - - GLenum OpenGL::FaceSide[] = - { - GL_BACK, // FaceSide_Back - GL_FRONT, // FaceSide_Front - GL_FRONT_AND_BACK // FaceSide_FrontAndBack - }; - - static_assert(FaceSide_Max + 1 == 3, "Face side array is incomplete"); - - GLenum OpenGL::PrimitiveMode[] = - { - GL_LINES, // PrimitiveMode_LineList - GL_LINE_STRIP, // PrimitiveMode_LineStrip - GL_POINTS, // PrimitiveMode_PointList - GL_TRIANGLES, // PrimitiveMode_TriangleList - GL_TRIANGLE_STRIP, // PrimitiveMode_TriangleStrip - GL_TRIANGLE_FAN // PrimitiveMode_TriangleFan - }; - - static_assert(PrimitiveMode_Max + 1 == 6, "Primitive mode array is incomplete"); - - GLenum OpenGL::QueryCondition[] = - { - GL_QUERY_WAIT, // GpuQueryCondition_NoWait - GL_QUERY_BY_REGION_NO_WAIT, // GpuQueryCondition_Region_NoWait - GL_QUERY_BY_REGION_WAIT, // GpuQueryCondition_Region_Wait - GL_QUERY_WAIT // GpuQueryCondition_Wait - }; - - static_assert(GpuQueryCondition_Max + 1 == 4, "Query condition array is incomplete"); - - GLenum OpenGL::QueryMode[] = - { - GL_ANY_SAMPLES_PASSED, // GpuQueryMode_AnySamplesPassed - GL_ANY_SAMPLES_PASSED_CONSERVATIVE, // GpuQueryMode_AnySamplesPassedConservative - GL_PRIMITIVES_GENERATED, // GpuQueryMode_PrimitiveGenerated - GL_SAMPLES_PASSED, // GpuQueryMode_SamplesPassed - GL_TIME_ELAPSED, // GpuQueryMode_TimeElapsed - GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN // GpuQueryMode_TransformFeedbackPrimitivesWritten - }; - - static_assert(GpuQueryMode_Max + 1 == 6, "Query mode array is incomplete"); - - GLenum OpenGL::RendererComparison[] = - { - GL_ALWAYS, // RendererComparison_Always - GL_EQUAL, // RendererComparison_Equal - GL_GREATER, // RendererComparison_Greater - GL_GEQUAL, // RendererComparison_GreaterOrEqual - GL_LESS, // RendererComparison_Less - GL_LEQUAL, // RendererComparison_LessOrEqual - GL_NEVER, // RendererComparison_Never - GL_NOTEQUAL // RendererComparison_NotEqual - }; - - static_assert(RendererComparison_Max + 1 == 8, "Renderer comparison array is incomplete"); - - GLenum OpenGL::RendererParameter[] = - { - GL_BLEND, // RendererParameter_Blend - GL_NONE, // RendererParameter_ColorWrite - GL_DEPTH_TEST, // RendererParameter_DepthBuffer - GL_NONE, // RendererParameter_DepthWrite - GL_CULL_FACE, // RendererParameter_FaceCulling - GL_SCISSOR_TEST, // RendererParameter_ScissorTest - GL_STENCIL_TEST // RendererParameter_StencilTest - }; - - static_assert(RendererParameter_Max + 1 == 7, "Renderer parameter array is incomplete"); - - GLenum OpenGL::SamplerWrapMode[] = - { - GL_CLAMP_TO_EDGE, // TextureWrap_Clamp - GL_MIRRORED_REPEAT, // SamplerWrap_MirroredRepeat - GL_REPEAT // TextureWrap_Repeat - }; - - static_assert(SamplerWrap_Max + 1 == 3, "Sampler wrap mode array is incomplete"); - - GLenum OpenGL::ShaderStage[] = - { - GL_FRAGMENT_SHADER, // ShaderStage_Fragment - GL_GEOMETRY_SHADER, // ShaderStage_Geometry - GL_VERTEX_SHADER // ShaderStage_Vertex - }; - - static_assert(ShaderStageType_Max + 1 == 3, "Shader stage array is incomplete"); - - GLenum OpenGL::StencilOperation[] = - { - GL_DECR, // StencilOperation_Decrement - GL_DECR_WRAP, // StencilOperation_DecrementNoClamp - GL_INCR, // StencilOperation_Increment - GL_INCR_WRAP, // StencilOperation_IncrementNoClamp - GL_INVERT, // StencilOperation_Invert - GL_KEEP, // StencilOperation_Keep - GL_REPLACE, // StencilOperation_Replace - GL_ZERO // StencilOperation_Zero - }; - - static_assert(StencilOperation_Max + 1 == 8, "Stencil operation array is incomplete"); - - GLenum OpenGL::TextureTarget[] = - { - GL_TEXTURE_1D, // ImageType_1D - GL_TEXTURE_1D_ARRAY, // ImageType_1D_Array - GL_TEXTURE_2D, // ImageType_2D - GL_TEXTURE_2D_ARRAY, // ImageType_2D_Array - GL_TEXTURE_3D, // ImageType_3D - GL_TEXTURE_CUBE_MAP // ImageType_Cubemap - }; - - static_assert(ImageType_Max + 1 == 6, "Texture target array is incomplete"); - - GLenum OpenGL::TextureTargetBinding[] = - { - GL_TEXTURE_BINDING_1D, // ImageType_1D - GL_TEXTURE_BINDING_1D_ARRAY, // ImageType_1D_Array - GL_TEXTURE_BINDING_2D, // ImageType_2D - GL_TEXTURE_BINDING_2D_ARRAY, // ImageType_2D_Array - GL_TEXTURE_BINDING_3D, // ImageType_3D - GL_TEXTURE_BINDING_CUBE_MAP // ImageType_Cubemap - }; - - static_assert(ImageType_Max + 1 == 6, "Texture target binding array is incomplete"); - - GLenum OpenGL::TextureTargetProxy[] = - { - GL_PROXY_TEXTURE_1D, // ImageType_1D - GL_PROXY_TEXTURE_1D_ARRAY, // ImageType_1D_Array - GL_PROXY_TEXTURE_2D, // ImageType_2D - GL_PROXY_TEXTURE_2D_ARRAY, // ImageType_2D_Array - GL_PROXY_TEXTURE_3D, // ImageType_3D - GL_PROXY_TEXTURE_CUBE_MAP // ImageType_Cubemap - }; - - static_assert(ImageType_Max + 1 == 6, "Texture target proxy array is incomplete"); - - UInt8 OpenGL::VertexComponentIndex[] = - { - 10, // VertexComponent_InstanceData0 - 11, // VertexComponent_InstanceData1 - 12, // VertexComponent_InstanceData2 - 13, // VertexComponent_InstanceData3 - 14, // VertexComponent_InstanceData4 - 15, // VertexComponent_InstanceData5 - 4, // VertexComponent_Color - 2, // VertexComponent_Normal - 0, // VertexComponent_Position - 3, // VertexComponent_Tangent - 1, // VertexComponent_TexCoord - 5, // VertexComponent_Userdata0 - 6, // VertexComponent_Userdata1 - 7, // VertexComponent_Userdata2 - 8, // VertexComponent_Userdata3 - 9 // VertexComponent_Userdata4 - }; - - static_assert(VertexComponent_Max + 1 == 16, "Attribute index array is incomplete"); - -PFNGLACTIVETEXTUREPROC glActiveTexture = nullptr; -PFNGLATTACHSHADERPROC glAttachShader = nullptr; -PFNGLBEGINCONDITIONALRENDERPROC glBeginConditionalRender = nullptr; -PFNGLBEGINQUERYPROC glBeginQuery = nullptr; -PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation = nullptr; -PFNGLBINDBUFFERPROC glBindBuffer = nullptr; -PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer = nullptr; -PFNGLBINDFRAGDATALOCATIONPROC glBindFragDataLocation = nullptr; -PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer = nullptr; -PFNGLBINDSAMPLERPROC glBindSampler = nullptr; -PFNGLBINDTEXTUREPROC glBindTexture = nullptr; -PFNGLBINDVERTEXARRAYPROC glBindVertexArray = nullptr; -PFNGLBLENDFUNCPROC glBlendFunc = nullptr; -PFNGLBLENDFUNCSEPARATEPROC glBlendFuncSeparate = nullptr; -PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer = nullptr; -PFNGLBUFFERDATAPROC glBufferData = nullptr; -PFNGLBUFFERSUBDATAPROC glBufferSubData = nullptr; -PFNGLCLEARPROC glClear = nullptr; -PFNGLCLEARCOLORPROC glClearColor = nullptr; -PFNGLCLEARDEPTHPROC glClearDepth = nullptr; -PFNGLCLEARSTENCILPROC glClearStencil = nullptr; -PFNGLCREATEPROGRAMPROC glCreateProgram = nullptr; -PFNGLCREATESHADERPROC glCreateShader = nullptr; -PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus = nullptr; -PFNGLCOLORMASKPROC glColorMask = nullptr; -PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glCompressedTexSubImage1D = nullptr; -PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glCompressedTexSubImage2D = nullptr; -PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glCompressedTexSubImage3D = nullptr; -PFNGLCULLFACEPROC glCullFace = nullptr; -PFNGLCOMPILESHADERPROC glCompileShader = nullptr; -PFNGLCOPYTEXSUBIMAGE2DPROC glCopyTexSubImage2D = nullptr; -PFNGLDEBUGMESSAGECALLBACKPROC glDebugMessageCallback = nullptr; -PFNGLDEBUGMESSAGECONTROLPROC glDebugMessageControl = nullptr; -PFNGLDEBUGMESSAGEINSERTPROC glDebugMessageInsert = nullptr; -PFNGLDELETEBUFFERSPROC glDeleteBuffers = nullptr; -PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers = nullptr; -PFNGLDELETEPROGRAMPROC glDeleteProgram = nullptr; -PFNGLDELETEQUERIESPROC glDeleteQueries = nullptr; -PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers = nullptr; -PFNGLDELETESAMPLERSPROC glDeleteSamplers = nullptr; -PFNGLDELETESHADERPROC glDeleteShader = nullptr; -PFNGLDELETETEXTURESPROC glDeleteTextures = nullptr; -PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays = nullptr; -PFNGLDEPTHFUNCPROC glDepthFunc = nullptr; -PFNGLDEPTHMASKPROC glDepthMask = nullptr; -PFNGLDISABLEPROC glDisable = nullptr; -PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray = nullptr; -PFNGLDRAWARRAYSPROC glDrawArrays = nullptr; -PFNGLDRAWARRAYSINSTANCEDPROC glDrawArraysInstanced = nullptr; -PFNGLDRAWBUFFERPROC glDrawBuffer = nullptr; -PFNGLDRAWBUFFERSPROC glDrawBuffers = nullptr; -PFNGLDRAWELEMENTSPROC glDrawElements = nullptr; -PFNGLDRAWELEMENTSINSTANCEDPROC glDrawElementsInstanced = nullptr; -PFNGLDRAWTEXTURENVPROC glDrawTexture = nullptr; -PFNGLENABLEPROC glEnable = nullptr; -PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray = nullptr; -PFNGLENDCONDITIONALRENDERPROC glEndConditionalRender = nullptr; -PFNGLENDQUERYPROC glEndQuery = nullptr; -PFNGLFLUSHPROC glFlush = nullptr; -PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer = nullptr; -PFNGLFRAMEBUFFERTEXTUREPROC glFramebufferTexture = nullptr; -PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D = nullptr; -PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D = nullptr; -PFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D = nullptr; -PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer = nullptr; -PFNGLGENERATEMIPMAPPROC glGenerateMipmap = nullptr; -PFNGLGENBUFFERSPROC glGenBuffers = nullptr; -PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers = nullptr; -PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers = nullptr; -PFNGLGENQUERIESPROC glGenQueries = nullptr; -PFNGLGENSAMPLERSPROC glGenSamplers = nullptr; -PFNGLGENTEXTURESPROC glGenTextures = nullptr; -PFNGLGENVERTEXARRAYSPROC glGenVertexArrays = nullptr; -PFNGLGETACTIVEUNIFORMPROC glGetActiveUniform = nullptr; -PFNGLGETBOOLEANVPROC glGetBooleanv = nullptr; -PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv = nullptr; -PFNGLGETDEBUGMESSAGELOGPROC glGetDebugMessageLog = nullptr; -PFNGLGETERRORPROC glGetError = nullptr; -PFNGLGETFLOATVPROC glGetFloatv = nullptr; -PFNGLGETINTEGERVPROC glGetIntegerv = nullptr; -PFNGLGETPROGRAMBINARYPROC glGetProgramBinary = nullptr; -PFNGLGETPROGRAMIVPROC glGetProgramiv = nullptr; -PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog = nullptr; -PFNGLGETQUERYIVPROC glGetQueryiv = nullptr; -PFNGLGETQUERYOBJECTIVPROC glGetQueryObjectiv = nullptr; -PFNGLGETQUERYOBJECTUIVPROC glGetQueryObjectuiv = nullptr; -PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog = nullptr; -PFNGLGETSHADERIVPROC glGetShaderiv = nullptr; -PFNGLGETSHADERSOURCEPROC glGetShaderSource = nullptr; -PFNGLGETSTRINGPROC glGetString = nullptr; -PFNGLGETSTRINGIPROC glGetStringi = nullptr; -PFNGLGETTEXIMAGEPROC glGetTexImage = nullptr; -PFNGLGETTEXLEVELPARAMETERFVPROC glGetTexLevelParameterfv = nullptr; -PFNGLGETTEXLEVELPARAMETERIVPROC glGetTexLevelParameteriv = nullptr; -PFNGLGETTEXPARAMETERFVPROC glGetTexParameterfv = nullptr; -PFNGLGETTEXPARAMETERIVPROC glGetTexParameteriv = nullptr; -PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation = nullptr; -PFNGLINVALIDATEBUFFERDATAPROC glInvalidateBufferData = nullptr; -PFNGLISENABLEDPROC glIsEnabled = nullptr; -PFNGLLINEWIDTHPROC glLineWidth = nullptr; -PFNGLLINKPROGRAMPROC glLinkProgram = nullptr; -PFNGLMAPBUFFERPROC glMapBuffer = nullptr; -PFNGLMAPBUFFERRANGEPROC glMapBufferRange = nullptr; -PFNGLPIXELSTOREIPROC glPixelStorei = nullptr; -PFNGLPOINTSIZEPROC glPointSize = nullptr; -PFNGLPOLYGONMODEPROC glPolygonMode = nullptr; -PFNGLPROGRAMBINARYPROC glProgramBinary = nullptr; -PFNGLPROGRAMPARAMETERIPROC glProgramParameteri = nullptr; -PFNGLPROGRAMUNIFORM1DPROC glProgramUniform1d = nullptr; -PFNGLPROGRAMUNIFORM1FPROC glProgramUniform1f = nullptr; -PFNGLPROGRAMUNIFORM1IPROC glProgramUniform1i = nullptr; -PFNGLPROGRAMUNIFORM1DVPROC glProgramUniform1dv = nullptr; -PFNGLPROGRAMUNIFORM1FVPROC glProgramUniform1fv = nullptr; -PFNGLPROGRAMUNIFORM1IVPROC glProgramUniform1iv = nullptr; -PFNGLPROGRAMUNIFORM2DVPROC glProgramUniform2dv = nullptr; -PFNGLPROGRAMUNIFORM2FVPROC glProgramUniform2fv = nullptr; -PFNGLPROGRAMUNIFORM2IVPROC glProgramUniform2iv = nullptr; -PFNGLPROGRAMUNIFORM3DVPROC glProgramUniform3dv = nullptr; -PFNGLPROGRAMUNIFORM3FVPROC glProgramUniform3fv = nullptr; -PFNGLPROGRAMUNIFORM3IVPROC glProgramUniform3iv = nullptr; -PFNGLPROGRAMUNIFORM4DVPROC glProgramUniform4dv = nullptr; -PFNGLPROGRAMUNIFORM4FVPROC glProgramUniform4fv = nullptr; -PFNGLPROGRAMUNIFORM4IVPROC glProgramUniform4iv = nullptr; -PFNGLPROGRAMUNIFORMMATRIX4DVPROC glProgramUniformMatrix4dv = nullptr; -PFNGLPROGRAMUNIFORMMATRIX4FVPROC glProgramUniformMatrix4fv = nullptr; -PFNGLREADPIXELSPROC glReadPixels = nullptr; -PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage = nullptr; -PFNGLSAMPLERPARAMETERFPROC glSamplerParameterf = nullptr; -PFNGLSAMPLERPARAMETERIPROC glSamplerParameteri = nullptr; -PFNGLSCISSORPROC glScissor = nullptr; -PFNGLSHADERSOURCEPROC glShaderSource = nullptr; -PFNGLSTENCILFUNCPROC glStencilFunc = nullptr; -PFNGLSTENCILFUNCSEPARATEPROC glStencilFuncSeparate = nullptr; -PFNGLSTENCILOPPROC glStencilOp = nullptr; -PFNGLSTENCILOPSEPARATEPROC glStencilOpSeparate = nullptr; -PFNGLTEXIMAGE1DPROC glTexImage1D = nullptr; -PFNGLTEXIMAGE2DPROC glTexImage2D = nullptr; -PFNGLTEXIMAGE3DPROC glTexImage3D = nullptr; -PFNGLTEXPARAMETERFPROC glTexParameterf = nullptr; -PFNGLTEXPARAMETERIPROC glTexParameteri = nullptr; -PFNGLTEXSTORAGE1DPROC glTexStorage1D = nullptr; -PFNGLTEXSTORAGE2DPROC glTexStorage2D = nullptr; -PFNGLTEXSTORAGE3DPROC glTexStorage3D = nullptr; -PFNGLTEXSUBIMAGE1DPROC glTexSubImage1D = nullptr; -PFNGLTEXSUBIMAGE2DPROC glTexSubImage2D = nullptr; -PFNGLTEXSUBIMAGE3DPROC glTexSubImage3D = nullptr; -PFNGLUNIFORM1DPROC glUniform1d = nullptr; -PFNGLUNIFORM1FPROC glUniform1f = nullptr; -PFNGLUNIFORM1IPROC glUniform1i = nullptr; -PFNGLUNIFORM1DVPROC glUniform1dv = nullptr; -PFNGLUNIFORM1FVPROC glUniform1fv = nullptr; -PFNGLUNIFORM1IVPROC glUniform1iv = nullptr; -PFNGLUNIFORM2DVPROC glUniform2dv = nullptr; -PFNGLUNIFORM2FVPROC glUniform2fv = nullptr; -PFNGLUNIFORM2IVPROC glUniform2iv = nullptr; -PFNGLUNIFORM3DVPROC glUniform3dv = nullptr; -PFNGLUNIFORM3FVPROC glUniform3fv = nullptr; -PFNGLUNIFORM3IVPROC glUniform3iv = nullptr; -PFNGLUNIFORM4DVPROC glUniform4dv = nullptr; -PFNGLUNIFORM4FVPROC glUniform4fv = nullptr; -PFNGLUNIFORM4IVPROC glUniform4iv = nullptr; -PFNGLUNIFORMMATRIX4DVPROC glUniformMatrix4dv = nullptr; -PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv = nullptr; -PFNGLUNMAPBUFFERPROC glUnmapBuffer = nullptr; -PFNGLUSEPROGRAMPROC glUseProgram = nullptr; -PFNGLVALIDATEPROGRAMPROC glValidateProgram = nullptr; -PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f = nullptr; -PFNGLVERTEXATTRIBDIVISORPROC glVertexAttribDivisor = nullptr; -PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer = nullptr; -PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer = nullptr; -PFNGLVERTEXATTRIBLPOINTERPROC glVertexAttribLPointer = nullptr; -PFNGLVIEWPORTPROC glViewport = nullptr; - -#if defined(NAZARA_PLATFORM_WINDOWS) -PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormat = nullptr; -PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs = nullptr; -PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = nullptr; -PFNWGLGETEXTENSIONSSTRINGEXTPROC wglGetExtensionsStringEXT = nullptr; -PFNWGLSWAPINTERVALEXTPROC wglSwapInterval = nullptr; -#elif defined(NAZARA_PLATFORM_GLX) -GLX::PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs = nullptr; -GLX::PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT = nullptr; -GLX::PFNGLXSWAPINTERVALMESAPROC NzglXSwapIntervalMESA = nullptr; -GLX::PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI = nullptr; -#endif - -} diff --git a/src/Nazara/Renderer/RenderBuffer.cpp b/src/Nazara/Renderer/RenderBuffer.cpp deleted file mode 100644 index b6b182ab8..000000000 --- a/src/Nazara/Renderer/RenderBuffer.cpp +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - RenderBuffer::RenderBuffer() : - m_id(0) - { - } - - RenderBuffer::~RenderBuffer() - { - OnRenderBufferRelease(this); - - Destroy(); - } - - bool RenderBuffer::Create(PixelFormatType format, unsigned int width, unsigned int height) - { - Destroy(); - - #if NAZARA_RENDERER_SAFE - if (width == 0 || height == 0) - { - NazaraError("Invalid size"); - return false; - } - - if (!PixelFormat::IsValid(format)) - { - NazaraError("Invalid pixel format"); - return false; - } - #endif - - OpenGL::Format openglFormat; - if (!OpenGL::TranslateFormat(format, &openglFormat, OpenGL::FormatType_RenderBuffer)) - { - NazaraError("Failed to translate pixel format \"" + PixelFormat::GetName(format) + "\" into OpenGL format"); - return false; - } - - GLuint renderBuffer = 0; - - glGenRenderbuffers(1, &renderBuffer); - if (!renderBuffer) - { - NazaraError("Failed to create renderbuffer"); - return false; - } - - GLint previous; - glGetIntegerv(GL_RENDERBUFFER_BINDING, &previous); - - glBindRenderbuffer(GL_RENDERBUFFER, renderBuffer); - glRenderbufferStorage(GL_RENDERBUFFER, openglFormat.internalFormat, width, height); - - if (previous != 0) - glBindRenderbuffer(GL_RENDERBUFFER, previous); - - m_pixelFormat = format; - m_height = height; - m_id = renderBuffer; - m_width = width; - - return true; - } - - void RenderBuffer::Destroy() - { - if (m_id) - { - OnRenderBufferDestroy(this); - - Context::EnsureContext(); - - GLuint renderBuffer = m_id; - glDeleteRenderbuffers(1, &renderBuffer); // Les Renderbuffers sont partagés entre les contextes: Ne posera pas de problème - m_id = 0; - } - } - - unsigned int RenderBuffer::GetHeight() const - { - return m_height; - } - - PixelFormatType RenderBuffer::GetFormat() const - { - return m_pixelFormat; - } - - unsigned int RenderBuffer::GetWidth() const - { - return m_width; - } - - unsigned int RenderBuffer::GetOpenGLID() const - { - return m_id; - } - - bool RenderBuffer::IsValid() const - { - return m_id != 0; - } - - bool RenderBuffer::Initialize() - { - if (!RenderBufferLibrary::Initialize()) - { - NazaraError("Failed to initialise library"); - return false; - } - - return true; - } - - void RenderBuffer::Uninitialize() - { - RenderBufferLibrary::Uninitialize(); - } - - RenderBufferLibrary::LibraryMap RenderBuffer::s_library; -} diff --git a/src/Nazara/Renderer/RenderTarget.cpp b/src/Nazara/Renderer/RenderTarget.cpp deleted file mode 100644 index 717c7497a..000000000 --- a/src/Nazara/Renderer/RenderTarget.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include - -namespace Nz -{ - RenderTarget::~RenderTarget() - { - OnRenderTargetRelease(this); - } - - bool RenderTarget::IsActive() const - { - return Renderer::GetTarget() == this; - } - - bool RenderTarget::SetActive(bool active) - { - if (active) - return Renderer::SetTarget(this); - else if (Renderer::GetTarget() == this) - return Renderer::SetTarget(nullptr); - - return true; - } - - void RenderTarget::Desactivate() const - { - // Seuls les target sans contextes (ex: RenderTexture) nécessitent une désactivation - } -} diff --git a/src/Nazara/Renderer/RenderTexture.cpp b/src/Nazara/Renderer/RenderTexture.cpp deleted file mode 100644 index 647b8ff91..000000000 --- a/src/Nazara/Renderer/RenderTexture.cpp +++ /dev/null @@ -1,854 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - namespace - { - struct Attachment - { - NazaraSlot(RenderBuffer, OnRenderBufferDestroy, renderBufferDestroySlot); - NazaraSlot(Texture, OnTextureDestroy, textureDestroySlot); - - RenderBufferRef buffer; - TextureRef texture; - - AttachmentPoint attachmentPoint; - bool isBuffer; - bool isUsed = false; - unsigned int height; - unsigned int width; - }; - - unsigned int attachmentIndex[AttachmentPoint_Max+1] = - { - 3, // AttachmentPoint_Color - 0, // AttachmentPoint_Depth - 1, // AttachmentPoint_DepthStencil - 2 // AttachmentPoint_Stencil - }; - - AttachmentPoint FormatTypeToAttachment(PixelFormatType format) - { - const PixelFormatInfo& info = PixelFormat::GetInfo(format); - switch (info.content) - { - case PixelFormatContent_ColorRGBA: - return AttachmentPoint_Color; - - case PixelFormatContent_DepthStencil: - return (!info.greenMask.TestAny()) ? AttachmentPoint_Depth : AttachmentPoint_DepthStencil; - - case PixelFormatContent_Stencil: - return AttachmentPoint_Stencil; - - case PixelFormatContent_Undefined: - break; - } - - NazaraInternalError("Unexpected pixel format content: 0x" + String::Number(info.content, 16)); - return AttachmentPoint_Max; - } - - GLuint lockedPrevious = 0; - UInt8 lockedLevel = 0; - } - - struct RenderTextureImpl - { - NazaraSlot(Context, OnContextDestroy, contextDestroySlot); - - GLuint fbo; - std::vector attachments; - std::vector colorTargets; - mutable std::vector drawBuffers; - const Context* context; - bool complete = false; - bool userDefinedTargets = false; - unsigned int height; - unsigned int width; - }; - - bool RenderTexture::AttachBuffer(AttachmentPoint attachmentPoint, UInt8 index, RenderBuffer* buffer) - { - #if NAZARA_RENDERER_SAFE - if (!m_impl) - { - NazaraError("Render texture not created"); - return false; - } - - if (attachmentPoint != AttachmentPoint_Color) - { - if (index > 0) - { - NazaraError("Index must be 0 for non-color attachments"); - return false; - } - } - else - { - if (index >= Renderer::GetMaxColorAttachments()) - { - NazaraError("Color index is over max color attachments (" + String::Number(index) + " >= " + String::Number(Renderer::GetMaxColorAttachments()) + ")"); - return false; - } - } - - if (!buffer || !buffer->IsValid()) - { - NazaraError("Invalid render buffer"); - return false; - } - - unsigned int depthStencilIndex = attachmentIndex[AttachmentPoint_DepthStencil]; - if (m_impl->attachments.size() > depthStencilIndex && m_impl->attachments[depthStencilIndex].isUsed) - { - if (attachmentPoint == AttachmentPoint_Depth) - { - NazaraError("Depth target already attached by DepthStencil attachment"); - return false; - } - else if (attachmentPoint == AttachmentPoint_Stencil) - { - NazaraError("Stencil target already attached by DepthStencil attachment"); - return false; - } - } - - AttachmentPoint targetAttachmentPoint = FormatTypeToAttachment(buffer->GetFormat()); - if (targetAttachmentPoint != attachmentPoint && targetAttachmentPoint != AttachmentPoint_DepthStencil && - attachmentPoint != AttachmentPoint_Depth && attachmentPoint != AttachmentPoint_Stencil) - { - NazaraError("Pixel format type does not match attachment point type"); - return false; - } - #endif - - if (!Lock()) - { - NazaraError("Failed to lock render texture"); - return false; - } - - // Détachement de l'attache précédente (Si il y a) - Detach(attachmentPoint, index); - - glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, OpenGL::Attachment[attachmentPoint]+index, GL_RENDERBUFFER, buffer->GetOpenGLID()); - - Unlock(); - - unsigned int attachIndex = attachmentIndex[attachmentPoint] + index; - if (attachIndex >= m_impl->attachments.size()) - m_impl->attachments.resize(attachIndex+1); - - Attachment& attachment = m_impl->attachments[attachIndex]; - attachment.attachmentPoint = attachmentPoint; - attachment.buffer = buffer; - attachment.renderBufferDestroySlot.Connect(buffer->OnRenderBufferDestroy, std::bind(&RenderTexture::OnRenderBufferDestroy, this, std::placeholders::_1, attachIndex)); - attachment.isBuffer = true; - attachment.isUsed = true; - attachment.height = buffer->GetHeight(); - attachment.width = buffer->GetWidth(); - - InvalidateSize(); - InvalidateTargets(); - - return true; - } - - bool RenderTexture::AttachBuffer(AttachmentPoint attachmentPoint, UInt8 index, PixelFormatType format, unsigned int width, unsigned int height) - { - RenderBufferRef renderBuffer = RenderBuffer::New(); - if (!renderBuffer->Create(format, width, height)) - { - NazaraError("Failed to create RenderBuffer"); - return false; - } - - if (!AttachBuffer(attachmentPoint, index, renderBuffer)) - { - NazaraError("Failed to attach buffer"); - return false; - } - - return true; - } - - bool RenderTexture::AttachTexture(AttachmentPoint attachmentPoint, UInt8 index, Texture* texture, unsigned int z) - { - #if NAZARA_RENDERER_SAFE - if (!m_impl) - { - NazaraError("Render texture not created"); - return false; - } - - if (attachmentPoint != AttachmentPoint_Color) - { - if (index > 0) - { - NazaraError("Index must be 0 for non-color attachments"); - return false; - } - } - else - { - if (index >= Renderer::GetMaxColorAttachments()) - { - NazaraError("Color index is over max color attachments (" + String::Number(index) + " >= " + String::Number(Renderer::GetMaxColorAttachments()) + ")"); - return false; - } - } - - if (attachmentPoint == AttachmentPoint_Stencil) - { - NazaraError("Targeting stencil-only textures is not supported"); - return false; - } - - unsigned int depthStencilIndex = attachmentIndex[AttachmentPoint_DepthStencil]; - if (attachmentPoint == AttachmentPoint_Depth && m_impl->attachments.size() > depthStencilIndex && - m_impl->attachments[depthStencilIndex].isUsed) - { - NazaraError("Depth target already attached by DepthStencil attachment"); - return false; - } - - if (!texture || !texture->IsValid()) - { - NazaraError("Invalid texture"); - return false; - } - - unsigned int depth = (texture->GetType() == ImageType_Cubemap) ? 6 : texture->GetDepth(); - if (z >= depth) - { - NazaraError("Z value exceeds depth (" + String::Number(z) + " >= (" + String::Number(depth) + ')'); - return false; - } - - AttachmentPoint targetAttachmentPoint = FormatTypeToAttachment(texture->GetFormat()); - if (targetAttachmentPoint != attachmentPoint && targetAttachmentPoint != AttachmentPoint_DepthStencil && - attachmentPoint != AttachmentPoint_Depth && attachmentPoint != AttachmentPoint_Stencil) - { - NazaraError("Pixel format type does not match attachment point type"); - return false; - } - #endif - - if (!Lock()) - { - NazaraError("Failed to lock render texture"); - return false; - } - - // Détachement de l'attache précédente (Si il y a) - Detach(attachmentPoint, index); - - switch (texture->GetType()) - { - case ImageType_1D: - glFramebufferTexture1D(GL_DRAW_FRAMEBUFFER, OpenGL::Attachment[attachmentPoint]+index, GL_TEXTURE_1D, texture->GetOpenGLID(), 0); - break; - - case ImageType_1D_Array: - case ImageType_2D_Array: - glFramebufferTextureLayer(GL_DRAW_FRAMEBUFFER, OpenGL::Attachment[attachmentPoint]+index, texture->GetOpenGLID(), 0, z); - break; - - case ImageType_2D: - glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, OpenGL::Attachment[attachmentPoint]+index, GL_TEXTURE_2D, texture->GetOpenGLID(), 0); - break; - - case ImageType_3D: - glFramebufferTexture3D(GL_DRAW_FRAMEBUFFER, OpenGL::Attachment[attachmentPoint]+index, GL_TEXTURE_3D, texture->GetOpenGLID(), 0, z); - break; - - case ImageType_Cubemap: - glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, OpenGL::Attachment[attachmentPoint]+index, OpenGL::CubemapFace[z], texture->GetOpenGLID(), 0); - break; - } - - Unlock(); - - unsigned int attachIndex = attachmentIndex[attachmentPoint] + index; - if (attachIndex >= m_impl->attachments.size()) - m_impl->attachments.resize(attachIndex+1); - - Attachment& attachment = m_impl->attachments[attachIndex]; - attachment.attachmentPoint = attachmentPoint; - attachment.isBuffer = false; - attachment.isUsed = true; - attachment.height = texture->GetHeight(); - attachment.texture = texture; - attachment.textureDestroySlot.Connect(texture->OnTextureDestroy, std::bind(&RenderTexture::OnTextureDestroy, this, std::placeholders::_1, attachIndex)); - attachment.width = texture->GetWidth(); - - InvalidateSize(); - InvalidateTargets(); - - return true; - } - - bool RenderTexture::Create(bool lock) - { - Destroy(); - - #if NAZARA_RENDERER_SAFE - if (Context::GetCurrent() == nullptr) - { - NazaraError("No active context"); - return false; - } - #endif - - std::unique_ptr impl(new RenderTextureImpl); - - impl->fbo = 0; - glGenFramebuffers(1, &impl->fbo); - - if (!impl->fbo) - { - NazaraError("Failed to create framebuffer"); - return false; - } - - m_impl = impl.release(); - m_impl->context = Context::GetCurrent(); - m_impl->contextDestroySlot.Connect(m_impl->context->OnContextDestroy, this, &RenderTexture::OnContextDestroy); - - m_checked = false; - m_drawBuffersUpdated = true; - m_sizeUpdated = false; - m_targetsUpdated = true; - - if (lock) - { - // En cas d'exception, la ressource sera quand même libérée - CallOnExit onExit([this] () - { - Destroy(); - }); - - if (!Lock()) - { - NazaraError("Failed to lock render texture"); - return false; - } - - onExit.Reset(); - } - - OnRenderTargetParametersChange(this); - OnRenderTargetSizeChange(this); - - return true; - } - - void RenderTexture::Destroy() - { - if (m_impl) - { - if (IsActive()) - Renderer::SetTarget(nullptr); - - // Le FBO devant être supprimé dans son contexte d'origine, nous déléguons sa suppression à la classe OpenGL - // Celle-ci va libérer le FBO dès que possible (la prochaine fois que son contexte d'origine sera actif) - OpenGL::DeleteFrameBuffer(m_impl->context, m_impl->fbo); - - delete m_impl; // Enlève également une références sur les Texture/RenderBuffer - m_impl = nullptr; - } - } - - void RenderTexture::Detach(AttachmentPoint attachmentPoint, UInt8 index) - { - #if NAZARA_RENDERER_SAFE - if (!m_impl) - { - NazaraError("Render texture not created"); - return; - } - - if (attachmentPoint != AttachmentPoint_Color && index > 0) - { - NazaraError("Index must be 0 for non-color attachments"); - return; - } - #endif - - unsigned int attachIndex = attachmentIndex[attachmentPoint] + index; - if (attachIndex >= m_impl->attachments.size()) - return; - - Attachment& attachement = m_impl->attachments[attachIndex]; - if (!attachement.isUsed) - return; - - if (!Lock()) - { - NazaraError("Failed to lock render texture"); - return; - } - - attachement.isUsed = false; - - if (attachement.isBuffer) - { - glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, OpenGL::Attachment[attachmentPoint]+index, GL_RENDERBUFFER, 0); - - attachement.buffer = nullptr; - attachement.renderBufferDestroySlot.Disconnect(); - } - else - { - if (glFramebufferTexture) - glFramebufferTexture(GL_DRAW_FRAMEBUFFER, OpenGL::Attachment[attachmentPoint]+index, 0, 0); - else - glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, OpenGL::Attachment[attachmentPoint]+index, 0, 0, 0); - - attachement.texture = nullptr; - attachement.textureDestroySlot.Disconnect(); - } - - InvalidateSize(); - - if (attachement.attachmentPoint == AttachmentPoint_Color) - InvalidateTargets(); - - Unlock(); - - m_checked = false; - } - - unsigned int RenderTexture::GetHeight() const - { - NazaraAssert(m_impl, "Invalid render texture"); - - if (!m_sizeUpdated) - UpdateSize(); - - return m_impl->height; - } - - RenderTargetParameters RenderTexture::GetParameters() const - { - NazaraAssert(m_impl, "Invalid render texture"); - - ///TODO - return RenderTargetParameters(); - } - - Vector2ui RenderTexture::GetSize() const - { - NazaraAssert(m_impl, "Invalid render texture"); - - if (!m_sizeUpdated) - UpdateSize(); - - return Vector2ui(m_impl->width, m_impl->height); - } - - unsigned int RenderTexture::GetWidth() const - { - NazaraAssert(m_impl, "Invalid render texture"); - - if (!m_sizeUpdated) - UpdateSize(); - - return m_impl->width; - } - - bool RenderTexture::IsComplete() const - { - NazaraAssert(m_impl, "Invalid render texture"); - - if (!m_checked) - { - if (!Lock()) - { - NazaraError("Failed to lock render texture"); - return false; - } - - GLenum status = glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER); - Unlock(); - - m_impl->complete = false; - - switch (status) - { - case GL_FRAMEBUFFER_COMPLETE: - m_impl->complete = true; - break; - - case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: - NazaraError("Incomplete attachment"); - break; - - case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER: - NazaraInternalError("Incomplete draw buffer"); - break; - - case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER: - NazaraInternalError("Incomplete read buffer"); - break; - - case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: - NazaraError("Incomplete missing attachment"); - break; - - case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: - NazaraError("Incomplete multisample"); - break; - - case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS: - NazaraError("Incomplete layer targets"); - break; - - case GL_FRAMEBUFFER_UNSUPPORTED: - NazaraError("Render texture has unsupported attachments"); - break; - - default: - NazaraInternalError("Unknown error"); - } - - m_checked = true; - } - - return m_impl->complete; - } - - bool RenderTexture::IsRenderable() const - { - return IsComplete() && !m_impl->attachments.empty(); - } - - bool RenderTexture::Lock() const - { - NazaraAssert(m_impl, "Invalid render texture"); - - #if NAZARA_RENDERER_SAFE - if (Context::GetCurrent() != m_impl->context) - { - NazaraError("RenderTexture cannot be used with this context"); - return false; - } - #endif - - if (lockedLevel++ == 0) - { - GLint previous; - glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &previous); - - lockedPrevious = previous; - - if (lockedPrevious != m_impl->fbo) - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_impl->fbo); - } - - return true; - } - - void RenderTexture::SetColorTargets(const UInt8* targets, unsigned int targetCount) const - { - NazaraAssert(m_impl, "Invalid render texture"); - - #if NAZARA_RENDERER_SAFE - for (unsigned int i = 0; i < targetCount; ++i) - { - unsigned int index = attachmentIndex[AttachmentPoint_Color] + targets[i]; - if (index >= m_impl->attachments.size() || !m_impl->attachments[index].isUsed) - { - NazaraError("Target " + String::Number(targets[i]) + " not attached"); - return; - } - } - #endif - - m_impl->colorTargets.resize(targetCount); - std::memcpy(&m_impl->colorTargets[0], targets, targetCount*sizeof(UInt8)); - - m_impl->userDefinedTargets = true; - InvalidateTargets(); - } - - void RenderTexture::SetColorTargets(const std::initializer_list& targets) const - { - NazaraAssert(m_impl, "Invalid render texture"); - - #if NAZARA_RENDERER_SAFE - for (UInt8 target : targets) - { - unsigned int index = attachmentIndex[AttachmentPoint_Color] + target; - if (index >= m_impl->attachments.size() || !m_impl->attachments[index].isUsed) - { - NazaraError("Target " + String::Number(target) + " not attached"); - return; - } - } - #endif - - m_impl->colorTargets.resize(targets.size()); - - UInt8* ptr = &m_impl->colorTargets[0]; - for (UInt8 index : targets) - *ptr++ = index; - - m_impl->userDefinedTargets = true; - InvalidateTargets(); - } - - void RenderTexture::Unlock() const - { - NazaraAssert(m_impl, "Invalid render texture"); - - #if NAZARA_RENDERER_SAFE - if (Context::GetCurrent() != m_impl->context) - { - NazaraError("RenderTexture cannot be used with this context"); - return; - } - - if (lockedLevel == 0) - { - NazaraWarning("Unlock called on non-locked texture"); - return; - } - #endif - - if (--lockedLevel == 0 && lockedPrevious != m_impl->fbo) // Ici, il est important qu'un FBO soit débindé si l'ancien était 0 - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, lockedPrevious); - } - - unsigned int RenderTexture::GetOpenGLID() const - { - NazaraAssert(m_impl, "Invalid render texture"); - - #if NAZARA_RENDERER_SAFE - if (Context::GetCurrent() != m_impl->context) - { - NazaraError("RenderTexture cannot be used with this context"); - return 0; - } - #endif - - return m_impl->fbo; - } - - bool RenderTexture::HasContext() const - { - return false; - } - - void RenderTexture::Blit(RenderTexture* src, Rectui srcRect, RenderTexture* dst, Rectui dstRect, UInt32 buffers, bool bilinearFilter) - { - NazaraAssert(src && src->IsValid(), "Invalid source render texture"); - NazaraAssert(dst && dst->IsValid(), "Invalid destination render texture"); - - #if NAZARA_RENDERER_SAFE - if (srcRect.x+srcRect.width > src->GetWidth() || srcRect.y+srcRect.height > src->GetHeight()) - { - NazaraError("Source rectangle dimensions are out of bounds"); - return; - } - - if (dstRect.x+dstRect.width > dst->GetWidth() || dstRect.y+dstRect.height > dst->GetHeight()) - { - NazaraError("Destination rectangle dimensions are out of bounds"); - return; - } - - if (bilinearFilter && (buffers & RendererBuffer_Depth || buffers & RendererBuffer_Stencil)) - { - NazaraError("Filter cannot be bilinear when blitting depth/stencil buffers"); - return; - } - #endif - - GLbitfield mask = 0; - if (buffers & RendererBuffer_Color) - mask |= GL_COLOR_BUFFER_BIT; - - if (buffers & RendererBuffer_Depth) - mask |= GL_DEPTH_BUFFER_BIT; - - if (buffers & RendererBuffer_Stencil) - mask |= GL_STENCIL_BUFFER_BIT; - - GLint previousDrawBuffer, previousReadBuffer; - glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &previousDrawBuffer); - glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &previousReadBuffer); - - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, dst->GetOpenGLID()); - glBindFramebuffer(GL_READ_FRAMEBUFFER, src->GetOpenGLID()); - - glBlitFramebuffer(srcRect.x, srcRect.y, srcRect.x + srcRect.width, srcRect.y + srcRect.height, - dstRect.x, dstRect.y, dstRect.x + dstRect.width, dstRect.y + dstRect.height, - mask, (bilinearFilter) ? GL_LINEAR : GL_NEAREST); - - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, previousDrawBuffer); - glBindFramebuffer(GL_READ_FRAMEBUFFER, previousReadBuffer); - } - - bool RenderTexture::Activate() const - { - NazaraAssert(m_impl, "Invalid render texture"); - - #if NAZARA_RENDERER_SAFE - if (Context::GetCurrent() != m_impl->context) - { - NazaraError("RenderTexture cannot be used with this context"); - return false; - } - #endif - - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_impl->fbo); - - m_drawBuffersUpdated = false; - - return true; - } - - void RenderTexture::Desactivate() const - { - NazaraAssert(m_impl, "Invalid render texture"); - - #if NAZARA_RENDERER_SAFE - if (Context::GetCurrent() != m_impl->context) - { - NazaraError("RenderTexture cannot be used with this context"); - return; - } - #endif - - glFlush(); - - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); - } - - void RenderTexture::EnsureTargetUpdated() const - { - if (!m_drawBuffersUpdated) - UpdateDrawBuffers(); - - for (UInt8 index : m_impl->colorTargets) - { - Attachment& attachment = m_impl->attachments[attachmentIndex[AttachmentPoint_Color] + index]; - if (!attachment.isBuffer) - attachment.texture->InvalidateMipmaps(); - } - } - - void RenderTexture::OnContextDestroy(const Context* context) - { - NazaraAssert(m_impl, "Invalid internal state"); - NazaraUnused(context); - - #ifdef NAZARA_DEBUG - if (m_impl->context != context) - { - NazaraInternalError("Not listening to " + String::Pointer(context)); - return; - } - #endif - - Destroy(); - } - - void RenderTexture::OnRenderBufferDestroy(const RenderBuffer* renderBuffer, unsigned int attachmentIndex) - { - NazaraAssert(m_impl, "Invalid internal state"); - NazaraAssert(attachmentIndex < m_impl->attachments.size(), "Invalid attachment index"); - NazaraAssert(m_impl->attachments[attachmentIndex].isBuffer, "Invalid attachment state"); - NazaraUnused(renderBuffer); - - Attachment& attachment = m_impl->attachments[attachmentIndex]; - attachment.buffer = nullptr; - attachment.isUsed = false; - attachment.renderBufferDestroySlot.Disconnect(); - - InvalidateTargets(); - } - - void RenderTexture::OnTextureDestroy(const Texture* texture, unsigned int attachmentIndex) - { - NazaraAssert(m_impl, "Invalid internal state"); - NazaraAssert(attachmentIndex < m_impl->attachments.size(), "Invalid attachment index"); - NazaraAssert(!m_impl->attachments[attachmentIndex].isBuffer, "Invalid attachment state"); - NazaraUnused(texture); - - InvalidateTargets(); - } - - void RenderTexture::UpdateDrawBuffers() const - { - if (!m_targetsUpdated) - UpdateTargets(); - - glDrawBuffers(m_impl->drawBuffers.size(), &m_impl->drawBuffers[0]); - - m_drawBuffersUpdated = true; - } - - void RenderTexture::UpdateSize() const - { - m_impl->width = 0; - m_impl->height = 0; - for (Attachment& attachment : m_impl->attachments) - { - if (attachment.isUsed) - { - m_impl->height = std::max(m_impl->height, attachment.height); - m_impl->width = std::max(m_impl->width, attachment.width); - } - } - - m_sizeUpdated = true; - } - - void RenderTexture::UpdateTargets() const - { - if (!m_impl->userDefinedTargets) - { - m_impl->colorTargets.clear(); - - unsigned int colorIndex = 0; - for (unsigned int index = attachmentIndex[AttachmentPoint_Color]; index < m_impl->attachments.size(); ++index) - m_impl->colorTargets.push_back(colorIndex++); - } - - if (m_impl->colorTargets.empty()) - { - m_impl->drawBuffers.resize(1); - m_impl->drawBuffers[0] = GL_NONE; - } - else - { - m_impl->drawBuffers.resize(m_impl->colorTargets.size()); - GLenum* ptr = &m_impl->drawBuffers[0]; - for (UInt8 index : m_impl->colorTargets) - *ptr++ = GL_COLOR_ATTACHMENT0 + index; - } - - m_targetsUpdated = true; - } -} diff --git a/src/Nazara/Renderer/RenderWindow.cpp b/src/Nazara/Renderer/RenderWindow.cpp index a9effa622..078c28f2b 100644 --- a/src/Nazara/Renderer/RenderWindow.cpp +++ b/src/Nazara/Renderer/RenderWindow.cpp @@ -1,7 +1,7 @@ // Copyright (C) 2015 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp - +/* #include #include #include @@ -289,3 +289,4 @@ namespace Nz OnRenderTargetSizeChange(this); } } +*/ \ No newline at end of file diff --git a/src/Nazara/Renderer/Renderer.cpp b/src/Nazara/Renderer/Renderer.cpp index 028f7513f..74a50d481 100644 --- a/src/Nazara/Renderer/Renderer.cpp +++ b/src/Nazara/Renderer/Renderer.cpp @@ -4,580 +4,23 @@ #include #include -#include -#include -#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -///TODO: Manager les VAO (permettre plusieurs draw calls sans rebinder le VAO) - namespace Nz { - namespace - { - const UInt8 r_coreFragmentShader[] = { - #include - }; - - const UInt8 r_coreVertexShader[] = { - #include - }; - - enum ObjectType - { - ObjectType_Context, - ObjectType_IndexBuffer, - ObjectType_VertexBuffer, - ObjectType_VertexDeclaration - }; - - enum UpdateFlags - { - Update_None = 0, - - Update_Matrices = 0x1, - Update_Shader = 0x2, - Update_Textures = 0x4, - Update_VAO = 0x8 - }; - - struct MatrixUnit - { - Matrix4f matrix; - bool updated; - int location; - }; - - struct TextureUnit - { - TextureSampler sampler; - const Texture* texture = nullptr; - bool samplerUpdated = false; - }; - - struct VAO_Entry - { - GLuint vao; - - NazaraSlot(IndexBuffer, OnIndexBufferRelease, onIndexBufferReleaseSlot); - NazaraSlot(VertexBuffer, OnVertexBufferRelease, onVertexBufferReleaseSlot); - NazaraSlot(VertexDeclaration, OnVertexDeclarationRelease, onInstancingDeclarationReleaseSlot); - NazaraSlot(VertexDeclaration, OnVertexDeclarationRelease, onVertexDeclarationReleaseSlot); - }; - - using VAO_Key = std::tuple; - using VAO_Map = std::map; - - struct Context_Entry - { - VAO_Map vaoMap; - - NazaraSlot(Context, OnContextRelease, onReleaseSlot); - }; - - using Context_Map = std::unordered_map; - - Context_Map s_vaos; - std::vector s_dirtyTextureUnits; - std::vector s_textureUnits; - GLuint s_currentVAO = 0; - VertexBuffer s_instanceBuffer; - VertexBuffer s_fullscreenQuadBuffer; - MatrixUnit s_matrices[MatrixType_Max + 1]; - RenderStates s_states; - Vector2ui s_targetSize; - UInt8 s_maxAnisotropyLevel; - UInt32 s_updateFlags; - const IndexBuffer* s_indexBuffer; - const RenderTarget* s_target; - const Shader* s_shader; - const VertexBuffer* s_vertexBuffer; - bool s_capabilities[RendererCap_Max + 1]; - bool s_instancing; - unsigned int s_maxColorAttachments; - unsigned int s_maxRenderTarget; - unsigned int s_maxTextureSize; - unsigned int s_maxTextureUnit; - unsigned int s_maxVertexAttribs; - } - - void Renderer::BeginCondition(const GpuQuery& query, GpuQueryCondition condition) - { - #ifdef NAZARA_DEBUG - if (Context::GetCurrent() == nullptr) - { - NazaraError("No active context"); - return; - } - #endif - - glBeginConditionalRender(query.GetOpenGLID(), OpenGL::QueryCondition[condition]); - } - - void Renderer::Clear(UInt32 flags) - { - #ifdef NAZARA_DEBUG - if (Context::GetCurrent() == nullptr) - { - NazaraError("No active context"); - return; - } - #endif - - if (flags) - { - // On n'oublie pas de mettre à jour la cible - s_target->EnsureTargetUpdated(); - // Les états du rendu sont suceptibles d'influencer glClear - OpenGL::ApplyStates(s_states); - - GLenum mask = 0; - - if (flags & RendererBuffer_Color) - mask |= GL_COLOR_BUFFER_BIT; - - if (flags & RendererBuffer_Depth) - mask |= GL_DEPTH_BUFFER_BIT; - - if (flags & RendererBuffer_Stencil) - mask |= GL_STENCIL_BUFFER_BIT; - - glClear(mask); - } - } - - void Renderer::DrawFullscreenQuad() - { - #ifdef NAZARA_DEBUG - if (Context::GetCurrent() == nullptr) - { - NazaraError("No active context"); - return; - } - #endif - - EnableInstancing(false); - SetIndexBuffer(nullptr); - SetVertexBuffer(&s_fullscreenQuadBuffer); - - if (!EnsureStateUpdate()) - { - NazaraError("Failed to update states: " + Error::GetLastError()); - return; - } - - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - glBindVertexArray(0); - } - - void Renderer::DrawIndexedPrimitives(PrimitiveMode mode, unsigned int firstIndex, unsigned int indexCount) - { - #ifdef NAZARA_DEBUG - if (Context::GetCurrent() == nullptr) - { - NazaraError("No active context"); - return; - } - - if (mode > PrimitiveMode_Max) - { - NazaraError("Primitive mode out of enum"); - return; - } - #endif - - #if NAZARA_RENDERER_SAFE - if (!s_indexBuffer) - { - NazaraError("No index buffer"); - return; - } - #endif - - EnableInstancing(false); - - if (!EnsureStateUpdate()) - { - NazaraError("Failed to update states: " + Error::GetLastError()); - return; - } - - GLenum type; - UInt8* offset = nullptr; - offset += s_indexBuffer->GetStartOffset(); - - if (s_indexBuffer->HasLargeIndices()) - { - offset += firstIndex*sizeof(UInt32); - type = GL_UNSIGNED_INT; - } - else - { - offset += firstIndex*sizeof(UInt16); - type = GL_UNSIGNED_SHORT; - } - - glDrawElements(OpenGL::PrimitiveMode[mode], indexCount, type, offset); - glBindVertexArray(0); - } - - void Renderer::DrawIndexedPrimitivesInstanced(unsigned int instanceCount, PrimitiveMode mode, unsigned int firstIndex, unsigned int indexCount) - { - #ifdef NAZARA_DEBUG - if (Context::GetCurrent() == nullptr) - { - NazaraError("No active context"); - return; - } - - if (mode > PrimitiveMode_Max) - { - NazaraError("Primitive mode out of enum"); - return; - } - #endif - - #if NAZARA_RENDERER_SAFE - if (!s_indexBuffer) - { - NazaraError("No index buffer"); - return; - } - - if (instanceCount == 0) - { - NazaraError("Instance count must be over zero"); - return; - } - - unsigned int maxInstanceCount = s_instanceBuffer.GetVertexCount(); - if (instanceCount > maxInstanceCount) - { - NazaraError("Instance count is over maximum instance count (" + String::Number(instanceCount) + " >= " NazaraStringifyMacro(NAZARA_RENDERER_MAX_INSTANCES) ")"); - return; - } - #endif - - EnableInstancing(true); - - if (!EnsureStateUpdate()) - { - NazaraError("Failed to update states: " + Error::GetLastError()); - return; - } - - GLenum type; - UInt8* offset = nullptr; - offset += s_indexBuffer->GetStartOffset(); - - if (s_indexBuffer->HasLargeIndices()) - { - offset += firstIndex*sizeof(UInt32); - type = GL_UNSIGNED_INT; - } - else - { - offset += firstIndex*sizeof(UInt16); - type = GL_UNSIGNED_SHORT; - } - - glDrawElementsInstanced(OpenGL::PrimitiveMode[mode], indexCount, type, offset, instanceCount); - glBindVertexArray(0); - } - - void Renderer::DrawPrimitives(PrimitiveMode mode, unsigned int firstVertex, unsigned int vertexCount) - { - #ifdef NAZARA_DEBUG - if (Context::GetCurrent() == nullptr) - { - NazaraError("No active context"); - return; - } - - if (mode > PrimitiveMode_Max) - { - NazaraError("Primitive mode out of enum"); - return; - } - #endif - - EnableInstancing(false); - - if (!EnsureStateUpdate()) - { - NazaraError("Failed to update states: " + Error::GetLastError()); - return; - } - - glDrawArrays(OpenGL::PrimitiveMode[mode], firstVertex, vertexCount); - glBindVertexArray(0); - } - - void Renderer::DrawPrimitivesInstanced(unsigned int instanceCount, PrimitiveMode mode, unsigned int firstVertex, unsigned int vertexCount) - { - #ifdef NAZARA_DEBUG - if (Context::GetCurrent() == nullptr) - { - NazaraError("No active context"); - return; - } - - if (mode > PrimitiveMode_Max) - { - NazaraError("Primitive mode out of enum"); - return; - } - #endif - - #if NAZARA_RENDERER_SAFE - if (instanceCount == 0) - { - NazaraError("Instance count must be over zero"); - return; - } - - unsigned int maxInstanceCount = s_instanceBuffer.GetVertexCount(); - if (instanceCount > maxInstanceCount) - { - NazaraError("Instance count is over maximum instance count (" + String::Number(instanceCount) + " >= " NazaraStringifyMacro(NAZARA_RENDERER_MAX_INSTANCES) ")"); - return; - } - #endif - - EnableInstancing(true); - - if (!EnsureStateUpdate()) - { - NazaraError("Failed to update states: " + Error::GetLastError()); - return; - } - - glDrawArraysInstanced(OpenGL::PrimitiveMode[mode], firstVertex, vertexCount, instanceCount); - glBindVertexArray(0); - } - - void Renderer::Enable(RendererParameter parameter, bool enable) - { - #ifdef NAZARA_DEBUG - if (Context::GetCurrent() == nullptr) - { - NazaraError("No active context"); - return; - } - - if (parameter > RendererParameter_Max) - { - NazaraError("Renderer parameter out of enum"); - return; - } - #endif - - switch (parameter) - { - case RendererParameter_Blend: - s_states.blending = enable; - return; - - case RendererParameter_ColorWrite: - s_states.colorWrite = enable; - return; - - case RendererParameter_DepthBuffer: - s_states.depthBuffer = enable; - return; - - case RendererParameter_DepthWrite: - s_states.depthWrite = enable; - return; - - case RendererParameter_FaceCulling: - s_states.faceCulling = enable; - return; - - case RendererParameter_ScissorTest: - s_states.scissorTest = enable; - return; - - case RendererParameter_StencilTest: - s_states.stencilTest = enable; - return; - } - - NazaraInternalError("Unhandled renderer parameter: 0x" + String::Number(parameter, 16)); - } - - void Renderer::EndCondition() - { - #ifdef NAZARA_DEBUG - if (Context::GetCurrent() == nullptr) - { - NazaraError("No active context"); - return; - } - #endif - - glEndConditionalRender(); - } - - void Renderer::Flush() - { - #ifdef NAZARA_DEBUG - if (Context::GetCurrent() == nullptr) - { - NazaraError("No active context"); - return; - } - #endif - - glFlush(); - } - - RendererComparison Renderer::GetDepthFunc() - { - return s_states.depthFunc; - } - - VertexBuffer* Renderer::GetInstanceBuffer() - { - s_updateFlags |= Update_VAO; - return &s_instanceBuffer; - } - - float Renderer::GetLineWidth() - { - #ifdef NAZARA_DEBUG - if (Context::GetCurrent() == nullptr) - { - NazaraError("No active context"); - return 0.f; - } - #endif - - return s_states.lineWidth; - } - - Matrix4f Renderer::GetMatrix(MatrixType type) - { - #ifdef NAZARA_DEBUG - if (type > MatrixType_Max) - { - NazaraError("Matrix type out of enum"); - return Matrix4f(); - } - #endif - - if (!s_matrices[type].updated) - UpdateMatrix(type); - - return s_matrices[type].matrix; - } - - UInt8 Renderer::GetMaxAnisotropyLevel() - { - return s_maxAnisotropyLevel; - } - - unsigned int Renderer::GetMaxColorAttachments() - { - return s_maxColorAttachments; - } - - unsigned int Renderer::GetMaxRenderTargets() - { - return s_maxRenderTarget; - } - - unsigned int Renderer::GetMaxTextureSize() - { - return s_maxTextureSize; - } - - unsigned int Renderer::GetMaxTextureUnits() - { - return s_maxTextureUnit; - } - - unsigned int Renderer::GetMaxVertexAttribs() - { - return s_maxVertexAttribs; - } - - float Renderer::GetPointSize() - { - return s_states.pointSize; - } - - const RenderStates& Renderer::GetRenderStates() - { - return s_states; - } - - Recti Renderer::GetScissorRect() - { - return OpenGL::GetCurrentScissorBox(); - } - - const Shader* Renderer::GetShader() - { - return s_shader; - } - - const RenderTarget* Renderer::GetTarget() - { - return s_target; - } - - Recti Renderer::GetViewport() - { - return OpenGL::GetCurrentViewport(); - } - - bool Renderer::HasCapability(RendererCap capability) - { - #ifdef NAZARA_DEBUG - if (capability > RendererCap_Max) - { - NazaraError("Renderer capability out of enum"); - return false; - } - #endif - - return s_capabilities[capability]; - } - bool Renderer::Initialize() { if (s_moduleReferenceCounter > 0) { s_moduleReferenceCounter++; - return true; // Déjà initialisé + return true; // Already initialized } - // Initialisation des dépendances + // Initialize module dependencies if (!Utility::Initialize()) { NazaraError("Failed to initialize Utility module"); @@ -586,165 +29,62 @@ namespace Nz s_moduleReferenceCounter++; - // Initialisation du module CallOnExit onExit(Renderer::Uninitialize); - // Initialisation d'OpenGL - if (!OpenGL::Initialize()) // Initialise également Context + NazaraDebug("Searching for renderer implementation"); + + Directory dir("."); + dir.SetPattern("Nazara?*Renderer*" NAZARA_DYNLIB_EXTENSION); //< Ex: NazaraVulkanRenderer.dll + + if (!dir.Open()) { - NazaraError("Failed to initialize OpenGL"); + NazaraError("Failed to open directory"); return false; } - Buffer::SetBufferFactory(DataStorage_Hardware, [] (Buffer* parent, BufferType type) -> AbstractBuffer* + DynLib chosenLib; + std::unique_ptr chosenImpl; + while (dir.NextResult()) { - return new HardwareBuffer(parent, type); - }); + NazaraDebug("Trying to load " + dir.GetResultName()); - for (unsigned int i = 0; i <= MatrixType_Max; ++i) - { - MatrixUnit& unit = s_matrices[i]; - unit.location = -1; - unit.matrix.MakeIdentity(); - unit.updated = true; - } - - // Récupération des capacités d'OpenGL - s_capabilities[RendererCap_AnisotropicFilter] = OpenGL::IsSupported(OpenGLExtension_AnisotropicFilter); - s_capabilities[RendererCap_FP64] = OpenGL::IsSupported(OpenGLExtension_FP64); - s_capabilities[RendererCap_Instancing] = true; // Supporté par OpenGL 3.3 - - Context::EnsureContext(); - - if (s_capabilities[RendererCap_AnisotropicFilter]) - { - GLfloat maxAnisotropy; - glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAnisotropy); - - s_maxAnisotropyLevel = static_cast(maxAnisotropy); - } - else - s_maxAnisotropyLevel = 1; - - GLint maxColorAttachments; - glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments); - s_maxColorAttachments = static_cast(maxColorAttachments); - - GLint maxDrawBuffers; - glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers); - s_maxRenderTarget = static_cast(maxDrawBuffers); - - GLint maxTextureUnits; - glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxTextureUnits); - s_maxTextureUnit = static_cast(maxTextureUnits); - - GLint maxTextureSize; - glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize); - s_maxTextureSize = static_cast(maxTextureSize); - - GLint maxVertexAttribs; - glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVertexAttribs); - s_maxVertexAttribs = static_cast(maxVertexAttribs); - - s_states = RenderStates(); - - s_indexBuffer = nullptr; - s_shader = nullptr; - s_target = nullptr; - s_targetSize.Set(0U); - s_textureUnits.resize(s_maxTextureUnit); - s_updateFlags = Update_Matrices | Update_Shader | Update_VAO; - s_vertexBuffer = nullptr; - - s_fullscreenQuadBuffer.Reset(VertexDeclaration::Get(VertexLayout_XY_UV), 4, DataStorage_Hardware, BufferUsage_Static); - - float vertices[4 * 2 * 2] = - { - -1.f, -1.f, 0.f, 1.f, - 1.f, -1.f, 1.f, 1.f, - -1.f, 1.f, 0.f, 0.f, - 1.f, 1.f, 1.f, 0.f - }; - - if (!s_fullscreenQuadBuffer.Fill(vertices, 0, 4)) - { - NazaraError("Failed to fill fullscreen quad buffer"); - return false; - } - - if (s_capabilities[RendererCap_Instancing]) - { - try + DynLib implLib; + if (!implLib.Load(dir.GetResultPath())) { - ErrorFlags errFlags(ErrorFlag_ThrowException, true); - s_instanceBuffer.Reset(nullptr, NAZARA_RENDERER_INSTANCE_BUFFER_SIZE, DataStorage_Hardware, BufferUsage_Dynamic); + NazaraWarning("Failed to load " + dir.GetResultName() + ": " + implLib.GetLastError()); + continue; } - catch (const std::exception& e) - { - s_capabilities[RendererCap_Instancing] = false; - ErrorFlags flags(ErrorFlag_ThrowExceptionDisabled); - NazaraError("Failed to create instancing buffer: " + String(e.what())); + CreateRendererImplFunc createRenderer = reinterpret_cast(implLib.GetSymbol("NazaraRenderer_Instantiate")); + if (!createRenderer) + { + NazaraDebug("Skipped " + dir.GetResultName() + " (symbol not found)"); + continue; + } + + std::unique_ptr impl(createRenderer()); + if (!impl || !impl->Prepare(Nz::ParameterList())) + { + NazaraError("Failed to create renderer implementation"); + continue; + } + + NazaraDebug("Loaded " + impl->QueryAPIString()); + + if (!chosenImpl || impl->IsBetterThan(chosenImpl.get())) + { + if (chosenImpl) + NazaraDebug("Choose " + impl->QueryAPIString() + " over " + chosenImpl->QueryAPIString()); + + chosenLib = std::move(implLib); + chosenImpl = std::move(impl); } } - if (!RenderBuffer::Initialize()) - { - NazaraError("Failed to initialize render buffers"); - return false; - } + s_rendererImpl = std::move(chosenImpl); + s_rendererLib = std::move(chosenLib); - if (!Shader::Initialize()) - { - NazaraError("Failed to initialize shaders"); - return false; - } - - if (!Texture::Initialize()) - { - NazaraError("Failed to initialize textures"); - return false; - } - - if (!TextureSampler::Initialize()) - { - NazaraError("Failed to initialize texture samplers"); - return false; - } - - if (!UberShader::Initialize()) - { - NazaraError("Failed to initialize uber shaders"); - return false; - } - - // Création du shader de Debug - ShaderRef debugShader = Shader::New(); - if (!debugShader->Create()) - { - NazaraError("Failed to create debug shader"); - return false; - } - - if (!debugShader->AttachStageFromSource(ShaderStageType_Fragment, reinterpret_cast(r_coreFragmentShader), sizeof(r_coreFragmentShader))) - { - NazaraError("Failed to attach fragment stage"); - return false; - } - - if (!debugShader->AttachStageFromSource(ShaderStageType_Vertex, reinterpret_cast(r_coreVertexShader), sizeof(r_coreVertexShader))) - { - NazaraError("Failed to attach vertex stage"); - return false; - } - - if (!debugShader->Link()) - { - NazaraError("Failed to link shader"); - return false; - } - - ShaderLibrary::Register("DebugSimple", debugShader); + NazaraDebug("Using " + s_rendererImpl->QueryAPIString() + " as renderer"); onExit.Reset(); @@ -752,1252 +92,28 @@ namespace Nz return true; } - bool Renderer::IsComponentTypeSupported(ComponentType type) - { - switch (type) - { - case ComponentType_Color: - case ComponentType_Float1: - case ComponentType_Float2: - case ComponentType_Float3: - case ComponentType_Float4: - return true; // Supportés nativement - - case ComponentType_Double1: - case ComponentType_Double2: - case ComponentType_Double3: - case ComponentType_Double4: - return glVertexAttribLPointer != nullptr; // Fonction requise pour envoyer des doubles - - case ComponentType_Int1: - case ComponentType_Int2: - case ComponentType_Int3: - case ComponentType_Int4: - return glVertexAttribIPointer != nullptr; // Fonction requise pour envoyer des entiers - - case ComponentType_Quaternion: - return false; - } - - NazaraError("Attribute type not handled (0x" + String::Number(type, 16) + ')'); - return false; - } - - bool Renderer::IsEnabled(RendererParameter parameter) - { - #ifdef NAZARA_DEBUG - if (parameter > RendererParameter_Max) - { - NazaraError("Renderer parameter out of enum"); - return false; - } - #endif - - switch (parameter) - { - case RendererParameter_Blend: - return s_states.blending; - - case RendererParameter_ColorWrite: - return s_states.colorWrite; - - case RendererParameter_DepthBuffer: - return s_states.depthBuffer; - - case RendererParameter_DepthWrite: - return s_states.depthWrite; - - case RendererParameter_FaceCulling: - return s_states.faceCulling; - - case RendererParameter_ScissorTest: - return s_states.scissorTest; - - case RendererParameter_StencilTest: - return s_states.stencilTest; - } - - NazaraInternalError("Unhandled renderer parameter: 0x" + String::Number(parameter, 16)); - return false; - } - - bool Renderer::IsInitialized() - { - return s_moduleReferenceCounter != 0; - } - - void Renderer::SetBlendFunc(BlendFunc srcBlend, BlendFunc dstBlend) - { - #ifdef NAZARA_DEBUG - if (srcBlend > BlendFunc_Max) - { - NazaraError("Blend func out of enum"); - return; - } - - if (dstBlend > BlendFunc_Max) - { - NazaraError("Blend func out of enum"); - return; - } - #endif - - s_states.srcBlend = srcBlend; - s_states.dstBlend = dstBlend; - } - - void Renderer::SetClearColor(const Color& color) - { - #ifdef NAZARA_DEBUG - if (Context::GetCurrent() == nullptr) - { - NazaraError("No active context"); - return; - } - #endif - - glClearColor(color.r / 255.f, color.g / 255.f, color.b / 255.f, color.a / 255.f); - } - - void Renderer::SetClearColor(UInt8 r, UInt8 g, UInt8 b, UInt8 a) - { - #ifdef NAZARA_DEBUG - if (Context::GetCurrent() == nullptr) - { - NazaraError("No active context"); - return; - } - #endif - - glClearColor(r / 255.f, g / 255.f, b / 255.f, a / 255.f); - } - - void Renderer::SetClearDepth(double depth) - { - #ifdef NAZARA_DEBUG - if (Context::GetCurrent() == nullptr) - { - NazaraError("No active context"); - return; - } - #endif - - glClearDepth(depth); - } - - void Renderer::SetClearStencil(unsigned int value) - { - #ifdef NAZARA_DEBUG - if (Context::GetCurrent() == nullptr) - { - NazaraError("No active context"); - return; - } - #endif - - glClearStencil(value); - } - - void Renderer::SetDepthFunc(RendererComparison compareFunc) - { - #ifdef NAZARA_DEBUG - if (compareFunc > RendererComparison_Max) - { - NazaraError("Renderer comparison out of enum"); - return; - } - #endif - - s_states.depthFunc = compareFunc; - } - - void Renderer::SetFaceCulling(FaceSide faceSide) - { - #ifdef NAZARA_DEBUG - if (faceSide > FaceSide_Max) - { - NazaraError("Face side out of enum"); - return; - } - #endif - - s_states.cullingSide = faceSide; - } - - void Renderer::SetFaceFilling(FaceFilling fillingMode) - { - #ifdef NAZARA_DEBUG - if (fillingMode > FaceFilling_Max) - { - NazaraError("Face filling out of enum"); - return; - } - #endif - - s_states.faceFilling = fillingMode; - } - - void Renderer::SetIndexBuffer(const IndexBuffer* indexBuffer) - { - #if NAZARA_RENDERER_SAFE - if (indexBuffer && !indexBuffer->IsHardware()) - { - NazaraError("Buffer must be hardware"); - return; - } - #endif - - if (s_indexBuffer != indexBuffer) - { - s_indexBuffer = indexBuffer; - s_updateFlags |= Update_VAO; - } - } - - void Renderer::SetLineWidth(float width) - { - #if NAZARA_RENDERER_SAFE - if (width <= 0.f) - { - NazaraError("Width must be over zero"); - return; - } - #endif - - s_states.lineWidth = width; - } - - void Renderer::SetMatrix(MatrixType type, const Matrix4f& matrix) - { - #ifdef NAZARA_DEBUG - if (type > MatrixType_Max) - { - NazaraError("Matrix type out of enum"); - return; - } - #endif - - s_matrices[type].matrix = matrix; - s_matrices[type].updated = true; - - // Invalidation des combinaisons - switch (type) - { - // Matrices de base - case MatrixType_Projection: - s_matrices[MatrixType_InvProjection].updated = false; - s_matrices[MatrixType_InvViewProj].updated = false; - s_matrices[MatrixType_InvWorldViewProj].updated = false; - s_matrices[MatrixType_ViewProj].updated = false; - s_matrices[MatrixType_WorldViewProj].updated = false; - break; - - case MatrixType_View: - s_matrices[MatrixType_InvView].updated = false; - s_matrices[MatrixType_InvViewProj].updated = false; - s_matrices[MatrixType_InvWorld].updated = false; - s_matrices[MatrixType_InvWorldViewProj].updated = false; - s_matrices[MatrixType_ViewProj].updated = false; - s_matrices[MatrixType_World].updated = false; - s_matrices[MatrixType_WorldViewProj].updated = false; - break; - - case MatrixType_World: - s_matrices[MatrixType_InvWorld].updated = false; - s_matrices[MatrixType_InvWorldView].updated = false; - s_matrices[MatrixType_InvWorldViewProj].updated = false; - s_matrices[MatrixType_WorldView].updated = false; - s_matrices[MatrixType_WorldViewProj].updated = false; - break; - - // Matrices combinées - case MatrixType_ViewProj: - s_matrices[MatrixType_InvViewProj].updated = false; - break; - - case MatrixType_WorldView: - s_matrices[MatrixType_InvWorldView].updated = false; - s_matrices[MatrixType_WorldViewProj].updated = false; - break; - - case MatrixType_WorldViewProj: - s_matrices[MatrixType_InvWorldViewProj].updated = false; - break; - - case MatrixType_InvProjection: - case MatrixType_InvView: - case MatrixType_InvViewProj: - case MatrixType_InvWorld: - case MatrixType_InvWorldView: - case MatrixType_InvWorldViewProj: - break; - } - - s_updateFlags |= Update_Matrices; - } - - void Renderer::SetPointSize(float size) - { - #if NAZARA_RENDERER_SAFE - if (size <= 0.f) - { - NazaraError("Size must be over zero"); - return; - } - #endif - - s_states.pointSize = size; - } - - void Renderer::SetRenderStates(const RenderStates& states) - { - s_states = states; - } - - void Renderer::SetScissorRect(const Recti& rect) - { - OpenGL::BindScissorBox(rect); - } - - void Renderer::SetShader(const Shader* shader) - { - #if NAZARA_RENDERER_SAFE - if (shader) - { - if (!shader->IsValid() || !shader->IsLinked()) - { - NazaraError("Invalid shader"); - return; - } - } - #endif - - if (s_shader != shader) - { - s_shader = shader; - s_updateFlags |= Update_Shader; - } - } - - void Renderer::SetStencilCompareFunction(RendererComparison compareFunc, FaceSide faceSide) - { - #ifdef NAZARA_DEBUG - if (compareFunc > RendererComparison_Max) - { - NazaraError("Renderer comparison out of enum"); - return; - } - - if (faceSide > FaceSide_Max) - { - NazaraError("Face side out of enum"); - return; - } - #endif - - switch (faceSide) - { - case FaceSide_Back: - s_states.stencilCompare.back = compareFunc; - break; - - case FaceSide_Front: - s_states.stencilCompare.front = compareFunc; - break; - - case FaceSide_FrontAndBack: - s_states.stencilCompare.back = compareFunc; - s_states.stencilCompare.front = compareFunc; - break; - } - } - - void Renderer::SetStencilFailOperation(StencilOperation failOperation, FaceSide faceSide) - { - #ifdef NAZARA_DEBUG - if (failOperation > StencilOperation_Max) - { - NazaraError("Stencil fail operation out of enum"); - return; - } - - if (faceSide > FaceSide_Max) - { - NazaraError("Face side out of enum"); - return; - } - #endif - - switch (faceSide) - { - case FaceSide_Back: - s_states.stencilFail.back = failOperation; - break; - - case FaceSide_Front: - s_states.stencilFail.front = failOperation; - break; - - case FaceSide_FrontAndBack: - s_states.stencilFail.back = failOperation; - s_states.stencilFail.front = failOperation; - break; - } - } - - void Renderer::SetStencilMask(UInt32 mask, FaceSide faceSide) - { - #ifdef NAZARA_DEBUG - if (faceSide > FaceSide_Max) - { - NazaraError("Face side out of enum"); - return; - } - #endif - - switch (faceSide) - { - case FaceSide_Back: - s_states.stencilWriteMask.back = mask; - break; - - case FaceSide_Front: - s_states.stencilWriteMask.front = mask; - break; - - case FaceSide_FrontAndBack: - s_states.stencilWriteMask.back = mask; - s_states.stencilWriteMask.front = mask; - break; - } - } - - void Renderer::SetStencilPassOperation(StencilOperation passOperation, FaceSide faceSide) - { - #ifdef NAZARA_DEBUG - if (passOperation > StencilOperation_Max) - { - NazaraError("Stencil pass operation out of enum"); - return; - } - - if (faceSide > FaceSide_Max) - { - NazaraError("Face side out of enum"); - return; - } - #endif - - switch (faceSide) - { - case FaceSide_Back: - s_states.stencilPass.back = passOperation; - break; - - case FaceSide_Front: - s_states.stencilPass.front = passOperation; - break; - - case FaceSide_FrontAndBack: - s_states.stencilPass.back = passOperation; - s_states.stencilPass.front = passOperation; - break; - } - } - - void Renderer::SetStencilReferenceValue(unsigned int refValue, FaceSide faceSide) - { - #ifdef NAZARA_DEBUG - if (faceSide > FaceSide_Max) - { - NazaraError("Face side out of enum"); - return; - } - #endif - - switch (faceSide) - { - case FaceSide_Back: - s_states.stencilReference.back = refValue; - break; - - case FaceSide_Front: - s_states.stencilReference.front = refValue; - break; - - case FaceSide_FrontAndBack: - s_states.stencilReference.back = refValue; - s_states.stencilReference.front = refValue; - break; - } - } - - void Renderer::SetStencilZFailOperation(StencilOperation zfailOperation, FaceSide faceSide) - { - #ifdef NAZARA_DEBUG - if (zfailOperation > StencilOperation_Max) - { - NazaraError("Stencil pass operation out of enum"); - return; - } - - if (faceSide > FaceSide_Max) - { - NazaraError("Face side out of enum"); - return; - } - #endif - - switch (faceSide) - { - case FaceSide_Back: - s_states.stencilDepthFail.back = zfailOperation; - break; - - case FaceSide_Front: - s_states.stencilDepthFail.front = zfailOperation; - break; - - case FaceSide_FrontAndBack: - s_states.stencilDepthFail.back = zfailOperation; - s_states.stencilDepthFail.front = zfailOperation; - break; - } - } - - bool Renderer::SetTarget(const RenderTarget* target) - { - if (s_target == target) - return true; - - if (s_target) - { - if (!s_target->HasContext()) - s_target->Desactivate(); - - s_target = nullptr; - } - - if (target) - { - #if NAZARA_RENDERER_SAFE - if (!target->IsRenderable()) - { - NazaraError("Target not renderable"); - return false; - } - #endif - - if (!target->Activate()) - { - NazaraError("Failed to activate target"); - return false; - } - - s_target = target; - } - - OpenGL::SetTarget(s_target); - - return true; - } - - void Renderer::SetTexture(UInt8 unit, const Texture* texture) - { - #if NAZARA_RENDERER_SAFE - if (unit >= s_maxTextureUnit) - { - NazaraError("Texture unit out of range (" + String::Number(unit) + " >= " + String::Number(s_maxTextureUnit) + ')'); - return; - } - #endif - - if (s_textureUnits[unit].texture != texture) - { - s_textureUnits[unit].texture = texture; - - if (texture) - { - if (s_textureUnits[unit].sampler.UseMipmaps(texture->HasMipmaps())) - s_textureUnits[unit].samplerUpdated = false; - } - - s_dirtyTextureUnits.push_back(unit); - s_updateFlags |= Update_Textures; - } - } - - void Renderer::SetTextureSampler(UInt8 unit, const TextureSampler& sampler) - { - #if NAZARA_RENDERER_SAFE - if (unit >= s_maxTextureUnit) - { - NazaraError("Texture unit out of range (" + String::Number(unit) + " >= " + String::Number(s_maxTextureUnit) + ')'); - return; - } - #endif - - s_textureUnits[unit].sampler = sampler; - s_textureUnits[unit].samplerUpdated = false; - - if (s_textureUnits[unit].texture) - s_textureUnits[unit].sampler.UseMipmaps(s_textureUnits[unit].texture->HasMipmaps()); - - s_dirtyTextureUnits.push_back(unit); - s_updateFlags |= Update_Textures; - } - - void Renderer::SetVertexBuffer(const VertexBuffer* vertexBuffer) - { - #if NAZARA_RENDERER_SAFE - if (vertexBuffer && !vertexBuffer->IsHardware()) - { - NazaraError("Buffer must be hardware"); - return; - } - #endif - - if (vertexBuffer && s_vertexBuffer != vertexBuffer) - { - s_vertexBuffer = vertexBuffer; - s_updateFlags |= Update_VAO; - } - } - - void Renderer::SetViewport(const Recti& viewport) - { - OpenGL::BindViewport(viewport); - } - void Renderer::Uninitialize() { if (s_moduleReferenceCounter != 1) { - // Le module est soit encore utilisé, soit pas initialisé + // Either the module is not initialized, either it was initialized multiple times if (s_moduleReferenceCounter > 1) s_moduleReferenceCounter--; return; } - // Libération du module s_moduleReferenceCounter = 0; - ShaderLibrary::Unregister("DebugSimple"); - - UberShader::Uninitialize(); - TextureSampler::Uninitialize(); - Texture::Uninitialize(); - Shader::Uninitialize(); - RenderBuffer::Uninitialize(); - DebugDrawer::Uninitialize(); - - s_textureUnits.clear(); - - // Libération des buffers - s_fullscreenQuadBuffer.Reset(); - s_instanceBuffer.Reset(); - - // Libération des VAOs - for (auto& pair : s_vaos) - { - const Context* context = pair.first; - const Context_Entry& contextEntry = pair.second; - - for (auto& pair2 : contextEntry.vaoMap) - { - const VAO_Entry& entry = pair2.second; - OpenGL::DeleteVertexArray(context, entry.vao); - } - } - s_vaos.clear(); - - OpenGL::Uninitialize(); + // Uninitialize module here NazaraNotice("Uninitialized: Renderer module"); - // Libération des dépendances + // Free module dependencies Utility::Uninitialize(); } - void Renderer::EnableInstancing(bool instancing) - { - if (s_instancing != instancing) - { - s_updateFlags |= Update_VAO; - s_instancing = instancing; - } - } - - bool Renderer::EnsureStateUpdate() - { - // Toutes les erreurs sont silencieuses car l'erreur est gérée par la fonction appelante - ErrorFlags flags(ErrorFlag_Silent | ErrorFlag_ThrowExceptionDisabled); - - #ifdef NAZARA_DEBUG - if (Context::GetCurrent() == nullptr) - { - NazaraError("No active context"); - return false; - } - #endif - - #if NAZARA_RENDERER_SAFE - if (!s_shader) - { - NazaraError("No shader"); - return false; - } - - if (!s_target) - { - NazaraError("No target"); - return false; - } - #endif - - s_target->EnsureTargetUpdated(); - - s_shader->Bind(); // Active le programme si ce n'est pas déjà le cas - - // Si le programme a été changé depuis la dernière fois - if (s_updateFlags & Update_Shader) - { - // Récupération des indices des variables uniformes (-1 si la variable n'existe pas) - s_matrices[MatrixType_Projection].location = s_shader->GetUniformLocation(ShaderUniform_ProjMatrix); - s_matrices[MatrixType_View].location = s_shader->GetUniformLocation(ShaderUniform_ViewMatrix); - s_matrices[MatrixType_World].location = s_shader->GetUniformLocation(ShaderUniform_WorldMatrix); - - s_matrices[MatrixType_ViewProj].location = s_shader->GetUniformLocation(ShaderUniform_ViewProjMatrix); - s_matrices[MatrixType_WorldView].location = s_shader->GetUniformLocation(ShaderUniform_WorldViewMatrix); - s_matrices[MatrixType_WorldViewProj].location = s_shader->GetUniformLocation(ShaderUniform_WorldViewProjMatrix); - - s_matrices[MatrixType_InvProjection].location = s_shader->GetUniformLocation(ShaderUniform_InvProjMatrix); - s_matrices[MatrixType_InvView].location = s_shader->GetUniformLocation(ShaderUniform_InvViewMatrix); - s_matrices[MatrixType_InvViewProj].location = s_shader->GetUniformLocation(ShaderUniform_InvViewProjMatrix); - s_matrices[MatrixType_InvWorld].location = s_shader->GetUniformLocation(ShaderUniform_InvWorldMatrix); - s_matrices[MatrixType_InvWorldView].location = s_shader->GetUniformLocation(ShaderUniform_InvWorldViewMatrix); - s_matrices[MatrixType_InvWorldViewProj].location = s_shader->GetUniformLocation(ShaderUniform_InvWorldViewProjMatrix); - - s_targetSize.Set(0U); // On force l'envoi des uniformes - s_updateFlags |= Update_Matrices; // Changement de programme, on renvoie toutes les matrices demandées - - s_updateFlags &= ~Update_Shader; - } - - // Envoi des uniformes liées au Renderer - Vector2ui targetSize(s_target->GetWidth(), s_target->GetHeight()); - if (s_targetSize != targetSize) - { - int location; - - location = s_shader->GetUniformLocation(ShaderUniform_InvTargetSize); - if (location != -1) - s_shader->SendVector(location, 1.f / Vector2f(targetSize)); - - location = s_shader->GetUniformLocation(ShaderUniform_TargetSize); - if (location != -1) - s_shader->SendVector(location, Vector2f(targetSize)); - - s_targetSize.Set(targetSize); - } - - if (s_updateFlags != Update_None) - { - if (s_updateFlags & Update_Textures) - { - for (unsigned int i : s_dirtyTextureUnits) - { - TextureUnit& unit = s_textureUnits[i]; - - if (unit.texture && !unit.samplerUpdated) - { - unit.sampler.Bind(i); - unit.samplerUpdated = true; - } - } - - s_dirtyTextureUnits.clear(); // Ne change pas la capacité - s_updateFlags &= ~Update_Textures; - } - - if (s_updateFlags & Update_Matrices) - { - for (unsigned int i = 0; i <= MatrixType_Max; ++i) - { - MatrixUnit& unit = s_matrices[i]; - if (unit.location != -1) // On ne traite que les matrices existant dans le programme - { - if (!unit.updated) - UpdateMatrix(static_cast(i)); - - s_shader->SendMatrix(unit.location, unit.matrix); - } - } - - s_updateFlags &= ~Update_Matrices; - } - - if (s_updateFlags & Update_VAO) - { - #if NAZARA_RENDERER_SAFE - if (!s_vertexBuffer) - { - NazaraError("No vertex buffer"); - return false; - } - #endif - - // Note: Les VAOs ne sont pas partagés entre les contextes, nous avons donc un tableau de VAOs par contexte - const Context* context = Context::GetCurrent(); - - auto it = s_vaos.find(context); - if (it == s_vaos.end()) - { - Context_Entry entry; - entry.onReleaseSlot.Connect(context->OnContextRelease, OnContextRelease); - - it = s_vaos.insert(std::make_pair(context, std::move(entry))).first; - } - - VAO_Map& vaoMap = it->second.vaoMap; - - // Notre clé est composée de ce qui définit un VAO - const VertexDeclaration* vertexDeclaration = s_vertexBuffer->GetVertexDeclaration(); - const VertexDeclaration* instancingDeclaration = (s_instancing) ? s_instanceBuffer.GetVertexDeclaration() : nullptr; - VAO_Key key(s_indexBuffer, s_vertexBuffer, vertexDeclaration, instancingDeclaration); - - // On recherche un VAO existant avec notre configuration - auto vaoIt = vaoMap.find(key); - if (vaoIt == vaoMap.end()) - { - // On créé notre VAO - glGenVertexArrays(1, &s_currentVAO); - glBindVertexArray(s_currentVAO); - - // On l'ajoute à notre liste - VAO_Entry entry; - entry.vao = s_currentVAO; - - // Connect the slots - if (s_indexBuffer) - entry.onIndexBufferReleaseSlot.Connect(s_indexBuffer->OnIndexBufferRelease, OnIndexBufferRelease); - - if (instancingDeclaration) - entry.onInstancingDeclarationReleaseSlot.Connect(instancingDeclaration->OnVertexDeclarationRelease, OnVertexDeclarationRelease); - - entry.onVertexBufferReleaseSlot.Connect(s_vertexBuffer->OnVertexBufferRelease, OnVertexBufferRelease); - entry.onVertexDeclarationReleaseSlot.Connect(vertexDeclaration->OnVertexDeclarationRelease, OnVertexDeclarationRelease); - - vaoIt = vaoMap.insert(std::make_pair(key, std::move(entry))).first; - - // And begin to program it - bool updateFailed = false; - - // Pour éviter la duplication de code, on va utiliser une astuce via une boucle for - for (unsigned int i = 0; i < (s_instancing ? 2U : 1U); ++i) - { - // Selon l'itération nous choisissons un buffer différent - const VertexBuffer* vertexBuffer = (i == 0) ? s_vertexBuffer : &s_instanceBuffer; - - HardwareBuffer* vertexBufferImpl = static_cast(vertexBuffer->GetBuffer()->GetImpl()); - glBindBuffer(OpenGL::BufferTarget[BufferType_Vertex], vertexBufferImpl->GetOpenGLID()); - - unsigned int bufferOffset = vertexBuffer->GetStartOffset(); - vertexDeclaration = vertexBuffer->GetVertexDeclaration(); - unsigned int stride = vertexDeclaration->GetStride(); - - // On définit les bornes (une fois de plus selon l'itération) - unsigned int start = (i == 0) ? VertexComponent_FirstVertexData : VertexComponent_FirstInstanceData; - unsigned int end = (i == 0) ? VertexComponent_LastVertexData : VertexComponent_LastInstanceData; - for (unsigned int j = start; j <= end; ++j) - { - ComponentType type; - bool enabled; - std::size_t offset; - vertexDeclaration->GetComponent(static_cast(j), &enabled, &type, &offset); - - if (enabled) - { - if (!IsComponentTypeSupported(type)) - { - NazaraError("Invalid vertex declaration " + String::Pointer(vertexDeclaration) + ": Vertex component 0x" + String::Number(j, 16) + " (type: 0x" + String::Number(type, 16) + ") is not supported"); - updateFailed = true; - break; - } - - glEnableVertexAttribArray(OpenGL::VertexComponentIndex[j]); - - switch (type) - { - case ComponentType_Color: - { - glVertexAttribPointer(OpenGL::VertexComponentIndex[j], - Utility::ComponentCount[type], - OpenGL::ComponentType[type], - GL_TRUE, - stride, - reinterpret_cast(bufferOffset + offset)); - - break; - } - - case ComponentType_Double1: - case ComponentType_Double2: - case ComponentType_Double3: - case ComponentType_Double4: - { - glVertexAttribLPointer(OpenGL::VertexComponentIndex[j], - Utility::ComponentCount[type], - OpenGL::ComponentType[type], - stride, - reinterpret_cast(bufferOffset + offset)); - - break; - } - - case ComponentType_Float1: - case ComponentType_Float2: - case ComponentType_Float3: - case ComponentType_Float4: - { - glVertexAttribPointer(OpenGL::VertexComponentIndex[j], - Utility::ComponentCount[type], - OpenGL::ComponentType[type], - GL_FALSE, - stride, - reinterpret_cast(bufferOffset + offset)); - - break; - } - - case ComponentType_Int1: - case ComponentType_Int2: - case ComponentType_Int3: - case ComponentType_Int4: - { - glVertexAttribIPointer(OpenGL::VertexComponentIndex[j], - Utility::ComponentCount[type], - OpenGL::ComponentType[type], - stride, - reinterpret_cast(bufferOffset + offset)); - - break; - } - - default: - { - NazaraInternalError("Unsupported component type (0x" + String::Number(type, 16) + ')'); - break; - } - } - - // Les attributs d'instancing ont un diviseur spécifique (pour dépendre de l'instance en cours) - if (i == 1) - glVertexAttribDivisor(OpenGL::VertexComponentIndex[j], 1); - } - else - glDisableVertexAttribArray(OpenGL::VertexComponentIndex[j]); - } - } - - if (!s_instancing) - { - // Je ne sais pas si c'est vraiment nécessaire de désactiver les attributs, sur mon ordinateur ça ne pose aucun problème - // mais dans le doute, je laisse ça comme ça. - for (unsigned int i = VertexComponent_FirstInstanceData; i <= VertexComponent_LastInstanceData; ++i) - glDisableVertexAttribArray(OpenGL::VertexComponentIndex[i]); - } - - // Et on active l'index buffer (Un seul index buffer par VAO) - if (s_indexBuffer) - { - HardwareBuffer* indexBufferImpl = static_cast(s_indexBuffer->GetBuffer()->GetImpl()); - glBindBuffer(OpenGL::BufferTarget[BufferType_Index], indexBufferImpl->GetOpenGLID()); - } - else - glBindBuffer(OpenGL::BufferTarget[BufferType_Index], 0); - - // On invalide les bindings des buffers (car nous les avons défini manuellement) - OpenGL::SetBuffer(BufferType_Index, 0); - OpenGL::SetBuffer(BufferType_Vertex, 0); - - if (updateFailed) - { - // La création de notre VAO a échoué, libérons-le et marquons-le comme problématique - glDeleteVertexArrays(1, &vaoIt->second.vao); - vaoIt->second.vao = 0; - s_currentVAO = 0; - } - else - glBindVertexArray(0); // On marque la fin de la construction du VAO en le débindant - } - else - // Notre VAO existe déjà, il est donc inutile de le reprogrammer - s_currentVAO = vaoIt->second.vao; - - // En cas de non-support des VAOs, les attributs doivent être respécifiés à chaque frame - s_updateFlags &= ~Update_VAO; - } - - #ifdef NAZARA_DEBUG - if (s_updateFlags != Update_None && s_updateFlags != Update_VAO) - NazaraWarning("Update flags not fully cleared"); - #endif - } - - // On bind notre VAO - if (!s_currentVAO) - { - NazaraError("Failed to create VAO"); - return false; - } - - glBindVertexArray(s_currentVAO); - - // On vérifie que les textures actuellement bindées sont bien nos textures - // Ceci à cause du fait qu'il est possible que des opérations sur les textures aient eu lieu - // entre le dernier rendu et maintenant - for (unsigned int i = 0; i < s_maxTextureUnit; ++i) - { - const Texture* texture = s_textureUnits[i].texture; - if (texture) - { - OpenGL::BindTexture(i, texture->GetType(), texture->GetOpenGLID()); - texture->EnsureMipmapsUpdate(); - } - } - - // Et on termine par envoyer nos états au driver - OpenGL::ApplyStates(s_states); - - #ifdef NAZARA_DEBUG - if (!s_shader->Validate()) - { - NazaraError(Error::GetLastError()); - return false; - } - #endif - - return true; - } - - void Renderer::OnContextRelease(const Context* context) - { - s_vaos.erase(context); - } - - void Renderer::OnIndexBufferRelease(const IndexBuffer* indexBuffer) - { - for (auto& pair : s_vaos) - { - const Context* context = pair.first; - VAO_Map& vaos = pair.second.vaoMap; - - auto it = vaos.begin(); - while (it != vaos.end()) - { - const VAO_Key& key = it->first; - const IndexBuffer* vaoIndexBuffer = std::get<0>(key); - - if (vaoIndexBuffer == indexBuffer) - { - // Suppression du VAO: - // Comme celui-ci est local à son contexte de création, sa suppression n'est possible que si - // son contexte d'origine est actif, sinon il faudra le mettre en file d'attente - // Ceci est géré par la méthode OpenGL::DeleteVertexArray - - OpenGL::DeleteVertexArray(context, it->second.vao); - vaos.erase(it++); - } - else - ++it; - } - } - } - - void Renderer::OnShaderReleased(const Shader* shader) - { - if (s_shader == shader) - { - s_shader = nullptr; - s_updateFlags |= Update_Shader; - } - } - - void Renderer::OnTextureReleased(const Texture* texture) - { - for (TextureUnit& unit : s_textureUnits) - { - if (unit.texture == texture) - unit.texture = nullptr; - - // Inutile de changer le flag pour une texture désactivée - } - } - - void Renderer::OnVertexBufferRelease(const VertexBuffer* vertexBuffer) - { - for (auto& pair : s_vaos) - { - const Context* context = pair.first; - VAO_Map& vaos = pair.second.vaoMap; - - auto it = vaos.begin(); - while (it != vaos.end()) - { - const VAO_Key& key = it->first; - const VertexBuffer* vaoVertexBuffer = std::get<1>(key); - - if (vaoVertexBuffer == vertexBuffer) - { - // Suppression du VAO: - // Comme celui-ci est local à son contexte de création, sa suppression n'est possible que si - // son contexte d'origine est actif, sinon il faudra le mettre en file d'attente - // Ceci est géré par la méthode OpenGL::DeleteVertexArray - - OpenGL::DeleteVertexArray(context, it->second.vao); - vaos.erase(it++); - } - else - ++it; - } - } - } - - void Renderer::OnVertexDeclarationRelease(const VertexDeclaration* vertexDeclaration) - { - for (auto& pair : s_vaos) - { - const Context* context = pair.first; - VAO_Map& vaos = pair.second.vaoMap; - - auto it = vaos.begin(); - while (it != vaos.end()) - { - const VAO_Key& key = it->first; - const VertexDeclaration* vaoVertexDeclaration = std::get<2>(key); - const VertexDeclaration* vaoInstancingDeclaration = std::get<3>(key); - - if (vaoVertexDeclaration == vertexDeclaration || vaoInstancingDeclaration == vertexDeclaration) - { - // Suppression du VAO: - // Comme celui-ci est local à son contexte de création, sa suppression n'est possible que si - // son contexte d'origine est actif, sinon il faudra le mettre en file d'attente - // Ceci est géré par la méthode OpenGL::DeleteVertexArray - - OpenGL::DeleteVertexArray(context, it->second.vao); - vaos.erase(it++); - } - else - ++it; - } - } - } - - void Renderer::UpdateMatrix(MatrixType type) - { - #ifdef NAZARA_DEBUG - if (type > MatrixType_Max) - { - NazaraError("Matrix type out of enum"); - return; - } - #endif - - switch (type) - { - // Matrices de base - case MatrixType_Projection: - case MatrixType_View: - case MatrixType_World: - s_matrices[type].updated = true; - break; - - // Matrices combinées - case MatrixType_ViewProj: - s_matrices[MatrixType_ViewProj].matrix = s_matrices[MatrixType_View].matrix; - s_matrices[MatrixType_ViewProj].matrix.Concatenate(s_matrices[MatrixType_Projection].matrix); - s_matrices[MatrixType_ViewProj].updated = true; - break; - - case MatrixType_WorldView: - s_matrices[MatrixType_WorldView].matrix = s_matrices[MatrixType_World].matrix; - s_matrices[MatrixType_WorldView].matrix.ConcatenateAffine(s_matrices[MatrixType_View].matrix); - s_matrices[MatrixType_WorldView].updated = true; - break; - - case MatrixType_WorldViewProj: - if (!s_matrices[MatrixType_WorldView].updated) - UpdateMatrix(MatrixType_WorldView); - - s_matrices[MatrixType_WorldViewProj].matrix = s_matrices[MatrixType_WorldView].matrix; - s_matrices[MatrixType_WorldViewProj].matrix.Concatenate(s_matrices[MatrixType_Projection].matrix); - s_matrices[MatrixType_WorldViewProj].updated = true; - break; - - // Matrices inversées - case MatrixType_InvProjection: - if (!s_matrices[MatrixType_Projection].updated) - UpdateMatrix(MatrixType_Projection); - - if (!s_matrices[MatrixType_Projection].matrix.GetInverse(&s_matrices[MatrixType_InvProjection].matrix)) - NazaraWarning("Failed to inverse Proj matrix"); - - s_matrices[MatrixType_InvProjection].updated = true; - break; - - case MatrixType_InvView: - if (!s_matrices[MatrixType_View].updated) - UpdateMatrix(MatrixType_View); - - if (!s_matrices[MatrixType_View].matrix.GetInverse(&s_matrices[MatrixType_InvView].matrix)) - NazaraWarning("Failed to inverse View matrix"); - - s_matrices[MatrixType_InvView].updated = true; - break; - - case MatrixType_InvViewProj: - if (!s_matrices[MatrixType_ViewProj].updated) - UpdateMatrix(MatrixType_ViewProj); - - if (!s_matrices[MatrixType_ViewProj].matrix.GetInverse(&s_matrices[MatrixType_InvViewProj].matrix)) - NazaraWarning("Failed to inverse ViewProj matrix"); - - s_matrices[MatrixType_InvViewProj].updated = true; - break; - - case MatrixType_InvWorld: - if (!s_matrices[MatrixType_World].updated) - UpdateMatrix(MatrixType_World); - - if (!s_matrices[MatrixType_World].matrix.GetInverse(&s_matrices[MatrixType_InvWorld].matrix)) - NazaraWarning("Failed to inverse World matrix"); - - s_matrices[MatrixType_InvWorld].updated = true; - break; - - case MatrixType_InvWorldView: - if (!s_matrices[MatrixType_WorldView].updated) - UpdateMatrix(MatrixType_WorldView); - - if (!s_matrices[MatrixType_WorldView].matrix.GetInverse(&s_matrices[MatrixType_InvWorldView].matrix)) - NazaraWarning("Failed to inverse WorldView matrix"); - - s_matrices[MatrixType_InvWorldView].updated = true; - break; - - case MatrixType_InvWorldViewProj: - if (!s_matrices[MatrixType_WorldViewProj].updated) - UpdateMatrix(MatrixType_WorldViewProj); - - if (!s_matrices[MatrixType_WorldViewProj].matrix.GetInverse(&s_matrices[MatrixType_InvWorldViewProj].matrix)) - NazaraWarning("Failed to inverse WorldViewProj matrix"); - - s_matrices[MatrixType_InvWorldViewProj].updated = true; - break; - } - } - + DynLib Renderer::s_rendererLib; + std::unique_ptr Renderer::s_rendererImpl; unsigned int Renderer::s_moduleReferenceCounter = 0; } diff --git a/src/Nazara/Renderer/RendererImpl.cpp b/src/Nazara/Renderer/RendererImpl.cpp new file mode 100644 index 000000000..f674e1098 --- /dev/null +++ b/src/Nazara/Renderer/RendererImpl.cpp @@ -0,0 +1,11 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + RendererImpl::~RendererImpl() = default; +} diff --git a/src/Nazara/Renderer/Resources/Shaders/Debug/core.frag b/src/Nazara/Renderer/Resources/Shaders/Debug/core.frag deleted file mode 100644 index 4bb28b00c..000000000 --- a/src/Nazara/Renderer/Resources/Shaders/Debug/core.frag +++ /dev/null @@ -1,13 +0,0 @@ -#version 140 - -/********************Sortant********************/ -out vec4 RenderTarget0; - -/********************Uniformes********************/ -uniform vec4 Color; - -/********************Fonctions********************/ -void main() -{ - RenderTarget0 = Color; -} \ No newline at end of file diff --git a/src/Nazara/Renderer/Resources/Shaders/Debug/core.frag.h b/src/Nazara/Renderer/Resources/Shaders/Debug/core.frag.h deleted file mode 100644 index bbb324c3c..000000000 --- a/src/Nazara/Renderer/Resources/Shaders/Debug/core.frag.h +++ /dev/null @@ -1 +0,0 @@ -35,118,101,114,115,105,111,110,32,49,52,48,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,83,111,114,116,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,111,117,116,32,118,101,99,52,32,82,101,110,100,101,114,84,97,114,103,101,116,48,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,117,110,105,102,111,114,109,32,118,101,99,52,32,67,111,108,111,114,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,9,82,101,110,100,101,114,84,97,114,103,101,116,48,32,61,32,67,111,108,111,114,59,13,10,125, \ No newline at end of file diff --git a/src/Nazara/Renderer/Resources/Shaders/Debug/core.vert b/src/Nazara/Renderer/Resources/Shaders/Debug/core.vert deleted file mode 100644 index e7806ffdf..000000000 --- a/src/Nazara/Renderer/Resources/Shaders/Debug/core.vert +++ /dev/null @@ -1,13 +0,0 @@ -#version 140 - -/********************Entrant********************/ -in vec3 VertexPosition; - -/********************Uniformes********************/ -uniform mat4 WorldViewProjMatrix; - -/********************Fonctions********************/ -void main() -{ - gl_Position = WorldViewProjMatrix * vec4(VertexPosition, 1.0); -} diff --git a/src/Nazara/Renderer/Resources/Shaders/Debug/core.vert.h b/src/Nazara/Renderer/Resources/Shaders/Debug/core.vert.h deleted file mode 100644 index 48c552e2d..000000000 --- a/src/Nazara/Renderer/Resources/Shaders/Debug/core.vert.h +++ /dev/null @@ -1 +0,0 @@ -35,118,101,114,115,105,111,110,32,49,52,48,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,69,110,116,114,97,110,116,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,105,110,32,118,101,99,51,32,86,101,114,116,101,120,80,111,115,105,116,105,111,110,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,85,110,105,102,111,114,109,101,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,117,110,105,102,111,114,109,32,109,97,116,52,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,59,13,10,13,10,47,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,70,111,110,99,116,105,111,110,115,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,47,13,10,118,111,105,100,32,109,97,105,110,40,41,13,10,123,13,10,9,103,108,95,80,111,115,105,116,105,111,110,32,61,32,87,111,114,108,100,86,105,101,119,80,114,111,106,77,97,116,114,105,120,32,42,32,118,101,99,52,40,86,101,114,116,101,120,80,111,115,105,116,105,111,110,44,32,49,46,48,41,59,13,10,125,13,10, \ No newline at end of file diff --git a/src/Nazara/Renderer/Shader.cpp b/src/Nazara/Renderer/Shader.cpp deleted file mode 100644 index 65deb8b3b..000000000 --- a/src/Nazara/Renderer/Shader.cpp +++ /dev/null @@ -1,841 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - Shader::Shader() : - m_linked(false), - m_program(0) - { - } - - Shader::~Shader() - { - OnShaderRelease(this); - - Destroy(); - } - - void Shader::AttachStage(ShaderStageType stage, const ShaderStage& shaderStage) - { - #if NAZARA_RENDERER_SAFE - if (!m_program) - { - NazaraError("Invalid program"); - return; - } - - if (!shaderStage.IsValid()) - { - NazaraError("Invalid shader stage"); - return; - } - - if (!shaderStage.IsCompiled()) - { - NazaraError("Shader stage must be compiled"); - return; - } - #endif - - unsigned int shader = shaderStage.GetOpenGLID(); - - #if NAZARA_RENDERER_SAFE - if (std::find(m_attachedShaders[stage].begin(), m_attachedShaders[stage].end(), shader) != m_attachedShaders[stage].end()) - { - NazaraError("Shader stage is already attached"); - return; - } - #endif - - glAttachShader(m_program, shader); - m_attachedShaders[stage].push_back(shader); - } - - bool Shader::AttachStageFromFile(ShaderStageType stage, const String& filePath) - { - ShaderStage shaderStage(stage); - if (!shaderStage.IsValid()) - { - NazaraError("Failed to create shader stage"); - return false; - } - - shaderStage.SetSourceFromFile(filePath); - - if (!shaderStage.Compile()) - { - NazaraError("Failed to compile stage: " + shaderStage.GetLog()); - return false; - } - - AttachStage(stage, shaderStage); - return true; - } - - bool Shader::AttachStageFromSource(ShaderStageType stage, const char* source, unsigned int length) - { - ShaderStage shaderStage(stage); - if (!shaderStage.IsValid()) - { - NazaraError("Failed to create shader stage"); - return false; - } - - shaderStage.SetSource(source, length); - - if (!shaderStage.Compile()) - { - NazaraError("Failed to compile stage: " + shaderStage.GetLog()); - return false; - } - - AttachStage(stage, shaderStage); - return true; - } - - bool Shader::AttachStageFromSource(ShaderStageType stage, const String& source) - { - ShaderStage shaderStage(stage); - if (!shaderStage.IsValid()) - { - NazaraError("Failed to create shader stage"); - return false; - } - - shaderStage.SetSource(source); - - if (!shaderStage.Compile()) - { - NazaraError("Failed to compile stage: " + shaderStage.GetLog()); - return false; - } - - AttachStage(stage, shaderStage); - return true; - } - - void Shader::Bind() const - { - OpenGL::BindProgram(m_program); - } - - bool Shader::Create() - { - Context::EnsureContext(); - - m_program = glCreateProgram(); - if (!m_program) - { - NazaraError("Failed to create program"); - return false; - } - - m_linked = false; - - glBindAttribLocation(m_program, OpenGL::VertexComponentIndex[VertexComponent_InstanceData0], "InstanceData0"); - glBindAttribLocation(m_program, OpenGL::VertexComponentIndex[VertexComponent_InstanceData1], "InstanceData1"); - glBindAttribLocation(m_program, OpenGL::VertexComponentIndex[VertexComponent_InstanceData2], "InstanceData2"); - glBindAttribLocation(m_program, OpenGL::VertexComponentIndex[VertexComponent_InstanceData3], "InstanceData3"); - glBindAttribLocation(m_program, OpenGL::VertexComponentIndex[VertexComponent_InstanceData4], "InstanceData4"); - glBindAttribLocation(m_program, OpenGL::VertexComponentIndex[VertexComponent_InstanceData5], "InstanceData5"); - glBindAttribLocation(m_program, OpenGL::VertexComponentIndex[VertexComponent_Color], "VertexColor"); - glBindAttribLocation(m_program, OpenGL::VertexComponentIndex[VertexComponent_Normal], "VertexNormal"); - glBindAttribLocation(m_program, OpenGL::VertexComponentIndex[VertexComponent_Position], "VertexPosition"); - glBindAttribLocation(m_program, OpenGL::VertexComponentIndex[VertexComponent_Tangent], "VertexTangent"); - glBindAttribLocation(m_program, OpenGL::VertexComponentIndex[VertexComponent_TexCoord], "VertexTexCoord"); - glBindAttribLocation(m_program, OpenGL::VertexComponentIndex[VertexComponent_Userdata0], "VertexUserdata0"); - glBindAttribLocation(m_program, OpenGL::VertexComponentIndex[VertexComponent_Userdata1], "VertexUserdata1"); - glBindAttribLocation(m_program, OpenGL::VertexComponentIndex[VertexComponent_Userdata2], "VertexUserdata2"); - glBindAttribLocation(m_program, OpenGL::VertexComponentIndex[VertexComponent_Userdata3], "VertexUserdata3"); - glBindAttribLocation(m_program, OpenGL::VertexComponentIndex[VertexComponent_Userdata4], "VertexUserdata4"); - - String uniform; - uniform = "RenderTarget"; - - unsigned int maxRenderTargets = Renderer::GetMaxRenderTargets(); - for (unsigned int i = 0; i < maxRenderTargets; ++i) - { - String uniformName = uniform + String::Number(i); - glBindFragDataLocation(m_program, i, uniformName.GetConstBuffer()); - } - - if (OpenGL::IsSupported(OpenGLExtension_GetProgramBinary)) - glProgramParameteri(m_program, GL_PROGRAM_BINARY_RETRIEVABLE_HINT, GL_TRUE); - - return true; - } - - void Shader::Destroy() - { - if (m_program) - { - OnShaderDestroy(this); - - Context::EnsureContext(); - OpenGL::DeleteProgram(m_program); - m_program = 0; - } - } - - ByteArray Shader::GetBinary() const - { - ByteArray byteArray; - - Context::EnsureContext(); - - GLint binaryLength = 0; - glGetProgramiv(m_program, GL_PROGRAM_BINARY_LENGTH, &binaryLength); - - if (binaryLength > 0) - { - byteArray.Reserve(sizeof(UInt64) + binaryLength); - - UInt8* buffer = byteArray.GetBuffer(); - - GLenum binaryFormat; - glGetProgramBinary(m_program, binaryLength, nullptr, &binaryFormat, &buffer[sizeof(UInt64)]); - - // On stocke le format au début du binaire - *reinterpret_cast(&buffer[0]) = binaryFormat; - } - - return byteArray; - } - - String Shader::GetLog() const - { - #if NAZARA_RENDERER_SAFE - if (!m_program) - { - NazaraError("Shader is not initialized"); - return String(); - } - #endif - - String log; - - GLint length = 0; - glGetProgramiv(m_program, GL_INFO_LOG_LENGTH, &length); - if (length > 1) // Le caractère de fin faisant partie du compte - { - log.Set(length - 1, '\0'); // La taille retournée est celle du buffer (Avec caractère de fin) - glGetProgramInfoLog(m_program, length, nullptr, &log[0]); - } - else - log = "No log."; - - return log; - } - - String Shader::GetSourceCode(ShaderStageType stage) const - { - if (!HasStage(stage)) - return String(); - - Context::EnsureContext(); - - static const char sep[] = "\n////////////////////////////////////////////////////////////////////////////////\n\n"; - - unsigned int totalLength = 0; - for (unsigned int shader : m_attachedShaders[stage]) - { - GLint length; - glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &length); - - totalLength += length - 1; - } - - totalLength += (m_attachedShaders[stage].size()-1) * (sizeof(sep)/sizeof(char)); - - String source(totalLength, '\0'); - - unsigned int offset = 0; - for (unsigned int shader : m_attachedShaders[stage]) - { - if (offset > 0) - { - std::memcpy(&source[offset], sep, sizeof(sep)); - offset += sizeof(sep)/sizeof(char); - } - - GLint length; - glGetShaderSource(shader, totalLength, &length, &source[offset]); - - offset += length; - } - - return source; - } - - int Shader::GetUniformLocation(const String& name) const - { - Context::EnsureContext(); - - return glGetUniformLocation(m_program, name.GetConstBuffer()); - } - - int Shader::GetUniformLocation(ShaderUniform shaderUniform) const - { - return m_uniformLocations[shaderUniform]; - } - - bool Shader::HasStage(ShaderStageType stage) const - { - return !m_attachedShaders[stage].empty(); - } - - bool Shader::IsBinaryRetrievable() const - { - return OpenGL::IsSupported(OpenGLExtension_GetProgramBinary); - } - - bool Shader::IsLinked() const - { - return m_linked; - } - - bool Shader::IsValid() const - { - return m_program != 0; - } - - bool Shader::Link() - { - Context::EnsureContext(); - - glLinkProgram(m_program); - - return PostLinkage(); - } - - bool Shader::LoadFromBinary(const void* buffer, unsigned int size) - { - #if NAZARA_RENDERER_SAFE - if (!glProgramBinary) - { - NazaraError("GL_ARB_get_program_binary not supported"); - return false; - } - - if (!buffer || size < sizeof(UInt64)) - { - NazaraError("Invalid buffer"); - return false; - } - #endif - - Context::EnsureContext(); - - const UInt8* ptr = reinterpret_cast(buffer); - - // On récupère le format au début du binaire - ///TODO: ByteStream ? - GLenum binaryFormat = static_cast(*reinterpret_cast(&ptr[0])); - ptr += sizeof(UInt64); - - glProgramBinary(m_program, binaryFormat, ptr, size - sizeof(UInt64)); - - return PostLinkage(); - } - - bool Shader::LoadFromBinary(const ByteArray& byteArray) - { - return LoadFromBinary(byteArray.GetConstBuffer(), byteArray.GetSize()); - } - - void Shader::SendBoolean(int location, bool value) const - { - if (location == -1) - return; - - if (glProgramUniform1i) - glProgramUniform1i(m_program, location, value); - else - { - OpenGL::BindProgram(m_program); - glUniform1i(location, value); - } - } - - void Shader::SendColor(int location, const Color& color) const - { - if (location == -1) - return; - - Vector4f vecColor(color.r/255.f, color.g/255.f, color.b/255.f, color.a/255.f); - - if (glProgramUniform4fv) - glProgramUniform4fv(m_program, location, 1, vecColor); - else - { - OpenGL::BindProgram(m_program); - glUniform4fv(location, 1, vecColor); - } - } - - void Shader::SendDouble(int location, double value) const - { - if (location == -1) - return; - - if (glProgramUniform1d) - glProgramUniform1d(m_program, location, value); - else - { - OpenGL::BindProgram(m_program); - glUniform1d(location, value); - } - } - - void Shader::SendDoubleArray(int location, const double* values, unsigned int count) const - { - if (location == -1) - return; - - if (glProgramUniform1dv) - glProgramUniform1dv(m_program, location, count, values); - else - { - OpenGL::BindProgram(m_program); - glUniform1dv(location, count, values); - } - } - - void Shader::SendFloat(int location, float value) const - { - if (location == -1) - return; - - if (glProgramUniform1f) - glProgramUniform1f(m_program, location, value); - else - { - OpenGL::BindProgram(m_program); - glUniform1f(location, value); - } - } - - void Shader::SendFloatArray(int location, const float* values, unsigned int count) const - { - if (location == -1) - return; - - if (glProgramUniform1fv) - glProgramUniform1fv(m_program, location, count, values); - else - { - OpenGL::BindProgram(m_program); - glUniform1fv(location, count, values); - } - } - - void Shader::SendInteger(int location, int value) const - { - if (location == -1) - return; - - if (glProgramUniform1i) - glProgramUniform1i(m_program, location, value); - else - { - OpenGL::BindProgram(m_program); - glUniform1i(location, value); - } - } - - void Shader::SendIntegerArray(int location, const int* values, unsigned int count) const - { - if (location == -1) - return; - - if (glProgramUniform1iv) - glProgramUniform1iv(m_program, location, count, values); - else - { - OpenGL::BindProgram(m_program); - glUniform1iv(location, count, values); - } - } - - void Shader::SendMatrix(int location, const Matrix4d& matrix) const - { - if (location == -1) - return; - - if (glProgramUniformMatrix4dv) - glProgramUniformMatrix4dv(m_program, location, 1, GL_FALSE, matrix); - else - { - OpenGL::BindProgram(m_program); - glUniformMatrix4dv(location, 1, GL_FALSE, matrix); - } - } - - void Shader::SendMatrix(int location, const Matrix4f& matrix) const - { - if (location == -1) - return; - - if (glProgramUniformMatrix4fv) - glProgramUniformMatrix4fv(m_program, location, 1, GL_FALSE, matrix); - else - { - OpenGL::BindProgram(m_program); - glUniformMatrix4fv(location, 1, GL_FALSE, matrix); - } - } - - void Shader::SendVector(int location, const Vector2d& vector) const - { - if (location == -1) - return; - - if (glProgramUniform2dv) - glProgramUniform2dv(m_program, location, 1, vector); - else - { - OpenGL::BindProgram(m_program); - glUniform2dv(location, 1, vector); - } - } - - void Shader::SendVector(int location, const Vector2f& vector) const - { - if (location == -1) - return; - - if (glProgramUniform2fv) - glProgramUniform2fv(m_program, location, 1, vector); - else - { - OpenGL::BindProgram(m_program); - glUniform2fv(location, 1, vector); - } - } - - void Shader::SendVector(int location, const Vector2i& vector) const - { - if (location == -1) - return; - - if (glProgramUniform2fv) - glProgramUniform2iv(m_program, location, 1, vector); - else - { - OpenGL::BindProgram(m_program); - glUniform2iv(location, 1, vector); - } - } - - void Shader::SendVector(int location, const Vector3d& vector) const - { - if (location == -1) - return; - - if (glProgramUniform3dv) - glProgramUniform3dv(m_program, location, 1, vector); - else - { - OpenGL::BindProgram(m_program); - glUniform3dv(location, 1, vector); - } - } - - void Shader::SendVector(int location, const Vector3f& vector) const - { - if (location == -1) - return; - - if (glProgramUniform3fv) - glProgramUniform3fv(m_program, location, 1, vector); - else - { - OpenGL::BindProgram(m_program); - glUniform3fv(location, 1, vector); - } - } - - void Shader::SendVector(int location, const Vector3i& vector) const - { - if (location == -1) - return; - - if (glProgramUniform3iv) - glProgramUniform3iv(m_program, location, 1, vector); - else - { - OpenGL::BindProgram(m_program); - glUniform3iv(location, 1, vector); - } - } - - void Shader::SendVector(int location, const Vector4d& vector) const - { - if (location == -1) - return; - - if (glProgramUniform4dv) - glProgramUniform4dv(m_program, location, 1, vector); - else - { - OpenGL::BindProgram(m_program); - glUniform4dv(location, 1, vector); - } - } - - void Shader::SendVector(int location, const Vector4f& vector) const - { - if (location == -1) - return; - - if (glProgramUniform4fv) - glProgramUniform4fv(m_program, location, 1, vector); - else - { - OpenGL::BindProgram(m_program); - glUniform4fv(location, 1, vector); - } - } - - void Shader::SendVector(int location, const Vector4i& vector) const - { - if (location == -1) - return; - - if (glProgramUniform4iv) - glProgramUniform4iv(m_program, location, 1, vector); - else - { - OpenGL::BindProgram(m_program); - glUniform4iv(location, 1, vector); - } - } - - void Shader::SendVectorArray(int location, const Vector2d* vectors, unsigned int count) const - { - if (location == -1) - return; - - if (glProgramUniform2dv) - glProgramUniform2dv(m_program, location, count, reinterpret_cast(vectors)); - else - { - OpenGL::BindProgram(m_program); - glUniform2dv(location, count, reinterpret_cast(vectors)); - } - } - - void Shader::SendVectorArray(int location, const Vector2f* vectors, unsigned int count) const - { - if (location == -1) - return; - - if (glProgramUniform2fv) - glProgramUniform2fv(m_program, location, count, reinterpret_cast(vectors)); - else - { - OpenGL::BindProgram(m_program); - glUniform2fv(location, count, reinterpret_cast(vectors)); - } - } - - void Shader::SendVectorArray(int location, const Vector2i* vectors, unsigned int count) const - { - if (location == -1) - return; - - if (glProgramUniform2iv) - glProgramUniform2iv(m_program, location, count, reinterpret_cast(vectors)); - else - { - OpenGL::BindProgram(m_program); - glUniform2iv(location, count, reinterpret_cast(vectors)); - } - } - - void Shader::SendVectorArray(int location, const Vector3d* vectors, unsigned int count) const - { - if (location == -1) - return; - - if (glProgramUniform3dv) - glProgramUniform3dv(m_program, location, count, reinterpret_cast(vectors)); - else - { - OpenGL::BindProgram(m_program); - glUniform3dv(location, count, reinterpret_cast(vectors)); - } - } - - void Shader::SendVectorArray(int location, const Vector3f* vectors, unsigned int count) const - { - if (location == -1) - return; - - if (glProgramUniform3fv) - glProgramUniform3fv(m_program, location, count, reinterpret_cast(vectors)); - else - { - OpenGL::BindProgram(m_program); - glUniform3fv(location, count, reinterpret_cast(vectors)); - } - } - - void Shader::SendVectorArray(int location, const Vector3i* vectors, unsigned int count) const - { - if (location == -1) - return; - - if (glProgramUniform3iv) - glProgramUniform3iv(m_program, location, count, reinterpret_cast(vectors)); - else - { - OpenGL::BindProgram(m_program); - glUniform3iv(location, count, reinterpret_cast(vectors)); - } - } - - void Shader::SendVectorArray(int location, const Vector4d* vectors, unsigned int count) const - { - if (location == -1) - return; - - if (glProgramUniform4dv) - glProgramUniform4dv(m_program, location, count, reinterpret_cast(vectors)); - else - { - OpenGL::BindProgram(m_program); - glUniform4dv(location, count, reinterpret_cast(vectors)); - } - } - - void Shader::SendVectorArray(int location, const Vector4f* vectors, unsigned int count) const - { - if (location == -1) - return; - - if (glProgramUniform4fv) - glProgramUniform4fv(m_program, location, count, reinterpret_cast(vectors)); - else - { - OpenGL::BindProgram(m_program); - glUniform4fv(location, count, reinterpret_cast(vectors)); - } - } - - void Shader::SendVectorArray(int location, const Vector4i* vectors, unsigned int count) const - { - if (location == -1) - return; - - if (glProgramUniform4iv) - glProgramUniform4iv(m_program, location, count, reinterpret_cast(vectors)); - else - { - OpenGL::BindProgram(m_program); - glUniform4iv(location, count, reinterpret_cast(vectors)); - } - } - - bool Shader::Validate() const - { - #if NAZARA_RENDERER_SAFE - if (!m_program) - { - NazaraError("Shader is not initialized"); - return false; - } - #endif - - glValidateProgram(m_program); - - GLint success; - glGetProgramiv(m_program, GL_VALIDATE_STATUS, &success); - - if (success == GL_TRUE) - return true; - else - { - NazaraError("Failed to validate shader: " + GetLog()); - return false; - } - } - - - unsigned int Shader::GetOpenGLID() const - { - return m_program; - } - - bool Shader::IsStageSupported(ShaderStageType stage) - { - return ShaderStage::IsSupported(stage); - } - - bool Shader::PostLinkage() - { - GLint success; - glGetProgramiv(m_program, GL_LINK_STATUS, &success); - - m_linked = (success == GL_TRUE); - if (m_linked) - { - // Pour éviter de se tromper entre le nom et la constante - #define CacheUniform(name) m_uniformLocations[ShaderUniform_##name] = glGetUniformLocation(m_program, #name) - - CacheUniform(InvProjMatrix); - CacheUniform(InvTargetSize); - CacheUniform(InvViewMatrix); - CacheUniform(InvViewProjMatrix); - CacheUniform(InvWorldMatrix); - CacheUniform(InvWorldViewMatrix); - CacheUniform(InvWorldViewProjMatrix); - CacheUniform(ProjMatrix); - CacheUniform(TargetSize); - CacheUniform(ViewMatrix); - CacheUniform(ViewProjMatrix); - CacheUniform(WorldMatrix); - CacheUniform(WorldViewMatrix); - CacheUniform(WorldViewProjMatrix); - - #undef CacheUniform - - OnShaderUniformInvalidated(this); - - return true; - } - else - { - NazaraError("Failed to link shader: " + GetLog()); - return false; - } - } - - bool Shader::Initialize() - { - if (!ShaderLibrary::Initialize()) - { - NazaraError("Failed to initialise library"); - return false; - } - - return true; - } - - void Shader::Uninitialize() - { - ShaderLibrary::Uninitialize(); - } - - ShaderLibrary::LibraryMap Shader::s_library; -} diff --git a/src/Nazara/Renderer/ShaderStage.cpp b/src/Nazara/Renderer/ShaderStage.cpp deleted file mode 100644 index 771a2ced1..000000000 --- a/src/Nazara/Renderer/ShaderStage.cpp +++ /dev/null @@ -1,234 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - ShaderStage::ShaderStage() : - m_compiled(false), - m_id(0) - { - } - - ShaderStage::ShaderStage(ShaderStageType stage) : - ShaderStage() - { - Create(stage); - } - - ShaderStage::ShaderStage(ShaderStage&& stage) : - m_stage(stage.m_stage), - m_compiled(stage.m_compiled), - m_id(stage.m_id) - { - stage.m_id = 0; - } - - ShaderStage::~ShaderStage() - { - Destroy(); - } - - bool ShaderStage::Compile() - { - #if NAZARA_RENDERER_SAFE - if (!m_id) - { - NazaraError("Shader stage is not initialized"); - return false; - } - #endif - - glCompileShader(m_id); - - GLint success; - glGetShaderiv(m_id, GL_COMPILE_STATUS, &success); - - m_compiled = (success == GL_TRUE); - if (m_compiled) - return true; - else - { - NazaraError("Failed to compile shader stage: " + GetLog()); - return false; - } - } - - bool ShaderStage::Create(ShaderStageType stage) - { - Destroy(); - - m_id = glCreateShader(OpenGL::ShaderStage[stage]); - m_stage = stage; - - return (m_id != 0); - } - - void ShaderStage::Destroy() - { - m_compiled = false; - if (m_id) - { - glDeleteShader(m_id); - m_id = 0; - } - } - - String ShaderStage::GetLog() const - { - #if NAZARA_RENDERER_SAFE - if (!m_id) - { - NazaraError("Shader stage is not initialized"); - return String(); - } - #endif - - String log; - - GLint length = 0; - glGetShaderiv(m_id, GL_INFO_LOG_LENGTH, &length); - if (length > 1) // Le caractère de fin faisant partie du compte - { - log.Set(length - 1, '\0'); // La taille retournée est celle du buffer (Avec caractère de fin) - glGetShaderInfoLog(m_id, length, nullptr, &log[0]); - } - else - log = "No log."; - - return log; - } - - String ShaderStage::GetSource() const - { - #if NAZARA_RENDERER_SAFE - if (!m_id) - { - NazaraError("Shader stage is not initialized"); - return String(); - } - #endif - - String source; - - GLint length = 0; - glGetShaderiv(m_id, GL_SHADER_SOURCE_LENGTH, &length); - if (length > 1) // Le caractère de fin compte - { - source.Set(length - 1, '\0'); // La taille retournée est celle du buffer (Avec caractère de fin) - glGetShaderSource(m_id, length, nullptr, &source[0]); - } - - return source; - } - - bool ShaderStage::IsCompiled() const - { - return m_compiled; - } - - bool ShaderStage::IsValid() const - { - return m_id != 0; - } - - void ShaderStage::SetSource(const char* source, unsigned int length) - { - #if NAZARA_RENDERER_SAFE - if (!m_id) - { - NazaraError("Shader stage is not initialized"); - return; - } - #endif - - glShaderSource(m_id, 1, &source, reinterpret_cast(&length)); - } - - void ShaderStage::SetSource(const String& source) - { - #if NAZARA_RENDERER_SAFE - if (!m_id) - { - NazaraError("Shader stage is not initialized"); - return; - } - #endif - - const char* tmp = source.GetConstBuffer(); - GLint length = source.GetSize(); - glShaderSource(m_id, 1, &tmp, &length); - } - - bool ShaderStage::SetSourceFromFile(const String& filePath) - { - #if NAZARA_RENDERER_SAFE - if (!m_id) - { - NazaraError("Shader stage is not initialized"); - return false; - } - #endif - - File file(filePath); - if (!file.Open(OpenMode_ReadOnly | OpenMode_Text)) - { - NazaraError("Failed to open \"" + filePath + '"'); - return false; - } - - unsigned int length = static_cast(file.GetSize()); - - String source(length, '\0'); - - if (file.Read(&source[0], length) != length) - { - NazaraError("Failed to read program file"); - return false; - } - - file.Close(); - - SetSource(source); - return true; - } - - ShaderStage& ShaderStage::operator=(ShaderStage&& shader) - { - Destroy(); - - m_compiled = shader.m_compiled; - m_id = shader.m_id; - m_stage = shader.m_stage; - - shader.m_id = 0; - - return *this; - } - - // Fonctions OpenGL - unsigned int ShaderStage::GetOpenGLID() const - { - return m_id; - } - - bool ShaderStage::IsSupported(ShaderStageType stage) - { - switch (stage) - { - case ShaderStageType_Fragment: - case ShaderStageType_Geometry: - case ShaderStageType_Vertex: - return true; - - default: - NazaraError("Shader stage not handled (0x" + String::Number(stage, 16) + ')'); - return false; - } - } -} diff --git a/src/Nazara/Renderer/Texture.cpp b/src/Nazara/Renderer/Texture.cpp deleted file mode 100644 index 458fb9992..000000000 --- a/src/Nazara/Renderer/Texture.cpp +++ /dev/null @@ -1,1347 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - struct TextureImpl - { - GLuint id; - ImageType type; - PixelFormatType format; - UInt8 levelCount; - bool mipmapping = false; - bool mipmapsUpdated = true; - unsigned int depth; - unsigned int height; - unsigned int width; - }; - - namespace - { - inline unsigned int GetLevelSize(unsigned int size, UInt8 level) - { - // Contrairement à la classe Image, un appel à GetLevelSize(0, level) n'est pas possible - return std::max(size >> level, 1U); - } - - inline void SetUnpackAlignement(UInt8 bpp) - { - if (bpp % 8 == 0) - glPixelStorei(GL_UNPACK_ALIGNMENT, 8); - else if (bpp % 4 == 0) - glPixelStorei(GL_UNPACK_ALIGNMENT, 4); - else if (bpp % 2 == 0) - glPixelStorei(GL_UNPACK_ALIGNMENT, 2); - else - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - } - } - - Texture::Texture(ImageType type, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth, UInt8 levelCount) - { - ErrorFlags flags(ErrorFlag_ThrowException); - Create(type, format, width, height, depth, levelCount); - } - - Texture::Texture(const Image& image) - { - ErrorFlags flags(ErrorFlag_ThrowException); - LoadFromImage(image); - } - - Texture::~Texture() - { - OnTextureRelease(this); - - Destroy(); - Renderer::OnTextureReleased(this); ///TODO: Gets rid of this - } - - bool Texture::Create(ImageType type, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth, UInt8 levelCount) - { - Destroy(); - - #if NAZARA_RENDERER_SAFE - if (!IsTypeSupported(type)) - { - NazaraError("Texture's type not supported"); - return false; - } - - if (!PixelFormat::IsValid(format)) - { - NazaraError("Invalid pixel format"); - return false; - } - - if (!IsFormatSupported(format)) - { - NazaraError("Texture's format not supported"); - return false; - } - - if (width == 0) - { - NazaraError("Width must be at least 1 (0)"); - return false; - } - - if (height == 0) - { - NazaraError("Height must be at least 1 (0)"); - return false; - } - - if (depth == 0) - { - NazaraError("Depth must be at least 1 (0)"); - return false; - } - - switch (type) - { - case ImageType_1D: - if (height > 1) - { - NazaraError("One dimensional texture's height must be 1"); - return false; - } - - if (depth > 1) - { - NazaraError("1D textures must be 1 deep"); - return false; - } - break; - - case ImageType_1D_Array: - case ImageType_2D: - if (depth > 1) - { - NazaraError("2D textures must be 1 deep"); - return false; - } - break; - - case ImageType_2D_Array: - case ImageType_3D: - break; - - case ImageType_Cubemap: - if (depth > 1) - { - NazaraError("Cubemaps must be 1 deep"); - return false; - } - - if (width != height) - { - NazaraError("Cubemaps must have square dimensions"); - return false; - } - break; - } - #endif - - Context::EnsureContext(); - - if (IsMipmappingSupported()) - levelCount = std::min(levelCount, Image::GetMaxLevel(width, height, depth)); - else if (levelCount > 1) - { - NazaraWarning("Mipmapping not supported, reducing level count to 1"); - levelCount = 1; - } - - m_impl = new TextureImpl; - m_impl->depth = depth; - m_impl->format = format; - m_impl->height = height; - m_impl->levelCount = levelCount; - m_impl->type = type; - m_impl->width = width; - - glGenTextures(1, &m_impl->id); - OpenGL::BindTexture(m_impl->type, m_impl->id); - - // En cas d'erreur (sortie prématurée), on détruit la texture - CallOnExit onExit([this]() - { - Destroy(); - }); - - // On précise le nombre de mipmaps avant la spécification de la texture - // https://www.opengl.org/wiki/Hardware_specifics:_NVidia - SetMipmapRange(0, m_impl->levelCount-1); - if (m_impl->levelCount > 1U) - EnableMipmapping(true); - - // Vérification du support par la carte graphique (texture proxy) - if (!CreateTexture(true)) - { - NazaraError("Texture's parameters not supported by driver"); - return false; - } - - // Création de la texture - if (!CreateTexture(false)) - { - NazaraError("Failed to create texture"); - return false; - } - - onExit.Reset(); - return true; - } - - void Texture::Destroy() - { - if (m_impl) - { - OnTextureDestroy(this); - - Context::EnsureContext(); - OpenGL::DeleteTexture(m_impl->id); - - delete m_impl; - m_impl = nullptr; - } - } - - bool Texture::Download(Image* image) const - { - #if NAZARA_RENDERER_SAFE - if (!m_impl) - { - NazaraError("Texture must be valid"); - return false; - } - - if (!image) - { - NazaraError("Image must be valid"); - return false; - } - #endif - - OpenGL::Format format; - if (!OpenGL::TranslateFormat(m_impl->format, &format, OpenGL::FormatType_Texture)) - { - NazaraError("Failed to get OpenGL format"); - return false; - } - - if (!image->Create(m_impl->type, m_impl->format, m_impl->width, m_impl->height, m_impl->depth, m_impl->levelCount)) - { - NazaraError("Failed to create image"); - return false; - } - - // Téléchargement... - OpenGL::BindTexture(m_impl->type, m_impl->id); - for (UInt8 level = 0; level < m_impl->levelCount; ++level) - glGetTexImage(OpenGL::TextureTarget[m_impl->type], level, format.dataFormat, format.dataType, image->GetPixels(0, 0, 0, level)); - - return true; - } - - bool Texture::EnableMipmapping(bool enable) - { - #if NAZARA_RENDERER_SAFE - if (!m_impl) - { - NazaraError("Texture must be valid"); - return false; - } - #endif - - if (!IsMipmappingSupported()) - { - NazaraError("Mipmapping not supported"); - return false; - } - - if (m_impl->levelCount == 1) // Transformation d'une texture sans mipmaps vers une texture avec mipmaps - { - ///FIXME: Est-ce que cette opération est seulement possible ? - m_impl->levelCount = Image::GetMaxLevel(m_impl->width, m_impl->height, m_impl->depth); - SetMipmapRange(0, m_impl->levelCount-1); - } - - if (!m_impl->mipmapping && enable) - m_impl->mipmapsUpdated = false; - - m_impl->mipmapping = enable; - - return true; - } - - void Texture::EnsureMipmapsUpdate() const - { - if (m_impl->mipmapping && !m_impl->mipmapsUpdated) - { - OpenGL::BindTexture(m_impl->type, m_impl->id); - glGenerateMipmap(OpenGL::TextureTarget[m_impl->type]); - m_impl->mipmapsUpdated = true; - } - } - - unsigned int Texture::GetDepth(UInt8 level) const - { - #if NAZARA_RENDERER_SAFE - if (!m_impl) - { - NazaraError("Texture must be valid"); - return 0; - } - #endif - - return GetLevelSize(m_impl->depth, level); - } - - PixelFormatType Texture::GetFormat() const - { - #if NAZARA_RENDERER_SAFE - if (!m_impl) - { - NazaraError("Texture must be valid"); - return PixelFormatType_Undefined; - } - #endif - - return m_impl->format; - } - - unsigned int Texture::GetHeight(UInt8 level) const - { - #if NAZARA_RENDERER_SAFE - if (!m_impl) - { - NazaraError("Texture must be valid"); - return 0; - } - #endif - - return GetLevelSize(m_impl->height, level); - } - - UInt8 Texture::GetLevelCount() const - { - #if NAZARA_RENDERER_SAFE - if (!m_impl) - { - NazaraError("Texture must be valid"); - return 0; - } - #endif - - return m_impl->levelCount; - } - - UInt8 Texture::GetMaxLevel() const - { - #if NAZARA_RENDERER_SAFE - if (!m_impl) - { - NazaraError("Texture must be valid"); - return 0; - } - #endif - - return Image::GetMaxLevel(m_impl->type, m_impl->width, m_impl->height, m_impl->depth); - } - - std::size_t Texture::GetMemoryUsage() const - { - #if NAZARA_RENDERER_SAFE - if (!m_impl) - { - NazaraError("Texture must be valid"); - return 0; - } - #endif - - unsigned int width = m_impl->width; - unsigned int height = m_impl->height; - unsigned int depth = m_impl->depth; - - unsigned int size = 0; - for (unsigned int i = 0; i < m_impl->levelCount; ++i) - { - size += width * height * depth; - - if (width > 1) - width >>= 1; - - if (height > 1) - height >>= 1; - - if (depth > 1) - depth >>= 1; - } - - if (m_impl->type == ImageType_Cubemap) - size *= 6; - - return size * PixelFormat::GetBytesPerPixel(m_impl->format); - } - - std::size_t Texture::GetMemoryUsage(UInt8 level) const - { - #if NAZARA_UTILITY_SAFE - if (!m_impl) - { - NazaraError("Texture must be valid"); - return 0; - } - - if (level >= m_impl->levelCount) - { - NazaraError("Level out of bounds (" + String::Number(level) + " >= " + String::Number(m_impl->levelCount) + ')'); - return 0; - } - #endif - - return (GetLevelSize(m_impl->width, level)) * - (GetLevelSize(m_impl->height, level)) * - ((m_impl->type == ImageType_Cubemap) ? 6 : GetLevelSize(m_impl->depth, level)) * - PixelFormat::GetBytesPerPixel(m_impl->format); - } - - Vector3ui Texture::GetSize(UInt8 level) const - { - #if NAZARA_RENDERER_SAFE - if (!m_impl) - { - NazaraError("Texture must be valid"); - return Vector3ui(0, 0, 0); - } - #endif - - return Vector3ui(GetLevelSize(m_impl->width, level), GetLevelSize(m_impl->height, level), GetLevelSize(m_impl->depth, level)); - } - - ImageType Texture::GetType() const - { - #if NAZARA_RENDERER_SAFE - if (!m_impl) - { - NazaraError("Texture must be valid"); - return ImageType_2D; - } - #endif - - return m_impl->type; - } - - unsigned int Texture::GetWidth(UInt8 level) const - { - #if NAZARA_RENDERER_SAFE - if (!m_impl) - { - NazaraError("Texture must be valid"); - return 0; - } - #endif - - return GetLevelSize(m_impl->width, level); - } - - bool Texture::HasMipmaps() const - { - #if NAZARA_RENDERER_SAFE - if (!m_impl) - { - NazaraError("Texture must be valid"); - return false; - } - #endif - - return m_impl->levelCount > 1; - } - - void Texture::InvalidateMipmaps() - { - #if NAZARA_RENDERER_SAFE - if (!m_impl) - { - NazaraInternalError("Texture must be valid"); - return; - } - #endif - - m_impl->mipmapsUpdated = false; - } - - bool Texture::IsValid() const - { - return m_impl != nullptr; - } - - bool Texture::LoadFromFile(const String& filePath, const ImageParams& params, bool generateMipmaps) - { - Image image; - if (!image.LoadFromFile(filePath, params)) - { - NazaraError("Failed to load image"); - return false; - } - - return LoadFromImage(image, generateMipmaps); - } - - bool Texture::LoadFromImage(const Image& image, bool generateMipmaps) - { - #if NAZARA_RENDERER_SAFE - if (!image.IsValid()) - { - NazaraError("Image must be valid"); - return false; - } - #endif - - // Vive le Copy-On-Write - Image newImage(image); - - PixelFormatType format = newImage.GetFormat(); - if (!IsFormatSupported(format)) - { - ///TODO: Sélectionner le format le plus adapté selon les composantes présentes dans le premier format - PixelFormatType newFormat = (PixelFormat::HasAlpha(format)) ? PixelFormatType_BGRA8 : PixelFormatType_BGR8; - NazaraWarning("Format " + PixelFormat::GetName(format) + " not supported, trying to convert it to " + PixelFormat::GetName(newFormat) + "..."); - - if (PixelFormat::IsConversionSupported(format, newFormat)) - { - if (newImage.Convert(newFormat)) - { - NazaraWarning("Conversion succeed"); - format = newFormat; - } - else - { - NazaraError("Conversion failed"); - return false; - } - } - else - { - NazaraError("Conversion not supported"); - return false; - } - } - - ImageType type = newImage.GetType(); - UInt8 levelCount = newImage.GetLevelCount(); - if (!Create(type, format, newImage.GetWidth(), newImage.GetHeight(), newImage.GetDepth(), (generateMipmaps) ? 0xFF : levelCount)) - { - NazaraError("Failed to create texture"); - return false; - } - - CallOnExit destroyOnExit([this]() - { - Destroy(); - }); - - if (type == ImageType_Cubemap) - { - for (UInt8 level = 0; level < levelCount; ++level) - { - for (unsigned int i = 0; i <= CubemapFace_Max; ++i) - { - if (!Update(newImage.GetConstPixels(0, 0, i, level), Rectui(0, 0, newImage.GetWidth(level), newImage.GetHeight(level)), i, level)) - { - NazaraError("Failed to update texture"); - return false; - } - } - } - } - else - { - for (UInt8 level = 0; level < levelCount; ++level) - { - if (!Update(newImage.GetConstPixels(0, 0, 0, level), level)) - { - NazaraError("Failed to update texture"); - return false; - } - } - } - - // Keep resource path info - SetFilePath(image.GetFilePath()); - - destroyOnExit.Reset(); - - return true; - } - - bool Texture::LoadFromMemory(const void* data, std::size_t size, const ImageParams& params, bool generateMipmaps) - { - Image image; - if (!image.LoadFromMemory(data, size, params)) - { - NazaraError("Failed to load image"); - return false; - } - - return LoadFromImage(image, generateMipmaps); - } - - bool Texture::LoadFromStream(Stream& stream, const ImageParams& params, bool generateMipmaps) - { - Image image; - if (!image.LoadFromStream(stream, params)) - { - NazaraError("Failed to load image"); - return false; - } - - return LoadFromImage(image, generateMipmaps); - } - - bool Texture::LoadArrayFromFile(const String& filePath, const ImageParams& imageParams, bool generateMipmaps, const Vector2ui& atlasSize) - { - Image cubemap; - if (!cubemap.LoadArrayFromFile(filePath, imageParams, atlasSize)) - { - NazaraError("Failed to load cubemap"); - return false; - } - - return LoadFromImage(cubemap, generateMipmaps); - } - - bool Texture::LoadArrayFromImage(const Image& image, bool generateMipmaps, const Vector2ui& atlasSize) - { - Image cubemap; - if (!cubemap.LoadArrayFromImage(image, atlasSize)) - { - NazaraError("Failed to load cubemap"); - return false; - } - - return LoadFromImage(cubemap, generateMipmaps); - } - - bool Texture::LoadArrayFromMemory(const void* data, std::size_t size, const ImageParams& imageParams, bool generateMipmaps, const Vector2ui& atlasSize) - { - Image cubemap; - if (!cubemap.LoadArrayFromMemory(data, size, imageParams, atlasSize)) - { - NazaraError("Failed to load cubemap"); - return false; - } - - return LoadFromImage(cubemap, generateMipmaps); - } - - bool Texture::LoadArrayFromStream(Stream& stream, const ImageParams& imageParams, bool generateMipmaps, const Vector2ui& atlasSize) - { - Image cubemap; - if (!cubemap.LoadArrayFromStream(stream, imageParams, atlasSize)) - { - NazaraError("Failed to load cubemap"); - return false; - } - - return LoadFromImage(cubemap, generateMipmaps); - } - - bool Texture::LoadCubemapFromFile(const String& filePath, const ImageParams& imageParams, bool generateMipmaps, const CubemapParams& cubemapParams) - { - Image cubemap; - if (!cubemap.LoadCubemapFromFile(filePath, imageParams, cubemapParams)) - { - NazaraError("Failed to load cubemap"); - return false; - } - - return LoadFromImage(cubemap, generateMipmaps); - } - - bool Texture::LoadCubemapFromImage(const Image& image, bool generateMipmaps, const CubemapParams& params) - { - Image cubemap; - if (!cubemap.LoadCubemapFromImage(image, params)) - { - NazaraError("Failed to load cubemap"); - return false; - } - - return LoadFromImage(cubemap, generateMipmaps); - } - - bool Texture::LoadCubemapFromMemory(const void* data, std::size_t size, const ImageParams& imageParams, bool generateMipmaps, const CubemapParams& cubemapParams) - { - Image cubemap; - if (!cubemap.LoadCubemapFromMemory(data, size, imageParams, cubemapParams)) - { - NazaraError("Failed to load cubemap"); - return false; - } - - return LoadFromImage(cubemap, generateMipmaps); - } - - bool Texture::LoadCubemapFromStream(Stream& stream, const ImageParams& imageParams, bool generateMipmaps, const CubemapParams& cubemapParams) - { - Image cubemap; - if (!cubemap.LoadCubemapFromStream(stream, imageParams, cubemapParams)) - { - NazaraError("Failed to load cubemap"); - return false; - } - - return LoadFromImage(cubemap, generateMipmaps); - } - - bool Texture::LoadFaceFromFile(CubemapFace face, const String& filePath, const ImageParams& params) - { - #if NAZARA_RENDERER_SAFE - if (!m_impl) - { - NazaraError("Texture must be valid"); - return false; - } - - if (m_impl->type != ImageType_Cubemap) - { - NazaraError("Texture must be a cubemap"); - return false; - } - #endif - - Image image; - if (!image.LoadFromFile(filePath, params)) - { - NazaraError("Failed to load image"); - return false; - } - - if (!image.Convert(m_impl->format)) - { - NazaraError("Failed to convert image to texture format"); - return false; - } - - unsigned int faceSize = m_impl->width; - if (image.GetWidth() != faceSize || image.GetHeight() != faceSize) - { - NazaraError("Image size must match texture face size"); - return false; - } - - return Update(image, Rectui(0, 0, faceSize, faceSize), face); - } - - bool Texture::LoadFaceFromMemory(CubemapFace face, const void* data, std::size_t size, const ImageParams& params) - { - #if NAZARA_RENDERER_SAFE - if (!m_impl) - { - NazaraError("Texture must be valid"); - return false; - } - - if (m_impl->type != ImageType_Cubemap) - { - NazaraError("Texture must be a cubemap"); - return false; - } - #endif - - Image image; - if (!image.LoadFromMemory(data, size, params)) - { - NazaraError("Failed to load image"); - return false; - } - - if (!image.Convert(m_impl->format)) - { - NazaraError("Failed to convert image to texture format"); - return false; - } - - unsigned int faceSize = m_impl->width; - if (image.GetWidth() != faceSize || image.GetHeight() != faceSize) - { - NazaraError("Image size must match texture face size"); - return false; - } - - return Update(image, Rectui(0, 0, faceSize, faceSize), face); - } - - bool Texture::LoadFaceFromStream(CubemapFace face, Stream& stream, const ImageParams& params) - { - #if NAZARA_RENDERER_SAFE - if (!m_impl) - { - NazaraError("Texture must be valid"); - return false; - } - - if (m_impl->type != ImageType_Cubemap) - { - NazaraError("Texture must be a cubemap"); - return false; - } - #endif - - Image image; - if (!image.LoadFromStream(stream, params)) - { - NazaraError("Failed to load image"); - return false; - } - - if (!image.Convert(m_impl->format)) - { - NazaraError("Failed to convert image to texture format"); - return false; - } - - unsigned int faceSize = m_impl->width; - - if (image.GetWidth() != faceSize || image.GetHeight() != faceSize) - { - NazaraError("Image size must match texture face size"); - return false; - } - - return Update(image, Rectui(0, 0, faceSize, faceSize), face); - } - - bool Texture::SaveToFile(const String& filePath, const ImageParams& params) - { - Image image; - if (!Download(&image)) - { - NazaraError("Failed to download texture"); - return false; - } - - return image.SaveToFile(filePath, params); - } - - bool Texture::SaveToStream(Stream& stream, const String& format, const ImageParams& params) - { - Image image; - if (!Download(&image)) - { - NazaraError("Failed to download texture"); - return false; - } - - return image.SaveToStream(stream, format, params); - } - - bool Texture::SetMipmapRange(UInt8 minLevel, UInt8 maxLevel) - { - #if NAZARA_RENDERER_SAFE - if (!m_impl) - { - NazaraError("Texture must be valid"); - return false; - } - - if (minLevel >= m_impl->levelCount) - { - NazaraError("Minimum level cannot be greater or equal than level count (" + String::Number(minLevel) + " >= " + String::Number(m_impl->levelCount) + ')'); - return false; - } - - if (maxLevel < minLevel) - { - NazaraError("Minimum level cannot be greater than maximum level (" + String::Number(minLevel) + " < " + String::Number(maxLevel) + ')'); - return false; - } - #endif - - OpenGL::BindTexture(m_impl->type, m_impl->id); - glTexParameteri(OpenGL::TextureTarget[m_impl->type], GL_TEXTURE_BASE_LEVEL, minLevel); - glTexParameteri(OpenGL::TextureTarget[m_impl->type], GL_TEXTURE_MAX_LEVEL, maxLevel); - - return true; - } - - bool Texture::Update(const Image& image, UInt8 level) - { - #if NAZARA_RENDERER_SAFE - if (!image.IsValid()) - { - NazaraError("Image must be valid"); - return false; - } - - if (image.GetFormat() != m_impl->format) - { - NazaraError("Image format does not match texture format"); - return false; - } - #endif - - const UInt8* pixels = image.GetConstPixels(0, 0, 0, level); - if (!pixels) - { - NazaraError("Failed to access image's pixels"); - return false; - } - - return Update(pixels, image.GetWidth(level), image.GetHeight(level), level); - } - - bool Texture::Update(const Image& image, const Boxui& box, UInt8 level) - { - #if NAZARA_RENDERER_SAFE - if (!image.IsValid()) - { - NazaraError("Image must be valid"); - return false; - } - - if (image.GetFormat() != m_impl->format) - { - NazaraError("Image format does not match texture format"); - return false; - } - #endif - - const UInt8* pixels = image.GetConstPixels(0, 0, 0, level); - if (!pixels) - { - NazaraError("Failed to access image's pixels"); - return false; - } - - return Update(pixels, box, image.GetWidth(level), image.GetHeight(level), level); - } - - bool Texture::Update(const Image& image, const Rectui& rect, unsigned int z, UInt8 level) - { - #if NAZARA_RENDERER_SAFE - if (!image.IsValid()) - { - NazaraError("Image must be valid"); - return false; - } - - if (image.GetFormat() != m_impl->format) - { - NazaraError("Image format does not match texture format"); - return false; - } - #endif - - const UInt8* pixels = image.GetConstPixels(0, 0, 0, level); - if (!pixels) - { - NazaraError("Failed to access image's pixels"); - return false; - } - - return Update(pixels, rect, z, image.GetWidth(level), image.GetHeight(level), level); - } - - bool Texture::Update(const UInt8* pixels, unsigned int srcWidth, unsigned int srcHeight, UInt8 level) - { - #if NAZARA_RENDERER_SAFE - if (!m_impl) - { - NazaraError("Texture must be valid"); - return false; - } - #endif - - return Update(pixels, Boxui(GetLevelSize(m_impl->width, level), GetLevelSize(m_impl->height, level), GetLevelSize(m_impl->depth, level)), srcWidth, srcHeight, level); - } - - bool Texture::Update(const UInt8* pixels, const Boxui& box, unsigned int srcWidth, unsigned int srcHeight, UInt8 level) - { - #if NAZARA_RENDERER_SAFE - if (!m_impl) - { - NazaraError("Texture must be valid"); - return false; - } - - if (!pixels) - { - NazaraError("Invalid pixel source"); - return false; - } - - if (!box.IsValid()) - { - NazaraError("Invalid box"); - return false; - } - - unsigned int width = GetLevelSize(m_impl->width, level); - unsigned int height = GetLevelSize(m_impl->height, level); - unsigned int depth = (m_impl->type == ImageType_Cubemap) ? 6 : GetLevelSize(m_impl->depth, level); - if (box.x+box.width > width || box.y+box.height > height || box.z+box.depth > depth || - (m_impl->type == ImageType_Cubemap && box.depth > 1)) // Nous n'autorisons pas de modifier plus d'une face du cubemap à la fois - { - NazaraError("Cube dimensions are out of bounds"); - return false; - } - - if (level >= m_impl->levelCount) - { - NazaraError("Level out of bounds (" + String::Number(level) + " >= " + String::Number(m_impl->levelCount) + ')'); - return false; - } - #endif - - OpenGL::Format format; - if (!OpenGL::TranslateFormat(m_impl->format, &format, OpenGL::FormatType_Texture)) - { - NazaraError("Failed to get OpenGL format"); - return false; - } - - SetUnpackAlignement(PixelFormat::GetBytesPerPixel(m_impl->format)); - glPixelStorei(GL_UNPACK_ROW_LENGTH, srcWidth); - glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, srcHeight); - - OpenGL::BindTexture(m_impl->type, m_impl->id); - - if (PixelFormat::IsCompressed(m_impl->format)) - { - switch (m_impl->type) - { - case ImageType_1D: - glCompressedTexSubImage1D(GL_TEXTURE_1D, level, box.x, box.width, format.internalFormat, PixelFormat::ComputeSize(m_impl->format, box.width, 1, 1), pixels); - break; - - case ImageType_1D_Array: - case ImageType_2D: - glCompressedTexSubImage2D(OpenGL::TextureTarget[m_impl->type], level, box.x, box.y, box.width, box.height, format.internalFormat, PixelFormat::ComputeSize(m_impl->format, box.width, box.height, 1), pixels); - break; - - case ImageType_2D_Array: - case ImageType_3D: - glCompressedTexSubImage3D(OpenGL::TextureTarget[m_impl->type], level, box.x, box.y, box.z, box.width, box.height, box.depth, format.internalFormat, PixelFormat::ComputeSize(m_impl->format, box.width, box.height, box.depth), pixels); - break; - - case ImageType_Cubemap: - glCompressedTexSubImage2D(OpenGL::CubemapFace[box.z], level, box.x, box.y, box.width, box.height, format.internalFormat, PixelFormat::ComputeSize(m_impl->format, box.width, box.height, box.depth), pixels); - break; - } - } - else - { - switch (m_impl->type) - { - case ImageType_1D: - glTexSubImage1D(GL_TEXTURE_1D, level, box.x, box.width, format.dataFormat, format.dataType, pixels); - break; - - case ImageType_1D_Array: - case ImageType_2D: - glTexSubImage2D(OpenGL::TextureTarget[m_impl->type], level, box.x, box.y, box.width, box.height, format.dataFormat, format.dataType, pixels); - break; - - case ImageType_2D_Array: - case ImageType_3D: - glTexSubImage3D(OpenGL::TextureTarget[m_impl->type], level, box.x, box.y, box.z, box.width, box.height, box.depth, format.dataFormat, format.dataType, pixels); - break; - - case ImageType_Cubemap: - glTexSubImage2D(OpenGL::CubemapFace[box.z], level, box.x, box.y, box.width, box.height, format.dataFormat, format.dataType, pixels); - break; - } - } - - return true; - } - - bool Texture::Update(const UInt8* pixels, const Rectui& rect, unsigned int z, unsigned int srcWidth, unsigned int srcHeight, UInt8 level) - { - return Update(pixels, Boxui(rect.x, rect.y, z, rect.width, rect.height, 1), srcWidth, srcHeight, level); - } - - unsigned int Texture::GetOpenGLID() const - { - #if NAZARA_RENDERER_SAFE - if (!m_impl) - { - NazaraError("Texture must be valid"); - return 0; - } - #endif - - return m_impl->id; - } - - bool Texture::IsFormatSupported(PixelFormatType format) - { - switch (format) - { - // Formats de base - case PixelFormatType_A8: - case PixelFormatType_BGR8: - case PixelFormatType_BGRA8: - case PixelFormatType_L8: - case PixelFormatType_LA8: - case PixelFormatType_RGB8: - case PixelFormatType_RGBA8: - return true; - - // Packed formats supportés depuis OpenGL 1.2 - case PixelFormatType_RGB5A1: - case PixelFormatType_RGBA4: - return true; - - // Formats supportés depuis OpenGL 3 - case PixelFormatType_R8: - case PixelFormatType_R8I: - case PixelFormatType_R8UI: - case PixelFormatType_R16: - case PixelFormatType_R16F: - case PixelFormatType_R16I: - case PixelFormatType_R16UI: - case PixelFormatType_R32F: - case PixelFormatType_R32I: - case PixelFormatType_R32UI: - case PixelFormatType_RG8: - case PixelFormatType_RG8I: - case PixelFormatType_RG8UI: - case PixelFormatType_RG16: - case PixelFormatType_RG16F: - case PixelFormatType_RG16I: - case PixelFormatType_RG16UI: - case PixelFormatType_RG32F: - case PixelFormatType_RG32I: - case PixelFormatType_RG32UI: - case PixelFormatType_RGB16F: - case PixelFormatType_RGB16I: - case PixelFormatType_RGB16UI: - case PixelFormatType_RGB32F: - case PixelFormatType_RGB32I: - case PixelFormatType_RGB32UI: - case PixelFormatType_RGBA16F: - case PixelFormatType_RGBA16I: - case PixelFormatType_RGBA16UI: - case PixelFormatType_RGBA32F: - case PixelFormatType_RGBA32I: - case PixelFormatType_RGBA32UI: - return true; - - // Formats de profondeur (Supportés avec les FBOs) - case PixelFormatType_Depth16: - case PixelFormatType_Depth24: - case PixelFormatType_Depth32: - case PixelFormatType_Depth24Stencil8: - return true; - - // Formats de stencil (Non supportés pour les textures) - case PixelFormatType_Stencil1: - case PixelFormatType_Stencil4: - case PixelFormatType_Stencil8: - case PixelFormatType_Stencil16: - return false; - - // Formats compressés - case PixelFormatType_DXT1: - case PixelFormatType_DXT3: - case PixelFormatType_DXT5: - return OpenGL::IsSupported(OpenGLExtension_TextureCompression_s3tc); - - case PixelFormatType_Undefined: - break; - } - - NazaraError("Invalid pixel format"); - return false; - } - - bool Texture::IsMipmappingSupported() - { - return glGenerateMipmap != nullptr; - } - - bool Texture::IsTypeSupported(ImageType type) - { - switch (type) - { - case ImageType_1D: - case ImageType_1D_Array: - case ImageType_2D: - case ImageType_2D_Array: - case ImageType_3D: - case ImageType_Cubemap: - return true; // Tous supportés nativement dans OpenGL 3 - } - - NazaraError("Image type not handled (0x" + String::Number(type, 16) + ')'); - return false; - } - - bool Texture::CreateTexture(bool proxy) - { - OpenGL::Format openGLFormat; - if (!OpenGL::TranslateFormat(m_impl->format, &openGLFormat, OpenGL::FormatType_Texture)) - { - NazaraError("Format " + PixelFormat::GetName(m_impl->format) + " not supported by OpenGL"); - return false; - } - - GLenum target = (proxy) ? OpenGL::TextureTargetProxy[m_impl->type] : OpenGL::TextureTarget[m_impl->type]; - switch (m_impl->type) - { - case ImageType_1D: - { - if (glTexStorage1D && !proxy) // Les drivers AMD semblent ne pas aimer glTexStorage avec un format proxy - glTexStorage1D(target, m_impl->levelCount, openGLFormat.internalFormat, m_impl->width); - else - { - unsigned int w = m_impl->width; - for (UInt8 level = 0; level < m_impl->levelCount; ++level) - { - glTexImage1D(target, level, openGLFormat.internalFormat, w, 0, openGLFormat.dataFormat, openGLFormat.dataType, nullptr); - if (w > 1U) - w >>= 1; - } - } - break; - } - - case ImageType_1D_Array: - case ImageType_2D: - { - if (glTexStorage2D && !proxy) - glTexStorage2D(target, m_impl->levelCount, openGLFormat.internalFormat, m_impl->width, m_impl->height); - else - { - unsigned int w = m_impl->width; - unsigned int h = m_impl->height; - for (UInt8 level = 0; level < m_impl->levelCount; ++level) - { - glTexImage2D(target, level, openGLFormat.internalFormat, w, h, 0, openGLFormat.dataFormat, openGLFormat.dataType, nullptr); - if (w > 1U) - w >>= 1; - - if (h > 1U) - h >>= 1; - } - } - break; - } - - case ImageType_2D_Array: - case ImageType_3D: - { - if (glTexStorage3D && !proxy) - glTexStorage3D(target, m_impl->levelCount, openGLFormat.internalFormat, m_impl->width, m_impl->height, m_impl->depth); - else - { - unsigned int w = m_impl->width; - unsigned int h = m_impl->height; - unsigned int d = m_impl->depth; - for (UInt8 level = 0; level < m_impl->levelCount; ++level) - { - glTexImage3D(target, level, openGLFormat.internalFormat, w, h, d, 0, openGLFormat.dataFormat, openGLFormat.dataType, nullptr); - if (w > 1U) - w >>= 1; - - if (h > 1U) - h >>= 1; - - if (d > 1U) - d >>= 1; - } - } - break; - } - - case ImageType_Cubemap: - { - if (glTexStorage2D && !proxy) - glTexStorage2D(target, m_impl->levelCount, openGLFormat.internalFormat, m_impl->width, m_impl->height); - else - { - unsigned int size = m_impl->width; // Les cubemaps ont une longueur et largeur identique - for (UInt8 level = 0; level < m_impl->levelCount; ++level) - { - for (GLenum face : OpenGL::CubemapFace) - glTexImage2D(face, level, openGLFormat.internalFormat, size, size, 0, openGLFormat.dataFormat, openGLFormat.dataType, nullptr); - - if (size > 1U) - size >>= 1; - } - } - break; - } - } - - if (proxy) - { - GLint internalFormat = 0; - glGetTexLevelParameteriv(target, 0, GL_TEXTURE_INTERNAL_FORMAT, &internalFormat); - if (internalFormat == 0) - return false; - } - - // Application du swizzle - if (!proxy && OpenGL::GetVersion() >= 300) - { - glTexParameteri(target, GL_TEXTURE_SWIZZLE_R, openGLFormat.swizzle[0]); - glTexParameteri(target, GL_TEXTURE_SWIZZLE_G, openGLFormat.swizzle[1]); - glTexParameteri(target, GL_TEXTURE_SWIZZLE_B, openGLFormat.swizzle[2]); - glTexParameteri(target, GL_TEXTURE_SWIZZLE_A, openGLFormat.swizzle[3]); - } - - if (!proxy && PixelFormat::GetContent(m_impl->format) == PixelFormatContent_DepthStencil) - { - glTexParameteri(target, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); - glTexParameteri(target, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); - } - - return true; - } - - bool Texture::Initialize() - { - if (!TextureLibrary::Initialize()) - { - NazaraError("Failed to initialise library"); - return false; - } - - if (!TextureManager::Initialize()) - { - NazaraError("Failed to initialise manager"); - return false; - } - - return true; - } - - void Texture::Uninitialize() - { - TextureManager::Uninitialize(); - TextureLibrary::Uninitialize(); - } - - TextureLibrary::LibraryMap Texture::s_library; - TextureManager::ManagerMap Texture::s_managerMap; - TextureManager::ManagerParams Texture::s_managerParameters; -} diff --git a/src/Nazara/Renderer/TextureSampler.cpp b/src/Nazara/Renderer/TextureSampler.cpp deleted file mode 100644 index bd09a943f..000000000 --- a/src/Nazara/Renderer/TextureSampler.cpp +++ /dev/null @@ -1,393 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - namespace - { - std::unordered_map s_samplers; - UInt8 s_maxAnisotropyLevel; - bool s_useAnisotropicFilter; - } - - TextureSampler::TextureSampler() : - m_filterMode(SamplerFilter_Default), - m_wrapMode(SamplerWrap_Default), - m_anisotropicLevel(0), - m_mipmaps(true), - m_samplerId(0) - { - } - - UInt8 TextureSampler::GetAnisotropicLevel() const - { - return m_anisotropicLevel; - } - - SamplerFilter TextureSampler::GetFilterMode() const - { - return m_filterMode; - } - - SamplerWrap TextureSampler::GetWrapMode() const - { - return m_wrapMode; - } - - void TextureSampler::SetAnisotropyLevel(UInt8 anisotropyLevel) - { - #ifdef NAZARA_DEBUG - if (!Renderer::IsInitialized()) - { - NazaraError("Renderer module must be initialized"); - return; - } - #endif - - if (m_anisotropicLevel != anisotropyLevel) - { - if (anisotropyLevel > s_maxAnisotropyLevel) - { - NazaraWarning("Anisotropy level is over maximum anisotropy level (" + String::Number(anisotropyLevel) + " > " + String::Number(s_maxAnisotropyLevel) + ')'); - anisotropyLevel = s_maxAnisotropyLevel; - } - - m_anisotropicLevel = anisotropyLevel; - m_samplerId = 0; - } - } - - void TextureSampler::SetFilterMode(SamplerFilter filterMode) - { - if (m_filterMode != filterMode) - { - m_filterMode = filterMode; - m_samplerId = 0; - } - } - - void TextureSampler::SetWrapMode(SamplerWrap wrapMode) - { - if (m_wrapMode != wrapMode) - { - m_wrapMode = wrapMode; - m_samplerId = 0; - } - } - - UInt8 TextureSampler::GetDefaultAnisotropicLevel() - { - return s_defaultAnisotropyLevel; - } - - SamplerFilter TextureSampler::GetDefaultFilterMode() - { - return s_defaultFilterMode; - } - - SamplerWrap TextureSampler::GetDefaultWrapMode() - { - return s_defaultWrapMode; - } - - void TextureSampler::SetDefaultAnisotropyLevel(UInt8 anisotropyLevel) - { - #if NAZARA_RENDERER_SAFE - if (anisotropyLevel == 0) - { - NazaraError("Default anisotropy level mode cannot be set to default value (0)"); - return; - } - #endif - - #ifdef NAZARA_DEBUG - if (!Renderer::IsInitialized()) - { - NazaraError("Renderer module must be initialized"); - return; - } - #endif - - if (anisotropyLevel > s_maxAnisotropyLevel) - { - NazaraWarning("Anisotropy level is over maximum anisotropy level (" + String::Number(anisotropyLevel) + " > " + String::Number(s_maxAnisotropyLevel)); - anisotropyLevel = s_maxAnisotropyLevel; - } - - s_defaultAnisotropyLevel = anisotropyLevel; - - if (s_useAnisotropicFilter) - { - for (const std::pair& pair : s_samplers) - { - if (((pair.first >> 5) & 0xFF) == 0) - glSamplerParameterf(pair.second, GL_TEXTURE_MAX_ANISOTROPY_EXT, static_cast(anisotropyLevel)); - } - } - } - - void TextureSampler::SetDefaultFilterMode(SamplerFilter filterMode) - { - #if NAZARA_RENDERER_SAFE - if (filterMode == SamplerFilter_Default) - { - NazaraError("Default filter mode cannot be set to default enum value (SamplerFilter_Default)"); - return; - } - #endif - - s_defaultFilterMode = filterMode; - - for (const std::pair& pair : s_samplers) - { - if (((pair.first >> 1) & 0x3) == SamplerFilter_Default) - { - bool mipmaps = pair.first & 0x1; - switch (filterMode) - { - case SamplerFilter_Bilinear: - if (mipmaps) - glSamplerParameteri(pair.second, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); - else - glSamplerParameteri(pair.second, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - - glSamplerParameteri(pair.second, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - break; - - case SamplerFilter_Nearest: - if (mipmaps) - glSamplerParameteri(pair.second, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); - else - glSamplerParameteri(pair.second, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - - glSamplerParameteri(pair.second, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - break; - - case SamplerFilter_Trilinear: - if (mipmaps) - glSamplerParameteri(pair.second, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); - else - glSamplerParameteri(pair.second, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // Filtrage bilinéaire - - glSamplerParameteri(pair.second, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - break; - - default: - NazaraError("Texture filter not handled (0x" + String::Number(filterMode, 16) + ')'); - break; - } - } - } - } - - void TextureSampler::SetDefaultWrapMode(SamplerWrap wrapMode) - { - #if NAZARA_RENDERER_SAFE - if (wrapMode == SamplerWrap_Default) - { - NazaraError("Default wrap mode cannot be set to default enum value (SamplerWrap_Default)"); - return; - } - #endif - - s_defaultWrapMode = wrapMode; - - GLenum wrapEnum = OpenGL::SamplerWrapMode[wrapMode]; - for (const std::pair& pair : s_samplers) - { - if (((pair.first >> 3) & 0x3) == SamplerWrap_Default) - { - glSamplerParameteri(pair.second, GL_TEXTURE_WRAP_R, wrapEnum); - glSamplerParameteri(pair.second, GL_TEXTURE_WRAP_T, wrapEnum); - glSamplerParameteri(pair.second, GL_TEXTURE_WRAP_S, wrapEnum); - } - } - } - - void TextureSampler::Apply(const Texture* texture) const - { - ImageType type = texture->GetType(); - GLenum target = OpenGL::TextureTarget[type]; - - OpenGL::BindTexture(type, texture->GetOpenGLID()); - - if (s_useAnisotropicFilter) - { - UInt8 anisotropyLevel = (m_anisotropicLevel == 0) ? s_defaultAnisotropyLevel : m_anisotropicLevel; - glTexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, static_cast(anisotropyLevel)); - } - - SamplerFilter filterMode = (m_filterMode == SamplerFilter_Default) ? s_defaultFilterMode : m_filterMode; - switch (filterMode) - { - case SamplerFilter_Bilinear: - if (m_mipmaps) - glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); - else - glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - - glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - break; - - case SamplerFilter_Nearest: - if (m_mipmaps) - glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); - else - glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - - glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - break; - - case SamplerFilter_Trilinear: - if (m_mipmaps) - glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); - else - glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // Filtrage bilinéaire - - glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - break; - - default: - NazaraError("Texture filter not handled (0x" + String::Number(filterMode, 16) + ')'); - break; - } - - GLenum wrapMode = OpenGL::SamplerWrapMode[(m_wrapMode == SamplerWrap_Default) ? s_defaultWrapMode : m_wrapMode]; - switch (type) - { - // Notez l'absence de "break" ici - case ImageType_3D: - glTexParameteri(target, GL_TEXTURE_WRAP_R, wrapMode); - case ImageType_2D: - case ImageType_2D_Array: - case ImageType_Cubemap: - glTexParameteri(target, GL_TEXTURE_WRAP_T, wrapMode); - case ImageType_1D: - case ImageType_1D_Array: - glTexParameteri(target, GL_TEXTURE_WRAP_S, wrapMode); - break; - } - } - - void TextureSampler::Bind(unsigned int unit) const - { - static_assert(SamplerFilter_Max < 0x4, "Maximum sampler filter mode takes more than 2 bits"); - static_assert(SamplerWrap_Max < 0x4, "Maximum sampler wrap mode takes more than 2 bits"); - - if (!m_samplerId) - UpdateSamplerId(); - - OpenGL::BindSampler(unit, m_samplerId); - } - - unsigned int TextureSampler::GetOpenGLID() const - { - if (!m_samplerId) - UpdateSamplerId(); - - return m_samplerId; - } - - void TextureSampler::UpdateSamplerId() const - { - UInt32 key = (((m_mipmaps) ? 1 : 0) << 0) | // 1 bit - (m_filterMode << 1) | // 2 bits - (m_wrapMode << 3) | // 2 bits - (m_anisotropicLevel << 5); // 8 bits - - auto it = s_samplers.find(key); - if (it == s_samplers.end()) - { - GLuint sampler; - glGenSamplers(1, &sampler); - - if (s_useAnisotropicFilter) - { - UInt8 anisotropyLevel = (m_anisotropicLevel == 0) ? s_defaultAnisotropyLevel : m_anisotropicLevel; - glSamplerParameterf(sampler, GL_TEXTURE_MAX_ANISOTROPY_EXT, static_cast(anisotropyLevel)); - } - - SamplerFilter filterMode = (m_filterMode == SamplerFilter_Default) ? s_defaultFilterMode : m_filterMode; - switch (filterMode) - { - case SamplerFilter_Bilinear: - glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, (m_mipmaps) ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR); - glSamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - break; - - case SamplerFilter_Nearest: - glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, (m_mipmaps) ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST); - glSamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - break; - - case SamplerFilter_Trilinear: - // Équivalent au filtrage bilinéaire si les mipmaps sont absentes - glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, (m_mipmaps) ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR); - glSamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - break; - - default: - NazaraError("Texture filter not handled (0x" + String::Number(filterMode, 16) + ')'); - break; - } - - GLenum wrapMode = OpenGL::SamplerWrapMode[(m_wrapMode == SamplerWrap_Default) ? s_defaultWrapMode : m_wrapMode]; - glSamplerParameteri(sampler, GL_TEXTURE_WRAP_R, wrapMode); - glSamplerParameteri(sampler, GL_TEXTURE_WRAP_T, wrapMode); - glSamplerParameteri(sampler, GL_TEXTURE_WRAP_S, wrapMode); - - s_samplers[key] = sampler; - m_samplerId = sampler; - } - else - m_samplerId = it->second; - } - - bool TextureSampler::UseMipmaps(bool mipmaps) - { - if (m_mipmaps != mipmaps) - { - m_mipmaps = mipmaps; - m_samplerId = 0; - - return true; // Renvoie true si la valeur a été changée (Donc s'il faut réappliquer le sampler) - } - else - return false; - } - - bool TextureSampler::Initialize() - { - s_maxAnisotropyLevel = Renderer::GetMaxAnisotropyLevel(); - s_useAnisotropicFilter = OpenGL::IsSupported(OpenGLExtension_AnisotropicFilter); - - return true; - } - - void TextureSampler::Uninitialize() - { - if (!s_samplers.empty()) - { - Context::EnsureContext(); - for (const std::pair& pair : s_samplers) - OpenGL::DeleteSampler(pair.second); - - s_samplers.clear(); - } - } - - UInt8 TextureSampler::s_defaultAnisotropyLevel = 1; - SamplerFilter TextureSampler::s_defaultFilterMode = SamplerFilter_Trilinear; - SamplerWrap TextureSampler::s_defaultWrapMode = SamplerWrap_Repeat; -} diff --git a/src/Nazara/Renderer/UberShader.cpp b/src/Nazara/Renderer/UberShader.cpp deleted file mode 100644 index 18a3c11fe..000000000 --- a/src/Nazara/Renderer/UberShader.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include - -namespace Nz -{ - UberShader::~UberShader() - { - OnUberShaderRelease(this); - } - - bool UberShader::Initialize() - { - if (!UberShaderLibrary::Initialize()) - { - NazaraError("Failed to initialise library"); - return false; - } - - return true; - } - - void UberShader::Uninitialize() - { - UberShaderLibrary::Uninitialize(); - } - - UberShaderLibrary::LibraryMap UberShader::s_library; -} diff --git a/src/Nazara/Renderer/UberShaderInstance.cpp b/src/Nazara/Renderer/UberShaderInstance.cpp deleted file mode 100644 index ec7043542..000000000 --- a/src/Nazara/Renderer/UberShaderInstance.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include - -namespace Nz -{ - UberShaderInstance::UberShaderInstance(const Shader* shader) : - m_shader(shader) - { - } - - UberShaderInstance::~UberShaderInstance() = default; - - const Shader* UberShaderInstance::GetShader() const - { - return m_shader; - } -} diff --git a/src/Nazara/Renderer/UberShaderInstancePreprocessor.cpp b/src/Nazara/Renderer/UberShaderInstancePreprocessor.cpp deleted file mode 100644 index 166645528..000000000 --- a/src/Nazara/Renderer/UberShaderInstancePreprocessor.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include - -namespace Nz -{ - UberShaderInstancePreprocessor::UberShaderInstancePreprocessor(const Shader* shader) : - UberShaderInstance(shader) - { - } - - UberShaderInstancePreprocessor::~UberShaderInstancePreprocessor() = default; - - bool UberShaderInstancePreprocessor::Activate() const - { - Renderer::SetShader(m_shader); - - return true; - } -} diff --git a/src/Nazara/Renderer/UberShaderPreprocessor.cpp b/src/Nazara/Renderer/UberShaderPreprocessor.cpp deleted file mode 100644 index 2a08088f5..000000000 --- a/src/Nazara/Renderer/UberShaderPreprocessor.cpp +++ /dev/null @@ -1,187 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - UberShaderPreprocessor::~UberShaderPreprocessor() - { - OnUberShaderPreprocessorRelease(this); - } - - UberShaderInstance* UberShaderPreprocessor::Get(const ParameterList& parameters) const - { - // Première étape, transformer les paramètres en un flag - UInt32 flags = 0; - for (auto it = m_flags.begin(); it != m_flags.end(); ++it) - { - if (parameters.HasParameter(it->first)) - { - bool value; - if (parameters.GetBooleanParameter(it->first, &value) && value) - flags |= it->second; - } - } - - // Le shader fait-il partie du cache ? - auto shaderIt = m_cache.find(flags); - - // Si non, il nous faut le construire - if (shaderIt == m_cache.end()) - { - try - { - // Une exception sera lancée à la moindre erreur et celle-ci ne sera pas enregistrée dans le log (car traitée dans le bloc catch) - ErrorFlags errFlags(ErrorFlag_Silent | ErrorFlag_ThrowException, true); - - ShaderRef shader = Shader::New(); - shader->Create(); - - for (unsigned int i = 0; i <= ShaderStageType_Max; ++i) - { - const CachedShader& shaderStage = m_shaders[i]; - - // Le shader stage est-il activé dans cette version du shader ? - if (shaderStage.present && (flags & shaderStage.requiredFlags) == shaderStage.requiredFlags) - { - UInt32 stageFlags = 0; - for (auto it = shaderStage.flags.begin(); it != shaderStage.flags.end(); ++it) - { - if (parameters.HasParameter(it->first)) - { - bool value; - if (parameters.GetBooleanParameter(it->first, &value) && value) - stageFlags |= it->second; - } - } - - auto stageIt = shaderStage.cache.find(stageFlags); - if (stageIt == shaderStage.cache.end()) - { - ShaderStage stage; - stage.Create(static_cast(i)); - - unsigned int glslVersion = OpenGL::GetGLSLVersion(); - - StringStream code; - code << "#version " << glslVersion << "\n\n"; - - code << "#define GLSL_VERSION " << glslVersion << "\n\n"; - - code << "#define EARLY_FRAGMENT_TEST " << (glslVersion >= 420 || OpenGL::IsSupported(OpenGLExtension_Shader_ImageLoadStore)) << "\n\n"; - - for (auto it = shaderStage.flags.begin(); it != shaderStage.flags.end(); ++it) - code << "#define " << it->first << ' ' << ((stageFlags & it->second) ? '1' : '0') << '\n'; - - code << "\n#line 1\n"; // Pour que les éventuelles erreurs du shader se réfèrent à la bonne ligne - code << shaderStage.source; - - stage.SetSource(code); - stage.Compile(); - - stageIt = shaderStage.cache.emplace(flags, std::move(stage)).first; - } - - shader->AttachStage(static_cast(i), stageIt->second); - } - } - - shader->Link(); - - // On construit l'instant - shaderIt = m_cache.emplace(flags, shader.Get()).first; - } - catch (const std::exception&) - { - ErrorFlags errFlags(ErrorFlag_ThrowExceptionDisabled); - - NazaraError("Failed to build UberShader instance: " + Error::GetLastError()); - throw; - } - } - - return &shaderIt->second; - } - - void UberShaderPreprocessor::SetShader(ShaderStageType stage, const String& source, const String& shaderFlags, const String& requiredFlags) - { - CachedShader& shader = m_shaders[stage]; - shader.present = true; - shader.source = source; - - // On extrait les flags de la chaîne - std::vector flags; - shaderFlags.Split(flags, ' '); - - for (String& flag : flags) - { - auto it = m_flags.find(flag); - if (it == m_flags.end()) - m_flags[flag] = 1U << m_flags.size(); - - auto it2 = shader.flags.find(flag); - if (it2 == shader.flags.end()) - shader.flags[flag] = 1U << shader.flags.size(); - } - - // On construit les flags requis pour l'activation du shader - shader.requiredFlags = 0; - - flags.clear(); - requiredFlags.Split(flags, ' '); - - for (String& flag : flags) - { - UInt32 flagVal; - - auto it = m_flags.find(flag); - if (it == m_flags.end()) - { - flagVal = 1U << m_flags.size(); - m_flags[flag] = flagVal; - } - else - flagVal = it->second; - - shader.requiredFlags |= flagVal; - } - } - - bool UberShaderPreprocessor::SetShaderFromFile(ShaderStageType stage, const String& filePath, const String& shaderFlags, const String& requiredFlags) - { - File file(filePath); - if (!file.Open(OpenMode_ReadOnly | OpenMode_Text)) - { - NazaraError("Failed to open \"" + filePath + '"'); - return false; - } - - unsigned int length = static_cast(file.GetSize()); - - String source(length, '\0'); - - if (file.Read(&source[0], length) != length) - { - NazaraError("Failed to read program file"); - return false; - } - - file.Close(); - - SetShader(stage, source, shaderFlags, requiredFlags); - return true; - } - - bool UberShaderPreprocessor::IsSupported() - { - return true; // Forcément supporté - } -} diff --git a/src/Nazara/Renderer/Win32/ContextImpl.cpp b/src/Nazara/Renderer/Win32/ContextImpl.cpp deleted file mode 100644 index 2f7094f70..000000000 --- a/src/Nazara/Renderer/Win32/ContextImpl.cpp +++ /dev/null @@ -1,248 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -// Code inspiré de NeHe (Lesson1) et de la SFML par Laurent Gomila - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - ContextImpl::ContextImpl() - { - } - - bool ContextImpl::Activate() - { - return wglMakeCurrent(m_deviceContext, m_context) == TRUE; - } - - bool ContextImpl::Create(ContextParameters& parameters) - { - if (parameters.window) - { - m_window = static_cast(parameters.window); - m_ownsWindow = false; - } - else - { - m_window = CreateWindowA("STATIC", nullptr, WS_DISABLED | WS_POPUP, 0, 0, 1, 1, nullptr, nullptr, GetModuleHandle(nullptr), nullptr); - if (!m_window) - { - NazaraError("Failed to create window"); - return false; - } - - ShowWindow(m_window, SW_HIDE); - m_ownsWindow = true; - } - - // En cas d'exception, la ressource sera quand même libérée - CallOnExit onExit([this] () - { - Destroy(); - }); - - m_deviceContext = GetDC(m_window); - if (!m_deviceContext) - { - NazaraError("Failed to get device context"); - return false; - } - - int pixelFormat = 0; - if (parameters.antialiasingLevel > 0) - { - if (wglChoosePixelFormat) - { - bool valid; - UINT numFormats; - - int attributes[] = { - WGL_DRAW_TO_WINDOW_ARB, GL_TRUE, - WGL_SUPPORT_OPENGL_ARB, GL_TRUE, - WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB, - WGL_COLOR_BITS_ARB, (parameters.bitsPerPixel == 32) ? 24 : parameters.bitsPerPixel, - WGL_ALPHA_BITS_ARB, (parameters.bitsPerPixel == 32) ? 8 : 0, - WGL_DEPTH_BITS_ARB, parameters.depthBits, - WGL_STENCIL_BITS_ARB, parameters.stencilBits, - WGL_DOUBLE_BUFFER_ARB, (parameters.doubleBuffered) ? GL_TRUE : GL_FALSE, - WGL_SAMPLE_BUFFERS_ARB, GL_TRUE, - WGL_SAMPLES_ARB, parameters.antialiasingLevel, - 0, 0 - }; - - do - { - valid = (wglChoosePixelFormat(m_deviceContext, attributes, nullptr, 1, &pixelFormat, &numFormats) == TRUE); - } - while ((!valid || numFormats == 0) && --attributes[19] > 0); - - if (!valid) - { - NazaraWarning("Could not find a format matching requirements, disabling antialiasing..."); - pixelFormat = 0; - } - - parameters.antialiasingLevel = attributes[19]; - } - else - { - NazaraWarning("Antialiasing is not supported"); - parameters.antialiasingLevel = 0; - } - } - - PIXELFORMATDESCRIPTOR descriptor; - ZeroMemory(&descriptor, sizeof(PIXELFORMATDESCRIPTOR)); - descriptor.nSize = sizeof(PIXELFORMATDESCRIPTOR); - descriptor.nVersion = 1; - - if (pixelFormat == 0) - { - descriptor.cColorBits = parameters.bitsPerPixel; - descriptor.cDepthBits = parameters.depthBits; - descriptor.cStencilBits = parameters.stencilBits; - descriptor.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL; - descriptor.iPixelType = PFD_TYPE_RGBA; - - if (parameters.bitsPerPixel == 32) - descriptor.cAlphaBits = 8; - - if (parameters.doubleBuffered) - descriptor.dwFlags |= PFD_DOUBLEBUFFER; - - pixelFormat = ChoosePixelFormat(m_deviceContext, &descriptor); - if (pixelFormat == 0) - { - NazaraError("Failed to choose pixel format"); - return false; - } - } - - if (!SetPixelFormat(m_deviceContext, pixelFormat, &descriptor)) - { - NazaraError("Failed to set pixel format"); - return false; - } - - // Arrivé ici, le format de pixel est choisi, nous récupérons donc les paramètres réels du futur contexte - if (DescribePixelFormat(m_deviceContext, pixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &descriptor) != 0) - { - parameters.bitsPerPixel = descriptor.cColorBits + descriptor.cAlphaBits; - parameters.depthBits = descriptor.cDepthBits; - parameters.stencilBits = descriptor.cDepthBits; - } - else - NazaraWarning("Failed to get context's parameters"); - - HGLRC shareContext = (parameters.shared) ? static_cast(parameters.shareContext->m_impl)->m_context : nullptr; - - m_context = nullptr; - if (wglCreateContextAttribs) - { - int attributes[4*2+1]; - int* attrib = attributes; - - *attrib++ = WGL_CONTEXT_MAJOR_VERSION_ARB; - *attrib++ = parameters.majorVersion; - - *attrib++ = WGL_CONTEXT_MINOR_VERSION_ARB; - *attrib++ = parameters.minorVersion; - - if (parameters.majorVersion >= 3) - { - *attrib++ = WGL_CONTEXT_PROFILE_MASK_ARB; - *attrib++ = (parameters.compatibilityProfile) ? WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB : WGL_CONTEXT_CORE_PROFILE_BIT_ARB; - - // Les contextes forward-compatible ne sont plus utilisés pour cette raison : - // http://www.opengl.org/discussion_boards/showthread.php/175052-Forward-compatible-vs-Core-profile - } - - if (parameters.debugMode) - { - *attrib++ = WGL_CONTEXT_FLAGS_ARB; - *attrib++ = WGL_CONTEXT_DEBUG_BIT_ARB; - } - - *attrib++ = 0; - - m_context = wglCreateContextAttribs(m_deviceContext, shareContext, attributes); - } - - if (!m_context) - { - m_context = wglCreateContext(m_deviceContext); - - if (shareContext) - { - // wglShareLists n'est pas thread-safe (source: SFML) - static Mutex mutex; - LockGuard lock(mutex); - - if (!wglShareLists(shareContext, m_context)) - NazaraWarning("Failed to share the context: " + Error::GetLastSystemError()); - } - } - - if (!m_context) - { - NazaraError("Failed to create context"); - return false; - } - - onExit.Reset(); - - return true; - } - - void ContextImpl::Destroy() - { - if (m_context) - { - if (wglGetCurrentContext() == m_context) - wglMakeCurrent(nullptr, nullptr); - - wglDeleteContext(m_context); - m_context = nullptr; - } - - if (m_deviceContext) - { - ReleaseDC(m_window, m_deviceContext); - m_deviceContext = nullptr; - } - - if (m_ownsWindow) - { - DestroyWindow(m_window); - m_window = nullptr; - } - } - - void ContextImpl::EnableVerticalSync(bool enabled) - { - if (wglSwapInterval) - wglSwapInterval(enabled ? 1 : 0); - else - NazaraError("Vertical sync not supported"); - } - - void ContextImpl::SwapBuffers() - { - ::SwapBuffers(m_deviceContext); - } - - bool ContextImpl::Desactivate() - { - return wglMakeCurrent(nullptr, nullptr) == TRUE; - } -} diff --git a/src/Nazara/Renderer/Win32/ContextImpl.hpp b/src/Nazara/Renderer/Win32/ContextImpl.hpp deleted file mode 100644 index 0e5c7cbc9..000000000 --- a/src/Nazara/Renderer/Win32/ContextImpl.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_CONTEXTIMPL_HPP -#define NAZARA_CONTEXTIMPL_HPP - -#include -#include -#include - -namespace Nz -{ - class ContextImpl - { - public: - ContextImpl(); - - bool Activate(); - - bool Create(ContextParameters& parameters); - - void Destroy(); - - void EnableVerticalSync(bool enabled); - - void SwapBuffers(); - - static bool Desactivate(); - - private: - HDC m_deviceContext; - HGLRC m_context; - HWND m_window; - bool m_ownsWindow; - }; -} - -#endif // NAZARA_CONTEXTIMPL_HPP diff --git a/src/Nazara/VulkanRenderer/Debug/NewOverload.cpp b/src/Nazara/VulkanRenderer/Debug/NewOverload.cpp new file mode 100644 index 000000000..f431e055f --- /dev/null +++ b/src/Nazara/VulkanRenderer/Debug/NewOverload.cpp @@ -0,0 +1,31 @@ +// 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_VULKANRENDERER_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_VULKANRENDERER_MANAGE_MEMORY diff --git a/src/Nazara/VulkanRenderer/Export.cpp b/src/Nazara/VulkanRenderer/Export.cpp new file mode 100644 index 000000000..42f89c79e --- /dev/null +++ b/src/Nazara/VulkanRenderer/Export.cpp @@ -0,0 +1,15 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +extern "C" +{ + NAZARA_EXPORT Nz::RendererImpl* NazaraRenderer_Instantiate() + { + std::unique_ptr renderer(new Nz::VulkanRenderer); + return renderer.release(); + } +} diff --git a/src/Nazara/VulkanRenderer/RenderTarget.cpp b/src/Nazara/VulkanRenderer/RenderTarget.cpp new file mode 100644 index 000000000..4c78a5321 --- /dev/null +++ b/src/Nazara/VulkanRenderer/RenderTarget.cpp @@ -0,0 +1,14 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + RenderTarget::~RenderTarget() + { + OnRenderTargetRelease(this); + } +} diff --git a/src/Nazara/VulkanRenderer/RenderWindow.cpp b/src/Nazara/VulkanRenderer/RenderWindow.cpp new file mode 100644 index 000000000..1d5fbd33e --- /dev/null +++ b/src/Nazara/VulkanRenderer/RenderWindow.cpp @@ -0,0 +1,530 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + RenderWindow::RenderWindow() : + RenderTarget(), Window(), + m_surface(Nz::Vulkan::GetInstance()), + m_forcedPhysicalDevice(nullptr), + m_depthStencilFormat(VK_FORMAT_MAX_ENUM) + { + } + + RenderWindow::RenderWindow(VideoMode mode, const String& title, UInt32 style) : + RenderWindow() + { + ErrorFlags flags(ErrorFlag_ThrowException, true); + Create(mode, title, style); + } + + RenderWindow::RenderWindow(WindowHandle handle) : + RenderWindow() + { + ErrorFlags flags(ErrorFlag_ThrowException, true); + Create(handle); + } + + RenderWindow::~RenderWindow() + { + // Nécessaire si Window::Destroy est appelé par son destructeur + OnWindowDestroy(); + } + + bool RenderWindow::Acquire(UInt32* imageIndex) const + { + if (!m_swapchain.AcquireNextImage(std::numeric_limits::max(), m_imageReadySemaphore, VK_NULL_HANDLE, imageIndex)) + { + NazaraError("Failed to acquire next image"); + return false; + } + + return true; + } + + void RenderWindow::BuildPreRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) + { + //commandBuffer.SetImageLayout(m_swapchain.GetBuffer(imageIndex).image, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); + + // Temporary + if (m_depthStencilFormat != VK_FORMAT_MAX_ENUM) + { + VkImageSubresourceRange imageRange = { + VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, // VkImageAspectFlags aspectMask + 0, // uint32_t baseMipLevel + 1, // uint32_t levelCount + 0, // uint32_t baseArrayLayer + 1 // uint32_t layerCount + }; + + commandBuffer.SetImageLayout(m_depthBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, imageRange); + } + } + + void RenderWindow::BuildPostRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) + { + //commandBuffer.SetImageLayout(m_swapchain.GetBuffer(imageIndex).image, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR); + } + + const Vk::Framebuffer& RenderWindow::GetFrameBuffer(UInt32 imageIndex) const + { + return m_frameBuffers[imageIndex]; + } + + UInt32 RenderWindow::GetFramebufferCount() const + { + return static_cast(m_frameBuffers.size()); + } + + bool RenderWindow::Create(VideoMode mode, const String& title, UInt32 style) + { + return Window::Create(mode, title, style); + } + + bool RenderWindow::Create(WindowHandle handle) + { + return Window::Create(handle); + } + + const Vk::DeviceHandle& RenderWindow::GetDevice() const + { + return m_device; + } + + UInt32 RenderWindow::GetPresentableFamilyQueue() const + { + return m_presentableFamilyQueue; + } + + const Vk::Surface& RenderWindow::GetSurface() const + { + return m_surface; + } + + const Vk::Swapchain& RenderWindow::GetSwapchain() const + { + return m_swapchain; + } + + void RenderWindow::Present(UInt32 imageIndex) + { + NazaraAssert(imageIndex < m_frameBuffers.size(), "Invalid image index"); + + m_presentQueue.Present(m_swapchain, imageIndex); + } + + bool RenderWindow::IsValid() const + { + return m_impl != nullptr; + } + + void RenderWindow::SetDepthStencilFormats(std::vector pixelFormat) + { + m_wantedDepthStencilFormats = std::move(pixelFormat); + } + + void RenderWindow::SetPhysicalDevice(VkPhysicalDevice device) + { + m_forcedPhysicalDevice = device; + } + + bool RenderWindow::OnWindowCreated() + { + OnRenderTargetSizeChange(this); + + #if defined(NAZARA_PLATFORM_WINDOWS) + HWND handle = reinterpret_cast(GetHandle()); + HINSTANCE instance = reinterpret_cast(GetWindowLongPtrW(handle, GWLP_HINSTANCE)); + bool success = m_surface.Create(instance, handle); + #else + #error This OS is not supported by Vulkan + #endif + + if (!success) + { + NazaraError("Failed to create Vulkan surface"); + return false; + } + + m_device = Vulkan::SelectDevice(m_forcedPhysicalDevice, m_surface, &m_presentableFamilyQueue); + if (!m_device) + { + NazaraError("Failed to get compatible Vulkan device"); + return false; + } + + m_presentQueue = m_device->GetQueue(m_presentableFamilyQueue, 0); + + std::vector surfaceFormats; + if (!m_surface.GetFormats(m_forcedPhysicalDevice, &surfaceFormats)) + { + NazaraError("Failed to query supported surface formats"); + return false; + } + + if (surfaceFormats.size() == 1 && surfaceFormats[0].format == VK_FORMAT_UNDEFINED) + m_colorFormat = VK_FORMAT_B8G8R8A8_UNORM; + else + m_colorFormat = surfaceFormats[0].format; + + m_colorSpace = surfaceFormats[0].colorSpace; + + if (!m_wantedDepthStencilFormats.empty()) + { + const Vk::PhysicalDevice& deviceInfo = Vulkan::GetPhysicalDeviceInfo(m_forcedPhysicalDevice); + + for (PixelFormatType format : m_wantedDepthStencilFormats) + { + switch (format) + { + case PixelFormatType_Depth16: + m_depthStencilFormat = VK_FORMAT_D16_UNORM; + break; + + case PixelFormatType_Depth24: + case PixelFormatType_Depth24Stencil8: + m_depthStencilFormat = VK_FORMAT_D24_UNORM_S8_UINT; + break; + + case PixelFormatType_Depth32: + m_depthStencilFormat = VK_FORMAT_D32_SFLOAT; + break; + + case PixelFormatType_Stencil1: + case PixelFormatType_Stencil4: + case PixelFormatType_Stencil8: + m_depthStencilFormat = VK_FORMAT_S8_UINT; + break; + + case PixelFormatType_Stencil16: + m_depthStencilFormat = VK_FORMAT_MAX_ENUM; + break; + + default: + { + PixelFormatContent formatContent = PixelFormat::GetContent(format); + if (formatContent != PixelFormatContent_DepthStencil && formatContent != PixelFormatContent_Stencil) + NazaraWarning("Invalid format " + PixelFormat::GetName(format) + " for depth-stencil attachment"); + + m_depthStencilFormat = VK_FORMAT_MAX_ENUM; + break; + } + } + + if (m_depthStencilFormat != VK_FORMAT_MAX_ENUM) + { + VkFormatProperties formatProperties = m_device->GetInstance().GetPhysicalDeviceFormatProperties(m_forcedPhysicalDevice, m_depthStencilFormat); + if (formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) + break; //< Found it + + m_depthStencilFormat = VK_FORMAT_MAX_ENUM; + } + } + } + + if (!SetupSwapchain()) + { + NazaraError("Failed to create swapchain"); + return false; + } + + if (m_depthStencilFormat != VK_FORMAT_MAX_ENUM && !SetupDepthBuffer()) + { + NazaraError("Failed to create depth buffer"); + return false; + } + + if (!SetupRenderPass()) + { + NazaraError("Failed to create render pass"); + return false; + } + + UInt32 imageCount = m_swapchain.GetBufferCount(); + + // Framebuffers + m_frameBuffers.resize(imageCount); + for (UInt32 i = 0; i < imageCount; ++i) + { + std::array attachments = {m_swapchain.GetBuffer(i).view, m_depthBufferView}; + + VkFramebufferCreateInfo frameBufferCreate = { + VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + 0, // VkFramebufferCreateFlags flags; + m_renderPass, // VkRenderPass renderPass; + (attachments[1] != VK_NULL_HANDLE) ? 2U : 1U, // uint32_t attachmentCount; + attachments.data(), // const VkImageView* pAttachments; + GetWidth(), // uint32_t width; + GetHeight(), // uint32_t height; + 1U // uint32_t layers; + }; + + if (!m_frameBuffers[i].Create(m_device, frameBufferCreate)) + { + NazaraError("Failed to create framebuffer for image #" + String::Number(i)); + return false; + } + } + + m_imageReadySemaphore.Create(m_device); + + m_clock.Restart(); + + return true; + } + + void RenderWindow::OnWindowDestroy() + { + m_device->WaitForIdle(); + m_frameBuffers.clear(); + m_renderPass.Destroy(); + + m_swapchain.Destroy(); + m_surface.Destroy(); + } + + void RenderWindow::OnWindowResized() + { + OnRenderTargetSizeChange(this); + } + + bool RenderWindow::SetupDepthBuffer() + { + VkImageCreateInfo imageCreateInfo = { + VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + 0U, // VkImageCreateFlags flags; + VK_IMAGE_TYPE_2D, // VkImageType imageType; + m_depthStencilFormat, // VkFormat format; + {GetWidth(), GetHeight(), 1U}, // VkExtent3D extent; + 1U, // uint32_t mipLevels; + 1U, // uint32_t arrayLayers; + VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples; + VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling; + VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT, // VkImageUsageFlags usage; + VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode; + 0U, // uint32_t queueFamilyIndexCount; + nullptr, // const uint32_t* pQueueFamilyIndices; + VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout; + }; + + if (!m_depthBuffer.Create(m_device, imageCreateInfo)) + { + NazaraError("Failed to create depth buffer"); + return false; + } + + VkMemoryRequirements memoryReq = m_depthBuffer.GetMemoryRequirements(); + if (!m_depthBufferMemory.Create(m_device, memoryReq.size, memoryReq.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)) + { + NazaraError("Failed to allocate depth buffer memory"); + return false; + } + + if (!m_depthBuffer.BindImageMemory(m_depthBufferMemory)) + { + NazaraError("Failed to bind depth buffer to buffer"); + return false; + } + + VkImageViewCreateInfo imageViewCreateInfo = { + VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + 0, // VkImageViewCreateFlags flags; + m_depthBuffer, // VkImage image; + VK_IMAGE_VIEW_TYPE_2D, // VkImageViewType viewType; + m_depthStencilFormat, // VkFormat format; + { // VkComponentMapping components; + VK_COMPONENT_SWIZZLE_R, // VkComponentSwizzle .r; + VK_COMPONENT_SWIZZLE_G, // VkComponentSwizzle .g; + VK_COMPONENT_SWIZZLE_B, // VkComponentSwizzle .b; + VK_COMPONENT_SWIZZLE_A // VkComponentSwizzle .a; + }, + { // VkImageSubresourceRange subresourceRange; + VK_IMAGE_ASPECT_DEPTH_BIT, // VkImageAspectFlags .aspectMask; + 0, // uint32_t .baseMipLevel; + 1, // uint32_t .levelCount; + 0, // uint32_t .baseArrayLayer; + 1 // uint32_t .layerCount; + } + }; + + if (!m_depthBufferView.Create(m_device, imageViewCreateInfo)) + { + NazaraError("Failed to create depth buffer view"); + return false; + } + + return true; + } + + bool RenderWindow::SetupRenderPass() + { + std::array attachments = { + { + { + 0, // VkAttachmentDescriptionFlags flags; + m_colorFormat, // VkFormat format; + VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples; + VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp loadOp; + VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp; + VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp; + VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp; + VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout; + VK_IMAGE_LAYOUT_PRESENT_SRC_KHR // VkImageLayout finalLayout; + }, + { + 0, // VkAttachmentDescriptionFlags flags; + m_depthStencilFormat, // VkFormat format; + VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples; + VK_ATTACHMENT_LOAD_OP_CLEAR, // VkAttachmentLoadOp loadOp; + VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp storeOp; + VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp; + VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp; + VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, // VkImageLayout initialLayout; + VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL // VkImageLayout finalLayout; + }, + } + }; + + VkAttachmentReference colorReference = { + 0, // uint32_t attachment; + VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout layout; + }; + + VkAttachmentReference depthReference = { + 1, // uint32_t attachment; + VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL // VkImageLayout layout; + }; + + VkSubpassDescription subpass = { + 0, // VkSubpassDescriptionFlags flags; + VK_PIPELINE_BIND_POINT_GRAPHICS, // VkPipelineBindPoint pipelineBindPoint; + 0U, // uint32_t inputAttachmentCount; + nullptr, // const VkAttachmentReference* pInputAttachments; + 1U, // uint32_t colorAttachmentCount; + &colorReference, // const VkAttachmentReference* pColorAttachments; + nullptr, // const VkAttachmentReference* pResolveAttachments; + (m_depthStencilFormat != VK_FORMAT_MAX_ENUM) ? &depthReference : nullptr, // const VkAttachmentReference* pDepthStencilAttachment; + 0U, // uint32_t preserveAttachmentCount; + nullptr // const uint32_t* pPreserveAttachments; + }; + + std::array dependencies; + // First dependency at the start of the renderpass + // Does the transition from final to initial layout + dependencies[0].srcSubpass = VK_SUBPASS_EXTERNAL; // Producer of the dependency + dependencies[0].dstSubpass = 0; // Consumer is our single subpass that will wait for the execution depdendency + dependencies[0].srcStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT; + dependencies[0].dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; + dependencies[0].srcAccessMask = VK_ACCESS_MEMORY_READ_BIT; + dependencies[0].dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; + dependencies[0].dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT; + + // Second dependency at the end the renderpass + // Does the transition from the initial to the final layout + dependencies[1].srcSubpass = 0; // Producer of the dependency is our single subpass + dependencies[1].dstSubpass = VK_SUBPASS_EXTERNAL; // Consumer are all commands outside of the renderpass + dependencies[1].srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; + dependencies[1].dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT; + dependencies[1].srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; + dependencies[1].dstAccessMask = VK_ACCESS_MEMORY_READ_BIT; + dependencies[1].dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT; + + VkRenderPassCreateInfo createInfo = { + VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + 0, // VkRenderPassCreateFlags flags; + (m_depthStencilFormat != VK_FORMAT_MAX_ENUM) ? 2U : 1U, // uint32_t attachmentCount; + attachments.data(), // const VkAttachmentDescription* pAttachments; + 1U, // uint32_t subpassCount; + &subpass, // const VkSubpassDescription* pSubpasses; + dependencies.size(), // uint32_t dependencyCount; + dependencies.data() // const VkSubpassDependency* pDependencies; + }; + + return m_renderPass.Create(m_device, createInfo); + } + + bool RenderWindow::SetupSwapchain() + { + VkSurfaceCapabilitiesKHR surfaceCapabilities; + if (!m_surface.GetCapabilities(m_forcedPhysicalDevice, &surfaceCapabilities)) + { + NazaraError("Failed to query surface capabilities"); + return false; + } + + Nz::UInt32 imageCount = surfaceCapabilities.minImageCount + 1; + if (surfaceCapabilities.maxImageCount > 0 && imageCount > surfaceCapabilities.maxImageCount) + imageCount = surfaceCapabilities.maxImageCount; + + VkExtent2D extent; + if (surfaceCapabilities.currentExtent.width == -1) + { + extent.width = Nz::Clamp(GetWidth(), surfaceCapabilities.minImageExtent.width, surfaceCapabilities.maxImageExtent.width); + extent.height = Nz::Clamp(GetHeight(), surfaceCapabilities.minImageExtent.height, surfaceCapabilities.maxImageExtent.height); + } + else + extent = surfaceCapabilities.currentExtent; + + std::vector presentModes; + if (!m_surface.GetPresentModes(m_forcedPhysicalDevice, &presentModes)) + { + NazaraError("Failed to query supported present modes"); + return false; + } + + VkPresentModeKHR swapchainPresentMode = VK_PRESENT_MODE_FIFO_KHR; + for (VkPresentModeKHR presentMode : presentModes) + { + if (presentMode == VK_PRESENT_MODE_MAILBOX_KHR) + { + swapchainPresentMode = VK_PRESENT_MODE_MAILBOX_KHR; + break; + } + + if (presentMode == VK_PRESENT_MODE_IMMEDIATE_KHR) + swapchainPresentMode = VK_PRESENT_MODE_IMMEDIATE_KHR; + } + + VkSwapchainCreateInfoKHR swapchainInfo = { + VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR, + nullptr, + 0, + m_surface, + imageCount, + m_colorFormat, + m_colorSpace, + extent, + 1, + VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, + VK_SHARING_MODE_EXCLUSIVE, + 0, nullptr, + surfaceCapabilities.currentTransform, + VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR, + swapchainPresentMode, + VK_TRUE, + 0 + }; + + if (!m_swapchain.Create(m_device, swapchainInfo)) + { + NazaraError("Failed to create swapchain"); + return false; + } + + return true; + } +} diff --git a/src/Nazara/VulkanRenderer/VkCommandPool.cpp b/src/Nazara/VulkanRenderer/VkCommandPool.cpp new file mode 100644 index 000000000..a1f2ea629 --- /dev/null +++ b/src/Nazara/VulkanRenderer/VkCommandPool.cpp @@ -0,0 +1,53 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// 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, + commandBufferCount + }; + + 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/VulkanRenderer/VkDescriptorPool.cpp b/src/Nazara/VulkanRenderer/VkDescriptorPool.cpp new file mode 100644 index 000000000..f84b9dc20 --- /dev/null +++ b/src/Nazara/VulkanRenderer/VkDescriptorPool.cpp @@ -0,0 +1,53 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + DescriptorSet DescriptorPool::AllocateDescriptorSet(const VkDescriptorSetLayout& setLayouts) + { + VkDescriptorSetAllocateInfo createInfo = + { + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + m_handle, // VkDescriptorPool descriptorPool; + 1U, // uint32_t descriptorSetCount; + &setLayouts // const VkDescriptorSetLayout* pSetLayouts; + }; + + VkDescriptorSet handle = VK_NULL_HANDLE; + m_lastErrorCode = m_device->vkAllocateDescriptorSets(*m_device, &createInfo, &handle); + + return DescriptorSet(*this, handle); + } + + std::vector DescriptorPool::AllocateDescriptorSets(UInt32 descriptorSetCount, const VkDescriptorSetLayout* setLayouts) + { + VkDescriptorSetAllocateInfo createInfo = + { + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + m_handle, // VkDescriptorPool descriptorPool; + descriptorSetCount, // uint32_t descriptorSetCount; + setLayouts // const VkDescriptorSetLayout* pSetLayouts; + }; + + std::vector handles(descriptorSetCount, VK_NULL_HANDLE); + m_lastErrorCode = m_device->vkAllocateDescriptorSets(*m_device, &createInfo, handles.data()); + if (m_lastErrorCode != VkResult::VK_SUCCESS) + return std::vector(); + + std::vector descriptorSets; + for (UInt32 i = 0; i < descriptorSetCount; ++i) + descriptorSets.emplace_back(DescriptorSet(*this, handles[i])); + + return descriptorSets; + } + } +} diff --git a/src/Nazara/VulkanRenderer/VkDevice.cpp b/src/Nazara/VulkanRenderer/VkDevice.cpp new file mode 100644 index 000000000..a62c65e26 --- /dev/null +++ b/src/Nazara/VulkanRenderer/VkDevice.cpp @@ -0,0 +1,222 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// 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) + { + std::vector queuesProperties; + if (!m_instance.GetPhysicalDeviceQueueFamilyProperties(device, &queuesProperties)) + { + NazaraError("Failed to query queue family properties"); + return false; + } + + m_lastErrorCode = m_instance.vkCreateDevice(device, &createInfo, allocator, &m_device); + if (m_lastErrorCode != VkResult::VK_SUCCESS) + { + NazaraError("Failed to create Vulkan device"); + return false; + } + + m_physicalDevice = device; + + // 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]); + + // Load all device-related functions + #define NAZARA_VULKANRENDERER_LOAD_DEVICE(func) func = reinterpret_cast(GetProcAddr(#func)) + + try + { + ErrorFlags flags(ErrorFlag_ThrowException, true); + + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkAllocateCommandBuffers); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkAllocateDescriptorSets); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkAllocateMemory); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkBeginCommandBuffer); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkBindBufferMemory); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkBindImageMemory); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdBeginQuery); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdBeginRenderPass); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdBindDescriptorSets); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdBindIndexBuffer); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdBindPipeline); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdBindVertexBuffers); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdBlitImage); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdClearAttachments); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdClearColorImage); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdClearDepthStencilImage); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdCopyBuffer); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdCopyBufferToImage); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdCopyImage); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdCopyImageToBuffer); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdCopyQueryPoolResults); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdDispatch); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdDispatchIndirect); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdDraw); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdDrawIndexed); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdDrawIndexedIndirect); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdDrawIndirect); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdEndQuery); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdEndRenderPass); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdExecuteCommands); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdFillBuffer); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdNextSubpass); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdPipelineBarrier); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdPushConstants); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdResetEvent); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdResetQueryPool); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdResolveImage); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdSetBlendConstants); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdSetDepthBias); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdSetDepthBounds); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdSetEvent); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdSetLineWidth); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdSetScissor); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdSetStencilCompareMask); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdSetStencilReference); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdSetStencilWriteMask); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdSetViewport); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdUpdateBuffer); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdWaitEvents); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdWriteTimestamp); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateBuffer); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateBufferView); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateCommandPool); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateComputePipelines); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateDescriptorPool); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateDescriptorSetLayout); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateEvent); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateFramebuffer); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateGraphicsPipelines); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateImage); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateImageView); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreatePipelineCache); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreatePipelineLayout); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateRenderPass); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateSampler); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateSemaphore); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateShaderModule); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyBuffer); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyBufferView); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyCommandPool); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyDescriptorPool); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyDescriptorSetLayout); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyDevice); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyEvent); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyFramebuffer); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyImage); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyImageView); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyPipeline); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyPipelineCache); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyPipelineLayout); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyRenderPass); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroySampler); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroySemaphore); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyShaderModule); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDeviceWaitIdle); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkEndCommandBuffer); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkFreeCommandBuffers); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkFreeDescriptorSets); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkFreeMemory); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkFlushMappedMemoryRanges); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkGetBufferMemoryRequirements); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkGetDeviceMemoryCommitment); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkGetDeviceQueue); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkGetEventStatus); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkGetFenceStatus); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkGetImageMemoryRequirements); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkGetImageSparseMemoryRequirements); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkGetImageSubresourceLayout); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkGetRenderAreaGranularity); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkInvalidateMappedMemoryRanges); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkMapMemory); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkMergePipelineCaches); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkQueueSubmit); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkQueueWaitIdle); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkResetCommandBuffer); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkResetCommandPool); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkResetDescriptorPool); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkResetFences); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkResetEvent); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkSetEvent); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkUnmapMemory); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkUpdateDescriptorSets); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkWaitForFences); + + // VK_KHR_display_swapchain + if (IsExtensionLoaded("VK_KHR_display_swapchain")) + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateSharedSwapchainsKHR); + + // VK_KHR_swapchain + if (IsExtensionLoaded("VK_KHR_swapchain")) + { + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkAcquireNextImageKHR); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateSwapchainKHR); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroySwapchainKHR); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkGetSwapchainImagesKHR); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkQueuePresentKHR); + } + } + catch (const std::exception& e) + { + NazaraError(String("Failed to query device function: ") + e.what()); + return false; + } + + #undef NAZARA_VULKANRENDERER_LOAD_DEVICE + + // And retains informations about queues + UInt32 maxFamilyIndex = 0; + m_enabledQueuesInfos.resize(createInfo.queueCreateInfoCount); + for (UInt32 i = 0; i < createInfo.queueCreateInfoCount; ++i) + { + const VkDeviceQueueCreateInfo& queueCreateInfo = createInfo.pQueueCreateInfos[i]; + QueueFamilyInfo& info = m_enabledQueuesInfos[i]; + + info.familyIndex = queueCreateInfo.queueFamilyIndex; + if (info.familyIndex > maxFamilyIndex) + maxFamilyIndex = info.familyIndex; + + const VkQueueFamilyProperties& queueProperties = queuesProperties[info.familyIndex]; + info.flags = queueProperties.queueFlags; + info.minImageTransferGranularity = queueProperties.minImageTransferGranularity; + info.timestampValidBits = queueProperties.timestampValidBits; + + info.queues.resize(queueCreateInfo.queueCount); + for (UInt32 queueIndex = 0; queueIndex < queueCreateInfo.queueCount; ++queueIndex) + { + QueueInfo& queueInfo = info.queues[queueIndex]; + queueInfo.familyInfo = &info; + queueInfo.priority = queueCreateInfo.pQueuePriorities[queueIndex]; + vkGetDeviceQueue(m_device, info.familyIndex, queueIndex, &queueInfo.queue); + } + } + + m_queuesByFamily.resize(maxFamilyIndex + 1); + for (const QueueFamilyInfo& familyInfo : m_enabledQueuesInfos) + m_queuesByFamily[familyInfo.familyIndex] = &familyInfo.queues; + + return true; + } + } +} diff --git a/src/Nazara/VulkanRenderer/VkInstance.cpp b/src/Nazara/VulkanRenderer/VkInstance.cpp new file mode 100644 index 000000000..411b8fa68 --- /dev/null +++ b/src/Nazara/VulkanRenderer/VkInstance.cpp @@ -0,0 +1,193 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// 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_VULKANRENDERER_LOAD_INSTANCE(func) func = reinterpret_cast(GetProcAddr(#func)) + + try + { + ErrorFlags flags(ErrorFlag_ThrowException, true); + + // Vulkan core + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkCreateDevice); + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkDestroyInstance); + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkEnumeratePhysicalDevices); + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetDeviceProcAddr); + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceFeatures); + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceFormatProperties); + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceImageFormatProperties); + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceMemoryProperties); + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceProperties); + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceQueueFamilyProperties); + + // VK_KHR_display + if (IsExtensionLoaded("VK_KHR_display")) + { + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkCreateDisplayModeKHR); + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkCreateDisplayPlaneSurfaceKHR); + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetDisplayModePropertiesKHR); + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetDisplayPlaneCapabilitiesKHR); + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetDisplayPlaneSupportedDisplaysKHR); + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceDisplayPlanePropertiesKHR); + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceDisplayPropertiesKHR); + } + + // VK_KHR_surface + if (IsExtensionLoaded("VK_KHR_surface")) + { + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkDestroySurfaceKHR); + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceSurfaceCapabilitiesKHR); + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceSurfaceFormatsKHR); + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceSurfacePresentModesKHR); + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceSurfaceSupportKHR); + } + + // VK_EXT_debug_report + if (IsExtensionLoaded("VK_EXT_debug_report")) + { + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkCreateDebugReportCallbackEXT); + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkDestroyDebugReportCallbackEXT); + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkDebugReportMessageEXT); + } + + #ifdef VK_USE_PLATFORM_ANDROID_KHR + // VK_KHR_android_surface + if (IsExtensionLoaded("VK_KHR_android_surface")) + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkCreateAndroidSurfaceKHR); + #endif + + #ifdef VK_USE_PLATFORM_MIR_KHR + // VK_KHR_mir_surface + if (IsExtensionLoaded("VK_KHR_mir_surface")) + { + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkCreateMirSurfaceKHR); + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceMirPresentationSupportKHR); + } + #endif + + #ifdef VK_USE_PLATFORM_XCB_KHR + // VK_KHR_xcb_surface + if (IsExtensionLoaded("VK_KHR_xcb_surface")) + { + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkCreateXcbSurfaceKHR); + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceXcbPresentationSupportKHR); + } + #endif + + #ifdef VK_USE_PLATFORM_XLIB_KHR + // VK_KHR_xlib_surface + if (IsExtensionLoaded("VK_KHR_xlib_surface")) + { + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkCreateXlibSurfaceKHR); + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceXlibPresentationSupportKHR); + } + #endif + + #ifdef VK_USE_PLATFORM_WAYLAND_KHR + // VK_KHR_wayland_surface + if (IsExtensionLoaded("VK_KHR_wayland_surface")) + { + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkCreateWaylandSurfaceKHR); + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceWaylandPresentationSupportKHR); + } + #endif + + #ifdef VK_USE_PLATFORM_WIN32_KHR + // VK_KHR_win32_surface + if (IsExtensionLoaded("VK_KHR_win32_surface")) + { + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkCreateWin32SurfaceKHR); + NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceWin32PresentationSupportKHR); + } + #endif + } + catch (const std::exception& e) + { + NazaraError(String("Failed to query instance function: ") + e.what()); + return false; + } + + #undef NAZARA_VULKANRENDERER_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/VulkanRenderer/VkLoader.cpp b/src/Nazara/VulkanRenderer/VkLoader.cpp new file mode 100644 index 000000000..0da9a930a --- /dev/null +++ b/src/Nazara/VulkanRenderer/VkLoader.cpp @@ -0,0 +1,117 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// 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_VULKANRENDERER_LOAD_GLOBAL(func) func = reinterpret_cast(vkGetInstanceProcAddr(nullptr, #func)) + + NAZARA_VULKANRENDERER_LOAD_GLOBAL(vkCreateInstance); + NAZARA_VULKANRENDERER_LOAD_GLOBAL(vkEnumerateInstanceExtensionProperties); + NAZARA_VULKANRENDERER_LOAD_GLOBAL(vkEnumerateInstanceLayerProperties); + + #undef NAZARA_VULKANRENDERER_LOAD_GLOBAL + + s_lastErrorCode = VkResult::VK_SUCCESS; + + return true; + } + + #define NAZARA_VULKANRENDERER_GLOBAL_FUNCTION_IMPL(func) PFN_##func Loader::func = nullptr + + NAZARA_VULKANRENDERER_GLOBAL_FUNCTION_IMPL(vkCreateInstance); + NAZARA_VULKANRENDERER_GLOBAL_FUNCTION_IMPL(vkEnumerateInstanceExtensionProperties); + NAZARA_VULKANRENDERER_GLOBAL_FUNCTION_IMPL(vkEnumerateInstanceLayerProperties); + NAZARA_VULKANRENDERER_GLOBAL_FUNCTION_IMPL(vkGetInstanceProcAddr); + + #undef NAZARA_VULKANRENDERER_GLOBAL_FUNCTION_IMPL + + DynLib Loader::s_vulkanLib; + VkResult Loader::s_lastErrorCode; + + void Loader::Uninitialize() + { + s_vulkanLib.Unload(); + } + } +} diff --git a/src/Nazara/VulkanRenderer/Vulkan.cpp b/src/Nazara/VulkanRenderer/Vulkan.cpp new file mode 100644 index 000000000..f80c3ec9a --- /dev/null +++ b/src/Nazara/VulkanRenderer/Vulkan.cpp @@ -0,0 +1,451 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + Vk::Instance& Vulkan::GetInstance() + { + return s_instance; + } + + const std::vector& Vulkan::GetPhysicalDevices() + { + return s_physDevices; + } + + const Vk::PhysicalDevice& Vulkan::GetPhysicalDeviceInfo(VkPhysicalDevice physDevice) + { + for (const Vk::PhysicalDevice& info : s_physDevices) + { + if (info.device == physDevice) + return info; + } + + // This cannot happen if physDevice is valid, as we retrieved every physical device + NazaraInternalError("Invalid physical device: " + String::Pointer(physDevice)); + + static Vk::PhysicalDevice dummy; + return dummy; + } + + 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 + if (!Vk::Loader::Initialize()) + { + NazaraError("Failed to load Vulkan API, it may be not installed on your system"); + return false; + } + + String appName = "Another application made with Nazara Engine"; + String engineName = "Nazara Engine - Vulkan Renderer"; + UInt32 apiVersion = VK_MAKE_VERSION(1, 0, 8); + UInt32 appVersion = VK_MAKE_VERSION(1, 0, 0); + UInt32 engineVersion = VK_MAKE_VERSION(1, 0, 0); + + s_initializationParameters.GetStringParameter("VkAppInfo_OverrideApplicationName", &appName); + s_initializationParameters.GetStringParameter("VkAppInfo_OverrideEngineName", &engineName); + + bool bParam; + int iParam; + + if (s_initializationParameters.GetIntegerParameter("VkAppInfo_OverrideAPIVersion", &iParam)) + apiVersion = iParam; + + if (s_initializationParameters.GetIntegerParameter("VkAppInfo_OverrideApplicationVersion", &iParam)) + appVersion = iParam; + + if (s_initializationParameters.GetIntegerParameter("VkAppInfo_OverrideEngineVersion", &iParam)) + engineVersion = iParam; + + VkApplicationInfo appInfo = { + VK_STRUCTURE_TYPE_APPLICATION_INFO, + nullptr, + appName.GetConstBuffer(), + appVersion, + engineName.GetConstBuffer(), + engineVersion, + apiVersion + }; + + VkInstanceCreateFlags createFlags = 0; + + if (s_initializationParameters.GetIntegerParameter("VkInstanceInfo_OverrideCreateFlags", &iParam)) + createFlags = static_cast(iParam); + + std::vector enabledLayers; + std::vector enabledExtensions; + + if (!s_initializationParameters.GetBooleanParameter("VkInstanceInfo_OverrideEnabledLayers", &bParam) || !bParam) + { + //< Nazara default layers goes here + } + + std::vector additionalLayers; // Just to keep the String alive + if (s_initializationParameters.GetIntegerParameter("VkInstanceInfo_EnabledLayerCount", &iParam)) + { + additionalLayers.reserve(iParam); + for (int i = 0; i < iParam; ++i) + { + Nz::String parameterName = "VkInstanceInfo_EnabledLayer" + String::Number(i); + Nz::String layer; + if (s_initializationParameters.GetStringParameter(parameterName, &layer)) + { + additionalLayers.emplace_back(std::move(layer)); + enabledLayers.push_back(additionalLayers.back().GetConstBuffer()); + } + else + NazaraWarning("Parameter " + parameterName + " expected"); + } + } + + if (!s_initializationParameters.GetBooleanParameter("VkInstanceInfo_OverrideEnabledExtensions", &bParam) || !bParam) + { + enabledExtensions.push_back("VK_KHR_surface"); + + #ifdef VK_USE_PLATFORM_ANDROID_KHR + enabledExtensions.push_back("VK_KHR_android_surface"); + #endif + + #ifdef VK_USE_PLATFORM_MIR_KHR + enabledExtensions.push_back("VK_KHR_mir_surface"); + #endif + + #ifdef VK_USE_PLATFORM_XCB_KHR + enabledExtensions.push_back("VK_KHR_xcb_surface"); + #endif + + #ifdef VK_USE_PLATFORM_XLIB_KHR + enabledExtensions.push_back("VK_KHR_xlib_surface"); + #endif + + #ifdef VK_USE_PLATFORM_WAYLAND_KHR + enabledExtensions.push_back("VK_KHR_wayland_surface"); + #endif + + #ifdef VK_USE_PLATFORM_WIN32_KHR + enabledExtensions.push_back("VK_KHR_win32_surface"); + #endif + } + + std::vector additionalExtensions; // Just to keep the String alive + if (s_initializationParameters.GetIntegerParameter("VkInstanceInfo_EnabledExtensionCount", &iParam)) + { + additionalExtensions.reserve(iParam); + for (int i = 0; i < iParam; ++i) + { + Nz::String parameterName = "VkInstanceInfo_EnabledExtension" + String::Number(i); + Nz::String extension; + if (s_initializationParameters.GetStringParameter(parameterName, &extension)) + { + additionalExtensions.emplace_back(std::move(extension)); + enabledExtensions.push_back(additionalExtensions.back().GetConstBuffer()); + } + else + NazaraWarning("Parameter " + parameterName + " expected"); + } + } + + VkInstanceCreateInfo instanceInfo = { + VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, + nullptr, + createFlags, + &appInfo, + UInt32(enabledLayers.size()), + enabledLayers.data(), + UInt32(enabledExtensions.size()), + enabledExtensions.data() + }; + + if (!s_instance.Create(instanceInfo)) + { + NazaraError("Failed to create instance"); + return false; + } + + std::vector physDevices; + if (!s_instance.EnumeratePhysicalDevices(&physDevices)) + { + NazaraError("Failed to enumerate physical devices"); + return false; + } + + s_physDevices.reserve(physDevices.size()); + + for (std::size_t i = 0; i < physDevices.size(); ++i) + { + VkPhysicalDevice physDevice = physDevices[i]; + + Vk::PhysicalDevice deviceInfo; + if (!s_instance.GetPhysicalDeviceQueueFamilyProperties(physDevice, &deviceInfo.queues)) + { + NazaraWarning("Failed to query physical device queue family properties"); + continue; + } + + deviceInfo.device = physDevice; + + deviceInfo.features = s_instance.GetPhysicalDeviceFeatures(physDevice); + deviceInfo.memoryProperties = s_instance.GetPhysicalDeviceMemoryProperties(physDevice); + deviceInfo.properties = s_instance.GetPhysicalDeviceProperties(physDevice); + + s_physDevices.emplace_back(std::move(deviceInfo)); + } + + if (s_physDevices.empty()) + { + NazaraError("No valid physical device found"); + return false; + } + + onExit.Reset(); + + NazaraNotice("Initialized: Vulkan module"); + return true; + } + + bool Vulkan::IsInitialized() + { + return s_moduleReferenceCounter != 0; + } + + Vk::DeviceHandle Vulkan::CreateDevice(VkPhysicalDevice gpu, const Vk::Surface& surface, UInt32* presentableFamilyQueue) + { + Nz::ErrorFlags errFlags(ErrorFlag_ThrowException, true); + + std::vector queueFamilies; + s_instance.GetPhysicalDeviceQueueFamilyProperties(gpu, &queueFamilies); + + // Find a queue that supports graphics operations + UInt32 graphicsQueueNodeIndex = UINT32_MAX; + UInt32 presentQueueNodeIndex = UINT32_MAX; + UInt32 transfertQueueNodeFamily = UINT32_MAX; + for (UInt32 i = 0; i < queueFamilies.size(); i++) + { + bool supportPresentation = false; + if (!surface.GetSupportPresentation(gpu, i, &supportPresentation)) + NazaraWarning("Failed to get presentation support of queue family #" + String::Number(i)); + + if (queueFamilies[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) + { + if (graphicsQueueNodeIndex == UINT32_MAX) + graphicsQueueNodeIndex = i; + + if (supportPresentation) + { + graphicsQueueNodeIndex = i; + presentQueueNodeIndex = i; + break; + } + } + else if (supportPresentation) + presentQueueNodeIndex = i; + } + + for (UInt32 i = 0; i < queueFamilies.size(); i++) + { + if (queueFamilies[i].queueFlags & VK_QUEUE_TRANSFER_BIT) + { + transfertQueueNodeFamily = i; + if (transfertQueueNodeFamily != graphicsQueueNodeIndex) + break; + } + } + + std::array usedQueueFamilies = {graphicsQueueNodeIndex, presentQueueNodeIndex, transfertQueueNodeFamily}; + std::array priorities = {1.f, 1.f, 1.f}; + + std::vector queueCreateInfos; + for (UInt32 queueFamily : usedQueueFamilies) + { + auto it = std::find_if(queueCreateInfos.begin(), queueCreateInfos.end(), [queueFamily] (const VkDeviceQueueCreateInfo& createInfo) + { + return createInfo.queueFamilyIndex == queueFamily; + }); + + if (it == queueCreateInfos.end()) + { + VkDeviceQueueCreateInfo createInfo = { + VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + 0, // VkDeviceQueueCreateFlags flags; + queueFamily, // uint32_t queueFamilyIndex; + 1, // uint32_t queueCount; + priorities.data() // const float* pQueuePriorities; + }; + + queueCreateInfos.emplace_back(createInfo); + } + } + + + std::vector enabledLayers; + std::vector enabledExtensions; + + bool bParam; + int iParam; + + if (!s_initializationParameters.GetBooleanParameter("VkDeviceInfo_OverrideEnabledLayers", &bParam) || !bParam) + { + //< Nazara default layers goes here + } + + std::vector additionalLayers; // Just to keep the String alive + if (s_initializationParameters.GetIntegerParameter("VkDeviceInfo_EnabledLayerCount", &iParam)) + { + additionalLayers.reserve(iParam); + for (int i = 0; i < iParam; ++i) + { + Nz::String parameterName = "VkDeviceInfo_EnabledLayer" + String::Number(i); + Nz::String layer; + if (s_initializationParameters.GetStringParameter(parameterName, &layer)) + { + additionalLayers.emplace_back(std::move(layer)); + enabledLayers.push_back(additionalLayers.back().GetConstBuffer()); + } + else + NazaraWarning("Parameter " + parameterName + " expected"); + } + } + + if (!s_initializationParameters.GetBooleanParameter("VkDeviceInfo_OverrideEnabledExtensions", &bParam) || !bParam) + enabledExtensions.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME); + + std::vector additionalExtensions; // Just to keep the String alive + if (s_initializationParameters.GetIntegerParameter("VkDeviceInfo_EnabledExtensionCount", &iParam)) + { + for (int i = 0; i < iParam; ++i) + { + Nz::String parameterName = "VkDeviceInfo_EnabledExtension" + String::Number(i); + Nz::String extension; + if (s_initializationParameters.GetStringParameter(parameterName, &extension)) + { + additionalExtensions.emplace_back(std::move(extension)); + enabledExtensions.push_back(additionalExtensions.back().GetConstBuffer()); + } + else + NazaraWarning("Parameter " + parameterName + " expected"); + } + } + + VkDeviceCreateInfo createInfo = { + VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, + nullptr, + 0, + UInt32(queueCreateInfos.size()), + queueCreateInfos.data(), + UInt32(enabledLayers.size()), + enabledLayers.data(), + UInt32(enabledExtensions.size()), + enabledExtensions.data(), + nullptr + }; + + ///TODO: First create then move + s_devices.emplace_back(s_instance); + + Vk::Device& device = s_devices.back(); + device.Create(gpu, createInfo); + + *presentableFamilyQueue = presentQueueNodeIndex; + + return device.CreateHandle(); + } + + Vk::DeviceHandle Vulkan::SelectDevice(VkPhysicalDevice gpu, const Vk::Surface& surface, UInt32* presentableFamilyQueue) + { + // First, try to find a device compatible with that surface + for (Vk::Device& device : s_devices) + { + if (device.GetPhysicalDevice() == gpu) + { + const std::vector& queueFamilyInfo = device.GetEnabledQueues(); + UInt32 presentableQueueFamilyIndex = UINT32_MAX; + for (Vk::Device::QueueFamilyInfo queueInfo : queueFamilyInfo) + { + bool supported = false; + if (surface.GetSupportPresentation(gpu, queueInfo.familyIndex, &supported) && supported) + { + if (presentableQueueFamilyIndex == UINT32_MAX || queueInfo.flags & VK_QUEUE_GRAPHICS_BIT) + { + presentableQueueFamilyIndex = queueInfo.familyIndex; + if (queueInfo.flags & VK_QUEUE_GRAPHICS_BIT) + break; + } + } + } + + if (presentableQueueFamilyIndex != UINT32_MAX) + *presentableFamilyQueue = presentableQueueFamilyIndex; + } + } + + // No device had support for that surface, create one + return CreateDevice(gpu, surface, presentableFamilyQueue); + } + + void Vulkan::SetParameters(const ParameterList& parameters) + { + s_initializationParameters = parameters; + } + + 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 + s_devices.clear(); + s_instance.Destroy(); + + Vk::Loader::Uninitialize(); + + NazaraNotice("Uninitialized: Vulkan module"); + + // Free module dependencies + Utility::Uninitialize(); + } + + std::list Vulkan::s_devices; + std::vector Vulkan::s_physDevices; + Vk::Instance Vulkan::s_instance; + ParameterList Vulkan::s_initializationParameters; + unsigned int Vulkan::s_moduleReferenceCounter = 0; +} + diff --git a/src/Nazara/VulkanRenderer/VulkanRenderer.cpp b/src/Nazara/VulkanRenderer/VulkanRenderer.cpp new file mode 100644 index 000000000..6d6f4d055 --- /dev/null +++ b/src/Nazara/VulkanRenderer/VulkanRenderer.cpp @@ -0,0 +1,252 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + bool VulkanRenderer::IsBetterThan(const RendererImpl* other) const + { + if (other->QueryAPI() == RenderAPI_Vulkan && QueryAPIVersion() < other->QueryAPIVersion()) + return false; + + return true; //< Vulkan FTW + } + + bool VulkanRenderer::Prepare(const ParameterList& parameters) + { + if (!Vk::Loader::Initialize()) + { + NazaraError("Failed to load Vulkan API, it may be not installed on your system"); + return false; + } + + String appName = "Another application made with Nazara Engine"; + String engineName = "Nazara Engine - Vulkan Renderer"; + + UInt32 apiVersion = APIVersion; + UInt32 appVersion = VK_MAKE_VERSION(1, 0, 0); + UInt32 engineVersion = VK_MAKE_VERSION(1, 0, 0); + + parameters.GetStringParameter("VkAppInfo_OverrideApplicationName", &appName); + parameters.GetStringParameter("VkAppInfo_OverrideEngineName", &engineName); + + bool bParam; + int iParam; + + if (parameters.GetIntegerParameter("VkAppInfo_OverrideAPIVersion", &iParam)) + apiVersion = iParam; + + if (parameters.GetIntegerParameter("VkAppInfo_OverrideApplicationVersion", &iParam)) + appVersion = iParam; + + if (parameters.GetIntegerParameter("VkAppInfo_OverrideEngineVersion", &iParam)) + engineVersion = iParam; + + VkApplicationInfo appInfo = { + VK_STRUCTURE_TYPE_APPLICATION_INFO, + nullptr, + appName.GetConstBuffer(), + appVersion, + engineName.GetConstBuffer(), + engineVersion, + apiVersion + }; + + VkInstanceCreateFlags createFlags = 0; + + if (parameters.GetIntegerParameter("VkInstanceInfo_OverrideCreateFlags", &iParam)) + createFlags = static_cast(iParam); + + std::vector enabledLayers; + std::vector enabledExtensions; + + if (!parameters.GetBooleanParameter("VkInstanceInfo_OverrideEnabledLayers", &bParam) || !bParam) + { + //< Nazara default layers goes here + } + + std::vector additionalLayers; // Just to keep the String alive + if (parameters.GetIntegerParameter("VkInstanceInfo_EnabledLayerCount", &iParam)) + { + additionalLayers.reserve(iParam); + for (int i = 0; i < iParam; ++i) + { + Nz::String parameterName = "VkInstanceInfo_EnabledLayer" + String::Number(i); + Nz::String layer; + if (parameters.GetStringParameter(parameterName, &layer)) + { + additionalLayers.emplace_back(std::move(layer)); + enabledLayers.push_back(additionalLayers.back().GetConstBuffer()); + } + else + NazaraWarning("Parameter " + parameterName + " expected"); + } + } + + if (!parameters.GetBooleanParameter("VkInstanceInfo_OverrideEnabledExtensions", &bParam) || !bParam) + { + enabledExtensions.push_back("VK_KHR_surface"); + + #ifdef VK_USE_PLATFORM_ANDROID_KHR + enabledExtensions.push_back("VK_KHR_android_surface"); + #endif + + #ifdef VK_USE_PLATFORM_MIR_KHR + enabledExtensions.push_back("VK_KHR_mir_surface"); + #endif + + #ifdef VK_USE_PLATFORM_XCB_KHR + enabledExtensions.push_back("VK_KHR_xcb_surface"); + #endif + + #ifdef VK_USE_PLATFORM_XLIB_KHR + enabledExtensions.push_back("VK_KHR_xlib_surface"); + #endif + + #ifdef VK_USE_PLATFORM_WAYLAND_KHR + enabledExtensions.push_back("VK_KHR_wayland_surface"); + #endif + + #ifdef VK_USE_PLATFORM_WIN32_KHR + enabledExtensions.push_back("VK_KHR_win32_surface"); + #endif + } + + std::vector additionalExtensions; // Just to keep the String alive + if (parameters.GetIntegerParameter("VkInstanceInfo_EnabledExtensionCount", &iParam)) + { + additionalExtensions.reserve(iParam); + for (int i = 0; i < iParam; ++i) + { + Nz::String parameterName = "VkInstanceInfo_EnabledExtension" + String::Number(i); + Nz::String extension; + if (parameters.GetStringParameter(parameterName, &extension)) + { + additionalExtensions.emplace_back(std::move(extension)); + enabledExtensions.push_back(additionalExtensions.back().GetConstBuffer()); + } + else + NazaraWarning("Parameter " + parameterName + " expected"); + } + } + + VkInstanceCreateInfo instanceInfo = + { + VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + createFlags, // VkInstanceCreateFlags flags; + &appInfo, // const VkApplicationInfo* pApplicationInfo; + UInt32(enabledLayers.size()), // uint32_t enabledLayerCount; + enabledLayers.data(), // const char* const* ppEnabledLayerNames; + UInt32(enabledExtensions.size()), // uint32_t enabledExtensionCount; + enabledExtensions.data() // const char* const* ppEnabledExtensionNames; + }; + + if (!m_instance.Create(instanceInfo)) + { + NazaraError("Failed to create instance"); + return false; + } + + m_apiVersion = apiVersion; + + std::vector physDevices; + if (!m_instance.EnumeratePhysicalDevices(&physDevices)) + { + NazaraError("Failed to enumerate physical devices"); + return false; + } + + m_physDevices.reserve(physDevices.size()); + for (std::size_t i = 0; i < physDevices.size(); ++i) + { + VkPhysicalDevice physDevice = physDevices[i]; + + Vk::PhysicalDevice deviceInfo; + if (!m_instance.GetPhysicalDeviceQueueFamilyProperties(physDevice, &deviceInfo.queues)) + { + NazaraWarning("Failed to query physical device queue family properties for " + String(deviceInfo.properties.deviceName) + " (0x" + String::Number(deviceInfo.properties.deviceID, 16) + ')'); + continue; + } + + deviceInfo.device = physDevice; + + deviceInfo.features = m_instance.GetPhysicalDeviceFeatures(physDevice); + deviceInfo.memoryProperties = m_instance.GetPhysicalDeviceMemoryProperties(physDevice); + deviceInfo.properties = m_instance.GetPhysicalDeviceProperties(physDevice); + + m_physDevices.emplace_back(std::move(deviceInfo)); + } + + if (m_physDevices.empty()) + { + NazaraError("No valid physical device found"); + return false; + } + + return true; + } + + RenderAPI VulkanRenderer::QueryAPI() const + { + return RenderAPI_Vulkan; + } + + String VulkanRenderer::QueryAPIString() const + { + StringStream ss; + ss << "Vulkan renderer " << VK_VERSION_MAJOR(m_apiVersion) << '.' << VK_VERSION_MINOR(m_apiVersion) << '.' << VK_VERSION_PATCH(m_apiVersion); + + return ss; + } + + UInt32 VulkanRenderer::QueryAPIVersion() const + { + return m_apiVersion; + } + + std::vector VulkanRenderer::QueryRenderDevices() const + { + std::vector devices; + devices.reserve(m_physDevices.size()); + + for (const Vk::PhysicalDevice& physDevice : m_physDevices) + { + RenderDevice device; + device.name = physDevice.properties.deviceName; + + switch (physDevice.properties.deviceType) + { + case VK_PHYSICAL_DEVICE_TYPE_CPU: + device.type = RenderDeviceType_Software; + break; + + case VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU: + device.type = RenderDeviceType_Dedicated; + break; + + case VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU: + device.type = RenderDeviceType_Integrated; + break; + + case VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU: + device.type = RenderDeviceType_Virtual; + break; + + default: + NazaraWarning("Device " + device.name + " has handled device type (0x" + String::Number(physDevice.properties.deviceType, 16) + ')'); + case VK_PHYSICAL_DEVICE_TYPE_OTHER: + device.type = RenderDeviceType_Unknown; + break; + } + + devices.emplace_back(device); + } + + return devices; + } +} From f709ca4997c5523de4e38c8edc29a2498e8697f8 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 15 Sep 2016 00:44:22 +0200 Subject: [PATCH 050/316] VulkanRenderer: Add RenderWindow wrapper Former-commit-id: 8046b7ecb5a71ba64bb5d51faaa2d2946318e6f1 [formerly adbc30c0ed533b63c445125f013384412f9272bd] [formerly eaa0c2a91e13440ee9b869d5fd2faad08d682879 [formerly 67381c6dbe3b960b1ab23bbe18c0a6193286f330]] Former-commit-id: f4716a44444383d107f44265b5720490e141e4d0 [formerly 49d667d30dda623e6192853573efe05aa589035c] Former-commit-id: fd3718fac5bb6d896d7cfd350807bbc1c0af309f --- include/Nazara/Renderer.hpp | 24 +- include/Nazara/Renderer/RenderWindow.hpp | 52 ++-- include/Nazara/Renderer/RenderWindow.inl | 99 +++---- include/Nazara/Renderer/RenderWindowImpl.hpp | 72 +---- .../Renderer/RenderWindowParameters.hpp | 23 ++ include/Nazara/Renderer/RendererImpl.hpp | 3 + include/Nazara/VulkanRenderer.hpp | 7 +- .../{RenderTarget.hpp => VkRenderTarget.hpp} | 28 +- .../{RenderWindow.hpp => VkRenderWindow.hpp} | 61 ++--- .../Nazara/VulkanRenderer/VkRenderWindow.inl | 48 ++++ .../Nazara/VulkanRenderer/VulkanRenderer.hpp | 2 + src/Nazara/Renderer/RenderWindow.cpp | 246 +----------------- src/Nazara/Renderer/RendererWindowImpl.cpp | 11 + .../{RenderTarget.cpp => VkRenderTarget.cpp} | 4 +- .../{RenderWindow.cpp => VkRenderWindow.cpp} | 178 ++++--------- src/Nazara/VulkanRenderer/VulkanRenderer.cpp | 6 + 16 files changed, 259 insertions(+), 605 deletions(-) create mode 100644 include/Nazara/Renderer/RenderWindowParameters.hpp rename include/Nazara/VulkanRenderer/{RenderTarget.hpp => VkRenderTarget.hpp} (65%) rename include/Nazara/VulkanRenderer/{RenderWindow.hpp => VkRenderWindow.hpp} (50%) create mode 100644 include/Nazara/VulkanRenderer/VkRenderWindow.inl create mode 100644 src/Nazara/Renderer/RendererWindowImpl.cpp rename src/Nazara/VulkanRenderer/{RenderTarget.cpp => VkRenderTarget.cpp} (76%) rename src/Nazara/VulkanRenderer/{RenderWindow.cpp => VkRenderWindow.cpp} (79%) diff --git a/include/Nazara/Renderer.hpp b/include/Nazara/Renderer.hpp index b57d4c5a5..52519d374 100644 --- a/include/Nazara/Renderer.hpp +++ b/include/Nazara/Renderer.hpp @@ -1,4 +1,4 @@ -// This file was automatically generated on 24 Jun 2015 at 13:55:50 +// This file was automatically generated on 15 Sep 2016 at 00:43:26 /* Nazara Engine - Renderer module @@ -30,26 +30,12 @@ #define NAZARA_GLOBAL_RENDERER_HPP #include -#include -#include -#include #include -#include -#include -#include +#include #include -#include -#include -#include -#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include #endif // NAZARA_GLOBAL_RENDERER_HPP diff --git a/include/Nazara/Renderer/RenderWindow.hpp b/include/Nazara/Renderer/RenderWindow.hpp index 5435cebaf..a0d5859e4 100644 --- a/include/Nazara/Renderer/RenderWindow.hpp +++ b/include/Nazara/Renderer/RenderWindow.hpp @@ -1,9 +1,7 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2016 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp -// Interface inspirée de la SFML par Laurent Gomila - #pragma once #ifndef NAZARA_RENDERWINDOW_HPP @@ -13,66 +11,52 @@ #include #include #include +#include +#include #include -#include +#include namespace Nz { - class AbstractImage; - class Context; - class Texture; - struct ContextParameters; - - class NAZARA_RENDERER_API RenderWindow : public RenderTarget, public Window + class NAZARA_RENDERER_API RenderWindow : public Window { public: - RenderWindow() = default; - RenderWindow(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default, const ContextParameters& parameters = ContextParameters()); - RenderWindow(WindowHandle handle, const ContextParameters& parameters = ContextParameters()); + inline RenderWindow(); + inline RenderWindow(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default, const RenderWindowParameters& parameters = RenderWindowParameters()); + inline RenderWindow(WindowHandle handle, const RenderWindowParameters& parameters = RenderWindowParameters()); RenderWindow(const RenderWindow&) = delete; RenderWindow(RenderWindow&&) = delete; ///TODO virtual ~RenderWindow(); - bool CopyToImage(AbstractImage* image, const Vector3ui& dstPos = Vector3ui(0U)) const; - bool CopyToImage(AbstractImage* image, const Rectui& rect, const Vector3ui& dstPos = Vector3ui(0U)) const; - - bool Create(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default, const ContextParameters& parameters = ContextParameters()); - bool Create(WindowHandle handle, const ContextParameters& parameters = ContextParameters()); + inline bool Create(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default, const RenderWindowParameters& parameters = RenderWindowParameters()); + inline bool Create(WindowHandle handle, const RenderWindowParameters& parameters = RenderWindowParameters()); void Display(); void EnableVerticalSync(bool enabled); - unsigned int GetHeight() const override; - RenderTargetParameters GetParameters() const override; - unsigned int GetWidth() const override; + inline RenderWindowImpl* GetImpl(); - bool IsRenderable() const override; - bool IsValid() const; + inline bool IsValid() const; - void SetFramerateLimit(unsigned int limit); - - // Fonctions OpenGL - ContextParameters GetContextParameters() const; - bool HasContext() const override; + inline void SetFramerateLimit(unsigned int limit); RenderWindow& operator=(const RenderWindow&) = delete; RenderWindow& operator=(RenderWindow&&) = delete; ///TODO protected: - bool Activate() const override; - void EnsureTargetUpdated() const override; bool OnWindowCreated() override; void OnWindowDestroy() override; void OnWindowResized() override; private: - mutable std::vector m_buffer; + std::unique_ptr m_impl; Clock m_clock; - ContextParameters m_parameters; - mutable Context* m_context = nullptr; - unsigned int m_framerateLimit = 0; + RenderWindowParameters m_parameters; + unsigned int m_framerateLimit; }; } +#include + #endif // NAZARA_RENDERWINDOW_HPP diff --git a/include/Nazara/Renderer/RenderWindow.inl b/include/Nazara/Renderer/RenderWindow.inl index 1cda9d63d..a7ff34c62 100644 --- a/include/Nazara/Renderer/RenderWindow.inl +++ b/include/Nazara/Renderer/RenderWindow.inl @@ -2,80 +2,57 @@ // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp -// Interface inspirée de la SFML par Laurent Gomila - -#pragma once - -#ifndef NAZARA_RENDERWINDOW_HPP -#define NAZARA_RENDERWINDOW_HPP - -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include namespace Nz { - class AbstractImage; - class Context; - class Texture; - struct ContextParameters; - - class NAZARA_RENDERER_API RenderWindow : public RenderTarget, public Window + inline RenderWindow::RenderWindow() : + m_framerateLimit(0U) { - public: - RenderWindow() = default; - RenderWindow(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default, const ContextParameters& parameters = ContextParameters()); - RenderWindow(WindowHandle handle, const ContextParameters& parameters = ContextParameters()); - RenderWindow(const RenderWindow&) = delete; - RenderWindow(RenderWindow&&) = delete; ///TODO - virtual ~RenderWindow(); + } - bool CopyToImage(AbstractImage* image, const Vector3ui& dstPos = Vector3ui(0U)) const; - bool CopyToImage(AbstractImage* image, const Rectui& rect, const Vector3ui& dstPos = Vector3ui(0U)) const; + inline RenderWindow::RenderWindow(VideoMode mode, const String& title, UInt32 style, const RenderWindowParameters& parameters) : + RenderWindow() + { + ErrorFlags errFlags(ErrorFlag_ThrowException, true); - bool Create(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default, const ContextParameters& parameters = ContextParameters()); - bool Create(WindowHandle handle, const ContextParameters& parameters = ContextParameters()); + Create(mode, title, style, parameters); + } - void Display(); + inline RenderWindow::RenderWindow(WindowHandle handle, const RenderWindowParameters& parameters) + { + ErrorFlags errFlags(ErrorFlag_ThrowException, true); - void EnableVerticalSync(bool enabled); + Create(handle, parameters); + } - unsigned int GetHeight() const override; - RenderTargetParameters GetParameters() const override; - unsigned int GetWidth() const override; + inline bool RenderWindow::Create(VideoMode mode, const String& title, UInt32 style, const RenderWindowParameters& parameters) + { + m_parameters = parameters; - bool IsRenderable() const override; - bool IsValid() const; + return Window::Create(mode, title, style); + } - void SetFramerateLimit(unsigned int limit); + inline bool RenderWindow::Create(WindowHandle handle, const RenderWindowParameters& parameters) + { + m_parameters = parameters; - // Fonctions OpenGL - ContextParameters GetContextParameters() const; - bool HasContext() const override; + return Window::Create(handle); + } - RenderWindow& operator=(const RenderWindow&) = delete; - RenderWindow& operator=(RenderWindow&&) = delete; ///TODO + inline RenderWindowImpl* Nz::RenderWindow::GetImpl() + { + return m_impl.get(); + } - protected: - bool Activate() const override; - void EnsureTargetUpdated() const override; - bool OnWindowCreated() override; - void OnWindowDestroy() override; - void OnWindowResized() override; + inline bool RenderWindow::IsValid() const + { + return m_impl != nullptr; + } - private: - mutable std::vector m_buffer; - Clock m_clock; - ContextParameters m_parameters; - mutable Context* m_context = nullptr; - unsigned int m_framerateLimit = 0; - }; + inline void RenderWindow::SetFramerateLimit(unsigned int limit) + { + m_framerateLimit = limit; + } } - -#endif // NAZARA_RENDERWINDOW_HPP diff --git a/include/Nazara/Renderer/RenderWindowImpl.hpp b/include/Nazara/Renderer/RenderWindowImpl.hpp index 1cda9d63d..19a831773 100644 --- a/include/Nazara/Renderer/RenderWindowImpl.hpp +++ b/include/Nazara/Renderer/RenderWindowImpl.hpp @@ -2,80 +2,28 @@ // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp -// Interface inspirée de la SFML par Laurent Gomila - #pragma once -#ifndef NAZARA_RENDERWINDOW_HPP -#define NAZARA_RENDERWINDOW_HPP +#ifndef NAZARA_RENDERWINDOWIMPL_HPP +#define NAZARA_RENDERWINDOWIMPL_HPP #include -#include -#include -#include +#include #include -#include -#include -#include +#include +#include #include namespace Nz { - class AbstractImage; - class Context; - class Texture; - struct ContextParameters; - - class NAZARA_RENDERER_API RenderWindow : public RenderTarget, public Window + class NAZARA_RENDERER_API RenderWindowImpl { public: - RenderWindow() = default; - RenderWindow(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default, const ContextParameters& parameters = ContextParameters()); - RenderWindow(WindowHandle handle, const ContextParameters& parameters = ContextParameters()); - RenderWindow(const RenderWindow&) = delete; - RenderWindow(RenderWindow&&) = delete; ///TODO - virtual ~RenderWindow(); + RenderWindowImpl() = default; + virtual ~RenderWindowImpl(); - bool CopyToImage(AbstractImage* image, const Vector3ui& dstPos = Vector3ui(0U)) const; - bool CopyToImage(AbstractImage* image, const Rectui& rect, const Vector3ui& dstPos = Vector3ui(0U)) const; - - bool Create(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default, const ContextParameters& parameters = ContextParameters()); - bool Create(WindowHandle handle, const ContextParameters& parameters = ContextParameters()); - - void Display(); - - void EnableVerticalSync(bool enabled); - - unsigned int GetHeight() const override; - RenderTargetParameters GetParameters() const override; - unsigned int GetWidth() const override; - - bool IsRenderable() const override; - bool IsValid() const; - - void SetFramerateLimit(unsigned int limit); - - // Fonctions OpenGL - ContextParameters GetContextParameters() const; - bool HasContext() const override; - - RenderWindow& operator=(const RenderWindow&) = delete; - RenderWindow& operator=(RenderWindow&&) = delete; ///TODO - - protected: - bool Activate() const override; - void EnsureTargetUpdated() const override; - bool OnWindowCreated() override; - void OnWindowDestroy() override; - void OnWindowResized() override; - - private: - mutable std::vector m_buffer; - Clock m_clock; - ContextParameters m_parameters; - mutable Context* m_context = nullptr; - unsigned int m_framerateLimit = 0; + virtual bool Create(WindowHandle handle, const Vector2ui& size, const RenderWindowParameters& parameters) = 0; }; } -#endif // NAZARA_RENDERWINDOW_HPP +#endif // NAZARA_RENDERWINDOWIMPL_HPP diff --git a/include/Nazara/Renderer/RenderWindowParameters.hpp b/include/Nazara/Renderer/RenderWindowParameters.hpp new file mode 100644 index 000000000..78645b54c --- /dev/null +++ b/include/Nazara/Renderer/RenderWindowParameters.hpp @@ -0,0 +1,23 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_RENDERWINDOWPARAMETERS_HPP +#define NAZARA_RENDERWINDOWPARAMETERS_HPP + +#include +#include +#include + +namespace Nz +{ + struct RenderWindowParameters + { + std::vector depthFormats = {Nz::PixelFormatType_Depth32, Nz::PixelFormatType_Depth24}; //< By order of preference + bool verticalSync = false; + }; +} + +#endif // NAZARA_RENDERWINDOWPARAMETERS_HPP diff --git a/include/Nazara/Renderer/RendererImpl.hpp b/include/Nazara/Renderer/RendererImpl.hpp index f3f70d892..4c88773dd 100644 --- a/include/Nazara/Renderer/RendererImpl.hpp +++ b/include/Nazara/Renderer/RendererImpl.hpp @@ -18,6 +18,7 @@ namespace Nz { class RendererImpl; + class RenderWindowImpl; using CreateRendererImplFunc = RendererImpl*(*)(); @@ -27,6 +28,8 @@ namespace Nz RendererImpl() = default; virtual ~RendererImpl(); + virtual std::unique_ptr CreateRenderWindowImpl() = 0; + virtual bool IsBetterThan(const RendererImpl* other) const = 0; virtual RenderAPI QueryAPI() const = 0; diff --git a/include/Nazara/VulkanRenderer.hpp b/include/Nazara/VulkanRenderer.hpp index a2973a5fc..13874e658 100644 --- a/include/Nazara/VulkanRenderer.hpp +++ b/include/Nazara/VulkanRenderer.hpp @@ -1,4 +1,4 @@ -// This file was automatically generated on 17 Aug 2016 at 14:07:55 +// This file was automatically generated on 15 Sep 2016 at 00:43:26 /* Nazara Engine - Vulkan @@ -30,8 +30,6 @@ #define NAZARA_GLOBAL_VULKANRENDERER_HPP #include -#include -#include #include #include #include @@ -52,10 +50,13 @@ #include #include #include +#include +#include #include #include #include #include #include +#include #endif // NAZARA_GLOBAL_VULKANRENDERER_HPP diff --git a/include/Nazara/VulkanRenderer/RenderTarget.hpp b/include/Nazara/VulkanRenderer/VkRenderTarget.hpp similarity index 65% rename from include/Nazara/VulkanRenderer/RenderTarget.hpp rename to include/Nazara/VulkanRenderer/VkRenderTarget.hpp index c8e6b27fa..51aa97d4a 100644 --- a/include/Nazara/VulkanRenderer/RenderTarget.hpp +++ b/include/Nazara/VulkanRenderer/VkRenderTarget.hpp @@ -4,8 +4,8 @@ #pragma once -#ifndef NAZARA_RENDERTARGET_HPP -#define NAZARA_RENDERTARGET_HPP +#ifndef NAZARA_VULKANRENDERER_RENDERTARGET_HPP +#define NAZARA_VULKANRENDERER_RENDERTARGET_HPP #include #include @@ -18,17 +18,13 @@ namespace Nz { - class Renderer; - - class NAZARA_VULKANRENDERER_API RenderTarget + class NAZARA_VULKANRENDERER_API VkRenderTarget { - friend Renderer; - public: - RenderTarget() = default; - RenderTarget(const RenderTarget&) = delete; - RenderTarget(RenderTarget&&) = delete; ///TOOD? - virtual ~RenderTarget(); + VkRenderTarget() = default; + VkRenderTarget(const VkRenderTarget&) = delete; + VkRenderTarget(VkRenderTarget&&) = delete; ///TOOD? + virtual ~VkRenderTarget(); virtual bool Acquire(UInt32* imageIndex) const = 0; @@ -44,12 +40,12 @@ namespace Nz virtual void Present(UInt32 imageIndex) = 0; - RenderTarget& operator=(const RenderTarget&) = delete; - RenderTarget& operator=(RenderTarget&&) = delete; ///TOOD? + VkRenderTarget& operator=(const VkRenderTarget&) = delete; + VkRenderTarget& operator=(VkRenderTarget&&) = delete; ///TOOD? // Signals: - NazaraSignal(OnRenderTargetRelease, const RenderTarget* /*renderTarget*/); - NazaraSignal(OnRenderTargetSizeChange, const RenderTarget* /*renderTarget*/); + NazaraSignal(OnRenderTargetRelease, const VkRenderTarget* /*renderTarget*/); + NazaraSignal(OnRenderTargetSizeChange, const VkRenderTarget* /*renderTarget*/); protected: Vk::RenderPass m_renderPass; @@ -57,4 +53,4 @@ namespace Nz }; } -#endif // NAZARA_RENDERTARGET_HPP +#endif // NAZARA_VULKANRENDERER_RENDERTARGET_HPP diff --git a/include/Nazara/VulkanRenderer/RenderWindow.hpp b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp similarity index 50% rename from include/Nazara/VulkanRenderer/RenderWindow.hpp rename to include/Nazara/VulkanRenderer/VkRenderWindow.hpp index 0b7f0878e..348fb84c1 100644 --- a/include/Nazara/VulkanRenderer/RenderWindow.hpp +++ b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp @@ -4,78 +4,65 @@ #pragma once -#ifndef NAZARA_RENDERWINDOW_HPP -#define NAZARA_RENDERWINDOW_HPP +#ifndef NAZARA_VULKANRENDERER_RENDERWINDOW_HPP +#define NAZARA_VULKANRENDERER_RENDERWINDOW_HPP #include #include #include #include +#include #include -#include #include #include #include #include #include #include +#include #include #include -#include #include namespace Nz { - class NAZARA_VULKANRENDERER_API RenderWindow : public RenderTarget, public Window + class NAZARA_VULKANRENDERER_API VkRenderWindow : public VkRenderTarget, public RenderWindowImpl { public: - RenderWindow(); - RenderWindow(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default); - RenderWindow(WindowHandle handle); - RenderWindow(const RenderWindow&) = delete; - RenderWindow(RenderWindow&&) = delete; ///TODO - virtual ~RenderWindow(); + VkRenderWindow(); + VkRenderWindow(const VkRenderWindow&) = delete; + VkRenderWindow(VkRenderWindow&&) = delete; ///TODO + virtual ~VkRenderWindow(); bool Acquire(UInt32* index) const override; void BuildPreRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) override; void BuildPostRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) override; - bool Create(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default); - bool Create(WindowHandle handle); + bool Create(WindowHandle handle, const Vector2ui& size, const RenderWindowParameters& parameters) override; - const Vk::Framebuffer& GetFrameBuffer(UInt32 imageIndex) const override; - UInt32 GetFramebufferCount() const; - const Vk::DeviceHandle& GetDevice() const; - UInt32 GetPresentableFamilyQueue() const; - const Vk::Surface& GetSurface() const; - const Vk::Swapchain& GetSwapchain() const; + inline const Vk::Framebuffer& GetFrameBuffer(UInt32 imageIndex) const override; + inline UInt32 GetFramebufferCount() const; + inline const Vk::DeviceHandle& GetDevice() const; + inline UInt32 GetPresentableFamilyQueue() const; + inline const Vk::Surface& GetSurface() const; + inline const Vk::Swapchain& GetSwapchain() const; void Present(UInt32 imageIndex) override; - bool IsValid() const; - - void SetDepthStencilFormats(std::vector pixelFormat); - void SetPhysicalDevice(VkPhysicalDevice device); - - RenderWindow& operator=(const RenderWindow&) = delete; - RenderWindow& operator=(RenderWindow&&) = delete; ///TODO + VkRenderWindow& operator=(const VkRenderWindow&) = delete; + VkRenderWindow& operator=(VkRenderWindow&&) = delete; ///TODO private: - bool OnWindowCreated() override; - void OnWindowDestroy() override; - void OnWindowResized() override; - - bool SetupDepthBuffer(); - bool SetupRenderPass(); - bool SetupSwapchain(); + bool SetupDepthBuffer(const Vector2ui& size); + bool SetupRenderPass(const Vector2ui& size); + bool SetupSwapchain(const Vector2ui& size); Clock m_clock; VkColorSpaceKHR m_colorSpace; VkFormat m_colorFormat; VkFormat m_depthStencilFormat; - VkPhysicalDevice m_forcedPhysicalDevice; - std::vector m_wantedDepthStencilFormats; + VkPhysicalDevice m_physicalDevice; std::vector m_frameBuffers; Vk::DeviceHandle m_device; Vk::DeviceMemory m_depthBufferMemory; @@ -88,4 +75,6 @@ namespace Nz }; } -#endif // NAZARA_RENDERWINDOW_HPP +#include + +#endif // NAZARA_VULKANRENDERER_RENDERWINDOW_HPP diff --git a/include/Nazara/VulkanRenderer/VkRenderWindow.inl b/include/Nazara/VulkanRenderer/VkRenderWindow.inl new file mode 100644 index 000000000..0142c1d03 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkRenderWindow.inl @@ -0,0 +1,48 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline const Vk::DeviceHandle& VkRenderWindow::GetDevice() const + { + return m_device; + } + + inline const Vk::Framebuffer& VkRenderWindow::GetFrameBuffer(UInt32 imageIndex) const + { + return m_frameBuffers[imageIndex]; + } + + inline UInt32 VkRenderWindow::GetFramebufferCount() const + { + return static_cast(m_frameBuffers.size()); + } + + inline UInt32 VkRenderWindow::GetPresentableFamilyQueue() const + { + return m_presentableFamilyQueue; + } + + inline const Vk::Surface& VkRenderWindow::GetSurface() const + { + return m_surface; + } + + inline const Vk::Swapchain& VkRenderWindow::GetSwapchain() const + { + return m_swapchain; + } + + inline void VkRenderWindow::Present(UInt32 imageIndex) + { + NazaraAssert(imageIndex < m_frameBuffers.size(), "Invalid image index"); + + m_presentQueue.Present(m_swapchain, imageIndex); + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/VulkanRenderer.hpp b/include/Nazara/VulkanRenderer/VulkanRenderer.hpp index b77cb6935..8fc88ca4c 100644 --- a/include/Nazara/VulkanRenderer/VulkanRenderer.hpp +++ b/include/Nazara/VulkanRenderer/VulkanRenderer.hpp @@ -21,6 +21,8 @@ namespace Nz VulkanRenderer() = default; ~VulkanRenderer() = default; + std::unique_ptr CreateRenderWindowImpl() override; + bool IsBetterThan(const RendererImpl* other) const override; RenderAPI QueryAPI() const override; diff --git a/src/Nazara/Renderer/RenderWindow.cpp b/src/Nazara/Renderer/RenderWindow.cpp index 078c28f2b..56626386e 100644 --- a/src/Nazara/Renderer/RenderWindow.cpp +++ b/src/Nazara/Renderer/RenderWindow.cpp @@ -1,138 +1,21 @@ // Copyright (C) 2015 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp -/* + #include #include -#include #include -#include -#include #include -#include -#include #include namespace Nz { - RenderWindow::RenderWindow(VideoMode mode, const String& title, UInt32 style, const ContextParameters& parameters) : - RenderTarget(), Window() - { - ErrorFlags flags(ErrorFlag_ThrowException, true); - Create(mode, title, style, parameters); - } - - RenderWindow::RenderWindow(WindowHandle handle, const ContextParameters& parameters) : - RenderTarget(), Window() - { - ErrorFlags flags(ErrorFlag_ThrowException, true); - Create(handle, parameters); - } - RenderWindow::~RenderWindow() { // Nécessaire si Window::Destroy est appelé par son destructeur OnWindowDestroy(); } - bool RenderWindow::CopyToImage(AbstractImage* image, const Vector3ui& dstPos) const - { - #if NAZARA_RENDERER_SAFE - if (!m_context) - { - NazaraError("Window has not been created"); - return false; - } - #endif - - return CopyToImage(image, Rectui(Vector2ui(0U), GetSize()), dstPos); - } - - bool RenderWindow::CopyToImage(AbstractImage* image, const Rectui& rect, const Vector3ui& dstPos) const - { - #if NAZARA_RENDERER_SAFE - if (!m_context) - { - NazaraError("Window has not been created"); - return false; - } - #endif - - Vector2ui windowSize = GetSize(); - - #if NAZARA_RENDERER_SAFE - if (!image) - { - NazaraError("Image must be valid"); - return false; - } - - if (image->GetFormat() != PixelFormatType_RGBA8) - { - // Pour plus de facilité, évidemment on peut faire sauter cette règle avec un peu de gestion - NazaraError("Image must be RGBA8-formatted"); - return false; - } - - if (rect.x + rect.width > windowSize.x || rect.y + rect.height > windowSize.y) - { - NazaraError("Rectangle dimensions are out of window's bounds"); - return false; - } - - Vector3ui imageSize = image->GetSize(); - if (dstPos.x + rect.width > imageSize.x || dstPos.y + rect.height > imageSize.y || dstPos.z > imageSize.z) - { - NazaraError("Cube dimensions are out of image's bounds"); - return false; - } - #endif - - const Context* currentContext = Context::GetCurrent(); - if (m_context != currentContext) - { - if (!m_context->SetActive(true)) - { - NazaraError("Failed to activate context"); - return false; - } - } - - ///TODO: Fast-path pour les images en cas de copie du buffer entier - - m_buffer.resize(rect.width*rect.height*4); - glReadPixels(rect.x, windowSize.y - rect.height - rect.y, rect.width, rect.height, GL_RGBA, GL_UNSIGNED_BYTE, m_buffer.data()); - - // Les pixels sont retournés, nous devons envoyer les pixels par rangée - for (unsigned int i = 0; i < rect.height; ++i) - image->Update(&m_buffer[rect.width*4*i], Boxui(dstPos.x, rect.height - i - 1, dstPos.z, rect.width, 1, 1), rect.width); - - if (m_context != currentContext) - { - if (currentContext) - { - if (!currentContext->SetActive(true)) - NazaraWarning("Failed to reset old context"); - } - else - m_context->SetActive(false); - } - - return true; - } - - bool RenderWindow::Create(VideoMode mode, const String& title, UInt32 style, const ContextParameters& parameters) - { - m_parameters = parameters; - return Window::Create(mode, title, style); - } - - bool RenderWindow::Create(WindowHandle handle, const ContextParameters& parameters) - { - m_parameters = parameters; - return Window::Create(handle); - } - void RenderWindow::Display() { if (m_framerateLimit > 0) @@ -143,129 +26,23 @@ namespace Nz m_clock.Restart(); } - - if (m_context && m_parameters.doubleBuffered) - m_context->SwapBuffers(); } void RenderWindow::EnableVerticalSync(bool enabled) { - if (m_context) - { - if (!m_context->SetActive(true)) - { - NazaraError("Failed to activate context"); - return; - } - - m_context->EnableVerticalSync(enabled); - } - else - NazaraError("No context"); - } - - unsigned int RenderWindow::GetHeight() const - { - return Window::GetHeight(); - } - - RenderTargetParameters RenderWindow::GetParameters() const - { - if (m_context) - { - const ContextParameters& parameters = m_context->GetParameters(); - return RenderTargetParameters(parameters.antialiasingLevel, parameters.depthBits, parameters.stencilBits); - } - else - { - NazaraError("Window not created/context not initialized"); - return RenderTargetParameters(); - } - } - - unsigned int RenderWindow::GetWidth() const - { - return Window::GetWidth(); - } - - bool RenderWindow::IsRenderable() const - { - return m_impl != nullptr; // Si m_impl est valide, alors m_context l'est aussi - } - - bool RenderWindow::IsValid() const - { - return m_impl != nullptr; - } - - void RenderWindow::SetFramerateLimit(unsigned int limit) - { - m_framerateLimit = limit; - } - - ContextParameters RenderWindow::GetContextParameters() const - { - if (m_context) - return m_context->GetParameters(); - else - { - NazaraError("Window not created/context not initialized"); - return ContextParameters(); - } - } - - bool RenderWindow::HasContext() const - { - return true; - } - - bool RenderWindow::Activate() const - { - if (m_context->SetActive(true)) - { - glDrawBuffer((m_parameters.doubleBuffered) ? GL_BACK : GL_FRONT); - return true; - } - else - { - NazaraError("Failed to activate window's context"); - return false; - } - } - - void RenderWindow::EnsureTargetUpdated() const - { - // Rien à faire + ///TODO } bool RenderWindow::OnWindowCreated() { - m_parameters.doubleBuffered = true; - m_parameters.window = GetHandle(); - - std::unique_ptr context(new Context); - if (!context->Create(m_parameters)) + auto impl = Renderer::GetRendererImpl()->CreateRenderWindowImpl(); + if (!impl->Create(GetHandle(), Vector2ui(GetWidth(), GetHeight()), m_parameters)) { - NazaraError("Failed to create context"); + NazaraError("Failed to create render window implementation: " + Error::GetLastError()); return false; } - m_context = context.release(); - - if (!SetActive(true)) // Les fenêtres s'activent à la création - NazaraWarning("Failed to activate window"); - - EnableVerticalSync(false); - - Vector2ui size = GetSize(); - - // Le scissorBox/viewport (à la création) est de la taille de la fenêtre - // https://www.opengl.org/sdk/docs/man/xhtml/glGet.xml - OpenGL::SetScissorBox(Recti(0, 0, size.x, size.y)); - OpenGL::SetViewport(Recti(0, 0, size.x, size.y)); - - OnRenderTargetParametersChange(this); - OnRenderTargetSizeChange(this); + m_impl = std::move(impl); m_clock.Restart(); @@ -274,19 +51,10 @@ namespace Nz void RenderWindow::OnWindowDestroy() { - if (m_context) - { - if (IsActive()) - Renderer::SetTarget(nullptr); - - delete m_context; - m_context = nullptr; - } + m_impl.reset(); } void RenderWindow::OnWindowResized() { - OnRenderTargetSizeChange(this); } } -*/ \ No newline at end of file diff --git a/src/Nazara/Renderer/RendererWindowImpl.cpp b/src/Nazara/Renderer/RendererWindowImpl.cpp new file mode 100644 index 000000000..b1a2b946f --- /dev/null +++ b/src/Nazara/Renderer/RendererWindowImpl.cpp @@ -0,0 +1,11 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + RenderWindowImpl::~RenderWindowImpl() = default; +} diff --git a/src/Nazara/VulkanRenderer/RenderTarget.cpp b/src/Nazara/VulkanRenderer/VkRenderTarget.cpp similarity index 76% rename from src/Nazara/VulkanRenderer/RenderTarget.cpp rename to src/Nazara/VulkanRenderer/VkRenderTarget.cpp index 4c78a5321..767ee7988 100644 --- a/src/Nazara/VulkanRenderer/RenderTarget.cpp +++ b/src/Nazara/VulkanRenderer/VkRenderTarget.cpp @@ -2,12 +2,12 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include namespace Nz { - RenderTarget::~RenderTarget() + VkRenderTarget::~VkRenderTarget() { OnRenderTargetRelease(this); } diff --git a/src/Nazara/VulkanRenderer/RenderWindow.cpp b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp similarity index 79% rename from src/Nazara/VulkanRenderer/RenderWindow.cpp rename to src/Nazara/VulkanRenderer/VkRenderWindow.cpp index 1d5fbd33e..b9a215318 100644 --- a/src/Nazara/VulkanRenderer/RenderWindow.cpp +++ b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include #include #include @@ -13,35 +13,24 @@ namespace Nz { - RenderWindow::RenderWindow() : - RenderTarget(), Window(), + VkRenderWindow::VkRenderWindow() : m_surface(Nz::Vulkan::GetInstance()), - m_forcedPhysicalDevice(nullptr), + m_physicalDevice(nullptr), m_depthStencilFormat(VK_FORMAT_MAX_ENUM) { } - RenderWindow::RenderWindow(VideoMode mode, const String& title, UInt32 style) : - RenderWindow() + VkRenderWindow::~VkRenderWindow() { - ErrorFlags flags(ErrorFlag_ThrowException, true); - Create(mode, title, style); + m_device->WaitForIdle(); + m_frameBuffers.clear(); + m_renderPass.Destroy(); + + m_swapchain.Destroy(); + m_surface.Destroy(); } - RenderWindow::RenderWindow(WindowHandle handle) : - RenderWindow() - { - ErrorFlags flags(ErrorFlag_ThrowException, true); - Create(handle); - } - - RenderWindow::~RenderWindow() - { - // Nécessaire si Window::Destroy est appelé par son destructeur - OnWindowDestroy(); - } - - bool RenderWindow::Acquire(UInt32* imageIndex) const + bool VkRenderWindow::Acquire(UInt32* imageIndex) const { if (!m_swapchain.AcquireNextImage(std::numeric_limits::max(), m_imageReadySemaphore, VK_NULL_HANDLE, imageIndex)) { @@ -52,7 +41,7 @@ namespace Nz return true; } - void RenderWindow::BuildPreRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) + void VkRenderWindow::BuildPreRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) { //commandBuffer.SetImageLayout(m_swapchain.GetBuffer(imageIndex).image, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); @@ -71,83 +60,19 @@ namespace Nz } } - void RenderWindow::BuildPostRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) + void VkRenderWindow::BuildPostRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) { //commandBuffer.SetImageLayout(m_swapchain.GetBuffer(imageIndex).image, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR); } - const Vk::Framebuffer& RenderWindow::GetFrameBuffer(UInt32 imageIndex) const + bool VkRenderWindow::Create(WindowHandle handle, const Vector2ui& size, const RenderWindowParameters& parameters) { - return m_frameBuffers[imageIndex]; - } - - UInt32 RenderWindow::GetFramebufferCount() const - { - return static_cast(m_frameBuffers.size()); - } - - bool RenderWindow::Create(VideoMode mode, const String& title, UInt32 style) - { - return Window::Create(mode, title, style); - } - - bool RenderWindow::Create(WindowHandle handle) - { - return Window::Create(handle); - } - - const Vk::DeviceHandle& RenderWindow::GetDevice() const - { - return m_device; - } - - UInt32 RenderWindow::GetPresentableFamilyQueue() const - { - return m_presentableFamilyQueue; - } - - const Vk::Surface& RenderWindow::GetSurface() const - { - return m_surface; - } - - const Vk::Swapchain& RenderWindow::GetSwapchain() const - { - return m_swapchain; - } - - void RenderWindow::Present(UInt32 imageIndex) - { - NazaraAssert(imageIndex < m_frameBuffers.size(), "Invalid image index"); - - m_presentQueue.Present(m_swapchain, imageIndex); - } - - bool RenderWindow::IsValid() const - { - return m_impl != nullptr; - } - - void RenderWindow::SetDepthStencilFormats(std::vector pixelFormat) - { - m_wantedDepthStencilFormats = std::move(pixelFormat); - } - - void RenderWindow::SetPhysicalDevice(VkPhysicalDevice device) - { - m_forcedPhysicalDevice = device; - } - - bool RenderWindow::OnWindowCreated() - { - OnRenderTargetSizeChange(this); - #if defined(NAZARA_PLATFORM_WINDOWS) - HWND handle = reinterpret_cast(GetHandle()); - HINSTANCE instance = reinterpret_cast(GetWindowLongPtrW(handle, GWLP_HINSTANCE)); - bool success = m_surface.Create(instance, handle); + HWND winHandle = reinterpret_cast(handle); + HINSTANCE instance = reinterpret_cast(GetWindowLongPtrW(winHandle, GWLP_HINSTANCE)); + bool success = m_surface.Create(instance, winHandle); #else - #error This OS is not supported by Vulkan + #error This OS is not supported by Vulkan #endif if (!success) @@ -156,7 +81,9 @@ namespace Nz return false; } - m_device = Vulkan::SelectDevice(m_forcedPhysicalDevice, m_surface, &m_presentableFamilyQueue); + m_physicalDevice = Vulkan::GetPhysicalDevices()[0].device; + + m_device = Vulkan::SelectDevice(m_physicalDevice, m_surface, &m_presentableFamilyQueue); if (!m_device) { NazaraError("Failed to get compatible Vulkan device"); @@ -166,7 +93,7 @@ namespace Nz m_presentQueue = m_device->GetQueue(m_presentableFamilyQueue, 0); std::vector surfaceFormats; - if (!m_surface.GetFormats(m_forcedPhysicalDevice, &surfaceFormats)) + if (!m_surface.GetFormats(m_physicalDevice, &surfaceFormats)) { NazaraError("Failed to query supported surface formats"); return false; @@ -179,11 +106,11 @@ namespace Nz m_colorSpace = surfaceFormats[0].colorSpace; - if (!m_wantedDepthStencilFormats.empty()) + if (!parameters.depthFormats.empty()) { - const Vk::PhysicalDevice& deviceInfo = Vulkan::GetPhysicalDeviceInfo(m_forcedPhysicalDevice); + const Vk::PhysicalDevice& deviceInfo = Vulkan::GetPhysicalDeviceInfo(m_physicalDevice); - for (PixelFormatType format : m_wantedDepthStencilFormats) + for (PixelFormatType format : parameters.depthFormats) { switch (format) { @@ -223,7 +150,7 @@ namespace Nz if (m_depthStencilFormat != VK_FORMAT_MAX_ENUM) { - VkFormatProperties formatProperties = m_device->GetInstance().GetPhysicalDeviceFormatProperties(m_forcedPhysicalDevice, m_depthStencilFormat); + VkFormatProperties formatProperties = m_device->GetInstance().GetPhysicalDeviceFormatProperties(m_physicalDevice, m_depthStencilFormat); if (formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) break; //< Found it @@ -232,19 +159,19 @@ namespace Nz } } - if (!SetupSwapchain()) + if (!SetupSwapchain(size)) { NazaraError("Failed to create swapchain"); return false; } - if (m_depthStencilFormat != VK_FORMAT_MAX_ENUM && !SetupDepthBuffer()) + if (m_depthStencilFormat != VK_FORMAT_MAX_ENUM && !SetupDepthBuffer(size)) { NazaraError("Failed to create depth buffer"); return false; } - if (!SetupRenderPass()) + if (!SetupRenderPass(size)) { NazaraError("Failed to create render pass"); return false; @@ -265,8 +192,8 @@ namespace Nz m_renderPass, // VkRenderPass renderPass; (attachments[1] != VK_NULL_HANDLE) ? 2U : 1U, // uint32_t attachmentCount; attachments.data(), // const VkImageView* pAttachments; - GetWidth(), // uint32_t width; - GetHeight(), // uint32_t height; + size.x, // uint32_t width; + size.y, // uint32_t height; 1U // uint32_t layers; }; @@ -284,22 +211,7 @@ namespace Nz return true; } - void RenderWindow::OnWindowDestroy() - { - m_device->WaitForIdle(); - m_frameBuffers.clear(); - m_renderPass.Destroy(); - - m_swapchain.Destroy(); - m_surface.Destroy(); - } - - void RenderWindow::OnWindowResized() - { - OnRenderTargetSizeChange(this); - } - - bool RenderWindow::SetupDepthBuffer() + bool VkRenderWindow::SetupDepthBuffer(const Vector2ui& size) { VkImageCreateInfo imageCreateInfo = { VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType; @@ -307,7 +219,7 @@ namespace Nz 0U, // VkImageCreateFlags flags; VK_IMAGE_TYPE_2D, // VkImageType imageType; m_depthStencilFormat, // VkFormat format; - {GetWidth(), GetHeight(), 1U}, // VkExtent3D extent; + {size.x, size.y, 1U}, // VkExtent3D extent; 1U, // uint32_t mipLevels; 1U, // uint32_t arrayLayers; VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples; @@ -369,7 +281,7 @@ namespace Nz return true; } - bool RenderWindow::SetupRenderPass() + bool VkRenderWindow::SetupRenderPass(const Vector2ui& size) { std::array attachments = { { @@ -424,8 +336,8 @@ namespace Nz std::array dependencies; // First dependency at the start of the renderpass // Does the transition from final to initial layout - dependencies[0].srcSubpass = VK_SUBPASS_EXTERNAL; // Producer of the dependency - dependencies[0].dstSubpass = 0; // Consumer is our single subpass that will wait for the execution depdendency + dependencies[0].srcSubpass = VK_SUBPASS_EXTERNAL; // Producer of the dependency + dependencies[0].dstSubpass = 0; // Consumer is our single subpass that will wait for the execution depdendency dependencies[0].srcStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT; dependencies[0].dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; dependencies[0].srcAccessMask = VK_ACCESS_MEMORY_READ_BIT; @@ -434,8 +346,8 @@ namespace Nz // Second dependency at the end the renderpass // Does the transition from the initial to the final layout - dependencies[1].srcSubpass = 0; // Producer of the dependency is our single subpass - dependencies[1].dstSubpass = VK_SUBPASS_EXTERNAL; // Consumer are all commands outside of the renderpass + dependencies[1].srcSubpass = 0; // Producer of the dependency is our single subpass + dependencies[1].dstSubpass = VK_SUBPASS_EXTERNAL; // Consumer are all commands outside of the renderpass dependencies[1].srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; dependencies[1].dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT; dependencies[1].srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; @@ -450,17 +362,17 @@ namespace Nz attachments.data(), // const VkAttachmentDescription* pAttachments; 1U, // uint32_t subpassCount; &subpass, // const VkSubpassDescription* pSubpasses; - dependencies.size(), // uint32_t dependencyCount; - dependencies.data() // const VkSubpassDependency* pDependencies; + UInt32(dependencies.size()), // uint32_t dependencyCount; + dependencies.data() // const VkSubpassDependency* pDependencies; }; return m_renderPass.Create(m_device, createInfo); } - bool RenderWindow::SetupSwapchain() + bool VkRenderWindow::SetupSwapchain(const Vector2ui& size) { VkSurfaceCapabilitiesKHR surfaceCapabilities; - if (!m_surface.GetCapabilities(m_forcedPhysicalDevice, &surfaceCapabilities)) + if (!m_surface.GetCapabilities(m_physicalDevice, &surfaceCapabilities)) { NazaraError("Failed to query surface capabilities"); return false; @@ -473,14 +385,14 @@ namespace Nz VkExtent2D extent; if (surfaceCapabilities.currentExtent.width == -1) { - extent.width = Nz::Clamp(GetWidth(), surfaceCapabilities.minImageExtent.width, surfaceCapabilities.maxImageExtent.width); - extent.height = Nz::Clamp(GetHeight(), surfaceCapabilities.minImageExtent.height, surfaceCapabilities.maxImageExtent.height); + extent.width = Nz::Clamp(size.x, surfaceCapabilities.minImageExtent.width, surfaceCapabilities.maxImageExtent.width); + extent.height = Nz::Clamp(size.y, surfaceCapabilities.minImageExtent.height, surfaceCapabilities.maxImageExtent.height); } else extent = surfaceCapabilities.currentExtent; std::vector presentModes; - if (!m_surface.GetPresentModes(m_forcedPhysicalDevice, &presentModes)) + if (!m_surface.GetPresentModes(m_physicalDevice, &presentModes)) { NazaraError("Failed to query supported present modes"); return false; diff --git a/src/Nazara/VulkanRenderer/VulkanRenderer.cpp b/src/Nazara/VulkanRenderer/VulkanRenderer.cpp index 6d6f4d055..2b838f189 100644 --- a/src/Nazara/VulkanRenderer/VulkanRenderer.cpp +++ b/src/Nazara/VulkanRenderer/VulkanRenderer.cpp @@ -4,10 +4,16 @@ #include #include +#include #include namespace Nz { + std::unique_ptr VulkanRenderer::CreateRenderWindowImpl() + { + return std::make_unique(); + } + bool VulkanRenderer::IsBetterThan(const RendererImpl* other) const { if (other->QueryAPI() == RenderAPI_Vulkan && QueryAPIVersion() < other->QueryAPIVersion()) From 2c80b046912fae02acda02549675fd3b551f30b9 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 15 Sep 2016 00:44:40 +0200 Subject: [PATCH 051/316] VulkanRenderer/DeviceMemory: Fix linking error Former-commit-id: 849e76f479aaf77646ae786584ac896838cc2f63 [formerly fcbd8bd667d6cfac01e01241bea06c43d34a1ad0] [formerly e042ac243512c07e9870213ec7d5a0e9ff7a4ba2 [formerly 378029f40ef5dee44eb29a73e3d39639bd91cee6]] Former-commit-id: c284ca126ded4435adbe15ca2a3e619fa2e09e1a [formerly 69da980659df0005066ef6b21a181359d28b184b] Former-commit-id: a989d3a678fd4c0ce1c23f54c5f3fda5fb175e2e --- include/Nazara/VulkanRenderer/VkDeviceMemory.hpp | 2 +- include/Nazara/VulkanRenderer/VkDeviceMemory.inl | 2 +- include/Nazara/VulkanRenderer/VkDeviceObject.hpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/Nazara/VulkanRenderer/VkDeviceMemory.hpp b/include/Nazara/VulkanRenderer/VkDeviceMemory.hpp index c2a5b72c5..7e6755dba 100644 --- a/include/Nazara/VulkanRenderer/VkDeviceMemory.hpp +++ b/include/Nazara/VulkanRenderer/VkDeviceMemory.hpp @@ -21,7 +21,7 @@ namespace Nz public: DeviceMemory(); DeviceMemory(const DeviceMemory&) = delete; - DeviceMemory(DeviceMemory&& memory); + inline DeviceMemory(DeviceMemory&& memory); ~DeviceMemory() = default; using DeviceObject::Create; diff --git a/include/Nazara/VulkanRenderer/VkDeviceMemory.inl b/include/Nazara/VulkanRenderer/VkDeviceMemory.inl index 2e0c26b30..19ed76ccd 100644 --- a/include/Nazara/VulkanRenderer/VkDeviceMemory.inl +++ b/include/Nazara/VulkanRenderer/VkDeviceMemory.inl @@ -16,7 +16,7 @@ namespace Nz { } - DeviceMemory::DeviceMemory(DeviceMemory&& memory) : + inline DeviceMemory::DeviceMemory(DeviceMemory&& memory) : DeviceObject(std::move(memory)) { m_mappedPtr = memory.m_mappedPtr; diff --git a/include/Nazara/VulkanRenderer/VkDeviceObject.hpp b/include/Nazara/VulkanRenderer/VkDeviceObject.hpp index 3778a73ea..5a61bf2ee 100644 --- a/include/Nazara/VulkanRenderer/VkDeviceObject.hpp +++ b/include/Nazara/VulkanRenderer/VkDeviceObject.hpp @@ -21,7 +21,7 @@ namespace Nz public: inline DeviceObject(); DeviceObject(const DeviceObject&) = delete; - DeviceObject(DeviceObject&&); + inline DeviceObject(DeviceObject&& object); inline ~DeviceObject(); inline bool Create(const DeviceHandle& device, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); From 01a812a5de1ed0b693b08ff403949fa3d07325da Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 12 Oct 2016 15:08:02 +0200 Subject: [PATCH 053/316] Vulkan: Improve error handling --- include/Nazara/VulkanRenderer/Utils.hpp | 19 ++++ .../Nazara/VulkanRenderer/VkCommandBuffer.inl | 4 +- include/Nazara/VulkanRenderer/VkDevice.inl | 3 +- .../Nazara/VulkanRenderer/VkDeviceMemory.inl | 3 +- .../Nazara/VulkanRenderer/VkDeviceObject.inl | 7 +- include/Nazara/VulkanRenderer/VkImage.inl | 3 +- include/Nazara/VulkanRenderer/VkInstance.inl | 3 +- include/Nazara/VulkanRenderer/VkPipeline.inl | 3 +- include/Nazara/VulkanRenderer/VkQueue.inl | 10 ++ include/Nazara/VulkanRenderer/VkSurface.inl | 13 +-- include/Nazara/VulkanRenderer/VkSwapchain.inl | 8 +- .../VulkanRenderer/Utils_VulkanRenderer.cpp | 97 +++++++++++++++++++ src/Nazara/VulkanRenderer/VkInstance.cpp | 5 +- src/Nazara/VulkanRenderer/VkLoader.cpp | 9 +- 14 files changed, 163 insertions(+), 24 deletions(-) create mode 100644 include/Nazara/VulkanRenderer/Utils.hpp create mode 100644 src/Nazara/VulkanRenderer/Utils_VulkanRenderer.cpp diff --git a/include/Nazara/VulkanRenderer/Utils.hpp b/include/Nazara/VulkanRenderer/Utils.hpp new file mode 100644 index 000000000..eb195b16c --- /dev/null +++ b/include/Nazara/VulkanRenderer/Utils.hpp @@ -0,0 +1,19 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_UTILS_VULKAN_HPP +#define NAZARA_UTILS_VULKAN_HPP + +#include +#include +#include + +namespace Nz +{ + NAZARA_VULKANRENDERER_API String TranslateVulkanError(VkResult code); +} + +#endif // NAZARA_UTILS_VULKAN_HPP diff --git a/include/Nazara/VulkanRenderer/VkCommandBuffer.inl b/include/Nazara/VulkanRenderer/VkCommandBuffer.inl index 1e425f114..7721a7a74 100644 --- a/include/Nazara/VulkanRenderer/VkCommandBuffer.inl +++ b/include/Nazara/VulkanRenderer/VkCommandBuffer.inl @@ -42,7 +42,7 @@ namespace Nz m_lastErrorCode = m_pool->GetDevice()->vkBeginCommandBuffer(m_handle, &info); if (m_lastErrorCode != VkResult::VK_SUCCESS) { - NazaraError("Failed to begin command buffer"); + NazaraError("Failed to begin command buffer: " + TranslateVulkanError(m_lastErrorCode)); return false; } @@ -208,7 +208,7 @@ namespace Nz m_lastErrorCode = m_pool->GetDevice()->vkEndCommandBuffer(m_handle); if (m_lastErrorCode != VkResult::VK_SUCCESS) { - NazaraError("Failed to end command buffer"); + NazaraError("Failed to end command buffer: " + TranslateVulkanError(m_lastErrorCode)); return false; } diff --git a/include/Nazara/VulkanRenderer/VkDevice.inl b/include/Nazara/VulkanRenderer/VkDevice.inl index f18fde6a7..b5574958b 100644 --- a/include/Nazara/VulkanRenderer/VkDevice.inl +++ b/include/Nazara/VulkanRenderer/VkDevice.inl @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -91,7 +92,7 @@ namespace Nz m_lastErrorCode = vkDeviceWaitIdle(m_device); if (m_lastErrorCode != VkResult::VK_SUCCESS) { - NazaraError("Failed to wait for device idle"); + NazaraError("Failed to wait for device idle: " + TranslateVulkanError(m_lastErrorCode)); return false; } diff --git a/include/Nazara/VulkanRenderer/VkDeviceMemory.inl b/include/Nazara/VulkanRenderer/VkDeviceMemory.inl index 19ed76ccd..2b66fc1c5 100644 --- a/include/Nazara/VulkanRenderer/VkDeviceMemory.inl +++ b/include/Nazara/VulkanRenderer/VkDeviceMemory.inl @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -66,7 +67,7 @@ namespace Nz m_lastErrorCode = m_device->vkMapMemory(*m_device, m_handle, offset, size, flags, &m_mappedPtr); if (m_lastErrorCode != VK_SUCCESS) { - NazaraError("Failed to map device memory"); + NazaraError("Failed to map device memory: " + TranslateVulkanError(m_lastErrorCode)); return false; } diff --git a/include/Nazara/VulkanRenderer/VkDeviceObject.inl b/include/Nazara/VulkanRenderer/VkDeviceObject.inl index f238d199a..f46cfd256 100644 --- a/include/Nazara/VulkanRenderer/VkDeviceObject.inl +++ b/include/Nazara/VulkanRenderer/VkDeviceObject.inl @@ -2,8 +2,10 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include +#include +#include #include #include @@ -40,7 +42,7 @@ namespace Nz m_lastErrorCode = C::CreateHelper(m_device, &createInfo, allocator, &m_handle); if (m_lastErrorCode != VkResult::VK_SUCCESS) { - NazaraError("Failed to create Vulkan object"); + NazaraError("Failed to create Vulkan object: " + TranslateVulkanError(m_lastErrorCode)); return false; } @@ -90,4 +92,3 @@ namespace Nz } #include -#include "VkDeviceObject.hpp" diff --git a/include/Nazara/VulkanRenderer/VkImage.inl b/include/Nazara/VulkanRenderer/VkImage.inl index b4e0332cb..e7a675f26 100644 --- a/include/Nazara/VulkanRenderer/VkImage.inl +++ b/include/Nazara/VulkanRenderer/VkImage.inl @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include namespace Nz @@ -14,7 +15,7 @@ namespace Nz m_lastErrorCode = m_device->vkBindImageMemory(*m_device, m_handle, memory, offset); if (m_lastErrorCode != VK_SUCCESS) { - NazaraError("Failed to bind buffer memory"); + NazaraError("Failed to bind image memory: " + TranslateVulkanError(m_lastErrorCode)); return false; } diff --git a/include/Nazara/VulkanRenderer/VkInstance.inl b/include/Nazara/VulkanRenderer/VkInstance.inl index 6de0929e9..5a842031b 100644 --- a/include/Nazara/VulkanRenderer/VkInstance.inl +++ b/include/Nazara/VulkanRenderer/VkInstance.inl @@ -4,6 +4,7 @@ #include #include +#include #include namespace Nz @@ -106,7 +107,7 @@ namespace Nz 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"); + NazaraError("Failed to get physical device image format properties: " + TranslateVulkanError(m_lastErrorCode)); return false; } diff --git a/include/Nazara/VulkanRenderer/VkPipeline.inl b/include/Nazara/VulkanRenderer/VkPipeline.inl index 42c758f46..936a003a7 100644 --- a/include/Nazara/VulkanRenderer/VkPipeline.inl +++ b/include/Nazara/VulkanRenderer/VkPipeline.inl @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include namespace Nz @@ -68,7 +69,7 @@ namespace Nz m_lastErrorCode = result; if (m_lastErrorCode != VkResult::VK_SUCCESS) { - NazaraError("Failed to create Vulkan object"); + NazaraError("Failed to create Vulkan object: " + TranslateVulkanError(m_lastErrorCode)); return false; } diff --git a/include/Nazara/VulkanRenderer/VkQueue.inl b/include/Nazara/VulkanRenderer/VkQueue.inl index 62b0c7984..c1d06ec4e 100644 --- a/include/Nazara/VulkanRenderer/VkQueue.inl +++ b/include/Nazara/VulkanRenderer/VkQueue.inl @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -51,7 +52,10 @@ namespace Nz { m_lastErrorCode = m_device->vkQueuePresentKHR(m_handle, &presentInfo); if (m_lastErrorCode != VkResult::VK_SUCCESS) + { + NazaraError("Failed to present queue: " + TranslateVulkanError(m_lastErrorCode)); return false; + } return true; } @@ -82,7 +86,10 @@ namespace Nz { m_lastErrorCode = m_device->vkQueueSubmit(m_handle, submitCount, submits, fence); if (m_lastErrorCode != VkResult::VK_SUCCESS) + { + NazaraError("Failed to submit queue: " + TranslateVulkanError(m_lastErrorCode)); return false; + } return true; } @@ -91,7 +98,10 @@ namespace Nz { m_lastErrorCode = m_device->vkQueueWaitIdle(m_handle); if (m_lastErrorCode != VkResult::VK_SUCCESS) + { + NazaraError("Failed to wait for queue: " + TranslateVulkanError(m_lastErrorCode)); return false; + } return true; } diff --git a/include/Nazara/VulkanRenderer/VkSurface.inl b/include/Nazara/VulkanRenderer/VkSurface.inl index efec9a34c..8b5ea7369 100644 --- a/include/Nazara/VulkanRenderer/VkSurface.inl +++ b/include/Nazara/VulkanRenderer/VkSurface.inl @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -181,7 +182,7 @@ namespace Nz m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice, m_surface, surfaceCapabilities); if (m_lastErrorCode != VkResult::VK_SUCCESS) { - NazaraError("Failed to query surface capabilities"); + NazaraError("Failed to query surface capabilities: " + TranslateVulkanError(m_lastErrorCode)); return false; } @@ -195,7 +196,7 @@ namespace Nz m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, m_surface, &surfaceCount, nullptr); if (m_lastErrorCode != VkResult::VK_SUCCESS || surfaceCount == 0) { - NazaraError("Failed to query format count"); + NazaraError("Failed to query format count: " + TranslateVulkanError(m_lastErrorCode)); return false; } @@ -204,7 +205,7 @@ namespace Nz m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, m_surface, &surfaceCount, surfaceFormats->data()); if (m_lastErrorCode != VkResult::VK_SUCCESS) { - NazaraError("Failed to query formats"); + NazaraError("Failed to query formats: " + TranslateVulkanError(m_lastErrorCode)); return false; } @@ -227,7 +228,7 @@ namespace Nz m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, m_surface, &presentModeCount, presentModes->data()); if (m_lastErrorCode != VkResult::VK_SUCCESS) { - NazaraError("Failed to query present modes"); + NazaraError("Failed to query present modes: " + TranslateVulkanError(m_lastErrorCode)); return false; } @@ -240,7 +241,7 @@ namespace Nz m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfaceSupportKHR(physicalDevice, queueFamilyIndex, m_surface, &presentationSupported); if (m_lastErrorCode != VkResult::VK_SUCCESS) { - NazaraError("Failed to query surface capabilities"); + NazaraError("Failed to query surface capabilities: " + TranslateVulkanError(m_lastErrorCode)); return false; } @@ -296,7 +297,7 @@ namespace Nz { if (m_lastErrorCode != VkResult::VK_SUCCESS) { - NazaraError("Failed to create Vulkan surface"); + NazaraError("Failed to create Vulkan surface: " + TranslateVulkanError(m_lastErrorCode)); return false; } diff --git a/include/Nazara/VulkanRenderer/VkSwapchain.inl b/include/Nazara/VulkanRenderer/VkSwapchain.inl index a8e0ead36..363807859 100644 --- a/include/Nazara/VulkanRenderer/VkSwapchain.inl +++ b/include/Nazara/VulkanRenderer/VkSwapchain.inl @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -21,7 +22,10 @@ namespace Nz return true; default: + { + NazaraError("Failed to acquire next swapchain image: " + TranslateVulkanError(m_lastErrorCode)); return false; + } } } @@ -34,7 +38,7 @@ namespace Nz 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"); + NazaraError("Failed to query swapchain image count: " + TranslateVulkanError(m_lastErrorCode)); return false; } @@ -42,7 +46,7 @@ namespace Nz m_lastErrorCode = m_device->vkGetSwapchainImagesKHR(*m_device, m_handle, &imageCount, images.data()); if (m_lastErrorCode != VkResult::VK_SUCCESS) { - NazaraError("Failed to query swapchain images"); + NazaraError("Failed to query swapchain images: " + TranslateVulkanError(m_lastErrorCode)); return false; } diff --git a/src/Nazara/VulkanRenderer/Utils_VulkanRenderer.cpp b/src/Nazara/VulkanRenderer/Utils_VulkanRenderer.cpp new file mode 100644 index 000000000..9d81fb4e5 --- /dev/null +++ b/src/Nazara/VulkanRenderer/Utils_VulkanRenderer.cpp @@ -0,0 +1,97 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + String TranslateVulkanError(VkResult code) + { + // From https://www.khronos.org/registry/vulkan/specs/1.0-wsi_extensions/xhtml/vkspec.html#VkResult + switch (code) + { + case VK_SUCCESS: + return "No error"; + + case VK_NOT_READY: + return "A fence or query has not yet completed"; + + case VK_TIMEOUT: + return "A wait operation has not completed in the specified time"; + + case VK_EVENT_SET: + return "An event is signaled"; + + case VK_EVENT_RESET: + return "An event is unsignaled"; + + case VK_INCOMPLETE: + return "A return array was too small for the result"; + + case VK_ERROR_OUT_OF_HOST_MEMORY: + return "A host memory allocation has failed"; + + case VK_ERROR_OUT_OF_DEVICE_MEMORY: + return "A device memory allocation has failed"; + + case VK_ERROR_INITIALIZATION_FAILED: + return "Initialization of an object could not be completed for implementation-specific reasons"; + + case VK_ERROR_DEVICE_LOST: + return "The logical or physical device has been lost"; + + case VK_ERROR_MEMORY_MAP_FAILED: + return "Mapping of the memory object has failed"; + + case VK_ERROR_LAYER_NOT_PRESENT: + return "A requested layer is not present or could not be loaded"; + + case VK_ERROR_EXTENSION_NOT_PRESENT: + return "A requested extension is not supported"; + + case VK_ERROR_FEATURE_NOT_PRESENT: + return "A requested feature is not supported"; + + case VK_ERROR_INCOMPATIBLE_DRIVER: + return "The requested version of Vulkan is not supported by the driver or is otherwise incompatible for implementation-specific reasons"; + + case VK_ERROR_TOO_MANY_OBJECTS: + return "Too many objects of the type have already been created"; + + case VK_ERROR_FORMAT_NOT_SUPPORTED: + return "A requested format is not supported on this device"; + + case VK_ERROR_FRAGMENTED_POOL: + return "A requested pool allocation has failed due to fragmentation of the pool’s memory"; + + case VK_ERROR_SURFACE_LOST_KHR: + return "A surface is no longer available"; + + case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR: + return "The requested window is already connected to a VkSurfaceKHR, or to some other non-Vulkan API"; + + case VK_SUBOPTIMAL_KHR: + return "A swapchain no longer matches the surface properties exactly, but can still be used to present to the surface successfully"; + + case VK_ERROR_OUT_OF_DATE_KHR: + return "A surface has changed in such a way that it is no longer compatible with the swapchain, and further presentation requests using the swapchain will fail. Applications must query the new surface properties and recreate their swapchain if they wish to continue presenting to the surface"; + + case VK_ERROR_INCOMPATIBLE_DISPLAY_KHR: + return "The display used by a swapchain does not use the same presentable image layout, or is incompatible in a way that prevents sharing an image"; + + case VK_ERROR_VALIDATION_FAILED_EXT: + return "A validation layer found an error"; + + case VK_ERROR_INVALID_SHADER_NV: + return "One or more shaders failed to compile or link"; + + default: + break; + } + + return "Unknown Vulkan error (0x" + String::Number(code, 16) + ')'; + } +} + diff --git a/src/Nazara/VulkanRenderer/VkInstance.cpp b/src/Nazara/VulkanRenderer/VkInstance.cpp index 411b8fa68..7daced8f1 100644 --- a/src/Nazara/VulkanRenderer/VkInstance.cpp +++ b/src/Nazara/VulkanRenderer/VkInstance.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include namespace Nz @@ -153,7 +154,7 @@ namespace Nz m_lastErrorCode = vkEnumeratePhysicalDevices(m_instance, &deviceCount, nullptr); if (m_lastErrorCode != VkResult::VK_SUCCESS || deviceCount == 0) { - NazaraError("Failed to query physical device count"); + NazaraError("Failed to query physical device count: " + TranslateVulkanError(m_lastErrorCode)); return false; } @@ -162,7 +163,7 @@ namespace Nz m_lastErrorCode = vkEnumeratePhysicalDevices(m_instance, &deviceCount, devices->data()); if (m_lastErrorCode != VkResult::VK_SUCCESS) { - NazaraError("Failed to query physical devices"); + NazaraError("Failed to query physical devices: " + TranslateVulkanError(m_lastErrorCode)); return false; } diff --git a/src/Nazara/VulkanRenderer/VkLoader.cpp b/src/Nazara/VulkanRenderer/VkLoader.cpp index 0da9a930a..8bc2bd05b 100644 --- a/src/Nazara/VulkanRenderer/VkLoader.cpp +++ b/src/Nazara/VulkanRenderer/VkLoader.cpp @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include namespace Nz @@ -18,7 +19,7 @@ namespace Nz s_lastErrorCode = vkEnumerateInstanceExtensionProperties(layerName, &propertyCount, properties->data()); if (s_lastErrorCode != VkResult::VK_SUCCESS) { - NazaraError("Failed to get instance extension properties count"); + NazaraError("Failed to get instance extension properties count: " + TranslateVulkanError(s_lastErrorCode)); return false; } @@ -27,7 +28,7 @@ namespace Nz s_lastErrorCode = vkEnumerateInstanceExtensionProperties(layerName, &propertyCount, properties->data()); if (s_lastErrorCode != VkResult::VK_SUCCESS) { - NazaraError("Failed to enumerate instance extension properties"); + NazaraError("Failed to enumerate instance extension properties: " + TranslateVulkanError(s_lastErrorCode)); return false; } @@ -43,7 +44,7 @@ namespace Nz s_lastErrorCode = vkEnumerateInstanceLayerProperties(&propertyCount, properties->data()); if (s_lastErrorCode != VkResult::VK_SUCCESS) { - NazaraError("Failed to get instance layer properties count"); + NazaraError("Failed to get instance layer properties count: " + TranslateVulkanError(s_lastErrorCode)); return false; } @@ -52,7 +53,7 @@ namespace Nz s_lastErrorCode = vkEnumerateInstanceLayerProperties(&propertyCount, properties->data()); if (s_lastErrorCode != VkResult::VK_SUCCESS) { - NazaraError("Failed to enumerate instance layer properties"); + NazaraError("Failed to enumerate instance layer properties: " + TranslateVulkanError(s_lastErrorCode)); return false; } From 5eefbdeb60a10677ea442385bdd906fff52c0d70 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 28 Oct 2016 22:18:41 +0200 Subject: [PATCH 054/316] Vulkan/VkInstance: Add IsValid() method --- include/Nazara/VulkanRenderer/VkInstance.hpp | 1 + include/Nazara/VulkanRenderer/VkInstance.inl | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/Nazara/VulkanRenderer/VkInstance.hpp b/include/Nazara/VulkanRenderer/VkInstance.hpp index 0e9f52f87..03e52e86a 100644 --- a/include/Nazara/VulkanRenderer/VkInstance.hpp +++ b/include/Nazara/VulkanRenderer/VkInstance.hpp @@ -45,6 +45,7 @@ namespace Nz inline bool IsExtensionLoaded(const String& extensionName); inline bool IsLayerLoaded(const String& layerName); + inline bool IsValid() const; Instance& operator=(const Instance&) = delete; Instance& operator=(Instance&&) = delete; diff --git a/include/Nazara/VulkanRenderer/VkInstance.inl b/include/Nazara/VulkanRenderer/VkInstance.inl index 5a842031b..db3a485af 100644 --- a/include/Nazara/VulkanRenderer/VkInstance.inl +++ b/include/Nazara/VulkanRenderer/VkInstance.inl @@ -81,6 +81,11 @@ namespace Nz return m_loadedLayers.count(layerName) > 0; } + inline bool Instance::IsValid() const + { + return m_instance != nullptr; + } + inline Instance::operator VkInstance() { return m_instance; From a1352b88233776b32c9d6f29350e65390a62b3a0 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 28 Oct 2016 22:30:22 +0200 Subject: [PATCH 055/316] VulkanRenderer: Move all the initialization back to the Vulkan static class --- include/Nazara/VulkanRenderer/Vulkan.hpp | 5 +- .../Nazara/VulkanRenderer/VulkanRenderer.hpp | 12 +- .../Nazara/VulkanRenderer/VulkanRenderer.inl | 12 ++ src/Nazara/VulkanRenderer/Vulkan.cpp | 85 +++------ src/Nazara/VulkanRenderer/VulkanRenderer.cpp | 178 +----------------- 5 files changed, 53 insertions(+), 239 deletions(-) create mode 100644 include/Nazara/VulkanRenderer/VulkanRenderer.inl diff --git a/include/Nazara/VulkanRenderer/Vulkan.hpp b/include/Nazara/VulkanRenderer/Vulkan.hpp index 619774e0f..bd0e38560 100644 --- a/include/Nazara/VulkanRenderer/Vulkan.hpp +++ b/include/Nazara/VulkanRenderer/Vulkan.hpp @@ -33,14 +33,12 @@ namespace Nz static const std::vector& GetPhysicalDevices(); static const Vk::PhysicalDevice& GetPhysicalDeviceInfo(VkPhysicalDevice physDevice); - static bool Initialize(); + static bool Initialize(UInt32 apiVersion, const ParameterList& parameters); static bool IsInitialized(); static Vk::DeviceHandle SelectDevice(VkPhysicalDevice gpu, const Vk::Surface& surface, UInt32* presentableFamilyQueue); - static void SetParameters(const ParameterList& parameters); - static void Uninitialize(); private: @@ -48,7 +46,6 @@ namespace Nz static std::vector s_physDevices; static Vk::Instance s_instance; static ParameterList s_initializationParameters; - static unsigned int s_moduleReferenceCounter; }; } diff --git a/include/Nazara/VulkanRenderer/VulkanRenderer.hpp b/include/Nazara/VulkanRenderer/VulkanRenderer.hpp index 8fc88ca4c..aeb3d19e6 100644 --- a/include/Nazara/VulkanRenderer/VulkanRenderer.hpp +++ b/include/Nazara/VulkanRenderer/VulkanRenderer.hpp @@ -10,8 +10,12 @@ #include #include #include +#include #include #include +#include +#include +#include namespace Nz { @@ -19,7 +23,7 @@ namespace Nz { public: VulkanRenderer() = default; - ~VulkanRenderer() = default; + ~VulkanRenderer(); std::unique_ptr CreateRenderWindowImpl() override; @@ -35,10 +39,14 @@ namespace Nz static constexpr UInt32 APIVersion = VK_API_VERSION_1_0; private: - Vk::Instance m_instance; + std::list m_devices; std::vector m_physDevices; + ParameterList m_initializationParameters; + Vk::Instance m_instance; UInt32 m_apiVersion; }; } +#include + #endif // NAZARA_VULKANRENDERER_HPP diff --git a/include/Nazara/VulkanRenderer/VulkanRenderer.inl b/include/Nazara/VulkanRenderer/VulkanRenderer.inl new file mode 100644 index 000000000..000661426 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanRenderer.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ +} + +#include diff --git a/src/Nazara/VulkanRenderer/Vulkan.cpp b/src/Nazara/VulkanRenderer/Vulkan.cpp index f80c3ec9a..0827bc030 100644 --- a/src/Nazara/VulkanRenderer/Vulkan.cpp +++ b/src/Nazara/VulkanRenderer/Vulkan.cpp @@ -39,24 +39,9 @@ namespace Nz return dummy; } - bool Vulkan::Initialize() + bool Vulkan::Initialize(UInt32 apiVersion, const ParameterList& parameters) { - 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); + NazaraAssert(!s_instance.IsValid(), "Vulkan is already initialized"); // Initialize module here if (!Vk::Loader::Initialize()) @@ -65,25 +50,27 @@ namespace Nz return false; } + CallOnExit onExit(Vulkan::Uninitialize); + String appName = "Another application made with Nazara Engine"; String engineName = "Nazara Engine - Vulkan Renderer"; - UInt32 apiVersion = VK_MAKE_VERSION(1, 0, 8); + UInt32 appVersion = VK_MAKE_VERSION(1, 0, 0); UInt32 engineVersion = VK_MAKE_VERSION(1, 0, 0); - s_initializationParameters.GetStringParameter("VkAppInfo_OverrideApplicationName", &appName); - s_initializationParameters.GetStringParameter("VkAppInfo_OverrideEngineName", &engineName); + parameters.GetStringParameter("VkAppInfo_OverrideApplicationName", &appName); + parameters.GetStringParameter("VkAppInfo_OverrideEngineName", &engineName); bool bParam; int iParam; - if (s_initializationParameters.GetIntegerParameter("VkAppInfo_OverrideAPIVersion", &iParam)) + if (parameters.GetIntegerParameter("VkAppInfo_OverrideAPIVersion", &iParam)) apiVersion = iParam; - if (s_initializationParameters.GetIntegerParameter("VkAppInfo_OverrideApplicationVersion", &iParam)) + if (parameters.GetIntegerParameter("VkAppInfo_OverrideApplicationVersion", &iParam)) appVersion = iParam; - if (s_initializationParameters.GetIntegerParameter("VkAppInfo_OverrideEngineVersion", &iParam)) + if (parameters.GetIntegerParameter("VkAppInfo_OverrideEngineVersion", &iParam)) engineVersion = iParam; VkApplicationInfo appInfo = { @@ -98,26 +85,26 @@ namespace Nz VkInstanceCreateFlags createFlags = 0; - if (s_initializationParameters.GetIntegerParameter("VkInstanceInfo_OverrideCreateFlags", &iParam)) + if (parameters.GetIntegerParameter("VkInstanceInfo_OverrideCreateFlags", &iParam)) createFlags = static_cast(iParam); std::vector enabledLayers; std::vector enabledExtensions; - if (!s_initializationParameters.GetBooleanParameter("VkInstanceInfo_OverrideEnabledLayers", &bParam) || !bParam) + if (!parameters.GetBooleanParameter("VkInstanceInfo_OverrideEnabledLayers", &bParam) || !bParam) { //< Nazara default layers goes here } std::vector additionalLayers; // Just to keep the String alive - if (s_initializationParameters.GetIntegerParameter("VkInstanceInfo_EnabledLayerCount", &iParam)) + if (parameters.GetIntegerParameter("VkInstanceInfo_EnabledLayerCount", &iParam)) { additionalLayers.reserve(iParam); for (int i = 0; i < iParam; ++i) { Nz::String parameterName = "VkInstanceInfo_EnabledLayer" + String::Number(i); Nz::String layer; - if (s_initializationParameters.GetStringParameter(parameterName, &layer)) + if (parameters.GetStringParameter(parameterName, &layer)) { additionalLayers.emplace_back(std::move(layer)); enabledLayers.push_back(additionalLayers.back().GetConstBuffer()); @@ -127,7 +114,7 @@ namespace Nz } } - if (!s_initializationParameters.GetBooleanParameter("VkInstanceInfo_OverrideEnabledExtensions", &bParam) || !bParam) + if (!parameters.GetBooleanParameter("VkInstanceInfo_OverrideEnabledExtensions", &bParam) || !bParam) { enabledExtensions.push_back("VK_KHR_surface"); @@ -157,14 +144,14 @@ namespace Nz } std::vector additionalExtensions; // Just to keep the String alive - if (s_initializationParameters.GetIntegerParameter("VkInstanceInfo_EnabledExtensionCount", &iParam)) + if (parameters.GetIntegerParameter("VkInstanceInfo_EnabledExtensionCount", &iParam)) { additionalExtensions.reserve(iParam); for (int i = 0; i < iParam; ++i) { Nz::String parameterName = "VkInstanceInfo_EnabledExtension" + String::Number(i); Nz::String extension; - if (s_initializationParameters.GetStringParameter(parameterName, &extension)) + if (parameters.GetStringParameter(parameterName, &extension)) { additionalExtensions.emplace_back(std::move(extension)); enabledExtensions.push_back(additionalExtensions.back().GetConstBuffer()); @@ -190,7 +177,7 @@ namespace Nz NazaraError("Failed to create instance"); return false; } - + std::vector physDevices; if (!s_instance.EnumeratePhysicalDevices(&physDevices)) { @@ -199,7 +186,6 @@ namespace Nz } s_physDevices.reserve(physDevices.size()); - for (std::size_t i = 0; i < physDevices.size(); ++i) { VkPhysicalDevice physDevice = physDevices[i]; @@ -207,15 +193,15 @@ namespace Nz Vk::PhysicalDevice deviceInfo; if (!s_instance.GetPhysicalDeviceQueueFamilyProperties(physDevice, &deviceInfo.queues)) { - NazaraWarning("Failed to query physical device queue family properties"); + NazaraWarning("Failed to query physical device queue family properties for " + String(deviceInfo.properties.deviceName) + " (0x" + String::Number(deviceInfo.properties.deviceID, 16) + ')'); continue; } deviceInfo.device = physDevice; - deviceInfo.features = s_instance.GetPhysicalDeviceFeatures(physDevice); + deviceInfo.features = s_instance.GetPhysicalDeviceFeatures(physDevice); deviceInfo.memoryProperties = s_instance.GetPhysicalDeviceMemoryProperties(physDevice); - deviceInfo.properties = s_instance.GetPhysicalDeviceProperties(physDevice); + deviceInfo.properties = s_instance.GetPhysicalDeviceProperties(physDevice); s_physDevices.emplace_back(std::move(deviceInfo)); } @@ -226,17 +212,14 @@ namespace Nz return false; } + s_initializationParameters = parameters; + onExit.Reset(); NazaraNotice("Initialized: Vulkan module"); return true; } - bool Vulkan::IsInitialized() - { - return s_moduleReferenceCounter != 0; - } - Vk::DeviceHandle Vulkan::CreateDevice(VkPhysicalDevice gpu, const Vk::Surface& surface, UInt32* presentableFamilyQueue) { Nz::ErrorFlags errFlags(ErrorFlag_ThrowException, true); @@ -412,40 +395,18 @@ namespace Nz return CreateDevice(gpu, surface, presentableFamilyQueue); } - void Vulkan::SetParameters(const ParameterList& parameters) - { - s_initializationParameters = parameters; - } - 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 s_devices.clear(); s_instance.Destroy(); Vk::Loader::Uninitialize(); - - NazaraNotice("Uninitialized: Vulkan module"); - - // Free module dependencies - Utility::Uninitialize(); } std::list Vulkan::s_devices; std::vector Vulkan::s_physDevices; Vk::Instance Vulkan::s_instance; ParameterList Vulkan::s_initializationParameters; - unsigned int Vulkan::s_moduleReferenceCounter = 0; } diff --git a/src/Nazara/VulkanRenderer/VulkanRenderer.cpp b/src/Nazara/VulkanRenderer/VulkanRenderer.cpp index 2b838f189..e647645a6 100644 --- a/src/Nazara/VulkanRenderer/VulkanRenderer.cpp +++ b/src/Nazara/VulkanRenderer/VulkanRenderer.cpp @@ -3,12 +3,18 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include #include #include namespace Nz { + VulkanRenderer::~VulkanRenderer() + { + Vulkan::Uninitialize(); + } + std::unique_ptr VulkanRenderer::CreateRenderWindowImpl() { return std::make_unique(); @@ -24,177 +30,7 @@ namespace Nz bool VulkanRenderer::Prepare(const ParameterList& parameters) { - if (!Vk::Loader::Initialize()) - { - NazaraError("Failed to load Vulkan API, it may be not installed on your system"); - return false; - } - - String appName = "Another application made with Nazara Engine"; - String engineName = "Nazara Engine - Vulkan Renderer"; - - UInt32 apiVersion = APIVersion; - UInt32 appVersion = VK_MAKE_VERSION(1, 0, 0); - UInt32 engineVersion = VK_MAKE_VERSION(1, 0, 0); - - parameters.GetStringParameter("VkAppInfo_OverrideApplicationName", &appName); - parameters.GetStringParameter("VkAppInfo_OverrideEngineName", &engineName); - - bool bParam; - int iParam; - - if (parameters.GetIntegerParameter("VkAppInfo_OverrideAPIVersion", &iParam)) - apiVersion = iParam; - - if (parameters.GetIntegerParameter("VkAppInfo_OverrideApplicationVersion", &iParam)) - appVersion = iParam; - - if (parameters.GetIntegerParameter("VkAppInfo_OverrideEngineVersion", &iParam)) - engineVersion = iParam; - - VkApplicationInfo appInfo = { - VK_STRUCTURE_TYPE_APPLICATION_INFO, - nullptr, - appName.GetConstBuffer(), - appVersion, - engineName.GetConstBuffer(), - engineVersion, - apiVersion - }; - - VkInstanceCreateFlags createFlags = 0; - - if (parameters.GetIntegerParameter("VkInstanceInfo_OverrideCreateFlags", &iParam)) - createFlags = static_cast(iParam); - - std::vector enabledLayers; - std::vector enabledExtensions; - - if (!parameters.GetBooleanParameter("VkInstanceInfo_OverrideEnabledLayers", &bParam) || !bParam) - { - //< Nazara default layers goes here - } - - std::vector additionalLayers; // Just to keep the String alive - if (parameters.GetIntegerParameter("VkInstanceInfo_EnabledLayerCount", &iParam)) - { - additionalLayers.reserve(iParam); - for (int i = 0; i < iParam; ++i) - { - Nz::String parameterName = "VkInstanceInfo_EnabledLayer" + String::Number(i); - Nz::String layer; - if (parameters.GetStringParameter(parameterName, &layer)) - { - additionalLayers.emplace_back(std::move(layer)); - enabledLayers.push_back(additionalLayers.back().GetConstBuffer()); - } - else - NazaraWarning("Parameter " + parameterName + " expected"); - } - } - - if (!parameters.GetBooleanParameter("VkInstanceInfo_OverrideEnabledExtensions", &bParam) || !bParam) - { - enabledExtensions.push_back("VK_KHR_surface"); - - #ifdef VK_USE_PLATFORM_ANDROID_KHR - enabledExtensions.push_back("VK_KHR_android_surface"); - #endif - - #ifdef VK_USE_PLATFORM_MIR_KHR - enabledExtensions.push_back("VK_KHR_mir_surface"); - #endif - - #ifdef VK_USE_PLATFORM_XCB_KHR - enabledExtensions.push_back("VK_KHR_xcb_surface"); - #endif - - #ifdef VK_USE_PLATFORM_XLIB_KHR - enabledExtensions.push_back("VK_KHR_xlib_surface"); - #endif - - #ifdef VK_USE_PLATFORM_WAYLAND_KHR - enabledExtensions.push_back("VK_KHR_wayland_surface"); - #endif - - #ifdef VK_USE_PLATFORM_WIN32_KHR - enabledExtensions.push_back("VK_KHR_win32_surface"); - #endif - } - - std::vector additionalExtensions; // Just to keep the String alive - if (parameters.GetIntegerParameter("VkInstanceInfo_EnabledExtensionCount", &iParam)) - { - additionalExtensions.reserve(iParam); - for (int i = 0; i < iParam; ++i) - { - Nz::String parameterName = "VkInstanceInfo_EnabledExtension" + String::Number(i); - Nz::String extension; - if (parameters.GetStringParameter(parameterName, &extension)) - { - additionalExtensions.emplace_back(std::move(extension)); - enabledExtensions.push_back(additionalExtensions.back().GetConstBuffer()); - } - else - NazaraWarning("Parameter " + parameterName + " expected"); - } - } - - VkInstanceCreateInfo instanceInfo = - { - VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, // VkStructureType sType; - nullptr, // const void* pNext; - createFlags, // VkInstanceCreateFlags flags; - &appInfo, // const VkApplicationInfo* pApplicationInfo; - UInt32(enabledLayers.size()), // uint32_t enabledLayerCount; - enabledLayers.data(), // const char* const* ppEnabledLayerNames; - UInt32(enabledExtensions.size()), // uint32_t enabledExtensionCount; - enabledExtensions.data() // const char* const* ppEnabledExtensionNames; - }; - - if (!m_instance.Create(instanceInfo)) - { - NazaraError("Failed to create instance"); - return false; - } - - m_apiVersion = apiVersion; - - std::vector physDevices; - if (!m_instance.EnumeratePhysicalDevices(&physDevices)) - { - NazaraError("Failed to enumerate physical devices"); - return false; - } - - m_physDevices.reserve(physDevices.size()); - for (std::size_t i = 0; i < physDevices.size(); ++i) - { - VkPhysicalDevice physDevice = physDevices[i]; - - Vk::PhysicalDevice deviceInfo; - if (!m_instance.GetPhysicalDeviceQueueFamilyProperties(physDevice, &deviceInfo.queues)) - { - NazaraWarning("Failed to query physical device queue family properties for " + String(deviceInfo.properties.deviceName) + " (0x" + String::Number(deviceInfo.properties.deviceID, 16) + ')'); - continue; - } - - deviceInfo.device = physDevice; - - deviceInfo.features = m_instance.GetPhysicalDeviceFeatures(physDevice); - deviceInfo.memoryProperties = m_instance.GetPhysicalDeviceMemoryProperties(physDevice); - deviceInfo.properties = m_instance.GetPhysicalDeviceProperties(physDevice); - - m_physDevices.emplace_back(std::move(deviceInfo)); - } - - if (m_physDevices.empty()) - { - NazaraError("No valid physical device found"); - return false; - } - - return true; + return Vulkan::Initialize(APIVersion, parameters); } RenderAPI VulkanRenderer::QueryAPI() const From 66172a163c281be8595c5875fb93f45f2e977ea7 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 28 Oct 2016 22:30:52 +0200 Subject: [PATCH 056/316] Renderer: Fix implementation uninitialization --- src/Nazara/Renderer/Renderer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Nazara/Renderer/Renderer.cpp b/src/Nazara/Renderer/Renderer.cpp index 74a50d481..f2de3f03f 100644 --- a/src/Nazara/Renderer/Renderer.cpp +++ b/src/Nazara/Renderer/Renderer.cpp @@ -106,6 +106,8 @@ namespace Nz s_moduleReferenceCounter = 0; // Uninitialize module here + s_rendererImpl.reset(); + s_rendererLib.Unload(); NazaraNotice("Uninitialized: Renderer module"); From 71aa4d53a3f3eefb477d3b317cc2e82319bcc68e Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 28 Oct 2016 22:31:04 +0200 Subject: [PATCH 057/316] Renderer: Allow to pass custom parameters --- include/Nazara/Renderer/Renderer.hpp | 5 ++++- include/Nazara/Renderer/Renderer.inl | 5 +++++ src/Nazara/Renderer/Renderer.cpp | 5 +++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/include/Nazara/Renderer/Renderer.hpp b/include/Nazara/Renderer/Renderer.hpp index b23a5b284..cd680d412 100644 --- a/include/Nazara/Renderer/Renderer.hpp +++ b/include/Nazara/Renderer/Renderer.hpp @@ -26,11 +26,14 @@ namespace Nz static inline bool IsInitialized(); + static inline void SetParameters(const ParameterList& parameters); + static void Uninitialize(); private: - static DynLib s_rendererLib; static std::unique_ptr s_rendererImpl; + static DynLib s_rendererLib; + static ParameterList s_initializationParameters; static unsigned int s_moduleReferenceCounter; }; } diff --git a/include/Nazara/Renderer/Renderer.inl b/include/Nazara/Renderer/Renderer.inl index 16c3746db..25d22de23 100644 --- a/include/Nazara/Renderer/Renderer.inl +++ b/include/Nazara/Renderer/Renderer.inl @@ -16,6 +16,11 @@ namespace Nz { return s_moduleReferenceCounter != 0; } + + void Renderer::SetParameters(const ParameterList& parameters) + { + s_initializationParameters = parameters; + } } #include diff --git a/src/Nazara/Renderer/Renderer.cpp b/src/Nazara/Renderer/Renderer.cpp index f2de3f03f..efd33fd14 100644 --- a/src/Nazara/Renderer/Renderer.cpp +++ b/src/Nazara/Renderer/Renderer.cpp @@ -63,7 +63,7 @@ namespace Nz } std::unique_ptr impl(createRenderer()); - if (!impl || !impl->Prepare(Nz::ParameterList())) + if (!impl || !impl->Prepare(s_initializationParameters)) { NazaraError("Failed to create renderer implementation"); continue; @@ -115,7 +115,8 @@ namespace Nz Utility::Uninitialize(); } - DynLib Renderer::s_rendererLib; std::unique_ptr Renderer::s_rendererImpl; + DynLib Renderer::s_rendererLib; + ParameterList Renderer::s_initializationParameters; unsigned int Renderer::s_moduleReferenceCounter = 0; } From b317c10f23993a90d1f271996ab316e04dfa1f3e Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 28 Oct 2016 23:25:27 +0200 Subject: [PATCH 058/316] VulkanRenderer/Vulkan: Fix IsInitialized() missing implementation --- src/Nazara/VulkanRenderer/Vulkan.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Nazara/VulkanRenderer/Vulkan.cpp b/src/Nazara/VulkanRenderer/Vulkan.cpp index 0827bc030..ce43249d3 100644 --- a/src/Nazara/VulkanRenderer/Vulkan.cpp +++ b/src/Nazara/VulkanRenderer/Vulkan.cpp @@ -41,7 +41,7 @@ namespace Nz bool Vulkan::Initialize(UInt32 apiVersion, const ParameterList& parameters) { - NazaraAssert(!s_instance.IsValid(), "Vulkan is already initialized"); + NazaraAssert(!IsInitialized(), "Vulkan is already initialized"); // Initialize module here if (!Vk::Loader::Initialize()) @@ -220,6 +220,11 @@ namespace Nz return true; } + bool Vulkan::IsInitialized() + { + return s_instance.IsValid(); + } + Vk::DeviceHandle Vulkan::CreateDevice(VkPhysicalDevice gpu, const Vk::Surface& surface, UInt32* presentableFamilyQueue) { Nz::ErrorFlags errFlags(ErrorFlag_ThrowException, true); From 8d06c57d0d8cca56487f571da5f8b22d0bc92510 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 29 Oct 2016 00:52:25 +0200 Subject: [PATCH 059/316] Renderer: Add support for hardware buffers --- include/Nazara/Renderer/Renderer.hpp | 6 ++++++ include/Nazara/Renderer/RendererImpl.hpp | 4 ++++ src/Nazara/Renderer/Renderer.cpp | 10 ++++++++++ 3 files changed, 20 insertions(+) diff --git a/include/Nazara/Renderer/Renderer.hpp b/include/Nazara/Renderer/Renderer.hpp index cd680d412..195b9b40a 100644 --- a/include/Nazara/Renderer/Renderer.hpp +++ b/include/Nazara/Renderer/Renderer.hpp @@ -11,9 +11,13 @@ #include #include #include +#include namespace Nz { + class AbstractBuffer; + class Buffer; + class NAZARA_RENDERER_API Renderer { public: @@ -31,6 +35,8 @@ namespace Nz static void Uninitialize(); private: + static AbstractBuffer* CreateHardwareBufferImpl(Buffer* parent, BufferType type); + static std::unique_ptr s_rendererImpl; static DynLib s_rendererLib; static ParameterList s_initializationParameters; diff --git a/include/Nazara/Renderer/RendererImpl.hpp b/include/Nazara/Renderer/RendererImpl.hpp index 4c88773dd..758765492 100644 --- a/include/Nazara/Renderer/RendererImpl.hpp +++ b/include/Nazara/Renderer/RendererImpl.hpp @@ -13,10 +13,13 @@ #include #include #include +#include #include namespace Nz { + class AbstractBuffer; + class Buffer; class RendererImpl; class RenderWindowImpl; @@ -28,6 +31,7 @@ namespace Nz RendererImpl() = default; virtual ~RendererImpl(); + virtual std::unique_ptr CreateHardwareBufferImpl(Buffer* parent, BufferType type) = 0; virtual std::unique_ptr CreateRenderWindowImpl() = 0; virtual bool IsBetterThan(const RendererImpl* other) const = 0; diff --git a/src/Nazara/Renderer/Renderer.cpp b/src/Nazara/Renderer/Renderer.cpp index efd33fd14..cece28a91 100644 --- a/src/Nazara/Renderer/Renderer.cpp +++ b/src/Nazara/Renderer/Renderer.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -86,6 +87,8 @@ namespace Nz NazaraDebug("Using " + s_rendererImpl->QueryAPIString() + " as renderer"); + Buffer::SetBufferFactory(DataStorage_Hardware, CreateHardwareBufferImpl); + onExit.Reset(); NazaraNotice("Initialized: Renderer module"); @@ -106,6 +109,8 @@ namespace Nz s_moduleReferenceCounter = 0; // Uninitialize module here + Buffer::SetBufferFactory(DataStorage_Hardware, nullptr); + s_rendererImpl.reset(); s_rendererLib.Unload(); @@ -115,6 +120,11 @@ namespace Nz Utility::Uninitialize(); } + AbstractBuffer* Renderer::CreateHardwareBufferImpl(Buffer * parent, BufferType type) + { + return s_rendererImpl->CreateHardwareBufferImpl(parent, type).release(); + } + std::unique_ptr Renderer::s_rendererImpl; DynLib Renderer::s_rendererLib; ParameterList Renderer::s_initializationParameters; From e61c6d0a8e2a3200baf29795abd93a7b787ef3f9 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 29 Oct 2016 01:59:06 +0200 Subject: [PATCH 060/316] VulkanRenderer: Move vulkan wrappers to a separate directory --- include/Nazara/VulkanRenderer/Utils.hpp | 2 +- include/Nazara/VulkanRenderer/VkRenderTarget.hpp | 6 +++--- include/Nazara/VulkanRenderer/VkRenderWindow.hpp | 16 ++++++++-------- include/Nazara/VulkanRenderer/Vulkan.hpp | 8 ++++---- include/Nazara/VulkanRenderer/VulkanRenderer.hpp | 8 ++++---- .../{VkBuffer.hpp => Wrapper/Buffer.hpp} | 4 ++-- .../{VkBuffer.inl => Wrapper/Buffer.inl} | 2 +- .../CommandBuffer.hpp} | 4 ++-- .../CommandBuffer.inl} | 4 ++-- .../CommandPool.hpp} | 4 ++-- .../CommandPool.inl} | 4 ++-- .../DescriptorPool.hpp} | 4 ++-- .../DescriptorPool.inl} | 2 +- .../DescriptorSet.hpp} | 4 ++-- .../DescriptorSet.inl} | 4 ++-- .../DescriptorSetLayout.hpp} | 4 ++-- .../DescriptorSetLayout.inl} | 2 +- .../{VkDevice.hpp => Wrapper/Device.hpp} | 4 ++-- .../{VkDevice.inl => Wrapper/Device.inl} | 6 +++--- .../DeviceMemory.hpp} | 4 ++-- .../DeviceMemory.inl} | 4 ++-- .../DeviceObject.hpp} | 4 ++-- .../DeviceObject.inl} | 6 +++--- .../Framebuffer.hpp} | 4 ++-- .../Framebuffer.inl} | 2 +- .../{VkImage.hpp => Wrapper/Image.hpp} | 4 ++-- .../{VkImage.inl => Wrapper/Image.inl} | 2 +- .../{VkImageView.hpp => Wrapper/ImageView.hpp} | 4 ++-- .../{VkImageView.inl => Wrapper/ImageView.inl} | 2 +- .../{VkInstance.hpp => Wrapper/Instance.hpp} | 4 ++-- .../{VkInstance.inl => Wrapper/Instance.inl} | 2 +- .../{VkLoader.hpp => Wrapper/Loader.hpp} | 2 +- .../{VkLoader.inl => Wrapper/Loader.inl} | 2 +- .../PhysicalDevice.hpp} | 0 .../{VkPipeline.hpp => Wrapper/Pipeline.hpp} | 4 ++-- .../{VkPipeline.inl => Wrapper/Pipeline.inl} | 2 +- .../PipelineCache.hpp} | 4 ++-- .../PipelineCache.inl} | 2 +- .../PipelineLayout.hpp} | 4 ++-- .../PipelineLayout.inl} | 2 +- .../{VkQueue.hpp => Wrapper/Queue.hpp} | 4 ++-- .../{VkQueue.inl => Wrapper/Queue.inl} | 4 ++-- .../{VkRenderPass.hpp => Wrapper/RenderPass.hpp} | 4 ++-- .../{VkRenderPass.inl => Wrapper/RenderPass.inl} | 2 +- .../{VkSemaphore.hpp => Wrapper/Semaphore.hpp} | 4 ++-- .../{VkSemaphore.inl => Wrapper/Semaphore.inl} | 2 +- .../ShaderModule.hpp} | 4 ++-- .../ShaderModule.inl} | 2 +- .../{VkSurface.hpp => Wrapper/Surface.hpp} | 4 ++-- .../{VkSurface.inl => Wrapper/Surface.inl} | 4 ++-- .../{VkSwapchain.hpp => Wrapper/Swapchain.hpp} | 6 +++--- .../{VkSwapchain.inl => Wrapper/Swapchain.inl} | 4 ++-- src/Nazara/VulkanRenderer/VulkanRenderer.cpp | 2 +- .../CommandPool.cpp} | 4 ++-- .../DescriptorPool.cpp} | 4 ++-- .../{VkDevice.cpp => Wrapper/Device.cpp} | 2 +- .../{VkInstance.cpp => Wrapper/Instance.cpp} | 2 +- .../{VkLoader.cpp => Wrapper/Loader.cpp} | 2 +- 58 files changed, 108 insertions(+), 108 deletions(-) rename include/Nazara/VulkanRenderer/{VkBuffer.hpp => Wrapper/Buffer.hpp} (92%) rename include/Nazara/VulkanRenderer/{VkBuffer.inl => Wrapper/Buffer.inl} (97%) rename include/Nazara/VulkanRenderer/{VkCommandBuffer.hpp => Wrapper/CommandBuffer.hpp} (98%) rename include/Nazara/VulkanRenderer/{VkCommandBuffer.inl => Wrapper/CommandBuffer.inl} (99%) rename include/Nazara/VulkanRenderer/{VkCommandPool.hpp => Wrapper/CommandPool.hpp} (93%) rename include/Nazara/VulkanRenderer/{VkCommandPool.inl => Wrapper/CommandPool.inl} (92%) rename include/Nazara/VulkanRenderer/{VkDescriptorPool.hpp => Wrapper/DescriptorPool.hpp} (94%) rename include/Nazara/VulkanRenderer/{VkDescriptorPool.inl => Wrapper/DescriptorPool.inl} (97%) rename include/Nazara/VulkanRenderer/{VkDescriptorSet.hpp => Wrapper/DescriptorSet.hpp} (94%) rename include/Nazara/VulkanRenderer/{VkDescriptorSet.inl => Wrapper/DescriptorSet.inl} (97%) rename include/Nazara/VulkanRenderer/{VkDescriptorSetLayout.hpp => Wrapper/DescriptorSetLayout.hpp} (93%) rename include/Nazara/VulkanRenderer/{VkDescriptorSetLayout.inl => Wrapper/DescriptorSetLayout.inl} (96%) rename include/Nazara/VulkanRenderer/{VkDevice.hpp => Wrapper/Device.hpp} (99%) rename include/Nazara/VulkanRenderer/{VkDevice.inl => Wrapper/Device.inl} (94%) rename include/Nazara/VulkanRenderer/{VkDeviceMemory.hpp => Wrapper/DeviceMemory.hpp} (93%) rename include/Nazara/VulkanRenderer/{VkDeviceMemory.inl => Wrapper/DeviceMemory.inl} (96%) rename include/Nazara/VulkanRenderer/{VkDeviceObject.hpp => Wrapper/DeviceObject.hpp} (92%) rename include/Nazara/VulkanRenderer/{VkDeviceObject.inl => Wrapper/DeviceObject.inl} (94%) rename include/Nazara/VulkanRenderer/{VkFramebuffer.hpp => Wrapper/Framebuffer.hpp} (90%) rename include/Nazara/VulkanRenderer/{VkFramebuffer.inl => Wrapper/Framebuffer.inl} (93%) rename include/Nazara/VulkanRenderer/{VkImage.hpp => Wrapper/Image.hpp} (91%) rename include/Nazara/VulkanRenderer/{VkImage.inl => Wrapper/Image.inl} (96%) rename include/Nazara/VulkanRenderer/{VkImageView.hpp => Wrapper/ImageView.hpp} (90%) rename include/Nazara/VulkanRenderer/{VkImageView.inl => Wrapper/ImageView.inl} (93%) rename include/Nazara/VulkanRenderer/{VkInstance.hpp => Wrapper/Instance.hpp} (98%) rename include/Nazara/VulkanRenderer/{VkInstance.inl => Wrapper/Instance.inl} (98%) rename include/Nazara/VulkanRenderer/{VkLoader.hpp => Wrapper/Loader.hpp} (96%) rename include/Nazara/VulkanRenderer/{VkLoader.inl => Wrapper/Loader.inl} (89%) rename include/Nazara/VulkanRenderer/{VkPhysicalDevice.hpp => Wrapper/PhysicalDevice.hpp} (100%) rename include/Nazara/VulkanRenderer/{VkPipeline.hpp => Wrapper/Pipeline.hpp} (92%) rename include/Nazara/VulkanRenderer/{VkPipeline.inl => Wrapper/Pipeline.inl} (97%) rename include/Nazara/VulkanRenderer/{VkPipelineCache.hpp => Wrapper/PipelineCache.hpp} (90%) rename include/Nazara/VulkanRenderer/{VkPipelineCache.inl => Wrapper/PipelineCache.inl} (93%) rename include/Nazara/VulkanRenderer/{VkPipelineLayout.hpp => Wrapper/PipelineLayout.hpp} (90%) rename include/Nazara/VulkanRenderer/{VkPipelineLayout.inl => Wrapper/PipelineLayout.inl} (93%) rename include/Nazara/VulkanRenderer/{VkQueue.hpp => Wrapper/Queue.hpp} (93%) rename include/Nazara/VulkanRenderer/{VkQueue.inl => Wrapper/Queue.inl} (96%) rename include/Nazara/VulkanRenderer/{VkRenderPass.hpp => Wrapper/RenderPass.hpp} (90%) rename include/Nazara/VulkanRenderer/{VkRenderPass.inl => Wrapper/RenderPass.inl} (93%) rename include/Nazara/VulkanRenderer/{VkSemaphore.hpp => Wrapper/Semaphore.hpp} (91%) rename include/Nazara/VulkanRenderer/{VkSemaphore.inl => Wrapper/Semaphore.inl} (95%) rename include/Nazara/VulkanRenderer/{VkShaderModule.hpp => Wrapper/ShaderModule.hpp} (92%) rename include/Nazara/VulkanRenderer/{VkShaderModule.inl => Wrapper/ShaderModule.inl} (95%) rename include/Nazara/VulkanRenderer/{VkSurface.hpp => Wrapper/Surface.hpp} (97%) rename include/Nazara/VulkanRenderer/{VkSurface.inl => Wrapper/Surface.inl} (98%) rename include/Nazara/VulkanRenderer/{VkSwapchain.hpp => Wrapper/Swapchain.hpp} (91%) rename include/Nazara/VulkanRenderer/{VkSwapchain.inl => Wrapper/Swapchain.inl} (97%) rename src/Nazara/VulkanRenderer/{VkCommandPool.cpp => Wrapper/CommandPool.cpp} (92%) rename src/Nazara/VulkanRenderer/{VkDescriptorPool.cpp => Wrapper/DescriptorPool.cpp} (94%) rename src/Nazara/VulkanRenderer/{VkDevice.cpp => Wrapper/Device.cpp} (99%) rename src/Nazara/VulkanRenderer/{VkInstance.cpp => Wrapper/Instance.cpp} (99%) rename src/Nazara/VulkanRenderer/{VkLoader.cpp => Wrapper/Loader.cpp} (98%) diff --git a/include/Nazara/VulkanRenderer/Utils.hpp b/include/Nazara/VulkanRenderer/Utils.hpp index eb195b16c..cd856a49c 100644 --- a/include/Nazara/VulkanRenderer/Utils.hpp +++ b/include/Nazara/VulkanRenderer/Utils.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include namespace Nz { diff --git a/include/Nazara/VulkanRenderer/VkRenderTarget.hpp b/include/Nazara/VulkanRenderer/VkRenderTarget.hpp index 51aa97d4a..52e7b034d 100644 --- a/include/Nazara/VulkanRenderer/VkRenderTarget.hpp +++ b/include/Nazara/VulkanRenderer/VkRenderTarget.hpp @@ -10,9 +10,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include diff --git a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp index 348fb84c1..7a3246984 100644 --- a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp +++ b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp @@ -13,15 +13,15 @@ #include #include #include -#include -#include -#include -#include -#include -#include #include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/Vulkan.hpp b/include/Nazara/VulkanRenderer/Vulkan.hpp index bd0e38560..04f62637b 100644 --- a/include/Nazara/VulkanRenderer/Vulkan.hpp +++ b/include/Nazara/VulkanRenderer/Vulkan.hpp @@ -11,10 +11,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/include/Nazara/VulkanRenderer/VulkanRenderer.hpp b/include/Nazara/VulkanRenderer/VulkanRenderer.hpp index aeb3d19e6..38dc8540f 100644 --- a/include/Nazara/VulkanRenderer/VulkanRenderer.hpp +++ b/include/Nazara/VulkanRenderer/VulkanRenderer.hpp @@ -10,10 +10,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/include/Nazara/VulkanRenderer/VkBuffer.hpp b/include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp similarity index 92% rename from include/Nazara/VulkanRenderer/VkBuffer.hpp rename to include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp index 9f280f655..2daf3d302 100644 --- a/include/Nazara/VulkanRenderer/VkBuffer.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp @@ -8,7 +8,7 @@ #define NAZARA_VULKANRENDERER_VKBUFFER_HPP #include -#include +#include namespace Nz { @@ -41,6 +41,6 @@ namespace Nz } } -#include +#include #endif // NAZARA_VULKANRENDERER_VKBUFFER_HPP diff --git a/include/Nazara/VulkanRenderer/VkBuffer.inl b/include/Nazara/VulkanRenderer/Wrapper/Buffer.inl similarity index 97% rename from include/Nazara/VulkanRenderer/VkBuffer.inl rename to include/Nazara/VulkanRenderer/Wrapper/Buffer.inl index 2ac598738..73ad69566 100644 --- a/include/Nazara/VulkanRenderer/VkBuffer.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Buffer.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/VkCommandBuffer.hpp b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp similarity index 98% rename from include/Nazara/VulkanRenderer/VkCommandBuffer.hpp rename to include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp index dc88f13da..c1d2b9e54 100644 --- a/include/Nazara/VulkanRenderer/VkCommandBuffer.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include namespace Nz @@ -95,6 +95,6 @@ namespace Nz } } -#include +#include #endif // NAZARA_VULKANRENDERER_VKCOMMANDBUFFER_HPP diff --git a/include/Nazara/VulkanRenderer/VkCommandBuffer.inl b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl similarity index 99% rename from include/Nazara/VulkanRenderer/VkCommandBuffer.inl rename to include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl index 7721a7a74..c020d284f 100644 --- a/include/Nazara/VulkanRenderer/VkCommandBuffer.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl @@ -2,9 +2,9 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include -#include +#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/VkCommandPool.hpp b/include/Nazara/VulkanRenderer/Wrapper/CommandPool.hpp similarity index 93% rename from include/Nazara/VulkanRenderer/VkCommandPool.hpp rename to include/Nazara/VulkanRenderer/Wrapper/CommandPool.hpp index 178ec1fec..1c1e2674a 100644 --- a/include/Nazara/VulkanRenderer/VkCommandPool.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandPool.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include namespace Nz { @@ -48,6 +48,6 @@ namespace Nz } } -#include +#include #endif // NAZARA_VULKANRENDERER_VKCOMMANDPOOL_HPP diff --git a/include/Nazara/VulkanRenderer/VkCommandPool.inl b/include/Nazara/VulkanRenderer/Wrapper/CommandPool.inl similarity index 92% rename from include/Nazara/VulkanRenderer/VkCommandPool.inl rename to include/Nazara/VulkanRenderer/Wrapper/CommandPool.inl index cba47f66b..90c952654 100644 --- a/include/Nazara/VulkanRenderer/VkCommandPool.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandPool.inl @@ -2,9 +2,9 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include -#include +#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/VkDescriptorPool.hpp b/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp similarity index 94% rename from include/Nazara/VulkanRenderer/VkDescriptorPool.hpp rename to include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp index b5c862ffe..f9fad39d3 100644 --- a/include/Nazara/VulkanRenderer/VkDescriptorPool.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include namespace Nz { @@ -47,6 +47,6 @@ namespace Nz } } -#include +#include #endif // NAZARA_VULKANRENDERER_VKDESCRIPTORPOOL_HPP diff --git a/include/Nazara/VulkanRenderer/VkDescriptorPool.inl b/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.inl similarity index 97% rename from include/Nazara/VulkanRenderer/VkDescriptorPool.inl rename to include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.inl index dc41a2ce8..cd81effcc 100644 --- a/include/Nazara/VulkanRenderer/VkDescriptorPool.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/VkDescriptorSet.hpp b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.hpp similarity index 94% rename from include/Nazara/VulkanRenderer/VkDescriptorSet.hpp rename to include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.hpp index 3a4fba9dc..0c08a52f8 100644 --- a/include/Nazara/VulkanRenderer/VkDescriptorSet.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include namespace Nz @@ -54,6 +54,6 @@ namespace Nz } } -#include +#include #endif // NAZARA_VULKANRENDERER_VKDESCRIPTORSET_HPP diff --git a/include/Nazara/VulkanRenderer/VkDescriptorSet.inl b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.inl similarity index 97% rename from include/Nazara/VulkanRenderer/VkDescriptorSet.inl rename to include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.inl index bc011005c..c94c48806 100644 --- a/include/Nazara/VulkanRenderer/VkDescriptorSet.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.inl @@ -2,9 +2,9 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include -#include +#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/VkDescriptorSetLayout.hpp b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.hpp similarity index 93% rename from include/Nazara/VulkanRenderer/VkDescriptorSetLayout.hpp rename to include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.hpp index 6aff14fbe..fc95be3db 100644 --- a/include/Nazara/VulkanRenderer/VkDescriptorSetLayout.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.hpp @@ -8,7 +8,7 @@ #define NAZARA_VULKANRENDERER_VKDESCRIPTORSETLAYOUT_HPP #include -#include +#include namespace Nz { @@ -38,6 +38,6 @@ namespace Nz } } -#include +#include #endif // NAZARA_VULKANRENDERER_VKDESCRIPTORSETLAYOUT_HPP diff --git a/include/Nazara/VulkanRenderer/VkDescriptorSetLayout.inl b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.inl similarity index 96% rename from include/Nazara/VulkanRenderer/VkDescriptorSetLayout.inl rename to include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.inl index a53956b64..707d6ccdd 100644 --- a/include/Nazara/VulkanRenderer/VkDescriptorSetLayout.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/VkDevice.hpp b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp similarity index 99% rename from include/Nazara/VulkanRenderer/VkDevice.hpp rename to include/Nazara/VulkanRenderer/Wrapper/Device.hpp index 32928338c..227e8f512 100644 --- a/include/Nazara/VulkanRenderer/VkDevice.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include @@ -227,6 +227,6 @@ namespace Nz } } -#include +#include #endif // NAZARA_VULKANRENDERER_VKDEVICE_HPP diff --git a/include/Nazara/VulkanRenderer/VkDevice.inl b/include/Nazara/VulkanRenderer/Wrapper/Device.inl similarity index 94% rename from include/Nazara/VulkanRenderer/VkDevice.inl rename to include/Nazara/VulkanRenderer/Wrapper/Device.inl index b5574958b..f7e76a2f0 100644 --- a/include/Nazara/VulkanRenderer/VkDevice.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Device.inl @@ -2,11 +2,11 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include #include -#include -#include +#include +#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/VkDeviceMemory.hpp b/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp similarity index 93% rename from include/Nazara/VulkanRenderer/VkDeviceMemory.hpp rename to include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp index 7e6755dba..1613ea019 100644 --- a/include/Nazara/VulkanRenderer/VkDeviceMemory.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp @@ -8,7 +8,7 @@ #define NAZARA_VULKANRENDERER_VKDEVICEMEMORY_HPP #include -#include +#include namespace Nz { @@ -46,6 +46,6 @@ namespace Nz } } -#include +#include #endif // NAZARA_VULKANRENDERER_VKDEVICEMEMORY_HPP diff --git a/include/Nazara/VulkanRenderer/VkDeviceMemory.inl b/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.inl similarity index 96% rename from include/Nazara/VulkanRenderer/VkDeviceMemory.inl rename to include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.inl index 2b66fc1c5..64e2f7618 100644 --- a/include/Nazara/VulkanRenderer/VkDeviceMemory.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.inl @@ -2,8 +2,8 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include -#include +#include +#include #include #include #include diff --git a/include/Nazara/VulkanRenderer/VkDeviceObject.hpp b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp similarity index 92% rename from include/Nazara/VulkanRenderer/VkDeviceObject.hpp rename to include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp index 5a61bf2ee..2c09fe638 100644 --- a/include/Nazara/VulkanRenderer/VkDeviceObject.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp @@ -8,7 +8,7 @@ #define NAZARA_VULKANRENDERER_VKDEVICEOBJECT_HPP #include -#include +#include #include namespace Nz @@ -46,6 +46,6 @@ namespace Nz } } -#include +#include #endif // NAZARA_VULKANRENDERER_VKDEVICEOBJECT_HPP diff --git a/include/Nazara/VulkanRenderer/VkDeviceObject.inl b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl similarity index 94% rename from include/Nazara/VulkanRenderer/VkDeviceObject.inl rename to include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl index f46cfd256..a68e7a469 100644 --- a/include/Nazara/VulkanRenderer/VkDeviceObject.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl @@ -2,11 +2,11 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include #include -#include -#include +#include +#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/VkFramebuffer.hpp b/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.hpp similarity index 90% rename from include/Nazara/VulkanRenderer/VkFramebuffer.hpp rename to include/Nazara/VulkanRenderer/Wrapper/Framebuffer.hpp index 606042371..99f168be5 100644 --- a/include/Nazara/VulkanRenderer/VkFramebuffer.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.hpp @@ -8,7 +8,7 @@ #define NAZARA_VULKANRENDERER_VKFRAMEBUFFER_HPP #include -#include +#include namespace Nz { @@ -34,6 +34,6 @@ namespace Nz } } -#include +#include #endif // NAZARA_VULKANRENDERER_VKFRAMEBUFFER_HPP diff --git a/include/Nazara/VulkanRenderer/VkFramebuffer.inl b/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.inl similarity index 93% rename from include/Nazara/VulkanRenderer/VkFramebuffer.inl rename to include/Nazara/VulkanRenderer/Wrapper/Framebuffer.inl index 961f3e0c6..1062a1d63 100644 --- a/include/Nazara/VulkanRenderer/VkFramebuffer.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/VkImage.hpp b/include/Nazara/VulkanRenderer/Wrapper/Image.hpp similarity index 91% rename from include/Nazara/VulkanRenderer/VkImage.hpp rename to include/Nazara/VulkanRenderer/Wrapper/Image.hpp index 578662600..eea75ee4d 100644 --- a/include/Nazara/VulkanRenderer/VkImage.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Image.hpp @@ -8,7 +8,7 @@ #define NAZARA_VULKANRENDERER_VKIMAGE_HPP #include -#include +#include namespace Nz { @@ -38,6 +38,6 @@ namespace Nz } } -#include +#include #endif // NAZARA_VULKANRENDERER_VKIMAGE_HPP diff --git a/include/Nazara/VulkanRenderer/VkImage.inl b/include/Nazara/VulkanRenderer/Wrapper/Image.inl similarity index 96% rename from include/Nazara/VulkanRenderer/VkImage.inl rename to include/Nazara/VulkanRenderer/Wrapper/Image.inl index e7a675f26..ffc8ed2f9 100644 --- a/include/Nazara/VulkanRenderer/VkImage.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Image.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include #include diff --git a/include/Nazara/VulkanRenderer/VkImageView.hpp b/include/Nazara/VulkanRenderer/Wrapper/ImageView.hpp similarity index 90% rename from include/Nazara/VulkanRenderer/VkImageView.hpp rename to include/Nazara/VulkanRenderer/Wrapper/ImageView.hpp index 8362859cc..373cf18b6 100644 --- a/include/Nazara/VulkanRenderer/VkImageView.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/ImageView.hpp @@ -8,7 +8,7 @@ #define NAZARA_VULKANRENDERER_VKIMAGEVIEW_HPP #include -#include +#include namespace Nz { @@ -34,6 +34,6 @@ namespace Nz } } -#include +#include #endif // NAZARA_VULKANRENDERER_VKIMAGEVIEW_HPP diff --git a/include/Nazara/VulkanRenderer/VkImageView.inl b/include/Nazara/VulkanRenderer/Wrapper/ImageView.inl similarity index 93% rename from include/Nazara/VulkanRenderer/VkImageView.inl rename to include/Nazara/VulkanRenderer/Wrapper/ImageView.inl index 8bf522c9e..0c2219703 100644 --- a/include/Nazara/VulkanRenderer/VkImageView.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/ImageView.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/VkInstance.hpp b/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp similarity index 98% rename from include/Nazara/VulkanRenderer/VkInstance.hpp rename to include/Nazara/VulkanRenderer/Wrapper/Instance.hpp index 03e52e86a..c8fafd9d3 100644 --- a/include/Nazara/VulkanRenderer/VkInstance.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include @@ -137,6 +137,6 @@ namespace Nz } } -#include +#include #endif // NAZARA_VULKANRENDERER_VKINSTANCE_HPP diff --git a/include/Nazara/VulkanRenderer/VkInstance.inl b/include/Nazara/VulkanRenderer/Wrapper/Instance.inl similarity index 98% rename from include/Nazara/VulkanRenderer/VkInstance.inl rename to include/Nazara/VulkanRenderer/Wrapper/Instance.inl index db3a485af..a750763c9 100644 --- a/include/Nazara/VulkanRenderer/VkInstance.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Instance.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include #include #include diff --git a/include/Nazara/VulkanRenderer/VkLoader.hpp b/include/Nazara/VulkanRenderer/Wrapper/Loader.hpp similarity index 96% rename from include/Nazara/VulkanRenderer/VkLoader.hpp rename to include/Nazara/VulkanRenderer/Wrapper/Loader.hpp index a83eb58e1..a1c4d4ed6 100644 --- a/include/Nazara/VulkanRenderer/VkLoader.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Loader.hpp @@ -47,6 +47,6 @@ namespace Nz } } -#include +#include #endif // NAZARA_VULKANRENDERER_VKLOADER_HPP diff --git a/include/Nazara/VulkanRenderer/VkLoader.inl b/include/Nazara/VulkanRenderer/Wrapper/Loader.inl similarity index 89% rename from include/Nazara/VulkanRenderer/VkLoader.inl rename to include/Nazara/VulkanRenderer/Wrapper/Loader.inl index caad2bab3..1ff9dfd01 100644 --- a/include/Nazara/VulkanRenderer/VkLoader.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Loader.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/VkPhysicalDevice.hpp b/include/Nazara/VulkanRenderer/Wrapper/PhysicalDevice.hpp similarity index 100% rename from include/Nazara/VulkanRenderer/VkPhysicalDevice.hpp rename to include/Nazara/VulkanRenderer/Wrapper/PhysicalDevice.hpp diff --git a/include/Nazara/VulkanRenderer/VkPipeline.hpp b/include/Nazara/VulkanRenderer/Wrapper/Pipeline.hpp similarity index 92% rename from include/Nazara/VulkanRenderer/VkPipeline.hpp rename to include/Nazara/VulkanRenderer/Wrapper/Pipeline.hpp index ec18dd416..ead741a30 100644 --- a/include/Nazara/VulkanRenderer/VkPipeline.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Pipeline.hpp @@ -8,7 +8,7 @@ #define NAZARA_VULKANRENDERER_VKPIPELINE_HPP #include -#include +#include namespace Nz { @@ -45,6 +45,6 @@ namespace Nz } } -#include +#include #endif // NAZARA_VULKANRENDERER_VKPIPELINE_HPP diff --git a/include/Nazara/VulkanRenderer/VkPipeline.inl b/include/Nazara/VulkanRenderer/Wrapper/Pipeline.inl similarity index 97% rename from include/Nazara/VulkanRenderer/VkPipeline.inl rename to include/Nazara/VulkanRenderer/Wrapper/Pipeline.inl index 936a003a7..d55eb95d6 100644 --- a/include/Nazara/VulkanRenderer/VkPipeline.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Pipeline.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include #include diff --git a/include/Nazara/VulkanRenderer/VkPipelineCache.hpp b/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.hpp similarity index 90% rename from include/Nazara/VulkanRenderer/VkPipelineCache.hpp rename to include/Nazara/VulkanRenderer/Wrapper/PipelineCache.hpp index cb60321b9..405fee3c2 100644 --- a/include/Nazara/VulkanRenderer/VkPipelineCache.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.hpp @@ -8,7 +8,7 @@ #define NAZARA_VULKANRENDERER_VKPIPELINECACHE_HPP #include -#include +#include namespace Nz { @@ -34,6 +34,6 @@ namespace Nz } } -#include +#include #endif // NAZARA_VULKANRENDERER_VKPIPELINECACHE_HPP diff --git a/include/Nazara/VulkanRenderer/VkPipelineCache.inl b/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.inl similarity index 93% rename from include/Nazara/VulkanRenderer/VkPipelineCache.inl rename to include/Nazara/VulkanRenderer/Wrapper/PipelineCache.inl index d37f5c8c0..fde28390c 100644 --- a/include/Nazara/VulkanRenderer/VkPipelineCache.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/VkPipelineLayout.hpp b/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp similarity index 90% rename from include/Nazara/VulkanRenderer/VkPipelineLayout.hpp rename to include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp index 4abb54e0a..fe5300127 100644 --- a/include/Nazara/VulkanRenderer/VkPipelineLayout.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp @@ -8,7 +8,7 @@ #define NAZARA_VULKANRENDERER_VKPIPELINELAYOUT_HPP #include -#include +#include namespace Nz { @@ -34,6 +34,6 @@ namespace Nz } } -#include +#include #endif // NAZARA_VULKANRENDERER_VKPIPELINELAYOUT_HPP diff --git a/include/Nazara/VulkanRenderer/VkPipelineLayout.inl b/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.inl similarity index 93% rename from include/Nazara/VulkanRenderer/VkPipelineLayout.inl rename to include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.inl index 22ceb988b..a7a1bc444 100644 --- a/include/Nazara/VulkanRenderer/VkPipelineLayout.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/VkQueue.hpp b/include/Nazara/VulkanRenderer/Wrapper/Queue.hpp similarity index 93% rename from include/Nazara/VulkanRenderer/VkQueue.hpp rename to include/Nazara/VulkanRenderer/Wrapper/Queue.hpp index 59cf74e17..f8502ab87 100644 --- a/include/Nazara/VulkanRenderer/VkQueue.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Queue.hpp @@ -8,7 +8,7 @@ #define NAZARA_VULKANRENDERER_VKQUEUE_HPP #include -#include +#include #include namespace Nz @@ -48,6 +48,6 @@ namespace Nz } } -#include +#include #endif // NAZARA_VULKANRENDERER_VKQUEUE_HPP diff --git a/include/Nazara/VulkanRenderer/VkQueue.inl b/include/Nazara/VulkanRenderer/Wrapper/Queue.inl similarity index 96% rename from include/Nazara/VulkanRenderer/VkQueue.inl rename to include/Nazara/VulkanRenderer/Wrapper/Queue.inl index c1d06ec4e..51966d94d 100644 --- a/include/Nazara/VulkanRenderer/VkQueue.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Queue.inl @@ -2,10 +2,10 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include #include -#include +#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/VkRenderPass.hpp b/include/Nazara/VulkanRenderer/Wrapper/RenderPass.hpp similarity index 90% rename from include/Nazara/VulkanRenderer/VkRenderPass.hpp rename to include/Nazara/VulkanRenderer/Wrapper/RenderPass.hpp index 2ea70a316..71c1d75e9 100644 --- a/include/Nazara/VulkanRenderer/VkRenderPass.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/RenderPass.hpp @@ -8,7 +8,7 @@ #define NAZARA_VULKANRENDERER_VKRENDERPASS_HPP #include -#include +#include namespace Nz { @@ -34,6 +34,6 @@ namespace Nz } } -#include +#include #endif // NAZARA_VULKANRENDERER_VKRENDERPASS_HPP diff --git a/include/Nazara/VulkanRenderer/VkRenderPass.inl b/include/Nazara/VulkanRenderer/Wrapper/RenderPass.inl similarity index 93% rename from include/Nazara/VulkanRenderer/VkRenderPass.inl rename to include/Nazara/VulkanRenderer/Wrapper/RenderPass.inl index 7fde52a75..4052fb100 100644 --- a/include/Nazara/VulkanRenderer/VkRenderPass.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/RenderPass.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/VkSemaphore.hpp b/include/Nazara/VulkanRenderer/Wrapper/Semaphore.hpp similarity index 91% rename from include/Nazara/VulkanRenderer/VkSemaphore.hpp rename to include/Nazara/VulkanRenderer/Wrapper/Semaphore.hpp index 0f5e09d59..baffe1171 100644 --- a/include/Nazara/VulkanRenderer/VkSemaphore.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Semaphore.hpp @@ -8,7 +8,7 @@ #define NAZARA_VULKANRENDERER_VKSEMAPHORE_HPP #include -#include +#include namespace Nz { @@ -37,6 +37,6 @@ namespace Nz } } -#include +#include #endif // NAZARA_VULKANRENDERER_VKSEMAPHORE_HPP diff --git a/include/Nazara/VulkanRenderer/VkSemaphore.inl b/include/Nazara/VulkanRenderer/Wrapper/Semaphore.inl similarity index 95% rename from include/Nazara/VulkanRenderer/VkSemaphore.inl rename to include/Nazara/VulkanRenderer/Wrapper/Semaphore.inl index 7220cfeb9..605a59c03 100644 --- a/include/Nazara/VulkanRenderer/VkSemaphore.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Semaphore.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/VkShaderModule.hpp b/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp similarity index 92% rename from include/Nazara/VulkanRenderer/VkShaderModule.hpp rename to include/Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp index e8b5f8fd1..65ee75ddc 100644 --- a/include/Nazara/VulkanRenderer/VkShaderModule.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp @@ -8,7 +8,7 @@ #define NAZARA_VULKANRENDERER_VKSHADERMODULE_HPP #include -#include +#include namespace Nz { @@ -37,6 +37,6 @@ namespace Nz } } -#include +#include #endif // NAZARA_VULKANRENDERER_VKSHADERMODULE_HPP diff --git a/include/Nazara/VulkanRenderer/VkShaderModule.inl b/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.inl similarity index 95% rename from include/Nazara/VulkanRenderer/VkShaderModule.inl rename to include/Nazara/VulkanRenderer/Wrapper/ShaderModule.inl index 81f5177fc..fa9781226 100644 --- a/include/Nazara/VulkanRenderer/VkShaderModule.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/VkSurface.hpp b/include/Nazara/VulkanRenderer/Wrapper/Surface.hpp similarity index 97% rename from include/Nazara/VulkanRenderer/VkSurface.hpp rename to include/Nazara/VulkanRenderer/Wrapper/Surface.hpp index 1f4db956f..765848962 100644 --- a/include/Nazara/VulkanRenderer/VkSurface.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Surface.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include namespace Nz @@ -89,6 +89,6 @@ namespace Nz } } -#include +#include #endif // NAZARA_VULKANRENDERER_VKSURFACE_HPP diff --git a/include/Nazara/VulkanRenderer/VkSurface.inl b/include/Nazara/VulkanRenderer/Wrapper/Surface.inl similarity index 98% rename from include/Nazara/VulkanRenderer/VkSurface.inl rename to include/Nazara/VulkanRenderer/Wrapper/Surface.inl index 8b5ea7369..bfc5f4824 100644 --- a/include/Nazara/VulkanRenderer/VkSurface.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Surface.inl @@ -2,10 +2,10 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include #include -#include +#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/VkSwapchain.hpp b/include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp similarity index 91% rename from include/Nazara/VulkanRenderer/VkSwapchain.hpp rename to include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp index b896c6c58..5df920ba0 100644 --- a/include/Nazara/VulkanRenderer/VkSwapchain.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp @@ -8,8 +8,8 @@ #define NAZARA_VULKANRENDERER_VKSWAPCHAIN_HPP #include -#include -#include +#include +#include namespace Nz { @@ -55,6 +55,6 @@ namespace Nz } } -#include +#include #endif // NAZARA_VULKANRENDERER_VKSWAPCHAIN_HPP diff --git a/include/Nazara/VulkanRenderer/VkSwapchain.inl b/include/Nazara/VulkanRenderer/Wrapper/Swapchain.inl similarity index 97% rename from include/Nazara/VulkanRenderer/VkSwapchain.inl rename to include/Nazara/VulkanRenderer/Wrapper/Swapchain.inl index 363807859..5561ac3f0 100644 --- a/include/Nazara/VulkanRenderer/VkSwapchain.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Swapchain.inl @@ -2,10 +2,10 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include #include -#include +#include #include namespace Nz diff --git a/src/Nazara/VulkanRenderer/VulkanRenderer.cpp b/src/Nazara/VulkanRenderer/VulkanRenderer.cpp index e647645a6..861557507 100644 --- a/src/Nazara/VulkanRenderer/VulkanRenderer.cpp +++ b/src/Nazara/VulkanRenderer/VulkanRenderer.cpp @@ -4,8 +4,8 @@ #include #include -#include #include +#include #include namespace Nz diff --git a/src/Nazara/VulkanRenderer/VkCommandPool.cpp b/src/Nazara/VulkanRenderer/Wrapper/CommandPool.cpp similarity index 92% rename from src/Nazara/VulkanRenderer/VkCommandPool.cpp rename to src/Nazara/VulkanRenderer/Wrapper/CommandPool.cpp index a1f2ea629..ab9cf5ccc 100644 --- a/src/Nazara/VulkanRenderer/VkCommandPool.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/CommandPool.cpp @@ -2,8 +2,8 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include -#include +#include +#include #include namespace Nz diff --git a/src/Nazara/VulkanRenderer/VkDescriptorPool.cpp b/src/Nazara/VulkanRenderer/Wrapper/DescriptorPool.cpp similarity index 94% rename from src/Nazara/VulkanRenderer/VkDescriptorPool.cpp rename to src/Nazara/VulkanRenderer/Wrapper/DescriptorPool.cpp index f84b9dc20..5cea20758 100644 --- a/src/Nazara/VulkanRenderer/VkDescriptorPool.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/DescriptorPool.cpp @@ -2,8 +2,8 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include -#include +#include +#include #include namespace Nz diff --git a/src/Nazara/VulkanRenderer/VkDevice.cpp b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp similarity index 99% rename from src/Nazara/VulkanRenderer/VkDevice.cpp rename to src/Nazara/VulkanRenderer/Wrapper/Device.cpp index a62c65e26..b5f6d8890 100644 --- a/src/Nazara/VulkanRenderer/VkDevice.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include #include #include diff --git a/src/Nazara/VulkanRenderer/VkInstance.cpp b/src/Nazara/VulkanRenderer/Wrapper/Instance.cpp similarity index 99% rename from src/Nazara/VulkanRenderer/VkInstance.cpp rename to src/Nazara/VulkanRenderer/Wrapper/Instance.cpp index 7daced8f1..4ec965725 100644 --- a/src/Nazara/VulkanRenderer/VkInstance.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Instance.cpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include #include #include diff --git a/src/Nazara/VulkanRenderer/VkLoader.cpp b/src/Nazara/VulkanRenderer/Wrapper/Loader.cpp similarity index 98% rename from src/Nazara/VulkanRenderer/VkLoader.cpp rename to src/Nazara/VulkanRenderer/Wrapper/Loader.cpp index 8bc2bd05b..c1d62f715 100644 --- a/src/Nazara/VulkanRenderer/VkLoader.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Loader.cpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include #include From 51f1df1ec0b3b1d3112acaac71d9e19c9c95348d Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 29 Oct 2016 01:59:17 +0200 Subject: [PATCH 061/316] Renderer/Renderer: Fix missing include --- src/Nazara/Renderer/Renderer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Nazara/Renderer/Renderer.cpp b/src/Nazara/Renderer/Renderer.cpp index cece28a91..7df964645 100644 --- a/src/Nazara/Renderer/Renderer.cpp +++ b/src/Nazara/Renderer/Renderer.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include From 86b892c3bc1ad7969b5352f22108635e9556f1ce Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 29 Oct 2016 02:46:59 +0200 Subject: [PATCH 062/316] Regenerate Vulkan global include; add wrapper global include --- build/scripts/actions/generateheaders.lua | 9 +++++++ include/Nazara/VulkanRenderer.hpp | 26 ++---------------- include/Nazara/VulkanRenderer/Wrapper.hpp | 33 +++++++++++++++++++++++ 3 files changed, 44 insertions(+), 24 deletions(-) create mode 100644 include/Nazara/VulkanRenderer/Wrapper.hpp diff --git a/build/scripts/actions/generateheaders.lua b/build/scripts/actions/generateheaders.lua index 6bbd5782c..829d0caba 100644 --- a/build/scripts/actions/generateheaders.lua +++ b/build/scripts/actions/generateheaders.lua @@ -42,6 +42,15 @@ ACTION.Function = function () }) end + table.insert(paths, { + Excludes = {}, + HeaderGuard = "NAZARA_GLOBAL_VULKANRENDERER_WRAPPER_HPP", + Name = "Vulkan wrapper", + SearchDir = "../include/Nazara/VulkanRenderer/Wrapper", + TopDir = "Nazara", + Target = "../include/Nazara/VulkanRenderer/Wrapper.hpp" + }) + table.insert(paths, { Excludes = {}, HeaderGuard = "NDK_COMPONENTS_GLOBAL_HPP", diff --git a/include/Nazara/VulkanRenderer.hpp b/include/Nazara/VulkanRenderer.hpp index dba9f55e3..367c2a55a 100644 --- a/include/Nazara/VulkanRenderer.hpp +++ b/include/Nazara/VulkanRenderer.hpp @@ -31,33 +31,11 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include -#include -#include -#include -#include #include +#include #include +#include #endif // NAZARA_GLOBAL_VULKANRENDERER_HPP diff --git a/include/Nazara/VulkanRenderer/Wrapper.hpp b/include/Nazara/VulkanRenderer/Wrapper.hpp new file mode 100644 index 000000000..651a8e04f --- /dev/null +++ b/include/Nazara/VulkanRenderer/Wrapper.hpp @@ -0,0 +1,33 @@ +// This file was automatically generated + +#pragma once + +#ifndef NAZARA_GLOBAL_VULKANRENDERER_WRAPPER_HPP +#define NAZARA_GLOBAL_VULKANRENDERER_WRAPPER_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // NAZARA_GLOBAL_VULKANRENDERER_WRAPPER_HPP From c136f8eddc221a0bb2fee4a77050ff1925a1210e Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 10 Nov 2016 12:54:10 +0100 Subject: [PATCH 063/316] Commit WIP about RenderSurface --- .../Nazara/Renderer/RenderDeviceInstance.hpp | 26 +++++++++++ .../Nazara/Renderer/RenderDeviceInstance.inl | 12 +++++ include/Nazara/Renderer/RenderSurface.hpp | 30 +++++++++++++ include/Nazara/Renderer/RenderSurface.inl | 12 +++++ include/Nazara/Renderer/RenderWindow.hpp | 2 + include/Nazara/Renderer/RenderWindowImpl.hpp | 4 +- include/Nazara/Renderer/RendererImpl.hpp | 5 +++ .../Nazara/VulkanRenderer/VkRenderWindow.hpp | 6 +-- .../Nazara/VulkanRenderer/VkRenderWindow.inl | 5 --- .../Nazara/VulkanRenderer/VulkanDevice.hpp | 35 +++++++++++++++ .../Nazara/VulkanRenderer/VulkanDevice.inl | 12 +++++ .../Nazara/VulkanRenderer/VulkanRenderer.hpp | 4 ++ .../Nazara/VulkanRenderer/VulkanSurface.hpp | 40 +++++++++++++++++ .../Nazara/VulkanRenderer/VulkanSurface.inl | 16 +++++++ src/Nazara/Renderer/RenderDeviceInstance.cpp | 11 +++++ src/Nazara/Renderer/RenderSurface.cpp | 11 +++++ src/Nazara/Renderer/RenderWindow.cpp | 11 ++++- src/Nazara/VulkanRenderer/VkRenderWindow.cpp | 35 +++++---------- src/Nazara/VulkanRenderer/Vulkan.cpp | 3 ++ src/Nazara/VulkanRenderer/VulkanDevice.cpp | 11 +++++ src/Nazara/VulkanRenderer/VulkanRenderer.cpp | 22 ++++++++- src/Nazara/VulkanRenderer/VulkanSurface.cpp | 45 +++++++++++++++++++ 22 files changed, 321 insertions(+), 37 deletions(-) create mode 100644 include/Nazara/Renderer/RenderDeviceInstance.hpp create mode 100644 include/Nazara/Renderer/RenderDeviceInstance.inl create mode 100644 include/Nazara/Renderer/RenderSurface.hpp create mode 100644 include/Nazara/Renderer/RenderSurface.inl create mode 100644 include/Nazara/VulkanRenderer/VulkanDevice.hpp create mode 100644 include/Nazara/VulkanRenderer/VulkanDevice.inl create mode 100644 include/Nazara/VulkanRenderer/VulkanSurface.hpp create mode 100644 include/Nazara/VulkanRenderer/VulkanSurface.inl create mode 100644 src/Nazara/Renderer/RenderDeviceInstance.cpp create mode 100644 src/Nazara/Renderer/RenderSurface.cpp create mode 100644 src/Nazara/VulkanRenderer/VulkanDevice.cpp create mode 100644 src/Nazara/VulkanRenderer/VulkanSurface.cpp diff --git a/include/Nazara/Renderer/RenderDeviceInstance.hpp b/include/Nazara/Renderer/RenderDeviceInstance.hpp new file mode 100644 index 000000000..3c019fc20 --- /dev/null +++ b/include/Nazara/Renderer/RenderDeviceInstance.hpp @@ -0,0 +1,26 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_RENDERDEVICEINSTANCE_HPP +#define NAZARA_RENDERDEVICEINSTANCE_HPP + +#include +#include + +namespace Nz +{ + ///TODO: Rename + class NAZARA_RENDERER_API RenderDeviceInstance + { + public: + RenderDeviceInstance() = default; + virtual ~RenderDeviceInstance(); + }; +} + +#include + +#endif // NAZARA_RENDERDEVICEINSTANCE_HPP diff --git a/include/Nazara/Renderer/RenderDeviceInstance.inl b/include/Nazara/Renderer/RenderDeviceInstance.inl new file mode 100644 index 000000000..68ffbd5cd --- /dev/null +++ b/include/Nazara/Renderer/RenderDeviceInstance.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ +} + +#include diff --git a/include/Nazara/Renderer/RenderSurface.hpp b/include/Nazara/Renderer/RenderSurface.hpp new file mode 100644 index 000000000..9835af794 --- /dev/null +++ b/include/Nazara/Renderer/RenderSurface.hpp @@ -0,0 +1,30 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_RENDERSURFACE_HPP +#define NAZARA_RENDERSURFACE_HPP + +#include +#include +#include + +namespace Nz +{ + ///TODO: Rename + class NAZARA_RENDERER_API RenderSurface + { + public: + RenderSurface() = default; + virtual ~RenderSurface(); + + virtual bool Create(WindowHandle handle) = 0; + virtual void Destroy() = 0; + }; +} + +#include + +#endif // NAZARA_RENDERSURFACE_HPP diff --git a/include/Nazara/Renderer/RenderSurface.inl b/include/Nazara/Renderer/RenderSurface.inl new file mode 100644 index 000000000..2d0103e88 --- /dev/null +++ b/include/Nazara/Renderer/RenderSurface.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ +} + +#include diff --git a/include/Nazara/Renderer/RenderWindow.hpp b/include/Nazara/Renderer/RenderWindow.hpp index a0d5859e4..82c80b342 100644 --- a/include/Nazara/Renderer/RenderWindow.hpp +++ b/include/Nazara/Renderer/RenderWindow.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -52,6 +53,7 @@ namespace Nz private: std::unique_ptr m_impl; Clock m_clock; + std::unique_ptr m_surface; RenderWindowParameters m_parameters; unsigned int m_framerateLimit; }; diff --git a/include/Nazara/Renderer/RenderWindowImpl.hpp b/include/Nazara/Renderer/RenderWindowImpl.hpp index 19a831773..85b1b9c36 100644 --- a/include/Nazara/Renderer/RenderWindowImpl.hpp +++ b/include/Nazara/Renderer/RenderWindowImpl.hpp @@ -16,13 +16,15 @@ namespace Nz { + class RenderSurface; + class NAZARA_RENDERER_API RenderWindowImpl { public: RenderWindowImpl() = default; virtual ~RenderWindowImpl(); - virtual bool Create(WindowHandle handle, const Vector2ui& size, const RenderWindowParameters& parameters) = 0; + virtual bool Create(RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) = 0; }; } diff --git a/include/Nazara/Renderer/RendererImpl.hpp b/include/Nazara/Renderer/RendererImpl.hpp index 758765492..0c0501e99 100644 --- a/include/Nazara/Renderer/RendererImpl.hpp +++ b/include/Nazara/Renderer/RendererImpl.hpp @@ -21,6 +21,8 @@ namespace Nz class AbstractBuffer; class Buffer; class RendererImpl; + class RenderDeviceInstance; + class RenderSurface; class RenderWindowImpl; using CreateRendererImplFunc = RendererImpl*(*)(); @@ -32,8 +34,11 @@ namespace Nz virtual ~RendererImpl(); virtual std::unique_ptr CreateHardwareBufferImpl(Buffer* parent, BufferType type) = 0; + virtual std::unique_ptr CreateRenderSurfaceImpl() = 0; virtual std::unique_ptr CreateRenderWindowImpl() = 0; + virtual std::unique_ptr InstanciateRenderDevice(std::size_t deviceIndex) = 0; + virtual bool IsBetterThan(const RendererImpl* other) const = 0; virtual RenderAPI QueryAPI() const = 0; diff --git a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp index 7a3246984..0ac221adc 100644 --- a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp +++ b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp @@ -39,13 +39,12 @@ namespace Nz void BuildPreRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) override; void BuildPostRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) override; - bool Create(WindowHandle handle, const Vector2ui& size, const RenderWindowParameters& parameters) override; + bool Create(RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) override; inline const Vk::Framebuffer& GetFrameBuffer(UInt32 imageIndex) const override; inline UInt32 GetFramebufferCount() const; inline const Vk::DeviceHandle& GetDevice() const; inline UInt32 GetPresentableFamilyQueue() const; - inline const Vk::Surface& GetSurface() const; inline const Vk::Swapchain& GetSwapchain() const; void Present(UInt32 imageIndex) override; @@ -56,7 +55,7 @@ namespace Nz private: bool SetupDepthBuffer(const Vector2ui& size); bool SetupRenderPass(const Vector2ui& size); - bool SetupSwapchain(const Vector2ui& size); + bool SetupSwapchain(Vk::Surface& surface, const Vector2ui& size); Clock m_clock; VkColorSpaceKHR m_colorSpace; @@ -69,7 +68,6 @@ namespace Nz Vk::Image m_depthBuffer; Vk::ImageView m_depthBufferView; Vk::Queue m_presentQueue; - Vk::Surface m_surface; Vk::Swapchain m_swapchain; UInt32 m_presentableFamilyQueue; }; diff --git a/include/Nazara/VulkanRenderer/VkRenderWindow.inl b/include/Nazara/VulkanRenderer/VkRenderWindow.inl index 0142c1d03..e207cc89a 100644 --- a/include/Nazara/VulkanRenderer/VkRenderWindow.inl +++ b/include/Nazara/VulkanRenderer/VkRenderWindow.inl @@ -27,11 +27,6 @@ namespace Nz return m_presentableFamilyQueue; } - inline const Vk::Surface& VkRenderWindow::GetSurface() const - { - return m_surface; - } - inline const Vk::Swapchain& VkRenderWindow::GetSwapchain() const { return m_swapchain; diff --git a/include/Nazara/VulkanRenderer/VulkanDevice.hpp b/include/Nazara/VulkanRenderer/VulkanDevice.hpp new file mode 100644 index 000000000..1e4344232 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanDevice.hpp @@ -0,0 +1,35 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VULKANDEVICE_HPP +#define NAZARA_VULKANRENDERER_VULKANDEVICE_HPP + +#include +#include +#include +#include + +namespace Nz +{ + //TODO: Move all the software stuff to the Renderer + + class NAZARA_VULKANRENDERER_API VulkanDevice : public RenderDeviceInstance + { + public: + VulkanDevice(Vk::DeviceHandle device); + ~VulkanDevice(); + + VulkanDevice& operator=(const VulkanDevice&) = delete; + VulkanDevice& operator=(VulkanDevice&&) = delete; ///TODO + + private: + Vk::DeviceHandle m_device; + }; +} + +#include + +#endif // NAZARA_VULKANRENDERER_VULKANDEVICE_HPP diff --git a/include/Nazara/VulkanRenderer/VulkanDevice.inl b/include/Nazara/VulkanRenderer/VulkanDevice.inl new file mode 100644 index 000000000..3a751f921 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanDevice.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ +} + +#include diff --git a/include/Nazara/VulkanRenderer/VulkanRenderer.hpp b/include/Nazara/VulkanRenderer/VulkanRenderer.hpp index 38dc8540f..74a2075a9 100644 --- a/include/Nazara/VulkanRenderer/VulkanRenderer.hpp +++ b/include/Nazara/VulkanRenderer/VulkanRenderer.hpp @@ -25,8 +25,12 @@ namespace Nz VulkanRenderer() = default; ~VulkanRenderer(); + std::unique_ptr CreateHardwareBufferImpl(Buffer* parent, BufferType type) override; + std::unique_ptr CreateRenderSurfaceImpl() override; std::unique_ptr CreateRenderWindowImpl() override; + std::unique_ptr InstanciateRenderDevice(std::size_t deviceIndex) override; + bool IsBetterThan(const RendererImpl* other) const override; RenderAPI QueryAPI() const override; diff --git a/include/Nazara/VulkanRenderer/VulkanSurface.hpp b/include/Nazara/VulkanRenderer/VulkanSurface.hpp new file mode 100644 index 000000000..e86d2fc2e --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanSurface.hpp @@ -0,0 +1,40 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_SURFACE_HPP +#define NAZARA_VULKANRENDERER_SURFACE_HPP + +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_VULKANRENDERER_API VulkanSurface : public RenderSurface + { + public: + VulkanSurface(); + VulkanSurface(const VulkanSurface&) = delete; + VulkanSurface(VulkanSurface&&) = delete; ///TODO + virtual ~VulkanSurface(); + + bool Create(WindowHandle handle) override; + void Destroy() override; + + inline Vk::Surface& GetSurface(); + + VulkanSurface& operator=(const VulkanSurface&) = delete; + VulkanSurface& operator=(VulkanSurface&&) = delete; ///TODO + + private: + Vk::Surface m_surface; + }; +} + +#include + +#endif // NAZARA_VULKANRENDERER_SURFACE_HPP diff --git a/include/Nazara/VulkanRenderer/VulkanSurface.inl b/include/Nazara/VulkanRenderer/VulkanSurface.inl new file mode 100644 index 000000000..04dfc2968 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanSurface.inl @@ -0,0 +1,16 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline Vk::Surface& VulkanSurface::GetSurface() + { + return m_surface; + } +} + +#include diff --git a/src/Nazara/Renderer/RenderDeviceInstance.cpp b/src/Nazara/Renderer/RenderDeviceInstance.cpp new file mode 100644 index 000000000..6d8078cfb --- /dev/null +++ b/src/Nazara/Renderer/RenderDeviceInstance.cpp @@ -0,0 +1,11 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + RenderDeviceInstance::~RenderDeviceInstance() = default; +} diff --git a/src/Nazara/Renderer/RenderSurface.cpp b/src/Nazara/Renderer/RenderSurface.cpp new file mode 100644 index 000000000..e48c69f6c --- /dev/null +++ b/src/Nazara/Renderer/RenderSurface.cpp @@ -0,0 +1,11 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + RenderSurface::~RenderSurface() = default; +} diff --git a/src/Nazara/Renderer/RenderWindow.cpp b/src/Nazara/Renderer/RenderWindow.cpp index 56626386e..117caaadf 100644 --- a/src/Nazara/Renderer/RenderWindow.cpp +++ b/src/Nazara/Renderer/RenderWindow.cpp @@ -35,14 +35,22 @@ namespace Nz bool RenderWindow::OnWindowCreated() { + auto surface = Renderer::GetRendererImpl()->CreateRenderSurfaceImpl(); + if (!surface->Create(GetHandle())) + { + NazaraError("Failed to create render surface: " + Error::GetLastError()); + return false; + } + auto impl = Renderer::GetRendererImpl()->CreateRenderWindowImpl(); - if (!impl->Create(GetHandle(), Vector2ui(GetWidth(), GetHeight()), m_parameters)) + if (!impl->Create(surface.get(), Vector2ui(GetWidth(), GetHeight()), m_parameters)) { NazaraError("Failed to create render window implementation: " + Error::GetLastError()); return false; } m_impl = std::move(impl); + m_surface = std::move(surface); m_clock.Restart(); @@ -52,6 +60,7 @@ namespace Nz void RenderWindow::OnWindowDestroy() { m_impl.reset(); + m_surface.reset(); } void RenderWindow::OnWindowResized() diff --git a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp index b9a215318..524facc29 100644 --- a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp +++ b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -14,7 +15,6 @@ namespace Nz { VkRenderWindow::VkRenderWindow() : - m_surface(Nz::Vulkan::GetInstance()), m_physicalDevice(nullptr), m_depthStencilFormat(VK_FORMAT_MAX_ENUM) { @@ -27,7 +27,6 @@ namespace Nz m_renderPass.Destroy(); m_swapchain.Destroy(); - m_surface.Destroy(); } bool VkRenderWindow::Acquire(UInt32* imageIndex) const @@ -65,25 +64,13 @@ namespace Nz //commandBuffer.SetImageLayout(m_swapchain.GetBuffer(imageIndex).image, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR); } - bool VkRenderWindow::Create(WindowHandle handle, const Vector2ui& size, const RenderWindowParameters& parameters) + bool VkRenderWindow::Create(RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) { - #if defined(NAZARA_PLATFORM_WINDOWS) - HWND winHandle = reinterpret_cast(handle); - HINSTANCE instance = reinterpret_cast(GetWindowLongPtrW(winHandle, GWLP_HINSTANCE)); - bool success = m_surface.Create(instance, winHandle); - #else - #error This OS is not supported by Vulkan - #endif - - if (!success) - { - NazaraError("Failed to create Vulkan surface"); - return false; - } - m_physicalDevice = Vulkan::GetPhysicalDevices()[0].device; - m_device = Vulkan::SelectDevice(m_physicalDevice, m_surface, &m_presentableFamilyQueue); + Vk::Surface& vulkanSurface = static_cast(surface)->GetSurface(); + + m_device = Vulkan::SelectDevice(m_physicalDevice, vulkanSurface, &m_presentableFamilyQueue); if (!m_device) { NazaraError("Failed to get compatible Vulkan device"); @@ -93,7 +80,7 @@ namespace Nz m_presentQueue = m_device->GetQueue(m_presentableFamilyQueue, 0); std::vector surfaceFormats; - if (!m_surface.GetFormats(m_physicalDevice, &surfaceFormats)) + if (!vulkanSurface.GetFormats(m_physicalDevice, &surfaceFormats)) { NazaraError("Failed to query supported surface formats"); return false; @@ -159,7 +146,7 @@ namespace Nz } } - if (!SetupSwapchain(size)) + if (!SetupSwapchain(vulkanSurface, size)) { NazaraError("Failed to create swapchain"); return false; @@ -369,10 +356,10 @@ namespace Nz return m_renderPass.Create(m_device, createInfo); } - bool VkRenderWindow::SetupSwapchain(const Vector2ui& size) + bool VkRenderWindow::SetupSwapchain(Vk::Surface& surface, const Vector2ui& size) { VkSurfaceCapabilitiesKHR surfaceCapabilities; - if (!m_surface.GetCapabilities(m_physicalDevice, &surfaceCapabilities)) + if (!surface.GetCapabilities(m_physicalDevice, &surfaceCapabilities)) { NazaraError("Failed to query surface capabilities"); return false; @@ -392,7 +379,7 @@ namespace Nz extent = surfaceCapabilities.currentExtent; std::vector presentModes; - if (!m_surface.GetPresentModes(m_physicalDevice, &presentModes)) + if (!surface.GetPresentModes(m_physicalDevice, &presentModes)) { NazaraError("Failed to query supported present modes"); return false; @@ -415,7 +402,7 @@ namespace Nz VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR, nullptr, 0, - m_surface, + surface, imageCount, m_colorFormat, m_colorSpace, diff --git a/src/Nazara/VulkanRenderer/Vulkan.cpp b/src/Nazara/VulkanRenderer/Vulkan.cpp index ce43249d3..3cab39710 100644 --- a/src/Nazara/VulkanRenderer/Vulkan.cpp +++ b/src/Nazara/VulkanRenderer/Vulkan.cpp @@ -392,7 +392,10 @@ namespace Nz } if (presentableQueueFamilyIndex != UINT32_MAX) + { *presentableFamilyQueue = presentableQueueFamilyIndex; + return device.CreateHandle(); + } } } diff --git a/src/Nazara/VulkanRenderer/VulkanDevice.cpp b/src/Nazara/VulkanRenderer/VulkanDevice.cpp new file mode 100644 index 000000000..bec1b3adb --- /dev/null +++ b/src/Nazara/VulkanRenderer/VulkanDevice.cpp @@ -0,0 +1,11 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + VulkanDevice::~VulkanDevice() = default; +} diff --git a/src/Nazara/VulkanRenderer/VulkanRenderer.cpp b/src/Nazara/VulkanRenderer/VulkanRenderer.cpp index 861557507..7485be521 100644 --- a/src/Nazara/VulkanRenderer/VulkanRenderer.cpp +++ b/src/Nazara/VulkanRenderer/VulkanRenderer.cpp @@ -4,6 +4,9 @@ #include #include +#include +#include +#include #include #include #include @@ -15,11 +18,26 @@ namespace Nz Vulkan::Uninitialize(); } + std::unique_ptr VulkanRenderer::CreateHardwareBufferImpl(Buffer* parent, BufferType type) + { + return nullptr; //< TODO + } + + std::unique_ptr VulkanRenderer::CreateRenderSurfaceImpl() + { + return std::make_unique(); + } + std::unique_ptr VulkanRenderer::CreateRenderWindowImpl() { return std::make_unique(); } + std::unique_ptr VulkanRenderer::InstanciateRenderDevice(std::size_t deviceIndex) + { + return std::unique_ptr(); + } + bool VulkanRenderer::IsBetterThan(const RendererImpl* other) const { if (other->QueryAPI() == RenderAPI_Vulkan && QueryAPIVersion() < other->QueryAPIVersion()) @@ -41,14 +59,14 @@ namespace Nz String VulkanRenderer::QueryAPIString() const { StringStream ss; - ss << "Vulkan renderer " << VK_VERSION_MAJOR(m_apiVersion) << '.' << VK_VERSION_MINOR(m_apiVersion) << '.' << VK_VERSION_PATCH(m_apiVersion); + ss << "Vulkan renderer " << VK_VERSION_MAJOR(APIVersion) << '.' << VK_VERSION_MINOR(APIVersion) << '.' << VK_VERSION_PATCH(APIVersion); return ss; } UInt32 VulkanRenderer::QueryAPIVersion() const { - return m_apiVersion; + return APIVersion; } std::vector VulkanRenderer::QueryRenderDevices() const diff --git a/src/Nazara/VulkanRenderer/VulkanSurface.cpp b/src/Nazara/VulkanRenderer/VulkanSurface.cpp new file mode 100644 index 000000000..c7cd7f3d6 --- /dev/null +++ b/src/Nazara/VulkanRenderer/VulkanSurface.cpp @@ -0,0 +1,45 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + VulkanSurface::VulkanSurface() : + m_surface(Vulkan::GetInstance()) + { + } + + VulkanSurface::~VulkanSurface() = default; + + bool VulkanSurface::Create(WindowHandle handle) + { + bool success = false; + #if defined(NAZARA_PLATFORM_WINDOWS) + { + HWND winHandle = reinterpret_cast(handle); + HINSTANCE instance = reinterpret_cast(GetWindowLongPtrW(winHandle, GWLP_HINSTANCE)); + + success = m_surface.Create(instance, winHandle); + } + #else + #error This OS is not supported by Vulkan + #endif + + if (!success) + { + NazaraError("Failed to create Vulkan surface: " + TranslateVulkanError(m_surface.GetLastErrorCode())); + return false; + } + + return true; + } + + void VulkanSurface::Destroy() + { + m_surface.Destroy(); + } +} From 2323060f30e25ce6597cb3f7dd4259d68dbf88f8 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 4 Jul 2017 23:24:23 +0200 Subject: [PATCH 064/316] Remove unused code --- include/Nazara/Renderer/RenderWindow.hpp | 4 - src/Nazara/Renderer/HardwareBuffer.cpp | 138 ----------------------- src/Nazara/Renderer/HardwareBuffer.hpp | 44 -------- 3 files changed, 186 deletions(-) delete mode 100644 src/Nazara/Renderer/HardwareBuffer.cpp delete mode 100644 src/Nazara/Renderer/HardwareBuffer.hpp diff --git a/include/Nazara/Renderer/RenderWindow.hpp b/include/Nazara/Renderer/RenderWindow.hpp index 8f2b494e9..bd8597c74 100644 --- a/include/Nazara/Renderer/RenderWindow.hpp +++ b/include/Nazara/Renderer/RenderWindow.hpp @@ -26,10 +26,6 @@ namespace Nz inline RenderWindow(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default, const RenderWindowParameters& parameters = RenderWindowParameters()); inline RenderWindow(WindowHandle handle, const RenderWindowParameters& parameters = RenderWindowParameters()); - RenderWindow(const RenderWindow&) = delete; - RenderWindow(RenderWindow&&) = delete; ///TODO - virtual ~RenderWindow(); - inline bool Create(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default, const RenderWindowParameters& parameters = RenderWindowParameters()); inline bool Create(WindowHandle handle, const RenderWindowParameters& parameters = RenderWindowParameters()); diff --git a/src/Nazara/Renderer/HardwareBuffer.cpp b/src/Nazara/Renderer/HardwareBuffer.cpp deleted file mode 100644 index 52bc339c2..000000000 --- a/src/Nazara/Renderer/HardwareBuffer.cpp +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - HardwareBuffer::HardwareBuffer(Buffer* parent, BufferType type) : - m_buffer(0), - m_type(type), - m_parent(parent) - { - } - - HardwareBuffer::~HardwareBuffer() - { - if (m_buffer) - { - Context::EnsureContext(); - - OpenGL::DeleteBuffer(m_type, m_buffer); - } - } - - bool HardwareBuffer::Initialize(UInt32 size, BufferUsageFlags usage) - { - Context::EnsureContext(); - - m_buffer = 0; - glGenBuffers(1, &m_buffer); - - OpenGL::BindBuffer(m_type, m_buffer); - glBufferData(OpenGL::BufferTarget[m_type], size, nullptr, (usage & BufferUsage_Dynamic) ? GL_STREAM_DRAW : GL_STATIC_DRAW); - - return true; - } - - bool HardwareBuffer::Fill(const void* data, UInt32 offset, UInt32 size) - { - Context::EnsureContext(); - - UInt32 totalSize = m_parent->GetSize(); - - bool forceDiscard = (size == totalSize); - - OpenGL::BindBuffer(m_type, m_buffer); - - // It seems glBuffer(Sub)Data performs faster than glMapBuffer under a specific range - // http://www.stevestreeting.com/2007/03/17/glmapbuffer-vs-glbuffersubdata-the-return/ - if (size < 32*1024) - { - // http://www.opengl.org/wiki/Buffer_Object_Streaming - if (forceDiscard) - glBufferData(OpenGL::BufferTarget[m_type], totalSize, nullptr, (m_parent->GetUsage() & BufferUsage_Dynamic) ? GL_STREAM_DRAW : GL_STATIC_DRAW); // Discard - - glBufferSubData(OpenGL::BufferTarget[m_type], offset, size, data); - } - else - { - void* ptr = Map((forceDiscard) ? BufferAccess_DiscardAndWrite : BufferAccess_WriteOnly, offset, size); - if (!ptr) - { - NazaraError("Failed to map buffer"); - return false; - } - - std::memcpy(ptr, data, size); - - Unmap(); - } - - return true; - } - - DataStorage HardwareBuffer::GetStorage() const - { - return DataStorage_Hardware; - } - - void* HardwareBuffer::Map(BufferAccess access, UInt32 offset, UInt32 size) - { - Context::EnsureContext(); - - OpenGL::BindBuffer(m_type, m_buffer); - - if (glMapBufferRange) - return glMapBufferRange(OpenGL::BufferTarget[m_type], offset, size, OpenGL::BufferLockRange[access]); - else - { - // http://www.opengl.org/wiki/Buffer_Object_Streaming - if (access == BufferAccess_DiscardAndWrite) - glBufferData(OpenGL::BufferTarget[m_type], m_parent->GetSize(), nullptr, (m_parent->GetUsage() & BufferUsage_Dynamic) ? GL_STREAM_DRAW : GL_STATIC_DRAW); // Discard - - UInt8* ptr = static_cast(glMapBuffer(OpenGL::BufferTarget[m_type], OpenGL::BufferLock[access])); - if (ptr) - ptr += offset; - - return ptr; - } - } - - bool HardwareBuffer::Unmap() - { - Context::EnsureContext(); - - OpenGL::BindBuffer(m_type, m_buffer); - - if (glUnmapBuffer(OpenGL::BufferTarget[m_type]) != GL_TRUE) - { - // An error occured, we have to reset the buffer - glBufferData(OpenGL::BufferTarget[m_type], m_parent->GetSize(), nullptr, (m_parent->GetUsage() & BufferUsage_Dynamic) ? GL_STREAM_DRAW : GL_STATIC_DRAW); - - NazaraError("Failed to unmap buffer, reinitialising content... (OpenGL error: 0x" + String::Number(glGetError(), 16) + ')'); - return false; - } - - return true; - } - - void HardwareBuffer::Bind() const - { - OpenGL::BindBuffer(m_type, m_buffer); - } - - GLuint HardwareBuffer::GetOpenGLID() const - { - return m_buffer; - } -} diff --git a/src/Nazara/Renderer/HardwareBuffer.hpp b/src/Nazara/Renderer/HardwareBuffer.hpp deleted file mode 100644 index d9cb26368..000000000 --- a/src/Nazara/Renderer/HardwareBuffer.hpp +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_HARDWAREBUFFER_HPP -#define NAZARA_HARDWAREBUFFER_HPP - -#include -#include -#include - -namespace Nz -{ - class Buffer; - - class HardwareBuffer : public AbstractBuffer - { - public: - HardwareBuffer(Buffer* parent, BufferType type); - ~HardwareBuffer(); - - bool Fill(const void* data, UInt32 offset, UInt32 size) override; - - bool Initialize(unsigned int size, BufferUsageFlags usage) override; - - DataStorage GetStorage() const override; - - void* Map(BufferAccess access, UInt32 offset = 0, UInt32 size = 0) override; - bool Unmap() override; - - // Fonctions OpenGL - void Bind() const; - GLuint GetOpenGLID() const; - - private: - GLuint m_buffer; - BufferType m_type; - Buffer* m_parent; - }; -} - -#endif // NAZARA_HARDWAREBUFFER_HPP From 8cdd922177196e6307bb1827dd197d3ab734f19e Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 4 Jul 2017 23:41:08 +0200 Subject: [PATCH 066/316] VulkanRenderer: Handle new errors cases --- src/Nazara/VulkanRenderer/Utils_VulkanRenderer.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Nazara/VulkanRenderer/Utils_VulkanRenderer.cpp b/src/Nazara/VulkanRenderer/Utils_VulkanRenderer.cpp index 9d81fb4e5..4df58b4cf 100644 --- a/src/Nazara/VulkanRenderer/Utils_VulkanRenderer.cpp +++ b/src/Nazara/VulkanRenderer/Utils_VulkanRenderer.cpp @@ -35,7 +35,7 @@ namespace Nz case VK_ERROR_OUT_OF_DEVICE_MEMORY: return "A device memory allocation has failed"; - + case VK_ERROR_INITIALIZATION_FAILED: return "Initialization of an object could not be completed for implementation-specific reasons"; @@ -87,6 +87,12 @@ namespace Nz case VK_ERROR_INVALID_SHADER_NV: return "One or more shaders failed to compile or link"; + case VK_ERROR_OUT_OF_POOL_MEMORY_KHR: + return "A requested pool allocation has failed"; + + case VK_ERROR_INVALID_EXTERNAL_HANDLE_KHX: + return "An external handle is not a valid handle of the specified type"; + default: break; } From 29cad19253f999f141760fb11dc26e226f130821 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 4 Jul 2017 23:57:43 +0200 Subject: [PATCH 067/316] Fix some compilation errors --- src/Nazara/VulkanRenderer/Vulkan.cpp | 20 ++++++++++---------- src/Nazara/VulkanRenderer/VulkanRenderer.cpp | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Nazara/VulkanRenderer/Vulkan.cpp b/src/Nazara/VulkanRenderer/Vulkan.cpp index 3cab39710..65351a20f 100644 --- a/src/Nazara/VulkanRenderer/Vulkan.cpp +++ b/src/Nazara/VulkanRenderer/Vulkan.cpp @@ -62,16 +62,16 @@ namespace Nz parameters.GetStringParameter("VkAppInfo_OverrideEngineName", &engineName); bool bParam; - int iParam; + long long iParam; if (parameters.GetIntegerParameter("VkAppInfo_OverrideAPIVersion", &iParam)) - apiVersion = iParam; + apiVersion = static_cast(iParam); if (parameters.GetIntegerParameter("VkAppInfo_OverrideApplicationVersion", &iParam)) - appVersion = iParam; + appVersion = static_cast(iParam); if (parameters.GetIntegerParameter("VkAppInfo_OverrideEngineVersion", &iParam)) - engineVersion = iParam; + engineVersion = static_cast(iParam); VkApplicationInfo appInfo = { VK_STRUCTURE_TYPE_APPLICATION_INFO, @@ -100,7 +100,7 @@ namespace Nz if (parameters.GetIntegerParameter("VkInstanceInfo_EnabledLayerCount", &iParam)) { additionalLayers.reserve(iParam); - for (int i = 0; i < iParam; ++i) + for (long long i = 0; i < iParam; ++i) { Nz::String parameterName = "VkInstanceInfo_EnabledLayer" + String::Number(i); Nz::String layer; @@ -171,13 +171,13 @@ namespace Nz UInt32(enabledExtensions.size()), enabledExtensions.data() }; - + if (!s_instance.Create(instanceInfo)) { NazaraError("Failed to create instance"); return false; } - + std::vector physDevices; if (!s_instance.EnumeratePhysicalDevices(&physDevices)) { @@ -299,7 +299,7 @@ namespace Nz std::vector enabledExtensions; bool bParam; - int iParam; + long long iParam; if (!s_initializationParameters.GetBooleanParameter("VkDeviceInfo_OverrideEnabledLayers", &bParam) || !bParam) { @@ -310,7 +310,7 @@ namespace Nz if (s_initializationParameters.GetIntegerParameter("VkDeviceInfo_EnabledLayerCount", &iParam)) { additionalLayers.reserve(iParam); - for (int i = 0; i < iParam; ++i) + for (long long i = 0; i < iParam; ++i) { Nz::String parameterName = "VkDeviceInfo_EnabledLayer" + String::Number(i); Nz::String layer; @@ -330,7 +330,7 @@ namespace Nz std::vector additionalExtensions; // Just to keep the String alive if (s_initializationParameters.GetIntegerParameter("VkDeviceInfo_EnabledExtensionCount", &iParam)) { - for (int i = 0; i < iParam; ++i) + for (long long i = 0; i < iParam; ++i) { Nz::String parameterName = "VkDeviceInfo_EnabledExtension" + String::Number(i); Nz::String extension; diff --git a/src/Nazara/VulkanRenderer/VulkanRenderer.cpp b/src/Nazara/VulkanRenderer/VulkanRenderer.cpp index 7485be521..3db104ee6 100644 --- a/src/Nazara/VulkanRenderer/VulkanRenderer.cpp +++ b/src/Nazara/VulkanRenderer/VulkanRenderer.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +//#include #include #include #include @@ -78,7 +78,7 @@ namespace Nz { RenderDevice device; device.name = physDevice.properties.deviceName; - + switch (physDevice.properties.deviceType) { case VK_PHYSICAL_DEVICE_TYPE_CPU: From 5b922cf52f15442dd081076ea6e28af09a22368e Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 6 Aug 2017 12:13:08 +0200 Subject: [PATCH 068/316] Vulkan: Add buffer placeholder --- include/Nazara/Renderer/RendererImpl.hpp | 2 +- .../Nazara/VulkanRenderer/VulkanBuffer.hpp | 49 +++++++++++++++++++ .../Nazara/VulkanRenderer/VulkanBuffer.inl | 16 ++++++ src/Nazara/VulkanRenderer/VulkanBuffer.cpp | 37 ++++++++++++++ src/Nazara/VulkanRenderer/VulkanRenderer.cpp | 4 +- 5 files changed, 105 insertions(+), 3 deletions(-) create mode 100644 include/Nazara/VulkanRenderer/VulkanBuffer.hpp create mode 100644 include/Nazara/VulkanRenderer/VulkanBuffer.inl create mode 100644 src/Nazara/VulkanRenderer/VulkanBuffer.cpp diff --git a/include/Nazara/Renderer/RendererImpl.hpp b/include/Nazara/Renderer/RendererImpl.hpp index 0c0501e99..38b043980 100644 --- a/include/Nazara/Renderer/RendererImpl.hpp +++ b/include/Nazara/Renderer/RendererImpl.hpp @@ -13,12 +13,12 @@ #include #include #include +#include #include #include namespace Nz { - class AbstractBuffer; class Buffer; class RendererImpl; class RenderDeviceInstance; diff --git a/include/Nazara/VulkanRenderer/VulkanBuffer.hpp b/include/Nazara/VulkanRenderer/VulkanBuffer.hpp new file mode 100644 index 000000000..597cc7236 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanBuffer.hpp @@ -0,0 +1,49 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_BUFFER_HPP +#define NAZARA_VULKANRENDERER_BUFFER_HPP + +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + //TODO: Move all the software stuff to the Renderer + + class NAZARA_VULKANRENDERER_API VulkanBuffer : public AbstractBuffer + { + public: + inline VulkanBuffer(Buffer* parent, BufferType type); + VulkanBuffer(const VulkanBuffer&) = delete; + VulkanBuffer(VulkanBuffer&&) = delete; ///TODO + virtual ~VulkanBuffer(); + + bool Fill(const void* data, UInt32 offset, UInt32 size) override; + + bool Initialize(UInt32 size, BufferUsageFlags usage) override; + + DataStorage GetStorage() const override; + + void* Map(BufferAccess access, UInt32 offset = 0, UInt32 size = 0) override; + bool Unmap() override; + + VulkanBuffer& operator=(const VulkanBuffer&) = delete; + VulkanBuffer& operator=(VulkanBuffer&&) = delete; ///TODO + + private: + BufferUsageFlags m_usage; + SoftwareBuffer m_softwareData; + }; +} + +#include + +#endif // NAZARA_VULKANRENDERER_BUFFER_HPP diff --git a/include/Nazara/VulkanRenderer/VulkanBuffer.inl b/include/Nazara/VulkanRenderer/VulkanBuffer.inl new file mode 100644 index 000000000..7638ebb80 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanBuffer.inl @@ -0,0 +1,16 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline VulkanBuffer::VulkanBuffer(Buffer* parent, BufferType type) : + m_softwareData(parent, type) + { + } +} + +#include diff --git a/src/Nazara/VulkanRenderer/VulkanBuffer.cpp b/src/Nazara/VulkanRenderer/VulkanBuffer.cpp new file mode 100644 index 000000000..530c345b4 --- /dev/null +++ b/src/Nazara/VulkanRenderer/VulkanBuffer.cpp @@ -0,0 +1,37 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + VulkanBuffer::~VulkanBuffer() = default; + + bool VulkanBuffer::Fill(const void* data, UInt32 offset, UInt32 size) + { + return m_softwareData.Fill(data, offset, size); + } + + bool VulkanBuffer::Initialize(UInt32 size, BufferUsageFlags usage) + { + m_usage = usage; + return m_softwareData.Initialize(size, usage); + } + + DataStorage VulkanBuffer::GetStorage() const + { + return DataStorage_Hardware; + } + + void* VulkanBuffer::Map(BufferAccess access, UInt32 offset, UInt32 size) + { + return m_softwareData.Map(access, offset, size); + } + + bool VulkanBuffer::Unmap() + { + return m_softwareData.Unmap(); + } +} diff --git a/src/Nazara/VulkanRenderer/VulkanRenderer.cpp b/src/Nazara/VulkanRenderer/VulkanRenderer.cpp index 3db104ee6..57db953d4 100644 --- a/src/Nazara/VulkanRenderer/VulkanRenderer.cpp +++ b/src/Nazara/VulkanRenderer/VulkanRenderer.cpp @@ -5,7 +5,7 @@ #include #include #include -//#include +#include #include #include #include @@ -20,7 +20,7 @@ namespace Nz std::unique_ptr VulkanRenderer::CreateHardwareBufferImpl(Buffer* parent, BufferType type) { - return nullptr; //< TODO + return std::make_unique(parent, type); //< TODO } std::unique_ptr VulkanRenderer::CreateRenderSurfaceImpl() From cc0c661dd7f71f408d3afaf78241c9a2177b4895 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 6 Aug 2017 12:13:39 +0200 Subject: [PATCH 069/316] Add Vulkan demo --- examples/VulkanTest/build.lua | 19 + examples/VulkanTest/main.cpp | 784 ++++++++++++++++++++++++++++++++++ 2 files changed, 803 insertions(+) create mode 100644 examples/VulkanTest/build.lua create mode 100644 examples/VulkanTest/main.cpp diff --git a/examples/VulkanTest/build.lua b/examples/VulkanTest/build.lua new file mode 100644 index 000000000..eab5abd2c --- /dev/null +++ b/examples/VulkanTest/build.lua @@ -0,0 +1,19 @@ +EXAMPLE.Name = "VulkanTest" + +EXAMPLE.EnableConsole = true + +EXAMPLE.OsDefines.Windows = { + "VK_USE_PLATFORM_WIN32_KHR", + "WIN32_LEAN_AND_MEAN", + "NOMINMAX" +} + +EXAMPLE.Files = { + "main.cpp" +} + +EXAMPLE.Libraries = { + "NazaraCore", + "NazaraVulkanRenderer", + "NazaraUtility" +} diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp new file mode 100644 index 000000000..ab691d38b --- /dev/null +++ b/examples/VulkanTest/main.cpp @@ -0,0 +1,784 @@ +#include +#include +#include +#include +#include +#include + +VKAPI_ATTR VkBool32 VKAPI_CALL MyDebugReportCallback( + VkDebugReportFlagsEXT flags, + VkDebugReportObjectTypeEXT objectType, + uint64_t object, + size_t location, + int32_t messageCode, + const char* pLayerPrefix, + const char* pMessage, + void* pUserData) +{ + std::cerr << pMessage << std::endl; + return VK_FALSE; +} + +int main() +{ + Nz::ParameterList params; + params.SetParameter("VkInstanceInfo_EnabledExtensionCount", 1LL); + params.SetParameter("VkInstanceInfo_EnabledExtension0", "VK_EXT_debug_report"); + + params.SetParameter("VkDeviceInfo_EnabledLayerCount", 1LL); + params.SetParameter("VkDeviceInfo_EnabledLayer0", "VK_LAYER_LUNARG_standard_validation"); + params.SetParameter("VkInstanceInfo_EnabledLayerCount", 1LL); + params.SetParameter("VkInstanceInfo_EnabledLayer0", "VK_LAYER_LUNARG_standard_validation"); + + Nz::Renderer::SetParameters(params); + + Nz::Initializer loader; + if (!loader) + { + std::cout << "Failed to initialize Vulkan" << std::endl;; + return __LINE__; + } + + Nz::VulkanRenderer* rendererImpl = static_cast(Nz::Renderer::GetRendererImpl()); + + Nz::Vk::Instance& instance = Nz::Vulkan::GetInstance(); + + VkDebugReportCallbackCreateInfoEXT callbackCreateInfo; + callbackCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT; + callbackCreateInfo.pNext = nullptr; + callbackCreateInfo.flags = VK_DEBUG_REPORT_FLAG_BITS_MAX_ENUM_EXT & ~VK_DEBUG_REPORT_INFORMATION_BIT_EXT; + callbackCreateInfo.pfnCallback = &MyDebugReportCallback; + callbackCreateInfo.pUserData = nullptr; + + /* Register the callback */ + VkDebugReportCallbackEXT callback; + + instance.vkCreateDebugReportCallbackEXT(instance, &callbackCreateInfo, nullptr, &callback); + + Nz::File shaderFile; + std::vector vertexShaderCode; + std::vector fragmentShaderCode; + + if (!shaderFile.Open("resources/shaders/triangle.vert.spv", Nz::OpenMode_ReadOnly)) + { + NazaraError("Failed to open vertex shader code"); + return __LINE__; + } + + vertexShaderCode.resize(shaderFile.GetSize()); + shaderFile.Read(vertexShaderCode.data(), vertexShaderCode.size()); + + if (!shaderFile.Open("resources/shaders/triangle.frag.spv", Nz::OpenMode_ReadOnly)) + { + NazaraError("Failed to open fragment shader code"); + return __LINE__; + } + + fragmentShaderCode.resize(shaderFile.GetSize()); + shaderFile.Read(fragmentShaderCode.data(), fragmentShaderCode.size()); + + shaderFile.Close(); + + std::vector layerProperties; + if (!Nz::Vk::Loader::EnumerateInstanceLayerProperties(&layerProperties)) + { + NazaraError("Failed to enumerate instance layer properties"); + return __LINE__; + } + + for (const VkLayerProperties& properties : layerProperties) + { + std::cout << properties.layerName << ": \t" << properties.description << std::endl; + } + /* + std::vector extensionProperties; + if (!Nz::Vk::Loader::EnumerateInstanceExtensionProperties(&extensionProperties)) + { + NazaraError("Failed to enumerate instance extension properties"); + return __LINE__; + } + + for (const VkExtensionProperties& properties : extensionProperties) + std::cout << properties.extensionName << ": \t" << properties.specVersion << std::endl; + + std::vector devices; + if (!instance.EnumeratePhysicalDevices(&devices)) + { + NazaraError("Failed to enumerate physical devices"); + return __LINE__; + } + */ + Nz::RenderWindow window; + + Nz::MeshParams meshParams; + meshParams.matrix = Nz::Matrix4f::Rotate(Nz::EulerAnglesf(0.f, 90.f, 180.f)); + + Nz::Mesh drfreak; + if (!drfreak.LoadFromFile("resources/drfreak.md2", meshParams)) + { + NazaraError("Failed to load Dr. Freak"); + return __LINE__; + } + + Nz::String windowTitle = "Vulkan Test"; + if (!window.Create(Nz::VideoMode(800, 600, 32), windowTitle)) + { + std::cout << "Failed to create Window" << std::endl; + return __LINE__; + } + + Nz::VkRenderWindow& vulkanWindow = *static_cast(window.GetImpl()); + + /*VkPhysicalDeviceFeatures features; + instance.GetPhysicalDeviceFeatures(physDevice, &features); + + VkPhysicalDeviceMemoryProperties memoryProperties; + instance.GetPhysicalDeviceMemoryProperties(physDevice, &memoryProperties); + + VkPhysicalDeviceProperties properties; + instance.GetPhysicalDeviceProperties(physDevice, &properties); + + std::vector queues; + instance.GetPhysicalDeviceQueueFamilyProperties(physDevice, &queues);*/ + + Nz::Vk::DeviceHandle device = vulkanWindow.GetDevice(); + + Nz::Vk::ShaderModule vertexShader; + if (!vertexShader.Create(device, reinterpret_cast(vertexShaderCode.data()), vertexShaderCode.size())) + { + NazaraError("Failed to create vertex shader"); + return __LINE__; + } + + Nz::Vk::ShaderModule fragmentShader; + if (!fragmentShader.Create(device, reinterpret_cast(fragmentShaderCode.data()), fragmentShaderCode.size())) + { + NazaraError("Failed to create fragment shader"); + return __LINE__; + } + + VkMemoryRequirements memRequirement; + + Nz::StaticMesh* drfreakMesh = static_cast(drfreak.GetSubMesh(0)); + + const Nz::VertexBuffer* drfreakVB = drfreakMesh->GetVertexBuffer(); + const Nz::IndexBuffer* drfreakIB = drfreakMesh->GetIndexBuffer(); + + // Vertex buffer + struct Vertex { + Nz::Vector4f pos; + Nz::Vector3f col; + }; + + /*std::vector vertexBufferData = { + {{-1.f, 1.f, 0.0f}, {1.0f, 0.0f, 0.0f}}, + {{1.f, 1.f, 0.0f}, {0.0f, 1.0f, 0.0f}}, + {{0.0f, -1.f, 0.0f}, {0.0f, 0.0f, 1.0f}} + }; + + Nz::Matrix4f projection = Nz::Matrix4f::Perspective(70.f, float(window.GetWidth()) / window.GetHeight(), 1.f, 1000.f); + Nz::Matrix4f world = Nz::Matrix4f::Translate(Nz::Vector3f::Forward() * 5.f); + + for (unsigned int i = 0; i < 3; ++i) + { + Nz::Vector4f pos = vertexBufferData[i].pos; + vertexBufferData[i].pos = projection * (world * pos); + }*/ + + Nz::BufferMapper vertexMapper(drfreakVB, Nz::BufferAccess_ReadOnly); + Nz::MeshVertex* meshVertices = static_cast(vertexMapper.GetPointer()); + + std::size_t vertexCount = drfreakVB->GetVertexCount(); + + Nz::Image meshImage; + if (!meshImage.LoadFromFile("resources/drfreak.tga")) + { + NazaraError("Failed to load texture"); + return __LINE__; + } + + std::vector vertexBufferData; + vertexBufferData.reserve(vertexCount); + for (std::size_t i = 0; i < vertexCount; ++i) + { + std::size_t texX = meshVertices[i].uv.x * meshImage.GetWidth(); + std::size_t texY = meshVertices[i].uv.y * meshImage.GetHeight(); + + Nz::Color c = meshImage.GetPixelColor(texX, texY); + + Vertex vertex = { + meshVertices[i].position, + {c.r / 255.f, c.g / 255.f, c.b / 255.f} + }; + + vertexBufferData.push_back(vertex); + } + + Nz::UInt32 vertexBufferSize = static_cast(vertexBufferData.size() * sizeof(Vertex)); + + Nz::Vk::Buffer vertexBuffer; + if (!vertexBuffer.Create(device, 0, vertexBufferSize, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT)) + { + NazaraError("Failed to create vertex buffer"); + return __LINE__; + } + + memRequirement = vertexBuffer.GetMemoryRequirements(); + + Nz::Vk::DeviceMemory vertexBufferMemory; + if (!vertexBufferMemory.Create(device, memRequirement.size, memRequirement.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) + { + NazaraError("Failed to allocate vertex buffer memory"); + return __LINE__; + } + + if (!vertexBufferMemory.Map(0, vertexBufferSize)) + { + NazaraError("Failed to map vertex buffer"); + return __LINE__; + } + + std::memcpy(vertexBufferMemory.GetMappedPointer(), vertexBufferData.data(), vertexBufferSize); + + vertexBufferMemory.Unmap(); + + if (!vertexBuffer.BindBufferMemory(vertexBufferMemory)) + { + NazaraError("Failed to bind vertex buffer to its memory"); + return __LINE__; + } + + // Index buffer + Nz::IndexMapper indexMapper(drfreakIB); + + std::size_t indexCount = indexMapper.GetIndexCount(); + std::vector indexBufferData; + indexBufferData.reserve(indexCount); + + for (std::size_t i = 0; i < indexCount; ++i) + { + indexBufferData.push_back(indexMapper.Get(i)); + } + + Nz::UInt32 indexBufferSize = indexBufferData.size() * sizeof(Nz::UInt32); + + Nz::Vk::Buffer indexBuffer; + if (!indexBuffer.Create(device, 0, indexBufferSize, VK_BUFFER_USAGE_INDEX_BUFFER_BIT)) + { + NazaraError("Failed to create vertex buffer"); + return __LINE__; + } + + memRequirement = indexBuffer.GetMemoryRequirements(); + + Nz::Vk::DeviceMemory indexBufferMemory; + if (!indexBufferMemory.Create(device, memRequirement.size, memRequirement.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) + { + NazaraError("Failed to allocate vertex buffer memory"); + return __LINE__; + } + + if (!indexBufferMemory.Map(0, indexBufferSize)) + { + NazaraError("Failed to map vertex buffer"); + return __LINE__; + } + + std::memcpy(indexBufferMemory.GetMappedPointer(), indexBufferData.data(), indexBufferSize); + + indexBufferMemory.Unmap(); + + if (!indexBuffer.BindBufferMemory(indexBufferMemory)) + { + NazaraError("Failed to bind vertex buffer to its memory"); + return __LINE__; + } + + struct + { + Nz::Matrix4f projectionMatrix; + Nz::Matrix4f modelMatrix; + Nz::Matrix4f viewMatrix; + } + ubo; + + ubo.projectionMatrix = Nz::Matrix4f::Perspective(70.f, float(window.GetWidth()) / window.GetHeight(), 0.1f, 1000.f); + ubo.viewMatrix = Nz::Matrix4f::Translate(Nz::Vector3f::Backward() * 1); + ubo.modelMatrix = Nz::Matrix4f::Translate(Nz::Vector3f::Forward() * 2 + Nz::Vector3f::Right()); + + Nz::UInt32 uniformSize = sizeof(ubo); + + Nz::Vk::Buffer uniformBuffer; + if (!uniformBuffer.Create(device, 0, uniformSize, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT)) + { + NazaraError("Failed to create vertex buffer"); + return __LINE__; + } + + memRequirement = uniformBuffer.GetMemoryRequirements(); + + Nz::Vk::DeviceMemory uniformBufferMemory; + if (!uniformBufferMemory.Create(device, memRequirement.size, memRequirement.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) + { + NazaraError("Failed to allocate vertex buffer memory"); + return __LINE__; + } + + if (!uniformBufferMemory.Map(0, uniformSize)) + { + NazaraError("Failed to map vertex buffer"); + return __LINE__; + } + + std::memcpy(uniformBufferMemory.GetMappedPointer(), &ubo, uniformSize); + + uniformBufferMemory.Unmap(); + + if (!uniformBuffer.BindBufferMemory(uniformBufferMemory)) + { + NazaraError("Failed to bind uniform buffer to its memory"); + return __LINE__; + } + + + VkDescriptorSetLayoutBinding layoutBinding = {}; + layoutBinding.binding = 0; + layoutBinding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; + layoutBinding.descriptorCount = 1; + layoutBinding.stageFlags = VK_SHADER_STAGE_VERTEX_BIT; + layoutBinding.pImmutableSamplers = nullptr; + + Nz::Vk::DescriptorSetLayout descriptorLayout; + if (!descriptorLayout.Create(device, layoutBinding)) + { + NazaraError("Failed to create descriptor set layout"); + return __LINE__; + } + + VkDescriptorPoolSize poolSize; + poolSize.descriptorCount = 1; + poolSize.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; + + Nz::Vk::DescriptorPool descriptorPool; + if (!descriptorPool.Create(device, 1, poolSize, VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT)) + { + NazaraError("Failed to create descriptor pool"); + return __LINE__; + } + + Nz::Vk::DescriptorSet descriptorSet = descriptorPool.AllocateDescriptorSet(descriptorLayout); + + descriptorSet.WriteUniformDescriptor(0, uniformBuffer, 0, uniformSize); + + std::array shaderStageCreateInfo = { + { + { + VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, + nullptr, + 0, + VK_SHADER_STAGE_VERTEX_BIT, + vertexShader, + "main", + nullptr + }, + { + VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, + nullptr, + 0, + VK_SHADER_STAGE_FRAGMENT_BIT, + fragmentShader, + "main", + nullptr + } + } + }; + + VkVertexInputBindingDescription bindingDescription = { + 0, + sizeof(Vertex), + VK_VERTEX_INPUT_RATE_VERTEX + }; + + std::array attributeDescription = + { + { + { + 0, // uint32_t location + 0, // uint32_t binding; + VK_FORMAT_R32G32B32A32_SFLOAT, // VkFormat format; + 0 // uint32_t offset; + }, + { + 1, // uint32_t location + 0, // uint32_t binding; + VK_FORMAT_R32G32B32_SFLOAT, // VkFormat format; + sizeof(float) * 4 // uint32_t offset; + } + } + }; + + VkPipelineVertexInputStateCreateInfo vertex_input_state_create_info = { + VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // VkStructureType sType + nullptr, // const void *pNext + 0, // VkPipelineVertexInputStateCreateFlags flags; + 1, // uint32_t vertexBindingDescriptionCount + &bindingDescription, // const VkVertexInputBindingDescription *pVertexBindingDescriptions + Nz::UInt32(attributeDescription.size()), // uint32_t vertexAttributeDescriptionCount + attributeDescription.data() // const VkVertexInputAttributeDescription *pVertexAttributeDescriptions + }; + + VkPipelineInputAssemblyStateCreateInfo input_assembly_state_create_info = { + VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, // VkStructureType sType + nullptr, // const void *pNext + 0, // VkPipelineInputAssemblyStateCreateFlags flags + VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, // VkPrimitiveTopology topology + VK_FALSE // VkBool32 primitiveRestartEnable + }; + + VkPipelineViewportStateCreateInfo viewport_state_create_info = { + VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, // VkStructureType sType + nullptr, // const void *pNext + 0, // VkPipelineViewportStateCreateFlags flags + 1, // uint32_t viewportCount + nullptr, // const VkViewport *pViewports + 1, // uint32_t scissorCount + nullptr // const VkRect2D *pScissors + }; + + VkPipelineRasterizationStateCreateInfo rasterization_state_create_info = { + VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, // VkStructureType sType + nullptr, // const void *pNext + 0, // VkPipelineRasterizationStateCreateFlags flags + VK_FALSE, // VkBool32 depthClampEnable + VK_FALSE, // VkBool32 rasterizerDiscardEnable + VK_POLYGON_MODE_FILL, // VkPolygonMode polygonMode + VK_CULL_MODE_NONE, // VkCullModeFlags cullMode + VK_FRONT_FACE_COUNTER_CLOCKWISE, // VkFrontFace frontFace + VK_FALSE, // VkBool32 depthBiasEnable + 0.0f, // float depthBiasConstantFactor + 0.0f, // float depthBiasClamp + 0.0f, // float depthBiasSlopeFactor + 1.0f // float lineWidth + }; + + VkPipelineMultisampleStateCreateInfo multisample_state_create_info = { + VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, // VkStructureType sType + nullptr, // const void *pNext + 0, // VkPipelineMultisampleStateCreateFlags flags + VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits rasterizationSamples + VK_FALSE, // VkBool32 sampleShadingEnable + 1.0f, // float minSampleShading + nullptr, // const VkSampleMask *pSampleMask + VK_FALSE, // VkBool32 alphaToCoverageEnable + VK_FALSE // VkBool32 alphaToOneEnable + }; + + VkPipelineColorBlendAttachmentState color_blend_attachment_state = { + VK_FALSE, // VkBool32 blendEnable + VK_BLEND_FACTOR_ONE, // VkBlendFactor srcColorBlendFactor + VK_BLEND_FACTOR_ZERO, // VkBlendFactor dstColorBlendFactor + VK_BLEND_OP_ADD, // VkBlendOp colorBlendOp + VK_BLEND_FACTOR_ONE, // VkBlendFactor srcAlphaBlendFactor + VK_BLEND_FACTOR_ZERO, // VkBlendFactor dstAlphaBlendFactor + VK_BLEND_OP_ADD, // VkBlendOp alphaBlendOp + VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | // VkColorComponentFlags colorWriteMask + VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT + }; + + VkPipelineColorBlendStateCreateInfo color_blend_state_create_info = { + VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, // VkStructureType sType + nullptr, // const void *pNext + 0, // VkPipelineColorBlendStateCreateFlags flags + VK_FALSE, // VkBool32 logicOpEnable + VK_LOGIC_OP_COPY, // VkLogicOp logicOp + 1, // uint32_t attachmentCount + &color_blend_attachment_state, // const VkPipelineColorBlendAttachmentState *pAttachments + {0.0f, 0.0f, 0.0f, 0.0f} // float blendConstants[4] + }; + + VkDescriptorSetLayout descriptorSetLayout = descriptorLayout; + + VkPipelineLayoutCreateInfo layout_create_info = { + VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, // VkStructureType sType + nullptr, // const void *pNext + 0, // VkPipelineLayoutCreateFlags flags + 1U, // uint32_t setLayoutCount + &descriptorSetLayout, // const VkDescriptorSetLayout *pSetLayouts + 0, // uint32_t pushConstantRangeCount + nullptr // const VkPushConstantRange *pPushConstantRanges + }; + + Nz::Vk::PipelineLayout pipelineLayout; + pipelineLayout.Create(device, layout_create_info); + + std::array dynamicStates = { + VK_DYNAMIC_STATE_SCISSOR, + VK_DYNAMIC_STATE_VIEWPORT, + }; + + VkPipelineDynamicStateCreateInfo dynamicStateInfo = { + VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + 0, // VkPipelineDynamicStateCreateFlags flags; + Nz::UInt32(dynamicStates.size()), // uint32_t dynamicStateCount; + dynamicStates.data() // const VkDynamicState* pDynamicStates; + }; + + VkPipelineDepthStencilStateCreateInfo depthStencilInfo = { + VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + 0U, // VkPipelineDepthStencilStateCreateFlags flags; + VK_TRUE, // VkBool32 depthTestEnable; + VK_TRUE, // VkBool32 depthWriteEnable; + VK_COMPARE_OP_LESS_OR_EQUAL, // VkCompareOp depthCompareOp; + VK_FALSE, // VkBool32 depthBoundsTestEnable; + VK_FALSE, // VkBool32 stencilTestEnable; + VkStencilOpState{},// VkStencilOpState front; + VkStencilOpState{},// VkStencilOpState back; + 0.f, // float minDepthBounds; + 0.f // float maxDepthBounds; + }; + + VkGraphicsPipelineCreateInfo pipeline_create_info = { + VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, // VkStructureType sType + nullptr, // const void *pNext + 0, // VkPipelineCreateFlags flags + static_cast(shaderStageCreateInfo.size()), // uint32_t stageCount + shaderStageCreateInfo.data(), // const VkPipelineShaderStageCreateInfo *pStages + &vertex_input_state_create_info, // const VkPipelineVertexInputStateCreateInfo *pVertexInputState; + &input_assembly_state_create_info, // const VkPipelineInputAssemblyStateCreateInfo *pInputAssemblyState + nullptr, // const VkPipelineTessellationStateCreateInfo *pTessellationState + &viewport_state_create_info, // const VkPipelineViewportStateCreateInfo *pViewportState + &rasterization_state_create_info, // const VkPipelineRasterizationStateCreateInfo *pRasterizationState + &multisample_state_create_info, // const VkPipelineMultisampleStateCreateInfo *pMultisampleState + &depthStencilInfo, // const VkPipelineDepthStencilStateCreateInfo *pDepthStencilState + &color_blend_state_create_info, // const VkPipelineColorBlendStateCreateInfo *pColorBlendState + &dynamicStateInfo, // const VkPipelineDynamicStateCreateInfo *pDynamicState + pipelineLayout, // VkPipelineLayout layout + vulkanWindow.GetRenderPass(), // VkRenderPass renderPass + 0, // uint32_t subpass + VK_NULL_HANDLE, // VkPipeline basePipelineHandle + -1 // int32_t basePipelineIndex + }; + + Nz::Vk::Pipeline pipeline; + if (!pipeline.CreateGraphics(device, pipeline_create_info)) + { + NazaraError("Failed to create pipeline"); + return __LINE__; + } + + Nz::Vk::CommandPool cmdPool; + if (!cmdPool.Create(device, 0, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)) + { + NazaraError("Failed to create rendering cmd pool"); + return __LINE__; + } + + std::array clearValues; + clearValues[0].color = {1.0f, 0.8f, 0.4f, 0.0f}; + clearValues[1].depthStencil = {1.f, 0}; + + Nz::Vk::Queue graphicsQueue(device, device->GetEnabledQueues()[0].queues[0].queue); + + Nz::UInt32 imageCount = vulkanWindow.GetFramebufferCount(); + std::vector renderCmds = cmdPool.AllocateCommandBuffers(imageCount, VK_COMMAND_BUFFER_LEVEL_PRIMARY); + for (Nz::UInt32 i = 0; i < imageCount; ++i) + { + Nz::Vk::CommandBuffer& renderCmd = renderCmds[i]; + + VkRect2D renderArea = { + { // VkOffset2D offset + 0, // int32_t x + 0 // int32_t y + }, + { // VkExtent2D extent + window.GetWidth(), // int32_t width + window.GetHeight(), // int32_t height + } + }; + + VkRenderPassBeginInfo render_pass_begin_info = { + VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, // VkStructureType sType + nullptr, // const void *pNext + vulkanWindow.GetRenderPass(), // VkRenderPass renderPass + vulkanWindow.GetFrameBuffer(i), // VkFramebuffer framebuffer + renderArea, + 2U, // uint32_t clearValueCount + clearValues.data() // const VkClearValue *pClearValues + }; + + VkClearAttachment clearAttachment = { + VK_IMAGE_ASPECT_COLOR_BIT, + 0U, + clearValues[0] + }; + + VkClearAttachment clearAttachmentDepth = { + VK_IMAGE_ASPECT_DEPTH_BIT, + 0U, + clearValues[1] + }; + + VkClearRect clearRect = { + renderArea, + 0U, + 1U + }; + + renderCmd.Begin(VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT); + + vulkanWindow.BuildPreRenderCommands(i, renderCmd); + + renderCmd.BeginRenderPass(render_pass_begin_info); + //renderCmd.ClearAttachment(clearAttachment, clearRect); + //renderCmd.ClearAttachment(clearAttachmentDepth, clearRect); + renderCmd.BindIndexBuffer(indexBuffer, 0, VK_INDEX_TYPE_UINT32); + renderCmd.BindVertexBuffer(0, vertexBuffer, 0); + renderCmd.BindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, descriptorSet); + renderCmd.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); + renderCmd.SetScissor(Nz::Recti{0, 0, int(window.GetWidth()), int(window.GetHeight())}); + renderCmd.SetViewport({0.f, 0.f, float(window.GetWidth()), float(window.GetHeight())}, 0.f, 1.f); + renderCmd.DrawIndexed(indexCount); + renderCmd.EndRenderPass(); + + vulkanWindow.BuildPostRenderCommands(i, renderCmd); + + if (!renderCmd.End()) + { + NazaraError("Failed to specify render cmd"); + return __LINE__; + } + } + + Nz::Vector3f viewerPos = Nz::Vector3f::Zero(); + + Nz::EulerAnglesf camAngles(0.f, 0.f, 0.f); + Nz::Quaternionf camQuat(camAngles); + + window.EnableEventPolling(true); + + Nz::Clock secondClock; + unsigned int fps = 0; + while (window.IsOpen()) + { + bool updateUniforms = false; + + Nz::WindowEvent event; + while (window.PollEvent(&event)) + { + switch (event.type) + { + case Nz::WindowEventType_Quit: + window.Close(); + break; + + case Nz::WindowEventType_MouseMoved: // La souris a bougé + { + // Gestion de la caméra free-fly (Rotation) + float sensitivity = 0.3f; // Sensibilité de la souris + + // On modifie l'angle de la caméra grâce au déplacement relatif sur X de la souris + camAngles.yaw = Nz::NormalizeAngle(camAngles.yaw - event.mouseMove.deltaX*sensitivity); + + // Idem, mais pour éviter les problèmes de calcul de la matrice de vue, on restreint les angles + camAngles.pitch = Nz::Clamp(camAngles.pitch + event.mouseMove.deltaY*sensitivity, -89.f, 89.f); + + camQuat = camAngles; + + // Pour éviter que le curseur ne sorte de l'écran, nous le renvoyons au centre de la fenêtre + // Cette fonction est codée de sorte à ne pas provoquer d'évènement MouseMoved + Nz::Mouse::SetPosition(window.GetWidth() / 2, window.GetHeight() / 2, window); + updateUniforms = true; + break; + } + + case Nz::WindowEventType_KeyPressed: + { + switch (event.key.code) + { + case Nz::Keyboard::Up: + viewerPos += camQuat * Nz::Vector3f::Forward(); + updateUniforms = true; + break; + + case Nz::Keyboard::Down: + viewerPos += camQuat * Nz::Vector3f::Backward(); + updateUniforms = true; + break; + } + break; + } + } + } + + if (updateUniforms) + { + ubo.viewMatrix = Nz::Matrix4f::ViewMatrix(viewerPos, camAngles); + + if (!uniformBufferMemory.Map(0, uniformSize)) + { + NazaraError("Failed to map vertex buffer"); + return __LINE__; + } + + std::memcpy(uniformBufferMemory.GetMappedPointer(), &ubo, uniformSize); + + uniformBufferMemory.Unmap(); + } + + Nz::UInt32 imageIndex; + if (!vulkanWindow.Acquire(&imageIndex)) + { + std::cout << "Failed to acquire next image" << std::endl; + return EXIT_FAILURE; + } + + VkCommandBuffer renderCmdBuffer = renderCmds[imageIndex]; + VkSemaphore waitSemaphore = vulkanWindow.GetRenderSemaphore(); + + VkPipelineStageFlags wait_dst_stage_mask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; + VkSubmitInfo submit_info = { + VK_STRUCTURE_TYPE_SUBMIT_INFO, // VkStructureType sType + nullptr, // const void *pNext + 1U, // uint32_t waitSemaphoreCount + &waitSemaphore, // const VkSemaphore *pWaitSemaphores + &wait_dst_stage_mask, // const VkPipelineStageFlags *pWaitDstStageMask; + 1, // uint32_t commandBufferCount + &renderCmdBuffer, // const VkCommandBuffer *pCommandBuffers + 0, // uint32_t signalSemaphoreCount + nullptr // const VkSemaphore *pSignalSemaphores + }; + + if (!graphicsQueue.Submit(submit_info)) + return false; + + vulkanWindow.Present(imageIndex); + + // On incrémente le compteur de FPS improvisé + fps++; + + if (secondClock.GetMilliseconds() >= 1000) // Toutes les secondes + { + // Et on insère ces données dans le titre de la fenêtre + window.SetTitle(windowTitle + " - " + Nz::String::Number(fps) + " FPS"); + + /* + Note: En C++11 il est possible d'insérer de l'Unicode de façon standard, quel que soit l'encodage du fichier, + via quelque chose de similaire à u8"Cha\u00CEne de caract\u00E8res". + Cependant, si le code source est encodé en UTF-8 (Comme c'est le cas dans ce fichier), + cela fonctionnera aussi comme ceci : "Chaîne de caractères". + */ + + // Et on réinitialise le compteur de FPS + fps = 0; + + // Et on relance l'horloge pour refaire ça dans une seconde + secondClock.Restart(); + } + } + +// instance.vkDestroyDebugReportCallbackEXT(instance, callback, nullptr); + + return EXIT_SUCCESS; +} \ No newline at end of file From 4a156ab3d7856301641e093cd60568a249273a16 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 6 Aug 2017 12:14:11 +0200 Subject: [PATCH 070/316] Vulkan: Add better handling for errors --- src/Nazara/Renderer/Renderer.cpp | 6 ++++++ src/Nazara/VulkanRenderer/Vulkan.cpp | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Nazara/Renderer/Renderer.cpp b/src/Nazara/Renderer/Renderer.cpp index cc7ec3ca8..424cf0daa 100644 --- a/src/Nazara/Renderer/Renderer.cpp +++ b/src/Nazara/Renderer/Renderer.cpp @@ -83,6 +83,12 @@ namespace Nz } } + if (!chosenImpl) + { + NazaraError("No renderer found"); + return false; + } + s_rendererImpl = std::move(chosenImpl); s_rendererLib = std::move(chosenLib); diff --git a/src/Nazara/VulkanRenderer/Vulkan.cpp b/src/Nazara/VulkanRenderer/Vulkan.cpp index 65351a20f..ffc9eefc8 100644 --- a/src/Nazara/VulkanRenderer/Vulkan.cpp +++ b/src/Nazara/VulkanRenderer/Vulkan.cpp @@ -174,7 +174,7 @@ namespace Nz if (!s_instance.Create(instanceInfo)) { - NazaraError("Failed to create instance"); + NazaraError("Failed to create instance: " + TranslateVulkanError(s_instance.GetLastErrorCode())); return false; } From cd661144a0c18216de77bf14d0db6c3d9f62d311 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 6 Aug 2017 12:14:22 +0200 Subject: [PATCH 071/316] Vulkan: Fix some errors --- src/Nazara/VulkanRenderer/VkRenderWindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp index 524facc29..fe33b3183 100644 --- a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp +++ b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp @@ -48,7 +48,7 @@ namespace Nz if (m_depthStencilFormat != VK_FORMAT_MAX_ENUM) { VkImageSubresourceRange imageRange = { - VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, // VkImageAspectFlags aspectMask + VK_IMAGE_ASPECT_DEPTH_BIT, // VkImageAspectFlags aspectMask 0, // uint32_t baseMipLevel 1, // uint32_t levelCount 0, // uint32_t baseArrayLayer @@ -276,7 +276,7 @@ namespace Nz 0, // VkAttachmentDescriptionFlags flags; m_colorFormat, // VkFormat format; VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples; - VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp loadOp; + VK_ATTACHMENT_LOAD_OP_CLEAR, // VkAttachmentLoadOp loadOp; VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp; VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp; VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp; From 037274a57f5ee1b86f9ddad2c3add36401eac3f9 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 6 Aug 2017 12:14:39 +0200 Subject: [PATCH 072/316] Push vulkan shaders --- .../bin/resources/shaders/spirv-triangle.bat | 3 ++ examples/bin/resources/shaders/triangle.frag | 13 ++++++++ .../bin/resources/shaders/triangle.frag.spv | Bin 0 -> 572 bytes examples/bin/resources/shaders/triangle.vert | 28 ++++++++++++++++++ .../bin/resources/shaders/triangle.vert.spv | Bin 0 -> 1492 bytes 5 files changed, 44 insertions(+) create mode 100644 examples/bin/resources/shaders/spirv-triangle.bat create mode 100644 examples/bin/resources/shaders/triangle.frag create mode 100644 examples/bin/resources/shaders/triangle.frag.spv create mode 100644 examples/bin/resources/shaders/triangle.vert create mode 100644 examples/bin/resources/shaders/triangle.vert.spv diff --git a/examples/bin/resources/shaders/spirv-triangle.bat b/examples/bin/resources/shaders/spirv-triangle.bat new file mode 100644 index 000000000..0459876df --- /dev/null +++ b/examples/bin/resources/shaders/spirv-triangle.bat @@ -0,0 +1,3 @@ +glslangvalidator -V triangle.vert -o triangle.vert.spv +glslangvalidator -V triangle.frag -o triangle.frag.spv + diff --git a/examples/bin/resources/shaders/triangle.frag b/examples/bin/resources/shaders/triangle.frag new file mode 100644 index 000000000..404919ccd --- /dev/null +++ b/examples/bin/resources/shaders/triangle.frag @@ -0,0 +1,13 @@ +#version 450 + +#extension GL_ARB_separate_shader_objects : enable +#extension GL_ARB_shading_language_420pack : enable + +layout (location = 0) in vec3 inColor; + +layout (location = 0) out vec4 outFragColor; + +void main() +{ + outFragColor = vec4(inColor, 1.0); +} \ No newline at end of file diff --git a/examples/bin/resources/shaders/triangle.frag.spv b/examples/bin/resources/shaders/triangle.frag.spv new file mode 100644 index 0000000000000000000000000000000000000000..06ab7a2fc2398c7fe17c45bb65069587bc9af78c GIT binary patch literal 572 zcmY*V+e*Vg6dar0wAzaWeUplhLMhUUASx=Dmppj+fMsn%jMk(i>AT zjBQ4jI`JI9oyV@gCl6Jr@B?%Gcw_Q#VKZBVCV#QBFf-}%Yd9_P{~DI!BrX{GPI&|Q z(JU?X_##tdz96gKI}DwFAgi;Tl4JVix+SL>YhAD8)c>CD<$sr<^U|v>AD5h}`>6I! HmuHM0CT}od literal 0 HcmV?d00001 diff --git a/examples/bin/resources/shaders/triangle.vert b/examples/bin/resources/shaders/triangle.vert new file mode 100644 index 000000000..7447fc43a --- /dev/null +++ b/examples/bin/resources/shaders/triangle.vert @@ -0,0 +1,28 @@ +#version 450 + +#extension GL_ARB_separate_shader_objects : enable +#extension GL_ARB_shading_language_420pack : enable + +layout (location = 0) in vec4 inPos; +layout (location = 1) in vec3 inColor; + +layout (binding = 0) uniform UBO +{ + mat4 projectionMatrix; + mat4 modelMatrix; + mat4 viewMatrix; +} ubo; + +layout (location = 0) out vec3 outColor; + +out gl_PerVertex +{ + vec4 gl_Position; +}; + + +void main() +{ + outColor = inColor; + gl_Position = ubo.projectionMatrix * ubo.viewMatrix * ubo.modelMatrix * vec4(inPos.xyz, 1.0); +} diff --git a/examples/bin/resources/shaders/triangle.vert.spv b/examples/bin/resources/shaders/triangle.vert.spv new file mode 100644 index 0000000000000000000000000000000000000000..f1901f112002a793f0cc0e6d441d879b805ae652 GIT binary patch literal 1492 zcmZ9LTW`}q5QUex34uaODZOwjPQ$$rRj42&#HHmSeMr>;f>+CJtYAp($aa9o{ss6+ z{3>3MIG^J|fsLj+=j@r8o$=PIwNE>DO24M-xXD^@HDTvwU8CH)y?4D%Ui3R#k2g`w zIjeSn)aUxn9*ss7i_=X3G!$ZW?>Np`NyyyWkGuQ zDLN|he>FOalR+>HlfgI~M8Vdh%~5#t+0~V4x@KJrb<=V2Ivu8&+)~3m;$%YA)z6&p zU>F=k*@q}AqHpLL6_3wZn#V<)CW`mU9^mmWX@9@7FLkr@;YV4@ttH%%i_j|X?bU67ALxf_HH>b=ho!2!1M$r|E?nFi3QKA9cW-`@+r2hksUK-jAK1m2Z7<4rab^$Aa!qniz89PsHI{_wlbKNi z%*^08U#Waztj3j!Gi+}N{kqP$4|T~0ZdV+7dc7@k?&Kx<2lD6#{S$p@>T+Ke{4X(l z|L0GUDJZ?uLBg z=+)wU`S2Fkl25EJLqktDW%R$Vm%{yTRUABvS<&+w)n+z#WN28%-IWiA*0_5WN9=(z nQ|rErc=Vhz=kLnP*@le!p`j<{{!qqyVqVM>jPAE8J(c|dI3Hwj literal 0 HcmV?d00001 From e2248ce5439dae6e0e1a9c0f8eeceb22050abd00 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 14 Aug 2017 01:54:15 +0200 Subject: [PATCH 073/316] Vulkan demo: Improve movements --- examples/VulkanTest/main.cpp | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index ab691d38b..1cf1592d3 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -658,6 +658,7 @@ int main() window.EnableEventPolling(true); + Nz::Clock updateClock; Nz::Clock secondClock; unsigned int fps = 0; while (window.IsOpen()) @@ -692,23 +693,24 @@ int main() updateUniforms = true; break; } + } + } - case Nz::WindowEventType_KeyPressed: - { - switch (event.key.code) - { - case Nz::Keyboard::Up: - viewerPos += camQuat * Nz::Vector3f::Forward(); - updateUniforms = true; - break; + if (updateClock.GetMilliseconds() > 1000 / 60) + { + float elapsedTime = updateClock.GetSeconds(); + updateClock.Restart(); - case Nz::Keyboard::Down: - viewerPos += camQuat * Nz::Vector3f::Backward(); - updateUniforms = true; - break; - } - break; - } + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Up)) + { + viewerPos += camQuat * Nz::Vector3f::Forward() * elapsedTime; + updateUniforms = true; + } + + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Down)) + { + viewerPos += camQuat * Nz::Vector3f::Backward() * elapsedTime; + updateUniforms = true; } } From 8a55888adaccb1afa91017c07fff99516fe3b897 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 16 Sep 2017 10:35:30 +0200 Subject: [PATCH 074/316] VulkanRenderer: Fix transfer queue choice --- src/Nazara/VulkanRenderer/Vulkan.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Nazara/VulkanRenderer/Vulkan.cpp b/src/Nazara/VulkanRenderer/Vulkan.cpp index ffc9eefc8..17a1171ec 100644 --- a/src/Nazara/VulkanRenderer/Vulkan.cpp +++ b/src/Nazara/VulkanRenderer/Vulkan.cpp @@ -244,15 +244,14 @@ namespace Nz if (queueFamilies[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) { - if (graphicsQueueNodeIndex == UINT32_MAX) - graphicsQueueNodeIndex = i; - if (supportPresentation) { graphicsQueueNodeIndex = i; presentQueueNodeIndex = i; break; } + else if (graphicsQueueNodeIndex == UINT32_MAX) + graphicsQueueNodeIndex = i; } else if (supportPresentation) presentQueueNodeIndex = i; @@ -260,7 +259,7 @@ namespace Nz for (UInt32 i = 0; i < queueFamilies.size(); i++) { - if (queueFamilies[i].queueFlags & VK_QUEUE_TRANSFER_BIT) + if (queueFamilies[i].queueFlags & (VK_QUEUE_COMPUTE_BIT | VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_TRANSFER_BIT)) //< Compute and graphics queue implicitly support transfer operations { transfertQueueNodeFamily = i; if (transfertQueueNodeFamily != graphicsQueueNodeIndex) From c4edf54297e09fbcf5f561e55ff60b95accbfa83 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 16 Sep 2017 10:36:41 +0200 Subject: [PATCH 075/316] Vulkan/RenderBuffer: WIP --- include/Nazara/Renderer/RenderBuffer.hpp | 39 ++++++++++++++++++++++++ include/Nazara/Renderer/RenderBuffer.inl | 12 ++++++++ src/Nazara/Renderer/RenderBuffer.cpp | 20 ++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 include/Nazara/Renderer/RenderBuffer.hpp create mode 100644 include/Nazara/Renderer/RenderBuffer.inl create mode 100644 src/Nazara/Renderer/RenderBuffer.cpp diff --git a/include/Nazara/Renderer/RenderBuffer.hpp b/include/Nazara/Renderer/RenderBuffer.hpp new file mode 100644 index 000000000..ac1c8391d --- /dev/null +++ b/include/Nazara/Renderer/RenderBuffer.hpp @@ -0,0 +1,39 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_RENDERBUFFER_HPP +#define NAZARA_RENDERBUFFER_HPP + +#include +#include +#include + +namespace Nz +{ + class NAZARA_RENDERER_API RenderBuffer : public AbstractBuffer + { + public: + RenderBuffer() = default; + ~RenderBuffer() = default; + + virtual bool Fill(const void* data, UInt32 offset, UInt32 size) = 0; + + bool Initialize(UInt32 size, BufferUsageFlags usage) override; + + DataStorage GetStorage() const override; + + virtual void* Map(BufferAccess access, UInt32 offset = 0, UInt32 size = 0) = 0; + virtual bool Unmap() = 0; + + private: + SoftwareBuffer m_softwareBuffer; + }; + +} + +#include + +#endif // NAZARA_RENDERBUFFER_HPP diff --git a/include/Nazara/Renderer/RenderBuffer.inl b/include/Nazara/Renderer/RenderBuffer.inl new file mode 100644 index 000000000..6a207825e --- /dev/null +++ b/include/Nazara/Renderer/RenderBuffer.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ +} + +#include diff --git a/src/Nazara/Renderer/RenderBuffer.cpp b/src/Nazara/Renderer/RenderBuffer.cpp new file mode 100644 index 000000000..d0338112a --- /dev/null +++ b/src/Nazara/Renderer/RenderBuffer.cpp @@ -0,0 +1,20 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + bool RenderBuffer::Initialize(UInt32 size, BufferUsageFlags usage) + { + m_softwareBuffer.Initialize(size, usage); + return true; + } + + DataStorage Nz::RenderBuffer::GetStorage() const + { + return DataStorage::DataStorage_Hardware; + } +} From 1e190caa2c179eab60420a36b77ca82a5fdb02ce Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 24 Nov 2017 20:15:04 +0100 Subject: [PATCH 076/316] Fix compilation --- examples/VulkanTest/build.lua | 1 + examples/VulkanTest/main.cpp | 15 ++++++++------- include/Nazara/Renderer/RenderSurface.hpp | 2 +- include/Nazara/Renderer/RenderWindowImpl.hpp | 2 +- include/Nazara/VulkanRenderer.hpp | 2 ++ 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/examples/VulkanTest/build.lua b/examples/VulkanTest/build.lua index eab5abd2c..3137d0f43 100644 --- a/examples/VulkanTest/build.lua +++ b/examples/VulkanTest/build.lua @@ -14,6 +14,7 @@ EXAMPLE.Files = { EXAMPLE.Libraries = { "NazaraCore", + "NazaraPlatform", "NazaraVulkanRenderer", "NazaraUtility" } diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index 1cf1592d3..7fc74f32b 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -176,7 +176,7 @@ int main() {{0.0f, -1.f, 0.0f}, {0.0f, 0.0f, 1.0f}} }; - Nz::Matrix4f projection = Nz::Matrix4f::Perspective(70.f, float(window.GetWidth()) / window.GetHeight(), 1.f, 1000.f); + Nz::Matrix4f projection = Nz::Matrix4f::Perspective(70.f, float(windowSize.x) / windowSize.y, 1.f, 1000.f); Nz::Matrix4f world = Nz::Matrix4f::Translate(Nz::Vector3f::Forward() * 5.f); for (unsigned int i = 0; i < 3; ++i) @@ -302,7 +302,8 @@ int main() } ubo; - ubo.projectionMatrix = Nz::Matrix4f::Perspective(70.f, float(window.GetWidth()) / window.GetHeight(), 0.1f, 1000.f); + Nz::Vector2ui windowSize = window.GetSize(); + ubo.projectionMatrix = Nz::Matrix4f::Perspective(70.f, float(windowSize.x) / windowSize.y, 0.1f, 1000.f); ubo.viewMatrix = Nz::Matrix4f::Translate(Nz::Vector3f::Backward() * 1); ubo.modelMatrix = Nz::Matrix4f::Translate(Nz::Vector3f::Forward() * 2 + Nz::Vector3f::Right()); @@ -593,8 +594,8 @@ int main() 0 // int32_t y }, { // VkExtent2D extent - window.GetWidth(), // int32_t width - window.GetHeight(), // int32_t height + windowSize.x, // int32_t width + windowSize.y, // int32_t height } }; @@ -637,8 +638,8 @@ int main() renderCmd.BindVertexBuffer(0, vertexBuffer, 0); renderCmd.BindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, descriptorSet); renderCmd.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); - renderCmd.SetScissor(Nz::Recti{0, 0, int(window.GetWidth()), int(window.GetHeight())}); - renderCmd.SetViewport({0.f, 0.f, float(window.GetWidth()), float(window.GetHeight())}, 0.f, 1.f); + renderCmd.SetScissor(Nz::Recti{0, 0, int(windowSize.x), int(windowSize.y)}); + renderCmd.SetViewport({0.f, 0.f, float(windowSize.x), float(windowSize.y)}, 0.f, 1.f); renderCmd.DrawIndexed(indexCount); renderCmd.EndRenderPass(); @@ -689,7 +690,7 @@ int main() // Pour éviter que le curseur ne sorte de l'écran, nous le renvoyons au centre de la fenêtre // Cette fonction est codée de sorte à ne pas provoquer d'évènement MouseMoved - Nz::Mouse::SetPosition(window.GetWidth() / 2, window.GetHeight() / 2, window); + Nz::Mouse::SetPosition(windowSize.x / 2, windowSize.y / 2, window); updateUniforms = true; break; } diff --git a/include/Nazara/Renderer/RenderSurface.hpp b/include/Nazara/Renderer/RenderSurface.hpp index 9835af794..a452dcfbc 100644 --- a/include/Nazara/Renderer/RenderSurface.hpp +++ b/include/Nazara/Renderer/RenderSurface.hpp @@ -8,7 +8,7 @@ #define NAZARA_RENDERSURFACE_HPP #include -#include +#include #include namespace Nz diff --git a/include/Nazara/Renderer/RenderWindowImpl.hpp b/include/Nazara/Renderer/RenderWindowImpl.hpp index 85b1b9c36..d9d7f51cd 100644 --- a/include/Nazara/Renderer/RenderWindowImpl.hpp +++ b/include/Nazara/Renderer/RenderWindowImpl.hpp @@ -9,9 +9,9 @@ #include #include +#include #include #include -#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer.hpp b/include/Nazara/VulkanRenderer.hpp index 367c2a55a..ed3a8c88f 100644 --- a/include/Nazara/VulkanRenderer.hpp +++ b/include/Nazara/VulkanRenderer.hpp @@ -35,7 +35,9 @@ #include #include #include +#include #include +#include #include #endif // NAZARA_GLOBAL_VULKANRENDERER_HPP From 9b8e8042e405fda8c493c79834dada1435dc636d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Fri, 9 Mar 2018 16:47:31 +0100 Subject: [PATCH 077/316] Merge fix --- include/Nazara/Renderer/RenderSurface.hpp | 2 +- include/Nazara/Renderer/RenderWindowImpl.hpp | 2 +- include/Nazara/Renderer/RenderWindowParameters.hpp | 2 +- include/Nazara/Renderer/RendererImpl.hpp | 2 +- include/Nazara/VulkanRenderer/Utils.hpp | 2 +- include/Nazara/VulkanRenderer/VkRenderTarget.hpp | 2 +- include/Nazara/VulkanRenderer/VkRenderWindow.hpp | 2 +- include/Nazara/VulkanRenderer/Vulkan.hpp | 2 +- include/Nazara/VulkanRenderer/VulkanBuffer.hpp | 2 +- include/Nazara/VulkanRenderer/VulkanDevice.hpp | 2 +- include/Nazara/VulkanRenderer/VulkanRenderer.hpp | 2 +- include/Nazara/VulkanRenderer/VulkanSurface.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/CommandPool.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/Device.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/Framebuffer.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/Image.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/ImageView.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/Instance.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/Loader.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/Pipeline.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/PipelineCache.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/Queue.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/RenderPass.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/Semaphore.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/Surface.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp | 2 +- src/Nazara/VulkanRenderer/Export.cpp | 2 +- 36 files changed, 36 insertions(+), 36 deletions(-) diff --git a/include/Nazara/Renderer/RenderSurface.hpp b/include/Nazara/Renderer/RenderSurface.hpp index a452dcfbc..177730511 100644 --- a/include/Nazara/Renderer/RenderSurface.hpp +++ b/include/Nazara/Renderer/RenderSurface.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_RENDERSURFACE_HPP #define NAZARA_RENDERSURFACE_HPP -#include +#include #include #include diff --git a/include/Nazara/Renderer/RenderWindowImpl.hpp b/include/Nazara/Renderer/RenderWindowImpl.hpp index d9d7f51cd..eb1bb8282 100644 --- a/include/Nazara/Renderer/RenderWindowImpl.hpp +++ b/include/Nazara/Renderer/RenderWindowImpl.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_RENDERWINDOWIMPL_HPP #define NAZARA_RENDERWINDOWIMPL_HPP -#include +#include #include #include #include diff --git a/include/Nazara/Renderer/RenderWindowParameters.hpp b/include/Nazara/Renderer/RenderWindowParameters.hpp index 78645b54c..a850a944b 100644 --- a/include/Nazara/Renderer/RenderWindowParameters.hpp +++ b/include/Nazara/Renderer/RenderWindowParameters.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_RENDERWINDOWPARAMETERS_HPP #define NAZARA_RENDERWINDOWPARAMETERS_HPP -#include +#include #include #include diff --git a/include/Nazara/Renderer/RendererImpl.hpp b/include/Nazara/Renderer/RendererImpl.hpp index 38b043980..c57b41781 100644 --- a/include/Nazara/Renderer/RendererImpl.hpp +++ b/include/Nazara/Renderer/RendererImpl.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_RENDERER_RENDERERIMPL_HPP #define NAZARA_RENDERER_RENDERERIMPL_HPP -#include +#include #include #include #include diff --git a/include/Nazara/VulkanRenderer/Utils.hpp b/include/Nazara/VulkanRenderer/Utils.hpp index cd856a49c..5fa483b5c 100644 --- a/include/Nazara/VulkanRenderer/Utils.hpp +++ b/include/Nazara/VulkanRenderer/Utils.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_UTILS_VULKAN_HPP #define NAZARA_UTILS_VULKAN_HPP -#include +#include #include #include diff --git a/include/Nazara/VulkanRenderer/VkRenderTarget.hpp b/include/Nazara/VulkanRenderer/VkRenderTarget.hpp index 52e7b034d..138651475 100644 --- a/include/Nazara/VulkanRenderer/VkRenderTarget.hpp +++ b/include/Nazara/VulkanRenderer/VkRenderTarget.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_VULKANRENDERER_RENDERTARGET_HPP #define NAZARA_VULKANRENDERER_RENDERTARGET_HPP -#include +#include #include #include #include diff --git a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp index 0ac221adc..186287703 100644 --- a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp +++ b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_VULKANRENDERER_RENDERWINDOW_HPP #define NAZARA_VULKANRENDERER_RENDERWINDOW_HPP -#include +#include #include #include #include diff --git a/include/Nazara/VulkanRenderer/Vulkan.hpp b/include/Nazara/VulkanRenderer/Vulkan.hpp index 04f62637b..7701a95b0 100644 --- a/include/Nazara/VulkanRenderer/Vulkan.hpp +++ b/include/Nazara/VulkanRenderer/Vulkan.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_VULKAN_HPP #define NAZARA_VULKAN_HPP -#include +#include #include #include #include diff --git a/include/Nazara/VulkanRenderer/VulkanBuffer.hpp b/include/Nazara/VulkanRenderer/VulkanBuffer.hpp index 597cc7236..e44406152 100644 --- a/include/Nazara/VulkanRenderer/VulkanBuffer.hpp +++ b/include/Nazara/VulkanRenderer/VulkanBuffer.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_VULKANRENDERER_BUFFER_HPP #define NAZARA_VULKANRENDERER_BUFFER_HPP -#include +#include #include #include #include diff --git a/include/Nazara/VulkanRenderer/VulkanDevice.hpp b/include/Nazara/VulkanRenderer/VulkanDevice.hpp index 1e4344232..151caa80f 100644 --- a/include/Nazara/VulkanRenderer/VulkanDevice.hpp +++ b/include/Nazara/VulkanRenderer/VulkanDevice.hpp @@ -7,8 +7,8 @@ #ifndef NAZARA_VULKANRENDERER_VULKANDEVICE_HPP #define NAZARA_VULKANRENDERER_VULKANDEVICE_HPP -#include #include +#include #include #include diff --git a/include/Nazara/VulkanRenderer/VulkanRenderer.hpp b/include/Nazara/VulkanRenderer/VulkanRenderer.hpp index 74a2075a9..b7ae2b723 100644 --- a/include/Nazara/VulkanRenderer/VulkanRenderer.hpp +++ b/include/Nazara/VulkanRenderer/VulkanRenderer.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_VULKANRENDERER_HPP #define NAZARA_VULKANRENDERER_HPP -#include +#include #include #include #include diff --git a/include/Nazara/VulkanRenderer/VulkanSurface.hpp b/include/Nazara/VulkanRenderer/VulkanSurface.hpp index e86d2fc2e..56505ce8e 100644 --- a/include/Nazara/VulkanRenderer/VulkanSurface.hpp +++ b/include/Nazara/VulkanRenderer/VulkanSurface.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_VULKANRENDERER_SURFACE_HPP #define NAZARA_VULKANRENDERER_SURFACE_HPP -#include +#include #include #include #include diff --git a/include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp b/include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp index 2daf3d302..5783791c5 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_VULKANRENDERER_VKBUFFER_HPP #define NAZARA_VULKANRENDERER_VKBUFFER_HPP -#include +#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp index c1d2b9e54..5ef24bd7d 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_VULKANRENDERER_VKCOMMANDBUFFER_HPP #define NAZARA_VULKANRENDERER_VKCOMMANDBUFFER_HPP -#include +#include #include #include #include diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandPool.hpp b/include/Nazara/VulkanRenderer/Wrapper/CommandPool.hpp index 1c1e2674a..7be788954 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandPool.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandPool.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_VULKANRENDERER_VKCOMMANDPOOL_HPP #define NAZARA_VULKANRENDERER_VKCOMMANDPOOL_HPP -#include +#include #include #include diff --git a/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp b/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp index f9fad39d3..e087b58b2 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_VULKANRENDERER_VKDESCRIPTORPOOL_HPP #define NAZARA_VULKANRENDERER_VKDESCRIPTORPOOL_HPP -#include +#include #include #include diff --git a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.hpp b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.hpp index 0c08a52f8..c9afa477e 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_VULKANRENDERER_VKDESCRIPTORSET_HPP #define NAZARA_VULKANRENDERER_VKDESCRIPTORSET_HPP -#include +#include #include #include #include diff --git a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.hpp b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.hpp index fc95be3db..fc0c69c34 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_VULKANRENDERER_VKDESCRIPTORSETLAYOUT_HPP #define NAZARA_VULKANRENDERER_VKDESCRIPTORSETLAYOUT_HPP -#include +#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp index 227e8f512..4be5e53bf 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_VULKANRENDERER_VKDEVICE_HPP #define NAZARA_VULKANRENDERER_VKDEVICE_HPP -#include +#include #include #include #include diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp b/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp index 1613ea019..67b319083 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_VULKANRENDERER_VKDEVICEMEMORY_HPP #define NAZARA_VULKANRENDERER_VKDEVICEMEMORY_HPP -#include +#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp index 2c09fe638..e807d774a 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_VULKANRENDERER_VKDEVICEOBJECT_HPP #define NAZARA_VULKANRENDERER_VKDEVICEOBJECT_HPP -#include +#include #include #include diff --git a/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.hpp b/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.hpp index 99f168be5..811bd2859 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_VULKANRENDERER_VKFRAMEBUFFER_HPP #define NAZARA_VULKANRENDERER_VKFRAMEBUFFER_HPP -#include +#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/Wrapper/Image.hpp b/include/Nazara/VulkanRenderer/Wrapper/Image.hpp index eea75ee4d..67f59fb2d 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Image.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Image.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_VULKANRENDERER_VKIMAGE_HPP #define NAZARA_VULKANRENDERER_VKIMAGE_HPP -#include +#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/Wrapper/ImageView.hpp b/include/Nazara/VulkanRenderer/Wrapper/ImageView.hpp index 373cf18b6..3a0bb5cbb 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/ImageView.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/ImageView.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_VULKANRENDERER_VKIMAGEVIEW_HPP #define NAZARA_VULKANRENDERER_VKIMAGEVIEW_HPP -#include +#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp b/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp index c8fafd9d3..71c3f08e5 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_VULKANRENDERER_VKINSTANCE_HPP #define NAZARA_VULKANRENDERER_VKINSTANCE_HPP -#include +#include #include #include #include diff --git a/include/Nazara/VulkanRenderer/Wrapper/Loader.hpp b/include/Nazara/VulkanRenderer/Wrapper/Loader.hpp index a1c4d4ed6..41620a0f4 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Loader.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Loader.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_VULKANRENDERER_VKLOADER_HPP #define NAZARA_VULKANRENDERER_VKLOADER_HPP -#include +#include #include #include #include diff --git a/include/Nazara/VulkanRenderer/Wrapper/Pipeline.hpp b/include/Nazara/VulkanRenderer/Wrapper/Pipeline.hpp index ead741a30..ea323ec49 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Pipeline.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Pipeline.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_VULKANRENDERER_VKPIPELINE_HPP #define NAZARA_VULKANRENDERER_VKPIPELINE_HPP -#include +#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.hpp b/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.hpp index 405fee3c2..0fedec109 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_VULKANRENDERER_VKPIPELINECACHE_HPP #define NAZARA_VULKANRENDERER_VKPIPELINECACHE_HPP -#include +#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp b/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp index fe5300127..f56f05639 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_VULKANRENDERER_VKPIPELINELAYOUT_HPP #define NAZARA_VULKANRENDERER_VKPIPELINELAYOUT_HPP -#include +#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/Wrapper/Queue.hpp b/include/Nazara/VulkanRenderer/Wrapper/Queue.hpp index f8502ab87..7b3e0436b 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Queue.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Queue.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_VULKANRENDERER_VKQUEUE_HPP #define NAZARA_VULKANRENDERER_VKQUEUE_HPP -#include +#include #include #include diff --git a/include/Nazara/VulkanRenderer/Wrapper/RenderPass.hpp b/include/Nazara/VulkanRenderer/Wrapper/RenderPass.hpp index 71c1d75e9..35e4b8268 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/RenderPass.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/RenderPass.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_VULKANRENDERER_VKRENDERPASS_HPP #define NAZARA_VULKANRENDERER_VKRENDERPASS_HPP -#include +#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/Wrapper/Semaphore.hpp b/include/Nazara/VulkanRenderer/Wrapper/Semaphore.hpp index baffe1171..8dfdf1cf9 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Semaphore.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Semaphore.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_VULKANRENDERER_VKSEMAPHORE_HPP #define NAZARA_VULKANRENDERER_VKSEMAPHORE_HPP -#include +#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp b/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp index 65ee75ddc..db00805e5 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_VULKANRENDERER_VKSHADERMODULE_HPP #define NAZARA_VULKANRENDERER_VKSHADERMODULE_HPP -#include +#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/Wrapper/Surface.hpp b/include/Nazara/VulkanRenderer/Wrapper/Surface.hpp index 765848962..3c77ca00f 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Surface.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Surface.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_VULKANRENDERER_VKSURFACE_HPP #define NAZARA_VULKANRENDERER_VKSURFACE_HPP -#include +#include #include #include #include diff --git a/include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp b/include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp index 5df920ba0..f3d2aac89 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp @@ -7,7 +7,7 @@ #ifndef NAZARA_VULKANRENDERER_VKSWAPCHAIN_HPP #define NAZARA_VULKANRENDERER_VKSWAPCHAIN_HPP -#include +#include #include #include diff --git a/src/Nazara/VulkanRenderer/Export.cpp b/src/Nazara/VulkanRenderer/Export.cpp index 42f89c79e..321038299 100644 --- a/src/Nazara/VulkanRenderer/Export.cpp +++ b/src/Nazara/VulkanRenderer/Export.cpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include extern "C" From cd31e6c397937b68d615b927c92360cf5df4ba17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Fri, 9 Mar 2018 16:49:01 +0100 Subject: [PATCH 078/316] Add buffer support --- examples/VulkanTest/main.cpp | 210 +++++------------- include/Nazara/Renderer.hpp | 2 +- include/Nazara/Renderer/RenderBuffer.hpp | 37 ++- include/Nazara/Renderer/RenderBuffer.inl | 7 + include/Nazara/Renderer/RenderDevice.hpp | 26 ++- ...derDeviceInstance.inl => RenderDevice.inl} | 2 +- include/Nazara/Renderer/RenderDeviceInfo.hpp | 23 ++ .../Nazara/Renderer/RenderDeviceInstance.hpp | 26 --- include/Nazara/Renderer/RenderWindowImpl.hpp | 3 +- include/Nazara/Renderer/RendererImpl.hpp | 9 +- include/Nazara/Utility/SoftwareBuffer.hpp | 1 + .../Nazara/VulkanRenderer/VkRenderWindow.hpp | 11 +- .../Nazara/VulkanRenderer/VkRenderWindow.inl | 9 +- include/Nazara/VulkanRenderer/Vulkan.hpp | 18 +- .../Nazara/VulkanRenderer/VulkanBuffer.hpp | 14 +- .../Nazara/VulkanRenderer/VulkanBuffer.inl | 11 +- .../Nazara/VulkanRenderer/VulkanDevice.hpp | 18 +- src/Nazara/Renderer/RenderBuffer.cpp | 71 +++++- ...derDeviceInstance.cpp => RenderDevice.cpp} | 4 +- src/Nazara/Renderer/RenderWindow.cpp | 7 +- src/Nazara/Renderer/Renderer.cpp | 5 +- src/Nazara/Utility/SoftwareBuffer.cpp | 5 + src/Nazara/VulkanRenderer/VkRenderWindow.cpp | 20 +- src/Nazara/VulkanRenderer/Vulkan.cpp | 138 +++++++++--- src/Nazara/VulkanRenderer/VulkanBuffer.cpp | 44 +++- src/Nazara/VulkanRenderer/VulkanDevice.cpp | 5 + src/Nazara/VulkanRenderer/VulkanRenderer.cpp | 21 +- 27 files changed, 452 insertions(+), 295 deletions(-) rename include/Nazara/Renderer/{RenderDeviceInstance.inl => RenderDevice.inl} (84%) create mode 100644 include/Nazara/Renderer/RenderDeviceInfo.hpp delete mode 100644 include/Nazara/Renderer/RenderDeviceInstance.hpp rename src/Nazara/Renderer/{RenderDeviceInstance.cpp => RenderDevice.cpp} (68%) diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index 7fc74f32b..b34574245 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -112,13 +113,7 @@ int main() Nz::MeshParams meshParams; meshParams.matrix = Nz::Matrix4f::Rotate(Nz::EulerAnglesf(0.f, 90.f, 180.f)); - - Nz::Mesh drfreak; - if (!drfreak.LoadFromFile("resources/drfreak.md2", meshParams)) - { - NazaraError("Failed to load Dr. Freak"); - return __LINE__; - } + meshParams.vertexDeclaration = Nz::VertexDeclaration::Get(Nz::VertexLayout_XYZ_Normal); Nz::String windowTitle = "Vulkan Test"; if (!window.Create(Nz::VideoMode(800, 600, 32), windowTitle)) @@ -141,23 +136,28 @@ int main() std::vector queues; instance.GetPhysicalDeviceQueueFamilyProperties(physDevice, &queues);*/ - Nz::Vk::DeviceHandle device = vulkanWindow.GetDevice(); + Nz::VulkanDevice& device = vulkanWindow.GetDevice(); Nz::Vk::ShaderModule vertexShader; - if (!vertexShader.Create(device, reinterpret_cast(vertexShaderCode.data()), vertexShaderCode.size())) + if (!vertexShader.Create(device.CreateHandle(), reinterpret_cast(vertexShaderCode.data()), vertexShaderCode.size())) { NazaraError("Failed to create vertex shader"); return __LINE__; } Nz::Vk::ShaderModule fragmentShader; - if (!fragmentShader.Create(device, reinterpret_cast(fragmentShaderCode.data()), fragmentShaderCode.size())) + if (!fragmentShader.Create(device.CreateHandle(), reinterpret_cast(fragmentShaderCode.data()), fragmentShaderCode.size())) { NazaraError("Failed to create fragment shader"); return __LINE__; } - VkMemoryRequirements memRequirement; + Nz::Mesh drfreak; + if (!drfreak.LoadFromFile("resources/OILTANK1.md2", meshParams)) + { + NazaraError("Failed to load model"); + return __LINE__; + } Nz::StaticMesh* drfreakMesh = static_cast(drfreak.GetSubMesh(0)); @@ -165,134 +165,28 @@ int main() const Nz::IndexBuffer* drfreakIB = drfreakMesh->GetIndexBuffer(); // Vertex buffer - struct Vertex { - Nz::Vector4f pos; - Nz::Vector3f col; - }; + std::cout << "Index count: " << drfreakIB->GetIndexCount() << std::endl; - /*std::vector vertexBufferData = { - {{-1.f, 1.f, 0.0f}, {1.0f, 0.0f, 0.0f}}, - {{1.f, 1.f, 0.0f}, {0.0f, 1.0f, 0.0f}}, - {{0.0f, -1.f, 0.0f}, {0.0f, 0.0f, 1.0f}} - }; - - Nz::Matrix4f projection = Nz::Matrix4f::Perspective(70.f, float(windowSize.x) / windowSize.y, 1.f, 1000.f); - Nz::Matrix4f world = Nz::Matrix4f::Translate(Nz::Vector3f::Forward() * 5.f); - - for (unsigned int i = 0; i < 3; ++i) + Nz::RenderBuffer* renderBufferIB = static_cast(drfreakIB->GetBuffer()->GetImpl()); + if (!renderBufferIB->Synchronize(&device)) { - Nz::Vector4f pos = vertexBufferData[i].pos; - vertexBufferData[i].pos = projection * (world * pos); - }*/ - - Nz::BufferMapper vertexMapper(drfreakVB, Nz::BufferAccess_ReadOnly); - Nz::MeshVertex* meshVertices = static_cast(vertexMapper.GetPointer()); - - std::size_t vertexCount = drfreakVB->GetVertexCount(); - - Nz::Image meshImage; - if (!meshImage.LoadFromFile("resources/drfreak.tga")) - { - NazaraError("Failed to load texture"); + NazaraError("Failed to synchronize render buffer"); return __LINE__; } - std::vector vertexBufferData; - vertexBufferData.reserve(vertexCount); - for (std::size_t i = 0; i < vertexCount; ++i) - { - std::size_t texX = meshVertices[i].uv.x * meshImage.GetWidth(); - std::size_t texY = meshVertices[i].uv.y * meshImage.GetHeight(); - - Nz::Color c = meshImage.GetPixelColor(texX, texY); - - Vertex vertex = { - meshVertices[i].position, - {c.r / 255.f, c.g / 255.f, c.b / 255.f} - }; - - vertexBufferData.push_back(vertex); - } - - Nz::UInt32 vertexBufferSize = static_cast(vertexBufferData.size() * sizeof(Vertex)); - - Nz::Vk::Buffer vertexBuffer; - if (!vertexBuffer.Create(device, 0, vertexBufferSize, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT)) - { - NazaraError("Failed to create vertex buffer"); - return __LINE__; - } - - memRequirement = vertexBuffer.GetMemoryRequirements(); - - Nz::Vk::DeviceMemory vertexBufferMemory; - if (!vertexBufferMemory.Create(device, memRequirement.size, memRequirement.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) - { - NazaraError("Failed to allocate vertex buffer memory"); - return __LINE__; - } - - if (!vertexBufferMemory.Map(0, vertexBufferSize)) - { - NazaraError("Failed to map vertex buffer"); - return __LINE__; - } - - std::memcpy(vertexBufferMemory.GetMappedPointer(), vertexBufferData.data(), vertexBufferSize); - - vertexBufferMemory.Unmap(); - - if (!vertexBuffer.BindBufferMemory(vertexBufferMemory)) - { - NazaraError("Failed to bind vertex buffer to its memory"); - return __LINE__; - } + Nz::VulkanBuffer* indexBufferImpl = static_cast(renderBufferIB->GetHardwareBuffer(&device)); // Index buffer - Nz::IndexMapper indexMapper(drfreakIB); + std::cout << "Vertex count: " << drfreakVB->GetVertexCount() << std::endl; - std::size_t indexCount = indexMapper.GetIndexCount(); - std::vector indexBufferData; - indexBufferData.reserve(indexCount); - - for (std::size_t i = 0; i < indexCount; ++i) + Nz::RenderBuffer* renderBufferVB = static_cast(drfreakVB->GetBuffer()->GetImpl()); + if (!renderBufferVB->Synchronize(&device)) { - indexBufferData.push_back(indexMapper.Get(i)); - } - - Nz::UInt32 indexBufferSize = indexBufferData.size() * sizeof(Nz::UInt32); - - Nz::Vk::Buffer indexBuffer; - if (!indexBuffer.Create(device, 0, indexBufferSize, VK_BUFFER_USAGE_INDEX_BUFFER_BIT)) - { - NazaraError("Failed to create vertex buffer"); + NazaraError("Failed to synchronize render buffer"); return __LINE__; } - memRequirement = indexBuffer.GetMemoryRequirements(); - - Nz::Vk::DeviceMemory indexBufferMemory; - if (!indexBufferMemory.Create(device, memRequirement.size, memRequirement.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) - { - NazaraError("Failed to allocate vertex buffer memory"); - return __LINE__; - } - - if (!indexBufferMemory.Map(0, indexBufferSize)) - { - NazaraError("Failed to map vertex buffer"); - return __LINE__; - } - - std::memcpy(indexBufferMemory.GetMappedPointer(), indexBufferData.data(), indexBufferSize); - - indexBufferMemory.Unmap(); - - if (!indexBuffer.BindBufferMemory(indexBufferMemory)) - { - NazaraError("Failed to bind vertex buffer to its memory"); - return __LINE__; - } + Nz::VulkanBuffer* vertexBufferImpl = static_cast(renderBufferVB->GetHardwareBuffer(&device)); struct { @@ -310,16 +204,16 @@ int main() Nz::UInt32 uniformSize = sizeof(ubo); Nz::Vk::Buffer uniformBuffer; - if (!uniformBuffer.Create(device, 0, uniformSize, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT)) + if (!uniformBuffer.Create(device.CreateHandle(), 0, uniformSize, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT)) { NazaraError("Failed to create vertex buffer"); return __LINE__; } - memRequirement = uniformBuffer.GetMemoryRequirements(); + VkMemoryRequirements memRequirement = uniformBuffer.GetMemoryRequirements(); Nz::Vk::DeviceMemory uniformBufferMemory; - if (!uniformBufferMemory.Create(device, memRequirement.size, memRequirement.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) + if (!uniformBufferMemory.Create(device.CreateHandle(), memRequirement.size, memRequirement.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) { NazaraError("Failed to allocate vertex buffer memory"); return __LINE__; @@ -350,7 +244,7 @@ int main() layoutBinding.pImmutableSamplers = nullptr; Nz::Vk::DescriptorSetLayout descriptorLayout; - if (!descriptorLayout.Create(device, layoutBinding)) + if (!descriptorLayout.Create(device.CreateHandle(), layoutBinding)) { NazaraError("Failed to create descriptor set layout"); return __LINE__; @@ -361,7 +255,7 @@ int main() poolSize.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; Nz::Vk::DescriptorPool descriptorPool; - if (!descriptorPool.Create(device, 1, poolSize, VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT)) + if (!descriptorPool.Create(device.CreateHandle(), 1, poolSize, VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT)) { NazaraError("Failed to create descriptor pool"); return __LINE__; @@ -396,7 +290,7 @@ int main() VkVertexInputBindingDescription bindingDescription = { 0, - sizeof(Vertex), + drfreakVB->GetStride(), VK_VERTEX_INPUT_RATE_VERTEX }; @@ -406,14 +300,14 @@ int main() { 0, // uint32_t location 0, // uint32_t binding; - VK_FORMAT_R32G32B32A32_SFLOAT, // VkFormat format; + VK_FORMAT_R32G32B32_SFLOAT, // VkFormat format; 0 // uint32_t offset; }, { 1, // uint32_t location 0, // uint32_t binding; VK_FORMAT_R32G32B32_SFLOAT, // VkFormat format; - sizeof(float) * 4 // uint32_t offset; + sizeof(float) * 3 // uint32_t offset; } } }; @@ -510,7 +404,7 @@ int main() }; Nz::Vk::PipelineLayout pipelineLayout; - pipelineLayout.Create(device, layout_create_info); + pipelineLayout.Create(device.CreateHandle(), layout_create_info); std::array dynamicStates = { VK_DYNAMIC_STATE_SCISSOR, @@ -563,14 +457,14 @@ int main() }; Nz::Vk::Pipeline pipeline; - if (!pipeline.CreateGraphics(device, pipeline_create_info)) + if (!pipeline.CreateGraphics(device.CreateHandle(), pipeline_create_info)) { NazaraError("Failed to create pipeline"); return __LINE__; } Nz::Vk::CommandPool cmdPool; - if (!cmdPool.Create(device, 0, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)) + if (!cmdPool.Create(device.CreateHandle(), 0, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)) { NazaraError("Failed to create rendering cmd pool"); return __LINE__; @@ -580,7 +474,7 @@ int main() clearValues[0].color = {1.0f, 0.8f, 0.4f, 0.0f}; clearValues[1].depthStencil = {1.f, 0}; - Nz::Vk::Queue graphicsQueue(device, device->GetEnabledQueues()[0].queues[0].queue); + Nz::Vk::Queue graphicsQueue(device.CreateHandle(), device.GetEnabledQueues()[0].queues[0].queue); Nz::UInt32 imageCount = vulkanWindow.GetFramebufferCount(); std::vector renderCmds = cmdPool.AllocateCommandBuffers(imageCount, VK_COMMAND_BUFFER_LEVEL_PRIMARY); @@ -634,13 +528,13 @@ int main() renderCmd.BeginRenderPass(render_pass_begin_info); //renderCmd.ClearAttachment(clearAttachment, clearRect); //renderCmd.ClearAttachment(clearAttachmentDepth, clearRect); - renderCmd.BindIndexBuffer(indexBuffer, 0, VK_INDEX_TYPE_UINT32); - renderCmd.BindVertexBuffer(0, vertexBuffer, 0); + renderCmd.BindIndexBuffer(indexBufferImpl->GetBufferHandle(), 0, VK_INDEX_TYPE_UINT16); + renderCmd.BindVertexBuffer(0, vertexBufferImpl->GetBufferHandle(), 0); renderCmd.BindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, descriptorSet); renderCmd.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); renderCmd.SetScissor(Nz::Recti{0, 0, int(windowSize.x), int(windowSize.y)}); renderCmd.SetViewport({0.f, 0.f, float(windowSize.x), float(windowSize.y)}, 0.f, 1.f); - renderCmd.DrawIndexed(indexCount); + renderCmd.DrawIndexed(drfreakIB->GetIndexCount()); renderCmd.EndRenderPass(); vulkanWindow.BuildPostRenderCommands(i, renderCmd); @@ -675,21 +569,21 @@ int main() window.Close(); break; - case Nz::WindowEventType_MouseMoved: // La souris a bougé + case Nz::WindowEventType_MouseMoved: // La souris a bougé { - // Gestion de la caméra free-fly (Rotation) - float sensitivity = 0.3f; // Sensibilité de la souris + // Gestion de la caméra free-fly (Rotation) + float sensitivity = 0.3f; // Sensibilité de la souris - // On modifie l'angle de la caméra grâce au déplacement relatif sur X de la souris + // On modifie l'angle de la caméra grâce au déplacement relatif sur X de la souris camAngles.yaw = Nz::NormalizeAngle(camAngles.yaw - event.mouseMove.deltaX*sensitivity); - // Idem, mais pour éviter les problèmes de calcul de la matrice de vue, on restreint les angles + // Idem, mais pour éviter les problèmes de calcul de la matrice de vue, on restreint les angles camAngles.pitch = Nz::Clamp(camAngles.pitch + event.mouseMove.deltaY*sensitivity, -89.f, 89.f); camQuat = camAngles; - // Pour éviter que le curseur ne sorte de l'écran, nous le renvoyons au centre de la fenêtre - // Cette fonction est codée de sorte à ne pas provoquer d'évènement MouseMoved + // Pour éviter que le curseur ne sorte de l'écran, nous le renvoyons au centre de la fenêtre + // Cette fonction est codée de sorte à ne pas provoquer d'évènement MouseMoved Nz::Mouse::SetPosition(windowSize.x / 2, windowSize.y / 2, window); updateUniforms = true; break; @@ -758,25 +652,25 @@ int main() vulkanWindow.Present(imageIndex); - // On incrémente le compteur de FPS improvisé + // On incrémente le compteur de FPS improvisé fps++; if (secondClock.GetMilliseconds() >= 1000) // Toutes les secondes { - // Et on insère ces données dans le titre de la fenêtre + // Et on insère ces données dans le titre de la fenêtre window.SetTitle(windowTitle + " - " + Nz::String::Number(fps) + " FPS"); /* - Note: En C++11 il est possible d'insérer de l'Unicode de façon standard, quel que soit l'encodage du fichier, - via quelque chose de similaire à u8"Cha\u00CEne de caract\u00E8res". - Cependant, si le code source est encodé en UTF-8 (Comme c'est le cas dans ce fichier), - cela fonctionnera aussi comme ceci : "Chaîne de caractères". + Note: En C++11 il est possible d'insérer de l'Unicode de façon standard, quel que soit l'encodage du fichier, + via quelque chose de similaire à u8"Cha\u00CEne de caract\u00E8res". + Cependant, si le code source est encodé en UTF-8 (Comme c'est le cas dans ce fichier), + cela fonctionnera aussi comme ceci : "Chaîne de caractères". */ - // Et on réinitialise le compteur de FPS + // Et on réinitialise le compteur de FPS fps = 0; - // Et on relance l'horloge pour refaire ça dans une seconde + // Et on relance l'horloge pour refaire ça dans une seconde secondClock.Restart(); } } @@ -784,4 +678,4 @@ int main() // instance.vkDestroyDebugReportCallbackEXT(instance, callback, nullptr); return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/include/Nazara/Renderer.hpp b/include/Nazara/Renderer.hpp index d733c1032..d64926f30 100644 --- a/include/Nazara/Renderer.hpp +++ b/include/Nazara/Renderer.hpp @@ -36,8 +36,8 @@ #include #include #include +#include #include -#include #include #include #include diff --git a/include/Nazara/Renderer/RenderBuffer.hpp b/include/Nazara/Renderer/RenderBuffer.hpp index ac1c8391d..a0a49159f 100644 --- a/include/Nazara/Renderer/RenderBuffer.hpp +++ b/include/Nazara/Renderer/RenderBuffer.hpp @@ -7,31 +7,56 @@ #ifndef NAZARA_RENDERBUFFER_HPP #define NAZARA_RENDERBUFFER_HPP +#include #include +#include #include #include +#include +#include namespace Nz { + class RenderDevice; + class NAZARA_RENDERER_API RenderBuffer : public AbstractBuffer { public: - RenderBuffer() = default; + inline RenderBuffer(Buffer* parent, BufferType type); + RenderBuffer(const RenderBuffer&) = delete; + RenderBuffer(RenderBuffer&&) = default; ~RenderBuffer() = default; - virtual bool Fill(const void* data, UInt32 offset, UInt32 size) = 0; + bool Fill(const void* data, UInt32 offset, UInt32 size) override final; bool Initialize(UInt32 size, BufferUsageFlags usage) override; + AbstractBuffer* GetHardwareBuffer(RenderDevice* device); DataStorage GetStorage() const override; - virtual void* Map(BufferAccess access, UInt32 offset = 0, UInt32 size = 0) = 0; - virtual bool Unmap() = 0; + void* Map(BufferAccess access, UInt32 offset = 0, UInt32 size = 0) override final; + bool Unmap() override final; + + RenderBuffer& operator=(const RenderBuffer&) = delete; + RenderBuffer& operator=(RenderBuffer&&) = default; + + public: //< temp + bool Synchronize(RenderDevice* device); private: - SoftwareBuffer m_softwareBuffer; - }; + struct HardwareBuffer + { + std::unique_ptr buffer; + bool synchronized = false; + }; + BufferUsageFlags m_usage; + SoftwareBuffer m_softwareBuffer; + Buffer* m_parent; + BufferType m_type; + std::size_t m_size; + std::unordered_map m_hardwareBuffers; + }; } #include diff --git a/include/Nazara/Renderer/RenderBuffer.inl b/include/Nazara/Renderer/RenderBuffer.inl index 6a207825e..ecd250f63 100644 --- a/include/Nazara/Renderer/RenderBuffer.inl +++ b/include/Nazara/Renderer/RenderBuffer.inl @@ -2,11 +2,18 @@ // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp +#include #include #include namespace Nz { + inline RenderBuffer::RenderBuffer(Buffer* parent, BufferType type) : + m_softwareBuffer(parent, type), + m_parent(parent), + m_type(type) + { + } } #include diff --git a/include/Nazara/Renderer/RenderDevice.hpp b/include/Nazara/Renderer/RenderDevice.hpp index 4b1991085..f01ea5ec5 100644 --- a/include/Nazara/Renderer/RenderDevice.hpp +++ b/include/Nazara/Renderer/RenderDevice.hpp @@ -4,20 +4,28 @@ #pragma once -#ifndef NAZARA_RENDERDEVICE_HPP -#define NAZARA_RENDERDEVICE_HPP +#ifndef NAZARA_RENDERDEVICEINSTANCE_HPP +#define NAZARA_RENDERDEVICEINSTANCE_HPP -#include -#include -#include +#include +#include +#include +#include namespace Nz { - struct RenderDevice + class Buffer; + + class NAZARA_RENDERER_API RenderDevice { - RenderDeviceType type; - String name; + public: + RenderDevice() = default; + virtual ~RenderDevice(); + + virtual std::unique_ptr InstantiateBuffer(Buffer* parent, BufferType type) = 0; }; } -#endif // NAZARA_RENDERER_HPP +#include + +#endif // NAZARA_RENDERDEVICEINSTANCE_HPP diff --git a/include/Nazara/Renderer/RenderDeviceInstance.inl b/include/Nazara/Renderer/RenderDevice.inl similarity index 84% rename from include/Nazara/Renderer/RenderDeviceInstance.inl rename to include/Nazara/Renderer/RenderDevice.inl index 68ffbd5cd..7a62a60ea 100644 --- a/include/Nazara/Renderer/RenderDeviceInstance.inl +++ b/include/Nazara/Renderer/RenderDevice.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include namespace Nz diff --git a/include/Nazara/Renderer/RenderDeviceInfo.hpp b/include/Nazara/Renderer/RenderDeviceInfo.hpp new file mode 100644 index 000000000..a1e379c18 --- /dev/null +++ b/include/Nazara/Renderer/RenderDeviceInfo.hpp @@ -0,0 +1,23 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_RENDERDEVICE_HPP +#define NAZARA_RENDERDEVICE_HPP + +#include +#include +#include + +namespace Nz +{ + struct RenderDeviceInfo + { + RenderDeviceType type; + String name; + }; +} + +#endif // NAZARA_RENDERER_HPP diff --git a/include/Nazara/Renderer/RenderDeviceInstance.hpp b/include/Nazara/Renderer/RenderDeviceInstance.hpp deleted file mode 100644 index 3c019fc20..000000000 --- a/include/Nazara/Renderer/RenderDeviceInstance.hpp +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2016 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_RENDERDEVICEINSTANCE_HPP -#define NAZARA_RENDERDEVICEINSTANCE_HPP - -#include -#include - -namespace Nz -{ - ///TODO: Rename - class NAZARA_RENDERER_API RenderDeviceInstance - { - public: - RenderDeviceInstance() = default; - virtual ~RenderDeviceInstance(); - }; -} - -#include - -#endif // NAZARA_RENDERDEVICEINSTANCE_HPP diff --git a/include/Nazara/Renderer/RenderWindowImpl.hpp b/include/Nazara/Renderer/RenderWindowImpl.hpp index eb1bb8282..e5abd0c98 100644 --- a/include/Nazara/Renderer/RenderWindowImpl.hpp +++ b/include/Nazara/Renderer/RenderWindowImpl.hpp @@ -16,6 +16,7 @@ namespace Nz { + class RendererImpl; class RenderSurface; class NAZARA_RENDERER_API RenderWindowImpl @@ -24,7 +25,7 @@ namespace Nz RenderWindowImpl() = default; virtual ~RenderWindowImpl(); - virtual bool Create(RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) = 0; + virtual bool Create(RendererImpl* renderer, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) = 0; }; } diff --git a/include/Nazara/Renderer/RendererImpl.hpp b/include/Nazara/Renderer/RendererImpl.hpp index c57b41781..f9b5f4d10 100644 --- a/include/Nazara/Renderer/RendererImpl.hpp +++ b/include/Nazara/Renderer/RendererImpl.hpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include @@ -21,7 +21,7 @@ namespace Nz { class Buffer; class RendererImpl; - class RenderDeviceInstance; + class RenderDevice; class RenderSurface; class RenderWindowImpl; @@ -33,11 +33,10 @@ namespace Nz RendererImpl() = default; virtual ~RendererImpl(); - virtual std::unique_ptr CreateHardwareBufferImpl(Buffer* parent, BufferType type) = 0; virtual std::unique_ptr CreateRenderSurfaceImpl() = 0; virtual std::unique_ptr CreateRenderWindowImpl() = 0; - virtual std::unique_ptr InstanciateRenderDevice(std::size_t deviceIndex) = 0; + virtual std::shared_ptr InstanciateRenderDevice(std::size_t deviceIndex) = 0; virtual bool IsBetterThan(const RendererImpl* other) const = 0; @@ -45,7 +44,7 @@ namespace Nz virtual String QueryAPIString() const = 0; virtual UInt32 QueryAPIVersion() const = 0; - virtual std::vector QueryRenderDevices() const = 0; + virtual std::vector QueryRenderDevices() const = 0; virtual bool Prepare(const ParameterList& parameters) = 0; }; diff --git a/include/Nazara/Utility/SoftwareBuffer.hpp b/include/Nazara/Utility/SoftwareBuffer.hpp index 0c792a4c2..d460eba4c 100644 --- a/include/Nazara/Utility/SoftwareBuffer.hpp +++ b/include/Nazara/Utility/SoftwareBuffer.hpp @@ -25,6 +25,7 @@ namespace Nz bool Initialize(UInt32 size, BufferUsageFlags usage) override; + const UInt8* GetData() const; DataStorage GetStorage() const override; void* Map(BufferAccess access, UInt32 offset = 0, UInt32 size = 0) override; diff --git a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp index 186287703..e1cdf3622 100644 --- a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp +++ b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp @@ -11,8 +11,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -39,11 +41,12 @@ namespace Nz void BuildPreRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) override; void BuildPostRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) override; - bool Create(RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) override; + bool Create(RendererImpl* renderer, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) override; inline const Vk::Framebuffer& GetFrameBuffer(UInt32 imageIndex) const override; - inline UInt32 GetFramebufferCount() const; - inline const Vk::DeviceHandle& GetDevice() const; + inline UInt32 GetFramebufferCount() const override; + inline VulkanDevice& GetDevice(); + inline const VulkanDevice& GetDevice() const; inline UInt32 GetPresentableFamilyQueue() const; inline const Vk::Swapchain& GetSwapchain() const; @@ -62,8 +65,8 @@ namespace Nz VkFormat m_colorFormat; VkFormat m_depthStencilFormat; VkPhysicalDevice m_physicalDevice; + std::shared_ptr m_device; std::vector m_frameBuffers; - Vk::DeviceHandle m_device; Vk::DeviceMemory m_depthBufferMemory; Vk::Image m_depthBuffer; Vk::ImageView m_depthBufferView; diff --git a/include/Nazara/VulkanRenderer/VkRenderWindow.inl b/include/Nazara/VulkanRenderer/VkRenderWindow.inl index e207cc89a..0721f4762 100644 --- a/include/Nazara/VulkanRenderer/VkRenderWindow.inl +++ b/include/Nazara/VulkanRenderer/VkRenderWindow.inl @@ -7,9 +7,14 @@ namespace Nz { - inline const Vk::DeviceHandle& VkRenderWindow::GetDevice() const + inline VulkanDevice& VkRenderWindow::GetDevice() { - return m_device; + return *m_device; + } + + inline const VulkanDevice& VkRenderWindow::GetDevice() const + { + return *m_device; } inline const Vk::Framebuffer& VkRenderWindow::GetFrameBuffer(UInt32 imageIndex) const diff --git a/include/Nazara/VulkanRenderer/Vulkan.hpp b/include/Nazara/VulkanRenderer/Vulkan.hpp index 7701a95b0..69ada9a7b 100644 --- a/include/Nazara/VulkanRenderer/Vulkan.hpp +++ b/include/Nazara/VulkanRenderer/Vulkan.hpp @@ -16,17 +16,28 @@ #include #include #include +#include #include namespace Nz { + class VulkanDevice; + class NAZARA_VULKANRENDERER_API Vulkan { public: + struct QueueFamily + { + UInt32 familyIndex; + float priority; + }; + Vulkan() = delete; ~Vulkan() = delete; - static Vk::DeviceHandle CreateDevice(VkPhysicalDevice gpu, const Vk::Surface& surface, UInt32* presentableFamilyQueue); + static std::shared_ptr CreateDevice(VkPhysicalDevice gpu); + static std::shared_ptr CreateDevice(VkPhysicalDevice gpu, const Vk::Surface& surface, UInt32* presentableFamilyQueue); + static std::shared_ptr CreateDevice(VkPhysicalDevice gpu, const QueueFamily* queueFamilies, std::size_t queueFamilyCount); static Vk::Instance& GetInstance(); @@ -37,12 +48,13 @@ namespace Nz static bool IsInitialized(); - static Vk::DeviceHandle SelectDevice(VkPhysicalDevice gpu, const Vk::Surface& surface, UInt32* presentableFamilyQueue); + static std::shared_ptr SelectDevice(VkPhysicalDevice gpu); + static std::shared_ptr SelectDevice(VkPhysicalDevice gpu, const Vk::Surface& surface, UInt32* presentableFamilyQueue); static void Uninitialize(); private: - static std::list s_devices; + static std::vector> s_devices; static std::vector s_physDevices; static Vk::Instance s_instance; static ParameterList s_initializationParameters; diff --git a/include/Nazara/VulkanRenderer/VulkanBuffer.hpp b/include/Nazara/VulkanRenderer/VulkanBuffer.hpp index e44406152..04ee709dd 100644 --- a/include/Nazara/VulkanRenderer/VulkanBuffer.hpp +++ b/include/Nazara/VulkanRenderer/VulkanBuffer.hpp @@ -9,25 +9,26 @@ #include #include -#include #include #include +#include #include namespace Nz { - //TODO: Move all the software stuff to the Renderer + class Buffer; class NAZARA_VULKANRENDERER_API VulkanBuffer : public AbstractBuffer { public: - inline VulkanBuffer(Buffer* parent, BufferType type); + inline VulkanBuffer(const Vk::DeviceHandle& device, Buffer* parent, BufferType type); VulkanBuffer(const VulkanBuffer&) = delete; VulkanBuffer(VulkanBuffer&&) = delete; ///TODO virtual ~VulkanBuffer(); bool Fill(const void* data, UInt32 offset, UInt32 size) override; + inline Nz::Vk::Buffer& GetBufferHandle(); bool Initialize(UInt32 size, BufferUsageFlags usage) override; DataStorage GetStorage() const override; @@ -39,8 +40,11 @@ namespace Nz VulkanBuffer& operator=(VulkanBuffer&&) = delete; ///TODO private: - BufferUsageFlags m_usage; - SoftwareBuffer m_softwareData; + Buffer* m_parent; + BufferType m_type; + Nz::Vk::Buffer m_buffer; + Nz::Vk::DeviceHandle m_device; + Nz::Vk::DeviceMemory m_memory; }; } diff --git a/include/Nazara/VulkanRenderer/VulkanBuffer.inl b/include/Nazara/VulkanRenderer/VulkanBuffer.inl index 7638ebb80..d2360055a 100644 --- a/include/Nazara/VulkanRenderer/VulkanBuffer.inl +++ b/include/Nazara/VulkanRenderer/VulkanBuffer.inl @@ -7,10 +7,17 @@ namespace Nz { - inline VulkanBuffer::VulkanBuffer(Buffer* parent, BufferType type) : - m_softwareData(parent, type) + inline VulkanBuffer::VulkanBuffer(const Vk::DeviceHandle& device, Buffer* parent, BufferType type) : + m_device(device), + m_parent(parent), + m_type(type) { } + + inline Nz::Vk::Buffer& Nz::VulkanBuffer::GetBufferHandle() + { + return m_buffer; + } } #include diff --git a/include/Nazara/VulkanRenderer/VulkanDevice.hpp b/include/Nazara/VulkanRenderer/VulkanDevice.hpp index 151caa80f..5ec2a891c 100644 --- a/include/Nazara/VulkanRenderer/VulkanDevice.hpp +++ b/include/Nazara/VulkanRenderer/VulkanDevice.hpp @@ -7,26 +7,26 @@ #ifndef NAZARA_VULKANRENDERER_VULKANDEVICE_HPP #define NAZARA_VULKANRENDERER_VULKANDEVICE_HPP -#include #include +#include +#include #include #include namespace Nz { - //TODO: Move all the software stuff to the Renderer - - class NAZARA_VULKANRENDERER_API VulkanDevice : public RenderDeviceInstance + class NAZARA_VULKANRENDERER_API VulkanDevice : public RenderDevice, public Vk::Device { public: - VulkanDevice(Vk::DeviceHandle device); + using Device::Device; + VulkanDevice(const VulkanDevice&) = delete; + VulkanDevice(VulkanDevice&&) = delete; ///TODO? ~VulkanDevice(); - VulkanDevice& operator=(const VulkanDevice&) = delete; - VulkanDevice& operator=(VulkanDevice&&) = delete; ///TODO + std::unique_ptr InstantiateBuffer(Buffer* parent, BufferType type) override; - private: - Vk::DeviceHandle m_device; + VulkanDevice& operator=(const VulkanDevice&) = delete; + VulkanDevice& operator=(VulkanDevice&&) = delete; ///TODO? }; } diff --git a/src/Nazara/Renderer/RenderBuffer.cpp b/src/Nazara/Renderer/RenderBuffer.cpp index d0338112a..470faf839 100644 --- a/src/Nazara/Renderer/RenderBuffer.cpp +++ b/src/Nazara/Renderer/RenderBuffer.cpp @@ -3,18 +3,87 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include namespace Nz { + bool RenderBuffer::Fill(const void* data, UInt32 offset, UInt32 size) + { + if (m_softwareBuffer.Fill(data, offset, size)) + { + for (auto& bufferPair : m_hardwareBuffers) + bufferPair.second.synchronized = false; + + return true; + } + else + return false; + } + bool RenderBuffer::Initialize(UInt32 size, BufferUsageFlags usage) { + m_size = size; m_softwareBuffer.Initialize(size, usage); + return true; } - DataStorage Nz::RenderBuffer::GetStorage() const + AbstractBuffer* RenderBuffer::GetHardwareBuffer(RenderDevice* device) + { + auto it = m_hardwareBuffers.find(device); + if (it == m_hardwareBuffers.end()) + return nullptr; + + return it->second.buffer.get(); + } + + DataStorage RenderBuffer::GetStorage() const { return DataStorage::DataStorage_Hardware; } + + void* RenderBuffer::Map(BufferAccess access, UInt32 offset, UInt32 size) + { + if (void* ptr = m_softwareBuffer.Map(access, offset, size)) + { + if (access != BufferAccess_ReadOnly) + { + for (auto& bufferPair : m_hardwareBuffers) + bufferPair.second.synchronized = false; + } + + return ptr; + } + else + return nullptr; + } + + bool RenderBuffer::Unmap() + { + return m_softwareBuffer.Unmap(); + } + + bool RenderBuffer::Synchronize(RenderDevice* device) + { + auto it = m_hardwareBuffers.find(device); + if (it == m_hardwareBuffers.end()) + { + HardwareBuffer hwBuffer; + hwBuffer.buffer = device->InstantiateBuffer(m_parent, m_type); + if (!hwBuffer.buffer->Initialize(m_size, m_usage)) + { + NazaraError("Failed to initialize hardware buffer"); + return false; + } + + it = m_hardwareBuffers.emplace(device, std::move(hwBuffer)).first; + } + + HardwareBuffer& hwBuffer = it->second; + if (hwBuffer.synchronized) + return true; + + return hwBuffer.buffer->Fill(m_softwareBuffer.GetData(), 0, m_size); + } } diff --git a/src/Nazara/Renderer/RenderDeviceInstance.cpp b/src/Nazara/Renderer/RenderDevice.cpp similarity index 68% rename from src/Nazara/Renderer/RenderDeviceInstance.cpp rename to src/Nazara/Renderer/RenderDevice.cpp index 6d8078cfb..de5e5f82d 100644 --- a/src/Nazara/Renderer/RenderDeviceInstance.cpp +++ b/src/Nazara/Renderer/RenderDevice.cpp @@ -2,10 +2,10 @@ // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include namespace Nz { - RenderDeviceInstance::~RenderDeviceInstance() = default; + RenderDevice::~RenderDevice() = default; } diff --git a/src/Nazara/Renderer/RenderWindow.cpp b/src/Nazara/Renderer/RenderWindow.cpp index 6b4ca5400..cc643747d 100644 --- a/src/Nazara/Renderer/RenderWindow.cpp +++ b/src/Nazara/Renderer/RenderWindow.cpp @@ -29,15 +29,16 @@ namespace Nz bool RenderWindow::OnWindowCreated() { - auto surface = Renderer::GetRendererImpl()->CreateRenderSurfaceImpl(); + RendererImpl* rendererImpl = Renderer::GetRendererImpl(); + auto surface = rendererImpl->CreateRenderSurfaceImpl(); if (!surface->Create(GetHandle())) { NazaraError("Failed to create render surface: " + Error::GetLastError()); return false; } - auto impl = Renderer::GetRendererImpl()->CreateRenderWindowImpl(); - if (!impl->Create(surface.get(), GetSize(), m_parameters)) + auto impl = rendererImpl->CreateRenderWindowImpl(); + if (!impl->Create(rendererImpl, surface.get(), GetSize(), m_parameters)) { NazaraError("Failed to create render window implementation: " + Error::GetLastError()); return false; diff --git a/src/Nazara/Renderer/Renderer.cpp b/src/Nazara/Renderer/Renderer.cpp index ab9b07f13..737b63b08 100644 --- a/src/Nazara/Renderer/Renderer.cpp +++ b/src/Nazara/Renderer/Renderer.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -135,9 +136,9 @@ namespace Nz Utility::Uninitialize(); } - AbstractBuffer* Renderer::CreateHardwareBufferImpl(Buffer * parent, BufferType type) + AbstractBuffer* Renderer::CreateHardwareBufferImpl(Buffer* parent, BufferType type) { - return s_rendererImpl->CreateHardwareBufferImpl(parent, type).release(); + return new RenderBuffer(parent, type); } std::unique_ptr Renderer::s_rendererImpl; diff --git a/src/Nazara/Utility/SoftwareBuffer.cpp b/src/Nazara/Utility/SoftwareBuffer.cpp index c76f20784..15147bd97 100644 --- a/src/Nazara/Utility/SoftwareBuffer.cpp +++ b/src/Nazara/Utility/SoftwareBuffer.cpp @@ -44,6 +44,11 @@ namespace Nz return true; } + const UInt8* SoftwareBuffer::GetData() const + { + return m_buffer.data(); + } + DataStorage SoftwareBuffer::GetStorage() const { return DataStorage_Software; diff --git a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp index fe33b3183..7f7928954 100644 --- a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp +++ b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp @@ -22,7 +22,9 @@ namespace Nz VkRenderWindow::~VkRenderWindow() { - m_device->WaitForIdle(); + if (m_device) + m_device->WaitForIdle(); + m_frameBuffers.clear(); m_renderPass.Destroy(); @@ -64,7 +66,7 @@ namespace Nz //commandBuffer.SetImageLayout(m_swapchain.GetBuffer(imageIndex).image, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR); } - bool VkRenderWindow::Create(RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) + bool VkRenderWindow::Create(RendererImpl* renderer, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) { m_physicalDevice = Vulkan::GetPhysicalDevices()[0].device; @@ -184,14 +186,14 @@ namespace Nz 1U // uint32_t layers; }; - if (!m_frameBuffers[i].Create(m_device, frameBufferCreate)) + if (!m_frameBuffers[i].Create(m_device->CreateHandle(), frameBufferCreate)) { NazaraError("Failed to create framebuffer for image #" + String::Number(i)); return false; } } - m_imageReadySemaphore.Create(m_device); + m_imageReadySemaphore.Create(m_device->CreateHandle()); m_clock.Restart(); @@ -218,14 +220,14 @@ namespace Nz VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout; }; - if (!m_depthBuffer.Create(m_device, imageCreateInfo)) + if (!m_depthBuffer.Create(m_device->CreateHandle(), imageCreateInfo)) { NazaraError("Failed to create depth buffer"); return false; } VkMemoryRequirements memoryReq = m_depthBuffer.GetMemoryRequirements(); - if (!m_depthBufferMemory.Create(m_device, memoryReq.size, memoryReq.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)) + if (!m_depthBufferMemory.Create(m_device->CreateHandle(), memoryReq.size, memoryReq.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)) { NazaraError("Failed to allocate depth buffer memory"); return false; @@ -259,7 +261,7 @@ namespace Nz } }; - if (!m_depthBufferView.Create(m_device, imageViewCreateInfo)) + if (!m_depthBufferView.Create(m_device->CreateHandle(), imageViewCreateInfo)) { NazaraError("Failed to create depth buffer view"); return false; @@ -353,7 +355,7 @@ namespace Nz dependencies.data() // const VkSubpassDependency* pDependencies; }; - return m_renderPass.Create(m_device, createInfo); + return m_renderPass.Create(m_device->CreateHandle(), createInfo); } bool VkRenderWindow::SetupSwapchain(Vk::Surface& surface, const Vector2ui& size) @@ -418,7 +420,7 @@ namespace Nz 0 }; - if (!m_swapchain.Create(m_device, swapchainInfo)) + if (!m_swapchain.Create(m_device->CreateHandle(), swapchainInfo)) { NazaraError("Failed to create swapchain"); return false; diff --git a/src/Nazara/VulkanRenderer/Vulkan.cpp b/src/Nazara/VulkanRenderer/Vulkan.cpp index 17a1171ec..f45555110 100644 --- a/src/Nazara/VulkanRenderer/Vulkan.cpp +++ b/src/Nazara/VulkanRenderer/Vulkan.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -186,10 +187,8 @@ namespace Nz } s_physDevices.reserve(physDevices.size()); - for (std::size_t i = 0; i < physDevices.size(); ++i) + for (VkPhysicalDevice physDevice : physDevices) { - VkPhysicalDevice physDevice = physDevices[i]; - Vk::PhysicalDevice deviceInfo; if (!s_instance.GetPhysicalDeviceQueueFamilyProperties(physDevice, &deviceInfo.queues)) { @@ -225,7 +224,47 @@ namespace Nz return s_instance.IsValid(); } - Vk::DeviceHandle Vulkan::CreateDevice(VkPhysicalDevice gpu, const Vk::Surface& surface, UInt32* presentableFamilyQueue) + std::shared_ptr Vulkan::CreateDevice(VkPhysicalDevice gpu) + { + Nz::ErrorFlags errFlags(ErrorFlag_ThrowException, true); + + std::vector queueFamilies; + s_instance.GetPhysicalDeviceQueueFamilyProperties(gpu, &queueFamilies); + + // Find a queue that supports graphics operations + UInt32 graphicsQueueNodeIndex = UINT32_MAX; + UInt32 transfertQueueNodeFamily = UINT32_MAX; + + for (UInt32 i = 0; i < queueFamilies.size(); i++) + { + if (queueFamilies[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) + { + graphicsQueueNodeIndex = i; + break; + } + } + + for (UInt32 i = 0; i < queueFamilies.size(); i++) + { + if (queueFamilies[i].queueFlags & (VK_QUEUE_COMPUTE_BIT | VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_TRANSFER_BIT)) //< Compute and graphics queue implicitly support transfer operations + { + transfertQueueNodeFamily = i; + if (transfertQueueNodeFamily != graphicsQueueNodeIndex) + break; + } + } + + std::array queuesFamilies = { + { + { graphicsQueueNodeIndex, 1.f }, + { transfertQueueNodeFamily, 1.f } + } + }; + + return CreateDevice(gpu, queuesFamilies.data(), queuesFamilies.size()); + } + + std::shared_ptr Vulkan::CreateDevice(VkPhysicalDevice gpu, const Vk::Surface& surface, UInt32* presentableFamilyQueue) { Nz::ErrorFlags errFlags(ErrorFlag_ThrowException, true); @@ -267,15 +306,31 @@ namespace Nz } } - std::array usedQueueFamilies = {graphicsQueueNodeIndex, presentQueueNodeIndex, transfertQueueNodeFamily}; - std::array priorities = {1.f, 1.f, 1.f}; - - std::vector queueCreateInfos; - for (UInt32 queueFamily : usedQueueFamilies) - { - auto it = std::find_if(queueCreateInfos.begin(), queueCreateInfos.end(), [queueFamily] (const VkDeviceQueueCreateInfo& createInfo) + std::array queuesFamilies = { { - return createInfo.queueFamilyIndex == queueFamily; + {graphicsQueueNodeIndex, 1.f}, + {presentQueueNodeIndex, 1.f}, + {transfertQueueNodeFamily, 1.f} + } + }; + + *presentableFamilyQueue = presentQueueNodeIndex; + + return CreateDevice(gpu, queuesFamilies.data(), queuesFamilies.size()); + } + + std::shared_ptr Vulkan::CreateDevice(VkPhysicalDevice gpu, const QueueFamily* queueFamilies, std::size_t queueFamilyCount) + { + std::vector queueCreateInfos; + queueCreateInfos.reserve(queueFamilyCount); + + for (std::size_t i = 0; i < queueFamilyCount; ++i) + { + const QueueFamily& queueFamily = queueFamilies[i]; + + auto it = std::find_if(queueCreateInfos.begin(), queueCreateInfos.end(), [&] (const VkDeviceQueueCreateInfo& createInfo) + { + return createInfo.queueFamilyIndex == queueFamily.familyIndex; }); if (it == queueCreateInfos.end()) @@ -284,16 +339,15 @@ namespace Nz VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, // VkStructureType sType; nullptr, // const void* pNext; 0, // VkDeviceQueueCreateFlags flags; - queueFamily, // uint32_t queueFamilyIndex; + queueFamily.familyIndex, // uint32_t queueFamilyIndex; 1, // uint32_t queueCount; - priorities.data() // const float* pQueuePriorities; + &queueFamily.priority // const float* pQueuePriorities; }; queueCreateInfos.emplace_back(createInfo); } } - std::vector enabledLayers; std::vector enabledExtensions; @@ -356,25 +410,51 @@ namespace Nz nullptr }; - ///TODO: First create then move - s_devices.emplace_back(s_instance); + std::shared_ptr device = std::make_shared(s_instance); + if (!device->Create(gpu, createInfo)) + { + NazaraError("Failed to create Vulkan Device: " + TranslateVulkanError(device->GetLastErrorCode())); + return {}; + } - Vk::Device& device = s_devices.back(); - device.Create(gpu, createInfo); + s_devices.emplace_back(device); - *presentableFamilyQueue = presentQueueNodeIndex; - - return device.CreateHandle(); + return device; } - Vk::DeviceHandle Vulkan::SelectDevice(VkPhysicalDevice gpu, const Vk::Surface& surface, UInt32* presentableFamilyQueue) + std::shared_ptr Vulkan::SelectDevice(VkPhysicalDevice gpu) + { + for (auto it = s_devices.begin(); it != s_devices.end();) + { + auto devicePtr = it->lock(); + if (!devicePtr) + { + it = s_devices.erase(it); + continue; + } + + if (devicePtr->GetPhysicalDevice() == gpu) + return devicePtr; + } + + return CreateDevice(gpu); + } + + std::shared_ptr Vulkan::SelectDevice(VkPhysicalDevice gpu, const Vk::Surface& surface, UInt32* presentableFamilyQueue) { // First, try to find a device compatible with that surface - for (Vk::Device& device : s_devices) + for (auto it = s_devices.begin(); it != s_devices.end();) { - if (device.GetPhysicalDevice() == gpu) + auto devicePtr = it->lock(); + if (!devicePtr) { - const std::vector& queueFamilyInfo = device.GetEnabledQueues(); + it = s_devices.erase(it); + continue; + } + + if (devicePtr->GetPhysicalDevice() == gpu) + { + const std::vector& queueFamilyInfo = devicePtr->GetEnabledQueues(); UInt32 presentableQueueFamilyIndex = UINT32_MAX; for (Vk::Device::QueueFamilyInfo queueInfo : queueFamilyInfo) { @@ -393,9 +473,11 @@ namespace Nz if (presentableQueueFamilyIndex != UINT32_MAX) { *presentableFamilyQueue = presentableQueueFamilyIndex; - return device.CreateHandle(); + return devicePtr; } } + + ++it; } // No device had support for that surface, create one @@ -411,7 +493,7 @@ namespace Nz Vk::Loader::Uninitialize(); } - std::list Vulkan::s_devices; + std::vector> Vulkan::s_devices; std::vector Vulkan::s_physDevices; Vk::Instance Vulkan::s_instance; ParameterList Vulkan::s_initializationParameters; diff --git a/src/Nazara/VulkanRenderer/VulkanBuffer.cpp b/src/Nazara/VulkanRenderer/VulkanBuffer.cpp index 530c345b4..08c9469a9 100644 --- a/src/Nazara/VulkanRenderer/VulkanBuffer.cpp +++ b/src/Nazara/VulkanRenderer/VulkanBuffer.cpp @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include namespace Nz @@ -11,13 +12,40 @@ namespace Nz bool VulkanBuffer::Fill(const void* data, UInt32 offset, UInt32 size) { - return m_softwareData.Fill(data, offset, size); + void* ptr = Map(BufferAccess_WriteOnly, offset, size); + if (!ptr) + return false; + + Nz::CallOnExit unmapOnExit([this]() { Unmap(); }); + + std::memcpy(ptr, data, size); + + return true; } bool VulkanBuffer::Initialize(UInt32 size, BufferUsageFlags usage) { - m_usage = usage; - return m_softwareData.Initialize(size, usage); + if (!m_buffer.Create(m_device, 0, size, (m_type == BufferType_Index) ? VK_BUFFER_USAGE_INDEX_BUFFER_BIT : VK_BUFFER_USAGE_VERTEX_BUFFER_BIT)) + { + NazaraError("Failed to create vertex buffer"); + return false; + } + + VkMemoryRequirements memRequirement = m_buffer.GetMemoryRequirements(); + + if (!m_memory.Create(m_device, memRequirement.size, memRequirement.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) + { + NazaraError("Failed to allocate vertex buffer memory"); + return false; + } + + if (!m_buffer.BindBufferMemory(m_memory)) + { + NazaraError("Failed to bind vertex buffer to its memory"); + return false; + } + + return true; } DataStorage VulkanBuffer::GetStorage() const @@ -25,13 +53,17 @@ namespace Nz return DataStorage_Hardware; } - void* VulkanBuffer::Map(BufferAccess access, UInt32 offset, UInt32 size) + void* VulkanBuffer::Map(BufferAccess /*access*/, UInt32 offset, UInt32 size) { - return m_softwareData.Map(access, offset, size); + if (!m_memory.Map(offset, size)) + return nullptr; + + return m_memory.GetMappedPointer(); } bool VulkanBuffer::Unmap() { - return m_softwareData.Unmap(); + m_memory.Unmap(); + return true; } } diff --git a/src/Nazara/VulkanRenderer/VulkanDevice.cpp b/src/Nazara/VulkanRenderer/VulkanDevice.cpp index bec1b3adb..2557f28b0 100644 --- a/src/Nazara/VulkanRenderer/VulkanDevice.cpp +++ b/src/Nazara/VulkanRenderer/VulkanDevice.cpp @@ -8,4 +8,9 @@ namespace Nz { VulkanDevice::~VulkanDevice() = default; + + std::unique_ptr VulkanDevice::InstantiateBuffer(Buffer* parent, BufferType type) + { + return std::make_unique(CreateHandle(), parent, type); + } } diff --git a/src/Nazara/VulkanRenderer/VulkanRenderer.cpp b/src/Nazara/VulkanRenderer/VulkanRenderer.cpp index 57db953d4..db44df280 100644 --- a/src/Nazara/VulkanRenderer/VulkanRenderer.cpp +++ b/src/Nazara/VulkanRenderer/VulkanRenderer.cpp @@ -4,11 +4,12 @@ #include #include -#include +#include #include #include #include #include +#include #include namespace Nz @@ -18,11 +19,6 @@ namespace Nz Vulkan::Uninitialize(); } - std::unique_ptr VulkanRenderer::CreateHardwareBufferImpl(Buffer* parent, BufferType type) - { - return std::make_unique(parent, type); //< TODO - } - std::unique_ptr VulkanRenderer::CreateRenderSurfaceImpl() { return std::make_unique(); @@ -33,9 +29,10 @@ namespace Nz return std::make_unique(); } - std::unique_ptr VulkanRenderer::InstanciateRenderDevice(std::size_t deviceIndex) + std::shared_ptr VulkanRenderer::InstanciateRenderDevice(std::size_t deviceIndex) { - return std::unique_ptr(); + assert(deviceIndex < m_physDevices.size()); + return Vulkan::SelectDevice(m_physDevices[deviceIndex].device); } bool VulkanRenderer::IsBetterThan(const RendererImpl* other) const @@ -69,14 +66,14 @@ namespace Nz return APIVersion; } - std::vector VulkanRenderer::QueryRenderDevices() const + std::vector VulkanRenderer::QueryRenderDevices() const { - std::vector devices; + std::vector devices; devices.reserve(m_physDevices.size()); for (const Vk::PhysicalDevice& physDevice : m_physDevices) { - RenderDevice device; + RenderDeviceInfo device; device.name = physDevice.properties.deviceName; switch (physDevice.properties.deviceType) @@ -104,7 +101,7 @@ namespace Nz break; } - devices.emplace_back(device); + devices.emplace_back(std::move(device)); } return devices; From a2691ee12e35c1b924faf6e1fc66d18e00613a63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Fri, 9 Mar 2018 16:49:15 +0100 Subject: [PATCH 079/316] Forgot a file --- include/Nazara/VulkanRenderer/VulkanRenderer.hpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/Nazara/VulkanRenderer/VulkanRenderer.hpp b/include/Nazara/VulkanRenderer/VulkanRenderer.hpp index b7ae2b723..cebc25089 100644 --- a/include/Nazara/VulkanRenderer/VulkanRenderer.hpp +++ b/include/Nazara/VulkanRenderer/VulkanRenderer.hpp @@ -25,18 +25,17 @@ namespace Nz VulkanRenderer() = default; ~VulkanRenderer(); - std::unique_ptr CreateHardwareBufferImpl(Buffer* parent, BufferType type) override; std::unique_ptr CreateRenderSurfaceImpl() override; std::unique_ptr CreateRenderWindowImpl() override; - std::unique_ptr InstanciateRenderDevice(std::size_t deviceIndex) override; + std::shared_ptr InstanciateRenderDevice(std::size_t deviceIndex) override; bool IsBetterThan(const RendererImpl* other) const override; RenderAPI QueryAPI() const override; String QueryAPIString() const override; UInt32 QueryAPIVersion() const override; - std::vector QueryRenderDevices() const override; + std::vector QueryRenderDevices() const override; bool Prepare(const ParameterList& parameters) override; From e4eae425b29397a0d5cc07138b502acf98c78278 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 6 Jun 2018 20:18:42 +0200 Subject: [PATCH 080/316] Add support for Uniform Buffer to Utility/Renderer --- include/Nazara/Renderer/OpenGL.hpp | 2 +- include/Nazara/Renderer/Renderer.hpp | 3 + include/Nazara/Utility/Enums.hpp | 3 +- include/Nazara/Utility/IndexBuffer.hpp | 1 - include/Nazara/Utility/IndexBuffer.inl | 5 - include/Nazara/Utility/UniformBuffer.hpp | 69 +++++++++++++ include/Nazara/Utility/UniformBuffer.inl | 41 ++++++++ src/Nazara/Renderer/OpenGL.cpp | 17 ++-- src/Nazara/Renderer/Renderer.cpp | 17 ++++ src/Nazara/Utility/IndexBuffer.cpp | 1 + src/Nazara/Utility/UniformBuffer.cpp | 118 +++++++++++++++++++++++ src/Nazara/Utility/VertexBuffer.cpp | 1 + 12 files changed, 259 insertions(+), 19 deletions(-) create mode 100644 include/Nazara/Utility/UniformBuffer.hpp create mode 100644 include/Nazara/Utility/UniformBuffer.inl create mode 100644 src/Nazara/Utility/UniformBuffer.cpp diff --git a/include/Nazara/Renderer/OpenGL.hpp b/include/Nazara/Renderer/OpenGL.hpp index c87426f12..ef791f96e 100644 --- a/include/Nazara/Renderer/OpenGL.hpp +++ b/include/Nazara/Renderer/OpenGL.hpp @@ -132,7 +132,6 @@ namespace Nz static GLenum BufferLock[BufferAccess_Max+1]; static GLenum BufferLockRange[BufferAccess_Max+1]; static GLenum BufferTarget[BufferType_Max+1]; - static GLenum BufferTargetBinding[BufferType_Max+1]; static GLenum ComponentType[ComponentType_Max+1]; static GLenum CubemapFace[6]; // Un cube possède six faces et ça n'est pas près de changer static GLenum FaceFilling[FaceFilling_Max+1]; @@ -161,6 +160,7 @@ NAZARA_RENDERER_API extern PFNGLBEGINCONDITIONALRENDERPROC glBeginConditionalR NAZARA_RENDERER_API extern PFNGLBEGINQUERYPROC glBeginQuery; NAZARA_RENDERER_API extern PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation; NAZARA_RENDERER_API extern PFNGLBINDBUFFERPROC glBindBuffer; +NAZARA_RENDERER_API extern PFNGLBINDBUFFERRANGEPROC glBindBufferRange; NAZARA_RENDERER_API extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer; NAZARA_RENDERER_API extern PFNGLBINDFRAGDATALOCATIONPROC glBindFragDataLocation; NAZARA_RENDERER_API extern PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer; diff --git a/include/Nazara/Renderer/Renderer.hpp b/include/Nazara/Renderer/Renderer.hpp index f0154934b..c23001ef0 100644 --- a/include/Nazara/Renderer/Renderer.hpp +++ b/include/Nazara/Renderer/Renderer.hpp @@ -25,6 +25,7 @@ namespace Nz class Shader; class Texture; class TextureSampler; + class UniformBuffer; class VertexBuffer; class VertexDeclaration; @@ -41,6 +42,8 @@ namespace Nz static void BeginCondition(const GpuQuery& query, GpuQueryCondition condition); + static void BindUniformBuffer(unsigned int bindingPoint, const UniformBuffer* uniformBuffer); + static void Clear(UInt32 flags = RendererBuffer_Color | RendererBuffer_Depth); static void DrawFullscreenQuad(); diff --git a/include/Nazara/Utility/Enums.hpp b/include/Nazara/Utility/Enums.hpp index d6fee2127..edc8708b4 100644 --- a/include/Nazara/Utility/Enums.hpp +++ b/include/Nazara/Utility/Enums.hpp @@ -49,8 +49,9 @@ namespace Nz { BufferType_Index, BufferType_Vertex, + BufferType_Uniform, - BufferType_Max = BufferType_Vertex + BufferType_Max = BufferType_Uniform }; enum BufferUsage diff --git a/include/Nazara/Utility/IndexBuffer.hpp b/include/Nazara/Utility/IndexBuffer.hpp index 7feee06e8..dd30a4e49 100644 --- a/include/Nazara/Utility/IndexBuffer.hpp +++ b/include/Nazara/Utility/IndexBuffer.hpp @@ -38,7 +38,6 @@ namespace Nz inline const BufferRef& GetBuffer() const; inline UInt32 GetEndOffset() const; inline UInt32 GetIndexCount() const; - inline DataStorage GetStorage() const; inline UInt32 GetStride() const; inline UInt32 GetStartOffset() const; diff --git a/include/Nazara/Utility/IndexBuffer.inl b/include/Nazara/Utility/IndexBuffer.inl index 1bcf60b26..52103b46d 100644 --- a/include/Nazara/Utility/IndexBuffer.inl +++ b/include/Nazara/Utility/IndexBuffer.inl @@ -22,11 +22,6 @@ namespace Nz return m_indexCount; } - inline DataStorage IndexBuffer::GetStorage() const - { - return DataStorage(); - } - inline UInt32 IndexBuffer::GetStride() const { return static_cast((m_largeIndices) ? sizeof(UInt32) : sizeof(UInt16)); diff --git a/include/Nazara/Utility/UniformBuffer.hpp b/include/Nazara/Utility/UniformBuffer.hpp new file mode 100644 index 000000000..aa77c3069 --- /dev/null +++ b/include/Nazara/Utility/UniformBuffer.hpp @@ -0,0 +1,69 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_UNIFORMBUFFER_HPP +#define NAZARA_UNIFORMBUFFER_HPP + +#include +#include +#include +#include + +namespace Nz +{ + class UniformBuffer; + + using UniformBufferConstRef = ObjectRef; + using UniformBufferRef = ObjectRef; + + class NAZARA_UTILITY_API UniformBuffer : public RefCounted + { + public: + UniformBuffer() = default; + UniformBuffer(BufferRef buffer); + UniformBuffer(BufferRef buffer, UInt32 offset, UInt32 size); + UniformBuffer(UInt32 length, DataStorage storage, BufferUsageFlags usage); + UniformBuffer(const UniformBuffer& uniformBuffer); + UniformBuffer(UniformBuffer&&) = delete; + ~UniformBuffer(); + + bool Fill(const void* data, UInt32 offset, UInt32 size); + + inline const BufferRef& GetBuffer() const; + inline UInt32 GetEndOffset() const; + inline UInt32 GetStartOffset() const; + + inline bool IsValid() const; + + void* Map(BufferAccess access, UInt32 offset = 0, UInt32 size = 0); + void* Map(BufferAccess access, UInt32 offset = 0, UInt32 size = 0) const; + + void Reset(); + void Reset(BufferRef buffer); + void Reset(BufferRef buffer, UInt32 offset, UInt32 size); + void Reset(UInt32 size, DataStorage storage, BufferUsageFlags usage); + void Reset(const UniformBuffer& uniformBuffer); + + void Unmap() const; + + UniformBuffer& operator=(const UniformBuffer& uniformBuffer); + UniformBuffer& operator=(UniformBuffer&&) = delete; + + template static UniformBufferRef New(Args&&... args); + + // Signals: + NazaraSignal(OnUniformBufferRelease, const UniformBuffer* /*UniformBuffer*/); + + private: + BufferRef m_buffer; + UInt32 m_endOffset; + UInt32 m_startOffset; + }; +} + +#include + +#endif // NAZARA_UNIFORMBUFFER_HPP diff --git a/include/Nazara/Utility/UniformBuffer.inl b/include/Nazara/Utility/UniformBuffer.inl new file mode 100644 index 000000000..50b2199eb --- /dev/null +++ b/include/Nazara/Utility/UniformBuffer.inl @@ -0,0 +1,41 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + inline const BufferRef& UniformBuffer::GetBuffer() const + { + return m_buffer; + } + + inline UInt32 UniformBuffer::GetEndOffset() const + { + return m_endOffset; + } + + inline UInt32 UniformBuffer::GetStartOffset() const + { + return m_startOffset; + } + + inline bool UniformBuffer::IsValid() const + { + return m_buffer.IsValid(); + } + + template + UniformBufferRef UniformBuffer::New(Args&&... args) + { + std::unique_ptr object(new UniformBuffer(std::forward(args)...)); + object->SetPersistent(false); + + return object.release(); + } +} + +#include diff --git a/src/Nazara/Renderer/OpenGL.cpp b/src/Nazara/Renderer/OpenGL.cpp index 0d6f07d2e..080c1e73c 100644 --- a/src/Nazara/Renderer/OpenGL.cpp +++ b/src/Nazara/Renderer/OpenGL.cpp @@ -885,6 +885,7 @@ namespace Nz glBeginQuery = reinterpret_cast(LoadEntry("glBeginQuery")); glBindAttribLocation = reinterpret_cast(LoadEntry("glBindAttribLocation")); glBindBuffer = reinterpret_cast(LoadEntry("glBindBuffer")); + glBindBufferRange = reinterpret_cast(LoadEntry("glBindBufferRange")); glBindFragDataLocation = reinterpret_cast(LoadEntry("glBindFragDataLocation")); glBindFramebuffer = reinterpret_cast(LoadEntry("glBindFramebuffer")); glBindRenderbuffer = reinterpret_cast(LoadEntry("glBindRenderbuffer")); @@ -1896,19 +1897,12 @@ namespace Nz GLenum OpenGL::BufferTarget[] = { - GL_ELEMENT_ARRAY_BUFFER, // BufferType_Index, - GL_ARRAY_BUFFER, // BufferType_Vertex + GL_ELEMENT_ARRAY_BUFFER, // BufferType_Index + GL_ARRAY_BUFFER, // BufferType_Vertex + GL_UNIFORM_BUFFER // BufferType_Uniform }; - static_assert(BufferType_Max + 1 == 2, "Buffer target array is incomplete"); - - GLenum OpenGL::BufferTargetBinding[] = - { - GL_ELEMENT_ARRAY_BUFFER_BINDING, // BufferType_Index, - GL_ARRAY_BUFFER_BINDING, // BufferType_Vertex - }; - - static_assert(BufferType_Max + 1 == 2, "Buffer target binding array is incomplete"); + static_assert(BufferType_Max + 1 == 3, "Buffer target array is incomplete"); GLenum OpenGL::ComponentType[] = { @@ -2117,6 +2111,7 @@ PFNGLBEGINCONDITIONALRENDERPROC glBeginConditionalRender = nullptr; PFNGLBEGINQUERYPROC glBeginQuery = nullptr; PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation = nullptr; PFNGLBINDBUFFERPROC glBindBuffer = nullptr; +PFNGLBINDBUFFERRANGEPROC glBindBufferRange = nullptr; PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer = nullptr; PFNGLBINDFRAGDATALOCATIONPROC glBindFragDataLocation = nullptr; PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer = nullptr; diff --git a/src/Nazara/Renderer/Renderer.cpp b/src/Nazara/Renderer/Renderer.cpp index d2a3ed7e1..b70e64423 100644 --- a/src/Nazara/Renderer/Renderer.cpp +++ b/src/Nazara/Renderer/Renderer.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -134,6 +135,22 @@ namespace Nz glBeginConditionalRender(query.GetOpenGLID(), OpenGL::QueryCondition[condition]); } + void Renderer::BindUniformBuffer(unsigned int bindingPoint, const UniformBuffer* uniformBuffer) + { + NazaraAssert(uniformBuffer && uniformBuffer->IsValid(), "Buffer must be valid"); + + const Nz::BufferRef& buffer = uniformBuffer->GetBuffer(); + if (buffer->GetStorage() != DataStorage_Hardware) + { + NazaraError("Uniform buffer storage is not hardware"); + return; + } + + HardwareBuffer* hwBuffer = static_cast(buffer->GetImpl()); + + glBindBufferRange(GL_UNIFORM_BUFFER, bindingPoint, hwBuffer->GetOpenGLID(), uniformBuffer->GetStartOffset(), uniformBuffer->GetEndOffset() - uniformBuffer->GetStartOffset()); + } + void Renderer::Clear(UInt32 flags) { #ifdef NAZARA_DEBUG diff --git a/src/Nazara/Utility/IndexBuffer.cpp b/src/Nazara/Utility/IndexBuffer.cpp index 4455a2f0c..e1e5cb126 100644 --- a/src/Nazara/Utility/IndexBuffer.cpp +++ b/src/Nazara/Utility/IndexBuffer.cpp @@ -106,6 +106,7 @@ namespace Nz void IndexBuffer::Reset(bool largeIndices, BufferRef buffer, UInt32 offset, UInt32 size) { NazaraAssert(buffer && buffer->IsValid(), "Invalid buffer"); + NazaraAssert(buffer->GetType() == BufferType_Index, "Buffer must be an index buffer"); NazaraAssert(size > 0, "Invalid size"); NazaraAssert(offset + size > buffer->GetSize(), "Virtual buffer exceed buffer bounds"); diff --git a/src/Nazara/Utility/UniformBuffer.cpp b/src/Nazara/Utility/UniformBuffer.cpp new file mode 100644 index 000000000..0ae065e3f --- /dev/null +++ b/src/Nazara/Utility/UniformBuffer.cpp @@ -0,0 +1,118 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include + +namespace Nz +{ + UniformBuffer::UniformBuffer(BufferRef buffer) + { + ErrorFlags(ErrorFlag_ThrowException, true); + Reset(std::move(buffer)); + } + + UniformBuffer::UniformBuffer(BufferRef buffer, UInt32 offset, UInt32 size) + { + ErrorFlags(ErrorFlag_ThrowException, true); + Reset(std::move(buffer), offset, size); + } + + UniformBuffer::UniformBuffer(UInt32 length, DataStorage storage, BufferUsageFlags usage) + { + ErrorFlags(ErrorFlag_ThrowException, true); + Reset(length, storage, usage); + } + + UniformBuffer::UniformBuffer(const UniformBuffer& uniformBuffer) : + RefCounted(), + m_buffer(uniformBuffer.m_buffer), + m_endOffset(uniformBuffer.m_endOffset), + m_startOffset(uniformBuffer.m_startOffset) + { + } + + UniformBuffer::~UniformBuffer() + { + OnUniformBufferRelease(this); + } + + bool UniformBuffer::Fill(const void* data, UInt32 offset, UInt32 size) + { + NazaraAssert(m_buffer && m_buffer->IsValid(), "Invalid buffer"); + NazaraAssert(m_startOffset + offset + size <= m_endOffset, "Exceeding virtual buffer size"); + + return m_buffer->Fill(data, m_startOffset + offset, size); + } + + void* UniformBuffer::Map(BufferAccess access, UInt32 offset, UInt32 size) + { + NazaraAssert(m_buffer && m_buffer->IsValid(), "Invalid buffer"); + NazaraAssert(m_startOffset + offset + size <= m_endOffset, "Exceeding virtual buffer size"); + + return m_buffer->Map(access, offset, size); + } + + void* UniformBuffer::Map(BufferAccess access, UInt32 offset, UInt32 size) const + { + NazaraAssert(m_buffer && m_buffer->IsValid(), "Invalid buffer"); + NazaraAssert(m_startOffset + offset + size <= m_endOffset, "Exceeding virtual buffer size"); + + return m_buffer->Map(access, offset, size); + } + + void UniformBuffer::Reset() + { + m_buffer.Reset(); + } + + void UniformBuffer::Reset(BufferRef buffer) + { + NazaraAssert(buffer && buffer->IsValid(), "Invalid buffer"); + + Reset(buffer, 0, buffer->GetSize()); + } + + void UniformBuffer::Reset(BufferRef buffer, UInt32 offset, UInt32 size) + { + NazaraAssert(buffer && buffer->IsValid(), "Invalid buffer"); + NazaraAssert(buffer->GetType() == BufferType_Uniform, "Buffer must be an uniform buffer"); + NazaraAssert(size > 0, "Invalid size"); + NazaraAssert(offset + size > buffer->GetSize(), "Virtual buffer exceed buffer bounds"); + + m_buffer = buffer; + m_endOffset = offset + size; + m_startOffset = offset; + } + + void UniformBuffer::Reset(UInt32 size, DataStorage storage, BufferUsageFlags usage) + { + m_endOffset = size; + m_startOffset = 0; + + m_buffer = Buffer::New(BufferType_Uniform, m_endOffset, storage, usage); + } + + void UniformBuffer::Reset(const UniformBuffer& UniformBuffer) + { + m_buffer = UniformBuffer.m_buffer; + m_endOffset = UniformBuffer.m_endOffset; + m_startOffset = UniformBuffer.m_startOffset; + } + + void UniformBuffer::Unmap() const + { + m_buffer->Unmap(); + } + + UniformBuffer& UniformBuffer::operator=(const UniformBuffer& uniformBuffer) + { + Reset(uniformBuffer); + + return *this; + } +} diff --git a/src/Nazara/Utility/VertexBuffer.cpp b/src/Nazara/Utility/VertexBuffer.cpp index e072c4aa1..d84dd8b39 100644 --- a/src/Nazara/Utility/VertexBuffer.cpp +++ b/src/Nazara/Utility/VertexBuffer.cpp @@ -98,6 +98,7 @@ namespace Nz void VertexBuffer::Reset(VertexDeclarationConstRef vertexDeclaration, BufferRef buffer) { NazaraAssert(buffer && buffer->IsValid(), "Invalid buffer"); + NazaraAssert(buffer->GetType() == BufferType_Vertex, "Buffer must be a vertex buffer"); UInt32 size = buffer->GetSize(); Reset(std::move(vertexDeclaration), std::move(buffer), 0, size); From 8ba8d2e92f434f15efc10f3a1f3005041a0d5ace Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 12 Jun 2018 19:33:06 +0200 Subject: [PATCH 081/316] Merge branch 'ubo' into vulkan --- include/Nazara/Renderer/Renderer.hpp | 54 ---------------------------- 1 file changed, 54 deletions(-) diff --git a/include/Nazara/Renderer/Renderer.hpp b/include/Nazara/Renderer/Renderer.hpp index 1e9e6d47d..1f14c04c0 100644 --- a/include/Nazara/Renderer/Renderer.hpp +++ b/include/Nazara/Renderer/Renderer.hpp @@ -15,23 +15,8 @@ namespace Nz { -<<<<<<< HEAD class AbstractBuffer; class Buffer; -======= - class Color; - class Context; - class GpuQuery; - class IndexBuffer; - class RenderTarget; - struct RenderStates; - class Shader; - class Texture; - class TextureSampler; - class UniformBuffer; - class VertexBuffer; - class VertexDeclaration; ->>>>>>> ubo class NAZARA_RENDERER_API Renderer { @@ -39,46 +24,7 @@ namespace Nz Renderer() = delete; ~Renderer() = delete; -<<<<<<< HEAD static inline RendererImpl* GetRendererImpl(); -======= - static void BeginCondition(const GpuQuery& query, GpuQueryCondition condition); - - static void BindUniformBuffer(unsigned int bindingPoint, const UniformBuffer* uniformBuffer); - - static void Clear(UInt32 flags = RendererBuffer_Color | RendererBuffer_Depth); - - static void DrawFullscreenQuad(); - static void DrawIndexedPrimitives(PrimitiveMode mode, unsigned int firstIndex, unsigned int indexCount); - static void DrawIndexedPrimitivesInstanced(unsigned int instanceCount, PrimitiveMode mode, unsigned int firstIndex, unsigned int indexCount); - static void DrawPrimitives(PrimitiveMode mode, unsigned int firstVertex, unsigned int vertexCount); - static void DrawPrimitivesInstanced(unsigned int instanceCount, PrimitiveMode mode, unsigned int firstVertex, unsigned int vertexCount); - - static void Enable(RendererParameter parameter, bool enable); - - static void EndCondition(); - - static void Flush(); - - static RendererComparison GetDepthFunc(); - static VertexBuffer* GetInstanceBuffer(); - static float GetLineWidth(); - static Matrix4f GetMatrix(MatrixType type); - static UInt8 GetMaxAnisotropyLevel(); - static unsigned int GetMaxColorAttachments(); - static unsigned int GetMaxRenderTargets(); - static unsigned int GetMaxTextureSize(); - static unsigned int GetMaxTextureUnits(); - static unsigned int GetMaxVertexAttribs(); - static float GetPointSize(); - static const RenderStates& GetRenderStates(); - static Recti GetScissorRect(); - static const Shader* GetShader(); - static const RenderTarget* GetTarget(); - static Recti GetViewport(); - - static bool HasCapability(RendererCap capability); ->>>>>>> ubo static bool Initialize(); From 848f05a42073a32cc8a544e0f94b855d7bc8a38b Mon Sep 17 00:00:00 2001 From: REMqb Date: Wed, 3 Apr 2019 21:17:06 +0200 Subject: [PATCH 082/316] ~ Initial SDL2 implementation Limitation - Dependent projects need to set NAZARA_PLATFORM_SDL2 if nazara has been build with SDL2 since OpenGL.hpp (and maybe some other headers) exposes platform details - SDL2 window doesn't supports async window since the API isn't fitting for now - Contexts parameters can't be changed until we close all the SDL windows (SDL limitation) --- .gitignore | 2 + SDK/src/NDK/Lua/LuaBinding_Platform.cpp | 5 +- build/config.lua | 3 + build/scripts/common.lua | 2 + build/scripts/modules/platform.lua | 54 +- build/scripts/modules/renderer.lua | 46 +- examples/FirstScene/build.lua | 4 + examples/HardwareInfo/build.lua | 4 + examples/MeshInfos/build.lua | 3 + examples/Particles/build.lua | 4 + examples/Tut00/build.lua | 4 + examples/Tut01/build.lua | 4 + examples/Tut02/build.lua | 4 + include/Nazara/Platform/Keyboard.hpp | 3 + include/Nazara/Platform/VideoMode.hpp | 12 +- include/Nazara/Platform/WindowHandle.hpp | 8 +- include/Nazara/Prerequisites.hpp | 13 +- include/Nazara/Renderer/OpenGL.hpp | 423 +++---- src/Nazara/Platform/Cursor.cpp | 4 +- src/Nazara/Platform/Icon.cpp | 4 +- src/Nazara/Platform/Keyboard.cpp | 4 +- src/Nazara/Platform/Mouse.cpp | 4 +- src/Nazara/Platform/SDL2/CursorImpl.cpp | 108 ++ src/Nazara/Platform/SDL2/CursorImpl.hpp | 45 + src/Nazara/Platform/SDL2/IconImpl.cpp | 49 + src/Nazara/Platform/SDL2/IconImpl.hpp | 33 + src/Nazara/Platform/SDL2/InputImpl.cpp | 234 ++++ src/Nazara/Platform/SDL2/InputImpl.hpp | 30 + src/Nazara/Platform/SDL2/VideoModeImpl.cpp | 51 + src/Nazara/Platform/SDL2/VideoModeImpl.hpp | 22 + src/Nazara/Platform/SDL2/WindowImpl.cpp | 695 +++++++++++ src/Nazara/Platform/SDL2/WindowImpl.hpp | 113 ++ src/Nazara/Platform/VideoMode.cpp | 4 +- src/Nazara/Platform/Win32/InputImpl.cpp | 178 +-- src/Nazara/Platform/Win32/WindowImpl.cpp | 89 +- src/Nazara/Platform/Window.cpp | 4 +- src/Nazara/Platform/X11/InputImpl.cpp | 3 + src/Nazara/Platform/X11/WindowImpl.cpp | 1295 ++++++++++---------- src/Nazara/Renderer/Context.cpp | 5 +- src/Nazara/Renderer/OpenGL.cpp | 452 +++---- src/Nazara/Renderer/SDL2/ContextImpl.cpp | 145 +++ src/Nazara/Renderer/SDL2/ContextImpl.hpp | 42 + 42 files changed, 2943 insertions(+), 1268 deletions(-) create mode 100644 src/Nazara/Platform/SDL2/CursorImpl.cpp create mode 100644 src/Nazara/Platform/SDL2/CursorImpl.hpp create mode 100644 src/Nazara/Platform/SDL2/IconImpl.cpp create mode 100644 src/Nazara/Platform/SDL2/IconImpl.hpp create mode 100644 src/Nazara/Platform/SDL2/InputImpl.cpp create mode 100644 src/Nazara/Platform/SDL2/InputImpl.hpp create mode 100644 src/Nazara/Platform/SDL2/VideoModeImpl.cpp create mode 100644 src/Nazara/Platform/SDL2/VideoModeImpl.hpp create mode 100644 src/Nazara/Platform/SDL2/WindowImpl.cpp create mode 100644 src/Nazara/Platform/SDL2/WindowImpl.hpp create mode 100644 src/Nazara/Renderer/SDL2/ContextImpl.cpp create mode 100644 src/Nazara/Renderer/SDL2/ContextImpl.hpp diff --git a/.gitignore b/.gitignore index 92e76fa18..5d64539e6 100644 --- a/.gitignore +++ b/.gitignore @@ -162,3 +162,5 @@ DocProject/Help/*.hhk DocProject/Help/*.hhp DocProject/Help/Html2 DocProject/Help/html + +build/gmake/ diff --git a/SDK/src/NDK/Lua/LuaBinding_Platform.cpp b/SDK/src/NDK/Lua/LuaBinding_Platform.cpp index 2a2b02e7e..ac16f6fb3 100644 --- a/SDK/src/NDK/Lua/LuaBinding_Platform.cpp +++ b/SDK/src/NDK/Lua/LuaBinding_Platform.cpp @@ -33,7 +33,7 @@ namespace Ndk keyboard.PushGlobalTable(state); { - static_assert(Nz::Keyboard::Count == 121, "Nz::Keyboard::Key has been updated but change was not reflected to Lua binding"); + static_assert(Nz::Keyboard::Count == 124, "Nz::Keyboard::Key has been updated but change was not reflected to Lua binding"); state.PushField("Undefined", Nz::Keyboard::Undefined); @@ -63,6 +63,7 @@ namespace Ndk state.PushField("Divide", Nz::Keyboard::Divide); state.PushField("Multiply", Nz::Keyboard::Multiply); state.PushField("Subtract", Nz::Keyboard::Subtract); + state.PushField("NumpadReturn", Nz::Keyboard::NumpadReturn); state.PushField("Backslash", Nz::Keyboard::Backslash); state.PushField("Backspace", Nz::Keyboard::Backspace); @@ -98,6 +99,8 @@ namespace Ndk state.PushField("Space", Nz::Keyboard::Space); state.PushField("Tab", Nz::Keyboard::Tab); state.PushField("Tilde", Nz::Keyboard::Tilde); + state.PushField("Menu", Nz::Keyboard::Menu); + state.PushField("ISOBackslash102", Nz::Keyboard::ISOBackslash102); state.PushField("Browser_Back", Nz::Keyboard::Browser_Back); state.PushField("Browser_Favorites", Nz::Keyboard::Browser_Favorites); state.PushField("Browser_Forward", Nz::Keyboard::Browser_Forward); diff --git a/build/config.lua b/build/config.lua index 571bf6dc9..a1f4546eb 100644 --- a/build/config.lua +++ b/build/config.lua @@ -24,3 +24,6 @@ ServerMode = false -- Builds modules as one united library (useless on POSIX systems) UniteModules = false + +-- Use SDL2 platform +PlatformSDL2 = true \ No newline at end of file diff --git a/build/scripts/common.lua b/build/scripts/common.lua index f5f50a9f8..a50fc5c27 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -387,6 +387,7 @@ function NazaraBuild:Initialize() if (f) then MODULE = {} self:SetupModuleTable(MODULE) + Config = self.Config f() @@ -529,6 +530,7 @@ function NazaraBuild:LoadConfig() AddBoolOption("PremakeProject", "premakeproject", "Add a PremakeProject as a shortcut to call Premake") AddBoolOption("ServerMode", "server", "Excludes client-only modules/tools/examples") AddBoolOption("UniteModules", "united", "Builds all the modules as one united library") + AddBoolOption("PlatformSDL2", "platform-sdl2", "Use SDL2 instead of native APIs") -- AdditionalCompilationOptions do diff --git a/build/scripts/modules/platform.lua b/build/scripts/modules/platform.lua index ad013c306..2768d1a28 100644 --- a/build/scripts/modules/platform.lua +++ b/build/scripts/modules/platform.lua @@ -7,27 +7,41 @@ MODULE.Libraries = { "NazaraUtility" } -MODULE.OsFiles.Windows = { - "../src/Nazara/Platform/Win32/**.hpp", - "../src/Nazara/Platform/Win32/**.cpp" -} +if Config.PlatformSDL2 then + table.insert(MODULE.Defines, "NAZARA_PLATFORM_SDL2") -MODULE.OsFiles.Posix = { - "../src/Nazara/Platform/X11/**.hpp", - "../src/Nazara/Platform/X11/**.cpp" -} + table.insert(MODULE.Files, "../src/Nazara/Platform/SDL2/**.hpp") + table.insert(MODULE.Files, "../src/Nazara/Platform/SDL2/**.cpp") -MODULE.OsLibraries.Windows = { - "gdi32" -} + table.insert(MODULE.Libraries, "SDL2") -MODULE.OsLibraries.Posix = { - "X11", - "xcb", - "xcb-cursor", - "xcb-ewmh", - "xcb-icccm", - "xcb-keysyms", - "xcb-randr" -} + MODULE.FilesExcluded = { + "../src/Nazara/Platform/Win32/**", + "../src/Nazara/Platform/X11/**" + } +else + MODULE.OsFiles.Windows = { + "../src/Nazara/Platform/Win32/**.hpp", + "../src/Nazara/Platform/Win32/**.cpp" + } + MODULE.OsFiles.Posix = { + "../src/Nazara/Platform/X11/**.hpp", + "../src/Nazara/Platform/X11/**.cpp" + } + + MODULE.OsLibraries.Windows = { + "gdi32" + } + + MODULE.OsLibraries.Posix = { + "X11", + "xcb", + "xcb-cursor", + "xcb-ewmh", + "xcb-icccm", + "xcb-keysyms", + "xcb-randr" + } + +end diff --git a/build/scripts/modules/renderer.lua b/build/scripts/modules/renderer.lua index 11b378d2b..800ca33b7 100644 --- a/build/scripts/modules/renderer.lua +++ b/build/scripts/modules/renderer.lua @@ -12,23 +12,35 @@ MODULE.Libraries = { "NazaraPlatform" } -MODULE.OsFiles.Windows = { - "../src/Nazara/Renderer/Win32/**.hpp", - "../src/Nazara/Renderer/Win32/**.cpp" -} +if Config.PlatformSDL2 then + table.insert(MODULE.Defines, "NAZARA_PLATFORM_SDL2") -MODULE.OsFiles.Posix = { - "../src/Nazara/Renderer/GLX/**.hpp", - "../src/Nazara/Renderer/GLX/**.cpp" -} + table.insert(MODULE.Files, "../src/Nazara/Renderer/SDL2/**.hpp") + table.insert(MODULE.Files, "../src/Nazara/Renderer/SDL2/**.cpp") -MODULE.OsLibraries.Windows = { - "gdi32", - "opengl32", - "winmm" -} + MODULE.FilesExcluded = { + "../src/Nazara/Renderer/Win32/**", + "../src/Nazara/Renderer/GLX/**.cpp" + } +else + MODULE.OsFiles.Windows = { + "../src/Nazara/Renderer/Win32/**.hpp", + "../src/Nazara/Renderer/Win32/**.cpp" + } -MODULE.OsLibraries.Posix = { - "GL", - "X11" -} + MODULE.OsFiles.Posix = { + "../src/Nazara/Renderer/GLX/**.hpp", + "../src/Nazara/Renderer/GLX/**.cpp" + } + + MODULE.OsLibraries.Windows = { + "gdi32", + "opengl32", + "winmm" + } + + MODULE.OsLibraries.Posix = { + "GL", + "X11" + } +end \ No newline at end of file diff --git a/examples/FirstScene/build.lua b/examples/FirstScene/build.lua index 612965b5a..aba72ac5b 100644 --- a/examples/FirstScene/build.lua +++ b/examples/FirstScene/build.lua @@ -9,3 +9,7 @@ EXAMPLE.Files = { EXAMPLE.Libraries = { "NazaraSDK" } + +if Config.PlatformSDL2 then + table.insert(EXAMPLE.Defines, "NAZARA_PLATFORM_SDL2") +end diff --git a/examples/HardwareInfo/build.lua b/examples/HardwareInfo/build.lua index 953cba7d9..c0917e765 100644 --- a/examples/HardwareInfo/build.lua +++ b/examples/HardwareInfo/build.lua @@ -16,3 +16,7 @@ EXAMPLE.Libraries = { "NazaraRenderer", "NazaraUtility" } + +if Config.PlatformSDL2 then + table.insert(EXAMPLE.Defines, "NAZARA_PLATFORM_SDL2") +end diff --git a/examples/MeshInfos/build.lua b/examples/MeshInfos/build.lua index 74616762e..462533740 100644 --- a/examples/MeshInfos/build.lua +++ b/examples/MeshInfos/build.lua @@ -12,3 +12,6 @@ EXAMPLE.Libraries = { "NazaraUtility" } +if Config.PlatformSDL2 then + table.insert(EXAMPLE.Defines, "NAZARA_PLATFORM_SDL2") +end diff --git a/examples/Particles/build.lua b/examples/Particles/build.lua index 2e1a37801..678a172d4 100644 --- a/examples/Particles/build.lua +++ b/examples/Particles/build.lua @@ -11,3 +11,7 @@ EXAMPLE.Files = { EXAMPLE.Libraries = { "NazaraSDK" } + +if Config.PlatformSDL2 then + table.insert(EXAMPLE.Defines, "NAZARA_PLATFORM_SDL2") +end diff --git a/examples/Tut00/build.lua b/examples/Tut00/build.lua index baf738d1d..bdb125ab1 100644 --- a/examples/Tut00/build.lua +++ b/examples/Tut00/build.lua @@ -20,3 +20,7 @@ EXAMPLE.Libraries = { "NazaraUtility", "NazaraSDK" } + +if Config.PlatformSDL2 then + table.insert(EXAMPLE.Defines, "NAZARA_PLATFORM_SDL2") +end diff --git a/examples/Tut01/build.lua b/examples/Tut01/build.lua index c195cbc1b..6084317f9 100644 --- a/examples/Tut01/build.lua +++ b/examples/Tut01/build.lua @@ -9,3 +9,7 @@ EXAMPLE.Files = { EXAMPLE.Libraries = { "NazaraSDK" } + +if Config.PlatformSDL2 then + table.insert(EXAMPLE.Defines, "NAZARA_PLATFORM_SDL2") +end diff --git a/examples/Tut02/build.lua b/examples/Tut02/build.lua index dbb8a8c9f..4ee3cd467 100644 --- a/examples/Tut02/build.lua +++ b/examples/Tut02/build.lua @@ -9,3 +9,7 @@ EXAMPLE.Files = { EXAMPLE.Libraries = { "NazaraSDK" } + +if Config.PlatformSDL2 then + table.insert(EXAMPLE.Defines, "NAZARA_PLATFORM_SDL2") +end diff --git a/include/Nazara/Platform/Keyboard.hpp b/include/Nazara/Platform/Keyboard.hpp index 24c5c4b4b..c3ec5ac19 100644 --- a/include/Nazara/Platform/Keyboard.hpp +++ b/include/Nazara/Platform/Keyboard.hpp @@ -78,6 +78,7 @@ namespace Nz Decimal, Divide, Multiply, + NumpadReturn, Numpad0, Numpad1, Numpad2, @@ -135,6 +136,8 @@ namespace Nz Space, Tab, Tilde, + Menu, + ISOBackslash102, // Navigator keys Browser_Back, diff --git a/include/Nazara/Platform/VideoMode.hpp b/include/Nazara/Platform/VideoMode.hpp index 663e5721b..55e30af50 100644 --- a/include/Nazara/Platform/VideoMode.hpp +++ b/include/Nazara/Platform/VideoMode.hpp @@ -32,12 +32,12 @@ namespace Nz static const std::vector& GetFullscreenModes(); }; - bool operator==(const VideoMode& left, const VideoMode& right); - bool operator!=(const VideoMode& left, const VideoMode& right); - bool operator<(const VideoMode& left, const VideoMode& right); - bool operator<=(const VideoMode& left, const VideoMode& right); - bool operator>(const VideoMode& left, const VideoMode& right); - bool operator>=(const VideoMode& left, const VideoMode& right); + bool NAZARA_PLATFORM_API operator==(const VideoMode& left, const VideoMode& right); + bool NAZARA_PLATFORM_API operator!=(const VideoMode& left, const VideoMode& right); + bool NAZARA_PLATFORM_API operator<(const VideoMode& left, const VideoMode& right); + bool NAZARA_PLATFORM_API operator<=(const VideoMode& left, const VideoMode& right); + bool NAZARA_PLATFORM_API operator>(const VideoMode& left, const VideoMode& right); + bool NAZARA_PLATFORM_API operator>=(const VideoMode& left, const VideoMode& right); } #endif // NAZARA_VIDEOMODE_HPP diff --git a/include/Nazara/Platform/WindowHandle.hpp b/include/Nazara/Platform/WindowHandle.hpp index 88274f3f9..b220151f7 100644 --- a/include/Nazara/Platform/WindowHandle.hpp +++ b/include/Nazara/Platform/WindowHandle.hpp @@ -8,13 +8,17 @@ #define NAZARA_WINDOWHANDLE_HPP #include -#if defined(NAZARA_PLATFORM_X11) +#if defined(NAZARA_PLATFORM_SDL2) +#elif defined(NAZARA_PLATFORM_X11) #include #endif namespace Nz { - #if defined(NAZARA_PLATFORM_WINDOWS) + #if defined(NAZARA_PLATFORM_SDL2) + // Real type is SDL_Window + using WindowHandle = void*; + #elif defined(NAZARA_PLATFORM_WINDOWS) // http://msdn.microsoft.com/en-us/library/aa383751(v=vs.85).aspx using WindowHandle = void*; #elif defined(NAZARA_PLATFORM_X11) diff --git a/include/Nazara/Prerequisites.hpp b/include/Nazara/Prerequisites.hpp index ddb2796fc..adbe4aa9c 100644 --- a/include/Nazara/Prerequisites.hpp +++ b/include/Nazara/Prerequisites.hpp @@ -117,16 +117,19 @@ #endif #elif defined(__linux__) || defined(__unix__) #define NAZARA_PLATFORM_LINUX - #define NAZARA_PLATFORM_GLX #define NAZARA_PLATFORM_POSIX - #define NAZARA_PLATFORM_X11 + + #ifndef NAZARA_PLATFORM_SDL2 + #define NAZARA_PLATFORM_GLX + #define NAZARA_PLATFORM_X11 + #endif #define NAZARA_EXPORT __attribute__((visibility ("default"))) #define NAZARA_IMPORT __attribute__((visibility ("default"))) /*#elif defined(__APPLE__) && defined(__MACH__) - #define NAZARA_CORE_API - #define NAZARA_PLATFORM_MACOSX - #define NAZARA_PLATFORM_POSIX*/ + #define NAZARA_CORE_API + #define NAZARA_PLATFORM_MACOSX + #define NAZARA_PLATFORM_POSIX*/ #else #error This operating system is not fully supported by the Nazara Engine diff --git a/include/Nazara/Renderer/OpenGL.hpp b/include/Nazara/Renderer/OpenGL.hpp index 77fe10ad3..35a851d00 100644 --- a/include/Nazara/Renderer/OpenGL.hpp +++ b/include/Nazara/Renderer/OpenGL.hpp @@ -6,12 +6,14 @@ #ifndef NAZARA_OPENGL_HPP #define NAZARA_OPENGL_HPP - +#ifndef NAZARA_RENDERER_OPENGL +#define NAZARA_RENDERER_OPENGL +#endif #ifdef NAZARA_RENDERER_OPENGL -#include #include #include +#include #include #include #include @@ -21,7 +23,9 @@ #include #include -#if defined(NAZARA_PLATFORM_WINDOWS) +#if defined(NAZARA_PLATFORM_SDL2) + #include +#elif defined(NAZARA_PLATFORM_WINDOWS) #include #elif defined(NAZARA_PLATFORM_GLX) namespace GLX @@ -129,223 +133,226 @@ namespace Nz static void Uninitialize(); - static GLenum Attachment[AttachmentPoint_Max+1]; - static GLenum BlendFunc[BlendFunc_Max+1]; - static GLenum BufferLock[BufferAccess_Max+1]; - static GLenum BufferLockRange[BufferAccess_Max+1]; - static GLenum BufferTarget[BufferType_Max+1]; - static GLenum BufferTargetBinding[BufferType_Max+1]; - static GLenum ComponentType[ComponentType_Max+1]; + static GLenum Attachment[AttachmentPoint_Max + 1]; + static GLenum BlendFunc[BlendFunc_Max + 1]; + static GLenum BufferLock[BufferAccess_Max + 1]; + static GLenum BufferLockRange[BufferAccess_Max + 1]; + static GLenum BufferTarget[BufferType_Max + 1]; + static GLenum BufferTargetBinding[BufferType_Max + 1]; + static GLenum ComponentType[ComponentType_Max + 1]; static GLenum CubemapFace[6]; // Un cube possède six faces et ça n'est pas près de changer - static GLenum FaceFilling[FaceFilling_Max+1]; - static GLenum FaceSide[FaceSide_Max+1]; - static GLenum PrimitiveMode[PrimitiveMode_Max+1]; - static GLenum QueryCondition[GpuQueryCondition_Max+1]; - static GLenum QueryMode[GpuQueryMode_Max+1]; - static GLenum RendererComparison[RendererComparison_Max+1]; - static GLenum RendererParameter[RendererParameter_Max+1]; - static GLenum SamplerWrapMode[SamplerWrap_Max+1]; - static GLenum ShaderStage[ShaderStageType_Max+1]; - static GLenum StencilOperation[StencilOperation_Max+1]; - static GLenum TextureTarget[ImageType_Max+1]; - static GLenum TextureTargetBinding[ImageType_Max+1]; - static GLenum TextureTargetProxy[ImageType_Max+1]; - static UInt8 VertexComponentIndex[VertexComponent_Max+1]; + static GLenum FaceFilling[FaceFilling_Max + 1]; + static GLenum FaceSide[FaceSide_Max + 1]; + static GLenum PrimitiveMode[PrimitiveMode_Max + 1]; + static GLenum QueryCondition[GpuQueryCondition_Max + 1]; + static GLenum QueryMode[GpuQueryMode_Max + 1]; + static GLenum RendererComparison[RendererComparison_Max + 1]; + static GLenum RendererParameter[RendererParameter_Max + 1]; + static GLenum SamplerWrapMode[SamplerWrap_Max + 1]; + static GLenum ShaderStage[ShaderStageType_Max + 1]; + static GLenum StencilOperation[StencilOperation_Max + 1]; + static GLenum TextureTarget[ImageType_Max + 1]; + static GLenum TextureTargetBinding[ImageType_Max + 1]; + static GLenum TextureTargetProxy[ImageType_Max + 1]; + static UInt8 VertexComponentIndex[VertexComponent_Max + 1]; private: static void OnContextChanged(const Context* newContext); static void OnContextDestruction(const Context* context); }; -NAZARA_RENDERER_API extern PFNGLACTIVETEXTUREPROC glActiveTexture; -NAZARA_RENDERER_API extern PFNGLATTACHSHADERPROC glAttachShader; -NAZARA_RENDERER_API extern PFNGLBEGINCONDITIONALRENDERPROC glBeginConditionalRender; -NAZARA_RENDERER_API extern PFNGLBEGINQUERYPROC glBeginQuery; -NAZARA_RENDERER_API extern PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation; -NAZARA_RENDERER_API extern PFNGLBINDBUFFERPROC glBindBuffer; -NAZARA_RENDERER_API extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer; -NAZARA_RENDERER_API extern PFNGLBINDFRAGDATALOCATIONPROC glBindFragDataLocation; -NAZARA_RENDERER_API extern PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer; -NAZARA_RENDERER_API extern PFNGLBINDSAMPLERPROC glBindSampler; -NAZARA_RENDERER_API extern PFNGLBINDTEXTUREPROC glBindTexture; -NAZARA_RENDERER_API extern PFNGLBINDVERTEXARRAYPROC glBindVertexArray; -NAZARA_RENDERER_API extern PFNGLBLENDFUNCPROC glBlendFunc; -NAZARA_RENDERER_API extern PFNGLBLENDFUNCSEPARATEPROC glBlendFuncSeparate; -NAZARA_RENDERER_API extern PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer; -NAZARA_RENDERER_API extern PFNGLBUFFERDATAPROC glBufferData; -NAZARA_RENDERER_API extern PFNGLBUFFERSUBDATAPROC glBufferSubData; -NAZARA_RENDERER_API extern PFNGLCLEARPROC glClear; -NAZARA_RENDERER_API extern PFNGLCLEARCOLORPROC glClearColor; -NAZARA_RENDERER_API extern PFNGLCLEARDEPTHPROC glClearDepth; -NAZARA_RENDERER_API extern PFNGLCLEARSTENCILPROC glClearStencil; -NAZARA_RENDERER_API extern PFNGLCREATEPROGRAMPROC glCreateProgram; -NAZARA_RENDERER_API extern PFNGLCREATESHADERPROC glCreateShader; -NAZARA_RENDERER_API extern PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus; -NAZARA_RENDERER_API extern PFNGLCOLORMASKPROC glColorMask; -NAZARA_RENDERER_API extern PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glCompressedTexSubImage1D; -NAZARA_RENDERER_API extern PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glCompressedTexSubImage2D; -NAZARA_RENDERER_API extern PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glCompressedTexSubImage3D; -NAZARA_RENDERER_API extern PFNGLCULLFACEPROC glCullFace; -NAZARA_RENDERER_API extern PFNGLCOMPILESHADERPROC glCompileShader; -NAZARA_RENDERER_API extern PFNGLCOPYTEXSUBIMAGE2DPROC glCopyTexSubImage2D; -NAZARA_RENDERER_API extern PFNGLDEBUGMESSAGECALLBACKPROC glDebugMessageCallback; -NAZARA_RENDERER_API extern PFNGLDEBUGMESSAGECONTROLPROC glDebugMessageControl; -NAZARA_RENDERER_API extern PFNGLDEBUGMESSAGEINSERTPROC glDebugMessageInsert; -NAZARA_RENDERER_API extern PFNGLDELETEBUFFERSPROC glDeleteBuffers; -NAZARA_RENDERER_API extern PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers; -NAZARA_RENDERER_API extern PFNGLDELETEPROGRAMPROC glDeleteProgram; -NAZARA_RENDERER_API extern PFNGLDELETEQUERIESPROC glDeleteQueries; -NAZARA_RENDERER_API extern PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers; -NAZARA_RENDERER_API extern PFNGLDELETESAMPLERSPROC glDeleteSamplers; -NAZARA_RENDERER_API extern PFNGLDELETESHADERPROC glDeleteShader; -NAZARA_RENDERER_API extern PFNGLDELETETEXTURESPROC glDeleteTextures; -NAZARA_RENDERER_API extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays; -NAZARA_RENDERER_API extern PFNGLDEPTHFUNCPROC glDepthFunc; -NAZARA_RENDERER_API extern PFNGLDEPTHMASKPROC glDepthMask; -NAZARA_RENDERER_API extern PFNGLDISABLEPROC glDisable; -NAZARA_RENDERER_API extern PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray; -NAZARA_RENDERER_API extern PFNGLDRAWARRAYSPROC glDrawArrays; -NAZARA_RENDERER_API extern PFNGLDRAWARRAYSINSTANCEDPROC glDrawArraysInstanced; -NAZARA_RENDERER_API extern PFNGLDRAWBUFFERPROC glDrawBuffer; -NAZARA_RENDERER_API extern PFNGLDRAWBUFFERSPROC glDrawBuffers; -NAZARA_RENDERER_API extern PFNGLDRAWELEMENTSPROC glDrawElements; -NAZARA_RENDERER_API extern PFNGLDRAWELEMENTSINSTANCEDPROC glDrawElementsInstanced; -NAZARA_RENDERER_API extern PFNGLDRAWTEXTURENVPROC glDrawTexture; -NAZARA_RENDERER_API extern PFNGLENABLEPROC glEnable; -NAZARA_RENDERER_API extern PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray; -NAZARA_RENDERER_API extern PFNGLENDCONDITIONALRENDERPROC glEndConditionalRender; -NAZARA_RENDERER_API extern PFNGLENDQUERYPROC glEndQuery; -NAZARA_RENDERER_API extern PFNGLFLUSHPROC glFlush; -NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer; -NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERTEXTUREPROC glFramebufferTexture; -NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D; -NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D; -NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D; -NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer; -NAZARA_RENDERER_API extern PFNGLGENERATEMIPMAPPROC glGenerateMipmap; -NAZARA_RENDERER_API extern PFNGLGENBUFFERSPROC glGenBuffers; -NAZARA_RENDERER_API extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers; -NAZARA_RENDERER_API extern PFNGLGENQUERIESPROC glGenQueries; -NAZARA_RENDERER_API extern PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers; -NAZARA_RENDERER_API extern PFNGLGENSAMPLERSPROC glGenSamplers; -NAZARA_RENDERER_API extern PFNGLGENTEXTURESPROC glGenTextures; -NAZARA_RENDERER_API extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays; -NAZARA_RENDERER_API extern PFNGLGETACTIVEUNIFORMPROC glGetActiveUniform; -NAZARA_RENDERER_API extern PFNGLGETBOOLEANVPROC glGetBooleanv; -NAZARA_RENDERER_API extern PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv; -NAZARA_RENDERER_API extern PFNGLGETDEBUGMESSAGELOGPROC glGetDebugMessageLog; -NAZARA_RENDERER_API extern PFNGLGETERRORPROC glGetError; -NAZARA_RENDERER_API extern PFNGLGETFLOATVPROC glGetFloatv; -NAZARA_RENDERER_API extern PFNGLGETINTEGERVPROC glGetIntegerv; -NAZARA_RENDERER_API extern PFNGLGETPROGRAMBINARYPROC glGetProgramBinary; -NAZARA_RENDERER_API extern PFNGLGETPROGRAMIVPROC glGetProgramiv; -NAZARA_RENDERER_API extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog; -NAZARA_RENDERER_API extern PFNGLGETQUERYIVPROC glGetQueryiv; -NAZARA_RENDERER_API extern PFNGLGETQUERYOBJECTIVPROC glGetQueryObjectiv; -NAZARA_RENDERER_API extern PFNGLGETQUERYOBJECTUIVPROC glGetQueryObjectuiv; -NAZARA_RENDERER_API extern PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog; -NAZARA_RENDERER_API extern PFNGLGETSHADERIVPROC glGetShaderiv; -NAZARA_RENDERER_API extern PFNGLGETSHADERSOURCEPROC glGetShaderSource; -NAZARA_RENDERER_API extern PFNGLGETSTRINGPROC glGetString; -NAZARA_RENDERER_API extern PFNGLGETSTRINGIPROC glGetStringi; -NAZARA_RENDERER_API extern PFNGLGETTEXIMAGEPROC glGetTexImage; -NAZARA_RENDERER_API extern PFNGLGETTEXLEVELPARAMETERFVPROC glGetTexLevelParameterfv; -NAZARA_RENDERER_API extern PFNGLGETTEXLEVELPARAMETERIVPROC glGetTexLevelParameteriv; -NAZARA_RENDERER_API extern PFNGLGETTEXPARAMETERFVPROC glGetTexParameterfv; -NAZARA_RENDERER_API extern PFNGLGETTEXPARAMETERIVPROC glGetTexParameteriv; -NAZARA_RENDERER_API extern PFNGLGETUNIFORMFVPROC glGetUniformfv; -NAZARA_RENDERER_API extern PFNGLGETUNIFORMIVPROC glGetUniformiv; -NAZARA_RENDERER_API extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation; -NAZARA_RENDERER_API extern PFNGLINVALIDATEBUFFERDATAPROC glInvalidateBufferData; -NAZARA_RENDERER_API extern PFNGLISENABLEDPROC glIsEnabled; -NAZARA_RENDERER_API extern PFNGLLINEWIDTHPROC glLineWidth; -NAZARA_RENDERER_API extern PFNGLLINKPROGRAMPROC glLinkProgram; -NAZARA_RENDERER_API extern PFNGLMAPBUFFERPROC glMapBuffer; -NAZARA_RENDERER_API extern PFNGLMAPBUFFERRANGEPROC glMapBufferRange; -NAZARA_RENDERER_API extern PFNGLPIXELSTOREIPROC glPixelStorei; -NAZARA_RENDERER_API extern PFNGLPOINTSIZEPROC glPointSize; -NAZARA_RENDERER_API extern PFNGLPOLYGONMODEPROC glPolygonMode; -NAZARA_RENDERER_API extern PFNGLPROGRAMBINARYPROC glProgramBinary; -NAZARA_RENDERER_API extern PFNGLPROGRAMPARAMETERIPROC glProgramParameteri; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1DPROC glProgramUniform1d; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1FPROC glProgramUniform1f; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1IPROC glProgramUniform1i; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1DVPROC glProgramUniform1dv; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1FVPROC glProgramUniform1fv; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1IVPROC glProgramUniform1iv; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM2DVPROC glProgramUniform2dv; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM2FVPROC glProgramUniform2fv; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM2IVPROC glProgramUniform2iv; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM3DVPROC glProgramUniform3dv; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM3FVPROC glProgramUniform3fv; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM3IVPROC glProgramUniform3iv; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM4DVPROC glProgramUniform4dv; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM4FVPROC glProgramUniform4fv; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM4IVPROC glProgramUniform4iv; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORMMATRIX4DVPROC glProgramUniformMatrix4dv; -NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORMMATRIX4FVPROC glProgramUniformMatrix4fv; -NAZARA_RENDERER_API extern PFNGLREADPIXELSPROC glReadPixels; -NAZARA_RENDERER_API extern PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage; -NAZARA_RENDERER_API extern PFNGLSAMPLERPARAMETERFPROC glSamplerParameterf; -NAZARA_RENDERER_API extern PFNGLSAMPLERPARAMETERIPROC glSamplerParameteri; -NAZARA_RENDERER_API extern PFNGLSCISSORPROC glScissor; -NAZARA_RENDERER_API extern PFNGLSHADERSOURCEPROC glShaderSource; -NAZARA_RENDERER_API extern PFNGLSTENCILFUNCPROC glStencilFunc; -NAZARA_RENDERER_API extern PFNGLSTENCILFUNCSEPARATEPROC glStencilFuncSeparate; -NAZARA_RENDERER_API extern PFNGLSTENCILOPPROC glStencilOp; -NAZARA_RENDERER_API extern PFNGLSTENCILOPSEPARATEPROC glStencilOpSeparate; -NAZARA_RENDERER_API extern PFNGLTEXIMAGE1DPROC glTexImage1D; -NAZARA_RENDERER_API extern PFNGLTEXIMAGE2DPROC glTexImage2D; -NAZARA_RENDERER_API extern PFNGLTEXIMAGE3DPROC glTexImage3D; -NAZARA_RENDERER_API extern PFNGLTEXPARAMETERFPROC glTexParameterf; -NAZARA_RENDERER_API extern PFNGLTEXPARAMETERIPROC glTexParameteri; -NAZARA_RENDERER_API extern PFNGLTEXSTORAGE1DPROC glTexStorage1D; -NAZARA_RENDERER_API extern PFNGLTEXSTORAGE2DPROC glTexStorage2D; -NAZARA_RENDERER_API extern PFNGLTEXSTORAGE3DPROC glTexStorage3D; -NAZARA_RENDERER_API extern PFNGLTEXSUBIMAGE1DPROC glTexSubImage1D; -NAZARA_RENDERER_API extern PFNGLTEXSUBIMAGE2DPROC glTexSubImage2D; -NAZARA_RENDERER_API extern PFNGLTEXSUBIMAGE3DPROC glTexSubImage3D; -NAZARA_RENDERER_API extern PFNGLUNIFORM1DPROC glUniform1d; -NAZARA_RENDERER_API extern PFNGLUNIFORM1FPROC glUniform1f; -NAZARA_RENDERER_API extern PFNGLUNIFORM1IPROC glUniform1i; -NAZARA_RENDERER_API extern PFNGLUNIFORM1DVPROC glUniform1dv; -NAZARA_RENDERER_API extern PFNGLUNIFORM1FVPROC glUniform1fv; -NAZARA_RENDERER_API extern PFNGLUNIFORM1IVPROC glUniform1iv; -NAZARA_RENDERER_API extern PFNGLUNIFORM2DVPROC glUniform2dv; -NAZARA_RENDERER_API extern PFNGLUNIFORM2FVPROC glUniform2fv; -NAZARA_RENDERER_API extern PFNGLUNIFORM2IVPROC glUniform2iv; -NAZARA_RENDERER_API extern PFNGLUNIFORM3DVPROC glUniform3dv; -NAZARA_RENDERER_API extern PFNGLUNIFORM3FVPROC glUniform3fv; -NAZARA_RENDERER_API extern PFNGLUNIFORM3IVPROC glUniform3iv; -NAZARA_RENDERER_API extern PFNGLUNIFORM4DVPROC glUniform4dv; -NAZARA_RENDERER_API extern PFNGLUNIFORM4FVPROC glUniform4fv; -NAZARA_RENDERER_API extern PFNGLUNIFORM4IVPROC glUniform4iv; -NAZARA_RENDERER_API extern PFNGLUNIFORMMATRIX4DVPROC glUniformMatrix4dv; -NAZARA_RENDERER_API extern PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv; -NAZARA_RENDERER_API extern PFNGLUNMAPBUFFERPROC glUnmapBuffer; -NAZARA_RENDERER_API extern PFNGLUSEPROGRAMPROC glUseProgram; -NAZARA_RENDERER_API extern PFNGLVALIDATEPROGRAMPROC glValidateProgram; -NAZARA_RENDERER_API extern PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f; -NAZARA_RENDERER_API extern PFNGLVERTEXATTRIBDIVISORPROC glVertexAttribDivisor; -NAZARA_RENDERER_API extern PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer; -NAZARA_RENDERER_API extern PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer; -NAZARA_RENDERER_API extern PFNGLVERTEXATTRIBLPOINTERPROC glVertexAttribLPointer; -NAZARA_RENDERER_API extern PFNGLVIEWPORTPROC glViewport; -#if defined(NAZARA_PLATFORM_WINDOWS) -NAZARA_RENDERER_API extern PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormat; -NAZARA_RENDERER_API extern PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs; -NAZARA_RENDERER_API extern PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB; -NAZARA_RENDERER_API extern PFNWGLGETEXTENSIONSSTRINGEXTPROC wglGetExtensionsStringEXT; -NAZARA_RENDERER_API extern PFNWGLSWAPINTERVALEXTPROC wglSwapInterval; + NAZARA_RENDERER_API extern PFNGLACTIVETEXTUREPROC glActiveTexture; + NAZARA_RENDERER_API extern PFNGLATTACHSHADERPROC glAttachShader; + NAZARA_RENDERER_API extern PFNGLBEGINCONDITIONALRENDERPROC glBeginConditionalRender; + NAZARA_RENDERER_API extern PFNGLBEGINQUERYPROC glBeginQuery; + NAZARA_RENDERER_API extern PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation; + NAZARA_RENDERER_API extern PFNGLBINDBUFFERPROC glBindBuffer; + NAZARA_RENDERER_API extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer; + NAZARA_RENDERER_API extern PFNGLBINDFRAGDATALOCATIONPROC glBindFragDataLocation; + NAZARA_RENDERER_API extern PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer; + NAZARA_RENDERER_API extern PFNGLBINDSAMPLERPROC glBindSampler; + NAZARA_RENDERER_API extern PFNGLBINDTEXTUREPROC glBindTexture; + NAZARA_RENDERER_API extern PFNGLBINDVERTEXARRAYPROC glBindVertexArray; + NAZARA_RENDERER_API extern PFNGLBLENDFUNCPROC glBlendFunc; + NAZARA_RENDERER_API extern PFNGLBLENDFUNCSEPARATEPROC glBlendFuncSeparate; + NAZARA_RENDERER_API extern PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer; + NAZARA_RENDERER_API extern PFNGLBUFFERDATAPROC glBufferData; + NAZARA_RENDERER_API extern PFNGLBUFFERSUBDATAPROC glBufferSubData; + NAZARA_RENDERER_API extern PFNGLCLEARPROC glClear; + NAZARA_RENDERER_API extern PFNGLCLEARCOLORPROC glClearColor; + NAZARA_RENDERER_API extern PFNGLCLEARDEPTHPROC glClearDepth; + NAZARA_RENDERER_API extern PFNGLCLEARSTENCILPROC glClearStencil; + NAZARA_RENDERER_API extern PFNGLCREATEPROGRAMPROC glCreateProgram; + NAZARA_RENDERER_API extern PFNGLCREATESHADERPROC glCreateShader; + NAZARA_RENDERER_API extern PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus; + NAZARA_RENDERER_API extern PFNGLCOLORMASKPROC glColorMask; + NAZARA_RENDERER_API extern PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glCompressedTexSubImage1D; + NAZARA_RENDERER_API extern PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glCompressedTexSubImage2D; + NAZARA_RENDERER_API extern PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glCompressedTexSubImage3D; + NAZARA_RENDERER_API extern PFNGLCULLFACEPROC glCullFace; + NAZARA_RENDERER_API extern PFNGLCOMPILESHADERPROC glCompileShader; + NAZARA_RENDERER_API extern PFNGLCOPYTEXSUBIMAGE2DPROC glCopyTexSubImage2D; + NAZARA_RENDERER_API extern PFNGLDEBUGMESSAGECALLBACKPROC glDebugMessageCallback; + NAZARA_RENDERER_API extern PFNGLDEBUGMESSAGECONTROLPROC glDebugMessageControl; + NAZARA_RENDERER_API extern PFNGLDEBUGMESSAGEINSERTPROC glDebugMessageInsert; + NAZARA_RENDERER_API extern PFNGLDELETEBUFFERSPROC glDeleteBuffers; + NAZARA_RENDERER_API extern PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers; + NAZARA_RENDERER_API extern PFNGLDELETEPROGRAMPROC glDeleteProgram; + NAZARA_RENDERER_API extern PFNGLDELETEQUERIESPROC glDeleteQueries; + NAZARA_RENDERER_API extern PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers; + NAZARA_RENDERER_API extern PFNGLDELETESAMPLERSPROC glDeleteSamplers; + NAZARA_RENDERER_API extern PFNGLDELETESHADERPROC glDeleteShader; + NAZARA_RENDERER_API extern PFNGLDELETETEXTURESPROC glDeleteTextures; + NAZARA_RENDERER_API extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays; + NAZARA_RENDERER_API extern PFNGLDEPTHFUNCPROC glDepthFunc; + NAZARA_RENDERER_API extern PFNGLDEPTHMASKPROC glDepthMask; + NAZARA_RENDERER_API extern PFNGLDISABLEPROC glDisable; + NAZARA_RENDERER_API extern PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray; + NAZARA_RENDERER_API extern PFNGLDRAWARRAYSPROC glDrawArrays; + NAZARA_RENDERER_API extern PFNGLDRAWARRAYSINSTANCEDPROC glDrawArraysInstanced; + NAZARA_RENDERER_API extern PFNGLDRAWBUFFERPROC glDrawBuffer; + NAZARA_RENDERER_API extern PFNGLDRAWBUFFERSPROC glDrawBuffers; + NAZARA_RENDERER_API extern PFNGLDRAWELEMENTSPROC glDrawElements; + NAZARA_RENDERER_API extern PFNGLDRAWELEMENTSINSTANCEDPROC glDrawElementsInstanced; + NAZARA_RENDERER_API extern PFNGLDRAWTEXTURENVPROC glDrawTexture; + NAZARA_RENDERER_API extern PFNGLENABLEPROC glEnable; + NAZARA_RENDERER_API extern PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray; + NAZARA_RENDERER_API extern PFNGLENDCONDITIONALRENDERPROC glEndConditionalRender; + NAZARA_RENDERER_API extern PFNGLENDQUERYPROC glEndQuery; + NAZARA_RENDERER_API extern PFNGLFLUSHPROC glFlush; + NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer; + NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERTEXTUREPROC glFramebufferTexture; + NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D; + NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D; + NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D; + NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer; + NAZARA_RENDERER_API extern PFNGLGENERATEMIPMAPPROC glGenerateMipmap; + NAZARA_RENDERER_API extern PFNGLGENBUFFERSPROC glGenBuffers; + NAZARA_RENDERER_API extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers; + NAZARA_RENDERER_API extern PFNGLGENQUERIESPROC glGenQueries; + NAZARA_RENDERER_API extern PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers; + NAZARA_RENDERER_API extern PFNGLGENSAMPLERSPROC glGenSamplers; + NAZARA_RENDERER_API extern PFNGLGENTEXTURESPROC glGenTextures; + NAZARA_RENDERER_API extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays; + NAZARA_RENDERER_API extern PFNGLGETACTIVEUNIFORMPROC glGetActiveUniform; + NAZARA_RENDERER_API extern PFNGLGETBOOLEANVPROC glGetBooleanv; + NAZARA_RENDERER_API extern PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv; + NAZARA_RENDERER_API extern PFNGLGETDEBUGMESSAGELOGPROC glGetDebugMessageLog; + NAZARA_RENDERER_API extern PFNGLGETERRORPROC glGetError; + NAZARA_RENDERER_API extern PFNGLGETFLOATVPROC glGetFloatv; + NAZARA_RENDERER_API extern PFNGLGETINTEGERVPROC glGetIntegerv; + NAZARA_RENDERER_API extern PFNGLGETPROGRAMBINARYPROC glGetProgramBinary; + NAZARA_RENDERER_API extern PFNGLGETPROGRAMIVPROC glGetProgramiv; + NAZARA_RENDERER_API extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog; + NAZARA_RENDERER_API extern PFNGLGETQUERYIVPROC glGetQueryiv; + NAZARA_RENDERER_API extern PFNGLGETQUERYOBJECTIVPROC glGetQueryObjectiv; + NAZARA_RENDERER_API extern PFNGLGETQUERYOBJECTUIVPROC glGetQueryObjectuiv; + NAZARA_RENDERER_API extern PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog; + NAZARA_RENDERER_API extern PFNGLGETSHADERIVPROC glGetShaderiv; + NAZARA_RENDERER_API extern PFNGLGETSHADERSOURCEPROC glGetShaderSource; + NAZARA_RENDERER_API extern PFNGLGETSTRINGPROC glGetString; + NAZARA_RENDERER_API extern PFNGLGETSTRINGIPROC glGetStringi; + NAZARA_RENDERER_API extern PFNGLGETTEXIMAGEPROC glGetTexImage; + NAZARA_RENDERER_API extern PFNGLGETTEXLEVELPARAMETERFVPROC glGetTexLevelParameterfv; + NAZARA_RENDERER_API extern PFNGLGETTEXLEVELPARAMETERIVPROC glGetTexLevelParameteriv; + NAZARA_RENDERER_API extern PFNGLGETTEXPARAMETERFVPROC glGetTexParameterfv; + NAZARA_RENDERER_API extern PFNGLGETTEXPARAMETERIVPROC glGetTexParameteriv; + NAZARA_RENDERER_API extern PFNGLGETUNIFORMFVPROC glGetUniformfv; + NAZARA_RENDERER_API extern PFNGLGETUNIFORMIVPROC glGetUniformiv; + NAZARA_RENDERER_API extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation; + NAZARA_RENDERER_API extern PFNGLINVALIDATEBUFFERDATAPROC glInvalidateBufferData; + NAZARA_RENDERER_API extern PFNGLISENABLEDPROC glIsEnabled; + NAZARA_RENDERER_API extern PFNGLLINEWIDTHPROC glLineWidth; + NAZARA_RENDERER_API extern PFNGLLINKPROGRAMPROC glLinkProgram; + NAZARA_RENDERER_API extern PFNGLMAPBUFFERPROC glMapBuffer; + NAZARA_RENDERER_API extern PFNGLMAPBUFFERRANGEPROC glMapBufferRange; + NAZARA_RENDERER_API extern PFNGLPIXELSTOREIPROC glPixelStorei; + NAZARA_RENDERER_API extern PFNGLPOINTSIZEPROC glPointSize; + NAZARA_RENDERER_API extern PFNGLPOLYGONMODEPROC glPolygonMode; + NAZARA_RENDERER_API extern PFNGLPROGRAMBINARYPROC glProgramBinary; + NAZARA_RENDERER_API extern PFNGLPROGRAMPARAMETERIPROC glProgramParameteri; + NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1DPROC glProgramUniform1d; + NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1FPROC glProgramUniform1f; + NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1IPROC glProgramUniform1i; + NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1DVPROC glProgramUniform1dv; + NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1FVPROC glProgramUniform1fv; + NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1IVPROC glProgramUniform1iv; + NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM2DVPROC glProgramUniform2dv; + NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM2FVPROC glProgramUniform2fv; + NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM2IVPROC glProgramUniform2iv; + NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM3DVPROC glProgramUniform3dv; + NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM3FVPROC glProgramUniform3fv; + NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM3IVPROC glProgramUniform3iv; + NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM4DVPROC glProgramUniform4dv; + NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM4FVPROC glProgramUniform4fv; + NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM4IVPROC glProgramUniform4iv; + NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORMMATRIX4DVPROC glProgramUniformMatrix4dv; + NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORMMATRIX4FVPROC glProgramUniformMatrix4fv; + NAZARA_RENDERER_API extern PFNGLREADPIXELSPROC glReadPixels; + NAZARA_RENDERER_API extern PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage; + NAZARA_RENDERER_API extern PFNGLSAMPLERPARAMETERFPROC glSamplerParameterf; + NAZARA_RENDERER_API extern PFNGLSAMPLERPARAMETERIPROC glSamplerParameteri; + NAZARA_RENDERER_API extern PFNGLSCISSORPROC glScissor; + NAZARA_RENDERER_API extern PFNGLSHADERSOURCEPROC glShaderSource; + NAZARA_RENDERER_API extern PFNGLSTENCILFUNCPROC glStencilFunc; + NAZARA_RENDERER_API extern PFNGLSTENCILFUNCSEPARATEPROC glStencilFuncSeparate; + NAZARA_RENDERER_API extern PFNGLSTENCILOPPROC glStencilOp; + NAZARA_RENDERER_API extern PFNGLSTENCILOPSEPARATEPROC glStencilOpSeparate; + NAZARA_RENDERER_API extern PFNGLTEXIMAGE1DPROC glTexImage1D; + NAZARA_RENDERER_API extern PFNGLTEXIMAGE2DPROC glTexImage2D; + NAZARA_RENDERER_API extern PFNGLTEXIMAGE3DPROC glTexImage3D; + NAZARA_RENDERER_API extern PFNGLTEXPARAMETERFPROC glTexParameterf; + NAZARA_RENDERER_API extern PFNGLTEXPARAMETERIPROC glTexParameteri; + NAZARA_RENDERER_API extern PFNGLTEXSTORAGE1DPROC glTexStorage1D; + NAZARA_RENDERER_API extern PFNGLTEXSTORAGE2DPROC glTexStorage2D; + NAZARA_RENDERER_API extern PFNGLTEXSTORAGE3DPROC glTexStorage3D; + NAZARA_RENDERER_API extern PFNGLTEXSUBIMAGE1DPROC glTexSubImage1D; + NAZARA_RENDERER_API extern PFNGLTEXSUBIMAGE2DPROC glTexSubImage2D; + NAZARA_RENDERER_API extern PFNGLTEXSUBIMAGE3DPROC glTexSubImage3D; + NAZARA_RENDERER_API extern PFNGLUNIFORM1DPROC glUniform1d; + NAZARA_RENDERER_API extern PFNGLUNIFORM1FPROC glUniform1f; + NAZARA_RENDERER_API extern PFNGLUNIFORM1IPROC glUniform1i; + NAZARA_RENDERER_API extern PFNGLUNIFORM1DVPROC glUniform1dv; + NAZARA_RENDERER_API extern PFNGLUNIFORM1FVPROC glUniform1fv; + NAZARA_RENDERER_API extern PFNGLUNIFORM1IVPROC glUniform1iv; + NAZARA_RENDERER_API extern PFNGLUNIFORM2DVPROC glUniform2dv; + NAZARA_RENDERER_API extern PFNGLUNIFORM2FVPROC glUniform2fv; + NAZARA_RENDERER_API extern PFNGLUNIFORM2IVPROC glUniform2iv; + NAZARA_RENDERER_API extern PFNGLUNIFORM3DVPROC glUniform3dv; + NAZARA_RENDERER_API extern PFNGLUNIFORM3FVPROC glUniform3fv; + NAZARA_RENDERER_API extern PFNGLUNIFORM3IVPROC glUniform3iv; + NAZARA_RENDERER_API extern PFNGLUNIFORM4DVPROC glUniform4dv; + NAZARA_RENDERER_API extern PFNGLUNIFORM4FVPROC glUniform4fv; + NAZARA_RENDERER_API extern PFNGLUNIFORM4IVPROC glUniform4iv; + NAZARA_RENDERER_API extern PFNGLUNIFORMMATRIX4DVPROC glUniformMatrix4dv; + NAZARA_RENDERER_API extern PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv; + NAZARA_RENDERER_API extern PFNGLUNMAPBUFFERPROC glUnmapBuffer; + NAZARA_RENDERER_API extern PFNGLUSEPROGRAMPROC glUseProgram; + NAZARA_RENDERER_API extern PFNGLVALIDATEPROGRAMPROC glValidateProgram; + NAZARA_RENDERER_API extern PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f; + NAZARA_RENDERER_API extern PFNGLVERTEXATTRIBDIVISORPROC glVertexAttribDivisor; + NAZARA_RENDERER_API extern PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer; + NAZARA_RENDERER_API extern PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer; + NAZARA_RENDERER_API extern PFNGLVERTEXATTRIBLPOINTERPROC glVertexAttribLPointer; + NAZARA_RENDERER_API extern PFNGLVIEWPORTPROC glViewport; +#if defined(NAZARA_PLATFORM_SDL2) +#elif defined(NAZARA_PLATFORM_WINDOWS) + NAZARA_RENDERER_API extern PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormat; + NAZARA_RENDERER_API extern PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs; + NAZARA_RENDERER_API extern PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB; + NAZARA_RENDERER_API extern PFNWGLGETEXTENSIONSSTRINGEXTPROC wglGetExtensionsStringEXT; + NAZARA_RENDERER_API extern PFNWGLSWAPINTERVALEXTPROC wglSwapInterval; #elif defined(NAZARA_PLATFORM_GLX) -NAZARA_RENDERER_API extern GLX::PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs; -NAZARA_RENDERER_API extern GLX::PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT; -NAZARA_RENDERER_API extern GLX::PFNGLXSWAPINTERVALMESAPROC NzglXSwapIntervalMESA; -NAZARA_RENDERER_API extern GLX::PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI; + NAZARA_RENDERER_API extern GLX::PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs; + NAZARA_RENDERER_API extern GLX::PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT; + NAZARA_RENDERER_API extern GLX::PFNGLXSWAPINTERVALMESAPROC NzglXSwapIntervalMESA; + NAZARA_RENDERER_API extern GLX::PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI; #endif } +#undef None + #endif // NAZARA_RENDERER_OPENGL #endif // NAZARA_OPENGL_HPP diff --git a/src/Nazara/Platform/Cursor.cpp b/src/Nazara/Platform/Cursor.cpp index 7d68a460b..a352d7f8c 100644 --- a/src/Nazara/Platform/Cursor.cpp +++ b/src/Nazara/Platform/Cursor.cpp @@ -4,7 +4,9 @@ #include -#if defined(NAZARA_PLATFORM_WINDOWS) +#if defined(NAZARA_PLATFORM_SDL2) + #include +#elif defined(NAZARA_PLATFORM_WINDOWS) #include #elif defined(NAZARA_PLATFORM_X11) #include diff --git a/src/Nazara/Platform/Icon.cpp b/src/Nazara/Platform/Icon.cpp index 010e9dfc2..86ce7559b 100644 --- a/src/Nazara/Platform/Icon.cpp +++ b/src/Nazara/Platform/Icon.cpp @@ -4,7 +4,9 @@ #include -#if defined(NAZARA_PLATFORM_WINDOWS) +#if defined(NAZARA_PLATFORM_SDL2) + #include +#elif defined(NAZARA_PLATFORM_WINDOWS) #include #elif defined(NAZARA_PLATFORM_X11) #include diff --git a/src/Nazara/Platform/Keyboard.cpp b/src/Nazara/Platform/Keyboard.cpp index be1341eb6..9fbf8fcdf 100644 --- a/src/Nazara/Platform/Keyboard.cpp +++ b/src/Nazara/Platform/Keyboard.cpp @@ -4,7 +4,9 @@ #include -#if defined(NAZARA_PLATFORM_WINDOWS) +#if defined(NAZARA_PLATFORM_SDL2) + #include +#elif defined(NAZARA_PLATFORM_WINDOWS) #include #elif defined(NAZARA_PLATFORM_X11) #include diff --git a/src/Nazara/Platform/Mouse.cpp b/src/Nazara/Platform/Mouse.cpp index 6d589697e..e9b55031a 100644 --- a/src/Nazara/Platform/Mouse.cpp +++ b/src/Nazara/Platform/Mouse.cpp @@ -5,7 +5,9 @@ #include #include -#if defined(NAZARA_PLATFORM_WINDOWS) +#if defined(NAZARA_PLATFORM_SDL2) + #include +#elif defined(NAZARA_PLATFORM_WINDOWS) #include #elif defined(NAZARA_PLATFORM_X11) #include diff --git a/src/Nazara/Platform/SDL2/CursorImpl.cpp b/src/Nazara/Platform/SDL2/CursorImpl.cpp new file mode 100644 index 000000000..c9497a2e8 --- /dev/null +++ b/src/Nazara/Platform/SDL2/CursorImpl.cpp @@ -0,0 +1,108 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Platform module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include + +namespace Nz +{ + bool CursorImpl::Create(const Image& cursor, int hotSpotX, int hotSpotY) + { + m_iconImage = cursor; + if (!m_iconImage.Convert(PixelFormatType_BGRA8)) + { + NazaraError("Failed to convert icon to BGRA8"); + return false; + } + + m_icon = SDL_CreateRGBSurfaceWithFormatFrom( + m_iconImage.GetPixels(), + m_iconImage.GetWidth(), + m_iconImage.GetHeight(), + 32, + 32 * m_iconImage.GetWidth(), + SDL_PIXELFORMAT_BGRA8888 + ); + + if (!m_icon) + { + NazaraError(SDL_GetError()); + + return false; + } + + m_cursor = SDL_CreateColorCursor(m_icon, hotSpotX, hotSpotY); + + if (!m_cursor) + { + NazaraError(SDL_GetError()); + + return false; + } + + return true; + } + + bool CursorImpl::Create(SystemCursor cursor) + { + if (cursor != SystemCursor_None) + m_cursor = SDL_CreateSystemCursor(s_systemCursorIds[cursor]); + else + m_cursor = nullptr; + + m_icon = nullptr; + + return true; + } + + void CursorImpl::Destroy() + { + if (m_icon) + SDL_FreeSurface(m_icon); + + if (m_cursor) + SDL_FreeCursor(m_cursor); + } + + SDL_Cursor* CursorImpl::GetCursor() + { + return m_cursor; + } + + bool CursorImpl::Initialize() + { + return true; + } + + void CursorImpl::Uninitialize() + { + } + + std::array CursorImpl::s_systemCursorIds = + { + SDL_SYSTEM_CURSOR_CROSSHAIR, // SystemCursor_Crosshair + SDL_SYSTEM_CURSOR_ARROW, // SystemCursor_Default + SDL_SYSTEM_CURSOR_HAND, // SystemCursor_Hand + SDL_SYSTEM_CURSOR_ARROW, // SystemCursor_Help + SDL_SYSTEM_CURSOR_SIZEALL, // SystemCursor_Move + SDL_NUM_SYSTEM_CURSORS, // SystemCursor_None + SDL_SYSTEM_CURSOR_HAND, // SystemCursor_Pointer + SDL_SYSTEM_CURSOR_WAITARROW, // SystemCursor_Progress + SDL_SYSTEM_CURSOR_SIZEWE, // SystemCursor_ResizeE + SDL_SYSTEM_CURSOR_SIZENS, // SystemCursor_ResizeN + SDL_SYSTEM_CURSOR_SIZENESW, // SystemCursor_ResizeNE + SDL_SYSTEM_CURSOR_SIZENWSE, // SystemCursor_ResizeNW + SDL_SYSTEM_CURSOR_SIZENS, // SystemCursor_ResizeS + SDL_SYSTEM_CURSOR_SIZENWSE, // SystemCursor_ResizeSE + SDL_SYSTEM_CURSOR_SIZENESW, // SystemCursor_ResizeSW + SDL_SYSTEM_CURSOR_SIZEWE, // SystemCursor_ResizeW + SDL_SYSTEM_CURSOR_IBEAM, // SystemCursor_Text + SDL_SYSTEM_CURSOR_WAIT // SystemCursor_Wait + }; + + static_assert(SystemCursor_Max + 1 == 18, "System cursor array is incomplete"); +} diff --git a/src/Nazara/Platform/SDL2/CursorImpl.hpp b/src/Nazara/Platform/SDL2/CursorImpl.hpp new file mode 100644 index 000000000..ae90ef7f4 --- /dev/null +++ b/src/Nazara/Platform/SDL2/CursorImpl.hpp @@ -0,0 +1,45 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Platform module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_CURSORIMPL_HPP +#define NAZARA_CURSORIMPL_HPP + +#include +#include +#include +#include + +#include + +namespace Nz +{ + class Image; + + class CursorImpl + { + friend class Cursor; + + public: + bool Create(const Image& image, int hotSpotX, int hotSpotY); + bool Create(SystemCursor cursor); + + void Destroy(); + + SDL_Cursor* GetCursor(); + + private: + static bool Initialize(); + static void Uninitialize(); + + SDL_Cursor* m_cursor = nullptr; + SDL_Surface* m_icon = nullptr; + Image m_iconImage; + + static std::array s_systemCursorIds; + }; +} + +#endif // NAZARA_CURSORIMPL_HPP diff --git a/src/Nazara/Platform/SDL2/IconImpl.cpp b/src/Nazara/Platform/SDL2/IconImpl.cpp new file mode 100644 index 000000000..b802b1176 --- /dev/null +++ b/src/Nazara/Platform/SDL2/IconImpl.cpp @@ -0,0 +1,49 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Platform module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include + +namespace Nz +{ + bool IconImpl::Create(const Image& icon) + { + m_iconImage = icon; + if (!m_iconImage.Convert(PixelFormatType_BGRA8)) + { + NazaraError("Failed to convert icon to BGRA8"); + return false; + } + + m_icon = SDL_CreateRGBSurfaceWithFormatFrom( + m_iconImage.GetPixels(), + m_iconImage.GetWidth(), + m_iconImage.GetHeight(), + 32, + 32 * m_iconImage.GetWidth(), + SDL_PIXELFORMAT_BGRA8888 + ); + + if (!m_icon) + { + NazaraError(SDL_GetError()); + return false; + } + + return true; + } + + void IconImpl::Destroy() + { + SDL_FreeSurface(m_icon); + m_iconImage.Destroy(); + } + + SDL_Surface* IconImpl::GetIcon() + { + return m_icon; + } +} diff --git a/src/Nazara/Platform/SDL2/IconImpl.hpp b/src/Nazara/Platform/SDL2/IconImpl.hpp new file mode 100644 index 000000000..891e6a547 --- /dev/null +++ b/src/Nazara/Platform/SDL2/IconImpl.hpp @@ -0,0 +1,33 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Platform module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_ICONIMPL_HPP +#define NAZARA_ICONIMPL_HPP + +#include +#include +#include + +namespace Nz +{ + class Image; + + class IconImpl + { + public: + bool Create(const Image& image); + void Destroy(); + + SDL_Surface* GetIcon(); + + private: + + SDL_Surface* m_icon = nullptr; + Image m_iconImage; + }; +} + +#endif // NAZARA_ICONIMPL_HPP diff --git a/src/Nazara/Platform/SDL2/InputImpl.cpp b/src/Nazara/Platform/SDL2/InputImpl.cpp new file mode 100644 index 000000000..671f79d22 --- /dev/null +++ b/src/Nazara/Platform/SDL2/InputImpl.cpp @@ -0,0 +1,234 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Platform module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include + +#include +#include + +namespace Nz +{ + namespace + { + SDL_Scancode nzKeyboardToSDLScanCode[Keyboard::Count] = { + // Lettres + SDL_SCANCODE_A, // Key::A + SDL_SCANCODE_B, // Key::B + SDL_SCANCODE_C, // Key::C + SDL_SCANCODE_D, // Key::D + SDL_SCANCODE_E, // Key::E + SDL_SCANCODE_F, // Key::F + SDL_SCANCODE_G, // Key::G + SDL_SCANCODE_H, // Key::H + SDL_SCANCODE_I, // Key::I + SDL_SCANCODE_J, // Key::J + SDL_SCANCODE_K, // Key::K + SDL_SCANCODE_L, // Key::L + SDL_SCANCODE_M, // Key::M + SDL_SCANCODE_N, // Key::N + SDL_SCANCODE_O, // Key::O + SDL_SCANCODE_P, // Key::P + SDL_SCANCODE_Q, // Key::Q + SDL_SCANCODE_R, // Key::R + SDL_SCANCODE_S, // Key::S + SDL_SCANCODE_T, // Key::T + SDL_SCANCODE_U, // Key::U + SDL_SCANCODE_V, // Key::V + SDL_SCANCODE_W, // Key::W + SDL_SCANCODE_X, // Key::X + SDL_SCANCODE_Y, // Key::Y + SDL_SCANCODE_Z, // Key::Z + + // Touches de fonction + SDL_SCANCODE_F1, // Key::F1 + SDL_SCANCODE_F2, // Key::F2 + SDL_SCANCODE_F3, // Key::F3 + SDL_SCANCODE_F4, // Key::F4 + SDL_SCANCODE_F5, // Key::F5 + SDL_SCANCODE_F6, // Key::F6 + SDL_SCANCODE_F7, // Key::F7 + SDL_SCANCODE_F8, // Key::F8 + SDL_SCANCODE_F9, // Key::F9 + SDL_SCANCODE_F10, // Key::F10 + SDL_SCANCODE_F11, // Key::F11 + SDL_SCANCODE_F12, // Key::F12 + SDL_SCANCODE_F13, // Key::F13 + SDL_SCANCODE_F14, // Key::F14 + SDL_SCANCODE_F15, // Key::F15 + + // Flèches directionnelles + SDL_SCANCODE_DOWN, // Key::Down + SDL_SCANCODE_LEFT, // Key::Left + SDL_SCANCODE_RIGHT, // Key::Right + SDL_SCANCODE_UP, // Key::Up + + // Pavé numérique + SDL_SCANCODE_KP_PLUS, // Key::Add + SDL_SCANCODE_KP_PERIOD, // Key::Decimal + SDL_SCANCODE_KP_DIVIDE, // Key::Divide + SDL_SCANCODE_KP_MULTIPLY, // Key::Multiply + SDL_SCANCODE_KP_ENTER, // Key::NumpadReturn + SDL_SCANCODE_KP_0, // Key::Numpad0 + SDL_SCANCODE_KP_1, // Key::Numpad1 + SDL_SCANCODE_KP_2, // Key::Numpad2 + SDL_SCANCODE_KP_3, // Key::Numpad3 + SDL_SCANCODE_KP_4, // Key::Numpad4 + SDL_SCANCODE_KP_5, // Key::Numpad5 + SDL_SCANCODE_KP_6, // Key::Numpad6 + SDL_SCANCODE_KP_7, // Key::Numpad7 + SDL_SCANCODE_KP_8, // Key::Numpad8 + SDL_SCANCODE_KP_9, // Key::Numpad9 + SDL_SCANCODE_KP_MINUS, // Key::Subtract + + + // Diverss + SDL_SCANCODE_BACKSLASH, // Key::Backslash + SDL_SCANCODE_BACKSPACE, // Key::Backspace + SDL_SCANCODE_CLEAR, // Key::Clear + SDL_SCANCODE_COMMA, // Key::Comma, + SDL_SCANCODE_MINUS, // Key::Dash + SDL_SCANCODE_DELETE, // Key::Delete + SDL_SCANCODE_END, // Key::End + SDL_SCANCODE_EQUALS, // Key::Equal + SDL_SCANCODE_ESCAPE, // Key::Escape + SDL_SCANCODE_HOME, // Key::Home + SDL_SCANCODE_INSERT, // Key::Insert + SDL_SCANCODE_LALT, // Key::LAlt + SDL_SCANCODE_LEFTBRACKET, // Key::LBracket + SDL_SCANCODE_LCTRL, // Key::LControl + SDL_SCANCODE_LSHIFT, // Key::LShift + SDL_SCANCODE_LGUI, // Key::LSystem + SDL_SCANCODE_0, // Key::Num0 + SDL_SCANCODE_1, // Key::Num1 + SDL_SCANCODE_2, // Key::Num2 + SDL_SCANCODE_3, // Key::Num3 + SDL_SCANCODE_4, // Key::Num4 + SDL_SCANCODE_5, // Key::Num5 + SDL_SCANCODE_6, // Key::Num6 + SDL_SCANCODE_7, // Key::Num7 + SDL_SCANCODE_8, // Key::Num8 + SDL_SCANCODE_9, // Key::Num9 + SDL_SCANCODE_PAGEDOWN, // Key::PageDown + SDL_SCANCODE_PAGEUP, // Key::PageUp + SDL_SCANCODE_PAUSE, // Key::Pause + SDL_SCANCODE_PERIOD, // Key::Period + SDL_SCANCODE_SYSREQ, // Key::Print + SDL_SCANCODE_PRINTSCREEN, // Key::PrintScreen + SDL_SCANCODE_APOSTROPHE, // Key::Quote + SDL_SCANCODE_RALT, // Key::RAlt + SDL_SCANCODE_RIGHTBRACKET, // Key::RBracket + SDL_SCANCODE_RCTRL, // Key::RControl + SDL_SCANCODE_RETURN, // Key::Return + SDL_SCANCODE_RSHIFT, // Key::RShift + SDL_SCANCODE_RGUI, // Key::RSystem + SDL_SCANCODE_SEMICOLON, // Key::Semicolon + SDL_SCANCODE_SLASH, // Key::Slash + SDL_SCANCODE_SPACE, // Key::Space + SDL_SCANCODE_TAB, // Key::Tab + SDL_SCANCODE_GRAVE, // Key::Tilde + SDL_SCANCODE_APPLICATION, // Key::Menu + SDL_SCANCODE_NONUSBACKSLASH,// Key::ISOBackslash102 + + // Touches navigateur + SDL_SCANCODE_AC_BACK, // Key::Browser_Back + SDL_SCANCODE_AC_BOOKMARKS, // Key::Browser_Favorites + SDL_SCANCODE_AC_FORWARD, // Key::Browser_Forward + SDL_SCANCODE_AC_HOME, // Key::Browser_Home + SDL_SCANCODE_AC_REFRESH, // Key::Browser_Refresh + SDL_SCANCODE_AC_SEARCH, // Key::Browser_Search + SDL_SCANCODE_AC_STOP, // Key::Browser_Stop + + // Touches de contrôle + SDL_SCANCODE_AUDIONEXT, // Key::Media_Next, + SDL_SCANCODE_AUDIOPLAY, // Key::Media_PlayPause, + SDL_SCANCODE_AUDIOPREV, // Key::Media_Previous, + SDL_SCANCODE_AUDIOSTOP, // Key::Media_Stop, + + // Touches de contrôle du volume + SDL_SCANCODE_VOLUMEDOWN, // Key::Volume_Down + SDL_SCANCODE_MUTE, // Key::Volume_Mute + SDL_SCANCODE_VOLUMEUP, // Key::Volume_Up + + // Touches à verrouillage + SDL_SCANCODE_CAPSLOCK, // Key::CapsLock + SDL_SCANCODE_NUMLOCKCLEAR, // Key::NumLock + SDL_SCANCODE_SCROLLLOCK // Key::ScrollLock + }; + } + + String EventImpl::GetKeyName(Keyboard::Key key) + { + auto scancode = nzKeyboardToSDLScanCode[key]; + + auto name = String::Unicode(SDL_GetKeyName(SDL_GetKeyFromScancode(scancode))); + + if (name == "") + name = "\"" + String::Unicode(SDL_GetScancodeName(scancode)) + "\""; + + return name == "\"\"" ? String::Unicode("Unknown") : name; + } + + Vector2i EventImpl::GetMousePosition() + { + Vector2i pos; + SDL_GetGlobalMouseState(&pos.x, &pos.y); + + return pos; + } + + Vector2i EventImpl::GetMousePosition(const Window& relativeTo) + { + auto handle = relativeTo.GetHandle(); + if (handle) + { + auto windowPos = relativeTo.GetPosition(); + auto mousePos = GetMousePosition(); + + return mousePos - windowPos; + } + else + { + NazaraError("Invalid window handle"); + + // Attention que (-1, -1) est une position tout à fait valide et ne doit pas servir de test + return Vector2i(-1, -1); + } + } + + bool EventImpl::IsKeyPressed(Keyboard::Key key) + { + return SDL_GetKeyboardState(nullptr)[nzKeyboardToSDLScanCode[key]]; + } + + bool EventImpl::IsMouseButtonPressed(Mouse::Button button) + { + static int vButtons[Mouse::Max + 1] = { + SDL_BUTTON_LMASK, // Button::Left + SDL_BUTTON_MMASK, // Button::Middle + SDL_BUTTON_RMASK, // Button::Right + SDL_BUTTON_X1MASK, // Button::XButton1 + SDL_BUTTON_X2MASK // Button::XButton2 + }; + + return (SDL_GetGlobalMouseState(nullptr, nullptr) & vButtons[button]) != 0; + } + + void EventImpl::SetMousePosition(int x, int y) + { + if (SDL_WarpMouseGlobal(x, y) != 0) + NazaraWarning(SDL_GetError()); + } + + void EventImpl::SetMousePosition(int x, int y, const Window& relativeTo) + { + auto handle = static_cast(relativeTo.GetHandle()); + if (handle) + SDL_WarpMouseInWindow(handle, x, y); + else + NazaraError("Invalid window handle"); + } +} diff --git a/src/Nazara/Platform/SDL2/InputImpl.hpp b/src/Nazara/Platform/SDL2/InputImpl.hpp new file mode 100644 index 000000000..09f7802ec --- /dev/null +++ b/src/Nazara/Platform/SDL2/InputImpl.hpp @@ -0,0 +1,30 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Platform module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_INPUTIMPL_HPP +#define NAZARA_INPUTIMPL_HPP + +#include +#include +#include +#include + +namespace Nz +{ + class EventImpl + { + public: + static String GetKeyName(Keyboard::Key key); + static Vector2i GetMousePosition(); + static Vector2i GetMousePosition(const Window& relativeTo); + static bool IsKeyPressed(Keyboard::Key key); + static bool IsMouseButtonPressed(Mouse::Button button); + static void SetMousePosition(int x, int y); + static void SetMousePosition(int x, int y, const Window& relativeTo); + }; +} + +#endif // NAZARA_INPUTIMPL_HPP diff --git a/src/Nazara/Platform/SDL2/VideoModeImpl.cpp b/src/Nazara/Platform/SDL2/VideoModeImpl.cpp new file mode 100644 index 000000000..a9661c572 --- /dev/null +++ b/src/Nazara/Platform/SDL2/VideoModeImpl.cpp @@ -0,0 +1,51 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Platform module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + VideoMode VideoModeImpl::GetDesktopMode() + { + SDL_DisplayMode mode; + if (SDL_GetDesktopDisplayMode(0, &mode) != 0) // handle multi screen ? + { + NazaraError(SDL_GetError()); + + return VideoMode(800, 600, static_cast(32)); // useless ? + } + + return VideoMode(mode.w, mode.h, SDL_BITSPERPIXEL(mode.format)); + } + + void VideoModeImpl::GetFullscreenModes(std::vector& modes) + { + SDL_DisplayMode mode; + + int numModes = SDL_GetNumDisplayModes(0); + if (numModes < 0) + { + NazaraError(SDL_GetError()); + + return; + } + + for (int i = 0; i < numModes; i++) + { + if (SDL_GetDisplayMode(0, i, &mode) != 0) // handle multi screen ? + + NazaraError(SDL_GetError()); + + VideoMode vMode(mode.w, mode.h, SDL_BITSPERPIXEL(mode.format)); + + if (std::find(modes.begin(), modes.end(), vMode) == modes.end()) + modes.push_back(vMode); + } + } +} diff --git a/src/Nazara/Platform/SDL2/VideoModeImpl.hpp b/src/Nazara/Platform/SDL2/VideoModeImpl.hpp new file mode 100644 index 000000000..39579b9a2 --- /dev/null +++ b/src/Nazara/Platform/SDL2/VideoModeImpl.hpp @@ -0,0 +1,22 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Platform module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VIDEOMODEIMPL_HPP +#define NAZARA_VIDEOMODEIMPL_HPP + +#include + +namespace Nz +{ + class VideoModeImpl + { + public: + static VideoMode GetDesktopMode(); + static void GetFullscreenModes(std::vector& modes); + }; +} + +#endif // NNAZARA_VIDEOMODEIMPL_HPP diff --git a/src/Nazara/Platform/SDL2/WindowImpl.cpp b/src/Nazara/Platform/SDL2/WindowImpl.cpp new file mode 100644 index 000000000..f44ca8fe5 --- /dev/null +++ b/src/Nazara/Platform/SDL2/WindowImpl.cpp @@ -0,0 +1,695 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Platform module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +// Un grand merci à Laurent Gomila pour la SFML qui m'aura bien aidé à réaliser cette implémentation + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + namespace + { + WindowImpl* fullscreenWindow = nullptr; + + Mouse::Button SDLToNazaraButton(Uint8 sdlButton) + { + switch (sdlButton) + { + case SDL_BUTTON_LEFT: + return Mouse::Left; + case SDL_BUTTON_MIDDLE: + return Mouse::Middle; + case SDL_BUTTON_RIGHT: + return Mouse::Right; + case SDL_BUTTON_X1: + return Mouse::XButton1; + case SDL_BUTTON_X2: + return Mouse::XButton2; + default: + NazaraAssert(false, "Unkown mouse button"); + return Mouse::Left; + } + } + } + + WindowImpl::WindowImpl(Window* parent) : + m_cursor(nullptr), + m_handle(nullptr), + //m_callback(0), + m_style(0), + m_maxSize(-1), + m_minSize(-1), + m_parent(parent), + m_keyRepeat(true), + m_mouseInside(false), + m_smoothScrolling(false), + m_scrolling(0) + { + m_cursor = SDL_GetDefaultCursor(); + } + + bool WindowImpl::Create(const VideoMode& mode, const String& title, WindowStyleFlags style) + { + bool async = (style & WindowStyle_Threaded) != 0; + if (async) + { + NazaraError("SDL2 backend doesn't support asyn window for now"); + + return false; + } + + + bool fullscreen = (style & WindowStyle_Fullscreen) != 0; + + Uint32 winStyle = SDL_WINDOW_OPENGL; + + unsigned int x, y; + unsigned int width = mode.width; + unsigned int height = mode.height; + if (fullscreen) + winStyle |= SDL_WINDOW_FULLSCREEN; + + // Testé une seconde fois car sa valeur peut changer + if (fullscreen) + { + x = 0; + y = 0; + + fullscreenWindow = this; + } + else + { + if (!(style & WindowStyle_Titlebar)) + winStyle |= SDL_WINDOW_BORDERLESS; + + x = SDL_WINDOWPOS_CENTERED; + y = SDL_WINDOWPOS_CENTERED; + } + + if (style & WindowStyle_Resizable) + winStyle |= SDL_WINDOW_RESIZABLE; + if (style & WindowStyle_Max) + winStyle |= SDL_WINDOW_MAXIMIZED; + + m_eventListener = true; + m_ownsWindow = true; + m_sizemove = false; + m_style = style; + + m_handle = SDL_CreateWindow(title.GetConstBuffer(), x, y, width, height, winStyle); + + if (!m_handle) + { + NazaraError("Failed to create window: " + Error::GetLastSystemError()); + return false; + } + + PrepareWindow(fullscreen); + + SDL_AddEventWatch(HandleEvent, this); + + return true; + } + + bool WindowImpl::Create(WindowHandle handle) + { + m_handle = static_cast(handle); + + if (!m_handle || !SDL_GetWindowID(m_handle)) + { + NazaraError("Invalid handle"); + return false; + } + + m_eventListener = false; + m_ownsWindow = false; + m_sizemove = false; + + SDL_GetWindowPosition(m_handle, &m_position.x, &m_position.y); + + int width; + int height; + SDL_GetWindowSize(m_handle, &width, &height); + + m_size.Set(width, height); + + SDL_AddEventWatch(HandleEvent, this); + + return true; + } + + void WindowImpl::Destroy() + { + if (m_ownsWindow && m_handle) + SDL_DestroyWindow(m_handle); + else + SetEventListener(false); + + SDL_DelEventWatch(HandleEvent, this); + } + + void WindowImpl::EnableKeyRepeat(bool enable) + { + m_keyRepeat = enable; + } + + void WindowImpl::EnableSmoothScrolling(bool enable) + { + m_smoothScrolling = enable; + } + + WindowHandle WindowImpl::GetHandle() const + { + return m_handle; + } + + Vector2i WindowImpl::GetPosition() const + { + return m_position; + } + + Vector2ui WindowImpl::GetSize() const + { + return m_size; + } + + WindowStyleFlags WindowImpl::GetStyle() const + { + return m_style; + } + + String WindowImpl::GetTitle() const + { + return String::Unicode(SDL_GetWindowTitle(m_handle)); + } + + bool WindowImpl::HasFocus() const + { + return (SDL_GetWindowFlags(m_handle) & SDL_WINDOW_INPUT_FOCUS) != 0; + } + + void WindowImpl::IgnoreNextMouseEvent(int mouseX, int mouseY) + { + m_ignoreNextMouseMove = true; + // Petite astuce ... probablement foireuse dans certains cas :ahde: + m_mousePos.x = mouseX; + m_mousePos.y = mouseY; + } + + bool WindowImpl::IsMinimized() const + { + return (SDL_GetWindowFlags(m_handle) & SDL_WINDOW_MINIMIZED) != 0; + } + + bool WindowImpl::IsVisible() const + { + return (SDL_GetWindowFlags(m_handle) & SDL_WINDOW_SHOWN) != 0; + } + + void WindowImpl::RefreshCursor() + { + if (!m_cursor) + { + if (SDL_ShowCursor(SDL_DISABLE) < 0) + NazaraWarning(SDL_GetError()); + } + else + { + if (SDL_ShowCursor(SDL_ENABLE) < 0) + NazaraWarning(SDL_GetError()); + + SDL_SetCursor(m_cursor); + } + } + + void WindowImpl::ProcessEvents(bool block) + { + SDL_PumpEvents(); + + + /*if (m_ownsWindow) + { + if (block) + WaitMessage(); + + MSG message; + while (PeekMessageW(&message, nullptr, 0, 0, PM_REMOVE)) + { + TranslateMessage(&message); + DispatchMessageW(&message); + } + }*/ + } + + int SDLCALL WindowImpl::HandleEvent(void *userdata, SDL_Event* event) + { + try { + auto window = static_cast(userdata); + + WindowEvent evt; + evt.type = WindowEventType::WindowEventType_Max; + + switch (event->type) + { + case SDL_WINDOWEVENT: + if (SDL_GetWindowID(window->m_handle) != event->window.windowID) + return 0; + + switch (event->window.event) + { + case SDL_WINDOWEVENT_CLOSE: + evt.type = Nz::WindowEventType::WindowEventType_Quit; + break; + case SDL_WINDOWEVENT_RESIZED: + evt.type = Nz::WindowEventType::WindowEventType_Resized; + + evt.size.width = event->window.data1; + evt.size.height = event->window.data2; + + window->m_size.Set(event->window.data1, event->window.data2); + + break; + case SDL_WINDOWEVENT_MOVED: + evt.type = Nz::WindowEventType::WindowEventType_Moved; + + evt.position.x = event->window.data1; + evt.position.y = event->window.data2; + + window->m_position.Set(event->window.data1, event->window.data2); + + break; + case SDL_WINDOWEVENT_FOCUS_GAINED: + evt.type = Nz::WindowEventType::WindowEventType_GainedFocus; + + break; + case SDL_WINDOWEVENT_FOCUS_LOST: + evt.type = Nz::WindowEventType::WindowEventType_LostFocus; + + break; + case SDL_WINDOWEVENT_ENTER: + evt.type = Nz::WindowEventType::WindowEventType_MouseEntered; + + break; + case SDL_WINDOWEVENT_LEAVE: + evt.type = Nz::WindowEventType::WindowEventType_MouseLeft; + + break; + } + break; + + case SDL_MOUSEMOTION: + if (SDL_GetWindowID(window->m_handle) != event->motion.windowID) + return 0; + + if (window->m_ignoreNextMouseMove && event->motion.x == window->m_mousePos.x && event->motion.y == window->m_mousePos.y) + { + window->m_ignoreNextMouseMove = false; + + return 0; + } + + evt.type = Nz::WindowEventType::WindowEventType_MouseMoved; + + evt.mouseMove.x = event->motion.x; + evt.mouseMove.y = event->motion.y; + evt.mouseMove.deltaX = event->motion.xrel; + evt.mouseMove.deltaY = event->motion.yrel; + + break; + + case SDL_MOUSEBUTTONDOWN: + if (SDL_GetWindowID(window->m_handle) != event->button.windowID) + return 0; + + evt.mouseButton.button = SDLToNazaraButton(event->button.button); + evt.mouseButton.x = event->button.x; + evt.mouseButton.y = event->button.y; + + if (event->button.clicks % 2 == 0) + { + evt.type = Nz::WindowEventType::WindowEventType_MouseButtonDoubleClicked; + + window->m_parent->PushEvent(evt); + } + + evt.type = Nz::WindowEventType::WindowEventType_MouseButtonPressed; + + break; + + case SDL_MOUSEBUTTONUP: + if (SDL_GetWindowID(window->m_handle) != event->button.windowID) + return 0; + + evt.mouseButton.button = SDLToNazaraButton(event->button.button); + evt.mouseButton.x = event->button.x; + evt.mouseButton.y = event->button.y; + + evt.type = Nz::WindowEventType::WindowEventType_MouseButtonReleased; + + break; + + case SDL_MOUSEWHEEL: + if (SDL_GetWindowID(window->m_handle) != event->wheel.windowID) + return 0; + + evt.type = Nz::WindowEventType::WindowEventType_MouseWheelMoved; + + evt.mouseWheel.delta = event->wheel.y; + + break; + + case SDL_KEYDOWN: + if (SDL_GetWindowID(window->m_handle) != event->key.windowID) + return 0; + + evt.type = WindowEventType_KeyPressed; + + evt.key.code = SDLKeySymToNazaraKey(event->key.keysym); + evt.key.alt = (event->key.keysym.mod & KMOD_ALT) != 0; + evt.key.control = (event->key.keysym.mod & KMOD_CTRL) != 0; + evt.key.repeated = event->key.repeat != 0; + evt.key.shift = (event->key.keysym.mod & KMOD_SHIFT) != 0; + evt.key.system = (event->key.keysym.mod & KMOD_GUI) != 0; + + break; + + case SDL_KEYUP: + if (SDL_GetWindowID(window->m_handle) != event->key.windowID) + return 0; + + evt.type = WindowEventType_KeyReleased; + + evt.key.code = SDLKeySymToNazaraKey(event->key.keysym); + evt.key.alt = (event->key.keysym.mod & KMOD_ALT) != 0; + evt.key.control = (event->key.keysym.mod & KMOD_CTRL) != 0; + evt.key.repeated = event->key.repeat != 0; + evt.key.shift = (event->key.keysym.mod & KMOD_SHIFT) != 0; + evt.key.system = (event->key.keysym.mod & KMOD_GUI) != 0; + + break; + + case SDL_TEXTINPUT: + if (SDL_GetWindowID(window->m_handle) != event->text.windowID) + return 0; + + evt.type = WindowEventType_TextEntered; + + for (decltype(evt.text.character)codepoint : String::Unicode(event->text.text).GetUtf32String()) + { + evt.text.character = codepoint; + + window->m_parent->PushEvent(evt); + } + + // prevent post switch event + evt.type = WindowEventType::WindowEventType_Max; + + break; + } + + if (evt.type != WindowEventType::WindowEventType_Max) + window->m_parent->PushEvent(evt); + } + catch (std::exception e) + { + NazaraError(e.what()); + } + catch (...) // Don't let any exceptions go thru C calls + { + NazaraError("An unknown error happened"); + } + + return 0; + } + + void WindowImpl::SetCursor(const Cursor& cursor) + { + m_cursor = cursor.m_impl->GetCursor(); + + if (HasFocus()) + RefreshCursor(); + } + + void WindowImpl::SetEventListener(bool listener) + { + + } + + void WindowImpl::SetFocus() + { + SDL_RaiseWindow(m_handle); + } + + void WindowImpl::SetIcon(const Icon& icon) + { + SDL_SetWindowIcon(m_handle, icon.m_impl->GetIcon()); + } + + void WindowImpl::SetMaximumSize(int width, int height) + { + SDL_SetWindowMaximumSize(m_handle, width, height); + } + + void WindowImpl::SetMinimumSize(int width, int height) + { + SDL_SetWindowMinimumSize(m_handle, width, height); + } + + void WindowImpl::SetPosition(int x, int y) + { + SDL_SetWindowPosition(m_handle, x, y); + } + + void WindowImpl::SetSize(unsigned int width, unsigned int height) + { + m_size.Set(width, height); + SDL_SetWindowSize(m_handle, width, height); + } + + void WindowImpl::SetStayOnTop(bool stayOnTop) + { + NazaraDebug("Stay on top isn't supported by SDL2 backend for now"); + } + + void WindowImpl::SetTitle(const String& title) + { + SDL_SetWindowTitle(m_handle, title.GetConstBuffer()); + } + + void WindowImpl::SetVisible(bool visible) + { + visible ? SDL_ShowWindow(m_handle) : SDL_HideWindow(m_handle); + } + + void WindowImpl::PrepareWindow(bool fullscreen) + { + (void)fullscreen; // ignore param warning + + SDL_GetWindowPosition(m_handle, &m_position.x, &m_position.y); + + int width, height; + SDL_GetWindowSize(m_handle, &width, &height); + + m_size.Set(width, height); + } + + bool WindowImpl::Initialize() + { + if (SDL_Init(SDL_INIT_VIDEO) < 0) + { + NazaraError(SDL_GetError()); + return false; + } + if (SDL_GL_LoadLibrary(nullptr) < 0) + { + NazaraError(SDL_GetError()); + + SDL_Quit(); + return false; + } + + if (SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, true) < 0) + NazaraError("Couldn't set share OpenGL contexes"); + + return true; + } + + void WindowImpl::Uninitialize() + { + SDL_Quit(); + } + + Keyboard::Key WindowImpl::SDLKeySymToNazaraKey(SDL_Keysym& keysym) + { + auto key = keysym.scancode; + + switch (key) + { + case SDL_SCANCODE_LCTRL: return Keyboard::LControl; + case SDL_SCANCODE_RCTRL: return Keyboard::RControl; + case SDL_SCANCODE_LALT: return Keyboard::LAlt; + case SDL_SCANCODE_RALT: return Keyboard::RAlt; + case SDL_SCANCODE_LSHIFT: return Keyboard::LShift; + case SDL_SCANCODE_RSHIFT: return Keyboard::RShift; + + case SDL_SCANCODE_0: return Keyboard::Num0; + case SDL_SCANCODE_1: return Keyboard::Num1; + case SDL_SCANCODE_2: return Keyboard::Num2; + case SDL_SCANCODE_3: return Keyboard::Num3; + case SDL_SCANCODE_4: return Keyboard::Num4; + case SDL_SCANCODE_5: return Keyboard::Num5; + case SDL_SCANCODE_6: return Keyboard::Num6; + case SDL_SCANCODE_7: return Keyboard::Num7; + case SDL_SCANCODE_8: return Keyboard::Num8; + case SDL_SCANCODE_9: return Keyboard::Num9; + case SDL_SCANCODE_A: return Keyboard::A; + case SDL_SCANCODE_B: return Keyboard::B; + case SDL_SCANCODE_C: return Keyboard::C; + case SDL_SCANCODE_D: return Keyboard::D; + case SDL_SCANCODE_E: return Keyboard::E; + case SDL_SCANCODE_F: return Keyboard::F; + case SDL_SCANCODE_G: return Keyboard::G; + case SDL_SCANCODE_H: return Keyboard::H; + case SDL_SCANCODE_I: return Keyboard::I; + case SDL_SCANCODE_J: return Keyboard::J; + case SDL_SCANCODE_K: return Keyboard::K; + case SDL_SCANCODE_L: return Keyboard::L; + case SDL_SCANCODE_M: return Keyboard::M; + case SDL_SCANCODE_N: return Keyboard::N; + case SDL_SCANCODE_O: return Keyboard::O; + case SDL_SCANCODE_P: return Keyboard::P; + case SDL_SCANCODE_Q: return Keyboard::Q; + case SDL_SCANCODE_R: return Keyboard::R; + case SDL_SCANCODE_S: return Keyboard::S; + case SDL_SCANCODE_T: return Keyboard::T; + case SDL_SCANCODE_U: return Keyboard::U; + case SDL_SCANCODE_V: return Keyboard::V; + case SDL_SCANCODE_W: return Keyboard::W; + case SDL_SCANCODE_X: return Keyboard::X; + case SDL_SCANCODE_Y: return Keyboard::Y; + case SDL_SCANCODE_Z: return Keyboard::Z; + case SDL_SCANCODE_KP_PLUS: return Keyboard::Add; + case SDL_SCANCODE_BACKSPACE: return Keyboard::Backspace; + case SDL_SCANCODE_AC_BACK: return Keyboard::Browser_Back; + case SDL_SCANCODE_AC_BOOKMARKS: return Keyboard::Browser_Favorites; + case SDL_SCANCODE_AC_FORWARD: return Keyboard::Browser_Forward; + case SDL_SCANCODE_AC_HOME: return Keyboard::Browser_Home; + case SDL_SCANCODE_AC_REFRESH: return Keyboard::Browser_Refresh; + case SDL_SCANCODE_AC_SEARCH: return Keyboard::Browser_Search; + case SDL_SCANCODE_AC_STOP: return Keyboard::Browser_Stop; + case SDL_SCANCODE_CAPSLOCK: return Keyboard::CapsLock; + case SDL_SCANCODE_CLEAR: return Keyboard::Clear; + case SDL_SCANCODE_KP_PERIOD: return Keyboard::Decimal; + case SDL_SCANCODE_DELETE: return Keyboard::Delete; + case SDL_SCANCODE_KP_DIVIDE: return Keyboard::Divide; + case SDL_SCANCODE_DOWN: return Keyboard::Down; + case SDL_SCANCODE_END: return Keyboard::End; + case SDL_SCANCODE_ESCAPE: return Keyboard::Escape; + case SDL_SCANCODE_F1: return Keyboard::F1; + case SDL_SCANCODE_F2: return Keyboard::F2; + case SDL_SCANCODE_F3: return Keyboard::F3; + case SDL_SCANCODE_F4: return Keyboard::F4; + case SDL_SCANCODE_F5: return Keyboard::F5; + case SDL_SCANCODE_F6: return Keyboard::F6; + case SDL_SCANCODE_F7: return Keyboard::F7; + case SDL_SCANCODE_F8: return Keyboard::F8; + case SDL_SCANCODE_F9: return Keyboard::F9; + case SDL_SCANCODE_F10: return Keyboard::F10; + case SDL_SCANCODE_F11: return Keyboard::F11; + case SDL_SCANCODE_F12: return Keyboard::F12; + case SDL_SCANCODE_F13: return Keyboard::F13; + case SDL_SCANCODE_F14: return Keyboard::F14; + case SDL_SCANCODE_F15: return Keyboard::F15; + case SDL_SCANCODE_HOME: return Keyboard::Home; + case SDL_SCANCODE_INSERT: return Keyboard::Insert; + case SDL_SCANCODE_LEFT: return Keyboard::Left; + case SDL_SCANCODE_LGUI: return Keyboard::LSystem; + case SDL_SCANCODE_AUDIONEXT: return Keyboard::Media_Next; + case SDL_SCANCODE_AUDIOPLAY: return Keyboard::Media_Play; + case SDL_SCANCODE_AUDIOPREV: return Keyboard::Media_Previous; + case SDL_SCANCODE_AUDIOSTOP: return Keyboard::Media_Stop; + case SDL_SCANCODE_KP_MULTIPLY: return Keyboard::Multiply; + case SDL_SCANCODE_PAGEDOWN: return Keyboard::PageDown; + case SDL_SCANCODE_KP_0: return Keyboard::Numpad0; + case SDL_SCANCODE_KP_1: return Keyboard::Numpad1; + case SDL_SCANCODE_KP_2: return Keyboard::Numpad2; + case SDL_SCANCODE_KP_3: return Keyboard::Numpad3; + case SDL_SCANCODE_KP_4: return Keyboard::Numpad4; + case SDL_SCANCODE_KP_5: return Keyboard::Numpad5; + case SDL_SCANCODE_KP_6: return Keyboard::Numpad6; + case SDL_SCANCODE_KP_7: return Keyboard::Numpad7; + case SDL_SCANCODE_KP_8: return Keyboard::Numpad8; + case SDL_SCANCODE_KP_9: return Keyboard::Numpad9; + case SDL_SCANCODE_NUMLOCKCLEAR: return Keyboard::NumLock; + case SDL_SCANCODE_SEMICOLON: return Keyboard::Semicolon; + case SDL_SCANCODE_SLASH: return Keyboard::Slash; + case SDL_SCANCODE_GRAVE: return Keyboard::Tilde; + case SDL_SCANCODE_APPLICATION: return Keyboard::Menu; + case SDL_SCANCODE_NONUSBACKSLASH: return Keyboard::ISOBackslash102; + case SDL_SCANCODE_LEFTBRACKET: return Keyboard::LBracket; + case SDL_SCANCODE_BACKSLASH: return Keyboard::Backslash; + case SDL_SCANCODE_RIGHTBRACKET: return Keyboard::RBracket; + case SDL_SCANCODE_APOSTROPHE: return Keyboard::Quote; + case SDL_SCANCODE_COMMA: return Keyboard::Comma; + case SDL_SCANCODE_MINUS: return Keyboard::Dash; + case SDL_SCANCODE_PERIOD: return Keyboard::Period; + case SDL_SCANCODE_EQUALS: return Keyboard::Equal; + case SDL_SCANCODE_RIGHT: return Keyboard::Right; + case SDL_SCANCODE_PAGEUP: return Keyboard::PageUp; + case SDL_SCANCODE_PAUSE: return Keyboard::Pause; + case SDL_SCANCODE_SYSREQ: return Keyboard::Print; + case SDL_SCANCODE_SCROLLLOCK: return Keyboard::ScrollLock; + case SDL_SCANCODE_PRINTSCREEN: return Keyboard::PrintScreen; + case SDL_SCANCODE_KP_MINUS: return Keyboard::Subtract; + case SDL_SCANCODE_RETURN: return Keyboard::Return; + case SDL_SCANCODE_KP_ENTER: return Keyboard::NumpadReturn; + case SDL_SCANCODE_RGUI: return Keyboard::RSystem; + case SDL_SCANCODE_SPACE: return Keyboard::Space; + case SDL_SCANCODE_TAB: return Keyboard::Tab; + case SDL_SCANCODE_UP: return Keyboard::Up; + case SDL_SCANCODE_VOLUMEDOWN: return Keyboard::Volume_Down; + case SDL_SCANCODE_MUTE: return Keyboard::Volume_Mute; + case SDL_SCANCODE_AUDIOMUTE: return Keyboard::Volume_Mute; + case SDL_SCANCODE_VOLUMEUP: return Keyboard::Volume_Up; + + default: + return Keyboard::Undefined; + } + } + + // not implemented for now, wait for mainloop friendly input + //void WindowImpl::WindowThread(SDL_Window* handle, /*DWORD styleEx,*/ const String& title, /*DWORD style,*/ bool fullscreen, const Rectui& dimensions, WindowImpl* window, Mutex* mutex, ConditionVariable* condition) + //{ + // SDL_Window& winHandle = *handle; + /*winHandle = CreateWindowExW(styleEx, className, title.GetWideString().data(), style, dimensions.x, dimensions.y, dimensions.width, dimensions.height, nullptr, nullptr, GetModuleHandle(nullptr), window); + + if (winHandle) + window->PrepareWindow(fullscreen); + + mutex->Lock(); + condition->Signal(); + mutex->Unlock(); // mutex and condition may be destroyed after this line + + if (!winHandle) + return; + + while (window->m_threadActive) + window->ProcessEvents(true); + + DestroyWindow(winHandle);*/ + //} +} diff --git a/src/Nazara/Platform/SDL2/WindowImpl.hpp b/src/Nazara/Platform/SDL2/WindowImpl.hpp new file mode 100644 index 000000000..b983d2881 --- /dev/null +++ b/src/Nazara/Platform/SDL2/WindowImpl.hpp @@ -0,0 +1,113 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Platform module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +// Interface inspirée de la SFML par Laurent Gomila + +#pragma once + +#ifndef NAZARA_WINDOWIMPL_HPP +#define NAZARA_WINDOWIMPL_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class ConditionVariable; + class Mutex; + class Window; + + class WindowImpl + { + public: + WindowImpl(Window* parent); + WindowImpl(const WindowImpl&) = delete; + WindowImpl(WindowImpl&&) = delete; ///TODO? + ~WindowImpl() = default; + + bool Create(const VideoMode& mode, const String& title, WindowStyleFlags style); + bool Create(WindowHandle handle); + + void Destroy(); + + void EnableKeyRepeat(bool enable); + void EnableSmoothScrolling(bool enable); + + WindowHandle GetHandle() const; + Vector2i GetPosition() const; + Vector2ui GetSize() const; + WindowStyleFlags GetStyle() const; + String GetTitle() const; + + bool HasFocus() const; + + void IgnoreNextMouseEvent(int mouseX, int mouseY); + + bool IsMinimized() const; + bool IsVisible() const; + + void RefreshCursor(); + + void ProcessEvents(bool block); + + void SetCursor(const Cursor& cursor); + void SetEventListener(bool listener); + void SetFocus(); + void SetIcon(const Icon& icon); + void SetMaximumSize(int width, int height); + void SetMinimumSize(int width, int height); + void SetPosition(int x, int y); + void SetSize(unsigned int width, unsigned int height); + void SetStayOnTop(bool stayOnTop); + void SetTitle(const String& title); + void SetVisible(bool visible); + + WindowImpl& operator=(const WindowImpl&) = delete; + WindowImpl& operator=(WindowImpl&&) = delete; ///TODO? + + static bool Initialize(); + static void Uninitialize(); + + private: + int static SDLCALL HandleEvent(void *userdata, SDL_Event * event); + + void PrepareWindow(bool fullscreen); + + static Keyboard::Key SDLKeySymToNazaraKey(SDL_Keysym& keysym); + //static void WindowThread(SDL_Window* handle, /*DWORD styleEx,*/ const String& title, /*DWORD style,*/ bool fullscreen, const Rectui& dimensions, WindowImpl* window, Mutex* mutex, ConditionVariable* condition); + + SDL_Cursor* m_cursor; + SDL_Window* m_handle; + WindowStyleFlags m_style; + Vector2i m_maxSize; + Vector2i m_minSize; + Vector2i m_mousePos; + Vector2i m_position; + Vector2ui m_size; + //Thread m_thread; + Window* m_parent; + bool m_eventListener; + bool m_ignoreNextMouseMove = false; + bool m_keyRepeat; + bool m_mouseInside; + bool m_ownsWindow; + bool m_sizemove; + bool m_smoothScrolling; + bool m_threadActive; + short m_scrolling; + }; +} + +#endif // NAZARA_WINDOWIMPL_HPP diff --git a/src/Nazara/Platform/VideoMode.cpp b/src/Nazara/Platform/VideoMode.cpp index 5cc78d981..1cd8b0990 100644 --- a/src/Nazara/Platform/VideoMode.cpp +++ b/src/Nazara/Platform/VideoMode.cpp @@ -6,7 +6,9 @@ #include #include -#if defined(NAZARA_PLATFORM_WINDOWS) +#if defined(NAZARA_PLATFORM_SDL2) + #include +#elif defined(NAZARA_PLATFORM_WINDOWS) #include #elif defined(NAZARA_PLATFORM_X11) #include diff --git a/src/Nazara/Platform/Win32/InputImpl.cpp b/src/Nazara/Platform/Win32/InputImpl.cpp index f44594fa4..0858ec7a0 100644 --- a/src/Nazara/Platform/Win32/InputImpl.cpp +++ b/src/Nazara/Platform/Win32/InputImpl.cpp @@ -2,11 +2,11 @@ // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include #include +#include +#include #include #include -#include namespace Nz { @@ -42,115 +42,118 @@ namespace Nz 0x5A, // Key::Z // Touches de fonction - VK_F1, // Key::F1 - VK_F2, // Key::F2 - VK_F3, // Key::F3 - VK_F4, // Key::F4 - VK_F5, // Key::F5 - VK_F6, // Key::F6 - VK_F7, // Key::F7 - VK_F8, // Key::F8 - VK_F9, // Key::F9 - VK_F10, // Key::F10 - VK_F11, // Key::F11 - VK_F12, // Key::F12 - VK_F13, // Key::F13 - VK_F14, // Key::F14 - VK_F15, // Key::F15 + VK_F1, // Key::F1 + VK_F2, // Key::F2 + VK_F3, // Key::F3 + VK_F4, // Key::F4 + VK_F5, // Key::F5 + VK_F6, // Key::F6 + VK_F7, // Key::F7 + VK_F8, // Key::F8 + VK_F9, // Key::F9 + VK_F10, // Key::F10 + VK_F11, // Key::F11 + VK_F12, // Key::F12 + VK_F13, // Key::F13 + VK_F14, // Key::F14 + VK_F15, // Key::F15 // Flèches directionnelles VK_DOWN, // Key::Down VK_LEFT, // Key::Left VK_RIGHT, // Key::Right - VK_UP, // Key::Up + VK_UP, // Key::Up // Pavé numérique - VK_ADD, // Key::Add + VK_ADD, // Key::Add VK_DECIMAL, // Key::Decimal - VK_DIVIDE, // Key::Divide + VK_DIVIDE, // Key::Divide VK_MULTIPLY, // Key::Multiply - VK_NUMPAD0, // Key::Numpad0 - VK_NUMPAD1, // Key::Numpad1 - VK_NUMPAD2, // Key::Numpad2 - VK_NUMPAD3, // Key::Numpad3 - VK_NUMPAD4, // Key::Numpad4 - VK_NUMPAD5, // Key::Numpad5 - VK_NUMPAD6, // Key::Numpad6 - VK_NUMPAD7, // Key::Numpad7 - VK_NUMPAD8, // Key::Numpad8 - VK_NUMPAD9, // Key::Numpad9 + VK_RETURN, // Key::Multiply + VK_NUMPAD0, // Key::Numpad0 + VK_NUMPAD1, // Key::Numpad1 + VK_NUMPAD2, // Key::Numpad2 + VK_NUMPAD3, // Key::Numpad3 + VK_NUMPAD4, // Key::Numpad4 + VK_NUMPAD5, // Key::Numpad5 + VK_NUMPAD6, // Key::Numpad6 + VK_NUMPAD7, // Key::Numpad7 + VK_NUMPAD8, // Key::Numpad8 + VK_NUMPAD9, // Key::Numpad9 VK_SUBTRACT, // Key::Subtract // Diverss - VK_OEM_5, // Key::Backslash - VK_BACK, // Key::Backspace - VK_CLEAR, // Key::Clear + VK_OEM_5, // Key::Backslash + VK_BACK, // Key::Backspace + VK_CLEAR, // Key::Clear VK_OEM_COMMA, // Key::Comma, VK_OEM_MINUS, // Key::Dash - VK_DELETE, // Key::Delete - VK_END, // Key::End + VK_DELETE, // Key::Delete + VK_END, // Key::End VK_OEM_PLUS, // Key::Equal - VK_ESCAPE, // Key::Escape - VK_HOME, // Key::Home - VK_INSERT, // Key::Insert - VK_LMENU, // Key::LAlt - VK_OEM_4, // Key::LBracket + VK_ESCAPE, // Key::Escape + VK_HOME, // Key::Home + VK_INSERT, // Key::Insert + VK_LMENU, // Key::LAlt + VK_OEM_4, // Key::LBracket VK_LCONTROL, // Key::LControl - VK_LSHIFT, // Key::LShift - VK_LWIN, // Key::LSystem - 0x30, // Key::Num0 - 0x31, // Key::Num1 - 0x32, // Key::Num2 - 0x33, // Key::Num3 - 0x34, // Key::Num4 - 0x35, // Key::Num5 - 0x36, // Key::Num6 - 0x37, // Key::Num7 - 0x38, // Key::Num8 - 0x39, // Key::Num9 - VK_NEXT, // Key::PageDown - VK_PRIOR, // Key::PageUp - VK_PAUSE, // Key::Pause + VK_LSHIFT, // Key::LShift + VK_LWIN, // Key::LSystem + 0x30, // Key::Num0 + 0x31, // Key::Num1 + 0x32, // Key::Num2 + 0x33, // Key::Num3 + 0x34, // Key::Num4 + 0x35, // Key::Num5 + 0x36, // Key::Num6 + 0x37, // Key::Num7 + 0x38, // Key::Num8 + 0x39, // Key::Num9 + VK_NEXT, // Key::PageDown + VK_PRIOR, // Key::PageUp + VK_PAUSE, // Key::Pause VK_OEM_PERIOD, // Key::Period - VK_PRINT, // Key::Print + VK_PRINT, // Key::Print VK_SNAPSHOT, // Key::PrintScreen - VK_OEM_7, // Key::Quote - VK_RMENU, // Key::RAlt - VK_OEM_6, // Key::RBracket + VK_OEM_7, // Key::Quote + VK_RMENU, // Key::RAlt + VK_OEM_6, // Key::RBracket VK_RCONTROL, // Key::RControl - VK_RETURN, // Key::Return - VK_RSHIFT, // Key::RShift - VK_RWIN, // Key::RSystem - VK_OEM_1, // Key::Semicolon - VK_OEM_2, // Key::Slash - VK_SPACE, // Key::Space - VK_TAB, // Key::Tab - VK_OEM_3, // Key::Tilde + VK_RETURN, // Key::Return + VK_RSHIFT, // Key::RShift + VK_RWIN, // Key::RSystem + VK_OEM_1, // Key::Semicolon + VK_OEM_2, // Key::Slash + VK_SPACE, // Key::Space + VK_TAB, // Key::Tab + VK_OEM_3, // Key::Tilde + VK_APPS, // Key::Menu + VK_OEM_102, // Key::ISOBackslash102 // Touches navigateur - VK_BROWSER_BACK, // Key::Browser_Back + VK_BROWSER_BACK, // Key::Browser_Back VK_BROWSER_FAVORITES, // Key::Browser_Favorites - VK_BROWSER_FORWARD, // Key::Browser_Forward - VK_BROWSER_HOME, // Key::Browser_Home - VK_BROWSER_REFRESH, // Key::Browser_Refresh - VK_BROWSER_SEARCH, // Key::Browser_Search - VK_BROWSER_STOP, // Key::Browser_Stop + VK_BROWSER_FORWARD, // Key::Browser_Forward + VK_BROWSER_HOME, // Key::Browser_Home + VK_BROWSER_REFRESH, // Key::Browser_Refresh + VK_BROWSER_SEARCH, // Key::Browser_Search + VK_BROWSER_STOP, // Key::Browser_Stop // Touches de contrôle VK_MEDIA_NEXT_TRACK, // Key::Media_Next, VK_MEDIA_PLAY_PAUSE, // Key::Media_PlayPause, VK_MEDIA_PREV_TRACK, // Key::Media_Previous, - VK_MEDIA_STOP, // Key::Media_Stop, + VK_MEDIA_STOP, // Key::Media_Stop, // Touches de contrôle du volume - VK_VOLUME_DOWN, // Key::Volume_Down - VK_VOLUME_MUTE, // Key::Volume_Mute - VK_VOLUME_UP, // Key::Volume_Up + VK_VOLUME_DOWN, // Key::Volume_Down + VK_VOLUME_MUTE, // Key::Volume_Mute + VK_VOLUME_UP, // Key::Volume_Up // Touches à verrouillage - VK_CAPITAL, // Key::CapsLock - VK_NUMLOCK, // Key::NumLock - VK_SCROLL // Key::ScrollLock + VK_CAPITAL, // Key::CapsLock + VK_NUMLOCK, // Key::NumLock + VK_SCROLL // Key::ScrollLock }; } @@ -192,6 +195,7 @@ namespace Nz case VK_RIGHT: case VK_RWIN: case VK_UP: + case VK_RETURN: // TODO check code |= 0x1000000; // 24ème bit pour l'extension break; } @@ -247,17 +251,16 @@ namespace Nz bool EventImpl::IsMouseButtonPressed(Mouse::Button button) { - static int vButtons[Mouse::Max+1] = { - VK_LBUTTON, // Button::Left - VK_MBUTTON, // Button::Middle - VK_RBUTTON, // Button::Right + static int vButtons[Mouse::Max + 1] = { + VK_LBUTTON, // Button::Left + VK_MBUTTON, // Button::Middle + VK_RBUTTON, // Button::Right VK_XBUTTON1, // Button::XButton1 - VK_XBUTTON2 // Button::XButton2 + VK_XBUTTON2 // Button::XButton2 }; // Gestion de l'inversement des boutons de la souris if (GetSystemMetrics(SM_SWAPBUTTON)) - { switch (button) { case Mouse::Left: @@ -271,7 +274,6 @@ namespace Nz default: break; } - } return (GetAsyncKeyState(vButtons[button]) & 0x8000) != 0; } @@ -292,5 +294,5 @@ namespace Nz } else NazaraError("Invalid window handle"); - } + } } diff --git a/src/Nazara/Platform/Win32/WindowImpl.cpp b/src/Nazara/Platform/Win32/WindowImpl.cpp index 1e5135168..ad381c8f8 100644 --- a/src/Nazara/Platform/Win32/WindowImpl.cpp +++ b/src/Nazara/Platform/Win32/WindowImpl.cpp @@ -4,21 +4,21 @@ // Un grand merci à Laurent Gomila pour la SFML qui m'aura bien aidé à réaliser cette implémentation -#include +#include +#include #include #include #include #include #include #include +#include #include #include #include +#include #include -#include -#include #include -#include #ifdef _WIN64 #define GCL_HCURSOR GCLP_HCURSOR @@ -41,17 +41,17 @@ namespace Nz } WindowImpl::WindowImpl(Window* parent) : - m_cursor(nullptr), - m_handle(nullptr), - m_callback(0), - m_style(0), - m_maxSize(-1), - m_minSize(-1), - m_parent(parent), - m_keyRepeat(true), - m_mouseInside(false), - m_smoothScrolling(false), - m_scrolling(0) + m_cursor(nullptr), + m_handle(nullptr), + m_callback(0), + m_style(0), + m_maxSize(-1), + m_minSize(-1), + m_parent(parent), + m_keyRepeat(true), + m_mouseInside(false), + m_smoothScrolling(false), + m_scrolling(0) { m_cursor = static_cast(LoadImage(nullptr, IDC_ARROW, IMAGE_CURSOR, 0, 0, LR_SHARED)); } @@ -71,8 +71,8 @@ namespace Nz win32Mode.dmBitsPerPel = mode.bitsPerPixel; win32Mode.dmPelsHeight = mode.height; win32Mode.dmPelsWidth = mode.width; - win32Mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; - win32Mode.dmSize = sizeof(DEVMODE); + win32Mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; + win32Mode.dmSize = sizeof(DEVMODE); if (ChangeDisplaySettings(&win32Mode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) { @@ -114,11 +114,11 @@ namespace Nz RECT rect = {0, 0, static_cast(width), static_cast(height)}; AdjustWindowRect(&rect, win32Style, false); - width = rect.right-rect.left; - height = rect.bottom-rect.top; + width = rect.right - rect.left; + height = rect.bottom - rect.top; - x = (GetSystemMetrics(SM_CXSCREEN) - width)/2; - y = (GetSystemMetrics(SM_CYSCREEN) - height)/2; + x = (GetSystemMetrics(SM_CXSCREEN) - width) / 2; + y = (GetSystemMetrics(SM_CYSCREEN) - height) / 2; } m_callback = 0; @@ -175,7 +175,7 @@ namespace Nz GetWindowRect(m_handle, &windowRect); m_position.Set(windowRect.left, windowRect.top); - m_size.Set(clientRect.right-clientRect.left, clientRect.bottom-clientRect.top); + m_size.Set(clientRect.right - clientRect.left, clientRect.bottom - clientRect.top); return true; } @@ -194,11 +194,8 @@ namespace Nz m_thread.Join(); } } - else - { - if (m_handle) - DestroyWindow(m_handle); - } + else if (m_handle) + DestroyWindow(m_handle); } else SetEventListener(false); @@ -338,12 +335,12 @@ namespace Nz AdjustWindowRect(&rect, static_cast(GetWindowLongPtr(m_handle, GWL_STYLE)), false); if (width != -1) - m_maxSize.x = rect.right-rect.left; + m_maxSize.x = rect.right - rect.left; else m_maxSize.x = -1; if (height != -1) - m_maxSize.y = rect.bottom-rect.top; + m_maxSize.y = rect.bottom - rect.top; else m_maxSize.y = -1; } @@ -354,12 +351,12 @@ namespace Nz AdjustWindowRect(&rect, static_cast(GetWindowLongPtr(m_handle, GWL_STYLE)), false); if (width != -1) - m_minSize.x = rect.right-rect.left; + m_minSize.x = rect.right - rect.left; else m_minSize.x = -1; if (height != -1) - m_minSize.y = rect.bottom-rect.top; + m_minSize.y = rect.bottom - rect.top; else m_minSize.y = -1; } @@ -411,11 +408,11 @@ namespace Nz break; /*case WM_SETCURSOR: - // http://msdn.microsoft.com/en-us/library/windows/desktop/ms648382(v=vs.85).aspx - if (LOWORD(lParam) == HTCLIENT) - ::SetCursor(m_cursor); + // http://msdn.microsoft.com/en-us/library/windows/desktop/ms648382(v=vs.85).aspx + if (LOWORD(lParam) == HTCLIENT) + ::SetCursor(m_cursor); - break;*/ + break;*/ case WM_WINDOWPOSCHANGING: { @@ -438,7 +435,6 @@ namespace Nz } if (m_eventListener) - { switch (message) { case WM_CHAR: @@ -497,7 +493,7 @@ namespace Nz m_parent->PushEvent(event); } - Vector2ui size(clientRect.right-clientRect.left, clientRect.bottom-clientRect.top); + Vector2ui size(clientRect.right - clientRect.left, clientRect.bottom - clientRect.top); if (m_size != size) { m_size = size; @@ -712,7 +708,7 @@ namespace Nz { WindowEvent event; event.type = WindowEventType_MouseWheelMoved; - event.mouseWheel.delta = static_cast(GET_WHEEL_DELTA_WPARAM(wParam))/WHEEL_DELTA; + event.mouseWheel.delta = static_cast(GET_WHEEL_DELTA_WPARAM(wParam)) / WHEEL_DELTA; m_parent->PushEvent(event); } else @@ -722,7 +718,7 @@ namespace Nz { WindowEvent event; event.type = WindowEventType_MouseWheelMoved; - event.mouseWheel.delta = static_cast(m_scrolling/WHEEL_DELTA); + event.mouseWheel.delta = static_cast(m_scrolling / WHEEL_DELTA); m_parent->PushEvent(event); m_scrolling %= WHEEL_DELTA; @@ -813,7 +809,7 @@ namespace Nz RECT rect; GetClientRect(m_handle, &rect); - Vector2ui size(rect.right-rect.left, rect.bottom-rect.top); // On récupère uniquement la taille de la zone client + Vector2ui size(rect.right - rect.left, rect.bottom - rect.top); // On récupère uniquement la taille de la zone client if (m_size == size) break; @@ -903,7 +899,6 @@ namespace Nz default: break; } - } #if NAZARA_PLATFORM_WINDOWS_DISABLE_MENU_KEYS // http://msdn.microsoft.com/en-us/library/windows/desktop/ms646360(v=vs.85).aspx @@ -959,8 +954,9 @@ namespace Nz { switch (key) { - case VK_CONTROL: return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::RControl : Keyboard::LControl; - case VK_MENU: return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::RAlt : Keyboard::LAlt; + case VK_CONTROL: return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::RControl : Keyboard::LControl; + case VK_MENU: return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::RAlt : Keyboard::LAlt; + case VK_RETURN: return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::NumpadReturn : Keyboard::Return; // TODO Check case VK_SHIFT: { static UINT scancode = MapVirtualKey(VK_SHIFT, MAPVK_VK_TO_VSC); @@ -1059,6 +1055,8 @@ namespace Nz case VK_OEM_1: return Keyboard::Semicolon; case VK_OEM_2: return Keyboard::Slash; case VK_OEM_3: return Keyboard::Tilde; + case VK_APPS: return Keyboard::Menu; + case VK_OEM_102: return Keyboard::ISOBackslash102; case VK_OEM_4: return Keyboard::LBracket; case VK_OEM_5: return Keyboard::Backslash; case VK_OEM_6: return Keyboard::RBracket; @@ -1074,7 +1072,6 @@ namespace Nz case VK_SCROLL: return Keyboard::ScrollLock; case VK_SNAPSHOT: return Keyboard::PrintScreen; case VK_SUBTRACT: return Keyboard::Subtract; - case VK_RETURN: return Keyboard::Return; case VK_RWIN: return Keyboard::RSystem; case VK_SPACE: return Keyboard::Space; case VK_TAB: return Keyboard::Tab; @@ -1137,10 +1134,8 @@ namespace Nz RECT rect; if (GetWindowRect(handle, &rect)) - { - if (static_cast(rect.right-rect.left) == mode.dmPelsWidth && static_cast(rect.bottom-rect.top) == mode.dmPelsHeight) + if (static_cast(rect.right - rect.left) == mode.dmPelsWidth && static_cast(rect.bottom - rect.top) == mode.dmPelsHeight) style |= WindowStyle_Fullscreen; - } return style; } diff --git a/src/Nazara/Platform/Window.cpp b/src/Nazara/Platform/Window.cpp index 9ce743ad4..47c93d290 100644 --- a/src/Nazara/Platform/Window.cpp +++ b/src/Nazara/Platform/Window.cpp @@ -9,7 +9,9 @@ #include #include -#if defined(NAZARA_PLATFORM_WINDOWS) +#if defined(NAZARA_PLATFORM_SDL2) + #include +#elif defined(NAZARA_PLATFORM_WINDOWS) #include #elif defined(NAZARA_PLATFORM_X11) #include diff --git a/src/Nazara/Platform/X11/InputImpl.cpp b/src/Nazara/Platform/X11/InputImpl.cpp index 152ba0337..5787e2d86 100644 --- a/src/Nazara/Platform/X11/InputImpl.cpp +++ b/src/Nazara/Platform/X11/InputImpl.cpp @@ -79,6 +79,7 @@ namespace Nz case Keyboard::Decimal: keysym = XK_KP_Decimal; break; case Keyboard::Divide: keysym = XK_KP_Divide; break; case Keyboard::Multiply: keysym = XK_KP_Multiply; break; + case Keyboard::NumpadReturn: keysym = XK_KP_Enter; break; case Keyboard::Numpad0: keysym = XK_KP_0; break; case Keyboard::Numpad1: keysym = XK_KP_1; break; case Keyboard::Numpad2: keysym = XK_KP_2; break; @@ -136,6 +137,8 @@ namespace Nz case Keyboard::Space: keysym = XK_space; break; case Keyboard::Tab: keysym = XK_Tab; break; case Keyboard::Tilde: keysym = XK_grave; break; + case Keyboard::Menu: keysym = XK_Menu; break; + case Keyboard::ISOBackslash102: keysym = XK_less; break; // Touches navigateur case Keyboard::Browser_Back: keysym = XF86XK_Back; break; diff --git a/src/Nazara/Platform/X11/WindowImpl.cpp b/src/Nazara/Platform/X11/WindowImpl.cpp index 0e8215e37..eda4453ea 100644 --- a/src/Nazara/Platform/X11/WindowImpl.cpp +++ b/src/Nazara/Platform/X11/WindowImpl.cpp @@ -4,10 +4,10 @@ // Un grand merci à Laurent Gomila pour la SFML qui m'aura bien aidé à réaliser cette implémentation -#include #include #include #include +#include #include #include #include @@ -15,14 +15,14 @@ #include #include #include +#include +#include #include #include #include -#include -#include /* - Things to do left: + Things to do left: Icon working sometimes (No idea) EnableKeyRepeat (Working but is it the right behaviour ?) @@ -35,7 +35,7 @@ SetStayOnTop (Equivalent for X11 ?) Opengl Context (glXCreateContextAttribs should be loaded like in window and the version for the context should be the one of NzContextParameters) -*/ + */ namespace Nz { @@ -44,21 +44,21 @@ namespace Nz Nz::WindowImpl* fullscreenWindow = nullptr; const uint32_t eventMask = XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_BUTTON_PRESS | - XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_BUTTON_MOTION | - XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_KEY_PRESS | - XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_STRUCTURE_NOTIFY | - XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW; + XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_BUTTON_MOTION | + XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_KEY_PRESS | + XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_STRUCTURE_NOTIFY | + XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW; xcb_connection_t* connection = nullptr; } WindowImpl::WindowImpl(Window* parent) : - m_window(0), - m_style(0), - m_parent(parent), - m_smoothScrolling(false), - m_mousePos(0, 0), - m_keyRepeat(true) + m_window(0), + m_style(0), + m_parent(parent), + m_smoothScrolling(false), + m_mousePos(0, 0), + m_keyRepeat(true) { std::memset(&m_size_hints, 0, sizeof(m_size_hints)); } @@ -96,34 +96,34 @@ namespace Nz const uint32_t value_list[] = { fullscreen, eventMask, colormap }; CallOnExit onExit([&](){ - if (!X11::CheckCookie( - connection, - xcb_free_colormap( - connection, - colormap - )) - ) - NazaraError("Failed to free colormap"); - }); + if (!X11::CheckCookie( + connection, + xcb_free_colormap( + connection, + colormap + )) + ) + NazaraError("Failed to free colormap"); + }); // Create the window m_window = xcb_generate_id(connection); if (!X11::CheckCookie( - connection, - xcb_create_window_checked( connection, - XCB_COPY_FROM_PARENT, - m_window, - m_screen->root, - left, top, - width, height, - 0, - XCB_WINDOW_CLASS_INPUT_OUTPUT, - m_screen->root_visual, - XCB_CW_EVENT_MASK | XCB_CW_OVERRIDE_REDIRECT | XCB_CW_COLORMAP, - value_list - ))) + xcb_create_window_checked( + connection, + XCB_COPY_FROM_PARENT, + m_window, + m_screen->root, + left, top, + width, height, + 0, + XCB_WINDOW_CLASS_INPUT_OUTPUT, + m_screen->root_visual, + XCB_CW_EVENT_MASK | XCB_CW_OVERRIDE_REDIRECT | XCB_CW_COLORMAP, + value_list + ))) { NazaraError("Failed to create window"); return false; @@ -141,7 +141,7 @@ namespace Nz m_window), &m_size_hints, &error - ); + ); if (error) NazaraError("Failed to get size hints"); @@ -215,7 +215,7 @@ namespace Nz m_window), &m_size_hints, &error - ); + ); if (error) { @@ -237,13 +237,11 @@ namespace Nz if (m_ownsWindow) { if (m_style & WindowStyle_Threaded) - { if (m_thread.IsJoinable()) { m_threadActive = false; m_thread.Join(); } - } // Destroy the window if (m_window && m_ownsWindow) @@ -252,11 +250,11 @@ namespace Nz SetCursor(*Cursor::Get(SystemCursor_Default)); if (!X11::CheckCookie( - connection, - xcb_destroy_window( connection, - m_window - ))) + xcb_destroy_window( + connection, + m_window + ))) NazaraError("Failed to destroy window"); xcb_flush(connection); @@ -309,7 +307,7 @@ namespace Nz xcb_ewmh_get_utf8_strings_reply_t data; xcb_ewmh_get_wm_name_reply(ewmhConnection, - xcb_ewmh_get_wm_name(ewmhConnection, m_window), &data, &error); + xcb_ewmh_get_wm_name(ewmhConnection, m_window), &data, &error); if (error) NazaraError("Failed to get window's title"); @@ -331,17 +329,17 @@ namespace Nz ScopedXCB error(nullptr); ScopedXCB reply(xcb_get_input_focus_reply( - connection, - xcb_get_input_focus_unchecked( - connection - ), - &error - )); + connection, + xcb_get_input_focus_unchecked( + connection + ), + &error + )); if (error) NazaraError("Failed to check if window has focus"); - return (reply->focus == m_window); + return reply->focus == m_window; } void WindowImpl::IgnoreNextMouseEvent(int mouseX, int mouseY) @@ -360,7 +358,7 @@ namespace Nz xcb_ewmh_get_atoms_reply_t atomReply; if (xcb_ewmh_get_wm_state_reply(ewmhConnection, - xcb_ewmh_get_wm_state(ewmhConnection, m_window), &atomReply, &error) == 1) + xcb_ewmh_get_wm_state(ewmhConnection, m_window), &atomReply, &error) == 1) { for (unsigned int i = 0; i < atomReply.atoms_len; i++) if (atomReply.atoms[i] == ewmhConnection->_NET_WM_STATE_HIDDEN) @@ -436,14 +434,14 @@ namespace Nz const uint32_t value_list[] = { eventMask }; if (!X11::CheckCookie( - connection, - xcb_change_window_attributes( connection, - m_window, - XCB_CW_EVENT_MASK, - value_list - )) - ) + xcb_change_window_attributes( + connection, + m_window, + XCB_CW_EVENT_MASK, + value_list + )) + ) NazaraError("Failed to change event for listener"); m_eventListener = true; @@ -453,14 +451,14 @@ namespace Nz const uint32_t value_list[] = { XCB_EVENT_MASK_NO_EVENT }; if (!X11::CheckCookie( - connection, - xcb_change_window_attributes( connection, - m_window, - XCB_CW_EVENT_MASK, - value_list - )) - ) + xcb_change_window_attributes( + connection, + m_window, + XCB_CW_EVENT_MASK, + value_list + )) + ) NazaraError("Failed to change event for listener"); m_eventListener = false; @@ -471,27 +469,27 @@ namespace Nz void WindowImpl::SetFocus() { if (!X11::CheckCookie( - connection, - xcb_set_input_focus( connection, - XCB_INPUT_FOCUS_POINTER_ROOT, - m_window, - XCB_CURRENT_TIME - )) - ) + xcb_set_input_focus( + connection, + XCB_INPUT_FOCUS_POINTER_ROOT, + m_window, + XCB_CURRENT_TIME + )) + ) NazaraError("Failed to set input focus"); const uint32_t values[] = { XCB_STACK_MODE_ABOVE }; if (!X11::CheckCookie( - connection, - xcb_configure_window( connection, - m_window, - XCB_CONFIG_WINDOW_STACK_MODE, - values - )) - ) + xcb_configure_window( + connection, + m_window, + XCB_CONFIG_WINDOW_STACK_MODE, + values + )) + ) NazaraError("Failed to set focus"); } @@ -518,7 +516,7 @@ namespace Nz m_window), &hints, &error - ); + ); if (error) NazaraError("Failed to get wm hints"); @@ -527,13 +525,13 @@ namespace Nz xcb_icccm_wm_hints_set_icon_mask(&hints, mask_pixmap); if (!X11::CheckCookie( - connection, - xcb_icccm_set_wm_hints( connection, - m_window, - &hints - )) - ) + xcb_icccm_set_wm_hints( + connection, + m_window, + &hints + )) + ) NazaraError("Failed to set wm hints"); xcb_flush(connection); @@ -570,14 +568,14 @@ namespace Nz const uint32_t values[] = { static_cast(x), static_cast(y) }; if (!X11::CheckCookie( - connection, - xcb_configure_window( connection, - m_window, - XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, - values - )) - ) + xcb_configure_window( + connection, + m_window, + XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, + values + )) + ) NazaraError("Failed to set position"); xcb_flush(connection); @@ -591,14 +589,14 @@ namespace Nz const uint32_t values[] = { width, height }; if (!X11::CheckCookie( - connection, - xcb_configure_window( connection, - m_window, - XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, - values - )) - ) + xcb_configure_window( + connection, + m_window, + XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, + values + )) + ) NazaraError("Failed to set sizes"); xcb_flush(connection); @@ -615,14 +613,14 @@ namespace Nz onTop = ewmhConnection->_NET_WM_STATE_BELOW; if (!X11::CheckCookie( - connection, - xcb_ewmh_set_wm_state( - ewmhConnection, - m_window, - 1, - &onTop - )) - ) + connection, + xcb_ewmh_set_wm_state( + ewmhConnection, + m_window, + 1, + &onTop + )) + ) NazaraError("Failed to set stay on top"); xcb_flush(connection); @@ -633,14 +631,14 @@ namespace Nz ScopedXCBEWMHConnection ewmhConnection(connection); if (!X11::CheckCookie( - connection, - xcb_ewmh_set_wm_name( - ewmhConnection, - m_window, - title.GetSize(), - title.GetConstBuffer() - )) - ) + connection, + xcb_ewmh_set_wm_name( + ewmhConnection, + m_window, + title.GetSize(), + title.GetConstBuffer() + )) + ) NazaraError("Failed to set title"); xcb_flush(connection); @@ -651,25 +649,22 @@ namespace Nz if (visible) { if (!X11::CheckCookie( - connection, - xcb_map_window( connection, - m_window - )) - ) + xcb_map_window( + connection, + m_window + )) + ) NazaraError("Failed to change window visibility to visible"); } - else - { - if (!X11::CheckCookie( - connection, - xcb_unmap_window( - connection, - m_window - )) - ) - NazaraError("Failed to change window visibility to invisible"); - } + else if (!X11::CheckCookie( + connection, + xcb_unmap_window( + connection, + m_window + )) + ) + NazaraError("Failed to change window visibility to invisible"); xcb_flush(connection); } @@ -708,8 +703,8 @@ namespace Nz xcb_keysym_t k0, k1; CallOnExit onExit([&](){ - X11::XCBKeySymbolsFree(keysyms); - }); + X11::XCBKeySymbolsFree(keysyms); + }); // Based on documentation in https://cgit.freedesktop.org/xcb/util-keysyms/tree/keysyms/keysyms.c // Mode switch = ctlr and alt gr = XCB_MOD_MASK_5 @@ -736,41 +731,41 @@ namespace Nz k1 = k0; /* The numlock modifier is on and the second KeySym is a keypad KeySym - The numlock modifier is on and the second KeySym is a keypad KeySym. In - this case, if the Shift modifier is on, or if the Lock modifier is on - and is interpreted as ShiftLock, then the first KeySym is used, - otherwise the second KeySym is used. - */ + The numlock modifier is on and the second KeySym is a keypad KeySym. In + this case, if the Shift modifier is on, or if the Lock modifier is on + and is interpreted as ShiftLock, then the first KeySym is used, + otherwise the second KeySym is used. + */ if ((state & XCB_MOD_MASK_2) && xcb_is_keypad_key(k1)) { - if ((state & XCB_MOD_MASK_SHIFT) || (state & XCB_MOD_MASK_LOCK && (state & XCB_MOD_MASK_SHIFT))) + if ((state & XCB_MOD_MASK_SHIFT) || (state & XCB_MOD_MASK_LOCK && (state & XCB_MOD_MASK_SHIFT))) return k0; else return k1; } /* The Shift and Lock modifiers are both off. In this case, the first - KeySym is used.*/ + KeySym is used.*/ else if (!(state & XCB_MOD_MASK_SHIFT) && !(state & XCB_MOD_MASK_LOCK)) return k0; /* The Shift modifier is off, and the Lock modifier is on and is - interpreted as CapsLock. In this case, the first KeySym is used, but - if that KeySym is lowercase alphabetic, then the corresponding - uppercase KeySym is used instead. */ + interpreted as CapsLock. In this case, the first KeySym is used, but + if that KeySym is lowercase alphabetic, then the corresponding + uppercase KeySym is used instead. */ else if (!(state & XCB_MOD_MASK_SHIFT) && (state & XCB_MOD_MASK_LOCK && (state & XCB_MOD_MASK_SHIFT))) return k0; /* The Shift modifier is on, and the Lock modifier is on and is - interpreted as CapsLock. In this case, the second KeySym is used, but - if that KeySym is lowercase alphabetic, then the corresponding - uppercase KeySym is used instead.*/ + interpreted as CapsLock. In this case, the second KeySym is used, but + if that KeySym is lowercase alphabetic, then the corresponding + uppercase KeySym is used instead.*/ else if ((state & XCB_MOD_MASK_SHIFT) && (state & XCB_MOD_MASK_LOCK && (state & XCB_MOD_MASK_SHIFT))) return k1; /* The Shift modifier is on, or the Lock modifier is on and is - interpreted as ShiftLock, or both. In this case, the second KeySym is - used. */ + interpreted as ShiftLock, or both. In this case, the second KeySym is + used. */ else if ((state & XCB_MOD_MASK_SHIFT) || (state & XCB_MOD_MASK_LOCK && (state & XCB_MOD_MASK_SHIFT))) return k1; @@ -785,149 +780,151 @@ namespace Nz switch (key) { - // Lettres - case XK_A: return Keyboard::A; - case XK_B: return Keyboard::B; - case XK_C: return Keyboard::C; - case XK_D: return Keyboard::D; - case XK_E: return Keyboard::E; - case XK_F: return Keyboard::F; - case XK_G: return Keyboard::G; - case XK_H: return Keyboard::H; - case XK_I: return Keyboard::I; - case XK_J: return Keyboard::J; - case XK_K: return Keyboard::K; - case XK_L: return Keyboard::L; - case XK_M: return Keyboard::M; - case XK_N: return Keyboard::N; - case XK_O: return Keyboard::O; - case XK_P: return Keyboard::P; - case XK_Q: return Keyboard::Q; - case XK_R: return Keyboard::R; - case XK_S: return Keyboard::S; - case XK_T: return Keyboard::T; - case XK_U: return Keyboard::U; - case XK_V: return Keyboard::V; - case XK_W: return Keyboard::W; - case XK_X: return Keyboard::X; - case XK_Y: return Keyboard::Y; - case XK_Z: return Keyboard::Z; + // Lettres + case XK_A: return Keyboard::A; + case XK_B: return Keyboard::B; + case XK_C: return Keyboard::C; + case XK_D: return Keyboard::D; + case XK_E: return Keyboard::E; + case XK_F: return Keyboard::F; + case XK_G: return Keyboard::G; + case XK_H: return Keyboard::H; + case XK_I: return Keyboard::I; + case XK_J: return Keyboard::J; + case XK_K: return Keyboard::K; + case XK_L: return Keyboard::L; + case XK_M: return Keyboard::M; + case XK_N: return Keyboard::N; + case XK_O: return Keyboard::O; + case XK_P: return Keyboard::P; + case XK_Q: return Keyboard::Q; + case XK_R: return Keyboard::R; + case XK_S: return Keyboard::S; + case XK_T: return Keyboard::T; + case XK_U: return Keyboard::U; + case XK_V: return Keyboard::V; + case XK_W: return Keyboard::W; + case XK_X: return Keyboard::X; + case XK_Y: return Keyboard::Y; + case XK_Z: return Keyboard::Z; - // Touches de fonction - case XK_F1: return Keyboard::F1; - case XK_F2: return Keyboard::F2; - case XK_F3: return Keyboard::F3; - case XK_F4: return Keyboard::F4; - case XK_F5: return Keyboard::F5; - case XK_F6: return Keyboard::F6; - case XK_F7: return Keyboard::F7; - case XK_F8: return Keyboard::F8; - case XK_F9: return Keyboard::F9; - case XK_F10: return Keyboard::F10; - case XK_F11: return Keyboard::F11; - case XK_F12: return Keyboard::F12; - case XK_F13: return Keyboard::F13; - case XK_F14: return Keyboard::F14; - case XK_F15: return Keyboard::F15; + // Touches de fonction + case XK_F1: return Keyboard::F1; + case XK_F2: return Keyboard::F2; + case XK_F3: return Keyboard::F3; + case XK_F4: return Keyboard::F4; + case XK_F5: return Keyboard::F5; + case XK_F6: return Keyboard::F6; + case XK_F7: return Keyboard::F7; + case XK_F8: return Keyboard::F8; + case XK_F9: return Keyboard::F9; + case XK_F10: return Keyboard::F10; + case XK_F11: return Keyboard::F11; + case XK_F12: return Keyboard::F12; + case XK_F13: return Keyboard::F13; + case XK_F14: return Keyboard::F14; + case XK_F15: return Keyboard::F15; - // Flèches directionnelles - case XK_Down: return Keyboard::Down; - case XK_Left: return Keyboard::Left; - case XK_Right: return Keyboard::Right; - case XK_Up: return Keyboard::Up; + // Flèches directionnelles + case XK_Down: return Keyboard::Down; + case XK_Left: return Keyboard::Left; + case XK_Right: return Keyboard::Right; + case XK_Up: return Keyboard::Up; - // Pavé numérique - case XK_KP_Add: return Keyboard::Add; - case XK_KP_Decimal: return Keyboard::Decimal; - case XK_KP_Delete: return Keyboard::Decimal; - case XK_KP_Divide: return Keyboard::Divide; - case XK_KP_Multiply: return Keyboard::Multiply; - case XK_KP_Insert: return Keyboard::Numpad0; - case XK_KP_End: return Keyboard::Numpad1; - case XK_KP_Down: return Keyboard::Numpad2; - case XK_KP_Page_Down: return Keyboard::Numpad3; - case XK_KP_Left: return Keyboard::Numpad4; - case XK_KP_Begin: return Keyboard::Numpad5; - case XK_KP_Right: return Keyboard::Numpad6; - case XK_KP_Home: return Keyboard::Numpad7; - case XK_KP_Up: return Keyboard::Numpad8; - case XK_KP_Page_Up: return Keyboard::Numpad9; - case XK_KP_Enter: return Keyboard::Return; - case XK_KP_Subtract: return Keyboard::Subtract; + // Pavé numérique + case XK_KP_Add: return Keyboard::Add; + case XK_KP_Decimal: return Keyboard::Decimal; + case XK_KP_Delete: return Keyboard::Decimal; + case XK_KP_Divide: return Keyboard::Divide; + case XK_KP_Multiply: return Keyboard::Multiply; + case XK_KP_Insert: return Keyboard::Numpad0; + case XK_KP_End: return Keyboard::Numpad1; + case XK_KP_Down: return Keyboard::Numpad2; + case XK_KP_Page_Down: return Keyboard::Numpad3; + case XK_KP_Left: return Keyboard::Numpad4; + case XK_KP_Begin: return Keyboard::Numpad5; + case XK_KP_Right: return Keyboard::Numpad6; + case XK_KP_Home: return Keyboard::Numpad7; + case XK_KP_Up: return Keyboard::Numpad8; + case XK_KP_Page_Up: return Keyboard::Numpad9; + case XK_KP_Enter: return Keyboard::NumpadReturn; + case XK_KP_Subtract: return Keyboard::Subtract; - // Divers - case XK_backslash: return Keyboard::Backslash; - case XK_BackSpace: return Keyboard::Backspace; - case XK_Clear: return Keyboard::Clear; - case XK_comma: return Keyboard::Comma; - case XK_minus: return Keyboard::Dash; - case XK_Delete: return Keyboard::Delete; - case XK_End: return Keyboard::End; - case XK_equal: return Keyboard::Equal; - case XK_Escape: return Keyboard::Escape; - case XK_Home: return Keyboard::Home; - case XK_Insert: return Keyboard::Insert; - case XK_Alt_L: return Keyboard::LAlt; - case XK_bracketleft: return Keyboard::LBracket; - case XK_Control_L: return Keyboard::LControl; - case XK_Shift_L: return Keyboard::LShift; - case XK_Super_L: return Keyboard::LSystem; - case XK_0: return Keyboard::Num0; - case XK_1: return Keyboard::Num1; - case XK_2: return Keyboard::Num2; - case XK_3: return Keyboard::Num3; - case XK_4: return Keyboard::Num4; - case XK_5: return Keyboard::Num5; - case XK_6: return Keyboard::Num6; - case XK_7: return Keyboard::Num7; - case XK_8: return Keyboard::Num8; - case XK_9: return Keyboard::Num9; - case XK_Page_Down: return Keyboard::PageDown; - case XK_Page_Up: return Keyboard::PageUp; - case XK_Pause: return Keyboard::Pause; - case XK_period: return Keyboard::Period; - case XK_Print: return Keyboard::Print; - case XK_Sys_Req: return Keyboard::PrintScreen; - case XK_quotedbl: return Keyboard::Quote; - case XK_Alt_R: return Keyboard::RAlt; - case XK_bracketright: return Keyboard::RBracket; - case XK_Control_R: return Keyboard::RControl; - case XK_Return: return Keyboard::Return; - case XK_Shift_R: return Keyboard::RShift; - case XK_Super_R: return Keyboard::RSystem; - case XK_semicolon: return Keyboard::Semicolon; - case XK_slash: return Keyboard::Slash; - case XK_space: return Keyboard::Space; - case XK_Tab: return Keyboard::Tab; - case XK_grave: return Keyboard::Tilde; + // Divers + case XK_backslash: return Keyboard::Backslash; + case XK_BackSpace: return Keyboard::Backspace; + case XK_Clear: return Keyboard::Clear; + case XK_comma: return Keyboard::Comma; + case XK_minus: return Keyboard::Dash; + case XK_Delete: return Keyboard::Delete; + case XK_End: return Keyboard::End; + case XK_equal: return Keyboard::Equal; + case XK_Escape: return Keyboard::Escape; + case XK_Home: return Keyboard::Home; + case XK_Insert: return Keyboard::Insert; + case XK_Alt_L: return Keyboard::LAlt; + case XK_bracketleft: return Keyboard::LBracket; + case XK_Control_L: return Keyboard::LControl; + case XK_Shift_L: return Keyboard::LShift; + case XK_Super_L: return Keyboard::LSystem; + case XK_0: return Keyboard::Num0; + case XK_1: return Keyboard::Num1; + case XK_2: return Keyboard::Num2; + case XK_3: return Keyboard::Num3; + case XK_4: return Keyboard::Num4; + case XK_5: return Keyboard::Num5; + case XK_6: return Keyboard::Num6; + case XK_7: return Keyboard::Num7; + case XK_8: return Keyboard::Num8; + case XK_9: return Keyboard::Num9; + case XK_Page_Down: return Keyboard::PageDown; + case XK_Page_Up: return Keyboard::PageUp; + case XK_Pause: return Keyboard::Pause; + case XK_period: return Keyboard::Period; + case XK_Print: return Keyboard::Print; + case XK_Sys_Req: return Keyboard::PrintScreen; + case XK_quotedbl: return Keyboard::Quote; + case XK_Alt_R: return Keyboard::RAlt; + case XK_bracketright: return Keyboard::RBracket; + case XK_Control_R: return Keyboard::RControl; + case XK_Return: return Keyboard::Return; + case XK_Shift_R: return Keyboard::RShift; + case XK_Super_R: return Keyboard::RSystem; + case XK_semicolon: return Keyboard::Semicolon; + case XK_slash: return Keyboard::Slash; + case XK_space: return Keyboard::Space; + case XK_Tab: return Keyboard::Tab; + case XK_grave: return Keyboard::Tilde; + case XK_Menu: return Keyboard::Menu; + case XK_less: return Keyboard::ISOBackslash102; - // Touches navigateur - case XF86XK_Back: return Keyboard::Browser_Back; - case XF86XK_Favorites: return Keyboard::Browser_Favorites; - case XF86XK_Forward: return Keyboard::Browser_Forward; - case XF86XK_HomePage: return Keyboard::Browser_Home; - case XF86XK_Refresh: return Keyboard::Browser_Refresh; - case XF86XK_Search: return Keyboard::Browser_Search; - case XF86XK_Stop: return Keyboard::Browser_Stop; + // Touches navigateur + case XF86XK_Back: return Keyboard::Browser_Back; + case XF86XK_Favorites: return Keyboard::Browser_Favorites; + case XF86XK_Forward: return Keyboard::Browser_Forward; + case XF86XK_HomePage: return Keyboard::Browser_Home; + case XF86XK_Refresh: return Keyboard::Browser_Refresh; + case XF86XK_Search: return Keyboard::Browser_Search; + case XF86XK_Stop: return Keyboard::Browser_Stop; - // Touches de contrôle - case XF86XK_AudioNext: return Keyboard::Media_Next; - case XF86XK_AudioPlay: return Keyboard::Media_Play; - case XF86XK_AudioPrev: return Keyboard::Media_Previous; - case XF86XK_AudioStop: return Keyboard::Media_Stop; + // Touches de contrôle + case XF86XK_AudioNext: return Keyboard::Media_Next; + case XF86XK_AudioPlay: return Keyboard::Media_Play; + case XF86XK_AudioPrev: return Keyboard::Media_Previous; + case XF86XK_AudioStop: return Keyboard::Media_Stop; - // Touches de contrôle du volume - case XF86XK_AudioLowerVolume: return Keyboard::Volume_Down; - case XF86XK_AudioMute: return Keyboard::Volume_Mute; - case XF86XK_AudioRaiseVolume: return Keyboard::Volume_Up; + // Touches de contrôle du volume + case XF86XK_AudioLowerVolume: return Keyboard::Volume_Down; + case XF86XK_AudioMute: return Keyboard::Volume_Mute; + case XF86XK_AudioRaiseVolume: return Keyboard::Volume_Up; - // Touches à verrouillage - case XK_Caps_Lock: return Keyboard::CapsLock; - case XK_Num_Lock: return Keyboard::NumLock; - case XK_Scroll_Lock: return Keyboard::ScrollLock; + // Touches à verrouillage + case XK_Caps_Lock: return Keyboard::CapsLock; + case XK_Num_Lock: return Keyboard::NumLock; + case XK_Scroll_Lock: return Keyboard::ScrollLock; - default: - return Keyboard::Undefined; + default: + return Keyboard::Undefined; } } @@ -945,15 +942,15 @@ namespace Nz }; if (!X11::CheckCookie( - connection, - xcb_icccm_set_wm_protocols( connection, - m_window, - X11::GetAtom("WM_PROTOCOLS"), - sizeof(protocols), - protocols - )) - ) + xcb_icccm_set_wm_protocols( + connection, + m_window, + X11::GetAtom("WM_PROTOCOLS"), + sizeof(protocols), + protocols + )) + ) NazaraError("Failed to get atom for deleting a window"); // Flush the commands queue @@ -964,57 +961,57 @@ namespace Nz { switch (keysym) { - case XK_KP_Space: - return ' '; - case XK_BackSpace: - return '\b'; - case XK_Tab: - case XK_KP_Tab: - return '\t'; - case XK_Linefeed: - return '\n'; - case XK_Return: - return '\r'; - // Numpad - case XK_KP_Multiply: - return '*'; - case XK_KP_Add: - return '+'; - case XK_KP_Separator: - return ','; // In french, it's '.' - case XK_KP_Subtract: - return '-'; - case XK_KP_Decimal: - return '.'; // In french, it's ',' - case XK_KP_Divide: - return '/'; - case XK_KP_0: - return '0'; - case XK_KP_1: - return '1'; - case XK_KP_2: - return '2'; - case XK_KP_3: - return '3'; - case XK_KP_4: - return '4'; - case XK_KP_5: - return '5'; - case XK_KP_6: - return '6'; - case XK_KP_7: - return '7'; - case XK_KP_8: - return '8'; - case XK_KP_9: - return '9'; - case XK_KP_Enter: - return '\r'; - default: - if (xcb_is_modifier_key(keysym) == true) - return '\0'; - else - return keysym; + case XK_KP_Space: + return ' '; + case XK_BackSpace: + return '\b'; + case XK_Tab: + case XK_KP_Tab: + return '\t'; + case XK_Linefeed: + return '\n'; + case XK_Return: + return '\r'; + // Numpad + case XK_KP_Multiply: + return '*'; + case XK_KP_Add: + return '+'; + case XK_KP_Separator: + return ','; // In french, it's '.' + case XK_KP_Subtract: + return '-'; + case XK_KP_Decimal: + return '.'; // In french, it's ',' + case XK_KP_Divide: + return '/'; + case XK_KP_0: + return '0'; + case XK_KP_1: + return '1'; + case XK_KP_2: + return '2'; + case XK_KP_3: + return '3'; + case XK_KP_4: + return '4'; + case XK_KP_5: + return '5'; + case XK_KP_6: + return '6'; + case XK_KP_7: + return '7'; + case XK_KP_8: + return '8'; + case XK_KP_9: + return '9'; + case XK_KP_Enter: + return '\r'; + default: + if (xcb_is_modifier_key(keysym) == true) + return '\0'; + else + return keysym; } } @@ -1026,296 +1023,296 @@ namespace Nz // Convert the xcb event to a Event switch (windowEvent->response_type & ~0x80) { - // Destroy event - case XCB_DESTROY_NOTIFY: - { - // The window is about to be destroyed: we must cleanup resources - CleanUp(); - break; - } + // Destroy event + case XCB_DESTROY_NOTIFY: + { + // The window is about to be destroyed: we must cleanup resources + CleanUp(); + break; + } - // Gain focus event - case XCB_FOCUS_IN: - { - const uint32_t value_list[] = { eventMask }; - if (!X11::CheckCookie( + // Gain focus event + case XCB_FOCUS_IN: + { + const uint32_t value_list[] = { eventMask }; + if (!X11::CheckCookie( connection, xcb_change_window_attributes( connection, m_window, XCB_CW_EVENT_MASK, value_list - )) - ) - NazaraError("Failed to change event mask"); + )) + ) + NazaraError("Failed to change event mask"); - WindowEvent event; - event.type = Nz::WindowEventType_GainedFocus; - m_parent->PushEvent(event); + WindowEvent event; + event.type = Nz::WindowEventType_GainedFocus; + m_parent->PushEvent(event); - break; - } + break; + } - // Lost focus event - case XCB_FOCUS_OUT: - { - WindowEvent event; - event.type = Nz::WindowEventType_LostFocus; - m_parent->PushEvent(event); + // Lost focus event + case XCB_FOCUS_OUT: + { + WindowEvent event; + event.type = Nz::WindowEventType_LostFocus; + m_parent->PushEvent(event); - const uint32_t values[] = { XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_FOCUS_CHANGE }; - if (!X11::CheckCookie( + const uint32_t values[] = { XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_FOCUS_CHANGE }; + if (!X11::CheckCookie( connection, xcb_change_window_attributes( connection, m_window, XCB_CW_EVENT_MASK, values - )) - ) - NazaraError("Failed to change event mask"); - + )) + ) + NazaraError("Failed to change event mask"); + + break; + } + + // Resize event + case XCB_CONFIGURE_NOTIFY: + { + xcb_configure_notify_event_t* configureNotifyEvent = (xcb_configure_notify_event_t*)windowEvent; + // ConfigureNotify can be triggered for other reasons, check if the size has actually changed + if ((configureNotifyEvent->width != m_size_hints.width) || (configureNotifyEvent->height != m_size_hints.width)) + { + WindowEvent event; + event.type = Nz::WindowEventType_Resized; + event.size.width = configureNotifyEvent->width; + event.size.height = configureNotifyEvent->height; + m_parent->PushEvent(event); + + m_size_hints.width = configureNotifyEvent->width; + m_size_hints.height = configureNotifyEvent->height; + } + if ((configureNotifyEvent->x != m_size_hints.x) || (configureNotifyEvent->y != m_size_hints.y)) + { + WindowEvent event; + event.type = Nz::WindowEventType_Moved; + event.size.width = configureNotifyEvent->x; + event.size.height = configureNotifyEvent->y; + m_parent->PushEvent(event); + + m_size_hints.x = configureNotifyEvent->x; + m_size_hints.y = configureNotifyEvent->y; + } + break; + } + + // Close event + case XCB_CLIENT_MESSAGE: + { + xcb_client_message_event_t* clientMessageEvent = (xcb_client_message_event_t*)windowEvent; + + if (clientMessageEvent->type != X11::GetAtom("WM_PROTOCOLS")) break; + if (clientMessageEvent->data.data32[0] == X11::GetAtom("WM_DELETE_WINDOW")) + { + WindowEvent event; + event.type = Nz::WindowEventType_Quit; + m_parent->PushEvent(event); } - // Resize event - case XCB_CONFIGURE_NOTIFY: + break; + } + + // Key down event + case XCB_KEY_PRESS: + { + xcb_key_press_event_t* keyPressEvent = (xcb_key_press_event_t*)windowEvent; + + if (!m_keyRepeat && m_eventQueue.curr && m_eventQueue.next) { - xcb_configure_notify_event_t* configureNotifyEvent = (xcb_configure_notify_event_t*)windowEvent; - // ConfigureNotify can be triggered for other reasons, check if the size has actually changed - if ((configureNotifyEvent->width != m_size_hints.width) || (configureNotifyEvent->height != m_size_hints.width)) - { - WindowEvent event; - event.type = Nz::WindowEventType_Resized; - event.size.width = configureNotifyEvent->width; - event.size.height = configureNotifyEvent->height; - m_parent->PushEvent(event); + xcb_key_press_event_t* current = (xcb_key_release_event_t*)m_eventQueue.curr; + // keyPressEvent == next - m_size_hints.width = configureNotifyEvent->width; - m_size_hints.height = configureNotifyEvent->height; - } - if ((configureNotifyEvent->x != m_size_hints.x) || (configureNotifyEvent->y != m_size_hints.y)) - { - WindowEvent event; - event.type = Nz::WindowEventType_Moved; - event.size.width = configureNotifyEvent->x; - event.size.height = configureNotifyEvent->y; - m_parent->PushEvent(event); - - m_size_hints.x = configureNotifyEvent->x; - m_size_hints.y = configureNotifyEvent->y; - } - break; - } - - // Close event - case XCB_CLIENT_MESSAGE: - { - xcb_client_message_event_t* clientMessageEvent = (xcb_client_message_event_t*)windowEvent; - - if (clientMessageEvent->type != X11::GetAtom("WM_PROTOCOLS")) + if ((current->time == keyPressEvent->time) && (current->detail == keyPressEvent->detail)) break; - if (clientMessageEvent->data.data32[0] == X11::GetAtom("WM_DELETE_WINDOW")) - { - WindowEvent event; - event.type = Nz::WindowEventType_Quit; - m_parent->PushEvent(event); - } - - break; } - // Key down event - case XCB_KEY_PRESS: + auto keysym = ConvertKeyCodeToKeySym(keyPressEvent->detail, keyPressEvent->state); + + WindowEvent event; + event.type = Nz::WindowEventType_KeyPressed; + event.key.code = ConvertVirtualKey(keysym); + event.key.alt = keyPressEvent->state & XCB_MOD_MASK_1; + event.key.control = keyPressEvent->state & XCB_MOD_MASK_CONTROL; + event.key.shift = keyPressEvent->state & XCB_MOD_MASK_SHIFT; + event.key.system = keyPressEvent->state & XCB_MOD_MASK_4; + m_parent->PushEvent(event); + + char32_t codePoint = GetRepresentation(keysym); + + // if (std::isprint(codePoint)) Is not working ? + handle combining ? { - xcb_key_press_event_t* keyPressEvent = (xcb_key_press_event_t*)windowEvent; - - if (!m_keyRepeat && m_eventQueue.curr && m_eventQueue.next) - { - xcb_key_press_event_t* current = (xcb_key_release_event_t*)m_eventQueue.curr; - // keyPressEvent == next - - if ((current->time == keyPressEvent->time) && (current->detail == keyPressEvent->detail)) - break; - } - - auto keysym = ConvertKeyCodeToKeySym(keyPressEvent->detail, keyPressEvent->state); - - WindowEvent event; - event.type = Nz::WindowEventType_KeyPressed; - event.key.code = ConvertVirtualKey(keysym); - event.key.alt = keyPressEvent->state & XCB_MOD_MASK_1; - event.key.control = keyPressEvent->state & XCB_MOD_MASK_CONTROL; - event.key.shift = keyPressEvent->state & XCB_MOD_MASK_SHIFT; - event.key.system = keyPressEvent->state & XCB_MOD_MASK_4; + event.type = Nz::WindowEventType_TextEntered; + event.text.character = codePoint; + event.text.repeated = false; m_parent->PushEvent(event); - - char32_t codePoint = GetRepresentation(keysym); - - // if (std::isprint(codePoint)) Is not working ? + handle combining ? - { - event.type = Nz::WindowEventType_TextEntered; - event.text.character = codePoint; - event.text.repeated = false; - m_parent->PushEvent(event); - } - - break; } - // Key up event - case XCB_KEY_RELEASE: + break; + } + + // Key up event + case XCB_KEY_RELEASE: + { + xcb_key_release_event_t* keyReleaseEvent = (xcb_key_release_event_t*)windowEvent; + + if (!m_keyRepeat && m_eventQueue.curr && m_eventQueue.next) { - xcb_key_release_event_t* keyReleaseEvent = (xcb_key_release_event_t*)windowEvent; + // keyReleaseEvent == current + xcb_key_press_event_t* next = (xcb_key_press_event_t*)m_eventQueue.next; - if (!m_keyRepeat && m_eventQueue.curr && m_eventQueue.next) - { - // keyReleaseEvent == current - xcb_key_press_event_t* next = (xcb_key_press_event_t*)m_eventQueue.next; - - if ((keyReleaseEvent->time == next->time) && (keyReleaseEvent->detail == next->detail)) - break; - } - - auto keysym = ConvertKeyCodeToKeySym(keyReleaseEvent->detail, keyReleaseEvent->state); - - WindowEvent event; - event.type = Nz::WindowEventType_KeyReleased; - event.key.code = ConvertVirtualKey(keysym); - event.key.alt = keyReleaseEvent->state & XCB_MOD_MASK_1; - event.key.control = keyReleaseEvent->state & XCB_MOD_MASK_CONTROL; - event.key.shift = keyReleaseEvent->state & XCB_MOD_MASK_SHIFT; - event.key.system = keyReleaseEvent->state & XCB_MOD_MASK_4; - m_parent->PushEvent(event); - - break; + if ((keyReleaseEvent->time == next->time) && (keyReleaseEvent->detail == next->detail)) + break; } - // Mouse button pressed - case XCB_BUTTON_PRESS: + auto keysym = ConvertKeyCodeToKeySym(keyReleaseEvent->detail, keyReleaseEvent->state); + + WindowEvent event; + event.type = Nz::WindowEventType_KeyReleased; + event.key.code = ConvertVirtualKey(keysym); + event.key.alt = keyReleaseEvent->state & XCB_MOD_MASK_1; + event.key.control = keyReleaseEvent->state & XCB_MOD_MASK_CONTROL; + event.key.shift = keyReleaseEvent->state & XCB_MOD_MASK_SHIFT; + event.key.system = keyReleaseEvent->state & XCB_MOD_MASK_4; + m_parent->PushEvent(event); + + break; + } + + // Mouse button pressed + case XCB_BUTTON_PRESS: + { + xcb_button_press_event_t* buttonPressEvent = (xcb_button_press_event_t*)windowEvent; + + WindowEvent event; + event.type = Nz::WindowEventType_MouseButtonPressed; + event.mouseButton.x = buttonPressEvent->event_x; + event.mouseButton.y = buttonPressEvent->event_y; + + if (buttonPressEvent->detail == XCB_BUTTON_INDEX_1) + event.mouseButton.button = Mouse::Left; + else if (buttonPressEvent->detail == XCB_BUTTON_INDEX_2) + event.mouseButton.button = Mouse::Middle; + else if (buttonPressEvent->detail == XCB_BUTTON_INDEX_3) + event.mouseButton.button = Mouse::Right; + else if (buttonPressEvent->detail == XCB_BUTTON_INDEX_4) + event.mouseButton.button = Mouse::XButton1; + else if (buttonPressEvent->detail == XCB_BUTTON_INDEX_5) + event.mouseButton.button = Mouse::XButton2; + else + NazaraWarning("Mouse button not handled"); + + m_parent->PushEvent(event); + + break; + } + + // Mouse button released + case XCB_BUTTON_RELEASE: + { + xcb_button_release_event_t* buttonReleaseEvent = (xcb_button_release_event_t*)windowEvent; + + WindowEvent event; + + switch (buttonReleaseEvent->detail) { - xcb_button_press_event_t* buttonPressEvent = (xcb_button_press_event_t*)windowEvent; + case XCB_BUTTON_INDEX_4: + case XCB_BUTTON_INDEX_5: + { + event.type = Nz::WindowEventType_MouseWheelMoved; + event.mouseWheel.delta = (buttonReleaseEvent->detail == XCB_BUTTON_INDEX_4) ? 1 : -1; + break; + } + default: + { + event.type = Nz::WindowEventType_MouseButtonReleased; + event.mouseButton.x = buttonReleaseEvent->event_x; + event.mouseButton.y = buttonReleaseEvent->event_y; - WindowEvent event; - event.type = Nz::WindowEventType_MouseButtonPressed; - event.mouseButton.x = buttonPressEvent->event_x; - event.mouseButton.y = buttonPressEvent->event_y; - - if (buttonPressEvent->detail == XCB_BUTTON_INDEX_1) + if (buttonReleaseEvent->detail == XCB_BUTTON_INDEX_1) event.mouseButton.button = Mouse::Left; - else if (buttonPressEvent->detail == XCB_BUTTON_INDEX_2) + else if (buttonReleaseEvent->detail == XCB_BUTTON_INDEX_2) event.mouseButton.button = Mouse::Middle; - else if (buttonPressEvent->detail == XCB_BUTTON_INDEX_3) + else if (buttonReleaseEvent->detail == XCB_BUTTON_INDEX_3) event.mouseButton.button = Mouse::Right; - else if (buttonPressEvent->detail == XCB_BUTTON_INDEX_4) + else if (buttonReleaseEvent->detail == XCB_BUTTON_INDEX_4) event.mouseButton.button = Mouse::XButton1; - else if (buttonPressEvent->detail == XCB_BUTTON_INDEX_5) + else if (buttonReleaseEvent->detail == XCB_BUTTON_INDEX_5) event.mouseButton.button = Mouse::XButton2; else NazaraWarning("Mouse button not handled"); - - m_parent->PushEvent(event); - - break; + } } - // Mouse button released - case XCB_BUTTON_RELEASE: - { - xcb_button_release_event_t* buttonReleaseEvent = (xcb_button_release_event_t*)windowEvent; + m_parent->PushEvent(event); - WindowEvent event; + break; + } - switch (buttonReleaseEvent->detail) - { - case XCB_BUTTON_INDEX_4: - case XCB_BUTTON_INDEX_5: - { - event.type = Nz::WindowEventType_MouseWheelMoved; - event.mouseWheel.delta = (buttonReleaseEvent->detail == XCB_BUTTON_INDEX_4) ? 1 : -1; - break; - } - default: - { - event.type = Nz::WindowEventType_MouseButtonReleased; - event.mouseButton.x = buttonReleaseEvent->event_x; - event.mouseButton.y = buttonReleaseEvent->event_y; - - if (buttonReleaseEvent->detail == XCB_BUTTON_INDEX_1) - event.mouseButton.button = Mouse::Left; - else if (buttonReleaseEvent->detail == XCB_BUTTON_INDEX_2) - event.mouseButton.button = Mouse::Middle; - else if (buttonReleaseEvent->detail == XCB_BUTTON_INDEX_3) - event.mouseButton.button = Mouse::Right; - else if (buttonReleaseEvent->detail == XCB_BUTTON_INDEX_4) - event.mouseButton.button = Mouse::XButton1; - else if (buttonReleaseEvent->detail == XCB_BUTTON_INDEX_5) - event.mouseButton.button = Mouse::XButton2; - else - NazaraWarning("Mouse button not handled"); - } - } - - m_parent->PushEvent(event); + // Mouse moved + case XCB_MOTION_NOTIFY: + { + xcb_motion_notify_event_t* motionNotifyEvent = (xcb_motion_notify_event_t*)windowEvent; + // We use the sequence to determine whether the motion is linked to a Mouse::SetPosition + if (m_mousePos.x == motionNotifyEvent->event_x && m_mousePos.y == motionNotifyEvent->event_y) break; - } - // Mouse moved - case XCB_MOTION_NOTIFY: - { - xcb_motion_notify_event_t* motionNotifyEvent = (xcb_motion_notify_event_t*)windowEvent; + WindowEvent event; + event.type = Nz::WindowEventType_MouseMoved; + event.mouseMove.deltaX = motionNotifyEvent->event_x - m_mousePos.x; + event.mouseMove.deltaY = motionNotifyEvent->event_y - m_mousePos.y; + event.mouseMove.x = motionNotifyEvent->event_x; + event.mouseMove.y = motionNotifyEvent->event_y; - // We use the sequence to determine whether the motion is linked to a Mouse::SetPosition - if (m_mousePos.x == motionNotifyEvent->event_x && m_mousePos.y == motionNotifyEvent->event_y) - break; + m_mousePos.x = motionNotifyEvent->event_x; + m_mousePos.y = motionNotifyEvent->event_y; - WindowEvent event; - event.type = Nz::WindowEventType_MouseMoved; - event.mouseMove.deltaX = motionNotifyEvent->event_x - m_mousePos.x; - event.mouseMove.deltaY = motionNotifyEvent->event_y - m_mousePos.y; - event.mouseMove.x = motionNotifyEvent->event_x; - event.mouseMove.y = motionNotifyEvent->event_y; + m_parent->PushEvent(event); - m_mousePos.x = motionNotifyEvent->event_x; - m_mousePos.y = motionNotifyEvent->event_y; + break; + } - m_parent->PushEvent(event); + // Mouse entered + case XCB_ENTER_NOTIFY: + { + WindowEvent event; + event.type = Nz::WindowEventType_MouseEntered; + m_parent->PushEvent(event); - break; - } + break; + } - // Mouse entered - case XCB_ENTER_NOTIFY: - { - WindowEvent event; - event.type = Nz::WindowEventType_MouseEntered; - m_parent->PushEvent(event); + // Mouse left + case XCB_LEAVE_NOTIFY: + { + WindowEvent event; + event.type = Nz::WindowEventType_MouseLeft; + m_parent->PushEvent(event); - break; - } + break; + } - // Mouse left - case XCB_LEAVE_NOTIFY: - { - WindowEvent event; - event.type = Nz::WindowEventType_MouseLeft; - m_parent->PushEvent(event); + // Parent window changed + case XCB_REPARENT_NOTIFY: + { + // Catch reparent events to properly apply fullscreen on + // some "strange" window managers (like Awesome) which + // seem to make use of temporary parents during mapping + if (m_style & WindowStyle_Fullscreen) + SwitchToFullscreen(); - break; - } - - // Parent window changed - case XCB_REPARENT_NOTIFY: - { - // Catch reparent events to properly apply fullscreen on - // some "strange" window managers (like Awesome) which - // seem to make use of temporary parents during mapping - if (m_style & WindowStyle_Fullscreen) - SwitchToFullscreen(); - - break; - } + break; + } } } @@ -1328,18 +1325,18 @@ namespace Nz // Reset the video mode ScopedXCB setScreenConfig(xcb_randr_set_screen_config_reply( - connection, - xcb_randr_set_screen_config( - connection, - m_oldVideoMode.root, - XCB_CURRENT_TIME, - m_oldVideoMode.config_timestamp, - m_oldVideoMode.sizeID, - m_oldVideoMode.rotation, - m_oldVideoMode.rate - ), - &error - )); + connection, + xcb_randr_set_screen_config( + connection, + m_oldVideoMode.root, + XCB_CURRENT_TIME, + m_oldVideoMode.config_timestamp, + m_oldVideoMode.sizeID, + m_oldVideoMode.rotation, + m_oldVideoMode.rate + ), + &error + )); if (error) NazaraError("Failed to reset old screen configuration"); @@ -1355,15 +1352,15 @@ namespace Nz const char MOTIF_WM_HINTS[] = "_MOTIF_WM_HINTS"; ScopedXCB hintsAtomReply(xcb_intern_atom_reply( - connection, - xcb_intern_atom( - connection, - 0, - sizeof(MOTIF_WM_HINTS) - 1, - MOTIF_WM_HINTS - ), - &error - )); + connection, + xcb_intern_atom( + connection, + 0, + sizeof(MOTIF_WM_HINTS) - 1, + MOTIF_WM_HINTS + ), + &error + )); if (!error && hintsAtomReply) { @@ -1390,7 +1387,7 @@ namespace Nz uint32_t flags; uint32_t functions; uint32_t decorations; - int32_t inputMode; + int32_t inputMode; uint32_t state; }; @@ -1418,18 +1415,18 @@ namespace Nz } ScopedXCB propertyError(xcb_request_check( - connection, - xcb_change_property_checked( - connection, - XCB_PROP_MODE_REPLACE, - m_window, - hintsAtomReply->atom, - hintsAtomReply->atom, - 32, - 5, - &hints - ) - )); + connection, + xcb_change_property_checked( + connection, + XCB_PROP_MODE_REPLACE, + m_window, + hintsAtomReply->atom, + hintsAtomReply->atom, + 32, + 5, + &hints + ) + )); if (propertyError) NazaraError("xcb_change_property failed, could not set window hints"); @@ -1458,14 +1455,14 @@ namespace Nz // Load RandR and check its version ScopedXCB randrVersion(xcb_randr_query_version_reply( - connection, - xcb_randr_query_version( - connection, - 1, - 1 - ), - &error - )); + connection, + xcb_randr_query_version( + connection, + 1, + 1 + ), + &error + )); if (error) { @@ -1475,13 +1472,13 @@ namespace Nz // Get the current configuration ScopedXCB config(xcb_randr_get_screen_info_reply( - connection, - xcb_randr_get_screen_info( - connection, - m_screen->root - ), - &error - )); + connection, + xcb_randr_get_screen_info( + connection, + m_screen->root + ), + &error + )); if (error || !config) { @@ -1506,26 +1503,26 @@ namespace Nz for (int i = 0; i < config->nSizes; ++i) { if (config->rotation == XCB_RANDR_ROTATION_ROTATE_90 || - config->rotation == XCB_RANDR_ROTATION_ROTATE_270) + config->rotation == XCB_RANDR_ROTATION_ROTATE_270) std::swap(sizes[i].height, sizes[i].width); if ((sizes[i].width == static_cast(mode.width)) && - (sizes[i].height == static_cast(mode.height))) + (sizes[i].height == static_cast(mode.height))) { // Switch to fullscreen mode ScopedXCB setScreenConfig(xcb_randr_set_screen_config_reply( - connection, - xcb_randr_set_screen_config( - connection, - config->root, - XCB_CURRENT_TIME, - config->config_timestamp, - i, - config->rotation, - config->rate - ), - &error - )); + connection, + xcb_randr_set_screen_config( + connection, + config->root, + XCB_CURRENT_TIME, + config->config_timestamp, + i, + config->rotation, + config->rate + ), + &error + )); if (error) NazaraError("Failed to set new screen configuration"); @@ -1546,14 +1543,14 @@ namespace Nz ScopedXCBEWMHConnection ewmhConnection(connection); if (!X11::CheckCookie( - connection, - xcb_ewmh_set_wm_state( - ewmhConnection, - m_window, - 1, - &ewmhConnection->_NET_WM_STATE_FULLSCREEN - )) - ) + connection, + xcb_ewmh_set_wm_state( + ewmhConnection, + m_window, + 1, + &ewmhConnection->_NET_WM_STATE_FULLSCREEN + )) + ) NazaraError("Failed to switch to fullscreen"); } @@ -1572,7 +1569,7 @@ namespace Nz connection, m_window, &m_size_hints - )); + )); } void WindowImpl::WindowThread(WindowImpl* window, Mutex* mutex, ConditionVariable* condition) diff --git a/src/Nazara/Renderer/Context.cpp b/src/Nazara/Renderer/Context.cpp index 90a17122d..0efb6ec61 100644 --- a/src/Nazara/Renderer/Context.cpp +++ b/src/Nazara/Renderer/Context.cpp @@ -12,7 +12,10 @@ #include #include -#if defined(NAZARA_PLATFORM_WINDOWS) +#if defined(NAZARA_PLATFORM_SDL2) + #include + #define CALLBACK +#elif defined(NAZARA_PLATFORM_WINDOWS) #include #elif defined(NAZARA_PLATFORM_GLX) #include diff --git a/src/Nazara/Renderer/OpenGL.cpp b/src/Nazara/Renderer/OpenGL.cpp index 1c6ac00dd..aea268456 100644 --- a/src/Nazara/Renderer/OpenGL.cpp +++ b/src/Nazara/Renderer/OpenGL.cpp @@ -2,21 +2,23 @@ // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include #include #include #include #include +#include #include #include -#if defined(NAZARA_PLATFORM_GLX) +#if defined(NAZARA_PLATFORM_SDL2) +#include +#elif defined(NAZARA_PLATFORM_GLX) #include #endif // NAZARA_PLATFORM_GLX +#include #include #include #include #include -#include namespace Nz { @@ -28,7 +30,9 @@ namespace Nz OpenGLFunc LoadEntry(const char* name, bool launchException = true) { - #if defined(NAZARA_PLATFORM_WINDOWS) + #if defined(NAZARA_PLATFORM_SDL2) + OpenGLFunc entry = reinterpret_cast(SDL_GL_GetProcAddress(name)); + #elif defined(NAZARA_PLATFORM_WINDOWS) OpenGLFunc entry = reinterpret_cast(wglGetProcAddress(name)); if (!entry) // wglGetProcAddress ne fonctionne pas sur les fonctions OpenGL <= 1.1 entry = reinterpret_cast(GetProcAddress(openGLlibrary, name)); @@ -51,7 +55,16 @@ namespace Nz bool LoadLibrary() { - #ifdef NAZARA_PLATFORM_WINDOWS + #if defined(NAZARA_PLATFORM_SDL2) + if (SDL_GL_LoadLibrary(nullptr) != 0) + { + NazaraError(SDL_GetError()); + + return false; + } + return true; + + #elif defined(NAZARA_PLATFORM_WINDOWS) openGLlibrary = ::LoadLibraryA("opengl32.dll"); return openGLlibrary != nullptr; @@ -62,7 +75,9 @@ namespace Nz void UnloadLibrary() { - #ifdef NAZARA_PLATFORM_WINDOWS + #if defined(NAZARA_PLATFORM_SDL2) + SDL_GL_UnloadLibrary(); + #elif defined(NAZARA_PLATFORM_WINDOWS) FreeLibrary(openGLlibrary); #endif } @@ -75,7 +90,7 @@ namespace Nz struct ContextStates { - std::vector> garbage; // Les ressources à supprimer dès que possible + std::vector > garbage; // Les ressources à supprimer dès que possible GLuint buffersBinding[BufferType_Max + 1] = {0}; GLuint currentProgram = 0; GLuint samplers[32] = {0}; // 32 est pour l'instant la plus haute limite (GL_TEXTURE31) @@ -158,15 +173,13 @@ namespace Nz // Les fonctions de blend n'a aucun intérêt sans blending if (states.blending) - { if (currentRenderStates.dstBlend != states.dstBlend || - currentRenderStates.srcBlend != states.srcBlend) + currentRenderStates.srcBlend != states.srcBlend) { glBlendFunc(BlendFunc[states.srcBlend], BlendFunc[states.dstBlend]); currentRenderStates.dstBlend = states.dstBlend; currentRenderStates.srcBlend = states.srcBlend; } - } if (states.depthBuffer) { @@ -187,13 +200,11 @@ namespace Nz // Inutile de changer le mode de face culling s'il n'est pas actif if (states.faceCulling) - { if (currentRenderStates.cullingSide != states.cullingSide) { glCullFace(FaceSide[states.cullingSide]); currentRenderStates.cullingSide = states.cullingSide; } - } if (currentRenderStates.faceFilling != states.faceFilling) { @@ -205,8 +216,8 @@ namespace Nz if (states.stencilTest) { if (currentRenderStates.stencilCompare.back != states.stencilCompare.back || - currentRenderStates.stencilReference.back != states.stencilReference.back || - currentRenderStates.stencilWriteMask.back != states.stencilWriteMask.back) + currentRenderStates.stencilReference.back != states.stencilReference.back || + currentRenderStates.stencilWriteMask.back != states.stencilWriteMask.back) { glStencilFuncSeparate(GL_BACK, RendererComparison[states.stencilCompare.back], states.stencilReference.back, states.stencilWriteMask.back); currentRenderStates.stencilCompare.back = states.stencilCompare.back; @@ -215,8 +226,8 @@ namespace Nz } if (currentRenderStates.stencilDepthFail.back != states.stencilDepthFail.back || - currentRenderStates.stencilFail.back != states.stencilFail.back || - currentRenderStates.stencilPass.back != states.stencilPass.back) + currentRenderStates.stencilFail.back != states.stencilFail.back || + currentRenderStates.stencilPass.back != states.stencilPass.back) { glStencilOpSeparate(GL_BACK, StencilOperation[states.stencilFail.back], StencilOperation[states.stencilDepthFail.back], StencilOperation[states.stencilPass.back]); currentRenderStates.stencilDepthFail.back = states.stencilDepthFail.back; @@ -225,8 +236,8 @@ namespace Nz } if (currentRenderStates.stencilCompare.front != states.stencilCompare.front || - currentRenderStates.stencilReference.front != states.stencilReference.front || - currentRenderStates.stencilWriteMask.front != states.stencilWriteMask.front) + currentRenderStates.stencilReference.front != states.stencilReference.front || + currentRenderStates.stencilWriteMask.front != states.stencilWriteMask.front) { glStencilFuncSeparate(GL_FRONT, RendererComparison[states.stencilCompare.front], states.stencilReference.front, states.stencilWriteMask.front); currentRenderStates.stencilCompare.front = states.stencilCompare.front; @@ -235,8 +246,8 @@ namespace Nz } if (currentRenderStates.stencilDepthFail.front != states.stencilDepthFail.front || - currentRenderStates.stencilFail.front != states.stencilFail.front || - currentRenderStates.stencilPass.front != states.stencilPass.front) + currentRenderStates.stencilFail.front != states.stencilFail.front || + currentRenderStates.stencilPass.front != states.stencilPass.front) { glStencilOpSeparate(GL_FRONT, StencilOperation[states.stencilFail.front], StencilOperation[states.stencilDepthFail.front], StencilOperation[states.stencilPass.front]); currentRenderStates.stencilDepthFail.front = states.stencilDepthFail.front; @@ -731,7 +742,10 @@ namespace Nz if (s_initialized) return true; - #if defined(NAZARA_PLATFORM_GLX) + + #if defined(NAZARA_PLATFORM_SDL2) + + #elif defined(NAZARA_PLATFORM_GLX) Initializer display; if (!display) { @@ -758,17 +772,17 @@ namespace Nz parameters.shared = false; /* - Note: Même le contexte de chargement nécessite quelques fonctions de base pour correctement s'initialiser - Pour cette raison, deux contextes sont créés, le premier sert à récupérer les fonctions permetttant - de créer le second avec les bons paramètres. + Note: Même le contexte de chargement nécessite quelques fonctions de base pour correctement s'initialiser + Pour cette raison, deux contextes sont créés, le premier sert à récupérer les fonctions permetttant + de créer le second avec les bons paramètres. - Non sérieusement si vous avez une meilleure idée, contactez-moi - */ + Non sérieusement si vous avez une meilleure idée, contactez-moi + */ /****************************Chargement OpenGL****************************/ ///FIXME: I'm really thinking this is a mistake and GLX has no need to be initialized differently (Lynix) - #if defined(NAZARA_PLATFORM_LINUX) + #if defined(NAZARA_PLATFORM_LINUX) && not defined(NAZARA_PLATFORM_SDL2) glXCreateContextAttribs = reinterpret_cast(LoadEntry("glXCreateContextAttribsARB", false)); #endif @@ -779,7 +793,7 @@ namespace Nz return false; } - #if defined(NAZARA_PLATFORM_WINDOWS) + #if defined(NAZARA_PLATFORM_WINDOWS) && not defined(NAZARA_PLATFORM_SDL2) wglCreateContextAttribs = reinterpret_cast(LoadEntry("wglCreateContextAttribsARB", false)); wglChoosePixelFormat = reinterpret_cast(LoadEntry("wglChoosePixelFormatARB", false)); if (!wglChoosePixelFormat) @@ -1031,7 +1045,8 @@ namespace Nz glInvalidateBufferData = reinterpret_cast(LoadEntry("glInvalidateBufferData", false)); glVertexAttribLPointer = reinterpret_cast(LoadEntry("glVertexAttribLPointer", false)); - #if defined(NAZARA_PLATFORM_WINDOWS) + #if defined(NAZARA_PLATFORM_SDL2) + #elif defined(NAZARA_PLATFORM_WINDOWS) wglGetExtensionsStringARB = reinterpret_cast(LoadEntry("wglGetExtensionsStringARB", false)); wglGetExtensionsStringEXT = reinterpret_cast(LoadEntry("wglGetExtensionsStringEXT", false)); wglSwapInterval = reinterpret_cast(LoadEntry("wglSwapIntervalEXT", false)); @@ -1898,7 +1913,7 @@ namespace Nz GLenum OpenGL::BufferTarget[] = { GL_ELEMENT_ARRAY_BUFFER, // BufferType_Index, - GL_ARRAY_BUFFER, // BufferType_Vertex + GL_ARRAY_BUFFER, // BufferType_Vertex }; static_assert(BufferType_Max + 1 == 2, "Buffer target array is incomplete"); @@ -1906,7 +1921,7 @@ namespace Nz GLenum OpenGL::BufferTargetBinding[] = { GL_ELEMENT_ARRAY_BUFFER_BINDING, // BufferType_Index, - GL_ARRAY_BUFFER_BINDING, // BufferType_Vertex + GL_ARRAY_BUFFER_BINDING, // BufferType_Vertex }; static_assert(BufferType_Max + 1 == 2, "Buffer target binding array is incomplete"); @@ -2033,9 +2048,9 @@ namespace Nz GLenum OpenGL::ShaderStage[] = { - GL_FRAGMENT_SHADER, // ShaderStage_Fragment - GL_GEOMETRY_SHADER, // ShaderStage_Geometry - GL_VERTEX_SHADER // ShaderStage_Vertex + GL_FRAGMENT_SHADER, // ShaderStage_Fragment + GL_GEOMETRY_SHADER, // ShaderStage_Geometry + GL_VERTEX_SHADER // ShaderStage_Vertex }; static_assert(ShaderStageType_Max + 1 == 3, "Shader stage array is incomplete"); @@ -2112,192 +2127,193 @@ namespace Nz static_assert(VertexComponent_Max + 1 == 16, "Attribute index array is incomplete"); -PFNGLACTIVETEXTUREPROC glActiveTexture = nullptr; -PFNGLATTACHSHADERPROC glAttachShader = nullptr; -PFNGLBEGINCONDITIONALRENDERPROC glBeginConditionalRender = nullptr; -PFNGLBEGINQUERYPROC glBeginQuery = nullptr; -PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation = nullptr; -PFNGLBINDBUFFERPROC glBindBuffer = nullptr; -PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer = nullptr; -PFNGLBINDFRAGDATALOCATIONPROC glBindFragDataLocation = nullptr; -PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer = nullptr; -PFNGLBINDSAMPLERPROC glBindSampler = nullptr; -PFNGLBINDTEXTUREPROC glBindTexture = nullptr; -PFNGLBINDVERTEXARRAYPROC glBindVertexArray = nullptr; -PFNGLBLENDFUNCPROC glBlendFunc = nullptr; -PFNGLBLENDFUNCSEPARATEPROC glBlendFuncSeparate = nullptr; -PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer = nullptr; -PFNGLBUFFERDATAPROC glBufferData = nullptr; -PFNGLBUFFERSUBDATAPROC glBufferSubData = nullptr; -PFNGLCLEARPROC glClear = nullptr; -PFNGLCLEARCOLORPROC glClearColor = nullptr; -PFNGLCLEARDEPTHPROC glClearDepth = nullptr; -PFNGLCLEARSTENCILPROC glClearStencil = nullptr; -PFNGLCREATEPROGRAMPROC glCreateProgram = nullptr; -PFNGLCREATESHADERPROC glCreateShader = nullptr; -PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus = nullptr; -PFNGLCOLORMASKPROC glColorMask = nullptr; -PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glCompressedTexSubImage1D = nullptr; -PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glCompressedTexSubImage2D = nullptr; -PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glCompressedTexSubImage3D = nullptr; -PFNGLCULLFACEPROC glCullFace = nullptr; -PFNGLCOMPILESHADERPROC glCompileShader = nullptr; -PFNGLCOPYTEXSUBIMAGE2DPROC glCopyTexSubImage2D = nullptr; -PFNGLDEBUGMESSAGECALLBACKPROC glDebugMessageCallback = nullptr; -PFNGLDEBUGMESSAGECONTROLPROC glDebugMessageControl = nullptr; -PFNGLDEBUGMESSAGEINSERTPROC glDebugMessageInsert = nullptr; -PFNGLDELETEBUFFERSPROC glDeleteBuffers = nullptr; -PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers = nullptr; -PFNGLDELETEPROGRAMPROC glDeleteProgram = nullptr; -PFNGLDELETEQUERIESPROC glDeleteQueries = nullptr; -PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers = nullptr; -PFNGLDELETESAMPLERSPROC glDeleteSamplers = nullptr; -PFNGLDELETESHADERPROC glDeleteShader = nullptr; -PFNGLDELETETEXTURESPROC glDeleteTextures = nullptr; -PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays = nullptr; -PFNGLDEPTHFUNCPROC glDepthFunc = nullptr; -PFNGLDEPTHMASKPROC glDepthMask = nullptr; -PFNGLDISABLEPROC glDisable = nullptr; -PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray = nullptr; -PFNGLDRAWARRAYSPROC glDrawArrays = nullptr; -PFNGLDRAWARRAYSINSTANCEDPROC glDrawArraysInstanced = nullptr; -PFNGLDRAWBUFFERPROC glDrawBuffer = nullptr; -PFNGLDRAWBUFFERSPROC glDrawBuffers = nullptr; -PFNGLDRAWELEMENTSPROC glDrawElements = nullptr; -PFNGLDRAWELEMENTSINSTANCEDPROC glDrawElementsInstanced = nullptr; -PFNGLDRAWTEXTURENVPROC glDrawTexture = nullptr; -PFNGLENABLEPROC glEnable = nullptr; -PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray = nullptr; -PFNGLENDCONDITIONALRENDERPROC glEndConditionalRender = nullptr; -PFNGLENDQUERYPROC glEndQuery = nullptr; -PFNGLFLUSHPROC glFlush = nullptr; -PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer = nullptr; -PFNGLFRAMEBUFFERTEXTUREPROC glFramebufferTexture = nullptr; -PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D = nullptr; -PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D = nullptr; -PFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D = nullptr; -PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer = nullptr; -PFNGLGENERATEMIPMAPPROC glGenerateMipmap = nullptr; -PFNGLGENBUFFERSPROC glGenBuffers = nullptr; -PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers = nullptr; -PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers = nullptr; -PFNGLGENQUERIESPROC glGenQueries = nullptr; -PFNGLGENSAMPLERSPROC glGenSamplers = nullptr; -PFNGLGENTEXTURESPROC glGenTextures = nullptr; -PFNGLGENVERTEXARRAYSPROC glGenVertexArrays = nullptr; -PFNGLGETACTIVEUNIFORMPROC glGetActiveUniform = nullptr; -PFNGLGETBOOLEANVPROC glGetBooleanv = nullptr; -PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv = nullptr; -PFNGLGETDEBUGMESSAGELOGPROC glGetDebugMessageLog = nullptr; -PFNGLGETERRORPROC glGetError = nullptr; -PFNGLGETFLOATVPROC glGetFloatv = nullptr; -PFNGLGETINTEGERVPROC glGetIntegerv = nullptr; -PFNGLGETPROGRAMBINARYPROC glGetProgramBinary = nullptr; -PFNGLGETPROGRAMIVPROC glGetProgramiv = nullptr; -PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog = nullptr; -PFNGLGETQUERYIVPROC glGetQueryiv = nullptr; -PFNGLGETQUERYOBJECTIVPROC glGetQueryObjectiv = nullptr; -PFNGLGETQUERYOBJECTUIVPROC glGetQueryObjectuiv = nullptr; -PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog = nullptr; -PFNGLGETSHADERIVPROC glGetShaderiv = nullptr; -PFNGLGETSHADERSOURCEPROC glGetShaderSource = nullptr; -PFNGLGETSTRINGPROC glGetString = nullptr; -PFNGLGETSTRINGIPROC glGetStringi = nullptr; -PFNGLGETTEXIMAGEPROC glGetTexImage = nullptr; -PFNGLGETTEXLEVELPARAMETERFVPROC glGetTexLevelParameterfv = nullptr; -PFNGLGETTEXLEVELPARAMETERIVPROC glGetTexLevelParameteriv = nullptr; -PFNGLGETTEXPARAMETERFVPROC glGetTexParameterfv = nullptr; -PFNGLGETTEXPARAMETERIVPROC glGetTexParameteriv = nullptr; -PFNGLGETUNIFORMFVPROC glGetUniformfv = nullptr; -PFNGLGETUNIFORMIVPROC glGetUniformiv = nullptr; -PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation = nullptr; -PFNGLINVALIDATEBUFFERDATAPROC glInvalidateBufferData = nullptr; -PFNGLISENABLEDPROC glIsEnabled = nullptr; -PFNGLLINEWIDTHPROC glLineWidth = nullptr; -PFNGLLINKPROGRAMPROC glLinkProgram = nullptr; -PFNGLMAPBUFFERPROC glMapBuffer = nullptr; -PFNGLMAPBUFFERRANGEPROC glMapBufferRange = nullptr; -PFNGLPIXELSTOREIPROC glPixelStorei = nullptr; -PFNGLPOINTSIZEPROC glPointSize = nullptr; -PFNGLPOLYGONMODEPROC glPolygonMode = nullptr; -PFNGLPROGRAMBINARYPROC glProgramBinary = nullptr; -PFNGLPROGRAMPARAMETERIPROC glProgramParameteri = nullptr; -PFNGLPROGRAMUNIFORM1DPROC glProgramUniform1d = nullptr; -PFNGLPROGRAMUNIFORM1FPROC glProgramUniform1f = nullptr; -PFNGLPROGRAMUNIFORM1IPROC glProgramUniform1i = nullptr; -PFNGLPROGRAMUNIFORM1DVPROC glProgramUniform1dv = nullptr; -PFNGLPROGRAMUNIFORM1FVPROC glProgramUniform1fv = nullptr; -PFNGLPROGRAMUNIFORM1IVPROC glProgramUniform1iv = nullptr; -PFNGLPROGRAMUNIFORM2DVPROC glProgramUniform2dv = nullptr; -PFNGLPROGRAMUNIFORM2FVPROC glProgramUniform2fv = nullptr; -PFNGLPROGRAMUNIFORM2IVPROC glProgramUniform2iv = nullptr; -PFNGLPROGRAMUNIFORM3DVPROC glProgramUniform3dv = nullptr; -PFNGLPROGRAMUNIFORM3FVPROC glProgramUniform3fv = nullptr; -PFNGLPROGRAMUNIFORM3IVPROC glProgramUniform3iv = nullptr; -PFNGLPROGRAMUNIFORM4DVPROC glProgramUniform4dv = nullptr; -PFNGLPROGRAMUNIFORM4FVPROC glProgramUniform4fv = nullptr; -PFNGLPROGRAMUNIFORM4IVPROC glProgramUniform4iv = nullptr; -PFNGLPROGRAMUNIFORMMATRIX4DVPROC glProgramUniformMatrix4dv = nullptr; -PFNGLPROGRAMUNIFORMMATRIX4FVPROC glProgramUniformMatrix4fv = nullptr; -PFNGLREADPIXELSPROC glReadPixels = nullptr; -PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage = nullptr; -PFNGLSAMPLERPARAMETERFPROC glSamplerParameterf = nullptr; -PFNGLSAMPLERPARAMETERIPROC glSamplerParameteri = nullptr; -PFNGLSCISSORPROC glScissor = nullptr; -PFNGLSHADERSOURCEPROC glShaderSource = nullptr; -PFNGLSTENCILFUNCPROC glStencilFunc = nullptr; -PFNGLSTENCILFUNCSEPARATEPROC glStencilFuncSeparate = nullptr; -PFNGLSTENCILOPPROC glStencilOp = nullptr; -PFNGLSTENCILOPSEPARATEPROC glStencilOpSeparate = nullptr; -PFNGLTEXIMAGE1DPROC glTexImage1D = nullptr; -PFNGLTEXIMAGE2DPROC glTexImage2D = nullptr; -PFNGLTEXIMAGE3DPROC glTexImage3D = nullptr; -PFNGLTEXPARAMETERFPROC glTexParameterf = nullptr; -PFNGLTEXPARAMETERIPROC glTexParameteri = nullptr; -PFNGLTEXSTORAGE1DPROC glTexStorage1D = nullptr; -PFNGLTEXSTORAGE2DPROC glTexStorage2D = nullptr; -PFNGLTEXSTORAGE3DPROC glTexStorage3D = nullptr; -PFNGLTEXSUBIMAGE1DPROC glTexSubImage1D = nullptr; -PFNGLTEXSUBIMAGE2DPROC glTexSubImage2D = nullptr; -PFNGLTEXSUBIMAGE3DPROC glTexSubImage3D = nullptr; -PFNGLUNIFORM1DPROC glUniform1d = nullptr; -PFNGLUNIFORM1FPROC glUniform1f = nullptr; -PFNGLUNIFORM1IPROC glUniform1i = nullptr; -PFNGLUNIFORM1DVPROC glUniform1dv = nullptr; -PFNGLUNIFORM1FVPROC glUniform1fv = nullptr; -PFNGLUNIFORM1IVPROC glUniform1iv = nullptr; -PFNGLUNIFORM2DVPROC glUniform2dv = nullptr; -PFNGLUNIFORM2FVPROC glUniform2fv = nullptr; -PFNGLUNIFORM2IVPROC glUniform2iv = nullptr; -PFNGLUNIFORM3DVPROC glUniform3dv = nullptr; -PFNGLUNIFORM3FVPROC glUniform3fv = nullptr; -PFNGLUNIFORM3IVPROC glUniform3iv = nullptr; -PFNGLUNIFORM4DVPROC glUniform4dv = nullptr; -PFNGLUNIFORM4FVPROC glUniform4fv = nullptr; -PFNGLUNIFORM4IVPROC glUniform4iv = nullptr; -PFNGLUNIFORMMATRIX4DVPROC glUniformMatrix4dv = nullptr; -PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv = nullptr; -PFNGLUNMAPBUFFERPROC glUnmapBuffer = nullptr; -PFNGLUSEPROGRAMPROC glUseProgram = nullptr; -PFNGLVALIDATEPROGRAMPROC glValidateProgram = nullptr; -PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f = nullptr; -PFNGLVERTEXATTRIBDIVISORPROC glVertexAttribDivisor = nullptr; -PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer = nullptr; -PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer = nullptr; -PFNGLVERTEXATTRIBLPOINTERPROC glVertexAttribLPointer = nullptr; -PFNGLVIEWPORTPROC glViewport = nullptr; + PFNGLACTIVETEXTUREPROC glActiveTexture = nullptr; + PFNGLATTACHSHADERPROC glAttachShader = nullptr; + PFNGLBEGINCONDITIONALRENDERPROC glBeginConditionalRender = nullptr; + PFNGLBEGINQUERYPROC glBeginQuery = nullptr; + PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation = nullptr; + PFNGLBINDBUFFERPROC glBindBuffer = nullptr; + PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer = nullptr; + PFNGLBINDFRAGDATALOCATIONPROC glBindFragDataLocation = nullptr; + PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer = nullptr; + PFNGLBINDSAMPLERPROC glBindSampler = nullptr; + PFNGLBINDTEXTUREPROC glBindTexture = nullptr; + PFNGLBINDVERTEXARRAYPROC glBindVertexArray = nullptr; + PFNGLBLENDFUNCPROC glBlendFunc = nullptr; + PFNGLBLENDFUNCSEPARATEPROC glBlendFuncSeparate = nullptr; + PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer = nullptr; + PFNGLBUFFERDATAPROC glBufferData = nullptr; + PFNGLBUFFERSUBDATAPROC glBufferSubData = nullptr; + PFNGLCLEARPROC glClear = nullptr; + PFNGLCLEARCOLORPROC glClearColor = nullptr; + PFNGLCLEARDEPTHPROC glClearDepth = nullptr; + PFNGLCLEARSTENCILPROC glClearStencil = nullptr; + PFNGLCREATEPROGRAMPROC glCreateProgram = nullptr; + PFNGLCREATESHADERPROC glCreateShader = nullptr; + PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus = nullptr; + PFNGLCOLORMASKPROC glColorMask = nullptr; + PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glCompressedTexSubImage1D = nullptr; + PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glCompressedTexSubImage2D = nullptr; + PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glCompressedTexSubImage3D = nullptr; + PFNGLCULLFACEPROC glCullFace = nullptr; + PFNGLCOMPILESHADERPROC glCompileShader = nullptr; + PFNGLCOPYTEXSUBIMAGE2DPROC glCopyTexSubImage2D = nullptr; + PFNGLDEBUGMESSAGECALLBACKPROC glDebugMessageCallback = nullptr; + PFNGLDEBUGMESSAGECONTROLPROC glDebugMessageControl = nullptr; + PFNGLDEBUGMESSAGEINSERTPROC glDebugMessageInsert = nullptr; + PFNGLDELETEBUFFERSPROC glDeleteBuffers = nullptr; + PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers = nullptr; + PFNGLDELETEPROGRAMPROC glDeleteProgram = nullptr; + PFNGLDELETEQUERIESPROC glDeleteQueries = nullptr; + PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers = nullptr; + PFNGLDELETESAMPLERSPROC glDeleteSamplers = nullptr; + PFNGLDELETESHADERPROC glDeleteShader = nullptr; + PFNGLDELETETEXTURESPROC glDeleteTextures = nullptr; + PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays = nullptr; + PFNGLDEPTHFUNCPROC glDepthFunc = nullptr; + PFNGLDEPTHMASKPROC glDepthMask = nullptr; + PFNGLDISABLEPROC glDisable = nullptr; + PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray = nullptr; + PFNGLDRAWARRAYSPROC glDrawArrays = nullptr; + PFNGLDRAWARRAYSINSTANCEDPROC glDrawArraysInstanced = nullptr; + PFNGLDRAWBUFFERPROC glDrawBuffer = nullptr; + PFNGLDRAWBUFFERSPROC glDrawBuffers = nullptr; + PFNGLDRAWELEMENTSPROC glDrawElements = nullptr; + PFNGLDRAWELEMENTSINSTANCEDPROC glDrawElementsInstanced = nullptr; + PFNGLDRAWTEXTURENVPROC glDrawTexture = nullptr; + PFNGLENABLEPROC glEnable = nullptr; + PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray = nullptr; + PFNGLENDCONDITIONALRENDERPROC glEndConditionalRender = nullptr; + PFNGLENDQUERYPROC glEndQuery = nullptr; + PFNGLFLUSHPROC glFlush = nullptr; + PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer = nullptr; + PFNGLFRAMEBUFFERTEXTUREPROC glFramebufferTexture = nullptr; + PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D = nullptr; + PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D = nullptr; + PFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D = nullptr; + PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer = nullptr; + PFNGLGENERATEMIPMAPPROC glGenerateMipmap = nullptr; + PFNGLGENBUFFERSPROC glGenBuffers = nullptr; + PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers = nullptr; + PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers = nullptr; + PFNGLGENQUERIESPROC glGenQueries = nullptr; + PFNGLGENSAMPLERSPROC glGenSamplers = nullptr; + PFNGLGENTEXTURESPROC glGenTextures = nullptr; + PFNGLGENVERTEXARRAYSPROC glGenVertexArrays = nullptr; + PFNGLGETACTIVEUNIFORMPROC glGetActiveUniform = nullptr; + PFNGLGETBOOLEANVPROC glGetBooleanv = nullptr; + PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv = nullptr; + PFNGLGETDEBUGMESSAGELOGPROC glGetDebugMessageLog = nullptr; + PFNGLGETERRORPROC glGetError = nullptr; + PFNGLGETFLOATVPROC glGetFloatv = nullptr; + PFNGLGETINTEGERVPROC glGetIntegerv = nullptr; + PFNGLGETPROGRAMBINARYPROC glGetProgramBinary = nullptr; + PFNGLGETPROGRAMIVPROC glGetProgramiv = nullptr; + PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog = nullptr; + PFNGLGETQUERYIVPROC glGetQueryiv = nullptr; + PFNGLGETQUERYOBJECTIVPROC glGetQueryObjectiv = nullptr; + PFNGLGETQUERYOBJECTUIVPROC glGetQueryObjectuiv = nullptr; + PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog = nullptr; + PFNGLGETSHADERIVPROC glGetShaderiv = nullptr; + PFNGLGETSHADERSOURCEPROC glGetShaderSource = nullptr; + PFNGLGETSTRINGPROC glGetString = nullptr; + PFNGLGETSTRINGIPROC glGetStringi = nullptr; + PFNGLGETTEXIMAGEPROC glGetTexImage = nullptr; + PFNGLGETTEXLEVELPARAMETERFVPROC glGetTexLevelParameterfv = nullptr; + PFNGLGETTEXLEVELPARAMETERIVPROC glGetTexLevelParameteriv = nullptr; + PFNGLGETTEXPARAMETERFVPROC glGetTexParameterfv = nullptr; + PFNGLGETTEXPARAMETERIVPROC glGetTexParameteriv = nullptr; + PFNGLGETUNIFORMFVPROC glGetUniformfv = nullptr; + PFNGLGETUNIFORMIVPROC glGetUniformiv = nullptr; + PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation = nullptr; + PFNGLINVALIDATEBUFFERDATAPROC glInvalidateBufferData = nullptr; + PFNGLISENABLEDPROC glIsEnabled = nullptr; + PFNGLLINEWIDTHPROC glLineWidth = nullptr; + PFNGLLINKPROGRAMPROC glLinkProgram = nullptr; + PFNGLMAPBUFFERPROC glMapBuffer = nullptr; + PFNGLMAPBUFFERRANGEPROC glMapBufferRange = nullptr; + PFNGLPIXELSTOREIPROC glPixelStorei = nullptr; + PFNGLPOINTSIZEPROC glPointSize = nullptr; + PFNGLPOLYGONMODEPROC glPolygonMode = nullptr; + PFNGLPROGRAMBINARYPROC glProgramBinary = nullptr; + PFNGLPROGRAMPARAMETERIPROC glProgramParameteri = nullptr; + PFNGLPROGRAMUNIFORM1DPROC glProgramUniform1d = nullptr; + PFNGLPROGRAMUNIFORM1FPROC glProgramUniform1f = nullptr; + PFNGLPROGRAMUNIFORM1IPROC glProgramUniform1i = nullptr; + PFNGLPROGRAMUNIFORM1DVPROC glProgramUniform1dv = nullptr; + PFNGLPROGRAMUNIFORM1FVPROC glProgramUniform1fv = nullptr; + PFNGLPROGRAMUNIFORM1IVPROC glProgramUniform1iv = nullptr; + PFNGLPROGRAMUNIFORM2DVPROC glProgramUniform2dv = nullptr; + PFNGLPROGRAMUNIFORM2FVPROC glProgramUniform2fv = nullptr; + PFNGLPROGRAMUNIFORM2IVPROC glProgramUniform2iv = nullptr; + PFNGLPROGRAMUNIFORM3DVPROC glProgramUniform3dv = nullptr; + PFNGLPROGRAMUNIFORM3FVPROC glProgramUniform3fv = nullptr; + PFNGLPROGRAMUNIFORM3IVPROC glProgramUniform3iv = nullptr; + PFNGLPROGRAMUNIFORM4DVPROC glProgramUniform4dv = nullptr; + PFNGLPROGRAMUNIFORM4FVPROC glProgramUniform4fv = nullptr; + PFNGLPROGRAMUNIFORM4IVPROC glProgramUniform4iv = nullptr; + PFNGLPROGRAMUNIFORMMATRIX4DVPROC glProgramUniformMatrix4dv = nullptr; + PFNGLPROGRAMUNIFORMMATRIX4FVPROC glProgramUniformMatrix4fv = nullptr; + PFNGLREADPIXELSPROC glReadPixels = nullptr; + PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage = nullptr; + PFNGLSAMPLERPARAMETERFPROC glSamplerParameterf = nullptr; + PFNGLSAMPLERPARAMETERIPROC glSamplerParameteri = nullptr; + PFNGLSCISSORPROC glScissor = nullptr; + PFNGLSHADERSOURCEPROC glShaderSource = nullptr; + PFNGLSTENCILFUNCPROC glStencilFunc = nullptr; + PFNGLSTENCILFUNCSEPARATEPROC glStencilFuncSeparate = nullptr; + PFNGLSTENCILOPPROC glStencilOp = nullptr; + PFNGLSTENCILOPSEPARATEPROC glStencilOpSeparate = nullptr; + PFNGLTEXIMAGE1DPROC glTexImage1D = nullptr; + PFNGLTEXIMAGE2DPROC glTexImage2D = nullptr; + PFNGLTEXIMAGE3DPROC glTexImage3D = nullptr; + PFNGLTEXPARAMETERFPROC glTexParameterf = nullptr; + PFNGLTEXPARAMETERIPROC glTexParameteri = nullptr; + PFNGLTEXSTORAGE1DPROC glTexStorage1D = nullptr; + PFNGLTEXSTORAGE2DPROC glTexStorage2D = nullptr; + PFNGLTEXSTORAGE3DPROC glTexStorage3D = nullptr; + PFNGLTEXSUBIMAGE1DPROC glTexSubImage1D = nullptr; + PFNGLTEXSUBIMAGE2DPROC glTexSubImage2D = nullptr; + PFNGLTEXSUBIMAGE3DPROC glTexSubImage3D = nullptr; + PFNGLUNIFORM1DPROC glUniform1d = nullptr; + PFNGLUNIFORM1FPROC glUniform1f = nullptr; + PFNGLUNIFORM1IPROC glUniform1i = nullptr; + PFNGLUNIFORM1DVPROC glUniform1dv = nullptr; + PFNGLUNIFORM1FVPROC glUniform1fv = nullptr; + PFNGLUNIFORM1IVPROC glUniform1iv = nullptr; + PFNGLUNIFORM2DVPROC glUniform2dv = nullptr; + PFNGLUNIFORM2FVPROC glUniform2fv = nullptr; + PFNGLUNIFORM2IVPROC glUniform2iv = nullptr; + PFNGLUNIFORM3DVPROC glUniform3dv = nullptr; + PFNGLUNIFORM3FVPROC glUniform3fv = nullptr; + PFNGLUNIFORM3IVPROC glUniform3iv = nullptr; + PFNGLUNIFORM4DVPROC glUniform4dv = nullptr; + PFNGLUNIFORM4FVPROC glUniform4fv = nullptr; + PFNGLUNIFORM4IVPROC glUniform4iv = nullptr; + PFNGLUNIFORMMATRIX4DVPROC glUniformMatrix4dv = nullptr; + PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv = nullptr; + PFNGLUNMAPBUFFERPROC glUnmapBuffer = nullptr; + PFNGLUSEPROGRAMPROC glUseProgram = nullptr; + PFNGLVALIDATEPROGRAMPROC glValidateProgram = nullptr; + PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f = nullptr; + PFNGLVERTEXATTRIBDIVISORPROC glVertexAttribDivisor = nullptr; + PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer = nullptr; + PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer = nullptr; + PFNGLVERTEXATTRIBLPOINTERPROC glVertexAttribLPointer = nullptr; + PFNGLVIEWPORTPROC glViewport = nullptr; -#if defined(NAZARA_PLATFORM_WINDOWS) -PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormat = nullptr; -PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs = nullptr; -PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = nullptr; -PFNWGLGETEXTENSIONSSTRINGEXTPROC wglGetExtensionsStringEXT = nullptr; -PFNWGLSWAPINTERVALEXTPROC wglSwapInterval = nullptr; +#if defined(NAZARA_PLATFORM_SDL2) +#elif defined(NAZARA_PLATFORM_WINDOWS) + PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormat = nullptr; + PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs = nullptr; + PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = nullptr; + PFNWGLGETEXTENSIONSSTRINGEXTPROC wglGetExtensionsStringEXT = nullptr; + PFNWGLSWAPINTERVALEXTPROC wglSwapInterval = nullptr; #elif defined(NAZARA_PLATFORM_GLX) -GLX::PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs = nullptr; -GLX::PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT = nullptr; -GLX::PFNGLXSWAPINTERVALMESAPROC NzglXSwapIntervalMESA = nullptr; -GLX::PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI = nullptr; + GLX::PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs = nullptr; + GLX::PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT = nullptr; + GLX::PFNGLXSWAPINTERVALMESAPROC NzglXSwapIntervalMESA = nullptr; + GLX::PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI = nullptr; #endif } diff --git a/src/Nazara/Renderer/SDL2/ContextImpl.cpp b/src/Nazara/Renderer/SDL2/ContextImpl.cpp new file mode 100644 index 000000000..35ebda856 --- /dev/null +++ b/src/Nazara/Renderer/SDL2/ContextImpl.cpp @@ -0,0 +1,145 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +// Code inspiré de NeHe (Lesson1) et de la SFML par Laurent Gomila + +#include +#include +#include +#include +#include +#include +#include +#include +#include +namespace Nz +{ + ContextImpl::ContextImpl() + { + } + + bool ContextImpl::Activate() const + { + bool success = SDL_GL_MakeCurrent(m_window, m_context) == 0; + + if (!success) + NazaraError(SDL_GetError()); + else + lastActive = m_window; + + return success; + } + + bool ContextImpl::Create(ContextParameters& parameters) + { + if (parameters.window) + { + m_window = static_cast(parameters.window); + m_ownsWindow = false; + } + else + { + m_window = SDL_CreateWindow("STATIC", 0, 0, 1, 1, SDL_WINDOW_OPENGL | SDL_WINDOW_HIDDEN); + if (!m_window) + { + NazaraError("Failed to create window"); + return false; + } + + //SDL_HideWindow(m_window); + m_ownsWindow = true; + } + + // En cas d'exception, la ressource sera quand même libérée + CallOnExit onExit([this] () + { + Destroy(); + }); + + + bool valid = true; + + std::array, 13> attributes{ + std::pair + {SDL_GL_CONTEXT_PROFILE_MASK, parameters.compatibilityProfile ? SDL_GL_CONTEXT_PROFILE_COMPATIBILITY : SDL_GL_CONTEXT_PROFILE_CORE}, + {SDL_GL_CONTEXT_MAJOR_VERSION, parameters.majorVersion}, + {SDL_GL_CONTEXT_MINOR_VERSION, parameters.minorVersion}, + {SDL_GL_CONTEXT_FLAGS, parameters.debugMode ? SDL_GL_CONTEXT_DEBUG_FLAG : 0}, + {SDL_GL_SHARE_WITH_CURRENT_CONTEXT, true}, + {SDL_GL_RED_SIZE, (parameters.bitsPerPixel == 32) ? 8 : parameters.bitsPerPixel / 3}, // sad but I don't have a solution for now + {SDL_GL_GREEN_SIZE, (parameters.bitsPerPixel == 32) ? 8 : parameters.bitsPerPixel / 3}, + {SDL_GL_BLUE_SIZE, (parameters.bitsPerPixel == 32) ? 8 : parameters.bitsPerPixel / 3}, + {SDL_GL_ALPHA_SIZE, (parameters.bitsPerPixel == 32) ? 8 : 0}, + {SDL_GL_DEPTH_SIZE, parameters.depthBits}, + {SDL_GL_STENCIL_SIZE, parameters.stencilBits}, + //{SDL_GL_DOUBLEBUFFER, parameters.doubleBuffered}, // doesn't work if we dont close all windows + {SDL_GL_MULTISAMPLEBUFFERS, parameters.antialiasingLevel > 0 ? GL_TRUE : GL_FALSE}, + {SDL_GL_MULTISAMPLESAMPLES, parameters.antialiasingLevel} + }; + + for (const auto& attribute : attributes) { + valid &= SDL_GL_SetAttribute(attribute.first, attribute.second) == 0; + + if (!valid) { + NazaraWarning(SDL_GetError()); + break; + } + } + + if (!valid) + NazaraWarning("Could not find a format matching requirements, disabling antialiasing..."); + + int antialiasingLevel; + SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &antialiasingLevel); + + parameters.antialiasingLevel = static_cast(antialiasingLevel); + + + onExit.Reset(); + + m_context = SDL_GL_CreateContext(m_window); + + if (!m_context) { + NazaraError(SDL_GetError()); + + return false; + } + + return true; + } + + void ContextImpl::Destroy() + { + if (m_context) + { + SDL_GL_DeleteContext(m_context); + m_context = nullptr; + } + + if (m_ownsWindow) + { + SDL_DestroyWindow(m_window); + m_window = nullptr; + } + } + + void ContextImpl::EnableVerticalSync(bool enabled) + { + + if (SDL_GL_SetSwapInterval(enabled ? 1 : 0) != 0) + NazaraError("Vertical sync not supported"); + } + + void ContextImpl::SwapBuffers() + { + SDL_GL_SwapWindow(m_window); + } + + bool ContextImpl::Desactivate() + { + return SDL_GL_MakeCurrent(nullptr, nullptr) == 0; + } + + SDL_Window* ContextImpl::lastActive = nullptr; +} diff --git a/src/Nazara/Renderer/SDL2/ContextImpl.hpp b/src/Nazara/Renderer/SDL2/ContextImpl.hpp new file mode 100644 index 000000000..ae1f620a1 --- /dev/null +++ b/src/Nazara/Renderer/SDL2/ContextImpl.hpp @@ -0,0 +1,42 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine". +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_CONTEXTIMPL_HPP +#define NAZARA_CONTEXTIMPL_HPP + +#include +#include +#include + +namespace Nz +{ + class ContextImpl + { + public: + ContextImpl(); + + bool Activate() const; + + bool Create(ContextParameters& parameters); + + void Destroy(); + + void EnableVerticalSync(bool enabled); + + void SwapBuffers(); + + static bool Desactivate(); + + private: + SDL_GLContext m_context; + SDL_Window* m_window; + bool m_ownsWindow; + + static SDL_Window* lastActive; + }; +} + +#endif // NAZARA_CONTEXTIMPL_HPP From ab5188c57d6cc2942b518932789c4859f715d2ac Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 19 May 2019 16:34:29 +0200 Subject: [PATCH 083/316] Add scancode and virtual key and fix some sdl stuff on Windows --- SDK/src/NDK/Application.cpp | 2 +- SDK/src/NDK/Canvas.cpp | 2 +- SDK/src/NDK/Console.cpp | 8 +- SDK/src/NDK/Lua/LuaBinding_Platform.cpp | 10 +- SDK/src/NDK/Widgets/TextAreaWidget.cpp | 20 +- build/scripts/modules/platform.lua | 2 +- build/scripts/modules/renderer.lua | 6 +- examples/FirstScene/main.cpp | 18 +- examples/Particles/SpacebattleDemo.cpp | 3 +- examples/Particles/main.cpp | 16 +- examples/Tut02/main.cpp | 4 +- include/Nazara/Platform/Event.hpp | 3 +- include/Nazara/Platform/Keyboard.hpp | 161 ++++- include/Nazara/Renderer/OpenGL.hpp | 10 +- src/Nazara/Platform/Keyboard.cpp | 24 +- src/Nazara/Platform/SDL2/InputImpl.cpp | 184 +----- src/Nazara/Platform/SDL2/InputImpl.hpp | 8 +- src/Nazara/Platform/SDL2/SDLHelper.cpp | 586 ++++++++++++++++++ src/Nazara/Platform/SDL2/SDLHelper.hpp | 26 + src/Nazara/Platform/SDL2/WindowImpl.cpp | 147 +---- src/Nazara/Platform/SDL2/WindowImpl.hpp | 1 - src/Nazara/Renderer/Context.cpp | 1 - src/Nazara/Renderer/OpenGL.cpp | 12 +- src/Nazara/Renderer/SDL2/ContextImpl.cpp | 4 +- .../Platform/EventHandler/EventState.cpp | 4 +- .../Platform/EventHandler/FocusState.cpp | 4 +- .../Engine/Platform/EventHandler/KeyState.cpp | 10 +- .../Platform/EventHandler/MenuState.cpp | 6 +- .../Platform/EventHandler/MouseClickState.cpp | 4 +- .../Platform/EventHandler/MouseEnterState.cpp | 4 +- .../Platform/EventHandler/MouseMoveState.cpp | 4 +- .../Platform/EventHandler/TextEnterState.cpp | 4 +- .../EventHandler/WindowModificationState.cpp | 4 +- 33 files changed, 920 insertions(+), 382 deletions(-) create mode 100644 src/Nazara/Platform/SDL2/SDLHelper.cpp create mode 100644 src/Nazara/Platform/SDL2/SDLHelper.hpp diff --git a/SDK/src/NDK/Application.cpp b/SDK/src/NDK/Application.cpp index a4fca055a..85757f33a 100644 --- a/SDK/src/NDK/Application.cpp +++ b/SDK/src/NDK/Application.cpp @@ -209,7 +209,7 @@ namespace Ndk overlay->keyPressedSlot.Connect(eventHandler.OnKeyPressed, [&consoleRef] (const Nz::EventHandler*, const Nz::WindowEvent::KeyEvent& event) { - if (event.code == Nz::Keyboard::F9) + if (event.virtualKey == Nz::Keyboard::VKey::F9) consoleRef.Show(!consoleRef.IsVisible()); }); diff --git a/SDK/src/NDK/Canvas.cpp b/SDK/src/NDK/Canvas.cpp index 3959f1765..7e74d5197 100644 --- a/SDK/src/NDK/Canvas.cpp +++ b/SDK/src/NDK/Canvas.cpp @@ -144,7 +144,7 @@ namespace Ndk if (m_widgetEntries[m_keyboardOwner].widget->OnKeyPressed(event)) return; - if (event.code == Nz::Keyboard::Tab) + if (event.virtualKey == Nz::Keyboard::VKey::Tab) { if (!event.shift) { diff --git a/SDK/src/NDK/Console.cpp b/SDK/src/NDK/Console.cpp index e5b4f1306..3dcdaca71 100644 --- a/SDK/src/NDK/Console.cpp +++ b/SDK/src/NDK/Console.cpp @@ -178,12 +178,12 @@ namespace Ndk case Nz::WindowEventType_KeyPressed: { - switch (event.key.code) + switch (event.key.virtualKey) { - case Nz::Keyboard::Down: - case Nz::Keyboard::Up: + case Nz::Keyboard::VKey::Down: + case Nz::Keyboard::VKey::Up: { - if (event.key.code == Nz::Keyboard::Up) + if (event.key.virtualKey == Nz::Keyboard::VKey::Up) m_historyPosition = std::min(m_commandHistory.size(), m_historyPosition + 1); else { diff --git a/SDK/src/NDK/Lua/LuaBinding_Platform.cpp b/SDK/src/NDK/Lua/LuaBinding_Platform.cpp index ac16f6fb3..24a218fae 100644 --- a/SDK/src/NDK/Lua/LuaBinding_Platform.cpp +++ b/SDK/src/NDK/Lua/LuaBinding_Platform.cpp @@ -17,8 +17,8 @@ namespace Ndk /*********************************** Nz::Keyboard **********************************/ keyboard.Reset("Keyboard"); { - keyboard.BindStaticMethod("GetKeyName", &Nz::Keyboard::GetKeyName); - keyboard.BindStaticMethod("IsKeyPressed", &Nz::Keyboard::IsKeyPressed); + //keyboard.BindStaticMethod("GetKeyName", &Nz::Keyboard::GetKeyName); + //keyboard.BindStaticMethod("IsKeyPressed", &Nz::Keyboard::IsKeyPressed); } } @@ -31,9 +31,9 @@ namespace Ndk { keyboard.Register(state); - keyboard.PushGlobalTable(state); + /*keyboard.PushGlobalTable(state); { - static_assert(Nz::Keyboard::Count == 124, "Nz::Keyboard::Key has been updated but change was not reflected to Lua binding"); + static_assert(Nz::Keyboard::Max == 123, "Nz::Keyboard::Key has been updated but change was not reflected to Lua binding"); state.PushField("Undefined", Nz::Keyboard::Undefined); @@ -119,7 +119,7 @@ namespace Ndk state.PushField("NumLock", Nz::Keyboard::NumLock); state.PushField("ScrollLock", Nz::Keyboard::ScrollLock); } - state.Pop(); + state.Pop();*/ static_assert(Nz::WindowStyle_Max + 1 == 6, "Nz::WindowStyle has been updated but change was not reflected to Lua binding"); state.PushTable(0, Nz::WindowStyle_Max + 1); diff --git a/SDK/src/NDK/Widgets/TextAreaWidget.cpp b/SDK/src/NDK/Widgets/TextAreaWidget.cpp index 09355c09c..53d3929c4 100644 --- a/SDK/src/NDK/Widgets/TextAreaWidget.cpp +++ b/SDK/src/NDK/Widgets/TextAreaWidget.cpp @@ -207,9 +207,9 @@ namespace Ndk bool TextAreaWidget::OnKeyPressed(const Nz::WindowEvent::KeyEvent& key) { - switch (key.code) + switch (key.virtualKey) { - case Nz::Keyboard::Delete: + case Nz::Keyboard::VKey::Delete: { if (HasSelection()) EraseSelection(); @@ -219,7 +219,7 @@ namespace Ndk return true; } - case Nz::Keyboard::Down: + case Nz::Keyboard::VKey::Down: { bool ignoreDefaultAction = false; OnTextAreaKeyDown(this, &ignoreDefaultAction); @@ -234,7 +234,7 @@ namespace Ndk return true; } - case Nz::Keyboard::End: + case Nz::Keyboard::VKey::End: { bool ignoreDefaultAction = false; OnTextAreaKeyEnd(this, &ignoreDefaultAction); @@ -251,7 +251,7 @@ namespace Ndk return true; } - case Nz::Keyboard::Home: + case Nz::Keyboard::VKey::Home: { bool ignoreDefaultAction = false; OnTextAreaKeyHome(this, &ignoreDefaultAction); @@ -263,7 +263,7 @@ namespace Ndk return true; } - case Nz::Keyboard::Left: + case Nz::Keyboard::VKey::Left: { bool ignoreDefaultAction = false; OnTextAreaKeyLeft(this, &ignoreDefaultAction); @@ -301,7 +301,7 @@ namespace Ndk return true; } - case Nz::Keyboard::Right: + case Nz::Keyboard::VKey::Right: { bool ignoreDefaultAction = false; OnTextAreaKeyRight(this, &ignoreDefaultAction); @@ -340,7 +340,7 @@ namespace Ndk return true; } - case Nz::Keyboard::Up: + case Nz::Keyboard::VKey::Up: { bool ignoreDefaultAction = false; OnTextAreaKeyUp(this, &ignoreDefaultAction); @@ -355,7 +355,7 @@ namespace Ndk return true; } - case Nz::Keyboard::Tab: + case Nz::Keyboard::VKey::Tab: { if (!m_tabEnabled) return false; @@ -425,7 +425,7 @@ namespace Ndk Nz::Vector2ui hoveredGlyph = GetHoveredGlyph(float(x) - 5.f, float(y) - 5.f); // Shift extends selection - if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::LShift) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::RShift)) + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::LShift) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::RShift)) SetSelection(hoveredGlyph, m_selectionCursor); else { diff --git a/build/scripts/modules/platform.lua b/build/scripts/modules/platform.lua index 2768d1a28..d6201c526 100644 --- a/build/scripts/modules/platform.lua +++ b/build/scripts/modules/platform.lua @@ -7,7 +7,7 @@ MODULE.Libraries = { "NazaraUtility" } -if Config.PlatformSDL2 then +if (Config.PlatformSDL2) then table.insert(MODULE.Defines, "NAZARA_PLATFORM_SDL2") table.insert(MODULE.Files, "../src/Nazara/Platform/SDL2/**.hpp") diff --git a/build/scripts/modules/renderer.lua b/build/scripts/modules/renderer.lua index 800ca33b7..c9f65526f 100644 --- a/build/scripts/modules/renderer.lua +++ b/build/scripts/modules/renderer.lua @@ -12,12 +12,14 @@ MODULE.Libraries = { "NazaraPlatform" } -if Config.PlatformSDL2 then +if (Config.PlatformSDL2) then table.insert(MODULE.Defines, "NAZARA_PLATFORM_SDL2") table.insert(MODULE.Files, "../src/Nazara/Renderer/SDL2/**.hpp") table.insert(MODULE.Files, "../src/Nazara/Renderer/SDL2/**.cpp") + table.insert(MODULE.Libraries, "SDL2") + MODULE.FilesExcluded = { "../src/Nazara/Renderer/Win32/**", "../src/Nazara/Renderer/GLX/**.cpp" @@ -43,4 +45,4 @@ else "GL", "X11" } -end \ No newline at end of file +end diff --git a/examples/FirstScene/main.cpp b/examples/FirstScene/main.cpp index 0e3f8f8a2..d6759ea12 100644 --- a/examples/FirstScene/main.cpp +++ b/examples/FirstScene/main.cpp @@ -305,9 +305,9 @@ int main() eventHandler.OnKeyPressed.Connect([&targetPos, &cameraNode, &smoothMovement, &window](const Nz::EventHandler*, const Nz::WindowEvent::KeyEvent& event) { // Une touche a été pressée ! - if (event.code == Nz::Keyboard::Key::Escape) + if (event.virtualKey == Nz::Keyboard::VKey::Escape) window.Close(); - else if (event.code == Nz::Keyboard::F1) + else if (event.virtualKey == Nz::Keyboard::VKey::F1) { if (smoothMovement) { @@ -348,34 +348,34 @@ int main() if (move) { // Si la touche espace est enfoncée, notre vitesse de déplacement est multipliée par deux - if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Space)) + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::Space)) cameraSpeed *= 2.f; // Pour que nos déplacement soient liés à la rotation de la caméra, nous allons utiliser // les directions locales de la caméra // Si la flèche du haut ou la touche Z (vive ZQSD !!) est pressée, on avance - if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Up) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Z)) + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::Up) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::Z)) targetPos += cameraNode.GetForward() * cameraSpeed; // Si la flèche du bas ou la touche S est pressée, on recule - if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Down) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::S)) + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::Down) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::S)) targetPos += cameraNode.GetBackward() * cameraSpeed; // Etc... - if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Left) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Q)) + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::Left) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::Q)) targetPos += cameraNode.GetLeft() * cameraSpeed; // Etc... - if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Right) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::D)) + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::Right) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::D)) targetPos += cameraNode.GetRight() * cameraSpeed; // Majuscule pour monter, notez l'utilisation d'une direction globale (Non-affectée par la rotation) - if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::LShift) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::RShift)) + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::LShift) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::RShift)) targetPos += Nz::Vector3f::Up() * cameraSpeed; // Contrôle (Gauche ou droite) pour descendre dans l'espace global, etc... - if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::LControl) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::RControl)) + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::LControl) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::RControl)) targetPos += Nz::Vector3f::Down() * cameraSpeed; } diff --git a/examples/Particles/SpacebattleDemo.cpp b/examples/Particles/SpacebattleDemo.cpp index 65336ad13..63b222599 100644 --- a/examples/Particles/SpacebattleDemo.cpp +++ b/examples/Particles/SpacebattleDemo.cpp @@ -677,7 +677,8 @@ void SpacebattleExample::Leave(Ndk::StateMachine& fsm) { m_ambientMusic.Stop(); m_onMouseMoved.Disconnect(); - m_shared.target->SetCursor(Nz::SystemCursor_Default); + if (m_shared.target) + m_shared.target->SetCursor(Nz::SystemCursor_Default); m_shared.world3D->RemoveSystem(); m_shared.world3D->RemoveSystem(); m_turretFireSound.Stop(); diff --git a/examples/Particles/main.cpp b/examples/Particles/main.cpp index e4940c63d..4738c5eb1 100644 --- a/examples/Particles/main.cpp +++ b/examples/Particles/main.cpp @@ -123,17 +123,17 @@ int main() { case Nz::WindowEventType_KeyPressed: { - switch (event.key.code) + switch (event.key.virtualKey) { - case Nz::Keyboard::Backspace: + case Nz::Keyboard::VKey::Backspace: stateMachine.ChangeState(shared.demos[demoIndex]); break; - case Nz::Keyboard::Escape: + case Nz::Keyboard::VKey::Escape: app.Quit(); break; - case Nz::Keyboard::Left: + case Nz::Keyboard::VKey::Left: { if (shared.demos.size() <= 1) break; @@ -146,7 +146,7 @@ int main() break; } - case Nz::Keyboard::Right: + case Nz::Keyboard::VKey::Right: { if (shared.demos.size() <= 1) break; @@ -159,14 +159,14 @@ int main() break; } - case Nz::Keyboard::Pause: + case Nz::Keyboard::VKey::Pause: { auto& velocitySystem = shared.world3D->GetSystem(); velocitySystem.Enable(!velocitySystem.IsEnabled()); break; } - case Nz::Keyboard::F5: + case Nz::Keyboard::VKey::F5: { Nz::Image screenshot; screenshot.Create(Nz::ImageType_2D, Nz::PixelFormatType_RGBA8, 1920, 1080); @@ -197,5 +197,7 @@ int main() window.Display(); } + shared.target = nullptr; + return EXIT_SUCCESS; } diff --git a/examples/Tut02/main.cpp b/examples/Tut02/main.cpp index 83de624c6..54e92993f 100644 --- a/examples/Tut02/main.cpp +++ b/examples/Tut02/main.cpp @@ -33,10 +33,10 @@ int main(int argc, char* argv[]) Nz::EventHandler& eventHandler = mainWindow.GetEventHandler(); eventHandler.OnKeyPressed.Connect([](const Nz::EventHandler*, const Nz::WindowEvent::KeyEvent& e) { - std::cout << Nz::Keyboard::GetKeyName(e.code) << std::endl; + std::cout << Nz::Keyboard::GetKeyName(e.virtualKey) << std::endl; // Profitons-en aussi pour nous donner un moyen de quitter le programme - if (e.code == Nz::Keyboard::Escape) + if (e.virtualKey == Nz::Keyboard::VKey::Escape) Ndk::Application::Instance()->Quit(); // Cette ligne casse la boucle Run() de l'application }); diff --git a/include/Nazara/Platform/Event.hpp b/include/Nazara/Platform/Event.hpp index 1fe219e8e..1c98f6b7f 100644 --- a/include/Nazara/Platform/Event.hpp +++ b/include/Nazara/Platform/Event.hpp @@ -22,7 +22,8 @@ namespace Nz // -WindowEventType_KeyReleased struct KeyEvent { - Keyboard::Key code; + Keyboard::Scancode scancode; + Keyboard::VKey virtualKey; bool alt; bool control; bool repeated; diff --git a/include/Nazara/Platform/Keyboard.hpp b/include/Nazara/Platform/Keyboard.hpp index c3ec5ac19..5a131b66f 100644 --- a/include/Nazara/Platform/Keyboard.hpp +++ b/include/Nazara/Platform/Keyboard.hpp @@ -18,7 +18,7 @@ namespace Nz class NAZARA_PLATFORM_API Keyboard { public: - enum Key + enum class Scancode { Undefined = -1, @@ -164,14 +164,167 @@ namespace Nz NumLock, ScrollLock, - Count + Max = ScrollLock + }; + + enum class VKey + { + Undefined = -1, + + // Lettres + A, + B, + C, + D, + E, + F, + G, + H, + I, + J, + K, + L, + M, + N, + O, + P, + Q, + R, + S, + T, + U, + V, + W, + X, + Y, + Z, + + // Functional keys + F1, + F2, + F3, + F4, + F5, + F6, + F7, + F8, + F9, + F10, + F11, + F12, + F13, + F14, + F15, + + // Directional keys + Down, + Left, + Right, + Up, + + // Numerical pad + Add, + Decimal, + Divide, + Multiply, + NumpadReturn, + Numpad0, + Numpad1, + Numpad2, + Numpad3, + Numpad4, + Numpad5, + Numpad6, + Numpad7, + Numpad8, + Numpad9, + Subtract, + + // Various + Backslash, + Backspace, + Clear, + Comma, + Dash, + Delete, + End, + Equal, + Escape, + Home, + Insert, + LAlt, + LBracket, + LControl, + LShift, + LSystem, + Num0, + Num1, + Num2, + Num3, + Num4, + Num5, + Num6, + Num7, + Num8, + Num9, + PageDown, + PageUp, + Pause, + Period, + Print, + PrintScreen, + Quote, + RAlt, + RBracket, + RControl, + Return, + RShift, + RSystem, + Semicolon, + Slash, + Space, + Tab, + Tilde, + Menu, + ISOBackslash102, + + // Navigator keys + Browser_Back, + Browser_Favorites, + Browser_Forward, + Browser_Home, + Browser_Refresh, + Browser_Search, + Browser_Stop, + + // Lecture control keys + Media_Next, + Media_Play, + Media_Previous, + Media_Stop, + + // Volume control keys + Volume_Down, + Volume_Mute, + Volume_Up, + + // Locking keys + CapsLock, + NumLock, + ScrollLock, + + Max = ScrollLock }; Keyboard() = delete; ~Keyboard() = delete; - static String GetKeyName(Key key); - static bool IsKeyPressed(Key key); + static String GetKeyName(Scancode scancode); + static String GetKeyName(VKey key); + static bool IsKeyPressed(Scancode scancode); + static bool IsKeyPressed(VKey key); + static Scancode ToScanCode(VKey key); + static VKey ToVirtualKey(Scancode key); }; } diff --git a/include/Nazara/Renderer/OpenGL.hpp b/include/Nazara/Renderer/OpenGL.hpp index 35a851d00..5252bcfbe 100644 --- a/include/Nazara/Renderer/OpenGL.hpp +++ b/include/Nazara/Renderer/OpenGL.hpp @@ -6,9 +6,6 @@ #ifndef NAZARA_OPENGL_HPP #define NAZARA_OPENGL_HPP -#ifndef NAZARA_RENDERER_OPENGL -#define NAZARA_RENDERER_OPENGL -#endif #ifdef NAZARA_RENDERER_OPENGL #include @@ -25,7 +22,9 @@ #if defined(NAZARA_PLATFORM_SDL2) #include -#elif defined(NAZARA_PLATFORM_WINDOWS) +#endif + +#if defined(NAZARA_PLATFORM_WINDOWS) #include #elif defined(NAZARA_PLATFORM_GLX) namespace GLX @@ -335,8 +334,7 @@ namespace Nz NAZARA_RENDERER_API extern PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer; NAZARA_RENDERER_API extern PFNGLVERTEXATTRIBLPOINTERPROC glVertexAttribLPointer; NAZARA_RENDERER_API extern PFNGLVIEWPORTPROC glViewport; -#if defined(NAZARA_PLATFORM_SDL2) -#elif defined(NAZARA_PLATFORM_WINDOWS) +#if defined(NAZARA_PLATFORM_WINDOWS) NAZARA_RENDERER_API extern PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormat; NAZARA_RENDERER_API extern PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs; NAZARA_RENDERER_API extern PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB; diff --git a/src/Nazara/Platform/Keyboard.cpp b/src/Nazara/Platform/Keyboard.cpp index 9fbf8fcdf..45435b818 100644 --- a/src/Nazara/Platform/Keyboard.cpp +++ b/src/Nazara/Platform/Keyboard.cpp @@ -18,13 +18,33 @@ namespace Nz { - String Keyboard::GetKeyName(Key key) + String Keyboard::GetKeyName(Scancode scancode) + { + return EventImpl::GetKeyName(scancode); + } + + String Keyboard::GetKeyName(VKey key) { return EventImpl::GetKeyName(key); } - bool Keyboard::IsKeyPressed(Key key) + bool Keyboard::IsKeyPressed(Scancode scancode) + { + return EventImpl::IsKeyPressed(scancode); + } + + bool Keyboard::IsKeyPressed(VKey key) { return EventImpl::IsKeyPressed(key); } + + Keyboard::Scancode Keyboard::ToScanCode(VKey key) + { + return EventImpl::ToScanCode(key); + } + + Keyboard::VKey Keyboard::ToVirtualKey(Scancode scancode) + { + return EventImpl::ToVirtualKey(scancode); + } } diff --git a/src/Nazara/Platform/SDL2/InputImpl.cpp b/src/Nazara/Platform/SDL2/InputImpl.cpp index 671f79d22..1ecbc8491 100644 --- a/src/Nazara/Platform/SDL2/InputImpl.cpp +++ b/src/Nazara/Platform/SDL2/InputImpl.cpp @@ -5,171 +5,34 @@ #include #include #include +#include #include - #include +#include #include namespace Nz { - namespace + String EventImpl::GetKeyName(Keyboard::Scancode key) { - SDL_Scancode nzKeyboardToSDLScanCode[Keyboard::Count] = { - // Lettres - SDL_SCANCODE_A, // Key::A - SDL_SCANCODE_B, // Key::B - SDL_SCANCODE_C, // Key::C - SDL_SCANCODE_D, // Key::D - SDL_SCANCODE_E, // Key::E - SDL_SCANCODE_F, // Key::F - SDL_SCANCODE_G, // Key::G - SDL_SCANCODE_H, // Key::H - SDL_SCANCODE_I, // Key::I - SDL_SCANCODE_J, // Key::J - SDL_SCANCODE_K, // Key::K - SDL_SCANCODE_L, // Key::L - SDL_SCANCODE_M, // Key::M - SDL_SCANCODE_N, // Key::N - SDL_SCANCODE_O, // Key::O - SDL_SCANCODE_P, // Key::P - SDL_SCANCODE_Q, // Key::Q - SDL_SCANCODE_R, // Key::R - SDL_SCANCODE_S, // Key::S - SDL_SCANCODE_T, // Key::T - SDL_SCANCODE_U, // Key::U - SDL_SCANCODE_V, // Key::V - SDL_SCANCODE_W, // Key::W - SDL_SCANCODE_X, // Key::X - SDL_SCANCODE_Y, // Key::Y - SDL_SCANCODE_Z, // Key::Z + SDL_Scancode scancode = SDLHelper::ToSDL(key); - // Touches de fonction - SDL_SCANCODE_F1, // Key::F1 - SDL_SCANCODE_F2, // Key::F2 - SDL_SCANCODE_F3, // Key::F3 - SDL_SCANCODE_F4, // Key::F4 - SDL_SCANCODE_F5, // Key::F5 - SDL_SCANCODE_F6, // Key::F6 - SDL_SCANCODE_F7, // Key::F7 - SDL_SCANCODE_F8, // Key::F8 - SDL_SCANCODE_F9, // Key::F9 - SDL_SCANCODE_F10, // Key::F10 - SDL_SCANCODE_F11, // Key::F11 - SDL_SCANCODE_F12, // Key::F12 - SDL_SCANCODE_F13, // Key::F13 - SDL_SCANCODE_F14, // Key::F14 - SDL_SCANCODE_F15, // Key::F15 + String name; + if (scancode != SDL_SCANCODE_UNKNOWN) + name = SDL_GetScancodeName(scancode); - // Flèches directionnelles - SDL_SCANCODE_DOWN, // Key::Down - SDL_SCANCODE_LEFT, // Key::Left - SDL_SCANCODE_RIGHT, // Key::Right - SDL_SCANCODE_UP, // Key::Up - - // Pavé numérique - SDL_SCANCODE_KP_PLUS, // Key::Add - SDL_SCANCODE_KP_PERIOD, // Key::Decimal - SDL_SCANCODE_KP_DIVIDE, // Key::Divide - SDL_SCANCODE_KP_MULTIPLY, // Key::Multiply - SDL_SCANCODE_KP_ENTER, // Key::NumpadReturn - SDL_SCANCODE_KP_0, // Key::Numpad0 - SDL_SCANCODE_KP_1, // Key::Numpad1 - SDL_SCANCODE_KP_2, // Key::Numpad2 - SDL_SCANCODE_KP_3, // Key::Numpad3 - SDL_SCANCODE_KP_4, // Key::Numpad4 - SDL_SCANCODE_KP_5, // Key::Numpad5 - SDL_SCANCODE_KP_6, // Key::Numpad6 - SDL_SCANCODE_KP_7, // Key::Numpad7 - SDL_SCANCODE_KP_8, // Key::Numpad8 - SDL_SCANCODE_KP_9, // Key::Numpad9 - SDL_SCANCODE_KP_MINUS, // Key::Subtract - - - // Diverss - SDL_SCANCODE_BACKSLASH, // Key::Backslash - SDL_SCANCODE_BACKSPACE, // Key::Backspace - SDL_SCANCODE_CLEAR, // Key::Clear - SDL_SCANCODE_COMMA, // Key::Comma, - SDL_SCANCODE_MINUS, // Key::Dash - SDL_SCANCODE_DELETE, // Key::Delete - SDL_SCANCODE_END, // Key::End - SDL_SCANCODE_EQUALS, // Key::Equal - SDL_SCANCODE_ESCAPE, // Key::Escape - SDL_SCANCODE_HOME, // Key::Home - SDL_SCANCODE_INSERT, // Key::Insert - SDL_SCANCODE_LALT, // Key::LAlt - SDL_SCANCODE_LEFTBRACKET, // Key::LBracket - SDL_SCANCODE_LCTRL, // Key::LControl - SDL_SCANCODE_LSHIFT, // Key::LShift - SDL_SCANCODE_LGUI, // Key::LSystem - SDL_SCANCODE_0, // Key::Num0 - SDL_SCANCODE_1, // Key::Num1 - SDL_SCANCODE_2, // Key::Num2 - SDL_SCANCODE_3, // Key::Num3 - SDL_SCANCODE_4, // Key::Num4 - SDL_SCANCODE_5, // Key::Num5 - SDL_SCANCODE_6, // Key::Num6 - SDL_SCANCODE_7, // Key::Num7 - SDL_SCANCODE_8, // Key::Num8 - SDL_SCANCODE_9, // Key::Num9 - SDL_SCANCODE_PAGEDOWN, // Key::PageDown - SDL_SCANCODE_PAGEUP, // Key::PageUp - SDL_SCANCODE_PAUSE, // Key::Pause - SDL_SCANCODE_PERIOD, // Key::Period - SDL_SCANCODE_SYSREQ, // Key::Print - SDL_SCANCODE_PRINTSCREEN, // Key::PrintScreen - SDL_SCANCODE_APOSTROPHE, // Key::Quote - SDL_SCANCODE_RALT, // Key::RAlt - SDL_SCANCODE_RIGHTBRACKET, // Key::RBracket - SDL_SCANCODE_RCTRL, // Key::RControl - SDL_SCANCODE_RETURN, // Key::Return - SDL_SCANCODE_RSHIFT, // Key::RShift - SDL_SCANCODE_RGUI, // Key::RSystem - SDL_SCANCODE_SEMICOLON, // Key::Semicolon - SDL_SCANCODE_SLASH, // Key::Slash - SDL_SCANCODE_SPACE, // Key::Space - SDL_SCANCODE_TAB, // Key::Tab - SDL_SCANCODE_GRAVE, // Key::Tilde - SDL_SCANCODE_APPLICATION, // Key::Menu - SDL_SCANCODE_NONUSBACKSLASH,// Key::ISOBackslash102 - - // Touches navigateur - SDL_SCANCODE_AC_BACK, // Key::Browser_Back - SDL_SCANCODE_AC_BOOKMARKS, // Key::Browser_Favorites - SDL_SCANCODE_AC_FORWARD, // Key::Browser_Forward - SDL_SCANCODE_AC_HOME, // Key::Browser_Home - SDL_SCANCODE_AC_REFRESH, // Key::Browser_Refresh - SDL_SCANCODE_AC_SEARCH, // Key::Browser_Search - SDL_SCANCODE_AC_STOP, // Key::Browser_Stop - - // Touches de contrôle - SDL_SCANCODE_AUDIONEXT, // Key::Media_Next, - SDL_SCANCODE_AUDIOPLAY, // Key::Media_PlayPause, - SDL_SCANCODE_AUDIOPREV, // Key::Media_Previous, - SDL_SCANCODE_AUDIOSTOP, // Key::Media_Stop, - - // Touches de contrôle du volume - SDL_SCANCODE_VOLUMEDOWN, // Key::Volume_Down - SDL_SCANCODE_MUTE, // Key::Volume_Mute - SDL_SCANCODE_VOLUMEUP, // Key::Volume_Up - - // Touches à verrouillage - SDL_SCANCODE_CAPSLOCK, // Key::CapsLock - SDL_SCANCODE_NUMLOCKCLEAR, // Key::NumLock - SDL_SCANCODE_SCROLLLOCK // Key::ScrollLock - }; + return !name.IsEmpty() ? name : String::Unicode("Unknown"); } - String EventImpl::GetKeyName(Keyboard::Key key) + String EventImpl::GetKeyName(Keyboard::VKey key) { - auto scancode = nzKeyboardToSDLScanCode[key]; + SDL_Keycode vkey = SDLHelper::ToSDL(key); - auto name = String::Unicode(SDL_GetKeyName(SDL_GetKeyFromScancode(scancode))); + String name; + if (vkey != SDLK_UNKNOWN) + name = SDL_GetKeyName(vkey); - if (name == "") - name = "\"" + String::Unicode(SDL_GetScancodeName(scancode)) + "\""; - - return name == "\"\"" ? String::Unicode("Unknown") : name; + return !name.IsEmpty() ? name : String::Unicode("Unknown"); } Vector2i EventImpl::GetMousePosition() @@ -199,9 +62,14 @@ namespace Nz } } - bool EventImpl::IsKeyPressed(Keyboard::Key key) + bool EventImpl::IsKeyPressed(Keyboard::Scancode key) { - return SDL_GetKeyboardState(nullptr)[nzKeyboardToSDLScanCode[key]]; + return SDL_GetKeyboardState(nullptr)[SDLHelper::ToSDL(key)]; + } + + bool EventImpl::IsKeyPressed(Keyboard::VKey key) + { + return IsKeyPressed(ToScanCode(key)); } bool EventImpl::IsMouseButtonPressed(Mouse::Button button) @@ -231,4 +99,14 @@ namespace Nz else NazaraError("Invalid window handle"); } + + Keyboard::Scancode EventImpl::ToScanCode(Keyboard::VKey key) + { + return SDLHelper::FromSDL(SDL_GetScancodeFromKey(SDLHelper::ToSDL(key))); + } + + Keyboard::VKey EventImpl::ToVirtualKey(Keyboard::Scancode scancode) + { + return SDLHelper::FromSDL(SDL_GetKeyFromScancode(SDLHelper::ToSDL(scancode))); + } } diff --git a/src/Nazara/Platform/SDL2/InputImpl.hpp b/src/Nazara/Platform/SDL2/InputImpl.hpp index 09f7802ec..9a21ed363 100644 --- a/src/Nazara/Platform/SDL2/InputImpl.hpp +++ b/src/Nazara/Platform/SDL2/InputImpl.hpp @@ -17,13 +17,17 @@ namespace Nz class EventImpl { public: - static String GetKeyName(Keyboard::Key key); + static String GetKeyName(Keyboard::Scancode scancode); + static String GetKeyName(Keyboard::VKey key); static Vector2i GetMousePosition(); static Vector2i GetMousePosition(const Window& relativeTo); - static bool IsKeyPressed(Keyboard::Key key); + static bool IsKeyPressed(Keyboard::Scancode key); + static bool IsKeyPressed(Keyboard::VKey key); static bool IsMouseButtonPressed(Mouse::Button button); static void SetMousePosition(int x, int y); static void SetMousePosition(int x, int y, const Window& relativeTo); + static Keyboard::Scancode ToScanCode(Keyboard::VKey key); + static Keyboard::VKey ToVirtualKey(Keyboard::Scancode scancode); }; } diff --git a/src/Nazara/Platform/SDL2/SDLHelper.cpp b/src/Nazara/Platform/SDL2/SDLHelper.cpp new file mode 100644 index 000000000..447e21c69 --- /dev/null +++ b/src/Nazara/Platform/SDL2/SDLHelper.cpp @@ -0,0 +1,586 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Platform module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include + +namespace Nz +{ + namespace + { + SDL_Scancode nzScancodeToSDLScanCode[static_cast(Keyboard::VKey::Max) + 1] = { + // Lettres + SDL_SCANCODE_A, // Key::A + SDL_SCANCODE_B, // Key::B + SDL_SCANCODE_C, // Key::C + SDL_SCANCODE_D, // Key::D + SDL_SCANCODE_E, // Key::E + SDL_SCANCODE_F, // Key::F + SDL_SCANCODE_G, // Key::G + SDL_SCANCODE_H, // Key::H + SDL_SCANCODE_I, // Key::I + SDL_SCANCODE_J, // Key::J + SDL_SCANCODE_K, // Key::K + SDL_SCANCODE_L, // Key::L + SDL_SCANCODE_M, // Key::M + SDL_SCANCODE_N, // Key::N + SDL_SCANCODE_O, // Key::O + SDL_SCANCODE_P, // Key::P + SDL_SCANCODE_Q, // Key::Q + SDL_SCANCODE_R, // Key::R + SDL_SCANCODE_S, // Key::S + SDL_SCANCODE_T, // Key::T + SDL_SCANCODE_U, // Key::U + SDL_SCANCODE_V, // Key::V + SDL_SCANCODE_W, // Key::W + SDL_SCANCODE_X, // Key::X + SDL_SCANCODE_Y, // Key::Y + SDL_SCANCODE_Z, // Key::Z + + // Touches de fonction + SDL_SCANCODE_F1, // Key::F1 + SDL_SCANCODE_F2, // Key::F2 + SDL_SCANCODE_F3, // Key::F3 + SDL_SCANCODE_F4, // Key::F4 + SDL_SCANCODE_F5, // Key::F5 + SDL_SCANCODE_F6, // Key::F6 + SDL_SCANCODE_F7, // Key::F7 + SDL_SCANCODE_F8, // Key::F8 + SDL_SCANCODE_F9, // Key::F9 + SDL_SCANCODE_F10, // Key::F10 + SDL_SCANCODE_F11, // Key::F11 + SDL_SCANCODE_F12, // Key::F12 + SDL_SCANCODE_F13, // Key::F13 + SDL_SCANCODE_F14, // Key::F14 + SDL_SCANCODE_F15, // Key::F15 + + // Flèches directionnelles + SDL_SCANCODE_DOWN, // Key::Down + SDL_SCANCODE_LEFT, // Key::Left + SDL_SCANCODE_RIGHT, // Key::Right + SDL_SCANCODE_UP, // Key::Up + + // Pavé numérique + SDL_SCANCODE_KP_PLUS, // Key::Add + SDL_SCANCODE_KP_PERIOD, // Key::Decimal + SDL_SCANCODE_KP_DIVIDE, // Key::Divide + SDL_SCANCODE_KP_MULTIPLY, // Key::Multiply + SDL_SCANCODE_KP_ENTER, // Key::NumpadReturn + SDL_SCANCODE_KP_0, // Key::Numpad0 + SDL_SCANCODE_KP_1, // Key::Numpad1 + SDL_SCANCODE_KP_2, // Key::Numpad2 + SDL_SCANCODE_KP_3, // Key::Numpad3 + SDL_SCANCODE_KP_4, // Key::Numpad4 + SDL_SCANCODE_KP_5, // Key::Numpad5 + SDL_SCANCODE_KP_6, // Key::Numpad6 + SDL_SCANCODE_KP_7, // Key::Numpad7 + SDL_SCANCODE_KP_8, // Key::Numpad8 + SDL_SCANCODE_KP_9, // Key::Numpad9 + SDL_SCANCODE_KP_MINUS, // Key::Subtract + + // Divers + SDL_SCANCODE_BACKSLASH, // Key::Backslash + SDL_SCANCODE_BACKSPACE, // Key::Backspace + SDL_SCANCODE_CLEAR, // Key::Clear + SDL_SCANCODE_COMMA, // Key::Comma, + SDL_SCANCODE_MINUS, // Key::Dash + SDL_SCANCODE_DELETE, // Key::Delete + SDL_SCANCODE_END, // Key::End + SDL_SCANCODE_EQUALS, // Key::Equal + SDL_SCANCODE_ESCAPE, // Key::Escape + SDL_SCANCODE_HOME, // Key::Home + SDL_SCANCODE_INSERT, // Key::Insert + SDL_SCANCODE_LALT, // Key::LAlt + SDL_SCANCODE_LEFTBRACKET, // Key::LBracket + SDL_SCANCODE_LCTRL, // Key::LControl + SDL_SCANCODE_LSHIFT, // Key::LShift + SDL_SCANCODE_LGUI, // Key::LSystem + SDL_SCANCODE_0, // Key::Num0 + SDL_SCANCODE_1, // Key::Num1 + SDL_SCANCODE_2, // Key::Num2 + SDL_SCANCODE_3, // Key::Num3 + SDL_SCANCODE_4, // Key::Num4 + SDL_SCANCODE_5, // Key::Num5 + SDL_SCANCODE_6, // Key::Num6 + SDL_SCANCODE_7, // Key::Num7 + SDL_SCANCODE_8, // Key::Num8 + SDL_SCANCODE_9, // Key::Num9 + SDL_SCANCODE_PAGEDOWN, // Key::PageDown + SDL_SCANCODE_PAGEUP, // Key::PageUp + SDL_SCANCODE_PAUSE, // Key::Pause + SDL_SCANCODE_PERIOD, // Key::Period + SDL_SCANCODE_SYSREQ, // Key::Print + SDL_SCANCODE_PRINTSCREEN, // Key::PrintScreen + SDL_SCANCODE_APOSTROPHE, // Key::Quote + SDL_SCANCODE_RALT, // Key::RAlt + SDL_SCANCODE_RIGHTBRACKET, // Key::RBracket + SDL_SCANCODE_RCTRL, // Key::RControl + SDL_SCANCODE_RETURN, // Key::Return + SDL_SCANCODE_RSHIFT, // Key::RShift + SDL_SCANCODE_RGUI, // Key::RSystem + SDL_SCANCODE_SEMICOLON, // Key::Semicolon + SDL_SCANCODE_SLASH, // Key::Slash + SDL_SCANCODE_SPACE, // Key::Space + SDL_SCANCODE_TAB, // Key::Tab + SDL_SCANCODE_GRAVE, // Key::Tilde + SDL_SCANCODE_APPLICATION, // Key::Menu + SDL_SCANCODE_NONUSBACKSLASH,// Key::ISOBackslash102 + + // Touches navigateur + SDL_SCANCODE_AC_BACK, // Key::Browser_Back + SDL_SCANCODE_AC_BOOKMARKS, // Key::Browser_Favorites + SDL_SCANCODE_AC_FORWARD, // Key::Browser_Forward + SDL_SCANCODE_AC_HOME, // Key::Browser_Home + SDL_SCANCODE_AC_REFRESH, // Key::Browser_Refresh + SDL_SCANCODE_AC_SEARCH, // Key::Browser_Search + SDL_SCANCODE_AC_STOP, // Key::Browser_Stop + + // Touches de contrôle + SDL_SCANCODE_AUDIONEXT, // Key::Media_Next, + SDL_SCANCODE_AUDIOPLAY, // Key::Media_PlayPause, + SDL_SCANCODE_AUDIOPREV, // Key::Media_Previous, + SDL_SCANCODE_AUDIOSTOP, // Key::Media_Stop, + + // Touches de contrôle du volume + SDL_SCANCODE_VOLUMEDOWN, // Key::Volume_Down + SDL_SCANCODE_MUTE, // Key::Volume_Mute + SDL_SCANCODE_VOLUMEUP, // Key::Volume_Up + + // Touches à verrouillage + SDL_SCANCODE_CAPSLOCK, // Key::CapsLock + SDL_SCANCODE_NUMLOCKCLEAR, // Key::NumLock + SDL_SCANCODE_SCROLLLOCK // Key::ScrollLock + }; + SDL_Keycode nzVKeyToSDLVKey[static_cast(Keyboard::VKey::Max) + 1] = { + // Keys + SDLK_a, // VKey::A + SDLK_b, // VKey::B + SDLK_c, // VKey::C + SDLK_d, // VKey::D + SDLK_e, // VKey::E + SDLK_f, // VKey::F + SDLK_g, // VKey::G + SDLK_h, // VKey::H + SDLK_i, // VKey::I + SDLK_j, // VKey::J + SDLK_k, // VKey::K + SDLK_l, // VKey::L + SDLK_m, // VKey::M + SDLK_n, // VKey::N + SDLK_o, // VKey::O + SDLK_p, // VKey::P + SDLK_q, // VKey::Q + SDLK_r, // VKey::R + SDLK_s, // VKey::S + SDLK_t, // VKey::T + SDLK_u, // VKey::U + SDLK_v, // VKey::V + SDLK_w, // VKey::W + SDLK_x, // VKey::X + SDLK_y, // VKey::Y + SDLK_z, // VKey::Z + + // Function keys + SDLK_F1, // VKey::F1 + SDLK_F2, // VKey::F2 + SDLK_F3, // VKey::F3 + SDLK_F4, // VKey::F4 + SDLK_F5, // VKey::F5 + SDLK_F6, // VKey::F6 + SDLK_F7, // VKey::F7 + SDLK_F8, // VKey::F8 + SDLK_F9, // VKey::F9 + SDLK_F10, // VKey::F10 + SDLK_F11, // VKey::F11 + SDLK_F12, // VKey::F12 + SDLK_F13, // VKey::F13 + SDLK_F14, // VKey::F14 + SDLK_F15, // VKey::F15 + + // Arrows + SDLK_DOWN, // VKey::Down + SDLK_LEFT, // VKey::Left + SDLK_RIGHT, // VKey::Right + SDLK_UP, // VKey::Up + + // Keypad + SDLK_KP_PLUS, // VKey::Add + SDLK_KP_PERIOD, // VKey::Decimal + SDLK_KP_DIVIDE, // VKey::Divide + SDLK_KP_MULTIPLY, // VKey::Multiply + SDLK_KP_ENTER, // VKey::NumpadReturn + SDLK_KP_0, // VKey::Numpad0 + SDLK_KP_1, // VKey::Numpad1 + SDLK_KP_2, // VKey::Numpad2 + SDLK_KP_3, // VKey::Numpad3 + SDLK_KP_4, // VKey::Numpad4 + SDLK_KP_5, // VKey::Numpad5 + SDLK_KP_6, // VKey::Numpad6 + SDLK_KP_7, // VKey::Numpad7 + SDLK_KP_8, // VKey::Numpad8 + SDLK_KP_9, // VKey::Numpad9 + SDLK_KP_MINUS, // VKey::Subtract + + // Divers + SDLK_BACKSLASH, // VKey::Backslash + SDLK_BACKSPACE, // VKey::Backspace + SDLK_CLEAR, // VKey::Clear + SDLK_COMMA, // VKey::Comma, + SDLK_MINUS, // VKey::Dash + SDLK_DELETE, // VKey::Delete + SDLK_END, // VKey::End + SDLK_EQUALS, // VKey::Equal + SDLK_ESCAPE, // VKey::Escape + SDLK_HOME, // VKey::Home + SDLK_INSERT, // VKey::Insert + SDLK_LALT, // VKey::LAlt + SDLK_LEFTBRACKET, // VKey::LBracket + SDLK_LCTRL, // VKey::LControl + SDLK_LSHIFT, // VKey::LShift + SDLK_LGUI, // VKey::LSystem + SDLK_0, // VKey::Num0 + SDLK_1, // VKey::Num1 + SDLK_2, // VKey::Num2 + SDLK_3, // VKey::Num3 + SDLK_4, // VKey::Num4 + SDLK_5, // VKey::Num5 + SDLK_6, // VKey::Num6 + SDLK_7, // VKey::Num7 + SDLK_8, // VKey::Num8 + SDLK_9, // VKey::Num9 + SDLK_PAGEDOWN, // VKey::PageDown + SDLK_PAGEUP, // VKey::PageUp + SDLK_PAUSE, // VKey::Pause + SDLK_PERIOD, // VKey::Period + SDLK_SYSREQ, // VKey::Print + SDLK_PRINTSCREEN, // VKey::PrintScreen + SDLK_QUOTE, // VKey::Quote + SDLK_RALT, // VKey::RAlt + SDLK_RIGHTBRACKET, // VKey::RBracket + SDLK_RCTRL, // VKey::RControl + SDLK_RETURN, // VKey::Return + SDLK_RSHIFT, // VKey::RShift + SDLK_RGUI, // VKey::RSystem + SDLK_SEMICOLON, // VKey::Semicolon + SDLK_SLASH, // VKey::Slash + SDLK_SPACE, // VKey::Space + SDLK_TAB, // VKey::Tab + SDLK_BACKQUOTE, // VKey::Tilde + SDLK_APPLICATION, // VKey::Menu + SDLK_UNKNOWN, // VKey::ISOBackslash102 + + // Browser control + SDLK_AC_BACK, // VKey::Browser_Back + SDLK_AC_BOOKMARKS, // VKey::Browser_Favorites + SDLK_AC_FORWARD, // VKey::Browser_Forward + SDLK_AC_HOME, // VKey::Browser_Home + SDLK_AC_REFRESH, // VKey::Browser_Refresh + SDLK_AC_SEARCH, // VKey::Browser_Search + SDLK_AC_STOP, // VKey::Browser_Stop + + // Audio control + SDLK_AUDIONEXT, // VKey::Media_Next, + SDLK_AUDIOPLAY, // VKey::Media_PlayPause, + SDLK_AUDIOPREV, // VKey::Media_Previous, + SDLK_AUDIOSTOP, // VKey::Media_Stop, + + // Volume control + SDLK_VOLUMEDOWN, // VKey::Volume_Down + SDLK_MUTE, // VKey::Volume_Mute + SDLK_VOLUMEUP, // VKey::Volume_Up + + // Lock keys + SDLK_CAPSLOCK, // VKey::CapsLock + SDLK_NUMLOCKCLEAR, // VKey::NumLock + SDLK_SCROLLLOCK // VKey::ScrollLock + }; + } + + Keyboard::Scancode SDLHelper::FromSDL(SDL_Scancode scancode) + { + switch (scancode) + { + case SDL_SCANCODE_LCTRL: return Keyboard::Scancode::LControl; + case SDL_SCANCODE_RCTRL: return Keyboard::Scancode::RControl; + case SDL_SCANCODE_LALT: return Keyboard::Scancode::LAlt; + case SDL_SCANCODE_RALT: return Keyboard::Scancode::RAlt; + case SDL_SCANCODE_LSHIFT: return Keyboard::Scancode::LShift; + case SDL_SCANCODE_RSHIFT: return Keyboard::Scancode::RShift; + + case SDL_SCANCODE_0: return Keyboard::Scancode::Num0; + case SDL_SCANCODE_1: return Keyboard::Scancode::Num1; + case SDL_SCANCODE_2: return Keyboard::Scancode::Num2; + case SDL_SCANCODE_3: return Keyboard::Scancode::Num3; + case SDL_SCANCODE_4: return Keyboard::Scancode::Num4; + case SDL_SCANCODE_5: return Keyboard::Scancode::Num5; + case SDL_SCANCODE_6: return Keyboard::Scancode::Num6; + case SDL_SCANCODE_7: return Keyboard::Scancode::Num7; + case SDL_SCANCODE_8: return Keyboard::Scancode::Num8; + case SDL_SCANCODE_9: return Keyboard::Scancode::Num9; + case SDL_SCANCODE_A: return Keyboard::Scancode::A; + case SDL_SCANCODE_B: return Keyboard::Scancode::B; + case SDL_SCANCODE_C: return Keyboard::Scancode::C; + case SDL_SCANCODE_D: return Keyboard::Scancode::D; + case SDL_SCANCODE_E: return Keyboard::Scancode::E; + case SDL_SCANCODE_F: return Keyboard::Scancode::F; + case SDL_SCANCODE_G: return Keyboard::Scancode::G; + case SDL_SCANCODE_H: return Keyboard::Scancode::H; + case SDL_SCANCODE_I: return Keyboard::Scancode::I; + case SDL_SCANCODE_J: return Keyboard::Scancode::J; + case SDL_SCANCODE_K: return Keyboard::Scancode::K; + case SDL_SCANCODE_L: return Keyboard::Scancode::L; + case SDL_SCANCODE_M: return Keyboard::Scancode::M; + case SDL_SCANCODE_N: return Keyboard::Scancode::N; + case SDL_SCANCODE_O: return Keyboard::Scancode::O; + case SDL_SCANCODE_P: return Keyboard::Scancode::P; + case SDL_SCANCODE_Q: return Keyboard::Scancode::Q; + case SDL_SCANCODE_R: return Keyboard::Scancode::R; + case SDL_SCANCODE_S: return Keyboard::Scancode::S; + case SDL_SCANCODE_T: return Keyboard::Scancode::T; + case SDL_SCANCODE_U: return Keyboard::Scancode::U; + case SDL_SCANCODE_V: return Keyboard::Scancode::V; + case SDL_SCANCODE_W: return Keyboard::Scancode::W; + case SDL_SCANCODE_X: return Keyboard::Scancode::X; + case SDL_SCANCODE_Y: return Keyboard::Scancode::Y; + case SDL_SCANCODE_Z: return Keyboard::Scancode::Z; + case SDL_SCANCODE_KP_PLUS: return Keyboard::Scancode::Add; + case SDL_SCANCODE_BACKSPACE: return Keyboard::Scancode::Backspace; + case SDL_SCANCODE_AC_BACK: return Keyboard::Scancode::Browser_Back; + case SDL_SCANCODE_AC_BOOKMARKS: return Keyboard::Scancode::Browser_Favorites; + case SDL_SCANCODE_AC_FORWARD: return Keyboard::Scancode::Browser_Forward; + case SDL_SCANCODE_AC_HOME: return Keyboard::Scancode::Browser_Home; + case SDL_SCANCODE_AC_REFRESH: return Keyboard::Scancode::Browser_Refresh; + case SDL_SCANCODE_AC_SEARCH: return Keyboard::Scancode::Browser_Search; + case SDL_SCANCODE_AC_STOP: return Keyboard::Scancode::Browser_Stop; + case SDL_SCANCODE_CAPSLOCK: return Keyboard::Scancode::CapsLock; + case SDL_SCANCODE_CLEAR: return Keyboard::Scancode::Clear; + case SDL_SCANCODE_KP_PERIOD: return Keyboard::Scancode::Decimal; + case SDL_SCANCODE_DELETE: return Keyboard::Scancode::Delete; + case SDL_SCANCODE_KP_DIVIDE: return Keyboard::Scancode::Divide; + case SDL_SCANCODE_DOWN: return Keyboard::Scancode::Down; + case SDL_SCANCODE_END: return Keyboard::Scancode::End; + case SDL_SCANCODE_ESCAPE: return Keyboard::Scancode::Escape; + case SDL_SCANCODE_F1: return Keyboard::Scancode::F1; + case SDL_SCANCODE_F2: return Keyboard::Scancode::F2; + case SDL_SCANCODE_F3: return Keyboard::Scancode::F3; + case SDL_SCANCODE_F4: return Keyboard::Scancode::F4; + case SDL_SCANCODE_F5: return Keyboard::Scancode::F5; + case SDL_SCANCODE_F6: return Keyboard::Scancode::F6; + case SDL_SCANCODE_F7: return Keyboard::Scancode::F7; + case SDL_SCANCODE_F8: return Keyboard::Scancode::F8; + case SDL_SCANCODE_F9: return Keyboard::Scancode::F9; + case SDL_SCANCODE_F10: return Keyboard::Scancode::F10; + case SDL_SCANCODE_F11: return Keyboard::Scancode::F11; + case SDL_SCANCODE_F12: return Keyboard::Scancode::F12; + case SDL_SCANCODE_F13: return Keyboard::Scancode::F13; + case SDL_SCANCODE_F14: return Keyboard::Scancode::F14; + case SDL_SCANCODE_F15: return Keyboard::Scancode::F15; + case SDL_SCANCODE_HOME: return Keyboard::Scancode::Home; + case SDL_SCANCODE_INSERT: return Keyboard::Scancode::Insert; + case SDL_SCANCODE_LEFT: return Keyboard::Scancode::Left; + case SDL_SCANCODE_LGUI: return Keyboard::Scancode::LSystem; + case SDL_SCANCODE_AUDIONEXT: return Keyboard::Scancode::Media_Next; + case SDL_SCANCODE_AUDIOPLAY: return Keyboard::Scancode::Media_Play; + case SDL_SCANCODE_AUDIOPREV: return Keyboard::Scancode::Media_Previous; + case SDL_SCANCODE_AUDIOSTOP: return Keyboard::Scancode::Media_Stop; + case SDL_SCANCODE_KP_MULTIPLY: return Keyboard::Scancode::Multiply; + case SDL_SCANCODE_PAGEDOWN: return Keyboard::Scancode::PageDown; + case SDL_SCANCODE_KP_0: return Keyboard::Scancode::Numpad0; + case SDL_SCANCODE_KP_1: return Keyboard::Scancode::Numpad1; + case SDL_SCANCODE_KP_2: return Keyboard::Scancode::Numpad2; + case SDL_SCANCODE_KP_3: return Keyboard::Scancode::Numpad3; + case SDL_SCANCODE_KP_4: return Keyboard::Scancode::Numpad4; + case SDL_SCANCODE_KP_5: return Keyboard::Scancode::Numpad5; + case SDL_SCANCODE_KP_6: return Keyboard::Scancode::Numpad6; + case SDL_SCANCODE_KP_7: return Keyboard::Scancode::Numpad7; + case SDL_SCANCODE_KP_8: return Keyboard::Scancode::Numpad8; + case SDL_SCANCODE_KP_9: return Keyboard::Scancode::Numpad9; + case SDL_SCANCODE_NUMLOCKCLEAR: return Keyboard::Scancode::NumLock; + case SDL_SCANCODE_SEMICOLON: return Keyboard::Scancode::Semicolon; + case SDL_SCANCODE_SLASH: return Keyboard::Scancode::Slash; + case SDL_SCANCODE_GRAVE: return Keyboard::Scancode::Tilde; + case SDL_SCANCODE_APPLICATION: return Keyboard::Scancode::Menu; + case SDL_SCANCODE_NONUSBACKSLASH: return Keyboard::Scancode::ISOBackslash102; + case SDL_SCANCODE_LEFTBRACKET: return Keyboard::Scancode::LBracket; + case SDL_SCANCODE_BACKSLASH: return Keyboard::Scancode::Backslash; + case SDL_SCANCODE_RIGHTBRACKET: return Keyboard::Scancode::RBracket; + case SDL_SCANCODE_APOSTROPHE: return Keyboard::Scancode::Quote; + case SDL_SCANCODE_COMMA: return Keyboard::Scancode::Comma; + case SDL_SCANCODE_MINUS: return Keyboard::Scancode::Dash; + case SDL_SCANCODE_PERIOD: return Keyboard::Scancode::Period; + case SDL_SCANCODE_EQUALS: return Keyboard::Scancode::Equal; + case SDL_SCANCODE_RIGHT: return Keyboard::Scancode::Right; + case SDL_SCANCODE_PAGEUP: return Keyboard::Scancode::PageUp; + case SDL_SCANCODE_PAUSE: return Keyboard::Scancode::Pause; + case SDL_SCANCODE_SYSREQ: return Keyboard::Scancode::Print; + case SDL_SCANCODE_SCROLLLOCK: return Keyboard::Scancode::ScrollLock; + case SDL_SCANCODE_PRINTSCREEN: return Keyboard::Scancode::PrintScreen; + case SDL_SCANCODE_KP_MINUS: return Keyboard::Scancode::Subtract; + case SDL_SCANCODE_RETURN: return Keyboard::Scancode::Return; + case SDL_SCANCODE_KP_ENTER: return Keyboard::Scancode::NumpadReturn; + case SDL_SCANCODE_RGUI: return Keyboard::Scancode::RSystem; + case SDL_SCANCODE_SPACE: return Keyboard::Scancode::Space; + case SDL_SCANCODE_TAB: return Keyboard::Scancode::Tab; + case SDL_SCANCODE_UP: return Keyboard::Scancode::Up; + case SDL_SCANCODE_VOLUMEDOWN: return Keyboard::Scancode::Volume_Down; + case SDL_SCANCODE_MUTE: return Keyboard::Scancode::Volume_Mute; + case SDL_SCANCODE_AUDIOMUTE: return Keyboard::Scancode::Volume_Mute; + case SDL_SCANCODE_VOLUMEUP: return Keyboard::Scancode::Volume_Up; + + default: + return Keyboard::Scancode::Undefined; + } + } + + Keyboard::VKey SDLHelper::FromSDL(SDL_Keycode keycode) + { + switch (keycode) + { + case SDLK_LCTRL: return Keyboard::VKey::LControl; + case SDLK_RCTRL: return Keyboard::VKey::RControl; + case SDLK_LALT: return Keyboard::VKey::LAlt; + case SDLK_RALT: return Keyboard::VKey::RAlt; + case SDLK_LSHIFT: return Keyboard::VKey::LShift; + case SDLK_RSHIFT: return Keyboard::VKey::RShift; + + case SDLK_0: return Keyboard::VKey::Num0; + case SDLK_1: return Keyboard::VKey::Num1; + case SDLK_2: return Keyboard::VKey::Num2; + case SDLK_3: return Keyboard::VKey::Num3; + case SDLK_4: return Keyboard::VKey::Num4; + case SDLK_5: return Keyboard::VKey::Num5; + case SDLK_6: return Keyboard::VKey::Num6; + case SDLK_7: return Keyboard::VKey::Num7; + case SDLK_8: return Keyboard::VKey::Num8; + case SDLK_9: return Keyboard::VKey::Num9; + case SDLK_a: return Keyboard::VKey::A; + case SDLK_b: return Keyboard::VKey::B; + case SDLK_c: return Keyboard::VKey::C; + case SDLK_d: return Keyboard::VKey::D; + case SDLK_e: return Keyboard::VKey::E; + case SDLK_f: return Keyboard::VKey::F; + case SDLK_g: return Keyboard::VKey::G; + case SDLK_h: return Keyboard::VKey::H; + case SDLK_i: return Keyboard::VKey::I; + case SDLK_j: return Keyboard::VKey::J; + case SDLK_k: return Keyboard::VKey::K; + case SDLK_l: return Keyboard::VKey::L; + case SDLK_m: return Keyboard::VKey::M; + case SDLK_n: return Keyboard::VKey::N; + case SDLK_o: return Keyboard::VKey::O; + case SDLK_p: return Keyboard::VKey::P; + case SDLK_q: return Keyboard::VKey::Q; + case SDLK_r: return Keyboard::VKey::R; + case SDLK_s: return Keyboard::VKey::S; + case SDLK_t: return Keyboard::VKey::T; + case SDLK_u: return Keyboard::VKey::U; + case SDLK_v: return Keyboard::VKey::V; + case SDLK_w: return Keyboard::VKey::W; + case SDLK_x: return Keyboard::VKey::X; + case SDLK_y: return Keyboard::VKey::Y; + case SDLK_z: return Keyboard::VKey::Z; + case SDLK_KP_PLUS: return Keyboard::VKey::Add; + case SDLK_BACKSPACE: return Keyboard::VKey::Backspace; + case SDLK_AC_BACK: return Keyboard::VKey::Browser_Back; + case SDLK_AC_BOOKMARKS: return Keyboard::VKey::Browser_Favorites; + case SDLK_AC_FORWARD: return Keyboard::VKey::Browser_Forward; + case SDLK_AC_HOME: return Keyboard::VKey::Browser_Home; + case SDLK_AC_REFRESH: return Keyboard::VKey::Browser_Refresh; + case SDLK_AC_SEARCH: return Keyboard::VKey::Browser_Search; + case SDLK_AC_STOP: return Keyboard::VKey::Browser_Stop; + case SDLK_CAPSLOCK: return Keyboard::VKey::CapsLock; + case SDLK_CLEAR: return Keyboard::VKey::Clear; + case SDLK_KP_PERIOD: return Keyboard::VKey::Decimal; + case SDLK_DELETE: return Keyboard::VKey::Delete; + case SDLK_KP_DIVIDE: return Keyboard::VKey::Divide; + case SDLK_DOWN: return Keyboard::VKey::Down; + case SDLK_END: return Keyboard::VKey::End; + case SDLK_ESCAPE: return Keyboard::VKey::Escape; + case SDLK_F1: return Keyboard::VKey::F1; + case SDLK_F2: return Keyboard::VKey::F2; + case SDLK_F3: return Keyboard::VKey::F3; + case SDLK_F4: return Keyboard::VKey::F4; + case SDLK_F5: return Keyboard::VKey::F5; + case SDLK_F6: return Keyboard::VKey::F6; + case SDLK_F7: return Keyboard::VKey::F7; + case SDLK_F8: return Keyboard::VKey::F8; + case SDLK_F9: return Keyboard::VKey::F9; + case SDLK_F10: return Keyboard::VKey::F10; + case SDLK_F11: return Keyboard::VKey::F11; + case SDLK_F12: return Keyboard::VKey::F12; + case SDLK_F13: return Keyboard::VKey::F13; + case SDLK_F14: return Keyboard::VKey::F14; + case SDLK_F15: return Keyboard::VKey::F15; + case SDLK_HOME: return Keyboard::VKey::Home; + case SDLK_INSERT: return Keyboard::VKey::Insert; + case SDLK_LEFT: return Keyboard::VKey::Left; + case SDLK_LGUI: return Keyboard::VKey::LSystem; + case SDLK_AUDIONEXT: return Keyboard::VKey::Media_Next; + case SDLK_AUDIOPLAY: return Keyboard::VKey::Media_Play; + case SDLK_AUDIOPREV: return Keyboard::VKey::Media_Previous; + case SDLK_AUDIOSTOP: return Keyboard::VKey::Media_Stop; + case SDLK_KP_MULTIPLY: return Keyboard::VKey::Multiply; + case SDLK_PAGEDOWN: return Keyboard::VKey::PageDown; + case SDLK_KP_0: return Keyboard::VKey::Numpad0; + case SDLK_KP_1: return Keyboard::VKey::Numpad1; + case SDLK_KP_2: return Keyboard::VKey::Numpad2; + case SDLK_KP_3: return Keyboard::VKey::Numpad3; + case SDLK_KP_4: return Keyboard::VKey::Numpad4; + case SDLK_KP_5: return Keyboard::VKey::Numpad5; + case SDLK_KP_6: return Keyboard::VKey::Numpad6; + case SDLK_KP_7: return Keyboard::VKey::Numpad7; + case SDLK_KP_8: return Keyboard::VKey::Numpad8; + case SDLK_KP_9: return Keyboard::VKey::Numpad9; + case SDLK_NUMLOCKCLEAR: return Keyboard::VKey::NumLock; + case SDLK_SEMICOLON: return Keyboard::VKey::Semicolon; + case SDLK_SLASH: return Keyboard::VKey::Slash; + case SDLK_BACKQUOTE: return Keyboard::VKey::Tilde; + case SDLK_APPLICATION: return Keyboard::VKey::Menu; + case SDLK_LEFTBRACKET: return Keyboard::VKey::LBracket; + case SDLK_BACKSLASH: return Keyboard::VKey::Backslash; + case SDLK_RIGHTBRACKET: return Keyboard::VKey::RBracket; + case SDLK_QUOTE: return Keyboard::VKey::Quote; + case SDLK_COMMA: return Keyboard::VKey::Comma; + case SDLK_MINUS: return Keyboard::VKey::Dash; + case SDLK_PERIOD: return Keyboard::VKey::Period; + case SDLK_EQUALS: return Keyboard::VKey::Equal; + case SDLK_RIGHT: return Keyboard::VKey::Right; + case SDLK_PAGEUP: return Keyboard::VKey::PageUp; + case SDLK_PAUSE: return Keyboard::VKey::Pause; + case SDLK_SYSREQ: return Keyboard::VKey::Print; + case SDLK_SCROLLLOCK: return Keyboard::VKey::ScrollLock; + case SDLK_PRINTSCREEN: return Keyboard::VKey::PrintScreen; + case SDLK_KP_MINUS: return Keyboard::VKey::Subtract; + case SDLK_RETURN: return Keyboard::VKey::Return; + case SDLK_KP_ENTER: return Keyboard::VKey::NumpadReturn; + case SDLK_RGUI: return Keyboard::VKey::RSystem; + case SDLK_SPACE: return Keyboard::VKey::Space; + case SDLK_TAB: return Keyboard::VKey::Tab; + case SDLK_UP: return Keyboard::VKey::Up; + case SDLK_VOLUMEDOWN: return Keyboard::VKey::Volume_Down; + case SDLK_MUTE: return Keyboard::VKey::Volume_Mute; + case SDLK_AUDIOMUTE: return Keyboard::VKey::Volume_Mute; + case SDLK_VOLUMEUP: return Keyboard::VKey::Volume_Up; + + default: + return Keyboard::VKey::Undefined; + } + } + + SDL_Scancode SDLHelper::ToSDL(Keyboard::Scancode scancode) + { + if (scancode == Keyboard::Scancode::Undefined) + return SDL_SCANCODE_UNKNOWN; + + return nzScancodeToSDLScanCode[static_cast(scancode)]; + } + + SDL_Keycode SDLHelper::ToSDL(Keyboard::VKey keycode) + { + if (keycode == Keyboard::VKey::Undefined) + return SDLK_UNKNOWN; + + return nzVKeyToSDLVKey[static_cast(keycode)]; + } + +} diff --git a/src/Nazara/Platform/SDL2/SDLHelper.hpp b/src/Nazara/Platform/SDL2/SDLHelper.hpp new file mode 100644 index 000000000..700e111a8 --- /dev/null +++ b/src/Nazara/Platform/SDL2/SDLHelper.hpp @@ -0,0 +1,26 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Platform module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_SDL2_HELPER_HPP +#define NAZARA_SDL2_HELPER_HPP + +#include +#include +#include + +namespace Nz +{ + class SDLHelper + { + public: + static Keyboard::Scancode FromSDL(SDL_Scancode scancode); + static Keyboard::VKey FromSDL(SDL_Keycode keycode); + static SDL_Scancode ToSDL(Keyboard::Scancode scancode); + static SDL_Keycode ToSDL(Keyboard::VKey keycode); + }; +} + +#endif // NAZARA_SDL2_HELPER_HPP diff --git a/src/Nazara/Platform/SDL2/WindowImpl.cpp b/src/Nazara/Platform/SDL2/WindowImpl.cpp index f44ca8fe5..6b9b18f5e 100644 --- a/src/Nazara/Platform/SDL2/WindowImpl.cpp +++ b/src/Nazara/Platform/SDL2/WindowImpl.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -315,7 +316,7 @@ namespace Nz if (SDL_GetWindowID(window->m_handle) != event->motion.windowID) return 0; - if (window->m_ignoreNextMouseMove && event->motion.x == window->m_mousePos.x && event->motion.y == window->m_mousePos.y) + if (window->m_ignoreNextMouseMove /*&& event->motion.x == window->m_mousePos.x && event->motion.y == window->m_mousePos.y*/) { window->m_ignoreNextMouseMove = false; @@ -378,7 +379,8 @@ namespace Nz evt.type = WindowEventType_KeyPressed; - evt.key.code = SDLKeySymToNazaraKey(event->key.keysym); + evt.key.scancode = SDLHelper::FromSDL(event->key.keysym.scancode); + evt.key.virtualKey = SDLHelper::FromSDL(event->key.keysym.sym); evt.key.alt = (event->key.keysym.mod & KMOD_ALT) != 0; evt.key.control = (event->key.keysym.mod & KMOD_CTRL) != 0; evt.key.repeated = event->key.repeat != 0; @@ -393,7 +395,8 @@ namespace Nz evt.type = WindowEventType_KeyReleased; - evt.key.code = SDLKeySymToNazaraKey(event->key.keysym); + evt.key.scancode = SDLHelper::FromSDL(event->key.keysym.scancode); + evt.key.virtualKey = SDLHelper::FromSDL(event->key.keysym.sym); evt.key.alt = (event->key.keysym.mod & KMOD_ALT) != 0; evt.key.control = (event->key.keysym.mod & KMOD_CTRL) != 0; evt.key.repeated = event->key.repeat != 0; @@ -533,144 +536,6 @@ namespace Nz SDL_Quit(); } - Keyboard::Key WindowImpl::SDLKeySymToNazaraKey(SDL_Keysym& keysym) - { - auto key = keysym.scancode; - - switch (key) - { - case SDL_SCANCODE_LCTRL: return Keyboard::LControl; - case SDL_SCANCODE_RCTRL: return Keyboard::RControl; - case SDL_SCANCODE_LALT: return Keyboard::LAlt; - case SDL_SCANCODE_RALT: return Keyboard::RAlt; - case SDL_SCANCODE_LSHIFT: return Keyboard::LShift; - case SDL_SCANCODE_RSHIFT: return Keyboard::RShift; - - case SDL_SCANCODE_0: return Keyboard::Num0; - case SDL_SCANCODE_1: return Keyboard::Num1; - case SDL_SCANCODE_2: return Keyboard::Num2; - case SDL_SCANCODE_3: return Keyboard::Num3; - case SDL_SCANCODE_4: return Keyboard::Num4; - case SDL_SCANCODE_5: return Keyboard::Num5; - case SDL_SCANCODE_6: return Keyboard::Num6; - case SDL_SCANCODE_7: return Keyboard::Num7; - case SDL_SCANCODE_8: return Keyboard::Num8; - case SDL_SCANCODE_9: return Keyboard::Num9; - case SDL_SCANCODE_A: return Keyboard::A; - case SDL_SCANCODE_B: return Keyboard::B; - case SDL_SCANCODE_C: return Keyboard::C; - case SDL_SCANCODE_D: return Keyboard::D; - case SDL_SCANCODE_E: return Keyboard::E; - case SDL_SCANCODE_F: return Keyboard::F; - case SDL_SCANCODE_G: return Keyboard::G; - case SDL_SCANCODE_H: return Keyboard::H; - case SDL_SCANCODE_I: return Keyboard::I; - case SDL_SCANCODE_J: return Keyboard::J; - case SDL_SCANCODE_K: return Keyboard::K; - case SDL_SCANCODE_L: return Keyboard::L; - case SDL_SCANCODE_M: return Keyboard::M; - case SDL_SCANCODE_N: return Keyboard::N; - case SDL_SCANCODE_O: return Keyboard::O; - case SDL_SCANCODE_P: return Keyboard::P; - case SDL_SCANCODE_Q: return Keyboard::Q; - case SDL_SCANCODE_R: return Keyboard::R; - case SDL_SCANCODE_S: return Keyboard::S; - case SDL_SCANCODE_T: return Keyboard::T; - case SDL_SCANCODE_U: return Keyboard::U; - case SDL_SCANCODE_V: return Keyboard::V; - case SDL_SCANCODE_W: return Keyboard::W; - case SDL_SCANCODE_X: return Keyboard::X; - case SDL_SCANCODE_Y: return Keyboard::Y; - case SDL_SCANCODE_Z: return Keyboard::Z; - case SDL_SCANCODE_KP_PLUS: return Keyboard::Add; - case SDL_SCANCODE_BACKSPACE: return Keyboard::Backspace; - case SDL_SCANCODE_AC_BACK: return Keyboard::Browser_Back; - case SDL_SCANCODE_AC_BOOKMARKS: return Keyboard::Browser_Favorites; - case SDL_SCANCODE_AC_FORWARD: return Keyboard::Browser_Forward; - case SDL_SCANCODE_AC_HOME: return Keyboard::Browser_Home; - case SDL_SCANCODE_AC_REFRESH: return Keyboard::Browser_Refresh; - case SDL_SCANCODE_AC_SEARCH: return Keyboard::Browser_Search; - case SDL_SCANCODE_AC_STOP: return Keyboard::Browser_Stop; - case SDL_SCANCODE_CAPSLOCK: return Keyboard::CapsLock; - case SDL_SCANCODE_CLEAR: return Keyboard::Clear; - case SDL_SCANCODE_KP_PERIOD: return Keyboard::Decimal; - case SDL_SCANCODE_DELETE: return Keyboard::Delete; - case SDL_SCANCODE_KP_DIVIDE: return Keyboard::Divide; - case SDL_SCANCODE_DOWN: return Keyboard::Down; - case SDL_SCANCODE_END: return Keyboard::End; - case SDL_SCANCODE_ESCAPE: return Keyboard::Escape; - case SDL_SCANCODE_F1: return Keyboard::F1; - case SDL_SCANCODE_F2: return Keyboard::F2; - case SDL_SCANCODE_F3: return Keyboard::F3; - case SDL_SCANCODE_F4: return Keyboard::F4; - case SDL_SCANCODE_F5: return Keyboard::F5; - case SDL_SCANCODE_F6: return Keyboard::F6; - case SDL_SCANCODE_F7: return Keyboard::F7; - case SDL_SCANCODE_F8: return Keyboard::F8; - case SDL_SCANCODE_F9: return Keyboard::F9; - case SDL_SCANCODE_F10: return Keyboard::F10; - case SDL_SCANCODE_F11: return Keyboard::F11; - case SDL_SCANCODE_F12: return Keyboard::F12; - case SDL_SCANCODE_F13: return Keyboard::F13; - case SDL_SCANCODE_F14: return Keyboard::F14; - case SDL_SCANCODE_F15: return Keyboard::F15; - case SDL_SCANCODE_HOME: return Keyboard::Home; - case SDL_SCANCODE_INSERT: return Keyboard::Insert; - case SDL_SCANCODE_LEFT: return Keyboard::Left; - case SDL_SCANCODE_LGUI: return Keyboard::LSystem; - case SDL_SCANCODE_AUDIONEXT: return Keyboard::Media_Next; - case SDL_SCANCODE_AUDIOPLAY: return Keyboard::Media_Play; - case SDL_SCANCODE_AUDIOPREV: return Keyboard::Media_Previous; - case SDL_SCANCODE_AUDIOSTOP: return Keyboard::Media_Stop; - case SDL_SCANCODE_KP_MULTIPLY: return Keyboard::Multiply; - case SDL_SCANCODE_PAGEDOWN: return Keyboard::PageDown; - case SDL_SCANCODE_KP_0: return Keyboard::Numpad0; - case SDL_SCANCODE_KP_1: return Keyboard::Numpad1; - case SDL_SCANCODE_KP_2: return Keyboard::Numpad2; - case SDL_SCANCODE_KP_3: return Keyboard::Numpad3; - case SDL_SCANCODE_KP_4: return Keyboard::Numpad4; - case SDL_SCANCODE_KP_5: return Keyboard::Numpad5; - case SDL_SCANCODE_KP_6: return Keyboard::Numpad6; - case SDL_SCANCODE_KP_7: return Keyboard::Numpad7; - case SDL_SCANCODE_KP_8: return Keyboard::Numpad8; - case SDL_SCANCODE_KP_9: return Keyboard::Numpad9; - case SDL_SCANCODE_NUMLOCKCLEAR: return Keyboard::NumLock; - case SDL_SCANCODE_SEMICOLON: return Keyboard::Semicolon; - case SDL_SCANCODE_SLASH: return Keyboard::Slash; - case SDL_SCANCODE_GRAVE: return Keyboard::Tilde; - case SDL_SCANCODE_APPLICATION: return Keyboard::Menu; - case SDL_SCANCODE_NONUSBACKSLASH: return Keyboard::ISOBackslash102; - case SDL_SCANCODE_LEFTBRACKET: return Keyboard::LBracket; - case SDL_SCANCODE_BACKSLASH: return Keyboard::Backslash; - case SDL_SCANCODE_RIGHTBRACKET: return Keyboard::RBracket; - case SDL_SCANCODE_APOSTROPHE: return Keyboard::Quote; - case SDL_SCANCODE_COMMA: return Keyboard::Comma; - case SDL_SCANCODE_MINUS: return Keyboard::Dash; - case SDL_SCANCODE_PERIOD: return Keyboard::Period; - case SDL_SCANCODE_EQUALS: return Keyboard::Equal; - case SDL_SCANCODE_RIGHT: return Keyboard::Right; - case SDL_SCANCODE_PAGEUP: return Keyboard::PageUp; - case SDL_SCANCODE_PAUSE: return Keyboard::Pause; - case SDL_SCANCODE_SYSREQ: return Keyboard::Print; - case SDL_SCANCODE_SCROLLLOCK: return Keyboard::ScrollLock; - case SDL_SCANCODE_PRINTSCREEN: return Keyboard::PrintScreen; - case SDL_SCANCODE_KP_MINUS: return Keyboard::Subtract; - case SDL_SCANCODE_RETURN: return Keyboard::Return; - case SDL_SCANCODE_KP_ENTER: return Keyboard::NumpadReturn; - case SDL_SCANCODE_RGUI: return Keyboard::RSystem; - case SDL_SCANCODE_SPACE: return Keyboard::Space; - case SDL_SCANCODE_TAB: return Keyboard::Tab; - case SDL_SCANCODE_UP: return Keyboard::Up; - case SDL_SCANCODE_VOLUMEDOWN: return Keyboard::Volume_Down; - case SDL_SCANCODE_MUTE: return Keyboard::Volume_Mute; - case SDL_SCANCODE_AUDIOMUTE: return Keyboard::Volume_Mute; - case SDL_SCANCODE_VOLUMEUP: return Keyboard::Volume_Up; - - default: - return Keyboard::Undefined; - } - } - // not implemented for now, wait for mainloop friendly input //void WindowImpl::WindowThread(SDL_Window* handle, /*DWORD styleEx,*/ const String& title, /*DWORD style,*/ bool fullscreen, const Rectui& dimensions, WindowImpl* window, Mutex* mutex, ConditionVariable* condition) //{ diff --git a/src/Nazara/Platform/SDL2/WindowImpl.hpp b/src/Nazara/Platform/SDL2/WindowImpl.hpp index b983d2881..7cccb5b1c 100644 --- a/src/Nazara/Platform/SDL2/WindowImpl.hpp +++ b/src/Nazara/Platform/SDL2/WindowImpl.hpp @@ -85,7 +85,6 @@ namespace Nz void PrepareWindow(bool fullscreen); - static Keyboard::Key SDLKeySymToNazaraKey(SDL_Keysym& keysym); //static void WindowThread(SDL_Window* handle, /*DWORD styleEx,*/ const String& title, /*DWORD style,*/ bool fullscreen, const Rectui& dimensions, WindowImpl* window, Mutex* mutex, ConditionVariable* condition); SDL_Cursor* m_cursor; diff --git a/src/Nazara/Renderer/Context.cpp b/src/Nazara/Renderer/Context.cpp index 0efb6ec61..7b4c62c9a 100644 --- a/src/Nazara/Renderer/Context.cpp +++ b/src/Nazara/Renderer/Context.cpp @@ -14,7 +14,6 @@ #if defined(NAZARA_PLATFORM_SDL2) #include - #define CALLBACK #elif defined(NAZARA_PLATFORM_WINDOWS) #include #elif defined(NAZARA_PLATFORM_GLX) diff --git a/src/Nazara/Renderer/OpenGL.cpp b/src/Nazara/Renderer/OpenGL.cpp index aea268456..6228aebad 100644 --- a/src/Nazara/Renderer/OpenGL.cpp +++ b/src/Nazara/Renderer/OpenGL.cpp @@ -1045,8 +1045,7 @@ namespace Nz glInvalidateBufferData = reinterpret_cast(LoadEntry("glInvalidateBufferData", false)); glVertexAttribLPointer = reinterpret_cast(LoadEntry("glVertexAttribLPointer", false)); - #if defined(NAZARA_PLATFORM_SDL2) - #elif defined(NAZARA_PLATFORM_WINDOWS) + #if defined(NAZARA_PLATFORM_WINDOWS) wglGetExtensionsStringARB = reinterpret_cast(LoadEntry("wglGetExtensionsStringARB", false)); wglGetExtensionsStringEXT = reinterpret_cast(LoadEntry("wglGetExtensionsStringEXT", false)); wglSwapInterval = reinterpret_cast(LoadEntry("wglSwapIntervalEXT", false)); @@ -1064,7 +1063,7 @@ namespace Nz NazaraWarning("Failed to load extension system"); } - #ifdef NAZARA_PLATFORM_WINDOWS + #if defined(NAZARA_PLATFORM_WINDOWS) && !defined(NAZARA_PLATFORM_SDL2) { bool loaded; if (wglGetExtensionsStringARB) @@ -1247,7 +1246,11 @@ namespace Nz bool OpenGL::IsSupported(const String& string) { +#ifdef NAZARA_PLATFORM_SDL2 + return SDL_GL_ExtensionSupported(string.GetConstBuffer()); +#else return s_openGLextensionSet.find(string) != s_openGLextensionSet.end(); +#endif } void OpenGL::SetBuffer(BufferType type, GLuint id) @@ -2302,8 +2305,7 @@ namespace Nz PFNGLVERTEXATTRIBLPOINTERPROC glVertexAttribLPointer = nullptr; PFNGLVIEWPORTPROC glViewport = nullptr; -#if defined(NAZARA_PLATFORM_SDL2) -#elif defined(NAZARA_PLATFORM_WINDOWS) +#if defined(NAZARA_PLATFORM_WINDOWS) PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormat = nullptr; PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs = nullptr; PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = nullptr; diff --git a/src/Nazara/Renderer/SDL2/ContextImpl.cpp b/src/Nazara/Renderer/SDL2/ContextImpl.cpp index 35ebda856..0a125e58f 100644 --- a/src/Nazara/Renderer/SDL2/ContextImpl.cpp +++ b/src/Nazara/Renderer/SDL2/ContextImpl.cpp @@ -4,7 +4,6 @@ // Code inspiré de NeHe (Lesson1) et de la SFML par Laurent Gomila -#include #include #include #include @@ -13,6 +12,9 @@ #include #include #include +#include +#include + namespace Nz { ContextImpl::ContextImpl() diff --git a/tests/Engine/Platform/EventHandler/EventState.cpp b/tests/Engine/Platform/EventHandler/EventState.cpp index 1d6a6784a..c4ba22c3b 100644 --- a/tests/Engine/Platform/EventHandler/EventState.cpp +++ b/tests/Engine/Platform/EventHandler/EventState.cpp @@ -19,7 +19,7 @@ void EventState::Enter(Ndk::StateMachine& fsm) Nz::EventHandler& eventHandler = m_context.window.GetEventHandler(); m_keyPressedSlot.Connect(eventHandler.OnKeyPressed, [&] (const Nz::EventHandler*, const Nz::WindowEvent::KeyEvent& key) { - if (key.code == Nz::Keyboard::Key::M && key.shift) + if (key.virtualKey == Nz::Keyboard::VKey::M && key.shift) { fsm.ChangeState(StateFactory::Get(EventStatus::Menu)); } @@ -90,4 +90,4 @@ Nz::String EventState::ToString(const Nz::WindowEvent& event) const default: return "Not handled"; } -} \ No newline at end of file +} diff --git a/tests/Engine/Platform/EventHandler/FocusState.cpp b/tests/Engine/Platform/EventHandler/FocusState.cpp index ee5fd5f7e..65a845654 100644 --- a/tests/Engine/Platform/EventHandler/FocusState.cpp +++ b/tests/Engine/Platform/EventHandler/FocusState.cpp @@ -18,7 +18,7 @@ void FocusState::Enter(Ndk::StateMachine& fsm) Nz::EventHandler& eventHandler = m_context.window.GetEventHandler(); m_keyPressedSlot.Connect(eventHandler.OnKeyPressed, [&] (const Nz::EventHandler*, const Nz::WindowEvent::KeyEvent& key) { - if (key.code == Nz::Keyboard::Key::M && key.shift) + if (key.virtualKey == Nz::Keyboard::VKey::M && key.shift) { fsm.ChangeState(StateFactory::Get(EventStatus::Menu)); } @@ -38,4 +38,4 @@ void FocusState::Enter(Ndk::StateMachine& fsm) void FocusState::DrawMenu() { m_text.SetContent("Click outside the windows, this text should change !\nM for Menu"); -} \ No newline at end of file +} diff --git a/tests/Engine/Platform/EventHandler/KeyState.cpp b/tests/Engine/Platform/EventHandler/KeyState.cpp index 40bd785f1..705769b7f 100644 --- a/tests/Engine/Platform/EventHandler/KeyState.cpp +++ b/tests/Engine/Platform/EventHandler/KeyState.cpp @@ -35,16 +35,16 @@ void KeyState::DrawMenu() void KeyState::ManageInput(KeyStatus /*isKeyPressed*/, const Nz::WindowEvent::KeyEvent& key, Ndk::StateMachine& fsm) { - if (key.code == Nz::Keyboard::Key::M && key.shift) + if (key.virtualKey == Nz::Keyboard::VKey::M && key.shift) fsm.ChangeState(StateFactory::Get(EventStatus::Menu)); - else if (key.code == Nz::Keyboard::Key::N && key.shift) + else if (key.virtualKey == Nz::Keyboard::VKey::N && key.shift) { if (m_keyStatus == KeyStatus::Pressed) m_keyStatus = KeyStatus::Released; else m_keyStatus = KeyStatus::Pressed; } - else + else { Nz::String content; if (m_keyStatus == KeyStatus::Pressed) @@ -52,7 +52,7 @@ void KeyState::ManageInput(KeyStatus /*isKeyPressed*/, const Nz::WindowEvent::Ke else content = "Released: "; - Nz::String keyName = Nz::Keyboard::GetKeyName(key.code); + Nz::String keyName = Nz::Keyboard::GetKeyName(key.virtualKey) + " (" + Nz::Keyboard::GetKeyName(key.scancode) + ")"; if (keyName.IsEmpty()) { m_text.SetContent("Unknown\nM for Menu"); @@ -74,4 +74,4 @@ void KeyState::ManageInput(KeyStatus /*isKeyPressed*/, const Nz::WindowEvent::Ke m_text.SetContent(content + "\nM for Menu"); } } -} \ No newline at end of file +} diff --git a/tests/Engine/Platform/EventHandler/MenuState.cpp b/tests/Engine/Platform/EventHandler/MenuState.cpp index d1a244369..be0c77cd8 100644 --- a/tests/Engine/Platform/EventHandler/MenuState.cpp +++ b/tests/Engine/Platform/EventHandler/MenuState.cpp @@ -19,9 +19,9 @@ void MenuState::Enter(Ndk::StateMachine& fsm) Nz::EventHandler& eventHandler = m_context.window.GetEventHandler(); m_keyPressedSlot.Connect(eventHandler.OnKeyPressed, [this] (const Nz::EventHandler*, const Nz::WindowEvent::KeyEvent& key) { - if (key.code >= Nz::Keyboard::Key::A && key.code < (Nz::Keyboard::Key::A + static_cast(EventStatus::Max) - 1)) + if (key.virtualKey >= Nz::Keyboard::VKey::A && key.virtualKey < static_cast(static_cast(Nz::Keyboard::VKey::A) + static_cast(EventStatus::Max) - 1)) { - m_selectedNextState = key.code - static_cast(Nz::Keyboard::Key::A); + m_selectedNextState = static_cast(key.virtualKey) - static_cast(Nz::Keyboard::VKey::A); } }); } @@ -44,4 +44,4 @@ bool MenuState::Update(Ndk::StateMachine& fsm, float /*elapsedTime*/) void MenuState::DrawMenu() { m_text.SetContent("a. Event\nb. Focus\nc. Key\nd. Mouse click\ne. Mouse enter\nf. Mouse move\ng. Text enter\nh. Window modification"); -} \ No newline at end of file +} diff --git a/tests/Engine/Platform/EventHandler/MouseClickState.cpp b/tests/Engine/Platform/EventHandler/MouseClickState.cpp index 74cb8ef79..b407d9c0e 100644 --- a/tests/Engine/Platform/EventHandler/MouseClickState.cpp +++ b/tests/Engine/Platform/EventHandler/MouseClickState.cpp @@ -18,7 +18,7 @@ void MouseClickState::Enter(Ndk::StateMachine& fsm) Nz::EventHandler& eventHandler = m_context.window.GetEventHandler(); m_keyPressedSlot.Connect(eventHandler.OnKeyPressed, [&] (const Nz::EventHandler*, const Nz::WindowEvent::KeyEvent& key) { - if (key.code == Nz::Keyboard::Key::M && key.shift) + if (key.virtualKey == Nz::Keyboard::VKey::M && key.shift) { fsm.ChangeState(StateFactory::Get(EventStatus::Menu)); } @@ -78,4 +78,4 @@ void MouseClickState::ManageInput(MouseStatus mouseStatus, const Nz::WindowEvent } m_text.SetContent(content + "\nM for Menu"); -} \ No newline at end of file +} diff --git a/tests/Engine/Platform/EventHandler/MouseEnterState.cpp b/tests/Engine/Platform/EventHandler/MouseEnterState.cpp index 1eb2ca9e2..a3225918f 100644 --- a/tests/Engine/Platform/EventHandler/MouseEnterState.cpp +++ b/tests/Engine/Platform/EventHandler/MouseEnterState.cpp @@ -18,7 +18,7 @@ void MouseEnterState::Enter(Ndk::StateMachine& fsm) Nz::EventHandler& eventHandler = m_context.window.GetEventHandler(); m_keyPressedSlot.Connect(eventHandler.OnKeyPressed, [&] (const Nz::EventHandler*, const Nz::WindowEvent::KeyEvent& key) { - if (key.code == Nz::Keyboard::Key::M && key.shift) + if (key.virtualKey == Nz::Keyboard::VKey::M && key.shift) { fsm.ChangeState(StateFactory::Get(EventStatus::Menu)); } @@ -38,4 +38,4 @@ void MouseEnterState::Enter(Ndk::StateMachine& fsm) void MouseEnterState::DrawMenu() { m_text.SetContent("Move your mouse outside the windows, this text should change !\nM for Menu"); -} \ No newline at end of file +} diff --git a/tests/Engine/Platform/EventHandler/MouseMoveState.cpp b/tests/Engine/Platform/EventHandler/MouseMoveState.cpp index f0fcb3659..15a9ac13b 100644 --- a/tests/Engine/Platform/EventHandler/MouseMoveState.cpp +++ b/tests/Engine/Platform/EventHandler/MouseMoveState.cpp @@ -18,7 +18,7 @@ void MouseMoveState::Enter(Ndk::StateMachine& fsm) Nz::EventHandler& eventHandler = m_context.window.GetEventHandler(); m_keyPressedSlot.Connect(eventHandler.OnKeyPressed, [&] (const Nz::EventHandler*, const Nz::WindowEvent::KeyEvent& key) { - if (key.code == Nz::Keyboard::Key::M && key.shift) + if (key.virtualKey == Nz::Keyboard::VKey::M && key.shift) { fsm.ChangeState(StateFactory::Get(EventStatus::Menu)); } @@ -38,4 +38,4 @@ void MouseMoveState::Enter(Ndk::StateMachine& fsm) void MouseMoveState::DrawMenu() { m_text.SetContent("Move your mouse or your wheel, this text should change !\nM for Menu"); -} \ No newline at end of file +} diff --git a/tests/Engine/Platform/EventHandler/TextEnterState.cpp b/tests/Engine/Platform/EventHandler/TextEnterState.cpp index 2aa58da69..c9e50ae35 100644 --- a/tests/Engine/Platform/EventHandler/TextEnterState.cpp +++ b/tests/Engine/Platform/EventHandler/TextEnterState.cpp @@ -18,7 +18,7 @@ void TextEnterState::Enter(Ndk::StateMachine& fsm) Nz::EventHandler& eventHandler = m_context.window.GetEventHandler(); m_keyPressedSlot.Connect(eventHandler.OnKeyPressed, [&] (const Nz::EventHandler*, const Nz::WindowEvent::KeyEvent& key) { - if (key.code == Nz::Keyboard::Key::M && key.shift) + if (key.virtualKey == Nz::Keyboard::VKey::M && key.shift) { fsm.ChangeState(StateFactory::Get(EventStatus::Menu)); } @@ -36,4 +36,4 @@ void TextEnterState::Enter(Ndk::StateMachine& fsm) void TextEnterState::DrawMenu() { m_text.SetContent("Enter some text, this text should change !\nM for Menu"); -} \ No newline at end of file +} diff --git a/tests/Engine/Platform/EventHandler/WindowModificationState.cpp b/tests/Engine/Platform/EventHandler/WindowModificationState.cpp index 027185fe6..f497dc62b 100644 --- a/tests/Engine/Platform/EventHandler/WindowModificationState.cpp +++ b/tests/Engine/Platform/EventHandler/WindowModificationState.cpp @@ -18,7 +18,7 @@ void WindowModificationState::Enter(Ndk::StateMachine& fsm) Nz::EventHandler& eventHandler = m_context.window.GetEventHandler(); m_keyPressedSlot.Connect(eventHandler.OnKeyPressed, [&] (const Nz::EventHandler*, const Nz::WindowEvent::KeyEvent& key) { - if (key.code == Nz::Keyboard::Key::M && key.shift) + if (key.virtualKey == Nz::Keyboard::VKey::M && key.shift) { fsm.ChangeState(StateFactory::Get(EventStatus::Menu)); } @@ -38,4 +38,4 @@ void WindowModificationState::Enter(Ndk::StateMachine& fsm) void WindowModificationState::DrawMenu() { m_text.SetContent("Move the window or resize it, this text should change !\nM for Menu"); -} \ No newline at end of file +} From 350a1cf09fec0b970e1fd8fe68d5d4503037d95c Mon Sep 17 00:00:00 2001 From: REMqb Date: Sun, 19 May 2019 17:17:37 +0200 Subject: [PATCH 084/316] ~ Fix linux build ~ Fix dopler example --- examples/DopplerEffect/main.cpp | 2 +- src/Nazara/Renderer/Context.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/DopplerEffect/main.cpp b/examples/DopplerEffect/main.cpp index 24120a2f5..54a1169d0 100644 --- a/examples/DopplerEffect/main.cpp +++ b/examples/DopplerEffect/main.cpp @@ -70,7 +70,7 @@ int main() std::cout << "Sound position: " << pos << std::endl; // Si la position de la source atteint une certaine position, ou si l'utilisateur appuie sur echap - if (pos.x > Nz::Vector3f::Left().x*-50.f || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Escape)) + if (pos.x > Nz::Vector3f::Left().x*-50.f || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::Escape)) sound.Stop(); // On arrête le son (Stoppant également la boucle) clock.Restart(); diff --git a/src/Nazara/Renderer/Context.cpp b/src/Nazara/Renderer/Context.cpp index 7b4c62c9a..ba74b3800 100644 --- a/src/Nazara/Renderer/Context.cpp +++ b/src/Nazara/Renderer/Context.cpp @@ -14,6 +14,10 @@ #if defined(NAZARA_PLATFORM_SDL2) #include + + #if defined(NAZARA_PLATFORM_LINUX) + #define CALLBACK + #endif #elif defined(NAZARA_PLATFORM_WINDOWS) #include #elif defined(NAZARA_PLATFORM_GLX) From ef791e2f3c3bfd17db0eb23b4226d8ca1fbc83ae Mon Sep 17 00:00:00 2001 From: REMqb Date: Thu, 19 Dec 2019 19:59:43 +0100 Subject: [PATCH 085/316] ~ WIP input IME --- SDK/include/NDK/BaseWidget.hpp | 3 +- SDK/include/NDK/Canvas.hpp | 6 +- SDK/include/NDK/Canvas.inl | 3 +- SDK/src/NDK/BaseWidget.cpp | 8 ++- SDK/src/NDK/Canvas.cpp | 8 ++- examples/Textarea/build.lua | 15 +++++ examples/Textarea/main.cpp | 58 +++++++++++++++++++ include/Nazara/Platform/Enums.hpp | 3 +- include/Nazara/Platform/Event.hpp | 16 +++++- include/Nazara/Platform/EventHandler.hpp | 3 +- include/Nazara/Platform/EventHandler.inl | 4 ++ include/Nazara/Platform/Keyboard.hpp | 2 + src/Nazara/Platform/Keyboard.cpp | 10 ++++ src/Nazara/Platform/SDL2/InputImpl.cpp | 10 ++++ src/Nazara/Platform/SDL2/InputImpl.hpp | 2 + src/Nazara/Platform/SDL2/WindowImpl.cpp | 73 ++++++++++++++++++++---- src/Nazara/Platform/SDL2/WindowImpl.hpp | 1 + src/Nazara/Renderer/OpenGL.cpp | 5 +- 18 files changed, 207 insertions(+), 23 deletions(-) create mode 100644 examples/Textarea/build.lua create mode 100644 examples/Textarea/main.cpp diff --git a/SDK/include/NDK/BaseWidget.hpp b/SDK/include/NDK/BaseWidget.hpp index 26c7f5539..021beeffc 100644 --- a/SDK/include/NDK/BaseWidget.hpp +++ b/SDK/include/NDK/BaseWidget.hpp @@ -117,7 +117,8 @@ namespace Ndk virtual void OnMouseButtonRelease(int x, int y, Nz::Mouse::Button button); virtual void OnMouseExit(); virtual void OnParentResized(const Nz::Vector2f& newSize); - virtual void OnTextEntered(char32_t character, bool repeated); + virtual void OnTextEntered(char32_t character, bool repeated); + virtual void OnTextEdited(const std::array& characters, int length); inline void SetPreferredSize(const Nz::Vector2f& preferredSize); diff --git a/SDK/include/NDK/Canvas.hpp b/SDK/include/NDK/Canvas.hpp index d563c6cd3..6b66cdeaf 100644 --- a/SDK/include/NDK/Canvas.hpp +++ b/SDK/include/NDK/Canvas.hpp @@ -52,7 +52,8 @@ namespace Ndk void OnEventMouseLeft(const Nz::EventHandler* eventHandler); void OnEventKeyPressed(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::KeyEvent& event); void OnEventKeyReleased(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::KeyEvent& event); - void OnEventTextEntered(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::TextEvent& event); + void OnEventTextEntered(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::TextEvent& event); + void OnEventTextEdited(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::EditEvent& event); struct WidgetEntry { @@ -67,7 +68,8 @@ namespace Ndk NazaraSlot(Nz::EventHandler, OnMouseButtonReleased, m_mouseButtonReleasedSlot); NazaraSlot(Nz::EventHandler, OnMouseMoved, m_mouseMovedSlot); NazaraSlot(Nz::EventHandler, OnMouseLeft, m_mouseLeftSlot); - NazaraSlot(Nz::EventHandler, OnTextEntered, m_textEnteredSlot); + NazaraSlot(Nz::EventHandler, OnTextEntered, m_textEnteredSlot); + NazaraSlot(Nz::EventHandler, OnTextEdited, m_textEditedSlot); std::size_t m_keyboardOwner; std::size_t m_hoveredWidget; diff --git a/SDK/include/NDK/Canvas.inl b/SDK/include/NDK/Canvas.inl index 7a602cffb..649f5f728 100644 --- a/SDK/include/NDK/Canvas.inl +++ b/SDK/include/NDK/Canvas.inl @@ -26,7 +26,8 @@ namespace Ndk m_mouseButtonReleasedSlot.Connect(eventHandler.OnMouseButtonReleased, this, &Canvas::OnEventMouseButtonRelease); m_mouseMovedSlot.Connect(eventHandler.OnMouseMoved, this, &Canvas::OnEventMouseMoved); m_mouseLeftSlot.Connect(eventHandler.OnMouseLeft, this, &Canvas::OnEventMouseLeft); - m_textEnteredSlot.Connect(eventHandler.OnTextEntered, this, &Canvas::OnEventTextEntered); + m_textEnteredSlot.Connect(eventHandler.OnTextEntered, this, &Canvas::OnEventTextEntered); + m_textEditedSlot.Connect(eventHandler.OnTextEdited, this, &Canvas::OnEventTextEdited); } inline Canvas::~Canvas() diff --git a/SDK/src/NDK/BaseWidget.cpp b/SDK/src/NDK/BaseWidget.cpp index 89ca6bb9c..ce900852a 100644 --- a/SDK/src/NDK/BaseWidget.cpp +++ b/SDK/src/NDK/BaseWidget.cpp @@ -242,12 +242,16 @@ namespace Ndk void BaseWidget::OnParentResized(const Nz::Vector2f& /*newSize*/) { - } + } - void BaseWidget::OnTextEntered(char32_t /*character*/, bool /*repeated*/) + void BaseWidget::OnTextEntered(char32_t /*character*/, bool /*repeated*/) { } + void BaseWidget::OnTextEdited(const std::array& /*characters*/, int /*length*/) + { + } + void BaseWidget::DestroyChild(BaseWidget* widget) { auto it = std::find_if(m_children.begin(), m_children.end(), [widget] (const std::unique_ptr& widgetPtr) -> bool diff --git a/SDK/src/NDK/Canvas.cpp b/SDK/src/NDK/Canvas.cpp index 7e74d5197..aa1e83328 100644 --- a/SDK/src/NDK/Canvas.cpp +++ b/SDK/src/NDK/Canvas.cpp @@ -203,5 +203,11 @@ namespace Ndk { if (m_keyboardOwner != InvalidCanvasIndex) m_widgetEntries[m_keyboardOwner].widget->OnTextEntered(event.character, event.repeated); - } + } + + void Canvas::OnEventTextEdited(const Nz::EventHandler* /*eventHandler*/, const Nz::WindowEvent::EditEvent& event) + { + if (m_keyboardOwner != InvalidCanvasIndex) + m_widgetEntries[m_keyboardOwner].widget->OnTextEdited(event.text, event.length); + } } diff --git a/examples/Textarea/build.lua b/examples/Textarea/build.lua new file mode 100644 index 000000000..3436aafef --- /dev/null +++ b/examples/Textarea/build.lua @@ -0,0 +1,15 @@ +EXAMPLE.Name = "Textarea" + +EXAMPLE.EnableConsole = true + +EXAMPLE.Files = { + "main.cpp" +} + +EXAMPLE.Libraries = { + "NazaraSDK" +} + +if Config.PlatformSDL2 then + table.insert(EXAMPLE.Defines, "NAZARA_PLATFORM_SDL2") +end diff --git a/examples/Textarea/main.cpp b/examples/Textarea/main.cpp new file mode 100644 index 000000000..6726aa1f1 --- /dev/null +++ b/examples/Textarea/main.cpp @@ -0,0 +1,58 @@ +// Sources pour https://github.com/DigitalPulseSoftware/NazaraEngine/wiki/(FR)-Tutoriel:-%5B01%5D-Hello-World + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char* argv[]) +{ + Ndk::Application application(argc, argv); + + Nz::RenderWindow& mainWindow = application.AddWindow(); + mainWindow.Create(Nz::VideoMode(800, 600, 32), "Test"); + + + Ndk::World& world = application.AddWorld(); + world.GetSystem().SetGlobalUp(Nz::Vector3f::Down()); + world.GetSystem().SetDefaultBackground(Nz::ColorBackground::New(Nz::Color(117, 122, 214))); + + + Ndk::EntityHandle viewEntity = world.CreateEntity(); + viewEntity->AddComponent(); + + Ndk::CameraComponent& viewer = viewEntity->AddComponent(); + viewer.SetTarget(&mainWindow); + viewer.SetProjectionType(Nz::ProjectionType_Orthogonal); + + Ndk::EntityHandle text = world.CreateEntity(); + Ndk::NodeComponent& nodeComponent = text->AddComponent(); + + Ndk::Canvas canvas(world.CreateHandle(), mainWindow.GetEventHandler(), mainWindow.GetCursorController().CreateHandle()); + canvas.SetFixedSize(Nz::Vector2f(mainWindow.GetSize())); + + auto textarea = canvas.Add(); + textarea->EnableBackground(true); + textarea->SetBackgroundColor(Nz::Color(0, 0, 0, 150)); + textarea->SetTextColor(Nz::Color::White); + textarea->EnableMultiline(); + + textarea->SetFixedSize(canvas.GetSize()/2); + + /*Nz::Boxf textBox = mainWindow.GetSize(); + Nz::Vector2ui windowSize = mainWindow.GetSize(); + nodeComponent.SetPosition(windowSize.x / 2 - textBox.width / 2, windowSize.y / 2 - textBox.height / 2);*/ + + while (application.Run()) + { + mainWindow.Display(); + } + + return EXIT_SUCCESS; +} diff --git a/include/Nazara/Platform/Enums.hpp b/include/Nazara/Platform/Enums.hpp index 77b69f65e..6d0c560ab 100644 --- a/include/Nazara/Platform/Enums.hpp +++ b/include/Nazara/Platform/Enums.hpp @@ -51,9 +51,10 @@ namespace Nz WindowEventType_Moved, WindowEventType_Quit, WindowEventType_Resized, + WindowEventType_TextEdited, WindowEventType_TextEntered, - WindowEventType_Max = WindowEventType_TextEntered + WindowEventType_Max = WindowEventType_TextEntered }; enum WindowStyle diff --git a/include/Nazara/Platform/Event.hpp b/include/Nazara/Platform/Event.hpp index 1c98f6b7f..ab5e2a906 100644 --- a/include/Nazara/Platform/Event.hpp +++ b/include/Nazara/Platform/Event.hpp @@ -9,6 +9,8 @@ #ifndef NAZARA_EVENT_HPP #define NAZARA_EVENT_HPP +#include + #include #include #include @@ -80,7 +82,15 @@ namespace Nz { bool repeated; char32_t character; - }; + }; + + // Used by: + // -WindowEventType_TextEdited + struct EditEvent + { + int length; + std::array text; + }; WindowEventType type; @@ -115,6 +125,10 @@ namespace Nz // Used by: // -WindowEventType_TextEntered TextEvent text; + + // Used by: + // -WindowEventType_TextEntered + EditEvent edit; }; }; } diff --git a/include/Nazara/Platform/EventHandler.hpp b/include/Nazara/Platform/EventHandler.hpp index 7404a26d6..e612823ec 100644 --- a/include/Nazara/Platform/EventHandler.hpp +++ b/include/Nazara/Platform/EventHandler.hpp @@ -48,7 +48,8 @@ namespace Nz NazaraSignal(OnMoved, const EventHandler* /*eventHandler*/, const WindowEvent::PositionEvent& /*event*/); NazaraSignal(OnQuit, const EventHandler* /*eventHandler*/); NazaraSignal(OnResized, const EventHandler* /*eventHandler*/, const WindowEvent::SizeEvent& /*event*/); - NazaraSignal(OnTextEntered, const EventHandler* /*eventHandler*/, const WindowEvent::TextEvent& /*event*/); + NazaraSignal(OnTextEntered, const EventHandler* /*eventHandler*/, const WindowEvent::TextEvent& /*event*/); + NazaraSignal(OnTextEdited, const EventHandler* /*eventHandler*/, const WindowEvent::EditEvent& /*event*/); }; } diff --git a/include/Nazara/Platform/EventHandler.inl b/include/Nazara/Platform/EventHandler.inl index 6cc31efe5..25f76a4ab 100644 --- a/include/Nazara/Platform/EventHandler.inl +++ b/include/Nazara/Platform/EventHandler.inl @@ -78,6 +78,10 @@ namespace Nz case WindowEventType_TextEntered: OnTextEntered(this, event.text); break; + + case WindowEventType_TextEdited: + OnTextEdited(this, event.edit); + break; } } } diff --git a/include/Nazara/Platform/Keyboard.hpp b/include/Nazara/Platform/Keyboard.hpp index 5a131b66f..36d87d2ee 100644 --- a/include/Nazara/Platform/Keyboard.hpp +++ b/include/Nazara/Platform/Keyboard.hpp @@ -323,6 +323,8 @@ namespace Nz static String GetKeyName(VKey key); static bool IsKeyPressed(Scancode scancode); static bool IsKeyPressed(VKey key); + static void StartTextInput(); + static void StopTextInput(); static Scancode ToScanCode(VKey key); static VKey ToVirtualKey(Scancode key); }; diff --git a/src/Nazara/Platform/Keyboard.cpp b/src/Nazara/Platform/Keyboard.cpp index 45435b818..7c68e5164 100644 --- a/src/Nazara/Platform/Keyboard.cpp +++ b/src/Nazara/Platform/Keyboard.cpp @@ -38,6 +38,16 @@ namespace Nz return EventImpl::IsKeyPressed(key); } + void Keyboard::StartTextInput() + { + EventImpl::StartTextInput(); + } + + void Keyboard::StopTextInput() + { + EventImpl::StopTextInput(); + } + Keyboard::Scancode Keyboard::ToScanCode(VKey key) { return EventImpl::ToScanCode(key); diff --git a/src/Nazara/Platform/SDL2/InputImpl.cpp b/src/Nazara/Platform/SDL2/InputImpl.cpp index 1ecbc8491..9daba650d 100644 --- a/src/Nazara/Platform/SDL2/InputImpl.cpp +++ b/src/Nazara/Platform/SDL2/InputImpl.cpp @@ -100,6 +100,16 @@ namespace Nz NazaraError("Invalid window handle"); } + void EventImpl::StartTextInput() + { + SDL_StartTextInput(); + } + + void EventImpl::StopTextInput() + { + SDL_StopTextInput(); + } + Keyboard::Scancode EventImpl::ToScanCode(Keyboard::VKey key) { return SDLHelper::FromSDL(SDL_GetScancodeFromKey(SDLHelper::ToSDL(key))); diff --git a/src/Nazara/Platform/SDL2/InputImpl.hpp b/src/Nazara/Platform/SDL2/InputImpl.hpp index 9a21ed363..8aca56985 100644 --- a/src/Nazara/Platform/SDL2/InputImpl.hpp +++ b/src/Nazara/Platform/SDL2/InputImpl.hpp @@ -26,6 +26,8 @@ namespace Nz static bool IsMouseButtonPressed(Mouse::Button button); static void SetMousePosition(int x, int y); static void SetMousePosition(int x, int y, const Window& relativeTo); + static void StartTextInput(); + static void StopTextInput(); static Keyboard::Scancode ToScanCode(Keyboard::VKey key); static Keyboard::VKey ToVirtualKey(Keyboard::Scancode scancode); }; diff --git a/src/Nazara/Platform/SDL2/WindowImpl.cpp b/src/Nazara/Platform/SDL2/WindowImpl.cpp index 6b9b18f5e..3462a1c09 100644 --- a/src/Nazara/Platform/SDL2/WindowImpl.cpp +++ b/src/Nazara/Platform/SDL2/WindowImpl.cpp @@ -278,10 +278,10 @@ namespace Nz case SDL_WINDOWEVENT_RESIZED: evt.type = Nz::WindowEventType::WindowEventType_Resized; - evt.size.width = event->window.data1; - evt.size.height = event->window.data2; + evt.size.width = static_cast(std::max(0, event->window.data1)); + evt.size.height = static_cast(std::max(0, event->window.data2)); - window->m_size.Set(event->window.data1, event->window.data2); + window->m_size.Set(evt.size.width, evt.size.height); break; case SDL_WINDOWEVENT_MOVED: @@ -387,6 +387,39 @@ namespace Nz evt.key.shift = (event->key.keysym.mod & KMOD_SHIFT) != 0; evt.key.system = (event->key.keysym.mod & KMOD_GUI) != 0; + // implements X11/Win32 APIs behavior for Enter and Backspace + switch (evt.key.virtualKey) { + case Nz::Keyboard::VKey::NumpadReturn: + case Nz::Keyboard::VKey::Return: + if (window->m_lastEditEventLength != 0) + { + break; + } + window->m_parent->PushEvent(evt); + + evt.type = WindowEventType_TextEntered; + + evt.text.character = U'\n'; + evt.text.repeated = event->key.repeat != 0; + + window->m_parent->PushEvent(evt); + + break; + case Nz::Keyboard::VKey::Backspace: + window->m_parent->PushEvent(evt); + + evt.type = WindowEventType_TextEntered; + + evt.text.character = U'\b'; + evt.text.repeated = event->key.repeat != 0; + + window->m_parent->PushEvent(evt); + + break; + default: + break; + } + break; case SDL_KEYUP: @@ -410,26 +443,42 @@ namespace Nz return 0; evt.type = WindowEventType_TextEntered; + evt.text.repeated = false; - for (decltype(evt.text.character)codepoint : String::Unicode(event->text.text).GetUtf32String()) + for (decltype(evt.text.character)codepoint : String::Unicode(event->text.text).Simplify().GetUtf32String()) { - evt.text.character = codepoint; + evt.text.character = codepoint; window->m_parent->PushEvent(evt); } // prevent post switch event - evt.type = WindowEventType::WindowEventType_Max; + evt.type = WindowEventType::WindowEventType_Max; - break; + break; + + case SDL_TEXTEDITING: + if (SDL_GetWindowID(window->m_handle) != event->edit.windowID) + return 0; + + evt.type = WindowEventType_TextEdited; + evt.edit.length = event->edit.length; + window->m_lastEditEventLength = evt.edit.length; + + for (std::size_t i = 0; i < 32; i++) + { + evt.edit.text[i] = event->edit.text[i]; + } + + break; } if (evt.type != WindowEventType::WindowEventType_Max) window->m_parent->PushEvent(evt); } catch (std::exception e) - { - NazaraError(e.what()); + { + NazaraError(e.what()); } catch (...) // Don't let any exceptions go thru C calls { @@ -511,11 +560,11 @@ namespace Nz } bool WindowImpl::Initialize() - { + { if (SDL_Init(SDL_INIT_VIDEO) < 0) { NazaraError(SDL_GetError()); - return false; + return false; } if (SDL_GL_LoadLibrary(nullptr) < 0) { @@ -523,7 +572,7 @@ namespace Nz SDL_Quit(); return false; - } + } if (SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, true) < 0) NazaraError("Couldn't set share OpenGL contexes"); diff --git a/src/Nazara/Platform/SDL2/WindowImpl.hpp b/src/Nazara/Platform/SDL2/WindowImpl.hpp index 7cccb5b1c..0ff3206ae 100644 --- a/src/Nazara/Platform/SDL2/WindowImpl.hpp +++ b/src/Nazara/Platform/SDL2/WindowImpl.hpp @@ -87,6 +87,7 @@ namespace Nz //static void WindowThread(SDL_Window* handle, /*DWORD styleEx,*/ const String& title, /*DWORD style,*/ bool fullscreen, const Rectui& dimensions, WindowImpl* window, Mutex* mutex, ConditionVariable* condition); + int m_lastEditEventLength = 0; SDL_Cursor* m_cursor; SDL_Window* m_handle; WindowStyleFlags m_style; diff --git a/src/Nazara/Renderer/OpenGL.cpp b/src/Nazara/Renderer/OpenGL.cpp index 6228aebad..993add34b 100644 --- a/src/Nazara/Renderer/OpenGL.cpp +++ b/src/Nazara/Renderer/OpenGL.cpp @@ -744,7 +744,10 @@ namespace Nz #if defined(NAZARA_PLATFORM_SDL2) - + if (SDL_VideoInit(NULL) != 0) + { + NazaraError(SDL_GetError()); + } #elif defined(NAZARA_PLATFORM_GLX) Initializer display; if (!display) From 0c008236ba15db8479da087c0a365441f3e6ec56 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 23 Feb 2020 01:28:16 +0100 Subject: [PATCH 086/316] Minor fixes + update vulkan include --- examples/VulkanTest/main.cpp | 7 +- .../Nazara/VulkanRenderer/VkRenderTarget.hpp | 2 + .../Nazara/VulkanRenderer/VkRenderWindow.hpp | 1 + .../Nazara/VulkanRenderer/Wrapper/Device.hpp | 5 +- .../Nazara/VulkanRenderer/Wrapper/Device.inl | 9 - .../Nazara/VulkanRenderer/Wrapper/Queue.inl | 1 - .../VulkanRenderer/Utils_VulkanRenderer.cpp | 2 +- src/Nazara/VulkanRenderer/VkRenderTarget.cpp | 6 + src/Nazara/VulkanRenderer/VkRenderWindow.cpp | 3 +- src/Nazara/VulkanRenderer/Wrapper/Device.cpp | 10 + thirdparty/include/vulkan/vk_icd.h | 183 + thirdparty/include/vulkan/vk_layer.h | 202 + thirdparty/include/vulkan/vk_platform.h | 30 +- thirdparty/include/vulkan/vk_sdk_platform.h | 69 + thirdparty/include/vulkan/vulkan.h | 6138 +-------- thirdparty/include/vulkan/vulkan_android.h | 122 + thirdparty/include/vulkan/vulkan_core.h | 10728 ++++++++++++++++ thirdparty/include/vulkan/vulkan_fuchsia.h | 57 + thirdparty/include/vulkan/vulkan_ggp.h | 68 + thirdparty/include/vulkan/vulkan_ios.h | 57 + thirdparty/include/vulkan/vulkan_macos.h | 57 + thirdparty/include/vulkan/vulkan_metal.h | 64 + thirdparty/include/vulkan/vulkan_vi.h | 57 + thirdparty/include/vulkan/vulkan_wayland.h | 64 + thirdparty/include/vulkan/vulkan_win32.h | 328 + thirdparty/include/vulkan/vulkan_xcb.h | 65 + thirdparty/include/vulkan/vulkan_xlib.h | 65 + .../include/vulkan/vulkan_xlib_xrandr.h | 55 + 28 files changed, 12325 insertions(+), 6130 deletions(-) create mode 100644 thirdparty/include/vulkan/vk_icd.h create mode 100644 thirdparty/include/vulkan/vk_layer.h create mode 100644 thirdparty/include/vulkan/vk_sdk_platform.h create mode 100644 thirdparty/include/vulkan/vulkan_android.h create mode 100644 thirdparty/include/vulkan/vulkan_core.h create mode 100644 thirdparty/include/vulkan/vulkan_fuchsia.h create mode 100644 thirdparty/include/vulkan/vulkan_ggp.h create mode 100644 thirdparty/include/vulkan/vulkan_ios.h create mode 100644 thirdparty/include/vulkan/vulkan_macos.h create mode 100644 thirdparty/include/vulkan/vulkan_metal.h create mode 100644 thirdparty/include/vulkan/vulkan_vi.h create mode 100644 thirdparty/include/vulkan/vulkan_wayland.h create mode 100644 thirdparty/include/vulkan/vulkan_win32.h create mode 100644 thirdparty/include/vulkan/vulkan_xcb.h create mode 100644 thirdparty/include/vulkan/vulkan_xlib.h create mode 100644 thirdparty/include/vulkan/vulkan_xlib_xrandr.h diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index b34574245..2e202b811 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -152,14 +152,15 @@ int main() return __LINE__; } - Nz::Mesh drfreak; - if (!drfreak.LoadFromFile("resources/OILTANK1.md2", meshParams)) + Nz::MeshRef drfreak = Nz::Mesh::LoadFromFile("resources/OILTANK1.md2", meshParams); + + if (!drfreak) { NazaraError("Failed to load model"); return __LINE__; } - Nz::StaticMesh* drfreakMesh = static_cast(drfreak.GetSubMesh(0)); + Nz::StaticMesh* drfreakMesh = static_cast(drfreak->GetSubMesh(0)); const Nz::VertexBuffer* drfreakVB = drfreakMesh->GetVertexBuffer(); const Nz::IndexBuffer* drfreakIB = drfreakMesh->GetIndexBuffer(); diff --git a/include/Nazara/VulkanRenderer/VkRenderTarget.hpp b/include/Nazara/VulkanRenderer/VkRenderTarget.hpp index 138651475..f997dda00 100644 --- a/include/Nazara/VulkanRenderer/VkRenderTarget.hpp +++ b/include/Nazara/VulkanRenderer/VkRenderTarget.hpp @@ -48,6 +48,8 @@ namespace Nz NazaraSignal(OnRenderTargetSizeChange, const VkRenderTarget* /*renderTarget*/); protected: + void Destroy(); + Vk::RenderPass m_renderPass; Vk::Semaphore m_imageReadySemaphore; }; diff --git a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp index e1cdf3622..38c464986 100644 --- a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp +++ b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include diff --git a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp index 4be5e53bf..01e508372 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -19,8 +20,8 @@ namespace Nz namespace Vk { class Device; - class Queue; class Instance; + class Queue; using DeviceHandle = ObjectHandle; @@ -42,7 +43,7 @@ namespace Nz inline const std::vector& GetEnabledQueues() const; inline const QueueList& GetEnabledQueues(UInt32 familyQueue) const; - inline Queue GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex); + Queue GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex); inline Instance& GetInstance(); inline const Instance& GetInstance() const; inline VkResult GetLastErrorCode() const; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Device.inl b/include/Nazara/VulkanRenderer/Wrapper/Device.inl index f7e76a2f0..92e32e0dc 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Device.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Device.inl @@ -6,7 +6,6 @@ #include #include #include -#include #include namespace Nz @@ -49,14 +48,6 @@ namespace Nz return *m_queuesByFamily[familyQueue]; } - inline Queue Device::GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex) - { - VkQueue queue; - vkGetDeviceQueue(m_device, queueFamilyIndex, queueIndex, &queue); - - return Queue(CreateHandle(), queue); - } - inline Instance& Device::GetInstance() { return m_instance; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Queue.inl b/include/Nazara/VulkanRenderer/Wrapper/Queue.inl index 51966d94d..63583e66e 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Queue.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Queue.inl @@ -5,7 +5,6 @@ #include #include #include -#include #include namespace Nz diff --git a/src/Nazara/VulkanRenderer/Utils_VulkanRenderer.cpp b/src/Nazara/VulkanRenderer/Utils_VulkanRenderer.cpp index 4df58b4cf..bec00a1ee 100644 --- a/src/Nazara/VulkanRenderer/Utils_VulkanRenderer.cpp +++ b/src/Nazara/VulkanRenderer/Utils_VulkanRenderer.cpp @@ -90,7 +90,7 @@ namespace Nz case VK_ERROR_OUT_OF_POOL_MEMORY_KHR: return "A requested pool allocation has failed"; - case VK_ERROR_INVALID_EXTERNAL_HANDLE_KHX: + case VK_ERROR_INVALID_EXTERNAL_HANDLE: return "An external handle is not a valid handle of the specified type"; default: diff --git a/src/Nazara/VulkanRenderer/VkRenderTarget.cpp b/src/Nazara/VulkanRenderer/VkRenderTarget.cpp index 767ee7988..27e1f5ff1 100644 --- a/src/Nazara/VulkanRenderer/VkRenderTarget.cpp +++ b/src/Nazara/VulkanRenderer/VkRenderTarget.cpp @@ -11,4 +11,10 @@ namespace Nz { OnRenderTargetRelease(this); } + + void VkRenderTarget::Destroy() + { + m_renderPass.Destroy(); + m_imageReadySemaphore.Destroy(); + } } diff --git a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp index 7f7928954..cc1c7de57 100644 --- a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp +++ b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp @@ -27,8 +27,9 @@ namespace Nz m_frameBuffers.clear(); m_renderPass.Destroy(); - m_swapchain.Destroy(); + + VkRenderTarget::Destroy(); } bool VkRenderWindow::Acquire(UInt32* imageIndex) const diff --git a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp index b5f6d8890..247f5a27c 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include namespace Nz @@ -218,5 +219,14 @@ namespace Nz return true; } + + Queue Device::GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex) + { + VkQueue queue; + vkGetDeviceQueue(m_device, queueFamilyIndex, queueIndex, &queue); + + return Queue(CreateHandle(), queue); + } + } } diff --git a/thirdparty/include/vulkan/vk_icd.h b/thirdparty/include/vulkan/vk_icd.h new file mode 100644 index 000000000..5dff59a16 --- /dev/null +++ b/thirdparty/include/vulkan/vk_icd.h @@ -0,0 +1,183 @@ +// +// File: vk_icd.h +// +/* + * Copyright (c) 2015-2016 The Khronos Group Inc. + * Copyright (c) 2015-2016 Valve Corporation + * Copyright (c) 2015-2016 LunarG, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef VKICD_H +#define VKICD_H + +#include "vulkan.h" +#include + +// Loader-ICD version negotiation API. Versions add the following features: +// Version 0 - Initial. Doesn't support vk_icdGetInstanceProcAddr +// or vk_icdNegotiateLoaderICDInterfaceVersion. +// Version 1 - Add support for vk_icdGetInstanceProcAddr. +// Version 2 - Add Loader/ICD Interface version negotiation +// via vk_icdNegotiateLoaderICDInterfaceVersion. +// Version 3 - Add ICD creation/destruction of KHR_surface objects. +// Version 4 - Add unknown physical device extension qyering via +// vk_icdGetPhysicalDeviceProcAddr. +// Version 5 - Tells ICDs that the loader is now paying attention to the +// application version of Vulkan passed into the ApplicationInfo +// structure during vkCreateInstance. This will tell the ICD +// that if the loader is older, it should automatically fail a +// call for any API version > 1.0. Otherwise, the loader will +// manually determine if it can support the expected version. +#define CURRENT_LOADER_ICD_INTERFACE_VERSION 5 +#define MIN_SUPPORTED_LOADER_ICD_INTERFACE_VERSION 0 +#define MIN_PHYS_DEV_EXTENSION_ICD_INTERFACE_VERSION 4 +typedef VkResult(VKAPI_PTR *PFN_vkNegotiateLoaderICDInterfaceVersion)(uint32_t *pVersion); + +// This is defined in vk_layer.h which will be found by the loader, but if an ICD is building against this +// file directly, it won't be found. +#ifndef PFN_GetPhysicalDeviceProcAddr +typedef PFN_vkVoidFunction(VKAPI_PTR *PFN_GetPhysicalDeviceProcAddr)(VkInstance instance, const char *pName); +#endif + +/* + * The ICD must reserve space for a pointer for the loader's dispatch + * table, at the start of . + * The ICD must initialize this variable using the SET_LOADER_MAGIC_VALUE macro. + */ + +#define ICD_LOADER_MAGIC 0x01CDC0DE + +typedef union { + uintptr_t loaderMagic; + void *loaderData; +} VK_LOADER_DATA; + +static inline void set_loader_magic_value(void *pNewObject) { + VK_LOADER_DATA *loader_info = (VK_LOADER_DATA *)pNewObject; + loader_info->loaderMagic = ICD_LOADER_MAGIC; +} + +static inline bool valid_loader_magic_value(void *pNewObject) { + const VK_LOADER_DATA *loader_info = (VK_LOADER_DATA *)pNewObject; + return (loader_info->loaderMagic & 0xffffffff) == ICD_LOADER_MAGIC; +} + +/* + * Windows and Linux ICDs will treat VkSurfaceKHR as a pointer to a struct that + * contains the platform-specific connection and surface information. + */ +typedef enum { + VK_ICD_WSI_PLATFORM_MIR, + VK_ICD_WSI_PLATFORM_WAYLAND, + VK_ICD_WSI_PLATFORM_WIN32, + VK_ICD_WSI_PLATFORM_XCB, + VK_ICD_WSI_PLATFORM_XLIB, + VK_ICD_WSI_PLATFORM_ANDROID, + VK_ICD_WSI_PLATFORM_MACOS, + VK_ICD_WSI_PLATFORM_IOS, + VK_ICD_WSI_PLATFORM_DISPLAY, + VK_ICD_WSI_PLATFORM_HEADLESS, + VK_ICD_WSI_PLATFORM_METAL, +} VkIcdWsiPlatform; + +typedef struct { + VkIcdWsiPlatform platform; +} VkIcdSurfaceBase; + +#ifdef VK_USE_PLATFORM_MIR_KHR +typedef struct { + VkIcdSurfaceBase base; + MirConnection *connection; + MirSurface *mirSurface; +} VkIcdSurfaceMir; +#endif // VK_USE_PLATFORM_MIR_KHR + +#ifdef VK_USE_PLATFORM_WAYLAND_KHR +typedef struct { + VkIcdSurfaceBase base; + struct wl_display *display; + struct wl_surface *surface; +} VkIcdSurfaceWayland; +#endif // VK_USE_PLATFORM_WAYLAND_KHR + +#ifdef VK_USE_PLATFORM_WIN32_KHR +typedef struct { + VkIcdSurfaceBase base; + HINSTANCE hinstance; + HWND hwnd; +} VkIcdSurfaceWin32; +#endif // VK_USE_PLATFORM_WIN32_KHR + +#ifdef VK_USE_PLATFORM_XCB_KHR +typedef struct { + VkIcdSurfaceBase base; + xcb_connection_t *connection; + xcb_window_t window; +} VkIcdSurfaceXcb; +#endif // VK_USE_PLATFORM_XCB_KHR + +#ifdef VK_USE_PLATFORM_XLIB_KHR +typedef struct { + VkIcdSurfaceBase base; + Display *dpy; + Window window; +} VkIcdSurfaceXlib; +#endif // VK_USE_PLATFORM_XLIB_KHR + +#ifdef VK_USE_PLATFORM_ANDROID_KHR +typedef struct { + VkIcdSurfaceBase base; + struct ANativeWindow *window; +} VkIcdSurfaceAndroid; +#endif // VK_USE_PLATFORM_ANDROID_KHR + +#ifdef VK_USE_PLATFORM_MACOS_MVK +typedef struct { + VkIcdSurfaceBase base; + const void *pView; +} VkIcdSurfaceMacOS; +#endif // VK_USE_PLATFORM_MACOS_MVK + +#ifdef VK_USE_PLATFORM_IOS_MVK +typedef struct { + VkIcdSurfaceBase base; + const void *pView; +} VkIcdSurfaceIOS; +#endif // VK_USE_PLATFORM_IOS_MVK + +typedef struct { + VkIcdSurfaceBase base; + VkDisplayModeKHR displayMode; + uint32_t planeIndex; + uint32_t planeStackIndex; + VkSurfaceTransformFlagBitsKHR transform; + float globalAlpha; + VkDisplayPlaneAlphaFlagBitsKHR alphaMode; + VkExtent2D imageExtent; +} VkIcdSurfaceDisplay; + +typedef struct { + VkIcdSurfaceBase base; +} VkIcdSurfaceHeadless; + +#ifdef VK_USE_PLATFORM_METAL_EXT +typedef struct { + VkIcdSurfaceBase base; + const CAMetalLayer *pLayer; +} VkIcdSurfaceMetal; +#endif // VK_USE_PLATFORM_METAL_EXT + +#endif // VKICD_H diff --git a/thirdparty/include/vulkan/vk_layer.h b/thirdparty/include/vulkan/vk_layer.h new file mode 100644 index 000000000..fa7652008 --- /dev/null +++ b/thirdparty/include/vulkan/vk_layer.h @@ -0,0 +1,202 @@ +// +// File: vk_layer.h +// +/* + * Copyright (c) 2015-2017 The Khronos Group Inc. + * Copyright (c) 2015-2017 Valve Corporation + * Copyright (c) 2015-2017 LunarG, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/* Need to define dispatch table + * Core struct can then have ptr to dispatch table at the top + * Along with object ptrs for current and next OBJ + */ +#pragma once + +#include "vulkan.h" +#if defined(__GNUC__) && __GNUC__ >= 4 +#define VK_LAYER_EXPORT __attribute__((visibility("default"))) +#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590) +#define VK_LAYER_EXPORT __attribute__((visibility("default"))) +#else +#define VK_LAYER_EXPORT +#endif + +#define MAX_NUM_UNKNOWN_EXTS 250 + + // Loader-Layer version negotiation API. Versions add the following features: + // Versions 0/1 - Initial. Doesn't support vk_layerGetPhysicalDeviceProcAddr + // or vk_icdNegotiateLoaderLayerInterfaceVersion. + // Version 2 - Add support for vk_layerGetPhysicalDeviceProcAddr and + // vk_icdNegotiateLoaderLayerInterfaceVersion. +#define CURRENT_LOADER_LAYER_INTERFACE_VERSION 2 +#define MIN_SUPPORTED_LOADER_LAYER_INTERFACE_VERSION 1 + +#define VK_CURRENT_CHAIN_VERSION 1 + +// Typedef for use in the interfaces below +typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_GetPhysicalDeviceProcAddr)(VkInstance instance, const char* pName); + +// Version negotiation values +typedef enum VkNegotiateLayerStructType { + LAYER_NEGOTIATE_UNINTIALIZED = 0, + LAYER_NEGOTIATE_INTERFACE_STRUCT = 1, +} VkNegotiateLayerStructType; + +// Version negotiation structures +typedef struct VkNegotiateLayerInterface { + VkNegotiateLayerStructType sType; + void *pNext; + uint32_t loaderLayerInterfaceVersion; + PFN_vkGetInstanceProcAddr pfnGetInstanceProcAddr; + PFN_vkGetDeviceProcAddr pfnGetDeviceProcAddr; + PFN_GetPhysicalDeviceProcAddr pfnGetPhysicalDeviceProcAddr; +} VkNegotiateLayerInterface; + +// Version negotiation functions +typedef VkResult (VKAPI_PTR *PFN_vkNegotiateLoaderLayerInterfaceVersion)(VkNegotiateLayerInterface *pVersionStruct); + +// Function prototype for unknown physical device extension command +typedef VkResult(VKAPI_PTR *PFN_PhysDevExt)(VkPhysicalDevice phys_device); + +// ------------------------------------------------------------------------------------------------ +// CreateInstance and CreateDevice support structures + +/* Sub type of structure for instance and device loader ext of CreateInfo. + * When sType == VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO + * or sType == VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO + * then VkLayerFunction indicates struct type pointed to by pNext + */ +typedef enum VkLayerFunction_ { + VK_LAYER_LINK_INFO = 0, + VK_LOADER_DATA_CALLBACK = 1, + VK_LOADER_LAYER_CREATE_DEVICE_CALLBACK = 2 +} VkLayerFunction; + +typedef struct VkLayerInstanceLink_ { + struct VkLayerInstanceLink_ *pNext; + PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr; + PFN_GetPhysicalDeviceProcAddr pfnNextGetPhysicalDeviceProcAddr; +} VkLayerInstanceLink; + +/* + * When creating the device chain the loader needs to pass + * down information about it's device structure needed at + * the end of the chain. Passing the data via the + * VkLayerDeviceInfo avoids issues with finding the + * exact instance being used. + */ +typedef struct VkLayerDeviceInfo_ { + void *device_info; + PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr; +} VkLayerDeviceInfo; + +typedef VkResult (VKAPI_PTR *PFN_vkSetInstanceLoaderData)(VkInstance instance, + void *object); +typedef VkResult (VKAPI_PTR *PFN_vkSetDeviceLoaderData)(VkDevice device, + void *object); +typedef VkResult (VKAPI_PTR *PFN_vkLayerCreateDevice)(VkInstance instance, VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, + const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, PFN_vkGetInstanceProcAddr layerGIPA, PFN_vkGetDeviceProcAddr *nextGDPA); +typedef void (VKAPI_PTR *PFN_vkLayerDestroyDevice)(VkDevice physicalDevice, const VkAllocationCallbacks *pAllocator, PFN_vkDestroyDevice destroyFunction); +typedef struct { + VkStructureType sType; // VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO + const void *pNext; + VkLayerFunction function; + union { + VkLayerInstanceLink *pLayerInfo; + PFN_vkSetInstanceLoaderData pfnSetInstanceLoaderData; + struct { + PFN_vkLayerCreateDevice pfnLayerCreateDevice; + PFN_vkLayerDestroyDevice pfnLayerDestroyDevice; + } layerDevice; + } u; +} VkLayerInstanceCreateInfo; + +typedef struct VkLayerDeviceLink_ { + struct VkLayerDeviceLink_ *pNext; + PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr; + PFN_vkGetDeviceProcAddr pfnNextGetDeviceProcAddr; +} VkLayerDeviceLink; + +typedef struct { + VkStructureType sType; // VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO + const void *pNext; + VkLayerFunction function; + union { + VkLayerDeviceLink *pLayerInfo; + PFN_vkSetDeviceLoaderData pfnSetDeviceLoaderData; + } u; +} VkLayerDeviceCreateInfo; + +#ifdef __cplusplus +extern "C" { +#endif + +VKAPI_ATTR VkResult VKAPI_CALL vkNegotiateLoaderLayerInterfaceVersion(VkNegotiateLayerInterface *pVersionStruct); + +typedef enum VkChainType { + VK_CHAIN_TYPE_UNKNOWN = 0, + VK_CHAIN_TYPE_ENUMERATE_INSTANCE_EXTENSION_PROPERTIES = 1, + VK_CHAIN_TYPE_ENUMERATE_INSTANCE_LAYER_PROPERTIES = 2, + VK_CHAIN_TYPE_ENUMERATE_INSTANCE_VERSION = 3, +} VkChainType; + +typedef struct VkChainHeader { + VkChainType type; + uint32_t version; + uint32_t size; +} VkChainHeader; + +typedef struct VkEnumerateInstanceExtensionPropertiesChain { + VkChainHeader header; + VkResult(VKAPI_PTR *pfnNextLayer)(const struct VkEnumerateInstanceExtensionPropertiesChain *, const char *, uint32_t *, + VkExtensionProperties *); + const struct VkEnumerateInstanceExtensionPropertiesChain *pNextLink; + +#if defined(__cplusplus) + inline VkResult CallDown(const char *pLayerName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties) const { + return pfnNextLayer(pNextLink, pLayerName, pPropertyCount, pProperties); + } +#endif +} VkEnumerateInstanceExtensionPropertiesChain; + +typedef struct VkEnumerateInstanceLayerPropertiesChain { + VkChainHeader header; + VkResult(VKAPI_PTR *pfnNextLayer)(const struct VkEnumerateInstanceLayerPropertiesChain *, uint32_t *, VkLayerProperties *); + const struct VkEnumerateInstanceLayerPropertiesChain *pNextLink; + +#if defined(__cplusplus) + inline VkResult CallDown(uint32_t *pPropertyCount, VkLayerProperties *pProperties) const { + return pfnNextLayer(pNextLink, pPropertyCount, pProperties); + } +#endif +} VkEnumerateInstanceLayerPropertiesChain; + +typedef struct VkEnumerateInstanceVersionChain { + VkChainHeader header; + VkResult(VKAPI_PTR *pfnNextLayer)(const struct VkEnumerateInstanceVersionChain *, uint32_t *); + const struct VkEnumerateInstanceVersionChain *pNextLink; + +#if defined(__cplusplus) + inline VkResult CallDown(uint32_t *pApiVersion) const { + return pfnNextLayer(pNextLink, pApiVersion); + } +#endif +} VkEnumerateInstanceVersionChain; + +#ifdef __cplusplus +} +#endif diff --git a/thirdparty/include/vulkan/vk_platform.h b/thirdparty/include/vulkan/vk_platform.h index 72f80493c..dbb011285 100644 --- a/thirdparty/include/vulkan/vk_platform.h +++ b/thirdparty/include/vulkan/vk_platform.h @@ -2,7 +2,7 @@ // File: vk_platform.h // /* -** Copyright (c) 2014-2017 The Khronos Group Inc. +** Copyright (c) 2014-2020 The Khronos Group Inc. ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. @@ -89,32 +89,4 @@ extern "C" } // extern "C" #endif // __cplusplus -// Platform-specific headers required by platform window system extensions. -// These are enabled prior to #including "vulkan.h". The same enable then -// controls inclusion of the extension interfaces in vulkan.h. - -#ifdef VK_USE_PLATFORM_ANDROID_KHR -#include -#endif - -#ifdef VK_USE_PLATFORM_MIR_KHR -#include -#endif - -#ifdef VK_USE_PLATFORM_WAYLAND_KHR -#include -#endif - -#ifdef VK_USE_PLATFORM_WIN32_KHR -#include -#endif - -#ifdef VK_USE_PLATFORM_XLIB_KHR -#include -#endif - -#ifdef VK_USE_PLATFORM_XCB_KHR -#include -#endif - #endif diff --git a/thirdparty/include/vulkan/vk_sdk_platform.h b/thirdparty/include/vulkan/vk_sdk_platform.h new file mode 100644 index 000000000..96d867694 --- /dev/null +++ b/thirdparty/include/vulkan/vk_sdk_platform.h @@ -0,0 +1,69 @@ +// +// File: vk_sdk_platform.h +// +/* + * Copyright (c) 2015-2016 The Khronos Group Inc. + * Copyright (c) 2015-2016 Valve Corporation + * Copyright (c) 2015-2016 LunarG, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef VK_SDK_PLATFORM_H +#define VK_SDK_PLATFORM_H + +#if defined(_WIN32) +#define NOMINMAX +#ifndef __cplusplus +#undef inline +#define inline __inline +#endif // __cplusplus + +#if (defined(_MSC_VER) && _MSC_VER < 1900 /*vs2015*/) +// C99: +// Microsoft didn't implement C99 in Visual Studio; but started adding it with +// VS2013. However, VS2013 still didn't have snprintf(). The following is a +// work-around (Note: The _CRT_SECURE_NO_WARNINGS macro must be set in the +// "CMakeLists.txt" file). +// NOTE: This is fixed in Visual Studio 2015. +#define snprintf _snprintf +#endif + +#define strdup _strdup + +#endif // _WIN32 + +// Check for noexcept support using clang, with fallback to Windows or GCC version numbers +#ifndef NOEXCEPT +#if defined(__clang__) +#if __has_feature(cxx_noexcept) +#define HAS_NOEXCEPT +#endif +#else +#if defined(__GXX_EXPERIMENTAL_CXX0X__) && __GNUC__ * 10 + __GNUC_MINOR__ >= 46 +#define HAS_NOEXCEPT +#else +#if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190023026 && defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS +#define HAS_NOEXCEPT +#endif +#endif +#endif + +#ifdef HAS_NOEXCEPT +#define NOEXCEPT noexcept +#else +#define NOEXCEPT +#endif +#endif + +#endif // VK_SDK_PLATFORM_H diff --git a/thirdparty/include/vulkan/vulkan.h b/thirdparty/include/vulkan/vulkan.h index 3255e7d74..ee3fd3c6f 100644 --- a/thirdparty/include/vulkan/vulkan.h +++ b/thirdparty/include/vulkan/vulkan.h @@ -1,12 +1,8 @@ #ifndef VULKAN_H_ #define VULKAN_H_ 1 -#ifdef __cplusplus -extern "C" { -#endif - /* -** Copyright (c) 2015-2017 The Khronos Group Inc. +** Copyright (c) 2015-2020 The Khronos Group Inc. ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. @@ -21,6096 +17,70 @@ extern "C" { ** limitations under the License. */ -/* -** This header is generated from the Khronos Vulkan XML API Registry. -** -*/ - - -#define VK_VERSION_1_0 1 #include "vk_platform.h" - -#define VK_MAKE_VERSION(major, minor, patch) \ - (((major) << 22) | ((minor) << 12) | (patch)) - -// DEPRECATED: This define has been removed. Specific version defines (e.g. VK_API_VERSION_1_0), or the VK_MAKE_VERSION macro, should be used instead. -//#define VK_API_VERSION VK_MAKE_VERSION(1, 0, 0) - -// Vulkan 1.0 version number -#define VK_API_VERSION_1_0 VK_MAKE_VERSION(1, 0, 0) - -#define VK_VERSION_MAJOR(version) ((uint32_t)(version) >> 22) -#define VK_VERSION_MINOR(version) (((uint32_t)(version) >> 12) & 0x3ff) -#define VK_VERSION_PATCH(version) ((uint32_t)(version) & 0xfff) -// Version of this file -#define VK_HEADER_VERSION 53 - - -#define VK_NULL_HANDLE 0 - - - -#define VK_DEFINE_HANDLE(object) typedef struct object##_T* object; - - -#if !defined(VK_DEFINE_NON_DISPATCHABLE_HANDLE) -#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) - #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef struct object##_T *object; -#else - #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t object; -#endif -#endif - - - -typedef uint32_t VkFlags; -typedef uint32_t VkBool32; -typedef uint64_t VkDeviceSize; -typedef uint32_t VkSampleMask; - -VK_DEFINE_HANDLE(VkInstance) -VK_DEFINE_HANDLE(VkPhysicalDevice) -VK_DEFINE_HANDLE(VkDevice) -VK_DEFINE_HANDLE(VkQueue) -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSemaphore) -VK_DEFINE_HANDLE(VkCommandBuffer) -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkFence) -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDeviceMemory) -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkBuffer) -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkImage) -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkEvent) -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkQueryPool) -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkBufferView) -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkImageView) -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkShaderModule) -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipelineCache) -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipelineLayout) -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkRenderPass) -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipeline) -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorSetLayout) -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSampler) -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorPool) -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorSet) -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkFramebuffer) -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkCommandPool) - -#define VK_LOD_CLAMP_NONE 1000.0f -#define VK_REMAINING_MIP_LEVELS (~0U) -#define VK_REMAINING_ARRAY_LAYERS (~0U) -#define VK_WHOLE_SIZE (~0ULL) -#define VK_ATTACHMENT_UNUSED (~0U) -#define VK_TRUE 1 -#define VK_FALSE 0 -#define VK_QUEUE_FAMILY_IGNORED (~0U) -#define VK_SUBPASS_EXTERNAL (~0U) -#define VK_MAX_PHYSICAL_DEVICE_NAME_SIZE 256 -#define VK_UUID_SIZE 16 -#define VK_MAX_MEMORY_TYPES 32 -#define VK_MAX_MEMORY_HEAPS 16 -#define VK_MAX_EXTENSION_NAME_SIZE 256 -#define VK_MAX_DESCRIPTION_SIZE 256 - - -typedef enum VkPipelineCacheHeaderVersion { - VK_PIPELINE_CACHE_HEADER_VERSION_ONE = 1, - VK_PIPELINE_CACHE_HEADER_VERSION_BEGIN_RANGE = VK_PIPELINE_CACHE_HEADER_VERSION_ONE, - VK_PIPELINE_CACHE_HEADER_VERSION_END_RANGE = VK_PIPELINE_CACHE_HEADER_VERSION_ONE, - VK_PIPELINE_CACHE_HEADER_VERSION_RANGE_SIZE = (VK_PIPELINE_CACHE_HEADER_VERSION_ONE - VK_PIPELINE_CACHE_HEADER_VERSION_ONE + 1), - VK_PIPELINE_CACHE_HEADER_VERSION_MAX_ENUM = 0x7FFFFFFF -} VkPipelineCacheHeaderVersion; - -typedef enum VkResult { - VK_SUCCESS = 0, - VK_NOT_READY = 1, - VK_TIMEOUT = 2, - VK_EVENT_SET = 3, - VK_EVENT_RESET = 4, - VK_INCOMPLETE = 5, - VK_ERROR_OUT_OF_HOST_MEMORY = -1, - VK_ERROR_OUT_OF_DEVICE_MEMORY = -2, - VK_ERROR_INITIALIZATION_FAILED = -3, - VK_ERROR_DEVICE_LOST = -4, - VK_ERROR_MEMORY_MAP_FAILED = -5, - VK_ERROR_LAYER_NOT_PRESENT = -6, - VK_ERROR_EXTENSION_NOT_PRESENT = -7, - VK_ERROR_FEATURE_NOT_PRESENT = -8, - VK_ERROR_INCOMPATIBLE_DRIVER = -9, - VK_ERROR_TOO_MANY_OBJECTS = -10, - VK_ERROR_FORMAT_NOT_SUPPORTED = -11, - VK_ERROR_FRAGMENTED_POOL = -12, - VK_ERROR_SURFACE_LOST_KHR = -1000000000, - VK_ERROR_NATIVE_WINDOW_IN_USE_KHR = -1000000001, - VK_SUBOPTIMAL_KHR = 1000001003, - VK_ERROR_OUT_OF_DATE_KHR = -1000001004, - VK_ERROR_INCOMPATIBLE_DISPLAY_KHR = -1000003001, - VK_ERROR_VALIDATION_FAILED_EXT = -1000011001, - VK_ERROR_INVALID_SHADER_NV = -1000012000, - VK_ERROR_OUT_OF_POOL_MEMORY_KHR = -1000069000, - VK_ERROR_INVALID_EXTERNAL_HANDLE_KHX = -1000072003, - VK_RESULT_BEGIN_RANGE = VK_ERROR_FRAGMENTED_POOL, - VK_RESULT_END_RANGE = VK_INCOMPLETE, - VK_RESULT_RANGE_SIZE = (VK_INCOMPLETE - VK_ERROR_FRAGMENTED_POOL + 1), - VK_RESULT_MAX_ENUM = 0x7FFFFFFF -} VkResult; - -typedef enum VkStructureType { - VK_STRUCTURE_TYPE_APPLICATION_INFO = 0, - VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO = 1, - VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO = 2, - VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO = 3, - VK_STRUCTURE_TYPE_SUBMIT_INFO = 4, - VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO = 5, - VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE = 6, - VK_STRUCTURE_TYPE_BIND_SPARSE_INFO = 7, - VK_STRUCTURE_TYPE_FENCE_CREATE_INFO = 8, - VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO = 9, - VK_STRUCTURE_TYPE_EVENT_CREATE_INFO = 10, - VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO = 11, - VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO = 12, - VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO = 13, - VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO = 14, - VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO = 15, - VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO = 16, - VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO = 17, - VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO = 18, - VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO = 19, - VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO = 20, - VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO = 21, - VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO = 22, - VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO = 23, - VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO = 24, - VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO = 25, - VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO = 26, - VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO = 27, - VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO = 28, - VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO = 29, - VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO = 30, - VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO = 31, - VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO = 32, - VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO = 33, - VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO = 34, - VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET = 35, - VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET = 36, - VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO = 37, - VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO = 38, - VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO = 39, - VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO = 40, - VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO = 41, - VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO = 42, - VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO = 43, - VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER = 44, - VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER = 45, - VK_STRUCTURE_TYPE_MEMORY_BARRIER = 46, - VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO = 47, - VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO = 48, - VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR = 1000001000, - VK_STRUCTURE_TYPE_PRESENT_INFO_KHR = 1000001001, - VK_STRUCTURE_TYPE_DISPLAY_MODE_CREATE_INFO_KHR = 1000002000, - VK_STRUCTURE_TYPE_DISPLAY_SURFACE_CREATE_INFO_KHR = 1000002001, - VK_STRUCTURE_TYPE_DISPLAY_PRESENT_INFO_KHR = 1000003000, - VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR = 1000004000, - VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR = 1000005000, - VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR = 1000006000, - VK_STRUCTURE_TYPE_MIR_SURFACE_CREATE_INFO_KHR = 1000007000, - VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR = 1000008000, - VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR = 1000009000, - VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT = 1000011000, - VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_RASTERIZATION_ORDER_AMD = 1000018000, - VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT = 1000022000, - VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_TAG_INFO_EXT = 1000022001, - VK_STRUCTURE_TYPE_DEBUG_MARKER_MARKER_INFO_EXT = 1000022002, - VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_IMAGE_CREATE_INFO_NV = 1000026000, - VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_BUFFER_CREATE_INFO_NV = 1000026001, - VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV = 1000026002, - VK_STRUCTURE_TYPE_TEXTURE_LOD_GATHER_FORMAT_PROPERTIES_AMD = 1000041000, - VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO_KHX = 1000053000, - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES_KHX = 1000053001, - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES_KHX = 1000053002, - VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO_NV = 1000056000, - VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO_NV = 1000056001, - VK_STRUCTURE_TYPE_IMPORT_MEMORY_WIN32_HANDLE_INFO_NV = 1000057000, - VK_STRUCTURE_TYPE_EXPORT_MEMORY_WIN32_HANDLE_INFO_NV = 1000057001, - VK_STRUCTURE_TYPE_WIN32_KEYED_MUTEX_ACQUIRE_RELEASE_INFO_NV = 1000058000, - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR = 1000059000, - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR = 1000059001, - VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2_KHR = 1000059002, - VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2_KHR = 1000059003, - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2_KHR = 1000059004, - VK_STRUCTURE_TYPE_QUEUE_FAMILY_PROPERTIES_2_KHR = 1000059005, - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2_KHR = 1000059006, - VK_STRUCTURE_TYPE_SPARSE_IMAGE_FORMAT_PROPERTIES_2_KHR = 1000059007, - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SPARSE_IMAGE_FORMAT_INFO_2_KHR = 1000059008, - VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO_KHX = 1000060000, - VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO_KHX = 1000060001, - VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO_KHX = 1000060002, - VK_STRUCTURE_TYPE_DEVICE_GROUP_RENDER_PASS_BEGIN_INFO_KHX = 1000060003, - VK_STRUCTURE_TYPE_DEVICE_GROUP_COMMAND_BUFFER_BEGIN_INFO_KHX = 1000060004, - VK_STRUCTURE_TYPE_DEVICE_GROUP_SUBMIT_INFO_KHX = 1000060005, - VK_STRUCTURE_TYPE_DEVICE_GROUP_BIND_SPARSE_INFO_KHX = 1000060006, - VK_STRUCTURE_TYPE_DEVICE_GROUP_PRESENT_CAPABILITIES_KHX = 1000060007, - VK_STRUCTURE_TYPE_IMAGE_SWAPCHAIN_CREATE_INFO_KHX = 1000060008, - VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHX = 1000060009, - VK_STRUCTURE_TYPE_ACQUIRE_NEXT_IMAGE_INFO_KHX = 1000060010, - VK_STRUCTURE_TYPE_DEVICE_GROUP_PRESENT_INFO_KHX = 1000060011, - VK_STRUCTURE_TYPE_DEVICE_GROUP_SWAPCHAIN_CREATE_INFO_KHX = 1000060012, - VK_STRUCTURE_TYPE_VALIDATION_FLAGS_EXT = 1000061000, - VK_STRUCTURE_TYPE_VI_SURFACE_CREATE_INFO_NN = 1000062000, - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GROUP_PROPERTIES_KHX = 1000070000, - VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO_KHX = 1000070001, - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO_KHX = 1000071000, - VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES_KHX = 1000071001, - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_BUFFER_INFO_KHX = 1000071002, - VK_STRUCTURE_TYPE_EXTERNAL_BUFFER_PROPERTIES_KHX = 1000071003, - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES_KHX = 1000071004, - VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO_KHX = 1000072000, - VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO_KHX = 1000072001, - VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO_KHX = 1000072002, - VK_STRUCTURE_TYPE_IMPORT_MEMORY_WIN32_HANDLE_INFO_KHX = 1000073000, - VK_STRUCTURE_TYPE_EXPORT_MEMORY_WIN32_HANDLE_INFO_KHX = 1000073001, - VK_STRUCTURE_TYPE_MEMORY_WIN32_HANDLE_PROPERTIES_KHX = 1000073002, - VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHX = 1000074000, - VK_STRUCTURE_TYPE_MEMORY_FD_PROPERTIES_KHX = 1000074001, - VK_STRUCTURE_TYPE_WIN32_KEYED_MUTEX_ACQUIRE_RELEASE_INFO_KHX = 1000075000, - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_SEMAPHORE_INFO_KHX = 1000076000, - VK_STRUCTURE_TYPE_EXTERNAL_SEMAPHORE_PROPERTIES_KHX = 1000076001, - VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO_KHX = 1000077000, - VK_STRUCTURE_TYPE_IMPORT_SEMAPHORE_WIN32_HANDLE_INFO_KHX = 1000078000, - VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_WIN32_HANDLE_INFO_KHX = 1000078001, - VK_STRUCTURE_TYPE_D3D12_FENCE_SUBMIT_INFO_KHX = 1000078002, - VK_STRUCTURE_TYPE_IMPORT_SEMAPHORE_FD_INFO_KHX = 1000079000, - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PUSH_DESCRIPTOR_PROPERTIES_KHR = 1000080000, - VK_STRUCTURE_TYPE_PRESENT_REGIONS_KHR = 1000084000, - VK_STRUCTURE_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO_KHR = 1000085000, - VK_STRUCTURE_TYPE_OBJECT_TABLE_CREATE_INFO_NVX = 1000086000, - VK_STRUCTURE_TYPE_INDIRECT_COMMANDS_LAYOUT_CREATE_INFO_NVX = 1000086001, - VK_STRUCTURE_TYPE_CMD_PROCESS_COMMANDS_INFO_NVX = 1000086002, - VK_STRUCTURE_TYPE_CMD_RESERVE_SPACE_FOR_COMMANDS_INFO_NVX = 1000086003, - VK_STRUCTURE_TYPE_DEVICE_GENERATED_COMMANDS_LIMITS_NVX = 1000086004, - VK_STRUCTURE_TYPE_DEVICE_GENERATED_COMMANDS_FEATURES_NVX = 1000086005, - VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV = 1000087000, - VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES2_EXT = 1000090000, - VK_STRUCTURE_TYPE_DISPLAY_POWER_INFO_EXT = 1000091000, - VK_STRUCTURE_TYPE_DEVICE_EVENT_INFO_EXT = 1000091001, - VK_STRUCTURE_TYPE_DISPLAY_EVENT_INFO_EXT = 1000091002, - VK_STRUCTURE_TYPE_SWAPCHAIN_COUNTER_CREATE_INFO_EXT = 1000091003, - VK_STRUCTURE_TYPE_PRESENT_TIMES_INFO_GOOGLE = 1000092000, - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PER_VIEW_ATTRIBUTES_PROPERTIES_NVX = 1000097000, - VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV = 1000098000, - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DISCARD_RECTANGLE_PROPERTIES_EXT = 1000099000, - VK_STRUCTURE_TYPE_PIPELINE_DISCARD_RECTANGLE_STATE_CREATE_INFO_EXT = 1000099001, - VK_STRUCTURE_TYPE_HDR_METADATA_EXT = 1000105000, - VK_STRUCTURE_TYPE_SHARED_PRESENT_SURFACE_CAPABILITIES_KHR = 1000111000, - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR = 1000119000, - VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_KHR = 1000119001, - VK_STRUCTURE_TYPE_SURFACE_FORMAT_2_KHR = 1000119002, - VK_STRUCTURE_TYPE_IOS_SURFACE_CREATE_INFO_MVK = 1000122000, - VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK = 1000123000, - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES_EXT = 1000130000, - VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO_EXT = 1000130001, - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_FEATURES_EXT = 1000148000, - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_PROPERTIES_EXT = 1000148001, - VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT = 1000148002, - VK_STRUCTURE_TYPE_PIPELINE_COVERAGE_TO_COLOR_STATE_CREATE_INFO_NV = 1000149000, - VK_STRUCTURE_TYPE_PIPELINE_COVERAGE_MODULATION_STATE_CREATE_INFO_NV = 1000152000, - VK_STRUCTURE_TYPE_BEGIN_RANGE = VK_STRUCTURE_TYPE_APPLICATION_INFO, - VK_STRUCTURE_TYPE_END_RANGE = VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO, - VK_STRUCTURE_TYPE_RANGE_SIZE = (VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO - VK_STRUCTURE_TYPE_APPLICATION_INFO + 1), - VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF -} VkStructureType; - -typedef enum VkSystemAllocationScope { - VK_SYSTEM_ALLOCATION_SCOPE_COMMAND = 0, - VK_SYSTEM_ALLOCATION_SCOPE_OBJECT = 1, - VK_SYSTEM_ALLOCATION_SCOPE_CACHE = 2, - VK_SYSTEM_ALLOCATION_SCOPE_DEVICE = 3, - VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE = 4, - VK_SYSTEM_ALLOCATION_SCOPE_BEGIN_RANGE = VK_SYSTEM_ALLOCATION_SCOPE_COMMAND, - VK_SYSTEM_ALLOCATION_SCOPE_END_RANGE = VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE, - VK_SYSTEM_ALLOCATION_SCOPE_RANGE_SIZE = (VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE - VK_SYSTEM_ALLOCATION_SCOPE_COMMAND + 1), - VK_SYSTEM_ALLOCATION_SCOPE_MAX_ENUM = 0x7FFFFFFF -} VkSystemAllocationScope; - -typedef enum VkInternalAllocationType { - VK_INTERNAL_ALLOCATION_TYPE_EXECUTABLE = 0, - VK_INTERNAL_ALLOCATION_TYPE_BEGIN_RANGE = VK_INTERNAL_ALLOCATION_TYPE_EXECUTABLE, - VK_INTERNAL_ALLOCATION_TYPE_END_RANGE = VK_INTERNAL_ALLOCATION_TYPE_EXECUTABLE, - VK_INTERNAL_ALLOCATION_TYPE_RANGE_SIZE = (VK_INTERNAL_ALLOCATION_TYPE_EXECUTABLE - VK_INTERNAL_ALLOCATION_TYPE_EXECUTABLE + 1), - VK_INTERNAL_ALLOCATION_TYPE_MAX_ENUM = 0x7FFFFFFF -} VkInternalAllocationType; - -typedef enum VkFormat { - VK_FORMAT_UNDEFINED = 0, - VK_FORMAT_R4G4_UNORM_PACK8 = 1, - VK_FORMAT_R4G4B4A4_UNORM_PACK16 = 2, - VK_FORMAT_B4G4R4A4_UNORM_PACK16 = 3, - VK_FORMAT_R5G6B5_UNORM_PACK16 = 4, - VK_FORMAT_B5G6R5_UNORM_PACK16 = 5, - VK_FORMAT_R5G5B5A1_UNORM_PACK16 = 6, - VK_FORMAT_B5G5R5A1_UNORM_PACK16 = 7, - VK_FORMAT_A1R5G5B5_UNORM_PACK16 = 8, - VK_FORMAT_R8_UNORM = 9, - VK_FORMAT_R8_SNORM = 10, - VK_FORMAT_R8_USCALED = 11, - VK_FORMAT_R8_SSCALED = 12, - VK_FORMAT_R8_UINT = 13, - VK_FORMAT_R8_SINT = 14, - VK_FORMAT_R8_SRGB = 15, - VK_FORMAT_R8G8_UNORM = 16, - VK_FORMAT_R8G8_SNORM = 17, - VK_FORMAT_R8G8_USCALED = 18, - VK_FORMAT_R8G8_SSCALED = 19, - VK_FORMAT_R8G8_UINT = 20, - VK_FORMAT_R8G8_SINT = 21, - VK_FORMAT_R8G8_SRGB = 22, - VK_FORMAT_R8G8B8_UNORM = 23, - VK_FORMAT_R8G8B8_SNORM = 24, - VK_FORMAT_R8G8B8_USCALED = 25, - VK_FORMAT_R8G8B8_SSCALED = 26, - VK_FORMAT_R8G8B8_UINT = 27, - VK_FORMAT_R8G8B8_SINT = 28, - VK_FORMAT_R8G8B8_SRGB = 29, - VK_FORMAT_B8G8R8_UNORM = 30, - VK_FORMAT_B8G8R8_SNORM = 31, - VK_FORMAT_B8G8R8_USCALED = 32, - VK_FORMAT_B8G8R8_SSCALED = 33, - VK_FORMAT_B8G8R8_UINT = 34, - VK_FORMAT_B8G8R8_SINT = 35, - VK_FORMAT_B8G8R8_SRGB = 36, - VK_FORMAT_R8G8B8A8_UNORM = 37, - VK_FORMAT_R8G8B8A8_SNORM = 38, - VK_FORMAT_R8G8B8A8_USCALED = 39, - VK_FORMAT_R8G8B8A8_SSCALED = 40, - VK_FORMAT_R8G8B8A8_UINT = 41, - VK_FORMAT_R8G8B8A8_SINT = 42, - VK_FORMAT_R8G8B8A8_SRGB = 43, - VK_FORMAT_B8G8R8A8_UNORM = 44, - VK_FORMAT_B8G8R8A8_SNORM = 45, - VK_FORMAT_B8G8R8A8_USCALED = 46, - VK_FORMAT_B8G8R8A8_SSCALED = 47, - VK_FORMAT_B8G8R8A8_UINT = 48, - VK_FORMAT_B8G8R8A8_SINT = 49, - VK_FORMAT_B8G8R8A8_SRGB = 50, - VK_FORMAT_A8B8G8R8_UNORM_PACK32 = 51, - VK_FORMAT_A8B8G8R8_SNORM_PACK32 = 52, - VK_FORMAT_A8B8G8R8_USCALED_PACK32 = 53, - VK_FORMAT_A8B8G8R8_SSCALED_PACK32 = 54, - VK_FORMAT_A8B8G8R8_UINT_PACK32 = 55, - VK_FORMAT_A8B8G8R8_SINT_PACK32 = 56, - VK_FORMAT_A8B8G8R8_SRGB_PACK32 = 57, - VK_FORMAT_A2R10G10B10_UNORM_PACK32 = 58, - VK_FORMAT_A2R10G10B10_SNORM_PACK32 = 59, - VK_FORMAT_A2R10G10B10_USCALED_PACK32 = 60, - VK_FORMAT_A2R10G10B10_SSCALED_PACK32 = 61, - VK_FORMAT_A2R10G10B10_UINT_PACK32 = 62, - VK_FORMAT_A2R10G10B10_SINT_PACK32 = 63, - VK_FORMAT_A2B10G10R10_UNORM_PACK32 = 64, - VK_FORMAT_A2B10G10R10_SNORM_PACK32 = 65, - VK_FORMAT_A2B10G10R10_USCALED_PACK32 = 66, - VK_FORMAT_A2B10G10R10_SSCALED_PACK32 = 67, - VK_FORMAT_A2B10G10R10_UINT_PACK32 = 68, - VK_FORMAT_A2B10G10R10_SINT_PACK32 = 69, - VK_FORMAT_R16_UNORM = 70, - VK_FORMAT_R16_SNORM = 71, - VK_FORMAT_R16_USCALED = 72, - VK_FORMAT_R16_SSCALED = 73, - VK_FORMAT_R16_UINT = 74, - VK_FORMAT_R16_SINT = 75, - VK_FORMAT_R16_SFLOAT = 76, - VK_FORMAT_R16G16_UNORM = 77, - VK_FORMAT_R16G16_SNORM = 78, - VK_FORMAT_R16G16_USCALED = 79, - VK_FORMAT_R16G16_SSCALED = 80, - VK_FORMAT_R16G16_UINT = 81, - VK_FORMAT_R16G16_SINT = 82, - VK_FORMAT_R16G16_SFLOAT = 83, - VK_FORMAT_R16G16B16_UNORM = 84, - VK_FORMAT_R16G16B16_SNORM = 85, - VK_FORMAT_R16G16B16_USCALED = 86, - VK_FORMAT_R16G16B16_SSCALED = 87, - VK_FORMAT_R16G16B16_UINT = 88, - VK_FORMAT_R16G16B16_SINT = 89, - VK_FORMAT_R16G16B16_SFLOAT = 90, - VK_FORMAT_R16G16B16A16_UNORM = 91, - VK_FORMAT_R16G16B16A16_SNORM = 92, - VK_FORMAT_R16G16B16A16_USCALED = 93, - VK_FORMAT_R16G16B16A16_SSCALED = 94, - VK_FORMAT_R16G16B16A16_UINT = 95, - VK_FORMAT_R16G16B16A16_SINT = 96, - VK_FORMAT_R16G16B16A16_SFLOAT = 97, - VK_FORMAT_R32_UINT = 98, - VK_FORMAT_R32_SINT = 99, - VK_FORMAT_R32_SFLOAT = 100, - VK_FORMAT_R32G32_UINT = 101, - VK_FORMAT_R32G32_SINT = 102, - VK_FORMAT_R32G32_SFLOAT = 103, - VK_FORMAT_R32G32B32_UINT = 104, - VK_FORMAT_R32G32B32_SINT = 105, - VK_FORMAT_R32G32B32_SFLOAT = 106, - VK_FORMAT_R32G32B32A32_UINT = 107, - VK_FORMAT_R32G32B32A32_SINT = 108, - VK_FORMAT_R32G32B32A32_SFLOAT = 109, - VK_FORMAT_R64_UINT = 110, - VK_FORMAT_R64_SINT = 111, - VK_FORMAT_R64_SFLOAT = 112, - VK_FORMAT_R64G64_UINT = 113, - VK_FORMAT_R64G64_SINT = 114, - VK_FORMAT_R64G64_SFLOAT = 115, - VK_FORMAT_R64G64B64_UINT = 116, - VK_FORMAT_R64G64B64_SINT = 117, - VK_FORMAT_R64G64B64_SFLOAT = 118, - VK_FORMAT_R64G64B64A64_UINT = 119, - VK_FORMAT_R64G64B64A64_SINT = 120, - VK_FORMAT_R64G64B64A64_SFLOAT = 121, - VK_FORMAT_B10G11R11_UFLOAT_PACK32 = 122, - VK_FORMAT_E5B9G9R9_UFLOAT_PACK32 = 123, - VK_FORMAT_D16_UNORM = 124, - VK_FORMAT_X8_D24_UNORM_PACK32 = 125, - VK_FORMAT_D32_SFLOAT = 126, - VK_FORMAT_S8_UINT = 127, - VK_FORMAT_D16_UNORM_S8_UINT = 128, - VK_FORMAT_D24_UNORM_S8_UINT = 129, - VK_FORMAT_D32_SFLOAT_S8_UINT = 130, - VK_FORMAT_BC1_RGB_UNORM_BLOCK = 131, - VK_FORMAT_BC1_RGB_SRGB_BLOCK = 132, - VK_FORMAT_BC1_RGBA_UNORM_BLOCK = 133, - VK_FORMAT_BC1_RGBA_SRGB_BLOCK = 134, - VK_FORMAT_BC2_UNORM_BLOCK = 135, - VK_FORMAT_BC2_SRGB_BLOCK = 136, - VK_FORMAT_BC3_UNORM_BLOCK = 137, - VK_FORMAT_BC3_SRGB_BLOCK = 138, - VK_FORMAT_BC4_UNORM_BLOCK = 139, - VK_FORMAT_BC4_SNORM_BLOCK = 140, - VK_FORMAT_BC5_UNORM_BLOCK = 141, - VK_FORMAT_BC5_SNORM_BLOCK = 142, - VK_FORMAT_BC6H_UFLOAT_BLOCK = 143, - VK_FORMAT_BC6H_SFLOAT_BLOCK = 144, - VK_FORMAT_BC7_UNORM_BLOCK = 145, - VK_FORMAT_BC7_SRGB_BLOCK = 146, - VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK = 147, - VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK = 148, - VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK = 149, - VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK = 150, - VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK = 151, - VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK = 152, - VK_FORMAT_EAC_R11_UNORM_BLOCK = 153, - VK_FORMAT_EAC_R11_SNORM_BLOCK = 154, - VK_FORMAT_EAC_R11G11_UNORM_BLOCK = 155, - VK_FORMAT_EAC_R11G11_SNORM_BLOCK = 156, - VK_FORMAT_ASTC_4x4_UNORM_BLOCK = 157, - VK_FORMAT_ASTC_4x4_SRGB_BLOCK = 158, - VK_FORMAT_ASTC_5x4_UNORM_BLOCK = 159, - VK_FORMAT_ASTC_5x4_SRGB_BLOCK = 160, - VK_FORMAT_ASTC_5x5_UNORM_BLOCK = 161, - VK_FORMAT_ASTC_5x5_SRGB_BLOCK = 162, - VK_FORMAT_ASTC_6x5_UNORM_BLOCK = 163, - VK_FORMAT_ASTC_6x5_SRGB_BLOCK = 164, - VK_FORMAT_ASTC_6x6_UNORM_BLOCK = 165, - VK_FORMAT_ASTC_6x6_SRGB_BLOCK = 166, - VK_FORMAT_ASTC_8x5_UNORM_BLOCK = 167, - VK_FORMAT_ASTC_8x5_SRGB_BLOCK = 168, - VK_FORMAT_ASTC_8x6_UNORM_BLOCK = 169, - VK_FORMAT_ASTC_8x6_SRGB_BLOCK = 170, - VK_FORMAT_ASTC_8x8_UNORM_BLOCK = 171, - VK_FORMAT_ASTC_8x8_SRGB_BLOCK = 172, - VK_FORMAT_ASTC_10x5_UNORM_BLOCK = 173, - VK_FORMAT_ASTC_10x5_SRGB_BLOCK = 174, - VK_FORMAT_ASTC_10x6_UNORM_BLOCK = 175, - VK_FORMAT_ASTC_10x6_SRGB_BLOCK = 176, - VK_FORMAT_ASTC_10x8_UNORM_BLOCK = 177, - VK_FORMAT_ASTC_10x8_SRGB_BLOCK = 178, - VK_FORMAT_ASTC_10x10_UNORM_BLOCK = 179, - VK_FORMAT_ASTC_10x10_SRGB_BLOCK = 180, - VK_FORMAT_ASTC_12x10_UNORM_BLOCK = 181, - VK_FORMAT_ASTC_12x10_SRGB_BLOCK = 182, - VK_FORMAT_ASTC_12x12_UNORM_BLOCK = 183, - VK_FORMAT_ASTC_12x12_SRGB_BLOCK = 184, - VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG = 1000054000, - VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG = 1000054001, - VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG = 1000054002, - VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG = 1000054003, - VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG = 1000054004, - VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG = 1000054005, - VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG = 1000054006, - VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG = 1000054007, - VK_FORMAT_BEGIN_RANGE = VK_FORMAT_UNDEFINED, - VK_FORMAT_END_RANGE = VK_FORMAT_ASTC_12x12_SRGB_BLOCK, - VK_FORMAT_RANGE_SIZE = (VK_FORMAT_ASTC_12x12_SRGB_BLOCK - VK_FORMAT_UNDEFINED + 1), - VK_FORMAT_MAX_ENUM = 0x7FFFFFFF -} VkFormat; - -typedef enum VkImageType { - VK_IMAGE_TYPE_1D = 0, - VK_IMAGE_TYPE_2D = 1, - VK_IMAGE_TYPE_3D = 2, - VK_IMAGE_TYPE_BEGIN_RANGE = VK_IMAGE_TYPE_1D, - VK_IMAGE_TYPE_END_RANGE = VK_IMAGE_TYPE_3D, - VK_IMAGE_TYPE_RANGE_SIZE = (VK_IMAGE_TYPE_3D - VK_IMAGE_TYPE_1D + 1), - VK_IMAGE_TYPE_MAX_ENUM = 0x7FFFFFFF -} VkImageType; - -typedef enum VkImageTiling { - VK_IMAGE_TILING_OPTIMAL = 0, - VK_IMAGE_TILING_LINEAR = 1, - VK_IMAGE_TILING_BEGIN_RANGE = VK_IMAGE_TILING_OPTIMAL, - VK_IMAGE_TILING_END_RANGE = VK_IMAGE_TILING_LINEAR, - VK_IMAGE_TILING_RANGE_SIZE = (VK_IMAGE_TILING_LINEAR - VK_IMAGE_TILING_OPTIMAL + 1), - VK_IMAGE_TILING_MAX_ENUM = 0x7FFFFFFF -} VkImageTiling; - -typedef enum VkPhysicalDeviceType { - VK_PHYSICAL_DEVICE_TYPE_OTHER = 0, - VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU = 1, - VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU = 2, - VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU = 3, - VK_PHYSICAL_DEVICE_TYPE_CPU = 4, - VK_PHYSICAL_DEVICE_TYPE_BEGIN_RANGE = VK_PHYSICAL_DEVICE_TYPE_OTHER, - VK_PHYSICAL_DEVICE_TYPE_END_RANGE = VK_PHYSICAL_DEVICE_TYPE_CPU, - VK_PHYSICAL_DEVICE_TYPE_RANGE_SIZE = (VK_PHYSICAL_DEVICE_TYPE_CPU - VK_PHYSICAL_DEVICE_TYPE_OTHER + 1), - VK_PHYSICAL_DEVICE_TYPE_MAX_ENUM = 0x7FFFFFFF -} VkPhysicalDeviceType; - -typedef enum VkQueryType { - VK_QUERY_TYPE_OCCLUSION = 0, - VK_QUERY_TYPE_PIPELINE_STATISTICS = 1, - VK_QUERY_TYPE_TIMESTAMP = 2, - VK_QUERY_TYPE_BEGIN_RANGE = VK_QUERY_TYPE_OCCLUSION, - VK_QUERY_TYPE_END_RANGE = VK_QUERY_TYPE_TIMESTAMP, - VK_QUERY_TYPE_RANGE_SIZE = (VK_QUERY_TYPE_TIMESTAMP - VK_QUERY_TYPE_OCCLUSION + 1), - VK_QUERY_TYPE_MAX_ENUM = 0x7FFFFFFF -} VkQueryType; - -typedef enum VkSharingMode { - VK_SHARING_MODE_EXCLUSIVE = 0, - VK_SHARING_MODE_CONCURRENT = 1, - VK_SHARING_MODE_BEGIN_RANGE = VK_SHARING_MODE_EXCLUSIVE, - VK_SHARING_MODE_END_RANGE = VK_SHARING_MODE_CONCURRENT, - VK_SHARING_MODE_RANGE_SIZE = (VK_SHARING_MODE_CONCURRENT - VK_SHARING_MODE_EXCLUSIVE + 1), - VK_SHARING_MODE_MAX_ENUM = 0x7FFFFFFF -} VkSharingMode; - -typedef enum VkImageLayout { - VK_IMAGE_LAYOUT_UNDEFINED = 0, - VK_IMAGE_LAYOUT_GENERAL = 1, - VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL = 2, - VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL = 3, - VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL = 4, - VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL = 5, - VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL = 6, - VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL = 7, - VK_IMAGE_LAYOUT_PREINITIALIZED = 8, - VK_IMAGE_LAYOUT_PRESENT_SRC_KHR = 1000001002, - VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR = 1000111000, - VK_IMAGE_LAYOUT_BEGIN_RANGE = VK_IMAGE_LAYOUT_UNDEFINED, - VK_IMAGE_LAYOUT_END_RANGE = VK_IMAGE_LAYOUT_PREINITIALIZED, - VK_IMAGE_LAYOUT_RANGE_SIZE = (VK_IMAGE_LAYOUT_PREINITIALIZED - VK_IMAGE_LAYOUT_UNDEFINED + 1), - VK_IMAGE_LAYOUT_MAX_ENUM = 0x7FFFFFFF -} VkImageLayout; - -typedef enum VkImageViewType { - VK_IMAGE_VIEW_TYPE_1D = 0, - VK_IMAGE_VIEW_TYPE_2D = 1, - VK_IMAGE_VIEW_TYPE_3D = 2, - VK_IMAGE_VIEW_TYPE_CUBE = 3, - VK_IMAGE_VIEW_TYPE_1D_ARRAY = 4, - VK_IMAGE_VIEW_TYPE_2D_ARRAY = 5, - VK_IMAGE_VIEW_TYPE_CUBE_ARRAY = 6, - VK_IMAGE_VIEW_TYPE_BEGIN_RANGE = VK_IMAGE_VIEW_TYPE_1D, - VK_IMAGE_VIEW_TYPE_END_RANGE = VK_IMAGE_VIEW_TYPE_CUBE_ARRAY, - VK_IMAGE_VIEW_TYPE_RANGE_SIZE = (VK_IMAGE_VIEW_TYPE_CUBE_ARRAY - VK_IMAGE_VIEW_TYPE_1D + 1), - VK_IMAGE_VIEW_TYPE_MAX_ENUM = 0x7FFFFFFF -} VkImageViewType; - -typedef enum VkComponentSwizzle { - VK_COMPONENT_SWIZZLE_IDENTITY = 0, - VK_COMPONENT_SWIZZLE_ZERO = 1, - VK_COMPONENT_SWIZZLE_ONE = 2, - VK_COMPONENT_SWIZZLE_R = 3, - VK_COMPONENT_SWIZZLE_G = 4, - VK_COMPONENT_SWIZZLE_B = 5, - VK_COMPONENT_SWIZZLE_A = 6, - VK_COMPONENT_SWIZZLE_BEGIN_RANGE = VK_COMPONENT_SWIZZLE_IDENTITY, - VK_COMPONENT_SWIZZLE_END_RANGE = VK_COMPONENT_SWIZZLE_A, - VK_COMPONENT_SWIZZLE_RANGE_SIZE = (VK_COMPONENT_SWIZZLE_A - VK_COMPONENT_SWIZZLE_IDENTITY + 1), - VK_COMPONENT_SWIZZLE_MAX_ENUM = 0x7FFFFFFF -} VkComponentSwizzle; - -typedef enum VkVertexInputRate { - VK_VERTEX_INPUT_RATE_VERTEX = 0, - VK_VERTEX_INPUT_RATE_INSTANCE = 1, - VK_VERTEX_INPUT_RATE_BEGIN_RANGE = VK_VERTEX_INPUT_RATE_VERTEX, - VK_VERTEX_INPUT_RATE_END_RANGE = VK_VERTEX_INPUT_RATE_INSTANCE, - VK_VERTEX_INPUT_RATE_RANGE_SIZE = (VK_VERTEX_INPUT_RATE_INSTANCE - VK_VERTEX_INPUT_RATE_VERTEX + 1), - VK_VERTEX_INPUT_RATE_MAX_ENUM = 0x7FFFFFFF -} VkVertexInputRate; - -typedef enum VkPrimitiveTopology { - VK_PRIMITIVE_TOPOLOGY_POINT_LIST = 0, - VK_PRIMITIVE_TOPOLOGY_LINE_LIST = 1, - VK_PRIMITIVE_TOPOLOGY_LINE_STRIP = 2, - VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST = 3, - VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP = 4, - VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN = 5, - VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY = 6, - VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY = 7, - VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY = 8, - VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY = 9, - VK_PRIMITIVE_TOPOLOGY_PATCH_LIST = 10, - VK_PRIMITIVE_TOPOLOGY_BEGIN_RANGE = VK_PRIMITIVE_TOPOLOGY_POINT_LIST, - VK_PRIMITIVE_TOPOLOGY_END_RANGE = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, - VK_PRIMITIVE_TOPOLOGY_RANGE_SIZE = (VK_PRIMITIVE_TOPOLOGY_PATCH_LIST - VK_PRIMITIVE_TOPOLOGY_POINT_LIST + 1), - VK_PRIMITIVE_TOPOLOGY_MAX_ENUM = 0x7FFFFFFF -} VkPrimitiveTopology; - -typedef enum VkPolygonMode { - VK_POLYGON_MODE_FILL = 0, - VK_POLYGON_MODE_LINE = 1, - VK_POLYGON_MODE_POINT = 2, - VK_POLYGON_MODE_FILL_RECTANGLE_NV = 1000153000, - VK_POLYGON_MODE_BEGIN_RANGE = VK_POLYGON_MODE_FILL, - VK_POLYGON_MODE_END_RANGE = VK_POLYGON_MODE_POINT, - VK_POLYGON_MODE_RANGE_SIZE = (VK_POLYGON_MODE_POINT - VK_POLYGON_MODE_FILL + 1), - VK_POLYGON_MODE_MAX_ENUM = 0x7FFFFFFF -} VkPolygonMode; - -typedef enum VkFrontFace { - VK_FRONT_FACE_COUNTER_CLOCKWISE = 0, - VK_FRONT_FACE_CLOCKWISE = 1, - VK_FRONT_FACE_BEGIN_RANGE = VK_FRONT_FACE_COUNTER_CLOCKWISE, - VK_FRONT_FACE_END_RANGE = VK_FRONT_FACE_CLOCKWISE, - VK_FRONT_FACE_RANGE_SIZE = (VK_FRONT_FACE_CLOCKWISE - VK_FRONT_FACE_COUNTER_CLOCKWISE + 1), - VK_FRONT_FACE_MAX_ENUM = 0x7FFFFFFF -} VkFrontFace; - -typedef enum VkCompareOp { - VK_COMPARE_OP_NEVER = 0, - VK_COMPARE_OP_LESS = 1, - VK_COMPARE_OP_EQUAL = 2, - VK_COMPARE_OP_LESS_OR_EQUAL = 3, - VK_COMPARE_OP_GREATER = 4, - VK_COMPARE_OP_NOT_EQUAL = 5, - VK_COMPARE_OP_GREATER_OR_EQUAL = 6, - VK_COMPARE_OP_ALWAYS = 7, - VK_COMPARE_OP_BEGIN_RANGE = VK_COMPARE_OP_NEVER, - VK_COMPARE_OP_END_RANGE = VK_COMPARE_OP_ALWAYS, - VK_COMPARE_OP_RANGE_SIZE = (VK_COMPARE_OP_ALWAYS - VK_COMPARE_OP_NEVER + 1), - VK_COMPARE_OP_MAX_ENUM = 0x7FFFFFFF -} VkCompareOp; - -typedef enum VkStencilOp { - VK_STENCIL_OP_KEEP = 0, - VK_STENCIL_OP_ZERO = 1, - VK_STENCIL_OP_REPLACE = 2, - VK_STENCIL_OP_INCREMENT_AND_CLAMP = 3, - VK_STENCIL_OP_DECREMENT_AND_CLAMP = 4, - VK_STENCIL_OP_INVERT = 5, - VK_STENCIL_OP_INCREMENT_AND_WRAP = 6, - VK_STENCIL_OP_DECREMENT_AND_WRAP = 7, - VK_STENCIL_OP_BEGIN_RANGE = VK_STENCIL_OP_KEEP, - VK_STENCIL_OP_END_RANGE = VK_STENCIL_OP_DECREMENT_AND_WRAP, - VK_STENCIL_OP_RANGE_SIZE = (VK_STENCIL_OP_DECREMENT_AND_WRAP - VK_STENCIL_OP_KEEP + 1), - VK_STENCIL_OP_MAX_ENUM = 0x7FFFFFFF -} VkStencilOp; - -typedef enum VkLogicOp { - VK_LOGIC_OP_CLEAR = 0, - VK_LOGIC_OP_AND = 1, - VK_LOGIC_OP_AND_REVERSE = 2, - VK_LOGIC_OP_COPY = 3, - VK_LOGIC_OP_AND_INVERTED = 4, - VK_LOGIC_OP_NO_OP = 5, - VK_LOGIC_OP_XOR = 6, - VK_LOGIC_OP_OR = 7, - VK_LOGIC_OP_NOR = 8, - VK_LOGIC_OP_EQUIVALENT = 9, - VK_LOGIC_OP_INVERT = 10, - VK_LOGIC_OP_OR_REVERSE = 11, - VK_LOGIC_OP_COPY_INVERTED = 12, - VK_LOGIC_OP_OR_INVERTED = 13, - VK_LOGIC_OP_NAND = 14, - VK_LOGIC_OP_SET = 15, - VK_LOGIC_OP_BEGIN_RANGE = VK_LOGIC_OP_CLEAR, - VK_LOGIC_OP_END_RANGE = VK_LOGIC_OP_SET, - VK_LOGIC_OP_RANGE_SIZE = (VK_LOGIC_OP_SET - VK_LOGIC_OP_CLEAR + 1), - VK_LOGIC_OP_MAX_ENUM = 0x7FFFFFFF -} VkLogicOp; - -typedef enum VkBlendFactor { - VK_BLEND_FACTOR_ZERO = 0, - VK_BLEND_FACTOR_ONE = 1, - VK_BLEND_FACTOR_SRC_COLOR = 2, - VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR = 3, - VK_BLEND_FACTOR_DST_COLOR = 4, - VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR = 5, - VK_BLEND_FACTOR_SRC_ALPHA = 6, - VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA = 7, - VK_BLEND_FACTOR_DST_ALPHA = 8, - VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA = 9, - VK_BLEND_FACTOR_CONSTANT_COLOR = 10, - VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR = 11, - VK_BLEND_FACTOR_CONSTANT_ALPHA = 12, - VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA = 13, - VK_BLEND_FACTOR_SRC_ALPHA_SATURATE = 14, - VK_BLEND_FACTOR_SRC1_COLOR = 15, - VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR = 16, - VK_BLEND_FACTOR_SRC1_ALPHA = 17, - VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA = 18, - VK_BLEND_FACTOR_BEGIN_RANGE = VK_BLEND_FACTOR_ZERO, - VK_BLEND_FACTOR_END_RANGE = VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA, - VK_BLEND_FACTOR_RANGE_SIZE = (VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA - VK_BLEND_FACTOR_ZERO + 1), - VK_BLEND_FACTOR_MAX_ENUM = 0x7FFFFFFF -} VkBlendFactor; - -typedef enum VkBlendOp { - VK_BLEND_OP_ADD = 0, - VK_BLEND_OP_SUBTRACT = 1, - VK_BLEND_OP_REVERSE_SUBTRACT = 2, - VK_BLEND_OP_MIN = 3, - VK_BLEND_OP_MAX = 4, - VK_BLEND_OP_ZERO_EXT = 1000148000, - VK_BLEND_OP_SRC_EXT = 1000148001, - VK_BLEND_OP_DST_EXT = 1000148002, - VK_BLEND_OP_SRC_OVER_EXT = 1000148003, - VK_BLEND_OP_DST_OVER_EXT = 1000148004, - VK_BLEND_OP_SRC_IN_EXT = 1000148005, - VK_BLEND_OP_DST_IN_EXT = 1000148006, - VK_BLEND_OP_SRC_OUT_EXT = 1000148007, - VK_BLEND_OP_DST_OUT_EXT = 1000148008, - VK_BLEND_OP_SRC_ATOP_EXT = 1000148009, - VK_BLEND_OP_DST_ATOP_EXT = 1000148010, - VK_BLEND_OP_XOR_EXT = 1000148011, - VK_BLEND_OP_MULTIPLY_EXT = 1000148012, - VK_BLEND_OP_SCREEN_EXT = 1000148013, - VK_BLEND_OP_OVERLAY_EXT = 1000148014, - VK_BLEND_OP_DARKEN_EXT = 1000148015, - VK_BLEND_OP_LIGHTEN_EXT = 1000148016, - VK_BLEND_OP_COLORDODGE_EXT = 1000148017, - VK_BLEND_OP_COLORBURN_EXT = 1000148018, - VK_BLEND_OP_HARDLIGHT_EXT = 1000148019, - VK_BLEND_OP_SOFTLIGHT_EXT = 1000148020, - VK_BLEND_OP_DIFFERENCE_EXT = 1000148021, - VK_BLEND_OP_EXCLUSION_EXT = 1000148022, - VK_BLEND_OP_INVERT_EXT = 1000148023, - VK_BLEND_OP_INVERT_RGB_EXT = 1000148024, - VK_BLEND_OP_LINEARDODGE_EXT = 1000148025, - VK_BLEND_OP_LINEARBURN_EXT = 1000148026, - VK_BLEND_OP_VIVIDLIGHT_EXT = 1000148027, - VK_BLEND_OP_LINEARLIGHT_EXT = 1000148028, - VK_BLEND_OP_PINLIGHT_EXT = 1000148029, - VK_BLEND_OP_HARDMIX_EXT = 1000148030, - VK_BLEND_OP_HSL_HUE_EXT = 1000148031, - VK_BLEND_OP_HSL_SATURATION_EXT = 1000148032, - VK_BLEND_OP_HSL_COLOR_EXT = 1000148033, - VK_BLEND_OP_HSL_LUMINOSITY_EXT = 1000148034, - VK_BLEND_OP_PLUS_EXT = 1000148035, - VK_BLEND_OP_PLUS_CLAMPED_EXT = 1000148036, - VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT = 1000148037, - VK_BLEND_OP_PLUS_DARKER_EXT = 1000148038, - VK_BLEND_OP_MINUS_EXT = 1000148039, - VK_BLEND_OP_MINUS_CLAMPED_EXT = 1000148040, - VK_BLEND_OP_CONTRAST_EXT = 1000148041, - VK_BLEND_OP_INVERT_OVG_EXT = 1000148042, - VK_BLEND_OP_RED_EXT = 1000148043, - VK_BLEND_OP_GREEN_EXT = 1000148044, - VK_BLEND_OP_BLUE_EXT = 1000148045, - VK_BLEND_OP_BEGIN_RANGE = VK_BLEND_OP_ADD, - VK_BLEND_OP_END_RANGE = VK_BLEND_OP_MAX, - VK_BLEND_OP_RANGE_SIZE = (VK_BLEND_OP_MAX - VK_BLEND_OP_ADD + 1), - VK_BLEND_OP_MAX_ENUM = 0x7FFFFFFF -} VkBlendOp; - -typedef enum VkDynamicState { - VK_DYNAMIC_STATE_VIEWPORT = 0, - VK_DYNAMIC_STATE_SCISSOR = 1, - VK_DYNAMIC_STATE_LINE_WIDTH = 2, - VK_DYNAMIC_STATE_DEPTH_BIAS = 3, - VK_DYNAMIC_STATE_BLEND_CONSTANTS = 4, - VK_DYNAMIC_STATE_DEPTH_BOUNDS = 5, - VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK = 6, - VK_DYNAMIC_STATE_STENCIL_WRITE_MASK = 7, - VK_DYNAMIC_STATE_STENCIL_REFERENCE = 8, - VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV = 1000087000, - VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT = 1000099000, - VK_DYNAMIC_STATE_BEGIN_RANGE = VK_DYNAMIC_STATE_VIEWPORT, - VK_DYNAMIC_STATE_END_RANGE = VK_DYNAMIC_STATE_STENCIL_REFERENCE, - VK_DYNAMIC_STATE_RANGE_SIZE = (VK_DYNAMIC_STATE_STENCIL_REFERENCE - VK_DYNAMIC_STATE_VIEWPORT + 1), - VK_DYNAMIC_STATE_MAX_ENUM = 0x7FFFFFFF -} VkDynamicState; - -typedef enum VkFilter { - VK_FILTER_NEAREST = 0, - VK_FILTER_LINEAR = 1, - VK_FILTER_CUBIC_IMG = 1000015000, - VK_FILTER_BEGIN_RANGE = VK_FILTER_NEAREST, - VK_FILTER_END_RANGE = VK_FILTER_LINEAR, - VK_FILTER_RANGE_SIZE = (VK_FILTER_LINEAR - VK_FILTER_NEAREST + 1), - VK_FILTER_MAX_ENUM = 0x7FFFFFFF -} VkFilter; - -typedef enum VkSamplerMipmapMode { - VK_SAMPLER_MIPMAP_MODE_NEAREST = 0, - VK_SAMPLER_MIPMAP_MODE_LINEAR = 1, - VK_SAMPLER_MIPMAP_MODE_BEGIN_RANGE = VK_SAMPLER_MIPMAP_MODE_NEAREST, - VK_SAMPLER_MIPMAP_MODE_END_RANGE = VK_SAMPLER_MIPMAP_MODE_LINEAR, - VK_SAMPLER_MIPMAP_MODE_RANGE_SIZE = (VK_SAMPLER_MIPMAP_MODE_LINEAR - VK_SAMPLER_MIPMAP_MODE_NEAREST + 1), - VK_SAMPLER_MIPMAP_MODE_MAX_ENUM = 0x7FFFFFFF -} VkSamplerMipmapMode; - -typedef enum VkSamplerAddressMode { - VK_SAMPLER_ADDRESS_MODE_REPEAT = 0, - VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT = 1, - VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE = 2, - VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER = 3, - VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE = 4, - VK_SAMPLER_ADDRESS_MODE_BEGIN_RANGE = VK_SAMPLER_ADDRESS_MODE_REPEAT, - VK_SAMPLER_ADDRESS_MODE_END_RANGE = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, - VK_SAMPLER_ADDRESS_MODE_RANGE_SIZE = (VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER - VK_SAMPLER_ADDRESS_MODE_REPEAT + 1), - VK_SAMPLER_ADDRESS_MODE_MAX_ENUM = 0x7FFFFFFF -} VkSamplerAddressMode; - -typedef enum VkBorderColor { - VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK = 0, - VK_BORDER_COLOR_INT_TRANSPARENT_BLACK = 1, - VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK = 2, - VK_BORDER_COLOR_INT_OPAQUE_BLACK = 3, - VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE = 4, - VK_BORDER_COLOR_INT_OPAQUE_WHITE = 5, - VK_BORDER_COLOR_BEGIN_RANGE = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK, - VK_BORDER_COLOR_END_RANGE = VK_BORDER_COLOR_INT_OPAQUE_WHITE, - VK_BORDER_COLOR_RANGE_SIZE = (VK_BORDER_COLOR_INT_OPAQUE_WHITE - VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK + 1), - VK_BORDER_COLOR_MAX_ENUM = 0x7FFFFFFF -} VkBorderColor; - -typedef enum VkDescriptorType { - VK_DESCRIPTOR_TYPE_SAMPLER = 0, - VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER = 1, - VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE = 2, - VK_DESCRIPTOR_TYPE_STORAGE_IMAGE = 3, - VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER = 4, - VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER = 5, - VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER = 6, - VK_DESCRIPTOR_TYPE_STORAGE_BUFFER = 7, - VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC = 8, - VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC = 9, - VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT = 10, - VK_DESCRIPTOR_TYPE_BEGIN_RANGE = VK_DESCRIPTOR_TYPE_SAMPLER, - VK_DESCRIPTOR_TYPE_END_RANGE = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, - VK_DESCRIPTOR_TYPE_RANGE_SIZE = (VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT - VK_DESCRIPTOR_TYPE_SAMPLER + 1), - VK_DESCRIPTOR_TYPE_MAX_ENUM = 0x7FFFFFFF -} VkDescriptorType; - -typedef enum VkAttachmentLoadOp { - VK_ATTACHMENT_LOAD_OP_LOAD = 0, - VK_ATTACHMENT_LOAD_OP_CLEAR = 1, - VK_ATTACHMENT_LOAD_OP_DONT_CARE = 2, - VK_ATTACHMENT_LOAD_OP_BEGIN_RANGE = VK_ATTACHMENT_LOAD_OP_LOAD, - VK_ATTACHMENT_LOAD_OP_END_RANGE = VK_ATTACHMENT_LOAD_OP_DONT_CARE, - VK_ATTACHMENT_LOAD_OP_RANGE_SIZE = (VK_ATTACHMENT_LOAD_OP_DONT_CARE - VK_ATTACHMENT_LOAD_OP_LOAD + 1), - VK_ATTACHMENT_LOAD_OP_MAX_ENUM = 0x7FFFFFFF -} VkAttachmentLoadOp; - -typedef enum VkAttachmentStoreOp { - VK_ATTACHMENT_STORE_OP_STORE = 0, - VK_ATTACHMENT_STORE_OP_DONT_CARE = 1, - VK_ATTACHMENT_STORE_OP_BEGIN_RANGE = VK_ATTACHMENT_STORE_OP_STORE, - VK_ATTACHMENT_STORE_OP_END_RANGE = VK_ATTACHMENT_STORE_OP_DONT_CARE, - VK_ATTACHMENT_STORE_OP_RANGE_SIZE = (VK_ATTACHMENT_STORE_OP_DONT_CARE - VK_ATTACHMENT_STORE_OP_STORE + 1), - VK_ATTACHMENT_STORE_OP_MAX_ENUM = 0x7FFFFFFF -} VkAttachmentStoreOp; - -typedef enum VkPipelineBindPoint { - VK_PIPELINE_BIND_POINT_GRAPHICS = 0, - VK_PIPELINE_BIND_POINT_COMPUTE = 1, - VK_PIPELINE_BIND_POINT_BEGIN_RANGE = VK_PIPELINE_BIND_POINT_GRAPHICS, - VK_PIPELINE_BIND_POINT_END_RANGE = VK_PIPELINE_BIND_POINT_COMPUTE, - VK_PIPELINE_BIND_POINT_RANGE_SIZE = (VK_PIPELINE_BIND_POINT_COMPUTE - VK_PIPELINE_BIND_POINT_GRAPHICS + 1), - VK_PIPELINE_BIND_POINT_MAX_ENUM = 0x7FFFFFFF -} VkPipelineBindPoint; - -typedef enum VkCommandBufferLevel { - VK_COMMAND_BUFFER_LEVEL_PRIMARY = 0, - VK_COMMAND_BUFFER_LEVEL_SECONDARY = 1, - VK_COMMAND_BUFFER_LEVEL_BEGIN_RANGE = VK_COMMAND_BUFFER_LEVEL_PRIMARY, - VK_COMMAND_BUFFER_LEVEL_END_RANGE = VK_COMMAND_BUFFER_LEVEL_SECONDARY, - VK_COMMAND_BUFFER_LEVEL_RANGE_SIZE = (VK_COMMAND_BUFFER_LEVEL_SECONDARY - VK_COMMAND_BUFFER_LEVEL_PRIMARY + 1), - VK_COMMAND_BUFFER_LEVEL_MAX_ENUM = 0x7FFFFFFF -} VkCommandBufferLevel; - -typedef enum VkIndexType { - VK_INDEX_TYPE_UINT16 = 0, - VK_INDEX_TYPE_UINT32 = 1, - VK_INDEX_TYPE_BEGIN_RANGE = VK_INDEX_TYPE_UINT16, - VK_INDEX_TYPE_END_RANGE = VK_INDEX_TYPE_UINT32, - VK_INDEX_TYPE_RANGE_SIZE = (VK_INDEX_TYPE_UINT32 - VK_INDEX_TYPE_UINT16 + 1), - VK_INDEX_TYPE_MAX_ENUM = 0x7FFFFFFF -} VkIndexType; - -typedef enum VkSubpassContents { - VK_SUBPASS_CONTENTS_INLINE = 0, - VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS = 1, - VK_SUBPASS_CONTENTS_BEGIN_RANGE = VK_SUBPASS_CONTENTS_INLINE, - VK_SUBPASS_CONTENTS_END_RANGE = VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS, - VK_SUBPASS_CONTENTS_RANGE_SIZE = (VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS - VK_SUBPASS_CONTENTS_INLINE + 1), - VK_SUBPASS_CONTENTS_MAX_ENUM = 0x7FFFFFFF -} VkSubpassContents; - -typedef enum VkObjectType { - VK_OBJECT_TYPE_UNKNOWN = 0, - VK_OBJECT_TYPE_INSTANCE = 1, - VK_OBJECT_TYPE_PHYSICAL_DEVICE = 2, - VK_OBJECT_TYPE_DEVICE = 3, - VK_OBJECT_TYPE_QUEUE = 4, - VK_OBJECT_TYPE_SEMAPHORE = 5, - VK_OBJECT_TYPE_COMMAND_BUFFER = 6, - VK_OBJECT_TYPE_FENCE = 7, - VK_OBJECT_TYPE_DEVICE_MEMORY = 8, - VK_OBJECT_TYPE_BUFFER = 9, - VK_OBJECT_TYPE_IMAGE = 10, - VK_OBJECT_TYPE_EVENT = 11, - VK_OBJECT_TYPE_QUERY_POOL = 12, - VK_OBJECT_TYPE_BUFFER_VIEW = 13, - VK_OBJECT_TYPE_IMAGE_VIEW = 14, - VK_OBJECT_TYPE_SHADER_MODULE = 15, - VK_OBJECT_TYPE_PIPELINE_CACHE = 16, - VK_OBJECT_TYPE_PIPELINE_LAYOUT = 17, - VK_OBJECT_TYPE_RENDER_PASS = 18, - VK_OBJECT_TYPE_PIPELINE = 19, - VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT = 20, - VK_OBJECT_TYPE_SAMPLER = 21, - VK_OBJECT_TYPE_DESCRIPTOR_POOL = 22, - VK_OBJECT_TYPE_DESCRIPTOR_SET = 23, - VK_OBJECT_TYPE_FRAMEBUFFER = 24, - VK_OBJECT_TYPE_COMMAND_POOL = 25, - VK_OBJECT_TYPE_SURFACE_KHR = 1000000000, - VK_OBJECT_TYPE_SWAPCHAIN_KHR = 1000001000, - VK_OBJECT_TYPE_DISPLAY_KHR = 1000002000, - VK_OBJECT_TYPE_DISPLAY_MODE_KHR = 1000002001, - VK_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT = 1000011000, - VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_KHR = 1000085000, - VK_OBJECT_TYPE_OBJECT_TABLE_NVX = 1000086000, - VK_OBJECT_TYPE_INDIRECT_COMMANDS_LAYOUT_NVX = 1000086001, - VK_OBJECT_TYPE_BEGIN_RANGE = VK_OBJECT_TYPE_UNKNOWN, - VK_OBJECT_TYPE_END_RANGE = VK_OBJECT_TYPE_COMMAND_POOL, - VK_OBJECT_TYPE_RANGE_SIZE = (VK_OBJECT_TYPE_COMMAND_POOL - VK_OBJECT_TYPE_UNKNOWN + 1), - VK_OBJECT_TYPE_MAX_ENUM = 0x7FFFFFFF -} VkObjectType; - -typedef VkFlags VkInstanceCreateFlags; - -typedef enum VkFormatFeatureFlagBits { - VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT = 0x00000001, - VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT = 0x00000002, - VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT = 0x00000004, - VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT = 0x00000008, - VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT = 0x00000010, - VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT = 0x00000020, - VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT = 0x00000040, - VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT = 0x00000080, - VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT = 0x00000100, - VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT = 0x00000200, - VK_FORMAT_FEATURE_BLIT_SRC_BIT = 0x00000400, - VK_FORMAT_FEATURE_BLIT_DST_BIT = 0x00000800, - VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT = 0x00001000, - VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_IMG = 0x00002000, - VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR = 0x00004000, - VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR = 0x00008000, - VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT_EXT = 0x00010000, - VK_FORMAT_FEATURE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkFormatFeatureFlagBits; -typedef VkFlags VkFormatFeatureFlags; - -typedef enum VkImageUsageFlagBits { - VK_IMAGE_USAGE_TRANSFER_SRC_BIT = 0x00000001, - VK_IMAGE_USAGE_TRANSFER_DST_BIT = 0x00000002, - VK_IMAGE_USAGE_SAMPLED_BIT = 0x00000004, - VK_IMAGE_USAGE_STORAGE_BIT = 0x00000008, - VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT = 0x00000010, - VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT = 0x00000020, - VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT = 0x00000040, - VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT = 0x00000080, - VK_IMAGE_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkImageUsageFlagBits; -typedef VkFlags VkImageUsageFlags; - -typedef enum VkImageCreateFlagBits { - VK_IMAGE_CREATE_SPARSE_BINDING_BIT = 0x00000001, - VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT = 0x00000002, - VK_IMAGE_CREATE_SPARSE_ALIASED_BIT = 0x00000004, - VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT = 0x00000008, - VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT = 0x00000010, - VK_IMAGE_CREATE_BIND_SFR_BIT_KHX = 0x00000040, - VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT_KHR = 0x00000020, - VK_IMAGE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkImageCreateFlagBits; -typedef VkFlags VkImageCreateFlags; - -typedef enum VkSampleCountFlagBits { - VK_SAMPLE_COUNT_1_BIT = 0x00000001, - VK_SAMPLE_COUNT_2_BIT = 0x00000002, - VK_SAMPLE_COUNT_4_BIT = 0x00000004, - VK_SAMPLE_COUNT_8_BIT = 0x00000008, - VK_SAMPLE_COUNT_16_BIT = 0x00000010, - VK_SAMPLE_COUNT_32_BIT = 0x00000020, - VK_SAMPLE_COUNT_64_BIT = 0x00000040, - VK_SAMPLE_COUNT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkSampleCountFlagBits; -typedef VkFlags VkSampleCountFlags; - -typedef enum VkQueueFlagBits { - VK_QUEUE_GRAPHICS_BIT = 0x00000001, - VK_QUEUE_COMPUTE_BIT = 0x00000002, - VK_QUEUE_TRANSFER_BIT = 0x00000004, - VK_QUEUE_SPARSE_BINDING_BIT = 0x00000008, - VK_QUEUE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkQueueFlagBits; -typedef VkFlags VkQueueFlags; - -typedef enum VkMemoryPropertyFlagBits { - VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT = 0x00000001, - VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT = 0x00000002, - VK_MEMORY_PROPERTY_HOST_COHERENT_BIT = 0x00000004, - VK_MEMORY_PROPERTY_HOST_CACHED_BIT = 0x00000008, - VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT = 0x00000010, - VK_MEMORY_PROPERTY_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkMemoryPropertyFlagBits; -typedef VkFlags VkMemoryPropertyFlags; - -typedef enum VkMemoryHeapFlagBits { - VK_MEMORY_HEAP_DEVICE_LOCAL_BIT = 0x00000001, - VK_MEMORY_HEAP_MULTI_INSTANCE_BIT_KHX = 0x00000002, - VK_MEMORY_HEAP_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkMemoryHeapFlagBits; -typedef VkFlags VkMemoryHeapFlags; -typedef VkFlags VkDeviceCreateFlags; -typedef VkFlags VkDeviceQueueCreateFlags; - -typedef enum VkPipelineStageFlagBits { - VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT = 0x00000001, - VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT = 0x00000002, - VK_PIPELINE_STAGE_VERTEX_INPUT_BIT = 0x00000004, - VK_PIPELINE_STAGE_VERTEX_SHADER_BIT = 0x00000008, - VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT = 0x00000010, - VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT = 0x00000020, - VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT = 0x00000040, - VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT = 0x00000080, - VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT = 0x00000100, - VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT = 0x00000200, - VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT = 0x00000400, - VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT = 0x00000800, - VK_PIPELINE_STAGE_TRANSFER_BIT = 0x00001000, - VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT = 0x00002000, - VK_PIPELINE_STAGE_HOST_BIT = 0x00004000, - VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT = 0x00008000, - VK_PIPELINE_STAGE_ALL_COMMANDS_BIT = 0x00010000, - VK_PIPELINE_STAGE_COMMAND_PROCESS_BIT_NVX = 0x00020000, - VK_PIPELINE_STAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkPipelineStageFlagBits; -typedef VkFlags VkPipelineStageFlags; -typedef VkFlags VkMemoryMapFlags; - -typedef enum VkImageAspectFlagBits { - VK_IMAGE_ASPECT_COLOR_BIT = 0x00000001, - VK_IMAGE_ASPECT_DEPTH_BIT = 0x00000002, - VK_IMAGE_ASPECT_STENCIL_BIT = 0x00000004, - VK_IMAGE_ASPECT_METADATA_BIT = 0x00000008, - VK_IMAGE_ASPECT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkImageAspectFlagBits; -typedef VkFlags VkImageAspectFlags; - -typedef enum VkSparseImageFormatFlagBits { - VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT = 0x00000001, - VK_SPARSE_IMAGE_FORMAT_ALIGNED_MIP_SIZE_BIT = 0x00000002, - VK_SPARSE_IMAGE_FORMAT_NONSTANDARD_BLOCK_SIZE_BIT = 0x00000004, - VK_SPARSE_IMAGE_FORMAT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkSparseImageFormatFlagBits; -typedef VkFlags VkSparseImageFormatFlags; - -typedef enum VkSparseMemoryBindFlagBits { - VK_SPARSE_MEMORY_BIND_METADATA_BIT = 0x00000001, - VK_SPARSE_MEMORY_BIND_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkSparseMemoryBindFlagBits; -typedef VkFlags VkSparseMemoryBindFlags; - -typedef enum VkFenceCreateFlagBits { - VK_FENCE_CREATE_SIGNALED_BIT = 0x00000001, - VK_FENCE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkFenceCreateFlagBits; -typedef VkFlags VkFenceCreateFlags; -typedef VkFlags VkSemaphoreCreateFlags; -typedef VkFlags VkEventCreateFlags; -typedef VkFlags VkQueryPoolCreateFlags; - -typedef enum VkQueryPipelineStatisticFlagBits { - VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT = 0x00000001, - VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT = 0x00000002, - VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT = 0x00000004, - VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT = 0x00000008, - VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT = 0x00000010, - VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT = 0x00000020, - VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT = 0x00000040, - VK_QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT = 0x00000080, - VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT = 0x00000100, - VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT = 0x00000200, - VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT = 0x00000400, - VK_QUERY_PIPELINE_STATISTIC_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkQueryPipelineStatisticFlagBits; -typedef VkFlags VkQueryPipelineStatisticFlags; - -typedef enum VkQueryResultFlagBits { - VK_QUERY_RESULT_64_BIT = 0x00000001, - VK_QUERY_RESULT_WAIT_BIT = 0x00000002, - VK_QUERY_RESULT_WITH_AVAILABILITY_BIT = 0x00000004, - VK_QUERY_RESULT_PARTIAL_BIT = 0x00000008, - VK_QUERY_RESULT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkQueryResultFlagBits; -typedef VkFlags VkQueryResultFlags; - -typedef enum VkBufferCreateFlagBits { - VK_BUFFER_CREATE_SPARSE_BINDING_BIT = 0x00000001, - VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT = 0x00000002, - VK_BUFFER_CREATE_SPARSE_ALIASED_BIT = 0x00000004, - VK_BUFFER_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkBufferCreateFlagBits; -typedef VkFlags VkBufferCreateFlags; - -typedef enum VkBufferUsageFlagBits { - VK_BUFFER_USAGE_TRANSFER_SRC_BIT = 0x00000001, - VK_BUFFER_USAGE_TRANSFER_DST_BIT = 0x00000002, - VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT = 0x00000004, - VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT = 0x00000008, - VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT = 0x00000010, - VK_BUFFER_USAGE_STORAGE_BUFFER_BIT = 0x00000020, - VK_BUFFER_USAGE_INDEX_BUFFER_BIT = 0x00000040, - VK_BUFFER_USAGE_VERTEX_BUFFER_BIT = 0x00000080, - VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT = 0x00000100, - VK_BUFFER_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkBufferUsageFlagBits; -typedef VkFlags VkBufferUsageFlags; -typedef VkFlags VkBufferViewCreateFlags; -typedef VkFlags VkImageViewCreateFlags; -typedef VkFlags VkShaderModuleCreateFlags; -typedef VkFlags VkPipelineCacheCreateFlags; - -typedef enum VkPipelineCreateFlagBits { - VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT = 0x00000001, - VK_PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT = 0x00000002, - VK_PIPELINE_CREATE_DERIVATIVE_BIT = 0x00000004, - VK_PIPELINE_CREATE_VIEW_INDEX_FROM_DEVICE_INDEX_BIT_KHX = 0x00000008, - VK_PIPELINE_CREATE_DISPATCH_BASE_KHX = 0x00000010, - VK_PIPELINE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkPipelineCreateFlagBits; -typedef VkFlags VkPipelineCreateFlags; -typedef VkFlags VkPipelineShaderStageCreateFlags; - -typedef enum VkShaderStageFlagBits { - VK_SHADER_STAGE_VERTEX_BIT = 0x00000001, - VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT = 0x00000002, - VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT = 0x00000004, - VK_SHADER_STAGE_GEOMETRY_BIT = 0x00000008, - VK_SHADER_STAGE_FRAGMENT_BIT = 0x00000010, - VK_SHADER_STAGE_COMPUTE_BIT = 0x00000020, - VK_SHADER_STAGE_ALL_GRAPHICS = 0x0000001F, - VK_SHADER_STAGE_ALL = 0x7FFFFFFF, - VK_SHADER_STAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkShaderStageFlagBits; -typedef VkFlags VkPipelineVertexInputStateCreateFlags; -typedef VkFlags VkPipelineInputAssemblyStateCreateFlags; -typedef VkFlags VkPipelineTessellationStateCreateFlags; -typedef VkFlags VkPipelineViewportStateCreateFlags; -typedef VkFlags VkPipelineRasterizationStateCreateFlags; - -typedef enum VkCullModeFlagBits { - VK_CULL_MODE_NONE = 0, - VK_CULL_MODE_FRONT_BIT = 0x00000001, - VK_CULL_MODE_BACK_BIT = 0x00000002, - VK_CULL_MODE_FRONT_AND_BACK = 0x00000003, - VK_CULL_MODE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkCullModeFlagBits; -typedef VkFlags VkCullModeFlags; -typedef VkFlags VkPipelineMultisampleStateCreateFlags; -typedef VkFlags VkPipelineDepthStencilStateCreateFlags; -typedef VkFlags VkPipelineColorBlendStateCreateFlags; - -typedef enum VkColorComponentFlagBits { - VK_COLOR_COMPONENT_R_BIT = 0x00000001, - VK_COLOR_COMPONENT_G_BIT = 0x00000002, - VK_COLOR_COMPONENT_B_BIT = 0x00000004, - VK_COLOR_COMPONENT_A_BIT = 0x00000008, - VK_COLOR_COMPONENT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkColorComponentFlagBits; -typedef VkFlags VkColorComponentFlags; -typedef VkFlags VkPipelineDynamicStateCreateFlags; -typedef VkFlags VkPipelineLayoutCreateFlags; -typedef VkFlags VkShaderStageFlags; -typedef VkFlags VkSamplerCreateFlags; - -typedef enum VkDescriptorSetLayoutCreateFlagBits { - VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR = 0x00000001, - VK_DESCRIPTOR_SET_LAYOUT_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkDescriptorSetLayoutCreateFlagBits; -typedef VkFlags VkDescriptorSetLayoutCreateFlags; - -typedef enum VkDescriptorPoolCreateFlagBits { - VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT = 0x00000001, - VK_DESCRIPTOR_POOL_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkDescriptorPoolCreateFlagBits; -typedef VkFlags VkDescriptorPoolCreateFlags; -typedef VkFlags VkDescriptorPoolResetFlags; -typedef VkFlags VkFramebufferCreateFlags; -typedef VkFlags VkRenderPassCreateFlags; - -typedef enum VkAttachmentDescriptionFlagBits { - VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT = 0x00000001, - VK_ATTACHMENT_DESCRIPTION_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkAttachmentDescriptionFlagBits; -typedef VkFlags VkAttachmentDescriptionFlags; - -typedef enum VkSubpassDescriptionFlagBits { - VK_SUBPASS_DESCRIPTION_PER_VIEW_ATTRIBUTES_BIT_NVX = 0x00000001, - VK_SUBPASS_DESCRIPTION_PER_VIEW_POSITION_X_ONLY_BIT_NVX = 0x00000002, - VK_SUBPASS_DESCRIPTION_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkSubpassDescriptionFlagBits; -typedef VkFlags VkSubpassDescriptionFlags; - -typedef enum VkAccessFlagBits { - VK_ACCESS_INDIRECT_COMMAND_READ_BIT = 0x00000001, - VK_ACCESS_INDEX_READ_BIT = 0x00000002, - VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT = 0x00000004, - VK_ACCESS_UNIFORM_READ_BIT = 0x00000008, - VK_ACCESS_INPUT_ATTACHMENT_READ_BIT = 0x00000010, - VK_ACCESS_SHADER_READ_BIT = 0x00000020, - VK_ACCESS_SHADER_WRITE_BIT = 0x00000040, - VK_ACCESS_COLOR_ATTACHMENT_READ_BIT = 0x00000080, - VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT = 0x00000100, - VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT = 0x00000200, - VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT = 0x00000400, - VK_ACCESS_TRANSFER_READ_BIT = 0x00000800, - VK_ACCESS_TRANSFER_WRITE_BIT = 0x00001000, - VK_ACCESS_HOST_READ_BIT = 0x00002000, - VK_ACCESS_HOST_WRITE_BIT = 0x00004000, - VK_ACCESS_MEMORY_READ_BIT = 0x00008000, - VK_ACCESS_MEMORY_WRITE_BIT = 0x00010000, - VK_ACCESS_COMMAND_PROCESS_READ_BIT_NVX = 0x00020000, - VK_ACCESS_COMMAND_PROCESS_WRITE_BIT_NVX = 0x00040000, - VK_ACCESS_COLOR_ATTACHMENT_READ_NONCOHERENT_BIT_EXT = 0x00080000, - VK_ACCESS_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkAccessFlagBits; -typedef VkFlags VkAccessFlags; - -typedef enum VkDependencyFlagBits { - VK_DEPENDENCY_BY_REGION_BIT = 0x00000001, - VK_DEPENDENCY_VIEW_LOCAL_BIT_KHX = 0x00000002, - VK_DEPENDENCY_DEVICE_GROUP_BIT_KHX = 0x00000004, - VK_DEPENDENCY_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkDependencyFlagBits; -typedef VkFlags VkDependencyFlags; - -typedef enum VkCommandPoolCreateFlagBits { - VK_COMMAND_POOL_CREATE_TRANSIENT_BIT = 0x00000001, - VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT = 0x00000002, - VK_COMMAND_POOL_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkCommandPoolCreateFlagBits; -typedef VkFlags VkCommandPoolCreateFlags; - -typedef enum VkCommandPoolResetFlagBits { - VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT = 0x00000001, - VK_COMMAND_POOL_RESET_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkCommandPoolResetFlagBits; -typedef VkFlags VkCommandPoolResetFlags; - -typedef enum VkCommandBufferUsageFlagBits { - VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT = 0x00000001, - VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT = 0x00000002, - VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT = 0x00000004, - VK_COMMAND_BUFFER_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkCommandBufferUsageFlagBits; -typedef VkFlags VkCommandBufferUsageFlags; - -typedef enum VkQueryControlFlagBits { - VK_QUERY_CONTROL_PRECISE_BIT = 0x00000001, - VK_QUERY_CONTROL_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkQueryControlFlagBits; -typedef VkFlags VkQueryControlFlags; - -typedef enum VkCommandBufferResetFlagBits { - VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT = 0x00000001, - VK_COMMAND_BUFFER_RESET_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkCommandBufferResetFlagBits; -typedef VkFlags VkCommandBufferResetFlags; - -typedef enum VkStencilFaceFlagBits { - VK_STENCIL_FACE_FRONT_BIT = 0x00000001, - VK_STENCIL_FACE_BACK_BIT = 0x00000002, - VK_STENCIL_FRONT_AND_BACK = 0x00000003, - VK_STENCIL_FACE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF -} VkStencilFaceFlagBits; -typedef VkFlags VkStencilFaceFlags; - -typedef void* (VKAPI_PTR *PFN_vkAllocationFunction)( - void* pUserData, - size_t size, - size_t alignment, - VkSystemAllocationScope allocationScope); - -typedef void* (VKAPI_PTR *PFN_vkReallocationFunction)( - void* pUserData, - void* pOriginal, - size_t size, - size_t alignment, - VkSystemAllocationScope allocationScope); - -typedef void (VKAPI_PTR *PFN_vkFreeFunction)( - void* pUserData, - void* pMemory); - -typedef void (VKAPI_PTR *PFN_vkInternalAllocationNotification)( - void* pUserData, - size_t size, - VkInternalAllocationType allocationType, - VkSystemAllocationScope allocationScope); - -typedef void (VKAPI_PTR *PFN_vkInternalFreeNotification)( - void* pUserData, - size_t size, - VkInternalAllocationType allocationType, - VkSystemAllocationScope allocationScope); - -typedef void (VKAPI_PTR *PFN_vkVoidFunction)(void); - -typedef struct VkApplicationInfo { - VkStructureType sType; - const void* pNext; - const char* pApplicationName; - uint32_t applicationVersion; - const char* pEngineName; - uint32_t engineVersion; - uint32_t apiVersion; -} VkApplicationInfo; - -typedef struct VkInstanceCreateInfo { - VkStructureType sType; - const void* pNext; - VkInstanceCreateFlags flags; - const VkApplicationInfo* pApplicationInfo; - uint32_t enabledLayerCount; - const char* const* ppEnabledLayerNames; - uint32_t enabledExtensionCount; - const char* const* ppEnabledExtensionNames; -} VkInstanceCreateInfo; - -typedef struct VkAllocationCallbacks { - void* pUserData; - PFN_vkAllocationFunction pfnAllocation; - PFN_vkReallocationFunction pfnReallocation; - PFN_vkFreeFunction pfnFree; - PFN_vkInternalAllocationNotification pfnInternalAllocation; - PFN_vkInternalFreeNotification pfnInternalFree; -} VkAllocationCallbacks; - -typedef struct VkPhysicalDeviceFeatures { - VkBool32 robustBufferAccess; - VkBool32 fullDrawIndexUint32; - VkBool32 imageCubeArray; - VkBool32 independentBlend; - VkBool32 geometryShader; - VkBool32 tessellationShader; - VkBool32 sampleRateShading; - VkBool32 dualSrcBlend; - VkBool32 logicOp; - VkBool32 multiDrawIndirect; - VkBool32 drawIndirectFirstInstance; - VkBool32 depthClamp; - VkBool32 depthBiasClamp; - VkBool32 fillModeNonSolid; - VkBool32 depthBounds; - VkBool32 wideLines; - VkBool32 largePoints; - VkBool32 alphaToOne; - VkBool32 multiViewport; - VkBool32 samplerAnisotropy; - VkBool32 textureCompressionETC2; - VkBool32 textureCompressionASTC_LDR; - VkBool32 textureCompressionBC; - VkBool32 occlusionQueryPrecise; - VkBool32 pipelineStatisticsQuery; - VkBool32 vertexPipelineStoresAndAtomics; - VkBool32 fragmentStoresAndAtomics; - VkBool32 shaderTessellationAndGeometryPointSize; - VkBool32 shaderImageGatherExtended; - VkBool32 shaderStorageImageExtendedFormats; - VkBool32 shaderStorageImageMultisample; - VkBool32 shaderStorageImageReadWithoutFormat; - VkBool32 shaderStorageImageWriteWithoutFormat; - VkBool32 shaderUniformBufferArrayDynamicIndexing; - VkBool32 shaderSampledImageArrayDynamicIndexing; - VkBool32 shaderStorageBufferArrayDynamicIndexing; - VkBool32 shaderStorageImageArrayDynamicIndexing; - VkBool32 shaderClipDistance; - VkBool32 shaderCullDistance; - VkBool32 shaderFloat64; - VkBool32 shaderInt64; - VkBool32 shaderInt16; - VkBool32 shaderResourceResidency; - VkBool32 shaderResourceMinLod; - VkBool32 sparseBinding; - VkBool32 sparseResidencyBuffer; - VkBool32 sparseResidencyImage2D; - VkBool32 sparseResidencyImage3D; - VkBool32 sparseResidency2Samples; - VkBool32 sparseResidency4Samples; - VkBool32 sparseResidency8Samples; - VkBool32 sparseResidency16Samples; - VkBool32 sparseResidencyAliased; - VkBool32 variableMultisampleRate; - VkBool32 inheritedQueries; -} VkPhysicalDeviceFeatures; - -typedef struct VkFormatProperties { - VkFormatFeatureFlags linearTilingFeatures; - VkFormatFeatureFlags optimalTilingFeatures; - VkFormatFeatureFlags bufferFeatures; -} VkFormatProperties; - -typedef struct VkExtent3D { - uint32_t width; - uint32_t height; - uint32_t depth; -} VkExtent3D; - -typedef struct VkImageFormatProperties { - VkExtent3D maxExtent; - uint32_t maxMipLevels; - uint32_t maxArrayLayers; - VkSampleCountFlags sampleCounts; - VkDeviceSize maxResourceSize; -} VkImageFormatProperties; - -typedef struct VkPhysicalDeviceLimits { - uint32_t maxImageDimension1D; - uint32_t maxImageDimension2D; - uint32_t maxImageDimension3D; - uint32_t maxImageDimensionCube; - uint32_t maxImageArrayLayers; - uint32_t maxTexelBufferElements; - uint32_t maxUniformBufferRange; - uint32_t maxStorageBufferRange; - uint32_t maxPushConstantsSize; - uint32_t maxMemoryAllocationCount; - uint32_t maxSamplerAllocationCount; - VkDeviceSize bufferImageGranularity; - VkDeviceSize sparseAddressSpaceSize; - uint32_t maxBoundDescriptorSets; - uint32_t maxPerStageDescriptorSamplers; - uint32_t maxPerStageDescriptorUniformBuffers; - uint32_t maxPerStageDescriptorStorageBuffers; - uint32_t maxPerStageDescriptorSampledImages; - uint32_t maxPerStageDescriptorStorageImages; - uint32_t maxPerStageDescriptorInputAttachments; - uint32_t maxPerStageResources; - uint32_t maxDescriptorSetSamplers; - uint32_t maxDescriptorSetUniformBuffers; - uint32_t maxDescriptorSetUniformBuffersDynamic; - uint32_t maxDescriptorSetStorageBuffers; - uint32_t maxDescriptorSetStorageBuffersDynamic; - uint32_t maxDescriptorSetSampledImages; - uint32_t maxDescriptorSetStorageImages; - uint32_t maxDescriptorSetInputAttachments; - uint32_t maxVertexInputAttributes; - uint32_t maxVertexInputBindings; - uint32_t maxVertexInputAttributeOffset; - uint32_t maxVertexInputBindingStride; - uint32_t maxVertexOutputComponents; - uint32_t maxTessellationGenerationLevel; - uint32_t maxTessellationPatchSize; - uint32_t maxTessellationControlPerVertexInputComponents; - uint32_t maxTessellationControlPerVertexOutputComponents; - uint32_t maxTessellationControlPerPatchOutputComponents; - uint32_t maxTessellationControlTotalOutputComponents; - uint32_t maxTessellationEvaluationInputComponents; - uint32_t maxTessellationEvaluationOutputComponents; - uint32_t maxGeometryShaderInvocations; - uint32_t maxGeometryInputComponents; - uint32_t maxGeometryOutputComponents; - uint32_t maxGeometryOutputVertices; - uint32_t maxGeometryTotalOutputComponents; - uint32_t maxFragmentInputComponents; - uint32_t maxFragmentOutputAttachments; - uint32_t maxFragmentDualSrcAttachments; - uint32_t maxFragmentCombinedOutputResources; - uint32_t maxComputeSharedMemorySize; - uint32_t maxComputeWorkGroupCount[3]; - uint32_t maxComputeWorkGroupInvocations; - uint32_t maxComputeWorkGroupSize[3]; - uint32_t subPixelPrecisionBits; - uint32_t subTexelPrecisionBits; - uint32_t mipmapPrecisionBits; - uint32_t maxDrawIndexedIndexValue; - uint32_t maxDrawIndirectCount; - float maxSamplerLodBias; - float maxSamplerAnisotropy; - uint32_t maxViewports; - uint32_t maxViewportDimensions[2]; - float viewportBoundsRange[2]; - uint32_t viewportSubPixelBits; - size_t minMemoryMapAlignment; - VkDeviceSize minTexelBufferOffsetAlignment; - VkDeviceSize minUniformBufferOffsetAlignment; - VkDeviceSize minStorageBufferOffsetAlignment; - int32_t minTexelOffset; - uint32_t maxTexelOffset; - int32_t minTexelGatherOffset; - uint32_t maxTexelGatherOffset; - float minInterpolationOffset; - float maxInterpolationOffset; - uint32_t subPixelInterpolationOffsetBits; - uint32_t maxFramebufferWidth; - uint32_t maxFramebufferHeight; - uint32_t maxFramebufferLayers; - VkSampleCountFlags framebufferColorSampleCounts; - VkSampleCountFlags framebufferDepthSampleCounts; - VkSampleCountFlags framebufferStencilSampleCounts; - VkSampleCountFlags framebufferNoAttachmentsSampleCounts; - uint32_t maxColorAttachments; - VkSampleCountFlags sampledImageColorSampleCounts; - VkSampleCountFlags sampledImageIntegerSampleCounts; - VkSampleCountFlags sampledImageDepthSampleCounts; - VkSampleCountFlags sampledImageStencilSampleCounts; - VkSampleCountFlags storageImageSampleCounts; - uint32_t maxSampleMaskWords; - VkBool32 timestampComputeAndGraphics; - float timestampPeriod; - uint32_t maxClipDistances; - uint32_t maxCullDistances; - uint32_t maxCombinedClipAndCullDistances; - uint32_t discreteQueuePriorities; - float pointSizeRange[2]; - float lineWidthRange[2]; - float pointSizeGranularity; - float lineWidthGranularity; - VkBool32 strictLines; - VkBool32 standardSampleLocations; - VkDeviceSize optimalBufferCopyOffsetAlignment; - VkDeviceSize optimalBufferCopyRowPitchAlignment; - VkDeviceSize nonCoherentAtomSize; -} VkPhysicalDeviceLimits; - -typedef struct VkPhysicalDeviceSparseProperties { - VkBool32 residencyStandard2DBlockShape; - VkBool32 residencyStandard2DMultisampleBlockShape; - VkBool32 residencyStandard3DBlockShape; - VkBool32 residencyAlignedMipSize; - VkBool32 residencyNonResidentStrict; -} VkPhysicalDeviceSparseProperties; - -typedef struct VkPhysicalDeviceProperties { - uint32_t apiVersion; - uint32_t driverVersion; - uint32_t vendorID; - uint32_t deviceID; - VkPhysicalDeviceType deviceType; - char deviceName[VK_MAX_PHYSICAL_DEVICE_NAME_SIZE]; - uint8_t pipelineCacheUUID[VK_UUID_SIZE]; - VkPhysicalDeviceLimits limits; - VkPhysicalDeviceSparseProperties sparseProperties; -} VkPhysicalDeviceProperties; - -typedef struct VkQueueFamilyProperties { - VkQueueFlags queueFlags; - uint32_t queueCount; - uint32_t timestampValidBits; - VkExtent3D minImageTransferGranularity; -} VkQueueFamilyProperties; - -typedef struct VkMemoryType { - VkMemoryPropertyFlags propertyFlags; - uint32_t heapIndex; -} VkMemoryType; - -typedef struct VkMemoryHeap { - VkDeviceSize size; - VkMemoryHeapFlags flags; -} VkMemoryHeap; - -typedef struct VkPhysicalDeviceMemoryProperties { - uint32_t memoryTypeCount; - VkMemoryType memoryTypes[VK_MAX_MEMORY_TYPES]; - uint32_t memoryHeapCount; - VkMemoryHeap memoryHeaps[VK_MAX_MEMORY_HEAPS]; -} VkPhysicalDeviceMemoryProperties; - -typedef struct VkDeviceQueueCreateInfo { - VkStructureType sType; - const void* pNext; - VkDeviceQueueCreateFlags flags; - uint32_t queueFamilyIndex; - uint32_t queueCount; - const float* pQueuePriorities; -} VkDeviceQueueCreateInfo; - -typedef struct VkDeviceCreateInfo { - VkStructureType sType; - const void* pNext; - VkDeviceCreateFlags flags; - uint32_t queueCreateInfoCount; - const VkDeviceQueueCreateInfo* pQueueCreateInfos; - uint32_t enabledLayerCount; - const char* const* ppEnabledLayerNames; - uint32_t enabledExtensionCount; - const char* const* ppEnabledExtensionNames; - const VkPhysicalDeviceFeatures* pEnabledFeatures; -} VkDeviceCreateInfo; - -typedef struct VkExtensionProperties { - char extensionName[VK_MAX_EXTENSION_NAME_SIZE]; - uint32_t specVersion; -} VkExtensionProperties; - -typedef struct VkLayerProperties { - char layerName[VK_MAX_EXTENSION_NAME_SIZE]; - uint32_t specVersion; - uint32_t implementationVersion; - char description[VK_MAX_DESCRIPTION_SIZE]; -} VkLayerProperties; - -typedef struct VkSubmitInfo { - VkStructureType sType; - const void* pNext; - uint32_t waitSemaphoreCount; - const VkSemaphore* pWaitSemaphores; - const VkPipelineStageFlags* pWaitDstStageMask; - uint32_t commandBufferCount; - const VkCommandBuffer* pCommandBuffers; - uint32_t signalSemaphoreCount; - const VkSemaphore* pSignalSemaphores; -} VkSubmitInfo; - -typedef struct VkMemoryAllocateInfo { - VkStructureType sType; - const void* pNext; - VkDeviceSize allocationSize; - uint32_t memoryTypeIndex; -} VkMemoryAllocateInfo; - -typedef struct VkMappedMemoryRange { - VkStructureType sType; - const void* pNext; - VkDeviceMemory memory; - VkDeviceSize offset; - VkDeviceSize size; -} VkMappedMemoryRange; - -typedef struct VkMemoryRequirements { - VkDeviceSize size; - VkDeviceSize alignment; - uint32_t memoryTypeBits; -} VkMemoryRequirements; - -typedef struct VkSparseImageFormatProperties { - VkImageAspectFlags aspectMask; - VkExtent3D imageGranularity; - VkSparseImageFormatFlags flags; -} VkSparseImageFormatProperties; - -typedef struct VkSparseImageMemoryRequirements { - VkSparseImageFormatProperties formatProperties; - uint32_t imageMipTailFirstLod; - VkDeviceSize imageMipTailSize; - VkDeviceSize imageMipTailOffset; - VkDeviceSize imageMipTailStride; -} VkSparseImageMemoryRequirements; - -typedef struct VkSparseMemoryBind { - VkDeviceSize resourceOffset; - VkDeviceSize size; - VkDeviceMemory memory; - VkDeviceSize memoryOffset; - VkSparseMemoryBindFlags flags; -} VkSparseMemoryBind; - -typedef struct VkSparseBufferMemoryBindInfo { - VkBuffer buffer; - uint32_t bindCount; - const VkSparseMemoryBind* pBinds; -} VkSparseBufferMemoryBindInfo; - -typedef struct VkSparseImageOpaqueMemoryBindInfo { - VkImage image; - uint32_t bindCount; - const VkSparseMemoryBind* pBinds; -} VkSparseImageOpaqueMemoryBindInfo; - -typedef struct VkImageSubresource { - VkImageAspectFlags aspectMask; - uint32_t mipLevel; - uint32_t arrayLayer; -} VkImageSubresource; - -typedef struct VkOffset3D { - int32_t x; - int32_t y; - int32_t z; -} VkOffset3D; - -typedef struct VkSparseImageMemoryBind { - VkImageSubresource subresource; - VkOffset3D offset; - VkExtent3D extent; - VkDeviceMemory memory; - VkDeviceSize memoryOffset; - VkSparseMemoryBindFlags flags; -} VkSparseImageMemoryBind; - -typedef struct VkSparseImageMemoryBindInfo { - VkImage image; - uint32_t bindCount; - const VkSparseImageMemoryBind* pBinds; -} VkSparseImageMemoryBindInfo; - -typedef struct VkBindSparseInfo { - VkStructureType sType; - const void* pNext; - uint32_t waitSemaphoreCount; - const VkSemaphore* pWaitSemaphores; - uint32_t bufferBindCount; - const VkSparseBufferMemoryBindInfo* pBufferBinds; - uint32_t imageOpaqueBindCount; - const VkSparseImageOpaqueMemoryBindInfo* pImageOpaqueBinds; - uint32_t imageBindCount; - const VkSparseImageMemoryBindInfo* pImageBinds; - uint32_t signalSemaphoreCount; - const VkSemaphore* pSignalSemaphores; -} VkBindSparseInfo; - -typedef struct VkFenceCreateInfo { - VkStructureType sType; - const void* pNext; - VkFenceCreateFlags flags; -} VkFenceCreateInfo; - -typedef struct VkSemaphoreCreateInfo { - VkStructureType sType; - const void* pNext; - VkSemaphoreCreateFlags flags; -} VkSemaphoreCreateInfo; - -typedef struct VkEventCreateInfo { - VkStructureType sType; - const void* pNext; - VkEventCreateFlags flags; -} VkEventCreateInfo; - -typedef struct VkQueryPoolCreateInfo { - VkStructureType sType; - const void* pNext; - VkQueryPoolCreateFlags flags; - VkQueryType queryType; - uint32_t queryCount; - VkQueryPipelineStatisticFlags pipelineStatistics; -} VkQueryPoolCreateInfo; - -typedef struct VkBufferCreateInfo { - VkStructureType sType; - const void* pNext; - VkBufferCreateFlags flags; - VkDeviceSize size; - VkBufferUsageFlags usage; - VkSharingMode sharingMode; - uint32_t queueFamilyIndexCount; - const uint32_t* pQueueFamilyIndices; -} VkBufferCreateInfo; - -typedef struct VkBufferViewCreateInfo { - VkStructureType sType; - const void* pNext; - VkBufferViewCreateFlags flags; - VkBuffer buffer; - VkFormat format; - VkDeviceSize offset; - VkDeviceSize range; -} VkBufferViewCreateInfo; - -typedef struct VkImageCreateInfo { - VkStructureType sType; - const void* pNext; - VkImageCreateFlags flags; - VkImageType imageType; - VkFormat format; - VkExtent3D extent; - uint32_t mipLevels; - uint32_t arrayLayers; - VkSampleCountFlagBits samples; - VkImageTiling tiling; - VkImageUsageFlags usage; - VkSharingMode sharingMode; - uint32_t queueFamilyIndexCount; - const uint32_t* pQueueFamilyIndices; - VkImageLayout initialLayout; -} VkImageCreateInfo; - -typedef struct VkSubresourceLayout { - VkDeviceSize offset; - VkDeviceSize size; - VkDeviceSize rowPitch; - VkDeviceSize arrayPitch; - VkDeviceSize depthPitch; -} VkSubresourceLayout; - -typedef struct VkComponentMapping { - VkComponentSwizzle r; - VkComponentSwizzle g; - VkComponentSwizzle b; - VkComponentSwizzle a; -} VkComponentMapping; - -typedef struct VkImageSubresourceRange { - VkImageAspectFlags aspectMask; - uint32_t baseMipLevel; - uint32_t levelCount; - uint32_t baseArrayLayer; - uint32_t layerCount; -} VkImageSubresourceRange; - -typedef struct VkImageViewCreateInfo { - VkStructureType sType; - const void* pNext; - VkImageViewCreateFlags flags; - VkImage image; - VkImageViewType viewType; - VkFormat format; - VkComponentMapping components; - VkImageSubresourceRange subresourceRange; -} VkImageViewCreateInfo; - -typedef struct VkShaderModuleCreateInfo { - VkStructureType sType; - const void* pNext; - VkShaderModuleCreateFlags flags; - size_t codeSize; - const uint32_t* pCode; -} VkShaderModuleCreateInfo; - -typedef struct VkPipelineCacheCreateInfo { - VkStructureType sType; - const void* pNext; - VkPipelineCacheCreateFlags flags; - size_t initialDataSize; - const void* pInitialData; -} VkPipelineCacheCreateInfo; - -typedef struct VkSpecializationMapEntry { - uint32_t constantID; - uint32_t offset; - size_t size; -} VkSpecializationMapEntry; - -typedef struct VkSpecializationInfo { - uint32_t mapEntryCount; - const VkSpecializationMapEntry* pMapEntries; - size_t dataSize; - const void* pData; -} VkSpecializationInfo; - -typedef struct VkPipelineShaderStageCreateInfo { - VkStructureType sType; - const void* pNext; - VkPipelineShaderStageCreateFlags flags; - VkShaderStageFlagBits stage; - VkShaderModule module; - const char* pName; - const VkSpecializationInfo* pSpecializationInfo; -} VkPipelineShaderStageCreateInfo; - -typedef struct VkVertexInputBindingDescription { - uint32_t binding; - uint32_t stride; - VkVertexInputRate inputRate; -} VkVertexInputBindingDescription; - -typedef struct VkVertexInputAttributeDescription { - uint32_t location; - uint32_t binding; - VkFormat format; - uint32_t offset; -} VkVertexInputAttributeDescription; - -typedef struct VkPipelineVertexInputStateCreateInfo { - VkStructureType sType; - const void* pNext; - VkPipelineVertexInputStateCreateFlags flags; - uint32_t vertexBindingDescriptionCount; - const VkVertexInputBindingDescription* pVertexBindingDescriptions; - uint32_t vertexAttributeDescriptionCount; - const VkVertexInputAttributeDescription* pVertexAttributeDescriptions; -} VkPipelineVertexInputStateCreateInfo; - -typedef struct VkPipelineInputAssemblyStateCreateInfo { - VkStructureType sType; - const void* pNext; - VkPipelineInputAssemblyStateCreateFlags flags; - VkPrimitiveTopology topology; - VkBool32 primitiveRestartEnable; -} VkPipelineInputAssemblyStateCreateInfo; - -typedef struct VkPipelineTessellationStateCreateInfo { - VkStructureType sType; - const void* pNext; - VkPipelineTessellationStateCreateFlags flags; - uint32_t patchControlPoints; -} VkPipelineTessellationStateCreateInfo; - -typedef struct VkViewport { - float x; - float y; - float width; - float height; - float minDepth; - float maxDepth; -} VkViewport; - -typedef struct VkOffset2D { - int32_t x; - int32_t y; -} VkOffset2D; - -typedef struct VkExtent2D { - uint32_t width; - uint32_t height; -} VkExtent2D; - -typedef struct VkRect2D { - VkOffset2D offset; - VkExtent2D extent; -} VkRect2D; - -typedef struct VkPipelineViewportStateCreateInfo { - VkStructureType sType; - const void* pNext; - VkPipelineViewportStateCreateFlags flags; - uint32_t viewportCount; - const VkViewport* pViewports; - uint32_t scissorCount; - const VkRect2D* pScissors; -} VkPipelineViewportStateCreateInfo; - -typedef struct VkPipelineRasterizationStateCreateInfo { - VkStructureType sType; - const void* pNext; - VkPipelineRasterizationStateCreateFlags flags; - VkBool32 depthClampEnable; - VkBool32 rasterizerDiscardEnable; - VkPolygonMode polygonMode; - VkCullModeFlags cullMode; - VkFrontFace frontFace; - VkBool32 depthBiasEnable; - float depthBiasConstantFactor; - float depthBiasClamp; - float depthBiasSlopeFactor; - float lineWidth; -} VkPipelineRasterizationStateCreateInfo; - -typedef struct VkPipelineMultisampleStateCreateInfo { - VkStructureType sType; - const void* pNext; - VkPipelineMultisampleStateCreateFlags flags; - VkSampleCountFlagBits rasterizationSamples; - VkBool32 sampleShadingEnable; - float minSampleShading; - const VkSampleMask* pSampleMask; - VkBool32 alphaToCoverageEnable; - VkBool32 alphaToOneEnable; -} VkPipelineMultisampleStateCreateInfo; - -typedef struct VkStencilOpState { - VkStencilOp failOp; - VkStencilOp passOp; - VkStencilOp depthFailOp; - VkCompareOp compareOp; - uint32_t compareMask; - uint32_t writeMask; - uint32_t reference; -} VkStencilOpState; - -typedef struct VkPipelineDepthStencilStateCreateInfo { - VkStructureType sType; - const void* pNext; - VkPipelineDepthStencilStateCreateFlags flags; - VkBool32 depthTestEnable; - VkBool32 depthWriteEnable; - VkCompareOp depthCompareOp; - VkBool32 depthBoundsTestEnable; - VkBool32 stencilTestEnable; - VkStencilOpState front; - VkStencilOpState back; - float minDepthBounds; - float maxDepthBounds; -} VkPipelineDepthStencilStateCreateInfo; - -typedef struct VkPipelineColorBlendAttachmentState { - VkBool32 blendEnable; - VkBlendFactor srcColorBlendFactor; - VkBlendFactor dstColorBlendFactor; - VkBlendOp colorBlendOp; - VkBlendFactor srcAlphaBlendFactor; - VkBlendFactor dstAlphaBlendFactor; - VkBlendOp alphaBlendOp; - VkColorComponentFlags colorWriteMask; -} VkPipelineColorBlendAttachmentState; - -typedef struct VkPipelineColorBlendStateCreateInfo { - VkStructureType sType; - const void* pNext; - VkPipelineColorBlendStateCreateFlags flags; - VkBool32 logicOpEnable; - VkLogicOp logicOp; - uint32_t attachmentCount; - const VkPipelineColorBlendAttachmentState* pAttachments; - float blendConstants[4]; -} VkPipelineColorBlendStateCreateInfo; - -typedef struct VkPipelineDynamicStateCreateInfo { - VkStructureType sType; - const void* pNext; - VkPipelineDynamicStateCreateFlags flags; - uint32_t dynamicStateCount; - const VkDynamicState* pDynamicStates; -} VkPipelineDynamicStateCreateInfo; - -typedef struct VkGraphicsPipelineCreateInfo { - VkStructureType sType; - const void* pNext; - VkPipelineCreateFlags flags; - uint32_t stageCount; - const VkPipelineShaderStageCreateInfo* pStages; - const VkPipelineVertexInputStateCreateInfo* pVertexInputState; - const VkPipelineInputAssemblyStateCreateInfo* pInputAssemblyState; - const VkPipelineTessellationStateCreateInfo* pTessellationState; - const VkPipelineViewportStateCreateInfo* pViewportState; - const VkPipelineRasterizationStateCreateInfo* pRasterizationState; - const VkPipelineMultisampleStateCreateInfo* pMultisampleState; - const VkPipelineDepthStencilStateCreateInfo* pDepthStencilState; - const VkPipelineColorBlendStateCreateInfo* pColorBlendState; - const VkPipelineDynamicStateCreateInfo* pDynamicState; - VkPipelineLayout layout; - VkRenderPass renderPass; - uint32_t subpass; - VkPipeline basePipelineHandle; - int32_t basePipelineIndex; -} VkGraphicsPipelineCreateInfo; - -typedef struct VkComputePipelineCreateInfo { - VkStructureType sType; - const void* pNext; - VkPipelineCreateFlags flags; - VkPipelineShaderStageCreateInfo stage; - VkPipelineLayout layout; - VkPipeline basePipelineHandle; - int32_t basePipelineIndex; -} VkComputePipelineCreateInfo; - -typedef struct VkPushConstantRange { - VkShaderStageFlags stageFlags; - uint32_t offset; - uint32_t size; -} VkPushConstantRange; - -typedef struct VkPipelineLayoutCreateInfo { - VkStructureType sType; - const void* pNext; - VkPipelineLayoutCreateFlags flags; - uint32_t setLayoutCount; - const VkDescriptorSetLayout* pSetLayouts; - uint32_t pushConstantRangeCount; - const VkPushConstantRange* pPushConstantRanges; -} VkPipelineLayoutCreateInfo; - -typedef struct VkSamplerCreateInfo { - VkStructureType sType; - const void* pNext; - VkSamplerCreateFlags flags; - VkFilter magFilter; - VkFilter minFilter; - VkSamplerMipmapMode mipmapMode; - VkSamplerAddressMode addressModeU; - VkSamplerAddressMode addressModeV; - VkSamplerAddressMode addressModeW; - float mipLodBias; - VkBool32 anisotropyEnable; - float maxAnisotropy; - VkBool32 compareEnable; - VkCompareOp compareOp; - float minLod; - float maxLod; - VkBorderColor borderColor; - VkBool32 unnormalizedCoordinates; -} VkSamplerCreateInfo; - -typedef struct VkDescriptorSetLayoutBinding { - uint32_t binding; - VkDescriptorType descriptorType; - uint32_t descriptorCount; - VkShaderStageFlags stageFlags; - const VkSampler* pImmutableSamplers; -} VkDescriptorSetLayoutBinding; - -typedef struct VkDescriptorSetLayoutCreateInfo { - VkStructureType sType; - const void* pNext; - VkDescriptorSetLayoutCreateFlags flags; - uint32_t bindingCount; - const VkDescriptorSetLayoutBinding* pBindings; -} VkDescriptorSetLayoutCreateInfo; - -typedef struct VkDescriptorPoolSize { - VkDescriptorType type; - uint32_t descriptorCount; -} VkDescriptorPoolSize; - -typedef struct VkDescriptorPoolCreateInfo { - VkStructureType sType; - const void* pNext; - VkDescriptorPoolCreateFlags flags; - uint32_t maxSets; - uint32_t poolSizeCount; - const VkDescriptorPoolSize* pPoolSizes; -} VkDescriptorPoolCreateInfo; - -typedef struct VkDescriptorSetAllocateInfo { - VkStructureType sType; - const void* pNext; - VkDescriptorPool descriptorPool; - uint32_t descriptorSetCount; - const VkDescriptorSetLayout* pSetLayouts; -} VkDescriptorSetAllocateInfo; - -typedef struct VkDescriptorImageInfo { - VkSampler sampler; - VkImageView imageView; - VkImageLayout imageLayout; -} VkDescriptorImageInfo; - -typedef struct VkDescriptorBufferInfo { - VkBuffer buffer; - VkDeviceSize offset; - VkDeviceSize range; -} VkDescriptorBufferInfo; - -typedef struct VkWriteDescriptorSet { - VkStructureType sType; - const void* pNext; - VkDescriptorSet dstSet; - uint32_t dstBinding; - uint32_t dstArrayElement; - uint32_t descriptorCount; - VkDescriptorType descriptorType; - const VkDescriptorImageInfo* pImageInfo; - const VkDescriptorBufferInfo* pBufferInfo; - const VkBufferView* pTexelBufferView; -} VkWriteDescriptorSet; - -typedef struct VkCopyDescriptorSet { - VkStructureType sType; - const void* pNext; - VkDescriptorSet srcSet; - uint32_t srcBinding; - uint32_t srcArrayElement; - VkDescriptorSet dstSet; - uint32_t dstBinding; - uint32_t dstArrayElement; - uint32_t descriptorCount; -} VkCopyDescriptorSet; - -typedef struct VkFramebufferCreateInfo { - VkStructureType sType; - const void* pNext; - VkFramebufferCreateFlags flags; - VkRenderPass renderPass; - uint32_t attachmentCount; - const VkImageView* pAttachments; - uint32_t width; - uint32_t height; - uint32_t layers; -} VkFramebufferCreateInfo; - -typedef struct VkAttachmentDescription { - VkAttachmentDescriptionFlags flags; - VkFormat format; - VkSampleCountFlagBits samples; - VkAttachmentLoadOp loadOp; - VkAttachmentStoreOp storeOp; - VkAttachmentLoadOp stencilLoadOp; - VkAttachmentStoreOp stencilStoreOp; - VkImageLayout initialLayout; - VkImageLayout finalLayout; -} VkAttachmentDescription; - -typedef struct VkAttachmentReference { - uint32_t attachment; - VkImageLayout layout; -} VkAttachmentReference; - -typedef struct VkSubpassDescription { - VkSubpassDescriptionFlags flags; - VkPipelineBindPoint pipelineBindPoint; - uint32_t inputAttachmentCount; - const VkAttachmentReference* pInputAttachments; - uint32_t colorAttachmentCount; - const VkAttachmentReference* pColorAttachments; - const VkAttachmentReference* pResolveAttachments; - const VkAttachmentReference* pDepthStencilAttachment; - uint32_t preserveAttachmentCount; - const uint32_t* pPreserveAttachments; -} VkSubpassDescription; - -typedef struct VkSubpassDependency { - uint32_t srcSubpass; - uint32_t dstSubpass; - VkPipelineStageFlags srcStageMask; - VkPipelineStageFlags dstStageMask; - VkAccessFlags srcAccessMask; - VkAccessFlags dstAccessMask; - VkDependencyFlags dependencyFlags; -} VkSubpassDependency; - -typedef struct VkRenderPassCreateInfo { - VkStructureType sType; - const void* pNext; - VkRenderPassCreateFlags flags; - uint32_t attachmentCount; - const VkAttachmentDescription* pAttachments; - uint32_t subpassCount; - const VkSubpassDescription* pSubpasses; - uint32_t dependencyCount; - const VkSubpassDependency* pDependencies; -} VkRenderPassCreateInfo; - -typedef struct VkCommandPoolCreateInfo { - VkStructureType sType; - const void* pNext; - VkCommandPoolCreateFlags flags; - uint32_t queueFamilyIndex; -} VkCommandPoolCreateInfo; - -typedef struct VkCommandBufferAllocateInfo { - VkStructureType sType; - const void* pNext; - VkCommandPool commandPool; - VkCommandBufferLevel level; - uint32_t commandBufferCount; -} VkCommandBufferAllocateInfo; - -typedef struct VkCommandBufferInheritanceInfo { - VkStructureType sType; - const void* pNext; - VkRenderPass renderPass; - uint32_t subpass; - VkFramebuffer framebuffer; - VkBool32 occlusionQueryEnable; - VkQueryControlFlags queryFlags; - VkQueryPipelineStatisticFlags pipelineStatistics; -} VkCommandBufferInheritanceInfo; - -typedef struct VkCommandBufferBeginInfo { - VkStructureType sType; - const void* pNext; - VkCommandBufferUsageFlags flags; - const VkCommandBufferInheritanceInfo* pInheritanceInfo; -} VkCommandBufferBeginInfo; - -typedef struct VkBufferCopy { - VkDeviceSize srcOffset; - VkDeviceSize dstOffset; - VkDeviceSize size; -} VkBufferCopy; - -typedef struct VkImageSubresourceLayers { - VkImageAspectFlags aspectMask; - uint32_t mipLevel; - uint32_t baseArrayLayer; - uint32_t layerCount; -} VkImageSubresourceLayers; - -typedef struct VkImageCopy { - VkImageSubresourceLayers srcSubresource; - VkOffset3D srcOffset; - VkImageSubresourceLayers dstSubresource; - VkOffset3D dstOffset; - VkExtent3D extent; -} VkImageCopy; - -typedef struct VkImageBlit { - VkImageSubresourceLayers srcSubresource; - VkOffset3D srcOffsets[2]; - VkImageSubresourceLayers dstSubresource; - VkOffset3D dstOffsets[2]; -} VkImageBlit; - -typedef struct VkBufferImageCopy { - VkDeviceSize bufferOffset; - uint32_t bufferRowLength; - uint32_t bufferImageHeight; - VkImageSubresourceLayers imageSubresource; - VkOffset3D imageOffset; - VkExtent3D imageExtent; -} VkBufferImageCopy; - -typedef union VkClearColorValue { - float float32[4]; - int32_t int32[4]; - uint32_t uint32[4]; -} VkClearColorValue; - -typedef struct VkClearDepthStencilValue { - float depth; - uint32_t stencil; -} VkClearDepthStencilValue; - -typedef union VkClearValue { - VkClearColorValue color; - VkClearDepthStencilValue depthStencil; -} VkClearValue; - -typedef struct VkClearAttachment { - VkImageAspectFlags aspectMask; - uint32_t colorAttachment; - VkClearValue clearValue; -} VkClearAttachment; - -typedef struct VkClearRect { - VkRect2D rect; - uint32_t baseArrayLayer; - uint32_t layerCount; -} VkClearRect; - -typedef struct VkImageResolve { - VkImageSubresourceLayers srcSubresource; - VkOffset3D srcOffset; - VkImageSubresourceLayers dstSubresource; - VkOffset3D dstOffset; - VkExtent3D extent; -} VkImageResolve; - -typedef struct VkMemoryBarrier { - VkStructureType sType; - const void* pNext; - VkAccessFlags srcAccessMask; - VkAccessFlags dstAccessMask; -} VkMemoryBarrier; - -typedef struct VkBufferMemoryBarrier { - VkStructureType sType; - const void* pNext; - VkAccessFlags srcAccessMask; - VkAccessFlags dstAccessMask; - uint32_t srcQueueFamilyIndex; - uint32_t dstQueueFamilyIndex; - VkBuffer buffer; - VkDeviceSize offset; - VkDeviceSize size; -} VkBufferMemoryBarrier; - -typedef struct VkImageMemoryBarrier { - VkStructureType sType; - const void* pNext; - VkAccessFlags srcAccessMask; - VkAccessFlags dstAccessMask; - VkImageLayout oldLayout; - VkImageLayout newLayout; - uint32_t srcQueueFamilyIndex; - uint32_t dstQueueFamilyIndex; - VkImage image; - VkImageSubresourceRange subresourceRange; -} VkImageMemoryBarrier; - -typedef struct VkRenderPassBeginInfo { - VkStructureType sType; - const void* pNext; - VkRenderPass renderPass; - VkFramebuffer framebuffer; - VkRect2D renderArea; - uint32_t clearValueCount; - const VkClearValue* pClearValues; -} VkRenderPassBeginInfo; - -typedef struct VkDispatchIndirectCommand { - uint32_t x; - uint32_t y; - uint32_t z; -} VkDispatchIndirectCommand; - -typedef struct VkDrawIndexedIndirectCommand { - uint32_t indexCount; - uint32_t instanceCount; - uint32_t firstIndex; - int32_t vertexOffset; - uint32_t firstInstance; -} VkDrawIndexedIndirectCommand; - -typedef struct VkDrawIndirectCommand { - uint32_t vertexCount; - uint32_t instanceCount; - uint32_t firstVertex; - uint32_t firstInstance; -} VkDrawIndirectCommand; - - -typedef VkResult (VKAPI_PTR *PFN_vkCreateInstance)(const VkInstanceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkInstance* pInstance); -typedef void (VKAPI_PTR *PFN_vkDestroyInstance)(VkInstance instance, const VkAllocationCallbacks* pAllocator); -typedef VkResult (VKAPI_PTR *PFN_vkEnumeratePhysicalDevices)(VkInstance instance, uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices); -typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceFeatures)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures* pFeatures); -typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceFormatProperties)(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties* pFormatProperties); -typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceImageFormatProperties)(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* pImageFormatProperties); -typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceProperties)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties* pProperties); -typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceQueueFamilyProperties)(VkPhysicalDevice physicalDevice, uint32_t* pQueueFamilyPropertyCount, VkQueueFamilyProperties* pQueueFamilyProperties); -typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceMemoryProperties)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties* pMemoryProperties); -typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_vkGetInstanceProcAddr)(VkInstance instance, const char* pName); -typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_vkGetDeviceProcAddr)(VkDevice device, const char* pName); -typedef VkResult (VKAPI_PTR *PFN_vkCreateDevice)(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDevice* pDevice); -typedef void (VKAPI_PTR *PFN_vkDestroyDevice)(VkDevice device, const VkAllocationCallbacks* pAllocator); -typedef VkResult (VKAPI_PTR *PFN_vkEnumerateInstanceExtensionProperties)(const char* pLayerName, uint32_t* pPropertyCount, VkExtensionProperties* pProperties); -typedef VkResult (VKAPI_PTR *PFN_vkEnumerateDeviceExtensionProperties)(VkPhysicalDevice physicalDevice, const char* pLayerName, uint32_t* pPropertyCount, VkExtensionProperties* pProperties); -typedef VkResult (VKAPI_PTR *PFN_vkEnumerateInstanceLayerProperties)(uint32_t* pPropertyCount, VkLayerProperties* pProperties); -typedef VkResult (VKAPI_PTR *PFN_vkEnumerateDeviceLayerProperties)(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkLayerProperties* pProperties); -typedef void (VKAPI_PTR *PFN_vkGetDeviceQueue)(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue* pQueue); -typedef VkResult (VKAPI_PTR *PFN_vkQueueSubmit)(VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmits, VkFence fence); -typedef VkResult (VKAPI_PTR *PFN_vkQueueWaitIdle)(VkQueue queue); -typedef VkResult (VKAPI_PTR *PFN_vkDeviceWaitIdle)(VkDevice device); -typedef VkResult (VKAPI_PTR *PFN_vkAllocateMemory)(VkDevice device, const VkMemoryAllocateInfo* pAllocateInfo, const VkAllocationCallbacks* pAllocator, VkDeviceMemory* pMemory); -typedef void (VKAPI_PTR *PFN_vkFreeMemory)(VkDevice device, VkDeviceMemory memory, const VkAllocationCallbacks* pAllocator); -typedef VkResult (VKAPI_PTR *PFN_vkMapMemory)(VkDevice device, VkDeviceMemory memory, VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags, void** ppData); -typedef void (VKAPI_PTR *PFN_vkUnmapMemory)(VkDevice device, VkDeviceMemory memory); -typedef VkResult (VKAPI_PTR *PFN_vkFlushMappedMemoryRanges)(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange* pMemoryRanges); -typedef VkResult (VKAPI_PTR *PFN_vkInvalidateMappedMemoryRanges)(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange* pMemoryRanges); -typedef void (VKAPI_PTR *PFN_vkGetDeviceMemoryCommitment)(VkDevice device, VkDeviceMemory memory, VkDeviceSize* pCommittedMemoryInBytes); -typedef VkResult (VKAPI_PTR *PFN_vkBindBufferMemory)(VkDevice device, VkBuffer buffer, VkDeviceMemory memory, VkDeviceSize memoryOffset); -typedef VkResult (VKAPI_PTR *PFN_vkBindImageMemory)(VkDevice device, VkImage image, VkDeviceMemory memory, VkDeviceSize memoryOffset); -typedef void (VKAPI_PTR *PFN_vkGetBufferMemoryRequirements)(VkDevice device, VkBuffer buffer, VkMemoryRequirements* pMemoryRequirements); -typedef void (VKAPI_PTR *PFN_vkGetImageMemoryRequirements)(VkDevice device, VkImage image, VkMemoryRequirements* pMemoryRequirements); -typedef void (VKAPI_PTR *PFN_vkGetImageSparseMemoryRequirements)(VkDevice device, VkImage image, uint32_t* pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements* pSparseMemoryRequirements); -typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceSparseImageFormatProperties)(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkSampleCountFlagBits samples, VkImageUsageFlags usage, VkImageTiling tiling, uint32_t* pPropertyCount, VkSparseImageFormatProperties* pProperties); -typedef VkResult (VKAPI_PTR *PFN_vkQueueBindSparse)(VkQueue queue, uint32_t bindInfoCount, const VkBindSparseInfo* pBindInfo, VkFence fence); -typedef VkResult (VKAPI_PTR *PFN_vkCreateFence)(VkDevice device, const VkFenceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkFence* pFence); -typedef void (VKAPI_PTR *PFN_vkDestroyFence)(VkDevice device, VkFence fence, const VkAllocationCallbacks* pAllocator); -typedef VkResult (VKAPI_PTR *PFN_vkResetFences)(VkDevice device, uint32_t fenceCount, const VkFence* pFences); -typedef VkResult (VKAPI_PTR *PFN_vkGetFenceStatus)(VkDevice device, VkFence fence); -typedef VkResult (VKAPI_PTR *PFN_vkWaitForFences)(VkDevice device, uint32_t fenceCount, const VkFence* pFences, VkBool32 waitAll, uint64_t timeout); -typedef VkResult (VKAPI_PTR *PFN_vkCreateSemaphore)(VkDevice device, const VkSemaphoreCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSemaphore* pSemaphore); -typedef void (VKAPI_PTR *PFN_vkDestroySemaphore)(VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks* pAllocator); -typedef VkResult (VKAPI_PTR *PFN_vkCreateEvent)(VkDevice device, const VkEventCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkEvent* pEvent); -typedef void (VKAPI_PTR *PFN_vkDestroyEvent)(VkDevice device, VkEvent event, const VkAllocationCallbacks* pAllocator); -typedef VkResult (VKAPI_PTR *PFN_vkGetEventStatus)(VkDevice device, VkEvent event); -typedef VkResult (VKAPI_PTR *PFN_vkSetEvent)(VkDevice device, VkEvent event); -typedef VkResult (VKAPI_PTR *PFN_vkResetEvent)(VkDevice device, VkEvent event); -typedef VkResult (VKAPI_PTR *PFN_vkCreateQueryPool)(VkDevice device, const VkQueryPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkQueryPool* pQueryPool); -typedef void (VKAPI_PTR *PFN_vkDestroyQueryPool)(VkDevice device, VkQueryPool queryPool, const VkAllocationCallbacks* pAllocator); -typedef VkResult (VKAPI_PTR *PFN_vkGetQueryPoolResults)(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, size_t dataSize, void* pData, VkDeviceSize stride, VkQueryResultFlags flags); -typedef VkResult (VKAPI_PTR *PFN_vkCreateBuffer)(VkDevice device, const VkBufferCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBuffer* pBuffer); -typedef void (VKAPI_PTR *PFN_vkDestroyBuffer)(VkDevice device, VkBuffer buffer, const VkAllocationCallbacks* pAllocator); -typedef VkResult (VKAPI_PTR *PFN_vkCreateBufferView)(VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBufferView* pView); -typedef void (VKAPI_PTR *PFN_vkDestroyBufferView)(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks* pAllocator); -typedef VkResult (VKAPI_PTR *PFN_vkCreateImage)(VkDevice device, const VkImageCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImage* pImage); -typedef void (VKAPI_PTR *PFN_vkDestroyImage)(VkDevice device, VkImage image, const VkAllocationCallbacks* pAllocator); -typedef void (VKAPI_PTR *PFN_vkGetImageSubresourceLayout)(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout); -typedef VkResult (VKAPI_PTR *PFN_vkCreateImageView)(VkDevice device, const VkImageViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImageView* pView); -typedef void (VKAPI_PTR *PFN_vkDestroyImageView)(VkDevice device, VkImageView imageView, const VkAllocationCallbacks* pAllocator); -typedef VkResult (VKAPI_PTR *PFN_vkCreateShaderModule)(VkDevice device, const VkShaderModuleCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkShaderModule* pShaderModule); -typedef void (VKAPI_PTR *PFN_vkDestroyShaderModule)(VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks* pAllocator); -typedef VkResult (VKAPI_PTR *PFN_vkCreatePipelineCache)(VkDevice device, const VkPipelineCacheCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineCache* pPipelineCache); -typedef void (VKAPI_PTR *PFN_vkDestroyPipelineCache)(VkDevice device, VkPipelineCache pipelineCache, const VkAllocationCallbacks* pAllocator); -typedef VkResult (VKAPI_PTR *PFN_vkGetPipelineCacheData)(VkDevice device, VkPipelineCache pipelineCache, size_t* pDataSize, void* pData); -typedef VkResult (VKAPI_PTR *PFN_vkMergePipelineCaches)(VkDevice device, VkPipelineCache dstCache, uint32_t srcCacheCount, const VkPipelineCache* pSrcCaches); -typedef VkResult (VKAPI_PTR *PFN_vkCreateGraphicsPipelines)(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkGraphicsPipelineCreateInfo* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines); -typedef VkResult (VKAPI_PTR *PFN_vkCreateComputePipelines)(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkComputePipelineCreateInfo* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines); -typedef void (VKAPI_PTR *PFN_vkDestroyPipeline)(VkDevice device, VkPipeline pipeline, const VkAllocationCallbacks* pAllocator); -typedef VkResult (VKAPI_PTR *PFN_vkCreatePipelineLayout)(VkDevice device, const VkPipelineLayoutCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineLayout* pPipelineLayout); -typedef void (VKAPI_PTR *PFN_vkDestroyPipelineLayout)(VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks* pAllocator); -typedef VkResult (VKAPI_PTR *PFN_vkCreateSampler)(VkDevice device, const VkSamplerCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSampler* pSampler); -typedef void (VKAPI_PTR *PFN_vkDestroySampler)(VkDevice device, VkSampler sampler, const VkAllocationCallbacks* pAllocator); -typedef VkResult (VKAPI_PTR *PFN_vkCreateDescriptorSetLayout)(VkDevice device, const VkDescriptorSetLayoutCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDescriptorSetLayout* pSetLayout); -typedef void (VKAPI_PTR *PFN_vkDestroyDescriptorSetLayout)(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const VkAllocationCallbacks* pAllocator); -typedef VkResult (VKAPI_PTR *PFN_vkCreateDescriptorPool)(VkDevice device, const VkDescriptorPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDescriptorPool* pDescriptorPool); -typedef void (VKAPI_PTR *PFN_vkDestroyDescriptorPool)(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocationCallbacks* pAllocator); -typedef VkResult (VKAPI_PTR *PFN_vkResetDescriptorPool)(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags); -typedef VkResult (VKAPI_PTR *PFN_vkAllocateDescriptorSets)(VkDevice device, const VkDescriptorSetAllocateInfo* pAllocateInfo, VkDescriptorSet* pDescriptorSets); -typedef VkResult (VKAPI_PTR *PFN_vkFreeDescriptorSets)(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, const VkDescriptorSet* pDescriptorSets); -typedef void (VKAPI_PTR *PFN_vkUpdateDescriptorSets)(VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t descriptorCopyCount, const VkCopyDescriptorSet* pDescriptorCopies); -typedef VkResult (VKAPI_PTR *PFN_vkCreateFramebuffer)(VkDevice device, const VkFramebufferCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkFramebuffer* pFramebuffer); -typedef void (VKAPI_PTR *PFN_vkDestroyFramebuffer)(VkDevice device, VkFramebuffer framebuffer, const VkAllocationCallbacks* pAllocator); -typedef VkResult (VKAPI_PTR *PFN_vkCreateRenderPass)(VkDevice device, const VkRenderPassCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkRenderPass* pRenderPass); -typedef void (VKAPI_PTR *PFN_vkDestroyRenderPass)(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks* pAllocator); -typedef void (VKAPI_PTR *PFN_vkGetRenderAreaGranularity)(VkDevice device, VkRenderPass renderPass, VkExtent2D* pGranularity); -typedef VkResult (VKAPI_PTR *PFN_vkCreateCommandPool)(VkDevice device, const VkCommandPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkCommandPool* pCommandPool); -typedef void (VKAPI_PTR *PFN_vkDestroyCommandPool)(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks* pAllocator); -typedef VkResult (VKAPI_PTR *PFN_vkResetCommandPool)(VkDevice device, VkCommandPool commandPool, VkCommandPoolResetFlags flags); -typedef VkResult (VKAPI_PTR *PFN_vkAllocateCommandBuffers)(VkDevice device, const VkCommandBufferAllocateInfo* pAllocateInfo, VkCommandBuffer* pCommandBuffers); -typedef void (VKAPI_PTR *PFN_vkFreeCommandBuffers)(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, const VkCommandBuffer* pCommandBuffers); -typedef VkResult (VKAPI_PTR *PFN_vkBeginCommandBuffer)(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo* pBeginInfo); -typedef VkResult (VKAPI_PTR *PFN_vkEndCommandBuffer)(VkCommandBuffer commandBuffer); -typedef VkResult (VKAPI_PTR *PFN_vkResetCommandBuffer)(VkCommandBuffer commandBuffer, VkCommandBufferResetFlags flags); -typedef void (VKAPI_PTR *PFN_vkCmdBindPipeline)(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline); -typedef void (VKAPI_PTR *PFN_vkCmdSetViewport)(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewport* pViewports); -typedef void (VKAPI_PTR *PFN_vkCmdSetScissor)(VkCommandBuffer commandBuffer, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D* pScissors); -typedef void (VKAPI_PTR *PFN_vkCmdSetLineWidth)(VkCommandBuffer commandBuffer, float lineWidth); -typedef void (VKAPI_PTR *PFN_vkCmdSetDepthBias)(VkCommandBuffer commandBuffer, float depthBiasConstantFactor, float depthBiasClamp, float depthBiasSlopeFactor); -typedef void (VKAPI_PTR *PFN_vkCmdSetBlendConstants)(VkCommandBuffer commandBuffer, const float blendConstants[4]); -typedef void (VKAPI_PTR *PFN_vkCmdSetDepthBounds)(VkCommandBuffer commandBuffer, float minDepthBounds, float maxDepthBounds); -typedef void (VKAPI_PTR *PFN_vkCmdSetStencilCompareMask)(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t compareMask); -typedef void (VKAPI_PTR *PFN_vkCmdSetStencilWriteMask)(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t writeMask); -typedef void (VKAPI_PTR *PFN_vkCmdSetStencilReference)(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t reference); -typedef void (VKAPI_PTR *PFN_vkCmdBindDescriptorSets)(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t firstSet, uint32_t descriptorSetCount, const VkDescriptorSet* pDescriptorSets, uint32_t dynamicOffsetCount, const uint32_t* pDynamicOffsets); -typedef void (VKAPI_PTR *PFN_vkCmdBindIndexBuffer)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType); -typedef void (VKAPI_PTR *PFN_vkCmdBindVertexBuffers)(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount, const VkBuffer* pBuffers, const VkDeviceSize* pOffsets); -typedef void (VKAPI_PTR *PFN_vkCmdDraw)(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance); -typedef void (VKAPI_PTR *PFN_vkCmdDrawIndexed)(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance); -typedef void (VKAPI_PTR *PFN_vkCmdDrawIndirect)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride); -typedef void (VKAPI_PTR *PFN_vkCmdDrawIndexedIndirect)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride); -typedef void (VKAPI_PTR *PFN_vkCmdDispatch)(VkCommandBuffer commandBuffer, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ); -typedef void (VKAPI_PTR *PFN_vkCmdDispatchIndirect)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset); -typedef void (VKAPI_PTR *PFN_vkCmdCopyBuffer)(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferCopy* pRegions); -typedef void (VKAPI_PTR *PFN_vkCmdCopyImage)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageCopy* pRegions); -typedef void (VKAPI_PTR *PFN_vkCmdBlitImage)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit* pRegions, VkFilter filter); -typedef void (VKAPI_PTR *PFN_vkCmdCopyBufferToImage)(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkBufferImageCopy* pRegions); -typedef void (VKAPI_PTR *PFN_vkCmdCopyImageToBuffer)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy* pRegions); -typedef void (VKAPI_PTR *PFN_vkCmdUpdateBuffer)(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize dataSize, const void* pData); -typedef void (VKAPI_PTR *PFN_vkCmdFillBuffer)(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data); -typedef void (VKAPI_PTR *PFN_vkCmdClearColorImage)(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearColorValue* pColor, uint32_t rangeCount, const VkImageSubresourceRange* pRanges); -typedef void (VKAPI_PTR *PFN_vkCmdClearDepthStencilImage)(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue* pDepthStencil, uint32_t rangeCount, const VkImageSubresourceRange* pRanges); -typedef void (VKAPI_PTR *PFN_vkCmdClearAttachments)(VkCommandBuffer commandBuffer, uint32_t attachmentCount, const VkClearAttachment* pAttachments, uint32_t rectCount, const VkClearRect* pRects); -typedef void (VKAPI_PTR *PFN_vkCmdResolveImage)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageResolve* pRegions); -typedef void (VKAPI_PTR *PFN_vkCmdSetEvent)(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask); -typedef void (VKAPI_PTR *PFN_vkCmdResetEvent)(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask); -typedef void (VKAPI_PTR *PFN_vkCmdWaitEvents)(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent* pEvents, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, uint32_t memoryBarrierCount, const VkMemoryBarrier* pMemoryBarriers, uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier* pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier* pImageMemoryBarriers); -typedef void (VKAPI_PTR *PFN_vkCmdPipelineBarrier)(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, uint32_t memoryBarrierCount, const VkMemoryBarrier* pMemoryBarriers, uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier* pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier* pImageMemoryBarriers); -typedef void (VKAPI_PTR *PFN_vkCmdBeginQuery)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query, VkQueryControlFlags flags); -typedef void (VKAPI_PTR *PFN_vkCmdEndQuery)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query); -typedef void (VKAPI_PTR *PFN_vkCmdResetQueryPool)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount); -typedef void (VKAPI_PTR *PFN_vkCmdWriteTimestamp)(VkCommandBuffer commandBuffer, VkPipelineStageFlagBits pipelineStage, VkQueryPool queryPool, uint32_t query); -typedef void (VKAPI_PTR *PFN_vkCmdCopyQueryPoolResults)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize stride, VkQueryResultFlags flags); -typedef void (VKAPI_PTR *PFN_vkCmdPushConstants)(VkCommandBuffer commandBuffer, VkPipelineLayout layout, VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size, const void* pValues); -typedef void (VKAPI_PTR *PFN_vkCmdBeginRenderPass)(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, VkSubpassContents contents); -typedef void (VKAPI_PTR *PFN_vkCmdNextSubpass)(VkCommandBuffer commandBuffer, VkSubpassContents contents); -typedef void (VKAPI_PTR *PFN_vkCmdEndRenderPass)(VkCommandBuffer commandBuffer); -typedef void (VKAPI_PTR *PFN_vkCmdExecuteCommands)(VkCommandBuffer commandBuffer, uint32_t commandBufferCount, const VkCommandBuffer* pCommandBuffers); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance( - const VkInstanceCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkInstance* pInstance); - -VKAPI_ATTR void VKAPI_CALL vkDestroyInstance( - VkInstance instance, - const VkAllocationCallbacks* pAllocator); - -VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDevices( - VkInstance instance, - uint32_t* pPhysicalDeviceCount, - VkPhysicalDevice* pPhysicalDevices); - -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures( - VkPhysicalDevice physicalDevice, - VkPhysicalDeviceFeatures* pFeatures); - -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties( - VkPhysicalDevice physicalDevice, - VkFormat format, - VkFormatProperties* pFormatProperties); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties( - VkPhysicalDevice physicalDevice, - VkFormat format, - VkImageType type, - VkImageTiling tiling, - VkImageUsageFlags usage, - VkImageCreateFlags flags, - VkImageFormatProperties* pImageFormatProperties); - -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties( - VkPhysicalDevice physicalDevice, - VkPhysicalDeviceProperties* pProperties); - -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties( - VkPhysicalDevice physicalDevice, - uint32_t* pQueueFamilyPropertyCount, - VkQueueFamilyProperties* pQueueFamilyProperties); - -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties( - VkPhysicalDevice physicalDevice, - VkPhysicalDeviceMemoryProperties* pMemoryProperties); - -VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr( - VkInstance instance, - const char* pName); - -VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr( - VkDevice device, - const char* pName); - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice( - VkPhysicalDevice physicalDevice, - const VkDeviceCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkDevice* pDevice); - -VKAPI_ATTR void VKAPI_CALL vkDestroyDevice( - VkDevice device, - const VkAllocationCallbacks* pAllocator); - -VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties( - const char* pLayerName, - uint32_t* pPropertyCount, - VkExtensionProperties* pProperties); - -VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties( - VkPhysicalDevice physicalDevice, - const char* pLayerName, - uint32_t* pPropertyCount, - VkExtensionProperties* pProperties); - -VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties( - uint32_t* pPropertyCount, - VkLayerProperties* pProperties); - -VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties( - VkPhysicalDevice physicalDevice, - uint32_t* pPropertyCount, - VkLayerProperties* pProperties); - -VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue( - VkDevice device, - uint32_t queueFamilyIndex, - uint32_t queueIndex, - VkQueue* pQueue); - -VKAPI_ATTR VkResult VKAPI_CALL vkQueueSubmit( - VkQueue queue, - uint32_t submitCount, - const VkSubmitInfo* pSubmits, - VkFence fence); - -VKAPI_ATTR VkResult VKAPI_CALL vkQueueWaitIdle( - VkQueue queue); - -VKAPI_ATTR VkResult VKAPI_CALL vkDeviceWaitIdle( - VkDevice device); - -VKAPI_ATTR VkResult VKAPI_CALL vkAllocateMemory( - VkDevice device, - const VkMemoryAllocateInfo* pAllocateInfo, - const VkAllocationCallbacks* pAllocator, - VkDeviceMemory* pMemory); - -VKAPI_ATTR void VKAPI_CALL vkFreeMemory( - VkDevice device, - VkDeviceMemory memory, - const VkAllocationCallbacks* pAllocator); - -VKAPI_ATTR VkResult VKAPI_CALL vkMapMemory( - VkDevice device, - VkDeviceMemory memory, - VkDeviceSize offset, - VkDeviceSize size, - VkMemoryMapFlags flags, - void** ppData); - -VKAPI_ATTR void VKAPI_CALL vkUnmapMemory( - VkDevice device, - VkDeviceMemory memory); - -VKAPI_ATTR VkResult VKAPI_CALL vkFlushMappedMemoryRanges( - VkDevice device, - uint32_t memoryRangeCount, - const VkMappedMemoryRange* pMemoryRanges); - -VKAPI_ATTR VkResult VKAPI_CALL vkInvalidateMappedMemoryRanges( - VkDevice device, - uint32_t memoryRangeCount, - const VkMappedMemoryRange* pMemoryRanges); - -VKAPI_ATTR void VKAPI_CALL vkGetDeviceMemoryCommitment( - VkDevice device, - VkDeviceMemory memory, - VkDeviceSize* pCommittedMemoryInBytes); - -VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory( - VkDevice device, - VkBuffer buffer, - VkDeviceMemory memory, - VkDeviceSize memoryOffset); - -VKAPI_ATTR VkResult VKAPI_CALL vkBindImageMemory( - VkDevice device, - VkImage image, - VkDeviceMemory memory, - VkDeviceSize memoryOffset); - -VKAPI_ATTR void VKAPI_CALL vkGetBufferMemoryRequirements( - VkDevice device, - VkBuffer buffer, - VkMemoryRequirements* pMemoryRequirements); - -VKAPI_ATTR void VKAPI_CALL vkGetImageMemoryRequirements( - VkDevice device, - VkImage image, - VkMemoryRequirements* pMemoryRequirements); - -VKAPI_ATTR void VKAPI_CALL vkGetImageSparseMemoryRequirements( - VkDevice device, - VkImage image, - uint32_t* pSparseMemoryRequirementCount, - VkSparseImageMemoryRequirements* pSparseMemoryRequirements); - -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceSparseImageFormatProperties( - VkPhysicalDevice physicalDevice, - VkFormat format, - VkImageType type, - VkSampleCountFlagBits samples, - VkImageUsageFlags usage, - VkImageTiling tiling, - uint32_t* pPropertyCount, - VkSparseImageFormatProperties* pProperties); - -VKAPI_ATTR VkResult VKAPI_CALL vkQueueBindSparse( - VkQueue queue, - uint32_t bindInfoCount, - const VkBindSparseInfo* pBindInfo, - VkFence fence); - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateFence( - VkDevice device, - const VkFenceCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkFence* pFence); - -VKAPI_ATTR void VKAPI_CALL vkDestroyFence( - VkDevice device, - VkFence fence, - const VkAllocationCallbacks* pAllocator); - -VKAPI_ATTR VkResult VKAPI_CALL vkResetFences( - VkDevice device, - uint32_t fenceCount, - const VkFence* pFences); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetFenceStatus( - VkDevice device, - VkFence fence); - -VKAPI_ATTR VkResult VKAPI_CALL vkWaitForFences( - VkDevice device, - uint32_t fenceCount, - const VkFence* pFences, - VkBool32 waitAll, - uint64_t timeout); - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateSemaphore( - VkDevice device, - const VkSemaphoreCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSemaphore* pSemaphore); - -VKAPI_ATTR void VKAPI_CALL vkDestroySemaphore( - VkDevice device, - VkSemaphore semaphore, - const VkAllocationCallbacks* pAllocator); - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateEvent( - VkDevice device, - const VkEventCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkEvent* pEvent); - -VKAPI_ATTR void VKAPI_CALL vkDestroyEvent( - VkDevice device, - VkEvent event, - const VkAllocationCallbacks* pAllocator); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetEventStatus( - VkDevice device, - VkEvent event); - -VKAPI_ATTR VkResult VKAPI_CALL vkSetEvent( - VkDevice device, - VkEvent event); - -VKAPI_ATTR VkResult VKAPI_CALL vkResetEvent( - VkDevice device, - VkEvent event); - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateQueryPool( - VkDevice device, - const VkQueryPoolCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkQueryPool* pQueryPool); - -VKAPI_ATTR void VKAPI_CALL vkDestroyQueryPool( - VkDevice device, - VkQueryPool queryPool, - const VkAllocationCallbacks* pAllocator); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetQueryPoolResults( - VkDevice device, - VkQueryPool queryPool, - uint32_t firstQuery, - uint32_t queryCount, - size_t dataSize, - void* pData, - VkDeviceSize stride, - VkQueryResultFlags flags); - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateBuffer( - VkDevice device, - const VkBufferCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkBuffer* pBuffer); - -VKAPI_ATTR void VKAPI_CALL vkDestroyBuffer( - VkDevice device, - VkBuffer buffer, - const VkAllocationCallbacks* pAllocator); - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateBufferView( - VkDevice device, - const VkBufferViewCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkBufferView* pView); - -VKAPI_ATTR void VKAPI_CALL vkDestroyBufferView( - VkDevice device, - VkBufferView bufferView, - const VkAllocationCallbacks* pAllocator); - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateImage( - VkDevice device, - const VkImageCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkImage* pImage); - -VKAPI_ATTR void VKAPI_CALL vkDestroyImage( - VkDevice device, - VkImage image, - const VkAllocationCallbacks* pAllocator); - -VKAPI_ATTR void VKAPI_CALL vkGetImageSubresourceLayout( - VkDevice device, - VkImage image, - const VkImageSubresource* pSubresource, - VkSubresourceLayout* pLayout); - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateImageView( - VkDevice device, - const VkImageViewCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkImageView* pView); - -VKAPI_ATTR void VKAPI_CALL vkDestroyImageView( - VkDevice device, - VkImageView imageView, - const VkAllocationCallbacks* pAllocator); - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateShaderModule( - VkDevice device, - const VkShaderModuleCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkShaderModule* pShaderModule); - -VKAPI_ATTR void VKAPI_CALL vkDestroyShaderModule( - VkDevice device, - VkShaderModule shaderModule, - const VkAllocationCallbacks* pAllocator); - -VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineCache( - VkDevice device, - const VkPipelineCacheCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkPipelineCache* pPipelineCache); - -VKAPI_ATTR void VKAPI_CALL vkDestroyPipelineCache( - VkDevice device, - VkPipelineCache pipelineCache, - const VkAllocationCallbacks* pAllocator); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetPipelineCacheData( - VkDevice device, - VkPipelineCache pipelineCache, - size_t* pDataSize, - void* pData); - -VKAPI_ATTR VkResult VKAPI_CALL vkMergePipelineCaches( - VkDevice device, - VkPipelineCache dstCache, - uint32_t srcCacheCount, - const VkPipelineCache* pSrcCaches); - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateGraphicsPipelines( - VkDevice device, - VkPipelineCache pipelineCache, - uint32_t createInfoCount, - const VkGraphicsPipelineCreateInfo* pCreateInfos, - const VkAllocationCallbacks* pAllocator, - VkPipeline* pPipelines); - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateComputePipelines( - VkDevice device, - VkPipelineCache pipelineCache, - uint32_t createInfoCount, - const VkComputePipelineCreateInfo* pCreateInfos, - const VkAllocationCallbacks* pAllocator, - VkPipeline* pPipelines); - -VKAPI_ATTR void VKAPI_CALL vkDestroyPipeline( - VkDevice device, - VkPipeline pipeline, - const VkAllocationCallbacks* pAllocator); - -VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineLayout( - VkDevice device, - const VkPipelineLayoutCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkPipelineLayout* pPipelineLayout); - -VKAPI_ATTR void VKAPI_CALL vkDestroyPipelineLayout( - VkDevice device, - VkPipelineLayout pipelineLayout, - const VkAllocationCallbacks* pAllocator); - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateSampler( - VkDevice device, - const VkSamplerCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSampler* pSampler); - -VKAPI_ATTR void VKAPI_CALL vkDestroySampler( - VkDevice device, - VkSampler sampler, - const VkAllocationCallbacks* pAllocator); - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorSetLayout( - VkDevice device, - const VkDescriptorSetLayoutCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkDescriptorSetLayout* pSetLayout); - -VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorSetLayout( - VkDevice device, - VkDescriptorSetLayout descriptorSetLayout, - const VkAllocationCallbacks* pAllocator); - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorPool( - VkDevice device, - const VkDescriptorPoolCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkDescriptorPool* pDescriptorPool); - -VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorPool( - VkDevice device, - VkDescriptorPool descriptorPool, - const VkAllocationCallbacks* pAllocator); - -VKAPI_ATTR VkResult VKAPI_CALL vkResetDescriptorPool( - VkDevice device, - VkDescriptorPool descriptorPool, - VkDescriptorPoolResetFlags flags); - -VKAPI_ATTR VkResult VKAPI_CALL vkAllocateDescriptorSets( - VkDevice device, - const VkDescriptorSetAllocateInfo* pAllocateInfo, - VkDescriptorSet* pDescriptorSets); - -VKAPI_ATTR VkResult VKAPI_CALL vkFreeDescriptorSets( - VkDevice device, - VkDescriptorPool descriptorPool, - uint32_t descriptorSetCount, - const VkDescriptorSet* pDescriptorSets); - -VKAPI_ATTR void VKAPI_CALL vkUpdateDescriptorSets( - VkDevice device, - uint32_t descriptorWriteCount, - const VkWriteDescriptorSet* pDescriptorWrites, - uint32_t descriptorCopyCount, - const VkCopyDescriptorSet* pDescriptorCopies); - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateFramebuffer( - VkDevice device, - const VkFramebufferCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkFramebuffer* pFramebuffer); - -VKAPI_ATTR void VKAPI_CALL vkDestroyFramebuffer( - VkDevice device, - VkFramebuffer framebuffer, - const VkAllocationCallbacks* pAllocator); - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateRenderPass( - VkDevice device, - const VkRenderPassCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkRenderPass* pRenderPass); - -VKAPI_ATTR void VKAPI_CALL vkDestroyRenderPass( - VkDevice device, - VkRenderPass renderPass, - const VkAllocationCallbacks* pAllocator); - -VKAPI_ATTR void VKAPI_CALL vkGetRenderAreaGranularity( - VkDevice device, - VkRenderPass renderPass, - VkExtent2D* pGranularity); - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateCommandPool( - VkDevice device, - const VkCommandPoolCreateInfo* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkCommandPool* pCommandPool); - -VKAPI_ATTR void VKAPI_CALL vkDestroyCommandPool( - VkDevice device, - VkCommandPool commandPool, - const VkAllocationCallbacks* pAllocator); - -VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandPool( - VkDevice device, - VkCommandPool commandPool, - VkCommandPoolResetFlags flags); - -VKAPI_ATTR VkResult VKAPI_CALL vkAllocateCommandBuffers( - VkDevice device, - const VkCommandBufferAllocateInfo* pAllocateInfo, - VkCommandBuffer* pCommandBuffers); - -VKAPI_ATTR void VKAPI_CALL vkFreeCommandBuffers( - VkDevice device, - VkCommandPool commandPool, - uint32_t commandBufferCount, - const VkCommandBuffer* pCommandBuffers); - -VKAPI_ATTR VkResult VKAPI_CALL vkBeginCommandBuffer( - VkCommandBuffer commandBuffer, - const VkCommandBufferBeginInfo* pBeginInfo); - -VKAPI_ATTR VkResult VKAPI_CALL vkEndCommandBuffer( - VkCommandBuffer commandBuffer); - -VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandBuffer( - VkCommandBuffer commandBuffer, - VkCommandBufferResetFlags flags); - -VKAPI_ATTR void VKAPI_CALL vkCmdBindPipeline( - VkCommandBuffer commandBuffer, - VkPipelineBindPoint pipelineBindPoint, - VkPipeline pipeline); - -VKAPI_ATTR void VKAPI_CALL vkCmdSetViewport( - VkCommandBuffer commandBuffer, - uint32_t firstViewport, - uint32_t viewportCount, - const VkViewport* pViewports); - -VKAPI_ATTR void VKAPI_CALL vkCmdSetScissor( - VkCommandBuffer commandBuffer, - uint32_t firstScissor, - uint32_t scissorCount, - const VkRect2D* pScissors); - -VKAPI_ATTR void VKAPI_CALL vkCmdSetLineWidth( - VkCommandBuffer commandBuffer, - float lineWidth); - -VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBias( - VkCommandBuffer commandBuffer, - float depthBiasConstantFactor, - float depthBiasClamp, - float depthBiasSlopeFactor); - -VKAPI_ATTR void VKAPI_CALL vkCmdSetBlendConstants( - VkCommandBuffer commandBuffer, - const float blendConstants[4]); - -VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBounds( - VkCommandBuffer commandBuffer, - float minDepthBounds, - float maxDepthBounds); - -VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilCompareMask( - VkCommandBuffer commandBuffer, - VkStencilFaceFlags faceMask, - uint32_t compareMask); - -VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilWriteMask( - VkCommandBuffer commandBuffer, - VkStencilFaceFlags faceMask, - uint32_t writeMask); - -VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilReference( - VkCommandBuffer commandBuffer, - VkStencilFaceFlags faceMask, - uint32_t reference); - -VKAPI_ATTR void VKAPI_CALL vkCmdBindDescriptorSets( - VkCommandBuffer commandBuffer, - VkPipelineBindPoint pipelineBindPoint, - VkPipelineLayout layout, - uint32_t firstSet, - uint32_t descriptorSetCount, - const VkDescriptorSet* pDescriptorSets, - uint32_t dynamicOffsetCount, - const uint32_t* pDynamicOffsets); - -VKAPI_ATTR void VKAPI_CALL vkCmdBindIndexBuffer( - VkCommandBuffer commandBuffer, - VkBuffer buffer, - VkDeviceSize offset, - VkIndexType indexType); - -VKAPI_ATTR void VKAPI_CALL vkCmdBindVertexBuffers( - VkCommandBuffer commandBuffer, - uint32_t firstBinding, - uint32_t bindingCount, - const VkBuffer* pBuffers, - const VkDeviceSize* pOffsets); - -VKAPI_ATTR void VKAPI_CALL vkCmdDraw( - VkCommandBuffer commandBuffer, - uint32_t vertexCount, - uint32_t instanceCount, - uint32_t firstVertex, - uint32_t firstInstance); - -VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexed( - VkCommandBuffer commandBuffer, - uint32_t indexCount, - uint32_t instanceCount, - uint32_t firstIndex, - int32_t vertexOffset, - uint32_t firstInstance); - -VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirect( - VkCommandBuffer commandBuffer, - VkBuffer buffer, - VkDeviceSize offset, - uint32_t drawCount, - uint32_t stride); - -VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexedIndirect( - VkCommandBuffer commandBuffer, - VkBuffer buffer, - VkDeviceSize offset, - uint32_t drawCount, - uint32_t stride); - -VKAPI_ATTR void VKAPI_CALL vkCmdDispatch( - VkCommandBuffer commandBuffer, - uint32_t groupCountX, - uint32_t groupCountY, - uint32_t groupCountZ); - -VKAPI_ATTR void VKAPI_CALL vkCmdDispatchIndirect( - VkCommandBuffer commandBuffer, - VkBuffer buffer, - VkDeviceSize offset); - -VKAPI_ATTR void VKAPI_CALL vkCmdCopyBuffer( - VkCommandBuffer commandBuffer, - VkBuffer srcBuffer, - VkBuffer dstBuffer, - uint32_t regionCount, - const VkBufferCopy* pRegions); - -VKAPI_ATTR void VKAPI_CALL vkCmdCopyImage( - VkCommandBuffer commandBuffer, - VkImage srcImage, - VkImageLayout srcImageLayout, - VkImage dstImage, - VkImageLayout dstImageLayout, - uint32_t regionCount, - const VkImageCopy* pRegions); - -VKAPI_ATTR void VKAPI_CALL vkCmdBlitImage( - VkCommandBuffer commandBuffer, - VkImage srcImage, - VkImageLayout srcImageLayout, - VkImage dstImage, - VkImageLayout dstImageLayout, - uint32_t regionCount, - const VkImageBlit* pRegions, - VkFilter filter); - -VKAPI_ATTR void VKAPI_CALL vkCmdCopyBufferToImage( - VkCommandBuffer commandBuffer, - VkBuffer srcBuffer, - VkImage dstImage, - VkImageLayout dstImageLayout, - uint32_t regionCount, - const VkBufferImageCopy* pRegions); - -VKAPI_ATTR void VKAPI_CALL vkCmdCopyImageToBuffer( - VkCommandBuffer commandBuffer, - VkImage srcImage, - VkImageLayout srcImageLayout, - VkBuffer dstBuffer, - uint32_t regionCount, - const VkBufferImageCopy* pRegions); - -VKAPI_ATTR void VKAPI_CALL vkCmdUpdateBuffer( - VkCommandBuffer commandBuffer, - VkBuffer dstBuffer, - VkDeviceSize dstOffset, - VkDeviceSize dataSize, - const void* pData); - -VKAPI_ATTR void VKAPI_CALL vkCmdFillBuffer( - VkCommandBuffer commandBuffer, - VkBuffer dstBuffer, - VkDeviceSize dstOffset, - VkDeviceSize size, - uint32_t data); - -VKAPI_ATTR void VKAPI_CALL vkCmdClearColorImage( - VkCommandBuffer commandBuffer, - VkImage image, - VkImageLayout imageLayout, - const VkClearColorValue* pColor, - uint32_t rangeCount, - const VkImageSubresourceRange* pRanges); - -VKAPI_ATTR void VKAPI_CALL vkCmdClearDepthStencilImage( - VkCommandBuffer commandBuffer, - VkImage image, - VkImageLayout imageLayout, - const VkClearDepthStencilValue* pDepthStencil, - uint32_t rangeCount, - const VkImageSubresourceRange* pRanges); - -VKAPI_ATTR void VKAPI_CALL vkCmdClearAttachments( - VkCommandBuffer commandBuffer, - uint32_t attachmentCount, - const VkClearAttachment* pAttachments, - uint32_t rectCount, - const VkClearRect* pRects); - -VKAPI_ATTR void VKAPI_CALL vkCmdResolveImage( - VkCommandBuffer commandBuffer, - VkImage srcImage, - VkImageLayout srcImageLayout, - VkImage dstImage, - VkImageLayout dstImageLayout, - uint32_t regionCount, - const VkImageResolve* pRegions); - -VKAPI_ATTR void VKAPI_CALL vkCmdSetEvent( - VkCommandBuffer commandBuffer, - VkEvent event, - VkPipelineStageFlags stageMask); - -VKAPI_ATTR void VKAPI_CALL vkCmdResetEvent( - VkCommandBuffer commandBuffer, - VkEvent event, - VkPipelineStageFlags stageMask); - -VKAPI_ATTR void VKAPI_CALL vkCmdWaitEvents( - VkCommandBuffer commandBuffer, - uint32_t eventCount, - const VkEvent* pEvents, - VkPipelineStageFlags srcStageMask, - VkPipelineStageFlags dstStageMask, - uint32_t memoryBarrierCount, - const VkMemoryBarrier* pMemoryBarriers, - uint32_t bufferMemoryBarrierCount, - const VkBufferMemoryBarrier* pBufferMemoryBarriers, - uint32_t imageMemoryBarrierCount, - const VkImageMemoryBarrier* pImageMemoryBarriers); - -VKAPI_ATTR void VKAPI_CALL vkCmdPipelineBarrier( - VkCommandBuffer commandBuffer, - VkPipelineStageFlags srcStageMask, - VkPipelineStageFlags dstStageMask, - VkDependencyFlags dependencyFlags, - uint32_t memoryBarrierCount, - const VkMemoryBarrier* pMemoryBarriers, - uint32_t bufferMemoryBarrierCount, - const VkBufferMemoryBarrier* pBufferMemoryBarriers, - uint32_t imageMemoryBarrierCount, - const VkImageMemoryBarrier* pImageMemoryBarriers); - -VKAPI_ATTR void VKAPI_CALL vkCmdBeginQuery( - VkCommandBuffer commandBuffer, - VkQueryPool queryPool, - uint32_t query, - VkQueryControlFlags flags); - -VKAPI_ATTR void VKAPI_CALL vkCmdEndQuery( - VkCommandBuffer commandBuffer, - VkQueryPool queryPool, - uint32_t query); - -VKAPI_ATTR void VKAPI_CALL vkCmdResetQueryPool( - VkCommandBuffer commandBuffer, - VkQueryPool queryPool, - uint32_t firstQuery, - uint32_t queryCount); - -VKAPI_ATTR void VKAPI_CALL vkCmdWriteTimestamp( - VkCommandBuffer commandBuffer, - VkPipelineStageFlagBits pipelineStage, - VkQueryPool queryPool, - uint32_t query); - -VKAPI_ATTR void VKAPI_CALL vkCmdCopyQueryPoolResults( - VkCommandBuffer commandBuffer, - VkQueryPool queryPool, - uint32_t firstQuery, - uint32_t queryCount, - VkBuffer dstBuffer, - VkDeviceSize dstOffset, - VkDeviceSize stride, - VkQueryResultFlags flags); - -VKAPI_ATTR void VKAPI_CALL vkCmdPushConstants( - VkCommandBuffer commandBuffer, - VkPipelineLayout layout, - VkShaderStageFlags stageFlags, - uint32_t offset, - uint32_t size, - const void* pValues); - -VKAPI_ATTR void VKAPI_CALL vkCmdBeginRenderPass( - VkCommandBuffer commandBuffer, - const VkRenderPassBeginInfo* pRenderPassBegin, - VkSubpassContents contents); - -VKAPI_ATTR void VKAPI_CALL vkCmdNextSubpass( - VkCommandBuffer commandBuffer, - VkSubpassContents contents); - -VKAPI_ATTR void VKAPI_CALL vkCmdEndRenderPass( - VkCommandBuffer commandBuffer); - -VKAPI_ATTR void VKAPI_CALL vkCmdExecuteCommands( - VkCommandBuffer commandBuffer, - uint32_t commandBufferCount, - const VkCommandBuffer* pCommandBuffers); -#endif - -#define VK_KHR_surface 1 -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSurfaceKHR) - -#define VK_KHR_SURFACE_SPEC_VERSION 25 -#define VK_KHR_SURFACE_EXTENSION_NAME "VK_KHR_surface" -#define VK_COLORSPACE_SRGB_NONLINEAR_KHR VK_COLOR_SPACE_SRGB_NONLINEAR_KHR - - -typedef enum VkColorSpaceKHR { - VK_COLOR_SPACE_SRGB_NONLINEAR_KHR = 0, - VK_COLOR_SPACE_DISPLAY_P3_NONLINEAR_EXT = 1000104001, - VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT = 1000104002, - VK_COLOR_SPACE_DCI_P3_LINEAR_EXT = 1000104003, - VK_COLOR_SPACE_DCI_P3_NONLINEAR_EXT = 1000104004, - VK_COLOR_SPACE_BT709_LINEAR_EXT = 1000104005, - VK_COLOR_SPACE_BT709_NONLINEAR_EXT = 1000104006, - VK_COLOR_SPACE_BT2020_LINEAR_EXT = 1000104007, - VK_COLOR_SPACE_HDR10_ST2084_EXT = 1000104008, - VK_COLOR_SPACE_DOLBYVISION_EXT = 1000104009, - VK_COLOR_SPACE_HDR10_HLG_EXT = 1000104010, - VK_COLOR_SPACE_ADOBERGB_LINEAR_EXT = 1000104011, - VK_COLOR_SPACE_ADOBERGB_NONLINEAR_EXT = 1000104012, - VK_COLOR_SPACE_PASS_THROUGH_EXT = 1000104013, - VK_COLOR_SPACE_BEGIN_RANGE_KHR = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR, - VK_COLOR_SPACE_END_RANGE_KHR = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR, - VK_COLOR_SPACE_RANGE_SIZE_KHR = (VK_COLOR_SPACE_SRGB_NONLINEAR_KHR - VK_COLOR_SPACE_SRGB_NONLINEAR_KHR + 1), - VK_COLOR_SPACE_MAX_ENUM_KHR = 0x7FFFFFFF -} VkColorSpaceKHR; - -typedef enum VkPresentModeKHR { - VK_PRESENT_MODE_IMMEDIATE_KHR = 0, - VK_PRESENT_MODE_MAILBOX_KHR = 1, - VK_PRESENT_MODE_FIFO_KHR = 2, - VK_PRESENT_MODE_FIFO_RELAXED_KHR = 3, - VK_PRESENT_MODE_SHARED_DEMAND_REFRESH_KHR = 1000111000, - VK_PRESENT_MODE_SHARED_CONTINUOUS_REFRESH_KHR = 1000111001, - VK_PRESENT_MODE_BEGIN_RANGE_KHR = VK_PRESENT_MODE_IMMEDIATE_KHR, - VK_PRESENT_MODE_END_RANGE_KHR = VK_PRESENT_MODE_FIFO_RELAXED_KHR, - VK_PRESENT_MODE_RANGE_SIZE_KHR = (VK_PRESENT_MODE_FIFO_RELAXED_KHR - VK_PRESENT_MODE_IMMEDIATE_KHR + 1), - VK_PRESENT_MODE_MAX_ENUM_KHR = 0x7FFFFFFF -} VkPresentModeKHR; - - -typedef enum VkSurfaceTransformFlagBitsKHR { - VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR = 0x00000001, - VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR = 0x00000002, - VK_SURFACE_TRANSFORM_ROTATE_180_BIT_KHR = 0x00000004, - VK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR = 0x00000008, - VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_BIT_KHR = 0x00000010, - VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_90_BIT_KHR = 0x00000020, - VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_180_BIT_KHR = 0x00000040, - VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_270_BIT_KHR = 0x00000080, - VK_SURFACE_TRANSFORM_INHERIT_BIT_KHR = 0x00000100, - VK_SURFACE_TRANSFORM_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF -} VkSurfaceTransformFlagBitsKHR; -typedef VkFlags VkSurfaceTransformFlagsKHR; - -typedef enum VkCompositeAlphaFlagBitsKHR { - VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR = 0x00000001, - VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR = 0x00000002, - VK_COMPOSITE_ALPHA_POST_MULTIPLIED_BIT_KHR = 0x00000004, - VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR = 0x00000008, - VK_COMPOSITE_ALPHA_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF -} VkCompositeAlphaFlagBitsKHR; -typedef VkFlags VkCompositeAlphaFlagsKHR; - -typedef struct VkSurfaceCapabilitiesKHR { - uint32_t minImageCount; - uint32_t maxImageCount; - VkExtent2D currentExtent; - VkExtent2D minImageExtent; - VkExtent2D maxImageExtent; - uint32_t maxImageArrayLayers; - VkSurfaceTransformFlagsKHR supportedTransforms; - VkSurfaceTransformFlagBitsKHR currentTransform; - VkCompositeAlphaFlagsKHR supportedCompositeAlpha; - VkImageUsageFlags supportedUsageFlags; -} VkSurfaceCapabilitiesKHR; - -typedef struct VkSurfaceFormatKHR { - VkFormat format; - VkColorSpaceKHR colorSpace; -} VkSurfaceFormatKHR; - - -typedef void (VKAPI_PTR *PFN_vkDestroySurfaceKHR)(VkInstance instance, VkSurfaceKHR surface, const VkAllocationCallbacks* pAllocator); -typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfaceSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, VkSurfaceKHR surface, VkBool32* pSupported); -typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR* pSurfaceCapabilities); -typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfaceFormatsKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t* pSurfaceFormatCount, VkSurfaceFormatKHR* pSurfaceFormats); -typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfacePresentModesKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t* pPresentModeCount, VkPresentModeKHR* pPresentModes); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR void VKAPI_CALL vkDestroySurfaceKHR( - VkInstance instance, - VkSurfaceKHR surface, - const VkAllocationCallbacks* pAllocator); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceSupportKHR( - VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex, - VkSurfaceKHR surface, - VkBool32* pSupported); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilitiesKHR( - VkPhysicalDevice physicalDevice, - VkSurfaceKHR surface, - VkSurfaceCapabilitiesKHR* pSurfaceCapabilities); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormatsKHR( - VkPhysicalDevice physicalDevice, - VkSurfaceKHR surface, - uint32_t* pSurfaceFormatCount, - VkSurfaceFormatKHR* pSurfaceFormats); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModesKHR( - VkPhysicalDevice physicalDevice, - VkSurfaceKHR surface, - uint32_t* pPresentModeCount, - VkPresentModeKHR* pPresentModes); -#endif - -#define VK_KHR_swapchain 1 -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSwapchainKHR) - -#define VK_KHR_SWAPCHAIN_SPEC_VERSION 68 -#define VK_KHR_SWAPCHAIN_EXTENSION_NAME "VK_KHR_swapchain" - - -typedef enum VkSwapchainCreateFlagBitsKHR { - VK_SWAPCHAIN_CREATE_BIND_SFR_BIT_KHX = 0x00000001, - VK_SWAPCHAIN_CREATE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF -} VkSwapchainCreateFlagBitsKHR; -typedef VkFlags VkSwapchainCreateFlagsKHR; - -typedef struct VkSwapchainCreateInfoKHR { - VkStructureType sType; - const void* pNext; - VkSwapchainCreateFlagsKHR flags; - VkSurfaceKHR surface; - uint32_t minImageCount; - VkFormat imageFormat; - VkColorSpaceKHR imageColorSpace; - VkExtent2D imageExtent; - uint32_t imageArrayLayers; - VkImageUsageFlags imageUsage; - VkSharingMode imageSharingMode; - uint32_t queueFamilyIndexCount; - const uint32_t* pQueueFamilyIndices; - VkSurfaceTransformFlagBitsKHR preTransform; - VkCompositeAlphaFlagBitsKHR compositeAlpha; - VkPresentModeKHR presentMode; - VkBool32 clipped; - VkSwapchainKHR oldSwapchain; -} VkSwapchainCreateInfoKHR; - -typedef struct VkPresentInfoKHR { - VkStructureType sType; - const void* pNext; - uint32_t waitSemaphoreCount; - const VkSemaphore* pWaitSemaphores; - uint32_t swapchainCount; - const VkSwapchainKHR* pSwapchains; - const uint32_t* pImageIndices; - VkResult* pResults; -} VkPresentInfoKHR; - - -typedef VkResult (VKAPI_PTR *PFN_vkCreateSwapchainKHR)(VkDevice device, const VkSwapchainCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSwapchainKHR* pSwapchain); -typedef void (VKAPI_PTR *PFN_vkDestroySwapchainKHR)(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks* pAllocator); -typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainImagesKHR)(VkDevice device, VkSwapchainKHR swapchain, uint32_t* pSwapchainImageCount, VkImage* pSwapchainImages); -typedef VkResult (VKAPI_PTR *PFN_vkAcquireNextImageKHR)(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, VkSemaphore semaphore, VkFence fence, uint32_t* pImageIndex); -typedef VkResult (VKAPI_PTR *PFN_vkQueuePresentKHR)(VkQueue queue, const VkPresentInfoKHR* pPresentInfo); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR( - VkDevice device, - const VkSwapchainCreateInfoKHR* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSwapchainKHR* pSwapchain); - -VKAPI_ATTR void VKAPI_CALL vkDestroySwapchainKHR( - VkDevice device, - VkSwapchainKHR swapchain, - const VkAllocationCallbacks* pAllocator); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR( - VkDevice device, - VkSwapchainKHR swapchain, - uint32_t* pSwapchainImageCount, - VkImage* pSwapchainImages); - -VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImageKHR( - VkDevice device, - VkSwapchainKHR swapchain, - uint64_t timeout, - VkSemaphore semaphore, - VkFence fence, - uint32_t* pImageIndex); - -VKAPI_ATTR VkResult VKAPI_CALL vkQueuePresentKHR( - VkQueue queue, - const VkPresentInfoKHR* pPresentInfo); -#endif - -#define VK_KHR_display 1 -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDisplayKHR) -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDisplayModeKHR) - -#define VK_KHR_DISPLAY_SPEC_VERSION 21 -#define VK_KHR_DISPLAY_EXTENSION_NAME "VK_KHR_display" - - -typedef enum VkDisplayPlaneAlphaFlagBitsKHR { - VK_DISPLAY_PLANE_ALPHA_OPAQUE_BIT_KHR = 0x00000001, - VK_DISPLAY_PLANE_ALPHA_GLOBAL_BIT_KHR = 0x00000002, - VK_DISPLAY_PLANE_ALPHA_PER_PIXEL_BIT_KHR = 0x00000004, - VK_DISPLAY_PLANE_ALPHA_PER_PIXEL_PREMULTIPLIED_BIT_KHR = 0x00000008, - VK_DISPLAY_PLANE_ALPHA_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF -} VkDisplayPlaneAlphaFlagBitsKHR; -typedef VkFlags VkDisplayPlaneAlphaFlagsKHR; -typedef VkFlags VkDisplayModeCreateFlagsKHR; -typedef VkFlags VkDisplaySurfaceCreateFlagsKHR; - -typedef struct VkDisplayPropertiesKHR { - VkDisplayKHR display; - const char* displayName; - VkExtent2D physicalDimensions; - VkExtent2D physicalResolution; - VkSurfaceTransformFlagsKHR supportedTransforms; - VkBool32 planeReorderPossible; - VkBool32 persistentContent; -} VkDisplayPropertiesKHR; - -typedef struct VkDisplayModeParametersKHR { - VkExtent2D visibleRegion; - uint32_t refreshRate; -} VkDisplayModeParametersKHR; - -typedef struct VkDisplayModePropertiesKHR { - VkDisplayModeKHR displayMode; - VkDisplayModeParametersKHR parameters; -} VkDisplayModePropertiesKHR; - -typedef struct VkDisplayModeCreateInfoKHR { - VkStructureType sType; - const void* pNext; - VkDisplayModeCreateFlagsKHR flags; - VkDisplayModeParametersKHR parameters; -} VkDisplayModeCreateInfoKHR; - -typedef struct VkDisplayPlaneCapabilitiesKHR { - VkDisplayPlaneAlphaFlagsKHR supportedAlpha; - VkOffset2D minSrcPosition; - VkOffset2D maxSrcPosition; - VkExtent2D minSrcExtent; - VkExtent2D maxSrcExtent; - VkOffset2D minDstPosition; - VkOffset2D maxDstPosition; - VkExtent2D minDstExtent; - VkExtent2D maxDstExtent; -} VkDisplayPlaneCapabilitiesKHR; - -typedef struct VkDisplayPlanePropertiesKHR { - VkDisplayKHR currentDisplay; - uint32_t currentStackIndex; -} VkDisplayPlanePropertiesKHR; - -typedef struct VkDisplaySurfaceCreateInfoKHR { - VkStructureType sType; - const void* pNext; - VkDisplaySurfaceCreateFlagsKHR flags; - VkDisplayModeKHR displayMode; - uint32_t planeIndex; - uint32_t planeStackIndex; - VkSurfaceTransformFlagBitsKHR transform; - float globalAlpha; - VkDisplayPlaneAlphaFlagBitsKHR alphaMode; - VkExtent2D imageExtent; -} VkDisplaySurfaceCreateInfoKHR; - - -typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceDisplayPropertiesKHR)(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkDisplayPropertiesKHR* pProperties); -typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR)(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkDisplayPlanePropertiesKHR* pProperties); -typedef VkResult (VKAPI_PTR *PFN_vkGetDisplayPlaneSupportedDisplaysKHR)(VkPhysicalDevice physicalDevice, uint32_t planeIndex, uint32_t* pDisplayCount, VkDisplayKHR* pDisplays); -typedef VkResult (VKAPI_PTR *PFN_vkGetDisplayModePropertiesKHR)(VkPhysicalDevice physicalDevice, VkDisplayKHR display, uint32_t* pPropertyCount, VkDisplayModePropertiesKHR* pProperties); -typedef VkResult (VKAPI_PTR *PFN_vkCreateDisplayModeKHR)(VkPhysicalDevice physicalDevice, VkDisplayKHR display, const VkDisplayModeCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDisplayModeKHR* pMode); -typedef VkResult (VKAPI_PTR *PFN_vkGetDisplayPlaneCapabilitiesKHR)(VkPhysicalDevice physicalDevice, VkDisplayModeKHR mode, uint32_t planeIndex, VkDisplayPlaneCapabilitiesKHR* pCapabilities); -typedef VkResult (VKAPI_PTR *PFN_vkCreateDisplayPlaneSurfaceKHR)(VkInstance instance, const VkDisplaySurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceDisplayPropertiesKHR( - VkPhysicalDevice physicalDevice, - uint32_t* pPropertyCount, - VkDisplayPropertiesKHR* pProperties); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceDisplayPlanePropertiesKHR( - VkPhysicalDevice physicalDevice, - uint32_t* pPropertyCount, - VkDisplayPlanePropertiesKHR* pProperties); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayPlaneSupportedDisplaysKHR( - VkPhysicalDevice physicalDevice, - uint32_t planeIndex, - uint32_t* pDisplayCount, - VkDisplayKHR* pDisplays); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayModePropertiesKHR( - VkPhysicalDevice physicalDevice, - VkDisplayKHR display, - uint32_t* pPropertyCount, - VkDisplayModePropertiesKHR* pProperties); - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayModeKHR( - VkPhysicalDevice physicalDevice, - VkDisplayKHR display, - const VkDisplayModeCreateInfoKHR* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkDisplayModeKHR* pMode); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayPlaneCapabilitiesKHR( - VkPhysicalDevice physicalDevice, - VkDisplayModeKHR mode, - uint32_t planeIndex, - VkDisplayPlaneCapabilitiesKHR* pCapabilities); - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayPlaneSurfaceKHR( - VkInstance instance, - const VkDisplaySurfaceCreateInfoKHR* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSurfaceKHR* pSurface); -#endif - -#define VK_KHR_display_swapchain 1 -#define VK_KHR_DISPLAY_SWAPCHAIN_SPEC_VERSION 9 -#define VK_KHR_DISPLAY_SWAPCHAIN_EXTENSION_NAME "VK_KHR_display_swapchain" - -typedef struct VkDisplayPresentInfoKHR { - VkStructureType sType; - const void* pNext; - VkRect2D srcRect; - VkRect2D dstRect; - VkBool32 persistent; -} VkDisplayPresentInfoKHR; - - -typedef VkResult (VKAPI_PTR *PFN_vkCreateSharedSwapchainsKHR)(VkDevice device, uint32_t swapchainCount, const VkSwapchainCreateInfoKHR* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkSwapchainKHR* pSwapchains); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkCreateSharedSwapchainsKHR( - VkDevice device, - uint32_t swapchainCount, - const VkSwapchainCreateInfoKHR* pCreateInfos, - const VkAllocationCallbacks* pAllocator, - VkSwapchainKHR* pSwapchains); -#endif - -#ifdef VK_USE_PLATFORM_XLIB_KHR -#define VK_KHR_xlib_surface 1 -#include - -#define VK_KHR_XLIB_SURFACE_SPEC_VERSION 6 -#define VK_KHR_XLIB_SURFACE_EXTENSION_NAME "VK_KHR_xlib_surface" - -typedef VkFlags VkXlibSurfaceCreateFlagsKHR; - -typedef struct VkXlibSurfaceCreateInfoKHR { - VkStructureType sType; - const void* pNext; - VkXlibSurfaceCreateFlagsKHR flags; - Display* dpy; - Window window; -} VkXlibSurfaceCreateInfoKHR; - - -typedef VkResult (VKAPI_PTR *PFN_vkCreateXlibSurfaceKHR)(VkInstance instance, const VkXlibSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); -typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, Display* dpy, VisualID visualID); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkCreateXlibSurfaceKHR( - VkInstance instance, - const VkXlibSurfaceCreateInfoKHR* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSurfaceKHR* pSurface); - -VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXlibPresentationSupportKHR( - VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex, - Display* dpy, - VisualID visualID); -#endif -#endif /* VK_USE_PLATFORM_XLIB_KHR */ - -#ifdef VK_USE_PLATFORM_XCB_KHR -#define VK_KHR_xcb_surface 1 -#include - -#define VK_KHR_XCB_SURFACE_SPEC_VERSION 6 -#define VK_KHR_XCB_SURFACE_EXTENSION_NAME "VK_KHR_xcb_surface" - -typedef VkFlags VkXcbSurfaceCreateFlagsKHR; - -typedef struct VkXcbSurfaceCreateInfoKHR { - VkStructureType sType; - const void* pNext; - VkXcbSurfaceCreateFlagsKHR flags; - xcb_connection_t* connection; - xcb_window_t window; -} VkXcbSurfaceCreateInfoKHR; - - -typedef VkResult (VKAPI_PTR *PFN_vkCreateXcbSurfaceKHR)(VkInstance instance, const VkXcbSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); -typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, xcb_connection_t* connection, xcb_visualid_t visual_id); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkCreateXcbSurfaceKHR( - VkInstance instance, - const VkXcbSurfaceCreateInfoKHR* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSurfaceKHR* pSurface); - -VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXcbPresentationSupportKHR( - VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex, - xcb_connection_t* connection, - xcb_visualid_t visual_id); -#endif -#endif /* VK_USE_PLATFORM_XCB_KHR */ - -#ifdef VK_USE_PLATFORM_WAYLAND_KHR -#define VK_KHR_wayland_surface 1 -#include - -#define VK_KHR_WAYLAND_SURFACE_SPEC_VERSION 6 -#define VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME "VK_KHR_wayland_surface" - -typedef VkFlags VkWaylandSurfaceCreateFlagsKHR; - -typedef struct VkWaylandSurfaceCreateInfoKHR { - VkStructureType sType; - const void* pNext; - VkWaylandSurfaceCreateFlagsKHR flags; - struct wl_display* display; - struct wl_surface* surface; -} VkWaylandSurfaceCreateInfoKHR; - - -typedef VkResult (VKAPI_PTR *PFN_vkCreateWaylandSurfaceKHR)(VkInstance instance, const VkWaylandSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); -typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, struct wl_display* display); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkCreateWaylandSurfaceKHR( - VkInstance instance, - const VkWaylandSurfaceCreateInfoKHR* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSurfaceKHR* pSurface); - -VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWaylandPresentationSupportKHR( - VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex, - struct wl_display* display); -#endif -#endif /* VK_USE_PLATFORM_WAYLAND_KHR */ - -#ifdef VK_USE_PLATFORM_MIR_KHR -#define VK_KHR_mir_surface 1 -#include - -#define VK_KHR_MIR_SURFACE_SPEC_VERSION 4 -#define VK_KHR_MIR_SURFACE_EXTENSION_NAME "VK_KHR_mir_surface" - -typedef VkFlags VkMirSurfaceCreateFlagsKHR; - -typedef struct VkMirSurfaceCreateInfoKHR { - VkStructureType sType; - const void* pNext; - VkMirSurfaceCreateFlagsKHR flags; - MirConnection* connection; - MirSurface* mirSurface; -} VkMirSurfaceCreateInfoKHR; - - -typedef VkResult (VKAPI_PTR *PFN_vkCreateMirSurfaceKHR)(VkInstance instance, const VkMirSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); -typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceMirPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, MirConnection* connection); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkCreateMirSurfaceKHR( - VkInstance instance, - const VkMirSurfaceCreateInfoKHR* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSurfaceKHR* pSurface); - -VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceMirPresentationSupportKHR( - VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex, - MirConnection* connection); -#endif -#endif /* VK_USE_PLATFORM_MIR_KHR */ +#include "vulkan_core.h" #ifdef VK_USE_PLATFORM_ANDROID_KHR -#define VK_KHR_android_surface 1 -#include - -#define VK_KHR_ANDROID_SURFACE_SPEC_VERSION 6 -#define VK_KHR_ANDROID_SURFACE_EXTENSION_NAME "VK_KHR_android_surface" - -typedef VkFlags VkAndroidSurfaceCreateFlagsKHR; - -typedef struct VkAndroidSurfaceCreateInfoKHR { - VkStructureType sType; - const void* pNext; - VkAndroidSurfaceCreateFlagsKHR flags; - ANativeWindow* window; -} VkAndroidSurfaceCreateInfoKHR; - - -typedef VkResult (VKAPI_PTR *PFN_vkCreateAndroidSurfaceKHR)(VkInstance instance, const VkAndroidSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkCreateAndroidSurfaceKHR( - VkInstance instance, - const VkAndroidSurfaceCreateInfoKHR* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSurfaceKHR* pSurface); -#endif -#endif /* VK_USE_PLATFORM_ANDROID_KHR */ - -#ifdef VK_USE_PLATFORM_WIN32_KHR -#define VK_KHR_win32_surface 1 -#include - -#define VK_KHR_WIN32_SURFACE_SPEC_VERSION 6 -#define VK_KHR_WIN32_SURFACE_EXTENSION_NAME "VK_KHR_win32_surface" - -typedef VkFlags VkWin32SurfaceCreateFlagsKHR; - -typedef struct VkWin32SurfaceCreateInfoKHR { - VkStructureType sType; - const void* pNext; - VkWin32SurfaceCreateFlagsKHR flags; - HINSTANCE hinstance; - HWND hwnd; -} VkWin32SurfaceCreateInfoKHR; - - -typedef VkResult (VKAPI_PTR *PFN_vkCreateWin32SurfaceKHR)(VkInstance instance, const VkWin32SurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); -typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkCreateWin32SurfaceKHR( - VkInstance instance, - const VkWin32SurfaceCreateInfoKHR* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSurfaceKHR* pSurface); - -VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWin32PresentationSupportKHR( - VkPhysicalDevice physicalDevice, - uint32_t queueFamilyIndex); -#endif -#endif /* VK_USE_PLATFORM_WIN32_KHR */ - -#define VK_KHR_sampler_mirror_clamp_to_edge 1 -#define VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_SPEC_VERSION 1 -#define VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME "VK_KHR_sampler_mirror_clamp_to_edge" - - -#define VK_KHR_get_physical_device_properties2 1 -#define VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_SPEC_VERSION 1 -#define VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME "VK_KHR_get_physical_device_properties2" - -typedef struct VkPhysicalDeviceFeatures2KHR { - VkStructureType sType; - void* pNext; - VkPhysicalDeviceFeatures features; -} VkPhysicalDeviceFeatures2KHR; - -typedef struct VkPhysicalDeviceProperties2KHR { - VkStructureType sType; - void* pNext; - VkPhysicalDeviceProperties properties; -} VkPhysicalDeviceProperties2KHR; - -typedef struct VkFormatProperties2KHR { - VkStructureType sType; - void* pNext; - VkFormatProperties formatProperties; -} VkFormatProperties2KHR; - -typedef struct VkImageFormatProperties2KHR { - VkStructureType sType; - void* pNext; - VkImageFormatProperties imageFormatProperties; -} VkImageFormatProperties2KHR; - -typedef struct VkPhysicalDeviceImageFormatInfo2KHR { - VkStructureType sType; - const void* pNext; - VkFormat format; - VkImageType type; - VkImageTiling tiling; - VkImageUsageFlags usage; - VkImageCreateFlags flags; -} VkPhysicalDeviceImageFormatInfo2KHR; - -typedef struct VkQueueFamilyProperties2KHR { - VkStructureType sType; - void* pNext; - VkQueueFamilyProperties queueFamilyProperties; -} VkQueueFamilyProperties2KHR; - -typedef struct VkPhysicalDeviceMemoryProperties2KHR { - VkStructureType sType; - void* pNext; - VkPhysicalDeviceMemoryProperties memoryProperties; -} VkPhysicalDeviceMemoryProperties2KHR; - -typedef struct VkSparseImageFormatProperties2KHR { - VkStructureType sType; - void* pNext; - VkSparseImageFormatProperties properties; -} VkSparseImageFormatProperties2KHR; - -typedef struct VkPhysicalDeviceSparseImageFormatInfo2KHR { - VkStructureType sType; - const void* pNext; - VkFormat format; - VkImageType type; - VkSampleCountFlagBits samples; - VkImageUsageFlags usage; - VkImageTiling tiling; -} VkPhysicalDeviceSparseImageFormatInfo2KHR; - - -typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceFeatures2KHR)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures2KHR* pFeatures); -typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceProperties2KHR)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties2KHR* pProperties); -typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceFormatProperties2KHR)(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties2KHR* pFormatProperties); -typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceImageFormatProperties2KHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2KHR* pImageFormatInfo, VkImageFormatProperties2KHR* pImageFormatProperties); -typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceQueueFamilyProperties2KHR)(VkPhysicalDevice physicalDevice, uint32_t* pQueueFamilyPropertyCount, VkQueueFamilyProperties2KHR* pQueueFamilyProperties); -typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceMemoryProperties2KHR)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties2KHR* pMemoryProperties); -typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceSparseImageFormatProperties2KHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSparseImageFormatInfo2KHR* pFormatInfo, uint32_t* pPropertyCount, VkSparseImageFormatProperties2KHR* pProperties); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures2KHR( - VkPhysicalDevice physicalDevice, - VkPhysicalDeviceFeatures2KHR* pFeatures); - -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties2KHR( - VkPhysicalDevice physicalDevice, - VkPhysicalDeviceProperties2KHR* pProperties); - -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties2KHR( - VkPhysicalDevice physicalDevice, - VkFormat format, - VkFormatProperties2KHR* pFormatProperties); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties2KHR( - VkPhysicalDevice physicalDevice, - const VkPhysicalDeviceImageFormatInfo2KHR* pImageFormatInfo, - VkImageFormatProperties2KHR* pImageFormatProperties); - -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties2KHR( - VkPhysicalDevice physicalDevice, - uint32_t* pQueueFamilyPropertyCount, - VkQueueFamilyProperties2KHR* pQueueFamilyProperties); - -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties2KHR( - VkPhysicalDevice physicalDevice, - VkPhysicalDeviceMemoryProperties2KHR* pMemoryProperties); - -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceSparseImageFormatProperties2KHR( - VkPhysicalDevice physicalDevice, - const VkPhysicalDeviceSparseImageFormatInfo2KHR* pFormatInfo, - uint32_t* pPropertyCount, - VkSparseImageFormatProperties2KHR* pProperties); +#include "vulkan_android.h" #endif -#define VK_KHR_shader_draw_parameters 1 -#define VK_KHR_SHADER_DRAW_PARAMETERS_SPEC_VERSION 1 -#define VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME "VK_KHR_shader_draw_parameters" - - -#define VK_KHR_maintenance1 1 -#define VK_KHR_MAINTENANCE1_SPEC_VERSION 1 -#define VK_KHR_MAINTENANCE1_EXTENSION_NAME "VK_KHR_maintenance1" - -typedef VkFlags VkCommandPoolTrimFlagsKHR; - -typedef void (VKAPI_PTR *PFN_vkTrimCommandPoolKHR)(VkDevice device, VkCommandPool commandPool, VkCommandPoolTrimFlagsKHR flags); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR void VKAPI_CALL vkTrimCommandPoolKHR( - VkDevice device, - VkCommandPool commandPool, - VkCommandPoolTrimFlagsKHR flags); -#endif - -#define VK_KHR_push_descriptor 1 -#define VK_KHR_PUSH_DESCRIPTOR_SPEC_VERSION 1 -#define VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME "VK_KHR_push_descriptor" - -typedef struct VkPhysicalDevicePushDescriptorPropertiesKHR { - VkStructureType sType; - void* pNext; - uint32_t maxPushDescriptors; -} VkPhysicalDevicePushDescriptorPropertiesKHR; - - -typedef void (VKAPI_PTR *PFN_vkCmdPushDescriptorSetKHR)(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t set, uint32_t descriptorWriteCount, const VkWriteDescriptorSet* pDescriptorWrites); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR void VKAPI_CALL vkCmdPushDescriptorSetKHR( - VkCommandBuffer commandBuffer, - VkPipelineBindPoint pipelineBindPoint, - VkPipelineLayout layout, - uint32_t set, - uint32_t descriptorWriteCount, - const VkWriteDescriptorSet* pDescriptorWrites); -#endif - -#define VK_KHR_incremental_present 1 -#define VK_KHR_INCREMENTAL_PRESENT_SPEC_VERSION 1 -#define VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME "VK_KHR_incremental_present" - -typedef struct VkRectLayerKHR { - VkOffset2D offset; - VkExtent2D extent; - uint32_t layer; -} VkRectLayerKHR; - -typedef struct VkPresentRegionKHR { - uint32_t rectangleCount; - const VkRectLayerKHR* pRectangles; -} VkPresentRegionKHR; - -typedef struct VkPresentRegionsKHR { - VkStructureType sType; - const void* pNext; - uint32_t swapchainCount; - const VkPresentRegionKHR* pRegions; -} VkPresentRegionsKHR; - - - -#define VK_KHR_descriptor_update_template 1 -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorUpdateTemplateKHR) - -#define VK_KHR_DESCRIPTOR_UPDATE_TEMPLATE_SPEC_VERSION 1 -#define VK_KHR_DESCRIPTOR_UPDATE_TEMPLATE_EXTENSION_NAME "VK_KHR_descriptor_update_template" - - -typedef enum VkDescriptorUpdateTemplateTypeKHR { - VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET_KHR = 0, - VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR = 1, - VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_BEGIN_RANGE_KHR = VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET_KHR, - VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_END_RANGE_KHR = VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR, - VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_RANGE_SIZE_KHR = (VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR - VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET_KHR + 1), - VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_MAX_ENUM_KHR = 0x7FFFFFFF -} VkDescriptorUpdateTemplateTypeKHR; - -typedef VkFlags VkDescriptorUpdateTemplateCreateFlagsKHR; - -typedef struct VkDescriptorUpdateTemplateEntryKHR { - uint32_t dstBinding; - uint32_t dstArrayElement; - uint32_t descriptorCount; - VkDescriptorType descriptorType; - size_t offset; - size_t stride; -} VkDescriptorUpdateTemplateEntryKHR; - -typedef struct VkDescriptorUpdateTemplateCreateInfoKHR { - VkStructureType sType; - void* pNext; - VkDescriptorUpdateTemplateCreateFlagsKHR flags; - uint32_t descriptorUpdateEntryCount; - const VkDescriptorUpdateTemplateEntryKHR* pDescriptorUpdateEntries; - VkDescriptorUpdateTemplateTypeKHR templateType; - VkDescriptorSetLayout descriptorSetLayout; - VkPipelineBindPoint pipelineBindPoint; - VkPipelineLayout pipelineLayout; - uint32_t set; -} VkDescriptorUpdateTemplateCreateInfoKHR; - - -typedef VkResult (VKAPI_PTR *PFN_vkCreateDescriptorUpdateTemplateKHR)(VkDevice device, const VkDescriptorUpdateTemplateCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDescriptorUpdateTemplateKHR* pDescriptorUpdateTemplate); -typedef void (VKAPI_PTR *PFN_vkDestroyDescriptorUpdateTemplateKHR)(VkDevice device, VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate, const VkAllocationCallbacks* pAllocator); -typedef void (VKAPI_PTR *PFN_vkUpdateDescriptorSetWithTemplateKHR)(VkDevice device, VkDescriptorSet descriptorSet, VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate, const void* pData); -typedef void (VKAPI_PTR *PFN_vkCmdPushDescriptorSetWithTemplateKHR)(VkCommandBuffer commandBuffer, VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate, VkPipelineLayout layout, uint32_t set, const void* pData); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorUpdateTemplateKHR( - VkDevice device, - const VkDescriptorUpdateTemplateCreateInfoKHR* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkDescriptorUpdateTemplateKHR* pDescriptorUpdateTemplate); - -VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorUpdateTemplateKHR( - VkDevice device, - VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate, - const VkAllocationCallbacks* pAllocator); - -VKAPI_ATTR void VKAPI_CALL vkUpdateDescriptorSetWithTemplateKHR( - VkDevice device, - VkDescriptorSet descriptorSet, - VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate, - const void* pData); - -VKAPI_ATTR void VKAPI_CALL vkCmdPushDescriptorSetWithTemplateKHR( - VkCommandBuffer commandBuffer, - VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate, - VkPipelineLayout layout, - uint32_t set, - const void* pData); -#endif - -#define VK_KHR_shared_presentable_image 1 -#define VK_KHR_SHARED_PRESENTABLE_IMAGE_SPEC_VERSION 1 -#define VK_KHR_SHARED_PRESENTABLE_IMAGE_EXTENSION_NAME "VK_KHR_shared_presentable_image" - -typedef struct VkSharedPresentSurfaceCapabilitiesKHR { - VkStructureType sType; - void* pNext; - VkImageUsageFlags sharedPresentSupportedUsageFlags; -} VkSharedPresentSurfaceCapabilitiesKHR; - - -typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainStatusKHR)(VkDevice device, VkSwapchainKHR swapchain); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainStatusKHR( - VkDevice device, - VkSwapchainKHR swapchain); -#endif - -#define VK_KHR_get_surface_capabilities2 1 -#define VK_KHR_GET_SURFACE_CAPABILITIES_2_SPEC_VERSION 1 -#define VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME "VK_KHR_get_surface_capabilities2" - -typedef struct VkPhysicalDeviceSurfaceInfo2KHR { - VkStructureType sType; - const void* pNext; - VkSurfaceKHR surface; -} VkPhysicalDeviceSurfaceInfo2KHR; - -typedef struct VkSurfaceCapabilities2KHR { - VkStructureType sType; - void* pNext; - VkSurfaceCapabilitiesKHR surfaceCapabilities; -} VkSurfaceCapabilities2KHR; - -typedef struct VkSurfaceFormat2KHR { - VkStructureType sType; - void* pNext; - VkSurfaceFormatKHR surfaceFormat; -} VkSurfaceFormat2KHR; - - -typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfaceCapabilities2KHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, VkSurfaceCapabilities2KHR* pSurfaceCapabilities); -typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfaceFormats2KHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, uint32_t* pSurfaceFormatCount, VkSurfaceFormat2KHR* pSurfaceFormats); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilities2KHR( - VkPhysicalDevice physicalDevice, - const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, - VkSurfaceCapabilities2KHR* pSurfaceCapabilities); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormats2KHR( - VkPhysicalDevice physicalDevice, - const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, - uint32_t* pSurfaceFormatCount, - VkSurfaceFormat2KHR* pSurfaceFormats); -#endif - -#define VK_EXT_debug_report 1 -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDebugReportCallbackEXT) - -#define VK_EXT_DEBUG_REPORT_SPEC_VERSION 8 -#define VK_EXT_DEBUG_REPORT_EXTENSION_NAME "VK_EXT_debug_report" -#define VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT -#define VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_EXT VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT_EXT - - -typedef enum VkDebugReportObjectTypeEXT { - VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT = 0, - VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT = 1, - VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT = 2, - VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT = 3, - VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT = 4, - VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT = 5, - VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT = 6, - VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT = 7, - VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT = 8, - VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT = 9, - VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT = 10, - VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT = 11, - VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT = 12, - VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT = 13, - VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT = 14, - VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT = 15, - VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT = 16, - VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT = 17, - VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT = 18, - VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT = 19, - VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT_EXT = 20, - VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT = 21, - VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT = 22, - VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT = 23, - VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT = 24, - VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT = 25, - VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT = 26, - VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT = 27, - VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT_EXT = 28, - VK_DEBUG_REPORT_OBJECT_TYPE_DISPLAY_KHR_EXT = 29, - VK_DEBUG_REPORT_OBJECT_TYPE_DISPLAY_MODE_KHR_EXT = 30, - VK_DEBUG_REPORT_OBJECT_TYPE_OBJECT_TABLE_NVX_EXT = 31, - VK_DEBUG_REPORT_OBJECT_TYPE_INDIRECT_COMMANDS_LAYOUT_NVX_EXT = 32, - VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_KHR_EXT = 1000085000, - VK_DEBUG_REPORT_OBJECT_TYPE_BEGIN_RANGE_EXT = VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_END_RANGE_EXT = VK_DEBUG_REPORT_OBJECT_TYPE_INDIRECT_COMMANDS_LAYOUT_NVX_EXT, - VK_DEBUG_REPORT_OBJECT_TYPE_RANGE_SIZE_EXT = (VK_DEBUG_REPORT_OBJECT_TYPE_INDIRECT_COMMANDS_LAYOUT_NVX_EXT - VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT + 1), - VK_DEBUG_REPORT_OBJECT_TYPE_MAX_ENUM_EXT = 0x7FFFFFFF -} VkDebugReportObjectTypeEXT; - - -typedef enum VkDebugReportFlagBitsEXT { - VK_DEBUG_REPORT_INFORMATION_BIT_EXT = 0x00000001, - VK_DEBUG_REPORT_WARNING_BIT_EXT = 0x00000002, - VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT = 0x00000004, - VK_DEBUG_REPORT_ERROR_BIT_EXT = 0x00000008, - VK_DEBUG_REPORT_DEBUG_BIT_EXT = 0x00000010, - VK_DEBUG_REPORT_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF -} VkDebugReportFlagBitsEXT; -typedef VkFlags VkDebugReportFlagsEXT; - -typedef VkBool32 (VKAPI_PTR *PFN_vkDebugReportCallbackEXT)( - VkDebugReportFlagsEXT flags, - VkDebugReportObjectTypeEXT objectType, - uint64_t object, - size_t location, - int32_t messageCode, - const char* pLayerPrefix, - const char* pMessage, - void* pUserData); - - -typedef struct VkDebugReportCallbackCreateInfoEXT { - VkStructureType sType; - const void* pNext; - VkDebugReportFlagsEXT flags; - PFN_vkDebugReportCallbackEXT pfnCallback; - void* pUserData; -} VkDebugReportCallbackCreateInfoEXT; - - -typedef VkResult (VKAPI_PTR *PFN_vkCreateDebugReportCallbackEXT)(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugReportCallbackEXT* pCallback); -typedef void (VKAPI_PTR *PFN_vkDestroyDebugReportCallbackEXT)(VkInstance instance, VkDebugReportCallbackEXT callback, const VkAllocationCallbacks* pAllocator); -typedef void (VKAPI_PTR *PFN_vkDebugReportMessageEXT)(VkInstance instance, VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugReportCallbackEXT( - VkInstance instance, - const VkDebugReportCallbackCreateInfoEXT* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkDebugReportCallbackEXT* pCallback); - -VKAPI_ATTR void VKAPI_CALL vkDestroyDebugReportCallbackEXT( - VkInstance instance, - VkDebugReportCallbackEXT callback, - const VkAllocationCallbacks* pAllocator); - -VKAPI_ATTR void VKAPI_CALL vkDebugReportMessageEXT( - VkInstance instance, - VkDebugReportFlagsEXT flags, - VkDebugReportObjectTypeEXT objectType, - uint64_t object, - size_t location, - int32_t messageCode, - const char* pLayerPrefix, - const char* pMessage); -#endif - -#define VK_NV_glsl_shader 1 -#define VK_NV_GLSL_SHADER_SPEC_VERSION 1 -#define VK_NV_GLSL_SHADER_EXTENSION_NAME "VK_NV_glsl_shader" - - -#define VK_IMG_filter_cubic 1 -#define VK_IMG_FILTER_CUBIC_SPEC_VERSION 1 -#define VK_IMG_FILTER_CUBIC_EXTENSION_NAME "VK_IMG_filter_cubic" - - -#define VK_AMD_rasterization_order 1 -#define VK_AMD_RASTERIZATION_ORDER_SPEC_VERSION 1 -#define VK_AMD_RASTERIZATION_ORDER_EXTENSION_NAME "VK_AMD_rasterization_order" - - -typedef enum VkRasterizationOrderAMD { - VK_RASTERIZATION_ORDER_STRICT_AMD = 0, - VK_RASTERIZATION_ORDER_RELAXED_AMD = 1, - VK_RASTERIZATION_ORDER_BEGIN_RANGE_AMD = VK_RASTERIZATION_ORDER_STRICT_AMD, - VK_RASTERIZATION_ORDER_END_RANGE_AMD = VK_RASTERIZATION_ORDER_RELAXED_AMD, - VK_RASTERIZATION_ORDER_RANGE_SIZE_AMD = (VK_RASTERIZATION_ORDER_RELAXED_AMD - VK_RASTERIZATION_ORDER_STRICT_AMD + 1), - VK_RASTERIZATION_ORDER_MAX_ENUM_AMD = 0x7FFFFFFF -} VkRasterizationOrderAMD; - -typedef struct VkPipelineRasterizationStateRasterizationOrderAMD { - VkStructureType sType; - const void* pNext; - VkRasterizationOrderAMD rasterizationOrder; -} VkPipelineRasterizationStateRasterizationOrderAMD; - - - -#define VK_AMD_shader_trinary_minmax 1 -#define VK_AMD_SHADER_TRINARY_MINMAX_SPEC_VERSION 1 -#define VK_AMD_SHADER_TRINARY_MINMAX_EXTENSION_NAME "VK_AMD_shader_trinary_minmax" - - -#define VK_AMD_shader_explicit_vertex_parameter 1 -#define VK_AMD_SHADER_EXPLICIT_VERTEX_PARAMETER_SPEC_VERSION 1 -#define VK_AMD_SHADER_EXPLICIT_VERTEX_PARAMETER_EXTENSION_NAME "VK_AMD_shader_explicit_vertex_parameter" - - -#define VK_EXT_debug_marker 1 -#define VK_EXT_DEBUG_MARKER_SPEC_VERSION 4 -#define VK_EXT_DEBUG_MARKER_EXTENSION_NAME "VK_EXT_debug_marker" - -typedef struct VkDebugMarkerObjectNameInfoEXT { - VkStructureType sType; - const void* pNext; - VkDebugReportObjectTypeEXT objectType; - uint64_t object; - const char* pObjectName; -} VkDebugMarkerObjectNameInfoEXT; - -typedef struct VkDebugMarkerObjectTagInfoEXT { - VkStructureType sType; - const void* pNext; - VkDebugReportObjectTypeEXT objectType; - uint64_t object; - uint64_t tagName; - size_t tagSize; - const void* pTag; -} VkDebugMarkerObjectTagInfoEXT; - -typedef struct VkDebugMarkerMarkerInfoEXT { - VkStructureType sType; - const void* pNext; - const char* pMarkerName; - float color[4]; -} VkDebugMarkerMarkerInfoEXT; - - -typedef VkResult (VKAPI_PTR *PFN_vkDebugMarkerSetObjectTagEXT)(VkDevice device, VkDebugMarkerObjectTagInfoEXT* pTagInfo); -typedef VkResult (VKAPI_PTR *PFN_vkDebugMarkerSetObjectNameEXT)(VkDevice device, VkDebugMarkerObjectNameInfoEXT* pNameInfo); -typedef void (VKAPI_PTR *PFN_vkCmdDebugMarkerBeginEXT)(VkCommandBuffer commandBuffer, VkDebugMarkerMarkerInfoEXT* pMarkerInfo); -typedef void (VKAPI_PTR *PFN_vkCmdDebugMarkerEndEXT)(VkCommandBuffer commandBuffer); -typedef void (VKAPI_PTR *PFN_vkCmdDebugMarkerInsertEXT)(VkCommandBuffer commandBuffer, VkDebugMarkerMarkerInfoEXT* pMarkerInfo); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkDebugMarkerSetObjectTagEXT( - VkDevice device, - VkDebugMarkerObjectTagInfoEXT* pTagInfo); - -VKAPI_ATTR VkResult VKAPI_CALL vkDebugMarkerSetObjectNameEXT( - VkDevice device, - VkDebugMarkerObjectNameInfoEXT* pNameInfo); - -VKAPI_ATTR void VKAPI_CALL vkCmdDebugMarkerBeginEXT( - VkCommandBuffer commandBuffer, - VkDebugMarkerMarkerInfoEXT* pMarkerInfo); - -VKAPI_ATTR void VKAPI_CALL vkCmdDebugMarkerEndEXT( - VkCommandBuffer commandBuffer); - -VKAPI_ATTR void VKAPI_CALL vkCmdDebugMarkerInsertEXT( - VkCommandBuffer commandBuffer, - VkDebugMarkerMarkerInfoEXT* pMarkerInfo); -#endif - -#define VK_AMD_gcn_shader 1 -#define VK_AMD_GCN_SHADER_SPEC_VERSION 1 -#define VK_AMD_GCN_SHADER_EXTENSION_NAME "VK_AMD_gcn_shader" - - -#define VK_NV_dedicated_allocation 1 -#define VK_NV_DEDICATED_ALLOCATION_SPEC_VERSION 1 -#define VK_NV_DEDICATED_ALLOCATION_EXTENSION_NAME "VK_NV_dedicated_allocation" - -typedef struct VkDedicatedAllocationImageCreateInfoNV { - VkStructureType sType; - const void* pNext; - VkBool32 dedicatedAllocation; -} VkDedicatedAllocationImageCreateInfoNV; - -typedef struct VkDedicatedAllocationBufferCreateInfoNV { - VkStructureType sType; - const void* pNext; - VkBool32 dedicatedAllocation; -} VkDedicatedAllocationBufferCreateInfoNV; - -typedef struct VkDedicatedAllocationMemoryAllocateInfoNV { - VkStructureType sType; - const void* pNext; - VkImage image; - VkBuffer buffer; -} VkDedicatedAllocationMemoryAllocateInfoNV; - - - -#define VK_AMD_draw_indirect_count 1 -#define VK_AMD_DRAW_INDIRECT_COUNT_SPEC_VERSION 1 -#define VK_AMD_DRAW_INDIRECT_COUNT_EXTENSION_NAME "VK_AMD_draw_indirect_count" - -typedef void (VKAPI_PTR *PFN_vkCmdDrawIndirectCountAMD)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride); -typedef void (VKAPI_PTR *PFN_vkCmdDrawIndexedIndirectCountAMD)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirectCountAMD( - VkCommandBuffer commandBuffer, - VkBuffer buffer, - VkDeviceSize offset, - VkBuffer countBuffer, - VkDeviceSize countBufferOffset, - uint32_t maxDrawCount, - uint32_t stride); - -VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexedIndirectCountAMD( - VkCommandBuffer commandBuffer, - VkBuffer buffer, - VkDeviceSize offset, - VkBuffer countBuffer, - VkDeviceSize countBufferOffset, - uint32_t maxDrawCount, - uint32_t stride); -#endif - -#define VK_AMD_negative_viewport_height 1 -#define VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_SPEC_VERSION 1 -#define VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME "VK_AMD_negative_viewport_height" - - -#define VK_AMD_gpu_shader_half_float 1 -#define VK_AMD_GPU_SHADER_HALF_FLOAT_SPEC_VERSION 1 -#define VK_AMD_GPU_SHADER_HALF_FLOAT_EXTENSION_NAME "VK_AMD_gpu_shader_half_float" - - -#define VK_AMD_shader_ballot 1 -#define VK_AMD_SHADER_BALLOT_SPEC_VERSION 1 -#define VK_AMD_SHADER_BALLOT_EXTENSION_NAME "VK_AMD_shader_ballot" - - -#define VK_AMD_texture_gather_bias_lod 1 -#define VK_AMD_TEXTURE_GATHER_BIAS_LOD_SPEC_VERSION 1 -#define VK_AMD_TEXTURE_GATHER_BIAS_LOD_EXTENSION_NAME "VK_AMD_texture_gather_bias_lod" - -typedef struct VkTextureLODGatherFormatPropertiesAMD { - VkStructureType sType; - void* pNext; - VkBool32 supportsTextureGatherLODBiasAMD; -} VkTextureLODGatherFormatPropertiesAMD; - - - -#define VK_KHX_multiview 1 -#define VK_KHX_MULTIVIEW_SPEC_VERSION 1 -#define VK_KHX_MULTIVIEW_EXTENSION_NAME "VK_KHX_multiview" - -typedef struct VkRenderPassMultiviewCreateInfoKHX { - VkStructureType sType; - const void* pNext; - uint32_t subpassCount; - const uint32_t* pViewMasks; - uint32_t dependencyCount; - const int32_t* pViewOffsets; - uint32_t correlationMaskCount; - const uint32_t* pCorrelationMasks; -} VkRenderPassMultiviewCreateInfoKHX; - -typedef struct VkPhysicalDeviceMultiviewFeaturesKHX { - VkStructureType sType; - void* pNext; - VkBool32 multiview; - VkBool32 multiviewGeometryShader; - VkBool32 multiviewTessellationShader; -} VkPhysicalDeviceMultiviewFeaturesKHX; - -typedef struct VkPhysicalDeviceMultiviewPropertiesKHX { - VkStructureType sType; - void* pNext; - uint32_t maxMultiviewViewCount; - uint32_t maxMultiviewInstanceIndex; -} VkPhysicalDeviceMultiviewPropertiesKHX; - - - -#define VK_IMG_format_pvrtc 1 -#define VK_IMG_FORMAT_PVRTC_SPEC_VERSION 1 -#define VK_IMG_FORMAT_PVRTC_EXTENSION_NAME "VK_IMG_format_pvrtc" - - -#define VK_NV_external_memory_capabilities 1 -#define VK_NV_EXTERNAL_MEMORY_CAPABILITIES_SPEC_VERSION 1 -#define VK_NV_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME "VK_NV_external_memory_capabilities" - - -typedef enum VkExternalMemoryHandleTypeFlagBitsNV { - VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT_NV = 0x00000001, - VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT_NV = 0x00000002, - VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_IMAGE_BIT_NV = 0x00000004, - VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_IMAGE_KMT_BIT_NV = 0x00000008, - VK_EXTERNAL_MEMORY_HANDLE_TYPE_FLAG_BITS_MAX_ENUM_NV = 0x7FFFFFFF -} VkExternalMemoryHandleTypeFlagBitsNV; -typedef VkFlags VkExternalMemoryHandleTypeFlagsNV; - -typedef enum VkExternalMemoryFeatureFlagBitsNV { - VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT_NV = 0x00000001, - VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT_NV = 0x00000002, - VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT_NV = 0x00000004, - VK_EXTERNAL_MEMORY_FEATURE_FLAG_BITS_MAX_ENUM_NV = 0x7FFFFFFF -} VkExternalMemoryFeatureFlagBitsNV; -typedef VkFlags VkExternalMemoryFeatureFlagsNV; - -typedef struct VkExternalImageFormatPropertiesNV { - VkImageFormatProperties imageFormatProperties; - VkExternalMemoryFeatureFlagsNV externalMemoryFeatures; - VkExternalMemoryHandleTypeFlagsNV exportFromImportedHandleTypes; - VkExternalMemoryHandleTypeFlagsNV compatibleHandleTypes; -} VkExternalImageFormatPropertiesNV; - - -typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceExternalImageFormatPropertiesNV)(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkExternalMemoryHandleTypeFlagsNV externalHandleType, VkExternalImageFormatPropertiesNV* pExternalImageFormatProperties); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceExternalImageFormatPropertiesNV( - VkPhysicalDevice physicalDevice, - VkFormat format, - VkImageType type, - VkImageTiling tiling, - VkImageUsageFlags usage, - VkImageCreateFlags flags, - VkExternalMemoryHandleTypeFlagsNV externalHandleType, - VkExternalImageFormatPropertiesNV* pExternalImageFormatProperties); -#endif - -#define VK_NV_external_memory 1 -#define VK_NV_EXTERNAL_MEMORY_SPEC_VERSION 1 -#define VK_NV_EXTERNAL_MEMORY_EXTENSION_NAME "VK_NV_external_memory" - -typedef struct VkExternalMemoryImageCreateInfoNV { - VkStructureType sType; - const void* pNext; - VkExternalMemoryHandleTypeFlagsNV handleTypes; -} VkExternalMemoryImageCreateInfoNV; - -typedef struct VkExportMemoryAllocateInfoNV { - VkStructureType sType; - const void* pNext; - VkExternalMemoryHandleTypeFlagsNV handleTypes; -} VkExportMemoryAllocateInfoNV; - - - -#ifdef VK_USE_PLATFORM_WIN32_KHR -#define VK_NV_external_memory_win32 1 -#define VK_NV_EXTERNAL_MEMORY_WIN32_SPEC_VERSION 1 -#define VK_NV_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME "VK_NV_external_memory_win32" - -typedef struct VkImportMemoryWin32HandleInfoNV { - VkStructureType sType; - const void* pNext; - VkExternalMemoryHandleTypeFlagsNV handleType; - HANDLE handle; -} VkImportMemoryWin32HandleInfoNV; - -typedef struct VkExportMemoryWin32HandleInfoNV { - VkStructureType sType; - const void* pNext; - const SECURITY_ATTRIBUTES* pAttributes; - DWORD dwAccess; -} VkExportMemoryWin32HandleInfoNV; - - -typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandleNV)(VkDevice device, VkDeviceMemory memory, VkExternalMemoryHandleTypeFlagsNV handleType, HANDLE* pHandle); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandleNV( - VkDevice device, - VkDeviceMemory memory, - VkExternalMemoryHandleTypeFlagsNV handleType, - HANDLE* pHandle); -#endif -#endif /* VK_USE_PLATFORM_WIN32_KHR */ - -#ifdef VK_USE_PLATFORM_WIN32_KHR -#define VK_NV_win32_keyed_mutex 1 -#define VK_NV_WIN32_KEYED_MUTEX_SPEC_VERSION 1 -#define VK_NV_WIN32_KEYED_MUTEX_EXTENSION_NAME "VK_NV_win32_keyed_mutex" - -typedef struct VkWin32KeyedMutexAcquireReleaseInfoNV { - VkStructureType sType; - const void* pNext; - uint32_t acquireCount; - const VkDeviceMemory* pAcquireSyncs; - const uint64_t* pAcquireKeys; - const uint32_t* pAcquireTimeoutMilliseconds; - uint32_t releaseCount; - const VkDeviceMemory* pReleaseSyncs; - const uint64_t* pReleaseKeys; -} VkWin32KeyedMutexAcquireReleaseInfoNV; - - -#endif /* VK_USE_PLATFORM_WIN32_KHR */ - -#define VK_KHX_device_group 1 -#define VK_MAX_DEVICE_GROUP_SIZE_KHX 32 -#define VK_KHX_DEVICE_GROUP_SPEC_VERSION 1 -#define VK_KHX_DEVICE_GROUP_EXTENSION_NAME "VK_KHX_device_group" - - -typedef enum VkPeerMemoryFeatureFlagBitsKHX { - VK_PEER_MEMORY_FEATURE_COPY_SRC_BIT_KHX = 0x00000001, - VK_PEER_MEMORY_FEATURE_COPY_DST_BIT_KHX = 0x00000002, - VK_PEER_MEMORY_FEATURE_GENERIC_SRC_BIT_KHX = 0x00000004, - VK_PEER_MEMORY_FEATURE_GENERIC_DST_BIT_KHX = 0x00000008, - VK_PEER_MEMORY_FEATURE_FLAG_BITS_MAX_ENUM_KHX = 0x7FFFFFFF -} VkPeerMemoryFeatureFlagBitsKHX; -typedef VkFlags VkPeerMemoryFeatureFlagsKHX; - -typedef enum VkMemoryAllocateFlagBitsKHX { - VK_MEMORY_ALLOCATE_DEVICE_MASK_BIT_KHX = 0x00000001, - VK_MEMORY_ALLOCATE_FLAG_BITS_MAX_ENUM_KHX = 0x7FFFFFFF -} VkMemoryAllocateFlagBitsKHX; -typedef VkFlags VkMemoryAllocateFlagsKHX; - -typedef enum VkDeviceGroupPresentModeFlagBitsKHX { - VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_BIT_KHX = 0x00000001, - VK_DEVICE_GROUP_PRESENT_MODE_REMOTE_BIT_KHX = 0x00000002, - VK_DEVICE_GROUP_PRESENT_MODE_SUM_BIT_KHX = 0x00000004, - VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_MULTI_DEVICE_BIT_KHX = 0x00000008, - VK_DEVICE_GROUP_PRESENT_MODE_FLAG_BITS_MAX_ENUM_KHX = 0x7FFFFFFF -} VkDeviceGroupPresentModeFlagBitsKHX; -typedef VkFlags VkDeviceGroupPresentModeFlagsKHX; - -typedef struct VkMemoryAllocateFlagsInfoKHX { - VkStructureType sType; - const void* pNext; - VkMemoryAllocateFlagsKHX flags; - uint32_t deviceMask; -} VkMemoryAllocateFlagsInfoKHX; - -typedef struct VkBindBufferMemoryInfoKHX { - VkStructureType sType; - const void* pNext; - VkBuffer buffer; - VkDeviceMemory memory; - VkDeviceSize memoryOffset; - uint32_t deviceIndexCount; - const uint32_t* pDeviceIndices; -} VkBindBufferMemoryInfoKHX; - -typedef struct VkBindImageMemoryInfoKHX { - VkStructureType sType; - const void* pNext; - VkImage image; - VkDeviceMemory memory; - VkDeviceSize memoryOffset; - uint32_t deviceIndexCount; - const uint32_t* pDeviceIndices; - uint32_t SFRRectCount; - const VkRect2D* pSFRRects; -} VkBindImageMemoryInfoKHX; - -typedef struct VkDeviceGroupRenderPassBeginInfoKHX { - VkStructureType sType; - const void* pNext; - uint32_t deviceMask; - uint32_t deviceRenderAreaCount; - const VkRect2D* pDeviceRenderAreas; -} VkDeviceGroupRenderPassBeginInfoKHX; - -typedef struct VkDeviceGroupCommandBufferBeginInfoKHX { - VkStructureType sType; - const void* pNext; - uint32_t deviceMask; -} VkDeviceGroupCommandBufferBeginInfoKHX; - -typedef struct VkDeviceGroupSubmitInfoKHX { - VkStructureType sType; - const void* pNext; - uint32_t waitSemaphoreCount; - const uint32_t* pWaitSemaphoreDeviceIndices; - uint32_t commandBufferCount; - const uint32_t* pCommandBufferDeviceMasks; - uint32_t signalSemaphoreCount; - const uint32_t* pSignalSemaphoreDeviceIndices; -} VkDeviceGroupSubmitInfoKHX; - -typedef struct VkDeviceGroupBindSparseInfoKHX { - VkStructureType sType; - const void* pNext; - uint32_t resourceDeviceIndex; - uint32_t memoryDeviceIndex; -} VkDeviceGroupBindSparseInfoKHX; - -typedef struct VkDeviceGroupPresentCapabilitiesKHX { - VkStructureType sType; - const void* pNext; - uint32_t presentMask[VK_MAX_DEVICE_GROUP_SIZE_KHX]; - VkDeviceGroupPresentModeFlagsKHX modes; -} VkDeviceGroupPresentCapabilitiesKHX; - -typedef struct VkImageSwapchainCreateInfoKHX { - VkStructureType sType; - const void* pNext; - VkSwapchainKHR swapchain; -} VkImageSwapchainCreateInfoKHX; - -typedef struct VkBindImageMemorySwapchainInfoKHX { - VkStructureType sType; - const void* pNext; - VkSwapchainKHR swapchain; - uint32_t imageIndex; -} VkBindImageMemorySwapchainInfoKHX; - -typedef struct VkAcquireNextImageInfoKHX { - VkStructureType sType; - const void* pNext; - VkSwapchainKHR swapchain; - uint64_t timeout; - VkSemaphore semaphore; - VkFence fence; - uint32_t deviceMask; -} VkAcquireNextImageInfoKHX; - -typedef struct VkDeviceGroupPresentInfoKHX { - VkStructureType sType; - const void* pNext; - uint32_t swapchainCount; - const uint32_t* pDeviceMasks; - VkDeviceGroupPresentModeFlagBitsKHX mode; -} VkDeviceGroupPresentInfoKHX; - -typedef struct VkDeviceGroupSwapchainCreateInfoKHX { - VkStructureType sType; - const void* pNext; - VkDeviceGroupPresentModeFlagsKHX modes; -} VkDeviceGroupSwapchainCreateInfoKHX; - - -typedef void (VKAPI_PTR *PFN_vkGetDeviceGroupPeerMemoryFeaturesKHX)(VkDevice device, uint32_t heapIndex, uint32_t localDeviceIndex, uint32_t remoteDeviceIndex, VkPeerMemoryFeatureFlagsKHX* pPeerMemoryFeatures); -typedef VkResult (VKAPI_PTR *PFN_vkBindBufferMemory2KHX)(VkDevice device, uint32_t bindInfoCount, const VkBindBufferMemoryInfoKHX* pBindInfos); -typedef VkResult (VKAPI_PTR *PFN_vkBindImageMemory2KHX)(VkDevice device, uint32_t bindInfoCount, const VkBindImageMemoryInfoKHX* pBindInfos); -typedef void (VKAPI_PTR *PFN_vkCmdSetDeviceMaskKHX)(VkCommandBuffer commandBuffer, uint32_t deviceMask); -typedef VkResult (VKAPI_PTR *PFN_vkGetDeviceGroupPresentCapabilitiesKHX)(VkDevice device, VkDeviceGroupPresentCapabilitiesKHX* pDeviceGroupPresentCapabilities); -typedef VkResult (VKAPI_PTR *PFN_vkGetDeviceGroupSurfacePresentModesKHX)(VkDevice device, VkSurfaceKHR surface, VkDeviceGroupPresentModeFlagsKHX* pModes); -typedef VkResult (VKAPI_PTR *PFN_vkAcquireNextImage2KHX)(VkDevice device, const VkAcquireNextImageInfoKHX* pAcquireInfo, uint32_t* pImageIndex); -typedef void (VKAPI_PTR *PFN_vkCmdDispatchBaseKHX)(VkCommandBuffer commandBuffer, uint32_t baseGroupX, uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ); -typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDevicePresentRectanglesKHX)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t* pRectCount, VkRect2D* pRects); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR void VKAPI_CALL vkGetDeviceGroupPeerMemoryFeaturesKHX( - VkDevice device, - uint32_t heapIndex, - uint32_t localDeviceIndex, - uint32_t remoteDeviceIndex, - VkPeerMemoryFeatureFlagsKHX* pPeerMemoryFeatures); - -VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory2KHX( - VkDevice device, - uint32_t bindInfoCount, - const VkBindBufferMemoryInfoKHX* pBindInfos); - -VKAPI_ATTR VkResult VKAPI_CALL vkBindImageMemory2KHX( - VkDevice device, - uint32_t bindInfoCount, - const VkBindImageMemoryInfoKHX* pBindInfos); - -VKAPI_ATTR void VKAPI_CALL vkCmdSetDeviceMaskKHX( - VkCommandBuffer commandBuffer, - uint32_t deviceMask); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupPresentCapabilitiesKHX( - VkDevice device, - VkDeviceGroupPresentCapabilitiesKHX* pDeviceGroupPresentCapabilities); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupSurfacePresentModesKHX( - VkDevice device, - VkSurfaceKHR surface, - VkDeviceGroupPresentModeFlagsKHX* pModes); - -VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImage2KHX( - VkDevice device, - const VkAcquireNextImageInfoKHX* pAcquireInfo, - uint32_t* pImageIndex); - -VKAPI_ATTR void VKAPI_CALL vkCmdDispatchBaseKHX( - VkCommandBuffer commandBuffer, - uint32_t baseGroupX, - uint32_t baseGroupY, - uint32_t baseGroupZ, - uint32_t groupCountX, - uint32_t groupCountY, - uint32_t groupCountZ); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDevicePresentRectanglesKHX( - VkPhysicalDevice physicalDevice, - VkSurfaceKHR surface, - uint32_t* pRectCount, - VkRect2D* pRects); -#endif - -#define VK_EXT_validation_flags 1 -#define VK_EXT_VALIDATION_FLAGS_SPEC_VERSION 1 -#define VK_EXT_VALIDATION_FLAGS_EXTENSION_NAME "VK_EXT_validation_flags" - - -typedef enum VkValidationCheckEXT { - VK_VALIDATION_CHECK_ALL_EXT = 0, - VK_VALIDATION_CHECK_SHADERS_EXT = 1, - VK_VALIDATION_CHECK_BEGIN_RANGE_EXT = VK_VALIDATION_CHECK_ALL_EXT, - VK_VALIDATION_CHECK_END_RANGE_EXT = VK_VALIDATION_CHECK_SHADERS_EXT, - VK_VALIDATION_CHECK_RANGE_SIZE_EXT = (VK_VALIDATION_CHECK_SHADERS_EXT - VK_VALIDATION_CHECK_ALL_EXT + 1), - VK_VALIDATION_CHECK_MAX_ENUM_EXT = 0x7FFFFFFF -} VkValidationCheckEXT; - -typedef struct VkValidationFlagsEXT { - VkStructureType sType; - const void* pNext; - uint32_t disabledValidationCheckCount; - VkValidationCheckEXT* pDisabledValidationChecks; -} VkValidationFlagsEXT; - - - -#ifdef VK_USE_PLATFORM_VI_NN -#define VK_NN_vi_surface 1 -#define VK_NN_VI_SURFACE_SPEC_VERSION 1 -#define VK_NN_VI_SURFACE_EXTENSION_NAME "VK_NN_vi_surface" - -typedef VkFlags VkViSurfaceCreateFlagsNN; - -typedef struct VkViSurfaceCreateInfoNN { - VkStructureType sType; - const void* pNext; - VkViSurfaceCreateFlagsNN flags; - void* window; -} VkViSurfaceCreateInfoNN; - - -typedef VkResult (VKAPI_PTR *PFN_vkCreateViSurfaceNN)(VkInstance instance, const VkViSurfaceCreateInfoNN* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkCreateViSurfaceNN( - VkInstance instance, - const VkViSurfaceCreateInfoNN* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSurfaceKHR* pSurface); -#endif -#endif /* VK_USE_PLATFORM_VI_NN */ - -#define VK_EXT_shader_subgroup_ballot 1 -#define VK_EXT_SHADER_SUBGROUP_BALLOT_SPEC_VERSION 1 -#define VK_EXT_SHADER_SUBGROUP_BALLOT_EXTENSION_NAME "VK_EXT_shader_subgroup_ballot" - - -#define VK_EXT_shader_subgroup_vote 1 -#define VK_EXT_SHADER_SUBGROUP_VOTE_SPEC_VERSION 1 -#define VK_EXT_SHADER_SUBGROUP_VOTE_EXTENSION_NAME "VK_EXT_shader_subgroup_vote" - - -#define VK_KHX_device_group_creation 1 -#define VK_KHX_DEVICE_GROUP_CREATION_SPEC_VERSION 1 -#define VK_KHX_DEVICE_GROUP_CREATION_EXTENSION_NAME "VK_KHX_device_group_creation" - -typedef struct VkPhysicalDeviceGroupPropertiesKHX { - VkStructureType sType; - void* pNext; - uint32_t physicalDeviceCount; - VkPhysicalDevice physicalDevices[VK_MAX_DEVICE_GROUP_SIZE_KHX]; - VkBool32 subsetAllocation; -} VkPhysicalDeviceGroupPropertiesKHX; - -typedef struct VkDeviceGroupDeviceCreateInfoKHX { - VkStructureType sType; - const void* pNext; - uint32_t physicalDeviceCount; - const VkPhysicalDevice* pPhysicalDevices; -} VkDeviceGroupDeviceCreateInfoKHX; - - -typedef VkResult (VKAPI_PTR *PFN_vkEnumeratePhysicalDeviceGroupsKHX)(VkInstance instance, uint32_t* pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupPropertiesKHX* pPhysicalDeviceGroupProperties); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDeviceGroupsKHX( - VkInstance instance, - uint32_t* pPhysicalDeviceGroupCount, - VkPhysicalDeviceGroupPropertiesKHX* pPhysicalDeviceGroupProperties); -#endif - -#define VK_KHX_external_memory_capabilities 1 -#define VK_LUID_SIZE_KHX 8 -#define VK_KHX_EXTERNAL_MEMORY_CAPABILITIES_SPEC_VERSION 1 -#define VK_KHX_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME "VK_KHX_external_memory_capabilities" - - -typedef enum VkExternalMemoryHandleTypeFlagBitsKHX { - VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHX = 0x00000001, - VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT_KHX = 0x00000002, - VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT_KHX = 0x00000004, - VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_BIT_KHX = 0x00000008, - VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_KMT_BIT_KHX = 0x00000010, - VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP_BIT_KHX = 0x00000020, - VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE_BIT_KHX = 0x00000040, - VK_EXTERNAL_MEMORY_HANDLE_TYPE_FLAG_BITS_MAX_ENUM_KHX = 0x7FFFFFFF -} VkExternalMemoryHandleTypeFlagBitsKHX; -typedef VkFlags VkExternalMemoryHandleTypeFlagsKHX; - -typedef enum VkExternalMemoryFeatureFlagBitsKHX { - VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT_KHX = 0x00000001, - VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT_KHX = 0x00000002, - VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT_KHX = 0x00000004, - VK_EXTERNAL_MEMORY_FEATURE_FLAG_BITS_MAX_ENUM_KHX = 0x7FFFFFFF -} VkExternalMemoryFeatureFlagBitsKHX; -typedef VkFlags VkExternalMemoryFeatureFlagsKHX; - -typedef struct VkExternalMemoryPropertiesKHX { - VkExternalMemoryFeatureFlagsKHX externalMemoryFeatures; - VkExternalMemoryHandleTypeFlagsKHX exportFromImportedHandleTypes; - VkExternalMemoryHandleTypeFlagsKHX compatibleHandleTypes; -} VkExternalMemoryPropertiesKHX; - -typedef struct VkPhysicalDeviceExternalImageFormatInfoKHX { - VkStructureType sType; - const void* pNext; - VkExternalMemoryHandleTypeFlagBitsKHX handleType; -} VkPhysicalDeviceExternalImageFormatInfoKHX; - -typedef struct VkExternalImageFormatPropertiesKHX { - VkStructureType sType; - void* pNext; - VkExternalMemoryPropertiesKHX externalMemoryProperties; -} VkExternalImageFormatPropertiesKHX; - -typedef struct VkPhysicalDeviceExternalBufferInfoKHX { - VkStructureType sType; - const void* pNext; - VkBufferCreateFlags flags; - VkBufferUsageFlags usage; - VkExternalMemoryHandleTypeFlagBitsKHX handleType; -} VkPhysicalDeviceExternalBufferInfoKHX; - -typedef struct VkExternalBufferPropertiesKHX { - VkStructureType sType; - void* pNext; - VkExternalMemoryPropertiesKHX externalMemoryProperties; -} VkExternalBufferPropertiesKHX; - -typedef struct VkPhysicalDeviceIDPropertiesKHX { - VkStructureType sType; - void* pNext; - uint8_t deviceUUID[VK_UUID_SIZE]; - uint8_t driverUUID[VK_UUID_SIZE]; - uint8_t deviceLUID[VK_LUID_SIZE_KHX]; - VkBool32 deviceLUIDValid; -} VkPhysicalDeviceIDPropertiesKHX; - - -typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceExternalBufferPropertiesKHX)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalBufferInfoKHX* pExternalBufferInfo, VkExternalBufferPropertiesKHX* pExternalBufferProperties); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalBufferPropertiesKHX( - VkPhysicalDevice physicalDevice, - const VkPhysicalDeviceExternalBufferInfoKHX* pExternalBufferInfo, - VkExternalBufferPropertiesKHX* pExternalBufferProperties); -#endif - -#define VK_KHX_external_memory 1 -#define VK_KHX_EXTERNAL_MEMORY_SPEC_VERSION 1 -#define VK_KHX_EXTERNAL_MEMORY_EXTENSION_NAME "VK_KHX_external_memory" -#define VK_QUEUE_FAMILY_EXTERNAL_KHX (~0U-1) - -typedef struct VkExternalMemoryImageCreateInfoKHX { - VkStructureType sType; - const void* pNext; - VkExternalMemoryHandleTypeFlagsKHX handleTypes; -} VkExternalMemoryImageCreateInfoKHX; - -typedef struct VkExternalMemoryBufferCreateInfoKHX { - VkStructureType sType; - const void* pNext; - VkExternalMemoryHandleTypeFlagsKHX handleTypes; -} VkExternalMemoryBufferCreateInfoKHX; - -typedef struct VkExportMemoryAllocateInfoKHX { - VkStructureType sType; - const void* pNext; - VkExternalMemoryHandleTypeFlagsKHX handleTypes; -} VkExportMemoryAllocateInfoKHX; - - - -#ifdef VK_USE_PLATFORM_WIN32_KHX -#define VK_KHX_external_memory_win32 1 -#define VK_KHX_EXTERNAL_MEMORY_WIN32_SPEC_VERSION 1 -#define VK_KHX_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME "VK_KHX_external_memory_win32" - -typedef struct VkImportMemoryWin32HandleInfoKHX { - VkStructureType sType; - const void* pNext; - VkExternalMemoryHandleTypeFlagBitsKHX handleType; - HANDLE handle; -} VkImportMemoryWin32HandleInfoKHX; - -typedef struct VkExportMemoryWin32HandleInfoKHX { - VkStructureType sType; - const void* pNext; - const SECURITY_ATTRIBUTES* pAttributes; - DWORD dwAccess; - LPCWSTR name; -} VkExportMemoryWin32HandleInfoKHX; - -typedef struct VkMemoryWin32HandlePropertiesKHX { - VkStructureType sType; - void* pNext; - uint32_t memoryTypeBits; -} VkMemoryWin32HandlePropertiesKHX; - - -typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandleKHX)(VkDevice device, VkDeviceMemory memory, VkExternalMemoryHandleTypeFlagBitsKHX handleType, HANDLE* pHandle); -typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandlePropertiesKHX)(VkDevice device, VkExternalMemoryHandleTypeFlagBitsKHX handleType, HANDLE handle, VkMemoryWin32HandlePropertiesKHX* pMemoryWin32HandleProperties); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandleKHX( - VkDevice device, - VkDeviceMemory memory, - VkExternalMemoryHandleTypeFlagBitsKHX handleType, - HANDLE* pHandle); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandlePropertiesKHX( - VkDevice device, - VkExternalMemoryHandleTypeFlagBitsKHX handleType, - HANDLE handle, - VkMemoryWin32HandlePropertiesKHX* pMemoryWin32HandleProperties); -#endif -#endif /* VK_USE_PLATFORM_WIN32_KHX */ - -#define VK_KHX_external_memory_fd 1 -#define VK_KHX_EXTERNAL_MEMORY_FD_SPEC_VERSION 1 -#define VK_KHX_EXTERNAL_MEMORY_FD_EXTENSION_NAME "VK_KHX_external_memory_fd" - -typedef struct VkImportMemoryFdInfoKHX { - VkStructureType sType; - const void* pNext; - VkExternalMemoryHandleTypeFlagBitsKHX handleType; - int fd; -} VkImportMemoryFdInfoKHX; - -typedef struct VkMemoryFdPropertiesKHX { - VkStructureType sType; - void* pNext; - uint32_t memoryTypeBits; -} VkMemoryFdPropertiesKHX; - - -typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryFdKHX)(VkDevice device, VkDeviceMemory memory, VkExternalMemoryHandleTypeFlagBitsKHX handleType, int* pFd); -typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryFdPropertiesKHX)(VkDevice device, VkExternalMemoryHandleTypeFlagBitsKHX handleType, int fd, VkMemoryFdPropertiesKHX* pMemoryFdProperties); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryFdKHX( - VkDevice device, - VkDeviceMemory memory, - VkExternalMemoryHandleTypeFlagBitsKHX handleType, - int* pFd); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryFdPropertiesKHX( - VkDevice device, - VkExternalMemoryHandleTypeFlagBitsKHX handleType, - int fd, - VkMemoryFdPropertiesKHX* pMemoryFdProperties); -#endif - -#ifdef VK_USE_PLATFORM_WIN32_KHR -#define VK_KHX_win32_keyed_mutex 1 -#define VK_KHX_WIN32_KEYED_MUTEX_SPEC_VERSION 1 -#define VK_KHX_WIN32_KEYED_MUTEX_EXTENSION_NAME "VK_KHX_win32_keyed_mutex" - -typedef struct VkWin32KeyedMutexAcquireReleaseInfoKHX { - VkStructureType sType; - const void* pNext; - uint32_t acquireCount; - const VkDeviceMemory* pAcquireSyncs; - const uint64_t* pAcquireKeys; - const uint32_t* pAcquireTimeouts; - uint32_t releaseCount; - const VkDeviceMemory* pReleaseSyncs; - const uint64_t* pReleaseKeys; -} VkWin32KeyedMutexAcquireReleaseInfoKHX; - - -#endif /* VK_USE_PLATFORM_WIN32_KHR */ - -#define VK_KHX_external_semaphore_capabilities 1 -#define VK_KHX_EXTERNAL_SEMAPHORE_CAPABILITIES_SPEC_VERSION 1 -#define VK_KHX_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME "VK_KHX_external_semaphore_capabilities" - - -typedef enum VkExternalSemaphoreHandleTypeFlagBitsKHX { - VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT_KHX = 0x00000001, - VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT_KHX = 0x00000002, - VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT_KHX = 0x00000004, - VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT_KHX = 0x00000008, - VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_FENCE_FD_BIT_KHX = 0x00000010, - VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_FLAG_BITS_MAX_ENUM_KHX = 0x7FFFFFFF -} VkExternalSemaphoreHandleTypeFlagBitsKHX; -typedef VkFlags VkExternalSemaphoreHandleTypeFlagsKHX; - -typedef enum VkExternalSemaphoreFeatureFlagBitsKHX { - VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT_KHX = 0x00000001, - VK_EXTERNAL_SEMAPHORE_FEATURE_IMPORTABLE_BIT_KHX = 0x00000002, - VK_EXTERNAL_SEMAPHORE_FEATURE_FLAG_BITS_MAX_ENUM_KHX = 0x7FFFFFFF -} VkExternalSemaphoreFeatureFlagBitsKHX; -typedef VkFlags VkExternalSemaphoreFeatureFlagsKHX; - -typedef struct VkPhysicalDeviceExternalSemaphoreInfoKHX { - VkStructureType sType; - const void* pNext; - VkExternalSemaphoreHandleTypeFlagBitsKHX handleType; -} VkPhysicalDeviceExternalSemaphoreInfoKHX; - -typedef struct VkExternalSemaphorePropertiesKHX { - VkStructureType sType; - void* pNext; - VkExternalSemaphoreHandleTypeFlagsKHX exportFromImportedHandleTypes; - VkExternalSemaphoreHandleTypeFlagsKHX compatibleHandleTypes; - VkExternalSemaphoreFeatureFlagsKHX externalSemaphoreFeatures; -} VkExternalSemaphorePropertiesKHX; - - -typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceExternalSemaphorePropertiesKHX)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalSemaphoreInfoKHX* pExternalSemaphoreInfo, VkExternalSemaphorePropertiesKHX* pExternalSemaphoreProperties); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalSemaphorePropertiesKHX( - VkPhysicalDevice physicalDevice, - const VkPhysicalDeviceExternalSemaphoreInfoKHX* pExternalSemaphoreInfo, - VkExternalSemaphorePropertiesKHX* pExternalSemaphoreProperties); -#endif - -#define VK_KHX_external_semaphore 1 -#define VK_KHX_EXTERNAL_SEMAPHORE_SPEC_VERSION 1 -#define VK_KHX_EXTERNAL_SEMAPHORE_EXTENSION_NAME "VK_KHX_external_semaphore" - -typedef struct VkExportSemaphoreCreateInfoKHX { - VkStructureType sType; - const void* pNext; - VkExternalSemaphoreHandleTypeFlagsKHX handleTypes; -} VkExportSemaphoreCreateInfoKHX; - - - -#ifdef VK_USE_PLATFORM_WIN32_KHX -#define VK_KHX_external_semaphore_win32 1 -#define VK_KHX_EXTERNAL_SEMAPHORE_WIN32_SPEC_VERSION 1 -#define VK_KHX_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME "VK_KHX_external_semaphore_win32" - -typedef struct VkImportSemaphoreWin32HandleInfoKHX { - VkStructureType sType; - const void* pNext; - VkSemaphore semaphore; - VkExternalSemaphoreHandleTypeFlagsKHX handleType; - HANDLE handle; -} VkImportSemaphoreWin32HandleInfoKHX; - -typedef struct VkExportSemaphoreWin32HandleInfoKHX { - VkStructureType sType; - const void* pNext; - const SECURITY_ATTRIBUTES* pAttributes; - DWORD dwAccess; - LPCWSTR name; -} VkExportSemaphoreWin32HandleInfoKHX; - -typedef struct VkD3D12FenceSubmitInfoKHX { - VkStructureType sType; - const void* pNext; - uint32_t waitSemaphoreValuesCount; - const uint64_t* pWaitSemaphoreValues; - uint32_t signalSemaphoreValuesCount; - const uint64_t* pSignalSemaphoreValues; -} VkD3D12FenceSubmitInfoKHX; - - -typedef VkResult (VKAPI_PTR *PFN_vkImportSemaphoreWin32HandleKHX)(VkDevice device, const VkImportSemaphoreWin32HandleInfoKHX* pImportSemaphoreWin32HandleInfo); -typedef VkResult (VKAPI_PTR *PFN_vkGetSemaphoreWin32HandleKHX)(VkDevice device, VkSemaphore semaphore, VkExternalSemaphoreHandleTypeFlagBitsKHX handleType, HANDLE* pHandle); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkImportSemaphoreWin32HandleKHX( - VkDevice device, - const VkImportSemaphoreWin32HandleInfoKHX* pImportSemaphoreWin32HandleInfo); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreWin32HandleKHX( - VkDevice device, - VkSemaphore semaphore, - VkExternalSemaphoreHandleTypeFlagBitsKHX handleType, - HANDLE* pHandle); -#endif -#endif /* VK_USE_PLATFORM_WIN32_KHX */ - -#define VK_KHX_external_semaphore_fd 1 -#define VK_KHX_EXTERNAL_SEMAPHORE_FD_SPEC_VERSION 1 -#define VK_KHX_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME "VK_KHX_external_semaphore_fd" - -typedef struct VkImportSemaphoreFdInfoKHX { - VkStructureType sType; - const void* pNext; - VkSemaphore semaphore; - VkExternalSemaphoreHandleTypeFlagBitsKHX handleType; - int fd; -} VkImportSemaphoreFdInfoKHX; - - -typedef VkResult (VKAPI_PTR *PFN_vkImportSemaphoreFdKHX)(VkDevice device, const VkImportSemaphoreFdInfoKHX* pImportSemaphoreFdInfo); -typedef VkResult (VKAPI_PTR *PFN_vkGetSemaphoreFdKHX)(VkDevice device, VkSemaphore semaphore, VkExternalSemaphoreHandleTypeFlagBitsKHX handleType, int* pFd); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkImportSemaphoreFdKHX( - VkDevice device, - const VkImportSemaphoreFdInfoKHX* pImportSemaphoreFdInfo); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreFdKHX( - VkDevice device, - VkSemaphore semaphore, - VkExternalSemaphoreHandleTypeFlagBitsKHX handleType, - int* pFd); -#endif - -#define VK_NVX_device_generated_commands 1 -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkObjectTableNVX) -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkIndirectCommandsLayoutNVX) - -#define VK_NVX_DEVICE_GENERATED_COMMANDS_SPEC_VERSION 1 -#define VK_NVX_DEVICE_GENERATED_COMMANDS_EXTENSION_NAME "VK_NVX_device_generated_commands" - - -typedef enum VkIndirectCommandsTokenTypeNVX { - VK_INDIRECT_COMMANDS_TOKEN_TYPE_PIPELINE_NVX = 0, - VK_INDIRECT_COMMANDS_TOKEN_TYPE_DESCRIPTOR_SET_NVX = 1, - VK_INDIRECT_COMMANDS_TOKEN_TYPE_INDEX_BUFFER_NVX = 2, - VK_INDIRECT_COMMANDS_TOKEN_TYPE_VERTEX_BUFFER_NVX = 3, - VK_INDIRECT_COMMANDS_TOKEN_TYPE_PUSH_CONSTANT_NVX = 4, - VK_INDIRECT_COMMANDS_TOKEN_TYPE_DRAW_INDEXED_NVX = 5, - VK_INDIRECT_COMMANDS_TOKEN_TYPE_DRAW_NVX = 6, - VK_INDIRECT_COMMANDS_TOKEN_TYPE_DISPATCH_NVX = 7, - VK_INDIRECT_COMMANDS_TOKEN_TYPE_BEGIN_RANGE_NVX = VK_INDIRECT_COMMANDS_TOKEN_TYPE_PIPELINE_NVX, - VK_INDIRECT_COMMANDS_TOKEN_TYPE_END_RANGE_NVX = VK_INDIRECT_COMMANDS_TOKEN_TYPE_DISPATCH_NVX, - VK_INDIRECT_COMMANDS_TOKEN_TYPE_RANGE_SIZE_NVX = (VK_INDIRECT_COMMANDS_TOKEN_TYPE_DISPATCH_NVX - VK_INDIRECT_COMMANDS_TOKEN_TYPE_PIPELINE_NVX + 1), - VK_INDIRECT_COMMANDS_TOKEN_TYPE_MAX_ENUM_NVX = 0x7FFFFFFF -} VkIndirectCommandsTokenTypeNVX; - -typedef enum VkObjectEntryTypeNVX { - VK_OBJECT_ENTRY_TYPE_DESCRIPTOR_SET_NVX = 0, - VK_OBJECT_ENTRY_TYPE_PIPELINE_NVX = 1, - VK_OBJECT_ENTRY_TYPE_INDEX_BUFFER_NVX = 2, - VK_OBJECT_ENTRY_TYPE_VERTEX_BUFFER_NVX = 3, - VK_OBJECT_ENTRY_TYPE_PUSH_CONSTANT_NVX = 4, - VK_OBJECT_ENTRY_TYPE_BEGIN_RANGE_NVX = VK_OBJECT_ENTRY_TYPE_DESCRIPTOR_SET_NVX, - VK_OBJECT_ENTRY_TYPE_END_RANGE_NVX = VK_OBJECT_ENTRY_TYPE_PUSH_CONSTANT_NVX, - VK_OBJECT_ENTRY_TYPE_RANGE_SIZE_NVX = (VK_OBJECT_ENTRY_TYPE_PUSH_CONSTANT_NVX - VK_OBJECT_ENTRY_TYPE_DESCRIPTOR_SET_NVX + 1), - VK_OBJECT_ENTRY_TYPE_MAX_ENUM_NVX = 0x7FFFFFFF -} VkObjectEntryTypeNVX; - - -typedef enum VkIndirectCommandsLayoutUsageFlagBitsNVX { - VK_INDIRECT_COMMANDS_LAYOUT_USAGE_UNORDERED_SEQUENCES_BIT_NVX = 0x00000001, - VK_INDIRECT_COMMANDS_LAYOUT_USAGE_SPARSE_SEQUENCES_BIT_NVX = 0x00000002, - VK_INDIRECT_COMMANDS_LAYOUT_USAGE_EMPTY_EXECUTIONS_BIT_NVX = 0x00000004, - VK_INDIRECT_COMMANDS_LAYOUT_USAGE_INDEXED_SEQUENCES_BIT_NVX = 0x00000008, - VK_INDIRECT_COMMANDS_LAYOUT_USAGE_FLAG_BITS_MAX_ENUM_NVX = 0x7FFFFFFF -} VkIndirectCommandsLayoutUsageFlagBitsNVX; -typedef VkFlags VkIndirectCommandsLayoutUsageFlagsNVX; - -typedef enum VkObjectEntryUsageFlagBitsNVX { - VK_OBJECT_ENTRY_USAGE_GRAPHICS_BIT_NVX = 0x00000001, - VK_OBJECT_ENTRY_USAGE_COMPUTE_BIT_NVX = 0x00000002, - VK_OBJECT_ENTRY_USAGE_FLAG_BITS_MAX_ENUM_NVX = 0x7FFFFFFF -} VkObjectEntryUsageFlagBitsNVX; -typedef VkFlags VkObjectEntryUsageFlagsNVX; - -typedef struct VkDeviceGeneratedCommandsFeaturesNVX { - VkStructureType sType; - const void* pNext; - VkBool32 computeBindingPointSupport; -} VkDeviceGeneratedCommandsFeaturesNVX; - -typedef struct VkDeviceGeneratedCommandsLimitsNVX { - VkStructureType sType; - const void* pNext; - uint32_t maxIndirectCommandsLayoutTokenCount; - uint32_t maxObjectEntryCounts; - uint32_t minSequenceCountBufferOffsetAlignment; - uint32_t minSequenceIndexBufferOffsetAlignment; - uint32_t minCommandsTokenBufferOffsetAlignment; -} VkDeviceGeneratedCommandsLimitsNVX; - -typedef struct VkIndirectCommandsTokenNVX { - VkIndirectCommandsTokenTypeNVX tokenType; - VkBuffer buffer; - VkDeviceSize offset; -} VkIndirectCommandsTokenNVX; - -typedef struct VkIndirectCommandsLayoutTokenNVX { - VkIndirectCommandsTokenTypeNVX tokenType; - uint32_t bindingUnit; - uint32_t dynamicCount; - uint32_t divisor; -} VkIndirectCommandsLayoutTokenNVX; - -typedef struct VkIndirectCommandsLayoutCreateInfoNVX { - VkStructureType sType; - const void* pNext; - VkPipelineBindPoint pipelineBindPoint; - VkIndirectCommandsLayoutUsageFlagsNVX flags; - uint32_t tokenCount; - const VkIndirectCommandsLayoutTokenNVX* pTokens; -} VkIndirectCommandsLayoutCreateInfoNVX; - -typedef struct VkCmdProcessCommandsInfoNVX { - VkStructureType sType; - const void* pNext; - VkObjectTableNVX objectTable; - VkIndirectCommandsLayoutNVX indirectCommandsLayout; - uint32_t indirectCommandsTokenCount; - const VkIndirectCommandsTokenNVX* pIndirectCommandsTokens; - uint32_t maxSequencesCount; - VkCommandBuffer targetCommandBuffer; - VkBuffer sequencesCountBuffer; - VkDeviceSize sequencesCountOffset; - VkBuffer sequencesIndexBuffer; - VkDeviceSize sequencesIndexOffset; -} VkCmdProcessCommandsInfoNVX; - -typedef struct VkCmdReserveSpaceForCommandsInfoNVX { - VkStructureType sType; - const void* pNext; - VkObjectTableNVX objectTable; - VkIndirectCommandsLayoutNVX indirectCommandsLayout; - uint32_t maxSequencesCount; -} VkCmdReserveSpaceForCommandsInfoNVX; - -typedef struct VkObjectTableCreateInfoNVX { - VkStructureType sType; - const void* pNext; - uint32_t objectCount; - const VkObjectEntryTypeNVX* pObjectEntryTypes; - const uint32_t* pObjectEntryCounts; - const VkObjectEntryUsageFlagsNVX* pObjectEntryUsageFlags; - uint32_t maxUniformBuffersPerDescriptor; - uint32_t maxStorageBuffersPerDescriptor; - uint32_t maxStorageImagesPerDescriptor; - uint32_t maxSampledImagesPerDescriptor; - uint32_t maxPipelineLayouts; -} VkObjectTableCreateInfoNVX; - -typedef struct VkObjectTableEntryNVX { - VkObjectEntryTypeNVX type; - VkObjectEntryUsageFlagsNVX flags; -} VkObjectTableEntryNVX; - -typedef struct VkObjectTablePipelineEntryNVX { - VkObjectEntryTypeNVX type; - VkObjectEntryUsageFlagsNVX flags; - VkPipeline pipeline; -} VkObjectTablePipelineEntryNVX; - -typedef struct VkObjectTableDescriptorSetEntryNVX { - VkObjectEntryTypeNVX type; - VkObjectEntryUsageFlagsNVX flags; - VkPipelineLayout pipelineLayout; - VkDescriptorSet descriptorSet; -} VkObjectTableDescriptorSetEntryNVX; - -typedef struct VkObjectTableVertexBufferEntryNVX { - VkObjectEntryTypeNVX type; - VkObjectEntryUsageFlagsNVX flags; - VkBuffer buffer; -} VkObjectTableVertexBufferEntryNVX; - -typedef struct VkObjectTableIndexBufferEntryNVX { - VkObjectEntryTypeNVX type; - VkObjectEntryUsageFlagsNVX flags; - VkBuffer buffer; - VkIndexType indexType; -} VkObjectTableIndexBufferEntryNVX; - -typedef struct VkObjectTablePushConstantEntryNVX { - VkObjectEntryTypeNVX type; - VkObjectEntryUsageFlagsNVX flags; - VkPipelineLayout pipelineLayout; - VkShaderStageFlags stageFlags; -} VkObjectTablePushConstantEntryNVX; - - -typedef void (VKAPI_PTR *PFN_vkCmdProcessCommandsNVX)(VkCommandBuffer commandBuffer, const VkCmdProcessCommandsInfoNVX* pProcessCommandsInfo); -typedef void (VKAPI_PTR *PFN_vkCmdReserveSpaceForCommandsNVX)(VkCommandBuffer commandBuffer, const VkCmdReserveSpaceForCommandsInfoNVX* pReserveSpaceInfo); -typedef VkResult (VKAPI_PTR *PFN_vkCreateIndirectCommandsLayoutNVX)(VkDevice device, const VkIndirectCommandsLayoutCreateInfoNVX* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkIndirectCommandsLayoutNVX* pIndirectCommandsLayout); -typedef void (VKAPI_PTR *PFN_vkDestroyIndirectCommandsLayoutNVX)(VkDevice device, VkIndirectCommandsLayoutNVX indirectCommandsLayout, const VkAllocationCallbacks* pAllocator); -typedef VkResult (VKAPI_PTR *PFN_vkCreateObjectTableNVX)(VkDevice device, const VkObjectTableCreateInfoNVX* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkObjectTableNVX* pObjectTable); -typedef void (VKAPI_PTR *PFN_vkDestroyObjectTableNVX)(VkDevice device, VkObjectTableNVX objectTable, const VkAllocationCallbacks* pAllocator); -typedef VkResult (VKAPI_PTR *PFN_vkRegisterObjectsNVX)(VkDevice device, VkObjectTableNVX objectTable, uint32_t objectCount, const VkObjectTableEntryNVX* const* ppObjectTableEntries, const uint32_t* pObjectIndices); -typedef VkResult (VKAPI_PTR *PFN_vkUnregisterObjectsNVX)(VkDevice device, VkObjectTableNVX objectTable, uint32_t objectCount, const VkObjectEntryTypeNVX* pObjectEntryTypes, const uint32_t* pObjectIndices); -typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX)(VkPhysicalDevice physicalDevice, VkDeviceGeneratedCommandsFeaturesNVX* pFeatures, VkDeviceGeneratedCommandsLimitsNVX* pLimits); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR void VKAPI_CALL vkCmdProcessCommandsNVX( - VkCommandBuffer commandBuffer, - const VkCmdProcessCommandsInfoNVX* pProcessCommandsInfo); - -VKAPI_ATTR void VKAPI_CALL vkCmdReserveSpaceForCommandsNVX( - VkCommandBuffer commandBuffer, - const VkCmdReserveSpaceForCommandsInfoNVX* pReserveSpaceInfo); - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateIndirectCommandsLayoutNVX( - VkDevice device, - const VkIndirectCommandsLayoutCreateInfoNVX* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkIndirectCommandsLayoutNVX* pIndirectCommandsLayout); - -VKAPI_ATTR void VKAPI_CALL vkDestroyIndirectCommandsLayoutNVX( - VkDevice device, - VkIndirectCommandsLayoutNVX indirectCommandsLayout, - const VkAllocationCallbacks* pAllocator); - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateObjectTableNVX( - VkDevice device, - const VkObjectTableCreateInfoNVX* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkObjectTableNVX* pObjectTable); - -VKAPI_ATTR void VKAPI_CALL vkDestroyObjectTableNVX( - VkDevice device, - VkObjectTableNVX objectTable, - const VkAllocationCallbacks* pAllocator); - -VKAPI_ATTR VkResult VKAPI_CALL vkRegisterObjectsNVX( - VkDevice device, - VkObjectTableNVX objectTable, - uint32_t objectCount, - const VkObjectTableEntryNVX* const* ppObjectTableEntries, - const uint32_t* pObjectIndices); - -VKAPI_ATTR VkResult VKAPI_CALL vkUnregisterObjectsNVX( - VkDevice device, - VkObjectTableNVX objectTable, - uint32_t objectCount, - const VkObjectEntryTypeNVX* pObjectEntryTypes, - const uint32_t* pObjectIndices); - -VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX( - VkPhysicalDevice physicalDevice, - VkDeviceGeneratedCommandsFeaturesNVX* pFeatures, - VkDeviceGeneratedCommandsLimitsNVX* pLimits); -#endif - -#define VK_NV_clip_space_w_scaling 1 -#define VK_NV_CLIP_SPACE_W_SCALING_SPEC_VERSION 1 -#define VK_NV_CLIP_SPACE_W_SCALING_EXTENSION_NAME "VK_NV_clip_space_w_scaling" - -typedef struct VkViewportWScalingNV { - float xcoeff; - float ycoeff; -} VkViewportWScalingNV; - -typedef struct VkPipelineViewportWScalingStateCreateInfoNV { - VkStructureType sType; - const void* pNext; - VkBool32 viewportWScalingEnable; - uint32_t viewportCount; - const VkViewportWScalingNV* pViewportWScalings; -} VkPipelineViewportWScalingStateCreateInfoNV; - - -typedef void (VKAPI_PTR *PFN_vkCmdSetViewportWScalingNV)(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewportWScalingNV* pViewportWScalings); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR void VKAPI_CALL vkCmdSetViewportWScalingNV( - VkCommandBuffer commandBuffer, - uint32_t firstViewport, - uint32_t viewportCount, - const VkViewportWScalingNV* pViewportWScalings); -#endif - -#define VK_EXT_direct_mode_display 1 -#define VK_EXT_DIRECT_MODE_DISPLAY_SPEC_VERSION 1 -#define VK_EXT_DIRECT_MODE_DISPLAY_EXTENSION_NAME "VK_EXT_direct_mode_display" - -typedef VkResult (VKAPI_PTR *PFN_vkReleaseDisplayEXT)(VkPhysicalDevice physicalDevice, VkDisplayKHR display); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkReleaseDisplayEXT( - VkPhysicalDevice physicalDevice, - VkDisplayKHR display); -#endif - -#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT -#define VK_EXT_acquire_xlib_display 1 -#include - -#define VK_EXT_ACQUIRE_XLIB_DISPLAY_SPEC_VERSION 1 -#define VK_EXT_ACQUIRE_XLIB_DISPLAY_EXTENSION_NAME "VK_EXT_acquire_xlib_display" - -typedef VkResult (VKAPI_PTR *PFN_vkAcquireXlibDisplayEXT)(VkPhysicalDevice physicalDevice, Display* dpy, VkDisplayKHR display); -typedef VkResult (VKAPI_PTR *PFN_vkGetRandROutputDisplayEXT)(VkPhysicalDevice physicalDevice, Display* dpy, RROutput rrOutput, VkDisplayKHR* pDisplay); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkAcquireXlibDisplayEXT( - VkPhysicalDevice physicalDevice, - Display* dpy, - VkDisplayKHR display); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetRandROutputDisplayEXT( - VkPhysicalDevice physicalDevice, - Display* dpy, - RROutput rrOutput, - VkDisplayKHR* pDisplay); -#endif -#endif /* VK_USE_PLATFORM_XLIB_XRANDR_EXT */ - -#define VK_EXT_display_surface_counter 1 -#define VK_EXT_DISPLAY_SURFACE_COUNTER_SPEC_VERSION 1 -#define VK_EXT_DISPLAY_SURFACE_COUNTER_EXTENSION_NAME "VK_EXT_display_surface_counter" - - -typedef enum VkSurfaceCounterFlagBitsEXT { - VK_SURFACE_COUNTER_VBLANK_EXT = 0x00000001, - VK_SURFACE_COUNTER_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF -} VkSurfaceCounterFlagBitsEXT; -typedef VkFlags VkSurfaceCounterFlagsEXT; - -typedef struct VkSurfaceCapabilities2EXT { - VkStructureType sType; - void* pNext; - uint32_t minImageCount; - uint32_t maxImageCount; - VkExtent2D currentExtent; - VkExtent2D minImageExtent; - VkExtent2D maxImageExtent; - uint32_t maxImageArrayLayers; - VkSurfaceTransformFlagsKHR supportedTransforms; - VkSurfaceTransformFlagBitsKHR currentTransform; - VkCompositeAlphaFlagsKHR supportedCompositeAlpha; - VkImageUsageFlags supportedUsageFlags; - VkSurfaceCounterFlagsEXT supportedSurfaceCounters; -} VkSurfaceCapabilities2EXT; - - -typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfaceCapabilities2EXT)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilities2EXT* pSurfaceCapabilities); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilities2EXT( - VkPhysicalDevice physicalDevice, - VkSurfaceKHR surface, - VkSurfaceCapabilities2EXT* pSurfaceCapabilities); -#endif - -#define VK_EXT_display_control 1 -#define VK_EXT_DISPLAY_CONTROL_SPEC_VERSION 1 -#define VK_EXT_DISPLAY_CONTROL_EXTENSION_NAME "VK_EXT_display_control" - - -typedef enum VkDisplayPowerStateEXT { - VK_DISPLAY_POWER_STATE_OFF_EXT = 0, - VK_DISPLAY_POWER_STATE_SUSPEND_EXT = 1, - VK_DISPLAY_POWER_STATE_ON_EXT = 2, - VK_DISPLAY_POWER_STATE_BEGIN_RANGE_EXT = VK_DISPLAY_POWER_STATE_OFF_EXT, - VK_DISPLAY_POWER_STATE_END_RANGE_EXT = VK_DISPLAY_POWER_STATE_ON_EXT, - VK_DISPLAY_POWER_STATE_RANGE_SIZE_EXT = (VK_DISPLAY_POWER_STATE_ON_EXT - VK_DISPLAY_POWER_STATE_OFF_EXT + 1), - VK_DISPLAY_POWER_STATE_MAX_ENUM_EXT = 0x7FFFFFFF -} VkDisplayPowerStateEXT; - -typedef enum VkDeviceEventTypeEXT { - VK_DEVICE_EVENT_TYPE_DISPLAY_HOTPLUG_EXT = 0, - VK_DEVICE_EVENT_TYPE_BEGIN_RANGE_EXT = VK_DEVICE_EVENT_TYPE_DISPLAY_HOTPLUG_EXT, - VK_DEVICE_EVENT_TYPE_END_RANGE_EXT = VK_DEVICE_EVENT_TYPE_DISPLAY_HOTPLUG_EXT, - VK_DEVICE_EVENT_TYPE_RANGE_SIZE_EXT = (VK_DEVICE_EVENT_TYPE_DISPLAY_HOTPLUG_EXT - VK_DEVICE_EVENT_TYPE_DISPLAY_HOTPLUG_EXT + 1), - VK_DEVICE_EVENT_TYPE_MAX_ENUM_EXT = 0x7FFFFFFF -} VkDeviceEventTypeEXT; - -typedef enum VkDisplayEventTypeEXT { - VK_DISPLAY_EVENT_TYPE_FIRST_PIXEL_OUT_EXT = 0, - VK_DISPLAY_EVENT_TYPE_BEGIN_RANGE_EXT = VK_DISPLAY_EVENT_TYPE_FIRST_PIXEL_OUT_EXT, - VK_DISPLAY_EVENT_TYPE_END_RANGE_EXT = VK_DISPLAY_EVENT_TYPE_FIRST_PIXEL_OUT_EXT, - VK_DISPLAY_EVENT_TYPE_RANGE_SIZE_EXT = (VK_DISPLAY_EVENT_TYPE_FIRST_PIXEL_OUT_EXT - VK_DISPLAY_EVENT_TYPE_FIRST_PIXEL_OUT_EXT + 1), - VK_DISPLAY_EVENT_TYPE_MAX_ENUM_EXT = 0x7FFFFFFF -} VkDisplayEventTypeEXT; - -typedef struct VkDisplayPowerInfoEXT { - VkStructureType sType; - const void* pNext; - VkDisplayPowerStateEXT powerState; -} VkDisplayPowerInfoEXT; - -typedef struct VkDeviceEventInfoEXT { - VkStructureType sType; - const void* pNext; - VkDeviceEventTypeEXT deviceEvent; -} VkDeviceEventInfoEXT; - -typedef struct VkDisplayEventInfoEXT { - VkStructureType sType; - const void* pNext; - VkDisplayEventTypeEXT displayEvent; -} VkDisplayEventInfoEXT; - -typedef struct VkSwapchainCounterCreateInfoEXT { - VkStructureType sType; - const void* pNext; - VkSurfaceCounterFlagsEXT surfaceCounters; -} VkSwapchainCounterCreateInfoEXT; - - -typedef VkResult (VKAPI_PTR *PFN_vkDisplayPowerControlEXT)(VkDevice device, VkDisplayKHR display, const VkDisplayPowerInfoEXT* pDisplayPowerInfo); -typedef VkResult (VKAPI_PTR *PFN_vkRegisterDeviceEventEXT)(VkDevice device, const VkDeviceEventInfoEXT* pDeviceEventInfo, const VkAllocationCallbacks* pAllocator, VkFence* pFence); -typedef VkResult (VKAPI_PTR *PFN_vkRegisterDisplayEventEXT)(VkDevice device, VkDisplayKHR display, const VkDisplayEventInfoEXT* pDisplayEventInfo, const VkAllocationCallbacks* pAllocator, VkFence* pFence); -typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainCounterEXT)(VkDevice device, VkSwapchainKHR swapchain, VkSurfaceCounterFlagBitsEXT counter, uint64_t* pCounterValue); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkDisplayPowerControlEXT( - VkDevice device, - VkDisplayKHR display, - const VkDisplayPowerInfoEXT* pDisplayPowerInfo); - -VKAPI_ATTR VkResult VKAPI_CALL vkRegisterDeviceEventEXT( - VkDevice device, - const VkDeviceEventInfoEXT* pDeviceEventInfo, - const VkAllocationCallbacks* pAllocator, - VkFence* pFence); - -VKAPI_ATTR VkResult VKAPI_CALL vkRegisterDisplayEventEXT( - VkDevice device, - VkDisplayKHR display, - const VkDisplayEventInfoEXT* pDisplayEventInfo, - const VkAllocationCallbacks* pAllocator, - VkFence* pFence); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainCounterEXT( - VkDevice device, - VkSwapchainKHR swapchain, - VkSurfaceCounterFlagBitsEXT counter, - uint64_t* pCounterValue); -#endif - -#define VK_GOOGLE_display_timing 1 -#define VK_GOOGLE_DISPLAY_TIMING_SPEC_VERSION 1 -#define VK_GOOGLE_DISPLAY_TIMING_EXTENSION_NAME "VK_GOOGLE_display_timing" - -typedef struct VkRefreshCycleDurationGOOGLE { - uint64_t refreshDuration; -} VkRefreshCycleDurationGOOGLE; - -typedef struct VkPastPresentationTimingGOOGLE { - uint32_t presentID; - uint64_t desiredPresentTime; - uint64_t actualPresentTime; - uint64_t earliestPresentTime; - uint64_t presentMargin; -} VkPastPresentationTimingGOOGLE; - -typedef struct VkPresentTimeGOOGLE { - uint32_t presentID; - uint64_t desiredPresentTime; -} VkPresentTimeGOOGLE; - -typedef struct VkPresentTimesInfoGOOGLE { - VkStructureType sType; - const void* pNext; - uint32_t swapchainCount; - const VkPresentTimeGOOGLE* pTimes; -} VkPresentTimesInfoGOOGLE; - - -typedef VkResult (VKAPI_PTR *PFN_vkGetRefreshCycleDurationGOOGLE)(VkDevice device, VkSwapchainKHR swapchain, VkRefreshCycleDurationGOOGLE* pDisplayTimingProperties); -typedef VkResult (VKAPI_PTR *PFN_vkGetPastPresentationTimingGOOGLE)(VkDevice device, VkSwapchainKHR swapchain, uint32_t* pPresentationTimingCount, VkPastPresentationTimingGOOGLE* pPresentationTimings); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkGetRefreshCycleDurationGOOGLE( - VkDevice device, - VkSwapchainKHR swapchain, - VkRefreshCycleDurationGOOGLE* pDisplayTimingProperties); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetPastPresentationTimingGOOGLE( - VkDevice device, - VkSwapchainKHR swapchain, - uint32_t* pPresentationTimingCount, - VkPastPresentationTimingGOOGLE* pPresentationTimings); -#endif - -#define VK_NV_sample_mask_override_coverage 1 -#define VK_NV_SAMPLE_MASK_OVERRIDE_COVERAGE_SPEC_VERSION 1 -#define VK_NV_SAMPLE_MASK_OVERRIDE_COVERAGE_EXTENSION_NAME "VK_NV_sample_mask_override_coverage" - - -#define VK_NV_geometry_shader_passthrough 1 -#define VK_NV_GEOMETRY_SHADER_PASSTHROUGH_SPEC_VERSION 1 -#define VK_NV_GEOMETRY_SHADER_PASSTHROUGH_EXTENSION_NAME "VK_NV_geometry_shader_passthrough" - - -#define VK_NV_viewport_array2 1 -#define VK_NV_VIEWPORT_ARRAY2_SPEC_VERSION 1 -#define VK_NV_VIEWPORT_ARRAY2_EXTENSION_NAME "VK_NV_viewport_array2" - - -#define VK_NVX_multiview_per_view_attributes 1 -#define VK_NVX_MULTIVIEW_PER_VIEW_ATTRIBUTES_SPEC_VERSION 1 -#define VK_NVX_MULTIVIEW_PER_VIEW_ATTRIBUTES_EXTENSION_NAME "VK_NVX_multiview_per_view_attributes" - -typedef struct VkPhysicalDeviceMultiviewPerViewAttributesPropertiesNVX { - VkStructureType sType; - void* pNext; - VkBool32 perViewPositionAllComponents; -} VkPhysicalDeviceMultiviewPerViewAttributesPropertiesNVX; - - - -#define VK_NV_viewport_swizzle 1 -#define VK_NV_VIEWPORT_SWIZZLE_SPEC_VERSION 1 -#define VK_NV_VIEWPORT_SWIZZLE_EXTENSION_NAME "VK_NV_viewport_swizzle" - - -typedef enum VkViewportCoordinateSwizzleNV { - VK_VIEWPORT_COORDINATE_SWIZZLE_POSITIVE_X_NV = 0, - VK_VIEWPORT_COORDINATE_SWIZZLE_NEGATIVE_X_NV = 1, - VK_VIEWPORT_COORDINATE_SWIZZLE_POSITIVE_Y_NV = 2, - VK_VIEWPORT_COORDINATE_SWIZZLE_NEGATIVE_Y_NV = 3, - VK_VIEWPORT_COORDINATE_SWIZZLE_POSITIVE_Z_NV = 4, - VK_VIEWPORT_COORDINATE_SWIZZLE_NEGATIVE_Z_NV = 5, - VK_VIEWPORT_COORDINATE_SWIZZLE_POSITIVE_W_NV = 6, - VK_VIEWPORT_COORDINATE_SWIZZLE_NEGATIVE_W_NV = 7, - VK_VIEWPORT_COORDINATE_SWIZZLE_BEGIN_RANGE_NV = VK_VIEWPORT_COORDINATE_SWIZZLE_POSITIVE_X_NV, - VK_VIEWPORT_COORDINATE_SWIZZLE_END_RANGE_NV = VK_VIEWPORT_COORDINATE_SWIZZLE_NEGATIVE_W_NV, - VK_VIEWPORT_COORDINATE_SWIZZLE_RANGE_SIZE_NV = (VK_VIEWPORT_COORDINATE_SWIZZLE_NEGATIVE_W_NV - VK_VIEWPORT_COORDINATE_SWIZZLE_POSITIVE_X_NV + 1), - VK_VIEWPORT_COORDINATE_SWIZZLE_MAX_ENUM_NV = 0x7FFFFFFF -} VkViewportCoordinateSwizzleNV; - -typedef VkFlags VkPipelineViewportSwizzleStateCreateFlagsNV; - -typedef struct VkViewportSwizzleNV { - VkViewportCoordinateSwizzleNV x; - VkViewportCoordinateSwizzleNV y; - VkViewportCoordinateSwizzleNV z; - VkViewportCoordinateSwizzleNV w; -} VkViewportSwizzleNV; - -typedef struct VkPipelineViewportSwizzleStateCreateInfoNV { - VkStructureType sType; - const void* pNext; - VkPipelineViewportSwizzleStateCreateFlagsNV flags; - uint32_t viewportCount; - const VkViewportSwizzleNV* pViewportSwizzles; -} VkPipelineViewportSwizzleStateCreateInfoNV; - - - -#define VK_EXT_discard_rectangles 1 -#define VK_EXT_DISCARD_RECTANGLES_SPEC_VERSION 1 -#define VK_EXT_DISCARD_RECTANGLES_EXTENSION_NAME "VK_EXT_discard_rectangles" - - -typedef enum VkDiscardRectangleModeEXT { - VK_DISCARD_RECTANGLE_MODE_INCLUSIVE_EXT = 0, - VK_DISCARD_RECTANGLE_MODE_EXCLUSIVE_EXT = 1, - VK_DISCARD_RECTANGLE_MODE_BEGIN_RANGE_EXT = VK_DISCARD_RECTANGLE_MODE_INCLUSIVE_EXT, - VK_DISCARD_RECTANGLE_MODE_END_RANGE_EXT = VK_DISCARD_RECTANGLE_MODE_EXCLUSIVE_EXT, - VK_DISCARD_RECTANGLE_MODE_RANGE_SIZE_EXT = (VK_DISCARD_RECTANGLE_MODE_EXCLUSIVE_EXT - VK_DISCARD_RECTANGLE_MODE_INCLUSIVE_EXT + 1), - VK_DISCARD_RECTANGLE_MODE_MAX_ENUM_EXT = 0x7FFFFFFF -} VkDiscardRectangleModeEXT; - -typedef VkFlags VkPipelineDiscardRectangleStateCreateFlagsEXT; - -typedef struct VkPhysicalDeviceDiscardRectanglePropertiesEXT { - VkStructureType sType; - void* pNext; - uint32_t maxDiscardRectangles; -} VkPhysicalDeviceDiscardRectanglePropertiesEXT; - -typedef struct VkPipelineDiscardRectangleStateCreateInfoEXT { - VkStructureType sType; - const void* pNext; - VkPipelineDiscardRectangleStateCreateFlagsEXT flags; - VkDiscardRectangleModeEXT discardRectangleMode; - uint32_t discardRectangleCount; - const VkRect2D* pDiscardRectangles; -} VkPipelineDiscardRectangleStateCreateInfoEXT; - - -typedef void (VKAPI_PTR *PFN_vkCmdSetDiscardRectangleEXT)(VkCommandBuffer commandBuffer, uint32_t firstDiscardRectangle, uint32_t discardRectangleCount, const VkRect2D* pDiscardRectangles); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR void VKAPI_CALL vkCmdSetDiscardRectangleEXT( - VkCommandBuffer commandBuffer, - uint32_t firstDiscardRectangle, - uint32_t discardRectangleCount, - const VkRect2D* pDiscardRectangles); -#endif - -#define VK_EXT_swapchain_colorspace 1 -#define VK_EXT_SWAPCHAIN_COLOR_SPACE_SPEC_VERSION 2 -#define VK_EXT_SWAPCHAIN_COLOR_SPACE_EXTENSION_NAME "VK_EXT_swapchain_colorspace" - - -#define VK_EXT_hdr_metadata 1 -#define VK_EXT_HDR_METADATA_SPEC_VERSION 1 -#define VK_EXT_HDR_METADATA_EXTENSION_NAME "VK_EXT_hdr_metadata" - -typedef struct VkXYColorEXT { - float x; - float y; -} VkXYColorEXT; - -typedef struct VkHdrMetadataEXT { - VkStructureType sType; - const void* pNext; - VkXYColorEXT displayPrimaryRed; - VkXYColorEXT displayPrimaryGreen; - VkXYColorEXT displayPrimaryBlue; - VkXYColorEXT whitePoint; - float maxLuminance; - float minLuminance; - float maxContentLightLevel; - float maxFrameAverageLightLevel; -} VkHdrMetadataEXT; - - -typedef void (VKAPI_PTR *PFN_vkSetHdrMetadataEXT)(VkDevice device, uint32_t swapchainCount, const VkSwapchainKHR* pSwapchains, const VkHdrMetadataEXT* pMetadata); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR void VKAPI_CALL vkSetHdrMetadataEXT( - VkDevice device, - uint32_t swapchainCount, - const VkSwapchainKHR* pSwapchains, - const VkHdrMetadataEXT* pMetadata); +#ifdef VK_USE_PLATFORM_FUCHSIA +#include +#include "vulkan_fuchsia.h" #endif #ifdef VK_USE_PLATFORM_IOS_MVK -#define VK_MVK_ios_surface 1 -#define VK_MVK_IOS_SURFACE_SPEC_VERSION 2 -#define VK_MVK_IOS_SURFACE_EXTENSION_NAME "VK_MVK_ios_surface" - -typedef VkFlags VkIOSSurfaceCreateFlagsMVK; - -typedef struct VkIOSSurfaceCreateInfoMVK { - VkStructureType sType; - const void* pNext; - VkIOSSurfaceCreateFlagsMVK flags; - const void* pView; -} VkIOSSurfaceCreateInfoMVK; - - -typedef VkResult (VKAPI_PTR *PFN_vkCreateIOSSurfaceMVK)(VkInstance instance, const VkIOSSurfaceCreateInfoMVK* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkCreateIOSSurfaceMVK( - VkInstance instance, - const VkIOSSurfaceCreateInfoMVK* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSurfaceKHR* pSurface); +#include "vulkan_ios.h" #endif -#endif /* VK_USE_PLATFORM_IOS_MVK */ + #ifdef VK_USE_PLATFORM_MACOS_MVK -#define VK_MVK_macos_surface 1 -#define VK_MVK_MACOS_SURFACE_SPEC_VERSION 2 -#define VK_MVK_MACOS_SURFACE_EXTENSION_NAME "VK_MVK_macos_surface" - -typedef VkFlags VkMacOSSurfaceCreateFlagsMVK; - -typedef struct VkMacOSSurfaceCreateInfoMVK { - VkStructureType sType; - const void* pNext; - VkMacOSSurfaceCreateFlagsMVK flags; - const void* pView; -} VkMacOSSurfaceCreateInfoMVK; - - -typedef VkResult (VKAPI_PTR *PFN_vkCreateMacOSSurfaceMVK)(VkInstance instance, const VkMacOSSurfaceCreateInfoMVK* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkCreateMacOSSurfaceMVK( - VkInstance instance, - const VkMacOSSurfaceCreateInfoMVK* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkSurfaceKHR* pSurface); -#endif -#endif /* VK_USE_PLATFORM_MACOS_MVK */ - -#define VK_EXT_sampler_filter_minmax 1 -#define VK_EXT_SAMPLER_FILTER_MINMAX_SPEC_VERSION 1 -#define VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME "VK_EXT_sampler_filter_minmax" - - -typedef enum VkSamplerReductionModeEXT { - VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE_EXT = 0, - VK_SAMPLER_REDUCTION_MODE_MIN_EXT = 1, - VK_SAMPLER_REDUCTION_MODE_MAX_EXT = 2, - VK_SAMPLER_REDUCTION_MODE_BEGIN_RANGE_EXT = VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE_EXT, - VK_SAMPLER_REDUCTION_MODE_END_RANGE_EXT = VK_SAMPLER_REDUCTION_MODE_MAX_EXT, - VK_SAMPLER_REDUCTION_MODE_RANGE_SIZE_EXT = (VK_SAMPLER_REDUCTION_MODE_MAX_EXT - VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE_EXT + 1), - VK_SAMPLER_REDUCTION_MODE_MAX_ENUM_EXT = 0x7FFFFFFF -} VkSamplerReductionModeEXT; - -typedef struct VkSamplerReductionModeCreateInfoEXT { - VkStructureType sType; - const void* pNext; - VkSamplerReductionModeEXT reductionMode; -} VkSamplerReductionModeCreateInfoEXT; - -typedef struct VkPhysicalDeviceSamplerFilterMinmaxPropertiesEXT { - VkStructureType sType; - void* pNext; - VkBool32 filterMinmaxSingleComponentFormats; - VkBool32 filterMinmaxImageComponentMapping; -} VkPhysicalDeviceSamplerFilterMinmaxPropertiesEXT; - - - -#define VK_AMD_gpu_shader_int16 1 -#define VK_AMD_GPU_SHADER_INT16_SPEC_VERSION 1 -#define VK_AMD_GPU_SHADER_INT16_EXTENSION_NAME "VK_AMD_gpu_shader_int16" - - -#define VK_EXT_blend_operation_advanced 1 -#define VK_EXT_BLEND_OPERATION_ADVANCED_SPEC_VERSION 2 -#define VK_EXT_BLEND_OPERATION_ADVANCED_EXTENSION_NAME "VK_EXT_blend_operation_advanced" - - -typedef enum VkBlendOverlapEXT { - VK_BLEND_OVERLAP_UNCORRELATED_EXT = 0, - VK_BLEND_OVERLAP_DISJOINT_EXT = 1, - VK_BLEND_OVERLAP_CONJOINT_EXT = 2, - VK_BLEND_OVERLAP_BEGIN_RANGE_EXT = VK_BLEND_OVERLAP_UNCORRELATED_EXT, - VK_BLEND_OVERLAP_END_RANGE_EXT = VK_BLEND_OVERLAP_CONJOINT_EXT, - VK_BLEND_OVERLAP_RANGE_SIZE_EXT = (VK_BLEND_OVERLAP_CONJOINT_EXT - VK_BLEND_OVERLAP_UNCORRELATED_EXT + 1), - VK_BLEND_OVERLAP_MAX_ENUM_EXT = 0x7FFFFFFF -} VkBlendOverlapEXT; - -typedef struct VkPhysicalDeviceBlendOperationAdvancedFeaturesEXT { - VkStructureType sType; - void* pNext; - VkBool32 advancedBlendCoherentOperations; -} VkPhysicalDeviceBlendOperationAdvancedFeaturesEXT; - -typedef struct VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT { - VkStructureType sType; - void* pNext; - uint32_t advancedBlendMaxColorAttachments; - VkBool32 advancedBlendIndependentBlend; - VkBool32 advancedBlendNonPremultipliedSrcColor; - VkBool32 advancedBlendNonPremultipliedDstColor; - VkBool32 advancedBlendCorrelatedOverlap; - VkBool32 advancedBlendAllOperations; -} VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT; - -typedef struct VkPipelineColorBlendAdvancedStateCreateInfoEXT { - VkStructureType sType; - const void* pNext; - VkBool32 srcPremultiplied; - VkBool32 dstPremultiplied; - VkBlendOverlapEXT blendOverlap; -} VkPipelineColorBlendAdvancedStateCreateInfoEXT; - - - -#define VK_NV_fragment_coverage_to_color 1 -#define VK_NV_FRAGMENT_COVERAGE_TO_COLOR_SPEC_VERSION 1 -#define VK_NV_FRAGMENT_COVERAGE_TO_COLOR_EXTENSION_NAME "VK_NV_fragment_coverage_to_color" - -typedef VkFlags VkPipelineCoverageToColorStateCreateFlagsNV; - -typedef struct VkPipelineCoverageToColorStateCreateInfoNV { - VkStructureType sType; - const void* pNext; - VkPipelineCoverageToColorStateCreateFlagsNV flags; - VkBool32 coverageToColorEnable; - uint32_t coverageToColorLocation; -} VkPipelineCoverageToColorStateCreateInfoNV; - - - -#define VK_NV_framebuffer_mixed_samples 1 -#define VK_NV_FRAMEBUFFER_MIXED_SAMPLES_SPEC_VERSION 1 -#define VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME "VK_NV_framebuffer_mixed_samples" - - -typedef enum VkCoverageModulationModeNV { - VK_COVERAGE_MODULATION_MODE_NONE_NV = 0, - VK_COVERAGE_MODULATION_MODE_RGB_NV = 1, - VK_COVERAGE_MODULATION_MODE_ALPHA_NV = 2, - VK_COVERAGE_MODULATION_MODE_RGBA_NV = 3, - VK_COVERAGE_MODULATION_MODE_BEGIN_RANGE_NV = VK_COVERAGE_MODULATION_MODE_NONE_NV, - VK_COVERAGE_MODULATION_MODE_END_RANGE_NV = VK_COVERAGE_MODULATION_MODE_RGBA_NV, - VK_COVERAGE_MODULATION_MODE_RANGE_SIZE_NV = (VK_COVERAGE_MODULATION_MODE_RGBA_NV - VK_COVERAGE_MODULATION_MODE_NONE_NV + 1), - VK_COVERAGE_MODULATION_MODE_MAX_ENUM_NV = 0x7FFFFFFF -} VkCoverageModulationModeNV; - -typedef VkFlags VkPipelineCoverageModulationStateCreateFlagsNV; - -typedef struct VkPipelineCoverageModulationStateCreateInfoNV { - VkStructureType sType; - const void* pNext; - VkPipelineCoverageModulationStateCreateFlagsNV flags; - VkCoverageModulationModeNV coverageModulationMode; - VkBool32 coverageModulationTableEnable; - uint32_t coverageModulationTableCount; - const float* pCoverageModulationTable; -} VkPipelineCoverageModulationStateCreateInfoNV; - - - -#define VK_NV_fill_rectangle 1 -#define VK_NV_FILL_RECTANGLE_SPEC_VERSION 1 -#define VK_NV_FILL_RECTANGLE_EXTENSION_NAME "VK_NV_fill_rectangle" - - -#ifdef __cplusplus -} +#include "vulkan_macos.h" #endif +#ifdef VK_USE_PLATFORM_METAL_EXT +#include "vulkan_metal.h" #endif + +#ifdef VK_USE_PLATFORM_VI_NN +#include "vulkan_vi.h" +#endif + + +#ifdef VK_USE_PLATFORM_WAYLAND_KHR +#include +#include "vulkan_wayland.h" +#endif + + +#ifdef VK_USE_PLATFORM_WIN32_KHR +#include +#include "vulkan_win32.h" +#endif + + +#ifdef VK_USE_PLATFORM_XCB_KHR +#include +#include "vulkan_xcb.h" +#endif + + +#ifdef VK_USE_PLATFORM_XLIB_KHR +#include +#include "vulkan_xlib.h" +#endif + + +#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT +#include +#include +#include "vulkan_xlib_xrandr.h" +#endif + + +#ifdef VK_USE_PLATFORM_GGP +#include +#include "vulkan_ggp.h" +#endif + +#endif // VULKAN_H_ diff --git a/thirdparty/include/vulkan/vulkan_android.h b/thirdparty/include/vulkan/vulkan_android.h new file mode 100644 index 000000000..4f27750cd --- /dev/null +++ b/thirdparty/include/vulkan/vulkan_android.h @@ -0,0 +1,122 @@ +#ifndef VULKAN_ANDROID_H_ +#define VULKAN_ANDROID_H_ 1 + +/* +** Copyright (c) 2015-2020 The Khronos Group Inc. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define VK_KHR_android_surface 1 +struct ANativeWindow; +#define VK_KHR_ANDROID_SURFACE_SPEC_VERSION 6 +#define VK_KHR_ANDROID_SURFACE_EXTENSION_NAME "VK_KHR_android_surface" +typedef VkFlags VkAndroidSurfaceCreateFlagsKHR; +typedef struct VkAndroidSurfaceCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkAndroidSurfaceCreateFlagsKHR flags; + struct ANativeWindow* window; +} VkAndroidSurfaceCreateInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateAndroidSurfaceKHR)(VkInstance instance, const VkAndroidSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateAndroidSurfaceKHR( + VkInstance instance, + const VkAndroidSurfaceCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); +#endif + + +#define VK_ANDROID_external_memory_android_hardware_buffer 1 +struct AHardwareBuffer; +#define VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_SPEC_VERSION 3 +#define VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME "VK_ANDROID_external_memory_android_hardware_buffer" +typedef struct VkAndroidHardwareBufferUsageANDROID { + VkStructureType sType; + void* pNext; + uint64_t androidHardwareBufferUsage; +} VkAndroidHardwareBufferUsageANDROID; + +typedef struct VkAndroidHardwareBufferPropertiesANDROID { + VkStructureType sType; + void* pNext; + VkDeviceSize allocationSize; + uint32_t memoryTypeBits; +} VkAndroidHardwareBufferPropertiesANDROID; + +typedef struct VkAndroidHardwareBufferFormatPropertiesANDROID { + VkStructureType sType; + void* pNext; + VkFormat format; + uint64_t externalFormat; + VkFormatFeatureFlags formatFeatures; + VkComponentMapping samplerYcbcrConversionComponents; + VkSamplerYcbcrModelConversion suggestedYcbcrModel; + VkSamplerYcbcrRange suggestedYcbcrRange; + VkChromaLocation suggestedXChromaOffset; + VkChromaLocation suggestedYChromaOffset; +} VkAndroidHardwareBufferFormatPropertiesANDROID; + +typedef struct VkImportAndroidHardwareBufferInfoANDROID { + VkStructureType sType; + const void* pNext; + struct AHardwareBuffer* buffer; +} VkImportAndroidHardwareBufferInfoANDROID; + +typedef struct VkMemoryGetAndroidHardwareBufferInfoANDROID { + VkStructureType sType; + const void* pNext; + VkDeviceMemory memory; +} VkMemoryGetAndroidHardwareBufferInfoANDROID; + +typedef struct VkExternalFormatANDROID { + VkStructureType sType; + void* pNext; + uint64_t externalFormat; +} VkExternalFormatANDROID; + +typedef VkResult (VKAPI_PTR *PFN_vkGetAndroidHardwareBufferPropertiesANDROID)(VkDevice device, const struct AHardwareBuffer* buffer, VkAndroidHardwareBufferPropertiesANDROID* pProperties); +typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryAndroidHardwareBufferANDROID)(VkDevice device, const VkMemoryGetAndroidHardwareBufferInfoANDROID* pInfo, struct AHardwareBuffer** pBuffer); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetAndroidHardwareBufferPropertiesANDROID( + VkDevice device, + const struct AHardwareBuffer* buffer, + VkAndroidHardwareBufferPropertiesANDROID* pProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryAndroidHardwareBufferANDROID( + VkDevice device, + const VkMemoryGetAndroidHardwareBufferInfoANDROID* pInfo, + struct AHardwareBuffer** pBuffer); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/include/vulkan/vulkan_core.h b/thirdparty/include/vulkan/vulkan_core.h new file mode 100644 index 000000000..09c569ef9 --- /dev/null +++ b/thirdparty/include/vulkan/vulkan_core.h @@ -0,0 +1,10728 @@ +#ifndef VULKAN_CORE_H_ +#define VULKAN_CORE_H_ 1 + +/* +** Copyright (c) 2015-2020 The Khronos Group Inc. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define VK_VERSION_1_0 1 +#include "vk_platform.h" +#define VK_MAKE_VERSION(major, minor, patch) \ + (((major) << 22) | ((minor) << 12) | (patch)) + +// DEPRECATED: This define has been removed. Specific version defines (e.g. VK_API_VERSION_1_0), or the VK_MAKE_VERSION macro, should be used instead. +//#define VK_API_VERSION VK_MAKE_VERSION(1, 0, 0) // Patch version should always be set to 0 + +// Vulkan 1.0 version number +#define VK_API_VERSION_1_0 VK_MAKE_VERSION(1, 0, 0)// Patch version should always be set to 0 + +#define VK_VERSION_MAJOR(version) ((uint32_t)(version) >> 22) +#define VK_VERSION_MINOR(version) (((uint32_t)(version) >> 12) & 0x3ff) +#define VK_VERSION_PATCH(version) ((uint32_t)(version) & 0xfff) +// Version of this file +#define VK_HEADER_VERSION 133 + + +#define VK_NULL_HANDLE 0 + + +#define VK_DEFINE_HANDLE(object) typedef struct object##_T* object; + + +#if !defined(VK_DEFINE_NON_DISPATCHABLE_HANDLE) +#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) + #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef struct object##_T *object; +#else + #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t object; +#endif +#endif + +typedef uint32_t VkFlags; +typedef uint32_t VkBool32; +typedef uint64_t VkDeviceSize; +typedef uint32_t VkSampleMask; +VK_DEFINE_HANDLE(VkInstance) +VK_DEFINE_HANDLE(VkPhysicalDevice) +VK_DEFINE_HANDLE(VkDevice) +VK_DEFINE_HANDLE(VkQueue) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSemaphore) +VK_DEFINE_HANDLE(VkCommandBuffer) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkFence) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDeviceMemory) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkBuffer) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkImage) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkEvent) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkQueryPool) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkBufferView) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkImageView) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkShaderModule) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipelineCache) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipelineLayout) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkRenderPass) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipeline) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorSetLayout) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSampler) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorPool) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorSet) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkFramebuffer) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkCommandPool) +#define VK_LOD_CLAMP_NONE 1000.0f +#define VK_REMAINING_MIP_LEVELS (~0U) +#define VK_REMAINING_ARRAY_LAYERS (~0U) +#define VK_WHOLE_SIZE (~0ULL) +#define VK_ATTACHMENT_UNUSED (~0U) +#define VK_TRUE 1 +#define VK_FALSE 0 +#define VK_QUEUE_FAMILY_IGNORED (~0U) +#define VK_SUBPASS_EXTERNAL (~0U) +#define VK_MAX_PHYSICAL_DEVICE_NAME_SIZE 256 +#define VK_UUID_SIZE 16 +#define VK_MAX_MEMORY_TYPES 32 +#define VK_MAX_MEMORY_HEAPS 16 +#define VK_MAX_EXTENSION_NAME_SIZE 256 +#define VK_MAX_DESCRIPTION_SIZE 256 + +typedef enum VkPipelineCacheHeaderVersion { + VK_PIPELINE_CACHE_HEADER_VERSION_ONE = 1, + VK_PIPELINE_CACHE_HEADER_VERSION_BEGIN_RANGE = VK_PIPELINE_CACHE_HEADER_VERSION_ONE, + VK_PIPELINE_CACHE_HEADER_VERSION_END_RANGE = VK_PIPELINE_CACHE_HEADER_VERSION_ONE, + VK_PIPELINE_CACHE_HEADER_VERSION_RANGE_SIZE = (VK_PIPELINE_CACHE_HEADER_VERSION_ONE - VK_PIPELINE_CACHE_HEADER_VERSION_ONE + 1), + VK_PIPELINE_CACHE_HEADER_VERSION_MAX_ENUM = 0x7FFFFFFF +} VkPipelineCacheHeaderVersion; + +typedef enum VkResult { + VK_SUCCESS = 0, + VK_NOT_READY = 1, + VK_TIMEOUT = 2, + VK_EVENT_SET = 3, + VK_EVENT_RESET = 4, + VK_INCOMPLETE = 5, + VK_ERROR_OUT_OF_HOST_MEMORY = -1, + VK_ERROR_OUT_OF_DEVICE_MEMORY = -2, + VK_ERROR_INITIALIZATION_FAILED = -3, + VK_ERROR_DEVICE_LOST = -4, + VK_ERROR_MEMORY_MAP_FAILED = -5, + VK_ERROR_LAYER_NOT_PRESENT = -6, + VK_ERROR_EXTENSION_NOT_PRESENT = -7, + VK_ERROR_FEATURE_NOT_PRESENT = -8, + VK_ERROR_INCOMPATIBLE_DRIVER = -9, + VK_ERROR_TOO_MANY_OBJECTS = -10, + VK_ERROR_FORMAT_NOT_SUPPORTED = -11, + VK_ERROR_FRAGMENTED_POOL = -12, + VK_ERROR_UNKNOWN = -13, + VK_ERROR_OUT_OF_POOL_MEMORY = -1000069000, + VK_ERROR_INVALID_EXTERNAL_HANDLE = -1000072003, + VK_ERROR_FRAGMENTATION = -1000161000, + VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS = -1000257000, + VK_ERROR_SURFACE_LOST_KHR = -1000000000, + VK_ERROR_NATIVE_WINDOW_IN_USE_KHR = -1000000001, + VK_SUBOPTIMAL_KHR = 1000001003, + VK_ERROR_OUT_OF_DATE_KHR = -1000001004, + VK_ERROR_INCOMPATIBLE_DISPLAY_KHR = -1000003001, + VK_ERROR_VALIDATION_FAILED_EXT = -1000011001, + VK_ERROR_INVALID_SHADER_NV = -1000012000, + VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT = -1000158000, + VK_ERROR_NOT_PERMITTED_EXT = -1000174001, + VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT = -1000255000, + VK_ERROR_OUT_OF_POOL_MEMORY_KHR = VK_ERROR_OUT_OF_POOL_MEMORY, + VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR = VK_ERROR_INVALID_EXTERNAL_HANDLE, + VK_ERROR_FRAGMENTATION_EXT = VK_ERROR_FRAGMENTATION, + VK_ERROR_INVALID_DEVICE_ADDRESS_EXT = VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS, + VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS_KHR = VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS, + VK_RESULT_BEGIN_RANGE = VK_ERROR_UNKNOWN, + VK_RESULT_END_RANGE = VK_INCOMPLETE, + VK_RESULT_RANGE_SIZE = (VK_INCOMPLETE - VK_ERROR_UNKNOWN + 1), + VK_RESULT_MAX_ENUM = 0x7FFFFFFF +} VkResult; + +typedef enum VkStructureType { + VK_STRUCTURE_TYPE_APPLICATION_INFO = 0, + VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO = 1, + VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO = 2, + VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO = 3, + VK_STRUCTURE_TYPE_SUBMIT_INFO = 4, + VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO = 5, + VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE = 6, + VK_STRUCTURE_TYPE_BIND_SPARSE_INFO = 7, + VK_STRUCTURE_TYPE_FENCE_CREATE_INFO = 8, + VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO = 9, + VK_STRUCTURE_TYPE_EVENT_CREATE_INFO = 10, + VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO = 11, + VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO = 12, + VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO = 13, + VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO = 14, + VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO = 15, + VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO = 16, + VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO = 17, + VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO = 18, + VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO = 19, + VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO = 20, + VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO = 21, + VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO = 22, + VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO = 23, + VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO = 24, + VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO = 25, + VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO = 26, + VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO = 27, + VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO = 28, + VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO = 29, + VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO = 30, + VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO = 31, + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO = 32, + VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO = 33, + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO = 34, + VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET = 35, + VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET = 36, + VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO = 37, + VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO = 38, + VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO = 39, + VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO = 40, + VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO = 41, + VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO = 42, + VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO = 43, + VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER = 44, + VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER = 45, + VK_STRUCTURE_TYPE_MEMORY_BARRIER = 46, + VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO = 47, + VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO = 48, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES = 1000094000, + VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO = 1000157000, + VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO = 1000157001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES = 1000083000, + VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS = 1000127000, + VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO = 1000127001, + VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO = 1000060000, + VK_STRUCTURE_TYPE_DEVICE_GROUP_RENDER_PASS_BEGIN_INFO = 1000060003, + VK_STRUCTURE_TYPE_DEVICE_GROUP_COMMAND_BUFFER_BEGIN_INFO = 1000060004, + VK_STRUCTURE_TYPE_DEVICE_GROUP_SUBMIT_INFO = 1000060005, + VK_STRUCTURE_TYPE_DEVICE_GROUP_BIND_SPARSE_INFO = 1000060006, + VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_DEVICE_GROUP_INFO = 1000060013, + VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_DEVICE_GROUP_INFO = 1000060014, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GROUP_PROPERTIES = 1000070000, + VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO = 1000070001, + VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2 = 1000146000, + VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2 = 1000146001, + VK_STRUCTURE_TYPE_IMAGE_SPARSE_MEMORY_REQUIREMENTS_INFO_2 = 1000146002, + VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2 = 1000146003, + VK_STRUCTURE_TYPE_SPARSE_IMAGE_MEMORY_REQUIREMENTS_2 = 1000146004, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2 = 1000059000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2 = 1000059001, + VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2 = 1000059002, + VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2 = 1000059003, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2 = 1000059004, + VK_STRUCTURE_TYPE_QUEUE_FAMILY_PROPERTIES_2 = 1000059005, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2 = 1000059006, + VK_STRUCTURE_TYPE_SPARSE_IMAGE_FORMAT_PROPERTIES_2 = 1000059007, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SPARSE_IMAGE_FORMAT_INFO_2 = 1000059008, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES = 1000117000, + VK_STRUCTURE_TYPE_RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO = 1000117001, + VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO = 1000117002, + VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO = 1000117003, + VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO = 1000053000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES = 1000053001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES = 1000053002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES = 1000120000, + VK_STRUCTURE_TYPE_PROTECTED_SUBMIT_INFO = 1000145000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES = 1000145001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_PROPERTIES = 1000145002, + VK_STRUCTURE_TYPE_DEVICE_QUEUE_INFO_2 = 1000145003, + VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_CREATE_INFO = 1000156000, + VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO = 1000156001, + VK_STRUCTURE_TYPE_BIND_IMAGE_PLANE_MEMORY_INFO = 1000156002, + VK_STRUCTURE_TYPE_IMAGE_PLANE_MEMORY_REQUIREMENTS_INFO = 1000156003, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES = 1000156004, + VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_IMAGE_FORMAT_PROPERTIES = 1000156005, + VK_STRUCTURE_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO = 1000085000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO = 1000071000, + VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES = 1000071001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_BUFFER_INFO = 1000071002, + VK_STRUCTURE_TYPE_EXTERNAL_BUFFER_PROPERTIES = 1000071003, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES = 1000071004, + VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO = 1000072000, + VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO = 1000072001, + VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO = 1000072002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_FENCE_INFO = 1000112000, + VK_STRUCTURE_TYPE_EXTERNAL_FENCE_PROPERTIES = 1000112001, + VK_STRUCTURE_TYPE_EXPORT_FENCE_CREATE_INFO = 1000113000, + VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO = 1000077000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_SEMAPHORE_INFO = 1000076000, + VK_STRUCTURE_TYPE_EXTERNAL_SEMAPHORE_PROPERTIES = 1000076001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES = 1000168000, + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_SUPPORT = 1000168001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES = 1000063000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES = 49, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_PROPERTIES = 50, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES = 51, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_PROPERTIES = 52, + VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO = 1000147000, + VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2 = 1000109000, + VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2 = 1000109001, + VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_2 = 1000109002, + VK_STRUCTURE_TYPE_SUBPASS_DEPENDENCY_2 = 1000109003, + VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO_2 = 1000109004, + VK_STRUCTURE_TYPE_SUBPASS_BEGIN_INFO = 1000109005, + VK_STRUCTURE_TYPE_SUBPASS_END_INFO = 1000109006, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES = 1000177000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES = 1000196000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES = 1000180000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES = 1000082000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FLOAT_CONTROLS_PROPERTIES = 1000197000, + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO = 1000161000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES = 1000161001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_PROPERTIES = 1000161002, + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO = 1000161003, + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_LAYOUT_SUPPORT = 1000161004, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES = 1000199000, + VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE = 1000199001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES = 1000221000, + VK_STRUCTURE_TYPE_IMAGE_STENCIL_USAGE_CREATE_INFO = 1000246000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES = 1000130000, + VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO = 1000130001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES = 1000211000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES = 1000108000, + VK_STRUCTURE_TYPE_FRAMEBUFFER_ATTACHMENTS_CREATE_INFO = 1000108001, + VK_STRUCTURE_TYPE_FRAMEBUFFER_ATTACHMENT_IMAGE_INFO = 1000108002, + VK_STRUCTURE_TYPE_RENDER_PASS_ATTACHMENT_BEGIN_INFO = 1000108003, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES = 1000253000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES = 1000175000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES = 1000241000, + VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_STENCIL_LAYOUT = 1000241001, + VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_STENCIL_LAYOUT = 1000241002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES = 1000261000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES = 1000207000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_PROPERTIES = 1000207001, + VK_STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO = 1000207002, + VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO = 1000207003, + VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO = 1000207004, + VK_STRUCTURE_TYPE_SEMAPHORE_SIGNAL_INFO = 1000207005, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES = 1000257000, + VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO = 1000244001, + VK_STRUCTURE_TYPE_BUFFER_OPAQUE_CAPTURE_ADDRESS_CREATE_INFO = 1000257002, + VK_STRUCTURE_TYPE_MEMORY_OPAQUE_CAPTURE_ADDRESS_ALLOCATE_INFO = 1000257003, + VK_STRUCTURE_TYPE_DEVICE_MEMORY_OPAQUE_CAPTURE_ADDRESS_INFO = 1000257004, + VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR = 1000001000, + VK_STRUCTURE_TYPE_PRESENT_INFO_KHR = 1000001001, + VK_STRUCTURE_TYPE_DEVICE_GROUP_PRESENT_CAPABILITIES_KHR = 1000060007, + VK_STRUCTURE_TYPE_IMAGE_SWAPCHAIN_CREATE_INFO_KHR = 1000060008, + VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR = 1000060009, + VK_STRUCTURE_TYPE_ACQUIRE_NEXT_IMAGE_INFO_KHR = 1000060010, + VK_STRUCTURE_TYPE_DEVICE_GROUP_PRESENT_INFO_KHR = 1000060011, + VK_STRUCTURE_TYPE_DEVICE_GROUP_SWAPCHAIN_CREATE_INFO_KHR = 1000060012, + VK_STRUCTURE_TYPE_DISPLAY_MODE_CREATE_INFO_KHR = 1000002000, + VK_STRUCTURE_TYPE_DISPLAY_SURFACE_CREATE_INFO_KHR = 1000002001, + VK_STRUCTURE_TYPE_DISPLAY_PRESENT_INFO_KHR = 1000003000, + VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR = 1000004000, + VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR = 1000005000, + VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR = 1000006000, + VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR = 1000008000, + VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR = 1000009000, + VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT = 1000011000, + VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_RASTERIZATION_ORDER_AMD = 1000018000, + VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT = 1000022000, + VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_TAG_INFO_EXT = 1000022001, + VK_STRUCTURE_TYPE_DEBUG_MARKER_MARKER_INFO_EXT = 1000022002, + VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_IMAGE_CREATE_INFO_NV = 1000026000, + VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_BUFFER_CREATE_INFO_NV = 1000026001, + VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV = 1000026002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_FEATURES_EXT = 1000028000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_PROPERTIES_EXT = 1000028001, + VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_STREAM_CREATE_INFO_EXT = 1000028002, + VK_STRUCTURE_TYPE_IMAGE_VIEW_HANDLE_INFO_NVX = 1000030000, + VK_STRUCTURE_TYPE_TEXTURE_LOD_GATHER_FORMAT_PROPERTIES_AMD = 1000041000, + VK_STRUCTURE_TYPE_STREAM_DESCRIPTOR_SURFACE_CREATE_INFO_GGP = 1000049000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CORNER_SAMPLED_IMAGE_FEATURES_NV = 1000050000, + VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO_NV = 1000056000, + VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO_NV = 1000056001, + VK_STRUCTURE_TYPE_IMPORT_MEMORY_WIN32_HANDLE_INFO_NV = 1000057000, + VK_STRUCTURE_TYPE_EXPORT_MEMORY_WIN32_HANDLE_INFO_NV = 1000057001, + VK_STRUCTURE_TYPE_WIN32_KEYED_MUTEX_ACQUIRE_RELEASE_INFO_NV = 1000058000, + VK_STRUCTURE_TYPE_VALIDATION_FLAGS_EXT = 1000061000, + VK_STRUCTURE_TYPE_VI_SURFACE_CREATE_INFO_NN = 1000062000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXTURE_COMPRESSION_ASTC_HDR_FEATURES_EXT = 1000066000, + VK_STRUCTURE_TYPE_IMAGE_VIEW_ASTC_DECODE_MODE_EXT = 1000067000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ASTC_DECODE_FEATURES_EXT = 1000067001, + VK_STRUCTURE_TYPE_IMPORT_MEMORY_WIN32_HANDLE_INFO_KHR = 1000073000, + VK_STRUCTURE_TYPE_EXPORT_MEMORY_WIN32_HANDLE_INFO_KHR = 1000073001, + VK_STRUCTURE_TYPE_MEMORY_WIN32_HANDLE_PROPERTIES_KHR = 1000073002, + VK_STRUCTURE_TYPE_MEMORY_GET_WIN32_HANDLE_INFO_KHR = 1000073003, + VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHR = 1000074000, + VK_STRUCTURE_TYPE_MEMORY_FD_PROPERTIES_KHR = 1000074001, + VK_STRUCTURE_TYPE_MEMORY_GET_FD_INFO_KHR = 1000074002, + VK_STRUCTURE_TYPE_WIN32_KEYED_MUTEX_ACQUIRE_RELEASE_INFO_KHR = 1000075000, + VK_STRUCTURE_TYPE_IMPORT_SEMAPHORE_WIN32_HANDLE_INFO_KHR = 1000078000, + VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_WIN32_HANDLE_INFO_KHR = 1000078001, + VK_STRUCTURE_TYPE_D3D12_FENCE_SUBMIT_INFO_KHR = 1000078002, + VK_STRUCTURE_TYPE_SEMAPHORE_GET_WIN32_HANDLE_INFO_KHR = 1000078003, + VK_STRUCTURE_TYPE_IMPORT_SEMAPHORE_FD_INFO_KHR = 1000079000, + VK_STRUCTURE_TYPE_SEMAPHORE_GET_FD_INFO_KHR = 1000079001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PUSH_DESCRIPTOR_PROPERTIES_KHR = 1000080000, + VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT = 1000081000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CONDITIONAL_RENDERING_FEATURES_EXT = 1000081001, + VK_STRUCTURE_TYPE_CONDITIONAL_RENDERING_BEGIN_INFO_EXT = 1000081002, + VK_STRUCTURE_TYPE_PRESENT_REGIONS_KHR = 1000084000, + VK_STRUCTURE_TYPE_OBJECT_TABLE_CREATE_INFO_NVX = 1000086000, + VK_STRUCTURE_TYPE_INDIRECT_COMMANDS_LAYOUT_CREATE_INFO_NVX = 1000086001, + VK_STRUCTURE_TYPE_CMD_PROCESS_COMMANDS_INFO_NVX = 1000086002, + VK_STRUCTURE_TYPE_CMD_RESERVE_SPACE_FOR_COMMANDS_INFO_NVX = 1000086003, + VK_STRUCTURE_TYPE_DEVICE_GENERATED_COMMANDS_LIMITS_NVX = 1000086004, + VK_STRUCTURE_TYPE_DEVICE_GENERATED_COMMANDS_FEATURES_NVX = 1000086005, + VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV = 1000087000, + VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_EXT = 1000090000, + VK_STRUCTURE_TYPE_DISPLAY_POWER_INFO_EXT = 1000091000, + VK_STRUCTURE_TYPE_DEVICE_EVENT_INFO_EXT = 1000091001, + VK_STRUCTURE_TYPE_DISPLAY_EVENT_INFO_EXT = 1000091002, + VK_STRUCTURE_TYPE_SWAPCHAIN_COUNTER_CREATE_INFO_EXT = 1000091003, + VK_STRUCTURE_TYPE_PRESENT_TIMES_INFO_GOOGLE = 1000092000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PER_VIEW_ATTRIBUTES_PROPERTIES_NVX = 1000097000, + VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV = 1000098000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DISCARD_RECTANGLE_PROPERTIES_EXT = 1000099000, + VK_STRUCTURE_TYPE_PIPELINE_DISCARD_RECTANGLE_STATE_CREATE_INFO_EXT = 1000099001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CONSERVATIVE_RASTERIZATION_PROPERTIES_EXT = 1000101000, + VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_CONSERVATIVE_STATE_CREATE_INFO_EXT = 1000101001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLIP_ENABLE_FEATURES_EXT = 1000102000, + VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_DEPTH_CLIP_STATE_CREATE_INFO_EXT = 1000102001, + VK_STRUCTURE_TYPE_HDR_METADATA_EXT = 1000105000, + VK_STRUCTURE_TYPE_SHARED_PRESENT_SURFACE_CAPABILITIES_KHR = 1000111000, + VK_STRUCTURE_TYPE_IMPORT_FENCE_WIN32_HANDLE_INFO_KHR = 1000114000, + VK_STRUCTURE_TYPE_EXPORT_FENCE_WIN32_HANDLE_INFO_KHR = 1000114001, + VK_STRUCTURE_TYPE_FENCE_GET_WIN32_HANDLE_INFO_KHR = 1000114002, + VK_STRUCTURE_TYPE_IMPORT_FENCE_FD_INFO_KHR = 1000115000, + VK_STRUCTURE_TYPE_FENCE_GET_FD_INFO_KHR = 1000115001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PERFORMANCE_QUERY_FEATURES_KHR = 1000116000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PERFORMANCE_QUERY_PROPERTIES_KHR = 1000116001, + VK_STRUCTURE_TYPE_QUERY_POOL_PERFORMANCE_CREATE_INFO_KHR = 1000116002, + VK_STRUCTURE_TYPE_PERFORMANCE_QUERY_SUBMIT_INFO_KHR = 1000116003, + VK_STRUCTURE_TYPE_ACQUIRE_PROFILING_LOCK_INFO_KHR = 1000116004, + VK_STRUCTURE_TYPE_PERFORMANCE_COUNTER_KHR = 1000116005, + VK_STRUCTURE_TYPE_PERFORMANCE_COUNTER_DESCRIPTION_KHR = 1000116006, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR = 1000119000, + VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_KHR = 1000119001, + VK_STRUCTURE_TYPE_SURFACE_FORMAT_2_KHR = 1000119002, + VK_STRUCTURE_TYPE_DISPLAY_PROPERTIES_2_KHR = 1000121000, + VK_STRUCTURE_TYPE_DISPLAY_PLANE_PROPERTIES_2_KHR = 1000121001, + VK_STRUCTURE_TYPE_DISPLAY_MODE_PROPERTIES_2_KHR = 1000121002, + VK_STRUCTURE_TYPE_DISPLAY_PLANE_INFO_2_KHR = 1000121003, + VK_STRUCTURE_TYPE_DISPLAY_PLANE_CAPABILITIES_2_KHR = 1000121004, + VK_STRUCTURE_TYPE_IOS_SURFACE_CREATE_INFO_MVK = 1000122000, + VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK = 1000123000, + VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT = 1000128000, + VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_TAG_INFO_EXT = 1000128001, + VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT = 1000128002, + VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CALLBACK_DATA_EXT = 1000128003, + VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT = 1000128004, + VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_USAGE_ANDROID = 1000129000, + VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_PROPERTIES_ANDROID = 1000129001, + VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_FORMAT_PROPERTIES_ANDROID = 1000129002, + VK_STRUCTURE_TYPE_IMPORT_ANDROID_HARDWARE_BUFFER_INFO_ANDROID = 1000129003, + VK_STRUCTURE_TYPE_MEMORY_GET_ANDROID_HARDWARE_BUFFER_INFO_ANDROID = 1000129004, + VK_STRUCTURE_TYPE_EXTERNAL_FORMAT_ANDROID = 1000129005, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_FEATURES_EXT = 1000138000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_PROPERTIES_EXT = 1000138001, + VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_INLINE_UNIFORM_BLOCK_EXT = 1000138002, + VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_INLINE_UNIFORM_BLOCK_CREATE_INFO_EXT = 1000138003, + VK_STRUCTURE_TYPE_SAMPLE_LOCATIONS_INFO_EXT = 1000143000, + VK_STRUCTURE_TYPE_RENDER_PASS_SAMPLE_LOCATIONS_BEGIN_INFO_EXT = 1000143001, + VK_STRUCTURE_TYPE_PIPELINE_SAMPLE_LOCATIONS_STATE_CREATE_INFO_EXT = 1000143002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLE_LOCATIONS_PROPERTIES_EXT = 1000143003, + VK_STRUCTURE_TYPE_MULTISAMPLE_PROPERTIES_EXT = 1000143004, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_FEATURES_EXT = 1000148000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_PROPERTIES_EXT = 1000148001, + VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT = 1000148002, + VK_STRUCTURE_TYPE_PIPELINE_COVERAGE_TO_COLOR_STATE_CREATE_INFO_NV = 1000149000, + VK_STRUCTURE_TYPE_PIPELINE_COVERAGE_MODULATION_STATE_CREATE_INFO_NV = 1000152000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SM_BUILTINS_FEATURES_NV = 1000154000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SM_BUILTINS_PROPERTIES_NV = 1000154001, + VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT = 1000158000, + VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_EXT = 1000158001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_DRM_FORMAT_MODIFIER_INFO_EXT = 1000158002, + VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_LIST_CREATE_INFO_EXT = 1000158003, + VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_EXPLICIT_CREATE_INFO_EXT = 1000158004, + VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_PROPERTIES_EXT = 1000158005, + VK_STRUCTURE_TYPE_VALIDATION_CACHE_CREATE_INFO_EXT = 1000160000, + VK_STRUCTURE_TYPE_SHADER_MODULE_VALIDATION_CACHE_CREATE_INFO_EXT = 1000160001, + VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV = 1000164000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADING_RATE_IMAGE_FEATURES_NV = 1000164001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADING_RATE_IMAGE_PROPERTIES_NV = 1000164002, + VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV = 1000164005, + VK_STRUCTURE_TYPE_RAY_TRACING_PIPELINE_CREATE_INFO_NV = 1000165000, + VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_CREATE_INFO_NV = 1000165001, + VK_STRUCTURE_TYPE_GEOMETRY_NV = 1000165003, + VK_STRUCTURE_TYPE_GEOMETRY_TRIANGLES_NV = 1000165004, + VK_STRUCTURE_TYPE_GEOMETRY_AABB_NV = 1000165005, + VK_STRUCTURE_TYPE_BIND_ACCELERATION_STRUCTURE_MEMORY_INFO_NV = 1000165006, + VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_NV = 1000165007, + VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_INFO_NV = 1000165008, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PROPERTIES_NV = 1000165009, + VK_STRUCTURE_TYPE_RAY_TRACING_SHADER_GROUP_CREATE_INFO_NV = 1000165011, + VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_INFO_NV = 1000165012, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_REPRESENTATIVE_FRAGMENT_TEST_FEATURES_NV = 1000166000, + VK_STRUCTURE_TYPE_PIPELINE_REPRESENTATIVE_FRAGMENT_TEST_STATE_CREATE_INFO_NV = 1000166001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_VIEW_IMAGE_FORMAT_INFO_EXT = 1000170000, + VK_STRUCTURE_TYPE_FILTER_CUBIC_IMAGE_VIEW_IMAGE_FORMAT_PROPERTIES_EXT = 1000170001, + VK_STRUCTURE_TYPE_DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_EXT = 1000174000, + VK_STRUCTURE_TYPE_IMPORT_MEMORY_HOST_POINTER_INFO_EXT = 1000178000, + VK_STRUCTURE_TYPE_MEMORY_HOST_POINTER_PROPERTIES_EXT = 1000178001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_MEMORY_HOST_PROPERTIES_EXT = 1000178002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_CLOCK_FEATURES_KHR = 1000181000, + VK_STRUCTURE_TYPE_PIPELINE_COMPILER_CONTROL_CREATE_INFO_AMD = 1000183000, + VK_STRUCTURE_TYPE_CALIBRATED_TIMESTAMP_INFO_EXT = 1000184000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_CORE_PROPERTIES_AMD = 1000185000, + VK_STRUCTURE_TYPE_DEVICE_MEMORY_OVERALLOCATION_CREATE_INFO_AMD = 1000189000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_PROPERTIES_EXT = 1000190000, + VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT = 1000190001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_FEATURES_EXT = 1000190002, + VK_STRUCTURE_TYPE_PRESENT_FRAME_TOKEN_GGP = 1000191000, + VK_STRUCTURE_TYPE_PIPELINE_CREATION_FEEDBACK_CREATE_INFO_EXT = 1000192000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COMPUTE_SHADER_DERIVATIVES_FEATURES_NV = 1000201000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MESH_SHADER_FEATURES_NV = 1000202000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MESH_SHADER_PROPERTIES_NV = 1000202001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_FEATURES_NV = 1000203000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_IMAGE_FOOTPRINT_FEATURES_NV = 1000204000, + VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV = 1000205000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXCLUSIVE_SCISSOR_FEATURES_NV = 1000205002, + VK_STRUCTURE_TYPE_CHECKPOINT_DATA_NV = 1000206000, + VK_STRUCTURE_TYPE_QUEUE_FAMILY_CHECKPOINT_PROPERTIES_NV = 1000206001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_FUNCTIONS_2_FEATURES_INTEL = 1000209000, + VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO_INTEL = 1000210000, + VK_STRUCTURE_TYPE_INITIALIZE_PERFORMANCE_API_INFO_INTEL = 1000210001, + VK_STRUCTURE_TYPE_PERFORMANCE_MARKER_INFO_INTEL = 1000210002, + VK_STRUCTURE_TYPE_PERFORMANCE_STREAM_MARKER_INFO_INTEL = 1000210003, + VK_STRUCTURE_TYPE_PERFORMANCE_OVERRIDE_INFO_INTEL = 1000210004, + VK_STRUCTURE_TYPE_PERFORMANCE_CONFIGURATION_ACQUIRE_INFO_INTEL = 1000210005, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT = 1000212000, + VK_STRUCTURE_TYPE_DISPLAY_NATIVE_HDR_SURFACE_CAPABILITIES_AMD = 1000213000, + VK_STRUCTURE_TYPE_SWAPCHAIN_DISPLAY_NATIVE_HDR_CREATE_INFO_AMD = 1000213001, + VK_STRUCTURE_TYPE_IMAGEPIPE_SURFACE_CREATE_INFO_FUCHSIA = 1000214000, + VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT = 1000217000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_FEATURES_EXT = 1000218000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_PROPERTIES_EXT = 1000218001, + VK_STRUCTURE_TYPE_RENDER_PASS_FRAGMENT_DENSITY_MAP_CREATE_INFO_EXT = 1000218002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_PROPERTIES_EXT = 1000225000, + VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_REQUIRED_SUBGROUP_SIZE_CREATE_INFO_EXT = 1000225001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_FEATURES_EXT = 1000225002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_CORE_PROPERTIES_2_AMD = 1000227000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COHERENT_MEMORY_FEATURES_AMD = 1000229000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_BUDGET_PROPERTIES_EXT = 1000237000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PRIORITY_FEATURES_EXT = 1000238000, + VK_STRUCTURE_TYPE_MEMORY_PRIORITY_ALLOCATE_INFO_EXT = 1000238001, + VK_STRUCTURE_TYPE_SURFACE_PROTECTED_CAPABILITIES_KHR = 1000239000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEDICATED_ALLOCATION_IMAGE_ALIASING_FEATURES_NV = 1000240000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_EXT = 1000244000, + VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_CREATE_INFO_EXT = 1000244002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TOOL_PROPERTIES_EXT = 1000245000, + VK_STRUCTURE_TYPE_VALIDATION_FEATURES_EXT = 1000247000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_NV = 1000249000, + VK_STRUCTURE_TYPE_COOPERATIVE_MATRIX_PROPERTIES_NV = 1000249001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_PROPERTIES_NV = 1000249002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COVERAGE_REDUCTION_MODE_FEATURES_NV = 1000250000, + VK_STRUCTURE_TYPE_PIPELINE_COVERAGE_REDUCTION_STATE_CREATE_INFO_NV = 1000250001, + VK_STRUCTURE_TYPE_FRAMEBUFFER_MIXED_SAMPLES_COMBINATION_NV = 1000250002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_INTERLOCK_FEATURES_EXT = 1000251000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_YCBCR_IMAGE_ARRAYS_FEATURES_EXT = 1000252000, + VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT = 1000255000, + VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_FULL_SCREEN_EXCLUSIVE_EXT = 1000255002, + VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT = 1000255001, + VK_STRUCTURE_TYPE_HEADLESS_SURFACE_CREATE_INFO_EXT = 1000256000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINE_RASTERIZATION_FEATURES_EXT = 1000259000, + VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_LINE_STATE_CREATE_INFO_EXT = 1000259001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINE_RASTERIZATION_PROPERTIES_EXT = 1000259002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INDEX_TYPE_UINT8_FEATURES_EXT = 1000265000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_EXECUTABLE_PROPERTIES_FEATURES_KHR = 1000269000, + VK_STRUCTURE_TYPE_PIPELINE_INFO_KHR = 1000269001, + VK_STRUCTURE_TYPE_PIPELINE_EXECUTABLE_PROPERTIES_KHR = 1000269002, + VK_STRUCTURE_TYPE_PIPELINE_EXECUTABLE_INFO_KHR = 1000269003, + VK_STRUCTURE_TYPE_PIPELINE_EXECUTABLE_STATISTIC_KHR = 1000269004, + VK_STRUCTURE_TYPE_PIPELINE_EXECUTABLE_INTERNAL_REPRESENTATION_KHR = 1000269005, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES_EXT = 1000276000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_FEATURES_EXT = 1000281000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_PROPERTIES_EXT = 1000281001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETER_FEATURES = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES, + VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT, + VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, + VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2_KHR = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2, + VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2_KHR = VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2, + VK_STRUCTURE_TYPE_QUEUE_FAMILY_PROPERTIES_2_KHR = VK_STRUCTURE_TYPE_QUEUE_FAMILY_PROPERTIES_2, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2, + VK_STRUCTURE_TYPE_SPARSE_IMAGE_FORMAT_PROPERTIES_2_KHR = VK_STRUCTURE_TYPE_SPARSE_IMAGE_FORMAT_PROPERTIES_2, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SPARSE_IMAGE_FORMAT_INFO_2_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SPARSE_IMAGE_FORMAT_INFO_2, + VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO_KHR = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO, + VK_STRUCTURE_TYPE_DEVICE_GROUP_RENDER_PASS_BEGIN_INFO_KHR = VK_STRUCTURE_TYPE_DEVICE_GROUP_RENDER_PASS_BEGIN_INFO, + VK_STRUCTURE_TYPE_DEVICE_GROUP_COMMAND_BUFFER_BEGIN_INFO_KHR = VK_STRUCTURE_TYPE_DEVICE_GROUP_COMMAND_BUFFER_BEGIN_INFO, + VK_STRUCTURE_TYPE_DEVICE_GROUP_SUBMIT_INFO_KHR = VK_STRUCTURE_TYPE_DEVICE_GROUP_SUBMIT_INFO, + VK_STRUCTURE_TYPE_DEVICE_GROUP_BIND_SPARSE_INFO_KHR = VK_STRUCTURE_TYPE_DEVICE_GROUP_BIND_SPARSE_INFO, + VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_DEVICE_GROUP_INFO_KHR = VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_DEVICE_GROUP_INFO, + VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_DEVICE_GROUP_INFO_KHR = VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_DEVICE_GROUP_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GROUP_PROPERTIES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GROUP_PROPERTIES, + VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO, + VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES_KHR = VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_BUFFER_INFO_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_BUFFER_INFO, + VK_STRUCTURE_TYPE_EXTERNAL_BUFFER_PROPERTIES_KHR = VK_STRUCTURE_TYPE_EXTERNAL_BUFFER_PROPERTIES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES, + VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO, + VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO, + VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO_KHR = VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_SEMAPHORE_INFO_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_SEMAPHORE_INFO, + VK_STRUCTURE_TYPE_EXTERNAL_SEMAPHORE_PROPERTIES_KHR = VK_STRUCTURE_TYPE_EXTERNAL_SEMAPHORE_PROPERTIES, + VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FLOAT16_INT8_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES, + VK_STRUCTURE_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO, + VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES2_EXT = VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_EXT, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES, + VK_STRUCTURE_TYPE_FRAMEBUFFER_ATTACHMENTS_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_FRAMEBUFFER_ATTACHMENTS_CREATE_INFO, + VK_STRUCTURE_TYPE_FRAMEBUFFER_ATTACHMENT_IMAGE_INFO_KHR = VK_STRUCTURE_TYPE_FRAMEBUFFER_ATTACHMENT_IMAGE_INFO, + VK_STRUCTURE_TYPE_RENDER_PASS_ATTACHMENT_BEGIN_INFO_KHR = VK_STRUCTURE_TYPE_RENDER_PASS_ATTACHMENT_BEGIN_INFO, + VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2_KHR = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2, + VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2_KHR = VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2, + VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_2_KHR = VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_2, + VK_STRUCTURE_TYPE_SUBPASS_DEPENDENCY_2_KHR = VK_STRUCTURE_TYPE_SUBPASS_DEPENDENCY_2, + VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO_2_KHR = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO_2, + VK_STRUCTURE_TYPE_SUBPASS_BEGIN_INFO_KHR = VK_STRUCTURE_TYPE_SUBPASS_BEGIN_INFO, + VK_STRUCTURE_TYPE_SUBPASS_END_INFO_KHR = VK_STRUCTURE_TYPE_SUBPASS_END_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_FENCE_INFO_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_FENCE_INFO, + VK_STRUCTURE_TYPE_EXTERNAL_FENCE_PROPERTIES_KHR = VK_STRUCTURE_TYPE_EXTERNAL_FENCE_PROPERTIES, + VK_STRUCTURE_TYPE_EXPORT_FENCE_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_EXPORT_FENCE_CREATE_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES, + VK_STRUCTURE_TYPE_RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO, + VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO, + VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES, + VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS_KHR = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS, + VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO_KHR = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES, + VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO_EXT = VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO, + VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2_KHR = VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2, + VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2_KHR = VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2, + VK_STRUCTURE_TYPE_IMAGE_SPARSE_MEMORY_REQUIREMENTS_INFO_2_KHR = VK_STRUCTURE_TYPE_IMAGE_SPARSE_MEMORY_REQUIREMENTS_INFO_2, + VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2_KHR = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2, + VK_STRUCTURE_TYPE_SPARSE_IMAGE_MEMORY_REQUIREMENTS_2_KHR = VK_STRUCTURE_TYPE_SPARSE_IMAGE_MEMORY_REQUIREMENTS_2, + VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO, + VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_CREATE_INFO, + VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO_KHR = VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO, + VK_STRUCTURE_TYPE_BIND_IMAGE_PLANE_MEMORY_INFO_KHR = VK_STRUCTURE_TYPE_BIND_IMAGE_PLANE_MEMORY_INFO, + VK_STRUCTURE_TYPE_IMAGE_PLANE_MEMORY_REQUIREMENTS_INFO_KHR = VK_STRUCTURE_TYPE_IMAGE_PLANE_MEMORY_REQUIREMENTS_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES, + VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_IMAGE_FORMAT_PROPERTIES_KHR = VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_IMAGE_FORMAT_PROPERTIES, + VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO_KHR = VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO, + VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO_KHR = VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO, + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO_EXT = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_PROPERTIES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_PROPERTIES, + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO_EXT = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO, + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_LAYOUT_SUPPORT_EXT = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_LAYOUT_SUPPORT, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES, + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_SUPPORT_KHR = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_SUPPORT, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FLOAT_CONTROLS_PROPERTIES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FLOAT_CONTROLS_PROPERTIES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES, + VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE_KHR = VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_PROPERTIES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_PROPERTIES, + VK_STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO, + VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO_KHR = VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO, + VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO_KHR = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO, + VK_STRUCTURE_TYPE_SEMAPHORE_SIGNAL_INFO_KHR = VK_STRUCTURE_TYPE_SEMAPHORE_SIGNAL_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES, + VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_STENCIL_LAYOUT_KHR = VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_STENCIL_LAYOUT, + VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_STENCIL_LAYOUT_KHR = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_STENCIL_LAYOUT, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_ADDRESS_FEATURES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_EXT, + VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO_EXT = VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO, + VK_STRUCTURE_TYPE_IMAGE_STENCIL_USAGE_CREATE_INFO_EXT = VK_STRUCTURE_TYPE_IMAGE_STENCIL_USAGE_CREATE_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES, + VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO_KHR = VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO, + VK_STRUCTURE_TYPE_BUFFER_OPAQUE_CAPTURE_ADDRESS_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_BUFFER_OPAQUE_CAPTURE_ADDRESS_CREATE_INFO, + VK_STRUCTURE_TYPE_MEMORY_OPAQUE_CAPTURE_ADDRESS_ALLOCATE_INFO_KHR = VK_STRUCTURE_TYPE_MEMORY_OPAQUE_CAPTURE_ADDRESS_ALLOCATE_INFO, + VK_STRUCTURE_TYPE_DEVICE_MEMORY_OPAQUE_CAPTURE_ADDRESS_INFO_KHR = VK_STRUCTURE_TYPE_DEVICE_MEMORY_OPAQUE_CAPTURE_ADDRESS_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES, + VK_STRUCTURE_TYPE_BEGIN_RANGE = VK_STRUCTURE_TYPE_APPLICATION_INFO, + VK_STRUCTURE_TYPE_END_RANGE = VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO, + VK_STRUCTURE_TYPE_RANGE_SIZE = (VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO - VK_STRUCTURE_TYPE_APPLICATION_INFO + 1), + VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF +} VkStructureType; + +typedef enum VkSystemAllocationScope { + VK_SYSTEM_ALLOCATION_SCOPE_COMMAND = 0, + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT = 1, + VK_SYSTEM_ALLOCATION_SCOPE_CACHE = 2, + VK_SYSTEM_ALLOCATION_SCOPE_DEVICE = 3, + VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE = 4, + VK_SYSTEM_ALLOCATION_SCOPE_BEGIN_RANGE = VK_SYSTEM_ALLOCATION_SCOPE_COMMAND, + VK_SYSTEM_ALLOCATION_SCOPE_END_RANGE = VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE, + VK_SYSTEM_ALLOCATION_SCOPE_RANGE_SIZE = (VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE - VK_SYSTEM_ALLOCATION_SCOPE_COMMAND + 1), + VK_SYSTEM_ALLOCATION_SCOPE_MAX_ENUM = 0x7FFFFFFF +} VkSystemAllocationScope; + +typedef enum VkInternalAllocationType { + VK_INTERNAL_ALLOCATION_TYPE_EXECUTABLE = 0, + VK_INTERNAL_ALLOCATION_TYPE_BEGIN_RANGE = VK_INTERNAL_ALLOCATION_TYPE_EXECUTABLE, + VK_INTERNAL_ALLOCATION_TYPE_END_RANGE = VK_INTERNAL_ALLOCATION_TYPE_EXECUTABLE, + VK_INTERNAL_ALLOCATION_TYPE_RANGE_SIZE = (VK_INTERNAL_ALLOCATION_TYPE_EXECUTABLE - VK_INTERNAL_ALLOCATION_TYPE_EXECUTABLE + 1), + VK_INTERNAL_ALLOCATION_TYPE_MAX_ENUM = 0x7FFFFFFF +} VkInternalAllocationType; + +typedef enum VkFormat { + VK_FORMAT_UNDEFINED = 0, + VK_FORMAT_R4G4_UNORM_PACK8 = 1, + VK_FORMAT_R4G4B4A4_UNORM_PACK16 = 2, + VK_FORMAT_B4G4R4A4_UNORM_PACK16 = 3, + VK_FORMAT_R5G6B5_UNORM_PACK16 = 4, + VK_FORMAT_B5G6R5_UNORM_PACK16 = 5, + VK_FORMAT_R5G5B5A1_UNORM_PACK16 = 6, + VK_FORMAT_B5G5R5A1_UNORM_PACK16 = 7, + VK_FORMAT_A1R5G5B5_UNORM_PACK16 = 8, + VK_FORMAT_R8_UNORM = 9, + VK_FORMAT_R8_SNORM = 10, + VK_FORMAT_R8_USCALED = 11, + VK_FORMAT_R8_SSCALED = 12, + VK_FORMAT_R8_UINT = 13, + VK_FORMAT_R8_SINT = 14, + VK_FORMAT_R8_SRGB = 15, + VK_FORMAT_R8G8_UNORM = 16, + VK_FORMAT_R8G8_SNORM = 17, + VK_FORMAT_R8G8_USCALED = 18, + VK_FORMAT_R8G8_SSCALED = 19, + VK_FORMAT_R8G8_UINT = 20, + VK_FORMAT_R8G8_SINT = 21, + VK_FORMAT_R8G8_SRGB = 22, + VK_FORMAT_R8G8B8_UNORM = 23, + VK_FORMAT_R8G8B8_SNORM = 24, + VK_FORMAT_R8G8B8_USCALED = 25, + VK_FORMAT_R8G8B8_SSCALED = 26, + VK_FORMAT_R8G8B8_UINT = 27, + VK_FORMAT_R8G8B8_SINT = 28, + VK_FORMAT_R8G8B8_SRGB = 29, + VK_FORMAT_B8G8R8_UNORM = 30, + VK_FORMAT_B8G8R8_SNORM = 31, + VK_FORMAT_B8G8R8_USCALED = 32, + VK_FORMAT_B8G8R8_SSCALED = 33, + VK_FORMAT_B8G8R8_UINT = 34, + VK_FORMAT_B8G8R8_SINT = 35, + VK_FORMAT_B8G8R8_SRGB = 36, + VK_FORMAT_R8G8B8A8_UNORM = 37, + VK_FORMAT_R8G8B8A8_SNORM = 38, + VK_FORMAT_R8G8B8A8_USCALED = 39, + VK_FORMAT_R8G8B8A8_SSCALED = 40, + VK_FORMAT_R8G8B8A8_UINT = 41, + VK_FORMAT_R8G8B8A8_SINT = 42, + VK_FORMAT_R8G8B8A8_SRGB = 43, + VK_FORMAT_B8G8R8A8_UNORM = 44, + VK_FORMAT_B8G8R8A8_SNORM = 45, + VK_FORMAT_B8G8R8A8_USCALED = 46, + VK_FORMAT_B8G8R8A8_SSCALED = 47, + VK_FORMAT_B8G8R8A8_UINT = 48, + VK_FORMAT_B8G8R8A8_SINT = 49, + VK_FORMAT_B8G8R8A8_SRGB = 50, + VK_FORMAT_A8B8G8R8_UNORM_PACK32 = 51, + VK_FORMAT_A8B8G8R8_SNORM_PACK32 = 52, + VK_FORMAT_A8B8G8R8_USCALED_PACK32 = 53, + VK_FORMAT_A8B8G8R8_SSCALED_PACK32 = 54, + VK_FORMAT_A8B8G8R8_UINT_PACK32 = 55, + VK_FORMAT_A8B8G8R8_SINT_PACK32 = 56, + VK_FORMAT_A8B8G8R8_SRGB_PACK32 = 57, + VK_FORMAT_A2R10G10B10_UNORM_PACK32 = 58, + VK_FORMAT_A2R10G10B10_SNORM_PACK32 = 59, + VK_FORMAT_A2R10G10B10_USCALED_PACK32 = 60, + VK_FORMAT_A2R10G10B10_SSCALED_PACK32 = 61, + VK_FORMAT_A2R10G10B10_UINT_PACK32 = 62, + VK_FORMAT_A2R10G10B10_SINT_PACK32 = 63, + VK_FORMAT_A2B10G10R10_UNORM_PACK32 = 64, + VK_FORMAT_A2B10G10R10_SNORM_PACK32 = 65, + VK_FORMAT_A2B10G10R10_USCALED_PACK32 = 66, + VK_FORMAT_A2B10G10R10_SSCALED_PACK32 = 67, + VK_FORMAT_A2B10G10R10_UINT_PACK32 = 68, + VK_FORMAT_A2B10G10R10_SINT_PACK32 = 69, + VK_FORMAT_R16_UNORM = 70, + VK_FORMAT_R16_SNORM = 71, + VK_FORMAT_R16_USCALED = 72, + VK_FORMAT_R16_SSCALED = 73, + VK_FORMAT_R16_UINT = 74, + VK_FORMAT_R16_SINT = 75, + VK_FORMAT_R16_SFLOAT = 76, + VK_FORMAT_R16G16_UNORM = 77, + VK_FORMAT_R16G16_SNORM = 78, + VK_FORMAT_R16G16_USCALED = 79, + VK_FORMAT_R16G16_SSCALED = 80, + VK_FORMAT_R16G16_UINT = 81, + VK_FORMAT_R16G16_SINT = 82, + VK_FORMAT_R16G16_SFLOAT = 83, + VK_FORMAT_R16G16B16_UNORM = 84, + VK_FORMAT_R16G16B16_SNORM = 85, + VK_FORMAT_R16G16B16_USCALED = 86, + VK_FORMAT_R16G16B16_SSCALED = 87, + VK_FORMAT_R16G16B16_UINT = 88, + VK_FORMAT_R16G16B16_SINT = 89, + VK_FORMAT_R16G16B16_SFLOAT = 90, + VK_FORMAT_R16G16B16A16_UNORM = 91, + VK_FORMAT_R16G16B16A16_SNORM = 92, + VK_FORMAT_R16G16B16A16_USCALED = 93, + VK_FORMAT_R16G16B16A16_SSCALED = 94, + VK_FORMAT_R16G16B16A16_UINT = 95, + VK_FORMAT_R16G16B16A16_SINT = 96, + VK_FORMAT_R16G16B16A16_SFLOAT = 97, + VK_FORMAT_R32_UINT = 98, + VK_FORMAT_R32_SINT = 99, + VK_FORMAT_R32_SFLOAT = 100, + VK_FORMAT_R32G32_UINT = 101, + VK_FORMAT_R32G32_SINT = 102, + VK_FORMAT_R32G32_SFLOAT = 103, + VK_FORMAT_R32G32B32_UINT = 104, + VK_FORMAT_R32G32B32_SINT = 105, + VK_FORMAT_R32G32B32_SFLOAT = 106, + VK_FORMAT_R32G32B32A32_UINT = 107, + VK_FORMAT_R32G32B32A32_SINT = 108, + VK_FORMAT_R32G32B32A32_SFLOAT = 109, + VK_FORMAT_R64_UINT = 110, + VK_FORMAT_R64_SINT = 111, + VK_FORMAT_R64_SFLOAT = 112, + VK_FORMAT_R64G64_UINT = 113, + VK_FORMAT_R64G64_SINT = 114, + VK_FORMAT_R64G64_SFLOAT = 115, + VK_FORMAT_R64G64B64_UINT = 116, + VK_FORMAT_R64G64B64_SINT = 117, + VK_FORMAT_R64G64B64_SFLOAT = 118, + VK_FORMAT_R64G64B64A64_UINT = 119, + VK_FORMAT_R64G64B64A64_SINT = 120, + VK_FORMAT_R64G64B64A64_SFLOAT = 121, + VK_FORMAT_B10G11R11_UFLOAT_PACK32 = 122, + VK_FORMAT_E5B9G9R9_UFLOAT_PACK32 = 123, + VK_FORMAT_D16_UNORM = 124, + VK_FORMAT_X8_D24_UNORM_PACK32 = 125, + VK_FORMAT_D32_SFLOAT = 126, + VK_FORMAT_S8_UINT = 127, + VK_FORMAT_D16_UNORM_S8_UINT = 128, + VK_FORMAT_D24_UNORM_S8_UINT = 129, + VK_FORMAT_D32_SFLOAT_S8_UINT = 130, + VK_FORMAT_BC1_RGB_UNORM_BLOCK = 131, + VK_FORMAT_BC1_RGB_SRGB_BLOCK = 132, + VK_FORMAT_BC1_RGBA_UNORM_BLOCK = 133, + VK_FORMAT_BC1_RGBA_SRGB_BLOCK = 134, + VK_FORMAT_BC2_UNORM_BLOCK = 135, + VK_FORMAT_BC2_SRGB_BLOCK = 136, + VK_FORMAT_BC3_UNORM_BLOCK = 137, + VK_FORMAT_BC3_SRGB_BLOCK = 138, + VK_FORMAT_BC4_UNORM_BLOCK = 139, + VK_FORMAT_BC4_SNORM_BLOCK = 140, + VK_FORMAT_BC5_UNORM_BLOCK = 141, + VK_FORMAT_BC5_SNORM_BLOCK = 142, + VK_FORMAT_BC6H_UFLOAT_BLOCK = 143, + VK_FORMAT_BC6H_SFLOAT_BLOCK = 144, + VK_FORMAT_BC7_UNORM_BLOCK = 145, + VK_FORMAT_BC7_SRGB_BLOCK = 146, + VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK = 147, + VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK = 148, + VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK = 149, + VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK = 150, + VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK = 151, + VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK = 152, + VK_FORMAT_EAC_R11_UNORM_BLOCK = 153, + VK_FORMAT_EAC_R11_SNORM_BLOCK = 154, + VK_FORMAT_EAC_R11G11_UNORM_BLOCK = 155, + VK_FORMAT_EAC_R11G11_SNORM_BLOCK = 156, + VK_FORMAT_ASTC_4x4_UNORM_BLOCK = 157, + VK_FORMAT_ASTC_4x4_SRGB_BLOCK = 158, + VK_FORMAT_ASTC_5x4_UNORM_BLOCK = 159, + VK_FORMAT_ASTC_5x4_SRGB_BLOCK = 160, + VK_FORMAT_ASTC_5x5_UNORM_BLOCK = 161, + VK_FORMAT_ASTC_5x5_SRGB_BLOCK = 162, + VK_FORMAT_ASTC_6x5_UNORM_BLOCK = 163, + VK_FORMAT_ASTC_6x5_SRGB_BLOCK = 164, + VK_FORMAT_ASTC_6x6_UNORM_BLOCK = 165, + VK_FORMAT_ASTC_6x6_SRGB_BLOCK = 166, + VK_FORMAT_ASTC_8x5_UNORM_BLOCK = 167, + VK_FORMAT_ASTC_8x5_SRGB_BLOCK = 168, + VK_FORMAT_ASTC_8x6_UNORM_BLOCK = 169, + VK_FORMAT_ASTC_8x6_SRGB_BLOCK = 170, + VK_FORMAT_ASTC_8x8_UNORM_BLOCK = 171, + VK_FORMAT_ASTC_8x8_SRGB_BLOCK = 172, + VK_FORMAT_ASTC_10x5_UNORM_BLOCK = 173, + VK_FORMAT_ASTC_10x5_SRGB_BLOCK = 174, + VK_FORMAT_ASTC_10x6_UNORM_BLOCK = 175, + VK_FORMAT_ASTC_10x6_SRGB_BLOCK = 176, + VK_FORMAT_ASTC_10x8_UNORM_BLOCK = 177, + VK_FORMAT_ASTC_10x8_SRGB_BLOCK = 178, + VK_FORMAT_ASTC_10x10_UNORM_BLOCK = 179, + VK_FORMAT_ASTC_10x10_SRGB_BLOCK = 180, + VK_FORMAT_ASTC_12x10_UNORM_BLOCK = 181, + VK_FORMAT_ASTC_12x10_SRGB_BLOCK = 182, + VK_FORMAT_ASTC_12x12_UNORM_BLOCK = 183, + VK_FORMAT_ASTC_12x12_SRGB_BLOCK = 184, + VK_FORMAT_G8B8G8R8_422_UNORM = 1000156000, + VK_FORMAT_B8G8R8G8_422_UNORM = 1000156001, + VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM = 1000156002, + VK_FORMAT_G8_B8R8_2PLANE_420_UNORM = 1000156003, + VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM = 1000156004, + VK_FORMAT_G8_B8R8_2PLANE_422_UNORM = 1000156005, + VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM = 1000156006, + VK_FORMAT_R10X6_UNORM_PACK16 = 1000156007, + VK_FORMAT_R10X6G10X6_UNORM_2PACK16 = 1000156008, + VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16 = 1000156009, + VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16 = 1000156010, + VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 = 1000156011, + VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16 = 1000156012, + VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16 = 1000156013, + VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16 = 1000156014, + VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16 = 1000156015, + VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16 = 1000156016, + VK_FORMAT_R12X4_UNORM_PACK16 = 1000156017, + VK_FORMAT_R12X4G12X4_UNORM_2PACK16 = 1000156018, + VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16 = 1000156019, + VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16 = 1000156020, + VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16 = 1000156021, + VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16 = 1000156022, + VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16 = 1000156023, + VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16 = 1000156024, + VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16 = 1000156025, + VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16 = 1000156026, + VK_FORMAT_G16B16G16R16_422_UNORM = 1000156027, + VK_FORMAT_B16G16R16G16_422_UNORM = 1000156028, + VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM = 1000156029, + VK_FORMAT_G16_B16R16_2PLANE_420_UNORM = 1000156030, + VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM = 1000156031, + VK_FORMAT_G16_B16R16_2PLANE_422_UNORM = 1000156032, + VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM = 1000156033, + VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG = 1000054000, + VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG = 1000054001, + VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG = 1000054002, + VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG = 1000054003, + VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG = 1000054004, + VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG = 1000054005, + VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG = 1000054006, + VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG = 1000054007, + VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK_EXT = 1000066000, + VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK_EXT = 1000066001, + VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK_EXT = 1000066002, + VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK_EXT = 1000066003, + VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK_EXT = 1000066004, + VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK_EXT = 1000066005, + VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK_EXT = 1000066006, + VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK_EXT = 1000066007, + VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK_EXT = 1000066008, + VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK_EXT = 1000066009, + VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK_EXT = 1000066010, + VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK_EXT = 1000066011, + VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK_EXT = 1000066012, + VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK_EXT = 1000066013, + VK_FORMAT_G8B8G8R8_422_UNORM_KHR = VK_FORMAT_G8B8G8R8_422_UNORM, + VK_FORMAT_B8G8R8G8_422_UNORM_KHR = VK_FORMAT_B8G8R8G8_422_UNORM, + VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM_KHR = VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM, + VK_FORMAT_G8_B8R8_2PLANE_420_UNORM_KHR = VK_FORMAT_G8_B8R8_2PLANE_420_UNORM, + VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM_KHR = VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM, + VK_FORMAT_G8_B8R8_2PLANE_422_UNORM_KHR = VK_FORMAT_G8_B8R8_2PLANE_422_UNORM, + VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM_KHR = VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM, + VK_FORMAT_R10X6_UNORM_PACK16_KHR = VK_FORMAT_R10X6_UNORM_PACK16, + VK_FORMAT_R10X6G10X6_UNORM_2PACK16_KHR = VK_FORMAT_R10X6G10X6_UNORM_2PACK16, + VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16_KHR = VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16, + VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16_KHR = VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16, + VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16_KHR = VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16, + VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16_KHR = VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16, + VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16_KHR = VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16, + VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16_KHR = VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16, + VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16_KHR = VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16, + VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16_KHR = VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16, + VK_FORMAT_R12X4_UNORM_PACK16_KHR = VK_FORMAT_R12X4_UNORM_PACK16, + VK_FORMAT_R12X4G12X4_UNORM_2PACK16_KHR = VK_FORMAT_R12X4G12X4_UNORM_2PACK16, + VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16_KHR = VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16, + VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16_KHR = VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16, + VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16_KHR = VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16, + VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16_KHR = VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16, + VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16_KHR = VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16, + VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16_KHR = VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16, + VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16_KHR = VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16, + VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16_KHR = VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16, + VK_FORMAT_G16B16G16R16_422_UNORM_KHR = VK_FORMAT_G16B16G16R16_422_UNORM, + VK_FORMAT_B16G16R16G16_422_UNORM_KHR = VK_FORMAT_B16G16R16G16_422_UNORM, + VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM_KHR = VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM, + VK_FORMAT_G16_B16R16_2PLANE_420_UNORM_KHR = VK_FORMAT_G16_B16R16_2PLANE_420_UNORM, + VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM_KHR = VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM, + VK_FORMAT_G16_B16R16_2PLANE_422_UNORM_KHR = VK_FORMAT_G16_B16R16_2PLANE_422_UNORM, + VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM_KHR = VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM, + VK_FORMAT_BEGIN_RANGE = VK_FORMAT_UNDEFINED, + VK_FORMAT_END_RANGE = VK_FORMAT_ASTC_12x12_SRGB_BLOCK, + VK_FORMAT_RANGE_SIZE = (VK_FORMAT_ASTC_12x12_SRGB_BLOCK - VK_FORMAT_UNDEFINED + 1), + VK_FORMAT_MAX_ENUM = 0x7FFFFFFF +} VkFormat; + +typedef enum VkImageType { + VK_IMAGE_TYPE_1D = 0, + VK_IMAGE_TYPE_2D = 1, + VK_IMAGE_TYPE_3D = 2, + VK_IMAGE_TYPE_BEGIN_RANGE = VK_IMAGE_TYPE_1D, + VK_IMAGE_TYPE_END_RANGE = VK_IMAGE_TYPE_3D, + VK_IMAGE_TYPE_RANGE_SIZE = (VK_IMAGE_TYPE_3D - VK_IMAGE_TYPE_1D + 1), + VK_IMAGE_TYPE_MAX_ENUM = 0x7FFFFFFF +} VkImageType; + +typedef enum VkImageTiling { + VK_IMAGE_TILING_OPTIMAL = 0, + VK_IMAGE_TILING_LINEAR = 1, + VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT = 1000158000, + VK_IMAGE_TILING_BEGIN_RANGE = VK_IMAGE_TILING_OPTIMAL, + VK_IMAGE_TILING_END_RANGE = VK_IMAGE_TILING_LINEAR, + VK_IMAGE_TILING_RANGE_SIZE = (VK_IMAGE_TILING_LINEAR - VK_IMAGE_TILING_OPTIMAL + 1), + VK_IMAGE_TILING_MAX_ENUM = 0x7FFFFFFF +} VkImageTiling; + +typedef enum VkPhysicalDeviceType { + VK_PHYSICAL_DEVICE_TYPE_OTHER = 0, + VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU = 1, + VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU = 2, + VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU = 3, + VK_PHYSICAL_DEVICE_TYPE_CPU = 4, + VK_PHYSICAL_DEVICE_TYPE_BEGIN_RANGE = VK_PHYSICAL_DEVICE_TYPE_OTHER, + VK_PHYSICAL_DEVICE_TYPE_END_RANGE = VK_PHYSICAL_DEVICE_TYPE_CPU, + VK_PHYSICAL_DEVICE_TYPE_RANGE_SIZE = (VK_PHYSICAL_DEVICE_TYPE_CPU - VK_PHYSICAL_DEVICE_TYPE_OTHER + 1), + VK_PHYSICAL_DEVICE_TYPE_MAX_ENUM = 0x7FFFFFFF +} VkPhysicalDeviceType; + +typedef enum VkQueryType { + VK_QUERY_TYPE_OCCLUSION = 0, + VK_QUERY_TYPE_PIPELINE_STATISTICS = 1, + VK_QUERY_TYPE_TIMESTAMP = 2, + VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT = 1000028004, + VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR = 1000116000, + VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV = 1000165000, + VK_QUERY_TYPE_PERFORMANCE_QUERY_INTEL = 1000210000, + VK_QUERY_TYPE_BEGIN_RANGE = VK_QUERY_TYPE_OCCLUSION, + VK_QUERY_TYPE_END_RANGE = VK_QUERY_TYPE_TIMESTAMP, + VK_QUERY_TYPE_RANGE_SIZE = (VK_QUERY_TYPE_TIMESTAMP - VK_QUERY_TYPE_OCCLUSION + 1), + VK_QUERY_TYPE_MAX_ENUM = 0x7FFFFFFF +} VkQueryType; + +typedef enum VkSharingMode { + VK_SHARING_MODE_EXCLUSIVE = 0, + VK_SHARING_MODE_CONCURRENT = 1, + VK_SHARING_MODE_BEGIN_RANGE = VK_SHARING_MODE_EXCLUSIVE, + VK_SHARING_MODE_END_RANGE = VK_SHARING_MODE_CONCURRENT, + VK_SHARING_MODE_RANGE_SIZE = (VK_SHARING_MODE_CONCURRENT - VK_SHARING_MODE_EXCLUSIVE + 1), + VK_SHARING_MODE_MAX_ENUM = 0x7FFFFFFF +} VkSharingMode; + +typedef enum VkImageLayout { + VK_IMAGE_LAYOUT_UNDEFINED = 0, + VK_IMAGE_LAYOUT_GENERAL = 1, + VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL = 2, + VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL = 3, + VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL = 4, + VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL = 5, + VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL = 6, + VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL = 7, + VK_IMAGE_LAYOUT_PREINITIALIZED = 8, + VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL = 1000117000, + VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL = 1000117001, + VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL = 1000241000, + VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_OPTIMAL = 1000241001, + VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL = 1000241002, + VK_IMAGE_LAYOUT_STENCIL_READ_ONLY_OPTIMAL = 1000241003, + VK_IMAGE_LAYOUT_PRESENT_SRC_KHR = 1000001002, + VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR = 1000111000, + VK_IMAGE_LAYOUT_SHADING_RATE_OPTIMAL_NV = 1000164003, + VK_IMAGE_LAYOUT_FRAGMENT_DENSITY_MAP_OPTIMAL_EXT = 1000218000, + VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL, + VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL, + VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL_KHR = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL, + VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_OPTIMAL_KHR = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_OPTIMAL, + VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL_KHR = VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL, + VK_IMAGE_LAYOUT_STENCIL_READ_ONLY_OPTIMAL_KHR = VK_IMAGE_LAYOUT_STENCIL_READ_ONLY_OPTIMAL, + VK_IMAGE_LAYOUT_BEGIN_RANGE = VK_IMAGE_LAYOUT_UNDEFINED, + VK_IMAGE_LAYOUT_END_RANGE = VK_IMAGE_LAYOUT_PREINITIALIZED, + VK_IMAGE_LAYOUT_RANGE_SIZE = (VK_IMAGE_LAYOUT_PREINITIALIZED - VK_IMAGE_LAYOUT_UNDEFINED + 1), + VK_IMAGE_LAYOUT_MAX_ENUM = 0x7FFFFFFF +} VkImageLayout; + +typedef enum VkImageViewType { + VK_IMAGE_VIEW_TYPE_1D = 0, + VK_IMAGE_VIEW_TYPE_2D = 1, + VK_IMAGE_VIEW_TYPE_3D = 2, + VK_IMAGE_VIEW_TYPE_CUBE = 3, + VK_IMAGE_VIEW_TYPE_1D_ARRAY = 4, + VK_IMAGE_VIEW_TYPE_2D_ARRAY = 5, + VK_IMAGE_VIEW_TYPE_CUBE_ARRAY = 6, + VK_IMAGE_VIEW_TYPE_BEGIN_RANGE = VK_IMAGE_VIEW_TYPE_1D, + VK_IMAGE_VIEW_TYPE_END_RANGE = VK_IMAGE_VIEW_TYPE_CUBE_ARRAY, + VK_IMAGE_VIEW_TYPE_RANGE_SIZE = (VK_IMAGE_VIEW_TYPE_CUBE_ARRAY - VK_IMAGE_VIEW_TYPE_1D + 1), + VK_IMAGE_VIEW_TYPE_MAX_ENUM = 0x7FFFFFFF +} VkImageViewType; + +typedef enum VkComponentSwizzle { + VK_COMPONENT_SWIZZLE_IDENTITY = 0, + VK_COMPONENT_SWIZZLE_ZERO = 1, + VK_COMPONENT_SWIZZLE_ONE = 2, + VK_COMPONENT_SWIZZLE_R = 3, + VK_COMPONENT_SWIZZLE_G = 4, + VK_COMPONENT_SWIZZLE_B = 5, + VK_COMPONENT_SWIZZLE_A = 6, + VK_COMPONENT_SWIZZLE_BEGIN_RANGE = VK_COMPONENT_SWIZZLE_IDENTITY, + VK_COMPONENT_SWIZZLE_END_RANGE = VK_COMPONENT_SWIZZLE_A, + VK_COMPONENT_SWIZZLE_RANGE_SIZE = (VK_COMPONENT_SWIZZLE_A - VK_COMPONENT_SWIZZLE_IDENTITY + 1), + VK_COMPONENT_SWIZZLE_MAX_ENUM = 0x7FFFFFFF +} VkComponentSwizzle; + +typedef enum VkVertexInputRate { + VK_VERTEX_INPUT_RATE_VERTEX = 0, + VK_VERTEX_INPUT_RATE_INSTANCE = 1, + VK_VERTEX_INPUT_RATE_BEGIN_RANGE = VK_VERTEX_INPUT_RATE_VERTEX, + VK_VERTEX_INPUT_RATE_END_RANGE = VK_VERTEX_INPUT_RATE_INSTANCE, + VK_VERTEX_INPUT_RATE_RANGE_SIZE = (VK_VERTEX_INPUT_RATE_INSTANCE - VK_VERTEX_INPUT_RATE_VERTEX + 1), + VK_VERTEX_INPUT_RATE_MAX_ENUM = 0x7FFFFFFF +} VkVertexInputRate; + +typedef enum VkPrimitiveTopology { + VK_PRIMITIVE_TOPOLOGY_POINT_LIST = 0, + VK_PRIMITIVE_TOPOLOGY_LINE_LIST = 1, + VK_PRIMITIVE_TOPOLOGY_LINE_STRIP = 2, + VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST = 3, + VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP = 4, + VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN = 5, + VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY = 6, + VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY = 7, + VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY = 8, + VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY = 9, + VK_PRIMITIVE_TOPOLOGY_PATCH_LIST = 10, + VK_PRIMITIVE_TOPOLOGY_BEGIN_RANGE = VK_PRIMITIVE_TOPOLOGY_POINT_LIST, + VK_PRIMITIVE_TOPOLOGY_END_RANGE = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, + VK_PRIMITIVE_TOPOLOGY_RANGE_SIZE = (VK_PRIMITIVE_TOPOLOGY_PATCH_LIST - VK_PRIMITIVE_TOPOLOGY_POINT_LIST + 1), + VK_PRIMITIVE_TOPOLOGY_MAX_ENUM = 0x7FFFFFFF +} VkPrimitiveTopology; + +typedef enum VkPolygonMode { + VK_POLYGON_MODE_FILL = 0, + VK_POLYGON_MODE_LINE = 1, + VK_POLYGON_MODE_POINT = 2, + VK_POLYGON_MODE_FILL_RECTANGLE_NV = 1000153000, + VK_POLYGON_MODE_BEGIN_RANGE = VK_POLYGON_MODE_FILL, + VK_POLYGON_MODE_END_RANGE = VK_POLYGON_MODE_POINT, + VK_POLYGON_MODE_RANGE_SIZE = (VK_POLYGON_MODE_POINT - VK_POLYGON_MODE_FILL + 1), + VK_POLYGON_MODE_MAX_ENUM = 0x7FFFFFFF +} VkPolygonMode; + +typedef enum VkFrontFace { + VK_FRONT_FACE_COUNTER_CLOCKWISE = 0, + VK_FRONT_FACE_CLOCKWISE = 1, + VK_FRONT_FACE_BEGIN_RANGE = VK_FRONT_FACE_COUNTER_CLOCKWISE, + VK_FRONT_FACE_END_RANGE = VK_FRONT_FACE_CLOCKWISE, + VK_FRONT_FACE_RANGE_SIZE = (VK_FRONT_FACE_CLOCKWISE - VK_FRONT_FACE_COUNTER_CLOCKWISE + 1), + VK_FRONT_FACE_MAX_ENUM = 0x7FFFFFFF +} VkFrontFace; + +typedef enum VkCompareOp { + VK_COMPARE_OP_NEVER = 0, + VK_COMPARE_OP_LESS = 1, + VK_COMPARE_OP_EQUAL = 2, + VK_COMPARE_OP_LESS_OR_EQUAL = 3, + VK_COMPARE_OP_GREATER = 4, + VK_COMPARE_OP_NOT_EQUAL = 5, + VK_COMPARE_OP_GREATER_OR_EQUAL = 6, + VK_COMPARE_OP_ALWAYS = 7, + VK_COMPARE_OP_BEGIN_RANGE = VK_COMPARE_OP_NEVER, + VK_COMPARE_OP_END_RANGE = VK_COMPARE_OP_ALWAYS, + VK_COMPARE_OP_RANGE_SIZE = (VK_COMPARE_OP_ALWAYS - VK_COMPARE_OP_NEVER + 1), + VK_COMPARE_OP_MAX_ENUM = 0x7FFFFFFF +} VkCompareOp; + +typedef enum VkStencilOp { + VK_STENCIL_OP_KEEP = 0, + VK_STENCIL_OP_ZERO = 1, + VK_STENCIL_OP_REPLACE = 2, + VK_STENCIL_OP_INCREMENT_AND_CLAMP = 3, + VK_STENCIL_OP_DECREMENT_AND_CLAMP = 4, + VK_STENCIL_OP_INVERT = 5, + VK_STENCIL_OP_INCREMENT_AND_WRAP = 6, + VK_STENCIL_OP_DECREMENT_AND_WRAP = 7, + VK_STENCIL_OP_BEGIN_RANGE = VK_STENCIL_OP_KEEP, + VK_STENCIL_OP_END_RANGE = VK_STENCIL_OP_DECREMENT_AND_WRAP, + VK_STENCIL_OP_RANGE_SIZE = (VK_STENCIL_OP_DECREMENT_AND_WRAP - VK_STENCIL_OP_KEEP + 1), + VK_STENCIL_OP_MAX_ENUM = 0x7FFFFFFF +} VkStencilOp; + +typedef enum VkLogicOp { + VK_LOGIC_OP_CLEAR = 0, + VK_LOGIC_OP_AND = 1, + VK_LOGIC_OP_AND_REVERSE = 2, + VK_LOGIC_OP_COPY = 3, + VK_LOGIC_OP_AND_INVERTED = 4, + VK_LOGIC_OP_NO_OP = 5, + VK_LOGIC_OP_XOR = 6, + VK_LOGIC_OP_OR = 7, + VK_LOGIC_OP_NOR = 8, + VK_LOGIC_OP_EQUIVALENT = 9, + VK_LOGIC_OP_INVERT = 10, + VK_LOGIC_OP_OR_REVERSE = 11, + VK_LOGIC_OP_COPY_INVERTED = 12, + VK_LOGIC_OP_OR_INVERTED = 13, + VK_LOGIC_OP_NAND = 14, + VK_LOGIC_OP_SET = 15, + VK_LOGIC_OP_BEGIN_RANGE = VK_LOGIC_OP_CLEAR, + VK_LOGIC_OP_END_RANGE = VK_LOGIC_OP_SET, + VK_LOGIC_OP_RANGE_SIZE = (VK_LOGIC_OP_SET - VK_LOGIC_OP_CLEAR + 1), + VK_LOGIC_OP_MAX_ENUM = 0x7FFFFFFF +} VkLogicOp; + +typedef enum VkBlendFactor { + VK_BLEND_FACTOR_ZERO = 0, + VK_BLEND_FACTOR_ONE = 1, + VK_BLEND_FACTOR_SRC_COLOR = 2, + VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR = 3, + VK_BLEND_FACTOR_DST_COLOR = 4, + VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR = 5, + VK_BLEND_FACTOR_SRC_ALPHA = 6, + VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA = 7, + VK_BLEND_FACTOR_DST_ALPHA = 8, + VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA = 9, + VK_BLEND_FACTOR_CONSTANT_COLOR = 10, + VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR = 11, + VK_BLEND_FACTOR_CONSTANT_ALPHA = 12, + VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA = 13, + VK_BLEND_FACTOR_SRC_ALPHA_SATURATE = 14, + VK_BLEND_FACTOR_SRC1_COLOR = 15, + VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR = 16, + VK_BLEND_FACTOR_SRC1_ALPHA = 17, + VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA = 18, + VK_BLEND_FACTOR_BEGIN_RANGE = VK_BLEND_FACTOR_ZERO, + VK_BLEND_FACTOR_END_RANGE = VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA, + VK_BLEND_FACTOR_RANGE_SIZE = (VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA - VK_BLEND_FACTOR_ZERO + 1), + VK_BLEND_FACTOR_MAX_ENUM = 0x7FFFFFFF +} VkBlendFactor; + +typedef enum VkBlendOp { + VK_BLEND_OP_ADD = 0, + VK_BLEND_OP_SUBTRACT = 1, + VK_BLEND_OP_REVERSE_SUBTRACT = 2, + VK_BLEND_OP_MIN = 3, + VK_BLEND_OP_MAX = 4, + VK_BLEND_OP_ZERO_EXT = 1000148000, + VK_BLEND_OP_SRC_EXT = 1000148001, + VK_BLEND_OP_DST_EXT = 1000148002, + VK_BLEND_OP_SRC_OVER_EXT = 1000148003, + VK_BLEND_OP_DST_OVER_EXT = 1000148004, + VK_BLEND_OP_SRC_IN_EXT = 1000148005, + VK_BLEND_OP_DST_IN_EXT = 1000148006, + VK_BLEND_OP_SRC_OUT_EXT = 1000148007, + VK_BLEND_OP_DST_OUT_EXT = 1000148008, + VK_BLEND_OP_SRC_ATOP_EXT = 1000148009, + VK_BLEND_OP_DST_ATOP_EXT = 1000148010, + VK_BLEND_OP_XOR_EXT = 1000148011, + VK_BLEND_OP_MULTIPLY_EXT = 1000148012, + VK_BLEND_OP_SCREEN_EXT = 1000148013, + VK_BLEND_OP_OVERLAY_EXT = 1000148014, + VK_BLEND_OP_DARKEN_EXT = 1000148015, + VK_BLEND_OP_LIGHTEN_EXT = 1000148016, + VK_BLEND_OP_COLORDODGE_EXT = 1000148017, + VK_BLEND_OP_COLORBURN_EXT = 1000148018, + VK_BLEND_OP_HARDLIGHT_EXT = 1000148019, + VK_BLEND_OP_SOFTLIGHT_EXT = 1000148020, + VK_BLEND_OP_DIFFERENCE_EXT = 1000148021, + VK_BLEND_OP_EXCLUSION_EXT = 1000148022, + VK_BLEND_OP_INVERT_EXT = 1000148023, + VK_BLEND_OP_INVERT_RGB_EXT = 1000148024, + VK_BLEND_OP_LINEARDODGE_EXT = 1000148025, + VK_BLEND_OP_LINEARBURN_EXT = 1000148026, + VK_BLEND_OP_VIVIDLIGHT_EXT = 1000148027, + VK_BLEND_OP_LINEARLIGHT_EXT = 1000148028, + VK_BLEND_OP_PINLIGHT_EXT = 1000148029, + VK_BLEND_OP_HARDMIX_EXT = 1000148030, + VK_BLEND_OP_HSL_HUE_EXT = 1000148031, + VK_BLEND_OP_HSL_SATURATION_EXT = 1000148032, + VK_BLEND_OP_HSL_COLOR_EXT = 1000148033, + VK_BLEND_OP_HSL_LUMINOSITY_EXT = 1000148034, + VK_BLEND_OP_PLUS_EXT = 1000148035, + VK_BLEND_OP_PLUS_CLAMPED_EXT = 1000148036, + VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT = 1000148037, + VK_BLEND_OP_PLUS_DARKER_EXT = 1000148038, + VK_BLEND_OP_MINUS_EXT = 1000148039, + VK_BLEND_OP_MINUS_CLAMPED_EXT = 1000148040, + VK_BLEND_OP_CONTRAST_EXT = 1000148041, + VK_BLEND_OP_INVERT_OVG_EXT = 1000148042, + VK_BLEND_OP_RED_EXT = 1000148043, + VK_BLEND_OP_GREEN_EXT = 1000148044, + VK_BLEND_OP_BLUE_EXT = 1000148045, + VK_BLEND_OP_BEGIN_RANGE = VK_BLEND_OP_ADD, + VK_BLEND_OP_END_RANGE = VK_BLEND_OP_MAX, + VK_BLEND_OP_RANGE_SIZE = (VK_BLEND_OP_MAX - VK_BLEND_OP_ADD + 1), + VK_BLEND_OP_MAX_ENUM = 0x7FFFFFFF +} VkBlendOp; + +typedef enum VkDynamicState { + VK_DYNAMIC_STATE_VIEWPORT = 0, + VK_DYNAMIC_STATE_SCISSOR = 1, + VK_DYNAMIC_STATE_LINE_WIDTH = 2, + VK_DYNAMIC_STATE_DEPTH_BIAS = 3, + VK_DYNAMIC_STATE_BLEND_CONSTANTS = 4, + VK_DYNAMIC_STATE_DEPTH_BOUNDS = 5, + VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK = 6, + VK_DYNAMIC_STATE_STENCIL_WRITE_MASK = 7, + VK_DYNAMIC_STATE_STENCIL_REFERENCE = 8, + VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV = 1000087000, + VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT = 1000099000, + VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT = 1000143000, + VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV = 1000164004, + VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV = 1000164006, + VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV = 1000205001, + VK_DYNAMIC_STATE_LINE_STIPPLE_EXT = 1000259000, + VK_DYNAMIC_STATE_BEGIN_RANGE = VK_DYNAMIC_STATE_VIEWPORT, + VK_DYNAMIC_STATE_END_RANGE = VK_DYNAMIC_STATE_STENCIL_REFERENCE, + VK_DYNAMIC_STATE_RANGE_SIZE = (VK_DYNAMIC_STATE_STENCIL_REFERENCE - VK_DYNAMIC_STATE_VIEWPORT + 1), + VK_DYNAMIC_STATE_MAX_ENUM = 0x7FFFFFFF +} VkDynamicState; + +typedef enum VkFilter { + VK_FILTER_NEAREST = 0, + VK_FILTER_LINEAR = 1, + VK_FILTER_CUBIC_IMG = 1000015000, + VK_FILTER_CUBIC_EXT = VK_FILTER_CUBIC_IMG, + VK_FILTER_BEGIN_RANGE = VK_FILTER_NEAREST, + VK_FILTER_END_RANGE = VK_FILTER_LINEAR, + VK_FILTER_RANGE_SIZE = (VK_FILTER_LINEAR - VK_FILTER_NEAREST + 1), + VK_FILTER_MAX_ENUM = 0x7FFFFFFF +} VkFilter; + +typedef enum VkSamplerMipmapMode { + VK_SAMPLER_MIPMAP_MODE_NEAREST = 0, + VK_SAMPLER_MIPMAP_MODE_LINEAR = 1, + VK_SAMPLER_MIPMAP_MODE_BEGIN_RANGE = VK_SAMPLER_MIPMAP_MODE_NEAREST, + VK_SAMPLER_MIPMAP_MODE_END_RANGE = VK_SAMPLER_MIPMAP_MODE_LINEAR, + VK_SAMPLER_MIPMAP_MODE_RANGE_SIZE = (VK_SAMPLER_MIPMAP_MODE_LINEAR - VK_SAMPLER_MIPMAP_MODE_NEAREST + 1), + VK_SAMPLER_MIPMAP_MODE_MAX_ENUM = 0x7FFFFFFF +} VkSamplerMipmapMode; + +typedef enum VkSamplerAddressMode { + VK_SAMPLER_ADDRESS_MODE_REPEAT = 0, + VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT = 1, + VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE = 2, + VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER = 3, + VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE = 4, + VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE_KHR = VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, + VK_SAMPLER_ADDRESS_MODE_BEGIN_RANGE = VK_SAMPLER_ADDRESS_MODE_REPEAT, + VK_SAMPLER_ADDRESS_MODE_END_RANGE = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, + VK_SAMPLER_ADDRESS_MODE_RANGE_SIZE = (VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER - VK_SAMPLER_ADDRESS_MODE_REPEAT + 1), + VK_SAMPLER_ADDRESS_MODE_MAX_ENUM = 0x7FFFFFFF +} VkSamplerAddressMode; + +typedef enum VkBorderColor { + VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK = 0, + VK_BORDER_COLOR_INT_TRANSPARENT_BLACK = 1, + VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK = 2, + VK_BORDER_COLOR_INT_OPAQUE_BLACK = 3, + VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE = 4, + VK_BORDER_COLOR_INT_OPAQUE_WHITE = 5, + VK_BORDER_COLOR_BEGIN_RANGE = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK, + VK_BORDER_COLOR_END_RANGE = VK_BORDER_COLOR_INT_OPAQUE_WHITE, + VK_BORDER_COLOR_RANGE_SIZE = (VK_BORDER_COLOR_INT_OPAQUE_WHITE - VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK + 1), + VK_BORDER_COLOR_MAX_ENUM = 0x7FFFFFFF +} VkBorderColor; + +typedef enum VkDescriptorType { + VK_DESCRIPTOR_TYPE_SAMPLER = 0, + VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER = 1, + VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE = 2, + VK_DESCRIPTOR_TYPE_STORAGE_IMAGE = 3, + VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER = 4, + VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER = 5, + VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER = 6, + VK_DESCRIPTOR_TYPE_STORAGE_BUFFER = 7, + VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC = 8, + VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC = 9, + VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT = 10, + VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT = 1000138000, + VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV = 1000165000, + VK_DESCRIPTOR_TYPE_BEGIN_RANGE = VK_DESCRIPTOR_TYPE_SAMPLER, + VK_DESCRIPTOR_TYPE_END_RANGE = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, + VK_DESCRIPTOR_TYPE_RANGE_SIZE = (VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT - VK_DESCRIPTOR_TYPE_SAMPLER + 1), + VK_DESCRIPTOR_TYPE_MAX_ENUM = 0x7FFFFFFF +} VkDescriptorType; + +typedef enum VkAttachmentLoadOp { + VK_ATTACHMENT_LOAD_OP_LOAD = 0, + VK_ATTACHMENT_LOAD_OP_CLEAR = 1, + VK_ATTACHMENT_LOAD_OP_DONT_CARE = 2, + VK_ATTACHMENT_LOAD_OP_BEGIN_RANGE = VK_ATTACHMENT_LOAD_OP_LOAD, + VK_ATTACHMENT_LOAD_OP_END_RANGE = VK_ATTACHMENT_LOAD_OP_DONT_CARE, + VK_ATTACHMENT_LOAD_OP_RANGE_SIZE = (VK_ATTACHMENT_LOAD_OP_DONT_CARE - VK_ATTACHMENT_LOAD_OP_LOAD + 1), + VK_ATTACHMENT_LOAD_OP_MAX_ENUM = 0x7FFFFFFF +} VkAttachmentLoadOp; + +typedef enum VkAttachmentStoreOp { + VK_ATTACHMENT_STORE_OP_STORE = 0, + VK_ATTACHMENT_STORE_OP_DONT_CARE = 1, + VK_ATTACHMENT_STORE_OP_BEGIN_RANGE = VK_ATTACHMENT_STORE_OP_STORE, + VK_ATTACHMENT_STORE_OP_END_RANGE = VK_ATTACHMENT_STORE_OP_DONT_CARE, + VK_ATTACHMENT_STORE_OP_RANGE_SIZE = (VK_ATTACHMENT_STORE_OP_DONT_CARE - VK_ATTACHMENT_STORE_OP_STORE + 1), + VK_ATTACHMENT_STORE_OP_MAX_ENUM = 0x7FFFFFFF +} VkAttachmentStoreOp; + +typedef enum VkPipelineBindPoint { + VK_PIPELINE_BIND_POINT_GRAPHICS = 0, + VK_PIPELINE_BIND_POINT_COMPUTE = 1, + VK_PIPELINE_BIND_POINT_RAY_TRACING_NV = 1000165000, + VK_PIPELINE_BIND_POINT_BEGIN_RANGE = VK_PIPELINE_BIND_POINT_GRAPHICS, + VK_PIPELINE_BIND_POINT_END_RANGE = VK_PIPELINE_BIND_POINT_COMPUTE, + VK_PIPELINE_BIND_POINT_RANGE_SIZE = (VK_PIPELINE_BIND_POINT_COMPUTE - VK_PIPELINE_BIND_POINT_GRAPHICS + 1), + VK_PIPELINE_BIND_POINT_MAX_ENUM = 0x7FFFFFFF +} VkPipelineBindPoint; + +typedef enum VkCommandBufferLevel { + VK_COMMAND_BUFFER_LEVEL_PRIMARY = 0, + VK_COMMAND_BUFFER_LEVEL_SECONDARY = 1, + VK_COMMAND_BUFFER_LEVEL_BEGIN_RANGE = VK_COMMAND_BUFFER_LEVEL_PRIMARY, + VK_COMMAND_BUFFER_LEVEL_END_RANGE = VK_COMMAND_BUFFER_LEVEL_SECONDARY, + VK_COMMAND_BUFFER_LEVEL_RANGE_SIZE = (VK_COMMAND_BUFFER_LEVEL_SECONDARY - VK_COMMAND_BUFFER_LEVEL_PRIMARY + 1), + VK_COMMAND_BUFFER_LEVEL_MAX_ENUM = 0x7FFFFFFF +} VkCommandBufferLevel; + +typedef enum VkIndexType { + VK_INDEX_TYPE_UINT16 = 0, + VK_INDEX_TYPE_UINT32 = 1, + VK_INDEX_TYPE_NONE_NV = 1000165000, + VK_INDEX_TYPE_UINT8_EXT = 1000265000, + VK_INDEX_TYPE_BEGIN_RANGE = VK_INDEX_TYPE_UINT16, + VK_INDEX_TYPE_END_RANGE = VK_INDEX_TYPE_UINT32, + VK_INDEX_TYPE_RANGE_SIZE = (VK_INDEX_TYPE_UINT32 - VK_INDEX_TYPE_UINT16 + 1), + VK_INDEX_TYPE_MAX_ENUM = 0x7FFFFFFF +} VkIndexType; + +typedef enum VkSubpassContents { + VK_SUBPASS_CONTENTS_INLINE = 0, + VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS = 1, + VK_SUBPASS_CONTENTS_BEGIN_RANGE = VK_SUBPASS_CONTENTS_INLINE, + VK_SUBPASS_CONTENTS_END_RANGE = VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS, + VK_SUBPASS_CONTENTS_RANGE_SIZE = (VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS - VK_SUBPASS_CONTENTS_INLINE + 1), + VK_SUBPASS_CONTENTS_MAX_ENUM = 0x7FFFFFFF +} VkSubpassContents; + +typedef enum VkObjectType { + VK_OBJECT_TYPE_UNKNOWN = 0, + VK_OBJECT_TYPE_INSTANCE = 1, + VK_OBJECT_TYPE_PHYSICAL_DEVICE = 2, + VK_OBJECT_TYPE_DEVICE = 3, + VK_OBJECT_TYPE_QUEUE = 4, + VK_OBJECT_TYPE_SEMAPHORE = 5, + VK_OBJECT_TYPE_COMMAND_BUFFER = 6, + VK_OBJECT_TYPE_FENCE = 7, + VK_OBJECT_TYPE_DEVICE_MEMORY = 8, + VK_OBJECT_TYPE_BUFFER = 9, + VK_OBJECT_TYPE_IMAGE = 10, + VK_OBJECT_TYPE_EVENT = 11, + VK_OBJECT_TYPE_QUERY_POOL = 12, + VK_OBJECT_TYPE_BUFFER_VIEW = 13, + VK_OBJECT_TYPE_IMAGE_VIEW = 14, + VK_OBJECT_TYPE_SHADER_MODULE = 15, + VK_OBJECT_TYPE_PIPELINE_CACHE = 16, + VK_OBJECT_TYPE_PIPELINE_LAYOUT = 17, + VK_OBJECT_TYPE_RENDER_PASS = 18, + VK_OBJECT_TYPE_PIPELINE = 19, + VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT = 20, + VK_OBJECT_TYPE_SAMPLER = 21, + VK_OBJECT_TYPE_DESCRIPTOR_POOL = 22, + VK_OBJECT_TYPE_DESCRIPTOR_SET = 23, + VK_OBJECT_TYPE_FRAMEBUFFER = 24, + VK_OBJECT_TYPE_COMMAND_POOL = 25, + VK_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION = 1000156000, + VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE = 1000085000, + VK_OBJECT_TYPE_SURFACE_KHR = 1000000000, + VK_OBJECT_TYPE_SWAPCHAIN_KHR = 1000001000, + VK_OBJECT_TYPE_DISPLAY_KHR = 1000002000, + VK_OBJECT_TYPE_DISPLAY_MODE_KHR = 1000002001, + VK_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT = 1000011000, + VK_OBJECT_TYPE_OBJECT_TABLE_NVX = 1000086000, + VK_OBJECT_TYPE_INDIRECT_COMMANDS_LAYOUT_NVX = 1000086001, + VK_OBJECT_TYPE_DEBUG_UTILS_MESSENGER_EXT = 1000128000, + VK_OBJECT_TYPE_VALIDATION_CACHE_EXT = 1000160000, + VK_OBJECT_TYPE_ACCELERATION_STRUCTURE_NV = 1000165000, + VK_OBJECT_TYPE_PERFORMANCE_CONFIGURATION_INTEL = 1000210000, + VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_KHR = VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE, + VK_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION_KHR = VK_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION, + VK_OBJECT_TYPE_BEGIN_RANGE = VK_OBJECT_TYPE_UNKNOWN, + VK_OBJECT_TYPE_END_RANGE = VK_OBJECT_TYPE_COMMAND_POOL, + VK_OBJECT_TYPE_RANGE_SIZE = (VK_OBJECT_TYPE_COMMAND_POOL - VK_OBJECT_TYPE_UNKNOWN + 1), + VK_OBJECT_TYPE_MAX_ENUM = 0x7FFFFFFF +} VkObjectType; + +typedef enum VkVendorId { + VK_VENDOR_ID_VIV = 0x10001, + VK_VENDOR_ID_VSI = 0x10002, + VK_VENDOR_ID_KAZAN = 0x10003, + VK_VENDOR_ID_CODEPLAY = 0x10004, + VK_VENDOR_ID_BEGIN_RANGE = VK_VENDOR_ID_VIV, + VK_VENDOR_ID_END_RANGE = VK_VENDOR_ID_CODEPLAY, + VK_VENDOR_ID_RANGE_SIZE = (VK_VENDOR_ID_CODEPLAY - VK_VENDOR_ID_VIV + 1), + VK_VENDOR_ID_MAX_ENUM = 0x7FFFFFFF +} VkVendorId; +typedef VkFlags VkInstanceCreateFlags; + +typedef enum VkFormatFeatureFlagBits { + VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT = 0x00000001, + VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT = 0x00000002, + VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT = 0x00000004, + VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT = 0x00000008, + VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT = 0x00000010, + VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT = 0x00000020, + VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT = 0x00000040, + VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT = 0x00000080, + VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT = 0x00000100, + VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT = 0x00000200, + VK_FORMAT_FEATURE_BLIT_SRC_BIT = 0x00000400, + VK_FORMAT_FEATURE_BLIT_DST_BIT = 0x00000800, + VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT = 0x00001000, + VK_FORMAT_FEATURE_TRANSFER_SRC_BIT = 0x00004000, + VK_FORMAT_FEATURE_TRANSFER_DST_BIT = 0x00008000, + VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT = 0x00020000, + VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT = 0x00040000, + VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER_BIT = 0x00080000, + VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_BIT = 0x00100000, + VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE_BIT = 0x00200000, + VK_FORMAT_FEATURE_DISJOINT_BIT = 0x00400000, + VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT = 0x00800000, + VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT = 0x00010000, + VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_IMG = 0x00002000, + VK_FORMAT_FEATURE_FRAGMENT_DENSITY_MAP_BIT_EXT = 0x01000000, + VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR = VK_FORMAT_FEATURE_TRANSFER_SRC_BIT, + VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR = VK_FORMAT_FEATURE_TRANSFER_DST_BIT, + VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT_EXT = VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT, + VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT_KHR = VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT, + VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT_KHR = VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT, + VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER_BIT_KHR = VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER_BIT, + VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_BIT_KHR = VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_BIT, + VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE_BIT_KHR = VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE_BIT, + VK_FORMAT_FEATURE_DISJOINT_BIT_KHR = VK_FORMAT_FEATURE_DISJOINT_BIT, + VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT_KHR = VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT, + VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_EXT = VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_IMG, + VK_FORMAT_FEATURE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkFormatFeatureFlagBits; +typedef VkFlags VkFormatFeatureFlags; + +typedef enum VkImageUsageFlagBits { + VK_IMAGE_USAGE_TRANSFER_SRC_BIT = 0x00000001, + VK_IMAGE_USAGE_TRANSFER_DST_BIT = 0x00000002, + VK_IMAGE_USAGE_SAMPLED_BIT = 0x00000004, + VK_IMAGE_USAGE_STORAGE_BIT = 0x00000008, + VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT = 0x00000010, + VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT = 0x00000020, + VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT = 0x00000040, + VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT = 0x00000080, + VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV = 0x00000100, + VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT = 0x00000200, + VK_IMAGE_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkImageUsageFlagBits; +typedef VkFlags VkImageUsageFlags; + +typedef enum VkImageCreateFlagBits { + VK_IMAGE_CREATE_SPARSE_BINDING_BIT = 0x00000001, + VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT = 0x00000002, + VK_IMAGE_CREATE_SPARSE_ALIASED_BIT = 0x00000004, + VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT = 0x00000008, + VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT = 0x00000010, + VK_IMAGE_CREATE_ALIAS_BIT = 0x00000400, + VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT = 0x00000040, + VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT = 0x00000020, + VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT = 0x00000080, + VK_IMAGE_CREATE_EXTENDED_USAGE_BIT = 0x00000100, + VK_IMAGE_CREATE_PROTECTED_BIT = 0x00000800, + VK_IMAGE_CREATE_DISJOINT_BIT = 0x00000200, + VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV = 0x00002000, + VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT = 0x00001000, + VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT = 0x00004000, + VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT_KHR = VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT, + VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT_KHR = VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT, + VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT_KHR = VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT, + VK_IMAGE_CREATE_EXTENDED_USAGE_BIT_KHR = VK_IMAGE_CREATE_EXTENDED_USAGE_BIT, + VK_IMAGE_CREATE_DISJOINT_BIT_KHR = VK_IMAGE_CREATE_DISJOINT_BIT, + VK_IMAGE_CREATE_ALIAS_BIT_KHR = VK_IMAGE_CREATE_ALIAS_BIT, + VK_IMAGE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkImageCreateFlagBits; +typedef VkFlags VkImageCreateFlags; + +typedef enum VkSampleCountFlagBits { + VK_SAMPLE_COUNT_1_BIT = 0x00000001, + VK_SAMPLE_COUNT_2_BIT = 0x00000002, + VK_SAMPLE_COUNT_4_BIT = 0x00000004, + VK_SAMPLE_COUNT_8_BIT = 0x00000008, + VK_SAMPLE_COUNT_16_BIT = 0x00000010, + VK_SAMPLE_COUNT_32_BIT = 0x00000020, + VK_SAMPLE_COUNT_64_BIT = 0x00000040, + VK_SAMPLE_COUNT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkSampleCountFlagBits; +typedef VkFlags VkSampleCountFlags; + +typedef enum VkQueueFlagBits { + VK_QUEUE_GRAPHICS_BIT = 0x00000001, + VK_QUEUE_COMPUTE_BIT = 0x00000002, + VK_QUEUE_TRANSFER_BIT = 0x00000004, + VK_QUEUE_SPARSE_BINDING_BIT = 0x00000008, + VK_QUEUE_PROTECTED_BIT = 0x00000010, + VK_QUEUE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkQueueFlagBits; +typedef VkFlags VkQueueFlags; + +typedef enum VkMemoryPropertyFlagBits { + VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT = 0x00000001, + VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT = 0x00000002, + VK_MEMORY_PROPERTY_HOST_COHERENT_BIT = 0x00000004, + VK_MEMORY_PROPERTY_HOST_CACHED_BIT = 0x00000008, + VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT = 0x00000010, + VK_MEMORY_PROPERTY_PROTECTED_BIT = 0x00000020, + VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD = 0x00000040, + VK_MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD = 0x00000080, + VK_MEMORY_PROPERTY_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkMemoryPropertyFlagBits; +typedef VkFlags VkMemoryPropertyFlags; + +typedef enum VkMemoryHeapFlagBits { + VK_MEMORY_HEAP_DEVICE_LOCAL_BIT = 0x00000001, + VK_MEMORY_HEAP_MULTI_INSTANCE_BIT = 0x00000002, + VK_MEMORY_HEAP_MULTI_INSTANCE_BIT_KHR = VK_MEMORY_HEAP_MULTI_INSTANCE_BIT, + VK_MEMORY_HEAP_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkMemoryHeapFlagBits; +typedef VkFlags VkMemoryHeapFlags; +typedef VkFlags VkDeviceCreateFlags; + +typedef enum VkDeviceQueueCreateFlagBits { + VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT = 0x00000001, + VK_DEVICE_QUEUE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkDeviceQueueCreateFlagBits; +typedef VkFlags VkDeviceQueueCreateFlags; + +typedef enum VkPipelineStageFlagBits { + VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT = 0x00000001, + VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT = 0x00000002, + VK_PIPELINE_STAGE_VERTEX_INPUT_BIT = 0x00000004, + VK_PIPELINE_STAGE_VERTEX_SHADER_BIT = 0x00000008, + VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT = 0x00000010, + VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT = 0x00000020, + VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT = 0x00000040, + VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT = 0x00000080, + VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT = 0x00000100, + VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT = 0x00000200, + VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT = 0x00000400, + VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT = 0x00000800, + VK_PIPELINE_STAGE_TRANSFER_BIT = 0x00001000, + VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT = 0x00002000, + VK_PIPELINE_STAGE_HOST_BIT = 0x00004000, + VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT = 0x00008000, + VK_PIPELINE_STAGE_ALL_COMMANDS_BIT = 0x00010000, + VK_PIPELINE_STAGE_TRANSFORM_FEEDBACK_BIT_EXT = 0x01000000, + VK_PIPELINE_STAGE_CONDITIONAL_RENDERING_BIT_EXT = 0x00040000, + VK_PIPELINE_STAGE_COMMAND_PROCESS_BIT_NVX = 0x00020000, + VK_PIPELINE_STAGE_SHADING_RATE_IMAGE_BIT_NV = 0x00400000, + VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_NV = 0x00200000, + VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_NV = 0x02000000, + VK_PIPELINE_STAGE_TASK_SHADER_BIT_NV = 0x00080000, + VK_PIPELINE_STAGE_MESH_SHADER_BIT_NV = 0x00100000, + VK_PIPELINE_STAGE_FRAGMENT_DENSITY_PROCESS_BIT_EXT = 0x00800000, + VK_PIPELINE_STAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkPipelineStageFlagBits; +typedef VkFlags VkPipelineStageFlags; +typedef VkFlags VkMemoryMapFlags; + +typedef enum VkImageAspectFlagBits { + VK_IMAGE_ASPECT_COLOR_BIT = 0x00000001, + VK_IMAGE_ASPECT_DEPTH_BIT = 0x00000002, + VK_IMAGE_ASPECT_STENCIL_BIT = 0x00000004, + VK_IMAGE_ASPECT_METADATA_BIT = 0x00000008, + VK_IMAGE_ASPECT_PLANE_0_BIT = 0x00000010, + VK_IMAGE_ASPECT_PLANE_1_BIT = 0x00000020, + VK_IMAGE_ASPECT_PLANE_2_BIT = 0x00000040, + VK_IMAGE_ASPECT_MEMORY_PLANE_0_BIT_EXT = 0x00000080, + VK_IMAGE_ASPECT_MEMORY_PLANE_1_BIT_EXT = 0x00000100, + VK_IMAGE_ASPECT_MEMORY_PLANE_2_BIT_EXT = 0x00000200, + VK_IMAGE_ASPECT_MEMORY_PLANE_3_BIT_EXT = 0x00000400, + VK_IMAGE_ASPECT_PLANE_0_BIT_KHR = VK_IMAGE_ASPECT_PLANE_0_BIT, + VK_IMAGE_ASPECT_PLANE_1_BIT_KHR = VK_IMAGE_ASPECT_PLANE_1_BIT, + VK_IMAGE_ASPECT_PLANE_2_BIT_KHR = VK_IMAGE_ASPECT_PLANE_2_BIT, + VK_IMAGE_ASPECT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkImageAspectFlagBits; +typedef VkFlags VkImageAspectFlags; + +typedef enum VkSparseImageFormatFlagBits { + VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT = 0x00000001, + VK_SPARSE_IMAGE_FORMAT_ALIGNED_MIP_SIZE_BIT = 0x00000002, + VK_SPARSE_IMAGE_FORMAT_NONSTANDARD_BLOCK_SIZE_BIT = 0x00000004, + VK_SPARSE_IMAGE_FORMAT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkSparseImageFormatFlagBits; +typedef VkFlags VkSparseImageFormatFlags; + +typedef enum VkSparseMemoryBindFlagBits { + VK_SPARSE_MEMORY_BIND_METADATA_BIT = 0x00000001, + VK_SPARSE_MEMORY_BIND_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkSparseMemoryBindFlagBits; +typedef VkFlags VkSparseMemoryBindFlags; + +typedef enum VkFenceCreateFlagBits { + VK_FENCE_CREATE_SIGNALED_BIT = 0x00000001, + VK_FENCE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkFenceCreateFlagBits; +typedef VkFlags VkFenceCreateFlags; +typedef VkFlags VkSemaphoreCreateFlags; +typedef VkFlags VkEventCreateFlags; +typedef VkFlags VkQueryPoolCreateFlags; + +typedef enum VkQueryPipelineStatisticFlagBits { + VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT = 0x00000001, + VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT = 0x00000002, + VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT = 0x00000004, + VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT = 0x00000008, + VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT = 0x00000010, + VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT = 0x00000020, + VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT = 0x00000040, + VK_QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT = 0x00000080, + VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT = 0x00000100, + VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT = 0x00000200, + VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT = 0x00000400, + VK_QUERY_PIPELINE_STATISTIC_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkQueryPipelineStatisticFlagBits; +typedef VkFlags VkQueryPipelineStatisticFlags; + +typedef enum VkQueryResultFlagBits { + VK_QUERY_RESULT_64_BIT = 0x00000001, + VK_QUERY_RESULT_WAIT_BIT = 0x00000002, + VK_QUERY_RESULT_WITH_AVAILABILITY_BIT = 0x00000004, + VK_QUERY_RESULT_PARTIAL_BIT = 0x00000008, + VK_QUERY_RESULT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkQueryResultFlagBits; +typedef VkFlags VkQueryResultFlags; + +typedef enum VkBufferCreateFlagBits { + VK_BUFFER_CREATE_SPARSE_BINDING_BIT = 0x00000001, + VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT = 0x00000002, + VK_BUFFER_CREATE_SPARSE_ALIASED_BIT = 0x00000004, + VK_BUFFER_CREATE_PROTECTED_BIT = 0x00000008, + VK_BUFFER_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT = 0x00000010, + VK_BUFFER_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_EXT = VK_BUFFER_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT, + VK_BUFFER_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR = VK_BUFFER_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT, + VK_BUFFER_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkBufferCreateFlagBits; +typedef VkFlags VkBufferCreateFlags; + +typedef enum VkBufferUsageFlagBits { + VK_BUFFER_USAGE_TRANSFER_SRC_BIT = 0x00000001, + VK_BUFFER_USAGE_TRANSFER_DST_BIT = 0x00000002, + VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT = 0x00000004, + VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT = 0x00000008, + VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT = 0x00000010, + VK_BUFFER_USAGE_STORAGE_BUFFER_BIT = 0x00000020, + VK_BUFFER_USAGE_INDEX_BUFFER_BIT = 0x00000040, + VK_BUFFER_USAGE_VERTEX_BUFFER_BIT = 0x00000080, + VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT = 0x00000100, + VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT = 0x00020000, + VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT = 0x00000800, + VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_COUNTER_BUFFER_BIT_EXT = 0x00001000, + VK_BUFFER_USAGE_CONDITIONAL_RENDERING_BIT_EXT = 0x00000200, + VK_BUFFER_USAGE_RAY_TRACING_BIT_NV = 0x00000400, + VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT_EXT = VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT, + VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT_KHR = VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT, + VK_BUFFER_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkBufferUsageFlagBits; +typedef VkFlags VkBufferUsageFlags; +typedef VkFlags VkBufferViewCreateFlags; + +typedef enum VkImageViewCreateFlagBits { + VK_IMAGE_VIEW_CREATE_FRAGMENT_DENSITY_MAP_DYNAMIC_BIT_EXT = 0x00000001, + VK_IMAGE_VIEW_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkImageViewCreateFlagBits; +typedef VkFlags VkImageViewCreateFlags; + +typedef enum VkShaderModuleCreateFlagBits { + VK_SHADER_MODULE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkShaderModuleCreateFlagBits; +typedef VkFlags VkShaderModuleCreateFlags; +typedef VkFlags VkPipelineCacheCreateFlags; + +typedef enum VkPipelineCreateFlagBits { + VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT = 0x00000001, + VK_PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT = 0x00000002, + VK_PIPELINE_CREATE_DERIVATIVE_BIT = 0x00000004, + VK_PIPELINE_CREATE_VIEW_INDEX_FROM_DEVICE_INDEX_BIT = 0x00000008, + VK_PIPELINE_CREATE_DISPATCH_BASE_BIT = 0x00000010, + VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV = 0x00000020, + VK_PIPELINE_CREATE_CAPTURE_STATISTICS_BIT_KHR = 0x00000040, + VK_PIPELINE_CREATE_CAPTURE_INTERNAL_REPRESENTATIONS_BIT_KHR = 0x00000080, + VK_PIPELINE_CREATE_DISPATCH_BASE = VK_PIPELINE_CREATE_DISPATCH_BASE_BIT, + VK_PIPELINE_CREATE_VIEW_INDEX_FROM_DEVICE_INDEX_BIT_KHR = VK_PIPELINE_CREATE_VIEW_INDEX_FROM_DEVICE_INDEX_BIT, + VK_PIPELINE_CREATE_DISPATCH_BASE_KHR = VK_PIPELINE_CREATE_DISPATCH_BASE, + VK_PIPELINE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkPipelineCreateFlagBits; +typedef VkFlags VkPipelineCreateFlags; + +typedef enum VkPipelineShaderStageCreateFlagBits { + VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT = 0x00000001, + VK_PIPELINE_SHADER_STAGE_CREATE_REQUIRE_FULL_SUBGROUPS_BIT_EXT = 0x00000002, + VK_PIPELINE_SHADER_STAGE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkPipelineShaderStageCreateFlagBits; +typedef VkFlags VkPipelineShaderStageCreateFlags; + +typedef enum VkShaderStageFlagBits { + VK_SHADER_STAGE_VERTEX_BIT = 0x00000001, + VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT = 0x00000002, + VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT = 0x00000004, + VK_SHADER_STAGE_GEOMETRY_BIT = 0x00000008, + VK_SHADER_STAGE_FRAGMENT_BIT = 0x00000010, + VK_SHADER_STAGE_COMPUTE_BIT = 0x00000020, + VK_SHADER_STAGE_ALL_GRAPHICS = 0x0000001F, + VK_SHADER_STAGE_ALL = 0x7FFFFFFF, + VK_SHADER_STAGE_RAYGEN_BIT_NV = 0x00000100, + VK_SHADER_STAGE_ANY_HIT_BIT_NV = 0x00000200, + VK_SHADER_STAGE_CLOSEST_HIT_BIT_NV = 0x00000400, + VK_SHADER_STAGE_MISS_BIT_NV = 0x00000800, + VK_SHADER_STAGE_INTERSECTION_BIT_NV = 0x00001000, + VK_SHADER_STAGE_CALLABLE_BIT_NV = 0x00002000, + VK_SHADER_STAGE_TASK_BIT_NV = 0x00000040, + VK_SHADER_STAGE_MESH_BIT_NV = 0x00000080, + VK_SHADER_STAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkShaderStageFlagBits; +typedef VkFlags VkPipelineVertexInputStateCreateFlags; +typedef VkFlags VkPipelineInputAssemblyStateCreateFlags; +typedef VkFlags VkPipelineTessellationStateCreateFlags; +typedef VkFlags VkPipelineViewportStateCreateFlags; +typedef VkFlags VkPipelineRasterizationStateCreateFlags; + +typedef enum VkCullModeFlagBits { + VK_CULL_MODE_NONE = 0, + VK_CULL_MODE_FRONT_BIT = 0x00000001, + VK_CULL_MODE_BACK_BIT = 0x00000002, + VK_CULL_MODE_FRONT_AND_BACK = 0x00000003, + VK_CULL_MODE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkCullModeFlagBits; +typedef VkFlags VkCullModeFlags; +typedef VkFlags VkPipelineMultisampleStateCreateFlags; +typedef VkFlags VkPipelineDepthStencilStateCreateFlags; +typedef VkFlags VkPipelineColorBlendStateCreateFlags; + +typedef enum VkColorComponentFlagBits { + VK_COLOR_COMPONENT_R_BIT = 0x00000001, + VK_COLOR_COMPONENT_G_BIT = 0x00000002, + VK_COLOR_COMPONENT_B_BIT = 0x00000004, + VK_COLOR_COMPONENT_A_BIT = 0x00000008, + VK_COLOR_COMPONENT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkColorComponentFlagBits; +typedef VkFlags VkColorComponentFlags; +typedef VkFlags VkPipelineDynamicStateCreateFlags; +typedef VkFlags VkPipelineLayoutCreateFlags; +typedef VkFlags VkShaderStageFlags; + +typedef enum VkSamplerCreateFlagBits { + VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT = 0x00000001, + VK_SAMPLER_CREATE_SUBSAMPLED_COARSE_RECONSTRUCTION_BIT_EXT = 0x00000002, + VK_SAMPLER_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkSamplerCreateFlagBits; +typedef VkFlags VkSamplerCreateFlags; + +typedef enum VkDescriptorSetLayoutCreateFlagBits { + VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT = 0x00000002, + VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR = 0x00000001, + VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT_EXT = VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT, + VK_DESCRIPTOR_SET_LAYOUT_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkDescriptorSetLayoutCreateFlagBits; +typedef VkFlags VkDescriptorSetLayoutCreateFlags; + +typedef enum VkDescriptorPoolCreateFlagBits { + VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT = 0x00000001, + VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT = 0x00000002, + VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT_EXT = VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT, + VK_DESCRIPTOR_POOL_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkDescriptorPoolCreateFlagBits; +typedef VkFlags VkDescriptorPoolCreateFlags; +typedef VkFlags VkDescriptorPoolResetFlags; + +typedef enum VkFramebufferCreateFlagBits { + VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT = 0x00000001, + VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR = VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT, + VK_FRAMEBUFFER_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkFramebufferCreateFlagBits; +typedef VkFlags VkFramebufferCreateFlags; + +typedef enum VkRenderPassCreateFlagBits { + VK_RENDER_PASS_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkRenderPassCreateFlagBits; +typedef VkFlags VkRenderPassCreateFlags; + +typedef enum VkAttachmentDescriptionFlagBits { + VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT = 0x00000001, + VK_ATTACHMENT_DESCRIPTION_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkAttachmentDescriptionFlagBits; +typedef VkFlags VkAttachmentDescriptionFlags; + +typedef enum VkSubpassDescriptionFlagBits { + VK_SUBPASS_DESCRIPTION_PER_VIEW_ATTRIBUTES_BIT_NVX = 0x00000001, + VK_SUBPASS_DESCRIPTION_PER_VIEW_POSITION_X_ONLY_BIT_NVX = 0x00000002, + VK_SUBPASS_DESCRIPTION_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkSubpassDescriptionFlagBits; +typedef VkFlags VkSubpassDescriptionFlags; + +typedef enum VkAccessFlagBits { + VK_ACCESS_INDIRECT_COMMAND_READ_BIT = 0x00000001, + VK_ACCESS_INDEX_READ_BIT = 0x00000002, + VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT = 0x00000004, + VK_ACCESS_UNIFORM_READ_BIT = 0x00000008, + VK_ACCESS_INPUT_ATTACHMENT_READ_BIT = 0x00000010, + VK_ACCESS_SHADER_READ_BIT = 0x00000020, + VK_ACCESS_SHADER_WRITE_BIT = 0x00000040, + VK_ACCESS_COLOR_ATTACHMENT_READ_BIT = 0x00000080, + VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT = 0x00000100, + VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT = 0x00000200, + VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT = 0x00000400, + VK_ACCESS_TRANSFER_READ_BIT = 0x00000800, + VK_ACCESS_TRANSFER_WRITE_BIT = 0x00001000, + VK_ACCESS_HOST_READ_BIT = 0x00002000, + VK_ACCESS_HOST_WRITE_BIT = 0x00004000, + VK_ACCESS_MEMORY_READ_BIT = 0x00008000, + VK_ACCESS_MEMORY_WRITE_BIT = 0x00010000, + VK_ACCESS_TRANSFORM_FEEDBACK_WRITE_BIT_EXT = 0x02000000, + VK_ACCESS_TRANSFORM_FEEDBACK_COUNTER_READ_BIT_EXT = 0x04000000, + VK_ACCESS_TRANSFORM_FEEDBACK_COUNTER_WRITE_BIT_EXT = 0x08000000, + VK_ACCESS_CONDITIONAL_RENDERING_READ_BIT_EXT = 0x00100000, + VK_ACCESS_COMMAND_PROCESS_READ_BIT_NVX = 0x00020000, + VK_ACCESS_COMMAND_PROCESS_WRITE_BIT_NVX = 0x00040000, + VK_ACCESS_COLOR_ATTACHMENT_READ_NONCOHERENT_BIT_EXT = 0x00080000, + VK_ACCESS_SHADING_RATE_IMAGE_READ_BIT_NV = 0x00800000, + VK_ACCESS_ACCELERATION_STRUCTURE_READ_BIT_NV = 0x00200000, + VK_ACCESS_ACCELERATION_STRUCTURE_WRITE_BIT_NV = 0x00400000, + VK_ACCESS_FRAGMENT_DENSITY_MAP_READ_BIT_EXT = 0x01000000, + VK_ACCESS_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkAccessFlagBits; +typedef VkFlags VkAccessFlags; + +typedef enum VkDependencyFlagBits { + VK_DEPENDENCY_BY_REGION_BIT = 0x00000001, + VK_DEPENDENCY_DEVICE_GROUP_BIT = 0x00000004, + VK_DEPENDENCY_VIEW_LOCAL_BIT = 0x00000002, + VK_DEPENDENCY_VIEW_LOCAL_BIT_KHR = VK_DEPENDENCY_VIEW_LOCAL_BIT, + VK_DEPENDENCY_DEVICE_GROUP_BIT_KHR = VK_DEPENDENCY_DEVICE_GROUP_BIT, + VK_DEPENDENCY_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkDependencyFlagBits; +typedef VkFlags VkDependencyFlags; + +typedef enum VkCommandPoolCreateFlagBits { + VK_COMMAND_POOL_CREATE_TRANSIENT_BIT = 0x00000001, + VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT = 0x00000002, + VK_COMMAND_POOL_CREATE_PROTECTED_BIT = 0x00000004, + VK_COMMAND_POOL_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkCommandPoolCreateFlagBits; +typedef VkFlags VkCommandPoolCreateFlags; + +typedef enum VkCommandPoolResetFlagBits { + VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT = 0x00000001, + VK_COMMAND_POOL_RESET_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkCommandPoolResetFlagBits; +typedef VkFlags VkCommandPoolResetFlags; + +typedef enum VkCommandBufferUsageFlagBits { + VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT = 0x00000001, + VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT = 0x00000002, + VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT = 0x00000004, + VK_COMMAND_BUFFER_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkCommandBufferUsageFlagBits; +typedef VkFlags VkCommandBufferUsageFlags; + +typedef enum VkQueryControlFlagBits { + VK_QUERY_CONTROL_PRECISE_BIT = 0x00000001, + VK_QUERY_CONTROL_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkQueryControlFlagBits; +typedef VkFlags VkQueryControlFlags; + +typedef enum VkCommandBufferResetFlagBits { + VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT = 0x00000001, + VK_COMMAND_BUFFER_RESET_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkCommandBufferResetFlagBits; +typedef VkFlags VkCommandBufferResetFlags; + +typedef enum VkStencilFaceFlagBits { + VK_STENCIL_FACE_FRONT_BIT = 0x00000001, + VK_STENCIL_FACE_BACK_BIT = 0x00000002, + VK_STENCIL_FACE_FRONT_AND_BACK = 0x00000003, + VK_STENCIL_FRONT_AND_BACK = VK_STENCIL_FACE_FRONT_AND_BACK, + VK_STENCIL_FACE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkStencilFaceFlagBits; +typedef VkFlags VkStencilFaceFlags; +typedef struct VkApplicationInfo { + VkStructureType sType; + const void* pNext; + const char* pApplicationName; + uint32_t applicationVersion; + const char* pEngineName; + uint32_t engineVersion; + uint32_t apiVersion; +} VkApplicationInfo; + +typedef struct VkInstanceCreateInfo { + VkStructureType sType; + const void* pNext; + VkInstanceCreateFlags flags; + const VkApplicationInfo* pApplicationInfo; + uint32_t enabledLayerCount; + const char* const* ppEnabledLayerNames; + uint32_t enabledExtensionCount; + const char* const* ppEnabledExtensionNames; +} VkInstanceCreateInfo; + +typedef void* (VKAPI_PTR *PFN_vkAllocationFunction)( + void* pUserData, + size_t size, + size_t alignment, + VkSystemAllocationScope allocationScope); + +typedef void* (VKAPI_PTR *PFN_vkReallocationFunction)( + void* pUserData, + void* pOriginal, + size_t size, + size_t alignment, + VkSystemAllocationScope allocationScope); + +typedef void (VKAPI_PTR *PFN_vkFreeFunction)( + void* pUserData, + void* pMemory); + +typedef void (VKAPI_PTR *PFN_vkInternalAllocationNotification)( + void* pUserData, + size_t size, + VkInternalAllocationType allocationType, + VkSystemAllocationScope allocationScope); + +typedef void (VKAPI_PTR *PFN_vkInternalFreeNotification)( + void* pUserData, + size_t size, + VkInternalAllocationType allocationType, + VkSystemAllocationScope allocationScope); + +typedef struct VkAllocationCallbacks { + void* pUserData; + PFN_vkAllocationFunction pfnAllocation; + PFN_vkReallocationFunction pfnReallocation; + PFN_vkFreeFunction pfnFree; + PFN_vkInternalAllocationNotification pfnInternalAllocation; + PFN_vkInternalFreeNotification pfnInternalFree; +} VkAllocationCallbacks; + +typedef struct VkPhysicalDeviceFeatures { + VkBool32 robustBufferAccess; + VkBool32 fullDrawIndexUint32; + VkBool32 imageCubeArray; + VkBool32 independentBlend; + VkBool32 geometryShader; + VkBool32 tessellationShader; + VkBool32 sampleRateShading; + VkBool32 dualSrcBlend; + VkBool32 logicOp; + VkBool32 multiDrawIndirect; + VkBool32 drawIndirectFirstInstance; + VkBool32 depthClamp; + VkBool32 depthBiasClamp; + VkBool32 fillModeNonSolid; + VkBool32 depthBounds; + VkBool32 wideLines; + VkBool32 largePoints; + VkBool32 alphaToOne; + VkBool32 multiViewport; + VkBool32 samplerAnisotropy; + VkBool32 textureCompressionETC2; + VkBool32 textureCompressionASTC_LDR; + VkBool32 textureCompressionBC; + VkBool32 occlusionQueryPrecise; + VkBool32 pipelineStatisticsQuery; + VkBool32 vertexPipelineStoresAndAtomics; + VkBool32 fragmentStoresAndAtomics; + VkBool32 shaderTessellationAndGeometryPointSize; + VkBool32 shaderImageGatherExtended; + VkBool32 shaderStorageImageExtendedFormats; + VkBool32 shaderStorageImageMultisample; + VkBool32 shaderStorageImageReadWithoutFormat; + VkBool32 shaderStorageImageWriteWithoutFormat; + VkBool32 shaderUniformBufferArrayDynamicIndexing; + VkBool32 shaderSampledImageArrayDynamicIndexing; + VkBool32 shaderStorageBufferArrayDynamicIndexing; + VkBool32 shaderStorageImageArrayDynamicIndexing; + VkBool32 shaderClipDistance; + VkBool32 shaderCullDistance; + VkBool32 shaderFloat64; + VkBool32 shaderInt64; + VkBool32 shaderInt16; + VkBool32 shaderResourceResidency; + VkBool32 shaderResourceMinLod; + VkBool32 sparseBinding; + VkBool32 sparseResidencyBuffer; + VkBool32 sparseResidencyImage2D; + VkBool32 sparseResidencyImage3D; + VkBool32 sparseResidency2Samples; + VkBool32 sparseResidency4Samples; + VkBool32 sparseResidency8Samples; + VkBool32 sparseResidency16Samples; + VkBool32 sparseResidencyAliased; + VkBool32 variableMultisampleRate; + VkBool32 inheritedQueries; +} VkPhysicalDeviceFeatures; + +typedef struct VkFormatProperties { + VkFormatFeatureFlags linearTilingFeatures; + VkFormatFeatureFlags optimalTilingFeatures; + VkFormatFeatureFlags bufferFeatures; +} VkFormatProperties; + +typedef struct VkExtent3D { + uint32_t width; + uint32_t height; + uint32_t depth; +} VkExtent3D; + +typedef struct VkImageFormatProperties { + VkExtent3D maxExtent; + uint32_t maxMipLevels; + uint32_t maxArrayLayers; + VkSampleCountFlags sampleCounts; + VkDeviceSize maxResourceSize; +} VkImageFormatProperties; + +typedef struct VkPhysicalDeviceLimits { + uint32_t maxImageDimension1D; + uint32_t maxImageDimension2D; + uint32_t maxImageDimension3D; + uint32_t maxImageDimensionCube; + uint32_t maxImageArrayLayers; + uint32_t maxTexelBufferElements; + uint32_t maxUniformBufferRange; + uint32_t maxStorageBufferRange; + uint32_t maxPushConstantsSize; + uint32_t maxMemoryAllocationCount; + uint32_t maxSamplerAllocationCount; + VkDeviceSize bufferImageGranularity; + VkDeviceSize sparseAddressSpaceSize; + uint32_t maxBoundDescriptorSets; + uint32_t maxPerStageDescriptorSamplers; + uint32_t maxPerStageDescriptorUniformBuffers; + uint32_t maxPerStageDescriptorStorageBuffers; + uint32_t maxPerStageDescriptorSampledImages; + uint32_t maxPerStageDescriptorStorageImages; + uint32_t maxPerStageDescriptorInputAttachments; + uint32_t maxPerStageResources; + uint32_t maxDescriptorSetSamplers; + uint32_t maxDescriptorSetUniformBuffers; + uint32_t maxDescriptorSetUniformBuffersDynamic; + uint32_t maxDescriptorSetStorageBuffers; + uint32_t maxDescriptorSetStorageBuffersDynamic; + uint32_t maxDescriptorSetSampledImages; + uint32_t maxDescriptorSetStorageImages; + uint32_t maxDescriptorSetInputAttachments; + uint32_t maxVertexInputAttributes; + uint32_t maxVertexInputBindings; + uint32_t maxVertexInputAttributeOffset; + uint32_t maxVertexInputBindingStride; + uint32_t maxVertexOutputComponents; + uint32_t maxTessellationGenerationLevel; + uint32_t maxTessellationPatchSize; + uint32_t maxTessellationControlPerVertexInputComponents; + uint32_t maxTessellationControlPerVertexOutputComponents; + uint32_t maxTessellationControlPerPatchOutputComponents; + uint32_t maxTessellationControlTotalOutputComponents; + uint32_t maxTessellationEvaluationInputComponents; + uint32_t maxTessellationEvaluationOutputComponents; + uint32_t maxGeometryShaderInvocations; + uint32_t maxGeometryInputComponents; + uint32_t maxGeometryOutputComponents; + uint32_t maxGeometryOutputVertices; + uint32_t maxGeometryTotalOutputComponents; + uint32_t maxFragmentInputComponents; + uint32_t maxFragmentOutputAttachments; + uint32_t maxFragmentDualSrcAttachments; + uint32_t maxFragmentCombinedOutputResources; + uint32_t maxComputeSharedMemorySize; + uint32_t maxComputeWorkGroupCount[3]; + uint32_t maxComputeWorkGroupInvocations; + uint32_t maxComputeWorkGroupSize[3]; + uint32_t subPixelPrecisionBits; + uint32_t subTexelPrecisionBits; + uint32_t mipmapPrecisionBits; + uint32_t maxDrawIndexedIndexValue; + uint32_t maxDrawIndirectCount; + float maxSamplerLodBias; + float maxSamplerAnisotropy; + uint32_t maxViewports; + uint32_t maxViewportDimensions[2]; + float viewportBoundsRange[2]; + uint32_t viewportSubPixelBits; + size_t minMemoryMapAlignment; + VkDeviceSize minTexelBufferOffsetAlignment; + VkDeviceSize minUniformBufferOffsetAlignment; + VkDeviceSize minStorageBufferOffsetAlignment; + int32_t minTexelOffset; + uint32_t maxTexelOffset; + int32_t minTexelGatherOffset; + uint32_t maxTexelGatherOffset; + float minInterpolationOffset; + float maxInterpolationOffset; + uint32_t subPixelInterpolationOffsetBits; + uint32_t maxFramebufferWidth; + uint32_t maxFramebufferHeight; + uint32_t maxFramebufferLayers; + VkSampleCountFlags framebufferColorSampleCounts; + VkSampleCountFlags framebufferDepthSampleCounts; + VkSampleCountFlags framebufferStencilSampleCounts; + VkSampleCountFlags framebufferNoAttachmentsSampleCounts; + uint32_t maxColorAttachments; + VkSampleCountFlags sampledImageColorSampleCounts; + VkSampleCountFlags sampledImageIntegerSampleCounts; + VkSampleCountFlags sampledImageDepthSampleCounts; + VkSampleCountFlags sampledImageStencilSampleCounts; + VkSampleCountFlags storageImageSampleCounts; + uint32_t maxSampleMaskWords; + VkBool32 timestampComputeAndGraphics; + float timestampPeriod; + uint32_t maxClipDistances; + uint32_t maxCullDistances; + uint32_t maxCombinedClipAndCullDistances; + uint32_t discreteQueuePriorities; + float pointSizeRange[2]; + float lineWidthRange[2]; + float pointSizeGranularity; + float lineWidthGranularity; + VkBool32 strictLines; + VkBool32 standardSampleLocations; + VkDeviceSize optimalBufferCopyOffsetAlignment; + VkDeviceSize optimalBufferCopyRowPitchAlignment; + VkDeviceSize nonCoherentAtomSize; +} VkPhysicalDeviceLimits; + +typedef struct VkPhysicalDeviceSparseProperties { + VkBool32 residencyStandard2DBlockShape; + VkBool32 residencyStandard2DMultisampleBlockShape; + VkBool32 residencyStandard3DBlockShape; + VkBool32 residencyAlignedMipSize; + VkBool32 residencyNonResidentStrict; +} VkPhysicalDeviceSparseProperties; + +typedef struct VkPhysicalDeviceProperties { + uint32_t apiVersion; + uint32_t driverVersion; + uint32_t vendorID; + uint32_t deviceID; + VkPhysicalDeviceType deviceType; + char deviceName[VK_MAX_PHYSICAL_DEVICE_NAME_SIZE]; + uint8_t pipelineCacheUUID[VK_UUID_SIZE]; + VkPhysicalDeviceLimits limits; + VkPhysicalDeviceSparseProperties sparseProperties; +} VkPhysicalDeviceProperties; + +typedef struct VkQueueFamilyProperties { + VkQueueFlags queueFlags; + uint32_t queueCount; + uint32_t timestampValidBits; + VkExtent3D minImageTransferGranularity; +} VkQueueFamilyProperties; + +typedef struct VkMemoryType { + VkMemoryPropertyFlags propertyFlags; + uint32_t heapIndex; +} VkMemoryType; + +typedef struct VkMemoryHeap { + VkDeviceSize size; + VkMemoryHeapFlags flags; +} VkMemoryHeap; + +typedef struct VkPhysicalDeviceMemoryProperties { + uint32_t memoryTypeCount; + VkMemoryType memoryTypes[VK_MAX_MEMORY_TYPES]; + uint32_t memoryHeapCount; + VkMemoryHeap memoryHeaps[VK_MAX_MEMORY_HEAPS]; +} VkPhysicalDeviceMemoryProperties; + +typedef void (VKAPI_PTR *PFN_vkVoidFunction)(void); +typedef struct VkDeviceQueueCreateInfo { + VkStructureType sType; + const void* pNext; + VkDeviceQueueCreateFlags flags; + uint32_t queueFamilyIndex; + uint32_t queueCount; + const float* pQueuePriorities; +} VkDeviceQueueCreateInfo; + +typedef struct VkDeviceCreateInfo { + VkStructureType sType; + const void* pNext; + VkDeviceCreateFlags flags; + uint32_t queueCreateInfoCount; + const VkDeviceQueueCreateInfo* pQueueCreateInfos; + uint32_t enabledLayerCount; + const char* const* ppEnabledLayerNames; + uint32_t enabledExtensionCount; + const char* const* ppEnabledExtensionNames; + const VkPhysicalDeviceFeatures* pEnabledFeatures; +} VkDeviceCreateInfo; + +typedef struct VkExtensionProperties { + char extensionName[VK_MAX_EXTENSION_NAME_SIZE]; + uint32_t specVersion; +} VkExtensionProperties; + +typedef struct VkLayerProperties { + char layerName[VK_MAX_EXTENSION_NAME_SIZE]; + uint32_t specVersion; + uint32_t implementationVersion; + char description[VK_MAX_DESCRIPTION_SIZE]; +} VkLayerProperties; + +typedef struct VkSubmitInfo { + VkStructureType sType; + const void* pNext; + uint32_t waitSemaphoreCount; + const VkSemaphore* pWaitSemaphores; + const VkPipelineStageFlags* pWaitDstStageMask; + uint32_t commandBufferCount; + const VkCommandBuffer* pCommandBuffers; + uint32_t signalSemaphoreCount; + const VkSemaphore* pSignalSemaphores; +} VkSubmitInfo; + +typedef struct VkMemoryAllocateInfo { + VkStructureType sType; + const void* pNext; + VkDeviceSize allocationSize; + uint32_t memoryTypeIndex; +} VkMemoryAllocateInfo; + +typedef struct VkMappedMemoryRange { + VkStructureType sType; + const void* pNext; + VkDeviceMemory memory; + VkDeviceSize offset; + VkDeviceSize size; +} VkMappedMemoryRange; + +typedef struct VkMemoryRequirements { + VkDeviceSize size; + VkDeviceSize alignment; + uint32_t memoryTypeBits; +} VkMemoryRequirements; + +typedef struct VkSparseImageFormatProperties { + VkImageAspectFlags aspectMask; + VkExtent3D imageGranularity; + VkSparseImageFormatFlags flags; +} VkSparseImageFormatProperties; + +typedef struct VkSparseImageMemoryRequirements { + VkSparseImageFormatProperties formatProperties; + uint32_t imageMipTailFirstLod; + VkDeviceSize imageMipTailSize; + VkDeviceSize imageMipTailOffset; + VkDeviceSize imageMipTailStride; +} VkSparseImageMemoryRequirements; + +typedef struct VkSparseMemoryBind { + VkDeviceSize resourceOffset; + VkDeviceSize size; + VkDeviceMemory memory; + VkDeviceSize memoryOffset; + VkSparseMemoryBindFlags flags; +} VkSparseMemoryBind; + +typedef struct VkSparseBufferMemoryBindInfo { + VkBuffer buffer; + uint32_t bindCount; + const VkSparseMemoryBind* pBinds; +} VkSparseBufferMemoryBindInfo; + +typedef struct VkSparseImageOpaqueMemoryBindInfo { + VkImage image; + uint32_t bindCount; + const VkSparseMemoryBind* pBinds; +} VkSparseImageOpaqueMemoryBindInfo; + +typedef struct VkImageSubresource { + VkImageAspectFlags aspectMask; + uint32_t mipLevel; + uint32_t arrayLayer; +} VkImageSubresource; + +typedef struct VkOffset3D { + int32_t x; + int32_t y; + int32_t z; +} VkOffset3D; + +typedef struct VkSparseImageMemoryBind { + VkImageSubresource subresource; + VkOffset3D offset; + VkExtent3D extent; + VkDeviceMemory memory; + VkDeviceSize memoryOffset; + VkSparseMemoryBindFlags flags; +} VkSparseImageMemoryBind; + +typedef struct VkSparseImageMemoryBindInfo { + VkImage image; + uint32_t bindCount; + const VkSparseImageMemoryBind* pBinds; +} VkSparseImageMemoryBindInfo; + +typedef struct VkBindSparseInfo { + VkStructureType sType; + const void* pNext; + uint32_t waitSemaphoreCount; + const VkSemaphore* pWaitSemaphores; + uint32_t bufferBindCount; + const VkSparseBufferMemoryBindInfo* pBufferBinds; + uint32_t imageOpaqueBindCount; + const VkSparseImageOpaqueMemoryBindInfo* pImageOpaqueBinds; + uint32_t imageBindCount; + const VkSparseImageMemoryBindInfo* pImageBinds; + uint32_t signalSemaphoreCount; + const VkSemaphore* pSignalSemaphores; +} VkBindSparseInfo; + +typedef struct VkFenceCreateInfo { + VkStructureType sType; + const void* pNext; + VkFenceCreateFlags flags; +} VkFenceCreateInfo; + +typedef struct VkSemaphoreCreateInfo { + VkStructureType sType; + const void* pNext; + VkSemaphoreCreateFlags flags; +} VkSemaphoreCreateInfo; + +typedef struct VkEventCreateInfo { + VkStructureType sType; + const void* pNext; + VkEventCreateFlags flags; +} VkEventCreateInfo; + +typedef struct VkQueryPoolCreateInfo { + VkStructureType sType; + const void* pNext; + VkQueryPoolCreateFlags flags; + VkQueryType queryType; + uint32_t queryCount; + VkQueryPipelineStatisticFlags pipelineStatistics; +} VkQueryPoolCreateInfo; + +typedef struct VkBufferCreateInfo { + VkStructureType sType; + const void* pNext; + VkBufferCreateFlags flags; + VkDeviceSize size; + VkBufferUsageFlags usage; + VkSharingMode sharingMode; + uint32_t queueFamilyIndexCount; + const uint32_t* pQueueFamilyIndices; +} VkBufferCreateInfo; + +typedef struct VkBufferViewCreateInfo { + VkStructureType sType; + const void* pNext; + VkBufferViewCreateFlags flags; + VkBuffer buffer; + VkFormat format; + VkDeviceSize offset; + VkDeviceSize range; +} VkBufferViewCreateInfo; + +typedef struct VkImageCreateInfo { + VkStructureType sType; + const void* pNext; + VkImageCreateFlags flags; + VkImageType imageType; + VkFormat format; + VkExtent3D extent; + uint32_t mipLevels; + uint32_t arrayLayers; + VkSampleCountFlagBits samples; + VkImageTiling tiling; + VkImageUsageFlags usage; + VkSharingMode sharingMode; + uint32_t queueFamilyIndexCount; + const uint32_t* pQueueFamilyIndices; + VkImageLayout initialLayout; +} VkImageCreateInfo; + +typedef struct VkSubresourceLayout { + VkDeviceSize offset; + VkDeviceSize size; + VkDeviceSize rowPitch; + VkDeviceSize arrayPitch; + VkDeviceSize depthPitch; +} VkSubresourceLayout; + +typedef struct VkComponentMapping { + VkComponentSwizzle r; + VkComponentSwizzle g; + VkComponentSwizzle b; + VkComponentSwizzle a; +} VkComponentMapping; + +typedef struct VkImageSubresourceRange { + VkImageAspectFlags aspectMask; + uint32_t baseMipLevel; + uint32_t levelCount; + uint32_t baseArrayLayer; + uint32_t layerCount; +} VkImageSubresourceRange; + +typedef struct VkImageViewCreateInfo { + VkStructureType sType; + const void* pNext; + VkImageViewCreateFlags flags; + VkImage image; + VkImageViewType viewType; + VkFormat format; + VkComponentMapping components; + VkImageSubresourceRange subresourceRange; +} VkImageViewCreateInfo; + +typedef struct VkShaderModuleCreateInfo { + VkStructureType sType; + const void* pNext; + VkShaderModuleCreateFlags flags; + size_t codeSize; + const uint32_t* pCode; +} VkShaderModuleCreateInfo; + +typedef struct VkPipelineCacheCreateInfo { + VkStructureType sType; + const void* pNext; + VkPipelineCacheCreateFlags flags; + size_t initialDataSize; + const void* pInitialData; +} VkPipelineCacheCreateInfo; + +typedef struct VkSpecializationMapEntry { + uint32_t constantID; + uint32_t offset; + size_t size; +} VkSpecializationMapEntry; + +typedef struct VkSpecializationInfo { + uint32_t mapEntryCount; + const VkSpecializationMapEntry* pMapEntries; + size_t dataSize; + const void* pData; +} VkSpecializationInfo; + +typedef struct VkPipelineShaderStageCreateInfo { + VkStructureType sType; + const void* pNext; + VkPipelineShaderStageCreateFlags flags; + VkShaderStageFlagBits stage; + VkShaderModule module; + const char* pName; + const VkSpecializationInfo* pSpecializationInfo; +} VkPipelineShaderStageCreateInfo; + +typedef struct VkVertexInputBindingDescription { + uint32_t binding; + uint32_t stride; + VkVertexInputRate inputRate; +} VkVertexInputBindingDescription; + +typedef struct VkVertexInputAttributeDescription { + uint32_t location; + uint32_t binding; + VkFormat format; + uint32_t offset; +} VkVertexInputAttributeDescription; + +typedef struct VkPipelineVertexInputStateCreateInfo { + VkStructureType sType; + const void* pNext; + VkPipelineVertexInputStateCreateFlags flags; + uint32_t vertexBindingDescriptionCount; + const VkVertexInputBindingDescription* pVertexBindingDescriptions; + uint32_t vertexAttributeDescriptionCount; + const VkVertexInputAttributeDescription* pVertexAttributeDescriptions; +} VkPipelineVertexInputStateCreateInfo; + +typedef struct VkPipelineInputAssemblyStateCreateInfo { + VkStructureType sType; + const void* pNext; + VkPipelineInputAssemblyStateCreateFlags flags; + VkPrimitiveTopology topology; + VkBool32 primitiveRestartEnable; +} VkPipelineInputAssemblyStateCreateInfo; + +typedef struct VkPipelineTessellationStateCreateInfo { + VkStructureType sType; + const void* pNext; + VkPipelineTessellationStateCreateFlags flags; + uint32_t patchControlPoints; +} VkPipelineTessellationStateCreateInfo; + +typedef struct VkViewport { + float x; + float y; + float width; + float height; + float minDepth; + float maxDepth; +} VkViewport; + +typedef struct VkOffset2D { + int32_t x; + int32_t y; +} VkOffset2D; + +typedef struct VkExtent2D { + uint32_t width; + uint32_t height; +} VkExtent2D; + +typedef struct VkRect2D { + VkOffset2D offset; + VkExtent2D extent; +} VkRect2D; + +typedef struct VkPipelineViewportStateCreateInfo { + VkStructureType sType; + const void* pNext; + VkPipelineViewportStateCreateFlags flags; + uint32_t viewportCount; + const VkViewport* pViewports; + uint32_t scissorCount; + const VkRect2D* pScissors; +} VkPipelineViewportStateCreateInfo; + +typedef struct VkPipelineRasterizationStateCreateInfo { + VkStructureType sType; + const void* pNext; + VkPipelineRasterizationStateCreateFlags flags; + VkBool32 depthClampEnable; + VkBool32 rasterizerDiscardEnable; + VkPolygonMode polygonMode; + VkCullModeFlags cullMode; + VkFrontFace frontFace; + VkBool32 depthBiasEnable; + float depthBiasConstantFactor; + float depthBiasClamp; + float depthBiasSlopeFactor; + float lineWidth; +} VkPipelineRasterizationStateCreateInfo; + +typedef struct VkPipelineMultisampleStateCreateInfo { + VkStructureType sType; + const void* pNext; + VkPipelineMultisampleStateCreateFlags flags; + VkSampleCountFlagBits rasterizationSamples; + VkBool32 sampleShadingEnable; + float minSampleShading; + const VkSampleMask* pSampleMask; + VkBool32 alphaToCoverageEnable; + VkBool32 alphaToOneEnable; +} VkPipelineMultisampleStateCreateInfo; + +typedef struct VkStencilOpState { + VkStencilOp failOp; + VkStencilOp passOp; + VkStencilOp depthFailOp; + VkCompareOp compareOp; + uint32_t compareMask; + uint32_t writeMask; + uint32_t reference; +} VkStencilOpState; + +typedef struct VkPipelineDepthStencilStateCreateInfo { + VkStructureType sType; + const void* pNext; + VkPipelineDepthStencilStateCreateFlags flags; + VkBool32 depthTestEnable; + VkBool32 depthWriteEnable; + VkCompareOp depthCompareOp; + VkBool32 depthBoundsTestEnable; + VkBool32 stencilTestEnable; + VkStencilOpState front; + VkStencilOpState back; + float minDepthBounds; + float maxDepthBounds; +} VkPipelineDepthStencilStateCreateInfo; + +typedef struct VkPipelineColorBlendAttachmentState { + VkBool32 blendEnable; + VkBlendFactor srcColorBlendFactor; + VkBlendFactor dstColorBlendFactor; + VkBlendOp colorBlendOp; + VkBlendFactor srcAlphaBlendFactor; + VkBlendFactor dstAlphaBlendFactor; + VkBlendOp alphaBlendOp; + VkColorComponentFlags colorWriteMask; +} VkPipelineColorBlendAttachmentState; + +typedef struct VkPipelineColorBlendStateCreateInfo { + VkStructureType sType; + const void* pNext; + VkPipelineColorBlendStateCreateFlags flags; + VkBool32 logicOpEnable; + VkLogicOp logicOp; + uint32_t attachmentCount; + const VkPipelineColorBlendAttachmentState* pAttachments; + float blendConstants[4]; +} VkPipelineColorBlendStateCreateInfo; + +typedef struct VkPipelineDynamicStateCreateInfo { + VkStructureType sType; + const void* pNext; + VkPipelineDynamicStateCreateFlags flags; + uint32_t dynamicStateCount; + const VkDynamicState* pDynamicStates; +} VkPipelineDynamicStateCreateInfo; + +typedef struct VkGraphicsPipelineCreateInfo { + VkStructureType sType; + const void* pNext; + VkPipelineCreateFlags flags; + uint32_t stageCount; + const VkPipelineShaderStageCreateInfo* pStages; + const VkPipelineVertexInputStateCreateInfo* pVertexInputState; + const VkPipelineInputAssemblyStateCreateInfo* pInputAssemblyState; + const VkPipelineTessellationStateCreateInfo* pTessellationState; + const VkPipelineViewportStateCreateInfo* pViewportState; + const VkPipelineRasterizationStateCreateInfo* pRasterizationState; + const VkPipelineMultisampleStateCreateInfo* pMultisampleState; + const VkPipelineDepthStencilStateCreateInfo* pDepthStencilState; + const VkPipelineColorBlendStateCreateInfo* pColorBlendState; + const VkPipelineDynamicStateCreateInfo* pDynamicState; + VkPipelineLayout layout; + VkRenderPass renderPass; + uint32_t subpass; + VkPipeline basePipelineHandle; + int32_t basePipelineIndex; +} VkGraphicsPipelineCreateInfo; + +typedef struct VkComputePipelineCreateInfo { + VkStructureType sType; + const void* pNext; + VkPipelineCreateFlags flags; + VkPipelineShaderStageCreateInfo stage; + VkPipelineLayout layout; + VkPipeline basePipelineHandle; + int32_t basePipelineIndex; +} VkComputePipelineCreateInfo; + +typedef struct VkPushConstantRange { + VkShaderStageFlags stageFlags; + uint32_t offset; + uint32_t size; +} VkPushConstantRange; + +typedef struct VkPipelineLayoutCreateInfo { + VkStructureType sType; + const void* pNext; + VkPipelineLayoutCreateFlags flags; + uint32_t setLayoutCount; + const VkDescriptorSetLayout* pSetLayouts; + uint32_t pushConstantRangeCount; + const VkPushConstantRange* pPushConstantRanges; +} VkPipelineLayoutCreateInfo; + +typedef struct VkSamplerCreateInfo { + VkStructureType sType; + const void* pNext; + VkSamplerCreateFlags flags; + VkFilter magFilter; + VkFilter minFilter; + VkSamplerMipmapMode mipmapMode; + VkSamplerAddressMode addressModeU; + VkSamplerAddressMode addressModeV; + VkSamplerAddressMode addressModeW; + float mipLodBias; + VkBool32 anisotropyEnable; + float maxAnisotropy; + VkBool32 compareEnable; + VkCompareOp compareOp; + float minLod; + float maxLod; + VkBorderColor borderColor; + VkBool32 unnormalizedCoordinates; +} VkSamplerCreateInfo; + +typedef struct VkDescriptorSetLayoutBinding { + uint32_t binding; + VkDescriptorType descriptorType; + uint32_t descriptorCount; + VkShaderStageFlags stageFlags; + const VkSampler* pImmutableSamplers; +} VkDescriptorSetLayoutBinding; + +typedef struct VkDescriptorSetLayoutCreateInfo { + VkStructureType sType; + const void* pNext; + VkDescriptorSetLayoutCreateFlags flags; + uint32_t bindingCount; + const VkDescriptorSetLayoutBinding* pBindings; +} VkDescriptorSetLayoutCreateInfo; + +typedef struct VkDescriptorPoolSize { + VkDescriptorType type; + uint32_t descriptorCount; +} VkDescriptorPoolSize; + +typedef struct VkDescriptorPoolCreateInfo { + VkStructureType sType; + const void* pNext; + VkDescriptorPoolCreateFlags flags; + uint32_t maxSets; + uint32_t poolSizeCount; + const VkDescriptorPoolSize* pPoolSizes; +} VkDescriptorPoolCreateInfo; + +typedef struct VkDescriptorSetAllocateInfo { + VkStructureType sType; + const void* pNext; + VkDescriptorPool descriptorPool; + uint32_t descriptorSetCount; + const VkDescriptorSetLayout* pSetLayouts; +} VkDescriptorSetAllocateInfo; + +typedef struct VkDescriptorImageInfo { + VkSampler sampler; + VkImageView imageView; + VkImageLayout imageLayout; +} VkDescriptorImageInfo; + +typedef struct VkDescriptorBufferInfo { + VkBuffer buffer; + VkDeviceSize offset; + VkDeviceSize range; +} VkDescriptorBufferInfo; + +typedef struct VkWriteDescriptorSet { + VkStructureType sType; + const void* pNext; + VkDescriptorSet dstSet; + uint32_t dstBinding; + uint32_t dstArrayElement; + uint32_t descriptorCount; + VkDescriptorType descriptorType; + const VkDescriptorImageInfo* pImageInfo; + const VkDescriptorBufferInfo* pBufferInfo; + const VkBufferView* pTexelBufferView; +} VkWriteDescriptorSet; + +typedef struct VkCopyDescriptorSet { + VkStructureType sType; + const void* pNext; + VkDescriptorSet srcSet; + uint32_t srcBinding; + uint32_t srcArrayElement; + VkDescriptorSet dstSet; + uint32_t dstBinding; + uint32_t dstArrayElement; + uint32_t descriptorCount; +} VkCopyDescriptorSet; + +typedef struct VkFramebufferCreateInfo { + VkStructureType sType; + const void* pNext; + VkFramebufferCreateFlags flags; + VkRenderPass renderPass; + uint32_t attachmentCount; + const VkImageView* pAttachments; + uint32_t width; + uint32_t height; + uint32_t layers; +} VkFramebufferCreateInfo; + +typedef struct VkAttachmentDescription { + VkAttachmentDescriptionFlags flags; + VkFormat format; + VkSampleCountFlagBits samples; + VkAttachmentLoadOp loadOp; + VkAttachmentStoreOp storeOp; + VkAttachmentLoadOp stencilLoadOp; + VkAttachmentStoreOp stencilStoreOp; + VkImageLayout initialLayout; + VkImageLayout finalLayout; +} VkAttachmentDescription; + +typedef struct VkAttachmentReference { + uint32_t attachment; + VkImageLayout layout; +} VkAttachmentReference; + +typedef struct VkSubpassDescription { + VkSubpassDescriptionFlags flags; + VkPipelineBindPoint pipelineBindPoint; + uint32_t inputAttachmentCount; + const VkAttachmentReference* pInputAttachments; + uint32_t colorAttachmentCount; + const VkAttachmentReference* pColorAttachments; + const VkAttachmentReference* pResolveAttachments; + const VkAttachmentReference* pDepthStencilAttachment; + uint32_t preserveAttachmentCount; + const uint32_t* pPreserveAttachments; +} VkSubpassDescription; + +typedef struct VkSubpassDependency { + uint32_t srcSubpass; + uint32_t dstSubpass; + VkPipelineStageFlags srcStageMask; + VkPipelineStageFlags dstStageMask; + VkAccessFlags srcAccessMask; + VkAccessFlags dstAccessMask; + VkDependencyFlags dependencyFlags; +} VkSubpassDependency; + +typedef struct VkRenderPassCreateInfo { + VkStructureType sType; + const void* pNext; + VkRenderPassCreateFlags flags; + uint32_t attachmentCount; + const VkAttachmentDescription* pAttachments; + uint32_t subpassCount; + const VkSubpassDescription* pSubpasses; + uint32_t dependencyCount; + const VkSubpassDependency* pDependencies; +} VkRenderPassCreateInfo; + +typedef struct VkCommandPoolCreateInfo { + VkStructureType sType; + const void* pNext; + VkCommandPoolCreateFlags flags; + uint32_t queueFamilyIndex; +} VkCommandPoolCreateInfo; + +typedef struct VkCommandBufferAllocateInfo { + VkStructureType sType; + const void* pNext; + VkCommandPool commandPool; + VkCommandBufferLevel level; + uint32_t commandBufferCount; +} VkCommandBufferAllocateInfo; + +typedef struct VkCommandBufferInheritanceInfo { + VkStructureType sType; + const void* pNext; + VkRenderPass renderPass; + uint32_t subpass; + VkFramebuffer framebuffer; + VkBool32 occlusionQueryEnable; + VkQueryControlFlags queryFlags; + VkQueryPipelineStatisticFlags pipelineStatistics; +} VkCommandBufferInheritanceInfo; + +typedef struct VkCommandBufferBeginInfo { + VkStructureType sType; + const void* pNext; + VkCommandBufferUsageFlags flags; + const VkCommandBufferInheritanceInfo* pInheritanceInfo; +} VkCommandBufferBeginInfo; + +typedef struct VkBufferCopy { + VkDeviceSize srcOffset; + VkDeviceSize dstOffset; + VkDeviceSize size; +} VkBufferCopy; + +typedef struct VkImageSubresourceLayers { + VkImageAspectFlags aspectMask; + uint32_t mipLevel; + uint32_t baseArrayLayer; + uint32_t layerCount; +} VkImageSubresourceLayers; + +typedef struct VkImageCopy { + VkImageSubresourceLayers srcSubresource; + VkOffset3D srcOffset; + VkImageSubresourceLayers dstSubresource; + VkOffset3D dstOffset; + VkExtent3D extent; +} VkImageCopy; + +typedef struct VkImageBlit { + VkImageSubresourceLayers srcSubresource; + VkOffset3D srcOffsets[2]; + VkImageSubresourceLayers dstSubresource; + VkOffset3D dstOffsets[2]; +} VkImageBlit; + +typedef struct VkBufferImageCopy { + VkDeviceSize bufferOffset; + uint32_t bufferRowLength; + uint32_t bufferImageHeight; + VkImageSubresourceLayers imageSubresource; + VkOffset3D imageOffset; + VkExtent3D imageExtent; +} VkBufferImageCopy; + +typedef union VkClearColorValue { + float float32[4]; + int32_t int32[4]; + uint32_t uint32[4]; +} VkClearColorValue; + +typedef struct VkClearDepthStencilValue { + float depth; + uint32_t stencil; +} VkClearDepthStencilValue; + +typedef union VkClearValue { + VkClearColorValue color; + VkClearDepthStencilValue depthStencil; +} VkClearValue; + +typedef struct VkClearAttachment { + VkImageAspectFlags aspectMask; + uint32_t colorAttachment; + VkClearValue clearValue; +} VkClearAttachment; + +typedef struct VkClearRect { + VkRect2D rect; + uint32_t baseArrayLayer; + uint32_t layerCount; +} VkClearRect; + +typedef struct VkImageResolve { + VkImageSubresourceLayers srcSubresource; + VkOffset3D srcOffset; + VkImageSubresourceLayers dstSubresource; + VkOffset3D dstOffset; + VkExtent3D extent; +} VkImageResolve; + +typedef struct VkMemoryBarrier { + VkStructureType sType; + const void* pNext; + VkAccessFlags srcAccessMask; + VkAccessFlags dstAccessMask; +} VkMemoryBarrier; + +typedef struct VkBufferMemoryBarrier { + VkStructureType sType; + const void* pNext; + VkAccessFlags srcAccessMask; + VkAccessFlags dstAccessMask; + uint32_t srcQueueFamilyIndex; + uint32_t dstQueueFamilyIndex; + VkBuffer buffer; + VkDeviceSize offset; + VkDeviceSize size; +} VkBufferMemoryBarrier; + +typedef struct VkImageMemoryBarrier { + VkStructureType sType; + const void* pNext; + VkAccessFlags srcAccessMask; + VkAccessFlags dstAccessMask; + VkImageLayout oldLayout; + VkImageLayout newLayout; + uint32_t srcQueueFamilyIndex; + uint32_t dstQueueFamilyIndex; + VkImage image; + VkImageSubresourceRange subresourceRange; +} VkImageMemoryBarrier; + +typedef struct VkRenderPassBeginInfo { + VkStructureType sType; + const void* pNext; + VkRenderPass renderPass; + VkFramebuffer framebuffer; + VkRect2D renderArea; + uint32_t clearValueCount; + const VkClearValue* pClearValues; +} VkRenderPassBeginInfo; + +typedef struct VkDispatchIndirectCommand { + uint32_t x; + uint32_t y; + uint32_t z; +} VkDispatchIndirectCommand; + +typedef struct VkDrawIndexedIndirectCommand { + uint32_t indexCount; + uint32_t instanceCount; + uint32_t firstIndex; + int32_t vertexOffset; + uint32_t firstInstance; +} VkDrawIndexedIndirectCommand; + +typedef struct VkDrawIndirectCommand { + uint32_t vertexCount; + uint32_t instanceCount; + uint32_t firstVertex; + uint32_t firstInstance; +} VkDrawIndirectCommand; + +typedef struct VkBaseOutStructure { + VkStructureType sType; + struct VkBaseOutStructure* pNext; +} VkBaseOutStructure; + +typedef struct VkBaseInStructure { + VkStructureType sType; + const struct VkBaseInStructure* pNext; +} VkBaseInStructure; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateInstance)(const VkInstanceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkInstance* pInstance); +typedef void (VKAPI_PTR *PFN_vkDestroyInstance)(VkInstance instance, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkEnumeratePhysicalDevices)(VkInstance instance, uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceFeatures)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures* pFeatures); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceFormatProperties)(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties* pFormatProperties); +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceImageFormatProperties)(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* pImageFormatProperties); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceProperties)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties* pProperties); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceQueueFamilyProperties)(VkPhysicalDevice physicalDevice, uint32_t* pQueueFamilyPropertyCount, VkQueueFamilyProperties* pQueueFamilyProperties); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceMemoryProperties)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties* pMemoryProperties); +typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_vkGetInstanceProcAddr)(VkInstance instance, const char* pName); +typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_vkGetDeviceProcAddr)(VkDevice device, const char* pName); +typedef VkResult (VKAPI_PTR *PFN_vkCreateDevice)(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDevice* pDevice); +typedef void (VKAPI_PTR *PFN_vkDestroyDevice)(VkDevice device, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkEnumerateInstanceExtensionProperties)(const char* pLayerName, uint32_t* pPropertyCount, VkExtensionProperties* pProperties); +typedef VkResult (VKAPI_PTR *PFN_vkEnumerateDeviceExtensionProperties)(VkPhysicalDevice physicalDevice, const char* pLayerName, uint32_t* pPropertyCount, VkExtensionProperties* pProperties); +typedef VkResult (VKAPI_PTR *PFN_vkEnumerateInstanceLayerProperties)(uint32_t* pPropertyCount, VkLayerProperties* pProperties); +typedef VkResult (VKAPI_PTR *PFN_vkEnumerateDeviceLayerProperties)(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkLayerProperties* pProperties); +typedef void (VKAPI_PTR *PFN_vkGetDeviceQueue)(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue* pQueue); +typedef VkResult (VKAPI_PTR *PFN_vkQueueSubmit)(VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmits, VkFence fence); +typedef VkResult (VKAPI_PTR *PFN_vkQueueWaitIdle)(VkQueue queue); +typedef VkResult (VKAPI_PTR *PFN_vkDeviceWaitIdle)(VkDevice device); +typedef VkResult (VKAPI_PTR *PFN_vkAllocateMemory)(VkDevice device, const VkMemoryAllocateInfo* pAllocateInfo, const VkAllocationCallbacks* pAllocator, VkDeviceMemory* pMemory); +typedef void (VKAPI_PTR *PFN_vkFreeMemory)(VkDevice device, VkDeviceMemory memory, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkMapMemory)(VkDevice device, VkDeviceMemory memory, VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags, void** ppData); +typedef void (VKAPI_PTR *PFN_vkUnmapMemory)(VkDevice device, VkDeviceMemory memory); +typedef VkResult (VKAPI_PTR *PFN_vkFlushMappedMemoryRanges)(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange* pMemoryRanges); +typedef VkResult (VKAPI_PTR *PFN_vkInvalidateMappedMemoryRanges)(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange* pMemoryRanges); +typedef void (VKAPI_PTR *PFN_vkGetDeviceMemoryCommitment)(VkDevice device, VkDeviceMemory memory, VkDeviceSize* pCommittedMemoryInBytes); +typedef VkResult (VKAPI_PTR *PFN_vkBindBufferMemory)(VkDevice device, VkBuffer buffer, VkDeviceMemory memory, VkDeviceSize memoryOffset); +typedef VkResult (VKAPI_PTR *PFN_vkBindImageMemory)(VkDevice device, VkImage image, VkDeviceMemory memory, VkDeviceSize memoryOffset); +typedef void (VKAPI_PTR *PFN_vkGetBufferMemoryRequirements)(VkDevice device, VkBuffer buffer, VkMemoryRequirements* pMemoryRequirements); +typedef void (VKAPI_PTR *PFN_vkGetImageMemoryRequirements)(VkDevice device, VkImage image, VkMemoryRequirements* pMemoryRequirements); +typedef void (VKAPI_PTR *PFN_vkGetImageSparseMemoryRequirements)(VkDevice device, VkImage image, uint32_t* pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements* pSparseMemoryRequirements); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceSparseImageFormatProperties)(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkSampleCountFlagBits samples, VkImageUsageFlags usage, VkImageTiling tiling, uint32_t* pPropertyCount, VkSparseImageFormatProperties* pProperties); +typedef VkResult (VKAPI_PTR *PFN_vkQueueBindSparse)(VkQueue queue, uint32_t bindInfoCount, const VkBindSparseInfo* pBindInfo, VkFence fence); +typedef VkResult (VKAPI_PTR *PFN_vkCreateFence)(VkDevice device, const VkFenceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkFence* pFence); +typedef void (VKAPI_PTR *PFN_vkDestroyFence)(VkDevice device, VkFence fence, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkResetFences)(VkDevice device, uint32_t fenceCount, const VkFence* pFences); +typedef VkResult (VKAPI_PTR *PFN_vkGetFenceStatus)(VkDevice device, VkFence fence); +typedef VkResult (VKAPI_PTR *PFN_vkWaitForFences)(VkDevice device, uint32_t fenceCount, const VkFence* pFences, VkBool32 waitAll, uint64_t timeout); +typedef VkResult (VKAPI_PTR *PFN_vkCreateSemaphore)(VkDevice device, const VkSemaphoreCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSemaphore* pSemaphore); +typedef void (VKAPI_PTR *PFN_vkDestroySemaphore)(VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkCreateEvent)(VkDevice device, const VkEventCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkEvent* pEvent); +typedef void (VKAPI_PTR *PFN_vkDestroyEvent)(VkDevice device, VkEvent event, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkGetEventStatus)(VkDevice device, VkEvent event); +typedef VkResult (VKAPI_PTR *PFN_vkSetEvent)(VkDevice device, VkEvent event); +typedef VkResult (VKAPI_PTR *PFN_vkResetEvent)(VkDevice device, VkEvent event); +typedef VkResult (VKAPI_PTR *PFN_vkCreateQueryPool)(VkDevice device, const VkQueryPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkQueryPool* pQueryPool); +typedef void (VKAPI_PTR *PFN_vkDestroyQueryPool)(VkDevice device, VkQueryPool queryPool, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkGetQueryPoolResults)(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, size_t dataSize, void* pData, VkDeviceSize stride, VkQueryResultFlags flags); +typedef VkResult (VKAPI_PTR *PFN_vkCreateBuffer)(VkDevice device, const VkBufferCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBuffer* pBuffer); +typedef void (VKAPI_PTR *PFN_vkDestroyBuffer)(VkDevice device, VkBuffer buffer, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkCreateBufferView)(VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBufferView* pView); +typedef void (VKAPI_PTR *PFN_vkDestroyBufferView)(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkCreateImage)(VkDevice device, const VkImageCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImage* pImage); +typedef void (VKAPI_PTR *PFN_vkDestroyImage)(VkDevice device, VkImage image, const VkAllocationCallbacks* pAllocator); +typedef void (VKAPI_PTR *PFN_vkGetImageSubresourceLayout)(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout); +typedef VkResult (VKAPI_PTR *PFN_vkCreateImageView)(VkDevice device, const VkImageViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImageView* pView); +typedef void (VKAPI_PTR *PFN_vkDestroyImageView)(VkDevice device, VkImageView imageView, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkCreateShaderModule)(VkDevice device, const VkShaderModuleCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkShaderModule* pShaderModule); +typedef void (VKAPI_PTR *PFN_vkDestroyShaderModule)(VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkCreatePipelineCache)(VkDevice device, const VkPipelineCacheCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineCache* pPipelineCache); +typedef void (VKAPI_PTR *PFN_vkDestroyPipelineCache)(VkDevice device, VkPipelineCache pipelineCache, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkGetPipelineCacheData)(VkDevice device, VkPipelineCache pipelineCache, size_t* pDataSize, void* pData); +typedef VkResult (VKAPI_PTR *PFN_vkMergePipelineCaches)(VkDevice device, VkPipelineCache dstCache, uint32_t srcCacheCount, const VkPipelineCache* pSrcCaches); +typedef VkResult (VKAPI_PTR *PFN_vkCreateGraphicsPipelines)(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkGraphicsPipelineCreateInfo* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines); +typedef VkResult (VKAPI_PTR *PFN_vkCreateComputePipelines)(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkComputePipelineCreateInfo* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines); +typedef void (VKAPI_PTR *PFN_vkDestroyPipeline)(VkDevice device, VkPipeline pipeline, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkCreatePipelineLayout)(VkDevice device, const VkPipelineLayoutCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineLayout* pPipelineLayout); +typedef void (VKAPI_PTR *PFN_vkDestroyPipelineLayout)(VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkCreateSampler)(VkDevice device, const VkSamplerCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSampler* pSampler); +typedef void (VKAPI_PTR *PFN_vkDestroySampler)(VkDevice device, VkSampler sampler, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkCreateDescriptorSetLayout)(VkDevice device, const VkDescriptorSetLayoutCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDescriptorSetLayout* pSetLayout); +typedef void (VKAPI_PTR *PFN_vkDestroyDescriptorSetLayout)(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkCreateDescriptorPool)(VkDevice device, const VkDescriptorPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDescriptorPool* pDescriptorPool); +typedef void (VKAPI_PTR *PFN_vkDestroyDescriptorPool)(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkResetDescriptorPool)(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags); +typedef VkResult (VKAPI_PTR *PFN_vkAllocateDescriptorSets)(VkDevice device, const VkDescriptorSetAllocateInfo* pAllocateInfo, VkDescriptorSet* pDescriptorSets); +typedef VkResult (VKAPI_PTR *PFN_vkFreeDescriptorSets)(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, const VkDescriptorSet* pDescriptorSets); +typedef void (VKAPI_PTR *PFN_vkUpdateDescriptorSets)(VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t descriptorCopyCount, const VkCopyDescriptorSet* pDescriptorCopies); +typedef VkResult (VKAPI_PTR *PFN_vkCreateFramebuffer)(VkDevice device, const VkFramebufferCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkFramebuffer* pFramebuffer); +typedef void (VKAPI_PTR *PFN_vkDestroyFramebuffer)(VkDevice device, VkFramebuffer framebuffer, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkCreateRenderPass)(VkDevice device, const VkRenderPassCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkRenderPass* pRenderPass); +typedef void (VKAPI_PTR *PFN_vkDestroyRenderPass)(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks* pAllocator); +typedef void (VKAPI_PTR *PFN_vkGetRenderAreaGranularity)(VkDevice device, VkRenderPass renderPass, VkExtent2D* pGranularity); +typedef VkResult (VKAPI_PTR *PFN_vkCreateCommandPool)(VkDevice device, const VkCommandPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkCommandPool* pCommandPool); +typedef void (VKAPI_PTR *PFN_vkDestroyCommandPool)(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkResetCommandPool)(VkDevice device, VkCommandPool commandPool, VkCommandPoolResetFlags flags); +typedef VkResult (VKAPI_PTR *PFN_vkAllocateCommandBuffers)(VkDevice device, const VkCommandBufferAllocateInfo* pAllocateInfo, VkCommandBuffer* pCommandBuffers); +typedef void (VKAPI_PTR *PFN_vkFreeCommandBuffers)(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, const VkCommandBuffer* pCommandBuffers); +typedef VkResult (VKAPI_PTR *PFN_vkBeginCommandBuffer)(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo* pBeginInfo); +typedef VkResult (VKAPI_PTR *PFN_vkEndCommandBuffer)(VkCommandBuffer commandBuffer); +typedef VkResult (VKAPI_PTR *PFN_vkResetCommandBuffer)(VkCommandBuffer commandBuffer, VkCommandBufferResetFlags flags); +typedef void (VKAPI_PTR *PFN_vkCmdBindPipeline)(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline); +typedef void (VKAPI_PTR *PFN_vkCmdSetViewport)(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewport* pViewports); +typedef void (VKAPI_PTR *PFN_vkCmdSetScissor)(VkCommandBuffer commandBuffer, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D* pScissors); +typedef void (VKAPI_PTR *PFN_vkCmdSetLineWidth)(VkCommandBuffer commandBuffer, float lineWidth); +typedef void (VKAPI_PTR *PFN_vkCmdSetDepthBias)(VkCommandBuffer commandBuffer, float depthBiasConstantFactor, float depthBiasClamp, float depthBiasSlopeFactor); +typedef void (VKAPI_PTR *PFN_vkCmdSetBlendConstants)(VkCommandBuffer commandBuffer, const float blendConstants[4]); +typedef void (VKAPI_PTR *PFN_vkCmdSetDepthBounds)(VkCommandBuffer commandBuffer, float minDepthBounds, float maxDepthBounds); +typedef void (VKAPI_PTR *PFN_vkCmdSetStencilCompareMask)(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t compareMask); +typedef void (VKAPI_PTR *PFN_vkCmdSetStencilWriteMask)(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t writeMask); +typedef void (VKAPI_PTR *PFN_vkCmdSetStencilReference)(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t reference); +typedef void (VKAPI_PTR *PFN_vkCmdBindDescriptorSets)(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t firstSet, uint32_t descriptorSetCount, const VkDescriptorSet* pDescriptorSets, uint32_t dynamicOffsetCount, const uint32_t* pDynamicOffsets); +typedef void (VKAPI_PTR *PFN_vkCmdBindIndexBuffer)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType); +typedef void (VKAPI_PTR *PFN_vkCmdBindVertexBuffers)(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount, const VkBuffer* pBuffers, const VkDeviceSize* pOffsets); +typedef void (VKAPI_PTR *PFN_vkCmdDraw)(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance); +typedef void (VKAPI_PTR *PFN_vkCmdDrawIndexed)(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance); +typedef void (VKAPI_PTR *PFN_vkCmdDrawIndirect)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride); +typedef void (VKAPI_PTR *PFN_vkCmdDrawIndexedIndirect)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride); +typedef void (VKAPI_PTR *PFN_vkCmdDispatch)(VkCommandBuffer commandBuffer, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ); +typedef void (VKAPI_PTR *PFN_vkCmdDispatchIndirect)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset); +typedef void (VKAPI_PTR *PFN_vkCmdCopyBuffer)(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferCopy* pRegions); +typedef void (VKAPI_PTR *PFN_vkCmdCopyImage)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageCopy* pRegions); +typedef void (VKAPI_PTR *PFN_vkCmdBlitImage)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit* pRegions, VkFilter filter); +typedef void (VKAPI_PTR *PFN_vkCmdCopyBufferToImage)(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkBufferImageCopy* pRegions); +typedef void (VKAPI_PTR *PFN_vkCmdCopyImageToBuffer)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy* pRegions); +typedef void (VKAPI_PTR *PFN_vkCmdUpdateBuffer)(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize dataSize, const void* pData); +typedef void (VKAPI_PTR *PFN_vkCmdFillBuffer)(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data); +typedef void (VKAPI_PTR *PFN_vkCmdClearColorImage)(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearColorValue* pColor, uint32_t rangeCount, const VkImageSubresourceRange* pRanges); +typedef void (VKAPI_PTR *PFN_vkCmdClearDepthStencilImage)(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue* pDepthStencil, uint32_t rangeCount, const VkImageSubresourceRange* pRanges); +typedef void (VKAPI_PTR *PFN_vkCmdClearAttachments)(VkCommandBuffer commandBuffer, uint32_t attachmentCount, const VkClearAttachment* pAttachments, uint32_t rectCount, const VkClearRect* pRects); +typedef void (VKAPI_PTR *PFN_vkCmdResolveImage)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageResolve* pRegions); +typedef void (VKAPI_PTR *PFN_vkCmdSetEvent)(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask); +typedef void (VKAPI_PTR *PFN_vkCmdResetEvent)(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask); +typedef void (VKAPI_PTR *PFN_vkCmdWaitEvents)(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent* pEvents, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, uint32_t memoryBarrierCount, const VkMemoryBarrier* pMemoryBarriers, uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier* pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier* pImageMemoryBarriers); +typedef void (VKAPI_PTR *PFN_vkCmdPipelineBarrier)(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, uint32_t memoryBarrierCount, const VkMemoryBarrier* pMemoryBarriers, uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier* pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier* pImageMemoryBarriers); +typedef void (VKAPI_PTR *PFN_vkCmdBeginQuery)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query, VkQueryControlFlags flags); +typedef void (VKAPI_PTR *PFN_vkCmdEndQuery)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query); +typedef void (VKAPI_PTR *PFN_vkCmdResetQueryPool)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount); +typedef void (VKAPI_PTR *PFN_vkCmdWriteTimestamp)(VkCommandBuffer commandBuffer, VkPipelineStageFlagBits pipelineStage, VkQueryPool queryPool, uint32_t query); +typedef void (VKAPI_PTR *PFN_vkCmdCopyQueryPoolResults)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize stride, VkQueryResultFlags flags); +typedef void (VKAPI_PTR *PFN_vkCmdPushConstants)(VkCommandBuffer commandBuffer, VkPipelineLayout layout, VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size, const void* pValues); +typedef void (VKAPI_PTR *PFN_vkCmdBeginRenderPass)(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, VkSubpassContents contents); +typedef void (VKAPI_PTR *PFN_vkCmdNextSubpass)(VkCommandBuffer commandBuffer, VkSubpassContents contents); +typedef void (VKAPI_PTR *PFN_vkCmdEndRenderPass)(VkCommandBuffer commandBuffer); +typedef void (VKAPI_PTR *PFN_vkCmdExecuteCommands)(VkCommandBuffer commandBuffer, uint32_t commandBufferCount, const VkCommandBuffer* pCommandBuffers); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance( + const VkInstanceCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkInstance* pInstance); + +VKAPI_ATTR void VKAPI_CALL vkDestroyInstance( + VkInstance instance, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDevices( + VkInstance instance, + uint32_t* pPhysicalDeviceCount, + VkPhysicalDevice* pPhysicalDevices); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures( + VkPhysicalDevice physicalDevice, + VkPhysicalDeviceFeatures* pFeatures); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties( + VkPhysicalDevice physicalDevice, + VkFormat format, + VkFormatProperties* pFormatProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties( + VkPhysicalDevice physicalDevice, + VkFormat format, + VkImageType type, + VkImageTiling tiling, + VkImageUsageFlags usage, + VkImageCreateFlags flags, + VkImageFormatProperties* pImageFormatProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties( + VkPhysicalDevice physicalDevice, + VkPhysicalDeviceProperties* pProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties( + VkPhysicalDevice physicalDevice, + uint32_t* pQueueFamilyPropertyCount, + VkQueueFamilyProperties* pQueueFamilyProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties( + VkPhysicalDevice physicalDevice, + VkPhysicalDeviceMemoryProperties* pMemoryProperties); + +VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr( + VkInstance instance, + const char* pName); + +VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr( + VkDevice device, + const char* pName); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice( + VkPhysicalDevice physicalDevice, + const VkDeviceCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkDevice* pDevice); + +VKAPI_ATTR void VKAPI_CALL vkDestroyDevice( + VkDevice device, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties( + const char* pLayerName, + uint32_t* pPropertyCount, + VkExtensionProperties* pProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties( + VkPhysicalDevice physicalDevice, + const char* pLayerName, + uint32_t* pPropertyCount, + VkExtensionProperties* pProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties( + uint32_t* pPropertyCount, + VkLayerProperties* pProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties( + VkPhysicalDevice physicalDevice, + uint32_t* pPropertyCount, + VkLayerProperties* pProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue( + VkDevice device, + uint32_t queueFamilyIndex, + uint32_t queueIndex, + VkQueue* pQueue); + +VKAPI_ATTR VkResult VKAPI_CALL vkQueueSubmit( + VkQueue queue, + uint32_t submitCount, + const VkSubmitInfo* pSubmits, + VkFence fence); + +VKAPI_ATTR VkResult VKAPI_CALL vkQueueWaitIdle( + VkQueue queue); + +VKAPI_ATTR VkResult VKAPI_CALL vkDeviceWaitIdle( + VkDevice device); + +VKAPI_ATTR VkResult VKAPI_CALL vkAllocateMemory( + VkDevice device, + const VkMemoryAllocateInfo* pAllocateInfo, + const VkAllocationCallbacks* pAllocator, + VkDeviceMemory* pMemory); + +VKAPI_ATTR void VKAPI_CALL vkFreeMemory( + VkDevice device, + VkDeviceMemory memory, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkMapMemory( + VkDevice device, + VkDeviceMemory memory, + VkDeviceSize offset, + VkDeviceSize size, + VkMemoryMapFlags flags, + void** ppData); + +VKAPI_ATTR void VKAPI_CALL vkUnmapMemory( + VkDevice device, + VkDeviceMemory memory); + +VKAPI_ATTR VkResult VKAPI_CALL vkFlushMappedMemoryRanges( + VkDevice device, + uint32_t memoryRangeCount, + const VkMappedMemoryRange* pMemoryRanges); + +VKAPI_ATTR VkResult VKAPI_CALL vkInvalidateMappedMemoryRanges( + VkDevice device, + uint32_t memoryRangeCount, + const VkMappedMemoryRange* pMemoryRanges); + +VKAPI_ATTR void VKAPI_CALL vkGetDeviceMemoryCommitment( + VkDevice device, + VkDeviceMemory memory, + VkDeviceSize* pCommittedMemoryInBytes); + +VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory( + VkDevice device, + VkBuffer buffer, + VkDeviceMemory memory, + VkDeviceSize memoryOffset); + +VKAPI_ATTR VkResult VKAPI_CALL vkBindImageMemory( + VkDevice device, + VkImage image, + VkDeviceMemory memory, + VkDeviceSize memoryOffset); + +VKAPI_ATTR void VKAPI_CALL vkGetBufferMemoryRequirements( + VkDevice device, + VkBuffer buffer, + VkMemoryRequirements* pMemoryRequirements); + +VKAPI_ATTR void VKAPI_CALL vkGetImageMemoryRequirements( + VkDevice device, + VkImage image, + VkMemoryRequirements* pMemoryRequirements); + +VKAPI_ATTR void VKAPI_CALL vkGetImageSparseMemoryRequirements( + VkDevice device, + VkImage image, + uint32_t* pSparseMemoryRequirementCount, + VkSparseImageMemoryRequirements* pSparseMemoryRequirements); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceSparseImageFormatProperties( + VkPhysicalDevice physicalDevice, + VkFormat format, + VkImageType type, + VkSampleCountFlagBits samples, + VkImageUsageFlags usage, + VkImageTiling tiling, + uint32_t* pPropertyCount, + VkSparseImageFormatProperties* pProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkQueueBindSparse( + VkQueue queue, + uint32_t bindInfoCount, + const VkBindSparseInfo* pBindInfo, + VkFence fence); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateFence( + VkDevice device, + const VkFenceCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkFence* pFence); + +VKAPI_ATTR void VKAPI_CALL vkDestroyFence( + VkDevice device, + VkFence fence, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkResetFences( + VkDevice device, + uint32_t fenceCount, + const VkFence* pFences); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetFenceStatus( + VkDevice device, + VkFence fence); + +VKAPI_ATTR VkResult VKAPI_CALL vkWaitForFences( + VkDevice device, + uint32_t fenceCount, + const VkFence* pFences, + VkBool32 waitAll, + uint64_t timeout); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateSemaphore( + VkDevice device, + const VkSemaphoreCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSemaphore* pSemaphore); + +VKAPI_ATTR void VKAPI_CALL vkDestroySemaphore( + VkDevice device, + VkSemaphore semaphore, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateEvent( + VkDevice device, + const VkEventCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkEvent* pEvent); + +VKAPI_ATTR void VKAPI_CALL vkDestroyEvent( + VkDevice device, + VkEvent event, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetEventStatus( + VkDevice device, + VkEvent event); + +VKAPI_ATTR VkResult VKAPI_CALL vkSetEvent( + VkDevice device, + VkEvent event); + +VKAPI_ATTR VkResult VKAPI_CALL vkResetEvent( + VkDevice device, + VkEvent event); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateQueryPool( + VkDevice device, + const VkQueryPoolCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkQueryPool* pQueryPool); + +VKAPI_ATTR void VKAPI_CALL vkDestroyQueryPool( + VkDevice device, + VkQueryPool queryPool, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetQueryPoolResults( + VkDevice device, + VkQueryPool queryPool, + uint32_t firstQuery, + uint32_t queryCount, + size_t dataSize, + void* pData, + VkDeviceSize stride, + VkQueryResultFlags flags); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateBuffer( + VkDevice device, + const VkBufferCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkBuffer* pBuffer); + +VKAPI_ATTR void VKAPI_CALL vkDestroyBuffer( + VkDevice device, + VkBuffer buffer, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateBufferView( + VkDevice device, + const VkBufferViewCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkBufferView* pView); + +VKAPI_ATTR void VKAPI_CALL vkDestroyBufferView( + VkDevice device, + VkBufferView bufferView, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateImage( + VkDevice device, + const VkImageCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkImage* pImage); + +VKAPI_ATTR void VKAPI_CALL vkDestroyImage( + VkDevice device, + VkImage image, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR void VKAPI_CALL vkGetImageSubresourceLayout( + VkDevice device, + VkImage image, + const VkImageSubresource* pSubresource, + VkSubresourceLayout* pLayout); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateImageView( + VkDevice device, + const VkImageViewCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkImageView* pView); + +VKAPI_ATTR void VKAPI_CALL vkDestroyImageView( + VkDevice device, + VkImageView imageView, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateShaderModule( + VkDevice device, + const VkShaderModuleCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkShaderModule* pShaderModule); + +VKAPI_ATTR void VKAPI_CALL vkDestroyShaderModule( + VkDevice device, + VkShaderModule shaderModule, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineCache( + VkDevice device, + const VkPipelineCacheCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkPipelineCache* pPipelineCache); + +VKAPI_ATTR void VKAPI_CALL vkDestroyPipelineCache( + VkDevice device, + VkPipelineCache pipelineCache, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPipelineCacheData( + VkDevice device, + VkPipelineCache pipelineCache, + size_t* pDataSize, + void* pData); + +VKAPI_ATTR VkResult VKAPI_CALL vkMergePipelineCaches( + VkDevice device, + VkPipelineCache dstCache, + uint32_t srcCacheCount, + const VkPipelineCache* pSrcCaches); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateGraphicsPipelines( + VkDevice device, + VkPipelineCache pipelineCache, + uint32_t createInfoCount, + const VkGraphicsPipelineCreateInfo* pCreateInfos, + const VkAllocationCallbacks* pAllocator, + VkPipeline* pPipelines); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateComputePipelines( + VkDevice device, + VkPipelineCache pipelineCache, + uint32_t createInfoCount, + const VkComputePipelineCreateInfo* pCreateInfos, + const VkAllocationCallbacks* pAllocator, + VkPipeline* pPipelines); + +VKAPI_ATTR void VKAPI_CALL vkDestroyPipeline( + VkDevice device, + VkPipeline pipeline, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineLayout( + VkDevice device, + const VkPipelineLayoutCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkPipelineLayout* pPipelineLayout); + +VKAPI_ATTR void VKAPI_CALL vkDestroyPipelineLayout( + VkDevice device, + VkPipelineLayout pipelineLayout, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateSampler( + VkDevice device, + const VkSamplerCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSampler* pSampler); + +VKAPI_ATTR void VKAPI_CALL vkDestroySampler( + VkDevice device, + VkSampler sampler, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorSetLayout( + VkDevice device, + const VkDescriptorSetLayoutCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkDescriptorSetLayout* pSetLayout); + +VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorSetLayout( + VkDevice device, + VkDescriptorSetLayout descriptorSetLayout, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorPool( + VkDevice device, + const VkDescriptorPoolCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkDescriptorPool* pDescriptorPool); + +VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorPool( + VkDevice device, + VkDescriptorPool descriptorPool, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkResetDescriptorPool( + VkDevice device, + VkDescriptorPool descriptorPool, + VkDescriptorPoolResetFlags flags); + +VKAPI_ATTR VkResult VKAPI_CALL vkAllocateDescriptorSets( + VkDevice device, + const VkDescriptorSetAllocateInfo* pAllocateInfo, + VkDescriptorSet* pDescriptorSets); + +VKAPI_ATTR VkResult VKAPI_CALL vkFreeDescriptorSets( + VkDevice device, + VkDescriptorPool descriptorPool, + uint32_t descriptorSetCount, + const VkDescriptorSet* pDescriptorSets); + +VKAPI_ATTR void VKAPI_CALL vkUpdateDescriptorSets( + VkDevice device, + uint32_t descriptorWriteCount, + const VkWriteDescriptorSet* pDescriptorWrites, + uint32_t descriptorCopyCount, + const VkCopyDescriptorSet* pDescriptorCopies); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateFramebuffer( + VkDevice device, + const VkFramebufferCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkFramebuffer* pFramebuffer); + +VKAPI_ATTR void VKAPI_CALL vkDestroyFramebuffer( + VkDevice device, + VkFramebuffer framebuffer, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateRenderPass( + VkDevice device, + const VkRenderPassCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkRenderPass* pRenderPass); + +VKAPI_ATTR void VKAPI_CALL vkDestroyRenderPass( + VkDevice device, + VkRenderPass renderPass, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR void VKAPI_CALL vkGetRenderAreaGranularity( + VkDevice device, + VkRenderPass renderPass, + VkExtent2D* pGranularity); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateCommandPool( + VkDevice device, + const VkCommandPoolCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkCommandPool* pCommandPool); + +VKAPI_ATTR void VKAPI_CALL vkDestroyCommandPool( + VkDevice device, + VkCommandPool commandPool, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandPool( + VkDevice device, + VkCommandPool commandPool, + VkCommandPoolResetFlags flags); + +VKAPI_ATTR VkResult VKAPI_CALL vkAllocateCommandBuffers( + VkDevice device, + const VkCommandBufferAllocateInfo* pAllocateInfo, + VkCommandBuffer* pCommandBuffers); + +VKAPI_ATTR void VKAPI_CALL vkFreeCommandBuffers( + VkDevice device, + VkCommandPool commandPool, + uint32_t commandBufferCount, + const VkCommandBuffer* pCommandBuffers); + +VKAPI_ATTR VkResult VKAPI_CALL vkBeginCommandBuffer( + VkCommandBuffer commandBuffer, + const VkCommandBufferBeginInfo* pBeginInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkEndCommandBuffer( + VkCommandBuffer commandBuffer); + +VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandBuffer( + VkCommandBuffer commandBuffer, + VkCommandBufferResetFlags flags); + +VKAPI_ATTR void VKAPI_CALL vkCmdBindPipeline( + VkCommandBuffer commandBuffer, + VkPipelineBindPoint pipelineBindPoint, + VkPipeline pipeline); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetViewport( + VkCommandBuffer commandBuffer, + uint32_t firstViewport, + uint32_t viewportCount, + const VkViewport* pViewports); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetScissor( + VkCommandBuffer commandBuffer, + uint32_t firstScissor, + uint32_t scissorCount, + const VkRect2D* pScissors); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetLineWidth( + VkCommandBuffer commandBuffer, + float lineWidth); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBias( + VkCommandBuffer commandBuffer, + float depthBiasConstantFactor, + float depthBiasClamp, + float depthBiasSlopeFactor); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetBlendConstants( + VkCommandBuffer commandBuffer, + const float blendConstants[4]); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBounds( + VkCommandBuffer commandBuffer, + float minDepthBounds, + float maxDepthBounds); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilCompareMask( + VkCommandBuffer commandBuffer, + VkStencilFaceFlags faceMask, + uint32_t compareMask); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilWriteMask( + VkCommandBuffer commandBuffer, + VkStencilFaceFlags faceMask, + uint32_t writeMask); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilReference( + VkCommandBuffer commandBuffer, + VkStencilFaceFlags faceMask, + uint32_t reference); + +VKAPI_ATTR void VKAPI_CALL vkCmdBindDescriptorSets( + VkCommandBuffer commandBuffer, + VkPipelineBindPoint pipelineBindPoint, + VkPipelineLayout layout, + uint32_t firstSet, + uint32_t descriptorSetCount, + const VkDescriptorSet* pDescriptorSets, + uint32_t dynamicOffsetCount, + const uint32_t* pDynamicOffsets); + +VKAPI_ATTR void VKAPI_CALL vkCmdBindIndexBuffer( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset, + VkIndexType indexType); + +VKAPI_ATTR void VKAPI_CALL vkCmdBindVertexBuffers( + VkCommandBuffer commandBuffer, + uint32_t firstBinding, + uint32_t bindingCount, + const VkBuffer* pBuffers, + const VkDeviceSize* pOffsets); + +VKAPI_ATTR void VKAPI_CALL vkCmdDraw( + VkCommandBuffer commandBuffer, + uint32_t vertexCount, + uint32_t instanceCount, + uint32_t firstVertex, + uint32_t firstInstance); + +VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexed( + VkCommandBuffer commandBuffer, + uint32_t indexCount, + uint32_t instanceCount, + uint32_t firstIndex, + int32_t vertexOffset, + uint32_t firstInstance); + +VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirect( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset, + uint32_t drawCount, + uint32_t stride); + +VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexedIndirect( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset, + uint32_t drawCount, + uint32_t stride); + +VKAPI_ATTR void VKAPI_CALL vkCmdDispatch( + VkCommandBuffer commandBuffer, + uint32_t groupCountX, + uint32_t groupCountY, + uint32_t groupCountZ); + +VKAPI_ATTR void VKAPI_CALL vkCmdDispatchIndirect( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyBuffer( + VkCommandBuffer commandBuffer, + VkBuffer srcBuffer, + VkBuffer dstBuffer, + uint32_t regionCount, + const VkBufferCopy* pRegions); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyImage( + VkCommandBuffer commandBuffer, + VkImage srcImage, + VkImageLayout srcImageLayout, + VkImage dstImage, + VkImageLayout dstImageLayout, + uint32_t regionCount, + const VkImageCopy* pRegions); + +VKAPI_ATTR void VKAPI_CALL vkCmdBlitImage( + VkCommandBuffer commandBuffer, + VkImage srcImage, + VkImageLayout srcImageLayout, + VkImage dstImage, + VkImageLayout dstImageLayout, + uint32_t regionCount, + const VkImageBlit* pRegions, + VkFilter filter); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyBufferToImage( + VkCommandBuffer commandBuffer, + VkBuffer srcBuffer, + VkImage dstImage, + VkImageLayout dstImageLayout, + uint32_t regionCount, + const VkBufferImageCopy* pRegions); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyImageToBuffer( + VkCommandBuffer commandBuffer, + VkImage srcImage, + VkImageLayout srcImageLayout, + VkBuffer dstBuffer, + uint32_t regionCount, + const VkBufferImageCopy* pRegions); + +VKAPI_ATTR void VKAPI_CALL vkCmdUpdateBuffer( + VkCommandBuffer commandBuffer, + VkBuffer dstBuffer, + VkDeviceSize dstOffset, + VkDeviceSize dataSize, + const void* pData); + +VKAPI_ATTR void VKAPI_CALL vkCmdFillBuffer( + VkCommandBuffer commandBuffer, + VkBuffer dstBuffer, + VkDeviceSize dstOffset, + VkDeviceSize size, + uint32_t data); + +VKAPI_ATTR void VKAPI_CALL vkCmdClearColorImage( + VkCommandBuffer commandBuffer, + VkImage image, + VkImageLayout imageLayout, + const VkClearColorValue* pColor, + uint32_t rangeCount, + const VkImageSubresourceRange* pRanges); + +VKAPI_ATTR void VKAPI_CALL vkCmdClearDepthStencilImage( + VkCommandBuffer commandBuffer, + VkImage image, + VkImageLayout imageLayout, + const VkClearDepthStencilValue* pDepthStencil, + uint32_t rangeCount, + const VkImageSubresourceRange* pRanges); + +VKAPI_ATTR void VKAPI_CALL vkCmdClearAttachments( + VkCommandBuffer commandBuffer, + uint32_t attachmentCount, + const VkClearAttachment* pAttachments, + uint32_t rectCount, + const VkClearRect* pRects); + +VKAPI_ATTR void VKAPI_CALL vkCmdResolveImage( + VkCommandBuffer commandBuffer, + VkImage srcImage, + VkImageLayout srcImageLayout, + VkImage dstImage, + VkImageLayout dstImageLayout, + uint32_t regionCount, + const VkImageResolve* pRegions); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetEvent( + VkCommandBuffer commandBuffer, + VkEvent event, + VkPipelineStageFlags stageMask); + +VKAPI_ATTR void VKAPI_CALL vkCmdResetEvent( + VkCommandBuffer commandBuffer, + VkEvent event, + VkPipelineStageFlags stageMask); + +VKAPI_ATTR void VKAPI_CALL vkCmdWaitEvents( + VkCommandBuffer commandBuffer, + uint32_t eventCount, + const VkEvent* pEvents, + VkPipelineStageFlags srcStageMask, + VkPipelineStageFlags dstStageMask, + uint32_t memoryBarrierCount, + const VkMemoryBarrier* pMemoryBarriers, + uint32_t bufferMemoryBarrierCount, + const VkBufferMemoryBarrier* pBufferMemoryBarriers, + uint32_t imageMemoryBarrierCount, + const VkImageMemoryBarrier* pImageMemoryBarriers); + +VKAPI_ATTR void VKAPI_CALL vkCmdPipelineBarrier( + VkCommandBuffer commandBuffer, + VkPipelineStageFlags srcStageMask, + VkPipelineStageFlags dstStageMask, + VkDependencyFlags dependencyFlags, + uint32_t memoryBarrierCount, + const VkMemoryBarrier* pMemoryBarriers, + uint32_t bufferMemoryBarrierCount, + const VkBufferMemoryBarrier* pBufferMemoryBarriers, + uint32_t imageMemoryBarrierCount, + const VkImageMemoryBarrier* pImageMemoryBarriers); + +VKAPI_ATTR void VKAPI_CALL vkCmdBeginQuery( + VkCommandBuffer commandBuffer, + VkQueryPool queryPool, + uint32_t query, + VkQueryControlFlags flags); + +VKAPI_ATTR void VKAPI_CALL vkCmdEndQuery( + VkCommandBuffer commandBuffer, + VkQueryPool queryPool, + uint32_t query); + +VKAPI_ATTR void VKAPI_CALL vkCmdResetQueryPool( + VkCommandBuffer commandBuffer, + VkQueryPool queryPool, + uint32_t firstQuery, + uint32_t queryCount); + +VKAPI_ATTR void VKAPI_CALL vkCmdWriteTimestamp( + VkCommandBuffer commandBuffer, + VkPipelineStageFlagBits pipelineStage, + VkQueryPool queryPool, + uint32_t query); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyQueryPoolResults( + VkCommandBuffer commandBuffer, + VkQueryPool queryPool, + uint32_t firstQuery, + uint32_t queryCount, + VkBuffer dstBuffer, + VkDeviceSize dstOffset, + VkDeviceSize stride, + VkQueryResultFlags flags); + +VKAPI_ATTR void VKAPI_CALL vkCmdPushConstants( + VkCommandBuffer commandBuffer, + VkPipelineLayout layout, + VkShaderStageFlags stageFlags, + uint32_t offset, + uint32_t size, + const void* pValues); + +VKAPI_ATTR void VKAPI_CALL vkCmdBeginRenderPass( + VkCommandBuffer commandBuffer, + const VkRenderPassBeginInfo* pRenderPassBegin, + VkSubpassContents contents); + +VKAPI_ATTR void VKAPI_CALL vkCmdNextSubpass( + VkCommandBuffer commandBuffer, + VkSubpassContents contents); + +VKAPI_ATTR void VKAPI_CALL vkCmdEndRenderPass( + VkCommandBuffer commandBuffer); + +VKAPI_ATTR void VKAPI_CALL vkCmdExecuteCommands( + VkCommandBuffer commandBuffer, + uint32_t commandBufferCount, + const VkCommandBuffer* pCommandBuffers); +#endif + + +#define VK_VERSION_1_1 1 +// Vulkan 1.1 version number +#define VK_API_VERSION_1_1 VK_MAKE_VERSION(1, 1, 0)// Patch version should always be set to 0 + +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSamplerYcbcrConversion) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorUpdateTemplate) +#define VK_MAX_DEVICE_GROUP_SIZE 32 +#define VK_LUID_SIZE 8 +#define VK_QUEUE_FAMILY_EXTERNAL (~0U-1) + +typedef enum VkPointClippingBehavior { + VK_POINT_CLIPPING_BEHAVIOR_ALL_CLIP_PLANES = 0, + VK_POINT_CLIPPING_BEHAVIOR_USER_CLIP_PLANES_ONLY = 1, + VK_POINT_CLIPPING_BEHAVIOR_ALL_CLIP_PLANES_KHR = VK_POINT_CLIPPING_BEHAVIOR_ALL_CLIP_PLANES, + VK_POINT_CLIPPING_BEHAVIOR_USER_CLIP_PLANES_ONLY_KHR = VK_POINT_CLIPPING_BEHAVIOR_USER_CLIP_PLANES_ONLY, + VK_POINT_CLIPPING_BEHAVIOR_BEGIN_RANGE = VK_POINT_CLIPPING_BEHAVIOR_ALL_CLIP_PLANES, + VK_POINT_CLIPPING_BEHAVIOR_END_RANGE = VK_POINT_CLIPPING_BEHAVIOR_USER_CLIP_PLANES_ONLY, + VK_POINT_CLIPPING_BEHAVIOR_RANGE_SIZE = (VK_POINT_CLIPPING_BEHAVIOR_USER_CLIP_PLANES_ONLY - VK_POINT_CLIPPING_BEHAVIOR_ALL_CLIP_PLANES + 1), + VK_POINT_CLIPPING_BEHAVIOR_MAX_ENUM = 0x7FFFFFFF +} VkPointClippingBehavior; + +typedef enum VkTessellationDomainOrigin { + VK_TESSELLATION_DOMAIN_ORIGIN_UPPER_LEFT = 0, + VK_TESSELLATION_DOMAIN_ORIGIN_LOWER_LEFT = 1, + VK_TESSELLATION_DOMAIN_ORIGIN_UPPER_LEFT_KHR = VK_TESSELLATION_DOMAIN_ORIGIN_UPPER_LEFT, + VK_TESSELLATION_DOMAIN_ORIGIN_LOWER_LEFT_KHR = VK_TESSELLATION_DOMAIN_ORIGIN_LOWER_LEFT, + VK_TESSELLATION_DOMAIN_ORIGIN_BEGIN_RANGE = VK_TESSELLATION_DOMAIN_ORIGIN_UPPER_LEFT, + VK_TESSELLATION_DOMAIN_ORIGIN_END_RANGE = VK_TESSELLATION_DOMAIN_ORIGIN_LOWER_LEFT, + VK_TESSELLATION_DOMAIN_ORIGIN_RANGE_SIZE = (VK_TESSELLATION_DOMAIN_ORIGIN_LOWER_LEFT - VK_TESSELLATION_DOMAIN_ORIGIN_UPPER_LEFT + 1), + VK_TESSELLATION_DOMAIN_ORIGIN_MAX_ENUM = 0x7FFFFFFF +} VkTessellationDomainOrigin; + +typedef enum VkSamplerYcbcrModelConversion { + VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY = 0, + VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_IDENTITY = 1, + VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_709 = 2, + VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_601 = 3, + VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_2020 = 4, + VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY_KHR = VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY, + VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_IDENTITY_KHR = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_IDENTITY, + VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_709_KHR = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_709, + VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_601_KHR = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_601, + VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_2020_KHR = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_2020, + VK_SAMPLER_YCBCR_MODEL_CONVERSION_BEGIN_RANGE = VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY, + VK_SAMPLER_YCBCR_MODEL_CONVERSION_END_RANGE = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_2020, + VK_SAMPLER_YCBCR_MODEL_CONVERSION_RANGE_SIZE = (VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_2020 - VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY + 1), + VK_SAMPLER_YCBCR_MODEL_CONVERSION_MAX_ENUM = 0x7FFFFFFF +} VkSamplerYcbcrModelConversion; + +typedef enum VkSamplerYcbcrRange { + VK_SAMPLER_YCBCR_RANGE_ITU_FULL = 0, + VK_SAMPLER_YCBCR_RANGE_ITU_NARROW = 1, + VK_SAMPLER_YCBCR_RANGE_ITU_FULL_KHR = VK_SAMPLER_YCBCR_RANGE_ITU_FULL, + VK_SAMPLER_YCBCR_RANGE_ITU_NARROW_KHR = VK_SAMPLER_YCBCR_RANGE_ITU_NARROW, + VK_SAMPLER_YCBCR_RANGE_BEGIN_RANGE = VK_SAMPLER_YCBCR_RANGE_ITU_FULL, + VK_SAMPLER_YCBCR_RANGE_END_RANGE = VK_SAMPLER_YCBCR_RANGE_ITU_NARROW, + VK_SAMPLER_YCBCR_RANGE_RANGE_SIZE = (VK_SAMPLER_YCBCR_RANGE_ITU_NARROW - VK_SAMPLER_YCBCR_RANGE_ITU_FULL + 1), + VK_SAMPLER_YCBCR_RANGE_MAX_ENUM = 0x7FFFFFFF +} VkSamplerYcbcrRange; + +typedef enum VkChromaLocation { + VK_CHROMA_LOCATION_COSITED_EVEN = 0, + VK_CHROMA_LOCATION_MIDPOINT = 1, + VK_CHROMA_LOCATION_COSITED_EVEN_KHR = VK_CHROMA_LOCATION_COSITED_EVEN, + VK_CHROMA_LOCATION_MIDPOINT_KHR = VK_CHROMA_LOCATION_MIDPOINT, + VK_CHROMA_LOCATION_BEGIN_RANGE = VK_CHROMA_LOCATION_COSITED_EVEN, + VK_CHROMA_LOCATION_END_RANGE = VK_CHROMA_LOCATION_MIDPOINT, + VK_CHROMA_LOCATION_RANGE_SIZE = (VK_CHROMA_LOCATION_MIDPOINT - VK_CHROMA_LOCATION_COSITED_EVEN + 1), + VK_CHROMA_LOCATION_MAX_ENUM = 0x7FFFFFFF +} VkChromaLocation; + +typedef enum VkDescriptorUpdateTemplateType { + VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET = 0, + VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR = 1, + VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET_KHR = VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET, + VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_BEGIN_RANGE = VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET, + VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_END_RANGE = VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET, + VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_RANGE_SIZE = (VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET - VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET + 1), + VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_MAX_ENUM = 0x7FFFFFFF +} VkDescriptorUpdateTemplateType; + +typedef enum VkSubgroupFeatureFlagBits { + VK_SUBGROUP_FEATURE_BASIC_BIT = 0x00000001, + VK_SUBGROUP_FEATURE_VOTE_BIT = 0x00000002, + VK_SUBGROUP_FEATURE_ARITHMETIC_BIT = 0x00000004, + VK_SUBGROUP_FEATURE_BALLOT_BIT = 0x00000008, + VK_SUBGROUP_FEATURE_SHUFFLE_BIT = 0x00000010, + VK_SUBGROUP_FEATURE_SHUFFLE_RELATIVE_BIT = 0x00000020, + VK_SUBGROUP_FEATURE_CLUSTERED_BIT = 0x00000040, + VK_SUBGROUP_FEATURE_QUAD_BIT = 0x00000080, + VK_SUBGROUP_FEATURE_PARTITIONED_BIT_NV = 0x00000100, + VK_SUBGROUP_FEATURE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkSubgroupFeatureFlagBits; +typedef VkFlags VkSubgroupFeatureFlags; + +typedef enum VkPeerMemoryFeatureFlagBits { + VK_PEER_MEMORY_FEATURE_COPY_SRC_BIT = 0x00000001, + VK_PEER_MEMORY_FEATURE_COPY_DST_BIT = 0x00000002, + VK_PEER_MEMORY_FEATURE_GENERIC_SRC_BIT = 0x00000004, + VK_PEER_MEMORY_FEATURE_GENERIC_DST_BIT = 0x00000008, + VK_PEER_MEMORY_FEATURE_COPY_SRC_BIT_KHR = VK_PEER_MEMORY_FEATURE_COPY_SRC_BIT, + VK_PEER_MEMORY_FEATURE_COPY_DST_BIT_KHR = VK_PEER_MEMORY_FEATURE_COPY_DST_BIT, + VK_PEER_MEMORY_FEATURE_GENERIC_SRC_BIT_KHR = VK_PEER_MEMORY_FEATURE_GENERIC_SRC_BIT, + VK_PEER_MEMORY_FEATURE_GENERIC_DST_BIT_KHR = VK_PEER_MEMORY_FEATURE_GENERIC_DST_BIT, + VK_PEER_MEMORY_FEATURE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkPeerMemoryFeatureFlagBits; +typedef VkFlags VkPeerMemoryFeatureFlags; + +typedef enum VkMemoryAllocateFlagBits { + VK_MEMORY_ALLOCATE_DEVICE_MASK_BIT = 0x00000001, + VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT = 0x00000002, + VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT = 0x00000004, + VK_MEMORY_ALLOCATE_DEVICE_MASK_BIT_KHR = VK_MEMORY_ALLOCATE_DEVICE_MASK_BIT, + VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR = VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT, + VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR = VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT, + VK_MEMORY_ALLOCATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkMemoryAllocateFlagBits; +typedef VkFlags VkMemoryAllocateFlags; +typedef VkFlags VkCommandPoolTrimFlags; +typedef VkFlags VkDescriptorUpdateTemplateCreateFlags; + +typedef enum VkExternalMemoryHandleTypeFlagBits { + VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT = 0x00000001, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT = 0x00000002, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT = 0x00000004, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_BIT = 0x00000008, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_KMT_BIT = 0x00000010, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP_BIT = 0x00000020, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE_BIT = 0x00000040, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT = 0x00000200, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID = 0x00000400, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT = 0x00000080, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_MAPPED_FOREIGN_MEMORY_BIT_EXT = 0x00000100, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT_KHR = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT_KHR = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_BIT_KHR = VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_BIT, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_KMT_BIT_KHR = VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_KMT_BIT, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP_BIT_KHR = VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP_BIT, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE_BIT_KHR = VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE_BIT, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkExternalMemoryHandleTypeFlagBits; +typedef VkFlags VkExternalMemoryHandleTypeFlags; + +typedef enum VkExternalMemoryFeatureFlagBits { + VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT = 0x00000001, + VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT = 0x00000002, + VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT = 0x00000004, + VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT_KHR = VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT, + VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT_KHR = VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT, + VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT_KHR = VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT, + VK_EXTERNAL_MEMORY_FEATURE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkExternalMemoryFeatureFlagBits; +typedef VkFlags VkExternalMemoryFeatureFlags; + +typedef enum VkExternalFenceHandleTypeFlagBits { + VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_FD_BIT = 0x00000001, + VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_BIT = 0x00000002, + VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT = 0x00000004, + VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT = 0x00000008, + VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_FD_BIT_KHR = VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_FD_BIT, + VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_BIT_KHR = VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_BIT, + VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT_KHR = VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT, + VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT_KHR = VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT, + VK_EXTERNAL_FENCE_HANDLE_TYPE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkExternalFenceHandleTypeFlagBits; +typedef VkFlags VkExternalFenceHandleTypeFlags; + +typedef enum VkExternalFenceFeatureFlagBits { + VK_EXTERNAL_FENCE_FEATURE_EXPORTABLE_BIT = 0x00000001, + VK_EXTERNAL_FENCE_FEATURE_IMPORTABLE_BIT = 0x00000002, + VK_EXTERNAL_FENCE_FEATURE_EXPORTABLE_BIT_KHR = VK_EXTERNAL_FENCE_FEATURE_EXPORTABLE_BIT, + VK_EXTERNAL_FENCE_FEATURE_IMPORTABLE_BIT_KHR = VK_EXTERNAL_FENCE_FEATURE_IMPORTABLE_BIT, + VK_EXTERNAL_FENCE_FEATURE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkExternalFenceFeatureFlagBits; +typedef VkFlags VkExternalFenceFeatureFlags; + +typedef enum VkFenceImportFlagBits { + VK_FENCE_IMPORT_TEMPORARY_BIT = 0x00000001, + VK_FENCE_IMPORT_TEMPORARY_BIT_KHR = VK_FENCE_IMPORT_TEMPORARY_BIT, + VK_FENCE_IMPORT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkFenceImportFlagBits; +typedef VkFlags VkFenceImportFlags; + +typedef enum VkSemaphoreImportFlagBits { + VK_SEMAPHORE_IMPORT_TEMPORARY_BIT = 0x00000001, + VK_SEMAPHORE_IMPORT_TEMPORARY_BIT_KHR = VK_SEMAPHORE_IMPORT_TEMPORARY_BIT, + VK_SEMAPHORE_IMPORT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkSemaphoreImportFlagBits; +typedef VkFlags VkSemaphoreImportFlags; + +typedef enum VkExternalSemaphoreHandleTypeFlagBits { + VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT = 0x00000001, + VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT = 0x00000002, + VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT = 0x00000004, + VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT = 0x00000008, + VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT = 0x00000010, + VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT_KHR = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT, + VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT_KHR = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT, + VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT_KHR = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT, + VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT_KHR = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT, + VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT_KHR = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT, + VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkExternalSemaphoreHandleTypeFlagBits; +typedef VkFlags VkExternalSemaphoreHandleTypeFlags; + +typedef enum VkExternalSemaphoreFeatureFlagBits { + VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT = 0x00000001, + VK_EXTERNAL_SEMAPHORE_FEATURE_IMPORTABLE_BIT = 0x00000002, + VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT_KHR = VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT, + VK_EXTERNAL_SEMAPHORE_FEATURE_IMPORTABLE_BIT_KHR = VK_EXTERNAL_SEMAPHORE_FEATURE_IMPORTABLE_BIT, + VK_EXTERNAL_SEMAPHORE_FEATURE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkExternalSemaphoreFeatureFlagBits; +typedef VkFlags VkExternalSemaphoreFeatureFlags; +typedef struct VkPhysicalDeviceSubgroupProperties { + VkStructureType sType; + void* pNext; + uint32_t subgroupSize; + VkShaderStageFlags supportedStages; + VkSubgroupFeatureFlags supportedOperations; + VkBool32 quadOperationsInAllStages; +} VkPhysicalDeviceSubgroupProperties; + +typedef struct VkBindBufferMemoryInfo { + VkStructureType sType; + const void* pNext; + VkBuffer buffer; + VkDeviceMemory memory; + VkDeviceSize memoryOffset; +} VkBindBufferMemoryInfo; + +typedef struct VkBindImageMemoryInfo { + VkStructureType sType; + const void* pNext; + VkImage image; + VkDeviceMemory memory; + VkDeviceSize memoryOffset; +} VkBindImageMemoryInfo; + +typedef struct VkPhysicalDevice16BitStorageFeatures { + VkStructureType sType; + void* pNext; + VkBool32 storageBuffer16BitAccess; + VkBool32 uniformAndStorageBuffer16BitAccess; + VkBool32 storagePushConstant16; + VkBool32 storageInputOutput16; +} VkPhysicalDevice16BitStorageFeatures; + +typedef struct VkMemoryDedicatedRequirements { + VkStructureType sType; + void* pNext; + VkBool32 prefersDedicatedAllocation; + VkBool32 requiresDedicatedAllocation; +} VkMemoryDedicatedRequirements; + +typedef struct VkMemoryDedicatedAllocateInfo { + VkStructureType sType; + const void* pNext; + VkImage image; + VkBuffer buffer; +} VkMemoryDedicatedAllocateInfo; + +typedef struct VkMemoryAllocateFlagsInfo { + VkStructureType sType; + const void* pNext; + VkMemoryAllocateFlags flags; + uint32_t deviceMask; +} VkMemoryAllocateFlagsInfo; + +typedef struct VkDeviceGroupRenderPassBeginInfo { + VkStructureType sType; + const void* pNext; + uint32_t deviceMask; + uint32_t deviceRenderAreaCount; + const VkRect2D* pDeviceRenderAreas; +} VkDeviceGroupRenderPassBeginInfo; + +typedef struct VkDeviceGroupCommandBufferBeginInfo { + VkStructureType sType; + const void* pNext; + uint32_t deviceMask; +} VkDeviceGroupCommandBufferBeginInfo; + +typedef struct VkDeviceGroupSubmitInfo { + VkStructureType sType; + const void* pNext; + uint32_t waitSemaphoreCount; + const uint32_t* pWaitSemaphoreDeviceIndices; + uint32_t commandBufferCount; + const uint32_t* pCommandBufferDeviceMasks; + uint32_t signalSemaphoreCount; + const uint32_t* pSignalSemaphoreDeviceIndices; +} VkDeviceGroupSubmitInfo; + +typedef struct VkDeviceGroupBindSparseInfo { + VkStructureType sType; + const void* pNext; + uint32_t resourceDeviceIndex; + uint32_t memoryDeviceIndex; +} VkDeviceGroupBindSparseInfo; + +typedef struct VkBindBufferMemoryDeviceGroupInfo { + VkStructureType sType; + const void* pNext; + uint32_t deviceIndexCount; + const uint32_t* pDeviceIndices; +} VkBindBufferMemoryDeviceGroupInfo; + +typedef struct VkBindImageMemoryDeviceGroupInfo { + VkStructureType sType; + const void* pNext; + uint32_t deviceIndexCount; + const uint32_t* pDeviceIndices; + uint32_t splitInstanceBindRegionCount; + const VkRect2D* pSplitInstanceBindRegions; +} VkBindImageMemoryDeviceGroupInfo; + +typedef struct VkPhysicalDeviceGroupProperties { + VkStructureType sType; + void* pNext; + uint32_t physicalDeviceCount; + VkPhysicalDevice physicalDevices[VK_MAX_DEVICE_GROUP_SIZE]; + VkBool32 subsetAllocation; +} VkPhysicalDeviceGroupProperties; + +typedef struct VkDeviceGroupDeviceCreateInfo { + VkStructureType sType; + const void* pNext; + uint32_t physicalDeviceCount; + const VkPhysicalDevice* pPhysicalDevices; +} VkDeviceGroupDeviceCreateInfo; + +typedef struct VkBufferMemoryRequirementsInfo2 { + VkStructureType sType; + const void* pNext; + VkBuffer buffer; +} VkBufferMemoryRequirementsInfo2; + +typedef struct VkImageMemoryRequirementsInfo2 { + VkStructureType sType; + const void* pNext; + VkImage image; +} VkImageMemoryRequirementsInfo2; + +typedef struct VkImageSparseMemoryRequirementsInfo2 { + VkStructureType sType; + const void* pNext; + VkImage image; +} VkImageSparseMemoryRequirementsInfo2; + +typedef struct VkMemoryRequirements2 { + VkStructureType sType; + void* pNext; + VkMemoryRequirements memoryRequirements; +} VkMemoryRequirements2; + +typedef VkMemoryRequirements2 VkMemoryRequirements2KHR; + +typedef struct VkSparseImageMemoryRequirements2 { + VkStructureType sType; + void* pNext; + VkSparseImageMemoryRequirements memoryRequirements; +} VkSparseImageMemoryRequirements2; + +typedef struct VkPhysicalDeviceFeatures2 { + VkStructureType sType; + void* pNext; + VkPhysicalDeviceFeatures features; +} VkPhysicalDeviceFeatures2; + +typedef struct VkPhysicalDeviceProperties2 { + VkStructureType sType; + void* pNext; + VkPhysicalDeviceProperties properties; +} VkPhysicalDeviceProperties2; + +typedef struct VkFormatProperties2 { + VkStructureType sType; + void* pNext; + VkFormatProperties formatProperties; +} VkFormatProperties2; + +typedef struct VkImageFormatProperties2 { + VkStructureType sType; + void* pNext; + VkImageFormatProperties imageFormatProperties; +} VkImageFormatProperties2; + +typedef struct VkPhysicalDeviceImageFormatInfo2 { + VkStructureType sType; + const void* pNext; + VkFormat format; + VkImageType type; + VkImageTiling tiling; + VkImageUsageFlags usage; + VkImageCreateFlags flags; +} VkPhysicalDeviceImageFormatInfo2; + +typedef struct VkQueueFamilyProperties2 { + VkStructureType sType; + void* pNext; + VkQueueFamilyProperties queueFamilyProperties; +} VkQueueFamilyProperties2; + +typedef struct VkPhysicalDeviceMemoryProperties2 { + VkStructureType sType; + void* pNext; + VkPhysicalDeviceMemoryProperties memoryProperties; +} VkPhysicalDeviceMemoryProperties2; + +typedef struct VkSparseImageFormatProperties2 { + VkStructureType sType; + void* pNext; + VkSparseImageFormatProperties properties; +} VkSparseImageFormatProperties2; + +typedef struct VkPhysicalDeviceSparseImageFormatInfo2 { + VkStructureType sType; + const void* pNext; + VkFormat format; + VkImageType type; + VkSampleCountFlagBits samples; + VkImageUsageFlags usage; + VkImageTiling tiling; +} VkPhysicalDeviceSparseImageFormatInfo2; + +typedef struct VkPhysicalDevicePointClippingProperties { + VkStructureType sType; + void* pNext; + VkPointClippingBehavior pointClippingBehavior; +} VkPhysicalDevicePointClippingProperties; + +typedef struct VkInputAttachmentAspectReference { + uint32_t subpass; + uint32_t inputAttachmentIndex; + VkImageAspectFlags aspectMask; +} VkInputAttachmentAspectReference; + +typedef struct VkRenderPassInputAttachmentAspectCreateInfo { + VkStructureType sType; + const void* pNext; + uint32_t aspectReferenceCount; + const VkInputAttachmentAspectReference* pAspectReferences; +} VkRenderPassInputAttachmentAspectCreateInfo; + +typedef struct VkImageViewUsageCreateInfo { + VkStructureType sType; + const void* pNext; + VkImageUsageFlags usage; +} VkImageViewUsageCreateInfo; + +typedef struct VkPipelineTessellationDomainOriginStateCreateInfo { + VkStructureType sType; + const void* pNext; + VkTessellationDomainOrigin domainOrigin; +} VkPipelineTessellationDomainOriginStateCreateInfo; + +typedef struct VkRenderPassMultiviewCreateInfo { + VkStructureType sType; + const void* pNext; + uint32_t subpassCount; + const uint32_t* pViewMasks; + uint32_t dependencyCount; + const int32_t* pViewOffsets; + uint32_t correlationMaskCount; + const uint32_t* pCorrelationMasks; +} VkRenderPassMultiviewCreateInfo; + +typedef struct VkPhysicalDeviceMultiviewFeatures { + VkStructureType sType; + void* pNext; + VkBool32 multiview; + VkBool32 multiviewGeometryShader; + VkBool32 multiviewTessellationShader; +} VkPhysicalDeviceMultiviewFeatures; + +typedef struct VkPhysicalDeviceMultiviewProperties { + VkStructureType sType; + void* pNext; + uint32_t maxMultiviewViewCount; + uint32_t maxMultiviewInstanceIndex; +} VkPhysicalDeviceMultiviewProperties; + +typedef struct VkPhysicalDeviceVariablePointersFeatures { + VkStructureType sType; + void* pNext; + VkBool32 variablePointersStorageBuffer; + VkBool32 variablePointers; +} VkPhysicalDeviceVariablePointersFeatures; + +typedef VkPhysicalDeviceVariablePointersFeatures VkPhysicalDeviceVariablePointerFeatures; + +typedef struct VkPhysicalDeviceProtectedMemoryFeatures { + VkStructureType sType; + void* pNext; + VkBool32 protectedMemory; +} VkPhysicalDeviceProtectedMemoryFeatures; + +typedef struct VkPhysicalDeviceProtectedMemoryProperties { + VkStructureType sType; + void* pNext; + VkBool32 protectedNoFault; +} VkPhysicalDeviceProtectedMemoryProperties; + +typedef struct VkDeviceQueueInfo2 { + VkStructureType sType; + const void* pNext; + VkDeviceQueueCreateFlags flags; + uint32_t queueFamilyIndex; + uint32_t queueIndex; +} VkDeviceQueueInfo2; + +typedef struct VkProtectedSubmitInfo { + VkStructureType sType; + const void* pNext; + VkBool32 protectedSubmit; +} VkProtectedSubmitInfo; + +typedef struct VkSamplerYcbcrConversionCreateInfo { + VkStructureType sType; + const void* pNext; + VkFormat format; + VkSamplerYcbcrModelConversion ycbcrModel; + VkSamplerYcbcrRange ycbcrRange; + VkComponentMapping components; + VkChromaLocation xChromaOffset; + VkChromaLocation yChromaOffset; + VkFilter chromaFilter; + VkBool32 forceExplicitReconstruction; +} VkSamplerYcbcrConversionCreateInfo; + +typedef struct VkSamplerYcbcrConversionInfo { + VkStructureType sType; + const void* pNext; + VkSamplerYcbcrConversion conversion; +} VkSamplerYcbcrConversionInfo; + +typedef struct VkBindImagePlaneMemoryInfo { + VkStructureType sType; + const void* pNext; + VkImageAspectFlagBits planeAspect; +} VkBindImagePlaneMemoryInfo; + +typedef struct VkImagePlaneMemoryRequirementsInfo { + VkStructureType sType; + const void* pNext; + VkImageAspectFlagBits planeAspect; +} VkImagePlaneMemoryRequirementsInfo; + +typedef struct VkPhysicalDeviceSamplerYcbcrConversionFeatures { + VkStructureType sType; + void* pNext; + VkBool32 samplerYcbcrConversion; +} VkPhysicalDeviceSamplerYcbcrConversionFeatures; + +typedef struct VkSamplerYcbcrConversionImageFormatProperties { + VkStructureType sType; + void* pNext; + uint32_t combinedImageSamplerDescriptorCount; +} VkSamplerYcbcrConversionImageFormatProperties; + +typedef struct VkDescriptorUpdateTemplateEntry { + uint32_t dstBinding; + uint32_t dstArrayElement; + uint32_t descriptorCount; + VkDescriptorType descriptorType; + size_t offset; + size_t stride; +} VkDescriptorUpdateTemplateEntry; + +typedef struct VkDescriptorUpdateTemplateCreateInfo { + VkStructureType sType; + const void* pNext; + VkDescriptorUpdateTemplateCreateFlags flags; + uint32_t descriptorUpdateEntryCount; + const VkDescriptorUpdateTemplateEntry* pDescriptorUpdateEntries; + VkDescriptorUpdateTemplateType templateType; + VkDescriptorSetLayout descriptorSetLayout; + VkPipelineBindPoint pipelineBindPoint; + VkPipelineLayout pipelineLayout; + uint32_t set; +} VkDescriptorUpdateTemplateCreateInfo; + +typedef struct VkExternalMemoryProperties { + VkExternalMemoryFeatureFlags externalMemoryFeatures; + VkExternalMemoryHandleTypeFlags exportFromImportedHandleTypes; + VkExternalMemoryHandleTypeFlags compatibleHandleTypes; +} VkExternalMemoryProperties; + +typedef struct VkPhysicalDeviceExternalImageFormatInfo { + VkStructureType sType; + const void* pNext; + VkExternalMemoryHandleTypeFlagBits handleType; +} VkPhysicalDeviceExternalImageFormatInfo; + +typedef struct VkExternalImageFormatProperties { + VkStructureType sType; + void* pNext; + VkExternalMemoryProperties externalMemoryProperties; +} VkExternalImageFormatProperties; + +typedef struct VkPhysicalDeviceExternalBufferInfo { + VkStructureType sType; + const void* pNext; + VkBufferCreateFlags flags; + VkBufferUsageFlags usage; + VkExternalMemoryHandleTypeFlagBits handleType; +} VkPhysicalDeviceExternalBufferInfo; + +typedef struct VkExternalBufferProperties { + VkStructureType sType; + void* pNext; + VkExternalMemoryProperties externalMemoryProperties; +} VkExternalBufferProperties; + +typedef struct VkPhysicalDeviceIDProperties { + VkStructureType sType; + void* pNext; + uint8_t deviceUUID[VK_UUID_SIZE]; + uint8_t driverUUID[VK_UUID_SIZE]; + uint8_t deviceLUID[VK_LUID_SIZE]; + uint32_t deviceNodeMask; + VkBool32 deviceLUIDValid; +} VkPhysicalDeviceIDProperties; + +typedef struct VkExternalMemoryImageCreateInfo { + VkStructureType sType; + const void* pNext; + VkExternalMemoryHandleTypeFlags handleTypes; +} VkExternalMemoryImageCreateInfo; + +typedef struct VkExternalMemoryBufferCreateInfo { + VkStructureType sType; + const void* pNext; + VkExternalMemoryHandleTypeFlags handleTypes; +} VkExternalMemoryBufferCreateInfo; + +typedef struct VkExportMemoryAllocateInfo { + VkStructureType sType; + const void* pNext; + VkExternalMemoryHandleTypeFlags handleTypes; +} VkExportMemoryAllocateInfo; + +typedef struct VkPhysicalDeviceExternalFenceInfo { + VkStructureType sType; + const void* pNext; + VkExternalFenceHandleTypeFlagBits handleType; +} VkPhysicalDeviceExternalFenceInfo; + +typedef struct VkExternalFenceProperties { + VkStructureType sType; + void* pNext; + VkExternalFenceHandleTypeFlags exportFromImportedHandleTypes; + VkExternalFenceHandleTypeFlags compatibleHandleTypes; + VkExternalFenceFeatureFlags externalFenceFeatures; +} VkExternalFenceProperties; + +typedef struct VkExportFenceCreateInfo { + VkStructureType sType; + const void* pNext; + VkExternalFenceHandleTypeFlags handleTypes; +} VkExportFenceCreateInfo; + +typedef struct VkExportSemaphoreCreateInfo { + VkStructureType sType; + const void* pNext; + VkExternalSemaphoreHandleTypeFlags handleTypes; +} VkExportSemaphoreCreateInfo; + +typedef struct VkPhysicalDeviceExternalSemaphoreInfo { + VkStructureType sType; + const void* pNext; + VkExternalSemaphoreHandleTypeFlagBits handleType; +} VkPhysicalDeviceExternalSemaphoreInfo; + +typedef struct VkExternalSemaphoreProperties { + VkStructureType sType; + void* pNext; + VkExternalSemaphoreHandleTypeFlags exportFromImportedHandleTypes; + VkExternalSemaphoreHandleTypeFlags compatibleHandleTypes; + VkExternalSemaphoreFeatureFlags externalSemaphoreFeatures; +} VkExternalSemaphoreProperties; + +typedef struct VkPhysicalDeviceMaintenance3Properties { + VkStructureType sType; + void* pNext; + uint32_t maxPerSetDescriptors; + VkDeviceSize maxMemoryAllocationSize; +} VkPhysicalDeviceMaintenance3Properties; + +typedef struct VkDescriptorSetLayoutSupport { + VkStructureType sType; + void* pNext; + VkBool32 supported; +} VkDescriptorSetLayoutSupport; + +typedef struct VkPhysicalDeviceShaderDrawParametersFeatures { + VkStructureType sType; + void* pNext; + VkBool32 shaderDrawParameters; +} VkPhysicalDeviceShaderDrawParametersFeatures; + +typedef VkPhysicalDeviceShaderDrawParametersFeatures VkPhysicalDeviceShaderDrawParameterFeatures; + +typedef VkResult (VKAPI_PTR *PFN_vkEnumerateInstanceVersion)(uint32_t* pApiVersion); +typedef VkResult (VKAPI_PTR *PFN_vkBindBufferMemory2)(VkDevice device, uint32_t bindInfoCount, const VkBindBufferMemoryInfo* pBindInfos); +typedef VkResult (VKAPI_PTR *PFN_vkBindImageMemory2)(VkDevice device, uint32_t bindInfoCount, const VkBindImageMemoryInfo* pBindInfos); +typedef void (VKAPI_PTR *PFN_vkGetDeviceGroupPeerMemoryFeatures)(VkDevice device, uint32_t heapIndex, uint32_t localDeviceIndex, uint32_t remoteDeviceIndex, VkPeerMemoryFeatureFlags* pPeerMemoryFeatures); +typedef void (VKAPI_PTR *PFN_vkCmdSetDeviceMask)(VkCommandBuffer commandBuffer, uint32_t deviceMask); +typedef void (VKAPI_PTR *PFN_vkCmdDispatchBase)(VkCommandBuffer commandBuffer, uint32_t baseGroupX, uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ); +typedef VkResult (VKAPI_PTR *PFN_vkEnumeratePhysicalDeviceGroups)(VkInstance instance, uint32_t* pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties); +typedef void (VKAPI_PTR *PFN_vkGetImageMemoryRequirements2)(VkDevice device, const VkImageMemoryRequirementsInfo2* pInfo, VkMemoryRequirements2* pMemoryRequirements); +typedef void (VKAPI_PTR *PFN_vkGetBufferMemoryRequirements2)(VkDevice device, const VkBufferMemoryRequirementsInfo2* pInfo, VkMemoryRequirements2* pMemoryRequirements); +typedef void (VKAPI_PTR *PFN_vkGetImageSparseMemoryRequirements2)(VkDevice device, const VkImageSparseMemoryRequirementsInfo2* pInfo, uint32_t* pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements2* pSparseMemoryRequirements); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceFeatures2)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures2* pFeatures); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceProperties2)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties2* pProperties); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceFormatProperties2)(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties2* pFormatProperties); +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceImageFormatProperties2)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2* pImageFormatInfo, VkImageFormatProperties2* pImageFormatProperties); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceQueueFamilyProperties2)(VkPhysicalDevice physicalDevice, uint32_t* pQueueFamilyPropertyCount, VkQueueFamilyProperties2* pQueueFamilyProperties); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceMemoryProperties2)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties2* pMemoryProperties); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceSparseImageFormatProperties2)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSparseImageFormatInfo2* pFormatInfo, uint32_t* pPropertyCount, VkSparseImageFormatProperties2* pProperties); +typedef void (VKAPI_PTR *PFN_vkTrimCommandPool)(VkDevice device, VkCommandPool commandPool, VkCommandPoolTrimFlags flags); +typedef void (VKAPI_PTR *PFN_vkGetDeviceQueue2)(VkDevice device, const VkDeviceQueueInfo2* pQueueInfo, VkQueue* pQueue); +typedef VkResult (VKAPI_PTR *PFN_vkCreateSamplerYcbcrConversion)(VkDevice device, const VkSamplerYcbcrConversionCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSamplerYcbcrConversion* pYcbcrConversion); +typedef void (VKAPI_PTR *PFN_vkDestroySamplerYcbcrConversion)(VkDevice device, VkSamplerYcbcrConversion ycbcrConversion, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkCreateDescriptorUpdateTemplate)(VkDevice device, const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDescriptorUpdateTemplate* pDescriptorUpdateTemplate); +typedef void (VKAPI_PTR *PFN_vkDestroyDescriptorUpdateTemplate)(VkDevice device, VkDescriptorUpdateTemplate descriptorUpdateTemplate, const VkAllocationCallbacks* pAllocator); +typedef void (VKAPI_PTR *PFN_vkUpdateDescriptorSetWithTemplate)(VkDevice device, VkDescriptorSet descriptorSet, VkDescriptorUpdateTemplate descriptorUpdateTemplate, const void* pData); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceExternalBufferProperties)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo, VkExternalBufferProperties* pExternalBufferProperties); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceExternalFenceProperties)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalFenceInfo* pExternalFenceInfo, VkExternalFenceProperties* pExternalFenceProperties); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceExternalSemaphoreProperties)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo, VkExternalSemaphoreProperties* pExternalSemaphoreProperties); +typedef void (VKAPI_PTR *PFN_vkGetDescriptorSetLayoutSupport)(VkDevice device, const VkDescriptorSetLayoutCreateInfo* pCreateInfo, VkDescriptorSetLayoutSupport* pSupport); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceVersion( + uint32_t* pApiVersion); + +VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory2( + VkDevice device, + uint32_t bindInfoCount, + const VkBindBufferMemoryInfo* pBindInfos); + +VKAPI_ATTR VkResult VKAPI_CALL vkBindImageMemory2( + VkDevice device, + uint32_t bindInfoCount, + const VkBindImageMemoryInfo* pBindInfos); + +VKAPI_ATTR void VKAPI_CALL vkGetDeviceGroupPeerMemoryFeatures( + VkDevice device, + uint32_t heapIndex, + uint32_t localDeviceIndex, + uint32_t remoteDeviceIndex, + VkPeerMemoryFeatureFlags* pPeerMemoryFeatures); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDeviceMask( + VkCommandBuffer commandBuffer, + uint32_t deviceMask); + +VKAPI_ATTR void VKAPI_CALL vkCmdDispatchBase( + VkCommandBuffer commandBuffer, + uint32_t baseGroupX, + uint32_t baseGroupY, + uint32_t baseGroupZ, + uint32_t groupCountX, + uint32_t groupCountY, + uint32_t groupCountZ); + +VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDeviceGroups( + VkInstance instance, + uint32_t* pPhysicalDeviceGroupCount, + VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetImageMemoryRequirements2( + VkDevice device, + const VkImageMemoryRequirementsInfo2* pInfo, + VkMemoryRequirements2* pMemoryRequirements); + +VKAPI_ATTR void VKAPI_CALL vkGetBufferMemoryRequirements2( + VkDevice device, + const VkBufferMemoryRequirementsInfo2* pInfo, + VkMemoryRequirements2* pMemoryRequirements); + +VKAPI_ATTR void VKAPI_CALL vkGetImageSparseMemoryRequirements2( + VkDevice device, + const VkImageSparseMemoryRequirementsInfo2* pInfo, + uint32_t* pSparseMemoryRequirementCount, + VkSparseImageMemoryRequirements2* pSparseMemoryRequirements); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures2( + VkPhysicalDevice physicalDevice, + VkPhysicalDeviceFeatures2* pFeatures); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties2( + VkPhysicalDevice physicalDevice, + VkPhysicalDeviceProperties2* pProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties2( + VkPhysicalDevice physicalDevice, + VkFormat format, + VkFormatProperties2* pFormatProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties2( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceImageFormatInfo2* pImageFormatInfo, + VkImageFormatProperties2* pImageFormatProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties2( + VkPhysicalDevice physicalDevice, + uint32_t* pQueueFamilyPropertyCount, + VkQueueFamilyProperties2* pQueueFamilyProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties2( + VkPhysicalDevice physicalDevice, + VkPhysicalDeviceMemoryProperties2* pMemoryProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceSparseImageFormatProperties2( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceSparseImageFormatInfo2* pFormatInfo, + uint32_t* pPropertyCount, + VkSparseImageFormatProperties2* pProperties); + +VKAPI_ATTR void VKAPI_CALL vkTrimCommandPool( + VkDevice device, + VkCommandPool commandPool, + VkCommandPoolTrimFlags flags); + +VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue2( + VkDevice device, + const VkDeviceQueueInfo2* pQueueInfo, + VkQueue* pQueue); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateSamplerYcbcrConversion( + VkDevice device, + const VkSamplerYcbcrConversionCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSamplerYcbcrConversion* pYcbcrConversion); + +VKAPI_ATTR void VKAPI_CALL vkDestroySamplerYcbcrConversion( + VkDevice device, + VkSamplerYcbcrConversion ycbcrConversion, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorUpdateTemplate( + VkDevice device, + const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkDescriptorUpdateTemplate* pDescriptorUpdateTemplate); + +VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorUpdateTemplate( + VkDevice device, + VkDescriptorUpdateTemplate descriptorUpdateTemplate, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR void VKAPI_CALL vkUpdateDescriptorSetWithTemplate( + VkDevice device, + VkDescriptorSet descriptorSet, + VkDescriptorUpdateTemplate descriptorUpdateTemplate, + const void* pData); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalBufferProperties( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo, + VkExternalBufferProperties* pExternalBufferProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalFenceProperties( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceExternalFenceInfo* pExternalFenceInfo, + VkExternalFenceProperties* pExternalFenceProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalSemaphoreProperties( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo, + VkExternalSemaphoreProperties* pExternalSemaphoreProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetDescriptorSetLayoutSupport( + VkDevice device, + const VkDescriptorSetLayoutCreateInfo* pCreateInfo, + VkDescriptorSetLayoutSupport* pSupport); +#endif + + +#define VK_VERSION_1_2 1 +// Vulkan 1.2 version number +#define VK_API_VERSION_1_2 VK_MAKE_VERSION(1, 2, 0)// Patch version should always be set to 0 + +typedef uint64_t VkDeviceAddress; +#define VK_MAX_DRIVER_NAME_SIZE 256 +#define VK_MAX_DRIVER_INFO_SIZE 256 + +typedef enum VkDriverId { + VK_DRIVER_ID_AMD_PROPRIETARY = 1, + VK_DRIVER_ID_AMD_OPEN_SOURCE = 2, + VK_DRIVER_ID_MESA_RADV = 3, + VK_DRIVER_ID_NVIDIA_PROPRIETARY = 4, + VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS = 5, + VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA = 6, + VK_DRIVER_ID_IMAGINATION_PROPRIETARY = 7, + VK_DRIVER_ID_QUALCOMM_PROPRIETARY = 8, + VK_DRIVER_ID_ARM_PROPRIETARY = 9, + VK_DRIVER_ID_GOOGLE_SWIFTSHADER = 10, + VK_DRIVER_ID_GGP_PROPRIETARY = 11, + VK_DRIVER_ID_BROADCOM_PROPRIETARY = 12, + VK_DRIVER_ID_AMD_PROPRIETARY_KHR = VK_DRIVER_ID_AMD_PROPRIETARY, + VK_DRIVER_ID_AMD_OPEN_SOURCE_KHR = VK_DRIVER_ID_AMD_OPEN_SOURCE, + VK_DRIVER_ID_MESA_RADV_KHR = VK_DRIVER_ID_MESA_RADV, + VK_DRIVER_ID_NVIDIA_PROPRIETARY_KHR = VK_DRIVER_ID_NVIDIA_PROPRIETARY, + VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS_KHR = VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS, + VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA_KHR = VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA, + VK_DRIVER_ID_IMAGINATION_PROPRIETARY_KHR = VK_DRIVER_ID_IMAGINATION_PROPRIETARY, + VK_DRIVER_ID_QUALCOMM_PROPRIETARY_KHR = VK_DRIVER_ID_QUALCOMM_PROPRIETARY, + VK_DRIVER_ID_ARM_PROPRIETARY_KHR = VK_DRIVER_ID_ARM_PROPRIETARY, + VK_DRIVER_ID_GOOGLE_SWIFTSHADER_KHR = VK_DRIVER_ID_GOOGLE_SWIFTSHADER, + VK_DRIVER_ID_GGP_PROPRIETARY_KHR = VK_DRIVER_ID_GGP_PROPRIETARY, + VK_DRIVER_ID_BROADCOM_PROPRIETARY_KHR = VK_DRIVER_ID_BROADCOM_PROPRIETARY, + VK_DRIVER_ID_BEGIN_RANGE = VK_DRIVER_ID_AMD_PROPRIETARY, + VK_DRIVER_ID_END_RANGE = VK_DRIVER_ID_BROADCOM_PROPRIETARY, + VK_DRIVER_ID_RANGE_SIZE = (VK_DRIVER_ID_BROADCOM_PROPRIETARY - VK_DRIVER_ID_AMD_PROPRIETARY + 1), + VK_DRIVER_ID_MAX_ENUM = 0x7FFFFFFF +} VkDriverId; + +typedef enum VkShaderFloatControlsIndependence { + VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_32_BIT_ONLY = 0, + VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_ALL = 1, + VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_NONE = 2, + VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_32_BIT_ONLY_KHR = VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_32_BIT_ONLY, + VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_ALL_KHR = VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_ALL, + VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_NONE_KHR = VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_NONE, + VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_BEGIN_RANGE = VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_32_BIT_ONLY, + VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_END_RANGE = VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_NONE, + VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_RANGE_SIZE = (VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_NONE - VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_32_BIT_ONLY + 1), + VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_MAX_ENUM = 0x7FFFFFFF +} VkShaderFloatControlsIndependence; + +typedef enum VkSamplerReductionMode { + VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE = 0, + VK_SAMPLER_REDUCTION_MODE_MIN = 1, + VK_SAMPLER_REDUCTION_MODE_MAX = 2, + VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE_EXT = VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE, + VK_SAMPLER_REDUCTION_MODE_MIN_EXT = VK_SAMPLER_REDUCTION_MODE_MIN, + VK_SAMPLER_REDUCTION_MODE_MAX_EXT = VK_SAMPLER_REDUCTION_MODE_MAX, + VK_SAMPLER_REDUCTION_MODE_BEGIN_RANGE = VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE, + VK_SAMPLER_REDUCTION_MODE_END_RANGE = VK_SAMPLER_REDUCTION_MODE_MAX, + VK_SAMPLER_REDUCTION_MODE_RANGE_SIZE = (VK_SAMPLER_REDUCTION_MODE_MAX - VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE + 1), + VK_SAMPLER_REDUCTION_MODE_MAX_ENUM = 0x7FFFFFFF +} VkSamplerReductionMode; + +typedef enum VkSemaphoreType { + VK_SEMAPHORE_TYPE_BINARY = 0, + VK_SEMAPHORE_TYPE_TIMELINE = 1, + VK_SEMAPHORE_TYPE_BINARY_KHR = VK_SEMAPHORE_TYPE_BINARY, + VK_SEMAPHORE_TYPE_TIMELINE_KHR = VK_SEMAPHORE_TYPE_TIMELINE, + VK_SEMAPHORE_TYPE_BEGIN_RANGE = VK_SEMAPHORE_TYPE_BINARY, + VK_SEMAPHORE_TYPE_END_RANGE = VK_SEMAPHORE_TYPE_TIMELINE, + VK_SEMAPHORE_TYPE_RANGE_SIZE = (VK_SEMAPHORE_TYPE_TIMELINE - VK_SEMAPHORE_TYPE_BINARY + 1), + VK_SEMAPHORE_TYPE_MAX_ENUM = 0x7FFFFFFF +} VkSemaphoreType; + +typedef enum VkResolveModeFlagBits { + VK_RESOLVE_MODE_NONE = 0, + VK_RESOLVE_MODE_SAMPLE_ZERO_BIT = 0x00000001, + VK_RESOLVE_MODE_AVERAGE_BIT = 0x00000002, + VK_RESOLVE_MODE_MIN_BIT = 0x00000004, + VK_RESOLVE_MODE_MAX_BIT = 0x00000008, + VK_RESOLVE_MODE_NONE_KHR = VK_RESOLVE_MODE_NONE, + VK_RESOLVE_MODE_SAMPLE_ZERO_BIT_KHR = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT, + VK_RESOLVE_MODE_AVERAGE_BIT_KHR = VK_RESOLVE_MODE_AVERAGE_BIT, + VK_RESOLVE_MODE_MIN_BIT_KHR = VK_RESOLVE_MODE_MIN_BIT, + VK_RESOLVE_MODE_MAX_BIT_KHR = VK_RESOLVE_MODE_MAX_BIT, + VK_RESOLVE_MODE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkResolveModeFlagBits; +typedef VkFlags VkResolveModeFlags; + +typedef enum VkDescriptorBindingFlagBits { + VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT = 0x00000001, + VK_DESCRIPTOR_BINDING_UPDATE_UNUSED_WHILE_PENDING_BIT = 0x00000002, + VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT = 0x00000004, + VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT = 0x00000008, + VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT_EXT = VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT, + VK_DESCRIPTOR_BINDING_UPDATE_UNUSED_WHILE_PENDING_BIT_EXT = VK_DESCRIPTOR_BINDING_UPDATE_UNUSED_WHILE_PENDING_BIT, + VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT_EXT = VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT, + VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT_EXT = VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT, + VK_DESCRIPTOR_BINDING_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkDescriptorBindingFlagBits; +typedef VkFlags VkDescriptorBindingFlags; + +typedef enum VkSemaphoreWaitFlagBits { + VK_SEMAPHORE_WAIT_ANY_BIT = 0x00000001, + VK_SEMAPHORE_WAIT_ANY_BIT_KHR = VK_SEMAPHORE_WAIT_ANY_BIT, + VK_SEMAPHORE_WAIT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkSemaphoreWaitFlagBits; +typedef VkFlags VkSemaphoreWaitFlags; +typedef struct VkPhysicalDeviceVulkan11Features { + VkStructureType sType; + void* pNext; + VkBool32 storageBuffer16BitAccess; + VkBool32 uniformAndStorageBuffer16BitAccess; + VkBool32 storagePushConstant16; + VkBool32 storageInputOutput16; + VkBool32 multiview; + VkBool32 multiviewGeometryShader; + VkBool32 multiviewTessellationShader; + VkBool32 variablePointersStorageBuffer; + VkBool32 variablePointers; + VkBool32 protectedMemory; + VkBool32 samplerYcbcrConversion; + VkBool32 shaderDrawParameters; +} VkPhysicalDeviceVulkan11Features; + +typedef struct VkPhysicalDeviceVulkan11Properties { + VkStructureType sType; + void* pNext; + uint8_t deviceUUID[VK_UUID_SIZE]; + uint8_t driverUUID[VK_UUID_SIZE]; + uint8_t deviceLUID[VK_LUID_SIZE]; + uint32_t deviceNodeMask; + VkBool32 deviceLUIDValid; + uint32_t subgroupSize; + VkShaderStageFlags subgroupSupportedStages; + VkSubgroupFeatureFlags subgroupSupportedOperations; + VkBool32 subgroupQuadOperationsInAllStages; + VkPointClippingBehavior pointClippingBehavior; + uint32_t maxMultiviewViewCount; + uint32_t maxMultiviewInstanceIndex; + VkBool32 protectedNoFault; + uint32_t maxPerSetDescriptors; + VkDeviceSize maxMemoryAllocationSize; +} VkPhysicalDeviceVulkan11Properties; + +typedef struct VkPhysicalDeviceVulkan12Features { + VkStructureType sType; + void* pNext; + VkBool32 samplerMirrorClampToEdge; + VkBool32 drawIndirectCount; + VkBool32 storageBuffer8BitAccess; + VkBool32 uniformAndStorageBuffer8BitAccess; + VkBool32 storagePushConstant8; + VkBool32 shaderBufferInt64Atomics; + VkBool32 shaderSharedInt64Atomics; + VkBool32 shaderFloat16; + VkBool32 shaderInt8; + VkBool32 descriptorIndexing; + VkBool32 shaderInputAttachmentArrayDynamicIndexing; + VkBool32 shaderUniformTexelBufferArrayDynamicIndexing; + VkBool32 shaderStorageTexelBufferArrayDynamicIndexing; + VkBool32 shaderUniformBufferArrayNonUniformIndexing; + VkBool32 shaderSampledImageArrayNonUniformIndexing; + VkBool32 shaderStorageBufferArrayNonUniformIndexing; + VkBool32 shaderStorageImageArrayNonUniformIndexing; + VkBool32 shaderInputAttachmentArrayNonUniformIndexing; + VkBool32 shaderUniformTexelBufferArrayNonUniformIndexing; + VkBool32 shaderStorageTexelBufferArrayNonUniformIndexing; + VkBool32 descriptorBindingUniformBufferUpdateAfterBind; + VkBool32 descriptorBindingSampledImageUpdateAfterBind; + VkBool32 descriptorBindingStorageImageUpdateAfterBind; + VkBool32 descriptorBindingStorageBufferUpdateAfterBind; + VkBool32 descriptorBindingUniformTexelBufferUpdateAfterBind; + VkBool32 descriptorBindingStorageTexelBufferUpdateAfterBind; + VkBool32 descriptorBindingUpdateUnusedWhilePending; + VkBool32 descriptorBindingPartiallyBound; + VkBool32 descriptorBindingVariableDescriptorCount; + VkBool32 runtimeDescriptorArray; + VkBool32 samplerFilterMinmax; + VkBool32 scalarBlockLayout; + VkBool32 imagelessFramebuffer; + VkBool32 uniformBufferStandardLayout; + VkBool32 shaderSubgroupExtendedTypes; + VkBool32 separateDepthStencilLayouts; + VkBool32 hostQueryReset; + VkBool32 timelineSemaphore; + VkBool32 bufferDeviceAddress; + VkBool32 bufferDeviceAddressCaptureReplay; + VkBool32 bufferDeviceAddressMultiDevice; + VkBool32 vulkanMemoryModel; + VkBool32 vulkanMemoryModelDeviceScope; + VkBool32 vulkanMemoryModelAvailabilityVisibilityChains; + VkBool32 shaderOutputViewportIndex; + VkBool32 shaderOutputLayer; + VkBool32 subgroupBroadcastDynamicId; +} VkPhysicalDeviceVulkan12Features; + +typedef struct VkConformanceVersion { + uint8_t major; + uint8_t minor; + uint8_t subminor; + uint8_t patch; +} VkConformanceVersion; + +typedef struct VkPhysicalDeviceVulkan12Properties { + VkStructureType sType; + void* pNext; + VkDriverId driverID; + char driverName[VK_MAX_DRIVER_NAME_SIZE]; + char driverInfo[VK_MAX_DRIVER_INFO_SIZE]; + VkConformanceVersion conformanceVersion; + VkShaderFloatControlsIndependence denormBehaviorIndependence; + VkShaderFloatControlsIndependence roundingModeIndependence; + VkBool32 shaderSignedZeroInfNanPreserveFloat16; + VkBool32 shaderSignedZeroInfNanPreserveFloat32; + VkBool32 shaderSignedZeroInfNanPreserveFloat64; + VkBool32 shaderDenormPreserveFloat16; + VkBool32 shaderDenormPreserveFloat32; + VkBool32 shaderDenormPreserveFloat64; + VkBool32 shaderDenormFlushToZeroFloat16; + VkBool32 shaderDenormFlushToZeroFloat32; + VkBool32 shaderDenormFlushToZeroFloat64; + VkBool32 shaderRoundingModeRTEFloat16; + VkBool32 shaderRoundingModeRTEFloat32; + VkBool32 shaderRoundingModeRTEFloat64; + VkBool32 shaderRoundingModeRTZFloat16; + VkBool32 shaderRoundingModeRTZFloat32; + VkBool32 shaderRoundingModeRTZFloat64; + uint32_t maxUpdateAfterBindDescriptorsInAllPools; + VkBool32 shaderUniformBufferArrayNonUniformIndexingNative; + VkBool32 shaderSampledImageArrayNonUniformIndexingNative; + VkBool32 shaderStorageBufferArrayNonUniformIndexingNative; + VkBool32 shaderStorageImageArrayNonUniformIndexingNative; + VkBool32 shaderInputAttachmentArrayNonUniformIndexingNative; + VkBool32 robustBufferAccessUpdateAfterBind; + VkBool32 quadDivergentImplicitLod; + uint32_t maxPerStageDescriptorUpdateAfterBindSamplers; + uint32_t maxPerStageDescriptorUpdateAfterBindUniformBuffers; + uint32_t maxPerStageDescriptorUpdateAfterBindStorageBuffers; + uint32_t maxPerStageDescriptorUpdateAfterBindSampledImages; + uint32_t maxPerStageDescriptorUpdateAfterBindStorageImages; + uint32_t maxPerStageDescriptorUpdateAfterBindInputAttachments; + uint32_t maxPerStageUpdateAfterBindResources; + uint32_t maxDescriptorSetUpdateAfterBindSamplers; + uint32_t maxDescriptorSetUpdateAfterBindUniformBuffers; + uint32_t maxDescriptorSetUpdateAfterBindUniformBuffersDynamic; + uint32_t maxDescriptorSetUpdateAfterBindStorageBuffers; + uint32_t maxDescriptorSetUpdateAfterBindStorageBuffersDynamic; + uint32_t maxDescriptorSetUpdateAfterBindSampledImages; + uint32_t maxDescriptorSetUpdateAfterBindStorageImages; + uint32_t maxDescriptorSetUpdateAfterBindInputAttachments; + VkResolveModeFlags supportedDepthResolveModes; + VkResolveModeFlags supportedStencilResolveModes; + VkBool32 independentResolveNone; + VkBool32 independentResolve; + VkBool32 filterMinmaxSingleComponentFormats; + VkBool32 filterMinmaxImageComponentMapping; + uint64_t maxTimelineSemaphoreValueDifference; + VkSampleCountFlags framebufferIntegerColorSampleCounts; +} VkPhysicalDeviceVulkan12Properties; + +typedef struct VkImageFormatListCreateInfo { + VkStructureType sType; + const void* pNext; + uint32_t viewFormatCount; + const VkFormat* pViewFormats; +} VkImageFormatListCreateInfo; + +typedef struct VkAttachmentDescription2 { + VkStructureType sType; + const void* pNext; + VkAttachmentDescriptionFlags flags; + VkFormat format; + VkSampleCountFlagBits samples; + VkAttachmentLoadOp loadOp; + VkAttachmentStoreOp storeOp; + VkAttachmentLoadOp stencilLoadOp; + VkAttachmentStoreOp stencilStoreOp; + VkImageLayout initialLayout; + VkImageLayout finalLayout; +} VkAttachmentDescription2; + +typedef struct VkAttachmentReference2 { + VkStructureType sType; + const void* pNext; + uint32_t attachment; + VkImageLayout layout; + VkImageAspectFlags aspectMask; +} VkAttachmentReference2; + +typedef struct VkSubpassDescription2 { + VkStructureType sType; + const void* pNext; + VkSubpassDescriptionFlags flags; + VkPipelineBindPoint pipelineBindPoint; + uint32_t viewMask; + uint32_t inputAttachmentCount; + const VkAttachmentReference2* pInputAttachments; + uint32_t colorAttachmentCount; + const VkAttachmentReference2* pColorAttachments; + const VkAttachmentReference2* pResolveAttachments; + const VkAttachmentReference2* pDepthStencilAttachment; + uint32_t preserveAttachmentCount; + const uint32_t* pPreserveAttachments; +} VkSubpassDescription2; + +typedef struct VkSubpassDependency2 { + VkStructureType sType; + const void* pNext; + uint32_t srcSubpass; + uint32_t dstSubpass; + VkPipelineStageFlags srcStageMask; + VkPipelineStageFlags dstStageMask; + VkAccessFlags srcAccessMask; + VkAccessFlags dstAccessMask; + VkDependencyFlags dependencyFlags; + int32_t viewOffset; +} VkSubpassDependency2; + +typedef struct VkRenderPassCreateInfo2 { + VkStructureType sType; + const void* pNext; + VkRenderPassCreateFlags flags; + uint32_t attachmentCount; + const VkAttachmentDescription2* pAttachments; + uint32_t subpassCount; + const VkSubpassDescription2* pSubpasses; + uint32_t dependencyCount; + const VkSubpassDependency2* pDependencies; + uint32_t correlatedViewMaskCount; + const uint32_t* pCorrelatedViewMasks; +} VkRenderPassCreateInfo2; + +typedef struct VkSubpassBeginInfo { + VkStructureType sType; + const void* pNext; + VkSubpassContents contents; +} VkSubpassBeginInfo; + +typedef struct VkSubpassEndInfo { + VkStructureType sType; + const void* pNext; +} VkSubpassEndInfo; + +typedef struct VkPhysicalDevice8BitStorageFeatures { + VkStructureType sType; + void* pNext; + VkBool32 storageBuffer8BitAccess; + VkBool32 uniformAndStorageBuffer8BitAccess; + VkBool32 storagePushConstant8; +} VkPhysicalDevice8BitStorageFeatures; + +typedef struct VkPhysicalDeviceDriverProperties { + VkStructureType sType; + void* pNext; + VkDriverId driverID; + char driverName[VK_MAX_DRIVER_NAME_SIZE]; + char driverInfo[VK_MAX_DRIVER_INFO_SIZE]; + VkConformanceVersion conformanceVersion; +} VkPhysicalDeviceDriverProperties; + +typedef struct VkPhysicalDeviceShaderAtomicInt64Features { + VkStructureType sType; + void* pNext; + VkBool32 shaderBufferInt64Atomics; + VkBool32 shaderSharedInt64Atomics; +} VkPhysicalDeviceShaderAtomicInt64Features; + +typedef struct VkPhysicalDeviceShaderFloat16Int8Features { + VkStructureType sType; + void* pNext; + VkBool32 shaderFloat16; + VkBool32 shaderInt8; +} VkPhysicalDeviceShaderFloat16Int8Features; + +typedef struct VkPhysicalDeviceFloatControlsProperties { + VkStructureType sType; + void* pNext; + VkShaderFloatControlsIndependence denormBehaviorIndependence; + VkShaderFloatControlsIndependence roundingModeIndependence; + VkBool32 shaderSignedZeroInfNanPreserveFloat16; + VkBool32 shaderSignedZeroInfNanPreserveFloat32; + VkBool32 shaderSignedZeroInfNanPreserveFloat64; + VkBool32 shaderDenormPreserveFloat16; + VkBool32 shaderDenormPreserveFloat32; + VkBool32 shaderDenormPreserveFloat64; + VkBool32 shaderDenormFlushToZeroFloat16; + VkBool32 shaderDenormFlushToZeroFloat32; + VkBool32 shaderDenormFlushToZeroFloat64; + VkBool32 shaderRoundingModeRTEFloat16; + VkBool32 shaderRoundingModeRTEFloat32; + VkBool32 shaderRoundingModeRTEFloat64; + VkBool32 shaderRoundingModeRTZFloat16; + VkBool32 shaderRoundingModeRTZFloat32; + VkBool32 shaderRoundingModeRTZFloat64; +} VkPhysicalDeviceFloatControlsProperties; + +typedef struct VkDescriptorSetLayoutBindingFlagsCreateInfo { + VkStructureType sType; + const void* pNext; + uint32_t bindingCount; + const VkDescriptorBindingFlags* pBindingFlags; +} VkDescriptorSetLayoutBindingFlagsCreateInfo; + +typedef struct VkPhysicalDeviceDescriptorIndexingFeatures { + VkStructureType sType; + void* pNext; + VkBool32 shaderInputAttachmentArrayDynamicIndexing; + VkBool32 shaderUniformTexelBufferArrayDynamicIndexing; + VkBool32 shaderStorageTexelBufferArrayDynamicIndexing; + VkBool32 shaderUniformBufferArrayNonUniformIndexing; + VkBool32 shaderSampledImageArrayNonUniformIndexing; + VkBool32 shaderStorageBufferArrayNonUniformIndexing; + VkBool32 shaderStorageImageArrayNonUniformIndexing; + VkBool32 shaderInputAttachmentArrayNonUniformIndexing; + VkBool32 shaderUniformTexelBufferArrayNonUniformIndexing; + VkBool32 shaderStorageTexelBufferArrayNonUniformIndexing; + VkBool32 descriptorBindingUniformBufferUpdateAfterBind; + VkBool32 descriptorBindingSampledImageUpdateAfterBind; + VkBool32 descriptorBindingStorageImageUpdateAfterBind; + VkBool32 descriptorBindingStorageBufferUpdateAfterBind; + VkBool32 descriptorBindingUniformTexelBufferUpdateAfterBind; + VkBool32 descriptorBindingStorageTexelBufferUpdateAfterBind; + VkBool32 descriptorBindingUpdateUnusedWhilePending; + VkBool32 descriptorBindingPartiallyBound; + VkBool32 descriptorBindingVariableDescriptorCount; + VkBool32 runtimeDescriptorArray; +} VkPhysicalDeviceDescriptorIndexingFeatures; + +typedef struct VkPhysicalDeviceDescriptorIndexingProperties { + VkStructureType sType; + void* pNext; + uint32_t maxUpdateAfterBindDescriptorsInAllPools; + VkBool32 shaderUniformBufferArrayNonUniformIndexingNative; + VkBool32 shaderSampledImageArrayNonUniformIndexingNative; + VkBool32 shaderStorageBufferArrayNonUniformIndexingNative; + VkBool32 shaderStorageImageArrayNonUniformIndexingNative; + VkBool32 shaderInputAttachmentArrayNonUniformIndexingNative; + VkBool32 robustBufferAccessUpdateAfterBind; + VkBool32 quadDivergentImplicitLod; + uint32_t maxPerStageDescriptorUpdateAfterBindSamplers; + uint32_t maxPerStageDescriptorUpdateAfterBindUniformBuffers; + uint32_t maxPerStageDescriptorUpdateAfterBindStorageBuffers; + uint32_t maxPerStageDescriptorUpdateAfterBindSampledImages; + uint32_t maxPerStageDescriptorUpdateAfterBindStorageImages; + uint32_t maxPerStageDescriptorUpdateAfterBindInputAttachments; + uint32_t maxPerStageUpdateAfterBindResources; + uint32_t maxDescriptorSetUpdateAfterBindSamplers; + uint32_t maxDescriptorSetUpdateAfterBindUniformBuffers; + uint32_t maxDescriptorSetUpdateAfterBindUniformBuffersDynamic; + uint32_t maxDescriptorSetUpdateAfterBindStorageBuffers; + uint32_t maxDescriptorSetUpdateAfterBindStorageBuffersDynamic; + uint32_t maxDescriptorSetUpdateAfterBindSampledImages; + uint32_t maxDescriptorSetUpdateAfterBindStorageImages; + uint32_t maxDescriptorSetUpdateAfterBindInputAttachments; +} VkPhysicalDeviceDescriptorIndexingProperties; + +typedef struct VkDescriptorSetVariableDescriptorCountAllocateInfo { + VkStructureType sType; + const void* pNext; + uint32_t descriptorSetCount; + const uint32_t* pDescriptorCounts; +} VkDescriptorSetVariableDescriptorCountAllocateInfo; + +typedef struct VkDescriptorSetVariableDescriptorCountLayoutSupport { + VkStructureType sType; + void* pNext; + uint32_t maxVariableDescriptorCount; +} VkDescriptorSetVariableDescriptorCountLayoutSupport; + +typedef struct VkSubpassDescriptionDepthStencilResolve { + VkStructureType sType; + const void* pNext; + VkResolveModeFlagBits depthResolveMode; + VkResolveModeFlagBits stencilResolveMode; + const VkAttachmentReference2* pDepthStencilResolveAttachment; +} VkSubpassDescriptionDepthStencilResolve; + +typedef struct VkPhysicalDeviceDepthStencilResolveProperties { + VkStructureType sType; + void* pNext; + VkResolveModeFlags supportedDepthResolveModes; + VkResolveModeFlags supportedStencilResolveModes; + VkBool32 independentResolveNone; + VkBool32 independentResolve; +} VkPhysicalDeviceDepthStencilResolveProperties; + +typedef struct VkPhysicalDeviceScalarBlockLayoutFeatures { + VkStructureType sType; + void* pNext; + VkBool32 scalarBlockLayout; +} VkPhysicalDeviceScalarBlockLayoutFeatures; + +typedef struct VkImageStencilUsageCreateInfo { + VkStructureType sType; + const void* pNext; + VkImageUsageFlags stencilUsage; +} VkImageStencilUsageCreateInfo; + +typedef struct VkSamplerReductionModeCreateInfo { + VkStructureType sType; + const void* pNext; + VkSamplerReductionMode reductionMode; +} VkSamplerReductionModeCreateInfo; + +typedef struct VkPhysicalDeviceSamplerFilterMinmaxProperties { + VkStructureType sType; + void* pNext; + VkBool32 filterMinmaxSingleComponentFormats; + VkBool32 filterMinmaxImageComponentMapping; +} VkPhysicalDeviceSamplerFilterMinmaxProperties; + +typedef struct VkPhysicalDeviceVulkanMemoryModelFeatures { + VkStructureType sType; + void* pNext; + VkBool32 vulkanMemoryModel; + VkBool32 vulkanMemoryModelDeviceScope; + VkBool32 vulkanMemoryModelAvailabilityVisibilityChains; +} VkPhysicalDeviceVulkanMemoryModelFeatures; + +typedef struct VkPhysicalDeviceImagelessFramebufferFeatures { + VkStructureType sType; + void* pNext; + VkBool32 imagelessFramebuffer; +} VkPhysicalDeviceImagelessFramebufferFeatures; + +typedef struct VkFramebufferAttachmentImageInfo { + VkStructureType sType; + const void* pNext; + VkImageCreateFlags flags; + VkImageUsageFlags usage; + uint32_t width; + uint32_t height; + uint32_t layerCount; + uint32_t viewFormatCount; + const VkFormat* pViewFormats; +} VkFramebufferAttachmentImageInfo; + +typedef struct VkFramebufferAttachmentsCreateInfo { + VkStructureType sType; + const void* pNext; + uint32_t attachmentImageInfoCount; + const VkFramebufferAttachmentImageInfo* pAttachmentImageInfos; +} VkFramebufferAttachmentsCreateInfo; + +typedef struct VkRenderPassAttachmentBeginInfo { + VkStructureType sType; + const void* pNext; + uint32_t attachmentCount; + const VkImageView* pAttachments; +} VkRenderPassAttachmentBeginInfo; + +typedef struct VkPhysicalDeviceUniformBufferStandardLayoutFeatures { + VkStructureType sType; + void* pNext; + VkBool32 uniformBufferStandardLayout; +} VkPhysicalDeviceUniformBufferStandardLayoutFeatures; + +typedef struct VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures { + VkStructureType sType; + void* pNext; + VkBool32 shaderSubgroupExtendedTypes; +} VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures; + +typedef struct VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures { + VkStructureType sType; + void* pNext; + VkBool32 separateDepthStencilLayouts; +} VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures; + +typedef struct VkAttachmentReferenceStencilLayout { + VkStructureType sType; + void* pNext; + VkImageLayout stencilLayout; +} VkAttachmentReferenceStencilLayout; + +typedef struct VkAttachmentDescriptionStencilLayout { + VkStructureType sType; + void* pNext; + VkImageLayout stencilInitialLayout; + VkImageLayout stencilFinalLayout; +} VkAttachmentDescriptionStencilLayout; + +typedef struct VkPhysicalDeviceHostQueryResetFeatures { + VkStructureType sType; + void* pNext; + VkBool32 hostQueryReset; +} VkPhysicalDeviceHostQueryResetFeatures; + +typedef struct VkPhysicalDeviceTimelineSemaphoreFeatures { + VkStructureType sType; + void* pNext; + VkBool32 timelineSemaphore; +} VkPhysicalDeviceTimelineSemaphoreFeatures; + +typedef struct VkPhysicalDeviceTimelineSemaphoreProperties { + VkStructureType sType; + void* pNext; + uint64_t maxTimelineSemaphoreValueDifference; +} VkPhysicalDeviceTimelineSemaphoreProperties; + +typedef struct VkSemaphoreTypeCreateInfo { + VkStructureType sType; + const void* pNext; + VkSemaphoreType semaphoreType; + uint64_t initialValue; +} VkSemaphoreTypeCreateInfo; + +typedef struct VkTimelineSemaphoreSubmitInfo { + VkStructureType sType; + const void* pNext; + uint32_t waitSemaphoreValueCount; + const uint64_t* pWaitSemaphoreValues; + uint32_t signalSemaphoreValueCount; + const uint64_t* pSignalSemaphoreValues; +} VkTimelineSemaphoreSubmitInfo; + +typedef struct VkSemaphoreWaitInfo { + VkStructureType sType; + const void* pNext; + VkSemaphoreWaitFlags flags; + uint32_t semaphoreCount; + const VkSemaphore* pSemaphores; + const uint64_t* pValues; +} VkSemaphoreWaitInfo; + +typedef struct VkSemaphoreSignalInfo { + VkStructureType sType; + const void* pNext; + VkSemaphore semaphore; + uint64_t value; +} VkSemaphoreSignalInfo; + +typedef struct VkPhysicalDeviceBufferDeviceAddressFeatures { + VkStructureType sType; + void* pNext; + VkBool32 bufferDeviceAddress; + VkBool32 bufferDeviceAddressCaptureReplay; + VkBool32 bufferDeviceAddressMultiDevice; +} VkPhysicalDeviceBufferDeviceAddressFeatures; + +typedef struct VkBufferDeviceAddressInfo { + VkStructureType sType; + const void* pNext; + VkBuffer buffer; +} VkBufferDeviceAddressInfo; + +typedef struct VkBufferOpaqueCaptureAddressCreateInfo { + VkStructureType sType; + const void* pNext; + uint64_t opaqueCaptureAddress; +} VkBufferOpaqueCaptureAddressCreateInfo; + +typedef struct VkMemoryOpaqueCaptureAddressAllocateInfo { + VkStructureType sType; + const void* pNext; + uint64_t opaqueCaptureAddress; +} VkMemoryOpaqueCaptureAddressAllocateInfo; + +typedef struct VkDeviceMemoryOpaqueCaptureAddressInfo { + VkStructureType sType; + const void* pNext; + VkDeviceMemory memory; +} VkDeviceMemoryOpaqueCaptureAddressInfo; + +typedef void (VKAPI_PTR *PFN_vkCmdDrawIndirectCount)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride); +typedef void (VKAPI_PTR *PFN_vkCmdDrawIndexedIndirectCount)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride); +typedef VkResult (VKAPI_PTR *PFN_vkCreateRenderPass2)(VkDevice device, const VkRenderPassCreateInfo2* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkRenderPass* pRenderPass); +typedef void (VKAPI_PTR *PFN_vkCmdBeginRenderPass2)(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, const VkSubpassBeginInfo* pSubpassBeginInfo); +typedef void (VKAPI_PTR *PFN_vkCmdNextSubpass2)(VkCommandBuffer commandBuffer, const VkSubpassBeginInfo* pSubpassBeginInfo, const VkSubpassEndInfo* pSubpassEndInfo); +typedef void (VKAPI_PTR *PFN_vkCmdEndRenderPass2)(VkCommandBuffer commandBuffer, const VkSubpassEndInfo* pSubpassEndInfo); +typedef void (VKAPI_PTR *PFN_vkResetQueryPool)(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount); +typedef VkResult (VKAPI_PTR *PFN_vkGetSemaphoreCounterValue)(VkDevice device, VkSemaphore semaphore, uint64_t* pValue); +typedef VkResult (VKAPI_PTR *PFN_vkWaitSemaphores)(VkDevice device, const VkSemaphoreWaitInfo* pWaitInfo, uint64_t timeout); +typedef VkResult (VKAPI_PTR *PFN_vkSignalSemaphore)(VkDevice device, const VkSemaphoreSignalInfo* pSignalInfo); +typedef VkDeviceAddress (VKAPI_PTR *PFN_vkGetBufferDeviceAddress)(VkDevice device, const VkBufferDeviceAddressInfo* pInfo); +typedef uint64_t (VKAPI_PTR *PFN_vkGetBufferOpaqueCaptureAddress)(VkDevice device, const VkBufferDeviceAddressInfo* pInfo); +typedef uint64_t (VKAPI_PTR *PFN_vkGetDeviceMemoryOpaqueCaptureAddress)(VkDevice device, const VkDeviceMemoryOpaqueCaptureAddressInfo* pInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirectCount( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset, + VkBuffer countBuffer, + VkDeviceSize countBufferOffset, + uint32_t maxDrawCount, + uint32_t stride); + +VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexedIndirectCount( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset, + VkBuffer countBuffer, + VkDeviceSize countBufferOffset, + uint32_t maxDrawCount, + uint32_t stride); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateRenderPass2( + VkDevice device, + const VkRenderPassCreateInfo2* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkRenderPass* pRenderPass); + +VKAPI_ATTR void VKAPI_CALL vkCmdBeginRenderPass2( + VkCommandBuffer commandBuffer, + const VkRenderPassBeginInfo* pRenderPassBegin, + const VkSubpassBeginInfo* pSubpassBeginInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdNextSubpass2( + VkCommandBuffer commandBuffer, + const VkSubpassBeginInfo* pSubpassBeginInfo, + const VkSubpassEndInfo* pSubpassEndInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdEndRenderPass2( + VkCommandBuffer commandBuffer, + const VkSubpassEndInfo* pSubpassEndInfo); + +VKAPI_ATTR void VKAPI_CALL vkResetQueryPool( + VkDevice device, + VkQueryPool queryPool, + uint32_t firstQuery, + uint32_t queryCount); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreCounterValue( + VkDevice device, + VkSemaphore semaphore, + uint64_t* pValue); + +VKAPI_ATTR VkResult VKAPI_CALL vkWaitSemaphores( + VkDevice device, + const VkSemaphoreWaitInfo* pWaitInfo, + uint64_t timeout); + +VKAPI_ATTR VkResult VKAPI_CALL vkSignalSemaphore( + VkDevice device, + const VkSemaphoreSignalInfo* pSignalInfo); + +VKAPI_ATTR VkDeviceAddress VKAPI_CALL vkGetBufferDeviceAddress( + VkDevice device, + const VkBufferDeviceAddressInfo* pInfo); + +VKAPI_ATTR uint64_t VKAPI_CALL vkGetBufferOpaqueCaptureAddress( + VkDevice device, + const VkBufferDeviceAddressInfo* pInfo); + +VKAPI_ATTR uint64_t VKAPI_CALL vkGetDeviceMemoryOpaqueCaptureAddress( + VkDevice device, + const VkDeviceMemoryOpaqueCaptureAddressInfo* pInfo); +#endif + + +#define VK_KHR_surface 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSurfaceKHR) +#define VK_KHR_SURFACE_SPEC_VERSION 25 +#define VK_KHR_SURFACE_EXTENSION_NAME "VK_KHR_surface" + +typedef enum VkColorSpaceKHR { + VK_COLOR_SPACE_SRGB_NONLINEAR_KHR = 0, + VK_COLOR_SPACE_DISPLAY_P3_NONLINEAR_EXT = 1000104001, + VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT = 1000104002, + VK_COLOR_SPACE_DISPLAY_P3_LINEAR_EXT = 1000104003, + VK_COLOR_SPACE_DCI_P3_NONLINEAR_EXT = 1000104004, + VK_COLOR_SPACE_BT709_LINEAR_EXT = 1000104005, + VK_COLOR_SPACE_BT709_NONLINEAR_EXT = 1000104006, + VK_COLOR_SPACE_BT2020_LINEAR_EXT = 1000104007, + VK_COLOR_SPACE_HDR10_ST2084_EXT = 1000104008, + VK_COLOR_SPACE_DOLBYVISION_EXT = 1000104009, + VK_COLOR_SPACE_HDR10_HLG_EXT = 1000104010, + VK_COLOR_SPACE_ADOBERGB_LINEAR_EXT = 1000104011, + VK_COLOR_SPACE_ADOBERGB_NONLINEAR_EXT = 1000104012, + VK_COLOR_SPACE_PASS_THROUGH_EXT = 1000104013, + VK_COLOR_SPACE_EXTENDED_SRGB_NONLINEAR_EXT = 1000104014, + VK_COLOR_SPACE_DISPLAY_NATIVE_AMD = 1000213000, + VK_COLORSPACE_SRGB_NONLINEAR_KHR = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR, + VK_COLOR_SPACE_DCI_P3_LINEAR_EXT = VK_COLOR_SPACE_DISPLAY_P3_LINEAR_EXT, + VK_COLOR_SPACE_BEGIN_RANGE_KHR = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR, + VK_COLOR_SPACE_END_RANGE_KHR = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR, + VK_COLOR_SPACE_RANGE_SIZE_KHR = (VK_COLOR_SPACE_SRGB_NONLINEAR_KHR - VK_COLOR_SPACE_SRGB_NONLINEAR_KHR + 1), + VK_COLOR_SPACE_MAX_ENUM_KHR = 0x7FFFFFFF +} VkColorSpaceKHR; + +typedef enum VkPresentModeKHR { + VK_PRESENT_MODE_IMMEDIATE_KHR = 0, + VK_PRESENT_MODE_MAILBOX_KHR = 1, + VK_PRESENT_MODE_FIFO_KHR = 2, + VK_PRESENT_MODE_FIFO_RELAXED_KHR = 3, + VK_PRESENT_MODE_SHARED_DEMAND_REFRESH_KHR = 1000111000, + VK_PRESENT_MODE_SHARED_CONTINUOUS_REFRESH_KHR = 1000111001, + VK_PRESENT_MODE_BEGIN_RANGE_KHR = VK_PRESENT_MODE_IMMEDIATE_KHR, + VK_PRESENT_MODE_END_RANGE_KHR = VK_PRESENT_MODE_FIFO_RELAXED_KHR, + VK_PRESENT_MODE_RANGE_SIZE_KHR = (VK_PRESENT_MODE_FIFO_RELAXED_KHR - VK_PRESENT_MODE_IMMEDIATE_KHR + 1), + VK_PRESENT_MODE_MAX_ENUM_KHR = 0x7FFFFFFF +} VkPresentModeKHR; + +typedef enum VkSurfaceTransformFlagBitsKHR { + VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR = 0x00000001, + VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR = 0x00000002, + VK_SURFACE_TRANSFORM_ROTATE_180_BIT_KHR = 0x00000004, + VK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR = 0x00000008, + VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_BIT_KHR = 0x00000010, + VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_90_BIT_KHR = 0x00000020, + VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_180_BIT_KHR = 0x00000040, + VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_270_BIT_KHR = 0x00000080, + VK_SURFACE_TRANSFORM_INHERIT_BIT_KHR = 0x00000100, + VK_SURFACE_TRANSFORM_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkSurfaceTransformFlagBitsKHR; +typedef VkFlags VkSurfaceTransformFlagsKHR; + +typedef enum VkCompositeAlphaFlagBitsKHR { + VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR = 0x00000001, + VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR = 0x00000002, + VK_COMPOSITE_ALPHA_POST_MULTIPLIED_BIT_KHR = 0x00000004, + VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR = 0x00000008, + VK_COMPOSITE_ALPHA_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkCompositeAlphaFlagBitsKHR; +typedef VkFlags VkCompositeAlphaFlagsKHR; +typedef struct VkSurfaceCapabilitiesKHR { + uint32_t minImageCount; + uint32_t maxImageCount; + VkExtent2D currentExtent; + VkExtent2D minImageExtent; + VkExtent2D maxImageExtent; + uint32_t maxImageArrayLayers; + VkSurfaceTransformFlagsKHR supportedTransforms; + VkSurfaceTransformFlagBitsKHR currentTransform; + VkCompositeAlphaFlagsKHR supportedCompositeAlpha; + VkImageUsageFlags supportedUsageFlags; +} VkSurfaceCapabilitiesKHR; + +typedef struct VkSurfaceFormatKHR { + VkFormat format; + VkColorSpaceKHR colorSpace; +} VkSurfaceFormatKHR; + +typedef void (VKAPI_PTR *PFN_vkDestroySurfaceKHR)(VkInstance instance, VkSurfaceKHR surface, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfaceSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, VkSurfaceKHR surface, VkBool32* pSupported); +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR* pSurfaceCapabilities); +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfaceFormatsKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t* pSurfaceFormatCount, VkSurfaceFormatKHR* pSurfaceFormats); +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfacePresentModesKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t* pPresentModeCount, VkPresentModeKHR* pPresentModes); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkDestroySurfaceKHR( + VkInstance instance, + VkSurfaceKHR surface, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceSupportKHR( + VkPhysicalDevice physicalDevice, + uint32_t queueFamilyIndex, + VkSurfaceKHR surface, + VkBool32* pSupported); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilitiesKHR( + VkPhysicalDevice physicalDevice, + VkSurfaceKHR surface, + VkSurfaceCapabilitiesKHR* pSurfaceCapabilities); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormatsKHR( + VkPhysicalDevice physicalDevice, + VkSurfaceKHR surface, + uint32_t* pSurfaceFormatCount, + VkSurfaceFormatKHR* pSurfaceFormats); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModesKHR( + VkPhysicalDevice physicalDevice, + VkSurfaceKHR surface, + uint32_t* pPresentModeCount, + VkPresentModeKHR* pPresentModes); +#endif + + +#define VK_KHR_swapchain 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSwapchainKHR) +#define VK_KHR_SWAPCHAIN_SPEC_VERSION 70 +#define VK_KHR_SWAPCHAIN_EXTENSION_NAME "VK_KHR_swapchain" + +typedef enum VkSwapchainCreateFlagBitsKHR { + VK_SWAPCHAIN_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT_KHR = 0x00000001, + VK_SWAPCHAIN_CREATE_PROTECTED_BIT_KHR = 0x00000002, + VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR = 0x00000004, + VK_SWAPCHAIN_CREATE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkSwapchainCreateFlagBitsKHR; +typedef VkFlags VkSwapchainCreateFlagsKHR; + +typedef enum VkDeviceGroupPresentModeFlagBitsKHR { + VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_BIT_KHR = 0x00000001, + VK_DEVICE_GROUP_PRESENT_MODE_REMOTE_BIT_KHR = 0x00000002, + VK_DEVICE_GROUP_PRESENT_MODE_SUM_BIT_KHR = 0x00000004, + VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_MULTI_DEVICE_BIT_KHR = 0x00000008, + VK_DEVICE_GROUP_PRESENT_MODE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkDeviceGroupPresentModeFlagBitsKHR; +typedef VkFlags VkDeviceGroupPresentModeFlagsKHR; +typedef struct VkSwapchainCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkSwapchainCreateFlagsKHR flags; + VkSurfaceKHR surface; + uint32_t minImageCount; + VkFormat imageFormat; + VkColorSpaceKHR imageColorSpace; + VkExtent2D imageExtent; + uint32_t imageArrayLayers; + VkImageUsageFlags imageUsage; + VkSharingMode imageSharingMode; + uint32_t queueFamilyIndexCount; + const uint32_t* pQueueFamilyIndices; + VkSurfaceTransformFlagBitsKHR preTransform; + VkCompositeAlphaFlagBitsKHR compositeAlpha; + VkPresentModeKHR presentMode; + VkBool32 clipped; + VkSwapchainKHR oldSwapchain; +} VkSwapchainCreateInfoKHR; + +typedef struct VkPresentInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t waitSemaphoreCount; + const VkSemaphore* pWaitSemaphores; + uint32_t swapchainCount; + const VkSwapchainKHR* pSwapchains; + const uint32_t* pImageIndices; + VkResult* pResults; +} VkPresentInfoKHR; + +typedef struct VkImageSwapchainCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkSwapchainKHR swapchain; +} VkImageSwapchainCreateInfoKHR; + +typedef struct VkBindImageMemorySwapchainInfoKHR { + VkStructureType sType; + const void* pNext; + VkSwapchainKHR swapchain; + uint32_t imageIndex; +} VkBindImageMemorySwapchainInfoKHR; + +typedef struct VkAcquireNextImageInfoKHR { + VkStructureType sType; + const void* pNext; + VkSwapchainKHR swapchain; + uint64_t timeout; + VkSemaphore semaphore; + VkFence fence; + uint32_t deviceMask; +} VkAcquireNextImageInfoKHR; + +typedef struct VkDeviceGroupPresentCapabilitiesKHR { + VkStructureType sType; + const void* pNext; + uint32_t presentMask[VK_MAX_DEVICE_GROUP_SIZE]; + VkDeviceGroupPresentModeFlagsKHR modes; +} VkDeviceGroupPresentCapabilitiesKHR; + +typedef struct VkDeviceGroupPresentInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t swapchainCount; + const uint32_t* pDeviceMasks; + VkDeviceGroupPresentModeFlagBitsKHR mode; +} VkDeviceGroupPresentInfoKHR; + +typedef struct VkDeviceGroupSwapchainCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkDeviceGroupPresentModeFlagsKHR modes; +} VkDeviceGroupSwapchainCreateInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateSwapchainKHR)(VkDevice device, const VkSwapchainCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSwapchainKHR* pSwapchain); +typedef void (VKAPI_PTR *PFN_vkDestroySwapchainKHR)(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainImagesKHR)(VkDevice device, VkSwapchainKHR swapchain, uint32_t* pSwapchainImageCount, VkImage* pSwapchainImages); +typedef VkResult (VKAPI_PTR *PFN_vkAcquireNextImageKHR)(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, VkSemaphore semaphore, VkFence fence, uint32_t* pImageIndex); +typedef VkResult (VKAPI_PTR *PFN_vkQueuePresentKHR)(VkQueue queue, const VkPresentInfoKHR* pPresentInfo); +typedef VkResult (VKAPI_PTR *PFN_vkGetDeviceGroupPresentCapabilitiesKHR)(VkDevice device, VkDeviceGroupPresentCapabilitiesKHR* pDeviceGroupPresentCapabilities); +typedef VkResult (VKAPI_PTR *PFN_vkGetDeviceGroupSurfacePresentModesKHR)(VkDevice device, VkSurfaceKHR surface, VkDeviceGroupPresentModeFlagsKHR* pModes); +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDevicePresentRectanglesKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t* pRectCount, VkRect2D* pRects); +typedef VkResult (VKAPI_PTR *PFN_vkAcquireNextImage2KHR)(VkDevice device, const VkAcquireNextImageInfoKHR* pAcquireInfo, uint32_t* pImageIndex); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR( + VkDevice device, + const VkSwapchainCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSwapchainKHR* pSwapchain); + +VKAPI_ATTR void VKAPI_CALL vkDestroySwapchainKHR( + VkDevice device, + VkSwapchainKHR swapchain, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR( + VkDevice device, + VkSwapchainKHR swapchain, + uint32_t* pSwapchainImageCount, + VkImage* pSwapchainImages); + +VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImageKHR( + VkDevice device, + VkSwapchainKHR swapchain, + uint64_t timeout, + VkSemaphore semaphore, + VkFence fence, + uint32_t* pImageIndex); + +VKAPI_ATTR VkResult VKAPI_CALL vkQueuePresentKHR( + VkQueue queue, + const VkPresentInfoKHR* pPresentInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupPresentCapabilitiesKHR( + VkDevice device, + VkDeviceGroupPresentCapabilitiesKHR* pDeviceGroupPresentCapabilities); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupSurfacePresentModesKHR( + VkDevice device, + VkSurfaceKHR surface, + VkDeviceGroupPresentModeFlagsKHR* pModes); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDevicePresentRectanglesKHR( + VkPhysicalDevice physicalDevice, + VkSurfaceKHR surface, + uint32_t* pRectCount, + VkRect2D* pRects); + +VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImage2KHR( + VkDevice device, + const VkAcquireNextImageInfoKHR* pAcquireInfo, + uint32_t* pImageIndex); +#endif + + +#define VK_KHR_display 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDisplayKHR) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDisplayModeKHR) +#define VK_KHR_DISPLAY_SPEC_VERSION 23 +#define VK_KHR_DISPLAY_EXTENSION_NAME "VK_KHR_display" + +typedef enum VkDisplayPlaneAlphaFlagBitsKHR { + VK_DISPLAY_PLANE_ALPHA_OPAQUE_BIT_KHR = 0x00000001, + VK_DISPLAY_PLANE_ALPHA_GLOBAL_BIT_KHR = 0x00000002, + VK_DISPLAY_PLANE_ALPHA_PER_PIXEL_BIT_KHR = 0x00000004, + VK_DISPLAY_PLANE_ALPHA_PER_PIXEL_PREMULTIPLIED_BIT_KHR = 0x00000008, + VK_DISPLAY_PLANE_ALPHA_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkDisplayPlaneAlphaFlagBitsKHR; +typedef VkFlags VkDisplayPlaneAlphaFlagsKHR; +typedef VkFlags VkDisplayModeCreateFlagsKHR; +typedef VkFlags VkDisplaySurfaceCreateFlagsKHR; +typedef struct VkDisplayPropertiesKHR { + VkDisplayKHR display; + const char* displayName; + VkExtent2D physicalDimensions; + VkExtent2D physicalResolution; + VkSurfaceTransformFlagsKHR supportedTransforms; + VkBool32 planeReorderPossible; + VkBool32 persistentContent; +} VkDisplayPropertiesKHR; + +typedef struct VkDisplayModeParametersKHR { + VkExtent2D visibleRegion; + uint32_t refreshRate; +} VkDisplayModeParametersKHR; + +typedef struct VkDisplayModePropertiesKHR { + VkDisplayModeKHR displayMode; + VkDisplayModeParametersKHR parameters; +} VkDisplayModePropertiesKHR; + +typedef struct VkDisplayModeCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkDisplayModeCreateFlagsKHR flags; + VkDisplayModeParametersKHR parameters; +} VkDisplayModeCreateInfoKHR; + +typedef struct VkDisplayPlaneCapabilitiesKHR { + VkDisplayPlaneAlphaFlagsKHR supportedAlpha; + VkOffset2D minSrcPosition; + VkOffset2D maxSrcPosition; + VkExtent2D minSrcExtent; + VkExtent2D maxSrcExtent; + VkOffset2D minDstPosition; + VkOffset2D maxDstPosition; + VkExtent2D minDstExtent; + VkExtent2D maxDstExtent; +} VkDisplayPlaneCapabilitiesKHR; + +typedef struct VkDisplayPlanePropertiesKHR { + VkDisplayKHR currentDisplay; + uint32_t currentStackIndex; +} VkDisplayPlanePropertiesKHR; + +typedef struct VkDisplaySurfaceCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkDisplaySurfaceCreateFlagsKHR flags; + VkDisplayModeKHR displayMode; + uint32_t planeIndex; + uint32_t planeStackIndex; + VkSurfaceTransformFlagBitsKHR transform; + float globalAlpha; + VkDisplayPlaneAlphaFlagBitsKHR alphaMode; + VkExtent2D imageExtent; +} VkDisplaySurfaceCreateInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceDisplayPropertiesKHR)(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkDisplayPropertiesKHR* pProperties); +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR)(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkDisplayPlanePropertiesKHR* pProperties); +typedef VkResult (VKAPI_PTR *PFN_vkGetDisplayPlaneSupportedDisplaysKHR)(VkPhysicalDevice physicalDevice, uint32_t planeIndex, uint32_t* pDisplayCount, VkDisplayKHR* pDisplays); +typedef VkResult (VKAPI_PTR *PFN_vkGetDisplayModePropertiesKHR)(VkPhysicalDevice physicalDevice, VkDisplayKHR display, uint32_t* pPropertyCount, VkDisplayModePropertiesKHR* pProperties); +typedef VkResult (VKAPI_PTR *PFN_vkCreateDisplayModeKHR)(VkPhysicalDevice physicalDevice, VkDisplayKHR display, const VkDisplayModeCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDisplayModeKHR* pMode); +typedef VkResult (VKAPI_PTR *PFN_vkGetDisplayPlaneCapabilitiesKHR)(VkPhysicalDevice physicalDevice, VkDisplayModeKHR mode, uint32_t planeIndex, VkDisplayPlaneCapabilitiesKHR* pCapabilities); +typedef VkResult (VKAPI_PTR *PFN_vkCreateDisplayPlaneSurfaceKHR)(VkInstance instance, const VkDisplaySurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceDisplayPropertiesKHR( + VkPhysicalDevice physicalDevice, + uint32_t* pPropertyCount, + VkDisplayPropertiesKHR* pProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceDisplayPlanePropertiesKHR( + VkPhysicalDevice physicalDevice, + uint32_t* pPropertyCount, + VkDisplayPlanePropertiesKHR* pProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayPlaneSupportedDisplaysKHR( + VkPhysicalDevice physicalDevice, + uint32_t planeIndex, + uint32_t* pDisplayCount, + VkDisplayKHR* pDisplays); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayModePropertiesKHR( + VkPhysicalDevice physicalDevice, + VkDisplayKHR display, + uint32_t* pPropertyCount, + VkDisplayModePropertiesKHR* pProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayModeKHR( + VkPhysicalDevice physicalDevice, + VkDisplayKHR display, + const VkDisplayModeCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkDisplayModeKHR* pMode); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayPlaneCapabilitiesKHR( + VkPhysicalDevice physicalDevice, + VkDisplayModeKHR mode, + uint32_t planeIndex, + VkDisplayPlaneCapabilitiesKHR* pCapabilities); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayPlaneSurfaceKHR( + VkInstance instance, + const VkDisplaySurfaceCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); +#endif + + +#define VK_KHR_display_swapchain 1 +#define VK_KHR_DISPLAY_SWAPCHAIN_SPEC_VERSION 10 +#define VK_KHR_DISPLAY_SWAPCHAIN_EXTENSION_NAME "VK_KHR_display_swapchain" +typedef struct VkDisplayPresentInfoKHR { + VkStructureType sType; + const void* pNext; + VkRect2D srcRect; + VkRect2D dstRect; + VkBool32 persistent; +} VkDisplayPresentInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateSharedSwapchainsKHR)(VkDevice device, uint32_t swapchainCount, const VkSwapchainCreateInfoKHR* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkSwapchainKHR* pSwapchains); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateSharedSwapchainsKHR( + VkDevice device, + uint32_t swapchainCount, + const VkSwapchainCreateInfoKHR* pCreateInfos, + const VkAllocationCallbacks* pAllocator, + VkSwapchainKHR* pSwapchains); +#endif + + +#define VK_KHR_sampler_mirror_clamp_to_edge 1 +#define VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_SPEC_VERSION 3 +#define VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME "VK_KHR_sampler_mirror_clamp_to_edge" + + +#define VK_KHR_multiview 1 +#define VK_KHR_MULTIVIEW_SPEC_VERSION 1 +#define VK_KHR_MULTIVIEW_EXTENSION_NAME "VK_KHR_multiview" +typedef VkRenderPassMultiviewCreateInfo VkRenderPassMultiviewCreateInfoKHR; + +typedef VkPhysicalDeviceMultiviewFeatures VkPhysicalDeviceMultiviewFeaturesKHR; + +typedef VkPhysicalDeviceMultiviewProperties VkPhysicalDeviceMultiviewPropertiesKHR; + + + +#define VK_KHR_get_physical_device_properties2 1 +#define VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_SPEC_VERSION 2 +#define VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME "VK_KHR_get_physical_device_properties2" +typedef VkPhysicalDeviceFeatures2 VkPhysicalDeviceFeatures2KHR; + +typedef VkPhysicalDeviceProperties2 VkPhysicalDeviceProperties2KHR; + +typedef VkFormatProperties2 VkFormatProperties2KHR; + +typedef VkImageFormatProperties2 VkImageFormatProperties2KHR; + +typedef VkPhysicalDeviceImageFormatInfo2 VkPhysicalDeviceImageFormatInfo2KHR; + +typedef VkQueueFamilyProperties2 VkQueueFamilyProperties2KHR; + +typedef VkPhysicalDeviceMemoryProperties2 VkPhysicalDeviceMemoryProperties2KHR; + +typedef VkSparseImageFormatProperties2 VkSparseImageFormatProperties2KHR; + +typedef VkPhysicalDeviceSparseImageFormatInfo2 VkPhysicalDeviceSparseImageFormatInfo2KHR; + +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceFeatures2KHR)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures2* pFeatures); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceProperties2KHR)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties2* pProperties); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceFormatProperties2KHR)(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties2* pFormatProperties); +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceImageFormatProperties2KHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2* pImageFormatInfo, VkImageFormatProperties2* pImageFormatProperties); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceQueueFamilyProperties2KHR)(VkPhysicalDevice physicalDevice, uint32_t* pQueueFamilyPropertyCount, VkQueueFamilyProperties2* pQueueFamilyProperties); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceMemoryProperties2KHR)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties2* pMemoryProperties); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceSparseImageFormatProperties2KHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSparseImageFormatInfo2* pFormatInfo, uint32_t* pPropertyCount, VkSparseImageFormatProperties2* pProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures2KHR( + VkPhysicalDevice physicalDevice, + VkPhysicalDeviceFeatures2* pFeatures); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties2KHR( + VkPhysicalDevice physicalDevice, + VkPhysicalDeviceProperties2* pProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties2KHR( + VkPhysicalDevice physicalDevice, + VkFormat format, + VkFormatProperties2* pFormatProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties2KHR( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceImageFormatInfo2* pImageFormatInfo, + VkImageFormatProperties2* pImageFormatProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties2KHR( + VkPhysicalDevice physicalDevice, + uint32_t* pQueueFamilyPropertyCount, + VkQueueFamilyProperties2* pQueueFamilyProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties2KHR( + VkPhysicalDevice physicalDevice, + VkPhysicalDeviceMemoryProperties2* pMemoryProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceSparseImageFormatProperties2KHR( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceSparseImageFormatInfo2* pFormatInfo, + uint32_t* pPropertyCount, + VkSparseImageFormatProperties2* pProperties); +#endif + + +#define VK_KHR_device_group 1 +#define VK_KHR_DEVICE_GROUP_SPEC_VERSION 4 +#define VK_KHR_DEVICE_GROUP_EXTENSION_NAME "VK_KHR_device_group" +typedef VkPeerMemoryFeatureFlags VkPeerMemoryFeatureFlagsKHR; + +typedef VkPeerMemoryFeatureFlagBits VkPeerMemoryFeatureFlagBitsKHR; + +typedef VkMemoryAllocateFlags VkMemoryAllocateFlagsKHR; + +typedef VkMemoryAllocateFlagBits VkMemoryAllocateFlagBitsKHR; + +typedef VkMemoryAllocateFlagsInfo VkMemoryAllocateFlagsInfoKHR; + +typedef VkDeviceGroupRenderPassBeginInfo VkDeviceGroupRenderPassBeginInfoKHR; + +typedef VkDeviceGroupCommandBufferBeginInfo VkDeviceGroupCommandBufferBeginInfoKHR; + +typedef VkDeviceGroupSubmitInfo VkDeviceGroupSubmitInfoKHR; + +typedef VkDeviceGroupBindSparseInfo VkDeviceGroupBindSparseInfoKHR; + +typedef VkBindBufferMemoryDeviceGroupInfo VkBindBufferMemoryDeviceGroupInfoKHR; + +typedef VkBindImageMemoryDeviceGroupInfo VkBindImageMemoryDeviceGroupInfoKHR; + +typedef void (VKAPI_PTR *PFN_vkGetDeviceGroupPeerMemoryFeaturesKHR)(VkDevice device, uint32_t heapIndex, uint32_t localDeviceIndex, uint32_t remoteDeviceIndex, VkPeerMemoryFeatureFlags* pPeerMemoryFeatures); +typedef void (VKAPI_PTR *PFN_vkCmdSetDeviceMaskKHR)(VkCommandBuffer commandBuffer, uint32_t deviceMask); +typedef void (VKAPI_PTR *PFN_vkCmdDispatchBaseKHR)(VkCommandBuffer commandBuffer, uint32_t baseGroupX, uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkGetDeviceGroupPeerMemoryFeaturesKHR( + VkDevice device, + uint32_t heapIndex, + uint32_t localDeviceIndex, + uint32_t remoteDeviceIndex, + VkPeerMemoryFeatureFlags* pPeerMemoryFeatures); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDeviceMaskKHR( + VkCommandBuffer commandBuffer, + uint32_t deviceMask); + +VKAPI_ATTR void VKAPI_CALL vkCmdDispatchBaseKHR( + VkCommandBuffer commandBuffer, + uint32_t baseGroupX, + uint32_t baseGroupY, + uint32_t baseGroupZ, + uint32_t groupCountX, + uint32_t groupCountY, + uint32_t groupCountZ); +#endif + + +#define VK_KHR_shader_draw_parameters 1 +#define VK_KHR_SHADER_DRAW_PARAMETERS_SPEC_VERSION 1 +#define VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME "VK_KHR_shader_draw_parameters" + + +#define VK_KHR_maintenance1 1 +#define VK_KHR_MAINTENANCE1_SPEC_VERSION 2 +#define VK_KHR_MAINTENANCE1_EXTENSION_NAME "VK_KHR_maintenance1" +typedef VkCommandPoolTrimFlags VkCommandPoolTrimFlagsKHR; + +typedef void (VKAPI_PTR *PFN_vkTrimCommandPoolKHR)(VkDevice device, VkCommandPool commandPool, VkCommandPoolTrimFlags flags); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkTrimCommandPoolKHR( + VkDevice device, + VkCommandPool commandPool, + VkCommandPoolTrimFlags flags); +#endif + + +#define VK_KHR_device_group_creation 1 +#define VK_KHR_DEVICE_GROUP_CREATION_SPEC_VERSION 1 +#define VK_KHR_DEVICE_GROUP_CREATION_EXTENSION_NAME "VK_KHR_device_group_creation" +#define VK_MAX_DEVICE_GROUP_SIZE_KHR VK_MAX_DEVICE_GROUP_SIZE +typedef VkPhysicalDeviceGroupProperties VkPhysicalDeviceGroupPropertiesKHR; + +typedef VkDeviceGroupDeviceCreateInfo VkDeviceGroupDeviceCreateInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkEnumeratePhysicalDeviceGroupsKHR)(VkInstance instance, uint32_t* pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDeviceGroupsKHR( + VkInstance instance, + uint32_t* pPhysicalDeviceGroupCount, + VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties); +#endif + + +#define VK_KHR_external_memory_capabilities 1 +#define VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_SPEC_VERSION 1 +#define VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME "VK_KHR_external_memory_capabilities" +#define VK_LUID_SIZE_KHR VK_LUID_SIZE +typedef VkExternalMemoryHandleTypeFlags VkExternalMemoryHandleTypeFlagsKHR; + +typedef VkExternalMemoryHandleTypeFlagBits VkExternalMemoryHandleTypeFlagBitsKHR; + +typedef VkExternalMemoryFeatureFlags VkExternalMemoryFeatureFlagsKHR; + +typedef VkExternalMemoryFeatureFlagBits VkExternalMemoryFeatureFlagBitsKHR; + +typedef VkExternalMemoryProperties VkExternalMemoryPropertiesKHR; + +typedef VkPhysicalDeviceExternalImageFormatInfo VkPhysicalDeviceExternalImageFormatInfoKHR; + +typedef VkExternalImageFormatProperties VkExternalImageFormatPropertiesKHR; + +typedef VkPhysicalDeviceExternalBufferInfo VkPhysicalDeviceExternalBufferInfoKHR; + +typedef VkExternalBufferProperties VkExternalBufferPropertiesKHR; + +typedef VkPhysicalDeviceIDProperties VkPhysicalDeviceIDPropertiesKHR; + +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceExternalBufferPropertiesKHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo, VkExternalBufferProperties* pExternalBufferProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalBufferPropertiesKHR( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo, + VkExternalBufferProperties* pExternalBufferProperties); +#endif + + +#define VK_KHR_external_memory 1 +#define VK_KHR_EXTERNAL_MEMORY_SPEC_VERSION 1 +#define VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME "VK_KHR_external_memory" +#define VK_QUEUE_FAMILY_EXTERNAL_KHR VK_QUEUE_FAMILY_EXTERNAL +typedef VkExternalMemoryImageCreateInfo VkExternalMemoryImageCreateInfoKHR; + +typedef VkExternalMemoryBufferCreateInfo VkExternalMemoryBufferCreateInfoKHR; + +typedef VkExportMemoryAllocateInfo VkExportMemoryAllocateInfoKHR; + + + +#define VK_KHR_external_memory_fd 1 +#define VK_KHR_EXTERNAL_MEMORY_FD_SPEC_VERSION 1 +#define VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME "VK_KHR_external_memory_fd" +typedef struct VkImportMemoryFdInfoKHR { + VkStructureType sType; + const void* pNext; + VkExternalMemoryHandleTypeFlagBits handleType; + int fd; +} VkImportMemoryFdInfoKHR; + +typedef struct VkMemoryFdPropertiesKHR { + VkStructureType sType; + void* pNext; + uint32_t memoryTypeBits; +} VkMemoryFdPropertiesKHR; + +typedef struct VkMemoryGetFdInfoKHR { + VkStructureType sType; + const void* pNext; + VkDeviceMemory memory; + VkExternalMemoryHandleTypeFlagBits handleType; +} VkMemoryGetFdInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryFdKHR)(VkDevice device, const VkMemoryGetFdInfoKHR* pGetFdInfo, int* pFd); +typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryFdPropertiesKHR)(VkDevice device, VkExternalMemoryHandleTypeFlagBits handleType, int fd, VkMemoryFdPropertiesKHR* pMemoryFdProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryFdKHR( + VkDevice device, + const VkMemoryGetFdInfoKHR* pGetFdInfo, + int* pFd); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryFdPropertiesKHR( + VkDevice device, + VkExternalMemoryHandleTypeFlagBits handleType, + int fd, + VkMemoryFdPropertiesKHR* pMemoryFdProperties); +#endif + + +#define VK_KHR_external_semaphore_capabilities 1 +#define VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_SPEC_VERSION 1 +#define VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME "VK_KHR_external_semaphore_capabilities" +typedef VkExternalSemaphoreHandleTypeFlags VkExternalSemaphoreHandleTypeFlagsKHR; + +typedef VkExternalSemaphoreHandleTypeFlagBits VkExternalSemaphoreHandleTypeFlagBitsKHR; + +typedef VkExternalSemaphoreFeatureFlags VkExternalSemaphoreFeatureFlagsKHR; + +typedef VkExternalSemaphoreFeatureFlagBits VkExternalSemaphoreFeatureFlagBitsKHR; + +typedef VkPhysicalDeviceExternalSemaphoreInfo VkPhysicalDeviceExternalSemaphoreInfoKHR; + +typedef VkExternalSemaphoreProperties VkExternalSemaphorePropertiesKHR; + +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceExternalSemaphorePropertiesKHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo, VkExternalSemaphoreProperties* pExternalSemaphoreProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalSemaphorePropertiesKHR( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo, + VkExternalSemaphoreProperties* pExternalSemaphoreProperties); +#endif + + +#define VK_KHR_external_semaphore 1 +#define VK_KHR_EXTERNAL_SEMAPHORE_SPEC_VERSION 1 +#define VK_KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME "VK_KHR_external_semaphore" +typedef VkSemaphoreImportFlags VkSemaphoreImportFlagsKHR; + +typedef VkSemaphoreImportFlagBits VkSemaphoreImportFlagBitsKHR; + +typedef VkExportSemaphoreCreateInfo VkExportSemaphoreCreateInfoKHR; + + + +#define VK_KHR_external_semaphore_fd 1 +#define VK_KHR_EXTERNAL_SEMAPHORE_FD_SPEC_VERSION 1 +#define VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME "VK_KHR_external_semaphore_fd" +typedef struct VkImportSemaphoreFdInfoKHR { + VkStructureType sType; + const void* pNext; + VkSemaphore semaphore; + VkSemaphoreImportFlags flags; + VkExternalSemaphoreHandleTypeFlagBits handleType; + int fd; +} VkImportSemaphoreFdInfoKHR; + +typedef struct VkSemaphoreGetFdInfoKHR { + VkStructureType sType; + const void* pNext; + VkSemaphore semaphore; + VkExternalSemaphoreHandleTypeFlagBits handleType; +} VkSemaphoreGetFdInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkImportSemaphoreFdKHR)(VkDevice device, const VkImportSemaphoreFdInfoKHR* pImportSemaphoreFdInfo); +typedef VkResult (VKAPI_PTR *PFN_vkGetSemaphoreFdKHR)(VkDevice device, const VkSemaphoreGetFdInfoKHR* pGetFdInfo, int* pFd); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkImportSemaphoreFdKHR( + VkDevice device, + const VkImportSemaphoreFdInfoKHR* pImportSemaphoreFdInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreFdKHR( + VkDevice device, + const VkSemaphoreGetFdInfoKHR* pGetFdInfo, + int* pFd); +#endif + + +#define VK_KHR_push_descriptor 1 +#define VK_KHR_PUSH_DESCRIPTOR_SPEC_VERSION 2 +#define VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME "VK_KHR_push_descriptor" +typedef struct VkPhysicalDevicePushDescriptorPropertiesKHR { + VkStructureType sType; + void* pNext; + uint32_t maxPushDescriptors; +} VkPhysicalDevicePushDescriptorPropertiesKHR; + +typedef void (VKAPI_PTR *PFN_vkCmdPushDescriptorSetKHR)(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t set, uint32_t descriptorWriteCount, const VkWriteDescriptorSet* pDescriptorWrites); +typedef void (VKAPI_PTR *PFN_vkCmdPushDescriptorSetWithTemplateKHR)(VkCommandBuffer commandBuffer, VkDescriptorUpdateTemplate descriptorUpdateTemplate, VkPipelineLayout layout, uint32_t set, const void* pData); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdPushDescriptorSetKHR( + VkCommandBuffer commandBuffer, + VkPipelineBindPoint pipelineBindPoint, + VkPipelineLayout layout, + uint32_t set, + uint32_t descriptorWriteCount, + const VkWriteDescriptorSet* pDescriptorWrites); + +VKAPI_ATTR void VKAPI_CALL vkCmdPushDescriptorSetWithTemplateKHR( + VkCommandBuffer commandBuffer, + VkDescriptorUpdateTemplate descriptorUpdateTemplate, + VkPipelineLayout layout, + uint32_t set, + const void* pData); +#endif + + +#define VK_KHR_shader_float16_int8 1 +#define VK_KHR_SHADER_FLOAT16_INT8_SPEC_VERSION 1 +#define VK_KHR_SHADER_FLOAT16_INT8_EXTENSION_NAME "VK_KHR_shader_float16_int8" +typedef VkPhysicalDeviceShaderFloat16Int8Features VkPhysicalDeviceShaderFloat16Int8FeaturesKHR; + +typedef VkPhysicalDeviceShaderFloat16Int8Features VkPhysicalDeviceFloat16Int8FeaturesKHR; + + + +#define VK_KHR_16bit_storage 1 +#define VK_KHR_16BIT_STORAGE_SPEC_VERSION 1 +#define VK_KHR_16BIT_STORAGE_EXTENSION_NAME "VK_KHR_16bit_storage" +typedef VkPhysicalDevice16BitStorageFeatures VkPhysicalDevice16BitStorageFeaturesKHR; + + + +#define VK_KHR_incremental_present 1 +#define VK_KHR_INCREMENTAL_PRESENT_SPEC_VERSION 1 +#define VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME "VK_KHR_incremental_present" +typedef struct VkRectLayerKHR { + VkOffset2D offset; + VkExtent2D extent; + uint32_t layer; +} VkRectLayerKHR; + +typedef struct VkPresentRegionKHR { + uint32_t rectangleCount; + const VkRectLayerKHR* pRectangles; +} VkPresentRegionKHR; + +typedef struct VkPresentRegionsKHR { + VkStructureType sType; + const void* pNext; + uint32_t swapchainCount; + const VkPresentRegionKHR* pRegions; +} VkPresentRegionsKHR; + + + +#define VK_KHR_descriptor_update_template 1 +typedef VkDescriptorUpdateTemplate VkDescriptorUpdateTemplateKHR; + +#define VK_KHR_DESCRIPTOR_UPDATE_TEMPLATE_SPEC_VERSION 1 +#define VK_KHR_DESCRIPTOR_UPDATE_TEMPLATE_EXTENSION_NAME "VK_KHR_descriptor_update_template" +typedef VkDescriptorUpdateTemplateType VkDescriptorUpdateTemplateTypeKHR; + +typedef VkDescriptorUpdateTemplateCreateFlags VkDescriptorUpdateTemplateCreateFlagsKHR; + +typedef VkDescriptorUpdateTemplateEntry VkDescriptorUpdateTemplateEntryKHR; + +typedef VkDescriptorUpdateTemplateCreateInfo VkDescriptorUpdateTemplateCreateInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateDescriptorUpdateTemplateKHR)(VkDevice device, const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDescriptorUpdateTemplate* pDescriptorUpdateTemplate); +typedef void (VKAPI_PTR *PFN_vkDestroyDescriptorUpdateTemplateKHR)(VkDevice device, VkDescriptorUpdateTemplate descriptorUpdateTemplate, const VkAllocationCallbacks* pAllocator); +typedef void (VKAPI_PTR *PFN_vkUpdateDescriptorSetWithTemplateKHR)(VkDevice device, VkDescriptorSet descriptorSet, VkDescriptorUpdateTemplate descriptorUpdateTemplate, const void* pData); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorUpdateTemplateKHR( + VkDevice device, + const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkDescriptorUpdateTemplate* pDescriptorUpdateTemplate); + +VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorUpdateTemplateKHR( + VkDevice device, + VkDescriptorUpdateTemplate descriptorUpdateTemplate, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR void VKAPI_CALL vkUpdateDescriptorSetWithTemplateKHR( + VkDevice device, + VkDescriptorSet descriptorSet, + VkDescriptorUpdateTemplate descriptorUpdateTemplate, + const void* pData); +#endif + + +#define VK_KHR_imageless_framebuffer 1 +#define VK_KHR_IMAGELESS_FRAMEBUFFER_SPEC_VERSION 1 +#define VK_KHR_IMAGELESS_FRAMEBUFFER_EXTENSION_NAME "VK_KHR_imageless_framebuffer" +typedef VkPhysicalDeviceImagelessFramebufferFeatures VkPhysicalDeviceImagelessFramebufferFeaturesKHR; + +typedef VkFramebufferAttachmentsCreateInfo VkFramebufferAttachmentsCreateInfoKHR; + +typedef VkFramebufferAttachmentImageInfo VkFramebufferAttachmentImageInfoKHR; + +typedef VkRenderPassAttachmentBeginInfo VkRenderPassAttachmentBeginInfoKHR; + + + +#define VK_KHR_create_renderpass2 1 +#define VK_KHR_CREATE_RENDERPASS_2_SPEC_VERSION 1 +#define VK_KHR_CREATE_RENDERPASS_2_EXTENSION_NAME "VK_KHR_create_renderpass2" +typedef VkRenderPassCreateInfo2 VkRenderPassCreateInfo2KHR; + +typedef VkAttachmentDescription2 VkAttachmentDescription2KHR; + +typedef VkAttachmentReference2 VkAttachmentReference2KHR; + +typedef VkSubpassDescription2 VkSubpassDescription2KHR; + +typedef VkSubpassDependency2 VkSubpassDependency2KHR; + +typedef VkSubpassBeginInfo VkSubpassBeginInfoKHR; + +typedef VkSubpassEndInfo VkSubpassEndInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateRenderPass2KHR)(VkDevice device, const VkRenderPassCreateInfo2* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkRenderPass* pRenderPass); +typedef void (VKAPI_PTR *PFN_vkCmdBeginRenderPass2KHR)(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, const VkSubpassBeginInfo* pSubpassBeginInfo); +typedef void (VKAPI_PTR *PFN_vkCmdNextSubpass2KHR)(VkCommandBuffer commandBuffer, const VkSubpassBeginInfo* pSubpassBeginInfo, const VkSubpassEndInfo* pSubpassEndInfo); +typedef void (VKAPI_PTR *PFN_vkCmdEndRenderPass2KHR)(VkCommandBuffer commandBuffer, const VkSubpassEndInfo* pSubpassEndInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateRenderPass2KHR( + VkDevice device, + const VkRenderPassCreateInfo2* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkRenderPass* pRenderPass); + +VKAPI_ATTR void VKAPI_CALL vkCmdBeginRenderPass2KHR( + VkCommandBuffer commandBuffer, + const VkRenderPassBeginInfo* pRenderPassBegin, + const VkSubpassBeginInfo* pSubpassBeginInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdNextSubpass2KHR( + VkCommandBuffer commandBuffer, + const VkSubpassBeginInfo* pSubpassBeginInfo, + const VkSubpassEndInfo* pSubpassEndInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdEndRenderPass2KHR( + VkCommandBuffer commandBuffer, + const VkSubpassEndInfo* pSubpassEndInfo); +#endif + + +#define VK_KHR_shared_presentable_image 1 +#define VK_KHR_SHARED_PRESENTABLE_IMAGE_SPEC_VERSION 1 +#define VK_KHR_SHARED_PRESENTABLE_IMAGE_EXTENSION_NAME "VK_KHR_shared_presentable_image" +typedef struct VkSharedPresentSurfaceCapabilitiesKHR { + VkStructureType sType; + void* pNext; + VkImageUsageFlags sharedPresentSupportedUsageFlags; +} VkSharedPresentSurfaceCapabilitiesKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainStatusKHR)(VkDevice device, VkSwapchainKHR swapchain); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainStatusKHR( + VkDevice device, + VkSwapchainKHR swapchain); +#endif + + +#define VK_KHR_external_fence_capabilities 1 +#define VK_KHR_EXTERNAL_FENCE_CAPABILITIES_SPEC_VERSION 1 +#define VK_KHR_EXTERNAL_FENCE_CAPABILITIES_EXTENSION_NAME "VK_KHR_external_fence_capabilities" +typedef VkExternalFenceHandleTypeFlags VkExternalFenceHandleTypeFlagsKHR; + +typedef VkExternalFenceHandleTypeFlagBits VkExternalFenceHandleTypeFlagBitsKHR; + +typedef VkExternalFenceFeatureFlags VkExternalFenceFeatureFlagsKHR; + +typedef VkExternalFenceFeatureFlagBits VkExternalFenceFeatureFlagBitsKHR; + +typedef VkPhysicalDeviceExternalFenceInfo VkPhysicalDeviceExternalFenceInfoKHR; + +typedef VkExternalFenceProperties VkExternalFencePropertiesKHR; + +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceExternalFencePropertiesKHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalFenceInfo* pExternalFenceInfo, VkExternalFenceProperties* pExternalFenceProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalFencePropertiesKHR( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceExternalFenceInfo* pExternalFenceInfo, + VkExternalFenceProperties* pExternalFenceProperties); +#endif + + +#define VK_KHR_external_fence 1 +#define VK_KHR_EXTERNAL_FENCE_SPEC_VERSION 1 +#define VK_KHR_EXTERNAL_FENCE_EXTENSION_NAME "VK_KHR_external_fence" +typedef VkFenceImportFlags VkFenceImportFlagsKHR; + +typedef VkFenceImportFlagBits VkFenceImportFlagBitsKHR; + +typedef VkExportFenceCreateInfo VkExportFenceCreateInfoKHR; + + + +#define VK_KHR_external_fence_fd 1 +#define VK_KHR_EXTERNAL_FENCE_FD_SPEC_VERSION 1 +#define VK_KHR_EXTERNAL_FENCE_FD_EXTENSION_NAME "VK_KHR_external_fence_fd" +typedef struct VkImportFenceFdInfoKHR { + VkStructureType sType; + const void* pNext; + VkFence fence; + VkFenceImportFlags flags; + VkExternalFenceHandleTypeFlagBits handleType; + int fd; +} VkImportFenceFdInfoKHR; + +typedef struct VkFenceGetFdInfoKHR { + VkStructureType sType; + const void* pNext; + VkFence fence; + VkExternalFenceHandleTypeFlagBits handleType; +} VkFenceGetFdInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkImportFenceFdKHR)(VkDevice device, const VkImportFenceFdInfoKHR* pImportFenceFdInfo); +typedef VkResult (VKAPI_PTR *PFN_vkGetFenceFdKHR)(VkDevice device, const VkFenceGetFdInfoKHR* pGetFdInfo, int* pFd); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkImportFenceFdKHR( + VkDevice device, + const VkImportFenceFdInfoKHR* pImportFenceFdInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetFenceFdKHR( + VkDevice device, + const VkFenceGetFdInfoKHR* pGetFdInfo, + int* pFd); +#endif + + +#define VK_KHR_performance_query 1 +#define VK_KHR_PERFORMANCE_QUERY_SPEC_VERSION 1 +#define VK_KHR_PERFORMANCE_QUERY_EXTENSION_NAME "VK_KHR_performance_query" + +typedef enum VkPerformanceCounterUnitKHR { + VK_PERFORMANCE_COUNTER_UNIT_GENERIC_KHR = 0, + VK_PERFORMANCE_COUNTER_UNIT_PERCENTAGE_KHR = 1, + VK_PERFORMANCE_COUNTER_UNIT_NANOSECONDS_KHR = 2, + VK_PERFORMANCE_COUNTER_UNIT_BYTES_KHR = 3, + VK_PERFORMANCE_COUNTER_UNIT_BYTES_PER_SECOND_KHR = 4, + VK_PERFORMANCE_COUNTER_UNIT_KELVIN_KHR = 5, + VK_PERFORMANCE_COUNTER_UNIT_WATTS_KHR = 6, + VK_PERFORMANCE_COUNTER_UNIT_VOLTS_KHR = 7, + VK_PERFORMANCE_COUNTER_UNIT_AMPS_KHR = 8, + VK_PERFORMANCE_COUNTER_UNIT_HERTZ_KHR = 9, + VK_PERFORMANCE_COUNTER_UNIT_CYCLES_KHR = 10, + VK_PERFORMANCE_COUNTER_UNIT_BEGIN_RANGE_KHR = VK_PERFORMANCE_COUNTER_UNIT_GENERIC_KHR, + VK_PERFORMANCE_COUNTER_UNIT_END_RANGE_KHR = VK_PERFORMANCE_COUNTER_UNIT_CYCLES_KHR, + VK_PERFORMANCE_COUNTER_UNIT_RANGE_SIZE_KHR = (VK_PERFORMANCE_COUNTER_UNIT_CYCLES_KHR - VK_PERFORMANCE_COUNTER_UNIT_GENERIC_KHR + 1), + VK_PERFORMANCE_COUNTER_UNIT_MAX_ENUM_KHR = 0x7FFFFFFF +} VkPerformanceCounterUnitKHR; + +typedef enum VkPerformanceCounterScopeKHR { + VK_PERFORMANCE_COUNTER_SCOPE_COMMAND_BUFFER_KHR = 0, + VK_PERFORMANCE_COUNTER_SCOPE_RENDER_PASS_KHR = 1, + VK_PERFORMANCE_COUNTER_SCOPE_COMMAND_KHR = 2, + VK_QUERY_SCOPE_COMMAND_BUFFER_KHR = VK_PERFORMANCE_COUNTER_SCOPE_COMMAND_BUFFER_KHR, + VK_QUERY_SCOPE_RENDER_PASS_KHR = VK_PERFORMANCE_COUNTER_SCOPE_RENDER_PASS_KHR, + VK_QUERY_SCOPE_COMMAND_KHR = VK_PERFORMANCE_COUNTER_SCOPE_COMMAND_KHR, + VK_PERFORMANCE_COUNTER_SCOPE_BEGIN_RANGE_KHR = VK_PERFORMANCE_COUNTER_SCOPE_COMMAND_BUFFER_KHR, + VK_PERFORMANCE_COUNTER_SCOPE_END_RANGE_KHR = VK_PERFORMANCE_COUNTER_SCOPE_COMMAND_KHR, + VK_PERFORMANCE_COUNTER_SCOPE_RANGE_SIZE_KHR = (VK_PERFORMANCE_COUNTER_SCOPE_COMMAND_KHR - VK_PERFORMANCE_COUNTER_SCOPE_COMMAND_BUFFER_KHR + 1), + VK_PERFORMANCE_COUNTER_SCOPE_MAX_ENUM_KHR = 0x7FFFFFFF +} VkPerformanceCounterScopeKHR; + +typedef enum VkPerformanceCounterStorageKHR { + VK_PERFORMANCE_COUNTER_STORAGE_INT32_KHR = 0, + VK_PERFORMANCE_COUNTER_STORAGE_INT64_KHR = 1, + VK_PERFORMANCE_COUNTER_STORAGE_UINT32_KHR = 2, + VK_PERFORMANCE_COUNTER_STORAGE_UINT64_KHR = 3, + VK_PERFORMANCE_COUNTER_STORAGE_FLOAT32_KHR = 4, + VK_PERFORMANCE_COUNTER_STORAGE_FLOAT64_KHR = 5, + VK_PERFORMANCE_COUNTER_STORAGE_BEGIN_RANGE_KHR = VK_PERFORMANCE_COUNTER_STORAGE_INT32_KHR, + VK_PERFORMANCE_COUNTER_STORAGE_END_RANGE_KHR = VK_PERFORMANCE_COUNTER_STORAGE_FLOAT64_KHR, + VK_PERFORMANCE_COUNTER_STORAGE_RANGE_SIZE_KHR = (VK_PERFORMANCE_COUNTER_STORAGE_FLOAT64_KHR - VK_PERFORMANCE_COUNTER_STORAGE_INT32_KHR + 1), + VK_PERFORMANCE_COUNTER_STORAGE_MAX_ENUM_KHR = 0x7FFFFFFF +} VkPerformanceCounterStorageKHR; + +typedef enum VkPerformanceCounterDescriptionFlagBitsKHR { + VK_PERFORMANCE_COUNTER_DESCRIPTION_PERFORMANCE_IMPACTING_KHR = 0x00000001, + VK_PERFORMANCE_COUNTER_DESCRIPTION_CONCURRENTLY_IMPACTED_KHR = 0x00000002, + VK_PERFORMANCE_COUNTER_DESCRIPTION_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkPerformanceCounterDescriptionFlagBitsKHR; +typedef VkFlags VkPerformanceCounterDescriptionFlagsKHR; + +typedef enum VkAcquireProfilingLockFlagBitsKHR { + VK_ACQUIRE_PROFILING_LOCK_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkAcquireProfilingLockFlagBitsKHR; +typedef VkFlags VkAcquireProfilingLockFlagsKHR; +typedef struct VkPhysicalDevicePerformanceQueryFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 performanceCounterQueryPools; + VkBool32 performanceCounterMultipleQueryPools; +} VkPhysicalDevicePerformanceQueryFeaturesKHR; + +typedef struct VkPhysicalDevicePerformanceQueryPropertiesKHR { + VkStructureType sType; + void* pNext; + VkBool32 allowCommandBufferQueryCopies; +} VkPhysicalDevicePerformanceQueryPropertiesKHR; + +typedef struct VkPerformanceCounterKHR { + VkStructureType sType; + const void* pNext; + VkPerformanceCounterUnitKHR unit; + VkPerformanceCounterScopeKHR scope; + VkPerformanceCounterStorageKHR storage; + uint8_t uuid[VK_UUID_SIZE]; +} VkPerformanceCounterKHR; + +typedef struct VkPerformanceCounterDescriptionKHR { + VkStructureType sType; + const void* pNext; + VkPerformanceCounterDescriptionFlagsKHR flags; + char name[VK_MAX_DESCRIPTION_SIZE]; + char category[VK_MAX_DESCRIPTION_SIZE]; + char description[VK_MAX_DESCRIPTION_SIZE]; +} VkPerformanceCounterDescriptionKHR; + +typedef struct VkQueryPoolPerformanceCreateInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t queueFamilyIndex; + uint32_t counterIndexCount; + const uint32_t* pCounterIndices; +} VkQueryPoolPerformanceCreateInfoKHR; + +typedef union VkPerformanceCounterResultKHR { + int32_t int32; + int64_t int64; + uint32_t uint32; + uint64_t uint64; + float float32; + double float64; +} VkPerformanceCounterResultKHR; + +typedef struct VkAcquireProfilingLockInfoKHR { + VkStructureType sType; + const void* pNext; + VkAcquireProfilingLockFlagsKHR flags; + uint64_t timeout; +} VkAcquireProfilingLockInfoKHR; + +typedef struct VkPerformanceQuerySubmitInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t counterPassIndex; +} VkPerformanceQuerySubmitInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, uint32_t* pCounterCount, VkPerformanceCounterKHR* pCounters, VkPerformanceCounterDescriptionKHR* pCounterDescriptions); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR)(VkPhysicalDevice physicalDevice, const VkQueryPoolPerformanceCreateInfoKHR* pPerformanceQueryCreateInfo, uint32_t* pNumPasses); +typedef VkResult (VKAPI_PTR *PFN_vkAcquireProfilingLockKHR)(VkDevice device, const VkAcquireProfilingLockInfoKHR* pInfo); +typedef void (VKAPI_PTR *PFN_vkReleaseProfilingLockKHR)(VkDevice device); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR( + VkPhysicalDevice physicalDevice, + uint32_t queueFamilyIndex, + uint32_t* pCounterCount, + VkPerformanceCounterKHR* pCounters, + VkPerformanceCounterDescriptionKHR* pCounterDescriptions); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR( + VkPhysicalDevice physicalDevice, + const VkQueryPoolPerformanceCreateInfoKHR* pPerformanceQueryCreateInfo, + uint32_t* pNumPasses); + +VKAPI_ATTR VkResult VKAPI_CALL vkAcquireProfilingLockKHR( + VkDevice device, + const VkAcquireProfilingLockInfoKHR* pInfo); + +VKAPI_ATTR void VKAPI_CALL vkReleaseProfilingLockKHR( + VkDevice device); +#endif + + +#define VK_KHR_maintenance2 1 +#define VK_KHR_MAINTENANCE2_SPEC_VERSION 1 +#define VK_KHR_MAINTENANCE2_EXTENSION_NAME "VK_KHR_maintenance2" +typedef VkPointClippingBehavior VkPointClippingBehaviorKHR; + +typedef VkTessellationDomainOrigin VkTessellationDomainOriginKHR; + +typedef VkPhysicalDevicePointClippingProperties VkPhysicalDevicePointClippingPropertiesKHR; + +typedef VkRenderPassInputAttachmentAspectCreateInfo VkRenderPassInputAttachmentAspectCreateInfoKHR; + +typedef VkInputAttachmentAspectReference VkInputAttachmentAspectReferenceKHR; + +typedef VkImageViewUsageCreateInfo VkImageViewUsageCreateInfoKHR; + +typedef VkPipelineTessellationDomainOriginStateCreateInfo VkPipelineTessellationDomainOriginStateCreateInfoKHR; + + + +#define VK_KHR_get_surface_capabilities2 1 +#define VK_KHR_GET_SURFACE_CAPABILITIES_2_SPEC_VERSION 1 +#define VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME "VK_KHR_get_surface_capabilities2" +typedef struct VkPhysicalDeviceSurfaceInfo2KHR { + VkStructureType sType; + const void* pNext; + VkSurfaceKHR surface; +} VkPhysicalDeviceSurfaceInfo2KHR; + +typedef struct VkSurfaceCapabilities2KHR { + VkStructureType sType; + void* pNext; + VkSurfaceCapabilitiesKHR surfaceCapabilities; +} VkSurfaceCapabilities2KHR; + +typedef struct VkSurfaceFormat2KHR { + VkStructureType sType; + void* pNext; + VkSurfaceFormatKHR surfaceFormat; +} VkSurfaceFormat2KHR; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfaceCapabilities2KHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, VkSurfaceCapabilities2KHR* pSurfaceCapabilities); +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfaceFormats2KHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, uint32_t* pSurfaceFormatCount, VkSurfaceFormat2KHR* pSurfaceFormats); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilities2KHR( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, + VkSurfaceCapabilities2KHR* pSurfaceCapabilities); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormats2KHR( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, + uint32_t* pSurfaceFormatCount, + VkSurfaceFormat2KHR* pSurfaceFormats); +#endif + + +#define VK_KHR_variable_pointers 1 +#define VK_KHR_VARIABLE_POINTERS_SPEC_VERSION 1 +#define VK_KHR_VARIABLE_POINTERS_EXTENSION_NAME "VK_KHR_variable_pointers" +typedef VkPhysicalDeviceVariablePointersFeatures VkPhysicalDeviceVariablePointerFeaturesKHR; + +typedef VkPhysicalDeviceVariablePointersFeatures VkPhysicalDeviceVariablePointersFeaturesKHR; + + + +#define VK_KHR_get_display_properties2 1 +#define VK_KHR_GET_DISPLAY_PROPERTIES_2_SPEC_VERSION 1 +#define VK_KHR_GET_DISPLAY_PROPERTIES_2_EXTENSION_NAME "VK_KHR_get_display_properties2" +typedef struct VkDisplayProperties2KHR { + VkStructureType sType; + void* pNext; + VkDisplayPropertiesKHR displayProperties; +} VkDisplayProperties2KHR; + +typedef struct VkDisplayPlaneProperties2KHR { + VkStructureType sType; + void* pNext; + VkDisplayPlanePropertiesKHR displayPlaneProperties; +} VkDisplayPlaneProperties2KHR; + +typedef struct VkDisplayModeProperties2KHR { + VkStructureType sType; + void* pNext; + VkDisplayModePropertiesKHR displayModeProperties; +} VkDisplayModeProperties2KHR; + +typedef struct VkDisplayPlaneInfo2KHR { + VkStructureType sType; + const void* pNext; + VkDisplayModeKHR mode; + uint32_t planeIndex; +} VkDisplayPlaneInfo2KHR; + +typedef struct VkDisplayPlaneCapabilities2KHR { + VkStructureType sType; + void* pNext; + VkDisplayPlaneCapabilitiesKHR capabilities; +} VkDisplayPlaneCapabilities2KHR; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceDisplayProperties2KHR)(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkDisplayProperties2KHR* pProperties); +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceDisplayPlaneProperties2KHR)(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkDisplayPlaneProperties2KHR* pProperties); +typedef VkResult (VKAPI_PTR *PFN_vkGetDisplayModeProperties2KHR)(VkPhysicalDevice physicalDevice, VkDisplayKHR display, uint32_t* pPropertyCount, VkDisplayModeProperties2KHR* pProperties); +typedef VkResult (VKAPI_PTR *PFN_vkGetDisplayPlaneCapabilities2KHR)(VkPhysicalDevice physicalDevice, const VkDisplayPlaneInfo2KHR* pDisplayPlaneInfo, VkDisplayPlaneCapabilities2KHR* pCapabilities); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceDisplayProperties2KHR( + VkPhysicalDevice physicalDevice, + uint32_t* pPropertyCount, + VkDisplayProperties2KHR* pProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceDisplayPlaneProperties2KHR( + VkPhysicalDevice physicalDevice, + uint32_t* pPropertyCount, + VkDisplayPlaneProperties2KHR* pProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayModeProperties2KHR( + VkPhysicalDevice physicalDevice, + VkDisplayKHR display, + uint32_t* pPropertyCount, + VkDisplayModeProperties2KHR* pProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayPlaneCapabilities2KHR( + VkPhysicalDevice physicalDevice, + const VkDisplayPlaneInfo2KHR* pDisplayPlaneInfo, + VkDisplayPlaneCapabilities2KHR* pCapabilities); +#endif + + +#define VK_KHR_dedicated_allocation 1 +#define VK_KHR_DEDICATED_ALLOCATION_SPEC_VERSION 3 +#define VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME "VK_KHR_dedicated_allocation" +typedef VkMemoryDedicatedRequirements VkMemoryDedicatedRequirementsKHR; + +typedef VkMemoryDedicatedAllocateInfo VkMemoryDedicatedAllocateInfoKHR; + + + +#define VK_KHR_storage_buffer_storage_class 1 +#define VK_KHR_STORAGE_BUFFER_STORAGE_CLASS_SPEC_VERSION 1 +#define VK_KHR_STORAGE_BUFFER_STORAGE_CLASS_EXTENSION_NAME "VK_KHR_storage_buffer_storage_class" + + +#define VK_KHR_relaxed_block_layout 1 +#define VK_KHR_RELAXED_BLOCK_LAYOUT_SPEC_VERSION 1 +#define VK_KHR_RELAXED_BLOCK_LAYOUT_EXTENSION_NAME "VK_KHR_relaxed_block_layout" + + +#define VK_KHR_get_memory_requirements2 1 +#define VK_KHR_GET_MEMORY_REQUIREMENTS_2_SPEC_VERSION 1 +#define VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME "VK_KHR_get_memory_requirements2" +typedef VkBufferMemoryRequirementsInfo2 VkBufferMemoryRequirementsInfo2KHR; + +typedef VkImageMemoryRequirementsInfo2 VkImageMemoryRequirementsInfo2KHR; + +typedef VkImageSparseMemoryRequirementsInfo2 VkImageSparseMemoryRequirementsInfo2KHR; + +typedef VkSparseImageMemoryRequirements2 VkSparseImageMemoryRequirements2KHR; + +typedef void (VKAPI_PTR *PFN_vkGetImageMemoryRequirements2KHR)(VkDevice device, const VkImageMemoryRequirementsInfo2* pInfo, VkMemoryRequirements2* pMemoryRequirements); +typedef void (VKAPI_PTR *PFN_vkGetBufferMemoryRequirements2KHR)(VkDevice device, const VkBufferMemoryRequirementsInfo2* pInfo, VkMemoryRequirements2* pMemoryRequirements); +typedef void (VKAPI_PTR *PFN_vkGetImageSparseMemoryRequirements2KHR)(VkDevice device, const VkImageSparseMemoryRequirementsInfo2* pInfo, uint32_t* pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements2* pSparseMemoryRequirements); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkGetImageMemoryRequirements2KHR( + VkDevice device, + const VkImageMemoryRequirementsInfo2* pInfo, + VkMemoryRequirements2* pMemoryRequirements); + +VKAPI_ATTR void VKAPI_CALL vkGetBufferMemoryRequirements2KHR( + VkDevice device, + const VkBufferMemoryRequirementsInfo2* pInfo, + VkMemoryRequirements2* pMemoryRequirements); + +VKAPI_ATTR void VKAPI_CALL vkGetImageSparseMemoryRequirements2KHR( + VkDevice device, + const VkImageSparseMemoryRequirementsInfo2* pInfo, + uint32_t* pSparseMemoryRequirementCount, + VkSparseImageMemoryRequirements2* pSparseMemoryRequirements); +#endif + + +#define VK_KHR_image_format_list 1 +#define VK_KHR_IMAGE_FORMAT_LIST_SPEC_VERSION 1 +#define VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME "VK_KHR_image_format_list" +typedef VkImageFormatListCreateInfo VkImageFormatListCreateInfoKHR; + + + +#define VK_KHR_sampler_ycbcr_conversion 1 +typedef VkSamplerYcbcrConversion VkSamplerYcbcrConversionKHR; + +#define VK_KHR_SAMPLER_YCBCR_CONVERSION_SPEC_VERSION 14 +#define VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME "VK_KHR_sampler_ycbcr_conversion" +typedef VkSamplerYcbcrModelConversion VkSamplerYcbcrModelConversionKHR; + +typedef VkSamplerYcbcrRange VkSamplerYcbcrRangeKHR; + +typedef VkChromaLocation VkChromaLocationKHR; + +typedef VkSamplerYcbcrConversionCreateInfo VkSamplerYcbcrConversionCreateInfoKHR; + +typedef VkSamplerYcbcrConversionInfo VkSamplerYcbcrConversionInfoKHR; + +typedef VkBindImagePlaneMemoryInfo VkBindImagePlaneMemoryInfoKHR; + +typedef VkImagePlaneMemoryRequirementsInfo VkImagePlaneMemoryRequirementsInfoKHR; + +typedef VkPhysicalDeviceSamplerYcbcrConversionFeatures VkPhysicalDeviceSamplerYcbcrConversionFeaturesKHR; + +typedef VkSamplerYcbcrConversionImageFormatProperties VkSamplerYcbcrConversionImageFormatPropertiesKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateSamplerYcbcrConversionKHR)(VkDevice device, const VkSamplerYcbcrConversionCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSamplerYcbcrConversion* pYcbcrConversion); +typedef void (VKAPI_PTR *PFN_vkDestroySamplerYcbcrConversionKHR)(VkDevice device, VkSamplerYcbcrConversion ycbcrConversion, const VkAllocationCallbacks* pAllocator); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateSamplerYcbcrConversionKHR( + VkDevice device, + const VkSamplerYcbcrConversionCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSamplerYcbcrConversion* pYcbcrConversion); + +VKAPI_ATTR void VKAPI_CALL vkDestroySamplerYcbcrConversionKHR( + VkDevice device, + VkSamplerYcbcrConversion ycbcrConversion, + const VkAllocationCallbacks* pAllocator); +#endif + + +#define VK_KHR_bind_memory2 1 +#define VK_KHR_BIND_MEMORY_2_SPEC_VERSION 1 +#define VK_KHR_BIND_MEMORY_2_EXTENSION_NAME "VK_KHR_bind_memory2" +typedef VkBindBufferMemoryInfo VkBindBufferMemoryInfoKHR; + +typedef VkBindImageMemoryInfo VkBindImageMemoryInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkBindBufferMemory2KHR)(VkDevice device, uint32_t bindInfoCount, const VkBindBufferMemoryInfo* pBindInfos); +typedef VkResult (VKAPI_PTR *PFN_vkBindImageMemory2KHR)(VkDevice device, uint32_t bindInfoCount, const VkBindImageMemoryInfo* pBindInfos); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory2KHR( + VkDevice device, + uint32_t bindInfoCount, + const VkBindBufferMemoryInfo* pBindInfos); + +VKAPI_ATTR VkResult VKAPI_CALL vkBindImageMemory2KHR( + VkDevice device, + uint32_t bindInfoCount, + const VkBindImageMemoryInfo* pBindInfos); +#endif + + +#define VK_KHR_maintenance3 1 +#define VK_KHR_MAINTENANCE3_SPEC_VERSION 1 +#define VK_KHR_MAINTENANCE3_EXTENSION_NAME "VK_KHR_maintenance3" +typedef VkPhysicalDeviceMaintenance3Properties VkPhysicalDeviceMaintenance3PropertiesKHR; + +typedef VkDescriptorSetLayoutSupport VkDescriptorSetLayoutSupportKHR; + +typedef void (VKAPI_PTR *PFN_vkGetDescriptorSetLayoutSupportKHR)(VkDevice device, const VkDescriptorSetLayoutCreateInfo* pCreateInfo, VkDescriptorSetLayoutSupport* pSupport); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkGetDescriptorSetLayoutSupportKHR( + VkDevice device, + const VkDescriptorSetLayoutCreateInfo* pCreateInfo, + VkDescriptorSetLayoutSupport* pSupport); +#endif + + +#define VK_KHR_draw_indirect_count 1 +#define VK_KHR_DRAW_INDIRECT_COUNT_SPEC_VERSION 1 +#define VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME "VK_KHR_draw_indirect_count" +typedef void (VKAPI_PTR *PFN_vkCmdDrawIndirectCountKHR)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride); +typedef void (VKAPI_PTR *PFN_vkCmdDrawIndexedIndirectCountKHR)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirectCountKHR( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset, + VkBuffer countBuffer, + VkDeviceSize countBufferOffset, + uint32_t maxDrawCount, + uint32_t stride); + +VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexedIndirectCountKHR( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset, + VkBuffer countBuffer, + VkDeviceSize countBufferOffset, + uint32_t maxDrawCount, + uint32_t stride); +#endif + + +#define VK_KHR_shader_subgroup_extended_types 1 +#define VK_KHR_SHADER_SUBGROUP_EXTENDED_TYPES_SPEC_VERSION 1 +#define VK_KHR_SHADER_SUBGROUP_EXTENDED_TYPES_EXTENSION_NAME "VK_KHR_shader_subgroup_extended_types" +typedef VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures VkPhysicalDeviceShaderSubgroupExtendedTypesFeaturesKHR; + + + +#define VK_KHR_8bit_storage 1 +#define VK_KHR_8BIT_STORAGE_SPEC_VERSION 1 +#define VK_KHR_8BIT_STORAGE_EXTENSION_NAME "VK_KHR_8bit_storage" +typedef VkPhysicalDevice8BitStorageFeatures VkPhysicalDevice8BitStorageFeaturesKHR; + + + +#define VK_KHR_shader_atomic_int64 1 +#define VK_KHR_SHADER_ATOMIC_INT64_SPEC_VERSION 1 +#define VK_KHR_SHADER_ATOMIC_INT64_EXTENSION_NAME "VK_KHR_shader_atomic_int64" +typedef VkPhysicalDeviceShaderAtomicInt64Features VkPhysicalDeviceShaderAtomicInt64FeaturesKHR; + + + +#define VK_KHR_shader_clock 1 +#define VK_KHR_SHADER_CLOCK_SPEC_VERSION 1 +#define VK_KHR_SHADER_CLOCK_EXTENSION_NAME "VK_KHR_shader_clock" +typedef struct VkPhysicalDeviceShaderClockFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 shaderSubgroupClock; + VkBool32 shaderDeviceClock; +} VkPhysicalDeviceShaderClockFeaturesKHR; + + + +#define VK_KHR_driver_properties 1 +#define VK_KHR_DRIVER_PROPERTIES_SPEC_VERSION 1 +#define VK_KHR_DRIVER_PROPERTIES_EXTENSION_NAME "VK_KHR_driver_properties" +#define VK_MAX_DRIVER_NAME_SIZE_KHR VK_MAX_DRIVER_NAME_SIZE +#define VK_MAX_DRIVER_INFO_SIZE_KHR VK_MAX_DRIVER_INFO_SIZE +typedef VkDriverId VkDriverIdKHR; + +typedef VkConformanceVersion VkConformanceVersionKHR; + +typedef VkPhysicalDeviceDriverProperties VkPhysicalDeviceDriverPropertiesKHR; + + + +#define VK_KHR_shader_float_controls 1 +#define VK_KHR_SHADER_FLOAT_CONTROLS_SPEC_VERSION 4 +#define VK_KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME "VK_KHR_shader_float_controls" +typedef VkShaderFloatControlsIndependence VkShaderFloatControlsIndependenceKHR; + +typedef VkPhysicalDeviceFloatControlsProperties VkPhysicalDeviceFloatControlsPropertiesKHR; + + + +#define VK_KHR_depth_stencil_resolve 1 +#define VK_KHR_DEPTH_STENCIL_RESOLVE_SPEC_VERSION 1 +#define VK_KHR_DEPTH_STENCIL_RESOLVE_EXTENSION_NAME "VK_KHR_depth_stencil_resolve" +typedef VkResolveModeFlagBits VkResolveModeFlagBitsKHR; + +typedef VkResolveModeFlags VkResolveModeFlagsKHR; + +typedef VkSubpassDescriptionDepthStencilResolve VkSubpassDescriptionDepthStencilResolveKHR; + +typedef VkPhysicalDeviceDepthStencilResolveProperties VkPhysicalDeviceDepthStencilResolvePropertiesKHR; + + + +#define VK_KHR_swapchain_mutable_format 1 +#define VK_KHR_SWAPCHAIN_MUTABLE_FORMAT_SPEC_VERSION 1 +#define VK_KHR_SWAPCHAIN_MUTABLE_FORMAT_EXTENSION_NAME "VK_KHR_swapchain_mutable_format" + + +#define VK_KHR_timeline_semaphore 1 +#define VK_KHR_TIMELINE_SEMAPHORE_SPEC_VERSION 2 +#define VK_KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME "VK_KHR_timeline_semaphore" +typedef VkSemaphoreType VkSemaphoreTypeKHR; + +typedef VkSemaphoreWaitFlagBits VkSemaphoreWaitFlagBitsKHR; + +typedef VkSemaphoreWaitFlags VkSemaphoreWaitFlagsKHR; + +typedef VkPhysicalDeviceTimelineSemaphoreFeatures VkPhysicalDeviceTimelineSemaphoreFeaturesKHR; + +typedef VkPhysicalDeviceTimelineSemaphoreProperties VkPhysicalDeviceTimelineSemaphorePropertiesKHR; + +typedef VkSemaphoreTypeCreateInfo VkSemaphoreTypeCreateInfoKHR; + +typedef VkTimelineSemaphoreSubmitInfo VkTimelineSemaphoreSubmitInfoKHR; + +typedef VkSemaphoreWaitInfo VkSemaphoreWaitInfoKHR; + +typedef VkSemaphoreSignalInfo VkSemaphoreSignalInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkGetSemaphoreCounterValueKHR)(VkDevice device, VkSemaphore semaphore, uint64_t* pValue); +typedef VkResult (VKAPI_PTR *PFN_vkWaitSemaphoresKHR)(VkDevice device, const VkSemaphoreWaitInfo* pWaitInfo, uint64_t timeout); +typedef VkResult (VKAPI_PTR *PFN_vkSignalSemaphoreKHR)(VkDevice device, const VkSemaphoreSignalInfo* pSignalInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreCounterValueKHR( + VkDevice device, + VkSemaphore semaphore, + uint64_t* pValue); + +VKAPI_ATTR VkResult VKAPI_CALL vkWaitSemaphoresKHR( + VkDevice device, + const VkSemaphoreWaitInfo* pWaitInfo, + uint64_t timeout); + +VKAPI_ATTR VkResult VKAPI_CALL vkSignalSemaphoreKHR( + VkDevice device, + const VkSemaphoreSignalInfo* pSignalInfo); +#endif + + +#define VK_KHR_vulkan_memory_model 1 +#define VK_KHR_VULKAN_MEMORY_MODEL_SPEC_VERSION 3 +#define VK_KHR_VULKAN_MEMORY_MODEL_EXTENSION_NAME "VK_KHR_vulkan_memory_model" +typedef VkPhysicalDeviceVulkanMemoryModelFeatures VkPhysicalDeviceVulkanMemoryModelFeaturesKHR; + + + +#define VK_KHR_spirv_1_4 1 +#define VK_KHR_SPIRV_1_4_SPEC_VERSION 1 +#define VK_KHR_SPIRV_1_4_EXTENSION_NAME "VK_KHR_spirv_1_4" + + +#define VK_KHR_surface_protected_capabilities 1 +#define VK_KHR_SURFACE_PROTECTED_CAPABILITIES_SPEC_VERSION 1 +#define VK_KHR_SURFACE_PROTECTED_CAPABILITIES_EXTENSION_NAME "VK_KHR_surface_protected_capabilities" +typedef struct VkSurfaceProtectedCapabilitiesKHR { + VkStructureType sType; + const void* pNext; + VkBool32 supportsProtected; +} VkSurfaceProtectedCapabilitiesKHR; + + + +#define VK_KHR_separate_depth_stencil_layouts 1 +#define VK_KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_SPEC_VERSION 1 +#define VK_KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_EXTENSION_NAME "VK_KHR_separate_depth_stencil_layouts" +typedef VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures VkPhysicalDeviceSeparateDepthStencilLayoutsFeaturesKHR; + +typedef VkAttachmentReferenceStencilLayout VkAttachmentReferenceStencilLayoutKHR; + +typedef VkAttachmentDescriptionStencilLayout VkAttachmentDescriptionStencilLayoutKHR; + + + +#define VK_KHR_uniform_buffer_standard_layout 1 +#define VK_KHR_UNIFORM_BUFFER_STANDARD_LAYOUT_SPEC_VERSION 1 +#define VK_KHR_UNIFORM_BUFFER_STANDARD_LAYOUT_EXTENSION_NAME "VK_KHR_uniform_buffer_standard_layout" +typedef VkPhysicalDeviceUniformBufferStandardLayoutFeatures VkPhysicalDeviceUniformBufferStandardLayoutFeaturesKHR; + + + +#define VK_KHR_buffer_device_address 1 +#define VK_KHR_BUFFER_DEVICE_ADDRESS_SPEC_VERSION 1 +#define VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME "VK_KHR_buffer_device_address" +typedef VkPhysicalDeviceBufferDeviceAddressFeatures VkPhysicalDeviceBufferDeviceAddressFeaturesKHR; + +typedef VkBufferDeviceAddressInfo VkBufferDeviceAddressInfoKHR; + +typedef VkBufferOpaqueCaptureAddressCreateInfo VkBufferOpaqueCaptureAddressCreateInfoKHR; + +typedef VkMemoryOpaqueCaptureAddressAllocateInfo VkMemoryOpaqueCaptureAddressAllocateInfoKHR; + +typedef VkDeviceMemoryOpaqueCaptureAddressInfo VkDeviceMemoryOpaqueCaptureAddressInfoKHR; + +typedef VkDeviceAddress (VKAPI_PTR *PFN_vkGetBufferDeviceAddressKHR)(VkDevice device, const VkBufferDeviceAddressInfo* pInfo); +typedef uint64_t (VKAPI_PTR *PFN_vkGetBufferOpaqueCaptureAddressKHR)(VkDevice device, const VkBufferDeviceAddressInfo* pInfo); +typedef uint64_t (VKAPI_PTR *PFN_vkGetDeviceMemoryOpaqueCaptureAddressKHR)(VkDevice device, const VkDeviceMemoryOpaqueCaptureAddressInfo* pInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkDeviceAddress VKAPI_CALL vkGetBufferDeviceAddressKHR( + VkDevice device, + const VkBufferDeviceAddressInfo* pInfo); + +VKAPI_ATTR uint64_t VKAPI_CALL vkGetBufferOpaqueCaptureAddressKHR( + VkDevice device, + const VkBufferDeviceAddressInfo* pInfo); + +VKAPI_ATTR uint64_t VKAPI_CALL vkGetDeviceMemoryOpaqueCaptureAddressKHR( + VkDevice device, + const VkDeviceMemoryOpaqueCaptureAddressInfo* pInfo); +#endif + + +#define VK_KHR_pipeline_executable_properties 1 +#define VK_KHR_PIPELINE_EXECUTABLE_PROPERTIES_SPEC_VERSION 1 +#define VK_KHR_PIPELINE_EXECUTABLE_PROPERTIES_EXTENSION_NAME "VK_KHR_pipeline_executable_properties" + +typedef enum VkPipelineExecutableStatisticFormatKHR { + VK_PIPELINE_EXECUTABLE_STATISTIC_FORMAT_BOOL32_KHR = 0, + VK_PIPELINE_EXECUTABLE_STATISTIC_FORMAT_INT64_KHR = 1, + VK_PIPELINE_EXECUTABLE_STATISTIC_FORMAT_UINT64_KHR = 2, + VK_PIPELINE_EXECUTABLE_STATISTIC_FORMAT_FLOAT64_KHR = 3, + VK_PIPELINE_EXECUTABLE_STATISTIC_FORMAT_BEGIN_RANGE_KHR = VK_PIPELINE_EXECUTABLE_STATISTIC_FORMAT_BOOL32_KHR, + VK_PIPELINE_EXECUTABLE_STATISTIC_FORMAT_END_RANGE_KHR = VK_PIPELINE_EXECUTABLE_STATISTIC_FORMAT_FLOAT64_KHR, + VK_PIPELINE_EXECUTABLE_STATISTIC_FORMAT_RANGE_SIZE_KHR = (VK_PIPELINE_EXECUTABLE_STATISTIC_FORMAT_FLOAT64_KHR - VK_PIPELINE_EXECUTABLE_STATISTIC_FORMAT_BOOL32_KHR + 1), + VK_PIPELINE_EXECUTABLE_STATISTIC_FORMAT_MAX_ENUM_KHR = 0x7FFFFFFF +} VkPipelineExecutableStatisticFormatKHR; +typedef struct VkPhysicalDevicePipelineExecutablePropertiesFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 pipelineExecutableInfo; +} VkPhysicalDevicePipelineExecutablePropertiesFeaturesKHR; + +typedef struct VkPipelineInfoKHR { + VkStructureType sType; + const void* pNext; + VkPipeline pipeline; +} VkPipelineInfoKHR; + +typedef struct VkPipelineExecutablePropertiesKHR { + VkStructureType sType; + void* pNext; + VkShaderStageFlags stages; + char name[VK_MAX_DESCRIPTION_SIZE]; + char description[VK_MAX_DESCRIPTION_SIZE]; + uint32_t subgroupSize; +} VkPipelineExecutablePropertiesKHR; + +typedef struct VkPipelineExecutableInfoKHR { + VkStructureType sType; + const void* pNext; + VkPipeline pipeline; + uint32_t executableIndex; +} VkPipelineExecutableInfoKHR; + +typedef union VkPipelineExecutableStatisticValueKHR { + VkBool32 b32; + int64_t i64; + uint64_t u64; + double f64; +} VkPipelineExecutableStatisticValueKHR; + +typedef struct VkPipelineExecutableStatisticKHR { + VkStructureType sType; + void* pNext; + char name[VK_MAX_DESCRIPTION_SIZE]; + char description[VK_MAX_DESCRIPTION_SIZE]; + VkPipelineExecutableStatisticFormatKHR format; + VkPipelineExecutableStatisticValueKHR value; +} VkPipelineExecutableStatisticKHR; + +typedef struct VkPipelineExecutableInternalRepresentationKHR { + VkStructureType sType; + void* pNext; + char name[VK_MAX_DESCRIPTION_SIZE]; + char description[VK_MAX_DESCRIPTION_SIZE]; + VkBool32 isText; + size_t dataSize; + void* pData; +} VkPipelineExecutableInternalRepresentationKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPipelineExecutablePropertiesKHR)(VkDevice device, const VkPipelineInfoKHR* pPipelineInfo, uint32_t* pExecutableCount, VkPipelineExecutablePropertiesKHR* pProperties); +typedef VkResult (VKAPI_PTR *PFN_vkGetPipelineExecutableStatisticsKHR)(VkDevice device, const VkPipelineExecutableInfoKHR* pExecutableInfo, uint32_t* pStatisticCount, VkPipelineExecutableStatisticKHR* pStatistics); +typedef VkResult (VKAPI_PTR *PFN_vkGetPipelineExecutableInternalRepresentationsKHR)(VkDevice device, const VkPipelineExecutableInfoKHR* pExecutableInfo, uint32_t* pInternalRepresentationCount, VkPipelineExecutableInternalRepresentationKHR* pInternalRepresentations); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPipelineExecutablePropertiesKHR( + VkDevice device, + const VkPipelineInfoKHR* pPipelineInfo, + uint32_t* pExecutableCount, + VkPipelineExecutablePropertiesKHR* pProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPipelineExecutableStatisticsKHR( + VkDevice device, + const VkPipelineExecutableInfoKHR* pExecutableInfo, + uint32_t* pStatisticCount, + VkPipelineExecutableStatisticKHR* pStatistics); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPipelineExecutableInternalRepresentationsKHR( + VkDevice device, + const VkPipelineExecutableInfoKHR* pExecutableInfo, + uint32_t* pInternalRepresentationCount, + VkPipelineExecutableInternalRepresentationKHR* pInternalRepresentations); +#endif + + +#define VK_KHR_shader_non_semantic_info 1 +#define VK_KHR_SHADER_NON_SEMANTIC_INFO_SPEC_VERSION 1 +#define VK_KHR_SHADER_NON_SEMANTIC_INFO_EXTENSION_NAME "VK_KHR_shader_non_semantic_info" + + +#define VK_EXT_debug_report 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDebugReportCallbackEXT) +#define VK_EXT_DEBUG_REPORT_SPEC_VERSION 9 +#define VK_EXT_DEBUG_REPORT_EXTENSION_NAME "VK_EXT_debug_report" + +typedef enum VkDebugReportObjectTypeEXT { + VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT = 0, + VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT = 1, + VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT = 2, + VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT = 3, + VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT = 4, + VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT = 5, + VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT = 6, + VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT = 7, + VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT = 8, + VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT = 9, + VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT = 10, + VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT = 11, + VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT = 12, + VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT = 13, + VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT = 14, + VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT = 15, + VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT = 16, + VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT = 17, + VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT = 18, + VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT = 19, + VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT_EXT = 20, + VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT = 21, + VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT = 22, + VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT = 23, + VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT = 24, + VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT = 25, + VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT = 26, + VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT = 27, + VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT_EXT = 28, + VK_DEBUG_REPORT_OBJECT_TYPE_DISPLAY_KHR_EXT = 29, + VK_DEBUG_REPORT_OBJECT_TYPE_DISPLAY_MODE_KHR_EXT = 30, + VK_DEBUG_REPORT_OBJECT_TYPE_OBJECT_TABLE_NVX_EXT = 31, + VK_DEBUG_REPORT_OBJECT_TYPE_INDIRECT_COMMANDS_LAYOUT_NVX_EXT = 32, + VK_DEBUG_REPORT_OBJECT_TYPE_VALIDATION_CACHE_EXT_EXT = 33, + VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION_EXT = 1000156000, + VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_EXT = 1000085000, + VK_DEBUG_REPORT_OBJECT_TYPE_ACCELERATION_STRUCTURE_NV_EXT = 1000165000, + VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_EXT = VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_VALIDATION_CACHE_EXT = VK_DEBUG_REPORT_OBJECT_TYPE_VALIDATION_CACHE_EXT_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_KHR_EXT = VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION_KHR_EXT = VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_BEGIN_RANGE_EXT = VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_END_RANGE_EXT = VK_DEBUG_REPORT_OBJECT_TYPE_VALIDATION_CACHE_EXT_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_RANGE_SIZE_EXT = (VK_DEBUG_REPORT_OBJECT_TYPE_VALIDATION_CACHE_EXT_EXT - VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT + 1), + VK_DEBUG_REPORT_OBJECT_TYPE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkDebugReportObjectTypeEXT; + +typedef enum VkDebugReportFlagBitsEXT { + VK_DEBUG_REPORT_INFORMATION_BIT_EXT = 0x00000001, + VK_DEBUG_REPORT_WARNING_BIT_EXT = 0x00000002, + VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT = 0x00000004, + VK_DEBUG_REPORT_ERROR_BIT_EXT = 0x00000008, + VK_DEBUG_REPORT_DEBUG_BIT_EXT = 0x00000010, + VK_DEBUG_REPORT_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkDebugReportFlagBitsEXT; +typedef VkFlags VkDebugReportFlagsEXT; +typedef VkBool32 (VKAPI_PTR *PFN_vkDebugReportCallbackEXT)( + VkDebugReportFlagsEXT flags, + VkDebugReportObjectTypeEXT objectType, + uint64_t object, + size_t location, + int32_t messageCode, + const char* pLayerPrefix, + const char* pMessage, + void* pUserData); + +typedef struct VkDebugReportCallbackCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkDebugReportFlagsEXT flags; + PFN_vkDebugReportCallbackEXT pfnCallback; + void* pUserData; +} VkDebugReportCallbackCreateInfoEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateDebugReportCallbackEXT)(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugReportCallbackEXT* pCallback); +typedef void (VKAPI_PTR *PFN_vkDestroyDebugReportCallbackEXT)(VkInstance instance, VkDebugReportCallbackEXT callback, const VkAllocationCallbacks* pAllocator); +typedef void (VKAPI_PTR *PFN_vkDebugReportMessageEXT)(VkInstance instance, VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugReportCallbackEXT( + VkInstance instance, + const VkDebugReportCallbackCreateInfoEXT* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkDebugReportCallbackEXT* pCallback); + +VKAPI_ATTR void VKAPI_CALL vkDestroyDebugReportCallbackEXT( + VkInstance instance, + VkDebugReportCallbackEXT callback, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR void VKAPI_CALL vkDebugReportMessageEXT( + VkInstance instance, + VkDebugReportFlagsEXT flags, + VkDebugReportObjectTypeEXT objectType, + uint64_t object, + size_t location, + int32_t messageCode, + const char* pLayerPrefix, + const char* pMessage); +#endif + + +#define VK_NV_glsl_shader 1 +#define VK_NV_GLSL_SHADER_SPEC_VERSION 1 +#define VK_NV_GLSL_SHADER_EXTENSION_NAME "VK_NV_glsl_shader" + + +#define VK_EXT_depth_range_unrestricted 1 +#define VK_EXT_DEPTH_RANGE_UNRESTRICTED_SPEC_VERSION 1 +#define VK_EXT_DEPTH_RANGE_UNRESTRICTED_EXTENSION_NAME "VK_EXT_depth_range_unrestricted" + + +#define VK_IMG_filter_cubic 1 +#define VK_IMG_FILTER_CUBIC_SPEC_VERSION 1 +#define VK_IMG_FILTER_CUBIC_EXTENSION_NAME "VK_IMG_filter_cubic" + + +#define VK_AMD_rasterization_order 1 +#define VK_AMD_RASTERIZATION_ORDER_SPEC_VERSION 1 +#define VK_AMD_RASTERIZATION_ORDER_EXTENSION_NAME "VK_AMD_rasterization_order" + +typedef enum VkRasterizationOrderAMD { + VK_RASTERIZATION_ORDER_STRICT_AMD = 0, + VK_RASTERIZATION_ORDER_RELAXED_AMD = 1, + VK_RASTERIZATION_ORDER_BEGIN_RANGE_AMD = VK_RASTERIZATION_ORDER_STRICT_AMD, + VK_RASTERIZATION_ORDER_END_RANGE_AMD = VK_RASTERIZATION_ORDER_RELAXED_AMD, + VK_RASTERIZATION_ORDER_RANGE_SIZE_AMD = (VK_RASTERIZATION_ORDER_RELAXED_AMD - VK_RASTERIZATION_ORDER_STRICT_AMD + 1), + VK_RASTERIZATION_ORDER_MAX_ENUM_AMD = 0x7FFFFFFF +} VkRasterizationOrderAMD; +typedef struct VkPipelineRasterizationStateRasterizationOrderAMD { + VkStructureType sType; + const void* pNext; + VkRasterizationOrderAMD rasterizationOrder; +} VkPipelineRasterizationStateRasterizationOrderAMD; + + + +#define VK_AMD_shader_trinary_minmax 1 +#define VK_AMD_SHADER_TRINARY_MINMAX_SPEC_VERSION 1 +#define VK_AMD_SHADER_TRINARY_MINMAX_EXTENSION_NAME "VK_AMD_shader_trinary_minmax" + + +#define VK_AMD_shader_explicit_vertex_parameter 1 +#define VK_AMD_SHADER_EXPLICIT_VERTEX_PARAMETER_SPEC_VERSION 1 +#define VK_AMD_SHADER_EXPLICIT_VERTEX_PARAMETER_EXTENSION_NAME "VK_AMD_shader_explicit_vertex_parameter" + + +#define VK_EXT_debug_marker 1 +#define VK_EXT_DEBUG_MARKER_SPEC_VERSION 4 +#define VK_EXT_DEBUG_MARKER_EXTENSION_NAME "VK_EXT_debug_marker" +typedef struct VkDebugMarkerObjectNameInfoEXT { + VkStructureType sType; + const void* pNext; + VkDebugReportObjectTypeEXT objectType; + uint64_t object; + const char* pObjectName; +} VkDebugMarkerObjectNameInfoEXT; + +typedef struct VkDebugMarkerObjectTagInfoEXT { + VkStructureType sType; + const void* pNext; + VkDebugReportObjectTypeEXT objectType; + uint64_t object; + uint64_t tagName; + size_t tagSize; + const void* pTag; +} VkDebugMarkerObjectTagInfoEXT; + +typedef struct VkDebugMarkerMarkerInfoEXT { + VkStructureType sType; + const void* pNext; + const char* pMarkerName; + float color[4]; +} VkDebugMarkerMarkerInfoEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkDebugMarkerSetObjectTagEXT)(VkDevice device, const VkDebugMarkerObjectTagInfoEXT* pTagInfo); +typedef VkResult (VKAPI_PTR *PFN_vkDebugMarkerSetObjectNameEXT)(VkDevice device, const VkDebugMarkerObjectNameInfoEXT* pNameInfo); +typedef void (VKAPI_PTR *PFN_vkCmdDebugMarkerBeginEXT)(VkCommandBuffer commandBuffer, const VkDebugMarkerMarkerInfoEXT* pMarkerInfo); +typedef void (VKAPI_PTR *PFN_vkCmdDebugMarkerEndEXT)(VkCommandBuffer commandBuffer); +typedef void (VKAPI_PTR *PFN_vkCmdDebugMarkerInsertEXT)(VkCommandBuffer commandBuffer, const VkDebugMarkerMarkerInfoEXT* pMarkerInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkDebugMarkerSetObjectTagEXT( + VkDevice device, + const VkDebugMarkerObjectTagInfoEXT* pTagInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkDebugMarkerSetObjectNameEXT( + VkDevice device, + const VkDebugMarkerObjectNameInfoEXT* pNameInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdDebugMarkerBeginEXT( + VkCommandBuffer commandBuffer, + const VkDebugMarkerMarkerInfoEXT* pMarkerInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdDebugMarkerEndEXT( + VkCommandBuffer commandBuffer); + +VKAPI_ATTR void VKAPI_CALL vkCmdDebugMarkerInsertEXT( + VkCommandBuffer commandBuffer, + const VkDebugMarkerMarkerInfoEXT* pMarkerInfo); +#endif + + +#define VK_AMD_gcn_shader 1 +#define VK_AMD_GCN_SHADER_SPEC_VERSION 1 +#define VK_AMD_GCN_SHADER_EXTENSION_NAME "VK_AMD_gcn_shader" + + +#define VK_NV_dedicated_allocation 1 +#define VK_NV_DEDICATED_ALLOCATION_SPEC_VERSION 1 +#define VK_NV_DEDICATED_ALLOCATION_EXTENSION_NAME "VK_NV_dedicated_allocation" +typedef struct VkDedicatedAllocationImageCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkBool32 dedicatedAllocation; +} VkDedicatedAllocationImageCreateInfoNV; + +typedef struct VkDedicatedAllocationBufferCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkBool32 dedicatedAllocation; +} VkDedicatedAllocationBufferCreateInfoNV; + +typedef struct VkDedicatedAllocationMemoryAllocateInfoNV { + VkStructureType sType; + const void* pNext; + VkImage image; + VkBuffer buffer; +} VkDedicatedAllocationMemoryAllocateInfoNV; + + + +#define VK_EXT_transform_feedback 1 +#define VK_EXT_TRANSFORM_FEEDBACK_SPEC_VERSION 1 +#define VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME "VK_EXT_transform_feedback" +typedef VkFlags VkPipelineRasterizationStateStreamCreateFlagsEXT; +typedef struct VkPhysicalDeviceTransformFeedbackFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 transformFeedback; + VkBool32 geometryStreams; +} VkPhysicalDeviceTransformFeedbackFeaturesEXT; + +typedef struct VkPhysicalDeviceTransformFeedbackPropertiesEXT { + VkStructureType sType; + void* pNext; + uint32_t maxTransformFeedbackStreams; + uint32_t maxTransformFeedbackBuffers; + VkDeviceSize maxTransformFeedbackBufferSize; + uint32_t maxTransformFeedbackStreamDataSize; + uint32_t maxTransformFeedbackBufferDataSize; + uint32_t maxTransformFeedbackBufferDataStride; + VkBool32 transformFeedbackQueries; + VkBool32 transformFeedbackStreamsLinesTriangles; + VkBool32 transformFeedbackRasterizationStreamSelect; + VkBool32 transformFeedbackDraw; +} VkPhysicalDeviceTransformFeedbackPropertiesEXT; + +typedef struct VkPipelineRasterizationStateStreamCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkPipelineRasterizationStateStreamCreateFlagsEXT flags; + uint32_t rasterizationStream; +} VkPipelineRasterizationStateStreamCreateInfoEXT; + +typedef void (VKAPI_PTR *PFN_vkCmdBindTransformFeedbackBuffersEXT)(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount, const VkBuffer* pBuffers, const VkDeviceSize* pOffsets, const VkDeviceSize* pSizes); +typedef void (VKAPI_PTR *PFN_vkCmdBeginTransformFeedbackEXT)(VkCommandBuffer commandBuffer, uint32_t firstCounterBuffer, uint32_t counterBufferCount, const VkBuffer* pCounterBuffers, const VkDeviceSize* pCounterBufferOffsets); +typedef void (VKAPI_PTR *PFN_vkCmdEndTransformFeedbackEXT)(VkCommandBuffer commandBuffer, uint32_t firstCounterBuffer, uint32_t counterBufferCount, const VkBuffer* pCounterBuffers, const VkDeviceSize* pCounterBufferOffsets); +typedef void (VKAPI_PTR *PFN_vkCmdBeginQueryIndexedEXT)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query, VkQueryControlFlags flags, uint32_t index); +typedef void (VKAPI_PTR *PFN_vkCmdEndQueryIndexedEXT)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query, uint32_t index); +typedef void (VKAPI_PTR *PFN_vkCmdDrawIndirectByteCountEXT)(VkCommandBuffer commandBuffer, uint32_t instanceCount, uint32_t firstInstance, VkBuffer counterBuffer, VkDeviceSize counterBufferOffset, uint32_t counterOffset, uint32_t vertexStride); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdBindTransformFeedbackBuffersEXT( + VkCommandBuffer commandBuffer, + uint32_t firstBinding, + uint32_t bindingCount, + const VkBuffer* pBuffers, + const VkDeviceSize* pOffsets, + const VkDeviceSize* pSizes); + +VKAPI_ATTR void VKAPI_CALL vkCmdBeginTransformFeedbackEXT( + VkCommandBuffer commandBuffer, + uint32_t firstCounterBuffer, + uint32_t counterBufferCount, + const VkBuffer* pCounterBuffers, + const VkDeviceSize* pCounterBufferOffsets); + +VKAPI_ATTR void VKAPI_CALL vkCmdEndTransformFeedbackEXT( + VkCommandBuffer commandBuffer, + uint32_t firstCounterBuffer, + uint32_t counterBufferCount, + const VkBuffer* pCounterBuffers, + const VkDeviceSize* pCounterBufferOffsets); + +VKAPI_ATTR void VKAPI_CALL vkCmdBeginQueryIndexedEXT( + VkCommandBuffer commandBuffer, + VkQueryPool queryPool, + uint32_t query, + VkQueryControlFlags flags, + uint32_t index); + +VKAPI_ATTR void VKAPI_CALL vkCmdEndQueryIndexedEXT( + VkCommandBuffer commandBuffer, + VkQueryPool queryPool, + uint32_t query, + uint32_t index); + +VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirectByteCountEXT( + VkCommandBuffer commandBuffer, + uint32_t instanceCount, + uint32_t firstInstance, + VkBuffer counterBuffer, + VkDeviceSize counterBufferOffset, + uint32_t counterOffset, + uint32_t vertexStride); +#endif + + +#define VK_NVX_image_view_handle 1 +#define VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION 1 +#define VK_NVX_IMAGE_VIEW_HANDLE_EXTENSION_NAME "VK_NVX_image_view_handle" +typedef struct VkImageViewHandleInfoNVX { + VkStructureType sType; + const void* pNext; + VkImageView imageView; + VkDescriptorType descriptorType; + VkSampler sampler; +} VkImageViewHandleInfoNVX; + +typedef uint32_t (VKAPI_PTR *PFN_vkGetImageViewHandleNVX)(VkDevice device, const VkImageViewHandleInfoNVX* pInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR uint32_t VKAPI_CALL vkGetImageViewHandleNVX( + VkDevice device, + const VkImageViewHandleInfoNVX* pInfo); +#endif + + +#define VK_AMD_draw_indirect_count 1 +#define VK_AMD_DRAW_INDIRECT_COUNT_SPEC_VERSION 2 +#define VK_AMD_DRAW_INDIRECT_COUNT_EXTENSION_NAME "VK_AMD_draw_indirect_count" +typedef void (VKAPI_PTR *PFN_vkCmdDrawIndirectCountAMD)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride); +typedef void (VKAPI_PTR *PFN_vkCmdDrawIndexedIndirectCountAMD)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirectCountAMD( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset, + VkBuffer countBuffer, + VkDeviceSize countBufferOffset, + uint32_t maxDrawCount, + uint32_t stride); + +VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexedIndirectCountAMD( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset, + VkBuffer countBuffer, + VkDeviceSize countBufferOffset, + uint32_t maxDrawCount, + uint32_t stride); +#endif + + +#define VK_AMD_negative_viewport_height 1 +#define VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_SPEC_VERSION 1 +#define VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME "VK_AMD_negative_viewport_height" + + +#define VK_AMD_gpu_shader_half_float 1 +#define VK_AMD_GPU_SHADER_HALF_FLOAT_SPEC_VERSION 2 +#define VK_AMD_GPU_SHADER_HALF_FLOAT_EXTENSION_NAME "VK_AMD_gpu_shader_half_float" + + +#define VK_AMD_shader_ballot 1 +#define VK_AMD_SHADER_BALLOT_SPEC_VERSION 1 +#define VK_AMD_SHADER_BALLOT_EXTENSION_NAME "VK_AMD_shader_ballot" + + +#define VK_AMD_texture_gather_bias_lod 1 +#define VK_AMD_TEXTURE_GATHER_BIAS_LOD_SPEC_VERSION 1 +#define VK_AMD_TEXTURE_GATHER_BIAS_LOD_EXTENSION_NAME "VK_AMD_texture_gather_bias_lod" +typedef struct VkTextureLODGatherFormatPropertiesAMD { + VkStructureType sType; + void* pNext; + VkBool32 supportsTextureGatherLODBiasAMD; +} VkTextureLODGatherFormatPropertiesAMD; + + + +#define VK_AMD_shader_info 1 +#define VK_AMD_SHADER_INFO_SPEC_VERSION 1 +#define VK_AMD_SHADER_INFO_EXTENSION_NAME "VK_AMD_shader_info" + +typedef enum VkShaderInfoTypeAMD { + VK_SHADER_INFO_TYPE_STATISTICS_AMD = 0, + VK_SHADER_INFO_TYPE_BINARY_AMD = 1, + VK_SHADER_INFO_TYPE_DISASSEMBLY_AMD = 2, + VK_SHADER_INFO_TYPE_BEGIN_RANGE_AMD = VK_SHADER_INFO_TYPE_STATISTICS_AMD, + VK_SHADER_INFO_TYPE_END_RANGE_AMD = VK_SHADER_INFO_TYPE_DISASSEMBLY_AMD, + VK_SHADER_INFO_TYPE_RANGE_SIZE_AMD = (VK_SHADER_INFO_TYPE_DISASSEMBLY_AMD - VK_SHADER_INFO_TYPE_STATISTICS_AMD + 1), + VK_SHADER_INFO_TYPE_MAX_ENUM_AMD = 0x7FFFFFFF +} VkShaderInfoTypeAMD; +typedef struct VkShaderResourceUsageAMD { + uint32_t numUsedVgprs; + uint32_t numUsedSgprs; + uint32_t ldsSizePerLocalWorkGroup; + size_t ldsUsageSizeInBytes; + size_t scratchMemUsageInBytes; +} VkShaderResourceUsageAMD; + +typedef struct VkShaderStatisticsInfoAMD { + VkShaderStageFlags shaderStageMask; + VkShaderResourceUsageAMD resourceUsage; + uint32_t numPhysicalVgprs; + uint32_t numPhysicalSgprs; + uint32_t numAvailableVgprs; + uint32_t numAvailableSgprs; + uint32_t computeWorkGroupSize[3]; +} VkShaderStatisticsInfoAMD; + +typedef VkResult (VKAPI_PTR *PFN_vkGetShaderInfoAMD)(VkDevice device, VkPipeline pipeline, VkShaderStageFlagBits shaderStage, VkShaderInfoTypeAMD infoType, size_t* pInfoSize, void* pInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetShaderInfoAMD( + VkDevice device, + VkPipeline pipeline, + VkShaderStageFlagBits shaderStage, + VkShaderInfoTypeAMD infoType, + size_t* pInfoSize, + void* pInfo); +#endif + + +#define VK_AMD_shader_image_load_store_lod 1 +#define VK_AMD_SHADER_IMAGE_LOAD_STORE_LOD_SPEC_VERSION 1 +#define VK_AMD_SHADER_IMAGE_LOAD_STORE_LOD_EXTENSION_NAME "VK_AMD_shader_image_load_store_lod" + + +#define VK_NV_corner_sampled_image 1 +#define VK_NV_CORNER_SAMPLED_IMAGE_SPEC_VERSION 2 +#define VK_NV_CORNER_SAMPLED_IMAGE_EXTENSION_NAME "VK_NV_corner_sampled_image" +typedef struct VkPhysicalDeviceCornerSampledImageFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 cornerSampledImage; +} VkPhysicalDeviceCornerSampledImageFeaturesNV; + + + +#define VK_IMG_format_pvrtc 1 +#define VK_IMG_FORMAT_PVRTC_SPEC_VERSION 1 +#define VK_IMG_FORMAT_PVRTC_EXTENSION_NAME "VK_IMG_format_pvrtc" + + +#define VK_NV_external_memory_capabilities 1 +#define VK_NV_EXTERNAL_MEMORY_CAPABILITIES_SPEC_VERSION 1 +#define VK_NV_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME "VK_NV_external_memory_capabilities" + +typedef enum VkExternalMemoryHandleTypeFlagBitsNV { + VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT_NV = 0x00000001, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT_NV = 0x00000002, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_IMAGE_BIT_NV = 0x00000004, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_IMAGE_KMT_BIT_NV = 0x00000008, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_FLAG_BITS_MAX_ENUM_NV = 0x7FFFFFFF +} VkExternalMemoryHandleTypeFlagBitsNV; +typedef VkFlags VkExternalMemoryHandleTypeFlagsNV; + +typedef enum VkExternalMemoryFeatureFlagBitsNV { + VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT_NV = 0x00000001, + VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT_NV = 0x00000002, + VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT_NV = 0x00000004, + VK_EXTERNAL_MEMORY_FEATURE_FLAG_BITS_MAX_ENUM_NV = 0x7FFFFFFF +} VkExternalMemoryFeatureFlagBitsNV; +typedef VkFlags VkExternalMemoryFeatureFlagsNV; +typedef struct VkExternalImageFormatPropertiesNV { + VkImageFormatProperties imageFormatProperties; + VkExternalMemoryFeatureFlagsNV externalMemoryFeatures; + VkExternalMemoryHandleTypeFlagsNV exportFromImportedHandleTypes; + VkExternalMemoryHandleTypeFlagsNV compatibleHandleTypes; +} VkExternalImageFormatPropertiesNV; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceExternalImageFormatPropertiesNV)(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkExternalMemoryHandleTypeFlagsNV externalHandleType, VkExternalImageFormatPropertiesNV* pExternalImageFormatProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceExternalImageFormatPropertiesNV( + VkPhysicalDevice physicalDevice, + VkFormat format, + VkImageType type, + VkImageTiling tiling, + VkImageUsageFlags usage, + VkImageCreateFlags flags, + VkExternalMemoryHandleTypeFlagsNV externalHandleType, + VkExternalImageFormatPropertiesNV* pExternalImageFormatProperties); +#endif + + +#define VK_NV_external_memory 1 +#define VK_NV_EXTERNAL_MEMORY_SPEC_VERSION 1 +#define VK_NV_EXTERNAL_MEMORY_EXTENSION_NAME "VK_NV_external_memory" +typedef struct VkExternalMemoryImageCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkExternalMemoryHandleTypeFlagsNV handleTypes; +} VkExternalMemoryImageCreateInfoNV; + +typedef struct VkExportMemoryAllocateInfoNV { + VkStructureType sType; + const void* pNext; + VkExternalMemoryHandleTypeFlagsNV handleTypes; +} VkExportMemoryAllocateInfoNV; + + + +#define VK_EXT_validation_flags 1 +#define VK_EXT_VALIDATION_FLAGS_SPEC_VERSION 2 +#define VK_EXT_VALIDATION_FLAGS_EXTENSION_NAME "VK_EXT_validation_flags" + +typedef enum VkValidationCheckEXT { + VK_VALIDATION_CHECK_ALL_EXT = 0, + VK_VALIDATION_CHECK_SHADERS_EXT = 1, + VK_VALIDATION_CHECK_BEGIN_RANGE_EXT = VK_VALIDATION_CHECK_ALL_EXT, + VK_VALIDATION_CHECK_END_RANGE_EXT = VK_VALIDATION_CHECK_SHADERS_EXT, + VK_VALIDATION_CHECK_RANGE_SIZE_EXT = (VK_VALIDATION_CHECK_SHADERS_EXT - VK_VALIDATION_CHECK_ALL_EXT + 1), + VK_VALIDATION_CHECK_MAX_ENUM_EXT = 0x7FFFFFFF +} VkValidationCheckEXT; +typedef struct VkValidationFlagsEXT { + VkStructureType sType; + const void* pNext; + uint32_t disabledValidationCheckCount; + const VkValidationCheckEXT* pDisabledValidationChecks; +} VkValidationFlagsEXT; + + + +#define VK_EXT_shader_subgroup_ballot 1 +#define VK_EXT_SHADER_SUBGROUP_BALLOT_SPEC_VERSION 1 +#define VK_EXT_SHADER_SUBGROUP_BALLOT_EXTENSION_NAME "VK_EXT_shader_subgroup_ballot" + + +#define VK_EXT_shader_subgroup_vote 1 +#define VK_EXT_SHADER_SUBGROUP_VOTE_SPEC_VERSION 1 +#define VK_EXT_SHADER_SUBGROUP_VOTE_EXTENSION_NAME "VK_EXT_shader_subgroup_vote" + + +#define VK_EXT_texture_compression_astc_hdr 1 +#define VK_EXT_TEXTURE_COMPRESSION_ASTC_HDR_SPEC_VERSION 1 +#define VK_EXT_TEXTURE_COMPRESSION_ASTC_HDR_EXTENSION_NAME "VK_EXT_texture_compression_astc_hdr" +typedef struct VkPhysicalDeviceTextureCompressionASTCHDRFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 textureCompressionASTC_HDR; +} VkPhysicalDeviceTextureCompressionASTCHDRFeaturesEXT; + + + +#define VK_EXT_astc_decode_mode 1 +#define VK_EXT_ASTC_DECODE_MODE_SPEC_VERSION 1 +#define VK_EXT_ASTC_DECODE_MODE_EXTENSION_NAME "VK_EXT_astc_decode_mode" +typedef struct VkImageViewASTCDecodeModeEXT { + VkStructureType sType; + const void* pNext; + VkFormat decodeMode; +} VkImageViewASTCDecodeModeEXT; + +typedef struct VkPhysicalDeviceASTCDecodeFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 decodeModeSharedExponent; +} VkPhysicalDeviceASTCDecodeFeaturesEXT; + + + +#define VK_EXT_conditional_rendering 1 +#define VK_EXT_CONDITIONAL_RENDERING_SPEC_VERSION 2 +#define VK_EXT_CONDITIONAL_RENDERING_EXTENSION_NAME "VK_EXT_conditional_rendering" + +typedef enum VkConditionalRenderingFlagBitsEXT { + VK_CONDITIONAL_RENDERING_INVERTED_BIT_EXT = 0x00000001, + VK_CONDITIONAL_RENDERING_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkConditionalRenderingFlagBitsEXT; +typedef VkFlags VkConditionalRenderingFlagsEXT; +typedef struct VkConditionalRenderingBeginInfoEXT { + VkStructureType sType; + const void* pNext; + VkBuffer buffer; + VkDeviceSize offset; + VkConditionalRenderingFlagsEXT flags; +} VkConditionalRenderingBeginInfoEXT; + +typedef struct VkPhysicalDeviceConditionalRenderingFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 conditionalRendering; + VkBool32 inheritedConditionalRendering; +} VkPhysicalDeviceConditionalRenderingFeaturesEXT; + +typedef struct VkCommandBufferInheritanceConditionalRenderingInfoEXT { + VkStructureType sType; + const void* pNext; + VkBool32 conditionalRenderingEnable; +} VkCommandBufferInheritanceConditionalRenderingInfoEXT; + +typedef void (VKAPI_PTR *PFN_vkCmdBeginConditionalRenderingEXT)(VkCommandBuffer commandBuffer, const VkConditionalRenderingBeginInfoEXT* pConditionalRenderingBegin); +typedef void (VKAPI_PTR *PFN_vkCmdEndConditionalRenderingEXT)(VkCommandBuffer commandBuffer); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdBeginConditionalRenderingEXT( + VkCommandBuffer commandBuffer, + const VkConditionalRenderingBeginInfoEXT* pConditionalRenderingBegin); + +VKAPI_ATTR void VKAPI_CALL vkCmdEndConditionalRenderingEXT( + VkCommandBuffer commandBuffer); +#endif + + +#define VK_NVX_device_generated_commands 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkObjectTableNVX) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkIndirectCommandsLayoutNVX) +#define VK_NVX_DEVICE_GENERATED_COMMANDS_SPEC_VERSION 3 +#define VK_NVX_DEVICE_GENERATED_COMMANDS_EXTENSION_NAME "VK_NVX_device_generated_commands" + +typedef enum VkIndirectCommandsTokenTypeNVX { + VK_INDIRECT_COMMANDS_TOKEN_TYPE_PIPELINE_NVX = 0, + VK_INDIRECT_COMMANDS_TOKEN_TYPE_DESCRIPTOR_SET_NVX = 1, + VK_INDIRECT_COMMANDS_TOKEN_TYPE_INDEX_BUFFER_NVX = 2, + VK_INDIRECT_COMMANDS_TOKEN_TYPE_VERTEX_BUFFER_NVX = 3, + VK_INDIRECT_COMMANDS_TOKEN_TYPE_PUSH_CONSTANT_NVX = 4, + VK_INDIRECT_COMMANDS_TOKEN_TYPE_DRAW_INDEXED_NVX = 5, + VK_INDIRECT_COMMANDS_TOKEN_TYPE_DRAW_NVX = 6, + VK_INDIRECT_COMMANDS_TOKEN_TYPE_DISPATCH_NVX = 7, + VK_INDIRECT_COMMANDS_TOKEN_TYPE_BEGIN_RANGE_NVX = VK_INDIRECT_COMMANDS_TOKEN_TYPE_PIPELINE_NVX, + VK_INDIRECT_COMMANDS_TOKEN_TYPE_END_RANGE_NVX = VK_INDIRECT_COMMANDS_TOKEN_TYPE_DISPATCH_NVX, + VK_INDIRECT_COMMANDS_TOKEN_TYPE_RANGE_SIZE_NVX = (VK_INDIRECT_COMMANDS_TOKEN_TYPE_DISPATCH_NVX - VK_INDIRECT_COMMANDS_TOKEN_TYPE_PIPELINE_NVX + 1), + VK_INDIRECT_COMMANDS_TOKEN_TYPE_MAX_ENUM_NVX = 0x7FFFFFFF +} VkIndirectCommandsTokenTypeNVX; + +typedef enum VkObjectEntryTypeNVX { + VK_OBJECT_ENTRY_TYPE_DESCRIPTOR_SET_NVX = 0, + VK_OBJECT_ENTRY_TYPE_PIPELINE_NVX = 1, + VK_OBJECT_ENTRY_TYPE_INDEX_BUFFER_NVX = 2, + VK_OBJECT_ENTRY_TYPE_VERTEX_BUFFER_NVX = 3, + VK_OBJECT_ENTRY_TYPE_PUSH_CONSTANT_NVX = 4, + VK_OBJECT_ENTRY_TYPE_BEGIN_RANGE_NVX = VK_OBJECT_ENTRY_TYPE_DESCRIPTOR_SET_NVX, + VK_OBJECT_ENTRY_TYPE_END_RANGE_NVX = VK_OBJECT_ENTRY_TYPE_PUSH_CONSTANT_NVX, + VK_OBJECT_ENTRY_TYPE_RANGE_SIZE_NVX = (VK_OBJECT_ENTRY_TYPE_PUSH_CONSTANT_NVX - VK_OBJECT_ENTRY_TYPE_DESCRIPTOR_SET_NVX + 1), + VK_OBJECT_ENTRY_TYPE_MAX_ENUM_NVX = 0x7FFFFFFF +} VkObjectEntryTypeNVX; + +typedef enum VkIndirectCommandsLayoutUsageFlagBitsNVX { + VK_INDIRECT_COMMANDS_LAYOUT_USAGE_UNORDERED_SEQUENCES_BIT_NVX = 0x00000001, + VK_INDIRECT_COMMANDS_LAYOUT_USAGE_SPARSE_SEQUENCES_BIT_NVX = 0x00000002, + VK_INDIRECT_COMMANDS_LAYOUT_USAGE_EMPTY_EXECUTIONS_BIT_NVX = 0x00000004, + VK_INDIRECT_COMMANDS_LAYOUT_USAGE_INDEXED_SEQUENCES_BIT_NVX = 0x00000008, + VK_INDIRECT_COMMANDS_LAYOUT_USAGE_FLAG_BITS_MAX_ENUM_NVX = 0x7FFFFFFF +} VkIndirectCommandsLayoutUsageFlagBitsNVX; +typedef VkFlags VkIndirectCommandsLayoutUsageFlagsNVX; + +typedef enum VkObjectEntryUsageFlagBitsNVX { + VK_OBJECT_ENTRY_USAGE_GRAPHICS_BIT_NVX = 0x00000001, + VK_OBJECT_ENTRY_USAGE_COMPUTE_BIT_NVX = 0x00000002, + VK_OBJECT_ENTRY_USAGE_FLAG_BITS_MAX_ENUM_NVX = 0x7FFFFFFF +} VkObjectEntryUsageFlagBitsNVX; +typedef VkFlags VkObjectEntryUsageFlagsNVX; +typedef struct VkDeviceGeneratedCommandsFeaturesNVX { + VkStructureType sType; + const void* pNext; + VkBool32 computeBindingPointSupport; +} VkDeviceGeneratedCommandsFeaturesNVX; + +typedef struct VkDeviceGeneratedCommandsLimitsNVX { + VkStructureType sType; + const void* pNext; + uint32_t maxIndirectCommandsLayoutTokenCount; + uint32_t maxObjectEntryCounts; + uint32_t minSequenceCountBufferOffsetAlignment; + uint32_t minSequenceIndexBufferOffsetAlignment; + uint32_t minCommandsTokenBufferOffsetAlignment; +} VkDeviceGeneratedCommandsLimitsNVX; + +typedef struct VkIndirectCommandsTokenNVX { + VkIndirectCommandsTokenTypeNVX tokenType; + VkBuffer buffer; + VkDeviceSize offset; +} VkIndirectCommandsTokenNVX; + +typedef struct VkIndirectCommandsLayoutTokenNVX { + VkIndirectCommandsTokenTypeNVX tokenType; + uint32_t bindingUnit; + uint32_t dynamicCount; + uint32_t divisor; +} VkIndirectCommandsLayoutTokenNVX; + +typedef struct VkIndirectCommandsLayoutCreateInfoNVX { + VkStructureType sType; + const void* pNext; + VkPipelineBindPoint pipelineBindPoint; + VkIndirectCommandsLayoutUsageFlagsNVX flags; + uint32_t tokenCount; + const VkIndirectCommandsLayoutTokenNVX* pTokens; +} VkIndirectCommandsLayoutCreateInfoNVX; + +typedef struct VkCmdProcessCommandsInfoNVX { + VkStructureType sType; + const void* pNext; + VkObjectTableNVX objectTable; + VkIndirectCommandsLayoutNVX indirectCommandsLayout; + uint32_t indirectCommandsTokenCount; + const VkIndirectCommandsTokenNVX* pIndirectCommandsTokens; + uint32_t maxSequencesCount; + VkCommandBuffer targetCommandBuffer; + VkBuffer sequencesCountBuffer; + VkDeviceSize sequencesCountOffset; + VkBuffer sequencesIndexBuffer; + VkDeviceSize sequencesIndexOffset; +} VkCmdProcessCommandsInfoNVX; + +typedef struct VkCmdReserveSpaceForCommandsInfoNVX { + VkStructureType sType; + const void* pNext; + VkObjectTableNVX objectTable; + VkIndirectCommandsLayoutNVX indirectCommandsLayout; + uint32_t maxSequencesCount; +} VkCmdReserveSpaceForCommandsInfoNVX; + +typedef struct VkObjectTableCreateInfoNVX { + VkStructureType sType; + const void* pNext; + uint32_t objectCount; + const VkObjectEntryTypeNVX* pObjectEntryTypes; + const uint32_t* pObjectEntryCounts; + const VkObjectEntryUsageFlagsNVX* pObjectEntryUsageFlags; + uint32_t maxUniformBuffersPerDescriptor; + uint32_t maxStorageBuffersPerDescriptor; + uint32_t maxStorageImagesPerDescriptor; + uint32_t maxSampledImagesPerDescriptor; + uint32_t maxPipelineLayouts; +} VkObjectTableCreateInfoNVX; + +typedef struct VkObjectTableEntryNVX { + VkObjectEntryTypeNVX type; + VkObjectEntryUsageFlagsNVX flags; +} VkObjectTableEntryNVX; + +typedef struct VkObjectTablePipelineEntryNVX { + VkObjectEntryTypeNVX type; + VkObjectEntryUsageFlagsNVX flags; + VkPipeline pipeline; +} VkObjectTablePipelineEntryNVX; + +typedef struct VkObjectTableDescriptorSetEntryNVX { + VkObjectEntryTypeNVX type; + VkObjectEntryUsageFlagsNVX flags; + VkPipelineLayout pipelineLayout; + VkDescriptorSet descriptorSet; +} VkObjectTableDescriptorSetEntryNVX; + +typedef struct VkObjectTableVertexBufferEntryNVX { + VkObjectEntryTypeNVX type; + VkObjectEntryUsageFlagsNVX flags; + VkBuffer buffer; +} VkObjectTableVertexBufferEntryNVX; + +typedef struct VkObjectTableIndexBufferEntryNVX { + VkObjectEntryTypeNVX type; + VkObjectEntryUsageFlagsNVX flags; + VkBuffer buffer; + VkIndexType indexType; +} VkObjectTableIndexBufferEntryNVX; + +typedef struct VkObjectTablePushConstantEntryNVX { + VkObjectEntryTypeNVX type; + VkObjectEntryUsageFlagsNVX flags; + VkPipelineLayout pipelineLayout; + VkShaderStageFlags stageFlags; +} VkObjectTablePushConstantEntryNVX; + +typedef void (VKAPI_PTR *PFN_vkCmdProcessCommandsNVX)(VkCommandBuffer commandBuffer, const VkCmdProcessCommandsInfoNVX* pProcessCommandsInfo); +typedef void (VKAPI_PTR *PFN_vkCmdReserveSpaceForCommandsNVX)(VkCommandBuffer commandBuffer, const VkCmdReserveSpaceForCommandsInfoNVX* pReserveSpaceInfo); +typedef VkResult (VKAPI_PTR *PFN_vkCreateIndirectCommandsLayoutNVX)(VkDevice device, const VkIndirectCommandsLayoutCreateInfoNVX* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkIndirectCommandsLayoutNVX* pIndirectCommandsLayout); +typedef void (VKAPI_PTR *PFN_vkDestroyIndirectCommandsLayoutNVX)(VkDevice device, VkIndirectCommandsLayoutNVX indirectCommandsLayout, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkCreateObjectTableNVX)(VkDevice device, const VkObjectTableCreateInfoNVX* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkObjectTableNVX* pObjectTable); +typedef void (VKAPI_PTR *PFN_vkDestroyObjectTableNVX)(VkDevice device, VkObjectTableNVX objectTable, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkRegisterObjectsNVX)(VkDevice device, VkObjectTableNVX objectTable, uint32_t objectCount, const VkObjectTableEntryNVX* const* ppObjectTableEntries, const uint32_t* pObjectIndices); +typedef VkResult (VKAPI_PTR *PFN_vkUnregisterObjectsNVX)(VkDevice device, VkObjectTableNVX objectTable, uint32_t objectCount, const VkObjectEntryTypeNVX* pObjectEntryTypes, const uint32_t* pObjectIndices); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX)(VkPhysicalDevice physicalDevice, VkDeviceGeneratedCommandsFeaturesNVX* pFeatures, VkDeviceGeneratedCommandsLimitsNVX* pLimits); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdProcessCommandsNVX( + VkCommandBuffer commandBuffer, + const VkCmdProcessCommandsInfoNVX* pProcessCommandsInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdReserveSpaceForCommandsNVX( + VkCommandBuffer commandBuffer, + const VkCmdReserveSpaceForCommandsInfoNVX* pReserveSpaceInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateIndirectCommandsLayoutNVX( + VkDevice device, + const VkIndirectCommandsLayoutCreateInfoNVX* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkIndirectCommandsLayoutNVX* pIndirectCommandsLayout); + +VKAPI_ATTR void VKAPI_CALL vkDestroyIndirectCommandsLayoutNVX( + VkDevice device, + VkIndirectCommandsLayoutNVX indirectCommandsLayout, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateObjectTableNVX( + VkDevice device, + const VkObjectTableCreateInfoNVX* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkObjectTableNVX* pObjectTable); + +VKAPI_ATTR void VKAPI_CALL vkDestroyObjectTableNVX( + VkDevice device, + VkObjectTableNVX objectTable, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkRegisterObjectsNVX( + VkDevice device, + VkObjectTableNVX objectTable, + uint32_t objectCount, + const VkObjectTableEntryNVX* const* ppObjectTableEntries, + const uint32_t* pObjectIndices); + +VKAPI_ATTR VkResult VKAPI_CALL vkUnregisterObjectsNVX( + VkDevice device, + VkObjectTableNVX objectTable, + uint32_t objectCount, + const VkObjectEntryTypeNVX* pObjectEntryTypes, + const uint32_t* pObjectIndices); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX( + VkPhysicalDevice physicalDevice, + VkDeviceGeneratedCommandsFeaturesNVX* pFeatures, + VkDeviceGeneratedCommandsLimitsNVX* pLimits); +#endif + + +#define VK_NV_clip_space_w_scaling 1 +#define VK_NV_CLIP_SPACE_W_SCALING_SPEC_VERSION 1 +#define VK_NV_CLIP_SPACE_W_SCALING_EXTENSION_NAME "VK_NV_clip_space_w_scaling" +typedef struct VkViewportWScalingNV { + float xcoeff; + float ycoeff; +} VkViewportWScalingNV; + +typedef struct VkPipelineViewportWScalingStateCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkBool32 viewportWScalingEnable; + uint32_t viewportCount; + const VkViewportWScalingNV* pViewportWScalings; +} VkPipelineViewportWScalingStateCreateInfoNV; + +typedef void (VKAPI_PTR *PFN_vkCmdSetViewportWScalingNV)(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewportWScalingNV* pViewportWScalings); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdSetViewportWScalingNV( + VkCommandBuffer commandBuffer, + uint32_t firstViewport, + uint32_t viewportCount, + const VkViewportWScalingNV* pViewportWScalings); +#endif + + +#define VK_EXT_direct_mode_display 1 +#define VK_EXT_DIRECT_MODE_DISPLAY_SPEC_VERSION 1 +#define VK_EXT_DIRECT_MODE_DISPLAY_EXTENSION_NAME "VK_EXT_direct_mode_display" +typedef VkResult (VKAPI_PTR *PFN_vkReleaseDisplayEXT)(VkPhysicalDevice physicalDevice, VkDisplayKHR display); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkReleaseDisplayEXT( + VkPhysicalDevice physicalDevice, + VkDisplayKHR display); +#endif + + +#define VK_EXT_display_surface_counter 1 +#define VK_EXT_DISPLAY_SURFACE_COUNTER_SPEC_VERSION 1 +#define VK_EXT_DISPLAY_SURFACE_COUNTER_EXTENSION_NAME "VK_EXT_display_surface_counter" + +typedef enum VkSurfaceCounterFlagBitsEXT { + VK_SURFACE_COUNTER_VBLANK_EXT = 0x00000001, + VK_SURFACE_COUNTER_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkSurfaceCounterFlagBitsEXT; +typedef VkFlags VkSurfaceCounterFlagsEXT; +typedef struct VkSurfaceCapabilities2EXT { + VkStructureType sType; + void* pNext; + uint32_t minImageCount; + uint32_t maxImageCount; + VkExtent2D currentExtent; + VkExtent2D minImageExtent; + VkExtent2D maxImageExtent; + uint32_t maxImageArrayLayers; + VkSurfaceTransformFlagsKHR supportedTransforms; + VkSurfaceTransformFlagBitsKHR currentTransform; + VkCompositeAlphaFlagsKHR supportedCompositeAlpha; + VkImageUsageFlags supportedUsageFlags; + VkSurfaceCounterFlagsEXT supportedSurfaceCounters; +} VkSurfaceCapabilities2EXT; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfaceCapabilities2EXT)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilities2EXT* pSurfaceCapabilities); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilities2EXT( + VkPhysicalDevice physicalDevice, + VkSurfaceKHR surface, + VkSurfaceCapabilities2EXT* pSurfaceCapabilities); +#endif + + +#define VK_EXT_display_control 1 +#define VK_EXT_DISPLAY_CONTROL_SPEC_VERSION 1 +#define VK_EXT_DISPLAY_CONTROL_EXTENSION_NAME "VK_EXT_display_control" + +typedef enum VkDisplayPowerStateEXT { + VK_DISPLAY_POWER_STATE_OFF_EXT = 0, + VK_DISPLAY_POWER_STATE_SUSPEND_EXT = 1, + VK_DISPLAY_POWER_STATE_ON_EXT = 2, + VK_DISPLAY_POWER_STATE_BEGIN_RANGE_EXT = VK_DISPLAY_POWER_STATE_OFF_EXT, + VK_DISPLAY_POWER_STATE_END_RANGE_EXT = VK_DISPLAY_POWER_STATE_ON_EXT, + VK_DISPLAY_POWER_STATE_RANGE_SIZE_EXT = (VK_DISPLAY_POWER_STATE_ON_EXT - VK_DISPLAY_POWER_STATE_OFF_EXT + 1), + VK_DISPLAY_POWER_STATE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkDisplayPowerStateEXT; + +typedef enum VkDeviceEventTypeEXT { + VK_DEVICE_EVENT_TYPE_DISPLAY_HOTPLUG_EXT = 0, + VK_DEVICE_EVENT_TYPE_BEGIN_RANGE_EXT = VK_DEVICE_EVENT_TYPE_DISPLAY_HOTPLUG_EXT, + VK_DEVICE_EVENT_TYPE_END_RANGE_EXT = VK_DEVICE_EVENT_TYPE_DISPLAY_HOTPLUG_EXT, + VK_DEVICE_EVENT_TYPE_RANGE_SIZE_EXT = (VK_DEVICE_EVENT_TYPE_DISPLAY_HOTPLUG_EXT - VK_DEVICE_EVENT_TYPE_DISPLAY_HOTPLUG_EXT + 1), + VK_DEVICE_EVENT_TYPE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkDeviceEventTypeEXT; + +typedef enum VkDisplayEventTypeEXT { + VK_DISPLAY_EVENT_TYPE_FIRST_PIXEL_OUT_EXT = 0, + VK_DISPLAY_EVENT_TYPE_BEGIN_RANGE_EXT = VK_DISPLAY_EVENT_TYPE_FIRST_PIXEL_OUT_EXT, + VK_DISPLAY_EVENT_TYPE_END_RANGE_EXT = VK_DISPLAY_EVENT_TYPE_FIRST_PIXEL_OUT_EXT, + VK_DISPLAY_EVENT_TYPE_RANGE_SIZE_EXT = (VK_DISPLAY_EVENT_TYPE_FIRST_PIXEL_OUT_EXT - VK_DISPLAY_EVENT_TYPE_FIRST_PIXEL_OUT_EXT + 1), + VK_DISPLAY_EVENT_TYPE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkDisplayEventTypeEXT; +typedef struct VkDisplayPowerInfoEXT { + VkStructureType sType; + const void* pNext; + VkDisplayPowerStateEXT powerState; +} VkDisplayPowerInfoEXT; + +typedef struct VkDeviceEventInfoEXT { + VkStructureType sType; + const void* pNext; + VkDeviceEventTypeEXT deviceEvent; +} VkDeviceEventInfoEXT; + +typedef struct VkDisplayEventInfoEXT { + VkStructureType sType; + const void* pNext; + VkDisplayEventTypeEXT displayEvent; +} VkDisplayEventInfoEXT; + +typedef struct VkSwapchainCounterCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkSurfaceCounterFlagsEXT surfaceCounters; +} VkSwapchainCounterCreateInfoEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkDisplayPowerControlEXT)(VkDevice device, VkDisplayKHR display, const VkDisplayPowerInfoEXT* pDisplayPowerInfo); +typedef VkResult (VKAPI_PTR *PFN_vkRegisterDeviceEventEXT)(VkDevice device, const VkDeviceEventInfoEXT* pDeviceEventInfo, const VkAllocationCallbacks* pAllocator, VkFence* pFence); +typedef VkResult (VKAPI_PTR *PFN_vkRegisterDisplayEventEXT)(VkDevice device, VkDisplayKHR display, const VkDisplayEventInfoEXT* pDisplayEventInfo, const VkAllocationCallbacks* pAllocator, VkFence* pFence); +typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainCounterEXT)(VkDevice device, VkSwapchainKHR swapchain, VkSurfaceCounterFlagBitsEXT counter, uint64_t* pCounterValue); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkDisplayPowerControlEXT( + VkDevice device, + VkDisplayKHR display, + const VkDisplayPowerInfoEXT* pDisplayPowerInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkRegisterDeviceEventEXT( + VkDevice device, + const VkDeviceEventInfoEXT* pDeviceEventInfo, + const VkAllocationCallbacks* pAllocator, + VkFence* pFence); + +VKAPI_ATTR VkResult VKAPI_CALL vkRegisterDisplayEventEXT( + VkDevice device, + VkDisplayKHR display, + const VkDisplayEventInfoEXT* pDisplayEventInfo, + const VkAllocationCallbacks* pAllocator, + VkFence* pFence); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainCounterEXT( + VkDevice device, + VkSwapchainKHR swapchain, + VkSurfaceCounterFlagBitsEXT counter, + uint64_t* pCounterValue); +#endif + + +#define VK_GOOGLE_display_timing 1 +#define VK_GOOGLE_DISPLAY_TIMING_SPEC_VERSION 1 +#define VK_GOOGLE_DISPLAY_TIMING_EXTENSION_NAME "VK_GOOGLE_display_timing" +typedef struct VkRefreshCycleDurationGOOGLE { + uint64_t refreshDuration; +} VkRefreshCycleDurationGOOGLE; + +typedef struct VkPastPresentationTimingGOOGLE { + uint32_t presentID; + uint64_t desiredPresentTime; + uint64_t actualPresentTime; + uint64_t earliestPresentTime; + uint64_t presentMargin; +} VkPastPresentationTimingGOOGLE; + +typedef struct VkPresentTimeGOOGLE { + uint32_t presentID; + uint64_t desiredPresentTime; +} VkPresentTimeGOOGLE; + +typedef struct VkPresentTimesInfoGOOGLE { + VkStructureType sType; + const void* pNext; + uint32_t swapchainCount; + const VkPresentTimeGOOGLE* pTimes; +} VkPresentTimesInfoGOOGLE; + +typedef VkResult (VKAPI_PTR *PFN_vkGetRefreshCycleDurationGOOGLE)(VkDevice device, VkSwapchainKHR swapchain, VkRefreshCycleDurationGOOGLE* pDisplayTimingProperties); +typedef VkResult (VKAPI_PTR *PFN_vkGetPastPresentationTimingGOOGLE)(VkDevice device, VkSwapchainKHR swapchain, uint32_t* pPresentationTimingCount, VkPastPresentationTimingGOOGLE* pPresentationTimings); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetRefreshCycleDurationGOOGLE( + VkDevice device, + VkSwapchainKHR swapchain, + VkRefreshCycleDurationGOOGLE* pDisplayTimingProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPastPresentationTimingGOOGLE( + VkDevice device, + VkSwapchainKHR swapchain, + uint32_t* pPresentationTimingCount, + VkPastPresentationTimingGOOGLE* pPresentationTimings); +#endif + + +#define VK_NV_sample_mask_override_coverage 1 +#define VK_NV_SAMPLE_MASK_OVERRIDE_COVERAGE_SPEC_VERSION 1 +#define VK_NV_SAMPLE_MASK_OVERRIDE_COVERAGE_EXTENSION_NAME "VK_NV_sample_mask_override_coverage" + + +#define VK_NV_geometry_shader_passthrough 1 +#define VK_NV_GEOMETRY_SHADER_PASSTHROUGH_SPEC_VERSION 1 +#define VK_NV_GEOMETRY_SHADER_PASSTHROUGH_EXTENSION_NAME "VK_NV_geometry_shader_passthrough" + + +#define VK_NV_viewport_array2 1 +#define VK_NV_VIEWPORT_ARRAY2_SPEC_VERSION 1 +#define VK_NV_VIEWPORT_ARRAY2_EXTENSION_NAME "VK_NV_viewport_array2" + + +#define VK_NVX_multiview_per_view_attributes 1 +#define VK_NVX_MULTIVIEW_PER_VIEW_ATTRIBUTES_SPEC_VERSION 1 +#define VK_NVX_MULTIVIEW_PER_VIEW_ATTRIBUTES_EXTENSION_NAME "VK_NVX_multiview_per_view_attributes" +typedef struct VkPhysicalDeviceMultiviewPerViewAttributesPropertiesNVX { + VkStructureType sType; + void* pNext; + VkBool32 perViewPositionAllComponents; +} VkPhysicalDeviceMultiviewPerViewAttributesPropertiesNVX; + + + +#define VK_NV_viewport_swizzle 1 +#define VK_NV_VIEWPORT_SWIZZLE_SPEC_VERSION 1 +#define VK_NV_VIEWPORT_SWIZZLE_EXTENSION_NAME "VK_NV_viewport_swizzle" + +typedef enum VkViewportCoordinateSwizzleNV { + VK_VIEWPORT_COORDINATE_SWIZZLE_POSITIVE_X_NV = 0, + VK_VIEWPORT_COORDINATE_SWIZZLE_NEGATIVE_X_NV = 1, + VK_VIEWPORT_COORDINATE_SWIZZLE_POSITIVE_Y_NV = 2, + VK_VIEWPORT_COORDINATE_SWIZZLE_NEGATIVE_Y_NV = 3, + VK_VIEWPORT_COORDINATE_SWIZZLE_POSITIVE_Z_NV = 4, + VK_VIEWPORT_COORDINATE_SWIZZLE_NEGATIVE_Z_NV = 5, + VK_VIEWPORT_COORDINATE_SWIZZLE_POSITIVE_W_NV = 6, + VK_VIEWPORT_COORDINATE_SWIZZLE_NEGATIVE_W_NV = 7, + VK_VIEWPORT_COORDINATE_SWIZZLE_BEGIN_RANGE_NV = VK_VIEWPORT_COORDINATE_SWIZZLE_POSITIVE_X_NV, + VK_VIEWPORT_COORDINATE_SWIZZLE_END_RANGE_NV = VK_VIEWPORT_COORDINATE_SWIZZLE_NEGATIVE_W_NV, + VK_VIEWPORT_COORDINATE_SWIZZLE_RANGE_SIZE_NV = (VK_VIEWPORT_COORDINATE_SWIZZLE_NEGATIVE_W_NV - VK_VIEWPORT_COORDINATE_SWIZZLE_POSITIVE_X_NV + 1), + VK_VIEWPORT_COORDINATE_SWIZZLE_MAX_ENUM_NV = 0x7FFFFFFF +} VkViewportCoordinateSwizzleNV; +typedef VkFlags VkPipelineViewportSwizzleStateCreateFlagsNV; +typedef struct VkViewportSwizzleNV { + VkViewportCoordinateSwizzleNV x; + VkViewportCoordinateSwizzleNV y; + VkViewportCoordinateSwizzleNV z; + VkViewportCoordinateSwizzleNV w; +} VkViewportSwizzleNV; + +typedef struct VkPipelineViewportSwizzleStateCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkPipelineViewportSwizzleStateCreateFlagsNV flags; + uint32_t viewportCount; + const VkViewportSwizzleNV* pViewportSwizzles; +} VkPipelineViewportSwizzleStateCreateInfoNV; + + + +#define VK_EXT_discard_rectangles 1 +#define VK_EXT_DISCARD_RECTANGLES_SPEC_VERSION 1 +#define VK_EXT_DISCARD_RECTANGLES_EXTENSION_NAME "VK_EXT_discard_rectangles" + +typedef enum VkDiscardRectangleModeEXT { + VK_DISCARD_RECTANGLE_MODE_INCLUSIVE_EXT = 0, + VK_DISCARD_RECTANGLE_MODE_EXCLUSIVE_EXT = 1, + VK_DISCARD_RECTANGLE_MODE_BEGIN_RANGE_EXT = VK_DISCARD_RECTANGLE_MODE_INCLUSIVE_EXT, + VK_DISCARD_RECTANGLE_MODE_END_RANGE_EXT = VK_DISCARD_RECTANGLE_MODE_EXCLUSIVE_EXT, + VK_DISCARD_RECTANGLE_MODE_RANGE_SIZE_EXT = (VK_DISCARD_RECTANGLE_MODE_EXCLUSIVE_EXT - VK_DISCARD_RECTANGLE_MODE_INCLUSIVE_EXT + 1), + VK_DISCARD_RECTANGLE_MODE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkDiscardRectangleModeEXT; +typedef VkFlags VkPipelineDiscardRectangleStateCreateFlagsEXT; +typedef struct VkPhysicalDeviceDiscardRectanglePropertiesEXT { + VkStructureType sType; + void* pNext; + uint32_t maxDiscardRectangles; +} VkPhysicalDeviceDiscardRectanglePropertiesEXT; + +typedef struct VkPipelineDiscardRectangleStateCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkPipelineDiscardRectangleStateCreateFlagsEXT flags; + VkDiscardRectangleModeEXT discardRectangleMode; + uint32_t discardRectangleCount; + const VkRect2D* pDiscardRectangles; +} VkPipelineDiscardRectangleStateCreateInfoEXT; + +typedef void (VKAPI_PTR *PFN_vkCmdSetDiscardRectangleEXT)(VkCommandBuffer commandBuffer, uint32_t firstDiscardRectangle, uint32_t discardRectangleCount, const VkRect2D* pDiscardRectangles); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdSetDiscardRectangleEXT( + VkCommandBuffer commandBuffer, + uint32_t firstDiscardRectangle, + uint32_t discardRectangleCount, + const VkRect2D* pDiscardRectangles); +#endif + + +#define VK_EXT_conservative_rasterization 1 +#define VK_EXT_CONSERVATIVE_RASTERIZATION_SPEC_VERSION 1 +#define VK_EXT_CONSERVATIVE_RASTERIZATION_EXTENSION_NAME "VK_EXT_conservative_rasterization" + +typedef enum VkConservativeRasterizationModeEXT { + VK_CONSERVATIVE_RASTERIZATION_MODE_DISABLED_EXT = 0, + VK_CONSERVATIVE_RASTERIZATION_MODE_OVERESTIMATE_EXT = 1, + VK_CONSERVATIVE_RASTERIZATION_MODE_UNDERESTIMATE_EXT = 2, + VK_CONSERVATIVE_RASTERIZATION_MODE_BEGIN_RANGE_EXT = VK_CONSERVATIVE_RASTERIZATION_MODE_DISABLED_EXT, + VK_CONSERVATIVE_RASTERIZATION_MODE_END_RANGE_EXT = VK_CONSERVATIVE_RASTERIZATION_MODE_UNDERESTIMATE_EXT, + VK_CONSERVATIVE_RASTERIZATION_MODE_RANGE_SIZE_EXT = (VK_CONSERVATIVE_RASTERIZATION_MODE_UNDERESTIMATE_EXT - VK_CONSERVATIVE_RASTERIZATION_MODE_DISABLED_EXT + 1), + VK_CONSERVATIVE_RASTERIZATION_MODE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkConservativeRasterizationModeEXT; +typedef VkFlags VkPipelineRasterizationConservativeStateCreateFlagsEXT; +typedef struct VkPhysicalDeviceConservativeRasterizationPropertiesEXT { + VkStructureType sType; + void* pNext; + float primitiveOverestimationSize; + float maxExtraPrimitiveOverestimationSize; + float extraPrimitiveOverestimationSizeGranularity; + VkBool32 primitiveUnderestimation; + VkBool32 conservativePointAndLineRasterization; + VkBool32 degenerateTrianglesRasterized; + VkBool32 degenerateLinesRasterized; + VkBool32 fullyCoveredFragmentShaderInputVariable; + VkBool32 conservativeRasterizationPostDepthCoverage; +} VkPhysicalDeviceConservativeRasterizationPropertiesEXT; + +typedef struct VkPipelineRasterizationConservativeStateCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkPipelineRasterizationConservativeStateCreateFlagsEXT flags; + VkConservativeRasterizationModeEXT conservativeRasterizationMode; + float extraPrimitiveOverestimationSize; +} VkPipelineRasterizationConservativeStateCreateInfoEXT; + + + +#define VK_EXT_depth_clip_enable 1 +#define VK_EXT_DEPTH_CLIP_ENABLE_SPEC_VERSION 1 +#define VK_EXT_DEPTH_CLIP_ENABLE_EXTENSION_NAME "VK_EXT_depth_clip_enable" +typedef VkFlags VkPipelineRasterizationDepthClipStateCreateFlagsEXT; +typedef struct VkPhysicalDeviceDepthClipEnableFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 depthClipEnable; +} VkPhysicalDeviceDepthClipEnableFeaturesEXT; + +typedef struct VkPipelineRasterizationDepthClipStateCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkPipelineRasterizationDepthClipStateCreateFlagsEXT flags; + VkBool32 depthClipEnable; +} VkPipelineRasterizationDepthClipStateCreateInfoEXT; + + + +#define VK_EXT_swapchain_colorspace 1 +#define VK_EXT_SWAPCHAIN_COLOR_SPACE_SPEC_VERSION 4 +#define VK_EXT_SWAPCHAIN_COLOR_SPACE_EXTENSION_NAME "VK_EXT_swapchain_colorspace" + + +#define VK_EXT_hdr_metadata 1 +#define VK_EXT_HDR_METADATA_SPEC_VERSION 2 +#define VK_EXT_HDR_METADATA_EXTENSION_NAME "VK_EXT_hdr_metadata" +typedef struct VkXYColorEXT { + float x; + float y; +} VkXYColorEXT; + +typedef struct VkHdrMetadataEXT { + VkStructureType sType; + const void* pNext; + VkXYColorEXT displayPrimaryRed; + VkXYColorEXT displayPrimaryGreen; + VkXYColorEXT displayPrimaryBlue; + VkXYColorEXT whitePoint; + float maxLuminance; + float minLuminance; + float maxContentLightLevel; + float maxFrameAverageLightLevel; +} VkHdrMetadataEXT; + +typedef void (VKAPI_PTR *PFN_vkSetHdrMetadataEXT)(VkDevice device, uint32_t swapchainCount, const VkSwapchainKHR* pSwapchains, const VkHdrMetadataEXT* pMetadata); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkSetHdrMetadataEXT( + VkDevice device, + uint32_t swapchainCount, + const VkSwapchainKHR* pSwapchains, + const VkHdrMetadataEXT* pMetadata); +#endif + + +#define VK_EXT_external_memory_dma_buf 1 +#define VK_EXT_EXTERNAL_MEMORY_DMA_BUF_SPEC_VERSION 1 +#define VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME "VK_EXT_external_memory_dma_buf" + + +#define VK_EXT_queue_family_foreign 1 +#define VK_EXT_QUEUE_FAMILY_FOREIGN_SPEC_VERSION 1 +#define VK_EXT_QUEUE_FAMILY_FOREIGN_EXTENSION_NAME "VK_EXT_queue_family_foreign" +#define VK_QUEUE_FAMILY_FOREIGN_EXT (~0U-2) + + +#define VK_EXT_debug_utils 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDebugUtilsMessengerEXT) +#define VK_EXT_DEBUG_UTILS_SPEC_VERSION 1 +#define VK_EXT_DEBUG_UTILS_EXTENSION_NAME "VK_EXT_debug_utils" +typedef VkFlags VkDebugUtilsMessengerCallbackDataFlagsEXT; +typedef VkFlags VkDebugUtilsMessengerCreateFlagsEXT; + +typedef enum VkDebugUtilsMessageSeverityFlagBitsEXT { + VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT = 0x00000001, + VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT = 0x00000010, + VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT = 0x00000100, + VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT = 0x00001000, + VK_DEBUG_UTILS_MESSAGE_SEVERITY_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkDebugUtilsMessageSeverityFlagBitsEXT; +typedef VkFlags VkDebugUtilsMessageSeverityFlagsEXT; + +typedef enum VkDebugUtilsMessageTypeFlagBitsEXT { + VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT = 0x00000001, + VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT = 0x00000002, + VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT = 0x00000004, + VK_DEBUG_UTILS_MESSAGE_TYPE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkDebugUtilsMessageTypeFlagBitsEXT; +typedef VkFlags VkDebugUtilsMessageTypeFlagsEXT; +typedef struct VkDebugUtilsObjectNameInfoEXT { + VkStructureType sType; + const void* pNext; + VkObjectType objectType; + uint64_t objectHandle; + const char* pObjectName; +} VkDebugUtilsObjectNameInfoEXT; + +typedef struct VkDebugUtilsObjectTagInfoEXT { + VkStructureType sType; + const void* pNext; + VkObjectType objectType; + uint64_t objectHandle; + uint64_t tagName; + size_t tagSize; + const void* pTag; +} VkDebugUtilsObjectTagInfoEXT; + +typedef struct VkDebugUtilsLabelEXT { + VkStructureType sType; + const void* pNext; + const char* pLabelName; + float color[4]; +} VkDebugUtilsLabelEXT; + +typedef struct VkDebugUtilsMessengerCallbackDataEXT { + VkStructureType sType; + const void* pNext; + VkDebugUtilsMessengerCallbackDataFlagsEXT flags; + const char* pMessageIdName; + int32_t messageIdNumber; + const char* pMessage; + uint32_t queueLabelCount; + const VkDebugUtilsLabelEXT* pQueueLabels; + uint32_t cmdBufLabelCount; + const VkDebugUtilsLabelEXT* pCmdBufLabels; + uint32_t objectCount; + const VkDebugUtilsObjectNameInfoEXT* pObjects; +} VkDebugUtilsMessengerCallbackDataEXT; + +typedef VkBool32 (VKAPI_PTR *PFN_vkDebugUtilsMessengerCallbackEXT)( + VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, + VkDebugUtilsMessageTypeFlagsEXT messageTypes, + const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, + void* pUserData); + +typedef struct VkDebugUtilsMessengerCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkDebugUtilsMessengerCreateFlagsEXT flags; + VkDebugUtilsMessageSeverityFlagsEXT messageSeverity; + VkDebugUtilsMessageTypeFlagsEXT messageType; + PFN_vkDebugUtilsMessengerCallbackEXT pfnUserCallback; + void* pUserData; +} VkDebugUtilsMessengerCreateInfoEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkSetDebugUtilsObjectNameEXT)(VkDevice device, const VkDebugUtilsObjectNameInfoEXT* pNameInfo); +typedef VkResult (VKAPI_PTR *PFN_vkSetDebugUtilsObjectTagEXT)(VkDevice device, const VkDebugUtilsObjectTagInfoEXT* pTagInfo); +typedef void (VKAPI_PTR *PFN_vkQueueBeginDebugUtilsLabelEXT)(VkQueue queue, const VkDebugUtilsLabelEXT* pLabelInfo); +typedef void (VKAPI_PTR *PFN_vkQueueEndDebugUtilsLabelEXT)(VkQueue queue); +typedef void (VKAPI_PTR *PFN_vkQueueInsertDebugUtilsLabelEXT)(VkQueue queue, const VkDebugUtilsLabelEXT* pLabelInfo); +typedef void (VKAPI_PTR *PFN_vkCmdBeginDebugUtilsLabelEXT)(VkCommandBuffer commandBuffer, const VkDebugUtilsLabelEXT* pLabelInfo); +typedef void (VKAPI_PTR *PFN_vkCmdEndDebugUtilsLabelEXT)(VkCommandBuffer commandBuffer); +typedef void (VKAPI_PTR *PFN_vkCmdInsertDebugUtilsLabelEXT)(VkCommandBuffer commandBuffer, const VkDebugUtilsLabelEXT* pLabelInfo); +typedef VkResult (VKAPI_PTR *PFN_vkCreateDebugUtilsMessengerEXT)(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugUtilsMessengerEXT* pMessenger); +typedef void (VKAPI_PTR *PFN_vkDestroyDebugUtilsMessengerEXT)(VkInstance instance, VkDebugUtilsMessengerEXT messenger, const VkAllocationCallbacks* pAllocator); +typedef void (VKAPI_PTR *PFN_vkSubmitDebugUtilsMessageEXT)(VkInstance instance, VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageTypes, const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkSetDebugUtilsObjectNameEXT( + VkDevice device, + const VkDebugUtilsObjectNameInfoEXT* pNameInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkSetDebugUtilsObjectTagEXT( + VkDevice device, + const VkDebugUtilsObjectTagInfoEXT* pTagInfo); + +VKAPI_ATTR void VKAPI_CALL vkQueueBeginDebugUtilsLabelEXT( + VkQueue queue, + const VkDebugUtilsLabelEXT* pLabelInfo); + +VKAPI_ATTR void VKAPI_CALL vkQueueEndDebugUtilsLabelEXT( + VkQueue queue); + +VKAPI_ATTR void VKAPI_CALL vkQueueInsertDebugUtilsLabelEXT( + VkQueue queue, + const VkDebugUtilsLabelEXT* pLabelInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdBeginDebugUtilsLabelEXT( + VkCommandBuffer commandBuffer, + const VkDebugUtilsLabelEXT* pLabelInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdEndDebugUtilsLabelEXT( + VkCommandBuffer commandBuffer); + +VKAPI_ATTR void VKAPI_CALL vkCmdInsertDebugUtilsLabelEXT( + VkCommandBuffer commandBuffer, + const VkDebugUtilsLabelEXT* pLabelInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugUtilsMessengerEXT( + VkInstance instance, + const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkDebugUtilsMessengerEXT* pMessenger); + +VKAPI_ATTR void VKAPI_CALL vkDestroyDebugUtilsMessengerEXT( + VkInstance instance, + VkDebugUtilsMessengerEXT messenger, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR void VKAPI_CALL vkSubmitDebugUtilsMessageEXT( + VkInstance instance, + VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, + VkDebugUtilsMessageTypeFlagsEXT messageTypes, + const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData); +#endif + + +#define VK_EXT_sampler_filter_minmax 1 +#define VK_EXT_SAMPLER_FILTER_MINMAX_SPEC_VERSION 2 +#define VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME "VK_EXT_sampler_filter_minmax" +typedef VkSamplerReductionMode VkSamplerReductionModeEXT; + +typedef VkSamplerReductionModeCreateInfo VkSamplerReductionModeCreateInfoEXT; + +typedef VkPhysicalDeviceSamplerFilterMinmaxProperties VkPhysicalDeviceSamplerFilterMinmaxPropertiesEXT; + + + +#define VK_AMD_gpu_shader_int16 1 +#define VK_AMD_GPU_SHADER_INT16_SPEC_VERSION 2 +#define VK_AMD_GPU_SHADER_INT16_EXTENSION_NAME "VK_AMD_gpu_shader_int16" + + +#define VK_AMD_mixed_attachment_samples 1 +#define VK_AMD_MIXED_ATTACHMENT_SAMPLES_SPEC_VERSION 1 +#define VK_AMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME "VK_AMD_mixed_attachment_samples" + + +#define VK_AMD_shader_fragment_mask 1 +#define VK_AMD_SHADER_FRAGMENT_MASK_SPEC_VERSION 1 +#define VK_AMD_SHADER_FRAGMENT_MASK_EXTENSION_NAME "VK_AMD_shader_fragment_mask" + + +#define VK_EXT_inline_uniform_block 1 +#define VK_EXT_INLINE_UNIFORM_BLOCK_SPEC_VERSION 1 +#define VK_EXT_INLINE_UNIFORM_BLOCK_EXTENSION_NAME "VK_EXT_inline_uniform_block" +typedef struct VkPhysicalDeviceInlineUniformBlockFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 inlineUniformBlock; + VkBool32 descriptorBindingInlineUniformBlockUpdateAfterBind; +} VkPhysicalDeviceInlineUniformBlockFeaturesEXT; + +typedef struct VkPhysicalDeviceInlineUniformBlockPropertiesEXT { + VkStructureType sType; + void* pNext; + uint32_t maxInlineUniformBlockSize; + uint32_t maxPerStageDescriptorInlineUniformBlocks; + uint32_t maxPerStageDescriptorUpdateAfterBindInlineUniformBlocks; + uint32_t maxDescriptorSetInlineUniformBlocks; + uint32_t maxDescriptorSetUpdateAfterBindInlineUniformBlocks; +} VkPhysicalDeviceInlineUniformBlockPropertiesEXT; + +typedef struct VkWriteDescriptorSetInlineUniformBlockEXT { + VkStructureType sType; + const void* pNext; + uint32_t dataSize; + const void* pData; +} VkWriteDescriptorSetInlineUniformBlockEXT; + +typedef struct VkDescriptorPoolInlineUniformBlockCreateInfoEXT { + VkStructureType sType; + const void* pNext; + uint32_t maxInlineUniformBlockBindings; +} VkDescriptorPoolInlineUniformBlockCreateInfoEXT; + + + +#define VK_EXT_shader_stencil_export 1 +#define VK_EXT_SHADER_STENCIL_EXPORT_SPEC_VERSION 1 +#define VK_EXT_SHADER_STENCIL_EXPORT_EXTENSION_NAME "VK_EXT_shader_stencil_export" + + +#define VK_EXT_sample_locations 1 +#define VK_EXT_SAMPLE_LOCATIONS_SPEC_VERSION 1 +#define VK_EXT_SAMPLE_LOCATIONS_EXTENSION_NAME "VK_EXT_sample_locations" +typedef struct VkSampleLocationEXT { + float x; + float y; +} VkSampleLocationEXT; + +typedef struct VkSampleLocationsInfoEXT { + VkStructureType sType; + const void* pNext; + VkSampleCountFlagBits sampleLocationsPerPixel; + VkExtent2D sampleLocationGridSize; + uint32_t sampleLocationsCount; + const VkSampleLocationEXT* pSampleLocations; +} VkSampleLocationsInfoEXT; + +typedef struct VkAttachmentSampleLocationsEXT { + uint32_t attachmentIndex; + VkSampleLocationsInfoEXT sampleLocationsInfo; +} VkAttachmentSampleLocationsEXT; + +typedef struct VkSubpassSampleLocationsEXT { + uint32_t subpassIndex; + VkSampleLocationsInfoEXT sampleLocationsInfo; +} VkSubpassSampleLocationsEXT; + +typedef struct VkRenderPassSampleLocationsBeginInfoEXT { + VkStructureType sType; + const void* pNext; + uint32_t attachmentInitialSampleLocationsCount; + const VkAttachmentSampleLocationsEXT* pAttachmentInitialSampleLocations; + uint32_t postSubpassSampleLocationsCount; + const VkSubpassSampleLocationsEXT* pPostSubpassSampleLocations; +} VkRenderPassSampleLocationsBeginInfoEXT; + +typedef struct VkPipelineSampleLocationsStateCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkBool32 sampleLocationsEnable; + VkSampleLocationsInfoEXT sampleLocationsInfo; +} VkPipelineSampleLocationsStateCreateInfoEXT; + +typedef struct VkPhysicalDeviceSampleLocationsPropertiesEXT { + VkStructureType sType; + void* pNext; + VkSampleCountFlags sampleLocationSampleCounts; + VkExtent2D maxSampleLocationGridSize; + float sampleLocationCoordinateRange[2]; + uint32_t sampleLocationSubPixelBits; + VkBool32 variableSampleLocations; +} VkPhysicalDeviceSampleLocationsPropertiesEXT; + +typedef struct VkMultisamplePropertiesEXT { + VkStructureType sType; + void* pNext; + VkExtent2D maxSampleLocationGridSize; +} VkMultisamplePropertiesEXT; + +typedef void (VKAPI_PTR *PFN_vkCmdSetSampleLocationsEXT)(VkCommandBuffer commandBuffer, const VkSampleLocationsInfoEXT* pSampleLocationsInfo); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceMultisamplePropertiesEXT)(VkPhysicalDevice physicalDevice, VkSampleCountFlagBits samples, VkMultisamplePropertiesEXT* pMultisampleProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdSetSampleLocationsEXT( + VkCommandBuffer commandBuffer, + const VkSampleLocationsInfoEXT* pSampleLocationsInfo); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMultisamplePropertiesEXT( + VkPhysicalDevice physicalDevice, + VkSampleCountFlagBits samples, + VkMultisamplePropertiesEXT* pMultisampleProperties); +#endif + + +#define VK_EXT_blend_operation_advanced 1 +#define VK_EXT_BLEND_OPERATION_ADVANCED_SPEC_VERSION 2 +#define VK_EXT_BLEND_OPERATION_ADVANCED_EXTENSION_NAME "VK_EXT_blend_operation_advanced" + +typedef enum VkBlendOverlapEXT { + VK_BLEND_OVERLAP_UNCORRELATED_EXT = 0, + VK_BLEND_OVERLAP_DISJOINT_EXT = 1, + VK_BLEND_OVERLAP_CONJOINT_EXT = 2, + VK_BLEND_OVERLAP_BEGIN_RANGE_EXT = VK_BLEND_OVERLAP_UNCORRELATED_EXT, + VK_BLEND_OVERLAP_END_RANGE_EXT = VK_BLEND_OVERLAP_CONJOINT_EXT, + VK_BLEND_OVERLAP_RANGE_SIZE_EXT = (VK_BLEND_OVERLAP_CONJOINT_EXT - VK_BLEND_OVERLAP_UNCORRELATED_EXT + 1), + VK_BLEND_OVERLAP_MAX_ENUM_EXT = 0x7FFFFFFF +} VkBlendOverlapEXT; +typedef struct VkPhysicalDeviceBlendOperationAdvancedFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 advancedBlendCoherentOperations; +} VkPhysicalDeviceBlendOperationAdvancedFeaturesEXT; + +typedef struct VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT { + VkStructureType sType; + void* pNext; + uint32_t advancedBlendMaxColorAttachments; + VkBool32 advancedBlendIndependentBlend; + VkBool32 advancedBlendNonPremultipliedSrcColor; + VkBool32 advancedBlendNonPremultipliedDstColor; + VkBool32 advancedBlendCorrelatedOverlap; + VkBool32 advancedBlendAllOperations; +} VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT; + +typedef struct VkPipelineColorBlendAdvancedStateCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkBool32 srcPremultiplied; + VkBool32 dstPremultiplied; + VkBlendOverlapEXT blendOverlap; +} VkPipelineColorBlendAdvancedStateCreateInfoEXT; + + + +#define VK_NV_fragment_coverage_to_color 1 +#define VK_NV_FRAGMENT_COVERAGE_TO_COLOR_SPEC_VERSION 1 +#define VK_NV_FRAGMENT_COVERAGE_TO_COLOR_EXTENSION_NAME "VK_NV_fragment_coverage_to_color" +typedef VkFlags VkPipelineCoverageToColorStateCreateFlagsNV; +typedef struct VkPipelineCoverageToColorStateCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkPipelineCoverageToColorStateCreateFlagsNV flags; + VkBool32 coverageToColorEnable; + uint32_t coverageToColorLocation; +} VkPipelineCoverageToColorStateCreateInfoNV; + + + +#define VK_NV_framebuffer_mixed_samples 1 +#define VK_NV_FRAMEBUFFER_MIXED_SAMPLES_SPEC_VERSION 1 +#define VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME "VK_NV_framebuffer_mixed_samples" + +typedef enum VkCoverageModulationModeNV { + VK_COVERAGE_MODULATION_MODE_NONE_NV = 0, + VK_COVERAGE_MODULATION_MODE_RGB_NV = 1, + VK_COVERAGE_MODULATION_MODE_ALPHA_NV = 2, + VK_COVERAGE_MODULATION_MODE_RGBA_NV = 3, + VK_COVERAGE_MODULATION_MODE_BEGIN_RANGE_NV = VK_COVERAGE_MODULATION_MODE_NONE_NV, + VK_COVERAGE_MODULATION_MODE_END_RANGE_NV = VK_COVERAGE_MODULATION_MODE_RGBA_NV, + VK_COVERAGE_MODULATION_MODE_RANGE_SIZE_NV = (VK_COVERAGE_MODULATION_MODE_RGBA_NV - VK_COVERAGE_MODULATION_MODE_NONE_NV + 1), + VK_COVERAGE_MODULATION_MODE_MAX_ENUM_NV = 0x7FFFFFFF +} VkCoverageModulationModeNV; +typedef VkFlags VkPipelineCoverageModulationStateCreateFlagsNV; +typedef struct VkPipelineCoverageModulationStateCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkPipelineCoverageModulationStateCreateFlagsNV flags; + VkCoverageModulationModeNV coverageModulationMode; + VkBool32 coverageModulationTableEnable; + uint32_t coverageModulationTableCount; + const float* pCoverageModulationTable; +} VkPipelineCoverageModulationStateCreateInfoNV; + + + +#define VK_NV_fill_rectangle 1 +#define VK_NV_FILL_RECTANGLE_SPEC_VERSION 1 +#define VK_NV_FILL_RECTANGLE_EXTENSION_NAME "VK_NV_fill_rectangle" + + +#define VK_NV_shader_sm_builtins 1 +#define VK_NV_SHADER_SM_BUILTINS_SPEC_VERSION 1 +#define VK_NV_SHADER_SM_BUILTINS_EXTENSION_NAME "VK_NV_shader_sm_builtins" +typedef struct VkPhysicalDeviceShaderSMBuiltinsPropertiesNV { + VkStructureType sType; + void* pNext; + uint32_t shaderSMCount; + uint32_t shaderWarpsPerSM; +} VkPhysicalDeviceShaderSMBuiltinsPropertiesNV; + +typedef struct VkPhysicalDeviceShaderSMBuiltinsFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 shaderSMBuiltins; +} VkPhysicalDeviceShaderSMBuiltinsFeaturesNV; + + + +#define VK_EXT_post_depth_coverage 1 +#define VK_EXT_POST_DEPTH_COVERAGE_SPEC_VERSION 1 +#define VK_EXT_POST_DEPTH_COVERAGE_EXTENSION_NAME "VK_EXT_post_depth_coverage" + + +#define VK_EXT_image_drm_format_modifier 1 +#define VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_SPEC_VERSION 1 +#define VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME "VK_EXT_image_drm_format_modifier" +typedef struct VkDrmFormatModifierPropertiesEXT { + uint64_t drmFormatModifier; + uint32_t drmFormatModifierPlaneCount; + VkFormatFeatureFlags drmFormatModifierTilingFeatures; +} VkDrmFormatModifierPropertiesEXT; + +typedef struct VkDrmFormatModifierPropertiesListEXT { + VkStructureType sType; + void* pNext; + uint32_t drmFormatModifierCount; + VkDrmFormatModifierPropertiesEXT* pDrmFormatModifierProperties; +} VkDrmFormatModifierPropertiesListEXT; + +typedef struct VkPhysicalDeviceImageDrmFormatModifierInfoEXT { + VkStructureType sType; + const void* pNext; + uint64_t drmFormatModifier; + VkSharingMode sharingMode; + uint32_t queueFamilyIndexCount; + const uint32_t* pQueueFamilyIndices; +} VkPhysicalDeviceImageDrmFormatModifierInfoEXT; + +typedef struct VkImageDrmFormatModifierListCreateInfoEXT { + VkStructureType sType; + const void* pNext; + uint32_t drmFormatModifierCount; + const uint64_t* pDrmFormatModifiers; +} VkImageDrmFormatModifierListCreateInfoEXT; + +typedef struct VkImageDrmFormatModifierExplicitCreateInfoEXT { + VkStructureType sType; + const void* pNext; + uint64_t drmFormatModifier; + uint32_t drmFormatModifierPlaneCount; + const VkSubresourceLayout* pPlaneLayouts; +} VkImageDrmFormatModifierExplicitCreateInfoEXT; + +typedef struct VkImageDrmFormatModifierPropertiesEXT { + VkStructureType sType; + void* pNext; + uint64_t drmFormatModifier; +} VkImageDrmFormatModifierPropertiesEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkGetImageDrmFormatModifierPropertiesEXT)(VkDevice device, VkImage image, VkImageDrmFormatModifierPropertiesEXT* pProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetImageDrmFormatModifierPropertiesEXT( + VkDevice device, + VkImage image, + VkImageDrmFormatModifierPropertiesEXT* pProperties); +#endif + + +#define VK_EXT_validation_cache 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkValidationCacheEXT) +#define VK_EXT_VALIDATION_CACHE_SPEC_VERSION 1 +#define VK_EXT_VALIDATION_CACHE_EXTENSION_NAME "VK_EXT_validation_cache" + +typedef enum VkValidationCacheHeaderVersionEXT { + VK_VALIDATION_CACHE_HEADER_VERSION_ONE_EXT = 1, + VK_VALIDATION_CACHE_HEADER_VERSION_BEGIN_RANGE_EXT = VK_VALIDATION_CACHE_HEADER_VERSION_ONE_EXT, + VK_VALIDATION_CACHE_HEADER_VERSION_END_RANGE_EXT = VK_VALIDATION_CACHE_HEADER_VERSION_ONE_EXT, + VK_VALIDATION_CACHE_HEADER_VERSION_RANGE_SIZE_EXT = (VK_VALIDATION_CACHE_HEADER_VERSION_ONE_EXT - VK_VALIDATION_CACHE_HEADER_VERSION_ONE_EXT + 1), + VK_VALIDATION_CACHE_HEADER_VERSION_MAX_ENUM_EXT = 0x7FFFFFFF +} VkValidationCacheHeaderVersionEXT; +typedef VkFlags VkValidationCacheCreateFlagsEXT; +typedef struct VkValidationCacheCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkValidationCacheCreateFlagsEXT flags; + size_t initialDataSize; + const void* pInitialData; +} VkValidationCacheCreateInfoEXT; + +typedef struct VkShaderModuleValidationCacheCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkValidationCacheEXT validationCache; +} VkShaderModuleValidationCacheCreateInfoEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateValidationCacheEXT)(VkDevice device, const VkValidationCacheCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkValidationCacheEXT* pValidationCache); +typedef void (VKAPI_PTR *PFN_vkDestroyValidationCacheEXT)(VkDevice device, VkValidationCacheEXT validationCache, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkMergeValidationCachesEXT)(VkDevice device, VkValidationCacheEXT dstCache, uint32_t srcCacheCount, const VkValidationCacheEXT* pSrcCaches); +typedef VkResult (VKAPI_PTR *PFN_vkGetValidationCacheDataEXT)(VkDevice device, VkValidationCacheEXT validationCache, size_t* pDataSize, void* pData); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateValidationCacheEXT( + VkDevice device, + const VkValidationCacheCreateInfoEXT* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkValidationCacheEXT* pValidationCache); + +VKAPI_ATTR void VKAPI_CALL vkDestroyValidationCacheEXT( + VkDevice device, + VkValidationCacheEXT validationCache, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkMergeValidationCachesEXT( + VkDevice device, + VkValidationCacheEXT dstCache, + uint32_t srcCacheCount, + const VkValidationCacheEXT* pSrcCaches); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetValidationCacheDataEXT( + VkDevice device, + VkValidationCacheEXT validationCache, + size_t* pDataSize, + void* pData); +#endif + + +#define VK_EXT_descriptor_indexing 1 +#define VK_EXT_DESCRIPTOR_INDEXING_SPEC_VERSION 2 +#define VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME "VK_EXT_descriptor_indexing" +typedef VkDescriptorBindingFlagBits VkDescriptorBindingFlagBitsEXT; + +typedef VkDescriptorBindingFlags VkDescriptorBindingFlagsEXT; + +typedef VkDescriptorSetLayoutBindingFlagsCreateInfo VkDescriptorSetLayoutBindingFlagsCreateInfoEXT; + +typedef VkPhysicalDeviceDescriptorIndexingFeatures VkPhysicalDeviceDescriptorIndexingFeaturesEXT; + +typedef VkPhysicalDeviceDescriptorIndexingProperties VkPhysicalDeviceDescriptorIndexingPropertiesEXT; + +typedef VkDescriptorSetVariableDescriptorCountAllocateInfo VkDescriptorSetVariableDescriptorCountAllocateInfoEXT; + +typedef VkDescriptorSetVariableDescriptorCountLayoutSupport VkDescriptorSetVariableDescriptorCountLayoutSupportEXT; + + + +#define VK_EXT_shader_viewport_index_layer 1 +#define VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_SPEC_VERSION 1 +#define VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME "VK_EXT_shader_viewport_index_layer" + + +#define VK_NV_shading_rate_image 1 +#define VK_NV_SHADING_RATE_IMAGE_SPEC_VERSION 3 +#define VK_NV_SHADING_RATE_IMAGE_EXTENSION_NAME "VK_NV_shading_rate_image" + +typedef enum VkShadingRatePaletteEntryNV { + VK_SHADING_RATE_PALETTE_ENTRY_NO_INVOCATIONS_NV = 0, + VK_SHADING_RATE_PALETTE_ENTRY_16_INVOCATIONS_PER_PIXEL_NV = 1, + VK_SHADING_RATE_PALETTE_ENTRY_8_INVOCATIONS_PER_PIXEL_NV = 2, + VK_SHADING_RATE_PALETTE_ENTRY_4_INVOCATIONS_PER_PIXEL_NV = 3, + VK_SHADING_RATE_PALETTE_ENTRY_2_INVOCATIONS_PER_PIXEL_NV = 4, + VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_PIXEL_NV = 5, + VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV = 6, + VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV = 7, + VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV = 8, + VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV = 9, + VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV = 10, + VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV = 11, + VK_SHADING_RATE_PALETTE_ENTRY_BEGIN_RANGE_NV = VK_SHADING_RATE_PALETTE_ENTRY_NO_INVOCATIONS_NV, + VK_SHADING_RATE_PALETTE_ENTRY_END_RANGE_NV = VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, + VK_SHADING_RATE_PALETTE_ENTRY_RANGE_SIZE_NV = (VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV - VK_SHADING_RATE_PALETTE_ENTRY_NO_INVOCATIONS_NV + 1), + VK_SHADING_RATE_PALETTE_ENTRY_MAX_ENUM_NV = 0x7FFFFFFF +} VkShadingRatePaletteEntryNV; + +typedef enum VkCoarseSampleOrderTypeNV { + VK_COARSE_SAMPLE_ORDER_TYPE_DEFAULT_NV = 0, + VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV = 1, + VK_COARSE_SAMPLE_ORDER_TYPE_PIXEL_MAJOR_NV = 2, + VK_COARSE_SAMPLE_ORDER_TYPE_SAMPLE_MAJOR_NV = 3, + VK_COARSE_SAMPLE_ORDER_TYPE_BEGIN_RANGE_NV = VK_COARSE_SAMPLE_ORDER_TYPE_DEFAULT_NV, + VK_COARSE_SAMPLE_ORDER_TYPE_END_RANGE_NV = VK_COARSE_SAMPLE_ORDER_TYPE_SAMPLE_MAJOR_NV, + VK_COARSE_SAMPLE_ORDER_TYPE_RANGE_SIZE_NV = (VK_COARSE_SAMPLE_ORDER_TYPE_SAMPLE_MAJOR_NV - VK_COARSE_SAMPLE_ORDER_TYPE_DEFAULT_NV + 1), + VK_COARSE_SAMPLE_ORDER_TYPE_MAX_ENUM_NV = 0x7FFFFFFF +} VkCoarseSampleOrderTypeNV; +typedef struct VkShadingRatePaletteNV { + uint32_t shadingRatePaletteEntryCount; + const VkShadingRatePaletteEntryNV* pShadingRatePaletteEntries; +} VkShadingRatePaletteNV; + +typedef struct VkPipelineViewportShadingRateImageStateCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkBool32 shadingRateImageEnable; + uint32_t viewportCount; + const VkShadingRatePaletteNV* pShadingRatePalettes; +} VkPipelineViewportShadingRateImageStateCreateInfoNV; + +typedef struct VkPhysicalDeviceShadingRateImageFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 shadingRateImage; + VkBool32 shadingRateCoarseSampleOrder; +} VkPhysicalDeviceShadingRateImageFeaturesNV; + +typedef struct VkPhysicalDeviceShadingRateImagePropertiesNV { + VkStructureType sType; + void* pNext; + VkExtent2D shadingRateTexelSize; + uint32_t shadingRatePaletteSize; + uint32_t shadingRateMaxCoarseSamples; +} VkPhysicalDeviceShadingRateImagePropertiesNV; + +typedef struct VkCoarseSampleLocationNV { + uint32_t pixelX; + uint32_t pixelY; + uint32_t sample; +} VkCoarseSampleLocationNV; + +typedef struct VkCoarseSampleOrderCustomNV { + VkShadingRatePaletteEntryNV shadingRate; + uint32_t sampleCount; + uint32_t sampleLocationCount; + const VkCoarseSampleLocationNV* pSampleLocations; +} VkCoarseSampleOrderCustomNV; + +typedef struct VkPipelineViewportCoarseSampleOrderStateCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkCoarseSampleOrderTypeNV sampleOrderType; + uint32_t customSampleOrderCount; + const VkCoarseSampleOrderCustomNV* pCustomSampleOrders; +} VkPipelineViewportCoarseSampleOrderStateCreateInfoNV; + +typedef void (VKAPI_PTR *PFN_vkCmdBindShadingRateImageNV)(VkCommandBuffer commandBuffer, VkImageView imageView, VkImageLayout imageLayout); +typedef void (VKAPI_PTR *PFN_vkCmdSetViewportShadingRatePaletteNV)(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkShadingRatePaletteNV* pShadingRatePalettes); +typedef void (VKAPI_PTR *PFN_vkCmdSetCoarseSampleOrderNV)(VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount, const VkCoarseSampleOrderCustomNV* pCustomSampleOrders); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdBindShadingRateImageNV( + VkCommandBuffer commandBuffer, + VkImageView imageView, + VkImageLayout imageLayout); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetViewportShadingRatePaletteNV( + VkCommandBuffer commandBuffer, + uint32_t firstViewport, + uint32_t viewportCount, + const VkShadingRatePaletteNV* pShadingRatePalettes); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetCoarseSampleOrderNV( + VkCommandBuffer commandBuffer, + VkCoarseSampleOrderTypeNV sampleOrderType, + uint32_t customSampleOrderCount, + const VkCoarseSampleOrderCustomNV* pCustomSampleOrders); +#endif + + +#define VK_NV_ray_tracing 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkAccelerationStructureNV) +#define VK_NV_RAY_TRACING_SPEC_VERSION 3 +#define VK_NV_RAY_TRACING_EXTENSION_NAME "VK_NV_ray_tracing" +#define VK_SHADER_UNUSED_NV (~0U) + +typedef enum VkAccelerationStructureTypeNV { + VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV = 0, + VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV = 1, + VK_ACCELERATION_STRUCTURE_TYPE_BEGIN_RANGE_NV = VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV, + VK_ACCELERATION_STRUCTURE_TYPE_END_RANGE_NV = VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV, + VK_ACCELERATION_STRUCTURE_TYPE_RANGE_SIZE_NV = (VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV - VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV + 1), + VK_ACCELERATION_STRUCTURE_TYPE_MAX_ENUM_NV = 0x7FFFFFFF +} VkAccelerationStructureTypeNV; + +typedef enum VkRayTracingShaderGroupTypeNV { + VK_RAY_TRACING_SHADER_GROUP_TYPE_GENERAL_NV = 0, + VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_NV = 1, + VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_NV = 2, + VK_RAY_TRACING_SHADER_GROUP_TYPE_BEGIN_RANGE_NV = VK_RAY_TRACING_SHADER_GROUP_TYPE_GENERAL_NV, + VK_RAY_TRACING_SHADER_GROUP_TYPE_END_RANGE_NV = VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_NV, + VK_RAY_TRACING_SHADER_GROUP_TYPE_RANGE_SIZE_NV = (VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_NV - VK_RAY_TRACING_SHADER_GROUP_TYPE_GENERAL_NV + 1), + VK_RAY_TRACING_SHADER_GROUP_TYPE_MAX_ENUM_NV = 0x7FFFFFFF +} VkRayTracingShaderGroupTypeNV; + +typedef enum VkGeometryTypeNV { + VK_GEOMETRY_TYPE_TRIANGLES_NV = 0, + VK_GEOMETRY_TYPE_AABBS_NV = 1, + VK_GEOMETRY_TYPE_BEGIN_RANGE_NV = VK_GEOMETRY_TYPE_TRIANGLES_NV, + VK_GEOMETRY_TYPE_END_RANGE_NV = VK_GEOMETRY_TYPE_AABBS_NV, + VK_GEOMETRY_TYPE_RANGE_SIZE_NV = (VK_GEOMETRY_TYPE_AABBS_NV - VK_GEOMETRY_TYPE_TRIANGLES_NV + 1), + VK_GEOMETRY_TYPE_MAX_ENUM_NV = 0x7FFFFFFF +} VkGeometryTypeNV; + +typedef enum VkCopyAccelerationStructureModeNV { + VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_NV = 0, + VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_NV = 1, + VK_COPY_ACCELERATION_STRUCTURE_MODE_BEGIN_RANGE_NV = VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_NV, + VK_COPY_ACCELERATION_STRUCTURE_MODE_END_RANGE_NV = VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_NV, + VK_COPY_ACCELERATION_STRUCTURE_MODE_RANGE_SIZE_NV = (VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_NV - VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_NV + 1), + VK_COPY_ACCELERATION_STRUCTURE_MODE_MAX_ENUM_NV = 0x7FFFFFFF +} VkCopyAccelerationStructureModeNV; + +typedef enum VkAccelerationStructureMemoryRequirementsTypeNV { + VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_OBJECT_NV = 0, + VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_BUILD_SCRATCH_NV = 1, + VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_UPDATE_SCRATCH_NV = 2, + VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_BEGIN_RANGE_NV = VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_OBJECT_NV, + VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_END_RANGE_NV = VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_UPDATE_SCRATCH_NV, + VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_RANGE_SIZE_NV = (VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_UPDATE_SCRATCH_NV - VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_OBJECT_NV + 1), + VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_MAX_ENUM_NV = 0x7FFFFFFF +} VkAccelerationStructureMemoryRequirementsTypeNV; + +typedef enum VkGeometryFlagBitsNV { + VK_GEOMETRY_OPAQUE_BIT_NV = 0x00000001, + VK_GEOMETRY_NO_DUPLICATE_ANY_HIT_INVOCATION_BIT_NV = 0x00000002, + VK_GEOMETRY_FLAG_BITS_MAX_ENUM_NV = 0x7FFFFFFF +} VkGeometryFlagBitsNV; +typedef VkFlags VkGeometryFlagsNV; + +typedef enum VkGeometryInstanceFlagBitsNV { + VK_GEOMETRY_INSTANCE_TRIANGLE_CULL_DISABLE_BIT_NV = 0x00000001, + VK_GEOMETRY_INSTANCE_TRIANGLE_FRONT_COUNTERCLOCKWISE_BIT_NV = 0x00000002, + VK_GEOMETRY_INSTANCE_FORCE_OPAQUE_BIT_NV = 0x00000004, + VK_GEOMETRY_INSTANCE_FORCE_NO_OPAQUE_BIT_NV = 0x00000008, + VK_GEOMETRY_INSTANCE_FLAG_BITS_MAX_ENUM_NV = 0x7FFFFFFF +} VkGeometryInstanceFlagBitsNV; +typedef VkFlags VkGeometryInstanceFlagsNV; + +typedef enum VkBuildAccelerationStructureFlagBitsNV { + VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_UPDATE_BIT_NV = 0x00000001, + VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_COMPACTION_BIT_NV = 0x00000002, + VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV = 0x00000004, + VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV = 0x00000008, + VK_BUILD_ACCELERATION_STRUCTURE_LOW_MEMORY_BIT_NV = 0x00000010, + VK_BUILD_ACCELERATION_STRUCTURE_FLAG_BITS_MAX_ENUM_NV = 0x7FFFFFFF +} VkBuildAccelerationStructureFlagBitsNV; +typedef VkFlags VkBuildAccelerationStructureFlagsNV; +typedef struct VkRayTracingShaderGroupCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkRayTracingShaderGroupTypeNV type; + uint32_t generalShader; + uint32_t closestHitShader; + uint32_t anyHitShader; + uint32_t intersectionShader; +} VkRayTracingShaderGroupCreateInfoNV; + +typedef struct VkRayTracingPipelineCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkPipelineCreateFlags flags; + uint32_t stageCount; + const VkPipelineShaderStageCreateInfo* pStages; + uint32_t groupCount; + const VkRayTracingShaderGroupCreateInfoNV* pGroups; + uint32_t maxRecursionDepth; + VkPipelineLayout layout; + VkPipeline basePipelineHandle; + int32_t basePipelineIndex; +} VkRayTracingPipelineCreateInfoNV; + +typedef struct VkGeometryTrianglesNV { + VkStructureType sType; + const void* pNext; + VkBuffer vertexData; + VkDeviceSize vertexOffset; + uint32_t vertexCount; + VkDeviceSize vertexStride; + VkFormat vertexFormat; + VkBuffer indexData; + VkDeviceSize indexOffset; + uint32_t indexCount; + VkIndexType indexType; + VkBuffer transformData; + VkDeviceSize transformOffset; +} VkGeometryTrianglesNV; + +typedef struct VkGeometryAABBNV { + VkStructureType sType; + const void* pNext; + VkBuffer aabbData; + uint32_t numAABBs; + uint32_t stride; + VkDeviceSize offset; +} VkGeometryAABBNV; + +typedef struct VkGeometryDataNV { + VkGeometryTrianglesNV triangles; + VkGeometryAABBNV aabbs; +} VkGeometryDataNV; + +typedef struct VkGeometryNV { + VkStructureType sType; + const void* pNext; + VkGeometryTypeNV geometryType; + VkGeometryDataNV geometry; + VkGeometryFlagsNV flags; +} VkGeometryNV; + +typedef struct VkAccelerationStructureInfoNV { + VkStructureType sType; + const void* pNext; + VkAccelerationStructureTypeNV type; + VkBuildAccelerationStructureFlagsNV flags; + uint32_t instanceCount; + uint32_t geometryCount; + const VkGeometryNV* pGeometries; +} VkAccelerationStructureInfoNV; + +typedef struct VkAccelerationStructureCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkDeviceSize compactedSize; + VkAccelerationStructureInfoNV info; +} VkAccelerationStructureCreateInfoNV; + +typedef struct VkBindAccelerationStructureMemoryInfoNV { + VkStructureType sType; + const void* pNext; + VkAccelerationStructureNV accelerationStructure; + VkDeviceMemory memory; + VkDeviceSize memoryOffset; + uint32_t deviceIndexCount; + const uint32_t* pDeviceIndices; +} VkBindAccelerationStructureMemoryInfoNV; + +typedef struct VkWriteDescriptorSetAccelerationStructureNV { + VkStructureType sType; + const void* pNext; + uint32_t accelerationStructureCount; + const VkAccelerationStructureNV* pAccelerationStructures; +} VkWriteDescriptorSetAccelerationStructureNV; + +typedef struct VkAccelerationStructureMemoryRequirementsInfoNV { + VkStructureType sType; + const void* pNext; + VkAccelerationStructureMemoryRequirementsTypeNV type; + VkAccelerationStructureNV accelerationStructure; +} VkAccelerationStructureMemoryRequirementsInfoNV; + +typedef struct VkPhysicalDeviceRayTracingPropertiesNV { + VkStructureType sType; + void* pNext; + uint32_t shaderGroupHandleSize; + uint32_t maxRecursionDepth; + uint32_t maxShaderGroupStride; + uint32_t shaderGroupBaseAlignment; + uint64_t maxGeometryCount; + uint64_t maxInstanceCount; + uint64_t maxTriangleCount; + uint32_t maxDescriptorSetAccelerationStructures; +} VkPhysicalDeviceRayTracingPropertiesNV; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateAccelerationStructureNV)(VkDevice device, const VkAccelerationStructureCreateInfoNV* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkAccelerationStructureNV* pAccelerationStructure); +typedef void (VKAPI_PTR *PFN_vkDestroyAccelerationStructureNV)(VkDevice device, VkAccelerationStructureNV accelerationStructure, const VkAllocationCallbacks* pAllocator); +typedef void (VKAPI_PTR *PFN_vkGetAccelerationStructureMemoryRequirementsNV)(VkDevice device, const VkAccelerationStructureMemoryRequirementsInfoNV* pInfo, VkMemoryRequirements2KHR* pMemoryRequirements); +typedef VkResult (VKAPI_PTR *PFN_vkBindAccelerationStructureMemoryNV)(VkDevice device, uint32_t bindInfoCount, const VkBindAccelerationStructureMemoryInfoNV* pBindInfos); +typedef void (VKAPI_PTR *PFN_vkCmdBuildAccelerationStructureNV)(VkCommandBuffer commandBuffer, const VkAccelerationStructureInfoNV* pInfo, VkBuffer instanceData, VkDeviceSize instanceOffset, VkBool32 update, VkAccelerationStructureNV dst, VkAccelerationStructureNV src, VkBuffer scratch, VkDeviceSize scratchOffset); +typedef void (VKAPI_PTR *PFN_vkCmdCopyAccelerationStructureNV)(VkCommandBuffer commandBuffer, VkAccelerationStructureNV dst, VkAccelerationStructureNV src, VkCopyAccelerationStructureModeNV mode); +typedef void (VKAPI_PTR *PFN_vkCmdTraceRaysNV)(VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset, VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride, VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride, VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride, uint32_t width, uint32_t height, uint32_t depth); +typedef VkResult (VKAPI_PTR *PFN_vkCreateRayTracingPipelinesNV)(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkRayTracingPipelineCreateInfoNV* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines); +typedef VkResult (VKAPI_PTR *PFN_vkGetRayTracingShaderGroupHandlesNV)(VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void* pData); +typedef VkResult (VKAPI_PTR *PFN_vkGetAccelerationStructureHandleNV)(VkDevice device, VkAccelerationStructureNV accelerationStructure, size_t dataSize, void* pData); +typedef void (VKAPI_PTR *PFN_vkCmdWriteAccelerationStructuresPropertiesNV)(VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV* pAccelerationStructures, VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery); +typedef VkResult (VKAPI_PTR *PFN_vkCompileDeferredNV)(VkDevice device, VkPipeline pipeline, uint32_t shader); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateAccelerationStructureNV( + VkDevice device, + const VkAccelerationStructureCreateInfoNV* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkAccelerationStructureNV* pAccelerationStructure); + +VKAPI_ATTR void VKAPI_CALL vkDestroyAccelerationStructureNV( + VkDevice device, + VkAccelerationStructureNV accelerationStructure, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR void VKAPI_CALL vkGetAccelerationStructureMemoryRequirementsNV( + VkDevice device, + const VkAccelerationStructureMemoryRequirementsInfoNV* pInfo, + VkMemoryRequirements2KHR* pMemoryRequirements); + +VKAPI_ATTR VkResult VKAPI_CALL vkBindAccelerationStructureMemoryNV( + VkDevice device, + uint32_t bindInfoCount, + const VkBindAccelerationStructureMemoryInfoNV* pBindInfos); + +VKAPI_ATTR void VKAPI_CALL vkCmdBuildAccelerationStructureNV( + VkCommandBuffer commandBuffer, + const VkAccelerationStructureInfoNV* pInfo, + VkBuffer instanceData, + VkDeviceSize instanceOffset, + VkBool32 update, + VkAccelerationStructureNV dst, + VkAccelerationStructureNV src, + VkBuffer scratch, + VkDeviceSize scratchOffset); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyAccelerationStructureNV( + VkCommandBuffer commandBuffer, + VkAccelerationStructureNV dst, + VkAccelerationStructureNV src, + VkCopyAccelerationStructureModeNV mode); + +VKAPI_ATTR void VKAPI_CALL vkCmdTraceRaysNV( + VkCommandBuffer commandBuffer, + VkBuffer raygenShaderBindingTableBuffer, + VkDeviceSize raygenShaderBindingOffset, + VkBuffer missShaderBindingTableBuffer, + VkDeviceSize missShaderBindingOffset, + VkDeviceSize missShaderBindingStride, + VkBuffer hitShaderBindingTableBuffer, + VkDeviceSize hitShaderBindingOffset, + VkDeviceSize hitShaderBindingStride, + VkBuffer callableShaderBindingTableBuffer, + VkDeviceSize callableShaderBindingOffset, + VkDeviceSize callableShaderBindingStride, + uint32_t width, + uint32_t height, + uint32_t depth); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateRayTracingPipelinesNV( + VkDevice device, + VkPipelineCache pipelineCache, + uint32_t createInfoCount, + const VkRayTracingPipelineCreateInfoNV* pCreateInfos, + const VkAllocationCallbacks* pAllocator, + VkPipeline* pPipelines); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetRayTracingShaderGroupHandlesNV( + VkDevice device, + VkPipeline pipeline, + uint32_t firstGroup, + uint32_t groupCount, + size_t dataSize, + void* pData); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetAccelerationStructureHandleNV( + VkDevice device, + VkAccelerationStructureNV accelerationStructure, + size_t dataSize, + void* pData); + +VKAPI_ATTR void VKAPI_CALL vkCmdWriteAccelerationStructuresPropertiesNV( + VkCommandBuffer commandBuffer, + uint32_t accelerationStructureCount, + const VkAccelerationStructureNV* pAccelerationStructures, + VkQueryType queryType, + VkQueryPool queryPool, + uint32_t firstQuery); + +VKAPI_ATTR VkResult VKAPI_CALL vkCompileDeferredNV( + VkDevice device, + VkPipeline pipeline, + uint32_t shader); +#endif + + +#define VK_NV_representative_fragment_test 1 +#define VK_NV_REPRESENTATIVE_FRAGMENT_TEST_SPEC_VERSION 2 +#define VK_NV_REPRESENTATIVE_FRAGMENT_TEST_EXTENSION_NAME "VK_NV_representative_fragment_test" +typedef struct VkPhysicalDeviceRepresentativeFragmentTestFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 representativeFragmentTest; +} VkPhysicalDeviceRepresentativeFragmentTestFeaturesNV; + +typedef struct VkPipelineRepresentativeFragmentTestStateCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkBool32 representativeFragmentTestEnable; +} VkPipelineRepresentativeFragmentTestStateCreateInfoNV; + + + +#define VK_EXT_filter_cubic 1 +#define VK_EXT_FILTER_CUBIC_SPEC_VERSION 3 +#define VK_EXT_FILTER_CUBIC_EXTENSION_NAME "VK_EXT_filter_cubic" +typedef struct VkPhysicalDeviceImageViewImageFormatInfoEXT { + VkStructureType sType; + void* pNext; + VkImageViewType imageViewType; +} VkPhysicalDeviceImageViewImageFormatInfoEXT; + +typedef struct VkFilterCubicImageViewImageFormatPropertiesEXT { + VkStructureType sType; + void* pNext; + VkBool32 filterCubic; + VkBool32 filterCubicMinmax; +} VkFilterCubicImageViewImageFormatPropertiesEXT; + + + +#define VK_EXT_global_priority 1 +#define VK_EXT_GLOBAL_PRIORITY_SPEC_VERSION 2 +#define VK_EXT_GLOBAL_PRIORITY_EXTENSION_NAME "VK_EXT_global_priority" + +typedef enum VkQueueGlobalPriorityEXT { + VK_QUEUE_GLOBAL_PRIORITY_LOW_EXT = 128, + VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT = 256, + VK_QUEUE_GLOBAL_PRIORITY_HIGH_EXT = 512, + VK_QUEUE_GLOBAL_PRIORITY_REALTIME_EXT = 1024, + VK_QUEUE_GLOBAL_PRIORITY_BEGIN_RANGE_EXT = VK_QUEUE_GLOBAL_PRIORITY_LOW_EXT, + VK_QUEUE_GLOBAL_PRIORITY_END_RANGE_EXT = VK_QUEUE_GLOBAL_PRIORITY_REALTIME_EXT, + VK_QUEUE_GLOBAL_PRIORITY_RANGE_SIZE_EXT = (VK_QUEUE_GLOBAL_PRIORITY_REALTIME_EXT - VK_QUEUE_GLOBAL_PRIORITY_LOW_EXT + 1), + VK_QUEUE_GLOBAL_PRIORITY_MAX_ENUM_EXT = 0x7FFFFFFF +} VkQueueGlobalPriorityEXT; +typedef struct VkDeviceQueueGlobalPriorityCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkQueueGlobalPriorityEXT globalPriority; +} VkDeviceQueueGlobalPriorityCreateInfoEXT; + + + +#define VK_EXT_external_memory_host 1 +#define VK_EXT_EXTERNAL_MEMORY_HOST_SPEC_VERSION 1 +#define VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME "VK_EXT_external_memory_host" +typedef struct VkImportMemoryHostPointerInfoEXT { + VkStructureType sType; + const void* pNext; + VkExternalMemoryHandleTypeFlagBits handleType; + void* pHostPointer; +} VkImportMemoryHostPointerInfoEXT; + +typedef struct VkMemoryHostPointerPropertiesEXT { + VkStructureType sType; + void* pNext; + uint32_t memoryTypeBits; +} VkMemoryHostPointerPropertiesEXT; + +typedef struct VkPhysicalDeviceExternalMemoryHostPropertiesEXT { + VkStructureType sType; + void* pNext; + VkDeviceSize minImportedHostPointerAlignment; +} VkPhysicalDeviceExternalMemoryHostPropertiesEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryHostPointerPropertiesEXT)(VkDevice device, VkExternalMemoryHandleTypeFlagBits handleType, const void* pHostPointer, VkMemoryHostPointerPropertiesEXT* pMemoryHostPointerProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryHostPointerPropertiesEXT( + VkDevice device, + VkExternalMemoryHandleTypeFlagBits handleType, + const void* pHostPointer, + VkMemoryHostPointerPropertiesEXT* pMemoryHostPointerProperties); +#endif + + +#define VK_AMD_buffer_marker 1 +#define VK_AMD_BUFFER_MARKER_SPEC_VERSION 1 +#define VK_AMD_BUFFER_MARKER_EXTENSION_NAME "VK_AMD_buffer_marker" +typedef void (VKAPI_PTR *PFN_vkCmdWriteBufferMarkerAMD)(VkCommandBuffer commandBuffer, VkPipelineStageFlagBits pipelineStage, VkBuffer dstBuffer, VkDeviceSize dstOffset, uint32_t marker); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdWriteBufferMarkerAMD( + VkCommandBuffer commandBuffer, + VkPipelineStageFlagBits pipelineStage, + VkBuffer dstBuffer, + VkDeviceSize dstOffset, + uint32_t marker); +#endif + + +#define VK_AMD_pipeline_compiler_control 1 +#define VK_AMD_PIPELINE_COMPILER_CONTROL_SPEC_VERSION 1 +#define VK_AMD_PIPELINE_COMPILER_CONTROL_EXTENSION_NAME "VK_AMD_pipeline_compiler_control" + +typedef enum VkPipelineCompilerControlFlagBitsAMD { + VK_PIPELINE_COMPILER_CONTROL_FLAG_BITS_MAX_ENUM_AMD = 0x7FFFFFFF +} VkPipelineCompilerControlFlagBitsAMD; +typedef VkFlags VkPipelineCompilerControlFlagsAMD; +typedef struct VkPipelineCompilerControlCreateInfoAMD { + VkStructureType sType; + const void* pNext; + VkPipelineCompilerControlFlagsAMD compilerControlFlags; +} VkPipelineCompilerControlCreateInfoAMD; + + + +#define VK_EXT_calibrated_timestamps 1 +#define VK_EXT_CALIBRATED_TIMESTAMPS_SPEC_VERSION 1 +#define VK_EXT_CALIBRATED_TIMESTAMPS_EXTENSION_NAME "VK_EXT_calibrated_timestamps" + +typedef enum VkTimeDomainEXT { + VK_TIME_DOMAIN_DEVICE_EXT = 0, + VK_TIME_DOMAIN_CLOCK_MONOTONIC_EXT = 1, + VK_TIME_DOMAIN_CLOCK_MONOTONIC_RAW_EXT = 2, + VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_EXT = 3, + VK_TIME_DOMAIN_BEGIN_RANGE_EXT = VK_TIME_DOMAIN_DEVICE_EXT, + VK_TIME_DOMAIN_END_RANGE_EXT = VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_EXT, + VK_TIME_DOMAIN_RANGE_SIZE_EXT = (VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_EXT - VK_TIME_DOMAIN_DEVICE_EXT + 1), + VK_TIME_DOMAIN_MAX_ENUM_EXT = 0x7FFFFFFF +} VkTimeDomainEXT; +typedef struct VkCalibratedTimestampInfoEXT { + VkStructureType sType; + const void* pNext; + VkTimeDomainEXT timeDomain; +} VkCalibratedTimestampInfoEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT)(VkPhysicalDevice physicalDevice, uint32_t* pTimeDomainCount, VkTimeDomainEXT* pTimeDomains); +typedef VkResult (VKAPI_PTR *PFN_vkGetCalibratedTimestampsEXT)(VkDevice device, uint32_t timestampCount, const VkCalibratedTimestampInfoEXT* pTimestampInfos, uint64_t* pTimestamps, uint64_t* pMaxDeviation); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceCalibrateableTimeDomainsEXT( + VkPhysicalDevice physicalDevice, + uint32_t* pTimeDomainCount, + VkTimeDomainEXT* pTimeDomains); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetCalibratedTimestampsEXT( + VkDevice device, + uint32_t timestampCount, + const VkCalibratedTimestampInfoEXT* pTimestampInfos, + uint64_t* pTimestamps, + uint64_t* pMaxDeviation); +#endif + + +#define VK_AMD_shader_core_properties 1 +#define VK_AMD_SHADER_CORE_PROPERTIES_SPEC_VERSION 2 +#define VK_AMD_SHADER_CORE_PROPERTIES_EXTENSION_NAME "VK_AMD_shader_core_properties" +typedef struct VkPhysicalDeviceShaderCorePropertiesAMD { + VkStructureType sType; + void* pNext; + uint32_t shaderEngineCount; + uint32_t shaderArraysPerEngineCount; + uint32_t computeUnitsPerShaderArray; + uint32_t simdPerComputeUnit; + uint32_t wavefrontsPerSimd; + uint32_t wavefrontSize; + uint32_t sgprsPerSimd; + uint32_t minSgprAllocation; + uint32_t maxSgprAllocation; + uint32_t sgprAllocationGranularity; + uint32_t vgprsPerSimd; + uint32_t minVgprAllocation; + uint32_t maxVgprAllocation; + uint32_t vgprAllocationGranularity; +} VkPhysicalDeviceShaderCorePropertiesAMD; + + + +#define VK_AMD_memory_overallocation_behavior 1 +#define VK_AMD_MEMORY_OVERALLOCATION_BEHAVIOR_SPEC_VERSION 1 +#define VK_AMD_MEMORY_OVERALLOCATION_BEHAVIOR_EXTENSION_NAME "VK_AMD_memory_overallocation_behavior" + +typedef enum VkMemoryOverallocationBehaviorAMD { + VK_MEMORY_OVERALLOCATION_BEHAVIOR_DEFAULT_AMD = 0, + VK_MEMORY_OVERALLOCATION_BEHAVIOR_ALLOWED_AMD = 1, + VK_MEMORY_OVERALLOCATION_BEHAVIOR_DISALLOWED_AMD = 2, + VK_MEMORY_OVERALLOCATION_BEHAVIOR_BEGIN_RANGE_AMD = VK_MEMORY_OVERALLOCATION_BEHAVIOR_DEFAULT_AMD, + VK_MEMORY_OVERALLOCATION_BEHAVIOR_END_RANGE_AMD = VK_MEMORY_OVERALLOCATION_BEHAVIOR_DISALLOWED_AMD, + VK_MEMORY_OVERALLOCATION_BEHAVIOR_RANGE_SIZE_AMD = (VK_MEMORY_OVERALLOCATION_BEHAVIOR_DISALLOWED_AMD - VK_MEMORY_OVERALLOCATION_BEHAVIOR_DEFAULT_AMD + 1), + VK_MEMORY_OVERALLOCATION_BEHAVIOR_MAX_ENUM_AMD = 0x7FFFFFFF +} VkMemoryOverallocationBehaviorAMD; +typedef struct VkDeviceMemoryOverallocationCreateInfoAMD { + VkStructureType sType; + const void* pNext; + VkMemoryOverallocationBehaviorAMD overallocationBehavior; +} VkDeviceMemoryOverallocationCreateInfoAMD; + + + +#define VK_EXT_vertex_attribute_divisor 1 +#define VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_SPEC_VERSION 3 +#define VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME "VK_EXT_vertex_attribute_divisor" +typedef struct VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT { + VkStructureType sType; + void* pNext; + uint32_t maxVertexAttribDivisor; +} VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT; + +typedef struct VkVertexInputBindingDivisorDescriptionEXT { + uint32_t binding; + uint32_t divisor; +} VkVertexInputBindingDivisorDescriptionEXT; + +typedef struct VkPipelineVertexInputDivisorStateCreateInfoEXT { + VkStructureType sType; + const void* pNext; + uint32_t vertexBindingDivisorCount; + const VkVertexInputBindingDivisorDescriptionEXT* pVertexBindingDivisors; +} VkPipelineVertexInputDivisorStateCreateInfoEXT; + +typedef struct VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 vertexAttributeInstanceRateDivisor; + VkBool32 vertexAttributeInstanceRateZeroDivisor; +} VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT; + + + +#define VK_EXT_pipeline_creation_feedback 1 +#define VK_EXT_PIPELINE_CREATION_FEEDBACK_SPEC_VERSION 1 +#define VK_EXT_PIPELINE_CREATION_FEEDBACK_EXTENSION_NAME "VK_EXT_pipeline_creation_feedback" + +typedef enum VkPipelineCreationFeedbackFlagBitsEXT { + VK_PIPELINE_CREATION_FEEDBACK_VALID_BIT_EXT = 0x00000001, + VK_PIPELINE_CREATION_FEEDBACK_APPLICATION_PIPELINE_CACHE_HIT_BIT_EXT = 0x00000002, + VK_PIPELINE_CREATION_FEEDBACK_BASE_PIPELINE_ACCELERATION_BIT_EXT = 0x00000004, + VK_PIPELINE_CREATION_FEEDBACK_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkPipelineCreationFeedbackFlagBitsEXT; +typedef VkFlags VkPipelineCreationFeedbackFlagsEXT; +typedef struct VkPipelineCreationFeedbackEXT { + VkPipelineCreationFeedbackFlagsEXT flags; + uint64_t duration; +} VkPipelineCreationFeedbackEXT; + +typedef struct VkPipelineCreationFeedbackCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkPipelineCreationFeedbackEXT* pPipelineCreationFeedback; + uint32_t pipelineStageCreationFeedbackCount; + VkPipelineCreationFeedbackEXT* pPipelineStageCreationFeedbacks; +} VkPipelineCreationFeedbackCreateInfoEXT; + + + +#define VK_NV_shader_subgroup_partitioned 1 +#define VK_NV_SHADER_SUBGROUP_PARTITIONED_SPEC_VERSION 1 +#define VK_NV_SHADER_SUBGROUP_PARTITIONED_EXTENSION_NAME "VK_NV_shader_subgroup_partitioned" + + +#define VK_NV_compute_shader_derivatives 1 +#define VK_NV_COMPUTE_SHADER_DERIVATIVES_SPEC_VERSION 1 +#define VK_NV_COMPUTE_SHADER_DERIVATIVES_EXTENSION_NAME "VK_NV_compute_shader_derivatives" +typedef struct VkPhysicalDeviceComputeShaderDerivativesFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 computeDerivativeGroupQuads; + VkBool32 computeDerivativeGroupLinear; +} VkPhysicalDeviceComputeShaderDerivativesFeaturesNV; + + + +#define VK_NV_mesh_shader 1 +#define VK_NV_MESH_SHADER_SPEC_VERSION 1 +#define VK_NV_MESH_SHADER_EXTENSION_NAME "VK_NV_mesh_shader" +typedef struct VkPhysicalDeviceMeshShaderFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 taskShader; + VkBool32 meshShader; +} VkPhysicalDeviceMeshShaderFeaturesNV; + +typedef struct VkPhysicalDeviceMeshShaderPropertiesNV { + VkStructureType sType; + void* pNext; + uint32_t maxDrawMeshTasksCount; + uint32_t maxTaskWorkGroupInvocations; + uint32_t maxTaskWorkGroupSize[3]; + uint32_t maxTaskTotalMemorySize; + uint32_t maxTaskOutputCount; + uint32_t maxMeshWorkGroupInvocations; + uint32_t maxMeshWorkGroupSize[3]; + uint32_t maxMeshTotalMemorySize; + uint32_t maxMeshOutputVertices; + uint32_t maxMeshOutputPrimitives; + uint32_t maxMeshMultiviewViewCount; + uint32_t meshOutputPerVertexGranularity; + uint32_t meshOutputPerPrimitiveGranularity; +} VkPhysicalDeviceMeshShaderPropertiesNV; + +typedef struct VkDrawMeshTasksIndirectCommandNV { + uint32_t taskCount; + uint32_t firstTask; +} VkDrawMeshTasksIndirectCommandNV; + +typedef void (VKAPI_PTR *PFN_vkCmdDrawMeshTasksNV)(VkCommandBuffer commandBuffer, uint32_t taskCount, uint32_t firstTask); +typedef void (VKAPI_PTR *PFN_vkCmdDrawMeshTasksIndirectNV)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride); +typedef void (VKAPI_PTR *PFN_vkCmdDrawMeshTasksIndirectCountNV)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdDrawMeshTasksNV( + VkCommandBuffer commandBuffer, + uint32_t taskCount, + uint32_t firstTask); + +VKAPI_ATTR void VKAPI_CALL vkCmdDrawMeshTasksIndirectNV( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset, + uint32_t drawCount, + uint32_t stride); + +VKAPI_ATTR void VKAPI_CALL vkCmdDrawMeshTasksIndirectCountNV( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset, + VkBuffer countBuffer, + VkDeviceSize countBufferOffset, + uint32_t maxDrawCount, + uint32_t stride); +#endif + + +#define VK_NV_fragment_shader_barycentric 1 +#define VK_NV_FRAGMENT_SHADER_BARYCENTRIC_SPEC_VERSION 1 +#define VK_NV_FRAGMENT_SHADER_BARYCENTRIC_EXTENSION_NAME "VK_NV_fragment_shader_barycentric" +typedef struct VkPhysicalDeviceFragmentShaderBarycentricFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 fragmentShaderBarycentric; +} VkPhysicalDeviceFragmentShaderBarycentricFeaturesNV; + + + +#define VK_NV_shader_image_footprint 1 +#define VK_NV_SHADER_IMAGE_FOOTPRINT_SPEC_VERSION 2 +#define VK_NV_SHADER_IMAGE_FOOTPRINT_EXTENSION_NAME "VK_NV_shader_image_footprint" +typedef struct VkPhysicalDeviceShaderImageFootprintFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 imageFootprint; +} VkPhysicalDeviceShaderImageFootprintFeaturesNV; + + + +#define VK_NV_scissor_exclusive 1 +#define VK_NV_SCISSOR_EXCLUSIVE_SPEC_VERSION 1 +#define VK_NV_SCISSOR_EXCLUSIVE_EXTENSION_NAME "VK_NV_scissor_exclusive" +typedef struct VkPipelineViewportExclusiveScissorStateCreateInfoNV { + VkStructureType sType; + const void* pNext; + uint32_t exclusiveScissorCount; + const VkRect2D* pExclusiveScissors; +} VkPipelineViewportExclusiveScissorStateCreateInfoNV; + +typedef struct VkPhysicalDeviceExclusiveScissorFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 exclusiveScissor; +} VkPhysicalDeviceExclusiveScissorFeaturesNV; + +typedef void (VKAPI_PTR *PFN_vkCmdSetExclusiveScissorNV)(VkCommandBuffer commandBuffer, uint32_t firstExclusiveScissor, uint32_t exclusiveScissorCount, const VkRect2D* pExclusiveScissors); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdSetExclusiveScissorNV( + VkCommandBuffer commandBuffer, + uint32_t firstExclusiveScissor, + uint32_t exclusiveScissorCount, + const VkRect2D* pExclusiveScissors); +#endif + + +#define VK_NV_device_diagnostic_checkpoints 1 +#define VK_NV_DEVICE_DIAGNOSTIC_CHECKPOINTS_SPEC_VERSION 2 +#define VK_NV_DEVICE_DIAGNOSTIC_CHECKPOINTS_EXTENSION_NAME "VK_NV_device_diagnostic_checkpoints" +typedef struct VkQueueFamilyCheckpointPropertiesNV { + VkStructureType sType; + void* pNext; + VkPipelineStageFlags checkpointExecutionStageMask; +} VkQueueFamilyCheckpointPropertiesNV; + +typedef struct VkCheckpointDataNV { + VkStructureType sType; + void* pNext; + VkPipelineStageFlagBits stage; + void* pCheckpointMarker; +} VkCheckpointDataNV; + +typedef void (VKAPI_PTR *PFN_vkCmdSetCheckpointNV)(VkCommandBuffer commandBuffer, const void* pCheckpointMarker); +typedef void (VKAPI_PTR *PFN_vkGetQueueCheckpointDataNV)(VkQueue queue, uint32_t* pCheckpointDataCount, VkCheckpointDataNV* pCheckpointData); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdSetCheckpointNV( + VkCommandBuffer commandBuffer, + const void* pCheckpointMarker); + +VKAPI_ATTR void VKAPI_CALL vkGetQueueCheckpointDataNV( + VkQueue queue, + uint32_t* pCheckpointDataCount, + VkCheckpointDataNV* pCheckpointData); +#endif + + +#define VK_INTEL_shader_integer_functions2 1 +#define VK_INTEL_SHADER_INTEGER_FUNCTIONS_2_SPEC_VERSION 1 +#define VK_INTEL_SHADER_INTEGER_FUNCTIONS_2_EXTENSION_NAME "VK_INTEL_shader_integer_functions2" +typedef struct VkPhysicalDeviceShaderIntegerFunctions2FeaturesINTEL { + VkStructureType sType; + void* pNext; + VkBool32 shaderIntegerFunctions2; +} VkPhysicalDeviceShaderIntegerFunctions2FeaturesINTEL; + + + +#define VK_INTEL_performance_query 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPerformanceConfigurationINTEL) +#define VK_INTEL_PERFORMANCE_QUERY_SPEC_VERSION 1 +#define VK_INTEL_PERFORMANCE_QUERY_EXTENSION_NAME "VK_INTEL_performance_query" + +typedef enum VkPerformanceConfigurationTypeINTEL { + VK_PERFORMANCE_CONFIGURATION_TYPE_COMMAND_QUEUE_METRICS_DISCOVERY_ACTIVATED_INTEL = 0, + VK_PERFORMANCE_CONFIGURATION_TYPE_BEGIN_RANGE_INTEL = VK_PERFORMANCE_CONFIGURATION_TYPE_COMMAND_QUEUE_METRICS_DISCOVERY_ACTIVATED_INTEL, + VK_PERFORMANCE_CONFIGURATION_TYPE_END_RANGE_INTEL = VK_PERFORMANCE_CONFIGURATION_TYPE_COMMAND_QUEUE_METRICS_DISCOVERY_ACTIVATED_INTEL, + VK_PERFORMANCE_CONFIGURATION_TYPE_RANGE_SIZE_INTEL = (VK_PERFORMANCE_CONFIGURATION_TYPE_COMMAND_QUEUE_METRICS_DISCOVERY_ACTIVATED_INTEL - VK_PERFORMANCE_CONFIGURATION_TYPE_COMMAND_QUEUE_METRICS_DISCOVERY_ACTIVATED_INTEL + 1), + VK_PERFORMANCE_CONFIGURATION_TYPE_MAX_ENUM_INTEL = 0x7FFFFFFF +} VkPerformanceConfigurationTypeINTEL; + +typedef enum VkQueryPoolSamplingModeINTEL { + VK_QUERY_POOL_SAMPLING_MODE_MANUAL_INTEL = 0, + VK_QUERY_POOL_SAMPLING_MODE_BEGIN_RANGE_INTEL = VK_QUERY_POOL_SAMPLING_MODE_MANUAL_INTEL, + VK_QUERY_POOL_SAMPLING_MODE_END_RANGE_INTEL = VK_QUERY_POOL_SAMPLING_MODE_MANUAL_INTEL, + VK_QUERY_POOL_SAMPLING_MODE_RANGE_SIZE_INTEL = (VK_QUERY_POOL_SAMPLING_MODE_MANUAL_INTEL - VK_QUERY_POOL_SAMPLING_MODE_MANUAL_INTEL + 1), + VK_QUERY_POOL_SAMPLING_MODE_MAX_ENUM_INTEL = 0x7FFFFFFF +} VkQueryPoolSamplingModeINTEL; + +typedef enum VkPerformanceOverrideTypeINTEL { + VK_PERFORMANCE_OVERRIDE_TYPE_NULL_HARDWARE_INTEL = 0, + VK_PERFORMANCE_OVERRIDE_TYPE_FLUSH_GPU_CACHES_INTEL = 1, + VK_PERFORMANCE_OVERRIDE_TYPE_BEGIN_RANGE_INTEL = VK_PERFORMANCE_OVERRIDE_TYPE_NULL_HARDWARE_INTEL, + VK_PERFORMANCE_OVERRIDE_TYPE_END_RANGE_INTEL = VK_PERFORMANCE_OVERRIDE_TYPE_FLUSH_GPU_CACHES_INTEL, + VK_PERFORMANCE_OVERRIDE_TYPE_RANGE_SIZE_INTEL = (VK_PERFORMANCE_OVERRIDE_TYPE_FLUSH_GPU_CACHES_INTEL - VK_PERFORMANCE_OVERRIDE_TYPE_NULL_HARDWARE_INTEL + 1), + VK_PERFORMANCE_OVERRIDE_TYPE_MAX_ENUM_INTEL = 0x7FFFFFFF +} VkPerformanceOverrideTypeINTEL; + +typedef enum VkPerformanceParameterTypeINTEL { + VK_PERFORMANCE_PARAMETER_TYPE_HW_COUNTERS_SUPPORTED_INTEL = 0, + VK_PERFORMANCE_PARAMETER_TYPE_STREAM_MARKER_VALID_BITS_INTEL = 1, + VK_PERFORMANCE_PARAMETER_TYPE_BEGIN_RANGE_INTEL = VK_PERFORMANCE_PARAMETER_TYPE_HW_COUNTERS_SUPPORTED_INTEL, + VK_PERFORMANCE_PARAMETER_TYPE_END_RANGE_INTEL = VK_PERFORMANCE_PARAMETER_TYPE_STREAM_MARKER_VALID_BITS_INTEL, + VK_PERFORMANCE_PARAMETER_TYPE_RANGE_SIZE_INTEL = (VK_PERFORMANCE_PARAMETER_TYPE_STREAM_MARKER_VALID_BITS_INTEL - VK_PERFORMANCE_PARAMETER_TYPE_HW_COUNTERS_SUPPORTED_INTEL + 1), + VK_PERFORMANCE_PARAMETER_TYPE_MAX_ENUM_INTEL = 0x7FFFFFFF +} VkPerformanceParameterTypeINTEL; + +typedef enum VkPerformanceValueTypeINTEL { + VK_PERFORMANCE_VALUE_TYPE_UINT32_INTEL = 0, + VK_PERFORMANCE_VALUE_TYPE_UINT64_INTEL = 1, + VK_PERFORMANCE_VALUE_TYPE_FLOAT_INTEL = 2, + VK_PERFORMANCE_VALUE_TYPE_BOOL_INTEL = 3, + VK_PERFORMANCE_VALUE_TYPE_STRING_INTEL = 4, + VK_PERFORMANCE_VALUE_TYPE_BEGIN_RANGE_INTEL = VK_PERFORMANCE_VALUE_TYPE_UINT32_INTEL, + VK_PERFORMANCE_VALUE_TYPE_END_RANGE_INTEL = VK_PERFORMANCE_VALUE_TYPE_STRING_INTEL, + VK_PERFORMANCE_VALUE_TYPE_RANGE_SIZE_INTEL = (VK_PERFORMANCE_VALUE_TYPE_STRING_INTEL - VK_PERFORMANCE_VALUE_TYPE_UINT32_INTEL + 1), + VK_PERFORMANCE_VALUE_TYPE_MAX_ENUM_INTEL = 0x7FFFFFFF +} VkPerformanceValueTypeINTEL; +typedef union VkPerformanceValueDataINTEL { + uint32_t value32; + uint64_t value64; + float valueFloat; + VkBool32 valueBool; + const char* valueString; +} VkPerformanceValueDataINTEL; + +typedef struct VkPerformanceValueINTEL { + VkPerformanceValueTypeINTEL type; + VkPerformanceValueDataINTEL data; +} VkPerformanceValueINTEL; + +typedef struct VkInitializePerformanceApiInfoINTEL { + VkStructureType sType; + const void* pNext; + void* pUserData; +} VkInitializePerformanceApiInfoINTEL; + +typedef struct VkQueryPoolCreateInfoINTEL { + VkStructureType sType; + const void* pNext; + VkQueryPoolSamplingModeINTEL performanceCountersSampling; +} VkQueryPoolCreateInfoINTEL; + +typedef struct VkPerformanceMarkerInfoINTEL { + VkStructureType sType; + const void* pNext; + uint64_t marker; +} VkPerformanceMarkerInfoINTEL; + +typedef struct VkPerformanceStreamMarkerInfoINTEL { + VkStructureType sType; + const void* pNext; + uint32_t marker; +} VkPerformanceStreamMarkerInfoINTEL; + +typedef struct VkPerformanceOverrideInfoINTEL { + VkStructureType sType; + const void* pNext; + VkPerformanceOverrideTypeINTEL type; + VkBool32 enable; + uint64_t parameter; +} VkPerformanceOverrideInfoINTEL; + +typedef struct VkPerformanceConfigurationAcquireInfoINTEL { + VkStructureType sType; + const void* pNext; + VkPerformanceConfigurationTypeINTEL type; +} VkPerformanceConfigurationAcquireInfoINTEL; + +typedef VkResult (VKAPI_PTR *PFN_vkInitializePerformanceApiINTEL)(VkDevice device, const VkInitializePerformanceApiInfoINTEL* pInitializeInfo); +typedef void (VKAPI_PTR *PFN_vkUninitializePerformanceApiINTEL)(VkDevice device); +typedef VkResult (VKAPI_PTR *PFN_vkCmdSetPerformanceMarkerINTEL)(VkCommandBuffer commandBuffer, const VkPerformanceMarkerInfoINTEL* pMarkerInfo); +typedef VkResult (VKAPI_PTR *PFN_vkCmdSetPerformanceStreamMarkerINTEL)(VkCommandBuffer commandBuffer, const VkPerformanceStreamMarkerInfoINTEL* pMarkerInfo); +typedef VkResult (VKAPI_PTR *PFN_vkCmdSetPerformanceOverrideINTEL)(VkCommandBuffer commandBuffer, const VkPerformanceOverrideInfoINTEL* pOverrideInfo); +typedef VkResult (VKAPI_PTR *PFN_vkAcquirePerformanceConfigurationINTEL)(VkDevice device, const VkPerformanceConfigurationAcquireInfoINTEL* pAcquireInfo, VkPerformanceConfigurationINTEL* pConfiguration); +typedef VkResult (VKAPI_PTR *PFN_vkReleasePerformanceConfigurationINTEL)(VkDevice device, VkPerformanceConfigurationINTEL configuration); +typedef VkResult (VKAPI_PTR *PFN_vkQueueSetPerformanceConfigurationINTEL)(VkQueue queue, VkPerformanceConfigurationINTEL configuration); +typedef VkResult (VKAPI_PTR *PFN_vkGetPerformanceParameterINTEL)(VkDevice device, VkPerformanceParameterTypeINTEL parameter, VkPerformanceValueINTEL* pValue); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkInitializePerformanceApiINTEL( + VkDevice device, + const VkInitializePerformanceApiInfoINTEL* pInitializeInfo); + +VKAPI_ATTR void VKAPI_CALL vkUninitializePerformanceApiINTEL( + VkDevice device); + +VKAPI_ATTR VkResult VKAPI_CALL vkCmdSetPerformanceMarkerINTEL( + VkCommandBuffer commandBuffer, + const VkPerformanceMarkerInfoINTEL* pMarkerInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkCmdSetPerformanceStreamMarkerINTEL( + VkCommandBuffer commandBuffer, + const VkPerformanceStreamMarkerInfoINTEL* pMarkerInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkCmdSetPerformanceOverrideINTEL( + VkCommandBuffer commandBuffer, + const VkPerformanceOverrideInfoINTEL* pOverrideInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkAcquirePerformanceConfigurationINTEL( + VkDevice device, + const VkPerformanceConfigurationAcquireInfoINTEL* pAcquireInfo, + VkPerformanceConfigurationINTEL* pConfiguration); + +VKAPI_ATTR VkResult VKAPI_CALL vkReleasePerformanceConfigurationINTEL( + VkDevice device, + VkPerformanceConfigurationINTEL configuration); + +VKAPI_ATTR VkResult VKAPI_CALL vkQueueSetPerformanceConfigurationINTEL( + VkQueue queue, + VkPerformanceConfigurationINTEL configuration); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPerformanceParameterINTEL( + VkDevice device, + VkPerformanceParameterTypeINTEL parameter, + VkPerformanceValueINTEL* pValue); +#endif + + +#define VK_EXT_pci_bus_info 1 +#define VK_EXT_PCI_BUS_INFO_SPEC_VERSION 2 +#define VK_EXT_PCI_BUS_INFO_EXTENSION_NAME "VK_EXT_pci_bus_info" +typedef struct VkPhysicalDevicePCIBusInfoPropertiesEXT { + VkStructureType sType; + void* pNext; + uint32_t pciDomain; + uint32_t pciBus; + uint32_t pciDevice; + uint32_t pciFunction; +} VkPhysicalDevicePCIBusInfoPropertiesEXT; + + + +#define VK_AMD_display_native_hdr 1 +#define VK_AMD_DISPLAY_NATIVE_HDR_SPEC_VERSION 1 +#define VK_AMD_DISPLAY_NATIVE_HDR_EXTENSION_NAME "VK_AMD_display_native_hdr" +typedef struct VkDisplayNativeHdrSurfaceCapabilitiesAMD { + VkStructureType sType; + void* pNext; + VkBool32 localDimmingSupport; +} VkDisplayNativeHdrSurfaceCapabilitiesAMD; + +typedef struct VkSwapchainDisplayNativeHdrCreateInfoAMD { + VkStructureType sType; + const void* pNext; + VkBool32 localDimmingEnable; +} VkSwapchainDisplayNativeHdrCreateInfoAMD; + +typedef void (VKAPI_PTR *PFN_vkSetLocalDimmingAMD)(VkDevice device, VkSwapchainKHR swapChain, VkBool32 localDimmingEnable); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkSetLocalDimmingAMD( + VkDevice device, + VkSwapchainKHR swapChain, + VkBool32 localDimmingEnable); +#endif + + +#define VK_EXT_fragment_density_map 1 +#define VK_EXT_FRAGMENT_DENSITY_MAP_SPEC_VERSION 1 +#define VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME "VK_EXT_fragment_density_map" +typedef struct VkPhysicalDeviceFragmentDensityMapFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 fragmentDensityMap; + VkBool32 fragmentDensityMapDynamic; + VkBool32 fragmentDensityMapNonSubsampledImages; +} VkPhysicalDeviceFragmentDensityMapFeaturesEXT; + +typedef struct VkPhysicalDeviceFragmentDensityMapPropertiesEXT { + VkStructureType sType; + void* pNext; + VkExtent2D minFragmentDensityTexelSize; + VkExtent2D maxFragmentDensityTexelSize; + VkBool32 fragmentDensityInvocations; +} VkPhysicalDeviceFragmentDensityMapPropertiesEXT; + +typedef struct VkRenderPassFragmentDensityMapCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkAttachmentReference fragmentDensityMapAttachment; +} VkRenderPassFragmentDensityMapCreateInfoEXT; + + + +#define VK_EXT_scalar_block_layout 1 +#define VK_EXT_SCALAR_BLOCK_LAYOUT_SPEC_VERSION 1 +#define VK_EXT_SCALAR_BLOCK_LAYOUT_EXTENSION_NAME "VK_EXT_scalar_block_layout" +typedef VkPhysicalDeviceScalarBlockLayoutFeatures VkPhysicalDeviceScalarBlockLayoutFeaturesEXT; + + + +#define VK_GOOGLE_hlsl_functionality1 1 +#define VK_GOOGLE_HLSL_FUNCTIONALITY1_SPEC_VERSION 1 +#define VK_GOOGLE_HLSL_FUNCTIONALITY1_EXTENSION_NAME "VK_GOOGLE_hlsl_functionality1" + + +#define VK_GOOGLE_decorate_string 1 +#define VK_GOOGLE_DECORATE_STRING_SPEC_VERSION 1 +#define VK_GOOGLE_DECORATE_STRING_EXTENSION_NAME "VK_GOOGLE_decorate_string" + + +#define VK_EXT_subgroup_size_control 1 +#define VK_EXT_SUBGROUP_SIZE_CONTROL_SPEC_VERSION 2 +#define VK_EXT_SUBGROUP_SIZE_CONTROL_EXTENSION_NAME "VK_EXT_subgroup_size_control" +typedef struct VkPhysicalDeviceSubgroupSizeControlFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 subgroupSizeControl; + VkBool32 computeFullSubgroups; +} VkPhysicalDeviceSubgroupSizeControlFeaturesEXT; + +typedef struct VkPhysicalDeviceSubgroupSizeControlPropertiesEXT { + VkStructureType sType; + void* pNext; + uint32_t minSubgroupSize; + uint32_t maxSubgroupSize; + uint32_t maxComputeWorkgroupSubgroups; + VkShaderStageFlags requiredSubgroupSizeStages; +} VkPhysicalDeviceSubgroupSizeControlPropertiesEXT; + +typedef struct VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT { + VkStructureType sType; + void* pNext; + uint32_t requiredSubgroupSize; +} VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT; + + + +#define VK_AMD_shader_core_properties2 1 +#define VK_AMD_SHADER_CORE_PROPERTIES_2_SPEC_VERSION 1 +#define VK_AMD_SHADER_CORE_PROPERTIES_2_EXTENSION_NAME "VK_AMD_shader_core_properties2" + +typedef enum VkShaderCorePropertiesFlagBitsAMD { + VK_SHADER_CORE_PROPERTIES_FLAG_BITS_MAX_ENUM_AMD = 0x7FFFFFFF +} VkShaderCorePropertiesFlagBitsAMD; +typedef VkFlags VkShaderCorePropertiesFlagsAMD; +typedef struct VkPhysicalDeviceShaderCoreProperties2AMD { + VkStructureType sType; + void* pNext; + VkShaderCorePropertiesFlagsAMD shaderCoreFeatures; + uint32_t activeComputeUnitCount; +} VkPhysicalDeviceShaderCoreProperties2AMD; + + + +#define VK_AMD_device_coherent_memory 1 +#define VK_AMD_DEVICE_COHERENT_MEMORY_SPEC_VERSION 1 +#define VK_AMD_DEVICE_COHERENT_MEMORY_EXTENSION_NAME "VK_AMD_device_coherent_memory" +typedef struct VkPhysicalDeviceCoherentMemoryFeaturesAMD { + VkStructureType sType; + void* pNext; + VkBool32 deviceCoherentMemory; +} VkPhysicalDeviceCoherentMemoryFeaturesAMD; + + + +#define VK_EXT_memory_budget 1 +#define VK_EXT_MEMORY_BUDGET_SPEC_VERSION 1 +#define VK_EXT_MEMORY_BUDGET_EXTENSION_NAME "VK_EXT_memory_budget" +typedef struct VkPhysicalDeviceMemoryBudgetPropertiesEXT { + VkStructureType sType; + void* pNext; + VkDeviceSize heapBudget[VK_MAX_MEMORY_HEAPS]; + VkDeviceSize heapUsage[VK_MAX_MEMORY_HEAPS]; +} VkPhysicalDeviceMemoryBudgetPropertiesEXT; + + + +#define VK_EXT_memory_priority 1 +#define VK_EXT_MEMORY_PRIORITY_SPEC_VERSION 1 +#define VK_EXT_MEMORY_PRIORITY_EXTENSION_NAME "VK_EXT_memory_priority" +typedef struct VkPhysicalDeviceMemoryPriorityFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 memoryPriority; +} VkPhysicalDeviceMemoryPriorityFeaturesEXT; + +typedef struct VkMemoryPriorityAllocateInfoEXT { + VkStructureType sType; + const void* pNext; + float priority; +} VkMemoryPriorityAllocateInfoEXT; + + + +#define VK_NV_dedicated_allocation_image_aliasing 1 +#define VK_NV_DEDICATED_ALLOCATION_IMAGE_ALIASING_SPEC_VERSION 1 +#define VK_NV_DEDICATED_ALLOCATION_IMAGE_ALIASING_EXTENSION_NAME "VK_NV_dedicated_allocation_image_aliasing" +typedef struct VkPhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 dedicatedAllocationImageAliasing; +} VkPhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV; + + + +#define VK_EXT_buffer_device_address 1 +#define VK_EXT_BUFFER_DEVICE_ADDRESS_SPEC_VERSION 2 +#define VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME "VK_EXT_buffer_device_address" +typedef struct VkPhysicalDeviceBufferDeviceAddressFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 bufferDeviceAddress; + VkBool32 bufferDeviceAddressCaptureReplay; + VkBool32 bufferDeviceAddressMultiDevice; +} VkPhysicalDeviceBufferDeviceAddressFeaturesEXT; + +typedef VkPhysicalDeviceBufferDeviceAddressFeaturesEXT VkPhysicalDeviceBufferAddressFeaturesEXT; + +typedef VkBufferDeviceAddressInfo VkBufferDeviceAddressInfoEXT; + +typedef struct VkBufferDeviceAddressCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkDeviceAddress deviceAddress; +} VkBufferDeviceAddressCreateInfoEXT; + +typedef VkDeviceAddress (VKAPI_PTR *PFN_vkGetBufferDeviceAddressEXT)(VkDevice device, const VkBufferDeviceAddressInfo* pInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkDeviceAddress VKAPI_CALL vkGetBufferDeviceAddressEXT( + VkDevice device, + const VkBufferDeviceAddressInfo* pInfo); +#endif + + +#define VK_EXT_tooling_info 1 +#define VK_EXT_TOOLING_INFO_SPEC_VERSION 1 +#define VK_EXT_TOOLING_INFO_EXTENSION_NAME "VK_EXT_tooling_info" + +typedef enum VkToolPurposeFlagBitsEXT { + VK_TOOL_PURPOSE_VALIDATION_BIT_EXT = 0x00000001, + VK_TOOL_PURPOSE_PROFILING_BIT_EXT = 0x00000002, + VK_TOOL_PURPOSE_TRACING_BIT_EXT = 0x00000004, + VK_TOOL_PURPOSE_ADDITIONAL_FEATURES_BIT_EXT = 0x00000008, + VK_TOOL_PURPOSE_MODIFYING_FEATURES_BIT_EXT = 0x00000010, + VK_TOOL_PURPOSE_DEBUG_REPORTING_BIT_EXT = 0x00000020, + VK_TOOL_PURPOSE_DEBUG_MARKERS_BIT_EXT = 0x00000040, + VK_TOOL_PURPOSE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkToolPurposeFlagBitsEXT; +typedef VkFlags VkToolPurposeFlagsEXT; +typedef struct VkPhysicalDeviceToolPropertiesEXT { + VkStructureType sType; + void* pNext; + char name[VK_MAX_EXTENSION_NAME_SIZE]; + char version[VK_MAX_EXTENSION_NAME_SIZE]; + VkToolPurposeFlagsEXT purposes; + char description[VK_MAX_DESCRIPTION_SIZE]; + char layer[VK_MAX_EXTENSION_NAME_SIZE]; +} VkPhysicalDeviceToolPropertiesEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceToolPropertiesEXT)(VkPhysicalDevice physicalDevice, uint32_t* pToolCount, VkPhysicalDeviceToolPropertiesEXT* pToolProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceToolPropertiesEXT( + VkPhysicalDevice physicalDevice, + uint32_t* pToolCount, + VkPhysicalDeviceToolPropertiesEXT* pToolProperties); +#endif + + +#define VK_EXT_separate_stencil_usage 1 +#define VK_EXT_SEPARATE_STENCIL_USAGE_SPEC_VERSION 1 +#define VK_EXT_SEPARATE_STENCIL_USAGE_EXTENSION_NAME "VK_EXT_separate_stencil_usage" +typedef VkImageStencilUsageCreateInfo VkImageStencilUsageCreateInfoEXT; + + + +#define VK_EXT_validation_features 1 +#define VK_EXT_VALIDATION_FEATURES_SPEC_VERSION 2 +#define VK_EXT_VALIDATION_FEATURES_EXTENSION_NAME "VK_EXT_validation_features" + +typedef enum VkValidationFeatureEnableEXT { + VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT = 0, + VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT = 1, + VK_VALIDATION_FEATURE_ENABLE_BEST_PRACTICES_EXT = 2, + VK_VALIDATION_FEATURE_ENABLE_BEGIN_RANGE_EXT = VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT, + VK_VALIDATION_FEATURE_ENABLE_END_RANGE_EXT = VK_VALIDATION_FEATURE_ENABLE_BEST_PRACTICES_EXT, + VK_VALIDATION_FEATURE_ENABLE_RANGE_SIZE_EXT = (VK_VALIDATION_FEATURE_ENABLE_BEST_PRACTICES_EXT - VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT + 1), + VK_VALIDATION_FEATURE_ENABLE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkValidationFeatureEnableEXT; + +typedef enum VkValidationFeatureDisableEXT { + VK_VALIDATION_FEATURE_DISABLE_ALL_EXT = 0, + VK_VALIDATION_FEATURE_DISABLE_SHADERS_EXT = 1, + VK_VALIDATION_FEATURE_DISABLE_THREAD_SAFETY_EXT = 2, + VK_VALIDATION_FEATURE_DISABLE_API_PARAMETERS_EXT = 3, + VK_VALIDATION_FEATURE_DISABLE_OBJECT_LIFETIMES_EXT = 4, + VK_VALIDATION_FEATURE_DISABLE_CORE_CHECKS_EXT = 5, + VK_VALIDATION_FEATURE_DISABLE_UNIQUE_HANDLES_EXT = 6, + VK_VALIDATION_FEATURE_DISABLE_BEGIN_RANGE_EXT = VK_VALIDATION_FEATURE_DISABLE_ALL_EXT, + VK_VALIDATION_FEATURE_DISABLE_END_RANGE_EXT = VK_VALIDATION_FEATURE_DISABLE_UNIQUE_HANDLES_EXT, + VK_VALIDATION_FEATURE_DISABLE_RANGE_SIZE_EXT = (VK_VALIDATION_FEATURE_DISABLE_UNIQUE_HANDLES_EXT - VK_VALIDATION_FEATURE_DISABLE_ALL_EXT + 1), + VK_VALIDATION_FEATURE_DISABLE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkValidationFeatureDisableEXT; +typedef struct VkValidationFeaturesEXT { + VkStructureType sType; + const void* pNext; + uint32_t enabledValidationFeatureCount; + const VkValidationFeatureEnableEXT* pEnabledValidationFeatures; + uint32_t disabledValidationFeatureCount; + const VkValidationFeatureDisableEXT* pDisabledValidationFeatures; +} VkValidationFeaturesEXT; + + + +#define VK_NV_cooperative_matrix 1 +#define VK_NV_COOPERATIVE_MATRIX_SPEC_VERSION 1 +#define VK_NV_COOPERATIVE_MATRIX_EXTENSION_NAME "VK_NV_cooperative_matrix" + +typedef enum VkComponentTypeNV { + VK_COMPONENT_TYPE_FLOAT16_NV = 0, + VK_COMPONENT_TYPE_FLOAT32_NV = 1, + VK_COMPONENT_TYPE_FLOAT64_NV = 2, + VK_COMPONENT_TYPE_SINT8_NV = 3, + VK_COMPONENT_TYPE_SINT16_NV = 4, + VK_COMPONENT_TYPE_SINT32_NV = 5, + VK_COMPONENT_TYPE_SINT64_NV = 6, + VK_COMPONENT_TYPE_UINT8_NV = 7, + VK_COMPONENT_TYPE_UINT16_NV = 8, + VK_COMPONENT_TYPE_UINT32_NV = 9, + VK_COMPONENT_TYPE_UINT64_NV = 10, + VK_COMPONENT_TYPE_BEGIN_RANGE_NV = VK_COMPONENT_TYPE_FLOAT16_NV, + VK_COMPONENT_TYPE_END_RANGE_NV = VK_COMPONENT_TYPE_UINT64_NV, + VK_COMPONENT_TYPE_RANGE_SIZE_NV = (VK_COMPONENT_TYPE_UINT64_NV - VK_COMPONENT_TYPE_FLOAT16_NV + 1), + VK_COMPONENT_TYPE_MAX_ENUM_NV = 0x7FFFFFFF +} VkComponentTypeNV; + +typedef enum VkScopeNV { + VK_SCOPE_DEVICE_NV = 1, + VK_SCOPE_WORKGROUP_NV = 2, + VK_SCOPE_SUBGROUP_NV = 3, + VK_SCOPE_QUEUE_FAMILY_NV = 5, + VK_SCOPE_BEGIN_RANGE_NV = VK_SCOPE_DEVICE_NV, + VK_SCOPE_END_RANGE_NV = VK_SCOPE_QUEUE_FAMILY_NV, + VK_SCOPE_RANGE_SIZE_NV = (VK_SCOPE_QUEUE_FAMILY_NV - VK_SCOPE_DEVICE_NV + 1), + VK_SCOPE_MAX_ENUM_NV = 0x7FFFFFFF +} VkScopeNV; +typedef struct VkCooperativeMatrixPropertiesNV { + VkStructureType sType; + void* pNext; + uint32_t MSize; + uint32_t NSize; + uint32_t KSize; + VkComponentTypeNV AType; + VkComponentTypeNV BType; + VkComponentTypeNV CType; + VkComponentTypeNV DType; + VkScopeNV scope; +} VkCooperativeMatrixPropertiesNV; + +typedef struct VkPhysicalDeviceCooperativeMatrixFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 cooperativeMatrix; + VkBool32 cooperativeMatrixRobustBufferAccess; +} VkPhysicalDeviceCooperativeMatrixFeaturesNV; + +typedef struct VkPhysicalDeviceCooperativeMatrixPropertiesNV { + VkStructureType sType; + void* pNext; + VkShaderStageFlags cooperativeMatrixSupportedStages; +} VkPhysicalDeviceCooperativeMatrixPropertiesNV; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV)(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkCooperativeMatrixPropertiesNV* pProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceCooperativeMatrixPropertiesNV( + VkPhysicalDevice physicalDevice, + uint32_t* pPropertyCount, + VkCooperativeMatrixPropertiesNV* pProperties); +#endif + + +#define VK_NV_coverage_reduction_mode 1 +#define VK_NV_COVERAGE_REDUCTION_MODE_SPEC_VERSION 1 +#define VK_NV_COVERAGE_REDUCTION_MODE_EXTENSION_NAME "VK_NV_coverage_reduction_mode" + +typedef enum VkCoverageReductionModeNV { + VK_COVERAGE_REDUCTION_MODE_MERGE_NV = 0, + VK_COVERAGE_REDUCTION_MODE_TRUNCATE_NV = 1, + VK_COVERAGE_REDUCTION_MODE_BEGIN_RANGE_NV = VK_COVERAGE_REDUCTION_MODE_MERGE_NV, + VK_COVERAGE_REDUCTION_MODE_END_RANGE_NV = VK_COVERAGE_REDUCTION_MODE_TRUNCATE_NV, + VK_COVERAGE_REDUCTION_MODE_RANGE_SIZE_NV = (VK_COVERAGE_REDUCTION_MODE_TRUNCATE_NV - VK_COVERAGE_REDUCTION_MODE_MERGE_NV + 1), + VK_COVERAGE_REDUCTION_MODE_MAX_ENUM_NV = 0x7FFFFFFF +} VkCoverageReductionModeNV; +typedef VkFlags VkPipelineCoverageReductionStateCreateFlagsNV; +typedef struct VkPhysicalDeviceCoverageReductionModeFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 coverageReductionMode; +} VkPhysicalDeviceCoverageReductionModeFeaturesNV; + +typedef struct VkPipelineCoverageReductionStateCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkPipelineCoverageReductionStateCreateFlagsNV flags; + VkCoverageReductionModeNV coverageReductionMode; +} VkPipelineCoverageReductionStateCreateInfoNV; + +typedef struct VkFramebufferMixedSamplesCombinationNV { + VkStructureType sType; + void* pNext; + VkCoverageReductionModeNV coverageReductionMode; + VkSampleCountFlagBits rasterizationSamples; + VkSampleCountFlags depthStencilSamples; + VkSampleCountFlags colorSamples; +} VkFramebufferMixedSamplesCombinationNV; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV)(VkPhysicalDevice physicalDevice, uint32_t* pCombinationCount, VkFramebufferMixedSamplesCombinationNV* pCombinations); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV( + VkPhysicalDevice physicalDevice, + uint32_t* pCombinationCount, + VkFramebufferMixedSamplesCombinationNV* pCombinations); +#endif + + +#define VK_EXT_fragment_shader_interlock 1 +#define VK_EXT_FRAGMENT_SHADER_INTERLOCK_SPEC_VERSION 1 +#define VK_EXT_FRAGMENT_SHADER_INTERLOCK_EXTENSION_NAME "VK_EXT_fragment_shader_interlock" +typedef struct VkPhysicalDeviceFragmentShaderInterlockFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 fragmentShaderSampleInterlock; + VkBool32 fragmentShaderPixelInterlock; + VkBool32 fragmentShaderShadingRateInterlock; +} VkPhysicalDeviceFragmentShaderInterlockFeaturesEXT; + + + +#define VK_EXT_ycbcr_image_arrays 1 +#define VK_EXT_YCBCR_IMAGE_ARRAYS_SPEC_VERSION 1 +#define VK_EXT_YCBCR_IMAGE_ARRAYS_EXTENSION_NAME "VK_EXT_ycbcr_image_arrays" +typedef struct VkPhysicalDeviceYcbcrImageArraysFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 ycbcrImageArrays; +} VkPhysicalDeviceYcbcrImageArraysFeaturesEXT; + + + +#define VK_EXT_headless_surface 1 +#define VK_EXT_HEADLESS_SURFACE_SPEC_VERSION 1 +#define VK_EXT_HEADLESS_SURFACE_EXTENSION_NAME "VK_EXT_headless_surface" +typedef VkFlags VkHeadlessSurfaceCreateFlagsEXT; +typedef struct VkHeadlessSurfaceCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkHeadlessSurfaceCreateFlagsEXT flags; +} VkHeadlessSurfaceCreateInfoEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateHeadlessSurfaceEXT)(VkInstance instance, const VkHeadlessSurfaceCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateHeadlessSurfaceEXT( + VkInstance instance, + const VkHeadlessSurfaceCreateInfoEXT* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); +#endif + + +#define VK_EXT_line_rasterization 1 +#define VK_EXT_LINE_RASTERIZATION_SPEC_VERSION 1 +#define VK_EXT_LINE_RASTERIZATION_EXTENSION_NAME "VK_EXT_line_rasterization" + +typedef enum VkLineRasterizationModeEXT { + VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT = 0, + VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT = 1, + VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT = 2, + VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT = 3, + VK_LINE_RASTERIZATION_MODE_BEGIN_RANGE_EXT = VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT, + VK_LINE_RASTERIZATION_MODE_END_RANGE_EXT = VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT, + VK_LINE_RASTERIZATION_MODE_RANGE_SIZE_EXT = (VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT - VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT + 1), + VK_LINE_RASTERIZATION_MODE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkLineRasterizationModeEXT; +typedef struct VkPhysicalDeviceLineRasterizationFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 rectangularLines; + VkBool32 bresenhamLines; + VkBool32 smoothLines; + VkBool32 stippledRectangularLines; + VkBool32 stippledBresenhamLines; + VkBool32 stippledSmoothLines; +} VkPhysicalDeviceLineRasterizationFeaturesEXT; + +typedef struct VkPhysicalDeviceLineRasterizationPropertiesEXT { + VkStructureType sType; + void* pNext; + uint32_t lineSubPixelPrecisionBits; +} VkPhysicalDeviceLineRasterizationPropertiesEXT; + +typedef struct VkPipelineRasterizationLineStateCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkLineRasterizationModeEXT lineRasterizationMode; + VkBool32 stippledLineEnable; + uint32_t lineStippleFactor; + uint16_t lineStipplePattern; +} VkPipelineRasterizationLineStateCreateInfoEXT; + +typedef void (VKAPI_PTR *PFN_vkCmdSetLineStippleEXT)(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor, uint16_t lineStipplePattern); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdSetLineStippleEXT( + VkCommandBuffer commandBuffer, + uint32_t lineStippleFactor, + uint16_t lineStipplePattern); +#endif + + +#define VK_EXT_host_query_reset 1 +#define VK_EXT_HOST_QUERY_RESET_SPEC_VERSION 1 +#define VK_EXT_HOST_QUERY_RESET_EXTENSION_NAME "VK_EXT_host_query_reset" +typedef VkPhysicalDeviceHostQueryResetFeatures VkPhysicalDeviceHostQueryResetFeaturesEXT; + +typedef void (VKAPI_PTR *PFN_vkResetQueryPoolEXT)(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkResetQueryPoolEXT( + VkDevice device, + VkQueryPool queryPool, + uint32_t firstQuery, + uint32_t queryCount); +#endif + + +#define VK_EXT_index_type_uint8 1 +#define VK_EXT_INDEX_TYPE_UINT8_SPEC_VERSION 1 +#define VK_EXT_INDEX_TYPE_UINT8_EXTENSION_NAME "VK_EXT_index_type_uint8" +typedef struct VkPhysicalDeviceIndexTypeUint8FeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 indexTypeUint8; +} VkPhysicalDeviceIndexTypeUint8FeaturesEXT; + + + +#define VK_EXT_shader_demote_to_helper_invocation 1 +#define VK_EXT_SHADER_DEMOTE_TO_HELPER_INVOCATION_SPEC_VERSION 1 +#define VK_EXT_SHADER_DEMOTE_TO_HELPER_INVOCATION_EXTENSION_NAME "VK_EXT_shader_demote_to_helper_invocation" +typedef struct VkPhysicalDeviceShaderDemoteToHelperInvocationFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 shaderDemoteToHelperInvocation; +} VkPhysicalDeviceShaderDemoteToHelperInvocationFeaturesEXT; + + + +#define VK_EXT_texel_buffer_alignment 1 +#define VK_EXT_TEXEL_BUFFER_ALIGNMENT_SPEC_VERSION 1 +#define VK_EXT_TEXEL_BUFFER_ALIGNMENT_EXTENSION_NAME "VK_EXT_texel_buffer_alignment" +typedef struct VkPhysicalDeviceTexelBufferAlignmentFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 texelBufferAlignment; +} VkPhysicalDeviceTexelBufferAlignmentFeaturesEXT; + +typedef struct VkPhysicalDeviceTexelBufferAlignmentPropertiesEXT { + VkStructureType sType; + void* pNext; + VkDeviceSize storageTexelBufferOffsetAlignmentBytes; + VkBool32 storageTexelBufferOffsetSingleTexelAlignment; + VkDeviceSize uniformTexelBufferOffsetAlignmentBytes; + VkBool32 uniformTexelBufferOffsetSingleTexelAlignment; +} VkPhysicalDeviceTexelBufferAlignmentPropertiesEXT; + + + +#define VK_GOOGLE_user_type 1 +#define VK_GOOGLE_USER_TYPE_SPEC_VERSION 1 +#define VK_GOOGLE_USER_TYPE_EXTENSION_NAME "VK_GOOGLE_user_type" + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/include/vulkan/vulkan_fuchsia.h b/thirdparty/include/vulkan/vulkan_fuchsia.h new file mode 100644 index 000000000..e97901480 --- /dev/null +++ b/thirdparty/include/vulkan/vulkan_fuchsia.h @@ -0,0 +1,57 @@ +#ifndef VULKAN_FUCHSIA_H_ +#define VULKAN_FUCHSIA_H_ 1 + +/* +** Copyright (c) 2015-2020 The Khronos Group Inc. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define VK_FUCHSIA_imagepipe_surface 1 +#define VK_FUCHSIA_IMAGEPIPE_SURFACE_SPEC_VERSION 1 +#define VK_FUCHSIA_IMAGEPIPE_SURFACE_EXTENSION_NAME "VK_FUCHSIA_imagepipe_surface" +typedef VkFlags VkImagePipeSurfaceCreateFlagsFUCHSIA; +typedef struct VkImagePipeSurfaceCreateInfoFUCHSIA { + VkStructureType sType; + const void* pNext; + VkImagePipeSurfaceCreateFlagsFUCHSIA flags; + zx_handle_t imagePipeHandle; +} VkImagePipeSurfaceCreateInfoFUCHSIA; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateImagePipeSurfaceFUCHSIA)(VkInstance instance, const VkImagePipeSurfaceCreateInfoFUCHSIA* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateImagePipeSurfaceFUCHSIA( + VkInstance instance, + const VkImagePipeSurfaceCreateInfoFUCHSIA* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/include/vulkan/vulkan_ggp.h b/thirdparty/include/vulkan/vulkan_ggp.h new file mode 100644 index 000000000..09b337e6d --- /dev/null +++ b/thirdparty/include/vulkan/vulkan_ggp.h @@ -0,0 +1,68 @@ +#ifndef VULKAN_GGP_H_ +#define VULKAN_GGP_H_ 1 + +/* +** Copyright (c) 2015-2020 The Khronos Group Inc. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define VK_GGP_stream_descriptor_surface 1 +#define VK_GGP_STREAM_DESCRIPTOR_SURFACE_SPEC_VERSION 1 +#define VK_GGP_STREAM_DESCRIPTOR_SURFACE_EXTENSION_NAME "VK_GGP_stream_descriptor_surface" +typedef VkFlags VkStreamDescriptorSurfaceCreateFlagsGGP; +typedef struct VkStreamDescriptorSurfaceCreateInfoGGP { + VkStructureType sType; + const void* pNext; + VkStreamDescriptorSurfaceCreateFlagsGGP flags; + GgpStreamDescriptor streamDescriptor; +} VkStreamDescriptorSurfaceCreateInfoGGP; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateStreamDescriptorSurfaceGGP)(VkInstance instance, const VkStreamDescriptorSurfaceCreateInfoGGP* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateStreamDescriptorSurfaceGGP( + VkInstance instance, + const VkStreamDescriptorSurfaceCreateInfoGGP* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); +#endif + + +#define VK_GGP_frame_token 1 +#define VK_GGP_FRAME_TOKEN_SPEC_VERSION 1 +#define VK_GGP_FRAME_TOKEN_EXTENSION_NAME "VK_GGP_frame_token" +typedef struct VkPresentFrameTokenGGP { + VkStructureType sType; + const void* pNext; + GgpFrameToken frameToken; +} VkPresentFrameTokenGGP; + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/include/vulkan/vulkan_ios.h b/thirdparty/include/vulkan/vulkan_ios.h new file mode 100644 index 000000000..9f8199938 --- /dev/null +++ b/thirdparty/include/vulkan/vulkan_ios.h @@ -0,0 +1,57 @@ +#ifndef VULKAN_IOS_H_ +#define VULKAN_IOS_H_ 1 + +/* +** Copyright (c) 2015-2020 The Khronos Group Inc. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define VK_MVK_ios_surface 1 +#define VK_MVK_IOS_SURFACE_SPEC_VERSION 2 +#define VK_MVK_IOS_SURFACE_EXTENSION_NAME "VK_MVK_ios_surface" +typedef VkFlags VkIOSSurfaceCreateFlagsMVK; +typedef struct VkIOSSurfaceCreateInfoMVK { + VkStructureType sType; + const void* pNext; + VkIOSSurfaceCreateFlagsMVK flags; + const void* pView; +} VkIOSSurfaceCreateInfoMVK; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateIOSSurfaceMVK)(VkInstance instance, const VkIOSSurfaceCreateInfoMVK* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateIOSSurfaceMVK( + VkInstance instance, + const VkIOSSurfaceCreateInfoMVK* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/include/vulkan/vulkan_macos.h b/thirdparty/include/vulkan/vulkan_macos.h new file mode 100644 index 000000000..8c9684778 --- /dev/null +++ b/thirdparty/include/vulkan/vulkan_macos.h @@ -0,0 +1,57 @@ +#ifndef VULKAN_MACOS_H_ +#define VULKAN_MACOS_H_ 1 + +/* +** Copyright (c) 2015-2020 The Khronos Group Inc. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define VK_MVK_macos_surface 1 +#define VK_MVK_MACOS_SURFACE_SPEC_VERSION 2 +#define VK_MVK_MACOS_SURFACE_EXTENSION_NAME "VK_MVK_macos_surface" +typedef VkFlags VkMacOSSurfaceCreateFlagsMVK; +typedef struct VkMacOSSurfaceCreateInfoMVK { + VkStructureType sType; + const void* pNext; + VkMacOSSurfaceCreateFlagsMVK flags; + const void* pView; +} VkMacOSSurfaceCreateInfoMVK; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateMacOSSurfaceMVK)(VkInstance instance, const VkMacOSSurfaceCreateInfoMVK* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateMacOSSurfaceMVK( + VkInstance instance, + const VkMacOSSurfaceCreateInfoMVK* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/include/vulkan/vulkan_metal.h b/thirdparty/include/vulkan/vulkan_metal.h new file mode 100644 index 000000000..c85d24387 --- /dev/null +++ b/thirdparty/include/vulkan/vulkan_metal.h @@ -0,0 +1,64 @@ +#ifndef VULKAN_METAL_H_ +#define VULKAN_METAL_H_ 1 + +/* +** Copyright (c) 2015-2020 The Khronos Group Inc. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define VK_EXT_metal_surface 1 + +#ifdef __OBJC__ +@class CAMetalLayer; +#else +typedef void CAMetalLayer; +#endif + +#define VK_EXT_METAL_SURFACE_SPEC_VERSION 1 +#define VK_EXT_METAL_SURFACE_EXTENSION_NAME "VK_EXT_metal_surface" +typedef VkFlags VkMetalSurfaceCreateFlagsEXT; +typedef struct VkMetalSurfaceCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkMetalSurfaceCreateFlagsEXT flags; + const CAMetalLayer* pLayer; +} VkMetalSurfaceCreateInfoEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateMetalSurfaceEXT)(VkInstance instance, const VkMetalSurfaceCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateMetalSurfaceEXT( + VkInstance instance, + const VkMetalSurfaceCreateInfoEXT* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/include/vulkan/vulkan_vi.h b/thirdparty/include/vulkan/vulkan_vi.h new file mode 100644 index 000000000..ee877d9b9 --- /dev/null +++ b/thirdparty/include/vulkan/vulkan_vi.h @@ -0,0 +1,57 @@ +#ifndef VULKAN_VI_H_ +#define VULKAN_VI_H_ 1 + +/* +** Copyright (c) 2015-2020 The Khronos Group Inc. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define VK_NN_vi_surface 1 +#define VK_NN_VI_SURFACE_SPEC_VERSION 1 +#define VK_NN_VI_SURFACE_EXTENSION_NAME "VK_NN_vi_surface" +typedef VkFlags VkViSurfaceCreateFlagsNN; +typedef struct VkViSurfaceCreateInfoNN { + VkStructureType sType; + const void* pNext; + VkViSurfaceCreateFlagsNN flags; + void* window; +} VkViSurfaceCreateInfoNN; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateViSurfaceNN)(VkInstance instance, const VkViSurfaceCreateInfoNN* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateViSurfaceNN( + VkInstance instance, + const VkViSurfaceCreateInfoNN* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/include/vulkan/vulkan_wayland.h b/thirdparty/include/vulkan/vulkan_wayland.h new file mode 100644 index 000000000..5278c188b --- /dev/null +++ b/thirdparty/include/vulkan/vulkan_wayland.h @@ -0,0 +1,64 @@ +#ifndef VULKAN_WAYLAND_H_ +#define VULKAN_WAYLAND_H_ 1 + +/* +** Copyright (c) 2015-2020 The Khronos Group Inc. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define VK_KHR_wayland_surface 1 +#define VK_KHR_WAYLAND_SURFACE_SPEC_VERSION 6 +#define VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME "VK_KHR_wayland_surface" +typedef VkFlags VkWaylandSurfaceCreateFlagsKHR; +typedef struct VkWaylandSurfaceCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkWaylandSurfaceCreateFlagsKHR flags; + struct wl_display* display; + struct wl_surface* surface; +} VkWaylandSurfaceCreateInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateWaylandSurfaceKHR)(VkInstance instance, const VkWaylandSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); +typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, struct wl_display* display); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateWaylandSurfaceKHR( + VkInstance instance, + const VkWaylandSurfaceCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); + +VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWaylandPresentationSupportKHR( + VkPhysicalDevice physicalDevice, + uint32_t queueFamilyIndex, + struct wl_display* display); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/include/vulkan/vulkan_win32.h b/thirdparty/include/vulkan/vulkan_win32.h new file mode 100644 index 000000000..a6c4af0e8 --- /dev/null +++ b/thirdparty/include/vulkan/vulkan_win32.h @@ -0,0 +1,328 @@ +#ifndef VULKAN_WIN32_H_ +#define VULKAN_WIN32_H_ 1 + +/* +** Copyright (c) 2015-2020 The Khronos Group Inc. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define VK_KHR_win32_surface 1 +#define VK_KHR_WIN32_SURFACE_SPEC_VERSION 6 +#define VK_KHR_WIN32_SURFACE_EXTENSION_NAME "VK_KHR_win32_surface" +typedef VkFlags VkWin32SurfaceCreateFlagsKHR; +typedef struct VkWin32SurfaceCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkWin32SurfaceCreateFlagsKHR flags; + HINSTANCE hinstance; + HWND hwnd; +} VkWin32SurfaceCreateInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateWin32SurfaceKHR)(VkInstance instance, const VkWin32SurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); +typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateWin32SurfaceKHR( + VkInstance instance, + const VkWin32SurfaceCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); + +VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWin32PresentationSupportKHR( + VkPhysicalDevice physicalDevice, + uint32_t queueFamilyIndex); +#endif + + +#define VK_KHR_external_memory_win32 1 +#define VK_KHR_EXTERNAL_MEMORY_WIN32_SPEC_VERSION 1 +#define VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME "VK_KHR_external_memory_win32" +typedef struct VkImportMemoryWin32HandleInfoKHR { + VkStructureType sType; + const void* pNext; + VkExternalMemoryHandleTypeFlagBits handleType; + HANDLE handle; + LPCWSTR name; +} VkImportMemoryWin32HandleInfoKHR; + +typedef struct VkExportMemoryWin32HandleInfoKHR { + VkStructureType sType; + const void* pNext; + const SECURITY_ATTRIBUTES* pAttributes; + DWORD dwAccess; + LPCWSTR name; +} VkExportMemoryWin32HandleInfoKHR; + +typedef struct VkMemoryWin32HandlePropertiesKHR { + VkStructureType sType; + void* pNext; + uint32_t memoryTypeBits; +} VkMemoryWin32HandlePropertiesKHR; + +typedef struct VkMemoryGetWin32HandleInfoKHR { + VkStructureType sType; + const void* pNext; + VkDeviceMemory memory; + VkExternalMemoryHandleTypeFlagBits handleType; +} VkMemoryGetWin32HandleInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandleKHR)(VkDevice device, const VkMemoryGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle); +typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandlePropertiesKHR)(VkDevice device, VkExternalMemoryHandleTypeFlagBits handleType, HANDLE handle, VkMemoryWin32HandlePropertiesKHR* pMemoryWin32HandleProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandleKHR( + VkDevice device, + const VkMemoryGetWin32HandleInfoKHR* pGetWin32HandleInfo, + HANDLE* pHandle); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandlePropertiesKHR( + VkDevice device, + VkExternalMemoryHandleTypeFlagBits handleType, + HANDLE handle, + VkMemoryWin32HandlePropertiesKHR* pMemoryWin32HandleProperties); +#endif + + +#define VK_KHR_win32_keyed_mutex 1 +#define VK_KHR_WIN32_KEYED_MUTEX_SPEC_VERSION 1 +#define VK_KHR_WIN32_KEYED_MUTEX_EXTENSION_NAME "VK_KHR_win32_keyed_mutex" +typedef struct VkWin32KeyedMutexAcquireReleaseInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t acquireCount; + const VkDeviceMemory* pAcquireSyncs; + const uint64_t* pAcquireKeys; + const uint32_t* pAcquireTimeouts; + uint32_t releaseCount; + const VkDeviceMemory* pReleaseSyncs; + const uint64_t* pReleaseKeys; +} VkWin32KeyedMutexAcquireReleaseInfoKHR; + + + +#define VK_KHR_external_semaphore_win32 1 +#define VK_KHR_EXTERNAL_SEMAPHORE_WIN32_SPEC_VERSION 1 +#define VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME "VK_KHR_external_semaphore_win32" +typedef struct VkImportSemaphoreWin32HandleInfoKHR { + VkStructureType sType; + const void* pNext; + VkSemaphore semaphore; + VkSemaphoreImportFlags flags; + VkExternalSemaphoreHandleTypeFlagBits handleType; + HANDLE handle; + LPCWSTR name; +} VkImportSemaphoreWin32HandleInfoKHR; + +typedef struct VkExportSemaphoreWin32HandleInfoKHR { + VkStructureType sType; + const void* pNext; + const SECURITY_ATTRIBUTES* pAttributes; + DWORD dwAccess; + LPCWSTR name; +} VkExportSemaphoreWin32HandleInfoKHR; + +typedef struct VkD3D12FenceSubmitInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t waitSemaphoreValuesCount; + const uint64_t* pWaitSemaphoreValues; + uint32_t signalSemaphoreValuesCount; + const uint64_t* pSignalSemaphoreValues; +} VkD3D12FenceSubmitInfoKHR; + +typedef struct VkSemaphoreGetWin32HandleInfoKHR { + VkStructureType sType; + const void* pNext; + VkSemaphore semaphore; + VkExternalSemaphoreHandleTypeFlagBits handleType; +} VkSemaphoreGetWin32HandleInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkImportSemaphoreWin32HandleKHR)(VkDevice device, const VkImportSemaphoreWin32HandleInfoKHR* pImportSemaphoreWin32HandleInfo); +typedef VkResult (VKAPI_PTR *PFN_vkGetSemaphoreWin32HandleKHR)(VkDevice device, const VkSemaphoreGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkImportSemaphoreWin32HandleKHR( + VkDevice device, + const VkImportSemaphoreWin32HandleInfoKHR* pImportSemaphoreWin32HandleInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreWin32HandleKHR( + VkDevice device, + const VkSemaphoreGetWin32HandleInfoKHR* pGetWin32HandleInfo, + HANDLE* pHandle); +#endif + + +#define VK_KHR_external_fence_win32 1 +#define VK_KHR_EXTERNAL_FENCE_WIN32_SPEC_VERSION 1 +#define VK_KHR_EXTERNAL_FENCE_WIN32_EXTENSION_NAME "VK_KHR_external_fence_win32" +typedef struct VkImportFenceWin32HandleInfoKHR { + VkStructureType sType; + const void* pNext; + VkFence fence; + VkFenceImportFlags flags; + VkExternalFenceHandleTypeFlagBits handleType; + HANDLE handle; + LPCWSTR name; +} VkImportFenceWin32HandleInfoKHR; + +typedef struct VkExportFenceWin32HandleInfoKHR { + VkStructureType sType; + const void* pNext; + const SECURITY_ATTRIBUTES* pAttributes; + DWORD dwAccess; + LPCWSTR name; +} VkExportFenceWin32HandleInfoKHR; + +typedef struct VkFenceGetWin32HandleInfoKHR { + VkStructureType sType; + const void* pNext; + VkFence fence; + VkExternalFenceHandleTypeFlagBits handleType; +} VkFenceGetWin32HandleInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkImportFenceWin32HandleKHR)(VkDevice device, const VkImportFenceWin32HandleInfoKHR* pImportFenceWin32HandleInfo); +typedef VkResult (VKAPI_PTR *PFN_vkGetFenceWin32HandleKHR)(VkDevice device, const VkFenceGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkImportFenceWin32HandleKHR( + VkDevice device, + const VkImportFenceWin32HandleInfoKHR* pImportFenceWin32HandleInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetFenceWin32HandleKHR( + VkDevice device, + const VkFenceGetWin32HandleInfoKHR* pGetWin32HandleInfo, + HANDLE* pHandle); +#endif + + +#define VK_NV_external_memory_win32 1 +#define VK_NV_EXTERNAL_MEMORY_WIN32_SPEC_VERSION 1 +#define VK_NV_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME "VK_NV_external_memory_win32" +typedef struct VkImportMemoryWin32HandleInfoNV { + VkStructureType sType; + const void* pNext; + VkExternalMemoryHandleTypeFlagsNV handleType; + HANDLE handle; +} VkImportMemoryWin32HandleInfoNV; + +typedef struct VkExportMemoryWin32HandleInfoNV { + VkStructureType sType; + const void* pNext; + const SECURITY_ATTRIBUTES* pAttributes; + DWORD dwAccess; +} VkExportMemoryWin32HandleInfoNV; + +typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandleNV)(VkDevice device, VkDeviceMemory memory, VkExternalMemoryHandleTypeFlagsNV handleType, HANDLE* pHandle); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandleNV( + VkDevice device, + VkDeviceMemory memory, + VkExternalMemoryHandleTypeFlagsNV handleType, + HANDLE* pHandle); +#endif + + +#define VK_NV_win32_keyed_mutex 1 +#define VK_NV_WIN32_KEYED_MUTEX_SPEC_VERSION 2 +#define VK_NV_WIN32_KEYED_MUTEX_EXTENSION_NAME "VK_NV_win32_keyed_mutex" +typedef struct VkWin32KeyedMutexAcquireReleaseInfoNV { + VkStructureType sType; + const void* pNext; + uint32_t acquireCount; + const VkDeviceMemory* pAcquireSyncs; + const uint64_t* pAcquireKeys; + const uint32_t* pAcquireTimeoutMilliseconds; + uint32_t releaseCount; + const VkDeviceMemory* pReleaseSyncs; + const uint64_t* pReleaseKeys; +} VkWin32KeyedMutexAcquireReleaseInfoNV; + + + +#define VK_EXT_full_screen_exclusive 1 +#define VK_EXT_FULL_SCREEN_EXCLUSIVE_SPEC_VERSION 4 +#define VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME "VK_EXT_full_screen_exclusive" + +typedef enum VkFullScreenExclusiveEXT { + VK_FULL_SCREEN_EXCLUSIVE_DEFAULT_EXT = 0, + VK_FULL_SCREEN_EXCLUSIVE_ALLOWED_EXT = 1, + VK_FULL_SCREEN_EXCLUSIVE_DISALLOWED_EXT = 2, + VK_FULL_SCREEN_EXCLUSIVE_APPLICATION_CONTROLLED_EXT = 3, + VK_FULL_SCREEN_EXCLUSIVE_BEGIN_RANGE_EXT = VK_FULL_SCREEN_EXCLUSIVE_DEFAULT_EXT, + VK_FULL_SCREEN_EXCLUSIVE_END_RANGE_EXT = VK_FULL_SCREEN_EXCLUSIVE_APPLICATION_CONTROLLED_EXT, + VK_FULL_SCREEN_EXCLUSIVE_RANGE_SIZE_EXT = (VK_FULL_SCREEN_EXCLUSIVE_APPLICATION_CONTROLLED_EXT - VK_FULL_SCREEN_EXCLUSIVE_DEFAULT_EXT + 1), + VK_FULL_SCREEN_EXCLUSIVE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkFullScreenExclusiveEXT; +typedef struct VkSurfaceFullScreenExclusiveInfoEXT { + VkStructureType sType; + void* pNext; + VkFullScreenExclusiveEXT fullScreenExclusive; +} VkSurfaceFullScreenExclusiveInfoEXT; + +typedef struct VkSurfaceCapabilitiesFullScreenExclusiveEXT { + VkStructureType sType; + void* pNext; + VkBool32 fullScreenExclusiveSupported; +} VkSurfaceCapabilitiesFullScreenExclusiveEXT; + +typedef struct VkSurfaceFullScreenExclusiveWin32InfoEXT { + VkStructureType sType; + const void* pNext; + HMONITOR hmonitor; +} VkSurfaceFullScreenExclusiveWin32InfoEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfacePresentModes2EXT)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, uint32_t* pPresentModeCount, VkPresentModeKHR* pPresentModes); +typedef VkResult (VKAPI_PTR *PFN_vkAcquireFullScreenExclusiveModeEXT)(VkDevice device, VkSwapchainKHR swapchain); +typedef VkResult (VKAPI_PTR *PFN_vkReleaseFullScreenExclusiveModeEXT)(VkDevice device, VkSwapchainKHR swapchain); +typedef VkResult (VKAPI_PTR *PFN_vkGetDeviceGroupSurfacePresentModes2EXT)(VkDevice device, const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, VkDeviceGroupPresentModeFlagsKHR* pModes); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModes2EXT( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, + uint32_t* pPresentModeCount, + VkPresentModeKHR* pPresentModes); + +VKAPI_ATTR VkResult VKAPI_CALL vkAcquireFullScreenExclusiveModeEXT( + VkDevice device, + VkSwapchainKHR swapchain); + +VKAPI_ATTR VkResult VKAPI_CALL vkReleaseFullScreenExclusiveModeEXT( + VkDevice device, + VkSwapchainKHR swapchain); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupSurfacePresentModes2EXT( + VkDevice device, + const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, + VkDeviceGroupPresentModeFlagsKHR* pModes); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/include/vulkan/vulkan_xcb.h b/thirdparty/include/vulkan/vulkan_xcb.h new file mode 100644 index 000000000..43d1407a8 --- /dev/null +++ b/thirdparty/include/vulkan/vulkan_xcb.h @@ -0,0 +1,65 @@ +#ifndef VULKAN_XCB_H_ +#define VULKAN_XCB_H_ 1 + +/* +** Copyright (c) 2015-2020 The Khronos Group Inc. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define VK_KHR_xcb_surface 1 +#define VK_KHR_XCB_SURFACE_SPEC_VERSION 6 +#define VK_KHR_XCB_SURFACE_EXTENSION_NAME "VK_KHR_xcb_surface" +typedef VkFlags VkXcbSurfaceCreateFlagsKHR; +typedef struct VkXcbSurfaceCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkXcbSurfaceCreateFlagsKHR flags; + xcb_connection_t* connection; + xcb_window_t window; +} VkXcbSurfaceCreateInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateXcbSurfaceKHR)(VkInstance instance, const VkXcbSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); +typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, xcb_connection_t* connection, xcb_visualid_t visual_id); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateXcbSurfaceKHR( + VkInstance instance, + const VkXcbSurfaceCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); + +VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXcbPresentationSupportKHR( + VkPhysicalDevice physicalDevice, + uint32_t queueFamilyIndex, + xcb_connection_t* connection, + xcb_visualid_t visual_id); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/include/vulkan/vulkan_xlib.h b/thirdparty/include/vulkan/vulkan_xlib.h new file mode 100644 index 000000000..7beada925 --- /dev/null +++ b/thirdparty/include/vulkan/vulkan_xlib.h @@ -0,0 +1,65 @@ +#ifndef VULKAN_XLIB_H_ +#define VULKAN_XLIB_H_ 1 + +/* +** Copyright (c) 2015-2020 The Khronos Group Inc. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define VK_KHR_xlib_surface 1 +#define VK_KHR_XLIB_SURFACE_SPEC_VERSION 6 +#define VK_KHR_XLIB_SURFACE_EXTENSION_NAME "VK_KHR_xlib_surface" +typedef VkFlags VkXlibSurfaceCreateFlagsKHR; +typedef struct VkXlibSurfaceCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkXlibSurfaceCreateFlagsKHR flags; + Display* dpy; + Window window; +} VkXlibSurfaceCreateInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateXlibSurfaceKHR)(VkInstance instance, const VkXlibSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); +typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, Display* dpy, VisualID visualID); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateXlibSurfaceKHR( + VkInstance instance, + const VkXlibSurfaceCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); + +VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXlibPresentationSupportKHR( + VkPhysicalDevice physicalDevice, + uint32_t queueFamilyIndex, + Display* dpy, + VisualID visualID); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/include/vulkan/vulkan_xlib_xrandr.h b/thirdparty/include/vulkan/vulkan_xlib_xrandr.h new file mode 100644 index 000000000..8e9e150d8 --- /dev/null +++ b/thirdparty/include/vulkan/vulkan_xlib_xrandr.h @@ -0,0 +1,55 @@ +#ifndef VULKAN_XLIB_XRANDR_H_ +#define VULKAN_XLIB_XRANDR_H_ 1 + +/* +** Copyright (c) 2015-2020 The Khronos Group Inc. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define VK_EXT_acquire_xlib_display 1 +#define VK_EXT_ACQUIRE_XLIB_DISPLAY_SPEC_VERSION 1 +#define VK_EXT_ACQUIRE_XLIB_DISPLAY_EXTENSION_NAME "VK_EXT_acquire_xlib_display" +typedef VkResult (VKAPI_PTR *PFN_vkAcquireXlibDisplayEXT)(VkPhysicalDevice physicalDevice, Display* dpy, VkDisplayKHR display); +typedef VkResult (VKAPI_PTR *PFN_vkGetRandROutputDisplayEXT)(VkPhysicalDevice physicalDevice, Display* dpy, RROutput rrOutput, VkDisplayKHR* pDisplay); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkAcquireXlibDisplayEXT( + VkPhysicalDevice physicalDevice, + Display* dpy, + VkDisplayKHR display); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetRandROutputDisplayEXT( + VkPhysicalDevice physicalDevice, + Display* dpy, + RROutput rrOutput, + VkDisplayKHR* pDisplay); +#endif + +#ifdef __cplusplus +} +#endif + +#endif From 79f732ee8a87e4f3c71eb1c2a02687c2e97b55e2 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 23 Feb 2020 12:02:15 +0100 Subject: [PATCH 087/316] VulkanRenderer: Replace ObjectHandle by std::shared_ptr/raw pointers --- examples/VulkanTest/main.cpp | 20 +++++++++---------- .../Nazara/VulkanRenderer/Wrapper/Buffer.hpp | 2 +- .../Nazara/VulkanRenderer/Wrapper/Buffer.inl | 4 ++-- .../VulkanRenderer/Wrapper/CommandBuffer.hpp | 2 +- .../VulkanRenderer/Wrapper/CommandBuffer.inl | 10 +++++++--- .../VulkanRenderer/Wrapper/CommandPool.hpp | 8 ++------ .../VulkanRenderer/Wrapper/CommandPool.inl | 4 ++-- .../VulkanRenderer/Wrapper/DescriptorPool.hpp | 10 +++------- .../VulkanRenderer/Wrapper/DescriptorPool.inl | 8 ++++---- .../VulkanRenderer/Wrapper/DescriptorSet.hpp | 2 +- .../VulkanRenderer/Wrapper/DescriptorSet.inl | 10 +++++++--- .../Wrapper/DescriptorSetLayout.hpp | 4 ++-- .../Wrapper/DescriptorSetLayout.inl | 8 ++++---- .../Nazara/VulkanRenderer/Wrapper/Device.hpp | 7 +++---- .../VulkanRenderer/Wrapper/DeviceMemory.hpp | 4 ++-- .../VulkanRenderer/Wrapper/DeviceMemory.inl | 8 ++++---- .../VulkanRenderer/Wrapper/DeviceObject.hpp | 2 +- .../VulkanRenderer/Wrapper/DeviceObject.inl | 4 ++-- .../VulkanRenderer/Wrapper/Pipeline.hpp | 2 +- .../VulkanRenderer/Wrapper/Pipeline.inl | 6 +++--- .../VulkanRenderer/Wrapper/Semaphore.hpp | 2 +- .../VulkanRenderer/Wrapper/Semaphore.inl | 4 ++-- .../VulkanRenderer/Wrapper/ShaderModule.hpp | 2 +- .../VulkanRenderer/Wrapper/ShaderModule.inl | 4 ++-- .../VulkanRenderer/Wrapper/Swapchain.hpp | 2 +- .../VulkanRenderer/Wrapper/Swapchain.inl | 4 ++-- src/Nazara/VulkanRenderer/VkRenderWindow.cpp | 14 ++++++------- src/Nazara/VulkanRenderer/VulkanDevice.cpp | 2 +- src/Nazara/VulkanRenderer/Wrapper/Device.cpp | 2 +- 29 files changed, 80 insertions(+), 81 deletions(-) diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index 2e202b811..c579594be 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -139,14 +139,14 @@ int main() Nz::VulkanDevice& device = vulkanWindow.GetDevice(); Nz::Vk::ShaderModule vertexShader; - if (!vertexShader.Create(device.CreateHandle(), reinterpret_cast(vertexShaderCode.data()), vertexShaderCode.size())) + if (!vertexShader.Create(device.shared_from_this(), reinterpret_cast(vertexShaderCode.data()), vertexShaderCode.size())) { NazaraError("Failed to create vertex shader"); return __LINE__; } Nz::Vk::ShaderModule fragmentShader; - if (!fragmentShader.Create(device.CreateHandle(), reinterpret_cast(fragmentShaderCode.data()), fragmentShaderCode.size())) + if (!fragmentShader.Create(device.shared_from_this(), reinterpret_cast(fragmentShaderCode.data()), fragmentShaderCode.size())) { NazaraError("Failed to create fragment shader"); return __LINE__; @@ -205,7 +205,7 @@ int main() Nz::UInt32 uniformSize = sizeof(ubo); Nz::Vk::Buffer uniformBuffer; - if (!uniformBuffer.Create(device.CreateHandle(), 0, uniformSize, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT)) + if (!uniformBuffer.Create(device.shared_from_this(), 0, uniformSize, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT)) { NazaraError("Failed to create vertex buffer"); return __LINE__; @@ -214,7 +214,7 @@ int main() VkMemoryRequirements memRequirement = uniformBuffer.GetMemoryRequirements(); Nz::Vk::DeviceMemory uniformBufferMemory; - if (!uniformBufferMemory.Create(device.CreateHandle(), memRequirement.size, memRequirement.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) + if (!uniformBufferMemory.Create(device.shared_from_this(), memRequirement.size, memRequirement.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) { NazaraError("Failed to allocate vertex buffer memory"); return __LINE__; @@ -245,7 +245,7 @@ int main() layoutBinding.pImmutableSamplers = nullptr; Nz::Vk::DescriptorSetLayout descriptorLayout; - if (!descriptorLayout.Create(device.CreateHandle(), layoutBinding)) + if (!descriptorLayout.Create(device.shared_from_this(), layoutBinding)) { NazaraError("Failed to create descriptor set layout"); return __LINE__; @@ -256,7 +256,7 @@ int main() poolSize.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; Nz::Vk::DescriptorPool descriptorPool; - if (!descriptorPool.Create(device.CreateHandle(), 1, poolSize, VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT)) + if (!descriptorPool.Create(device.shared_from_this(), 1, poolSize, VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT)) { NazaraError("Failed to create descriptor pool"); return __LINE__; @@ -405,7 +405,7 @@ int main() }; Nz::Vk::PipelineLayout pipelineLayout; - pipelineLayout.Create(device.CreateHandle(), layout_create_info); + pipelineLayout.Create(device.shared_from_this(), layout_create_info); std::array dynamicStates = { VK_DYNAMIC_STATE_SCISSOR, @@ -458,14 +458,14 @@ int main() }; Nz::Vk::Pipeline pipeline; - if (!pipeline.CreateGraphics(device.CreateHandle(), pipeline_create_info)) + if (!pipeline.CreateGraphics(device.shared_from_this(), pipeline_create_info)) { NazaraError("Failed to create pipeline"); return __LINE__; } Nz::Vk::CommandPool cmdPool; - if (!cmdPool.Create(device.CreateHandle(), 0, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)) + if (!cmdPool.Create(device.shared_from_this(), 0, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)) { NazaraError("Failed to create rendering cmd pool"); return __LINE__; @@ -475,7 +475,7 @@ int main() clearValues[0].color = {1.0f, 0.8f, 0.4f, 0.0f}; clearValues[1].depthStencil = {1.f, 0}; - Nz::Vk::Queue graphicsQueue(device.CreateHandle(), device.GetEnabledQueues()[0].queues[0].queue); + Nz::Vk::Queue graphicsQueue(device.shared_from_this(), device.GetEnabledQueues()[0].queues[0].queue); Nz::UInt32 imageCount = vulkanWindow.GetFramebufferCount(); std::vector renderCmds = cmdPool.AllocateCommandBuffers(imageCount, VK_COMMAND_BUFFER_LEVEL_PRIMARY); diff --git a/include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp b/include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp index 5783791c5..53648a0f9 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp @@ -27,7 +27,7 @@ namespace Nz bool BindBufferMemory(VkDeviceMemory memory, VkDeviceSize offset = 0); using DeviceObject::Create; - inline bool Create(const DeviceHandle& device, VkBufferCreateFlags flags, VkDeviceSize size, VkBufferUsageFlags usage, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(DeviceHandle device, VkBufferCreateFlags flags, VkDeviceSize size, VkBufferUsageFlags usage, const VkAllocationCallbacks* allocator = nullptr); VkMemoryRequirements GetMemoryRequirements() const; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Buffer.inl b/include/Nazara/VulkanRenderer/Wrapper/Buffer.inl index 73ad69566..9b5e41bdd 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Buffer.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Buffer.inl @@ -21,7 +21,7 @@ namespace Nz return true; } - inline bool Buffer::Create(const DeviceHandle& device, VkBufferCreateFlags flags, VkDeviceSize size, VkBufferUsageFlags usage, const VkAllocationCallbacks* allocator) + inline bool Buffer::Create(DeviceHandle device, VkBufferCreateFlags flags, VkDeviceSize size, VkBufferUsageFlags usage, const VkAllocationCallbacks* allocator) { VkBufferCreateInfo createInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType; @@ -34,7 +34,7 @@ namespace Nz nullptr // const uint32_t* pQueueFamilyIndices; }; - return Create(device, createInfo, allocator); + return Create(std::move(device), createInfo, allocator); } inline VkMemoryRequirements Buffer::GetMemoryRequirements() const diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp index 5ef24bd7d..aad18cee7 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp @@ -86,7 +86,7 @@ namespace Nz private: inline CommandBuffer(CommandPool& pool, VkCommandBuffer handle); - CommandPoolHandle m_pool; + CommandPool* m_pool; VkAllocationCallbacks m_allocator; VkCommandBuffer m_handle; VkResult m_lastErrorCode; diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl index c020d284f..62db2a27a 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl @@ -5,6 +5,7 @@ #include #include #include +#include #include namespace Nz @@ -12,7 +13,7 @@ namespace Nz namespace Vk { inline CommandBuffer::CommandBuffer() : - m_pool(), + m_pool(nullptr), m_handle(VK_NULL_HANDLE) { } @@ -24,7 +25,7 @@ namespace Nz } inline CommandBuffer::CommandBuffer(CommandBuffer&& commandBuffer) : - m_pool(std::move(commandBuffer.m_pool)), + m_pool(commandBuffer.m_pool), m_allocator(commandBuffer.m_allocator), m_handle(commandBuffer.m_handle), m_lastErrorCode(commandBuffer.m_lastErrorCode) @@ -223,7 +224,10 @@ namespace Nz inline void CommandBuffer::Free() { if (m_handle) + { + assert(m_pool); m_pool->GetDevice()->vkFreeCommandBuffers(*m_pool->GetDevice(), *m_pool, 1, &m_handle); + } } inline void CommandBuffer::PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, const VkImageMemoryBarrier& imageMemoryBarrier) @@ -401,7 +405,7 @@ namespace Nz m_allocator = commandBuffer.m_allocator; m_handle = commandBuffer.m_handle; m_lastErrorCode = commandBuffer.m_lastErrorCode; - m_pool = std::move(commandBuffer.m_pool); + m_pool = commandBuffer.m_pool; m_handle = commandBuffer.m_handle; commandBuffer.m_handle = VK_NULL_HANDLE; diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandPool.hpp b/include/Nazara/VulkanRenderer/Wrapper/CommandPool.hpp index 7be788954..8d65e4fa9 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandPool.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandPool.hpp @@ -8,7 +8,6 @@ #define NAZARA_VULKANRENDERER_VKCOMMANDPOOL_HPP #include -#include #include namespace Nz @@ -16,11 +15,8 @@ namespace Nz namespace Vk { class CommandBuffer; - class CommandPool; - using CommandPoolHandle = ObjectHandle; - - class NAZARA_VULKANRENDERER_API CommandPool : public DeviceObject, public HandledObject + class NAZARA_VULKANRENDERER_API CommandPool : public DeviceObject { friend DeviceObject; @@ -34,7 +30,7 @@ namespace Nz std::vector AllocateCommandBuffers(UInt32 commandBufferCount, VkCommandBufferLevel level); using DeviceObject::Create; - inline bool Create(const DeviceHandle& device, UInt32 queueFamilyIndex, VkCommandPoolCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(DeviceHandle device, UInt32 queueFamilyIndex, VkCommandPoolCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); inline bool Reset(VkCommandPoolResetFlags flags); diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandPool.inl b/include/Nazara/VulkanRenderer/Wrapper/CommandPool.inl index 90c952654..5ce0e58a3 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandPool.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandPool.inl @@ -11,7 +11,7 @@ namespace Nz { namespace Vk { - inline bool CommandPool::Create(const DeviceHandle& device, UInt32 queueFamilyIndex, VkCommandPoolCreateFlags flags, const VkAllocationCallbacks* allocator) + inline bool CommandPool::Create(DeviceHandle device, UInt32 queueFamilyIndex, VkCommandPoolCreateFlags flags, const VkAllocationCallbacks* allocator) { VkCommandPoolCreateInfo createInfo = { @@ -21,7 +21,7 @@ namespace Nz queueFamilyIndex }; - return Create(device, createInfo, allocator); + return Create(std::move(device), createInfo, allocator); } inline bool CommandPool::Reset(VkCommandPoolResetFlags flags) diff --git a/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp b/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp index e087b58b2..0ca9a0c59 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp @@ -8,19 +8,15 @@ #define NAZARA_VULKANRENDERER_VKDESCRIPTORPOOL_HPP #include -#include #include namespace Nz { namespace Vk { - class DescriptorPool; class DescriptorSet; - using DescriptorPoolHandle = ObjectHandle; - - class NAZARA_VULKANRENDERER_API DescriptorPool : public DeviceObject, public HandledObject + class NAZARA_VULKANRENDERER_API DescriptorPool : public DeviceObject { friend DeviceObject; @@ -34,8 +30,8 @@ namespace Nz std::vector AllocateDescriptorSets(UInt32 descriptorSetCount, const VkDescriptorSetLayout* setLayouts); using DeviceObject::Create; - inline bool Create(const DeviceHandle& device, UInt32 maxSets, const VkDescriptorPoolSize& poolSize, VkDescriptorPoolCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); - inline bool Create(const DeviceHandle& device, UInt32 maxSets, UInt32 poolSizeCount, const VkDescriptorPoolSize* poolSize, VkDescriptorPoolCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(DeviceHandle device, UInt32 maxSets, const VkDescriptorPoolSize& poolSize, VkDescriptorPoolCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(DeviceHandle device, UInt32 maxSets, UInt32 poolSizeCount, const VkDescriptorPoolSize* poolSize, VkDescriptorPoolCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); DescriptorPool& operator=(const DescriptorPool&) = delete; DescriptorPool& operator=(DescriptorPool&&) = delete; diff --git a/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.inl b/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.inl index cd81effcc..f407edef0 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.inl @@ -9,7 +9,7 @@ namespace Nz { namespace Vk { - inline bool DescriptorPool::Create(const DeviceHandle& device, UInt32 maxSets, const VkDescriptorPoolSize& poolSize, VkDescriptorPoolCreateFlags flags, const VkAllocationCallbacks* allocator) + inline bool DescriptorPool::Create(DeviceHandle device, UInt32 maxSets, const VkDescriptorPoolSize& poolSize, VkDescriptorPoolCreateFlags flags, const VkAllocationCallbacks* allocator) { VkDescriptorPoolCreateInfo createInfo = { @@ -21,10 +21,10 @@ namespace Nz &poolSize // const VkDescriptorPoolSize* pPoolSizes; }; - return Create(device, createInfo, allocator); + return Create(std::move(device), createInfo, allocator); } - inline bool DescriptorPool::Create(const DeviceHandle& device, UInt32 maxSets, UInt32 poolSizeCount, const VkDescriptorPoolSize* poolSize, VkDescriptorPoolCreateFlags flags, const VkAllocationCallbacks* allocator) + inline bool DescriptorPool::Create(DeviceHandle device, UInt32 maxSets, UInt32 poolSizeCount, const VkDescriptorPoolSize* poolSize, VkDescriptorPoolCreateFlags flags, const VkAllocationCallbacks* allocator) { VkDescriptorPoolCreateInfo createInfo = { @@ -36,7 +36,7 @@ namespace Nz poolSize // const VkDescriptorPoolSize* pPoolSizes; }; - return Create(device, createInfo, allocator); + return Create(std::move(device), createInfo, allocator); } inline VkResult DescriptorPool::CreateHelper(const DeviceHandle& device, const VkDescriptorPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkDescriptorPool* handle) diff --git a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.hpp b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.hpp index c9afa477e..68a8d1644 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.hpp @@ -45,7 +45,7 @@ namespace Nz private: inline DescriptorSet(DescriptorPool& pool, VkDescriptorSet handle); - DescriptorPoolHandle m_pool; + DescriptorPool* m_pool; VkAllocationCallbacks m_allocator; VkDescriptorSet m_handle; VkResult m_lastErrorCode; diff --git a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.inl b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.inl index c94c48806..30d735eb5 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.inl @@ -5,6 +5,7 @@ #include #include #include +#include #include namespace Nz @@ -12,7 +13,7 @@ namespace Nz namespace Vk { inline DescriptorSet::DescriptorSet() : - m_pool(), + m_pool(nullptr), m_handle(VK_NULL_HANDLE) { } @@ -24,7 +25,7 @@ namespace Nz } inline DescriptorSet::DescriptorSet(DescriptorSet&& descriptorSet) : - m_pool(std::move(descriptorSet.m_pool)), + m_pool(descriptorSet.m_pool), m_allocator(descriptorSet.m_allocator), m_handle(descriptorSet.m_handle), m_lastErrorCode(descriptorSet.m_lastErrorCode) @@ -40,7 +41,10 @@ namespace Nz inline void DescriptorSet::Free() { if (m_handle) + { + assert(m_pool); m_pool->GetDevice()->vkFreeDescriptorSets(*m_pool->GetDevice(), *m_pool, 1, &m_handle); + } } inline VkResult DescriptorSet::GetLastErrorCode() const @@ -104,7 +108,7 @@ namespace Nz m_allocator = descriptorSet.m_allocator; m_handle = descriptorSet.m_handle; m_lastErrorCode = descriptorSet.m_lastErrorCode; - m_pool = std::move(descriptorSet.m_pool); + m_pool = descriptorSet.m_pool; m_handle = descriptorSet.m_handle; descriptorSet.m_handle = VK_NULL_HANDLE; diff --git a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.hpp b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.hpp index fc0c69c34..b5f1dd9ee 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.hpp @@ -25,8 +25,8 @@ namespace Nz ~DescriptorSetLayout() = default; using DeviceObject::Create; - inline bool Create(const DeviceHandle& device, const VkDescriptorSetLayoutBinding& binding, VkDescriptorSetLayoutCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); - inline bool Create(const DeviceHandle& device, UInt32 bindingCount, const VkDescriptorSetLayoutBinding* binding, VkDescriptorSetLayoutCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(DeviceHandle device, const VkDescriptorSetLayoutBinding& binding, VkDescriptorSetLayoutCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(DeviceHandle device, UInt32 bindingCount, const VkDescriptorSetLayoutBinding* binding, VkDescriptorSetLayoutCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); DescriptorSetLayout& operator=(const DescriptorSetLayout&) = delete; DescriptorSetLayout& operator=(DescriptorSetLayout&&) = delete; diff --git a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.inl b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.inl index 707d6ccdd..8989a4768 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.inl @@ -9,12 +9,12 @@ namespace Nz { namespace Vk { - inline bool DescriptorSetLayout::Create(const DeviceHandle& device, const VkDescriptorSetLayoutBinding& binding, VkDescriptorSetLayoutCreateFlags flags, const VkAllocationCallbacks* allocator) + inline bool DescriptorSetLayout::Create(DeviceHandle device, const VkDescriptorSetLayoutBinding& binding, VkDescriptorSetLayoutCreateFlags flags, const VkAllocationCallbacks* allocator) { - return Create(device, 1U, &binding, flags, allocator); + return Create(std::move(device), 1U, &binding, flags, allocator); } - inline bool DescriptorSetLayout::Create(const DeviceHandle& device, UInt32 bindingCount, const VkDescriptorSetLayoutBinding* binding, VkDescriptorSetLayoutCreateFlags flags, const VkAllocationCallbacks* allocator) + inline bool DescriptorSetLayout::Create(DeviceHandle device, UInt32 bindingCount, const VkDescriptorSetLayoutBinding* binding, VkDescriptorSetLayoutCreateFlags flags, const VkAllocationCallbacks* allocator) { VkDescriptorSetLayoutCreateInfo createInfo = { @@ -25,7 +25,7 @@ namespace Nz binding // const VkDescriptorSetLayoutBinding* pBindings; }; - return Create(device, createInfo, allocator); + return Create(std::move(device), createInfo, allocator); } inline VkResult DescriptorSetLayout::CreateHelper(const DeviceHandle& device, const VkDescriptorSetLayoutCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkDescriptorSetLayout* handle) diff --git a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp index 01e508372..3d72b4b7d 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp @@ -8,11 +8,10 @@ #define NAZARA_VULKANRENDERER_VKDEVICE_HPP #include -#include -#include #include #include #include +#include #include namespace Nz @@ -23,9 +22,9 @@ namespace Nz class Instance; class Queue; - using DeviceHandle = ObjectHandle; + using DeviceHandle = std::shared_ptr; - class NAZARA_VULKANRENDERER_API Device : public HandledObject + class NAZARA_VULKANRENDERER_API Device : public std::enable_shared_from_this { public: struct QueueFamilyInfo; diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp b/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp index 67b319083..3a57dc1b5 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp @@ -25,8 +25,8 @@ namespace Nz ~DeviceMemory() = default; using DeviceObject::Create; - inline bool Create(const DeviceHandle& device, VkDeviceSize size, UInt32 memoryType, const VkAllocationCallbacks* allocator = nullptr); - inline bool Create(const DeviceHandle& device, VkDeviceSize size, UInt32 typeBits, VkFlags properties, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(DeviceHandle device, VkDeviceSize size, UInt32 memoryType, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(DeviceHandle device, VkDeviceSize size, UInt32 typeBits, VkFlags properties, const VkAllocationCallbacks* allocator = nullptr); inline void* GetMappedPointer(); diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.inl b/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.inl index 64e2f7618..c3bb310ba 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.inl @@ -24,7 +24,7 @@ namespace Nz memory.m_mappedPtr = nullptr; } - inline bool DeviceMemory::Create(const DeviceHandle& device, VkDeviceSize size, UInt32 memoryType, const VkAllocationCallbacks* allocator) + inline bool DeviceMemory::Create(DeviceHandle device, VkDeviceSize size, UInt32 memoryType, const VkAllocationCallbacks* allocator) { VkMemoryAllocateInfo allocInfo = { @@ -34,10 +34,10 @@ namespace Nz memoryType // uint32_t memoryTypeIndex; }; - return Create(device, allocInfo, allocator); + return Create(std::move(device), allocInfo, allocator); } - inline bool DeviceMemory::Create(const DeviceHandle& device, VkDeviceSize size, UInt32 typeBits, VkFlags properties, const VkAllocationCallbacks* allocator) + inline bool DeviceMemory::Create(DeviceHandle device, VkDeviceSize size, UInt32 typeBits, VkFlags properties, const VkAllocationCallbacks* allocator) { const Vk::PhysicalDevice& deviceInfo = Vulkan::GetPhysicalDeviceInfo(device->GetPhysicalDevice()); @@ -47,7 +47,7 @@ namespace Nz if (typeBits & typeMask) { if ((deviceInfo.memoryProperties.memoryTypes[i].propertyFlags & properties) == properties) - return Create(device, size, i, allocator); + return Create(std::move(device), size, i, allocator); } typeMask <<= 1; diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp index e807d774a..6ee48251e 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp @@ -24,7 +24,7 @@ namespace Nz inline DeviceObject(DeviceObject&& object); inline ~DeviceObject(); - inline bool Create(const DeviceHandle& device, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(DeviceHandle device, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); inline void Destroy(); inline bool IsValid() const; diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl index a68e7a469..8ea41182a 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl @@ -36,9 +36,9 @@ namespace Nz } template - inline bool DeviceObject::Create(const DeviceHandle& device, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator) + inline bool DeviceObject::Create(DeviceHandle device, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator) { - m_device = device; + m_device = std::move(device); m_lastErrorCode = C::CreateHelper(m_device, &createInfo, allocator, &m_handle); if (m_lastErrorCode != VkResult::VK_SUCCESS) { diff --git a/include/Nazara/VulkanRenderer/Wrapper/Pipeline.hpp b/include/Nazara/VulkanRenderer/Wrapper/Pipeline.hpp index ea323ec49..000f3de9c 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Pipeline.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Pipeline.hpp @@ -35,7 +35,7 @@ namespace Nz inline operator VkPipeline() const; protected: - inline bool Create(const DeviceHandle& device, VkResult result, const VkAllocationCallbacks* allocator); + inline bool Create(DeviceHandle device, VkResult result, const VkAllocationCallbacks* allocator); DeviceHandle m_device; VkAllocationCallbacks m_allocator; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Pipeline.inl b/include/Nazara/VulkanRenderer/Wrapper/Pipeline.inl index d55eb95d6..cecef540b 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Pipeline.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Pipeline.inl @@ -31,12 +31,12 @@ namespace Nz inline bool Pipeline::CreateCompute(const DeviceHandle& device, const VkComputePipelineCreateInfo& createInfo, VkPipelineCache cache, const VkAllocationCallbacks* allocator) { - return Create(device, device->vkCreateComputePipelines(*device, cache, 1U, &createInfo, allocator, &m_handle), allocator); + return Create(std::move(device), device->vkCreateComputePipelines(*device, cache, 1U, &createInfo, allocator, &m_handle), allocator); } inline bool Pipeline::CreateGraphics(const DeviceHandle& device, const VkGraphicsPipelineCreateInfo& createInfo, VkPipelineCache cache, const VkAllocationCallbacks* allocator) { - return Create(device, device->vkCreateGraphicsPipelines(*device, cache, 1U, &createInfo, allocator, &m_handle), allocator); + return Create(std::move(device), device->vkCreateGraphicsPipelines(*device, cache, 1U, &createInfo, allocator, &m_handle), allocator); } inline void Pipeline::Destroy() @@ -63,7 +63,7 @@ namespace Nz return m_handle; } - inline bool Pipeline::Create(const DeviceHandle& device, VkResult result, const VkAllocationCallbacks* allocator) + inline bool Pipeline::Create(DeviceHandle device, VkResult result, const VkAllocationCallbacks* allocator) { m_device = device; m_lastErrorCode = result; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Semaphore.hpp b/include/Nazara/VulkanRenderer/Wrapper/Semaphore.hpp index 8dfdf1cf9..e6e21289c 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Semaphore.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Semaphore.hpp @@ -25,7 +25,7 @@ namespace Nz ~Semaphore() = default; using DeviceObject::Create; - inline bool Create(const DeviceHandle& device, VkSemaphoreCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(DeviceHandle device, VkSemaphoreCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); Semaphore& operator=(const Semaphore&) = delete; Semaphore& operator=(Semaphore&&) = delete; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Semaphore.inl b/include/Nazara/VulkanRenderer/Wrapper/Semaphore.inl index 605a59c03..60f5c8afb 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Semaphore.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Semaphore.inl @@ -9,7 +9,7 @@ namespace Nz { namespace Vk { - inline bool Semaphore::Create(const DeviceHandle& device, VkSemaphoreCreateFlags flags, const VkAllocationCallbacks* allocator) + inline bool Semaphore::Create(DeviceHandle device, VkSemaphoreCreateFlags flags, const VkAllocationCallbacks* allocator) { VkSemaphoreCreateInfo createInfo = { @@ -18,7 +18,7 @@ namespace Nz flags }; - return Create(device, createInfo, allocator); + return Create(std::move(device), createInfo, allocator); } inline VkResult Semaphore::CreateHelper(const DeviceHandle& device, const VkSemaphoreCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSemaphore* handle) diff --git a/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp b/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp index db00805e5..fbc5bc6c2 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp @@ -25,7 +25,7 @@ namespace Nz ~ShaderModule() = default; using DeviceObject::Create; - inline bool Create(const DeviceHandle& device, const UInt32* code, std::size_t size, VkShaderModuleCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(DeviceHandle device, const UInt32* code, std::size_t size, VkShaderModuleCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); ShaderModule& operator=(const ShaderModule&) = delete; ShaderModule& operator=(ShaderModule&&) = delete; diff --git a/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.inl b/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.inl index fa9781226..dfe55a0e3 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.inl @@ -9,7 +9,7 @@ namespace Nz { namespace Vk { - inline bool ShaderModule::Create(const DeviceHandle& device, const UInt32* code, std::size_t size, VkShaderModuleCreateFlags flags, const VkAllocationCallbacks* allocator) + inline bool ShaderModule::Create(DeviceHandle device, const UInt32* code, std::size_t size, VkShaderModuleCreateFlags flags, const VkAllocationCallbacks* allocator) { VkShaderModuleCreateInfo createInfo = { @@ -20,7 +20,7 @@ namespace Nz code }; - return Create(device, createInfo, allocator); + return Create(std::move(device), createInfo, allocator); } inline VkResult ShaderModule::CreateHelper(const DeviceHandle& device, const VkShaderModuleCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkShaderModule* handle) diff --git a/include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp b/include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp index f3d2aac89..91672502e 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp @@ -29,7 +29,7 @@ namespace Nz inline bool AcquireNextImage(Nz::UInt64 timeout, VkSemaphore semaphore, VkFence fence, UInt32* imageIndex) const; - inline bool Create(const DeviceHandle& device, const VkSwapchainCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(DeviceHandle device, const VkSwapchainCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); inline const Buffer& GetBuffer(UInt32 index) const; inline const std::vector& GetBuffers() const; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Swapchain.inl b/include/Nazara/VulkanRenderer/Wrapper/Swapchain.inl index 5561ac3f0..2ad91cdb4 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Swapchain.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Swapchain.inl @@ -29,9 +29,9 @@ namespace Nz } } - inline bool Swapchain::Create(const DeviceHandle& device, const VkSwapchainCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) + inline bool Swapchain::Create(DeviceHandle device, const VkSwapchainCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) { - if (!DeviceObject::Create(device, createInfo, allocator)) + if (!DeviceObject::Create(std::move(device), createInfo, allocator)) return false; UInt32 imageCount = 0; diff --git a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp index cc1c7de57..62056f217 100644 --- a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp +++ b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp @@ -187,14 +187,14 @@ namespace Nz 1U // uint32_t layers; }; - if (!m_frameBuffers[i].Create(m_device->CreateHandle(), frameBufferCreate)) + if (!m_frameBuffers[i].Create(m_device, frameBufferCreate)) { NazaraError("Failed to create framebuffer for image #" + String::Number(i)); return false; } } - m_imageReadySemaphore.Create(m_device->CreateHandle()); + m_imageReadySemaphore.Create(m_device); m_clock.Restart(); @@ -221,14 +221,14 @@ namespace Nz VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout; }; - if (!m_depthBuffer.Create(m_device->CreateHandle(), imageCreateInfo)) + if (!m_depthBuffer.Create(m_device, imageCreateInfo)) { NazaraError("Failed to create depth buffer"); return false; } VkMemoryRequirements memoryReq = m_depthBuffer.GetMemoryRequirements(); - if (!m_depthBufferMemory.Create(m_device->CreateHandle(), memoryReq.size, memoryReq.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)) + if (!m_depthBufferMemory.Create(m_device, memoryReq.size, memoryReq.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)) { NazaraError("Failed to allocate depth buffer memory"); return false; @@ -262,7 +262,7 @@ namespace Nz } }; - if (!m_depthBufferView.Create(m_device->CreateHandle(), imageViewCreateInfo)) + if (!m_depthBufferView.Create(m_device, imageViewCreateInfo)) { NazaraError("Failed to create depth buffer view"); return false; @@ -356,7 +356,7 @@ namespace Nz dependencies.data() // const VkSubpassDependency* pDependencies; }; - return m_renderPass.Create(m_device->CreateHandle(), createInfo); + return m_renderPass.Create(m_device, createInfo); } bool VkRenderWindow::SetupSwapchain(Vk::Surface& surface, const Vector2ui& size) @@ -421,7 +421,7 @@ namespace Nz 0 }; - if (!m_swapchain.Create(m_device->CreateHandle(), swapchainInfo)) + if (!m_swapchain.Create(m_device, swapchainInfo)) { NazaraError("Failed to create swapchain"); return false; diff --git a/src/Nazara/VulkanRenderer/VulkanDevice.cpp b/src/Nazara/VulkanRenderer/VulkanDevice.cpp index 2557f28b0..d1c0e736e 100644 --- a/src/Nazara/VulkanRenderer/VulkanDevice.cpp +++ b/src/Nazara/VulkanRenderer/VulkanDevice.cpp @@ -11,6 +11,6 @@ namespace Nz std::unique_ptr VulkanDevice::InstantiateBuffer(Buffer* parent, BufferType type) { - return std::make_unique(CreateHandle(), parent, type); + return std::make_unique(shared_from_this(), parent, type); } } diff --git a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp index 247f5a27c..88dedd878 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp @@ -225,7 +225,7 @@ namespace Nz VkQueue queue; vkGetDeviceQueue(m_device, queueFamilyIndex, queueIndex, &queue); - return Queue(CreateHandle(), queue); + return Queue(shared_from_this(), queue); } } From 7bbba14ba0afabc14b31e1b607a7455ae40335b4 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 25 Feb 2020 20:22:46 +0100 Subject: [PATCH 088/316] Fix merge --- include/Nazara/Core/StringExt.hpp | 3 ++ include/Nazara/Core/StringExt.inl | 8 +++ .../Nazara/VulkanRenderer/Wrapper/Device.hpp | 8 +-- .../Nazara/VulkanRenderer/Wrapper/Device.inl | 4 +- src/Nazara/Core/StringExt.cpp | 51 +++++++++++++++++++ src/Nazara/Renderer/Renderer.cpp | 38 ++++++++------ src/Nazara/Utility/IndexBuffer.cpp | 4 +- src/Nazara/VulkanRenderer/Export.cpp | 2 +- src/Nazara/VulkanRenderer/Wrapper/Device.cpp | 4 +- src/Nazara/VulkanRenderer/Wrapper/Loader.cpp | 1 + 10 files changed, 97 insertions(+), 26 deletions(-) diff --git a/include/Nazara/Core/StringExt.hpp b/include/Nazara/Core/StringExt.hpp index 4d38014e7..f24c24305 100644 --- a/include/Nazara/Core/StringExt.hpp +++ b/include/Nazara/Core/StringExt.hpp @@ -29,6 +29,9 @@ namespace Nz inline bool IsNumber(const char* str); inline bool IsNumber(const std::string_view& str); + inline bool MatchPattern(const std::string_view& str, const char* pattern); + NAZARA_CORE_API bool MatchPattern(const std::string_view& str, const std::string_view& pattern); + template bool StartsWith(const std::string_view& str, const char* s, Args&&... args); inline bool StartsWith(const std::string_view& str, const std::string_view& s); NAZARA_CORE_API bool StartsWith(const std::string_view& str, const std::string_view& s, CaseIndependent); diff --git a/include/Nazara/Core/StringExt.inl b/include/Nazara/Core/StringExt.inl index 5203358f3..069cded5f 100644 --- a/include/Nazara/Core/StringExt.inl +++ b/include/Nazara/Core/StringExt.inl @@ -21,6 +21,14 @@ namespace Nz return !str.empty() && std::find_if(str.begin(), str.end(), [](unsigned char c) { return !std::isdigit(c); }) == str.end(); } + bool MatchPattern(const std::string_view& str, const char* pattern) + { + if (!pattern) + return false; + + return MatchPattern(str, std::string_view(pattern, std::strlen(pattern))); + } + template bool StartsWith(const std::string_view& str, const char* s, Args&&... args) { std::size_t size = std::strlen(s); diff --git a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp index 3d72b4b7d..cbf50d052 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp @@ -48,8 +48,8 @@ namespace Nz inline VkResult GetLastErrorCode() const; inline VkPhysicalDevice GetPhysicalDevice() const; - inline bool IsExtensionLoaded(const String& extensionName); - inline bool IsLayerLoaded(const String& layerName); + inline bool IsExtensionLoaded(const std::string& extensionName); + inline bool IsLayerLoaded(const std::string& layerName); inline bool WaitForIdle(); @@ -219,8 +219,8 @@ namespace Nz VkDevice m_device; VkPhysicalDevice m_physicalDevice; VkResult m_lastErrorCode; - std::unordered_set m_loadedExtensions; - std::unordered_set m_loadedLayers; + std::unordered_set m_loadedExtensions; + std::unordered_set m_loadedLayers; std::vector m_enabledQueuesInfos; std::vector m_queuesByFamily; }; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Device.inl b/include/Nazara/VulkanRenderer/Wrapper/Device.inl index 92e32e0dc..0f85878f5 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Device.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Device.inl @@ -68,12 +68,12 @@ namespace Nz return m_physicalDevice; } - inline bool Device::IsExtensionLoaded(const String& extensionName) + inline bool Device::IsExtensionLoaded(const std::string& extensionName) { return m_loadedExtensions.count(extensionName) > 0; } - inline bool Device::IsLayerLoaded(const String& layerName) + inline bool Device::IsLayerLoaded(const std::string& layerName) { return m_loadedLayers.count(layerName) > 0; } diff --git a/src/Nazara/Core/StringExt.cpp b/src/Nazara/Core/StringExt.cpp index 2238a3810..b1bd95042 100644 --- a/src/Nazara/Core/StringExt.cpp +++ b/src/Nazara/Core/StringExt.cpp @@ -118,6 +118,57 @@ namespace Nz return WideConverter::From(wstr.data(), wstr.size()); } + bool MatchPattern(const std::string_view& str, const std::string_view& pattern) + { + if (str.empty() || pattern.empty()) + return false; + + // Par Jack Handy - akkhandy@hotmail.com + // From : http://www.codeproject.com/Articles/1088/Wildcard-string-compare-globbing + const char* ptr = str.data(); + const char* ptrEnd = str.data() + str.size(); + + const char* patternPtr = pattern.data(); + const char* patternPtrEnd = pattern.data() + pattern.size(); + + while (ptr < ptrEnd && *patternPtr != '*') + { + if (patternPtr < patternPtrEnd && *patternPtr != *ptr && *patternPtr != '?') + return false; + + patternPtr++; + ptr++; + } + + const char* cp = nullptr; + const char* mp = nullptr; + while (*ptr) + { + if (*patternPtr == '*') + { + if (patternPtr + 1 >= patternPtrEnd) + return true; + + mp = ++patternPtr; + cp = ptr + 1; + } + else if (*patternPtr == *ptr || *patternPtr == '?') + { + patternPtr++; + ptr++; + } + else + { + patternPtr = mp; + ptr = cp++; + } + } + + while (patternPtr < patternPtrEnd && *patternPtr == '*') + patternPtr++; + + return patternPtr >= patternPtrEnd; + } bool StartsWith(const std::string_view& str, const std::string_view& s, CaseIndependent) { if (s.size() > str.size()) diff --git a/src/Nazara/Renderer/Renderer.cpp b/src/Nazara/Renderer/Renderer.cpp index 737b63b08..ea21ee99d 100644 --- a/src/Nazara/Renderer/Renderer.cpp +++ b/src/Nazara/Renderer/Renderer.cpp @@ -4,16 +4,23 @@ #include #include -#include #include #include +#include #include #include #include #include #include +#include #include +#ifdef NAZARA_DEBUG + #define NazaraRendererPattern "Nazara?*Renderer-d" NAZARA_DYNLIB_EXTENSION +#else + #define NazaraRendererPattern "Nazara?*Renderer" NAZARA_DYNLIB_EXTENSION +#endif + namespace Nz { bool Renderer::Initialize() @@ -43,32 +50,33 @@ namespace Nz NazaraDebug("Searching for renderer implementation"); - Directory dir("."); - dir.SetPattern("Nazara?*Renderer*" NAZARA_DYNLIB_EXTENSION); //< Ex: NazaraVulkanRenderer.dll - - if (!dir.Open()) - { - NazaraError("Failed to open directory"); - return false; - } - DynLib chosenLib; std::unique_ptr chosenImpl; - while (dir.NextResult()) + + for (auto&& entry : std::filesystem::directory_iterator(".")) { - NazaraDebug("Trying to load " + dir.GetResultName()); + if (!entry.is_regular_file()) + continue; + + const std::filesystem::path& entryPath = entry.path(); + std::filesystem::path fileName = entryPath.filename(); + std::string fileNameStr = fileName.generic_u8string(); + if (!MatchPattern(fileNameStr, NazaraRendererPattern)) + continue; + + NazaraDebug("Trying to load " + fileNameStr); DynLib implLib; - if (!implLib.Load(dir.GetResultPath())) + if (!implLib.Load(entryPath)) { - NazaraWarning("Failed to load " + dir.GetResultName() + ": " + implLib.GetLastError()); + NazaraWarning("Failed to load " + fileNameStr + ": " + implLib.GetLastError()); continue; } CreateRendererImplFunc createRenderer = reinterpret_cast(implLib.GetSymbol("NazaraRenderer_Instantiate")); if (!createRenderer) { - NazaraDebug("Skipped " + dir.GetResultName() + " (symbol not found)"); + NazaraDebug("Skipped " + fileNameStr + " (symbol not found)"); continue; } diff --git a/src/Nazara/Utility/IndexBuffer.cpp b/src/Nazara/Utility/IndexBuffer.cpp index 6ac75bda4..c0af3c123 100644 --- a/src/Nazara/Utility/IndexBuffer.cpp +++ b/src/Nazara/Utility/IndexBuffer.cpp @@ -110,7 +110,7 @@ namespace Nz NazaraAssert(size > 0, "Invalid size"); NazaraAssert(offset + size > buffer->GetSize(), "Virtual buffer exceed buffer bounds"); - std::size_t stride = static_cast((largeIndices) ? sizeof(std::size_t) : sizeof(UInt16)); + std::size_t stride = static_cast((largeIndices) ? sizeof(UInt32) : sizeof(UInt16)); m_buffer = buffer; m_endOffset = offset + size; @@ -121,7 +121,7 @@ namespace Nz void IndexBuffer::Reset(bool largeIndices, std::size_t length, DataStorage storage, BufferUsageFlags usage) { - std::size_t stride = static_cast((largeIndices) ? sizeof(std::size_t) : sizeof(UInt16)); + std::size_t stride = static_cast((largeIndices) ? sizeof(UInt32) : sizeof(UInt16)); m_endOffset = length * stride; m_indexCount = length; diff --git a/src/Nazara/VulkanRenderer/Export.cpp b/src/Nazara/VulkanRenderer/Export.cpp index 321038299..6c9bbaf0f 100644 --- a/src/Nazara/VulkanRenderer/Export.cpp +++ b/src/Nazara/VulkanRenderer/Export.cpp @@ -9,7 +9,7 @@ extern "C" { NAZARA_EXPORT Nz::RendererImpl* NazaraRenderer_Instantiate() { - std::unique_ptr renderer(new Nz::VulkanRenderer); + std::unique_ptr renderer = std::make_unique(); return renderer.release(); } } diff --git a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp index 88dedd878..26e6c949e 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp @@ -38,10 +38,10 @@ namespace Nz // Parse extensions and layers for (UInt32 i = 0; i < createInfo.enabledExtensionCount; ++i) - m_loadedExtensions.insert(createInfo.ppEnabledExtensionNames[i]); + m_loadedExtensions.emplace(createInfo.ppEnabledExtensionNames[i]); for (UInt32 i = 0; i < createInfo.enabledLayerCount; ++i) - m_loadedLayers.insert(createInfo.ppEnabledLayerNames[i]); + m_loadedLayers.emplace(createInfo.ppEnabledLayerNames[i]); // Load all device-related functions #define NAZARA_VULKANRENDERER_LOAD_DEVICE(func) func = reinterpret_cast(GetProcAddr(#func)) diff --git a/src/Nazara/VulkanRenderer/Wrapper/Loader.cpp b/src/Nazara/VulkanRenderer/Wrapper/Loader.cpp index c1d62f715..b5f0df100 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/Loader.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Loader.cpp @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include #include From c05ea4095adf84666a29402ca187baaeb086c083 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 25 Feb 2020 22:56:08 +0100 Subject: [PATCH 089/316] Begin work on RenderPipeline --- examples/VulkanTest/main.cpp | 86 +++++++++---------- include/Nazara/Renderer.hpp | 8 +- include/Nazara/Renderer/RenderDevice.hpp | 2 + include/Nazara/Renderer/RenderPipeline.hpp | 21 ++--- include/Nazara/Renderer/RenderPipeline.inl | 35 -------- include/Nazara/Renderer/RenderStates.hpp | 49 ++--------- include/Nazara/Renderer/RenderStates.inl | 64 +++++++------- include/Nazara/Renderer/RenderWindow.hpp | 3 + include/Nazara/Renderer/RenderWindowImpl.hpp | 3 + include/Nazara/Utility.hpp | 1 + include/Nazara/VulkanRenderer.hpp | 1 + include/Nazara/VulkanRenderer/Utils.hpp | 5 ++ include/Nazara/VulkanRenderer/Utils.inl | 49 +++++++++++ .../Nazara/VulkanRenderer/VkRenderWindow.hpp | 2 + .../Nazara/VulkanRenderer/VkRenderWindow.inl | 5 ++ .../Nazara/VulkanRenderer/VulkanDevice.hpp | 1 + .../VulkanRenderer/VulkanRenderPipeline.hpp | 34 ++++++++ .../VulkanRenderer/VulkanRenderPipeline.inl | 12 +++ src/Nazara/Renderer/RenderPipeline.cpp | 11 +++ src/Nazara/Renderer/RenderWindow.cpp | 8 ++ src/Nazara/VulkanRenderer/VulkanDevice.cpp | 6 ++ .../VulkanRenderer/VulkanRenderPipeline.cpp | 51 +++++++++++ 22 files changed, 284 insertions(+), 173 deletions(-) create mode 100644 include/Nazara/VulkanRenderer/Utils.inl create mode 100644 include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp create mode 100644 include/Nazara/VulkanRenderer/VulkanRenderPipeline.inl create mode 100644 src/Nazara/Renderer/RenderPipeline.cpp create mode 100644 src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index c579594be..907bc43a0 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -122,6 +122,8 @@ int main() return __LINE__; } + std::shared_ptr device = window.GetRenderDevice(); + Nz::VkRenderWindow& vulkanWindow = *static_cast(window.GetImpl()); /*VkPhysicalDeviceFeatures features; @@ -136,17 +138,17 @@ int main() std::vector queues; instance.GetPhysicalDeviceQueueFamilyProperties(physDevice, &queues);*/ - Nz::VulkanDevice& device = vulkanWindow.GetDevice(); + Nz::VulkanDevice& vulkanDevice = vulkanWindow.GetDevice(); Nz::Vk::ShaderModule vertexShader; - if (!vertexShader.Create(device.shared_from_this(), reinterpret_cast(vertexShaderCode.data()), vertexShaderCode.size())) + if (!vertexShader.Create(vulkanDevice.shared_from_this(), reinterpret_cast(vertexShaderCode.data()), vertexShaderCode.size())) { NazaraError("Failed to create vertex shader"); return __LINE__; } Nz::Vk::ShaderModule fragmentShader; - if (!fragmentShader.Create(device.shared_from_this(), reinterpret_cast(fragmentShaderCode.data()), fragmentShaderCode.size())) + if (!fragmentShader.Create(vulkanDevice.shared_from_this(), reinterpret_cast(fragmentShaderCode.data()), fragmentShaderCode.size())) { NazaraError("Failed to create fragment shader"); return __LINE__; @@ -169,25 +171,25 @@ int main() std::cout << "Index count: " << drfreakIB->GetIndexCount() << std::endl; Nz::RenderBuffer* renderBufferIB = static_cast(drfreakIB->GetBuffer()->GetImpl()); - if (!renderBufferIB->Synchronize(&device)) + if (!renderBufferIB->Synchronize(&vulkanDevice)) { NazaraError("Failed to synchronize render buffer"); return __LINE__; } - Nz::VulkanBuffer* indexBufferImpl = static_cast(renderBufferIB->GetHardwareBuffer(&device)); + Nz::VulkanBuffer* indexBufferImpl = static_cast(renderBufferIB->GetHardwareBuffer(&vulkanDevice)); // Index buffer std::cout << "Vertex count: " << drfreakVB->GetVertexCount() << std::endl; Nz::RenderBuffer* renderBufferVB = static_cast(drfreakVB->GetBuffer()->GetImpl()); - if (!renderBufferVB->Synchronize(&device)) + if (!renderBufferVB->Synchronize(&vulkanDevice)) { NazaraError("Failed to synchronize render buffer"); return __LINE__; } - Nz::VulkanBuffer* vertexBufferImpl = static_cast(renderBufferVB->GetHardwareBuffer(&device)); + Nz::VulkanBuffer* vertexBufferImpl = static_cast(renderBufferVB->GetHardwareBuffer(&vulkanDevice)); struct { @@ -205,7 +207,7 @@ int main() Nz::UInt32 uniformSize = sizeof(ubo); Nz::Vk::Buffer uniformBuffer; - if (!uniformBuffer.Create(device.shared_from_this(), 0, uniformSize, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT)) + if (!uniformBuffer.Create(vulkanDevice.shared_from_this(), 0, uniformSize, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT)) { NazaraError("Failed to create vertex buffer"); return __LINE__; @@ -214,7 +216,7 @@ int main() VkMemoryRequirements memRequirement = uniformBuffer.GetMemoryRequirements(); Nz::Vk::DeviceMemory uniformBufferMemory; - if (!uniformBufferMemory.Create(device.shared_from_this(), memRequirement.size, memRequirement.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) + if (!uniformBufferMemory.Create(vulkanDevice.shared_from_this(), memRequirement.size, memRequirement.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) { NazaraError("Failed to allocate vertex buffer memory"); return __LINE__; @@ -245,7 +247,7 @@ int main() layoutBinding.pImmutableSamplers = nullptr; Nz::Vk::DescriptorSetLayout descriptorLayout; - if (!descriptorLayout.Create(device.shared_from_this(), layoutBinding)) + if (!descriptorLayout.Create(vulkanDevice.shared_from_this(), layoutBinding)) { NazaraError("Failed to create descriptor set layout"); return __LINE__; @@ -256,7 +258,7 @@ int main() poolSize.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; Nz::Vk::DescriptorPool descriptorPool; - if (!descriptorPool.Create(device.shared_from_this(), 1, poolSize, VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT)) + if (!descriptorPool.Create(vulkanDevice.shared_from_this(), 1, poolSize, VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT)) { NazaraError("Failed to create descriptor pool"); return __LINE__; @@ -266,6 +268,28 @@ int main() descriptorSet.WriteUniformDescriptor(0, uniformBuffer, 0, uniformSize); + Nz::RenderPipelineInfo pipelineInfo; + pipelineInfo.depthBuffer = true; + pipelineInfo.depthCompare = Nz::RendererComparison_Equal; + + std::unique_ptr pipeline = device->InstantiateRenderPipeline(pipelineInfo); + + VkDescriptorSetLayout descriptorSetLayout = descriptorLayout; + + VkPipelineLayoutCreateInfo layout_create_info = { + VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, // VkStructureType sType + nullptr, // const void *pNext + 0, // VkPipelineLayoutCreateFlags flags + 1U, // uint32_t setLayoutCount + &descriptorSetLayout, // const VkDescriptorSetLayout *pSetLayouts + 0, // uint32_t pushConstantRangeCount + nullptr // const VkPushConstantRange *pPushConstantRanges + }; + + Nz::Vk::PipelineLayout pipelineLayout; + pipelineLayout.Create(vulkanDevice.shared_from_this(), layout_create_info); + + std::array shaderStageCreateInfo = { { { @@ -392,21 +416,6 @@ int main() {0.0f, 0.0f, 0.0f, 0.0f} // float blendConstants[4] }; - VkDescriptorSetLayout descriptorSetLayout = descriptorLayout; - - VkPipelineLayoutCreateInfo layout_create_info = { - VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, // VkStructureType sType - nullptr, // const void *pNext - 0, // VkPipelineLayoutCreateFlags flags - 1U, // uint32_t setLayoutCount - &descriptorSetLayout, // const VkDescriptorSetLayout *pSetLayouts - 0, // uint32_t pushConstantRangeCount - nullptr // const VkPushConstantRange *pPushConstantRanges - }; - - Nz::Vk::PipelineLayout pipelineLayout; - pipelineLayout.Create(device.shared_from_this(), layout_create_info); - std::array dynamicStates = { VK_DYNAMIC_STATE_SCISSOR, VK_DYNAMIC_STATE_VIEWPORT, @@ -420,20 +429,7 @@ int main() dynamicStates.data() // const VkDynamicState* pDynamicStates; }; - VkPipelineDepthStencilStateCreateInfo depthStencilInfo = { - VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, // VkStructureType sType; - nullptr, // const void* pNext; - 0U, // VkPipelineDepthStencilStateCreateFlags flags; - VK_TRUE, // VkBool32 depthTestEnable; - VK_TRUE, // VkBool32 depthWriteEnable; - VK_COMPARE_OP_LESS_OR_EQUAL, // VkCompareOp depthCompareOp; - VK_FALSE, // VkBool32 depthBoundsTestEnable; - VK_FALSE, // VkBool32 stencilTestEnable; - VkStencilOpState{},// VkStencilOpState front; - VkStencilOpState{},// VkStencilOpState back; - 0.f, // float minDepthBounds; - 0.f // float maxDepthBounds; - }; + VkPipelineDepthStencilStateCreateInfo depthStencilInfo = Nz::VulkanRenderPipeline::BuildDepthStencilInfo(pipelineInfo); VkGraphicsPipelineCreateInfo pipeline_create_info = { VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, // VkStructureType sType @@ -457,15 +453,15 @@ int main() -1 // int32_t basePipelineIndex }; - Nz::Vk::Pipeline pipeline; - if (!pipeline.CreateGraphics(device.shared_from_this(), pipeline_create_info)) + Nz::Vk::Pipeline vkPipeline; + if (!vkPipeline.CreateGraphics(vulkanDevice.shared_from_this(), pipeline_create_info)) { NazaraError("Failed to create pipeline"); return __LINE__; } Nz::Vk::CommandPool cmdPool; - if (!cmdPool.Create(device.shared_from_this(), 0, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)) + if (!cmdPool.Create(vulkanDevice.shared_from_this(), 0, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)) { NazaraError("Failed to create rendering cmd pool"); return __LINE__; @@ -475,7 +471,7 @@ int main() clearValues[0].color = {1.0f, 0.8f, 0.4f, 0.0f}; clearValues[1].depthStencil = {1.f, 0}; - Nz::Vk::Queue graphicsQueue(device.shared_from_this(), device.GetEnabledQueues()[0].queues[0].queue); + Nz::Vk::Queue graphicsQueue(vulkanDevice.shared_from_this(), vulkanDevice.GetEnabledQueues()[0].queues[0].queue); Nz::UInt32 imageCount = vulkanWindow.GetFramebufferCount(); std::vector renderCmds = cmdPool.AllocateCommandBuffers(imageCount, VK_COMMAND_BUFFER_LEVEL_PRIMARY); @@ -532,7 +528,7 @@ int main() renderCmd.BindIndexBuffer(indexBufferImpl->GetBufferHandle(), 0, VK_INDEX_TYPE_UINT16); renderCmd.BindVertexBuffer(0, vertexBufferImpl->GetBufferHandle(), 0); renderCmd.BindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, descriptorSet); - renderCmd.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); + renderCmd.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, vkPipeline); renderCmd.SetScissor(Nz::Recti{0, 0, int(windowSize.x), int(windowSize.y)}); renderCmd.SetViewport({0.f, 0.f, float(windowSize.x), float(windowSize.y)}, 0.f, 1.f); renderCmd.DrawIndexed(drfreakIB->GetIndexCount()); diff --git a/include/Nazara/Renderer.hpp b/include/Nazara/Renderer.hpp index d64926f30..652538c6b 100644 --- a/include/Nazara/Renderer.hpp +++ b/include/Nazara/Renderer.hpp @@ -30,21 +30,17 @@ #define NAZARA_GLOBAL_RENDERER_HPP #include -#include #include #include #include -#include #include -#include #include +#include #include #include #include #include #include -#include -#include #include #include #include @@ -53,7 +49,5 @@ #include #include #include -#include -#include #endif // NAZARA_GLOBAL_RENDERER_HPP diff --git a/include/Nazara/Renderer/RenderDevice.hpp b/include/Nazara/Renderer/RenderDevice.hpp index f01ea5ec5..18f27bc5e 100644 --- a/include/Nazara/Renderer/RenderDevice.hpp +++ b/include/Nazara/Renderer/RenderDevice.hpp @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -23,6 +24,7 @@ namespace Nz virtual ~RenderDevice(); virtual std::unique_ptr InstantiateBuffer(Buffer* parent, BufferType type) = 0; + virtual std::unique_ptr InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) = 0; }; } diff --git a/include/Nazara/Renderer/RenderPipeline.hpp b/include/Nazara/Renderer/RenderPipeline.hpp index 846cfb4af..d78270ca2 100644 --- a/include/Nazara/Renderer/RenderPipeline.hpp +++ b/include/Nazara/Renderer/RenderPipeline.hpp @@ -9,31 +9,20 @@ #include #include -#include +//#include namespace Nz { struct RenderPipelineInfo : RenderStates { - ShaderConstRef shader; + /*ShaderConstRef shader;*/ }; - class RenderPipeline + class NAZARA_RENDERER_API RenderPipeline { public: - inline RenderPipeline(); - inline ~RenderPipeline(); - - inline bool Create(const RenderPipelineInfo& pipelineInfo); - inline void Destroy(); - - inline const RenderPipelineInfo& GetInfo() const; - - inline bool IsValid() const; - - private: - RenderPipelineInfo m_pipelineInfo; - bool m_valid; + RenderPipeline() = default; + virtual ~RenderPipeline(); }; } diff --git a/include/Nazara/Renderer/RenderPipeline.inl b/include/Nazara/Renderer/RenderPipeline.inl index 2a1aef815..991e50a2c 100644 --- a/include/Nazara/Renderer/RenderPipeline.inl +++ b/include/Nazara/Renderer/RenderPipeline.inl @@ -8,41 +8,6 @@ namespace Nz { - inline RenderPipeline::RenderPipeline() : - m_valid(false) - { - } - - inline RenderPipeline::~RenderPipeline() - { - } - - inline bool RenderPipeline::Create(const RenderPipelineInfo& pipelineInfo) - { - NazaraAssert(pipelineInfo.shader, "Invalid shader"); - - m_pipelineInfo = pipelineInfo; - m_valid = true; - - return true; - } - - inline void RenderPipeline::Destroy() - { - m_valid = false; - } - - inline const RenderPipelineInfo& RenderPipeline::GetInfo() const - { - NazaraAssert(m_valid, "Invalid pipeline info"); - - return m_pipelineInfo; - } - - inline bool RenderPipeline::IsValid() const - { - return m_valid; - } } #include diff --git a/include/Nazara/Renderer/RenderStates.hpp b/include/Nazara/Renderer/RenderStates.hpp index 642f9e93f..5fec08981 100644 --- a/include/Nazara/Renderer/RenderStates.hpp +++ b/include/Nazara/Renderer/RenderStates.hpp @@ -18,49 +18,18 @@ namespace Nz BlendFunc srcBlend = BlendFunc_One; FaceFilling faceFilling = FaceFilling_Fill; FaceSide cullingSide = FaceSide_Back; - RendererComparison depthFunc = RendererComparison_Less; + RendererComparison depthCompare = RendererComparison_Less; struct { - RendererComparison back = RendererComparison_Always; - RendererComparison front = RendererComparison_Always; - } stencilCompare; - - struct - { - UInt32 back = 0xFFFFFFFF; - UInt32 front = 0xFFFFFFFF; - } stencilCompareMask; - - struct - { - StencilOperation back = StencilOperation_Keep; - StencilOperation front = StencilOperation_Keep; - } stencilDepthFail; - - struct - { - StencilOperation back = StencilOperation_Keep; - StencilOperation front = StencilOperation_Keep; - } stencilFail; - - struct - { - StencilOperation back = StencilOperation_Keep; - StencilOperation front = StencilOperation_Keep; - } stencilPass; - - struct - { - UInt32 back = 0U; - UInt32 front = 0U; - } stencilReference; - - struct - { - UInt32 back = 0xFFFFFFFF; - UInt32 front = 0xFFFFFFFF; - } stencilWriteMask; + RendererComparison compare = RendererComparison_Always; + StencilOperation depthFail = StencilOperation_Keep; + StencilOperation fail = StencilOperation_Keep; + StencilOperation pass = StencilOperation_Keep; + UInt32 compareMask = 0xFFFFFFFF; + UInt32 reference = 0; + UInt32 writeMask = 0xFFFFFFFF; + } stencilBack, stencilFront; bool blending = false; bool colorWrite = true; diff --git a/include/Nazara/Renderer/RenderStates.inl b/include/Nazara/Renderer/RenderStates.inl index 7f976ff13..4d521e65c 100644 --- a/include/Nazara/Renderer/RenderStates.inl +++ b/include/Nazara/Renderer/RenderStates.inl @@ -35,27 +35,28 @@ namespace Nz } if (lhs.depthBuffer) - NazaraRenderStateMember(depthFunc); + NazaraRenderStateMember(depthCompare); if (lhs.faceCulling) NazaraRenderStateMember(cullingSide); if (lhs.stencilTest) { - NazaraRenderStateMember(stencilCompare.back); - NazaraRenderStateMember(stencilCompare.front); - NazaraRenderStateMember(stencilCompareMask.back); - NazaraRenderStateMember(stencilCompareMask.front); - NazaraRenderStateMember(stencilDepthFail.back); - NazaraRenderStateMember(stencilDepthFail.front); - NazaraRenderStateMember(stencilFail.back); - NazaraRenderStateMember(stencilFail.front); - NazaraRenderStateMember(stencilPass.back); - NazaraRenderStateMember(stencilPass.front); - NazaraRenderStateMember(stencilReference.back); - NazaraRenderStateMember(stencilReference.front); - NazaraRenderStateMember(stencilWriteMask.back); - NazaraRenderStateMember(stencilWriteMask.front); + NazaraRenderStateMember(stencilBack.compare); + NazaraRenderStateMember(stencilBack.compareMask); + NazaraRenderStateMember(stencilBack.depthFail); + NazaraRenderStateMember(stencilBack.fail); + NazaraRenderStateMember(stencilBack.pass); + NazaraRenderStateMember(stencilBack.reference); + NazaraRenderStateMember(stencilBack.writeMask); + + NazaraRenderStateMember(stencilFront.compare); + NazaraRenderStateMember(stencilFront.compareMask); + NazaraRenderStateMember(stencilFront.depthFail); + NazaraRenderStateMember(stencilFront.fail); + NazaraRenderStateMember(stencilFront.pass); + NazaraRenderStateMember(stencilFront.reference); + NazaraRenderStateMember(stencilFront.writeMask); } NazaraRenderStateFloatMember(lineWidth, 0.001f); @@ -85,6 +86,7 @@ namespace std #define NazaraRenderStateBoolDep(dependency, member) parameterHash |= ((pipelineInfo.dependency && pipelineInfo.member) ? 1U : 0U) << (parameterIndex++) #define NazaraRenderStateEnum(member) Nz::HashCombine(seed, static_cast(pipelineInfo.member)) #define NazaraRenderStateFloat(member, maxDiff) Nz::HashCombine(seed, std::floor(pipelineInfo.member / maxDiff) * maxDiff) + #define NazaraRenderStateUInt32(member) Nz::HashCombine(seed, pipelineInfo.member) NazaraRenderStateBool(blending); NazaraRenderStateBool(colorWrite); @@ -104,27 +106,28 @@ namespace std } if (pipelineInfo.depthBuffer) - NazaraRenderStateEnum(depthFunc); + NazaraRenderStateEnum(depthCompare); if (pipelineInfo.faceCulling) NazaraRenderStateEnum(cullingSide); if (pipelineInfo.stencilTest) { - NazaraRenderStateEnum(stencilCompare.back); - NazaraRenderStateEnum(stencilCompare.front); - NazaraRenderStateEnum(stencilCompareMask.back); - NazaraRenderStateEnum(stencilCompareMask.front); - NazaraRenderStateEnum(stencilDepthFail.back); - NazaraRenderStateEnum(stencilDepthFail.front); - NazaraRenderStateEnum(stencilFail.back); - NazaraRenderStateEnum(stencilFail.front); - NazaraRenderStateEnum(stencilPass.back); - NazaraRenderStateEnum(stencilPass.front); - NazaraRenderStateEnum(stencilReference.back); - NazaraRenderStateEnum(stencilReference.front); - NazaraRenderStateEnum(stencilWriteMask.back); - NazaraRenderStateEnum(stencilWriteMask.front); + NazaraRenderStateEnum(stencilBack.compare); + NazaraRenderStateUInt32(stencilBack.compareMask); + NazaraRenderStateEnum(stencilBack.depthFail); + NazaraRenderStateEnum(stencilBack.fail); + NazaraRenderStateEnum(stencilBack.pass); + NazaraRenderStateUInt32(stencilBack.reference); + NazaraRenderStateUInt32(stencilBack.writeMask); + + NazaraRenderStateEnum(stencilFront.compare); + NazaraRenderStateUInt32(stencilFront.compareMask); + NazaraRenderStateEnum(stencilFront.depthFail); + NazaraRenderStateEnum(stencilFront.fail); + NazaraRenderStateEnum(stencilFront.pass); + NazaraRenderStateUInt32(stencilFront.reference); + NazaraRenderStateUInt32(stencilFront.writeMask); } NazaraRenderStateFloat(lineWidth, 0.001f); @@ -134,6 +137,7 @@ namespace std #undef NazaraRenderStateBoolDep #undef NazaraRenderStateEnum #undef NazaraRenderStateFloat + #undef NazaraRenderStateUInt32 Nz::HashCombine(seed, parameterHash); diff --git a/include/Nazara/Renderer/RenderWindow.hpp b/include/Nazara/Renderer/RenderWindow.hpp index 73dfa55a9..b15d3bb51 100644 --- a/include/Nazara/Renderer/RenderWindow.hpp +++ b/include/Nazara/Renderer/RenderWindow.hpp @@ -19,6 +19,8 @@ namespace Nz { + class RenderDevice; + class NAZARA_RENDERER_API RenderWindow : public Window { public: @@ -34,6 +36,7 @@ namespace Nz void EnableVerticalSync(bool enabled); inline RenderWindowImpl* GetImpl(); + std::shared_ptr GetRenderDevice(); inline bool IsValid() const; diff --git a/include/Nazara/Renderer/RenderWindowImpl.hpp b/include/Nazara/Renderer/RenderWindowImpl.hpp index e5abd0c98..df67001c5 100644 --- a/include/Nazara/Renderer/RenderWindowImpl.hpp +++ b/include/Nazara/Renderer/RenderWindowImpl.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -26,6 +27,8 @@ namespace Nz virtual ~RenderWindowImpl(); virtual bool Create(RendererImpl* renderer, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) = 0; + + virtual std::shared_ptr GetRenderDevice() = 0; }; } diff --git a/include/Nazara/Utility.hpp b/include/Nazara/Utility.hpp index 97deaca58..735b83c32 100644 --- a/include/Nazara/Utility.hpp +++ b/include/Nazara/Utility.hpp @@ -63,6 +63,7 @@ #include #include #include +#include #include #include #include diff --git a/include/Nazara/VulkanRenderer.hpp b/include/Nazara/VulkanRenderer.hpp index ed3a8c88f..71c764abf 100644 --- a/include/Nazara/VulkanRenderer.hpp +++ b/include/Nazara/VulkanRenderer.hpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include diff --git a/include/Nazara/VulkanRenderer/Utils.hpp b/include/Nazara/VulkanRenderer/Utils.hpp index 5fa483b5c..bd4ea0563 100644 --- a/include/Nazara/VulkanRenderer/Utils.hpp +++ b/include/Nazara/VulkanRenderer/Utils.hpp @@ -9,11 +9,16 @@ #include #include +#include #include namespace Nz { + inline VkCompareOp ToVulkan(RendererComparison comparison); + inline VkStencilOp ToVulkan(StencilOperation stencilOp); NAZARA_VULKANRENDERER_API String TranslateVulkanError(VkResult code); } +#include + #endif // NAZARA_UTILS_VULKAN_HPP diff --git a/include/Nazara/VulkanRenderer/Utils.inl b/include/Nazara/VulkanRenderer/Utils.inl new file mode 100644 index 000000000..dfc13cd1f --- /dev/null +++ b/include/Nazara/VulkanRenderer/Utils.inl @@ -0,0 +1,49 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include + +namespace Nz +{ + inline VkCompareOp ToVulkan(RendererComparison comparison) + { + switch (comparison) + { + case RendererComparison_Never: return VK_COMPARE_OP_NEVER; + case RendererComparison_Less: return VK_COMPARE_OP_LESS; + case RendererComparison_Equal: return VK_COMPARE_OP_EQUAL; + case RendererComparison_LessOrEqual: return VK_COMPARE_OP_LESS_OR_EQUAL; + case RendererComparison_Greater: return VK_COMPARE_OP_GREATER; + case RendererComparison_NotEqual: return VK_COMPARE_OP_NOT_EQUAL; + case RendererComparison_GreaterOrEqual: return VK_COMPARE_OP_GREATER_OR_EQUAL; + case RendererComparison_Always: return VK_COMPARE_OP_ALWAYS; + } + + NazaraError("Unhandled RendererComparison 0x" + String::Number(comparison, 16)); + return VK_COMPARE_OP_NEVER; + } + + VkStencilOp ToVulkan(StencilOperation stencilOp) + { + switch (stencilOp) + { + case StencilOperation_Decrement: return VK_STENCIL_OP_DECREMENT_AND_CLAMP; + case StencilOperation_DecrementNoClamp: return VK_STENCIL_OP_DECREMENT_AND_WRAP; + case StencilOperation_Increment: return VK_STENCIL_OP_INCREMENT_AND_CLAMP; + case StencilOperation_IncrementNoClamp: return VK_STENCIL_OP_INCREMENT_AND_WRAP; + case StencilOperation_Invert: return VK_STENCIL_OP_INVERT; + case StencilOperation_Keep: return VK_STENCIL_OP_KEEP; + case StencilOperation_Replace: return VK_STENCIL_OP_REPLACE; + case StencilOperation_Zero: return VK_STENCIL_OP_ZERO; + } + + NazaraError("Unhandled RendererComparison 0x" + String::Number(stencilOp, 16)); + return VK_STENCIL_OP_KEEP; + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp index 38c464986..1ed643149 100644 --- a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp +++ b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp @@ -51,6 +51,8 @@ namespace Nz inline UInt32 GetPresentableFamilyQueue() const; inline const Vk::Swapchain& GetSwapchain() const; + std::shared_ptr GetRenderDevice() override; + void Present(UInt32 imageIndex) override; VkRenderWindow& operator=(const VkRenderWindow&) = delete; diff --git a/include/Nazara/VulkanRenderer/VkRenderWindow.inl b/include/Nazara/VulkanRenderer/VkRenderWindow.inl index 0721f4762..11310e89b 100644 --- a/include/Nazara/VulkanRenderer/VkRenderWindow.inl +++ b/include/Nazara/VulkanRenderer/VkRenderWindow.inl @@ -37,6 +37,11 @@ namespace Nz return m_swapchain; } + inline std::shared_ptr Nz::VkRenderWindow::GetRenderDevice() + { + return m_device; + } + inline void VkRenderWindow::Present(UInt32 imageIndex) { NazaraAssert(imageIndex < m_frameBuffers.size(), "Invalid image index"); diff --git a/include/Nazara/VulkanRenderer/VulkanDevice.hpp b/include/Nazara/VulkanRenderer/VulkanDevice.hpp index 5ec2a891c..291aa7b3e 100644 --- a/include/Nazara/VulkanRenderer/VulkanDevice.hpp +++ b/include/Nazara/VulkanRenderer/VulkanDevice.hpp @@ -24,6 +24,7 @@ namespace Nz ~VulkanDevice(); std::unique_ptr InstantiateBuffer(Buffer* parent, BufferType type) override; + std::unique_ptr InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) override; VulkanDevice& operator=(const VulkanDevice&) = delete; VulkanDevice& operator=(VulkanDevice&&) = delete; ///TODO? diff --git a/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp b/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp new file mode 100644 index 000000000..34e39a990 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp @@ -0,0 +1,34 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VULKANRENDERPIPELINE_HPP +#define NAZARA_VULKANRENDERER_VULKANRENDERPIPELINE_HPP + +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_VULKANRENDERER_API VulkanRenderPipeline : public RenderPipeline + { + public: + VulkanRenderPipeline(Vk::DeviceHandle device, RenderPipelineInfo pipelineInfo); + ~VulkanRenderPipeline() = default; + + static VkPipelineDepthStencilStateCreateInfo BuildDepthStencilInfo(const RenderPipelineInfo& pipelineInfo); + static VkStencilOpState BuildStencilOp(const RenderPipelineInfo& pipelineInfo, bool front); + + private: + Vk::DeviceHandle m_device; + RenderPipelineInfo m_pipelineInfo; + }; +} + +#include + +#endif // NAZARA_VULKANRENDERER_VULKANRENDERPIPELINE_HPP diff --git a/include/Nazara/VulkanRenderer/VulkanRenderPipeline.inl b/include/Nazara/VulkanRenderer/VulkanRenderPipeline.inl new file mode 100644 index 000000000..180aaa736 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanRenderPipeline.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ +} + +#include diff --git a/src/Nazara/Renderer/RenderPipeline.cpp b/src/Nazara/Renderer/RenderPipeline.cpp new file mode 100644 index 000000000..c5faed12b --- /dev/null +++ b/src/Nazara/Renderer/RenderPipeline.cpp @@ -0,0 +1,11 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + RenderPipeline::~RenderPipeline() = default; +} diff --git a/src/Nazara/Renderer/RenderWindow.cpp b/src/Nazara/Renderer/RenderWindow.cpp index bd720c01c..2fe2f99cb 100644 --- a/src/Nazara/Renderer/RenderWindow.cpp +++ b/src/Nazara/Renderer/RenderWindow.cpp @@ -28,6 +28,14 @@ namespace Nz ///TODO } + std::shared_ptr RenderWindow::GetRenderDevice() + { + if (!m_impl) + return std::shared_ptr(); + + return m_impl->GetRenderDevice(); + } + bool RenderWindow::OnWindowCreated() { RendererImpl* rendererImpl = Renderer::GetRendererImpl(); diff --git a/src/Nazara/VulkanRenderer/VulkanDevice.cpp b/src/Nazara/VulkanRenderer/VulkanDevice.cpp index d1c0e736e..43bb964fc 100644 --- a/src/Nazara/VulkanRenderer/VulkanDevice.cpp +++ b/src/Nazara/VulkanRenderer/VulkanDevice.cpp @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include namespace Nz @@ -13,4 +14,9 @@ namespace Nz { return std::make_unique(shared_from_this(), parent, type); } + + std::unique_ptr VulkanDevice::InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) + { + return std::make_unique(shared_from_this(), std::move(pipelineInfo)); + } } diff --git a/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp b/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp new file mode 100644 index 000000000..ad4b43a5a --- /dev/null +++ b/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp @@ -0,0 +1,51 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include + +namespace Nz +{ + VulkanRenderPipeline::VulkanRenderPipeline(Vk::DeviceHandle device, RenderPipelineInfo pipelineInfo) : + m_device(std::move(device)), + m_pipelineInfo(std::move(pipelineInfo)) + { + } + + VkPipelineDepthStencilStateCreateInfo VulkanRenderPipeline::BuildDepthStencilInfo(const RenderPipelineInfo& pipelineInfo) + { + VkPipelineDepthStencilStateCreateInfo createInfo = {}; + createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; + createInfo.pNext = nullptr; + createInfo.flags = 0U; + createInfo.depthTestEnable = pipelineInfo.depthBuffer; + createInfo.depthWriteEnable = pipelineInfo.depthWrite; + createInfo.depthCompareOp = ToVulkan(pipelineInfo.depthCompare); + createInfo.depthBoundsTestEnable = VK_FALSE; + createInfo.stencilTestEnable = pipelineInfo.stencilTest; + createInfo.front = BuildStencilOp(pipelineInfo, true); + createInfo.back = BuildStencilOp(pipelineInfo, false); + + return createInfo; + } + + VkStencilOpState VulkanRenderPipeline::BuildStencilOp(const RenderPipelineInfo& pipelineInfo, bool front) + { + const auto& pipelineStencil = (front) ? pipelineInfo.stencilFront : pipelineInfo.stencilBack; + + VkStencilOpState stencilStates; + stencilStates.compareMask = pipelineStencil.compareMask; + stencilStates.compareOp = ToVulkan(pipelineStencil.compare); + stencilStates.depthFailOp = ToVulkan(pipelineStencil.depthFail); + stencilStates.failOp = ToVulkan(pipelineStencil.fail); + stencilStates.passOp = ToVulkan(pipelineStencil.pass); + stencilStates.reference = pipelineStencil.reference; + stencilStates.writeMask = pipelineStencil.writeMask; + + return stencilStates; + } +} From 2944d73586e9df01ae34bef77c8ec44722dd093b Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 27 Feb 2020 23:12:05 +0100 Subject: [PATCH 090/316] Fix instance extensions/layers query --- src/Nazara/VulkanRenderer/Wrapper/Loader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nazara/VulkanRenderer/Wrapper/Loader.cpp b/src/Nazara/VulkanRenderer/Wrapper/Loader.cpp index b5f0df100..c110a737b 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/Loader.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Loader.cpp @@ -17,7 +17,7 @@ namespace Nz // First, query physical device count UInt32 propertyCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t - s_lastErrorCode = vkEnumerateInstanceExtensionProperties(layerName, &propertyCount, properties->data()); + s_lastErrorCode = vkEnumerateInstanceExtensionProperties(layerName, &propertyCount, nullptr); if (s_lastErrorCode != VkResult::VK_SUCCESS) { NazaraError("Failed to get instance extension properties count: " + TranslateVulkanError(s_lastErrorCode)); @@ -42,7 +42,7 @@ namespace Nz // First, query physical device count UInt32 propertyCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t - s_lastErrorCode = vkEnumerateInstanceLayerProperties(&propertyCount, properties->data()); + s_lastErrorCode = vkEnumerateInstanceLayerProperties(&propertyCount, nullptr); if (s_lastErrorCode != VkResult::VK_SUCCESS) { NazaraError("Failed to get instance layer properties count: " + TranslateVulkanError(s_lastErrorCode)); From 798425ce10647a6cfe3a1055aac0af47cd22faed Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 27 Feb 2020 23:12:29 +0100 Subject: [PATCH 091/316] Some work on render pipelines --- examples/VulkanTest/main.cpp | 32 ++---------- include/Nazara/Renderer/RenderStates.hpp | 1 + include/Nazara/Utility/Enums.hpp | 2 + include/Nazara/VulkanRenderer/Utils.hpp | 3 ++ include/Nazara/VulkanRenderer/Utils.inl | 43 ++++++++++++++++ .../VulkanRenderer/VulkanRenderPipeline.hpp | 3 ++ .../VulkanRenderer/VulkanRenderPipeline.cpp | 50 +++++++++++++++++-- 7 files changed, 104 insertions(+), 30 deletions(-) diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index 907bc43a0..e91a42ccc 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -347,39 +347,19 @@ int main() attributeDescription.data() // const VkVertexInputAttributeDescription *pVertexAttributeDescriptions }; - VkPipelineInputAssemblyStateCreateInfo input_assembly_state_create_info = { - VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, // VkStructureType sType - nullptr, // const void *pNext - 0, // VkPipelineInputAssemblyStateCreateFlags flags - VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, // VkPrimitiveTopology topology - VK_FALSE // VkBool32 primitiveRestartEnable - }; - VkPipelineViewportStateCreateInfo viewport_state_create_info = { VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, // VkStructureType sType nullptr, // const void *pNext 0, // VkPipelineViewportStateCreateFlags flags 1, // uint32_t viewportCount - nullptr, // const VkViewport *pViewports + nullptr, // const VkViewport *pViewports 1, // uint32_t scissorCount - nullptr // const VkRect2D *pScissors + nullptr // const VkRect2D *pScissors }; - VkPipelineRasterizationStateCreateInfo rasterization_state_create_info = { - VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, // VkStructureType sType - nullptr, // const void *pNext - 0, // VkPipelineRasterizationStateCreateFlags flags - VK_FALSE, // VkBool32 depthClampEnable - VK_FALSE, // VkBool32 rasterizerDiscardEnable - VK_POLYGON_MODE_FILL, // VkPolygonMode polygonMode - VK_CULL_MODE_NONE, // VkCullModeFlags cullMode - VK_FRONT_FACE_COUNTER_CLOCKWISE, // VkFrontFace frontFace - VK_FALSE, // VkBool32 depthBiasEnable - 0.0f, // float depthBiasConstantFactor - 0.0f, // float depthBiasClamp - 0.0f, // float depthBiasSlopeFactor - 1.0f // float lineWidth - }; + VkPipelineInputAssemblyStateCreateInfo input_assembly_state_create_info = Nz::VulkanRenderPipeline::BuildInputAssemblyInfo(pipelineInfo); + VkPipelineRasterizationStateCreateInfo rasterization_state_create_info = Nz::VulkanRenderPipeline::BuildRasterizationInfo(pipelineInfo); + VkPipelineDepthStencilStateCreateInfo depthStencilInfo = Nz::VulkanRenderPipeline::BuildDepthStencilInfo(pipelineInfo); VkPipelineMultisampleStateCreateInfo multisample_state_create_info = { VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, // VkStructureType sType @@ -429,8 +409,6 @@ int main() dynamicStates.data() // const VkDynamicState* pDynamicStates; }; - VkPipelineDepthStencilStateCreateInfo depthStencilInfo = Nz::VulkanRenderPipeline::BuildDepthStencilInfo(pipelineInfo); - VkGraphicsPipelineCreateInfo pipeline_create_info = { VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, // VkStructureType sType nullptr, // const void *pNext diff --git a/include/Nazara/Renderer/RenderStates.hpp b/include/Nazara/Renderer/RenderStates.hpp index 5fec08981..d31b37be0 100644 --- a/include/Nazara/Renderer/RenderStates.hpp +++ b/include/Nazara/Renderer/RenderStates.hpp @@ -19,6 +19,7 @@ namespace Nz FaceFilling faceFilling = FaceFilling_Fill; FaceSide cullingSide = FaceSide_Back; RendererComparison depthCompare = RendererComparison_Less; + PrimitiveMode primitiveMode = PrimitiveMode_TriangleList; struct { diff --git a/include/Nazara/Utility/Enums.hpp b/include/Nazara/Utility/Enums.hpp index c77fed662..cc7413844 100644 --- a/include/Nazara/Utility/Enums.hpp +++ b/include/Nazara/Utility/Enums.hpp @@ -123,6 +123,8 @@ namespace Nz enum FaceSide { + FaceSide_None, + FaceSide_Back, FaceSide_Front, FaceSide_FrontAndBack, diff --git a/include/Nazara/VulkanRenderer/Utils.hpp b/include/Nazara/VulkanRenderer/Utils.hpp index bd4ea0563..b80a3c3fd 100644 --- a/include/Nazara/VulkanRenderer/Utils.hpp +++ b/include/Nazara/VulkanRenderer/Utils.hpp @@ -14,6 +14,9 @@ namespace Nz { + inline VkCullModeFlagBits ToVulkan(FaceSide faceSide); + inline VkPolygonMode ToVulkan(FaceFilling faceFilling); + inline VkPrimitiveTopology ToVulkan(PrimitiveMode primitiveMode); inline VkCompareOp ToVulkan(RendererComparison comparison); inline VkStencilOp ToVulkan(StencilOperation stencilOp); NAZARA_VULKANRENDERER_API String TranslateVulkanError(VkResult code); diff --git a/include/Nazara/VulkanRenderer/Utils.inl b/include/Nazara/VulkanRenderer/Utils.inl index dfc13cd1f..4abbe1d0c 100644 --- a/include/Nazara/VulkanRenderer/Utils.inl +++ b/include/Nazara/VulkanRenderer/Utils.inl @@ -9,6 +9,49 @@ namespace Nz { + VkCullModeFlagBits ToVulkan(FaceSide faceSide) + { + switch (faceSide) + { + case FaceSide_None: return VK_CULL_MODE_NONE; + case FaceSide_Back: return VK_CULL_MODE_BACK_BIT; + case FaceSide_Front: return VK_CULL_MODE_FRONT_BIT; + case FaceSide_FrontAndBack: return VK_CULL_MODE_FRONT_AND_BACK; + } + + NazaraError("Unhandled FaceSide 0x" + String::Number(faceSide, 16)); + return VK_CULL_MODE_BACK_BIT; + } + + inline VkPolygonMode ToVulkan(FaceFilling faceFilling) + { + switch (faceFilling) + { + case FaceFilling_Fill: return VK_POLYGON_MODE_FILL; + case FaceFilling_Line: return VK_POLYGON_MODE_LINE; + case FaceFilling_Point: return VK_POLYGON_MODE_POINT; + } + + NazaraError("Unhandled FaceFilling 0x" + String::Number(faceFilling, 16)); + return VK_POLYGON_MODE_FILL; + } + + VkPrimitiveTopology ToVulkan(PrimitiveMode primitiveMode) + { + switch (primitiveMode) + { + case PrimitiveMode_LineList: return VK_PRIMITIVE_TOPOLOGY_LINE_LIST; + case PrimitiveMode_LineStrip: return VK_PRIMITIVE_TOPOLOGY_LINE_STRIP; + case PrimitiveMode_PointList: return VK_PRIMITIVE_TOPOLOGY_POINT_LIST; + case PrimitiveMode_TriangleList: return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; + case PrimitiveMode_TriangleStrip: return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; + case PrimitiveMode_TriangleFan: return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN; + } + + NazaraError("Unhandled FaceFilling 0x" + String::Number(primitiveMode, 16)); + return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; + } + inline VkCompareOp ToVulkan(RendererComparison comparison) { switch (comparison) diff --git a/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp b/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp index 34e39a990..76836708e 100644 --- a/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp +++ b/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp @@ -20,7 +20,10 @@ namespace Nz VulkanRenderPipeline(Vk::DeviceHandle device, RenderPipelineInfo pipelineInfo); ~VulkanRenderPipeline() = default; + static VkPipelineColorBlendAttachmentState BuildColorBlendState(const RenderPipelineInfo& pipelineInfo); static VkPipelineDepthStencilStateCreateInfo BuildDepthStencilInfo(const RenderPipelineInfo& pipelineInfo); + static VkPipelineInputAssemblyStateCreateInfo BuildInputAssemblyInfo(const RenderPipelineInfo& pipelineInfo); + static VkPipelineRasterizationStateCreateInfo BuildRasterizationInfo(const RenderPipelineInfo& pipelineInfo); static VkStencilOpState BuildStencilOp(const RenderPipelineInfo& pipelineInfo, bool front); private: diff --git a/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp b/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp index ad4b43a5a..71daf7eaa 100644 --- a/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp +++ b/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp @@ -16,16 +16,39 @@ namespace Nz { } + VkPipelineColorBlendAttachmentState VulkanRenderPipeline::BuildColorBlendState(const RenderPipelineInfo& pipelineInfo) + { + VkPipelineColorBlendAttachmentState colorBlendStates; + colorBlendStates.blendEnable = pipelineInfo.blending; + colorBlendStates.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT; //< TODO + + if (pipelineInfo.blending) + { + //TODO + /*switch (pipelineInfo.dstBlend) + { + blendState.dstAlphaBlendFactor + }*/ + } + else + { + colorBlendStates.srcColorBlendFactor = VK_BLEND_FACTOR_ONE; + colorBlendStates.dstColorBlendFactor = VK_BLEND_FACTOR_ZERO; + colorBlendStates.colorBlendOp = VK_BLEND_OP_ADD; + colorBlendStates.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE; + colorBlendStates.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO; + colorBlendStates.alphaBlendOp = VK_BLEND_OP_ADD; + } + return colorBlendStates; + } + VkPipelineDepthStencilStateCreateInfo VulkanRenderPipeline::BuildDepthStencilInfo(const RenderPipelineInfo& pipelineInfo) { VkPipelineDepthStencilStateCreateInfo createInfo = {}; createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; - createInfo.pNext = nullptr; - createInfo.flags = 0U; createInfo.depthTestEnable = pipelineInfo.depthBuffer; createInfo.depthWriteEnable = pipelineInfo.depthWrite; createInfo.depthCompareOp = ToVulkan(pipelineInfo.depthCompare); - createInfo.depthBoundsTestEnable = VK_FALSE; createInfo.stencilTestEnable = pipelineInfo.stencilTest; createInfo.front = BuildStencilOp(pipelineInfo, true); createInfo.back = BuildStencilOp(pipelineInfo, false); @@ -33,6 +56,27 @@ namespace Nz return createInfo; } + VkPipelineInputAssemblyStateCreateInfo VulkanRenderPipeline::BuildInputAssemblyInfo(const RenderPipelineInfo& pipelineInfo) + { + VkPipelineInputAssemblyStateCreateInfo createInfo = {}; + createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; + createInfo.topology = ToVulkan(pipelineInfo.primitiveMode); + + return createInfo; + } + + VkPipelineRasterizationStateCreateInfo VulkanRenderPipeline::BuildRasterizationInfo(const RenderPipelineInfo& pipelineInfo) + { + VkPipelineRasterizationStateCreateInfo createInfo = {}; + createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; + createInfo.polygonMode = ToVulkan(pipelineInfo.faceFilling); + createInfo.cullMode = ToVulkan(pipelineInfo.cullingSide); + createInfo.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; //< TODO + createInfo.lineWidth = pipelineInfo.lineWidth; + + return createInfo; + } + VkStencilOpState VulkanRenderPipeline::BuildStencilOp(const RenderPipelineInfo& pipelineInfo, bool front) { const auto& pipelineStencil = (front) ? pipelineInfo.stencilFront : pipelineInfo.stencilBack; From 5d449095bf7c37beacdb7172ba8e4ede6565ba4c Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 29 Feb 2020 23:28:21 +0100 Subject: [PATCH 092/316] Renderer: Add ShaderStage class --- examples/VulkanTest/main.cpp | 55 ++++++------------- include/Nazara/Renderer.hpp | 1 + include/Nazara/Renderer/Enums.hpp | 14 +++++ include/Nazara/Renderer/RenderDevice.hpp | 5 ++ include/Nazara/Renderer/ShaderStageImpl.hpp | 24 ++++++++ include/Nazara/VulkanRenderer.hpp | 1 + .../Nazara/VulkanRenderer/VulkanDevice.hpp | 1 + .../VulkanRenderer/VulkanShaderStage.hpp | 41 ++++++++++++++ .../VulkanRenderer/VulkanShaderStage.inl | 16 ++++++ src/Nazara/Renderer/RenderDevice.cpp | 23 ++++++++ src/Nazara/Renderer/ShaderStageImpl.cpp | 11 ++++ src/Nazara/VulkanRenderer/VulkanDevice.cpp | 10 ++++ .../VulkanRenderer/VulkanShaderStage.cpp | 27 +++++++++ 13 files changed, 190 insertions(+), 39 deletions(-) create mode 100644 include/Nazara/Renderer/ShaderStageImpl.hpp create mode 100644 include/Nazara/VulkanRenderer/VulkanShaderStage.hpp create mode 100644 include/Nazara/VulkanRenderer/VulkanShaderStage.inl create mode 100644 src/Nazara/Renderer/ShaderStageImpl.cpp create mode 100644 src/Nazara/VulkanRenderer/VulkanShaderStage.cpp diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index e91a42ccc..e840227dc 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -56,29 +56,6 @@ int main() instance.vkCreateDebugReportCallbackEXT(instance, &callbackCreateInfo, nullptr, &callback); - Nz::File shaderFile; - std::vector vertexShaderCode; - std::vector fragmentShaderCode; - - if (!shaderFile.Open("resources/shaders/triangle.vert.spv", Nz::OpenMode_ReadOnly)) - { - NazaraError("Failed to open vertex shader code"); - return __LINE__; - } - - vertexShaderCode.resize(shaderFile.GetSize()); - shaderFile.Read(vertexShaderCode.data(), vertexShaderCode.size()); - - if (!shaderFile.Open("resources/shaders/triangle.frag.spv", Nz::OpenMode_ReadOnly)) - { - NazaraError("Failed to open fragment shader code"); - return __LINE__; - } - - fragmentShaderCode.resize(shaderFile.GetSize()); - shaderFile.Read(fragmentShaderCode.data(), fragmentShaderCode.size()); - - shaderFile.Close(); std::vector layerProperties; if (!Nz::Vk::Loader::EnumerateInstanceLayerProperties(&layerProperties)) @@ -124,6 +101,20 @@ int main() std::shared_ptr device = window.GetRenderDevice(); + auto fragmentShader = device->InstantiateShaderStage(Nz::ShaderStageType::Fragment, Nz::ShaderLanguage::SpirV, "resources/shaders/triangle.frag.spv"); + if (!fragmentShader) + { + std::cout << "Failed to instantiate fragment shader" << std::endl; + return __LINE__; + } + + auto vertexShader = device->InstantiateShaderStage(Nz::ShaderStageType::Vertex, Nz::ShaderLanguage::SpirV, "resources/shaders/triangle.vert.spv"); + if (!vertexShader) + { + std::cout << "Failed to instantiate fragment shader" << std::endl; + return __LINE__; + } + Nz::VkRenderWindow& vulkanWindow = *static_cast(window.GetImpl()); /*VkPhysicalDeviceFeatures features; @@ -140,20 +131,6 @@ int main() Nz::VulkanDevice& vulkanDevice = vulkanWindow.GetDevice(); - Nz::Vk::ShaderModule vertexShader; - if (!vertexShader.Create(vulkanDevice.shared_from_this(), reinterpret_cast(vertexShaderCode.data()), vertexShaderCode.size())) - { - NazaraError("Failed to create vertex shader"); - return __LINE__; - } - - Nz::Vk::ShaderModule fragmentShader; - if (!fragmentShader.Create(vulkanDevice.shared_from_this(), reinterpret_cast(fragmentShaderCode.data()), fragmentShaderCode.size())) - { - NazaraError("Failed to create fragment shader"); - return __LINE__; - } - Nz::MeshRef drfreak = Nz::Mesh::LoadFromFile("resources/OILTANK1.md2", meshParams); if (!drfreak) @@ -297,7 +274,7 @@ int main() nullptr, 0, VK_SHADER_STAGE_VERTEX_BIT, - vertexShader, + static_cast(vertexShader.get())->GetHandle(), "main", nullptr }, @@ -306,7 +283,7 @@ int main() nullptr, 0, VK_SHADER_STAGE_FRAGMENT_BIT, - fragmentShader, + static_cast(fragmentShader.get())->GetHandle(), "main", nullptr } diff --git a/include/Nazara/Renderer.hpp b/include/Nazara/Renderer.hpp index 652538c6b..75c13cf0c 100644 --- a/include/Nazara/Renderer.hpp +++ b/include/Nazara/Renderer.hpp @@ -47,6 +47,7 @@ #include #include #include +#include #include #include diff --git a/include/Nazara/Renderer/Enums.hpp b/include/Nazara/Renderer/Enums.hpp index 2621081cd..3ea481e17 100644 --- a/include/Nazara/Renderer/Enums.hpp +++ b/include/Nazara/Renderer/Enums.hpp @@ -33,6 +33,20 @@ namespace Nz RenderDeviceType_Max = RenderDeviceType_Unknown }; + + enum class ShaderLanguage + { + GLSL, + HLSL, + MSL, + SpirV + }; + + enum class ShaderStageType + { + Fragment, + Vertex + }; } #endif // NAZARA_ENUMS_RENDERER_HPP diff --git a/include/Nazara/Renderer/RenderDevice.hpp b/include/Nazara/Renderer/RenderDevice.hpp index 18f27bc5e..5df49c600 100644 --- a/include/Nazara/Renderer/RenderDevice.hpp +++ b/include/Nazara/Renderer/RenderDevice.hpp @@ -9,13 +9,16 @@ #include #include +#include #include #include #include +#include namespace Nz { class Buffer; + class ShaderStageImpl; class NAZARA_RENDERER_API RenderDevice { @@ -25,6 +28,8 @@ namespace Nz virtual std::unique_ptr InstantiateBuffer(Buffer* parent, BufferType type) = 0; virtual std::unique_ptr InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) = 0; + virtual std::shared_ptr InstantiateShaderStage(ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) = 0; + std::shared_ptr InstantiateShaderStage(ShaderStageType type, ShaderLanguage lang, const std::filesystem::path& sourcePath); }; } diff --git a/include/Nazara/Renderer/ShaderStageImpl.hpp b/include/Nazara/Renderer/ShaderStageImpl.hpp new file mode 100644 index 000000000..4bee731e2 --- /dev/null +++ b/include/Nazara/Renderer/ShaderStageImpl.hpp @@ -0,0 +1,24 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_RENDERER_SHADERSTAGEIMPL_HPP +#define NAZARA_RENDERER_SHADERSTAGEIMPL_HPP + +#include +#include +#include + +namespace Nz +{ + class NAZARA_RENDERER_API ShaderStageImpl + { + public: + ShaderStageImpl() = default; + virtual ~ShaderStageImpl(); + }; +} + +#endif // NAZARA_RENDERER_SHADERSTAGEIMPL_HPP diff --git a/include/Nazara/VulkanRenderer.hpp b/include/Nazara/VulkanRenderer.hpp index 71c764abf..429629660 100644 --- a/include/Nazara/VulkanRenderer.hpp +++ b/include/Nazara/VulkanRenderer.hpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include diff --git a/include/Nazara/VulkanRenderer/VulkanDevice.hpp b/include/Nazara/VulkanRenderer/VulkanDevice.hpp index 291aa7b3e..9d625d634 100644 --- a/include/Nazara/VulkanRenderer/VulkanDevice.hpp +++ b/include/Nazara/VulkanRenderer/VulkanDevice.hpp @@ -25,6 +25,7 @@ namespace Nz std::unique_ptr InstantiateBuffer(Buffer* parent, BufferType type) override; std::unique_ptr InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) override; + std::shared_ptr InstantiateShaderStage(ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) override; VulkanDevice& operator=(const VulkanDevice&) = delete; VulkanDevice& operator=(VulkanDevice&&) = delete; ///TODO? diff --git a/include/Nazara/VulkanRenderer/VulkanShaderStage.hpp b/include/Nazara/VulkanRenderer/VulkanShaderStage.hpp new file mode 100644 index 000000000..c7c4dcf92 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanShaderStage.hpp @@ -0,0 +1,41 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VULKANSHADERSTAGE_HPP +#define NAZARA_VULKANRENDERER_VULKANSHADERSTAGE_HPP + +#include +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_VULKANRENDERER_API VulkanShaderStage : public ShaderStageImpl + { + public: + VulkanShaderStage() = default; + VulkanShaderStage(const VulkanShaderStage&) = delete; + VulkanShaderStage(VulkanShaderStage&&) noexcept = default; + ~VulkanShaderStage() = default; + + bool Create(const Vk::DeviceHandle& device, ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize); + + inline const Vk::ShaderModule& GetHandle() const; + + VulkanShaderStage& operator=(const VulkanShaderStage&) = delete; + VulkanShaderStage& operator=(VulkanShaderStage&&) noexcept = default; + + private: + Vk::ShaderModule m_shaderModule; + ShaderStageType m_stage; + }; +} + +#include + +#endif // NAZARA_VULKANRENDERER_VULKANSHADERSTAGE_HPP diff --git a/include/Nazara/VulkanRenderer/VulkanShaderStage.inl b/include/Nazara/VulkanRenderer/VulkanShaderStage.inl new file mode 100644 index 000000000..5796071bb --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanShaderStage.inl @@ -0,0 +1,16 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline const Vk::ShaderModule& VulkanShaderStage::GetHandle() const + { + return m_shaderModule; + } +} + +#include diff --git a/src/Nazara/Renderer/RenderDevice.cpp b/src/Nazara/Renderer/RenderDevice.cpp index de5e5f82d..2ef01974a 100644 --- a/src/Nazara/Renderer/RenderDevice.cpp +++ b/src/Nazara/Renderer/RenderDevice.cpp @@ -3,9 +3,32 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include +#include #include namespace Nz { RenderDevice::~RenderDevice() = default; + + std::shared_ptr RenderDevice::InstantiateShaderStage(ShaderStageType type, ShaderLanguage lang, const std::filesystem::path& sourcePath) + { + File file(sourcePath); + if (!file.Open(OpenMode_ReadOnly | OpenMode_Text)) + { + NazaraError("Failed to open \"" + sourcePath.generic_u8string() + '"'); + return {}; + } + + std::size_t length = static_cast(file.GetSize()); + + std::vector source(length); + if (file.Read(&source[0], length) != length) + { + NazaraError("Failed to read program file"); + return {}; + } + + return InstantiateShaderStage(type, lang, source.data(), source.size()); + } } diff --git a/src/Nazara/Renderer/ShaderStageImpl.cpp b/src/Nazara/Renderer/ShaderStageImpl.cpp new file mode 100644 index 000000000..62ae7a7ed --- /dev/null +++ b/src/Nazara/Renderer/ShaderStageImpl.cpp @@ -0,0 +1,11 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + ShaderStageImpl::~ShaderStageImpl() = default; +} diff --git a/src/Nazara/VulkanRenderer/VulkanDevice.cpp b/src/Nazara/VulkanRenderer/VulkanDevice.cpp index 43bb964fc..f2a802f4d 100644 --- a/src/Nazara/VulkanRenderer/VulkanDevice.cpp +++ b/src/Nazara/VulkanRenderer/VulkanDevice.cpp @@ -4,6 +4,7 @@ #include #include +#include #include namespace Nz @@ -19,4 +20,13 @@ namespace Nz { return std::make_unique(shared_from_this(), std::move(pipelineInfo)); } + + std::shared_ptr VulkanDevice::InstantiateShaderStage(ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) + { + auto stage = std::make_shared(); + if (!stage->Create(shared_from_this(), type, lang, source, sourceSize)) + return {}; + + return stage; + } } diff --git a/src/Nazara/VulkanRenderer/VulkanShaderStage.cpp b/src/Nazara/VulkanRenderer/VulkanShaderStage.cpp new file mode 100644 index 000000000..b19bdca04 --- /dev/null +++ b/src/Nazara/VulkanRenderer/VulkanShaderStage.cpp @@ -0,0 +1,27 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + bool VulkanShaderStage::Create(const Vk::DeviceHandle& device, ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) + { + if (lang != ShaderLanguage::SpirV) + { + NazaraError("Only Spir-V is supported for now"); + return false; + } + + if (!m_shaderModule.Create(device, reinterpret_cast(source), sourceSize)) + { + NazaraError("Failed to create shader module"); + return false; + } + + m_stage = type; + return true; + } +} From af28ea02a8042dac80e2a691a6aa62033dfe0ee6 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 29 Feb 2020 23:28:59 +0100 Subject: [PATCH 093/316] Vulkan usage fixes --- examples/VulkanTest/main.cpp | 10 +++------- include/Nazara/Renderer/RenderWindow.hpp | 1 + include/Nazara/Renderer/RenderWindow.inl | 5 +++++ src/Nazara/VulkanRenderer/VkRenderWindow.cpp | 12 ++++++------ 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index e840227dc..f456edf96 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -44,12 +44,10 @@ int main() Nz::Vk::Instance& instance = Nz::Vulkan::GetInstance(); - VkDebugReportCallbackCreateInfoEXT callbackCreateInfo; + VkDebugReportCallbackCreateInfoEXT callbackCreateInfo = {}; callbackCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT; - callbackCreateInfo.pNext = nullptr; - callbackCreateInfo.flags = VK_DEBUG_REPORT_FLAG_BITS_MAX_ENUM_EXT & ~VK_DEBUG_REPORT_INFORMATION_BIT_EXT; + callbackCreateInfo.flags = VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT | VK_DEBUG_REPORT_DEBUG_BIT_EXT ; callbackCreateInfo.pfnCallback = &MyDebugReportCallback; - callbackCreateInfo.pUserData = nullptr; /* Register the callback */ VkDebugReportCallbackEXT callback; @@ -246,8 +244,6 @@ int main() descriptorSet.WriteUniformDescriptor(0, uniformBuffer, 0, uniformSize); Nz::RenderPipelineInfo pipelineInfo; - pipelineInfo.depthBuffer = true; - pipelineInfo.depthCompare = Nz::RendererComparison_Equal; std::unique_ptr pipeline = device->InstantiateRenderPipeline(pipelineInfo); @@ -627,7 +623,7 @@ int main() } } -// instance.vkDestroyDebugReportCallbackEXT(instance, callback, nullptr); + instance.vkDestroyDebugReportCallbackEXT(instance, callback, nullptr); return EXIT_SUCCESS; } diff --git a/include/Nazara/Renderer/RenderWindow.hpp b/include/Nazara/Renderer/RenderWindow.hpp index b15d3bb51..c5838456b 100644 --- a/include/Nazara/Renderer/RenderWindow.hpp +++ b/include/Nazara/Renderer/RenderWindow.hpp @@ -27,6 +27,7 @@ namespace Nz inline RenderWindow(); inline RenderWindow(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default, const RenderWindowParameters& parameters = RenderWindowParameters()); inline explicit RenderWindow(WindowHandle handle, const RenderWindowParameters& parameters = RenderWindowParameters()); + inline ~RenderWindow(); inline bool Create(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default, const RenderWindowParameters& parameters = RenderWindowParameters()); inline bool Create(WindowHandle handle, const RenderWindowParameters& parameters = RenderWindowParameters()); diff --git a/include/Nazara/Renderer/RenderWindow.inl b/include/Nazara/Renderer/RenderWindow.inl index 882ad8dd5..7b926ce55 100644 --- a/include/Nazara/Renderer/RenderWindow.inl +++ b/include/Nazara/Renderer/RenderWindow.inl @@ -27,6 +27,11 @@ namespace Nz Create(handle, parameters); } + inline RenderWindow::~RenderWindow() + { + Destroy(); + } + inline bool RenderWindow::Create(VideoMode mode, const String& title, WindowStyleFlags style, const RenderWindowParameters& parameters) { m_parameters = parameters; diff --git a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp index 62056f217..f1822b227 100644 --- a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp +++ b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp @@ -48,7 +48,7 @@ namespace Nz //commandBuffer.SetImageLayout(m_swapchain.GetBuffer(imageIndex).image, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); // Temporary - if (m_depthStencilFormat != VK_FORMAT_MAX_ENUM) + /*if (m_depthStencilFormat != VK_FORMAT_MAX_ENUM) { VkImageSubresourceRange imageRange = { VK_IMAGE_ASPECT_DEPTH_BIT, // VkImageAspectFlags aspectMask @@ -59,7 +59,7 @@ namespace Nz }; commandBuffer.SetImageLayout(m_depthBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, imageRange); - } + }*/ } void VkRenderWindow::BuildPostRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) @@ -283,18 +283,18 @@ namespace Nz VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp; VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp; VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp; - VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout; - VK_IMAGE_LAYOUT_PRESENT_SRC_KHR // VkImageLayout finalLayout; + VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout; + VK_IMAGE_LAYOUT_PRESENT_SRC_KHR // VkImageLayout finalLayout; }, { 0, // VkAttachmentDescriptionFlags flags; m_depthStencilFormat, // VkFormat format; VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples; VK_ATTACHMENT_LOAD_OP_CLEAR, // VkAttachmentLoadOp loadOp; - VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp storeOp; + VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp storeOp; VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp; VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp; - VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, // VkImageLayout initialLayout; + VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout; VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL // VkImageLayout finalLayout; }, } From 286461c48254335d206279757210fdfb7a8f4ae9 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 1 Mar 2020 12:49:49 +0100 Subject: [PATCH 094/316] Make use of Nazara uniform buffer --- examples/VulkanTest/main.cpp | 48 ++++++---------------- src/Nazara/VulkanRenderer/VulkanBuffer.cpp | 23 ++++++++++- 2 files changed, 35 insertions(+), 36 deletions(-) diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index f456edf96..8690fc699 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -181,38 +181,17 @@ int main() Nz::UInt32 uniformSize = sizeof(ubo); - Nz::Vk::Buffer uniformBuffer; - if (!uniformBuffer.Create(vulkanDevice.shared_from_this(), 0, uniformSize, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT)) + Nz::UniformBuffer uniformBuffer(uniformSize, Nz::DataStorage_Hardware, Nz::BufferUsage_Dynamic); + uniformBuffer.Fill(&ubo, 0, uniformSize); + + Nz::RenderBuffer* renderBufferUB = static_cast(uniformBuffer.GetBuffer()->GetImpl()); + if (!renderBufferUB->Synchronize(&vulkanDevice)) { - NazaraError("Failed to create vertex buffer"); - return __LINE__; - } - - VkMemoryRequirements memRequirement = uniformBuffer.GetMemoryRequirements(); - - Nz::Vk::DeviceMemory uniformBufferMemory; - if (!uniformBufferMemory.Create(vulkanDevice.shared_from_this(), memRequirement.size, memRequirement.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) - { - NazaraError("Failed to allocate vertex buffer memory"); - return __LINE__; - } - - if (!uniformBufferMemory.Map(0, uniformSize)) - { - NazaraError("Failed to map vertex buffer"); - return __LINE__; - } - - std::memcpy(uniformBufferMemory.GetMappedPointer(), &ubo, uniformSize); - - uniformBufferMemory.Unmap(); - - if (!uniformBuffer.BindBufferMemory(uniformBufferMemory)) - { - NazaraError("Failed to bind uniform buffer to its memory"); + NazaraError("Failed to synchronize render buffer"); return __LINE__; } + Nz::VulkanBuffer* uniformBufferImpl = static_cast(renderBufferUB->GetHardwareBuffer(&vulkanDevice)); VkDescriptorSetLayoutBinding layoutBinding = {}; layoutBinding.binding = 0; @@ -241,7 +220,7 @@ int main() Nz::Vk::DescriptorSet descriptorSet = descriptorPool.AllocateDescriptorSet(descriptorLayout); - descriptorSet.WriteUniformDescriptor(0, uniformBuffer, 0, uniformSize); + descriptorSet.WriteUniformDescriptor(0, uniformBufferImpl->GetBufferHandle(), 0, uniformSize); Nz::RenderPipelineInfo pipelineInfo; @@ -561,15 +540,14 @@ int main() { ubo.viewMatrix = Nz::Matrix4f::ViewMatrix(viewerPos, camAngles); - if (!uniformBufferMemory.Map(0, uniformSize)) + uniformBuffer.Fill(&ubo, 0, uniformSize); + + Nz::RenderBuffer* renderBufferUB = static_cast(uniformBuffer.GetBuffer()->GetImpl()); + if (!renderBufferUB->Synchronize(&vulkanDevice)) { - NazaraError("Failed to map vertex buffer"); + NazaraError("Failed to synchronize render buffer"); return __LINE__; } - - std::memcpy(uniformBufferMemory.GetMappedPointer(), &ubo, uniformSize); - - uniformBufferMemory.Unmap(); } Nz::UInt32 imageIndex; diff --git a/src/Nazara/VulkanRenderer/VulkanBuffer.cpp b/src/Nazara/VulkanRenderer/VulkanBuffer.cpp index 08c9469a9..db834d035 100644 --- a/src/Nazara/VulkanRenderer/VulkanBuffer.cpp +++ b/src/Nazara/VulkanRenderer/VulkanBuffer.cpp @@ -4,6 +4,7 @@ #include #include +#include #include namespace Nz @@ -25,7 +26,27 @@ namespace Nz bool VulkanBuffer::Initialize(UInt32 size, BufferUsageFlags usage) { - if (!m_buffer.Create(m_device, 0, size, (m_type == BufferType_Index) ? VK_BUFFER_USAGE_INDEX_BUFFER_BIT : VK_BUFFER_USAGE_VERTEX_BUFFER_BIT)) + VkBufferUsageFlags type; + switch (m_type) + { + case BufferType_Index: + type = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; + break; + + case BufferType_Vertex: + type = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT; + break; + + case BufferType_Uniform: + type = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; + break; + + default: + NazaraError("Unhandled buffer usage 0x" + String::Number(m_type, 16)); + return false; + } + + if (!m_buffer.Create(m_device, 0, size, type)) { NazaraError("Failed to create vertex buffer"); return false; From 7180a8d94ea25bf11f3ecaba15c3a8c41d703b32 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 1 Mar 2020 20:31:41 +0100 Subject: [PATCH 095/316] WIP --- examples/VulkanTest/main.cpp | 4 ++-- include/Nazara/Renderer/RenderStates.hpp | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index 8690fc699..e731f04ed 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -142,7 +142,7 @@ int main() const Nz::VertexBuffer* drfreakVB = drfreakMesh->GetVertexBuffer(); const Nz::IndexBuffer* drfreakIB = drfreakMesh->GetIndexBuffer(); - // Vertex buffer + // Index buffer std::cout << "Index count: " << drfreakIB->GetIndexCount() << std::endl; Nz::RenderBuffer* renderBufferIB = static_cast(drfreakIB->GetBuffer()->GetImpl()); @@ -154,7 +154,7 @@ int main() Nz::VulkanBuffer* indexBufferImpl = static_cast(renderBufferIB->GetHardwareBuffer(&vulkanDevice)); - // Index buffer + // Vertex buffer std::cout << "Vertex count: " << drfreakVB->GetVertexCount() << std::endl; Nz::RenderBuffer* renderBufferVB = static_cast(drfreakVB->GetBuffer()->GetImpl()); diff --git a/include/Nazara/Renderer/RenderStates.hpp b/include/Nazara/Renderer/RenderStates.hpp index d31b37be0..f4d4ea369 100644 --- a/include/Nazara/Renderer/RenderStates.hpp +++ b/include/Nazara/Renderer/RenderStates.hpp @@ -9,9 +9,13 @@ #include #include +#include +#include namespace Nz { + class ShaderStageImpl; + struct RenderStates { BlendFunc dstBlend = BlendFunc_Zero; @@ -32,6 +36,8 @@ namespace Nz UInt32 writeMask = 0xFFFFFFFF; } stencilBack, stencilFront; + std::vector> shaderStages; + bool blending = false; bool colorWrite = true; bool depthBuffer = false; From 287be5d9b6d24d9cf482fb7946fb02c3024cd656 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 1 Mar 2020 20:31:48 +0100 Subject: [PATCH 096/316] WIP --- .../VulkanRenderer/VulkanRenderPipeline.hpp | 16 +++++++++++++++- .../VulkanRenderer/VulkanRenderPipeline.cpp | 19 ++++++++++++++++--- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp b/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp index 76836708e..aed7b6769 100644 --- a/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp +++ b/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp @@ -11,22 +11,36 @@ #include #include #include +#include namespace Nz { class NAZARA_VULKANRENDERER_API VulkanRenderPipeline : public RenderPipeline { public: + struct CreateInfo; + VulkanRenderPipeline(Vk::DeviceHandle device, RenderPipelineInfo pipelineInfo); ~VulkanRenderPipeline() = default; - static VkPipelineColorBlendAttachmentState BuildColorBlendState(const RenderPipelineInfo& pipelineInfo); + static std::vector BuildColorBlendAttachmentState(const RenderPipelineInfo& pipelineInfo); static VkPipelineDepthStencilStateCreateInfo BuildDepthStencilInfo(const RenderPipelineInfo& pipelineInfo); static VkPipelineInputAssemblyStateCreateInfo BuildInputAssemblyInfo(const RenderPipelineInfo& pipelineInfo); static VkPipelineRasterizationStateCreateInfo BuildRasterizationInfo(const RenderPipelineInfo& pipelineInfo); static VkStencilOpState BuildStencilOp(const RenderPipelineInfo& pipelineInfo, bool front); + static std::vector BuildShaderStageInfo(const RenderPipelineInfo& pipelineInfo); + static CreateInfo BuildCreateInfo(const RenderPipelineInfo& pipelineInfo); + + struct CreateInfo + { + std::vector colorBlendAttachmentState; + std::vector shaderStages; + VkGraphicsPipelineCreateInfo createInfo; + }; private: + + Vk::DeviceHandle m_device; RenderPipelineInfo m_pipelineInfo; }; diff --git a/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp b/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp index 71daf7eaa..1071f7573 100644 --- a/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp +++ b/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp @@ -16,7 +16,7 @@ namespace Nz { } - VkPipelineColorBlendAttachmentState VulkanRenderPipeline::BuildColorBlendState(const RenderPipelineInfo& pipelineInfo) + /*VkPipelineColorBlendAttachmentState VulkanRenderPipeline::BuildColorBlendAttachmentState(const RenderPipelineInfo& pipelineInfo) { VkPipelineColorBlendAttachmentState colorBlendStates; colorBlendStates.blendEnable = pipelineInfo.blending; @@ -29,7 +29,7 @@ namespace Nz { blendState.dstAlphaBlendFactor }*/ - } + /*} else { colorBlendStates.srcColorBlendFactor = VK_BLEND_FACTOR_ONE; @@ -40,7 +40,7 @@ namespace Nz colorBlendStates.alphaBlendOp = VK_BLEND_OP_ADD; } return colorBlendStates; - } + }*/ VkPipelineDepthStencilStateCreateInfo VulkanRenderPipeline::BuildDepthStencilInfo(const RenderPipelineInfo& pipelineInfo) { @@ -92,4 +92,17 @@ namespace Nz return stencilStates; } + + std::vector VulkanRenderPipeline::BuildShaderStageInfo(const RenderPipelineInfo& pipelineInfo) + { + std::vector shaderStageCreateInfos; + + for (auto&& stagePtr : pipelineInfo.shaderStages) + { + VkPipelineShaderStageCreateInfo& createInfo = shaderStageCreateInfos.emplace_back(); + //createInfo. + } + + return shaderStageCreateInfos; + } } From d5c75926c63da16f764bc04aa4a8155ec9621fa4 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 3 Mar 2020 01:04:24 +0100 Subject: [PATCH 097/316] WIP (VertexDeclaration) --- include/Nazara/Utility/Algorithm.inl | 40 ++-- include/Nazara/Utility/Enums.hpp | 28 +-- include/Nazara/Utility/VertexDeclaration.hpp | 71 ++++--- include/Nazara/Utility/VertexDeclaration.inl | 83 ++++++-- include/Nazara/VulkanRenderer/Utils.hpp | 2 + include/Nazara/VulkanRenderer/Utils.inl | 12 ++ .../VulkanRenderer/VulkanRenderPipeline.hpp | 22 +- .../VulkanRenderer/VulkanShaderStage.hpp | 1 + .../VulkanRenderer/VulkanShaderStage.inl | 5 + src/Nazara/Utility/Utility.cpp | 10 +- src/Nazara/Utility/VertexDeclaration.cpp | 190 +++++------------- .../VulkanRenderer/VulkanRenderPipeline.cpp | 95 +++++++-- 12 files changed, 304 insertions(+), 255 deletions(-) diff --git a/include/Nazara/Utility/Algorithm.inl b/include/Nazara/Utility/Algorithm.inl index 829276bfb..e3f1e8be3 100644 --- a/include/Nazara/Utility/Algorithm.inl +++ b/include/Nazara/Utility/Algorithm.inl @@ -1,40 +1,32 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include namespace Nz { - namespace Detail - { - template - struct IsSuitableForComponent - { - constexpr static bool value = false; - }; - } - template constexpr ComponentType ComponentTypeId() { - static_assert(Detail::IsSuitableForComponent::value, "This type cannot be used as a component."); + static_assert(AlwaysFalse::value, "This type cannot be used as a component."); return ComponentType{}; } - template<> constexpr ComponentType ComponentTypeId() { return ComponentType_Color; } - template<> constexpr ComponentType ComponentTypeId() { return ComponentType_Double1; } - template<> constexpr ComponentType ComponentTypeId() { return ComponentType_Double2; } - template<> constexpr ComponentType ComponentTypeId() { return ComponentType_Double3; } - template<> constexpr ComponentType ComponentTypeId() { return ComponentType_Double4; } - template<> constexpr ComponentType ComponentTypeId() { return ComponentType_Float1; } - template<> constexpr ComponentType ComponentTypeId() { return ComponentType_Float2; } - template<> constexpr ComponentType ComponentTypeId() { return ComponentType_Float3; } - template<> constexpr ComponentType ComponentTypeId() { return ComponentType_Float4; } - template<> constexpr ComponentType ComponentTypeId() { return ComponentType_Int1; } - template<> constexpr ComponentType ComponentTypeId() { return ComponentType_Int2; } - template<> constexpr ComponentType ComponentTypeId() { return ComponentType_Int3; } - template<> constexpr ComponentType ComponentTypeId() { return ComponentType_Int4; } + template<> constexpr ComponentType ComponentTypeId() { return ComponentType_Color; } + template<> constexpr ComponentType ComponentTypeId() { return ComponentType_Double1; } + template<> constexpr ComponentType ComponentTypeId() { return ComponentType_Double2; } + template<> constexpr ComponentType ComponentTypeId() { return ComponentType_Double3; } + template<> constexpr ComponentType ComponentTypeId() { return ComponentType_Double4; } + template<> constexpr ComponentType ComponentTypeId() { return ComponentType_Float1; } + template<> constexpr ComponentType ComponentTypeId() { return ComponentType_Float2; } + template<> constexpr ComponentType ComponentTypeId() { return ComponentType_Float3; } + template<> constexpr ComponentType ComponentTypeId() { return ComponentType_Float4; } + template<> constexpr ComponentType ComponentTypeId() { return ComponentType_Int1; } + template<> constexpr ComponentType ComponentTypeId() { return ComponentType_Int2; } + template<> constexpr ComponentType ComponentTypeId() { return ComponentType_Int3; } + template<> constexpr ComponentType ComponentTypeId() { return ComponentType_Int4; } template<> constexpr ComponentType ComponentTypeId() { return ComponentType_Quaternion; } template diff --git a/include/Nazara/Utility/Enums.hpp b/include/Nazara/Utility/Enums.hpp index cc7413844..d9891b026 100644 --- a/include/Nazara/Utility/Enums.hpp +++ b/include/Nazara/Utility/Enums.hpp @@ -356,35 +356,25 @@ namespace Nz { VertexComponent_Unused = -1, - // We limit to 16 components by vertex since it's the minimal number supported by the GPU - VertexComponent_InstanceData0, - VertexComponent_InstanceData1, - VertexComponent_InstanceData2, - VertexComponent_InstanceData3, - VertexComponent_InstanceData4, - VertexComponent_InstanceData5, VertexComponent_Color, VertexComponent_Normal, VertexComponent_Position, VertexComponent_Tangent, VertexComponent_TexCoord, - VertexComponent_Userdata0, - VertexComponent_Userdata1, - VertexComponent_Userdata2, - VertexComponent_Userdata3, - VertexComponent_Userdata4, + VertexComponent_Userdata, - VertexComponent_FirstInstanceData = VertexComponent_InstanceData0, - VertexComponent_FirstVertexData = VertexComponent_Color, - VertexComponent_LastInstanceData = VertexComponent_InstanceData5, - VertexComponent_LastVertexData = VertexComponent_Userdata4, + VertexComponent_Max = VertexComponent_Userdata + }; - VertexComponent_Max = VertexComponent_Userdata4 + enum class VertexInputRate + { + Instance, + Vertex }; enum VertexLayout { - // Declarations meant for the rendering + // Predefined declarations for rendering VertexLayout_XY, VertexLayout_XY_Color, VertexLayout_XY_UV, @@ -397,7 +387,7 @@ namespace Nz VertexLayout_XYZ_Normal_UV_Tangent_Skinning, VertexLayout_XYZ_UV, - // Declarations meant for the instancing + // Predefined declarations for instancing VertexLayout_Matrix4, VertexLayout_Max = VertexLayout_Matrix4 diff --git a/include/Nazara/Utility/VertexDeclaration.hpp b/include/Nazara/Utility/VertexDeclaration.hpp index 536707e17..649482e6b 100644 --- a/include/Nazara/Utility/VertexDeclaration.hpp +++ b/include/Nazara/Utility/VertexDeclaration.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include @@ -30,52 +30,57 @@ namespace Nz friend class Utility; public: - VertexDeclaration(); - VertexDeclaration(const VertexDeclaration& declaration); - ~VertexDeclaration(); + struct Component; + struct ComponentEntry; - void DisableComponent(VertexComponent component); - void EnableComponent(VertexComponent component, ComponentType type, std::size_t offset); + VertexDeclaration(VertexInputRate inputRate, std::initializer_list components); + VertexDeclaration(const VertexDeclaration&) = delete; + VertexDeclaration(VertexDeclaration&&) noexcept = default; + ~VertexDeclaration() = default; - void GetComponent(VertexComponent component, bool* enabled, ComponentType* type, std::size_t* offset) const; - bool HasComponent(VertexComponent component) const; - template bool HasComponentOfType(VertexComponent component) const; - std::size_t GetStride() const; + inline const Component* FindComponent(VertexComponent vertexComponent, std::size_t componentIndex) const; - void SetStride(std::size_t stride); + template const Component* GetComponentByType(VertexComponent vertexComponent, std::size_t componentIndex = 0) const; - VertexDeclaration& operator=(const VertexDeclaration& declaration); + inline const Component& GetComponent(std::size_t componentIndex) const; + inline std::size_t GetComponentCount() const; + inline VertexInputRate GetInputRate() const; + inline std::size_t GetStride() const; - static VertexDeclaration* Get(VertexLayout layout); + inline bool HasComponent(VertexComponent component, std::size_t componentIndex = 0) const; + template bool HasComponentOfType(VertexComponent vertexComponent, std::size_t componentIndex = 0) const; + + VertexDeclaration& operator=(const VertexDeclaration&) = delete; + VertexDeclaration& operator=(VertexDeclaration&&) noexcept = default; + + static const VertexDeclarationRef& Get(VertexLayout layout); static bool IsTypeSupported(ComponentType type); template static VertexDeclarationRef New(Args&&... args); - // Signals: - NazaraSignal(OnVertexDeclarationRelease, const VertexDeclaration* /*vertexDeclaration*/); + struct Component + { + ComponentType type; + VertexComponent component; + std::size_t componentIndex; + std::size_t offset; + }; + + struct ComponentEntry + { + VertexComponent component; + ComponentType type; + std::size_t componentIndex; + }; private: static bool Initialize(); static void Uninitialize(); - struct Component - { - ComponentType type; // Le type de donnée - bool enabled = false; // Ce composant est-il activé ?/ - std::size_t offset; // La position, en octets, de la première donnée - - /* - ** -Lynix: - ** Il serait aussi possible de préciser le stride de façon indépendante, ce que je ne permets pas - ** pour décomplexifier l'interface en enlevant quelque chose que je juge inutile. - ** Si vous pensez que ça peut être utile, n'hésitez pas à me le faire savoir ! - ** PS: Même cas pour le diviseur (instancing) - */ - }; - - std::array m_components; + std::vector m_components; std::size_t m_stride; + VertexInputRate m_inputRate; - static std::array s_declarations; + static std::array s_declarations; static VertexDeclarationLibrary::LibraryMap s_library; }; } diff --git a/include/Nazara/Utility/VertexDeclaration.inl b/include/Nazara/Utility/VertexDeclaration.inl index 8f8e74179..f1ee4c290 100644 --- a/include/Nazara/Utility/VertexDeclaration.inl +++ b/include/Nazara/Utility/VertexDeclaration.inl @@ -1,32 +1,87 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp +#include +#include +#include #include #include -#include namespace Nz { + inline auto Nz::VertexDeclaration::FindComponent(VertexComponent vertexComponent, std::size_t componentIndex) const -> const Component* + { + assert(componentIndex == 0 || vertexComponent == VertexComponent_Userdata); + + for (const Component& component : m_components) + { + if (component.component == vertexComponent && component.componentIndex == componentIndex) + return &component; + } + + return nullptr; + } + + inline auto VertexDeclaration::GetComponent(std::size_t componentIndex) const -> const Component& + { + return m_components[componentIndex]; + } + + inline std::size_t VertexDeclaration::GetComponentCount() const + { + return m_components.size(); + } + + inline VertexInputRate VertexDeclaration::GetInputRate() const + { + return m_inputRate; + } + + inline std::size_t VertexDeclaration::GetStride() const + { + return m_stride; + } + + inline bool VertexDeclaration::HasComponent(VertexComponent component, std::size_t componentIndex) const + { + return FindComponent(component, componentIndex) != nullptr; + } + + template + auto VertexDeclaration::GetComponentByType(VertexComponent vertexComponent, std::size_t componentIndex) const -> const Component* + { + NazaraAssert(componentIndex == 0 || vertexComponent == VertexComponent_Userdata, "Only userdata vertex component can have component indexes"); + if (const Component* component = FindComponent(vertexComponent, componentIndex)) + { + if (GetComponentTypeOf() == component->type) + return component; + } + + return nullptr; + } + + template + bool VertexDeclaration::HasComponentOfType(VertexComponent vertexComponent, std::size_t componentIndex) const + { + return GetComponentByType(vertexComponent, componentIndex) != nullptr; + } + + const VertexDeclarationRef& VertexDeclaration::Get(VertexLayout layout) + { + NazaraAssert(layout <= VertexLayout_Max, "Vertex layout out of enum"); + + return s_declarations[layout]; + } + template VertexDeclarationRef VertexDeclaration::New(Args&&... args) { - std::unique_ptr object(new VertexDeclaration(std::forward(args)...)); + std::unique_ptr object = std::make_unique(std::forward(args)...); object->SetPersistent(false); return object.release(); } - - template - bool VertexDeclaration::HasComponentOfType(VertexComponent component) const - { - bool enabled; - Nz::ComponentType type; - - GetComponent(component, &enabled, &type, nullptr); - - return enabled && GetComponentTypeOf() == type; - } } #include diff --git a/include/Nazara/VulkanRenderer/Utils.hpp b/include/Nazara/VulkanRenderer/Utils.hpp index b80a3c3fd..40e5009a9 100644 --- a/include/Nazara/VulkanRenderer/Utils.hpp +++ b/include/Nazara/VulkanRenderer/Utils.hpp @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -18,6 +19,7 @@ namespace Nz inline VkPolygonMode ToVulkan(FaceFilling faceFilling); inline VkPrimitiveTopology ToVulkan(PrimitiveMode primitiveMode); inline VkCompareOp ToVulkan(RendererComparison comparison); + inline VkShaderStageFlagBits ToVulkan(ShaderStageType stageType); inline VkStencilOp ToVulkan(StencilOperation stencilOp); NAZARA_VULKANRENDERER_API String TranslateVulkanError(VkResult code); } diff --git a/include/Nazara/VulkanRenderer/Utils.inl b/include/Nazara/VulkanRenderer/Utils.inl index 4abbe1d0c..1f806bc43 100644 --- a/include/Nazara/VulkanRenderer/Utils.inl +++ b/include/Nazara/VulkanRenderer/Utils.inl @@ -70,6 +70,18 @@ namespace Nz return VK_COMPARE_OP_NEVER; } + VkShaderStageFlagBits ToVulkan(ShaderStageType stageType) + { + switch (stageType) + { + case ShaderStageType::Fragment: return VK_SHADER_STAGE_FRAGMENT_BIT; + case ShaderStageType::Vertex: return VK_SHADER_STAGE_VERTEX_BIT; + } + + NazaraError("Unhandled ShaderStageType 0x" + String::Number(static_cast(stageType), 16)); + return {}; + } + VkStencilOp ToVulkan(StencilOperation stencilOp) { switch (stencilOp) diff --git a/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp b/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp index aed7b6769..76f73d224 100644 --- a/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp +++ b/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp @@ -23,19 +23,37 @@ namespace Nz VulkanRenderPipeline(Vk::DeviceHandle device, RenderPipelineInfo pipelineInfo); ~VulkanRenderPipeline() = default; - static std::vector BuildColorBlendAttachmentState(const RenderPipelineInfo& pipelineInfo); + static std::vector BuildColorBlendAttachmentStateList(const RenderPipelineInfo& pipelineInfo); + static VkPipelineColorBlendStateCreateInfo BuildColorBlendInfo(const RenderPipelineInfo& pipelineInfo, const std::vector& attachmentState); static VkPipelineDepthStencilStateCreateInfo BuildDepthStencilInfo(const RenderPipelineInfo& pipelineInfo); + static VkPipelineDynamicStateCreateInfo BuildDynamicStateInfo(const RenderPipelineInfo& pipelineInfo, const std::vector& dynamicStates); + static std::vector BuildDynamicStateList(const RenderPipelineInfo& pipelineInfo); static VkPipelineInputAssemblyStateCreateInfo BuildInputAssemblyInfo(const RenderPipelineInfo& pipelineInfo); static VkPipelineRasterizationStateCreateInfo BuildRasterizationInfo(const RenderPipelineInfo& pipelineInfo); + static VkPipelineViewportStateCreateInfo BuildViewportInfo(const RenderPipelineInfo& pipelineInfo); static VkStencilOpState BuildStencilOp(const RenderPipelineInfo& pipelineInfo, bool front); static std::vector BuildShaderStageInfo(const RenderPipelineInfo& pipelineInfo); + static CreateInfo BuildCreateInfo(const RenderPipelineInfo& pipelineInfo); struct CreateInfo { + struct StateData + { + VkPipelineVertexInputStateCreateInfo vertexInputState; + VkPipelineInputAssemblyStateCreateInfo inputAssemblyState; + VkPipelineViewportStateCreateInfo viewportState; + VkPipelineRasterizationStateCreateInfo rasterizationState; + VkPipelineDepthStencilStateCreateInfo depthStencilState; + VkPipelineColorBlendStateCreateInfo colorBlendState; + VkPipelineDynamicStateCreateInfo dynamicState; + }; + std::vector colorBlendAttachmentState; + std::vector dynamicStates; std::vector shaderStages; - VkGraphicsPipelineCreateInfo createInfo; + std::unique_ptr stateData; + VkGraphicsPipelineCreateInfo pipelineInfo; }; private: diff --git a/include/Nazara/VulkanRenderer/VulkanShaderStage.hpp b/include/Nazara/VulkanRenderer/VulkanShaderStage.hpp index c7c4dcf92..533592a45 100644 --- a/include/Nazara/VulkanRenderer/VulkanShaderStage.hpp +++ b/include/Nazara/VulkanRenderer/VulkanShaderStage.hpp @@ -26,6 +26,7 @@ namespace Nz bool Create(const Vk::DeviceHandle& device, ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize); inline const Vk::ShaderModule& GetHandle() const; + inline ShaderStageType GetStageType() const; VulkanShaderStage& operator=(const VulkanShaderStage&) = delete; VulkanShaderStage& operator=(VulkanShaderStage&&) noexcept = default; diff --git a/include/Nazara/VulkanRenderer/VulkanShaderStage.inl b/include/Nazara/VulkanRenderer/VulkanShaderStage.inl index 5796071bb..e3a634c83 100644 --- a/include/Nazara/VulkanRenderer/VulkanShaderStage.inl +++ b/include/Nazara/VulkanRenderer/VulkanShaderStage.inl @@ -11,6 +11,11 @@ namespace Nz { return m_shaderModule; } + + inline ShaderStageType VulkanShaderStage::GetStageType() const + { + return m_stage; + } } #include diff --git a/src/Nazara/Utility/Utility.cpp b/src/Nazara/Utility/Utility.cpp index 4c8f1809e..1efd1c861 100644 --- a/src/Nazara/Utility/Utility.cpp +++ b/src/Nazara/Utility/Utility.cpp @@ -211,7 +211,7 @@ namespace Nz std::size_t Utility::ComponentStride[ComponentType_Max+1] = { - 4*sizeof(UInt8), // ComponentType_Color + 4*sizeof(UInt8), // ComponentType_Color 1*sizeof(double), // ComponentType_Double1 2*sizeof(double), // ComponentType_Double2 3*sizeof(double), // ComponentType_Double3 @@ -220,10 +220,10 @@ namespace Nz 2*sizeof(float), // ComponentType_Float2 3*sizeof(float), // ComponentType_Float3 4*sizeof(float), // ComponentType_Float4 - 1*sizeof(UInt32), // ComponentType_Int1 - 2*sizeof(UInt32), // ComponentType_Int2 - 3*sizeof(UInt32), // ComponentType_Int3 - 4*sizeof(UInt32), // ComponentType_Int4 + 1*sizeof(UInt32), // ComponentType_Int1 + 2*sizeof(UInt32), // ComponentType_Int2 + 3*sizeof(UInt32), // ComponentType_Int3 + 4*sizeof(UInt32), // ComponentType_Int4 4*sizeof(float) // ComponentType_Quaternion }; diff --git a/src/Nazara/Utility/VertexDeclaration.cpp b/src/Nazara/Utility/VertexDeclaration.cpp index 7edbd3124..d44692e31 100644 --- a/src/Nazara/Utility/VertexDeclaration.cpp +++ b/src/Nazara/Utility/VertexDeclaration.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2017 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp @@ -14,144 +14,27 @@ namespace Nz { - VertexDeclaration::VertexDeclaration() : - m_stride(0) + VertexDeclaration::VertexDeclaration(VertexInputRate inputRate, std::initializer_list components) : + m_inputRate(inputRate) { - } + std::size_t offset = 0; - VertexDeclaration::VertexDeclaration(const VertexDeclaration& declaration) : - RefCounted(), - m_components(declaration.m_components), - m_stride(declaration.m_stride) - { - } - - VertexDeclaration::~VertexDeclaration() - { - OnVertexDeclarationRelease(this); - } - - void VertexDeclaration::DisableComponent(VertexComponent component) - { - #ifdef NAZARA_DEBUG - if (component > VertexComponent_Max) + m_components.reserve(components.size()); + for (const ComponentEntry& entry : components) { - NazaraError("Vertex component out of enum"); - return; - } - #endif + auto& component = m_components.emplace_back(); + component.component = entry.component; + component.componentIndex = entry.componentIndex; + component.offset = offset; + component.type = entry.type; - #if NAZARA_UTILITY_SAFE - if (component == VertexComponent_Unused) - { - NazaraError("Cannot disable \"unused\" component"); - return; - } - #endif + NazaraAssert(IsTypeSupported(component.type), "Component type 0x" + String::Number(component.type, 16) + " is not supported by vertex declarations"); + NazaraAssert(component.componentIndex == 0 || component.component == VertexComponent_Userdata, "Only userdata components can have non-zero component indexes"); - Component& vertexComponent = m_components[component]; - if (vertexComponent.enabled) - { - vertexComponent.enabled = false; - m_stride -= Utility::ComponentStride[vertexComponent.type]; - } - } - - void VertexDeclaration::EnableComponent(VertexComponent component, ComponentType type, std::size_t offset) - { - #ifdef NAZARA_DEBUG - if (component > VertexComponent_Max) - { - NazaraError("Vertex component out of enum"); - return; - } - #endif - - #if NAZARA_UTILITY_SAFE - if (!IsTypeSupported(type)) - { - NazaraError("Component type 0x" + String::Number(type, 16) + " is not supported by vertex declarations"); - return; - } - #endif - - if (component != VertexComponent_Unused) - { - Component& vertexComponent = m_components[component]; - if (vertexComponent.enabled) - m_stride -= Utility::ComponentStride[vertexComponent.type]; - else - vertexComponent.enabled = true; - - vertexComponent.offset = offset; - vertexComponent.type = type; + offset += Utility::ComponentStride[component.type]; } - m_stride += Utility::ComponentStride[type]; - } - - void VertexDeclaration::GetComponent(VertexComponent component, bool* enabled, ComponentType* type, std::size_t* offset) const - { - #ifdef NAZARA_DEBUG - if (component > VertexComponent_Max) - { - NazaraError("Vertex component out of enum"); - return; - } - #endif - - #if NAZARA_UTILITY_SAFE - if (component == VertexComponent_Unused) - { - NazaraError("Cannot get \"unused\" component"); - return; - } - #endif - - const Component& vertexComponent = m_components[component]; - - if (enabled) - *enabled = vertexComponent.enabled; - - if (type) - *type = vertexComponent.type; - - if (offset) - *offset = vertexComponent.offset; - } - - bool VertexDeclaration::HasComponent(VertexComponent component) const - { - bool enabled; - - GetComponent(component, &enabled, nullptr, nullptr); - - return enabled; - } - - std::size_t VertexDeclaration::GetStride() const - { - return m_stride; - } - - void VertexDeclaration::SetStride(std::size_t stride) - { - m_stride = stride; - } - - VertexDeclaration& VertexDeclaration::operator=(const VertexDeclaration& declaration) - { - m_components = declaration.m_components; - m_stride = declaration.m_stride; - - return *this; - } - - VertexDeclaration* VertexDeclaration::Get(VertexLayout layout) - { - NazaraAssert(layout <= VertexLayout_Max, "Vertex layout out of enum"); - - return &s_declarations[layout]; + m_stride = offset; } bool VertexDeclaration::IsTypeSupported(ComponentType type) @@ -193,22 +76,37 @@ namespace Nz { ErrorFlags flags(ErrorFlag_Silent | ErrorFlag_ThrowException); - // Layout : Type - VertexDeclaration* declaration; + auto NewDeclaration = [](VertexInputRate inputRate, std::initializer_list components) + { + return New(inputRate, std::move(components)); + }; // VertexLayout_XY : VertexStruct_XY - declaration = &s_declarations[VertexLayout_XY]; - declaration->EnableComponent(VertexComponent_Position, ComponentType_Float2, NazaraOffsetOf(VertexStruct_XY, position)); + s_declarations[VertexLayout_XY] = NewDeclaration(VertexInputRate::Vertex, { + { + VertexComponent_Position, + ComponentType_Float2, + 0 + } + }); - NazaraAssert(declaration->GetStride() == sizeof(VertexStruct_XY), "Invalid stride for declaration VertexLayout_XY"); + NazaraAssert(s_declarations[VertexLayout_XY]->GetStride() == sizeof(VertexStruct_XY), "Invalid stride for declaration VertexLayout_XY"); - // VertexLayout_XY_Color : VertexStruct_XY_Color - declaration = &s_declarations[VertexLayout_XY_Color]; - declaration->EnableComponent(VertexComponent_Position, ComponentType_Float2, NazaraOffsetOf(VertexStruct_XY_Color, position)); - declaration->EnableComponent(VertexComponent_Color, ComponentType_Color, NazaraOffsetOf(VertexStruct_XY_Color, color)); - - NazaraAssert(declaration->GetStride() == sizeof(VertexStruct_XY_Color), "Invalid stride for declaration VertexLayout_XY_Color"); + s_declarations[VertexLayout_XY_Color] = NewDeclaration(VertexInputRate::Vertex, { + { + VertexComponent_Position, + ComponentType_Float2, + 0 + }, + { + VertexComponent_Color, + ComponentType_Color, + 0 + }, + }); + NazaraAssert(s_declarations[VertexLayout_XY_Color]->GetStride() == sizeof(VertexStruct_XY_Color), "Invalid stride for declaration VertexLayout_XY_Color"); + /* // VertexLayout_XY_UV : VertexStruct_XY_UV declaration = &s_declarations[VertexLayout_XY_UV]; declaration->EnableComponent(VertexComponent_Position, ComponentType_Float2, NazaraOffsetOf(VertexStruct_XY_UV, position)); @@ -287,7 +185,7 @@ namespace Nz declaration->EnableComponent(VertexComponent_InstanceData2, ComponentType_Float4, NazaraOffsetOf(Matrix4f, m31)); declaration->EnableComponent(VertexComponent_InstanceData3, ComponentType_Float4, NazaraOffsetOf(Matrix4f, m41)); - NazaraAssert(declaration->GetStride() == sizeof(Matrix4f), "Invalid stride for declaration VertexLayout_Matrix4"); + NazaraAssert(declaration->GetStride() == sizeof(Matrix4f), "Invalid stride for declaration VertexLayout_Matrix4");*/ } catch (const std::exception& e) { @@ -301,8 +199,10 @@ namespace Nz void VertexDeclaration::Uninitialize() { VertexDeclarationLibrary::Uninitialize(); + + s_declarations.fill(nullptr); } - std::array VertexDeclaration::s_declarations; + std::array VertexDeclaration::s_declarations; VertexDeclarationLibrary::LibraryMap VertexDeclaration::s_library; } diff --git a/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp b/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp index 1071f7573..99a185107 100644 --- a/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp +++ b/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -16,11 +17,13 @@ namespace Nz { } - /*VkPipelineColorBlendAttachmentState VulkanRenderPipeline::BuildColorBlendAttachmentState(const RenderPipelineInfo& pipelineInfo) + std::vector VulkanRenderPipeline::BuildColorBlendAttachmentStateList(const RenderPipelineInfo& pipelineInfo) { - VkPipelineColorBlendAttachmentState colorBlendStates; - colorBlendStates.blendEnable = pipelineInfo.blending; - colorBlendStates.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT; //< TODO + std::vector colorBlendStates; + + VkPipelineColorBlendAttachmentState colorBlendState = colorBlendStates.emplace_back(); + colorBlendState.blendEnable = pipelineInfo.blending; + colorBlendState.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT; //< TODO if (pipelineInfo.blending) { @@ -29,18 +32,29 @@ namespace Nz { blendState.dstAlphaBlendFactor }*/ - /*} + } else { - colorBlendStates.srcColorBlendFactor = VK_BLEND_FACTOR_ONE; - colorBlendStates.dstColorBlendFactor = VK_BLEND_FACTOR_ZERO; - colorBlendStates.colorBlendOp = VK_BLEND_OP_ADD; - colorBlendStates.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE; - colorBlendStates.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO; - colorBlendStates.alphaBlendOp = VK_BLEND_OP_ADD; + colorBlendState.srcColorBlendFactor = VK_BLEND_FACTOR_ONE; + colorBlendState.dstColorBlendFactor = VK_BLEND_FACTOR_ZERO; + colorBlendState.colorBlendOp = VK_BLEND_OP_ADD; + colorBlendState.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE; + colorBlendState.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO; + colorBlendState.alphaBlendOp = VK_BLEND_OP_ADD; } + return colorBlendStates; - }*/ + } + + VkPipelineColorBlendStateCreateInfo VulkanRenderPipeline::BuildColorBlendInfo(const RenderPipelineInfo& pipelineInfo, const std::vector& attachmentState) + { + VkPipelineColorBlendStateCreateInfo createInfo = {}; + createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; + createInfo.attachmentCount = std::uint32_t(attachmentState.size()); + createInfo.pAttachments = attachmentState.data(); + + return createInfo; + } VkPipelineDepthStencilStateCreateInfo VulkanRenderPipeline::BuildDepthStencilInfo(const RenderPipelineInfo& pipelineInfo) { @@ -56,6 +70,21 @@ namespace Nz return createInfo; } + VkPipelineDynamicStateCreateInfo VulkanRenderPipeline::BuildDynamicStateInfo(const RenderPipelineInfo& pipelineInfo, const std::vector& dynamicStates) + { + VkPipelineDynamicStateCreateInfo createInfo = {}; + createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; + createInfo.dynamicStateCount = std::uint32_t(dynamicStates.size()); + createInfo.pDynamicStates = dynamicStates.data(); + + return createInfo; + } + + std::vector VulkanRenderPipeline::BuildDynamicStateList(const RenderPipelineInfo& pipelineInfo) + { + return { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR }; + } + VkPipelineInputAssemblyStateCreateInfo VulkanRenderPipeline::BuildInputAssemblyInfo(const RenderPipelineInfo& pipelineInfo) { VkPipelineInputAssemblyStateCreateInfo createInfo = {}; @@ -77,6 +106,15 @@ namespace Nz return createInfo; } + VkPipelineViewportStateCreateInfo VulkanRenderPipeline::BuildViewportInfo(const RenderPipelineInfo& pipelineInfo) + { + VkPipelineViewportStateCreateInfo createInfo = {}; + createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; + createInfo.scissorCount = createInfo.viewportCount = 1; //< TODO + + return createInfo; + } + VkStencilOpState VulkanRenderPipeline::BuildStencilOp(const RenderPipelineInfo& pipelineInfo, bool front) { const auto& pipelineStencil = (front) ? pipelineInfo.stencilFront : pipelineInfo.stencilBack; @@ -99,10 +137,41 @@ namespace Nz for (auto&& stagePtr : pipelineInfo.shaderStages) { + Nz::VulkanShaderStage& vulkanStage = *static_cast(stagePtr.get()); + VkPipelineShaderStageCreateInfo& createInfo = shaderStageCreateInfos.emplace_back(); - //createInfo. + createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; + createInfo.module = vulkanStage.GetHandle(); + createInfo.pName = "main"; + createInfo.stage = ToVulkan(vulkanStage.GetStageType()); } return shaderStageCreateInfos; } + + auto VulkanRenderPipeline::BuildCreateInfo(const RenderPipelineInfo& pipelineInfo) -> CreateInfo + { + CreateInfo createInfo = {}; + createInfo.stateData = std::make_unique(); + + createInfo.colorBlendAttachmentState = BuildColorBlendAttachmentStateList(pipelineInfo); + createInfo.dynamicStates = BuildDynamicStateList(pipelineInfo); + createInfo.shaderStages = BuildShaderStageInfo(pipelineInfo); + + createInfo.stateData->colorBlendState = BuildColorBlendInfo(pipelineInfo, createInfo.colorBlendAttachmentState); + createInfo.stateData->depthStencilState = BuildDepthStencilInfo(pipelineInfo); + createInfo.stateData->dynamicState = BuildDynamicStateInfo(pipelineInfo, createInfo.dynamicStates); + createInfo.stateData->inputAssemblyState = BuildInputAssemblyInfo(pipelineInfo); + createInfo.stateData->rasterizationState = BuildRasterizationInfo(pipelineInfo); + createInfo.stateData->viewportState = BuildViewportInfo(pipelineInfo); + + createInfo.pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; + createInfo.pipelineInfo.stageCount = std::uint32_t(createInfo.shaderStages.size()); + createInfo.pipelineInfo.pStages = createInfo.shaderStages.data(); + + createInfo.pipelineInfo.pColorBlendState = createInfo.colorBlendAttachmentState.data(); + createInfo.pipelineInfo. + + return createInfo; + } } From 7bf734cdd45d9aa75fc87455cd5cadd36544e2f5 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 3 Mar 2020 22:26:57 +0100 Subject: [PATCH 098/316] Improve pipeline building --- examples/VulkanTest/main.cpp | 157 +----------- .../bin/resources/shaders/triangle.frag.spv | Bin 572 -> 572 bytes examples/bin/resources/shaders/triangle.vert | 4 +- .../bin/resources/shaders/triangle.vert.spv | Bin 1492 -> 1444 bytes include/Nazara/Core/Algorithm.hpp | 1 + include/Nazara/Core/Algorithm.inl | 6 + include/Nazara/Renderer/RenderStates.hpp | 8 + include/Nazara/Utility/VertexDeclaration.hpp | 2 +- include/Nazara/Utility/VertexDeclaration.inl | 17 +- include/Nazara/Utility/VertexMapper.hpp | 2 +- include/Nazara/Utility/VertexMapper.inl | 12 +- include/Nazara/VulkanRenderer/Utils.hpp | 3 + include/Nazara/VulkanRenderer/Utils.inl | 37 +++ .../VulkanRenderer/VulkanRenderPipeline.hpp | 17 +- src/Nazara/Utility/VertexDeclaration.cpp | 232 ++++++++++++++---- .../VulkanRenderer/VulkanRenderPipeline.cpp | 79 +++++- 16 files changed, 360 insertions(+), 217 deletions(-) diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index e731f04ed..811c8a21f 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -223,8 +223,15 @@ int main() descriptorSet.WriteUniformDescriptor(0, uniformBufferImpl->GetBufferHandle(), 0, uniformSize); Nz::RenderPipelineInfo pipelineInfo; + pipelineInfo.shaderStages.emplace_back(fragmentShader); + pipelineInfo.shaderStages.emplace_back(vertexShader); - std::unique_ptr pipeline = device->InstantiateRenderPipeline(pipelineInfo); + auto& vertexBuffer = pipelineInfo.vertexBuffers.emplace_back(); + vertexBuffer.binding = 0; + vertexBuffer.declaration = drfreakVB->GetVertexDeclaration(); + + + //std::unique_ptr pipeline = device->InstantiateRenderPipeline(pipelineInfo); VkDescriptorSetLayout descriptorSetLayout = descriptorLayout; @@ -241,150 +248,12 @@ int main() Nz::Vk::PipelineLayout pipelineLayout; pipelineLayout.Create(vulkanDevice.shared_from_this(), layout_create_info); - - std::array shaderStageCreateInfo = { - { - { - VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, - nullptr, - 0, - VK_SHADER_STAGE_VERTEX_BIT, - static_cast(vertexShader.get())->GetHandle(), - "main", - nullptr - }, - { - VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, - nullptr, - 0, - VK_SHADER_STAGE_FRAGMENT_BIT, - static_cast(fragmentShader.get())->GetHandle(), - "main", - nullptr - } - } - }; - - VkVertexInputBindingDescription bindingDescription = { - 0, - drfreakVB->GetStride(), - VK_VERTEX_INPUT_RATE_VERTEX - }; - - std::array attributeDescription = - { - { - { - 0, // uint32_t location - 0, // uint32_t binding; - VK_FORMAT_R32G32B32_SFLOAT, // VkFormat format; - 0 // uint32_t offset; - }, - { - 1, // uint32_t location - 0, // uint32_t binding; - VK_FORMAT_R32G32B32_SFLOAT, // VkFormat format; - sizeof(float) * 3 // uint32_t offset; - } - } - }; - - VkPipelineVertexInputStateCreateInfo vertex_input_state_create_info = { - VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // VkStructureType sType - nullptr, // const void *pNext - 0, // VkPipelineVertexInputStateCreateFlags flags; - 1, // uint32_t vertexBindingDescriptionCount - &bindingDescription, // const VkVertexInputBindingDescription *pVertexBindingDescriptions - Nz::UInt32(attributeDescription.size()), // uint32_t vertexAttributeDescriptionCount - attributeDescription.data() // const VkVertexInputAttributeDescription *pVertexAttributeDescriptions - }; - - VkPipelineViewportStateCreateInfo viewport_state_create_info = { - VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, // VkStructureType sType - nullptr, // const void *pNext - 0, // VkPipelineViewportStateCreateFlags flags - 1, // uint32_t viewportCount - nullptr, // const VkViewport *pViewports - 1, // uint32_t scissorCount - nullptr // const VkRect2D *pScissors - }; - - VkPipelineInputAssemblyStateCreateInfo input_assembly_state_create_info = Nz::VulkanRenderPipeline::BuildInputAssemblyInfo(pipelineInfo); - VkPipelineRasterizationStateCreateInfo rasterization_state_create_info = Nz::VulkanRenderPipeline::BuildRasterizationInfo(pipelineInfo); - VkPipelineDepthStencilStateCreateInfo depthStencilInfo = Nz::VulkanRenderPipeline::BuildDepthStencilInfo(pipelineInfo); - - VkPipelineMultisampleStateCreateInfo multisample_state_create_info = { - VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, // VkStructureType sType - nullptr, // const void *pNext - 0, // VkPipelineMultisampleStateCreateFlags flags - VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits rasterizationSamples - VK_FALSE, // VkBool32 sampleShadingEnable - 1.0f, // float minSampleShading - nullptr, // const VkSampleMask *pSampleMask - VK_FALSE, // VkBool32 alphaToCoverageEnable - VK_FALSE // VkBool32 alphaToOneEnable - }; - - VkPipelineColorBlendAttachmentState color_blend_attachment_state = { - VK_FALSE, // VkBool32 blendEnable - VK_BLEND_FACTOR_ONE, // VkBlendFactor srcColorBlendFactor - VK_BLEND_FACTOR_ZERO, // VkBlendFactor dstColorBlendFactor - VK_BLEND_OP_ADD, // VkBlendOp colorBlendOp - VK_BLEND_FACTOR_ONE, // VkBlendFactor srcAlphaBlendFactor - VK_BLEND_FACTOR_ZERO, // VkBlendFactor dstAlphaBlendFactor - VK_BLEND_OP_ADD, // VkBlendOp alphaBlendOp - VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | // VkColorComponentFlags colorWriteMask - VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT - }; - - VkPipelineColorBlendStateCreateInfo color_blend_state_create_info = { - VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, // VkStructureType sType - nullptr, // const void *pNext - 0, // VkPipelineColorBlendStateCreateFlags flags - VK_FALSE, // VkBool32 logicOpEnable - VK_LOGIC_OP_COPY, // VkLogicOp logicOp - 1, // uint32_t attachmentCount - &color_blend_attachment_state, // const VkPipelineColorBlendAttachmentState *pAttachments - {0.0f, 0.0f, 0.0f, 0.0f} // float blendConstants[4] - }; - - std::array dynamicStates = { - VK_DYNAMIC_STATE_SCISSOR, - VK_DYNAMIC_STATE_VIEWPORT, - }; - - VkPipelineDynamicStateCreateInfo dynamicStateInfo = { - VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO, // VkStructureType sType; - nullptr, // const void* pNext; - 0, // VkPipelineDynamicStateCreateFlags flags; - Nz::UInt32(dynamicStates.size()), // uint32_t dynamicStateCount; - dynamicStates.data() // const VkDynamicState* pDynamicStates; - }; - - VkGraphicsPipelineCreateInfo pipeline_create_info = { - VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, // VkStructureType sType - nullptr, // const void *pNext - 0, // VkPipelineCreateFlags flags - static_cast(shaderStageCreateInfo.size()), // uint32_t stageCount - shaderStageCreateInfo.data(), // const VkPipelineShaderStageCreateInfo *pStages - &vertex_input_state_create_info, // const VkPipelineVertexInputStateCreateInfo *pVertexInputState; - &input_assembly_state_create_info, // const VkPipelineInputAssemblyStateCreateInfo *pInputAssemblyState - nullptr, // const VkPipelineTessellationStateCreateInfo *pTessellationState - &viewport_state_create_info, // const VkPipelineViewportStateCreateInfo *pViewportState - &rasterization_state_create_info, // const VkPipelineRasterizationStateCreateInfo *pRasterizationState - &multisample_state_create_info, // const VkPipelineMultisampleStateCreateInfo *pMultisampleState - &depthStencilInfo, // const VkPipelineDepthStencilStateCreateInfo *pDepthStencilState - &color_blend_state_create_info, // const VkPipelineColorBlendStateCreateInfo *pColorBlendState - &dynamicStateInfo, // const VkPipelineDynamicStateCreateInfo *pDynamicState - pipelineLayout, // VkPipelineLayout layout - vulkanWindow.GetRenderPass(), // VkRenderPass renderPass - 0, // uint32_t subpass - VK_NULL_HANDLE, // VkPipeline basePipelineHandle - -1 // int32_t basePipelineIndex - }; + Nz::VulkanRenderPipeline::CreateInfo pipelineCreateInfo = Nz::VulkanRenderPipeline::BuildCreateInfo(pipelineInfo); + pipelineCreateInfo.pipelineInfo.layout = pipelineLayout; + pipelineCreateInfo.pipelineInfo.renderPass = vulkanWindow.GetRenderPass(); Nz::Vk::Pipeline vkPipeline; - if (!vkPipeline.CreateGraphics(vulkanDevice.shared_from_this(), pipeline_create_info)) + if (!vkPipeline.CreateGraphics(vulkanDevice.shared_from_this(), pipelineCreateInfo.pipelineInfo)) { NazaraError("Failed to create pipeline"); return __LINE__; @@ -501,7 +370,7 @@ int main() // Gestion de la caméra free-fly (Rotation) float sensitivity = 0.3f; // Sensibilité de la souris - // On modifie l'angle de la caméra grâce au déplacement relatif sur X de la souris + // On modifie l'angle de la caméra grâce au déplacement relatif sur X de la souris camAngles.yaw = Nz::NormalizeAngle(camAngles.yaw - event.mouseMove.deltaX*sensitivity); // Idem, mais pour éviter les problèmes de calcul de la matrice de vue, on restreint les angles diff --git a/examples/bin/resources/shaders/triangle.frag.spv b/examples/bin/resources/shaders/triangle.frag.spv index 06ab7a2fc2398c7fe17c45bb65069587bc9af78c..3804e0ca05a6071d94591cb640444938edc1df7b 100644 GIT binary patch delta 18 ZcmdnPvWJC}nMs+Qfq{{MV3Y!EeG JiywY`Nxplb6Au6Y delta 293 zcmXwzOA5k35JYQ|_<=AWo std::size_t CountOf(const T& c); template void HashCombine(std::size_t& seed, const T& v); template T ReverseBits(T integer); + template auto UnderlyingCast(T value) -> std::underlying_type_t; template struct AlwaysFalse : std::false_type {}; diff --git a/include/Nazara/Core/Algorithm.inl b/include/Nazara/Core/Algorithm.inl index f21b0c36a..391e32326 100644 --- a/include/Nazara/Core/Algorithm.inl +++ b/include/Nazara/Core/Algorithm.inl @@ -195,6 +195,12 @@ namespace Nz return reversed; } + template + auto UnderlyingCast(T value) -> std::underlying_type_t + { + return static_cast>(value); + } + template struct PointedType { using type = T; }; template struct PointedType { using type = T; }; template struct PointedType { using type = T; }; diff --git a/include/Nazara/Renderer/RenderStates.hpp b/include/Nazara/Renderer/RenderStates.hpp index f4d4ea369..f1c0ff6cb 100644 --- a/include/Nazara/Renderer/RenderStates.hpp +++ b/include/Nazara/Renderer/RenderStates.hpp @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -36,7 +37,14 @@ namespace Nz UInt32 writeMask = 0xFFFFFFFF; } stencilBack, stencilFront; + struct VertexBufferData + { + std::size_t binding; + VertexDeclarationConstRef declaration; + }; + std::vector> shaderStages; + std::vector vertexBuffers; bool blending = false; bool colorWrite = true; diff --git a/include/Nazara/Utility/VertexDeclaration.hpp b/include/Nazara/Utility/VertexDeclaration.hpp index 649482e6b..a11b3b798 100644 --- a/include/Nazara/Utility/VertexDeclaration.hpp +++ b/include/Nazara/Utility/VertexDeclaration.hpp @@ -53,7 +53,7 @@ namespace Nz VertexDeclaration& operator=(const VertexDeclaration&) = delete; VertexDeclaration& operator=(VertexDeclaration&&) noexcept = default; - static const VertexDeclarationRef& Get(VertexLayout layout); + static inline const VertexDeclarationRef& Get(VertexLayout layout); static bool IsTypeSupported(ComponentType type); template static VertexDeclarationRef New(Args&&... args); diff --git a/include/Nazara/Utility/VertexDeclaration.inl b/include/Nazara/Utility/VertexDeclaration.inl index f1ee4c290..1e1462556 100644 --- a/include/Nazara/Utility/VertexDeclaration.inl +++ b/include/Nazara/Utility/VertexDeclaration.inl @@ -67,7 +67,7 @@ namespace Nz return GetComponentByType(vertexComponent, componentIndex) != nullptr; } - const VertexDeclarationRef& VertexDeclaration::Get(VertexLayout layout) + inline const VertexDeclarationRef& VertexDeclaration::Get(VertexLayout layout) { NazaraAssert(layout <= VertexLayout_Max, "Vertex layout out of enum"); @@ -84,4 +84,19 @@ namespace Nz } } +namespace std +{ + inline const Nz::VertexDeclaration::Component* begin(const Nz::VertexDeclaration& declaration) + { + assert(declaration.GetComponentCount() != 0); + return &declaration.GetComponent(0); + } + + inline const Nz::VertexDeclaration::Component* end(const Nz::VertexDeclaration& declaration) + { + assert(declaration.GetComponentCount() != 0); + return (&declaration.GetComponent(declaration.GetComponentCount() - 1) + 1); + } +} + #include diff --git a/include/Nazara/Utility/VertexMapper.hpp b/include/Nazara/Utility/VertexMapper.hpp index d76d830a6..80680a86d 100644 --- a/include/Nazara/Utility/VertexMapper.hpp +++ b/include/Nazara/Utility/VertexMapper.hpp @@ -26,7 +26,7 @@ namespace Nz VertexMapper(const VertexBuffer* vertexBuffer, BufferAccess access = BufferAccess_ReadOnly); ~VertexMapper(); - template SparsePtr GetComponentPtr(VertexComponent component); + template SparsePtr GetComponentPtr(VertexComponent component, std::size_t componentIndex = 0); inline const VertexBuffer* GetVertexBuffer() const; inline std::size_t GetVertexCount() const; diff --git a/include/Nazara/Utility/VertexMapper.inl b/include/Nazara/Utility/VertexMapper.inl index bdb1edfc2..736a51c35 100644 --- a/include/Nazara/Utility/VertexMapper.inl +++ b/include/Nazara/Utility/VertexMapper.inl @@ -10,19 +10,13 @@ namespace Nz { template - SparsePtr VertexMapper::GetComponentPtr(VertexComponent component) + SparsePtr VertexMapper::GetComponentPtr(VertexComponent component, std::size_t componentIndex) { // On récupère la déclaration depuis le buffer const VertexDeclaration* declaration = m_mapper.GetBuffer()->GetVertexDeclaration(); - // Ensuite le composant qui nous intéresse - bool enabled; - ComponentType type; - std::size_t offset; - declaration->GetComponent(component, &enabled, &type, &offset); - - if (enabled && GetComponentTypeOf() == type) - return SparsePtr(static_cast(m_mapper.GetPointer()) + offset, declaration->GetStride()); + if (const auto* componentData = declaration->GetComponentByType(component, componentIndex)) + return SparsePtr(static_cast(m_mapper.GetPointer()) + componentData->offset, declaration->GetStride()); else return SparsePtr(); } diff --git a/include/Nazara/VulkanRenderer/Utils.hpp b/include/Nazara/VulkanRenderer/Utils.hpp index 40e5009a9..1c1d6715e 100644 --- a/include/Nazara/VulkanRenderer/Utils.hpp +++ b/include/Nazara/VulkanRenderer/Utils.hpp @@ -15,12 +15,15 @@ namespace Nz { + inline VkFormat ToVulkan(ComponentType componentType); inline VkCullModeFlagBits ToVulkan(FaceSide faceSide); inline VkPolygonMode ToVulkan(FaceFilling faceFilling); inline VkPrimitiveTopology ToVulkan(PrimitiveMode primitiveMode); inline VkCompareOp ToVulkan(RendererComparison comparison); inline VkShaderStageFlagBits ToVulkan(ShaderStageType stageType); inline VkStencilOp ToVulkan(StencilOperation stencilOp); + inline VkVertexInputRate ToVulkan(VertexInputRate inputRate); + NAZARA_VULKANRENDERER_API String TranslateVulkanError(VkResult code); } diff --git a/include/Nazara/VulkanRenderer/Utils.inl b/include/Nazara/VulkanRenderer/Utils.inl index 1f806bc43..723483292 100644 --- a/include/Nazara/VulkanRenderer/Utils.inl +++ b/include/Nazara/VulkanRenderer/Utils.inl @@ -3,12 +3,37 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include #include #include namespace Nz { + VkFormat ToVulkan(ComponentType componentType) + { + switch (componentType) + { + case ComponentType_Color: return VK_FORMAT_R8G8B8A8_UINT; + case ComponentType_Double1: return VK_FORMAT_R64_SFLOAT; + case ComponentType_Double2: return VK_FORMAT_R64G64_SFLOAT; + case ComponentType_Double3: return VK_FORMAT_R64G64B64_SFLOAT; + case ComponentType_Double4: return VK_FORMAT_R64G64B64A64_SFLOAT; + case ComponentType_Float1: return VK_FORMAT_R32_SFLOAT; + case ComponentType_Float2: return VK_FORMAT_R32G32_SFLOAT; + case ComponentType_Float3: return VK_FORMAT_R32G32B32_SFLOAT; + case ComponentType_Float4: return VK_FORMAT_R32G32B32A32_SFLOAT; + case ComponentType_Int1: return VK_FORMAT_R32_SINT; + case ComponentType_Int2: return VK_FORMAT_R32G32_SINT; + case ComponentType_Int3: return VK_FORMAT_R32G32B32_SINT; + case ComponentType_Int4: return VK_FORMAT_R32G32B32A32_SINT; + case ComponentType_Quaternion: return VK_FORMAT_R32G32B32A32_SFLOAT; + } + + NazaraError("Unhandled ComponentType 0x" + String::Number(componentType, 16)); + return VK_FORMAT_UNDEFINED; + } + VkCullModeFlagBits ToVulkan(FaceSide faceSide) { switch (faceSide) @@ -99,6 +124,18 @@ namespace Nz NazaraError("Unhandled RendererComparison 0x" + String::Number(stencilOp, 16)); return VK_STENCIL_OP_KEEP; } + + VkVertexInputRate ToVulkan(VertexInputRate inputRate) + { + switch (inputRate) + { + case VertexInputRate::Instance: return VK_VERTEX_INPUT_RATE_INSTANCE; + case VertexInputRate::Vertex: return VK_VERTEX_INPUT_RATE_VERTEX; + } + + NazaraError("Unhandled VertexInputRate 0x" + String::Number(UnderlyingCast(inputRate), 16)); + return VK_VERTEX_INPUT_RATE_VERTEX; + } } #include diff --git a/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp b/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp index 76f73d224..5c292da04 100644 --- a/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp +++ b/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp @@ -29,10 +29,14 @@ namespace Nz static VkPipelineDynamicStateCreateInfo BuildDynamicStateInfo(const RenderPipelineInfo& pipelineInfo, const std::vector& dynamicStates); static std::vector BuildDynamicStateList(const RenderPipelineInfo& pipelineInfo); static VkPipelineInputAssemblyStateCreateInfo BuildInputAssemblyInfo(const RenderPipelineInfo& pipelineInfo); + static VkPipelineMultisampleStateCreateInfo BuildMultisampleInfo(const RenderPipelineInfo& pipelineInfo); static VkPipelineRasterizationStateCreateInfo BuildRasterizationInfo(const RenderPipelineInfo& pipelineInfo); static VkPipelineViewportStateCreateInfo BuildViewportInfo(const RenderPipelineInfo& pipelineInfo); static VkStencilOpState BuildStencilOp(const RenderPipelineInfo& pipelineInfo, bool front); static std::vector BuildShaderStageInfo(const RenderPipelineInfo& pipelineInfo); + static std::vector BuildVertexAttributeDescription(const RenderPipelineInfo& pipelineInfo); + static std::vector BuildVertexBindingDescription(const RenderPipelineInfo& pipelineInfo); + static VkPipelineVertexInputStateCreateInfo BuildVertexInputInfo(const RenderPipelineInfo& pipelineInfo, const std::vector& vertexAttributes, const std::vector& bindingDescription); static CreateInfo BuildCreateInfo(const RenderPipelineInfo& pipelineInfo); @@ -40,18 +44,21 @@ namespace Nz { struct StateData { - VkPipelineVertexInputStateCreateInfo vertexInputState; - VkPipelineInputAssemblyStateCreateInfo inputAssemblyState; - VkPipelineViewportStateCreateInfo viewportState; - VkPipelineRasterizationStateCreateInfo rasterizationState; - VkPipelineDepthStencilStateCreateInfo depthStencilState; VkPipelineColorBlendStateCreateInfo colorBlendState; + VkPipelineDepthStencilStateCreateInfo depthStencilState; VkPipelineDynamicStateCreateInfo dynamicState; + VkPipelineMultisampleStateCreateInfo multiSampleState; + VkPipelineInputAssemblyStateCreateInfo inputAssemblyState; + VkPipelineRasterizationStateCreateInfo rasterizationState; + VkPipelineVertexInputStateCreateInfo vertexInputState; + VkPipelineViewportStateCreateInfo viewportState; }; std::vector colorBlendAttachmentState; std::vector dynamicStates; std::vector shaderStages; + std::vector vertexAttributesDescription; + std::vector vertexBindingDescription; std::unique_ptr stateData; VkGraphicsPipelineCreateInfo pipelineInfo; }; diff --git a/src/Nazara/Utility/VertexDeclaration.cpp b/src/Nazara/Utility/VertexDeclaration.cpp index d44692e31..61c7f1d86 100644 --- a/src/Nazara/Utility/VertexDeclaration.cpp +++ b/src/Nazara/Utility/VertexDeclaration.cpp @@ -106,86 +106,216 @@ namespace Nz }); NazaraAssert(s_declarations[VertexLayout_XY_Color]->GetStride() == sizeof(VertexStruct_XY_Color), "Invalid stride for declaration VertexLayout_XY_Color"); - /* + // VertexLayout_XY_UV : VertexStruct_XY_UV - declaration = &s_declarations[VertexLayout_XY_UV]; - declaration->EnableComponent(VertexComponent_Position, ComponentType_Float2, NazaraOffsetOf(VertexStruct_XY_UV, position)); - declaration->EnableComponent(VertexComponent_TexCoord, ComponentType_Float2, NazaraOffsetOf(VertexStruct_XY_UV, uv)); + s_declarations[VertexLayout_XY_UV] = NewDeclaration(VertexInputRate::Vertex, { + { + VertexComponent_Position, + ComponentType_Float2, + 0 + }, + { + VertexComponent_TexCoord, + ComponentType_Float2, + 0 + }, + }); - NazaraAssert(declaration->GetStride() == sizeof(VertexStruct_XY_UV), "Invalid stride for declaration VertexLayout_XY_UV"); + NazaraAssert(s_declarations[VertexLayout_XY_UV]->GetStride() == sizeof(VertexStruct_XY_UV), "Invalid stride for declaration VertexLayout_XY_UV"); // VertexLayout_XYZ : VertexStruct_XYZ - declaration = &s_declarations[VertexLayout_XYZ]; - declaration->EnableComponent(VertexComponent_Position, ComponentType_Float3, NazaraOffsetOf(VertexStruct_XYZ, position)); + s_declarations[VertexLayout_XYZ] = NewDeclaration(VertexInputRate::Vertex, { + { + VertexComponent_Position, + ComponentType_Float3, + 0 + }, + }); - NazaraAssert(declaration->GetStride() == sizeof(VertexStruct_XYZ), "Invalid stride for declaration VertexLayout_XYZ"); + NazaraAssert(s_declarations[VertexLayout_XYZ]->GetStride() == sizeof(VertexStruct_XYZ), "Invalid stride for declaration VertexLayout_XYZ"); // VertexLayout_XYZ_Color : VertexStruct_XYZ_Color - declaration = &s_declarations[VertexLayout_XYZ_Color]; - declaration->EnableComponent(VertexComponent_Position, ComponentType_Float3, NazaraOffsetOf(VertexStruct_XYZ_Color, position)); - declaration->EnableComponent(VertexComponent_Color, ComponentType_Color, NazaraOffsetOf(VertexStruct_XYZ_Color, color)); + s_declarations[VertexLayout_XYZ_Color] = NewDeclaration(VertexInputRate::Vertex, { + { + VertexComponent_Position, + ComponentType_Float3, + 0 + }, + { + VertexComponent_Color, + ComponentType_Color, + 0 + } + }); - NazaraAssert(declaration->GetStride() == sizeof(VertexStruct_XYZ_Color), "Invalid stride for declaration VertexLayout_XYZ_Color"); + NazaraAssert(s_declarations[VertexLayout_XYZ_Color]->GetStride() == sizeof(VertexStruct_XYZ_Color), "Invalid stride for declaration VertexLayout_XYZ_Color"); // VertexLayout_XYZ_Color_UV : VertexStruct_XYZ_Color_UV - declaration = &s_declarations[VertexLayout_XYZ_Color_UV]; - declaration->EnableComponent(VertexComponent_Position, ComponentType_Float3, NazaraOffsetOf(VertexStruct_XYZ_Color_UV, position)); - declaration->EnableComponent(VertexComponent_Color, ComponentType_Color, NazaraOffsetOf(VertexStruct_XYZ_Color_UV, color)); - declaration->EnableComponent(VertexComponent_TexCoord, ComponentType_Float2, NazaraOffsetOf(VertexStruct_XYZ_Color_UV, uv)); + s_declarations[VertexLayout_XYZ_Color_UV] = NewDeclaration(VertexInputRate::Vertex, { + { + VertexComponent_Position, + ComponentType_Float3, + 0 + }, + { + VertexComponent_Color, + ComponentType_Color, + 0 + }, + { + VertexComponent_TexCoord, + ComponentType_Float2, + 0 + }, + }); - NazaraAssert(declaration->GetStride() == sizeof(VertexStruct_XYZ_Color_UV), "Invalid stride for declaration VertexLayout_XYZ_Color_UV"); + NazaraAssert(s_declarations[VertexLayout_XYZ_Color_UV]->GetStride() == sizeof(VertexStruct_XYZ_Color_UV), "Invalid stride for declaration VertexLayout_XYZ_Color_UV"); // VertexLayout_XYZ_Normal : VertexStruct_XYZ_Normal - declaration = &s_declarations[VertexLayout_XYZ_Normal]; - declaration->EnableComponent(VertexComponent_Position, ComponentType_Float3, NazaraOffsetOf(VertexStruct_XYZ_Normal, position)); - declaration->EnableComponent(VertexComponent_Normal, ComponentType_Float3, NazaraOffsetOf(VertexStruct_XYZ_Normal, normal)); + s_declarations[VertexLayout_XYZ_Normal] = NewDeclaration(VertexInputRate::Vertex, { + { + VertexComponent_Position, + ComponentType_Float3, + 0 + }, + { + VertexComponent_Normal, + ComponentType_Float3, + 0 + } + }); - NazaraAssert(declaration->GetStride() == sizeof(VertexStruct_XYZ_Normal), "Invalid stride for declaration VertexLayout_XYZ_Normal"); + NazaraAssert(s_declarations[VertexLayout_XYZ_Normal]->GetStride() == sizeof(VertexStruct_XYZ_Normal), "Invalid stride for declaration VertexLayout_XYZ_Normal"); // VertexLayout_XYZ_Normal_UV : VertexStruct_XYZ_Normal_UV - declaration = &s_declarations[VertexLayout_XYZ_Normal_UV]; - declaration->EnableComponent(VertexComponent_Position, ComponentType_Float3, NazaraOffsetOf(VertexStruct_XYZ_Normal_UV, position)); - declaration->EnableComponent(VertexComponent_Normal, ComponentType_Float3, NazaraOffsetOf(VertexStruct_XYZ_Normal_UV, normal)); - declaration->EnableComponent(VertexComponent_TexCoord, ComponentType_Float2, NazaraOffsetOf(VertexStruct_XYZ_Normal_UV, uv)); + s_declarations[VertexLayout_XYZ_Normal_UV] = NewDeclaration(VertexInputRate::Vertex, { + { + VertexComponent_Position, + ComponentType_Float3, + 0 + }, + { + VertexComponent_Normal, + ComponentType_Float3, + 0 + }, + { + VertexComponent_TexCoord, + ComponentType_Float2, + 0 + } + }); - NazaraAssert(declaration->GetStride() == sizeof(VertexStruct_XYZ_Normal_UV), "Invalid stride for declaration VertexLayout_XYZ_Normal_UV"); + NazaraAssert(s_declarations[VertexLayout_XYZ_Normal_UV]->GetStride() == sizeof(VertexStruct_XYZ_Normal_UV), "Invalid stride for declaration VertexLayout_XYZ_Normal_UV"); // VertexLayout_XYZ_Normal_UV_Tangent : VertexStruct_XYZ_Normal_UV_Tangent - declaration = &s_declarations[VertexLayout_XYZ_Normal_UV_Tangent]; - declaration->EnableComponent(VertexComponent_Position, ComponentType_Float3, NazaraOffsetOf(VertexStruct_XYZ_Normal_UV_Tangent, position)); - declaration->EnableComponent(VertexComponent_Normal, ComponentType_Float3, NazaraOffsetOf(VertexStruct_XYZ_Normal_UV_Tangent, normal)); - declaration->EnableComponent(VertexComponent_TexCoord, ComponentType_Float2, NazaraOffsetOf(VertexStruct_XYZ_Normal_UV_Tangent, uv)); - declaration->EnableComponent(VertexComponent_Tangent, ComponentType_Float3, NazaraOffsetOf(VertexStruct_XYZ_Normal_UV_Tangent, tangent)); + s_declarations[VertexLayout_XYZ_Normal_UV_Tangent] = NewDeclaration(VertexInputRate::Vertex, { + { + VertexComponent_Position, + ComponentType_Float3, + 0 + }, + { + VertexComponent_Normal, + ComponentType_Float3, + 0 + }, + { + VertexComponent_TexCoord, + ComponentType_Float2, + 0 + }, + { + VertexComponent_Tangent, + ComponentType_Float3, + 0 + } + }); - NazaraAssert(declaration->GetStride() == sizeof(VertexStruct_XYZ_Normal_UV_Tangent), "Invalid stride for declaration VertexLayout_XYZ_Normal_UV_Tangent"); + NazaraAssert(s_declarations[VertexLayout_XYZ_Normal_UV_Tangent]->GetStride() == sizeof(VertexStruct_XYZ_Normal_UV_Tangent), "Invalid stride for declaration VertexLayout_XYZ_Normal_UV_Tangent"); // VertexLayout_XYZ_Normal_UV_Tangent_Skinning : VertexStruct_XYZ_Normal_UV_Tangent_Skinning - declaration = &s_declarations[VertexLayout_XYZ_Normal_UV_Tangent_Skinning]; - declaration->EnableComponent(VertexComponent_Position, ComponentType_Float3, NazaraOffsetOf(VertexStruct_XYZ_Normal_UV_Tangent_Skinning, position)); - declaration->EnableComponent(VertexComponent_Normal, ComponentType_Float3, NazaraOffsetOf(VertexStruct_XYZ_Normal_UV_Tangent_Skinning, normal)); - declaration->EnableComponent(VertexComponent_TexCoord, ComponentType_Float2, NazaraOffsetOf(VertexStruct_XYZ_Normal_UV_Tangent_Skinning, uv)); - declaration->EnableComponent(VertexComponent_Tangent, ComponentType_Float3, NazaraOffsetOf(VertexStruct_XYZ_Normal_UV_Tangent_Skinning, tangent)); - declaration->EnableComponent(VertexComponent_Unused, ComponentType_Int1, NazaraOffsetOf(VertexStruct_XYZ_Normal_UV_Tangent_Skinning, weightCount)); - declaration->EnableComponent(VertexComponent_Userdata0, ComponentType_Float4, NazaraOffsetOf(VertexStruct_XYZ_Normal_UV_Tangent_Skinning, weights)); - declaration->EnableComponent(VertexComponent_Userdata1, ComponentType_Int4, NazaraOffsetOf(VertexStruct_XYZ_Normal_UV_Tangent_Skinning, jointIndexes)); + s_declarations[VertexLayout_XYZ_Normal_UV_Tangent_Skinning] = NewDeclaration(VertexInputRate::Vertex, { + { + VertexComponent_Position, + ComponentType_Float3, + 0 + }, + { + VertexComponent_Normal, + ComponentType_Float3, + 0 + }, + { + VertexComponent_TexCoord, + ComponentType_Float2, + 0 + }, + { + VertexComponent_Tangent, + ComponentType_Float3, + 0 + }, + { + VertexComponent_Userdata, + ComponentType_Int1, + 0 // Weight count + }, + { + VertexComponent_Userdata, + ComponentType_Float4, + 1 // Weights + }, + { + VertexComponent_Userdata, + ComponentType_Int4, + 2 // Joint indexes + }, + }); - NazaraAssert(declaration->GetStride() == sizeof(VertexStruct_XYZ_Normal_UV_Tangent_Skinning), "Invalid stride for declaration VertexLayout_XYZ_Normal_UV_Tangent_Skinning"); + NazaraAssert(s_declarations[VertexLayout_XYZ_Normal_UV_Tangent_Skinning]->GetStride() == sizeof(VertexStruct_XYZ_Normal_UV_Tangent_Skinning), "Invalid stride for declaration VertexLayout_XYZ_Normal_UV_Tangent_Skinning"); // VertexLayout_XYZ_UV : VertexStruct_XYZ_UV - declaration = &s_declarations[VertexLayout_XYZ_UV]; - declaration->EnableComponent(VertexComponent_Position, ComponentType_Float3, NazaraOffsetOf(VertexStruct_XYZ_UV, position)); - declaration->EnableComponent(VertexComponent_TexCoord, ComponentType_Float2, NazaraOffsetOf(VertexStruct_XYZ_UV, uv)); + s_declarations[VertexLayout_XYZ_UV] = NewDeclaration(VertexInputRate::Vertex, { + { + VertexComponent_Position, + ComponentType_Float3, + 0 + }, + { + VertexComponent_TexCoord, + ComponentType_Float2, + 0 + } + }); - NazaraAssert(declaration->GetStride() == sizeof(VertexStruct_XYZ_UV), "Invalid stride for declaration VertexLayout_XYZ_UV"); + NazaraAssert(s_declarations[VertexLayout_XYZ_UV]->GetStride() == sizeof(VertexStruct_XYZ_UV), "Invalid stride for declaration VertexLayout_XYZ_UV"); // VertexLayout_Matrix4 : Matrix4f - declaration = &s_declarations[VertexLayout_Matrix4]; - declaration->EnableComponent(VertexComponent_InstanceData0, ComponentType_Float4, NazaraOffsetOf(Matrix4f, m11)); - declaration->EnableComponent(VertexComponent_InstanceData1, ComponentType_Float4, NazaraOffsetOf(Matrix4f, m21)); - declaration->EnableComponent(VertexComponent_InstanceData2, ComponentType_Float4, NazaraOffsetOf(Matrix4f, m31)); - declaration->EnableComponent(VertexComponent_InstanceData3, ComponentType_Float4, NazaraOffsetOf(Matrix4f, m41)); + s_declarations[VertexLayout_Matrix4] = NewDeclaration(VertexInputRate::Vertex, { + { + VertexComponent_Userdata, + ComponentType_Float4, + 0 + }, + { + VertexComponent_Userdata, + ComponentType_Float4, + 1 + }, + { + VertexComponent_Userdata, + ComponentType_Float4, + 2 + }, + { + VertexComponent_Userdata, + ComponentType_Float4, + 3 + } + }); - NazaraAssert(declaration->GetStride() == sizeof(Matrix4f), "Invalid stride for declaration VertexLayout_Matrix4");*/ + NazaraAssert(s_declarations[VertexLayout_Matrix4]->GetStride() == sizeof(Matrix4f), "Invalid stride for declaration VertexLayout_Matrix4"); } catch (const std::exception& e) { diff --git a/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp b/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp index 99a185107..fca5229c1 100644 --- a/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp +++ b/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include namespace Nz @@ -21,7 +22,7 @@ namespace Nz { std::vector colorBlendStates; - VkPipelineColorBlendAttachmentState colorBlendState = colorBlendStates.emplace_back(); + VkPipelineColorBlendAttachmentState& colorBlendState = colorBlendStates.emplace_back(); colorBlendState.blendEnable = pipelineInfo.blending; colorBlendState.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT; //< TODO @@ -94,6 +95,16 @@ namespace Nz return createInfo; } + VkPipelineMultisampleStateCreateInfo VulkanRenderPipeline::BuildMultisampleInfo(const RenderPipelineInfo& pipelineInfo) + { + VkPipelineMultisampleStateCreateInfo createInfo = {}; + createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; + createInfo.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; + createInfo.minSampleShading = 1.0f; //< TODO: Remove + + return createInfo; + } + VkPipelineRasterizationStateCreateInfo VulkanRenderPipeline::BuildRasterizationInfo(const RenderPipelineInfo& pipelineInfo) { VkPipelineRasterizationStateCreateInfo createInfo = {}; @@ -149,6 +160,58 @@ namespace Nz return shaderStageCreateInfos; } + std::vector VulkanRenderPipeline::BuildVertexAttributeDescription(const RenderPipelineInfo& pipelineInfo) + { + std::vector vertexAttributes; + + std::uint32_t locationIndex = 0; + + for (const auto& bufferData : pipelineInfo.vertexBuffers) + { + std::uint32_t binding = std::uint32_t(bufferData.binding); + + for (const auto& componentInfo : *bufferData.declaration) + { + auto& bufferAttribute = vertexAttributes.emplace_back(); + bufferAttribute.binding = binding; + bufferAttribute.location = locationIndex++; + bufferAttribute.offset = std::uint32_t(componentInfo.offset); + bufferAttribute.format = ToVulkan(componentInfo.type); + } + } + + return vertexAttributes; + } + + std::vector VulkanRenderPipeline::BuildVertexBindingDescription(const RenderPipelineInfo& pipelineInfo) + { + std::vector vertexBindings; + + for (const auto& bufferData : pipelineInfo.vertexBuffers) + { + auto& bufferBinding = vertexBindings.emplace_back(); + bufferBinding.binding = std::uint32_t(bufferData.binding); + bufferBinding.stride = std::uint32_t(bufferData.declaration->GetStride()); + bufferBinding.inputRate = ToVulkan(bufferData.declaration->GetInputRate()); + } + + return vertexBindings; + } + + VkPipelineVertexInputStateCreateInfo VulkanRenderPipeline::BuildVertexInputInfo(const RenderPipelineInfo& pipelineInfo, const std::vector& vertexAttributes, const std::vector& bindingDescriptions) + { + VkPipelineVertexInputStateCreateInfo createInfo = {}; + createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; + + createInfo.vertexAttributeDescriptionCount = std::uint32_t(vertexAttributes.size()); + createInfo.pVertexAttributeDescriptions = vertexAttributes.data(); + + createInfo.vertexBindingDescriptionCount = std::uint32_t(bindingDescriptions.size()); + createInfo.pVertexBindingDescriptions = bindingDescriptions.data(); + + return createInfo; + } + auto VulkanRenderPipeline::BuildCreateInfo(const RenderPipelineInfo& pipelineInfo) -> CreateInfo { CreateInfo createInfo = {}; @@ -157,20 +220,30 @@ namespace Nz createInfo.colorBlendAttachmentState = BuildColorBlendAttachmentStateList(pipelineInfo); createInfo.dynamicStates = BuildDynamicStateList(pipelineInfo); createInfo.shaderStages = BuildShaderStageInfo(pipelineInfo); + createInfo.vertexAttributesDescription = BuildVertexAttributeDescription(pipelineInfo); + createInfo.vertexBindingDescription = BuildVertexBindingDescription(pipelineInfo); createInfo.stateData->colorBlendState = BuildColorBlendInfo(pipelineInfo, createInfo.colorBlendAttachmentState); createInfo.stateData->depthStencilState = BuildDepthStencilInfo(pipelineInfo); createInfo.stateData->dynamicState = BuildDynamicStateInfo(pipelineInfo, createInfo.dynamicStates); createInfo.stateData->inputAssemblyState = BuildInputAssemblyInfo(pipelineInfo); + createInfo.stateData->multiSampleState = BuildMultisampleInfo(pipelineInfo); createInfo.stateData->rasterizationState = BuildRasterizationInfo(pipelineInfo); createInfo.stateData->viewportState = BuildViewportInfo(pipelineInfo); + createInfo.stateData->vertexInputState = BuildVertexInputInfo(pipelineInfo, createInfo.vertexAttributesDescription, createInfo.vertexBindingDescription); createInfo.pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; createInfo.pipelineInfo.stageCount = std::uint32_t(createInfo.shaderStages.size()); createInfo.pipelineInfo.pStages = createInfo.shaderStages.data(); - createInfo.pipelineInfo.pColorBlendState = createInfo.colorBlendAttachmentState.data(); - createInfo.pipelineInfo. + createInfo.pipelineInfo.pColorBlendState = &createInfo.stateData->colorBlendState; + createInfo.pipelineInfo.pDepthStencilState = &createInfo.stateData->depthStencilState; + createInfo.pipelineInfo.pDynamicState = &createInfo.stateData->dynamicState; + createInfo.pipelineInfo.pInputAssemblyState = &createInfo.stateData->inputAssemblyState; + createInfo.pipelineInfo.pMultisampleState = &createInfo.stateData->multiSampleState; + createInfo.pipelineInfo.pRasterizationState = &createInfo.stateData->rasterizationState; + createInfo.pipelineInfo.pVertexInputState = &createInfo.stateData->vertexInputState; + createInfo.pipelineInfo.pViewportState = &createInfo.stateData->viewportState; return createInfo; } From 7ba9a33d35f82fc832b441d0d9d98bf230149470 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 4 Mar 2020 18:50:41 +0100 Subject: [PATCH 099/316] Add Fence objects (+ use them for sync) --- examples/VulkanTest/main.cpp | 12 +++- include/Nazara/VulkanRenderer/Wrapper.hpp | 1 + .../VulkanRenderer/Wrapper/CommandBuffer.hpp | 2 +- .../Nazara/VulkanRenderer/Wrapper/Device.hpp | 2 + .../Nazara/VulkanRenderer/Wrapper/Fence.hpp | 47 +++++++++++++ .../Nazara/VulkanRenderer/Wrapper/Fence.inl | 68 +++++++++++++++++++ src/Nazara/VulkanRenderer/Wrapper/Device.cpp | 2 + 7 files changed, 131 insertions(+), 3 deletions(-) create mode 100644 include/Nazara/VulkanRenderer/Wrapper/Fence.hpp create mode 100644 include/Nazara/VulkanRenderer/Wrapper/Fence.inl diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index 811c8a21f..b1991c6e1 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -274,6 +274,11 @@ int main() Nz::UInt32 imageCount = vulkanWindow.GetFramebufferCount(); std::vector renderCmds = cmdPool.AllocateCommandBuffers(imageCount, VK_COMMAND_BUFFER_LEVEL_PRIMARY); + + std::vector fences(imageCount); + for (auto& fence : fences) + fence.Create(vulkanDevice.shared_from_this()); + for (Nz::UInt32 i = 0; i < imageCount; ++i) { Nz::Vk::CommandBuffer& renderCmd = renderCmds[i]; @@ -317,7 +322,7 @@ int main() 1U }; - renderCmd.Begin(VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT); + renderCmd.Begin(); vulkanWindow.BuildPreRenderCommands(i, renderCmd); @@ -426,6 +431,9 @@ int main() return EXIT_FAILURE; } + fences[imageIndex].Wait(); + fences[imageIndex].Reset(); + VkCommandBuffer renderCmdBuffer = renderCmds[imageIndex]; VkSemaphore waitSemaphore = vulkanWindow.GetRenderSemaphore(); @@ -442,7 +450,7 @@ int main() nullptr // const VkSemaphore *pSignalSemaphores }; - if (!graphicsQueue.Submit(submit_info)) + if (!graphicsQueue.Submit(submit_info, fences[imageIndex])) return false; vulkanWindow.Present(imageIndex); diff --git a/include/Nazara/VulkanRenderer/Wrapper.hpp b/include/Nazara/VulkanRenderer/Wrapper.hpp index 651a8e04f..84f8cd991 100644 --- a/include/Nazara/VulkanRenderer/Wrapper.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper.hpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp index aad18cee7..c5164ebf5 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp @@ -27,7 +27,7 @@ namespace Nz inline ~CommandBuffer(); inline bool Begin(const VkCommandBufferBeginInfo& info); - inline bool Begin(VkCommandBufferUsageFlags flags); + inline bool Begin(VkCommandBufferUsageFlags flags = 0); 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); diff --git a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp index cbf50d052..f38885fb6 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp @@ -119,6 +119,7 @@ namespace Nz NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateDescriptorPool); NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateDescriptorSetLayout); NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateEvent); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateFence); NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateFramebuffer); NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateGraphicsPipelines); NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateImage); @@ -136,6 +137,7 @@ namespace Nz NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyDescriptorSetLayout); NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyDevice); NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyEvent); + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyFence); NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyFramebuffer); NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyImage); NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyImageView); diff --git a/include/Nazara/VulkanRenderer/Wrapper/Fence.hpp b/include/Nazara/VulkanRenderer/Wrapper/Fence.hpp new file mode 100644 index 000000000..480e5524e --- /dev/null +++ b/include/Nazara/VulkanRenderer/Wrapper/Fence.hpp @@ -0,0 +1,47 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VKFENCE_HPP +#define NAZARA_VULKANRENDERER_VKFENCE_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class Fence : public DeviceObject + { + friend DeviceObject; + + public: + Fence() = default; + Fence(const Fence&) = delete; + Fence(Fence&&) = default; + ~Fence() = default; + + using DeviceObject::Create; + inline bool Create(DeviceHandle device, VkFenceCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + + inline bool Reset(); + + inline bool Wait(); + inline bool Wait(UInt64 timeout, bool* didTimeout = nullptr); + + Fence& operator=(const Fence&) = delete; + Fence& operator=(Fence&&) = delete; + + private: + static inline VkResult CreateHelper(const DeviceHandle& device, const VkFenceCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkFence* handle); + static inline void DestroyHelper(const DeviceHandle& device, VkFence handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_VULKANRENDERER_VKFENCE_HPP diff --git a/include/Nazara/VulkanRenderer/Wrapper/Fence.inl b/include/Nazara/VulkanRenderer/Wrapper/Fence.inl new file mode 100644 index 000000000..c67bfc6e5 --- /dev/null +++ b/include/Nazara/VulkanRenderer/Wrapper/Fence.inl @@ -0,0 +1,68 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + namespace Vk + { + inline bool Fence::Create(DeviceHandle device, VkFenceCreateFlags flags, const VkAllocationCallbacks* allocator) + { + VkFenceCreateInfo createInfo = + { + VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, + nullptr, + flags + }; + + return Create(std::move(device), createInfo, allocator); + } + + inline bool Fence::Reset() + { + m_lastErrorCode = m_device->vkResetFences(*m_device, 1U, &m_handle); + if (m_lastErrorCode != VK_SUCCESS) + { + NazaraError("Failed to reset fence: " + TranslateVulkanError(m_lastErrorCode)); + return false; + } + + return true; + } + + inline bool Fence::Wait() + { + return Wait(std::numeric_limits::max()); + } + + inline bool Fence::Wait(UInt64 timeout, bool* didTimeout) + { + m_lastErrorCode = m_device->vkWaitForFences(*m_device, 1U, &m_handle, VK_TRUE, timeout); + if (m_lastErrorCode != VK_SUCCESS && m_lastErrorCode != VK_TIMEOUT) + { + NazaraError("Failed to wait for fence: " + TranslateVulkanError(m_lastErrorCode)); + return false; + } + + if (didTimeout) + *didTimeout = (m_lastErrorCode == VK_TIMEOUT); + + return true; + } + + inline VkResult Fence::CreateHelper(const DeviceHandle& device, const VkFenceCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkFence* handle) + { + return device->vkCreateFence(*device, createInfo, allocator, handle); + } + + inline void Fence::DestroyHelper(const DeviceHandle& device, VkFence handle, const VkAllocationCallbacks* allocator) + { + return device->vkDestroyFence(*device, handle, allocator); + } + } +} + +#include diff --git a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp index 26e6c949e..32a54641c 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp @@ -107,6 +107,7 @@ namespace Nz NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateDescriptorPool); NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateDescriptorSetLayout); NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateEvent); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateFence); NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateFramebuffer); NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateGraphicsPipelines); NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateImage); @@ -124,6 +125,7 @@ namespace Nz NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyDescriptorSetLayout); NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyDevice); NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyEvent); + NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyFence); NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyFramebuffer); NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyImage); NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyImageView); From 9f4037e46184758e3f175da50591a916f785b81c Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 4 Mar 2020 18:55:37 +0100 Subject: [PATCH 100/316] Reverse front face --- src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp b/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp index fca5229c1..1e2d8067d 100644 --- a/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp +++ b/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp @@ -111,7 +111,7 @@ namespace Nz createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; createInfo.polygonMode = ToVulkan(pipelineInfo.faceFilling); createInfo.cullMode = ToVulkan(pipelineInfo.cullingSide); - createInfo.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; //< TODO + createInfo.frontFace = VK_FRONT_FACE_CLOCKWISE; //< TODO createInfo.lineWidth = pipelineInfo.lineWidth; return createInfo; From 771355ec875d845df5be19dd846cb7cf7af02ae9 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 4 Mar 2020 18:55:52 +0100 Subject: [PATCH 101/316] Switch to Dr Freak model --- examples/VulkanTest/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index b1991c6e1..79023df89 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -129,7 +129,7 @@ int main() Nz::VulkanDevice& vulkanDevice = vulkanWindow.GetDevice(); - Nz::MeshRef drfreak = Nz::Mesh::LoadFromFile("resources/OILTANK1.md2", meshParams); + Nz::MeshRef drfreak = Nz::Mesh::LoadFromFile("resources/drfreak.md2", meshParams); if (!drfreak) { @@ -223,6 +223,7 @@ int main() descriptorSet.WriteUniformDescriptor(0, uniformBufferImpl->GetBufferHandle(), 0, uniformSize); Nz::RenderPipelineInfo pipelineInfo; + pipelineInfo.depthBuffer = true; pipelineInfo.shaderStages.emplace_back(fragmentShader); pipelineInfo.shaderStages.emplace_back(vertexShader); From 9515f1c8070a0c89f4c527b7c9a086f311109882 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 4 Mar 2020 20:13:37 +0100 Subject: [PATCH 102/316] Improve synchronization based on vulkan-tutorial https://vulkan-tutorial.com/Drawing_a_triangle/Drawing/Rendering_and_presentation --- examples/VulkanTest/main.cpp | 65 +++++++++++-------- .../Nazara/VulkanRenderer/VkRenderTarget.hpp | 14 ++-- .../Nazara/VulkanRenderer/VkRenderTarget.inl | 16 +++++ .../Nazara/VulkanRenderer/VkRenderWindow.hpp | 7 +- .../Nazara/VulkanRenderer/VkRenderWindow.inl | 4 +- .../Nazara/VulkanRenderer/Wrapper/Queue.hpp | 6 +- .../Nazara/VulkanRenderer/Wrapper/Queue.inl | 30 +++++++-- src/Nazara/VulkanRenderer/VkRenderTarget.cpp | 1 - src/Nazara/VulkanRenderer/VkRenderWindow.cpp | 30 +-------- 9 files changed, 94 insertions(+), 79 deletions(-) create mode 100644 include/Nazara/VulkanRenderer/VkRenderTarget.inl diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index 79023df89..617584ffd 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -276,10 +276,6 @@ int main() Nz::UInt32 imageCount = vulkanWindow.GetFramebufferCount(); std::vector renderCmds = cmdPool.AllocateCommandBuffers(imageCount, VK_COMMAND_BUFFER_LEVEL_PRIMARY); - std::vector fences(imageCount); - for (auto& fence : fences) - fence.Create(vulkanDevice.shared_from_this()); - for (Nz::UInt32 i = 0; i < imageCount; ++i) { Nz::Vk::CommandBuffer& renderCmd = renderCmds[i]; @@ -325,8 +321,6 @@ int main() renderCmd.Begin(); - vulkanWindow.BuildPreRenderCommands(i, renderCmd); - renderCmd.BeginRenderPass(render_pass_begin_info); //renderCmd.ClearAttachment(clearAttachment, clearRect); //renderCmd.ClearAttachment(clearAttachmentDepth, clearRect); @@ -339,8 +333,6 @@ int main() renderCmd.DrawIndexed(drfreakIB->GetIndexCount()); renderCmd.EndRenderPass(); - vulkanWindow.BuildPostRenderCommands(i, renderCmd); - if (!renderCmd.End()) { NazaraError("Failed to specify render cmd"); @@ -355,6 +347,31 @@ int main() window.EnableEventPolling(true); + struct ImageSync + { + Nz::Vk::Fence inflightFence; + Nz::Vk::Semaphore imageAvailableSemaphore; + Nz::Vk::Semaphore renderFinishedSemaphore; + }; + + const std::size_t MaxConcurrentImage = imageCount; + + std::vector frameSync(MaxConcurrentImage); + for (ImageSync& syncData : frameSync) + { + syncData.imageAvailableSemaphore.Create(vulkanDevice.shared_from_this()); + syncData.renderFinishedSemaphore.Create(vulkanDevice.shared_from_this()); + + syncData.inflightFence.Create(vulkanDevice.shared_from_this(), VK_FENCE_CREATE_SIGNALED_BIT); + } + + /*std::vector> imageFences; + for (std::size_t i = 0; i < imageCount; ++i) + imageFences.emplace_back(sync[i % sync.size()].inflightFence);*/ + std::vector inflightFences(imageCount, nullptr); + + std::size_t currentFrame = 0; + Nz::Clock updateClock; Nz::Clock secondClock; unsigned int fps = 0; @@ -425,36 +442,26 @@ int main() } } + ImageSync& syncPrimitives = frameSync[currentFrame]; + syncPrimitives.inflightFence.Wait(); + Nz::UInt32 imageIndex; - if (!vulkanWindow.Acquire(&imageIndex)) + if (!vulkanWindow.Acquire(&imageIndex, syncPrimitives.imageAvailableSemaphore)) { std::cout << "Failed to acquire next image" << std::endl; return EXIT_FAILURE; } - fences[imageIndex].Wait(); - fences[imageIndex].Reset(); + if (inflightFences[imageIndex]) + inflightFences[imageIndex]->Wait(); - VkCommandBuffer renderCmdBuffer = renderCmds[imageIndex]; - VkSemaphore waitSemaphore = vulkanWindow.GetRenderSemaphore(); + inflightFences[imageIndex] = &syncPrimitives.inflightFence; + inflightFences[imageIndex]->Reset(); - VkPipelineStageFlags wait_dst_stage_mask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; - VkSubmitInfo submit_info = { - VK_STRUCTURE_TYPE_SUBMIT_INFO, // VkStructureType sType - nullptr, // const void *pNext - 1U, // uint32_t waitSemaphoreCount - &waitSemaphore, // const VkSemaphore *pWaitSemaphores - &wait_dst_stage_mask, // const VkPipelineStageFlags *pWaitDstStageMask; - 1, // uint32_t commandBufferCount - &renderCmdBuffer, // const VkCommandBuffer *pCommandBuffers - 0, // uint32_t signalSemaphoreCount - nullptr // const VkSemaphore *pSignalSemaphores - }; - - if (!graphicsQueue.Submit(submit_info, fences[imageIndex])) + if (!graphicsQueue.Submit(renderCmds[imageIndex], syncPrimitives.imageAvailableSemaphore, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, syncPrimitives.renderFinishedSemaphore, syncPrimitives.inflightFence)) return false; - vulkanWindow.Present(imageIndex); + vulkanWindow.Present(imageIndex, syncPrimitives.renderFinishedSemaphore); // On incrémente le compteur de FPS improvisé fps++; @@ -477,6 +484,8 @@ int main() // Et on relance l'horloge pour refaire ça dans une seconde secondClock.Restart(); } + + currentFrame = (currentFrame + 1) % imageCount; } instance.vkDestroyDebugReportCallbackEXT(instance, callback, nullptr); diff --git a/include/Nazara/VulkanRenderer/VkRenderTarget.hpp b/include/Nazara/VulkanRenderer/VkRenderTarget.hpp index f997dda00..c98580e67 100644 --- a/include/Nazara/VulkanRenderer/VkRenderTarget.hpp +++ b/include/Nazara/VulkanRenderer/VkRenderTarget.hpp @@ -26,19 +26,14 @@ namespace Nz VkRenderTarget(VkRenderTarget&&) = delete; ///TOOD? virtual ~VkRenderTarget(); - virtual bool Acquire(UInt32* imageIndex) const = 0; - - virtual void BuildPreRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) = 0; - virtual void BuildPostRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) = 0; + virtual bool Acquire(UInt32* imageIndex, VkSemaphore signalSemaphore = VK_NULL_HANDLE, VkFence signalFence = VK_NULL_HANDLE) const = 0; virtual const Vk::Framebuffer& GetFrameBuffer(UInt32 imageIndex) const = 0; virtual UInt32 GetFramebufferCount() const = 0; - const Vk::RenderPass& GetRenderPass() const { return m_renderPass; } + inline const Vk::RenderPass& GetRenderPass() const; - const Vk::Semaphore& GetRenderSemaphore() const { return m_imageReadySemaphore; } - - virtual void Present(UInt32 imageIndex) = 0; + virtual void Present(UInt32 imageIndex, VkSemaphore waitSemaphore = VK_NULL_HANDLE) = 0; VkRenderTarget& operator=(const VkRenderTarget&) = delete; VkRenderTarget& operator=(VkRenderTarget&&) = delete; ///TOOD? @@ -51,8 +46,9 @@ namespace Nz void Destroy(); Vk::RenderPass m_renderPass; - Vk::Semaphore m_imageReadySemaphore; }; } +#include + #endif // NAZARA_VULKANRENDERER_RENDERTARGET_HPP diff --git a/include/Nazara/VulkanRenderer/VkRenderTarget.inl b/include/Nazara/VulkanRenderer/VkRenderTarget.inl new file mode 100644 index 000000000..1fd0550bc --- /dev/null +++ b/include/Nazara/VulkanRenderer/VkRenderTarget.inl @@ -0,0 +1,16 @@ +// Copyright (C) 2016 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline const Vk::RenderPass& VkRenderTarget::GetRenderPass() const + { + return m_renderPass; + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp index 1ed643149..e972b2c86 100644 --- a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp +++ b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp @@ -37,10 +37,7 @@ namespace Nz VkRenderWindow(VkRenderWindow&&) = delete; ///TODO virtual ~VkRenderWindow(); - bool Acquire(UInt32* index) const override; - - void BuildPreRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) override; - void BuildPostRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) override; + bool Acquire(UInt32* index, VkSemaphore signalSemaphore = VK_NULL_HANDLE, VkFence signalFence = VK_NULL_HANDLE) const override; bool Create(RendererImpl* renderer, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) override; @@ -53,7 +50,7 @@ namespace Nz std::shared_ptr GetRenderDevice() override; - void Present(UInt32 imageIndex) override; + void Present(UInt32 imageIndex, VkSemaphore waitSemaphore = VK_NULL_HANDLE) override; VkRenderWindow& operator=(const VkRenderWindow&) = delete; VkRenderWindow& operator=(VkRenderWindow&&) = delete; ///TODO diff --git a/include/Nazara/VulkanRenderer/VkRenderWindow.inl b/include/Nazara/VulkanRenderer/VkRenderWindow.inl index 11310e89b..8c4737578 100644 --- a/include/Nazara/VulkanRenderer/VkRenderWindow.inl +++ b/include/Nazara/VulkanRenderer/VkRenderWindow.inl @@ -42,11 +42,11 @@ namespace Nz return m_device; } - inline void VkRenderWindow::Present(UInt32 imageIndex) + inline void VkRenderWindow::Present(UInt32 imageIndex, VkSemaphore waitSemaphore) { NazaraAssert(imageIndex < m_frameBuffers.size(), "Invalid image index"); - m_presentQueue.Present(m_swapchain, imageIndex); + m_presentQueue.Present(m_swapchain, imageIndex, waitSemaphore); } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/Queue.hpp b/include/Nazara/VulkanRenderer/Wrapper/Queue.hpp index 7b3e0436b..a4129e4d0 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Queue.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Queue.hpp @@ -30,8 +30,10 @@ namespace Nz inline bool Present(const VkPresentInfoKHR& presentInfo) const; inline bool Present(VkSwapchainKHR swapchain, UInt32 imageIndex, VkSemaphore waitSemaphore = VK_NULL_HANDLE) const; - inline bool Submit(const VkSubmitInfo& submit, VkFence fence = VK_NULL_HANDLE) const; - inline bool Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence fence = VK_NULL_HANDLE) const; + inline bool Submit(VkCommandBuffer commandBuffer, VkSemaphore waitSemaphore, VkPipelineStageFlags waitStage, VkSemaphore signalSemaphore, VkFence signalFence = VK_NULL_HANDLE) const; + inline bool Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, VkSemaphore waitSemaphore, VkPipelineStageFlags waitStage, VkSemaphore signalSemaphore, VkFence signalFence = VK_NULL_HANDLE) const; + inline bool Submit(const VkSubmitInfo& submit, VkFence signalFence = VK_NULL_HANDLE) const; + inline bool Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence signalFence = VK_NULL_HANDLE) const; inline bool WaitIdle() const; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Queue.inl b/include/Nazara/VulkanRenderer/Wrapper/Queue.inl index 63583e66e..dc8603465 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Queue.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Queue.inl @@ -76,14 +76,36 @@ namespace Nz return Present(presentInfo); } - inline bool Queue::Submit(const VkSubmitInfo& submit, VkFence fence) const + inline bool Queue::Submit(VkCommandBuffer commandBuffer, VkSemaphore waitSemaphore, VkPipelineStageFlags waitStage, VkSemaphore signalSemaphore, VkFence signalFence) const { - return Submit(1, &submit, fence); + return Submit(1U, &commandBuffer, waitSemaphore, waitStage, signalSemaphore, signalFence); } - inline bool Queue::Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence fence) const + inline bool Queue::Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, VkSemaphore waitSemaphore, VkPipelineStageFlags waitStage, VkSemaphore signalSemaphore, VkFence signalFence) const { - m_lastErrorCode = m_device->vkQueueSubmit(m_handle, submitCount, submits, fence); + VkSubmitInfo submitInfo = { + VK_STRUCTURE_TYPE_SUBMIT_INFO, + nullptr, + (waitSemaphore) ? 1U : 0U, + &waitSemaphore, + &waitStage, + commandBufferCount, + commandBuffers, + (signalSemaphore) ? 1U : 0U, + &signalSemaphore + }; + + return Submit(submitInfo, signalFence); + } + + inline bool Queue::Submit(const VkSubmitInfo& submit, VkFence signalFence) const + { + return Submit(1, &submit, signalFence); + } + + inline bool Queue::Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence signalFence) const + { + m_lastErrorCode = m_device->vkQueueSubmit(m_handle, submitCount, submits, signalFence); if (m_lastErrorCode != VkResult::VK_SUCCESS) { NazaraError("Failed to submit queue: " + TranslateVulkanError(m_lastErrorCode)); diff --git a/src/Nazara/VulkanRenderer/VkRenderTarget.cpp b/src/Nazara/VulkanRenderer/VkRenderTarget.cpp index 27e1f5ff1..a553a2c1e 100644 --- a/src/Nazara/VulkanRenderer/VkRenderTarget.cpp +++ b/src/Nazara/VulkanRenderer/VkRenderTarget.cpp @@ -15,6 +15,5 @@ namespace Nz void VkRenderTarget::Destroy() { m_renderPass.Destroy(); - m_imageReadySemaphore.Destroy(); } } diff --git a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp index f1822b227..6edaa6649 100644 --- a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp +++ b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp @@ -32,9 +32,9 @@ namespace Nz VkRenderTarget::Destroy(); } - bool VkRenderWindow::Acquire(UInt32* imageIndex) const + bool VkRenderWindow::Acquire(UInt32* imageIndex, VkSemaphore signalSemaphore, VkFence signalFence) const { - if (!m_swapchain.AcquireNextImage(std::numeric_limits::max(), m_imageReadySemaphore, VK_NULL_HANDLE, imageIndex)) + if (!m_swapchain.AcquireNextImage(std::numeric_limits::max(), signalSemaphore, signalFence, imageIndex)) { NazaraError("Failed to acquire next image"); return false; @@ -43,30 +43,6 @@ namespace Nz return true; } - void VkRenderWindow::BuildPreRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) - { - //commandBuffer.SetImageLayout(m_swapchain.GetBuffer(imageIndex).image, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); - - // Temporary - /*if (m_depthStencilFormat != VK_FORMAT_MAX_ENUM) - { - VkImageSubresourceRange imageRange = { - VK_IMAGE_ASPECT_DEPTH_BIT, // VkImageAspectFlags aspectMask - 0, // uint32_t baseMipLevel - 1, // uint32_t levelCount - 0, // uint32_t baseArrayLayer - 1 // uint32_t layerCount - }; - - commandBuffer.SetImageLayout(m_depthBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, imageRange); - }*/ - } - - void VkRenderWindow::BuildPostRenderCommands(UInt32 imageIndex, Vk::CommandBuffer& commandBuffer) - { - //commandBuffer.SetImageLayout(m_swapchain.GetBuffer(imageIndex).image, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR); - } - bool VkRenderWindow::Create(RendererImpl* renderer, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) { m_physicalDevice = Vulkan::GetPhysicalDevices()[0].device; @@ -194,8 +170,6 @@ namespace Nz } } - m_imageReadySemaphore.Create(m_device); - m_clock.Restart(); return true; From 74275292bf81b200aa5251c195870474acf8b353 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 5 Mar 2020 17:24:55 +0100 Subject: [PATCH 103/316] Some cleanup --- examples/VulkanTest/main.cpp | 23 ------------ include/Nazara/Renderer/Enums.hpp | 53 +++++++++++++++++++--------- src/Nazara/VulkanRenderer/Vulkan.cpp | 30 ++++++++++++---- 3 files changed, 61 insertions(+), 45 deletions(-) diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index 617584ffd..a60dd2f07 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -301,29 +301,9 @@ int main() clearValues.data() // const VkClearValue *pClearValues }; - VkClearAttachment clearAttachment = { - VK_IMAGE_ASPECT_COLOR_BIT, - 0U, - clearValues[0] - }; - - VkClearAttachment clearAttachmentDepth = { - VK_IMAGE_ASPECT_DEPTH_BIT, - 0U, - clearValues[1] - }; - - VkClearRect clearRect = { - renderArea, - 0U, - 1U - }; - renderCmd.Begin(); renderCmd.BeginRenderPass(render_pass_begin_info); - //renderCmd.ClearAttachment(clearAttachment, clearRect); - //renderCmd.ClearAttachment(clearAttachmentDepth, clearRect); renderCmd.BindIndexBuffer(indexBufferImpl->GetBufferHandle(), 0, VK_INDEX_TYPE_UINT16); renderCmd.BindVertexBuffer(0, vertexBufferImpl->GetBufferHandle(), 0); renderCmd.BindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, descriptorSet); @@ -365,9 +345,6 @@ int main() syncData.inflightFence.Create(vulkanDevice.shared_from_this(), VK_FENCE_CREATE_SIGNALED_BIT); } - /*std::vector> imageFences; - for (std::size_t i = 0; i < imageCount; ++i) - imageFences.emplace_back(sync[i % sync.size()].inflightFence);*/ std::vector inflightFences(imageCount, nullptr); std::size_t currentFrame = 0; diff --git a/include/Nazara/Renderer/Enums.hpp b/include/Nazara/Renderer/Enums.hpp index 3ea481e17..9a18d8dbf 100644 --- a/include/Nazara/Renderer/Enums.hpp +++ b/include/Nazara/Renderer/Enums.hpp @@ -7,31 +7,41 @@ #ifndef NAZARA_ENUMS_RENDERER_HPP #define NAZARA_ENUMS_RENDERER_HPP +#include + namespace Nz { - enum RenderAPI + enum class RenderAPI { - RenderAPI_Direct3D, ///< Microsoft Render API, only works on MS platforms - RenderAPI_Mantle, ///< AMD Render API, Vulkan predecessor, only works on AMD GPUs - RenderAPI_Metal, ///< Apple Render API, only works on OS X platforms - RenderAPI_OpenGL, ///< Khronos Render API, works on Web/Desktop/Mobile and some consoles - RenderAPI_Vulkan, ///< New Khronos Render API, made to replace OpenGL, works on desktop (Windows/Linux) and mobile (Android) + Direct3D, ///< Microsoft Render API, only works on MS platforms + Mantle, ///< AMD Render API, Vulkan predecessor, only works on AMD GPUs + Metal, ///< Apple Render API, only works on OS X platforms + OpenGL, ///< Khronos Render API, works on Web/Desktop/Mobile and some consoles + Vulkan, ///< New Khronos Render API, made to replace OpenGL, works on desktop (Windows/Linux) and mobile (Android), and Apple platform using MoltenVK - RenderAPI_Other, ///< RenderAPI not corresponding to an entry of the enum, or result of a failed query + Unknown, ///< RenderAPI not corresponding to an entry of the enum, or result of a failed query - RenderAPI_Max = RenderAPI_Other + Max = Unknown }; - enum RenderDeviceType + enum class RenderDeviceType { - RenderDeviceType_Integrated, ///< Hardware-accelerated chipset integrated to a CPU (ex: Intel Graphics HD 4000) - RenderDeviceType_Dedicated, ///< Hardware-accelerated GPU (ex: AMD R9 390) - RenderDeviceType_Software, ///< Software-renderer - RenderDeviceType_Virtual, ///< Proxy renderer relaying instructions to another unknown device + Integrated, ///< Hardware-accelerated chipset integrated to a CPU (ex: Intel Graphics HD 4000) + Dedicated, ///< Hardware-accelerated GPU (ex: AMD R9 390) + Software, ///< Software-renderer + Virtual, ///< Proxy renderer relaying instructions to another unknown device - RenderDeviceType_Unknown, ///< Device type not corresponding to an entry of the enum, or result of a failed query + Unknown, ///< Device type not corresponding to an entry of the enum, or result of a failed query - RenderDeviceType_Max = RenderDeviceType_Unknown + Max = Unknown + }; + + enum class ShaderBindingType + { + Texture, + UniformBuffer, + + Max = UniformBuffer }; enum class ShaderLanguage @@ -45,8 +55,19 @@ namespace Nz enum class ShaderStageType { Fragment, - Vertex + Vertex, + + Max = Vertex }; + + struct EnumAsFlags + { + static constexpr ShaderStageType max = ShaderStageType::Max; + }; + + using ShaderStageTypeFlags = Flags; + + constexpr ShaderStageTypeFlags ShaderStageType_All = ShaderStageType::Fragment | ShaderStageType::Vertex; } #endif // NAZARA_ENUMS_RENDERER_HPP diff --git a/src/Nazara/VulkanRenderer/Vulkan.cpp b/src/Nazara/VulkanRenderer/Vulkan.cpp index f45555110..c54a8a199 100644 --- a/src/Nazara/VulkanRenderer/Vulkan.cpp +++ b/src/Nazara/VulkanRenderer/Vulkan.cpp @@ -274,7 +274,7 @@ namespace Nz // Find a queue that supports graphics operations UInt32 graphicsQueueNodeIndex = UINT32_MAX; UInt32 presentQueueNodeIndex = UINT32_MAX; - UInt32 transfertQueueNodeFamily = UINT32_MAX; + UInt32 transferQueueNodeFamily = UINT32_MAX; for (UInt32 i = 0; i < queueFamilies.size(); i++) { bool supportPresentation = false; @@ -285,6 +285,7 @@ namespace Nz { if (supportPresentation) { + // Queue family support both graphics and presentation to our surface, choose it graphicsQueueNodeIndex = i; presentQueueNodeIndex = i; break; @@ -296,21 +297,38 @@ namespace Nz presentQueueNodeIndex = i; } + if (graphicsQueueNodeIndex == UINT32_MAX) + { + // A Vulkan device without graphics support may technically exists but I've yet to see one + NazaraError("Device does not support graphics operations"); + return {}; + } + + if (presentQueueNodeIndex == UINT32_MAX) + { + // On multi-GPU systems, it's very possible to have surfaces unsupported by some + NazaraError("Device cannot present this surface"); + return {}; + } + + // Search for a transfer queue (first one being different to the graphics one) for (UInt32 i = 0; i < queueFamilies.size(); i++) { - if (queueFamilies[i].queueFlags & (VK_QUEUE_COMPUTE_BIT | VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_TRANSFER_BIT)) //< Compute and graphics queue implicitly support transfer operations + // Transfer bit is not mandatory if compute and graphics bits are set (as they implicitly support transfer) + if (queueFamilies[i].queueFlags & (VK_QUEUE_COMPUTE_BIT | VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_TRANSFER_BIT)) { - transfertQueueNodeFamily = i; - if (transfertQueueNodeFamily != graphicsQueueNodeIndex) + transferQueueNodeFamily = i; + if (transferQueueNodeFamily != graphicsQueueNodeIndex) break; } } + assert(transferQueueNodeFamily != UINT32_MAX); std::array queuesFamilies = { { {graphicsQueueNodeIndex, 1.f}, {presentQueueNodeIndex, 1.f}, - {transfertQueueNodeFamily, 1.f} + {transferQueueNodeFamily, 1.f} } }; @@ -456,7 +474,7 @@ namespace Nz { const std::vector& queueFamilyInfo = devicePtr->GetEnabledQueues(); UInt32 presentableQueueFamilyIndex = UINT32_MAX; - for (Vk::Device::QueueFamilyInfo queueInfo : queueFamilyInfo) + for (const Vk::Device::QueueFamilyInfo& queueInfo : queueFamilyInfo) { bool supported = false; if (surface.GetSupportPresentation(gpu, queueInfo.familyIndex, &supported) && supported) From c23b6dfa01e74052a3e466b4d6e13ca1c85ac1a1 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 5 Mar 2020 17:27:26 +0100 Subject: [PATCH 104/316] Copyright year update I can't wait to see the conflicts this will cause --- include/Nazara/Audio/Algorithm.hpp | 2 +- include/Nazara/Audio/Algorithm.inl | 2 +- include/Nazara/Audio/Audio.hpp | 2 +- include/Nazara/Audio/ConfigCheck.hpp | 2 +- include/Nazara/Audio/Debug.hpp | 2 +- include/Nazara/Audio/DebugOff.hpp | 2 +- include/Nazara/Audio/Enums.hpp | 2 +- include/Nazara/Audio/Music.hpp | 2 +- include/Nazara/Audio/OpenAL.hpp | 2 +- include/Nazara/Audio/Sound.hpp | 2 +- include/Nazara/Audio/SoundBuffer.hpp | 2 +- include/Nazara/Audio/SoundBuffer.inl | 2 +- include/Nazara/Audio/SoundEmitter.hpp | 2 +- include/Nazara/Audio/SoundStream.hpp | 2 +- include/Nazara/Core/AbstractHash.hpp | 2 +- include/Nazara/Core/AbstractLogger.hpp | 2 +- include/Nazara/Core/Algorithm.hpp | 2 +- include/Nazara/Core/Algorithm.inl | 2 +- include/Nazara/Core/Bitset.hpp | 2 +- include/Nazara/Core/Bitset.inl | 2 +- include/Nazara/Core/ByteArray.hpp | 2 +- include/Nazara/Core/ByteArray.inl | 2 +- include/Nazara/Core/ByteArrayPool.hpp | 2 +- include/Nazara/Core/ByteArrayPool.inl | 2 +- include/Nazara/Core/ByteStream.hpp | 2 +- include/Nazara/Core/ByteStream.inl | 2 +- include/Nazara/Core/CallOnExit.hpp | 2 +- include/Nazara/Core/CallOnExit.inl | 2 +- include/Nazara/Core/Clock.hpp | 2 +- include/Nazara/Core/Color.hpp | 2 +- include/Nazara/Core/Color.inl | 2 +- include/Nazara/Core/ConfigCheck.hpp | 2 +- include/Nazara/Core/Core.hpp | 2 +- include/Nazara/Core/Debug.hpp | 2 +- include/Nazara/Core/Debug/NewRedefinition.hpp | 2 +- include/Nazara/Core/DebugOff.hpp | 2 +- include/Nazara/Core/DynLib.hpp | 2 +- include/Nazara/Core/EmptyStream.hpp | 2 +- include/Nazara/Core/EmptyStream.inl | 2 +- include/Nazara/Core/Endianness.hpp | 2 +- include/Nazara/Core/Endianness.inl | 2 +- include/Nazara/Core/Enums.hpp | 2 +- include/Nazara/Core/Error.hpp | 2 +- include/Nazara/Core/ErrorFlags.hpp | 2 +- include/Nazara/Core/File.hpp | 2 +- include/Nazara/Core/File.inl | 2 +- include/Nazara/Core/FileLogger.hpp | 2 +- include/Nazara/Core/Flags.hpp | 2 +- include/Nazara/Core/Flags.inl | 2 +- include/Nazara/Core/Functor.hpp | 2 +- include/Nazara/Core/Functor.inl | 2 +- include/Nazara/Core/GuillotineBinPack.hpp | 2 +- include/Nazara/Core/HandledObject.hpp | 2 +- include/Nazara/Core/HandledObject.inl | 2 +- include/Nazara/Core/HardwareInfo.hpp | 2 +- include/Nazara/Core/Hash/CRC32.hpp | 2 +- include/Nazara/Core/Hash/CRC64.hpp | 2 +- include/Nazara/Core/Hash/Fletcher16.hpp | 2 +- include/Nazara/Core/Hash/MD5.hpp | 2 +- include/Nazara/Core/Hash/SHA1.hpp | 2 +- include/Nazara/Core/Hash/SHA224.hpp | 2 +- include/Nazara/Core/Hash/SHA256.hpp | 2 +- include/Nazara/Core/Hash/SHA384.hpp | 2 +- include/Nazara/Core/Hash/SHA512.hpp | 2 +- include/Nazara/Core/Hash/Whirlpool.hpp | 2 +- include/Nazara/Core/Initializer.hpp | 2 +- include/Nazara/Core/Initializer.inl | 2 +- include/Nazara/Core/Log.hpp | 2 +- include/Nazara/Core/MemoryHelper.hpp | 2 +- include/Nazara/Core/MemoryHelper.inl | 2 +- include/Nazara/Core/MemoryManager.hpp | 2 +- include/Nazara/Core/MemoryPool.hpp | 2 +- include/Nazara/Core/MemoryPool.inl | 2 +- include/Nazara/Core/MemoryStream.hpp | 2 +- include/Nazara/Core/MemoryStream.inl | 2 +- include/Nazara/Core/MemoryView.hpp | 2 +- include/Nazara/Core/MovablePtr.hpp | 2 +- include/Nazara/Core/MovablePtr.inl | 2 +- include/Nazara/Core/ObjectHandle.hpp | 2 +- include/Nazara/Core/ObjectHandle.inl | 2 +- include/Nazara/Core/ObjectLibrary.hpp | 2 +- include/Nazara/Core/ObjectLibrary.inl | 2 +- include/Nazara/Core/ObjectRef.hpp | 2 +- include/Nazara/Core/ObjectRef.inl | 2 +- include/Nazara/Core/OffsetOf.hpp | 2 +- include/Nazara/Core/ParameterList.hpp | 2 +- include/Nazara/Core/ParameterList.inl | 2 +- include/Nazara/Core/PluginManager.hpp | 2 +- include/Nazara/Core/PoolByteStream.hpp | 2 +- include/Nazara/Core/PoolByteStream.inl | 2 +- include/Nazara/Core/Primitive.hpp | 2 +- include/Nazara/Core/Primitive.inl | 2 +- include/Nazara/Core/PrimitiveList.hpp | 2 +- include/Nazara/Core/RefCounted.hpp | 2 +- include/Nazara/Core/Resource.hpp | 2 +- include/Nazara/Core/ResourceLoader.hpp | 2 +- include/Nazara/Core/ResourceLoader.inl | 2 +- include/Nazara/Core/ResourceManager.hpp | 2 +- include/Nazara/Core/ResourceManager.inl | 2 +- include/Nazara/Core/ResourceParameters.hpp | 2 +- include/Nazara/Core/ResourceSaver.hpp | 2 +- include/Nazara/Core/ResourceSaver.inl | 2 +- include/Nazara/Core/SerializationContext.hpp | 2 +- include/Nazara/Core/SerializationContext.inl | 2 +- include/Nazara/Core/Signal.hpp | 2 +- include/Nazara/Core/Signal.inl | 2 +- include/Nazara/Core/SparsePtr.hpp | 2 +- include/Nazara/Core/SparsePtr.inl | 2 +- include/Nazara/Core/StackArray.hpp | 2 +- include/Nazara/Core/StackArray.inl | 2 +- include/Nazara/Core/StackVector.hpp | 2 +- include/Nazara/Core/StackVector.inl | 2 +- include/Nazara/Core/StdLogger.hpp | 2 +- include/Nazara/Core/Stream.hpp | 2 +- include/Nazara/Core/Stream.inl | 2 +- include/Nazara/Core/String.hpp | 2 +- include/Nazara/Core/String.inl | 2 +- include/Nazara/Core/StringExt.hpp | 2 +- include/Nazara/Core/StringExt.inl | 2 +- include/Nazara/Core/StringStream.hpp | 2 +- include/Nazara/Core/TaskScheduler.hpp | 2 +- include/Nazara/Core/TaskScheduler.inl | 2 +- include/Nazara/Core/TypeTag.hpp | 2 +- include/Nazara/Core/Unicode.hpp | 2 +- include/Nazara/Core/Updatable.hpp | 2 +- include/Nazara/Graphics/AbstractBackground.hpp | 2 +- include/Nazara/Graphics/AbstractRenderQueue.hpp | 2 +- include/Nazara/Graphics/AbstractRenderTechnique.hpp | 2 +- include/Nazara/Graphics/AbstractViewer.hpp | 2 +- include/Nazara/Graphics/BasicRenderQueue.hpp | 2 +- include/Nazara/Graphics/BasicRenderQueue.inl | 2 +- include/Nazara/Graphics/Billboard.hpp | 2 +- include/Nazara/Graphics/Billboard.inl | 2 +- include/Nazara/Graphics/ColorBackground.hpp | 2 +- include/Nazara/Graphics/ColorBackground.inl | 2 +- include/Nazara/Graphics/ConfigCheck.hpp | 2 +- include/Nazara/Graphics/CullingList.hpp | 2 +- include/Nazara/Graphics/CullingList.inl | 2 +- include/Nazara/Graphics/Debug.hpp | 2 +- include/Nazara/Graphics/DebugOff.hpp | 2 +- include/Nazara/Graphics/DeferredBloomPass.hpp | 2 +- include/Nazara/Graphics/DeferredDOFPass.hpp | 2 +- include/Nazara/Graphics/DeferredFXAAPass.hpp | 2 +- include/Nazara/Graphics/DeferredFinalPass.hpp | 2 +- include/Nazara/Graphics/DeferredFogPass.hpp | 2 +- include/Nazara/Graphics/DeferredForwardPass.hpp | 2 +- include/Nazara/Graphics/DeferredGeometryPass.hpp | 2 +- include/Nazara/Graphics/DeferredPhongLightingPass.hpp | 2 +- include/Nazara/Graphics/DeferredProxyRenderQueue.hpp | 2 +- include/Nazara/Graphics/DeferredProxyRenderQueue.inl | 2 +- include/Nazara/Graphics/DeferredRenderPass.hpp | 2 +- include/Nazara/Graphics/DeferredRenderTechnique.hpp | 2 +- include/Nazara/Graphics/DepthRenderQueue.hpp | 2 +- include/Nazara/Graphics/DepthRenderQueue.inl | 2 +- include/Nazara/Graphics/DepthRenderTechnique.hpp | 2 +- include/Nazara/Graphics/DepthRenderTechnique.inl | 2 +- include/Nazara/Graphics/Drawable.hpp | 2 +- include/Nazara/Graphics/Enums.hpp | 2 +- include/Nazara/Graphics/ForwardRenderTechnique.hpp | 2 +- include/Nazara/Graphics/ForwardRenderTechnique.inl | 2 +- include/Nazara/Graphics/Graphics.hpp | 2 +- include/Nazara/Graphics/GuillotineTextureAtlas.hpp | 2 +- include/Nazara/Graphics/InstancedRenderable.hpp | 2 +- include/Nazara/Graphics/InstancedRenderable.inl | 2 +- include/Nazara/Graphics/Light.hpp | 2 +- include/Nazara/Graphics/Light.inl | 2 +- include/Nazara/Graphics/Material.hpp | 2 +- include/Nazara/Graphics/Material.inl | 2 +- include/Nazara/Graphics/MaterialPipeline.hpp | 2 +- include/Nazara/Graphics/MaterialPipeline.inl | 2 +- include/Nazara/Graphics/Model.hpp | 2 +- include/Nazara/Graphics/Model.inl | 2 +- include/Nazara/Graphics/ParticleController.hpp | 2 +- include/Nazara/Graphics/ParticleDeclaration.hpp | 2 +- include/Nazara/Graphics/ParticleDeclaration.inl | 2 +- include/Nazara/Graphics/ParticleEmitter.hpp | 2 +- include/Nazara/Graphics/ParticleFunctionController.hpp | 2 +- include/Nazara/Graphics/ParticleFunctionController.inl | 2 +- include/Nazara/Graphics/ParticleFunctionGenerator.hpp | 2 +- include/Nazara/Graphics/ParticleFunctionGenerator.inl | 2 +- include/Nazara/Graphics/ParticleFunctionRenderer.hpp | 2 +- include/Nazara/Graphics/ParticleFunctionRenderer.inl | 2 +- include/Nazara/Graphics/ParticleGenerator.hpp | 2 +- include/Nazara/Graphics/ParticleGroup.hpp | 2 +- include/Nazara/Graphics/ParticleGroup.inl | 2 +- include/Nazara/Graphics/ParticleMapper.hpp | 2 +- include/Nazara/Graphics/ParticleMapper.inl | 2 +- include/Nazara/Graphics/ParticleRenderer.hpp | 2 +- include/Nazara/Graphics/ParticleStruct.hpp | 2 +- include/Nazara/Graphics/RenderQueue.hpp | 2 +- include/Nazara/Graphics/RenderQueue.inl | 2 +- include/Nazara/Graphics/RenderTechniques.hpp | 2 +- include/Nazara/Graphics/Renderable.hpp | 2 +- include/Nazara/Graphics/Renderable.inl | 2 +- include/Nazara/Graphics/SceneData.hpp | 2 +- include/Nazara/Graphics/SkeletalModel.hpp | 2 +- include/Nazara/Graphics/SkeletalModel.inl | 2 +- include/Nazara/Graphics/SkinningManager.hpp | 2 +- include/Nazara/Graphics/SkyboxBackground.hpp | 2 +- include/Nazara/Graphics/SkyboxBackground.inl | 2 +- include/Nazara/Graphics/Sprite.hpp | 2 +- include/Nazara/Graphics/Sprite.inl | 2 +- include/Nazara/Graphics/TextSprite.hpp | 2 +- include/Nazara/Graphics/TextSprite.inl | 2 +- include/Nazara/Graphics/TextureBackground.hpp | 2 +- include/Nazara/Graphics/TextureBackground.inl | 2 +- include/Nazara/Graphics/TileMap.hpp | 2 +- include/Nazara/Graphics/TileMap.inl | 2 +- include/Nazara/Math/Algorithm.hpp | 2 +- include/Nazara/Math/Algorithm.inl | 2 +- include/Nazara/Math/Angle.hpp | 2 +- include/Nazara/Math/Angle.inl | 2 +- include/Nazara/Math/BoundingVolume.hpp | 2 +- include/Nazara/Math/BoundingVolume.inl | 2 +- include/Nazara/Math/Box.hpp | 2 +- include/Nazara/Math/Box.inl | 2 +- include/Nazara/Math/Enums.hpp | 2 +- include/Nazara/Math/EulerAngles.hpp | 2 +- include/Nazara/Math/EulerAngles.inl | 2 +- include/Nazara/Math/Frustum.hpp | 2 +- include/Nazara/Math/Frustum.inl | 2 +- include/Nazara/Math/Matrix4.hpp | 2 +- include/Nazara/Math/Matrix4.inl | 2 +- include/Nazara/Math/OrientedBox.hpp | 2 +- include/Nazara/Math/OrientedBox.inl | 2 +- include/Nazara/Math/Plane.hpp | 2 +- include/Nazara/Math/Plane.inl | 2 +- include/Nazara/Math/Rect.hpp | 2 +- include/Nazara/Math/Rect.inl | 2 +- include/Nazara/Math/Sphere.hpp | 2 +- include/Nazara/Math/Sphere.inl | 2 +- include/Nazara/Math/Vector2.hpp | 2 +- include/Nazara/Math/Vector2.inl | 2 +- include/Nazara/Network/AbstractSocket.hpp | 2 +- include/Nazara/Network/AbstractSocket.inl | 2 +- include/Nazara/Network/Algorithm.hpp | 2 +- include/Nazara/Network/Algorithm.inl | 2 +- include/Nazara/Network/ConfigCheck.hpp | 2 +- include/Nazara/Network/Debug.hpp | 2 +- include/Nazara/Network/DebugOff.hpp | 2 +- include/Nazara/Network/ENetCompressor.hpp | 2 +- include/Nazara/Network/ENetHost.hpp | 2 +- include/Nazara/Network/ENetHost.inl | 2 +- include/Nazara/Network/ENetPacket.hpp | 2 +- include/Nazara/Network/ENetPeer.hpp | 2 +- include/Nazara/Network/ENetPeer.inl | 2 +- include/Nazara/Network/ENetProtocol.hpp | 2 +- include/Nazara/Network/ENetProtocol.inl | 2 +- include/Nazara/Network/Enums.hpp | 2 +- include/Nazara/Network/IpAddress.hpp | 2 +- include/Nazara/Network/IpAddress.inl | 2 +- include/Nazara/Network/NetBuffer.hpp | 2 +- include/Nazara/Network/NetPacket.hpp | 2 +- include/Nazara/Network/NetPacket.inl | 2 +- include/Nazara/Network/Network.hpp | 2 +- include/Nazara/Network/RUdpConnection.hpp | 2 +- include/Nazara/Network/RUdpConnection.inl | 2 +- include/Nazara/Network/RUdpMessage.hpp | 2 +- include/Nazara/Network/SocketHandle.hpp | 2 +- include/Nazara/Network/SocketPoller.hpp | 2 +- include/Nazara/Network/SocketPoller.inl | 2 +- include/Nazara/Network/TcpClient.hpp | 2 +- include/Nazara/Network/TcpClient.inl | 2 +- include/Nazara/Network/TcpServer.hpp | 2 +- include/Nazara/Network/TcpServer.inl | 2 +- include/Nazara/Network/UdpSocket.hpp | 2 +- include/Nazara/Network/UdpSocket.inl | 2 +- include/Nazara/Physics2D/Arbiter2D.hpp | 2 +- include/Nazara/Physics2D/Arbiter2D.inl | 2 +- include/Nazara/Physics2D/Collider2D.hpp | 2 +- include/Nazara/Physics2D/Collider2D.inl | 2 +- include/Nazara/Physics2D/ConfigCheck.hpp | 2 +- include/Nazara/Physics2D/Constraint2D.hpp | 2 +- include/Nazara/Physics2D/Constraint2D.inl | 2 +- include/Nazara/Physics2D/Debug.hpp | 2 +- include/Nazara/Physics2D/DebugOff.hpp | 2 +- include/Nazara/Physics2D/Enums.hpp | 2 +- include/Nazara/Physics2D/PhysWorld2D.hpp | 2 +- include/Nazara/Physics2D/Physics2D.hpp | 2 +- include/Nazara/Physics2D/RigidBody2D.hpp | 2 +- include/Nazara/Physics2D/RigidBody2D.inl | 2 +- include/Nazara/Physics3D/Collider3D.hpp | 2 +- include/Nazara/Physics3D/Collider3D.inl | 2 +- include/Nazara/Physics3D/ConfigCheck.hpp | 2 +- include/Nazara/Physics3D/Debug.hpp | 2 +- include/Nazara/Physics3D/DebugOff.hpp | 2 +- include/Nazara/Physics3D/Enums.hpp | 2 +- include/Nazara/Physics3D/PhysWorld3D.hpp | 2 +- include/Nazara/Physics3D/Physics3D.hpp | 2 +- include/Nazara/Physics3D/RigidBody3D.hpp | 2 +- include/Nazara/Platform/ConfigCheck.hpp | 2 +- include/Nazara/Platform/Cursor.hpp | 2 +- include/Nazara/Platform/Cursor.inl | 2 +- include/Nazara/Platform/CursorController.hpp | 2 +- include/Nazara/Platform/CursorController.inl | 2 +- include/Nazara/Platform/Debug.hpp | 2 +- include/Nazara/Platform/DebugOff.hpp | 2 +- include/Nazara/Platform/Enums.hpp | 2 +- include/Nazara/Platform/Event.hpp | 2 +- include/Nazara/Platform/EventHandler.hpp | 2 +- include/Nazara/Platform/EventHandler.inl | 2 +- include/Nazara/Platform/Icon.hpp | 2 +- include/Nazara/Platform/Icon.inl | 2 +- include/Nazara/Platform/Joystick.hpp | 2 +- include/Nazara/Platform/Keyboard.hpp | 2 +- include/Nazara/Platform/Mouse.hpp | 2 +- include/Nazara/Platform/Platform.hpp | 2 +- include/Nazara/Platform/VideoMode.hpp | 2 +- include/Nazara/Platform/Window.hpp | 2 +- include/Nazara/Platform/Window.inl | 2 +- include/Nazara/Platform/WindowHandle.hpp | 2 +- include/Nazara/Renderer/ConfigCheck.hpp | 2 +- include/Nazara/Renderer/Debug.hpp | 2 +- include/Nazara/Renderer/DebugDrawer.hpp | 2 +- include/Nazara/Renderer/DebugOff.hpp | 2 +- include/Nazara/Renderer/Enums.hpp | 2 +- include/Nazara/Renderer/GlslWriter.hpp | 2 +- include/Nazara/Renderer/RenderBuffer.hpp | 2 +- include/Nazara/Renderer/RenderBuffer.inl | 2 +- include/Nazara/Renderer/RenderDevice.hpp | 2 +- include/Nazara/Renderer/RenderDevice.inl | 2 +- include/Nazara/Renderer/RenderDeviceInfo.hpp | 2 +- include/Nazara/Renderer/RenderPipeline.hpp | 2 +- include/Nazara/Renderer/RenderPipeline.inl | 2 +- include/Nazara/Renderer/RenderStates.hpp | 2 +- include/Nazara/Renderer/RenderStates.inl | 2 +- include/Nazara/Renderer/RenderSurface.hpp | 2 +- include/Nazara/Renderer/RenderSurface.inl | 2 +- include/Nazara/Renderer/RenderWindow.hpp | 2 +- include/Nazara/Renderer/RenderWindowParameters.hpp | 2 +- include/Nazara/Renderer/Renderer.hpp | 2 +- include/Nazara/Renderer/Renderer.inl | 2 +- include/Nazara/Renderer/Shader.hpp | 2 +- include/Nazara/Renderer/ShaderAst.hpp | 2 +- include/Nazara/Renderer/ShaderAst.inl | 2 +- include/Nazara/Renderer/ShaderBuilder.hpp | 2 +- include/Nazara/Renderer/ShaderBuilder.inl | 2 +- include/Nazara/Renderer/Texture.hpp | 2 +- include/Nazara/Utility/AbstractAtlas.hpp | 2 +- include/Nazara/Utility/AbstractBuffer.hpp | 2 +- include/Nazara/Utility/AbstractImage.hpp | 2 +- include/Nazara/Utility/AbstractImage.inl | 2 +- include/Nazara/Utility/AbstractTextDrawer.hpp | 2 +- include/Nazara/Utility/AbstractTextDrawer.inl | 2 +- include/Nazara/Utility/Algorithm.hpp | 2 +- include/Nazara/Utility/Algorithm.inl | 2 +- include/Nazara/Utility/Animation.hpp | 2 +- include/Nazara/Utility/Animation.inl | 2 +- include/Nazara/Utility/Buffer.hpp | 2 +- include/Nazara/Utility/Buffer.inl | 2 +- include/Nazara/Utility/BufferMapper.hpp | 2 +- include/Nazara/Utility/BufferMapper.inl | 2 +- include/Nazara/Utility/ConfigCheck.hpp | 2 +- include/Nazara/Utility/CubemapParams.hpp | 2 +- include/Nazara/Utility/Debug.hpp | 2 +- include/Nazara/Utility/DebugOff.hpp | 2 +- include/Nazara/Utility/Enums.hpp | 2 +- include/Nazara/Utility/Font.hpp | 2 +- include/Nazara/Utility/Font.inl | 2 +- include/Nazara/Utility/FontData.hpp | 2 +- include/Nazara/Utility/FontGlyph.hpp | 2 +- include/Nazara/Utility/Formats/MD5AnimParser.hpp | 2 +- include/Nazara/Utility/Formats/MD5MeshParser.hpp | 2 +- include/Nazara/Utility/Formats/MTLParser.hpp | 2 +- include/Nazara/Utility/Formats/MTLParser.inl | 2 +- include/Nazara/Utility/Formats/OBJParser.hpp | 2 +- include/Nazara/Utility/Formats/OBJParser.inl | 2 +- include/Nazara/Utility/GuillotineImageAtlas.hpp | 2 +- include/Nazara/Utility/Image.hpp | 2 +- include/Nazara/Utility/Image.inl | 2 +- include/Nazara/Utility/IndexBuffer.hpp | 2 +- include/Nazara/Utility/IndexBuffer.inl | 2 +- include/Nazara/Utility/IndexIterator.hpp | 2 +- include/Nazara/Utility/IndexIterator.inl | 2 +- include/Nazara/Utility/IndexMapper.hpp | 2 +- include/Nazara/Utility/Joint.hpp | 2 +- include/Nazara/Utility/MaterialData.hpp | 2 +- include/Nazara/Utility/Mesh.hpp | 2 +- include/Nazara/Utility/Mesh.inl | 2 +- include/Nazara/Utility/MeshData.hpp | 2 +- include/Nazara/Utility/Node.hpp | 2 +- include/Nazara/Utility/PixelFormat.hpp | 2 +- include/Nazara/Utility/PixelFormat.inl | 2 +- include/Nazara/Utility/RichTextDrawer.hpp | 2 +- include/Nazara/Utility/RichTextDrawer.inl | 2 +- include/Nazara/Utility/Sequence.hpp | 2 +- include/Nazara/Utility/SimpleTextDrawer.hpp | 2 +- include/Nazara/Utility/SimpleTextDrawer.inl | 2 +- include/Nazara/Utility/SkeletalMesh.hpp | 2 +- include/Nazara/Utility/SkeletalMesh.inl | 2 +- include/Nazara/Utility/Skeleton.hpp | 2 +- include/Nazara/Utility/Skeleton.inl | 2 +- include/Nazara/Utility/SoftwareBuffer.hpp | 2 +- include/Nazara/Utility/StaticMesh.hpp | 2 +- include/Nazara/Utility/StaticMesh.inl | 2 +- include/Nazara/Utility/SubMesh.hpp | 2 +- include/Nazara/Utility/TriangleIterator.hpp | 2 +- include/Nazara/Utility/UniformBuffer.hpp | 2 +- include/Nazara/Utility/UniformBuffer.inl | 2 +- include/Nazara/Utility/Utility.hpp | 2 +- include/Nazara/Utility/VertexBuffer.hpp | 2 +- include/Nazara/Utility/VertexBuffer.inl | 2 +- include/Nazara/Utility/VertexDeclaration.hpp | 2 +- include/Nazara/Utility/VertexDeclaration.inl | 2 +- include/Nazara/Utility/VertexMapper.hpp | 2 +- include/Nazara/Utility/VertexMapper.inl | 2 +- include/Nazara/Utility/VertexStruct.hpp | 2 +- include/Nazara/VulkanRenderer/ConfigCheck.hpp | 2 +- include/Nazara/VulkanRenderer/Debug.hpp | 2 +- include/Nazara/VulkanRenderer/DebugOff.hpp | 2 +- include/Nazara/VulkanRenderer/Utils.hpp | 2 +- include/Nazara/VulkanRenderer/Utils.inl | 2 +- include/Nazara/VulkanRenderer/VkRenderTarget.inl | 2 +- include/Nazara/VulkanRenderer/VkRenderWindow.inl | 2 +- include/Nazara/VulkanRenderer/Vulkan.hpp | 2 +- include/Nazara/VulkanRenderer/VulkanBuffer.inl | 2 +- include/Nazara/VulkanRenderer/VulkanDevice.inl | 2 +- include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp | 2 +- include/Nazara/VulkanRenderer/VulkanRenderPipeline.inl | 2 +- include/Nazara/VulkanRenderer/VulkanRenderer.hpp | 2 +- include/Nazara/VulkanRenderer/VulkanRenderer.inl | 2 +- include/Nazara/VulkanRenderer/VulkanShaderStage.inl | 2 +- include/Nazara/VulkanRenderer/VulkanSurface.inl | 2 +- include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/Buffer.inl | 2 +- include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl | 2 +- include/Nazara/VulkanRenderer/Wrapper/CommandPool.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/CommandPool.inl | 2 +- include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.inl | 2 +- include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.inl | 2 +- include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.inl | 2 +- include/Nazara/VulkanRenderer/Wrapper/Device.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/Device.inl | 2 +- include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.inl | 2 +- include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl | 2 +- include/Nazara/VulkanRenderer/Wrapper/Fence.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/Fence.inl | 2 +- include/Nazara/VulkanRenderer/Wrapper/Framebuffer.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/Framebuffer.inl | 2 +- include/Nazara/VulkanRenderer/Wrapper/Image.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/Image.inl | 2 +- include/Nazara/VulkanRenderer/Wrapper/ImageView.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/ImageView.inl | 2 +- include/Nazara/VulkanRenderer/Wrapper/Instance.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/Instance.inl | 2 +- include/Nazara/VulkanRenderer/Wrapper/Loader.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/Loader.inl | 2 +- include/Nazara/VulkanRenderer/Wrapper/PhysicalDevice.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/Pipeline.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/Pipeline.inl | 2 +- include/Nazara/VulkanRenderer/Wrapper/PipelineCache.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/PipelineCache.inl | 2 +- include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.inl | 2 +- include/Nazara/VulkanRenderer/Wrapper/Queue.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/Queue.inl | 2 +- include/Nazara/VulkanRenderer/Wrapper/RenderPass.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/RenderPass.inl | 2 +- include/Nazara/VulkanRenderer/Wrapper/Semaphore.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/Semaphore.inl | 2 +- include/Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/ShaderModule.inl | 2 +- include/Nazara/VulkanRenderer/Wrapper/Surface.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/Surface.inl | 2 +- include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp | 2 +- include/Nazara/VulkanRenderer/Wrapper/Swapchain.inl | 2 +- include/NazaraSDK/Algorithm.hpp | 2 +- include/NazaraSDK/Algorithm.inl | 2 +- include/NazaraSDK/Application.hpp | 2 +- include/NazaraSDK/Application.inl | 2 +- include/NazaraSDK/BaseComponent.hpp | 2 +- include/NazaraSDK/BaseComponent.inl | 2 +- include/NazaraSDK/BaseSystem.hpp | 2 +- include/NazaraSDK/BaseSystem.inl | 2 +- include/NazaraSDK/BaseWidget.hpp | 2 +- include/NazaraSDK/BaseWidget.inl | 2 +- include/NazaraSDK/Canvas.hpp | 2 +- include/NazaraSDK/Canvas.inl | 2 +- include/NazaraSDK/Component.hpp | 2 +- include/NazaraSDK/Component.inl | 2 +- include/NazaraSDK/Components/CameraComponent.hpp | 2 +- include/NazaraSDK/Components/CameraComponent.inl | 2 +- include/NazaraSDK/Components/CollisionComponent2D.hpp | 2 +- include/NazaraSDK/Components/CollisionComponent2D.inl | 2 +- include/NazaraSDK/Components/CollisionComponent3D.hpp | 2 +- include/NazaraSDK/Components/CollisionComponent3D.inl | 2 +- include/NazaraSDK/Components/ConstraintComponent2D.hpp | 2 +- include/NazaraSDK/Components/ConstraintComponent2D.inl | 2 +- include/NazaraSDK/Components/DebugComponent.hpp | 2 +- include/NazaraSDK/Components/DebugComponent.inl | 2 +- include/NazaraSDK/Components/GraphicsComponent.hpp | 2 +- include/NazaraSDK/Components/GraphicsComponent.inl | 2 +- include/NazaraSDK/Components/LifetimeComponent.hpp | 2 +- include/NazaraSDK/Components/LifetimeComponent.inl | 2 +- include/NazaraSDK/Components/LightComponent.hpp | 2 +- include/NazaraSDK/Components/LightComponent.inl | 2 +- include/NazaraSDK/Components/ListenerComponent.hpp | 2 +- include/NazaraSDK/Components/ListenerComponent.inl | 2 +- include/NazaraSDK/Components/NodeComponent.hpp | 2 +- include/NazaraSDK/Components/NodeComponent.inl | 2 +- include/NazaraSDK/Components/ParticleEmitterComponent.hpp | 2 +- include/NazaraSDK/Components/ParticleEmitterComponent.inl | 2 +- include/NazaraSDK/Components/ParticleGroupComponent.hpp | 2 +- include/NazaraSDK/Components/ParticleGroupComponent.inl | 2 +- include/NazaraSDK/Components/PhysicsComponent2D.hpp | 2 +- include/NazaraSDK/Components/PhysicsComponent2D.inl | 2 +- include/NazaraSDK/Components/PhysicsComponent3D.hpp | 2 +- include/NazaraSDK/Components/PhysicsComponent3D.inl | 2 +- include/NazaraSDK/Components/VelocityComponent.hpp | 2 +- include/NazaraSDK/Components/VelocityComponent.inl | 2 +- include/NazaraSDK/Console.hpp | 2 +- include/NazaraSDK/Console.inl | 2 +- include/NazaraSDK/Entity.hpp | 2 +- include/NazaraSDK/Entity.inl | 2 +- include/NazaraSDK/EntityList.hpp | 2 +- include/NazaraSDK/EntityList.inl | 2 +- include/NazaraSDK/EntityOwner.hpp | 2 +- include/NazaraSDK/EntityOwner.inl | 2 +- include/NazaraSDK/Sdk.hpp | 2 +- include/NazaraSDK/Sdk.inl | 2 +- include/NazaraSDK/State.hpp | 2 +- include/NazaraSDK/StateMachine.hpp | 2 +- include/NazaraSDK/StateMachine.inl | 2 +- include/NazaraSDK/System.hpp | 2 +- include/NazaraSDK/System.inl | 2 +- include/NazaraSDK/Systems/DebugSystem.hpp | 2 +- include/NazaraSDK/Systems/DebugSystem.inl | 2 +- include/NazaraSDK/Systems/LifetimeSystem.hpp | 2 +- include/NazaraSDK/Systems/LifetimeSystem.inl | 2 +- include/NazaraSDK/Systems/ListenerSystem.hpp | 2 +- include/NazaraSDK/Systems/ListenerSystem.inl | 2 +- include/NazaraSDK/Systems/ParticleSystem.hpp | 2 +- include/NazaraSDK/Systems/ParticleSystem.inl | 2 +- include/NazaraSDK/Systems/PhysicsSystem2D.hpp | 2 +- include/NazaraSDK/Systems/PhysicsSystem2D.inl | 2 +- include/NazaraSDK/Systems/PhysicsSystem3D.hpp | 2 +- include/NazaraSDK/Systems/PhysicsSystem3D.inl | 2 +- include/NazaraSDK/Systems/RenderSystem.hpp | 2 +- include/NazaraSDK/Systems/RenderSystem.inl | 2 +- include/NazaraSDK/Systems/VelocitySystem.hpp | 2 +- include/NazaraSDK/Systems/VelocitySystem.inl | 2 +- include/NazaraSDK/Widgets/AbstractTextAreaWidget.hpp | 2 +- include/NazaraSDK/Widgets/AbstractTextAreaWidget.inl | 2 +- include/NazaraSDK/Widgets/BoxLayout.hpp | 2 +- include/NazaraSDK/Widgets/BoxLayout.inl | 2 +- include/NazaraSDK/Widgets/ButtonWidget.hpp | 2 +- include/NazaraSDK/Widgets/ButtonWidget.inl | 2 +- include/NazaraSDK/Widgets/LabelWidget.hpp | 2 +- include/NazaraSDK/Widgets/LabelWidget.inl | 2 +- include/NazaraSDK/Widgets/RichTextAreaWidget.hpp | 2 +- include/NazaraSDK/Widgets/RichTextAreaWidget.inl | 2 +- include/NazaraSDK/Widgets/ScrollAreaWidget.hpp | 2 +- include/NazaraSDK/Widgets/ScrollAreaWidget.inl | 2 +- include/NazaraSDK/Widgets/TextAreaWidget.hpp | 2 +- include/NazaraSDK/Widgets/TextAreaWidget.inl | 2 +- include/NazaraSDK/World.hpp | 2 +- include/NazaraSDK/World.inl | 2 +- plugins/Assimp/CustomStream.cpp | 2 +- plugins/Assimp/CustomStream.hpp | 2 +- src/Nazara/Audio/Audio.cpp | 2 +- src/Nazara/Audio/Debug/NewOverload.cpp | 2 +- src/Nazara/Audio/Formats/sndfileLoader.cpp | 2 +- src/Nazara/Audio/Formats/sndfileLoader.hpp | 2 +- src/Nazara/Audio/Music.cpp | 2 +- src/Nazara/Audio/OpenAL.cpp | 2 +- src/Nazara/Audio/Sound.cpp | 2 +- src/Nazara/Audio/SoundBuffer.cpp | 2 +- src/Nazara/Audio/SoundEmitter.cpp | 2 +- src/Nazara/Audio/SoundStream.cpp | 2 +- src/Nazara/Core/AbstractHash.cpp | 2 +- src/Nazara/Core/AbstractLogger.cpp | 2 +- src/Nazara/Core/AlgorithmCore.cpp | 2 +- src/Nazara/Core/ByteArray.cpp | 2 +- src/Nazara/Core/ByteStream.cpp | 2 +- src/Nazara/Core/Clock.cpp | 2 +- src/Nazara/Core/Color.cpp | 2 +- src/Nazara/Core/Core.cpp | 2 +- src/Nazara/Core/Debug/NewOverload.cpp | 2 +- src/Nazara/Core/Debug/NewRedefinition.cpp | 2 +- src/Nazara/Core/DynLib.cpp | 2 +- src/Nazara/Core/EmptyStream.cpp | 2 +- src/Nazara/Core/Error.cpp | 2 +- src/Nazara/Core/ErrorFlags.cpp | 2 +- src/Nazara/Core/File.cpp | 2 +- src/Nazara/Core/FileLogger.cpp | 2 +- src/Nazara/Core/GuillotineBinPack.cpp | 2 +- src/Nazara/Core/HandledObject.cpp | 2 +- src/Nazara/Core/HardwareInfo.cpp | 2 +- src/Nazara/Core/Hash/CRC32.cpp | 2 +- src/Nazara/Core/Hash/CRC64.cpp | 2 +- src/Nazara/Core/Hash/Fletcher16.cpp | 2 +- src/Nazara/Core/Hash/MD5.cpp | 2 +- src/Nazara/Core/Hash/SHA/Internal.cpp | 2 +- src/Nazara/Core/Hash/SHA/Internal.hpp | 2 +- src/Nazara/Core/Hash/SHA1.cpp | 2 +- src/Nazara/Core/Hash/SHA224.cpp | 2 +- src/Nazara/Core/Hash/SHA256.cpp | 2 +- src/Nazara/Core/Hash/SHA384.cpp | 2 +- src/Nazara/Core/Hash/SHA512.cpp | 2 +- src/Nazara/Core/Hash/Whirlpool.cpp | 2 +- src/Nazara/Core/Log.cpp | 2 +- src/Nazara/Core/MemoryManager.cpp | 2 +- src/Nazara/Core/MemoryStream.cpp | 2 +- src/Nazara/Core/MemoryView.cpp | 2 +- src/Nazara/Core/ParameterList.cpp | 2 +- src/Nazara/Core/PluginManager.cpp | 2 +- src/Nazara/Core/PoolByteStream.cpp | 2 +- src/Nazara/Core/PrimitiveList.cpp | 2 +- src/Nazara/Core/RefCounted.cpp | 2 +- src/Nazara/Core/Resource.cpp | 2 +- src/Nazara/Core/SerializationContext.cpp | 2 +- src/Nazara/Core/StdLogger.cpp | 2 +- src/Nazara/Core/Stream.cpp | 2 +- src/Nazara/Core/String.cpp | 2 +- src/Nazara/Core/StringExt.cpp | 2 +- src/Nazara/Core/StringStream.cpp | 2 +- src/Nazara/Core/TaskScheduler.cpp | 2 +- src/Nazara/Core/Unicode.cpp | 2 +- src/Nazara/Core/Updatable.cpp | 2 +- src/Nazara/Core/Win32/ClockImpl.cpp | 2 +- src/Nazara/Core/Win32/ClockImpl.hpp | 2 +- src/Nazara/Core/Win32/DynLibImpl.cpp | 2 +- src/Nazara/Core/Win32/DynLibImpl.hpp | 2 +- src/Nazara/Core/Win32/FileImpl.cpp | 2 +- src/Nazara/Core/Win32/FileImpl.hpp | 2 +- src/Nazara/Core/Win32/HardwareInfoImpl.cpp | 2 +- src/Nazara/Core/Win32/HardwareInfoImpl.hpp | 2 +- src/Nazara/Core/Win32/TaskSchedulerImpl.cpp | 2 +- src/Nazara/Core/Win32/TaskSchedulerImpl.hpp | 2 +- src/Nazara/Core/Win32/Time.cpp | 2 +- src/Nazara/Core/Win32/Time.hpp | 2 +- src/Nazara/Graphics/AbstractBackground.cpp | 2 +- src/Nazara/Graphics/AbstractRenderQueue.cpp | 2 +- src/Nazara/Graphics/AbstractRenderTechnique.cpp | 2 +- src/Nazara/Graphics/AbstractViewer.cpp | 2 +- src/Nazara/Graphics/BasicRenderQueue.cpp | 2 +- src/Nazara/Graphics/Billboard.cpp | 2 +- src/Nazara/Graphics/ColorBackground.cpp | 2 +- src/Nazara/Graphics/Debug/NewOverload.cpp | 2 +- src/Nazara/Graphics/DeferredBloomPass.cpp | 2 +- src/Nazara/Graphics/DeferredDOFPass.cpp | 2 +- src/Nazara/Graphics/DeferredFXAAPass.cpp | 2 +- src/Nazara/Graphics/DeferredFinalPass.cpp | 2 +- src/Nazara/Graphics/DeferredFogPass.cpp | 2 +- src/Nazara/Graphics/DeferredForwardPass.cpp | 2 +- src/Nazara/Graphics/DeferredGeometryPass.cpp | 2 +- src/Nazara/Graphics/DeferredPhongLightingPass.cpp | 2 +- src/Nazara/Graphics/DeferredProxyRenderQueue.cpp | 2 +- src/Nazara/Graphics/DeferredRenderPass.cpp | 2 +- src/Nazara/Graphics/DeferredRenderTechnique.cpp | 2 +- src/Nazara/Graphics/DepthRenderQueue.cpp | 2 +- src/Nazara/Graphics/DepthRenderTechnique.cpp | 2 +- src/Nazara/Graphics/Drawable.cpp | 2 +- src/Nazara/Graphics/Formats/MeshLoader.cpp | 2 +- src/Nazara/Graphics/Formats/MeshLoader.hpp | 2 +- src/Nazara/Graphics/Formats/TextureLoader.cpp | 2 +- src/Nazara/Graphics/Formats/TextureLoader.hpp | 2 +- src/Nazara/Graphics/ForwardRenderTechnique.cpp | 2 +- src/Nazara/Graphics/Graphics.cpp | 2 +- src/Nazara/Graphics/GuillotineTextureAtlas.cpp | 2 +- src/Nazara/Graphics/InstancedRenderable.cpp | 2 +- src/Nazara/Graphics/Light.cpp | 2 +- src/Nazara/Graphics/Material.cpp | 2 +- src/Nazara/Graphics/MaterialPipeline.cpp | 2 +- src/Nazara/Graphics/Model.cpp | 2 +- src/Nazara/Graphics/ParticleController.cpp | 2 +- src/Nazara/Graphics/ParticleDeclaration.cpp | 2 +- src/Nazara/Graphics/ParticleEmitter.cpp | 2 +- src/Nazara/Graphics/ParticleFunctionController.cpp | 2 +- src/Nazara/Graphics/ParticleFunctionGenerator.cpp | 2 +- src/Nazara/Graphics/ParticleFunctionRenderer.cpp | 2 +- src/Nazara/Graphics/ParticleGenerator.cpp | 2 +- src/Nazara/Graphics/ParticleGroup.cpp | 2 +- src/Nazara/Graphics/ParticleMapper.cpp | 2 +- src/Nazara/Graphics/ParticleRenderer.cpp | 2 +- src/Nazara/Graphics/RenderQueue.cpp | 2 +- src/Nazara/Graphics/RenderTechniques.cpp | 2 +- src/Nazara/Graphics/Renderable.cpp | 2 +- src/Nazara/Graphics/SkeletalModel.cpp | 2 +- src/Nazara/Graphics/SkinningManager.cpp | 2 +- src/Nazara/Graphics/SkyboxBackground.cpp | 2 +- src/Nazara/Graphics/Sprite.cpp | 2 +- src/Nazara/Graphics/TextSprite.cpp | 2 +- src/Nazara/Graphics/TextureBackground.cpp | 2 +- src/Nazara/Graphics/TileMap.cpp | 2 +- src/Nazara/Network/AbstractSocket.cpp | 2 +- src/Nazara/Network/AlgorithmNetwork.cpp | 2 +- src/Nazara/Network/Debug/NewOverload.cpp | 2 +- src/Nazara/Network/ENetCompressor.cpp | 2 +- src/Nazara/Network/ENetHost.cpp | 2 +- src/Nazara/Network/ENetPacket.cpp | 2 +- src/Nazara/Network/ENetPeer.cpp | 2 +- src/Nazara/Network/IpAddress.cpp | 2 +- src/Nazara/Network/NetPacket.cpp | 2 +- src/Nazara/Network/Network.cpp | 2 +- src/Nazara/Network/RUdpConnection.cpp | 2 +- src/Nazara/Network/SocketPoller.cpp | 2 +- src/Nazara/Network/SystemSocket.hpp | 2 +- src/Nazara/Network/TcpClient.cpp | 2 +- src/Nazara/Network/TcpServer.cpp | 2 +- src/Nazara/Network/UdpSocket.cpp | 2 +- src/Nazara/Network/Win32/IpAddressImpl.cpp | 2 +- src/Nazara/Network/Win32/IpAddressImpl.hpp | 2 +- src/Nazara/Network/Win32/SocketImpl.cpp | 2 +- src/Nazara/Network/Win32/SocketImpl.hpp | 2 +- src/Nazara/Network/Win32/SocketPollerImpl.cpp | 2 +- src/Nazara/Network/Win32/SocketPollerImpl.hpp | 2 +- src/Nazara/Physics2D/Arbiter2D.cpp | 2 +- src/Nazara/Physics2D/Collider2D.cpp | 2 +- src/Nazara/Physics2D/Constraint2D.cpp | 2 +- src/Nazara/Physics2D/Debug/NewOverload.cpp | 2 +- src/Nazara/Physics2D/PhysWorld2D.cpp | 2 +- src/Nazara/Physics2D/Physics2D.cpp | 2 +- src/Nazara/Physics2D/RigidBody2D.cpp | 2 +- src/Nazara/Physics3D/Collider3D.cpp | 2 +- src/Nazara/Physics3D/Debug/NewOverload.cpp | 2 +- src/Nazara/Physics3D/PhysWorld3D.cpp | 2 +- src/Nazara/Physics3D/Physics3D.cpp | 2 +- src/Nazara/Physics3D/RigidBody3D.cpp | 2 +- src/Nazara/Platform/Cursor.cpp | 2 +- src/Nazara/Platform/Debug/NewOverload.cpp | 2 +- src/Nazara/Platform/Icon.cpp | 2 +- src/Nazara/Platform/Keyboard.cpp | 2 +- src/Nazara/Platform/Mouse.cpp | 2 +- src/Nazara/Platform/Platform.cpp | 2 +- src/Nazara/Platform/VideoMode.cpp | 2 +- src/Nazara/Platform/VideoModeImpl.hpp | 2 +- src/Nazara/Platform/Win32/CursorImpl.cpp | 2 +- src/Nazara/Platform/Win32/CursorImpl.hpp | 2 +- src/Nazara/Platform/Win32/IconImpl.cpp | 2 +- src/Nazara/Platform/Win32/IconImpl.hpp | 2 +- src/Nazara/Platform/Win32/InputImpl.cpp | 2 +- src/Nazara/Platform/Win32/InputImpl.hpp | 2 +- src/Nazara/Platform/Win32/VideoModeImpl.cpp | 2 +- src/Nazara/Platform/Win32/VideoModeImpl.hpp | 2 +- src/Nazara/Platform/Win32/WindowImpl.cpp | 2 +- src/Nazara/Platform/Win32/WindowImpl.hpp | 2 +- src/Nazara/Platform/Window.cpp | 2 +- src/Nazara/Platform/X11/ScopedXCB.inl | 2 +- src/Nazara/Renderer/Debug/NewOverload.cpp | 2 +- src/Nazara/Renderer/HardwareBuffer.hpp | 2 +- src/Nazara/Renderer/RenderWindow.cpp | 2 +- src/Nazara/Renderer/Renderer.cpp | 2 +- src/Nazara/Renderer/ShaderAst.cpp | 2 +- src/Nazara/Renderer/Win32/ContextImpl.hpp | 2 +- src/Nazara/Utility/AbstractAtlas.cpp | 2 +- src/Nazara/Utility/AbstractBuffer.cpp | 2 +- src/Nazara/Utility/AbstractImage.cpp | 2 +- src/Nazara/Utility/AbstractTextDrawer.cpp | 2 +- src/Nazara/Utility/AlgorithmUtility.cpp | 2 +- src/Nazara/Utility/Animation.cpp | 2 +- src/Nazara/Utility/Buffer.cpp | 2 +- src/Nazara/Utility/Debug/NewOverload.cpp | 2 +- src/Nazara/Utility/Font.cpp | 2 +- src/Nazara/Utility/FontData.cpp | 2 +- src/Nazara/Utility/Formats/DDSConstants.cpp | 2 +- src/Nazara/Utility/Formats/DDSLoader.cpp | 2 +- src/Nazara/Utility/Formats/DDSLoader.hpp | 2 +- src/Nazara/Utility/Formats/FreeTypeLoader.cpp | 2 +- src/Nazara/Utility/Formats/FreeTypeLoader.hpp | 2 +- src/Nazara/Utility/Formats/MD2Constants.cpp | 2 +- src/Nazara/Utility/Formats/MD2Constants.hpp | 2 +- src/Nazara/Utility/Formats/MD2Loader.cpp | 2 +- src/Nazara/Utility/Formats/MD2Loader.hpp | 2 +- src/Nazara/Utility/Formats/MD5AnimLoader.cpp | 2 +- src/Nazara/Utility/Formats/MD5AnimLoader.hpp | 2 +- src/Nazara/Utility/Formats/MD5AnimParser.cpp | 2 +- src/Nazara/Utility/Formats/MD5MeshLoader.cpp | 2 +- src/Nazara/Utility/Formats/MD5MeshLoader.hpp | 2 +- src/Nazara/Utility/Formats/MD5MeshParser.cpp | 2 +- src/Nazara/Utility/Formats/MTLParser.cpp | 2 +- src/Nazara/Utility/Formats/OBJLoader.cpp | 2 +- src/Nazara/Utility/Formats/OBJLoader.hpp | 2 +- src/Nazara/Utility/Formats/OBJParser.cpp | 2 +- src/Nazara/Utility/Formats/OBJSaver.cpp | 2 +- src/Nazara/Utility/Formats/OBJSaver.hpp | 2 +- src/Nazara/Utility/Formats/PCXLoader.cpp | 2 +- src/Nazara/Utility/Formats/PCXLoader.hpp | 2 +- src/Nazara/Utility/Formats/STBLoader.cpp | 2 +- src/Nazara/Utility/Formats/STBLoader.hpp | 2 +- src/Nazara/Utility/Formats/STBSaver.cpp | 2 +- src/Nazara/Utility/Formats/STBSaver.hpp | 2 +- src/Nazara/Utility/GuillotineImageAtlas.cpp | 2 +- src/Nazara/Utility/Image.cpp | 2 +- src/Nazara/Utility/IndexBuffer.cpp | 2 +- src/Nazara/Utility/IndexMapper.cpp | 2 +- src/Nazara/Utility/Joint.cpp | 2 +- src/Nazara/Utility/Mesh.cpp | 2 +- src/Nazara/Utility/Node.cpp | 2 +- src/Nazara/Utility/PixelFormat.cpp | 2 +- src/Nazara/Utility/RichTextDrawer.cpp | 2 +- src/Nazara/Utility/SimpleTextDrawer.cpp | 2 +- src/Nazara/Utility/SkeletalMesh.cpp | 2 +- src/Nazara/Utility/Skeleton.cpp | 2 +- src/Nazara/Utility/SoftwareBuffer.cpp | 2 +- src/Nazara/Utility/StaticMesh.cpp | 2 +- src/Nazara/Utility/SubMesh.cpp | 2 +- src/Nazara/Utility/TriangleIterator.cpp | 2 +- src/Nazara/Utility/UniformBuffer.cpp | 2 +- src/Nazara/Utility/Utility.cpp | 2 +- src/Nazara/Utility/VertexBuffer.cpp | 2 +- src/Nazara/Utility/VertexDeclaration.cpp | 2 +- src/Nazara/Utility/VertexMapper.cpp | 2 +- src/Nazara/VulkanRenderer/Export.cpp | 2 +- src/Nazara/VulkanRenderer/Utils_VulkanRenderer.cpp | 2 +- src/Nazara/VulkanRenderer/VkRenderTarget.cpp | 2 +- src/Nazara/VulkanRenderer/Vulkan.cpp | 2 +- src/Nazara/VulkanRenderer/VulkanBuffer.cpp | 2 +- src/Nazara/VulkanRenderer/VulkanDevice.cpp | 2 +- src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp | 2 +- src/Nazara/VulkanRenderer/VulkanRenderer.cpp | 2 +- src/Nazara/VulkanRenderer/VulkanShaderStage.cpp | 2 +- src/Nazara/VulkanRenderer/VulkanSurface.cpp | 2 +- src/Nazara/VulkanRenderer/Wrapper/CommandPool.cpp | 2 +- src/Nazara/VulkanRenderer/Wrapper/DescriptorPool.cpp | 2 +- src/Nazara/VulkanRenderer/Wrapper/Device.cpp | 2 +- src/Nazara/VulkanRenderer/Wrapper/Instance.cpp | 2 +- src/Nazara/VulkanRenderer/Wrapper/Loader.cpp | 2 +- src/NazaraSDK/Application.cpp | 2 +- src/NazaraSDK/BaseComponent.cpp | 2 +- src/NazaraSDK/BaseSystem.cpp | 2 +- src/NazaraSDK/BaseWidget.cpp | 2 +- src/NazaraSDK/Canvas.cpp | 2 +- src/NazaraSDK/Components/CameraComponent.cpp | 2 +- src/NazaraSDK/Components/CollisionComponent2D.cpp | 2 +- src/NazaraSDK/Components/CollisionComponent3D.cpp | 2 +- src/NazaraSDK/Components/ConstraintComponent2D.cpp | 2 +- src/NazaraSDK/Components/DebugComponent.cpp | 2 +- src/NazaraSDK/Components/GraphicsComponent.cpp | 2 +- src/NazaraSDK/Components/LifetimeComponent.cpp | 2 +- src/NazaraSDK/Components/LightComponent.cpp | 2 +- src/NazaraSDK/Components/ListenerComponent.cpp | 2 +- src/NazaraSDK/Components/NodeComponent.cpp | 2 +- src/NazaraSDK/Components/ParticleEmitterComponent.cpp | 2 +- src/NazaraSDK/Components/ParticleGroupComponent.cpp | 2 +- src/NazaraSDK/Components/PhysicsComponent2D.cpp | 2 +- src/NazaraSDK/Components/PhysicsComponent3D.cpp | 2 +- src/NazaraSDK/Components/VelocityComponent.cpp | 2 +- src/NazaraSDK/Console.cpp | 2 +- src/NazaraSDK/Entity.cpp | 2 +- src/NazaraSDK/EntityList.cpp | 2 +- src/NazaraSDK/LuaBinding_Renderer.cpp | 2 +- src/NazaraSDK/LuaBinding_SDK.cpp | 2 +- src/NazaraSDK/Sdk.cpp | 2 +- src/NazaraSDK/State.cpp | 2 +- src/NazaraSDK/Systems/DebugSystem.cpp | 2 +- src/NazaraSDK/Systems/LifetimeSystem.cpp | 2 +- src/NazaraSDK/Systems/ListenerSystem.cpp | 2 +- src/NazaraSDK/Systems/ParticleSystem.cpp | 2 +- src/NazaraSDK/Systems/PhysicsSystem2D.cpp | 2 +- src/NazaraSDK/Systems/PhysicsSystem3D.cpp | 2 +- src/NazaraSDK/Systems/RenderSystem.cpp | 2 +- src/NazaraSDK/Systems/VelocitySystem.cpp | 2 +- src/NazaraSDK/Widgets/AbstractTextAreaWidget.cpp | 2 +- src/NazaraSDK/Widgets/BoxLayout.cpp | 2 +- src/NazaraSDK/Widgets/ButtonWidget.cpp | 2 +- src/NazaraSDK/Widgets/LabelWidget.cpp | 2 +- src/NazaraSDK/Widgets/RichTextAreaWidget.cpp | 2 +- src/NazaraSDK/Widgets/ScrollAreaWidget.cpp | 2 +- src/NazaraSDK/Widgets/TextAreaWidget.cpp | 2 +- src/NazaraSDK/World.cpp | 2 +- 867 files changed, 867 insertions(+), 867 deletions(-) diff --git a/include/Nazara/Audio/Algorithm.hpp b/include/Nazara/Audio/Algorithm.hpp index de8fac319..830e6ead6 100644 --- a/include/Nazara/Audio/Algorithm.hpp +++ b/include/Nazara/Audio/Algorithm.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Audio/Algorithm.inl b/include/Nazara/Audio/Algorithm.inl index a2b5c5fe5..f7db75e77 100644 --- a/include/Nazara/Audio/Algorithm.inl +++ b/include/Nazara/Audio/Algorithm.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Audio/Audio.hpp b/include/Nazara/Audio/Audio.hpp index 848202970..3293bc451 100644 --- a/include/Nazara/Audio/Audio.hpp +++ b/include/Nazara/Audio/Audio.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Audio/ConfigCheck.hpp b/include/Nazara/Audio/ConfigCheck.hpp index e69257bd5..f6ec2db6b 100644 --- a/include/Nazara/Audio/ConfigCheck.hpp +++ b/include/Nazara/Audio/ConfigCheck.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Audio/Debug.hpp b/include/Nazara/Audio/Debug.hpp index 4ff3e269a..3b2806373 100644 --- a/include/Nazara/Audio/Debug.hpp +++ b/include/Nazara/Audio/Debug.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Audio/DebugOff.hpp b/include/Nazara/Audio/DebugOff.hpp index 557486b46..c8a8906e2 100644 --- a/include/Nazara/Audio/DebugOff.hpp +++ b/include/Nazara/Audio/DebugOff.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Audio/Enums.hpp b/include/Nazara/Audio/Enums.hpp index 80c4dd91f..e3e12b41b 100644 --- a/include/Nazara/Audio/Enums.hpp +++ b/include/Nazara/Audio/Enums.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Audio/Music.hpp b/include/Nazara/Audio/Music.hpp index 0f0acc1b7..dd7b00a10 100644 --- a/include/Nazara/Audio/Music.hpp +++ b/include/Nazara/Audio/Music.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Audio/OpenAL.hpp b/include/Nazara/Audio/OpenAL.hpp index 9688129e4..214f7a4bf 100644 --- a/include/Nazara/Audio/OpenAL.hpp +++ b/include/Nazara/Audio/OpenAL.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Audio/Sound.hpp b/include/Nazara/Audio/Sound.hpp index 1c1415dc8..535983bd8 100644 --- a/include/Nazara/Audio/Sound.hpp +++ b/include/Nazara/Audio/Sound.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Audio/SoundBuffer.hpp b/include/Nazara/Audio/SoundBuffer.hpp index 0a7ab4f63..ca9ce0036 100644 --- a/include/Nazara/Audio/SoundBuffer.hpp +++ b/include/Nazara/Audio/SoundBuffer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Audio/SoundBuffer.inl b/include/Nazara/Audio/SoundBuffer.inl index bb4168d2c..5bc73396d 100644 --- a/include/Nazara/Audio/SoundBuffer.inl +++ b/include/Nazara/Audio/SoundBuffer.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Audio/SoundEmitter.hpp b/include/Nazara/Audio/SoundEmitter.hpp index 725c6cf76..169567a0e 100644 --- a/include/Nazara/Audio/SoundEmitter.hpp +++ b/include/Nazara/Audio/SoundEmitter.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Audio/SoundStream.hpp b/include/Nazara/Audio/SoundStream.hpp index 89b229317..f1db5a98d 100644 --- a/include/Nazara/Audio/SoundStream.hpp +++ b/include/Nazara/Audio/SoundStream.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/AbstractHash.hpp b/include/Nazara/Core/AbstractHash.hpp index e99e174db..23a8739d0 100644 --- a/include/Nazara/Core/AbstractHash.hpp +++ b/include/Nazara/Core/AbstractHash.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/AbstractLogger.hpp b/include/Nazara/Core/AbstractLogger.hpp index 2bcc53e28..34a83f6ce 100644 --- a/include/Nazara/Core/AbstractLogger.hpp +++ b/include/Nazara/Core/AbstractLogger.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Algorithm.hpp b/include/Nazara/Core/Algorithm.hpp index d54984d7e..b1cef6a60 100644 --- a/include/Nazara/Core/Algorithm.hpp +++ b/include/Nazara/Core/Algorithm.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Algorithm.inl b/include/Nazara/Core/Algorithm.inl index 391e32326..b6f10b37b 100644 --- a/include/Nazara/Core/Algorithm.inl +++ b/include/Nazara/Core/Algorithm.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Bitset.hpp b/include/Nazara/Core/Bitset.hpp index 1ac7a74b2..08c8017a4 100644 --- a/include/Nazara/Core/Bitset.hpp +++ b/include/Nazara/Core/Bitset.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Bitset.inl b/include/Nazara/Core/Bitset.inl index e4fd9b69c..6100e5171 100644 --- a/include/Nazara/Core/Bitset.inl +++ b/include/Nazara/Core/Bitset.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ByteArray.hpp b/include/Nazara/Core/ByteArray.hpp index ac378b366..93acf5daa 100644 --- a/include/Nazara/Core/ByteArray.hpp +++ b/include/Nazara/Core/ByteArray.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ByteArray.inl b/include/Nazara/Core/ByteArray.inl index 5d6e823dc..738b5d924 100644 --- a/include/Nazara/Core/ByteArray.inl +++ b/include/Nazara/Core/ByteArray.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ByteArrayPool.hpp b/include/Nazara/Core/ByteArrayPool.hpp index e45ceee67..cb2f2ab9c 100644 --- a/include/Nazara/Core/ByteArrayPool.hpp +++ b/include/Nazara/Core/ByteArrayPool.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ByteArrayPool.inl b/include/Nazara/Core/ByteArrayPool.inl index 82cf8349c..709c631e7 100644 --- a/include/Nazara/Core/ByteArrayPool.inl +++ b/include/Nazara/Core/ByteArrayPool.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ByteStream.hpp b/include/Nazara/Core/ByteStream.hpp index 6c2069895..f56c58dde 100644 --- a/include/Nazara/Core/ByteStream.hpp +++ b/include/Nazara/Core/ByteStream.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ByteStream.inl b/include/Nazara/Core/ByteStream.inl index c52ec0274..07f45e14b 100644 --- a/include/Nazara/Core/ByteStream.inl +++ b/include/Nazara/Core/ByteStream.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/CallOnExit.hpp b/include/Nazara/Core/CallOnExit.hpp index c4d90e171..2c67c3347 100644 --- a/include/Nazara/Core/CallOnExit.hpp +++ b/include/Nazara/Core/CallOnExit.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/CallOnExit.inl b/include/Nazara/Core/CallOnExit.inl index d4c5e393c..874369796 100644 --- a/include/Nazara/Core/CallOnExit.inl +++ b/include/Nazara/Core/CallOnExit.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Clock.hpp b/include/Nazara/Core/Clock.hpp index f37f78a52..d3e6862db 100644 --- a/include/Nazara/Core/Clock.hpp +++ b/include/Nazara/Core/Clock.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Color.hpp b/include/Nazara/Core/Color.hpp index 16977c2e0..13efb3fa3 100644 --- a/include/Nazara/Core/Color.hpp +++ b/include/Nazara/Core/Color.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Color.inl b/include/Nazara/Core/Color.inl index ace951dd0..bfcd3ab1a 100644 --- a/include/Nazara/Core/Color.inl +++ b/include/Nazara/Core/Color.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ConfigCheck.hpp b/include/Nazara/Core/ConfigCheck.hpp index 0e3b1e66e..fa53bfa1a 100644 --- a/include/Nazara/Core/ConfigCheck.hpp +++ b/include/Nazara/Core/ConfigCheck.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Core.hpp b/include/Nazara/Core/Core.hpp index e5d8e2705..2542f4a10 100644 --- a/include/Nazara/Core/Core.hpp +++ b/include/Nazara/Core/Core.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Debug.hpp b/include/Nazara/Core/Debug.hpp index 3a3d0444c..fd30666d0 100644 --- a/include/Nazara/Core/Debug.hpp +++ b/include/Nazara/Core/Debug.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Debug/NewRedefinition.hpp b/include/Nazara/Core/Debug/NewRedefinition.hpp index 06245f378..e738d3c30 100644 --- a/include/Nazara/Core/Debug/NewRedefinition.hpp +++ b/include/Nazara/Core/Debug/NewRedefinition.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/DebugOff.hpp b/include/Nazara/Core/DebugOff.hpp index 931fa629d..ffdd9fc52 100644 --- a/include/Nazara/Core/DebugOff.hpp +++ b/include/Nazara/Core/DebugOff.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/DynLib.hpp b/include/Nazara/Core/DynLib.hpp index 71730d6e1..967c060e9 100644 --- a/include/Nazara/Core/DynLib.hpp +++ b/include/Nazara/Core/DynLib.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/EmptyStream.hpp b/include/Nazara/Core/EmptyStream.hpp index da66ca329..84a60d024 100644 --- a/include/Nazara/Core/EmptyStream.hpp +++ b/include/Nazara/Core/EmptyStream.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/EmptyStream.inl b/include/Nazara/Core/EmptyStream.inl index 4da4db08d..88e421cdc 100644 --- a/include/Nazara/Core/EmptyStream.inl +++ b/include/Nazara/Core/EmptyStream.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2019 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Endianness.hpp b/include/Nazara/Core/Endianness.hpp index c76836b25..aaadb75c0 100644 --- a/include/Nazara/Core/Endianness.hpp +++ b/include/Nazara/Core/Endianness.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Endianness.inl b/include/Nazara/Core/Endianness.inl index 3ef527105..b3eca0b09 100644 --- a/include/Nazara/Core/Endianness.inl +++ b/include/Nazara/Core/Endianness.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Enums.hpp b/include/Nazara/Core/Enums.hpp index fd171fc86..d69e75e72 100644 --- a/include/Nazara/Core/Enums.hpp +++ b/include/Nazara/Core/Enums.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Error.hpp b/include/Nazara/Core/Error.hpp index 16c7d6ca7..c2562af9a 100644 --- a/include/Nazara/Core/Error.hpp +++ b/include/Nazara/Core/Error.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ErrorFlags.hpp b/include/Nazara/Core/ErrorFlags.hpp index 41e33ff82..abcabbfc5 100644 --- a/include/Nazara/Core/ErrorFlags.hpp +++ b/include/Nazara/Core/ErrorFlags.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/File.hpp b/include/Nazara/Core/File.hpp index 10e37a31b..2432359b7 100644 --- a/include/Nazara/Core/File.hpp +++ b/include/Nazara/Core/File.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/File.inl b/include/Nazara/Core/File.inl index d23daf953..7552317ab 100644 --- a/include/Nazara/Core/File.inl +++ b/include/Nazara/Core/File.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/FileLogger.hpp b/include/Nazara/Core/FileLogger.hpp index 6ca049453..36a1ff9ce 100644 --- a/include/Nazara/Core/FileLogger.hpp +++ b/include/Nazara/Core/FileLogger.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Flags.hpp b/include/Nazara/Core/Flags.hpp index 3fa7d2741..36ff02f6b 100644 --- a/include/Nazara/Core/Flags.hpp +++ b/include/Nazara/Core/Flags.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Flags.inl b/include/Nazara/Core/Flags.inl index 2e1800ff8..36a001c4f 100644 --- a/include/Nazara/Core/Flags.inl +++ b/include/Nazara/Core/Flags.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Functor.hpp b/include/Nazara/Core/Functor.hpp index 17578474c..f25434b21 100644 --- a/include/Nazara/Core/Functor.hpp +++ b/include/Nazara/Core/Functor.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Functor.inl b/include/Nazara/Core/Functor.inl index ea7bdbad2..200320e78 100644 --- a/include/Nazara/Core/Functor.inl +++ b/include/Nazara/Core/Functor.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/GuillotineBinPack.hpp b/include/Nazara/Core/GuillotineBinPack.hpp index 8c82bb5d5..8b7e537f6 100644 --- a/include/Nazara/Core/GuillotineBinPack.hpp +++ b/include/Nazara/Core/GuillotineBinPack.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/HandledObject.hpp b/include/Nazara/Core/HandledObject.hpp index 390a4e612..50a283059 100644 --- a/include/Nazara/Core/HandledObject.hpp +++ b/include/Nazara/Core/HandledObject.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/Nazara/Core/HandledObject.inl b/include/Nazara/Core/HandledObject.inl index ed0115f5b..909828277 100644 --- a/include/Nazara/Core/HandledObject.inl +++ b/include/Nazara/Core/HandledObject.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/Nazara/Core/HardwareInfo.hpp b/include/Nazara/Core/HardwareInfo.hpp index dace7ed0c..5b3187038 100644 --- a/include/Nazara/Core/HardwareInfo.hpp +++ b/include/Nazara/Core/HardwareInfo.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Hash/CRC32.hpp b/include/Nazara/Core/Hash/CRC32.hpp index 63a8a60f7..19a906388 100644 --- a/include/Nazara/Core/Hash/CRC32.hpp +++ b/include/Nazara/Core/Hash/CRC32.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Hash/CRC64.hpp b/include/Nazara/Core/Hash/CRC64.hpp index c65eea4f9..43cf11047 100644 --- a/include/Nazara/Core/Hash/CRC64.hpp +++ b/include/Nazara/Core/Hash/CRC64.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Hash/Fletcher16.hpp b/include/Nazara/Core/Hash/Fletcher16.hpp index 54f44b901..e849c8e6c 100644 --- a/include/Nazara/Core/Hash/Fletcher16.hpp +++ b/include/Nazara/Core/Hash/Fletcher16.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine". // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Hash/MD5.hpp b/include/Nazara/Core/Hash/MD5.hpp index 61d960783..e689acd0c 100644 --- a/include/Nazara/Core/Hash/MD5.hpp +++ b/include/Nazara/Core/Hash/MD5.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine". // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Hash/SHA1.hpp b/include/Nazara/Core/Hash/SHA1.hpp index a8e63e563..b097af941 100644 --- a/include/Nazara/Core/Hash/SHA1.hpp +++ b/include/Nazara/Core/Hash/SHA1.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine". // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Hash/SHA224.hpp b/include/Nazara/Core/Hash/SHA224.hpp index 6e79c99d5..d51f9de4e 100644 --- a/include/Nazara/Core/Hash/SHA224.hpp +++ b/include/Nazara/Core/Hash/SHA224.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine". // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Hash/SHA256.hpp b/include/Nazara/Core/Hash/SHA256.hpp index 3b04986b6..7c8a616e2 100644 --- a/include/Nazara/Core/Hash/SHA256.hpp +++ b/include/Nazara/Core/Hash/SHA256.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine". // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Hash/SHA384.hpp b/include/Nazara/Core/Hash/SHA384.hpp index 4aaab3127..59509cae0 100644 --- a/include/Nazara/Core/Hash/SHA384.hpp +++ b/include/Nazara/Core/Hash/SHA384.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine". // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Hash/SHA512.hpp b/include/Nazara/Core/Hash/SHA512.hpp index 6523a2848..7551565a1 100644 --- a/include/Nazara/Core/Hash/SHA512.hpp +++ b/include/Nazara/Core/Hash/SHA512.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine". // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Hash/Whirlpool.hpp b/include/Nazara/Core/Hash/Whirlpool.hpp index a6a9a84d9..790a8d77b 100644 --- a/include/Nazara/Core/Hash/Whirlpool.hpp +++ b/include/Nazara/Core/Hash/Whirlpool.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine". // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Initializer.hpp b/include/Nazara/Core/Initializer.hpp index 06e90da59..64308c9ad 100644 --- a/include/Nazara/Core/Initializer.hpp +++ b/include/Nazara/Core/Initializer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Initializer.inl b/include/Nazara/Core/Initializer.inl index 0d886d0a0..89eaae526 100644 --- a/include/Nazara/Core/Initializer.inl +++ b/include/Nazara/Core/Initializer.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Log.hpp b/include/Nazara/Core/Log.hpp index c398b76a7..8c3799756 100644 --- a/include/Nazara/Core/Log.hpp +++ b/include/Nazara/Core/Log.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/MemoryHelper.hpp b/include/Nazara/Core/MemoryHelper.hpp index 9d4a71ee4..2410f9ce4 100644 --- a/include/Nazara/Core/MemoryHelper.hpp +++ b/include/Nazara/Core/MemoryHelper.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/MemoryHelper.inl b/include/Nazara/Core/MemoryHelper.inl index afe2eca6b..6aef769fb 100644 --- a/include/Nazara/Core/MemoryHelper.inl +++ b/include/Nazara/Core/MemoryHelper.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/MemoryManager.hpp b/include/Nazara/Core/MemoryManager.hpp index f0363781f..28ad83970 100644 --- a/include/Nazara/Core/MemoryManager.hpp +++ b/include/Nazara/Core/MemoryManager.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/MemoryPool.hpp b/include/Nazara/Core/MemoryPool.hpp index 101c29d3a..c6fa00ee3 100644 --- a/include/Nazara/Core/MemoryPool.hpp +++ b/include/Nazara/Core/MemoryPool.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/MemoryPool.inl b/include/Nazara/Core/MemoryPool.inl index 41443e38b..d6b7e9a60 100644 --- a/include/Nazara/Core/MemoryPool.inl +++ b/include/Nazara/Core/MemoryPool.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/MemoryStream.hpp b/include/Nazara/Core/MemoryStream.hpp index 808b410c8..d7504d0fa 100644 --- a/include/Nazara/Core/MemoryStream.hpp +++ b/include/Nazara/Core/MemoryStream.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/MemoryStream.inl b/include/Nazara/Core/MemoryStream.inl index e1369d819..1395b3137 100644 --- a/include/Nazara/Core/MemoryStream.inl +++ b/include/Nazara/Core/MemoryStream.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/MemoryView.hpp b/include/Nazara/Core/MemoryView.hpp index 7b5fbab45..ec13af018 100644 --- a/include/Nazara/Core/MemoryView.hpp +++ b/include/Nazara/Core/MemoryView.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/MovablePtr.hpp b/include/Nazara/Core/MovablePtr.hpp index f27e365e6..82cb3b62c 100644 --- a/include/Nazara/Core/MovablePtr.hpp +++ b/include/Nazara/Core/MovablePtr.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/MovablePtr.inl b/include/Nazara/Core/MovablePtr.inl index 80d342e4a..71745a6e8 100644 --- a/include/Nazara/Core/MovablePtr.inl +++ b/include/Nazara/Core/MovablePtr.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ObjectHandle.hpp b/include/Nazara/Core/ObjectHandle.hpp index e2e72f185..8c61ac660 100644 --- a/include/Nazara/Core/ObjectHandle.hpp +++ b/include/Nazara/Core/ObjectHandle.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ObjectHandle.inl b/include/Nazara/Core/ObjectHandle.inl index fc43fdffe..32b59d81b 100644 --- a/include/Nazara/Core/ObjectHandle.inl +++ b/include/Nazara/Core/ObjectHandle.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ObjectLibrary.hpp b/include/Nazara/Core/ObjectLibrary.hpp index 8528f358d..dedb4efe6 100644 --- a/include/Nazara/Core/ObjectLibrary.hpp +++ b/include/Nazara/Core/ObjectLibrary.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ObjectLibrary.inl b/include/Nazara/Core/ObjectLibrary.inl index 83686e04f..767f05f5c 100644 --- a/include/Nazara/Core/ObjectLibrary.inl +++ b/include/Nazara/Core/ObjectLibrary.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ObjectRef.hpp b/include/Nazara/Core/ObjectRef.hpp index cb100c554..686cb5242 100644 --- a/include/Nazara/Core/ObjectRef.hpp +++ b/include/Nazara/Core/ObjectRef.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ObjectRef.inl b/include/Nazara/Core/ObjectRef.inl index 25ff82a95..f6ec6c44f 100644 --- a/include/Nazara/Core/ObjectRef.inl +++ b/include/Nazara/Core/ObjectRef.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/OffsetOf.hpp b/include/Nazara/Core/OffsetOf.hpp index 5c26aa870..2aa95fd81 100644 --- a/include/Nazara/Core/OffsetOf.hpp +++ b/include/Nazara/Core/OffsetOf.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ParameterList.hpp b/include/Nazara/Core/ParameterList.hpp index 4dba23207..0afe0f7dd 100644 --- a/include/Nazara/Core/ParameterList.hpp +++ b/include/Nazara/Core/ParameterList.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ParameterList.inl b/include/Nazara/Core/ParameterList.inl index 029d3d4f3..557951a46 100644 --- a/include/Nazara/Core/ParameterList.inl +++ b/include/Nazara/Core/ParameterList.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/PluginManager.hpp b/include/Nazara/Core/PluginManager.hpp index a13f1f0b0..3a8fce661 100644 --- a/include/Nazara/Core/PluginManager.hpp +++ b/include/Nazara/Core/PluginManager.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/PoolByteStream.hpp b/include/Nazara/Core/PoolByteStream.hpp index 63150290d..c07058c2d 100644 --- a/include/Nazara/Core/PoolByteStream.hpp +++ b/include/Nazara/Core/PoolByteStream.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/PoolByteStream.inl b/include/Nazara/Core/PoolByteStream.inl index d786c6a67..3fdb48a30 100644 --- a/include/Nazara/Core/PoolByteStream.inl +++ b/include/Nazara/Core/PoolByteStream.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Primitive.hpp b/include/Nazara/Core/Primitive.hpp index 7afcace47..3f3af285b 100644 --- a/include/Nazara/Core/Primitive.hpp +++ b/include/Nazara/Core/Primitive.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Primitive.inl b/include/Nazara/Core/Primitive.inl index 24d14e8f7..d9bd6f24c 100644 --- a/include/Nazara/Core/Primitive.inl +++ b/include/Nazara/Core/Primitive.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/PrimitiveList.hpp b/include/Nazara/Core/PrimitiveList.hpp index 34014de47..cee8c215b 100644 --- a/include/Nazara/Core/PrimitiveList.hpp +++ b/include/Nazara/Core/PrimitiveList.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/RefCounted.hpp b/include/Nazara/Core/RefCounted.hpp index a108653f7..d7b779977 100644 --- a/include/Nazara/Core/RefCounted.hpp +++ b/include/Nazara/Core/RefCounted.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Resource.hpp b/include/Nazara/Core/Resource.hpp index d1cc1bc2e..036903524 100644 --- a/include/Nazara/Core/Resource.hpp +++ b/include/Nazara/Core/Resource.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ResourceLoader.hpp b/include/Nazara/Core/ResourceLoader.hpp index c3a0918a9..97f9a8d83 100644 --- a/include/Nazara/Core/ResourceLoader.hpp +++ b/include/Nazara/Core/ResourceLoader.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ResourceLoader.inl b/include/Nazara/Core/ResourceLoader.inl index 65ae38803..baddafd4f 100644 --- a/include/Nazara/Core/ResourceLoader.inl +++ b/include/Nazara/Core/ResourceLoader.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ResourceManager.hpp b/include/Nazara/Core/ResourceManager.hpp index c8b5f8f68..70ad3a545 100644 --- a/include/Nazara/Core/ResourceManager.hpp +++ b/include/Nazara/Core/ResourceManager.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ResourceManager.inl b/include/Nazara/Core/ResourceManager.inl index 8da2c138e..992b3e081 100644 --- a/include/Nazara/Core/ResourceManager.inl +++ b/include/Nazara/Core/ResourceManager.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ResourceParameters.hpp b/include/Nazara/Core/ResourceParameters.hpp index 8ddbecec1..2d0483d0e 100644 --- a/include/Nazara/Core/ResourceParameters.hpp +++ b/include/Nazara/Core/ResourceParameters.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ResourceSaver.hpp b/include/Nazara/Core/ResourceSaver.hpp index 3a122013f..a863d8763 100644 --- a/include/Nazara/Core/ResourceSaver.hpp +++ b/include/Nazara/Core/ResourceSaver.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/ResourceSaver.inl b/include/Nazara/Core/ResourceSaver.inl index 57d038843..7686ce4d9 100644 --- a/include/Nazara/Core/ResourceSaver.inl +++ b/include/Nazara/Core/ResourceSaver.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/SerializationContext.hpp b/include/Nazara/Core/SerializationContext.hpp index 122fc41dc..9cd64f2fd 100644 --- a/include/Nazara/Core/SerializationContext.hpp +++ b/include/Nazara/Core/SerializationContext.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/SerializationContext.inl b/include/Nazara/Core/SerializationContext.inl index 4379f718d..0c3c71cb8 100644 --- a/include/Nazara/Core/SerializationContext.inl +++ b/include/Nazara/Core/SerializationContext.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Signal.hpp b/include/Nazara/Core/Signal.hpp index 973181e47..79f2eea5f 100644 --- a/include/Nazara/Core/Signal.hpp +++ b/include/Nazara/Core/Signal.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Signal.inl b/include/Nazara/Core/Signal.inl index 47d490a09..983d8c0c9 100644 --- a/include/Nazara/Core/Signal.inl +++ b/include/Nazara/Core/Signal.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/SparsePtr.hpp b/include/Nazara/Core/SparsePtr.hpp index c26602697..573feecf9 100644 --- a/include/Nazara/Core/SparsePtr.hpp +++ b/include/Nazara/Core/SparsePtr.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/SparsePtr.inl b/include/Nazara/Core/SparsePtr.inl index db3a60c33..55a898cd6 100644 --- a/include/Nazara/Core/SparsePtr.inl +++ b/include/Nazara/Core/SparsePtr.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/StackArray.hpp b/include/Nazara/Core/StackArray.hpp index 0a9f23faa..9e6a0ffaa 100644 --- a/include/Nazara/Core/StackArray.hpp +++ b/include/Nazara/Core/StackArray.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/StackArray.inl b/include/Nazara/Core/StackArray.inl index 7e46afc64..54ff249ec 100644 --- a/include/Nazara/Core/StackArray.inl +++ b/include/Nazara/Core/StackArray.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/StackVector.hpp b/include/Nazara/Core/StackVector.hpp index 6d01d8589..47b211d7d 100644 --- a/include/Nazara/Core/StackVector.hpp +++ b/include/Nazara/Core/StackVector.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/StackVector.inl b/include/Nazara/Core/StackVector.inl index 580ade499..e9cc99c20 100644 --- a/include/Nazara/Core/StackVector.inl +++ b/include/Nazara/Core/StackVector.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/StdLogger.hpp b/include/Nazara/Core/StdLogger.hpp index 5330d22ab..2df4d7539 100644 --- a/include/Nazara/Core/StdLogger.hpp +++ b/include/Nazara/Core/StdLogger.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Stream.hpp b/include/Nazara/Core/Stream.hpp index 128ccf099..3296a8a7c 100644 --- a/include/Nazara/Core/Stream.hpp +++ b/include/Nazara/Core/Stream.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Stream.inl b/include/Nazara/Core/Stream.inl index 5fb3186d6..0c014919d 100644 --- a/include/Nazara/Core/Stream.inl +++ b/include/Nazara/Core/Stream.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/String.hpp b/include/Nazara/Core/String.hpp index 42dacc191..53617ee95 100644 --- a/include/Nazara/Core/String.hpp +++ b/include/Nazara/Core/String.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/String.inl b/include/Nazara/Core/String.inl index eed2269d0..d66eb3d29 100644 --- a/include/Nazara/Core/String.inl +++ b/include/Nazara/Core/String.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/StringExt.hpp b/include/Nazara/Core/StringExt.hpp index f24c24305..c07f796c0 100644 --- a/include/Nazara/Core/StringExt.hpp +++ b/include/Nazara/Core/StringExt.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/StringExt.inl b/include/Nazara/Core/StringExt.inl index 069cded5f..72ce07a60 100644 --- a/include/Nazara/Core/StringExt.inl +++ b/include/Nazara/Core/StringExt.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/StringStream.hpp b/include/Nazara/Core/StringStream.hpp index 8a410a275..22864f0a1 100644 --- a/include/Nazara/Core/StringStream.hpp +++ b/include/Nazara/Core/StringStream.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/TaskScheduler.hpp b/include/Nazara/Core/TaskScheduler.hpp index ac79f16c9..695556210 100644 --- a/include/Nazara/Core/TaskScheduler.hpp +++ b/include/Nazara/Core/TaskScheduler.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/TaskScheduler.inl b/include/Nazara/Core/TaskScheduler.inl index 62b77447b..1450ef1ca 100644 --- a/include/Nazara/Core/TaskScheduler.inl +++ b/include/Nazara/Core/TaskScheduler.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/TypeTag.hpp b/include/Nazara/Core/TypeTag.hpp index c7f6c0f4e..e52366ba2 100644 --- a/include/Nazara/Core/TypeTag.hpp +++ b/include/Nazara/Core/TypeTag.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Unicode.hpp b/include/Nazara/Core/Unicode.hpp index f1c889ecb..cfd32ce92 100644 --- a/include/Nazara/Core/Unicode.hpp +++ b/include/Nazara/Core/Unicode.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Core/Updatable.hpp b/include/Nazara/Core/Updatable.hpp index 32657793a..4ee6057e5 100644 --- a/include/Nazara/Core/Updatable.hpp +++ b/include/Nazara/Core/Updatable.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core Module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/AbstractBackground.hpp b/include/Nazara/Graphics/AbstractBackground.hpp index fb0bc3df8..db969dd7e 100644 --- a/include/Nazara/Graphics/AbstractBackground.hpp +++ b/include/Nazara/Graphics/AbstractBackground.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/AbstractRenderQueue.hpp b/include/Nazara/Graphics/AbstractRenderQueue.hpp index 341d61607..a9cc391c2 100644 --- a/include/Nazara/Graphics/AbstractRenderQueue.hpp +++ b/include/Nazara/Graphics/AbstractRenderQueue.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/AbstractRenderTechnique.hpp b/include/Nazara/Graphics/AbstractRenderTechnique.hpp index ede4225f7..3460b16e6 100644 --- a/include/Nazara/Graphics/AbstractRenderTechnique.hpp +++ b/include/Nazara/Graphics/AbstractRenderTechnique.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/AbstractViewer.hpp b/include/Nazara/Graphics/AbstractViewer.hpp index 36547b1ec..06284ddf4 100644 --- a/include/Nazara/Graphics/AbstractViewer.hpp +++ b/include/Nazara/Graphics/AbstractViewer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/BasicRenderQueue.hpp b/include/Nazara/Graphics/BasicRenderQueue.hpp index 1be56b5fd..e6f0c4240 100644 --- a/include/Nazara/Graphics/BasicRenderQueue.hpp +++ b/include/Nazara/Graphics/BasicRenderQueue.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/BasicRenderQueue.inl b/include/Nazara/Graphics/BasicRenderQueue.inl index 14dde08dc..29eb9509d 100644 --- a/include/Nazara/Graphics/BasicRenderQueue.inl +++ b/include/Nazara/Graphics/BasicRenderQueue.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Billboard.hpp b/include/Nazara/Graphics/Billboard.hpp index 1a151ca69..9b75c0aa2 100644 --- a/include/Nazara/Graphics/Billboard.hpp +++ b/include/Nazara/Graphics/Billboard.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Billboard.inl b/include/Nazara/Graphics/Billboard.inl index be1a47918..13c232b88 100644 --- a/include/Nazara/Graphics/Billboard.inl +++ b/include/Nazara/Graphics/Billboard.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ColorBackground.hpp b/include/Nazara/Graphics/ColorBackground.hpp index 2f0fdd8fc..759af3a39 100644 --- a/include/Nazara/Graphics/ColorBackground.hpp +++ b/include/Nazara/Graphics/ColorBackground.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ColorBackground.inl b/include/Nazara/Graphics/ColorBackground.inl index 30d870365..bd32a1877 100644 --- a/include/Nazara/Graphics/ColorBackground.inl +++ b/include/Nazara/Graphics/ColorBackground.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ConfigCheck.hpp b/include/Nazara/Graphics/ConfigCheck.hpp index 8aa8164db..f72b91725 100644 --- a/include/Nazara/Graphics/ConfigCheck.hpp +++ b/include/Nazara/Graphics/ConfigCheck.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/CullingList.hpp b/include/Nazara/Graphics/CullingList.hpp index 7feb32362..1c6213bb7 100644 --- a/include/Nazara/Graphics/CullingList.hpp +++ b/include/Nazara/Graphics/CullingList.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/CullingList.inl b/include/Nazara/Graphics/CullingList.inl index 341508351..a5d553764 100644 --- a/include/Nazara/Graphics/CullingList.inl +++ b/include/Nazara/Graphics/CullingList.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Debug.hpp b/include/Nazara/Graphics/Debug.hpp index f20764d29..c7cd0cad5 100644 --- a/include/Nazara/Graphics/Debug.hpp +++ b/include/Nazara/Graphics/Debug.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DebugOff.hpp b/include/Nazara/Graphics/DebugOff.hpp index 325dc62f9..42bef4737 100644 --- a/include/Nazara/Graphics/DebugOff.hpp +++ b/include/Nazara/Graphics/DebugOff.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DeferredBloomPass.hpp b/include/Nazara/Graphics/DeferredBloomPass.hpp index c34f16534..b93083b61 100644 --- a/include/Nazara/Graphics/DeferredBloomPass.hpp +++ b/include/Nazara/Graphics/DeferredBloomPass.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DeferredDOFPass.hpp b/include/Nazara/Graphics/DeferredDOFPass.hpp index 4d5778dcd..fc06fade9 100644 --- a/include/Nazara/Graphics/DeferredDOFPass.hpp +++ b/include/Nazara/Graphics/DeferredDOFPass.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DeferredFXAAPass.hpp b/include/Nazara/Graphics/DeferredFXAAPass.hpp index 0b9c22494..0a5b389df 100644 --- a/include/Nazara/Graphics/DeferredFXAAPass.hpp +++ b/include/Nazara/Graphics/DeferredFXAAPass.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DeferredFinalPass.hpp b/include/Nazara/Graphics/DeferredFinalPass.hpp index 1407502a3..06b547a2d 100644 --- a/include/Nazara/Graphics/DeferredFinalPass.hpp +++ b/include/Nazara/Graphics/DeferredFinalPass.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DeferredFogPass.hpp b/include/Nazara/Graphics/DeferredFogPass.hpp index 5bf9e81f4..c5faecf7e 100644 --- a/include/Nazara/Graphics/DeferredFogPass.hpp +++ b/include/Nazara/Graphics/DeferredFogPass.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DeferredForwardPass.hpp b/include/Nazara/Graphics/DeferredForwardPass.hpp index 2e26dde03..f711a74b5 100644 --- a/include/Nazara/Graphics/DeferredForwardPass.hpp +++ b/include/Nazara/Graphics/DeferredForwardPass.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DeferredGeometryPass.hpp b/include/Nazara/Graphics/DeferredGeometryPass.hpp index 043378642..4c50241c8 100644 --- a/include/Nazara/Graphics/DeferredGeometryPass.hpp +++ b/include/Nazara/Graphics/DeferredGeometryPass.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DeferredPhongLightingPass.hpp b/include/Nazara/Graphics/DeferredPhongLightingPass.hpp index 76b826f92..3dcdbe9fe 100644 --- a/include/Nazara/Graphics/DeferredPhongLightingPass.hpp +++ b/include/Nazara/Graphics/DeferredPhongLightingPass.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DeferredProxyRenderQueue.hpp b/include/Nazara/Graphics/DeferredProxyRenderQueue.hpp index 98155b0fd..a0ce9c6a5 100644 --- a/include/Nazara/Graphics/DeferredProxyRenderQueue.hpp +++ b/include/Nazara/Graphics/DeferredProxyRenderQueue.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DeferredProxyRenderQueue.inl b/include/Nazara/Graphics/DeferredProxyRenderQueue.inl index e56545e0d..2f6e3da04 100644 --- a/include/Nazara/Graphics/DeferredProxyRenderQueue.inl +++ b/include/Nazara/Graphics/DeferredProxyRenderQueue.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DeferredRenderPass.hpp b/include/Nazara/Graphics/DeferredRenderPass.hpp index ca4cdce3d..217517d4c 100644 --- a/include/Nazara/Graphics/DeferredRenderPass.hpp +++ b/include/Nazara/Graphics/DeferredRenderPass.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DeferredRenderTechnique.hpp b/include/Nazara/Graphics/DeferredRenderTechnique.hpp index fc9588ae5..cca4cf166 100644 --- a/include/Nazara/Graphics/DeferredRenderTechnique.hpp +++ b/include/Nazara/Graphics/DeferredRenderTechnique.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DepthRenderQueue.hpp b/include/Nazara/Graphics/DepthRenderQueue.hpp index 10a00783e..c0f6b57e0 100644 --- a/include/Nazara/Graphics/DepthRenderQueue.hpp +++ b/include/Nazara/Graphics/DepthRenderQueue.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DepthRenderQueue.inl b/include/Nazara/Graphics/DepthRenderQueue.inl index 7646c76a7..2922736a1 100644 --- a/include/Nazara/Graphics/DepthRenderQueue.inl +++ b/include/Nazara/Graphics/DepthRenderQueue.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DepthRenderTechnique.hpp b/include/Nazara/Graphics/DepthRenderTechnique.hpp index 5ae883352..945f546b8 100644 --- a/include/Nazara/Graphics/DepthRenderTechnique.hpp +++ b/include/Nazara/Graphics/DepthRenderTechnique.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/DepthRenderTechnique.inl b/include/Nazara/Graphics/DepthRenderTechnique.inl index 9b32e7d42..811fb7c6b 100644 --- a/include/Nazara/Graphics/DepthRenderTechnique.inl +++ b/include/Nazara/Graphics/DepthRenderTechnique.inl @@ -1,3 +1,3 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Drawable.hpp b/include/Nazara/Graphics/Drawable.hpp index a8605a4cc..4970367a0 100644 --- a/include/Nazara/Graphics/Drawable.hpp +++ b/include/Nazara/Graphics/Drawable.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Enums.hpp b/include/Nazara/Graphics/Enums.hpp index 277d78a03..6a351494e 100644 --- a/include/Nazara/Graphics/Enums.hpp +++ b/include/Nazara/Graphics/Enums.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ForwardRenderTechnique.hpp b/include/Nazara/Graphics/ForwardRenderTechnique.hpp index f041e1246..caa340981 100644 --- a/include/Nazara/Graphics/ForwardRenderTechnique.hpp +++ b/include/Nazara/Graphics/ForwardRenderTechnique.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ForwardRenderTechnique.inl b/include/Nazara/Graphics/ForwardRenderTechnique.inl index 564da3d22..d76ae79dc 100644 --- a/include/Nazara/Graphics/ForwardRenderTechnique.inl +++ b/include/Nazara/Graphics/ForwardRenderTechnique.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Graphics.hpp b/include/Nazara/Graphics/Graphics.hpp index a44abdcfa..3e1bfdf2a 100644 --- a/include/Nazara/Graphics/Graphics.hpp +++ b/include/Nazara/Graphics/Graphics.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/GuillotineTextureAtlas.hpp b/include/Nazara/Graphics/GuillotineTextureAtlas.hpp index 318cf8655..fa38f205a 100644 --- a/include/Nazara/Graphics/GuillotineTextureAtlas.hpp +++ b/include/Nazara/Graphics/GuillotineTextureAtlas.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/InstancedRenderable.hpp b/include/Nazara/Graphics/InstancedRenderable.hpp index 9ec0d973f..fec1df25c 100644 --- a/include/Nazara/Graphics/InstancedRenderable.hpp +++ b/include/Nazara/Graphics/InstancedRenderable.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/InstancedRenderable.inl b/include/Nazara/Graphics/InstancedRenderable.inl index f54f9cebe..0aa0a03a5 100644 --- a/include/Nazara/Graphics/InstancedRenderable.inl +++ b/include/Nazara/Graphics/InstancedRenderable.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Light.hpp b/include/Nazara/Graphics/Light.hpp index 2f20f5762..8c9410d96 100644 --- a/include/Nazara/Graphics/Light.hpp +++ b/include/Nazara/Graphics/Light.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Light.inl b/include/Nazara/Graphics/Light.inl index f76bbe841..e3fb3f78f 100644 --- a/include/Nazara/Graphics/Light.inl +++ b/include/Nazara/Graphics/Light.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Material.hpp b/include/Nazara/Graphics/Material.hpp index 71aff5332..03fa145b7 100644 --- a/include/Nazara/Graphics/Material.hpp +++ b/include/Nazara/Graphics/Material.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Material.inl b/include/Nazara/Graphics/Material.inl index ac22ea266..e56d1675c 100644 --- a/include/Nazara/Graphics/Material.inl +++ b/include/Nazara/Graphics/Material.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/MaterialPipeline.hpp b/include/Nazara/Graphics/MaterialPipeline.hpp index ef3e1eafb..1f6575719 100644 --- a/include/Nazara/Graphics/MaterialPipeline.hpp +++ b/include/Nazara/Graphics/MaterialPipeline.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/MaterialPipeline.inl b/include/Nazara/Graphics/MaterialPipeline.inl index 2df585e28..7fe6f1bbb 100644 --- a/include/Nazara/Graphics/MaterialPipeline.inl +++ b/include/Nazara/Graphics/MaterialPipeline.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Model.hpp b/include/Nazara/Graphics/Model.hpp index 70be0d70c..3780bc1be 100644 --- a/include/Nazara/Graphics/Model.hpp +++ b/include/Nazara/Graphics/Model.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Model.inl b/include/Nazara/Graphics/Model.inl index 9c1809368..e7a909dba 100644 --- a/include/Nazara/Graphics/Model.inl +++ b/include/Nazara/Graphics/Model.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleController.hpp b/include/Nazara/Graphics/ParticleController.hpp index 3328958bf..566381b05 100644 --- a/include/Nazara/Graphics/ParticleController.hpp +++ b/include/Nazara/Graphics/ParticleController.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleDeclaration.hpp b/include/Nazara/Graphics/ParticleDeclaration.hpp index 89a7dfb32..2b370c3be 100644 --- a/include/Nazara/Graphics/ParticleDeclaration.hpp +++ b/include/Nazara/Graphics/ParticleDeclaration.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleDeclaration.inl b/include/Nazara/Graphics/ParticleDeclaration.inl index efbb4fd39..719bd38ca 100644 --- a/include/Nazara/Graphics/ParticleDeclaration.inl +++ b/include/Nazara/Graphics/ParticleDeclaration.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleEmitter.hpp b/include/Nazara/Graphics/ParticleEmitter.hpp index 7e7dfca31..eafd5255b 100644 --- a/include/Nazara/Graphics/ParticleEmitter.hpp +++ b/include/Nazara/Graphics/ParticleEmitter.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleFunctionController.hpp b/include/Nazara/Graphics/ParticleFunctionController.hpp index c9965c4ac..f46e09500 100644 --- a/include/Nazara/Graphics/ParticleFunctionController.hpp +++ b/include/Nazara/Graphics/ParticleFunctionController.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleFunctionController.inl b/include/Nazara/Graphics/ParticleFunctionController.inl index ae2b2ca6d..ee03ddf8e 100644 --- a/include/Nazara/Graphics/ParticleFunctionController.inl +++ b/include/Nazara/Graphics/ParticleFunctionController.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleFunctionGenerator.hpp b/include/Nazara/Graphics/ParticleFunctionGenerator.hpp index 70729c011..7075ccbdb 100644 --- a/include/Nazara/Graphics/ParticleFunctionGenerator.hpp +++ b/include/Nazara/Graphics/ParticleFunctionGenerator.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleFunctionGenerator.inl b/include/Nazara/Graphics/ParticleFunctionGenerator.inl index f52afaaf9..813f3a786 100644 --- a/include/Nazara/Graphics/ParticleFunctionGenerator.inl +++ b/include/Nazara/Graphics/ParticleFunctionGenerator.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleFunctionRenderer.hpp b/include/Nazara/Graphics/ParticleFunctionRenderer.hpp index 54c9fb176..bb6fd841e 100644 --- a/include/Nazara/Graphics/ParticleFunctionRenderer.hpp +++ b/include/Nazara/Graphics/ParticleFunctionRenderer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleFunctionRenderer.inl b/include/Nazara/Graphics/ParticleFunctionRenderer.inl index e51178b7a..414805aa2 100644 --- a/include/Nazara/Graphics/ParticleFunctionRenderer.inl +++ b/include/Nazara/Graphics/ParticleFunctionRenderer.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleGenerator.hpp b/include/Nazara/Graphics/ParticleGenerator.hpp index 795d1ca49..85c61405a 100644 --- a/include/Nazara/Graphics/ParticleGenerator.hpp +++ b/include/Nazara/Graphics/ParticleGenerator.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleGroup.hpp b/include/Nazara/Graphics/ParticleGroup.hpp index 1d6bdae89..ae91cc099 100644 --- a/include/Nazara/Graphics/ParticleGroup.hpp +++ b/include/Nazara/Graphics/ParticleGroup.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleGroup.inl b/include/Nazara/Graphics/ParticleGroup.inl index bc12fe145..645d31815 100644 --- a/include/Nazara/Graphics/ParticleGroup.inl +++ b/include/Nazara/Graphics/ParticleGroup.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleMapper.hpp b/include/Nazara/Graphics/ParticleMapper.hpp index a980d7bb8..642327b1d 100644 --- a/include/Nazara/Graphics/ParticleMapper.hpp +++ b/include/Nazara/Graphics/ParticleMapper.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleMapper.inl b/include/Nazara/Graphics/ParticleMapper.inl index b60eab4bf..69caaabad 100644 --- a/include/Nazara/Graphics/ParticleMapper.inl +++ b/include/Nazara/Graphics/ParticleMapper.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleRenderer.hpp b/include/Nazara/Graphics/ParticleRenderer.hpp index 0a076156e..0b1927e27 100644 --- a/include/Nazara/Graphics/ParticleRenderer.hpp +++ b/include/Nazara/Graphics/ParticleRenderer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/ParticleStruct.hpp b/include/Nazara/Graphics/ParticleStruct.hpp index 4e14ab9ca..a10fd1631 100644 --- a/include/Nazara/Graphics/ParticleStruct.hpp +++ b/include/Nazara/Graphics/ParticleStruct.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/RenderQueue.hpp b/include/Nazara/Graphics/RenderQueue.hpp index 0d1f1fb81..e6efd9ba3 100644 --- a/include/Nazara/Graphics/RenderQueue.hpp +++ b/include/Nazara/Graphics/RenderQueue.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/RenderQueue.inl b/include/Nazara/Graphics/RenderQueue.inl index 47ec03c98..cfa368a8a 100644 --- a/include/Nazara/Graphics/RenderQueue.inl +++ b/include/Nazara/Graphics/RenderQueue.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/RenderTechniques.hpp b/include/Nazara/Graphics/RenderTechniques.hpp index 3854af1d4..99f277467 100644 --- a/include/Nazara/Graphics/RenderTechniques.hpp +++ b/include/Nazara/Graphics/RenderTechniques.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Renderable.hpp b/include/Nazara/Graphics/Renderable.hpp index 22b76d423..f28df8dcc 100644 --- a/include/Nazara/Graphics/Renderable.hpp +++ b/include/Nazara/Graphics/Renderable.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Renderable.inl b/include/Nazara/Graphics/Renderable.inl index 4c572a1cb..c7f9d43a2 100644 --- a/include/Nazara/Graphics/Renderable.inl +++ b/include/Nazara/Graphics/Renderable.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/SceneData.hpp b/include/Nazara/Graphics/SceneData.hpp index d11ada35c..953d38ced 100644 --- a/include/Nazara/Graphics/SceneData.hpp +++ b/include/Nazara/Graphics/SceneData.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/SkeletalModel.hpp b/include/Nazara/Graphics/SkeletalModel.hpp index b7ed266e2..adaec3be1 100644 --- a/include/Nazara/Graphics/SkeletalModel.hpp +++ b/include/Nazara/Graphics/SkeletalModel.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/SkeletalModel.inl b/include/Nazara/Graphics/SkeletalModel.inl index 4bb2df2b6..70d550e67 100644 --- a/include/Nazara/Graphics/SkeletalModel.inl +++ b/include/Nazara/Graphics/SkeletalModel.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/SkinningManager.hpp b/include/Nazara/Graphics/SkinningManager.hpp index 34d578b3e..4cf24d0ad 100644 --- a/include/Nazara/Graphics/SkinningManager.hpp +++ b/include/Nazara/Graphics/SkinningManager.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/SkyboxBackground.hpp b/include/Nazara/Graphics/SkyboxBackground.hpp index 675c2c27a..3488742fb 100644 --- a/include/Nazara/Graphics/SkyboxBackground.hpp +++ b/include/Nazara/Graphics/SkyboxBackground.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/SkyboxBackground.inl b/include/Nazara/Graphics/SkyboxBackground.inl index 3379ca9d1..93a08ab90 100644 --- a/include/Nazara/Graphics/SkyboxBackground.inl +++ b/include/Nazara/Graphics/SkyboxBackground.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Sprite.hpp b/include/Nazara/Graphics/Sprite.hpp index cba7195df..7d94cb345 100644 --- a/include/Nazara/Graphics/Sprite.hpp +++ b/include/Nazara/Graphics/Sprite.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/Sprite.inl b/include/Nazara/Graphics/Sprite.inl index a00eae551..4fd39cced 100644 --- a/include/Nazara/Graphics/Sprite.inl +++ b/include/Nazara/Graphics/Sprite.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/TextSprite.hpp b/include/Nazara/Graphics/TextSprite.hpp index 1826aa21b..e6dabeab0 100644 --- a/include/Nazara/Graphics/TextSprite.hpp +++ b/include/Nazara/Graphics/TextSprite.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/TextSprite.inl b/include/Nazara/Graphics/TextSprite.inl index 97b17d888..06b3f14a4 100644 --- a/include/Nazara/Graphics/TextSprite.inl +++ b/include/Nazara/Graphics/TextSprite.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/TextureBackground.hpp b/include/Nazara/Graphics/TextureBackground.hpp index c74539e38..788968c47 100644 --- a/include/Nazara/Graphics/TextureBackground.hpp +++ b/include/Nazara/Graphics/TextureBackground.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/TextureBackground.inl b/include/Nazara/Graphics/TextureBackground.inl index 7686fa466..24ec19af8 100644 --- a/include/Nazara/Graphics/TextureBackground.inl +++ b/include/Nazara/Graphics/TextureBackground.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/TileMap.hpp b/include/Nazara/Graphics/TileMap.hpp index b096b5948..e1e105206 100644 --- a/include/Nazara/Graphics/TileMap.hpp +++ b/include/Nazara/Graphics/TileMap.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Graphics/TileMap.inl b/include/Nazara/Graphics/TileMap.inl index bb24ea3d4..d363844eb 100644 --- a/include/Nazara/Graphics/TileMap.inl +++ b/include/Nazara/Graphics/TileMap.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Algorithm.hpp b/include/Nazara/Math/Algorithm.hpp index 7bd77437d..0ba481f7f 100644 --- a/include/Nazara/Math/Algorithm.hpp +++ b/include/Nazara/Math/Algorithm.hpp @@ -1,5 +1,5 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Algorithm.inl b/include/Nazara/Math/Algorithm.inl index 5a7bfb8fc..6b06196fa 100644 --- a/include/Nazara/Math/Algorithm.inl +++ b/include/Nazara/Math/Algorithm.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Angle.hpp b/include/Nazara/Math/Angle.hpp index 64e7ad878..a8ec44641 100644 --- a/include/Nazara/Math/Angle.hpp +++ b/include/Nazara/Math/Angle.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Angle.inl b/include/Nazara/Math/Angle.inl index 036ed5943..61d334ecf 100644 --- a/include/Nazara/Math/Angle.inl +++ b/include/Nazara/Math/Angle.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/BoundingVolume.hpp b/include/Nazara/Math/BoundingVolume.hpp index 235259b2e..1daf84281 100644 --- a/include/Nazara/Math/BoundingVolume.hpp +++ b/include/Nazara/Math/BoundingVolume.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/BoundingVolume.inl b/include/Nazara/Math/BoundingVolume.inl index 5d80e2730..12dbf8ed8 100644 --- a/include/Nazara/Math/BoundingVolume.inl +++ b/include/Nazara/Math/BoundingVolume.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Box.hpp b/include/Nazara/Math/Box.hpp index e9e57c8f0..d43378ce7 100644 --- a/include/Nazara/Math/Box.hpp +++ b/include/Nazara/Math/Box.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Box.inl b/include/Nazara/Math/Box.inl index 6055b3444..5dc03837c 100644 --- a/include/Nazara/Math/Box.inl +++ b/include/Nazara/Math/Box.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Enums.hpp b/include/Nazara/Math/Enums.hpp index 78f36942b..2c51092b3 100644 --- a/include/Nazara/Math/Enums.hpp +++ b/include/Nazara/Math/Enums.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/EulerAngles.hpp b/include/Nazara/Math/EulerAngles.hpp index 503a0fb94..85ed23ebb 100644 --- a/include/Nazara/Math/EulerAngles.hpp +++ b/include/Nazara/Math/EulerAngles.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/EulerAngles.inl b/include/Nazara/Math/EulerAngles.inl index 00f78bf27..7a0dac44f 100644 --- a/include/Nazara/Math/EulerAngles.inl +++ b/include/Nazara/Math/EulerAngles.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Frustum.hpp b/include/Nazara/Math/Frustum.hpp index f1b37811a..9e893a091 100644 --- a/include/Nazara/Math/Frustum.hpp +++ b/include/Nazara/Math/Frustum.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Frustum.inl b/include/Nazara/Math/Frustum.inl index 36a13a316..51203b751 100644 --- a/include/Nazara/Math/Frustum.inl +++ b/include/Nazara/Math/Frustum.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Matrix4.hpp b/include/Nazara/Math/Matrix4.hpp index 3ed2cd717..bcb51c378 100644 --- a/include/Nazara/Math/Matrix4.hpp +++ b/include/Nazara/Math/Matrix4.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Matrix4.inl b/include/Nazara/Math/Matrix4.inl index 1f2f58a17..a74391437 100644 --- a/include/Nazara/Math/Matrix4.inl +++ b/include/Nazara/Math/Matrix4.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/OrientedBox.hpp b/include/Nazara/Math/OrientedBox.hpp index dbc1820c5..ffa15782c 100644 --- a/include/Nazara/Math/OrientedBox.hpp +++ b/include/Nazara/Math/OrientedBox.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/OrientedBox.inl b/include/Nazara/Math/OrientedBox.inl index 7e561eb41..ee1eab23a 100644 --- a/include/Nazara/Math/OrientedBox.inl +++ b/include/Nazara/Math/OrientedBox.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Plane.hpp b/include/Nazara/Math/Plane.hpp index 0f0dbd5f0..24ddf7be5 100644 --- a/include/Nazara/Math/Plane.hpp +++ b/include/Nazara/Math/Plane.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Plane.inl b/include/Nazara/Math/Plane.inl index 7430b4dca..4a71f7f84 100644 --- a/include/Nazara/Math/Plane.inl +++ b/include/Nazara/Math/Plane.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Rect.hpp b/include/Nazara/Math/Rect.hpp index 58e6ed677..0934d2968 100644 --- a/include/Nazara/Math/Rect.hpp +++ b/include/Nazara/Math/Rect.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Rect.inl b/include/Nazara/Math/Rect.inl index 20181a763..18411fbd9 100644 --- a/include/Nazara/Math/Rect.inl +++ b/include/Nazara/Math/Rect.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Sphere.hpp b/include/Nazara/Math/Sphere.hpp index 762a276dc..f07eb8f4a 100644 --- a/include/Nazara/Math/Sphere.hpp +++ b/include/Nazara/Math/Sphere.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Sphere.inl b/include/Nazara/Math/Sphere.inl index c9ac33414..39f5a1433 100644 --- a/include/Nazara/Math/Sphere.inl +++ b/include/Nazara/Math/Sphere.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Vector2.hpp b/include/Nazara/Math/Vector2.hpp index fa41597a1..c9dba6bfa 100644 --- a/include/Nazara/Math/Vector2.hpp +++ b/include/Nazara/Math/Vector2.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Math/Vector2.inl b/include/Nazara/Math/Vector2.inl index d1724f838..e22e00bc2 100644 --- a/include/Nazara/Math/Vector2.inl +++ b/include/Nazara/Math/Vector2.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/AbstractSocket.hpp b/include/Nazara/Network/AbstractSocket.hpp index ca69d7713..74f5d6334 100644 --- a/include/Nazara/Network/AbstractSocket.hpp +++ b/include/Nazara/Network/AbstractSocket.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/AbstractSocket.inl b/include/Nazara/Network/AbstractSocket.inl index 9b7434812..bc5d16d31 100644 --- a/include/Nazara/Network/AbstractSocket.inl +++ b/include/Nazara/Network/AbstractSocket.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/Algorithm.hpp b/include/Nazara/Network/Algorithm.hpp index c2306ac5c..1b28fb747 100644 --- a/include/Nazara/Network/Algorithm.hpp +++ b/include/Nazara/Network/Algorithm.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/Algorithm.inl b/include/Nazara/Network/Algorithm.inl index 4cba24136..6fff88eef 100644 --- a/include/Nazara/Network/Algorithm.inl +++ b/include/Nazara/Network/Algorithm.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/ConfigCheck.hpp b/include/Nazara/Network/ConfigCheck.hpp index c17f870dc..5745be1d8 100644 --- a/include/Nazara/Network/ConfigCheck.hpp +++ b/include/Nazara/Network/ConfigCheck.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/Debug.hpp b/include/Nazara/Network/Debug.hpp index 40f5296fa..25cfbf44f 100644 --- a/include/Nazara/Network/Debug.hpp +++ b/include/Nazara/Network/Debug.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/DebugOff.hpp b/include/Nazara/Network/DebugOff.hpp index d6bf6d17f..498823705 100644 --- a/include/Nazara/Network/DebugOff.hpp +++ b/include/Nazara/Network/DebugOff.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/ENetCompressor.hpp b/include/Nazara/Network/ENetCompressor.hpp index 27bccdace..49803673a 100644 --- a/include/Nazara/Network/ENetCompressor.hpp +++ b/include/Nazara/Network/ENetCompressor.hpp @@ -8,7 +8,7 @@ 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. */ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/ENetHost.hpp b/include/Nazara/Network/ENetHost.hpp index b6af25895..013a15e17 100644 --- a/include/Nazara/Network/ENetHost.hpp +++ b/include/Nazara/Network/ENetHost.hpp @@ -8,7 +8,7 @@ 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. */ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/ENetHost.inl b/include/Nazara/Network/ENetHost.inl index fadcc9fc4..283d55059 100644 --- a/include/Nazara/Network/ENetHost.inl +++ b/include/Nazara/Network/ENetHost.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/ENetPacket.hpp b/include/Nazara/Network/ENetPacket.hpp index 7054e6b45..a062ef164 100644 --- a/include/Nazara/Network/ENetPacket.hpp +++ b/include/Nazara/Network/ENetPacket.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/ENetPeer.hpp b/include/Nazara/Network/ENetPeer.hpp index 812b644cd..f59dceeaa 100644 --- a/include/Nazara/Network/ENetPeer.hpp +++ b/include/Nazara/Network/ENetPeer.hpp @@ -8,7 +8,7 @@ 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. */ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/ENetPeer.inl b/include/Nazara/Network/ENetPeer.inl index 0d7a96104..cc27d77f4 100644 --- a/include/Nazara/Network/ENetPeer.inl +++ b/include/Nazara/Network/ENetPeer.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/ENetProtocol.hpp b/include/Nazara/Network/ENetProtocol.hpp index d7312ee8f..e91768d13 100644 --- a/include/Nazara/Network/ENetProtocol.hpp +++ b/include/Nazara/Network/ENetProtocol.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/ENetProtocol.inl b/include/Nazara/Network/ENetProtocol.inl index b854f26c8..416b93258 100644 --- a/include/Nazara/Network/ENetProtocol.inl +++ b/include/Nazara/Network/ENetProtocol.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/Enums.hpp b/include/Nazara/Network/Enums.hpp index dc082deba..7a7348407 100644 --- a/include/Nazara/Network/Enums.hpp +++ b/include/Nazara/Network/Enums.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/IpAddress.hpp b/include/Nazara/Network/IpAddress.hpp index 9ef8823e7..7897bc6c5 100644 --- a/include/Nazara/Network/IpAddress.hpp +++ b/include/Nazara/Network/IpAddress.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/IpAddress.inl b/include/Nazara/Network/IpAddress.inl index 7e59099d2..c75b5fcff 100644 --- a/include/Nazara/Network/IpAddress.inl +++ b/include/Nazara/Network/IpAddress.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/NetBuffer.hpp b/include/Nazara/Network/NetBuffer.hpp index d3a23bda3..0605de5a1 100644 --- a/include/Nazara/Network/NetBuffer.hpp +++ b/include/Nazara/Network/NetBuffer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/NetPacket.hpp b/include/Nazara/Network/NetPacket.hpp index be515b81a..53920fda0 100644 --- a/include/Nazara/Network/NetPacket.hpp +++ b/include/Nazara/Network/NetPacket.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/NetPacket.inl b/include/Nazara/Network/NetPacket.inl index b2a4a5f60..abd75bd14 100644 --- a/include/Nazara/Network/NetPacket.inl +++ b/include/Nazara/Network/NetPacket.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/Network.hpp b/include/Nazara/Network/Network.hpp index cf2e662f7..070199f60 100644 --- a/include/Nazara/Network/Network.hpp +++ b/include/Nazara/Network/Network.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/RUdpConnection.hpp b/include/Nazara/Network/RUdpConnection.hpp index 0740b4647..cd4192326 100644 --- a/include/Nazara/Network/RUdpConnection.hpp +++ b/include/Nazara/Network/RUdpConnection.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/RUdpConnection.inl b/include/Nazara/Network/RUdpConnection.inl index fa61ec136..1441572b8 100644 --- a/include/Nazara/Network/RUdpConnection.inl +++ b/include/Nazara/Network/RUdpConnection.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/RUdpMessage.hpp b/include/Nazara/Network/RUdpMessage.hpp index afd24e916..ce1c57771 100644 --- a/include/Nazara/Network/RUdpMessage.hpp +++ b/include/Nazara/Network/RUdpMessage.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/SocketHandle.hpp b/include/Nazara/Network/SocketHandle.hpp index d0e09c6a0..abbddfab3 100644 --- a/include/Nazara/Network/SocketHandle.hpp +++ b/include/Nazara/Network/SocketHandle.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/SocketPoller.hpp b/include/Nazara/Network/SocketPoller.hpp index bbe446c08..c2437eacc 100644 --- a/include/Nazara/Network/SocketPoller.hpp +++ b/include/Nazara/Network/SocketPoller.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/SocketPoller.inl b/include/Nazara/Network/SocketPoller.inl index 7c9dfe7cb..dcba8c1ff 100644 --- a/include/Nazara/Network/SocketPoller.inl +++ b/include/Nazara/Network/SocketPoller.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/TcpClient.hpp b/include/Nazara/Network/TcpClient.hpp index 13ab9a13b..40eb0e85c 100644 --- a/include/Nazara/Network/TcpClient.hpp +++ b/include/Nazara/Network/TcpClient.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/TcpClient.inl b/include/Nazara/Network/TcpClient.inl index 2d410d4f3..ca559e72f 100644 --- a/include/Nazara/Network/TcpClient.inl +++ b/include/Nazara/Network/TcpClient.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/TcpServer.hpp b/include/Nazara/Network/TcpServer.hpp index 6f26ed1f1..bd2369011 100644 --- a/include/Nazara/Network/TcpServer.hpp +++ b/include/Nazara/Network/TcpServer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/TcpServer.inl b/include/Nazara/Network/TcpServer.inl index c3aedbd0e..759ff0b80 100644 --- a/include/Nazara/Network/TcpServer.inl +++ b/include/Nazara/Network/TcpServer.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/UdpSocket.hpp b/include/Nazara/Network/UdpSocket.hpp index 47a3a3bbc..6fda01a23 100644 --- a/include/Nazara/Network/UdpSocket.hpp +++ b/include/Nazara/Network/UdpSocket.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Network/UdpSocket.inl b/include/Nazara/Network/UdpSocket.inl index 1879c1a8a..93fe841cf 100644 --- a/include/Nazara/Network/UdpSocket.inl +++ b/include/Nazara/Network/UdpSocket.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics2D/Arbiter2D.hpp b/include/Nazara/Physics2D/Arbiter2D.hpp index b8683e2eb..80e2764e6 100644 --- a/include/Nazara/Physics2D/Arbiter2D.hpp +++ b/include/Nazara/Physics2D/Arbiter2D.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics2D/Arbiter2D.inl b/include/Nazara/Physics2D/Arbiter2D.inl index 5e6b3edf6..425bb11cb 100644 --- a/include/Nazara/Physics2D/Arbiter2D.inl +++ b/include/Nazara/Physics2D/Arbiter2D.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics2D/Collider2D.hpp b/include/Nazara/Physics2D/Collider2D.hpp index d0f7fd608..b713e510d 100644 --- a/include/Nazara/Physics2D/Collider2D.hpp +++ b/include/Nazara/Physics2D/Collider2D.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics2D/Collider2D.inl b/include/Nazara/Physics2D/Collider2D.inl index 75696ce50..ad85b0304 100644 --- a/include/Nazara/Physics2D/Collider2D.inl +++ b/include/Nazara/Physics2D/Collider2D.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics2D/ConfigCheck.hpp b/include/Nazara/Physics2D/ConfigCheck.hpp index 288cfd59a..10dbe06ce 100644 --- a/include/Nazara/Physics2D/ConfigCheck.hpp +++ b/include/Nazara/Physics2D/ConfigCheck.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics2D/Constraint2D.hpp b/include/Nazara/Physics2D/Constraint2D.hpp index 13ee68c86..337ef63e3 100644 --- a/include/Nazara/Physics2D/Constraint2D.hpp +++ b/include/Nazara/Physics2D/Constraint2D.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics2D/Constraint2D.inl b/include/Nazara/Physics2D/Constraint2D.inl index 2ed7744f3..53c0d3312 100644 --- a/include/Nazara/Physics2D/Constraint2D.inl +++ b/include/Nazara/Physics2D/Constraint2D.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics2D/Debug.hpp b/include/Nazara/Physics2D/Debug.hpp index d98efc02d..4aa838dd3 100644 --- a/include/Nazara/Physics2D/Debug.hpp +++ b/include/Nazara/Physics2D/Debug.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics2D/DebugOff.hpp b/include/Nazara/Physics2D/DebugOff.hpp index 5cedb88f3..2c2c615dc 100644 --- a/include/Nazara/Physics2D/DebugOff.hpp +++ b/include/Nazara/Physics2D/DebugOff.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics2D/Enums.hpp b/include/Nazara/Physics2D/Enums.hpp index 8cbb73d39..e92d63e02 100644 --- a/include/Nazara/Physics2D/Enums.hpp +++ b/include/Nazara/Physics2D/Enums.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics2D/PhysWorld2D.hpp b/include/Nazara/Physics2D/PhysWorld2D.hpp index e6521b37a..b6a7fed8e 100644 --- a/include/Nazara/Physics2D/PhysWorld2D.hpp +++ b/include/Nazara/Physics2D/PhysWorld2D.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics2D/Physics2D.hpp b/include/Nazara/Physics2D/Physics2D.hpp index 16547ffdc..d96fc9f91 100644 --- a/include/Nazara/Physics2D/Physics2D.hpp +++ b/include/Nazara/Physics2D/Physics2D.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics2D/RigidBody2D.hpp b/include/Nazara/Physics2D/RigidBody2D.hpp index f80c0c8cf..1fd826da1 100644 --- a/include/Nazara/Physics2D/RigidBody2D.hpp +++ b/include/Nazara/Physics2D/RigidBody2D.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics2D/RigidBody2D.inl b/include/Nazara/Physics2D/RigidBody2D.inl index 272c8fe30..5f03ccf9a 100644 --- a/include/Nazara/Physics2D/RigidBody2D.inl +++ b/include/Nazara/Physics2D/RigidBody2D.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics3D/Collider3D.hpp b/include/Nazara/Physics3D/Collider3D.hpp index 9dbfe126c..7c96fca8a 100644 --- a/include/Nazara/Physics3D/Collider3D.hpp +++ b/include/Nazara/Physics3D/Collider3D.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics3D/Collider3D.inl b/include/Nazara/Physics3D/Collider3D.inl index 3ded7d289..4caa926f1 100644 --- a/include/Nazara/Physics3D/Collider3D.inl +++ b/include/Nazara/Physics3D/Collider3D.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics3D/ConfigCheck.hpp b/include/Nazara/Physics3D/ConfigCheck.hpp index 7b882ef42..d5dbfeef3 100644 --- a/include/Nazara/Physics3D/ConfigCheck.hpp +++ b/include/Nazara/Physics3D/ConfigCheck.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics3D/Debug.hpp b/include/Nazara/Physics3D/Debug.hpp index 506b3a773..43b5baff9 100644 --- a/include/Nazara/Physics3D/Debug.hpp +++ b/include/Nazara/Physics3D/Debug.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics3D/DebugOff.hpp b/include/Nazara/Physics3D/DebugOff.hpp index 9804c567d..91841d58a 100644 --- a/include/Nazara/Physics3D/DebugOff.hpp +++ b/include/Nazara/Physics3D/DebugOff.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics3D/Enums.hpp b/include/Nazara/Physics3D/Enums.hpp index 12c754899..68b93454b 100644 --- a/include/Nazara/Physics3D/Enums.hpp +++ b/include/Nazara/Physics3D/Enums.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics3D/PhysWorld3D.hpp b/include/Nazara/Physics3D/PhysWorld3D.hpp index 129c2d89c..f985b0cc6 100644 --- a/include/Nazara/Physics3D/PhysWorld3D.hpp +++ b/include/Nazara/Physics3D/PhysWorld3D.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics3D/Physics3D.hpp b/include/Nazara/Physics3D/Physics3D.hpp index 2e1d98929..2aca1917b 100644 --- a/include/Nazara/Physics3D/Physics3D.hpp +++ b/include/Nazara/Physics3D/Physics3D.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Physics3D/RigidBody3D.hpp b/include/Nazara/Physics3D/RigidBody3D.hpp index a5c5a1956..fb47b5888 100644 --- a/include/Nazara/Physics3D/RigidBody3D.hpp +++ b/include/Nazara/Physics3D/RigidBody3D.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Platform/ConfigCheck.hpp b/include/Nazara/Platform/ConfigCheck.hpp index 2b58e4586..0c2bca36c 100644 --- a/include/Nazara/Platform/ConfigCheck.hpp +++ b/include/Nazara/Platform/ConfigCheck.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Platform/Cursor.hpp b/include/Nazara/Platform/Cursor.hpp index dc435cd94..52438123f 100644 --- a/include/Nazara/Platform/Cursor.hpp +++ b/include/Nazara/Platform/Cursor.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Platform/Cursor.inl b/include/Nazara/Platform/Cursor.inl index 5177faeea..12aceb908 100644 --- a/include/Nazara/Platform/Cursor.inl +++ b/include/Nazara/Platform/Cursor.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Platform/CursorController.hpp b/include/Nazara/Platform/CursorController.hpp index d27384d18..2fc68d623 100644 --- a/include/Nazara/Platform/CursorController.hpp +++ b/include/Nazara/Platform/CursorController.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Platform/CursorController.inl b/include/Nazara/Platform/CursorController.inl index 75260b66d..45b9393e1 100644 --- a/include/Nazara/Platform/CursorController.inl +++ b/include/Nazara/Platform/CursorController.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Platform/Debug.hpp b/include/Nazara/Platform/Debug.hpp index 94d6e9134..54c8be8db 100644 --- a/include/Nazara/Platform/Debug.hpp +++ b/include/Nazara/Platform/Debug.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Platform/DebugOff.hpp b/include/Nazara/Platform/DebugOff.hpp index d6072e479..bf6b093a3 100644 --- a/include/Nazara/Platform/DebugOff.hpp +++ b/include/Nazara/Platform/DebugOff.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Platform/Enums.hpp b/include/Nazara/Platform/Enums.hpp index 77b69f65e..f359abbcb 100644 --- a/include/Nazara/Platform/Enums.hpp +++ b/include/Nazara/Platform/Enums.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Platform/Event.hpp b/include/Nazara/Platform/Event.hpp index 02a842889..18eb50a79 100644 --- a/include/Nazara/Platform/Event.hpp +++ b/include/Nazara/Platform/Event.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Platform/EventHandler.hpp b/include/Nazara/Platform/EventHandler.hpp index 7404a26d6..dfbc7c431 100644 --- a/include/Nazara/Platform/EventHandler.hpp +++ b/include/Nazara/Platform/EventHandler.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Platform/EventHandler.inl b/include/Nazara/Platform/EventHandler.inl index 6cc31efe5..68bd41483 100644 --- a/include/Nazara/Platform/EventHandler.inl +++ b/include/Nazara/Platform/EventHandler.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Platform/Icon.hpp b/include/Nazara/Platform/Icon.hpp index 85f89a5f4..080a42171 100644 --- a/include/Nazara/Platform/Icon.hpp +++ b/include/Nazara/Platform/Icon.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Platform/Icon.inl b/include/Nazara/Platform/Icon.inl index d2b1a5318..9dc84932c 100644 --- a/include/Nazara/Platform/Icon.inl +++ b/include/Nazara/Platform/Icon.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Platform/Joystick.hpp b/include/Nazara/Platform/Joystick.hpp index a54f7c569..45cb5d10f 100644 --- a/include/Nazara/Platform/Joystick.hpp +++ b/include/Nazara/Platform/Joystick.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Platform/Keyboard.hpp b/include/Nazara/Platform/Keyboard.hpp index 24c5c4b4b..a8f3b58dd 100644 --- a/include/Nazara/Platform/Keyboard.hpp +++ b/include/Nazara/Platform/Keyboard.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Platform/Mouse.hpp b/include/Nazara/Platform/Mouse.hpp index 9a77179f9..3d4806296 100644 --- a/include/Nazara/Platform/Mouse.hpp +++ b/include/Nazara/Platform/Mouse.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Platform/Platform.hpp b/include/Nazara/Platform/Platform.hpp index 94a245220..80dbe676b 100644 --- a/include/Nazara/Platform/Platform.hpp +++ b/include/Nazara/Platform/Platform.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Platform/VideoMode.hpp b/include/Nazara/Platform/VideoMode.hpp index 663e5721b..64c96475f 100644 --- a/include/Nazara/Platform/VideoMode.hpp +++ b/include/Nazara/Platform/VideoMode.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Platform/Window.hpp b/include/Nazara/Platform/Window.hpp index 4cfff0bed..bdf4ba6a2 100644 --- a/include/Nazara/Platform/Window.hpp +++ b/include/Nazara/Platform/Window.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Platform/Window.inl b/include/Nazara/Platform/Window.inl index c18ebd26e..04a191a1e 100644 --- a/include/Nazara/Platform/Window.inl +++ b/include/Nazara/Platform/Window.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Platform/WindowHandle.hpp b/include/Nazara/Platform/WindowHandle.hpp index 88274f3f9..94d1795da 100644 --- a/include/Nazara/Platform/WindowHandle.hpp +++ b/include/Nazara/Platform/WindowHandle.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/ConfigCheck.hpp b/include/Nazara/Renderer/ConfigCheck.hpp index d8e677789..2cd2060fd 100644 --- a/include/Nazara/Renderer/ConfigCheck.hpp +++ b/include/Nazara/Renderer/ConfigCheck.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/Debug.hpp b/include/Nazara/Renderer/Debug.hpp index 22444ba98..3756acfbf 100644 --- a/include/Nazara/Renderer/Debug.hpp +++ b/include/Nazara/Renderer/Debug.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/DebugDrawer.hpp b/include/Nazara/Renderer/DebugDrawer.hpp index e6667e7a9..4a61fa2bd 100644 --- a/include/Nazara/Renderer/DebugDrawer.hpp +++ b/include/Nazara/Renderer/DebugDrawer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/DebugOff.hpp b/include/Nazara/Renderer/DebugOff.hpp index ecc9a1b92..0115eabf3 100644 --- a/include/Nazara/Renderer/DebugOff.hpp +++ b/include/Nazara/Renderer/DebugOff.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/Enums.hpp b/include/Nazara/Renderer/Enums.hpp index 9a18d8dbf..5a6463ed3 100644 --- a/include/Nazara/Renderer/Enums.hpp +++ b/include/Nazara/Renderer/Enums.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/GlslWriter.hpp b/include/Nazara/Renderer/GlslWriter.hpp index c6194845f..8a06a3fbe 100644 --- a/include/Nazara/Renderer/GlslWriter.hpp +++ b/include/Nazara/Renderer/GlslWriter.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/RenderBuffer.hpp b/include/Nazara/Renderer/RenderBuffer.hpp index a0a49159f..06304f2ca 100644 --- a/include/Nazara/Renderer/RenderBuffer.hpp +++ b/include/Nazara/Renderer/RenderBuffer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/RenderBuffer.inl b/include/Nazara/Renderer/RenderBuffer.inl index ecd250f63..eaab1900c 100644 --- a/include/Nazara/Renderer/RenderBuffer.inl +++ b/include/Nazara/Renderer/RenderBuffer.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/RenderDevice.hpp b/include/Nazara/Renderer/RenderDevice.hpp index 5df49c600..b1716090f 100644 --- a/include/Nazara/Renderer/RenderDevice.hpp +++ b/include/Nazara/Renderer/RenderDevice.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/RenderDevice.inl b/include/Nazara/Renderer/RenderDevice.inl index 7a62a60ea..48c394ee9 100644 --- a/include/Nazara/Renderer/RenderDevice.inl +++ b/include/Nazara/Renderer/RenderDevice.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/RenderDeviceInfo.hpp b/include/Nazara/Renderer/RenderDeviceInfo.hpp index a1e379c18..fd4924253 100644 --- a/include/Nazara/Renderer/RenderDeviceInfo.hpp +++ b/include/Nazara/Renderer/RenderDeviceInfo.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/RenderPipeline.hpp b/include/Nazara/Renderer/RenderPipeline.hpp index d78270ca2..fd3350637 100644 --- a/include/Nazara/Renderer/RenderPipeline.hpp +++ b/include/Nazara/Renderer/RenderPipeline.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/RenderPipeline.inl b/include/Nazara/Renderer/RenderPipeline.inl index 991e50a2c..e1a1526d4 100644 --- a/include/Nazara/Renderer/RenderPipeline.inl +++ b/include/Nazara/Renderer/RenderPipeline.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/RenderStates.hpp b/include/Nazara/Renderer/RenderStates.hpp index f1c0ff6cb..6d40197c2 100644 --- a/include/Nazara/Renderer/RenderStates.hpp +++ b/include/Nazara/Renderer/RenderStates.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/RenderStates.inl b/include/Nazara/Renderer/RenderStates.inl index 4d521e65c..2a1fc08fc 100644 --- a/include/Nazara/Renderer/RenderStates.inl +++ b/include/Nazara/Renderer/RenderStates.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/RenderSurface.hpp b/include/Nazara/Renderer/RenderSurface.hpp index 177730511..b9d585d77 100644 --- a/include/Nazara/Renderer/RenderSurface.hpp +++ b/include/Nazara/Renderer/RenderSurface.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/RenderSurface.inl b/include/Nazara/Renderer/RenderSurface.inl index 2d0103e88..12663e56b 100644 --- a/include/Nazara/Renderer/RenderSurface.inl +++ b/include/Nazara/Renderer/RenderSurface.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/RenderWindow.hpp b/include/Nazara/Renderer/RenderWindow.hpp index c5838456b..9c5b3a47f 100644 --- a/include/Nazara/Renderer/RenderWindow.hpp +++ b/include/Nazara/Renderer/RenderWindow.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/RenderWindowParameters.hpp b/include/Nazara/Renderer/RenderWindowParameters.hpp index a850a944b..4a32196c6 100644 --- a/include/Nazara/Renderer/RenderWindowParameters.hpp +++ b/include/Nazara/Renderer/RenderWindowParameters.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/Renderer.hpp b/include/Nazara/Renderer/Renderer.hpp index 1f14c04c0..2b4a4a175 100644 --- a/include/Nazara/Renderer/Renderer.hpp +++ b/include/Nazara/Renderer/Renderer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/Renderer.inl b/include/Nazara/Renderer/Renderer.inl index 25d22de23..a10535d53 100644 --- a/include/Nazara/Renderer/Renderer.inl +++ b/include/Nazara/Renderer/Renderer.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/Shader.hpp b/include/Nazara/Renderer/Shader.hpp index b169f32fc..06d195758 100644 --- a/include/Nazara/Renderer/Shader.hpp +++ b/include/Nazara/Renderer/Shader.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/ShaderAst.hpp b/include/Nazara/Renderer/ShaderAst.hpp index 856c5858c..549b45194 100644 --- a/include/Nazara/Renderer/ShaderAst.hpp +++ b/include/Nazara/Renderer/ShaderAst.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/ShaderAst.inl b/include/Nazara/Renderer/ShaderAst.inl index 35bdab9fe..2235c9a74 100644 --- a/include/Nazara/Renderer/ShaderAst.inl +++ b/include/Nazara/Renderer/ShaderAst.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/ShaderBuilder.hpp b/include/Nazara/Renderer/ShaderBuilder.hpp index 8b7b9a4df..79512e90f 100644 --- a/include/Nazara/Renderer/ShaderBuilder.hpp +++ b/include/Nazara/Renderer/ShaderBuilder.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/ShaderBuilder.inl b/include/Nazara/Renderer/ShaderBuilder.inl index 0de69b676..89fa14c35 100644 --- a/include/Nazara/Renderer/ShaderBuilder.inl +++ b/include/Nazara/Renderer/ShaderBuilder.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer/Texture.hpp b/include/Nazara/Renderer/Texture.hpp index 69b88f3bf..7dd8cad0a 100644 --- a/include/Nazara/Renderer/Texture.hpp +++ b/include/Nazara/Renderer/Texture.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/AbstractAtlas.hpp b/include/Nazara/Utility/AbstractAtlas.hpp index fc84cfa0e..dfb370af8 100644 --- a/include/Nazara/Utility/AbstractAtlas.hpp +++ b/include/Nazara/Utility/AbstractAtlas.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/AbstractBuffer.hpp b/include/Nazara/Utility/AbstractBuffer.hpp index a0f183218..a2d36ce2e 100644 --- a/include/Nazara/Utility/AbstractBuffer.hpp +++ b/include/Nazara/Utility/AbstractBuffer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/AbstractImage.hpp b/include/Nazara/Utility/AbstractImage.hpp index e40ed7a5e..d325f660f 100644 --- a/include/Nazara/Utility/AbstractImage.hpp +++ b/include/Nazara/Utility/AbstractImage.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/AbstractImage.inl b/include/Nazara/Utility/AbstractImage.inl index 98dbabfdd..772ba8418 100644 --- a/include/Nazara/Utility/AbstractImage.inl +++ b/include/Nazara/Utility/AbstractImage.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/AbstractTextDrawer.hpp b/include/Nazara/Utility/AbstractTextDrawer.hpp index e62338c61..a435ecc03 100644 --- a/include/Nazara/Utility/AbstractTextDrawer.hpp +++ b/include/Nazara/Utility/AbstractTextDrawer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/AbstractTextDrawer.inl b/include/Nazara/Utility/AbstractTextDrawer.inl index a10a16892..65f8b41f1 100644 --- a/include/Nazara/Utility/AbstractTextDrawer.inl +++ b/include/Nazara/Utility/AbstractTextDrawer.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Algorithm.hpp b/include/Nazara/Utility/Algorithm.hpp index 339b5c681..c2ae790ea 100644 --- a/include/Nazara/Utility/Algorithm.hpp +++ b/include/Nazara/Utility/Algorithm.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Algorithm.inl b/include/Nazara/Utility/Algorithm.inl index e3f1e8be3..e208d3021 100644 --- a/include/Nazara/Utility/Algorithm.inl +++ b/include/Nazara/Utility/Algorithm.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Animation.hpp b/include/Nazara/Utility/Animation.hpp index a1f8f7ffe..db4d4488e 100644 --- a/include/Nazara/Utility/Animation.hpp +++ b/include/Nazara/Utility/Animation.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Animation.inl b/include/Nazara/Utility/Animation.inl index d56733c57..074080565 100644 --- a/include/Nazara/Utility/Animation.inl +++ b/include/Nazara/Utility/Animation.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Buffer.hpp b/include/Nazara/Utility/Buffer.hpp index e125c63e9..5cc4f173f 100644 --- a/include/Nazara/Utility/Buffer.hpp +++ b/include/Nazara/Utility/Buffer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Buffer.inl b/include/Nazara/Utility/Buffer.inl index afeef1624..4b02b35b7 100644 --- a/include/Nazara/Utility/Buffer.inl +++ b/include/Nazara/Utility/Buffer.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/BufferMapper.hpp b/include/Nazara/Utility/BufferMapper.hpp index 4f80528fd..d0786ee41 100644 --- a/include/Nazara/Utility/BufferMapper.hpp +++ b/include/Nazara/Utility/BufferMapper.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/BufferMapper.inl b/include/Nazara/Utility/BufferMapper.inl index 4b7b8be35..f2c184f64 100644 --- a/include/Nazara/Utility/BufferMapper.inl +++ b/include/Nazara/Utility/BufferMapper.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/ConfigCheck.hpp b/include/Nazara/Utility/ConfigCheck.hpp index 42aa5f92c..4a8e891e8 100644 --- a/include/Nazara/Utility/ConfigCheck.hpp +++ b/include/Nazara/Utility/ConfigCheck.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/CubemapParams.hpp b/include/Nazara/Utility/CubemapParams.hpp index 6153eb06d..d89d9c54e 100644 --- a/include/Nazara/Utility/CubemapParams.hpp +++ b/include/Nazara/Utility/CubemapParams.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Debug.hpp b/include/Nazara/Utility/Debug.hpp index 2041a7363..15ef4b99c 100644 --- a/include/Nazara/Utility/Debug.hpp +++ b/include/Nazara/Utility/Debug.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/DebugOff.hpp b/include/Nazara/Utility/DebugOff.hpp index 621ac2c38..e38133afc 100644 --- a/include/Nazara/Utility/DebugOff.hpp +++ b/include/Nazara/Utility/DebugOff.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Enums.hpp b/include/Nazara/Utility/Enums.hpp index d9891b026..70c64e527 100644 --- a/include/Nazara/Utility/Enums.hpp +++ b/include/Nazara/Utility/Enums.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Font.hpp b/include/Nazara/Utility/Font.hpp index bf2561201..9ba2f5a6e 100644 --- a/include/Nazara/Utility/Font.hpp +++ b/include/Nazara/Utility/Font.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Font.inl b/include/Nazara/Utility/Font.inl index efe2a4adc..eaa4fb9bb 100644 --- a/include/Nazara/Utility/Font.inl +++ b/include/Nazara/Utility/Font.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/FontData.hpp b/include/Nazara/Utility/FontData.hpp index 88838a3b7..35039da2c 100644 --- a/include/Nazara/Utility/FontData.hpp +++ b/include/Nazara/Utility/FontData.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/FontGlyph.hpp b/include/Nazara/Utility/FontGlyph.hpp index ea673e178..8adbe34cf 100644 --- a/include/Nazara/Utility/FontGlyph.hpp +++ b/include/Nazara/Utility/FontGlyph.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Formats/MD5AnimParser.hpp b/include/Nazara/Utility/Formats/MD5AnimParser.hpp index 98f209aaf..e1915e6ad 100644 --- a/include/Nazara/Utility/Formats/MD5AnimParser.hpp +++ b/include/Nazara/Utility/Formats/MD5AnimParser.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Formats/MD5MeshParser.hpp b/include/Nazara/Utility/Formats/MD5MeshParser.hpp index ce8df1630..0d1e5641d 100644 --- a/include/Nazara/Utility/Formats/MD5MeshParser.hpp +++ b/include/Nazara/Utility/Formats/MD5MeshParser.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Formats/MTLParser.hpp b/include/Nazara/Utility/Formats/MTLParser.hpp index fcc9ec7fb..cd56a2693 100644 --- a/include/Nazara/Utility/Formats/MTLParser.hpp +++ b/include/Nazara/Utility/Formats/MTLParser.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Formats/MTLParser.inl b/include/Nazara/Utility/Formats/MTLParser.inl index 20c95dc9c..03e4b2c35 100644 --- a/include/Nazara/Utility/Formats/MTLParser.inl +++ b/include/Nazara/Utility/Formats/MTLParser.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Formats/OBJParser.hpp b/include/Nazara/Utility/Formats/OBJParser.hpp index 4a7a7d50a..de0dcf1cb 100644 --- a/include/Nazara/Utility/Formats/OBJParser.hpp +++ b/include/Nazara/Utility/Formats/OBJParser.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Formats/OBJParser.inl b/include/Nazara/Utility/Formats/OBJParser.inl index af36929a2..da4a6abc0 100644 --- a/include/Nazara/Utility/Formats/OBJParser.inl +++ b/include/Nazara/Utility/Formats/OBJParser.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/GuillotineImageAtlas.hpp b/include/Nazara/Utility/GuillotineImageAtlas.hpp index 506922c46..af9ba94ce 100644 --- a/include/Nazara/Utility/GuillotineImageAtlas.hpp +++ b/include/Nazara/Utility/GuillotineImageAtlas.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Image.hpp b/include/Nazara/Utility/Image.hpp index 1ee0011dc..a07b805a4 100644 --- a/include/Nazara/Utility/Image.hpp +++ b/include/Nazara/Utility/Image.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Image.inl b/include/Nazara/Utility/Image.inl index b59a2629b..4fd41adf1 100644 --- a/include/Nazara/Utility/Image.inl +++ b/include/Nazara/Utility/Image.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/IndexBuffer.hpp b/include/Nazara/Utility/IndexBuffer.hpp index 1f554b636..3a908788d 100644 --- a/include/Nazara/Utility/IndexBuffer.hpp +++ b/include/Nazara/Utility/IndexBuffer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/IndexBuffer.inl b/include/Nazara/Utility/IndexBuffer.inl index d764539a5..d9a93f471 100644 --- a/include/Nazara/Utility/IndexBuffer.inl +++ b/include/Nazara/Utility/IndexBuffer.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/IndexIterator.hpp b/include/Nazara/Utility/IndexIterator.hpp index 3733e48ab..4c6c6b371 100644 --- a/include/Nazara/Utility/IndexIterator.hpp +++ b/include/Nazara/Utility/IndexIterator.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/IndexIterator.inl b/include/Nazara/Utility/IndexIterator.inl index 0398059f6..240bbfd25 100644 --- a/include/Nazara/Utility/IndexIterator.inl +++ b/include/Nazara/Utility/IndexIterator.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/IndexMapper.hpp b/include/Nazara/Utility/IndexMapper.hpp index 6ac654194..f7fbd30f7 100644 --- a/include/Nazara/Utility/IndexMapper.hpp +++ b/include/Nazara/Utility/IndexMapper.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Joint.hpp b/include/Nazara/Utility/Joint.hpp index 261530a3c..760062350 100644 --- a/include/Nazara/Utility/Joint.hpp +++ b/include/Nazara/Utility/Joint.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/MaterialData.hpp b/include/Nazara/Utility/MaterialData.hpp index 5d82400d7..c09a0e213 100644 --- a/include/Nazara/Utility/MaterialData.hpp +++ b/include/Nazara/Utility/MaterialData.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Mesh.hpp b/include/Nazara/Utility/Mesh.hpp index 634a66629..7e4a7965b 100644 --- a/include/Nazara/Utility/Mesh.hpp +++ b/include/Nazara/Utility/Mesh.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Mesh.inl b/include/Nazara/Utility/Mesh.inl index 8913aa89c..71af75f0d 100644 --- a/include/Nazara/Utility/Mesh.inl +++ b/include/Nazara/Utility/Mesh.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/MeshData.hpp b/include/Nazara/Utility/MeshData.hpp index 54b5ca0e7..cff792676 100644 --- a/include/Nazara/Utility/MeshData.hpp +++ b/include/Nazara/Utility/MeshData.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Node.hpp b/include/Nazara/Utility/Node.hpp index df931a7ba..d2faaab1c 100644 --- a/include/Nazara/Utility/Node.hpp +++ b/include/Nazara/Utility/Node.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/PixelFormat.hpp b/include/Nazara/Utility/PixelFormat.hpp index 317a9b228..1375a1eb1 100644 --- a/include/Nazara/Utility/PixelFormat.hpp +++ b/include/Nazara/Utility/PixelFormat.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/PixelFormat.inl b/include/Nazara/Utility/PixelFormat.inl index 7fe11d1a4..b1dfdfb0a 100644 --- a/include/Nazara/Utility/PixelFormat.inl +++ b/include/Nazara/Utility/PixelFormat.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/RichTextDrawer.hpp b/include/Nazara/Utility/RichTextDrawer.hpp index 25bd8dcf6..3d9bfce88 100644 --- a/include/Nazara/Utility/RichTextDrawer.hpp +++ b/include/Nazara/Utility/RichTextDrawer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/RichTextDrawer.inl b/include/Nazara/Utility/RichTextDrawer.inl index 38f220198..cc132391f 100644 --- a/include/Nazara/Utility/RichTextDrawer.inl +++ b/include/Nazara/Utility/RichTextDrawer.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Sequence.hpp b/include/Nazara/Utility/Sequence.hpp index 1f729e5e4..a5c27702a 100644 --- a/include/Nazara/Utility/Sequence.hpp +++ b/include/Nazara/Utility/Sequence.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/SimpleTextDrawer.hpp b/include/Nazara/Utility/SimpleTextDrawer.hpp index 3ee3b1b25..deca360a2 100644 --- a/include/Nazara/Utility/SimpleTextDrawer.hpp +++ b/include/Nazara/Utility/SimpleTextDrawer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/SimpleTextDrawer.inl b/include/Nazara/Utility/SimpleTextDrawer.inl index a203bfa8e..fb7dfdc54 100644 --- a/include/Nazara/Utility/SimpleTextDrawer.inl +++ b/include/Nazara/Utility/SimpleTextDrawer.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/SkeletalMesh.hpp b/include/Nazara/Utility/SkeletalMesh.hpp index 051e87a8b..486403cda 100644 --- a/include/Nazara/Utility/SkeletalMesh.hpp +++ b/include/Nazara/Utility/SkeletalMesh.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/SkeletalMesh.inl b/include/Nazara/Utility/SkeletalMesh.inl index 561e906e9..d6b071062 100644 --- a/include/Nazara/Utility/SkeletalMesh.inl +++ b/include/Nazara/Utility/SkeletalMesh.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Skeleton.hpp b/include/Nazara/Utility/Skeleton.hpp index eab57a02b..3ef9091bc 100644 --- a/include/Nazara/Utility/Skeleton.hpp +++ b/include/Nazara/Utility/Skeleton.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Skeleton.inl b/include/Nazara/Utility/Skeleton.inl index ece3fbf98..033cba926 100644 --- a/include/Nazara/Utility/Skeleton.inl +++ b/include/Nazara/Utility/Skeleton.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/SoftwareBuffer.hpp b/include/Nazara/Utility/SoftwareBuffer.hpp index d460eba4c..574aebb50 100644 --- a/include/Nazara/Utility/SoftwareBuffer.hpp +++ b/include/Nazara/Utility/SoftwareBuffer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/StaticMesh.hpp b/include/Nazara/Utility/StaticMesh.hpp index a1b7c5020..64887e254 100644 --- a/include/Nazara/Utility/StaticMesh.hpp +++ b/include/Nazara/Utility/StaticMesh.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/StaticMesh.inl b/include/Nazara/Utility/StaticMesh.inl index efe6ffd12..d25367dcb 100644 --- a/include/Nazara/Utility/StaticMesh.inl +++ b/include/Nazara/Utility/StaticMesh.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/SubMesh.hpp b/include/Nazara/Utility/SubMesh.hpp index 19a8aedc5..8feb14f15 100644 --- a/include/Nazara/Utility/SubMesh.hpp +++ b/include/Nazara/Utility/SubMesh.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/TriangleIterator.hpp b/include/Nazara/Utility/TriangleIterator.hpp index 6263112e4..b33b1b386 100644 --- a/include/Nazara/Utility/TriangleIterator.hpp +++ b/include/Nazara/Utility/TriangleIterator.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/UniformBuffer.hpp b/include/Nazara/Utility/UniformBuffer.hpp index aa77c3069..cf16bc118 100644 --- a/include/Nazara/Utility/UniformBuffer.hpp +++ b/include/Nazara/Utility/UniformBuffer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/UniformBuffer.inl b/include/Nazara/Utility/UniformBuffer.inl index 50b2199eb..958f0131a 100644 --- a/include/Nazara/Utility/UniformBuffer.inl +++ b/include/Nazara/Utility/UniformBuffer.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/Utility.hpp b/include/Nazara/Utility/Utility.hpp index 46d5e0f08..ee02bd7f6 100644 --- a/include/Nazara/Utility/Utility.hpp +++ b/include/Nazara/Utility/Utility.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/VertexBuffer.hpp b/include/Nazara/Utility/VertexBuffer.hpp index 481327a40..82c83399d 100644 --- a/include/Nazara/Utility/VertexBuffer.hpp +++ b/include/Nazara/Utility/VertexBuffer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/VertexBuffer.inl b/include/Nazara/Utility/VertexBuffer.inl index f7091752e..6cf8e8c19 100644 --- a/include/Nazara/Utility/VertexBuffer.inl +++ b/include/Nazara/Utility/VertexBuffer.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/VertexDeclaration.hpp b/include/Nazara/Utility/VertexDeclaration.hpp index a11b3b798..a49ef92b4 100644 --- a/include/Nazara/Utility/VertexDeclaration.hpp +++ b/include/Nazara/Utility/VertexDeclaration.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/VertexDeclaration.inl b/include/Nazara/Utility/VertexDeclaration.inl index 1e1462556..07a82ba7b 100644 --- a/include/Nazara/Utility/VertexDeclaration.inl +++ b/include/Nazara/Utility/VertexDeclaration.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/VertexMapper.hpp b/include/Nazara/Utility/VertexMapper.hpp index 80680a86d..39a210b00 100644 --- a/include/Nazara/Utility/VertexMapper.hpp +++ b/include/Nazara/Utility/VertexMapper.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/VertexMapper.inl b/include/Nazara/Utility/VertexMapper.inl index 736a51c35..ddb1015c2 100644 --- a/include/Nazara/Utility/VertexMapper.inl +++ b/include/Nazara/Utility/VertexMapper.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/VertexStruct.hpp b/include/Nazara/Utility/VertexStruct.hpp index 2a811722e..024574828 100644 --- a/include/Nazara/Utility/VertexStruct.hpp +++ b/include/Nazara/Utility/VertexStruct.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/ConfigCheck.hpp b/include/Nazara/VulkanRenderer/ConfigCheck.hpp index 600d214dd..2944ecfb9 100644 --- a/include/Nazara/VulkanRenderer/ConfigCheck.hpp +++ b/include/Nazara/VulkanRenderer/ConfigCheck.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Debug.hpp b/include/Nazara/VulkanRenderer/Debug.hpp index 795aa7c7d..1ef1a1f9a 100644 --- a/include/Nazara/VulkanRenderer/Debug.hpp +++ b/include/Nazara/VulkanRenderer/Debug.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/DebugOff.hpp b/include/Nazara/VulkanRenderer/DebugOff.hpp index a2e247323..f80fde373 100644 --- a/include/Nazara/VulkanRenderer/DebugOff.hpp +++ b/include/Nazara/VulkanRenderer/DebugOff.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Utils.hpp b/include/Nazara/VulkanRenderer/Utils.hpp index 1c1d6715e..fcf092394 100644 --- a/include/Nazara/VulkanRenderer/Utils.hpp +++ b/include/Nazara/VulkanRenderer/Utils.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Utils.inl b/include/Nazara/VulkanRenderer/Utils.inl index 723483292..69c89d85d 100644 --- a/include/Nazara/VulkanRenderer/Utils.inl +++ b/include/Nazara/VulkanRenderer/Utils.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/VkRenderTarget.inl b/include/Nazara/VulkanRenderer/VkRenderTarget.inl index 1fd0550bc..ffe654e14 100644 --- a/include/Nazara/VulkanRenderer/VkRenderTarget.inl +++ b/include/Nazara/VulkanRenderer/VkRenderTarget.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/VkRenderWindow.inl b/include/Nazara/VulkanRenderer/VkRenderWindow.inl index 8c4737578..4d9cf9e92 100644 --- a/include/Nazara/VulkanRenderer/VkRenderWindow.inl +++ b/include/Nazara/VulkanRenderer/VkRenderWindow.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Vulkan.hpp b/include/Nazara/VulkanRenderer/Vulkan.hpp index 69ada9a7b..2898dca94 100644 --- a/include/Nazara/VulkanRenderer/Vulkan.hpp +++ b/include/Nazara/VulkanRenderer/Vulkan.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/VulkanBuffer.inl b/include/Nazara/VulkanRenderer/VulkanBuffer.inl index d2360055a..cc699a10d 100644 --- a/include/Nazara/VulkanRenderer/VulkanBuffer.inl +++ b/include/Nazara/VulkanRenderer/VulkanBuffer.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/VulkanDevice.inl b/include/Nazara/VulkanRenderer/VulkanDevice.inl index 3a751f921..dd44f8b19 100644 --- a/include/Nazara/VulkanRenderer/VulkanDevice.inl +++ b/include/Nazara/VulkanRenderer/VulkanDevice.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp b/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp index 5c292da04..a622c51ff 100644 --- a/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp +++ b/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/VulkanRenderPipeline.inl b/include/Nazara/VulkanRenderer/VulkanRenderPipeline.inl index 180aaa736..00c03d4d2 100644 --- a/include/Nazara/VulkanRenderer/VulkanRenderPipeline.inl +++ b/include/Nazara/VulkanRenderer/VulkanRenderPipeline.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/VulkanRenderer.hpp b/include/Nazara/VulkanRenderer/VulkanRenderer.hpp index cebc25089..62bd426ca 100644 --- a/include/Nazara/VulkanRenderer/VulkanRenderer.hpp +++ b/include/Nazara/VulkanRenderer/VulkanRenderer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/VulkanRenderer.inl b/include/Nazara/VulkanRenderer/VulkanRenderer.inl index 000661426..12341585a 100644 --- a/include/Nazara/VulkanRenderer/VulkanRenderer.inl +++ b/include/Nazara/VulkanRenderer/VulkanRenderer.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/VulkanShaderStage.inl b/include/Nazara/VulkanRenderer/VulkanShaderStage.inl index e3a634c83..04aae8d74 100644 --- a/include/Nazara/VulkanRenderer/VulkanShaderStage.inl +++ b/include/Nazara/VulkanRenderer/VulkanShaderStage.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/VulkanSurface.inl b/include/Nazara/VulkanRenderer/VulkanSurface.inl index 04dfc2968..18a125c4a 100644 --- a/include/Nazara/VulkanRenderer/VulkanSurface.inl +++ b/include/Nazara/VulkanRenderer/VulkanSurface.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp b/include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp index 53648a0f9..a846c922e 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/Buffer.inl b/include/Nazara/VulkanRenderer/Wrapper/Buffer.inl index 9b5e41bdd..e5b79d6c7 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Buffer.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Buffer.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp index c5164ebf5..3191f76eb 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl index 62db2a27a..93255ad58 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandPool.hpp b/include/Nazara/VulkanRenderer/Wrapper/CommandPool.hpp index 8d65e4fa9..ff88dc378 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandPool.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandPool.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandPool.inl b/include/Nazara/VulkanRenderer/Wrapper/CommandPool.inl index 5ce0e58a3..96b1f2abd 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandPool.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandPool.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp b/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp index 0ca9a0c59..bf7da5556 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.inl b/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.inl index f407edef0..a4161b367 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.hpp b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.hpp index 68a8d1644..8fd14fcba 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.inl b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.inl index 30d735eb5..9a0267cf1 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.hpp b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.hpp index b5f1dd9ee..fd2b09a22 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.inl b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.inl index 8989a4768..20b74400a 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp index f38885fb6..a5ed0759c 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/Device.inl b/include/Nazara/VulkanRenderer/Wrapper/Device.inl index 0f85878f5..a5035a75d 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Device.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Device.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp b/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp index 3a57dc1b5..d6f32e80a 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.inl b/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.inl index c3bb310ba..26bee7012 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp index 6ee48251e..0e6090d73 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl index 8ea41182a..961a5b4ad 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/Fence.hpp b/include/Nazara/VulkanRenderer/Wrapper/Fence.hpp index 480e5524e..a78b4a597 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Fence.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Fence.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/Fence.inl b/include/Nazara/VulkanRenderer/Wrapper/Fence.inl index c67bfc6e5..7a02c20b5 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Fence.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Fence.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.hpp b/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.hpp index 811bd2859..297b69b93 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.inl b/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.inl index 1062a1d63..a13b52539 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/Image.hpp b/include/Nazara/VulkanRenderer/Wrapper/Image.hpp index 67f59fb2d..f63910501 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Image.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Image.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/Image.inl b/include/Nazara/VulkanRenderer/Wrapper/Image.inl index ffc8ed2f9..bafaf1c62 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Image.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Image.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/ImageView.hpp b/include/Nazara/VulkanRenderer/Wrapper/ImageView.hpp index 3a0bb5cbb..8e3b00031 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/ImageView.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/ImageView.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/ImageView.inl b/include/Nazara/VulkanRenderer/Wrapper/ImageView.inl index 0c2219703..cf107865b 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/ImageView.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/ImageView.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp b/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp index 71c3f08e5..f00056ef1 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/Instance.inl b/include/Nazara/VulkanRenderer/Wrapper/Instance.inl index a750763c9..646f3d4c9 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Instance.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Instance.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/Loader.hpp b/include/Nazara/VulkanRenderer/Wrapper/Loader.hpp index 41620a0f4..c4d584132 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Loader.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Loader.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/Loader.inl b/include/Nazara/VulkanRenderer/Wrapper/Loader.inl index 1ff9dfd01..7fa6c4193 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Loader.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Loader.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/PhysicalDevice.hpp b/include/Nazara/VulkanRenderer/Wrapper/PhysicalDevice.hpp index 3caa8a179..266d1d877 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/PhysicalDevice.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/PhysicalDevice.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/Pipeline.hpp b/include/Nazara/VulkanRenderer/Wrapper/Pipeline.hpp index 000f3de9c..e97a50509 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Pipeline.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Pipeline.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/Pipeline.inl b/include/Nazara/VulkanRenderer/Wrapper/Pipeline.inl index cecef540b..010437000 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Pipeline.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Pipeline.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.hpp b/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.hpp index 0fedec109..8fbd900eb 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.inl b/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.inl index fde28390c..a23d2c509 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp b/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp index f56f05639..7e2af843e 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.inl b/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.inl index a7a1bc444..333062780 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/Queue.hpp b/include/Nazara/VulkanRenderer/Wrapper/Queue.hpp index a4129e4d0..9256441e7 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Queue.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Queue.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/Queue.inl b/include/Nazara/VulkanRenderer/Wrapper/Queue.inl index dc8603465..c22e73ab4 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Queue.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Queue.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/RenderPass.hpp b/include/Nazara/VulkanRenderer/Wrapper/RenderPass.hpp index 35e4b8268..b5b6ef58d 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/RenderPass.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/RenderPass.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/RenderPass.inl b/include/Nazara/VulkanRenderer/Wrapper/RenderPass.inl index 4052fb100..16b27c5e7 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/RenderPass.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/RenderPass.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/Semaphore.hpp b/include/Nazara/VulkanRenderer/Wrapper/Semaphore.hpp index e6e21289c..f8f1592bb 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Semaphore.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Semaphore.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/Semaphore.inl b/include/Nazara/VulkanRenderer/Wrapper/Semaphore.inl index 60f5c8afb..7a17c6d5e 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Semaphore.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Semaphore.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp b/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp index fbc5bc6c2..a815db5fd 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.inl b/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.inl index dfe55a0e3..bce7a49b8 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/Surface.hpp b/include/Nazara/VulkanRenderer/Wrapper/Surface.hpp index 3c77ca00f..f49b207cb 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Surface.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Surface.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/Surface.inl b/include/Nazara/VulkanRenderer/Wrapper/Surface.inl index bfc5f4824..43101eb4c 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Surface.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Surface.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp b/include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp index 91672502e..893f74913 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/Swapchain.inl b/include/Nazara/VulkanRenderer/Wrapper/Swapchain.inl index 2ad91cdb4..c0e146d40 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Swapchain.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Swapchain.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/NazaraSDK/Algorithm.hpp b/include/NazaraSDK/Algorithm.hpp index 9496c4d21..4a15e10b6 100644 --- a/include/NazaraSDK/Algorithm.hpp +++ b/include/NazaraSDK/Algorithm.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Algorithm.inl b/include/NazaraSDK/Algorithm.inl index 2f9c42a10..829b76729 100644 --- a/include/NazaraSDK/Algorithm.inl +++ b/include/NazaraSDK/Algorithm.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Application.hpp b/include/NazaraSDK/Application.hpp index 5302d68a0..707677552 100644 --- a/include/NazaraSDK/Application.hpp +++ b/include/NazaraSDK/Application.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Application.inl b/include/NazaraSDK/Application.inl index df690d038..7adf9ea0f 100644 --- a/include/NazaraSDK/Application.inl +++ b/include/NazaraSDK/Application.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/BaseComponent.hpp b/include/NazaraSDK/BaseComponent.hpp index c00260b09..dbd6d3b59 100644 --- a/include/NazaraSDK/BaseComponent.hpp +++ b/include/NazaraSDK/BaseComponent.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/BaseComponent.inl b/include/NazaraSDK/BaseComponent.inl index a484a87df..e08bab1fb 100644 --- a/include/NazaraSDK/BaseComponent.inl +++ b/include/NazaraSDK/BaseComponent.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/BaseSystem.hpp b/include/NazaraSDK/BaseSystem.hpp index 87967764d..ed17d6ec9 100644 --- a/include/NazaraSDK/BaseSystem.hpp +++ b/include/NazaraSDK/BaseSystem.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/BaseSystem.inl b/include/NazaraSDK/BaseSystem.inl index 843448988..5e707b1f1 100644 --- a/include/NazaraSDK/BaseSystem.inl +++ b/include/NazaraSDK/BaseSystem.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/BaseWidget.hpp b/include/NazaraSDK/BaseWidget.hpp index 62ace6eba..b8d786d69 100644 --- a/include/NazaraSDK/BaseWidget.hpp +++ b/include/NazaraSDK/BaseWidget.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/BaseWidget.inl b/include/NazaraSDK/BaseWidget.inl index 7115b5ad5..0f9ff5b16 100644 --- a/include/NazaraSDK/BaseWidget.inl +++ b/include/NazaraSDK/BaseWidget.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Canvas.hpp b/include/NazaraSDK/Canvas.hpp index 1cff05828..af4f5e8e5 100644 --- a/include/NazaraSDK/Canvas.hpp +++ b/include/NazaraSDK/Canvas.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Canvas.inl b/include/NazaraSDK/Canvas.inl index 4e308631e..77cdfc29a 100644 --- a/include/NazaraSDK/Canvas.inl +++ b/include/NazaraSDK/Canvas.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Component.hpp b/include/NazaraSDK/Component.hpp index d2ccaaf5d..24298dc14 100644 --- a/include/NazaraSDK/Component.hpp +++ b/include/NazaraSDK/Component.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Component.inl b/include/NazaraSDK/Component.inl index 459cd4789..3410d96ee 100644 --- a/include/NazaraSDK/Component.inl +++ b/include/NazaraSDK/Component.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Components/CameraComponent.hpp b/include/NazaraSDK/Components/CameraComponent.hpp index a4faaf7fa..c8be2ec83 100644 --- a/include/NazaraSDK/Components/CameraComponent.hpp +++ b/include/NazaraSDK/Components/CameraComponent.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Components/CameraComponent.inl b/include/NazaraSDK/Components/CameraComponent.inl index e059a68b1..23ab08896 100644 --- a/include/NazaraSDK/Components/CameraComponent.inl +++ b/include/NazaraSDK/Components/CameraComponent.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Components/CollisionComponent2D.hpp b/include/NazaraSDK/Components/CollisionComponent2D.hpp index 4bd47e6ae..d2ea33db8 100644 --- a/include/NazaraSDK/Components/CollisionComponent2D.hpp +++ b/include/NazaraSDK/Components/CollisionComponent2D.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Components/CollisionComponent2D.inl b/include/NazaraSDK/Components/CollisionComponent2D.inl index 1bc9f0978..35df6467c 100644 --- a/include/NazaraSDK/Components/CollisionComponent2D.inl +++ b/include/NazaraSDK/Components/CollisionComponent2D.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Components/CollisionComponent3D.hpp b/include/NazaraSDK/Components/CollisionComponent3D.hpp index 846985cf4..c8f832a50 100644 --- a/include/NazaraSDK/Components/CollisionComponent3D.hpp +++ b/include/NazaraSDK/Components/CollisionComponent3D.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Components/CollisionComponent3D.inl b/include/NazaraSDK/Components/CollisionComponent3D.inl index 73225b262..fc31fe0b5 100644 --- a/include/NazaraSDK/Components/CollisionComponent3D.inl +++ b/include/NazaraSDK/Components/CollisionComponent3D.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Components/ConstraintComponent2D.hpp b/include/NazaraSDK/Components/ConstraintComponent2D.hpp index 97c201570..fa1d7fe72 100644 --- a/include/NazaraSDK/Components/ConstraintComponent2D.hpp +++ b/include/NazaraSDK/Components/ConstraintComponent2D.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Components/ConstraintComponent2D.inl b/include/NazaraSDK/Components/ConstraintComponent2D.inl index 4d4d2e81a..10cb2a3dc 100644 --- a/include/NazaraSDK/Components/ConstraintComponent2D.inl +++ b/include/NazaraSDK/Components/ConstraintComponent2D.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2019 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Components/DebugComponent.hpp b/include/NazaraSDK/Components/DebugComponent.hpp index 9dcf762d5..3718dc6d8 100644 --- a/include/NazaraSDK/Components/DebugComponent.hpp +++ b/include/NazaraSDK/Components/DebugComponent.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Components/DebugComponent.inl b/include/NazaraSDK/Components/DebugComponent.inl index 0aff21089..ebac94095 100644 --- a/include/NazaraSDK/Components/DebugComponent.inl +++ b/include/NazaraSDK/Components/DebugComponent.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Components/GraphicsComponent.hpp b/include/NazaraSDK/Components/GraphicsComponent.hpp index fca142554..38910b878 100644 --- a/include/NazaraSDK/Components/GraphicsComponent.hpp +++ b/include/NazaraSDK/Components/GraphicsComponent.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Components/GraphicsComponent.inl b/include/NazaraSDK/Components/GraphicsComponent.inl index 05c878df7..2b26360db 100644 --- a/include/NazaraSDK/Components/GraphicsComponent.inl +++ b/include/NazaraSDK/Components/GraphicsComponent.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Components/LifetimeComponent.hpp b/include/NazaraSDK/Components/LifetimeComponent.hpp index cb2044605..21802baa8 100644 --- a/include/NazaraSDK/Components/LifetimeComponent.hpp +++ b/include/NazaraSDK/Components/LifetimeComponent.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Components/LifetimeComponent.inl b/include/NazaraSDK/Components/LifetimeComponent.inl index 6635bc0d8..01de40668 100644 --- a/include/NazaraSDK/Components/LifetimeComponent.inl +++ b/include/NazaraSDK/Components/LifetimeComponent.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Components/LightComponent.hpp b/include/NazaraSDK/Components/LightComponent.hpp index 33eec59a1..f34e7a2c1 100644 --- a/include/NazaraSDK/Components/LightComponent.hpp +++ b/include/NazaraSDK/Components/LightComponent.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Components/LightComponent.inl b/include/NazaraSDK/Components/LightComponent.inl index 7ddb5d788..43b278757 100644 --- a/include/NazaraSDK/Components/LightComponent.inl +++ b/include/NazaraSDK/Components/LightComponent.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Components/ListenerComponent.hpp b/include/NazaraSDK/Components/ListenerComponent.hpp index 4a8490d6a..cea5a8d84 100644 --- a/include/NazaraSDK/Components/ListenerComponent.hpp +++ b/include/NazaraSDK/Components/ListenerComponent.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Components/ListenerComponent.inl b/include/NazaraSDK/Components/ListenerComponent.inl index 52032dfb3..5ac13d076 100644 --- a/include/NazaraSDK/Components/ListenerComponent.inl +++ b/include/NazaraSDK/Components/ListenerComponent.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Components/NodeComponent.hpp b/include/NazaraSDK/Components/NodeComponent.hpp index 2a5dd2289..e7e2da9dc 100644 --- a/include/NazaraSDK/Components/NodeComponent.hpp +++ b/include/NazaraSDK/Components/NodeComponent.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Components/NodeComponent.inl b/include/NazaraSDK/Components/NodeComponent.inl index 6a6770d66..9dcc36ed7 100644 --- a/include/NazaraSDK/Components/NodeComponent.inl +++ b/include/NazaraSDK/Components/NodeComponent.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Components/ParticleEmitterComponent.hpp b/include/NazaraSDK/Components/ParticleEmitterComponent.hpp index 65833003f..99d7bd30e 100644 --- a/include/NazaraSDK/Components/ParticleEmitterComponent.hpp +++ b/include/NazaraSDK/Components/ParticleEmitterComponent.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Components/ParticleEmitterComponent.inl b/include/NazaraSDK/Components/ParticleEmitterComponent.inl index dd60f1a88..d37c82065 100644 --- a/include/NazaraSDK/Components/ParticleEmitterComponent.inl +++ b/include/NazaraSDK/Components/ParticleEmitterComponent.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Components/ParticleGroupComponent.hpp b/include/NazaraSDK/Components/ParticleGroupComponent.hpp index 8471ecc03..1f760fe59 100644 --- a/include/NazaraSDK/Components/ParticleGroupComponent.hpp +++ b/include/NazaraSDK/Components/ParticleGroupComponent.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Components/ParticleGroupComponent.inl b/include/NazaraSDK/Components/ParticleGroupComponent.inl index 1e0d75cac..672d4b308 100644 --- a/include/NazaraSDK/Components/ParticleGroupComponent.inl +++ b/include/NazaraSDK/Components/ParticleGroupComponent.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Components/PhysicsComponent2D.hpp b/include/NazaraSDK/Components/PhysicsComponent2D.hpp index 15159709d..66c034537 100644 --- a/include/NazaraSDK/Components/PhysicsComponent2D.hpp +++ b/include/NazaraSDK/Components/PhysicsComponent2D.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Components/PhysicsComponent2D.inl b/include/NazaraSDK/Components/PhysicsComponent2D.inl index f42b95c85..e28a84f8a 100644 --- a/include/NazaraSDK/Components/PhysicsComponent2D.inl +++ b/include/NazaraSDK/Components/PhysicsComponent2D.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Components/PhysicsComponent3D.hpp b/include/NazaraSDK/Components/PhysicsComponent3D.hpp index 538860cde..4dfb6fce6 100644 --- a/include/NazaraSDK/Components/PhysicsComponent3D.hpp +++ b/include/NazaraSDK/Components/PhysicsComponent3D.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Components/PhysicsComponent3D.inl b/include/NazaraSDK/Components/PhysicsComponent3D.inl index 22123ca52..a5a171a6e 100644 --- a/include/NazaraSDK/Components/PhysicsComponent3D.inl +++ b/include/NazaraSDK/Components/PhysicsComponent3D.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Components/VelocityComponent.hpp b/include/NazaraSDK/Components/VelocityComponent.hpp index b2f82a556..a82ecdf5c 100644 --- a/include/NazaraSDK/Components/VelocityComponent.hpp +++ b/include/NazaraSDK/Components/VelocityComponent.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Components/VelocityComponent.inl b/include/NazaraSDK/Components/VelocityComponent.inl index 2adedf413..582fb0d40 100644 --- a/include/NazaraSDK/Components/VelocityComponent.inl +++ b/include/NazaraSDK/Components/VelocityComponent.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Console.hpp b/include/NazaraSDK/Console.hpp index 67aece140..8d8f73574 100644 --- a/include/NazaraSDK/Console.hpp +++ b/include/NazaraSDK/Console.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Console.inl b/include/NazaraSDK/Console.inl index 3cd318ae3..fa902f2c3 100644 --- a/include/NazaraSDK/Console.inl +++ b/include/NazaraSDK/Console.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Entity.hpp b/include/NazaraSDK/Entity.hpp index f05a5c432..e96bfe48e 100644 --- a/include/NazaraSDK/Entity.hpp +++ b/include/NazaraSDK/Entity.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Entity.inl b/include/NazaraSDK/Entity.inl index f17ff92fa..ed9d6e98e 100644 --- a/include/NazaraSDK/Entity.inl +++ b/include/NazaraSDK/Entity.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/EntityList.hpp b/include/NazaraSDK/EntityList.hpp index 0950cae2f..db65e900e 100644 --- a/include/NazaraSDK/EntityList.hpp +++ b/include/NazaraSDK/EntityList.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/EntityList.inl b/include/NazaraSDK/EntityList.inl index a34165a68..48876faf8 100644 --- a/include/NazaraSDK/EntityList.inl +++ b/include/NazaraSDK/EntityList.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/EntityOwner.hpp b/include/NazaraSDK/EntityOwner.hpp index 2fec8f6dc..edc238aca 100644 --- a/include/NazaraSDK/EntityOwner.hpp +++ b/include/NazaraSDK/EntityOwner.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/EntityOwner.inl b/include/NazaraSDK/EntityOwner.inl index 13f1e8cad..bf0a1a82d 100644 --- a/include/NazaraSDK/EntityOwner.inl +++ b/include/NazaraSDK/EntityOwner.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Sdk.hpp b/include/NazaraSDK/Sdk.hpp index 9e42e3ac6..787eb29fc 100644 --- a/include/NazaraSDK/Sdk.hpp +++ b/include/NazaraSDK/Sdk.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Sdk.inl b/include/NazaraSDK/Sdk.inl index 6c8a860e3..42d92d06e 100644 --- a/include/NazaraSDK/Sdk.inl +++ b/include/NazaraSDK/Sdk.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/State.hpp b/include/NazaraSDK/State.hpp index 506cd6476..4f21f6910 100644 --- a/include/NazaraSDK/State.hpp +++ b/include/NazaraSDK/State.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/StateMachine.hpp b/include/NazaraSDK/StateMachine.hpp index 54db4877b..fd2303259 100644 --- a/include/NazaraSDK/StateMachine.hpp +++ b/include/NazaraSDK/StateMachine.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/StateMachine.inl b/include/NazaraSDK/StateMachine.inl index 95df4e82b..9392140e1 100644 --- a/include/NazaraSDK/StateMachine.inl +++ b/include/NazaraSDK/StateMachine.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/System.hpp b/include/NazaraSDK/System.hpp index 5276a2251..cf3877127 100644 --- a/include/NazaraSDK/System.hpp +++ b/include/NazaraSDK/System.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/System.inl b/include/NazaraSDK/System.inl index 0110da45a..a6dcffd92 100644 --- a/include/NazaraSDK/System.inl +++ b/include/NazaraSDK/System.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Systems/DebugSystem.hpp b/include/NazaraSDK/Systems/DebugSystem.hpp index d8c7ccfd7..38fcd2680 100644 --- a/include/NazaraSDK/Systems/DebugSystem.hpp +++ b/include/NazaraSDK/Systems/DebugSystem.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Systems/DebugSystem.inl b/include/NazaraSDK/Systems/DebugSystem.inl index 46d425afa..41f5e598d 100644 --- a/include/NazaraSDK/Systems/DebugSystem.inl +++ b/include/NazaraSDK/Systems/DebugSystem.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Systems/LifetimeSystem.hpp b/include/NazaraSDK/Systems/LifetimeSystem.hpp index ff095580d..3109b2b72 100644 --- a/include/NazaraSDK/Systems/LifetimeSystem.hpp +++ b/include/NazaraSDK/Systems/LifetimeSystem.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Systems/LifetimeSystem.inl b/include/NazaraSDK/Systems/LifetimeSystem.inl index 5302ce8d0..b9de8cfdb 100644 --- a/include/NazaraSDK/Systems/LifetimeSystem.inl +++ b/include/NazaraSDK/Systems/LifetimeSystem.inl @@ -1,3 +1,3 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Systems/ListenerSystem.hpp b/include/NazaraSDK/Systems/ListenerSystem.hpp index 7f203c35a..3c9317e0d 100644 --- a/include/NazaraSDK/Systems/ListenerSystem.hpp +++ b/include/NazaraSDK/Systems/ListenerSystem.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Systems/ListenerSystem.inl b/include/NazaraSDK/Systems/ListenerSystem.inl index 5302ce8d0..b9de8cfdb 100644 --- a/include/NazaraSDK/Systems/ListenerSystem.inl +++ b/include/NazaraSDK/Systems/ListenerSystem.inl @@ -1,3 +1,3 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Systems/ParticleSystem.hpp b/include/NazaraSDK/Systems/ParticleSystem.hpp index cb57a41d7..51d00782f 100644 --- a/include/NazaraSDK/Systems/ParticleSystem.hpp +++ b/include/NazaraSDK/Systems/ParticleSystem.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Systems/ParticleSystem.inl b/include/NazaraSDK/Systems/ParticleSystem.inl index 5302ce8d0..b9de8cfdb 100644 --- a/include/NazaraSDK/Systems/ParticleSystem.inl +++ b/include/NazaraSDK/Systems/ParticleSystem.inl @@ -1,3 +1,3 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Systems/PhysicsSystem2D.hpp b/include/NazaraSDK/Systems/PhysicsSystem2D.hpp index faff327a2..8e9f271fc 100644 --- a/include/NazaraSDK/Systems/PhysicsSystem2D.hpp +++ b/include/NazaraSDK/Systems/PhysicsSystem2D.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Systems/PhysicsSystem2D.inl b/include/NazaraSDK/Systems/PhysicsSystem2D.inl index 1a490b4dd..0d8184ab2 100644 --- a/include/NazaraSDK/Systems/PhysicsSystem2D.inl +++ b/include/NazaraSDK/Systems/PhysicsSystem2D.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Systems/PhysicsSystem3D.hpp b/include/NazaraSDK/Systems/PhysicsSystem3D.hpp index 0e70e21f6..716f298e1 100644 --- a/include/NazaraSDK/Systems/PhysicsSystem3D.hpp +++ b/include/NazaraSDK/Systems/PhysicsSystem3D.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Systems/PhysicsSystem3D.inl b/include/NazaraSDK/Systems/PhysicsSystem3D.inl index 70d41b104..a4369ff9c 100644 --- a/include/NazaraSDK/Systems/PhysicsSystem3D.inl +++ b/include/NazaraSDK/Systems/PhysicsSystem3D.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Systems/RenderSystem.hpp b/include/NazaraSDK/Systems/RenderSystem.hpp index 52758bc6d..82978e712 100644 --- a/include/NazaraSDK/Systems/RenderSystem.hpp +++ b/include/NazaraSDK/Systems/RenderSystem.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Systems/RenderSystem.inl b/include/NazaraSDK/Systems/RenderSystem.inl index ab9d03839..34b7588c2 100644 --- a/include/NazaraSDK/Systems/RenderSystem.inl +++ b/include/NazaraSDK/Systems/RenderSystem.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Systems/VelocitySystem.hpp b/include/NazaraSDK/Systems/VelocitySystem.hpp index 46ef02862..82e507288 100644 --- a/include/NazaraSDK/Systems/VelocitySystem.hpp +++ b/include/NazaraSDK/Systems/VelocitySystem.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Systems/VelocitySystem.inl b/include/NazaraSDK/Systems/VelocitySystem.inl index 5302ce8d0..b9de8cfdb 100644 --- a/include/NazaraSDK/Systems/VelocitySystem.inl +++ b/include/NazaraSDK/Systems/VelocitySystem.inl @@ -1,3 +1,3 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Widgets/AbstractTextAreaWidget.hpp b/include/NazaraSDK/Widgets/AbstractTextAreaWidget.hpp index 1a23bfa8e..6762f8d63 100644 --- a/include/NazaraSDK/Widgets/AbstractTextAreaWidget.hpp +++ b/include/NazaraSDK/Widgets/AbstractTextAreaWidget.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Widgets/AbstractTextAreaWidget.inl b/include/NazaraSDK/Widgets/AbstractTextAreaWidget.inl index 0af05d76e..377321c35 100644 --- a/include/NazaraSDK/Widgets/AbstractTextAreaWidget.inl +++ b/include/NazaraSDK/Widgets/AbstractTextAreaWidget.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Widgets/BoxLayout.hpp b/include/NazaraSDK/Widgets/BoxLayout.hpp index 5c2ad0a9f..408f1a996 100644 --- a/include/NazaraSDK/Widgets/BoxLayout.hpp +++ b/include/NazaraSDK/Widgets/BoxLayout.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Widgets/BoxLayout.inl b/include/NazaraSDK/Widgets/BoxLayout.inl index aceb4cc9d..c28b31232 100644 --- a/include/NazaraSDK/Widgets/BoxLayout.inl +++ b/include/NazaraSDK/Widgets/BoxLayout.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Widgets/ButtonWidget.hpp b/include/NazaraSDK/Widgets/ButtonWidget.hpp index 3e3b6f16f..6a75b4e23 100644 --- a/include/NazaraSDK/Widgets/ButtonWidget.hpp +++ b/include/NazaraSDK/Widgets/ButtonWidget.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Widgets/ButtonWidget.inl b/include/NazaraSDK/Widgets/ButtonWidget.inl index 0924ab882..5d320e767 100644 --- a/include/NazaraSDK/Widgets/ButtonWidget.inl +++ b/include/NazaraSDK/Widgets/ButtonWidget.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Widgets/LabelWidget.hpp b/include/NazaraSDK/Widgets/LabelWidget.hpp index a446262fb..9b01a44e8 100644 --- a/include/NazaraSDK/Widgets/LabelWidget.hpp +++ b/include/NazaraSDK/Widgets/LabelWidget.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Widgets/LabelWidget.inl b/include/NazaraSDK/Widgets/LabelWidget.inl index de1b6d19e..ee168ead0 100644 --- a/include/NazaraSDK/Widgets/LabelWidget.inl +++ b/include/NazaraSDK/Widgets/LabelWidget.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Widgets/RichTextAreaWidget.hpp b/include/NazaraSDK/Widgets/RichTextAreaWidget.hpp index 24cf26f7c..a75fd34dc 100644 --- a/include/NazaraSDK/Widgets/RichTextAreaWidget.hpp +++ b/include/NazaraSDK/Widgets/RichTextAreaWidget.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Widgets/RichTextAreaWidget.inl b/include/NazaraSDK/Widgets/RichTextAreaWidget.inl index 82d84c3be..cc9b933cf 100644 --- a/include/NazaraSDK/Widgets/RichTextAreaWidget.inl +++ b/include/NazaraSDK/Widgets/RichTextAreaWidget.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Widgets/ScrollAreaWidget.hpp b/include/NazaraSDK/Widgets/ScrollAreaWidget.hpp index bc4e01a93..e7652c3e7 100644 --- a/include/NazaraSDK/Widgets/ScrollAreaWidget.hpp +++ b/include/NazaraSDK/Widgets/ScrollAreaWidget.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Widgets/ScrollAreaWidget.inl b/include/NazaraSDK/Widgets/ScrollAreaWidget.inl index 64ee3b1df..71ccd579c 100644 --- a/include/NazaraSDK/Widgets/ScrollAreaWidget.inl +++ b/include/NazaraSDK/Widgets/ScrollAreaWidget.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2019 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Widgets/TextAreaWidget.hpp b/include/NazaraSDK/Widgets/TextAreaWidget.hpp index c2fe9822c..e438ead2b 100644 --- a/include/NazaraSDK/Widgets/TextAreaWidget.hpp +++ b/include/NazaraSDK/Widgets/TextAreaWidget.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/Widgets/TextAreaWidget.inl b/include/NazaraSDK/Widgets/TextAreaWidget.inl index 776841979..9cfc1cd57 100644 --- a/include/NazaraSDK/Widgets/TextAreaWidget.inl +++ b/include/NazaraSDK/Widgets/TextAreaWidget.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/World.hpp b/include/NazaraSDK/World.hpp index b0d2f3c92..b8765d379 100644 --- a/include/NazaraSDK/World.hpp +++ b/include/NazaraSDK/World.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/include/NazaraSDK/World.inl b/include/NazaraSDK/World.inl index 00451153b..e0c60d4c4 100644 --- a/include/NazaraSDK/World.inl +++ b/include/NazaraSDK/World.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/plugins/Assimp/CustomStream.cpp b/plugins/Assimp/CustomStream.cpp index 04e8cddce..d66088c6a 100644 --- a/plugins/Assimp/CustomStream.cpp +++ b/plugins/Assimp/CustomStream.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Assimp Plugin" // For conditions of distribution and use, see copyright notice in Plugin.cpp diff --git a/plugins/Assimp/CustomStream.hpp b/plugins/Assimp/CustomStream.hpp index 55197d05c..9ba461527 100644 --- a/plugins/Assimp/CustomStream.hpp +++ b/plugins/Assimp/CustomStream.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Assimp Plugin" // For conditions of distribution and use, see copyright notice in Plugin.cpp diff --git a/src/Nazara/Audio/Audio.cpp b/src/Nazara/Audio/Audio.cpp index 08ff28198..fd0602168 100644 --- a/src/Nazara/Audio/Audio.cpp +++ b/src/Nazara/Audio/Audio.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Audio/Debug/NewOverload.cpp b/src/Nazara/Audio/Debug/NewOverload.cpp index 85431a7a0..098d812d7 100644 --- a/src/Nazara/Audio/Debug/NewOverload.cpp +++ b/src/Nazara/Audio/Debug/NewOverload.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Audio/Formats/sndfileLoader.cpp b/src/Nazara/Audio/Formats/sndfileLoader.cpp index 5d297fc4f..162a33361 100644 --- a/src/Nazara/Audio/Formats/sndfileLoader.cpp +++ b/src/Nazara/Audio/Formats/sndfileLoader.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Audio/Formats/sndfileLoader.hpp b/src/Nazara/Audio/Formats/sndfileLoader.hpp index 1d39c8b11..f97dfd25b 100644 --- a/src/Nazara/Audio/Formats/sndfileLoader.hpp +++ b/src/Nazara/Audio/Formats/sndfileLoader.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Audio/Music.cpp b/src/Nazara/Audio/Music.cpp index 85bdc764e..7c101eeec 100644 --- a/src/Nazara/Audio/Music.cpp +++ b/src/Nazara/Audio/Music.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Audio/OpenAL.cpp b/src/Nazara/Audio/OpenAL.cpp index f9e5b346b..547807508 100644 --- a/src/Nazara/Audio/OpenAL.cpp +++ b/src/Nazara/Audio/OpenAL.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Audio/Sound.cpp b/src/Nazara/Audio/Sound.cpp index 707ed3a21..c6e96fff8 100644 --- a/src/Nazara/Audio/Sound.cpp +++ b/src/Nazara/Audio/Sound.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Audio/SoundBuffer.cpp b/src/Nazara/Audio/SoundBuffer.cpp index 5641e3e57..82b726b19 100644 --- a/src/Nazara/Audio/SoundBuffer.cpp +++ b/src/Nazara/Audio/SoundBuffer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Audio/SoundEmitter.cpp b/src/Nazara/Audio/SoundEmitter.cpp index 40b7ccd59..1489cda62 100644 --- a/src/Nazara/Audio/SoundEmitter.cpp +++ b/src/Nazara/Audio/SoundEmitter.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Audio/SoundStream.cpp b/src/Nazara/Audio/SoundStream.cpp index 6bfdaafbe..e4f1a766e 100644 --- a/src/Nazara/Audio/SoundStream.cpp +++ b/src/Nazara/Audio/SoundStream.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Audio module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/AbstractHash.cpp b/src/Nazara/Core/AbstractHash.cpp index 39e5a2ef2..c45ec4b0f 100644 --- a/src/Nazara/Core/AbstractHash.cpp +++ b/src/Nazara/Core/AbstractHash.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/AbstractLogger.cpp b/src/Nazara/Core/AbstractLogger.cpp index 4ae945c0a..a6eddc6ed 100644 --- a/src/Nazara/Core/AbstractLogger.cpp +++ b/src/Nazara/Core/AbstractLogger.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/AlgorithmCore.cpp b/src/Nazara/Core/AlgorithmCore.cpp index 6d6b09b80..039a116e1 100644 --- a/src/Nazara/Core/AlgorithmCore.cpp +++ b/src/Nazara/Core/AlgorithmCore.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/ByteArray.cpp b/src/Nazara/Core/ByteArray.cpp index a6556c6d2..a49801201 100644 --- a/src/Nazara/Core/ByteArray.cpp +++ b/src/Nazara/Core/ByteArray.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/ByteStream.cpp b/src/Nazara/Core/ByteStream.cpp index 6559e50fb..782f4de42 100644 --- a/src/Nazara/Core/ByteStream.cpp +++ b/src/Nazara/Core/ByteStream.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Clock.cpp b/src/Nazara/Core/Clock.cpp index ee7e32acb..7b41422a9 100644 --- a/src/Nazara/Core/Clock.cpp +++ b/src/Nazara/Core/Clock.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Color.cpp b/src/Nazara/Core/Color.cpp index d87ab5cc6..d6cd528a5 100644 --- a/src/Nazara/Core/Color.cpp +++ b/src/Nazara/Core/Color.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Core.cpp b/src/Nazara/Core/Core.cpp index 614d6217b..7174425b9 100644 --- a/src/Nazara/Core/Core.cpp +++ b/src/Nazara/Core/Core.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Debug/NewOverload.cpp b/src/Nazara/Core/Debug/NewOverload.cpp index 95b2fc888..091f8b5c2 100644 --- a/src/Nazara/Core/Debug/NewOverload.cpp +++ b/src/Nazara/Core/Debug/NewOverload.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Debug/NewRedefinition.cpp b/src/Nazara/Core/Debug/NewRedefinition.cpp index 77aa93b00..89e7fc59a 100644 --- a/src/Nazara/Core/Debug/NewRedefinition.cpp +++ b/src/Nazara/Core/Debug/NewRedefinition.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/DynLib.cpp b/src/Nazara/Core/DynLib.cpp index 486d628b8..2565314d9 100644 --- a/src/Nazara/Core/DynLib.cpp +++ b/src/Nazara/Core/DynLib.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/EmptyStream.cpp b/src/Nazara/Core/EmptyStream.cpp index 5cba8af35..e30345294 100644 --- a/src/Nazara/Core/EmptyStream.cpp +++ b/src/Nazara/Core/EmptyStream.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Error.cpp b/src/Nazara/Core/Error.cpp index 424a898d0..090804ead 100644 --- a/src/Nazara/Core/Error.cpp +++ b/src/Nazara/Core/Error.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/ErrorFlags.cpp b/src/Nazara/Core/ErrorFlags.cpp index 01cc6fbcf..478799672 100644 --- a/src/Nazara/Core/ErrorFlags.cpp +++ b/src/Nazara/Core/ErrorFlags.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/File.cpp b/src/Nazara/Core/File.cpp index c11b92c1f..18a6d5a0a 100644 --- a/src/Nazara/Core/File.cpp +++ b/src/Nazara/Core/File.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/FileLogger.cpp b/src/Nazara/Core/FileLogger.cpp index 3d4b4a0f9..2ce6f03db 100644 --- a/src/Nazara/Core/FileLogger.cpp +++ b/src/Nazara/Core/FileLogger.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/GuillotineBinPack.cpp b/src/Nazara/Core/GuillotineBinPack.cpp index ef8e2f953..e0589966d 100644 --- a/src/Nazara/Core/GuillotineBinPack.cpp +++ b/src/Nazara/Core/GuillotineBinPack.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/HandledObject.cpp b/src/Nazara/Core/HandledObject.cpp index 664912a6c..f140330ff 100644 --- a/src/Nazara/Core/HandledObject.cpp +++ b/src/Nazara/Core/HandledObject.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/HardwareInfo.cpp b/src/Nazara/Core/HardwareInfo.cpp index a22bbbdf6..f90560e9d 100644 --- a/src/Nazara/Core/HardwareInfo.cpp +++ b/src/Nazara/Core/HardwareInfo.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Hash/CRC32.cpp b/src/Nazara/Core/Hash/CRC32.cpp index db4a52634..52435ac89 100644 --- a/src/Nazara/Core/Hash/CRC32.cpp +++ b/src/Nazara/Core/Hash/CRC32.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Hash/CRC64.cpp b/src/Nazara/Core/Hash/CRC64.cpp index 3001009a3..7dfa4660c 100644 --- a/src/Nazara/Core/Hash/CRC64.cpp +++ b/src/Nazara/Core/Hash/CRC64.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Hash/Fletcher16.cpp b/src/Nazara/Core/Hash/Fletcher16.cpp index d1d563aca..5afb1ad8a 100644 --- a/src/Nazara/Core/Hash/Fletcher16.cpp +++ b/src/Nazara/Core/Hash/Fletcher16.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Hash/MD5.cpp b/src/Nazara/Core/Hash/MD5.cpp index b0f25d684..76df113a7 100644 --- a/src/Nazara/Core/Hash/MD5.cpp +++ b/src/Nazara/Core/Hash/MD5.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Hash/SHA/Internal.cpp b/src/Nazara/Core/Hash/SHA/Internal.cpp index 91d6d5e9c..af54fb758 100644 --- a/src/Nazara/Core/Hash/SHA/Internal.cpp +++ b/src/Nazara/Core/Hash/SHA/Internal.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Hash/SHA/Internal.hpp b/src/Nazara/Core/Hash/SHA/Internal.hpp index a4544f309..f5ca6d06c 100644 --- a/src/Nazara/Core/Hash/SHA/Internal.hpp +++ b/src/Nazara/Core/Hash/SHA/Internal.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Hash/SHA1.cpp b/src/Nazara/Core/Hash/SHA1.cpp index 6ba573a10..3fa6b0d06 100644 --- a/src/Nazara/Core/Hash/SHA1.cpp +++ b/src/Nazara/Core/Hash/SHA1.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Hash/SHA224.cpp b/src/Nazara/Core/Hash/SHA224.cpp index 0cf5e8777..5abafaa64 100644 --- a/src/Nazara/Core/Hash/SHA224.cpp +++ b/src/Nazara/Core/Hash/SHA224.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Hash/SHA256.cpp b/src/Nazara/Core/Hash/SHA256.cpp index fec15b074..dd085456d 100644 --- a/src/Nazara/Core/Hash/SHA256.cpp +++ b/src/Nazara/Core/Hash/SHA256.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Hash/SHA384.cpp b/src/Nazara/Core/Hash/SHA384.cpp index 7fdb85ea9..4c794b4b8 100644 --- a/src/Nazara/Core/Hash/SHA384.cpp +++ b/src/Nazara/Core/Hash/SHA384.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Hash/SHA512.cpp b/src/Nazara/Core/Hash/SHA512.cpp index 27812fdb7..258908063 100644 --- a/src/Nazara/Core/Hash/SHA512.cpp +++ b/src/Nazara/Core/Hash/SHA512.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Hash/Whirlpool.cpp b/src/Nazara/Core/Hash/Whirlpool.cpp index e01fb4f4f..6980a5ad3 100644 --- a/src/Nazara/Core/Hash/Whirlpool.cpp +++ b/src/Nazara/Core/Hash/Whirlpool.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Log.cpp b/src/Nazara/Core/Log.cpp index b3dfed34a..cce990be9 100644 --- a/src/Nazara/Core/Log.cpp +++ b/src/Nazara/Core/Log.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/MemoryManager.cpp b/src/Nazara/Core/MemoryManager.cpp index ad175126e..ac8b5ee81 100644 --- a/src/Nazara/Core/MemoryManager.cpp +++ b/src/Nazara/Core/MemoryManager.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/MemoryStream.cpp b/src/Nazara/Core/MemoryStream.cpp index 31a9cdf6a..884ab64d5 100644 --- a/src/Nazara/Core/MemoryStream.cpp +++ b/src/Nazara/Core/MemoryStream.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/MemoryView.cpp b/src/Nazara/Core/MemoryView.cpp index 0d69b7a53..12d8c3fe5 100644 --- a/src/Nazara/Core/MemoryView.cpp +++ b/src/Nazara/Core/MemoryView.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/ParameterList.cpp b/src/Nazara/Core/ParameterList.cpp index 25298b950..a0562fc16 100644 --- a/src/Nazara/Core/ParameterList.cpp +++ b/src/Nazara/Core/ParameterList.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/PluginManager.cpp b/src/Nazara/Core/PluginManager.cpp index 8d0769c5e..215854c15 100644 --- a/src/Nazara/Core/PluginManager.cpp +++ b/src/Nazara/Core/PluginManager.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/PoolByteStream.cpp b/src/Nazara/Core/PoolByteStream.cpp index 889fe32ca..ca778b44d 100644 --- a/src/Nazara/Core/PoolByteStream.cpp +++ b/src/Nazara/Core/PoolByteStream.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/PrimitiveList.cpp b/src/Nazara/Core/PrimitiveList.cpp index 038ebe98e..daa54df69 100644 --- a/src/Nazara/Core/PrimitiveList.cpp +++ b/src/Nazara/Core/PrimitiveList.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/RefCounted.cpp b/src/Nazara/Core/RefCounted.cpp index 42fbe5aaa..cab4b2fac 100644 --- a/src/Nazara/Core/RefCounted.cpp +++ b/src/Nazara/Core/RefCounted.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Resource.cpp b/src/Nazara/Core/Resource.cpp index d409d15cc..739e49f4d 100644 --- a/src/Nazara/Core/Resource.cpp +++ b/src/Nazara/Core/Resource.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/SerializationContext.cpp b/src/Nazara/Core/SerializationContext.cpp index cf9711bea..38feb2ad6 100644 --- a/src/Nazara/Core/SerializationContext.cpp +++ b/src/Nazara/Core/SerializationContext.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/StdLogger.cpp b/src/Nazara/Core/StdLogger.cpp index 9fb14c140..171139188 100644 --- a/src/Nazara/Core/StdLogger.cpp +++ b/src/Nazara/Core/StdLogger.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Stream.cpp b/src/Nazara/Core/Stream.cpp index c607ff313..5935a6ce3 100644 --- a/src/Nazara/Core/Stream.cpp +++ b/src/Nazara/Core/Stream.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/String.cpp b/src/Nazara/Core/String.cpp index 438565449..054be149f 100644 --- a/src/Nazara/Core/String.cpp +++ b/src/Nazara/Core/String.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/StringExt.cpp b/src/Nazara/Core/StringExt.cpp index b1bd95042..3dbdb041e 100644 --- a/src/Nazara/Core/StringExt.cpp +++ b/src/Nazara/Core/StringExt.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/StringStream.cpp b/src/Nazara/Core/StringStream.cpp index 4b206489e..d6b17cac8 100644 --- a/src/Nazara/Core/StringStream.cpp +++ b/src/Nazara/Core/StringStream.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/TaskScheduler.cpp b/src/Nazara/Core/TaskScheduler.cpp index fc14c5ea6..dc992953e 100644 --- a/src/Nazara/Core/TaskScheduler.cpp +++ b/src/Nazara/Core/TaskScheduler.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Unicode.cpp b/src/Nazara/Core/Unicode.cpp index 5b20ebce6..28be2bc93 100644 --- a/src/Nazara/Core/Unicode.cpp +++ b/src/Nazara/Core/Unicode.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Updatable.cpp b/src/Nazara/Core/Updatable.cpp index 1ce56e3fd..4acd28d8b 100644 --- a/src/Nazara/Core/Updatable.cpp +++ b/src/Nazara/Core/Updatable.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/ClockImpl.cpp b/src/Nazara/Core/Win32/ClockImpl.cpp index d78e7328c..a2fa8a996 100644 --- a/src/Nazara/Core/Win32/ClockImpl.cpp +++ b/src/Nazara/Core/Win32/ClockImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/ClockImpl.hpp b/src/Nazara/Core/Win32/ClockImpl.hpp index 5a234e674..18410899b 100644 --- a/src/Nazara/Core/Win32/ClockImpl.hpp +++ b/src/Nazara/Core/Win32/ClockImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/DynLibImpl.cpp b/src/Nazara/Core/Win32/DynLibImpl.cpp index d2cbecb7d..8db998956 100644 --- a/src/Nazara/Core/Win32/DynLibImpl.cpp +++ b/src/Nazara/Core/Win32/DynLibImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/DynLibImpl.hpp b/src/Nazara/Core/Win32/DynLibImpl.hpp index 31a279103..2b0ede570 100644 --- a/src/Nazara/Core/Win32/DynLibImpl.hpp +++ b/src/Nazara/Core/Win32/DynLibImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/FileImpl.cpp b/src/Nazara/Core/Win32/FileImpl.cpp index 5b1fe952b..fd58fc9d8 100644 --- a/src/Nazara/Core/Win32/FileImpl.cpp +++ b/src/Nazara/Core/Win32/FileImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/FileImpl.hpp b/src/Nazara/Core/Win32/FileImpl.hpp index 3380a71e4..6c7e75203 100644 --- a/src/Nazara/Core/Win32/FileImpl.hpp +++ b/src/Nazara/Core/Win32/FileImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/HardwareInfoImpl.cpp b/src/Nazara/Core/Win32/HardwareInfoImpl.cpp index e1cdfaf50..7d75153ee 100644 --- a/src/Nazara/Core/Win32/HardwareInfoImpl.cpp +++ b/src/Nazara/Core/Win32/HardwareInfoImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/HardwareInfoImpl.hpp b/src/Nazara/Core/Win32/HardwareInfoImpl.hpp index e3f4d612d..d2e4c3937 100644 --- a/src/Nazara/Core/Win32/HardwareInfoImpl.hpp +++ b/src/Nazara/Core/Win32/HardwareInfoImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/TaskSchedulerImpl.cpp b/src/Nazara/Core/Win32/TaskSchedulerImpl.cpp index 3aba937e4..b24b4ab28 100644 --- a/src/Nazara/Core/Win32/TaskSchedulerImpl.cpp +++ b/src/Nazara/Core/Win32/TaskSchedulerImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/TaskSchedulerImpl.hpp b/src/Nazara/Core/Win32/TaskSchedulerImpl.hpp index fa41d6e71..f40ac0fe1 100644 --- a/src/Nazara/Core/Win32/TaskSchedulerImpl.hpp +++ b/src/Nazara/Core/Win32/TaskSchedulerImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/Time.cpp b/src/Nazara/Core/Win32/Time.cpp index 2fab92eb3..e926a2b9e 100644 --- a/src/Nazara/Core/Win32/Time.cpp +++ b/src/Nazara/Core/Win32/Time.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Core/Win32/Time.hpp b/src/Nazara/Core/Win32/Time.hpp index 25ac664c1..2e784a409 100644 --- a/src/Nazara/Core/Win32/Time.hpp +++ b/src/Nazara/Core/Win32/Time.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/AbstractBackground.cpp b/src/Nazara/Graphics/AbstractBackground.cpp index 5d1f23a6d..3a0600c85 100644 --- a/src/Nazara/Graphics/AbstractBackground.cpp +++ b/src/Nazara/Graphics/AbstractBackground.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/AbstractRenderQueue.cpp b/src/Nazara/Graphics/AbstractRenderQueue.cpp index c623b218f..b5878cc78 100644 --- a/src/Nazara/Graphics/AbstractRenderQueue.cpp +++ b/src/Nazara/Graphics/AbstractRenderQueue.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/AbstractRenderTechnique.cpp b/src/Nazara/Graphics/AbstractRenderTechnique.cpp index 963582d45..9dad6e24e 100644 --- a/src/Nazara/Graphics/AbstractRenderTechnique.cpp +++ b/src/Nazara/Graphics/AbstractRenderTechnique.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/AbstractViewer.cpp b/src/Nazara/Graphics/AbstractViewer.cpp index e9d91c92c..e2c4a8f8e 100644 --- a/src/Nazara/Graphics/AbstractViewer.cpp +++ b/src/Nazara/Graphics/AbstractViewer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/BasicRenderQueue.cpp b/src/Nazara/Graphics/BasicRenderQueue.cpp index ece80a421..2b8dd58a3 100644 --- a/src/Nazara/Graphics/BasicRenderQueue.cpp +++ b/src/Nazara/Graphics/BasicRenderQueue.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/Billboard.cpp b/src/Nazara/Graphics/Billboard.cpp index 35021ef8d..4ad49d097 100644 --- a/src/Nazara/Graphics/Billboard.cpp +++ b/src/Nazara/Graphics/Billboard.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/ColorBackground.cpp b/src/Nazara/Graphics/ColorBackground.cpp index b5c41e7c2..465b29964 100644 --- a/src/Nazara/Graphics/ColorBackground.cpp +++ b/src/Nazara/Graphics/ColorBackground.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/Debug/NewOverload.cpp b/src/Nazara/Graphics/Debug/NewOverload.cpp index b79e8408e..74d124395 100644 --- a/src/Nazara/Graphics/Debug/NewOverload.cpp +++ b/src/Nazara/Graphics/Debug/NewOverload.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/DeferredBloomPass.cpp b/src/Nazara/Graphics/DeferredBloomPass.cpp index 380bf532d..0ce2985f1 100644 --- a/src/Nazara/Graphics/DeferredBloomPass.cpp +++ b/src/Nazara/Graphics/DeferredBloomPass.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/DeferredDOFPass.cpp b/src/Nazara/Graphics/DeferredDOFPass.cpp index 1aebdcaa6..a13eb31f4 100644 --- a/src/Nazara/Graphics/DeferredDOFPass.cpp +++ b/src/Nazara/Graphics/DeferredDOFPass.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/DeferredFXAAPass.cpp b/src/Nazara/Graphics/DeferredFXAAPass.cpp index 91174aaa7..eb8052b8a 100644 --- a/src/Nazara/Graphics/DeferredFXAAPass.cpp +++ b/src/Nazara/Graphics/DeferredFXAAPass.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/DeferredFinalPass.cpp b/src/Nazara/Graphics/DeferredFinalPass.cpp index 265989233..996104a26 100644 --- a/src/Nazara/Graphics/DeferredFinalPass.cpp +++ b/src/Nazara/Graphics/DeferredFinalPass.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/DeferredFogPass.cpp b/src/Nazara/Graphics/DeferredFogPass.cpp index 77432f6d2..826e26d1d 100644 --- a/src/Nazara/Graphics/DeferredFogPass.cpp +++ b/src/Nazara/Graphics/DeferredFogPass.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/DeferredForwardPass.cpp b/src/Nazara/Graphics/DeferredForwardPass.cpp index e4685d3ae..e4be9e955 100644 --- a/src/Nazara/Graphics/DeferredForwardPass.cpp +++ b/src/Nazara/Graphics/DeferredForwardPass.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/DeferredGeometryPass.cpp b/src/Nazara/Graphics/DeferredGeometryPass.cpp index 0129c4980..18afe9236 100644 --- a/src/Nazara/Graphics/DeferredGeometryPass.cpp +++ b/src/Nazara/Graphics/DeferredGeometryPass.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/DeferredPhongLightingPass.cpp b/src/Nazara/Graphics/DeferredPhongLightingPass.cpp index 7e4ef2480..f9c7a77b9 100644 --- a/src/Nazara/Graphics/DeferredPhongLightingPass.cpp +++ b/src/Nazara/Graphics/DeferredPhongLightingPass.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/DeferredProxyRenderQueue.cpp b/src/Nazara/Graphics/DeferredProxyRenderQueue.cpp index 56d2b76d3..c016b4496 100644 --- a/src/Nazara/Graphics/DeferredProxyRenderQueue.cpp +++ b/src/Nazara/Graphics/DeferredProxyRenderQueue.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/DeferredRenderPass.cpp b/src/Nazara/Graphics/DeferredRenderPass.cpp index d3f89e348..e8e1ff289 100644 --- a/src/Nazara/Graphics/DeferredRenderPass.cpp +++ b/src/Nazara/Graphics/DeferredRenderPass.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/DeferredRenderTechnique.cpp b/src/Nazara/Graphics/DeferredRenderTechnique.cpp index 34db9e271..e4d435df0 100644 --- a/src/Nazara/Graphics/DeferredRenderTechnique.cpp +++ b/src/Nazara/Graphics/DeferredRenderTechnique.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/DepthRenderQueue.cpp b/src/Nazara/Graphics/DepthRenderQueue.cpp index 71c985097..9c684b28a 100644 --- a/src/Nazara/Graphics/DepthRenderQueue.cpp +++ b/src/Nazara/Graphics/DepthRenderQueue.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/DepthRenderTechnique.cpp b/src/Nazara/Graphics/DepthRenderTechnique.cpp index 531b9988a..44eb1e9f7 100644 --- a/src/Nazara/Graphics/DepthRenderTechnique.cpp +++ b/src/Nazara/Graphics/DepthRenderTechnique.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/Drawable.cpp b/src/Nazara/Graphics/Drawable.cpp index 79df17ef1..3695fa1cd 100644 --- a/src/Nazara/Graphics/Drawable.cpp +++ b/src/Nazara/Graphics/Drawable.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/Formats/MeshLoader.cpp b/src/Nazara/Graphics/Formats/MeshLoader.cpp index 5b8df3932..f804cf4cb 100644 --- a/src/Nazara/Graphics/Formats/MeshLoader.cpp +++ b/src/Nazara/Graphics/Formats/MeshLoader.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/Formats/MeshLoader.hpp b/src/Nazara/Graphics/Formats/MeshLoader.hpp index 558d3dfb3..68e08f079 100644 --- a/src/Nazara/Graphics/Formats/MeshLoader.hpp +++ b/src/Nazara/Graphics/Formats/MeshLoader.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/Formats/TextureLoader.cpp b/src/Nazara/Graphics/Formats/TextureLoader.cpp index cda56c187..e8555b6db 100644 --- a/src/Nazara/Graphics/Formats/TextureLoader.cpp +++ b/src/Nazara/Graphics/Formats/TextureLoader.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/Formats/TextureLoader.hpp b/src/Nazara/Graphics/Formats/TextureLoader.hpp index 483d69546..f6dba4711 100644 --- a/src/Nazara/Graphics/Formats/TextureLoader.hpp +++ b/src/Nazara/Graphics/Formats/TextureLoader.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/ForwardRenderTechnique.cpp b/src/Nazara/Graphics/ForwardRenderTechnique.cpp index 77098ecf5..d620a3076 100644 --- a/src/Nazara/Graphics/ForwardRenderTechnique.cpp +++ b/src/Nazara/Graphics/ForwardRenderTechnique.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/Graphics.cpp b/src/Nazara/Graphics/Graphics.cpp index b8538a163..9757d661b 100644 --- a/src/Nazara/Graphics/Graphics.cpp +++ b/src/Nazara/Graphics/Graphics.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/GuillotineTextureAtlas.cpp b/src/Nazara/Graphics/GuillotineTextureAtlas.cpp index 9c59baa7b..b413ed76a 100644 --- a/src/Nazara/Graphics/GuillotineTextureAtlas.cpp +++ b/src/Nazara/Graphics/GuillotineTextureAtlas.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/InstancedRenderable.cpp b/src/Nazara/Graphics/InstancedRenderable.cpp index 5eb0f17fa..412c4809e 100644 --- a/src/Nazara/Graphics/InstancedRenderable.cpp +++ b/src/Nazara/Graphics/InstancedRenderable.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/Light.cpp b/src/Nazara/Graphics/Light.cpp index c891204a7..4156ee77d 100644 --- a/src/Nazara/Graphics/Light.cpp +++ b/src/Nazara/Graphics/Light.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/Material.cpp b/src/Nazara/Graphics/Material.cpp index 08b769c1a..cdfd619fe 100644 --- a/src/Nazara/Graphics/Material.cpp +++ b/src/Nazara/Graphics/Material.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/MaterialPipeline.cpp b/src/Nazara/Graphics/MaterialPipeline.cpp index 37e5f8ca0..a3f84ecdf 100644 --- a/src/Nazara/Graphics/MaterialPipeline.cpp +++ b/src/Nazara/Graphics/MaterialPipeline.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/Model.cpp b/src/Nazara/Graphics/Model.cpp index 31187023b..1a2bc0814 100644 --- a/src/Nazara/Graphics/Model.cpp +++ b/src/Nazara/Graphics/Model.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/ParticleController.cpp b/src/Nazara/Graphics/ParticleController.cpp index ab94bae69..a760314cf 100644 --- a/src/Nazara/Graphics/ParticleController.cpp +++ b/src/Nazara/Graphics/ParticleController.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/ParticleDeclaration.cpp b/src/Nazara/Graphics/ParticleDeclaration.cpp index a9a8e983d..99fdf8dd7 100644 --- a/src/Nazara/Graphics/ParticleDeclaration.cpp +++ b/src/Nazara/Graphics/ParticleDeclaration.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/ParticleEmitter.cpp b/src/Nazara/Graphics/ParticleEmitter.cpp index fe1b17e82..dd9b5fc28 100644 --- a/src/Nazara/Graphics/ParticleEmitter.cpp +++ b/src/Nazara/Graphics/ParticleEmitter.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/ParticleFunctionController.cpp b/src/Nazara/Graphics/ParticleFunctionController.cpp index 0519d08cc..270f329e0 100644 --- a/src/Nazara/Graphics/ParticleFunctionController.cpp +++ b/src/Nazara/Graphics/ParticleFunctionController.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/ParticleFunctionGenerator.cpp b/src/Nazara/Graphics/ParticleFunctionGenerator.cpp index 649fc1c12..65c46d60a 100644 --- a/src/Nazara/Graphics/ParticleFunctionGenerator.cpp +++ b/src/Nazara/Graphics/ParticleFunctionGenerator.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/ParticleFunctionRenderer.cpp b/src/Nazara/Graphics/ParticleFunctionRenderer.cpp index 779dc4e6d..b395df916 100644 --- a/src/Nazara/Graphics/ParticleFunctionRenderer.cpp +++ b/src/Nazara/Graphics/ParticleFunctionRenderer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/ParticleGenerator.cpp b/src/Nazara/Graphics/ParticleGenerator.cpp index edb745e99..295f56105 100644 --- a/src/Nazara/Graphics/ParticleGenerator.cpp +++ b/src/Nazara/Graphics/ParticleGenerator.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/ParticleGroup.cpp b/src/Nazara/Graphics/ParticleGroup.cpp index 0bad010a4..d2df6f201 100644 --- a/src/Nazara/Graphics/ParticleGroup.cpp +++ b/src/Nazara/Graphics/ParticleGroup.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/ParticleMapper.cpp b/src/Nazara/Graphics/ParticleMapper.cpp index ef48e8c14..a70043c39 100644 --- a/src/Nazara/Graphics/ParticleMapper.cpp +++ b/src/Nazara/Graphics/ParticleMapper.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/ParticleRenderer.cpp b/src/Nazara/Graphics/ParticleRenderer.cpp index 9195d05ae..cc06c87ce 100644 --- a/src/Nazara/Graphics/ParticleRenderer.cpp +++ b/src/Nazara/Graphics/ParticleRenderer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/RenderQueue.cpp b/src/Nazara/Graphics/RenderQueue.cpp index 3baa8ecc1..c94f999da 100644 --- a/src/Nazara/Graphics/RenderQueue.cpp +++ b/src/Nazara/Graphics/RenderQueue.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/RenderTechniques.cpp b/src/Nazara/Graphics/RenderTechniques.cpp index 5dc3c66cd..06a3db15d 100644 --- a/src/Nazara/Graphics/RenderTechniques.cpp +++ b/src/Nazara/Graphics/RenderTechniques.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/Renderable.cpp b/src/Nazara/Graphics/Renderable.cpp index 28a487209..6633bd173 100644 --- a/src/Nazara/Graphics/Renderable.cpp +++ b/src/Nazara/Graphics/Renderable.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/SkeletalModel.cpp b/src/Nazara/Graphics/SkeletalModel.cpp index 30ee9396d..4423bb167 100644 --- a/src/Nazara/Graphics/SkeletalModel.cpp +++ b/src/Nazara/Graphics/SkeletalModel.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/SkinningManager.cpp b/src/Nazara/Graphics/SkinningManager.cpp index 6460a1f1c..5c148838c 100644 --- a/src/Nazara/Graphics/SkinningManager.cpp +++ b/src/Nazara/Graphics/SkinningManager.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/SkyboxBackground.cpp b/src/Nazara/Graphics/SkyboxBackground.cpp index 411f3d0c1..5415c95f6 100644 --- a/src/Nazara/Graphics/SkyboxBackground.cpp +++ b/src/Nazara/Graphics/SkyboxBackground.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/Sprite.cpp b/src/Nazara/Graphics/Sprite.cpp index 6a01fd5d2..07499c3af 100644 --- a/src/Nazara/Graphics/Sprite.cpp +++ b/src/Nazara/Graphics/Sprite.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/TextSprite.cpp b/src/Nazara/Graphics/TextSprite.cpp index f253b5539..8f00aba93 100644 --- a/src/Nazara/Graphics/TextSprite.cpp +++ b/src/Nazara/Graphics/TextSprite.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/TextureBackground.cpp b/src/Nazara/Graphics/TextureBackground.cpp index 25de25d9e..9b115ecef 100644 --- a/src/Nazara/Graphics/TextureBackground.cpp +++ b/src/Nazara/Graphics/TextureBackground.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Graphics/TileMap.cpp b/src/Nazara/Graphics/TileMap.cpp index 4789f4a8b..71bdc6af1 100644 --- a/src/Nazara/Graphics/TileMap.cpp +++ b/src/Nazara/Graphics/TileMap.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/AbstractSocket.cpp b/src/Nazara/Network/AbstractSocket.cpp index 64bdd0e0d..321df9034 100644 --- a/src/Nazara/Network/AbstractSocket.cpp +++ b/src/Nazara/Network/AbstractSocket.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/AlgorithmNetwork.cpp b/src/Nazara/Network/AlgorithmNetwork.cpp index 55d6a5569..bc9bbb811 100644 --- a/src/Nazara/Network/AlgorithmNetwork.cpp +++ b/src/Nazara/Network/AlgorithmNetwork.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/Debug/NewOverload.cpp b/src/Nazara/Network/Debug/NewOverload.cpp index b6d707ee5..720a86469 100644 --- a/src/Nazara/Network/Debug/NewOverload.cpp +++ b/src/Nazara/Network/Debug/NewOverload.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/ENetCompressor.cpp b/src/Nazara/Network/ENetCompressor.cpp index 373389ecc..88297603e 100644 --- a/src/Nazara/Network/ENetCompressor.cpp +++ b/src/Nazara/Network/ENetCompressor.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/ENetHost.cpp b/src/Nazara/Network/ENetHost.cpp index 04119a330..42b5a62e2 100644 --- a/src/Nazara/Network/ENetHost.cpp +++ b/src/Nazara/Network/ENetHost.cpp @@ -8,7 +8,7 @@ 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. */ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/ENetPacket.cpp b/src/Nazara/Network/ENetPacket.cpp index 4b4157ac4..07be92c31 100644 --- a/src/Nazara/Network/ENetPacket.cpp +++ b/src/Nazara/Network/ENetPacket.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/ENetPeer.cpp b/src/Nazara/Network/ENetPeer.cpp index 294585631..0f9954847 100644 --- a/src/Nazara/Network/ENetPeer.cpp +++ b/src/Nazara/Network/ENetPeer.cpp @@ -8,7 +8,7 @@ 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. */ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/IpAddress.cpp b/src/Nazara/Network/IpAddress.cpp index aee2550f3..6c3c7d3f4 100644 --- a/src/Nazara/Network/IpAddress.cpp +++ b/src/Nazara/Network/IpAddress.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/NetPacket.cpp b/src/Nazara/Network/NetPacket.cpp index 0887e7d3f..24db7be0c 100644 --- a/src/Nazara/Network/NetPacket.cpp +++ b/src/Nazara/Network/NetPacket.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/Network.cpp b/src/Nazara/Network/Network.cpp index 392b196b6..f929a681c 100644 --- a/src/Nazara/Network/Network.cpp +++ b/src/Nazara/Network/Network.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/RUdpConnection.cpp b/src/Nazara/Network/RUdpConnection.cpp index 3667eb113..6d317d7eb 100644 --- a/src/Nazara/Network/RUdpConnection.cpp +++ b/src/Nazara/Network/RUdpConnection.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/SocketPoller.cpp b/src/Nazara/Network/SocketPoller.cpp index 20b575b62..5ef9f617a 100644 --- a/src/Nazara/Network/SocketPoller.cpp +++ b/src/Nazara/Network/SocketPoller.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/SystemSocket.hpp b/src/Nazara/Network/SystemSocket.hpp index df71c43c7..eab505a17 100644 --- a/src/Nazara/Network/SystemSocket.hpp +++ b/src/Nazara/Network/SystemSocket.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/TcpClient.cpp b/src/Nazara/Network/TcpClient.cpp index de8e2771d..6920f8216 100644 --- a/src/Nazara/Network/TcpClient.cpp +++ b/src/Nazara/Network/TcpClient.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/TcpServer.cpp b/src/Nazara/Network/TcpServer.cpp index ebeb2392e..e062d082a 100644 --- a/src/Nazara/Network/TcpServer.cpp +++ b/src/Nazara/Network/TcpServer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/UdpSocket.cpp b/src/Nazara/Network/UdpSocket.cpp index a44ad3c14..5d8e87f17 100644 --- a/src/Nazara/Network/UdpSocket.cpp +++ b/src/Nazara/Network/UdpSocket.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/Win32/IpAddressImpl.cpp b/src/Nazara/Network/Win32/IpAddressImpl.cpp index 38da48b4b..5b9e402fe 100644 --- a/src/Nazara/Network/Win32/IpAddressImpl.cpp +++ b/src/Nazara/Network/Win32/IpAddressImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/Win32/IpAddressImpl.hpp b/src/Nazara/Network/Win32/IpAddressImpl.hpp index 3415906d9..2a6c79cdd 100644 --- a/src/Nazara/Network/Win32/IpAddressImpl.hpp +++ b/src/Nazara/Network/Win32/IpAddressImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/Win32/SocketImpl.cpp b/src/Nazara/Network/Win32/SocketImpl.cpp index f9e4b42f5..468948133 100644 --- a/src/Nazara/Network/Win32/SocketImpl.cpp +++ b/src/Nazara/Network/Win32/SocketImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2018 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/Win32/SocketImpl.hpp b/src/Nazara/Network/Win32/SocketImpl.hpp index 36ba874ee..d43fca859 100644 --- a/src/Nazara/Network/Win32/SocketImpl.hpp +++ b/src/Nazara/Network/Win32/SocketImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/Win32/SocketPollerImpl.cpp b/src/Nazara/Network/Win32/SocketPollerImpl.cpp index f6272b246..93142e755 100644 --- a/src/Nazara/Network/Win32/SocketPollerImpl.cpp +++ b/src/Nazara/Network/Win32/SocketPollerImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Network/Win32/SocketPollerImpl.hpp b/src/Nazara/Network/Win32/SocketPollerImpl.hpp index 611548591..bc9642ae3 100644 --- a/src/Nazara/Network/Win32/SocketPollerImpl.hpp +++ b/src/Nazara/Network/Win32/SocketPollerImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Physics2D/Arbiter2D.cpp b/src/Nazara/Physics2D/Arbiter2D.cpp index 56668bbe5..9da160216 100644 --- a/src/Nazara/Physics2D/Arbiter2D.cpp +++ b/src/Nazara/Physics2D/Arbiter2D.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Physics2D/Collider2D.cpp b/src/Nazara/Physics2D/Collider2D.cpp index 16587a092..9d0743b88 100644 --- a/src/Nazara/Physics2D/Collider2D.cpp +++ b/src/Nazara/Physics2D/Collider2D.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Physics2D/Constraint2D.cpp b/src/Nazara/Physics2D/Constraint2D.cpp index e4ad5e407..ec8592a46 100644 --- a/src/Nazara/Physics2D/Constraint2D.cpp +++ b/src/Nazara/Physics2D/Constraint2D.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Physics2D/Debug/NewOverload.cpp b/src/Nazara/Physics2D/Debug/NewOverload.cpp index 0bbef36d9..4563d007b 100644 --- a/src/Nazara/Physics2D/Debug/NewOverload.cpp +++ b/src/Nazara/Physics2D/Debug/NewOverload.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Physics2D/PhysWorld2D.cpp b/src/Nazara/Physics2D/PhysWorld2D.cpp index 0296558ec..d7d9552af 100644 --- a/src/Nazara/Physics2D/PhysWorld2D.cpp +++ b/src/Nazara/Physics2D/PhysWorld2D.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Physics2D/Physics2D.cpp b/src/Nazara/Physics2D/Physics2D.cpp index f6acdb152..de3f1e5e8 100644 --- a/src/Nazara/Physics2D/Physics2D.cpp +++ b/src/Nazara/Physics2D/Physics2D.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Physics2D/RigidBody2D.cpp b/src/Nazara/Physics2D/RigidBody2D.cpp index 1e3835bdd..656fdb03f 100644 --- a/src/Nazara/Physics2D/RigidBody2D.cpp +++ b/src/Nazara/Physics2D/RigidBody2D.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 2D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Physics3D/Collider3D.cpp b/src/Nazara/Physics3D/Collider3D.cpp index be4436a61..1cd0515e5 100644 --- a/src/Nazara/Physics3D/Collider3D.cpp +++ b/src/Nazara/Physics3D/Collider3D.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Physics3D/Debug/NewOverload.cpp b/src/Nazara/Physics3D/Debug/NewOverload.cpp index da675a56f..6a720e4b4 100644 --- a/src/Nazara/Physics3D/Debug/NewOverload.cpp +++ b/src/Nazara/Physics3D/Debug/NewOverload.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Physics3D/PhysWorld3D.cpp b/src/Nazara/Physics3D/PhysWorld3D.cpp index bce1f5b6d..9377d1cee 100644 --- a/src/Nazara/Physics3D/PhysWorld3D.cpp +++ b/src/Nazara/Physics3D/PhysWorld3D.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Physics3D/Physics3D.cpp b/src/Nazara/Physics3D/Physics3D.cpp index 033d13374..03d873408 100644 --- a/src/Nazara/Physics3D/Physics3D.cpp +++ b/src/Nazara/Physics3D/Physics3D.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Physics3D/RigidBody3D.cpp b/src/Nazara/Physics3D/RigidBody3D.cpp index c18055f56..15cfa0e31 100644 --- a/src/Nazara/Physics3D/RigidBody3D.cpp +++ b/src/Nazara/Physics3D/RigidBody3D.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Physics 3D module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Platform/Cursor.cpp b/src/Nazara/Platform/Cursor.cpp index 7d68a460b..a6f35a3e5 100644 --- a/src/Nazara/Platform/Cursor.cpp +++ b/src/Nazara/Platform/Cursor.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Platform/Debug/NewOverload.cpp b/src/Nazara/Platform/Debug/NewOverload.cpp index c5522beb8..d11cb08ab 100644 --- a/src/Nazara/Platform/Debug/NewOverload.cpp +++ b/src/Nazara/Platform/Debug/NewOverload.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Platform/Icon.cpp b/src/Nazara/Platform/Icon.cpp index 010e9dfc2..8cc0cf5f3 100644 --- a/src/Nazara/Platform/Icon.cpp +++ b/src/Nazara/Platform/Icon.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Platform/Keyboard.cpp b/src/Nazara/Platform/Keyboard.cpp index be1341eb6..b47acdd86 100644 --- a/src/Nazara/Platform/Keyboard.cpp +++ b/src/Nazara/Platform/Keyboard.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Platform/Mouse.cpp b/src/Nazara/Platform/Mouse.cpp index 6d589697e..e7c56ab47 100644 --- a/src/Nazara/Platform/Mouse.cpp +++ b/src/Nazara/Platform/Mouse.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Platform/Platform.cpp b/src/Nazara/Platform/Platform.cpp index 5151ed123..9c4d32b2c 100644 --- a/src/Nazara/Platform/Platform.cpp +++ b/src/Nazara/Platform/Platform.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Platform/VideoMode.cpp b/src/Nazara/Platform/VideoMode.cpp index 5cc78d981..8d0db4f46 100644 --- a/src/Nazara/Platform/VideoMode.cpp +++ b/src/Nazara/Platform/VideoMode.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Platform/VideoModeImpl.hpp b/src/Nazara/Platform/VideoModeImpl.hpp index b5be4b3b1..9bbc040aa 100644 --- a/src/Nazara/Platform/VideoModeImpl.hpp +++ b/src/Nazara/Platform/VideoModeImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Platform/Win32/CursorImpl.cpp b/src/Nazara/Platform/Win32/CursorImpl.cpp index 48d960f92..8af6502fe 100644 --- a/src/Nazara/Platform/Win32/CursorImpl.cpp +++ b/src/Nazara/Platform/Win32/CursorImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Platform/Win32/CursorImpl.hpp b/src/Nazara/Platform/Win32/CursorImpl.hpp index c3c1f4040..056e70f36 100644 --- a/src/Nazara/Platform/Win32/CursorImpl.hpp +++ b/src/Nazara/Platform/Win32/CursorImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Platform/Win32/IconImpl.cpp b/src/Nazara/Platform/Win32/IconImpl.cpp index 14a67cfba..47839be16 100644 --- a/src/Nazara/Platform/Win32/IconImpl.cpp +++ b/src/Nazara/Platform/Win32/IconImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Platform/Win32/IconImpl.hpp b/src/Nazara/Platform/Win32/IconImpl.hpp index e3e7b49a9..895ce5e00 100644 --- a/src/Nazara/Platform/Win32/IconImpl.hpp +++ b/src/Nazara/Platform/Win32/IconImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Platform/Win32/InputImpl.cpp b/src/Nazara/Platform/Win32/InputImpl.cpp index 79a8b6a3c..73ec442fc 100644 --- a/src/Nazara/Platform/Win32/InputImpl.cpp +++ b/src/Nazara/Platform/Win32/InputImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Platform/Win32/InputImpl.hpp b/src/Nazara/Platform/Win32/InputImpl.hpp index fc5e226a5..3eda794b1 100644 --- a/src/Nazara/Platform/Win32/InputImpl.hpp +++ b/src/Nazara/Platform/Win32/InputImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Platform/Win32/VideoModeImpl.cpp b/src/Nazara/Platform/Win32/VideoModeImpl.cpp index 6102a568e..95c68a460 100644 --- a/src/Nazara/Platform/Win32/VideoModeImpl.cpp +++ b/src/Nazara/Platform/Win32/VideoModeImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Platform/Win32/VideoModeImpl.hpp b/src/Nazara/Platform/Win32/VideoModeImpl.hpp index 39579b9a2..cb3ff7f5a 100644 --- a/src/Nazara/Platform/Win32/VideoModeImpl.hpp +++ b/src/Nazara/Platform/Win32/VideoModeImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Platform/Win32/WindowImpl.cpp b/src/Nazara/Platform/Win32/WindowImpl.cpp index edc5dd1d6..8bac26a1f 100644 --- a/src/Nazara/Platform/Win32/WindowImpl.cpp +++ b/src/Nazara/Platform/Win32/WindowImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Platform/Win32/WindowImpl.hpp b/src/Nazara/Platform/Win32/WindowImpl.hpp index 8165ae8c5..8e7c1f5f6 100644 --- a/src/Nazara/Platform/Win32/WindowImpl.hpp +++ b/src/Nazara/Platform/Win32/WindowImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Platform/Window.cpp b/src/Nazara/Platform/Window.cpp index 90b6556a2..80980687b 100644 --- a/src/Nazara/Platform/Window.cpp +++ b/src/Nazara/Platform/Window.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Platform/X11/ScopedXCB.inl b/src/Nazara/Platform/X11/ScopedXCB.inl index 13c62bd56..a9e4cad00 100644 --- a/src/Nazara/Platform/X11/ScopedXCB.inl +++ b/src/Nazara/Platform/X11/ScopedXCB.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/Debug/NewOverload.cpp b/src/Nazara/Renderer/Debug/NewOverload.cpp index 1a198d979..96ed88e75 100644 --- a/src/Nazara/Renderer/Debug/NewOverload.cpp +++ b/src/Nazara/Renderer/Debug/NewOverload.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/HardwareBuffer.hpp b/src/Nazara/Renderer/HardwareBuffer.hpp index a640d3eb0..5a5146095 100644 --- a/src/Nazara/Renderer/HardwareBuffer.hpp +++ b/src/Nazara/Renderer/HardwareBuffer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/RenderWindow.cpp b/src/Nazara/Renderer/RenderWindow.cpp index 2fe2f99cb..9b76f21db 100644 --- a/src/Nazara/Renderer/RenderWindow.cpp +++ b/src/Nazara/Renderer/RenderWindow.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/Renderer.cpp b/src/Nazara/Renderer/Renderer.cpp index ea21ee99d..541dc4b6e 100644 --- a/src/Nazara/Renderer/Renderer.cpp +++ b/src/Nazara/Renderer/Renderer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/ShaderAst.cpp b/src/Nazara/Renderer/ShaderAst.cpp index ef6860d68..180930595 100644 --- a/src/Nazara/Renderer/ShaderAst.cpp +++ b/src/Nazara/Renderer/ShaderAst.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/Win32/ContextImpl.hpp b/src/Nazara/Renderer/Win32/ContextImpl.hpp index b3cf0d053..ffd61e12f 100644 --- a/src/Nazara/Renderer/Win32/ContextImpl.hpp +++ b/src/Nazara/Renderer/Win32/ContextImpl.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine". // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/AbstractAtlas.cpp b/src/Nazara/Utility/AbstractAtlas.cpp index 10e4d286f..82591526c 100644 --- a/src/Nazara/Utility/AbstractAtlas.cpp +++ b/src/Nazara/Utility/AbstractAtlas.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/AbstractBuffer.cpp b/src/Nazara/Utility/AbstractBuffer.cpp index aa550c5a5..ac4e9ee6d 100644 --- a/src/Nazara/Utility/AbstractBuffer.cpp +++ b/src/Nazara/Utility/AbstractBuffer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/AbstractImage.cpp b/src/Nazara/Utility/AbstractImage.cpp index f539605f1..a5605acd8 100644 --- a/src/Nazara/Utility/AbstractImage.cpp +++ b/src/Nazara/Utility/AbstractImage.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/AbstractTextDrawer.cpp b/src/Nazara/Utility/AbstractTextDrawer.cpp index 563c8bf57..ff5b3cd53 100644 --- a/src/Nazara/Utility/AbstractTextDrawer.cpp +++ b/src/Nazara/Utility/AbstractTextDrawer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/AlgorithmUtility.cpp b/src/Nazara/Utility/AlgorithmUtility.cpp index 22bf4bb43..8ad1970b4 100644 --- a/src/Nazara/Utility/AlgorithmUtility.cpp +++ b/src/Nazara/Utility/AlgorithmUtility.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Animation.cpp b/src/Nazara/Utility/Animation.cpp index 1a05ef423..81f627f8e 100644 --- a/src/Nazara/Utility/Animation.cpp +++ b/src/Nazara/Utility/Animation.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Buffer.cpp b/src/Nazara/Utility/Buffer.cpp index c4f0acbb9..22ec561e9 100644 --- a/src/Nazara/Utility/Buffer.cpp +++ b/src/Nazara/Utility/Buffer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Debug/NewOverload.cpp b/src/Nazara/Utility/Debug/NewOverload.cpp index 18bca9315..3b115fdd6 100644 --- a/src/Nazara/Utility/Debug/NewOverload.cpp +++ b/src/Nazara/Utility/Debug/NewOverload.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Font.cpp b/src/Nazara/Utility/Font.cpp index 7bbd80ad2..7900760d9 100644 --- a/src/Nazara/Utility/Font.cpp +++ b/src/Nazara/Utility/Font.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/FontData.cpp b/src/Nazara/Utility/FontData.cpp index 00480ec9f..e0c8240a5 100644 --- a/src/Nazara/Utility/FontData.cpp +++ b/src/Nazara/Utility/FontData.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/DDSConstants.cpp b/src/Nazara/Utility/Formats/DDSConstants.cpp index 0fda7ac16..605aed7b2 100644 --- a/src/Nazara/Utility/Formats/DDSConstants.cpp +++ b/src/Nazara/Utility/Formats/DDSConstants.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/DDSLoader.cpp b/src/Nazara/Utility/Formats/DDSLoader.cpp index 9fb93cc6e..b6d50ce2b 100644 --- a/src/Nazara/Utility/Formats/DDSLoader.cpp +++ b/src/Nazara/Utility/Formats/DDSLoader.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq - 2009 Cruden BV +// Copyright (C) 2020 Jérôme Leclercq - 2009 Cruden BV // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/DDSLoader.hpp b/src/Nazara/Utility/Formats/DDSLoader.hpp index dc95ce950..97dca0e83 100644 --- a/src/Nazara/Utility/Formats/DDSLoader.hpp +++ b/src/Nazara/Utility/Formats/DDSLoader.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/FreeTypeLoader.cpp b/src/Nazara/Utility/Formats/FreeTypeLoader.cpp index 37ca659fe..601f16031 100644 --- a/src/Nazara/Utility/Formats/FreeTypeLoader.cpp +++ b/src/Nazara/Utility/Formats/FreeTypeLoader.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq - 2009 Cruden BV +// Copyright (C) 2020 Jérôme Leclercq - 2009 Cruden BV // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/FreeTypeLoader.hpp b/src/Nazara/Utility/Formats/FreeTypeLoader.hpp index f2abc1406..c26e63c4a 100644 --- a/src/Nazara/Utility/Formats/FreeTypeLoader.hpp +++ b/src/Nazara/Utility/Formats/FreeTypeLoader.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/MD2Constants.cpp b/src/Nazara/Utility/Formats/MD2Constants.cpp index f381689ec..fa6227bf6 100644 --- a/src/Nazara/Utility/Formats/MD2Constants.cpp +++ b/src/Nazara/Utility/Formats/MD2Constants.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/MD2Constants.hpp b/src/Nazara/Utility/Formats/MD2Constants.hpp index cb1a533a2..f8ab17eba 100644 --- a/src/Nazara/Utility/Formats/MD2Constants.hpp +++ b/src/Nazara/Utility/Formats/MD2Constants.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/MD2Loader.cpp b/src/Nazara/Utility/Formats/MD2Loader.cpp index d5fb90270..0f369cfe5 100644 --- a/src/Nazara/Utility/Formats/MD2Loader.cpp +++ b/src/Nazara/Utility/Formats/MD2Loader.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/MD2Loader.hpp b/src/Nazara/Utility/Formats/MD2Loader.hpp index 84a05d4e3..208a8bbf5 100644 --- a/src/Nazara/Utility/Formats/MD2Loader.hpp +++ b/src/Nazara/Utility/Formats/MD2Loader.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/MD5AnimLoader.cpp b/src/Nazara/Utility/Formats/MD5AnimLoader.cpp index e93299d1a..f069322ab 100644 --- a/src/Nazara/Utility/Formats/MD5AnimLoader.cpp +++ b/src/Nazara/Utility/Formats/MD5AnimLoader.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/MD5AnimLoader.hpp b/src/Nazara/Utility/Formats/MD5AnimLoader.hpp index 43b118369..e84729106 100644 --- a/src/Nazara/Utility/Formats/MD5AnimLoader.hpp +++ b/src/Nazara/Utility/Formats/MD5AnimLoader.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/MD5AnimParser.cpp b/src/Nazara/Utility/Formats/MD5AnimParser.cpp index 10acc9975..f85a279c5 100644 --- a/src/Nazara/Utility/Formats/MD5AnimParser.cpp +++ b/src/Nazara/Utility/Formats/MD5AnimParser.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/MD5MeshLoader.cpp b/src/Nazara/Utility/Formats/MD5MeshLoader.cpp index 69ffcad36..8894a7682 100644 --- a/src/Nazara/Utility/Formats/MD5MeshLoader.cpp +++ b/src/Nazara/Utility/Formats/MD5MeshLoader.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/MD5MeshLoader.hpp b/src/Nazara/Utility/Formats/MD5MeshLoader.hpp index 06450f740..0a0fb5af4 100644 --- a/src/Nazara/Utility/Formats/MD5MeshLoader.hpp +++ b/src/Nazara/Utility/Formats/MD5MeshLoader.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/MD5MeshParser.cpp b/src/Nazara/Utility/Formats/MD5MeshParser.cpp index fc5f30f6d..9556e1ced 100644 --- a/src/Nazara/Utility/Formats/MD5MeshParser.cpp +++ b/src/Nazara/Utility/Formats/MD5MeshParser.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/MTLParser.cpp b/src/Nazara/Utility/Formats/MTLParser.cpp index 743622f0c..d2f3ea4ae 100644 --- a/src/Nazara/Utility/Formats/MTLParser.cpp +++ b/src/Nazara/Utility/Formats/MTLParser.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/OBJLoader.cpp b/src/Nazara/Utility/Formats/OBJLoader.cpp index 819bbe256..125fdc3d8 100644 --- a/src/Nazara/Utility/Formats/OBJLoader.cpp +++ b/src/Nazara/Utility/Formats/OBJLoader.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/OBJLoader.hpp b/src/Nazara/Utility/Formats/OBJLoader.hpp index afbb59eed..2f3c2f8e5 100644 --- a/src/Nazara/Utility/Formats/OBJLoader.hpp +++ b/src/Nazara/Utility/Formats/OBJLoader.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/OBJParser.cpp b/src/Nazara/Utility/Formats/OBJParser.cpp index 03cf494fa..62c41615b 100644 --- a/src/Nazara/Utility/Formats/OBJParser.cpp +++ b/src/Nazara/Utility/Formats/OBJParser.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/OBJSaver.cpp b/src/Nazara/Utility/Formats/OBJSaver.cpp index d363bbe67..58cf15f70 100644 --- a/src/Nazara/Utility/Formats/OBJSaver.cpp +++ b/src/Nazara/Utility/Formats/OBJSaver.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/OBJSaver.hpp b/src/Nazara/Utility/Formats/OBJSaver.hpp index f6242e2d2..c67e04f48 100644 --- a/src/Nazara/Utility/Formats/OBJSaver.hpp +++ b/src/Nazara/Utility/Formats/OBJSaver.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/PCXLoader.cpp b/src/Nazara/Utility/Formats/PCXLoader.cpp index 75016cd2c..7e9ff82f5 100644 --- a/src/Nazara/Utility/Formats/PCXLoader.cpp +++ b/src/Nazara/Utility/Formats/PCXLoader.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/PCXLoader.hpp b/src/Nazara/Utility/Formats/PCXLoader.hpp index 1819e8468..2b83a8526 100644 --- a/src/Nazara/Utility/Formats/PCXLoader.hpp +++ b/src/Nazara/Utility/Formats/PCXLoader.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/STBLoader.cpp b/src/Nazara/Utility/Formats/STBLoader.cpp index 26836c057..9e2132906 100644 --- a/src/Nazara/Utility/Formats/STBLoader.cpp +++ b/src/Nazara/Utility/Formats/STBLoader.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/STBLoader.hpp b/src/Nazara/Utility/Formats/STBLoader.hpp index 6978aa8ef..e1e87b998 100644 --- a/src/Nazara/Utility/Formats/STBLoader.hpp +++ b/src/Nazara/Utility/Formats/STBLoader.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/STBSaver.cpp b/src/Nazara/Utility/Formats/STBSaver.cpp index effb8b921..77a71b64d 100644 --- a/src/Nazara/Utility/Formats/STBSaver.cpp +++ b/src/Nazara/Utility/Formats/STBSaver.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/STBSaver.hpp b/src/Nazara/Utility/Formats/STBSaver.hpp index c5126b61e..bb4ad5d1b 100644 --- a/src/Nazara/Utility/Formats/STBSaver.hpp +++ b/src/Nazara/Utility/Formats/STBSaver.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/GuillotineImageAtlas.cpp b/src/Nazara/Utility/GuillotineImageAtlas.cpp index 2593bc368..54dfb813b 100644 --- a/src/Nazara/Utility/GuillotineImageAtlas.cpp +++ b/src/Nazara/Utility/GuillotineImageAtlas.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Image.cpp b/src/Nazara/Utility/Image.cpp index 51443667a..189acb484 100644 --- a/src/Nazara/Utility/Image.cpp +++ b/src/Nazara/Utility/Image.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/IndexBuffer.cpp b/src/Nazara/Utility/IndexBuffer.cpp index c0af3c123..b0cadc27c 100644 --- a/src/Nazara/Utility/IndexBuffer.cpp +++ b/src/Nazara/Utility/IndexBuffer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/IndexMapper.cpp b/src/Nazara/Utility/IndexMapper.cpp index 78fdd36a0..7bc0ecb1e 100644 --- a/src/Nazara/Utility/IndexMapper.cpp +++ b/src/Nazara/Utility/IndexMapper.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Joint.cpp b/src/Nazara/Utility/Joint.cpp index 5d3a3796c..0f93bcc90 100644 --- a/src/Nazara/Utility/Joint.cpp +++ b/src/Nazara/Utility/Joint.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Mesh.cpp b/src/Nazara/Utility/Mesh.cpp index d2ed17353..9982982f3 100644 --- a/src/Nazara/Utility/Mesh.cpp +++ b/src/Nazara/Utility/Mesh.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Node.cpp b/src/Nazara/Utility/Node.cpp index e18e81244..87f076c69 100644 --- a/src/Nazara/Utility/Node.cpp +++ b/src/Nazara/Utility/Node.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/PixelFormat.cpp b/src/Nazara/Utility/PixelFormat.cpp index f27f6bd00..f19d19276 100644 --- a/src/Nazara/Utility/PixelFormat.cpp +++ b/src/Nazara/Utility/PixelFormat.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/RichTextDrawer.cpp b/src/Nazara/Utility/RichTextDrawer.cpp index 87e64c326..2c4ef43c2 100644 --- a/src/Nazara/Utility/RichTextDrawer.cpp +++ b/src/Nazara/Utility/RichTextDrawer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/SimpleTextDrawer.cpp b/src/Nazara/Utility/SimpleTextDrawer.cpp index ebaf28b3a..2d1eedb90 100644 --- a/src/Nazara/Utility/SimpleTextDrawer.cpp +++ b/src/Nazara/Utility/SimpleTextDrawer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/SkeletalMesh.cpp b/src/Nazara/Utility/SkeletalMesh.cpp index 7b8bc6a78..21f89da26 100644 --- a/src/Nazara/Utility/SkeletalMesh.cpp +++ b/src/Nazara/Utility/SkeletalMesh.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Skeleton.cpp b/src/Nazara/Utility/Skeleton.cpp index 21e0596b7..f8a7c7cdc 100644 --- a/src/Nazara/Utility/Skeleton.cpp +++ b/src/Nazara/Utility/Skeleton.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/SoftwareBuffer.cpp b/src/Nazara/Utility/SoftwareBuffer.cpp index 15147bd97..8867fa517 100644 --- a/src/Nazara/Utility/SoftwareBuffer.cpp +++ b/src/Nazara/Utility/SoftwareBuffer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/StaticMesh.cpp b/src/Nazara/Utility/StaticMesh.cpp index 38de3c033..3d17f3638 100644 --- a/src/Nazara/Utility/StaticMesh.cpp +++ b/src/Nazara/Utility/StaticMesh.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/SubMesh.cpp b/src/Nazara/Utility/SubMesh.cpp index b10c42992..0e020c11c 100644 --- a/src/Nazara/Utility/SubMesh.cpp +++ b/src/Nazara/Utility/SubMesh.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/TriangleIterator.cpp b/src/Nazara/Utility/TriangleIterator.cpp index ad6dfb2c6..66b085ac2 100644 --- a/src/Nazara/Utility/TriangleIterator.cpp +++ b/src/Nazara/Utility/TriangleIterator.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/UniformBuffer.cpp b/src/Nazara/Utility/UniformBuffer.cpp index 0ae065e3f..8e3d58668 100644 --- a/src/Nazara/Utility/UniformBuffer.cpp +++ b/src/Nazara/Utility/UniformBuffer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Utility.cpp b/src/Nazara/Utility/Utility.cpp index 1efd1c861..5feff8f33 100644 --- a/src/Nazara/Utility/Utility.cpp +++ b/src/Nazara/Utility/Utility.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/VertexBuffer.cpp b/src/Nazara/Utility/VertexBuffer.cpp index 8ff08f3e0..c4fff82fb 100644 --- a/src/Nazara/Utility/VertexBuffer.cpp +++ b/src/Nazara/Utility/VertexBuffer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/VertexDeclaration.cpp b/src/Nazara/Utility/VertexDeclaration.cpp index 61c7f1d86..6b4ecfd8c 100644 --- a/src/Nazara/Utility/VertexDeclaration.cpp +++ b/src/Nazara/Utility/VertexDeclaration.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/VertexMapper.cpp b/src/Nazara/Utility/VertexMapper.cpp index 43a96a89a..c722a14bb 100644 --- a/src/Nazara/Utility/VertexMapper.cpp +++ b/src/Nazara/Utility/VertexMapper.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/VulkanRenderer/Export.cpp b/src/Nazara/VulkanRenderer/Export.cpp index 6c9bbaf0f..3e221e156 100644 --- a/src/Nazara/VulkanRenderer/Export.cpp +++ b/src/Nazara/VulkanRenderer/Export.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/VulkanRenderer/Utils_VulkanRenderer.cpp b/src/Nazara/VulkanRenderer/Utils_VulkanRenderer.cpp index bec00a1ee..a21630c9b 100644 --- a/src/Nazara/VulkanRenderer/Utils_VulkanRenderer.cpp +++ b/src/Nazara/VulkanRenderer/Utils_VulkanRenderer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/VulkanRenderer/VkRenderTarget.cpp b/src/Nazara/VulkanRenderer/VkRenderTarget.cpp index a553a2c1e..69f356d0d 100644 --- a/src/Nazara/VulkanRenderer/VkRenderTarget.cpp +++ b/src/Nazara/VulkanRenderer/VkRenderTarget.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/VulkanRenderer/Vulkan.cpp b/src/Nazara/VulkanRenderer/Vulkan.cpp index c54a8a199..8582f5eac 100644 --- a/src/Nazara/VulkanRenderer/Vulkan.cpp +++ b/src/Nazara/VulkanRenderer/Vulkan.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/VulkanRenderer/VulkanBuffer.cpp b/src/Nazara/VulkanRenderer/VulkanBuffer.cpp index db834d035..14944d9fc 100644 --- a/src/Nazara/VulkanRenderer/VulkanBuffer.cpp +++ b/src/Nazara/VulkanRenderer/VulkanBuffer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/VulkanRenderer/VulkanDevice.cpp b/src/Nazara/VulkanRenderer/VulkanDevice.cpp index f2a802f4d..827433a1c 100644 --- a/src/Nazara/VulkanRenderer/VulkanDevice.cpp +++ b/src/Nazara/VulkanRenderer/VulkanDevice.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp b/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp index 1e2d8067d..47c133104 100644 --- a/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp +++ b/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/VulkanRenderer/VulkanRenderer.cpp b/src/Nazara/VulkanRenderer/VulkanRenderer.cpp index db44df280..3900a0248 100644 --- a/src/Nazara/VulkanRenderer/VulkanRenderer.cpp +++ b/src/Nazara/VulkanRenderer/VulkanRenderer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/VulkanRenderer/VulkanShaderStage.cpp b/src/Nazara/VulkanRenderer/VulkanShaderStage.cpp index b19bdca04..ea95dd0ac 100644 --- a/src/Nazara/VulkanRenderer/VulkanShaderStage.cpp +++ b/src/Nazara/VulkanRenderer/VulkanShaderStage.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/VulkanRenderer/VulkanSurface.cpp b/src/Nazara/VulkanRenderer/VulkanSurface.cpp index c7cd7f3d6..c14799f02 100644 --- a/src/Nazara/VulkanRenderer/VulkanSurface.cpp +++ b/src/Nazara/VulkanRenderer/VulkanSurface.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/VulkanRenderer/Wrapper/CommandPool.cpp b/src/Nazara/VulkanRenderer/Wrapper/CommandPool.cpp index ab9cf5ccc..5cc59106e 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/CommandPool.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/CommandPool.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/VulkanRenderer/Wrapper/DescriptorPool.cpp b/src/Nazara/VulkanRenderer/Wrapper/DescriptorPool.cpp index 5cea20758..488ec27a4 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/DescriptorPool.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/DescriptorPool.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp index 32a54641c..11ce99bf8 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/VulkanRenderer/Wrapper/Instance.cpp b/src/Nazara/VulkanRenderer/Wrapper/Instance.cpp index 4ec965725..f842e1279 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/Instance.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Instance.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/VulkanRenderer/Wrapper/Loader.cpp b/src/Nazara/VulkanRenderer/Wrapper/Loader.cpp index c110a737b..fd7aed2ac 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/Loader.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Loader.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/NazaraSDK/Application.cpp b/src/NazaraSDK/Application.cpp index d96fa23d8..845843c2c 100644 --- a/src/NazaraSDK/Application.cpp +++ b/src/NazaraSDK/Application.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/BaseComponent.cpp b/src/NazaraSDK/BaseComponent.cpp index 9ed65f3be..e7d0ccead 100644 --- a/src/NazaraSDK/BaseComponent.cpp +++ b/src/NazaraSDK/BaseComponent.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/BaseSystem.cpp b/src/NazaraSDK/BaseSystem.cpp index 708a6a9db..e35f114c8 100644 --- a/src/NazaraSDK/BaseSystem.cpp +++ b/src/NazaraSDK/BaseSystem.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/BaseWidget.cpp b/src/NazaraSDK/BaseWidget.cpp index 463ac0f45..d85ce7e1b 100644 --- a/src/NazaraSDK/BaseWidget.cpp +++ b/src/NazaraSDK/BaseWidget.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Canvas.cpp b/src/NazaraSDK/Canvas.cpp index 2eb09ecac..02e5afce0 100644 --- a/src/NazaraSDK/Canvas.cpp +++ b/src/NazaraSDK/Canvas.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Components/CameraComponent.cpp b/src/NazaraSDK/Components/CameraComponent.cpp index 3a7ddda15..9e63590e4 100644 --- a/src/NazaraSDK/Components/CameraComponent.cpp +++ b/src/NazaraSDK/Components/CameraComponent.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Components/CollisionComponent2D.cpp b/src/NazaraSDK/Components/CollisionComponent2D.cpp index 5d6d21eaa..c45a47118 100644 --- a/src/NazaraSDK/Components/CollisionComponent2D.cpp +++ b/src/NazaraSDK/Components/CollisionComponent2D.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Components/CollisionComponent3D.cpp b/src/NazaraSDK/Components/CollisionComponent3D.cpp index dc37cb163..4983a8af1 100644 --- a/src/NazaraSDK/Components/CollisionComponent3D.cpp +++ b/src/NazaraSDK/Components/CollisionComponent3D.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Components/ConstraintComponent2D.cpp b/src/NazaraSDK/Components/ConstraintComponent2D.cpp index 5c6e6e091..395a1e92e 100644 --- a/src/NazaraSDK/Components/ConstraintComponent2D.cpp +++ b/src/NazaraSDK/Components/ConstraintComponent2D.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Components/DebugComponent.cpp b/src/NazaraSDK/Components/DebugComponent.cpp index f0cccc684..22c742f6f 100644 --- a/src/NazaraSDK/Components/DebugComponent.cpp +++ b/src/NazaraSDK/Components/DebugComponent.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Components/GraphicsComponent.cpp b/src/NazaraSDK/Components/GraphicsComponent.cpp index 8fa933a73..b7251fd95 100644 --- a/src/NazaraSDK/Components/GraphicsComponent.cpp +++ b/src/NazaraSDK/Components/GraphicsComponent.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Components/LifetimeComponent.cpp b/src/NazaraSDK/Components/LifetimeComponent.cpp index 18099c3e7..f605d5cac 100644 --- a/src/NazaraSDK/Components/LifetimeComponent.cpp +++ b/src/NazaraSDK/Components/LifetimeComponent.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Components/LightComponent.cpp b/src/NazaraSDK/Components/LightComponent.cpp index 59ee5cfe7..a3cf50368 100644 --- a/src/NazaraSDK/Components/LightComponent.cpp +++ b/src/NazaraSDK/Components/LightComponent.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Components/ListenerComponent.cpp b/src/NazaraSDK/Components/ListenerComponent.cpp index 8948ba703..0e3df07bf 100644 --- a/src/NazaraSDK/Components/ListenerComponent.cpp +++ b/src/NazaraSDK/Components/ListenerComponent.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Components/NodeComponent.cpp b/src/NazaraSDK/Components/NodeComponent.cpp index d87a6f76e..cea0d2cde 100644 --- a/src/NazaraSDK/Components/NodeComponent.cpp +++ b/src/NazaraSDK/Components/NodeComponent.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Components/ParticleEmitterComponent.cpp b/src/NazaraSDK/Components/ParticleEmitterComponent.cpp index 8268d2b99..365f4d6f4 100644 --- a/src/NazaraSDK/Components/ParticleEmitterComponent.cpp +++ b/src/NazaraSDK/Components/ParticleEmitterComponent.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Components/ParticleGroupComponent.cpp b/src/NazaraSDK/Components/ParticleGroupComponent.cpp index 6aef06598..244f28b34 100644 --- a/src/NazaraSDK/Components/ParticleGroupComponent.cpp +++ b/src/NazaraSDK/Components/ParticleGroupComponent.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Components/PhysicsComponent2D.cpp b/src/NazaraSDK/Components/PhysicsComponent2D.cpp index 579fad093..5c2de1abb 100644 --- a/src/NazaraSDK/Components/PhysicsComponent2D.cpp +++ b/src/NazaraSDK/Components/PhysicsComponent2D.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Components/PhysicsComponent3D.cpp b/src/NazaraSDK/Components/PhysicsComponent3D.cpp index c02a6a7f7..c830960a2 100644 --- a/src/NazaraSDK/Components/PhysicsComponent3D.cpp +++ b/src/NazaraSDK/Components/PhysicsComponent3D.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Components/VelocityComponent.cpp b/src/NazaraSDK/Components/VelocityComponent.cpp index a41da1baf..937b7fae9 100644 --- a/src/NazaraSDK/Components/VelocityComponent.cpp +++ b/src/NazaraSDK/Components/VelocityComponent.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Console.cpp b/src/NazaraSDK/Console.cpp index 2450b8996..e4cc8db23 100644 --- a/src/NazaraSDK/Console.cpp +++ b/src/NazaraSDK/Console.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Entity.cpp b/src/NazaraSDK/Entity.cpp index 0cfb1125d..36c2c9128 100644 --- a/src/NazaraSDK/Entity.cpp +++ b/src/NazaraSDK/Entity.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/EntityList.cpp b/src/NazaraSDK/EntityList.cpp index fe906f84a..a6a9d1140 100644 --- a/src/NazaraSDK/EntityList.cpp +++ b/src/NazaraSDK/EntityList.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/LuaBinding_Renderer.cpp b/src/NazaraSDK/LuaBinding_Renderer.cpp index 1f1f9479f..9d52bb039 100644 --- a/src/NazaraSDK/LuaBinding_Renderer.cpp +++ b/src/NazaraSDK/LuaBinding_Renderer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq, Arnaud Cadot +// Copyright (C) 2020 Jérôme Leclercq, Arnaud Cadot // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/src/NazaraSDK/LuaBinding_SDK.cpp b/src/NazaraSDK/LuaBinding_SDK.cpp index 37c2d71e9..64d30036c 100644 --- a/src/NazaraSDK/LuaBinding_SDK.cpp +++ b/src/NazaraSDK/LuaBinding_SDK.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2016 Jérôme Leclercq, Arnaud Cadot +// Copyright (C) 2020 Jérôme Leclercq, Arnaud Cadot // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequesites.hpp diff --git a/src/NazaraSDK/Sdk.cpp b/src/NazaraSDK/Sdk.cpp index 0a7e08ee3..6fd036924 100644 --- a/src/NazaraSDK/Sdk.cpp +++ b/src/NazaraSDK/Sdk.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/State.cpp b/src/NazaraSDK/State.cpp index edc284034..112fa9f9b 100644 --- a/src/NazaraSDK/State.cpp +++ b/src/NazaraSDK/State.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Systems/DebugSystem.cpp b/src/NazaraSDK/Systems/DebugSystem.cpp index 377d8f936..da02053ac 100644 --- a/src/NazaraSDK/Systems/DebugSystem.cpp +++ b/src/NazaraSDK/Systems/DebugSystem.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Systems/LifetimeSystem.cpp b/src/NazaraSDK/Systems/LifetimeSystem.cpp index 76fd24721..894795477 100644 --- a/src/NazaraSDK/Systems/LifetimeSystem.cpp +++ b/src/NazaraSDK/Systems/LifetimeSystem.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Systems/ListenerSystem.cpp b/src/NazaraSDK/Systems/ListenerSystem.cpp index 0139b536b..314d2b4e1 100644 --- a/src/NazaraSDK/Systems/ListenerSystem.cpp +++ b/src/NazaraSDK/Systems/ListenerSystem.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Systems/ParticleSystem.cpp b/src/NazaraSDK/Systems/ParticleSystem.cpp index 0a9ecc3b6..ab54b572e 100644 --- a/src/NazaraSDK/Systems/ParticleSystem.cpp +++ b/src/NazaraSDK/Systems/ParticleSystem.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Systems/PhysicsSystem2D.cpp b/src/NazaraSDK/Systems/PhysicsSystem2D.cpp index 23559f4fe..86c9e69d3 100644 --- a/src/NazaraSDK/Systems/PhysicsSystem2D.cpp +++ b/src/NazaraSDK/Systems/PhysicsSystem2D.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Systems/PhysicsSystem3D.cpp b/src/NazaraSDK/Systems/PhysicsSystem3D.cpp index 39218e13f..c83103048 100644 --- a/src/NazaraSDK/Systems/PhysicsSystem3D.cpp +++ b/src/NazaraSDK/Systems/PhysicsSystem3D.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Systems/RenderSystem.cpp b/src/NazaraSDK/Systems/RenderSystem.cpp index b2693a041..5c5e8abd7 100644 --- a/src/NazaraSDK/Systems/RenderSystem.cpp +++ b/src/NazaraSDK/Systems/RenderSystem.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Systems/VelocitySystem.cpp b/src/NazaraSDK/Systems/VelocitySystem.cpp index 0f4dfe630..6baaba84c 100644 --- a/src/NazaraSDK/Systems/VelocitySystem.cpp +++ b/src/NazaraSDK/Systems/VelocitySystem.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Widgets/AbstractTextAreaWidget.cpp b/src/NazaraSDK/Widgets/AbstractTextAreaWidget.cpp index 773df6b68..b7a46775d 100644 --- a/src/NazaraSDK/Widgets/AbstractTextAreaWidget.cpp +++ b/src/NazaraSDK/Widgets/AbstractTextAreaWidget.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Widgets/BoxLayout.cpp b/src/NazaraSDK/Widgets/BoxLayout.cpp index 2e59bf559..dd9a94efa 100644 --- a/src/NazaraSDK/Widgets/BoxLayout.cpp +++ b/src/NazaraSDK/Widgets/BoxLayout.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Widgets/ButtonWidget.cpp b/src/NazaraSDK/Widgets/ButtonWidget.cpp index 84818e45b..84a72b17f 100644 --- a/src/NazaraSDK/Widgets/ButtonWidget.cpp +++ b/src/NazaraSDK/Widgets/ButtonWidget.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Widgets/LabelWidget.cpp b/src/NazaraSDK/Widgets/LabelWidget.cpp index 6c3c2825b..bbff99e0d 100644 --- a/src/NazaraSDK/Widgets/LabelWidget.cpp +++ b/src/NazaraSDK/Widgets/LabelWidget.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Widgets/RichTextAreaWidget.cpp b/src/NazaraSDK/Widgets/RichTextAreaWidget.cpp index dfb32bd98..a9eec53b9 100644 --- a/src/NazaraSDK/Widgets/RichTextAreaWidget.cpp +++ b/src/NazaraSDK/Widgets/RichTextAreaWidget.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Widgets/ScrollAreaWidget.cpp b/src/NazaraSDK/Widgets/ScrollAreaWidget.cpp index 09c33c2a5..323642ac7 100644 --- a/src/NazaraSDK/Widgets/ScrollAreaWidget.cpp +++ b/src/NazaraSDK/Widgets/ScrollAreaWidget.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/Widgets/TextAreaWidget.cpp b/src/NazaraSDK/Widgets/TextAreaWidget.cpp index b6110d781..3615ad5f6 100644 --- a/src/NazaraSDK/Widgets/TextAreaWidget.cpp +++ b/src/NazaraSDK/Widgets/TextAreaWidget.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp diff --git a/src/NazaraSDK/World.cpp b/src/NazaraSDK/World.cpp index f06f1338f..af2ca3370 100644 --- a/src/NazaraSDK/World.cpp +++ b/src/NazaraSDK/World.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp From 4941de61da9c83ffc13e8c5c389b3f57cc8d210b Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 5 Mar 2020 17:28:16 +0100 Subject: [PATCH 105/316] Spaaaace --- src/Nazara/VulkanRenderer/Vulkan.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Nazara/VulkanRenderer/Vulkan.cpp b/src/Nazara/VulkanRenderer/Vulkan.cpp index 8582f5eac..3ffbd9fc4 100644 --- a/src/Nazara/VulkanRenderer/Vulkan.cpp +++ b/src/Nazara/VulkanRenderer/Vulkan.cpp @@ -354,12 +354,12 @@ namespace Nz if (it == queueCreateInfos.end()) { VkDeviceQueueCreateInfo createInfo = { - VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, // VkStructureType sType; - nullptr, // const void* pNext; - 0, // VkDeviceQueueCreateFlags flags; - queueFamily.familyIndex, // uint32_t queueFamilyIndex; - 1, // uint32_t queueCount; - &queueFamily.priority // const float* pQueuePriorities; + VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + 0, // VkDeviceQueueCreateFlags flags; + queueFamily.familyIndex, // uint32_t queueFamilyIndex; + 1, // uint32_t queueCount; + &queueFamily.priority // const float* pQueuePriorities; }; queueCreateInfos.emplace_back(createInfo); From 2b3241f3543c3ddac4aedbb3b8de99aa48389732 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 5 Mar 2020 20:35:31 +0100 Subject: [PATCH 106/316] Add RenderPipelineLayout --- examples/VulkanTest/main.cpp | 142 ++++++------------ include/Nazara/Core/Algorithm.hpp | 2 +- include/Nazara/Core/Algorithm.inl | 2 +- include/Nazara/Renderer.hpp | 1 + include/Nazara/Renderer/Enums.hpp | 1 + include/Nazara/Renderer/RenderDevice.hpp | 2 + include/Nazara/Renderer/RenderPipeline.hpp | 11 +- .../Nazara/Renderer/RenderPipelineLayout.hpp | 40 +++++ .../Nazara/Renderer/RenderPipelineLayout.inl | 13 ++ include/Nazara/Renderer/RenderStates.hpp | 9 -- include/Nazara/VulkanRenderer.hpp | 1 + include/Nazara/VulkanRenderer/Utils.hpp | 2 + include/Nazara/VulkanRenderer/Utils.inl | 29 +++- .../Nazara/VulkanRenderer/VulkanDevice.hpp | 1 + .../VulkanRenderer/VulkanRenderPipeline.hpp | 8 +- .../VulkanRenderPipelineLayout.hpp | 41 +++++ .../VulkanRenderPipelineLayout.inl | 21 +++ .../VulkanRenderer/Wrapper/PipelineLayout.hpp | 4 + .../VulkanRenderer/Wrapper/PipelineLayout.inl | 20 +++ src/Nazara/Renderer/RenderPipelineLayout.cpp | 11 ++ src/Nazara/VulkanRenderer/VkRenderWindow.cpp | 6 +- src/Nazara/VulkanRenderer/VulkanDevice.cpp | 10 ++ .../VulkanRenderer/VulkanRenderPipeline.cpp | 26 +++- .../VulkanRenderPipelineLayout.cpp | 39 +++++ src/Nazara/VulkanRenderer/VulkanRenderer.cpp | 14 +- 25 files changed, 330 insertions(+), 126 deletions(-) create mode 100644 include/Nazara/Renderer/RenderPipelineLayout.hpp create mode 100644 include/Nazara/Renderer/RenderPipelineLayout.inl create mode 100644 include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.hpp create mode 100644 include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.inl create mode 100644 src/Nazara/Renderer/RenderPipelineLayout.cpp create mode 100644 src/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.cpp diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index a60dd2f07..bd121a9b1 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -66,24 +66,7 @@ int main() { std::cout << properties.layerName << ": \t" << properties.description << std::endl; } - /* - std::vector extensionProperties; - if (!Nz::Vk::Loader::EnumerateInstanceExtensionProperties(&extensionProperties)) - { - NazaraError("Failed to enumerate instance extension properties"); - return __LINE__; - } - for (const VkExtensionProperties& properties : extensionProperties) - std::cout << properties.extensionName << ": \t" << properties.specVersion << std::endl; - - std::vector devices; - if (!instance.EnumeratePhysicalDevices(&devices)) - { - NazaraError("Failed to enumerate physical devices"); - return __LINE__; - } - */ Nz::RenderWindow window; Nz::MeshParams meshParams; @@ -113,22 +96,6 @@ int main() return __LINE__; } - Nz::VkRenderWindow& vulkanWindow = *static_cast(window.GetImpl()); - - /*VkPhysicalDeviceFeatures features; - instance.GetPhysicalDeviceFeatures(physDevice, &features); - - VkPhysicalDeviceMemoryProperties memoryProperties; - instance.GetPhysicalDeviceMemoryProperties(physDevice, &memoryProperties); - - VkPhysicalDeviceProperties properties; - instance.GetPhysicalDeviceProperties(physDevice, &properties); - - std::vector queues; - instance.GetPhysicalDeviceQueueFamilyProperties(physDevice, &queues);*/ - - Nz::VulkanDevice& vulkanDevice = vulkanWindow.GetDevice(); - Nz::MeshRef drfreak = Nz::Mesh::LoadFromFile("resources/drfreak.md2", meshParams); if (!drfreak) @@ -145,27 +112,9 @@ int main() // Index buffer std::cout << "Index count: " << drfreakIB->GetIndexCount() << std::endl; - Nz::RenderBuffer* renderBufferIB = static_cast(drfreakIB->GetBuffer()->GetImpl()); - if (!renderBufferIB->Synchronize(&vulkanDevice)) - { - NazaraError("Failed to synchronize render buffer"); - return __LINE__; - } - - Nz::VulkanBuffer* indexBufferImpl = static_cast(renderBufferIB->GetHardwareBuffer(&vulkanDevice)); - // Vertex buffer std::cout << "Vertex count: " << drfreakVB->GetVertexCount() << std::endl; - Nz::RenderBuffer* renderBufferVB = static_cast(drfreakVB->GetBuffer()->GetImpl()); - if (!renderBufferVB->Synchronize(&vulkanDevice)) - { - NazaraError("Failed to synchronize render buffer"); - return __LINE__; - } - - Nz::VulkanBuffer* vertexBufferImpl = static_cast(renderBufferVB->GetHardwareBuffer(&vulkanDevice)); - struct { Nz::Matrix4f projectionMatrix; @@ -184,33 +133,26 @@ int main() Nz::UniformBuffer uniformBuffer(uniformSize, Nz::DataStorage_Hardware, Nz::BufferUsage_Dynamic); uniformBuffer.Fill(&ubo, 0, uniformSize); - Nz::RenderBuffer* renderBufferUB = static_cast(uniformBuffer.GetBuffer()->GetImpl()); - if (!renderBufferUB->Synchronize(&vulkanDevice)) - { - NazaraError("Failed to synchronize render buffer"); - return __LINE__; - } + Nz::RenderPipelineLayoutInfo pipelineLayoutInfo; + auto& bindingInfo = pipelineLayoutInfo.bindings.emplace_back(); + bindingInfo.index = 0; + bindingInfo.shaderStageFlags = Nz::ShaderStageType::Vertex; + bindingInfo.type = Nz::ShaderBindingType::UniformBuffer; - Nz::VulkanBuffer* uniformBufferImpl = static_cast(renderBufferUB->GetHardwareBuffer(&vulkanDevice)); + std::shared_ptr renderPipelineLayout = device->InstantiateRenderPipelineLayout(pipelineLayoutInfo); - VkDescriptorSetLayoutBinding layoutBinding = {}; - layoutBinding.binding = 0; - layoutBinding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; - layoutBinding.descriptorCount = 1; - layoutBinding.stageFlags = VK_SHADER_STAGE_VERTEX_BIT; - layoutBinding.pImmutableSamplers = nullptr; + Nz::VulkanRenderPipelineLayout* vkPipelineLayout = static_cast(renderPipelineLayout.get()); - Nz::Vk::DescriptorSetLayout descriptorLayout; - if (!descriptorLayout.Create(vulkanDevice.shared_from_this(), layoutBinding)) - { - NazaraError("Failed to create descriptor set layout"); - return __LINE__; - } + VkDescriptorSetLayout descriptorLayout = vkPipelineLayout->GetDescriptorSetLayout(); + VkPipelineLayout pipelineLayout = vkPipelineLayout->GetPipelineLayout(); VkDescriptorPoolSize poolSize; poolSize.descriptorCount = 1; poolSize.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; + Nz::VkRenderWindow& vulkanWindow = *static_cast(window.GetImpl()); + Nz::VulkanDevice& vulkanDevice = vulkanWindow.GetDevice(); + Nz::Vk::DescriptorPool descriptorPool; if (!descriptorPool.Create(vulkanDevice.shared_from_this(), 1, poolSize, VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT)) { @@ -220,9 +162,18 @@ int main() Nz::Vk::DescriptorSet descriptorSet = descriptorPool.AllocateDescriptorSet(descriptorLayout); + Nz::RenderBuffer* renderBufferUB = static_cast(uniformBuffer.GetBuffer()->GetImpl()); + if (!renderBufferUB->Synchronize(&vulkanDevice)) + { + NazaraError("Failed to synchronize render buffer"); + return __LINE__; + } + Nz::VulkanBuffer* uniformBufferImpl = static_cast(renderBufferUB->GetHardwareBuffer(&vulkanDevice)); descriptorSet.WriteUniformDescriptor(0, uniformBufferImpl->GetBufferHandle(), 0, uniformSize); Nz::RenderPipelineInfo pipelineInfo; + pipelineInfo.pipelineLayout = renderPipelineLayout; + pipelineInfo.depthBuffer = true; pipelineInfo.shaderStages.emplace_back(fragmentShader); pipelineInfo.shaderStages.emplace_back(vertexShader); @@ -231,35 +182,11 @@ int main() vertexBuffer.binding = 0; vertexBuffer.declaration = drfreakVB->GetVertexDeclaration(); - - //std::unique_ptr pipeline = device->InstantiateRenderPipeline(pipelineInfo); - - VkDescriptorSetLayout descriptorSetLayout = descriptorLayout; - - VkPipelineLayoutCreateInfo layout_create_info = { - VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, // VkStructureType sType - nullptr, // const void *pNext - 0, // VkPipelineLayoutCreateFlags flags - 1U, // uint32_t setLayoutCount - &descriptorSetLayout, // const VkDescriptorSetLayout *pSetLayouts - 0, // uint32_t pushConstantRangeCount - nullptr // const VkPushConstantRange *pPushConstantRanges - }; - - Nz::Vk::PipelineLayout pipelineLayout; - pipelineLayout.Create(vulkanDevice.shared_from_this(), layout_create_info); + std::unique_ptr pipeline = device->InstantiateRenderPipeline(pipelineInfo); Nz::VulkanRenderPipeline::CreateInfo pipelineCreateInfo = Nz::VulkanRenderPipeline::BuildCreateInfo(pipelineInfo); - pipelineCreateInfo.pipelineInfo.layout = pipelineLayout; pipelineCreateInfo.pipelineInfo.renderPass = vulkanWindow.GetRenderPass(); - Nz::Vk::Pipeline vkPipeline; - if (!vkPipeline.CreateGraphics(vulkanDevice.shared_from_this(), pipelineCreateInfo.pipelineInfo)) - { - NazaraError("Failed to create pipeline"); - return __LINE__; - } - Nz::Vk::CommandPool cmdPool; if (!cmdPool.Create(vulkanDevice.shared_from_this(), 0, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)) { @@ -276,6 +203,26 @@ int main() Nz::UInt32 imageCount = vulkanWindow.GetFramebufferCount(); std::vector renderCmds = cmdPool.AllocateCommandBuffers(imageCount, VK_COMMAND_BUFFER_LEVEL_PRIMARY); + Nz::RenderBuffer* renderBufferIB = static_cast(drfreakIB->GetBuffer()->GetImpl()); + Nz::RenderBuffer* renderBufferVB = static_cast(drfreakVB->GetBuffer()->GetImpl()); + + if (!renderBufferIB->Synchronize(&vulkanDevice)) + { + NazaraError("Failed to synchronize render buffer"); + return __LINE__; + } + + if (!renderBufferVB->Synchronize(&vulkanDevice)) + { + NazaraError("Failed to synchronize render buffer"); + return __LINE__; + } + + Nz::VulkanBuffer* indexBufferImpl = static_cast(renderBufferIB->GetHardwareBuffer(&vulkanDevice)); + Nz::VulkanBuffer* vertexBufferImpl = static_cast(renderBufferVB->GetHardwareBuffer(&vulkanDevice)); + + Nz::VulkanRenderPipeline* vkPipeline = static_cast(pipeline.get()); + for (Nz::UInt32 i = 0; i < imageCount; ++i) { Nz::Vk::CommandBuffer& renderCmd = renderCmds[i]; @@ -307,7 +254,7 @@ int main() renderCmd.BindIndexBuffer(indexBufferImpl->GetBufferHandle(), 0, VK_INDEX_TYPE_UINT16); renderCmd.BindVertexBuffer(0, vertexBufferImpl->GetBufferHandle(), 0); renderCmd.BindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, descriptorSet); - renderCmd.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, vkPipeline); + renderCmd.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, vkPipeline->Get(vulkanWindow.GetRenderPass())); renderCmd.SetScissor(Nz::Recti{0, 0, int(windowSize.x), int(windowSize.y)}); renderCmd.SetViewport({0.f, 0.f, float(windowSize.x), float(windowSize.y)}, 0.f, 1.f); renderCmd.DrawIndexed(drfreakIB->GetIndexCount()); @@ -352,6 +299,7 @@ int main() Nz::Clock updateClock; Nz::Clock secondClock; unsigned int fps = 0; + while (window.IsOpen()) { bool updateUniforms = false; @@ -410,8 +358,6 @@ int main() ubo.viewMatrix = Nz::Matrix4f::ViewMatrix(viewerPos, camAngles); uniformBuffer.Fill(&ubo, 0, uniformSize); - - Nz::RenderBuffer* renderBufferUB = static_cast(uniformBuffer.GetBuffer()->GetImpl()); if (!renderBufferUB->Synchronize(&vulkanDevice)) { NazaraError("Failed to synchronize render buffer"); diff --git a/include/Nazara/Core/Algorithm.hpp b/include/Nazara/Core/Algorithm.hpp index b1cef6a60..1a44940be 100644 --- a/include/Nazara/Core/Algorithm.hpp +++ b/include/Nazara/Core/Algorithm.hpp @@ -30,7 +30,7 @@ namespace Nz template std::size_t CountOf(const T& c); template void HashCombine(std::size_t& seed, const T& v); template T ReverseBits(T integer); - template auto UnderlyingCast(T value) -> std::underlying_type_t; + template constexpr auto UnderlyingCast(T value) -> std::underlying_type_t; template struct AlwaysFalse : std::false_type {}; diff --git a/include/Nazara/Core/Algorithm.inl b/include/Nazara/Core/Algorithm.inl index b6f10b37b..3a77759d3 100644 --- a/include/Nazara/Core/Algorithm.inl +++ b/include/Nazara/Core/Algorithm.inl @@ -196,7 +196,7 @@ namespace Nz } template - auto UnderlyingCast(T value) -> std::underlying_type_t + constexpr auto UnderlyingCast(T value) -> std::underlying_type_t { return static_cast>(value); } diff --git a/include/Nazara/Renderer.hpp b/include/Nazara/Renderer.hpp index 75c13cf0c..b043de0de 100644 --- a/include/Nazara/Renderer.hpp +++ b/include/Nazara/Renderer.hpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include diff --git a/include/Nazara/Renderer/Enums.hpp b/include/Nazara/Renderer/Enums.hpp index 5a6463ed3..4721662ff 100644 --- a/include/Nazara/Renderer/Enums.hpp +++ b/include/Nazara/Renderer/Enums.hpp @@ -60,6 +60,7 @@ namespace Nz Max = Vertex }; + template<> struct EnumAsFlags { static constexpr ShaderStageType max = ShaderStageType::Max; diff --git a/include/Nazara/Renderer/RenderDevice.hpp b/include/Nazara/Renderer/RenderDevice.hpp index b1716090f..739471ea4 100644 --- a/include/Nazara/Renderer/RenderDevice.hpp +++ b/include/Nazara/Renderer/RenderDevice.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -28,6 +29,7 @@ namespace Nz virtual std::unique_ptr InstantiateBuffer(Buffer* parent, BufferType type) = 0; virtual std::unique_ptr InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) = 0; + virtual std::shared_ptr InstantiateRenderPipelineLayout(RenderPipelineLayoutInfo pipelineLayoutInfo) = 0; virtual std::shared_ptr InstantiateShaderStage(ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) = 0; std::shared_ptr InstantiateShaderStage(ShaderStageType type, ShaderLanguage lang, const std::filesystem::path& sourcePath); }; diff --git a/include/Nazara/Renderer/RenderPipeline.hpp b/include/Nazara/Renderer/RenderPipeline.hpp index fd3350637..6e938eba7 100644 --- a/include/Nazara/Renderer/RenderPipeline.hpp +++ b/include/Nazara/Renderer/RenderPipeline.hpp @@ -8,6 +8,7 @@ #define NAZARA_RENDERPIPELINE_HPP #include +#include #include //#include @@ -15,7 +16,15 @@ namespace Nz { struct RenderPipelineInfo : RenderStates { - /*ShaderConstRef shader;*/ + struct VertexBufferData + { + std::size_t binding; + VertexDeclarationConstRef declaration; + }; + + std::shared_ptr pipelineLayout; + std::vector> shaderStages; + std::vector vertexBuffers; }; class NAZARA_RENDERER_API RenderPipeline diff --git a/include/Nazara/Renderer/RenderPipelineLayout.hpp b/include/Nazara/Renderer/RenderPipelineLayout.hpp new file mode 100644 index 000000000..13d6ab668 --- /dev/null +++ b/include/Nazara/Renderer/RenderPipelineLayout.hpp @@ -0,0 +1,40 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_RENDERPIPELINELAYOUT_HPP +#define NAZARA_RENDERPIPELINELAYOUT_HPP + +#include +#include +#include +#include + +namespace Nz +{ + struct RenderPipelineLayoutInfo + { + struct Binding + { + std::string name; //< FIXME: wtf is this? + ShaderBindingType type; + ShaderStageTypeFlags shaderStageFlags; + unsigned int index; + }; + + std::vector bindings; + }; + + class NAZARA_RENDERER_API RenderPipelineLayout + { + public: + RenderPipelineLayout() = default; + virtual ~RenderPipelineLayout(); + }; +} + +#include + +#endif // NAZARA_RENDERPIPELINELAYOUT_HPP diff --git a/include/Nazara/Renderer/RenderPipelineLayout.inl b/include/Nazara/Renderer/RenderPipelineLayout.inl new file mode 100644 index 000000000..71049528f --- /dev/null +++ b/include/Nazara/Renderer/RenderPipelineLayout.inl @@ -0,0 +1,13 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ +} + +#include diff --git a/include/Nazara/Renderer/RenderStates.hpp b/include/Nazara/Renderer/RenderStates.hpp index 6d40197c2..dca3d4c7c 100644 --- a/include/Nazara/Renderer/RenderStates.hpp +++ b/include/Nazara/Renderer/RenderStates.hpp @@ -37,15 +37,6 @@ namespace Nz UInt32 writeMask = 0xFFFFFFFF; } stencilBack, stencilFront; - struct VertexBufferData - { - std::size_t binding; - VertexDeclarationConstRef declaration; - }; - - std::vector> shaderStages; - std::vector vertexBuffers; - bool blending = false; bool colorWrite = true; bool depthBuffer = false; diff --git a/include/Nazara/VulkanRenderer.hpp b/include/Nazara/VulkanRenderer.hpp index 429629660..e93ca271d 100644 --- a/include/Nazara/VulkanRenderer.hpp +++ b/include/Nazara/VulkanRenderer.hpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include diff --git a/include/Nazara/VulkanRenderer/Utils.hpp b/include/Nazara/VulkanRenderer/Utils.hpp index fcf092394..71c0af4c4 100644 --- a/include/Nazara/VulkanRenderer/Utils.hpp +++ b/include/Nazara/VulkanRenderer/Utils.hpp @@ -20,7 +20,9 @@ namespace Nz inline VkPolygonMode ToVulkan(FaceFilling faceFilling); inline VkPrimitiveTopology ToVulkan(PrimitiveMode primitiveMode); inline VkCompareOp ToVulkan(RendererComparison comparison); + inline VkDescriptorType ToVulkan(ShaderBindingType bindingType); inline VkShaderStageFlagBits ToVulkan(ShaderStageType stageType); + inline VkShaderStageFlags ToVulkan(ShaderStageTypeFlags stageType); inline VkStencilOp ToVulkan(StencilOperation stencilOp); inline VkVertexInputRate ToVulkan(VertexInputRate inputRate); diff --git a/include/Nazara/VulkanRenderer/Utils.inl b/include/Nazara/VulkanRenderer/Utils.inl index 69c89d85d..4c9b5616d 100644 --- a/include/Nazara/VulkanRenderer/Utils.inl +++ b/include/Nazara/VulkanRenderer/Utils.inl @@ -95,6 +95,18 @@ namespace Nz return VK_COMPARE_OP_NEVER; } + VkDescriptorType ToVulkan(ShaderBindingType bindingType) + { + switch (bindingType) + { + case ShaderBindingType::Texture: return VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; + case ShaderBindingType::UniformBuffer: return VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; + } + + NazaraError("Unhandled ShaderBindingType 0x" + String::Number(UnderlyingCast(bindingType), 16)); + return VK_DESCRIPTOR_TYPE_SAMPLER; + } + VkShaderStageFlagBits ToVulkan(ShaderStageType stageType) { switch (stageType) @@ -103,10 +115,25 @@ namespace Nz case ShaderStageType::Vertex: return VK_SHADER_STAGE_VERTEX_BIT; } - NazaraError("Unhandled ShaderStageType 0x" + String::Number(static_cast(stageType), 16)); + NazaraError("Unhandled ShaderStageType 0x" + String::Number(UnderlyingCast(stageType), 16)); return {}; } + VkShaderStageFlags ToVulkan(ShaderStageTypeFlags stageType) + { + VkShaderStageFlags shaderStageBits = 0; + + if (stageType.Test(ShaderStageType::Fragment)) + shaderStageBits |= VK_SHADER_STAGE_FRAGMENT_BIT; + + if (stageType.Test(ShaderStageType::Vertex)) + shaderStageBits |= VK_SHADER_STAGE_VERTEX_BIT; + + static_assert(UnderlyingCast(ShaderStageType::Max) + 1 == 2); + + return shaderStageBits; + } + VkStencilOp ToVulkan(StencilOperation stencilOp) { switch (stencilOp) diff --git a/include/Nazara/VulkanRenderer/VulkanDevice.hpp b/include/Nazara/VulkanRenderer/VulkanDevice.hpp index 9d625d634..7fe07729a 100644 --- a/include/Nazara/VulkanRenderer/VulkanDevice.hpp +++ b/include/Nazara/VulkanRenderer/VulkanDevice.hpp @@ -25,6 +25,7 @@ namespace Nz std::unique_ptr InstantiateBuffer(Buffer* parent, BufferType type) override; std::unique_ptr InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) override; + std::shared_ptr InstantiateRenderPipelineLayout(RenderPipelineLayoutInfo pipelineLayoutInfo) override; std::shared_ptr InstantiateShaderStage(ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) override; VulkanDevice& operator=(const VulkanDevice&) = delete; diff --git a/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp b/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp index a622c51ff..baa644c60 100644 --- a/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp +++ b/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include namespace Nz @@ -23,6 +25,8 @@ namespace Nz VulkanRenderPipeline(Vk::DeviceHandle device, RenderPipelineInfo pipelineInfo); ~VulkanRenderPipeline() = default; + VkPipeline Get(const Vk::RenderPass& renderPass); + static std::vector BuildColorBlendAttachmentStateList(const RenderPipelineInfo& pipelineInfo); static VkPipelineColorBlendStateCreateInfo BuildColorBlendInfo(const RenderPipelineInfo& pipelineInfo, const std::vector& attachmentState); static VkPipelineDepthStencilStateCreateInfo BuildDepthStencilInfo(const RenderPipelineInfo& pipelineInfo); @@ -64,9 +68,9 @@ namespace Nz }; private: - - + std::unordered_map m_pipelines; Vk::DeviceHandle m_device; + CreateInfo m_pipelineCreateInfo; RenderPipelineInfo m_pipelineInfo; }; } diff --git a/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.hpp b/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.hpp new file mode 100644 index 000000000..beac99148 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.hpp @@ -0,0 +1,41 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VULKANRENDERPIPELINELAYOUT_HPP +#define NAZARA_VULKANRENDERER_VULKANRENDERPIPELINELAYOUT_HPP + +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_VULKANRENDERER_API VulkanRenderPipelineLayout : public RenderPipelineLayout + { + public: + VulkanRenderPipelineLayout() = default; + ~VulkanRenderPipelineLayout() = default; + + bool Create(Vk::DeviceHandle device, RenderPipelineLayoutInfo layoutInfo); + + inline const Vk::DescriptorSetLayout& GetDescriptorSetLayout() const; + inline const Vk::PipelineLayout& GetPipelineLayout() const; + + private: + Vk::DeviceHandle m_device; + Vk::DescriptorSetLayout m_descriptorSetLayout; + Vk::PipelineLayout m_pipelineLayout; + RenderPipelineLayoutInfo m_layoutInfo; + }; +} + +#include + +#endif // NAZARA_VULKANRENDERER_VULKANRENDERPIPELINE_HPP diff --git a/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.inl b/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.inl new file mode 100644 index 000000000..36cad5f4a --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.inl @@ -0,0 +1,21 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline const Vk::DescriptorSetLayout& VulkanRenderPipelineLayout::GetDescriptorSetLayout() const + { + return m_descriptorSetLayout; + } + + inline const Vk::PipelineLayout& VulkanRenderPipelineLayout::GetPipelineLayout() const + { + return m_pipelineLayout; + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp b/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp index 7e2af843e..1a27d40a4 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp @@ -24,6 +24,10 @@ namespace Nz PipelineLayout(PipelineLayout&&) = default; ~PipelineLayout() = default; + using DeviceObject::Create; + bool Create(DeviceHandle device, VkDescriptorSetLayout layout, VkPipelineLayoutCreateFlags flags = 0); + bool Create(DeviceHandle device, UInt32 layoutCount, const VkDescriptorSetLayout* layouts, VkPipelineLayoutCreateFlags flags = 0); + PipelineLayout& operator=(const PipelineLayout&) = delete; PipelineLayout& operator=(PipelineLayout&&) = delete; diff --git a/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.inl b/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.inl index 333062780..3f0f52df1 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.inl @@ -9,6 +9,26 @@ namespace Nz { namespace Vk { + inline bool PipelineLayout::Create(DeviceHandle device, VkDescriptorSetLayout layout, VkPipelineLayoutCreateFlags flags) + { + return Create(std::move(device), 1U, &layout, flags); + } + + inline bool PipelineLayout::Create(DeviceHandle device, UInt32 layoutCount, const VkDescriptorSetLayout* layouts, VkPipelineLayoutCreateFlags flags) + { + VkPipelineLayoutCreateInfo createInfo = { + VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, + nullptr, + flags, + layoutCount, + layouts, + 0U, + nullptr + }; + + return Create(std::move(device), createInfo); + } + inline VkResult PipelineLayout::CreateHelper(const DeviceHandle& device, const VkPipelineLayoutCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkPipelineLayout* handle) { return device->vkCreatePipelineLayout(*device, createInfo, allocator, handle); diff --git a/src/Nazara/Renderer/RenderPipelineLayout.cpp b/src/Nazara/Renderer/RenderPipelineLayout.cpp new file mode 100644 index 000000000..ec26fad08 --- /dev/null +++ b/src/Nazara/Renderer/RenderPipelineLayout.cpp @@ -0,0 +1,11 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + RenderPipelineLayout::~RenderPipelineLayout() = default; +} diff --git a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp index 6edaa6649..08b9b651e 100644 --- a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp +++ b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp @@ -137,7 +137,7 @@ namespace Nz return false; } - if (!SetupRenderPass(size)) + if (!SetupRenderPass()) { NazaraError("Failed to create render pass"); return false; @@ -245,8 +245,8 @@ namespace Nz return true; } - bool VkRenderWindow::SetupRenderPass(const Vector2ui& size) - { + bool VkRenderWindow::SetupRenderPass() +{ std::array attachments = { { { diff --git a/src/Nazara/VulkanRenderer/VulkanDevice.cpp b/src/Nazara/VulkanRenderer/VulkanDevice.cpp index 827433a1c..f1c532846 100644 --- a/src/Nazara/VulkanRenderer/VulkanDevice.cpp +++ b/src/Nazara/VulkanRenderer/VulkanDevice.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -21,6 +22,15 @@ namespace Nz return std::make_unique(shared_from_this(), std::move(pipelineInfo)); } + std::shared_ptr VulkanDevice::InstantiateRenderPipelineLayout(RenderPipelineLayoutInfo pipelineLayoutInfo) + { + auto pipelineLayout = std::make_shared(); + if (!pipelineLayout->Create(shared_from_this(), std::move(pipelineLayoutInfo))) + return {}; + + return pipelineLayout; + } + std::shared_ptr VulkanDevice::InstantiateShaderStage(ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) { auto stage = std::make_shared(); diff --git a/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp b/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp index 47c133104..93a05ebcc 100644 --- a/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp +++ b/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp @@ -4,10 +4,10 @@ #include #include -#include #include +#include +#include #include -#include #include namespace Nz @@ -16,6 +16,24 @@ namespace Nz m_device(std::move(device)), m_pipelineInfo(std::move(pipelineInfo)) { + m_pipelineCreateInfo = BuildCreateInfo(m_pipelineInfo); + } + + VkPipeline VulkanRenderPipeline::Get(const Vk::RenderPass& renderPass) + { + if (auto it = m_pipelines.find(renderPass); it != m_pipelines.end()) + return it->second; + + // Copy create info to make Get re-entrant + VkGraphicsPipelineCreateInfo pipelineCreateInfo = m_pipelineCreateInfo.pipelineInfo; + pipelineCreateInfo.renderPass = renderPass; + + Vk::Pipeline newPipeline; + if (!newPipeline.CreateGraphics(m_device, pipelineCreateInfo)) + return VK_NULL_HANDLE; + + auto it = m_pipelines.emplace(renderPass, std::move(newPipeline)).first; + return it->second; } std::vector VulkanRenderPipeline::BuildColorBlendAttachmentStateList(const RenderPipelineInfo& pipelineInfo) @@ -235,7 +253,6 @@ namespace Nz createInfo.pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; createInfo.pipelineInfo.stageCount = std::uint32_t(createInfo.shaderStages.size()); createInfo.pipelineInfo.pStages = createInfo.shaderStages.data(); - createInfo.pipelineInfo.pColorBlendState = &createInfo.stateData->colorBlendState; createInfo.pipelineInfo.pDepthStencilState = &createInfo.stateData->depthStencilState; createInfo.pipelineInfo.pDynamicState = &createInfo.stateData->dynamicState; @@ -245,6 +262,9 @@ namespace Nz createInfo.pipelineInfo.pVertexInputState = &createInfo.stateData->vertexInputState; createInfo.pipelineInfo.pViewportState = &createInfo.stateData->viewportState; + VulkanRenderPipelineLayout& pipelineLayout = *static_cast(pipelineInfo.pipelineLayout.get()); + createInfo.pipelineInfo.layout = pipelineLayout.GetPipelineLayout(); + return createInfo; } } diff --git a/src/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.cpp b/src/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.cpp new file mode 100644 index 000000000..d509ff043 --- /dev/null +++ b/src/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.cpp @@ -0,0 +1,39 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + bool VulkanRenderPipelineLayout::Create(Vk::DeviceHandle device, RenderPipelineLayoutInfo layoutInfo) + { + m_device = std::move(device); + m_layoutInfo = std::move(layoutInfo); + + StackVector layoutBindings = NazaraStackVector(VkDescriptorSetLayoutBinding, m_layoutInfo.bindings.size()); + + for (const auto& bindingInfo : m_layoutInfo.bindings) + { + VkDescriptorSetLayoutBinding& layoutBinding = layoutBindings.emplace_back(); + layoutBinding.binding = bindingInfo.index; + layoutBinding.descriptorCount = 1U; + layoutBinding.descriptorType = ToVulkan(bindingInfo.type); + layoutBinding.stageFlags = ToVulkan(bindingInfo.shaderStageFlags); + } + + if (!m_descriptorSetLayout.Create(m_device, layoutBindings.size(), layoutBindings.data())) + return false; + + if (!m_pipelineLayout.Create(m_device, m_descriptorSetLayout)) + return false; + + return true; + } +} diff --git a/src/Nazara/VulkanRenderer/VulkanRenderer.cpp b/src/Nazara/VulkanRenderer/VulkanRenderer.cpp index 3900a0248..7e543c256 100644 --- a/src/Nazara/VulkanRenderer/VulkanRenderer.cpp +++ b/src/Nazara/VulkanRenderer/VulkanRenderer.cpp @@ -37,7 +37,7 @@ namespace Nz bool VulkanRenderer::IsBetterThan(const RendererImpl* other) const { - if (other->QueryAPI() == RenderAPI_Vulkan && QueryAPIVersion() < other->QueryAPIVersion()) + if (other->QueryAPI() == RenderAPI::Vulkan && QueryAPIVersion() < other->QueryAPIVersion()) return false; return true; //< Vulkan FTW @@ -50,7 +50,7 @@ namespace Nz RenderAPI VulkanRenderer::QueryAPI() const { - return RenderAPI_Vulkan; + return RenderAPI::Vulkan; } String VulkanRenderer::QueryAPIString() const @@ -79,25 +79,25 @@ namespace Nz switch (physDevice.properties.deviceType) { case VK_PHYSICAL_DEVICE_TYPE_CPU: - device.type = RenderDeviceType_Software; + device.type = RenderDeviceType::Software; break; case VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU: - device.type = RenderDeviceType_Dedicated; + device.type = RenderDeviceType::Dedicated; break; case VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU: - device.type = RenderDeviceType_Integrated; + device.type = RenderDeviceType::Integrated; break; case VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU: - device.type = RenderDeviceType_Virtual; + device.type = RenderDeviceType::Virtual; break; default: NazaraWarning("Device " + device.name + " has handled device type (0x" + String::Number(physDevice.properties.deviceType, 16) + ')'); case VK_PHYSICAL_DEVICE_TYPE_OTHER: - device.type = RenderDeviceType_Unknown; + device.type = RenderDeviceType::Unknown; break; } From c1a01c418357c4f25dbd29ee03e15df30523b8ea Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 5 Mar 2020 22:35:00 +0100 Subject: [PATCH 107/316] Remove useless inline --- .../VulkanRenderer/Wrapper/DeviceObject.hpp | 18 +++++++++--------- .../VulkanRenderer/Wrapper/DeviceObject.inl | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp index 0e6090d73..4062cb5c8 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp @@ -19,23 +19,23 @@ namespace Nz class DeviceObject { public: - inline DeviceObject(); + DeviceObject(); DeviceObject(const DeviceObject&) = delete; - inline DeviceObject(DeviceObject&& object); - inline ~DeviceObject(); + DeviceObject(DeviceObject&& object); + ~DeviceObject(); - inline bool Create(DeviceHandle device, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); - inline void Destroy(); + bool Create(DeviceHandle device, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); + void Destroy(); - inline bool IsValid() const; + bool IsValid() const; - inline const DeviceHandle& GetDevice() const; - inline VkResult GetLastErrorCode() const; + const DeviceHandle& GetDevice() const; + VkResult GetLastErrorCode() const; DeviceObject& operator=(const DeviceObject&) = delete; DeviceObject& operator=(DeviceObject&&) = delete; - inline operator VkType() const; + operator VkType() const; protected: DeviceHandle m_device; diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl index 961a5b4ad..def0ebc0a 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl @@ -14,13 +14,13 @@ namespace Nz namespace Vk { template - inline DeviceObject::DeviceObject() : + DeviceObject::DeviceObject() : m_handle(VK_NULL_HANDLE) { } template - inline DeviceObject::DeviceObject(DeviceObject&& object) : + DeviceObject::DeviceObject(DeviceObject&& object) : m_device(std::move(object.m_device)), m_allocator(object.m_allocator), m_handle(object.m_handle), @@ -30,13 +30,13 @@ namespace Nz } template - inline DeviceObject::~DeviceObject() + DeviceObject::~DeviceObject() { Destroy(); } template - inline bool DeviceObject::Create(DeviceHandle device, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator) + bool DeviceObject::Create(DeviceHandle device, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator) { m_device = std::move(device); m_lastErrorCode = C::CreateHelper(m_device, &createInfo, allocator, &m_handle); @@ -56,7 +56,7 @@ namespace Nz } template - inline void DeviceObject::Destroy() + void DeviceObject::Destroy() { if (IsValid()) { @@ -66,25 +66,25 @@ namespace Nz } template - inline bool DeviceObject::IsValid() const + bool DeviceObject::IsValid() const { return m_handle != VK_NULL_HANDLE; } template - inline const DeviceHandle& DeviceObject::GetDevice() const + const DeviceHandle& DeviceObject::GetDevice() const { return m_device; } template - inline VkResult DeviceObject::GetLastErrorCode() const + VkResult DeviceObject::GetLastErrorCode() const { return m_lastErrorCode; } template - inline DeviceObject::operator VkType() const + DeviceObject::operator VkType() const { return m_handle; } From f830dbf6d4832ee51688183bd681e2754f3850f6 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 5 Mar 2020 22:35:12 +0100 Subject: [PATCH 108/316] Fix compilation --- include/Nazara/VulkanRenderer/VkRenderWindow.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp index e972b2c86..e19abc909 100644 --- a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp +++ b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp @@ -57,7 +57,7 @@ namespace Nz private: bool SetupDepthBuffer(const Vector2ui& size); - bool SetupRenderPass(const Vector2ui& size); + bool SetupRenderPass(); bool SetupSwapchain(Vk::Surface& surface, const Vector2ui& size); Clock m_clock; From 0e27c2315fc478d206aedfd447567d43bcce4d7f Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 8 Mar 2020 18:09:45 +0100 Subject: [PATCH 109/316] Move Vulkan functions list to external files --- .../Nazara/VulkanRenderer/Wrapper/Device.hpp | 144 +----------------- .../Wrapper/DeviceFunctions.hpp | 140 +++++++++++++++++ .../VulkanRenderer/Wrapper/Instance.hpp | 76 +-------- .../Wrapper/InstanceFunctions.hpp | 80 ++++++++++ src/Nazara/VulkanRenderer/Wrapper/Device.cpp | 138 +---------------- .../VulkanRenderer/Wrapper/Instance.cpp | 101 +----------- 6 files changed, 249 insertions(+), 430 deletions(-) create mode 100644 include/Nazara/VulkanRenderer/Wrapper/DeviceFunctions.hpp create mode 100644 include/Nazara/VulkanRenderer/Wrapper/InstanceFunctions.hpp diff --git a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp index a5ed0759c..71c9b28fc 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp @@ -59,143 +59,15 @@ namespace Nz inline operator VkDevice(); // Vulkan functions - #define NAZARA_VULKANRENDERER_DEVICE_FUNCTION(func) PFN_##func func +#define NAZARA_VULKANRENDERER_DEVICE_EXT_BEGIN(ext) +#define NAZARA_VULKANRENDERER_DEVICE_EXT_END() +#define NAZARA_VULKANRENDERER_DEVICE_FUNCTION(func) PFN_##func func; - // Vulkan core - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkAllocateCommandBuffers); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkAllocateDescriptorSets); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkAllocateMemory); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkBeginCommandBuffer); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkBindBufferMemory); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkBindImageMemory); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdBeginQuery); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdBeginRenderPass); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdBindDescriptorSets); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdBindIndexBuffer); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdBindPipeline); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdBindVertexBuffers); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdBlitImage); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdClearAttachments); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdClearColorImage); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdClearDepthStencilImage); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdCopyBuffer); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdCopyBufferToImage); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdCopyImage); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdCopyImageToBuffer); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdCopyQueryPoolResults); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdDispatch); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdDispatchIndirect); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdDraw); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdDrawIndexed); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdDrawIndexedIndirect); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdDrawIndirect); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdEndQuery); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdEndRenderPass); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdExecuteCommands); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdFillBuffer); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdNextSubpass); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdPipelineBarrier); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdPushConstants); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdResetEvent); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdResetQueryPool); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdResolveImage); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdSetBlendConstants); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdSetDepthBias); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdSetDepthBounds); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdSetEvent); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdSetLineWidth); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdSetScissor); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdSetStencilCompareMask); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdSetStencilReference); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdSetStencilWriteMask); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdSetViewport); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdUpdateBuffer); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdWaitEvents); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdWriteTimestamp); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateBuffer); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateBufferView); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateCommandPool); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateComputePipelines); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateDescriptorPool); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateDescriptorSetLayout); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateEvent); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateFence); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateFramebuffer); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateGraphicsPipelines); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateImage); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateImageView); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreatePipelineCache); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreatePipelineLayout); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateRenderPass); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateSampler); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateSemaphore); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateShaderModule); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyBuffer); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyBufferView); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyCommandPool); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyDescriptorPool); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyDescriptorSetLayout); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyDevice); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyEvent); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyFence); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyFramebuffer); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyImage); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyImageView); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyPipeline); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyPipelineCache); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyPipelineLayout); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyRenderPass); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroySampler); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroySemaphore); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyShaderModule); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDeviceWaitIdle); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkEndCommandBuffer); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkFreeCommandBuffers); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkFreeDescriptorSets); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkFreeMemory); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkFlushMappedMemoryRanges); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetBufferMemoryRequirements); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetDeviceMemoryCommitment); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetDeviceQueue); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetEventStatus); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetFenceStatus); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetImageMemoryRequirements); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetImageSparseMemoryRequirements); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetImageSubresourceLayout); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetRenderAreaGranularity); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkInvalidateMappedMemoryRanges); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkMapMemory); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkMergePipelineCaches); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkQueueSubmit); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkQueueWaitIdle); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkResetCommandBuffer); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkResetCommandPool); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkResetDescriptorPool); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkResetFences); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkResetEvent); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkSetEvent); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkUnmapMemory); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkUpdateDescriptorSets); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkWaitForFences); +#include - // VK_KHR_display_swapchain - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateSharedSwapchainsKHR); - - // VK_KHR_surface - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroySurfaceKHR); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetPhysicalDeviceSurfaceCapabilitiesKHR); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetPhysicalDeviceSurfaceFormatsKHR); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetPhysicalDeviceSurfacePresentModesKHR); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetPhysicalDeviceSurfaceSupportKHR); - - // VK_KHR_swapchain - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkAcquireNextImageKHR); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateSwapchainKHR); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroySwapchainKHR); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetSwapchainImagesKHR); - NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkQueuePresentKHR); - - #undef NAZARA_VULKANRENDERER_DEVICE_FUNCTION +#undef NAZARA_VULKANRENDERER_DEVICE_EXT_BEGIN +#undef NAZARA_VULKANRENDERER_DEVICE_EXT_END +#undef NAZARA_VULKANRENDERER_DEVICE_FUNCTION struct QueueInfo { @@ -217,9 +89,9 @@ namespace Nz inline PFN_vkVoidFunction GetProcAddr(const char* name); Instance& m_instance; + const Vk::PhysicalDevice* m_physicalDevice; VkAllocationCallbacks m_allocator; VkDevice m_device; - VkPhysicalDevice m_physicalDevice; VkResult m_lastErrorCode; std::unordered_set m_loadedExtensions; std::unordered_set m_loadedLayers; diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceFunctions.hpp b/include/Nazara/VulkanRenderer/Wrapper/DeviceFunctions.hpp new file mode 100644 index 000000000..2b3b03564 --- /dev/null +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceFunctions.hpp @@ -0,0 +1,140 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +// Vulkan core +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkAllocateCommandBuffers) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkAllocateDescriptorSets) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkAllocateMemory) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkBeginCommandBuffer) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkBindBufferMemory) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkBindImageMemory) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdBeginQuery) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdBeginRenderPass) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdBindDescriptorSets) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdBindIndexBuffer) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdBindPipeline) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdBindVertexBuffers) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdBlitImage) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdClearAttachments) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdClearColorImage) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdClearDepthStencilImage) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdCopyBuffer) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdCopyBufferToImage) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdCopyImage) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdCopyImageToBuffer) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdCopyQueryPoolResults) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdDispatch) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdDispatchIndirect) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdDraw) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdDrawIndexed) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdDrawIndexedIndirect) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdDrawIndirect) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdEndQuery) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdEndRenderPass) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdExecuteCommands) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdFillBuffer) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdNextSubpass) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdPipelineBarrier) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdPushConstants) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdResetEvent) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdResetQueryPool) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdResolveImage) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdSetBlendConstants) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdSetDepthBias) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdSetDepthBounds) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdSetEvent) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdSetLineWidth) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdSetScissor) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdSetStencilCompareMask) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdSetStencilReference) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdSetStencilWriteMask) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdSetViewport) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdUpdateBuffer) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdWaitEvents) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdWriteTimestamp) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateBuffer) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateBufferView) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateCommandPool) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateComputePipelines) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateDescriptorPool) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateDescriptorSetLayout) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateEvent) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateFence) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateFramebuffer) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateGraphicsPipelines) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateImage) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateImageView) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreatePipelineCache) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreatePipelineLayout) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateRenderPass) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateSampler) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateSemaphore) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateShaderModule) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyBuffer) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyBufferView) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyCommandPool) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyDescriptorPool) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyDescriptorSetLayout) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyDevice) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyEvent) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyFence) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyFramebuffer) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyImage) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyImageView) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyPipeline) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyPipelineCache) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyPipelineLayout) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyRenderPass) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroySampler) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroySemaphore) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroyShaderModule) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDeviceWaitIdle) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkEndCommandBuffer) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkFreeCommandBuffers) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkFreeDescriptorSets) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkFreeMemory) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkFlushMappedMemoryRanges) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetBufferMemoryRequirements) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetDeviceMemoryCommitment) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetDeviceQueue) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetEventStatus) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetFenceStatus) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetImageMemoryRequirements) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetImageSparseMemoryRequirements) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetImageSubresourceLayout) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetRenderAreaGranularity) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkInvalidateMappedMemoryRanges) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkMapMemory) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkMergePipelineCaches) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkQueueSubmit) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkQueueWaitIdle) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkResetCommandBuffer) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkResetCommandPool) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkResetDescriptorPool) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkResetFences) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkResetEvent) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkSetEvent) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkUnmapMemory) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkUpdateDescriptorSets) +NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkWaitForFences) + +NAZARA_VULKANRENDERER_DEVICE_EXT_BEGIN(VK_KHR_display_swapchain) + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateSharedSwapchainsKHR) +NAZARA_VULKANRENDERER_DEVICE_EXT_END() + +NAZARA_VULKANRENDERER_DEVICE_EXT_BEGIN(VK_KHR_surface) + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroySurfaceKHR) + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetPhysicalDeviceSurfaceCapabilitiesKHR) + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetPhysicalDeviceSurfaceFormatsKHR) + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetPhysicalDeviceSurfacePresentModesKHR) + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetPhysicalDeviceSurfaceSupportKHR) +NAZARA_VULKANRENDERER_DEVICE_EXT_END() + +NAZARA_VULKANRENDERER_DEVICE_EXT_BEGIN(VK_KHR_swapchain) + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkAcquireNextImageKHR) + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateSwapchainKHR) + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkDestroySwapchainKHR) + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetSwapchainImagesKHR) + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkQueuePresentKHR) +NAZARA_VULKANRENDERER_DEVICE_EXT_END() diff --git a/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp b/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp index f00056ef1..3a97e5b0b 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp @@ -53,77 +53,15 @@ namespace Nz inline operator VkInstance(); // Vulkan functions - #define NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(func) PFN_##func func +#define NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(ext) +#define NAZARA_VULKANRENDERER_INSTANCE_EXT_END() +#define NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(func) PFN_##func func; - // Vulkan core - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateDevice); - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkDestroyInstance); - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkEnumeratePhysicalDevices); - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetDeviceProcAddr); - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceFeatures); - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceFormatProperties); - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceImageFormatProperties); - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceMemoryProperties); - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceProperties); - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceQueueFamilyProperties); +#include - // VK_KHR_display - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateDisplayModeKHR); - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateDisplayPlaneSurfaceKHR); - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetDisplayModePropertiesKHR); - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetDisplayPlaneCapabilitiesKHR); - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetDisplayPlaneSupportedDisplaysKHR); - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceDisplayPlanePropertiesKHR); - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceDisplayPropertiesKHR); - - // VK_KHR_surface - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkDestroySurfaceKHR); - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfaceCapabilitiesKHR); - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfaceFormatsKHR); - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfacePresentModesKHR); - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfaceSupportKHR); - - // VK_EXT_debug_report - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateDebugReportCallbackEXT); - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkDestroyDebugReportCallbackEXT); - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkDebugReportMessageEXT); - - #ifdef VK_USE_PLATFORM_ANDROID_KHR - // VK_KHR_android_surface - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateAndroidSurfaceKHR); - #endif - - #ifdef VK_USE_PLATFORM_MIR_KHR - // VK_KHR_mir_surface - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateMirSurfaceKHR); - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceMirPresentationSupportKHR); - #endif - - #ifdef VK_USE_PLATFORM_XCB_KHR - // VK_KHR_xcb_surface - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateXcbSurfaceKHR); - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceXcbPresentationSupportKHR); - #endif - - #ifdef VK_USE_PLATFORM_XLIB_KHR - // VK_KHR_xlib_surface - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateXlibSurfaceKHR); - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceXlibPresentationSupportKHR); - #endif - - #ifdef VK_USE_PLATFORM_WAYLAND_KHR - // VK_KHR_wayland_surface - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateWaylandSurfaceKHR); - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceWaylandPresentationSupportKHR); - #endif - - #ifdef VK_USE_PLATFORM_WIN32_KHR - // VK_KHR_win32_surface - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateWin32SurfaceKHR); - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceWin32PresentationSupportKHR); - #endif - - #undef NAZARA_VULKANRENDERER_INSTANCE_FUNCTION +#undef NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN +#undef NAZARA_VULKANRENDERER_INSTANCE_EXT_END +#undef NAZARA_VULKANRENDERER_INSTANCE_FUNCTION private: inline PFN_vkVoidFunction GetProcAddr(const char* name); diff --git a/include/Nazara/VulkanRenderer/Wrapper/InstanceFunctions.hpp b/include/Nazara/VulkanRenderer/Wrapper/InstanceFunctions.hpp new file mode 100644 index 000000000..4f37b2767 --- /dev/null +++ b/include/Nazara/VulkanRenderer/Wrapper/InstanceFunctions.hpp @@ -0,0 +1,80 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +// Vulkan core +NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateDevice) +NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkDestroyInstance) +NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkEnumeratePhysicalDevices) +NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetDeviceProcAddr) +NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceFeatures) +NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceFormatProperties) +NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceImageFormatProperties) +NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceMemoryProperties) +NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceProperties) +NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceQueueFamilyProperties) + +NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(VK_KHR_display) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateDisplayModeKHR) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateDisplayPlaneSurfaceKHR) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetDisplayModePropertiesKHR) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetDisplayPlaneCapabilitiesKHR) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetDisplayPlaneSupportedDisplaysKHR) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceDisplayPlanePropertiesKHR) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceDisplayPropertiesKHR) +NAZARA_VULKANRENDERER_INSTANCE_EXT_END() + +NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(VK_KHR_surface) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkDestroySurfaceKHR) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfaceCapabilitiesKHR) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfaceFormatsKHR) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfacePresentModesKHR) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfaceSupportKHR) +NAZARA_VULKANRENDERER_INSTANCE_EXT_END() + +NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(VK_EXT_debug_report) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateDebugReportCallbackEXT) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkDestroyDebugReportCallbackEXT) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkDebugReportMessageEXT) +NAZARA_VULKANRENDERER_INSTANCE_EXT_END() + +#ifdef VK_USE_PLATFORM_ANDROID_KHR +NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(VK_KHR_android_surface) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateAndroidSurfaceKHR) +NAZARA_VULKANRENDERER_INSTANCE_EXT_END() +#endif + +#ifdef VK_USE_PLATFORM_MIR_KHR +NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(VK_KHR_mir_surface) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateMirSurfaceKHR) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceMirPresentationSupportKHR) +NAZARA_VULKANRENDERER_INSTANCE_EXT_END() +#endif + +#ifdef VK_USE_PLATFORM_XCB_KHR +NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(VK_KHR_xcb_surface) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateXcbSurfaceKHR) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceXcbPresentationSupportKHR) +NAZARA_VULKANRENDERER_INSTANCE_EXT_END() +#endif + +#ifdef VK_USE_PLATFORM_XLIB_KHR +NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(VK_KHR_xlib_surface) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateXlibSurfaceKHR) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceXlibPresentationSupportKHR) +NAZARA_VULKANRENDERER_INSTANCE_EXT_END() +#endif + +#ifdef VK_USE_PLATFORM_WAYLAND_KHR +NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(VK_KHR_wayland_surface) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateWaylandSurfaceKHR) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceWaylandPresentationSupportKHR) +NAZARA_VULKANRENDERER_INSTANCE_EXT_END() +#endif + +#ifdef VK_USE_PLATFORM_WIN32_KHR +NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(VK_KHR_win32_surface) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateWin32SurfaceKHR) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceWin32PresentationSupportKHR) +NAZARA_VULKANRENDERER_INSTANCE_EXT_END() +#endif diff --git a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp index 11ce99bf8..fe462adb6 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp @@ -44,141 +44,19 @@ namespace Nz m_loadedLayers.emplace(createInfo.ppEnabledLayerNames[i]); // Load all device-related functions - #define NAZARA_VULKANRENDERER_LOAD_DEVICE(func) func = reinterpret_cast(GetProcAddr(#func)) - try { ErrorFlags flags(ErrorFlag_ThrowException, true); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkAllocateCommandBuffers); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkAllocateDescriptorSets); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkAllocateMemory); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkBeginCommandBuffer); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkBindBufferMemory); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkBindImageMemory); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdBeginQuery); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdBeginRenderPass); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdBindDescriptorSets); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdBindIndexBuffer); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdBindPipeline); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdBindVertexBuffers); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdBlitImage); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdClearAttachments); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdClearColorImage); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdClearDepthStencilImage); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdCopyBuffer); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdCopyBufferToImage); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdCopyImage); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdCopyImageToBuffer); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdCopyQueryPoolResults); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdDispatch); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdDispatchIndirect); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdDraw); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdDrawIndexed); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdDrawIndexedIndirect); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdDrawIndirect); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdEndQuery); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdEndRenderPass); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdExecuteCommands); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdFillBuffer); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdNextSubpass); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdPipelineBarrier); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdPushConstants); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdResetEvent); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdResetQueryPool); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdResolveImage); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdSetBlendConstants); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdSetDepthBias); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdSetDepthBounds); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdSetEvent); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdSetLineWidth); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdSetScissor); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdSetStencilCompareMask); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdSetStencilReference); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdSetStencilWriteMask); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdSetViewport); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdUpdateBuffer); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdWaitEvents); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCmdWriteTimestamp); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateBuffer); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateBufferView); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateCommandPool); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateComputePipelines); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateDescriptorPool); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateDescriptorSetLayout); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateEvent); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateFence); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateFramebuffer); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateGraphicsPipelines); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateImage); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateImageView); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreatePipelineCache); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreatePipelineLayout); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateRenderPass); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateSampler); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateSemaphore); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateShaderModule); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyBuffer); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyBufferView); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyCommandPool); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyDescriptorPool); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyDescriptorSetLayout); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyDevice); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyEvent); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyFence); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyFramebuffer); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyImage); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyImageView); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyPipeline); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyPipelineCache); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyPipelineLayout); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyRenderPass); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroySampler); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroySemaphore); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroyShaderModule); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDeviceWaitIdle); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkEndCommandBuffer); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkFreeCommandBuffers); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkFreeDescriptorSets); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkFreeMemory); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkFlushMappedMemoryRanges); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkGetBufferMemoryRequirements); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkGetDeviceMemoryCommitment); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkGetDeviceQueue); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkGetEventStatus); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkGetFenceStatus); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkGetImageMemoryRequirements); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkGetImageSparseMemoryRequirements); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkGetImageSubresourceLayout); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkGetRenderAreaGranularity); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkInvalidateMappedMemoryRanges); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkMapMemory); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkMergePipelineCaches); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkQueueSubmit); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkQueueWaitIdle); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkResetCommandBuffer); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkResetCommandPool); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkResetDescriptorPool); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkResetFences); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkResetEvent); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkSetEvent); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkUnmapMemory); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkUpdateDescriptorSets); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkWaitForFences); +#define NAZARA_VULKANRENDERER_DEVICE_EXT_BEGIN(ext) if (IsExtensionLoaded(#ext)) { +#define NAZARA_VULKANRENDERER_DEVICE_EXT_END() } +#define NAZARA_VULKANRENDERER_DEVICE_FUNCTION(func) func = reinterpret_cast(GetProcAddr(#func)); - // VK_KHR_display_swapchain - if (IsExtensionLoaded("VK_KHR_display_swapchain")) - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateSharedSwapchainsKHR); +#include - // VK_KHR_swapchain - if (IsExtensionLoaded("VK_KHR_swapchain")) - { - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkAcquireNextImageKHR); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkCreateSwapchainKHR); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkDestroySwapchainKHR); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkGetSwapchainImagesKHR); - NAZARA_VULKANRENDERER_LOAD_DEVICE(vkQueuePresentKHR); - } +#undef NAZARA_VULKANRENDERER_DEVICE_EXT_BEGIN +#undef NAZARA_VULKANRENDERER_DEVICE_EXT_END +#undef NAZARA_VULKANRENDERER_DEVICE_FUNCTION } catch (const std::exception& e) { @@ -186,8 +64,6 @@ namespace Nz return false; } - #undef NAZARA_VULKANRENDERER_LOAD_DEVICE - // And retains informations about queues UInt32 maxFamilyIndex = 0; m_enabledQueuesInfos.resize(createInfo.queueCreateInfoCount); diff --git a/src/Nazara/VulkanRenderer/Wrapper/Instance.cpp b/src/Nazara/VulkanRenderer/Wrapper/Instance.cpp index f842e1279..c46028b15 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/Instance.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Instance.cpp @@ -35,104 +35,19 @@ namespace Nz m_loadedLayers.insert(createInfo.ppEnabledLayerNames[i]); // And now load everything - #define NAZARA_VULKANRENDERER_LOAD_INSTANCE(func) func = reinterpret_cast(GetProcAddr(#func)) - try { ErrorFlags flags(ErrorFlag_ThrowException, true); - // Vulkan core - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkCreateDevice); - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkDestroyInstance); - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkEnumeratePhysicalDevices); - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetDeviceProcAddr); - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceFeatures); - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceFormatProperties); - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceImageFormatProperties); - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceMemoryProperties); - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceProperties); - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceQueueFamilyProperties); +#define NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(ext) if (IsExtensionLoaded(#ext)) { +#define NAZARA_VULKANRENDERER_INSTANCE_EXT_END() } +#define NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(func) func = reinterpret_cast(GetProcAddr(#func)); - // VK_KHR_display - if (IsExtensionLoaded("VK_KHR_display")) - { - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkCreateDisplayModeKHR); - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkCreateDisplayPlaneSurfaceKHR); - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetDisplayModePropertiesKHR); - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetDisplayPlaneCapabilitiesKHR); - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetDisplayPlaneSupportedDisplaysKHR); - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceDisplayPlanePropertiesKHR); - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceDisplayPropertiesKHR); - } +#include - // VK_KHR_surface - if (IsExtensionLoaded("VK_KHR_surface")) - { - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkDestroySurfaceKHR); - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceSurfaceCapabilitiesKHR); - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceSurfaceFormatsKHR); - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceSurfacePresentModesKHR); - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceSurfaceSupportKHR); - } - - // VK_EXT_debug_report - if (IsExtensionLoaded("VK_EXT_debug_report")) - { - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkCreateDebugReportCallbackEXT); - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkDestroyDebugReportCallbackEXT); - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkDebugReportMessageEXT); - } - - #ifdef VK_USE_PLATFORM_ANDROID_KHR - // VK_KHR_android_surface - if (IsExtensionLoaded("VK_KHR_android_surface")) - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkCreateAndroidSurfaceKHR); - #endif - - #ifdef VK_USE_PLATFORM_MIR_KHR - // VK_KHR_mir_surface - if (IsExtensionLoaded("VK_KHR_mir_surface")) - { - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkCreateMirSurfaceKHR); - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceMirPresentationSupportKHR); - } - #endif - - #ifdef VK_USE_PLATFORM_XCB_KHR - // VK_KHR_xcb_surface - if (IsExtensionLoaded("VK_KHR_xcb_surface")) - { - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkCreateXcbSurfaceKHR); - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceXcbPresentationSupportKHR); - } - #endif - - #ifdef VK_USE_PLATFORM_XLIB_KHR - // VK_KHR_xlib_surface - if (IsExtensionLoaded("VK_KHR_xlib_surface")) - { - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkCreateXlibSurfaceKHR); - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceXlibPresentationSupportKHR); - } - #endif - - #ifdef VK_USE_PLATFORM_WAYLAND_KHR - // VK_KHR_wayland_surface - if (IsExtensionLoaded("VK_KHR_wayland_surface")) - { - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkCreateWaylandSurfaceKHR); - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceWaylandPresentationSupportKHR); - } - #endif - - #ifdef VK_USE_PLATFORM_WIN32_KHR - // VK_KHR_win32_surface - if (IsExtensionLoaded("VK_KHR_win32_surface")) - { - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkCreateWin32SurfaceKHR); - NAZARA_VULKANRENDERER_LOAD_INSTANCE(vkGetPhysicalDeviceWin32PresentationSupportKHR); - } - #endif +#undef NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN +#undef NAZARA_VULKANRENDERER_INSTANCE_EXT_END +#undef NAZARA_VULKANRENDERER_INSTANCE_FUNCTION } catch (const std::exception& e) { @@ -140,8 +55,6 @@ namespace Nz return false; } - #undef NAZARA_VULKANRENDERER_LOAD_INSTANCE - return true; } From 28cf4ed6e3dfefa6be736df72e66601c8ca043a3 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 8 Mar 2020 18:10:12 +0100 Subject: [PATCH 110/316] Make Vk::Device store a reference to Vk::PhysicalDevice info --- include/Nazara/VulkanRenderer/Wrapper/Device.hpp | 4 +++- include/Nazara/VulkanRenderer/Wrapper/Device.inl | 13 +++++++++---- src/Nazara/VulkanRenderer/Vulkan.cpp | 2 +- src/Nazara/VulkanRenderer/Wrapper/Device.cpp | 15 ++++----------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp index 71c9b28fc..1e381d16d 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -36,7 +37,7 @@ namespace Nz Device(Device&&) = delete; inline ~Device(); - bool Create(VkPhysicalDevice device, const VkDeviceCreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); + bool Create(const Vk::PhysicalDevice& deviceInfo, const VkDeviceCreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); inline void Destroy(); inline const std::vector& GetEnabledQueues() const; @@ -47,6 +48,7 @@ namespace Nz inline const Instance& GetInstance() const; inline VkResult GetLastErrorCode() const; inline VkPhysicalDevice GetPhysicalDevice() const; + inline const Vk::PhysicalDevice& GetPhysicalDeviceInfo() const; inline bool IsExtensionLoaded(const std::string& extensionName); inline bool IsLayerLoaded(const std::string& layerName); diff --git a/include/Nazara/VulkanRenderer/Wrapper/Device.inl b/include/Nazara/VulkanRenderer/Wrapper/Device.inl index a5035a75d..5affb6bc2 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Device.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Device.inl @@ -14,8 +14,8 @@ namespace Nz { inline Device::Device(Instance& instance) : m_instance(instance), - m_device(VK_NULL_HANDLE), - m_physicalDevice(VK_NULL_HANDLE) + m_physicalDevice(nullptr), + m_device(VK_NULL_HANDLE) { } @@ -32,7 +32,7 @@ namespace Nz vkDestroyDevice(m_device, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); m_device = VK_NULL_HANDLE; - m_physicalDevice = VK_NULL_HANDLE; + m_physicalDevice = nullptr; } } @@ -65,7 +65,12 @@ namespace Nz inline VkPhysicalDevice Device::GetPhysicalDevice() const { - return m_physicalDevice; + return m_physicalDevice->device; + } + + inline const Vk::PhysicalDevice& Device::GetPhysicalDeviceInfo() const + { + return *m_physicalDevice; } inline bool Device::IsExtensionLoaded(const std::string& extensionName) diff --git a/src/Nazara/VulkanRenderer/Vulkan.cpp b/src/Nazara/VulkanRenderer/Vulkan.cpp index 3ffbd9fc4..344f50103 100644 --- a/src/Nazara/VulkanRenderer/Vulkan.cpp +++ b/src/Nazara/VulkanRenderer/Vulkan.cpp @@ -429,7 +429,7 @@ namespace Nz }; std::shared_ptr device = std::make_shared(s_instance); - if (!device->Create(gpu, createInfo)) + if (!device->Create(GetPhysicalDeviceInfo(gpu), createInfo)) { NazaraError("Failed to create Vulkan Device: " + TranslateVulkanError(device->GetLastErrorCode())); return {}; diff --git a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp index fe462adb6..8f15e73ba 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp @@ -12,23 +12,16 @@ namespace Nz { namespace Vk { - bool Device::Create(VkPhysicalDevice device, const VkDeviceCreateInfo& createInfo, const VkAllocationCallbacks* allocator) + bool Device::Create(const Vk::PhysicalDevice& deviceInfo, const VkDeviceCreateInfo& createInfo, const VkAllocationCallbacks* allocator) { - std::vector queuesProperties; - if (!m_instance.GetPhysicalDeviceQueueFamilyProperties(device, &queuesProperties)) - { - NazaraError("Failed to query queue family properties"); - return false; - } - - m_lastErrorCode = m_instance.vkCreateDevice(device, &createInfo, allocator, &m_device); + m_lastErrorCode = m_instance.vkCreateDevice(deviceInfo.device, &createInfo, allocator, &m_device); if (m_lastErrorCode != VkResult::VK_SUCCESS) { NazaraError("Failed to create Vulkan device"); return false; } - m_physicalDevice = device; + m_physicalDevice = &deviceInfo; // Store the allocator to access them when needed if (allocator) @@ -76,7 +69,7 @@ namespace Nz if (info.familyIndex > maxFamilyIndex) maxFamilyIndex = info.familyIndex; - const VkQueueFamilyProperties& queueProperties = queuesProperties[info.familyIndex]; + const VkQueueFamilyProperties& queueProperties = deviceInfo.queues[info.familyIndex]; info.flags = queueProperties.queueFlags; info.minImageTransferGranularity = queueProperties.minImageTransferGranularity; info.timestampValidBits = queueProperties.timestampValidBits; From 4cf24cde7d55066a26a8f7e556429ed24043c9dd Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 8 Mar 2020 18:10:23 +0100 Subject: [PATCH 111/316] VertexDeclaration: Add check for duplicates --- include/Nazara/Utility/VertexDeclaration.inl | 2 +- src/Nazara/Utility/VertexDeclaration.cpp | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/include/Nazara/Utility/VertexDeclaration.inl b/include/Nazara/Utility/VertexDeclaration.inl index 07a82ba7b..1722e3936 100644 --- a/include/Nazara/Utility/VertexDeclaration.inl +++ b/include/Nazara/Utility/VertexDeclaration.inl @@ -10,7 +10,7 @@ namespace Nz { - inline auto Nz::VertexDeclaration::FindComponent(VertexComponent vertexComponent, std::size_t componentIndex) const -> const Component* + inline auto VertexDeclaration::FindComponent(VertexComponent vertexComponent, std::size_t componentIndex) const -> const Component* { assert(componentIndex == 0 || vertexComponent == VertexComponent_Userdata); diff --git a/src/Nazara/Utility/VertexDeclaration.cpp b/src/Nazara/Utility/VertexDeclaration.cpp index 6b4ecfd8c..99059aef5 100644 --- a/src/Nazara/Utility/VertexDeclaration.cpp +++ b/src/Nazara/Utility/VertexDeclaration.cpp @@ -17,20 +17,31 @@ namespace Nz VertexDeclaration::VertexDeclaration(VertexInputRate inputRate, std::initializer_list components) : m_inputRate(inputRate) { + ErrorFlags errFlags(ErrorFlag_ThrowException); std::size_t offset = 0; m_components.reserve(components.size()); for (const ComponentEntry& entry : components) { + NazaraAssert(IsTypeSupported(entry.type), "Component type 0x" + String::Number(entry.type, 16) + " is not supported by vertex declarations"); + NazaraAssert(entry.componentIndex == 0 || entry.component == VertexComponent_Userdata, "Only userdata components can have non-zero component indexes"); + + if (entry.component != VertexComponent_Unused) + { + // Check for duplicates + for (const Component& component : m_components) + { + if (component.component == entry.component && component.componentIndex == entry.componentIndex) + NazaraError("Duplicate component type found"); + } + } + auto& component = m_components.emplace_back(); component.component = entry.component; component.componentIndex = entry.componentIndex; component.offset = offset; component.type = entry.type; - NazaraAssert(IsTypeSupported(component.type), "Component type 0x" + String::Number(component.type, 16) + " is not supported by vertex declarations"); - NazaraAssert(component.componentIndex == 0 || component.component == VertexComponent_Userdata, "Only userdata components can have non-zero component indexes"); - offset += Utility::ComponentStride[component.type]; } From 63547fcd4e57c81afeea9760ddc7f4c0a1c0dfb0 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 13 Mar 2020 18:38:26 +0100 Subject: [PATCH 112/316] Replace DeviceHandle by references and keep device alive until Vulkan is freed --- examples/VulkanTest/main.cpp | 14 ++--- include/Nazara/VulkanRenderer/Vulkan.hpp | 2 +- .../Nazara/VulkanRenderer/VulkanBuffer.hpp | 6 +- .../Nazara/VulkanRenderer/VulkanBuffer.inl | 2 +- .../VulkanRenderer/VulkanRenderPipeline.hpp | 5 +- .../VulkanRenderPipelineLayout.hpp | 4 +- .../VulkanRenderer/VulkanShaderStage.hpp | 2 +- .../Nazara/VulkanRenderer/Wrapper/Buffer.hpp | 6 +- .../Nazara/VulkanRenderer/Wrapper/Buffer.inl | 12 ++-- .../VulkanRenderer/Wrapper/CommandPool.hpp | 6 +- .../VulkanRenderer/Wrapper/CommandPool.inl | 12 ++-- .../VulkanRenderer/Wrapper/DescriptorPool.hpp | 8 +-- .../VulkanRenderer/Wrapper/DescriptorPool.inl | 16 ++--- .../Wrapper/DescriptorSetLayout.hpp | 8 +-- .../Wrapper/DescriptorSetLayout.inl | 16 ++--- .../Nazara/VulkanRenderer/Wrapper/Device.hpp | 12 ++-- .../Nazara/VulkanRenderer/Wrapper/Device.inl | 24 -------- .../VulkanRenderer/Wrapper/DeviceMemory.hpp | 8 +-- .../VulkanRenderer/Wrapper/DeviceMemory.inl | 18 +++--- .../VulkanRenderer/Wrapper/DeviceObject.hpp | 7 ++- .../VulkanRenderer/Wrapper/DeviceObject.inl | 10 ++-- .../Nazara/VulkanRenderer/Wrapper/Fence.hpp | 6 +- .../Nazara/VulkanRenderer/Wrapper/Fence.inl | 12 ++-- .../VulkanRenderer/Wrapper/Framebuffer.hpp | 4 +- .../VulkanRenderer/Wrapper/Framebuffer.inl | 8 +-- .../Nazara/VulkanRenderer/Wrapper/Image.hpp | 4 +- .../Nazara/VulkanRenderer/Wrapper/Image.inl | 8 +-- .../VulkanRenderer/Wrapper/ImageView.hpp | 4 +- .../VulkanRenderer/Wrapper/ImageView.inl | 8 +-- .../VulkanRenderer/Wrapper/Instance.hpp | 3 + .../VulkanRenderer/Wrapper/Instance.inl | 15 ++++- .../VulkanRenderer/Wrapper/Pipeline.hpp | 10 ++-- .../VulkanRenderer/Wrapper/Pipeline.inl | 16 ++--- .../VulkanRenderer/Wrapper/PipelineCache.hpp | 4 +- .../VulkanRenderer/Wrapper/PipelineCache.inl | 8 +-- .../VulkanRenderer/Wrapper/PipelineLayout.hpp | 8 +-- .../VulkanRenderer/Wrapper/PipelineLayout.inl | 16 ++--- .../Nazara/VulkanRenderer/Wrapper/Queue.hpp | 6 +- .../Nazara/VulkanRenderer/Wrapper/Queue.inl | 25 ++------ .../VulkanRenderer/Wrapper/RenderPass.hpp | 4 +- .../VulkanRenderer/Wrapper/RenderPass.inl | 8 +-- .../VulkanRenderer/Wrapper/Semaphore.hpp | 6 +- .../VulkanRenderer/Wrapper/Semaphore.inl | 12 ++-- .../VulkanRenderer/Wrapper/ShaderModule.hpp | 6 +- .../VulkanRenderer/Wrapper/ShaderModule.inl | 12 ++-- .../VulkanRenderer/Wrapper/Swapchain.hpp | 6 +- .../VulkanRenderer/Wrapper/Swapchain.inl | 14 ++--- src/Nazara/VulkanRenderer/VkRenderWindow.cpp | 17 +++--- src/Nazara/VulkanRenderer/Vulkan.cpp | 18 +----- src/Nazara/VulkanRenderer/VulkanDevice.cpp | 10 ++-- .../VulkanRenderer/VulkanRenderPipeline.cpp | 6 +- .../VulkanRenderPipelineLayout.cpp | 8 +-- src/Nazara/VulkanRenderer/VulkanRenderer.cpp | 4 +- .../VulkanRenderer/VulkanShaderStage.cpp | 2 +- src/Nazara/VulkanRenderer/Wrapper/Device.cpp | 60 ++++++++++++++++++- .../VulkanRenderer/Wrapper/Instance.cpp | 15 +++++ 56 files changed, 303 insertions(+), 268 deletions(-) diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index bd121a9b1..34333abb5 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -154,7 +154,7 @@ int main() Nz::VulkanDevice& vulkanDevice = vulkanWindow.GetDevice(); Nz::Vk::DescriptorPool descriptorPool; - if (!descriptorPool.Create(vulkanDevice.shared_from_this(), 1, poolSize, VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT)) + if (!descriptorPool.Create(vulkanDevice, 1, poolSize, VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT)) { NazaraError("Failed to create descriptor pool"); return __LINE__; @@ -165,7 +165,7 @@ int main() Nz::RenderBuffer* renderBufferUB = static_cast(uniformBuffer.GetBuffer()->GetImpl()); if (!renderBufferUB->Synchronize(&vulkanDevice)) { - NazaraError("Failed to synchronize render buffer"); + NazaraError("Failed to create uniform buffer"); return __LINE__; } Nz::VulkanBuffer* uniformBufferImpl = static_cast(renderBufferUB->GetHardwareBuffer(&vulkanDevice)); @@ -188,7 +188,7 @@ int main() pipelineCreateInfo.pipelineInfo.renderPass = vulkanWindow.GetRenderPass(); Nz::Vk::CommandPool cmdPool; - if (!cmdPool.Create(vulkanDevice.shared_from_this(), 0, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)) + if (!cmdPool.Create(vulkanDevice, 0, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)) { NazaraError("Failed to create rendering cmd pool"); return __LINE__; @@ -198,7 +198,7 @@ int main() clearValues[0].color = {1.0f, 0.8f, 0.4f, 0.0f}; clearValues[1].depthStencil = {1.f, 0}; - Nz::Vk::Queue graphicsQueue(vulkanDevice.shared_from_this(), vulkanDevice.GetEnabledQueues()[0].queues[0].queue); + Nz::Vk::Queue graphicsQueue(vulkanDevice, vulkanDevice.GetEnabledQueues()[0].queues[0].queue); Nz::UInt32 imageCount = vulkanWindow.GetFramebufferCount(); std::vector renderCmds = cmdPool.AllocateCommandBuffers(imageCount, VK_COMMAND_BUFFER_LEVEL_PRIMARY); @@ -286,10 +286,10 @@ int main() std::vector frameSync(MaxConcurrentImage); for (ImageSync& syncData : frameSync) { - syncData.imageAvailableSemaphore.Create(vulkanDevice.shared_from_this()); - syncData.renderFinishedSemaphore.Create(vulkanDevice.shared_from_this()); + syncData.imageAvailableSemaphore.Create(vulkanDevice); + syncData.renderFinishedSemaphore.Create(vulkanDevice); - syncData.inflightFence.Create(vulkanDevice.shared_from_this(), VK_FENCE_CREATE_SIGNALED_BIT); + syncData.inflightFence.Create(vulkanDevice, VK_FENCE_CREATE_SIGNALED_BIT); } std::vector inflightFences(imageCount, nullptr); diff --git a/include/Nazara/VulkanRenderer/Vulkan.hpp b/include/Nazara/VulkanRenderer/Vulkan.hpp index 2898dca94..ef88e3d10 100644 --- a/include/Nazara/VulkanRenderer/Vulkan.hpp +++ b/include/Nazara/VulkanRenderer/Vulkan.hpp @@ -54,7 +54,7 @@ namespace Nz static void Uninitialize(); private: - static std::vector> s_devices; + static std::vector> s_devices; static std::vector s_physDevices; static Vk::Instance s_instance; static ParameterList s_initializationParameters; diff --git a/include/Nazara/VulkanRenderer/VulkanBuffer.hpp b/include/Nazara/VulkanRenderer/VulkanBuffer.hpp index 04ee709dd..52adcf253 100644 --- a/include/Nazara/VulkanRenderer/VulkanBuffer.hpp +++ b/include/Nazara/VulkanRenderer/VulkanBuffer.hpp @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include namespace Nz @@ -21,7 +23,7 @@ namespace Nz class NAZARA_VULKANRENDERER_API VulkanBuffer : public AbstractBuffer { public: - inline VulkanBuffer(const Vk::DeviceHandle& device, Buffer* parent, BufferType type); + inline VulkanBuffer(Vk::Device& device, Buffer* parent, BufferType type); VulkanBuffer(const VulkanBuffer&) = delete; VulkanBuffer(VulkanBuffer&&) = delete; ///TODO virtual ~VulkanBuffer(); @@ -43,8 +45,8 @@ namespace Nz Buffer* m_parent; BufferType m_type; Nz::Vk::Buffer m_buffer; - Nz::Vk::DeviceHandle m_device; Nz::Vk::DeviceMemory m_memory; + Vk::Device& m_device; }; } diff --git a/include/Nazara/VulkanRenderer/VulkanBuffer.inl b/include/Nazara/VulkanRenderer/VulkanBuffer.inl index cc699a10d..2e210c149 100644 --- a/include/Nazara/VulkanRenderer/VulkanBuffer.inl +++ b/include/Nazara/VulkanRenderer/VulkanBuffer.inl @@ -7,7 +7,7 @@ namespace Nz { - inline VulkanBuffer::VulkanBuffer(const Vk::DeviceHandle& device, Buffer* parent, BufferType type) : + inline VulkanBuffer::VulkanBuffer(Vk::Device& device, Buffer* /*parent*/, BufferType type) : m_device(device), m_parent(parent), m_type(type) diff --git a/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp b/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp index baa644c60..6fa836a47 100644 --- a/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp +++ b/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp @@ -8,6 +8,7 @@ #define NAZARA_VULKANRENDERER_VULKANRENDERPIPELINE_HPP #include +#include #include #include #include @@ -22,7 +23,7 @@ namespace Nz public: struct CreateInfo; - VulkanRenderPipeline(Vk::DeviceHandle device, RenderPipelineInfo pipelineInfo); + VulkanRenderPipeline(Vk::Device& device, RenderPipelineInfo pipelineInfo); ~VulkanRenderPipeline() = default; VkPipeline Get(const Vk::RenderPass& renderPass); @@ -69,7 +70,7 @@ namespace Nz private: std::unordered_map m_pipelines; - Vk::DeviceHandle m_device; + MovablePtr m_device; CreateInfo m_pipelineCreateInfo; RenderPipelineInfo m_pipelineInfo; }; diff --git a/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.hpp b/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.hpp index beac99148..98911226c 100644 --- a/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.hpp +++ b/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.hpp @@ -23,13 +23,13 @@ namespace Nz VulkanRenderPipelineLayout() = default; ~VulkanRenderPipelineLayout() = default; - bool Create(Vk::DeviceHandle device, RenderPipelineLayoutInfo layoutInfo); + bool Create(Vk::Device& device, RenderPipelineLayoutInfo layoutInfo); inline const Vk::DescriptorSetLayout& GetDescriptorSetLayout() const; inline const Vk::PipelineLayout& GetPipelineLayout() const; private: - Vk::DeviceHandle m_device; + MovablePtr m_device; Vk::DescriptorSetLayout m_descriptorSetLayout; Vk::PipelineLayout m_pipelineLayout; RenderPipelineLayoutInfo m_layoutInfo; diff --git a/include/Nazara/VulkanRenderer/VulkanShaderStage.hpp b/include/Nazara/VulkanRenderer/VulkanShaderStage.hpp index 533592a45..5809ba4e7 100644 --- a/include/Nazara/VulkanRenderer/VulkanShaderStage.hpp +++ b/include/Nazara/VulkanRenderer/VulkanShaderStage.hpp @@ -23,7 +23,7 @@ namespace Nz VulkanShaderStage(VulkanShaderStage&&) noexcept = default; ~VulkanShaderStage() = default; - bool Create(const Vk::DeviceHandle& device, ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize); + bool Create(Vk::Device& device, ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize); inline const Vk::ShaderModule& GetHandle() const; inline ShaderStageType GetStageType() const; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp b/include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp index a846c922e..ad3573f34 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp @@ -27,7 +27,7 @@ namespace Nz bool BindBufferMemory(VkDeviceMemory memory, VkDeviceSize offset = 0); using DeviceObject::Create; - inline bool Create(DeviceHandle device, VkBufferCreateFlags flags, VkDeviceSize size, VkBufferUsageFlags usage, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(Device& device, VkBufferCreateFlags flags, VkDeviceSize size, VkBufferUsageFlags usage, const VkAllocationCallbacks* allocator = nullptr); VkMemoryRequirements GetMemoryRequirements() const; @@ -35,8 +35,8 @@ namespace Nz Buffer& operator=(Buffer&&) = delete; private: - static inline VkResult CreateHelper(const DeviceHandle& device, const VkBufferCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkBuffer* handle); - static inline void DestroyHelper(const DeviceHandle& device, VkBuffer handle, const VkAllocationCallbacks* allocator); + static inline VkResult CreateHelper(Device& device, const VkBufferCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkBuffer* handle); + static inline void DestroyHelper(Device& device, VkBuffer handle, const VkAllocationCallbacks* allocator); }; } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/Buffer.inl b/include/Nazara/VulkanRenderer/Wrapper/Buffer.inl index e5b79d6c7..15762a7b0 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Buffer.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Buffer.inl @@ -21,7 +21,7 @@ namespace Nz return true; } - inline bool Buffer::Create(DeviceHandle device, VkBufferCreateFlags flags, VkDeviceSize size, VkBufferUsageFlags usage, const VkAllocationCallbacks* allocator) + inline bool Buffer::Create(Device& device, VkBufferCreateFlags flags, VkDeviceSize size, VkBufferUsageFlags usage, const VkAllocationCallbacks* allocator) { VkBufferCreateInfo createInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType; @@ -34,7 +34,7 @@ namespace Nz nullptr // const uint32_t* pQueueFamilyIndices; }; - return Create(std::move(device), createInfo, allocator); + return Create(device, createInfo, allocator); } inline VkMemoryRequirements Buffer::GetMemoryRequirements() const @@ -47,14 +47,14 @@ namespace Nz return memoryRequirements; } - inline VkResult Buffer::CreateHelper(const DeviceHandle& device, const VkBufferCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkBuffer* handle) + inline VkResult Buffer::CreateHelper(Device& device, const VkBufferCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkBuffer* handle) { - return device->vkCreateBuffer(*device, createInfo, allocator, handle); + return device.vkCreateBuffer(device, createInfo, allocator, handle); } - inline void Buffer::DestroyHelper(const DeviceHandle& device, VkBuffer handle, const VkAllocationCallbacks* allocator) + inline void Buffer::DestroyHelper(Device& device, VkBuffer handle, const VkAllocationCallbacks* allocator) { - return device->vkDestroyBuffer(*device, handle, allocator); + return device.vkDestroyBuffer(device, handle, allocator); } } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandPool.hpp b/include/Nazara/VulkanRenderer/Wrapper/CommandPool.hpp index ff88dc378..807f26f19 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandPool.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandPool.hpp @@ -30,7 +30,7 @@ namespace Nz std::vector AllocateCommandBuffers(UInt32 commandBufferCount, VkCommandBufferLevel level); using DeviceObject::Create; - inline bool Create(DeviceHandle device, UInt32 queueFamilyIndex, VkCommandPoolCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(Device& device, UInt32 queueFamilyIndex, VkCommandPoolCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); inline bool Reset(VkCommandPoolResetFlags flags); @@ -38,8 +38,8 @@ namespace Nz CommandPool& operator=(CommandPool&&) = delete; private: - static inline VkResult CreateHelper(const DeviceHandle& device, const VkCommandPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkCommandPool* handle); - static inline void DestroyHelper(const DeviceHandle& device, VkCommandPool handle, const VkAllocationCallbacks* allocator); + 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); }; } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandPool.inl b/include/Nazara/VulkanRenderer/Wrapper/CommandPool.inl index 96b1f2abd..615db5898 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandPool.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandPool.inl @@ -11,7 +11,7 @@ namespace Nz { namespace Vk { - inline bool CommandPool::Create(DeviceHandle device, UInt32 queueFamilyIndex, VkCommandPoolCreateFlags flags, const VkAllocationCallbacks* allocator) + inline bool CommandPool::Create(Device& device, UInt32 queueFamilyIndex, VkCommandPoolCreateFlags flags, const VkAllocationCallbacks* allocator) { VkCommandPoolCreateInfo createInfo = { @@ -21,7 +21,7 @@ namespace Nz queueFamilyIndex }; - return Create(std::move(device), createInfo, allocator); + return Create(device, createInfo, allocator); } inline bool CommandPool::Reset(VkCommandPoolResetFlags flags) @@ -33,14 +33,14 @@ namespace Nz return true; } - inline VkResult CommandPool::CreateHelper(const DeviceHandle& device, const VkCommandPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkCommandPool* handle) + inline VkResult CommandPool::CreateHelper(Device& device, const VkCommandPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkCommandPool* handle) { - return device->vkCreateCommandPool(*device, createInfo, allocator, handle); + return device.vkCreateCommandPool(device, createInfo, allocator, handle); } - inline void CommandPool::DestroyHelper(const DeviceHandle& device, VkCommandPool handle, const VkAllocationCallbacks* allocator) + inline void CommandPool::DestroyHelper(Device& device, VkCommandPool handle, const VkAllocationCallbacks* allocator) { - return device->vkDestroyCommandPool(*device, handle, allocator); + return device.vkDestroyCommandPool(device, handle, allocator); } } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp b/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp index bf7da5556..06f64d185 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp @@ -30,15 +30,15 @@ namespace Nz std::vector AllocateDescriptorSets(UInt32 descriptorSetCount, const VkDescriptorSetLayout* setLayouts); using DeviceObject::Create; - inline bool Create(DeviceHandle device, UInt32 maxSets, const VkDescriptorPoolSize& poolSize, VkDescriptorPoolCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); - inline bool Create(DeviceHandle device, UInt32 maxSets, UInt32 poolSizeCount, const VkDescriptorPoolSize* poolSize, VkDescriptorPoolCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(Device& device, UInt32 maxSets, const VkDescriptorPoolSize& poolSize, VkDescriptorPoolCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(Device& device, UInt32 maxSets, UInt32 poolSizeCount, const VkDescriptorPoolSize* poolSize, VkDescriptorPoolCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); DescriptorPool& operator=(const DescriptorPool&) = delete; DescriptorPool& operator=(DescriptorPool&&) = delete; private: - static inline VkResult CreateHelper(const DeviceHandle& device, const VkDescriptorPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkDescriptorPool* handle); - static inline void DestroyHelper(const DeviceHandle& device, VkDescriptorPool handle, const VkAllocationCallbacks* allocator); + static inline VkResult CreateHelper(Device& device, const VkDescriptorPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkDescriptorPool* handle); + static inline void DestroyHelper(Device& device, VkDescriptorPool handle, const VkAllocationCallbacks* allocator); }; } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.inl b/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.inl index a4161b367..46392a326 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.inl @@ -9,7 +9,7 @@ namespace Nz { namespace Vk { - inline bool DescriptorPool::Create(DeviceHandle device, UInt32 maxSets, const VkDescriptorPoolSize& poolSize, VkDescriptorPoolCreateFlags flags, const VkAllocationCallbacks* allocator) + inline bool DescriptorPool::Create(Device& device, UInt32 maxSets, const VkDescriptorPoolSize& poolSize, VkDescriptorPoolCreateFlags flags, const VkAllocationCallbacks* allocator) { VkDescriptorPoolCreateInfo createInfo = { @@ -21,10 +21,10 @@ namespace Nz &poolSize // const VkDescriptorPoolSize* pPoolSizes; }; - return Create(std::move(device), createInfo, allocator); + return Create(device, createInfo, allocator); } - inline bool DescriptorPool::Create(DeviceHandle device, UInt32 maxSets, UInt32 poolSizeCount, const VkDescriptorPoolSize* poolSize, VkDescriptorPoolCreateFlags flags, const VkAllocationCallbacks* allocator) + inline bool DescriptorPool::Create(Device& device, UInt32 maxSets, UInt32 poolSizeCount, const VkDescriptorPoolSize* poolSize, VkDescriptorPoolCreateFlags flags, const VkAllocationCallbacks* allocator) { VkDescriptorPoolCreateInfo createInfo = { @@ -36,17 +36,17 @@ namespace Nz poolSize // const VkDescriptorPoolSize* pPoolSizes; }; - return Create(std::move(device), createInfo, allocator); + return Create(device, createInfo, allocator); } - inline VkResult DescriptorPool::CreateHelper(const DeviceHandle& device, const VkDescriptorPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkDescriptorPool* handle) + inline VkResult DescriptorPool::CreateHelper(Device& device, const VkDescriptorPoolCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkDescriptorPool* handle) { - return device->vkCreateDescriptorPool(*device, createInfo, allocator, handle); + return device.vkCreateDescriptorPool(device, createInfo, allocator, handle); } - inline void DescriptorPool::DestroyHelper(const DeviceHandle& device, VkDescriptorPool handle, const VkAllocationCallbacks* allocator) + inline void DescriptorPool::DestroyHelper(Device& device, VkDescriptorPool handle, const VkAllocationCallbacks* allocator) { - return device->vkDestroyDescriptorPool(*device, handle, allocator); + return device.vkDestroyDescriptorPool(device, handle, allocator); } } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.hpp b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.hpp index fd2b09a22..81ef4849e 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.hpp @@ -25,15 +25,15 @@ namespace Nz ~DescriptorSetLayout() = default; using DeviceObject::Create; - inline bool Create(DeviceHandle device, const VkDescriptorSetLayoutBinding& binding, VkDescriptorSetLayoutCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); - inline bool Create(DeviceHandle device, UInt32 bindingCount, const VkDescriptorSetLayoutBinding* binding, VkDescriptorSetLayoutCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(Device& device, const VkDescriptorSetLayoutBinding& binding, VkDescriptorSetLayoutCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(Device& device, UInt32 bindingCount, const VkDescriptorSetLayoutBinding* binding, VkDescriptorSetLayoutCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); DescriptorSetLayout& operator=(const DescriptorSetLayout&) = delete; DescriptorSetLayout& operator=(DescriptorSetLayout&&) = delete; private: - static inline VkResult CreateHelper(const DeviceHandle& device, const VkDescriptorSetLayoutCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkDescriptorSetLayout* handle); - static inline void DestroyHelper(const DeviceHandle& device, VkDescriptorSetLayout handle, const VkAllocationCallbacks* allocator); + static inline VkResult CreateHelper(Device& device, const VkDescriptorSetLayoutCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkDescriptorSetLayout* handle); + static inline void DestroyHelper(Device& device, VkDescriptorSetLayout handle, const VkAllocationCallbacks* allocator); }; } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.inl b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.inl index 20b74400a..3e25fe591 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.inl @@ -9,12 +9,12 @@ namespace Nz { namespace Vk { - inline bool DescriptorSetLayout::Create(DeviceHandle device, const VkDescriptorSetLayoutBinding& binding, VkDescriptorSetLayoutCreateFlags flags, const VkAllocationCallbacks* allocator) + inline bool DescriptorSetLayout::Create(Device& device, const VkDescriptorSetLayoutBinding& binding, VkDescriptorSetLayoutCreateFlags flags, const VkAllocationCallbacks* allocator) { - return Create(std::move(device), 1U, &binding, flags, allocator); + return Create(device, 1U, &binding, flags, allocator); } - inline bool DescriptorSetLayout::Create(DeviceHandle device, UInt32 bindingCount, const VkDescriptorSetLayoutBinding* binding, VkDescriptorSetLayoutCreateFlags flags, const VkAllocationCallbacks* allocator) + inline bool DescriptorSetLayout::Create(Device& device, UInt32 bindingCount, const VkDescriptorSetLayoutBinding* binding, VkDescriptorSetLayoutCreateFlags flags, const VkAllocationCallbacks* allocator) { VkDescriptorSetLayoutCreateInfo createInfo = { @@ -25,17 +25,17 @@ namespace Nz binding // const VkDescriptorSetLayoutBinding* pBindings; }; - return Create(std::move(device), createInfo, allocator); + return Create(device, createInfo, allocator); } - inline VkResult DescriptorSetLayout::CreateHelper(const DeviceHandle& device, const VkDescriptorSetLayoutCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkDescriptorSetLayout* handle) + inline VkResult DescriptorSetLayout::CreateHelper(Device& device, const VkDescriptorSetLayoutCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkDescriptorSetLayout* handle) { - return device->vkCreateDescriptorSetLayout(*device, createInfo, allocator, handle); + return device.vkCreateDescriptorSetLayout(device, createInfo, allocator, handle); } - inline void DescriptorSetLayout::DestroyHelper(const DeviceHandle& device, VkDescriptorSetLayout handle, const VkAllocationCallbacks* allocator) + inline void DescriptorSetLayout::DestroyHelper(Device& device, VkDescriptorSetLayout handle, const VkAllocationCallbacks* allocator) { - return device->vkDestroyDescriptorSetLayout(*device, handle, allocator); + return device.vkDestroyDescriptorSetLayout(device, handle, allocator); } } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp index 1e381d16d..b2a4cf70b 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp @@ -19,12 +19,9 @@ namespace Nz { namespace Vk { - class Device; class Instance; class Queue; - using DeviceHandle = std::shared_ptr; - class NAZARA_VULKANRENDERER_API Device : public std::enable_shared_from_this { public: @@ -32,10 +29,10 @@ namespace Nz struct QueueInfo; using QueueList = std::vector; - inline Device(Instance& instance); + Device(Instance& instance); Device(const Device&) = delete; Device(Device&&) = delete; - inline ~Device(); + ~Device(); bool Create(const Vk::PhysicalDevice& deviceInfo, const VkDeviceCreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); inline void Destroy(); @@ -63,7 +60,7 @@ namespace Nz // Vulkan functions #define NAZARA_VULKANRENDERER_DEVICE_EXT_BEGIN(ext) #define NAZARA_VULKANRENDERER_DEVICE_EXT_END() -#define NAZARA_VULKANRENDERER_DEVICE_FUNCTION(func) PFN_##func func; +#define NAZARA_VULKANRENDERER_DEVICE_FUNCTION(func) PFN_##func func = nullptr; #include @@ -88,6 +85,9 @@ namespace Nz }; private: + void WaitAndDestroyDevice(); + void ResetPointers(); + inline PFN_vkVoidFunction GetProcAddr(const char* name); Instance& m_instance; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Device.inl b/include/Nazara/VulkanRenderer/Wrapper/Device.inl index 5affb6bc2..e3a069745 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Device.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Device.inl @@ -12,30 +12,6 @@ namespace Nz { namespace Vk { - inline Device::Device(Instance& instance) : - m_instance(instance), - m_physicalDevice(nullptr), - m_device(VK_NULL_HANDLE) - { - } - - inline Device::~Device() - { - Destroy(); - } - - inline void Device::Destroy() - { - if (m_device != VK_NULL_HANDLE) - { - vkDeviceWaitIdle(m_device); - vkDestroyDevice(m_device, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); - - m_device = VK_NULL_HANDLE; - m_physicalDevice = nullptr; - } - } - inline const std::vector& Device::GetEnabledQueues() const { return m_enabledQueuesInfos; diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp b/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp index d6f32e80a..8b2d57ada 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp @@ -25,8 +25,8 @@ namespace Nz ~DeviceMemory() = default; using DeviceObject::Create; - inline bool Create(DeviceHandle device, VkDeviceSize size, UInt32 memoryType, const VkAllocationCallbacks* allocator = nullptr); - inline bool Create(DeviceHandle device, VkDeviceSize size, UInt32 typeBits, VkFlags properties, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(Device& device, VkDeviceSize size, UInt32 memoryType, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(Device& device, VkDeviceSize size, UInt32 typeBits, VkFlags properties, const VkAllocationCallbacks* allocator = nullptr); inline void* GetMappedPointer(); @@ -38,8 +38,8 @@ namespace Nz DeviceMemory& operator=(DeviceMemory&&) = delete; private: - static inline VkResult CreateHelper(const DeviceHandle& device, const VkMemoryAllocateInfo* allocInfo, const VkAllocationCallbacks* allocator, VkDeviceMemory* handle); - static inline void DestroyHelper(const DeviceHandle& device, VkDeviceMemory handle, const VkAllocationCallbacks* allocator); + static inline VkResult CreateHelper(Device& device, const VkMemoryAllocateInfo* allocInfo, const VkAllocationCallbacks* allocator, VkDeviceMemory* handle); + static inline void DestroyHelper(Device& device, VkDeviceMemory handle, const VkAllocationCallbacks* allocator); void* m_mappedPtr; }; diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.inl b/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.inl index 26bee7012..65fd619d4 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.inl @@ -24,7 +24,7 @@ namespace Nz memory.m_mappedPtr = nullptr; } - inline bool DeviceMemory::Create(DeviceHandle device, VkDeviceSize size, UInt32 memoryType, const VkAllocationCallbacks* allocator) + inline bool DeviceMemory::Create(Device& device, VkDeviceSize size, UInt32 memoryType, const VkAllocationCallbacks* allocator) { VkMemoryAllocateInfo allocInfo = { @@ -34,12 +34,12 @@ namespace Nz memoryType // uint32_t memoryTypeIndex; }; - return Create(std::move(device), allocInfo, allocator); + return Create(device, allocInfo, allocator); } - inline bool DeviceMemory::Create(DeviceHandle device, VkDeviceSize size, UInt32 typeBits, VkFlags properties, const VkAllocationCallbacks* allocator) + inline bool DeviceMemory::Create(Device& device, VkDeviceSize size, UInt32 typeBits, VkFlags properties, const VkAllocationCallbacks* allocator) { - const Vk::PhysicalDevice& deviceInfo = Vulkan::GetPhysicalDeviceInfo(device->GetPhysicalDevice()); + const Vk::PhysicalDevice& deviceInfo = Vulkan::GetPhysicalDeviceInfo(device.GetPhysicalDevice()); UInt32 typeMask = 1; for (UInt32 i = 0; i < VK_MAX_MEMORY_TYPES; ++i) @@ -47,7 +47,7 @@ namespace Nz if (typeBits & typeMask) { if ((deviceInfo.memoryProperties.memoryTypes[i].propertyFlags & properties) == properties) - return Create(std::move(device), size, i, allocator); + return Create(device, size, i, allocator); } typeMask <<= 1; @@ -82,14 +82,14 @@ namespace Nz m_mappedPtr = nullptr; } - inline VkResult DeviceMemory::CreateHelper(const DeviceHandle& device, const VkMemoryAllocateInfo* allocInfo, const VkAllocationCallbacks* allocator, VkDeviceMemory* handle) + inline VkResult DeviceMemory::CreateHelper(Device& device, const VkMemoryAllocateInfo* allocInfo, const VkAllocationCallbacks* allocator, VkDeviceMemory* handle) { - return device->vkAllocateMemory(*device, allocInfo, allocator, handle); + return device.vkAllocateMemory(device, allocInfo, allocator, handle); } - inline void DeviceMemory::DestroyHelper(const DeviceHandle& device, VkDeviceMemory handle, const VkAllocationCallbacks* allocator) + inline void DeviceMemory::DestroyHelper(Device& device, VkDeviceMemory handle, const VkAllocationCallbacks* allocator) { - return device->vkFreeMemory(*device, handle, allocator); + return device.vkFreeMemory(device, handle, allocator); } } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp index 4062cb5c8..887b05563 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp @@ -8,6 +8,7 @@ #define NAZARA_VULKANRENDERER_VKDEVICEOBJECT_HPP #include +#include #include #include @@ -24,12 +25,12 @@ namespace Nz DeviceObject(DeviceObject&& object); ~DeviceObject(); - bool Create(DeviceHandle device, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); + bool Create(Device& device, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); void Destroy(); bool IsValid() const; - const DeviceHandle& GetDevice() const; + Device* GetDevice() const; VkResult GetLastErrorCode() const; DeviceObject& operator=(const DeviceObject&) = delete; @@ -38,7 +39,7 @@ namespace Nz operator VkType() const; protected: - DeviceHandle m_device; + MovablePtr m_device; VkAllocationCallbacks m_allocator; VkType m_handle; mutable VkResult m_lastErrorCode; diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl index def0ebc0a..91c671ce4 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl @@ -36,10 +36,10 @@ namespace Nz } template - bool DeviceObject::Create(DeviceHandle device, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator) + bool DeviceObject::Create(Device& device, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator) { - m_device = std::move(device); - m_lastErrorCode = C::CreateHelper(m_device, &createInfo, allocator, &m_handle); + m_device = &device; + m_lastErrorCode = C::CreateHelper(*m_device, &createInfo, allocator, &m_handle); if (m_lastErrorCode != VkResult::VK_SUCCESS) { NazaraError("Failed to create Vulkan object: " + TranslateVulkanError(m_lastErrorCode)); @@ -60,7 +60,7 @@ namespace Nz { if (IsValid()) { - C::DestroyHelper(m_device, m_handle, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); + C::DestroyHelper(*m_device, m_handle, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); m_handle = VK_NULL_HANDLE; } } @@ -72,7 +72,7 @@ namespace Nz } template - const DeviceHandle& DeviceObject::GetDevice() const + Device* DeviceObject::GetDevice() const { return m_device; } diff --git a/include/Nazara/VulkanRenderer/Wrapper/Fence.hpp b/include/Nazara/VulkanRenderer/Wrapper/Fence.hpp index a78b4a597..054083a3a 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Fence.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Fence.hpp @@ -25,7 +25,7 @@ namespace Nz ~Fence() = default; using DeviceObject::Create; - inline bool Create(DeviceHandle device, VkFenceCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(Device& device, VkFenceCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); inline bool Reset(); @@ -36,8 +36,8 @@ namespace Nz Fence& operator=(Fence&&) = delete; private: - static inline VkResult CreateHelper(const DeviceHandle& device, const VkFenceCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkFence* handle); - static inline void DestroyHelper(const DeviceHandle& device, VkFence handle, const VkAllocationCallbacks* allocator); + static inline VkResult CreateHelper(Device& device, const VkFenceCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkFence* handle); + static inline void DestroyHelper(Device& device, VkFence handle, const VkAllocationCallbacks* allocator); }; } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/Fence.inl b/include/Nazara/VulkanRenderer/Wrapper/Fence.inl index 7a02c20b5..e89f31ed1 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Fence.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Fence.inl @@ -9,7 +9,7 @@ namespace Nz { namespace Vk { - inline bool Fence::Create(DeviceHandle device, VkFenceCreateFlags flags, const VkAllocationCallbacks* allocator) + inline bool Fence::Create(Device& device, VkFenceCreateFlags flags, const VkAllocationCallbacks* allocator) { VkFenceCreateInfo createInfo = { @@ -18,7 +18,7 @@ namespace Nz flags }; - return Create(std::move(device), createInfo, allocator); + return Create(device, createInfo, allocator); } inline bool Fence::Reset() @@ -53,14 +53,14 @@ namespace Nz return true; } - inline VkResult Fence::CreateHelper(const DeviceHandle& device, const VkFenceCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkFence* handle) + inline VkResult Fence::CreateHelper(Device& device, const VkFenceCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkFence* handle) { - return device->vkCreateFence(*device, createInfo, allocator, handle); + return device.vkCreateFence(device, createInfo, allocator, handle); } - inline void Fence::DestroyHelper(const DeviceHandle& device, VkFence handle, const VkAllocationCallbacks* allocator) + inline void Fence::DestroyHelper(Device& device, VkFence handle, const VkAllocationCallbacks* allocator) { - return device->vkDestroyFence(*device, handle, allocator); + return device.vkDestroyFence(device, handle, allocator); } } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.hpp b/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.hpp index 297b69b93..014d1e205 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.hpp @@ -28,8 +28,8 @@ namespace Nz Framebuffer& operator=(Framebuffer&&) = delete; private: - static inline VkResult CreateHelper(const DeviceHandle& device, const VkFramebufferCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkFramebuffer* handle); - static inline void DestroyHelper(const DeviceHandle& device, VkFramebuffer handle, const VkAllocationCallbacks* allocator); + static inline VkResult CreateHelper(Device& device, const VkFramebufferCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkFramebuffer* handle); + static inline void DestroyHelper(Device& device, VkFramebuffer handle, const VkAllocationCallbacks* allocator); }; } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.inl b/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.inl index a13b52539..7b486c952 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.inl @@ -9,14 +9,14 @@ namespace Nz { namespace Vk { - inline VkResult Framebuffer::CreateHelper(const DeviceHandle& device, const VkFramebufferCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkFramebuffer* handle) + inline VkResult Framebuffer::CreateHelper(Device& device, const VkFramebufferCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkFramebuffer* handle) { - return device->vkCreateFramebuffer(*device, createInfo, allocator, handle); + return device.vkCreateFramebuffer(device, createInfo, allocator, handle); } - inline void Framebuffer::DestroyHelper(const DeviceHandle& device, VkFramebuffer handle, const VkAllocationCallbacks* allocator) + inline void Framebuffer::DestroyHelper(Device& device, VkFramebuffer handle, const VkAllocationCallbacks* allocator) { - return device->vkDestroyFramebuffer(*device, handle, allocator); + return device.vkDestroyFramebuffer(device, handle, allocator); } } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/Image.hpp b/include/Nazara/VulkanRenderer/Wrapper/Image.hpp index f63910501..3c6cdc0e1 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Image.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Image.hpp @@ -32,8 +32,8 @@ namespace Nz Image& operator=(Image&&) = delete; private: - static inline VkResult CreateHelper(const DeviceHandle& device, const VkImageCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkImage* handle); - static inline void DestroyHelper(const DeviceHandle& device, VkImage handle, const VkAllocationCallbacks* allocator); + static inline VkResult CreateHelper(Device& device, const VkImageCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkImage* handle); + static inline void DestroyHelper(Device& device, VkImage handle, const VkAllocationCallbacks* allocator); }; } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/Image.inl b/include/Nazara/VulkanRenderer/Wrapper/Image.inl index bafaf1c62..575aab441 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Image.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Image.inl @@ -32,14 +32,14 @@ namespace Nz return memoryRequirements; } - inline VkResult Image::CreateHelper(const DeviceHandle& device, const VkImageCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkImage* handle) + inline VkResult Image::CreateHelper(Device& device, const VkImageCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkImage* handle) { - return device->vkCreateImage(*device, createInfo, allocator, handle); + return device.vkCreateImage(device, createInfo, allocator, handle); } - inline void Image::DestroyHelper(const DeviceHandle& device, VkImage handle, const VkAllocationCallbacks* allocator) + inline void Image::DestroyHelper(Device& device, VkImage handle, const VkAllocationCallbacks* allocator) { - return device->vkDestroyImage(*device, handle, allocator); + return device.vkDestroyImage(device, handle, allocator); } } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/ImageView.hpp b/include/Nazara/VulkanRenderer/Wrapper/ImageView.hpp index 8e3b00031..957453774 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/ImageView.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/ImageView.hpp @@ -28,8 +28,8 @@ namespace Nz ImageView& operator=(ImageView&&) = delete; private: - static inline VkResult CreateHelper(const DeviceHandle& device, const VkImageViewCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkImageView* handle); - static inline void DestroyHelper(const DeviceHandle& device, VkImageView handle, const VkAllocationCallbacks* allocator); + static inline VkResult CreateHelper(Device& device, const VkImageViewCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkImageView* handle); + static inline void DestroyHelper(Device& device, VkImageView handle, const VkAllocationCallbacks* allocator); }; } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/ImageView.inl b/include/Nazara/VulkanRenderer/Wrapper/ImageView.inl index cf107865b..d49988586 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/ImageView.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/ImageView.inl @@ -9,14 +9,14 @@ namespace Nz { namespace Vk { - inline VkResult ImageView::CreateHelper(const DeviceHandle& device, const VkImageViewCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkImageView* handle) + inline VkResult ImageView::CreateHelper(Device& device, const VkImageViewCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkImageView* handle) { - return device->vkCreateImageView(*device, createInfo, allocator, handle); + return device.vkCreateImageView(device, createInfo, allocator, handle); } - inline void ImageView::DestroyHelper(const DeviceHandle& device, VkImageView handle, const VkAllocationCallbacks* allocator) + inline void ImageView::DestroyHelper(Device& device, VkImageView handle, const VkAllocationCallbacks* allocator) { - return device->vkDestroyImageView(*device, handle, allocator); + return device.vkDestroyImageView(device, handle, allocator); } } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp b/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp index 3a97e5b0b..5ce955bca 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp @@ -64,6 +64,9 @@ namespace Nz #undef NAZARA_VULKANRENDERER_INSTANCE_FUNCTION private: + inline void DestroyInstance(); + void ResetPointers(); + inline PFN_vkVoidFunction GetProcAddr(const char* name); VkAllocationCallbacks m_allocator; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Instance.inl b/include/Nazara/VulkanRenderer/Wrapper/Instance.inl index 646f3d4c9..309a01fb2 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Instance.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Instance.inl @@ -5,6 +5,7 @@ #include #include #include +#include #include namespace Nz @@ -18,7 +19,7 @@ namespace Nz inline Instance::~Instance() { - Destroy(); + DestroyInstance(); } 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) @@ -52,8 +53,8 @@ namespace Nz { if (m_instance) { - vkDestroyInstance(m_instance, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); - m_instance = nullptr; + DestroyInstance(); + ResetPointers(); } } @@ -135,6 +136,14 @@ namespace Nz return properties; } + inline void Instance::DestroyInstance() + { + assert(m_instance != VK_NULL_HANDLE); + + if (vkDestroyInstance) + vkDestroyInstance(m_instance, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); + } + inline PFN_vkVoidFunction Instance::GetProcAddr(const char* name) { PFN_vkVoidFunction func = Loader::GetInstanceProcAddr(m_instance, name); diff --git a/include/Nazara/VulkanRenderer/Wrapper/Pipeline.hpp b/include/Nazara/VulkanRenderer/Wrapper/Pipeline.hpp index e97a50509..d63abadac 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Pipeline.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Pipeline.hpp @@ -22,11 +22,11 @@ namespace Nz Pipeline(Pipeline&&); inline ~Pipeline(); - inline bool CreateCompute(const DeviceHandle& device, const VkComputePipelineCreateInfo& createInfo, VkPipelineCache cache = VK_NULL_HANDLE, const VkAllocationCallbacks* allocator = nullptr); - inline bool CreateGraphics(const DeviceHandle& device, const VkGraphicsPipelineCreateInfo& createInfo, VkPipelineCache cache = VK_NULL_HANDLE, const VkAllocationCallbacks* allocator = nullptr); + inline bool CreateCompute(Device& device, const VkComputePipelineCreateInfo& createInfo, VkPipelineCache cache = VK_NULL_HANDLE, const VkAllocationCallbacks* allocator = nullptr); + inline bool CreateGraphics(Device& device, const VkGraphicsPipelineCreateInfo& createInfo, VkPipelineCache cache = VK_NULL_HANDLE, const VkAllocationCallbacks* allocator = nullptr); inline void Destroy(); - inline const DeviceHandle& GetDevice() const; + inline Device& GetDevice() const; inline VkResult GetLastErrorCode() const; Pipeline& operator=(const Pipeline&) = delete; @@ -35,9 +35,9 @@ namespace Nz inline operator VkPipeline() const; protected: - inline bool Create(DeviceHandle device, VkResult result, const VkAllocationCallbacks* allocator); + inline bool Create(Device& device, VkResult result, const VkAllocationCallbacks* allocator); - DeviceHandle m_device; + MovablePtr m_device; VkAllocationCallbacks m_allocator; VkPipeline m_handle; mutable VkResult m_lastErrorCode; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Pipeline.inl b/include/Nazara/VulkanRenderer/Wrapper/Pipeline.inl index 010437000..e91fe8107 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Pipeline.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Pipeline.inl @@ -29,14 +29,14 @@ namespace Nz Destroy(); } - inline bool Pipeline::CreateCompute(const DeviceHandle& device, const VkComputePipelineCreateInfo& createInfo, VkPipelineCache cache, const VkAllocationCallbacks* allocator) + inline bool Pipeline::CreateCompute(Device& device, const VkComputePipelineCreateInfo& createInfo, VkPipelineCache cache, const VkAllocationCallbacks* allocator) { - return Create(std::move(device), device->vkCreateComputePipelines(*device, cache, 1U, &createInfo, allocator, &m_handle), allocator); + return Create(device, device.vkCreateComputePipelines(device, cache, 1U, &createInfo, allocator, &m_handle), allocator); } - inline bool Pipeline::CreateGraphics(const DeviceHandle& device, const VkGraphicsPipelineCreateInfo& createInfo, VkPipelineCache cache, const VkAllocationCallbacks* allocator) + inline bool Pipeline::CreateGraphics(Device& device, const VkGraphicsPipelineCreateInfo& createInfo, VkPipelineCache cache, const VkAllocationCallbacks* allocator) { - return Create(std::move(device), device->vkCreateGraphicsPipelines(*device, cache, 1U, &createInfo, allocator, &m_handle), allocator); + return Create(device, device.vkCreateGraphicsPipelines(device, cache, 1U, &createInfo, allocator, &m_handle), allocator); } inline void Pipeline::Destroy() @@ -48,9 +48,9 @@ namespace Nz } } - inline const DeviceHandle& Pipeline::GetDevice() const + inline Device& Pipeline::GetDevice() const { - return m_device; + return *m_device; } inline VkResult Pipeline::GetLastErrorCode() const @@ -63,9 +63,9 @@ namespace Nz return m_handle; } - inline bool Pipeline::Create(DeviceHandle device, VkResult result, const VkAllocationCallbacks* allocator) + inline bool Pipeline::Create(Device& device, VkResult result, const VkAllocationCallbacks* allocator) { - m_device = device; + m_device = &device; m_lastErrorCode = result; if (m_lastErrorCode != VkResult::VK_SUCCESS) { diff --git a/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.hpp b/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.hpp index 8fbd900eb..8c923c311 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.hpp @@ -28,8 +28,8 @@ namespace Nz PipelineCache& operator=(PipelineCache&&) = delete; private: - static inline VkResult CreateHelper(const DeviceHandle& device, const VkPipelineCacheCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkPipelineCache* handle); - static inline void DestroyHelper(const DeviceHandle& device, VkPipelineCache handle, const VkAllocationCallbacks* allocator); + static inline VkResult CreateHelper(Device& device, const VkPipelineCacheCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkPipelineCache* handle); + static inline void DestroyHelper(Device& device, VkPipelineCache handle, const VkAllocationCallbacks* allocator); }; } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.inl b/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.inl index a23d2c509..c16d8dbd8 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.inl @@ -9,14 +9,14 @@ namespace Nz { namespace Vk { - inline VkResult PipelineCache::CreateHelper(const DeviceHandle& device, const VkPipelineCacheCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkPipelineCache* handle) + inline VkResult PipelineCache::CreateHelper(Device& device, const VkPipelineCacheCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkPipelineCache* handle) { - return device->vkCreatePipelineCache(*device, createInfo, allocator, handle); + return device.vkCreatePipelineCache(device, createInfo, allocator, handle); } - inline void PipelineCache::DestroyHelper(const DeviceHandle& device, VkPipelineCache handle, const VkAllocationCallbacks* allocator) + inline void PipelineCache::DestroyHelper(Device& device, VkPipelineCache handle, const VkAllocationCallbacks* allocator) { - return device->vkDestroyPipelineCache(*device, handle, allocator); + return device.vkDestroyPipelineCache(device, handle, allocator); } } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp b/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp index 1a27d40a4..ad97ca925 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp @@ -25,15 +25,15 @@ namespace Nz ~PipelineLayout() = default; using DeviceObject::Create; - bool Create(DeviceHandle device, VkDescriptorSetLayout layout, VkPipelineLayoutCreateFlags flags = 0); - bool Create(DeviceHandle device, UInt32 layoutCount, const VkDescriptorSetLayout* layouts, VkPipelineLayoutCreateFlags flags = 0); + bool Create(Device& device, VkDescriptorSetLayout layout, VkPipelineLayoutCreateFlags flags = 0); + bool Create(Device& device, UInt32 layoutCount, const VkDescriptorSetLayout* layouts, VkPipelineLayoutCreateFlags flags = 0); PipelineLayout& operator=(const PipelineLayout&) = delete; PipelineLayout& operator=(PipelineLayout&&) = delete; private: - static inline VkResult CreateHelper(const DeviceHandle& device, const VkPipelineLayoutCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkPipelineLayout* handle); - static inline void DestroyHelper(const DeviceHandle& device, VkPipelineLayout handle, const VkAllocationCallbacks* allocator); + static inline VkResult CreateHelper(Device& device, const VkPipelineLayoutCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkPipelineLayout* handle); + static inline void DestroyHelper(Device& device, VkPipelineLayout handle, const VkAllocationCallbacks* allocator); }; } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.inl b/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.inl index 3f0f52df1..96e1c57ac 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.inl @@ -9,12 +9,12 @@ namespace Nz { namespace Vk { - inline bool PipelineLayout::Create(DeviceHandle device, VkDescriptorSetLayout layout, VkPipelineLayoutCreateFlags flags) + inline bool PipelineLayout::Create(Device& device, VkDescriptorSetLayout layout, VkPipelineLayoutCreateFlags flags) { - return Create(std::move(device), 1U, &layout, flags); + return Create(device, 1U, &layout, flags); } - inline bool PipelineLayout::Create(DeviceHandle device, UInt32 layoutCount, const VkDescriptorSetLayout* layouts, VkPipelineLayoutCreateFlags flags) + inline bool PipelineLayout::Create(Device& device, UInt32 layoutCount, const VkDescriptorSetLayout* layouts, VkPipelineLayoutCreateFlags flags) { VkPipelineLayoutCreateInfo createInfo = { VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, @@ -26,17 +26,17 @@ namespace Nz nullptr }; - return Create(std::move(device), createInfo); + return Create(device, createInfo); } - inline VkResult PipelineLayout::CreateHelper(const DeviceHandle& device, const VkPipelineLayoutCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkPipelineLayout* handle) + inline VkResult PipelineLayout::CreateHelper(Device& device, const VkPipelineLayoutCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkPipelineLayout* handle) { - return device->vkCreatePipelineLayout(*device, createInfo, allocator, handle); + return device.vkCreatePipelineLayout(device, createInfo, allocator, handle); } - inline void PipelineLayout::DestroyHelper(const DeviceHandle& device, VkPipelineLayout handle, const VkAllocationCallbacks* allocator) + inline void PipelineLayout::DestroyHelper(Device& device, VkPipelineLayout handle, const VkAllocationCallbacks* allocator) { - return device->vkDestroyPipelineLayout(*device, handle, allocator); + return device.vkDestroyPipelineLayout(device, handle, allocator); } } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/Queue.hpp b/include/Nazara/VulkanRenderer/Wrapper/Queue.hpp index 9256441e7..9de7e73e2 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Queue.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Queue.hpp @@ -19,12 +19,12 @@ namespace Nz { public: inline Queue(); - inline Queue(const DeviceHandle& device, VkQueue queue); + inline Queue(Device& device, VkQueue queue); inline Queue(const Queue& queue); inline Queue(Queue&& queue); inline ~Queue() = default; - inline const DeviceHandle& GetDevice() const; + inline Device& GetDevice() const; inline VkResult GetLastErrorCode() const; inline bool Present(const VkPresentInfoKHR& presentInfo) const; @@ -43,7 +43,7 @@ namespace Nz inline operator VkQueue(); protected: - DeviceHandle m_device; + Device* m_device; VkQueue m_handle; mutable VkResult m_lastErrorCode; }; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Queue.inl b/include/Nazara/VulkanRenderer/Wrapper/Queue.inl index c22e73ab4..96465e993 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Queue.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Queue.inl @@ -12,34 +12,21 @@ namespace Nz namespace Vk { inline Queue::Queue() : - Queue(DeviceHandle(), VK_NULL_HANDLE) + m_handle(VK_NULL_HANDLE), + m_lastErrorCode(VkResult::VK_SUCCESS) { } - inline Queue::Queue(const DeviceHandle& device, VkQueue queue) : - m_device(device), + 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 Device& Queue::GetDevice() const { - } - - inline Queue::Queue(Queue&& queue) : - m_device(queue.m_device), - m_handle(queue.m_handle), - m_lastErrorCode(queue.m_lastErrorCode) - { - } - - inline const DeviceHandle& Queue::GetDevice() const - { - return m_device; + return *m_device; } inline VkResult Queue::GetLastErrorCode() const diff --git a/include/Nazara/VulkanRenderer/Wrapper/RenderPass.hpp b/include/Nazara/VulkanRenderer/Wrapper/RenderPass.hpp index b5b6ef58d..de95bfcca 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/RenderPass.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/RenderPass.hpp @@ -28,8 +28,8 @@ namespace Nz RenderPass& operator=(RenderPass&&) = delete; private: - static inline VkResult CreateHelper(const DeviceHandle& device, const VkRenderPassCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkRenderPass* handle); - static inline void DestroyHelper(const DeviceHandle& device, VkRenderPass handle, const VkAllocationCallbacks* allocator); + static inline VkResult CreateHelper(Device& device, const VkRenderPassCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkRenderPass* handle); + static inline void DestroyHelper(Device& device, VkRenderPass handle, const VkAllocationCallbacks* allocator); }; } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/RenderPass.inl b/include/Nazara/VulkanRenderer/Wrapper/RenderPass.inl index 16b27c5e7..583dfa248 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/RenderPass.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/RenderPass.inl @@ -9,14 +9,14 @@ namespace Nz { namespace Vk { - inline VkResult RenderPass::CreateHelper(const DeviceHandle& device, const VkRenderPassCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkRenderPass* handle) + inline VkResult RenderPass::CreateHelper(Device& device, const VkRenderPassCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkRenderPass* handle) { - return device->vkCreateRenderPass(*device, createInfo, allocator, handle); + return device.vkCreateRenderPass(device, createInfo, allocator, handle); } - inline void RenderPass::DestroyHelper(const DeviceHandle& device, VkRenderPass handle, const VkAllocationCallbacks* allocator) + inline void RenderPass::DestroyHelper(Device& device, VkRenderPass handle, const VkAllocationCallbacks* allocator) { - return device->vkDestroyRenderPass(*device, handle, allocator); + return device.vkDestroyRenderPass(device, handle, allocator); } } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/Semaphore.hpp b/include/Nazara/VulkanRenderer/Wrapper/Semaphore.hpp index f8f1592bb..b42cd8c27 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Semaphore.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Semaphore.hpp @@ -25,14 +25,14 @@ namespace Nz ~Semaphore() = default; using DeviceObject::Create; - inline bool Create(DeviceHandle device, VkSemaphoreCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(Device& device, VkSemaphoreCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); Semaphore& operator=(const Semaphore&) = delete; Semaphore& operator=(Semaphore&&) = delete; private: - static inline VkResult CreateHelper(const DeviceHandle& device, const VkSemaphoreCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSemaphore* handle); - static inline void DestroyHelper(const DeviceHandle& device, VkSemaphore handle, const VkAllocationCallbacks* allocator); + static inline VkResult CreateHelper(Device& device, const VkSemaphoreCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSemaphore* handle); + static inline void DestroyHelper(Device& device, VkSemaphore handle, const VkAllocationCallbacks* allocator); }; } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/Semaphore.inl b/include/Nazara/VulkanRenderer/Wrapper/Semaphore.inl index 7a17c6d5e..334af2fe6 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Semaphore.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Semaphore.inl @@ -9,7 +9,7 @@ namespace Nz { namespace Vk { - inline bool Semaphore::Create(DeviceHandle device, VkSemaphoreCreateFlags flags, const VkAllocationCallbacks* allocator) + inline bool Semaphore::Create(Device& device, VkSemaphoreCreateFlags flags, const VkAllocationCallbacks* allocator) { VkSemaphoreCreateInfo createInfo = { @@ -18,17 +18,17 @@ namespace Nz flags }; - return Create(std::move(device), createInfo, allocator); + return Create(device, createInfo, allocator); } - inline VkResult Semaphore::CreateHelper(const DeviceHandle& device, const VkSemaphoreCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSemaphore* handle) + inline VkResult Semaphore::CreateHelper(Device& device, const VkSemaphoreCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSemaphore* handle) { - return device->vkCreateSemaphore(*device, createInfo, allocator, handle); + return device.vkCreateSemaphore(device, createInfo, allocator, handle); } - inline void Semaphore::DestroyHelper(const DeviceHandle& device, VkSemaphore handle, const VkAllocationCallbacks* allocator) + inline void Semaphore::DestroyHelper(Device& device, VkSemaphore handle, const VkAllocationCallbacks* allocator) { - return device->vkDestroySemaphore(*device, handle, allocator); + return device.vkDestroySemaphore(device, handle, allocator); } } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp b/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp index a815db5fd..caacaccea 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp @@ -25,14 +25,14 @@ namespace Nz ~ShaderModule() = default; using DeviceObject::Create; - inline bool Create(DeviceHandle device, const UInt32* code, std::size_t size, VkShaderModuleCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(Device& device, const UInt32* code, std::size_t size, VkShaderModuleCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); ShaderModule& operator=(const ShaderModule&) = delete; ShaderModule& operator=(ShaderModule&&) = delete; private: - static inline VkResult CreateHelper(const DeviceHandle& device, const VkShaderModuleCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkShaderModule* handle); - static inline void DestroyHelper(const DeviceHandle& device, VkShaderModule handle, const VkAllocationCallbacks* allocator); + static inline VkResult CreateHelper(Device& device, const VkShaderModuleCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkShaderModule* handle); + static inline void DestroyHelper(Device& device, VkShaderModule handle, const VkAllocationCallbacks* allocator); }; } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.inl b/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.inl index bce7a49b8..851e85916 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.inl @@ -9,7 +9,7 @@ namespace Nz { namespace Vk { - inline bool ShaderModule::Create(DeviceHandle device, const UInt32* code, std::size_t size, VkShaderModuleCreateFlags flags, const VkAllocationCallbacks* allocator) + inline bool ShaderModule::Create(Device& device, const UInt32* code, std::size_t size, VkShaderModuleCreateFlags flags, const VkAllocationCallbacks* allocator) { VkShaderModuleCreateInfo createInfo = { @@ -20,17 +20,17 @@ namespace Nz code }; - return Create(std::move(device), createInfo, allocator); + return Create(device, createInfo, allocator); } - inline VkResult ShaderModule::CreateHelper(const DeviceHandle& device, const VkShaderModuleCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkShaderModule* handle) + inline VkResult ShaderModule::CreateHelper(Device& device, const VkShaderModuleCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkShaderModule* handle) { - return device->vkCreateShaderModule(*device, createInfo, allocator, handle); + return device.vkCreateShaderModule(device, createInfo, allocator, handle); } - inline void ShaderModule::DestroyHelper(const DeviceHandle& device, VkShaderModule handle, const VkAllocationCallbacks* allocator) + inline void ShaderModule::DestroyHelper(Device& device, VkShaderModule handle, const VkAllocationCallbacks* allocator) { - return device->vkDestroyShaderModule(*device, handle, allocator); + return device.vkDestroyShaderModule(device, handle, allocator); } } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp b/include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp index 893f74913..d8d611585 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp @@ -29,7 +29,7 @@ namespace Nz inline bool AcquireNextImage(Nz::UInt64 timeout, VkSemaphore semaphore, VkFence fence, UInt32* imageIndex) const; - inline bool Create(DeviceHandle device, const VkSwapchainCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(Device& device, const VkSwapchainCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); inline const Buffer& GetBuffer(UInt32 index) const; inline const std::vector& GetBuffers() const; @@ -47,8 +47,8 @@ namespace Nz }; private: - static inline VkResult CreateHelper(const DeviceHandle& device, const VkSwapchainCreateInfoKHR* createInfo, const VkAllocationCallbacks* allocator, VkSwapchainKHR* handle); - static inline void DestroyHelper(const DeviceHandle& device, VkSwapchainKHR handle, const VkAllocationCallbacks* allocator); + static inline VkResult CreateHelper(Device& device, const VkSwapchainCreateInfoKHR* createInfo, const VkAllocationCallbacks* allocator, VkSwapchainKHR* handle); + static inline void DestroyHelper(Device& device, VkSwapchainKHR handle, const VkAllocationCallbacks* allocator); std::vector m_buffers; }; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Swapchain.inl b/include/Nazara/VulkanRenderer/Wrapper/Swapchain.inl index c0e146d40..fff7991d6 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Swapchain.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Swapchain.inl @@ -29,9 +29,9 @@ namespace Nz } } - inline bool Swapchain::Create(DeviceHandle device, const VkSwapchainCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) + inline bool Swapchain::Create(Device& device, const VkSwapchainCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator) { - if (!DeviceObject::Create(std::move(device), createInfo, allocator)) + if (!DeviceObject::Create(device, createInfo, allocator)) return false; UInt32 imageCount = 0; @@ -77,7 +77,7 @@ namespace Nz } }; - if (!m_buffers[i].view.Create(m_device, imageViewCreateInfo)) + if (!m_buffers[i].view.Create(*m_device, imageViewCreateInfo)) { NazaraError("Failed to create image view for image #" + String::Number(i)); return false; @@ -110,14 +110,14 @@ namespace Nz return true; } - inline VkResult Swapchain::CreateHelper(const DeviceHandle& device, const VkSwapchainCreateInfoKHR* createInfo, const VkAllocationCallbacks* allocator, VkSwapchainKHR* handle) + inline VkResult Swapchain::CreateHelper(Device& device, const VkSwapchainCreateInfoKHR* createInfo, const VkAllocationCallbacks* allocator, VkSwapchainKHR* handle) { - return device->vkCreateSwapchainKHR(*device, createInfo, allocator, handle); + return device.vkCreateSwapchainKHR(device, createInfo, allocator, handle); } - inline void Swapchain::DestroyHelper(const DeviceHandle& device, VkSwapchainKHR handle, const VkAllocationCallbacks* allocator) + inline void Swapchain::DestroyHelper(Device& device, VkSwapchainKHR handle, const VkAllocationCallbacks* allocator) { - return device->vkDestroySwapchainKHR(*device, handle, allocator); + return device.vkDestroySwapchainKHR(device, handle, allocator); } } } diff --git a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp index 08b9b651e..f1c367d6e 100644 --- a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp +++ b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -43,7 +44,7 @@ namespace Nz return true; } - bool VkRenderWindow::Create(RendererImpl* renderer, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) + bool VkRenderWindow::Create(RendererImpl* /*renderer*/, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) { m_physicalDevice = Vulkan::GetPhysicalDevices()[0].device; @@ -74,8 +75,6 @@ namespace Nz if (!parameters.depthFormats.empty()) { - const Vk::PhysicalDevice& deviceInfo = Vulkan::GetPhysicalDeviceInfo(m_physicalDevice); - for (PixelFormatType format : parameters.depthFormats) { switch (format) @@ -163,7 +162,7 @@ namespace Nz 1U // uint32_t layers; }; - if (!m_frameBuffers[i].Create(m_device, frameBufferCreate)) + if (!m_frameBuffers[i].Create(*m_device, frameBufferCreate)) { NazaraError("Failed to create framebuffer for image #" + String::Number(i)); return false; @@ -195,14 +194,14 @@ namespace Nz VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout; }; - if (!m_depthBuffer.Create(m_device, imageCreateInfo)) + if (!m_depthBuffer.Create(*m_device, imageCreateInfo)) { NazaraError("Failed to create depth buffer"); return false; } VkMemoryRequirements memoryReq = m_depthBuffer.GetMemoryRequirements(); - if (!m_depthBufferMemory.Create(m_device, memoryReq.size, memoryReq.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)) + if (!m_depthBufferMemory.Create(*m_device, memoryReq.size, memoryReq.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)) { NazaraError("Failed to allocate depth buffer memory"); return false; @@ -236,7 +235,7 @@ namespace Nz } }; - if (!m_depthBufferView.Create(m_device, imageViewCreateInfo)) + if (!m_depthBufferView.Create(*m_device, imageViewCreateInfo)) { NazaraError("Failed to create depth buffer view"); return false; @@ -330,7 +329,7 @@ namespace Nz dependencies.data() // const VkSubpassDependency* pDependencies; }; - return m_renderPass.Create(m_device, createInfo); + return m_renderPass.Create(*m_device, createInfo); } bool VkRenderWindow::SetupSwapchain(Vk::Surface& surface, const Vector2ui& size) @@ -395,7 +394,7 @@ namespace Nz 0 }; - if (!m_swapchain.Create(m_device, swapchainInfo)) + if (!m_swapchain.Create(*m_device, swapchainInfo)) { NazaraError("Failed to create swapchain"); return false; diff --git a/src/Nazara/VulkanRenderer/Vulkan.cpp b/src/Nazara/VulkanRenderer/Vulkan.cpp index 344f50103..cb211ad01 100644 --- a/src/Nazara/VulkanRenderer/Vulkan.cpp +++ b/src/Nazara/VulkanRenderer/Vulkan.cpp @@ -444,13 +444,7 @@ namespace Nz { for (auto it = s_devices.begin(); it != s_devices.end();) { - auto devicePtr = it->lock(); - if (!devicePtr) - { - it = s_devices.erase(it); - continue; - } - + const auto& devicePtr = *it; if (devicePtr->GetPhysicalDevice() == gpu) return devicePtr; } @@ -463,13 +457,7 @@ namespace Nz // First, try to find a device compatible with that surface for (auto it = s_devices.begin(); it != s_devices.end();) { - auto devicePtr = it->lock(); - if (!devicePtr) - { - it = s_devices.erase(it); - continue; - } - + const auto& devicePtr = *it; if (devicePtr->GetPhysicalDevice() == gpu) { const std::vector& queueFamilyInfo = devicePtr->GetEnabledQueues(); @@ -511,7 +499,7 @@ namespace Nz Vk::Loader::Uninitialize(); } - std::vector> Vulkan::s_devices; + std::vector> Vulkan::s_devices; std::vector Vulkan::s_physDevices; Vk::Instance Vulkan::s_instance; ParameterList Vulkan::s_initializationParameters; diff --git a/src/Nazara/VulkanRenderer/VulkanDevice.cpp b/src/Nazara/VulkanRenderer/VulkanDevice.cpp index f1c532846..252d7436b 100644 --- a/src/Nazara/VulkanRenderer/VulkanDevice.cpp +++ b/src/Nazara/VulkanRenderer/VulkanDevice.cpp @@ -12,20 +12,20 @@ namespace Nz { VulkanDevice::~VulkanDevice() = default; - std::unique_ptr VulkanDevice::InstantiateBuffer(Buffer* parent, BufferType type) + std::unique_ptr VulkanDevice::InstantiateBuffer(BufferType type) { - return std::make_unique(shared_from_this(), parent, type); + return std::make_unique(*this, type); } std::unique_ptr VulkanDevice::InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) { - return std::make_unique(shared_from_this(), std::move(pipelineInfo)); + return std::make_unique(*this, std::move(pipelineInfo)); } std::shared_ptr VulkanDevice::InstantiateRenderPipelineLayout(RenderPipelineLayoutInfo pipelineLayoutInfo) { auto pipelineLayout = std::make_shared(); - if (!pipelineLayout->Create(shared_from_this(), std::move(pipelineLayoutInfo))) + if (!pipelineLayout->Create(*this, std::move(pipelineLayoutInfo))) return {}; return pipelineLayout; @@ -34,7 +34,7 @@ namespace Nz std::shared_ptr VulkanDevice::InstantiateShaderStage(ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) { auto stage = std::make_shared(); - if (!stage->Create(shared_from_this(), type, lang, source, sourceSize)) + if (!stage->Create(*this, type, lang, source, sourceSize)) return {}; return stage; diff --git a/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp b/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp index 93a05ebcc..d7b790aec 100644 --- a/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp +++ b/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp @@ -12,8 +12,8 @@ namespace Nz { - VulkanRenderPipeline::VulkanRenderPipeline(Vk::DeviceHandle device, RenderPipelineInfo pipelineInfo) : - m_device(std::move(device)), + VulkanRenderPipeline::VulkanRenderPipeline(Vk::Device& device, RenderPipelineInfo pipelineInfo) : + m_device(&device), m_pipelineInfo(std::move(pipelineInfo)) { m_pipelineCreateInfo = BuildCreateInfo(m_pipelineInfo); @@ -29,7 +29,7 @@ namespace Nz pipelineCreateInfo.renderPass = renderPass; Vk::Pipeline newPipeline; - if (!newPipeline.CreateGraphics(m_device, pipelineCreateInfo)) + if (!newPipeline.CreateGraphics(*m_device, pipelineCreateInfo)) return VK_NULL_HANDLE; auto it = m_pipelines.emplace(renderPass, std::move(newPipeline)).first; diff --git a/src/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.cpp b/src/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.cpp index d509ff043..b8d4704de 100644 --- a/src/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.cpp +++ b/src/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.cpp @@ -12,9 +12,9 @@ namespace Nz { - bool VulkanRenderPipelineLayout::Create(Vk::DeviceHandle device, RenderPipelineLayoutInfo layoutInfo) + bool VulkanRenderPipelineLayout::Create(Vk::Device& device, RenderPipelineLayoutInfo layoutInfo) { - m_device = std::move(device); + m_device = &device; m_layoutInfo = std::move(layoutInfo); StackVector layoutBindings = NazaraStackVector(VkDescriptorSetLayoutBinding, m_layoutInfo.bindings.size()); @@ -28,10 +28,10 @@ namespace Nz layoutBinding.stageFlags = ToVulkan(bindingInfo.shaderStageFlags); } - if (!m_descriptorSetLayout.Create(m_device, layoutBindings.size(), layoutBindings.data())) + if (!m_descriptorSetLayout.Create(*m_device, UInt32(layoutBindings.size()), layoutBindings.data())) return false; - if (!m_pipelineLayout.Create(m_device, m_descriptorSetLayout)) + if (!m_pipelineLayout.Create(*m_device, m_descriptorSetLayout)) return false; return true; diff --git a/src/Nazara/VulkanRenderer/VulkanRenderer.cpp b/src/Nazara/VulkanRenderer/VulkanRenderer.cpp index 7e543c256..bfacf89bc 100644 --- a/src/Nazara/VulkanRenderer/VulkanRenderer.cpp +++ b/src/Nazara/VulkanRenderer/VulkanRenderer.cpp @@ -73,7 +73,7 @@ namespace Nz for (const Vk::PhysicalDevice& physDevice : m_physDevices) { - RenderDeviceInfo device; + RenderDeviceInfo& device = devices.emplace_back(); device.name = physDevice.properties.deviceName; switch (physDevice.properties.deviceType) @@ -100,8 +100,6 @@ namespace Nz device.type = RenderDeviceType::Unknown; break; } - - devices.emplace_back(std::move(device)); } return devices; diff --git a/src/Nazara/VulkanRenderer/VulkanShaderStage.cpp b/src/Nazara/VulkanRenderer/VulkanShaderStage.cpp index ea95dd0ac..238bb6468 100644 --- a/src/Nazara/VulkanRenderer/VulkanShaderStage.cpp +++ b/src/Nazara/VulkanRenderer/VulkanShaderStage.cpp @@ -7,7 +7,7 @@ namespace Nz { - bool VulkanShaderStage::Create(const Vk::DeviceHandle& device, ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) + bool VulkanShaderStage::Create(Vk::Device& device, ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) { if (lang != ShaderLanguage::SpirV) { diff --git a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp index 8f15e73ba..65aa4c463 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include #include #include @@ -12,6 +13,28 @@ namespace Nz { namespace Vk { + Device::Device(Instance& instance) : + m_instance(instance), + m_physicalDevice(nullptr), + m_device(VK_NULL_HANDLE) + { + } + + Device::~Device() + { + if (m_device != VK_NULL_HANDLE) + WaitAndDestroyDevice(); + } + + void Device::Destroy() + { + if (m_device != VK_NULL_HANDLE) + { + WaitAndDestroyDevice(); + ResetPointers(); + } + } + bool Device::Create(const Vk::PhysicalDevice& deviceInfo, const VkDeviceCreateInfo& createInfo, const VkAllocationCallbacks* allocator) { m_lastErrorCode = m_instance.vkCreateDevice(deviceInfo.device, &createInfo, allocator, &m_device); @@ -21,6 +44,8 @@ namespace Nz return false; } + CallOnExit destroyOnFailure([this] { Destroy(); }); + m_physicalDevice = &deviceInfo; // Store the allocator to access them when needed @@ -53,7 +78,7 @@ namespace Nz } catch (const std::exception& e) { - NazaraError(String("Failed to query device function: ") + e.what()); + NazaraError(std::string("Failed to query device function: ") + e.what()); return false; } @@ -88,6 +113,8 @@ namespace Nz for (const QueueFamilyInfo& familyInfo : m_enabledQueuesInfos) m_queuesByFamily[familyInfo.familyIndex] = &familyInfo.queues; + destroyOnFailure.Reset(); + return true; } @@ -96,8 +123,37 @@ namespace Nz VkQueue queue; vkGetDeviceQueue(m_device, queueFamilyIndex, queueIndex, &queue); - return Queue(shared_from_this(), queue); + return Queue(*this, queue); } + void Device::WaitAndDestroyDevice() + { + assert(m_device != VK_NULL_HANDLE); + + if (vkDeviceWaitIdle) + vkDeviceWaitIdle(m_device); + + m_internalData.reset(); + + if (vkDestroyDevice) + vkDestroyDevice(m_device, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); + } + + void Device::ResetPointers() + { + m_device = VK_NULL_HANDLE; + m_physicalDevice = nullptr; + + // Reset functions pointers +#define NAZARA_VULKANRENDERER_DEVICE_EXT_BEGIN(ext) +#define NAZARA_VULKANRENDERER_DEVICE_EXT_END() +#define NAZARA_VULKANRENDERER_DEVICE_FUNCTION(func) func = nullptr; + +#include + +#undef NAZARA_VULKANRENDERER_DEVICE_EXT_BEGIN +#undef NAZARA_VULKANRENDERER_DEVICE_EXT_END +#undef NAZARA_VULKANRENDERER_DEVICE_FUNCTION + } } } diff --git a/src/Nazara/VulkanRenderer/Wrapper/Instance.cpp b/src/Nazara/VulkanRenderer/Wrapper/Instance.cpp index c46028b15..e7b0330d7 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/Instance.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Instance.cpp @@ -103,5 +103,20 @@ namespace Nz return true; } + void Instance::ResetPointers() + { + assert(m_instance != VK_NULL_HANDLE); + m_instance = VK_NULL_HANDLE; + +#define NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(ext) +#define NAZARA_VULKANRENDERER_INSTANCE_EXT_END() +#define NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(func) func = nullptr; + +#include + +#undef NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN +#undef NAZARA_VULKANRENDERER_INSTANCE_EXT_END +#undef NAZARA_VULKANRENDERER_INSTANCE_FUNCTION + } } } From b774a879b684800892667eb6e79ce63f868090dc Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 13 Mar 2020 18:44:49 +0100 Subject: [PATCH 113/316] Rework buffers synchronization --- examples/VulkanTest/main.cpp | 34 +++--- include/Nazara/Renderer/RenderDevice.hpp | 3 +- include/Nazara/Utility/Enums.hpp | 6 +- include/Nazara/VulkanRenderer/Utils.hpp | 4 +- include/Nazara/VulkanRenderer/Utils.inl | 13 ++ .../Nazara/VulkanRenderer/VulkanBuffer.hpp | 16 +-- .../Nazara/VulkanRenderer/VulkanBuffer.inl | 5 +- .../Nazara/VulkanRenderer/VulkanDevice.hpp | 2 +- .../VulkanRenderer/Wrapper/CommandBuffer.hpp | 2 + .../VulkanRenderer/Wrapper/CommandBuffer.inl | 10 ++ .../Nazara/VulkanRenderer/Wrapper/Device.hpp | 9 ++ .../Nazara/VulkanRenderer/Wrapper/Device.inl | 5 + .../VulkanRenderer/Wrapper/DeviceMemory.hpp | 3 + .../VulkanRenderer/Wrapper/DeviceMemory.inl | 25 ++++ src/Nazara/Renderer/RenderBuffer.cpp | 2 +- src/Nazara/Utility/Formats/MD5MeshLoader.cpp | 2 +- .../VulkanRenderer/Utils_VulkanRenderer.cpp | 4 +- src/Nazara/VulkanRenderer/VulkanBuffer.cpp | 114 +++++++++++++----- src/Nazara/VulkanRenderer/Wrapper/Device.cpp | 32 +++++ 19 files changed, 223 insertions(+), 68 deletions(-) diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index 34333abb5..e8b9a7478 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -130,9 +130,6 @@ int main() Nz::UInt32 uniformSize = sizeof(ubo); - Nz::UniformBuffer uniformBuffer(uniformSize, Nz::DataStorage_Hardware, Nz::BufferUsage_Dynamic); - uniformBuffer.Fill(&ubo, 0, uniformSize); - Nz::RenderPipelineLayoutInfo pipelineLayoutInfo; auto& bindingInfo = pipelineLayoutInfo.bindings.emplace_back(); bindingInfo.index = 0; @@ -162,13 +159,14 @@ int main() Nz::Vk::DescriptorSet descriptorSet = descriptorPool.AllocateDescriptorSet(descriptorLayout); - Nz::RenderBuffer* renderBufferUB = static_cast(uniformBuffer.GetBuffer()->GetImpl()); - if (!renderBufferUB->Synchronize(&vulkanDevice)) + std::unique_ptr uniformBuffer = device->InstantiateBuffer(Nz::BufferType_Uniform); + if (!uniformBuffer->Initialize(uniformSize, Nz::BufferUsage_DeviceLocal)) { NazaraError("Failed to create uniform buffer"); return __LINE__; } - Nz::VulkanBuffer* uniformBufferImpl = static_cast(renderBufferUB->GetHardwareBuffer(&vulkanDevice)); + + Nz::VulkanBuffer* uniformBufferImpl = static_cast(uniformBuffer.get()); descriptorSet.WriteUniformDescriptor(0, uniformBufferImpl->GetBufferHandle(), 0, uniformSize); Nz::RenderPipelineInfo pipelineInfo; @@ -353,18 +351,6 @@ int main() } } - if (updateUniforms) - { - ubo.viewMatrix = Nz::Matrix4f::ViewMatrix(viewerPos, camAngles); - - uniformBuffer.Fill(&ubo, 0, uniformSize); - if (!renderBufferUB->Synchronize(&vulkanDevice)) - { - NazaraError("Failed to synchronize render buffer"); - return __LINE__; - } - } - ImageSync& syncPrimitives = frameSync[currentFrame]; syncPrimitives.inflightFence.Wait(); @@ -381,6 +367,18 @@ int main() inflightFences[imageIndex] = &syncPrimitives.inflightFence; inflightFences[imageIndex]->Reset(); + if (updateUniforms) + { + ubo.viewMatrix = Nz::Matrix4f::ViewMatrix(viewerPos, camAngles); + + void* mappedPtr = uniformBufferImpl->Map(Nz::BufferAccess_DiscardAndWrite, 0, sizeof(ubo)); + if (mappedPtr) + { + std::memcpy(mappedPtr, &ubo, sizeof(ubo)); + uniformBufferImpl->Unmap(); + } + } + if (!graphicsQueue.Submit(renderCmds[imageIndex], syncPrimitives.imageAvailableSemaphore, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, syncPrimitives.renderFinishedSemaphore, syncPrimitives.inflightFence)) return false; diff --git a/include/Nazara/Renderer/RenderDevice.hpp b/include/Nazara/Renderer/RenderDevice.hpp index 739471ea4..daf74ca2e 100644 --- a/include/Nazara/Renderer/RenderDevice.hpp +++ b/include/Nazara/Renderer/RenderDevice.hpp @@ -18,7 +18,6 @@ namespace Nz { - class Buffer; class ShaderStageImpl; class NAZARA_RENDERER_API RenderDevice @@ -27,7 +26,7 @@ namespace Nz RenderDevice() = default; virtual ~RenderDevice(); - virtual std::unique_ptr InstantiateBuffer(Buffer* parent, BufferType type) = 0; + virtual std::unique_ptr InstantiateBuffer(BufferType type) = 0; virtual std::unique_ptr InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) = 0; virtual std::shared_ptr InstantiateRenderPipelineLayout(RenderPipelineLayoutInfo pipelineLayoutInfo) = 0; virtual std::shared_ptr InstantiateShaderStage(ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) = 0; diff --git a/include/Nazara/Utility/Enums.hpp b/include/Nazara/Utility/Enums.hpp index 70c64e527..bc958a07a 100644 --- a/include/Nazara/Utility/Enums.hpp +++ b/include/Nazara/Utility/Enums.hpp @@ -56,10 +56,10 @@ namespace Nz enum BufferUsage { - BufferUsage_Dynamic, - BufferUsage_FastRead, + BufferUsage_DeviceLocal, + BufferUsage_DirectMapping, - BufferUsage_Max = BufferUsage_FastRead + BufferUsage_Max = BufferUsage_DirectMapping }; template<> diff --git a/include/Nazara/VulkanRenderer/Utils.hpp b/include/Nazara/VulkanRenderer/Utils.hpp index 71c0af4c4..3d772abca 100644 --- a/include/Nazara/VulkanRenderer/Utils.hpp +++ b/include/Nazara/VulkanRenderer/Utils.hpp @@ -12,9 +12,11 @@ #include #include #include +#include namespace Nz { + inline VkBufferUsageFlags ToVulkan(BufferType bufferType); inline VkFormat ToVulkan(ComponentType componentType); inline VkCullModeFlagBits ToVulkan(FaceSide faceSide); inline VkPolygonMode ToVulkan(FaceFilling faceFilling); @@ -26,7 +28,7 @@ namespace Nz inline VkStencilOp ToVulkan(StencilOperation stencilOp); inline VkVertexInputRate ToVulkan(VertexInputRate inputRate); - NAZARA_VULKANRENDERER_API String TranslateVulkanError(VkResult code); + NAZARA_VULKANRENDERER_API std::string TranslateVulkanError(VkResult code); } #include diff --git a/include/Nazara/VulkanRenderer/Utils.inl b/include/Nazara/VulkanRenderer/Utils.inl index 4c9b5616d..aa0f18d38 100644 --- a/include/Nazara/VulkanRenderer/Utils.inl +++ b/include/Nazara/VulkanRenderer/Utils.inl @@ -10,6 +10,19 @@ namespace Nz { + VkBufferUsageFlags ToVulkan(BufferType bufferType) + { + switch (bufferType) + { + case BufferType_Index: return VK_BUFFER_USAGE_INDEX_BUFFER_BIT; + case BufferType_Vertex: return VK_BUFFER_USAGE_VERTEX_BUFFER_BIT; + case BufferType_Uniform: return VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; + } + + NazaraError("Unhandled BufferType 0x" + String::Number(bufferType, 16)); + return 0; + } + VkFormat ToVulkan(ComponentType componentType) { switch (componentType) diff --git a/include/Nazara/VulkanRenderer/VulkanBuffer.hpp b/include/Nazara/VulkanRenderer/VulkanBuffer.hpp index 52adcf253..190277143 100644 --- a/include/Nazara/VulkanRenderer/VulkanBuffer.hpp +++ b/include/Nazara/VulkanRenderer/VulkanBuffer.hpp @@ -18,12 +18,10 @@ namespace Nz { - class Buffer; - class NAZARA_VULKANRENDERER_API VulkanBuffer : public AbstractBuffer { public: - inline VulkanBuffer(Vk::Device& device, Buffer* parent, BufferType type); + inline VulkanBuffer(Vk::Device& device, BufferType type); VulkanBuffer(const VulkanBuffer&) = delete; VulkanBuffer(VulkanBuffer&&) = delete; ///TODO virtual ~VulkanBuffer(); @@ -35,18 +33,22 @@ namespace Nz DataStorage GetStorage() const override; - void* Map(BufferAccess access, UInt32 offset = 0, UInt32 size = 0) override; + void* Map(BufferAccess access, UInt32 offset, UInt32 size) override; bool Unmap() override; VulkanBuffer& operator=(const VulkanBuffer&) = delete; VulkanBuffer& operator=(VulkanBuffer&&) = delete; ///TODO private: - Buffer* m_parent; + Vk::Buffer m_stagingBuffer; + Vk::DeviceMemory m_stagingMemory; BufferType m_type; - Nz::Vk::Buffer m_buffer; - Nz::Vk::DeviceMemory m_memory; + BufferUsageFlags m_usage; + UInt32 m_size; + Vk::Buffer m_buffer; + Vk::Fence m_stagingFence; Vk::Device& m_device; + Vk::DeviceMemory m_memory; }; } diff --git a/include/Nazara/VulkanRenderer/VulkanBuffer.inl b/include/Nazara/VulkanRenderer/VulkanBuffer.inl index 2e210c149..41eef8918 100644 --- a/include/Nazara/VulkanRenderer/VulkanBuffer.inl +++ b/include/Nazara/VulkanRenderer/VulkanBuffer.inl @@ -7,14 +7,13 @@ namespace Nz { - inline VulkanBuffer::VulkanBuffer(Vk::Device& device, Buffer* /*parent*/, BufferType type) : + inline VulkanBuffer::VulkanBuffer(Vk::Device& device, BufferType type) : m_device(device), - m_parent(parent), m_type(type) { } - inline Nz::Vk::Buffer& Nz::VulkanBuffer::GetBufferHandle() + inline Vk::Buffer& VulkanBuffer::GetBufferHandle() { return m_buffer; } diff --git a/include/Nazara/VulkanRenderer/VulkanDevice.hpp b/include/Nazara/VulkanRenderer/VulkanDevice.hpp index 7fe07729a..fb4a11c79 100644 --- a/include/Nazara/VulkanRenderer/VulkanDevice.hpp +++ b/include/Nazara/VulkanRenderer/VulkanDevice.hpp @@ -23,7 +23,7 @@ namespace Nz VulkanDevice(VulkanDevice&&) = delete; ///TODO? ~VulkanDevice(); - std::unique_ptr InstantiateBuffer(Buffer* parent, BufferType type) override; + std::unique_ptr InstantiateBuffer(BufferType type) override; std::unique_ptr InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) override; std::shared_ptr InstantiateRenderPipelineLayout(RenderPipelineLayoutInfo pipelineLayoutInfo) override; std::shared_ptr InstantiateShaderStage(ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) override; diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp index 3191f76eb..80ff5b7f4 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp @@ -51,6 +51,8 @@ namespace Nz inline void ClearDepthStencilImage(VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue& depthStencil, const VkImageSubresourceRange& range); inline void ClearDepthStencilImage(VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue& depthStencil, UInt32 rangeCount, const VkImageSubresourceRange* ranges); + inline void CopyBuffer(VkBuffer source, VkBuffer target, UInt32 size, UInt32 sourceOffset = 0, UInt32 targetOffset = 0); + inline void Draw(UInt32 vertexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0); inline void DrawIndexed(UInt32 indexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, Int32 vertexOffset = 0, UInt32 firstInstance = 0); diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl index 93255ad58..bd2c4ce76 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl @@ -194,6 +194,16 @@ namespace Nz return m_pool->GetDevice()->vkCmdClearDepthStencilImage(m_handle, image, imageLayout, &depthStencil, rangeCount, ranges); } + inline void CommandBuffer::CopyBuffer(VkBuffer source, VkBuffer target, UInt32 size, UInt32 sourceOffset, UInt32 targetOffset) + { + VkBufferCopy region; + region.dstOffset = targetOffset; + region.size = size; + region.srcOffset = sourceOffset; + + return m_pool->GetDevice()->vkCmdCopyBuffer(m_handle, source, target, 1, ®ion); + } + inline void CommandBuffer::Draw(UInt32 vertexCount, UInt32 instanceCount, UInt32 firstVertex, UInt32 firstInstance) { return m_pool->GetDevice()->vkCmdDraw(m_handle, vertexCount, instanceCount, firstVertex, firstInstance); diff --git a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp index b2a4cf70b..d7a5a3fce 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp @@ -19,6 +19,7 @@ namespace Nz { namespace Vk { + class CommandBuffer; class Instance; class Queue; @@ -34,6 +35,8 @@ namespace Nz Device(Device&&) = delete; ~Device(); + CommandBuffer AllocateTransferCommandBuffer(); + bool Create(const Vk::PhysicalDevice& deviceInfo, const VkDeviceCreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); inline void Destroy(); @@ -47,6 +50,8 @@ namespace Nz inline VkPhysicalDevice GetPhysicalDevice() const; inline const Vk::PhysicalDevice& GetPhysicalDeviceInfo() const; + inline UInt32 GetTransferQueueFamilyIndex() const; + inline bool IsExtensionLoaded(const std::string& extensionName); inline bool IsLayerLoaded(const std::string& layerName); @@ -90,11 +95,15 @@ namespace Nz inline PFN_vkVoidFunction GetProcAddr(const char* name); + struct InternalData; + + std::unique_ptr m_internalData; Instance& m_instance; const Vk::PhysicalDevice* m_physicalDevice; VkAllocationCallbacks m_allocator; VkDevice m_device; VkResult m_lastErrorCode; + UInt32 m_transferQueueFamilyIndex; std::unordered_set m_loadedExtensions; std::unordered_set m_loadedLayers; std::vector m_enabledQueuesInfos; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Device.inl b/include/Nazara/VulkanRenderer/Wrapper/Device.inl index e3a069745..1d44e193d 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Device.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Device.inl @@ -49,6 +49,11 @@ namespace Nz return *m_physicalDevice; } + inline UInt32 Device::GetTransferQueueFamilyIndex() const + { + return m_transferQueueFamilyIndex; + } + inline bool Device::IsExtensionLoaded(const std::string& extensionName) { return m_loadedExtensions.count(extensionName) > 0; diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp b/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp index 8b2d57ada..c6ec63832 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp @@ -28,6 +28,9 @@ namespace Nz inline bool Create(Device& device, VkDeviceSize size, UInt32 memoryType, const VkAllocationCallbacks* allocator = nullptr); inline bool Create(Device& device, VkDeviceSize size, UInt32 typeBits, VkFlags properties, const VkAllocationCallbacks* allocator = nullptr); + inline bool FlushMemory(); + inline bool FlushMemory(UInt64 offset, UInt64 size); + inline void* GetMappedPointer(); inline bool Map(VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags = 0); diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.inl b/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.inl index 65fd619d4..a764fbbdb 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.inl @@ -57,6 +57,31 @@ namespace Nz return false; } + inline bool DeviceMemory::FlushMemory() + { + return FlushMemory(0, VK_WHOLE_SIZE); + } + + inline bool DeviceMemory::FlushMemory(UInt64 offset, UInt64 size) + { + VkMappedMemoryRange memoryRange = { + VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, + nullptr, + m_handle, + offset, + size + }; + + m_lastErrorCode = m_device->vkFlushMappedMemoryRanges(*m_device, 1, &memoryRange); + if (m_lastErrorCode != VK_SUCCESS) + { + NazaraError("Failed to flush memory: " + TranslateVulkanError(m_lastErrorCode)); + return false; + } + + return true; + } + inline void* DeviceMemory::GetMappedPointer() { return m_mappedPtr; diff --git a/src/Nazara/Renderer/RenderBuffer.cpp b/src/Nazara/Renderer/RenderBuffer.cpp index 470faf839..c8de03340 100644 --- a/src/Nazara/Renderer/RenderBuffer.cpp +++ b/src/Nazara/Renderer/RenderBuffer.cpp @@ -70,7 +70,7 @@ namespace Nz if (it == m_hardwareBuffers.end()) { HardwareBuffer hwBuffer; - hwBuffer.buffer = device->InstantiateBuffer(m_parent, m_type); + hwBuffer.buffer = device->InstantiateBuffer(m_type); if (!hwBuffer.buffer->Initialize(m_size, m_usage)) { NazaraError("Failed to initialize hardware buffer"); diff --git a/src/Nazara/Utility/Formats/MD5MeshLoader.cpp b/src/Nazara/Utility/Formats/MD5MeshLoader.cpp index 8894a7682..18f6c028e 100644 --- a/src/Nazara/Utility/Formats/MD5MeshLoader.cpp +++ b/src/Nazara/Utility/Formats/MD5MeshLoader.cpp @@ -97,7 +97,7 @@ namespace Nz bool largeIndices = (vertexCount > std::numeric_limits::max()); IndexBufferRef indexBuffer = IndexBuffer::New(largeIndices, UInt32(indexCount), parameters.storage, parameters.indexBufferFlags); - VertexBufferRef vertexBuffer = VertexBuffer::New(VertexDeclaration::Get(VertexLayout_XYZ_Normal_UV_Tangent_Skinning), UInt32(vertexCount), parameters.storage, parameters.vertexBufferFlags | BufferUsage_Dynamic); + VertexBufferRef vertexBuffer = VertexBuffer::New(VertexDeclaration::Get(VertexLayout_XYZ_Normal_UV_Tangent_Skinning), UInt32(vertexCount), parameters.storage, parameters.vertexBufferFlags); // Index buffer IndexMapper indexMapper(indexBuffer, BufferAccess_DiscardAndWrite); diff --git a/src/Nazara/VulkanRenderer/Utils_VulkanRenderer.cpp b/src/Nazara/VulkanRenderer/Utils_VulkanRenderer.cpp index a21630c9b..b1e29a6e4 100644 --- a/src/Nazara/VulkanRenderer/Utils_VulkanRenderer.cpp +++ b/src/Nazara/VulkanRenderer/Utils_VulkanRenderer.cpp @@ -7,7 +7,7 @@ namespace Nz { - String TranslateVulkanError(VkResult code) + std::string TranslateVulkanError(VkResult code) { // From https://www.khronos.org/registry/vulkan/specs/1.0-wsi_extensions/xhtml/vkspec.html#VkResult switch (code) @@ -97,7 +97,7 @@ namespace Nz break; } - return "Unknown Vulkan error (0x" + String::Number(code, 16) + ')'; + return "Unknown Vulkan error (0x" + String::Number(code, 16).ToStdString() + ')'; } } diff --git a/src/Nazara/VulkanRenderer/VulkanBuffer.cpp b/src/Nazara/VulkanRenderer/VulkanBuffer.cpp index 14944d9fc..c22bb9dc6 100644 --- a/src/Nazara/VulkanRenderer/VulkanBuffer.cpp +++ b/src/Nazara/VulkanRenderer/VulkanBuffer.cpp @@ -5,6 +5,8 @@ #include #include #include +#include +#include #include namespace Nz @@ -26,37 +28,30 @@ namespace Nz bool VulkanBuffer::Initialize(UInt32 size, BufferUsageFlags usage) { - VkBufferUsageFlags type; - switch (m_type) + m_size = size; + m_usage = usage; + + VkBufferUsageFlags bufferUsage = ToVulkan(m_type); + VkMemoryPropertyFlags memoryProperties = 0; + if (usage & BufferUsage_DeviceLocal) + memoryProperties |= VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; + + if (usage & BufferUsage_DirectMapping) + memoryProperties |= VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; + else + bufferUsage |= VK_BUFFER_USAGE_TRANSFER_DST_BIT; + + if (!m_buffer.Create(m_device, 0, size, bufferUsage)) { - case BufferType_Index: - type = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; - break; - - case BufferType_Vertex: - type = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT; - break; - - case BufferType_Uniform: - type = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; - break; - - default: - NazaraError("Unhandled buffer usage 0x" + String::Number(m_type, 16)); - return false; - } - - if (!m_buffer.Create(m_device, 0, size, type)) - { - NazaraError("Failed to create vertex buffer"); + NazaraError("Failed to create vulkan buffer"); return false; } VkMemoryRequirements memRequirement = m_buffer.GetMemoryRequirements(); - if (!m_memory.Create(m_device, memRequirement.size, memRequirement.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) + if (!m_memory.Create(m_device, memRequirement.size, memRequirement.memoryTypeBits, memoryProperties)) { - NazaraError("Failed to allocate vertex buffer memory"); + NazaraError("Failed to allocate buffer memory"); return false; } @@ -76,15 +71,76 @@ namespace Nz void* VulkanBuffer::Map(BufferAccess /*access*/, UInt32 offset, UInt32 size) { - if (!m_memory.Map(offset, size)) - return nullptr; + if (m_usage & BufferUsage_DirectMapping) + { + if (!m_memory.Map(offset, size)) + return nullptr; - return m_memory.GetMappedPointer(); + return m_memory.GetMappedPointer(); + } + else + { + if (!m_stagingFence.Create(m_device)) + { + NazaraError("Failed to create staging fence"); + return nullptr; + } + + if (!m_stagingBuffer.Create(m_device, 0, m_size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT)) + { + NazaraError("Failed to create staging buffer"); + return nullptr; + } + + VkMemoryPropertyFlags memoryProperties = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; + + VkMemoryRequirements memRequirement = m_stagingBuffer.GetMemoryRequirements(); + if (!m_stagingMemory.Create(m_device, memRequirement.size, memRequirement.memoryTypeBits, memoryProperties)) + { + NazaraError("Failed to allocate vertex buffer memory"); + return nullptr; + } + + if (!m_stagingBuffer.BindBufferMemory(m_stagingMemory)) + { + NazaraError("Failed to bind vertex buffer to its memory"); + return nullptr; + } + + if (!m_stagingMemory.Map(offset, size)) + return nullptr; + + return m_stagingMemory.GetMappedPointer(); + } } bool VulkanBuffer::Unmap() { - m_memory.Unmap(); - return true; + if (m_usage & BufferUsage_DirectMapping) + { + m_memory.Unmap(); + return true; + } + else + { + m_stagingMemory.FlushMemory(); + m_stagingMemory.Unmap(); + + Vk::CommandBuffer copyCommandBuffer = m_device.AllocateTransferCommandBuffer(); + copyCommandBuffer.Begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT); + copyCommandBuffer.CopyBuffer(m_stagingBuffer, m_buffer, m_size); + copyCommandBuffer.End(); + + Vk::Queue transferQueue = m_device.GetQueue(m_device.GetTransferQueueFamilyIndex(), 0); + if (!transferQueue.Submit(copyCommandBuffer, VK_NULL_HANDLE, 0, VK_NULL_HANDLE, m_stagingFence)) + return false; + + m_stagingFence.Wait(); + + m_stagingBuffer.Destroy(); + m_stagingFence.Destroy(); + m_stagingMemory.Destroy(); + return true; + } } } diff --git a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp index 65aa4c463..3105ae1a8 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp @@ -6,6 +6,8 @@ #include #include #include +#include +#include #include #include @@ -13,6 +15,11 @@ namespace Nz { namespace Vk { + struct Device::InternalData + { + Vk::CommandPool transferCommandPool; + }; + Device::Device(Instance& instance) : m_instance(instance), m_physicalDevice(nullptr), @@ -26,6 +33,11 @@ namespace Nz WaitAndDestroyDevice(); } + CommandBuffer Device::AllocateTransferCommandBuffer() + { + return m_internalData->transferCommandPool.AllocateCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY); + } + void Device::Destroy() { if (m_device != VK_NULL_HANDLE) @@ -83,6 +95,8 @@ namespace Nz } // And retains informations about queues + m_transferQueueFamilyIndex = UINT32_MAX; + UInt32 maxFamilyIndex = 0; m_enabledQueuesInfos.resize(createInfo.queueCreateInfoCount); for (UInt32 i = 0; i < createInfo.queueCreateInfoCount; ++i) @@ -107,12 +121,30 @@ namespace Nz queueInfo.priority = queueCreateInfo.pQueuePriorities[queueIndex]; vkGetDeviceQueue(m_device, info.familyIndex, queueIndex, &queueInfo.queue); } + + if (info.flags & (VK_QUEUE_TRANSFER_BIT | VK_QUEUE_COMPUTE_BIT | VK_QUEUE_GRAPHICS_BIT)) + { + if (m_transferQueueFamilyIndex == UINT32_MAX) + m_transferQueueFamilyIndex = info.familyIndex; + else if ((info.flags & (VK_QUEUE_COMPUTE_BIT | VK_QUEUE_GRAPHICS_BIT)) == 0) + { + m_transferQueueFamilyIndex = info.familyIndex; + break; + } + } } m_queuesByFamily.resize(maxFamilyIndex + 1); for (const QueueFamilyInfo& familyInfo : m_enabledQueuesInfos) m_queuesByFamily[familyInfo.familyIndex] = &familyInfo.queues; + m_internalData = std::make_unique(); + if (!m_internalData->transferCommandPool.Create(*this, m_transferQueueFamilyIndex, VK_COMMAND_POOL_CREATE_TRANSIENT_BIT)) + { + NazaraError("Failed to create transfer command pool: " + TranslateVulkanError(m_internalData->transferCommandPool.GetLastErrorCode())); + return false; + } + destroyOnFailure.Reset(); return true; From 0ace9a5e8d165c97901b357ada45089766f48068 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 13 Mar 2020 18:45:56 +0100 Subject: [PATCH 114/316] Fix instance destruction --- include/Nazara/VulkanRenderer/Wrapper/Instance.inl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/Nazara/VulkanRenderer/Wrapper/Instance.inl b/include/Nazara/VulkanRenderer/Wrapper/Instance.inl index 309a01fb2..50feca010 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Instance.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Instance.inl @@ -19,7 +19,8 @@ namespace Nz inline Instance::~Instance() { - DestroyInstance(); + if (m_instance) + DestroyInstance(); } 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) From cee47f366fcbd29857e02ec5755c5b03c930385c Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 14 Mar 2020 17:33:50 +0100 Subject: [PATCH 115/316] Rename Vk::Queue to Vk::QueueHandle --- .../Nazara/VulkanRenderer/VkRenderWindow.hpp | 4 +- include/Nazara/VulkanRenderer/Wrapper.hpp | 2 +- .../Nazara/VulkanRenderer/Wrapper/Device.hpp | 4 +- .../Wrapper/{Queue.hpp => QueueHandle.hpp} | 22 +++++----- .../Wrapper/{Queue.inl => QueueHandle.inl} | 43 ++++++++----------- src/Nazara/VulkanRenderer/VulkanBuffer.cpp | 4 +- src/Nazara/VulkanRenderer/Wrapper/Device.cpp | 24 ++++++++--- 7 files changed, 54 insertions(+), 49 deletions(-) rename include/Nazara/VulkanRenderer/Wrapper/{Queue.hpp => QueueHandle.hpp} (66%) rename include/Nazara/VulkanRenderer/Wrapper/{Queue.inl => QueueHandle.inl} (60%) diff --git a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp index e19abc909..2914dcacb 100644 --- a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp +++ b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include @@ -70,7 +70,7 @@ namespace Nz Vk::DeviceMemory m_depthBufferMemory; Vk::Image m_depthBuffer; Vk::ImageView m_depthBufferView; - Vk::Queue m_presentQueue; + Vk::QueueHandle m_presentQueue; Vk::Swapchain m_swapchain; UInt32 m_presentableFamilyQueue; }; diff --git a/include/Nazara/VulkanRenderer/Wrapper.hpp b/include/Nazara/VulkanRenderer/Wrapper.hpp index 84f8cd991..8f360d652 100644 --- a/include/Nazara/VulkanRenderer/Wrapper.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper.hpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp index d7a5a3fce..3d6211057 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp @@ -21,7 +21,7 @@ namespace Nz { class CommandBuffer; class Instance; - class Queue; + class QueueHandle; class NAZARA_VULKANRENDERER_API Device : public std::enable_shared_from_this { @@ -43,7 +43,7 @@ namespace Nz inline const std::vector& GetEnabledQueues() const; inline const QueueList& GetEnabledQueues(UInt32 familyQueue) const; - Queue GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex); + QueueHandle GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex); inline Instance& GetInstance(); inline const Instance& GetInstance() const; inline VkResult GetLastErrorCode() const; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Queue.hpp b/include/Nazara/VulkanRenderer/Wrapper/QueueHandle.hpp similarity index 66% rename from include/Nazara/VulkanRenderer/Wrapper/Queue.hpp rename to include/Nazara/VulkanRenderer/Wrapper/QueueHandle.hpp index 9de7e73e2..4fcd9c3bf 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Queue.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/QueueHandle.hpp @@ -8,6 +8,7 @@ #define NAZARA_VULKANRENDERER_VKQUEUE_HPP #include +#include #include #include @@ -15,14 +16,14 @@ namespace Nz { namespace Vk { - class Queue + class QueueHandle { public: - inline Queue(); - inline Queue(Device& device, VkQueue queue); - inline Queue(const Queue& queue); - inline Queue(Queue&& queue); - inline ~Queue() = default; + inline QueueHandle(); + inline QueueHandle(Device& device, VkQueue queue); + QueueHandle(const QueueHandle& queue) = delete; + QueueHandle(QueueHandle&& queue) noexcept = default; + ~QueueHandle() = default; inline Device& GetDevice() const; inline VkResult GetLastErrorCode() const; @@ -32,24 +33,25 @@ namespace Nz inline bool Submit(VkCommandBuffer commandBuffer, VkSemaphore waitSemaphore, VkPipelineStageFlags waitStage, VkSemaphore signalSemaphore, VkFence signalFence = VK_NULL_HANDLE) const; inline bool Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, VkSemaphore waitSemaphore, VkPipelineStageFlags waitStage, VkSemaphore signalSemaphore, VkFence signalFence = VK_NULL_HANDLE) const; + inline bool Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, UInt32 waitSemaphoreCount, const VkSemaphore* waitSemaphores, VkPipelineStageFlags waitStage, UInt32 signalSemaphoreCount, const VkSemaphore* signalSemaphores, VkFence signalFence = VK_NULL_HANDLE) const; inline bool Submit(const VkSubmitInfo& submit, VkFence signalFence = VK_NULL_HANDLE) const; inline bool Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence signalFence = VK_NULL_HANDLE) const; inline bool WaitIdle() const; - Queue& operator=(const Queue& queue) = delete; - inline Queue& operator=(Queue&&); + QueueHandle& operator=(const QueueHandle& queue) = delete; + QueueHandle& operator=(QueueHandle&&) noexcept = default; inline operator VkQueue(); protected: - Device* m_device; + MovablePtr m_device; VkQueue m_handle; mutable VkResult m_lastErrorCode; }; } } -#include +#include #endif // NAZARA_VULKANRENDERER_VKQUEUE_HPP diff --git a/include/Nazara/VulkanRenderer/Wrapper/Queue.inl b/include/Nazara/VulkanRenderer/Wrapper/QueueHandle.inl similarity index 60% rename from include/Nazara/VulkanRenderer/Wrapper/Queue.inl rename to include/Nazara/VulkanRenderer/Wrapper/QueueHandle.inl index 96465e993..c43eb2fe7 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Queue.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/QueueHandle.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include #include #include @@ -11,30 +11,30 @@ namespace Nz { namespace Vk { - inline Queue::Queue() : + inline QueueHandle::QueueHandle() : m_handle(VK_NULL_HANDLE), m_lastErrorCode(VkResult::VK_SUCCESS) { } - inline Queue::Queue(Device& device, VkQueue queue) : + inline QueueHandle::QueueHandle(Device& device, VkQueue queue) : m_device(&device), m_handle(queue), m_lastErrorCode(VkResult::VK_SUCCESS) { } - inline Device& Queue::GetDevice() const + inline Device& QueueHandle::GetDevice() const { return *m_device; } - inline VkResult Queue::GetLastErrorCode() const + inline VkResult QueueHandle::GetLastErrorCode() const { return m_lastErrorCode; } - inline bool Queue::Present(const VkPresentInfoKHR& presentInfo) const + inline bool QueueHandle::Present(const VkPresentInfoKHR& presentInfo) const { m_lastErrorCode = m_device->vkQueuePresentKHR(m_handle, &presentInfo); if (m_lastErrorCode != VkResult::VK_SUCCESS) @@ -46,7 +46,7 @@ namespace Nz return true; } - inline bool Queue::Present(VkSwapchainKHR swapchain, UInt32 imageIndex, VkSemaphore waitSemaphore) const + inline bool QueueHandle::Present(VkSwapchainKHR swapchain, UInt32 imageIndex, VkSemaphore waitSemaphore) const { VkPresentInfoKHR presentInfo = { @@ -63,34 +63,34 @@ namespace Nz return Present(presentInfo); } - inline bool Queue::Submit(VkCommandBuffer commandBuffer, VkSemaphore waitSemaphore, VkPipelineStageFlags waitStage, VkSemaphore signalSemaphore, VkFence signalFence) const + inline bool QueueHandle::Submit(VkCommandBuffer commandBuffer, VkSemaphore waitSemaphore, VkPipelineStageFlags waitStage, VkSemaphore signalSemaphore, VkFence signalFence) const { return Submit(1U, &commandBuffer, waitSemaphore, waitStage, signalSemaphore, signalFence); } - inline bool Queue::Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, VkSemaphore waitSemaphore, VkPipelineStageFlags waitStage, VkSemaphore signalSemaphore, VkFence signalFence) const + inline bool QueueHandle::Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, UInt32 waitSemaphoreCount, const VkSemaphore* waitSemaphores, VkPipelineStageFlags waitStage, UInt32 signalSemaphoreCount, const VkSemaphore* signalSemaphores, VkFence signalFence) const { VkSubmitInfo submitInfo = { VK_STRUCTURE_TYPE_SUBMIT_INFO, nullptr, - (waitSemaphore) ? 1U : 0U, - &waitSemaphore, + waitSemaphoreCount, + waitSemaphores, &waitStage, commandBufferCount, commandBuffers, - (signalSemaphore) ? 1U : 0U, - &signalSemaphore + signalSemaphoreCount, + signalSemaphores }; return Submit(submitInfo, signalFence); } - inline bool Queue::Submit(const VkSubmitInfo& submit, VkFence signalFence) const + inline bool QueueHandle::Submit(const VkSubmitInfo& submit, VkFence signalFence) const { return Submit(1, &submit, signalFence); } - inline bool Queue::Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence signalFence) const + inline bool QueueHandle::Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence signalFence) const { m_lastErrorCode = m_device->vkQueueSubmit(m_handle, submitCount, submits, signalFence); if (m_lastErrorCode != VkResult::VK_SUCCESS) @@ -102,7 +102,7 @@ namespace Nz return true; } - inline bool Queue::WaitIdle() const + inline bool QueueHandle::WaitIdle() const { m_lastErrorCode = m_device->vkQueueWaitIdle(m_handle); if (m_lastErrorCode != VkResult::VK_SUCCESS) @@ -114,16 +114,7 @@ namespace Nz return true; } - inline Queue& Queue::operator=(Queue&& queue) - { - m_device = std::move(queue.m_device); - m_handle = queue.m_handle; - m_lastErrorCode = queue.m_lastErrorCode; - - return *this; - } - - inline Queue::operator VkQueue() + inline QueueHandle::operator VkQueue() { return m_handle; } diff --git a/src/Nazara/VulkanRenderer/VulkanBuffer.cpp b/src/Nazara/VulkanRenderer/VulkanBuffer.cpp index c22bb9dc6..d1d047245 100644 --- a/src/Nazara/VulkanRenderer/VulkanBuffer.cpp +++ b/src/Nazara/VulkanRenderer/VulkanBuffer.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include namespace Nz @@ -131,7 +131,7 @@ namespace Nz copyCommandBuffer.CopyBuffer(m_stagingBuffer, m_buffer, m_size); copyCommandBuffer.End(); - Vk::Queue transferQueue = m_device.GetQueue(m_device.GetTransferQueueFamilyIndex(), 0); + Vk::QueueHandle transferQueue = m_device.GetQueue(m_device.GetTransferQueueFamilyIndex(), 0); if (!transferQueue.Submit(copyCommandBuffer, VK_NULL_HANDLE, 0, VK_NULL_HANDLE, m_stagingFence)) return false; diff --git a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp index 3105ae1a8..6fadbf1ae 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include namespace Nz @@ -150,25 +150,24 @@ namespace Nz return true; } - Queue Device::GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex) { - VkQueue queue; - vkGetDeviceQueue(m_device, queueFamilyIndex, queueIndex, &queue); - - return Queue(*this, queue); } void Device::WaitAndDestroyDevice() + QueueHandle Device::GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex) { assert(m_device != VK_NULL_HANDLE); if (vkDeviceWaitIdle) vkDeviceWaitIdle(m_device); + const auto& queues = GetEnabledQueues(queueFamilyIndex); + NazaraAssert(queueIndex < queues.size(), "Invalid queue index"); m_internalData.reset(); if (vkDestroyDevice) vkDestroyDevice(m_device, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); + return QueueHandle(*this, queues[queueIndex].queue); } void Device::ResetPointers() @@ -187,5 +186,18 @@ namespace Nz #undef NAZARA_VULKANRENDERER_DEVICE_EXT_END #undef NAZARA_VULKANRENDERER_DEVICE_FUNCTION } + + void Device::WaitAndDestroyDevice() + { + assert(m_device != VK_NULL_HANDLE); + + if (vkDeviceWaitIdle) + vkDeviceWaitIdle(m_device); + + m_internalData.reset(); + + if (vkDestroyDevice) + vkDestroyDevice(m_device, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); + } } } From 74adef0aec48d9c6b08d9f3302ec4a865dc6ad46 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 14 Mar 2020 17:34:21 +0100 Subject: [PATCH 116/316] OCD fix --- .../Nazara/VulkanRenderer/Wrapper/Device.hpp | 2 +- src/Nazara/VulkanRenderer/Wrapper/Device.cpp | 24 +++++-------------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp index 3d6211057..6de35f597 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp @@ -90,8 +90,8 @@ namespace Nz }; private: - void WaitAndDestroyDevice(); void ResetPointers(); + void WaitAndDestroyDevice(); inline PFN_vkVoidFunction GetProcAddr(const char* name); diff --git a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp index 6fadbf1ae..a795dd7de 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp @@ -38,15 +38,6 @@ namespace Nz return m_internalData->transferCommandPool.AllocateCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY); } - void Device::Destroy() - { - if (m_device != VK_NULL_HANDLE) - { - WaitAndDestroyDevice(); - ResetPointers(); - } - } - bool Device::Create(const Vk::PhysicalDevice& deviceInfo, const VkDeviceCreateInfo& createInfo, const VkAllocationCallbacks* allocator) { m_lastErrorCode = m_instance.vkCreateDevice(deviceInfo.device, &createInfo, allocator, &m_device); @@ -150,23 +141,20 @@ namespace Nz return true; } + void Device::Destroy() { + if (m_device != VK_NULL_HANDLE) + { + WaitAndDestroyDevice(); + ResetPointers(); + } } - void Device::WaitAndDestroyDevice() QueueHandle Device::GetQueue(UInt32 queueFamilyIndex, UInt32 queueIndex) { - assert(m_device != VK_NULL_HANDLE); - - if (vkDeviceWaitIdle) - vkDeviceWaitIdle(m_device); const auto& queues = GetEnabledQueues(queueFamilyIndex); NazaraAssert(queueIndex < queues.size(), "Invalid queue index"); - m_internalData.reset(); - - if (vkDestroyDevice) - vkDestroyDevice(m_device, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); return QueueHandle(*this, queues[queueIndex].queue); } From 91c05abd19f739b4710165bb62126202512e4059 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 14 Mar 2020 17:34:40 +0100 Subject: [PATCH 117/316] Define VK_NO_PROTOTYPES to prevent accidental usage of free Vulkan functions --- build/scripts/tools/vulkanrenderer.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/scripts/tools/vulkanrenderer.lua b/build/scripts/tools/vulkanrenderer.lua index 8ecca1f2b..6e6a5bed2 100644 --- a/build/scripts/tools/vulkanrenderer.lua +++ b/build/scripts/tools/vulkanrenderer.lua @@ -7,7 +7,8 @@ TOOL.TargetDirectory = "../lib" TOOL.Defines = { "NAZARA_BUILD", - "NAZARA_VULKANRENDERER_BUILD" + "NAZARA_VULKANRENDERER_BUILD", + "VK_NO_PROTOTYPES" } TOOL.Includes = { From 7cce08ecfd7d6cfe16c38ce73a67e47488d4c822 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 14 Mar 2020 17:35:03 +0100 Subject: [PATCH 118/316] VulkanRenderer/QueueHandle: Add overloads able to take multiple wait/signal semaphores --- .../VulkanRenderer/Wrapper/QueueHandle.hpp | 2 ++ .../VulkanRenderer/Wrapper/QueueHandle.inl | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/include/Nazara/VulkanRenderer/Wrapper/QueueHandle.hpp b/include/Nazara/VulkanRenderer/Wrapper/QueueHandle.hpp index 4fcd9c3bf..8f19639c5 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/QueueHandle.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/QueueHandle.hpp @@ -32,6 +32,8 @@ namespace Nz inline bool Present(VkSwapchainKHR swapchain, UInt32 imageIndex, VkSemaphore waitSemaphore = VK_NULL_HANDLE) const; inline bool Submit(VkCommandBuffer commandBuffer, VkSemaphore waitSemaphore, VkPipelineStageFlags waitStage, VkSemaphore signalSemaphore, VkFence signalFence = VK_NULL_HANDLE) const; + inline bool Submit(VkCommandBuffer commandBuffer, std::initializer_list waitSemaphores, VkPipelineStageFlags waitStage, std::initializer_list signalSemaphores, VkFence signalFence = VK_NULL_HANDLE) const; + inline bool Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, std::initializer_list waitSemaphores, VkPipelineStageFlags waitStage, std::initializer_list signalSemaphores, VkFence signalFence = VK_NULL_HANDLE) const; inline bool Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, VkSemaphore waitSemaphore, VkPipelineStageFlags waitStage, VkSemaphore signalSemaphore, VkFence signalFence = VK_NULL_HANDLE) const; inline bool Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, UInt32 waitSemaphoreCount, const VkSemaphore* waitSemaphores, VkPipelineStageFlags waitStage, UInt32 signalSemaphoreCount, const VkSemaphore* signalSemaphores, VkFence signalFence = VK_NULL_HANDLE) const; inline bool Submit(const VkSubmitInfo& submit, VkFence signalFence = VK_NULL_HANDLE) const; diff --git a/include/Nazara/VulkanRenderer/Wrapper/QueueHandle.inl b/include/Nazara/VulkanRenderer/Wrapper/QueueHandle.inl index c43eb2fe7..96bc080d0 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/QueueHandle.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/QueueHandle.inl @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -68,6 +69,34 @@ namespace Nz return Submit(1U, &commandBuffer, waitSemaphore, waitStage, signalSemaphore, signalFence); } + inline bool QueueHandle::Submit(VkCommandBuffer commandBuffer, std::initializer_list waitSemaphores, VkPipelineStageFlags waitStage, std::initializer_list signalSemaphores, VkFence signalFence) const + { + return Submit(1U, &commandBuffer, waitSemaphores, waitStage, signalSemaphores, signalFence); + } + + inline bool QueueHandle::Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, std::initializer_list waitSemaphores, VkPipelineStageFlags waitStage, std::initializer_list signalSemaphores, VkFence signalFence) const + { + // Make continuous array of semaphores (initializer_list doesn't have that guarantee) + StackArray signalSemaphoresCont = NazaraStackArrayNoInit(VkSemaphore, signalSemaphores.size()); + StackArray waitSemaphoresCont = NazaraStackArrayNoInit(VkSemaphore, waitSemaphores.size()); + std::size_t i; + + i = 0; + for (VkSemaphore semaphore : signalSemaphores) + signalSemaphoresCont[i++] = semaphore; + + i = 0; + for (VkSemaphore semaphore : waitSemaphores) + waitSemaphoresCont[i++] = semaphore; + + return Submit(commandBufferCount, commandBuffers, UInt32(waitSemaphoresCont.size()), waitSemaphoresCont.data(), waitStage, UInt32(signalSemaphoresCont.size()), signalSemaphoresCont.data(), signalFence); + } + + inline bool QueueHandle::Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, VkSemaphore waitSemaphore, VkPipelineStageFlags waitStage, VkSemaphore signalSemaphore, VkFence signalFence) const + { + return Submit(commandBufferCount, commandBuffers, (waitSemaphore) ? 1U : 0U, &waitSemaphore, waitStage, (signalSemaphore) ? 1U : 0U, &signalSemaphore, signalFence); + } + inline bool QueueHandle::Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, UInt32 waitSemaphoreCount, const VkSemaphore* waitSemaphores, VkPipelineStageFlags waitStage, UInt32 signalSemaphoreCount, const VkSemaphore* signalSemaphores, VkFence signalFence) const { VkSubmitInfo submitInfo = { From 8d0a2cb70cd97020722087571c0dac94e70952d9 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 14 Mar 2020 18:10:50 +0100 Subject: [PATCH 119/316] Fix example --- examples/VulkanTest/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index e8b9a7478..d85a2c85c 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -196,7 +196,7 @@ int main() clearValues[0].color = {1.0f, 0.8f, 0.4f, 0.0f}; clearValues[1].depthStencil = {1.f, 0}; - Nz::Vk::Queue graphicsQueue(vulkanDevice, vulkanDevice.GetEnabledQueues()[0].queues[0].queue); + Nz::Vk::QueueHandle graphicsQueue = vulkanDevice.GetQueue(0, 0); Nz::UInt32 imageCount = vulkanWindow.GetFramebufferCount(); std::vector renderCmds = cmdPool.AllocateCommandBuffers(imageCount, VK_COMMAND_BUFFER_LEVEL_PRIMARY); From 6fd1f70a6d093b967ab0b2fe0c591b86c5a29e8a Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 15 Mar 2020 13:26:20 +0100 Subject: [PATCH 120/316] QueueHandle: Fix submit overloads --- .../VulkanRenderer/Wrapper/QueueHandle.hpp | 7 +++--- .../VulkanRenderer/Wrapper/QueueHandle.inl | 24 ++++++++++++++----- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/include/Nazara/VulkanRenderer/Wrapper/QueueHandle.hpp b/include/Nazara/VulkanRenderer/Wrapper/QueueHandle.hpp index 8f19639c5..d34649164 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/QueueHandle.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/QueueHandle.hpp @@ -31,11 +31,12 @@ namespace Nz inline bool Present(const VkPresentInfoKHR& presentInfo) const; inline bool Present(VkSwapchainKHR swapchain, UInt32 imageIndex, VkSemaphore waitSemaphore = VK_NULL_HANDLE) const; + inline bool Submit(VkCommandBuffer commandBuffer, VkFence signalFence = VK_NULL_HANDLE) const; inline bool Submit(VkCommandBuffer commandBuffer, VkSemaphore waitSemaphore, VkPipelineStageFlags waitStage, VkSemaphore signalSemaphore, VkFence signalFence = VK_NULL_HANDLE) const; - inline bool Submit(VkCommandBuffer commandBuffer, std::initializer_list waitSemaphores, VkPipelineStageFlags waitStage, std::initializer_list signalSemaphores, VkFence signalFence = VK_NULL_HANDLE) const; - inline bool Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, std::initializer_list waitSemaphores, VkPipelineStageFlags waitStage, std::initializer_list signalSemaphores, VkFence signalFence = VK_NULL_HANDLE) const; + inline bool Submit(VkCommandBuffer commandBuffer, std::initializer_list waitSemaphores, std::initializer_list waitStages, std::initializer_list signalSemaphores, VkFence signalFence = VK_NULL_HANDLE) const; + inline bool Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, std::initializer_list waitSemaphores, std::initializer_list waitStages, std::initializer_list signalSemaphores, VkFence signalFence = VK_NULL_HANDLE) const; inline bool Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, VkSemaphore waitSemaphore, VkPipelineStageFlags waitStage, VkSemaphore signalSemaphore, VkFence signalFence = VK_NULL_HANDLE) const; - inline bool Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, UInt32 waitSemaphoreCount, const VkSemaphore* waitSemaphores, VkPipelineStageFlags waitStage, UInt32 signalSemaphoreCount, const VkSemaphore* signalSemaphores, VkFence signalFence = VK_NULL_HANDLE) const; + inline bool Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, UInt32 waitSemaphoreCount, const VkSemaphore* waitSemaphores, const VkPipelineStageFlags* waitStage, UInt32 signalSemaphoreCount, const VkSemaphore* signalSemaphores, VkFence signalFence = VK_NULL_HANDLE) const; inline bool Submit(const VkSubmitInfo& submit, VkFence signalFence = VK_NULL_HANDLE) const; inline bool Submit(UInt32 submitCount, const VkSubmitInfo* submits, VkFence signalFence = VK_NULL_HANDLE) const; diff --git a/include/Nazara/VulkanRenderer/Wrapper/QueueHandle.inl b/include/Nazara/VulkanRenderer/Wrapper/QueueHandle.inl index 96bc080d0..20ee10c4e 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/QueueHandle.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/QueueHandle.inl @@ -64,21 +64,29 @@ namespace Nz return Present(presentInfo); } + inline bool QueueHandle::Submit(VkCommandBuffer commandBuffer, VkFence signalFence) const + { + return Submit(1U, &commandBuffer, VK_NULL_HANDLE, 0, VK_NULL_HANDLE, signalFence); + } + inline bool QueueHandle::Submit(VkCommandBuffer commandBuffer, VkSemaphore waitSemaphore, VkPipelineStageFlags waitStage, VkSemaphore signalSemaphore, VkFence signalFence) const { return Submit(1U, &commandBuffer, waitSemaphore, waitStage, signalSemaphore, signalFence); } - inline bool QueueHandle::Submit(VkCommandBuffer commandBuffer, std::initializer_list waitSemaphores, VkPipelineStageFlags waitStage, std::initializer_list signalSemaphores, VkFence signalFence) const + inline bool QueueHandle::Submit(VkCommandBuffer commandBuffer, std::initializer_list waitSemaphores, std::initializer_list waitStage, std::initializer_list signalSemaphores, VkFence signalFence) const { return Submit(1U, &commandBuffer, waitSemaphores, waitStage, signalSemaphores, signalFence); } - inline bool QueueHandle::Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, std::initializer_list waitSemaphores, VkPipelineStageFlags waitStage, std::initializer_list signalSemaphores, VkFence signalFence) const + inline bool QueueHandle::Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, std::initializer_list waitSemaphores, std::initializer_list waitStages, std::initializer_list signalSemaphores, VkFence signalFence) const { + NazaraAssert(waitSemaphores.size() == waitStages.size(), "Wait stage count must match wait semaphores count"); + // Make continuous array of semaphores (initializer_list doesn't have that guarantee) StackArray signalSemaphoresCont = NazaraStackArrayNoInit(VkSemaphore, signalSemaphores.size()); StackArray waitSemaphoresCont = NazaraStackArrayNoInit(VkSemaphore, waitSemaphores.size()); + StackArray waitStageCont = NazaraStackArrayNoInit(VkPipelineStageFlags, waitStages.size()); std::size_t i; i = 0; @@ -89,22 +97,26 @@ namespace Nz for (VkSemaphore semaphore : waitSemaphores) waitSemaphoresCont[i++] = semaphore; - return Submit(commandBufferCount, commandBuffers, UInt32(waitSemaphoresCont.size()), waitSemaphoresCont.data(), waitStage, UInt32(signalSemaphoresCont.size()), signalSemaphoresCont.data(), signalFence); + i = 0; + for (VkPipelineStageFlags flags : waitStages) + waitStageCont[i++] = flags; + + return Submit(commandBufferCount, commandBuffers, UInt32(waitSemaphoresCont.size()), waitSemaphoresCont.data(), waitStageCont.data(), UInt32(signalSemaphoresCont.size()), signalSemaphoresCont.data(), signalFence); } inline bool QueueHandle::Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, VkSemaphore waitSemaphore, VkPipelineStageFlags waitStage, VkSemaphore signalSemaphore, VkFence signalFence) const { - return Submit(commandBufferCount, commandBuffers, (waitSemaphore) ? 1U : 0U, &waitSemaphore, waitStage, (signalSemaphore) ? 1U : 0U, &signalSemaphore, signalFence); + return Submit(commandBufferCount, commandBuffers, (waitSemaphore) ? 1U : 0U, &waitSemaphore, &waitStage, (signalSemaphore) ? 1U : 0U, &signalSemaphore, signalFence); } - inline bool QueueHandle::Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, UInt32 waitSemaphoreCount, const VkSemaphore* waitSemaphores, VkPipelineStageFlags waitStage, UInt32 signalSemaphoreCount, const VkSemaphore* signalSemaphores, VkFence signalFence) const + inline bool QueueHandle::Submit(UInt32 commandBufferCount, const VkCommandBuffer* commandBuffers, UInt32 waitSemaphoreCount, const VkSemaphore* waitSemaphores, const VkPipelineStageFlags* waitStages, UInt32 signalSemaphoreCount, const VkSemaphore* signalSemaphores, VkFence signalFence) const { VkSubmitInfo submitInfo = { VK_STRUCTURE_TYPE_SUBMIT_INFO, nullptr, waitSemaphoreCount, waitSemaphores, - &waitStage, + waitStages, commandBufferCount, commandBuffers, signalSemaphoreCount, From 5fde1e335b2d1f1f44a2081deb0c788a65cb7487 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 15 Mar 2020 13:26:36 +0100 Subject: [PATCH 121/316] VulkanBuffer: Use WaitIdle instead of a fence (same effect) --- .../Nazara/VulkanRenderer/VulkanBuffer.hpp | 1 - src/Nazara/VulkanRenderer/VulkanBuffer.cpp | 24 ++++++++----------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/include/Nazara/VulkanRenderer/VulkanBuffer.hpp b/include/Nazara/VulkanRenderer/VulkanBuffer.hpp index 190277143..71f8365df 100644 --- a/include/Nazara/VulkanRenderer/VulkanBuffer.hpp +++ b/include/Nazara/VulkanRenderer/VulkanBuffer.hpp @@ -46,7 +46,6 @@ namespace Nz BufferUsageFlags m_usage; UInt32 m_size; Vk::Buffer m_buffer; - Vk::Fence m_stagingFence; Vk::Device& m_device; Vk::DeviceMemory m_memory; }; diff --git a/src/Nazara/VulkanRenderer/VulkanBuffer.cpp b/src/Nazara/VulkanRenderer/VulkanBuffer.cpp index d1d047245..3bfc3f615 100644 --- a/src/Nazara/VulkanRenderer/VulkanBuffer.cpp +++ b/src/Nazara/VulkanRenderer/VulkanBuffer.cpp @@ -80,12 +80,6 @@ namespace Nz } else { - if (!m_stagingFence.Create(m_device)) - { - NazaraError("Failed to create staging fence"); - return nullptr; - } - if (!m_stagingBuffer.Create(m_device, 0, m_size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT)) { NazaraError("Failed to create staging buffer"); @@ -127,18 +121,20 @@ namespace Nz m_stagingMemory.Unmap(); Vk::CommandBuffer copyCommandBuffer = m_device.AllocateTransferCommandBuffer(); - copyCommandBuffer.Begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT); - copyCommandBuffer.CopyBuffer(m_stagingBuffer, m_buffer, m_size); - copyCommandBuffer.End(); - - Vk::QueueHandle transferQueue = m_device.GetQueue(m_device.GetTransferQueueFamilyIndex(), 0); - if (!transferQueue.Submit(copyCommandBuffer, VK_NULL_HANDLE, 0, VK_NULL_HANDLE, m_stagingFence)) + if (!copyCommandBuffer.Begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT)) return false; - m_stagingFence.Wait(); + copyCommandBuffer.CopyBuffer(m_stagingBuffer, m_buffer, m_size); + if (!copyCommandBuffer.End()) + return false; + + Vk::QueueHandle transferQueue = m_device.GetQueue(m_device.GetTransferQueueFamilyIndex(), 0); + if (!transferQueue.Submit(copyCommandBuffer)) + return false; + + transferQueue.WaitIdle(); m_stagingBuffer.Destroy(); - m_stagingFence.Destroy(); m_stagingMemory.Destroy(); return true; } From adf1233ef2444da361b6eb97fd34e84c5edefc6c Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 15 Mar 2020 17:48:14 +0100 Subject: [PATCH 122/316] Add BaseWidget::ShowChildren --- SDK/include/NDK/BaseWidget.hpp | 3 +++ SDK/include/NDK/BaseWidget.inl | 5 +++++ SDK/src/NDK/BaseWidget.cpp | 9 +++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/SDK/include/NDK/BaseWidget.hpp b/SDK/include/NDK/BaseWidget.hpp index 8bdd15584..917747e17 100644 --- a/SDK/include/NDK/BaseWidget.hpp +++ b/SDK/include/NDK/BaseWidget.hpp @@ -75,6 +75,7 @@ namespace Ndk bool HasFocus() const; + inline void Hide(); inline bool IsVisible() const; void Resize(const Nz::Vector2f& size); @@ -128,6 +129,8 @@ namespace Ndk inline void SetPreferredSize(const Nz::Vector2f& preferredSize); + virtual void ShowChildren(bool show); + private: inline BaseWidget(); diff --git a/SDK/include/NDK/BaseWidget.inl b/SDK/include/NDK/BaseWidget.inl index edff81436..fc8e1f710 100644 --- a/SDK/include/NDK/BaseWidget.inl +++ b/SDK/include/NDK/BaseWidget.inl @@ -172,6 +172,11 @@ namespace Ndk return m_children.size(); } + inline void BaseWidget::Hide() + { + return Show(false); + } + inline bool BaseWidget::IsVisible() const { return m_visible; diff --git a/SDK/src/NDK/BaseWidget.cpp b/SDK/src/NDK/BaseWidget.cpp index cb643dc0c..83decf372 100644 --- a/SDK/src/NDK/BaseWidget.cpp +++ b/SDK/src/NDK/BaseWidget.cpp @@ -188,8 +188,7 @@ namespace Ndk } } - for (const auto& widgetPtr : m_children) - widgetPtr->Show(show); + ShowChildren(show); } } @@ -313,6 +312,12 @@ namespace Ndk { } + void BaseWidget::ShowChildren(bool show) + { + for (const auto& widgetPtr : m_children) + widgetPtr->Show(show); + } + void BaseWidget::DestroyChild(BaseWidget* widget) { auto it = std::find_if(m_children.begin(), m_children.end(), [widget] (const std::unique_ptr& widgetPtr) -> bool From 9cc206b33efcd91032075ee9ef5522e590842557 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 17 Mar 2020 17:13:27 +0100 Subject: [PATCH 123/316] Minor C++ fixes --- .../VulkanRenderer/Wrapper/CommandBuffer.hpp | 2 +- .../VulkanRenderer/Wrapper/CommandBuffer.inl | 42 +++++++------- .../VulkanRenderer/Wrapper/DescriptorPool.hpp | 2 +- .../VulkanRenderer/Wrapper/DescriptorSet.hpp | 10 ++-- .../VulkanRenderer/Wrapper/DescriptorSet.inl | 57 +++++++++---------- .../VulkanRenderer/Wrapper/DeviceObject.hpp | 2 +- .../VulkanRenderer/Wrapper/DeviceObject.inl | 2 +- .../VulkanRenderer/Wrapper/Pipeline.hpp | 2 +- .../VulkanRenderer/Wrapper/Pipeline.inl | 2 +- .../VulkanRenderer/Wrapper/DescriptorPool.cpp | 28 +++++---- 10 files changed, 72 insertions(+), 77 deletions(-) diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp index 80ff5b7f4..ab5f54eae 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp @@ -81,7 +81,7 @@ namespace Nz inline VkResult GetLastErrorCode() const; CommandBuffer& operator=(const CommandBuffer&) = delete; - CommandBuffer& operator=(CommandBuffer&& commandBuffer); + CommandBuffer& operator=(CommandBuffer&& commandBuffer) noexcept; inline operator VkCommandBuffer() const; diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl index bd2c4ce76..574cb90a5 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl @@ -26,7 +26,6 @@ namespace Nz inline CommandBuffer::CommandBuffer(CommandBuffer&& commandBuffer) : m_pool(commandBuffer.m_pool), - m_allocator(commandBuffer.m_allocator), m_handle(commandBuffer.m_handle), m_lastErrorCode(commandBuffer.m_lastErrorCode) { @@ -258,8 +257,14 @@ namespace Nz inline void CommandBuffer::SetScissor(const Recti& scissorRegion) { VkRect2D rect = { - {scissorRegion.x, scissorRegion.y}, // VkOffset2D offset - {UInt32(scissorRegion.width), UInt32(scissorRegion.height)} // VkExtent2D extent + { + scissorRegion.x, + scissorRegion.y + }, + { + UInt32(scissorRegion.width), + UInt32(scissorRegion.height) + } }; SetScissor(rect); @@ -288,11 +293,11 @@ namespace Nz inline void CommandBuffer::SetImageLayout(VkImage image, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkImageLayout oldImageLayout, VkImageLayout newImageLayout) { VkImageSubresourceRange imageRange = { - VK_IMAGE_ASPECT_COLOR_BIT, // VkImageAspectFlags aspectMask - 0, // uint32_t baseMipLevel - 1, // uint32_t levelCount - 0, // uint32_t baseArrayLayer - 1 // uint32_t layerCount + VK_IMAGE_ASPECT_COLOR_BIT, + 0, //< baseMipLevel + 1, //< levelCount + 0, //< baseArrayLayer + 1 //< layerCount }; return SetImageLayout(image, srcStageMask, dstStageMask, oldImageLayout, newImageLayout, imageRange); @@ -384,12 +389,12 @@ namespace Nz inline void CommandBuffer::SetViewport(const Rectf& viewport, float minDepth, float maxDepth) { VkViewport rect = { - viewport.x, // float x; - viewport.y, // float y; - viewport.width, // float width; - viewport.height, // float height; - minDepth, // float minDepth; - maxDepth // float maxDepth; + viewport.x, + viewport.y, + viewport.width, + viewport.height, + minDepth, + maxDepth }; SetViewport(rect); @@ -410,15 +415,12 @@ namespace Nz return m_lastErrorCode; } - inline CommandBuffer& CommandBuffer::operator=(CommandBuffer&& commandBuffer) + inline CommandBuffer& CommandBuffer::operator=(CommandBuffer&& commandBuffer) noexcept { - m_allocator = commandBuffer.m_allocator; - m_handle = commandBuffer.m_handle; m_lastErrorCode = commandBuffer.m_lastErrorCode; m_pool = commandBuffer.m_pool; - m_handle = commandBuffer.m_handle; - - commandBuffer.m_handle = VK_NULL_HANDLE; + + std::swap(m_handle, commandBuffer.m_handle); return *this; } diff --git a/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp b/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp index 06f64d185..890b882d2 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp @@ -23,7 +23,7 @@ namespace Nz public: DescriptorPool() = default; DescriptorPool(const DescriptorPool&) = delete; - DescriptorPool(DescriptorPool&&) = default; + DescriptorPool(DescriptorPool&&) noexcept = default; ~DescriptorPool() = default; DescriptorSet AllocateDescriptorSet(const VkDescriptorSetLayout& setLayouts); diff --git a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.hpp b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.hpp index 8fd14fcba..42bc26721 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.hpp @@ -23,12 +23,12 @@ namespace Nz public: inline DescriptorSet(); DescriptorSet(const DescriptorSet&) = delete; - inline DescriptorSet(DescriptorSet&& descriptorSet); + inline DescriptorSet(DescriptorSet&& descriptorSet) noexcept; inline ~DescriptorSet(); inline void Free(); - inline VkResult GetLastErrorCode() const; + inline bool IsValid() const; inline void WriteUniformDescriptor(UInt32 binding, VkBuffer buffer, VkDeviceSize offset, VkDeviceSize range); inline void WriteUniformDescriptor(UInt32 binding, const VkDescriptorBufferInfo& bufferInfo); @@ -38,18 +38,16 @@ namespace Nz inline void WriteUniformDescriptors(UInt32 binding, UInt32 arrayElement, UInt32 descriptorCount, const VkDescriptorBufferInfo* bufferInfo); DescriptorSet& operator=(const DescriptorSet&) = delete; - DescriptorSet& operator=(DescriptorSet&& descriptorSet); + inline DescriptorSet& operator=(DescriptorSet&& descriptorSet) noexcept; + inline explicit operator bool() const; inline operator VkDescriptorSet() const; private: inline DescriptorSet(DescriptorPool& pool, VkDescriptorSet handle); DescriptorPool* m_pool; - VkAllocationCallbacks m_allocator; VkDescriptorSet m_handle; - VkResult m_lastErrorCode; - }; } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.inl b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.inl index 9a0267cf1..5e5943bd3 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.inl @@ -24,11 +24,9 @@ namespace Nz { } - inline DescriptorSet::DescriptorSet(DescriptorSet&& descriptorSet) : + inline DescriptorSet::DescriptorSet(DescriptorSet&& descriptorSet) noexcept : m_pool(descriptorSet.m_pool), - m_allocator(descriptorSet.m_allocator), - m_handle(descriptorSet.m_handle), - m_lastErrorCode(descriptorSet.m_lastErrorCode) + m_handle(descriptorSet.m_handle) { descriptorSet.m_handle = VK_NULL_HANDLE; } @@ -47,9 +45,9 @@ namespace Nz } } - inline VkResult DescriptorSet::GetLastErrorCode() const + inline bool DescriptorSet::IsValid() const { - return m_lastErrorCode; + return m_handle != VK_NULL_HANDLE; } inline void DescriptorSet::WriteUniformDescriptor(UInt32 binding, VkBuffer buffer, VkDeviceSize offset, VkDeviceSize range) @@ -64,11 +62,10 @@ namespace Nz inline void DescriptorSet::WriteUniformDescriptor(UInt32 binding, UInt32 arrayElement, VkBuffer buffer, VkDeviceSize offset, VkDeviceSize range) { - VkDescriptorBufferInfo bufferInfo = - { - buffer, // VkBuffer buffer; - offset, // VkDeviceSize offset; - range // VkDeviceSize range; + VkDescriptorBufferInfo bufferInfo = { + buffer, + offset, + range }; return WriteUniformDescriptor(binding, arrayElement, bufferInfo); @@ -86,36 +83,36 @@ namespace Nz inline void DescriptorSet::WriteUniformDescriptors(UInt32 binding, UInt32 arrayElement, UInt32 descriptorCount, const VkDescriptorBufferInfo* bufferInfo) { - VkWriteDescriptorSet writeDescriptorSet = - { - VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, // VkStructureType sType; - nullptr, // const void* pNext; - m_handle, // VkDescriptorSet dstSet; - binding, // uint32_t dstBinding; - arrayElement, // uint32_t dstArrayElement; - descriptorCount, // uint32_t descriptorCount; - VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, // VkDescriptorType descriptorType; - nullptr, // const VkDescriptorImageInfo* pImageInfo; - bufferInfo, // const VkDescriptorBufferInfo* pBufferInfo; - nullptr // const VkBufferView* pTexelBufferView; + VkWriteDescriptorSet writeDescriptorSet = { + VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, + nullptr, + m_handle, + binding, + arrayElement, + descriptorCount, + VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, + nullptr, + bufferInfo, + nullptr }; return m_pool->GetDevice()->vkUpdateDescriptorSets(*m_pool->GetDevice(), 1U, &writeDescriptorSet, 0U, nullptr); } - inline DescriptorSet& DescriptorSet::operator=(DescriptorSet&& descriptorSet) + inline DescriptorSet& DescriptorSet::operator=(DescriptorSet&& descriptorSet) noexcept { - m_allocator = descriptorSet.m_allocator; - m_handle = descriptorSet.m_handle; - m_lastErrorCode = descriptorSet.m_lastErrorCode; m_pool = descriptorSet.m_pool; - m_handle = descriptorSet.m_handle; - - descriptorSet.m_handle = VK_NULL_HANDLE; + + std::swap(m_handle, descriptorSet.m_handle); return *this; } + inline DescriptorSet::operator bool() const + { + return IsValid(); + } + inline DescriptorSet::operator VkDescriptorSet() const { return m_handle; diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp index 887b05563..4ce478418 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp @@ -22,7 +22,7 @@ namespace Nz public: DeviceObject(); DeviceObject(const DeviceObject&) = delete; - DeviceObject(DeviceObject&& object); + DeviceObject(DeviceObject&& object) noexcept; ~DeviceObject(); bool Create(Device& device, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl index 91c671ce4..fcc5245d1 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl @@ -20,7 +20,7 @@ namespace Nz } template - DeviceObject::DeviceObject(DeviceObject&& object) : + DeviceObject::DeviceObject(DeviceObject&& object) noexcept : m_device(std::move(object.m_device)), m_allocator(object.m_allocator), m_handle(object.m_handle), diff --git a/include/Nazara/VulkanRenderer/Wrapper/Pipeline.hpp b/include/Nazara/VulkanRenderer/Wrapper/Pipeline.hpp index d63abadac..995a9e0ca 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Pipeline.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Pipeline.hpp @@ -19,7 +19,7 @@ namespace Nz public: inline Pipeline(); Pipeline(const Pipeline&) = delete; - Pipeline(Pipeline&&); + Pipeline(Pipeline&&) noexcept; inline ~Pipeline(); inline bool CreateCompute(Device& device, const VkComputePipelineCreateInfo& createInfo, VkPipelineCache cache = VK_NULL_HANDLE, const VkAllocationCallbacks* allocator = nullptr); diff --git a/include/Nazara/VulkanRenderer/Wrapper/Pipeline.inl b/include/Nazara/VulkanRenderer/Wrapper/Pipeline.inl index e91fe8107..ab865a777 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Pipeline.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Pipeline.inl @@ -15,7 +15,7 @@ namespace Nz { } - inline Pipeline::Pipeline(Pipeline&& object) : + inline Pipeline::Pipeline(Pipeline&& object) noexcept : m_device(std::move(object.m_device)), m_allocator(object.m_allocator), m_handle(object.m_handle), diff --git a/src/Nazara/VulkanRenderer/Wrapper/DescriptorPool.cpp b/src/Nazara/VulkanRenderer/Wrapper/DescriptorPool.cpp index 488ec27a4..ddcc30002 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/DescriptorPool.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/DescriptorPool.cpp @@ -12,13 +12,12 @@ namespace Nz { DescriptorSet DescriptorPool::AllocateDescriptorSet(const VkDescriptorSetLayout& setLayouts) { - VkDescriptorSetAllocateInfo createInfo = - { - VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO, // VkStructureType sType; - nullptr, // const void* pNext; - m_handle, // VkDescriptorPool descriptorPool; - 1U, // uint32_t descriptorSetCount; - &setLayouts // const VkDescriptorSetLayout* pSetLayouts; + VkDescriptorSetAllocateInfo createInfo = { + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO, + nullptr, + m_handle, + 1U, + & setLayouts }; VkDescriptorSet handle = VK_NULL_HANDLE; @@ -29,19 +28,18 @@ namespace Nz std::vector DescriptorPool::AllocateDescriptorSets(UInt32 descriptorSetCount, const VkDescriptorSetLayout* setLayouts) { - VkDescriptorSetAllocateInfo createInfo = - { - VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO, // VkStructureType sType; - nullptr, // const void* pNext; - m_handle, // VkDescriptorPool descriptorPool; - descriptorSetCount, // uint32_t descriptorSetCount; - setLayouts // const VkDescriptorSetLayout* pSetLayouts; + VkDescriptorSetAllocateInfo createInfo = { + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO, + nullptr, + m_handle, + descriptorSetCount, + setLayouts }; std::vector handles(descriptorSetCount, VK_NULL_HANDLE); m_lastErrorCode = m_device->vkAllocateDescriptorSets(*m_device, &createInfo, handles.data()); if (m_lastErrorCode != VkResult::VK_SUCCESS) - return std::vector(); + return {}; std::vector descriptorSets; for (UInt32 i = 0; i < descriptorSetCount; ++i) From 4ede9f1cfe222b981fd2de59c970be8ef3ea2130 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 18 Mar 2020 13:48:05 +0100 Subject: [PATCH 124/316] Add texture in demo --- build/scripts/actions/generateheaders.lua | 5 +- examples/VulkanTest/main.cpp | 199 ++++++++++++++---- examples/bin/resources/shaders/triangle.frag | 7 +- .../bin/resources/shaders/triangle.frag.spv | Bin 572 -> 728 bytes examples/bin/resources/shaders/triangle.vert | 3 + .../bin/resources/shaders/triangle.vert.spv | Bin 1444 -> 1636 bytes .../VulkanRenderPipelineLayout.hpp | 12 +- include/Nazara/VulkanRenderer/Wrapper.hpp | 1 + .../VulkanRenderer/Wrapper/CommandBuffer.hpp | 1 + .../VulkanRenderer/Wrapper/CommandBuffer.inl | 23 ++ .../VulkanRenderer/Wrapper/DescriptorSet.hpp | 7 + .../VulkanRenderer/Wrapper/DescriptorSet.inl | 49 +++++ .../Nazara/VulkanRenderer/Wrapper/Sampler.hpp | 39 ++++ .../Nazara/VulkanRenderer/Wrapper/Sampler.inl | 24 +++ .../VulkanRenderPipelineLayout.cpp | 29 +++ 15 files changed, 359 insertions(+), 40 deletions(-) create mode 100644 include/Nazara/VulkanRenderer/Wrapper/Sampler.hpp create mode 100644 include/Nazara/VulkanRenderer/Wrapper/Sampler.inl diff --git a/build/scripts/actions/generateheaders.lua b/build/scripts/actions/generateheaders.lua index d9bbe3ea6..81536a706 100644 --- a/build/scripts/actions/generateheaders.lua +++ b/build/scripts/actions/generateheaders.lua @@ -43,7 +43,10 @@ ACTION.Function = function () end table.insert(paths, { - Excludes = {}, + Excludes = { + ["DeviceFunctions.hpp"] = true, + ["InstanceFunctions.hpp"] = true, + }, HeaderGuard = "NAZARA_GLOBAL_VULKANRENDERER_WRAPPER_HPP", Name = "Vulkan wrapper", SearchDir = "../include/Nazara/VulkanRenderer/Wrapper", diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index d85a2c85c..f71e98518 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -70,8 +70,8 @@ int main() Nz::RenderWindow window; Nz::MeshParams meshParams; - meshParams.matrix = Nz::Matrix4f::Rotate(Nz::EulerAnglesf(0.f, 90.f, 180.f)); - meshParams.vertexDeclaration = Nz::VertexDeclaration::Get(Nz::VertexLayout_XYZ_Normal); + meshParams.matrix = Nz::Matrix4f::Rotate(Nz::EulerAnglesf(0.f, 90.f, 180.f)) * Nz::Matrix4f::Scale(Nz::Vector3f(0.002f)); + meshParams.vertexDeclaration = Nz::VertexDeclaration::Get(Nz::VertexLayout_XYZ_Normal_UV); Nz::String windowTitle = "Vulkan Test"; if (!window.Create(Nz::VideoMode(800, 600, 32), windowTitle)) @@ -96,7 +96,7 @@ int main() return __LINE__; } - Nz::MeshRef drfreak = Nz::Mesh::LoadFromFile("resources/drfreak.md2", meshParams); + Nz::MeshRef drfreak = Nz::Mesh::LoadFromFile("resources/Spaceship/spaceship.obj", meshParams); if (!drfreak) { @@ -115,6 +115,153 @@ int main() // Vertex buffer std::cout << "Vertex count: " << drfreakVB->GetVertexCount() << std::endl; + Nz::VkRenderWindow& vulkanWindow = *static_cast(window.GetImpl()); + Nz::VulkanDevice& vulkanDevice = vulkanWindow.GetDevice(); + + Nz::Vk::CommandPool cmdPool; + if (!cmdPool.Create(vulkanDevice, 0, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)) + { + NazaraError("Failed to create rendering cmd pool"); + return __LINE__; + } + + Nz::Vk::QueueHandle graphicsQueue = vulkanDevice.GetQueue(0, 0); + + // Texture + Nz::ImageRef drfreakImage = Nz::Image::LoadFromFile("resources/Spaceship/Texture/diffuse.png"); + if (!drfreakImage || !drfreakImage->Convert(Nz::PixelFormatType_RGBA8)) + { + NazaraError("Failed to load image"); + return __LINE__; + } + + VkImageCreateInfo imageInfo = {}; + imageInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; + imageInfo.imageType = VK_IMAGE_TYPE_2D; + imageInfo.extent.width = static_cast(drfreakImage->GetWidth()); + imageInfo.extent.height = static_cast(drfreakImage->GetHeight()); + imageInfo.extent.depth = 1; + imageInfo.mipLevels = 1; + imageInfo.arrayLayers = 1; + imageInfo.samples = VK_SAMPLE_COUNT_1_BIT; + imageInfo.format = VK_FORMAT_R8G8B8A8_SRGB; + imageInfo.tiling = VK_IMAGE_TILING_OPTIMAL; + imageInfo.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; + imageInfo.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT; + imageInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE; + + Nz::Vk::Image vkImage; + if (!vkImage.Create(vulkanDevice, imageInfo)) + { + NazaraError("Failed to create vulkan image"); + return __LINE__; + } + + VkMemoryRequirements imageMemRequirement = vkImage.GetMemoryRequirements(); + + Nz::Vk::DeviceMemory imageMemory; + if (!imageMemory.Create(vulkanDevice, imageMemRequirement.size, imageMemRequirement.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)) + { + NazaraError("Failed to create vulkan image memory"); + return __LINE__; + } + + vkImage.BindImageMemory(imageMemory); + + // Update texture + { + Nz::Vk::Buffer stagingImageBuffer; + if (!stagingImageBuffer.Create(vulkanDevice, 0, drfreakImage->GetMemoryUsage(), VK_BUFFER_USAGE_TRANSFER_SRC_BIT)) + { + NazaraError("Failed to create staging buffer"); + return __LINE__; + } + + VkMemoryPropertyFlags memoryProperties = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; + + Nz::Vk::DeviceMemory stagingImageMemory; + + VkMemoryRequirements memRequirement = stagingImageBuffer.GetMemoryRequirements(); + if (!stagingImageMemory.Create(vulkanDevice, memRequirement.size, memRequirement.memoryTypeBits, memoryProperties)) + { + NazaraError("Failed to allocate vertex buffer memory"); + return __LINE__; + } + + if (!stagingImageBuffer.BindBufferMemory(stagingImageMemory)) + { + NazaraError("Failed to bind vertex buffer to its memory"); + return __LINE__; + } + + if (!stagingImageMemory.Map(0, memRequirement.size)) + return __LINE__; + + std::memcpy(stagingImageMemory.GetMappedPointer(), drfreakImage->GetPixels(), drfreakImage->GetMemoryUsage()); + + stagingImageMemory.FlushMemory(); + stagingImageMemory.Unmap(); + + Nz::Vk::CommandBuffer copyCommand = cmdPool.AllocateCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY); + copyCommand.Begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT); + copyCommand.SetImageLayout(vkImage, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); + copyCommand.CopyBufferToImage(stagingImageBuffer, vkImage, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, drfreakImage->GetWidth(), drfreakImage->GetHeight()); + copyCommand.SetImageLayout(vkImage, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); + if (!copyCommand.End()) + return __LINE__; + + if (!graphicsQueue.Submit(copyCommand)) + return __LINE__; + + graphicsQueue.WaitIdle(); + } + + // Create image view + + VkImageViewCreateInfo imageViewInfo = {}; + imageViewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; + imageViewInfo.components = { + VK_COMPONENT_SWIZZLE_R, + VK_COMPONENT_SWIZZLE_G, + VK_COMPONENT_SWIZZLE_B, + VK_COMPONENT_SWIZZLE_A + }; + imageViewInfo.format = VK_FORMAT_R8G8B8A8_SRGB; + imageViewInfo.image = vkImage; + imageViewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; + imageViewInfo.subresourceRange = { + VK_IMAGE_ASPECT_COLOR_BIT, + 0, + 1, + 0, + 1 + }; + + Nz::Vk::ImageView imageView; + if (!imageView.Create(vulkanDevice, imageViewInfo)) + return __LINE__; + + // Sampler + + VkSamplerCreateInfo samplerInfo = {}; + samplerInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; + samplerInfo.magFilter = VK_FILTER_LINEAR; + samplerInfo.minFilter = VK_FILTER_LINEAR; + samplerInfo.addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT; + samplerInfo.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT; + samplerInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT; + samplerInfo.anisotropyEnable = VK_FALSE; + samplerInfo.maxAnisotropy = 16; + samplerInfo.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK; + samplerInfo.unnormalizedCoordinates = VK_FALSE; + samplerInfo.compareEnable = VK_FALSE; + samplerInfo.compareOp = VK_COMPARE_OP_ALWAYS; + samplerInfo.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR; + + Nz::Vk::Sampler imageSampler; + if (!imageSampler.Create(vulkanDevice, samplerInfo)) + return __LINE__; + struct { Nz::Matrix4f projectionMatrix; @@ -131,33 +278,21 @@ int main() Nz::UInt32 uniformSize = sizeof(ubo); Nz::RenderPipelineLayoutInfo pipelineLayoutInfo; - auto& bindingInfo = pipelineLayoutInfo.bindings.emplace_back(); - bindingInfo.index = 0; - bindingInfo.shaderStageFlags = Nz::ShaderStageType::Vertex; - bindingInfo.type = Nz::ShaderBindingType::UniformBuffer; + auto& uboBinding = pipelineLayoutInfo.bindings.emplace_back(); + uboBinding.index = 0; + uboBinding.shaderStageFlags = Nz::ShaderStageType::Vertex; + uboBinding.type = Nz::ShaderBindingType::UniformBuffer; + + auto& textureBinding = pipelineLayoutInfo.bindings.emplace_back(); + textureBinding.index = 1; + textureBinding.shaderStageFlags = Nz::ShaderStageType::Fragment; + textureBinding.type = Nz::ShaderBindingType::Texture; std::shared_ptr renderPipelineLayout = device->InstantiateRenderPipelineLayout(pipelineLayoutInfo); Nz::VulkanRenderPipelineLayout* vkPipelineLayout = static_cast(renderPipelineLayout.get()); - VkDescriptorSetLayout descriptorLayout = vkPipelineLayout->GetDescriptorSetLayout(); - VkPipelineLayout pipelineLayout = vkPipelineLayout->GetPipelineLayout(); - - VkDescriptorPoolSize poolSize; - poolSize.descriptorCount = 1; - poolSize.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; - - Nz::VkRenderWindow& vulkanWindow = *static_cast(window.GetImpl()); - Nz::VulkanDevice& vulkanDevice = vulkanWindow.GetDevice(); - - Nz::Vk::DescriptorPool descriptorPool; - if (!descriptorPool.Create(vulkanDevice, 1, poolSize, VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT)) - { - NazaraError("Failed to create descriptor pool"); - return __LINE__; - } - - Nz::Vk::DescriptorSet descriptorSet = descriptorPool.AllocateDescriptorSet(descriptorLayout); + Nz::Vk::DescriptorSet descriptorSet = vkPipelineLayout->AllocateDescriptorSet(); std::unique_ptr uniformBuffer = device->InstantiateBuffer(Nz::BufferType_Uniform); if (!uniformBuffer->Initialize(uniformSize, Nz::BufferUsage_DeviceLocal)) @@ -168,6 +303,7 @@ int main() Nz::VulkanBuffer* uniformBufferImpl = static_cast(uniformBuffer.get()); descriptorSet.WriteUniformDescriptor(0, uniformBufferImpl->GetBufferHandle(), 0, uniformSize); + descriptorSet.WriteCombinedImageSamplerDescriptor(1, imageSampler, imageView, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); Nz::RenderPipelineInfo pipelineInfo; pipelineInfo.pipelineLayout = renderPipelineLayout; @@ -185,19 +321,10 @@ int main() Nz::VulkanRenderPipeline::CreateInfo pipelineCreateInfo = Nz::VulkanRenderPipeline::BuildCreateInfo(pipelineInfo); pipelineCreateInfo.pipelineInfo.renderPass = vulkanWindow.GetRenderPass(); - Nz::Vk::CommandPool cmdPool; - if (!cmdPool.Create(vulkanDevice, 0, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)) - { - NazaraError("Failed to create rendering cmd pool"); - return __LINE__; - } - std::array clearValues; - clearValues[0].color = {1.0f, 0.8f, 0.4f, 0.0f}; + clearValues[0].color = {0.0f, 0.0f, 0.0f, 0.0f}; clearValues[1].depthStencil = {1.f, 0}; - Nz::Vk::QueueHandle graphicsQueue = vulkanDevice.GetQueue(0, 0); - Nz::UInt32 imageCount = vulkanWindow.GetFramebufferCount(); std::vector renderCmds = cmdPool.AllocateCommandBuffers(imageCount, VK_COMMAND_BUFFER_LEVEL_PRIMARY); @@ -251,7 +378,7 @@ int main() renderCmd.BeginRenderPass(render_pass_begin_info); renderCmd.BindIndexBuffer(indexBufferImpl->GetBufferHandle(), 0, VK_INDEX_TYPE_UINT16); renderCmd.BindVertexBuffer(0, vertexBufferImpl->GetBufferHandle(), 0); - renderCmd.BindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, descriptorSet); + renderCmd.BindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, vkPipelineLayout->GetPipelineLayout(), 0, descriptorSet); renderCmd.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, vkPipeline->Get(vulkanWindow.GetRenderPass())); renderCmd.SetScissor(Nz::Recti{0, 0, int(windowSize.x), int(windowSize.y)}); renderCmd.SetViewport({0.f, 0.f, float(windowSize.x), float(windowSize.y)}, 0.f, 1.f); diff --git a/examples/bin/resources/shaders/triangle.frag b/examples/bin/resources/shaders/triangle.frag index 404919ccd..58a4eff89 100644 --- a/examples/bin/resources/shaders/triangle.frag +++ b/examples/bin/resources/shaders/triangle.frag @@ -3,11 +3,14 @@ #extension GL_ARB_separate_shader_objects : enable #extension GL_ARB_shading_language_420pack : enable +layout(binding = 1) uniform sampler2D texSampler; + layout (location = 0) in vec3 inColor; +layout (location = 1) in vec2 outTexCoords; layout (location = 0) out vec4 outFragColor; void main() { - outFragColor = vec4(inColor, 1.0); -} \ No newline at end of file + outFragColor = texture(texSampler, outTexCoords); +} diff --git a/examples/bin/resources/shaders/triangle.frag.spv b/examples/bin/resources/shaders/triangle.frag.spv index 3804e0ca05a6071d94591cb640444938edc1df7b..c163dc05af340d2d8646f3c6862a0e40c6286fe1 100644 GIT binary patch literal 728 zcmY+ATT22_6opUfm}PnCqC^l{?;>FlL_rDp;!_4a4ksNZOJ`(e1b<(@s+XYkjY@W8 zyJxMv_BETi*fwTMzk;co<*S;EurWoGPkpaH=(plz)aqQdQIt$J6{0CCFDH*p?KmK? zBdf}4vWm3C)I?udRW{~Ji8-lyefQz{(T%;Cjcnq%@w**)ksH2!c*7+AuTf|m`0m68 z{@nVW+qrDd?C{e#suEJAIYO<9`wiZ#Ng3`xdGg@E=*l^7QegSG%J3#;d delta 252 zcmcb?x`&0AnMs+Qfq{{M0|mnN5Gw%r+(4QUh(Y4kP(BY-OdH4tspSJ=28IUv$t6q*6(EJY zKnzk8$iNC#zz-DzQgAT=s2Ip_m^wkI7!!~VU|2g!phvjaL0c*8G#H%PpA z|7&oN4o`CA3ZtIa_oLp(?*-oG#`?fN_~t6gG+DbMg!=I)-HH2gA~oaCPZ;G;MRU=c zI3I(foj6Xqss^u;^&3V8gH_#S`FeeCFGxNINg5o%trj>szIYg>VH}BH%H{<}zpC@o z_FJ)QnGQZkVkQ**jh`mrI3HYgdKh3rDCk4=7T=AX2=Cv58MDkC%V<+n>rDZ_Gqc|1!+9QgFe*UXO-m>!tBDA`qA zn{hIZo``#$aq?VX|Hn~#G7g)#V~O|>Z@=fa`792h{_h$Ln zDY53q<{mBIoOJT>`&d>KcM3-Cd7b0|BR4j`Q?Pm2i#qEPa;+8il61Z$*;jOuE6<(Z z8JGz*uE}N=?tmKD+=0z^qtJ=58ubD*`=)Gquzhhy))TYcmpFI)ihBHWqJR2&s+U3? z`r`xtBZT+!LMV51Uc&xg%F8`r<71zfBTCN{9ouxLeYRV{VJPEgjtA?noyV91gSGldzk2%FSNZ3QWfsdr)BP&v*|D rj9u+16T53kh=-4#9sg8be2*m5heOZo{IP_$!#>y-HoU*Osb`XZFaB~I literal 1444 zcmZ9L+fEZv6o$7gtyL669KGBWmDwGSEpKEi=t@s$TL6`ba*N zHzxkyo>`{2o5f!Lzs_qm)k^2Ab7x#bzelb(3$7x@xmj2DcenSkw=vH98(U8{@tAW} z?}*R5JLmNo{XGuj1OPKDxg=>zs`^!Q|5Ct=tleI){b45P{>*EsrS5#(MLH#tmw&+IHt)Q0Y^-^lZCfM)uK`a16H! z=rK0i$)YADS4%l~ndr;X>bjef73HH27<*H=QR?u|OU(N*`+4a$7j`iFg(KfZ-Q?p9 zt|^Lr!;yPlH+kTQ1@pfEwLyo_yZBykCe&CGW=?iS4KO={ z!@g4L#8{1MC1=>)kj>YY-FjlS+Y;waUXkyiH2SBnr~0zgp+64%Z!vuD7h>7z1qu6l zDJy#gZ_9(eRweYx%=pveRSCTLT$hdyJ)6%B>F__5hnSlZ;@~armUQBn&ElHU;VrHu zo!F+t`t3+({`bnw>~|z^9OLdvhhs;^-77ivv8Tz|&wUB;_+w{}Ka>~S0}1u #include #include +#include +#include +#include #include #include -#include #include namespace Nz @@ -23,13 +25,21 @@ namespace Nz VulkanRenderPipelineLayout() = default; ~VulkanRenderPipelineLayout() = default; + Vk::DescriptorSet AllocateDescriptorSet(); + bool Create(Vk::Device& device, RenderPipelineLayoutInfo layoutInfo); inline const Vk::DescriptorSetLayout& GetDescriptorSetLayout() const; inline const Vk::PipelineLayout& GetPipelineLayout() const; private: + struct DescriptorPool + { + Vk::DescriptorPool descriptorPool; + }; + MovablePtr m_device; + std::vector m_descriptorPools; Vk::DescriptorSetLayout m_descriptorSetLayout; Vk::PipelineLayout m_pipelineLayout; RenderPipelineLayoutInfo m_layoutInfo; diff --git a/include/Nazara/VulkanRenderer/Wrapper.hpp b/include/Nazara/VulkanRenderer/Wrapper.hpp index 8f360d652..1ae7ed140 100644 --- a/include/Nazara/VulkanRenderer/Wrapper.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper.hpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp index ab5f54eae..52e457236 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp @@ -52,6 +52,7 @@ namespace Nz inline void ClearDepthStencilImage(VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue& depthStencil, UInt32 rangeCount, const VkImageSubresourceRange* ranges); inline void CopyBuffer(VkBuffer source, VkBuffer target, UInt32 size, UInt32 sourceOffset = 0, UInt32 targetOffset = 0); + inline void CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, UInt32 width, UInt32 height); inline void Draw(UInt32 vertexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0); inline void DrawIndexed(UInt32 indexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, Int32 vertexOffset = 0, UInt32 firstInstance = 0); diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl index 574cb90a5..00f3c9f31 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl @@ -203,6 +203,29 @@ namespace Nz return m_pool->GetDevice()->vkCmdCopyBuffer(m_handle, source, target, 1, ®ion); } + inline void CommandBuffer::CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, UInt32 width, UInt32 height) + { + VkBufferImageCopy region = { + 0, + 0, + 0, + { // imageSubresource + VK_IMAGE_ASPECT_COLOR_BIT, //< aspectMask + 0, + 0, + 1 + }, + { // imageOffset + 0, 0, 0 + }, + { // imageExtent + width, height, 1U + } + }; + + return m_pool->GetDevice()->vkCmdCopyBufferToImage(m_handle, source, target, targetLayout, 1, ®ion); + } + inline void CommandBuffer::Draw(UInt32 vertexCount, UInt32 instanceCount, UInt32 firstVertex, UInt32 firstInstance) { return m_pool->GetDevice()->vkCmdDraw(m_handle, vertexCount, instanceCount, firstVertex, firstInstance); diff --git a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.hpp b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.hpp index 42bc26721..24eb8c6ed 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.hpp @@ -30,6 +30,13 @@ namespace Nz inline bool IsValid() const; + inline void WriteCombinedImageSamplerDescriptor(UInt32 binding, VkSampler sampler, VkImageView imageView, VkImageLayout imageLayout); + inline void WriteCombinedImageSamplerDescriptor(UInt32 binding, const VkDescriptorImageInfo& imageInfo); + inline void WriteCombinedImageSamplerDescriptor(UInt32 binding, UInt32 arrayElement, VkSampler sampler, VkImageView imageView, VkImageLayout imageLayout); + inline void WriteCombinedImageSamplerDescriptor(UInt32 binding, UInt32 arrayElement, const VkDescriptorImageInfo& imageInfo); + inline void WriteCombinedImageSamplerDescriptors(UInt32 binding, UInt32 descriptorCount, const VkDescriptorImageInfo* imageInfo); + inline void WriteCombinedImageSamplerDescriptors(UInt32 binding, UInt32 arrayElement, UInt32 descriptorCount, const VkDescriptorImageInfo* imageInfo); + inline void WriteUniformDescriptor(UInt32 binding, VkBuffer buffer, VkDeviceSize offset, VkDeviceSize range); inline void WriteUniformDescriptor(UInt32 binding, const VkDescriptorBufferInfo& bufferInfo); inline void WriteUniformDescriptor(UInt32 binding, UInt32 arrayElement, VkBuffer buffer, VkDeviceSize offset, VkDeviceSize range); diff --git a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.inl b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.inl index 5e5943bd3..3932fdfcf 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.inl @@ -50,6 +50,55 @@ namespace Nz return m_handle != VK_NULL_HANDLE; } + inline void DescriptorSet::WriteCombinedImageSamplerDescriptor(UInt32 binding, VkSampler sampler, VkImageView imageView, VkImageLayout imageLayout) + { + return WriteCombinedImageSamplerDescriptor(binding, 0, sampler, imageView, imageLayout); + } + + inline void DescriptorSet::WriteCombinedImageSamplerDescriptor(UInt32 binding, const VkDescriptorImageInfo& imageInfo) + { + return WriteCombinedImageSamplerDescriptor(binding, 0, imageInfo); + } + + inline void DescriptorSet::WriteCombinedImageSamplerDescriptor(UInt32 binding, UInt32 arrayElement, VkSampler sampler, VkImageView imageView, VkImageLayout imageLayout) + { + VkDescriptorImageInfo imageInfo = { + sampler, + imageView, + imageLayout + }; + + return WriteCombinedImageSamplerDescriptors(binding, arrayElement, 1U, &imageInfo); + } + + inline void DescriptorSet::WriteCombinedImageSamplerDescriptor(UInt32 binding, UInt32 arrayElement, const VkDescriptorImageInfo& imageInfo) + { + return WriteCombinedImageSamplerDescriptors(binding, arrayElement, 1U, &imageInfo); + } + + inline void DescriptorSet::WriteCombinedImageSamplerDescriptors(UInt32 binding, UInt32 descriptorCount, const VkDescriptorImageInfo* imageInfo) + { + return WriteCombinedImageSamplerDescriptors(binding, 0U, descriptorCount, imageInfo); + } + + inline void DescriptorSet::WriteCombinedImageSamplerDescriptors(UInt32 binding, UInt32 arrayElement, UInt32 descriptorCount, const VkDescriptorImageInfo* imageInfo) + { + VkWriteDescriptorSet writeDescriptorSet = { + VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, + nullptr, + m_handle, + binding, + arrayElement, + descriptorCount, + VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, + imageInfo, + nullptr, + nullptr + }; + + return m_pool->GetDevice()->vkUpdateDescriptorSets(*m_pool->GetDevice(), 1U, &writeDescriptorSet, 0U, nullptr); + } + inline void DescriptorSet::WriteUniformDescriptor(UInt32 binding, VkBuffer buffer, VkDeviceSize offset, VkDeviceSize range) { return WriteUniformDescriptor(binding, 0U, buffer, offset, range); diff --git a/include/Nazara/VulkanRenderer/Wrapper/Sampler.hpp b/include/Nazara/VulkanRenderer/Wrapper/Sampler.hpp new file mode 100644 index 000000000..8cbde84d1 --- /dev/null +++ b/include/Nazara/VulkanRenderer/Wrapper/Sampler.hpp @@ -0,0 +1,39 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VKSAMPLER_HPP +#define NAZARA_VULKANRENDERER_VKSAMPLER_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class Sampler : public DeviceObject + { + friend DeviceObject; + + public: + Sampler() = default; + Sampler(const Sampler&) = delete; + Sampler(Sampler&&) = default; + ~Sampler() = default; + + Sampler& operator=(const Sampler&) = delete; + Sampler& operator=(Sampler&&) = delete; + + private: + static inline VkResult CreateHelper(Device& device, const VkSamplerCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSampler* handle); + static inline void DestroyHelper(Device& device, VkSampler handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_VULKANRENDERER_VKSAMPLER_HPP diff --git a/include/Nazara/VulkanRenderer/Wrapper/Sampler.inl b/include/Nazara/VulkanRenderer/Wrapper/Sampler.inl new file mode 100644 index 000000000..7835bdce0 --- /dev/null +++ b/include/Nazara/VulkanRenderer/Wrapper/Sampler.inl @@ -0,0 +1,24 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + namespace Vk + { + inline VkResult Sampler::CreateHelper(Device& device, const VkSamplerCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSampler* handle) + { + return device.vkCreateSampler(device, createInfo, allocator, handle); + } + + inline void Sampler::DestroyHelper(Device& device, VkSampler handle, const VkAllocationCallbacks* allocator) + { + return device.vkDestroySampler(device, handle, allocator); + } + } +} + +#include diff --git a/src/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.cpp b/src/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.cpp index b8d4704de..8eaf5d268 100644 --- a/src/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.cpp +++ b/src/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.cpp @@ -12,6 +12,35 @@ namespace Nz { + Vk::DescriptorSet VulkanRenderPipelineLayout::AllocateDescriptorSet() + { + // TODO: Watch descriptor set count for each pool + for (auto& pool : m_descriptorPools) + { + Vk::DescriptorSet descriptorSet = pool.descriptorPool.AllocateDescriptorSet(m_descriptorSetLayout); + if (descriptorSet) + return descriptorSet; + } + + // Allocate a new descriptor pool + StackVector poolSizes = NazaraStackVector(VkDescriptorPoolSize, m_layoutInfo.bindings.size()); + + constexpr UInt32 MaxSet = 100; + + for (const auto& bindingInfo : m_layoutInfo.bindings) + { + VkDescriptorPoolSize& poolSize = poolSizes.emplace_back(); + poolSize.descriptorCount = MaxSet; + poolSize.type = ToVulkan(bindingInfo.type); + } + + DescriptorPool pool; + if (!pool.descriptorPool.Create(*m_device, MaxSet, UInt32(poolSizes.size()), poolSizes.data(), VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT)) + return {}; + + return m_descriptorPools.emplace_back(std::move(pool)).descriptorPool.AllocateDescriptorSet(m_descriptorSetLayout); + } + bool VulkanRenderPipelineLayout::Create(Vk::Device& device, RenderPipelineLayoutInfo layoutInfo) { m_device = &device; From 07fa581525e45f21769a9e349ff91cfae239e679 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 18 Mar 2020 13:48:53 +0100 Subject: [PATCH 125/316] Cleanup device creation/selection --- .../Nazara/VulkanRenderer/VkRenderWindow.hpp | 3 +- include/Nazara/VulkanRenderer/Vulkan.hpp | 10 ++-- .../Nazara/VulkanRenderer/Wrapper/Device.inl | 2 +- .../VulkanRenderer/Wrapper/PhysicalDevice.hpp | 5 +- src/Nazara/VulkanRenderer/VkRenderWindow.cpp | 19 +++--- src/Nazara/VulkanRenderer/Vulkan.cpp | 60 +++++++++---------- src/Nazara/VulkanRenderer/VulkanRenderer.cpp | 2 +- src/Nazara/VulkanRenderer/Wrapper/Device.cpp | 4 +- 8 files changed, 51 insertions(+), 54 deletions(-) diff --git a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp index 2914dcacb..d58dbe883 100644 --- a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp +++ b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp @@ -58,13 +58,12 @@ namespace Nz private: bool SetupDepthBuffer(const Vector2ui& size); bool SetupRenderPass(); - bool SetupSwapchain(Vk::Surface& surface, const Vector2ui& size); + bool SetupSwapchain(const Vk::PhysicalDevice& deviceInfo, Vk::Surface& surface, const Vector2ui& size); Clock m_clock; VkColorSpaceKHR m_colorSpace; VkFormat m_colorFormat; VkFormat m_depthStencilFormat; - VkPhysicalDevice m_physicalDevice; std::shared_ptr m_device; std::vector m_frameBuffers; Vk::DeviceMemory m_depthBufferMemory; diff --git a/include/Nazara/VulkanRenderer/Vulkan.hpp b/include/Nazara/VulkanRenderer/Vulkan.hpp index ef88e3d10..bffff2e1a 100644 --- a/include/Nazara/VulkanRenderer/Vulkan.hpp +++ b/include/Nazara/VulkanRenderer/Vulkan.hpp @@ -35,9 +35,9 @@ namespace Nz Vulkan() = delete; ~Vulkan() = delete; - static std::shared_ptr CreateDevice(VkPhysicalDevice gpu); - static std::shared_ptr CreateDevice(VkPhysicalDevice gpu, const Vk::Surface& surface, UInt32* presentableFamilyQueue); - static std::shared_ptr CreateDevice(VkPhysicalDevice gpu, const QueueFamily* queueFamilies, std::size_t queueFamilyCount); + static std::shared_ptr CreateDevice(const Vk::PhysicalDevice& deviceInfo); + static std::shared_ptr CreateDevice(const Vk::PhysicalDevice& deviceInfo, const Vk::Surface& surface, UInt32* presentableFamilyQueue); + static std::shared_ptr CreateDevice(const Vk::PhysicalDevice& deviceInfo, const QueueFamily* queueFamilies, std::size_t queueFamilyCount); static Vk::Instance& GetInstance(); @@ -48,8 +48,8 @@ namespace Nz static bool IsInitialized(); - static std::shared_ptr SelectDevice(VkPhysicalDevice gpu); - static std::shared_ptr SelectDevice(VkPhysicalDevice gpu, const Vk::Surface& surface, UInt32* presentableFamilyQueue); + static std::shared_ptr SelectDevice(const Vk::PhysicalDevice& deviceInfo); + static std::shared_ptr SelectDevice(const Vk::PhysicalDevice& deviceInfo, const Vk::Surface& surface, UInt32* presentableFamilyQueue); static void Uninitialize(); diff --git a/include/Nazara/VulkanRenderer/Wrapper/Device.inl b/include/Nazara/VulkanRenderer/Wrapper/Device.inl index 1d44e193d..81ae1f4b3 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Device.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Device.inl @@ -41,7 +41,7 @@ namespace Nz inline VkPhysicalDevice Device::GetPhysicalDevice() const { - return m_physicalDevice->device; + return m_physicalDevice->physDevice; } inline const Vk::PhysicalDevice& Device::GetPhysicalDeviceInfo() const diff --git a/include/Nazara/VulkanRenderer/Wrapper/PhysicalDevice.hpp b/include/Nazara/VulkanRenderer/Wrapper/PhysicalDevice.hpp index 266d1d877..3e58e1f16 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/PhysicalDevice.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/PhysicalDevice.hpp @@ -8,6 +8,7 @@ #define NAZARA_VULKANRENDERER_VKPHYSICALDEVICE_HPP #include +#include #include namespace Nz @@ -16,11 +17,11 @@ namespace Nz { struct PhysicalDevice { - VkPhysicalDevice device; + VkPhysicalDevice physDevice; VkPhysicalDeviceFeatures features; VkPhysicalDeviceMemoryProperties memoryProperties; VkPhysicalDeviceProperties properties; - std::vector queues; + std::vector queueFamilies; }; } } diff --git a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp index f1c367d6e..72588bfd4 100644 --- a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp +++ b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp @@ -16,7 +16,6 @@ namespace Nz { VkRenderWindow::VkRenderWindow() : - m_physicalDevice(nullptr), m_depthStencilFormat(VK_FORMAT_MAX_ENUM) { } @@ -46,11 +45,11 @@ namespace Nz bool VkRenderWindow::Create(RendererImpl* /*renderer*/, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) { - m_physicalDevice = Vulkan::GetPhysicalDevices()[0].device; + const auto& deviceInfo = Vulkan::GetPhysicalDevices()[0]; Vk::Surface& vulkanSurface = static_cast(surface)->GetSurface(); - m_device = Vulkan::SelectDevice(m_physicalDevice, vulkanSurface, &m_presentableFamilyQueue); + m_device = Vulkan::SelectDevice(deviceInfo, vulkanSurface, &m_presentableFamilyQueue); if (!m_device) { NazaraError("Failed to get compatible Vulkan device"); @@ -60,7 +59,7 @@ namespace Nz m_presentQueue = m_device->GetQueue(m_presentableFamilyQueue, 0); std::vector surfaceFormats; - if (!vulkanSurface.GetFormats(m_physicalDevice, &surfaceFormats)) + if (!vulkanSurface.GetFormats(deviceInfo.physDevice, &surfaceFormats)) { NazaraError("Failed to query supported surface formats"); return false; @@ -115,7 +114,7 @@ namespace Nz if (m_depthStencilFormat != VK_FORMAT_MAX_ENUM) { - VkFormatProperties formatProperties = m_device->GetInstance().GetPhysicalDeviceFormatProperties(m_physicalDevice, m_depthStencilFormat); + VkFormatProperties formatProperties = m_device->GetInstance().GetPhysicalDeviceFormatProperties(deviceInfo.physDevice, m_depthStencilFormat); if (formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) break; //< Found it @@ -124,7 +123,7 @@ namespace Nz } } - if (!SetupSwapchain(vulkanSurface, size)) + if (!SetupSwapchain(deviceInfo, vulkanSurface, size)) { NazaraError("Failed to create swapchain"); return false; @@ -332,10 +331,10 @@ namespace Nz return m_renderPass.Create(*m_device, createInfo); } - bool VkRenderWindow::SetupSwapchain(Vk::Surface& surface, const Vector2ui& size) + bool VkRenderWindow::SetupSwapchain(const Vk::PhysicalDevice& deviceInfo, Vk::Surface& surface, const Vector2ui& size) { VkSurfaceCapabilitiesKHR surfaceCapabilities; - if (!surface.GetCapabilities(m_physicalDevice, &surfaceCapabilities)) + if (!surface.GetCapabilities(deviceInfo.physDevice, &surfaceCapabilities)) { NazaraError("Failed to query surface capabilities"); return false; @@ -355,7 +354,7 @@ namespace Nz extent = surfaceCapabilities.currentExtent; std::vector presentModes; - if (!surface.GetPresentModes(m_physicalDevice, &presentModes)) + if (!surface.GetPresentModes(deviceInfo.physDevice, &presentModes)) { NazaraError("Failed to query supported present modes"); return false; @@ -391,7 +390,7 @@ namespace Nz VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR, swapchainPresentMode, VK_TRUE, - 0 + VK_NULL_HANDLE }; if (!m_swapchain.Create(*m_device, swapchainInfo)) diff --git a/src/Nazara/VulkanRenderer/Vulkan.cpp b/src/Nazara/VulkanRenderer/Vulkan.cpp index cb211ad01..d0d6b9da6 100644 --- a/src/Nazara/VulkanRenderer/Vulkan.cpp +++ b/src/Nazara/VulkanRenderer/Vulkan.cpp @@ -29,7 +29,7 @@ namespace Nz { for (const Vk::PhysicalDevice& info : s_physDevices) { - if (info.device == physDevice) + if (info.physDevice == physDevice) return info; } @@ -190,13 +190,13 @@ namespace Nz for (VkPhysicalDevice physDevice : physDevices) { Vk::PhysicalDevice deviceInfo; - if (!s_instance.GetPhysicalDeviceQueueFamilyProperties(physDevice, &deviceInfo.queues)) + if (!s_instance.GetPhysicalDeviceQueueFamilyProperties(physDevice, &deviceInfo.queueFamilies)) { NazaraWarning("Failed to query physical device queue family properties for " + String(deviceInfo.properties.deviceName) + " (0x" + String::Number(deviceInfo.properties.deviceID, 16) + ')'); continue; } - deviceInfo.device = physDevice; + deviceInfo.physDevice = physDevice; deviceInfo.features = s_instance.GetPhysicalDeviceFeatures(physDevice); deviceInfo.memoryProperties = s_instance.GetPhysicalDeviceMemoryProperties(physDevice); @@ -224,29 +224,26 @@ namespace Nz return s_instance.IsValid(); } - std::shared_ptr Vulkan::CreateDevice(VkPhysicalDevice gpu) + std::shared_ptr Vulkan::CreateDevice(const Vk::PhysicalDevice& deviceInfo) { Nz::ErrorFlags errFlags(ErrorFlag_ThrowException, true); - std::vector queueFamilies; - s_instance.GetPhysicalDeviceQueueFamilyProperties(gpu, &queueFamilies); - // Find a queue that supports graphics operations UInt32 graphicsQueueNodeIndex = UINT32_MAX; UInt32 transfertQueueNodeFamily = UINT32_MAX; - for (UInt32 i = 0; i < queueFamilies.size(); i++) + for (UInt32 i = 0; i < deviceInfo.queueFamilies.size(); i++) { - if (queueFamilies[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) + if (deviceInfo.queueFamilies[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) { graphicsQueueNodeIndex = i; break; } } - for (UInt32 i = 0; i < queueFamilies.size(); i++) + for (UInt32 i = 0; i < deviceInfo.queueFamilies.size(); i++) { - if (queueFamilies[i].queueFlags & (VK_QUEUE_COMPUTE_BIT | VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_TRANSFER_BIT)) //< Compute and graphics queue implicitly support transfer operations + if (deviceInfo.queueFamilies[i].queueFlags & (VK_QUEUE_COMPUTE_BIT | VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_TRANSFER_BIT)) //< Compute and graphics queue implicitly support transfer operations { transfertQueueNodeFamily = i; if (transfertQueueNodeFamily != graphicsQueueNodeIndex) @@ -261,27 +258,24 @@ namespace Nz } }; - return CreateDevice(gpu, queuesFamilies.data(), queuesFamilies.size()); + return CreateDevice(deviceInfo, queuesFamilies.data(), queuesFamilies.size()); } - std::shared_ptr Vulkan::CreateDevice(VkPhysicalDevice gpu, const Vk::Surface& surface, UInt32* presentableFamilyQueue) + std::shared_ptr Vulkan::CreateDevice(const Vk::PhysicalDevice& deviceInfo, const Vk::Surface& surface, UInt32* presentableFamilyQueue) { Nz::ErrorFlags errFlags(ErrorFlag_ThrowException, true); - std::vector queueFamilies; - s_instance.GetPhysicalDeviceQueueFamilyProperties(gpu, &queueFamilies); - // Find a queue that supports graphics operations UInt32 graphicsQueueNodeIndex = UINT32_MAX; UInt32 presentQueueNodeIndex = UINT32_MAX; UInt32 transferQueueNodeFamily = UINT32_MAX; - for (UInt32 i = 0; i < queueFamilies.size(); i++) + for (UInt32 i = 0; i < deviceInfo.queueFamilies.size(); i++) { bool supportPresentation = false; - if (!surface.GetSupportPresentation(gpu, i, &supportPresentation)) + if (!surface.GetSupportPresentation(deviceInfo.physDevice, i, &supportPresentation)) NazaraWarning("Failed to get presentation support of queue family #" + String::Number(i)); - if (queueFamilies[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) + if (deviceInfo.queueFamilies[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) { if (supportPresentation) { @@ -312,10 +306,10 @@ namespace Nz } // Search for a transfer queue (first one being different to the graphics one) - for (UInt32 i = 0; i < queueFamilies.size(); i++) + for (UInt32 i = 0; i < deviceInfo.queueFamilies.size(); i++) { // Transfer bit is not mandatory if compute and graphics bits are set (as they implicitly support transfer) - if (queueFamilies[i].queueFlags & (VK_QUEUE_COMPUTE_BIT | VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_TRANSFER_BIT)) + if (deviceInfo.queueFamilies[i].queueFlags & (VK_QUEUE_COMPUTE_BIT | VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_TRANSFER_BIT)) { transferQueueNodeFamily = i; if (transferQueueNodeFamily != graphicsQueueNodeIndex) @@ -334,10 +328,10 @@ namespace Nz *presentableFamilyQueue = presentQueueNodeIndex; - return CreateDevice(gpu, queuesFamilies.data(), queuesFamilies.size()); + return CreateDevice(deviceInfo, queuesFamilies.data(), queuesFamilies.size()); } - std::shared_ptr Vulkan::CreateDevice(VkPhysicalDevice gpu, const QueueFamily* queueFamilies, std::size_t queueFamilyCount) + std::shared_ptr Vulkan::CreateDevice(const Vk::PhysicalDevice& deviceInfo, const QueueFamily* queueFamilies, std::size_t queueFamilyCount) { std::vector queueCreateInfos; queueCreateInfos.reserve(queueFamilyCount); @@ -396,8 +390,12 @@ namespace Nz } if (!s_initializationParameters.GetBooleanParameter("VkDeviceInfo_OverrideEnabledExtensions", &bParam) || !bParam) + { + // Swapchain extension is required for rendering enabledExtensions.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME); + } + std::vector additionalExtensions; // Just to keep the String alive if (s_initializationParameters.GetIntegerParameter("VkDeviceInfo_EnabledExtensionCount", &iParam)) { @@ -429,7 +427,7 @@ namespace Nz }; std::shared_ptr device = std::make_shared(s_instance); - if (!device->Create(GetPhysicalDeviceInfo(gpu), createInfo)) + if (!device->Create(deviceInfo, createInfo)) { NazaraError("Failed to create Vulkan Device: " + TranslateVulkanError(device->GetLastErrorCode())); return {}; @@ -440,32 +438,32 @@ namespace Nz return device; } - std::shared_ptr Vulkan::SelectDevice(VkPhysicalDevice gpu) + std::shared_ptr Vulkan::SelectDevice(const Vk::PhysicalDevice& deviceInfo) { for (auto it = s_devices.begin(); it != s_devices.end();) { const auto& devicePtr = *it; - if (devicePtr->GetPhysicalDevice() == gpu) + if (devicePtr->GetPhysicalDevice() == deviceInfo.physDevice) return devicePtr; } - return CreateDevice(gpu); + return CreateDevice(deviceInfo); } - std::shared_ptr Vulkan::SelectDevice(VkPhysicalDevice gpu, const Vk::Surface& surface, UInt32* presentableFamilyQueue) + std::shared_ptr Vulkan::SelectDevice(const Vk::PhysicalDevice& deviceInfo, const Vk::Surface& surface, UInt32* presentableFamilyQueue) { // First, try to find a device compatible with that surface for (auto it = s_devices.begin(); it != s_devices.end();) { const auto& devicePtr = *it; - if (devicePtr->GetPhysicalDevice() == gpu) + if (devicePtr->GetPhysicalDevice() == deviceInfo.physDevice) { const std::vector& queueFamilyInfo = devicePtr->GetEnabledQueues(); UInt32 presentableQueueFamilyIndex = UINT32_MAX; for (const Vk::Device::QueueFamilyInfo& queueInfo : queueFamilyInfo) { bool supported = false; - if (surface.GetSupportPresentation(gpu, queueInfo.familyIndex, &supported) && supported) + if (surface.GetSupportPresentation(deviceInfo.physDevice, queueInfo.familyIndex, &supported) && supported) { if (presentableQueueFamilyIndex == UINT32_MAX || queueInfo.flags & VK_QUEUE_GRAPHICS_BIT) { @@ -487,7 +485,7 @@ namespace Nz } // No device had support for that surface, create one - return CreateDevice(gpu, surface, presentableFamilyQueue); + return CreateDevice(deviceInfo, surface, presentableFamilyQueue); } void Vulkan::Uninitialize() diff --git a/src/Nazara/VulkanRenderer/VulkanRenderer.cpp b/src/Nazara/VulkanRenderer/VulkanRenderer.cpp index bfacf89bc..ee06a5bf9 100644 --- a/src/Nazara/VulkanRenderer/VulkanRenderer.cpp +++ b/src/Nazara/VulkanRenderer/VulkanRenderer.cpp @@ -32,7 +32,7 @@ namespace Nz std::shared_ptr VulkanRenderer::InstanciateRenderDevice(std::size_t deviceIndex) { assert(deviceIndex < m_physDevices.size()); - return Vulkan::SelectDevice(m_physDevices[deviceIndex].device); + return Vulkan::SelectDevice(m_physDevices[deviceIndex]); } bool VulkanRenderer::IsBetterThan(const RendererImpl* other) const diff --git a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp index a795dd7de..4c566fb30 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp @@ -40,7 +40,7 @@ namespace Nz bool Device::Create(const Vk::PhysicalDevice& deviceInfo, const VkDeviceCreateInfo& createInfo, const VkAllocationCallbacks* allocator) { - m_lastErrorCode = m_instance.vkCreateDevice(deviceInfo.device, &createInfo, allocator, &m_device); + m_lastErrorCode = m_instance.vkCreateDevice(deviceInfo.physDevice, &createInfo, allocator, &m_device); if (m_lastErrorCode != VkResult::VK_SUCCESS) { NazaraError("Failed to create Vulkan device"); @@ -99,7 +99,7 @@ namespace Nz if (info.familyIndex > maxFamilyIndex) maxFamilyIndex = info.familyIndex; - const VkQueueFamilyProperties& queueProperties = deviceInfo.queues[info.familyIndex]; + const VkQueueFamilyProperties& queueProperties = deviceInfo.queueFamilies[info.familyIndex]; info.flags = queueProperties.queueFlags; info.minImageTransferGranularity = queueProperties.minImageTransferGranularity; info.timestampValidBits = queueProperties.timestampValidBits; From 42d58bd77c241b52c4ba0e3b6e5d130f2a51c79f Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 18 Mar 2020 13:58:30 +0100 Subject: [PATCH 126/316] Vulkan: Add physical device extension listing --- .../VulkanRenderer/Wrapper/Instance.hpp | 1 + .../Wrapper/InstanceFunctions.hpp | 1 + .../VulkanRenderer/Wrapper/PhysicalDevice.hpp | 1 + src/Nazara/VulkanRenderer/Vulkan.cpp | 9 ++++++ .../VulkanRenderer/Wrapper/Instance.cpp | 30 ++++++++++++++++++- 5 files changed, 41 insertions(+), 1 deletion(-) diff --git a/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp b/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp index 5ce955bca..5ec96ec0d 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp @@ -34,6 +34,7 @@ namespace Nz inline PFN_vkVoidFunction GetDeviceProcAddr(VkDevice device, const char* name); + bool GetPhysicalDeviceExtensions(VkPhysicalDevice device, std::vector* extensionProperties); inline VkPhysicalDeviceFeatures GetPhysicalDeviceFeatures(VkPhysicalDevice device); inline VkFormatProperties GetPhysicalDeviceFormatProperties(VkPhysicalDevice device, VkFormat format); inline bool GetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* imageFormatProperties); diff --git a/include/Nazara/VulkanRenderer/Wrapper/InstanceFunctions.hpp b/include/Nazara/VulkanRenderer/Wrapper/InstanceFunctions.hpp index 4f37b2767..a08459ba5 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/InstanceFunctions.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/InstanceFunctions.hpp @@ -5,6 +5,7 @@ // Vulkan core NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateDevice) NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkDestroyInstance) +NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkEnumerateDeviceExtensionProperties) NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkEnumeratePhysicalDevices) NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetDeviceProcAddr) NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceFeatures) diff --git a/include/Nazara/VulkanRenderer/Wrapper/PhysicalDevice.hpp b/include/Nazara/VulkanRenderer/Wrapper/PhysicalDevice.hpp index 3e58e1f16..0e95917c2 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/PhysicalDevice.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/PhysicalDevice.hpp @@ -21,6 +21,7 @@ namespace Nz VkPhysicalDeviceFeatures features; VkPhysicalDeviceMemoryProperties memoryProperties; VkPhysicalDeviceProperties properties; + std::unordered_set extensions; std::vector queueFamilies; }; } diff --git a/src/Nazara/VulkanRenderer/Vulkan.cpp b/src/Nazara/VulkanRenderer/Vulkan.cpp index d0d6b9da6..a3bab8bbf 100644 --- a/src/Nazara/VulkanRenderer/Vulkan.cpp +++ b/src/Nazara/VulkanRenderer/Vulkan.cpp @@ -202,6 +202,15 @@ namespace Nz deviceInfo.memoryProperties = s_instance.GetPhysicalDeviceMemoryProperties(physDevice); deviceInfo.properties = s_instance.GetPhysicalDeviceProperties(physDevice); + std::vector extensions; + if (s_instance.GetPhysicalDeviceExtensions(physDevice, &extensions)) + { + for (auto& extProperty : extensions) + deviceInfo.extensions.emplace(extProperty.extensionName); + } + else + NazaraWarning("Failed to query physical device extensions for " + String(deviceInfo.properties.deviceName) + " (0x" + String::Number(deviceInfo.properties.deviceID, 16) + ')'); + s_physDevices.emplace_back(std::move(deviceInfo)); } diff --git a/src/Nazara/VulkanRenderer/Wrapper/Instance.cpp b/src/Nazara/VulkanRenderer/Wrapper/Instance.cpp index e7b0330d7..e70f2ef9d 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/Instance.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Instance.cpp @@ -83,9 +83,37 @@ namespace Nz return true; } + bool Instance::GetPhysicalDeviceExtensions(VkPhysicalDevice device, std::vector* extensionProperties) + { + NazaraAssert(extensionProperties, "Invalid extension properties vector"); + + // First, query physical device count + UInt32 extensionPropertyCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t + m_lastErrorCode = vkEnumerateDeviceExtensionProperties(device, nullptr, &extensionPropertyCount, nullptr); + if (m_lastErrorCode != VkResult::VK_SUCCESS) + { + NazaraError("Failed to query extension properties count: " + TranslateVulkanError(m_lastErrorCode)); + return false; + } + + if (extensionPropertyCount == 0) + return true; //< No extension available + + // Now we can get the list of the available physical device + extensionProperties->resize(extensionPropertyCount); + m_lastErrorCode = vkEnumerateDeviceExtensionProperties(device, nullptr, &extensionPropertyCount, extensionProperties->data()); + if (m_lastErrorCode != VkResult::VK_SUCCESS) + { + NazaraError("Failed to query extension properties count: " + TranslateVulkanError(m_lastErrorCode)); + return false; + } + + return true; + } + bool Instance::GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice device, std::vector* queueFamilyProperties) { - NazaraAssert(queueFamilyProperties, "Invalid device vector"); + NazaraAssert(queueFamilyProperties, "Invalid family properties vector"); // First, query physical device count UInt32 queueFamiliesCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t From 1c9a390d6788cf94e06dabf547c28fbcaab3445c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Thu, 19 Mar 2020 18:41:05 +0100 Subject: [PATCH 127/316] Fix std::iterator inheritance --- SDK/include/NDK/EntityList.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/SDK/include/NDK/EntityList.hpp b/SDK/include/NDK/EntityList.hpp index 0f89d0cad..3b4f1580a 100644 --- a/SDK/include/NDK/EntityList.hpp +++ b/SDK/include/NDK/EntityList.hpp @@ -55,7 +55,7 @@ namespace Ndk World* m_world; }; - class NDK_API EntityList::iterator : public std::iterator + class NDK_API EntityList::iterator { friend EntityList; @@ -73,6 +73,12 @@ namespace Ndk friend inline void swap(iterator& lhs, iterator& rhs); + using difference_type = std::ptrdiff_t; + using iterator_category = std::forward_iterator_tag; + using pointer = EntityHandle*; + using reference = EntityHandle&; + using value_type = EntityHandle; + private: inline iterator(const EntityList* world, std::size_t nextId); From da5d8bc4c22d67eac2efcd1d49fb9988d98c3dfe Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 20 Mar 2020 20:56:15 +0100 Subject: [PATCH 128/316] Bypass MSVC parser regression --- include/Nazara/Graphics/CullingList.hpp | 8 ++++++++ include/Nazara/Graphics/CullingList.inl | 16 ++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/include/Nazara/Graphics/CullingList.hpp b/include/Nazara/Graphics/CullingList.hpp index 7feb32362..7eff97852 100644 --- a/include/Nazara/Graphics/CullingList.hpp +++ b/include/Nazara/Graphics/CullingList.hpp @@ -136,6 +136,8 @@ namespace Nz { friend CullingList; + using ParentType = Entry; + public: BoxEntry(); BoxEntry(BoxEntry&&) = default; @@ -154,6 +156,8 @@ namespace Nz { friend CullingList; + using ParentType = Entry; + public: NoTestEntry(); NoTestEntry(NoTestEntry&&) = default; @@ -170,6 +174,8 @@ namespace Nz { friend CullingList; + using ParentType = Entry; + public: SphereEntry(); SphereEntry(SphereEntry&&) = default; @@ -188,6 +194,8 @@ namespace Nz { friend CullingList; + using ParentType = Entry; + public: VolumeEntry(); VolumeEntry(VolumeEntry&&) = default; diff --git a/include/Nazara/Graphics/CullingList.inl b/include/Nazara/Graphics/CullingList.inl index 341508351..aa94bc995 100644 --- a/include/Nazara/Graphics/CullingList.inl +++ b/include/Nazara/Graphics/CullingList.inl @@ -424,13 +424,13 @@ namespace Nz template CullingList::BoxEntry::BoxEntry() : - Entry() + ParentType() { } template CullingList::BoxEntry::BoxEntry(CullingList* parent, std::size_t index) : - Entry(parent, index) + ParentType(parent, index) { } @@ -444,13 +444,13 @@ namespace Nz template CullingList::NoTestEntry::NoTestEntry() : - Entry() + ParentType() { } template CullingList::NoTestEntry::NoTestEntry(CullingList* parent, std::size_t index) : - Entry(parent, index) + ParentType(parent, index) { } @@ -458,13 +458,13 @@ namespace Nz template CullingList::SphereEntry::SphereEntry() : - Entry() + ParentType() { } template CullingList::SphereEntry::SphereEntry(CullingList* parent, std::size_t index) : - Entry(parent, index) + ParentType(parent, index) { } @@ -478,13 +478,13 @@ namespace Nz template CullingList::VolumeEntry::VolumeEntry() : - Entry() + ParentType() { } template CullingList::VolumeEntry::VolumeEntry(CullingList* parent, std::size_t index) : - Entry(parent, index) + ParentType(parent, index) { } From 96ea792656c3dfc0197a6220879ad8ef7e48116c Mon Sep 17 00:00:00 2001 From: REMqb Date: Sat, 21 Mar 2020 12:42:50 +0100 Subject: [PATCH 129/316] ~ Formatting --- SDK/include/NDK/BaseWidget.hpp | 4 +- SDK/include/NDK/Canvas.hpp | 8 +- SDK/include/NDK/Canvas.inl | 4 +- SDK/src/NDK/BaseWidget.cpp | 36 ++++----- SDK/src/NDK/Canvas.cpp | 12 +-- examples/Textarea/build.lua | 15 ---- examples/Textarea/main.cpp | 58 -------------- include/Nazara/Platform/Enums.hpp | 4 +- include/Nazara/Platform/Event.hpp | 22 +++--- include/Nazara/Platform/EventHandler.hpp | 4 +- include/Nazara/Platform/EventHandler.inl | 6 +- include/Nazara/Platform/Keyboard.hpp | 4 +- src/Nazara/Platform/Keyboard.cpp | 16 ++-- src/Nazara/Platform/SDL2/InputImpl.cpp | 16 ++-- src/Nazara/Platform/SDL2/InputImpl.hpp | 4 +- src/Nazara/Platform/SDL2/WindowImpl.cpp | 96 ++++++++++++------------ src/Nazara/Platform/SDL2/WindowImpl.hpp | 2 +- src/Nazara/Renderer/OpenGL.cpp | 7 +- 18 files changed, 120 insertions(+), 198 deletions(-) delete mode 100644 examples/Textarea/build.lua delete mode 100644 examples/Textarea/main.cpp diff --git a/SDK/include/NDK/BaseWidget.hpp b/SDK/include/NDK/BaseWidget.hpp index 021beeffc..0b3bdecb7 100644 --- a/SDK/include/NDK/BaseWidget.hpp +++ b/SDK/include/NDK/BaseWidget.hpp @@ -117,8 +117,8 @@ namespace Ndk virtual void OnMouseButtonRelease(int x, int y, Nz::Mouse::Button button); virtual void OnMouseExit(); virtual void OnParentResized(const Nz::Vector2f& newSize); - virtual void OnTextEntered(char32_t character, bool repeated); - virtual void OnTextEdited(const std::array& characters, int length); + virtual void OnTextEntered(char32_t character, bool repeated); + virtual void OnTextEdited(const std::array& characters, int length); inline void SetPreferredSize(const Nz::Vector2f& preferredSize); diff --git a/SDK/include/NDK/Canvas.hpp b/SDK/include/NDK/Canvas.hpp index 6b66cdeaf..4d9e9d05a 100644 --- a/SDK/include/NDK/Canvas.hpp +++ b/SDK/include/NDK/Canvas.hpp @@ -52,8 +52,8 @@ namespace Ndk void OnEventMouseLeft(const Nz::EventHandler* eventHandler); void OnEventKeyPressed(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::KeyEvent& event); void OnEventKeyReleased(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::KeyEvent& event); - void OnEventTextEntered(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::TextEvent& event); - void OnEventTextEdited(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::EditEvent& event); + void OnEventTextEntered(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::TextEvent& event); + void OnEventTextEdited(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::EditEvent& event); struct WidgetEntry { @@ -68,8 +68,8 @@ namespace Ndk NazaraSlot(Nz::EventHandler, OnMouseButtonReleased, m_mouseButtonReleasedSlot); NazaraSlot(Nz::EventHandler, OnMouseMoved, m_mouseMovedSlot); NazaraSlot(Nz::EventHandler, OnMouseLeft, m_mouseLeftSlot); - NazaraSlot(Nz::EventHandler, OnTextEntered, m_textEnteredSlot); - NazaraSlot(Nz::EventHandler, OnTextEdited, m_textEditedSlot); + NazaraSlot(Nz::EventHandler, OnTextEntered, m_textEnteredSlot); + NazaraSlot(Nz::EventHandler, OnTextEdited, m_textEditedSlot); std::size_t m_keyboardOwner; std::size_t m_hoveredWidget; diff --git a/SDK/include/NDK/Canvas.inl b/SDK/include/NDK/Canvas.inl index 649f5f728..8abe9c748 100644 --- a/SDK/include/NDK/Canvas.inl +++ b/SDK/include/NDK/Canvas.inl @@ -26,8 +26,8 @@ namespace Ndk m_mouseButtonReleasedSlot.Connect(eventHandler.OnMouseButtonReleased, this, &Canvas::OnEventMouseButtonRelease); m_mouseMovedSlot.Connect(eventHandler.OnMouseMoved, this, &Canvas::OnEventMouseMoved); m_mouseLeftSlot.Connect(eventHandler.OnMouseLeft, this, &Canvas::OnEventMouseLeft); - m_textEnteredSlot.Connect(eventHandler.OnTextEntered, this, &Canvas::OnEventTextEntered); - m_textEditedSlot.Connect(eventHandler.OnTextEdited, this, &Canvas::OnEventTextEdited); + m_textEnteredSlot.Connect(eventHandler.OnTextEntered, this, &Canvas::OnEventTextEntered); + m_textEditedSlot.Connect(eventHandler.OnTextEdited, this, &Canvas::OnEventTextEdited); } inline Canvas::~Canvas() diff --git a/SDK/src/NDK/BaseWidget.cpp b/SDK/src/NDK/BaseWidget.cpp index ce900852a..03fb87e97 100644 --- a/SDK/src/NDK/BaseWidget.cpp +++ b/SDK/src/NDK/BaseWidget.cpp @@ -39,16 +39,16 @@ namespace Ndk } /*! - * \brief Frees the widget, unregistering it from its canvas - */ + * \brief Frees the widget, unregistering it from its canvas + */ BaseWidget::~BaseWidget() { UnregisterFromCanvas(); } /*! - * \brief Clears keyboard focus if and only if this widget owns it. - */ + * \brief Clears keyboard focus if and only if this widget owns it. + */ void BaseWidget::ClearFocus() { if (IsRegisteredToCanvas()) @@ -56,10 +56,10 @@ namespace Ndk } /*! - * \brief Destroy the widget, deleting it in the process. - * - * Calling this function immediately destroys the widget, freeing its memory. - */ + * \brief Destroy the widget, deleting it in the process. + * + * Calling this function immediately destroys the widget, freeing its memory. + */ void BaseWidget::Destroy() { NazaraAssert(this != m_canvas, "Canvas cannot be destroyed by calling Destroy()"); @@ -68,8 +68,8 @@ namespace Ndk } /*! - * \brief Enable or disables the widget background. - */ + * \brief Enable or disables the widget background. + */ void BaseWidget::EnableBackground(bool enable) { if (m_backgroundEntity.IsValid() == enable) @@ -95,9 +95,9 @@ namespace Ndk } /*! - * \brief Checks if this widget has keyboard focus - * \return true if widget has keyboard focus, false otherwise - */ + * \brief Checks if this widget has keyboard focus + * \return true if widget has keyboard focus, false otherwise + */ bool BaseWidget::HasFocus() const { if (!IsRegisteredToCanvas()) @@ -242,15 +242,15 @@ namespace Ndk void BaseWidget::OnParentResized(const Nz::Vector2f& /*newSize*/) { - } + } - void BaseWidget::OnTextEntered(char32_t /*character*/, bool /*repeated*/) + void BaseWidget::OnTextEntered(char32_t /*character*/, bool /*repeated*/) { } - void BaseWidget::OnTextEdited(const std::array& /*characters*/, int /*length*/) - { - } + void BaseWidget::OnTextEdited(const std::array& /*characters*/, int /*length*/) + { + } void BaseWidget::DestroyChild(BaseWidget* widget) { diff --git a/SDK/src/NDK/Canvas.cpp b/SDK/src/NDK/Canvas.cpp index aa1e83328..f628713e2 100644 --- a/SDK/src/NDK/Canvas.cpp +++ b/SDK/src/NDK/Canvas.cpp @@ -203,11 +203,11 @@ namespace Ndk { if (m_keyboardOwner != InvalidCanvasIndex) m_widgetEntries[m_keyboardOwner].widget->OnTextEntered(event.character, event.repeated); - } + } - void Canvas::OnEventTextEdited(const Nz::EventHandler* /*eventHandler*/, const Nz::WindowEvent::EditEvent& event) - { - if (m_keyboardOwner != InvalidCanvasIndex) - m_widgetEntries[m_keyboardOwner].widget->OnTextEdited(event.text, event.length); - } + void Canvas::OnEventTextEdited(const Nz::EventHandler* /*eventHandler*/, const Nz::WindowEvent::EditEvent& event) + { + if (m_keyboardOwner != InvalidCanvasIndex) + m_widgetEntries[m_keyboardOwner].widget->OnTextEdited(event.text, event.length); + } } diff --git a/examples/Textarea/build.lua b/examples/Textarea/build.lua deleted file mode 100644 index 3436aafef..000000000 --- a/examples/Textarea/build.lua +++ /dev/null @@ -1,15 +0,0 @@ -EXAMPLE.Name = "Textarea" - -EXAMPLE.EnableConsole = true - -EXAMPLE.Files = { - "main.cpp" -} - -EXAMPLE.Libraries = { - "NazaraSDK" -} - -if Config.PlatformSDL2 then - table.insert(EXAMPLE.Defines, "NAZARA_PLATFORM_SDL2") -end diff --git a/examples/Textarea/main.cpp b/examples/Textarea/main.cpp deleted file mode 100644 index 6726aa1f1..000000000 --- a/examples/Textarea/main.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// Sources pour https://github.com/DigitalPulseSoftware/NazaraEngine/wiki/(FR)-Tutoriel:-%5B01%5D-Hello-World - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -int main(int argc, char* argv[]) -{ - Ndk::Application application(argc, argv); - - Nz::RenderWindow& mainWindow = application.AddWindow(); - mainWindow.Create(Nz::VideoMode(800, 600, 32), "Test"); - - - Ndk::World& world = application.AddWorld(); - world.GetSystem().SetGlobalUp(Nz::Vector3f::Down()); - world.GetSystem().SetDefaultBackground(Nz::ColorBackground::New(Nz::Color(117, 122, 214))); - - - Ndk::EntityHandle viewEntity = world.CreateEntity(); - viewEntity->AddComponent(); - - Ndk::CameraComponent& viewer = viewEntity->AddComponent(); - viewer.SetTarget(&mainWindow); - viewer.SetProjectionType(Nz::ProjectionType_Orthogonal); - - Ndk::EntityHandle text = world.CreateEntity(); - Ndk::NodeComponent& nodeComponent = text->AddComponent(); - - Ndk::Canvas canvas(world.CreateHandle(), mainWindow.GetEventHandler(), mainWindow.GetCursorController().CreateHandle()); - canvas.SetFixedSize(Nz::Vector2f(mainWindow.GetSize())); - - auto textarea = canvas.Add(); - textarea->EnableBackground(true); - textarea->SetBackgroundColor(Nz::Color(0, 0, 0, 150)); - textarea->SetTextColor(Nz::Color::White); - textarea->EnableMultiline(); - - textarea->SetFixedSize(canvas.GetSize()/2); - - /*Nz::Boxf textBox = mainWindow.GetSize(); - Nz::Vector2ui windowSize = mainWindow.GetSize(); - nodeComponent.SetPosition(windowSize.x / 2 - textBox.width / 2, windowSize.y / 2 - textBox.height / 2);*/ - - while (application.Run()) - { - mainWindow.Display(); - } - - return EXIT_SUCCESS; -} diff --git a/include/Nazara/Platform/Enums.hpp b/include/Nazara/Platform/Enums.hpp index 6d0c560ab..2ec3c5bf3 100644 --- a/include/Nazara/Platform/Enums.hpp +++ b/include/Nazara/Platform/Enums.hpp @@ -51,10 +51,10 @@ namespace Nz WindowEventType_Moved, WindowEventType_Quit, WindowEventType_Resized, - WindowEventType_TextEdited, + WindowEventType_TextEdited, WindowEventType_TextEntered, - WindowEventType_Max = WindowEventType_TextEntered + WindowEventType_Max = WindowEventType_TextEntered }; enum WindowStyle diff --git a/include/Nazara/Platform/Event.hpp b/include/Nazara/Platform/Event.hpp index ab5e2a906..5c8dfd24f 100644 --- a/include/Nazara/Platform/Event.hpp +++ b/include/Nazara/Platform/Event.hpp @@ -82,15 +82,15 @@ namespace Nz { bool repeated; char32_t character; - }; + }; - // Used by: - // -WindowEventType_TextEdited - struct EditEvent - { - int length; - std::array text; - }; + // Used by: + // -WindowEventType_TextEdited + struct EditEvent + { + int length; + std::array text; + }; WindowEventType type; @@ -126,9 +126,9 @@ namespace Nz // -WindowEventType_TextEntered TextEvent text; - // Used by: - // -WindowEventType_TextEntered - EditEvent edit; + // Used by: + // -WindowEventType_TextEntered + EditEvent edit; }; }; } diff --git a/include/Nazara/Platform/EventHandler.hpp b/include/Nazara/Platform/EventHandler.hpp index e612823ec..be979e65e 100644 --- a/include/Nazara/Platform/EventHandler.hpp +++ b/include/Nazara/Platform/EventHandler.hpp @@ -48,8 +48,8 @@ namespace Nz NazaraSignal(OnMoved, const EventHandler* /*eventHandler*/, const WindowEvent::PositionEvent& /*event*/); NazaraSignal(OnQuit, const EventHandler* /*eventHandler*/); NazaraSignal(OnResized, const EventHandler* /*eventHandler*/, const WindowEvent::SizeEvent& /*event*/); - NazaraSignal(OnTextEntered, const EventHandler* /*eventHandler*/, const WindowEvent::TextEvent& /*event*/); - NazaraSignal(OnTextEdited, const EventHandler* /*eventHandler*/, const WindowEvent::EditEvent& /*event*/); + NazaraSignal(OnTextEntered, const EventHandler* /*eventHandler*/, const WindowEvent::TextEvent& /*event*/); + NazaraSignal(OnTextEdited, const EventHandler* /*eventHandler*/, const WindowEvent::EditEvent& /*event*/); }; } diff --git a/include/Nazara/Platform/EventHandler.inl b/include/Nazara/Platform/EventHandler.inl index 25f76a4ab..c3edc1cd2 100644 --- a/include/Nazara/Platform/EventHandler.inl +++ b/include/Nazara/Platform/EventHandler.inl @@ -79,9 +79,9 @@ namespace Nz OnTextEntered(this, event.text); break; - case WindowEventType_TextEdited: - OnTextEdited(this, event.edit); - break; + case WindowEventType_TextEdited: + OnTextEdited(this, event.edit); + break; } } } diff --git a/include/Nazara/Platform/Keyboard.hpp b/include/Nazara/Platform/Keyboard.hpp index 36d87d2ee..25bc19756 100644 --- a/include/Nazara/Platform/Keyboard.hpp +++ b/include/Nazara/Platform/Keyboard.hpp @@ -323,8 +323,8 @@ namespace Nz static String GetKeyName(VKey key); static bool IsKeyPressed(Scancode scancode); static bool IsKeyPressed(VKey key); - static void StartTextInput(); - static void StopTextInput(); + static void StartTextInput(); + static void StopTextInput(); static Scancode ToScanCode(VKey key); static VKey ToVirtualKey(Scancode key); }; diff --git a/src/Nazara/Platform/Keyboard.cpp b/src/Nazara/Platform/Keyboard.cpp index 7c68e5164..d2a287e32 100644 --- a/src/Nazara/Platform/Keyboard.cpp +++ b/src/Nazara/Platform/Keyboard.cpp @@ -38,15 +38,15 @@ namespace Nz return EventImpl::IsKeyPressed(key); } - void Keyboard::StartTextInput() - { - EventImpl::StartTextInput(); - } + void Keyboard::StartTextInput() + { + EventImpl::StartTextInput(); + } - void Keyboard::StopTextInput() - { - EventImpl::StopTextInput(); - } + void Keyboard::StopTextInput() + { + EventImpl::StopTextInput(); + } Keyboard::Scancode Keyboard::ToScanCode(VKey key) { diff --git a/src/Nazara/Platform/SDL2/InputImpl.cpp b/src/Nazara/Platform/SDL2/InputImpl.cpp index 9daba650d..9bf2fd40f 100644 --- a/src/Nazara/Platform/SDL2/InputImpl.cpp +++ b/src/Nazara/Platform/SDL2/InputImpl.cpp @@ -100,15 +100,15 @@ namespace Nz NazaraError("Invalid window handle"); } - void EventImpl::StartTextInput() - { - SDL_StartTextInput(); - } + void EventImpl::StartTextInput() + { + SDL_StartTextInput(); + } - void EventImpl::StopTextInput() - { - SDL_StopTextInput(); - } + void EventImpl::StopTextInput() + { + SDL_StopTextInput(); + } Keyboard::Scancode EventImpl::ToScanCode(Keyboard::VKey key) { diff --git a/src/Nazara/Platform/SDL2/InputImpl.hpp b/src/Nazara/Platform/SDL2/InputImpl.hpp index 8aca56985..568acb755 100644 --- a/src/Nazara/Platform/SDL2/InputImpl.hpp +++ b/src/Nazara/Platform/SDL2/InputImpl.hpp @@ -26,8 +26,8 @@ namespace Nz static bool IsMouseButtonPressed(Mouse::Button button); static void SetMousePosition(int x, int y); static void SetMousePosition(int x, int y, const Window& relativeTo); - static void StartTextInput(); - static void StopTextInput(); + static void StartTextInput(); + static void StopTextInput(); static Keyboard::Scancode ToScanCode(Keyboard::VKey key); static Keyboard::VKey ToVirtualKey(Keyboard::Scancode scancode); }; diff --git a/src/Nazara/Platform/SDL2/WindowImpl.cpp b/src/Nazara/Platform/SDL2/WindowImpl.cpp index 3462a1c09..2db2b55be 100644 --- a/src/Nazara/Platform/SDL2/WindowImpl.cpp +++ b/src/Nazara/Platform/SDL2/WindowImpl.cpp @@ -2,8 +2,6 @@ // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp -// Un grand merci à Laurent Gomila pour la SFML qui m'aura bien aidé à réaliser cette implémentation - #include #include #include @@ -278,10 +276,10 @@ namespace Nz case SDL_WINDOWEVENT_RESIZED: evt.type = Nz::WindowEventType::WindowEventType_Resized; - evt.size.width = static_cast(std::max(0, event->window.data1)); - evt.size.height = static_cast(std::max(0, event->window.data2)); + evt.size.width = static_cast(std::max(0, event->window.data1)); + evt.size.height = static_cast(std::max(0, event->window.data2)); - window->m_size.Set(evt.size.width, evt.size.height); + window->m_size.Set(evt.size.width, evt.size.height); break; case SDL_WINDOWEVENT_MOVED: @@ -387,38 +385,36 @@ namespace Nz evt.key.shift = (event->key.keysym.mod & KMOD_SHIFT) != 0; evt.key.system = (event->key.keysym.mod & KMOD_GUI) != 0; - // implements X11/Win32 APIs behavior for Enter and Backspace - switch (evt.key.virtualKey) { - case Nz::Keyboard::VKey::NumpadReturn: - case Nz::Keyboard::VKey::Return: - if (window->m_lastEditEventLength != 0) - { - break; - } - window->m_parent->PushEvent(evt); + // implements X11/Win32 APIs behavior for Enter and Backspace + switch (evt.key.virtualKey) { + case Nz::Keyboard::VKey::NumpadReturn: + case Nz::Keyboard::VKey::Return: + if (window->m_lastEditEventLength != 0) + break; + window->m_parent->PushEvent(evt); - evt.type = WindowEventType_TextEntered; + evt.type = WindowEventType_TextEntered; - evt.text.character = U'\n'; - evt.text.repeated = event->key.repeat != 0; + evt.text.character = U'\n'; + evt.text.repeated = event->key.repeat != 0; - window->m_parent->PushEvent(evt); + window->m_parent->PushEvent(evt); - break; - case Nz::Keyboard::VKey::Backspace: - window->m_parent->PushEvent(evt); + break; + case Nz::Keyboard::VKey::Backspace: + window->m_parent->PushEvent(evt); - evt.type = WindowEventType_TextEntered; + evt.type = WindowEventType_TextEntered; - evt.text.character = U'\b'; - evt.text.repeated = event->key.repeat != 0; + evt.text.character = U'\b'; + evt.text.repeated = event->key.repeat != 0; - window->m_parent->PushEvent(evt); + window->m_parent->PushEvent(evt); - break; - default: - break; - } + break; + default: + break; + } break; @@ -443,42 +439,42 @@ namespace Nz return 0; evt.type = WindowEventType_TextEntered; - evt.text.repeated = false; + evt.text.repeated = false; - for (decltype(evt.text.character)codepoint : String::Unicode(event->text.text).Simplify().GetUtf32String()) + for (decltype(evt.text.character) codepoint : String::Unicode(event->text.text).Simplify().GetUtf32String()) { - evt.text.character = codepoint; + evt.text.character = codepoint; window->m_parent->PushEvent(evt); } // prevent post switch event - evt.type = WindowEventType::WindowEventType_Max; + evt.type = WindowEventType::WindowEventType_Max; - break; + break; - case SDL_TEXTEDITING: - if (SDL_GetWindowID(window->m_handle) != event->edit.windowID) - return 0; + case SDL_TEXTEDITING: + if (SDL_GetWindowID(window->m_handle) != event->edit.windowID) + return 0; - evt.type = WindowEventType_TextEdited; - evt.edit.length = event->edit.length; - window->m_lastEditEventLength = evt.edit.length; + evt.type = WindowEventType_TextEdited; + evt.edit.length = event->edit.length; + window->m_lastEditEventLength = evt.edit.length; - for (std::size_t i = 0; i < 32; i++) - { - evt.edit.text[i] = event->edit.text[i]; - } + for (std::size_t i = 0; i < 32; i++) + { + evt.edit.text[i] = event->edit.text[i]; + } - break; + break; } if (evt.type != WindowEventType::WindowEventType_Max) window->m_parent->PushEvent(evt); } catch (std::exception e) - { - NazaraError(e.what()); + { + NazaraError(e.what()); } catch (...) // Don't let any exceptions go thru C calls { @@ -560,11 +556,11 @@ namespace Nz } bool WindowImpl::Initialize() - { + { if (SDL_Init(SDL_INIT_VIDEO) < 0) { NazaraError(SDL_GetError()); - return false; + return false; } if (SDL_GL_LoadLibrary(nullptr) < 0) { @@ -572,7 +568,7 @@ namespace Nz SDL_Quit(); return false; - } + } if (SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, true) < 0) NazaraError("Couldn't set share OpenGL contexes"); diff --git a/src/Nazara/Platform/SDL2/WindowImpl.hpp b/src/Nazara/Platform/SDL2/WindowImpl.hpp index 0ff3206ae..8d960eaff 100644 --- a/src/Nazara/Platform/SDL2/WindowImpl.hpp +++ b/src/Nazara/Platform/SDL2/WindowImpl.hpp @@ -87,7 +87,7 @@ namespace Nz //static void WindowThread(SDL_Window* handle, /*DWORD styleEx,*/ const String& title, /*DWORD style,*/ bool fullscreen, const Rectui& dimensions, WindowImpl* window, Mutex* mutex, ConditionVariable* condition); - int m_lastEditEventLength = 0; + int m_lastEditEventLength = 0; SDL_Cursor* m_cursor; SDL_Window* m_handle; WindowStyleFlags m_style; diff --git a/src/Nazara/Renderer/OpenGL.cpp b/src/Nazara/Renderer/OpenGL.cpp index 993add34b..79685d25a 100644 --- a/src/Nazara/Renderer/OpenGL.cpp +++ b/src/Nazara/Renderer/OpenGL.cpp @@ -744,10 +744,9 @@ namespace Nz #if defined(NAZARA_PLATFORM_SDL2) - if (SDL_VideoInit(NULL) != 0) - { - NazaraError(SDL_GetError()); - } + if (SDL_VideoInit(NULL) != 0) + NazaraError(SDL_GetError()); + #elif defined(NAZARA_PLATFORM_GLX) Initializer display; if (!display) From d892e8eaff79b7e6a2d4c7fc3ffbed49b649a845 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 26 Mar 2020 20:42:57 +0100 Subject: [PATCH 130/316] Add support for Vulkan 1.1 & 1.2 --- include/Nazara/VulkanRenderer/Vulkan.hpp | 2 +- .../Nazara/VulkanRenderer/VulkanRenderer.hpp | 2 +- .../Wrapper/DeviceFunctions.hpp | 6 +++ .../Wrapper/GlobalFunctions.hpp | 9 ++++ .../VulkanRenderer/Wrapper/Instance.hpp | 20 ++++---- .../VulkanRenderer/Wrapper/Instance.inl | 19 +++++--- .../Wrapper/InstanceFunctions.hpp | 8 ++++ .../Nazara/VulkanRenderer/Wrapper/Loader.hpp | 13 +++--- src/Nazara/VulkanRenderer/Vulkan.cpp | 29 ++++++++++-- src/Nazara/VulkanRenderer/Wrapper/Device.cpp | 15 +++++- .../VulkanRenderer/Wrapper/Instance.cpp | 19 ++++++-- src/Nazara/VulkanRenderer/Wrapper/Loader.cpp | 46 ++++++++++++++----- 12 files changed, 143 insertions(+), 45 deletions(-) create mode 100644 include/Nazara/VulkanRenderer/Wrapper/GlobalFunctions.hpp diff --git a/include/Nazara/VulkanRenderer/Vulkan.hpp b/include/Nazara/VulkanRenderer/Vulkan.hpp index bffff2e1a..f3c40959c 100644 --- a/include/Nazara/VulkanRenderer/Vulkan.hpp +++ b/include/Nazara/VulkanRenderer/Vulkan.hpp @@ -44,7 +44,7 @@ namespace Nz static const std::vector& GetPhysicalDevices(); static const Vk::PhysicalDevice& GetPhysicalDeviceInfo(VkPhysicalDevice physDevice); - static bool Initialize(UInt32 apiVersion, const ParameterList& parameters); + static bool Initialize(UInt32 targetApiVersion, const ParameterList& parameters); static bool IsInitialized(); diff --git a/include/Nazara/VulkanRenderer/VulkanRenderer.hpp b/include/Nazara/VulkanRenderer/VulkanRenderer.hpp index 62bd426ca..2d7b2f779 100644 --- a/include/Nazara/VulkanRenderer/VulkanRenderer.hpp +++ b/include/Nazara/VulkanRenderer/VulkanRenderer.hpp @@ -39,7 +39,7 @@ namespace Nz bool Prepare(const ParameterList& parameters) override; - static constexpr UInt32 APIVersion = VK_API_VERSION_1_0; + static constexpr UInt32 APIVersion = VK_API_VERSION_1_2; private: std::list m_devices; diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceFunctions.hpp b/include/Nazara/VulkanRenderer/Wrapper/DeviceFunctions.hpp index 2b3b03564..6c76c4e7e 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceFunctions.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceFunctions.hpp @@ -119,6 +119,12 @@ NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkUnmapMemory) NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkUpdateDescriptorSets) NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkWaitForFences) +NAZARA_VULKANRENDERER_DEVICE_CORE_EXT_FUNCTION(vkBindBufferMemory2, VK_API_VERSION_1_1, KHR, bind_memory2) +NAZARA_VULKANRENDERER_DEVICE_CORE_EXT_FUNCTION(vkBindImageMemory2, VK_API_VERSION_1_1, KHR, bind_memory2) + +NAZARA_VULKANRENDERER_DEVICE_CORE_EXT_FUNCTION(vkGetBufferMemoryRequirements2, VK_API_VERSION_1_1, KHR, get_memory_requirements2) +NAZARA_VULKANRENDERER_DEVICE_CORE_EXT_FUNCTION(vkGetImageMemoryRequirements2, VK_API_VERSION_1_1, KHR, get_memory_requirements2) + NAZARA_VULKANRENDERER_DEVICE_EXT_BEGIN(VK_KHR_display_swapchain) NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCreateSharedSwapchainsKHR) NAZARA_VULKANRENDERER_DEVICE_EXT_END() diff --git a/include/Nazara/VulkanRenderer/Wrapper/GlobalFunctions.hpp b/include/Nazara/VulkanRenderer/Wrapper/GlobalFunctions.hpp new file mode 100644 index 000000000..a1ee8a8dc --- /dev/null +++ b/include/Nazara/VulkanRenderer/Wrapper/GlobalFunctions.hpp @@ -0,0 +1,9 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +// Vulkan core +NAZARA_VULKANRENDERER_GLOBAL_FUNCTION(vkCreateInstance) +NAZARA_VULKANRENDERER_GLOBAL_FUNCTION(vkEnumerateInstanceExtensionProperties) +NAZARA_VULKANRENDERER_GLOBAL_FUNCTION(vkEnumerateInstanceLayerProperties) +NAZARA_VULKANRENDERER_GLOBAL_FUNCTION_OPT(vkEnumerateInstanceVersion) diff --git a/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp b/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp index 5ec96ec0d..3d3e86df8 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp @@ -8,10 +8,10 @@ #define NAZARA_VULKANRENDERER_VKINSTANCE_HPP #include -#include #include #include #include +#include #include namespace Nz @@ -27,13 +27,16 @@ namespace Nz 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 bool Create(const std::string& appName, UInt32 appVersion, const std::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 UInt32 GetApiVersion() const; + inline VkResult GetLastErrorCode() const; + bool GetPhysicalDeviceExtensions(VkPhysicalDevice device, std::vector* extensionProperties); inline VkPhysicalDeviceFeatures GetPhysicalDeviceFeatures(VkPhysicalDevice device); inline VkFormatProperties GetPhysicalDeviceFormatProperties(VkPhysicalDevice device, VkFormat format); @@ -42,10 +45,8 @@ namespace Nz inline VkPhysicalDeviceProperties GetPhysicalDeviceProperties(VkPhysicalDevice device); bool GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice device, std::vector* queueFamilyProperties); - inline VkResult GetLastErrorCode() const; - - inline bool IsExtensionLoaded(const String& extensionName); - inline bool IsLayerLoaded(const String& layerName); + inline bool IsExtensionLoaded(const std::string& extensionName); + inline bool IsLayerLoaded(const std::string& layerName); inline bool IsValid() const; Instance& operator=(const Instance&) = delete; @@ -57,9 +58,11 @@ namespace Nz #define NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(ext) #define NAZARA_VULKANRENDERER_INSTANCE_EXT_END() #define NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(func) PFN_##func func; +#define NAZARA_VULKANRENDERER_INSTANCE_CORE_EXT_FUNCTION(func, ...) NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(func) #include +#undef NAZARA_VULKANRENDERER_INSTANCE_CORE_EXT_FUNCTION #undef NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN #undef NAZARA_VULKANRENDERER_INSTANCE_EXT_END #undef NAZARA_VULKANRENDERER_INSTANCE_FUNCTION @@ -73,8 +76,9 @@ namespace Nz VkAllocationCallbacks m_allocator; VkInstance m_instance; VkResult m_lastErrorCode; - std::unordered_set m_loadedExtensions; - std::unordered_set m_loadedLayers; + UInt32 m_apiVersion; + std::unordered_set m_loadedExtensions; + std::unordered_set m_loadedLayers; }; } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/Instance.inl b/include/Nazara/VulkanRenderer/Wrapper/Instance.inl index 50feca010..64224d746 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Instance.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Instance.inl @@ -23,15 +23,15 @@ namespace Nz DestroyInstance(); } - 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) + inline bool Instance::Create(const std::string& appName, UInt32 appVersion, const std::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(), + appName.data(), appVersion, - engineName.GetConstBuffer(), + engineName.data(), engineVersion }; @@ -63,22 +63,27 @@ namespace Nz { PFN_vkVoidFunction func = vkGetDeviceProcAddr(device, name); if (!func) - NazaraError("Failed to get " + String(name) + " address"); + NazaraError("Failed to get " + std::string(name) + " address"); return func; } + inline UInt32 Instance::GetApiVersion() const + { + return m_apiVersion; + } + inline VkResult Instance::GetLastErrorCode() const { return m_lastErrorCode; } - inline bool Instance::IsExtensionLoaded(const String& extensionName) + inline bool Instance::IsExtensionLoaded(const std::string& extensionName) { return m_loadedExtensions.count(extensionName) > 0; } - inline bool Instance::IsLayerLoaded(const String& layerName) + inline bool Instance::IsLayerLoaded(const std::string& layerName) { return m_loadedLayers.count(layerName) > 0; } @@ -149,7 +154,7 @@ namespace Nz { PFN_vkVoidFunction func = Loader::GetInstanceProcAddr(m_instance, name); if (!func) - NazaraError("Failed to get " + String(name) + " address"); + NazaraError("Failed to get " + std::string(name) + " address"); return func; } diff --git a/include/Nazara/VulkanRenderer/Wrapper/InstanceFunctions.hpp b/include/Nazara/VulkanRenderer/Wrapper/InstanceFunctions.hpp index a08459ba5..25e9235c0 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/InstanceFunctions.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/InstanceFunctions.hpp @@ -15,6 +15,14 @@ NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceMemoryProperties) NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceProperties) NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceQueueFamilyProperties) +NAZARA_VULKANRENDERER_INSTANCE_CORE_EXT_FUNCTION(vkGetPhysicalDeviceFeatures2, VK_API_VERSION_1_1, KHR, get_physical_device_properties2) +NAZARA_VULKANRENDERER_INSTANCE_CORE_EXT_FUNCTION(vkGetPhysicalDeviceProperties2, VK_API_VERSION_1_1, KHR, get_physical_device_properties2) +NAZARA_VULKANRENDERER_INSTANCE_CORE_EXT_FUNCTION(vkGetPhysicalDeviceFormatProperties2, VK_API_VERSION_1_1, KHR, get_physical_device_properties2) +NAZARA_VULKANRENDERER_INSTANCE_CORE_EXT_FUNCTION(vkGetPhysicalDeviceImageFormatProperties2, VK_API_VERSION_1_1, KHR, get_physical_device_properties2) +NAZARA_VULKANRENDERER_INSTANCE_CORE_EXT_FUNCTION(vkGetPhysicalDeviceQueueFamilyProperties2, VK_API_VERSION_1_1, KHR, get_physical_device_properties2) +NAZARA_VULKANRENDERER_INSTANCE_CORE_EXT_FUNCTION(vkGetPhysicalDeviceMemoryProperties2, VK_API_VERSION_1_1, KHR, get_physical_device_properties2) +NAZARA_VULKANRENDERER_INSTANCE_CORE_EXT_FUNCTION(vkGetPhysicalDeviceSparseImageFormatProperties2, VK_API_VERSION_1_1, KHR, get_physical_device_properties2) + NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(VK_KHR_display) NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateDisplayModeKHR) NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateDisplayPlaneSurfaceKHR) diff --git a/include/Nazara/VulkanRenderer/Wrapper/Loader.hpp b/include/Nazara/VulkanRenderer/Wrapper/Loader.hpp index c4d584132..5a0e77e45 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Loader.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Loader.hpp @@ -31,14 +31,15 @@ namespace Nz static void Uninitialize(); // Vulkan functions - #define NAZARA_VULKANRENDERER_GLOBAL_FUNCTION(func) static PFN_##func func + static PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr; - NAZARA_VULKANRENDERER_GLOBAL_FUNCTION(vkCreateInstance); - NAZARA_VULKANRENDERER_GLOBAL_FUNCTION(vkEnumerateInstanceExtensionProperties); - NAZARA_VULKANRENDERER_GLOBAL_FUNCTION(vkEnumerateInstanceLayerProperties); - NAZARA_VULKANRENDERER_GLOBAL_FUNCTION(vkGetInstanceProcAddr); +#define NAZARA_VULKANRENDERER_GLOBAL_FUNCTION(func) static PFN_##func func; +#define NAZARA_VULKANRENDERER_GLOBAL_FUNCTION_OPT NAZARA_VULKANRENDERER_GLOBAL_FUNCTION - #undef NAZARA_VULKANRENDERER_GLOBAL_FUNCTION +#include + +#undef NAZARA_VULKANRENDERER_GLOBAL_FUNCTION_OPT +#undef NAZARA_VULKANRENDERER_GLOBAL_FUNCTION private: static DynLib s_vulkanLib; diff --git a/src/Nazara/VulkanRenderer/Vulkan.cpp b/src/Nazara/VulkanRenderer/Vulkan.cpp index a3bab8bbf..49dffd8b6 100644 --- a/src/Nazara/VulkanRenderer/Vulkan.cpp +++ b/src/Nazara/VulkanRenderer/Vulkan.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include namespace Nz @@ -40,7 +41,7 @@ namespace Nz return dummy; } - bool Vulkan::Initialize(UInt32 apiVersion, const ParameterList& parameters) + bool Vulkan::Initialize(UInt32 targetApiVersion, const ParameterList& parameters) { NazaraAssert(!IsInitialized(), "Vulkan is already initialized"); @@ -66,7 +67,7 @@ namespace Nz long long iParam; if (parameters.GetIntegerParameter("VkAppInfo_OverrideAPIVersion", &iParam)) - apiVersion = static_cast(iParam); + targetApiVersion = static_cast(iParam); if (parameters.GetIntegerParameter("VkAppInfo_OverrideApplicationVersion", &iParam)) appVersion = static_cast(iParam); @@ -74,6 +75,17 @@ namespace Nz if (parameters.GetIntegerParameter("VkAppInfo_OverrideEngineVersion", &iParam)) engineVersion = static_cast(iParam); + if (Vk::Loader::vkEnumerateInstanceVersion) + { + UInt32 supportedApiVersion; + Vk::Loader::vkEnumerateInstanceVersion(&supportedApiVersion); + + targetApiVersion = std::min(targetApiVersion, supportedApiVersion); + } + else + // vkEnumerateInstanceVersion is available from Vulkan 1.1, fallback to 1.0 if not supported + targetApiVersion = VK_API_VERSION_1_0; + VkApplicationInfo appInfo = { VK_STRUCTURE_TYPE_APPLICATION_INFO, nullptr, @@ -81,7 +93,7 @@ namespace Nz appVersion, engineName.GetConstBuffer(), engineVersion, - apiVersion + targetApiVersion }; VkInstanceCreateFlags createFlags = 0; @@ -115,6 +127,15 @@ namespace Nz } } + // Get extension list + std::unordered_set availableExtensions; + std::vector extensionList; + if (Vk::Loader::EnumerateInstanceExtensionProperties(&extensionList)) + { + for (VkExtensionProperties& extProperty : extensionList) + availableExtensions.insert(extProperty.extensionName); + } + if (!parameters.GetBooleanParameter("VkInstanceInfo_OverrideEnabledExtensions", &bParam) || !bParam) { enabledExtensions.push_back("VK_KHR_surface"); @@ -401,7 +422,7 @@ namespace Nz if (!s_initializationParameters.GetBooleanParameter("VkDeviceInfo_OverrideEnabledExtensions", &bParam) || !bParam) { // Swapchain extension is required for rendering - enabledExtensions.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME); + enabledExtensions.emplace_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME); } diff --git a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp index 4c566fb30..29bd02b86 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp @@ -69,12 +69,21 @@ namespace Nz { ErrorFlags flags(ErrorFlag_ThrowException, true); + UInt32 deviceVersion = deviceInfo.properties.apiVersion; + #define NAZARA_VULKANRENDERER_DEVICE_EXT_BEGIN(ext) if (IsExtensionLoaded(#ext)) { #define NAZARA_VULKANRENDERER_DEVICE_EXT_END() } #define NAZARA_VULKANRENDERER_DEVICE_FUNCTION(func) func = reinterpret_cast(GetProcAddr(#func)); +#define NAZARA_VULKANRENDERER_DEVICE_CORE_EXT_FUNCTION(func, coreVersion, suffix, extName) \ + if (deviceVersion >= coreVersion) \ + func = reinterpret_cast(GetProcAddr(#func)); \ + else if (IsExtensionLoaded("VK_" #suffix "_" #extName)) \ + func = reinterpret_cast(GetProcAddr(#func #suffix)); + #include +#undef NAZARA_VULKANRENDERER_DEVICE_CORE_EXT_FUNCTION #undef NAZARA_VULKANRENDERER_DEVICE_EXT_BEGIN #undef NAZARA_VULKANRENDERER_DEVICE_EXT_END #undef NAZARA_VULKANRENDERER_DEVICE_FUNCTION @@ -164,15 +173,17 @@ namespace Nz m_physicalDevice = nullptr; // Reset functions pointers +#define NAZARA_VULKANRENDERER_DEVICE_FUNCTION(func) func = nullptr; +#define NAZARA_VULKANRENDERER_DEVICE_CORE_EXT_FUNCTION(func, ...) NAZARA_VULKANRENDERER_DEVICE_FUNCTION(func) #define NAZARA_VULKANRENDERER_DEVICE_EXT_BEGIN(ext) #define NAZARA_VULKANRENDERER_DEVICE_EXT_END() -#define NAZARA_VULKANRENDERER_DEVICE_FUNCTION(func) func = nullptr; #include +#undef NAZARA_VULKANRENDERER_DEVICE_CORE_EXT_FUNCTION +#undef NAZARA_VULKANRENDERER_DEVICE_FUNCTION #undef NAZARA_VULKANRENDERER_DEVICE_EXT_BEGIN #undef NAZARA_VULKANRENDERER_DEVICE_EXT_END -#undef NAZARA_VULKANRENDERER_DEVICE_FUNCTION } void Device::WaitAndDestroyDevice() diff --git a/src/Nazara/VulkanRenderer/Wrapper/Instance.cpp b/src/Nazara/VulkanRenderer/Wrapper/Instance.cpp index e70f2ef9d..8d88817a4 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/Instance.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Instance.cpp @@ -21,6 +21,8 @@ namespace Nz return false; } + m_apiVersion = createInfo.pApplicationInfo->apiVersion; + // Store the allocator to access them when needed if (allocator) m_allocator = *allocator; @@ -43,15 +45,22 @@ namespace Nz #define NAZARA_VULKANRENDERER_INSTANCE_EXT_END() } #define NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(func) func = reinterpret_cast(GetProcAddr(#func)); +#define NAZARA_VULKANRENDERER_INSTANCE_CORE_EXT_FUNCTION(func, coreVersion, suffix, extName) \ + if (m_apiVersion >= coreVersion) \ + func = reinterpret_cast(GetProcAddr(#func)); \ + else if (IsExtensionLoaded("VK_" #suffix "_" #extName)) \ + func = reinterpret_cast(GetProcAddr(#func #suffix)); + #include +#undef NAZARA_VULKANRENDERER_INSTANCE_CORE_EXT_FUNCTION #undef NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN #undef NAZARA_VULKANRENDERER_INSTANCE_EXT_END #undef NAZARA_VULKANRENDERER_INSTANCE_FUNCTION } catch (const std::exception& e) { - NazaraError(String("Failed to query instance function: ") + e.what()); + NazaraError(std::string("Failed to query instance function: ") + e.what()); return false; } @@ -87,8 +96,8 @@ namespace Nz { NazaraAssert(extensionProperties, "Invalid extension properties vector"); - // First, query physical device count - UInt32 extensionPropertyCount = 0; // Remember, Nz::UInt32 is a typedef on uint32_t + // First, query extension count + UInt32 extensionPropertyCount = 0; m_lastErrorCode = vkEnumerateDeviceExtensionProperties(device, nullptr, &extensionPropertyCount, nullptr); if (m_lastErrorCode != VkResult::VK_SUCCESS) { @@ -99,7 +108,7 @@ namespace Nz if (extensionPropertyCount == 0) return true; //< No extension available - // Now we can get the list of the available physical device + // Now we can get the list of the available extensions extensionProperties->resize(extensionPropertyCount); m_lastErrorCode = vkEnumerateDeviceExtensionProperties(device, nullptr, &extensionPropertyCount, extensionProperties->data()); if (m_lastErrorCode != VkResult::VK_SUCCESS) @@ -139,9 +148,11 @@ namespace Nz #define NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(ext) #define NAZARA_VULKANRENDERER_INSTANCE_EXT_END() #define NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(func) func = nullptr; +#define NAZARA_VULKANRENDERER_INSTANCE_CORE_EXT_FUNCTION(func, ...) NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(func) #include +#undef NAZARA_VULKANRENDERER_INSTANCE_CORE_EXT_FUNCTION #undef NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN #undef NAZARA_VULKANRENDERER_INSTANCE_EXT_END #undef NAZARA_VULKANRENDERER_INSTANCE_FUNCTION diff --git a/src/Nazara/VulkanRenderer/Wrapper/Loader.cpp b/src/Nazara/VulkanRenderer/Wrapper/Loader.cpp index fd7aed2ac..89a6843de 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/Loader.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Loader.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -77,7 +78,7 @@ namespace Nz return false; } - // vkGetInstanceProcAddr is the only function that's garantee to be exported + // vkGetInstanceProcAddr is the only function that's guarantee to be exported vkGetInstanceProcAddr = reinterpret_cast(s_vulkanLib.GetSymbol("vkGetInstanceProcAddr")); if (!vkGetInstanceProcAddr) { @@ -85,28 +86,49 @@ namespace Nz return false; } + auto GetProcAddr = [&](const char* name, bool opt) + { + PFN_vkVoidFunction func = vkGetInstanceProcAddr(nullptr, name); + if (!func && !opt) + NazaraError("Failed to get " + std::string(name) + " address"); + + return func; + }; + // all other functions should be loaded using vkGetInstanceProcAddr - #define NAZARA_VULKANRENDERER_LOAD_GLOBAL(func) func = reinterpret_cast(vkGetInstanceProcAddr(nullptr, #func)) + #define NAZARA_VULKANRENDERER_LOAD_GLOBAL(func) func = reinterpret_cast(GetProcAddr(#func)) + try + { + ErrorFlags flags(ErrorFlag_ThrowException, true); - NAZARA_VULKANRENDERER_LOAD_GLOBAL(vkCreateInstance); - NAZARA_VULKANRENDERER_LOAD_GLOBAL(vkEnumerateInstanceExtensionProperties); - NAZARA_VULKANRENDERER_LOAD_GLOBAL(vkEnumerateInstanceLayerProperties); +#define NAZARA_VULKANRENDERER_GLOBAL_FUNCTION(func) func = reinterpret_cast(GetProcAddr(#func, false)); +#define NAZARA_VULKANRENDERER_GLOBAL_FUNCTION_OPT(func) func = reinterpret_cast(GetProcAddr(#func, true)); - #undef NAZARA_VULKANRENDERER_LOAD_GLOBAL +#include + +#undef NAZARA_VULKANRENDERER_GLOBAL_FUNCTION_OPT +#undef NAZARA_VULKANRENDERER_GLOBAL_FUNCTION + } + catch (const std::exception& e) + { + NazaraError(std::string("Failed to query device function: ") + e.what()); + return false; + } s_lastErrorCode = VkResult::VK_SUCCESS; return true; } - #define NAZARA_VULKANRENDERER_GLOBAL_FUNCTION_IMPL(func) PFN_##func Loader::func = nullptr + PFN_vkGetInstanceProcAddr Loader::vkGetInstanceProcAddr = nullptr; - NAZARA_VULKANRENDERER_GLOBAL_FUNCTION_IMPL(vkCreateInstance); - NAZARA_VULKANRENDERER_GLOBAL_FUNCTION_IMPL(vkEnumerateInstanceExtensionProperties); - NAZARA_VULKANRENDERER_GLOBAL_FUNCTION_IMPL(vkEnumerateInstanceLayerProperties); - NAZARA_VULKANRENDERER_GLOBAL_FUNCTION_IMPL(vkGetInstanceProcAddr); +#define NAZARA_VULKANRENDERER_GLOBAL_FUNCTION(func) PFN_##func Loader::func = nullptr; +#define NAZARA_VULKANRENDERER_GLOBAL_FUNCTION_OPT NAZARA_VULKANRENDERER_GLOBAL_FUNCTION - #undef NAZARA_VULKANRENDERER_GLOBAL_FUNCTION_IMPL +#include + +#undef NAZARA_VULKANRENDERER_GLOBAL_FUNCTION_OPT +#undef NAZARA_VULKANRENDERER_GLOBAL_FUNCTION DynLib Loader::s_vulkanLib; VkResult Loader::s_lastErrorCode; From 91a5e70ac5b5ba8b8b42262a6737409a87f868ba Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 26 Mar 2020 20:43:30 +0100 Subject: [PATCH 131/316] Fix global headers --- build/scripts/actions/generateheaders.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/build/scripts/actions/generateheaders.lua b/build/scripts/actions/generateheaders.lua index 81536a706..c8e90ebe0 100644 --- a/build/scripts/actions/generateheaders.lua +++ b/build/scripts/actions/generateheaders.lua @@ -45,6 +45,7 @@ ACTION.Function = function () table.insert(paths, { Excludes = { ["DeviceFunctions.hpp"] = true, + ["GlobalFunctions.hpp"] = true, ["InstanceFunctions.hpp"] = true, }, HeaderGuard = "NAZARA_GLOBAL_VULKANRENDERER_WRAPPER_HPP", From e53e15d1aaa90da1d64a9f02cd15ca55101acf6d Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 26 Mar 2020 21:09:58 +0100 Subject: [PATCH 132/316] Split CommandBuffer into Auto and normal variants --- include/Nazara/VulkanRenderer/Wrapper.hpp | 1 + .../VulkanRenderer/Wrapper/AutoFree.hpp | 42 +++++++++++++ .../VulkanRenderer/Wrapper/AutoFree.inl | 60 +++++++++++++++++++ .../VulkanRenderer/Wrapper/CommandBuffer.hpp | 11 +++- .../VulkanRenderer/Wrapper/CommandBuffer.inl | 5 -- .../VulkanRenderer/Wrapper/DescriptorSet.hpp | 12 +++- .../VulkanRenderer/Wrapper/DescriptorSet.inl | 5 -- 7 files changed, 123 insertions(+), 13 deletions(-) create mode 100644 include/Nazara/VulkanRenderer/Wrapper/AutoFree.hpp create mode 100644 include/Nazara/VulkanRenderer/Wrapper/AutoFree.inl diff --git a/include/Nazara/VulkanRenderer/Wrapper.hpp b/include/Nazara/VulkanRenderer/Wrapper.hpp index 1ae7ed140..846542a50 100644 --- a/include/Nazara/VulkanRenderer/Wrapper.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper.hpp @@ -5,6 +5,7 @@ #ifndef NAZARA_GLOBAL_VULKANRENDERER_WRAPPER_HPP #define NAZARA_GLOBAL_VULKANRENDERER_WRAPPER_HPP +#include #include #include #include diff --git a/include/Nazara/VulkanRenderer/Wrapper/AutoFree.hpp b/include/Nazara/VulkanRenderer/Wrapper/AutoFree.hpp new file mode 100644 index 000000000..68ce8b48a --- /dev/null +++ b/include/Nazara/VulkanRenderer/Wrapper/AutoFree.hpp @@ -0,0 +1,42 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VKAUTOFREE_HPP +#define NAZARA_VULKANRENDERER_VKAUTOFREE_HPP + +#include + +namespace Nz::Vk +{ + template + class AutoFree + { + public: + template AutoFree(Args&&... args); + AutoFree(const AutoFree&) = default; + AutoFree(AutoFree&&) = default; + ~AutoFree(); + + T& Get(); + const T& Get() const; + + T* operator->(); + const T* operator->() const; + + operator T&(); + operator const T&() const; + + AutoFree& operator=(const AutoFree&) = delete; + AutoFree& operator=(AutoFree&&) = default; + + private: + T m_object; + }; +} + +#include + +#endif // NAZARA_VULKANRENDERER_VKAUTOFREE_HPP diff --git a/include/Nazara/VulkanRenderer/Wrapper/AutoFree.inl b/include/Nazara/VulkanRenderer/Wrapper/AutoFree.inl new file mode 100644 index 000000000..8e0781406 --- /dev/null +++ b/include/Nazara/VulkanRenderer/Wrapper/AutoFree.inl @@ -0,0 +1,60 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz::Vk +{ + template + template + AutoFree::AutoFree(Args&&... args) : + m_object(std::forward(args)...) + { + } + + template + AutoFree::~AutoFree() + { + m_object.Free(); + } + + template + T& AutoFree::Get() + { + return m_object; + } + + template + const T& AutoFree::Get() const + { + return m_object; + } + + template + T* AutoFree::operator->() + { + return &m_object; + } + + template + const T* AutoFree::operator->() const + { + return &m_object; + } + + template + AutoFree::operator T&() + { + return Get(); + } + + template + AutoFree::operator const T&() const + { + return Get(); + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp index 52e457236..8e058256a 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -24,7 +25,7 @@ namespace Nz inline CommandBuffer(); CommandBuffer(const CommandBuffer&) = delete; inline CommandBuffer(CommandBuffer&& commandBuffer); - inline ~CommandBuffer(); + ~CommandBuffer() = default; inline bool Begin(const VkCommandBufferBeginInfo& info); inline bool Begin(VkCommandBufferUsageFlags flags = 0); @@ -90,10 +91,16 @@ namespace Nz inline CommandBuffer(CommandPool& pool, VkCommandBuffer handle); CommandPool* m_pool; - VkAllocationCallbacks m_allocator; VkCommandBuffer m_handle; VkResult m_lastErrorCode; + }; + class AutoCommandBuffer : public AutoFree + { + public: + using AutoFree::AutoFree; + + operator VkCommandBuffer() const { return Get(); } }; } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl index 00f3c9f31..f504a0df8 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl @@ -32,11 +32,6 @@ namespace Nz 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); diff --git a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.hpp b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.hpp index 24eb8c6ed..55da61cf5 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.hpp @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -24,7 +25,7 @@ namespace Nz inline DescriptorSet(); DescriptorSet(const DescriptorSet&) = delete; inline DescriptorSet(DescriptorSet&& descriptorSet) noexcept; - inline ~DescriptorSet(); + ~DescriptorSet() = default; inline void Free(); @@ -56,6 +57,15 @@ namespace Nz DescriptorPool* m_pool; VkDescriptorSet m_handle; }; + + class AutoDescriptorSet : public AutoFree + { + public: + using AutoFree::AutoFree; + + explicit operator bool() const { return Get(); } + operator VkDescriptorSet() const { return Get(); } + }; } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.inl b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.inl index 3932fdfcf..d6712c1b4 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSet.inl @@ -31,11 +31,6 @@ namespace Nz descriptorSet.m_handle = VK_NULL_HANDLE; } - inline DescriptorSet::~DescriptorSet() - { - Free(); - } - inline void DescriptorSet::Free() { if (m_handle) From 509c392e052e187ff2d74cc24e74448eadb5773d Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 26 Mar 2020 21:13:06 +0100 Subject: [PATCH 133/316] Implement UploadPool to efficiently update UBOs --- examples/VulkanTest/main.cpp | 90 ++++++++++------- include/Nazara/Core/Algorithm.hpp | 3 + include/Nazara/Core/Algorithm.inl | 52 ++++++++++ include/Nazara/VulkanRenderer.hpp | 1 + .../VulkanRenderer/VulkanUploadPool.hpp | 61 ++++++++++++ .../VulkanRenderer/VulkanUploadPool.inl | 17 ++++ .../Nazara/VulkanRenderer/Wrapper/Buffer.hpp | 2 +- .../VulkanRenderer/Wrapper/DeviceMemory.hpp | 8 +- .../VulkanRenderer/Wrapper/DeviceMemory.inl | 22 ++--- .../VulkanRenderer/VulkanUploadPool.cpp | 96 +++++++++++++++++++ 10 files changed, 302 insertions(+), 50 deletions(-) create mode 100644 include/Nazara/VulkanRenderer/VulkanUploadPool.hpp create mode 100644 include/Nazara/VulkanRenderer/VulkanUploadPool.inl create mode 100644 src/Nazara/VulkanRenderer/VulkanUploadPool.cpp diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index f71e98518..864c9f5ed 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -399,22 +399,31 @@ int main() window.EnableEventPolling(true); - struct ImageSync + struct ImageData { Nz::Vk::Fence inflightFence; Nz::Vk::Semaphore imageAvailableSemaphore; Nz::Vk::Semaphore renderFinishedSemaphore; + Nz::Vk::AutoCommandBuffer commandBuffer; + std::optional uploadPool; }; const std::size_t MaxConcurrentImage = imageCount; - std::vector frameSync(MaxConcurrentImage); - for (ImageSync& syncData : frameSync) + Nz::Vk::CommandPool transientPool; + transientPool.Create(vulkanDevice, 0, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT); + + std::vector frameSync(MaxConcurrentImage); + for (ImageData& syncData : frameSync) { syncData.imageAvailableSemaphore.Create(vulkanDevice); syncData.renderFinishedSemaphore.Create(vulkanDevice); syncData.inflightFence.Create(vulkanDevice, VK_FENCE_CREATE_SIGNALED_BIT); + + syncData.uploadPool.emplace(vulkanDevice, 8 * 1024 * 1024); + + syncData.commandBuffer = transientPool.AllocateCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY); } std::vector inflightFences(imageCount, nullptr); @@ -427,8 +436,6 @@ int main() while (window.IsOpen()) { - bool updateUniforms = false; - Nz::WindowEvent event; while (window.PollEvent(&event)) { @@ -454,7 +461,6 @@ int main() // Pour éviter que le curseur ne sorte de l'écran, nous le renvoyons au centre de la fenêtre // Cette fonction est codée de sorte à ne pas provoquer d'évènement MouseMoved Nz::Mouse::SetPosition(windowSize.x / 2, windowSize.y / 2, window); - updateUniforms = true; break; } } @@ -462,27 +468,38 @@ int main() if (updateClock.GetMilliseconds() > 1000 / 60) { - float elapsedTime = updateClock.GetSeconds(); + float cameraSpeed = 2.f * updateClock.GetSeconds(); updateClock.Restart(); - if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Up)) - { - viewerPos += camQuat * Nz::Vector3f::Forward() * elapsedTime; - updateUniforms = true; - } + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Up) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Z)) + viewerPos += camQuat * Nz::Vector3f::Forward() * cameraSpeed; - if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Down)) - { - viewerPos += camQuat * Nz::Vector3f::Backward() * elapsedTime; - updateUniforms = true; - } + // Si la flèche du bas ou la touche S est pressée, on recule + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Down) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::S)) + viewerPos += camQuat * Nz::Vector3f::Backward() * cameraSpeed; + + // Etc... + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Left) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Q)) + viewerPos += camQuat * Nz::Vector3f::Left() * cameraSpeed; + + // Etc... + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Right) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::D)) + viewerPos += camQuat * Nz::Vector3f::Right() * cameraSpeed; + + // Majuscule pour monter, notez l'utilisation d'une direction globale (Non-affectée par la rotation) + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::LShift) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::RShift)) + viewerPos += Nz::Vector3f::Up() * cameraSpeed; + + // Contrôle (Gauche ou droite) pour descendre dans l'espace global, etc... + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::LControl) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::RControl)) + viewerPos += Nz::Vector3f::Down() * cameraSpeed; } - ImageSync& syncPrimitives = frameSync[currentFrame]; - syncPrimitives.inflightFence.Wait(); + ImageData& frame = frameSync[currentFrame]; + frame.inflightFence.Wait(); Nz::UInt32 imageIndex; - if (!vulkanWindow.Acquire(&imageIndex, syncPrimitives.imageAvailableSemaphore)) + if (!vulkanWindow.Acquire(&imageIndex, frame.imageAvailableSemaphore)) { std::cout << "Failed to acquire next image" << std::endl; return EXIT_FAILURE; @@ -491,25 +508,32 @@ int main() if (inflightFences[imageIndex]) inflightFences[imageIndex]->Wait(); - inflightFences[imageIndex] = &syncPrimitives.inflightFence; + inflightFences[imageIndex] = &frame.inflightFence; inflightFences[imageIndex]->Reset(); - if (updateUniforms) - { - ubo.viewMatrix = Nz::Matrix4f::ViewMatrix(viewerPos, camAngles); + // Update UBO + frame.uploadPool->Reset(); - void* mappedPtr = uniformBufferImpl->Map(Nz::BufferAccess_DiscardAndWrite, 0, sizeof(ubo)); - if (mappedPtr) - { - std::memcpy(mappedPtr, &ubo, sizeof(ubo)); - uniformBufferImpl->Unmap(); - } - } + ubo.viewMatrix = Nz::Matrix4f::ViewMatrix(viewerPos, camAngles); - if (!graphicsQueue.Submit(renderCmds[imageIndex], syncPrimitives.imageAvailableSemaphore, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, syncPrimitives.renderFinishedSemaphore, syncPrimitives.inflightFence)) + auto allocData = frame.uploadPool->Allocate(uniformSize); + assert(allocData); + + std::memcpy(allocData->mappedPtr, &ubo, sizeof(ubo)); + + frame.commandBuffer->Begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT); + frame.commandBuffer->MemoryBarrier(VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0U, VK_ACCESS_TRANSFER_READ_BIT); + frame.commandBuffer->CopyBuffer(allocData->buffer, static_cast(uniformBuffer.get())->GetBuffer(), allocData->size, allocData->offset); + frame.commandBuffer->MemoryBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_UNIFORM_READ_BIT); + frame.commandBuffer->End(); + + if (!graphicsQueue.Submit(frame.commandBuffer)) return false; - vulkanWindow.Present(imageIndex, syncPrimitives.renderFinishedSemaphore); + if (!graphicsQueue.Submit(renderCmds[imageIndex], frame.imageAvailableSemaphore, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, frame.renderFinishedSemaphore, frame.inflightFence)) + return false; + + vulkanWindow.Present(imageIndex, frame.renderFinishedSemaphore); // On incrémente le compteur de FPS improvisé fps++; diff --git a/include/Nazara/Core/Algorithm.hpp b/include/Nazara/Core/Algorithm.hpp index 1a44940be..af602556a 100644 --- a/include/Nazara/Core/Algorithm.hpp +++ b/include/Nazara/Core/Algorithm.hpp @@ -21,6 +21,8 @@ namespace Nz class AbstractHash; class ByteArray; + template constexpr T Align(T offset, T alignment); + template constexpr T AlignPow2(T offset, T alignment); template decltype(auto) Apply(F&& fn, Tuple&& t); template decltype(auto) Apply(O& object, F&& fn, Tuple&& t); template constexpr std::size_t BitCount(); @@ -29,6 +31,7 @@ namespace Nz template constexpr std::size_t CountOf(T(&name)[N]) noexcept; template std::size_t CountOf(const T& c); template void HashCombine(std::size_t& seed, const T& v); + template bool IsPowerOfTwo(T value); template T ReverseBits(T integer); template constexpr auto UnderlyingCast(T value) -> std::underlying_type_t; diff --git a/include/Nazara/Core/Algorithm.inl b/include/Nazara/Core/Algorithm.inl index 3a77759d3..7cacf36e5 100644 --- a/include/Nazara/Core/Algorithm.inl +++ b/include/Nazara/Core/Algorithm.inl @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -35,6 +36,43 @@ namespace Nz NAZARA_CORE_API extern const UInt8 BitReverseTable256[256]; } + /*! + * \ingroup core + * \brief Align an offset + * \return Aligned offset according to alignment + * + * \param offset Base offset + * \param alignment Non-zero alignment + * + * \see AlignPow2 + */ + template + constexpr T Align(T offset, T alignment) + { + assert(alignment > 0); + return ((offset + alignment - 1) / alignment) * alignment; + } + + /*! + * \ingroup core + * \brief Align an offset + * \return Aligned offset according to a power of two alignment + * + * \param offset Base offset + * \param alignment Non-zero power of two alignment + * + * \see Align + * \remark This function is quicker than Align but only works with power of two alignment values + */ + template + constexpr T AlignPow2(T offset, T alignment) + { + assert(alignment > 0); + assert(IsPowerOfTwo(alignment)); + + return (offset + alignment - 1) & ~(alignment - 1); + } + /*! * \ingroup core * \brief Applies the tuple to the function (e.g. calls the function using the tuple content as arguments) @@ -178,6 +216,20 @@ namespace Nz seed = static_cast(b * kMul); } + /*! + * \ingroup core + * \brief Check if a value is a power of two + * \return true if value is a power of two + * + * \param value Non-zero value + */ + template + bool IsPowerOfTwo(T value) + { + assert(value != 0); + return (value & (value - 1)) == 0; + } + /*! * \ingroup core * \brief Reverse the bit order of the integer diff --git a/include/Nazara/VulkanRenderer.hpp b/include/Nazara/VulkanRenderer.hpp index e93ca271d..3b21f92c2 100644 --- a/include/Nazara/VulkanRenderer.hpp +++ b/include/Nazara/VulkanRenderer.hpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #endif // NAZARA_GLOBAL_VULKANRENDERER_HPP diff --git a/include/Nazara/VulkanRenderer/VulkanUploadPool.hpp b/include/Nazara/VulkanRenderer/VulkanUploadPool.hpp new file mode 100644 index 000000000..2383f88c8 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanUploadPool.hpp @@ -0,0 +1,61 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VULKANUPLOADPOOL_HPP +#define NAZARA_VULKANRENDERER_VULKANUPLOADPOOL_HPP + +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_VULKANRENDERER_API VulkanUploadPool + { + public: + struct AllocationData; + + inline VulkanUploadPool(Vk::Device& device, UInt64 blockSize); + VulkanUploadPool(const VulkanUploadPool&) = delete; + VulkanUploadPool(VulkanUploadPool&&) noexcept = default; + ~VulkanUploadPool() = default; + + std::optional Allocate(UInt64 size); + std::optional Allocate(UInt64 size, UInt64 alignment); + + void Reset(); + + struct AllocationData + { + VkBuffer buffer; + void* mappedPtr; + UInt64 offset; + UInt64 size; + }; + + VulkanUploadPool& operator=(const VulkanUploadPool&) = delete; + VulkanUploadPool& operator=(VulkanUploadPool&&) = delete; + + private: + struct Block + { + Vk::DeviceMemory blockMemory; + Vk::Buffer buffer; + UInt64 freeOffset; + }; + + UInt64 m_blockSize; + Vk::Device& m_device; + std::vector m_blocks; + }; +} + +#include + +#endif // NAZARA_VULKANRENDERER_VULKANUPLOADPOOL_HPP diff --git a/include/Nazara/VulkanRenderer/VulkanUploadPool.inl b/include/Nazara/VulkanRenderer/VulkanUploadPool.inl new file mode 100644 index 000000000..0245b5513 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanUploadPool.inl @@ -0,0 +1,17 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline VulkanUploadPool::VulkanUploadPool(Vk::Device& device, UInt64 blockSize) : + m_blockSize(blockSize), + m_device(device) + { + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp b/include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp index ad3573f34..4dba01ec1 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp @@ -21,7 +21,7 @@ namespace Nz public: Buffer() = default; Buffer(const Buffer&) = delete; - Buffer(Buffer&&) = default; + Buffer(Buffer&&) noexcept = default; ~Buffer() = default; bool BindBufferMemory(VkDeviceMemory memory, VkDeviceSize offset = 0); diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp b/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp index c6ec63832..e750779b4 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp @@ -8,6 +8,7 @@ #define NAZARA_VULKANRENDERER_VKDEVICEMEMORY_HPP #include +#include #include namespace Nz @@ -19,9 +20,9 @@ namespace Nz friend DeviceObject; public: - DeviceMemory(); + DeviceMemory() = default; DeviceMemory(const DeviceMemory&) = delete; - inline DeviceMemory(DeviceMemory&& memory); + DeviceMemory(DeviceMemory&& memory) noexcept = default; ~DeviceMemory() = default; using DeviceObject::Create; @@ -33,6 +34,7 @@ namespace Nz inline void* GetMappedPointer(); + inline bool Map(VkMemoryMapFlags flags = 0); inline bool Map(VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags = 0); inline void Unmap(); @@ -44,7 +46,7 @@ namespace Nz static inline VkResult CreateHelper(Device& device, const VkMemoryAllocateInfo* allocInfo, const VkAllocationCallbacks* allocator, VkDeviceMemory* handle); static inline void DestroyHelper(Device& device, VkDeviceMemory handle, const VkAllocationCallbacks* allocator); - void* m_mappedPtr; + MovablePtr m_mappedPtr; }; } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.inl b/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.inl index a764fbbdb..1fcc219b5 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.inl @@ -12,18 +12,6 @@ namespace Nz { namespace Vk { - inline DeviceMemory::DeviceMemory() : - m_mappedPtr(nullptr) - { - } - - inline DeviceMemory::DeviceMemory(DeviceMemory&& memory) : - DeviceObject(std::move(memory)) - { - m_mappedPtr = memory.m_mappedPtr; - memory.m_mappedPtr = nullptr; - } - inline bool DeviceMemory::Create(Device& device, VkDeviceSize size, UInt32 memoryType, const VkAllocationCallbacks* allocator) { VkMemoryAllocateInfo allocInfo = @@ -87,15 +75,23 @@ namespace Nz return m_mappedPtr; } + inline bool DeviceMemory::Map(VkMemoryMapFlags flags) + { + return Map(0, VK_WHOLE_SIZE, flags); + } + inline bool DeviceMemory::Map(VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags) { - m_lastErrorCode = m_device->vkMapMemory(*m_device, m_handle, offset, size, flags, &m_mappedPtr); + void* mappedPtr; + m_lastErrorCode = m_device->vkMapMemory(*m_device, m_handle, offset, size, flags, &mappedPtr); if (m_lastErrorCode != VK_SUCCESS) { NazaraError("Failed to map device memory: " + TranslateVulkanError(m_lastErrorCode)); return false; } + m_mappedPtr = mappedPtr; + return true; } diff --git a/src/Nazara/VulkanRenderer/VulkanUploadPool.cpp b/src/Nazara/VulkanRenderer/VulkanUploadPool.cpp new file mode 100644 index 000000000..ffbf17f1a --- /dev/null +++ b/src/Nazara/VulkanRenderer/VulkanUploadPool.cpp @@ -0,0 +1,96 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + auto VulkanUploadPool::Allocate(UInt64 size) -> std::optional + { + const auto& deviceProperties = m_device.GetPhysicalDeviceInfo().properties; + UInt64 preferredAlignement = deviceProperties.limits.optimalBufferCopyOffsetAlignment; + + return Allocate(size, preferredAlignement); + } + + auto VulkanUploadPool::Allocate(UInt64 size, UInt64 alignment) -> std::optional + { + assert(size <= m_blockSize); + + // Try to minimize lost space + struct + { + Block* block = nullptr; + UInt64 alignedOffset = 0; + UInt64 lostSpace = 0; + } bestBlock; + + for (Block& block : m_blocks) + { + UInt64 alignedOffset = AlignPow2(block.freeOffset, alignment); + if (alignedOffset + size > m_blockSize) + continue; //< Not enough space + + UInt64 lostSpace = alignedOffset - block.freeOffset; + + if (!bestBlock.block || lostSpace < bestBlock.lostSpace) + { + bestBlock.block = █ + bestBlock.alignedOffset = alignedOffset; + bestBlock.lostSpace = lostSpace; + } + } + + // No block found, allocate a new one + if (!bestBlock.block) + { + Block newBlock; + if (!newBlock.buffer.Create(m_device, 0U, m_blockSize, VK_BUFFER_USAGE_TRANSFER_SRC_BIT)) + { + NazaraError("Failed to create block buffer: " + TranslateVulkanError(newBlock.buffer.GetLastErrorCode())); + return {}; + } + + VkMemoryRequirements requirement = newBlock.buffer.GetMemoryRequirements(); + + if (!newBlock.blockMemory.Create(m_device, requirement.size, requirement.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) + { + NazaraError("Failed to allocate block memory: " + TranslateVulkanError(newBlock.blockMemory.GetLastErrorCode())); + return {}; + } + + if (!newBlock.buffer.BindBufferMemory(newBlock.blockMemory)) + { + NazaraError("Failed to bind buffer memory: " + TranslateVulkanError(newBlock.buffer.GetLastErrorCode())); + return {}; + } + + if (!newBlock.blockMemory.Map()) + { + NazaraError("Failed to map buffer memory: " + TranslateVulkanError(newBlock.buffer.GetLastErrorCode())); + return {}; + } + + bestBlock.block = &m_blocks.emplace_back(std::move(newBlock)); + bestBlock.alignedOffset = 0; + bestBlock.lostSpace = 0; + } + + AllocationData allocationData; + allocationData.buffer = bestBlock.block->buffer; + allocationData.mappedPtr = static_cast(bestBlock.block->blockMemory.GetMappedPointer()) + bestBlock.alignedOffset; + allocationData.offset = bestBlock.alignedOffset; + allocationData.size = size; + + return allocationData; + } + + void VulkanUploadPool::Reset() + { + for (Block& block : m_blocks) + block.freeOffset = 0; + } +} From b73d3e8f044937d61e348e81f63e8ed53f19ef73 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 26 Mar 2020 21:15:49 +0100 Subject: [PATCH 134/316] Add and make use of Vulkan Memory Allocator --- include/Nazara/Renderer/RenderBuffer.hpp | 10 +- include/Nazara/Utility/Enums.hpp | 1 + .../Nazara/VulkanRenderer/VulkanBuffer.hpp | 10 +- .../Nazara/VulkanRenderer/VulkanBuffer.inl | 2 +- .../Nazara/VulkanRenderer/Wrapper/Device.hpp | 11 +- .../Nazara/VulkanRenderer/Wrapper/Device.inl | 5 + src/Nazara/Renderer/HardwareBuffer.hpp | 44 - src/Nazara/Renderer/RenderBuffer.cpp | 28 +- src/Nazara/VulkanRenderer/Vulkan.cpp | 13 + src/Nazara/VulkanRenderer/VulkanBuffer.cpp | 104 +- src/Nazara/VulkanRenderer/Wrapper/Device.cpp | 69 +- thirdparty/include/vma/vk_mem_alloc.h | 18318 ++++++++++++++++ thirdparty/include/vma/vk_mem_alloc.natvis | 40 + 13 files changed, 18536 insertions(+), 119 deletions(-) delete mode 100644 src/Nazara/Renderer/HardwareBuffer.hpp create mode 100644 thirdparty/include/vma/vk_mem_alloc.h create mode 100644 thirdparty/include/vma/vk_mem_alloc.natvis diff --git a/include/Nazara/Renderer/RenderBuffer.hpp b/include/Nazara/Renderer/RenderBuffer.hpp index 06304f2ca..9e501a002 100644 --- a/include/Nazara/Renderer/RenderBuffer.hpp +++ b/include/Nazara/Renderer/RenderBuffer.hpp @@ -27,15 +27,15 @@ namespace Nz RenderBuffer(RenderBuffer&&) = default; ~RenderBuffer() = default; - bool Fill(const void* data, UInt32 offset, UInt32 size) override final; + bool Fill(const void* data, UInt32 offset, UInt32 size) final; bool Initialize(UInt32 size, BufferUsageFlags usage) override; AbstractBuffer* GetHardwareBuffer(RenderDevice* device); DataStorage GetStorage() const override; - void* Map(BufferAccess access, UInt32 offset = 0, UInt32 size = 0) override final; - bool Unmap() override final; + void* Map(BufferAccess access, UInt32 offset = 0, UInt32 size = 0) final; + bool Unmap() final; RenderBuffer& operator=(const RenderBuffer&) = delete; RenderBuffer& operator=(RenderBuffer&&) = default; @@ -44,6 +44,10 @@ namespace Nz bool Synchronize(RenderDevice* device); private: + struct HardwareBuffer; + + HardwareBuffer* GetHardwareBufferData(RenderDevice* device); + struct HardwareBuffer { std::unique_ptr buffer; diff --git a/include/Nazara/Utility/Enums.hpp b/include/Nazara/Utility/Enums.hpp index bc958a07a..9c7a23554 100644 --- a/include/Nazara/Utility/Enums.hpp +++ b/include/Nazara/Utility/Enums.hpp @@ -58,6 +58,7 @@ namespace Nz { BufferUsage_DeviceLocal, BufferUsage_DirectMapping, + BufferUsage_PersistentMapping, BufferUsage_Max = BufferUsage_DirectMapping }; diff --git a/include/Nazara/VulkanRenderer/VulkanBuffer.hpp b/include/Nazara/VulkanRenderer/VulkanBuffer.hpp index 71f8365df..8cdab89f4 100644 --- a/include/Nazara/VulkanRenderer/VulkanBuffer.hpp +++ b/include/Nazara/VulkanRenderer/VulkanBuffer.hpp @@ -28,7 +28,7 @@ namespace Nz bool Fill(const void* data, UInt32 offset, UInt32 size) override; - inline Nz::Vk::Buffer& GetBufferHandle(); + inline VkBuffer GetBuffer(); bool Initialize(UInt32 size, BufferUsageFlags usage) override; DataStorage GetStorage() const override; @@ -40,14 +40,14 @@ namespace Nz VulkanBuffer& operator=(VulkanBuffer&&) = delete; ///TODO private: - Vk::Buffer m_stagingBuffer; - Vk::DeviceMemory m_stagingMemory; BufferType m_type; BufferUsageFlags m_usage; UInt32 m_size; - Vk::Buffer m_buffer; + VkBuffer m_buffer; + VkBuffer m_stagingBuffer; + VmaAllocation m_allocation; + VmaAllocation m_stagingAllocation; Vk::Device& m_device; - Vk::DeviceMemory m_memory; }; } diff --git a/include/Nazara/VulkanRenderer/VulkanBuffer.inl b/include/Nazara/VulkanRenderer/VulkanBuffer.inl index 41eef8918..a68a4ac64 100644 --- a/include/Nazara/VulkanRenderer/VulkanBuffer.inl +++ b/include/Nazara/VulkanRenderer/VulkanBuffer.inl @@ -13,7 +13,7 @@ namespace Nz { } - inline Vk::Buffer& VulkanBuffer::GetBufferHandle() + inline VkBuffer VulkanBuffer::GetBuffer() { return m_buffer; } diff --git a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp index 6de35f597..e1c5e48de 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp @@ -15,6 +15,9 @@ #include #include +VK_DEFINE_HANDLE(VmaAllocator) +VK_DEFINE_HANDLE(VmaAllocation) + namespace Nz { namespace Vk @@ -47,6 +50,7 @@ namespace Nz inline Instance& GetInstance(); inline const Instance& GetInstance() const; inline VkResult GetLastErrorCode() const; + inline VmaAllocator GetMemoryAllocator() const; inline VkPhysicalDevice GetPhysicalDevice() const; inline const Vk::PhysicalDevice& GetPhysicalDeviceInfo() const; @@ -63,15 +67,17 @@ namespace Nz inline operator VkDevice(); // Vulkan functions +#define NAZARA_VULKANRENDERER_DEVICE_FUNCTION(func) PFN_##func func = nullptr; +#define NAZARA_VULKANRENDERER_DEVICE_CORE_EXT_FUNCTION(func, ...) NAZARA_VULKANRENDERER_DEVICE_FUNCTION(func) #define NAZARA_VULKANRENDERER_DEVICE_EXT_BEGIN(ext) #define NAZARA_VULKANRENDERER_DEVICE_EXT_END() -#define NAZARA_VULKANRENDERER_DEVICE_FUNCTION(func) PFN_##func func = nullptr; #include +#undef NAZARA_VULKANRENDERER_DEVICE_CORE_EXT_FUNCTION +#undef NAZARA_VULKANRENDERER_DEVICE_FUNCTION #undef NAZARA_VULKANRENDERER_DEVICE_EXT_BEGIN #undef NAZARA_VULKANRENDERER_DEVICE_EXT_END -#undef NAZARA_VULKANRENDERER_DEVICE_FUNCTION struct QueueInfo { @@ -103,6 +109,7 @@ namespace Nz VkAllocationCallbacks m_allocator; VkDevice m_device; VkResult m_lastErrorCode; + VmaAllocator m_memAllocator; UInt32 m_transferQueueFamilyIndex; std::unordered_set m_loadedExtensions; std::unordered_set m_loadedLayers; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Device.inl b/include/Nazara/VulkanRenderer/Wrapper/Device.inl index 81ae1f4b3..1e8617731 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Device.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Device.inl @@ -39,6 +39,11 @@ namespace Nz return m_lastErrorCode; } + inline VmaAllocator Device::GetMemoryAllocator() const + { + return m_memAllocator; + } + inline VkPhysicalDevice Device::GetPhysicalDevice() const { return m_physicalDevice->physDevice; diff --git a/src/Nazara/Renderer/HardwareBuffer.hpp b/src/Nazara/Renderer/HardwareBuffer.hpp deleted file mode 100644 index 5a5146095..000000000 --- a/src/Nazara/Renderer/HardwareBuffer.hpp +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_HARDWAREBUFFER_HPP -#define NAZARA_HARDWAREBUFFER_HPP - -#include -#include -#include - -namespace Nz -{ - class Buffer; - - class HardwareBuffer : public AbstractBuffer - { - public: - HardwareBuffer(Buffer* parent, BufferType type); - ~HardwareBuffer(); - - bool Fill(const void* data, UInt32 offset, UInt32 size) override; - - bool Initialize(unsigned int size, BufferUsageFlags usage) override; - - DataStorage GetStorage() const override; - - void* Map(BufferAccess access, UInt32 offset = 0, UInt32 size = 0) override; - bool Unmap() override; - - // Fonctions OpenGL - void Bind() const; - GLuint GetOpenGLID() const; - - private: - GLuint m_buffer; - BufferType m_type; - Buffer* m_parent; - }; -} - -#endif // NAZARA_HARDWAREBUFFER_HPP diff --git a/src/Nazara/Renderer/RenderBuffer.cpp b/src/Nazara/Renderer/RenderBuffer.cpp index c8de03340..a78660fe3 100644 --- a/src/Nazara/Renderer/RenderBuffer.cpp +++ b/src/Nazara/Renderer/RenderBuffer.cpp @@ -31,11 +31,10 @@ namespace Nz AbstractBuffer* RenderBuffer::GetHardwareBuffer(RenderDevice* device) { - auto it = m_hardwareBuffers.find(device); - if (it == m_hardwareBuffers.end()) - return nullptr; + if (HardwareBuffer* hwBuffer = GetHardwareBufferData(device)) + return hwBuffer->buffer.get(); - return it->second.buffer.get(); + return nullptr; } DataStorage RenderBuffer::GetStorage() const @@ -65,6 +64,18 @@ namespace Nz } bool RenderBuffer::Synchronize(RenderDevice* device) + { + HardwareBuffer* hwBuffer = GetHardwareBufferData(device); + if (!hwBuffer) + return false; + + if (hwBuffer->synchronized) + return true; + + return hwBuffer->buffer->Fill(m_softwareBuffer.GetData(), 0, m_size); + } + + auto RenderBuffer::GetHardwareBufferData(RenderDevice* device) -> HardwareBuffer* { auto it = m_hardwareBuffers.find(device); if (it == m_hardwareBuffers.end()) @@ -74,16 +85,13 @@ namespace Nz if (!hwBuffer.buffer->Initialize(m_size, m_usage)) { NazaraError("Failed to initialize hardware buffer"); - return false; + return nullptr; } it = m_hardwareBuffers.emplace(device, std::move(hwBuffer)).first; } - HardwareBuffer& hwBuffer = it->second; - if (hwBuffer.synchronized) - return true; - - return hwBuffer.buffer->Fill(m_softwareBuffer.GetData(), 0, m_size); + return &it->second; } + } diff --git a/src/Nazara/VulkanRenderer/Vulkan.cpp b/src/Nazara/VulkanRenderer/Vulkan.cpp index 49dffd8b6..c60650158 100644 --- a/src/Nazara/VulkanRenderer/Vulkan.cpp +++ b/src/Nazara/VulkanRenderer/Vulkan.cpp @@ -163,6 +163,9 @@ namespace Nz #ifdef VK_USE_PLATFORM_WIN32_KHR enabledExtensions.push_back("VK_KHR_win32_surface"); #endif + + if (availableExtensions.count(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME)) + enabledExtensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); } std::vector additionalExtensions; // Just to keep the String alive @@ -424,6 +427,16 @@ namespace Nz // Swapchain extension is required for rendering enabledExtensions.emplace_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME); + auto EnableIfSupported = [&](const char* extName) + { + if (deviceInfo.extensions.count(extName)) + enabledExtensions.emplace_back(extName); + }; + + // VMA extensions + EnableIfSupported(VK_EXT_MEMORY_BUDGET_EXTENSION_NAME); + EnableIfSupported(VK_KHR_BIND_MEMORY_2_EXTENSION_NAME); + EnableIfSupported(VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME); } std::vector additionalExtensions; // Just to keep the String alive diff --git a/src/Nazara/VulkanRenderer/VulkanBuffer.cpp b/src/Nazara/VulkanRenderer/VulkanBuffer.cpp index 3bfc3f615..d31298e5c 100644 --- a/src/Nazara/VulkanRenderer/VulkanBuffer.cpp +++ b/src/Nazara/VulkanRenderer/VulkanBuffer.cpp @@ -7,11 +7,15 @@ #include #include #include +#include #include namespace Nz { - VulkanBuffer::~VulkanBuffer() = default; + VulkanBuffer::~VulkanBuffer() + { + vmaDestroyBuffer(m_device.GetMemoryAllocator(), m_buffer, m_allocation); + } bool VulkanBuffer::Fill(const void* data, UInt32 offset, UInt32 size) { @@ -32,32 +36,33 @@ namespace Nz m_usage = usage; VkBufferUsageFlags bufferUsage = ToVulkan(m_type); - VkMemoryPropertyFlags memoryProperties = 0; - if (usage & BufferUsage_DeviceLocal) - memoryProperties |= VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; - if (usage & BufferUsage_DirectMapping) - memoryProperties |= VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; - else + if ((usage & BufferUsage_DirectMapping) == 0) bufferUsage |= VK_BUFFER_USAGE_TRANSFER_DST_BIT; - if (!m_buffer.Create(m_device, 0, size, bufferUsage)) + VkBufferCreateInfo createInfo = {}; + createInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; + createInfo.size = size; + createInfo.usage = bufferUsage; + + VmaAllocationCreateInfo allocInfo = {}; + if (usage & BufferUsage_DeviceLocal) { - NazaraError("Failed to create vulkan buffer"); - return false; + if (usage & BufferUsage_DirectMapping) + allocInfo.usage = VMA_MEMORY_USAGE_CPU_TO_GPU; + else + allocInfo.usage = VMA_MEMORY_USAGE_GPU_ONLY; } + else + allocInfo.usage = VMA_MEMORY_USAGE_CPU_ONLY; - VkMemoryRequirements memRequirement = m_buffer.GetMemoryRequirements(); + if (usage & BufferUsage_PersistentMapping) + allocInfo.flags |= VMA_ALLOCATION_CREATE_MAPPED_BIT; - if (!m_memory.Create(m_device, memRequirement.size, memRequirement.memoryTypeBits, memoryProperties)) + VkResult result = vmaCreateBuffer(m_device.GetMemoryAllocator(), &createInfo, &allocInfo, &m_buffer, &m_allocation, nullptr); + if (result != VK_SUCCESS) { - NazaraError("Failed to allocate buffer memory"); - return false; - } - - if (!m_buffer.BindBufferMemory(m_memory)) - { - NazaraError("Failed to bind vertex buffer to its memory"); + NazaraError("Failed to allocate buffer: " + TranslateVulkanError(result)); return false; } @@ -73,38 +78,37 @@ namespace Nz { if (m_usage & BufferUsage_DirectMapping) { - if (!m_memory.Map(offset, size)) + void* mappedPtr; + VkResult result = vmaMapMemory(m_device.GetMemoryAllocator(), m_allocation, &mappedPtr); + if (result != VK_SUCCESS) + { + NazaraError("Failed to map buffer: " + TranslateVulkanError(result)); return nullptr; + } - return m_memory.GetMappedPointer(); + return static_cast(mappedPtr) + offset; } else { - if (!m_stagingBuffer.Create(m_device, 0, m_size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT)) + VkBufferCreateInfo createInfo = {}; + createInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; + createInfo.size = size; + createInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT; + + VmaAllocationCreateInfo allocInfo = {}; + allocInfo.flags = VMA_ALLOCATION_CREATE_MAPPED_BIT; + allocInfo.usage = VMA_MEMORY_USAGE_CPU_TO_GPU; + + VmaAllocationInfo allocationInfo; + + VkResult result = vmaCreateBuffer(m_device.GetMemoryAllocator(), &createInfo, &allocInfo, &m_stagingBuffer, &m_stagingAllocation, &allocationInfo); + if (result != VK_SUCCESS) { - NazaraError("Failed to create staging buffer"); + NazaraError("Failed to allocate staging buffer: " + TranslateVulkanError(result)); return nullptr; } - VkMemoryPropertyFlags memoryProperties = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; - - VkMemoryRequirements memRequirement = m_stagingBuffer.GetMemoryRequirements(); - if (!m_stagingMemory.Create(m_device, memRequirement.size, memRequirement.memoryTypeBits, memoryProperties)) - { - NazaraError("Failed to allocate vertex buffer memory"); - return nullptr; - } - - if (!m_stagingBuffer.BindBufferMemory(m_stagingMemory)) - { - NazaraError("Failed to bind vertex buffer to its memory"); - return nullptr; - } - - if (!m_stagingMemory.Map(offset, size)) - return nullptr; - - return m_stagingMemory.GetMappedPointer(); + return allocationInfo.pMappedData; } } @@ -112,20 +116,17 @@ namespace Nz { if (m_usage & BufferUsage_DirectMapping) { - m_memory.Unmap(); + vmaUnmapMemory(m_device.GetMemoryAllocator(), m_allocation); return true; } else { - m_stagingMemory.FlushMemory(); - m_stagingMemory.Unmap(); - - Vk::CommandBuffer copyCommandBuffer = m_device.AllocateTransferCommandBuffer(); - if (!copyCommandBuffer.Begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT)) + Vk::AutoCommandBuffer copyCommandBuffer = m_device.AllocateTransferCommandBuffer(); + if (!copyCommandBuffer->Begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT)) return false; - copyCommandBuffer.CopyBuffer(m_stagingBuffer, m_buffer, m_size); - if (!copyCommandBuffer.End()) + copyCommandBuffer->CopyBuffer(m_stagingBuffer, m_buffer, m_size); + if (!copyCommandBuffer->End()) return false; Vk::QueueHandle transferQueue = m_device.GetQueue(m_device.GetTransferQueueFamilyIndex(), 0); @@ -134,8 +135,7 @@ namespace Nz transferQueue.WaitIdle(); - m_stagingBuffer.Destroy(); - m_stagingMemory.Destroy(); + vmaDestroyBuffer(m_device.GetMemoryAllocator(), m_stagingBuffer, m_stagingAllocation); return true; } } diff --git a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp index 29bd02b86..6d0248bef 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp @@ -9,6 +9,11 @@ #include #include #include + +#define VMA_IMPLEMENTATION +#define VMA_STATIC_VULKAN_FUNCTIONS 0 +#include + #include namespace Nz @@ -23,7 +28,9 @@ namespace Nz Device::Device(Instance& instance) : m_instance(instance), m_physicalDevice(nullptr), - m_device(VK_NULL_HANDLE) + m_device(VK_NULL_HANDLE), + m_lastErrorCode(VK_SUCCESS), + m_memAllocator(VK_NULL_HANDLE) { } @@ -43,7 +50,7 @@ namespace Nz m_lastErrorCode = m_instance.vkCreateDevice(deviceInfo.physDevice, &createInfo, allocator, &m_device); if (m_lastErrorCode != VkResult::VK_SUCCESS) { - NazaraError("Failed to create Vulkan device"); + NazaraError("Failed to create Vulkan device: " + TranslateVulkanError(m_lastErrorCode)); return false; } @@ -145,6 +152,61 @@ namespace Nz return false; } + // Initialize VMA + VmaVulkanFunctions vulkanFunctions = { + m_instance.vkGetPhysicalDeviceProperties, + m_instance.vkGetPhysicalDeviceMemoryProperties, + vkAllocateMemory, + vkFreeMemory, + vkMapMemory, + vkUnmapMemory, + vkFlushMappedMemoryRanges, + vkInvalidateMappedMemoryRanges, + vkBindBufferMemory, + vkBindImageMemory, + vkGetBufferMemoryRequirements, + vkGetImageMemoryRequirements, + vkCreateBuffer, + vkDestroyBuffer, + vkCreateImage, + vkDestroyImage, + vkCmdCopyBuffer, +#if VMA_DEDICATED_ALLOCATION || VMA_VULKAN_VERSION >= 1001000 + vkGetBufferMemoryRequirements2, + vkGetImageMemoryRequirements2, +#endif +#if VMA_BIND_MEMORY2 || VMA_VULKAN_VERSION >= 1001000 + vkBindBufferMemory2, + vkBindImageMemory2, +#endif +#if VMA_MEMORY_BUDGET || VMA_VULKAN_VERSION >= 1001000 + m_instance.vkGetPhysicalDeviceMemoryProperties2, +#endif + }; + + VmaAllocatorCreateInfo allocatorInfo = {}; + allocatorInfo.physicalDevice = deviceInfo.physDevice; + allocatorInfo.device = m_device; + allocatorInfo.instance = m_instance; + allocatorInfo.vulkanApiVersion = std::min(VK_API_VERSION_1_1, m_instance.GetApiVersion()); + allocatorInfo.pVulkanFunctions = &vulkanFunctions; + + if (vkGetBufferMemoryRequirements2 && vkGetImageMemoryRequirements2) + allocatorInfo.flags |= VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT; + + if (vkBindBufferMemory2 && vkBindImageMemory2) + allocatorInfo.flags |= VMA_ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT; + + if (IsExtensionLoaded(VK_EXT_MEMORY_BUDGET_EXTENSION_NAME)) + allocatorInfo.flags |= VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT; + + m_lastErrorCode = vmaCreateAllocator(&allocatorInfo, &m_memAllocator); + if (m_lastErrorCode != VK_SUCCESS) + { + NazaraError("Failed to initialize Vulkan Memory Allocator (VMA): " + TranslateVulkanError(m_lastErrorCode)); + return false; + } + destroyOnFailure.Reset(); return true; @@ -193,6 +255,9 @@ namespace Nz if (vkDeviceWaitIdle) vkDeviceWaitIdle(m_device); + if (m_memAllocator != VK_NULL_HANDLE) + vmaDestroyAllocator(m_memAllocator); + m_internalData.reset(); if (vkDestroyDevice) diff --git a/thirdparty/include/vma/vk_mem_alloc.h b/thirdparty/include/vma/vk_mem_alloc.h new file mode 100644 index 000000000..15e0c6598 --- /dev/null +++ b/thirdparty/include/vma/vk_mem_alloc.h @@ -0,0 +1,18318 @@ +// +// Copyright (c) 2017-2020 Advanced Micro Devices, Inc. All rights reserved. +// +// 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. +// + +#ifndef AMD_VULKAN_MEMORY_ALLOCATOR_H +#define AMD_VULKAN_MEMORY_ALLOCATOR_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** \mainpage Vulkan Memory Allocator + +Version 2.4.0-development (2020-03-02) + +Copyright (c) 2017-2020 Advanced Micro Devices, Inc. All rights reserved. \n +License: MIT + +Documentation of all members: vk_mem_alloc.h + +\section main_table_of_contents Table of contents + +- User guide + - \subpage quick_start + - [Project setup](@ref quick_start_project_setup) + - [Initialization](@ref quick_start_initialization) + - [Resource allocation](@ref quick_start_resource_allocation) + - \subpage choosing_memory_type + - [Usage](@ref choosing_memory_type_usage) + - [Required and preferred flags](@ref choosing_memory_type_required_preferred_flags) + - [Explicit memory types](@ref choosing_memory_type_explicit_memory_types) + - [Custom memory pools](@ref choosing_memory_type_custom_memory_pools) + - [Dedicated allocations](@ref choosing_memory_type_dedicated_allocations) + - \subpage memory_mapping + - [Mapping functions](@ref memory_mapping_mapping_functions) + - [Persistently mapped memory](@ref memory_mapping_persistently_mapped_memory) + - [Cache flush and invalidate](@ref memory_mapping_cache_control) + - [Finding out if memory is mappable](@ref memory_mapping_finding_if_memory_mappable) + - \subpage staying_within_budget + - [Querying for budget](@ref staying_within_budget_querying_for_budget) + - [Controlling memory usage](@ref staying_within_budget_controlling_memory_usage) + - \subpage custom_memory_pools + - [Choosing memory type index](@ref custom_memory_pools_MemTypeIndex) + - [Linear allocation algorithm](@ref linear_algorithm) + - [Free-at-once](@ref linear_algorithm_free_at_once) + - [Stack](@ref linear_algorithm_stack) + - [Double stack](@ref linear_algorithm_double_stack) + - [Ring buffer](@ref linear_algorithm_ring_buffer) + - [Buddy allocation algorithm](@ref buddy_algorithm) + - \subpage defragmentation + - [Defragmenting CPU memory](@ref defragmentation_cpu) + - [Defragmenting GPU memory](@ref defragmentation_gpu) + - [Additional notes](@ref defragmentation_additional_notes) + - [Writing custom allocation algorithm](@ref defragmentation_custom_algorithm) + - \subpage lost_allocations + - \subpage statistics + - [Numeric statistics](@ref statistics_numeric_statistics) + - [JSON dump](@ref statistics_json_dump) + - \subpage allocation_annotation + - [Allocation user data](@ref allocation_user_data) + - [Allocation names](@ref allocation_names) + - \subpage debugging_memory_usage + - [Memory initialization](@ref debugging_memory_usage_initialization) + - [Margins](@ref debugging_memory_usage_margins) + - [Corruption detection](@ref debugging_memory_usage_corruption_detection) + - \subpage record_and_replay +- \subpage usage_patterns + - [Common mistakes](@ref usage_patterns_common_mistakes) + - [Simple patterns](@ref usage_patterns_simple) + - [Advanced patterns](@ref usage_patterns_advanced) +- \subpage configuration + - [Pointers to Vulkan functions](@ref config_Vulkan_functions) + - [Custom host memory allocator](@ref custom_memory_allocator) + - [Device memory allocation callbacks](@ref allocation_callbacks) + - [Device heap memory limit](@ref heap_memory_limit) + - \subpage vk_khr_dedicated_allocation + - \subpage vk_amd_device_coherent_memory +- \subpage general_considerations + - [Thread safety](@ref general_considerations_thread_safety) + - [Validation layer warnings](@ref general_considerations_validation_layer_warnings) + - [Allocation algorithm](@ref general_considerations_allocation_algorithm) + - [Features not supported](@ref general_considerations_features_not_supported) + +\section main_see_also See also + +- [Product page on GPUOpen](https://gpuopen.com/gaming-product/vulkan-memory-allocator/) +- [Source repository on GitHub](https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator) + + + + +\page quick_start Quick start + +\section quick_start_project_setup Project setup + +Vulkan Memory Allocator comes in form of a "stb-style" single header file. +You don't need to build it as a separate library project. +You can add this file directly to your project and submit it to code repository next to your other source files. + +"Single header" doesn't mean that everything is contained in C/C++ declarations, +like it tends to be in case of inline functions or C++ templates. +It means that implementation is bundled with interface in a single file and needs to be extracted using preprocessor macro. +If you don't do it properly, you will get linker errors. + +To do it properly: + +-# Include "vk_mem_alloc.h" file in each CPP file where you want to use the library. + This includes declarations of all members of the library. +-# In exacly one CPP file define following macro before this include. + It enables also internal definitions. + +\code +#define VMA_IMPLEMENTATION +#include "vk_mem_alloc.h" +\endcode + +It may be a good idea to create dedicated CPP file just for this purpose. + +Note on language: This library is written in C++, but has C-compatible interface. +Thus you can include and use vk_mem_alloc.h in C or C++ code, but full +implementation with `VMA_IMPLEMENTATION` macro must be compiled as C++, NOT as C. + +Please note that this library includes header ``, which in turn +includes `` on Windows. If you need some specific macros defined +before including these headers (like `WIN32_LEAN_AND_MEAN` or +`WINVER` for Windows, `VK_USE_PLATFORM_WIN32_KHR` for Vulkan), you must define +them before every `#include` of this library. + + +\section quick_start_initialization Initialization + +At program startup: + +-# Initialize Vulkan to have `VkPhysicalDevice` and `VkDevice` object. +-# Fill VmaAllocatorCreateInfo structure and create #VmaAllocator object by + calling vmaCreateAllocator(). + +\code +VmaAllocatorCreateInfo allocatorInfo = {}; +allocatorInfo.physicalDevice = physicalDevice; +allocatorInfo.device = device; + +VmaAllocator allocator; +vmaCreateAllocator(&allocatorInfo, &allocator); +\endcode + +\section quick_start_resource_allocation Resource allocation + +When you want to create a buffer or image: + +-# Fill `VkBufferCreateInfo` / `VkImageCreateInfo` structure. +-# Fill VmaAllocationCreateInfo structure. +-# Call vmaCreateBuffer() / vmaCreateImage() to get `VkBuffer`/`VkImage` with memory + already allocated and bound to it. + +\code +VkBufferCreateInfo bufferInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO }; +bufferInfo.size = 65536; +bufferInfo.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT; + +VmaAllocationCreateInfo allocInfo = {}; +allocInfo.usage = VMA_MEMORY_USAGE_GPU_ONLY; + +VkBuffer buffer; +VmaAllocation allocation; +vmaCreateBuffer(allocator, &bufferInfo, &allocInfo, &buffer, &allocation, nullptr); +\endcode + +Don't forget to destroy your objects when no longer needed: + +\code +vmaDestroyBuffer(allocator, buffer, allocation); +vmaDestroyAllocator(allocator); +\endcode + + +\page choosing_memory_type Choosing memory type + +Physical devices in Vulkan support various combinations of memory heaps and +types. Help with choosing correct and optimal memory type for your specific +resource is one of the key features of this library. You can use it by filling +appropriate members of VmaAllocationCreateInfo structure, as described below. +You can also combine multiple methods. + +-# If you just want to find memory type index that meets your requirements, you + can use function: vmaFindMemoryTypeIndex(), vmaFindMemoryTypeIndexForBufferInfo(), + vmaFindMemoryTypeIndexForImageInfo(). +-# If you want to allocate a region of device memory without association with any + specific image or buffer, you can use function vmaAllocateMemory(). Usage of + this function is not recommended and usually not needed. + vmaAllocateMemoryPages() function is also provided for creating multiple allocations at once, + which may be useful for sparse binding. +-# If you already have a buffer or an image created, you want to allocate memory + for it and then you will bind it yourself, you can use function + vmaAllocateMemoryForBuffer(), vmaAllocateMemoryForImage(). + For binding you should use functions: vmaBindBufferMemory(), vmaBindImageMemory() + or their extended versions: vmaBindBufferMemory2(), vmaBindImageMemory2(). +-# If you want to create a buffer or an image, allocate memory for it and bind + them together, all in one call, you can use function vmaCreateBuffer(), + vmaCreateImage(). This is the easiest and recommended way to use this library. + +When using 3. or 4., the library internally queries Vulkan for memory types +supported for that buffer or image (function `vkGetBufferMemoryRequirements()`) +and uses only one of these types. + +If no memory type can be found that meets all the requirements, these functions +return `VK_ERROR_FEATURE_NOT_PRESENT`. + +You can leave VmaAllocationCreateInfo structure completely filled with zeros. +It means no requirements are specified for memory type. +It is valid, although not very useful. + +\section choosing_memory_type_usage Usage + +The easiest way to specify memory requirements is to fill member +VmaAllocationCreateInfo::usage using one of the values of enum #VmaMemoryUsage. +It defines high level, common usage types. +For more details, see description of this enum. + +For example, if you want to create a uniform buffer that will be filled using +transfer only once or infrequently and used for rendering every frame, you can +do it using following code: + +\code +VkBufferCreateInfo bufferInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO }; +bufferInfo.size = 65536; +bufferInfo.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT; + +VmaAllocationCreateInfo allocInfo = {}; +allocInfo.usage = VMA_MEMORY_USAGE_GPU_ONLY; + +VkBuffer buffer; +VmaAllocation allocation; +vmaCreateBuffer(allocator, &bufferInfo, &allocInfo, &buffer, &allocation, nullptr); +\endcode + +\section choosing_memory_type_required_preferred_flags Required and preferred flags + +You can specify more detailed requirements by filling members +VmaAllocationCreateInfo::requiredFlags and VmaAllocationCreateInfo::preferredFlags +with a combination of bits from enum `VkMemoryPropertyFlags`. For example, +if you want to create a buffer that will be persistently mapped on host (so it +must be `HOST_VISIBLE`) and preferably will also be `HOST_COHERENT` and `HOST_CACHED`, +use following code: + +\code +VmaAllocationCreateInfo allocInfo = {}; +allocInfo.requiredFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; +allocInfo.preferredFlags = VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT; +allocInfo.flags = VMA_ALLOCATION_CREATE_MAPPED_BIT; + +VkBuffer buffer; +VmaAllocation allocation; +vmaCreateBuffer(allocator, &bufferInfo, &allocInfo, &buffer, &allocation, nullptr); +\endcode + +A memory type is chosen that has all the required flags and as many preferred +flags set as possible. + +If you use VmaAllocationCreateInfo::usage, it is just internally converted to +a set of required and preferred flags. + +\section choosing_memory_type_explicit_memory_types Explicit memory types + +If you inspected memory types available on the physical device and you have +a preference for memory types that you want to use, you can fill member +VmaAllocationCreateInfo::memoryTypeBits. It is a bit mask, where each bit set +means that a memory type with that index is allowed to be used for the +allocation. Special value 0, just like `UINT32_MAX`, means there are no +restrictions to memory type index. + +Please note that this member is NOT just a memory type index. +Still you can use it to choose just one, specific memory type. +For example, if you already determined that your buffer should be created in +memory type 2, use following code: + +\code +uint32_t memoryTypeIndex = 2; + +VmaAllocationCreateInfo allocInfo = {}; +allocInfo.memoryTypeBits = 1u << memoryTypeIndex; + +VkBuffer buffer; +VmaAllocation allocation; +vmaCreateBuffer(allocator, &bufferInfo, &allocInfo, &buffer, &allocation, nullptr); +\endcode + +\section choosing_memory_type_custom_memory_pools Custom memory pools + +If you allocate from custom memory pool, all the ways of specifying memory +requirements described above are not applicable and the aforementioned members +of VmaAllocationCreateInfo structure are ignored. Memory type is selected +explicitly when creating the pool and then used to make all the allocations from +that pool. For further details, see \ref custom_memory_pools. + +\section choosing_memory_type_dedicated_allocations Dedicated allocations + +Memory for allocations is reserved out of larger block of `VkDeviceMemory` +allocated from Vulkan internally. That's the main feature of this whole library. +You can still request a separate memory block to be created for an allocation, +just like you would do in a trivial solution without using any allocator. +In that case, a buffer or image is always bound to that memory at offset 0. +This is called a "dedicated allocation". +You can explicitly request it by using flag #VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT. +The library can also internally decide to use dedicated allocation in some cases, e.g.: + +- When the size of the allocation is large. +- When [VK_KHR_dedicated_allocation](@ref vk_khr_dedicated_allocation) extension is enabled + and it reports that dedicated allocation is required or recommended for the resource. +- When allocation of next big memory block fails due to not enough device memory, + but allocation with the exact requested size succeeds. + + +\page memory_mapping Memory mapping + +To "map memory" in Vulkan means to obtain a CPU pointer to `VkDeviceMemory`, +to be able to read from it or write to it in CPU code. +Mapping is possible only of memory allocated from a memory type that has +`VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT` flag. +Functions `vkMapMemory()`, `vkUnmapMemory()` are designed for this purpose. +You can use them directly with memory allocated by this library, +but it is not recommended because of following issue: +Mapping the same `VkDeviceMemory` block multiple times is illegal - only one mapping at a time is allowed. +This includes mapping disjoint regions. Mapping is not reference-counted internally by Vulkan. +Because of this, Vulkan Memory Allocator provides following facilities: + +\section memory_mapping_mapping_functions Mapping functions + +The library provides following functions for mapping of a specific #VmaAllocation: vmaMapMemory(), vmaUnmapMemory(). +They are safer and more convenient to use than standard Vulkan functions. +You can map an allocation multiple times simultaneously - mapping is reference-counted internally. +You can also map different allocations simultaneously regardless of whether they use the same `VkDeviceMemory` block. +The way it's implemented is that the library always maps entire memory block, not just region of the allocation. +For further details, see description of vmaMapMemory() function. +Example: + +\code +// Having these objects initialized: + +struct ConstantBuffer +{ + ... +}; +ConstantBuffer constantBufferData; + +VmaAllocator allocator; +VkBuffer constantBuffer; +VmaAllocation constantBufferAllocation; + +// You can map and fill your buffer using following code: + +void* mappedData; +vmaMapMemory(allocator, constantBufferAllocation, &mappedData); +memcpy(mappedData, &constantBufferData, sizeof(constantBufferData)); +vmaUnmapMemory(allocator, constantBufferAllocation); +\endcode + +When mapping, you may see a warning from Vulkan validation layer similar to this one: + +Mapping an image with layout VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL can result in undefined behavior if this memory is used by the device. Only GENERAL or PREINITIALIZED should be used. + +It happens because the library maps entire `VkDeviceMemory` block, where different +types of images and buffers may end up together, especially on GPUs with unified memory like Intel. +You can safely ignore it if you are sure you access only memory of the intended +object that you wanted to map. + + +\section memory_mapping_persistently_mapped_memory Persistently mapped memory + +Kepping your memory persistently mapped is generally OK in Vulkan. +You don't need to unmap it before using its data on the GPU. +The library provides a special feature designed for that: +Allocations made with #VMA_ALLOCATION_CREATE_MAPPED_BIT flag set in +VmaAllocationCreateInfo::flags stay mapped all the time, +so you can just access CPU pointer to it any time +without a need to call any "map" or "unmap" function. +Example: + +\code +VkBufferCreateInfo bufCreateInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO }; +bufCreateInfo.size = sizeof(ConstantBuffer); +bufCreateInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT; + +VmaAllocationCreateInfo allocCreateInfo = {}; +allocCreateInfo.usage = VMA_MEMORY_USAGE_CPU_ONLY; +allocCreateInfo.flags = VMA_ALLOCATION_CREATE_MAPPED_BIT; + +VkBuffer buf; +VmaAllocation alloc; +VmaAllocationInfo allocInfo; +vmaCreateBuffer(allocator, &bufCreateInfo, &allocCreateInfo, &buf, &alloc, &allocInfo); + +// Buffer is already mapped. You can access its memory. +memcpy(allocInfo.pMappedData, &constantBufferData, sizeof(constantBufferData)); +\endcode + +There are some exceptions though, when you should consider mapping memory only for a short period of time: + +- When operating system is Windows 7 or 8.x (Windows 10 is not affected because it uses WDDM2), + device is discrete AMD GPU, + and memory type is the special 256 MiB pool of `DEVICE_LOCAL + HOST_VISIBLE` memory + (selected when you use #VMA_MEMORY_USAGE_CPU_TO_GPU), + then whenever a memory block allocated from this memory type stays mapped + for the time of any call to `vkQueueSubmit()` or `vkQueuePresentKHR()`, this + block is migrated by WDDM to system RAM, which degrades performance. It doesn't + matter if that particular memory block is actually used by the command buffer + being submitted. +- On Mac/MoltenVK there is a known bug - [Issue #175](https://github.com/KhronosGroup/MoltenVK/issues/175) + which requires unmapping before GPU can see updated texture. +- Keeping many large memory blocks mapped may impact performance or stability of some debugging tools. + +\section memory_mapping_cache_control Cache flush and invalidate + +Memory in Vulkan doesn't need to be unmapped before using it on GPU, +but unless a memory types has `VK_MEMORY_PROPERTY_HOST_COHERENT_BIT` flag set, +you need to manually **invalidate** cache before reading of mapped pointer +and **flush** cache after writing to mapped pointer. +Map/unmap operations don't do that automatically. +Vulkan provides following functions for this purpose `vkFlushMappedMemoryRanges()`, +`vkInvalidateMappedMemoryRanges()`, but this library provides more convenient +functions that refer to given allocation object: vmaFlushAllocation(), +vmaInvalidateAllocation(). + +Regions of memory specified for flush/invalidate must be aligned to +`VkPhysicalDeviceLimits::nonCoherentAtomSize`. This is automatically ensured by the library. +In any memory type that is `HOST_VISIBLE` but not `HOST_COHERENT`, all allocations +within blocks are aligned to this value, so their offsets are always multiply of +`nonCoherentAtomSize` and two different allocations never share same "line" of this size. + +Please note that memory allocated with #VMA_MEMORY_USAGE_CPU_ONLY is guaranteed to be `HOST_COHERENT`. + +Also, Windows drivers from all 3 **PC** GPU vendors (AMD, Intel, NVIDIA) +currently provide `HOST_COHERENT` flag on all memory types that are +`HOST_VISIBLE`, so on this platform you may not need to bother. + +\section memory_mapping_finding_if_memory_mappable Finding out if memory is mappable + +It may happen that your allocation ends up in memory that is `HOST_VISIBLE` (available for mapping) +despite it wasn't explicitly requested. +For example, application may work on integrated graphics with unified memory (like Intel) or +allocation from video memory might have failed, so the library chose system memory as fallback. + +You can detect this case and map such allocation to access its memory on CPU directly, +instead of launching a transfer operation. +In order to do that: inspect `allocInfo.memoryType`, call vmaGetMemoryTypeProperties(), +and look for `VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT` flag in properties of that memory type. + +\code +VkBufferCreateInfo bufCreateInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO }; +bufCreateInfo.size = sizeof(ConstantBuffer); +bufCreateInfo.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT; + +VmaAllocationCreateInfo allocCreateInfo = {}; +allocCreateInfo.usage = VMA_MEMORY_USAGE_GPU_ONLY; +allocCreateInfo.preferredFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; + +VkBuffer buf; +VmaAllocation alloc; +VmaAllocationInfo allocInfo; +vmaCreateBuffer(allocator, &bufCreateInfo, &allocCreateInfo, &buf, &alloc, &allocInfo); + +VkMemoryPropertyFlags memFlags; +vmaGetMemoryTypeProperties(allocator, allocInfo.memoryType, &memFlags); +if((memFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) == 0) +{ + // Allocation ended up in mappable memory. You can map it and access it directly. + void* mappedData; + vmaMapMemory(allocator, alloc, &mappedData); + memcpy(mappedData, &constantBufferData, sizeof(constantBufferData)); + vmaUnmapMemory(allocator, alloc); +} +else +{ + // Allocation ended up in non-mappable memory. + // You need to create CPU-side buffer in VMA_MEMORY_USAGE_CPU_ONLY and make a transfer. +} +\endcode + +You can even use #VMA_ALLOCATION_CREATE_MAPPED_BIT flag while creating allocations +that are not necessarily `HOST_VISIBLE` (e.g. using #VMA_MEMORY_USAGE_GPU_ONLY). +If the allocation ends up in memory type that is `HOST_VISIBLE`, it will be persistently mapped and you can use it directly. +If not, the flag is just ignored. +Example: + +\code +VkBufferCreateInfo bufCreateInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO }; +bufCreateInfo.size = sizeof(ConstantBuffer); +bufCreateInfo.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT; + +VmaAllocationCreateInfo allocCreateInfo = {}; +allocCreateInfo.usage = VMA_MEMORY_USAGE_GPU_ONLY; +allocCreateInfo.flags = VMA_ALLOCATION_CREATE_MAPPED_BIT; + +VkBuffer buf; +VmaAllocation alloc; +VmaAllocationInfo allocInfo; +vmaCreateBuffer(allocator, &bufCreateInfo, &allocCreateInfo, &buf, &alloc, &allocInfo); + +if(allocInfo.pUserData != nullptr) +{ + // Allocation ended up in mappable memory. + // It's persistently mapped. You can access it directly. + memcpy(allocInfo.pMappedData, &constantBufferData, sizeof(constantBufferData)); +} +else +{ + // Allocation ended up in non-mappable memory. + // You need to create CPU-side buffer in VMA_MEMORY_USAGE_CPU_ONLY and make a transfer. +} +\endcode + + +\page staying_within_budget Staying within budget + +When developing a graphics-intensive game or program, it is important to avoid allocating +more GPU memory than it's physically available. When the memory is over-committed, +various bad things can happen, depending on the specific GPU, graphics driver, and +operating system: + +- It may just work without any problems. +- The application may slow down because some memory blocks are moved to system RAM + and the GPU has to access them through PCI Express bus. +- A new allocation may take very long time to complete, even few seconds, and possibly + freeze entire system. +- The new allocation may fail with `VK_ERROR_OUT_OF_DEVICE_MEMORY`. +- It may even result in GPU crash (TDR), observed as `VK_ERROR_DEVICE_LOST` + returned somewhere later. + +\section staying_within_budget_querying_for_budget Querying for budget + +To query for current memory usage and available budget, use function vmaGetBudget(). +Returned structure #VmaBudget contains quantities expressed in bytes, per Vulkan memory heap. + +Please note that this function returns different information and works faster than +vmaCalculateStats(). vmaGetBudget() can be called every frame or even before every +allocation, while vmaCalculateStats() is intended to be used rarely, +only to obtain statistical information, e.g. for debugging purposes. + +It is recommended to use VK_EXT_memory_budget device extension to obtain information +about the budget from Vulkan device. VMA is able to use this extension automatically. +When not enabled, the allocator behaves same way, but then it estimates current usage +and available budget based on its internal information and Vulkan memory heap sizes, +which may be less precise. In order to use this extension: + +1. Make sure extensions VK_EXT_memory_budget and VK_KHR_get_physical_device_properties2 + required by it are available and enable them. Please note that the first is a device + extension and the second is instance extension! +2. Use flag #VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT when creating #VmaAllocator object. +3. Make sure to call vmaSetCurrentFrameIndex() every frame. Budget is queried from + Vulkan inside of it to avoid overhead of querying it with every allocation. + +\section staying_within_budget_controlling_memory_usage Controlling memory usage + +There are many ways in which you can try to stay within the budget. + +First, when making new allocation requires allocating a new memory block, the library +tries not to exceed the budget automatically. If a block with default recommended size +(e.g. 256 MB) would go over budget, a smaller block is allocated, possibly even +dedicated memory for just this resource. + +If the size of the requested resource plus current memory usage is more than the +budget, by default the library still tries to create it, leaving it to the Vulkan +implementation whether the allocation succeeds or fails. You can change this behavior +by using #VMA_ALLOCATION_CREATE_WITHIN_BUDGET_BIT flag. With it, the allocation is +not made if it would exceed the budget or if the budget is already exceeded. +Some other allocations become lost instead to make room for it, if the mechanism of +[lost allocations](@ref lost_allocations) is used. +If that is not possible, the allocation fails with `VK_ERROR_OUT_OF_DEVICE_MEMORY`. +Example usage pattern may be to pass the #VMA_ALLOCATION_CREATE_WITHIN_BUDGET_BIT flag +when creating resources that are not essential for the application (e.g. the texture +of a specific object) and not to pass it when creating critically important resources +(e.g. render targets). + +Finally, you can also use #VMA_ALLOCATION_CREATE_NEVER_ALLOCATE_BIT flag to make sure +a new allocation is created only when it fits inside one of the existing memory blocks. +If it would require to allocate a new block, if fails instead with `VK_ERROR_OUT_OF_DEVICE_MEMORY`. +This also ensures that the function call is very fast because it never goes to Vulkan +to obtain a new block. + +Please note that creating \ref custom_memory_pools with VmaPoolCreateInfo::minBlockCount +set to more than 0 will try to allocate memory blocks without checking whether they +fit within budget. + + +\page custom_memory_pools Custom memory pools + +A memory pool contains a number of `VkDeviceMemory` blocks. +The library automatically creates and manages default pool for each memory type available on the device. +Default memory pool automatically grows in size. +Size of allocated blocks is also variable and managed automatically. + +You can create custom pool and allocate memory out of it. +It can be useful if you want to: + +- Keep certain kind of allocations separate from others. +- Enforce particular, fixed size of Vulkan memory blocks. +- Limit maximum amount of Vulkan memory allocated for that pool. +- Reserve minimum or fixed amount of Vulkan memory always preallocated for that pool. + +To use custom memory pools: + +-# Fill VmaPoolCreateInfo structure. +-# Call vmaCreatePool() to obtain #VmaPool handle. +-# When making an allocation, set VmaAllocationCreateInfo::pool to this handle. + You don't need to specify any other parameters of this structure, like `usage`. + +Example: + +\code +// Create a pool that can have at most 2 blocks, 128 MiB each. +VmaPoolCreateInfo poolCreateInfo = {}; +poolCreateInfo.memoryTypeIndex = ... +poolCreateInfo.blockSize = 128ull * 1024 * 1024; +poolCreateInfo.maxBlockCount = 2; + +VmaPool pool; +vmaCreatePool(allocator, &poolCreateInfo, &pool); + +// Allocate a buffer out of it. +VkBufferCreateInfo bufCreateInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO }; +bufCreateInfo.size = 1024; +bufCreateInfo.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT; + +VmaAllocationCreateInfo allocCreateInfo = {}; +allocCreateInfo.pool = pool; + +VkBuffer buf; +VmaAllocation alloc; +VmaAllocationInfo allocInfo; +vmaCreateBuffer(allocator, &bufCreateInfo, &allocCreateInfo, &buf, &alloc, &allocInfo); +\endcode + +You have to free all allocations made from this pool before destroying it. + +\code +vmaDestroyBuffer(allocator, buf, alloc); +vmaDestroyPool(allocator, pool); +\endcode + +\section custom_memory_pools_MemTypeIndex Choosing memory type index + +When creating a pool, you must explicitly specify memory type index. +To find the one suitable for your buffers or images, you can use helper functions +vmaFindMemoryTypeIndexForBufferInfo(), vmaFindMemoryTypeIndexForImageInfo(). +You need to provide structures with example parameters of buffers or images +that you are going to create in that pool. + +\code +VkBufferCreateInfo exampleBufCreateInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO }; +exampleBufCreateInfo.size = 1024; // Whatever. +exampleBufCreateInfo.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT; // Change if needed. + +VmaAllocationCreateInfo allocCreateInfo = {}; +allocCreateInfo.usage = VMA_MEMORY_USAGE_GPU_ONLY; // Change if needed. + +uint32_t memTypeIndex; +vmaFindMemoryTypeIndexForBufferInfo(allocator, &exampleBufCreateInfo, &allocCreateInfo, &memTypeIndex); + +VmaPoolCreateInfo poolCreateInfo = {}; +poolCreateInfo.memoryTypeIndex = memTypeIndex; +// ... +\endcode + +When creating buffers/images allocated in that pool, provide following parameters: + +- `VkBufferCreateInfo`: Prefer to pass same parameters as above. + Otherwise you risk creating resources in a memory type that is not suitable for them, which may result in undefined behavior. + Using different `VK_BUFFER_USAGE_` flags may work, but you shouldn't create images in a pool intended for buffers + or the other way around. +- VmaAllocationCreateInfo: You don't need to pass same parameters. Fill only `pool` member. + Other members are ignored anyway. + +\section linear_algorithm Linear allocation algorithm + +Each Vulkan memory block managed by this library has accompanying metadata that +keeps track of used and unused regions. By default, the metadata structure and +algorithm tries to find best place for new allocations among free regions to +optimize memory usage. This way you can allocate and free objects in any order. + +![Default allocation algorithm](../gfx/Linear_allocator_1_algo_default.png) + +Sometimes there is a need to use simpler, linear allocation algorithm. You can +create custom pool that uses such algorithm by adding flag +#VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT to VmaPoolCreateInfo::flags while creating +#VmaPool object. Then an alternative metadata management is used. It always +creates new allocations after last one and doesn't reuse free regions after +allocations freed in the middle. It results in better allocation performance and +less memory consumed by metadata. + +![Linear allocation algorithm](../gfx/Linear_allocator_2_algo_linear.png) + +With this one flag, you can create a custom pool that can be used in many ways: +free-at-once, stack, double stack, and ring buffer. See below for details. + +\subsection linear_algorithm_free_at_once Free-at-once + +In a pool that uses linear algorithm, you still need to free all the allocations +individually, e.g. by using vmaFreeMemory() or vmaDestroyBuffer(). You can free +them in any order. New allocations are always made after last one - free space +in the middle is not reused. However, when you release all the allocation and +the pool becomes empty, allocation starts from the beginning again. This way you +can use linear algorithm to speed up creation of allocations that you are going +to release all at once. + +![Free-at-once](../gfx/Linear_allocator_3_free_at_once.png) + +This mode is also available for pools created with VmaPoolCreateInfo::maxBlockCount +value that allows multiple memory blocks. + +\subsection linear_algorithm_stack Stack + +When you free an allocation that was created last, its space can be reused. +Thanks to this, if you always release allocations in the order opposite to their +creation (LIFO - Last In First Out), you can achieve behavior of a stack. + +![Stack](../gfx/Linear_allocator_4_stack.png) + +This mode is also available for pools created with VmaPoolCreateInfo::maxBlockCount +value that allows multiple memory blocks. + +\subsection linear_algorithm_double_stack Double stack + +The space reserved by a custom pool with linear algorithm may be used by two +stacks: + +- First, default one, growing up from offset 0. +- Second, "upper" one, growing down from the end towards lower offsets. + +To make allocation from upper stack, add flag #VMA_ALLOCATION_CREATE_UPPER_ADDRESS_BIT +to VmaAllocationCreateInfo::flags. + +![Double stack](../gfx/Linear_allocator_7_double_stack.png) + +Double stack is available only in pools with one memory block - +VmaPoolCreateInfo::maxBlockCount must be 1. Otherwise behavior is undefined. + +When the two stacks' ends meet so there is not enough space between them for a +new allocation, such allocation fails with usual +`VK_ERROR_OUT_OF_DEVICE_MEMORY` error. + +\subsection linear_algorithm_ring_buffer Ring buffer + +When you free some allocations from the beginning and there is not enough free space +for a new one at the end of a pool, allocator's "cursor" wraps around to the +beginning and starts allocation there. Thanks to this, if you always release +allocations in the same order as you created them (FIFO - First In First Out), +you can achieve behavior of a ring buffer / queue. + +![Ring buffer](../gfx/Linear_allocator_5_ring_buffer.png) + +Pools with linear algorithm support [lost allocations](@ref lost_allocations) when used as ring buffer. +If there is not enough free space for a new allocation, but existing allocations +from the front of the queue can become lost, they become lost and the allocation +succeeds. + +![Ring buffer with lost allocations](../gfx/Linear_allocator_6_ring_buffer_lost.png) + +Ring buffer is available only in pools with one memory block - +VmaPoolCreateInfo::maxBlockCount must be 1. Otherwise behavior is undefined. + +\section buddy_algorithm Buddy allocation algorithm + +There is another allocation algorithm that can be used with custom pools, called +"buddy". Its internal data structure is based on a tree of blocks, each having +size that is a power of two and a half of its parent's size. When you want to +allocate memory of certain size, a free node in the tree is located. If it's too +large, it is recursively split into two halves (called "buddies"). However, if +requested allocation size is not a power of two, the size of a tree node is +aligned up to the nearest power of two and the remaining space is wasted. When +two buddy nodes become free, they are merged back into one larger node. + +![Buddy allocator](../gfx/Buddy_allocator.png) + +The advantage of buddy allocation algorithm over default algorithm is faster +allocation and deallocation, as well as smaller external fragmentation. The +disadvantage is more wasted space (internal fragmentation). + +For more information, please read ["Buddy memory allocation" on Wikipedia](https://en.wikipedia.org/wiki/Buddy_memory_allocation) +or other sources that describe this concept in general. + +To use buddy allocation algorithm with a custom pool, add flag +#VMA_POOL_CREATE_BUDDY_ALGORITHM_BIT to VmaPoolCreateInfo::flags while creating +#VmaPool object. + +Several limitations apply to pools that use buddy algorithm: + +- It is recommended to use VmaPoolCreateInfo::blockSize that is a power of two. + Otherwise, only largest power of two smaller than the size is used for + allocations. The remaining space always stays unused. +- [Margins](@ref debugging_memory_usage_margins) and + [corruption detection](@ref debugging_memory_usage_corruption_detection) + don't work in such pools. +- [Lost allocations](@ref lost_allocations) don't work in such pools. You can + use them, but they never become lost. Support may be added in the future. +- [Defragmentation](@ref defragmentation) doesn't work with allocations made from + such pool. + +\page defragmentation Defragmentation + +Interleaved allocations and deallocations of many objects of varying size can +cause fragmentation over time, which can lead to a situation where the library is unable +to find a continuous range of free memory for a new allocation despite there is +enough free space, just scattered across many small free ranges between existing +allocations. + +To mitigate this problem, you can use defragmentation feature: +structure #VmaDefragmentationInfo2, function vmaDefragmentationBegin(), vmaDefragmentationEnd(). +Given set of allocations, +this function can move them to compact used memory, ensure more continuous free +space and possibly also free some `VkDeviceMemory` blocks. + +What the defragmentation does is: + +- Updates #VmaAllocation objects to point to new `VkDeviceMemory` and offset. + After allocation has been moved, its VmaAllocationInfo::deviceMemory and/or + VmaAllocationInfo::offset changes. You must query them again using + vmaGetAllocationInfo() if you need them. +- Moves actual data in memory. + +What it doesn't do, so you need to do it yourself: + +- Recreate buffers and images that were bound to allocations that were defragmented and + bind them with their new places in memory. + You must use `vkDestroyBuffer()`, `vkDestroyImage()`, + `vkCreateBuffer()`, `vkCreateImage()`, vmaBindBufferMemory(), vmaBindImageMemory() + for that purpose and NOT vmaDestroyBuffer(), + vmaDestroyImage(), vmaCreateBuffer(), vmaCreateImage(), because you don't need to + destroy or create allocation objects! +- Recreate views and update descriptors that point to these buffers and images. + +\section defragmentation_cpu Defragmenting CPU memory + +Following example demonstrates how you can run defragmentation on CPU. +Only allocations created in memory types that are `HOST_VISIBLE` can be defragmented. +Others are ignored. + +The way it works is: + +- It temporarily maps entire memory blocks when necessary. +- It moves data using `memmove()` function. + +\code +// Given following variables already initialized: +VkDevice device; +VmaAllocator allocator; +std::vector buffers; +std::vector allocations; + + +const uint32_t allocCount = (uint32_t)allocations.size(); +std::vector allocationsChanged(allocCount); + +VmaDefragmentationInfo2 defragInfo = {}; +defragInfo.allocationCount = allocCount; +defragInfo.pAllocations = allocations.data(); +defragInfo.pAllocationsChanged = allocationsChanged.data(); +defragInfo.maxCpuBytesToMove = VK_WHOLE_SIZE; // No limit. +defragInfo.maxCpuAllocationsToMove = UINT32_MAX; // No limit. + +VmaDefragmentationContext defragCtx; +vmaDefragmentationBegin(allocator, &defragInfo, nullptr, &defragCtx); +vmaDefragmentationEnd(allocator, defragCtx); + +for(uint32_t i = 0; i < allocCount; ++i) +{ + if(allocationsChanged[i]) + { + // Destroy buffer that is immutably bound to memory region which is no longer valid. + vkDestroyBuffer(device, buffers[i], nullptr); + + // Create new buffer with same parameters. + VkBufferCreateInfo bufferInfo = ...; + vkCreateBuffer(device, &bufferInfo, nullptr, &buffers[i]); + + // You can make dummy call to vkGetBufferMemoryRequirements here to silence validation layer warning. + + // Bind new buffer to new memory region. Data contained in it is already moved. + VmaAllocationInfo allocInfo; + vmaGetAllocationInfo(allocator, allocations[i], &allocInfo); + vmaBindBufferMemory(allocator, allocations[i], buffers[i]); + } +} +\endcode + +Setting VmaDefragmentationInfo2::pAllocationsChanged is optional. +This output array tells whether particular allocation in VmaDefragmentationInfo2::pAllocations at the same index +has been modified during defragmentation. +You can pass null, but you then need to query every allocation passed to defragmentation +for new parameters using vmaGetAllocationInfo() if you might need to recreate and rebind a buffer or image associated with it. + +If you use [Custom memory pools](@ref choosing_memory_type_custom_memory_pools), +you can fill VmaDefragmentationInfo2::poolCount and VmaDefragmentationInfo2::pPools +instead of VmaDefragmentationInfo2::allocationCount and VmaDefragmentationInfo2::pAllocations +to defragment all allocations in given pools. +You cannot use VmaDefragmentationInfo2::pAllocationsChanged in that case. +You can also combine both methods. + +\section defragmentation_gpu Defragmenting GPU memory + +It is also possible to defragment allocations created in memory types that are not `HOST_VISIBLE`. +To do that, you need to pass a command buffer that meets requirements as described in +VmaDefragmentationInfo2::commandBuffer. The way it works is: + +- It creates temporary buffers and binds them to entire memory blocks when necessary. +- It issues `vkCmdCopyBuffer()` to passed command buffer. + +Example: + +\code +// Given following variables already initialized: +VkDevice device; +VmaAllocator allocator; +VkCommandBuffer commandBuffer; +std::vector buffers; +std::vector allocations; + + +const uint32_t allocCount = (uint32_t)allocations.size(); +std::vector allocationsChanged(allocCount); + +VkCommandBufferBeginInfo cmdBufBeginInfo = ...; +vkBeginCommandBuffer(commandBuffer, &cmdBufBeginInfo); + +VmaDefragmentationInfo2 defragInfo = {}; +defragInfo.allocationCount = allocCount; +defragInfo.pAllocations = allocations.data(); +defragInfo.pAllocationsChanged = allocationsChanged.data(); +defragInfo.maxGpuBytesToMove = VK_WHOLE_SIZE; // Notice it's "GPU" this time. +defragInfo.maxGpuAllocationsToMove = UINT32_MAX; // Notice it's "GPU" this time. +defragInfo.commandBuffer = commandBuffer; + +VmaDefragmentationContext defragCtx; +vmaDefragmentationBegin(allocator, &defragInfo, nullptr, &defragCtx); + +vkEndCommandBuffer(commandBuffer); + +// Submit commandBuffer. +// Wait for a fence that ensures commandBuffer execution finished. + +vmaDefragmentationEnd(allocator, defragCtx); + +for(uint32_t i = 0; i < allocCount; ++i) +{ + if(allocationsChanged[i]) + { + // Destroy buffer that is immutably bound to memory region which is no longer valid. + vkDestroyBuffer(device, buffers[i], nullptr); + + // Create new buffer with same parameters. + VkBufferCreateInfo bufferInfo = ...; + vkCreateBuffer(device, &bufferInfo, nullptr, &buffers[i]); + + // You can make dummy call to vkGetBufferMemoryRequirements here to silence validation layer warning. + + // Bind new buffer to new memory region. Data contained in it is already moved. + VmaAllocationInfo allocInfo; + vmaGetAllocationInfo(allocator, allocations[i], &allocInfo); + vmaBindBufferMemory(allocator, allocations[i], buffers[i]); + } +} +\endcode + +You can combine these two methods by specifying non-zero `maxGpu*` as well as `maxCpu*` parameters. +The library automatically chooses best method to defragment each memory pool. + +You may try not to block your entire program to wait until defragmentation finishes, +but do it in the background, as long as you carefully fullfill requirements described +in function vmaDefragmentationBegin(). + +\section defragmentation_additional_notes Additional notes + +It is only legal to defragment allocations bound to: + +- buffers +- images created with `VK_IMAGE_CREATE_ALIAS_BIT`, `VK_IMAGE_TILING_LINEAR`, and + being currently in `VK_IMAGE_LAYOUT_GENERAL` or `VK_IMAGE_LAYOUT_PREINITIALIZED`. + +Defragmentation of images created with `VK_IMAGE_TILING_OPTIMAL` or in any other +layout may give undefined results. + +If you defragment allocations bound to images, new images to be bound to new +memory region after defragmentation should be created with `VK_IMAGE_LAYOUT_PREINITIALIZED` +and then transitioned to their original layout from before defragmentation if +needed using an image memory barrier. + +While using defragmentation, you may experience validation layer warnings, which you just need to ignore. +See [Validation layer warnings](@ref general_considerations_validation_layer_warnings). + +Please don't expect memory to be fully compacted after defragmentation. +Algorithms inside are based on some heuristics that try to maximize number of Vulkan +memory blocks to make totally empty to release them, as well as to maximimze continuous +empty space inside remaining blocks, while minimizing the number and size of allocations that +need to be moved. Some fragmentation may still remain - this is normal. + +\section defragmentation_custom_algorithm Writing custom defragmentation algorithm + +If you want to implement your own, custom defragmentation algorithm, +there is infrastructure prepared for that, +but it is not exposed through the library API - you need to hack its source code. +Here are steps needed to do this: + +-# Main thing you need to do is to define your own class derived from base abstract + class `VmaDefragmentationAlgorithm` and implement your version of its pure virtual methods. + See definition and comments of this class for details. +-# Your code needs to interact with device memory block metadata. + If you need more access to its data than it's provided by its public interface, + declare your new class as a friend class e.g. in class `VmaBlockMetadata_Generic`. +-# If you want to create a flag that would enable your algorithm or pass some additional + flags to configure it, add them to `VmaDefragmentationFlagBits` and use them in + VmaDefragmentationInfo2::flags. +-# Modify function `VmaBlockVectorDefragmentationContext::Begin` to create object + of your new class whenever needed. + + +\page lost_allocations Lost allocations + +If your game oversubscribes video memory, if may work OK in previous-generation +graphics APIs (DirectX 9, 10, 11, OpenGL) because resources are automatically +paged to system RAM. In Vulkan you can't do it because when you run out of +memory, an allocation just fails. If you have more data (e.g. textures) that can +fit into VRAM and you don't need it all at once, you may want to upload them to +GPU on demand and "push out" ones that are not used for a long time to make room +for the new ones, effectively using VRAM (or a cartain memory pool) as a form of +cache. Vulkan Memory Allocator can help you with that by supporting a concept of +"lost allocations". + +To create an allocation that can become lost, include #VMA_ALLOCATION_CREATE_CAN_BECOME_LOST_BIT +flag in VmaAllocationCreateInfo::flags. Before using a buffer or image bound to +such allocation in every new frame, you need to query it if it's not lost. +To check it, call vmaTouchAllocation(). +If the allocation is lost, you should not use it or buffer/image bound to it. +You mustn't forget to destroy this allocation and this buffer/image. +vmaGetAllocationInfo() can also be used for checking status of the allocation. +Allocation is lost when returned VmaAllocationInfo::deviceMemory == `VK_NULL_HANDLE`. + +To create an allocation that can make some other allocations lost to make room +for it, use #VMA_ALLOCATION_CREATE_CAN_MAKE_OTHER_LOST_BIT flag. You will +usually use both flags #VMA_ALLOCATION_CREATE_CAN_MAKE_OTHER_LOST_BIT and +#VMA_ALLOCATION_CREATE_CAN_BECOME_LOST_BIT at the same time. + +Warning! Current implementation uses quite naive, brute force algorithm, +which can make allocation calls that use #VMA_ALLOCATION_CREATE_CAN_MAKE_OTHER_LOST_BIT +flag quite slow. A new, more optimal algorithm and data structure to speed this +up is planned for the future. + +Q: When interleaving creation of new allocations with usage of existing ones, +how do you make sure that an allocation won't become lost while it's used in the +current frame? + +It is ensured because vmaTouchAllocation() / vmaGetAllocationInfo() not only returns allocation +status/parameters and checks whether it's not lost, but when it's not, it also +atomically marks it as used in the current frame, which makes it impossible to +become lost in that frame. It uses lockless algorithm, so it works fast and +doesn't involve locking any internal mutex. + +Q: What if my allocation may still be in use by the GPU when it's rendering a +previous frame while I already submit new frame on the CPU? + +You can make sure that allocations "touched" by vmaTouchAllocation() / vmaGetAllocationInfo() will not +become lost for a number of additional frames back from the current one by +specifying this number as VmaAllocatorCreateInfo::frameInUseCount (for default +memory pool) and VmaPoolCreateInfo::frameInUseCount (for custom pool). + +Q: How do you inform the library when new frame starts? + +You need to call function vmaSetCurrentFrameIndex(). + +Example code: + +\code +struct MyBuffer +{ + VkBuffer m_Buf = nullptr; + VmaAllocation m_Alloc = nullptr; + + // Called when the buffer is really needed in the current frame. + void EnsureBuffer(); +}; + +void MyBuffer::EnsureBuffer() +{ + // Buffer has been created. + if(m_Buf != VK_NULL_HANDLE) + { + // Check if its allocation is not lost + mark it as used in current frame. + if(vmaTouchAllocation(allocator, m_Alloc)) + { + // It's all OK - safe to use m_Buf. + return; + } + } + + // Buffer not yet exists or lost - destroy and recreate it. + + vmaDestroyBuffer(allocator, m_Buf, m_Alloc); + + VkBufferCreateInfo bufCreateInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO }; + bufCreateInfo.size = 1024; + bufCreateInfo.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT; + + VmaAllocationCreateInfo allocCreateInfo = {}; + allocCreateInfo.usage = VMA_MEMORY_USAGE_GPU_ONLY; + allocCreateInfo.flags = VMA_ALLOCATION_CREATE_CAN_BECOME_LOST_BIT | + VMA_ALLOCATION_CREATE_CAN_MAKE_OTHER_LOST_BIT; + + vmaCreateBuffer(allocator, &bufCreateInfo, &allocCreateInfo, &m_Buf, &m_Alloc, nullptr); +} +\endcode + +When using lost allocations, you may see some Vulkan validation layer warnings +about overlapping regions of memory bound to different kinds of buffers and +images. This is still valid as long as you implement proper handling of lost +allocations (like in the example above) and don't use them. + +You can create an allocation that is already in lost state from the beginning using function +vmaCreateLostAllocation(). It may be useful if you need a "dummy" allocation that is not null. + +You can call function vmaMakePoolAllocationsLost() to set all eligible allocations +in a specified custom pool to lost state. +Allocations that have been "touched" in current frame or VmaPoolCreateInfo::frameInUseCount frames back +cannot become lost. + +Q: Can I touch allocation that cannot become lost? + +Yes, although it has no visible effect. +Calls to vmaGetAllocationInfo() and vmaTouchAllocation() update last use frame index +also for allocations that cannot become lost, but the only way to observe it is to dump +internal allocator state using vmaBuildStatsString(). +You can use this feature for debugging purposes to explicitly mark allocations that you use +in current frame and then analyze JSON dump to see for how long each allocation stays unused. + + +\page statistics Statistics + +This library contains functions that return information about its internal state, +especially the amount of memory allocated from Vulkan. +Please keep in mind that these functions need to traverse all internal data structures +to gather these information, so they may be quite time-consuming. +Don't call them too often. + +\section statistics_numeric_statistics Numeric statistics + +You can query for overall statistics of the allocator using function vmaCalculateStats(). +Information are returned using structure #VmaStats. +It contains #VmaStatInfo - number of allocated blocks, number of allocations +(occupied ranges in these blocks), number of unused (free) ranges in these blocks, +number of bytes used and unused (but still allocated from Vulkan) and other information. +They are summed across memory heaps, memory types and total for whole allocator. + +You can query for statistics of a custom pool using function vmaGetPoolStats(). +Information are returned using structure #VmaPoolStats. + +You can query for information about specific allocation using function vmaGetAllocationInfo(). +It fill structure #VmaAllocationInfo. + +\section statistics_json_dump JSON dump + +You can dump internal state of the allocator to a string in JSON format using function vmaBuildStatsString(). +The result is guaranteed to be correct JSON. +It uses ANSI encoding. +Any strings provided by user (see [Allocation names](@ref allocation_names)) +are copied as-is and properly escaped for JSON, so if they use UTF-8, ISO-8859-2 or any other encoding, +this JSON string can be treated as using this encoding. +It must be freed using function vmaFreeStatsString(). + +The format of this JSON string is not part of official documentation of the library, +but it will not change in backward-incompatible way without increasing library major version number +and appropriate mention in changelog. + +The JSON string contains all the data that can be obtained using vmaCalculateStats(). +It can also contain detailed map of allocated memory blocks and their regions - +free and occupied by allocations. +This allows e.g. to visualize the memory or assess fragmentation. + + +\page allocation_annotation Allocation names and user data + +\section allocation_user_data Allocation user data + +You can annotate allocations with your own information, e.g. for debugging purposes. +To do that, fill VmaAllocationCreateInfo::pUserData field when creating +an allocation. It's an opaque `void*` pointer. You can use it e.g. as a pointer, +some handle, index, key, ordinal number or any other value that would associate +the allocation with your custom metadata. + +\code +VkBufferCreateInfo bufferInfo = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO }; +// Fill bufferInfo... + +MyBufferMetadata* pMetadata = CreateBufferMetadata(); + +VmaAllocationCreateInfo allocCreateInfo = {}; +allocCreateInfo.usage = VMA_MEMORY_USAGE_GPU_ONLY; +allocCreateInfo.pUserData = pMetadata; + +VkBuffer buffer; +VmaAllocation allocation; +vmaCreateBuffer(allocator, &bufferInfo, &allocCreateInfo, &buffer, &allocation, nullptr); +\endcode + +The pointer may be later retrieved as VmaAllocationInfo::pUserData: + +\code +VmaAllocationInfo allocInfo; +vmaGetAllocationInfo(allocator, allocation, &allocInfo); +MyBufferMetadata* pMetadata = (MyBufferMetadata*)allocInfo.pUserData; +\endcode + +It can also be changed using function vmaSetAllocationUserData(). + +Values of (non-zero) allocations' `pUserData` are printed in JSON report created by +vmaBuildStatsString(), in hexadecimal form. + +\section allocation_names Allocation names + +There is alternative mode available where `pUserData` pointer is used to point to +a null-terminated string, giving a name to the allocation. To use this mode, +set #VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT flag in VmaAllocationCreateInfo::flags. +Then `pUserData` passed as VmaAllocationCreateInfo::pUserData or argument to +vmaSetAllocationUserData() must be either null or pointer to a null-terminated string. +The library creates internal copy of the string, so the pointer you pass doesn't need +to be valid for whole lifetime of the allocation. You can free it after the call. + +\code +VkImageCreateInfo imageInfo = { VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO }; +// Fill imageInfo... + +std::string imageName = "Texture: "; +imageName += fileName; + +VmaAllocationCreateInfo allocCreateInfo = {}; +allocCreateInfo.usage = VMA_MEMORY_USAGE_GPU_ONLY; +allocCreateInfo.flags = VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT; +allocCreateInfo.pUserData = imageName.c_str(); + +VkImage image; +VmaAllocation allocation; +vmaCreateImage(allocator, &imageInfo, &allocCreateInfo, &image, &allocation, nullptr); +\endcode + +The value of `pUserData` pointer of the allocation will be different than the one +you passed when setting allocation's name - pointing to a buffer managed +internally that holds copy of the string. + +\code +VmaAllocationInfo allocInfo; +vmaGetAllocationInfo(allocator, allocation, &allocInfo); +const char* imageName = (const char*)allocInfo.pUserData; +printf("Image name: %s\n", imageName); +\endcode + +That string is also printed in JSON report created by vmaBuildStatsString(). + +\note Passing string name to VMA allocation doesn't automatically set it to the Vulkan buffer or image created with it. +You must do it manually using an extension like VK_EXT_debug_utils, which is independent of this library. + + +\page debugging_memory_usage Debugging incorrect memory usage + +If you suspect a bug with memory usage, like usage of uninitialized memory or +memory being overwritten out of bounds of an allocation, +you can use debug features of this library to verify this. + +\section debugging_memory_usage_initialization Memory initialization + +If you experience a bug with incorrect and nondeterministic data in your program and you suspect uninitialized memory to be used, +you can enable automatic memory initialization to verify this. +To do it, define macro `VMA_DEBUG_INITIALIZE_ALLOCATIONS` to 1. + +\code +#define VMA_DEBUG_INITIALIZE_ALLOCATIONS 1 +#include "vk_mem_alloc.h" +\endcode + +It makes memory of all new allocations initialized to bit pattern `0xDCDCDCDC`. +Before an allocation is destroyed, its memory is filled with bit pattern `0xEFEFEFEF`. +Memory is automatically mapped and unmapped if necessary. + +If you find these values while debugging your program, good chances are that you incorrectly +read Vulkan memory that is allocated but not initialized, or already freed, respectively. + +Memory initialization works only with memory types that are `HOST_VISIBLE`. +It works also with dedicated allocations. +It doesn't work with allocations created with #VMA_ALLOCATION_CREATE_CAN_BECOME_LOST_BIT flag, +as they cannot be mapped. + +\section debugging_memory_usage_margins Margins + +By default, allocations are laid out in memory blocks next to each other if possible +(considering required alignment, `bufferImageGranularity`, and `nonCoherentAtomSize`). + +![Allocations without margin](../gfx/Margins_1.png) + +Define macro `VMA_DEBUG_MARGIN` to some non-zero value (e.g. 16) to enforce specified +number of bytes as a margin before and after every allocation. + +\code +#define VMA_DEBUG_MARGIN 16 +#include "vk_mem_alloc.h" +\endcode + +![Allocations with margin](../gfx/Margins_2.png) + +If your bug goes away after enabling margins, it means it may be caused by memory +being overwritten outside of allocation boundaries. It is not 100% certain though. +Change in application behavior may also be caused by different order and distribution +of allocations across memory blocks after margins are applied. + +The margin is applied also before first and after last allocation in a block. +It may occur only once between two adjacent allocations. + +Margins work with all types of memory. + +Margin is applied only to allocations made out of memory blocks and not to dedicated +allocations, which have their own memory block of specific size. +It is thus not applied to allocations made using #VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT flag +or those automatically decided to put into dedicated allocations, e.g. due to its +large size or recommended by VK_KHR_dedicated_allocation extension. +Margins are also not active in custom pools created with #VMA_POOL_CREATE_BUDDY_ALGORITHM_BIT flag. + +Margins appear in [JSON dump](@ref statistics_json_dump) as part of free space. + +Note that enabling margins increases memory usage and fragmentation. + +\section debugging_memory_usage_corruption_detection Corruption detection + +You can additionally define macro `VMA_DEBUG_DETECT_CORRUPTION` to 1 to enable validation +of contents of the margins. + +\code +#define VMA_DEBUG_MARGIN 16 +#define VMA_DEBUG_DETECT_CORRUPTION 1 +#include "vk_mem_alloc.h" +\endcode + +When this feature is enabled, number of bytes specified as `VMA_DEBUG_MARGIN` +(it must be multiply of 4) before and after every allocation is filled with a magic number. +This idea is also know as "canary". +Memory is automatically mapped and unmapped if necessary. + +This number is validated automatically when the allocation is destroyed. +If it's not equal to the expected value, `VMA_ASSERT()` is executed. +It clearly means that either CPU or GPU overwritten the memory outside of boundaries of the allocation, +which indicates a serious bug. + +You can also explicitly request checking margins of all allocations in all memory blocks +that belong to specified memory types by using function vmaCheckCorruption(), +or in memory blocks that belong to specified custom pool, by using function +vmaCheckPoolCorruption(). + +Margin validation (corruption detection) works only for memory types that are +`HOST_VISIBLE` and `HOST_COHERENT`. + + +\page record_and_replay Record and replay + +\section record_and_replay_introduction Introduction + +While using the library, sequence of calls to its functions together with their +parameters can be recorded to a file and later replayed using standalone player +application. It can be useful to: + +- Test correctness - check if same sequence of calls will not cause crash or + failures on a target platform. +- Gather statistics - see number of allocations, peak memory usage, number of + calls etc. +- Benchmark performance - see how much time it takes to replay the whole + sequence. + +\section record_and_replay_usage Usage + +Recording functionality is disabled by default. +To enable it, define following macro before every include of this library: + +\code +#define VMA_RECORDING_ENABLED 1 +\endcode + +To record sequence of calls to a file: Fill in +VmaAllocatorCreateInfo::pRecordSettings member while creating #VmaAllocator +object. File is opened and written during whole lifetime of the allocator. + +To replay file: Use VmaReplay - standalone command-line program. +Precompiled binary can be found in "bin" directory. +Its source can be found in "src/VmaReplay" directory. +Its project is generated by Premake. +Command line syntax is printed when the program is launched without parameters. +Basic usage: + + VmaReplay.exe MyRecording.csv + +Documentation of file format can be found in file: "docs/Recording file format.md". +It's a human-readable, text file in CSV format (Comma Separated Values). + +\section record_and_replay_additional_considerations Additional considerations + +- Replaying file that was recorded on a different GPU (with different parameters + like `bufferImageGranularity`, `nonCoherentAtomSize`, and especially different + set of memory heaps and types) may give different performance and memory usage + results, as well as issue some warnings and errors. +- Current implementation of recording in VMA, as well as VmaReplay application, is + coded and tested only on Windows. Inclusion of recording code is driven by + `VMA_RECORDING_ENABLED` macro. Support for other platforms should be easy to + add. Contributions are welcomed. + + +\page usage_patterns Recommended usage patterns + +See also slides from talk: +[Sawicki, Adam. Advanced Graphics Techniques Tutorial: Memory management in Vulkan and DX12. Game Developers Conference, 2018](https://www.gdcvault.com/play/1025458/Advanced-Graphics-Techniques-Tutorial-New) + + +\section usage_patterns_common_mistakes Common mistakes + +Use of CPU_TO_GPU instead of CPU_ONLY memory + +#VMA_MEMORY_USAGE_CPU_TO_GPU is recommended only for resources that will be +mapped and written by the CPU, as well as read directly by the GPU - like some +buffers or textures updated every frame (dynamic). If you create a staging copy +of a resource to be written by CPU and then used as a source of transfer to +another resource placed in the GPU memory, that staging resource should be +created with #VMA_MEMORY_USAGE_CPU_ONLY. Please read the descriptions of these +enums carefully for details. + +Unnecessary use of custom pools + +\ref custom_memory_pools may be useful for special purposes - when you want to +keep certain type of resources separate e.g. to reserve minimum amount of memory +for them, limit maximum amount of memory they can occupy, or make some of them +push out the other through the mechanism of \ref lost_allocations. For most +resources this is not needed and so it is not recommended to create #VmaPool +objects and allocations out of them. Allocating from the default pool is sufficient. + +\section usage_patterns_simple Simple patterns + +\subsection usage_patterns_simple_render_targets Render targets + +When: +Any resources that you frequently write and read on GPU, +e.g. images used as color attachments (aka "render targets"), depth-stencil attachments, +images/buffers used as storage image/buffer (aka "Unordered Access View (UAV)"). + +What to do: +Create them in video memory that is fastest to access from GPU using +#VMA_MEMORY_USAGE_GPU_ONLY. + +Consider using [VK_KHR_dedicated_allocation](@ref vk_khr_dedicated_allocation) extension +and/or manually creating them as dedicated allocations using #VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT, +especially if they are large or if you plan to destroy and recreate them e.g. when +display resolution changes. +Prefer to create such resources first and all other GPU resources (like textures and vertex buffers) later. + +\subsection usage_patterns_simple_immutable_resources Immutable resources + +When: +Any resources that you fill on CPU only once (aka "immutable") or infrequently +and then read frequently on GPU, +e.g. textures, vertex and index buffers, constant buffers that don't change often. + +What to do: +Create them in video memory that is fastest to access from GPU using +#VMA_MEMORY_USAGE_GPU_ONLY. + +To initialize content of such resource, create a CPU-side (aka "staging") copy of it +in system memory - #VMA_MEMORY_USAGE_CPU_ONLY, map it, fill it, +and submit a transfer from it to the GPU resource. +You can keep the staging copy if you need it for another upload transfer in the future. +If you don't, you can destroy it or reuse this buffer for uploading different resource +after the transfer finishes. + +Prefer to create just buffers in system memory rather than images, even for uploading textures. +Use `vkCmdCopyBufferToImage()`. +Dont use images with `VK_IMAGE_TILING_LINEAR`. + +\subsection usage_patterns_dynamic_resources Dynamic resources + +When: +Any resources that change frequently (aka "dynamic"), e.g. every frame or every draw call, +written on CPU, read on GPU. + +What to do: +Create them using #VMA_MEMORY_USAGE_CPU_TO_GPU. +You can map it and write to it directly on CPU, as well as read from it on GPU. + +This is a more complex situation. Different solutions are possible, +and the best one depends on specific GPU type, but you can use this simple approach for the start. +Prefer to write to such resource sequentially (e.g. using `memcpy`). +Don't perform random access or any reads from it on CPU, as it may be very slow. + +\subsection usage_patterns_readback Readback + +When: +Resources that contain data written by GPU that you want to read back on CPU, +e.g. results of some computations. + +What to do: +Create them using #VMA_MEMORY_USAGE_GPU_TO_CPU. +You can write to them directly on GPU, as well as map and read them on CPU. + +\section usage_patterns_advanced Advanced patterns + +\subsection usage_patterns_integrated_graphics Detecting integrated graphics + +You can support integrated graphics (like Intel HD Graphics, AMD APU) better +by detecting it in Vulkan. +To do it, call `vkGetPhysicalDeviceProperties()`, inspect +`VkPhysicalDeviceProperties::deviceType` and look for `VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU`. +When you find it, you can assume that memory is unified and all memory types are comparably fast +to access from GPU, regardless of `VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT`. + +You can then sum up sizes of all available memory heaps and treat them as useful for +your GPU resources, instead of only `DEVICE_LOCAL` ones. +You can also prefer to create your resources in memory types that are `HOST_VISIBLE` to map them +directly instead of submitting explicit transfer (see below). + +\subsection usage_patterns_direct_vs_transfer Direct access versus transfer + +For resources that you frequently write on CPU and read on GPU, many solutions are possible: + +-# Create one copy in video memory using #VMA_MEMORY_USAGE_GPU_ONLY, + second copy in system memory using #VMA_MEMORY_USAGE_CPU_ONLY and submit explicit tranfer each time. +-# Create just single copy using #VMA_MEMORY_USAGE_CPU_TO_GPU, map it and fill it on CPU, + read it directly on GPU. +-# Create just single copy using #VMA_MEMORY_USAGE_CPU_ONLY, map it and fill it on CPU, + read it directly on GPU. + +Which solution is the most efficient depends on your resource and especially on the GPU. +It is best to measure it and then make the decision. +Some general recommendations: + +- On integrated graphics use (2) or (3) to avoid unnecesary time and memory overhead + related to using a second copy and making transfer. +- For small resources (e.g. constant buffers) use (2). + Discrete AMD cards have special 256 MiB pool of video memory that is directly mappable. + Even if the resource ends up in system memory, its data may be cached on GPU after first + fetch over PCIe bus. +- For larger resources (e.g. textures), decide between (1) and (2). + You may want to differentiate NVIDIA and AMD, e.g. by looking for memory type that is + both `DEVICE_LOCAL` and `HOST_VISIBLE`. When you find it, use (2), otherwise use (1). + +Similarly, for resources that you frequently write on GPU and read on CPU, multiple +solutions are possible: + +-# Create one copy in video memory using #VMA_MEMORY_USAGE_GPU_ONLY, + second copy in system memory using #VMA_MEMORY_USAGE_GPU_TO_CPU and submit explicit tranfer each time. +-# Create just single copy using #VMA_MEMORY_USAGE_GPU_TO_CPU, write to it directly on GPU, + map it and read it on CPU. + +You should take some measurements to decide which option is faster in case of your specific +resource. + +If you don't want to specialize your code for specific types of GPUs, you can still make +an simple optimization for cases when your resource ends up in mappable memory to use it +directly in this case instead of creating CPU-side staging copy. +For details see [Finding out if memory is mappable](@ref memory_mapping_finding_if_memory_mappable). + + +\page configuration Configuration + +Please check "CONFIGURATION SECTION" in the code to find macros that you can define +before each include of this file or change directly in this file to provide +your own implementation of basic facilities like assert, `min()` and `max()` functions, +mutex, atomic etc. +The library uses its own implementation of containers by default, but you can switch to using +STL containers instead. + +For example, define `VMA_ASSERT(expr)` before including the library to provide +custom implementation of the assertion, compatible with your project. +By default it is defined to standard C `assert(expr)` in `_DEBUG` configuration +and empty otherwise. + +\section config_Vulkan_functions Pointers to Vulkan functions + +The library uses Vulkan functions straight from the `vulkan.h` header by default. +If you want to provide your own pointers to these functions, e.g. fetched using +`vkGetInstanceProcAddr()` and `vkGetDeviceProcAddr()`: + +-# Define `VMA_STATIC_VULKAN_FUNCTIONS 0`. +-# Provide valid pointers through VmaAllocatorCreateInfo::pVulkanFunctions. + +\section custom_memory_allocator Custom host memory allocator + +If you use custom allocator for CPU memory rather than default operator `new` +and `delete` from C++, you can make this library using your allocator as well +by filling optional member VmaAllocatorCreateInfo::pAllocationCallbacks. These +functions will be passed to Vulkan, as well as used by the library itself to +make any CPU-side allocations. + +\section allocation_callbacks Device memory allocation callbacks + +The library makes calls to `vkAllocateMemory()` and `vkFreeMemory()` internally. +You can setup callbacks to be informed about these calls, e.g. for the purpose +of gathering some statistics. To do it, fill optional member +VmaAllocatorCreateInfo::pDeviceMemoryCallbacks. + +\section heap_memory_limit Device heap memory limit + +When device memory of certain heap runs out of free space, new allocations may +fail (returning error code) or they may succeed, silently pushing some existing +memory blocks from GPU VRAM to system RAM (which degrades performance). This +behavior is implementation-dependant - it depends on GPU vendor and graphics +driver. + +On AMD cards it can be controlled while creating Vulkan device object by using +VK_AMD_memory_overallocation_behavior extension, if available. + +Alternatively, if you want to test how your program behaves with limited amount of Vulkan device +memory available without switching your graphics card to one that really has +smaller VRAM, you can use a feature of this library intended for this purpose. +To do it, fill optional member VmaAllocatorCreateInfo::pHeapSizeLimit. + + + +\page vk_khr_dedicated_allocation VK_KHR_dedicated_allocation + +VK_KHR_dedicated_allocation is a Vulkan extension which can be used to improve +performance on some GPUs. It augments Vulkan API with possibility to query +driver whether it prefers particular buffer or image to have its own, dedicated +allocation (separate `VkDeviceMemory` block) for better efficiency - to be able +to do some internal optimizations. + +The extension is supported by this library. It will be used automatically when +enabled. To enable it: + +1 . When creating Vulkan device, check if following 2 device extensions are +supported (call `vkEnumerateDeviceExtensionProperties()`). +If yes, enable them (fill `VkDeviceCreateInfo::ppEnabledExtensionNames`). + +- VK_KHR_get_memory_requirements2 +- VK_KHR_dedicated_allocation + +If you enabled these extensions: + +2 . Use #VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT flag when creating +your #VmaAllocator`to inform the library that you enabled required extensions +and you want the library to use them. + +\code +allocatorInfo.flags |= VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT; + +vmaCreateAllocator(&allocatorInfo, &allocator); +\endcode + +That's all. The extension will be automatically used whenever you create a +buffer using vmaCreateBuffer() or image using vmaCreateImage(). + +When using the extension together with Vulkan Validation Layer, you will receive +warnings like this: + + vkBindBufferMemory(): Binding memory to buffer 0x33 but vkGetBufferMemoryRequirements() has not been called on that buffer. + +It is OK, you should just ignore it. It happens because you use function +`vkGetBufferMemoryRequirements2KHR()` instead of standard +`vkGetBufferMemoryRequirements()`, while the validation layer seems to be +unaware of it. + +To learn more about this extension, see: + +- [VK_KHR_dedicated_allocation in Vulkan specification](https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/chap44.html#VK_KHR_dedicated_allocation) +- [VK_KHR_dedicated_allocation unofficial manual](http://asawicki.info/articles/VK_KHR_dedicated_allocation.php5) + + + +\page vk_amd_device_coherent_memory VK_AMD_device_coherent_memory + +VK_AMD_device_coherent_memory is a device extension that enables access to +additional memory types with `VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD` and +`VK_MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD` flag. It is useful mostly for +allocation of buffers intended for writing "breadcrumb markers" in between passes +or draw calls, which in turn are useful for debugging GPU crash/hang/TDR cases. + +When the extension is available but has not been enabled, Vulkan physical device +still exposes those memory types, but their usage is forbidden. VMA automatically +takes care of that - it returns `VK_ERROR_FEATURE_NOT_PRESENT` when an attempt +to allocate memory of such type is made. + +If you want to use this extension in connection with VMA, follow these steps: + +\section vk_amd_device_coherent_memory_initialization Initialization + +1) Call `vkEnumerateDeviceExtensionProperties` for the physical device. +Check if the extension is supported - if returned array of `VkExtensionProperties` contains "VK_AMD_device_coherent_memory". + +2) Call `vkGetPhysicalDeviceFeatures2` for the physical device instead of old `vkGetPhysicalDeviceFeatures`. +Attach additional structure `VkPhysicalDeviceCoherentMemoryFeaturesAMD` to `VkPhysicalDeviceFeatures2::pNext` to be returned. +Check if the device feature is really supported - check if `VkPhysicalDeviceCoherentMemoryFeaturesAMD::deviceCoherentMemory` is true. + +3) While creating device with `vkCreateDevice`, enable this extension - add "VK_AMD_device_coherent_memory" +to the list passed as `VkDeviceCreateInfo::ppEnabledExtensionNames`. + +4) While creating the device, also don't set `VkDeviceCreateInfo::pEnabledFeatures`. +Fill in `VkPhysicalDeviceFeatures2` structure instead and pass it as `VkDeviceCreateInfo::pNext`. +Enable this device feature - attach additional structure `VkPhysicalDeviceCoherentMemoryFeaturesAMD` to +`VkPhysicalDeviceFeatures2::pNext` and set its member `deviceCoherentMemory` to `VK_TRUE`. + +5) While creating #VmaAllocator with vmaCreateAllocator() inform VMA that you +have enabled this extension and feature - add #VMA_ALLOCATOR_CREATE_AMD_DEVICE_COHERENT_MEMORY_BIT +to VmaAllocatorCreateInfo::flags. + +\section vk_amd_device_coherent_memory_usage Usage + +After following steps described above, you can create VMA allocations and custom pools +out of the special `DEVICE_COHERENT` and `DEVICE_UNCACHED` memory types on eligible +devices. There are multiple ways to do it, for example: + +- You can request or prefer to allocate out of such memory types by adding + `VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD` to VmaAllocationCreateInfo::requiredFlags + or VmaAllocationCreateInfo::preferredFlags. Those flags can be freely mixed with + other ways of \ref choosing_memory_type, like setting VmaAllocationCreateInfo::usage. +- If you manually found memory type index to use for this purpose, force allocation + from this specific index by setting VmaAllocationCreateInfo::memoryTypeBits `= 1u << index`. + +\section vk_amd_device_coherent_memory_more_information More information + +To learn more about this extension, see [VK_AMD_device_coherent_memory in Vulkan specification](https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/chap44.html#VK_AMD_device_coherent_memory) + +Example use of this extension can be found in the code of the sample and test suite +accompanying this library. + + +\page general_considerations General considerations + +\section general_considerations_thread_safety Thread safety + +- The library has no global state, so separate #VmaAllocator objects can be used + independently. + There should be no need to create multiple such objects though - one per `VkDevice` is enough. +- By default, all calls to functions that take #VmaAllocator as first parameter + are safe to call from multiple threads simultaneously because they are + synchronized internally when needed. +- When the allocator is created with #VMA_ALLOCATOR_CREATE_EXTERNALLY_SYNCHRONIZED_BIT + flag, calls to functions that take such #VmaAllocator object must be + synchronized externally. +- Access to a #VmaAllocation object must be externally synchronized. For example, + you must not call vmaGetAllocationInfo() and vmaMapMemory() from different + threads at the same time if you pass the same #VmaAllocation object to these + functions. + +\section general_considerations_validation_layer_warnings Validation layer warnings + +When using this library, you can meet following types of warnings issued by +Vulkan validation layer. They don't necessarily indicate a bug, so you may need +to just ignore them. + +- *vkBindBufferMemory(): Binding memory to buffer 0xeb8e4 but vkGetBufferMemoryRequirements() has not been called on that buffer.* + - It happens when VK_KHR_dedicated_allocation extension is enabled. + `vkGetBufferMemoryRequirements2KHR` function is used instead, while validation layer seems to be unaware of it. +- *Mapping an image with layout VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL can result in undefined behavior if this memory is used by the device. Only GENERAL or PREINITIALIZED should be used.* + - It happens when you map a buffer or image, because the library maps entire + `VkDeviceMemory` block, where different types of images and buffers may end + up together, especially on GPUs with unified memory like Intel. +- *Non-linear image 0xebc91 is aliased with linear buffer 0xeb8e4 which may indicate a bug.* + - It happens when you use lost allocations, and a new image or buffer is + created in place of an existing object that bacame lost. + - It may happen also when you use [defragmentation](@ref defragmentation). + +\section general_considerations_allocation_algorithm Allocation algorithm + +The library uses following algorithm for allocation, in order: + +-# Try to find free range of memory in existing blocks. +-# If failed, try to create a new block of `VkDeviceMemory`, with preferred block size. +-# If failed, try to create such block with size/2, size/4, size/8. +-# If failed and #VMA_ALLOCATION_CREATE_CAN_MAKE_OTHER_LOST_BIT flag was + specified, try to find space in existing blocks, possilby making some other + allocations lost. +-# If failed, try to allocate separate `VkDeviceMemory` for this allocation, + just like when you use #VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT. +-# If failed, choose other memory type that meets the requirements specified in + VmaAllocationCreateInfo and go to point 1. +-# If failed, return `VK_ERROR_OUT_OF_DEVICE_MEMORY`. + +\section general_considerations_features_not_supported Features not supported + +Features deliberately excluded from the scope of this library: + +- Data transfer. Uploading (straming) and downloading data of buffers and images + between CPU and GPU memory and related synchronization is responsibility of the user. + Defining some "texture" object that would automatically stream its data from a + staging copy in CPU memory to GPU memory would rather be a feature of another, + higher-level library implemented on top of VMA. +- Allocations for imported/exported external memory. They tend to require + explicit memory type index and dedicated allocation anyway, so they don't + interact with main features of this library. Such special purpose allocations + should be made manually, using `vkCreateBuffer()` and `vkAllocateMemory()`. +- Recreation of buffers and images. Although the library has functions for + buffer and image creation (vmaCreateBuffer(), vmaCreateImage()), you need to + recreate these objects yourself after defragmentation. That's because the big + structures `VkBufferCreateInfo`, `VkImageCreateInfo` are not stored in + #VmaAllocation object. +- Handling CPU memory allocation failures. When dynamically creating small C++ + objects in CPU memory (not Vulkan memory), allocation failures are not checked + and handled gracefully, because that would complicate code significantly and + is usually not needed in desktop PC applications anyway. +- Code free of any compiler warnings. Maintaining the library to compile and + work correctly on so many different platforms is hard enough. Being free of + any warnings, on any version of any compiler, is simply not feasible. +- This is a C++ library with C interface. + Bindings or ports to any other programming languages are welcomed as external projects and + are not going to be included into this repository. + +*/ + +/* +Define this macro to 0/1 to disable/enable support for recording functionality, +available through VmaAllocatorCreateInfo::pRecordSettings. +*/ +#ifndef VMA_RECORDING_ENABLED + #define VMA_RECORDING_ENABLED 0 +#endif + +#ifndef NOMINMAX + #define NOMINMAX // For windows.h +#endif + +#ifndef VULKAN_H_ + #include +#endif + +#if VMA_RECORDING_ENABLED + #include +#endif + +// Define this macro to declare maximum supported Vulkan version in format AAABBBCCC, +// where AAA = major, BBB = minor, CCC = patch. +// If you want to use version > 1.0, it still needs to be enabled via VmaAllocatorCreateInfo::vulkanApiVersion. +#if !defined(VMA_VULKAN_VERSION) + #if defined(VK_VERSION_1_2) + #define VMA_VULKAN_VERSION 1002000 + #elif defined(VK_VERSION_1_1) + #define VMA_VULKAN_VERSION 1001000 + #else + #define VMA_VULKAN_VERSION 1000000 + #endif +#endif + +#if !defined(VMA_DEDICATED_ALLOCATION) + #if VK_KHR_get_memory_requirements2 && VK_KHR_dedicated_allocation + #define VMA_DEDICATED_ALLOCATION 1 + #else + #define VMA_DEDICATED_ALLOCATION 0 + #endif +#endif + +#if !defined(VMA_BIND_MEMORY2) + #if VK_KHR_bind_memory2 + #define VMA_BIND_MEMORY2 1 + #else + #define VMA_BIND_MEMORY2 0 + #endif +#endif + +#if !defined(VMA_MEMORY_BUDGET) + #if VK_EXT_memory_budget && (VK_KHR_get_physical_device_properties2 || VMA_VULKAN_VERSION >= 1001000) + #define VMA_MEMORY_BUDGET 1 + #else + #define VMA_MEMORY_BUDGET 0 + #endif +#endif + +// Define these macros to decorate all public functions with additional code, +// before and after returned type, appropriately. This may be useful for +// exporing the functions when compiling VMA as a separate library. Example: +// #define VMA_CALL_PRE __declspec(dllexport) +// #define VMA_CALL_POST __cdecl +#ifndef VMA_CALL_PRE + #define VMA_CALL_PRE +#endif +#ifndef VMA_CALL_POST + #define VMA_CALL_POST +#endif + +/** \struct VmaAllocator +\brief Represents main object of this library initialized. + +Fill structure #VmaAllocatorCreateInfo and call function vmaCreateAllocator() to create it. +Call function vmaDestroyAllocator() to destroy it. + +It is recommended to create just one object of this type per `VkDevice` object, +right after Vulkan is initialized and keep it alive until before Vulkan device is destroyed. +*/ +VK_DEFINE_HANDLE(VmaAllocator) + +/// Callback function called after successful vkAllocateMemory. +typedef void (VKAPI_PTR *PFN_vmaAllocateDeviceMemoryFunction)( + VmaAllocator allocator, + uint32_t memoryType, + VkDeviceMemory memory, + VkDeviceSize size); +/// Callback function called before vkFreeMemory. +typedef void (VKAPI_PTR *PFN_vmaFreeDeviceMemoryFunction)( + VmaAllocator allocator, + uint32_t memoryType, + VkDeviceMemory memory, + VkDeviceSize size); + +/** \brief Set of callbacks that the library will call for `vkAllocateMemory` and `vkFreeMemory`. + +Provided for informative purpose, e.g. to gather statistics about number of +allocations or total amount of memory allocated in Vulkan. + +Used in VmaAllocatorCreateInfo::pDeviceMemoryCallbacks. +*/ +typedef struct VmaDeviceMemoryCallbacks { + /// Optional, can be null. + PFN_vmaAllocateDeviceMemoryFunction pfnAllocate; + /// Optional, can be null. + PFN_vmaFreeDeviceMemoryFunction pfnFree; +} VmaDeviceMemoryCallbacks; + +/// Flags for created #VmaAllocator. +typedef enum VmaAllocatorCreateFlagBits { + /** \brief Allocator and all objects created from it will not be synchronized internally, so you must guarantee they are used from only one thread at a time or synchronized externally by you. + + Using this flag may increase performance because internal mutexes are not used. + */ + VMA_ALLOCATOR_CREATE_EXTERNALLY_SYNCHRONIZED_BIT = 0x00000001, + /** \brief Enables usage of VK_KHR_dedicated_allocation extension. + + The flag works only if VmaAllocatorCreateInfo::vulkanApiVersion `== VK_API_VERSION_1_0`. + When it's `VK_API_VERSION_1_1`, the flag is ignored because the extension has been promoted to Vulkan 1.1. + + Using this extenion will automatically allocate dedicated blocks of memory for + some buffers and images instead of suballocating place for them out of bigger + memory blocks (as if you explicitly used #VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT + flag) when it is recommended by the driver. It may improve performance on some + GPUs. + + You may set this flag only if you found out that following device extensions are + supported, you enabled them while creating Vulkan device passed as + VmaAllocatorCreateInfo::device, and you want them to be used internally by this + library: + + - VK_KHR_get_memory_requirements2 (device extension) + - VK_KHR_dedicated_allocation (device extension) + + When this flag is set, you can experience following warnings reported by Vulkan + validation layer. You can ignore them. + + > vkBindBufferMemory(): Binding memory to buffer 0x2d but vkGetBufferMemoryRequirements() has not been called on that buffer. + */ + VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT = 0x00000002, + /** + Enables usage of VK_KHR_bind_memory2 extension. + + The flag works only if VmaAllocatorCreateInfo::vulkanApiVersion `== VK_API_VERSION_1_0`. + When it's `VK_API_VERSION_1_1`, the flag is ignored because the extension has been promoted to Vulkan 1.1. + + You may set this flag only if you found out that this device extension is supported, + you enabled it while creating Vulkan device passed as VmaAllocatorCreateInfo::device, + and you want it to be used internally by this library. + + The extension provides functions `vkBindBufferMemory2KHR` and `vkBindImageMemory2KHR`, + which allow to pass a chain of `pNext` structures while binding. + This flag is required if you use `pNext` parameter in vmaBindBufferMemory2() or vmaBindImageMemory2(). + */ + VMA_ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT = 0x00000004, + /** + Enables usage of VK_EXT_memory_budget extension. + + You may set this flag only if you found out that this device extension is supported, + you enabled it while creating Vulkan device passed as VmaAllocatorCreateInfo::device, + and you want it to be used internally by this library, along with another instance extension + VK_KHR_get_physical_device_properties2, which is required by it (or Vulkan 1.1, where this extension is promoted). + + The extension provides query for current memory usage and budget, which will probably + be more accurate than an estimation used by the library otherwise. + */ + VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT = 0x00000008, + /** + Enabled usage of VK_AMD_device_coherent_memory extension. + + You may set this flag only if you: + + - found out that this device extension is supported and enabled it while creating Vulkan device passed as VmaAllocatorCreateInfo::device, + - checked that `VkPhysicalDeviceCoherentMemoryFeaturesAMD::deviceCoherentMemory` is true and set it while creating the Vulkan device, + - want it to be used internally by this library. + + The extension and accompanying device feature provide access to memory types with + `VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD` and `VK_MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD` flags. + They are useful mostly for writing breadcrumb markers - a common method for debugging GPU crash/hang/TDR. + + When the extension is not enabled, such memory types are still enumerated, but their usage is illegal. + To protect from this error, if you don't create the allocator with this flag, it will refuse to allocate any memory or create a custom pool in such memory type, + returning `VK_ERROR_FEATURE_NOT_PRESENT`. + */ + VMA_ALLOCATOR_CREATE_AMD_DEVICE_COHERENT_MEMORY_BIT = 0x00000010, + + VMA_ALLOCATOR_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VmaAllocatorCreateFlagBits; +typedef VkFlags VmaAllocatorCreateFlags; + +/** \brief Pointers to some Vulkan functions - a subset used by the library. + +Used in VmaAllocatorCreateInfo::pVulkanFunctions. +*/ +typedef struct VmaVulkanFunctions { + PFN_vkGetPhysicalDeviceProperties vkGetPhysicalDeviceProperties; + PFN_vkGetPhysicalDeviceMemoryProperties vkGetPhysicalDeviceMemoryProperties; + PFN_vkAllocateMemory vkAllocateMemory; + PFN_vkFreeMemory vkFreeMemory; + PFN_vkMapMemory vkMapMemory; + PFN_vkUnmapMemory vkUnmapMemory; + PFN_vkFlushMappedMemoryRanges vkFlushMappedMemoryRanges; + PFN_vkInvalidateMappedMemoryRanges vkInvalidateMappedMemoryRanges; + PFN_vkBindBufferMemory vkBindBufferMemory; + PFN_vkBindImageMemory vkBindImageMemory; + PFN_vkGetBufferMemoryRequirements vkGetBufferMemoryRequirements; + PFN_vkGetImageMemoryRequirements vkGetImageMemoryRequirements; + PFN_vkCreateBuffer vkCreateBuffer; + PFN_vkDestroyBuffer vkDestroyBuffer; + PFN_vkCreateImage vkCreateImage; + PFN_vkDestroyImage vkDestroyImage; + PFN_vkCmdCopyBuffer vkCmdCopyBuffer; +#if VMA_DEDICATED_ALLOCATION || VMA_VULKAN_VERSION >= 1001000 + PFN_vkGetBufferMemoryRequirements2KHR vkGetBufferMemoryRequirements2KHR; + PFN_vkGetImageMemoryRequirements2KHR vkGetImageMemoryRequirements2KHR; +#endif +#if VMA_BIND_MEMORY2 || VMA_VULKAN_VERSION >= 1001000 + PFN_vkBindBufferMemory2KHR vkBindBufferMemory2KHR; + PFN_vkBindImageMemory2KHR vkBindImageMemory2KHR; +#endif +#if VMA_MEMORY_BUDGET || VMA_VULKAN_VERSION >= 1001000 + PFN_vkGetPhysicalDeviceMemoryProperties2KHR vkGetPhysicalDeviceMemoryProperties2KHR; +#endif +} VmaVulkanFunctions; + +/// Flags to be used in VmaRecordSettings::flags. +typedef enum VmaRecordFlagBits { + /** \brief Enables flush after recording every function call. + + Enable it if you expect your application to crash, which may leave recording file truncated. + It may degrade performance though. + */ + VMA_RECORD_FLUSH_AFTER_CALL_BIT = 0x00000001, + + VMA_RECORD_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VmaRecordFlagBits; +typedef VkFlags VmaRecordFlags; + +/// Parameters for recording calls to VMA functions. To be used in VmaAllocatorCreateInfo::pRecordSettings. +typedef struct VmaRecordSettings +{ + /// Flags for recording. Use #VmaRecordFlagBits enum. + VmaRecordFlags flags; + /** \brief Path to the file that should be written by the recording. + + Suggested extension: "csv". + If the file already exists, it will be overwritten. + It will be opened for the whole time #VmaAllocator object is alive. + If opening this file fails, creation of the whole allocator object fails. + */ + const char* pFilePath; +} VmaRecordSettings; + +/// Description of a Allocator to be created. +typedef struct VmaAllocatorCreateInfo +{ + /// Flags for created allocator. Use #VmaAllocatorCreateFlagBits enum. + VmaAllocatorCreateFlags flags; + /// Vulkan physical device. + /** It must be valid throughout whole lifetime of created allocator. */ + VkPhysicalDevice physicalDevice; + /// Vulkan device. + /** It must be valid throughout whole lifetime of created allocator. */ + VkDevice device; + /// Preferred size of a single `VkDeviceMemory` block to be allocated from large heaps > 1 GiB. Optional. + /** Set to 0 to use default, which is currently 256 MiB. */ + VkDeviceSize preferredLargeHeapBlockSize; + /// Custom CPU memory allocation callbacks. Optional. + /** Optional, can be null. When specified, will also be used for all CPU-side memory allocations. */ + const VkAllocationCallbacks* pAllocationCallbacks; + /// Informative callbacks for `vkAllocateMemory`, `vkFreeMemory`. Optional. + /** Optional, can be null. */ + const VmaDeviceMemoryCallbacks* pDeviceMemoryCallbacks; + /** \brief Maximum number of additional frames that are in use at the same time as current frame. + + This value is used only when you make allocations with + VMA_ALLOCATION_CREATE_CAN_BECOME_LOST_BIT flag. Such allocation cannot become + lost if allocation.lastUseFrameIndex >= allocator.currentFrameIndex - frameInUseCount. + + For example, if you double-buffer your command buffers, so resources used for + rendering in previous frame may still be in use by the GPU at the moment you + allocate resources needed for the current frame, set this value to 1. + + If you want to allow any allocations other than used in the current frame to + become lost, set this value to 0. + */ + uint32_t frameInUseCount; + /** \brief Either null or a pointer to an array of limits on maximum number of bytes that can be allocated out of particular Vulkan memory heap. + + If not NULL, it must be a pointer to an array of + `VkPhysicalDeviceMemoryProperties::memoryHeapCount` elements, defining limit on + maximum number of bytes that can be allocated out of particular Vulkan memory + heap. + + Any of the elements may be equal to `VK_WHOLE_SIZE`, which means no limit on that + heap. This is also the default in case of `pHeapSizeLimit` = NULL. + + If there is a limit defined for a heap: + + - If user tries to allocate more memory from that heap using this allocator, + the allocation fails with `VK_ERROR_OUT_OF_DEVICE_MEMORY`. + - If the limit is smaller than heap size reported in `VkMemoryHeap::size`, the + value of this limit will be reported instead when using vmaGetMemoryProperties(). + + Warning! Using this feature may not be equivalent to installing a GPU with + smaller amount of memory, because graphics driver doesn't necessary fail new + allocations with `VK_ERROR_OUT_OF_DEVICE_MEMORY` result when memory capacity is + exceeded. It may return success and just silently migrate some device memory + blocks to system RAM. This driver behavior can also be controlled using + VK_AMD_memory_overallocation_behavior extension. + */ + const VkDeviceSize* pHeapSizeLimit; + /** \brief Pointers to Vulkan functions. Can be null if you leave define `VMA_STATIC_VULKAN_FUNCTIONS 1`. + + If you leave define `VMA_STATIC_VULKAN_FUNCTIONS 1` in configuration section, + you can pass null as this member, because the library will fetch pointers to + Vulkan functions internally in a static way, like: + + vulkanFunctions.vkAllocateMemory = &vkAllocateMemory; + + Fill this member if you want to provide your own pointers to Vulkan functions, + e.g. fetched using `vkGetInstanceProcAddr()` and `vkGetDeviceProcAddr()`. + */ + const VmaVulkanFunctions* pVulkanFunctions; + /** \brief Parameters for recording of VMA calls. Can be null. + + If not null, it enables recording of calls to VMA functions to a file. + If support for recording is not enabled using `VMA_RECORDING_ENABLED` macro, + creation of the allocator object fails with `VK_ERROR_FEATURE_NOT_PRESENT`. + */ + const VmaRecordSettings* pRecordSettings; + /** \brief Optional handle to Vulkan instance object. + + Optional, can be null. Must be set if #VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT flas is used + or if `vulkanApiVersion >= VK_MAKE_VERSION(1, 1, 0)`. + */ + VkInstance instance; + /** \brief Optional. The highest version of Vulkan that the application is designed to use. + + It must be a value in the format as created by macro `VK_MAKE_VERSION` or a constant like: `VK_API_VERSION_1_1`, `VK_API_VERSION_1_0`. + The patch version number specified is ignored. Only the major and minor versions are considered. + It must be less or equal (preferably equal) to value as passed to `vkCreateInstance` as `VkApplicationInfo::apiVersion`. + Only versions 1.0 and 1.1 are supported by the current implementation. + Leaving it initialized to zero is equivalent to `VK_API_VERSION_1_0`. + */ + uint32_t vulkanApiVersion; +} VmaAllocatorCreateInfo; + +/// Creates Allocator object. +VMA_CALL_PRE VkResult VMA_CALL_POST vmaCreateAllocator( + const VmaAllocatorCreateInfo* pCreateInfo, + VmaAllocator* pAllocator); + +/// Destroys allocator object. +VMA_CALL_PRE void VMA_CALL_POST vmaDestroyAllocator( + VmaAllocator allocator); + +/** \brief Information about existing #VmaAllocator object. +*/ +typedef struct VmaAllocatorInfo +{ + /** \brief Handle to Vulkan instance object. + + This is the same value as has been passed through VmaAllocatorCreateInfo::instance. + */ + VkInstance instance; + /** \brief Handle to Vulkan physical device object. + + This is the same value as has been passed through VmaAllocatorCreateInfo::physicalDevice. + */ + VkPhysicalDevice physicalDevice; + /** \brief Handle to Vulkan device object. + + This is the same value as has been passed through VmaAllocatorCreateInfo::device. + */ + VkDevice device; +} VmaAllocatorInfo; + +/** \brief Returns information about existing #VmaAllocator object - handle to Vulkan device etc. + +It might be useful if you want to keep just the #VmaAllocator handle and fetch other required handles to +`VkPhysicalDevice`, `VkDevice` etc. every time using this function. +*/ +VMA_CALL_PRE void VMA_CALL_POST vmaGetAllocatorInfo(VmaAllocator allocator, VmaAllocatorInfo* pAllocatorInfo); + +/** +PhysicalDeviceProperties are fetched from physicalDevice by the allocator. +You can access it here, without fetching it again on your own. +*/ +VMA_CALL_PRE void VMA_CALL_POST vmaGetPhysicalDeviceProperties( + VmaAllocator allocator, + const VkPhysicalDeviceProperties** ppPhysicalDeviceProperties); + +/** +PhysicalDeviceMemoryProperties are fetched from physicalDevice by the allocator. +You can access it here, without fetching it again on your own. +*/ +VMA_CALL_PRE void VMA_CALL_POST vmaGetMemoryProperties( + VmaAllocator allocator, + const VkPhysicalDeviceMemoryProperties** ppPhysicalDeviceMemoryProperties); + +/** +\brief Given Memory Type Index, returns Property Flags of this memory type. + +This is just a convenience function. Same information can be obtained using +vmaGetMemoryProperties(). +*/ +VMA_CALL_PRE void VMA_CALL_POST vmaGetMemoryTypeProperties( + VmaAllocator allocator, + uint32_t memoryTypeIndex, + VkMemoryPropertyFlags* pFlags); + +/** \brief Sets index of the current frame. + +This function must be used if you make allocations with +#VMA_ALLOCATION_CREATE_CAN_BECOME_LOST_BIT and +#VMA_ALLOCATION_CREATE_CAN_MAKE_OTHER_LOST_BIT flags to inform the allocator +when a new frame begins. Allocations queried using vmaGetAllocationInfo() cannot +become lost in the current frame. +*/ +VMA_CALL_PRE void VMA_CALL_POST vmaSetCurrentFrameIndex( + VmaAllocator allocator, + uint32_t frameIndex); + +/** \brief Calculated statistics of memory usage in entire allocator. +*/ +typedef struct VmaStatInfo +{ + /// Number of `VkDeviceMemory` Vulkan memory blocks allocated. + uint32_t blockCount; + /// Number of #VmaAllocation allocation objects allocated. + uint32_t allocationCount; + /// Number of free ranges of memory between allocations. + uint32_t unusedRangeCount; + /// Total number of bytes occupied by all allocations. + VkDeviceSize usedBytes; + /// Total number of bytes occupied by unused ranges. + VkDeviceSize unusedBytes; + VkDeviceSize allocationSizeMin, allocationSizeAvg, allocationSizeMax; + VkDeviceSize unusedRangeSizeMin, unusedRangeSizeAvg, unusedRangeSizeMax; +} VmaStatInfo; + +/// General statistics from current state of Allocator. +typedef struct VmaStats +{ + VmaStatInfo memoryType[VK_MAX_MEMORY_TYPES]; + VmaStatInfo memoryHeap[VK_MAX_MEMORY_HEAPS]; + VmaStatInfo total; +} VmaStats; + +/** \brief Retrieves statistics from current state of the Allocator. + +This function is called "calculate" not "get" because it has to traverse all +internal data structures, so it may be quite slow. For faster but more brief statistics +suitable to be called every frame or every allocation, use vmaGetBudget(). + +Note that when using allocator from multiple threads, returned information may immediately +become outdated. +*/ +VMA_CALL_PRE void VMA_CALL_POST vmaCalculateStats( + VmaAllocator allocator, + VmaStats* pStats); + +/** \brief Statistics of current memory usage and available budget, in bytes, for specific memory heap. +*/ +typedef struct VmaBudget +{ + /** \brief Sum size of all `VkDeviceMemory` blocks allocated from particular heap, in bytes. + */ + VkDeviceSize blockBytes; + + /** \brief Sum size of all allocations created in particular heap, in bytes. + + Usually less or equal than `blockBytes`. + Difference `blockBytes - allocationBytes` is the amount of memory allocated but unused - + available for new allocations or wasted due to fragmentation. + + It might be greater than `blockBytes` if there are some allocations in lost state, as they account + to this value as well. + */ + VkDeviceSize allocationBytes; + + /** \brief Estimated current memory usage of the program, in bytes. + + Fetched from system using `VK_EXT_memory_budget` extension if enabled. + + It might be different than `blockBytes` (usually higher) due to additional implicit objects + also occupying the memory, like swapchain, pipelines, descriptor heaps, command buffers, or + `VkDeviceMemory` blocks allocated outside of this library, if any. + */ + VkDeviceSize usage; + + /** \brief Estimated amount of memory available to the program, in bytes. + + Fetched from system using `VK_EXT_memory_budget` extension if enabled. + + It might be different (most probably smaller) than `VkMemoryHeap::size[heapIndex]` due to factors + external to the program, like other programs also consuming system resources. + Difference `budget - usage` is the amount of additional memory that can probably + be allocated without problems. Exceeding the budget may result in various problems. + */ + VkDeviceSize budget; +} VmaBudget; + +/** \brief Retrieves information about current memory budget for all memory heaps. + +\param[out] pBudget Must point to array with number of elements at least equal to number of memory heaps in physical device used. + +This function is called "get" not "calculate" because it is very fast, suitable to be called +every frame or every allocation. For more detailed statistics use vmaCalculateStats(). + +Note that when using allocator from multiple threads, returned information may immediately +become outdated. +*/ +VMA_CALL_PRE void VMA_CALL_POST vmaGetBudget( + VmaAllocator allocator, + VmaBudget* pBudget); + +#ifndef VMA_STATS_STRING_ENABLED +#define VMA_STATS_STRING_ENABLED 1 +#endif + +#if VMA_STATS_STRING_ENABLED + +/// Builds and returns statistics as string in JSON format. +/** @param[out] ppStatsString Must be freed using vmaFreeStatsString() function. +*/ +VMA_CALL_PRE void VMA_CALL_POST vmaBuildStatsString( + VmaAllocator allocator, + char** ppStatsString, + VkBool32 detailedMap); + +VMA_CALL_PRE void VMA_CALL_POST vmaFreeStatsString( + VmaAllocator allocator, + char* pStatsString); + +#endif // #if VMA_STATS_STRING_ENABLED + +/** \struct VmaPool +\brief Represents custom memory pool + +Fill structure VmaPoolCreateInfo and call function vmaCreatePool() to create it. +Call function vmaDestroyPool() to destroy it. + +For more information see [Custom memory pools](@ref choosing_memory_type_custom_memory_pools). +*/ +VK_DEFINE_HANDLE(VmaPool) + +typedef enum VmaMemoryUsage +{ + /** No intended memory usage specified. + Use other members of VmaAllocationCreateInfo to specify your requirements. + */ + VMA_MEMORY_USAGE_UNKNOWN = 0, + /** Memory will be used on device only, so fast access from the device is preferred. + It usually means device-local GPU (video) memory. + No need to be mappable on host. + It is roughly equivalent of `D3D12_HEAP_TYPE_DEFAULT`. + + Usage: + + - Resources written and read by device, e.g. images used as attachments. + - Resources transferred from host once (immutable) or infrequently and read by + device multiple times, e.g. textures to be sampled, vertex buffers, uniform + (constant) buffers, and majority of other types of resources used on GPU. + + Allocation may still end up in `HOST_VISIBLE` memory on some implementations. + In such case, you are free to map it. + You can use #VMA_ALLOCATION_CREATE_MAPPED_BIT with this usage type. + */ + VMA_MEMORY_USAGE_GPU_ONLY = 1, + /** Memory will be mappable on host. + It usually means CPU (system) memory. + Guarantees to be `HOST_VISIBLE` and `HOST_COHERENT`. + CPU access is typically uncached. Writes may be write-combined. + Resources created in this pool may still be accessible to the device, but access to them can be slow. + It is roughly equivalent of `D3D12_HEAP_TYPE_UPLOAD`. + + Usage: Staging copy of resources used as transfer source. + */ + VMA_MEMORY_USAGE_CPU_ONLY = 2, + /** + Memory that is both mappable on host (guarantees to be `HOST_VISIBLE`) and preferably fast to access by GPU. + CPU access is typically uncached. Writes may be write-combined. + + Usage: Resources written frequently by host (dynamic), read by device. E.g. textures, vertex buffers, uniform buffers updated every frame or every draw call. + */ + VMA_MEMORY_USAGE_CPU_TO_GPU = 3, + /** Memory mappable on host (guarantees to be `HOST_VISIBLE`) and cached. + It is roughly equivalent of `D3D12_HEAP_TYPE_READBACK`. + + Usage: + + - Resources written by device, read by host - results of some computations, e.g. screen capture, average scene luminance for HDR tone mapping. + - Any resources read or accessed randomly on host, e.g. CPU-side copy of vertex buffer used as source of transfer, but also used for collision detection. + */ + VMA_MEMORY_USAGE_GPU_TO_CPU = 4, + /** CPU memory - memory that is preferably not `DEVICE_LOCAL`, but also not guaranteed to be `HOST_VISIBLE`. + + Usage: Staging copy of resources moved from GPU memory to CPU memory as part + of custom paging/residency mechanism, to be moved back to GPU memory when needed. + */ + VMA_MEMORY_USAGE_CPU_COPY = 5, + /** Lazily allocated GPU memory having `VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT`. + Exists mostly on mobile platforms. Using it on desktop PC or other GPUs with no such memory type present will fail the allocation. + + Usage: Memory for transient attachment images (color attachments, depth attachments etc.), created with `VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT`. + + Allocations with this usage are always created as dedicated - it implies #VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT. + */ + VMA_MEMORY_USAGE_GPU_LAZILY_ALLOCATED = 6, + + VMA_MEMORY_USAGE_MAX_ENUM = 0x7FFFFFFF +} VmaMemoryUsage; + +/// Flags to be passed as VmaAllocationCreateInfo::flags. +typedef enum VmaAllocationCreateFlagBits { + /** \brief Set this flag if the allocation should have its own memory block. + + Use it for special, big resources, like fullscreen images used as attachments. + + You should not use this flag if VmaAllocationCreateInfo::pool is not null. + */ + VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT = 0x00000001, + + /** \brief Set this flag to only try to allocate from existing `VkDeviceMemory` blocks and never create new such block. + + If new allocation cannot be placed in any of the existing blocks, allocation + fails with `VK_ERROR_OUT_OF_DEVICE_MEMORY` error. + + You should not use #VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT and + #VMA_ALLOCATION_CREATE_NEVER_ALLOCATE_BIT at the same time. It makes no sense. + + If VmaAllocationCreateInfo::pool is not null, this flag is implied and ignored. */ + VMA_ALLOCATION_CREATE_NEVER_ALLOCATE_BIT = 0x00000002, + /** \brief Set this flag to use a memory that will be persistently mapped and retrieve pointer to it. + + Pointer to mapped memory will be returned through VmaAllocationInfo::pMappedData. + + Is it valid to use this flag for allocation made from memory type that is not + `HOST_VISIBLE`. This flag is then ignored and memory is not mapped. This is + useful if you need an allocation that is efficient to use on GPU + (`DEVICE_LOCAL`) and still want to map it directly if possible on platforms that + support it (e.g. Intel GPU). + + You should not use this flag together with #VMA_ALLOCATION_CREATE_CAN_BECOME_LOST_BIT. + */ + VMA_ALLOCATION_CREATE_MAPPED_BIT = 0x00000004, + /** Allocation created with this flag can become lost as a result of another + allocation with #VMA_ALLOCATION_CREATE_CAN_MAKE_OTHER_LOST_BIT flag, so you + must check it before use. + + To check if allocation is not lost, call vmaGetAllocationInfo() and check if + VmaAllocationInfo::deviceMemory is not `VK_NULL_HANDLE`. + + For details about supporting lost allocations, see Lost Allocations + chapter of User Guide on Main Page. + + You should not use this flag together with #VMA_ALLOCATION_CREATE_MAPPED_BIT. + */ + VMA_ALLOCATION_CREATE_CAN_BECOME_LOST_BIT = 0x00000008, + /** While creating allocation using this flag, other allocations that were + created with flag #VMA_ALLOCATION_CREATE_CAN_BECOME_LOST_BIT can become lost. + + For details about supporting lost allocations, see Lost Allocations + chapter of User Guide on Main Page. + */ + VMA_ALLOCATION_CREATE_CAN_MAKE_OTHER_LOST_BIT = 0x00000010, + /** Set this flag to treat VmaAllocationCreateInfo::pUserData as pointer to a + null-terminated string. Instead of copying pointer value, a local copy of the + string is made and stored in allocation's `pUserData`. The string is automatically + freed together with the allocation. It is also used in vmaBuildStatsString(). + */ + VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT = 0x00000020, + /** Allocation will be created from upper stack in a double stack pool. + + This flag is only allowed for custom pools created with #VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT flag. + */ + VMA_ALLOCATION_CREATE_UPPER_ADDRESS_BIT = 0x00000040, + /** Create both buffer/image and allocation, but don't bind them together. + It is useful when you want to bind yourself to do some more advanced binding, e.g. using some extensions. + The flag is meaningful only with functions that bind by default: vmaCreateBuffer(), vmaCreateImage(). + Otherwise it is ignored. + */ + VMA_ALLOCATION_CREATE_DONT_BIND_BIT = 0x00000080, + /** Create allocation only if additional device memory required for it, if any, won't exceed + memory budget. Otherwise return `VK_ERROR_OUT_OF_DEVICE_MEMORY`. + */ + VMA_ALLOCATION_CREATE_WITHIN_BUDGET_BIT = 0x00000100, + + /** Allocation strategy that chooses smallest possible free range for the + allocation. + */ + VMA_ALLOCATION_CREATE_STRATEGY_BEST_FIT_BIT = 0x00010000, + /** Allocation strategy that chooses biggest possible free range for the + allocation. + */ + VMA_ALLOCATION_CREATE_STRATEGY_WORST_FIT_BIT = 0x00020000, + /** Allocation strategy that chooses first suitable free range for the + allocation. + + "First" doesn't necessarily means the one with smallest offset in memory, + but rather the one that is easiest and fastest to find. + */ + VMA_ALLOCATION_CREATE_STRATEGY_FIRST_FIT_BIT = 0x00040000, + + /** Allocation strategy that tries to minimize memory usage. + */ + VMA_ALLOCATION_CREATE_STRATEGY_MIN_MEMORY_BIT = VMA_ALLOCATION_CREATE_STRATEGY_BEST_FIT_BIT, + /** Allocation strategy that tries to minimize allocation time. + */ + VMA_ALLOCATION_CREATE_STRATEGY_MIN_TIME_BIT = VMA_ALLOCATION_CREATE_STRATEGY_FIRST_FIT_BIT, + /** Allocation strategy that tries to minimize memory fragmentation. + */ + VMA_ALLOCATION_CREATE_STRATEGY_MIN_FRAGMENTATION_BIT = VMA_ALLOCATION_CREATE_STRATEGY_WORST_FIT_BIT, + + /** A bit mask to extract only `STRATEGY` bits from entire set of flags. + */ + VMA_ALLOCATION_CREATE_STRATEGY_MASK = + VMA_ALLOCATION_CREATE_STRATEGY_BEST_FIT_BIT | + VMA_ALLOCATION_CREATE_STRATEGY_WORST_FIT_BIT | + VMA_ALLOCATION_CREATE_STRATEGY_FIRST_FIT_BIT, + + VMA_ALLOCATION_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VmaAllocationCreateFlagBits; +typedef VkFlags VmaAllocationCreateFlags; + +typedef struct VmaAllocationCreateInfo +{ + /// Use #VmaAllocationCreateFlagBits enum. + VmaAllocationCreateFlags flags; + /** \brief Intended usage of memory. + + You can leave #VMA_MEMORY_USAGE_UNKNOWN if you specify memory requirements in other way. \n + If `pool` is not null, this member is ignored. + */ + VmaMemoryUsage usage; + /** \brief Flags that must be set in a Memory Type chosen for an allocation. + + Leave 0 if you specify memory requirements in other way. \n + If `pool` is not null, this member is ignored.*/ + VkMemoryPropertyFlags requiredFlags; + /** \brief Flags that preferably should be set in a memory type chosen for an allocation. + + Set to 0 if no additional flags are prefered. \n + If `pool` is not null, this member is ignored. */ + VkMemoryPropertyFlags preferredFlags; + /** \brief Bitmask containing one bit set for every memory type acceptable for this allocation. + + Value 0 is equivalent to `UINT32_MAX` - it means any memory type is accepted if + it meets other requirements specified by this structure, with no further + restrictions on memory type index. \n + If `pool` is not null, this member is ignored. + */ + uint32_t memoryTypeBits; + /** \brief Pool that this allocation should be created in. + + Leave `VK_NULL_HANDLE` to allocate from default pool. If not null, members: + `usage`, `requiredFlags`, `preferredFlags`, `memoryTypeBits` are ignored. + */ + VmaPool pool; + /** \brief Custom general-purpose pointer that will be stored in #VmaAllocation, can be read as VmaAllocationInfo::pUserData and changed using vmaSetAllocationUserData(). + + If #VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT is used, it must be either + null or pointer to a null-terminated string. The string will be then copied to + internal buffer, so it doesn't need to be valid after allocation call. + */ + void* pUserData; +} VmaAllocationCreateInfo; + +/** +\brief Helps to find memoryTypeIndex, given memoryTypeBits and VmaAllocationCreateInfo. + +This algorithm tries to find a memory type that: + +- Is allowed by memoryTypeBits. +- Contains all the flags from pAllocationCreateInfo->requiredFlags. +- Matches intended usage. +- Has as many flags from pAllocationCreateInfo->preferredFlags as possible. + +\return Returns VK_ERROR_FEATURE_NOT_PRESENT if not found. Receiving such result +from this function or any other allocating function probably means that your +device doesn't support any memory type with requested features for the specific +type of resource you want to use it for. Please check parameters of your +resource, like image layout (OPTIMAL versus LINEAR) or mip level count. +*/ +VMA_CALL_PRE VkResult VMA_CALL_POST vmaFindMemoryTypeIndex( + VmaAllocator allocator, + uint32_t memoryTypeBits, + const VmaAllocationCreateInfo* pAllocationCreateInfo, + uint32_t* pMemoryTypeIndex); + +/** +\brief Helps to find memoryTypeIndex, given VkBufferCreateInfo and VmaAllocationCreateInfo. + +It can be useful e.g. to determine value to be used as VmaPoolCreateInfo::memoryTypeIndex. +It internally creates a temporary, dummy buffer that never has memory bound. +It is just a convenience function, equivalent to calling: + +- `vkCreateBuffer` +- `vkGetBufferMemoryRequirements` +- `vmaFindMemoryTypeIndex` +- `vkDestroyBuffer` +*/ +VMA_CALL_PRE VkResult VMA_CALL_POST vmaFindMemoryTypeIndexForBufferInfo( + VmaAllocator allocator, + const VkBufferCreateInfo* pBufferCreateInfo, + const VmaAllocationCreateInfo* pAllocationCreateInfo, + uint32_t* pMemoryTypeIndex); + +/** +\brief Helps to find memoryTypeIndex, given VkImageCreateInfo and VmaAllocationCreateInfo. + +It can be useful e.g. to determine value to be used as VmaPoolCreateInfo::memoryTypeIndex. +It internally creates a temporary, dummy image that never has memory bound. +It is just a convenience function, equivalent to calling: + +- `vkCreateImage` +- `vkGetImageMemoryRequirements` +- `vmaFindMemoryTypeIndex` +- `vkDestroyImage` +*/ +VMA_CALL_PRE VkResult VMA_CALL_POST vmaFindMemoryTypeIndexForImageInfo( + VmaAllocator allocator, + const VkImageCreateInfo* pImageCreateInfo, + const VmaAllocationCreateInfo* pAllocationCreateInfo, + uint32_t* pMemoryTypeIndex); + +/// Flags to be passed as VmaPoolCreateInfo::flags. +typedef enum VmaPoolCreateFlagBits { + /** \brief Use this flag if you always allocate only buffers and linear images or only optimal images out of this pool and so Buffer-Image Granularity can be ignored. + + This is an optional optimization flag. + + If you always allocate using vmaCreateBuffer(), vmaCreateImage(), + vmaAllocateMemoryForBuffer(), then you don't need to use it because allocator + knows exact type of your allocations so it can handle Buffer-Image Granularity + in the optimal way. + + If you also allocate using vmaAllocateMemoryForImage() or vmaAllocateMemory(), + exact type of such allocations is not known, so allocator must be conservative + in handling Buffer-Image Granularity, which can lead to suboptimal allocation + (wasted memory). In that case, if you can make sure you always allocate only + buffers and linear images or only optimal images out of this pool, use this flag + to make allocator disregard Buffer-Image Granularity and so make allocations + faster and more optimal. + */ + VMA_POOL_CREATE_IGNORE_BUFFER_IMAGE_GRANULARITY_BIT = 0x00000002, + + /** \brief Enables alternative, linear allocation algorithm in this pool. + + Specify this flag to enable linear allocation algorithm, which always creates + new allocations after last one and doesn't reuse space from allocations freed in + between. It trades memory consumption for simplified algorithm and data + structure, which has better performance and uses less memory for metadata. + + By using this flag, you can achieve behavior of free-at-once, stack, + ring buffer, and double stack. For details, see documentation chapter + \ref linear_algorithm. + + When using this flag, you must specify VmaPoolCreateInfo::maxBlockCount == 1 (or 0 for default). + + For more details, see [Linear allocation algorithm](@ref linear_algorithm). + */ + VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT = 0x00000004, + + /** \brief Enables alternative, buddy allocation algorithm in this pool. + + It operates on a tree of blocks, each having size that is a power of two and + a half of its parent's size. Comparing to default algorithm, this one provides + faster allocation and deallocation and decreased external fragmentation, + at the expense of more memory wasted (internal fragmentation). + + For more details, see [Buddy allocation algorithm](@ref buddy_algorithm). + */ + VMA_POOL_CREATE_BUDDY_ALGORITHM_BIT = 0x00000008, + + /** Bit mask to extract only `ALGORITHM` bits from entire set of flags. + */ + VMA_POOL_CREATE_ALGORITHM_MASK = + VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT | + VMA_POOL_CREATE_BUDDY_ALGORITHM_BIT, + + VMA_POOL_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VmaPoolCreateFlagBits; +typedef VkFlags VmaPoolCreateFlags; + +/** \brief Describes parameter of created #VmaPool. +*/ +typedef struct VmaPoolCreateInfo { + /** \brief Vulkan memory type index to allocate this pool from. + */ + uint32_t memoryTypeIndex; + /** \brief Use combination of #VmaPoolCreateFlagBits. + */ + VmaPoolCreateFlags flags; + /** \brief Size of a single `VkDeviceMemory` block to be allocated as part of this pool, in bytes. Optional. + + Specify nonzero to set explicit, constant size of memory blocks used by this + pool. + + Leave 0 to use default and let the library manage block sizes automatically. + Sizes of particular blocks may vary. + */ + VkDeviceSize blockSize; + /** \brief Minimum number of blocks to be always allocated in this pool, even if they stay empty. + + Set to 0 to have no preallocated blocks and allow the pool be completely empty. + */ + size_t minBlockCount; + /** \brief Maximum number of blocks that can be allocated in this pool. Optional. + + Set to 0 to use default, which is `SIZE_MAX`, which means no limit. + + Set to same value as VmaPoolCreateInfo::minBlockCount to have fixed amount of memory allocated + throughout whole lifetime of this pool. + */ + size_t maxBlockCount; + /** \brief Maximum number of additional frames that are in use at the same time as current frame. + + This value is used only when you make allocations with + #VMA_ALLOCATION_CREATE_CAN_BECOME_LOST_BIT flag. Such allocation cannot become + lost if allocation.lastUseFrameIndex >= allocator.currentFrameIndex - frameInUseCount. + + For example, if you double-buffer your command buffers, so resources used for + rendering in previous frame may still be in use by the GPU at the moment you + allocate resources needed for the current frame, set this value to 1. + + If you want to allow any allocations other than used in the current frame to + become lost, set this value to 0. + */ + uint32_t frameInUseCount; +} VmaPoolCreateInfo; + +/** \brief Describes parameter of existing #VmaPool. +*/ +typedef struct VmaPoolStats { + /** \brief Total amount of `VkDeviceMemory` allocated from Vulkan for this pool, in bytes. + */ + VkDeviceSize size; + /** \brief Total number of bytes in the pool not used by any #VmaAllocation. + */ + VkDeviceSize unusedSize; + /** \brief Number of #VmaAllocation objects created from this pool that were not destroyed or lost. + */ + size_t allocationCount; + /** \brief Number of continuous memory ranges in the pool not used by any #VmaAllocation. + */ + size_t unusedRangeCount; + /** \brief Size of the largest continuous free memory region available for new allocation. + + Making a new allocation of that size is not guaranteed to succeed because of + possible additional margin required to respect alignment and buffer/image + granularity. + */ + VkDeviceSize unusedRangeSizeMax; + /** \brief Number of `VkDeviceMemory` blocks allocated for this pool. + */ + size_t blockCount; +} VmaPoolStats; + +/** \brief Allocates Vulkan device memory and creates #VmaPool object. + +@param allocator Allocator object. +@param pCreateInfo Parameters of pool to create. +@param[out] pPool Handle to created pool. +*/ +VMA_CALL_PRE VkResult VMA_CALL_POST vmaCreatePool( + VmaAllocator allocator, + const VmaPoolCreateInfo* pCreateInfo, + VmaPool* pPool); + +/** \brief Destroys #VmaPool object and frees Vulkan device memory. +*/ +VMA_CALL_PRE void VMA_CALL_POST vmaDestroyPool( + VmaAllocator allocator, + VmaPool pool); + +/** \brief Retrieves statistics of existing #VmaPool object. + +@param allocator Allocator object. +@param pool Pool object. +@param[out] pPoolStats Statistics of specified pool. +*/ +VMA_CALL_PRE void VMA_CALL_POST vmaGetPoolStats( + VmaAllocator allocator, + VmaPool pool, + VmaPoolStats* pPoolStats); + +/** \brief Marks all allocations in given pool as lost if they are not used in current frame or VmaPoolCreateInfo::frameInUseCount back from now. + +@param allocator Allocator object. +@param pool Pool. +@param[out] pLostAllocationCount Number of allocations marked as lost. Optional - pass null if you don't need this information. +*/ +VMA_CALL_PRE void VMA_CALL_POST vmaMakePoolAllocationsLost( + VmaAllocator allocator, + VmaPool pool, + size_t* pLostAllocationCount); + +/** \brief Checks magic number in margins around all allocations in given memory pool in search for corruptions. + +Corruption detection is enabled only when `VMA_DEBUG_DETECT_CORRUPTION` macro is defined to nonzero, +`VMA_DEBUG_MARGIN` is defined to nonzero and the pool is created in memory type that is +`HOST_VISIBLE` and `HOST_COHERENT`. For more information, see [Corruption detection](@ref debugging_memory_usage_corruption_detection). + +Possible return values: + +- `VK_ERROR_FEATURE_NOT_PRESENT` - corruption detection is not enabled for specified pool. +- `VK_SUCCESS` - corruption detection has been performed and succeeded. +- `VK_ERROR_VALIDATION_FAILED_EXT` - corruption detection has been performed and found memory corruptions around one of the allocations. + `VMA_ASSERT` is also fired in that case. +- Other value: Error returned by Vulkan, e.g. memory mapping failure. +*/ +VMA_CALL_PRE VkResult VMA_CALL_POST vmaCheckPoolCorruption(VmaAllocator allocator, VmaPool pool); + +/** \brief Retrieves name of a custom pool. + +After the call `ppName` is either null or points to an internally-owned null-terminated string +containing name of the pool that was previously set. The pointer becomes invalid when the pool is +destroyed or its name is changed using vmaSetPoolName(). +*/ +VMA_CALL_PRE void VMA_CALL_POST vmaGetPoolName( + VmaAllocator allocator, + VmaPool pool, + const char** ppName); + +/** \brief Sets name of a custom pool. + +`pName` can be either null or pointer to a null-terminated string with new name for the pool. +Function makes internal copy of the string, so it can be changed or freed immediately after this call. +*/ +VMA_CALL_PRE void VMA_CALL_POST vmaSetPoolName( + VmaAllocator allocator, + VmaPool pool, + const char* pName); + +/** \struct VmaAllocation +\brief Represents single memory allocation. + +It may be either dedicated block of `VkDeviceMemory` or a specific region of a bigger block of this type +plus unique offset. + +There are multiple ways to create such object. +You need to fill structure VmaAllocationCreateInfo. +For more information see [Choosing memory type](@ref choosing_memory_type). + +Although the library provides convenience functions that create Vulkan buffer or image, +allocate memory for it and bind them together, +binding of the allocation to a buffer or an image is out of scope of the allocation itself. +Allocation object can exist without buffer/image bound, +binding can be done manually by the user, and destruction of it can be done +independently of destruction of the allocation. + +The object also remembers its size and some other information. +To retrieve this information, use function vmaGetAllocationInfo() and inspect +returned structure VmaAllocationInfo. + +Some kinds allocations can be in lost state. +For more information, see [Lost allocations](@ref lost_allocations). +*/ +VK_DEFINE_HANDLE(VmaAllocation) + +/** \brief Parameters of #VmaAllocation objects, that can be retrieved using function vmaGetAllocationInfo(). +*/ +typedef struct VmaAllocationInfo { + /** \brief Memory type index that this allocation was allocated from. + + It never changes. + */ + uint32_t memoryType; + /** \brief Handle to Vulkan memory object. + + Same memory object can be shared by multiple allocations. + + It can change after call to vmaDefragment() if this allocation is passed to the function, or if allocation is lost. + + If the allocation is lost, it is equal to `VK_NULL_HANDLE`. + */ + VkDeviceMemory deviceMemory; + /** \brief Offset into deviceMemory object to the beginning of this allocation, in bytes. (deviceMemory, offset) pair is unique to this allocation. + + It can change after call to vmaDefragment() if this allocation is passed to the function, or if allocation is lost. + */ + VkDeviceSize offset; + /** \brief Size of this allocation, in bytes. + + It never changes, unless allocation is lost. + */ + VkDeviceSize size; + /** \brief Pointer to the beginning of this allocation as mapped data. + + If the allocation hasn't been mapped using vmaMapMemory() and hasn't been + created with #VMA_ALLOCATION_CREATE_MAPPED_BIT flag, this value null. + + It can change after call to vmaMapMemory(), vmaUnmapMemory(). + It can also change after call to vmaDefragment() if this allocation is passed to the function. + */ + void* pMappedData; + /** \brief Custom general-purpose pointer that was passed as VmaAllocationCreateInfo::pUserData or set using vmaSetAllocationUserData(). + + It can change after call to vmaSetAllocationUserData() for this allocation. + */ + void* pUserData; +} VmaAllocationInfo; + +/** \brief General purpose memory allocation. + +@param[out] pAllocation Handle to allocated memory. +@param[out] pAllocationInfo Optional. Information about allocated memory. It can be later fetched using function vmaGetAllocationInfo(). + +You should free the memory using vmaFreeMemory() or vmaFreeMemoryPages(). + +It is recommended to use vmaAllocateMemoryForBuffer(), vmaAllocateMemoryForImage(), +vmaCreateBuffer(), vmaCreateImage() instead whenever possible. +*/ +VMA_CALL_PRE VkResult VMA_CALL_POST vmaAllocateMemory( + VmaAllocator allocator, + const VkMemoryRequirements* pVkMemoryRequirements, + const VmaAllocationCreateInfo* pCreateInfo, + VmaAllocation* pAllocation, + VmaAllocationInfo* pAllocationInfo); + +/** \brief General purpose memory allocation for multiple allocation objects at once. + +@param allocator Allocator object. +@param pVkMemoryRequirements Memory requirements for each allocation. +@param pCreateInfo Creation parameters for each alloction. +@param allocationCount Number of allocations to make. +@param[out] pAllocations Pointer to array that will be filled with handles to created allocations. +@param[out] pAllocationInfo Optional. Pointer to array that will be filled with parameters of created allocations. + +You should free the memory using vmaFreeMemory() or vmaFreeMemoryPages(). + +Word "pages" is just a suggestion to use this function to allocate pieces of memory needed for sparse binding. +It is just a general purpose allocation function able to make multiple allocations at once. +It may be internally optimized to be more efficient than calling vmaAllocateMemory() `allocationCount` times. + +All allocations are made using same parameters. All of them are created out of the same memory pool and type. +If any allocation fails, all allocations already made within this function call are also freed, so that when +returned result is not `VK_SUCCESS`, `pAllocation` array is always entirely filled with `VK_NULL_HANDLE`. +*/ +VMA_CALL_PRE VkResult VMA_CALL_POST vmaAllocateMemoryPages( + VmaAllocator allocator, + const VkMemoryRequirements* pVkMemoryRequirements, + const VmaAllocationCreateInfo* pCreateInfo, + size_t allocationCount, + VmaAllocation* pAllocations, + VmaAllocationInfo* pAllocationInfo); + +/** +@param[out] pAllocation Handle to allocated memory. +@param[out] pAllocationInfo Optional. Information about allocated memory. It can be later fetched using function vmaGetAllocationInfo(). + +You should free the memory using vmaFreeMemory(). +*/ +VMA_CALL_PRE VkResult VMA_CALL_POST vmaAllocateMemoryForBuffer( + VmaAllocator allocator, + VkBuffer buffer, + const VmaAllocationCreateInfo* pCreateInfo, + VmaAllocation* pAllocation, + VmaAllocationInfo* pAllocationInfo); + +/// Function similar to vmaAllocateMemoryForBuffer(). +VMA_CALL_PRE VkResult VMA_CALL_POST vmaAllocateMemoryForImage( + VmaAllocator allocator, + VkImage image, + const VmaAllocationCreateInfo* pCreateInfo, + VmaAllocation* pAllocation, + VmaAllocationInfo* pAllocationInfo); + +/** \brief Frees memory previously allocated using vmaAllocateMemory(), vmaAllocateMemoryForBuffer(), or vmaAllocateMemoryForImage(). + +Passing `VK_NULL_HANDLE` as `allocation` is valid. Such function call is just skipped. +*/ +VMA_CALL_PRE void VMA_CALL_POST vmaFreeMemory( + VmaAllocator allocator, + VmaAllocation allocation); + +/** \brief Frees memory and destroys multiple allocations. + +Word "pages" is just a suggestion to use this function to free pieces of memory used for sparse binding. +It is just a general purpose function to free memory and destroy allocations made using e.g. vmaAllocateMemory(), +vmaAllocateMemoryPages() and other functions. +It may be internally optimized to be more efficient than calling vmaFreeMemory() `allocationCount` times. + +Allocations in `pAllocations` array can come from any memory pools and types. +Passing `VK_NULL_HANDLE` as elements of `pAllocations` array is valid. Such entries are just skipped. +*/ +VMA_CALL_PRE void VMA_CALL_POST vmaFreeMemoryPages( + VmaAllocator allocator, + size_t allocationCount, + VmaAllocation* pAllocations); + +/** \brief Deprecated. + +\deprecated +In version 2.2.0 it used to try to change allocation's size without moving or reallocating it. +In current version it returns `VK_SUCCESS` only if `newSize` equals current allocation's size. +Otherwise returns `VK_ERROR_OUT_OF_POOL_MEMORY`, indicating that allocation's size could not be changed. +*/ +VMA_CALL_PRE VkResult VMA_CALL_POST vmaResizeAllocation( + VmaAllocator allocator, + VmaAllocation allocation, + VkDeviceSize newSize); + +/** \brief Returns current information about specified allocation and atomically marks it as used in current frame. + +Current paramters of given allocation are returned in `pAllocationInfo`. + +This function also atomically "touches" allocation - marks it as used in current frame, +just like vmaTouchAllocation(). +If the allocation is in lost state, `pAllocationInfo->deviceMemory == VK_NULL_HANDLE`. + +Although this function uses atomics and doesn't lock any mutex, so it should be quite efficient, +you can avoid calling it too often. + +- You can retrieve same VmaAllocationInfo structure while creating your resource, from function + vmaCreateBuffer(), vmaCreateImage(). You can remember it if you are sure parameters don't change + (e.g. due to defragmentation or allocation becoming lost). +- If you just want to check if allocation is not lost, vmaTouchAllocation() will work faster. +*/ +VMA_CALL_PRE void VMA_CALL_POST vmaGetAllocationInfo( + VmaAllocator allocator, + VmaAllocation allocation, + VmaAllocationInfo* pAllocationInfo); + +/** \brief Returns `VK_TRUE` if allocation is not lost and atomically marks it as used in current frame. + +If the allocation has been created with #VMA_ALLOCATION_CREATE_CAN_BECOME_LOST_BIT flag, +this function returns `VK_TRUE` if it's not in lost state, so it can still be used. +It then also atomically "touches" the allocation - marks it as used in current frame, +so that you can be sure it won't become lost in current frame or next `frameInUseCount` frames. + +If the allocation is in lost state, the function returns `VK_FALSE`. +Memory of such allocation, as well as buffer or image bound to it, should not be used. +Lost allocation and the buffer/image still need to be destroyed. + +If the allocation has been created without #VMA_ALLOCATION_CREATE_CAN_BECOME_LOST_BIT flag, +this function always returns `VK_TRUE`. +*/ +VMA_CALL_PRE VkBool32 VMA_CALL_POST vmaTouchAllocation( + VmaAllocator allocator, + VmaAllocation allocation); + +/** \brief Sets pUserData in given allocation to new value. + +If the allocation was created with VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT, +pUserData must be either null, or pointer to a null-terminated string. The function +makes local copy of the string and sets it as allocation's `pUserData`. String +passed as pUserData doesn't need to be valid for whole lifetime of the allocation - +you can free it after this call. String previously pointed by allocation's +pUserData is freed from memory. + +If the flag was not used, the value of pointer `pUserData` is just copied to +allocation's `pUserData`. It is opaque, so you can use it however you want - e.g. +as a pointer, ordinal number or some handle to you own data. +*/ +VMA_CALL_PRE void VMA_CALL_POST vmaSetAllocationUserData( + VmaAllocator allocator, + VmaAllocation allocation, + void* pUserData); + +/** \brief Creates new allocation that is in lost state from the beginning. + +It can be useful if you need a dummy, non-null allocation. + +You still need to destroy created object using vmaFreeMemory(). + +Returned allocation is not tied to any specific memory pool or memory type and +not bound to any image or buffer. It has size = 0. It cannot be turned into +a real, non-empty allocation. +*/ +VMA_CALL_PRE void VMA_CALL_POST vmaCreateLostAllocation( + VmaAllocator allocator, + VmaAllocation* pAllocation); + +/** \brief Maps memory represented by given allocation and returns pointer to it. + +Maps memory represented by given allocation to make it accessible to CPU code. +When succeeded, `*ppData` contains pointer to first byte of this memory. +If the allocation is part of bigger `VkDeviceMemory` block, the pointer is +correctly offseted to the beginning of region assigned to this particular +allocation. + +Mapping is internally reference-counted and synchronized, so despite raw Vulkan +function `vkMapMemory()` cannot be used to map same block of `VkDeviceMemory` +multiple times simultaneously, it is safe to call this function on allocations +assigned to the same memory block. Actual Vulkan memory will be mapped on first +mapping and unmapped on last unmapping. + +If the function succeeded, you must call vmaUnmapMemory() to unmap the +allocation when mapping is no longer needed or before freeing the allocation, at +the latest. + +It also safe to call this function multiple times on the same allocation. You +must call vmaUnmapMemory() same number of times as you called vmaMapMemory(). + +It is also safe to call this function on allocation created with +#VMA_ALLOCATION_CREATE_MAPPED_BIT flag. Its memory stays mapped all the time. +You must still call vmaUnmapMemory() same number of times as you called +vmaMapMemory(). You must not call vmaUnmapMemory() additional time to free the +"0-th" mapping made automatically due to #VMA_ALLOCATION_CREATE_MAPPED_BIT flag. + +This function fails when used on allocation made in memory type that is not +`HOST_VISIBLE`. + +This function always fails when called for allocation that was created with +#VMA_ALLOCATION_CREATE_CAN_BECOME_LOST_BIT flag. Such allocations cannot be +mapped. + +This function doesn't automatically flush or invalidate caches. +If the allocation is made from a memory types that is not `HOST_COHERENT`, +you also need to use vmaInvalidateAllocation() / vmaFlushAllocation(), as required by Vulkan specification. +*/ +VMA_CALL_PRE VkResult VMA_CALL_POST vmaMapMemory( + VmaAllocator allocator, + VmaAllocation allocation, + void** ppData); + +/** \brief Unmaps memory represented by given allocation, mapped previously using vmaMapMemory(). + +For details, see description of vmaMapMemory(). + +This function doesn't automatically flush or invalidate caches. +If the allocation is made from a memory types that is not `HOST_COHERENT`, +you also need to use vmaInvalidateAllocation() / vmaFlushAllocation(), as required by Vulkan specification. +*/ +VMA_CALL_PRE void VMA_CALL_POST vmaUnmapMemory( + VmaAllocator allocator, + VmaAllocation allocation); + +/** \brief Flushes memory of given allocation. + +Calls `vkFlushMappedMemoryRanges()` for memory associated with given range of given allocation. +It needs to be called after writing to a mapped memory for memory types that are not `HOST_COHERENT`. +Unmap operation doesn't do that automatically. + +- `offset` must be relative to the beginning of allocation. +- `size` can be `VK_WHOLE_SIZE`. It means all memory from `offset` the the end of given allocation. +- `offset` and `size` don't have to be aligned. + They are internally rounded down/up to multiply of `nonCoherentAtomSize`. +- If `size` is 0, this call is ignored. +- If memory type that the `allocation` belongs to is not `HOST_VISIBLE` or it is `HOST_COHERENT`, + this call is ignored. + +Warning! `offset` and `size` are relative to the contents of given `allocation`. +If you mean whole allocation, you can pass 0 and `VK_WHOLE_SIZE`, respectively. +Do not pass allocation's offset as `offset`!!! +*/ +VMA_CALL_PRE void VMA_CALL_POST vmaFlushAllocation(VmaAllocator allocator, VmaAllocation allocation, VkDeviceSize offset, VkDeviceSize size); + +/** \brief Invalidates memory of given allocation. + +Calls `vkInvalidateMappedMemoryRanges()` for memory associated with given range of given allocation. +It needs to be called before reading from a mapped memory for memory types that are not `HOST_COHERENT`. +Map operation doesn't do that automatically. + +- `offset` must be relative to the beginning of allocation. +- `size` can be `VK_WHOLE_SIZE`. It means all memory from `offset` the the end of given allocation. +- `offset` and `size` don't have to be aligned. + They are internally rounded down/up to multiply of `nonCoherentAtomSize`. +- If `size` is 0, this call is ignored. +- If memory type that the `allocation` belongs to is not `HOST_VISIBLE` or it is `HOST_COHERENT`, + this call is ignored. + +Warning! `offset` and `size` are relative to the contents of given `allocation`. +If you mean whole allocation, you can pass 0 and `VK_WHOLE_SIZE`, respectively. +Do not pass allocation's offset as `offset`!!! +*/ +VMA_CALL_PRE void VMA_CALL_POST vmaInvalidateAllocation(VmaAllocator allocator, VmaAllocation allocation, VkDeviceSize offset, VkDeviceSize size); + +/** \brief Checks magic number in margins around all allocations in given memory types (in both default and custom pools) in search for corruptions. + +@param memoryTypeBits Bit mask, where each bit set means that a memory type with that index should be checked. + +Corruption detection is enabled only when `VMA_DEBUG_DETECT_CORRUPTION` macro is defined to nonzero, +`VMA_DEBUG_MARGIN` is defined to nonzero and only for memory types that are +`HOST_VISIBLE` and `HOST_COHERENT`. For more information, see [Corruption detection](@ref debugging_memory_usage_corruption_detection). + +Possible return values: + +- `VK_ERROR_FEATURE_NOT_PRESENT` - corruption detection is not enabled for any of specified memory types. +- `VK_SUCCESS` - corruption detection has been performed and succeeded. +- `VK_ERROR_VALIDATION_FAILED_EXT` - corruption detection has been performed and found memory corruptions around one of the allocations. + `VMA_ASSERT` is also fired in that case. +- Other value: Error returned by Vulkan, e.g. memory mapping failure. +*/ +VMA_CALL_PRE VkResult VMA_CALL_POST vmaCheckCorruption(VmaAllocator allocator, uint32_t memoryTypeBits); + +/** \struct VmaDefragmentationContext +\brief Represents Opaque object that represents started defragmentation process. + +Fill structure #VmaDefragmentationInfo2 and call function vmaDefragmentationBegin() to create it. +Call function vmaDefragmentationEnd() to destroy it. +*/ +VK_DEFINE_HANDLE(VmaDefragmentationContext) + +/// Flags to be used in vmaDefragmentationBegin(). None at the moment. Reserved for future use. +typedef enum VmaDefragmentationFlagBits { + VMA_DEFRAGMENTATION_FLAG_INCREMENTAL = 0x1, + VMA_DEFRAGMENTATION_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VmaDefragmentationFlagBits; +typedef VkFlags VmaDefragmentationFlags; + +/** \brief Parameters for defragmentation. + +To be used with function vmaDefragmentationBegin(). +*/ +typedef struct VmaDefragmentationInfo2 { + /** \brief Reserved for future use. Should be 0. + */ + VmaDefragmentationFlags flags; + /** \brief Number of allocations in `pAllocations` array. + */ + uint32_t allocationCount; + /** \brief Pointer to array of allocations that can be defragmented. + + The array should have `allocationCount` elements. + The array should not contain nulls. + Elements in the array should be unique - same allocation cannot occur twice. + It is safe to pass allocations that are in the lost state - they are ignored. + All allocations not present in this array are considered non-moveable during this defragmentation. + */ + VmaAllocation* pAllocations; + /** \brief Optional, output. Pointer to array that will be filled with information whether the allocation at certain index has been changed during defragmentation. + + The array should have `allocationCount` elements. + You can pass null if you are not interested in this information. + */ + VkBool32* pAllocationsChanged; + /** \brief Numer of pools in `pPools` array. + */ + uint32_t poolCount; + /** \brief Either null or pointer to array of pools to be defragmented. + + All the allocations in the specified pools can be moved during defragmentation + and there is no way to check if they were really moved as in `pAllocationsChanged`, + so you must query all the allocations in all these pools for new `VkDeviceMemory` + and offset using vmaGetAllocationInfo() if you might need to recreate buffers + and images bound to them. + + The array should have `poolCount` elements. + The array should not contain nulls. + Elements in the array should be unique - same pool cannot occur twice. + + Using this array is equivalent to specifying all allocations from the pools in `pAllocations`. + It might be more efficient. + */ + VmaPool* pPools; + /** \brief Maximum total numbers of bytes that can be copied while moving allocations to different places using transfers on CPU side, like `memcpy()`, `memmove()`. + + `VK_WHOLE_SIZE` means no limit. + */ + VkDeviceSize maxCpuBytesToMove; + /** \brief Maximum number of allocations that can be moved to a different place using transfers on CPU side, like `memcpy()`, `memmove()`. + + `UINT32_MAX` means no limit. + */ + uint32_t maxCpuAllocationsToMove; + /** \brief Maximum total numbers of bytes that can be copied while moving allocations to different places using transfers on GPU side, posted to `commandBuffer`. + + `VK_WHOLE_SIZE` means no limit. + */ + VkDeviceSize maxGpuBytesToMove; + /** \brief Maximum number of allocations that can be moved to a different place using transfers on GPU side, posted to `commandBuffer`. + + `UINT32_MAX` means no limit. + */ + uint32_t maxGpuAllocationsToMove; + /** \brief Optional. Command buffer where GPU copy commands will be posted. + + If not null, it must be a valid command buffer handle that supports Transfer queue type. + It must be in the recording state and outside of a render pass instance. + You need to submit it and make sure it finished execution before calling vmaDefragmentationEnd(). + + Passing null means that only CPU defragmentation will be performed. + */ + VkCommandBuffer commandBuffer; +} VmaDefragmentationInfo2; + +typedef struct VmaDefragmentationPassMoveInfo { + VmaAllocation allocation; + VkDeviceMemory memory; + VkDeviceSize offset; +} VmaDefragmentationPassMoveInfo; + +/** \brief Parameters for incremental defragmentation steps. + +To be used with function vmaBeginDefragmentationPass(). +*/ +typedef struct VmaDefragmentationPassInfo { + uint32_t moveCount; + VmaDefragmentationPassMoveInfo* pMoves; +} VmaDefragmentationPassInfo; + +/** \brief Deprecated. Optional configuration parameters to be passed to function vmaDefragment(). + +\deprecated This is a part of the old interface. It is recommended to use structure #VmaDefragmentationInfo2 and function vmaDefragmentationBegin() instead. +*/ +typedef struct VmaDefragmentationInfo { + /** \brief Maximum total numbers of bytes that can be copied while moving allocations to different places. + + Default is `VK_WHOLE_SIZE`, which means no limit. + */ + VkDeviceSize maxBytesToMove; + /** \brief Maximum number of allocations that can be moved to different place. + + Default is `UINT32_MAX`, which means no limit. + */ + uint32_t maxAllocationsToMove; +} VmaDefragmentationInfo; + +/** \brief Statistics returned by function vmaDefragment(). */ +typedef struct VmaDefragmentationStats { + /// Total number of bytes that have been copied while moving allocations to different places. + VkDeviceSize bytesMoved; + /// Total number of bytes that have been released to the system by freeing empty `VkDeviceMemory` objects. + VkDeviceSize bytesFreed; + /// Number of allocations that have been moved to different places. + uint32_t allocationsMoved; + /// Number of empty `VkDeviceMemory` objects that have been released to the system. + uint32_t deviceMemoryBlocksFreed; +} VmaDefragmentationStats; + +/** \brief Begins defragmentation process. + +@param allocator Allocator object. +@param pInfo Structure filled with parameters of defragmentation. +@param[out] pStats Optional. Statistics of defragmentation. You can pass null if you are not interested in this information. +@param[out] pContext Context object that must be passed to vmaDefragmentationEnd() to finish defragmentation. +@return `VK_SUCCESS` and `*pContext == null` if defragmentation finished within this function call. `VK_NOT_READY` and `*pContext != null` if defragmentation has been started and you need to call vmaDefragmentationEnd() to finish it. Negative value in case of error. + +Use this function instead of old, deprecated vmaDefragment(). + +Warning! Between the call to vmaDefragmentationBegin() and vmaDefragmentationEnd(): + +- You should not use any of allocations passed as `pInfo->pAllocations` or + any allocations that belong to pools passed as `pInfo->pPools`, + including calling vmaGetAllocationInfo(), vmaTouchAllocation(), or access + their data. +- Some mutexes protecting internal data structures may be locked, so trying to + make or free any allocations, bind buffers or images, map memory, or launch + another simultaneous defragmentation in between may cause stall (when done on + another thread) or deadlock (when done on the same thread), unless you are + 100% sure that defragmented allocations are in different pools. +- Information returned via `pStats` and `pInfo->pAllocationsChanged` are undefined. + They become valid after call to vmaDefragmentationEnd(). +- If `pInfo->commandBuffer` is not null, you must submit that command buffer + and make sure it finished execution before calling vmaDefragmentationEnd(). + +For more information and important limitations regarding defragmentation, see documentation chapter: +[Defragmentation](@ref defragmentation). +*/ +VMA_CALL_PRE VkResult VMA_CALL_POST vmaDefragmentationBegin( + VmaAllocator allocator, + const VmaDefragmentationInfo2* pInfo, + VmaDefragmentationStats* pStats, + VmaDefragmentationContext *pContext); + +/** \brief Ends defragmentation process. + +Use this function to finish defragmentation started by vmaDefragmentationBegin(). +It is safe to pass `context == null`. The function then does nothing. +*/ +VMA_CALL_PRE VkResult VMA_CALL_POST vmaDefragmentationEnd( + VmaAllocator allocator, + VmaDefragmentationContext context); + +VMA_CALL_PRE VkResult VMA_CALL_POST vmaBeginDefragmentationPass( + VmaAllocator allocator, + VmaDefragmentationContext context, + VmaDefragmentationPassInfo* pInfo +); +VMA_CALL_PRE VkResult VMA_CALL_POST vmaEndDefragmentationPass( + VmaAllocator allocator, + VmaDefragmentationContext context +); + +/** \brief Deprecated. Compacts memory by moving allocations. + +@param pAllocations Array of allocations that can be moved during this compation. +@param allocationCount Number of elements in pAllocations and pAllocationsChanged arrays. +@param[out] pAllocationsChanged Array of boolean values that will indicate whether matching allocation in pAllocations array has been moved. This parameter is optional. Pass null if you don't need this information. +@param pDefragmentationInfo Configuration parameters. Optional - pass null to use default values. +@param[out] pDefragmentationStats Statistics returned by the function. Optional - pass null if you don't need this information. +@return `VK_SUCCESS` if completed, negative error code in case of error. + +\deprecated This is a part of the old interface. It is recommended to use structure #VmaDefragmentationInfo2 and function vmaDefragmentationBegin() instead. + +This function works by moving allocations to different places (different +`VkDeviceMemory` objects and/or different offsets) in order to optimize memory +usage. Only allocations that are in `pAllocations` array can be moved. All other +allocations are considered nonmovable in this call. Basic rules: + +- Only allocations made in memory types that have + `VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT` and `VK_MEMORY_PROPERTY_HOST_COHERENT_BIT` + flags can be compacted. You may pass other allocations but it makes no sense - + these will never be moved. +- Custom pools created with #VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT or + #VMA_POOL_CREATE_BUDDY_ALGORITHM_BIT flag are not defragmented. Allocations + passed to this function that come from such pools are ignored. +- Allocations created with #VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT or + created as dedicated allocations for any other reason are also ignored. +- Both allocations made with or without #VMA_ALLOCATION_CREATE_MAPPED_BIT + flag can be compacted. If not persistently mapped, memory will be mapped + temporarily inside this function if needed. +- You must not pass same #VmaAllocation object multiple times in `pAllocations` array. + +The function also frees empty `VkDeviceMemory` blocks. + +Warning: This function may be time-consuming, so you shouldn't call it too often +(like after every resource creation/destruction). +You can call it on special occasions (like when reloading a game level or +when you just destroyed a lot of objects). Calling it every frame may be OK, but +you should measure that on your platform. + +For more information, see [Defragmentation](@ref defragmentation) chapter. +*/ +VMA_CALL_PRE VkResult VMA_CALL_POST vmaDefragment( + VmaAllocator allocator, + VmaAllocation* pAllocations, + size_t allocationCount, + VkBool32* pAllocationsChanged, + const VmaDefragmentationInfo *pDefragmentationInfo, + VmaDefragmentationStats* pDefragmentationStats); + +/** \brief Binds buffer to allocation. + +Binds specified buffer to region of memory represented by specified allocation. +Gets `VkDeviceMemory` handle and offset from the allocation. +If you want to create a buffer, allocate memory for it and bind them together separately, +you should use this function for binding instead of standard `vkBindBufferMemory()`, +because it ensures proper synchronization so that when a `VkDeviceMemory` object is used by multiple +allocations, calls to `vkBind*Memory()` or `vkMapMemory()` won't happen from multiple threads simultaneously +(which is illegal in Vulkan). + +It is recommended to use function vmaCreateBuffer() instead of this one. +*/ +VMA_CALL_PRE VkResult VMA_CALL_POST vmaBindBufferMemory( + VmaAllocator allocator, + VmaAllocation allocation, + VkBuffer buffer); + +/** \brief Binds buffer to allocation with additional parameters. + +@param allocationLocalOffset Additional offset to be added while binding, relative to the beginnig of the `allocation`. Normally it should be 0. +@param pNext A chain of structures to be attached to `VkBindBufferMemoryInfoKHR` structure used internally. Normally it should be null. + +This function is similar to vmaBindBufferMemory(), but it provides additional parameters. + +If `pNext` is not null, #VmaAllocator object must have been created with #VMA_ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT flag +or with VmaAllocatorCreateInfo::vulkanApiVersion `== VK_API_VERSION_1_1`. Otherwise the call fails. +*/ +VMA_CALL_PRE VkResult VMA_CALL_POST vmaBindBufferMemory2( + VmaAllocator allocator, + VmaAllocation allocation, + VkDeviceSize allocationLocalOffset, + VkBuffer buffer, + const void* pNext); + +/** \brief Binds image to allocation. + +Binds specified image to region of memory represented by specified allocation. +Gets `VkDeviceMemory` handle and offset from the allocation. +If you want to create an image, allocate memory for it and bind them together separately, +you should use this function for binding instead of standard `vkBindImageMemory()`, +because it ensures proper synchronization so that when a `VkDeviceMemory` object is used by multiple +allocations, calls to `vkBind*Memory()` or `vkMapMemory()` won't happen from multiple threads simultaneously +(which is illegal in Vulkan). + +It is recommended to use function vmaCreateImage() instead of this one. +*/ +VMA_CALL_PRE VkResult VMA_CALL_POST vmaBindImageMemory( + VmaAllocator allocator, + VmaAllocation allocation, + VkImage image); + +/** \brief Binds image to allocation with additional parameters. + +@param allocationLocalOffset Additional offset to be added while binding, relative to the beginnig of the `allocation`. Normally it should be 0. +@param pNext A chain of structures to be attached to `VkBindImageMemoryInfoKHR` structure used internally. Normally it should be null. + +This function is similar to vmaBindImageMemory(), but it provides additional parameters. + +If `pNext` is not null, #VmaAllocator object must have been created with #VMA_ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT flag +or with VmaAllocatorCreateInfo::vulkanApiVersion `== VK_API_VERSION_1_1`. Otherwise the call fails. +*/ +VMA_CALL_PRE VkResult VMA_CALL_POST vmaBindImageMemory2( + VmaAllocator allocator, + VmaAllocation allocation, + VkDeviceSize allocationLocalOffset, + VkImage image, + const void* pNext); + +/** +@param[out] pBuffer Buffer that was created. +@param[out] pAllocation Allocation that was created. +@param[out] pAllocationInfo Optional. Information about allocated memory. It can be later fetched using function vmaGetAllocationInfo(). + +This function automatically: + +-# Creates buffer. +-# Allocates appropriate memory for it. +-# Binds the buffer with the memory. + +If any of these operations fail, buffer and allocation are not created, +returned value is negative error code, *pBuffer and *pAllocation are null. + +If the function succeeded, you must destroy both buffer and allocation when you +no longer need them using either convenience function vmaDestroyBuffer() or +separately, using `vkDestroyBuffer()` and vmaFreeMemory(). + +If VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT flag was used, +VK_KHR_dedicated_allocation extension is used internally to query driver whether +it requires or prefers the new buffer to have dedicated allocation. If yes, +and if dedicated allocation is possible (VmaAllocationCreateInfo::pool is null +and VMA_ALLOCATION_CREATE_NEVER_ALLOCATE_BIT is not used), it creates dedicated +allocation for this buffer, just like when using +VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT. +*/ +VMA_CALL_PRE VkResult VMA_CALL_POST vmaCreateBuffer( + VmaAllocator allocator, + const VkBufferCreateInfo* pBufferCreateInfo, + const VmaAllocationCreateInfo* pAllocationCreateInfo, + VkBuffer* pBuffer, + VmaAllocation* pAllocation, + VmaAllocationInfo* pAllocationInfo); + +/** \brief Destroys Vulkan buffer and frees allocated memory. + +This is just a convenience function equivalent to: + +\code +vkDestroyBuffer(device, buffer, allocationCallbacks); +vmaFreeMemory(allocator, allocation); +\endcode + +It it safe to pass null as buffer and/or allocation. +*/ +VMA_CALL_PRE void VMA_CALL_POST vmaDestroyBuffer( + VmaAllocator allocator, + VkBuffer buffer, + VmaAllocation allocation); + +/// Function similar to vmaCreateBuffer(). +VMA_CALL_PRE VkResult VMA_CALL_POST vmaCreateImage( + VmaAllocator allocator, + const VkImageCreateInfo* pImageCreateInfo, + const VmaAllocationCreateInfo* pAllocationCreateInfo, + VkImage* pImage, + VmaAllocation* pAllocation, + VmaAllocationInfo* pAllocationInfo); + +/** \brief Destroys Vulkan image and frees allocated memory. + +This is just a convenience function equivalent to: + +\code +vkDestroyImage(device, image, allocationCallbacks); +vmaFreeMemory(allocator, allocation); +\endcode + +It it safe to pass null as image and/or allocation. +*/ +VMA_CALL_PRE void VMA_CALL_POST vmaDestroyImage( + VmaAllocator allocator, + VkImage image, + VmaAllocation allocation); + +#ifdef __cplusplus +} +#endif + +#endif // AMD_VULKAN_MEMORY_ALLOCATOR_H + +// For Visual Studio IntelliSense. +#if defined(__cplusplus) && defined(__INTELLISENSE__) +#define VMA_IMPLEMENTATION +#endif + +#ifdef VMA_IMPLEMENTATION +#undef VMA_IMPLEMENTATION + +#include +#include +#include +#include + +/******************************************************************************* +CONFIGURATION SECTION + +Define some of these macros before each #include of this header or change them +here if you need other then default behavior depending on your environment. +*/ + +/* +Define this macro to 1 to make the library fetch pointers to Vulkan functions +internally, like: + + vulkanFunctions.vkAllocateMemory = &vkAllocateMemory; + +Define to 0 if you are going to provide you own pointers to Vulkan functions via +VmaAllocatorCreateInfo::pVulkanFunctions. +*/ +#if !defined(VMA_STATIC_VULKAN_FUNCTIONS) && !defined(VK_NO_PROTOTYPES) +#define VMA_STATIC_VULKAN_FUNCTIONS 1 +#endif + +// Define this macro to 1 to make the library use STL containers instead of its own implementation. +//#define VMA_USE_STL_CONTAINERS 1 + +/* Set this macro to 1 to make the library including and using STL containers: +std::pair, std::vector, std::list, std::unordered_map. + +Set it to 0 or undefined to make the library using its own implementation of +the containers. +*/ +#if VMA_USE_STL_CONTAINERS + #define VMA_USE_STL_VECTOR 1 + #define VMA_USE_STL_UNORDERED_MAP 1 + #define VMA_USE_STL_LIST 1 +#endif + +#ifndef VMA_USE_STL_SHARED_MUTEX + // Compiler conforms to C++17. + #if __cplusplus >= 201703L + #define VMA_USE_STL_SHARED_MUTEX 1 + // Visual studio defines __cplusplus properly only when passed additional parameter: /Zc:__cplusplus + // Otherwise it's always 199711L, despite shared_mutex works since Visual Studio 2015 Update 2. + // See: https://blogs.msdn.microsoft.com/vcblog/2018/04/09/msvc-now-correctly-reports-__cplusplus/ + #elif defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190023918 && __cplusplus == 199711L && _MSVC_LANG >= 201703L + #define VMA_USE_STL_SHARED_MUTEX 1 + #else + #define VMA_USE_STL_SHARED_MUTEX 0 + #endif +#endif + +/* +THESE INCLUDES ARE NOT ENABLED BY DEFAULT. +Library has its own container implementation. +*/ +#if VMA_USE_STL_VECTOR + #include +#endif + +#if VMA_USE_STL_UNORDERED_MAP + #include +#endif + +#if VMA_USE_STL_LIST + #include +#endif + +/* +Following headers are used in this CONFIGURATION section only, so feel free to +remove them if not needed. +*/ +#include // for assert +#include // for min, max +#include + +#ifndef VMA_NULL + // Value used as null pointer. Define it to e.g.: nullptr, NULL, 0, (void*)0. + #define VMA_NULL nullptr +#endif + +#if defined(__ANDROID_API__) && (__ANDROID_API__ < 16) +#include +void *aligned_alloc(size_t alignment, size_t size) +{ + // alignment must be >= sizeof(void*) + if(alignment < sizeof(void*)) + { + alignment = sizeof(void*); + } + + return memalign(alignment, size); +} +#elif defined(__APPLE__) || defined(__ANDROID__) || (defined(__linux__) && defined(__GLIBCXX__) && !defined(_GLIBCXX_HAVE_ALIGNED_ALLOC)) +#include +void *aligned_alloc(size_t alignment, size_t size) +{ + // alignment must be >= sizeof(void*) + if(alignment < sizeof(void*)) + { + alignment = sizeof(void*); + } + + void *pointer; + if(posix_memalign(&pointer, alignment, size) == 0) + return pointer; + return VMA_NULL; +} +#endif + +// If your compiler is not compatible with C++11 and definition of +// aligned_alloc() function is missing, uncommeting following line may help: + +//#include + +// Normal assert to check for programmer's errors, especially in Debug configuration. +#ifndef VMA_ASSERT + #ifdef NDEBUG + #define VMA_ASSERT(expr) + #else + #define VMA_ASSERT(expr) assert(expr) + #endif +#endif + +// Assert that will be called very often, like inside data structures e.g. operator[]. +// Making it non-empty can make program slow. +#ifndef VMA_HEAVY_ASSERT + #ifdef NDEBUG + #define VMA_HEAVY_ASSERT(expr) + #else + #define VMA_HEAVY_ASSERT(expr) //VMA_ASSERT(expr) + #endif +#endif + +#ifndef VMA_ALIGN_OF + #define VMA_ALIGN_OF(type) (__alignof(type)) +#endif + +#ifndef VMA_SYSTEM_ALIGNED_MALLOC + #if defined(_WIN32) + #define VMA_SYSTEM_ALIGNED_MALLOC(size, alignment) (_aligned_malloc((size), (alignment))) + #else + #define VMA_SYSTEM_ALIGNED_MALLOC(size, alignment) (aligned_alloc((alignment), (size) )) + #endif +#endif + +#ifndef VMA_SYSTEM_FREE + #if defined(_WIN32) + #define VMA_SYSTEM_FREE(ptr) _aligned_free(ptr) + #else + #define VMA_SYSTEM_FREE(ptr) free(ptr) + #endif +#endif + +#ifndef VMA_MIN + #define VMA_MIN(v1, v2) (std::min((v1), (v2))) +#endif + +#ifndef VMA_MAX + #define VMA_MAX(v1, v2) (std::max((v1), (v2))) +#endif + +#ifndef VMA_SWAP + #define VMA_SWAP(v1, v2) std::swap((v1), (v2)) +#endif + +#ifndef VMA_SORT + #define VMA_SORT(beg, end, cmp) std::sort(beg, end, cmp) +#endif + +#ifndef VMA_DEBUG_LOG + #define VMA_DEBUG_LOG(format, ...) + /* + #define VMA_DEBUG_LOG(format, ...) do { \ + printf(format, __VA_ARGS__); \ + printf("\n"); \ + } while(false) + */ +#endif + +// Define this macro to 1 to enable functions: vmaBuildStatsString, vmaFreeStatsString. +#if VMA_STATS_STRING_ENABLED + static inline void VmaUint32ToStr(char* outStr, size_t strLen, uint32_t num) + { + snprintf(outStr, strLen, "%u", static_cast(num)); + } + static inline void VmaUint64ToStr(char* outStr, size_t strLen, uint64_t num) + { + snprintf(outStr, strLen, "%llu", static_cast(num)); + } + static inline void VmaPtrToStr(char* outStr, size_t strLen, const void* ptr) + { + snprintf(outStr, strLen, "%p", ptr); + } +#endif + +#ifndef VMA_MUTEX + class VmaMutex + { + public: + void Lock() { m_Mutex.lock(); } + void Unlock() { m_Mutex.unlock(); } + bool TryLock() { return m_Mutex.try_lock(); } + private: + std::mutex m_Mutex; + }; + #define VMA_MUTEX VmaMutex +#endif + +// Read-write mutex, where "read" is shared access, "write" is exclusive access. +#ifndef VMA_RW_MUTEX + #if VMA_USE_STL_SHARED_MUTEX + // Use std::shared_mutex from C++17. + #include + class VmaRWMutex + { + public: + void LockRead() { m_Mutex.lock_shared(); } + void UnlockRead() { m_Mutex.unlock_shared(); } + bool TryLockRead() { return m_Mutex.try_lock_shared(); } + void LockWrite() { m_Mutex.lock(); } + void UnlockWrite() { m_Mutex.unlock(); } + bool TryLockWrite() { return m_Mutex.try_lock(); } + private: + std::shared_mutex m_Mutex; + }; + #define VMA_RW_MUTEX VmaRWMutex + #elif defined(_WIN32) && defined(WINVER) && WINVER >= 0x0600 + // Use SRWLOCK from WinAPI. + // Minimum supported client = Windows Vista, server = Windows Server 2008. + class VmaRWMutex + { + public: + VmaRWMutex() { InitializeSRWLock(&m_Lock); } + void LockRead() { AcquireSRWLockShared(&m_Lock); } + void UnlockRead() { ReleaseSRWLockShared(&m_Lock); } + bool TryLockRead() { return TryAcquireSRWLockShared(&m_Lock) != FALSE; } + void LockWrite() { AcquireSRWLockExclusive(&m_Lock); } + void UnlockWrite() { ReleaseSRWLockExclusive(&m_Lock); } + bool TryLockWrite() { return TryAcquireSRWLockExclusive(&m_Lock) != FALSE; } + private: + SRWLOCK m_Lock; + }; + #define VMA_RW_MUTEX VmaRWMutex + #else + // Less efficient fallback: Use normal mutex. + class VmaRWMutex + { + public: + void LockRead() { m_Mutex.Lock(); } + void UnlockRead() { m_Mutex.Unlock(); } + bool TryLockRead() { return m_Mutex.TryLock(); } + void LockWrite() { m_Mutex.Lock(); } + void UnlockWrite() { m_Mutex.Unlock(); } + bool TryLockWrite() { return m_Mutex.TryLock(); } + private: + VMA_MUTEX m_Mutex; + }; + #define VMA_RW_MUTEX VmaRWMutex + #endif // #if VMA_USE_STL_SHARED_MUTEX +#endif // #ifndef VMA_RW_MUTEX + +/* +If providing your own implementation, you need to implement a subset of std::atomic. +*/ +#ifndef VMA_ATOMIC_UINT32 + #include + #define VMA_ATOMIC_UINT32 std::atomic +#endif + +#ifndef VMA_ATOMIC_UINT64 + #include + #define VMA_ATOMIC_UINT64 std::atomic +#endif + +#ifndef VMA_DEBUG_ALWAYS_DEDICATED_MEMORY + /** + Every allocation will have its own memory block. + Define to 1 for debugging purposes only. + */ + #define VMA_DEBUG_ALWAYS_DEDICATED_MEMORY (0) +#endif + +#ifndef VMA_DEBUG_ALIGNMENT + /** + Minimum alignment of all allocations, in bytes. + Set to more than 1 for debugging purposes only. Must be power of two. + */ + #define VMA_DEBUG_ALIGNMENT (1) +#endif + +#ifndef VMA_DEBUG_MARGIN + /** + Minimum margin before and after every allocation, in bytes. + Set nonzero for debugging purposes only. + */ + #define VMA_DEBUG_MARGIN (0) +#endif + +#ifndef VMA_DEBUG_INITIALIZE_ALLOCATIONS + /** + Define this macro to 1 to automatically fill new allocations and destroyed + allocations with some bit pattern. + */ + #define VMA_DEBUG_INITIALIZE_ALLOCATIONS (0) +#endif + +#ifndef VMA_DEBUG_DETECT_CORRUPTION + /** + Define this macro to 1 together with non-zero value of VMA_DEBUG_MARGIN to + enable writing magic value to the margin before and after every allocation and + validating it, so that memory corruptions (out-of-bounds writes) are detected. + */ + #define VMA_DEBUG_DETECT_CORRUPTION (0) +#endif + +#ifndef VMA_DEBUG_GLOBAL_MUTEX + /** + Set this to 1 for debugging purposes only, to enable single mutex protecting all + entry calls to the library. Can be useful for debugging multithreading issues. + */ + #define VMA_DEBUG_GLOBAL_MUTEX (0) +#endif + +#ifndef VMA_DEBUG_MIN_BUFFER_IMAGE_GRANULARITY + /** + Minimum value for VkPhysicalDeviceLimits::bufferImageGranularity. + Set to more than 1 for debugging purposes only. Must be power of two. + */ + #define VMA_DEBUG_MIN_BUFFER_IMAGE_GRANULARITY (1) +#endif + +#ifndef VMA_SMALL_HEAP_MAX_SIZE + /// Maximum size of a memory heap in Vulkan to consider it "small". + #define VMA_SMALL_HEAP_MAX_SIZE (1024ull * 1024 * 1024) +#endif + +#ifndef VMA_DEFAULT_LARGE_HEAP_BLOCK_SIZE + /// Default size of a block allocated as single VkDeviceMemory from a "large" heap. + #define VMA_DEFAULT_LARGE_HEAP_BLOCK_SIZE (256ull * 1024 * 1024) +#endif + +#ifndef VMA_CLASS_NO_COPY + #define VMA_CLASS_NO_COPY(className) \ + private: \ + className(const className&) = delete; \ + className& operator=(const className&) = delete; +#endif + +static const uint32_t VMA_FRAME_INDEX_LOST = UINT32_MAX; + +// Decimal 2139416166, float NaN, little-endian binary 66 E6 84 7F. +static const uint32_t VMA_CORRUPTION_DETECTION_MAGIC_VALUE = 0x7F84E666; + +static const uint8_t VMA_ALLOCATION_FILL_PATTERN_CREATED = 0xDC; +static const uint8_t VMA_ALLOCATION_FILL_PATTERN_DESTROYED = 0xEF; + +/******************************************************************************* +END OF CONFIGURATION +*/ + +// # Copy of some Vulkan definitions so we don't need to check their existence just to handle few constants. + +static const uint32_t VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD_COPY = 0x00000040; +static const uint32_t VK_MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD_COPY = 0x00000080; + + +static const uint32_t VMA_ALLOCATION_INTERNAL_STRATEGY_MIN_OFFSET = 0x10000000u; + +static VkAllocationCallbacks VmaEmptyAllocationCallbacks = { + VMA_NULL, VMA_NULL, VMA_NULL, VMA_NULL, VMA_NULL, VMA_NULL }; + +// Returns number of bits set to 1 in (v). +static inline uint32_t VmaCountBitsSet(uint32_t v) +{ + uint32_t c = v - ((v >> 1) & 0x55555555); + c = ((c >> 2) & 0x33333333) + (c & 0x33333333); + c = ((c >> 4) + c) & 0x0F0F0F0F; + c = ((c >> 8) + c) & 0x00FF00FF; + c = ((c >> 16) + c) & 0x0000FFFF; + return c; +} + +// Aligns given value up to nearest multiply of align value. For example: VmaAlignUp(11, 8) = 16. +// Use types like uint32_t, uint64_t as T. +template +static inline T VmaAlignUp(T val, T align) +{ + return (val + align - 1) / align * align; +} +// Aligns given value down to nearest multiply of align value. For example: VmaAlignUp(11, 8) = 8. +// Use types like uint32_t, uint64_t as T. +template +static inline T VmaAlignDown(T val, T align) +{ + return val / align * align; +} + +// Division with mathematical rounding to nearest number. +template +static inline T VmaRoundDiv(T x, T y) +{ + return (x + (y / (T)2)) / y; +} + +/* +Returns true if given number is a power of two. +T must be unsigned integer number or signed integer but always nonnegative. +For 0 returns true. +*/ +template +inline bool VmaIsPow2(T x) +{ + return (x & (x-1)) == 0; +} + +// Returns smallest power of 2 greater or equal to v. +static inline uint32_t VmaNextPow2(uint32_t v) +{ + v--; + v |= v >> 1; + v |= v >> 2; + v |= v >> 4; + v |= v >> 8; + v |= v >> 16; + v++; + return v; +} +static inline uint64_t VmaNextPow2(uint64_t v) +{ + v--; + v |= v >> 1; + v |= v >> 2; + v |= v >> 4; + v |= v >> 8; + v |= v >> 16; + v |= v >> 32; + v++; + return v; +} + +// Returns largest power of 2 less or equal to v. +static inline uint32_t VmaPrevPow2(uint32_t v) +{ + v |= v >> 1; + v |= v >> 2; + v |= v >> 4; + v |= v >> 8; + v |= v >> 16; + v = v ^ (v >> 1); + return v; +} +static inline uint64_t VmaPrevPow2(uint64_t v) +{ + v |= v >> 1; + v |= v >> 2; + v |= v >> 4; + v |= v >> 8; + v |= v >> 16; + v |= v >> 32; + v = v ^ (v >> 1); + return v; +} + +static inline bool VmaStrIsEmpty(const char* pStr) +{ + return pStr == VMA_NULL || *pStr == '\0'; +} + +#if VMA_STATS_STRING_ENABLED + +static const char* VmaAlgorithmToStr(uint32_t algorithm) +{ + switch(algorithm) + { + case VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT: + return "Linear"; + case VMA_POOL_CREATE_BUDDY_ALGORITHM_BIT: + return "Buddy"; + case 0: + return "Default"; + default: + VMA_ASSERT(0); + return ""; + } +} + +#endif // #if VMA_STATS_STRING_ENABLED + +#ifndef VMA_SORT + +template +Iterator VmaQuickSortPartition(Iterator beg, Iterator end, Compare cmp) +{ + Iterator centerValue = end; --centerValue; + Iterator insertIndex = beg; + for(Iterator memTypeIndex = beg; memTypeIndex < centerValue; ++memTypeIndex) + { + if(cmp(*memTypeIndex, *centerValue)) + { + if(insertIndex != memTypeIndex) + { + VMA_SWAP(*memTypeIndex, *insertIndex); + } + ++insertIndex; + } + } + if(insertIndex != centerValue) + { + VMA_SWAP(*insertIndex, *centerValue); + } + return insertIndex; +} + +template +void VmaQuickSort(Iterator beg, Iterator end, Compare cmp) +{ + if(beg < end) + { + Iterator it = VmaQuickSortPartition(beg, end, cmp); + VmaQuickSort(beg, it, cmp); + VmaQuickSort(it + 1, end, cmp); + } +} + +#define VMA_SORT(beg, end, cmp) VmaQuickSort(beg, end, cmp) + +#endif // #ifndef VMA_SORT + +/* +Returns true if two memory blocks occupy overlapping pages. +ResourceA must be in less memory offset than ResourceB. + +Algorithm is based on "Vulkan 1.0.39 - A Specification (with all registered Vulkan extensions)" +chapter 11.6 "Resource Memory Association", paragraph "Buffer-Image Granularity". +*/ +static inline bool VmaBlocksOnSamePage( + VkDeviceSize resourceAOffset, + VkDeviceSize resourceASize, + VkDeviceSize resourceBOffset, + VkDeviceSize pageSize) +{ + VMA_ASSERT(resourceAOffset + resourceASize <= resourceBOffset && resourceASize > 0 && pageSize > 0); + VkDeviceSize resourceAEnd = resourceAOffset + resourceASize - 1; + VkDeviceSize resourceAEndPage = resourceAEnd & ~(pageSize - 1); + VkDeviceSize resourceBStart = resourceBOffset; + VkDeviceSize resourceBStartPage = resourceBStart & ~(pageSize - 1); + return resourceAEndPage == resourceBStartPage; +} + +enum VmaSuballocationType +{ + VMA_SUBALLOCATION_TYPE_FREE = 0, + VMA_SUBALLOCATION_TYPE_UNKNOWN = 1, + VMA_SUBALLOCATION_TYPE_BUFFER = 2, + VMA_SUBALLOCATION_TYPE_IMAGE_UNKNOWN = 3, + VMA_SUBALLOCATION_TYPE_IMAGE_LINEAR = 4, + VMA_SUBALLOCATION_TYPE_IMAGE_OPTIMAL = 5, + VMA_SUBALLOCATION_TYPE_MAX_ENUM = 0x7FFFFFFF +}; + +/* +Returns true if given suballocation types could conflict and must respect +VkPhysicalDeviceLimits::bufferImageGranularity. They conflict if one is buffer +or linear image and another one is optimal image. If type is unknown, behave +conservatively. +*/ +static inline bool VmaIsBufferImageGranularityConflict( + VmaSuballocationType suballocType1, + VmaSuballocationType suballocType2) +{ + if(suballocType1 > suballocType2) + { + VMA_SWAP(suballocType1, suballocType2); + } + + switch(suballocType1) + { + case VMA_SUBALLOCATION_TYPE_FREE: + return false; + case VMA_SUBALLOCATION_TYPE_UNKNOWN: + return true; + case VMA_SUBALLOCATION_TYPE_BUFFER: + return + suballocType2 == VMA_SUBALLOCATION_TYPE_IMAGE_UNKNOWN || + suballocType2 == VMA_SUBALLOCATION_TYPE_IMAGE_OPTIMAL; + case VMA_SUBALLOCATION_TYPE_IMAGE_UNKNOWN: + return + suballocType2 == VMA_SUBALLOCATION_TYPE_IMAGE_UNKNOWN || + suballocType2 == VMA_SUBALLOCATION_TYPE_IMAGE_LINEAR || + suballocType2 == VMA_SUBALLOCATION_TYPE_IMAGE_OPTIMAL; + case VMA_SUBALLOCATION_TYPE_IMAGE_LINEAR: + return + suballocType2 == VMA_SUBALLOCATION_TYPE_IMAGE_OPTIMAL; + case VMA_SUBALLOCATION_TYPE_IMAGE_OPTIMAL: + return false; + default: + VMA_ASSERT(0); + return true; + } +} + +static void VmaWriteMagicValue(void* pData, VkDeviceSize offset) +{ +#if VMA_DEBUG_MARGIN > 0 && VMA_DEBUG_DETECT_CORRUPTION + uint32_t* pDst = (uint32_t*)((char*)pData + offset); + const size_t numberCount = VMA_DEBUG_MARGIN / sizeof(uint32_t); + for(size_t i = 0; i < numberCount; ++i, ++pDst) + { + *pDst = VMA_CORRUPTION_DETECTION_MAGIC_VALUE; + } +#else + // no-op +#endif +} + +static bool VmaValidateMagicValue(const void* pData, VkDeviceSize offset) +{ +#if VMA_DEBUG_MARGIN > 0 && VMA_DEBUG_DETECT_CORRUPTION + const uint32_t* pSrc = (const uint32_t*)((const char*)pData + offset); + const size_t numberCount = VMA_DEBUG_MARGIN / sizeof(uint32_t); + for(size_t i = 0; i < numberCount; ++i, ++pSrc) + { + if(*pSrc != VMA_CORRUPTION_DETECTION_MAGIC_VALUE) + { + return false; + } + } +#endif + return true; +} + +/* +Fills structure with parameters of an example buffer to be used for transfers +during GPU memory defragmentation. +*/ +static void VmaFillGpuDefragmentationBufferCreateInfo(VkBufferCreateInfo& outBufCreateInfo) +{ + memset(&outBufCreateInfo, 0, sizeof(outBufCreateInfo)); + outBufCreateInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; + outBufCreateInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT; + outBufCreateInfo.size = (VkDeviceSize)VMA_DEFAULT_LARGE_HEAP_BLOCK_SIZE; // Example size. +} + +// Helper RAII class to lock a mutex in constructor and unlock it in destructor (at the end of scope). +struct VmaMutexLock +{ + VMA_CLASS_NO_COPY(VmaMutexLock) +public: + VmaMutexLock(VMA_MUTEX& mutex, bool useMutex = true) : + m_pMutex(useMutex ? &mutex : VMA_NULL) + { if(m_pMutex) { m_pMutex->Lock(); } } + ~VmaMutexLock() + { if(m_pMutex) { m_pMutex->Unlock(); } } +private: + VMA_MUTEX* m_pMutex; +}; + +// Helper RAII class to lock a RW mutex in constructor and unlock it in destructor (at the end of scope), for reading. +struct VmaMutexLockRead +{ + VMA_CLASS_NO_COPY(VmaMutexLockRead) +public: + VmaMutexLockRead(VMA_RW_MUTEX& mutex, bool useMutex) : + m_pMutex(useMutex ? &mutex : VMA_NULL) + { if(m_pMutex) { m_pMutex->LockRead(); } } + ~VmaMutexLockRead() { if(m_pMutex) { m_pMutex->UnlockRead(); } } +private: + VMA_RW_MUTEX* m_pMutex; +}; + +// Helper RAII class to lock a RW mutex in constructor and unlock it in destructor (at the end of scope), for writing. +struct VmaMutexLockWrite +{ + VMA_CLASS_NO_COPY(VmaMutexLockWrite) +public: + VmaMutexLockWrite(VMA_RW_MUTEX& mutex, bool useMutex) : + m_pMutex(useMutex ? &mutex : VMA_NULL) + { if(m_pMutex) { m_pMutex->LockWrite(); } } + ~VmaMutexLockWrite() { if(m_pMutex) { m_pMutex->UnlockWrite(); } } +private: + VMA_RW_MUTEX* m_pMutex; +}; + +#if VMA_DEBUG_GLOBAL_MUTEX + static VMA_MUTEX gDebugGlobalMutex; + #define VMA_DEBUG_GLOBAL_MUTEX_LOCK VmaMutexLock debugGlobalMutexLock(gDebugGlobalMutex, true); +#else + #define VMA_DEBUG_GLOBAL_MUTEX_LOCK +#endif + +// Minimum size of a free suballocation to register it in the free suballocation collection. +static const VkDeviceSize VMA_MIN_FREE_SUBALLOCATION_SIZE_TO_REGISTER = 16; + +/* +Performs binary search and returns iterator to first element that is greater or +equal to (key), according to comparison (cmp). + +Cmp should return true if first argument is less than second argument. + +Returned value is the found element, if present in the collection or place where +new element with value (key) should be inserted. +*/ +template +static IterT VmaBinaryFindFirstNotLess(IterT beg, IterT end, const KeyT &key, const CmpLess& cmp) +{ + size_t down = 0, up = (end - beg); + while(down < up) + { + const size_t mid = (down + up) / 2; + if(cmp(*(beg+mid), key)) + { + down = mid + 1; + } + else + { + up = mid; + } + } + return beg + down; +} + +template +IterT VmaBinaryFindSorted(const IterT& beg, const IterT& end, const KeyT& value, const CmpLess& cmp) +{ + IterT it = VmaBinaryFindFirstNotLess( + beg, end, value, cmp); + if(it == end || + (!cmp(*it, value) && !cmp(value, *it))) + { + return it; + } + return end; +} + +/* +Returns true if all pointers in the array are not-null and unique. +Warning! O(n^2) complexity. Use only inside VMA_HEAVY_ASSERT. +T must be pointer type, e.g. VmaAllocation, VmaPool. +*/ +template +static bool VmaValidatePointerArray(uint32_t count, const T* arr) +{ + for(uint32_t i = 0; i < count; ++i) + { + const T iPtr = arr[i]; + if(iPtr == VMA_NULL) + { + return false; + } + for(uint32_t j = i + 1; j < count; ++j) + { + if(iPtr == arr[j]) + { + return false; + } + } + } + return true; +} + +//////////////////////////////////////////////////////////////////////////////// +// Memory allocation + +static void* VmaMalloc(const VkAllocationCallbacks* pAllocationCallbacks, size_t size, size_t alignment) +{ + if((pAllocationCallbacks != VMA_NULL) && + (pAllocationCallbacks->pfnAllocation != VMA_NULL)) + { + return (*pAllocationCallbacks->pfnAllocation)( + pAllocationCallbacks->pUserData, + size, + alignment, + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); + } + else + { + return VMA_SYSTEM_ALIGNED_MALLOC(size, alignment); + } +} + +static void VmaFree(const VkAllocationCallbacks* pAllocationCallbacks, void* ptr) +{ + if((pAllocationCallbacks != VMA_NULL) && + (pAllocationCallbacks->pfnFree != VMA_NULL)) + { + (*pAllocationCallbacks->pfnFree)(pAllocationCallbacks->pUserData, ptr); + } + else + { + VMA_SYSTEM_FREE(ptr); + } +} + +template +static T* VmaAllocate(const VkAllocationCallbacks* pAllocationCallbacks) +{ + return (T*)VmaMalloc(pAllocationCallbacks, sizeof(T), VMA_ALIGN_OF(T)); +} + +template +static T* VmaAllocateArray(const VkAllocationCallbacks* pAllocationCallbacks, size_t count) +{ + return (T*)VmaMalloc(pAllocationCallbacks, sizeof(T) * count, VMA_ALIGN_OF(T)); +} + +#define vma_new(allocator, type) new(VmaAllocate(allocator))(type) + +#define vma_new_array(allocator, type, count) new(VmaAllocateArray((allocator), (count)))(type) + +template +static void vma_delete(const VkAllocationCallbacks* pAllocationCallbacks, T* ptr) +{ + ptr->~T(); + VmaFree(pAllocationCallbacks, ptr); +} + +template +static void vma_delete_array(const VkAllocationCallbacks* pAllocationCallbacks, T* ptr, size_t count) +{ + if(ptr != VMA_NULL) + { + for(size_t i = count; i--; ) + { + ptr[i].~T(); + } + VmaFree(pAllocationCallbacks, ptr); + } +} + +static char* VmaCreateStringCopy(const VkAllocationCallbacks* allocs, const char* srcStr) +{ + if(srcStr != VMA_NULL) + { + const size_t len = strlen(srcStr); + char* const result = vma_new_array(allocs, char, len + 1); + memcpy(result, srcStr, len + 1); + return result; + } + else + { + return VMA_NULL; + } +} + +static void VmaFreeString(const VkAllocationCallbacks* allocs, char* str) +{ + if(str != VMA_NULL) + { + const size_t len = strlen(str); + vma_delete_array(allocs, str, len + 1); + } +} + +// STL-compatible allocator. +template +class VmaStlAllocator +{ +public: + const VkAllocationCallbacks* const m_pCallbacks; + typedef T value_type; + + VmaStlAllocator(const VkAllocationCallbacks* pCallbacks) : m_pCallbacks(pCallbacks) { } + template VmaStlAllocator(const VmaStlAllocator& src) : m_pCallbacks(src.m_pCallbacks) { } + + T* allocate(size_t n) { return VmaAllocateArray(m_pCallbacks, n); } + void deallocate(T* p, size_t n) { VmaFree(m_pCallbacks, p); } + + template + bool operator==(const VmaStlAllocator& rhs) const + { + return m_pCallbacks == rhs.m_pCallbacks; + } + template + bool operator!=(const VmaStlAllocator& rhs) const + { + return m_pCallbacks != rhs.m_pCallbacks; + } + + VmaStlAllocator& operator=(const VmaStlAllocator& x) = delete; +}; + +#if VMA_USE_STL_VECTOR + +#define VmaVector std::vector + +template +static void VmaVectorInsert(std::vector& vec, size_t index, const T& item) +{ + vec.insert(vec.begin() + index, item); +} + +template +static void VmaVectorRemove(std::vector& vec, size_t index) +{ + vec.erase(vec.begin() + index); +} + +#else // #if VMA_USE_STL_VECTOR + +/* Class with interface compatible with subset of std::vector. +T must be POD because constructors and destructors are not called and memcpy is +used for these objects. */ +template +class VmaVector +{ +public: + typedef T value_type; + + VmaVector(const AllocatorT& allocator) : + m_Allocator(allocator), + m_pArray(VMA_NULL), + m_Count(0), + m_Capacity(0) + { + } + + VmaVector(size_t count, const AllocatorT& allocator) : + m_Allocator(allocator), + m_pArray(count ? (T*)VmaAllocateArray(allocator.m_pCallbacks, count) : VMA_NULL), + m_Count(count), + m_Capacity(count) + { + } + + // This version of the constructor is here for compatibility with pre-C++14 std::vector. + // value is unused. + VmaVector(size_t count, const T& value, const AllocatorT& allocator) + : VmaVector(count, allocator) {} + + VmaVector(const VmaVector& src) : + m_Allocator(src.m_Allocator), + m_pArray(src.m_Count ? (T*)VmaAllocateArray(src.m_Allocator.m_pCallbacks, src.m_Count) : VMA_NULL), + m_Count(src.m_Count), + m_Capacity(src.m_Count) + { + if(m_Count != 0) + { + memcpy(m_pArray, src.m_pArray, m_Count * sizeof(T)); + } + } + + ~VmaVector() + { + VmaFree(m_Allocator.m_pCallbacks, m_pArray); + } + + VmaVector& operator=(const VmaVector& rhs) + { + if(&rhs != this) + { + resize(rhs.m_Count); + if(m_Count != 0) + { + memcpy(m_pArray, rhs.m_pArray, m_Count * sizeof(T)); + } + } + return *this; + } + + bool empty() const { return m_Count == 0; } + size_t size() const { return m_Count; } + T* data() { return m_pArray; } + const T* data() const { return m_pArray; } + + T& operator[](size_t index) + { + VMA_HEAVY_ASSERT(index < m_Count); + return m_pArray[index]; + } + const T& operator[](size_t index) const + { + VMA_HEAVY_ASSERT(index < m_Count); + return m_pArray[index]; + } + + T& front() + { + VMA_HEAVY_ASSERT(m_Count > 0); + return m_pArray[0]; + } + const T& front() const + { + VMA_HEAVY_ASSERT(m_Count > 0); + return m_pArray[0]; + } + T& back() + { + VMA_HEAVY_ASSERT(m_Count > 0); + return m_pArray[m_Count - 1]; + } + const T& back() const + { + VMA_HEAVY_ASSERT(m_Count > 0); + return m_pArray[m_Count - 1]; + } + + void reserve(size_t newCapacity, bool freeMemory = false) + { + newCapacity = VMA_MAX(newCapacity, m_Count); + + if((newCapacity < m_Capacity) && !freeMemory) + { + newCapacity = m_Capacity; + } + + if(newCapacity != m_Capacity) + { + T* const newArray = newCapacity ? VmaAllocateArray(m_Allocator, newCapacity) : VMA_NULL; + if(m_Count != 0) + { + memcpy(newArray, m_pArray, m_Count * sizeof(T)); + } + VmaFree(m_Allocator.m_pCallbacks, m_pArray); + m_Capacity = newCapacity; + m_pArray = newArray; + } + } + + void resize(size_t newCount, bool freeMemory = false) + { + size_t newCapacity = m_Capacity; + if(newCount > m_Capacity) + { + newCapacity = VMA_MAX(newCount, VMA_MAX(m_Capacity * 3 / 2, (size_t)8)); + } + else if(freeMemory) + { + newCapacity = newCount; + } + + if(newCapacity != m_Capacity) + { + T* const newArray = newCapacity ? VmaAllocateArray(m_Allocator.m_pCallbacks, newCapacity) : VMA_NULL; + const size_t elementsToCopy = VMA_MIN(m_Count, newCount); + if(elementsToCopy != 0) + { + memcpy(newArray, m_pArray, elementsToCopy * sizeof(T)); + } + VmaFree(m_Allocator.m_pCallbacks, m_pArray); + m_Capacity = newCapacity; + m_pArray = newArray; + } + + m_Count = newCount; + } + + void clear(bool freeMemory = false) + { + resize(0, freeMemory); + } + + void insert(size_t index, const T& src) + { + VMA_HEAVY_ASSERT(index <= m_Count); + const size_t oldCount = size(); + resize(oldCount + 1); + if(index < oldCount) + { + memmove(m_pArray + (index + 1), m_pArray + index, (oldCount - index) * sizeof(T)); + } + m_pArray[index] = src; + } + + void remove(size_t index) + { + VMA_HEAVY_ASSERT(index < m_Count); + const size_t oldCount = size(); + if(index < oldCount - 1) + { + memmove(m_pArray + index, m_pArray + (index + 1), (oldCount - index - 1) * sizeof(T)); + } + resize(oldCount - 1); + } + + void push_back(const T& src) + { + const size_t newIndex = size(); + resize(newIndex + 1); + m_pArray[newIndex] = src; + } + + void pop_back() + { + VMA_HEAVY_ASSERT(m_Count > 0); + resize(size() - 1); + } + + void push_front(const T& src) + { + insert(0, src); + } + + void pop_front() + { + VMA_HEAVY_ASSERT(m_Count > 0); + remove(0); + } + + typedef T* iterator; + + iterator begin() { return m_pArray; } + iterator end() { return m_pArray + m_Count; } + +private: + AllocatorT m_Allocator; + T* m_pArray; + size_t m_Count; + size_t m_Capacity; +}; + +template +static void VmaVectorInsert(VmaVector& vec, size_t index, const T& item) +{ + vec.insert(index, item); +} + +template +static void VmaVectorRemove(VmaVector& vec, size_t index) +{ + vec.remove(index); +} + +#endif // #if VMA_USE_STL_VECTOR + +template +size_t VmaVectorInsertSorted(VectorT& vector, const typename VectorT::value_type& value) +{ + const size_t indexToInsert = VmaBinaryFindFirstNotLess( + vector.data(), + vector.data() + vector.size(), + value, + CmpLess()) - vector.data(); + VmaVectorInsert(vector, indexToInsert, value); + return indexToInsert; +} + +template +bool VmaVectorRemoveSorted(VectorT& vector, const typename VectorT::value_type& value) +{ + CmpLess comparator; + typename VectorT::iterator it = VmaBinaryFindFirstNotLess( + vector.begin(), + vector.end(), + value, + comparator); + if((it != vector.end()) && !comparator(*it, value) && !comparator(value, *it)) + { + size_t indexToRemove = it - vector.begin(); + VmaVectorRemove(vector, indexToRemove); + return true; + } + return false; +} + +//////////////////////////////////////////////////////////////////////////////// +// class VmaPoolAllocator + +/* +Allocator for objects of type T using a list of arrays (pools) to speed up +allocation. Number of elements that can be allocated is not bounded because +allocator can create multiple blocks. +*/ +template +class VmaPoolAllocator +{ + VMA_CLASS_NO_COPY(VmaPoolAllocator) +public: + VmaPoolAllocator(const VkAllocationCallbacks* pAllocationCallbacks, uint32_t firstBlockCapacity); + ~VmaPoolAllocator(); + template T* Alloc(Types... args); + void Free(T* ptr); + +private: + union Item + { + uint32_t NextFreeIndex; + alignas(T) char Value[sizeof(T)]; + }; + + struct ItemBlock + { + Item* pItems; + uint32_t Capacity; + uint32_t FirstFreeIndex; + }; + + const VkAllocationCallbacks* m_pAllocationCallbacks; + const uint32_t m_FirstBlockCapacity; + VmaVector< ItemBlock, VmaStlAllocator > m_ItemBlocks; + + ItemBlock& CreateNewBlock(); +}; + +template +VmaPoolAllocator::VmaPoolAllocator(const VkAllocationCallbacks* pAllocationCallbacks, uint32_t firstBlockCapacity) : + m_pAllocationCallbacks(pAllocationCallbacks), + m_FirstBlockCapacity(firstBlockCapacity), + m_ItemBlocks(VmaStlAllocator(pAllocationCallbacks)) +{ + VMA_ASSERT(m_FirstBlockCapacity > 1); +} + +template +VmaPoolAllocator::~VmaPoolAllocator() +{ + for(size_t i = m_ItemBlocks.size(); i--; ) + vma_delete_array(m_pAllocationCallbacks, m_ItemBlocks[i].pItems, m_ItemBlocks[i].Capacity); + m_ItemBlocks.clear(); +} + +template +template T* VmaPoolAllocator::Alloc(Types... args) +{ + for(size_t i = m_ItemBlocks.size(); i--; ) + { + ItemBlock& block = m_ItemBlocks[i]; + // This block has some free items: Use first one. + if(block.FirstFreeIndex != UINT32_MAX) + { + Item* const pItem = &block.pItems[block.FirstFreeIndex]; + block.FirstFreeIndex = pItem->NextFreeIndex; + T* result = (T*)&pItem->Value; + new(result)T(std::forward(args)...); // Explicit constructor call. + return result; + } + } + + // No block has free item: Create new one and use it. + ItemBlock& newBlock = CreateNewBlock(); + Item* const pItem = &newBlock.pItems[0]; + newBlock.FirstFreeIndex = pItem->NextFreeIndex; + T* result = (T*)&pItem->Value; + new(result)T(std::forward(args)...); // Explicit constructor call. + return result; +} + +template +void VmaPoolAllocator::Free(T* ptr) +{ + // Search all memory blocks to find ptr. + for(size_t i = m_ItemBlocks.size(); i--; ) + { + ItemBlock& block = m_ItemBlocks[i]; + + // Casting to union. + Item* pItemPtr; + memcpy(&pItemPtr, &ptr, sizeof(pItemPtr)); + + // Check if pItemPtr is in address range of this block. + if((pItemPtr >= block.pItems) && (pItemPtr < block.pItems + block.Capacity)) + { + ptr->~T(); // Explicit destructor call. + const uint32_t index = static_cast(pItemPtr - block.pItems); + pItemPtr->NextFreeIndex = block.FirstFreeIndex; + block.FirstFreeIndex = index; + return; + } + } + VMA_ASSERT(0 && "Pointer doesn't belong to this memory pool."); +} + +template +typename VmaPoolAllocator::ItemBlock& VmaPoolAllocator::CreateNewBlock() +{ + const uint32_t newBlockCapacity = m_ItemBlocks.empty() ? + m_FirstBlockCapacity : m_ItemBlocks.back().Capacity * 3 / 2; + + const ItemBlock newBlock = { + vma_new_array(m_pAllocationCallbacks, Item, newBlockCapacity), + newBlockCapacity, + 0 }; + + m_ItemBlocks.push_back(newBlock); + + // Setup singly-linked list of all free items in this block. + for(uint32_t i = 0; i < newBlockCapacity - 1; ++i) + newBlock.pItems[i].NextFreeIndex = i + 1; + newBlock.pItems[newBlockCapacity - 1].NextFreeIndex = UINT32_MAX; + return m_ItemBlocks.back(); +} + +//////////////////////////////////////////////////////////////////////////////// +// class VmaRawList, VmaList + +#if VMA_USE_STL_LIST + +#define VmaList std::list + +#else // #if VMA_USE_STL_LIST + +template +struct VmaListItem +{ + VmaListItem* pPrev; + VmaListItem* pNext; + T Value; +}; + +// Doubly linked list. +template +class VmaRawList +{ + VMA_CLASS_NO_COPY(VmaRawList) +public: + typedef VmaListItem ItemType; + + VmaRawList(const VkAllocationCallbacks* pAllocationCallbacks); + ~VmaRawList(); + void Clear(); + + size_t GetCount() const { return m_Count; } + bool IsEmpty() const { return m_Count == 0; } + + ItemType* Front() { return m_pFront; } + const ItemType* Front() const { return m_pFront; } + ItemType* Back() { return m_pBack; } + const ItemType* Back() const { return m_pBack; } + + ItemType* PushBack(); + ItemType* PushFront(); + ItemType* PushBack(const T& value); + ItemType* PushFront(const T& value); + void PopBack(); + void PopFront(); + + // Item can be null - it means PushBack. + ItemType* InsertBefore(ItemType* pItem); + // Item can be null - it means PushFront. + ItemType* InsertAfter(ItemType* pItem); + + ItemType* InsertBefore(ItemType* pItem, const T& value); + ItemType* InsertAfter(ItemType* pItem, const T& value); + + void Remove(ItemType* pItem); + +private: + const VkAllocationCallbacks* const m_pAllocationCallbacks; + VmaPoolAllocator m_ItemAllocator; + ItemType* m_pFront; + ItemType* m_pBack; + size_t m_Count; +}; + +template +VmaRawList::VmaRawList(const VkAllocationCallbacks* pAllocationCallbacks) : + m_pAllocationCallbacks(pAllocationCallbacks), + m_ItemAllocator(pAllocationCallbacks, 128), + m_pFront(VMA_NULL), + m_pBack(VMA_NULL), + m_Count(0) +{ +} + +template +VmaRawList::~VmaRawList() +{ + // Intentionally not calling Clear, because that would be unnecessary + // computations to return all items to m_ItemAllocator as free. +} + +template +void VmaRawList::Clear() +{ + if(IsEmpty() == false) + { + ItemType* pItem = m_pBack; + while(pItem != VMA_NULL) + { + ItemType* const pPrevItem = pItem->pPrev; + m_ItemAllocator.Free(pItem); + pItem = pPrevItem; + } + m_pFront = VMA_NULL; + m_pBack = VMA_NULL; + m_Count = 0; + } +} + +template +VmaListItem* VmaRawList::PushBack() +{ + ItemType* const pNewItem = m_ItemAllocator.Alloc(); + pNewItem->pNext = VMA_NULL; + if(IsEmpty()) + { + pNewItem->pPrev = VMA_NULL; + m_pFront = pNewItem; + m_pBack = pNewItem; + m_Count = 1; + } + else + { + pNewItem->pPrev = m_pBack; + m_pBack->pNext = pNewItem; + m_pBack = pNewItem; + ++m_Count; + } + return pNewItem; +} + +template +VmaListItem* VmaRawList::PushFront() +{ + ItemType* const pNewItem = m_ItemAllocator.Alloc(); + pNewItem->pPrev = VMA_NULL; + if(IsEmpty()) + { + pNewItem->pNext = VMA_NULL; + m_pFront = pNewItem; + m_pBack = pNewItem; + m_Count = 1; + } + else + { + pNewItem->pNext = m_pFront; + m_pFront->pPrev = pNewItem; + m_pFront = pNewItem; + ++m_Count; + } + return pNewItem; +} + +template +VmaListItem* VmaRawList::PushBack(const T& value) +{ + ItemType* const pNewItem = PushBack(); + pNewItem->Value = value; + return pNewItem; +} + +template +VmaListItem* VmaRawList::PushFront(const T& value) +{ + ItemType* const pNewItem = PushFront(); + pNewItem->Value = value; + return pNewItem; +} + +template +void VmaRawList::PopBack() +{ + VMA_HEAVY_ASSERT(m_Count > 0); + ItemType* const pBackItem = m_pBack; + ItemType* const pPrevItem = pBackItem->pPrev; + if(pPrevItem != VMA_NULL) + { + pPrevItem->pNext = VMA_NULL; + } + m_pBack = pPrevItem; + m_ItemAllocator.Free(pBackItem); + --m_Count; +} + +template +void VmaRawList::PopFront() +{ + VMA_HEAVY_ASSERT(m_Count > 0); + ItemType* const pFrontItem = m_pFront; + ItemType* const pNextItem = pFrontItem->pNext; + if(pNextItem != VMA_NULL) + { + pNextItem->pPrev = VMA_NULL; + } + m_pFront = pNextItem; + m_ItemAllocator.Free(pFrontItem); + --m_Count; +} + +template +void VmaRawList::Remove(ItemType* pItem) +{ + VMA_HEAVY_ASSERT(pItem != VMA_NULL); + VMA_HEAVY_ASSERT(m_Count > 0); + + if(pItem->pPrev != VMA_NULL) + { + pItem->pPrev->pNext = pItem->pNext; + } + else + { + VMA_HEAVY_ASSERT(m_pFront == pItem); + m_pFront = pItem->pNext; + } + + if(pItem->pNext != VMA_NULL) + { + pItem->pNext->pPrev = pItem->pPrev; + } + else + { + VMA_HEAVY_ASSERT(m_pBack == pItem); + m_pBack = pItem->pPrev; + } + + m_ItemAllocator.Free(pItem); + --m_Count; +} + +template +VmaListItem* VmaRawList::InsertBefore(ItemType* pItem) +{ + if(pItem != VMA_NULL) + { + ItemType* const prevItem = pItem->pPrev; + ItemType* const newItem = m_ItemAllocator.Alloc(); + newItem->pPrev = prevItem; + newItem->pNext = pItem; + pItem->pPrev = newItem; + if(prevItem != VMA_NULL) + { + prevItem->pNext = newItem; + } + else + { + VMA_HEAVY_ASSERT(m_pFront == pItem); + m_pFront = newItem; + } + ++m_Count; + return newItem; + } + else + return PushBack(); +} + +template +VmaListItem* VmaRawList::InsertAfter(ItemType* pItem) +{ + if(pItem != VMA_NULL) + { + ItemType* const nextItem = pItem->pNext; + ItemType* const newItem = m_ItemAllocator.Alloc(); + newItem->pNext = nextItem; + newItem->pPrev = pItem; + pItem->pNext = newItem; + if(nextItem != VMA_NULL) + { + nextItem->pPrev = newItem; + } + else + { + VMA_HEAVY_ASSERT(m_pBack == pItem); + m_pBack = newItem; + } + ++m_Count; + return newItem; + } + else + return PushFront(); +} + +template +VmaListItem* VmaRawList::InsertBefore(ItemType* pItem, const T& value) +{ + ItemType* const newItem = InsertBefore(pItem); + newItem->Value = value; + return newItem; +} + +template +VmaListItem* VmaRawList::InsertAfter(ItemType* pItem, const T& value) +{ + ItemType* const newItem = InsertAfter(pItem); + newItem->Value = value; + return newItem; +} + +template +class VmaList +{ + VMA_CLASS_NO_COPY(VmaList) +public: + class iterator + { + public: + iterator() : + m_pList(VMA_NULL), + m_pItem(VMA_NULL) + { + } + + T& operator*() const + { + VMA_HEAVY_ASSERT(m_pItem != VMA_NULL); + return m_pItem->Value; + } + T* operator->() const + { + VMA_HEAVY_ASSERT(m_pItem != VMA_NULL); + return &m_pItem->Value; + } + + iterator& operator++() + { + VMA_HEAVY_ASSERT(m_pItem != VMA_NULL); + m_pItem = m_pItem->pNext; + return *this; + } + iterator& operator--() + { + if(m_pItem != VMA_NULL) + { + m_pItem = m_pItem->pPrev; + } + else + { + VMA_HEAVY_ASSERT(!m_pList->IsEmpty()); + m_pItem = m_pList->Back(); + } + return *this; + } + + iterator operator++(int) + { + iterator result = *this; + ++*this; + return result; + } + iterator operator--(int) + { + iterator result = *this; + --*this; + return result; + } + + bool operator==(const iterator& rhs) const + { + VMA_HEAVY_ASSERT(m_pList == rhs.m_pList); + return m_pItem == rhs.m_pItem; + } + bool operator!=(const iterator& rhs) const + { + VMA_HEAVY_ASSERT(m_pList == rhs.m_pList); + return m_pItem != rhs.m_pItem; + } + + private: + VmaRawList* m_pList; + VmaListItem* m_pItem; + + iterator(VmaRawList* pList, VmaListItem* pItem) : + m_pList(pList), + m_pItem(pItem) + { + } + + friend class VmaList; + }; + + class const_iterator + { + public: + const_iterator() : + m_pList(VMA_NULL), + m_pItem(VMA_NULL) + { + } + + const_iterator(const iterator& src) : + m_pList(src.m_pList), + m_pItem(src.m_pItem) + { + } + + const T& operator*() const + { + VMA_HEAVY_ASSERT(m_pItem != VMA_NULL); + return m_pItem->Value; + } + const T* operator->() const + { + VMA_HEAVY_ASSERT(m_pItem != VMA_NULL); + return &m_pItem->Value; + } + + const_iterator& operator++() + { + VMA_HEAVY_ASSERT(m_pItem != VMA_NULL); + m_pItem = m_pItem->pNext; + return *this; + } + const_iterator& operator--() + { + if(m_pItem != VMA_NULL) + { + m_pItem = m_pItem->pPrev; + } + else + { + VMA_HEAVY_ASSERT(!m_pList->IsEmpty()); + m_pItem = m_pList->Back(); + } + return *this; + } + + const_iterator operator++(int) + { + const_iterator result = *this; + ++*this; + return result; + } + const_iterator operator--(int) + { + const_iterator result = *this; + --*this; + return result; + } + + bool operator==(const const_iterator& rhs) const + { + VMA_HEAVY_ASSERT(m_pList == rhs.m_pList); + return m_pItem == rhs.m_pItem; + } + bool operator!=(const const_iterator& rhs) const + { + VMA_HEAVY_ASSERT(m_pList == rhs.m_pList); + return m_pItem != rhs.m_pItem; + } + + private: + const_iterator(const VmaRawList* pList, const VmaListItem* pItem) : + m_pList(pList), + m_pItem(pItem) + { + } + + const VmaRawList* m_pList; + const VmaListItem* m_pItem; + + friend class VmaList; + }; + + VmaList(const AllocatorT& allocator) : m_RawList(allocator.m_pCallbacks) { } + + bool empty() const { return m_RawList.IsEmpty(); } + size_t size() const { return m_RawList.GetCount(); } + + iterator begin() { return iterator(&m_RawList, m_RawList.Front()); } + iterator end() { return iterator(&m_RawList, VMA_NULL); } + + const_iterator cbegin() const { return const_iterator(&m_RawList, m_RawList.Front()); } + const_iterator cend() const { return const_iterator(&m_RawList, VMA_NULL); } + + void clear() { m_RawList.Clear(); } + void push_back(const T& value) { m_RawList.PushBack(value); } + void erase(iterator it) { m_RawList.Remove(it.m_pItem); } + iterator insert(iterator it, const T& value) { return iterator(&m_RawList, m_RawList.InsertBefore(it.m_pItem, value)); } + +private: + VmaRawList m_RawList; +}; + +#endif // #if VMA_USE_STL_LIST + +//////////////////////////////////////////////////////////////////////////////// +// class VmaMap + +// Unused in this version. +#if 0 + +#if VMA_USE_STL_UNORDERED_MAP + +#define VmaPair std::pair + +#define VMA_MAP_TYPE(KeyT, ValueT) \ + std::unordered_map< KeyT, ValueT, std::hash, std::equal_to, VmaStlAllocator< std::pair > > + +#else // #if VMA_USE_STL_UNORDERED_MAP + +template +struct VmaPair +{ + T1 first; + T2 second; + + VmaPair() : first(), second() { } + VmaPair(const T1& firstSrc, const T2& secondSrc) : first(firstSrc), second(secondSrc) { } +}; + +/* Class compatible with subset of interface of std::unordered_map. +KeyT, ValueT must be POD because they will be stored in VmaVector. +*/ +template +class VmaMap +{ +public: + typedef VmaPair PairType; + typedef PairType* iterator; + + VmaMap(const VmaStlAllocator& allocator) : m_Vector(allocator) { } + + iterator begin() { return m_Vector.begin(); } + iterator end() { return m_Vector.end(); } + + void insert(const PairType& pair); + iterator find(const KeyT& key); + void erase(iterator it); + +private: + VmaVector< PairType, VmaStlAllocator > m_Vector; +}; + +#define VMA_MAP_TYPE(KeyT, ValueT) VmaMap + +template +struct VmaPairFirstLess +{ + bool operator()(const VmaPair& lhs, const VmaPair& rhs) const + { + return lhs.first < rhs.first; + } + bool operator()(const VmaPair& lhs, const FirstT& rhsFirst) const + { + return lhs.first < rhsFirst; + } +}; + +template +void VmaMap::insert(const PairType& pair) +{ + const size_t indexToInsert = VmaBinaryFindFirstNotLess( + m_Vector.data(), + m_Vector.data() + m_Vector.size(), + pair, + VmaPairFirstLess()) - m_Vector.data(); + VmaVectorInsert(m_Vector, indexToInsert, pair); +} + +template +VmaPair* VmaMap::find(const KeyT& key) +{ + PairType* it = VmaBinaryFindFirstNotLess( + m_Vector.data(), + m_Vector.data() + m_Vector.size(), + key, + VmaPairFirstLess()); + if((it != m_Vector.end()) && (it->first == key)) + { + return it; + } + else + { + return m_Vector.end(); + } +} + +template +void VmaMap::erase(iterator it) +{ + VmaVectorRemove(m_Vector, it - m_Vector.begin()); +} + +#endif // #if VMA_USE_STL_UNORDERED_MAP + +#endif // #if 0 + +//////////////////////////////////////////////////////////////////////////////// + +class VmaDeviceMemoryBlock; + +enum VMA_CACHE_OPERATION { VMA_CACHE_FLUSH, VMA_CACHE_INVALIDATE }; + +struct VmaAllocation_T +{ +private: + static const uint8_t MAP_COUNT_FLAG_PERSISTENT_MAP = 0x80; + + enum FLAGS + { + FLAG_USER_DATA_STRING = 0x01, + }; + +public: + enum ALLOCATION_TYPE + { + ALLOCATION_TYPE_NONE, + ALLOCATION_TYPE_BLOCK, + ALLOCATION_TYPE_DEDICATED, + }; + + /* + This struct is allocated using VmaPoolAllocator. + */ + + VmaAllocation_T(uint32_t currentFrameIndex, bool userDataString) : + m_Alignment{1}, + m_Size{0}, + m_pUserData{VMA_NULL}, + m_LastUseFrameIndex{currentFrameIndex}, + m_MemoryTypeIndex{0}, + m_Type{(uint8_t)ALLOCATION_TYPE_NONE}, + m_SuballocationType{(uint8_t)VMA_SUBALLOCATION_TYPE_UNKNOWN}, + m_MapCount{0}, + m_Flags{userDataString ? (uint8_t)FLAG_USER_DATA_STRING : (uint8_t)0} + { +#if VMA_STATS_STRING_ENABLED + m_CreationFrameIndex = currentFrameIndex; + m_BufferImageUsage = 0; +#endif + } + + ~VmaAllocation_T() + { + VMA_ASSERT((m_MapCount & ~MAP_COUNT_FLAG_PERSISTENT_MAP) == 0 && "Allocation was not unmapped before destruction."); + + // Check if owned string was freed. + VMA_ASSERT(m_pUserData == VMA_NULL); + } + + void InitBlockAllocation( + VmaDeviceMemoryBlock* block, + VkDeviceSize offset, + VkDeviceSize alignment, + VkDeviceSize size, + uint32_t memoryTypeIndex, + VmaSuballocationType suballocationType, + bool mapped, + bool canBecomeLost) + { + VMA_ASSERT(m_Type == ALLOCATION_TYPE_NONE); + VMA_ASSERT(block != VMA_NULL); + m_Type = (uint8_t)ALLOCATION_TYPE_BLOCK; + m_Alignment = alignment; + m_Size = size; + m_MemoryTypeIndex = memoryTypeIndex; + m_MapCount = mapped ? MAP_COUNT_FLAG_PERSISTENT_MAP : 0; + m_SuballocationType = (uint8_t)suballocationType; + m_BlockAllocation.m_Block = block; + m_BlockAllocation.m_Offset = offset; + m_BlockAllocation.m_CanBecomeLost = canBecomeLost; + } + + void InitLost() + { + VMA_ASSERT(m_Type == ALLOCATION_TYPE_NONE); + VMA_ASSERT(m_LastUseFrameIndex.load() == VMA_FRAME_INDEX_LOST); + m_Type = (uint8_t)ALLOCATION_TYPE_BLOCK; + m_MemoryTypeIndex = 0; + m_BlockAllocation.m_Block = VMA_NULL; + m_BlockAllocation.m_Offset = 0; + m_BlockAllocation.m_CanBecomeLost = true; + } + + void ChangeBlockAllocation( + VmaAllocator hAllocator, + VmaDeviceMemoryBlock* block, + VkDeviceSize offset); + + void ChangeOffset(VkDeviceSize newOffset); + + // pMappedData not null means allocation is created with MAPPED flag. + void InitDedicatedAllocation( + uint32_t memoryTypeIndex, + VkDeviceMemory hMemory, + VmaSuballocationType suballocationType, + void* pMappedData, + VkDeviceSize size) + { + VMA_ASSERT(m_Type == ALLOCATION_TYPE_NONE); + VMA_ASSERT(hMemory != VK_NULL_HANDLE); + m_Type = (uint8_t)ALLOCATION_TYPE_DEDICATED; + m_Alignment = 0; + m_Size = size; + m_MemoryTypeIndex = memoryTypeIndex; + m_SuballocationType = (uint8_t)suballocationType; + m_MapCount = (pMappedData != VMA_NULL) ? MAP_COUNT_FLAG_PERSISTENT_MAP : 0; + m_DedicatedAllocation.m_hMemory = hMemory; + m_DedicatedAllocation.m_pMappedData = pMappedData; + } + + ALLOCATION_TYPE GetType() const { return (ALLOCATION_TYPE)m_Type; } + VkDeviceSize GetAlignment() const { return m_Alignment; } + VkDeviceSize GetSize() const { return m_Size; } + bool IsUserDataString() const { return (m_Flags & FLAG_USER_DATA_STRING) != 0; } + void* GetUserData() const { return m_pUserData; } + void SetUserData(VmaAllocator hAllocator, void* pUserData); + VmaSuballocationType GetSuballocationType() const { return (VmaSuballocationType)m_SuballocationType; } + + VmaDeviceMemoryBlock* GetBlock() const + { + VMA_ASSERT(m_Type == ALLOCATION_TYPE_BLOCK); + return m_BlockAllocation.m_Block; + } + VkDeviceSize GetOffset() const; + VkDeviceMemory GetMemory() const; + uint32_t GetMemoryTypeIndex() const { return m_MemoryTypeIndex; } + bool IsPersistentMap() const { return (m_MapCount & MAP_COUNT_FLAG_PERSISTENT_MAP) != 0; } + void* GetMappedData() const; + bool CanBecomeLost() const; + + uint32_t GetLastUseFrameIndex() const + { + return m_LastUseFrameIndex.load(); + } + bool CompareExchangeLastUseFrameIndex(uint32_t& expected, uint32_t desired) + { + return m_LastUseFrameIndex.compare_exchange_weak(expected, desired); + } + /* + - If hAllocation.LastUseFrameIndex + frameInUseCount < allocator.CurrentFrameIndex, + makes it lost by setting LastUseFrameIndex = VMA_FRAME_INDEX_LOST and returns true. + - Else, returns false. + + If hAllocation is already lost, assert - you should not call it then. + If hAllocation was not created with CAN_BECOME_LOST_BIT, assert. + */ + bool MakeLost(uint32_t currentFrameIndex, uint32_t frameInUseCount); + + void DedicatedAllocCalcStatsInfo(VmaStatInfo& outInfo) + { + VMA_ASSERT(m_Type == ALLOCATION_TYPE_DEDICATED); + outInfo.blockCount = 1; + outInfo.allocationCount = 1; + outInfo.unusedRangeCount = 0; + outInfo.usedBytes = m_Size; + outInfo.unusedBytes = 0; + outInfo.allocationSizeMin = outInfo.allocationSizeMax = m_Size; + outInfo.unusedRangeSizeMin = UINT64_MAX; + outInfo.unusedRangeSizeMax = 0; + } + + void BlockAllocMap(); + void BlockAllocUnmap(); + VkResult DedicatedAllocMap(VmaAllocator hAllocator, void** ppData); + void DedicatedAllocUnmap(VmaAllocator hAllocator); + +#if VMA_STATS_STRING_ENABLED + uint32_t GetCreationFrameIndex() const { return m_CreationFrameIndex; } + uint32_t GetBufferImageUsage() const { return m_BufferImageUsage; } + + void InitBufferImageUsage(uint32_t bufferImageUsage) + { + VMA_ASSERT(m_BufferImageUsage == 0); + m_BufferImageUsage = bufferImageUsage; + } + + void PrintParameters(class VmaJsonWriter& json) const; +#endif + +private: + VkDeviceSize m_Alignment; + VkDeviceSize m_Size; + void* m_pUserData; + VMA_ATOMIC_UINT32 m_LastUseFrameIndex; + uint32_t m_MemoryTypeIndex; + uint8_t m_Type; // ALLOCATION_TYPE + uint8_t m_SuballocationType; // VmaSuballocationType + // Bit 0x80 is set when allocation was created with VMA_ALLOCATION_CREATE_MAPPED_BIT. + // Bits with mask 0x7F are reference counter for vmaMapMemory()/vmaUnmapMemory(). + uint8_t m_MapCount; + uint8_t m_Flags; // enum FLAGS + + // Allocation out of VmaDeviceMemoryBlock. + struct BlockAllocation + { + VmaDeviceMemoryBlock* m_Block; + VkDeviceSize m_Offset; + bool m_CanBecomeLost; + }; + + // Allocation for an object that has its own private VkDeviceMemory. + struct DedicatedAllocation + { + VkDeviceMemory m_hMemory; + void* m_pMappedData; // Not null means memory is mapped. + }; + + union + { + // Allocation out of VmaDeviceMemoryBlock. + BlockAllocation m_BlockAllocation; + // Allocation for an object that has its own private VkDeviceMemory. + DedicatedAllocation m_DedicatedAllocation; + }; + +#if VMA_STATS_STRING_ENABLED + uint32_t m_CreationFrameIndex; + uint32_t m_BufferImageUsage; // 0 if unknown. +#endif + + void FreeUserDataString(VmaAllocator hAllocator); +}; + +/* +Represents a region of VmaDeviceMemoryBlock that is either assigned and returned as +allocated memory block or free. +*/ +struct VmaSuballocation +{ + VkDeviceSize offset; + VkDeviceSize size; + VmaAllocation hAllocation; + VmaSuballocationType type; +}; + +// Comparator for offsets. +struct VmaSuballocationOffsetLess +{ + bool operator()(const VmaSuballocation& lhs, const VmaSuballocation& rhs) const + { + return lhs.offset < rhs.offset; + } +}; +struct VmaSuballocationOffsetGreater +{ + bool operator()(const VmaSuballocation& lhs, const VmaSuballocation& rhs) const + { + return lhs.offset > rhs.offset; + } +}; + +typedef VmaList< VmaSuballocation, VmaStlAllocator > VmaSuballocationList; + +// Cost of one additional allocation lost, as equivalent in bytes. +static const VkDeviceSize VMA_LOST_ALLOCATION_COST = 1048576; + +enum class VmaAllocationRequestType +{ + Normal, + // Used by "Linear" algorithm. + UpperAddress, + EndOf1st, + EndOf2nd, +}; + +/* +Parameters of planned allocation inside a VmaDeviceMemoryBlock. + +If canMakeOtherLost was false: +- item points to a FREE suballocation. +- itemsToMakeLostCount is 0. + +If canMakeOtherLost was true: +- item points to first of sequence of suballocations, which are either FREE, + or point to VmaAllocations that can become lost. +- itemsToMakeLostCount is the number of VmaAllocations that need to be made lost for + the requested allocation to succeed. +*/ +struct VmaAllocationRequest +{ + VkDeviceSize offset; + VkDeviceSize sumFreeSize; // Sum size of free items that overlap with proposed allocation. + VkDeviceSize sumItemSize; // Sum size of items to make lost that overlap with proposed allocation. + VmaSuballocationList::iterator item; + size_t itemsToMakeLostCount; + void* customData; + VmaAllocationRequestType type; + + VkDeviceSize CalcCost() const + { + return sumItemSize + itemsToMakeLostCount * VMA_LOST_ALLOCATION_COST; + } +}; + +/* +Data structure used for bookkeeping of allocations and unused ranges of memory +in a single VkDeviceMemory block. +*/ +class VmaBlockMetadata +{ +public: + VmaBlockMetadata(VmaAllocator hAllocator); + virtual ~VmaBlockMetadata() { } + virtual void Init(VkDeviceSize size) { m_Size = size; } + + // Validates all data structures inside this object. If not valid, returns false. + virtual bool Validate() const = 0; + VkDeviceSize GetSize() const { return m_Size; } + virtual size_t GetAllocationCount() const = 0; + virtual VkDeviceSize GetSumFreeSize() const = 0; + virtual VkDeviceSize GetUnusedRangeSizeMax() const = 0; + // Returns true if this block is empty - contains only single free suballocation. + virtual bool IsEmpty() const = 0; + + virtual void CalcAllocationStatInfo(VmaStatInfo& outInfo) const = 0; + // Shouldn't modify blockCount. + virtual void AddPoolStats(VmaPoolStats& inoutStats) const = 0; + +#if VMA_STATS_STRING_ENABLED + virtual void PrintDetailedMap(class VmaJsonWriter& json) const = 0; +#endif + + // Tries to find a place for suballocation with given parameters inside this block. + // If succeeded, fills pAllocationRequest and returns true. + // If failed, returns false. + virtual bool CreateAllocationRequest( + uint32_t currentFrameIndex, + uint32_t frameInUseCount, + VkDeviceSize bufferImageGranularity, + VkDeviceSize allocSize, + VkDeviceSize allocAlignment, + bool upperAddress, + VmaSuballocationType allocType, + bool canMakeOtherLost, + // Always one of VMA_ALLOCATION_CREATE_STRATEGY_* or VMA_ALLOCATION_INTERNAL_STRATEGY_* flags. + uint32_t strategy, + VmaAllocationRequest* pAllocationRequest) = 0; + + virtual bool MakeRequestedAllocationsLost( + uint32_t currentFrameIndex, + uint32_t frameInUseCount, + VmaAllocationRequest* pAllocationRequest) = 0; + + virtual uint32_t MakeAllocationsLost(uint32_t currentFrameIndex, uint32_t frameInUseCount) = 0; + + virtual VkResult CheckCorruption(const void* pBlockData) = 0; + + // Makes actual allocation based on request. Request must already be checked and valid. + virtual void Alloc( + const VmaAllocationRequest& request, + VmaSuballocationType type, + VkDeviceSize allocSize, + VmaAllocation hAllocation) = 0; + + // Frees suballocation assigned to given memory region. + virtual void Free(const VmaAllocation allocation) = 0; + virtual void FreeAtOffset(VkDeviceSize offset) = 0; + +protected: + const VkAllocationCallbacks* GetAllocationCallbacks() const { return m_pAllocationCallbacks; } + +#if VMA_STATS_STRING_ENABLED + void PrintDetailedMap_Begin(class VmaJsonWriter& json, + VkDeviceSize unusedBytes, + size_t allocationCount, + size_t unusedRangeCount) const; + void PrintDetailedMap_Allocation(class VmaJsonWriter& json, + VkDeviceSize offset, + VmaAllocation hAllocation) const; + void PrintDetailedMap_UnusedRange(class VmaJsonWriter& json, + VkDeviceSize offset, + VkDeviceSize size) const; + void PrintDetailedMap_End(class VmaJsonWriter& json) const; +#endif + +private: + VkDeviceSize m_Size; + const VkAllocationCallbacks* m_pAllocationCallbacks; +}; + +#define VMA_VALIDATE(cond) do { if(!(cond)) { \ + VMA_ASSERT(0 && "Validation failed: " #cond); \ + return false; \ + } } while(false) + +class VmaBlockMetadata_Generic : public VmaBlockMetadata +{ + VMA_CLASS_NO_COPY(VmaBlockMetadata_Generic) +public: + VmaBlockMetadata_Generic(VmaAllocator hAllocator); + virtual ~VmaBlockMetadata_Generic(); + virtual void Init(VkDeviceSize size); + + virtual bool Validate() const; + virtual size_t GetAllocationCount() const { return m_Suballocations.size() - m_FreeCount; } + virtual VkDeviceSize GetSumFreeSize() const { return m_SumFreeSize; } + virtual VkDeviceSize GetUnusedRangeSizeMax() const; + virtual bool IsEmpty() const; + + virtual void CalcAllocationStatInfo(VmaStatInfo& outInfo) const; + virtual void AddPoolStats(VmaPoolStats& inoutStats) const; + +#if VMA_STATS_STRING_ENABLED + virtual void PrintDetailedMap(class VmaJsonWriter& json) const; +#endif + + virtual bool CreateAllocationRequest( + uint32_t currentFrameIndex, + uint32_t frameInUseCount, + VkDeviceSize bufferImageGranularity, + VkDeviceSize allocSize, + VkDeviceSize allocAlignment, + bool upperAddress, + VmaSuballocationType allocType, + bool canMakeOtherLost, + uint32_t strategy, + VmaAllocationRequest* pAllocationRequest); + + virtual bool MakeRequestedAllocationsLost( + uint32_t currentFrameIndex, + uint32_t frameInUseCount, + VmaAllocationRequest* pAllocationRequest); + + virtual uint32_t MakeAllocationsLost(uint32_t currentFrameIndex, uint32_t frameInUseCount); + + virtual VkResult CheckCorruption(const void* pBlockData); + + virtual void Alloc( + const VmaAllocationRequest& request, + VmaSuballocationType type, + VkDeviceSize allocSize, + VmaAllocation hAllocation); + + virtual void Free(const VmaAllocation allocation); + virtual void FreeAtOffset(VkDeviceSize offset); + + //////////////////////////////////////////////////////////////////////////////// + // For defragmentation + + bool IsBufferImageGranularityConflictPossible( + VkDeviceSize bufferImageGranularity, + VmaSuballocationType& inOutPrevSuballocType) const; + +private: + friend class VmaDefragmentationAlgorithm_Generic; + friend class VmaDefragmentationAlgorithm_Fast; + + uint32_t m_FreeCount; + VkDeviceSize m_SumFreeSize; + VmaSuballocationList m_Suballocations; + // Suballocations that are free and have size greater than certain threshold. + // Sorted by size, ascending. + VmaVector< VmaSuballocationList::iterator, VmaStlAllocator< VmaSuballocationList::iterator > > m_FreeSuballocationsBySize; + + bool ValidateFreeSuballocationList() const; + + // Checks if requested suballocation with given parameters can be placed in given pFreeSuballocItem. + // If yes, fills pOffset and returns true. If no, returns false. + bool CheckAllocation( + uint32_t currentFrameIndex, + uint32_t frameInUseCount, + VkDeviceSize bufferImageGranularity, + VkDeviceSize allocSize, + VkDeviceSize allocAlignment, + VmaSuballocationType allocType, + VmaSuballocationList::const_iterator suballocItem, + bool canMakeOtherLost, + VkDeviceSize* pOffset, + size_t* itemsToMakeLostCount, + VkDeviceSize* pSumFreeSize, + VkDeviceSize* pSumItemSize) const; + // Given free suballocation, it merges it with following one, which must also be free. + void MergeFreeWithNext(VmaSuballocationList::iterator item); + // Releases given suballocation, making it free. + // Merges it with adjacent free suballocations if applicable. + // Returns iterator to new free suballocation at this place. + VmaSuballocationList::iterator FreeSuballocation(VmaSuballocationList::iterator suballocItem); + // Given free suballocation, it inserts it into sorted list of + // m_FreeSuballocationsBySize if it's suitable. + void RegisterFreeSuballocation(VmaSuballocationList::iterator item); + // Given free suballocation, it removes it from sorted list of + // m_FreeSuballocationsBySize if it's suitable. + void UnregisterFreeSuballocation(VmaSuballocationList::iterator item); +}; + +/* +Allocations and their references in internal data structure look like this: + +if(m_2ndVectorMode == SECOND_VECTOR_EMPTY): + + 0 +-------+ + | | + | | + | | + +-------+ + | Alloc | 1st[m_1stNullItemsBeginCount] + +-------+ + | Alloc | 1st[m_1stNullItemsBeginCount + 1] + +-------+ + | ... | + +-------+ + | Alloc | 1st[1st.size() - 1] + +-------+ + | | + | | + | | +GetSize() +-------+ + +if(m_2ndVectorMode == SECOND_VECTOR_RING_BUFFER): + + 0 +-------+ + | Alloc | 2nd[0] + +-------+ + | Alloc | 2nd[1] + +-------+ + | ... | + +-------+ + | Alloc | 2nd[2nd.size() - 1] + +-------+ + | | + | | + | | + +-------+ + | Alloc | 1st[m_1stNullItemsBeginCount] + +-------+ + | Alloc | 1st[m_1stNullItemsBeginCount + 1] + +-------+ + | ... | + +-------+ + | Alloc | 1st[1st.size() - 1] + +-------+ + | | +GetSize() +-------+ + +if(m_2ndVectorMode == SECOND_VECTOR_DOUBLE_STACK): + + 0 +-------+ + | | + | | + | | + +-------+ + | Alloc | 1st[m_1stNullItemsBeginCount] + +-------+ + | Alloc | 1st[m_1stNullItemsBeginCount + 1] + +-------+ + | ... | + +-------+ + | Alloc | 1st[1st.size() - 1] + +-------+ + | | + | | + | | + +-------+ + | Alloc | 2nd[2nd.size() - 1] + +-------+ + | ... | + +-------+ + | Alloc | 2nd[1] + +-------+ + | Alloc | 2nd[0] +GetSize() +-------+ + +*/ +class VmaBlockMetadata_Linear : public VmaBlockMetadata +{ + VMA_CLASS_NO_COPY(VmaBlockMetadata_Linear) +public: + VmaBlockMetadata_Linear(VmaAllocator hAllocator); + virtual ~VmaBlockMetadata_Linear(); + virtual void Init(VkDeviceSize size); + + virtual bool Validate() const; + virtual size_t GetAllocationCount() const; + virtual VkDeviceSize GetSumFreeSize() const { return m_SumFreeSize; } + virtual VkDeviceSize GetUnusedRangeSizeMax() const; + virtual bool IsEmpty() const { return GetAllocationCount() == 0; } + + virtual void CalcAllocationStatInfo(VmaStatInfo& outInfo) const; + virtual void AddPoolStats(VmaPoolStats& inoutStats) const; + +#if VMA_STATS_STRING_ENABLED + virtual void PrintDetailedMap(class VmaJsonWriter& json) const; +#endif + + virtual bool CreateAllocationRequest( + uint32_t currentFrameIndex, + uint32_t frameInUseCount, + VkDeviceSize bufferImageGranularity, + VkDeviceSize allocSize, + VkDeviceSize allocAlignment, + bool upperAddress, + VmaSuballocationType allocType, + bool canMakeOtherLost, + uint32_t strategy, + VmaAllocationRequest* pAllocationRequest); + + virtual bool MakeRequestedAllocationsLost( + uint32_t currentFrameIndex, + uint32_t frameInUseCount, + VmaAllocationRequest* pAllocationRequest); + + virtual uint32_t MakeAllocationsLost(uint32_t currentFrameIndex, uint32_t frameInUseCount); + + virtual VkResult CheckCorruption(const void* pBlockData); + + virtual void Alloc( + const VmaAllocationRequest& request, + VmaSuballocationType type, + VkDeviceSize allocSize, + VmaAllocation hAllocation); + + virtual void Free(const VmaAllocation allocation); + virtual void FreeAtOffset(VkDeviceSize offset); + +private: + /* + There are two suballocation vectors, used in ping-pong way. + The one with index m_1stVectorIndex is called 1st. + The one with index (m_1stVectorIndex ^ 1) is called 2nd. + 2nd can be non-empty only when 1st is not empty. + When 2nd is not empty, m_2ndVectorMode indicates its mode of operation. + */ + typedef VmaVector< VmaSuballocation, VmaStlAllocator > SuballocationVectorType; + + enum SECOND_VECTOR_MODE + { + SECOND_VECTOR_EMPTY, + /* + Suballocations in 2nd vector are created later than the ones in 1st, but they + all have smaller offset. + */ + SECOND_VECTOR_RING_BUFFER, + /* + Suballocations in 2nd vector are upper side of double stack. + They all have offsets higher than those in 1st vector. + Top of this stack means smaller offsets, but higher indices in this vector. + */ + SECOND_VECTOR_DOUBLE_STACK, + }; + + VkDeviceSize m_SumFreeSize; + SuballocationVectorType m_Suballocations0, m_Suballocations1; + uint32_t m_1stVectorIndex; + SECOND_VECTOR_MODE m_2ndVectorMode; + + SuballocationVectorType& AccessSuballocations1st() { return m_1stVectorIndex ? m_Suballocations1 : m_Suballocations0; } + SuballocationVectorType& AccessSuballocations2nd() { return m_1stVectorIndex ? m_Suballocations0 : m_Suballocations1; } + const SuballocationVectorType& AccessSuballocations1st() const { return m_1stVectorIndex ? m_Suballocations1 : m_Suballocations0; } + const SuballocationVectorType& AccessSuballocations2nd() const { return m_1stVectorIndex ? m_Suballocations0 : m_Suballocations1; } + + // Number of items in 1st vector with hAllocation = null at the beginning. + size_t m_1stNullItemsBeginCount; + // Number of other items in 1st vector with hAllocation = null somewhere in the middle. + size_t m_1stNullItemsMiddleCount; + // Number of items in 2nd vector with hAllocation = null. + size_t m_2ndNullItemsCount; + + bool ShouldCompact1st() const; + void CleanupAfterFree(); + + bool CreateAllocationRequest_LowerAddress( + uint32_t currentFrameIndex, + uint32_t frameInUseCount, + VkDeviceSize bufferImageGranularity, + VkDeviceSize allocSize, + VkDeviceSize allocAlignment, + VmaSuballocationType allocType, + bool canMakeOtherLost, + uint32_t strategy, + VmaAllocationRequest* pAllocationRequest); + bool CreateAllocationRequest_UpperAddress( + uint32_t currentFrameIndex, + uint32_t frameInUseCount, + VkDeviceSize bufferImageGranularity, + VkDeviceSize allocSize, + VkDeviceSize allocAlignment, + VmaSuballocationType allocType, + bool canMakeOtherLost, + uint32_t strategy, + VmaAllocationRequest* pAllocationRequest); +}; + +/* +- GetSize() is the original size of allocated memory block. +- m_UsableSize is this size aligned down to a power of two. + All allocations and calculations happen relative to m_UsableSize. +- GetUnusableSize() is the difference between them. + It is repoted as separate, unused range, not available for allocations. + +Node at level 0 has size = m_UsableSize. +Each next level contains nodes with size 2 times smaller than current level. +m_LevelCount is the maximum number of levels to use in the current object. +*/ +class VmaBlockMetadata_Buddy : public VmaBlockMetadata +{ + VMA_CLASS_NO_COPY(VmaBlockMetadata_Buddy) +public: + VmaBlockMetadata_Buddy(VmaAllocator hAllocator); + virtual ~VmaBlockMetadata_Buddy(); + virtual void Init(VkDeviceSize size); + + virtual bool Validate() const; + virtual size_t GetAllocationCount() const { return m_AllocationCount; } + virtual VkDeviceSize GetSumFreeSize() const { return m_SumFreeSize + GetUnusableSize(); } + virtual VkDeviceSize GetUnusedRangeSizeMax() const; + virtual bool IsEmpty() const { return m_Root->type == Node::TYPE_FREE; } + + virtual void CalcAllocationStatInfo(VmaStatInfo& outInfo) const; + virtual void AddPoolStats(VmaPoolStats& inoutStats) const; + +#if VMA_STATS_STRING_ENABLED + virtual void PrintDetailedMap(class VmaJsonWriter& json) const; +#endif + + virtual bool CreateAllocationRequest( + uint32_t currentFrameIndex, + uint32_t frameInUseCount, + VkDeviceSize bufferImageGranularity, + VkDeviceSize allocSize, + VkDeviceSize allocAlignment, + bool upperAddress, + VmaSuballocationType allocType, + bool canMakeOtherLost, + uint32_t strategy, + VmaAllocationRequest* pAllocationRequest); + + virtual bool MakeRequestedAllocationsLost( + uint32_t currentFrameIndex, + uint32_t frameInUseCount, + VmaAllocationRequest* pAllocationRequest); + + virtual uint32_t MakeAllocationsLost(uint32_t currentFrameIndex, uint32_t frameInUseCount); + + virtual VkResult CheckCorruption(const void* pBlockData) { return VK_ERROR_FEATURE_NOT_PRESENT; } + + virtual void Alloc( + const VmaAllocationRequest& request, + VmaSuballocationType type, + VkDeviceSize allocSize, + VmaAllocation hAllocation); + + virtual void Free(const VmaAllocation allocation) { FreeAtOffset(allocation, allocation->GetOffset()); } + virtual void FreeAtOffset(VkDeviceSize offset) { FreeAtOffset(VMA_NULL, offset); } + +private: + static const VkDeviceSize MIN_NODE_SIZE = 32; + static const size_t MAX_LEVELS = 30; + + struct ValidationContext + { + size_t calculatedAllocationCount; + size_t calculatedFreeCount; + VkDeviceSize calculatedSumFreeSize; + + ValidationContext() : + calculatedAllocationCount(0), + calculatedFreeCount(0), + calculatedSumFreeSize(0) { } + }; + + struct Node + { + VkDeviceSize offset; + enum TYPE + { + TYPE_FREE, + TYPE_ALLOCATION, + TYPE_SPLIT, + TYPE_COUNT + } type; + Node* parent; + Node* buddy; + + union + { + struct + { + Node* prev; + Node* next; + } free; + struct + { + VmaAllocation alloc; + } allocation; + struct + { + Node* leftChild; + } split; + }; + }; + + // Size of the memory block aligned down to a power of two. + VkDeviceSize m_UsableSize; + uint32_t m_LevelCount; + + Node* m_Root; + struct { + Node* front; + Node* back; + } m_FreeList[MAX_LEVELS]; + // Number of nodes in the tree with type == TYPE_ALLOCATION. + size_t m_AllocationCount; + // Number of nodes in the tree with type == TYPE_FREE. + size_t m_FreeCount; + // This includes space wasted due to internal fragmentation. Doesn't include unusable size. + VkDeviceSize m_SumFreeSize; + + VkDeviceSize GetUnusableSize() const { return GetSize() - m_UsableSize; } + void DeleteNode(Node* node); + bool ValidateNode(ValidationContext& ctx, const Node* parent, const Node* curr, uint32_t level, VkDeviceSize levelNodeSize) const; + uint32_t AllocSizeToLevel(VkDeviceSize allocSize) const; + inline VkDeviceSize LevelToNodeSize(uint32_t level) const { return m_UsableSize >> level; } + // Alloc passed just for validation. Can be null. + void FreeAtOffset(VmaAllocation alloc, VkDeviceSize offset); + void CalcAllocationStatInfoNode(VmaStatInfo& outInfo, const Node* node, VkDeviceSize levelNodeSize) const; + // Adds node to the front of FreeList at given level. + // node->type must be FREE. + // node->free.prev, next can be undefined. + void AddToFreeListFront(uint32_t level, Node* node); + // Removes node from FreeList at given level. + // node->type must be FREE. + // node->free.prev, next stay untouched. + void RemoveFromFreeList(uint32_t level, Node* node); + +#if VMA_STATS_STRING_ENABLED + void PrintDetailedMapNode(class VmaJsonWriter& json, const Node* node, VkDeviceSize levelNodeSize) const; +#endif +}; + +/* +Represents a single block of device memory (`VkDeviceMemory`) with all the +data about its regions (aka suballocations, #VmaAllocation), assigned and free. + +Thread-safety: This class must be externally synchronized. +*/ +class VmaDeviceMemoryBlock +{ + VMA_CLASS_NO_COPY(VmaDeviceMemoryBlock) +public: + VmaBlockMetadata* m_pMetadata; + + VmaDeviceMemoryBlock(VmaAllocator hAllocator); + + ~VmaDeviceMemoryBlock() + { + VMA_ASSERT(m_MapCount == 0 && "VkDeviceMemory block is being destroyed while it is still mapped."); + VMA_ASSERT(m_hMemory == VK_NULL_HANDLE); + } + + // Always call after construction. + void Init( + VmaAllocator hAllocator, + VmaPool hParentPool, + uint32_t newMemoryTypeIndex, + VkDeviceMemory newMemory, + VkDeviceSize newSize, + uint32_t id, + uint32_t algorithm); + // Always call before destruction. + void Destroy(VmaAllocator allocator); + + VmaPool GetParentPool() const { return m_hParentPool; } + VkDeviceMemory GetDeviceMemory() const { return m_hMemory; } + uint32_t GetMemoryTypeIndex() const { return m_MemoryTypeIndex; } + uint32_t GetId() const { return m_Id; } + void* GetMappedData() const { return m_pMappedData; } + + // Validates all data structures inside this object. If not valid, returns false. + bool Validate() const; + + VkResult CheckCorruption(VmaAllocator hAllocator); + + // ppData can be null. + VkResult Map(VmaAllocator hAllocator, uint32_t count, void** ppData); + void Unmap(VmaAllocator hAllocator, uint32_t count); + + VkResult WriteMagicValueAroundAllocation(VmaAllocator hAllocator, VkDeviceSize allocOffset, VkDeviceSize allocSize); + VkResult ValidateMagicValueAroundAllocation(VmaAllocator hAllocator, VkDeviceSize allocOffset, VkDeviceSize allocSize); + + VkResult BindBufferMemory( + const VmaAllocator hAllocator, + const VmaAllocation hAllocation, + VkDeviceSize allocationLocalOffset, + VkBuffer hBuffer, + const void* pNext); + VkResult BindImageMemory( + const VmaAllocator hAllocator, + const VmaAllocation hAllocation, + VkDeviceSize allocationLocalOffset, + VkImage hImage, + const void* pNext); + +private: + VmaPool m_hParentPool; // VK_NULL_HANDLE if not belongs to custom pool. + uint32_t m_MemoryTypeIndex; + uint32_t m_Id; + VkDeviceMemory m_hMemory; + + /* + Protects access to m_hMemory so it's not used by multiple threads simultaneously, e.g. vkMapMemory, vkBindBufferMemory. + Also protects m_MapCount, m_pMappedData. + Allocations, deallocations, any change in m_pMetadata is protected by parent's VmaBlockVector::m_Mutex. + */ + VMA_MUTEX m_Mutex; + uint32_t m_MapCount; + void* m_pMappedData; +}; + +struct VmaPointerLess +{ + bool operator()(const void* lhs, const void* rhs) const + { + return lhs < rhs; + } +}; + +struct VmaDefragmentationMove +{ + size_t srcBlockIndex; + size_t dstBlockIndex; + VkDeviceSize srcOffset; + VkDeviceSize dstOffset; + VkDeviceSize size; + VmaAllocation hAllocation; + VmaDeviceMemoryBlock* pSrcBlock; + VmaDeviceMemoryBlock* pDstBlock; +}; + +class VmaDefragmentationAlgorithm; + +/* +Sequence of VmaDeviceMemoryBlock. Represents memory blocks allocated for a specific +Vulkan memory type. + +Synchronized internally with a mutex. +*/ +struct VmaBlockVector +{ + VMA_CLASS_NO_COPY(VmaBlockVector) +public: + VmaBlockVector( + VmaAllocator hAllocator, + VmaPool hParentPool, + uint32_t memoryTypeIndex, + VkDeviceSize preferredBlockSize, + size_t minBlockCount, + size_t maxBlockCount, + VkDeviceSize bufferImageGranularity, + uint32_t frameInUseCount, + bool explicitBlockSize, + uint32_t algorithm); + ~VmaBlockVector(); + + VkResult CreateMinBlocks(); + + VmaAllocator GetAllocator() const { return m_hAllocator; } + VmaPool GetParentPool() const { return m_hParentPool; } + bool IsCustomPool() const { return m_hParentPool != VMA_NULL; } + uint32_t GetMemoryTypeIndex() const { return m_MemoryTypeIndex; } + VkDeviceSize GetPreferredBlockSize() const { return m_PreferredBlockSize; } + VkDeviceSize GetBufferImageGranularity() const { return m_BufferImageGranularity; } + uint32_t GetFrameInUseCount() const { return m_FrameInUseCount; } + uint32_t GetAlgorithm() const { return m_Algorithm; } + + void GetPoolStats(VmaPoolStats* pStats); + + bool IsEmpty(); + bool IsCorruptionDetectionEnabled() const; + + VkResult Allocate( + uint32_t currentFrameIndex, + VkDeviceSize size, + VkDeviceSize alignment, + const VmaAllocationCreateInfo& createInfo, + VmaSuballocationType suballocType, + size_t allocationCount, + VmaAllocation* pAllocations); + + void Free(const VmaAllocation hAllocation); + + // Adds statistics of this BlockVector to pStats. + void AddStats(VmaStats* pStats); + +#if VMA_STATS_STRING_ENABLED + void PrintDetailedMap(class VmaJsonWriter& json); +#endif + + void MakePoolAllocationsLost( + uint32_t currentFrameIndex, + size_t* pLostAllocationCount); + VkResult CheckCorruption(); + + // Saves results in pCtx->res. + void Defragment( + class VmaBlockVectorDefragmentationContext* pCtx, + VmaDefragmentationStats* pStats, VmaDefragmentationFlags flags, + VkDeviceSize& maxCpuBytesToMove, uint32_t& maxCpuAllocationsToMove, + VkDeviceSize& maxGpuBytesToMove, uint32_t& maxGpuAllocationsToMove, + VkCommandBuffer commandBuffer); + void DefragmentationEnd( + class VmaBlockVectorDefragmentationContext* pCtx, + VmaDefragmentationStats* pStats); + + uint32_t ProcessDefragmentations( + class VmaBlockVectorDefragmentationContext *pCtx, + VmaDefragmentationPassMoveInfo* pMove, uint32_t maxMoves); + + void CommitDefragmentations( + class VmaBlockVectorDefragmentationContext *pCtx, + VmaDefragmentationStats* pStats); + + //////////////////////////////////////////////////////////////////////////////// + // To be used only while the m_Mutex is locked. Used during defragmentation. + + size_t GetBlockCount() const { return m_Blocks.size(); } + VmaDeviceMemoryBlock* GetBlock(size_t index) const { return m_Blocks[index]; } + size_t CalcAllocationCount() const; + bool IsBufferImageGranularityConflictPossible() const; + +private: + friend class VmaDefragmentationAlgorithm_Generic; + + const VmaAllocator m_hAllocator; + const VmaPool m_hParentPool; + const uint32_t m_MemoryTypeIndex; + const VkDeviceSize m_PreferredBlockSize; + const size_t m_MinBlockCount; + const size_t m_MaxBlockCount; + const VkDeviceSize m_BufferImageGranularity; + const uint32_t m_FrameInUseCount; + const bool m_ExplicitBlockSize; + const uint32_t m_Algorithm; + VMA_RW_MUTEX m_Mutex; + + /* There can be at most one allocation that is completely empty (except when minBlockCount > 0) - + a hysteresis to avoid pessimistic case of alternating creation and destruction of a VkDeviceMemory. */ + bool m_HasEmptyBlock; + // Incrementally sorted by sumFreeSize, ascending. + VmaVector< VmaDeviceMemoryBlock*, VmaStlAllocator > m_Blocks; + uint32_t m_NextBlockId; + + VkDeviceSize CalcMaxBlockSize() const; + + // Finds and removes given block from vector. + void Remove(VmaDeviceMemoryBlock* pBlock); + + // Performs single step in sorting m_Blocks. They may not be fully sorted + // after this call. + void IncrementallySortBlocks(); + + VkResult AllocatePage( + uint32_t currentFrameIndex, + VkDeviceSize size, + VkDeviceSize alignment, + const VmaAllocationCreateInfo& createInfo, + VmaSuballocationType suballocType, + VmaAllocation* pAllocation); + + // To be used only without CAN_MAKE_OTHER_LOST flag. + VkResult AllocateFromBlock( + VmaDeviceMemoryBlock* pBlock, + uint32_t currentFrameIndex, + VkDeviceSize size, + VkDeviceSize alignment, + VmaAllocationCreateFlags allocFlags, + void* pUserData, + VmaSuballocationType suballocType, + uint32_t strategy, + VmaAllocation* pAllocation); + + VkResult CreateBlock(VkDeviceSize blockSize, size_t* pNewBlockIndex); + + // Saves result to pCtx->res. + void ApplyDefragmentationMovesCpu( + class VmaBlockVectorDefragmentationContext* pDefragCtx, + const VmaVector< VmaDefragmentationMove, VmaStlAllocator >& moves); + // Saves result to pCtx->res. + void ApplyDefragmentationMovesGpu( + class VmaBlockVectorDefragmentationContext* pDefragCtx, + VmaVector< VmaDefragmentationMove, VmaStlAllocator >& moves, + VkCommandBuffer commandBuffer); + + /* + Used during defragmentation. pDefragmentationStats is optional. It's in/out + - updated with new data. + */ + void FreeEmptyBlocks(VmaDefragmentationStats* pDefragmentationStats); + + void UpdateHasEmptyBlock(); +}; + +struct VmaPool_T +{ + VMA_CLASS_NO_COPY(VmaPool_T) +public: + VmaBlockVector m_BlockVector; + + VmaPool_T( + VmaAllocator hAllocator, + const VmaPoolCreateInfo& createInfo, + VkDeviceSize preferredBlockSize); + ~VmaPool_T(); + + uint32_t GetId() const { return m_Id; } + void SetId(uint32_t id) { VMA_ASSERT(m_Id == 0); m_Id = id; } + + const char* GetName() const { return m_Name; } + void SetName(const char* pName); + +#if VMA_STATS_STRING_ENABLED + //void PrintDetailedMap(class VmaStringBuilder& sb); +#endif + +private: + uint32_t m_Id; + char* m_Name; +}; + +/* +Performs defragmentation: + +- Updates `pBlockVector->m_pMetadata`. +- Updates allocations by calling ChangeBlockAllocation() or ChangeOffset(). +- Does not move actual data, only returns requested moves as `moves`. +*/ +class VmaDefragmentationAlgorithm +{ + VMA_CLASS_NO_COPY(VmaDefragmentationAlgorithm) +public: + VmaDefragmentationAlgorithm( + VmaAllocator hAllocator, + VmaBlockVector* pBlockVector, + uint32_t currentFrameIndex) : + m_hAllocator(hAllocator), + m_pBlockVector(pBlockVector), + m_CurrentFrameIndex(currentFrameIndex) + { + } + virtual ~VmaDefragmentationAlgorithm() + { + } + + virtual void AddAllocation(VmaAllocation hAlloc, VkBool32* pChanged) = 0; + virtual void AddAll() = 0; + + virtual VkResult Defragment( + VmaVector< VmaDefragmentationMove, VmaStlAllocator >& moves, + VkDeviceSize maxBytesToMove, + uint32_t maxAllocationsToMove, + VmaDefragmentationFlags flags) = 0; + + virtual VkDeviceSize GetBytesMoved() const = 0; + virtual uint32_t GetAllocationsMoved() const = 0; + +protected: + VmaAllocator const m_hAllocator; + VmaBlockVector* const m_pBlockVector; + const uint32_t m_CurrentFrameIndex; + + struct AllocationInfo + { + VmaAllocation m_hAllocation; + VkBool32* m_pChanged; + + AllocationInfo() : + m_hAllocation(VK_NULL_HANDLE), + m_pChanged(VMA_NULL) + { + } + AllocationInfo(VmaAllocation hAlloc, VkBool32* pChanged) : + m_hAllocation(hAlloc), + m_pChanged(pChanged) + { + } + }; +}; + +class VmaDefragmentationAlgorithm_Generic : public VmaDefragmentationAlgorithm +{ + VMA_CLASS_NO_COPY(VmaDefragmentationAlgorithm_Generic) +public: + VmaDefragmentationAlgorithm_Generic( + VmaAllocator hAllocator, + VmaBlockVector* pBlockVector, + uint32_t currentFrameIndex, + bool overlappingMoveSupported); + virtual ~VmaDefragmentationAlgorithm_Generic(); + + virtual void AddAllocation(VmaAllocation hAlloc, VkBool32* pChanged); + virtual void AddAll() { m_AllAllocations = true; } + + virtual VkResult Defragment( + VmaVector< VmaDefragmentationMove, VmaStlAllocator >& moves, + VkDeviceSize maxBytesToMove, + uint32_t maxAllocationsToMove, + VmaDefragmentationFlags flags); + + virtual VkDeviceSize GetBytesMoved() const { return m_BytesMoved; } + virtual uint32_t GetAllocationsMoved() const { return m_AllocationsMoved; } + +private: + uint32_t m_AllocationCount; + bool m_AllAllocations; + + VkDeviceSize m_BytesMoved; + uint32_t m_AllocationsMoved; + + struct AllocationInfoSizeGreater + { + bool operator()(const AllocationInfo& lhs, const AllocationInfo& rhs) const + { + return lhs.m_hAllocation->GetSize() > rhs.m_hAllocation->GetSize(); + } + }; + + struct AllocationInfoOffsetGreater + { + bool operator()(const AllocationInfo& lhs, const AllocationInfo& rhs) const + { + return lhs.m_hAllocation->GetOffset() > rhs.m_hAllocation->GetOffset(); + } + }; + + struct BlockInfo + { + size_t m_OriginalBlockIndex; + VmaDeviceMemoryBlock* m_pBlock; + bool m_HasNonMovableAllocations; + VmaVector< AllocationInfo, VmaStlAllocator > m_Allocations; + + BlockInfo(const VkAllocationCallbacks* pAllocationCallbacks) : + m_OriginalBlockIndex(SIZE_MAX), + m_pBlock(VMA_NULL), + m_HasNonMovableAllocations(true), + m_Allocations(pAllocationCallbacks) + { + } + + void CalcHasNonMovableAllocations() + { + const size_t blockAllocCount = m_pBlock->m_pMetadata->GetAllocationCount(); + const size_t defragmentAllocCount = m_Allocations.size(); + m_HasNonMovableAllocations = blockAllocCount != defragmentAllocCount; + } + + void SortAllocationsBySizeDescending() + { + VMA_SORT(m_Allocations.begin(), m_Allocations.end(), AllocationInfoSizeGreater()); + } + + void SortAllocationsByOffsetDescending() + { + VMA_SORT(m_Allocations.begin(), m_Allocations.end(), AllocationInfoOffsetGreater()); + } + }; + + struct BlockPointerLess + { + bool operator()(const BlockInfo* pLhsBlockInfo, const VmaDeviceMemoryBlock* pRhsBlock) const + { + return pLhsBlockInfo->m_pBlock < pRhsBlock; + } + bool operator()(const BlockInfo* pLhsBlockInfo, const BlockInfo* pRhsBlockInfo) const + { + return pLhsBlockInfo->m_pBlock < pRhsBlockInfo->m_pBlock; + } + }; + + // 1. Blocks with some non-movable allocations go first. + // 2. Blocks with smaller sumFreeSize go first. + struct BlockInfoCompareMoveDestination + { + bool operator()(const BlockInfo* pLhsBlockInfo, const BlockInfo* pRhsBlockInfo) const + { + if(pLhsBlockInfo->m_HasNonMovableAllocations && !pRhsBlockInfo->m_HasNonMovableAllocations) + { + return true; + } + if(!pLhsBlockInfo->m_HasNonMovableAllocations && pRhsBlockInfo->m_HasNonMovableAllocations) + { + return false; + } + if(pLhsBlockInfo->m_pBlock->m_pMetadata->GetSumFreeSize() < pRhsBlockInfo->m_pBlock->m_pMetadata->GetSumFreeSize()) + { + return true; + } + return false; + } + }; + + typedef VmaVector< BlockInfo*, VmaStlAllocator > BlockInfoVector; + BlockInfoVector m_Blocks; + + VkResult DefragmentRound( + VmaVector< VmaDefragmentationMove, VmaStlAllocator >& moves, + VkDeviceSize maxBytesToMove, + uint32_t maxAllocationsToMove, + bool freeOldAllocations); + + size_t CalcBlocksWithNonMovableCount() const; + + static bool MoveMakesSense( + size_t dstBlockIndex, VkDeviceSize dstOffset, + size_t srcBlockIndex, VkDeviceSize srcOffset); +}; + +class VmaDefragmentationAlgorithm_Fast : public VmaDefragmentationAlgorithm +{ + VMA_CLASS_NO_COPY(VmaDefragmentationAlgorithm_Fast) +public: + VmaDefragmentationAlgorithm_Fast( + VmaAllocator hAllocator, + VmaBlockVector* pBlockVector, + uint32_t currentFrameIndex, + bool overlappingMoveSupported); + virtual ~VmaDefragmentationAlgorithm_Fast(); + + virtual void AddAllocation(VmaAllocation hAlloc, VkBool32* pChanged) { ++m_AllocationCount; } + virtual void AddAll() { m_AllAllocations = true; } + + virtual VkResult Defragment( + VmaVector< VmaDefragmentationMove, VmaStlAllocator >& moves, + VkDeviceSize maxBytesToMove, + uint32_t maxAllocationsToMove, + VmaDefragmentationFlags flags); + + virtual VkDeviceSize GetBytesMoved() const { return m_BytesMoved; } + virtual uint32_t GetAllocationsMoved() const { return m_AllocationsMoved; } + +private: + struct BlockInfo + { + size_t origBlockIndex; + }; + + class FreeSpaceDatabase + { + public: + FreeSpaceDatabase() + { + FreeSpace s = {}; + s.blockInfoIndex = SIZE_MAX; + for(size_t i = 0; i < MAX_COUNT; ++i) + { + m_FreeSpaces[i] = s; + } + } + + void Register(size_t blockInfoIndex, VkDeviceSize offset, VkDeviceSize size) + { + if(size < VMA_MIN_FREE_SUBALLOCATION_SIZE_TO_REGISTER) + { + return; + } + + // Find first invalid or the smallest structure. + size_t bestIndex = SIZE_MAX; + for(size_t i = 0; i < MAX_COUNT; ++i) + { + // Empty structure. + if(m_FreeSpaces[i].blockInfoIndex == SIZE_MAX) + { + bestIndex = i; + break; + } + if(m_FreeSpaces[i].size < size && + (bestIndex == SIZE_MAX || m_FreeSpaces[bestIndex].size > m_FreeSpaces[i].size)) + { + bestIndex = i; + } + } + + if(bestIndex != SIZE_MAX) + { + m_FreeSpaces[bestIndex].blockInfoIndex = blockInfoIndex; + m_FreeSpaces[bestIndex].offset = offset; + m_FreeSpaces[bestIndex].size = size; + } + } + + bool Fetch(VkDeviceSize alignment, VkDeviceSize size, + size_t& outBlockInfoIndex, VkDeviceSize& outDstOffset) + { + size_t bestIndex = SIZE_MAX; + VkDeviceSize bestFreeSpaceAfter = 0; + for(size_t i = 0; i < MAX_COUNT; ++i) + { + // Structure is valid. + if(m_FreeSpaces[i].blockInfoIndex != SIZE_MAX) + { + const VkDeviceSize dstOffset = VmaAlignUp(m_FreeSpaces[i].offset, alignment); + // Allocation fits into this structure. + if(dstOffset + size <= m_FreeSpaces[i].offset + m_FreeSpaces[i].size) + { + const VkDeviceSize freeSpaceAfter = (m_FreeSpaces[i].offset + m_FreeSpaces[i].size) - + (dstOffset + size); + if(bestIndex == SIZE_MAX || freeSpaceAfter > bestFreeSpaceAfter) + { + bestIndex = i; + bestFreeSpaceAfter = freeSpaceAfter; + } + } + } + } + + if(bestIndex != SIZE_MAX) + { + outBlockInfoIndex = m_FreeSpaces[bestIndex].blockInfoIndex; + outDstOffset = VmaAlignUp(m_FreeSpaces[bestIndex].offset, alignment); + + if(bestFreeSpaceAfter >= VMA_MIN_FREE_SUBALLOCATION_SIZE_TO_REGISTER) + { + // Leave this structure for remaining empty space. + const VkDeviceSize alignmentPlusSize = (outDstOffset - m_FreeSpaces[bestIndex].offset) + size; + m_FreeSpaces[bestIndex].offset += alignmentPlusSize; + m_FreeSpaces[bestIndex].size -= alignmentPlusSize; + } + else + { + // This structure becomes invalid. + m_FreeSpaces[bestIndex].blockInfoIndex = SIZE_MAX; + } + + return true; + } + + return false; + } + + private: + static const size_t MAX_COUNT = 4; + + struct FreeSpace + { + size_t blockInfoIndex; // SIZE_MAX means this structure is invalid. + VkDeviceSize offset; + VkDeviceSize size; + } m_FreeSpaces[MAX_COUNT]; + }; + + const bool m_OverlappingMoveSupported; + + uint32_t m_AllocationCount; + bool m_AllAllocations; + + VkDeviceSize m_BytesMoved; + uint32_t m_AllocationsMoved; + + VmaVector< BlockInfo, VmaStlAllocator > m_BlockInfos; + + void PreprocessMetadata(); + void PostprocessMetadata(); + void InsertSuballoc(VmaBlockMetadata_Generic* pMetadata, const VmaSuballocation& suballoc); +}; + +struct VmaBlockDefragmentationContext +{ + enum BLOCK_FLAG + { + BLOCK_FLAG_USED = 0x00000001, + }; + uint32_t flags; + VkBuffer hBuffer; +}; + +class VmaBlockVectorDefragmentationContext +{ + VMA_CLASS_NO_COPY(VmaBlockVectorDefragmentationContext) +public: + VkResult res; + bool mutexLocked; + VmaVector< VmaBlockDefragmentationContext, VmaStlAllocator > blockContexts; + VmaVector< VmaDefragmentationMove, VmaStlAllocator > defragmentationMoves; + uint32_t defragmentationMovesProcessed; + uint32_t defragmentationMovesCommitted; + bool hasDefragmentationPlan; + + VmaBlockVectorDefragmentationContext( + VmaAllocator hAllocator, + VmaPool hCustomPool, // Optional. + VmaBlockVector* pBlockVector, + uint32_t currFrameIndex); + ~VmaBlockVectorDefragmentationContext(); + + VmaPool GetCustomPool() const { return m_hCustomPool; } + VmaBlockVector* GetBlockVector() const { return m_pBlockVector; } + VmaDefragmentationAlgorithm* GetAlgorithm() const { return m_pAlgorithm; } + + void AddAllocation(VmaAllocation hAlloc, VkBool32* pChanged); + void AddAll() { m_AllAllocations = true; } + + void Begin(bool overlappingMoveSupported, VmaDefragmentationFlags flags); + +private: + const VmaAllocator m_hAllocator; + // Null if not from custom pool. + const VmaPool m_hCustomPool; + // Redundant, for convenience not to fetch from m_hCustomPool->m_BlockVector or m_hAllocator->m_pBlockVectors. + VmaBlockVector* const m_pBlockVector; + const uint32_t m_CurrFrameIndex; + // Owner of this object. + VmaDefragmentationAlgorithm* m_pAlgorithm; + + struct AllocInfo + { + VmaAllocation hAlloc; + VkBool32* pChanged; + }; + // Used between constructor and Begin. + VmaVector< AllocInfo, VmaStlAllocator > m_Allocations; + bool m_AllAllocations; +}; + +struct VmaDefragmentationContext_T +{ +private: + VMA_CLASS_NO_COPY(VmaDefragmentationContext_T) +public: + VmaDefragmentationContext_T( + VmaAllocator hAllocator, + uint32_t currFrameIndex, + uint32_t flags, + VmaDefragmentationStats* pStats); + ~VmaDefragmentationContext_T(); + + void AddPools(uint32_t poolCount, VmaPool* pPools); + void AddAllocations( + uint32_t allocationCount, + VmaAllocation* pAllocations, + VkBool32* pAllocationsChanged); + + /* + Returns: + - `VK_SUCCESS` if succeeded and object can be destroyed immediately. + - `VK_NOT_READY` if succeeded but the object must remain alive until vmaDefragmentationEnd(). + - Negative value if error occured and object can be destroyed immediately. + */ + VkResult Defragment( + VkDeviceSize maxCpuBytesToMove, uint32_t maxCpuAllocationsToMove, + VkDeviceSize maxGpuBytesToMove, uint32_t maxGpuAllocationsToMove, + VkCommandBuffer commandBuffer, VmaDefragmentationStats* pStats, VmaDefragmentationFlags flags); + + VkResult DefragmentPassBegin(VmaDefragmentationPassInfo* pInfo); + VkResult DefragmentPassEnd(); + +private: + const VmaAllocator m_hAllocator; + const uint32_t m_CurrFrameIndex; + const uint32_t m_Flags; + VmaDefragmentationStats* const m_pStats; + + VkDeviceSize m_MaxCpuBytesToMove; + uint32_t m_MaxCpuAllocationsToMove; + VkDeviceSize m_MaxGpuBytesToMove; + uint32_t m_MaxGpuAllocationsToMove; + + // Owner of these objects. + VmaBlockVectorDefragmentationContext* m_DefaultPoolContexts[VK_MAX_MEMORY_TYPES]; + // Owner of these objects. + VmaVector< VmaBlockVectorDefragmentationContext*, VmaStlAllocator > m_CustomPoolContexts; +}; + +#if VMA_RECORDING_ENABLED + +class VmaRecorder +{ +public: + VmaRecorder(); + VkResult Init(const VmaRecordSettings& settings, bool useMutex); + void WriteConfiguration( + const VkPhysicalDeviceProperties& devProps, + const VkPhysicalDeviceMemoryProperties& memProps, + uint32_t vulkanApiVersion, + bool dedicatedAllocationExtensionEnabled, + bool bindMemory2ExtensionEnabled, + bool memoryBudgetExtensionEnabled, + bool deviceCoherentMemoryExtensionEnabled); + ~VmaRecorder(); + + void RecordCreateAllocator(uint32_t frameIndex); + void RecordDestroyAllocator(uint32_t frameIndex); + void RecordCreatePool(uint32_t frameIndex, + const VmaPoolCreateInfo& createInfo, + VmaPool pool); + void RecordDestroyPool(uint32_t frameIndex, VmaPool pool); + void RecordAllocateMemory(uint32_t frameIndex, + const VkMemoryRequirements& vkMemReq, + const VmaAllocationCreateInfo& createInfo, + VmaAllocation allocation); + void RecordAllocateMemoryPages(uint32_t frameIndex, + const VkMemoryRequirements& vkMemReq, + const VmaAllocationCreateInfo& createInfo, + uint64_t allocationCount, + const VmaAllocation* pAllocations); + void RecordAllocateMemoryForBuffer(uint32_t frameIndex, + const VkMemoryRequirements& vkMemReq, + bool requiresDedicatedAllocation, + bool prefersDedicatedAllocation, + const VmaAllocationCreateInfo& createInfo, + VmaAllocation allocation); + void RecordAllocateMemoryForImage(uint32_t frameIndex, + const VkMemoryRequirements& vkMemReq, + bool requiresDedicatedAllocation, + bool prefersDedicatedAllocation, + const VmaAllocationCreateInfo& createInfo, + VmaAllocation allocation); + void RecordFreeMemory(uint32_t frameIndex, + VmaAllocation allocation); + void RecordFreeMemoryPages(uint32_t frameIndex, + uint64_t allocationCount, + const VmaAllocation* pAllocations); + void RecordSetAllocationUserData(uint32_t frameIndex, + VmaAllocation allocation, + const void* pUserData); + void RecordCreateLostAllocation(uint32_t frameIndex, + VmaAllocation allocation); + void RecordMapMemory(uint32_t frameIndex, + VmaAllocation allocation); + void RecordUnmapMemory(uint32_t frameIndex, + VmaAllocation allocation); + void RecordFlushAllocation(uint32_t frameIndex, + VmaAllocation allocation, VkDeviceSize offset, VkDeviceSize size); + void RecordInvalidateAllocation(uint32_t frameIndex, + VmaAllocation allocation, VkDeviceSize offset, VkDeviceSize size); + void RecordCreateBuffer(uint32_t frameIndex, + const VkBufferCreateInfo& bufCreateInfo, + const VmaAllocationCreateInfo& allocCreateInfo, + VmaAllocation allocation); + void RecordCreateImage(uint32_t frameIndex, + const VkImageCreateInfo& imageCreateInfo, + const VmaAllocationCreateInfo& allocCreateInfo, + VmaAllocation allocation); + void RecordDestroyBuffer(uint32_t frameIndex, + VmaAllocation allocation); + void RecordDestroyImage(uint32_t frameIndex, + VmaAllocation allocation); + void RecordTouchAllocation(uint32_t frameIndex, + VmaAllocation allocation); + void RecordGetAllocationInfo(uint32_t frameIndex, + VmaAllocation allocation); + void RecordMakePoolAllocationsLost(uint32_t frameIndex, + VmaPool pool); + void RecordDefragmentationBegin(uint32_t frameIndex, + const VmaDefragmentationInfo2& info, + VmaDefragmentationContext ctx); + void RecordDefragmentationEnd(uint32_t frameIndex, + VmaDefragmentationContext ctx); + void RecordSetPoolName(uint32_t frameIndex, + VmaPool pool, + const char* name); + +private: + struct CallParams + { + uint32_t threadId; + double time; + }; + + class UserDataString + { + public: + UserDataString(VmaAllocationCreateFlags allocFlags, const void* pUserData); + const char* GetString() const { return m_Str; } + + private: + char m_PtrStr[17]; + const char* m_Str; + }; + + bool m_UseMutex; + VmaRecordFlags m_Flags; + FILE* m_File; + VMA_MUTEX m_FileMutex; + int64_t m_Freq; + int64_t m_StartCounter; + + void GetBasicParams(CallParams& outParams); + + // T must be a pointer type, e.g. VmaAllocation, VmaPool. + template + void PrintPointerList(uint64_t count, const T* pItems) + { + if(count) + { + fprintf(m_File, "%p", pItems[0]); + for(uint64_t i = 1; i < count; ++i) + { + fprintf(m_File, " %p", pItems[i]); + } + } + } + + void PrintPointerList(uint64_t count, const VmaAllocation* pItems); + void Flush(); +}; + +#endif // #if VMA_RECORDING_ENABLED + +/* +Thread-safe wrapper over VmaPoolAllocator free list, for allocation of VmaAllocation_T objects. +*/ +class VmaAllocationObjectAllocator +{ + VMA_CLASS_NO_COPY(VmaAllocationObjectAllocator) +public: + VmaAllocationObjectAllocator(const VkAllocationCallbacks* pAllocationCallbacks); + + template VmaAllocation Allocate(Types... args); + void Free(VmaAllocation hAlloc); + +private: + VMA_MUTEX m_Mutex; + VmaPoolAllocator m_Allocator; +}; + +struct VmaCurrentBudgetData +{ + VMA_ATOMIC_UINT64 m_BlockBytes[VK_MAX_MEMORY_HEAPS]; + VMA_ATOMIC_UINT64 m_AllocationBytes[VK_MAX_MEMORY_HEAPS]; + +#if VMA_MEMORY_BUDGET + VMA_ATOMIC_UINT32 m_OperationsSinceBudgetFetch; + VMA_RW_MUTEX m_BudgetMutex; + uint64_t m_VulkanUsage[VK_MAX_MEMORY_HEAPS]; + uint64_t m_VulkanBudget[VK_MAX_MEMORY_HEAPS]; + uint64_t m_BlockBytesAtBudgetFetch[VK_MAX_MEMORY_HEAPS]; +#endif // #if VMA_MEMORY_BUDGET + + VmaCurrentBudgetData() + { + for(uint32_t heapIndex = 0; heapIndex < VK_MAX_MEMORY_HEAPS; ++heapIndex) + { + m_BlockBytes[heapIndex] = 0; + m_AllocationBytes[heapIndex] = 0; +#if VMA_MEMORY_BUDGET + m_VulkanUsage[heapIndex] = 0; + m_VulkanBudget[heapIndex] = 0; + m_BlockBytesAtBudgetFetch[heapIndex] = 0; +#endif + } + +#if VMA_MEMORY_BUDGET + m_OperationsSinceBudgetFetch = 0; +#endif + } + + void AddAllocation(uint32_t heapIndex, VkDeviceSize allocationSize) + { + m_AllocationBytes[heapIndex] += allocationSize; +#if VMA_MEMORY_BUDGET + ++m_OperationsSinceBudgetFetch; +#endif + } + + void RemoveAllocation(uint32_t heapIndex, VkDeviceSize allocationSize) + { + VMA_ASSERT(m_AllocationBytes[heapIndex] >= allocationSize); // DELME + m_AllocationBytes[heapIndex] -= allocationSize; +#if VMA_MEMORY_BUDGET + ++m_OperationsSinceBudgetFetch; +#endif + } +}; + +// Main allocator object. +struct VmaAllocator_T +{ + VMA_CLASS_NO_COPY(VmaAllocator_T) +public: + bool m_UseMutex; + uint32_t m_VulkanApiVersion; + bool m_UseKhrDedicatedAllocation; // Can be set only if m_VulkanApiVersion < VK_MAKE_VERSION(1, 1, 0). + bool m_UseKhrBindMemory2; // Can be set only if m_VulkanApiVersion < VK_MAKE_VERSION(1, 1, 0). + bool m_UseExtMemoryBudget; + bool m_UseAmdDeviceCoherentMemory; + VkDevice m_hDevice; + VkInstance m_hInstance; + bool m_AllocationCallbacksSpecified; + VkAllocationCallbacks m_AllocationCallbacks; + VmaDeviceMemoryCallbacks m_DeviceMemoryCallbacks; + VmaAllocationObjectAllocator m_AllocationObjectAllocator; + + // Each bit (1 << i) is set if HeapSizeLimit is enabled for that heap, so cannot allocate more than the heap size. + uint32_t m_HeapSizeLimitMask; + + VkPhysicalDeviceProperties m_PhysicalDeviceProperties; + VkPhysicalDeviceMemoryProperties m_MemProps; + + // Default pools. + VmaBlockVector* m_pBlockVectors[VK_MAX_MEMORY_TYPES]; + + // Each vector is sorted by memory (handle value). + typedef VmaVector< VmaAllocation, VmaStlAllocator > AllocationVectorType; + AllocationVectorType* m_pDedicatedAllocations[VK_MAX_MEMORY_TYPES]; + VMA_RW_MUTEX m_DedicatedAllocationsMutex[VK_MAX_MEMORY_TYPES]; + + VmaCurrentBudgetData m_Budget; + + VmaAllocator_T(const VmaAllocatorCreateInfo* pCreateInfo); + VkResult Init(const VmaAllocatorCreateInfo* pCreateInfo); + ~VmaAllocator_T(); + + const VkAllocationCallbacks* GetAllocationCallbacks() const + { + return m_AllocationCallbacksSpecified ? &m_AllocationCallbacks : 0; + } + const VmaVulkanFunctions& GetVulkanFunctions() const + { + return m_VulkanFunctions; + } + + VkPhysicalDevice GetPhysicalDevice() const { return m_PhysicalDevice; } + + VkDeviceSize GetBufferImageGranularity() const + { + return VMA_MAX( + static_cast(VMA_DEBUG_MIN_BUFFER_IMAGE_GRANULARITY), + m_PhysicalDeviceProperties.limits.bufferImageGranularity); + } + + uint32_t GetMemoryHeapCount() const { return m_MemProps.memoryHeapCount; } + uint32_t GetMemoryTypeCount() const { return m_MemProps.memoryTypeCount; } + + uint32_t MemoryTypeIndexToHeapIndex(uint32_t memTypeIndex) const + { + VMA_ASSERT(memTypeIndex < m_MemProps.memoryTypeCount); + return m_MemProps.memoryTypes[memTypeIndex].heapIndex; + } + // True when specific memory type is HOST_VISIBLE but not HOST_COHERENT. + bool IsMemoryTypeNonCoherent(uint32_t memTypeIndex) const + { + return (m_MemProps.memoryTypes[memTypeIndex].propertyFlags & (VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) == + VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; + } + // Minimum alignment for all allocations in specific memory type. + VkDeviceSize GetMemoryTypeMinAlignment(uint32_t memTypeIndex) const + { + return IsMemoryTypeNonCoherent(memTypeIndex) ? + VMA_MAX((VkDeviceSize)VMA_DEBUG_ALIGNMENT, m_PhysicalDeviceProperties.limits.nonCoherentAtomSize) : + (VkDeviceSize)VMA_DEBUG_ALIGNMENT; + } + + bool IsIntegratedGpu() const + { + return m_PhysicalDeviceProperties.deviceType == VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU; + } + + uint32_t GetGlobalMemoryTypeBits() const { return m_GlobalMemoryTypeBits; } + +#if VMA_RECORDING_ENABLED + VmaRecorder* GetRecorder() const { return m_pRecorder; } +#endif + + void GetBufferMemoryRequirements( + VkBuffer hBuffer, + VkMemoryRequirements& memReq, + bool& requiresDedicatedAllocation, + bool& prefersDedicatedAllocation) const; + void GetImageMemoryRequirements( + VkImage hImage, + VkMemoryRequirements& memReq, + bool& requiresDedicatedAllocation, + bool& prefersDedicatedAllocation) const; + + // Main allocation function. + VkResult AllocateMemory( + const VkMemoryRequirements& vkMemReq, + bool requiresDedicatedAllocation, + bool prefersDedicatedAllocation, + VkBuffer dedicatedBuffer, + VkImage dedicatedImage, + const VmaAllocationCreateInfo& createInfo, + VmaSuballocationType suballocType, + size_t allocationCount, + VmaAllocation* pAllocations); + + // Main deallocation function. + void FreeMemory( + size_t allocationCount, + const VmaAllocation* pAllocations); + + VkResult ResizeAllocation( + const VmaAllocation alloc, + VkDeviceSize newSize); + + void CalculateStats(VmaStats* pStats); + + void GetBudget( + VmaBudget* outBudget, uint32_t firstHeap, uint32_t heapCount); + +#if VMA_STATS_STRING_ENABLED + void PrintDetailedMap(class VmaJsonWriter& json); +#endif + + VkResult DefragmentationBegin( + const VmaDefragmentationInfo2& info, + VmaDefragmentationStats* pStats, + VmaDefragmentationContext* pContext); + VkResult DefragmentationEnd( + VmaDefragmentationContext context); + + VkResult DefragmentationPassBegin( + VmaDefragmentationPassInfo* pInfo, + VmaDefragmentationContext context); + VkResult DefragmentationPassEnd( + VmaDefragmentationContext context); + + void GetAllocationInfo(VmaAllocation hAllocation, VmaAllocationInfo* pAllocationInfo); + bool TouchAllocation(VmaAllocation hAllocation); + + VkResult CreatePool(const VmaPoolCreateInfo* pCreateInfo, VmaPool* pPool); + void DestroyPool(VmaPool pool); + void GetPoolStats(VmaPool pool, VmaPoolStats* pPoolStats); + + void SetCurrentFrameIndex(uint32_t frameIndex); + uint32_t GetCurrentFrameIndex() const { return m_CurrentFrameIndex.load(); } + + void MakePoolAllocationsLost( + VmaPool hPool, + size_t* pLostAllocationCount); + VkResult CheckPoolCorruption(VmaPool hPool); + VkResult CheckCorruption(uint32_t memoryTypeBits); + + void CreateLostAllocation(VmaAllocation* pAllocation); + + // Call to Vulkan function vkAllocateMemory with accompanying bookkeeping. + VkResult AllocateVulkanMemory(const VkMemoryAllocateInfo* pAllocateInfo, VkDeviceMemory* pMemory); + // Call to Vulkan function vkFreeMemory with accompanying bookkeeping. + void FreeVulkanMemory(uint32_t memoryType, VkDeviceSize size, VkDeviceMemory hMemory); + // Call to Vulkan function vkBindBufferMemory or vkBindBufferMemory2KHR. + VkResult BindVulkanBuffer( + VkDeviceMemory memory, + VkDeviceSize memoryOffset, + VkBuffer buffer, + const void* pNext); + // Call to Vulkan function vkBindImageMemory or vkBindImageMemory2KHR. + VkResult BindVulkanImage( + VkDeviceMemory memory, + VkDeviceSize memoryOffset, + VkImage image, + const void* pNext); + + VkResult Map(VmaAllocation hAllocation, void** ppData); + void Unmap(VmaAllocation hAllocation); + + VkResult BindBufferMemory( + VmaAllocation hAllocation, + VkDeviceSize allocationLocalOffset, + VkBuffer hBuffer, + const void* pNext); + VkResult BindImageMemory( + VmaAllocation hAllocation, + VkDeviceSize allocationLocalOffset, + VkImage hImage, + const void* pNext); + + void FlushOrInvalidateAllocation( + VmaAllocation hAllocation, + VkDeviceSize offset, VkDeviceSize size, + VMA_CACHE_OPERATION op); + + void FillAllocation(const VmaAllocation hAllocation, uint8_t pattern); + + /* + Returns bit mask of memory types that can support defragmentation on GPU as + they support creation of required buffer for copy operations. + */ + uint32_t GetGpuDefragmentationMemoryTypeBits(); + +private: + VkDeviceSize m_PreferredLargeHeapBlockSize; + + VkPhysicalDevice m_PhysicalDevice; + VMA_ATOMIC_UINT32 m_CurrentFrameIndex; + VMA_ATOMIC_UINT32 m_GpuDefragmentationMemoryTypeBits; // UINT32_MAX means uninitialized. + + VMA_RW_MUTEX m_PoolsMutex; + // Protected by m_PoolsMutex. Sorted by pointer value. + VmaVector > m_Pools; + uint32_t m_NextPoolId; + + VmaVulkanFunctions m_VulkanFunctions; + + // Global bit mask AND-ed with any memoryTypeBits to disallow certain memory types. + uint32_t m_GlobalMemoryTypeBits; + +#if VMA_RECORDING_ENABLED + VmaRecorder* m_pRecorder; +#endif + + void ImportVulkanFunctions(const VmaVulkanFunctions* pVulkanFunctions); + + VkDeviceSize CalcPreferredBlockSize(uint32_t memTypeIndex); + + VkResult AllocateMemoryOfType( + VkDeviceSize size, + VkDeviceSize alignment, + bool dedicatedAllocation, + VkBuffer dedicatedBuffer, + VkImage dedicatedImage, + const VmaAllocationCreateInfo& createInfo, + uint32_t memTypeIndex, + VmaSuballocationType suballocType, + size_t allocationCount, + VmaAllocation* pAllocations); + + // Helper function only to be used inside AllocateDedicatedMemory. + VkResult AllocateDedicatedMemoryPage( + VkDeviceSize size, + VmaSuballocationType suballocType, + uint32_t memTypeIndex, + const VkMemoryAllocateInfo& allocInfo, + bool map, + bool isUserDataString, + void* pUserData, + VmaAllocation* pAllocation); + + // Allocates and registers new VkDeviceMemory specifically for dedicated allocations. + VkResult AllocateDedicatedMemory( + VkDeviceSize size, + VmaSuballocationType suballocType, + uint32_t memTypeIndex, + bool withinBudget, + bool map, + bool isUserDataString, + void* pUserData, + VkBuffer dedicatedBuffer, + VkImage dedicatedImage, + size_t allocationCount, + VmaAllocation* pAllocations); + + void FreeDedicatedMemory(const VmaAllocation allocation); + + /* + Calculates and returns bit mask of memory types that can support defragmentation + on GPU as they support creation of required buffer for copy operations. + */ + uint32_t CalculateGpuDefragmentationMemoryTypeBits() const; + + uint32_t CalculateGlobalMemoryTypeBits() const; + +#if VMA_MEMORY_BUDGET + void UpdateVulkanBudget(); +#endif // #if VMA_MEMORY_BUDGET +}; + +//////////////////////////////////////////////////////////////////////////////// +// Memory allocation #2 after VmaAllocator_T definition + +static void* VmaMalloc(VmaAllocator hAllocator, size_t size, size_t alignment) +{ + return VmaMalloc(&hAllocator->m_AllocationCallbacks, size, alignment); +} + +static void VmaFree(VmaAllocator hAllocator, void* ptr) +{ + VmaFree(&hAllocator->m_AllocationCallbacks, ptr); +} + +template +static T* VmaAllocate(VmaAllocator hAllocator) +{ + return (T*)VmaMalloc(hAllocator, sizeof(T), VMA_ALIGN_OF(T)); +} + +template +static T* VmaAllocateArray(VmaAllocator hAllocator, size_t count) +{ + return (T*)VmaMalloc(hAllocator, sizeof(T) * count, VMA_ALIGN_OF(T)); +} + +template +static void vma_delete(VmaAllocator hAllocator, T* ptr) +{ + if(ptr != VMA_NULL) + { + ptr->~T(); + VmaFree(hAllocator, ptr); + } +} + +template +static void vma_delete_array(VmaAllocator hAllocator, T* ptr, size_t count) +{ + if(ptr != VMA_NULL) + { + for(size_t i = count; i--; ) + ptr[i].~T(); + VmaFree(hAllocator, ptr); + } +} + +//////////////////////////////////////////////////////////////////////////////// +// VmaStringBuilder + +#if VMA_STATS_STRING_ENABLED + +class VmaStringBuilder +{ +public: + VmaStringBuilder(VmaAllocator alloc) : m_Data(VmaStlAllocator(alloc->GetAllocationCallbacks())) { } + size_t GetLength() const { return m_Data.size(); } + const char* GetData() const { return m_Data.data(); } + + void Add(char ch) { m_Data.push_back(ch); } + void Add(const char* pStr); + void AddNewLine() { Add('\n'); } + void AddNumber(uint32_t num); + void AddNumber(uint64_t num); + void AddPointer(const void* ptr); + +private: + VmaVector< char, VmaStlAllocator > m_Data; +}; + +void VmaStringBuilder::Add(const char* pStr) +{ + const size_t strLen = strlen(pStr); + if(strLen > 0) + { + const size_t oldCount = m_Data.size(); + m_Data.resize(oldCount + strLen); + memcpy(m_Data.data() + oldCount, pStr, strLen); + } +} + +void VmaStringBuilder::AddNumber(uint32_t num) +{ + char buf[11]; + buf[10] = '\0'; + char *p = &buf[10]; + do + { + *--p = '0' + (num % 10); + num /= 10; + } + while(num); + Add(p); +} + +void VmaStringBuilder::AddNumber(uint64_t num) +{ + char buf[21]; + buf[20] = '\0'; + char *p = &buf[20]; + do + { + *--p = '0' + (num % 10); + num /= 10; + } + while(num); + Add(p); +} + +void VmaStringBuilder::AddPointer(const void* ptr) +{ + char buf[21]; + VmaPtrToStr(buf, sizeof(buf), ptr); + Add(buf); +} + +#endif // #if VMA_STATS_STRING_ENABLED + +//////////////////////////////////////////////////////////////////////////////// +// VmaJsonWriter + +#if VMA_STATS_STRING_ENABLED + +class VmaJsonWriter +{ + VMA_CLASS_NO_COPY(VmaJsonWriter) +public: + VmaJsonWriter(const VkAllocationCallbacks* pAllocationCallbacks, VmaStringBuilder& sb); + ~VmaJsonWriter(); + + void BeginObject(bool singleLine = false); + void EndObject(); + + void BeginArray(bool singleLine = false); + void EndArray(); + + void WriteString(const char* pStr); + void BeginString(const char* pStr = VMA_NULL); + void ContinueString(const char* pStr); + void ContinueString(uint32_t n); + void ContinueString(uint64_t n); + void ContinueString_Pointer(const void* ptr); + void EndString(const char* pStr = VMA_NULL); + + void WriteNumber(uint32_t n); + void WriteNumber(uint64_t n); + void WriteBool(bool b); + void WriteNull(); + +private: + static const char* const INDENT; + + enum COLLECTION_TYPE + { + COLLECTION_TYPE_OBJECT, + COLLECTION_TYPE_ARRAY, + }; + struct StackItem + { + COLLECTION_TYPE type; + uint32_t valueCount; + bool singleLineMode; + }; + + VmaStringBuilder& m_SB; + VmaVector< StackItem, VmaStlAllocator > m_Stack; + bool m_InsideString; + + void BeginValue(bool isString); + void WriteIndent(bool oneLess = false); +}; + +const char* const VmaJsonWriter::INDENT = " "; + +VmaJsonWriter::VmaJsonWriter(const VkAllocationCallbacks* pAllocationCallbacks, VmaStringBuilder& sb) : + m_SB(sb), + m_Stack(VmaStlAllocator(pAllocationCallbacks)), + m_InsideString(false) +{ +} + +VmaJsonWriter::~VmaJsonWriter() +{ + VMA_ASSERT(!m_InsideString); + VMA_ASSERT(m_Stack.empty()); +} + +void VmaJsonWriter::BeginObject(bool singleLine) +{ + VMA_ASSERT(!m_InsideString); + + BeginValue(false); + m_SB.Add('{'); + + StackItem item; + item.type = COLLECTION_TYPE_OBJECT; + item.valueCount = 0; + item.singleLineMode = singleLine; + m_Stack.push_back(item); +} + +void VmaJsonWriter::EndObject() +{ + VMA_ASSERT(!m_InsideString); + + WriteIndent(true); + m_SB.Add('}'); + + VMA_ASSERT(!m_Stack.empty() && m_Stack.back().type == COLLECTION_TYPE_OBJECT); + m_Stack.pop_back(); +} + +void VmaJsonWriter::BeginArray(bool singleLine) +{ + VMA_ASSERT(!m_InsideString); + + BeginValue(false); + m_SB.Add('['); + + StackItem item; + item.type = COLLECTION_TYPE_ARRAY; + item.valueCount = 0; + item.singleLineMode = singleLine; + m_Stack.push_back(item); +} + +void VmaJsonWriter::EndArray() +{ + VMA_ASSERT(!m_InsideString); + + WriteIndent(true); + m_SB.Add(']'); + + VMA_ASSERT(!m_Stack.empty() && m_Stack.back().type == COLLECTION_TYPE_ARRAY); + m_Stack.pop_back(); +} + +void VmaJsonWriter::WriteString(const char* pStr) +{ + BeginString(pStr); + EndString(); +} + +void VmaJsonWriter::BeginString(const char* pStr) +{ + VMA_ASSERT(!m_InsideString); + + BeginValue(true); + m_SB.Add('"'); + m_InsideString = true; + if(pStr != VMA_NULL && pStr[0] != '\0') + { + ContinueString(pStr); + } +} + +void VmaJsonWriter::ContinueString(const char* pStr) +{ + VMA_ASSERT(m_InsideString); + + const size_t strLen = strlen(pStr); + for(size_t i = 0; i < strLen; ++i) + { + char ch = pStr[i]; + if(ch == '\\') + { + m_SB.Add("\\\\"); + } + else if(ch == '"') + { + m_SB.Add("\\\""); + } + else if(ch >= 32) + { + m_SB.Add(ch); + } + else switch(ch) + { + case '\b': + m_SB.Add("\\b"); + break; + case '\f': + m_SB.Add("\\f"); + break; + case '\n': + m_SB.Add("\\n"); + break; + case '\r': + m_SB.Add("\\r"); + break; + case '\t': + m_SB.Add("\\t"); + break; + default: + VMA_ASSERT(0 && "Character not currently supported."); + break; + } + } +} + +void VmaJsonWriter::ContinueString(uint32_t n) +{ + VMA_ASSERT(m_InsideString); + m_SB.AddNumber(n); +} + +void VmaJsonWriter::ContinueString(uint64_t n) +{ + VMA_ASSERT(m_InsideString); + m_SB.AddNumber(n); +} + +void VmaJsonWriter::ContinueString_Pointer(const void* ptr) +{ + VMA_ASSERT(m_InsideString); + m_SB.AddPointer(ptr); +} + +void VmaJsonWriter::EndString(const char* pStr) +{ + VMA_ASSERT(m_InsideString); + if(pStr != VMA_NULL && pStr[0] != '\0') + { + ContinueString(pStr); + } + m_SB.Add('"'); + m_InsideString = false; +} + +void VmaJsonWriter::WriteNumber(uint32_t n) +{ + VMA_ASSERT(!m_InsideString); + BeginValue(false); + m_SB.AddNumber(n); +} + +void VmaJsonWriter::WriteNumber(uint64_t n) +{ + VMA_ASSERT(!m_InsideString); + BeginValue(false); + m_SB.AddNumber(n); +} + +void VmaJsonWriter::WriteBool(bool b) +{ + VMA_ASSERT(!m_InsideString); + BeginValue(false); + m_SB.Add(b ? "true" : "false"); +} + +void VmaJsonWriter::WriteNull() +{ + VMA_ASSERT(!m_InsideString); + BeginValue(false); + m_SB.Add("null"); +} + +void VmaJsonWriter::BeginValue(bool isString) +{ + if(!m_Stack.empty()) + { + StackItem& currItem = m_Stack.back(); + if(currItem.type == COLLECTION_TYPE_OBJECT && + currItem.valueCount % 2 == 0) + { + VMA_ASSERT(isString); + } + + if(currItem.type == COLLECTION_TYPE_OBJECT && + currItem.valueCount % 2 != 0) + { + m_SB.Add(": "); + } + else if(currItem.valueCount > 0) + { + m_SB.Add(", "); + WriteIndent(); + } + else + { + WriteIndent(); + } + ++currItem.valueCount; + } +} + +void VmaJsonWriter::WriteIndent(bool oneLess) +{ + if(!m_Stack.empty() && !m_Stack.back().singleLineMode) + { + m_SB.AddNewLine(); + + size_t count = m_Stack.size(); + if(count > 0 && oneLess) + { + --count; + } + for(size_t i = 0; i < count; ++i) + { + m_SB.Add(INDENT); + } + } +} + +#endif // #if VMA_STATS_STRING_ENABLED + +//////////////////////////////////////////////////////////////////////////////// + +void VmaAllocation_T::SetUserData(VmaAllocator hAllocator, void* pUserData) +{ + if(IsUserDataString()) + { + VMA_ASSERT(pUserData == VMA_NULL || pUserData != m_pUserData); + + FreeUserDataString(hAllocator); + + if(pUserData != VMA_NULL) + { + m_pUserData = VmaCreateStringCopy(hAllocator->GetAllocationCallbacks(), (const char*)pUserData); + } + } + else + { + m_pUserData = pUserData; + } +} + +void VmaAllocation_T::ChangeBlockAllocation( + VmaAllocator hAllocator, + VmaDeviceMemoryBlock* block, + VkDeviceSize offset) +{ + VMA_ASSERT(block != VMA_NULL); + VMA_ASSERT(m_Type == ALLOCATION_TYPE_BLOCK); + + // Move mapping reference counter from old block to new block. + if(block != m_BlockAllocation.m_Block) + { + uint32_t mapRefCount = m_MapCount & ~MAP_COUNT_FLAG_PERSISTENT_MAP; + if(IsPersistentMap()) + ++mapRefCount; + m_BlockAllocation.m_Block->Unmap(hAllocator, mapRefCount); + block->Map(hAllocator, mapRefCount, VMA_NULL); + } + + m_BlockAllocation.m_Block = block; + m_BlockAllocation.m_Offset = offset; +} + +void VmaAllocation_T::ChangeOffset(VkDeviceSize newOffset) +{ + VMA_ASSERT(m_Type == ALLOCATION_TYPE_BLOCK); + m_BlockAllocation.m_Offset = newOffset; +} + +VkDeviceSize VmaAllocation_T::GetOffset() const +{ + switch(m_Type) + { + case ALLOCATION_TYPE_BLOCK: + return m_BlockAllocation.m_Offset; + case ALLOCATION_TYPE_DEDICATED: + return 0; + default: + VMA_ASSERT(0); + return 0; + } +} + +VkDeviceMemory VmaAllocation_T::GetMemory() const +{ + switch(m_Type) + { + case ALLOCATION_TYPE_BLOCK: + return m_BlockAllocation.m_Block->GetDeviceMemory(); + case ALLOCATION_TYPE_DEDICATED: + return m_DedicatedAllocation.m_hMemory; + default: + VMA_ASSERT(0); + return VK_NULL_HANDLE; + } +} + +void* VmaAllocation_T::GetMappedData() const +{ + switch(m_Type) + { + case ALLOCATION_TYPE_BLOCK: + if(m_MapCount != 0) + { + void* pBlockData = m_BlockAllocation.m_Block->GetMappedData(); + VMA_ASSERT(pBlockData != VMA_NULL); + return (char*)pBlockData + m_BlockAllocation.m_Offset; + } + else + { + return VMA_NULL; + } + break; + case ALLOCATION_TYPE_DEDICATED: + VMA_ASSERT((m_DedicatedAllocation.m_pMappedData != VMA_NULL) == (m_MapCount != 0)); + return m_DedicatedAllocation.m_pMappedData; + default: + VMA_ASSERT(0); + return VMA_NULL; + } +} + +bool VmaAllocation_T::CanBecomeLost() const +{ + switch(m_Type) + { + case ALLOCATION_TYPE_BLOCK: + return m_BlockAllocation.m_CanBecomeLost; + case ALLOCATION_TYPE_DEDICATED: + return false; + default: + VMA_ASSERT(0); + return false; + } +} + +bool VmaAllocation_T::MakeLost(uint32_t currentFrameIndex, uint32_t frameInUseCount) +{ + VMA_ASSERT(CanBecomeLost()); + + /* + Warning: This is a carefully designed algorithm. + Do not modify unless you really know what you're doing :) + */ + uint32_t localLastUseFrameIndex = GetLastUseFrameIndex(); + for(;;) + { + if(localLastUseFrameIndex == VMA_FRAME_INDEX_LOST) + { + VMA_ASSERT(0); + return false; + } + else if(localLastUseFrameIndex + frameInUseCount >= currentFrameIndex) + { + return false; + } + else // Last use time earlier than current time. + { + if(CompareExchangeLastUseFrameIndex(localLastUseFrameIndex, VMA_FRAME_INDEX_LOST)) + { + // Setting hAllocation.LastUseFrameIndex atomic to VMA_FRAME_INDEX_LOST is enough to mark it as LOST. + // Calling code just needs to unregister this allocation in owning VmaDeviceMemoryBlock. + return true; + } + } + } +} + +#if VMA_STATS_STRING_ENABLED + +// Correspond to values of enum VmaSuballocationType. +static const char* VMA_SUBALLOCATION_TYPE_NAMES[] = { + "FREE", + "UNKNOWN", + "BUFFER", + "IMAGE_UNKNOWN", + "IMAGE_LINEAR", + "IMAGE_OPTIMAL", +}; + +void VmaAllocation_T::PrintParameters(class VmaJsonWriter& json) const +{ + json.WriteString("Type"); + json.WriteString(VMA_SUBALLOCATION_TYPE_NAMES[m_SuballocationType]); + + json.WriteString("Size"); + json.WriteNumber(m_Size); + + if(m_pUserData != VMA_NULL) + { + json.WriteString("UserData"); + if(IsUserDataString()) + { + json.WriteString((const char*)m_pUserData); + } + else + { + json.BeginString(); + json.ContinueString_Pointer(m_pUserData); + json.EndString(); + } + } + + json.WriteString("CreationFrameIndex"); + json.WriteNumber(m_CreationFrameIndex); + + json.WriteString("LastUseFrameIndex"); + json.WriteNumber(GetLastUseFrameIndex()); + + if(m_BufferImageUsage != 0) + { + json.WriteString("Usage"); + json.WriteNumber(m_BufferImageUsage); + } +} + +#endif + +void VmaAllocation_T::FreeUserDataString(VmaAllocator hAllocator) +{ + VMA_ASSERT(IsUserDataString()); + VmaFreeString(hAllocator->GetAllocationCallbacks(), (char*)m_pUserData); + m_pUserData = VMA_NULL; +} + +void VmaAllocation_T::BlockAllocMap() +{ + VMA_ASSERT(GetType() == ALLOCATION_TYPE_BLOCK); + + if((m_MapCount & ~MAP_COUNT_FLAG_PERSISTENT_MAP) < 0x7F) + { + ++m_MapCount; + } + else + { + VMA_ASSERT(0 && "Allocation mapped too many times simultaneously."); + } +} + +void VmaAllocation_T::BlockAllocUnmap() +{ + VMA_ASSERT(GetType() == ALLOCATION_TYPE_BLOCK); + + if((m_MapCount & ~MAP_COUNT_FLAG_PERSISTENT_MAP) != 0) + { + --m_MapCount; + } + else + { + VMA_ASSERT(0 && "Unmapping allocation not previously mapped."); + } +} + +VkResult VmaAllocation_T::DedicatedAllocMap(VmaAllocator hAllocator, void** ppData) +{ + VMA_ASSERT(GetType() == ALLOCATION_TYPE_DEDICATED); + + if(m_MapCount != 0) + { + if((m_MapCount & ~MAP_COUNT_FLAG_PERSISTENT_MAP) < 0x7F) + { + VMA_ASSERT(m_DedicatedAllocation.m_pMappedData != VMA_NULL); + *ppData = m_DedicatedAllocation.m_pMappedData; + ++m_MapCount; + return VK_SUCCESS; + } + else + { + VMA_ASSERT(0 && "Dedicated allocation mapped too many times simultaneously."); + return VK_ERROR_MEMORY_MAP_FAILED; + } + } + else + { + VkResult result = (*hAllocator->GetVulkanFunctions().vkMapMemory)( + hAllocator->m_hDevice, + m_DedicatedAllocation.m_hMemory, + 0, // offset + VK_WHOLE_SIZE, + 0, // flags + ppData); + if(result == VK_SUCCESS) + { + m_DedicatedAllocation.m_pMappedData = *ppData; + m_MapCount = 1; + } + return result; + } +} + +void VmaAllocation_T::DedicatedAllocUnmap(VmaAllocator hAllocator) +{ + VMA_ASSERT(GetType() == ALLOCATION_TYPE_DEDICATED); + + if((m_MapCount & ~MAP_COUNT_FLAG_PERSISTENT_MAP) != 0) + { + --m_MapCount; + if(m_MapCount == 0) + { + m_DedicatedAllocation.m_pMappedData = VMA_NULL; + (*hAllocator->GetVulkanFunctions().vkUnmapMemory)( + hAllocator->m_hDevice, + m_DedicatedAllocation.m_hMemory); + } + } + else + { + VMA_ASSERT(0 && "Unmapping dedicated allocation not previously mapped."); + } +} + +#if VMA_STATS_STRING_ENABLED + +static void VmaPrintStatInfo(VmaJsonWriter& json, const VmaStatInfo& stat) +{ + json.BeginObject(); + + json.WriteString("Blocks"); + json.WriteNumber(stat.blockCount); + + json.WriteString("Allocations"); + json.WriteNumber(stat.allocationCount); + + json.WriteString("UnusedRanges"); + json.WriteNumber(stat.unusedRangeCount); + + json.WriteString("UsedBytes"); + json.WriteNumber(stat.usedBytes); + + json.WriteString("UnusedBytes"); + json.WriteNumber(stat.unusedBytes); + + if(stat.allocationCount > 1) + { + json.WriteString("AllocationSize"); + json.BeginObject(true); + json.WriteString("Min"); + json.WriteNumber(stat.allocationSizeMin); + json.WriteString("Avg"); + json.WriteNumber(stat.allocationSizeAvg); + json.WriteString("Max"); + json.WriteNumber(stat.allocationSizeMax); + json.EndObject(); + } + + if(stat.unusedRangeCount > 1) + { + json.WriteString("UnusedRangeSize"); + json.BeginObject(true); + json.WriteString("Min"); + json.WriteNumber(stat.unusedRangeSizeMin); + json.WriteString("Avg"); + json.WriteNumber(stat.unusedRangeSizeAvg); + json.WriteString("Max"); + json.WriteNumber(stat.unusedRangeSizeMax); + json.EndObject(); + } + + json.EndObject(); +} + +#endif // #if VMA_STATS_STRING_ENABLED + +struct VmaSuballocationItemSizeLess +{ + bool operator()( + const VmaSuballocationList::iterator lhs, + const VmaSuballocationList::iterator rhs) const + { + return lhs->size < rhs->size; + } + bool operator()( + const VmaSuballocationList::iterator lhs, + VkDeviceSize rhsSize) const + { + return lhs->size < rhsSize; + } +}; + + +//////////////////////////////////////////////////////////////////////////////// +// class VmaBlockMetadata + +VmaBlockMetadata::VmaBlockMetadata(VmaAllocator hAllocator) : + m_Size(0), + m_pAllocationCallbacks(hAllocator->GetAllocationCallbacks()) +{ +} + +#if VMA_STATS_STRING_ENABLED + +void VmaBlockMetadata::PrintDetailedMap_Begin(class VmaJsonWriter& json, + VkDeviceSize unusedBytes, + size_t allocationCount, + size_t unusedRangeCount) const +{ + json.BeginObject(); + + json.WriteString("TotalBytes"); + json.WriteNumber(GetSize()); + + json.WriteString("UnusedBytes"); + json.WriteNumber(unusedBytes); + + json.WriteString("Allocations"); + json.WriteNumber((uint64_t)allocationCount); + + json.WriteString("UnusedRanges"); + json.WriteNumber((uint64_t)unusedRangeCount); + + json.WriteString("Suballocations"); + json.BeginArray(); +} + +void VmaBlockMetadata::PrintDetailedMap_Allocation(class VmaJsonWriter& json, + VkDeviceSize offset, + VmaAllocation hAllocation) const +{ + json.BeginObject(true); + + json.WriteString("Offset"); + json.WriteNumber(offset); + + hAllocation->PrintParameters(json); + + json.EndObject(); +} + +void VmaBlockMetadata::PrintDetailedMap_UnusedRange(class VmaJsonWriter& json, + VkDeviceSize offset, + VkDeviceSize size) const +{ + json.BeginObject(true); + + json.WriteString("Offset"); + json.WriteNumber(offset); + + json.WriteString("Type"); + json.WriteString(VMA_SUBALLOCATION_TYPE_NAMES[VMA_SUBALLOCATION_TYPE_FREE]); + + json.WriteString("Size"); + json.WriteNumber(size); + + json.EndObject(); +} + +void VmaBlockMetadata::PrintDetailedMap_End(class VmaJsonWriter& json) const +{ + json.EndArray(); + json.EndObject(); +} + +#endif // #if VMA_STATS_STRING_ENABLED + +//////////////////////////////////////////////////////////////////////////////// +// class VmaBlockMetadata_Generic + +VmaBlockMetadata_Generic::VmaBlockMetadata_Generic(VmaAllocator hAllocator) : + VmaBlockMetadata(hAllocator), + m_FreeCount(0), + m_SumFreeSize(0), + m_Suballocations(VmaStlAllocator(hAllocator->GetAllocationCallbacks())), + m_FreeSuballocationsBySize(VmaStlAllocator(hAllocator->GetAllocationCallbacks())) +{ +} + +VmaBlockMetadata_Generic::~VmaBlockMetadata_Generic() +{ +} + +void VmaBlockMetadata_Generic::Init(VkDeviceSize size) +{ + VmaBlockMetadata::Init(size); + + m_FreeCount = 1; + m_SumFreeSize = size; + + VmaSuballocation suballoc = {}; + suballoc.offset = 0; + suballoc.size = size; + suballoc.type = VMA_SUBALLOCATION_TYPE_FREE; + suballoc.hAllocation = VK_NULL_HANDLE; + + VMA_ASSERT(size > VMA_MIN_FREE_SUBALLOCATION_SIZE_TO_REGISTER); + m_Suballocations.push_back(suballoc); + VmaSuballocationList::iterator suballocItem = m_Suballocations.end(); + --suballocItem; + m_FreeSuballocationsBySize.push_back(suballocItem); +} + +bool VmaBlockMetadata_Generic::Validate() const +{ + VMA_VALIDATE(!m_Suballocations.empty()); + + // Expected offset of new suballocation as calculated from previous ones. + VkDeviceSize calculatedOffset = 0; + // Expected number of free suballocations as calculated from traversing their list. + uint32_t calculatedFreeCount = 0; + // Expected sum size of free suballocations as calculated from traversing their list. + VkDeviceSize calculatedSumFreeSize = 0; + // Expected number of free suballocations that should be registered in + // m_FreeSuballocationsBySize calculated from traversing their list. + size_t freeSuballocationsToRegister = 0; + // True if previous visited suballocation was free. + bool prevFree = false; + + for(VmaSuballocationList::const_iterator suballocItem = m_Suballocations.cbegin(); + suballocItem != m_Suballocations.cend(); + ++suballocItem) + { + const VmaSuballocation& subAlloc = *suballocItem; + + // Actual offset of this suballocation doesn't match expected one. + VMA_VALIDATE(subAlloc.offset == calculatedOffset); + + const bool currFree = (subAlloc.type == VMA_SUBALLOCATION_TYPE_FREE); + // Two adjacent free suballocations are invalid. They should be merged. + VMA_VALIDATE(!prevFree || !currFree); + + VMA_VALIDATE(currFree == (subAlloc.hAllocation == VK_NULL_HANDLE)); + + if(currFree) + { + calculatedSumFreeSize += subAlloc.size; + ++calculatedFreeCount; + if(subAlloc.size >= VMA_MIN_FREE_SUBALLOCATION_SIZE_TO_REGISTER) + { + ++freeSuballocationsToRegister; + } + + // Margin required between allocations - every free space must be at least that large. + VMA_VALIDATE(subAlloc.size >= VMA_DEBUG_MARGIN); + } + else + { + VMA_VALIDATE(subAlloc.hAllocation->GetOffset() == subAlloc.offset); + VMA_VALIDATE(subAlloc.hAllocation->GetSize() == subAlloc.size); + + // Margin required between allocations - previous allocation must be free. + VMA_VALIDATE(VMA_DEBUG_MARGIN == 0 || prevFree); + } + + calculatedOffset += subAlloc.size; + prevFree = currFree; + } + + // Number of free suballocations registered in m_FreeSuballocationsBySize doesn't + // match expected one. + VMA_VALIDATE(m_FreeSuballocationsBySize.size() == freeSuballocationsToRegister); + + VkDeviceSize lastSize = 0; + for(size_t i = 0; i < m_FreeSuballocationsBySize.size(); ++i) + { + VmaSuballocationList::iterator suballocItem = m_FreeSuballocationsBySize[i]; + + // Only free suballocations can be registered in m_FreeSuballocationsBySize. + VMA_VALIDATE(suballocItem->type == VMA_SUBALLOCATION_TYPE_FREE); + // They must be sorted by size ascending. + VMA_VALIDATE(suballocItem->size >= lastSize); + + lastSize = suballocItem->size; + } + + // Check if totals match calculacted values. + VMA_VALIDATE(ValidateFreeSuballocationList()); + VMA_VALIDATE(calculatedOffset == GetSize()); + VMA_VALIDATE(calculatedSumFreeSize == m_SumFreeSize); + VMA_VALIDATE(calculatedFreeCount == m_FreeCount); + + return true; +} + +VkDeviceSize VmaBlockMetadata_Generic::GetUnusedRangeSizeMax() const +{ + if(!m_FreeSuballocationsBySize.empty()) + { + return m_FreeSuballocationsBySize.back()->size; + } + else + { + return 0; + } +} + +bool VmaBlockMetadata_Generic::IsEmpty() const +{ + return (m_Suballocations.size() == 1) && (m_FreeCount == 1); +} + +void VmaBlockMetadata_Generic::CalcAllocationStatInfo(VmaStatInfo& outInfo) const +{ + outInfo.blockCount = 1; + + const uint32_t rangeCount = (uint32_t)m_Suballocations.size(); + outInfo.allocationCount = rangeCount - m_FreeCount; + outInfo.unusedRangeCount = m_FreeCount; + + outInfo.unusedBytes = m_SumFreeSize; + outInfo.usedBytes = GetSize() - outInfo.unusedBytes; + + outInfo.allocationSizeMin = UINT64_MAX; + outInfo.allocationSizeMax = 0; + outInfo.unusedRangeSizeMin = UINT64_MAX; + outInfo.unusedRangeSizeMax = 0; + + for(VmaSuballocationList::const_iterator suballocItem = m_Suballocations.cbegin(); + suballocItem != m_Suballocations.cend(); + ++suballocItem) + { + const VmaSuballocation& suballoc = *suballocItem; + if(suballoc.type != VMA_SUBALLOCATION_TYPE_FREE) + { + outInfo.allocationSizeMin = VMA_MIN(outInfo.allocationSizeMin, suballoc.size); + outInfo.allocationSizeMax = VMA_MAX(outInfo.allocationSizeMax, suballoc.size); + } + else + { + outInfo.unusedRangeSizeMin = VMA_MIN(outInfo.unusedRangeSizeMin, suballoc.size); + outInfo.unusedRangeSizeMax = VMA_MAX(outInfo.unusedRangeSizeMax, suballoc.size); + } + } +} + +void VmaBlockMetadata_Generic::AddPoolStats(VmaPoolStats& inoutStats) const +{ + const uint32_t rangeCount = (uint32_t)m_Suballocations.size(); + + inoutStats.size += GetSize(); + inoutStats.unusedSize += m_SumFreeSize; + inoutStats.allocationCount += rangeCount - m_FreeCount; + inoutStats.unusedRangeCount += m_FreeCount; + inoutStats.unusedRangeSizeMax = VMA_MAX(inoutStats.unusedRangeSizeMax, GetUnusedRangeSizeMax()); +} + +#if VMA_STATS_STRING_ENABLED + +void VmaBlockMetadata_Generic::PrintDetailedMap(class VmaJsonWriter& json) const +{ + PrintDetailedMap_Begin(json, + m_SumFreeSize, // unusedBytes + m_Suballocations.size() - (size_t)m_FreeCount, // allocationCount + m_FreeCount); // unusedRangeCount + + size_t i = 0; + for(VmaSuballocationList::const_iterator suballocItem = m_Suballocations.cbegin(); + suballocItem != m_Suballocations.cend(); + ++suballocItem, ++i) + { + if(suballocItem->type == VMA_SUBALLOCATION_TYPE_FREE) + { + PrintDetailedMap_UnusedRange(json, suballocItem->offset, suballocItem->size); + } + else + { + PrintDetailedMap_Allocation(json, suballocItem->offset, suballocItem->hAllocation); + } + } + + PrintDetailedMap_End(json); +} + +#endif // #if VMA_STATS_STRING_ENABLED + +bool VmaBlockMetadata_Generic::CreateAllocationRequest( + uint32_t currentFrameIndex, + uint32_t frameInUseCount, + VkDeviceSize bufferImageGranularity, + VkDeviceSize allocSize, + VkDeviceSize allocAlignment, + bool upperAddress, + VmaSuballocationType allocType, + bool canMakeOtherLost, + uint32_t strategy, + VmaAllocationRequest* pAllocationRequest) +{ + VMA_ASSERT(allocSize > 0); + VMA_ASSERT(!upperAddress); + VMA_ASSERT(allocType != VMA_SUBALLOCATION_TYPE_FREE); + VMA_ASSERT(pAllocationRequest != VMA_NULL); + VMA_HEAVY_ASSERT(Validate()); + + pAllocationRequest->type = VmaAllocationRequestType::Normal; + + // There is not enough total free space in this block to fullfill the request: Early return. + if(canMakeOtherLost == false && + m_SumFreeSize < allocSize + 2 * VMA_DEBUG_MARGIN) + { + return false; + } + + // New algorithm, efficiently searching freeSuballocationsBySize. + const size_t freeSuballocCount = m_FreeSuballocationsBySize.size(); + if(freeSuballocCount > 0) + { + if(strategy == VMA_ALLOCATION_CREATE_STRATEGY_BEST_FIT_BIT) + { + // Find first free suballocation with size not less than allocSize + 2 * VMA_DEBUG_MARGIN. + VmaSuballocationList::iterator* const it = VmaBinaryFindFirstNotLess( + m_FreeSuballocationsBySize.data(), + m_FreeSuballocationsBySize.data() + freeSuballocCount, + allocSize + 2 * VMA_DEBUG_MARGIN, + VmaSuballocationItemSizeLess()); + size_t index = it - m_FreeSuballocationsBySize.data(); + for(; index < freeSuballocCount; ++index) + { + if(CheckAllocation( + currentFrameIndex, + frameInUseCount, + bufferImageGranularity, + allocSize, + allocAlignment, + allocType, + m_FreeSuballocationsBySize[index], + false, // canMakeOtherLost + &pAllocationRequest->offset, + &pAllocationRequest->itemsToMakeLostCount, + &pAllocationRequest->sumFreeSize, + &pAllocationRequest->sumItemSize)) + { + pAllocationRequest->item = m_FreeSuballocationsBySize[index]; + return true; + } + } + } + else if(strategy == VMA_ALLOCATION_INTERNAL_STRATEGY_MIN_OFFSET) + { + for(VmaSuballocationList::iterator it = m_Suballocations.begin(); + it != m_Suballocations.end(); + ++it) + { + if(it->type == VMA_SUBALLOCATION_TYPE_FREE && CheckAllocation( + currentFrameIndex, + frameInUseCount, + bufferImageGranularity, + allocSize, + allocAlignment, + allocType, + it, + false, // canMakeOtherLost + &pAllocationRequest->offset, + &pAllocationRequest->itemsToMakeLostCount, + &pAllocationRequest->sumFreeSize, + &pAllocationRequest->sumItemSize)) + { + pAllocationRequest->item = it; + return true; + } + } + } + else // WORST_FIT, FIRST_FIT + { + // Search staring from biggest suballocations. + for(size_t index = freeSuballocCount; index--; ) + { + if(CheckAllocation( + currentFrameIndex, + frameInUseCount, + bufferImageGranularity, + allocSize, + allocAlignment, + allocType, + m_FreeSuballocationsBySize[index], + false, // canMakeOtherLost + &pAllocationRequest->offset, + &pAllocationRequest->itemsToMakeLostCount, + &pAllocationRequest->sumFreeSize, + &pAllocationRequest->sumItemSize)) + { + pAllocationRequest->item = m_FreeSuballocationsBySize[index]; + return true; + } + } + } + } + + if(canMakeOtherLost) + { + // Brute-force algorithm. TODO: Come up with something better. + + bool found = false; + VmaAllocationRequest tmpAllocRequest = {}; + tmpAllocRequest.type = VmaAllocationRequestType::Normal; + for(VmaSuballocationList::iterator suballocIt = m_Suballocations.begin(); + suballocIt != m_Suballocations.end(); + ++suballocIt) + { + if(suballocIt->type == VMA_SUBALLOCATION_TYPE_FREE || + suballocIt->hAllocation->CanBecomeLost()) + { + if(CheckAllocation( + currentFrameIndex, + frameInUseCount, + bufferImageGranularity, + allocSize, + allocAlignment, + allocType, + suballocIt, + canMakeOtherLost, + &tmpAllocRequest.offset, + &tmpAllocRequest.itemsToMakeLostCount, + &tmpAllocRequest.sumFreeSize, + &tmpAllocRequest.sumItemSize)) + { + if(strategy == VMA_ALLOCATION_CREATE_STRATEGY_FIRST_FIT_BIT) + { + *pAllocationRequest = tmpAllocRequest; + pAllocationRequest->item = suballocIt; + break; + } + if(!found || tmpAllocRequest.CalcCost() < pAllocationRequest->CalcCost()) + { + *pAllocationRequest = tmpAllocRequest; + pAllocationRequest->item = suballocIt; + found = true; + } + } + } + } + + return found; + } + + return false; +} + +bool VmaBlockMetadata_Generic::MakeRequestedAllocationsLost( + uint32_t currentFrameIndex, + uint32_t frameInUseCount, + VmaAllocationRequest* pAllocationRequest) +{ + VMA_ASSERT(pAllocationRequest && pAllocationRequest->type == VmaAllocationRequestType::Normal); + + while(pAllocationRequest->itemsToMakeLostCount > 0) + { + if(pAllocationRequest->item->type == VMA_SUBALLOCATION_TYPE_FREE) + { + ++pAllocationRequest->item; + } + VMA_ASSERT(pAllocationRequest->item != m_Suballocations.end()); + VMA_ASSERT(pAllocationRequest->item->hAllocation != VK_NULL_HANDLE); + VMA_ASSERT(pAllocationRequest->item->hAllocation->CanBecomeLost()); + if(pAllocationRequest->item->hAllocation->MakeLost(currentFrameIndex, frameInUseCount)) + { + pAllocationRequest->item = FreeSuballocation(pAllocationRequest->item); + --pAllocationRequest->itemsToMakeLostCount; + } + else + { + return false; + } + } + + VMA_HEAVY_ASSERT(Validate()); + VMA_ASSERT(pAllocationRequest->item != m_Suballocations.end()); + VMA_ASSERT(pAllocationRequest->item->type == VMA_SUBALLOCATION_TYPE_FREE); + + return true; +} + +uint32_t VmaBlockMetadata_Generic::MakeAllocationsLost(uint32_t currentFrameIndex, uint32_t frameInUseCount) +{ + uint32_t lostAllocationCount = 0; + for(VmaSuballocationList::iterator it = m_Suballocations.begin(); + it != m_Suballocations.end(); + ++it) + { + if(it->type != VMA_SUBALLOCATION_TYPE_FREE && + it->hAllocation->CanBecomeLost() && + it->hAllocation->MakeLost(currentFrameIndex, frameInUseCount)) + { + it = FreeSuballocation(it); + ++lostAllocationCount; + } + } + return lostAllocationCount; +} + +VkResult VmaBlockMetadata_Generic::CheckCorruption(const void* pBlockData) +{ + for(VmaSuballocationList::iterator it = m_Suballocations.begin(); + it != m_Suballocations.end(); + ++it) + { + if(it->type != VMA_SUBALLOCATION_TYPE_FREE) + { + if(!VmaValidateMagicValue(pBlockData, it->offset - VMA_DEBUG_MARGIN)) + { + VMA_ASSERT(0 && "MEMORY CORRUPTION DETECTED BEFORE VALIDATED ALLOCATION!"); + return VK_ERROR_VALIDATION_FAILED_EXT; + } + if(!VmaValidateMagicValue(pBlockData, it->offset + it->size)) + { + VMA_ASSERT(0 && "MEMORY CORRUPTION DETECTED AFTER VALIDATED ALLOCATION!"); + return VK_ERROR_VALIDATION_FAILED_EXT; + } + } + } + + return VK_SUCCESS; +} + +void VmaBlockMetadata_Generic::Alloc( + const VmaAllocationRequest& request, + VmaSuballocationType type, + VkDeviceSize allocSize, + VmaAllocation hAllocation) +{ + VMA_ASSERT(request.type == VmaAllocationRequestType::Normal); + VMA_ASSERT(request.item != m_Suballocations.end()); + VmaSuballocation& suballoc = *request.item; + // Given suballocation is a free block. + VMA_ASSERT(suballoc.type == VMA_SUBALLOCATION_TYPE_FREE); + // Given offset is inside this suballocation. + VMA_ASSERT(request.offset >= suballoc.offset); + const VkDeviceSize paddingBegin = request.offset - suballoc.offset; + VMA_ASSERT(suballoc.size >= paddingBegin + allocSize); + const VkDeviceSize paddingEnd = suballoc.size - paddingBegin - allocSize; + + // Unregister this free suballocation from m_FreeSuballocationsBySize and update + // it to become used. + UnregisterFreeSuballocation(request.item); + + suballoc.offset = request.offset; + suballoc.size = allocSize; + suballoc.type = type; + suballoc.hAllocation = hAllocation; + + // If there are any free bytes remaining at the end, insert new free suballocation after current one. + if(paddingEnd) + { + VmaSuballocation paddingSuballoc = {}; + paddingSuballoc.offset = request.offset + allocSize; + paddingSuballoc.size = paddingEnd; + paddingSuballoc.type = VMA_SUBALLOCATION_TYPE_FREE; + VmaSuballocationList::iterator next = request.item; + ++next; + const VmaSuballocationList::iterator paddingEndItem = + m_Suballocations.insert(next, paddingSuballoc); + RegisterFreeSuballocation(paddingEndItem); + } + + // If there are any free bytes remaining at the beginning, insert new free suballocation before current one. + if(paddingBegin) + { + VmaSuballocation paddingSuballoc = {}; + paddingSuballoc.offset = request.offset - paddingBegin; + paddingSuballoc.size = paddingBegin; + paddingSuballoc.type = VMA_SUBALLOCATION_TYPE_FREE; + const VmaSuballocationList::iterator paddingBeginItem = + m_Suballocations.insert(request.item, paddingSuballoc); + RegisterFreeSuballocation(paddingBeginItem); + } + + // Update totals. + m_FreeCount = m_FreeCount - 1; + if(paddingBegin > 0) + { + ++m_FreeCount; + } + if(paddingEnd > 0) + { + ++m_FreeCount; + } + m_SumFreeSize -= allocSize; +} + +void VmaBlockMetadata_Generic::Free(const VmaAllocation allocation) +{ + for(VmaSuballocationList::iterator suballocItem = m_Suballocations.begin(); + suballocItem != m_Suballocations.end(); + ++suballocItem) + { + VmaSuballocation& suballoc = *suballocItem; + if(suballoc.hAllocation == allocation) + { + FreeSuballocation(suballocItem); + VMA_HEAVY_ASSERT(Validate()); + return; + } + } + VMA_ASSERT(0 && "Not found!"); +} + +void VmaBlockMetadata_Generic::FreeAtOffset(VkDeviceSize offset) +{ + for(VmaSuballocationList::iterator suballocItem = m_Suballocations.begin(); + suballocItem != m_Suballocations.end(); + ++suballocItem) + { + VmaSuballocation& suballoc = *suballocItem; + if(suballoc.offset == offset) + { + FreeSuballocation(suballocItem); + return; + } + } + VMA_ASSERT(0 && "Not found!"); +} + +bool VmaBlockMetadata_Generic::ValidateFreeSuballocationList() const +{ + VkDeviceSize lastSize = 0; + for(size_t i = 0, count = m_FreeSuballocationsBySize.size(); i < count; ++i) + { + const VmaSuballocationList::iterator it = m_FreeSuballocationsBySize[i]; + + VMA_VALIDATE(it->type == VMA_SUBALLOCATION_TYPE_FREE); + VMA_VALIDATE(it->size >= VMA_MIN_FREE_SUBALLOCATION_SIZE_TO_REGISTER); + VMA_VALIDATE(it->size >= lastSize); + lastSize = it->size; + } + return true; +} + +bool VmaBlockMetadata_Generic::CheckAllocation( + uint32_t currentFrameIndex, + uint32_t frameInUseCount, + VkDeviceSize bufferImageGranularity, + VkDeviceSize allocSize, + VkDeviceSize allocAlignment, + VmaSuballocationType allocType, + VmaSuballocationList::const_iterator suballocItem, + bool canMakeOtherLost, + VkDeviceSize* pOffset, + size_t* itemsToMakeLostCount, + VkDeviceSize* pSumFreeSize, + VkDeviceSize* pSumItemSize) const +{ + VMA_ASSERT(allocSize > 0); + VMA_ASSERT(allocType != VMA_SUBALLOCATION_TYPE_FREE); + VMA_ASSERT(suballocItem != m_Suballocations.cend()); + VMA_ASSERT(pOffset != VMA_NULL); + + *itemsToMakeLostCount = 0; + *pSumFreeSize = 0; + *pSumItemSize = 0; + + if(canMakeOtherLost) + { + if(suballocItem->type == VMA_SUBALLOCATION_TYPE_FREE) + { + *pSumFreeSize = suballocItem->size; + } + else + { + if(suballocItem->hAllocation->CanBecomeLost() && + suballocItem->hAllocation->GetLastUseFrameIndex() + frameInUseCount < currentFrameIndex) + { + ++*itemsToMakeLostCount; + *pSumItemSize = suballocItem->size; + } + else + { + return false; + } + } + + // Remaining size is too small for this request: Early return. + if(GetSize() - suballocItem->offset < allocSize) + { + return false; + } + + // Start from offset equal to beginning of this suballocation. + *pOffset = suballocItem->offset; + + // Apply VMA_DEBUG_MARGIN at the beginning. + if(VMA_DEBUG_MARGIN > 0) + { + *pOffset += VMA_DEBUG_MARGIN; + } + + // Apply alignment. + *pOffset = VmaAlignUp(*pOffset, allocAlignment); + + // Check previous suballocations for BufferImageGranularity conflicts. + // Make bigger alignment if necessary. + if(bufferImageGranularity > 1) + { + bool bufferImageGranularityConflict = false; + VmaSuballocationList::const_iterator prevSuballocItem = suballocItem; + while(prevSuballocItem != m_Suballocations.cbegin()) + { + --prevSuballocItem; + const VmaSuballocation& prevSuballoc = *prevSuballocItem; + if(VmaBlocksOnSamePage(prevSuballoc.offset, prevSuballoc.size, *pOffset, bufferImageGranularity)) + { + if(VmaIsBufferImageGranularityConflict(prevSuballoc.type, allocType)) + { + bufferImageGranularityConflict = true; + break; + } + } + else + // Already on previous page. + break; + } + if(bufferImageGranularityConflict) + { + *pOffset = VmaAlignUp(*pOffset, bufferImageGranularity); + } + } + + // Now that we have final *pOffset, check if we are past suballocItem. + // If yes, return false - this function should be called for another suballocItem as starting point. + if(*pOffset >= suballocItem->offset + suballocItem->size) + { + return false; + } + + // Calculate padding at the beginning based on current offset. + const VkDeviceSize paddingBegin = *pOffset - suballocItem->offset; + + // Calculate required margin at the end. + const VkDeviceSize requiredEndMargin = VMA_DEBUG_MARGIN; + + const VkDeviceSize totalSize = paddingBegin + allocSize + requiredEndMargin; + // Another early return check. + if(suballocItem->offset + totalSize > GetSize()) + { + return false; + } + + // Advance lastSuballocItem until desired size is reached. + // Update itemsToMakeLostCount. + VmaSuballocationList::const_iterator lastSuballocItem = suballocItem; + if(totalSize > suballocItem->size) + { + VkDeviceSize remainingSize = totalSize - suballocItem->size; + while(remainingSize > 0) + { + ++lastSuballocItem; + if(lastSuballocItem == m_Suballocations.cend()) + { + return false; + } + if(lastSuballocItem->type == VMA_SUBALLOCATION_TYPE_FREE) + { + *pSumFreeSize += lastSuballocItem->size; + } + else + { + VMA_ASSERT(lastSuballocItem->hAllocation != VK_NULL_HANDLE); + if(lastSuballocItem->hAllocation->CanBecomeLost() && + lastSuballocItem->hAllocation->GetLastUseFrameIndex() + frameInUseCount < currentFrameIndex) + { + ++*itemsToMakeLostCount; + *pSumItemSize += lastSuballocItem->size; + } + else + { + return false; + } + } + remainingSize = (lastSuballocItem->size < remainingSize) ? + remainingSize - lastSuballocItem->size : 0; + } + } + + // Check next suballocations for BufferImageGranularity conflicts. + // If conflict exists, we must mark more allocations lost or fail. + if(bufferImageGranularity > 1) + { + VmaSuballocationList::const_iterator nextSuballocItem = lastSuballocItem; + ++nextSuballocItem; + while(nextSuballocItem != m_Suballocations.cend()) + { + const VmaSuballocation& nextSuballoc = *nextSuballocItem; + if(VmaBlocksOnSamePage(*pOffset, allocSize, nextSuballoc.offset, bufferImageGranularity)) + { + if(VmaIsBufferImageGranularityConflict(allocType, nextSuballoc.type)) + { + VMA_ASSERT(nextSuballoc.hAllocation != VK_NULL_HANDLE); + if(nextSuballoc.hAllocation->CanBecomeLost() && + nextSuballoc.hAllocation->GetLastUseFrameIndex() + frameInUseCount < currentFrameIndex) + { + ++*itemsToMakeLostCount; + } + else + { + return false; + } + } + } + else + { + // Already on next page. + break; + } + ++nextSuballocItem; + } + } + } + else + { + const VmaSuballocation& suballoc = *suballocItem; + VMA_ASSERT(suballoc.type == VMA_SUBALLOCATION_TYPE_FREE); + + *pSumFreeSize = suballoc.size; + + // Size of this suballocation is too small for this request: Early return. + if(suballoc.size < allocSize) + { + return false; + } + + // Start from offset equal to beginning of this suballocation. + *pOffset = suballoc.offset; + + // Apply VMA_DEBUG_MARGIN at the beginning. + if(VMA_DEBUG_MARGIN > 0) + { + *pOffset += VMA_DEBUG_MARGIN; + } + + // Apply alignment. + *pOffset = VmaAlignUp(*pOffset, allocAlignment); + + // Check previous suballocations for BufferImageGranularity conflicts. + // Make bigger alignment if necessary. + if(bufferImageGranularity > 1) + { + bool bufferImageGranularityConflict = false; + VmaSuballocationList::const_iterator prevSuballocItem = suballocItem; + while(prevSuballocItem != m_Suballocations.cbegin()) + { + --prevSuballocItem; + const VmaSuballocation& prevSuballoc = *prevSuballocItem; + if(VmaBlocksOnSamePage(prevSuballoc.offset, prevSuballoc.size, *pOffset, bufferImageGranularity)) + { + if(VmaIsBufferImageGranularityConflict(prevSuballoc.type, allocType)) + { + bufferImageGranularityConflict = true; + break; + } + } + else + // Already on previous page. + break; + } + if(bufferImageGranularityConflict) + { + *pOffset = VmaAlignUp(*pOffset, bufferImageGranularity); + } + } + + // Calculate padding at the beginning based on current offset. + const VkDeviceSize paddingBegin = *pOffset - suballoc.offset; + + // Calculate required margin at the end. + const VkDeviceSize requiredEndMargin = VMA_DEBUG_MARGIN; + + // Fail if requested size plus margin before and after is bigger than size of this suballocation. + if(paddingBegin + allocSize + requiredEndMargin > suballoc.size) + { + return false; + } + + // Check next suballocations for BufferImageGranularity conflicts. + // If conflict exists, allocation cannot be made here. + if(bufferImageGranularity > 1) + { + VmaSuballocationList::const_iterator nextSuballocItem = suballocItem; + ++nextSuballocItem; + while(nextSuballocItem != m_Suballocations.cend()) + { + const VmaSuballocation& nextSuballoc = *nextSuballocItem; + if(VmaBlocksOnSamePage(*pOffset, allocSize, nextSuballoc.offset, bufferImageGranularity)) + { + if(VmaIsBufferImageGranularityConflict(allocType, nextSuballoc.type)) + { + return false; + } + } + else + { + // Already on next page. + break; + } + ++nextSuballocItem; + } + } + } + + // All tests passed: Success. pOffset is already filled. + return true; +} + +void VmaBlockMetadata_Generic::MergeFreeWithNext(VmaSuballocationList::iterator item) +{ + VMA_ASSERT(item != m_Suballocations.end()); + VMA_ASSERT(item->type == VMA_SUBALLOCATION_TYPE_FREE); + + VmaSuballocationList::iterator nextItem = item; + ++nextItem; + VMA_ASSERT(nextItem != m_Suballocations.end()); + VMA_ASSERT(nextItem->type == VMA_SUBALLOCATION_TYPE_FREE); + + item->size += nextItem->size; + --m_FreeCount; + m_Suballocations.erase(nextItem); +} + +VmaSuballocationList::iterator VmaBlockMetadata_Generic::FreeSuballocation(VmaSuballocationList::iterator suballocItem) +{ + // Change this suballocation to be marked as free. + VmaSuballocation& suballoc = *suballocItem; + suballoc.type = VMA_SUBALLOCATION_TYPE_FREE; + suballoc.hAllocation = VK_NULL_HANDLE; + + // Update totals. + ++m_FreeCount; + m_SumFreeSize += suballoc.size; + + // Merge with previous and/or next suballocation if it's also free. + bool mergeWithNext = false; + bool mergeWithPrev = false; + + VmaSuballocationList::iterator nextItem = suballocItem; + ++nextItem; + if((nextItem != m_Suballocations.end()) && (nextItem->type == VMA_SUBALLOCATION_TYPE_FREE)) + { + mergeWithNext = true; + } + + VmaSuballocationList::iterator prevItem = suballocItem; + if(suballocItem != m_Suballocations.begin()) + { + --prevItem; + if(prevItem->type == VMA_SUBALLOCATION_TYPE_FREE) + { + mergeWithPrev = true; + } + } + + if(mergeWithNext) + { + UnregisterFreeSuballocation(nextItem); + MergeFreeWithNext(suballocItem); + } + + if(mergeWithPrev) + { + UnregisterFreeSuballocation(prevItem); + MergeFreeWithNext(prevItem); + RegisterFreeSuballocation(prevItem); + return prevItem; + } + else + { + RegisterFreeSuballocation(suballocItem); + return suballocItem; + } +} + +void VmaBlockMetadata_Generic::RegisterFreeSuballocation(VmaSuballocationList::iterator item) +{ + VMA_ASSERT(item->type == VMA_SUBALLOCATION_TYPE_FREE); + VMA_ASSERT(item->size > 0); + + // You may want to enable this validation at the beginning or at the end of + // this function, depending on what do you want to check. + VMA_HEAVY_ASSERT(ValidateFreeSuballocationList()); + + if(item->size >= VMA_MIN_FREE_SUBALLOCATION_SIZE_TO_REGISTER) + { + if(m_FreeSuballocationsBySize.empty()) + { + m_FreeSuballocationsBySize.push_back(item); + } + else + { + VmaVectorInsertSorted(m_FreeSuballocationsBySize, item); + } + } + + //VMA_HEAVY_ASSERT(ValidateFreeSuballocationList()); +} + + +void VmaBlockMetadata_Generic::UnregisterFreeSuballocation(VmaSuballocationList::iterator item) +{ + VMA_ASSERT(item->type == VMA_SUBALLOCATION_TYPE_FREE); + VMA_ASSERT(item->size > 0); + + // You may want to enable this validation at the beginning or at the end of + // this function, depending on what do you want to check. + VMA_HEAVY_ASSERT(ValidateFreeSuballocationList()); + + if(item->size >= VMA_MIN_FREE_SUBALLOCATION_SIZE_TO_REGISTER) + { + VmaSuballocationList::iterator* const it = VmaBinaryFindFirstNotLess( + m_FreeSuballocationsBySize.data(), + m_FreeSuballocationsBySize.data() + m_FreeSuballocationsBySize.size(), + item, + VmaSuballocationItemSizeLess()); + for(size_t index = it - m_FreeSuballocationsBySize.data(); + index < m_FreeSuballocationsBySize.size(); + ++index) + { + if(m_FreeSuballocationsBySize[index] == item) + { + VmaVectorRemove(m_FreeSuballocationsBySize, index); + return; + } + VMA_ASSERT((m_FreeSuballocationsBySize[index]->size == item->size) && "Not found."); + } + VMA_ASSERT(0 && "Not found."); + } + + //VMA_HEAVY_ASSERT(ValidateFreeSuballocationList()); +} + +bool VmaBlockMetadata_Generic::IsBufferImageGranularityConflictPossible( + VkDeviceSize bufferImageGranularity, + VmaSuballocationType& inOutPrevSuballocType) const +{ + if(bufferImageGranularity == 1 || IsEmpty()) + { + return false; + } + + VkDeviceSize minAlignment = VK_WHOLE_SIZE; + bool typeConflictFound = false; + for(VmaSuballocationList::const_iterator it = m_Suballocations.cbegin(); + it != m_Suballocations.cend(); + ++it) + { + const VmaSuballocationType suballocType = it->type; + if(suballocType != VMA_SUBALLOCATION_TYPE_FREE) + { + minAlignment = VMA_MIN(minAlignment, it->hAllocation->GetAlignment()); + if(VmaIsBufferImageGranularityConflict(inOutPrevSuballocType, suballocType)) + { + typeConflictFound = true; + } + inOutPrevSuballocType = suballocType; + } + } + + return typeConflictFound || minAlignment >= bufferImageGranularity; +} + +//////////////////////////////////////////////////////////////////////////////// +// class VmaBlockMetadata_Linear + +VmaBlockMetadata_Linear::VmaBlockMetadata_Linear(VmaAllocator hAllocator) : + VmaBlockMetadata(hAllocator), + m_SumFreeSize(0), + m_Suballocations0(VmaStlAllocator(hAllocator->GetAllocationCallbacks())), + m_Suballocations1(VmaStlAllocator(hAllocator->GetAllocationCallbacks())), + m_1stVectorIndex(0), + m_2ndVectorMode(SECOND_VECTOR_EMPTY), + m_1stNullItemsBeginCount(0), + m_1stNullItemsMiddleCount(0), + m_2ndNullItemsCount(0) +{ +} + +VmaBlockMetadata_Linear::~VmaBlockMetadata_Linear() +{ +} + +void VmaBlockMetadata_Linear::Init(VkDeviceSize size) +{ + VmaBlockMetadata::Init(size); + m_SumFreeSize = size; +} + +bool VmaBlockMetadata_Linear::Validate() const +{ + const SuballocationVectorType& suballocations1st = AccessSuballocations1st(); + const SuballocationVectorType& suballocations2nd = AccessSuballocations2nd(); + + VMA_VALIDATE(suballocations2nd.empty() == (m_2ndVectorMode == SECOND_VECTOR_EMPTY)); + VMA_VALIDATE(!suballocations1st.empty() || + suballocations2nd.empty() || + m_2ndVectorMode != SECOND_VECTOR_RING_BUFFER); + + if(!suballocations1st.empty()) + { + // Null item at the beginning should be accounted into m_1stNullItemsBeginCount. + VMA_VALIDATE(suballocations1st[m_1stNullItemsBeginCount].hAllocation != VK_NULL_HANDLE); + // Null item at the end should be just pop_back(). + VMA_VALIDATE(suballocations1st.back().hAllocation != VK_NULL_HANDLE); + } + if(!suballocations2nd.empty()) + { + // Null item at the end should be just pop_back(). + VMA_VALIDATE(suballocations2nd.back().hAllocation != VK_NULL_HANDLE); + } + + VMA_VALIDATE(m_1stNullItemsBeginCount + m_1stNullItemsMiddleCount <= suballocations1st.size()); + VMA_VALIDATE(m_2ndNullItemsCount <= suballocations2nd.size()); + + VkDeviceSize sumUsedSize = 0; + const size_t suballoc1stCount = suballocations1st.size(); + VkDeviceSize offset = VMA_DEBUG_MARGIN; + + if(m_2ndVectorMode == SECOND_VECTOR_RING_BUFFER) + { + const size_t suballoc2ndCount = suballocations2nd.size(); + size_t nullItem2ndCount = 0; + for(size_t i = 0; i < suballoc2ndCount; ++i) + { + const VmaSuballocation& suballoc = suballocations2nd[i]; + const bool currFree = (suballoc.type == VMA_SUBALLOCATION_TYPE_FREE); + + VMA_VALIDATE(currFree == (suballoc.hAllocation == VK_NULL_HANDLE)); + VMA_VALIDATE(suballoc.offset >= offset); + + if(!currFree) + { + VMA_VALIDATE(suballoc.hAllocation->GetOffset() == suballoc.offset); + VMA_VALIDATE(suballoc.hAllocation->GetSize() == suballoc.size); + sumUsedSize += suballoc.size; + } + else + { + ++nullItem2ndCount; + } + + offset = suballoc.offset + suballoc.size + VMA_DEBUG_MARGIN; + } + + VMA_VALIDATE(nullItem2ndCount == m_2ndNullItemsCount); + } + + for(size_t i = 0; i < m_1stNullItemsBeginCount; ++i) + { + const VmaSuballocation& suballoc = suballocations1st[i]; + VMA_VALIDATE(suballoc.type == VMA_SUBALLOCATION_TYPE_FREE && + suballoc.hAllocation == VK_NULL_HANDLE); + } + + size_t nullItem1stCount = m_1stNullItemsBeginCount; + + for(size_t i = m_1stNullItemsBeginCount; i < suballoc1stCount; ++i) + { + const VmaSuballocation& suballoc = suballocations1st[i]; + const bool currFree = (suballoc.type == VMA_SUBALLOCATION_TYPE_FREE); + + VMA_VALIDATE(currFree == (suballoc.hAllocation == VK_NULL_HANDLE)); + VMA_VALIDATE(suballoc.offset >= offset); + VMA_VALIDATE(i >= m_1stNullItemsBeginCount || currFree); + + if(!currFree) + { + VMA_VALIDATE(suballoc.hAllocation->GetOffset() == suballoc.offset); + VMA_VALIDATE(suballoc.hAllocation->GetSize() == suballoc.size); + sumUsedSize += suballoc.size; + } + else + { + ++nullItem1stCount; + } + + offset = suballoc.offset + suballoc.size + VMA_DEBUG_MARGIN; + } + VMA_VALIDATE(nullItem1stCount == m_1stNullItemsBeginCount + m_1stNullItemsMiddleCount); + + if(m_2ndVectorMode == SECOND_VECTOR_DOUBLE_STACK) + { + const size_t suballoc2ndCount = suballocations2nd.size(); + size_t nullItem2ndCount = 0; + for(size_t i = suballoc2ndCount; i--; ) + { + const VmaSuballocation& suballoc = suballocations2nd[i]; + const bool currFree = (suballoc.type == VMA_SUBALLOCATION_TYPE_FREE); + + VMA_VALIDATE(currFree == (suballoc.hAllocation == VK_NULL_HANDLE)); + VMA_VALIDATE(suballoc.offset >= offset); + + if(!currFree) + { + VMA_VALIDATE(suballoc.hAllocation->GetOffset() == suballoc.offset); + VMA_VALIDATE(suballoc.hAllocation->GetSize() == suballoc.size); + sumUsedSize += suballoc.size; + } + else + { + ++nullItem2ndCount; + } + + offset = suballoc.offset + suballoc.size + VMA_DEBUG_MARGIN; + } + + VMA_VALIDATE(nullItem2ndCount == m_2ndNullItemsCount); + } + + VMA_VALIDATE(offset <= GetSize()); + VMA_VALIDATE(m_SumFreeSize == GetSize() - sumUsedSize); + + return true; +} + +size_t VmaBlockMetadata_Linear::GetAllocationCount() const +{ + return AccessSuballocations1st().size() - (m_1stNullItemsBeginCount + m_1stNullItemsMiddleCount) + + AccessSuballocations2nd().size() - m_2ndNullItemsCount; +} + +VkDeviceSize VmaBlockMetadata_Linear::GetUnusedRangeSizeMax() const +{ + const VkDeviceSize size = GetSize(); + + /* + We don't consider gaps inside allocation vectors with freed allocations because + they are not suitable for reuse in linear allocator. We consider only space that + is available for new allocations. + */ + if(IsEmpty()) + { + return size; + } + + const SuballocationVectorType& suballocations1st = AccessSuballocations1st(); + + switch(m_2ndVectorMode) + { + case SECOND_VECTOR_EMPTY: + /* + Available space is after end of 1st, as well as before beginning of 1st (which + whould make it a ring buffer). + */ + { + const size_t suballocations1stCount = suballocations1st.size(); + VMA_ASSERT(suballocations1stCount > m_1stNullItemsBeginCount); + const VmaSuballocation& firstSuballoc = suballocations1st[m_1stNullItemsBeginCount]; + const VmaSuballocation& lastSuballoc = suballocations1st[suballocations1stCount - 1]; + return VMA_MAX( + firstSuballoc.offset, + size - (lastSuballoc.offset + lastSuballoc.size)); + } + break; + + case SECOND_VECTOR_RING_BUFFER: + /* + Available space is only between end of 2nd and beginning of 1st. + */ + { + const SuballocationVectorType& suballocations2nd = AccessSuballocations2nd(); + const VmaSuballocation& lastSuballoc2nd = suballocations2nd.back(); + const VmaSuballocation& firstSuballoc1st = suballocations1st[m_1stNullItemsBeginCount]; + return firstSuballoc1st.offset - (lastSuballoc2nd.offset + lastSuballoc2nd.size); + } + break; + + case SECOND_VECTOR_DOUBLE_STACK: + /* + Available space is only between end of 1st and top of 2nd. + */ + { + const SuballocationVectorType& suballocations2nd = AccessSuballocations2nd(); + const VmaSuballocation& topSuballoc2nd = suballocations2nd.back(); + const VmaSuballocation& lastSuballoc1st = suballocations1st.back(); + return topSuballoc2nd.offset - (lastSuballoc1st.offset + lastSuballoc1st.size); + } + break; + + default: + VMA_ASSERT(0); + return 0; + } +} + +void VmaBlockMetadata_Linear::CalcAllocationStatInfo(VmaStatInfo& outInfo) const +{ + const VkDeviceSize size = GetSize(); + const SuballocationVectorType& suballocations1st = AccessSuballocations1st(); + const SuballocationVectorType& suballocations2nd = AccessSuballocations2nd(); + const size_t suballoc1stCount = suballocations1st.size(); + const size_t suballoc2ndCount = suballocations2nd.size(); + + outInfo.blockCount = 1; + outInfo.allocationCount = (uint32_t)GetAllocationCount(); + outInfo.unusedRangeCount = 0; + outInfo.usedBytes = 0; + outInfo.allocationSizeMin = UINT64_MAX; + outInfo.allocationSizeMax = 0; + outInfo.unusedRangeSizeMin = UINT64_MAX; + outInfo.unusedRangeSizeMax = 0; + + VkDeviceSize lastOffset = 0; + + if(m_2ndVectorMode == SECOND_VECTOR_RING_BUFFER) + { + const VkDeviceSize freeSpace2ndTo1stEnd = suballocations1st[m_1stNullItemsBeginCount].offset; + size_t nextAlloc2ndIndex = 0; + while(lastOffset < freeSpace2ndTo1stEnd) + { + // Find next non-null allocation or move nextAllocIndex to the end. + while(nextAlloc2ndIndex < suballoc2ndCount && + suballocations2nd[nextAlloc2ndIndex].hAllocation == VK_NULL_HANDLE) + { + ++nextAlloc2ndIndex; + } + + // Found non-null allocation. + if(nextAlloc2ndIndex < suballoc2ndCount) + { + const VmaSuballocation& suballoc = suballocations2nd[nextAlloc2ndIndex]; + + // 1. Process free space before this allocation. + if(lastOffset < suballoc.offset) + { + // There is free space from lastOffset to suballoc.offset. + const VkDeviceSize unusedRangeSize = suballoc.offset - lastOffset; + ++outInfo.unusedRangeCount; + outInfo.unusedBytes += unusedRangeSize; + outInfo.unusedRangeSizeMin = VMA_MIN(outInfo.unusedRangeSizeMin, unusedRangeSize); + outInfo.unusedRangeSizeMax = VMA_MIN(outInfo.unusedRangeSizeMax, unusedRangeSize); + } + + // 2. Process this allocation. + // There is allocation with suballoc.offset, suballoc.size. + outInfo.usedBytes += suballoc.size; + outInfo.allocationSizeMin = VMA_MIN(outInfo.allocationSizeMin, suballoc.size); + outInfo.allocationSizeMax = VMA_MIN(outInfo.allocationSizeMax, suballoc.size); + + // 3. Prepare for next iteration. + lastOffset = suballoc.offset + suballoc.size; + ++nextAlloc2ndIndex; + } + // We are at the end. + else + { + // There is free space from lastOffset to freeSpace2ndTo1stEnd. + if(lastOffset < freeSpace2ndTo1stEnd) + { + const VkDeviceSize unusedRangeSize = freeSpace2ndTo1stEnd - lastOffset; + ++outInfo.unusedRangeCount; + outInfo.unusedBytes += unusedRangeSize; + outInfo.unusedRangeSizeMin = VMA_MIN(outInfo.unusedRangeSizeMin, unusedRangeSize); + outInfo.unusedRangeSizeMax = VMA_MIN(outInfo.unusedRangeSizeMax, unusedRangeSize); + } + + // End of loop. + lastOffset = freeSpace2ndTo1stEnd; + } + } + } + + size_t nextAlloc1stIndex = m_1stNullItemsBeginCount; + const VkDeviceSize freeSpace1stTo2ndEnd = + m_2ndVectorMode == SECOND_VECTOR_DOUBLE_STACK ? suballocations2nd.back().offset : size; + while(lastOffset < freeSpace1stTo2ndEnd) + { + // Find next non-null allocation or move nextAllocIndex to the end. + while(nextAlloc1stIndex < suballoc1stCount && + suballocations1st[nextAlloc1stIndex].hAllocation == VK_NULL_HANDLE) + { + ++nextAlloc1stIndex; + } + + // Found non-null allocation. + if(nextAlloc1stIndex < suballoc1stCount) + { + const VmaSuballocation& suballoc = suballocations1st[nextAlloc1stIndex]; + + // 1. Process free space before this allocation. + if(lastOffset < suballoc.offset) + { + // There is free space from lastOffset to suballoc.offset. + const VkDeviceSize unusedRangeSize = suballoc.offset - lastOffset; + ++outInfo.unusedRangeCount; + outInfo.unusedBytes += unusedRangeSize; + outInfo.unusedRangeSizeMin = VMA_MIN(outInfo.unusedRangeSizeMin, unusedRangeSize); + outInfo.unusedRangeSizeMax = VMA_MIN(outInfo.unusedRangeSizeMax, unusedRangeSize); + } + + // 2. Process this allocation. + // There is allocation with suballoc.offset, suballoc.size. + outInfo.usedBytes += suballoc.size; + outInfo.allocationSizeMin = VMA_MIN(outInfo.allocationSizeMin, suballoc.size); + outInfo.allocationSizeMax = VMA_MIN(outInfo.allocationSizeMax, suballoc.size); + + // 3. Prepare for next iteration. + lastOffset = suballoc.offset + suballoc.size; + ++nextAlloc1stIndex; + } + // We are at the end. + else + { + // There is free space from lastOffset to freeSpace1stTo2ndEnd. + if(lastOffset < freeSpace1stTo2ndEnd) + { + const VkDeviceSize unusedRangeSize = freeSpace1stTo2ndEnd - lastOffset; + ++outInfo.unusedRangeCount; + outInfo.unusedBytes += unusedRangeSize; + outInfo.unusedRangeSizeMin = VMA_MIN(outInfo.unusedRangeSizeMin, unusedRangeSize); + outInfo.unusedRangeSizeMax = VMA_MIN(outInfo.unusedRangeSizeMax, unusedRangeSize); + } + + // End of loop. + lastOffset = freeSpace1stTo2ndEnd; + } + } + + if(m_2ndVectorMode == SECOND_VECTOR_DOUBLE_STACK) + { + size_t nextAlloc2ndIndex = suballocations2nd.size() - 1; + while(lastOffset < size) + { + // Find next non-null allocation or move nextAllocIndex to the end. + while(nextAlloc2ndIndex != SIZE_MAX && + suballocations2nd[nextAlloc2ndIndex].hAllocation == VK_NULL_HANDLE) + { + --nextAlloc2ndIndex; + } + + // Found non-null allocation. + if(nextAlloc2ndIndex != SIZE_MAX) + { + const VmaSuballocation& suballoc = suballocations2nd[nextAlloc2ndIndex]; + + // 1. Process free space before this allocation. + if(lastOffset < suballoc.offset) + { + // There is free space from lastOffset to suballoc.offset. + const VkDeviceSize unusedRangeSize = suballoc.offset - lastOffset; + ++outInfo.unusedRangeCount; + outInfo.unusedBytes += unusedRangeSize; + outInfo.unusedRangeSizeMin = VMA_MIN(outInfo.unusedRangeSizeMin, unusedRangeSize); + outInfo.unusedRangeSizeMax = VMA_MIN(outInfo.unusedRangeSizeMax, unusedRangeSize); + } + + // 2. Process this allocation. + // There is allocation with suballoc.offset, suballoc.size. + outInfo.usedBytes += suballoc.size; + outInfo.allocationSizeMin = VMA_MIN(outInfo.allocationSizeMin, suballoc.size); + outInfo.allocationSizeMax = VMA_MIN(outInfo.allocationSizeMax, suballoc.size); + + // 3. Prepare for next iteration. + lastOffset = suballoc.offset + suballoc.size; + --nextAlloc2ndIndex; + } + // We are at the end. + else + { + // There is free space from lastOffset to size. + if(lastOffset < size) + { + const VkDeviceSize unusedRangeSize = size - lastOffset; + ++outInfo.unusedRangeCount; + outInfo.unusedBytes += unusedRangeSize; + outInfo.unusedRangeSizeMin = VMA_MIN(outInfo.unusedRangeSizeMin, unusedRangeSize); + outInfo.unusedRangeSizeMax = VMA_MIN(outInfo.unusedRangeSizeMax, unusedRangeSize); + } + + // End of loop. + lastOffset = size; + } + } + } + + outInfo.unusedBytes = size - outInfo.usedBytes; +} + +void VmaBlockMetadata_Linear::AddPoolStats(VmaPoolStats& inoutStats) const +{ + const SuballocationVectorType& suballocations1st = AccessSuballocations1st(); + const SuballocationVectorType& suballocations2nd = AccessSuballocations2nd(); + const VkDeviceSize size = GetSize(); + const size_t suballoc1stCount = suballocations1st.size(); + const size_t suballoc2ndCount = suballocations2nd.size(); + + inoutStats.size += size; + + VkDeviceSize lastOffset = 0; + + if(m_2ndVectorMode == SECOND_VECTOR_RING_BUFFER) + { + const VkDeviceSize freeSpace2ndTo1stEnd = suballocations1st[m_1stNullItemsBeginCount].offset; + size_t nextAlloc2ndIndex = m_1stNullItemsBeginCount; + while(lastOffset < freeSpace2ndTo1stEnd) + { + // Find next non-null allocation or move nextAlloc2ndIndex to the end. + while(nextAlloc2ndIndex < suballoc2ndCount && + suballocations2nd[nextAlloc2ndIndex].hAllocation == VK_NULL_HANDLE) + { + ++nextAlloc2ndIndex; + } + + // Found non-null allocation. + if(nextAlloc2ndIndex < suballoc2ndCount) + { + const VmaSuballocation& suballoc = suballocations2nd[nextAlloc2ndIndex]; + + // 1. Process free space before this allocation. + if(lastOffset < suballoc.offset) + { + // There is free space from lastOffset to suballoc.offset. + const VkDeviceSize unusedRangeSize = suballoc.offset - lastOffset; + inoutStats.unusedSize += unusedRangeSize; + ++inoutStats.unusedRangeCount; + inoutStats.unusedRangeSizeMax = VMA_MAX(inoutStats.unusedRangeSizeMax, unusedRangeSize); + } + + // 2. Process this allocation. + // There is allocation with suballoc.offset, suballoc.size. + ++inoutStats.allocationCount; + + // 3. Prepare for next iteration. + lastOffset = suballoc.offset + suballoc.size; + ++nextAlloc2ndIndex; + } + // We are at the end. + else + { + if(lastOffset < freeSpace2ndTo1stEnd) + { + // There is free space from lastOffset to freeSpace2ndTo1stEnd. + const VkDeviceSize unusedRangeSize = freeSpace2ndTo1stEnd - lastOffset; + inoutStats.unusedSize += unusedRangeSize; + ++inoutStats.unusedRangeCount; + inoutStats.unusedRangeSizeMax = VMA_MAX(inoutStats.unusedRangeSizeMax, unusedRangeSize); + } + + // End of loop. + lastOffset = freeSpace2ndTo1stEnd; + } + } + } + + size_t nextAlloc1stIndex = m_1stNullItemsBeginCount; + const VkDeviceSize freeSpace1stTo2ndEnd = + m_2ndVectorMode == SECOND_VECTOR_DOUBLE_STACK ? suballocations2nd.back().offset : size; + while(lastOffset < freeSpace1stTo2ndEnd) + { + // Find next non-null allocation or move nextAllocIndex to the end. + while(nextAlloc1stIndex < suballoc1stCount && + suballocations1st[nextAlloc1stIndex].hAllocation == VK_NULL_HANDLE) + { + ++nextAlloc1stIndex; + } + + // Found non-null allocation. + if(nextAlloc1stIndex < suballoc1stCount) + { + const VmaSuballocation& suballoc = suballocations1st[nextAlloc1stIndex]; + + // 1. Process free space before this allocation. + if(lastOffset < suballoc.offset) + { + // There is free space from lastOffset to suballoc.offset. + const VkDeviceSize unusedRangeSize = suballoc.offset - lastOffset; + inoutStats.unusedSize += unusedRangeSize; + ++inoutStats.unusedRangeCount; + inoutStats.unusedRangeSizeMax = VMA_MAX(inoutStats.unusedRangeSizeMax, unusedRangeSize); + } + + // 2. Process this allocation. + // There is allocation with suballoc.offset, suballoc.size. + ++inoutStats.allocationCount; + + // 3. Prepare for next iteration. + lastOffset = suballoc.offset + suballoc.size; + ++nextAlloc1stIndex; + } + // We are at the end. + else + { + if(lastOffset < freeSpace1stTo2ndEnd) + { + // There is free space from lastOffset to freeSpace1stTo2ndEnd. + const VkDeviceSize unusedRangeSize = freeSpace1stTo2ndEnd - lastOffset; + inoutStats.unusedSize += unusedRangeSize; + ++inoutStats.unusedRangeCount; + inoutStats.unusedRangeSizeMax = VMA_MAX(inoutStats.unusedRangeSizeMax, unusedRangeSize); + } + + // End of loop. + lastOffset = freeSpace1stTo2ndEnd; + } + } + + if(m_2ndVectorMode == SECOND_VECTOR_DOUBLE_STACK) + { + size_t nextAlloc2ndIndex = suballocations2nd.size() - 1; + while(lastOffset < size) + { + // Find next non-null allocation or move nextAlloc2ndIndex to the end. + while(nextAlloc2ndIndex != SIZE_MAX && + suballocations2nd[nextAlloc2ndIndex].hAllocation == VK_NULL_HANDLE) + { + --nextAlloc2ndIndex; + } + + // Found non-null allocation. + if(nextAlloc2ndIndex != SIZE_MAX) + { + const VmaSuballocation& suballoc = suballocations2nd[nextAlloc2ndIndex]; + + // 1. Process free space before this allocation. + if(lastOffset < suballoc.offset) + { + // There is free space from lastOffset to suballoc.offset. + const VkDeviceSize unusedRangeSize = suballoc.offset - lastOffset; + inoutStats.unusedSize += unusedRangeSize; + ++inoutStats.unusedRangeCount; + inoutStats.unusedRangeSizeMax = VMA_MAX(inoutStats.unusedRangeSizeMax, unusedRangeSize); + } + + // 2. Process this allocation. + // There is allocation with suballoc.offset, suballoc.size. + ++inoutStats.allocationCount; + + // 3. Prepare for next iteration. + lastOffset = suballoc.offset + suballoc.size; + --nextAlloc2ndIndex; + } + // We are at the end. + else + { + if(lastOffset < size) + { + // There is free space from lastOffset to size. + const VkDeviceSize unusedRangeSize = size - lastOffset; + inoutStats.unusedSize += unusedRangeSize; + ++inoutStats.unusedRangeCount; + inoutStats.unusedRangeSizeMax = VMA_MAX(inoutStats.unusedRangeSizeMax, unusedRangeSize); + } + + // End of loop. + lastOffset = size; + } + } + } +} + +#if VMA_STATS_STRING_ENABLED +void VmaBlockMetadata_Linear::PrintDetailedMap(class VmaJsonWriter& json) const +{ + const VkDeviceSize size = GetSize(); + const SuballocationVectorType& suballocations1st = AccessSuballocations1st(); + const SuballocationVectorType& suballocations2nd = AccessSuballocations2nd(); + const size_t suballoc1stCount = suballocations1st.size(); + const size_t suballoc2ndCount = suballocations2nd.size(); + + // FIRST PASS + + size_t unusedRangeCount = 0; + VkDeviceSize usedBytes = 0; + + VkDeviceSize lastOffset = 0; + + size_t alloc2ndCount = 0; + if(m_2ndVectorMode == SECOND_VECTOR_RING_BUFFER) + { + const VkDeviceSize freeSpace2ndTo1stEnd = suballocations1st[m_1stNullItemsBeginCount].offset; + size_t nextAlloc2ndIndex = 0; + while(lastOffset < freeSpace2ndTo1stEnd) + { + // Find next non-null allocation or move nextAlloc2ndIndex to the end. + while(nextAlloc2ndIndex < suballoc2ndCount && + suballocations2nd[nextAlloc2ndIndex].hAllocation == VK_NULL_HANDLE) + { + ++nextAlloc2ndIndex; + } + + // Found non-null allocation. + if(nextAlloc2ndIndex < suballoc2ndCount) + { + const VmaSuballocation& suballoc = suballocations2nd[nextAlloc2ndIndex]; + + // 1. Process free space before this allocation. + if(lastOffset < suballoc.offset) + { + // There is free space from lastOffset to suballoc.offset. + ++unusedRangeCount; + } + + // 2. Process this allocation. + // There is allocation with suballoc.offset, suballoc.size. + ++alloc2ndCount; + usedBytes += suballoc.size; + + // 3. Prepare for next iteration. + lastOffset = suballoc.offset + suballoc.size; + ++nextAlloc2ndIndex; + } + // We are at the end. + else + { + if(lastOffset < freeSpace2ndTo1stEnd) + { + // There is free space from lastOffset to freeSpace2ndTo1stEnd. + ++unusedRangeCount; + } + + // End of loop. + lastOffset = freeSpace2ndTo1stEnd; + } + } + } + + size_t nextAlloc1stIndex = m_1stNullItemsBeginCount; + size_t alloc1stCount = 0; + const VkDeviceSize freeSpace1stTo2ndEnd = + m_2ndVectorMode == SECOND_VECTOR_DOUBLE_STACK ? suballocations2nd.back().offset : size; + while(lastOffset < freeSpace1stTo2ndEnd) + { + // Find next non-null allocation or move nextAllocIndex to the end. + while(nextAlloc1stIndex < suballoc1stCount && + suballocations1st[nextAlloc1stIndex].hAllocation == VK_NULL_HANDLE) + { + ++nextAlloc1stIndex; + } + + // Found non-null allocation. + if(nextAlloc1stIndex < suballoc1stCount) + { + const VmaSuballocation& suballoc = suballocations1st[nextAlloc1stIndex]; + + // 1. Process free space before this allocation. + if(lastOffset < suballoc.offset) + { + // There is free space from lastOffset to suballoc.offset. + ++unusedRangeCount; + } + + // 2. Process this allocation. + // There is allocation with suballoc.offset, suballoc.size. + ++alloc1stCount; + usedBytes += suballoc.size; + + // 3. Prepare for next iteration. + lastOffset = suballoc.offset + suballoc.size; + ++nextAlloc1stIndex; + } + // We are at the end. + else + { + if(lastOffset < size) + { + // There is free space from lastOffset to freeSpace1stTo2ndEnd. + ++unusedRangeCount; + } + + // End of loop. + lastOffset = freeSpace1stTo2ndEnd; + } + } + + if(m_2ndVectorMode == SECOND_VECTOR_DOUBLE_STACK) + { + size_t nextAlloc2ndIndex = suballocations2nd.size() - 1; + while(lastOffset < size) + { + // Find next non-null allocation or move nextAlloc2ndIndex to the end. + while(nextAlloc2ndIndex != SIZE_MAX && + suballocations2nd[nextAlloc2ndIndex].hAllocation == VK_NULL_HANDLE) + { + --nextAlloc2ndIndex; + } + + // Found non-null allocation. + if(nextAlloc2ndIndex != SIZE_MAX) + { + const VmaSuballocation& suballoc = suballocations2nd[nextAlloc2ndIndex]; + + // 1. Process free space before this allocation. + if(lastOffset < suballoc.offset) + { + // There is free space from lastOffset to suballoc.offset. + ++unusedRangeCount; + } + + // 2. Process this allocation. + // There is allocation with suballoc.offset, suballoc.size. + ++alloc2ndCount; + usedBytes += suballoc.size; + + // 3. Prepare for next iteration. + lastOffset = suballoc.offset + suballoc.size; + --nextAlloc2ndIndex; + } + // We are at the end. + else + { + if(lastOffset < size) + { + // There is free space from lastOffset to size. + ++unusedRangeCount; + } + + // End of loop. + lastOffset = size; + } + } + } + + const VkDeviceSize unusedBytes = size - usedBytes; + PrintDetailedMap_Begin(json, unusedBytes, alloc1stCount + alloc2ndCount, unusedRangeCount); + + // SECOND PASS + lastOffset = 0; + + if(m_2ndVectorMode == SECOND_VECTOR_RING_BUFFER) + { + const VkDeviceSize freeSpace2ndTo1stEnd = suballocations1st[m_1stNullItemsBeginCount].offset; + size_t nextAlloc2ndIndex = 0; + while(lastOffset < freeSpace2ndTo1stEnd) + { + // Find next non-null allocation or move nextAlloc2ndIndex to the end. + while(nextAlloc2ndIndex < suballoc2ndCount && + suballocations2nd[nextAlloc2ndIndex].hAllocation == VK_NULL_HANDLE) + { + ++nextAlloc2ndIndex; + } + + // Found non-null allocation. + if(nextAlloc2ndIndex < suballoc2ndCount) + { + const VmaSuballocation& suballoc = suballocations2nd[nextAlloc2ndIndex]; + + // 1. Process free space before this allocation. + if(lastOffset < suballoc.offset) + { + // There is free space from lastOffset to suballoc.offset. + const VkDeviceSize unusedRangeSize = suballoc.offset - lastOffset; + PrintDetailedMap_UnusedRange(json, lastOffset, unusedRangeSize); + } + + // 2. Process this allocation. + // There is allocation with suballoc.offset, suballoc.size. + PrintDetailedMap_Allocation(json, suballoc.offset, suballoc.hAllocation); + + // 3. Prepare for next iteration. + lastOffset = suballoc.offset + suballoc.size; + ++nextAlloc2ndIndex; + } + // We are at the end. + else + { + if(lastOffset < freeSpace2ndTo1stEnd) + { + // There is free space from lastOffset to freeSpace2ndTo1stEnd. + const VkDeviceSize unusedRangeSize = freeSpace2ndTo1stEnd - lastOffset; + PrintDetailedMap_UnusedRange(json, lastOffset, unusedRangeSize); + } + + // End of loop. + lastOffset = freeSpace2ndTo1stEnd; + } + } + } + + nextAlloc1stIndex = m_1stNullItemsBeginCount; + while(lastOffset < freeSpace1stTo2ndEnd) + { + // Find next non-null allocation or move nextAllocIndex to the end. + while(nextAlloc1stIndex < suballoc1stCount && + suballocations1st[nextAlloc1stIndex].hAllocation == VK_NULL_HANDLE) + { + ++nextAlloc1stIndex; + } + + // Found non-null allocation. + if(nextAlloc1stIndex < suballoc1stCount) + { + const VmaSuballocation& suballoc = suballocations1st[nextAlloc1stIndex]; + + // 1. Process free space before this allocation. + if(lastOffset < suballoc.offset) + { + // There is free space from lastOffset to suballoc.offset. + const VkDeviceSize unusedRangeSize = suballoc.offset - lastOffset; + PrintDetailedMap_UnusedRange(json, lastOffset, unusedRangeSize); + } + + // 2. Process this allocation. + // There is allocation with suballoc.offset, suballoc.size. + PrintDetailedMap_Allocation(json, suballoc.offset, suballoc.hAllocation); + + // 3. Prepare for next iteration. + lastOffset = suballoc.offset + suballoc.size; + ++nextAlloc1stIndex; + } + // We are at the end. + else + { + if(lastOffset < freeSpace1stTo2ndEnd) + { + // There is free space from lastOffset to freeSpace1stTo2ndEnd. + const VkDeviceSize unusedRangeSize = freeSpace1stTo2ndEnd - lastOffset; + PrintDetailedMap_UnusedRange(json, lastOffset, unusedRangeSize); + } + + // End of loop. + lastOffset = freeSpace1stTo2ndEnd; + } + } + + if(m_2ndVectorMode == SECOND_VECTOR_DOUBLE_STACK) + { + size_t nextAlloc2ndIndex = suballocations2nd.size() - 1; + while(lastOffset < size) + { + // Find next non-null allocation or move nextAlloc2ndIndex to the end. + while(nextAlloc2ndIndex != SIZE_MAX && + suballocations2nd[nextAlloc2ndIndex].hAllocation == VK_NULL_HANDLE) + { + --nextAlloc2ndIndex; + } + + // Found non-null allocation. + if(nextAlloc2ndIndex != SIZE_MAX) + { + const VmaSuballocation& suballoc = suballocations2nd[nextAlloc2ndIndex]; + + // 1. Process free space before this allocation. + if(lastOffset < suballoc.offset) + { + // There is free space from lastOffset to suballoc.offset. + const VkDeviceSize unusedRangeSize = suballoc.offset - lastOffset; + PrintDetailedMap_UnusedRange(json, lastOffset, unusedRangeSize); + } + + // 2. Process this allocation. + // There is allocation with suballoc.offset, suballoc.size. + PrintDetailedMap_Allocation(json, suballoc.offset, suballoc.hAllocation); + + // 3. Prepare for next iteration. + lastOffset = suballoc.offset + suballoc.size; + --nextAlloc2ndIndex; + } + // We are at the end. + else + { + if(lastOffset < size) + { + // There is free space from lastOffset to size. + const VkDeviceSize unusedRangeSize = size - lastOffset; + PrintDetailedMap_UnusedRange(json, lastOffset, unusedRangeSize); + } + + // End of loop. + lastOffset = size; + } + } + } + + PrintDetailedMap_End(json); +} +#endif // #if VMA_STATS_STRING_ENABLED + +bool VmaBlockMetadata_Linear::CreateAllocationRequest( + uint32_t currentFrameIndex, + uint32_t frameInUseCount, + VkDeviceSize bufferImageGranularity, + VkDeviceSize allocSize, + VkDeviceSize allocAlignment, + bool upperAddress, + VmaSuballocationType allocType, + bool canMakeOtherLost, + uint32_t strategy, + VmaAllocationRequest* pAllocationRequest) +{ + VMA_ASSERT(allocSize > 0); + VMA_ASSERT(allocType != VMA_SUBALLOCATION_TYPE_FREE); + VMA_ASSERT(pAllocationRequest != VMA_NULL); + VMA_HEAVY_ASSERT(Validate()); + return upperAddress ? + CreateAllocationRequest_UpperAddress( + currentFrameIndex, frameInUseCount, bufferImageGranularity, + allocSize, allocAlignment, allocType, canMakeOtherLost, strategy, pAllocationRequest) : + CreateAllocationRequest_LowerAddress( + currentFrameIndex, frameInUseCount, bufferImageGranularity, + allocSize, allocAlignment, allocType, canMakeOtherLost, strategy, pAllocationRequest); +} + +bool VmaBlockMetadata_Linear::CreateAllocationRequest_UpperAddress( + uint32_t currentFrameIndex, + uint32_t frameInUseCount, + VkDeviceSize bufferImageGranularity, + VkDeviceSize allocSize, + VkDeviceSize allocAlignment, + VmaSuballocationType allocType, + bool canMakeOtherLost, + uint32_t strategy, + VmaAllocationRequest* pAllocationRequest) +{ + const VkDeviceSize size = GetSize(); + SuballocationVectorType& suballocations1st = AccessSuballocations1st(); + SuballocationVectorType& suballocations2nd = AccessSuballocations2nd(); + + if(m_2ndVectorMode == SECOND_VECTOR_RING_BUFFER) + { + VMA_ASSERT(0 && "Trying to use pool with linear algorithm as double stack, while it is already being used as ring buffer."); + return false; + } + + // Try to allocate before 2nd.back(), or end of block if 2nd.empty(). + if(allocSize > size) + { + return false; + } + VkDeviceSize resultBaseOffset = size - allocSize; + if(!suballocations2nd.empty()) + { + const VmaSuballocation& lastSuballoc = suballocations2nd.back(); + resultBaseOffset = lastSuballoc.offset - allocSize; + if(allocSize > lastSuballoc.offset) + { + return false; + } + } + + // Start from offset equal to end of free space. + VkDeviceSize resultOffset = resultBaseOffset; + + // Apply VMA_DEBUG_MARGIN at the end. + if(VMA_DEBUG_MARGIN > 0) + { + if(resultOffset < VMA_DEBUG_MARGIN) + { + return false; + } + resultOffset -= VMA_DEBUG_MARGIN; + } + + // Apply alignment. + resultOffset = VmaAlignDown(resultOffset, allocAlignment); + + // Check next suballocations from 2nd for BufferImageGranularity conflicts. + // Make bigger alignment if necessary. + if(bufferImageGranularity > 1 && !suballocations2nd.empty()) + { + bool bufferImageGranularityConflict = false; + for(size_t nextSuballocIndex = suballocations2nd.size(); nextSuballocIndex--; ) + { + const VmaSuballocation& nextSuballoc = suballocations2nd[nextSuballocIndex]; + if(VmaBlocksOnSamePage(resultOffset, allocSize, nextSuballoc.offset, bufferImageGranularity)) + { + if(VmaIsBufferImageGranularityConflict(nextSuballoc.type, allocType)) + { + bufferImageGranularityConflict = true; + break; + } + } + else + // Already on previous page. + break; + } + if(bufferImageGranularityConflict) + { + resultOffset = VmaAlignDown(resultOffset, bufferImageGranularity); + } + } + + // There is enough free space. + const VkDeviceSize endOf1st = !suballocations1st.empty() ? + suballocations1st.back().offset + suballocations1st.back().size : + 0; + if(endOf1st + VMA_DEBUG_MARGIN <= resultOffset) + { + // Check previous suballocations for BufferImageGranularity conflicts. + // If conflict exists, allocation cannot be made here. + if(bufferImageGranularity > 1) + { + for(size_t prevSuballocIndex = suballocations1st.size(); prevSuballocIndex--; ) + { + const VmaSuballocation& prevSuballoc = suballocations1st[prevSuballocIndex]; + if(VmaBlocksOnSamePage(prevSuballoc.offset, prevSuballoc.size, resultOffset, bufferImageGranularity)) + { + if(VmaIsBufferImageGranularityConflict(allocType, prevSuballoc.type)) + { + return false; + } + } + else + { + // Already on next page. + break; + } + } + } + + // All tests passed: Success. + pAllocationRequest->offset = resultOffset; + pAllocationRequest->sumFreeSize = resultBaseOffset + allocSize - endOf1st; + pAllocationRequest->sumItemSize = 0; + // pAllocationRequest->item unused. + pAllocationRequest->itemsToMakeLostCount = 0; + pAllocationRequest->type = VmaAllocationRequestType::UpperAddress; + return true; + } + + return false; +} + +bool VmaBlockMetadata_Linear::CreateAllocationRequest_LowerAddress( + uint32_t currentFrameIndex, + uint32_t frameInUseCount, + VkDeviceSize bufferImageGranularity, + VkDeviceSize allocSize, + VkDeviceSize allocAlignment, + VmaSuballocationType allocType, + bool canMakeOtherLost, + uint32_t strategy, + VmaAllocationRequest* pAllocationRequest) +{ + const VkDeviceSize size = GetSize(); + SuballocationVectorType& suballocations1st = AccessSuballocations1st(); + SuballocationVectorType& suballocations2nd = AccessSuballocations2nd(); + + if(m_2ndVectorMode == SECOND_VECTOR_EMPTY || m_2ndVectorMode == SECOND_VECTOR_DOUBLE_STACK) + { + // Try to allocate at the end of 1st vector. + + VkDeviceSize resultBaseOffset = 0; + if(!suballocations1st.empty()) + { + const VmaSuballocation& lastSuballoc = suballocations1st.back(); + resultBaseOffset = lastSuballoc.offset + lastSuballoc.size; + } + + // Start from offset equal to beginning of free space. + VkDeviceSize resultOffset = resultBaseOffset; + + // Apply VMA_DEBUG_MARGIN at the beginning. + if(VMA_DEBUG_MARGIN > 0) + { + resultOffset += VMA_DEBUG_MARGIN; + } + + // Apply alignment. + resultOffset = VmaAlignUp(resultOffset, allocAlignment); + + // Check previous suballocations for BufferImageGranularity conflicts. + // Make bigger alignment if necessary. + if(bufferImageGranularity > 1 && !suballocations1st.empty()) + { + bool bufferImageGranularityConflict = false; + for(size_t prevSuballocIndex = suballocations1st.size(); prevSuballocIndex--; ) + { + const VmaSuballocation& prevSuballoc = suballocations1st[prevSuballocIndex]; + if(VmaBlocksOnSamePage(prevSuballoc.offset, prevSuballoc.size, resultOffset, bufferImageGranularity)) + { + if(VmaIsBufferImageGranularityConflict(prevSuballoc.type, allocType)) + { + bufferImageGranularityConflict = true; + break; + } + } + else + // Already on previous page. + break; + } + if(bufferImageGranularityConflict) + { + resultOffset = VmaAlignUp(resultOffset, bufferImageGranularity); + } + } + + const VkDeviceSize freeSpaceEnd = m_2ndVectorMode == SECOND_VECTOR_DOUBLE_STACK ? + suballocations2nd.back().offset : size; + + // There is enough free space at the end after alignment. + if(resultOffset + allocSize + VMA_DEBUG_MARGIN <= freeSpaceEnd) + { + // Check next suballocations for BufferImageGranularity conflicts. + // If conflict exists, allocation cannot be made here. + if(bufferImageGranularity > 1 && m_2ndVectorMode == SECOND_VECTOR_DOUBLE_STACK) + { + for(size_t nextSuballocIndex = suballocations2nd.size(); nextSuballocIndex--; ) + { + const VmaSuballocation& nextSuballoc = suballocations2nd[nextSuballocIndex]; + if(VmaBlocksOnSamePage(resultOffset, allocSize, nextSuballoc.offset, bufferImageGranularity)) + { + if(VmaIsBufferImageGranularityConflict(allocType, nextSuballoc.type)) + { + return false; + } + } + else + { + // Already on previous page. + break; + } + } + } + + // All tests passed: Success. + pAllocationRequest->offset = resultOffset; + pAllocationRequest->sumFreeSize = freeSpaceEnd - resultBaseOffset; + pAllocationRequest->sumItemSize = 0; + // pAllocationRequest->item, customData unused. + pAllocationRequest->type = VmaAllocationRequestType::EndOf1st; + pAllocationRequest->itemsToMakeLostCount = 0; + return true; + } + } + + // Wrap-around to end of 2nd vector. Try to allocate there, watching for the + // beginning of 1st vector as the end of free space. + if(m_2ndVectorMode == SECOND_VECTOR_EMPTY || m_2ndVectorMode == SECOND_VECTOR_RING_BUFFER) + { + VMA_ASSERT(!suballocations1st.empty()); + + VkDeviceSize resultBaseOffset = 0; + if(!suballocations2nd.empty()) + { + const VmaSuballocation& lastSuballoc = suballocations2nd.back(); + resultBaseOffset = lastSuballoc.offset + lastSuballoc.size; + } + + // Start from offset equal to beginning of free space. + VkDeviceSize resultOffset = resultBaseOffset; + + // Apply VMA_DEBUG_MARGIN at the beginning. + if(VMA_DEBUG_MARGIN > 0) + { + resultOffset += VMA_DEBUG_MARGIN; + } + + // Apply alignment. + resultOffset = VmaAlignUp(resultOffset, allocAlignment); + + // Check previous suballocations for BufferImageGranularity conflicts. + // Make bigger alignment if necessary. + if(bufferImageGranularity > 1 && !suballocations2nd.empty()) + { + bool bufferImageGranularityConflict = false; + for(size_t prevSuballocIndex = suballocations2nd.size(); prevSuballocIndex--; ) + { + const VmaSuballocation& prevSuballoc = suballocations2nd[prevSuballocIndex]; + if(VmaBlocksOnSamePage(prevSuballoc.offset, prevSuballoc.size, resultOffset, bufferImageGranularity)) + { + if(VmaIsBufferImageGranularityConflict(prevSuballoc.type, allocType)) + { + bufferImageGranularityConflict = true; + break; + } + } + else + // Already on previous page. + break; + } + if(bufferImageGranularityConflict) + { + resultOffset = VmaAlignUp(resultOffset, bufferImageGranularity); + } + } + + pAllocationRequest->itemsToMakeLostCount = 0; + pAllocationRequest->sumItemSize = 0; + size_t index1st = m_1stNullItemsBeginCount; + + if(canMakeOtherLost) + { + while(index1st < suballocations1st.size() && + resultOffset + allocSize + VMA_DEBUG_MARGIN > suballocations1st[index1st].offset) + { + // Next colliding allocation at the beginning of 1st vector found. Try to make it lost. + const VmaSuballocation& suballoc = suballocations1st[index1st]; + if(suballoc.type == VMA_SUBALLOCATION_TYPE_FREE) + { + // No problem. + } + else + { + VMA_ASSERT(suballoc.hAllocation != VK_NULL_HANDLE); + if(suballoc.hAllocation->CanBecomeLost() && + suballoc.hAllocation->GetLastUseFrameIndex() + frameInUseCount < currentFrameIndex) + { + ++pAllocationRequest->itemsToMakeLostCount; + pAllocationRequest->sumItemSize += suballoc.size; + } + else + { + return false; + } + } + ++index1st; + } + + // Check next suballocations for BufferImageGranularity conflicts. + // If conflict exists, we must mark more allocations lost or fail. + if(bufferImageGranularity > 1) + { + while(index1st < suballocations1st.size()) + { + const VmaSuballocation& suballoc = suballocations1st[index1st]; + if(VmaBlocksOnSamePage(resultOffset, allocSize, suballoc.offset, bufferImageGranularity)) + { + if(suballoc.hAllocation != VK_NULL_HANDLE) + { + // Not checking actual VmaIsBufferImageGranularityConflict(allocType, suballoc.type). + if(suballoc.hAllocation->CanBecomeLost() && + suballoc.hAllocation->GetLastUseFrameIndex() + frameInUseCount < currentFrameIndex) + { + ++pAllocationRequest->itemsToMakeLostCount; + pAllocationRequest->sumItemSize += suballoc.size; + } + else + { + return false; + } + } + } + else + { + // Already on next page. + break; + } + ++index1st; + } + } + + // Special case: There is not enough room at the end for this allocation, even after making all from the 1st lost. + if(index1st == suballocations1st.size() && + resultOffset + allocSize + VMA_DEBUG_MARGIN > size) + { + // TODO: This is a known bug that it's not yet implemented and the allocation is failing. + VMA_DEBUG_LOG("Unsupported special case in custom pool with linear allocation algorithm used as ring buffer with allocations that can be lost."); + } + } + + // There is enough free space at the end after alignment. + if((index1st == suballocations1st.size() && resultOffset + allocSize + VMA_DEBUG_MARGIN <= size) || + (index1st < suballocations1st.size() && resultOffset + allocSize + VMA_DEBUG_MARGIN <= suballocations1st[index1st].offset)) + { + // Check next suballocations for BufferImageGranularity conflicts. + // If conflict exists, allocation cannot be made here. + if(bufferImageGranularity > 1) + { + for(size_t nextSuballocIndex = index1st; + nextSuballocIndex < suballocations1st.size(); + nextSuballocIndex++) + { + const VmaSuballocation& nextSuballoc = suballocations1st[nextSuballocIndex]; + if(VmaBlocksOnSamePage(resultOffset, allocSize, nextSuballoc.offset, bufferImageGranularity)) + { + if(VmaIsBufferImageGranularityConflict(allocType, nextSuballoc.type)) + { + return false; + } + } + else + { + // Already on next page. + break; + } + } + } + + // All tests passed: Success. + pAllocationRequest->offset = resultOffset; + pAllocationRequest->sumFreeSize = + (index1st < suballocations1st.size() ? suballocations1st[index1st].offset : size) + - resultBaseOffset + - pAllocationRequest->sumItemSize; + pAllocationRequest->type = VmaAllocationRequestType::EndOf2nd; + // pAllocationRequest->item, customData unused. + return true; + } + } + + return false; +} + +bool VmaBlockMetadata_Linear::MakeRequestedAllocationsLost( + uint32_t currentFrameIndex, + uint32_t frameInUseCount, + VmaAllocationRequest* pAllocationRequest) +{ + if(pAllocationRequest->itemsToMakeLostCount == 0) + { + return true; + } + + VMA_ASSERT(m_2ndVectorMode == SECOND_VECTOR_EMPTY || m_2ndVectorMode == SECOND_VECTOR_RING_BUFFER); + + // We always start from 1st. + SuballocationVectorType* suballocations = &AccessSuballocations1st(); + size_t index = m_1stNullItemsBeginCount; + size_t madeLostCount = 0; + while(madeLostCount < pAllocationRequest->itemsToMakeLostCount) + { + if(index == suballocations->size()) + { + index = 0; + // If we get to the end of 1st, we wrap around to beginning of 2nd of 1st. + if(m_2ndVectorMode == SECOND_VECTOR_RING_BUFFER) + { + suballocations = &AccessSuballocations2nd(); + } + // else: m_2ndVectorMode == SECOND_VECTOR_EMPTY: + // suballocations continues pointing at AccessSuballocations1st(). + VMA_ASSERT(!suballocations->empty()); + } + VmaSuballocation& suballoc = (*suballocations)[index]; + if(suballoc.type != VMA_SUBALLOCATION_TYPE_FREE) + { + VMA_ASSERT(suballoc.hAllocation != VK_NULL_HANDLE); + VMA_ASSERT(suballoc.hAllocation->CanBecomeLost()); + if(suballoc.hAllocation->MakeLost(currentFrameIndex, frameInUseCount)) + { + suballoc.type = VMA_SUBALLOCATION_TYPE_FREE; + suballoc.hAllocation = VK_NULL_HANDLE; + m_SumFreeSize += suballoc.size; + if(suballocations == &AccessSuballocations1st()) + { + ++m_1stNullItemsMiddleCount; + } + else + { + ++m_2ndNullItemsCount; + } + ++madeLostCount; + } + else + { + return false; + } + } + ++index; + } + + CleanupAfterFree(); + //VMA_HEAVY_ASSERT(Validate()); // Already called by ClanupAfterFree(). + + return true; +} + +uint32_t VmaBlockMetadata_Linear::MakeAllocationsLost(uint32_t currentFrameIndex, uint32_t frameInUseCount) +{ + uint32_t lostAllocationCount = 0; + + SuballocationVectorType& suballocations1st = AccessSuballocations1st(); + for(size_t i = m_1stNullItemsBeginCount, count = suballocations1st.size(); i < count; ++i) + { + VmaSuballocation& suballoc = suballocations1st[i]; + if(suballoc.type != VMA_SUBALLOCATION_TYPE_FREE && + suballoc.hAllocation->CanBecomeLost() && + suballoc.hAllocation->MakeLost(currentFrameIndex, frameInUseCount)) + { + suballoc.type = VMA_SUBALLOCATION_TYPE_FREE; + suballoc.hAllocation = VK_NULL_HANDLE; + ++m_1stNullItemsMiddleCount; + m_SumFreeSize += suballoc.size; + ++lostAllocationCount; + } + } + + SuballocationVectorType& suballocations2nd = AccessSuballocations2nd(); + for(size_t i = 0, count = suballocations2nd.size(); i < count; ++i) + { + VmaSuballocation& suballoc = suballocations2nd[i]; + if(suballoc.type != VMA_SUBALLOCATION_TYPE_FREE && + suballoc.hAllocation->CanBecomeLost() && + suballoc.hAllocation->MakeLost(currentFrameIndex, frameInUseCount)) + { + suballoc.type = VMA_SUBALLOCATION_TYPE_FREE; + suballoc.hAllocation = VK_NULL_HANDLE; + ++m_2ndNullItemsCount; + m_SumFreeSize += suballoc.size; + ++lostAllocationCount; + } + } + + if(lostAllocationCount) + { + CleanupAfterFree(); + } + + return lostAllocationCount; +} + +VkResult VmaBlockMetadata_Linear::CheckCorruption(const void* pBlockData) +{ + SuballocationVectorType& suballocations1st = AccessSuballocations1st(); + for(size_t i = m_1stNullItemsBeginCount, count = suballocations1st.size(); i < count; ++i) + { + const VmaSuballocation& suballoc = suballocations1st[i]; + if(suballoc.type != VMA_SUBALLOCATION_TYPE_FREE) + { + if(!VmaValidateMagicValue(pBlockData, suballoc.offset - VMA_DEBUG_MARGIN)) + { + VMA_ASSERT(0 && "MEMORY CORRUPTION DETECTED BEFORE VALIDATED ALLOCATION!"); + return VK_ERROR_VALIDATION_FAILED_EXT; + } + if(!VmaValidateMagicValue(pBlockData, suballoc.offset + suballoc.size)) + { + VMA_ASSERT(0 && "MEMORY CORRUPTION DETECTED AFTER VALIDATED ALLOCATION!"); + return VK_ERROR_VALIDATION_FAILED_EXT; + } + } + } + + SuballocationVectorType& suballocations2nd = AccessSuballocations2nd(); + for(size_t i = 0, count = suballocations2nd.size(); i < count; ++i) + { + const VmaSuballocation& suballoc = suballocations2nd[i]; + if(suballoc.type != VMA_SUBALLOCATION_TYPE_FREE) + { + if(!VmaValidateMagicValue(pBlockData, suballoc.offset - VMA_DEBUG_MARGIN)) + { + VMA_ASSERT(0 && "MEMORY CORRUPTION DETECTED BEFORE VALIDATED ALLOCATION!"); + return VK_ERROR_VALIDATION_FAILED_EXT; + } + if(!VmaValidateMagicValue(pBlockData, suballoc.offset + suballoc.size)) + { + VMA_ASSERT(0 && "MEMORY CORRUPTION DETECTED AFTER VALIDATED ALLOCATION!"); + return VK_ERROR_VALIDATION_FAILED_EXT; + } + } + } + + return VK_SUCCESS; +} + +void VmaBlockMetadata_Linear::Alloc( + const VmaAllocationRequest& request, + VmaSuballocationType type, + VkDeviceSize allocSize, + VmaAllocation hAllocation) +{ + const VmaSuballocation newSuballoc = { request.offset, allocSize, hAllocation, type }; + + switch(request.type) + { + case VmaAllocationRequestType::UpperAddress: + { + VMA_ASSERT(m_2ndVectorMode != SECOND_VECTOR_RING_BUFFER && + "CRITICAL ERROR: Trying to use linear allocator as double stack while it was already used as ring buffer."); + SuballocationVectorType& suballocations2nd = AccessSuballocations2nd(); + suballocations2nd.push_back(newSuballoc); + m_2ndVectorMode = SECOND_VECTOR_DOUBLE_STACK; + } + break; + case VmaAllocationRequestType::EndOf1st: + { + SuballocationVectorType& suballocations1st = AccessSuballocations1st(); + + VMA_ASSERT(suballocations1st.empty() || + request.offset >= suballocations1st.back().offset + suballocations1st.back().size); + // Check if it fits before the end of the block. + VMA_ASSERT(request.offset + allocSize <= GetSize()); + + suballocations1st.push_back(newSuballoc); + } + break; + case VmaAllocationRequestType::EndOf2nd: + { + SuballocationVectorType& suballocations1st = AccessSuballocations1st(); + // New allocation at the end of 2-part ring buffer, so before first allocation from 1st vector. + VMA_ASSERT(!suballocations1st.empty() && + request.offset + allocSize <= suballocations1st[m_1stNullItemsBeginCount].offset); + SuballocationVectorType& suballocations2nd = AccessSuballocations2nd(); + + switch(m_2ndVectorMode) + { + case SECOND_VECTOR_EMPTY: + // First allocation from second part ring buffer. + VMA_ASSERT(suballocations2nd.empty()); + m_2ndVectorMode = SECOND_VECTOR_RING_BUFFER; + break; + case SECOND_VECTOR_RING_BUFFER: + // 2-part ring buffer is already started. + VMA_ASSERT(!suballocations2nd.empty()); + break; + case SECOND_VECTOR_DOUBLE_STACK: + VMA_ASSERT(0 && "CRITICAL ERROR: Trying to use linear allocator as ring buffer while it was already used as double stack."); + break; + default: + VMA_ASSERT(0); + } + + suballocations2nd.push_back(newSuballoc); + } + break; + default: + VMA_ASSERT(0 && "CRITICAL INTERNAL ERROR."); + } + + m_SumFreeSize -= newSuballoc.size; +} + +void VmaBlockMetadata_Linear::Free(const VmaAllocation allocation) +{ + FreeAtOffset(allocation->GetOffset()); +} + +void VmaBlockMetadata_Linear::FreeAtOffset(VkDeviceSize offset) +{ + SuballocationVectorType& suballocations1st = AccessSuballocations1st(); + SuballocationVectorType& suballocations2nd = AccessSuballocations2nd(); + + if(!suballocations1st.empty()) + { + // First allocation: Mark it as next empty at the beginning. + VmaSuballocation& firstSuballoc = suballocations1st[m_1stNullItemsBeginCount]; + if(firstSuballoc.offset == offset) + { + firstSuballoc.type = VMA_SUBALLOCATION_TYPE_FREE; + firstSuballoc.hAllocation = VK_NULL_HANDLE; + m_SumFreeSize += firstSuballoc.size; + ++m_1stNullItemsBeginCount; + CleanupAfterFree(); + return; + } + } + + // Last allocation in 2-part ring buffer or top of upper stack (same logic). + if(m_2ndVectorMode == SECOND_VECTOR_RING_BUFFER || + m_2ndVectorMode == SECOND_VECTOR_DOUBLE_STACK) + { + VmaSuballocation& lastSuballoc = suballocations2nd.back(); + if(lastSuballoc.offset == offset) + { + m_SumFreeSize += lastSuballoc.size; + suballocations2nd.pop_back(); + CleanupAfterFree(); + return; + } + } + // Last allocation in 1st vector. + else if(m_2ndVectorMode == SECOND_VECTOR_EMPTY) + { + VmaSuballocation& lastSuballoc = suballocations1st.back(); + if(lastSuballoc.offset == offset) + { + m_SumFreeSize += lastSuballoc.size; + suballocations1st.pop_back(); + CleanupAfterFree(); + return; + } + } + + // Item from the middle of 1st vector. + { + VmaSuballocation refSuballoc; + refSuballoc.offset = offset; + // Rest of members stays uninitialized intentionally for better performance. + SuballocationVectorType::iterator it = VmaBinaryFindSorted( + suballocations1st.begin() + m_1stNullItemsBeginCount, + suballocations1st.end(), + refSuballoc, + VmaSuballocationOffsetLess()); + if(it != suballocations1st.end()) + { + it->type = VMA_SUBALLOCATION_TYPE_FREE; + it->hAllocation = VK_NULL_HANDLE; + ++m_1stNullItemsMiddleCount; + m_SumFreeSize += it->size; + CleanupAfterFree(); + return; + } + } + + if(m_2ndVectorMode != SECOND_VECTOR_EMPTY) + { + // Item from the middle of 2nd vector. + VmaSuballocation refSuballoc; + refSuballoc.offset = offset; + // Rest of members stays uninitialized intentionally for better performance. + SuballocationVectorType::iterator it = m_2ndVectorMode == SECOND_VECTOR_RING_BUFFER ? + VmaBinaryFindSorted(suballocations2nd.begin(), suballocations2nd.end(), refSuballoc, VmaSuballocationOffsetLess()) : + VmaBinaryFindSorted(suballocations2nd.begin(), suballocations2nd.end(), refSuballoc, VmaSuballocationOffsetGreater()); + if(it != suballocations2nd.end()) + { + it->type = VMA_SUBALLOCATION_TYPE_FREE; + it->hAllocation = VK_NULL_HANDLE; + ++m_2ndNullItemsCount; + m_SumFreeSize += it->size; + CleanupAfterFree(); + return; + } + } + + VMA_ASSERT(0 && "Allocation to free not found in linear allocator!"); +} + +bool VmaBlockMetadata_Linear::ShouldCompact1st() const +{ + const size_t nullItemCount = m_1stNullItemsBeginCount + m_1stNullItemsMiddleCount; + const size_t suballocCount = AccessSuballocations1st().size(); + return suballocCount > 32 && nullItemCount * 2 >= (suballocCount - nullItemCount) * 3; +} + +void VmaBlockMetadata_Linear::CleanupAfterFree() +{ + SuballocationVectorType& suballocations1st = AccessSuballocations1st(); + SuballocationVectorType& suballocations2nd = AccessSuballocations2nd(); + + if(IsEmpty()) + { + suballocations1st.clear(); + suballocations2nd.clear(); + m_1stNullItemsBeginCount = 0; + m_1stNullItemsMiddleCount = 0; + m_2ndNullItemsCount = 0; + m_2ndVectorMode = SECOND_VECTOR_EMPTY; + } + else + { + const size_t suballoc1stCount = suballocations1st.size(); + const size_t nullItem1stCount = m_1stNullItemsBeginCount + m_1stNullItemsMiddleCount; + VMA_ASSERT(nullItem1stCount <= suballoc1stCount); + + // Find more null items at the beginning of 1st vector. + while(m_1stNullItemsBeginCount < suballoc1stCount && + suballocations1st[m_1stNullItemsBeginCount].hAllocation == VK_NULL_HANDLE) + { + ++m_1stNullItemsBeginCount; + --m_1stNullItemsMiddleCount; + } + + // Find more null items at the end of 1st vector. + while(m_1stNullItemsMiddleCount > 0 && + suballocations1st.back().hAllocation == VK_NULL_HANDLE) + { + --m_1stNullItemsMiddleCount; + suballocations1st.pop_back(); + } + + // Find more null items at the end of 2nd vector. + while(m_2ndNullItemsCount > 0 && + suballocations2nd.back().hAllocation == VK_NULL_HANDLE) + { + --m_2ndNullItemsCount; + suballocations2nd.pop_back(); + } + + // Find more null items at the beginning of 2nd vector. + while(m_2ndNullItemsCount > 0 && + suballocations2nd[0].hAllocation == VK_NULL_HANDLE) + { + --m_2ndNullItemsCount; + VmaVectorRemove(suballocations2nd, 0); + } + + if(ShouldCompact1st()) + { + const size_t nonNullItemCount = suballoc1stCount - nullItem1stCount; + size_t srcIndex = m_1stNullItemsBeginCount; + for(size_t dstIndex = 0; dstIndex < nonNullItemCount; ++dstIndex) + { + while(suballocations1st[srcIndex].hAllocation == VK_NULL_HANDLE) + { + ++srcIndex; + } + if(dstIndex != srcIndex) + { + suballocations1st[dstIndex] = suballocations1st[srcIndex]; + } + ++srcIndex; + } + suballocations1st.resize(nonNullItemCount); + m_1stNullItemsBeginCount = 0; + m_1stNullItemsMiddleCount = 0; + } + + // 2nd vector became empty. + if(suballocations2nd.empty()) + { + m_2ndVectorMode = SECOND_VECTOR_EMPTY; + } + + // 1st vector became empty. + if(suballocations1st.size() - m_1stNullItemsBeginCount == 0) + { + suballocations1st.clear(); + m_1stNullItemsBeginCount = 0; + + if(!suballocations2nd.empty() && m_2ndVectorMode == SECOND_VECTOR_RING_BUFFER) + { + // Swap 1st with 2nd. Now 2nd is empty. + m_2ndVectorMode = SECOND_VECTOR_EMPTY; + m_1stNullItemsMiddleCount = m_2ndNullItemsCount; + while(m_1stNullItemsBeginCount < suballocations2nd.size() && + suballocations2nd[m_1stNullItemsBeginCount].hAllocation == VK_NULL_HANDLE) + { + ++m_1stNullItemsBeginCount; + --m_1stNullItemsMiddleCount; + } + m_2ndNullItemsCount = 0; + m_1stVectorIndex ^= 1; + } + } + } + + VMA_HEAVY_ASSERT(Validate()); +} + + +//////////////////////////////////////////////////////////////////////////////// +// class VmaBlockMetadata_Buddy + +VmaBlockMetadata_Buddy::VmaBlockMetadata_Buddy(VmaAllocator hAllocator) : + VmaBlockMetadata(hAllocator), + m_Root(VMA_NULL), + m_AllocationCount(0), + m_FreeCount(1), + m_SumFreeSize(0) +{ + memset(m_FreeList, 0, sizeof(m_FreeList)); +} + +VmaBlockMetadata_Buddy::~VmaBlockMetadata_Buddy() +{ + DeleteNode(m_Root); +} + +void VmaBlockMetadata_Buddy::Init(VkDeviceSize size) +{ + VmaBlockMetadata::Init(size); + + m_UsableSize = VmaPrevPow2(size); + m_SumFreeSize = m_UsableSize; + + // Calculate m_LevelCount. + m_LevelCount = 1; + while(m_LevelCount < MAX_LEVELS && + LevelToNodeSize(m_LevelCount) >= MIN_NODE_SIZE) + { + ++m_LevelCount; + } + + Node* rootNode = vma_new(GetAllocationCallbacks(), Node)(); + rootNode->offset = 0; + rootNode->type = Node::TYPE_FREE; + rootNode->parent = VMA_NULL; + rootNode->buddy = VMA_NULL; + + m_Root = rootNode; + AddToFreeListFront(0, rootNode); +} + +bool VmaBlockMetadata_Buddy::Validate() const +{ + // Validate tree. + ValidationContext ctx; + if(!ValidateNode(ctx, VMA_NULL, m_Root, 0, LevelToNodeSize(0))) + { + VMA_VALIDATE(false && "ValidateNode failed."); + } + VMA_VALIDATE(m_AllocationCount == ctx.calculatedAllocationCount); + VMA_VALIDATE(m_SumFreeSize == ctx.calculatedSumFreeSize); + + // Validate free node lists. + for(uint32_t level = 0; level < m_LevelCount; ++level) + { + VMA_VALIDATE(m_FreeList[level].front == VMA_NULL || + m_FreeList[level].front->free.prev == VMA_NULL); + + for(Node* node = m_FreeList[level].front; + node != VMA_NULL; + node = node->free.next) + { + VMA_VALIDATE(node->type == Node::TYPE_FREE); + + if(node->free.next == VMA_NULL) + { + VMA_VALIDATE(m_FreeList[level].back == node); + } + else + { + VMA_VALIDATE(node->free.next->free.prev == node); + } + } + } + + // Validate that free lists ar higher levels are empty. + for(uint32_t level = m_LevelCount; level < MAX_LEVELS; ++level) + { + VMA_VALIDATE(m_FreeList[level].front == VMA_NULL && m_FreeList[level].back == VMA_NULL); + } + + return true; +} + +VkDeviceSize VmaBlockMetadata_Buddy::GetUnusedRangeSizeMax() const +{ + for(uint32_t level = 0; level < m_LevelCount; ++level) + { + if(m_FreeList[level].front != VMA_NULL) + { + return LevelToNodeSize(level); + } + } + return 0; +} + +void VmaBlockMetadata_Buddy::CalcAllocationStatInfo(VmaStatInfo& outInfo) const +{ + const VkDeviceSize unusableSize = GetUnusableSize(); + + outInfo.blockCount = 1; + + outInfo.allocationCount = outInfo.unusedRangeCount = 0; + outInfo.usedBytes = outInfo.unusedBytes = 0; + + outInfo.allocationSizeMax = outInfo.unusedRangeSizeMax = 0; + outInfo.allocationSizeMin = outInfo.unusedRangeSizeMin = UINT64_MAX; + outInfo.allocationSizeAvg = outInfo.unusedRangeSizeAvg = 0; // Unused. + + CalcAllocationStatInfoNode(outInfo, m_Root, LevelToNodeSize(0)); + + if(unusableSize > 0) + { + ++outInfo.unusedRangeCount; + outInfo.unusedBytes += unusableSize; + outInfo.unusedRangeSizeMax = VMA_MAX(outInfo.unusedRangeSizeMax, unusableSize); + outInfo.unusedRangeSizeMin = VMA_MIN(outInfo.unusedRangeSizeMin, unusableSize); + } +} + +void VmaBlockMetadata_Buddy::AddPoolStats(VmaPoolStats& inoutStats) const +{ + const VkDeviceSize unusableSize = GetUnusableSize(); + + inoutStats.size += GetSize(); + inoutStats.unusedSize += m_SumFreeSize + unusableSize; + inoutStats.allocationCount += m_AllocationCount; + inoutStats.unusedRangeCount += m_FreeCount; + inoutStats.unusedRangeSizeMax = VMA_MAX(inoutStats.unusedRangeSizeMax, GetUnusedRangeSizeMax()); + + if(unusableSize > 0) + { + ++inoutStats.unusedRangeCount; + // Not updating inoutStats.unusedRangeSizeMax with unusableSize because this space is not available for allocations. + } +} + +#if VMA_STATS_STRING_ENABLED + +void VmaBlockMetadata_Buddy::PrintDetailedMap(class VmaJsonWriter& json) const +{ + // TODO optimize + VmaStatInfo stat; + CalcAllocationStatInfo(stat); + + PrintDetailedMap_Begin( + json, + stat.unusedBytes, + stat.allocationCount, + stat.unusedRangeCount); + + PrintDetailedMapNode(json, m_Root, LevelToNodeSize(0)); + + const VkDeviceSize unusableSize = GetUnusableSize(); + if(unusableSize > 0) + { + PrintDetailedMap_UnusedRange(json, + m_UsableSize, // offset + unusableSize); // size + } + + PrintDetailedMap_End(json); +} + +#endif // #if VMA_STATS_STRING_ENABLED + +bool VmaBlockMetadata_Buddy::CreateAllocationRequest( + uint32_t currentFrameIndex, + uint32_t frameInUseCount, + VkDeviceSize bufferImageGranularity, + VkDeviceSize allocSize, + VkDeviceSize allocAlignment, + bool upperAddress, + VmaSuballocationType allocType, + bool canMakeOtherLost, + uint32_t strategy, + VmaAllocationRequest* pAllocationRequest) +{ + VMA_ASSERT(!upperAddress && "VMA_ALLOCATION_CREATE_UPPER_ADDRESS_BIT can be used only with linear algorithm."); + + // Simple way to respect bufferImageGranularity. May be optimized some day. + // Whenever it might be an OPTIMAL image... + if(allocType == VMA_SUBALLOCATION_TYPE_UNKNOWN || + allocType == VMA_SUBALLOCATION_TYPE_IMAGE_UNKNOWN || + allocType == VMA_SUBALLOCATION_TYPE_IMAGE_OPTIMAL) + { + allocAlignment = VMA_MAX(allocAlignment, bufferImageGranularity); + allocSize = VMA_MAX(allocSize, bufferImageGranularity); + } + + if(allocSize > m_UsableSize) + { + return false; + } + + const uint32_t targetLevel = AllocSizeToLevel(allocSize); + for(uint32_t level = targetLevel + 1; level--; ) + { + for(Node* freeNode = m_FreeList[level].front; + freeNode != VMA_NULL; + freeNode = freeNode->free.next) + { + if(freeNode->offset % allocAlignment == 0) + { + pAllocationRequest->type = VmaAllocationRequestType::Normal; + pAllocationRequest->offset = freeNode->offset; + pAllocationRequest->sumFreeSize = LevelToNodeSize(level); + pAllocationRequest->sumItemSize = 0; + pAllocationRequest->itemsToMakeLostCount = 0; + pAllocationRequest->customData = (void*)(uintptr_t)level; + return true; + } + } + } + + return false; +} + +bool VmaBlockMetadata_Buddy::MakeRequestedAllocationsLost( + uint32_t currentFrameIndex, + uint32_t frameInUseCount, + VmaAllocationRequest* pAllocationRequest) +{ + /* + Lost allocations are not supported in buddy allocator at the moment. + Support might be added in the future. + */ + return pAllocationRequest->itemsToMakeLostCount == 0; +} + +uint32_t VmaBlockMetadata_Buddy::MakeAllocationsLost(uint32_t currentFrameIndex, uint32_t frameInUseCount) +{ + /* + Lost allocations are not supported in buddy allocator at the moment. + Support might be added in the future. + */ + return 0; +} + +void VmaBlockMetadata_Buddy::Alloc( + const VmaAllocationRequest& request, + VmaSuballocationType type, + VkDeviceSize allocSize, + VmaAllocation hAllocation) +{ + VMA_ASSERT(request.type == VmaAllocationRequestType::Normal); + + const uint32_t targetLevel = AllocSizeToLevel(allocSize); + uint32_t currLevel = (uint32_t)(uintptr_t)request.customData; + + Node* currNode = m_FreeList[currLevel].front; + VMA_ASSERT(currNode != VMA_NULL && currNode->type == Node::TYPE_FREE); + while(currNode->offset != request.offset) + { + currNode = currNode->free.next; + VMA_ASSERT(currNode != VMA_NULL && currNode->type == Node::TYPE_FREE); + } + + // Go down, splitting free nodes. + while(currLevel < targetLevel) + { + // currNode is already first free node at currLevel. + // Remove it from list of free nodes at this currLevel. + RemoveFromFreeList(currLevel, currNode); + + const uint32_t childrenLevel = currLevel + 1; + + // Create two free sub-nodes. + Node* leftChild = vma_new(GetAllocationCallbacks(), Node)(); + Node* rightChild = vma_new(GetAllocationCallbacks(), Node)(); + + leftChild->offset = currNode->offset; + leftChild->type = Node::TYPE_FREE; + leftChild->parent = currNode; + leftChild->buddy = rightChild; + + rightChild->offset = currNode->offset + LevelToNodeSize(childrenLevel); + rightChild->type = Node::TYPE_FREE; + rightChild->parent = currNode; + rightChild->buddy = leftChild; + + // Convert current currNode to split type. + currNode->type = Node::TYPE_SPLIT; + currNode->split.leftChild = leftChild; + + // Add child nodes to free list. Order is important! + AddToFreeListFront(childrenLevel, rightChild); + AddToFreeListFront(childrenLevel, leftChild); + + ++m_FreeCount; + //m_SumFreeSize -= LevelToNodeSize(currLevel) % 2; // Useful only when level node sizes can be non power of 2. + ++currLevel; + currNode = m_FreeList[currLevel].front; + + /* + We can be sure that currNode, as left child of node previously split, + also fullfills the alignment requirement. + */ + } + + // Remove from free list. + VMA_ASSERT(currLevel == targetLevel && + currNode != VMA_NULL && + currNode->type == Node::TYPE_FREE); + RemoveFromFreeList(currLevel, currNode); + + // Convert to allocation node. + currNode->type = Node::TYPE_ALLOCATION; + currNode->allocation.alloc = hAllocation; + + ++m_AllocationCount; + --m_FreeCount; + m_SumFreeSize -= allocSize; +} + +void VmaBlockMetadata_Buddy::DeleteNode(Node* node) +{ + if(node->type == Node::TYPE_SPLIT) + { + DeleteNode(node->split.leftChild->buddy); + DeleteNode(node->split.leftChild); + } + + vma_delete(GetAllocationCallbacks(), node); +} + +bool VmaBlockMetadata_Buddy::ValidateNode(ValidationContext& ctx, const Node* parent, const Node* curr, uint32_t level, VkDeviceSize levelNodeSize) const +{ + VMA_VALIDATE(level < m_LevelCount); + VMA_VALIDATE(curr->parent == parent); + VMA_VALIDATE((curr->buddy == VMA_NULL) == (parent == VMA_NULL)); + VMA_VALIDATE(curr->buddy == VMA_NULL || curr->buddy->buddy == curr); + switch(curr->type) + { + case Node::TYPE_FREE: + // curr->free.prev, next are validated separately. + ctx.calculatedSumFreeSize += levelNodeSize; + ++ctx.calculatedFreeCount; + break; + case Node::TYPE_ALLOCATION: + ++ctx.calculatedAllocationCount; + ctx.calculatedSumFreeSize += levelNodeSize - curr->allocation.alloc->GetSize(); + VMA_VALIDATE(curr->allocation.alloc != VK_NULL_HANDLE); + break; + case Node::TYPE_SPLIT: + { + const uint32_t childrenLevel = level + 1; + const VkDeviceSize childrenLevelNodeSize = levelNodeSize / 2; + const Node* const leftChild = curr->split.leftChild; + VMA_VALIDATE(leftChild != VMA_NULL); + VMA_VALIDATE(leftChild->offset == curr->offset); + if(!ValidateNode(ctx, curr, leftChild, childrenLevel, childrenLevelNodeSize)) + { + VMA_VALIDATE(false && "ValidateNode for left child failed."); + } + const Node* const rightChild = leftChild->buddy; + VMA_VALIDATE(rightChild->offset == curr->offset + childrenLevelNodeSize); + if(!ValidateNode(ctx, curr, rightChild, childrenLevel, childrenLevelNodeSize)) + { + VMA_VALIDATE(false && "ValidateNode for right child failed."); + } + } + break; + default: + return false; + } + + return true; +} + +uint32_t VmaBlockMetadata_Buddy::AllocSizeToLevel(VkDeviceSize allocSize) const +{ + // I know this could be optimized somehow e.g. by using std::log2p1 from C++20. + uint32_t level = 0; + VkDeviceSize currLevelNodeSize = m_UsableSize; + VkDeviceSize nextLevelNodeSize = currLevelNodeSize >> 1; + while(allocSize <= nextLevelNodeSize && level + 1 < m_LevelCount) + { + ++level; + currLevelNodeSize = nextLevelNodeSize; + nextLevelNodeSize = currLevelNodeSize >> 1; + } + return level; +} + +void VmaBlockMetadata_Buddy::FreeAtOffset(VmaAllocation alloc, VkDeviceSize offset) +{ + // Find node and level. + Node* node = m_Root; + VkDeviceSize nodeOffset = 0; + uint32_t level = 0; + VkDeviceSize levelNodeSize = LevelToNodeSize(0); + while(node->type == Node::TYPE_SPLIT) + { + const VkDeviceSize nextLevelSize = levelNodeSize >> 1; + if(offset < nodeOffset + nextLevelSize) + { + node = node->split.leftChild; + } + else + { + node = node->split.leftChild->buddy; + nodeOffset += nextLevelSize; + } + ++level; + levelNodeSize = nextLevelSize; + } + + VMA_ASSERT(node != VMA_NULL && node->type == Node::TYPE_ALLOCATION); + VMA_ASSERT(alloc == VK_NULL_HANDLE || node->allocation.alloc == alloc); + + ++m_FreeCount; + --m_AllocationCount; + m_SumFreeSize += alloc->GetSize(); + + node->type = Node::TYPE_FREE; + + // Join free nodes if possible. + while(level > 0 && node->buddy->type == Node::TYPE_FREE) + { + RemoveFromFreeList(level, node->buddy); + Node* const parent = node->parent; + + vma_delete(GetAllocationCallbacks(), node->buddy); + vma_delete(GetAllocationCallbacks(), node); + parent->type = Node::TYPE_FREE; + + node = parent; + --level; + //m_SumFreeSize += LevelToNodeSize(level) % 2; // Useful only when level node sizes can be non power of 2. + --m_FreeCount; + } + + AddToFreeListFront(level, node); +} + +void VmaBlockMetadata_Buddy::CalcAllocationStatInfoNode(VmaStatInfo& outInfo, const Node* node, VkDeviceSize levelNodeSize) const +{ + switch(node->type) + { + case Node::TYPE_FREE: + ++outInfo.unusedRangeCount; + outInfo.unusedBytes += levelNodeSize; + outInfo.unusedRangeSizeMax = VMA_MAX(outInfo.unusedRangeSizeMax, levelNodeSize); + outInfo.unusedRangeSizeMin = VMA_MAX(outInfo.unusedRangeSizeMin, levelNodeSize); + break; + case Node::TYPE_ALLOCATION: + { + const VkDeviceSize allocSize = node->allocation.alloc->GetSize(); + ++outInfo.allocationCount; + outInfo.usedBytes += allocSize; + outInfo.allocationSizeMax = VMA_MAX(outInfo.allocationSizeMax, allocSize); + outInfo.allocationSizeMin = VMA_MAX(outInfo.allocationSizeMin, allocSize); + + const VkDeviceSize unusedRangeSize = levelNodeSize - allocSize; + if(unusedRangeSize > 0) + { + ++outInfo.unusedRangeCount; + outInfo.unusedBytes += unusedRangeSize; + outInfo.unusedRangeSizeMax = VMA_MAX(outInfo.unusedRangeSizeMax, unusedRangeSize); + outInfo.unusedRangeSizeMin = VMA_MAX(outInfo.unusedRangeSizeMin, unusedRangeSize); + } + } + break; + case Node::TYPE_SPLIT: + { + const VkDeviceSize childrenNodeSize = levelNodeSize / 2; + const Node* const leftChild = node->split.leftChild; + CalcAllocationStatInfoNode(outInfo, leftChild, childrenNodeSize); + const Node* const rightChild = leftChild->buddy; + CalcAllocationStatInfoNode(outInfo, rightChild, childrenNodeSize); + } + break; + default: + VMA_ASSERT(0); + } +} + +void VmaBlockMetadata_Buddy::AddToFreeListFront(uint32_t level, Node* node) +{ + VMA_ASSERT(node->type == Node::TYPE_FREE); + + // List is empty. + Node* const frontNode = m_FreeList[level].front; + if(frontNode == VMA_NULL) + { + VMA_ASSERT(m_FreeList[level].back == VMA_NULL); + node->free.prev = node->free.next = VMA_NULL; + m_FreeList[level].front = m_FreeList[level].back = node; + } + else + { + VMA_ASSERT(frontNode->free.prev == VMA_NULL); + node->free.prev = VMA_NULL; + node->free.next = frontNode; + frontNode->free.prev = node; + m_FreeList[level].front = node; + } +} + +void VmaBlockMetadata_Buddy::RemoveFromFreeList(uint32_t level, Node* node) +{ + VMA_ASSERT(m_FreeList[level].front != VMA_NULL); + + // It is at the front. + if(node->free.prev == VMA_NULL) + { + VMA_ASSERT(m_FreeList[level].front == node); + m_FreeList[level].front = node->free.next; + } + else + { + Node* const prevFreeNode = node->free.prev; + VMA_ASSERT(prevFreeNode->free.next == node); + prevFreeNode->free.next = node->free.next; + } + + // It is at the back. + if(node->free.next == VMA_NULL) + { + VMA_ASSERT(m_FreeList[level].back == node); + m_FreeList[level].back = node->free.prev; + } + else + { + Node* const nextFreeNode = node->free.next; + VMA_ASSERT(nextFreeNode->free.prev == node); + nextFreeNode->free.prev = node->free.prev; + } +} + +#if VMA_STATS_STRING_ENABLED +void VmaBlockMetadata_Buddy::PrintDetailedMapNode(class VmaJsonWriter& json, const Node* node, VkDeviceSize levelNodeSize) const +{ + switch(node->type) + { + case Node::TYPE_FREE: + PrintDetailedMap_UnusedRange(json, node->offset, levelNodeSize); + break; + case Node::TYPE_ALLOCATION: + { + PrintDetailedMap_Allocation(json, node->offset, node->allocation.alloc); + const VkDeviceSize allocSize = node->allocation.alloc->GetSize(); + if(allocSize < levelNodeSize) + { + PrintDetailedMap_UnusedRange(json, node->offset + allocSize, levelNodeSize - allocSize); + } + } + break; + case Node::TYPE_SPLIT: + { + const VkDeviceSize childrenNodeSize = levelNodeSize / 2; + const Node* const leftChild = node->split.leftChild; + PrintDetailedMapNode(json, leftChild, childrenNodeSize); + const Node* const rightChild = leftChild->buddy; + PrintDetailedMapNode(json, rightChild, childrenNodeSize); + } + break; + default: + VMA_ASSERT(0); + } +} +#endif // #if VMA_STATS_STRING_ENABLED + + +//////////////////////////////////////////////////////////////////////////////// +// class VmaDeviceMemoryBlock + +VmaDeviceMemoryBlock::VmaDeviceMemoryBlock(VmaAllocator hAllocator) : + m_pMetadata(VMA_NULL), + m_MemoryTypeIndex(UINT32_MAX), + m_Id(0), + m_hMemory(VK_NULL_HANDLE), + m_MapCount(0), + m_pMappedData(VMA_NULL) +{ +} + +void VmaDeviceMemoryBlock::Init( + VmaAllocator hAllocator, + VmaPool hParentPool, + uint32_t newMemoryTypeIndex, + VkDeviceMemory newMemory, + VkDeviceSize newSize, + uint32_t id, + uint32_t algorithm) +{ + VMA_ASSERT(m_hMemory == VK_NULL_HANDLE); + + m_hParentPool = hParentPool; + m_MemoryTypeIndex = newMemoryTypeIndex; + m_Id = id; + m_hMemory = newMemory; + + switch(algorithm) + { + case VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT: + m_pMetadata = vma_new(hAllocator, VmaBlockMetadata_Linear)(hAllocator); + break; + case VMA_POOL_CREATE_BUDDY_ALGORITHM_BIT: + m_pMetadata = vma_new(hAllocator, VmaBlockMetadata_Buddy)(hAllocator); + break; + default: + VMA_ASSERT(0); + // Fall-through. + case 0: + m_pMetadata = vma_new(hAllocator, VmaBlockMetadata_Generic)(hAllocator); + } + m_pMetadata->Init(newSize); +} + +void VmaDeviceMemoryBlock::Destroy(VmaAllocator allocator) +{ + // This is the most important assert in the entire library. + // Hitting it means you have some memory leak - unreleased VmaAllocation objects. + VMA_ASSERT(m_pMetadata->IsEmpty() && "Some allocations were not freed before destruction of this memory block!"); + + VMA_ASSERT(m_hMemory != VK_NULL_HANDLE); + allocator->FreeVulkanMemory(m_MemoryTypeIndex, m_pMetadata->GetSize(), m_hMemory); + m_hMemory = VK_NULL_HANDLE; + + vma_delete(allocator, m_pMetadata); + m_pMetadata = VMA_NULL; +} + +bool VmaDeviceMemoryBlock::Validate() const +{ + VMA_VALIDATE((m_hMemory != VK_NULL_HANDLE) && + (m_pMetadata->GetSize() != 0)); + + return m_pMetadata->Validate(); +} + +VkResult VmaDeviceMemoryBlock::CheckCorruption(VmaAllocator hAllocator) +{ + void* pData = nullptr; + VkResult res = Map(hAllocator, 1, &pData); + if(res != VK_SUCCESS) + { + return res; + } + + res = m_pMetadata->CheckCorruption(pData); + + Unmap(hAllocator, 1); + + return res; +} + +VkResult VmaDeviceMemoryBlock::Map(VmaAllocator hAllocator, uint32_t count, void** ppData) +{ + if(count == 0) + { + return VK_SUCCESS; + } + + VmaMutexLock lock(m_Mutex, hAllocator->m_UseMutex); + if(m_MapCount != 0) + { + m_MapCount += count; + VMA_ASSERT(m_pMappedData != VMA_NULL); + if(ppData != VMA_NULL) + { + *ppData = m_pMappedData; + } + return VK_SUCCESS; + } + else + { + VkResult result = (*hAllocator->GetVulkanFunctions().vkMapMemory)( + hAllocator->m_hDevice, + m_hMemory, + 0, // offset + VK_WHOLE_SIZE, + 0, // flags + &m_pMappedData); + if(result == VK_SUCCESS) + { + if(ppData != VMA_NULL) + { + *ppData = m_pMappedData; + } + m_MapCount = count; + } + return result; + } +} + +void VmaDeviceMemoryBlock::Unmap(VmaAllocator hAllocator, uint32_t count) +{ + if(count == 0) + { + return; + } + + VmaMutexLock lock(m_Mutex, hAllocator->m_UseMutex); + if(m_MapCount >= count) + { + m_MapCount -= count; + if(m_MapCount == 0) + { + m_pMappedData = VMA_NULL; + (*hAllocator->GetVulkanFunctions().vkUnmapMemory)(hAllocator->m_hDevice, m_hMemory); + } + } + else + { + VMA_ASSERT(0 && "VkDeviceMemory block is being unmapped while it was not previously mapped."); + } +} + +VkResult VmaDeviceMemoryBlock::WriteMagicValueAroundAllocation(VmaAllocator hAllocator, VkDeviceSize allocOffset, VkDeviceSize allocSize) +{ + VMA_ASSERT(VMA_DEBUG_MARGIN > 0 && VMA_DEBUG_MARGIN % 4 == 0 && VMA_DEBUG_DETECT_CORRUPTION); + VMA_ASSERT(allocOffset >= VMA_DEBUG_MARGIN); + + void* pData; + VkResult res = Map(hAllocator, 1, &pData); + if(res != VK_SUCCESS) + { + return res; + } + + VmaWriteMagicValue(pData, allocOffset - VMA_DEBUG_MARGIN); + VmaWriteMagicValue(pData, allocOffset + allocSize); + + Unmap(hAllocator, 1); + + return VK_SUCCESS; +} + +VkResult VmaDeviceMemoryBlock::ValidateMagicValueAroundAllocation(VmaAllocator hAllocator, VkDeviceSize allocOffset, VkDeviceSize allocSize) +{ + VMA_ASSERT(VMA_DEBUG_MARGIN > 0 && VMA_DEBUG_MARGIN % 4 == 0 && VMA_DEBUG_DETECT_CORRUPTION); + VMA_ASSERT(allocOffset >= VMA_DEBUG_MARGIN); + + void* pData; + VkResult res = Map(hAllocator, 1, &pData); + if(res != VK_SUCCESS) + { + return res; + } + + if(!VmaValidateMagicValue(pData, allocOffset - VMA_DEBUG_MARGIN)) + { + VMA_ASSERT(0 && "MEMORY CORRUPTION DETECTED BEFORE FREED ALLOCATION!"); + } + else if(!VmaValidateMagicValue(pData, allocOffset + allocSize)) + { + VMA_ASSERT(0 && "MEMORY CORRUPTION DETECTED AFTER FREED ALLOCATION!"); + } + + Unmap(hAllocator, 1); + + return VK_SUCCESS; +} + +VkResult VmaDeviceMemoryBlock::BindBufferMemory( + const VmaAllocator hAllocator, + const VmaAllocation hAllocation, + VkDeviceSize allocationLocalOffset, + VkBuffer hBuffer, + const void* pNext) +{ + VMA_ASSERT(hAllocation->GetType() == VmaAllocation_T::ALLOCATION_TYPE_BLOCK && + hAllocation->GetBlock() == this); + VMA_ASSERT(allocationLocalOffset < hAllocation->GetSize() && + "Invalid allocationLocalOffset. Did you forget that this offset is relative to the beginning of the allocation, not the whole memory block?"); + const VkDeviceSize memoryOffset = hAllocation->GetOffset() + allocationLocalOffset; + // This lock is important so that we don't call vkBind... and/or vkMap... simultaneously on the same VkDeviceMemory from multiple threads. + VmaMutexLock lock(m_Mutex, hAllocator->m_UseMutex); + return hAllocator->BindVulkanBuffer(m_hMemory, memoryOffset, hBuffer, pNext); +} + +VkResult VmaDeviceMemoryBlock::BindImageMemory( + const VmaAllocator hAllocator, + const VmaAllocation hAllocation, + VkDeviceSize allocationLocalOffset, + VkImage hImage, + const void* pNext) +{ + VMA_ASSERT(hAllocation->GetType() == VmaAllocation_T::ALLOCATION_TYPE_BLOCK && + hAllocation->GetBlock() == this); + VMA_ASSERT(allocationLocalOffset < hAllocation->GetSize() && + "Invalid allocationLocalOffset. Did you forget that this offset is relative to the beginning of the allocation, not the whole memory block?"); + const VkDeviceSize memoryOffset = hAllocation->GetOffset() + allocationLocalOffset; + // This lock is important so that we don't call vkBind... and/or vkMap... simultaneously on the same VkDeviceMemory from multiple threads. + VmaMutexLock lock(m_Mutex, hAllocator->m_UseMutex); + return hAllocator->BindVulkanImage(m_hMemory, memoryOffset, hImage, pNext); +} + +static void InitStatInfo(VmaStatInfo& outInfo) +{ + memset(&outInfo, 0, sizeof(outInfo)); + outInfo.allocationSizeMin = UINT64_MAX; + outInfo.unusedRangeSizeMin = UINT64_MAX; +} + +// Adds statistics srcInfo into inoutInfo, like: inoutInfo += srcInfo. +static void VmaAddStatInfo(VmaStatInfo& inoutInfo, const VmaStatInfo& srcInfo) +{ + inoutInfo.blockCount += srcInfo.blockCount; + inoutInfo.allocationCount += srcInfo.allocationCount; + inoutInfo.unusedRangeCount += srcInfo.unusedRangeCount; + inoutInfo.usedBytes += srcInfo.usedBytes; + inoutInfo.unusedBytes += srcInfo.unusedBytes; + inoutInfo.allocationSizeMin = VMA_MIN(inoutInfo.allocationSizeMin, srcInfo.allocationSizeMin); + inoutInfo.allocationSizeMax = VMA_MAX(inoutInfo.allocationSizeMax, srcInfo.allocationSizeMax); + inoutInfo.unusedRangeSizeMin = VMA_MIN(inoutInfo.unusedRangeSizeMin, srcInfo.unusedRangeSizeMin); + inoutInfo.unusedRangeSizeMax = VMA_MAX(inoutInfo.unusedRangeSizeMax, srcInfo.unusedRangeSizeMax); +} + +static void VmaPostprocessCalcStatInfo(VmaStatInfo& inoutInfo) +{ + inoutInfo.allocationSizeAvg = (inoutInfo.allocationCount > 0) ? + VmaRoundDiv(inoutInfo.usedBytes, inoutInfo.allocationCount) : 0; + inoutInfo.unusedRangeSizeAvg = (inoutInfo.unusedRangeCount > 0) ? + VmaRoundDiv(inoutInfo.unusedBytes, inoutInfo.unusedRangeCount) : 0; +} + +VmaPool_T::VmaPool_T( + VmaAllocator hAllocator, + const VmaPoolCreateInfo& createInfo, + VkDeviceSize preferredBlockSize) : + m_BlockVector( + hAllocator, + this, // hParentPool + createInfo.memoryTypeIndex, + createInfo.blockSize != 0 ? createInfo.blockSize : preferredBlockSize, + createInfo.minBlockCount, + createInfo.maxBlockCount, + (createInfo.flags & VMA_POOL_CREATE_IGNORE_BUFFER_IMAGE_GRANULARITY_BIT) != 0 ? 1 : hAllocator->GetBufferImageGranularity(), + createInfo.frameInUseCount, + createInfo.blockSize != 0, // explicitBlockSize + createInfo.flags & VMA_POOL_CREATE_ALGORITHM_MASK), // algorithm + m_Id(0), + m_Name(VMA_NULL) +{ +} + +VmaPool_T::~VmaPool_T() +{ +} + +void VmaPool_T::SetName(const char* pName) +{ + const VkAllocationCallbacks* allocs = m_BlockVector.GetAllocator()->GetAllocationCallbacks(); + VmaFreeString(allocs, m_Name); + + if(pName != VMA_NULL) + { + m_Name = VmaCreateStringCopy(allocs, pName); + } + else + { + m_Name = VMA_NULL; + } +} + +#if VMA_STATS_STRING_ENABLED + +#endif // #if VMA_STATS_STRING_ENABLED + +VmaBlockVector::VmaBlockVector( + VmaAllocator hAllocator, + VmaPool hParentPool, + uint32_t memoryTypeIndex, + VkDeviceSize preferredBlockSize, + size_t minBlockCount, + size_t maxBlockCount, + VkDeviceSize bufferImageGranularity, + uint32_t frameInUseCount, + bool explicitBlockSize, + uint32_t algorithm) : + m_hAllocator(hAllocator), + m_hParentPool(hParentPool), + m_MemoryTypeIndex(memoryTypeIndex), + m_PreferredBlockSize(preferredBlockSize), + m_MinBlockCount(minBlockCount), + m_MaxBlockCount(maxBlockCount), + m_BufferImageGranularity(bufferImageGranularity), + m_FrameInUseCount(frameInUseCount), + m_ExplicitBlockSize(explicitBlockSize), + m_Algorithm(algorithm), + m_HasEmptyBlock(false), + m_Blocks(VmaStlAllocator(hAllocator->GetAllocationCallbacks())), + m_NextBlockId(0) +{ +} + +VmaBlockVector::~VmaBlockVector() +{ + for(size_t i = m_Blocks.size(); i--; ) + { + m_Blocks[i]->Destroy(m_hAllocator); + vma_delete(m_hAllocator, m_Blocks[i]); + } +} + +VkResult VmaBlockVector::CreateMinBlocks() +{ + for(size_t i = 0; i < m_MinBlockCount; ++i) + { + VkResult res = CreateBlock(m_PreferredBlockSize, VMA_NULL); + if(res != VK_SUCCESS) + { + return res; + } + } + return VK_SUCCESS; +} + +void VmaBlockVector::GetPoolStats(VmaPoolStats* pStats) +{ + VmaMutexLockRead lock(m_Mutex, m_hAllocator->m_UseMutex); + + const size_t blockCount = m_Blocks.size(); + + pStats->size = 0; + pStats->unusedSize = 0; + pStats->allocationCount = 0; + pStats->unusedRangeCount = 0; + pStats->unusedRangeSizeMax = 0; + pStats->blockCount = blockCount; + + for(uint32_t blockIndex = 0; blockIndex < blockCount; ++blockIndex) + { + const VmaDeviceMemoryBlock* const pBlock = m_Blocks[blockIndex]; + VMA_ASSERT(pBlock); + VMA_HEAVY_ASSERT(pBlock->Validate()); + pBlock->m_pMetadata->AddPoolStats(*pStats); + } +} + +bool VmaBlockVector::IsEmpty() +{ + VmaMutexLockRead lock(m_Mutex, m_hAllocator->m_UseMutex); + return m_Blocks.empty(); +} + +bool VmaBlockVector::IsCorruptionDetectionEnabled() const +{ + const uint32_t requiredMemFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; + return (VMA_DEBUG_DETECT_CORRUPTION != 0) && + (VMA_DEBUG_MARGIN > 0) && + (m_Algorithm == 0 || m_Algorithm == VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT) && + (m_hAllocator->m_MemProps.memoryTypes[m_MemoryTypeIndex].propertyFlags & requiredMemFlags) == requiredMemFlags; +} + +static const uint32_t VMA_ALLOCATION_TRY_COUNT = 32; + +VkResult VmaBlockVector::Allocate( + uint32_t currentFrameIndex, + VkDeviceSize size, + VkDeviceSize alignment, + const VmaAllocationCreateInfo& createInfo, + VmaSuballocationType suballocType, + size_t allocationCount, + VmaAllocation* pAllocations) +{ + size_t allocIndex; + VkResult res = VK_SUCCESS; + + if(IsCorruptionDetectionEnabled()) + { + size = VmaAlignUp(size, sizeof(VMA_CORRUPTION_DETECTION_MAGIC_VALUE)); + alignment = VmaAlignUp(alignment, sizeof(VMA_CORRUPTION_DETECTION_MAGIC_VALUE)); + } + + { + VmaMutexLockWrite lock(m_Mutex, m_hAllocator->m_UseMutex); + for(allocIndex = 0; allocIndex < allocationCount; ++allocIndex) + { + res = AllocatePage( + currentFrameIndex, + size, + alignment, + createInfo, + suballocType, + pAllocations + allocIndex); + if(res != VK_SUCCESS) + { + break; + } + } + } + + if(res != VK_SUCCESS) + { + // Free all already created allocations. + while(allocIndex--) + { + Free(pAllocations[allocIndex]); + } + memset(pAllocations, 0, sizeof(VmaAllocation) * allocationCount); + } + + return res; +} + +VkResult VmaBlockVector::AllocatePage( + uint32_t currentFrameIndex, + VkDeviceSize size, + VkDeviceSize alignment, + const VmaAllocationCreateInfo& createInfo, + VmaSuballocationType suballocType, + VmaAllocation* pAllocation) +{ + const bool isUpperAddress = (createInfo.flags & VMA_ALLOCATION_CREATE_UPPER_ADDRESS_BIT) != 0; + bool canMakeOtherLost = (createInfo.flags & VMA_ALLOCATION_CREATE_CAN_MAKE_OTHER_LOST_BIT) != 0; + const bool mapped = (createInfo.flags & VMA_ALLOCATION_CREATE_MAPPED_BIT) != 0; + const bool isUserDataString = (createInfo.flags & VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT) != 0; + + VkDeviceSize freeMemory; + { + const uint32_t heapIndex = m_hAllocator->MemoryTypeIndexToHeapIndex(m_MemoryTypeIndex); + VmaBudget heapBudget = {}; + m_hAllocator->GetBudget(&heapBudget, heapIndex, 1); + freeMemory = (heapBudget.usage < heapBudget.budget) ? (heapBudget.budget - heapBudget.usage) : 0; + } + + const bool canFallbackToDedicated = !IsCustomPool(); + const bool canCreateNewBlock = + ((createInfo.flags & VMA_ALLOCATION_CREATE_NEVER_ALLOCATE_BIT) == 0) && + (m_Blocks.size() < m_MaxBlockCount) && + (freeMemory >= size || !canFallbackToDedicated); + uint32_t strategy = createInfo.flags & VMA_ALLOCATION_CREATE_STRATEGY_MASK; + + // If linearAlgorithm is used, canMakeOtherLost is available only when used as ring buffer. + // Which in turn is available only when maxBlockCount = 1. + if(m_Algorithm == VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT && m_MaxBlockCount > 1) + { + canMakeOtherLost = false; + } + + // Upper address can only be used with linear allocator and within single memory block. + if(isUpperAddress && + (m_Algorithm != VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT || m_MaxBlockCount > 1)) + { + return VK_ERROR_FEATURE_NOT_PRESENT; + } + + // Validate strategy. + switch(strategy) + { + case 0: + strategy = VMA_ALLOCATION_CREATE_STRATEGY_BEST_FIT_BIT; + break; + case VMA_ALLOCATION_CREATE_STRATEGY_BEST_FIT_BIT: + case VMA_ALLOCATION_CREATE_STRATEGY_WORST_FIT_BIT: + case VMA_ALLOCATION_CREATE_STRATEGY_FIRST_FIT_BIT: + break; + default: + return VK_ERROR_FEATURE_NOT_PRESENT; + } + + // Early reject: requested allocation size is larger that maximum block size for this block vector. + if(size + 2 * VMA_DEBUG_MARGIN > m_PreferredBlockSize) + { + return VK_ERROR_OUT_OF_DEVICE_MEMORY; + } + + /* + Under certain condition, this whole section can be skipped for optimization, so + we move on directly to trying to allocate with canMakeOtherLost. That's the case + e.g. for custom pools with linear algorithm. + */ + if(!canMakeOtherLost || canCreateNewBlock) + { + // 1. Search existing allocations. Try to allocate without making other allocations lost. + VmaAllocationCreateFlags allocFlagsCopy = createInfo.flags; + allocFlagsCopy &= ~VMA_ALLOCATION_CREATE_CAN_MAKE_OTHER_LOST_BIT; + + if(m_Algorithm == VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT) + { + // Use only last block. + if(!m_Blocks.empty()) + { + VmaDeviceMemoryBlock* const pCurrBlock = m_Blocks.back(); + VMA_ASSERT(pCurrBlock); + VkResult res = AllocateFromBlock( + pCurrBlock, + currentFrameIndex, + size, + alignment, + allocFlagsCopy, + createInfo.pUserData, + suballocType, + strategy, + pAllocation); + if(res == VK_SUCCESS) + { + VMA_DEBUG_LOG(" Returned from last block #%u", pCurrBlock->GetId()); + return VK_SUCCESS; + } + } + } + else + { + if(strategy == VMA_ALLOCATION_CREATE_STRATEGY_BEST_FIT_BIT) + { + // Forward order in m_Blocks - prefer blocks with smallest amount of free space. + for(size_t blockIndex = 0; blockIndex < m_Blocks.size(); ++blockIndex ) + { + VmaDeviceMemoryBlock* const pCurrBlock = m_Blocks[blockIndex]; + VMA_ASSERT(pCurrBlock); + VkResult res = AllocateFromBlock( + pCurrBlock, + currentFrameIndex, + size, + alignment, + allocFlagsCopy, + createInfo.pUserData, + suballocType, + strategy, + pAllocation); + if(res == VK_SUCCESS) + { + VMA_DEBUG_LOG(" Returned from existing block #%u", pCurrBlock->GetId()); + return VK_SUCCESS; + } + } + } + else // WORST_FIT, FIRST_FIT + { + // Backward order in m_Blocks - prefer blocks with largest amount of free space. + for(size_t blockIndex = m_Blocks.size(); blockIndex--; ) + { + VmaDeviceMemoryBlock* const pCurrBlock = m_Blocks[blockIndex]; + VMA_ASSERT(pCurrBlock); + VkResult res = AllocateFromBlock( + pCurrBlock, + currentFrameIndex, + size, + alignment, + allocFlagsCopy, + createInfo.pUserData, + suballocType, + strategy, + pAllocation); + if(res == VK_SUCCESS) + { + VMA_DEBUG_LOG(" Returned from existing block #%u", pCurrBlock->GetId()); + return VK_SUCCESS; + } + } + } + } + + // 2. Try to create new block. + if(canCreateNewBlock) + { + // Calculate optimal size for new block. + VkDeviceSize newBlockSize = m_PreferredBlockSize; + uint32_t newBlockSizeShift = 0; + const uint32_t NEW_BLOCK_SIZE_SHIFT_MAX = 3; + + if(!m_ExplicitBlockSize) + { + // Allocate 1/8, 1/4, 1/2 as first blocks. + const VkDeviceSize maxExistingBlockSize = CalcMaxBlockSize(); + for(uint32_t i = 0; i < NEW_BLOCK_SIZE_SHIFT_MAX; ++i) + { + const VkDeviceSize smallerNewBlockSize = newBlockSize / 2; + if(smallerNewBlockSize > maxExistingBlockSize && smallerNewBlockSize >= size * 2) + { + newBlockSize = smallerNewBlockSize; + ++newBlockSizeShift; + } + else + { + break; + } + } + } + + size_t newBlockIndex = 0; + VkResult res = (newBlockSize <= freeMemory || !canFallbackToDedicated) ? + CreateBlock(newBlockSize, &newBlockIndex) : VK_ERROR_OUT_OF_DEVICE_MEMORY; + // Allocation of this size failed? Try 1/2, 1/4, 1/8 of m_PreferredBlockSize. + if(!m_ExplicitBlockSize) + { + while(res < 0 && newBlockSizeShift < NEW_BLOCK_SIZE_SHIFT_MAX) + { + const VkDeviceSize smallerNewBlockSize = newBlockSize / 2; + if(smallerNewBlockSize >= size) + { + newBlockSize = smallerNewBlockSize; + ++newBlockSizeShift; + res = (newBlockSize <= freeMemory || !canFallbackToDedicated) ? + CreateBlock(newBlockSize, &newBlockIndex) : VK_ERROR_OUT_OF_DEVICE_MEMORY; + } + else + { + break; + } + } + } + + if(res == VK_SUCCESS) + { + VmaDeviceMemoryBlock* const pBlock = m_Blocks[newBlockIndex]; + VMA_ASSERT(pBlock->m_pMetadata->GetSize() >= size); + + res = AllocateFromBlock( + pBlock, + currentFrameIndex, + size, + alignment, + allocFlagsCopy, + createInfo.pUserData, + suballocType, + strategy, + pAllocation); + if(res == VK_SUCCESS) + { + VMA_DEBUG_LOG(" Created new block #%u Size=%llu", pBlock->GetId(), newBlockSize); + return VK_SUCCESS; + } + else + { + // Allocation from new block failed, possibly due to VMA_DEBUG_MARGIN or alignment. + return VK_ERROR_OUT_OF_DEVICE_MEMORY; + } + } + } + } + + // 3. Try to allocate from existing blocks with making other allocations lost. + if(canMakeOtherLost) + { + uint32_t tryIndex = 0; + for(; tryIndex < VMA_ALLOCATION_TRY_COUNT; ++tryIndex) + { + VmaDeviceMemoryBlock* pBestRequestBlock = VMA_NULL; + VmaAllocationRequest bestRequest = {}; + VkDeviceSize bestRequestCost = VK_WHOLE_SIZE; + + // 1. Search existing allocations. + if(strategy == VMA_ALLOCATION_CREATE_STRATEGY_BEST_FIT_BIT) + { + // Forward order in m_Blocks - prefer blocks with smallest amount of free space. + for(size_t blockIndex = 0; blockIndex < m_Blocks.size(); ++blockIndex ) + { + VmaDeviceMemoryBlock* const pCurrBlock = m_Blocks[blockIndex]; + VMA_ASSERT(pCurrBlock); + VmaAllocationRequest currRequest = {}; + if(pCurrBlock->m_pMetadata->CreateAllocationRequest( + currentFrameIndex, + m_FrameInUseCount, + m_BufferImageGranularity, + size, + alignment, + (createInfo.flags & VMA_ALLOCATION_CREATE_UPPER_ADDRESS_BIT) != 0, + suballocType, + canMakeOtherLost, + strategy, + &currRequest)) + { + const VkDeviceSize currRequestCost = currRequest.CalcCost(); + if(pBestRequestBlock == VMA_NULL || + currRequestCost < bestRequestCost) + { + pBestRequestBlock = pCurrBlock; + bestRequest = currRequest; + bestRequestCost = currRequestCost; + + if(bestRequestCost == 0) + { + break; + } + } + } + } + } + else // WORST_FIT, FIRST_FIT + { + // Backward order in m_Blocks - prefer blocks with largest amount of free space. + for(size_t blockIndex = m_Blocks.size(); blockIndex--; ) + { + VmaDeviceMemoryBlock* const pCurrBlock = m_Blocks[blockIndex]; + VMA_ASSERT(pCurrBlock); + VmaAllocationRequest currRequest = {}; + if(pCurrBlock->m_pMetadata->CreateAllocationRequest( + currentFrameIndex, + m_FrameInUseCount, + m_BufferImageGranularity, + size, + alignment, + (createInfo.flags & VMA_ALLOCATION_CREATE_UPPER_ADDRESS_BIT) != 0, + suballocType, + canMakeOtherLost, + strategy, + &currRequest)) + { + const VkDeviceSize currRequestCost = currRequest.CalcCost(); + if(pBestRequestBlock == VMA_NULL || + currRequestCost < bestRequestCost || + strategy == VMA_ALLOCATION_CREATE_STRATEGY_FIRST_FIT_BIT) + { + pBestRequestBlock = pCurrBlock; + bestRequest = currRequest; + bestRequestCost = currRequestCost; + + if(bestRequestCost == 0 || + strategy == VMA_ALLOCATION_CREATE_STRATEGY_FIRST_FIT_BIT) + { + break; + } + } + } + } + } + + if(pBestRequestBlock != VMA_NULL) + { + if(mapped) + { + VkResult res = pBestRequestBlock->Map(m_hAllocator, 1, VMA_NULL); + if(res != VK_SUCCESS) + { + return res; + } + } + + if(pBestRequestBlock->m_pMetadata->MakeRequestedAllocationsLost( + currentFrameIndex, + m_FrameInUseCount, + &bestRequest)) + { + // Allocate from this pBlock. + *pAllocation = m_hAllocator->m_AllocationObjectAllocator.Allocate(currentFrameIndex, isUserDataString); + pBestRequestBlock->m_pMetadata->Alloc(bestRequest, suballocType, size, *pAllocation); + UpdateHasEmptyBlock(); + (*pAllocation)->InitBlockAllocation( + pBestRequestBlock, + bestRequest.offset, + alignment, + size, + m_MemoryTypeIndex, + suballocType, + mapped, + (createInfo.flags & VMA_ALLOCATION_CREATE_CAN_BECOME_LOST_BIT) != 0); + VMA_HEAVY_ASSERT(pBestRequestBlock->Validate()); + VMA_DEBUG_LOG(" Returned from existing block"); + (*pAllocation)->SetUserData(m_hAllocator, createInfo.pUserData); + m_hAllocator->m_Budget.AddAllocation(m_hAllocator->MemoryTypeIndexToHeapIndex(m_MemoryTypeIndex), size); + if(VMA_DEBUG_INITIALIZE_ALLOCATIONS) + { + m_hAllocator->FillAllocation(*pAllocation, VMA_ALLOCATION_FILL_PATTERN_CREATED); + } + if(IsCorruptionDetectionEnabled()) + { + VkResult res = pBestRequestBlock->WriteMagicValueAroundAllocation(m_hAllocator, bestRequest.offset, size); + VMA_ASSERT(res == VK_SUCCESS && "Couldn't map block memory to write magic value."); + } + return VK_SUCCESS; + } + // else: Some allocations must have been touched while we are here. Next try. + } + else + { + // Could not find place in any of the blocks - break outer loop. + break; + } + } + /* Maximum number of tries exceeded - a very unlike event when many other + threads are simultaneously touching allocations making it impossible to make + lost at the same time as we try to allocate. */ + if(tryIndex == VMA_ALLOCATION_TRY_COUNT) + { + return VK_ERROR_TOO_MANY_OBJECTS; + } + } + + return VK_ERROR_OUT_OF_DEVICE_MEMORY; +} + +void VmaBlockVector::Free( + const VmaAllocation hAllocation) +{ + VmaDeviceMemoryBlock* pBlockToDelete = VMA_NULL; + + bool budgetExceeded = false; + { + const uint32_t heapIndex = m_hAllocator->MemoryTypeIndexToHeapIndex(m_MemoryTypeIndex); + VmaBudget heapBudget = {}; + m_hAllocator->GetBudget(&heapBudget, heapIndex, 1); + budgetExceeded = heapBudget.usage >= heapBudget.budget; + } + + // Scope for lock. + { + VmaMutexLockWrite lock(m_Mutex, m_hAllocator->m_UseMutex); + + VmaDeviceMemoryBlock* pBlock = hAllocation->GetBlock(); + + if(IsCorruptionDetectionEnabled()) + { + VkResult res = pBlock->ValidateMagicValueAroundAllocation(m_hAllocator, hAllocation->GetOffset(), hAllocation->GetSize()); + VMA_ASSERT(res == VK_SUCCESS && "Couldn't map block memory to validate magic value."); + } + + if(hAllocation->IsPersistentMap()) + { + pBlock->Unmap(m_hAllocator, 1); + } + + pBlock->m_pMetadata->Free(hAllocation); + VMA_HEAVY_ASSERT(pBlock->Validate()); + + VMA_DEBUG_LOG(" Freed from MemoryTypeIndex=%u", m_MemoryTypeIndex); + + const bool canDeleteBlock = m_Blocks.size() > m_MinBlockCount; + // pBlock became empty after this deallocation. + if(pBlock->m_pMetadata->IsEmpty()) + { + // Already has empty block. We don't want to have two, so delete this one. + if((m_HasEmptyBlock || budgetExceeded) && canDeleteBlock) + { + pBlockToDelete = pBlock; + Remove(pBlock); + } + // else: We now have an empty block - leave it. + } + // pBlock didn't become empty, but we have another empty block - find and free that one. + // (This is optional, heuristics.) + else if(m_HasEmptyBlock && canDeleteBlock) + { + VmaDeviceMemoryBlock* pLastBlock = m_Blocks.back(); + if(pLastBlock->m_pMetadata->IsEmpty()) + { + pBlockToDelete = pLastBlock; + m_Blocks.pop_back(); + } + } + + UpdateHasEmptyBlock(); + IncrementallySortBlocks(); + } + + // Destruction of a free block. Deferred until this point, outside of mutex + // lock, for performance reason. + if(pBlockToDelete != VMA_NULL) + { + VMA_DEBUG_LOG(" Deleted empty block"); + pBlockToDelete->Destroy(m_hAllocator); + vma_delete(m_hAllocator, pBlockToDelete); + } +} + +VkDeviceSize VmaBlockVector::CalcMaxBlockSize() const +{ + VkDeviceSize result = 0; + for(size_t i = m_Blocks.size(); i--; ) + { + result = VMA_MAX(result, m_Blocks[i]->m_pMetadata->GetSize()); + if(result >= m_PreferredBlockSize) + { + break; + } + } + return result; +} + +void VmaBlockVector::Remove(VmaDeviceMemoryBlock* pBlock) +{ + for(uint32_t blockIndex = 0; blockIndex < m_Blocks.size(); ++blockIndex) + { + if(m_Blocks[blockIndex] == pBlock) + { + VmaVectorRemove(m_Blocks, blockIndex); + return; + } + } + VMA_ASSERT(0); +} + +void VmaBlockVector::IncrementallySortBlocks() +{ + if(m_Algorithm != VMA_POOL_CREATE_LINEAR_ALGORITHM_BIT) + { + // Bubble sort only until first swap. + for(size_t i = 1; i < m_Blocks.size(); ++i) + { + if(m_Blocks[i - 1]->m_pMetadata->GetSumFreeSize() > m_Blocks[i]->m_pMetadata->GetSumFreeSize()) + { + VMA_SWAP(m_Blocks[i - 1], m_Blocks[i]); + return; + } + } + } +} + +VkResult VmaBlockVector::AllocateFromBlock( + VmaDeviceMemoryBlock* pBlock, + uint32_t currentFrameIndex, + VkDeviceSize size, + VkDeviceSize alignment, + VmaAllocationCreateFlags allocFlags, + void* pUserData, + VmaSuballocationType suballocType, + uint32_t strategy, + VmaAllocation* pAllocation) +{ + VMA_ASSERT((allocFlags & VMA_ALLOCATION_CREATE_CAN_MAKE_OTHER_LOST_BIT) == 0); + const bool isUpperAddress = (allocFlags & VMA_ALLOCATION_CREATE_UPPER_ADDRESS_BIT) != 0; + const bool mapped = (allocFlags & VMA_ALLOCATION_CREATE_MAPPED_BIT) != 0; + const bool isUserDataString = (allocFlags & VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT) != 0; + + VmaAllocationRequest currRequest = {}; + if(pBlock->m_pMetadata->CreateAllocationRequest( + currentFrameIndex, + m_FrameInUseCount, + m_BufferImageGranularity, + size, + alignment, + isUpperAddress, + suballocType, + false, // canMakeOtherLost + strategy, + &currRequest)) + { + // Allocate from pCurrBlock. + VMA_ASSERT(currRequest.itemsToMakeLostCount == 0); + + if(mapped) + { + VkResult res = pBlock->Map(m_hAllocator, 1, VMA_NULL); + if(res != VK_SUCCESS) + { + return res; + } + } + + *pAllocation = m_hAllocator->m_AllocationObjectAllocator.Allocate(currentFrameIndex, isUserDataString); + pBlock->m_pMetadata->Alloc(currRequest, suballocType, size, *pAllocation); + UpdateHasEmptyBlock(); + (*pAllocation)->InitBlockAllocation( + pBlock, + currRequest.offset, + alignment, + size, + m_MemoryTypeIndex, + suballocType, + mapped, + (allocFlags & VMA_ALLOCATION_CREATE_CAN_BECOME_LOST_BIT) != 0); + VMA_HEAVY_ASSERT(pBlock->Validate()); + (*pAllocation)->SetUserData(m_hAllocator, pUserData); + m_hAllocator->m_Budget.AddAllocation(m_hAllocator->MemoryTypeIndexToHeapIndex(m_MemoryTypeIndex), size); + if(VMA_DEBUG_INITIALIZE_ALLOCATIONS) + { + m_hAllocator->FillAllocation(*pAllocation, VMA_ALLOCATION_FILL_PATTERN_CREATED); + } + if(IsCorruptionDetectionEnabled()) + { + VkResult res = pBlock->WriteMagicValueAroundAllocation(m_hAllocator, currRequest.offset, size); + VMA_ASSERT(res == VK_SUCCESS && "Couldn't map block memory to write magic value."); + } + return VK_SUCCESS; + } + return VK_ERROR_OUT_OF_DEVICE_MEMORY; +} + +VkResult VmaBlockVector::CreateBlock(VkDeviceSize blockSize, size_t* pNewBlockIndex) +{ + VkMemoryAllocateInfo allocInfo = { VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO }; + allocInfo.memoryTypeIndex = m_MemoryTypeIndex; + allocInfo.allocationSize = blockSize; + VkDeviceMemory mem = VK_NULL_HANDLE; + VkResult res = m_hAllocator->AllocateVulkanMemory(&allocInfo, &mem); + if(res < 0) + { + return res; + } + + // New VkDeviceMemory successfully created. + + // Create new Allocation for it. + VmaDeviceMemoryBlock* const pBlock = vma_new(m_hAllocator, VmaDeviceMemoryBlock)(m_hAllocator); + pBlock->Init( + m_hAllocator, + m_hParentPool, + m_MemoryTypeIndex, + mem, + allocInfo.allocationSize, + m_NextBlockId++, + m_Algorithm); + + m_Blocks.push_back(pBlock); + if(pNewBlockIndex != VMA_NULL) + { + *pNewBlockIndex = m_Blocks.size() - 1; + } + + return VK_SUCCESS; +} + +void VmaBlockVector::ApplyDefragmentationMovesCpu( + class VmaBlockVectorDefragmentationContext* pDefragCtx, + const VmaVector< VmaDefragmentationMove, VmaStlAllocator >& moves) +{ + const size_t blockCount = m_Blocks.size(); + const bool isNonCoherent = m_hAllocator->IsMemoryTypeNonCoherent(m_MemoryTypeIndex); + + enum BLOCK_FLAG + { + BLOCK_FLAG_USED = 0x00000001, + BLOCK_FLAG_MAPPED_FOR_DEFRAGMENTATION = 0x00000002, + }; + + struct BlockInfo + { + uint32_t flags; + void* pMappedData; + }; + VmaVector< BlockInfo, VmaStlAllocator > + blockInfo(blockCount, BlockInfo(), VmaStlAllocator(m_hAllocator->GetAllocationCallbacks())); + memset(blockInfo.data(), 0, blockCount * sizeof(BlockInfo)); + + // Go over all moves. Mark blocks that are used with BLOCK_FLAG_USED. + const size_t moveCount = moves.size(); + for(size_t moveIndex = 0; moveIndex < moveCount; ++moveIndex) + { + const VmaDefragmentationMove& move = moves[moveIndex]; + blockInfo[move.srcBlockIndex].flags |= BLOCK_FLAG_USED; + blockInfo[move.dstBlockIndex].flags |= BLOCK_FLAG_USED; + } + + VMA_ASSERT(pDefragCtx->res == VK_SUCCESS); + + // Go over all blocks. Get mapped pointer or map if necessary. + for(size_t blockIndex = 0; pDefragCtx->res == VK_SUCCESS && blockIndex < blockCount; ++blockIndex) + { + BlockInfo& currBlockInfo = blockInfo[blockIndex]; + VmaDeviceMemoryBlock* pBlock = m_Blocks[blockIndex]; + if((currBlockInfo.flags & BLOCK_FLAG_USED) != 0) + { + currBlockInfo.pMappedData = pBlock->GetMappedData(); + // It is not originally mapped - map it. + if(currBlockInfo.pMappedData == VMA_NULL) + { + pDefragCtx->res = pBlock->Map(m_hAllocator, 1, &currBlockInfo.pMappedData); + if(pDefragCtx->res == VK_SUCCESS) + { + currBlockInfo.flags |= BLOCK_FLAG_MAPPED_FOR_DEFRAGMENTATION; + } + } + } + } + + // Go over all moves. Do actual data transfer. + if(pDefragCtx->res == VK_SUCCESS) + { + const VkDeviceSize nonCoherentAtomSize = m_hAllocator->m_PhysicalDeviceProperties.limits.nonCoherentAtomSize; + VkMappedMemoryRange memRange = { VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE }; + + for(size_t moveIndex = 0; moveIndex < moveCount; ++moveIndex) + { + const VmaDefragmentationMove& move = moves[moveIndex]; + + const BlockInfo& srcBlockInfo = blockInfo[move.srcBlockIndex]; + const BlockInfo& dstBlockInfo = blockInfo[move.dstBlockIndex]; + + VMA_ASSERT(srcBlockInfo.pMappedData && dstBlockInfo.pMappedData); + + // Invalidate source. + if(isNonCoherent) + { + VmaDeviceMemoryBlock* const pSrcBlock = m_Blocks[move.srcBlockIndex]; + memRange.memory = pSrcBlock->GetDeviceMemory(); + memRange.offset = VmaAlignDown(move.srcOffset, nonCoherentAtomSize); + memRange.size = VMA_MIN( + VmaAlignUp(move.size + (move.srcOffset - memRange.offset), nonCoherentAtomSize), + pSrcBlock->m_pMetadata->GetSize() - memRange.offset); + (*m_hAllocator->GetVulkanFunctions().vkInvalidateMappedMemoryRanges)(m_hAllocator->m_hDevice, 1, &memRange); + } + + // THE PLACE WHERE ACTUAL DATA COPY HAPPENS. + memmove( + reinterpret_cast(dstBlockInfo.pMappedData) + move.dstOffset, + reinterpret_cast(srcBlockInfo.pMappedData) + move.srcOffset, + static_cast(move.size)); + + if(IsCorruptionDetectionEnabled()) + { + VmaWriteMagicValue(dstBlockInfo.pMappedData, move.dstOffset - VMA_DEBUG_MARGIN); + VmaWriteMagicValue(dstBlockInfo.pMappedData, move.dstOffset + move.size); + } + + // Flush destination. + if(isNonCoherent) + { + VmaDeviceMemoryBlock* const pDstBlock = m_Blocks[move.dstBlockIndex]; + memRange.memory = pDstBlock->GetDeviceMemory(); + memRange.offset = VmaAlignDown(move.dstOffset, nonCoherentAtomSize); + memRange.size = VMA_MIN( + VmaAlignUp(move.size + (move.dstOffset - memRange.offset), nonCoherentAtomSize), + pDstBlock->m_pMetadata->GetSize() - memRange.offset); + (*m_hAllocator->GetVulkanFunctions().vkFlushMappedMemoryRanges)(m_hAllocator->m_hDevice, 1, &memRange); + } + } + } + + // Go over all blocks in reverse order. Unmap those that were mapped just for defragmentation. + // Regardless of pCtx->res == VK_SUCCESS. + for(size_t blockIndex = blockCount; blockIndex--; ) + { + const BlockInfo& currBlockInfo = blockInfo[blockIndex]; + if((currBlockInfo.flags & BLOCK_FLAG_MAPPED_FOR_DEFRAGMENTATION) != 0) + { + VmaDeviceMemoryBlock* pBlock = m_Blocks[blockIndex]; + pBlock->Unmap(m_hAllocator, 1); + } + } +} + +void VmaBlockVector::ApplyDefragmentationMovesGpu( + class VmaBlockVectorDefragmentationContext* pDefragCtx, + VmaVector< VmaDefragmentationMove, VmaStlAllocator >& moves, + VkCommandBuffer commandBuffer) +{ + const size_t blockCount = m_Blocks.size(); + + pDefragCtx->blockContexts.resize(blockCount); + memset(pDefragCtx->blockContexts.data(), 0, blockCount * sizeof(VmaBlockDefragmentationContext)); + + // Go over all moves. Mark blocks that are used with BLOCK_FLAG_USED. + const size_t moveCount = moves.size(); + for(size_t moveIndex = 0; moveIndex < moveCount; ++moveIndex) + { + const VmaDefragmentationMove& move = moves[moveIndex]; + + //if(move.type == VMA_ALLOCATION_TYPE_UNKNOWN) + { + // Old school move still require us to map the whole block + pDefragCtx->blockContexts[move.srcBlockIndex].flags |= VmaBlockDefragmentationContext::BLOCK_FLAG_USED; + pDefragCtx->blockContexts[move.dstBlockIndex].flags |= VmaBlockDefragmentationContext::BLOCK_FLAG_USED; + } + } + + VMA_ASSERT(pDefragCtx->res == VK_SUCCESS); + + // Go over all blocks. Create and bind buffer for whole block if necessary. + { + VkBufferCreateInfo bufCreateInfo; + VmaFillGpuDefragmentationBufferCreateInfo(bufCreateInfo); + + for(size_t blockIndex = 0; pDefragCtx->res == VK_SUCCESS && blockIndex < blockCount; ++blockIndex) + { + VmaBlockDefragmentationContext& currBlockCtx = pDefragCtx->blockContexts[blockIndex]; + VmaDeviceMemoryBlock* pBlock = m_Blocks[blockIndex]; + if((currBlockCtx.flags & VmaBlockDefragmentationContext::BLOCK_FLAG_USED) != 0) + { + bufCreateInfo.size = pBlock->m_pMetadata->GetSize(); + pDefragCtx->res = (*m_hAllocator->GetVulkanFunctions().vkCreateBuffer)( + m_hAllocator->m_hDevice, &bufCreateInfo, m_hAllocator->GetAllocationCallbacks(), &currBlockCtx.hBuffer); + if(pDefragCtx->res == VK_SUCCESS) + { + pDefragCtx->res = (*m_hAllocator->GetVulkanFunctions().vkBindBufferMemory)( + m_hAllocator->m_hDevice, currBlockCtx.hBuffer, pBlock->GetDeviceMemory(), 0); + } + } + } + } + + // Go over all moves. Post data transfer commands to command buffer. + if(pDefragCtx->res == VK_SUCCESS) + { + for(size_t moveIndex = 0; moveIndex < moveCount; ++moveIndex) + { + const VmaDefragmentationMove& move = moves[moveIndex]; + + const VmaBlockDefragmentationContext& srcBlockCtx = pDefragCtx->blockContexts[move.srcBlockIndex]; + const VmaBlockDefragmentationContext& dstBlockCtx = pDefragCtx->blockContexts[move.dstBlockIndex]; + + VMA_ASSERT(srcBlockCtx.hBuffer && dstBlockCtx.hBuffer); + + VkBufferCopy region = { + move.srcOffset, + move.dstOffset, + move.size }; + (*m_hAllocator->GetVulkanFunctions().vkCmdCopyBuffer)( + commandBuffer, srcBlockCtx.hBuffer, dstBlockCtx.hBuffer, 1, ®ion); + } + } + + // Save buffers to defrag context for later destruction. + if(pDefragCtx->res == VK_SUCCESS && moveCount > 0) + { + pDefragCtx->res = VK_NOT_READY; + } +} + +void VmaBlockVector::FreeEmptyBlocks(VmaDefragmentationStats* pDefragmentationStats) +{ + for(size_t blockIndex = m_Blocks.size(); blockIndex--; ) + { + VmaDeviceMemoryBlock* pBlock = m_Blocks[blockIndex]; + if(pBlock->m_pMetadata->IsEmpty()) + { + if(m_Blocks.size() > m_MinBlockCount) + { + if(pDefragmentationStats != VMA_NULL) + { + ++pDefragmentationStats->deviceMemoryBlocksFreed; + pDefragmentationStats->bytesFreed += pBlock->m_pMetadata->GetSize(); + } + + VmaVectorRemove(m_Blocks, blockIndex); + pBlock->Destroy(m_hAllocator); + vma_delete(m_hAllocator, pBlock); + } + else + { + break; + } + } + } + UpdateHasEmptyBlock(); +} + +void VmaBlockVector::UpdateHasEmptyBlock() +{ + m_HasEmptyBlock = false; + for(size_t index = 0, count = m_Blocks.size(); index < count; ++index) + { + VmaDeviceMemoryBlock* const pBlock = m_Blocks[index]; + if(pBlock->m_pMetadata->IsEmpty()) + { + m_HasEmptyBlock = true; + break; + } + } +} + +#if VMA_STATS_STRING_ENABLED + +void VmaBlockVector::PrintDetailedMap(class VmaJsonWriter& json) +{ + VmaMutexLockRead lock(m_Mutex, m_hAllocator->m_UseMutex); + + json.BeginObject(); + + if(IsCustomPool()) + { + const char* poolName = m_hParentPool->GetName(); + if(poolName != VMA_NULL && poolName[0] != '\0') + { + json.WriteString("Name"); + json.WriteString(poolName); + } + + json.WriteString("MemoryTypeIndex"); + json.WriteNumber(m_MemoryTypeIndex); + + json.WriteString("BlockSize"); + json.WriteNumber(m_PreferredBlockSize); + + json.WriteString("BlockCount"); + json.BeginObject(true); + if(m_MinBlockCount > 0) + { + json.WriteString("Min"); + json.WriteNumber((uint64_t)m_MinBlockCount); + } + if(m_MaxBlockCount < SIZE_MAX) + { + json.WriteString("Max"); + json.WriteNumber((uint64_t)m_MaxBlockCount); + } + json.WriteString("Cur"); + json.WriteNumber((uint64_t)m_Blocks.size()); + json.EndObject(); + + if(m_FrameInUseCount > 0) + { + json.WriteString("FrameInUseCount"); + json.WriteNumber(m_FrameInUseCount); + } + + if(m_Algorithm != 0) + { + json.WriteString("Algorithm"); + json.WriteString(VmaAlgorithmToStr(m_Algorithm)); + } + } + else + { + json.WriteString("PreferredBlockSize"); + json.WriteNumber(m_PreferredBlockSize); + } + + json.WriteString("Blocks"); + json.BeginObject(); + for(size_t i = 0; i < m_Blocks.size(); ++i) + { + json.BeginString(); + json.ContinueString(m_Blocks[i]->GetId()); + json.EndString(); + + m_Blocks[i]->m_pMetadata->PrintDetailedMap(json); + } + json.EndObject(); + + json.EndObject(); +} + +#endif // #if VMA_STATS_STRING_ENABLED + +void VmaBlockVector::Defragment( + class VmaBlockVectorDefragmentationContext* pCtx, + VmaDefragmentationStats* pStats, VmaDefragmentationFlags flags, + VkDeviceSize& maxCpuBytesToMove, uint32_t& maxCpuAllocationsToMove, + VkDeviceSize& maxGpuBytesToMove, uint32_t& maxGpuAllocationsToMove, + VkCommandBuffer commandBuffer) +{ + pCtx->res = VK_SUCCESS; + + const VkMemoryPropertyFlags memPropFlags = + m_hAllocator->m_MemProps.memoryTypes[m_MemoryTypeIndex].propertyFlags; + const bool isHostVisible = (memPropFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) != 0; + + const bool canDefragmentOnCpu = maxCpuBytesToMove > 0 && maxCpuAllocationsToMove > 0 && + isHostVisible; + const bool canDefragmentOnGpu = maxGpuBytesToMove > 0 && maxGpuAllocationsToMove > 0 && + !IsCorruptionDetectionEnabled() && + ((1u << m_MemoryTypeIndex) & m_hAllocator->GetGpuDefragmentationMemoryTypeBits()) != 0; + + // There are options to defragment this memory type. + if(canDefragmentOnCpu || canDefragmentOnGpu) + { + bool defragmentOnGpu; + // There is only one option to defragment this memory type. + if(canDefragmentOnGpu != canDefragmentOnCpu) + { + defragmentOnGpu = canDefragmentOnGpu; + } + // Both options are available: Heuristics to choose the best one. + else + { + defragmentOnGpu = (memPropFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) != 0 || + m_hAllocator->IsIntegratedGpu(); + } + + bool overlappingMoveSupported = !defragmentOnGpu; + + if(m_hAllocator->m_UseMutex) + { + if(flags & VMA_DEFRAGMENTATION_FLAG_INCREMENTAL) + { + if(!m_Mutex.TryLockWrite()) + { + pCtx->res = VK_ERROR_INITIALIZATION_FAILED; + return; + } + } + else + { + m_Mutex.LockWrite(); + pCtx->mutexLocked = true; + } + } + + pCtx->Begin(overlappingMoveSupported, flags); + + // Defragment. + + const VkDeviceSize maxBytesToMove = defragmentOnGpu ? maxGpuBytesToMove : maxCpuBytesToMove; + const uint32_t maxAllocationsToMove = defragmentOnGpu ? maxGpuAllocationsToMove : maxCpuAllocationsToMove; + pCtx->res = pCtx->GetAlgorithm()->Defragment(pCtx->defragmentationMoves, maxBytesToMove, maxAllocationsToMove, flags); + + // Accumulate statistics. + if(pStats != VMA_NULL) + { + const VkDeviceSize bytesMoved = pCtx->GetAlgorithm()->GetBytesMoved(); + const uint32_t allocationsMoved = pCtx->GetAlgorithm()->GetAllocationsMoved(); + pStats->bytesMoved += bytesMoved; + pStats->allocationsMoved += allocationsMoved; + VMA_ASSERT(bytesMoved <= maxBytesToMove); + VMA_ASSERT(allocationsMoved <= maxAllocationsToMove); + if(defragmentOnGpu) + { + maxGpuBytesToMove -= bytesMoved; + maxGpuAllocationsToMove -= allocationsMoved; + } + else + { + maxCpuBytesToMove -= bytesMoved; + maxCpuAllocationsToMove -= allocationsMoved; + } + } + + if(flags & VMA_DEFRAGMENTATION_FLAG_INCREMENTAL) + { + if(m_hAllocator->m_UseMutex) + m_Mutex.UnlockWrite(); + + if(pCtx->res >= VK_SUCCESS && !pCtx->defragmentationMoves.empty()) + pCtx->res = VK_NOT_READY; + + return; + } + + if(pCtx->res >= VK_SUCCESS) + { + if(defragmentOnGpu) + { + ApplyDefragmentationMovesGpu(pCtx, pCtx->defragmentationMoves, commandBuffer); + } + else + { + ApplyDefragmentationMovesCpu(pCtx, pCtx->defragmentationMoves); + } + } + } +} + +void VmaBlockVector::DefragmentationEnd( + class VmaBlockVectorDefragmentationContext* pCtx, + VmaDefragmentationStats* pStats) +{ + // Destroy buffers. + for(size_t blockIndex = pCtx->blockContexts.size(); blockIndex--; ) + { + VmaBlockDefragmentationContext& blockCtx = pCtx->blockContexts[blockIndex]; + if(blockCtx.hBuffer) + { + (*m_hAllocator->GetVulkanFunctions().vkDestroyBuffer)( + m_hAllocator->m_hDevice, blockCtx.hBuffer, m_hAllocator->GetAllocationCallbacks()); + } + } + + if(pCtx->res >= VK_SUCCESS) + { + FreeEmptyBlocks(pStats); + } + + if(pCtx->mutexLocked) + { + VMA_ASSERT(m_hAllocator->m_UseMutex); + m_Mutex.UnlockWrite(); + } +} + +uint32_t VmaBlockVector::ProcessDefragmentations( + class VmaBlockVectorDefragmentationContext *pCtx, + VmaDefragmentationPassMoveInfo* pMove, uint32_t maxMoves) +{ + VmaMutexLockWrite lock(m_Mutex, m_hAllocator->m_UseMutex); + + const uint32_t moveCount = std::min(uint32_t(pCtx->defragmentationMoves.size()) - pCtx->defragmentationMovesProcessed, maxMoves); + + for(uint32_t i = 0; i < moveCount; ++ i) + { + VmaDefragmentationMove& move = pCtx->defragmentationMoves[pCtx->defragmentationMovesProcessed + i]; + + pMove->allocation = move.hAllocation; + pMove->memory = move.pDstBlock->GetDeviceMemory(); + pMove->offset = move.dstOffset; + + ++ pMove; + } + + pCtx->defragmentationMovesProcessed += moveCount; + + return moveCount; +} + +void VmaBlockVector::CommitDefragmentations( + class VmaBlockVectorDefragmentationContext *pCtx, + VmaDefragmentationStats* pStats) +{ + VmaMutexLockWrite lock(m_Mutex, m_hAllocator->m_UseMutex); + + for(uint32_t i = pCtx->defragmentationMovesCommitted; i < pCtx->defragmentationMovesProcessed; ++ i) + { + const VmaDefragmentationMove &move = pCtx->defragmentationMoves[i]; + + move.pSrcBlock->m_pMetadata->FreeAtOffset(move.srcOffset); + move.hAllocation->ChangeBlockAllocation(m_hAllocator, move.pDstBlock, move.dstOffset); + } + + pCtx->defragmentationMovesCommitted = pCtx->defragmentationMovesProcessed; + FreeEmptyBlocks(pStats); +} + +size_t VmaBlockVector::CalcAllocationCount() const +{ + size_t result = 0; + for(size_t i = 0; i < m_Blocks.size(); ++i) + { + result += m_Blocks[i]->m_pMetadata->GetAllocationCount(); + } + return result; +} + +bool VmaBlockVector::IsBufferImageGranularityConflictPossible() const +{ + if(m_BufferImageGranularity == 1) + { + return false; + } + VmaSuballocationType lastSuballocType = VMA_SUBALLOCATION_TYPE_FREE; + for(size_t i = 0, count = m_Blocks.size(); i < count; ++i) + { + VmaDeviceMemoryBlock* const pBlock = m_Blocks[i]; + VMA_ASSERT(m_Algorithm == 0); + VmaBlockMetadata_Generic* const pMetadata = (VmaBlockMetadata_Generic*)pBlock->m_pMetadata; + if(pMetadata->IsBufferImageGranularityConflictPossible(m_BufferImageGranularity, lastSuballocType)) + { + return true; + } + } + return false; +} + +void VmaBlockVector::MakePoolAllocationsLost( + uint32_t currentFrameIndex, + size_t* pLostAllocationCount) +{ + VmaMutexLockWrite lock(m_Mutex, m_hAllocator->m_UseMutex); + size_t lostAllocationCount = 0; + for(uint32_t blockIndex = 0; blockIndex < m_Blocks.size(); ++blockIndex) + { + VmaDeviceMemoryBlock* const pBlock = m_Blocks[blockIndex]; + VMA_ASSERT(pBlock); + lostAllocationCount += pBlock->m_pMetadata->MakeAllocationsLost(currentFrameIndex, m_FrameInUseCount); + } + if(pLostAllocationCount != VMA_NULL) + { + *pLostAllocationCount = lostAllocationCount; + } +} + +VkResult VmaBlockVector::CheckCorruption() +{ + if(!IsCorruptionDetectionEnabled()) + { + return VK_ERROR_FEATURE_NOT_PRESENT; + } + + VmaMutexLockRead lock(m_Mutex, m_hAllocator->m_UseMutex); + for(uint32_t blockIndex = 0; blockIndex < m_Blocks.size(); ++blockIndex) + { + VmaDeviceMemoryBlock* const pBlock = m_Blocks[blockIndex]; + VMA_ASSERT(pBlock); + VkResult res = pBlock->CheckCorruption(m_hAllocator); + if(res != VK_SUCCESS) + { + return res; + } + } + return VK_SUCCESS; +} + +void VmaBlockVector::AddStats(VmaStats* pStats) +{ + const uint32_t memTypeIndex = m_MemoryTypeIndex; + const uint32_t memHeapIndex = m_hAllocator->MemoryTypeIndexToHeapIndex(memTypeIndex); + + VmaMutexLockRead lock(m_Mutex, m_hAllocator->m_UseMutex); + + for(uint32_t blockIndex = 0; blockIndex < m_Blocks.size(); ++blockIndex) + { + const VmaDeviceMemoryBlock* const pBlock = m_Blocks[blockIndex]; + VMA_ASSERT(pBlock); + VMA_HEAVY_ASSERT(pBlock->Validate()); + VmaStatInfo allocationStatInfo; + pBlock->m_pMetadata->CalcAllocationStatInfo(allocationStatInfo); + VmaAddStatInfo(pStats->total, allocationStatInfo); + VmaAddStatInfo(pStats->memoryType[memTypeIndex], allocationStatInfo); + VmaAddStatInfo(pStats->memoryHeap[memHeapIndex], allocationStatInfo); + } +} + +//////////////////////////////////////////////////////////////////////////////// +// VmaDefragmentationAlgorithm_Generic members definition + +VmaDefragmentationAlgorithm_Generic::VmaDefragmentationAlgorithm_Generic( + VmaAllocator hAllocator, + VmaBlockVector* pBlockVector, + uint32_t currentFrameIndex, + bool overlappingMoveSupported) : + VmaDefragmentationAlgorithm(hAllocator, pBlockVector, currentFrameIndex), + m_AllocationCount(0), + m_AllAllocations(false), + m_BytesMoved(0), + m_AllocationsMoved(0), + m_Blocks(VmaStlAllocator(hAllocator->GetAllocationCallbacks())) +{ + // Create block info for each block. + const size_t blockCount = m_pBlockVector->m_Blocks.size(); + for(size_t blockIndex = 0; blockIndex < blockCount; ++blockIndex) + { + BlockInfo* pBlockInfo = vma_new(m_hAllocator, BlockInfo)(m_hAllocator->GetAllocationCallbacks()); + pBlockInfo->m_OriginalBlockIndex = blockIndex; + pBlockInfo->m_pBlock = m_pBlockVector->m_Blocks[blockIndex]; + m_Blocks.push_back(pBlockInfo); + } + + // Sort them by m_pBlock pointer value. + VMA_SORT(m_Blocks.begin(), m_Blocks.end(), BlockPointerLess()); +} + +VmaDefragmentationAlgorithm_Generic::~VmaDefragmentationAlgorithm_Generic() +{ + for(size_t i = m_Blocks.size(); i--; ) + { + vma_delete(m_hAllocator, m_Blocks[i]); + } +} + +void VmaDefragmentationAlgorithm_Generic::AddAllocation(VmaAllocation hAlloc, VkBool32* pChanged) +{ + // Now as we are inside VmaBlockVector::m_Mutex, we can make final check if this allocation was not lost. + if(hAlloc->GetLastUseFrameIndex() != VMA_FRAME_INDEX_LOST) + { + VmaDeviceMemoryBlock* pBlock = hAlloc->GetBlock(); + BlockInfoVector::iterator it = VmaBinaryFindFirstNotLess(m_Blocks.begin(), m_Blocks.end(), pBlock, BlockPointerLess()); + if(it != m_Blocks.end() && (*it)->m_pBlock == pBlock) + { + AllocationInfo allocInfo = AllocationInfo(hAlloc, pChanged); + (*it)->m_Allocations.push_back(allocInfo); + } + else + { + VMA_ASSERT(0); + } + + ++m_AllocationCount; + } +} + +VkResult VmaDefragmentationAlgorithm_Generic::DefragmentRound( + VmaVector< VmaDefragmentationMove, VmaStlAllocator >& moves, + VkDeviceSize maxBytesToMove, + uint32_t maxAllocationsToMove, + bool freeOldAllocations) +{ + if(m_Blocks.empty()) + { + return VK_SUCCESS; + } + + // This is a choice based on research. + // Option 1: + uint32_t strategy = VMA_ALLOCATION_CREATE_STRATEGY_MIN_TIME_BIT; + // Option 2: + //uint32_t strategy = VMA_ALLOCATION_CREATE_STRATEGY_MIN_MEMORY_BIT; + // Option 3: + //uint32_t strategy = VMA_ALLOCATION_CREATE_STRATEGY_MIN_FRAGMENTATION_BIT; + + size_t srcBlockMinIndex = 0; + // When FAST_ALGORITHM, move allocations from only last out of blocks that contain non-movable allocations. + /* + if(m_AlgorithmFlags & VMA_DEFRAGMENTATION_FAST_ALGORITHM_BIT) + { + const size_t blocksWithNonMovableCount = CalcBlocksWithNonMovableCount(); + if(blocksWithNonMovableCount > 0) + { + srcBlockMinIndex = blocksWithNonMovableCount - 1; + } + } + */ + + size_t srcBlockIndex = m_Blocks.size() - 1; + size_t srcAllocIndex = SIZE_MAX; + for(;;) + { + // 1. Find next allocation to move. + // 1.1. Start from last to first m_Blocks - they are sorted from most "destination" to most "source". + // 1.2. Then start from last to first m_Allocations. + while(srcAllocIndex >= m_Blocks[srcBlockIndex]->m_Allocations.size()) + { + if(m_Blocks[srcBlockIndex]->m_Allocations.empty()) + { + // Finished: no more allocations to process. + if(srcBlockIndex == srcBlockMinIndex) + { + return VK_SUCCESS; + } + else + { + --srcBlockIndex; + srcAllocIndex = SIZE_MAX; + } + } + else + { + srcAllocIndex = m_Blocks[srcBlockIndex]->m_Allocations.size() - 1; + } + } + + BlockInfo* pSrcBlockInfo = m_Blocks[srcBlockIndex]; + AllocationInfo& allocInfo = pSrcBlockInfo->m_Allocations[srcAllocIndex]; + + const VkDeviceSize size = allocInfo.m_hAllocation->GetSize(); + const VkDeviceSize srcOffset = allocInfo.m_hAllocation->GetOffset(); + const VkDeviceSize alignment = allocInfo.m_hAllocation->GetAlignment(); + const VmaSuballocationType suballocType = allocInfo.m_hAllocation->GetSuballocationType(); + + // 2. Try to find new place for this allocation in preceding or current block. + for(size_t dstBlockIndex = 0; dstBlockIndex <= srcBlockIndex; ++dstBlockIndex) + { + BlockInfo* pDstBlockInfo = m_Blocks[dstBlockIndex]; + VmaAllocationRequest dstAllocRequest; + if(pDstBlockInfo->m_pBlock->m_pMetadata->CreateAllocationRequest( + m_CurrentFrameIndex, + m_pBlockVector->GetFrameInUseCount(), + m_pBlockVector->GetBufferImageGranularity(), + size, + alignment, + false, // upperAddress + suballocType, + false, // canMakeOtherLost + strategy, + &dstAllocRequest) && + MoveMakesSense( + dstBlockIndex, dstAllocRequest.offset, srcBlockIndex, srcOffset)) + { + VMA_ASSERT(dstAllocRequest.itemsToMakeLostCount == 0); + + // Reached limit on number of allocations or bytes to move. + if((m_AllocationsMoved + 1 > maxAllocationsToMove) || + (m_BytesMoved + size > maxBytesToMove)) + { + return VK_SUCCESS; + } + + VmaDefragmentationMove move = {}; + move.srcBlockIndex = pSrcBlockInfo->m_OriginalBlockIndex; + move.dstBlockIndex = pDstBlockInfo->m_OriginalBlockIndex; + move.srcOffset = srcOffset; + move.dstOffset = dstAllocRequest.offset; + move.size = size; + move.hAllocation = allocInfo.m_hAllocation; + move.pSrcBlock = pSrcBlockInfo->m_pBlock; + move.pDstBlock = pDstBlockInfo->m_pBlock; + + moves.push_back(move); + + pDstBlockInfo->m_pBlock->m_pMetadata->Alloc( + dstAllocRequest, + suballocType, + size, + allocInfo.m_hAllocation); + + if(freeOldAllocations) + { + pSrcBlockInfo->m_pBlock->m_pMetadata->FreeAtOffset(srcOffset); + allocInfo.m_hAllocation->ChangeBlockAllocation(m_hAllocator, pDstBlockInfo->m_pBlock, dstAllocRequest.offset); + } + + if(allocInfo.m_pChanged != VMA_NULL) + { + *allocInfo.m_pChanged = VK_TRUE; + } + + ++m_AllocationsMoved; + m_BytesMoved += size; + + VmaVectorRemove(pSrcBlockInfo->m_Allocations, srcAllocIndex); + + break; + } + } + + // If not processed, this allocInfo remains in pBlockInfo->m_Allocations for next round. + + if(srcAllocIndex > 0) + { + --srcAllocIndex; + } + else + { + if(srcBlockIndex > 0) + { + --srcBlockIndex; + srcAllocIndex = SIZE_MAX; + } + else + { + return VK_SUCCESS; + } + } + } +} + +size_t VmaDefragmentationAlgorithm_Generic::CalcBlocksWithNonMovableCount() const +{ + size_t result = 0; + for(size_t i = 0; i < m_Blocks.size(); ++i) + { + if(m_Blocks[i]->m_HasNonMovableAllocations) + { + ++result; + } + } + return result; +} + +VkResult VmaDefragmentationAlgorithm_Generic::Defragment( + VmaVector< VmaDefragmentationMove, VmaStlAllocator >& moves, + VkDeviceSize maxBytesToMove, + uint32_t maxAllocationsToMove, + VmaDefragmentationFlags flags) +{ + if(!m_AllAllocations && m_AllocationCount == 0) + { + return VK_SUCCESS; + } + + const size_t blockCount = m_Blocks.size(); + for(size_t blockIndex = 0; blockIndex < blockCount; ++blockIndex) + { + BlockInfo* pBlockInfo = m_Blocks[blockIndex]; + + if(m_AllAllocations) + { + VmaBlockMetadata_Generic* pMetadata = (VmaBlockMetadata_Generic*)pBlockInfo->m_pBlock->m_pMetadata; + for(VmaSuballocationList::const_iterator it = pMetadata->m_Suballocations.begin(); + it != pMetadata->m_Suballocations.end(); + ++it) + { + if(it->type != VMA_SUBALLOCATION_TYPE_FREE) + { + AllocationInfo allocInfo = AllocationInfo(it->hAllocation, VMA_NULL); + pBlockInfo->m_Allocations.push_back(allocInfo); + } + } + } + + pBlockInfo->CalcHasNonMovableAllocations(); + + // This is a choice based on research. + // Option 1: + pBlockInfo->SortAllocationsByOffsetDescending(); + // Option 2: + //pBlockInfo->SortAllocationsBySizeDescending(); + } + + // Sort m_Blocks this time by the main criterium, from most "destination" to most "source" blocks. + VMA_SORT(m_Blocks.begin(), m_Blocks.end(), BlockInfoCompareMoveDestination()); + + // This is a choice based on research. + const uint32_t roundCount = 2; + + // Execute defragmentation rounds (the main part). + VkResult result = VK_SUCCESS; + for(uint32_t round = 0; (round < roundCount) && (result == VK_SUCCESS); ++round) + { + result = DefragmentRound(moves, maxBytesToMove, maxAllocationsToMove, !(flags & VMA_DEFRAGMENTATION_FLAG_INCREMENTAL)); + } + + return result; +} + +bool VmaDefragmentationAlgorithm_Generic::MoveMakesSense( + size_t dstBlockIndex, VkDeviceSize dstOffset, + size_t srcBlockIndex, VkDeviceSize srcOffset) +{ + if(dstBlockIndex < srcBlockIndex) + { + return true; + } + if(dstBlockIndex > srcBlockIndex) + { + return false; + } + if(dstOffset < srcOffset) + { + return true; + } + return false; +} + +//////////////////////////////////////////////////////////////////////////////// +// VmaDefragmentationAlgorithm_Fast + +VmaDefragmentationAlgorithm_Fast::VmaDefragmentationAlgorithm_Fast( + VmaAllocator hAllocator, + VmaBlockVector* pBlockVector, + uint32_t currentFrameIndex, + bool overlappingMoveSupported) : + VmaDefragmentationAlgorithm(hAllocator, pBlockVector, currentFrameIndex), + m_OverlappingMoveSupported(overlappingMoveSupported), + m_AllocationCount(0), + m_AllAllocations(false), + m_BytesMoved(0), + m_AllocationsMoved(0), + m_BlockInfos(VmaStlAllocator(hAllocator->GetAllocationCallbacks())) +{ + VMA_ASSERT(VMA_DEBUG_MARGIN == 0); + +} + +VmaDefragmentationAlgorithm_Fast::~VmaDefragmentationAlgorithm_Fast() +{ +} + +VkResult VmaDefragmentationAlgorithm_Fast::Defragment( + VmaVector< VmaDefragmentationMove, VmaStlAllocator >& moves, + VkDeviceSize maxBytesToMove, + uint32_t maxAllocationsToMove, + VmaDefragmentationFlags flags) +{ + VMA_ASSERT(m_AllAllocations || m_pBlockVector->CalcAllocationCount() == m_AllocationCount); + + const size_t blockCount = m_pBlockVector->GetBlockCount(); + if(blockCount == 0 || maxBytesToMove == 0 || maxAllocationsToMove == 0) + { + return VK_SUCCESS; + } + + PreprocessMetadata(); + + // Sort blocks in order from most destination. + + m_BlockInfos.resize(blockCount); + for(size_t i = 0; i < blockCount; ++i) + { + m_BlockInfos[i].origBlockIndex = i; + } + + VMA_SORT(m_BlockInfos.begin(), m_BlockInfos.end(), [this](const BlockInfo& lhs, const BlockInfo& rhs) -> bool { + return m_pBlockVector->GetBlock(lhs.origBlockIndex)->m_pMetadata->GetSumFreeSize() < + m_pBlockVector->GetBlock(rhs.origBlockIndex)->m_pMetadata->GetSumFreeSize(); + }); + + // THE MAIN ALGORITHM + + FreeSpaceDatabase freeSpaceDb; + + size_t dstBlockInfoIndex = 0; + size_t dstOrigBlockIndex = m_BlockInfos[dstBlockInfoIndex].origBlockIndex; + VmaDeviceMemoryBlock* pDstBlock = m_pBlockVector->GetBlock(dstOrigBlockIndex); + VmaBlockMetadata_Generic* pDstMetadata = (VmaBlockMetadata_Generic*)pDstBlock->m_pMetadata; + VkDeviceSize dstBlockSize = pDstMetadata->GetSize(); + VkDeviceSize dstOffset = 0; + + bool end = false; + for(size_t srcBlockInfoIndex = 0; !end && srcBlockInfoIndex < blockCount; ++srcBlockInfoIndex) + { + const size_t srcOrigBlockIndex = m_BlockInfos[srcBlockInfoIndex].origBlockIndex; + VmaDeviceMemoryBlock* const pSrcBlock = m_pBlockVector->GetBlock(srcOrigBlockIndex); + VmaBlockMetadata_Generic* const pSrcMetadata = (VmaBlockMetadata_Generic*)pSrcBlock->m_pMetadata; + for(VmaSuballocationList::iterator srcSuballocIt = pSrcMetadata->m_Suballocations.begin(); + !end && srcSuballocIt != pSrcMetadata->m_Suballocations.end(); ) + { + VmaAllocation_T* const pAlloc = srcSuballocIt->hAllocation; + const VkDeviceSize srcAllocAlignment = pAlloc->GetAlignment(); + const VkDeviceSize srcAllocSize = srcSuballocIt->size; + if(m_AllocationsMoved == maxAllocationsToMove || + m_BytesMoved + srcAllocSize > maxBytesToMove) + { + end = true; + break; + } + const VkDeviceSize srcAllocOffset = srcSuballocIt->offset; + + VmaDefragmentationMove move = {}; + // Try to place it in one of free spaces from the database. + size_t freeSpaceInfoIndex; + VkDeviceSize dstAllocOffset; + if(freeSpaceDb.Fetch(srcAllocAlignment, srcAllocSize, + freeSpaceInfoIndex, dstAllocOffset)) + { + size_t freeSpaceOrigBlockIndex = m_BlockInfos[freeSpaceInfoIndex].origBlockIndex; + VmaDeviceMemoryBlock* pFreeSpaceBlock = m_pBlockVector->GetBlock(freeSpaceOrigBlockIndex); + VmaBlockMetadata_Generic* pFreeSpaceMetadata = (VmaBlockMetadata_Generic*)pFreeSpaceBlock->m_pMetadata; + + // Same block + if(freeSpaceInfoIndex == srcBlockInfoIndex) + { + VMA_ASSERT(dstAllocOffset <= srcAllocOffset); + + // MOVE OPTION 1: Move the allocation inside the same block by decreasing offset. + + VmaSuballocation suballoc = *srcSuballocIt; + suballoc.offset = dstAllocOffset; + suballoc.hAllocation->ChangeOffset(dstAllocOffset); + m_BytesMoved += srcAllocSize; + ++m_AllocationsMoved; + + VmaSuballocationList::iterator nextSuballocIt = srcSuballocIt; + ++nextSuballocIt; + pSrcMetadata->m_Suballocations.erase(srcSuballocIt); + srcSuballocIt = nextSuballocIt; + + InsertSuballoc(pFreeSpaceMetadata, suballoc); + + move.srcBlockIndex = srcOrigBlockIndex; + move.dstBlockIndex = freeSpaceOrigBlockIndex; + move.srcOffset = srcAllocOffset; + move.dstOffset = dstAllocOffset; + move.size = srcAllocSize; + + moves.push_back(move); + } + // Different block + else + { + // MOVE OPTION 2: Move the allocation to a different block. + + VMA_ASSERT(freeSpaceInfoIndex < srcBlockInfoIndex); + + VmaSuballocation suballoc = *srcSuballocIt; + suballoc.offset = dstAllocOffset; + suballoc.hAllocation->ChangeBlockAllocation(m_hAllocator, pFreeSpaceBlock, dstAllocOffset); + m_BytesMoved += srcAllocSize; + ++m_AllocationsMoved; + + VmaSuballocationList::iterator nextSuballocIt = srcSuballocIt; + ++nextSuballocIt; + pSrcMetadata->m_Suballocations.erase(srcSuballocIt); + srcSuballocIt = nextSuballocIt; + + InsertSuballoc(pFreeSpaceMetadata, suballoc); + + move.srcBlockIndex = srcOrigBlockIndex; + move.dstBlockIndex = freeSpaceOrigBlockIndex; + move.srcOffset = srcAllocOffset; + move.dstOffset = dstAllocOffset; + move.size = srcAllocSize; + + moves.push_back(move); + } + } + else + { + dstAllocOffset = VmaAlignUp(dstOffset, srcAllocAlignment); + + // If the allocation doesn't fit before the end of dstBlock, forward to next block. + while(dstBlockInfoIndex < srcBlockInfoIndex && + dstAllocOffset + srcAllocSize > dstBlockSize) + { + // But before that, register remaining free space at the end of dst block. + freeSpaceDb.Register(dstBlockInfoIndex, dstOffset, dstBlockSize - dstOffset); + + ++dstBlockInfoIndex; + dstOrigBlockIndex = m_BlockInfos[dstBlockInfoIndex].origBlockIndex; + pDstBlock = m_pBlockVector->GetBlock(dstOrigBlockIndex); + pDstMetadata = (VmaBlockMetadata_Generic*)pDstBlock->m_pMetadata; + dstBlockSize = pDstMetadata->GetSize(); + dstOffset = 0; + dstAllocOffset = 0; + } + + // Same block + if(dstBlockInfoIndex == srcBlockInfoIndex) + { + VMA_ASSERT(dstAllocOffset <= srcAllocOffset); + + const bool overlap = dstAllocOffset + srcAllocSize > srcAllocOffset; + + bool skipOver = overlap; + if(overlap && m_OverlappingMoveSupported && dstAllocOffset < srcAllocOffset) + { + // If destination and source place overlap, skip if it would move it + // by only < 1/64 of its size. + skipOver = (srcAllocOffset - dstAllocOffset) * 64 < srcAllocSize; + } + + if(skipOver) + { + freeSpaceDb.Register(dstBlockInfoIndex, dstOffset, srcAllocOffset - dstOffset); + + dstOffset = srcAllocOffset + srcAllocSize; + ++srcSuballocIt; + } + // MOVE OPTION 1: Move the allocation inside the same block by decreasing offset. + else + { + srcSuballocIt->offset = dstAllocOffset; + srcSuballocIt->hAllocation->ChangeOffset(dstAllocOffset); + dstOffset = dstAllocOffset + srcAllocSize; + m_BytesMoved += srcAllocSize; + ++m_AllocationsMoved; + ++srcSuballocIt; + + move.srcBlockIndex = srcOrigBlockIndex; + move.dstBlockIndex = dstOrigBlockIndex; + move.srcOffset = srcAllocOffset; + move.dstOffset = dstAllocOffset; + move.size = srcAllocSize; + + moves.push_back(move); + } + } + // Different block + else + { + // MOVE OPTION 2: Move the allocation to a different block. + + VMA_ASSERT(dstBlockInfoIndex < srcBlockInfoIndex); + VMA_ASSERT(dstAllocOffset + srcAllocSize <= dstBlockSize); + + VmaSuballocation suballoc = *srcSuballocIt; + suballoc.offset = dstAllocOffset; + suballoc.hAllocation->ChangeBlockAllocation(m_hAllocator, pDstBlock, dstAllocOffset); + dstOffset = dstAllocOffset + srcAllocSize; + m_BytesMoved += srcAllocSize; + ++m_AllocationsMoved; + + VmaSuballocationList::iterator nextSuballocIt = srcSuballocIt; + ++nextSuballocIt; + pSrcMetadata->m_Suballocations.erase(srcSuballocIt); + srcSuballocIt = nextSuballocIt; + + pDstMetadata->m_Suballocations.push_back(suballoc); + + move.srcBlockIndex = srcOrigBlockIndex; + move.dstBlockIndex = dstOrigBlockIndex; + move.srcOffset = srcAllocOffset; + move.dstOffset = dstAllocOffset; + move.size = srcAllocSize; + + moves.push_back(move); + } + } + } + } + + m_BlockInfos.clear(); + + PostprocessMetadata(); + + return VK_SUCCESS; +} + +void VmaDefragmentationAlgorithm_Fast::PreprocessMetadata() +{ + const size_t blockCount = m_pBlockVector->GetBlockCount(); + for(size_t blockIndex = 0; blockIndex < blockCount; ++blockIndex) + { + VmaBlockMetadata_Generic* const pMetadata = + (VmaBlockMetadata_Generic*)m_pBlockVector->GetBlock(blockIndex)->m_pMetadata; + pMetadata->m_FreeCount = 0; + pMetadata->m_SumFreeSize = pMetadata->GetSize(); + pMetadata->m_FreeSuballocationsBySize.clear(); + for(VmaSuballocationList::iterator it = pMetadata->m_Suballocations.begin(); + it != pMetadata->m_Suballocations.end(); ) + { + if(it->type == VMA_SUBALLOCATION_TYPE_FREE) + { + VmaSuballocationList::iterator nextIt = it; + ++nextIt; + pMetadata->m_Suballocations.erase(it); + it = nextIt; + } + else + { + ++it; + } + } + } +} + +void VmaDefragmentationAlgorithm_Fast::PostprocessMetadata() +{ + const size_t blockCount = m_pBlockVector->GetBlockCount(); + for(size_t blockIndex = 0; blockIndex < blockCount; ++blockIndex) + { + VmaBlockMetadata_Generic* const pMetadata = + (VmaBlockMetadata_Generic*)m_pBlockVector->GetBlock(blockIndex)->m_pMetadata; + const VkDeviceSize blockSize = pMetadata->GetSize(); + + // No allocations in this block - entire area is free. + if(pMetadata->m_Suballocations.empty()) + { + pMetadata->m_FreeCount = 1; + //pMetadata->m_SumFreeSize is already set to blockSize. + VmaSuballocation suballoc = { + 0, // offset + blockSize, // size + VMA_NULL, // hAllocation + VMA_SUBALLOCATION_TYPE_FREE }; + pMetadata->m_Suballocations.push_back(suballoc); + pMetadata->RegisterFreeSuballocation(pMetadata->m_Suballocations.begin()); + } + // There are some allocations in this block. + else + { + VkDeviceSize offset = 0; + VmaSuballocationList::iterator it; + for(it = pMetadata->m_Suballocations.begin(); + it != pMetadata->m_Suballocations.end(); + ++it) + { + VMA_ASSERT(it->type != VMA_SUBALLOCATION_TYPE_FREE); + VMA_ASSERT(it->offset >= offset); + + // Need to insert preceding free space. + if(it->offset > offset) + { + ++pMetadata->m_FreeCount; + const VkDeviceSize freeSize = it->offset - offset; + VmaSuballocation suballoc = { + offset, // offset + freeSize, // size + VMA_NULL, // hAllocation + VMA_SUBALLOCATION_TYPE_FREE }; + VmaSuballocationList::iterator precedingFreeIt = pMetadata->m_Suballocations.insert(it, suballoc); + if(freeSize >= VMA_MIN_FREE_SUBALLOCATION_SIZE_TO_REGISTER) + { + pMetadata->m_FreeSuballocationsBySize.push_back(precedingFreeIt); + } + } + + pMetadata->m_SumFreeSize -= it->size; + offset = it->offset + it->size; + } + + // Need to insert trailing free space. + if(offset < blockSize) + { + ++pMetadata->m_FreeCount; + const VkDeviceSize freeSize = blockSize - offset; + VmaSuballocation suballoc = { + offset, // offset + freeSize, // size + VMA_NULL, // hAllocation + VMA_SUBALLOCATION_TYPE_FREE }; + VMA_ASSERT(it == pMetadata->m_Suballocations.end()); + VmaSuballocationList::iterator trailingFreeIt = pMetadata->m_Suballocations.insert(it, suballoc); + if(freeSize > VMA_MIN_FREE_SUBALLOCATION_SIZE_TO_REGISTER) + { + pMetadata->m_FreeSuballocationsBySize.push_back(trailingFreeIt); + } + } + + VMA_SORT( + pMetadata->m_FreeSuballocationsBySize.begin(), + pMetadata->m_FreeSuballocationsBySize.end(), + VmaSuballocationItemSizeLess()); + } + + VMA_HEAVY_ASSERT(pMetadata->Validate()); + } +} + +void VmaDefragmentationAlgorithm_Fast::InsertSuballoc(VmaBlockMetadata_Generic* pMetadata, const VmaSuballocation& suballoc) +{ + // TODO: Optimize somehow. Remember iterator instead of searching for it linearly. + VmaSuballocationList::iterator it = pMetadata->m_Suballocations.begin(); + while(it != pMetadata->m_Suballocations.end()) + { + if(it->offset < suballoc.offset) + { + ++it; + } + } + pMetadata->m_Suballocations.insert(it, suballoc); +} + +//////////////////////////////////////////////////////////////////////////////// +// VmaBlockVectorDefragmentationContext + +VmaBlockVectorDefragmentationContext::VmaBlockVectorDefragmentationContext( + VmaAllocator hAllocator, + VmaPool hCustomPool, + VmaBlockVector* pBlockVector, + uint32_t currFrameIndex) : + res(VK_SUCCESS), + mutexLocked(false), + blockContexts(VmaStlAllocator(hAllocator->GetAllocationCallbacks())), + defragmentationMoves(VmaStlAllocator(hAllocator->GetAllocationCallbacks())), + defragmentationMovesProcessed(0), + defragmentationMovesCommitted(0), + hasDefragmentationPlan(0), + m_hAllocator(hAllocator), + m_hCustomPool(hCustomPool), + m_pBlockVector(pBlockVector), + m_CurrFrameIndex(currFrameIndex), + m_pAlgorithm(VMA_NULL), + m_Allocations(VmaStlAllocator(hAllocator->GetAllocationCallbacks())), + m_AllAllocations(false) +{ +} + +VmaBlockVectorDefragmentationContext::~VmaBlockVectorDefragmentationContext() +{ + vma_delete(m_hAllocator, m_pAlgorithm); +} + +void VmaBlockVectorDefragmentationContext::AddAllocation(VmaAllocation hAlloc, VkBool32* pChanged) +{ + AllocInfo info = { hAlloc, pChanged }; + m_Allocations.push_back(info); +} + +void VmaBlockVectorDefragmentationContext::Begin(bool overlappingMoveSupported, VmaDefragmentationFlags flags) +{ + const bool allAllocations = m_AllAllocations || + m_Allocations.size() == m_pBlockVector->CalcAllocationCount(); + + /******************************** + HERE IS THE CHOICE OF DEFRAGMENTATION ALGORITHM. + ********************************/ + + /* + Fast algorithm is supported only when certain criteria are met: + - VMA_DEBUG_MARGIN is 0. + - All allocations in this block vector are moveable. + - There is no possibility of image/buffer granularity conflict. + - The defragmentation is not incremental + */ + if(VMA_DEBUG_MARGIN == 0 && + allAllocations && + !m_pBlockVector->IsBufferImageGranularityConflictPossible() && + !(flags & VMA_DEFRAGMENTATION_FLAG_INCREMENTAL)) + { + m_pAlgorithm = vma_new(m_hAllocator, VmaDefragmentationAlgorithm_Fast)( + m_hAllocator, m_pBlockVector, m_CurrFrameIndex, overlappingMoveSupported); + } + else + { + m_pAlgorithm = vma_new(m_hAllocator, VmaDefragmentationAlgorithm_Generic)( + m_hAllocator, m_pBlockVector, m_CurrFrameIndex, overlappingMoveSupported); + } + + if(allAllocations) + { + m_pAlgorithm->AddAll(); + } + else + { + for(size_t i = 0, count = m_Allocations.size(); i < count; ++i) + { + m_pAlgorithm->AddAllocation(m_Allocations[i].hAlloc, m_Allocations[i].pChanged); + } + } +} + +//////////////////////////////////////////////////////////////////////////////// +// VmaDefragmentationContext + +VmaDefragmentationContext_T::VmaDefragmentationContext_T( + VmaAllocator hAllocator, + uint32_t currFrameIndex, + uint32_t flags, + VmaDefragmentationStats* pStats) : + m_hAllocator(hAllocator), + m_CurrFrameIndex(currFrameIndex), + m_Flags(flags), + m_pStats(pStats), + m_CustomPoolContexts(VmaStlAllocator(hAllocator->GetAllocationCallbacks())) +{ + memset(m_DefaultPoolContexts, 0, sizeof(m_DefaultPoolContexts)); +} + +VmaDefragmentationContext_T::~VmaDefragmentationContext_T() +{ + for(size_t i = m_CustomPoolContexts.size(); i--; ) + { + VmaBlockVectorDefragmentationContext* pBlockVectorCtx = m_CustomPoolContexts[i]; + pBlockVectorCtx->GetBlockVector()->DefragmentationEnd(pBlockVectorCtx, m_pStats); + vma_delete(m_hAllocator, pBlockVectorCtx); + } + for(size_t i = m_hAllocator->m_MemProps.memoryTypeCount; i--; ) + { + VmaBlockVectorDefragmentationContext* pBlockVectorCtx = m_DefaultPoolContexts[i]; + if(pBlockVectorCtx) + { + pBlockVectorCtx->GetBlockVector()->DefragmentationEnd(pBlockVectorCtx, m_pStats); + vma_delete(m_hAllocator, pBlockVectorCtx); + } + } +} + +void VmaDefragmentationContext_T::AddPools(uint32_t poolCount, VmaPool* pPools) +{ + for(uint32_t poolIndex = 0; poolIndex < poolCount; ++poolIndex) + { + VmaPool pool = pPools[poolIndex]; + VMA_ASSERT(pool); + // Pools with algorithm other than default are not defragmented. + if(pool->m_BlockVector.GetAlgorithm() == 0) + { + VmaBlockVectorDefragmentationContext* pBlockVectorDefragCtx = VMA_NULL; + + for(size_t i = m_CustomPoolContexts.size(); i--; ) + { + if(m_CustomPoolContexts[i]->GetCustomPool() == pool) + { + pBlockVectorDefragCtx = m_CustomPoolContexts[i]; + break; + } + } + + if(!pBlockVectorDefragCtx) + { + pBlockVectorDefragCtx = vma_new(m_hAllocator, VmaBlockVectorDefragmentationContext)( + m_hAllocator, + pool, + &pool->m_BlockVector, + m_CurrFrameIndex); + m_CustomPoolContexts.push_back(pBlockVectorDefragCtx); + } + + pBlockVectorDefragCtx->AddAll(); + } + } +} + +void VmaDefragmentationContext_T::AddAllocations( + uint32_t allocationCount, + VmaAllocation* pAllocations, + VkBool32* pAllocationsChanged) +{ + // Dispatch pAllocations among defragmentators. Create them when necessary. + for(uint32_t allocIndex = 0; allocIndex < allocationCount; ++allocIndex) + { + const VmaAllocation hAlloc = pAllocations[allocIndex]; + VMA_ASSERT(hAlloc); + // DedicatedAlloc cannot be defragmented. + if((hAlloc->GetType() == VmaAllocation_T::ALLOCATION_TYPE_BLOCK) && + // Lost allocation cannot be defragmented. + (hAlloc->GetLastUseFrameIndex() != VMA_FRAME_INDEX_LOST)) + { + VmaBlockVectorDefragmentationContext* pBlockVectorDefragCtx = VMA_NULL; + + const VmaPool hAllocPool = hAlloc->GetBlock()->GetParentPool(); + // This allocation belongs to custom pool. + if(hAllocPool != VK_NULL_HANDLE) + { + // Pools with algorithm other than default are not defragmented. + if(hAllocPool->m_BlockVector.GetAlgorithm() == 0) + { + for(size_t i = m_CustomPoolContexts.size(); i--; ) + { + if(m_CustomPoolContexts[i]->GetCustomPool() == hAllocPool) + { + pBlockVectorDefragCtx = m_CustomPoolContexts[i]; + break; + } + } + if(!pBlockVectorDefragCtx) + { + pBlockVectorDefragCtx = vma_new(m_hAllocator, VmaBlockVectorDefragmentationContext)( + m_hAllocator, + hAllocPool, + &hAllocPool->m_BlockVector, + m_CurrFrameIndex); + m_CustomPoolContexts.push_back(pBlockVectorDefragCtx); + } + } + } + // This allocation belongs to default pool. + else + { + const uint32_t memTypeIndex = hAlloc->GetMemoryTypeIndex(); + pBlockVectorDefragCtx = m_DefaultPoolContexts[memTypeIndex]; + if(!pBlockVectorDefragCtx) + { + pBlockVectorDefragCtx = vma_new(m_hAllocator, VmaBlockVectorDefragmentationContext)( + m_hAllocator, + VMA_NULL, // hCustomPool + m_hAllocator->m_pBlockVectors[memTypeIndex], + m_CurrFrameIndex); + m_DefaultPoolContexts[memTypeIndex] = pBlockVectorDefragCtx; + } + } + + if(pBlockVectorDefragCtx) + { + VkBool32* const pChanged = (pAllocationsChanged != VMA_NULL) ? + &pAllocationsChanged[allocIndex] : VMA_NULL; + pBlockVectorDefragCtx->AddAllocation(hAlloc, pChanged); + } + } + } +} + +VkResult VmaDefragmentationContext_T::Defragment( + VkDeviceSize maxCpuBytesToMove, uint32_t maxCpuAllocationsToMove, + VkDeviceSize maxGpuBytesToMove, uint32_t maxGpuAllocationsToMove, + VkCommandBuffer commandBuffer, VmaDefragmentationStats* pStats, VmaDefragmentationFlags flags) +{ + if(pStats) + { + memset(pStats, 0, sizeof(VmaDefragmentationStats)); + } + + if(flags & VMA_DEFRAGMENTATION_FLAG_INCREMENTAL) + { + // For incremental defragmetnations, we just earmark how much we can move + // The real meat is in the defragmentation steps + m_MaxCpuBytesToMove = maxCpuBytesToMove; + m_MaxCpuAllocationsToMove = maxCpuAllocationsToMove; + + m_MaxGpuBytesToMove = maxGpuBytesToMove; + m_MaxGpuAllocationsToMove = maxGpuAllocationsToMove; + + if(m_MaxCpuBytesToMove == 0 && m_MaxCpuAllocationsToMove == 0 && + m_MaxGpuBytesToMove == 0 && m_MaxGpuAllocationsToMove == 0) + return VK_SUCCESS; + + return VK_NOT_READY; + } + + if(commandBuffer == VK_NULL_HANDLE) + { + maxGpuBytesToMove = 0; + maxGpuAllocationsToMove = 0; + } + + VkResult res = VK_SUCCESS; + + // Process default pools. + for(uint32_t memTypeIndex = 0; + memTypeIndex < m_hAllocator->GetMemoryTypeCount() && res >= VK_SUCCESS; + ++memTypeIndex) + { + VmaBlockVectorDefragmentationContext* pBlockVectorCtx = m_DefaultPoolContexts[memTypeIndex]; + if(pBlockVectorCtx) + { + VMA_ASSERT(pBlockVectorCtx->GetBlockVector()); + pBlockVectorCtx->GetBlockVector()->Defragment( + pBlockVectorCtx, + pStats, flags, + maxCpuBytesToMove, maxCpuAllocationsToMove, + maxGpuBytesToMove, maxGpuAllocationsToMove, + commandBuffer); + if(pBlockVectorCtx->res != VK_SUCCESS) + { + res = pBlockVectorCtx->res; + } + } + } + + // Process custom pools. + for(size_t customCtxIndex = 0, customCtxCount = m_CustomPoolContexts.size(); + customCtxIndex < customCtxCount && res >= VK_SUCCESS; + ++customCtxIndex) + { + VmaBlockVectorDefragmentationContext* pBlockVectorCtx = m_CustomPoolContexts[customCtxIndex]; + VMA_ASSERT(pBlockVectorCtx && pBlockVectorCtx->GetBlockVector()); + pBlockVectorCtx->GetBlockVector()->Defragment( + pBlockVectorCtx, + pStats, flags, + maxCpuBytesToMove, maxCpuAllocationsToMove, + maxGpuBytesToMove, maxGpuAllocationsToMove, + commandBuffer); + if(pBlockVectorCtx->res != VK_SUCCESS) + { + res = pBlockVectorCtx->res; + } + } + + return res; +} + +VkResult VmaDefragmentationContext_T::DefragmentPassBegin(VmaDefragmentationPassInfo* pInfo) +{ + VmaDefragmentationPassMoveInfo* pCurrentMove = pInfo->pMoves; + uint32_t movesLeft = pInfo->moveCount; + + // Process default pools. + for(uint32_t memTypeIndex = 0; + memTypeIndex < m_hAllocator->GetMemoryTypeCount(); + ++memTypeIndex) + { + VmaBlockVectorDefragmentationContext *pBlockVectorCtx = m_DefaultPoolContexts[memTypeIndex]; + if(pBlockVectorCtx) + { + VMA_ASSERT(pBlockVectorCtx->GetBlockVector()); + + if(!pBlockVectorCtx->hasDefragmentationPlan) + { + pBlockVectorCtx->GetBlockVector()->Defragment( + pBlockVectorCtx, + m_pStats, m_Flags, + m_MaxCpuBytesToMove, m_MaxCpuAllocationsToMove, + m_MaxGpuBytesToMove, m_MaxGpuAllocationsToMove, + VK_NULL_HANDLE); + + if(pBlockVectorCtx->res < VK_SUCCESS) + continue; + + pBlockVectorCtx->hasDefragmentationPlan = true; + } + + const uint32_t processed = pBlockVectorCtx->GetBlockVector()->ProcessDefragmentations( + pBlockVectorCtx, + pCurrentMove, movesLeft); + + movesLeft -= processed; + pCurrentMove += processed; + } + } + + // Process custom pools. + for(size_t customCtxIndex = 0, customCtxCount = m_CustomPoolContexts.size(); + customCtxIndex < customCtxCount; + ++customCtxIndex) + { + VmaBlockVectorDefragmentationContext *pBlockVectorCtx = m_CustomPoolContexts[customCtxIndex]; + VMA_ASSERT(pBlockVectorCtx && pBlockVectorCtx->GetBlockVector()); + + if(!pBlockVectorCtx->hasDefragmentationPlan) + { + pBlockVectorCtx->GetBlockVector()->Defragment( + pBlockVectorCtx, + m_pStats, m_Flags, + m_MaxCpuBytesToMove, m_MaxCpuAllocationsToMove, + m_MaxGpuBytesToMove, m_MaxGpuAllocationsToMove, + VK_NULL_HANDLE); + + if(pBlockVectorCtx->res < VK_SUCCESS) + continue; + + pBlockVectorCtx->hasDefragmentationPlan = true; + } + + const uint32_t processed = pBlockVectorCtx->GetBlockVector()->ProcessDefragmentations( + pBlockVectorCtx, + pCurrentMove, movesLeft); + + movesLeft -= processed; + pCurrentMove += processed; + } + + pInfo->moveCount = pInfo->moveCount - movesLeft; + + return VK_SUCCESS; +} +VkResult VmaDefragmentationContext_T::DefragmentPassEnd() +{ + VkResult res = VK_SUCCESS; + + // Process default pools. + for(uint32_t memTypeIndex = 0; + memTypeIndex < m_hAllocator->GetMemoryTypeCount(); + ++memTypeIndex) + { + VmaBlockVectorDefragmentationContext *pBlockVectorCtx = m_DefaultPoolContexts[memTypeIndex]; + if(pBlockVectorCtx) + { + VMA_ASSERT(pBlockVectorCtx->GetBlockVector()); + + if(!pBlockVectorCtx->hasDefragmentationPlan) + { + res = VK_NOT_READY; + continue; + } + + pBlockVectorCtx->GetBlockVector()->CommitDefragmentations( + pBlockVectorCtx, m_pStats); + + if(pBlockVectorCtx->defragmentationMoves.size() != pBlockVectorCtx->defragmentationMovesCommitted) + res = VK_NOT_READY; + } + } + + // Process custom pools. + for(size_t customCtxIndex = 0, customCtxCount = m_CustomPoolContexts.size(); + customCtxIndex < customCtxCount; + ++customCtxIndex) + { + VmaBlockVectorDefragmentationContext *pBlockVectorCtx = m_CustomPoolContexts[customCtxIndex]; + VMA_ASSERT(pBlockVectorCtx && pBlockVectorCtx->GetBlockVector()); + + if(!pBlockVectorCtx->hasDefragmentationPlan) + { + res = VK_NOT_READY; + continue; + } + + pBlockVectorCtx->GetBlockVector()->CommitDefragmentations( + pBlockVectorCtx, m_pStats); + + if(pBlockVectorCtx->defragmentationMoves.size() != pBlockVectorCtx->defragmentationMovesCommitted) + res = VK_NOT_READY; + } + + return res; +} + +//////////////////////////////////////////////////////////////////////////////// +// VmaRecorder + +#if VMA_RECORDING_ENABLED + +VmaRecorder::VmaRecorder() : + m_UseMutex(true), + m_Flags(0), + m_File(VMA_NULL), + m_Freq(INT64_MAX), + m_StartCounter(INT64_MAX) +{ +} + +VkResult VmaRecorder::Init(const VmaRecordSettings& settings, bool useMutex) +{ + m_UseMutex = useMutex; + m_Flags = settings.flags; + + QueryPerformanceFrequency((LARGE_INTEGER*)&m_Freq); + QueryPerformanceCounter((LARGE_INTEGER*)&m_StartCounter); + + // Open file for writing. + errno_t err = fopen_s(&m_File, settings.pFilePath, "wb"); + if(err != 0) + { + return VK_ERROR_INITIALIZATION_FAILED; + } + + // Write header. + fprintf(m_File, "%s\n", "Vulkan Memory Allocator,Calls recording"); + fprintf(m_File, "%s\n", "1,8"); + + return VK_SUCCESS; +} + +VmaRecorder::~VmaRecorder() +{ + if(m_File != VMA_NULL) + { + fclose(m_File); + } +} + +void VmaRecorder::RecordCreateAllocator(uint32_t frameIndex) +{ + CallParams callParams; + GetBasicParams(callParams); + + VmaMutexLock lock(m_FileMutex, m_UseMutex); + fprintf(m_File, "%u,%.3f,%u,vmaCreateAllocator\n", callParams.threadId, callParams.time, frameIndex); + Flush(); +} + +void VmaRecorder::RecordDestroyAllocator(uint32_t frameIndex) +{ + CallParams callParams; + GetBasicParams(callParams); + + VmaMutexLock lock(m_FileMutex, m_UseMutex); + fprintf(m_File, "%u,%.3f,%u,vmaDestroyAllocator\n", callParams.threadId, callParams.time, frameIndex); + Flush(); +} + +void VmaRecorder::RecordCreatePool(uint32_t frameIndex, const VmaPoolCreateInfo& createInfo, VmaPool pool) +{ + CallParams callParams; + GetBasicParams(callParams); + + VmaMutexLock lock(m_FileMutex, m_UseMutex); + fprintf(m_File, "%u,%.3f,%u,vmaCreatePool,%u,%u,%llu,%llu,%llu,%u,%p\n", callParams.threadId, callParams.time, frameIndex, + createInfo.memoryTypeIndex, + createInfo.flags, + createInfo.blockSize, + (uint64_t)createInfo.minBlockCount, + (uint64_t)createInfo.maxBlockCount, + createInfo.frameInUseCount, + pool); + Flush(); +} + +void VmaRecorder::RecordDestroyPool(uint32_t frameIndex, VmaPool pool) +{ + CallParams callParams; + GetBasicParams(callParams); + + VmaMutexLock lock(m_FileMutex, m_UseMutex); + fprintf(m_File, "%u,%.3f,%u,vmaDestroyPool,%p\n", callParams.threadId, callParams.time, frameIndex, + pool); + Flush(); +} + +void VmaRecorder::RecordAllocateMemory(uint32_t frameIndex, + const VkMemoryRequirements& vkMemReq, + const VmaAllocationCreateInfo& createInfo, + VmaAllocation allocation) +{ + CallParams callParams; + GetBasicParams(callParams); + + VmaMutexLock lock(m_FileMutex, m_UseMutex); + UserDataString userDataStr(createInfo.flags, createInfo.pUserData); + fprintf(m_File, "%u,%.3f,%u,vmaAllocateMemory,%llu,%llu,%u,%u,%u,%u,%u,%u,%p,%p,%s\n", callParams.threadId, callParams.time, frameIndex, + vkMemReq.size, + vkMemReq.alignment, + vkMemReq.memoryTypeBits, + createInfo.flags, + createInfo.usage, + createInfo.requiredFlags, + createInfo.preferredFlags, + createInfo.memoryTypeBits, + createInfo.pool, + allocation, + userDataStr.GetString()); + Flush(); +} + +void VmaRecorder::RecordAllocateMemoryPages(uint32_t frameIndex, + const VkMemoryRequirements& vkMemReq, + const VmaAllocationCreateInfo& createInfo, + uint64_t allocationCount, + const VmaAllocation* pAllocations) +{ + CallParams callParams; + GetBasicParams(callParams); + + VmaMutexLock lock(m_FileMutex, m_UseMutex); + UserDataString userDataStr(createInfo.flags, createInfo.pUserData); + fprintf(m_File, "%u,%.3f,%u,vmaAllocateMemoryPages,%llu,%llu,%u,%u,%u,%u,%u,%u,%p,", callParams.threadId, callParams.time, frameIndex, + vkMemReq.size, + vkMemReq.alignment, + vkMemReq.memoryTypeBits, + createInfo.flags, + createInfo.usage, + createInfo.requiredFlags, + createInfo.preferredFlags, + createInfo.memoryTypeBits, + createInfo.pool); + PrintPointerList(allocationCount, pAllocations); + fprintf(m_File, ",%s\n", userDataStr.GetString()); + Flush(); +} + +void VmaRecorder::RecordAllocateMemoryForBuffer(uint32_t frameIndex, + const VkMemoryRequirements& vkMemReq, + bool requiresDedicatedAllocation, + bool prefersDedicatedAllocation, + const VmaAllocationCreateInfo& createInfo, + VmaAllocation allocation) +{ + CallParams callParams; + GetBasicParams(callParams); + + VmaMutexLock lock(m_FileMutex, m_UseMutex); + UserDataString userDataStr(createInfo.flags, createInfo.pUserData); + fprintf(m_File, "%u,%.3f,%u,vmaAllocateMemoryForBuffer,%llu,%llu,%u,%u,%u,%u,%u,%u,%u,%u,%p,%p,%s\n", callParams.threadId, callParams.time, frameIndex, + vkMemReq.size, + vkMemReq.alignment, + vkMemReq.memoryTypeBits, + requiresDedicatedAllocation ? 1 : 0, + prefersDedicatedAllocation ? 1 : 0, + createInfo.flags, + createInfo.usage, + createInfo.requiredFlags, + createInfo.preferredFlags, + createInfo.memoryTypeBits, + createInfo.pool, + allocation, + userDataStr.GetString()); + Flush(); +} + +void VmaRecorder::RecordAllocateMemoryForImage(uint32_t frameIndex, + const VkMemoryRequirements& vkMemReq, + bool requiresDedicatedAllocation, + bool prefersDedicatedAllocation, + const VmaAllocationCreateInfo& createInfo, + VmaAllocation allocation) +{ + CallParams callParams; + GetBasicParams(callParams); + + VmaMutexLock lock(m_FileMutex, m_UseMutex); + UserDataString userDataStr(createInfo.flags, createInfo.pUserData); + fprintf(m_File, "%u,%.3f,%u,vmaAllocateMemoryForImage,%llu,%llu,%u,%u,%u,%u,%u,%u,%u,%u,%p,%p,%s\n", callParams.threadId, callParams.time, frameIndex, + vkMemReq.size, + vkMemReq.alignment, + vkMemReq.memoryTypeBits, + requiresDedicatedAllocation ? 1 : 0, + prefersDedicatedAllocation ? 1 : 0, + createInfo.flags, + createInfo.usage, + createInfo.requiredFlags, + createInfo.preferredFlags, + createInfo.memoryTypeBits, + createInfo.pool, + allocation, + userDataStr.GetString()); + Flush(); +} + +void VmaRecorder::RecordFreeMemory(uint32_t frameIndex, + VmaAllocation allocation) +{ + CallParams callParams; + GetBasicParams(callParams); + + VmaMutexLock lock(m_FileMutex, m_UseMutex); + fprintf(m_File, "%u,%.3f,%u,vmaFreeMemory,%p\n", callParams.threadId, callParams.time, frameIndex, + allocation); + Flush(); +} + +void VmaRecorder::RecordFreeMemoryPages(uint32_t frameIndex, + uint64_t allocationCount, + const VmaAllocation* pAllocations) +{ + CallParams callParams; + GetBasicParams(callParams); + + VmaMutexLock lock(m_FileMutex, m_UseMutex); + fprintf(m_File, "%u,%.3f,%u,vmaFreeMemoryPages,", callParams.threadId, callParams.time, frameIndex); + PrintPointerList(allocationCount, pAllocations); + fprintf(m_File, "\n"); + Flush(); +} + +void VmaRecorder::RecordSetAllocationUserData(uint32_t frameIndex, + VmaAllocation allocation, + const void* pUserData) +{ + CallParams callParams; + GetBasicParams(callParams); + + VmaMutexLock lock(m_FileMutex, m_UseMutex); + UserDataString userDataStr( + allocation->IsUserDataString() ? VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT : 0, + pUserData); + fprintf(m_File, "%u,%.3f,%u,vmaSetAllocationUserData,%p,%s\n", callParams.threadId, callParams.time, frameIndex, + allocation, + userDataStr.GetString()); + Flush(); +} + +void VmaRecorder::RecordCreateLostAllocation(uint32_t frameIndex, + VmaAllocation allocation) +{ + CallParams callParams; + GetBasicParams(callParams); + + VmaMutexLock lock(m_FileMutex, m_UseMutex); + fprintf(m_File, "%u,%.3f,%u,vmaCreateLostAllocation,%p\n", callParams.threadId, callParams.time, frameIndex, + allocation); + Flush(); +} + +void VmaRecorder::RecordMapMemory(uint32_t frameIndex, + VmaAllocation allocation) +{ + CallParams callParams; + GetBasicParams(callParams); + + VmaMutexLock lock(m_FileMutex, m_UseMutex); + fprintf(m_File, "%u,%.3f,%u,vmaMapMemory,%p\n", callParams.threadId, callParams.time, frameIndex, + allocation); + Flush(); +} + +void VmaRecorder::RecordUnmapMemory(uint32_t frameIndex, + VmaAllocation allocation) +{ + CallParams callParams; + GetBasicParams(callParams); + + VmaMutexLock lock(m_FileMutex, m_UseMutex); + fprintf(m_File, "%u,%.3f,%u,vmaUnmapMemory,%p\n", callParams.threadId, callParams.time, frameIndex, + allocation); + Flush(); +} + +void VmaRecorder::RecordFlushAllocation(uint32_t frameIndex, + VmaAllocation allocation, VkDeviceSize offset, VkDeviceSize size) +{ + CallParams callParams; + GetBasicParams(callParams); + + VmaMutexLock lock(m_FileMutex, m_UseMutex); + fprintf(m_File, "%u,%.3f,%u,vmaFlushAllocation,%p,%llu,%llu\n", callParams.threadId, callParams.time, frameIndex, + allocation, + offset, + size); + Flush(); +} + +void VmaRecorder::RecordInvalidateAllocation(uint32_t frameIndex, + VmaAllocation allocation, VkDeviceSize offset, VkDeviceSize size) +{ + CallParams callParams; + GetBasicParams(callParams); + + VmaMutexLock lock(m_FileMutex, m_UseMutex); + fprintf(m_File, "%u,%.3f,%u,vmaInvalidateAllocation,%p,%llu,%llu\n", callParams.threadId, callParams.time, frameIndex, + allocation, + offset, + size); + Flush(); +} + +void VmaRecorder::RecordCreateBuffer(uint32_t frameIndex, + const VkBufferCreateInfo& bufCreateInfo, + const VmaAllocationCreateInfo& allocCreateInfo, + VmaAllocation allocation) +{ + CallParams callParams; + GetBasicParams(callParams); + + VmaMutexLock lock(m_FileMutex, m_UseMutex); + UserDataString userDataStr(allocCreateInfo.flags, allocCreateInfo.pUserData); + fprintf(m_File, "%u,%.3f,%u,vmaCreateBuffer,%u,%llu,%u,%u,%u,%u,%u,%u,%u,%p,%p,%s\n", callParams.threadId, callParams.time, frameIndex, + bufCreateInfo.flags, + bufCreateInfo.size, + bufCreateInfo.usage, + bufCreateInfo.sharingMode, + allocCreateInfo.flags, + allocCreateInfo.usage, + allocCreateInfo.requiredFlags, + allocCreateInfo.preferredFlags, + allocCreateInfo.memoryTypeBits, + allocCreateInfo.pool, + allocation, + userDataStr.GetString()); + Flush(); +} + +void VmaRecorder::RecordCreateImage(uint32_t frameIndex, + const VkImageCreateInfo& imageCreateInfo, + const VmaAllocationCreateInfo& allocCreateInfo, + VmaAllocation allocation) +{ + CallParams callParams; + GetBasicParams(callParams); + + VmaMutexLock lock(m_FileMutex, m_UseMutex); + UserDataString userDataStr(allocCreateInfo.flags, allocCreateInfo.pUserData); + fprintf(m_File, "%u,%.3f,%u,vmaCreateImage,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%p,%p,%s\n", callParams.threadId, callParams.time, frameIndex, + imageCreateInfo.flags, + imageCreateInfo.imageType, + imageCreateInfo.format, + imageCreateInfo.extent.width, + imageCreateInfo.extent.height, + imageCreateInfo.extent.depth, + imageCreateInfo.mipLevels, + imageCreateInfo.arrayLayers, + imageCreateInfo.samples, + imageCreateInfo.tiling, + imageCreateInfo.usage, + imageCreateInfo.sharingMode, + imageCreateInfo.initialLayout, + allocCreateInfo.flags, + allocCreateInfo.usage, + allocCreateInfo.requiredFlags, + allocCreateInfo.preferredFlags, + allocCreateInfo.memoryTypeBits, + allocCreateInfo.pool, + allocation, + userDataStr.GetString()); + Flush(); +} + +void VmaRecorder::RecordDestroyBuffer(uint32_t frameIndex, + VmaAllocation allocation) +{ + CallParams callParams; + GetBasicParams(callParams); + + VmaMutexLock lock(m_FileMutex, m_UseMutex); + fprintf(m_File, "%u,%.3f,%u,vmaDestroyBuffer,%p\n", callParams.threadId, callParams.time, frameIndex, + allocation); + Flush(); +} + +void VmaRecorder::RecordDestroyImage(uint32_t frameIndex, + VmaAllocation allocation) +{ + CallParams callParams; + GetBasicParams(callParams); + + VmaMutexLock lock(m_FileMutex, m_UseMutex); + fprintf(m_File, "%u,%.3f,%u,vmaDestroyImage,%p\n", callParams.threadId, callParams.time, frameIndex, + allocation); + Flush(); +} + +void VmaRecorder::RecordTouchAllocation(uint32_t frameIndex, + VmaAllocation allocation) +{ + CallParams callParams; + GetBasicParams(callParams); + + VmaMutexLock lock(m_FileMutex, m_UseMutex); + fprintf(m_File, "%u,%.3f,%u,vmaTouchAllocation,%p\n", callParams.threadId, callParams.time, frameIndex, + allocation); + Flush(); +} + +void VmaRecorder::RecordGetAllocationInfo(uint32_t frameIndex, + VmaAllocation allocation) +{ + CallParams callParams; + GetBasicParams(callParams); + + VmaMutexLock lock(m_FileMutex, m_UseMutex); + fprintf(m_File, "%u,%.3f,%u,vmaGetAllocationInfo,%p\n", callParams.threadId, callParams.time, frameIndex, + allocation); + Flush(); +} + +void VmaRecorder::RecordMakePoolAllocationsLost(uint32_t frameIndex, + VmaPool pool) +{ + CallParams callParams; + GetBasicParams(callParams); + + VmaMutexLock lock(m_FileMutex, m_UseMutex); + fprintf(m_File, "%u,%.3f,%u,vmaMakePoolAllocationsLost,%p\n", callParams.threadId, callParams.time, frameIndex, + pool); + Flush(); +} + +void VmaRecorder::RecordDefragmentationBegin(uint32_t frameIndex, + const VmaDefragmentationInfo2& info, + VmaDefragmentationContext ctx) +{ + CallParams callParams; + GetBasicParams(callParams); + + VmaMutexLock lock(m_FileMutex, m_UseMutex); + fprintf(m_File, "%u,%.3f,%u,vmaDefragmentationBegin,%u,", callParams.threadId, callParams.time, frameIndex, + info.flags); + PrintPointerList(info.allocationCount, info.pAllocations); + fprintf(m_File, ","); + PrintPointerList(info.poolCount, info.pPools); + fprintf(m_File, ",%llu,%u,%llu,%u,%p,%p\n", + info.maxCpuBytesToMove, + info.maxCpuAllocationsToMove, + info.maxGpuBytesToMove, + info.maxGpuAllocationsToMove, + info.commandBuffer, + ctx); + Flush(); +} + +void VmaRecorder::RecordDefragmentationEnd(uint32_t frameIndex, + VmaDefragmentationContext ctx) +{ + CallParams callParams; + GetBasicParams(callParams); + + VmaMutexLock lock(m_FileMutex, m_UseMutex); + fprintf(m_File, "%u,%.3f,%u,vmaDefragmentationEnd,%p\n", callParams.threadId, callParams.time, frameIndex, + ctx); + Flush(); +} + +void VmaRecorder::RecordSetPoolName(uint32_t frameIndex, + VmaPool pool, + const char* name) +{ + CallParams callParams; + GetBasicParams(callParams); + + VmaMutexLock lock(m_FileMutex, m_UseMutex); + fprintf(m_File, "%u,%.3f,%u,vmaSetPoolName,%p,%s\n", callParams.threadId, callParams.time, frameIndex, + pool, name != VMA_NULL ? name : ""); + Flush(); +} + +VmaRecorder::UserDataString::UserDataString(VmaAllocationCreateFlags allocFlags, const void* pUserData) +{ + if(pUserData != VMA_NULL) + { + if((allocFlags & VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT) != 0) + { + m_Str = (const char*)pUserData; + } + else + { + sprintf_s(m_PtrStr, "%p", pUserData); + m_Str = m_PtrStr; + } + } + else + { + m_Str = ""; + } +} + +void VmaRecorder::WriteConfiguration( + const VkPhysicalDeviceProperties& devProps, + const VkPhysicalDeviceMemoryProperties& memProps, + uint32_t vulkanApiVersion, + bool dedicatedAllocationExtensionEnabled, + bool bindMemory2ExtensionEnabled, + bool memoryBudgetExtensionEnabled, + bool deviceCoherentMemoryExtensionEnabled) +{ + fprintf(m_File, "Config,Begin\n"); + + fprintf(m_File, "VulkanApiVersion,%u,%u\n", VK_VERSION_MAJOR(vulkanApiVersion), VK_VERSION_MINOR(vulkanApiVersion)); + + fprintf(m_File, "PhysicalDevice,apiVersion,%u\n", devProps.apiVersion); + fprintf(m_File, "PhysicalDevice,driverVersion,%u\n", devProps.driverVersion); + fprintf(m_File, "PhysicalDevice,vendorID,%u\n", devProps.vendorID); + fprintf(m_File, "PhysicalDevice,deviceID,%u\n", devProps.deviceID); + fprintf(m_File, "PhysicalDevice,deviceType,%u\n", devProps.deviceType); + fprintf(m_File, "PhysicalDevice,deviceName,%s\n", devProps.deviceName); + + fprintf(m_File, "PhysicalDeviceLimits,maxMemoryAllocationCount,%u\n", devProps.limits.maxMemoryAllocationCount); + fprintf(m_File, "PhysicalDeviceLimits,bufferImageGranularity,%llu\n", devProps.limits.bufferImageGranularity); + fprintf(m_File, "PhysicalDeviceLimits,nonCoherentAtomSize,%llu\n", devProps.limits.nonCoherentAtomSize); + + fprintf(m_File, "PhysicalDeviceMemory,HeapCount,%u\n", memProps.memoryHeapCount); + for(uint32_t i = 0; i < memProps.memoryHeapCount; ++i) + { + fprintf(m_File, "PhysicalDeviceMemory,Heap,%u,size,%llu\n", i, memProps.memoryHeaps[i].size); + fprintf(m_File, "PhysicalDeviceMemory,Heap,%u,flags,%u\n", i, memProps.memoryHeaps[i].flags); + } + fprintf(m_File, "PhysicalDeviceMemory,TypeCount,%u\n", memProps.memoryTypeCount); + for(uint32_t i = 0; i < memProps.memoryTypeCount; ++i) + { + fprintf(m_File, "PhysicalDeviceMemory,Type,%u,heapIndex,%u\n", i, memProps.memoryTypes[i].heapIndex); + fprintf(m_File, "PhysicalDeviceMemory,Type,%u,propertyFlags,%u\n", i, memProps.memoryTypes[i].propertyFlags); + } + + fprintf(m_File, "Extension,VK_KHR_dedicated_allocation,%u\n", dedicatedAllocationExtensionEnabled ? 1 : 0); + fprintf(m_File, "Extension,VK_KHR_bind_memory2,%u\n", bindMemory2ExtensionEnabled ? 1 : 0); + fprintf(m_File, "Extension,VK_EXT_memory_budget,%u\n", memoryBudgetExtensionEnabled ? 1 : 0); + fprintf(m_File, "Extension,VK_AMD_device_coherent_memory,%u\n", deviceCoherentMemoryExtensionEnabled ? 1 : 0); + + fprintf(m_File, "Macro,VMA_DEBUG_ALWAYS_DEDICATED_MEMORY,%u\n", VMA_DEBUG_ALWAYS_DEDICATED_MEMORY ? 1 : 0); + fprintf(m_File, "Macro,VMA_DEBUG_ALIGNMENT,%llu\n", (VkDeviceSize)VMA_DEBUG_ALIGNMENT); + fprintf(m_File, "Macro,VMA_DEBUG_MARGIN,%llu\n", (VkDeviceSize)VMA_DEBUG_MARGIN); + fprintf(m_File, "Macro,VMA_DEBUG_INITIALIZE_ALLOCATIONS,%u\n", VMA_DEBUG_INITIALIZE_ALLOCATIONS ? 1 : 0); + fprintf(m_File, "Macro,VMA_DEBUG_DETECT_CORRUPTION,%u\n", VMA_DEBUG_DETECT_CORRUPTION ? 1 : 0); + fprintf(m_File, "Macro,VMA_DEBUG_GLOBAL_MUTEX,%u\n", VMA_DEBUG_GLOBAL_MUTEX ? 1 : 0); + fprintf(m_File, "Macro,VMA_DEBUG_MIN_BUFFER_IMAGE_GRANULARITY,%llu\n", (VkDeviceSize)VMA_DEBUG_MIN_BUFFER_IMAGE_GRANULARITY); + fprintf(m_File, "Macro,VMA_SMALL_HEAP_MAX_SIZE,%llu\n", (VkDeviceSize)VMA_SMALL_HEAP_MAX_SIZE); + fprintf(m_File, "Macro,VMA_DEFAULT_LARGE_HEAP_BLOCK_SIZE,%llu\n", (VkDeviceSize)VMA_DEFAULT_LARGE_HEAP_BLOCK_SIZE); + + fprintf(m_File, "Config,End\n"); +} + +void VmaRecorder::GetBasicParams(CallParams& outParams) +{ + outParams.threadId = GetCurrentThreadId(); + + LARGE_INTEGER counter; + QueryPerformanceCounter(&counter); + outParams.time = (double)(counter.QuadPart - m_StartCounter) / (double)m_Freq; +} + +void VmaRecorder::PrintPointerList(uint64_t count, const VmaAllocation* pItems) +{ + if(count) + { + fprintf(m_File, "%p", pItems[0]); + for(uint64_t i = 1; i < count; ++i) + { + fprintf(m_File, " %p", pItems[i]); + } + } +} + +void VmaRecorder::Flush() +{ + if((m_Flags & VMA_RECORD_FLUSH_AFTER_CALL_BIT) != 0) + { + fflush(m_File); + } +} + +#endif // #if VMA_RECORDING_ENABLED + +//////////////////////////////////////////////////////////////////////////////// +// VmaAllocationObjectAllocator + +VmaAllocationObjectAllocator::VmaAllocationObjectAllocator(const VkAllocationCallbacks* pAllocationCallbacks) : + m_Allocator(pAllocationCallbacks, 1024) +{ +} + +template VmaAllocation VmaAllocationObjectAllocator::Allocate(Types... args) +{ + VmaMutexLock mutexLock(m_Mutex); + return m_Allocator.Alloc(std::forward(args)...); +} + +void VmaAllocationObjectAllocator::Free(VmaAllocation hAlloc) +{ + VmaMutexLock mutexLock(m_Mutex); + m_Allocator.Free(hAlloc); +} + +//////////////////////////////////////////////////////////////////////////////// +// VmaAllocator_T + +VmaAllocator_T::VmaAllocator_T(const VmaAllocatorCreateInfo* pCreateInfo) : + m_UseMutex((pCreateInfo->flags & VMA_ALLOCATOR_CREATE_EXTERNALLY_SYNCHRONIZED_BIT) == 0), + m_VulkanApiVersion(pCreateInfo->vulkanApiVersion != 0 ? pCreateInfo->vulkanApiVersion : VK_API_VERSION_1_0), + m_UseKhrDedicatedAllocation((pCreateInfo->flags & VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT) != 0), + m_UseKhrBindMemory2((pCreateInfo->flags & VMA_ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT) != 0), + m_UseExtMemoryBudget((pCreateInfo->flags & VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT) != 0), + m_UseAmdDeviceCoherentMemory((pCreateInfo->flags & VMA_ALLOCATOR_CREATE_AMD_DEVICE_COHERENT_MEMORY_BIT) != 0), + m_hDevice(pCreateInfo->device), + m_hInstance(pCreateInfo->instance), + m_AllocationCallbacksSpecified(pCreateInfo->pAllocationCallbacks != VMA_NULL), + m_AllocationCallbacks(pCreateInfo->pAllocationCallbacks ? + *pCreateInfo->pAllocationCallbacks : VmaEmptyAllocationCallbacks), + m_AllocationObjectAllocator(&m_AllocationCallbacks), + m_HeapSizeLimitMask(0), + m_PreferredLargeHeapBlockSize(0), + m_PhysicalDevice(pCreateInfo->physicalDevice), + m_CurrentFrameIndex(0), + m_GpuDefragmentationMemoryTypeBits(UINT32_MAX), + m_Pools(VmaStlAllocator(GetAllocationCallbacks())), + m_NextPoolId(0), + m_GlobalMemoryTypeBits(UINT32_MAX) +#if VMA_RECORDING_ENABLED + ,m_pRecorder(VMA_NULL) +#endif +{ + if(m_VulkanApiVersion >= VK_MAKE_VERSION(1, 1, 0)) + { + m_UseKhrDedicatedAllocation = false; + m_UseKhrBindMemory2 = false; + } + + if(VMA_DEBUG_DETECT_CORRUPTION) + { + // Needs to be multiply of uint32_t size because we are going to write VMA_CORRUPTION_DETECTION_MAGIC_VALUE to it. + VMA_ASSERT(VMA_DEBUG_MARGIN % sizeof(uint32_t) == 0); + } + + VMA_ASSERT(pCreateInfo->physicalDevice && pCreateInfo->device); + + if(m_VulkanApiVersion < VK_MAKE_VERSION(1, 1, 0)) + { +#if !(VMA_DEDICATED_ALLOCATION) + if((pCreateInfo->flags & VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT) != 0) + { + VMA_ASSERT(0 && "VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT set but required extensions are disabled by preprocessor macros."); + } +#endif +#if !(VMA_BIND_MEMORY2) + if((pCreateInfo->flags & VMA_ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT) != 0) + { + VMA_ASSERT(0 && "VMA_ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT set but required extension is disabled by preprocessor macros."); + } +#endif + } +#if !(VMA_MEMORY_BUDGET) + if((pCreateInfo->flags & VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT) != 0) + { + VMA_ASSERT(0 && "VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT set but required extension is disabled by preprocessor macros."); + } +#endif +#if VMA_VULKAN_VERSION < 1002000 + if(m_VulkanApiVersion >= VK_MAKE_VERSION(1, 2, 0)) + { + VMA_ASSERT(0 && "vulkanApiVersion >= VK_API_VERSION_1_2 but required Vulkan version is disabled by preprocessor macros."); + } +#endif +#if VMA_VULKAN_VERSION < 1001000 + if(m_VulkanApiVersion >= VK_MAKE_VERSION(1, 1, 0)) + { + VMA_ASSERT(0 && "vulkanApiVersion >= VK_API_VERSION_1_1 but required Vulkan version is disabled by preprocessor macros."); + } +#endif + + memset(&m_DeviceMemoryCallbacks, 0 ,sizeof(m_DeviceMemoryCallbacks)); + memset(&m_PhysicalDeviceProperties, 0, sizeof(m_PhysicalDeviceProperties)); + memset(&m_MemProps, 0, sizeof(m_MemProps)); + + memset(&m_pBlockVectors, 0, sizeof(m_pBlockVectors)); + memset(&m_pDedicatedAllocations, 0, sizeof(m_pDedicatedAllocations)); + memset(&m_VulkanFunctions, 0, sizeof(m_VulkanFunctions)); + + if(pCreateInfo->pDeviceMemoryCallbacks != VMA_NULL) + { + m_DeviceMemoryCallbacks.pfnAllocate = pCreateInfo->pDeviceMemoryCallbacks->pfnAllocate; + m_DeviceMemoryCallbacks.pfnFree = pCreateInfo->pDeviceMemoryCallbacks->pfnFree; + } + + ImportVulkanFunctions(pCreateInfo->pVulkanFunctions); + + (*m_VulkanFunctions.vkGetPhysicalDeviceProperties)(m_PhysicalDevice, &m_PhysicalDeviceProperties); + (*m_VulkanFunctions.vkGetPhysicalDeviceMemoryProperties)(m_PhysicalDevice, &m_MemProps); + + VMA_ASSERT(VmaIsPow2(VMA_DEBUG_ALIGNMENT)); + VMA_ASSERT(VmaIsPow2(VMA_DEBUG_MIN_BUFFER_IMAGE_GRANULARITY)); + VMA_ASSERT(VmaIsPow2(m_PhysicalDeviceProperties.limits.bufferImageGranularity)); + VMA_ASSERT(VmaIsPow2(m_PhysicalDeviceProperties.limits.nonCoherentAtomSize)); + + m_PreferredLargeHeapBlockSize = (pCreateInfo->preferredLargeHeapBlockSize != 0) ? + pCreateInfo->preferredLargeHeapBlockSize : static_cast(VMA_DEFAULT_LARGE_HEAP_BLOCK_SIZE); + + m_GlobalMemoryTypeBits = CalculateGlobalMemoryTypeBits(); + + if(pCreateInfo->pHeapSizeLimit != VMA_NULL) + { + for(uint32_t heapIndex = 0; heapIndex < GetMemoryHeapCount(); ++heapIndex) + { + const VkDeviceSize limit = pCreateInfo->pHeapSizeLimit[heapIndex]; + if(limit != VK_WHOLE_SIZE) + { + m_HeapSizeLimitMask |= 1u << heapIndex; + if(limit < m_MemProps.memoryHeaps[heapIndex].size) + { + m_MemProps.memoryHeaps[heapIndex].size = limit; + } + } + } + } + + for(uint32_t memTypeIndex = 0; memTypeIndex < GetMemoryTypeCount(); ++memTypeIndex) + { + const VkDeviceSize preferredBlockSize = CalcPreferredBlockSize(memTypeIndex); + + m_pBlockVectors[memTypeIndex] = vma_new(this, VmaBlockVector)( + this, + VK_NULL_HANDLE, // hParentPool + memTypeIndex, + preferredBlockSize, + 0, + SIZE_MAX, + GetBufferImageGranularity(), + pCreateInfo->frameInUseCount, + false, // explicitBlockSize + false); // linearAlgorithm + // No need to call m_pBlockVectors[memTypeIndex][blockVectorTypeIndex]->CreateMinBlocks here, + // becase minBlockCount is 0. + m_pDedicatedAllocations[memTypeIndex] = vma_new(this, AllocationVectorType)(VmaStlAllocator(GetAllocationCallbacks())); + + } +} + +VkResult VmaAllocator_T::Init(const VmaAllocatorCreateInfo* pCreateInfo) +{ + VkResult res = VK_SUCCESS; + + if(pCreateInfo->pRecordSettings != VMA_NULL && + !VmaStrIsEmpty(pCreateInfo->pRecordSettings->pFilePath)) + { +#if VMA_RECORDING_ENABLED + m_pRecorder = vma_new(this, VmaRecorder)(); + res = m_pRecorder->Init(*pCreateInfo->pRecordSettings, m_UseMutex); + if(res != VK_SUCCESS) + { + return res; + } + m_pRecorder->WriteConfiguration( + m_PhysicalDeviceProperties, + m_MemProps, + m_VulkanApiVersion, + m_UseKhrDedicatedAllocation, + m_UseKhrBindMemory2, + m_UseExtMemoryBudget, + m_UseAmdDeviceCoherentMemory); + m_pRecorder->RecordCreateAllocator(GetCurrentFrameIndex()); +#else + VMA_ASSERT(0 && "VmaAllocatorCreateInfo::pRecordSettings used, but not supported due to VMA_RECORDING_ENABLED not defined to 1."); + return VK_ERROR_FEATURE_NOT_PRESENT; +#endif + } + +#if VMA_MEMORY_BUDGET + if(m_UseExtMemoryBudget) + { + UpdateVulkanBudget(); + } +#endif // #if VMA_MEMORY_BUDGET + + return res; +} + +VmaAllocator_T::~VmaAllocator_T() +{ +#if VMA_RECORDING_ENABLED + if(m_pRecorder != VMA_NULL) + { + m_pRecorder->RecordDestroyAllocator(GetCurrentFrameIndex()); + vma_delete(this, m_pRecorder); + } +#endif + + VMA_ASSERT(m_Pools.empty()); + + for(size_t i = GetMemoryTypeCount(); i--; ) + { + if(m_pDedicatedAllocations[i] != VMA_NULL && !m_pDedicatedAllocations[i]->empty()) + { + VMA_ASSERT(0 && "Unfreed dedicated allocations found."); + } + + vma_delete(this, m_pDedicatedAllocations[i]); + vma_delete(this, m_pBlockVectors[i]); + } +} + +void VmaAllocator_T::ImportVulkanFunctions(const VmaVulkanFunctions* pVulkanFunctions) +{ +#if VMA_STATIC_VULKAN_FUNCTIONS == 1 + m_VulkanFunctions.vkGetPhysicalDeviceProperties = (PFN_vkGetPhysicalDeviceProperties)vkGetPhysicalDeviceProperties; + m_VulkanFunctions.vkGetPhysicalDeviceMemoryProperties = (PFN_vkGetPhysicalDeviceMemoryProperties)vkGetPhysicalDeviceMemoryProperties; + m_VulkanFunctions.vkAllocateMemory = (PFN_vkAllocateMemory)vkAllocateMemory; + m_VulkanFunctions.vkFreeMemory = (PFN_vkFreeMemory)vkFreeMemory; + m_VulkanFunctions.vkMapMemory = (PFN_vkMapMemory)vkMapMemory; + m_VulkanFunctions.vkUnmapMemory = (PFN_vkUnmapMemory)vkUnmapMemory; + m_VulkanFunctions.vkFlushMappedMemoryRanges = (PFN_vkFlushMappedMemoryRanges)vkFlushMappedMemoryRanges; + m_VulkanFunctions.vkInvalidateMappedMemoryRanges = (PFN_vkInvalidateMappedMemoryRanges)vkInvalidateMappedMemoryRanges; + m_VulkanFunctions.vkBindBufferMemory = (PFN_vkBindBufferMemory)vkBindBufferMemory; + m_VulkanFunctions.vkBindImageMemory = (PFN_vkBindImageMemory)vkBindImageMemory; + m_VulkanFunctions.vkGetBufferMemoryRequirements = (PFN_vkGetBufferMemoryRequirements)vkGetBufferMemoryRequirements; + m_VulkanFunctions.vkGetImageMemoryRequirements = (PFN_vkGetImageMemoryRequirements)vkGetImageMemoryRequirements; + m_VulkanFunctions.vkCreateBuffer = (PFN_vkCreateBuffer)vkCreateBuffer; + m_VulkanFunctions.vkDestroyBuffer = (PFN_vkDestroyBuffer)vkDestroyBuffer; + m_VulkanFunctions.vkCreateImage = (PFN_vkCreateImage)vkCreateImage; + m_VulkanFunctions.vkDestroyImage = (PFN_vkDestroyImage)vkDestroyImage; + m_VulkanFunctions.vkCmdCopyBuffer = (PFN_vkCmdCopyBuffer)vkCmdCopyBuffer; +#if VMA_VULKAN_VERSION >= 1001000 + if(m_VulkanApiVersion >= VK_MAKE_VERSION(1, 1, 0)) + { + VMA_ASSERT(m_hInstance != VK_NULL_HANDLE); + m_VulkanFunctions.vkGetBufferMemoryRequirements2KHR = + (PFN_vkGetBufferMemoryRequirements2KHR)vkGetDeviceProcAddr(m_hDevice, "vkGetBufferMemoryRequirements2"); + m_VulkanFunctions.vkGetImageMemoryRequirements2KHR = + (PFN_vkGetImageMemoryRequirements2KHR)vkGetDeviceProcAddr(m_hDevice, "vkGetImageMemoryRequirements2"); + m_VulkanFunctions.vkBindBufferMemory2KHR = + (PFN_vkBindBufferMemory2KHR)vkGetDeviceProcAddr(m_hDevice, "vkBindBufferMemory2"); + m_VulkanFunctions.vkBindImageMemory2KHR = + (PFN_vkBindImageMemory2KHR)vkGetDeviceProcAddr(m_hDevice, "vkBindImageMemory2"); + m_VulkanFunctions.vkGetPhysicalDeviceMemoryProperties2KHR = + (PFN_vkGetPhysicalDeviceMemoryProperties2KHR)vkGetInstanceProcAddr(m_hInstance, "vkGetPhysicalDeviceMemoryProperties2"); + } +#endif +#if VMA_DEDICATED_ALLOCATION + if(m_UseKhrDedicatedAllocation) + { + if(m_VulkanFunctions.vkGetBufferMemoryRequirements2KHR == nullptr) + { + m_VulkanFunctions.vkGetBufferMemoryRequirements2KHR = + (PFN_vkGetBufferMemoryRequirements2KHR)vkGetDeviceProcAddr(m_hDevice, "vkGetBufferMemoryRequirements2KHR"); + } + if(m_VulkanFunctions.vkGetImageMemoryRequirements2KHR == nullptr) + { + m_VulkanFunctions.vkGetImageMemoryRequirements2KHR = + (PFN_vkGetImageMemoryRequirements2KHR)vkGetDeviceProcAddr(m_hDevice, "vkGetImageMemoryRequirements2KHR"); + } + } +#endif +#if VMA_BIND_MEMORY2 + if(m_UseKhrBindMemory2) + { + if(m_VulkanFunctions.vkBindBufferMemory2KHR == nullptr) + { + m_VulkanFunctions.vkBindBufferMemory2KHR = + (PFN_vkBindBufferMemory2KHR)vkGetDeviceProcAddr(m_hDevice, "vkBindBufferMemory2KHR"); + } + if(m_VulkanFunctions.vkBindImageMemory2KHR == nullptr) + { + m_VulkanFunctions.vkBindImageMemory2KHR = + (PFN_vkBindImageMemory2KHR)vkGetDeviceProcAddr(m_hDevice, "vkBindImageMemory2KHR"); + } + } +#endif // #if VMA_BIND_MEMORY2 +#if VMA_MEMORY_BUDGET + if(m_UseExtMemoryBudget && m_VulkanApiVersion < VK_MAKE_VERSION(1, 1, 0)) + { + VMA_ASSERT(m_hInstance != VK_NULL_HANDLE); + if(m_VulkanFunctions.vkGetPhysicalDeviceMemoryProperties2KHR == nullptr) + { + m_VulkanFunctions.vkGetPhysicalDeviceMemoryProperties2KHR = + (PFN_vkGetPhysicalDeviceMemoryProperties2KHR)vkGetInstanceProcAddr(m_hInstance, "vkGetPhysicalDeviceMemoryProperties2KHR"); + } + } +#endif // #if VMA_MEMORY_BUDGET +#endif // #if VMA_STATIC_VULKAN_FUNCTIONS == 1 + +#define VMA_COPY_IF_NOT_NULL(funcName) \ + if(pVulkanFunctions->funcName != VMA_NULL) m_VulkanFunctions.funcName = pVulkanFunctions->funcName; + + if(pVulkanFunctions != VMA_NULL) + { + VMA_COPY_IF_NOT_NULL(vkGetPhysicalDeviceProperties); + VMA_COPY_IF_NOT_NULL(vkGetPhysicalDeviceMemoryProperties); + VMA_COPY_IF_NOT_NULL(vkAllocateMemory); + VMA_COPY_IF_NOT_NULL(vkFreeMemory); + VMA_COPY_IF_NOT_NULL(vkMapMemory); + VMA_COPY_IF_NOT_NULL(vkUnmapMemory); + VMA_COPY_IF_NOT_NULL(vkFlushMappedMemoryRanges); + VMA_COPY_IF_NOT_NULL(vkInvalidateMappedMemoryRanges); + VMA_COPY_IF_NOT_NULL(vkBindBufferMemory); + VMA_COPY_IF_NOT_NULL(vkBindImageMemory); + VMA_COPY_IF_NOT_NULL(vkGetBufferMemoryRequirements); + VMA_COPY_IF_NOT_NULL(vkGetImageMemoryRequirements); + VMA_COPY_IF_NOT_NULL(vkCreateBuffer); + VMA_COPY_IF_NOT_NULL(vkDestroyBuffer); + VMA_COPY_IF_NOT_NULL(vkCreateImage); + VMA_COPY_IF_NOT_NULL(vkDestroyImage); + VMA_COPY_IF_NOT_NULL(vkCmdCopyBuffer); +#if VMA_DEDICATED_ALLOCATION || VMA_VULKAN_VERSION >= 1001000 + VMA_COPY_IF_NOT_NULL(vkGetBufferMemoryRequirements2KHR); + VMA_COPY_IF_NOT_NULL(vkGetImageMemoryRequirements2KHR); +#endif +#if VMA_BIND_MEMORY2 || VMA_VULKAN_VERSION >= 1001000 + VMA_COPY_IF_NOT_NULL(vkBindBufferMemory2KHR); + VMA_COPY_IF_NOT_NULL(vkBindImageMemory2KHR); +#endif +#if VMA_MEMORY_BUDGET + VMA_COPY_IF_NOT_NULL(vkGetPhysicalDeviceMemoryProperties2KHR); +#endif + } + +#undef VMA_COPY_IF_NOT_NULL + + // If these asserts are hit, you must either #define VMA_STATIC_VULKAN_FUNCTIONS 1 + // or pass valid pointers as VmaAllocatorCreateInfo::pVulkanFunctions. + VMA_ASSERT(m_VulkanFunctions.vkGetPhysicalDeviceProperties != VMA_NULL); + VMA_ASSERT(m_VulkanFunctions.vkGetPhysicalDeviceMemoryProperties != VMA_NULL); + VMA_ASSERT(m_VulkanFunctions.vkAllocateMemory != VMA_NULL); + VMA_ASSERT(m_VulkanFunctions.vkFreeMemory != VMA_NULL); + VMA_ASSERT(m_VulkanFunctions.vkMapMemory != VMA_NULL); + VMA_ASSERT(m_VulkanFunctions.vkUnmapMemory != VMA_NULL); + VMA_ASSERT(m_VulkanFunctions.vkFlushMappedMemoryRanges != VMA_NULL); + VMA_ASSERT(m_VulkanFunctions.vkInvalidateMappedMemoryRanges != VMA_NULL); + VMA_ASSERT(m_VulkanFunctions.vkBindBufferMemory != VMA_NULL); + VMA_ASSERT(m_VulkanFunctions.vkBindImageMemory != VMA_NULL); + VMA_ASSERT(m_VulkanFunctions.vkGetBufferMemoryRequirements != VMA_NULL); + VMA_ASSERT(m_VulkanFunctions.vkGetImageMemoryRequirements != VMA_NULL); + VMA_ASSERT(m_VulkanFunctions.vkCreateBuffer != VMA_NULL); + VMA_ASSERT(m_VulkanFunctions.vkDestroyBuffer != VMA_NULL); + VMA_ASSERT(m_VulkanFunctions.vkCreateImage != VMA_NULL); + VMA_ASSERT(m_VulkanFunctions.vkDestroyImage != VMA_NULL); + VMA_ASSERT(m_VulkanFunctions.vkCmdCopyBuffer != VMA_NULL); +#if VMA_DEDICATED_ALLOCATION || VMA_VULKAN_VERSION >= 1001000 + if(m_VulkanApiVersion >= VK_MAKE_VERSION(1, 1, 0) || m_UseKhrDedicatedAllocation) + { + VMA_ASSERT(m_VulkanFunctions.vkGetBufferMemoryRequirements2KHR != VMA_NULL); + VMA_ASSERT(m_VulkanFunctions.vkGetImageMemoryRequirements2KHR != VMA_NULL); + } +#endif +#if VMA_BIND_MEMORY2 || VMA_VULKAN_VERSION >= 1001000 + if(m_VulkanApiVersion >= VK_MAKE_VERSION(1, 1, 0) || m_UseKhrBindMemory2) + { + VMA_ASSERT(m_VulkanFunctions.vkBindBufferMemory2KHR != VMA_NULL); + VMA_ASSERT(m_VulkanFunctions.vkBindImageMemory2KHR != VMA_NULL); + } +#endif +#if VMA_MEMORY_BUDGET || VMA_VULKAN_VERSION >= 1001000 + if(m_UseExtMemoryBudget || m_VulkanApiVersion >= VK_MAKE_VERSION(1, 1, 0)) + { + VMA_ASSERT(m_VulkanFunctions.vkGetPhysicalDeviceMemoryProperties2KHR != VMA_NULL); + } +#endif +} + +VkDeviceSize VmaAllocator_T::CalcPreferredBlockSize(uint32_t memTypeIndex) +{ + const uint32_t heapIndex = MemoryTypeIndexToHeapIndex(memTypeIndex); + const VkDeviceSize heapSize = m_MemProps.memoryHeaps[heapIndex].size; + const bool isSmallHeap = heapSize <= VMA_SMALL_HEAP_MAX_SIZE; + return VmaAlignUp(isSmallHeap ? (heapSize / 8) : m_PreferredLargeHeapBlockSize, (VkDeviceSize)32); +} + +VkResult VmaAllocator_T::AllocateMemoryOfType( + VkDeviceSize size, + VkDeviceSize alignment, + bool dedicatedAllocation, + VkBuffer dedicatedBuffer, + VkImage dedicatedImage, + const VmaAllocationCreateInfo& createInfo, + uint32_t memTypeIndex, + VmaSuballocationType suballocType, + size_t allocationCount, + VmaAllocation* pAllocations) +{ + VMA_ASSERT(pAllocations != VMA_NULL); + VMA_DEBUG_LOG(" AllocateMemory: MemoryTypeIndex=%u, AllocationCount=%zu, Size=%llu", memTypeIndex, allocationCount, size); + + VmaAllocationCreateInfo finalCreateInfo = createInfo; + + // If memory type is not HOST_VISIBLE, disable MAPPED. + if((finalCreateInfo.flags & VMA_ALLOCATION_CREATE_MAPPED_BIT) != 0 && + (m_MemProps.memoryTypes[memTypeIndex].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) == 0) + { + finalCreateInfo.flags &= ~VMA_ALLOCATION_CREATE_MAPPED_BIT; + } + // If memory is lazily allocated, it should be always dedicated. + if(finalCreateInfo.usage == VMA_MEMORY_USAGE_GPU_LAZILY_ALLOCATED) + { + finalCreateInfo.flags |= VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT; + } + + VmaBlockVector* const blockVector = m_pBlockVectors[memTypeIndex]; + VMA_ASSERT(blockVector); + + const VkDeviceSize preferredBlockSize = blockVector->GetPreferredBlockSize(); + bool preferDedicatedMemory = + VMA_DEBUG_ALWAYS_DEDICATED_MEMORY || + dedicatedAllocation || + // Heuristics: Allocate dedicated memory if requested size if greater than half of preferred block size. + size > preferredBlockSize / 2; + + if(preferDedicatedMemory && + (finalCreateInfo.flags & VMA_ALLOCATION_CREATE_NEVER_ALLOCATE_BIT) == 0 && + finalCreateInfo.pool == VK_NULL_HANDLE) + { + finalCreateInfo.flags |= VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT; + } + + if((finalCreateInfo.flags & VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT) != 0) + { + if((finalCreateInfo.flags & VMA_ALLOCATION_CREATE_NEVER_ALLOCATE_BIT) != 0) + { + return VK_ERROR_OUT_OF_DEVICE_MEMORY; + } + else + { + return AllocateDedicatedMemory( + size, + suballocType, + memTypeIndex, + (finalCreateInfo.flags & VMA_ALLOCATION_CREATE_WITHIN_BUDGET_BIT) != 0, + (finalCreateInfo.flags & VMA_ALLOCATION_CREATE_MAPPED_BIT) != 0, + (finalCreateInfo.flags & VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT) != 0, + finalCreateInfo.pUserData, + dedicatedBuffer, + dedicatedImage, + allocationCount, + pAllocations); + } + } + else + { + VkResult res = blockVector->Allocate( + m_CurrentFrameIndex.load(), + size, + alignment, + finalCreateInfo, + suballocType, + allocationCount, + pAllocations); + if(res == VK_SUCCESS) + { + return res; + } + + // 5. Try dedicated memory. + if((finalCreateInfo.flags & VMA_ALLOCATION_CREATE_NEVER_ALLOCATE_BIT) != 0) + { + return VK_ERROR_OUT_OF_DEVICE_MEMORY; + } + else + { + res = AllocateDedicatedMemory( + size, + suballocType, + memTypeIndex, + (finalCreateInfo.flags & VMA_ALLOCATION_CREATE_WITHIN_BUDGET_BIT) != 0, + (finalCreateInfo.flags & VMA_ALLOCATION_CREATE_MAPPED_BIT) != 0, + (finalCreateInfo.flags & VMA_ALLOCATION_CREATE_USER_DATA_COPY_STRING_BIT) != 0, + finalCreateInfo.pUserData, + dedicatedBuffer, + dedicatedImage, + allocationCount, + pAllocations); + if(res == VK_SUCCESS) + { + // Succeeded: AllocateDedicatedMemory function already filld pMemory, nothing more to do here. + VMA_DEBUG_LOG(" Allocated as DedicatedMemory"); + return VK_SUCCESS; + } + else + { + // Everything failed: Return error code. + VMA_DEBUG_LOG(" vkAllocateMemory FAILED"); + return res; + } + } + } +} + +VkResult VmaAllocator_T::AllocateDedicatedMemory( + VkDeviceSize size, + VmaSuballocationType suballocType, + uint32_t memTypeIndex, + bool withinBudget, + bool map, + bool isUserDataString, + void* pUserData, + VkBuffer dedicatedBuffer, + VkImage dedicatedImage, + size_t allocationCount, + VmaAllocation* pAllocations) +{ + VMA_ASSERT(allocationCount > 0 && pAllocations); + + if(withinBudget) + { + const uint32_t heapIndex = MemoryTypeIndexToHeapIndex(memTypeIndex); + VmaBudget heapBudget = {}; + GetBudget(&heapBudget, heapIndex, 1); + if(heapBudget.usage + size * allocationCount > heapBudget.budget) + { + return VK_ERROR_OUT_OF_DEVICE_MEMORY; + } + } + + VkMemoryAllocateInfo allocInfo = { VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO }; + allocInfo.memoryTypeIndex = memTypeIndex; + allocInfo.allocationSize = size; + +#if VMA_DEDICATED_ALLOCATION || VMA_VULKAN_VERSION >= 1001000 + VkMemoryDedicatedAllocateInfoKHR dedicatedAllocInfo = { VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO_KHR }; + if(m_UseKhrDedicatedAllocation || m_VulkanApiVersion >= VK_MAKE_VERSION(1, 1, 0)) + { + if(dedicatedBuffer != VK_NULL_HANDLE) + { + VMA_ASSERT(dedicatedImage == VK_NULL_HANDLE); + dedicatedAllocInfo.buffer = dedicatedBuffer; + allocInfo.pNext = &dedicatedAllocInfo; + } + else if(dedicatedImage != VK_NULL_HANDLE) + { + dedicatedAllocInfo.image = dedicatedImage; + allocInfo.pNext = &dedicatedAllocInfo; + } + } +#endif // #if VMA_DEDICATED_ALLOCATION || VMA_VULKAN_VERSION >= 1001000 + + size_t allocIndex; + VkResult res = VK_SUCCESS; + for(allocIndex = 0; allocIndex < allocationCount; ++allocIndex) + { + res = AllocateDedicatedMemoryPage( + size, + suballocType, + memTypeIndex, + allocInfo, + map, + isUserDataString, + pUserData, + pAllocations + allocIndex); + if(res != VK_SUCCESS) + { + break; + } + } + + if(res == VK_SUCCESS) + { + // Register them in m_pDedicatedAllocations. + { + VmaMutexLockWrite lock(m_DedicatedAllocationsMutex[memTypeIndex], m_UseMutex); + AllocationVectorType* pDedicatedAllocations = m_pDedicatedAllocations[memTypeIndex]; + VMA_ASSERT(pDedicatedAllocations); + for(allocIndex = 0; allocIndex < allocationCount; ++allocIndex) + { + VmaVectorInsertSorted(*pDedicatedAllocations, pAllocations[allocIndex]); + } + } + + VMA_DEBUG_LOG(" Allocated DedicatedMemory Count=%zu, MemoryTypeIndex=#%u", allocationCount, memTypeIndex); + } + else + { + // Free all already created allocations. + while(allocIndex--) + { + VmaAllocation currAlloc = pAllocations[allocIndex]; + VkDeviceMemory hMemory = currAlloc->GetMemory(); + + /* + There is no need to call this, because Vulkan spec allows to skip vkUnmapMemory + before vkFreeMemory. + + if(currAlloc->GetMappedData() != VMA_NULL) + { + (*m_VulkanFunctions.vkUnmapMemory)(m_hDevice, hMemory); + } + */ + + FreeVulkanMemory(memTypeIndex, currAlloc->GetSize(), hMemory); + m_Budget.RemoveAllocation(MemoryTypeIndexToHeapIndex(memTypeIndex), currAlloc->GetSize()); + currAlloc->SetUserData(this, VMA_NULL); + m_AllocationObjectAllocator.Free(currAlloc); + } + + memset(pAllocations, 0, sizeof(VmaAllocation) * allocationCount); + } + + return res; +} + +VkResult VmaAllocator_T::AllocateDedicatedMemoryPage( + VkDeviceSize size, + VmaSuballocationType suballocType, + uint32_t memTypeIndex, + const VkMemoryAllocateInfo& allocInfo, + bool map, + bool isUserDataString, + void* pUserData, + VmaAllocation* pAllocation) +{ + VkDeviceMemory hMemory = VK_NULL_HANDLE; + VkResult res = AllocateVulkanMemory(&allocInfo, &hMemory); + if(res < 0) + { + VMA_DEBUG_LOG(" vkAllocateMemory FAILED"); + return res; + } + + void* pMappedData = VMA_NULL; + if(map) + { + res = (*m_VulkanFunctions.vkMapMemory)( + m_hDevice, + hMemory, + 0, + VK_WHOLE_SIZE, + 0, + &pMappedData); + if(res < 0) + { + VMA_DEBUG_LOG(" vkMapMemory FAILED"); + FreeVulkanMemory(memTypeIndex, size, hMemory); + return res; + } + } + + *pAllocation = m_AllocationObjectAllocator.Allocate(m_CurrentFrameIndex.load(), isUserDataString); + (*pAllocation)->InitDedicatedAllocation(memTypeIndex, hMemory, suballocType, pMappedData, size); + (*pAllocation)->SetUserData(this, pUserData); + m_Budget.AddAllocation(MemoryTypeIndexToHeapIndex(memTypeIndex), size); + if(VMA_DEBUG_INITIALIZE_ALLOCATIONS) + { + FillAllocation(*pAllocation, VMA_ALLOCATION_FILL_PATTERN_CREATED); + } + + return VK_SUCCESS; +} + +void VmaAllocator_T::GetBufferMemoryRequirements( + VkBuffer hBuffer, + VkMemoryRequirements& memReq, + bool& requiresDedicatedAllocation, + bool& prefersDedicatedAllocation) const +{ +#if VMA_DEDICATED_ALLOCATION || VMA_VULKAN_VERSION >= 1001000 + if(m_UseKhrDedicatedAllocation || m_VulkanApiVersion >= VK_MAKE_VERSION(1, 1, 0)) + { + VkBufferMemoryRequirementsInfo2KHR memReqInfo = { VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2_KHR }; + memReqInfo.buffer = hBuffer; + + VkMemoryDedicatedRequirementsKHR memDedicatedReq = { VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS_KHR }; + + VkMemoryRequirements2KHR memReq2 = { VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2_KHR }; + memReq2.pNext = &memDedicatedReq; + + (*m_VulkanFunctions.vkGetBufferMemoryRequirements2KHR)(m_hDevice, &memReqInfo, &memReq2); + + memReq = memReq2.memoryRequirements; + requiresDedicatedAllocation = (memDedicatedReq.requiresDedicatedAllocation != VK_FALSE); + prefersDedicatedAllocation = (memDedicatedReq.prefersDedicatedAllocation != VK_FALSE); + } + else +#endif // #if VMA_DEDICATED_ALLOCATION || VMA_VULKAN_VERSION >= 1001000 + { + (*m_VulkanFunctions.vkGetBufferMemoryRequirements)(m_hDevice, hBuffer, &memReq); + requiresDedicatedAllocation = false; + prefersDedicatedAllocation = false; + } +} + +void VmaAllocator_T::GetImageMemoryRequirements( + VkImage hImage, + VkMemoryRequirements& memReq, + bool& requiresDedicatedAllocation, + bool& prefersDedicatedAllocation) const +{ +#if VMA_DEDICATED_ALLOCATION || VMA_VULKAN_VERSION >= 1001000 + if(m_UseKhrDedicatedAllocation || m_VulkanApiVersion >= VK_MAKE_VERSION(1, 1, 0)) + { + VkImageMemoryRequirementsInfo2KHR memReqInfo = { VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2_KHR }; + memReqInfo.image = hImage; + + VkMemoryDedicatedRequirementsKHR memDedicatedReq = { VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS_KHR }; + + VkMemoryRequirements2KHR memReq2 = { VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2_KHR }; + memReq2.pNext = &memDedicatedReq; + + (*m_VulkanFunctions.vkGetImageMemoryRequirements2KHR)(m_hDevice, &memReqInfo, &memReq2); + + memReq = memReq2.memoryRequirements; + requiresDedicatedAllocation = (memDedicatedReq.requiresDedicatedAllocation != VK_FALSE); + prefersDedicatedAllocation = (memDedicatedReq.prefersDedicatedAllocation != VK_FALSE); + } + else +#endif // #if VMA_DEDICATED_ALLOCATION || VMA_VULKAN_VERSION >= 1001000 + { + (*m_VulkanFunctions.vkGetImageMemoryRequirements)(m_hDevice, hImage, &memReq); + requiresDedicatedAllocation = false; + prefersDedicatedAllocation = false; + } +} + +VkResult VmaAllocator_T::AllocateMemory( + const VkMemoryRequirements& vkMemReq, + bool requiresDedicatedAllocation, + bool prefersDedicatedAllocation, + VkBuffer dedicatedBuffer, + VkImage dedicatedImage, + const VmaAllocationCreateInfo& createInfo, + VmaSuballocationType suballocType, + size_t allocationCount, + VmaAllocation* pAllocations) +{ + memset(pAllocations, 0, sizeof(VmaAllocation) * allocationCount); + + VMA_ASSERT(VmaIsPow2(vkMemReq.alignment)); + + if(vkMemReq.size == 0) + { + return VK_ERROR_VALIDATION_FAILED_EXT; + } + if((createInfo.flags & VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT) != 0 && + (createInfo.flags & VMA_ALLOCATION_CREATE_NEVER_ALLOCATE_BIT) != 0) + { + VMA_ASSERT(0 && "Specifying VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT together with VMA_ALLOCATION_CREATE_NEVER_ALLOCATE_BIT makes no sense."); + return VK_ERROR_OUT_OF_DEVICE_MEMORY; + } + if((createInfo.flags & VMA_ALLOCATION_CREATE_MAPPED_BIT) != 0 && + (createInfo.flags & VMA_ALLOCATION_CREATE_CAN_BECOME_LOST_BIT) != 0) + { + VMA_ASSERT(0 && "Specifying VMA_ALLOCATION_CREATE_MAPPED_BIT together with VMA_ALLOCATION_CREATE_CAN_BECOME_LOST_BIT is invalid."); + return VK_ERROR_OUT_OF_DEVICE_MEMORY; + } + if(requiresDedicatedAllocation) + { + if((createInfo.flags & VMA_ALLOCATION_CREATE_NEVER_ALLOCATE_BIT) != 0) + { + VMA_ASSERT(0 && "VMA_ALLOCATION_CREATE_NEVER_ALLOCATE_BIT specified while dedicated allocation is required."); + return VK_ERROR_OUT_OF_DEVICE_MEMORY; + } + if(createInfo.pool != VK_NULL_HANDLE) + { + VMA_ASSERT(0 && "Pool specified while dedicated allocation is required."); + return VK_ERROR_OUT_OF_DEVICE_MEMORY; + } + } + if((createInfo.pool != VK_NULL_HANDLE) && + ((createInfo.flags & (VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT)) != 0)) + { + VMA_ASSERT(0 && "Specifying VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT when pool != null is invalid."); + return VK_ERROR_OUT_OF_DEVICE_MEMORY; + } + + if(createInfo.pool != VK_NULL_HANDLE) + { + const VkDeviceSize alignmentForPool = VMA_MAX( + vkMemReq.alignment, + GetMemoryTypeMinAlignment(createInfo.pool->m_BlockVector.GetMemoryTypeIndex())); + + VmaAllocationCreateInfo createInfoForPool = createInfo; + // If memory type is not HOST_VISIBLE, disable MAPPED. + if((createInfoForPool.flags & VMA_ALLOCATION_CREATE_MAPPED_BIT) != 0 && + (m_MemProps.memoryTypes[createInfo.pool->m_BlockVector.GetMemoryTypeIndex()].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) == 0) + { + createInfoForPool.flags &= ~VMA_ALLOCATION_CREATE_MAPPED_BIT; + } + + return createInfo.pool->m_BlockVector.Allocate( + m_CurrentFrameIndex.load(), + vkMemReq.size, + alignmentForPool, + createInfoForPool, + suballocType, + allocationCount, + pAllocations); + } + else + { + // Bit mask of memory Vulkan types acceptable for this allocation. + uint32_t memoryTypeBits = vkMemReq.memoryTypeBits; + uint32_t memTypeIndex = UINT32_MAX; + VkResult res = vmaFindMemoryTypeIndex(this, memoryTypeBits, &createInfo, &memTypeIndex); + if(res == VK_SUCCESS) + { + VkDeviceSize alignmentForMemType = VMA_MAX( + vkMemReq.alignment, + GetMemoryTypeMinAlignment(memTypeIndex)); + + res = AllocateMemoryOfType( + vkMemReq.size, + alignmentForMemType, + requiresDedicatedAllocation || prefersDedicatedAllocation, + dedicatedBuffer, + dedicatedImage, + createInfo, + memTypeIndex, + suballocType, + allocationCount, + pAllocations); + // Succeeded on first try. + if(res == VK_SUCCESS) + { + return res; + } + // Allocation from this memory type failed. Try other compatible memory types. + else + { + for(;;) + { + // Remove old memTypeIndex from list of possibilities. + memoryTypeBits &= ~(1u << memTypeIndex); + // Find alternative memTypeIndex. + res = vmaFindMemoryTypeIndex(this, memoryTypeBits, &createInfo, &memTypeIndex); + if(res == VK_SUCCESS) + { + alignmentForMemType = VMA_MAX( + vkMemReq.alignment, + GetMemoryTypeMinAlignment(memTypeIndex)); + + res = AllocateMemoryOfType( + vkMemReq.size, + alignmentForMemType, + requiresDedicatedAllocation || prefersDedicatedAllocation, + dedicatedBuffer, + dedicatedImage, + createInfo, + memTypeIndex, + suballocType, + allocationCount, + pAllocations); + // Allocation from this alternative memory type succeeded. + if(res == VK_SUCCESS) + { + return res; + } + // else: Allocation from this memory type failed. Try next one - next loop iteration. + } + // No other matching memory type index could be found. + else + { + // Not returning res, which is VK_ERROR_FEATURE_NOT_PRESENT, because we already failed to allocate once. + return VK_ERROR_OUT_OF_DEVICE_MEMORY; + } + } + } + } + // Can't find any single memory type maching requirements. res is VK_ERROR_FEATURE_NOT_PRESENT. + else + return res; + } +} + +void VmaAllocator_T::FreeMemory( + size_t allocationCount, + const VmaAllocation* pAllocations) +{ + VMA_ASSERT(pAllocations); + + for(size_t allocIndex = allocationCount; allocIndex--; ) + { + VmaAllocation allocation = pAllocations[allocIndex]; + + if(allocation != VK_NULL_HANDLE) + { + if(TouchAllocation(allocation)) + { + if(VMA_DEBUG_INITIALIZE_ALLOCATIONS) + { + FillAllocation(allocation, VMA_ALLOCATION_FILL_PATTERN_DESTROYED); + } + + switch(allocation->GetType()) + { + case VmaAllocation_T::ALLOCATION_TYPE_BLOCK: + { + VmaBlockVector* pBlockVector = VMA_NULL; + VmaPool hPool = allocation->GetBlock()->GetParentPool(); + if(hPool != VK_NULL_HANDLE) + { + pBlockVector = &hPool->m_BlockVector; + } + else + { + const uint32_t memTypeIndex = allocation->GetMemoryTypeIndex(); + pBlockVector = m_pBlockVectors[memTypeIndex]; + } + pBlockVector->Free(allocation); + } + break; + case VmaAllocation_T::ALLOCATION_TYPE_DEDICATED: + FreeDedicatedMemory(allocation); + break; + default: + VMA_ASSERT(0); + } + } + + // Do this regardless of whether the allocation is lost. Lost allocations still account to Budget.AllocationBytes. + m_Budget.RemoveAllocation(MemoryTypeIndexToHeapIndex(allocation->GetMemoryTypeIndex()), allocation->GetSize()); + allocation->SetUserData(this, VMA_NULL); + m_AllocationObjectAllocator.Free(allocation); + } + } +} + +VkResult VmaAllocator_T::ResizeAllocation( + const VmaAllocation alloc, + VkDeviceSize newSize) +{ + // This function is deprecated and so it does nothing. It's left for backward compatibility. + if(newSize == 0 || alloc->GetLastUseFrameIndex() == VMA_FRAME_INDEX_LOST) + { + return VK_ERROR_VALIDATION_FAILED_EXT; + } + if(newSize == alloc->GetSize()) + { + return VK_SUCCESS; + } + return VK_ERROR_OUT_OF_POOL_MEMORY; +} + +void VmaAllocator_T::CalculateStats(VmaStats* pStats) +{ + // Initialize. + InitStatInfo(pStats->total); + for(size_t i = 0; i < VK_MAX_MEMORY_TYPES; ++i) + InitStatInfo(pStats->memoryType[i]); + for(size_t i = 0; i < VK_MAX_MEMORY_HEAPS; ++i) + InitStatInfo(pStats->memoryHeap[i]); + + // Process default pools. + for(uint32_t memTypeIndex = 0; memTypeIndex < GetMemoryTypeCount(); ++memTypeIndex) + { + VmaBlockVector* const pBlockVector = m_pBlockVectors[memTypeIndex]; + VMA_ASSERT(pBlockVector); + pBlockVector->AddStats(pStats); + } + + // Process custom pools. + { + VmaMutexLockRead lock(m_PoolsMutex, m_UseMutex); + for(size_t poolIndex = 0, poolCount = m_Pools.size(); poolIndex < poolCount; ++poolIndex) + { + m_Pools[poolIndex]->m_BlockVector.AddStats(pStats); + } + } + + // Process dedicated allocations. + for(uint32_t memTypeIndex = 0; memTypeIndex < GetMemoryTypeCount(); ++memTypeIndex) + { + const uint32_t memHeapIndex = MemoryTypeIndexToHeapIndex(memTypeIndex); + VmaMutexLockRead dedicatedAllocationsLock(m_DedicatedAllocationsMutex[memTypeIndex], m_UseMutex); + AllocationVectorType* const pDedicatedAllocVector = m_pDedicatedAllocations[memTypeIndex]; + VMA_ASSERT(pDedicatedAllocVector); + for(size_t allocIndex = 0, allocCount = pDedicatedAllocVector->size(); allocIndex < allocCount; ++allocIndex) + { + VmaStatInfo allocationStatInfo; + (*pDedicatedAllocVector)[allocIndex]->DedicatedAllocCalcStatsInfo(allocationStatInfo); + VmaAddStatInfo(pStats->total, allocationStatInfo); + VmaAddStatInfo(pStats->memoryType[memTypeIndex], allocationStatInfo); + VmaAddStatInfo(pStats->memoryHeap[memHeapIndex], allocationStatInfo); + } + } + + // Postprocess. + VmaPostprocessCalcStatInfo(pStats->total); + for(size_t i = 0; i < GetMemoryTypeCount(); ++i) + VmaPostprocessCalcStatInfo(pStats->memoryType[i]); + for(size_t i = 0; i < GetMemoryHeapCount(); ++i) + VmaPostprocessCalcStatInfo(pStats->memoryHeap[i]); +} + +void VmaAllocator_T::GetBudget(VmaBudget* outBudget, uint32_t firstHeap, uint32_t heapCount) +{ +#if VMA_MEMORY_BUDGET + if(m_UseExtMemoryBudget) + { + if(m_Budget.m_OperationsSinceBudgetFetch < 30) + { + VmaMutexLockRead lockRead(m_Budget.m_BudgetMutex, m_UseMutex); + for(uint32_t i = 0; i < heapCount; ++i, ++outBudget) + { + const uint32_t heapIndex = firstHeap + i; + + outBudget->blockBytes = m_Budget.m_BlockBytes[heapIndex]; + outBudget->allocationBytes = m_Budget.m_AllocationBytes[heapIndex]; + + if(m_Budget.m_VulkanUsage[heapIndex] + outBudget->blockBytes > m_Budget.m_BlockBytesAtBudgetFetch[heapIndex]) + { + outBudget->usage = m_Budget.m_VulkanUsage[heapIndex] + + outBudget->blockBytes - m_Budget.m_BlockBytesAtBudgetFetch[heapIndex]; + } + else + { + outBudget->usage = 0; + } + + // Have to take MIN with heap size because explicit HeapSizeLimit is included in it. + outBudget->budget = VMA_MIN( + m_Budget.m_VulkanBudget[heapIndex], m_MemProps.memoryHeaps[heapIndex].size); + } + } + else + { + UpdateVulkanBudget(); // Outside of mutex lock + GetBudget(outBudget, firstHeap, heapCount); // Recursion + } + } + else +#endif + { + for(uint32_t i = 0; i < heapCount; ++i, ++outBudget) + { + const uint32_t heapIndex = firstHeap + i; + + outBudget->blockBytes = m_Budget.m_BlockBytes[heapIndex]; + outBudget->allocationBytes = m_Budget.m_AllocationBytes[heapIndex]; + + outBudget->usage = outBudget->blockBytes; + outBudget->budget = m_MemProps.memoryHeaps[heapIndex].size * 8 / 10; // 80% heuristics. + } + } +} + +static const uint32_t VMA_VENDOR_ID_AMD = 4098; + +VkResult VmaAllocator_T::DefragmentationBegin( + const VmaDefragmentationInfo2& info, + VmaDefragmentationStats* pStats, + VmaDefragmentationContext* pContext) +{ + if(info.pAllocationsChanged != VMA_NULL) + { + memset(info.pAllocationsChanged, 0, info.allocationCount * sizeof(VkBool32)); + } + + *pContext = vma_new(this, VmaDefragmentationContext_T)( + this, m_CurrentFrameIndex.load(), info.flags, pStats); + + (*pContext)->AddPools(info.poolCount, info.pPools); + (*pContext)->AddAllocations( + info.allocationCount, info.pAllocations, info.pAllocationsChanged); + + VkResult res = (*pContext)->Defragment( + info.maxCpuBytesToMove, info.maxCpuAllocationsToMove, + info.maxGpuBytesToMove, info.maxGpuAllocationsToMove, + info.commandBuffer, pStats, info.flags); + + if(res != VK_NOT_READY) + { + vma_delete(this, *pContext); + *pContext = VMA_NULL; + } + + return res; +} + +VkResult VmaAllocator_T::DefragmentationEnd( + VmaDefragmentationContext context) +{ + vma_delete(this, context); + return VK_SUCCESS; +} + +VkResult VmaAllocator_T::DefragmentationPassBegin( + VmaDefragmentationPassInfo* pInfo, + VmaDefragmentationContext context) +{ + return context->DefragmentPassBegin(pInfo); +} +VkResult VmaAllocator_T::DefragmentationPassEnd( + VmaDefragmentationContext context) +{ + return context->DefragmentPassEnd(); + +} + +void VmaAllocator_T::GetAllocationInfo(VmaAllocation hAllocation, VmaAllocationInfo* pAllocationInfo) +{ + if(hAllocation->CanBecomeLost()) + { + /* + Warning: This is a carefully designed algorithm. + Do not modify unless you really know what you're doing :) + */ + const uint32_t localCurrFrameIndex = m_CurrentFrameIndex.load(); + uint32_t localLastUseFrameIndex = hAllocation->GetLastUseFrameIndex(); + for(;;) + { + if(localLastUseFrameIndex == VMA_FRAME_INDEX_LOST) + { + pAllocationInfo->memoryType = UINT32_MAX; + pAllocationInfo->deviceMemory = VK_NULL_HANDLE; + pAllocationInfo->offset = 0; + pAllocationInfo->size = hAllocation->GetSize(); + pAllocationInfo->pMappedData = VMA_NULL; + pAllocationInfo->pUserData = hAllocation->GetUserData(); + return; + } + else if(localLastUseFrameIndex == localCurrFrameIndex) + { + pAllocationInfo->memoryType = hAllocation->GetMemoryTypeIndex(); + pAllocationInfo->deviceMemory = hAllocation->GetMemory(); + pAllocationInfo->offset = hAllocation->GetOffset(); + pAllocationInfo->size = hAllocation->GetSize(); + pAllocationInfo->pMappedData = VMA_NULL; + pAllocationInfo->pUserData = hAllocation->GetUserData(); + return; + } + else // Last use time earlier than current time. + { + if(hAllocation->CompareExchangeLastUseFrameIndex(localLastUseFrameIndex, localCurrFrameIndex)) + { + localLastUseFrameIndex = localCurrFrameIndex; + } + } + } + } + else + { +#if VMA_STATS_STRING_ENABLED + uint32_t localCurrFrameIndex = m_CurrentFrameIndex.load(); + uint32_t localLastUseFrameIndex = hAllocation->GetLastUseFrameIndex(); + for(;;) + { + VMA_ASSERT(localLastUseFrameIndex != VMA_FRAME_INDEX_LOST); + if(localLastUseFrameIndex == localCurrFrameIndex) + { + break; + } + else // Last use time earlier than current time. + { + if(hAllocation->CompareExchangeLastUseFrameIndex(localLastUseFrameIndex, localCurrFrameIndex)) + { + localLastUseFrameIndex = localCurrFrameIndex; + } + } + } +#endif + + pAllocationInfo->memoryType = hAllocation->GetMemoryTypeIndex(); + pAllocationInfo->deviceMemory = hAllocation->GetMemory(); + pAllocationInfo->offset = hAllocation->GetOffset(); + pAllocationInfo->size = hAllocation->GetSize(); + pAllocationInfo->pMappedData = hAllocation->GetMappedData(); + pAllocationInfo->pUserData = hAllocation->GetUserData(); + } +} + +bool VmaAllocator_T::TouchAllocation(VmaAllocation hAllocation) +{ + // This is a stripped-down version of VmaAllocator_T::GetAllocationInfo. + if(hAllocation->CanBecomeLost()) + { + uint32_t localCurrFrameIndex = m_CurrentFrameIndex.load(); + uint32_t localLastUseFrameIndex = hAllocation->GetLastUseFrameIndex(); + for(;;) + { + if(localLastUseFrameIndex == VMA_FRAME_INDEX_LOST) + { + return false; + } + else if(localLastUseFrameIndex == localCurrFrameIndex) + { + return true; + } + else // Last use time earlier than current time. + { + if(hAllocation->CompareExchangeLastUseFrameIndex(localLastUseFrameIndex, localCurrFrameIndex)) + { + localLastUseFrameIndex = localCurrFrameIndex; + } + } + } + } + else + { +#if VMA_STATS_STRING_ENABLED + uint32_t localCurrFrameIndex = m_CurrentFrameIndex.load(); + uint32_t localLastUseFrameIndex = hAllocation->GetLastUseFrameIndex(); + for(;;) + { + VMA_ASSERT(localLastUseFrameIndex != VMA_FRAME_INDEX_LOST); + if(localLastUseFrameIndex == localCurrFrameIndex) + { + break; + } + else // Last use time earlier than current time. + { + if(hAllocation->CompareExchangeLastUseFrameIndex(localLastUseFrameIndex, localCurrFrameIndex)) + { + localLastUseFrameIndex = localCurrFrameIndex; + } + } + } +#endif + + return true; + } +} + +VkResult VmaAllocator_T::CreatePool(const VmaPoolCreateInfo* pCreateInfo, VmaPool* pPool) +{ + VMA_DEBUG_LOG(" CreatePool: MemoryTypeIndex=%u, flags=%u", pCreateInfo->memoryTypeIndex, pCreateInfo->flags); + + VmaPoolCreateInfo newCreateInfo = *pCreateInfo; + + if(newCreateInfo.maxBlockCount == 0) + { + newCreateInfo.maxBlockCount = SIZE_MAX; + } + if(newCreateInfo.minBlockCount > newCreateInfo.maxBlockCount) + { + return VK_ERROR_INITIALIZATION_FAILED; + } + // Memory type index out of range or forbidden. + if(pCreateInfo->memoryTypeIndex >= GetMemoryTypeCount() || + ((1u << pCreateInfo->memoryTypeIndex) & m_GlobalMemoryTypeBits) == 0) + { + return VK_ERROR_FEATURE_NOT_PRESENT; + } + + const VkDeviceSize preferredBlockSize = CalcPreferredBlockSize(newCreateInfo.memoryTypeIndex); + + *pPool = vma_new(this, VmaPool_T)(this, newCreateInfo, preferredBlockSize); + + VkResult res = (*pPool)->m_BlockVector.CreateMinBlocks(); + if(res != VK_SUCCESS) + { + vma_delete(this, *pPool); + *pPool = VMA_NULL; + return res; + } + + // Add to m_Pools. + { + VmaMutexLockWrite lock(m_PoolsMutex, m_UseMutex); + (*pPool)->SetId(m_NextPoolId++); + VmaVectorInsertSorted(m_Pools, *pPool); + } + + return VK_SUCCESS; +} + +void VmaAllocator_T::DestroyPool(VmaPool pool) +{ + // Remove from m_Pools. + { + VmaMutexLockWrite lock(m_PoolsMutex, m_UseMutex); + bool success = VmaVectorRemoveSorted(m_Pools, pool); + VMA_ASSERT(success && "Pool not found in Allocator."); + } + + vma_delete(this, pool); +} + +void VmaAllocator_T::GetPoolStats(VmaPool pool, VmaPoolStats* pPoolStats) +{ + pool->m_BlockVector.GetPoolStats(pPoolStats); +} + +void VmaAllocator_T::SetCurrentFrameIndex(uint32_t frameIndex) +{ + m_CurrentFrameIndex.store(frameIndex); + +#if VMA_MEMORY_BUDGET + if(m_UseExtMemoryBudget) + { + UpdateVulkanBudget(); + } +#endif // #if VMA_MEMORY_BUDGET +} + +void VmaAllocator_T::MakePoolAllocationsLost( + VmaPool hPool, + size_t* pLostAllocationCount) +{ + hPool->m_BlockVector.MakePoolAllocationsLost( + m_CurrentFrameIndex.load(), + pLostAllocationCount); +} + +VkResult VmaAllocator_T::CheckPoolCorruption(VmaPool hPool) +{ + return hPool->m_BlockVector.CheckCorruption(); +} + +VkResult VmaAllocator_T::CheckCorruption(uint32_t memoryTypeBits) +{ + VkResult finalRes = VK_ERROR_FEATURE_NOT_PRESENT; + + // Process default pools. + for(uint32_t memTypeIndex = 0; memTypeIndex < GetMemoryTypeCount(); ++memTypeIndex) + { + if(((1u << memTypeIndex) & memoryTypeBits) != 0) + { + VmaBlockVector* const pBlockVector = m_pBlockVectors[memTypeIndex]; + VMA_ASSERT(pBlockVector); + VkResult localRes = pBlockVector->CheckCorruption(); + switch(localRes) + { + case VK_ERROR_FEATURE_NOT_PRESENT: + break; + case VK_SUCCESS: + finalRes = VK_SUCCESS; + break; + default: + return localRes; + } + } + } + + // Process custom pools. + { + VmaMutexLockRead lock(m_PoolsMutex, m_UseMutex); + for(size_t poolIndex = 0, poolCount = m_Pools.size(); poolIndex < poolCount; ++poolIndex) + { + if(((1u << m_Pools[poolIndex]->m_BlockVector.GetMemoryTypeIndex()) & memoryTypeBits) != 0) + { + VkResult localRes = m_Pools[poolIndex]->m_BlockVector.CheckCorruption(); + switch(localRes) + { + case VK_ERROR_FEATURE_NOT_PRESENT: + break; + case VK_SUCCESS: + finalRes = VK_SUCCESS; + break; + default: + return localRes; + } + } + } + } + + return finalRes; +} + +void VmaAllocator_T::CreateLostAllocation(VmaAllocation* pAllocation) +{ + *pAllocation = m_AllocationObjectAllocator.Allocate(VMA_FRAME_INDEX_LOST, false); + (*pAllocation)->InitLost(); +} + +VkResult VmaAllocator_T::AllocateVulkanMemory(const VkMemoryAllocateInfo* pAllocateInfo, VkDeviceMemory* pMemory) +{ + const uint32_t heapIndex = MemoryTypeIndexToHeapIndex(pAllocateInfo->memoryTypeIndex); + + // HeapSizeLimit is in effect for this heap. + if((m_HeapSizeLimitMask & (1u << heapIndex)) != 0) + { + const VkDeviceSize heapSize = m_MemProps.memoryHeaps[heapIndex].size; + VkDeviceSize blockBytes = m_Budget.m_BlockBytes[heapIndex]; + for(;;) + { + const VkDeviceSize blockBytesAfterAllocation = blockBytes + pAllocateInfo->allocationSize; + if(blockBytesAfterAllocation > heapSize) + { + return VK_ERROR_OUT_OF_DEVICE_MEMORY; + } + if(m_Budget.m_BlockBytes[heapIndex].compare_exchange_strong(blockBytes, blockBytesAfterAllocation)) + { + break; + } + } + } + else + { + m_Budget.m_BlockBytes[heapIndex] += pAllocateInfo->allocationSize; + } + + // VULKAN CALL vkAllocateMemory. + VkResult res = (*m_VulkanFunctions.vkAllocateMemory)(m_hDevice, pAllocateInfo, GetAllocationCallbacks(), pMemory); + + if(res == VK_SUCCESS) + { +#if VMA_MEMORY_BUDGET + ++m_Budget.m_OperationsSinceBudgetFetch; +#endif + + // Informative callback. + if(m_DeviceMemoryCallbacks.pfnAllocate != VMA_NULL) + { + (*m_DeviceMemoryCallbacks.pfnAllocate)(this, pAllocateInfo->memoryTypeIndex, *pMemory, pAllocateInfo->allocationSize); + } + } + else + { + m_Budget.m_BlockBytes[heapIndex] -= pAllocateInfo->allocationSize; + } + + return res; +} + +void VmaAllocator_T::FreeVulkanMemory(uint32_t memoryType, VkDeviceSize size, VkDeviceMemory hMemory) +{ + // Informative callback. + if(m_DeviceMemoryCallbacks.pfnFree != VMA_NULL) + { + (*m_DeviceMemoryCallbacks.pfnFree)(this, memoryType, hMemory, size); + } + + // VULKAN CALL vkFreeMemory. + (*m_VulkanFunctions.vkFreeMemory)(m_hDevice, hMemory, GetAllocationCallbacks()); + + m_Budget.m_BlockBytes[MemoryTypeIndexToHeapIndex(memoryType)] -= size; +} + +VkResult VmaAllocator_T::BindVulkanBuffer( + VkDeviceMemory memory, + VkDeviceSize memoryOffset, + VkBuffer buffer, + const void* pNext) +{ + if(pNext != VMA_NULL) + { +#if VMA_VULKAN_VERSION >= 1001000 || VMA_BIND_MEMORY2 + if((m_UseKhrBindMemory2 || m_VulkanApiVersion >= VK_MAKE_VERSION(1, 1, 0)) && + m_VulkanFunctions.vkBindBufferMemory2KHR != VMA_NULL) + { + VkBindBufferMemoryInfoKHR bindBufferMemoryInfo = { VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO_KHR }; + bindBufferMemoryInfo.pNext = pNext; + bindBufferMemoryInfo.buffer = buffer; + bindBufferMemoryInfo.memory = memory; + bindBufferMemoryInfo.memoryOffset = memoryOffset; + return (*m_VulkanFunctions.vkBindBufferMemory2KHR)(m_hDevice, 1, &bindBufferMemoryInfo); + } + else +#endif // #if VMA_VULKAN_VERSION >= 1001000 || VMA_BIND_MEMORY2 + { + return VK_ERROR_EXTENSION_NOT_PRESENT; + } + } + else + { + return (*m_VulkanFunctions.vkBindBufferMemory)(m_hDevice, buffer, memory, memoryOffset); + } +} + +VkResult VmaAllocator_T::BindVulkanImage( + VkDeviceMemory memory, + VkDeviceSize memoryOffset, + VkImage image, + const void* pNext) +{ + if(pNext != VMA_NULL) + { +#if VMA_VULKAN_VERSION >= 1001000 || VMA_BIND_MEMORY2 + if((m_UseKhrBindMemory2 || m_VulkanApiVersion >= VK_MAKE_VERSION(1, 1, 0)) && + m_VulkanFunctions.vkBindImageMemory2KHR != VMA_NULL) + { + VkBindImageMemoryInfoKHR bindBufferMemoryInfo = { VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO_KHR }; + bindBufferMemoryInfo.pNext = pNext; + bindBufferMemoryInfo.image = image; + bindBufferMemoryInfo.memory = memory; + bindBufferMemoryInfo.memoryOffset = memoryOffset; + return (*m_VulkanFunctions.vkBindImageMemory2KHR)(m_hDevice, 1, &bindBufferMemoryInfo); + } + else +#endif // #if VMA_BIND_MEMORY2 + { + return VK_ERROR_EXTENSION_NOT_PRESENT; + } + } + else + { + return (*m_VulkanFunctions.vkBindImageMemory)(m_hDevice, image, memory, memoryOffset); + } +} + +VkResult VmaAllocator_T::Map(VmaAllocation hAllocation, void** ppData) +{ + if(hAllocation->CanBecomeLost()) + { + return VK_ERROR_MEMORY_MAP_FAILED; + } + + switch(hAllocation->GetType()) + { + case VmaAllocation_T::ALLOCATION_TYPE_BLOCK: + { + VmaDeviceMemoryBlock* const pBlock = hAllocation->GetBlock(); + char *pBytes = VMA_NULL; + VkResult res = pBlock->Map(this, 1, (void**)&pBytes); + if(res == VK_SUCCESS) + { + *ppData = pBytes + (ptrdiff_t)hAllocation->GetOffset(); + hAllocation->BlockAllocMap(); + } + return res; + } + case VmaAllocation_T::ALLOCATION_TYPE_DEDICATED: + return hAllocation->DedicatedAllocMap(this, ppData); + default: + VMA_ASSERT(0); + return VK_ERROR_MEMORY_MAP_FAILED; + } +} + +void VmaAllocator_T::Unmap(VmaAllocation hAllocation) +{ + switch(hAllocation->GetType()) + { + case VmaAllocation_T::ALLOCATION_TYPE_BLOCK: + { + VmaDeviceMemoryBlock* const pBlock = hAllocation->GetBlock(); + hAllocation->BlockAllocUnmap(); + pBlock->Unmap(this, 1); + } + break; + case VmaAllocation_T::ALLOCATION_TYPE_DEDICATED: + hAllocation->DedicatedAllocUnmap(this); + break; + default: + VMA_ASSERT(0); + } +} + +VkResult VmaAllocator_T::BindBufferMemory( + VmaAllocation hAllocation, + VkDeviceSize allocationLocalOffset, + VkBuffer hBuffer, + const void* pNext) +{ + VkResult res = VK_SUCCESS; + switch(hAllocation->GetType()) + { + case VmaAllocation_T::ALLOCATION_TYPE_DEDICATED: + res = BindVulkanBuffer(hAllocation->GetMemory(), allocationLocalOffset, hBuffer, pNext); + break; + case VmaAllocation_T::ALLOCATION_TYPE_BLOCK: + { + VmaDeviceMemoryBlock* const pBlock = hAllocation->GetBlock(); + VMA_ASSERT(pBlock && "Binding buffer to allocation that doesn't belong to any block. Is the allocation lost?"); + res = pBlock->BindBufferMemory(this, hAllocation, allocationLocalOffset, hBuffer, pNext); + break; + } + default: + VMA_ASSERT(0); + } + return res; +} + +VkResult VmaAllocator_T::BindImageMemory( + VmaAllocation hAllocation, + VkDeviceSize allocationLocalOffset, + VkImage hImage, + const void* pNext) +{ + VkResult res = VK_SUCCESS; + switch(hAllocation->GetType()) + { + case VmaAllocation_T::ALLOCATION_TYPE_DEDICATED: + res = BindVulkanImage(hAllocation->GetMemory(), allocationLocalOffset, hImage, pNext); + break; + case VmaAllocation_T::ALLOCATION_TYPE_BLOCK: + { + VmaDeviceMemoryBlock* pBlock = hAllocation->GetBlock(); + VMA_ASSERT(pBlock && "Binding image to allocation that doesn't belong to any block. Is the allocation lost?"); + res = pBlock->BindImageMemory(this, hAllocation, allocationLocalOffset, hImage, pNext); + break; + } + default: + VMA_ASSERT(0); + } + return res; +} + +void VmaAllocator_T::FlushOrInvalidateAllocation( + VmaAllocation hAllocation, + VkDeviceSize offset, VkDeviceSize size, + VMA_CACHE_OPERATION op) +{ + const uint32_t memTypeIndex = hAllocation->GetMemoryTypeIndex(); + if(size > 0 && IsMemoryTypeNonCoherent(memTypeIndex)) + { + const VkDeviceSize allocationSize = hAllocation->GetSize(); + VMA_ASSERT(offset <= allocationSize); + + const VkDeviceSize nonCoherentAtomSize = m_PhysicalDeviceProperties.limits.nonCoherentAtomSize; + + VkMappedMemoryRange memRange = { VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE }; + memRange.memory = hAllocation->GetMemory(); + + switch(hAllocation->GetType()) + { + case VmaAllocation_T::ALLOCATION_TYPE_DEDICATED: + memRange.offset = VmaAlignDown(offset, nonCoherentAtomSize); + if(size == VK_WHOLE_SIZE) + { + memRange.size = allocationSize - memRange.offset; + } + else + { + VMA_ASSERT(offset + size <= allocationSize); + memRange.size = VMA_MIN( + VmaAlignUp(size + (offset - memRange.offset), nonCoherentAtomSize), + allocationSize - memRange.offset); + } + break; + + case VmaAllocation_T::ALLOCATION_TYPE_BLOCK: + { + // 1. Still within this allocation. + memRange.offset = VmaAlignDown(offset, nonCoherentAtomSize); + if(size == VK_WHOLE_SIZE) + { + size = allocationSize - offset; + } + else + { + VMA_ASSERT(offset + size <= allocationSize); + } + memRange.size = VmaAlignUp(size + (offset - memRange.offset), nonCoherentAtomSize); + + // 2. Adjust to whole block. + const VkDeviceSize allocationOffset = hAllocation->GetOffset(); + VMA_ASSERT(allocationOffset % nonCoherentAtomSize == 0); + const VkDeviceSize blockSize = hAllocation->GetBlock()->m_pMetadata->GetSize(); + memRange.offset += allocationOffset; + memRange.size = VMA_MIN(memRange.size, blockSize - memRange.offset); + + break; + } + + default: + VMA_ASSERT(0); + } + + switch(op) + { + case VMA_CACHE_FLUSH: + (*GetVulkanFunctions().vkFlushMappedMemoryRanges)(m_hDevice, 1, &memRange); + break; + case VMA_CACHE_INVALIDATE: + (*GetVulkanFunctions().vkInvalidateMappedMemoryRanges)(m_hDevice, 1, &memRange); + break; + default: + VMA_ASSERT(0); + } + } + // else: Just ignore this call. +} + +void VmaAllocator_T::FreeDedicatedMemory(const VmaAllocation allocation) +{ + VMA_ASSERT(allocation && allocation->GetType() == VmaAllocation_T::ALLOCATION_TYPE_DEDICATED); + + const uint32_t memTypeIndex = allocation->GetMemoryTypeIndex(); + { + VmaMutexLockWrite lock(m_DedicatedAllocationsMutex[memTypeIndex], m_UseMutex); + AllocationVectorType* const pDedicatedAllocations = m_pDedicatedAllocations[memTypeIndex]; + VMA_ASSERT(pDedicatedAllocations); + bool success = VmaVectorRemoveSorted(*pDedicatedAllocations, allocation); + VMA_ASSERT(success); + } + + VkDeviceMemory hMemory = allocation->GetMemory(); + + /* + There is no need to call this, because Vulkan spec allows to skip vkUnmapMemory + before vkFreeMemory. + + if(allocation->GetMappedData() != VMA_NULL) + { + (*m_VulkanFunctions.vkUnmapMemory)(m_hDevice, hMemory); + } + */ + + FreeVulkanMemory(memTypeIndex, allocation->GetSize(), hMemory); + + VMA_DEBUG_LOG(" Freed DedicatedMemory MemoryTypeIndex=%u", memTypeIndex); +} + +uint32_t VmaAllocator_T::CalculateGpuDefragmentationMemoryTypeBits() const +{ + VkBufferCreateInfo dummyBufCreateInfo; + VmaFillGpuDefragmentationBufferCreateInfo(dummyBufCreateInfo); + + uint32_t memoryTypeBits = 0; + + // Create buffer. + VkBuffer buf = VK_NULL_HANDLE; + VkResult res = (*GetVulkanFunctions().vkCreateBuffer)( + m_hDevice, &dummyBufCreateInfo, GetAllocationCallbacks(), &buf); + if(res == VK_SUCCESS) + { + // Query for supported memory types. + VkMemoryRequirements memReq; + (*GetVulkanFunctions().vkGetBufferMemoryRequirements)(m_hDevice, buf, &memReq); + memoryTypeBits = memReq.memoryTypeBits; + + // Destroy buffer. + (*GetVulkanFunctions().vkDestroyBuffer)(m_hDevice, buf, GetAllocationCallbacks()); + } + + return memoryTypeBits; +} + +uint32_t VmaAllocator_T::CalculateGlobalMemoryTypeBits() const +{ + // Make sure memory information is already fetched. + VMA_ASSERT(GetMemoryTypeCount() > 0); + + uint32_t memoryTypeBits = UINT32_MAX; + + if(!m_UseAmdDeviceCoherentMemory) + { + // Exclude memory types that have VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD. + for(uint32_t memTypeIndex = 0; memTypeIndex < GetMemoryTypeCount(); ++memTypeIndex) + { + if((m_MemProps.memoryTypes[memTypeIndex].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD_COPY) != 0) + { + memoryTypeBits &= ~(1u << memTypeIndex); + } + } + } + + return memoryTypeBits; +} + +#if VMA_MEMORY_BUDGET + +void VmaAllocator_T::UpdateVulkanBudget() +{ + VMA_ASSERT(m_UseExtMemoryBudget); + + VkPhysicalDeviceMemoryProperties2KHR memProps = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2_KHR }; + + VkPhysicalDeviceMemoryBudgetPropertiesEXT budgetProps = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_BUDGET_PROPERTIES_EXT }; + memProps.pNext = &budgetProps; + + GetVulkanFunctions().vkGetPhysicalDeviceMemoryProperties2KHR(m_PhysicalDevice, &memProps); + + { + VmaMutexLockWrite lockWrite(m_Budget.m_BudgetMutex, m_UseMutex); + + for(uint32_t heapIndex = 0; heapIndex < GetMemoryHeapCount(); ++heapIndex) + { + m_Budget.m_VulkanUsage[heapIndex] = budgetProps.heapUsage[heapIndex]; + m_Budget.m_VulkanBudget[heapIndex] = budgetProps.heapBudget[heapIndex]; + m_Budget.m_BlockBytesAtBudgetFetch[heapIndex] = m_Budget.m_BlockBytes[heapIndex].load(); + + // Some bugged drivers return the budget incorrectly, e.g. 0 or much bigger than heap size. + if(m_Budget.m_VulkanBudget[heapIndex] == 0) + { + m_Budget.m_VulkanBudget[heapIndex] = m_MemProps.memoryHeaps[heapIndex].size * 8 / 10; // 80% heuristics. + } + else if(m_Budget.m_VulkanBudget[heapIndex] > m_MemProps.memoryHeaps[heapIndex].size) + { + m_Budget.m_VulkanBudget[heapIndex] = m_MemProps.memoryHeaps[heapIndex].size; + } + if(m_Budget.m_VulkanUsage[heapIndex] == 0 && m_Budget.m_BlockBytesAtBudgetFetch[heapIndex] > 0) + { + m_Budget.m_VulkanUsage[heapIndex] = m_Budget.m_BlockBytesAtBudgetFetch[heapIndex]; + } + } + m_Budget.m_OperationsSinceBudgetFetch = 0; + } +} + +#endif // #if VMA_MEMORY_BUDGET + +void VmaAllocator_T::FillAllocation(const VmaAllocation hAllocation, uint8_t pattern) +{ + if(VMA_DEBUG_INITIALIZE_ALLOCATIONS && + !hAllocation->CanBecomeLost() && + (m_MemProps.memoryTypes[hAllocation->GetMemoryTypeIndex()].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) != 0) + { + void* pData = VMA_NULL; + VkResult res = Map(hAllocation, &pData); + if(res == VK_SUCCESS) + { + memset(pData, (int)pattern, (size_t)hAllocation->GetSize()); + FlushOrInvalidateAllocation(hAllocation, 0, VK_WHOLE_SIZE, VMA_CACHE_FLUSH); + Unmap(hAllocation); + } + else + { + VMA_ASSERT(0 && "VMA_DEBUG_INITIALIZE_ALLOCATIONS is enabled, but couldn't map memory to fill allocation."); + } + } +} + +uint32_t VmaAllocator_T::GetGpuDefragmentationMemoryTypeBits() +{ + uint32_t memoryTypeBits = m_GpuDefragmentationMemoryTypeBits.load(); + if(memoryTypeBits == UINT32_MAX) + { + memoryTypeBits = CalculateGpuDefragmentationMemoryTypeBits(); + m_GpuDefragmentationMemoryTypeBits.store(memoryTypeBits); + } + return memoryTypeBits; +} + +#if VMA_STATS_STRING_ENABLED + +void VmaAllocator_T::PrintDetailedMap(VmaJsonWriter& json) +{ + bool dedicatedAllocationsStarted = false; + for(uint32_t memTypeIndex = 0; memTypeIndex < GetMemoryTypeCount(); ++memTypeIndex) + { + VmaMutexLockRead dedicatedAllocationsLock(m_DedicatedAllocationsMutex[memTypeIndex], m_UseMutex); + AllocationVectorType* const pDedicatedAllocVector = m_pDedicatedAllocations[memTypeIndex]; + VMA_ASSERT(pDedicatedAllocVector); + if(pDedicatedAllocVector->empty() == false) + { + if(dedicatedAllocationsStarted == false) + { + dedicatedAllocationsStarted = true; + json.WriteString("DedicatedAllocations"); + json.BeginObject(); + } + + json.BeginString("Type "); + json.ContinueString(memTypeIndex); + json.EndString(); + + json.BeginArray(); + + for(size_t i = 0; i < pDedicatedAllocVector->size(); ++i) + { + json.BeginObject(true); + const VmaAllocation hAlloc = (*pDedicatedAllocVector)[i]; + hAlloc->PrintParameters(json); + json.EndObject(); + } + + json.EndArray(); + } + } + if(dedicatedAllocationsStarted) + { + json.EndObject(); + } + + { + bool allocationsStarted = false; + for(uint32_t memTypeIndex = 0; memTypeIndex < GetMemoryTypeCount(); ++memTypeIndex) + { + if(m_pBlockVectors[memTypeIndex]->IsEmpty() == false) + { + if(allocationsStarted == false) + { + allocationsStarted = true; + json.WriteString("DefaultPools"); + json.BeginObject(); + } + + json.BeginString("Type "); + json.ContinueString(memTypeIndex); + json.EndString(); + + m_pBlockVectors[memTypeIndex]->PrintDetailedMap(json); + } + } + if(allocationsStarted) + { + json.EndObject(); + } + } + + // Custom pools + { + VmaMutexLockRead lock(m_PoolsMutex, m_UseMutex); + const size_t poolCount = m_Pools.size(); + if(poolCount > 0) + { + json.WriteString("Pools"); + json.BeginObject(); + for(size_t poolIndex = 0; poolIndex < poolCount; ++poolIndex) + { + json.BeginString(); + json.ContinueString(m_Pools[poolIndex]->GetId()); + json.EndString(); + + m_Pools[poolIndex]->m_BlockVector.PrintDetailedMap(json); + } + json.EndObject(); + } + } +} + +#endif // #if VMA_STATS_STRING_ENABLED + +//////////////////////////////////////////////////////////////////////////////// +// Public interface + +VMA_CALL_PRE VkResult VMA_CALL_POST vmaCreateAllocator( + const VmaAllocatorCreateInfo* pCreateInfo, + VmaAllocator* pAllocator) +{ + VMA_ASSERT(pCreateInfo && pAllocator); + VMA_ASSERT(pCreateInfo->vulkanApiVersion == 0 || + (VK_VERSION_MAJOR(pCreateInfo->vulkanApiVersion) == 1 && VK_VERSION_MINOR(pCreateInfo->vulkanApiVersion) <= 2)); + VMA_DEBUG_LOG("vmaCreateAllocator"); + *pAllocator = vma_new(pCreateInfo->pAllocationCallbacks, VmaAllocator_T)(pCreateInfo); + return (*pAllocator)->Init(pCreateInfo); +} + +VMA_CALL_PRE void VMA_CALL_POST vmaDestroyAllocator( + VmaAllocator allocator) +{ + if(allocator != VK_NULL_HANDLE) + { + VMA_DEBUG_LOG("vmaDestroyAllocator"); + VkAllocationCallbacks allocationCallbacks = allocator->m_AllocationCallbacks; + vma_delete(&allocationCallbacks, allocator); + } +} + +VMA_CALL_PRE void VMA_CALL_POST vmaGetAllocatorInfo(VmaAllocator allocator, VmaAllocatorInfo* pAllocatorInfo) +{ + VMA_ASSERT(allocator && pAllocatorInfo); + pAllocatorInfo->instance = allocator->m_hInstance; + pAllocatorInfo->physicalDevice = allocator->GetPhysicalDevice(); + pAllocatorInfo->device = allocator->m_hDevice; +} + +VMA_CALL_PRE void VMA_CALL_POST vmaGetPhysicalDeviceProperties( + VmaAllocator allocator, + const VkPhysicalDeviceProperties **ppPhysicalDeviceProperties) +{ + VMA_ASSERT(allocator && ppPhysicalDeviceProperties); + *ppPhysicalDeviceProperties = &allocator->m_PhysicalDeviceProperties; +} + +VMA_CALL_PRE void VMA_CALL_POST vmaGetMemoryProperties( + VmaAllocator allocator, + const VkPhysicalDeviceMemoryProperties** ppPhysicalDeviceMemoryProperties) +{ + VMA_ASSERT(allocator && ppPhysicalDeviceMemoryProperties); + *ppPhysicalDeviceMemoryProperties = &allocator->m_MemProps; +} + +VMA_CALL_PRE void VMA_CALL_POST vmaGetMemoryTypeProperties( + VmaAllocator allocator, + uint32_t memoryTypeIndex, + VkMemoryPropertyFlags* pFlags) +{ + VMA_ASSERT(allocator && pFlags); + VMA_ASSERT(memoryTypeIndex < allocator->GetMemoryTypeCount()); + *pFlags = allocator->m_MemProps.memoryTypes[memoryTypeIndex].propertyFlags; +} + +VMA_CALL_PRE void VMA_CALL_POST vmaSetCurrentFrameIndex( + VmaAllocator allocator, + uint32_t frameIndex) +{ + VMA_ASSERT(allocator); + VMA_ASSERT(frameIndex != VMA_FRAME_INDEX_LOST); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + + allocator->SetCurrentFrameIndex(frameIndex); +} + +VMA_CALL_PRE void VMA_CALL_POST vmaCalculateStats( + VmaAllocator allocator, + VmaStats* pStats) +{ + VMA_ASSERT(allocator && pStats); + VMA_DEBUG_GLOBAL_MUTEX_LOCK + allocator->CalculateStats(pStats); +} + +VMA_CALL_PRE void VMA_CALL_POST vmaGetBudget( + VmaAllocator allocator, + VmaBudget* pBudget) +{ + VMA_ASSERT(allocator && pBudget); + VMA_DEBUG_GLOBAL_MUTEX_LOCK + allocator->GetBudget(pBudget, 0, allocator->GetMemoryHeapCount()); +} + +#if VMA_STATS_STRING_ENABLED + +VMA_CALL_PRE void VMA_CALL_POST vmaBuildStatsString( + VmaAllocator allocator, + char** ppStatsString, + VkBool32 detailedMap) +{ + VMA_ASSERT(allocator && ppStatsString); + VMA_DEBUG_GLOBAL_MUTEX_LOCK + + VmaStringBuilder sb(allocator); + { + VmaJsonWriter json(allocator->GetAllocationCallbacks(), sb); + json.BeginObject(); + + VmaBudget budget[VK_MAX_MEMORY_HEAPS]; + allocator->GetBudget(budget, 0, allocator->GetMemoryHeapCount()); + + VmaStats stats; + allocator->CalculateStats(&stats); + + json.WriteString("Total"); + VmaPrintStatInfo(json, stats.total); + + for(uint32_t heapIndex = 0; heapIndex < allocator->GetMemoryHeapCount(); ++heapIndex) + { + json.BeginString("Heap "); + json.ContinueString(heapIndex); + json.EndString(); + json.BeginObject(); + + json.WriteString("Size"); + json.WriteNumber(allocator->m_MemProps.memoryHeaps[heapIndex].size); + + json.WriteString("Flags"); + json.BeginArray(true); + if((allocator->m_MemProps.memoryHeaps[heapIndex].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) != 0) + { + json.WriteString("DEVICE_LOCAL"); + } + json.EndArray(); + + json.WriteString("Budget"); + json.BeginObject(); + { + json.WriteString("BlockBytes"); + json.WriteNumber(budget[heapIndex].blockBytes); + json.WriteString("AllocationBytes"); + json.WriteNumber(budget[heapIndex].allocationBytes); + json.WriteString("Usage"); + json.WriteNumber(budget[heapIndex].usage); + json.WriteString("Budget"); + json.WriteNumber(budget[heapIndex].budget); + } + json.EndObject(); + + if(stats.memoryHeap[heapIndex].blockCount > 0) + { + json.WriteString("Stats"); + VmaPrintStatInfo(json, stats.memoryHeap[heapIndex]); + } + + for(uint32_t typeIndex = 0; typeIndex < allocator->GetMemoryTypeCount(); ++typeIndex) + { + if(allocator->MemoryTypeIndexToHeapIndex(typeIndex) == heapIndex) + { + json.BeginString("Type "); + json.ContinueString(typeIndex); + json.EndString(); + + json.BeginObject(); + + json.WriteString("Flags"); + json.BeginArray(true); + VkMemoryPropertyFlags flags = allocator->m_MemProps.memoryTypes[typeIndex].propertyFlags; + if((flags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) != 0) + { + json.WriteString("DEVICE_LOCAL"); + } + if((flags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) != 0) + { + json.WriteString("HOST_VISIBLE"); + } + if((flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) != 0) + { + json.WriteString("HOST_COHERENT"); + } + if((flags & VK_MEMORY_PROPERTY_HOST_CACHED_BIT) != 0) + { + json.WriteString("HOST_CACHED"); + } + if((flags & VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT) != 0) + { + json.WriteString("LAZILY_ALLOCATED"); + } + if((flags & VK_MEMORY_PROPERTY_PROTECTED_BIT) != 0) + { + json.WriteString(" PROTECTED"); + } + if((flags & VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD_COPY) != 0) + { + json.WriteString(" DEVICE_COHERENT"); + } + if((flags & VK_MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD_COPY) != 0) + { + json.WriteString(" DEVICE_UNCACHED"); + } + json.EndArray(); + + if(stats.memoryType[typeIndex].blockCount > 0) + { + json.WriteString("Stats"); + VmaPrintStatInfo(json, stats.memoryType[typeIndex]); + } + + json.EndObject(); + } + } + + json.EndObject(); + } + if(detailedMap == VK_TRUE) + { + allocator->PrintDetailedMap(json); + } + + json.EndObject(); + } + + const size_t len = sb.GetLength(); + char* const pChars = vma_new_array(allocator, char, len + 1); + if(len > 0) + { + memcpy(pChars, sb.GetData(), len); + } + pChars[len] = '\0'; + *ppStatsString = pChars; +} + +VMA_CALL_PRE void VMA_CALL_POST vmaFreeStatsString( + VmaAllocator allocator, + char* pStatsString) +{ + if(pStatsString != VMA_NULL) + { + VMA_ASSERT(allocator); + size_t len = strlen(pStatsString); + vma_delete_array(allocator, pStatsString, len + 1); + } +} + +#endif // #if VMA_STATS_STRING_ENABLED + +/* +This function is not protected by any mutex because it just reads immutable data. +*/ +VMA_CALL_PRE VkResult VMA_CALL_POST vmaFindMemoryTypeIndex( + VmaAllocator allocator, + uint32_t memoryTypeBits, + const VmaAllocationCreateInfo* pAllocationCreateInfo, + uint32_t* pMemoryTypeIndex) +{ + VMA_ASSERT(allocator != VK_NULL_HANDLE); + VMA_ASSERT(pAllocationCreateInfo != VMA_NULL); + VMA_ASSERT(pMemoryTypeIndex != VMA_NULL); + + memoryTypeBits &= allocator->GetGlobalMemoryTypeBits(); + + if(pAllocationCreateInfo->memoryTypeBits != 0) + { + memoryTypeBits &= pAllocationCreateInfo->memoryTypeBits; + } + + uint32_t requiredFlags = pAllocationCreateInfo->requiredFlags; + uint32_t preferredFlags = pAllocationCreateInfo->preferredFlags; + uint32_t notPreferredFlags = 0; + + // Convert usage to requiredFlags and preferredFlags. + switch(pAllocationCreateInfo->usage) + { + case VMA_MEMORY_USAGE_UNKNOWN: + break; + case VMA_MEMORY_USAGE_GPU_ONLY: + if(!allocator->IsIntegratedGpu() || (preferredFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) == 0) + { + preferredFlags |= VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; + } + break; + case VMA_MEMORY_USAGE_CPU_ONLY: + requiredFlags |= VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; + break; + case VMA_MEMORY_USAGE_CPU_TO_GPU: + requiredFlags |= VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; + if(!allocator->IsIntegratedGpu() || (preferredFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) == 0) + { + preferredFlags |= VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; + } + break; + case VMA_MEMORY_USAGE_GPU_TO_CPU: + requiredFlags |= VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; + preferredFlags |= VK_MEMORY_PROPERTY_HOST_CACHED_BIT; + break; + case VMA_MEMORY_USAGE_CPU_COPY: + notPreferredFlags |= VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; + break; + case VMA_MEMORY_USAGE_GPU_LAZILY_ALLOCATED: + requiredFlags |= VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT; + break; + default: + VMA_ASSERT(0); + break; + } + + // Avoid DEVICE_COHERENT unless explicitly requested. + if(((pAllocationCreateInfo->requiredFlags | pAllocationCreateInfo->preferredFlags) & + (VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD_COPY | VK_MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD_COPY)) == 0) + { + notPreferredFlags |= VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD_COPY; + } + + *pMemoryTypeIndex = UINT32_MAX; + uint32_t minCost = UINT32_MAX; + for(uint32_t memTypeIndex = 0, memTypeBit = 1; + memTypeIndex < allocator->GetMemoryTypeCount(); + ++memTypeIndex, memTypeBit <<= 1) + { + // This memory type is acceptable according to memoryTypeBits bitmask. + if((memTypeBit & memoryTypeBits) != 0) + { + const VkMemoryPropertyFlags currFlags = + allocator->m_MemProps.memoryTypes[memTypeIndex].propertyFlags; + // This memory type contains requiredFlags. + if((requiredFlags & ~currFlags) == 0) + { + // Calculate cost as number of bits from preferredFlags not present in this memory type. + uint32_t currCost = VmaCountBitsSet(preferredFlags & ~currFlags) + + VmaCountBitsSet(currFlags & notPreferredFlags); + // Remember memory type with lowest cost. + if(currCost < minCost) + { + *pMemoryTypeIndex = memTypeIndex; + if(currCost == 0) + { + return VK_SUCCESS; + } + minCost = currCost; + } + } + } + } + return (*pMemoryTypeIndex != UINT32_MAX) ? VK_SUCCESS : VK_ERROR_FEATURE_NOT_PRESENT; +} + +VMA_CALL_PRE VkResult VMA_CALL_POST vmaFindMemoryTypeIndexForBufferInfo( + VmaAllocator allocator, + const VkBufferCreateInfo* pBufferCreateInfo, + const VmaAllocationCreateInfo* pAllocationCreateInfo, + uint32_t* pMemoryTypeIndex) +{ + VMA_ASSERT(allocator != VK_NULL_HANDLE); + VMA_ASSERT(pBufferCreateInfo != VMA_NULL); + VMA_ASSERT(pAllocationCreateInfo != VMA_NULL); + VMA_ASSERT(pMemoryTypeIndex != VMA_NULL); + + const VkDevice hDev = allocator->m_hDevice; + VkBuffer hBuffer = VK_NULL_HANDLE; + VkResult res = allocator->GetVulkanFunctions().vkCreateBuffer( + hDev, pBufferCreateInfo, allocator->GetAllocationCallbacks(), &hBuffer); + if(res == VK_SUCCESS) + { + VkMemoryRequirements memReq = {}; + allocator->GetVulkanFunctions().vkGetBufferMemoryRequirements( + hDev, hBuffer, &memReq); + + res = vmaFindMemoryTypeIndex( + allocator, + memReq.memoryTypeBits, + pAllocationCreateInfo, + pMemoryTypeIndex); + + allocator->GetVulkanFunctions().vkDestroyBuffer( + hDev, hBuffer, allocator->GetAllocationCallbacks()); + } + return res; +} + +VMA_CALL_PRE VkResult VMA_CALL_POST vmaFindMemoryTypeIndexForImageInfo( + VmaAllocator allocator, + const VkImageCreateInfo* pImageCreateInfo, + const VmaAllocationCreateInfo* pAllocationCreateInfo, + uint32_t* pMemoryTypeIndex) +{ + VMA_ASSERT(allocator != VK_NULL_HANDLE); + VMA_ASSERT(pImageCreateInfo != VMA_NULL); + VMA_ASSERT(pAllocationCreateInfo != VMA_NULL); + VMA_ASSERT(pMemoryTypeIndex != VMA_NULL); + + const VkDevice hDev = allocator->m_hDevice; + VkImage hImage = VK_NULL_HANDLE; + VkResult res = allocator->GetVulkanFunctions().vkCreateImage( + hDev, pImageCreateInfo, allocator->GetAllocationCallbacks(), &hImage); + if(res == VK_SUCCESS) + { + VkMemoryRequirements memReq = {}; + allocator->GetVulkanFunctions().vkGetImageMemoryRequirements( + hDev, hImage, &memReq); + + res = vmaFindMemoryTypeIndex( + allocator, + memReq.memoryTypeBits, + pAllocationCreateInfo, + pMemoryTypeIndex); + + allocator->GetVulkanFunctions().vkDestroyImage( + hDev, hImage, allocator->GetAllocationCallbacks()); + } + return res; +} + +VMA_CALL_PRE VkResult VMA_CALL_POST vmaCreatePool( + VmaAllocator allocator, + const VmaPoolCreateInfo* pCreateInfo, + VmaPool* pPool) +{ + VMA_ASSERT(allocator && pCreateInfo && pPool); + + VMA_DEBUG_LOG("vmaCreatePool"); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + + VkResult res = allocator->CreatePool(pCreateInfo, pPool); + +#if VMA_RECORDING_ENABLED + if(allocator->GetRecorder() != VMA_NULL) + { + allocator->GetRecorder()->RecordCreatePool(allocator->GetCurrentFrameIndex(), *pCreateInfo, *pPool); + } +#endif + + return res; +} + +VMA_CALL_PRE void VMA_CALL_POST vmaDestroyPool( + VmaAllocator allocator, + VmaPool pool) +{ + VMA_ASSERT(allocator); + + if(pool == VK_NULL_HANDLE) + { + return; + } + + VMA_DEBUG_LOG("vmaDestroyPool"); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + +#if VMA_RECORDING_ENABLED + if(allocator->GetRecorder() != VMA_NULL) + { + allocator->GetRecorder()->RecordDestroyPool(allocator->GetCurrentFrameIndex(), pool); + } +#endif + + allocator->DestroyPool(pool); +} + +VMA_CALL_PRE void VMA_CALL_POST vmaGetPoolStats( + VmaAllocator allocator, + VmaPool pool, + VmaPoolStats* pPoolStats) +{ + VMA_ASSERT(allocator && pool && pPoolStats); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + + allocator->GetPoolStats(pool, pPoolStats); +} + +VMA_CALL_PRE void VMA_CALL_POST vmaMakePoolAllocationsLost( + VmaAllocator allocator, + VmaPool pool, + size_t* pLostAllocationCount) +{ + VMA_ASSERT(allocator && pool); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + +#if VMA_RECORDING_ENABLED + if(allocator->GetRecorder() != VMA_NULL) + { + allocator->GetRecorder()->RecordMakePoolAllocationsLost(allocator->GetCurrentFrameIndex(), pool); + } +#endif + + allocator->MakePoolAllocationsLost(pool, pLostAllocationCount); +} + +VMA_CALL_PRE VkResult VMA_CALL_POST vmaCheckPoolCorruption(VmaAllocator allocator, VmaPool pool) +{ + VMA_ASSERT(allocator && pool); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + + VMA_DEBUG_LOG("vmaCheckPoolCorruption"); + + return allocator->CheckPoolCorruption(pool); +} + +VMA_CALL_PRE void VMA_CALL_POST vmaGetPoolName( + VmaAllocator allocator, + VmaPool pool, + const char** ppName) +{ + VMA_ASSERT(allocator && pool); + + VMA_DEBUG_LOG("vmaGetPoolName"); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + + *ppName = pool->GetName(); +} + +VMA_CALL_PRE void VMA_CALL_POST vmaSetPoolName( + VmaAllocator allocator, + VmaPool pool, + const char* pName) +{ + VMA_ASSERT(allocator && pool); + + VMA_DEBUG_LOG("vmaSetPoolName"); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + + pool->SetName(pName); + +#if VMA_RECORDING_ENABLED + if(allocator->GetRecorder() != VMA_NULL) + { + allocator->GetRecorder()->RecordSetPoolName(allocator->GetCurrentFrameIndex(), pool, pName); + } +#endif +} + +VMA_CALL_PRE VkResult VMA_CALL_POST vmaAllocateMemory( + VmaAllocator allocator, + const VkMemoryRequirements* pVkMemoryRequirements, + const VmaAllocationCreateInfo* pCreateInfo, + VmaAllocation* pAllocation, + VmaAllocationInfo* pAllocationInfo) +{ + VMA_ASSERT(allocator && pVkMemoryRequirements && pCreateInfo && pAllocation); + + VMA_DEBUG_LOG("vmaAllocateMemory"); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + + VkResult result = allocator->AllocateMemory( + *pVkMemoryRequirements, + false, // requiresDedicatedAllocation + false, // prefersDedicatedAllocation + VK_NULL_HANDLE, // dedicatedBuffer + VK_NULL_HANDLE, // dedicatedImage + *pCreateInfo, + VMA_SUBALLOCATION_TYPE_UNKNOWN, + 1, // allocationCount + pAllocation); + +#if VMA_RECORDING_ENABLED + if(allocator->GetRecorder() != VMA_NULL) + { + allocator->GetRecorder()->RecordAllocateMemory( + allocator->GetCurrentFrameIndex(), + *pVkMemoryRequirements, + *pCreateInfo, + *pAllocation); + } +#endif + + if(pAllocationInfo != VMA_NULL && result == VK_SUCCESS) + { + allocator->GetAllocationInfo(*pAllocation, pAllocationInfo); + } + + return result; +} + +VMA_CALL_PRE VkResult VMA_CALL_POST vmaAllocateMemoryPages( + VmaAllocator allocator, + const VkMemoryRequirements* pVkMemoryRequirements, + const VmaAllocationCreateInfo* pCreateInfo, + size_t allocationCount, + VmaAllocation* pAllocations, + VmaAllocationInfo* pAllocationInfo) +{ + if(allocationCount == 0) + { + return VK_SUCCESS; + } + + VMA_ASSERT(allocator && pVkMemoryRequirements && pCreateInfo && pAllocations); + + VMA_DEBUG_LOG("vmaAllocateMemoryPages"); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + + VkResult result = allocator->AllocateMemory( + *pVkMemoryRequirements, + false, // requiresDedicatedAllocation + false, // prefersDedicatedAllocation + VK_NULL_HANDLE, // dedicatedBuffer + VK_NULL_HANDLE, // dedicatedImage + *pCreateInfo, + VMA_SUBALLOCATION_TYPE_UNKNOWN, + allocationCount, + pAllocations); + +#if VMA_RECORDING_ENABLED + if(allocator->GetRecorder() != VMA_NULL) + { + allocator->GetRecorder()->RecordAllocateMemoryPages( + allocator->GetCurrentFrameIndex(), + *pVkMemoryRequirements, + *pCreateInfo, + (uint64_t)allocationCount, + pAllocations); + } +#endif + + if(pAllocationInfo != VMA_NULL && result == VK_SUCCESS) + { + for(size_t i = 0; i < allocationCount; ++i) + { + allocator->GetAllocationInfo(pAllocations[i], pAllocationInfo + i); + } + } + + return result; +} + +VMA_CALL_PRE VkResult VMA_CALL_POST vmaAllocateMemoryForBuffer( + VmaAllocator allocator, + VkBuffer buffer, + const VmaAllocationCreateInfo* pCreateInfo, + VmaAllocation* pAllocation, + VmaAllocationInfo* pAllocationInfo) +{ + VMA_ASSERT(allocator && buffer != VK_NULL_HANDLE && pCreateInfo && pAllocation); + + VMA_DEBUG_LOG("vmaAllocateMemoryForBuffer"); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + + VkMemoryRequirements vkMemReq = {}; + bool requiresDedicatedAllocation = false; + bool prefersDedicatedAllocation = false; + allocator->GetBufferMemoryRequirements(buffer, vkMemReq, + requiresDedicatedAllocation, + prefersDedicatedAllocation); + + VkResult result = allocator->AllocateMemory( + vkMemReq, + requiresDedicatedAllocation, + prefersDedicatedAllocation, + buffer, // dedicatedBuffer + VK_NULL_HANDLE, // dedicatedImage + *pCreateInfo, + VMA_SUBALLOCATION_TYPE_BUFFER, + 1, // allocationCount + pAllocation); + +#if VMA_RECORDING_ENABLED + if(allocator->GetRecorder() != VMA_NULL) + { + allocator->GetRecorder()->RecordAllocateMemoryForBuffer( + allocator->GetCurrentFrameIndex(), + vkMemReq, + requiresDedicatedAllocation, + prefersDedicatedAllocation, + *pCreateInfo, + *pAllocation); + } +#endif + + if(pAllocationInfo && result == VK_SUCCESS) + { + allocator->GetAllocationInfo(*pAllocation, pAllocationInfo); + } + + return result; +} + +VMA_CALL_PRE VkResult VMA_CALL_POST vmaAllocateMemoryForImage( + VmaAllocator allocator, + VkImage image, + const VmaAllocationCreateInfo* pCreateInfo, + VmaAllocation* pAllocation, + VmaAllocationInfo* pAllocationInfo) +{ + VMA_ASSERT(allocator && image != VK_NULL_HANDLE && pCreateInfo && pAllocation); + + VMA_DEBUG_LOG("vmaAllocateMemoryForImage"); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + + VkMemoryRequirements vkMemReq = {}; + bool requiresDedicatedAllocation = false; + bool prefersDedicatedAllocation = false; + allocator->GetImageMemoryRequirements(image, vkMemReq, + requiresDedicatedAllocation, prefersDedicatedAllocation); + + VkResult result = allocator->AllocateMemory( + vkMemReq, + requiresDedicatedAllocation, + prefersDedicatedAllocation, + VK_NULL_HANDLE, // dedicatedBuffer + image, // dedicatedImage + *pCreateInfo, + VMA_SUBALLOCATION_TYPE_IMAGE_UNKNOWN, + 1, // allocationCount + pAllocation); + +#if VMA_RECORDING_ENABLED + if(allocator->GetRecorder() != VMA_NULL) + { + allocator->GetRecorder()->RecordAllocateMemoryForImage( + allocator->GetCurrentFrameIndex(), + vkMemReq, + requiresDedicatedAllocation, + prefersDedicatedAllocation, + *pCreateInfo, + *pAllocation); + } +#endif + + if(pAllocationInfo && result == VK_SUCCESS) + { + allocator->GetAllocationInfo(*pAllocation, pAllocationInfo); + } + + return result; +} + +VMA_CALL_PRE void VMA_CALL_POST vmaFreeMemory( + VmaAllocator allocator, + VmaAllocation allocation) +{ + VMA_ASSERT(allocator); + + if(allocation == VK_NULL_HANDLE) + { + return; + } + + VMA_DEBUG_LOG("vmaFreeMemory"); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + +#if VMA_RECORDING_ENABLED + if(allocator->GetRecorder() != VMA_NULL) + { + allocator->GetRecorder()->RecordFreeMemory( + allocator->GetCurrentFrameIndex(), + allocation); + } +#endif + + allocator->FreeMemory( + 1, // allocationCount + &allocation); +} + +VMA_CALL_PRE void VMA_CALL_POST vmaFreeMemoryPages( + VmaAllocator allocator, + size_t allocationCount, + VmaAllocation* pAllocations) +{ + if(allocationCount == 0) + { + return; + } + + VMA_ASSERT(allocator); + + VMA_DEBUG_LOG("vmaFreeMemoryPages"); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + +#if VMA_RECORDING_ENABLED + if(allocator->GetRecorder() != VMA_NULL) + { + allocator->GetRecorder()->RecordFreeMemoryPages( + allocator->GetCurrentFrameIndex(), + (uint64_t)allocationCount, + pAllocations); + } +#endif + + allocator->FreeMemory(allocationCount, pAllocations); +} + +VMA_CALL_PRE VkResult VMA_CALL_POST vmaResizeAllocation( + VmaAllocator allocator, + VmaAllocation allocation, + VkDeviceSize newSize) +{ + VMA_ASSERT(allocator && allocation); + + VMA_DEBUG_LOG("vmaResizeAllocation"); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + + return allocator->ResizeAllocation(allocation, newSize); +} + +VMA_CALL_PRE void VMA_CALL_POST vmaGetAllocationInfo( + VmaAllocator allocator, + VmaAllocation allocation, + VmaAllocationInfo* pAllocationInfo) +{ + VMA_ASSERT(allocator && allocation && pAllocationInfo); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + +#if VMA_RECORDING_ENABLED + if(allocator->GetRecorder() != VMA_NULL) + { + allocator->GetRecorder()->RecordGetAllocationInfo( + allocator->GetCurrentFrameIndex(), + allocation); + } +#endif + + allocator->GetAllocationInfo(allocation, pAllocationInfo); +} + +VMA_CALL_PRE VkBool32 VMA_CALL_POST vmaTouchAllocation( + VmaAllocator allocator, + VmaAllocation allocation) +{ + VMA_ASSERT(allocator && allocation); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + +#if VMA_RECORDING_ENABLED + if(allocator->GetRecorder() != VMA_NULL) + { + allocator->GetRecorder()->RecordTouchAllocation( + allocator->GetCurrentFrameIndex(), + allocation); + } +#endif + + return allocator->TouchAllocation(allocation); +} + +VMA_CALL_PRE void VMA_CALL_POST vmaSetAllocationUserData( + VmaAllocator allocator, + VmaAllocation allocation, + void* pUserData) +{ + VMA_ASSERT(allocator && allocation); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + + allocation->SetUserData(allocator, pUserData); + +#if VMA_RECORDING_ENABLED + if(allocator->GetRecorder() != VMA_NULL) + { + allocator->GetRecorder()->RecordSetAllocationUserData( + allocator->GetCurrentFrameIndex(), + allocation, + pUserData); + } +#endif +} + +VMA_CALL_PRE void VMA_CALL_POST vmaCreateLostAllocation( + VmaAllocator allocator, + VmaAllocation* pAllocation) +{ + VMA_ASSERT(allocator && pAllocation); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK; + + allocator->CreateLostAllocation(pAllocation); + +#if VMA_RECORDING_ENABLED + if(allocator->GetRecorder() != VMA_NULL) + { + allocator->GetRecorder()->RecordCreateLostAllocation( + allocator->GetCurrentFrameIndex(), + *pAllocation); + } +#endif +} + +VMA_CALL_PRE VkResult VMA_CALL_POST vmaMapMemory( + VmaAllocator allocator, + VmaAllocation allocation, + void** ppData) +{ + VMA_ASSERT(allocator && allocation && ppData); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + + VkResult res = allocator->Map(allocation, ppData); + +#if VMA_RECORDING_ENABLED + if(allocator->GetRecorder() != VMA_NULL) + { + allocator->GetRecorder()->RecordMapMemory( + allocator->GetCurrentFrameIndex(), + allocation); + } +#endif + + return res; +} + +VMA_CALL_PRE void VMA_CALL_POST vmaUnmapMemory( + VmaAllocator allocator, + VmaAllocation allocation) +{ + VMA_ASSERT(allocator && allocation); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + +#if VMA_RECORDING_ENABLED + if(allocator->GetRecorder() != VMA_NULL) + { + allocator->GetRecorder()->RecordUnmapMemory( + allocator->GetCurrentFrameIndex(), + allocation); + } +#endif + + allocator->Unmap(allocation); +} + +VMA_CALL_PRE void VMA_CALL_POST vmaFlushAllocation(VmaAllocator allocator, VmaAllocation allocation, VkDeviceSize offset, VkDeviceSize size) +{ + VMA_ASSERT(allocator && allocation); + + VMA_DEBUG_LOG("vmaFlushAllocation"); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + + allocator->FlushOrInvalidateAllocation(allocation, offset, size, VMA_CACHE_FLUSH); + +#if VMA_RECORDING_ENABLED + if(allocator->GetRecorder() != VMA_NULL) + { + allocator->GetRecorder()->RecordFlushAllocation( + allocator->GetCurrentFrameIndex(), + allocation, offset, size); + } +#endif +} + +VMA_CALL_PRE void VMA_CALL_POST vmaInvalidateAllocation(VmaAllocator allocator, VmaAllocation allocation, VkDeviceSize offset, VkDeviceSize size) +{ + VMA_ASSERT(allocator && allocation); + + VMA_DEBUG_LOG("vmaInvalidateAllocation"); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + + allocator->FlushOrInvalidateAllocation(allocation, offset, size, VMA_CACHE_INVALIDATE); + +#if VMA_RECORDING_ENABLED + if(allocator->GetRecorder() != VMA_NULL) + { + allocator->GetRecorder()->RecordInvalidateAllocation( + allocator->GetCurrentFrameIndex(), + allocation, offset, size); + } +#endif +} + +VMA_CALL_PRE VkResult VMA_CALL_POST vmaCheckCorruption(VmaAllocator allocator, uint32_t memoryTypeBits) +{ + VMA_ASSERT(allocator); + + VMA_DEBUG_LOG("vmaCheckCorruption"); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + + return allocator->CheckCorruption(memoryTypeBits); +} + +VMA_CALL_PRE VkResult VMA_CALL_POST vmaDefragment( + VmaAllocator allocator, + VmaAllocation* pAllocations, + size_t allocationCount, + VkBool32* pAllocationsChanged, + const VmaDefragmentationInfo *pDefragmentationInfo, + VmaDefragmentationStats* pDefragmentationStats) +{ + // Deprecated interface, reimplemented using new one. + + VmaDefragmentationInfo2 info2 = {}; + info2.allocationCount = (uint32_t)allocationCount; + info2.pAllocations = pAllocations; + info2.pAllocationsChanged = pAllocationsChanged; + if(pDefragmentationInfo != VMA_NULL) + { + info2.maxCpuAllocationsToMove = pDefragmentationInfo->maxAllocationsToMove; + info2.maxCpuBytesToMove = pDefragmentationInfo->maxBytesToMove; + } + else + { + info2.maxCpuAllocationsToMove = UINT32_MAX; + info2.maxCpuBytesToMove = VK_WHOLE_SIZE; + } + // info2.flags, maxGpuAllocationsToMove, maxGpuBytesToMove, commandBuffer deliberately left zero. + + VmaDefragmentationContext ctx; + VkResult res = vmaDefragmentationBegin(allocator, &info2, pDefragmentationStats, &ctx); + if(res == VK_NOT_READY) + { + res = vmaDefragmentationEnd( allocator, ctx); + } + return res; +} + +VMA_CALL_PRE VkResult VMA_CALL_POST vmaDefragmentationBegin( + VmaAllocator allocator, + const VmaDefragmentationInfo2* pInfo, + VmaDefragmentationStats* pStats, + VmaDefragmentationContext *pContext) +{ + VMA_ASSERT(allocator && pInfo && pContext); + + // Degenerate case: Nothing to defragment. + if(pInfo->allocationCount == 0 && pInfo->poolCount == 0) + { + return VK_SUCCESS; + } + + VMA_ASSERT(pInfo->allocationCount == 0 || pInfo->pAllocations != VMA_NULL); + VMA_ASSERT(pInfo->poolCount == 0 || pInfo->pPools != VMA_NULL); + VMA_HEAVY_ASSERT(VmaValidatePointerArray(pInfo->allocationCount, pInfo->pAllocations)); + VMA_HEAVY_ASSERT(VmaValidatePointerArray(pInfo->poolCount, pInfo->pPools)); + + VMA_DEBUG_LOG("vmaDefragmentationBegin"); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + + VkResult res = allocator->DefragmentationBegin(*pInfo, pStats, pContext); + +#if VMA_RECORDING_ENABLED + if(allocator->GetRecorder() != VMA_NULL) + { + allocator->GetRecorder()->RecordDefragmentationBegin( + allocator->GetCurrentFrameIndex(), *pInfo, *pContext); + } +#endif + + return res; +} + +VMA_CALL_PRE VkResult VMA_CALL_POST vmaDefragmentationEnd( + VmaAllocator allocator, + VmaDefragmentationContext context) +{ + VMA_ASSERT(allocator); + + VMA_DEBUG_LOG("vmaDefragmentationEnd"); + + if(context != VK_NULL_HANDLE) + { + VMA_DEBUG_GLOBAL_MUTEX_LOCK + +#if VMA_RECORDING_ENABLED + if(allocator->GetRecorder() != VMA_NULL) + { + allocator->GetRecorder()->RecordDefragmentationEnd( + allocator->GetCurrentFrameIndex(), context); + } +#endif + + return allocator->DefragmentationEnd(context); + } + else + { + return VK_SUCCESS; + } +} + +VMA_CALL_PRE VkResult VMA_CALL_POST vmaBeginDefragmentationPass( + VmaAllocator allocator, + VmaDefragmentationContext context, + VmaDefragmentationPassInfo* pInfo + ) +{ + VMA_ASSERT(allocator); + VMA_ASSERT(pInfo); + VMA_HEAVY_ASSERT(VmaValidatePointerArray(pInfo->moveCount, pInfo->pMoves)); + + VMA_DEBUG_LOG("vmaBeginDefragmentationPass"); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + + if(context == VK_NULL_HANDLE) + { + pInfo->moveCount = 0; + return VK_SUCCESS; + } + + return allocator->DefragmentationPassBegin(pInfo, context); +} +VMA_CALL_PRE VkResult VMA_CALL_POST vmaEndDefragmentationPass( + VmaAllocator allocator, + VmaDefragmentationContext context) +{ + VMA_ASSERT(allocator); + + VMA_DEBUG_LOG("vmaEndDefragmentationPass"); + VMA_DEBUG_GLOBAL_MUTEX_LOCK + + if(context == VK_NULL_HANDLE) + return VK_SUCCESS; + + return allocator->DefragmentationPassEnd(context); +} + +VMA_CALL_PRE VkResult VMA_CALL_POST vmaBindBufferMemory( + VmaAllocator allocator, + VmaAllocation allocation, + VkBuffer buffer) +{ + VMA_ASSERT(allocator && allocation && buffer); + + VMA_DEBUG_LOG("vmaBindBufferMemory"); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + + return allocator->BindBufferMemory(allocation, 0, buffer, VMA_NULL); +} + +VMA_CALL_PRE VkResult VMA_CALL_POST vmaBindBufferMemory2( + VmaAllocator allocator, + VmaAllocation allocation, + VkDeviceSize allocationLocalOffset, + VkBuffer buffer, + const void* pNext) +{ + VMA_ASSERT(allocator && allocation && buffer); + + VMA_DEBUG_LOG("vmaBindBufferMemory2"); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + + return allocator->BindBufferMemory(allocation, allocationLocalOffset, buffer, pNext); +} + +VMA_CALL_PRE VkResult VMA_CALL_POST vmaBindImageMemory( + VmaAllocator allocator, + VmaAllocation allocation, + VkImage image) +{ + VMA_ASSERT(allocator && allocation && image); + + VMA_DEBUG_LOG("vmaBindImageMemory"); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + + return allocator->BindImageMemory(allocation, 0, image, VMA_NULL); +} + +VMA_CALL_PRE VkResult VMA_CALL_POST vmaBindImageMemory2( + VmaAllocator allocator, + VmaAllocation allocation, + VkDeviceSize allocationLocalOffset, + VkImage image, + const void* pNext) +{ + VMA_ASSERT(allocator && allocation && image); + + VMA_DEBUG_LOG("vmaBindImageMemory2"); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + + return allocator->BindImageMemory(allocation, allocationLocalOffset, image, pNext); +} + +VMA_CALL_PRE VkResult VMA_CALL_POST vmaCreateBuffer( + VmaAllocator allocator, + const VkBufferCreateInfo* pBufferCreateInfo, + const VmaAllocationCreateInfo* pAllocationCreateInfo, + VkBuffer* pBuffer, + VmaAllocation* pAllocation, + VmaAllocationInfo* pAllocationInfo) +{ + VMA_ASSERT(allocator && pBufferCreateInfo && pAllocationCreateInfo && pBuffer && pAllocation); + + if(pBufferCreateInfo->size == 0) + { + return VK_ERROR_VALIDATION_FAILED_EXT; + } + + VMA_DEBUG_LOG("vmaCreateBuffer"); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + + *pBuffer = VK_NULL_HANDLE; + *pAllocation = VK_NULL_HANDLE; + + // 1. Create VkBuffer. + VkResult res = (*allocator->GetVulkanFunctions().vkCreateBuffer)( + allocator->m_hDevice, + pBufferCreateInfo, + allocator->GetAllocationCallbacks(), + pBuffer); + if(res >= 0) + { + // 2. vkGetBufferMemoryRequirements. + VkMemoryRequirements vkMemReq = {}; + bool requiresDedicatedAllocation = false; + bool prefersDedicatedAllocation = false; + allocator->GetBufferMemoryRequirements(*pBuffer, vkMemReq, + requiresDedicatedAllocation, prefersDedicatedAllocation); + + // 3. Allocate memory using allocator. + res = allocator->AllocateMemory( + vkMemReq, + requiresDedicatedAllocation, + prefersDedicatedAllocation, + *pBuffer, // dedicatedBuffer + VK_NULL_HANDLE, // dedicatedImage + *pAllocationCreateInfo, + VMA_SUBALLOCATION_TYPE_BUFFER, + 1, // allocationCount + pAllocation); + +#if VMA_RECORDING_ENABLED + if(allocator->GetRecorder() != VMA_NULL) + { + allocator->GetRecorder()->RecordCreateBuffer( + allocator->GetCurrentFrameIndex(), + *pBufferCreateInfo, + *pAllocationCreateInfo, + *pAllocation); + } +#endif + + if(res >= 0) + { + // 3. Bind buffer with memory. + if((pAllocationCreateInfo->flags & VMA_ALLOCATION_CREATE_DONT_BIND_BIT) == 0) + { + res = allocator->BindBufferMemory(*pAllocation, 0, *pBuffer, VMA_NULL); + } + if(res >= 0) + { + // All steps succeeded. + #if VMA_STATS_STRING_ENABLED + (*pAllocation)->InitBufferImageUsage(pBufferCreateInfo->usage); + #endif + if(pAllocationInfo != VMA_NULL) + { + allocator->GetAllocationInfo(*pAllocation, pAllocationInfo); + } + + return VK_SUCCESS; + } + allocator->FreeMemory( + 1, // allocationCount + pAllocation); + *pAllocation = VK_NULL_HANDLE; + (*allocator->GetVulkanFunctions().vkDestroyBuffer)(allocator->m_hDevice, *pBuffer, allocator->GetAllocationCallbacks()); + *pBuffer = VK_NULL_HANDLE; + return res; + } + (*allocator->GetVulkanFunctions().vkDestroyBuffer)(allocator->m_hDevice, *pBuffer, allocator->GetAllocationCallbacks()); + *pBuffer = VK_NULL_HANDLE; + return res; + } + return res; +} + +VMA_CALL_PRE void VMA_CALL_POST vmaDestroyBuffer( + VmaAllocator allocator, + VkBuffer buffer, + VmaAllocation allocation) +{ + VMA_ASSERT(allocator); + + if(buffer == VK_NULL_HANDLE && allocation == VK_NULL_HANDLE) + { + return; + } + + VMA_DEBUG_LOG("vmaDestroyBuffer"); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + +#if VMA_RECORDING_ENABLED + if(allocator->GetRecorder() != VMA_NULL) + { + allocator->GetRecorder()->RecordDestroyBuffer( + allocator->GetCurrentFrameIndex(), + allocation); + } +#endif + + if(buffer != VK_NULL_HANDLE) + { + (*allocator->GetVulkanFunctions().vkDestroyBuffer)(allocator->m_hDevice, buffer, allocator->GetAllocationCallbacks()); + } + + if(allocation != VK_NULL_HANDLE) + { + allocator->FreeMemory( + 1, // allocationCount + &allocation); + } +} + +VMA_CALL_PRE VkResult VMA_CALL_POST vmaCreateImage( + VmaAllocator allocator, + const VkImageCreateInfo* pImageCreateInfo, + const VmaAllocationCreateInfo* pAllocationCreateInfo, + VkImage* pImage, + VmaAllocation* pAllocation, + VmaAllocationInfo* pAllocationInfo) +{ + VMA_ASSERT(allocator && pImageCreateInfo && pAllocationCreateInfo && pImage && pAllocation); + + if(pImageCreateInfo->extent.width == 0 || + pImageCreateInfo->extent.height == 0 || + pImageCreateInfo->extent.depth == 0 || + pImageCreateInfo->mipLevels == 0 || + pImageCreateInfo->arrayLayers == 0) + { + return VK_ERROR_VALIDATION_FAILED_EXT; + } + + VMA_DEBUG_LOG("vmaCreateImage"); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + + *pImage = VK_NULL_HANDLE; + *pAllocation = VK_NULL_HANDLE; + + // 1. Create VkImage. + VkResult res = (*allocator->GetVulkanFunctions().vkCreateImage)( + allocator->m_hDevice, + pImageCreateInfo, + allocator->GetAllocationCallbacks(), + pImage); + if(res >= 0) + { + VmaSuballocationType suballocType = pImageCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL ? + VMA_SUBALLOCATION_TYPE_IMAGE_OPTIMAL : + VMA_SUBALLOCATION_TYPE_IMAGE_LINEAR; + + // 2. Allocate memory using allocator. + VkMemoryRequirements vkMemReq = {}; + bool requiresDedicatedAllocation = false; + bool prefersDedicatedAllocation = false; + allocator->GetImageMemoryRequirements(*pImage, vkMemReq, + requiresDedicatedAllocation, prefersDedicatedAllocation); + + res = allocator->AllocateMemory( + vkMemReq, + requiresDedicatedAllocation, + prefersDedicatedAllocation, + VK_NULL_HANDLE, // dedicatedBuffer + *pImage, // dedicatedImage + *pAllocationCreateInfo, + suballocType, + 1, // allocationCount + pAllocation); + +#if VMA_RECORDING_ENABLED + if(allocator->GetRecorder() != VMA_NULL) + { + allocator->GetRecorder()->RecordCreateImage( + allocator->GetCurrentFrameIndex(), + *pImageCreateInfo, + *pAllocationCreateInfo, + *pAllocation); + } +#endif + + if(res >= 0) + { + // 3. Bind image with memory. + if((pAllocationCreateInfo->flags & VMA_ALLOCATION_CREATE_DONT_BIND_BIT) == 0) + { + res = allocator->BindImageMemory(*pAllocation, 0, *pImage, VMA_NULL); + } + if(res >= 0) + { + // All steps succeeded. + #if VMA_STATS_STRING_ENABLED + (*pAllocation)->InitBufferImageUsage(pImageCreateInfo->usage); + #endif + if(pAllocationInfo != VMA_NULL) + { + allocator->GetAllocationInfo(*pAllocation, pAllocationInfo); + } + + return VK_SUCCESS; + } + allocator->FreeMemory( + 1, // allocationCount + pAllocation); + *pAllocation = VK_NULL_HANDLE; + (*allocator->GetVulkanFunctions().vkDestroyImage)(allocator->m_hDevice, *pImage, allocator->GetAllocationCallbacks()); + *pImage = VK_NULL_HANDLE; + return res; + } + (*allocator->GetVulkanFunctions().vkDestroyImage)(allocator->m_hDevice, *pImage, allocator->GetAllocationCallbacks()); + *pImage = VK_NULL_HANDLE; + return res; + } + return res; +} + +VMA_CALL_PRE void VMA_CALL_POST vmaDestroyImage( + VmaAllocator allocator, + VkImage image, + VmaAllocation allocation) +{ + VMA_ASSERT(allocator); + + if(image == VK_NULL_HANDLE && allocation == VK_NULL_HANDLE) + { + return; + } + + VMA_DEBUG_LOG("vmaDestroyImage"); + + VMA_DEBUG_GLOBAL_MUTEX_LOCK + +#if VMA_RECORDING_ENABLED + if(allocator->GetRecorder() != VMA_NULL) + { + allocator->GetRecorder()->RecordDestroyImage( + allocator->GetCurrentFrameIndex(), + allocation); + } +#endif + + if(image != VK_NULL_HANDLE) + { + (*allocator->GetVulkanFunctions().vkDestroyImage)(allocator->m_hDevice, image, allocator->GetAllocationCallbacks()); + } + if(allocation != VK_NULL_HANDLE) + { + allocator->FreeMemory( + 1, // allocationCount + &allocation); + } +} + +#endif // #ifdef VMA_IMPLEMENTATION diff --git a/thirdparty/include/vma/vk_mem_alloc.natvis b/thirdparty/include/vma/vk_mem_alloc.natvis new file mode 100644 index 000000000..85c75335f --- /dev/null +++ b/thirdparty/include/vma/vk_mem_alloc.natvis @@ -0,0 +1,40 @@ + + + + {{ Count={m_Count} }} + + m_Count + + m_Count + m_pFront + pNext + Value + + + + + + {{ Count={m_RawList.m_Count} }} + + m_RawList.m_Count + + m_RawList.m_Count + m_RawList.m_pFront + pNext + Value + + + + + + {{ Count={m_Count} }} + + m_Count + m_Capacity + + m_Count + m_pArray + + + + \ No newline at end of file From 874130efd44cc0933817795e64a403ed83f48127 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 26 Mar 2020 21:18:35 +0100 Subject: [PATCH 135/316] Implement Texture and TextureSampler --- examples/VulkanTest/main.cpp | 131 +------- include/Nazara/Renderer.hpp | 1 + include/Nazara/Renderer/RenderDevice.hpp | 4 + include/Nazara/Renderer/Texture.hpp | 124 ++------ include/Nazara/Renderer/Texture.inl | 12 + include/Nazara/Renderer/TextureSampler.hpp | 42 +++ include/Nazara/Renderer/TextureSampler.inl | 12 + include/Nazara/Utility/Enums.hpp | 19 +- include/Nazara/VulkanRenderer.hpp | 2 + include/Nazara/VulkanRenderer/Utils.hpp | 3 + include/Nazara/VulkanRenderer/Utils.inl | 37 +++ .../Nazara/VulkanRenderer/VulkanDevice.hpp | 2 + .../Nazara/VulkanRenderer/VulkanTexture.hpp | 51 ++++ .../Nazara/VulkanRenderer/VulkanTexture.inl | 21 ++ .../VulkanRenderer/VulkanTextureSampler.hpp | 36 +++ .../VulkanRenderer/VulkanTextureSampler.inl | 16 + src/Nazara/Renderer/Texture.cpp | 11 + src/Nazara/Renderer/TextureSampler.cpp | 11 + src/Nazara/VulkanRenderer/VulkanDevice.cpp | 12 + src/Nazara/VulkanRenderer/VulkanTexture.cpp | 287 ++++++++++++++++++ .../VulkanRenderer/VulkanTextureSampler.cpp | 31 ++ 21 files changed, 628 insertions(+), 237 deletions(-) create mode 100644 include/Nazara/Renderer/Texture.inl create mode 100644 include/Nazara/Renderer/TextureSampler.hpp create mode 100644 include/Nazara/Renderer/TextureSampler.inl create mode 100644 include/Nazara/VulkanRenderer/VulkanTexture.hpp create mode 100644 include/Nazara/VulkanRenderer/VulkanTexture.inl create mode 100644 include/Nazara/VulkanRenderer/VulkanTextureSampler.hpp create mode 100644 include/Nazara/VulkanRenderer/VulkanTextureSampler.inl create mode 100644 src/Nazara/Renderer/Texture.cpp create mode 100644 src/Nazara/Renderer/TextureSampler.cpp create mode 100644 src/Nazara/VulkanRenderer/VulkanTexture.cpp create mode 100644 src/Nazara/VulkanRenderer/VulkanTextureSampler.cpp diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index 864c9f5ed..754911922 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -135,132 +135,21 @@ int main() return __LINE__; } - VkImageCreateInfo imageInfo = {}; - imageInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; - imageInfo.imageType = VK_IMAGE_TYPE_2D; - imageInfo.extent.width = static_cast(drfreakImage->GetWidth()); - imageInfo.extent.height = static_cast(drfreakImage->GetHeight()); - imageInfo.extent.depth = 1; - imageInfo.mipLevels = 1; - imageInfo.arrayLayers = 1; - imageInfo.samples = VK_SAMPLE_COUNT_1_BIT; - imageInfo.format = VK_FORMAT_R8G8B8A8_SRGB; - imageInfo.tiling = VK_IMAGE_TILING_OPTIMAL; - imageInfo.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; - imageInfo.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT; - imageInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE; + Nz::TextureInfo texParams; + texParams.pixelFormat = drfreakImage->GetFormat(); + texParams.type = drfreakImage->GetType(); + texParams.width = drfreakImage->GetWidth(); + texParams.height = drfreakImage->GetHeight(); + texParams.depth = drfreakImage->GetDepth(); - Nz::Vk::Image vkImage; - if (!vkImage.Create(vulkanDevice, imageInfo)) + std::unique_ptr texture = device->InstantiateTexture(texParams); + if (!texture->Update(drfreakImage->GetConstPixels())) { - NazaraError("Failed to create vulkan image"); + NazaraError("Failed to update texture"); return __LINE__; } - VkMemoryRequirements imageMemRequirement = vkImage.GetMemoryRequirements(); - - Nz::Vk::DeviceMemory imageMemory; - if (!imageMemory.Create(vulkanDevice, imageMemRequirement.size, imageMemRequirement.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)) - { - NazaraError("Failed to create vulkan image memory"); - return __LINE__; - } - - vkImage.BindImageMemory(imageMemory); - - // Update texture - { - Nz::Vk::Buffer stagingImageBuffer; - if (!stagingImageBuffer.Create(vulkanDevice, 0, drfreakImage->GetMemoryUsage(), VK_BUFFER_USAGE_TRANSFER_SRC_BIT)) - { - NazaraError("Failed to create staging buffer"); - return __LINE__; - } - - VkMemoryPropertyFlags memoryProperties = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; - - Nz::Vk::DeviceMemory stagingImageMemory; - - VkMemoryRequirements memRequirement = stagingImageBuffer.GetMemoryRequirements(); - if (!stagingImageMemory.Create(vulkanDevice, memRequirement.size, memRequirement.memoryTypeBits, memoryProperties)) - { - NazaraError("Failed to allocate vertex buffer memory"); - return __LINE__; - } - - if (!stagingImageBuffer.BindBufferMemory(stagingImageMemory)) - { - NazaraError("Failed to bind vertex buffer to its memory"); - return __LINE__; - } - - if (!stagingImageMemory.Map(0, memRequirement.size)) - return __LINE__; - - std::memcpy(stagingImageMemory.GetMappedPointer(), drfreakImage->GetPixels(), drfreakImage->GetMemoryUsage()); - - stagingImageMemory.FlushMemory(); - stagingImageMemory.Unmap(); - - Nz::Vk::CommandBuffer copyCommand = cmdPool.AllocateCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY); - copyCommand.Begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT); - copyCommand.SetImageLayout(vkImage, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); - copyCommand.CopyBufferToImage(stagingImageBuffer, vkImage, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, drfreakImage->GetWidth(), drfreakImage->GetHeight()); - copyCommand.SetImageLayout(vkImage, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); - if (!copyCommand.End()) - return __LINE__; - - if (!graphicsQueue.Submit(copyCommand)) - return __LINE__; - - graphicsQueue.WaitIdle(); - } - - // Create image view - - VkImageViewCreateInfo imageViewInfo = {}; - imageViewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; - imageViewInfo.components = { - VK_COMPONENT_SWIZZLE_R, - VK_COMPONENT_SWIZZLE_G, - VK_COMPONENT_SWIZZLE_B, - VK_COMPONENT_SWIZZLE_A - }; - imageViewInfo.format = VK_FORMAT_R8G8B8A8_SRGB; - imageViewInfo.image = vkImage; - imageViewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; - imageViewInfo.subresourceRange = { - VK_IMAGE_ASPECT_COLOR_BIT, - 0, - 1, - 0, - 1 - }; - - Nz::Vk::ImageView imageView; - if (!imageView.Create(vulkanDevice, imageViewInfo)) - return __LINE__; - - // Sampler - - VkSamplerCreateInfo samplerInfo = {}; - samplerInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; - samplerInfo.magFilter = VK_FILTER_LINEAR; - samplerInfo.minFilter = VK_FILTER_LINEAR; - samplerInfo.addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT; - samplerInfo.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT; - samplerInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT; - samplerInfo.anisotropyEnable = VK_FALSE; - samplerInfo.maxAnisotropy = 16; - samplerInfo.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK; - samplerInfo.unnormalizedCoordinates = VK_FALSE; - samplerInfo.compareEnable = VK_FALSE; - samplerInfo.compareOp = VK_COMPARE_OP_ALWAYS; - samplerInfo.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR; - - Nz::Vk::Sampler imageSampler; - if (!imageSampler.Create(vulkanDevice, samplerInfo)) - return __LINE__; + std::unique_ptr textureSampler = device->InstantiateTextureSampler({}); struct { diff --git a/include/Nazara/Renderer.hpp b/include/Nazara/Renderer.hpp index b043de0de..546ea5c55 100644 --- a/include/Nazara/Renderer.hpp +++ b/include/Nazara/Renderer.hpp @@ -51,5 +51,6 @@ #include #include #include +#include #endif // NAZARA_GLOBAL_RENDERER_HPP diff --git a/include/Nazara/Renderer/RenderDevice.hpp b/include/Nazara/Renderer/RenderDevice.hpp index daf74ca2e..ad48155a4 100644 --- a/include/Nazara/Renderer/RenderDevice.hpp +++ b/include/Nazara/Renderer/RenderDevice.hpp @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include #include #include @@ -31,6 +33,8 @@ namespace Nz virtual std::shared_ptr InstantiateRenderPipelineLayout(RenderPipelineLayoutInfo pipelineLayoutInfo) = 0; virtual std::shared_ptr InstantiateShaderStage(ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) = 0; std::shared_ptr InstantiateShaderStage(ShaderStageType type, ShaderLanguage lang, const std::filesystem::path& sourcePath); + virtual std::unique_ptr InstantiateTexture(const TextureInfo& params) = 0; + virtual std::unique_ptr InstantiateTextureSampler(const TextureSamplerInfo& params) = 0; }; } diff --git a/include/Nazara/Renderer/Texture.hpp b/include/Nazara/Renderer/Texture.hpp index 7dd8cad0a..4d9776879 100644 --- a/include/Nazara/Renderer/Texture.hpp +++ b/include/Nazara/Renderer/Texture.hpp @@ -8,128 +8,40 @@ #define NAZARA_TEXTURE_HPP #include -#include -#include #include -#include -#include +#include #include -#include -#include -#include +#include namespace Nz { - class Texture; - - using TextureConstRef = ObjectRef; - using TextureLibrary = ObjectLibrary; - using TextureManager = ResourceManager; - using TextureRef = ObjectRef; - - struct TextureImpl; - - class NAZARA_RENDERER_API Texture : public AbstractImage, public Resource + struct TextureInfo { - friend TextureLibrary; - friend TextureManager; - friend class Renderer; + PixelFormatType pixelFormat; + ImageType type; + unsigned int depth = 1; + unsigned int height; + unsigned int mipmapLevel = 1; + unsigned int width; + }; + class NAZARA_RENDERER_API Texture : public Resource + { public: Texture() = default; - Texture(ImageType type, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth = 1, UInt8 levelCount = 1); Texture(const Texture&) = delete; Texture(Texture&&) = delete; - ~Texture(); + virtual ~Texture(); - bool Create(ImageType type, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth = 1, UInt8 levelCount = 1); - void Destroy(); + virtual PixelFormatType GetFormat() const = 0; + virtual UInt8 GetLevelCount() const = 0; + virtual Vector3ui GetSize(UInt8 level = 0) const = 0; + virtual ImageType GetType() const = 0; - bool Download(Image* image) const; - - bool EnableMipmapping(bool enable); - - void EnsureMipmapsUpdate() const; - - unsigned int GetDepth(UInt8 level = 0) const override; - PixelFormatType GetFormat() const override; - unsigned int GetHeight(UInt8 level = 0) const override; - UInt8 GetLevelCount() const override; - UInt8 GetMaxLevel() const override; - std::size_t GetMemoryUsage() const override; - std::size_t GetMemoryUsage(UInt8 level) const override; - Vector3ui GetSize(UInt8 level = 0) const override; - ImageType GetType() const override; - unsigned int GetWidth(UInt8 level = 0) const override; - - bool HasMipmaps() const; - - void InvalidateMipmaps(); - bool IsValid() const; - - // LoadFace - bool LoadFaceFromFile(CubemapFace face, const std::filesystem::path& filePath, const ImageParams& params = ImageParams()); - bool LoadFaceFromMemory(CubemapFace face, const void* data, std::size_t size, const ImageParams& params = ImageParams()); - bool LoadFaceFromStream(CubemapFace face, Stream& stream, const ImageParams& params = ImageParams()); - - // Save - bool SaveToFile(const std::filesystem::path& filePath, const ImageParams& params = ImageParams()); - bool SaveToStream(Stream& stream, const std::string& format, const ImageParams& params = ImageParams()); - - bool SetMipmapRange(UInt8 minLevel, UInt8 maxLevel); - - bool Update(const Image* image, UInt8 level = 0); - bool Update(const Image* image, const Boxui& box, UInt8 level = 0); - bool Update(const Image* image, const Rectui& rect, unsigned int z = 0, UInt8 level = 0); - bool Update(const UInt8* pixels, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0) override; - bool Update(const UInt8* pixels, const Boxui& box, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0) override; - bool Update(const UInt8* pixels, const Rectui& rect, unsigned int z = 0, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0) override; - - // Fonctions OpenGL - unsigned int GetOpenGLID() const; + virtual bool Update(const void* ptr) = 0; Texture& operator=(const Texture&) = delete; Texture& operator=(Texture&&) = delete; - - static bool IsFormatSupported(PixelFormatType format); - static bool IsMipmappingSupported(); - static bool IsTypeSupported(ImageType type); - - // Load - static TextureRef LoadFromFile(const std::filesystem::path& filePath, const ImageParams& params = ImageParams(), bool generateMipmaps = true); - static TextureRef LoadFromImage(const Image* image, bool generateMipmaps = true); - static TextureRef LoadFromMemory(const void* data, std::size_t size, const ImageParams& params = ImageParams(), bool generateMipmaps = true); - static TextureRef LoadFromStream(Stream& stream, const ImageParams& params = ImageParams(), bool generateMipmaps = true); - - // LoadArray - static TextureRef LoadArrayFromFile(const std::filesystem::path& filePath, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2)); - static TextureRef LoadArrayFromImage(const Image* image, bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2)); - static TextureRef LoadArrayFromMemory(const void* data, std::size_t size, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2)); - static TextureRef LoadArrayFromStream(Stream& stream, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2)); - - // LoadCubemap - static TextureRef LoadCubemapFromFile(const std::filesystem::path& filePath, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams()); - static TextureRef LoadCubemapFromImage(const Image* image, bool generateMipmaps = true, const CubemapParams& params = CubemapParams()); - static TextureRef LoadCubemapFromMemory(const void* data, std::size_t size, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams()); - static TextureRef LoadCubemapFromStream(Stream& stream, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams()); - - template static TextureRef New(Args&&... args); - - // Signals: - NazaraSignal(OnTextureDestroy, const Texture* /*texture*/); - NazaraSignal(OnTextureRelease, const Texture* /*texture*/); - - private: - bool CreateTexture(bool proxy); - - static bool Initialize(); - static void Uninitialize(); - - TextureImpl* m_impl = nullptr; - - static TextureLibrary::LibraryMap s_library; - static TextureManager::ManagerMap s_managerMap; - static TextureManager::ManagerParams s_managerParameters; }; } diff --git a/include/Nazara/Renderer/Texture.inl b/include/Nazara/Renderer/Texture.inl new file mode 100644 index 000000000..f389a6984 --- /dev/null +++ b/include/Nazara/Renderer/Texture.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ +} + +#include diff --git a/include/Nazara/Renderer/TextureSampler.hpp b/include/Nazara/Renderer/TextureSampler.hpp new file mode 100644 index 000000000..e050298c3 --- /dev/null +++ b/include/Nazara/Renderer/TextureSampler.hpp @@ -0,0 +1,42 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_TEXTURE_SAMPLER_HPP +#define NAZARA_TEXTURE_SAMPLER_HPP + +#include +#include +#include + +namespace Nz +{ + struct TextureSamplerInfo + { + float anisotropyLevel = 0.f; + SamplerFilter magFilter = SamplerFilter_Linear; + SamplerFilter minFilter = SamplerFilter_Linear; + SamplerMipmapMode mipmapMode = SamplerMipmapMode_Linear; + SamplerWrap wrapModeU = SamplerWrap_Clamp; + SamplerWrap wrapModeV = SamplerWrap_Clamp; + SamplerWrap wrapModeW = SamplerWrap_Clamp; + }; + + class NAZARA_RENDERER_API TextureSampler + { + public: + TextureSampler() = default; + TextureSampler(const TextureSampler&) = delete; + TextureSampler(TextureSampler&&) = delete; + virtual ~TextureSampler(); + + TextureSampler& operator=(const TextureSampler&) = delete; + TextureSampler& operator=(TextureSampler&&) = delete; + }; +} + +#include + +#endif // NAZARA_TEXTURE_HPP diff --git a/include/Nazara/Renderer/TextureSampler.inl b/include/Nazara/Renderer/TextureSampler.inl new file mode 100644 index 000000000..a741958f0 --- /dev/null +++ b/include/Nazara/Renderer/TextureSampler.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ +} + +#include diff --git a/include/Nazara/Utility/Enums.hpp b/include/Nazara/Utility/Enums.hpp index 9c7a23554..602c60f0f 100644 --- a/include/Nazara/Utility/Enums.hpp +++ b/include/Nazara/Utility/Enums.hpp @@ -286,27 +286,26 @@ namespace Nz enum SamplerFilter { - SamplerFilter_Unknown = -1, - - SamplerFilter_Bilinear, + SamplerFilter_Linear, SamplerFilter_Nearest, - SamplerFilter_Trilinear, - SamplerFilter_Default, + SamplerFilter_Max = SamplerFilter_Nearest + }; - SamplerFilter_Max = SamplerFilter_Default + enum SamplerMipmapMode + { + SamplerMipmapMode_Linear, + SamplerMipmapMode_Nearest, + + SamplerMipmapMode_Max = SamplerMipmapMode_Nearest }; enum SamplerWrap { - SamplerWrap_Unknown = -1, - SamplerWrap_Clamp, SamplerWrap_MirroredRepeat, SamplerWrap_Repeat, - SamplerWrap_Default, - SamplerWrap_Max = SamplerWrap_Repeat }; diff --git a/include/Nazara/VulkanRenderer.hpp b/include/Nazara/VulkanRenderer.hpp index 3b21f92c2..5aa12a1c7 100644 --- a/include/Nazara/VulkanRenderer.hpp +++ b/include/Nazara/VulkanRenderer.hpp @@ -41,6 +41,8 @@ #include #include #include +#include +#include #include #include diff --git a/include/Nazara/VulkanRenderer/Utils.hpp b/include/Nazara/VulkanRenderer/Utils.hpp index 3d772abca..173589965 100644 --- a/include/Nazara/VulkanRenderer/Utils.hpp +++ b/include/Nazara/VulkanRenderer/Utils.hpp @@ -22,6 +22,9 @@ namespace Nz inline VkPolygonMode ToVulkan(FaceFilling faceFilling); inline VkPrimitiveTopology ToVulkan(PrimitiveMode primitiveMode); inline VkCompareOp ToVulkan(RendererComparison comparison); + inline VkFilter ToVulkan(SamplerFilter samplerFilter); + inline VkSamplerMipmapMode ToVulkan(SamplerMipmapMode samplerMipmap); + inline VkSamplerAddressMode ToVulkan(SamplerWrap samplerWrap); inline VkDescriptorType ToVulkan(ShaderBindingType bindingType); inline VkShaderStageFlagBits ToVulkan(ShaderStageType stageType); inline VkShaderStageFlags ToVulkan(ShaderStageTypeFlags stageType); diff --git a/include/Nazara/VulkanRenderer/Utils.inl b/include/Nazara/VulkanRenderer/Utils.inl index aa0f18d38..a843b67f5 100644 --- a/include/Nazara/VulkanRenderer/Utils.inl +++ b/include/Nazara/VulkanRenderer/Utils.inl @@ -108,6 +108,43 @@ namespace Nz return VK_COMPARE_OP_NEVER; } + VkFilter ToVulkan(SamplerFilter samplerFilter) + { + switch (samplerFilter) + { + case SamplerFilter_Linear: return VK_FILTER_LINEAR; + case SamplerFilter_Nearest: return VK_FILTER_NEAREST; + } + + NazaraError("Unhandled SamplerFilter 0x" + String::Number(UnderlyingCast(samplerFilter), 16)); + return VK_FILTER_NEAREST; + } + + VkSamplerMipmapMode ToVulkan(SamplerMipmapMode samplerMipmap) + { + switch (samplerMipmap) + { + case SamplerMipmapMode_Linear: return VK_SAMPLER_MIPMAP_MODE_LINEAR; + case SamplerMipmapMode_Nearest: return VK_SAMPLER_MIPMAP_MODE_NEAREST; + } + + NazaraError("Unhandled SamplerMipmapMode 0x" + String::Number(UnderlyingCast(samplerMipmap), 16)); + return VK_SAMPLER_MIPMAP_MODE_NEAREST; + } + + VkSamplerAddressMode ToVulkan(SamplerWrap samplerWrap) + { + switch (samplerWrap) + { + case SamplerWrap_Clamp: return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; + case SamplerWrap_MirroredRepeat: return VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT; + case SamplerWrap_Repeat: return VK_SAMPLER_ADDRESS_MODE_REPEAT; + } + + NazaraError("Unhandled SamplerWrap 0x" + String::Number(UnderlyingCast(samplerWrap), 16)); + return VK_SAMPLER_ADDRESS_MODE_REPEAT; + } + VkDescriptorType ToVulkan(ShaderBindingType bindingType) { switch (bindingType) diff --git a/include/Nazara/VulkanRenderer/VulkanDevice.hpp b/include/Nazara/VulkanRenderer/VulkanDevice.hpp index fb4a11c79..ce717c414 100644 --- a/include/Nazara/VulkanRenderer/VulkanDevice.hpp +++ b/include/Nazara/VulkanRenderer/VulkanDevice.hpp @@ -27,6 +27,8 @@ namespace Nz std::unique_ptr InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) override; std::shared_ptr InstantiateRenderPipelineLayout(RenderPipelineLayoutInfo pipelineLayoutInfo) override; std::shared_ptr InstantiateShaderStage(ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) override; + std::unique_ptr InstantiateTexture(const TextureInfo& params) override; + std::unique_ptr InstantiateTextureSampler(const TextureSamplerInfo& params) override; VulkanDevice& operator=(const VulkanDevice&) = delete; VulkanDevice& operator=(VulkanDevice&&) = delete; ///TODO? diff --git a/include/Nazara/VulkanRenderer/VulkanTexture.hpp b/include/Nazara/VulkanRenderer/VulkanTexture.hpp new file mode 100644 index 000000000..e5fc61426 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanTexture.hpp @@ -0,0 +1,51 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VULKANTEXTURE_HPP +#define NAZARA_VULKANRENDERER_VULKANTEXTURE_HPP + +#include +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_VULKANRENDERER_API VulkanTexture : public Texture + { + public: + VulkanTexture(Vk::Device& device, const TextureInfo& params); + VulkanTexture(const VulkanTexture&) = default; + VulkanTexture(VulkanTexture&&) noexcept = default; + ~VulkanTexture(); + + PixelFormatType GetFormat() const override; + inline VkImage GetImage() const; + inline VkImageView GetImageView() const; + UInt8 GetLevelCount() const override; + Vector3ui GetSize(UInt8 level = 0) const override; + ImageType GetType() const override; + + bool Update(const void* ptr) override; + + VulkanTexture& operator=(const VulkanTexture&) = delete; + VulkanTexture& operator=(VulkanTexture&&) = delete; + + private: + static void InitForFormat(PixelFormatType pixelFormat, VkImageCreateInfo& createImage, VkImageViewCreateInfo& createImageView); + + VkImage m_image; + VmaAllocation m_allocation; + Vk::Device& m_device; + Vk::ImageView m_imageView; + TextureInfo m_params; + }; +} + +#include + +#endif // NAZARA_VULKANRENDERER_VULKANTEXTURE_HPP diff --git a/include/Nazara/VulkanRenderer/VulkanTexture.inl b/include/Nazara/VulkanRenderer/VulkanTexture.inl new file mode 100644 index 000000000..26a36793a --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanTexture.inl @@ -0,0 +1,21 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline VkImage VulkanTexture::GetImage() const + { + return m_image; + } + + inline VkImageView VulkanTexture::GetImageView() const + { + return m_imageView; + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/VulkanTextureSampler.hpp b/include/Nazara/VulkanRenderer/VulkanTextureSampler.hpp new file mode 100644 index 000000000..2ea6e549b --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanTextureSampler.hpp @@ -0,0 +1,36 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VULKANTEXTURESAMPLER_HPP +#define NAZARA_VULKANRENDERER_VULKANTEXTURESAMPLER_HPP + +#include +#include +#include + +namespace Nz +{ + class NAZARA_VULKANRENDERER_API VulkanTextureSampler : public TextureSampler + { + public: + VulkanTextureSampler(Vk::Device& device, TextureSamplerInfo samplerInfo); + VulkanTextureSampler(const VulkanTextureSampler&) = default; + VulkanTextureSampler(VulkanTextureSampler&&) noexcept = default; + ~VulkanTextureSampler() = default; + + inline VkSampler GetSampler() const; + + VulkanTextureSampler& operator=(const VulkanTextureSampler&) = delete; + VulkanTextureSampler& operator=(VulkanTextureSampler&&) = delete; + + private: + Vk::Sampler m_sampler; + }; +} + +#include + +#endif // NAZARA_VULKANRENDERER_VULKANTEXTURESAMPLER_HPP diff --git a/include/Nazara/VulkanRenderer/VulkanTextureSampler.inl b/include/Nazara/VulkanRenderer/VulkanTextureSampler.inl new file mode 100644 index 000000000..710f4ee73 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanTextureSampler.inl @@ -0,0 +1,16 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline VkSampler VulkanTextureSampler::GetSampler() const + { + return m_sampler; + } +} + +#include diff --git a/src/Nazara/Renderer/Texture.cpp b/src/Nazara/Renderer/Texture.cpp new file mode 100644 index 000000000..6a3e4b1fb --- /dev/null +++ b/src/Nazara/Renderer/Texture.cpp @@ -0,0 +1,11 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + Texture::~Texture() = default; +} diff --git a/src/Nazara/Renderer/TextureSampler.cpp b/src/Nazara/Renderer/TextureSampler.cpp new file mode 100644 index 000000000..e8571e775 --- /dev/null +++ b/src/Nazara/Renderer/TextureSampler.cpp @@ -0,0 +1,11 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + TextureSampler::~TextureSampler() = default; +} diff --git a/src/Nazara/VulkanRenderer/VulkanDevice.cpp b/src/Nazara/VulkanRenderer/VulkanDevice.cpp index 252d7436b..0f8ce9a9f 100644 --- a/src/Nazara/VulkanRenderer/VulkanDevice.cpp +++ b/src/Nazara/VulkanRenderer/VulkanDevice.cpp @@ -6,6 +6,8 @@ #include #include #include +#include +#include #include namespace Nz @@ -39,4 +41,14 @@ namespace Nz return stage; } + + std::unique_ptr VulkanDevice::InstantiateTexture(const TextureInfo& params) + { + return std::make_unique(*this, params); + } + + std::unique_ptr VulkanDevice::InstantiateTextureSampler(const TextureSamplerInfo& params) + { + return std::make_unique(*this, params); + } } diff --git a/src/Nazara/VulkanRenderer/VulkanTexture.cpp b/src/Nazara/VulkanRenderer/VulkanTexture.cpp new file mode 100644 index 000000000..f991051d3 --- /dev/null +++ b/src/Nazara/VulkanRenderer/VulkanTexture.cpp @@ -0,0 +1,287 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + namespace + { + inline unsigned int GetLevelSize(unsigned int size, UInt8 level) + { + if (size == 0) // Possible dans le cas d'une image invalide + return 0; + + return std::max(size >> level, 1U); + } + } + + VulkanTexture::VulkanTexture(Vk::Device& device, const TextureInfo& params) : + m_image(VK_NULL_HANDLE), + m_allocation(nullptr), + m_device(device), + m_params(params) + { + VkImageCreateInfo createInfo = { VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO }; + createInfo.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; + createInfo.mipLevels = params.mipmapLevel; + createInfo.samples = VK_SAMPLE_COUNT_1_BIT; + createInfo.tiling = VK_IMAGE_TILING_OPTIMAL; + createInfo.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT; + + VkImageViewCreateInfo createInfoView = { VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO }; + createInfoView.subresourceRange = { + VK_IMAGE_ASPECT_COLOR_BIT, + 0, + 1, + 0, + 1 + }; + + InitForFormat(params.pixelFormat, createInfo, createInfoView); + + switch (params.type) + { + case ImageType_1D: + NazaraAssert(params.width > 0, "Width must be over zero"); + + createInfoView.viewType = VK_IMAGE_VIEW_TYPE_1D; + + createInfo.imageType = VK_IMAGE_TYPE_1D; + createInfo.extent.width = params.width; + createInfo.extent.height = 1; + createInfo.extent.depth = 1; + createInfo.arrayLayers = 1; + break; + + case ImageType_1D_Array: + NazaraAssert(params.width > 0, "Width must be over zero"); + NazaraAssert(params.height > 0, "Height must be over zero"); + + createInfoView.viewType = VK_IMAGE_VIEW_TYPE_1D_ARRAY; + + createInfo.imageType = VK_IMAGE_TYPE_1D; + createInfo.extent.width = params.width; + createInfo.extent.height = 1; + createInfo.extent.depth = 1; + createInfo.arrayLayers = params.height; + break; + + case ImageType_2D: + NazaraAssert(params.width > 0, "Width must be over zero"); + NazaraAssert(params.height > 0, "Height must be over zero"); + + createInfoView.viewType = VK_IMAGE_VIEW_TYPE_2D; + + createInfo.imageType = VK_IMAGE_TYPE_2D; + createInfo.extent.width = params.width; + createInfo.extent.height = params.height; + createInfo.extent.depth = 1; + createInfo.arrayLayers = 1; + break; + + case ImageType_2D_Array: + NazaraAssert(params.width > 0, "Width must be over zero"); + NazaraAssert(params.height > 0, "Height must be over zero"); + NazaraAssert(params.depth > 0, "Depth must be over zero"); + + createInfoView.viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY; + + createInfo.imageType = VK_IMAGE_TYPE_2D; + createInfo.extent.width = params.width; + createInfo.extent.height = params.height; + createInfo.extent.depth = 1; + createInfo.arrayLayers = params.height; + break; + + case ImageType_3D: + NazaraAssert(params.width > 0, "Width must be over zero"); + NazaraAssert(params.height > 0, "Height must be over zero"); + NazaraAssert(params.depth > 0, "Depth must be over zero"); + + createInfoView.viewType = VK_IMAGE_VIEW_TYPE_3D; + + createInfo.imageType = VK_IMAGE_TYPE_3D; + createInfo.extent.width = params.width; + createInfo.extent.height = params.height; + createInfo.extent.depth = params.depth; + createInfo.arrayLayers = 1; + break; + + case ImageType_Cubemap: + NazaraAssert(params.width > 0, "Width must be over zero"); + NazaraAssert(params.height > 0, "Height must be over zero"); + + createInfoView.viewType = VK_IMAGE_VIEW_TYPE_CUBE; + + createInfo.imageType = VK_IMAGE_TYPE_2D; + createInfo.extent.width = params.width; + createInfo.extent.height = params.height; + createInfo.extent.depth = 1; + createInfo.arrayLayers = 6; + createInfo.flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT; + break; + + default: + break; + } + + VmaAllocationCreateInfo allocInfo = {}; + allocInfo.usage = VMA_MEMORY_USAGE_GPU_ONLY; + + VkResult result = vmaCreateImage(m_device.GetMemoryAllocator(), &createInfo, &allocInfo, &m_image, &m_allocation, nullptr); + if (result != VK_SUCCESS) + throw std::runtime_error("Failed to allocate image: " + TranslateVulkanError(result)); + + createInfoView.image = m_image; + + if (!m_imageView.Create(device, createInfoView)) + { + // FIXME + vmaDestroyImage(m_device.GetMemoryAllocator(), m_image, m_allocation); + throw std::runtime_error("Failed to create image view: " + TranslateVulkanError(m_imageView.GetLastErrorCode())); + } + } + + VulkanTexture::~VulkanTexture() + { + vmaDestroyImage(m_device.GetMemoryAllocator(), m_image, m_allocation); + } + + PixelFormatType VulkanTexture::GetFormat() const + { + return m_params.pixelFormat; + } + + UInt8 VulkanTexture::GetLevelCount() const + { + return m_params.mipmapLevel; + } + + Vector3ui VulkanTexture::GetSize(UInt8 level) const + { + return Vector3ui(GetLevelSize(m_params.width, level), GetLevelSize(m_params.height, level), GetLevelSize(m_params.depth, level)); + } + + ImageType VulkanTexture::GetType() const + { + return m_params.type; + } + + bool VulkanTexture::Update(const void* ptr) + { + std::size_t textureSize = m_params.width * m_params.height * m_params.depth * PixelFormat::GetBytesPerPixel(m_params.pixelFormat); + + VkBufferCreateInfo createInfo = {}; + createInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; + createInfo.size = textureSize; + createInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT; + + VmaAllocationCreateInfo allocInfo = {}; + allocInfo.flags = VMA_ALLOCATION_CREATE_MAPPED_BIT; + allocInfo.usage = VMA_MEMORY_USAGE_CPU_TO_GPU; + + VmaAllocationInfo allocationInfo; + + VkBuffer stagingBuffer; + VmaAllocation stagingAllocation; + + VkResult result = vmaCreateBuffer(m_device.GetMemoryAllocator(), &createInfo, &allocInfo, &stagingBuffer, &stagingAllocation, &allocationInfo); + if (result != VK_SUCCESS) + { + NazaraError("Failed to allocate staging buffer: " + TranslateVulkanError(result)); + return false; + } + + CallOnExit freeStaging([&] { + vmaDestroyBuffer(m_device.GetMemoryAllocator(), stagingBuffer, stagingAllocation); + }); + + std::memcpy(allocationInfo.pMappedData, ptr, textureSize); + + Vk::AutoCommandBuffer copyCommandBuffer = m_device.AllocateTransferCommandBuffer(); + if (!copyCommandBuffer->Begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT)) + return false; + + copyCommandBuffer->SetImageLayout(m_image, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); + + copyCommandBuffer->CopyBufferToImage(stagingBuffer, m_image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, m_params.width, m_params.height, m_params.depth); + + copyCommandBuffer->SetImageLayout(m_image, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); + + if (!copyCommandBuffer->End()) + return false; + + Vk::QueueHandle transferQueue = m_device.GetQueue(m_device.GetTransferQueueFamilyIndex(), 0); + if (!transferQueue.Submit(copyCommandBuffer)) + return false; + + transferQueue.WaitIdle(); + + return true; + } + + void VulkanTexture::InitForFormat(PixelFormatType pixelFormat, VkImageCreateInfo& createImage, VkImageViewCreateInfo& createImageView) + { + createImageView.components = { + VK_COMPONENT_SWIZZLE_R, + VK_COMPONENT_SWIZZLE_G, + VK_COMPONENT_SWIZZLE_B, + VK_COMPONENT_SWIZZLE_A + }; + + switch (pixelFormat) + { + case PixelFormatType_L8: + { + createImage.format = VK_FORMAT_R8_SRGB; + createImageView.format = createImage.format; + createImageView.components = { + VK_COMPONENT_SWIZZLE_R, + VK_COMPONENT_SWIZZLE_R, + VK_COMPONENT_SWIZZLE_R, + VK_COMPONENT_SWIZZLE_A + }; + break; + } + + case PixelFormatType_LA8: + { + createImage.format = VK_FORMAT_R8G8_SRGB; + createImageView.format = createImage.format; + createImageView.components = { + VK_COMPONENT_SWIZZLE_R, + VK_COMPONENT_SWIZZLE_R, + VK_COMPONENT_SWIZZLE_R, + VK_COMPONENT_SWIZZLE_G + }; + break; + } + + case PixelFormatType_RGB8: + { + createImage.format = VK_FORMAT_R8G8B8_SRGB; + createImageView.format = createImage.format; + break; + } + + case PixelFormatType_RGBA8: + { + createImage.format = VK_FORMAT_R8G8B8A8_SRGB; + createImageView.format = createImage.format; + break; + } + + default: + throw std::runtime_error(("Unsupported pixel format " + PixelFormat::GetName(pixelFormat)).ToStdString()); + } + } +} diff --git a/src/Nazara/VulkanRenderer/VulkanTextureSampler.cpp b/src/Nazara/VulkanRenderer/VulkanTextureSampler.cpp new file mode 100644 index 000000000..053683bd4 --- /dev/null +++ b/src/Nazara/VulkanRenderer/VulkanTextureSampler.cpp @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + VulkanTextureSampler::VulkanTextureSampler(Vk::Device& device, TextureSamplerInfo samplerInfo) + { + VkSamplerCreateInfo createInfo = { VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO }; + createInfo.magFilter = ToVulkan(samplerInfo.magFilter); + createInfo.minFilter = ToVulkan(samplerInfo.minFilter); + createInfo.addressModeU = ToVulkan(samplerInfo.wrapModeU); + createInfo.addressModeV = ToVulkan(samplerInfo.wrapModeV); + createInfo.addressModeW = ToVulkan(samplerInfo.wrapModeW); + createInfo.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK; + createInfo.mipmapMode = ToVulkan(samplerInfo.mipmapMode); + + if (samplerInfo.anisotropyLevel > 0.f) + { + createInfo.anisotropyEnable = VK_TRUE; + createInfo.maxAnisotropy = samplerInfo.anisotropyLevel; + } + + if (!m_sampler.Create(device, createInfo)) + throw std::runtime_error("Failed to create sampler: " + TranslateVulkanError(m_sampler.GetLastErrorCode())); + } +} From 1dc0ed8e941f97992d4b41a257b3e9dffd6ee1b5 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 26 Mar 2020 21:19:46 +0100 Subject: [PATCH 136/316] Add ShaderBinding --- examples/VulkanTest/main.cpp | 31 ++-- include/Nazara/Renderer.hpp | 2 +- .../Nazara/Renderer/RenderPipelineLayout.hpp | 4 + include/Nazara/Renderer/Shader.hpp | 135 ------------------ include/Nazara/Renderer/ShaderBinding.hpp | 57 ++++++++ include/Nazara/Renderer/ShaderBinding.inl | 12 ++ include/Nazara/VulkanRenderer.hpp | 1 + .../VulkanRenderPipelineLayout.hpp | 6 +- .../VulkanRenderPipelineLayout.inl | 5 + .../VulkanRenderer/VulkanShaderBinding.hpp | 41 ++++++ .../VulkanRenderer/VulkanShaderBinding.inl | 22 +++ src/Nazara/Renderer/ShaderBinding.cpp | 11 ++ .../VulkanRenderPipelineLayout.cpp | 18 ++- .../VulkanRenderer/VulkanShaderBinding.cpp | 70 +++++++++ 14 files changed, 265 insertions(+), 150 deletions(-) delete mode 100644 include/Nazara/Renderer/Shader.hpp create mode 100644 include/Nazara/Renderer/ShaderBinding.hpp create mode 100644 include/Nazara/Renderer/ShaderBinding.inl create mode 100644 include/Nazara/VulkanRenderer/VulkanShaderBinding.hpp create mode 100644 include/Nazara/VulkanRenderer/VulkanShaderBinding.inl create mode 100644 src/Nazara/Renderer/ShaderBinding.cpp create mode 100644 src/Nazara/VulkanRenderer/VulkanShaderBinding.cpp diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index 754911922..1e38c6260 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -179,9 +179,7 @@ int main() std::shared_ptr renderPipelineLayout = device->InstantiateRenderPipelineLayout(pipelineLayoutInfo); - Nz::VulkanRenderPipelineLayout* vkPipelineLayout = static_cast(renderPipelineLayout.get()); - - Nz::Vk::DescriptorSet descriptorSet = vkPipelineLayout->AllocateDescriptorSet(); + Nz::ShaderBinding& shaderBinding = renderPipelineLayout->AllocateShaderBinding(); std::unique_ptr uniformBuffer = device->InstantiateBuffer(Nz::BufferType_Uniform); if (!uniformBuffer->Initialize(uniformSize, Nz::BufferUsage_DeviceLocal)) @@ -190,9 +188,20 @@ int main() return __LINE__; } - Nz::VulkanBuffer* uniformBufferImpl = static_cast(uniformBuffer.get()); - descriptorSet.WriteUniformDescriptor(0, uniformBufferImpl->GetBufferHandle(), 0, uniformSize); - descriptorSet.WriteCombinedImageSamplerDescriptor(1, imageSampler, imageView, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); + shaderBinding.Update({ + { + 0, + Nz::ShaderBinding::UniformBufferBinding { + uniformBuffer.get(), 0, uniformSize + } + }, + { + 1, + Nz::ShaderBinding::TextureBinding { + texture.get(), textureSampler.get() + } + } + }); Nz::RenderPipelineInfo pipelineInfo; pipelineInfo.pipelineLayout = renderPipelineLayout; @@ -237,6 +246,10 @@ int main() Nz::VulkanRenderPipeline* vkPipeline = static_cast(pipeline.get()); + Nz::VulkanRenderPipelineLayout* vkPipelineLayout = static_cast(renderPipelineLayout.get()); + + Nz::VulkanShaderBinding& vkShaderBinding = static_cast(shaderBinding); + for (Nz::UInt32 i = 0; i < imageCount; ++i) { Nz::Vk::CommandBuffer& renderCmd = renderCmds[i]; @@ -265,9 +278,9 @@ int main() renderCmd.Begin(); renderCmd.BeginRenderPass(render_pass_begin_info); - renderCmd.BindIndexBuffer(indexBufferImpl->GetBufferHandle(), 0, VK_INDEX_TYPE_UINT16); - renderCmd.BindVertexBuffer(0, vertexBufferImpl->GetBufferHandle(), 0); - renderCmd.BindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, vkPipelineLayout->GetPipelineLayout(), 0, descriptorSet); + renderCmd.BindIndexBuffer(indexBufferImpl->GetBuffer(), 0, VK_INDEX_TYPE_UINT16); + renderCmd.BindVertexBuffer(0, vertexBufferImpl->GetBuffer(), 0); + renderCmd.BindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, vkPipelineLayout->GetPipelineLayout(), 0, vkShaderBinding.GetDescriptorSet()); renderCmd.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, vkPipeline->Get(vulkanWindow.GetRenderPass())); renderCmd.SetScissor(Nz::Recti{0, 0, int(windowSize.x), int(windowSize.y)}); renderCmd.SetViewport({0.f, 0.f, float(windowSize.x), float(windowSize.y)}, 0.f, 1.f); diff --git a/include/Nazara/Renderer.hpp b/include/Nazara/Renderer.hpp index 546ea5c55..6ce0da6dc 100644 --- a/include/Nazara/Renderer.hpp +++ b/include/Nazara/Renderer.hpp @@ -45,8 +45,8 @@ #include #include #include -#include #include +#include #include #include #include diff --git a/include/Nazara/Renderer/RenderPipelineLayout.hpp b/include/Nazara/Renderer/RenderPipelineLayout.hpp index 13d6ab668..7cbaa54de 100644 --- a/include/Nazara/Renderer/RenderPipelineLayout.hpp +++ b/include/Nazara/Renderer/RenderPipelineLayout.hpp @@ -27,11 +27,15 @@ namespace Nz std::vector bindings; }; + class ShaderBinding; + class NAZARA_RENDERER_API RenderPipelineLayout { public: RenderPipelineLayout() = default; virtual ~RenderPipelineLayout(); + + virtual ShaderBinding& AllocateShaderBinding() = 0; }; } diff --git a/include/Nazara/Renderer/Shader.hpp b/include/Nazara/Renderer/Shader.hpp deleted file mode 100644 index 06d195758..000000000 --- a/include/Nazara/Renderer/Shader.hpp +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_SHADER_HPP -#define NAZARA_SHADER_HPP - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - class Color; - class Shader; - class ShaderStage; - - using ShaderConstRef = ObjectRef; - using ShaderLibrary = ObjectLibrary; - using ShaderRef = ObjectRef; - - class NAZARA_RENDERER_API Shader : public RefCounted - { - friend ShaderLibrary; - friend class Renderer; - - public: - Shader(); - Shader(const Shader&) = delete; - Shader(Shader&&) = delete; - ~Shader(); - - void AttachStage(ShaderStageType stage, const ShaderStage& shaderStage); - bool AttachStageFromFile(ShaderStageType stage, const std::filesystem::path& filePath); - bool AttachStageFromSource(ShaderStageType stage, const char* source, unsigned int length); - bool AttachStageFromSource(ShaderStageType stage, const String& source); - - void Bind() const; - - bool Create(); - void Destroy(); - - ByteArray GetBinary() const; - String GetLog() const; - String GetSourceCode(ShaderStageType stage) const; - int GetUniformLocation(const String& name) const; - int GetUniformLocation(ShaderUniform shaderUniform) const; - - bool HasStage(ShaderStageType stage) const; - - bool IsBinaryRetrievable() const; - bool IsLinked() const; - bool IsValid() const; - - bool Link(); - - bool LoadFromBinary(const void* buffer, unsigned int size); - bool LoadFromBinary(const ByteArray& byteArray); - - void SendBoolean(int location, bool value) const; - void SendColor(int location, const Color& color) const; - void SendDouble(int location, double value) const; - void SendDoubleArray(int location, const double* values, unsigned int count) const; - void SendFloat(int location, float value) const; - void SendFloatArray(int location, const float* values, unsigned int count) const; - void SendInteger(int location, int value) const; - void SendIntegerArray(int location, const int* values, unsigned int count) const; - void SendMatrix(int location, const Matrix4d& matrix) const; - void SendMatrix(int location, const Matrix4f& matrix) const; - void SendVector(int location, const Vector2d& vector) const; - void SendVector(int location, const Vector2f& vector) const; - void SendVector(int location, const Vector2i& vector) const; - void SendVector(int location, const Vector3d& vector) const; - void SendVector(int location, const Vector3f& vector) const; - void SendVector(int location, const Vector3i& vector) const; - void SendVector(int location, const Vector4d& vector) const; - void SendVector(int location, const Vector4f& vector) const; - void SendVector(int location, const Vector4i& vector) const; - void SendVectorArray(int location, const Vector2d* vectors, unsigned int count) const; - void SendVectorArray(int location, const Vector2f* vectors, unsigned int count) const; - void SendVectorArray(int location, const Vector2i* vectors, unsigned int count) const; - void SendVectorArray(int location, const Vector3d* vectors, unsigned int count) const; - void SendVectorArray(int location, const Vector3f* vectors, unsigned int count) const; - void SendVectorArray(int location, const Vector3i* vectors, unsigned int count) const; - void SendVectorArray(int location, const Vector4d* vectors, unsigned int count) const; - void SendVectorArray(int location, const Vector4f* vectors, unsigned int count) const; - void SendVectorArray(int location, const Vector4i* vectors, unsigned int count) const; - - bool Validate() const; - - // Fonctions OpenGL - unsigned int GetOpenGLID() const; - - Shader& operator=(const Shader&) = delete; - Shader& operator=(Shader&&) = delete; - - static bool IsStageSupported(ShaderStageType stage); - template static ShaderRef New(Args&&... args); - - // Signals: - NazaraSignal(OnShaderDestroy, const Shader* /*shader*/); - NazaraSignal(OnShaderRelease, const Shader* /*shader*/); - NazaraSignal(OnShaderUniformInvalidated, const Shader* /*shader*/); - - private: - bool PostLinkage(); - - static bool Initialize(); - static void Uninitialize(); - - std::vector m_attachedShaders[ShaderStageType_Max+1]; - bool m_linked; - int m_uniformLocations[ShaderUniform_Max+1]; - unsigned int m_program; - - static ShaderLibrary::LibraryMap s_library; - }; -} - -#include - -#endif // NAZARA_SHADER_HPP diff --git a/include/Nazara/Renderer/ShaderBinding.hpp b/include/Nazara/Renderer/ShaderBinding.hpp new file mode 100644 index 000000000..1a2daba5e --- /dev/null +++ b/include/Nazara/Renderer/ShaderBinding.hpp @@ -0,0 +1,57 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_SHADERBINDING_HPP +#define NAZARA_SHADERBINDING_HPP + +#include +#include +#include + +namespace Nz +{ + class AbstractBuffer; + class Texture; + class TextureSampler; + + class NAZARA_RENDERER_API ShaderBinding + { + public: + struct Binding; + + ShaderBinding() = default; + virtual ~ShaderBinding(); + + virtual void Update(std::initializer_list bindings) = 0; + + struct TextureBinding + { + Texture* texture; + TextureSampler* sampler; + }; + + struct UniformBufferBinding + { + AbstractBuffer* buffer; + UInt64 offset; + UInt64 range; + }; + + struct Binding + { + std::size_t bindingIndex; + std::variant content; + }; + + protected: + ShaderBinding(const ShaderBinding&) = delete; + ShaderBinding(ShaderBinding&&) = default; + }; +} + +#include + +#endif // NAZARA_SHADERBINDING_HPP diff --git a/include/Nazara/Renderer/ShaderBinding.inl b/include/Nazara/Renderer/ShaderBinding.inl new file mode 100644 index 000000000..dccd89939 --- /dev/null +++ b/include/Nazara/Renderer/ShaderBinding.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ +} + +#include diff --git a/include/Nazara/VulkanRenderer.hpp b/include/Nazara/VulkanRenderer.hpp index 5aa12a1c7..6cc1db9dd 100644 --- a/include/Nazara/VulkanRenderer.hpp +++ b/include/Nazara/VulkanRenderer.hpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include diff --git a/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.hpp b/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.hpp index 80c530b9e..1dc17f883 100644 --- a/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.hpp +++ b/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -25,10 +26,12 @@ namespace Nz VulkanRenderPipelineLayout() = default; ~VulkanRenderPipelineLayout() = default; - Vk::DescriptorSet AllocateDescriptorSet(); + VulkanShaderBinding& AllocateShaderBinding() override; bool Create(Vk::Device& device, RenderPipelineLayoutInfo layoutInfo); + inline Vk::Device* GetDevice() const; + inline const Vk::DescriptorSetLayout& GetDescriptorSetLayout() const; inline const Vk::PipelineLayout& GetPipelineLayout() const; @@ -36,6 +39,7 @@ namespace Nz struct DescriptorPool { Vk::DescriptorPool descriptorPool; + std::vector allocatedSets; }; MovablePtr m_device; diff --git a/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.inl b/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.inl index 36cad5f4a..e4a9f73c4 100644 --- a/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.inl +++ b/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.inl @@ -7,6 +7,11 @@ namespace Nz { + inline Vk::Device* VulkanRenderPipelineLayout::GetDevice() const + { + return m_device.Get(); + } + inline const Vk::DescriptorSetLayout& VulkanRenderPipelineLayout::GetDescriptorSetLayout() const { return m_descriptorSetLayout; diff --git a/include/Nazara/VulkanRenderer/VulkanShaderBinding.hpp b/include/Nazara/VulkanRenderer/VulkanShaderBinding.hpp new file mode 100644 index 000000000..8d92b3697 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanShaderBinding.hpp @@ -0,0 +1,41 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VULKANSHADERBINDING_HPP +#define NAZARA_VULKANRENDERER_VULKANSHADERBINDING_HPP + +#include +#include +#include + +namespace Nz +{ + class VulkanRenderPipelineLayout; + + class NAZARA_VULKANRENDERER_API VulkanShaderBinding : public ShaderBinding + { + public: + inline VulkanShaderBinding(VulkanRenderPipelineLayout& owner, Vk::DescriptorSet descriptorSet); + VulkanShaderBinding(const VulkanShaderBinding&) = default; + VulkanShaderBinding(VulkanShaderBinding&&) noexcept = default; + ~VulkanShaderBinding() = default; + + inline Vk::DescriptorSet& GetDescriptorSet(); + + void Update(std::initializer_list bindings) override; + + VulkanShaderBinding& operator=(const VulkanShaderBinding&) = delete; + VulkanShaderBinding& operator=(VulkanShaderBinding&&) = delete; + + private: + Vk::AutoDescriptorSet m_descriptorSet; + VulkanRenderPipelineLayout& m_owner; + }; +} + +#include + +#endif // NAZARA_VULKANRENDERER_VULKANSHADERBINDING_HPP diff --git a/include/Nazara/VulkanRenderer/VulkanShaderBinding.inl b/include/Nazara/VulkanRenderer/VulkanShaderBinding.inl new file mode 100644 index 000000000..4300cf788 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanShaderBinding.inl @@ -0,0 +1,22 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline VulkanShaderBinding::VulkanShaderBinding(VulkanRenderPipelineLayout& owner, Vk::DescriptorSet descriptorSet) : + m_descriptorSet(std::move(descriptorSet)), + m_owner(owner) + { + } + + inline Vk::DescriptorSet& VulkanShaderBinding::GetDescriptorSet() + { + return m_descriptorSet; + } +} + +#include diff --git a/src/Nazara/Renderer/ShaderBinding.cpp b/src/Nazara/Renderer/ShaderBinding.cpp new file mode 100644 index 000000000..240d848c6 --- /dev/null +++ b/src/Nazara/Renderer/ShaderBinding.cpp @@ -0,0 +1,11 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + ShaderBinding::~ShaderBinding() = default; +} diff --git a/src/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.cpp b/src/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.cpp index 8eaf5d268..3af7735fc 100644 --- a/src/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.cpp +++ b/src/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.cpp @@ -12,14 +12,17 @@ namespace Nz { - Vk::DescriptorSet VulkanRenderPipelineLayout::AllocateDescriptorSet() + VulkanShaderBinding& VulkanRenderPipelineLayout::AllocateShaderBinding() { // TODO: Watch descriptor set count for each pool for (auto& pool : m_descriptorPools) { + if (pool.allocatedSets.capacity() <= pool.allocatedSets.size()) + continue; + Vk::DescriptorSet descriptorSet = pool.descriptorPool.AllocateDescriptorSet(m_descriptorSetLayout); if (descriptorSet) - return descriptorSet; + return pool.allocatedSets.emplace_back(*this, std::move(descriptorSet)); } // Allocate a new descriptor pool @@ -36,9 +39,16 @@ namespace Nz DescriptorPool pool; if (!pool.descriptorPool.Create(*m_device, MaxSet, UInt32(poolSizes.size()), poolSizes.data(), VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT)) - return {}; + { + //return {}; + } - return m_descriptorPools.emplace_back(std::move(pool)).descriptorPool.AllocateDescriptorSet(m_descriptorSetLayout); + pool.allocatedSets.reserve(MaxSet); + + auto& poolData = m_descriptorPools.emplace_back(std::move(pool)); + Vk::DescriptorSet descriptorSet = poolData.descriptorPool.AllocateDescriptorSet(m_descriptorSetLayout); + //if (descriptorSet) + return poolData.allocatedSets.emplace_back(*this, std::move(descriptorSet)); } bool VulkanRenderPipelineLayout::Create(Vk::Device& device, RenderPipelineLayoutInfo layoutInfo) diff --git a/src/Nazara/VulkanRenderer/VulkanShaderBinding.cpp b/src/Nazara/VulkanRenderer/VulkanShaderBinding.cpp new file mode 100644 index 000000000..4f1d4754b --- /dev/null +++ b/src/Nazara/VulkanRenderer/VulkanShaderBinding.cpp @@ -0,0 +1,70 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + void VulkanShaderBinding::Update(std::initializer_list bindings) + { + StackVector bufferBinding = NazaraStackVector(VkDescriptorBufferInfo, bindings.size()); + StackVector imageBinding = NazaraStackVector(VkDescriptorImageInfo, bindings.size()); + StackVector writeOps = NazaraStackVector(VkWriteDescriptorSet, bindings.size()); + + for (const Binding& binding : bindings) + { + VkWriteDescriptorSet& writeOp = writeOps.emplace_back(); + writeOp.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; + writeOp.dstSet = m_descriptorSet; + writeOp.dstBinding = UInt32(binding.bindingIndex); + + std::visit([&](auto&& arg) + { + using T = std::decay_t; + + if constexpr (std::is_same_v) + { + VulkanTexture& vkTexture = *static_cast(arg.texture); + VulkanTextureSampler& vkSampler = *static_cast(arg.sampler); + + VkDescriptorImageInfo& imageInfo = imageBinding.emplace_back(); + imageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; + imageInfo.imageView = vkTexture.GetImageView(); + imageInfo.sampler = vkSampler.GetSampler(); + + writeOp.descriptorCount = 1; + writeOp.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; + + writeOp.pImageInfo = &imageInfo; + } + else if constexpr (std::is_same_v) + { + VulkanBuffer& vkBuffer = *static_cast(arg.buffer); + + VkDescriptorBufferInfo& bufferInfo = bufferBinding.emplace_back(); + bufferInfo.buffer = vkBuffer.GetBuffer(); + bufferInfo.offset = arg.offset; + bufferInfo.range = arg.range; + + writeOp.descriptorCount = 1; + writeOp.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; + + writeOp.pBufferInfo = &bufferInfo; + } + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + + }, binding.content); + } + + m_owner.GetDevice()->vkUpdateDescriptorSets(*m_owner.GetDevice(), UInt32(writeOps.size()), writeOps.data(), 0U, nullptr); + } +} From 15b95ca4a16562414d9a746fbae462e6133fd55d Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 26 Mar 2020 21:20:00 +0100 Subject: [PATCH 137/316] Minor and forgotten stuff --- include/Nazara/Renderer/RendererImpl.hpp | 4 ++-- .../Nazara/VulkanRenderer/VulkanRenderer.hpp | 2 +- .../VulkanRenderer/Wrapper/CommandBuffer.hpp | 6 ++++-- .../VulkanRenderer/Wrapper/CommandBuffer.inl | 20 +++++++++++++++---- plugins/Assimp/Plugin.cpp | 2 +- src/Nazara/Core/PluginManager.cpp | 4 ++-- src/Nazara/VulkanRenderer/VulkanRenderer.cpp | 7 ++++--- 7 files changed, 30 insertions(+), 15 deletions(-) diff --git a/include/Nazara/Renderer/RendererImpl.hpp b/include/Nazara/Renderer/RendererImpl.hpp index f9b5f4d10..67eeafe64 100644 --- a/include/Nazara/Renderer/RendererImpl.hpp +++ b/include/Nazara/Renderer/RendererImpl.hpp @@ -9,12 +9,12 @@ #include #include -#include #include #include #include #include #include +#include #include namespace Nz @@ -41,7 +41,7 @@ namespace Nz virtual bool IsBetterThan(const RendererImpl* other) const = 0; virtual RenderAPI QueryAPI() const = 0; - virtual String QueryAPIString() const = 0; + virtual std::string QueryAPIString() const = 0; virtual UInt32 QueryAPIVersion() const = 0; virtual std::vector QueryRenderDevices() const = 0; diff --git a/include/Nazara/VulkanRenderer/VulkanRenderer.hpp b/include/Nazara/VulkanRenderer/VulkanRenderer.hpp index 2d7b2f779..e228170a4 100644 --- a/include/Nazara/VulkanRenderer/VulkanRenderer.hpp +++ b/include/Nazara/VulkanRenderer/VulkanRenderer.hpp @@ -33,7 +33,7 @@ namespace Nz bool IsBetterThan(const RendererImpl* other) const override; RenderAPI QueryAPI() const override; - String QueryAPIString() const override; + std::string QueryAPIString() const override; UInt32 QueryAPIVersion() const override; std::vector QueryRenderDevices() const override; diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp index 8e058256a..bac7e5f61 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp @@ -53,7 +53,7 @@ namespace Nz inline void ClearDepthStencilImage(VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue& depthStencil, UInt32 rangeCount, const VkImageSubresourceRange* ranges); inline void CopyBuffer(VkBuffer source, VkBuffer target, UInt32 size, UInt32 sourceOffset = 0, UInt32 targetOffset = 0); - inline void CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, UInt32 width, UInt32 height); + inline void CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, UInt32 width, UInt32 height, UInt32 depth = 1); inline void Draw(UInt32 vertexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0); inline void DrawIndexed(UInt32 indexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, Int32 vertexOffset = 0, UInt32 firstInstance = 0); @@ -64,8 +64,10 @@ namespace Nz inline void Free(); + inline void MemoryBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask); + inline void PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, const VkImageMemoryBarrier& imageMemoryBarrier); - inline void PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, const VkMemoryBarrier& memoryBarrier, const VkBufferMemoryBarrier& bufferMemoryBarrier, const VkImageMemoryBarrier& imageMemoryBarrier); + inline void PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, const VkMemoryBarrier& memoryBarrier); inline void PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, UInt32 memoryBarrierCount, const VkMemoryBarrier* memoryBarriers, UInt32 bufferMemoryBarrierCount, const VkBufferMemoryBarrier* bufferMemoryBarriers, UInt32 imageMemoryBarrierCount, const VkImageMemoryBarrier* imageMemoryBarriers); inline void SetScissor(const Recti& scissorRegion); diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl index f504a0df8..9b2558a63 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl @@ -198,7 +198,7 @@ namespace Nz return m_pool->GetDevice()->vkCmdCopyBuffer(m_handle, source, target, 1, ®ion); } - inline void CommandBuffer::CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, UInt32 width, UInt32 height) + inline void CommandBuffer::CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, UInt32 width, UInt32 height, UInt32 depth) { VkBufferImageCopy region = { 0, @@ -214,7 +214,7 @@ namespace Nz 0, 0, 0 }, { // imageExtent - width, height, 1U + width, height, depth } }; @@ -257,14 +257,26 @@ namespace Nz } } + inline void CommandBuffer::MemoryBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask) + { + VkMemoryBarrier memoryBarrier = { + VK_STRUCTURE_TYPE_MEMORY_BARRIER, + nullptr, + srcAccessMask, + dstAccessMask + }; + + return PipelineBarrier(srcStageMask, dstStageMask, 0U, memoryBarrier); + } + inline void CommandBuffer::PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, const VkImageMemoryBarrier& imageMemoryBarrier) { return PipelineBarrier(srcStageMask, dstStageMask, dependencyFlags, 0, nullptr, 0, nullptr, 1, &imageMemoryBarrier); } - inline void CommandBuffer::PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, const VkMemoryBarrier& memoryBarrier, const VkBufferMemoryBarrier& bufferMemoryBarrier, const VkImageMemoryBarrier& imageMemoryBarrier) + inline void CommandBuffer::PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, const VkMemoryBarrier& memoryBarrier) { - return PipelineBarrier(srcStageMask, dstStageMask, dependencyFlags, 1, &memoryBarrier, 1, &bufferMemoryBarrier, 1, &imageMemoryBarrier); + return PipelineBarrier(srcStageMask, dstStageMask, dependencyFlags, 1, &memoryBarrier, 0, nullptr, 0, nullptr); } inline void CommandBuffer::PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, UInt32 memoryBarrierCount, const VkMemoryBarrier* memoryBarriers, UInt32 bufferMemoryBarrierCount, const VkBufferMemoryBarrier* bufferMemoryBarriers, UInt32 imageMemoryBarrierCount, const VkImageMemoryBarrier* imageMemoryBarriers) diff --git a/plugins/Assimp/Plugin.cpp b/plugins/Assimp/Plugin.cpp index 79efd69f0..e84b9f4f5 100644 --- a/plugins/Assimp/Plugin.cpp +++ b/plugins/Assimp/Plugin.cpp @@ -320,7 +320,7 @@ MeshRef LoadMesh(Stream& stream, const MeshParams& parameters) if (normalTangentMatrix.HasScale()) normalTangentMatrix.ApplyScale(1.f / normalTangentMatrix.GetScale()); - VertexBufferRef vertexBuffer = VertexBuffer::New(VertexDeclaration::Get(VertexLayout_XYZ_Normal_UV_Tangent_Skinning), vertexCount, parameters.storage, parameters.vertexBufferFlags | BufferUsage_Dynamic); + VertexBufferRef vertexBuffer = VertexBuffer::New(VertexDeclaration::Get(VertexLayout_XYZ_Normal_UV_Tangent_Skinning), vertexCount, parameters.storage, parameters.vertexBufferFlags); BufferMapper vertexMapper(vertexBuffer, BufferAccess_ReadWrite); SkeletalMeshVertex* vertices = static_cast(vertexMapper.GetPointer()); diff --git a/src/Nazara/Core/PluginManager.cpp b/src/Nazara/Core/PluginManager.cpp index 215854c15..ffbbeda67 100644 --- a/src/Nazara/Core/PluginManager.cpp +++ b/src/Nazara/Core/PluginManager.cpp @@ -113,7 +113,7 @@ namespace Nz } std::filesystem::path path = pluginPath; - if (appendExtension && path.extension() == NAZARA_DYNLIB_EXTENSION) + if (appendExtension && path.extension() != NAZARA_DYNLIB_EXTENSION) path += NAZARA_DYNLIB_EXTENSION; bool exists = false; @@ -159,7 +159,7 @@ namespace Nz return false; } - std::filesystem::path canonicalPath = std::filesystem::canonical(pluginPath); + std::filesystem::path canonicalPath = std::filesystem::canonical(path); s_plugins[canonicalPath] = std::move(library); return true; diff --git a/src/Nazara/VulkanRenderer/VulkanRenderer.cpp b/src/Nazara/VulkanRenderer/VulkanRenderer.cpp index ee06a5bf9..dfc11eeb5 100644 --- a/src/Nazara/VulkanRenderer/VulkanRenderer.cpp +++ b/src/Nazara/VulkanRenderer/VulkanRenderer.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include namespace Nz @@ -53,12 +54,12 @@ namespace Nz return RenderAPI::Vulkan; } - String VulkanRenderer::QueryAPIString() const + std::string VulkanRenderer::QueryAPIString() const { - StringStream ss; + std::ostringstream ss; ss << "Vulkan renderer " << VK_VERSION_MAJOR(APIVersion) << '.' << VK_VERSION_MINOR(APIVersion) << '.' << VK_VERSION_PATCH(APIVersion); - return ss; + return ss.str(); } UInt32 VulkanRenderer::QueryAPIVersion() const From cf396b07925a14102fd5bc7f70bbd6e894d86952 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 26 Mar 2020 23:34:58 +0100 Subject: [PATCH 138/316] Add support for VK_EXT_debug_utils --- examples/VulkanTest/main.cpp | 40 ++++++------ .../Nazara/VulkanRenderer/Wrapper/Buffer.hpp | 2 +- .../VulkanRenderer/Wrapper/CommandBuffer.hpp | 7 +++ .../VulkanRenderer/Wrapper/CommandBuffer.inl | 63 +++++++++++++++++++ .../VulkanRenderer/Wrapper/CommandPool.hpp | 2 +- .../VulkanRenderer/Wrapper/DescriptorPool.hpp | 2 +- .../Wrapper/DescriptorSetLayout.hpp | 2 +- .../Nazara/VulkanRenderer/Wrapper/Device.hpp | 8 ++- .../Wrapper/DeviceFunctions.hpp | 11 ++++ .../VulkanRenderer/Wrapper/DeviceMemory.hpp | 2 +- .../VulkanRenderer/Wrapper/DeviceObject.hpp | 6 +- .../VulkanRenderer/Wrapper/DeviceObject.inl | 56 +++++++++++------ .../Nazara/VulkanRenderer/Wrapper/Fence.hpp | 2 +- .../VulkanRenderer/Wrapper/Framebuffer.hpp | 2 +- .../Nazara/VulkanRenderer/Wrapper/Image.hpp | 2 +- .../VulkanRenderer/Wrapper/ImageView.hpp | 2 +- .../Wrapper/InstanceFunctions.hpp | 10 +-- .../VulkanRenderer/Wrapper/PipelineCache.hpp | 2 +- .../VulkanRenderer/Wrapper/PipelineLayout.hpp | 2 +- .../VulkanRenderer/Wrapper/RenderPass.hpp | 2 +- .../Nazara/VulkanRenderer/Wrapper/Sampler.hpp | 2 +- .../VulkanRenderer/Wrapper/Semaphore.hpp | 2 +- .../VulkanRenderer/Wrapper/ShaderModule.hpp | 2 +- .../VulkanRenderer/Wrapper/Swapchain.hpp | 2 +- src/Nazara/VulkanRenderer/Vulkan.cpp | 3 + src/Nazara/VulkanRenderer/Wrapper/Device.cpp | 11 +++- 26 files changed, 185 insertions(+), 62 deletions(-) diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index 1e38c6260..d4e2ba25d 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -7,16 +7,15 @@ #include VKAPI_ATTR VkBool32 VKAPI_CALL MyDebugReportCallback( - VkDebugReportFlagsEXT flags, - VkDebugReportObjectTypeEXT objectType, - uint64_t object, - size_t location, - int32_t messageCode, - const char* pLayerPrefix, - const char* pMessage, - void* pUserData) + VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, + VkDebugUtilsMessageTypeFlagsEXT messageTypes, + const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, + void* pUserData) { - std::cerr << pMessage << std::endl; + if (pCallbackData->messageIdNumber != 0) + std::cerr << "#" << pCallbackData->messageIdNumber << " " << pCallbackData->messageIdNumber << ": "; + + std::cerr << pCallbackData->pMessage << std::endl; return VK_FALSE; } @@ -44,15 +43,15 @@ int main() Nz::Vk::Instance& instance = Nz::Vulkan::GetInstance(); - VkDebugReportCallbackCreateInfoEXT callbackCreateInfo = {}; - callbackCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT; - callbackCreateInfo.flags = VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT | VK_DEBUG_REPORT_DEBUG_BIT_EXT ; - callbackCreateInfo.pfnCallback = &MyDebugReportCallback; + VkDebugUtilsMessengerCreateInfoEXT callbackCreateInfo = { VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT }; + callbackCreateInfo.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT; + callbackCreateInfo.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT; + callbackCreateInfo.pfnUserCallback = &MyDebugReportCallback; /* Register the callback */ - VkDebugReportCallbackEXT callback; + VkDebugUtilsMessengerEXT callback; - instance.vkCreateDebugReportCallbackEXT(instance, &callbackCreateInfo, nullptr, &callback); + instance.vkCreateDebugUtilsMessengerEXT(instance, &callbackCreateInfo, nullptr, &callback); std::vector layerProperties; @@ -216,9 +215,6 @@ int main() std::unique_ptr pipeline = device->InstantiateRenderPipeline(pipelineInfo); - Nz::VulkanRenderPipeline::CreateInfo pipelineCreateInfo = Nz::VulkanRenderPipeline::BuildCreateInfo(pipelineInfo); - pipelineCreateInfo.pipelineInfo.renderPass = vulkanWindow.GetRenderPass(); - std::array clearValues; clearValues[0].color = {0.0f, 0.0f, 0.0f, 0.0f}; clearValues[1].depthStencil = {1.f, 0}; @@ -276,7 +272,7 @@ int main() }; renderCmd.Begin(); - + renderCmd.BeginDebugRegion("Main window rendering", Nz::Color::Green); renderCmd.BeginRenderPass(render_pass_begin_info); renderCmd.BindIndexBuffer(indexBufferImpl->GetBuffer(), 0, VK_INDEX_TYPE_UINT16); renderCmd.BindVertexBuffer(0, vertexBufferImpl->GetBuffer(), 0); @@ -286,6 +282,7 @@ int main() renderCmd.SetViewport({0.f, 0.f, float(windowSize.x), float(windowSize.y)}, 0.f, 1.f); renderCmd.DrawIndexed(drfreakIB->GetIndexCount()); renderCmd.EndRenderPass(); + renderCmd.EndDebugRegion(); if (!renderCmd.End()) { @@ -314,6 +311,7 @@ int main() Nz::Vk::CommandPool transientPool; transientPool.Create(vulkanDevice, 0, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT); + transientPool.SetDebugName("Transient command pool"); std::vector frameSync(MaxConcurrentImage); for (ImageData& syncData : frameSync) @@ -424,9 +422,11 @@ int main() std::memcpy(allocData->mappedPtr, &ubo, sizeof(ubo)); frame.commandBuffer->Begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT); + frame.commandBuffer->BeginDebugRegion("UBO Update", Nz::Color::Yellow); frame.commandBuffer->MemoryBarrier(VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0U, VK_ACCESS_TRANSFER_READ_BIT); frame.commandBuffer->CopyBuffer(allocData->buffer, static_cast(uniformBuffer.get())->GetBuffer(), allocData->size, allocData->offset); frame.commandBuffer->MemoryBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_UNIFORM_READ_BIT); + frame.commandBuffer->EndDebugRegion(); frame.commandBuffer->End(); if (!graphicsQueue.Submit(frame.commandBuffer)) @@ -462,7 +462,7 @@ int main() currentFrame = (currentFrame + 1) % imageCount; } - instance.vkDestroyDebugReportCallbackEXT(instance, callback, nullptr); + instance.vkDestroyDebugUtilsMessengerEXT(instance, callback, nullptr); return EXIT_SUCCESS; } diff --git a/include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp b/include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp index 4dba01ec1..8e868df14 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Buffer.hpp @@ -14,7 +14,7 @@ namespace Nz { namespace Vk { - class Buffer : public DeviceObject + class Buffer : public DeviceObject { friend DeviceObject; diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp index bac7e5f61..47982a0be 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp @@ -8,6 +8,7 @@ #define NAZARA_VULKANRENDERER_VKCOMMANDBUFFER_HPP #include +#include #include #include #include @@ -33,6 +34,8 @@ namespace Nz 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 void BeginDebugRegion(const char* label); + inline void BeginDebugRegion(const char* label, Nz::Color color); inline void BeginRenderPass(const VkRenderPassBeginInfo& beginInfo, VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE); inline void BindDescriptorSet(VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, UInt32 firstSet, const VkDescriptorSet& descriptorSets); @@ -60,10 +63,14 @@ namespace Nz inline bool End(); + inline void EndDebugRegion(); inline void EndRenderPass(); inline void Free(); + inline void InsertDebugLabel(const char* label); + inline void InsertDebugLabel(const char* label, Nz::Color color); + inline void MemoryBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask); inline void PipelineBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, const VkImageMemoryBarrier& imageMemoryBarrier); diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl index 9b2558a63..a34dde3f5 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl @@ -118,6 +118,34 @@ namespace Nz return Begin(beginInfo); } + inline void CommandBuffer::BeginDebugRegion(const char* label) + { + Vk::Device* device = m_pool->GetDevice(); + if (device->vkCmdBeginDebugUtilsLabelEXT) + { + VkDebugUtilsLabelEXT debugLabel = { VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT }; + debugLabel.pLabelName = label; + + device->vkCmdBeginDebugUtilsLabelEXT(m_handle, &debugLabel); + } + } + + inline void CommandBuffer::BeginDebugRegion(const char* label, Nz::Color color) + { + Vk::Device* device = m_pool->GetDevice(); + if (device->vkCmdBeginDebugUtilsLabelEXT) + { + VkDebugUtilsLabelEXT debugLabel = { VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT }; + debugLabel.pLabelName = label; + debugLabel.color[0] = color.r / 255.f; + debugLabel.color[1] = color.g / 255.f; + debugLabel.color[2] = color.b / 255.f; + debugLabel.color[3] = color.a / 255.f; + + device->vkCmdBeginDebugUtilsLabelEXT(m_handle, &debugLabel); + } + } + inline void CommandBuffer::BeginRenderPass(const VkRenderPassBeginInfo& beginInfo, VkSubpassContents contents) { return m_pool->GetDevice()->vkCmdBeginRenderPass(m_handle, &beginInfo, contents); @@ -243,6 +271,13 @@ namespace Nz return true; } + inline void CommandBuffer::EndDebugRegion() + { + Vk::Device* device = m_pool->GetDevice(); + if (device->vkCmdEndDebugUtilsLabelEXT) + device->vkCmdEndDebugUtilsLabelEXT(m_handle); + } + inline void CommandBuffer::EndRenderPass() { return m_pool->GetDevice()->vkCmdEndRenderPass(m_handle); @@ -257,6 +292,34 @@ namespace Nz } } + inline void CommandBuffer::InsertDebugLabel(const char* label) + { + Vk::Device* device = m_pool->GetDevice(); + if (device->vkCmdInsertDebugUtilsLabelEXT) + { + VkDebugUtilsLabelEXT debugLabel = { VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT }; + debugLabel.pLabelName = label; + + device->vkCmdInsertDebugUtilsLabelEXT(m_handle, &debugLabel); + } + } + + inline void CommandBuffer::InsertDebugLabel(const char* label, Nz::Color color) + { + Vk::Device* device = m_pool->GetDevice(); + if (device->vkCmdInsertDebugUtilsLabelEXT) + { + VkDebugUtilsLabelEXT debugLabel = { VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT }; + debugLabel.pLabelName = label; + debugLabel.color[0] = color.r / 255.f; + debugLabel.color[1] = color.g / 255.f; + debugLabel.color[2] = color.b / 255.f; + debugLabel.color[3] = color.a / 255.f; + + device->vkCmdInsertDebugUtilsLabelEXT(m_handle, &debugLabel); + } + } + inline void CommandBuffer::MemoryBarrier(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask) { VkMemoryBarrier memoryBarrier = { diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandPool.hpp b/include/Nazara/VulkanRenderer/Wrapper/CommandPool.hpp index 807f26f19..fbe253bd1 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandPool.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandPool.hpp @@ -16,7 +16,7 @@ namespace Nz { class CommandBuffer; - class NAZARA_VULKANRENDERER_API CommandPool : public DeviceObject + class NAZARA_VULKANRENDERER_API CommandPool : public DeviceObject { friend DeviceObject; diff --git a/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp b/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp index 890b882d2..ee68a6e32 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorPool.hpp @@ -16,7 +16,7 @@ namespace Nz { class DescriptorSet; - class NAZARA_VULKANRENDERER_API DescriptorPool : public DeviceObject + class NAZARA_VULKANRENDERER_API DescriptorPool : public DeviceObject { friend DeviceObject; diff --git a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.hpp b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.hpp index 81ef4849e..c49fadcf2 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DescriptorSetLayout.hpp @@ -14,7 +14,7 @@ namespace Nz { namespace Vk { - class DescriptorSetLayout : public DeviceObject + class DescriptorSetLayout : public DeviceObject { friend DeviceObject; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp index e1c5e48de..86c42ad5f 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp @@ -22,7 +22,7 @@ namespace Nz { namespace Vk { - class CommandBuffer; + class AutoCommandBuffer; class Instance; class QueueHandle; @@ -38,7 +38,7 @@ namespace Nz Device(Device&&) = delete; ~Device(); - CommandBuffer AllocateTransferCommandBuffer(); + AutoCommandBuffer AllocateTransferCommandBuffer(); bool Create(const Vk::PhysicalDevice& deviceInfo, const VkDeviceCreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); inline void Destroy(); @@ -71,6 +71,8 @@ namespace Nz #define NAZARA_VULKANRENDERER_DEVICE_CORE_EXT_FUNCTION(func, ...) NAZARA_VULKANRENDERER_DEVICE_FUNCTION(func) #define NAZARA_VULKANRENDERER_DEVICE_EXT_BEGIN(ext) #define NAZARA_VULKANRENDERER_DEVICE_EXT_END() +#define NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(ext) +#define NAZARA_VULKANRENDERER_INSTANCE_EXT_END() #include @@ -78,6 +80,8 @@ namespace Nz #undef NAZARA_VULKANRENDERER_DEVICE_FUNCTION #undef NAZARA_VULKANRENDERER_DEVICE_EXT_BEGIN #undef NAZARA_VULKANRENDERER_DEVICE_EXT_END +#undef NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN +#undef NAZARA_VULKANRENDERER_INSTANCE_EXT_END struct QueueInfo { diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceFunctions.hpp b/include/Nazara/VulkanRenderer/Wrapper/DeviceFunctions.hpp index 6c76c4e7e..8c68aa569 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceFunctions.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceFunctions.hpp @@ -144,3 +144,14 @@ NAZARA_VULKANRENDERER_DEVICE_EXT_BEGIN(VK_KHR_swapchain) NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkGetSwapchainImagesKHR) NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkQueuePresentKHR) NAZARA_VULKANRENDERER_DEVICE_EXT_END() + +NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(VK_EXT_debug_utils) + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdBeginDebugUtilsLabelEXT) + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdEndDebugUtilsLabelEXT) + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkCmdInsertDebugUtilsLabelEXT) + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkQueueBeginDebugUtilsLabelEXT) + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkQueueEndDebugUtilsLabelEXT) + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkQueueInsertDebugUtilsLabelEXT) + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkSetDebugUtilsObjectNameEXT) + NAZARA_VULKANRENDERER_DEVICE_FUNCTION(vkSetDebugUtilsObjectTagEXT) +NAZARA_VULKANRENDERER_INSTANCE_EXT_END() diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp b/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp index e750779b4..490a95095 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp @@ -15,7 +15,7 @@ namespace Nz { namespace Vk { - class DeviceMemory : public DeviceObject + class DeviceMemory : public DeviceObject { friend DeviceObject; diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp index 4ce478418..e16b73c16 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp @@ -11,12 +11,13 @@ #include #include #include +#include namespace Nz { namespace Vk { - template + template class DeviceObject { public: @@ -33,6 +34,9 @@ namespace Nz Device* GetDevice() const; VkResult GetLastErrorCode() const; + void SetDebugName(const char* name); + void SetDebugName(const std::string& name); + DeviceObject& operator=(const DeviceObject&) = delete; DeviceObject& operator=(DeviceObject&&) = delete; diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl index fcc5245d1..e6728d016 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl @@ -13,14 +13,14 @@ namespace Nz { namespace Vk { - template - DeviceObject::DeviceObject() : + template + DeviceObject::DeviceObject() : m_handle(VK_NULL_HANDLE) { } - template - DeviceObject::DeviceObject(DeviceObject&& object) noexcept : + template + DeviceObject::DeviceObject(DeviceObject&& object) noexcept : m_device(std::move(object.m_device)), m_allocator(object.m_allocator), m_handle(object.m_handle), @@ -29,14 +29,14 @@ namespace Nz object.m_handle = VK_NULL_HANDLE; } - template - DeviceObject::~DeviceObject() + template + DeviceObject::~DeviceObject() { Destroy(); } - template - bool DeviceObject::Create(Device& device, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator) + template + bool DeviceObject::Create(Device& device, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator) { m_device = &device; m_lastErrorCode = C::CreateHelper(*m_device, &createInfo, allocator, &m_handle); @@ -55,8 +55,8 @@ namespace Nz return true; } - template - void DeviceObject::Destroy() + template + void DeviceObject::Destroy() { if (IsValid()) { @@ -65,26 +65,46 @@ namespace Nz } } - template - bool DeviceObject::IsValid() const + template + bool DeviceObject::IsValid() const { return m_handle != VK_NULL_HANDLE; } - template - Device* DeviceObject::GetDevice() const + template + Device* DeviceObject::GetDevice() const { return m_device; } - template - VkResult DeviceObject::GetLastErrorCode() const + template + VkResult DeviceObject::GetLastErrorCode() const { return m_lastErrorCode; } - template - DeviceObject::operator VkType() const + template + void DeviceObject::SetDebugName(const char* name) + { + if (m_device->vkSetDebugUtilsObjectNameEXT) + { + VkDebugUtilsObjectNameInfoEXT debugName = { VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT }; + debugName.objectType = ObjectType; + debugName.objectHandle = static_cast(reinterpret_cast(m_handle)); + debugName.pObjectName = name; + + m_device->vkSetDebugUtilsObjectNameEXT(*m_device, &debugName); + } + } + + template + void DeviceObject::SetDebugName(const std::string& name) + { + return SetDebugName(name.data()); + } + + template + DeviceObject::operator VkType() const { return m_handle; } diff --git a/include/Nazara/VulkanRenderer/Wrapper/Fence.hpp b/include/Nazara/VulkanRenderer/Wrapper/Fence.hpp index 054083a3a..b4b5939df 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Fence.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Fence.hpp @@ -14,7 +14,7 @@ namespace Nz { namespace Vk { - class Fence : public DeviceObject + class Fence : public DeviceObject { friend DeviceObject; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.hpp b/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.hpp index 014d1e205..8dd3446a0 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Framebuffer.hpp @@ -14,7 +14,7 @@ namespace Nz { namespace Vk { - class Framebuffer : public DeviceObject + class Framebuffer : public DeviceObject { friend DeviceObject; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Image.hpp b/include/Nazara/VulkanRenderer/Wrapper/Image.hpp index 3c6cdc0e1..14ff705d0 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Image.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Image.hpp @@ -14,7 +14,7 @@ namespace Nz { namespace Vk { - class Image : public DeviceObject + class Image : public DeviceObject { friend DeviceObject; diff --git a/include/Nazara/VulkanRenderer/Wrapper/ImageView.hpp b/include/Nazara/VulkanRenderer/Wrapper/ImageView.hpp index 957453774..78c99d9b4 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/ImageView.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/ImageView.hpp @@ -14,7 +14,7 @@ namespace Nz { namespace Vk { - class ImageView : public DeviceObject + class ImageView : public DeviceObject { friend DeviceObject; diff --git a/include/Nazara/VulkanRenderer/Wrapper/InstanceFunctions.hpp b/include/Nazara/VulkanRenderer/Wrapper/InstanceFunctions.hpp index 25e9235c0..ec258bbc3 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/InstanceFunctions.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/InstanceFunctions.hpp @@ -41,10 +41,12 @@ NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(VK_KHR_surface) NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfaceSupportKHR) NAZARA_VULKANRENDERER_INSTANCE_EXT_END() -NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(VK_EXT_debug_report) - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateDebugReportCallbackEXT) - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkDestroyDebugReportCallbackEXT) - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkDebugReportMessageEXT) +NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(VK_EXT_debug_utils) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateDebugUtilsMessengerEXT) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkDestroyDebugUtilsMessengerEXT) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkSetDebugUtilsObjectNameEXT) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkSetDebugUtilsObjectTagEXT) + NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkSubmitDebugUtilsMessageEXT) NAZARA_VULKANRENDERER_INSTANCE_EXT_END() #ifdef VK_USE_PLATFORM_ANDROID_KHR diff --git a/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.hpp b/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.hpp index 8c923c311..eb697b9ed 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/PipelineCache.hpp @@ -14,7 +14,7 @@ namespace Nz { namespace Vk { - class PipelineCache : public DeviceObject + class PipelineCache : public DeviceObject { friend DeviceObject; diff --git a/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp b/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp index ad97ca925..9db58733d 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/PipelineLayout.hpp @@ -14,7 +14,7 @@ namespace Nz { namespace Vk { - class PipelineLayout : public DeviceObject + class PipelineLayout : public DeviceObject { friend DeviceObject; diff --git a/include/Nazara/VulkanRenderer/Wrapper/RenderPass.hpp b/include/Nazara/VulkanRenderer/Wrapper/RenderPass.hpp index de95bfcca..c8b93093a 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/RenderPass.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/RenderPass.hpp @@ -14,7 +14,7 @@ namespace Nz { namespace Vk { - class RenderPass : public DeviceObject + class RenderPass : public DeviceObject { friend DeviceObject; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Sampler.hpp b/include/Nazara/VulkanRenderer/Wrapper/Sampler.hpp index 8cbde84d1..1fa92b55a 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Sampler.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Sampler.hpp @@ -14,7 +14,7 @@ namespace Nz { namespace Vk { - class Sampler : public DeviceObject + class Sampler : public DeviceObject { friend DeviceObject; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Semaphore.hpp b/include/Nazara/VulkanRenderer/Wrapper/Semaphore.hpp index b42cd8c27..62084b9b6 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Semaphore.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Semaphore.hpp @@ -14,7 +14,7 @@ namespace Nz { namespace Vk { - class Semaphore : public DeviceObject + class Semaphore : public DeviceObject { friend DeviceObject; diff --git a/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp b/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp index caacaccea..d3724d464 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp @@ -14,7 +14,7 @@ namespace Nz { namespace Vk { - class ShaderModule : public DeviceObject + class ShaderModule : public DeviceObject { friend DeviceObject; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp b/include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp index d8d611585..399ca909f 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp @@ -15,7 +15,7 @@ namespace Nz { namespace Vk { - class Swapchain : public DeviceObject + class Swapchain : public DeviceObject { friend DeviceObject; diff --git a/src/Nazara/VulkanRenderer/Vulkan.cpp b/src/Nazara/VulkanRenderer/Vulkan.cpp index c60650158..ff9095478 100644 --- a/src/Nazara/VulkanRenderer/Vulkan.cpp +++ b/src/Nazara/VulkanRenderer/Vulkan.cpp @@ -166,6 +166,9 @@ namespace Nz if (availableExtensions.count(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME)) enabledExtensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); + + if (availableExtensions.count(VK_EXT_DEBUG_UTILS_EXTENSION_NAME)) + enabledExtensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME); } std::vector additionalExtensions; // Just to keep the String alive diff --git a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp index 6d0248bef..49d22d586 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp @@ -40,7 +40,7 @@ namespace Nz WaitAndDestroyDevice(); } - CommandBuffer Device::AllocateTransferCommandBuffer() + AutoCommandBuffer Device::AllocateTransferCommandBuffer() { return m_internalData->transferCommandPool.AllocateCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY); } @@ -82,6 +82,9 @@ namespace Nz #define NAZARA_VULKANRENDERER_DEVICE_EXT_END() } #define NAZARA_VULKANRENDERER_DEVICE_FUNCTION(func) func = reinterpret_cast(GetProcAddr(#func)); +#define NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(ext) if (m_instance.IsExtensionLoaded(#ext)) { +#define NAZARA_VULKANRENDERER_INSTANCE_EXT_END() } + #define NAZARA_VULKANRENDERER_DEVICE_CORE_EXT_FUNCTION(func, coreVersion, suffix, extName) \ if (deviceVersion >= coreVersion) \ func = reinterpret_cast(GetProcAddr(#func)); \ @@ -94,6 +97,8 @@ namespace Nz #undef NAZARA_VULKANRENDERER_DEVICE_EXT_BEGIN #undef NAZARA_VULKANRENDERER_DEVICE_EXT_END #undef NAZARA_VULKANRENDERER_DEVICE_FUNCTION +#undef NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN +#undef NAZARA_VULKANRENDERER_INSTANCE_EXT_END } catch (const std::exception& e) { @@ -239,6 +244,8 @@ namespace Nz #define NAZARA_VULKANRENDERER_DEVICE_CORE_EXT_FUNCTION(func, ...) NAZARA_VULKANRENDERER_DEVICE_FUNCTION(func) #define NAZARA_VULKANRENDERER_DEVICE_EXT_BEGIN(ext) #define NAZARA_VULKANRENDERER_DEVICE_EXT_END() +#define NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(ext) +#define NAZARA_VULKANRENDERER_INSTANCE_EXT_END() #include @@ -246,6 +253,8 @@ namespace Nz #undef NAZARA_VULKANRENDERER_DEVICE_FUNCTION #undef NAZARA_VULKANRENDERER_DEVICE_EXT_BEGIN #undef NAZARA_VULKANRENDERER_DEVICE_EXT_END +#undef NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN +#undef NAZARA_VULKANRENDERER_INSTANCE_EXT_END } void Device::WaitAndDestroyDevice() From f443bec6bcf8c95b528434d7d11a6e4b25b34b9b Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 2 Apr 2020 21:07:01 +0200 Subject: [PATCH 139/316] Add command buffers (WIP) --- examples/VulkanTest/main.cpp | 149 ++++++------------ include/Nazara/Renderer.hpp | 5 + include/Nazara/Renderer/CommandBuffer.hpp | 30 ++++ include/Nazara/Renderer/CommandBuffer.inl | 12 ++ .../Nazara/Renderer/CommandBufferBuilder.hpp | 59 +++++++ .../Nazara/Renderer/CommandBufferBuilder.inl | 21 +++ include/Nazara/Renderer/RenderBuffer.hpp | 7 +- include/Nazara/Renderer/RenderBufferView.hpp | 41 +++++ include/Nazara/Renderer/RenderBufferView.inl | 39 +++++ include/Nazara/Renderer/RenderImage.hpp | 42 +++++ include/Nazara/Renderer/RenderImage.inl | 12 ++ include/Nazara/Renderer/RenderWindowImpl.hpp | 9 +- include/Nazara/Renderer/UploadPool.hpp | 52 ++++++ include/Nazara/Renderer/UploadPool.inl | 12 ++ include/Nazara/Utility/AbstractBuffer.hpp | 7 +- include/Nazara/Utility/SoftwareBuffer.hpp | 9 +- include/Nazara/VulkanRenderer.hpp | 3 + .../Nazara/VulkanRenderer/VkRenderTarget.hpp | 4 - .../Nazara/VulkanRenderer/VkRenderWindow.hpp | 22 ++- .../Nazara/VulkanRenderer/VkRenderWindow.inl | 18 ++- include/Nazara/VulkanRenderer/Vulkan.hpp | 4 +- .../Nazara/VulkanRenderer/VulkanBuffer.hpp | 11 +- .../VulkanRenderer/VulkanCommandBuffer.hpp | 37 +++++ .../VulkanRenderer/VulkanCommandBuffer.inl | 21 +++ .../VulkanCommandBufferBuilder.hpp | 57 +++++++ .../VulkanCommandBufferBuilder.inl | 21 +++ .../VulkanRenderer/VulkanRenderImage.hpp | 65 ++++++++ .../VulkanRenderer/VulkanRenderImage.inl | 39 +++++ .../VulkanRenderer/VulkanShaderBinding.hpp | 1 + .../VulkanRenderer/VulkanShaderBinding.inl | 5 + .../VulkanRenderer/VulkanUploadPool.hpp | 23 ++- .../VulkanRenderer/Wrapper/CommandBuffer.hpp | 4 +- .../VulkanRenderer/Wrapper/CommandBuffer.inl | 7 +- .../VulkanRenderer/Wrapper/QueueHandle.hpp | 4 +- .../VulkanRenderer/Wrapper/QueueHandle.inl | 10 +- src/Nazara/Renderer/CommandBuffer.cpp | 11 ++ src/Nazara/Renderer/CommandBufferBuilder.cpp | 11 ++ src/Nazara/Renderer/RenderBuffer.cpp | 11 +- src/Nazara/Renderer/RenderImage.cpp | 11 ++ src/Nazara/Renderer/UploadPool.cpp | 12 ++ src/Nazara/Utility/SoftwareBuffer.cpp | 15 +- src/Nazara/VulkanRenderer/VkRenderWindow.cpp | 78 +++++++-- src/Nazara/VulkanRenderer/Vulkan.cpp | 27 +++- src/Nazara/VulkanRenderer/VulkanBuffer.cpp | 11 +- .../VulkanRenderer/VulkanCommandBuffer.cpp | 10 ++ .../VulkanCommandBufferBuilder.cpp | 98 ++++++++++++ .../VulkanRenderer/VulkanRenderImage.cpp | 93 +++++++++++ .../VulkanRenderPipelineLayout.cpp | 10 +- .../VulkanRenderer/VulkanUploadPool.cpp | 29 ++-- src/Nazara/VulkanRenderer/Wrapper/Device.cpp | 2 +- 50 files changed, 1076 insertions(+), 215 deletions(-) create mode 100644 include/Nazara/Renderer/CommandBuffer.hpp create mode 100644 include/Nazara/Renderer/CommandBuffer.inl create mode 100644 include/Nazara/Renderer/CommandBufferBuilder.hpp create mode 100644 include/Nazara/Renderer/CommandBufferBuilder.inl create mode 100644 include/Nazara/Renderer/RenderBufferView.hpp create mode 100644 include/Nazara/Renderer/RenderBufferView.inl create mode 100644 include/Nazara/Renderer/RenderImage.hpp create mode 100644 include/Nazara/Renderer/RenderImage.inl create mode 100644 include/Nazara/Renderer/UploadPool.hpp create mode 100644 include/Nazara/Renderer/UploadPool.inl create mode 100644 include/Nazara/VulkanRenderer/VulkanCommandBuffer.hpp create mode 100644 include/Nazara/VulkanRenderer/VulkanCommandBuffer.inl create mode 100644 include/Nazara/VulkanRenderer/VulkanCommandBufferBuilder.hpp create mode 100644 include/Nazara/VulkanRenderer/VulkanCommandBufferBuilder.inl create mode 100644 include/Nazara/VulkanRenderer/VulkanRenderImage.hpp create mode 100644 include/Nazara/VulkanRenderer/VulkanRenderImage.inl create mode 100644 src/Nazara/Renderer/CommandBuffer.cpp create mode 100644 src/Nazara/Renderer/CommandBufferBuilder.cpp create mode 100644 src/Nazara/Renderer/RenderImage.cpp create mode 100644 src/Nazara/Renderer/UploadPool.cpp create mode 100644 src/Nazara/VulkanRenderer/VulkanCommandBuffer.cpp create mode 100644 src/Nazara/VulkanRenderer/VulkanCommandBufferBuilder.cpp create mode 100644 src/Nazara/VulkanRenderer/VulkanRenderImage.cpp diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index d4e2ba25d..9612cacd9 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -114,18 +114,6 @@ int main() // Vertex buffer std::cout << "Vertex count: " << drfreakVB->GetVertexCount() << std::endl; - Nz::VkRenderWindow& vulkanWindow = *static_cast(window.GetImpl()); - Nz::VulkanDevice& vulkanDevice = vulkanWindow.GetDevice(); - - Nz::Vk::CommandPool cmdPool; - if (!cmdPool.Create(vulkanDevice, 0, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)) - { - NazaraError("Failed to create rendering cmd pool"); - return __LINE__; - } - - Nz::Vk::QueueHandle graphicsQueue = vulkanDevice.GetQueue(0, 0); - // Texture Nz::ImageRef drfreakImage = Nz::Image::LoadFromFile("resources/Spaceship/Texture/diffuse.png"); if (!drfreakImage || !drfreakImage->Convert(Nz::PixelFormatType_RGBA8)) @@ -219,8 +207,11 @@ int main() clearValues[0].color = {0.0f, 0.0f, 0.0f, 0.0f}; clearValues[1].depthStencil = {1.f, 0}; + Nz::VkRenderWindow& vulkanWindow = *static_cast(window.GetImpl()); + Nz::VulkanDevice& vulkanDevice = vulkanWindow.GetDevice(); + Nz::UInt32 imageCount = vulkanWindow.GetFramebufferCount(); - std::vector renderCmds = cmdPool.AllocateCommandBuffers(imageCount, VK_COMMAND_BUFFER_LEVEL_PRIMARY); + std::vector> renderCmds(imageCount); Nz::RenderBuffer* renderBufferIB = static_cast(drfreakIB->GetBuffer()->GetImpl()); Nz::RenderBuffer* renderBufferVB = static_cast(drfreakVB->GetBuffer()->GetImpl()); @@ -237,18 +228,14 @@ int main() return __LINE__; } - Nz::VulkanBuffer* indexBufferImpl = static_cast(renderBufferIB->GetHardwareBuffer(&vulkanDevice)); - Nz::VulkanBuffer* vertexBufferImpl = static_cast(renderBufferVB->GetHardwareBuffer(&vulkanDevice)); + Nz::AbstractBuffer* indexBufferImpl = renderBufferIB->GetHardwareBuffer(&vulkanDevice); + Nz::AbstractBuffer* vertexBufferImpl = renderBufferVB->GetHardwareBuffer(&vulkanDevice); Nz::VulkanRenderPipeline* vkPipeline = static_cast(pipeline.get()); - Nz::VulkanRenderPipelineLayout* vkPipelineLayout = static_cast(renderPipelineLayout.get()); - - Nz::VulkanShaderBinding& vkShaderBinding = static_cast(shaderBinding); - for (Nz::UInt32 i = 0; i < imageCount; ++i) { - Nz::Vk::CommandBuffer& renderCmd = renderCmds[i]; + auto& commandBufferPtr = renderCmds[i]; VkRect2D renderArea = { { // VkOffset2D offset @@ -271,24 +258,29 @@ int main() clearValues.data() // const VkClearValue *pClearValues }; - renderCmd.Begin(); - renderCmd.BeginDebugRegion("Main window rendering", Nz::Color::Green); - renderCmd.BeginRenderPass(render_pass_begin_info); - renderCmd.BindIndexBuffer(indexBufferImpl->GetBuffer(), 0, VK_INDEX_TYPE_UINT16); - renderCmd.BindVertexBuffer(0, vertexBufferImpl->GetBuffer(), 0); - renderCmd.BindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, vkPipelineLayout->GetPipelineLayout(), 0, vkShaderBinding.GetDescriptorSet()); - renderCmd.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, vkPipeline->Get(vulkanWindow.GetRenderPass())); - renderCmd.SetScissor(Nz::Recti{0, 0, int(windowSize.x), int(windowSize.y)}); - renderCmd.SetViewport({0.f, 0.f, float(windowSize.x), float(windowSize.y)}, 0.f, 1.f); - renderCmd.DrawIndexed(drfreakIB->GetIndexCount()); - renderCmd.EndRenderPass(); - renderCmd.EndDebugRegion(); - - if (!renderCmd.End()) + commandBufferPtr = vulkanWindow.BuildCommandBuffer([&](Nz::CommandBufferBuilder& builder) { - NazaraError("Failed to specify render cmd"); - return __LINE__; - } + Nz::Vk::CommandBuffer& vkCommandBuffer = static_cast(builder).GetCommandBuffer(); + + builder.BeginDebugRegion("Main window rendering", Nz::Color::Green); + { + vkCommandBuffer.BeginRenderPass(render_pass_begin_info); + { + builder.BindIndexBuffer(indexBufferImpl); + builder.BindVertexBuffer(0, vertexBufferImpl); + builder.BindShaderBinding(shaderBinding); + + builder.SetScissor(Nz::Recti{ 0, 0, int(windowSize.x), int(windowSize.y) }); + builder.SetViewport(Nz::Recti{ 0, 0, int(windowSize.x), int(windowSize.y) }); + + vkCommandBuffer.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, vkPipeline->Get(vulkanWindow.GetRenderPass())); //< TODO + + builder.DrawIndexed(drfreakIB->GetIndexCount()); + } + vkCommandBuffer.EndRenderPass(); + } + builder.EndDebugRegion(); + }); } Nz::Vector3f viewerPos = Nz::Vector3f::Zero(); @@ -298,38 +290,6 @@ int main() window.EnableEventPolling(true); - struct ImageData - { - Nz::Vk::Fence inflightFence; - Nz::Vk::Semaphore imageAvailableSemaphore; - Nz::Vk::Semaphore renderFinishedSemaphore; - Nz::Vk::AutoCommandBuffer commandBuffer; - std::optional uploadPool; - }; - - const std::size_t MaxConcurrentImage = imageCount; - - Nz::Vk::CommandPool transientPool; - transientPool.Create(vulkanDevice, 0, VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT); - transientPool.SetDebugName("Transient command pool"); - - std::vector frameSync(MaxConcurrentImage); - for (ImageData& syncData : frameSync) - { - syncData.imageAvailableSemaphore.Create(vulkanDevice); - syncData.renderFinishedSemaphore.Create(vulkanDevice); - - syncData.inflightFence.Create(vulkanDevice, VK_FENCE_CREATE_SIGNALED_BIT); - - syncData.uploadPool.emplace(vulkanDevice, 8 * 1024 * 1024); - - syncData.commandBuffer = transientPool.AllocateCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY); - } - - std::vector inflightFences(imageCount, nullptr); - - std::size_t currentFrame = 0; - Nz::Clock updateClock; Nz::Clock secondClock; unsigned int fps = 0; @@ -395,47 +355,30 @@ int main() viewerPos += Nz::Vector3f::Down() * cameraSpeed; } - ImageData& frame = frameSync[currentFrame]; - frame.inflightFence.Wait(); - - Nz::UInt32 imageIndex; - if (!vulkanWindow.Acquire(&imageIndex, frame.imageAvailableSemaphore)) - { - std::cout << "Failed to acquire next image" << std::endl; - return EXIT_FAILURE; - } - - if (inflightFences[imageIndex]) - inflightFences[imageIndex]->Wait(); - - inflightFences[imageIndex] = &frame.inflightFence; - inflightFences[imageIndex]->Reset(); - - // Update UBO - frame.uploadPool->Reset(); + Nz::VulkanRenderImage& renderImage = vulkanWindow.Acquire(); ubo.viewMatrix = Nz::Matrix4f::ViewMatrix(viewerPos, camAngles); - auto allocData = frame.uploadPool->Allocate(uniformSize); - assert(allocData); + auto& allocation = renderImage.GetUploadPool().Allocate(uniformSize); - std::memcpy(allocData->mappedPtr, &ubo, sizeof(ubo)); + std::memcpy(allocation.mappedPtr, &ubo, sizeof(ubo)); - frame.commandBuffer->Begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT); - frame.commandBuffer->BeginDebugRegion("UBO Update", Nz::Color::Yellow); - frame.commandBuffer->MemoryBarrier(VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0U, VK_ACCESS_TRANSFER_READ_BIT); - frame.commandBuffer->CopyBuffer(allocData->buffer, static_cast(uniformBuffer.get())->GetBuffer(), allocData->size, allocData->offset); - frame.commandBuffer->MemoryBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_UNIFORM_READ_BIT); - frame.commandBuffer->EndDebugRegion(); - frame.commandBuffer->End(); + renderImage.Execute([&](Nz::CommandBufferBuilder& builder) + { + builder.BeginDebugRegion("UBO Update", Nz::Color::Yellow); + { + builder.PreTransferBarrier(); + builder.CopyBuffer(allocation, uniformBuffer.get()); + builder.PostTransferBarrier(); + } + builder.EndDebugRegion(); + }, false); - if (!graphicsQueue.Submit(frame.commandBuffer)) - return false; + Nz::UInt32 imageIndex = renderImage.GetImageIndex(); - if (!graphicsQueue.Submit(renderCmds[imageIndex], frame.imageAvailableSemaphore, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, frame.renderFinishedSemaphore, frame.inflightFence)) - return false; + renderImage.SubmitCommandBuffer(renderCmds[imageIndex].get(), true); - vulkanWindow.Present(imageIndex, frame.renderFinishedSemaphore); + renderImage.Present(); // On incrémente le compteur de FPS improvisé fps++; @@ -458,8 +401,6 @@ int main() // Et on relance l'horloge pour refaire ça dans une seconde secondClock.Restart(); } - - currentFrame = (currentFrame + 1) % imageCount; } instance.vkDestroyDebugUtilsMessengerEXT(instance, callback, nullptr); diff --git a/include/Nazara/Renderer.hpp b/include/Nazara/Renderer.hpp index 6ce0da6dc..df330e594 100644 --- a/include/Nazara/Renderer.hpp +++ b/include/Nazara/Renderer.hpp @@ -29,15 +29,19 @@ #ifndef NAZARA_GLOBAL_RENDERER_HPP #define NAZARA_GLOBAL_RENDERER_HPP +#include +#include #include #include #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -52,5 +56,6 @@ #include #include #include +#include #endif // NAZARA_GLOBAL_RENDERER_HPP diff --git a/include/Nazara/Renderer/CommandBuffer.hpp b/include/Nazara/Renderer/CommandBuffer.hpp new file mode 100644 index 000000000..547d0a3f2 --- /dev/null +++ b/include/Nazara/Renderer/CommandBuffer.hpp @@ -0,0 +1,30 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_COMMANDBUFFER_HPP +#define NAZARA_COMMANDBUFFER_HPP + +#include +#include + +namespace Nz +{ + class NAZARA_RENDERER_API CommandBuffer + { + public: + CommandBuffer() = default; + CommandBuffer(const CommandBuffer&) = delete; + CommandBuffer(CommandBuffer&&) = default; + virtual ~CommandBuffer(); + + CommandBuffer& operator=(const CommandBuffer&) = delete; + CommandBuffer& operator=(CommandBuffer&&) = default; + }; +} + +#include + +#endif // NAZARA_COMMANDBUFFER_HPP diff --git a/include/Nazara/Renderer/CommandBuffer.inl b/include/Nazara/Renderer/CommandBuffer.inl new file mode 100644 index 000000000..be4849bd3 --- /dev/null +++ b/include/Nazara/Renderer/CommandBuffer.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ +} + +#include diff --git a/include/Nazara/Renderer/CommandBufferBuilder.hpp b/include/Nazara/Renderer/CommandBufferBuilder.hpp new file mode 100644 index 000000000..5d30a5205 --- /dev/null +++ b/include/Nazara/Renderer/CommandBufferBuilder.hpp @@ -0,0 +1,59 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_COMMANDBUFFERBUILDER_HPP +#define NAZARA_COMMANDBUFFERBUILDER_HPP + +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class ShaderBinding; + + class NAZARA_RENDERER_API CommandBufferBuilder + { + public: + CommandBufferBuilder() = default; + CommandBufferBuilder(const CommandBufferBuilder&) = delete; + CommandBufferBuilder(CommandBufferBuilder&&) = default; + virtual ~CommandBufferBuilder(); + + virtual void BeginDebugRegion(const std::string_view& regionName, const Nz::Color& color) = 0; + + virtual void BindIndexBuffer(Nz::AbstractBuffer* indexBuffer, UInt64 offset = 0) = 0; + virtual void BindShaderBinding(ShaderBinding& binding) = 0; + virtual void BindVertexBuffer(UInt32 binding, Nz::AbstractBuffer* vertexBuffer, UInt64 offset = 0) = 0; + + inline void CopyBuffer(const RenderBufferView& source, const RenderBufferView& target); + virtual void CopyBuffer(const RenderBufferView& source, const RenderBufferView& target, UInt64 size, UInt64 fromOffset = 0, UInt64 toOffset = 0) = 0; + inline void CopyBuffer(const UploadPool::Allocation& allocation, const RenderBufferView& target); + virtual void CopyBuffer(const UploadPool::Allocation& allocation, const RenderBufferView& target, UInt64 size, UInt64 fromOffset = 0, UInt64 toOffset = 0) = 0; + + virtual void Draw(UInt32 vertexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0) = 0; + virtual void DrawIndexed(UInt32 indexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0) = 0; + + virtual void EndDebugRegion() = 0; + + virtual void PreTransferBarrier() = 0; + virtual void PostTransferBarrier() = 0; + + virtual void SetScissor(Nz::Recti scissorRegion) = 0; + virtual void SetViewport(Nz::Recti viewportRegion) = 0; + + CommandBufferBuilder& operator=(const CommandBufferBuilder&) = delete; + CommandBufferBuilder& operator=(CommandBufferBuilder&&) = default; + }; +} + +#include + +#endif // NAZARA_COMMANDBUFFERBUILDER_HPP diff --git a/include/Nazara/Renderer/CommandBufferBuilder.inl b/include/Nazara/Renderer/CommandBufferBuilder.inl new file mode 100644 index 000000000..c0a726580 --- /dev/null +++ b/include/Nazara/Renderer/CommandBufferBuilder.inl @@ -0,0 +1,21 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline void CommandBufferBuilder::CopyBuffer(const RenderBufferView& from, const RenderBufferView& to) + { + return CopyBuffer(from, to, from.GetSize()); + } + + inline void CommandBufferBuilder::CopyBuffer(const UploadPool::Allocation& allocation, const RenderBufferView& target) + { + return CopyBuffer(allocation, target, allocation.size); + } +} + +#include diff --git a/include/Nazara/Renderer/RenderBuffer.hpp b/include/Nazara/Renderer/RenderBuffer.hpp index 9e501a002..897270ac2 100644 --- a/include/Nazara/Renderer/RenderBuffer.hpp +++ b/include/Nazara/Renderer/RenderBuffer.hpp @@ -27,14 +27,15 @@ namespace Nz RenderBuffer(RenderBuffer&&) = default; ~RenderBuffer() = default; - bool Fill(const void* data, UInt32 offset, UInt32 size) final; + bool Fill(const void* data, UInt64 offset, UInt64 size) final; - bool Initialize(UInt32 size, BufferUsageFlags usage) override; + bool Initialize(UInt64 size, BufferUsageFlags usage) override; AbstractBuffer* GetHardwareBuffer(RenderDevice* device); + UInt64 GetSize() const override; DataStorage GetStorage() const override; - void* Map(BufferAccess access, UInt32 offset = 0, UInt32 size = 0) final; + void* Map(BufferAccess access, UInt64 offset = 0, UInt64 size = 0) final; bool Unmap() final; RenderBuffer& operator=(const RenderBuffer&) = delete; diff --git a/include/Nazara/Renderer/RenderBufferView.hpp b/include/Nazara/Renderer/RenderBufferView.hpp new file mode 100644 index 000000000..f653866eb --- /dev/null +++ b/include/Nazara/Renderer/RenderBufferView.hpp @@ -0,0 +1,41 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_RENDERBUFFERVIEW_HPP +#define NAZARA_RENDERBUFFERVIEW_HPP + +#include +#include +#include + +namespace Nz +{ + class RenderBufferView + { + public: + inline RenderBufferView(AbstractBuffer* buffer); + inline RenderBufferView(AbstractBuffer* buffer, UInt64 offset, UInt64 size); + RenderBufferView(const RenderBufferView&) = delete; + RenderBufferView(RenderBufferView&&) = default; + ~RenderBufferView() = default; + + inline AbstractBuffer* GetBuffer() const; + inline UInt64 GetOffset() const; + inline UInt64 GetSize() const; + + RenderBufferView& operator=(const RenderBufferView&) = delete; + RenderBufferView& operator=(RenderBufferView&&) = default; + + private: + UInt64 m_offset; + UInt64 m_size; + AbstractBuffer* m_buffer; + }; +} + +#include + +#endif // NAZARA_RENDERBUFFERVIEW_HPP diff --git a/include/Nazara/Renderer/RenderBufferView.inl b/include/Nazara/Renderer/RenderBufferView.inl new file mode 100644 index 000000000..a0cb08aa5 --- /dev/null +++ b/include/Nazara/Renderer/RenderBufferView.inl @@ -0,0 +1,39 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + inline RenderBufferView::RenderBufferView(AbstractBuffer* buffer) : + RenderBufferView(buffer, 0, buffer->GetSize()) + { + } + + inline RenderBufferView::RenderBufferView(AbstractBuffer* buffer, UInt64 offset, UInt64 size) : + m_buffer(buffer), + m_offset(offset), + m_size(size) + { + } + + inline AbstractBuffer* RenderBufferView::GetBuffer() const + { + return m_buffer; + } + + inline UInt64 RenderBufferView::GetOffset() const + { + return m_offset; + } + + inline UInt64 RenderBufferView::GetSize() const + { + return m_size; + } +} + +#include diff --git a/include/Nazara/Renderer/RenderImage.hpp b/include/Nazara/Renderer/RenderImage.hpp new file mode 100644 index 000000000..2661f45c7 --- /dev/null +++ b/include/Nazara/Renderer/RenderImage.hpp @@ -0,0 +1,42 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_RENDERIMAGE_HPP +#define NAZARA_RENDERIMAGE_HPP + +#include +#include +#include + +namespace Nz +{ + class CommandBuffer; + class CommandBufferBuilder; + class UploadPool; + + class NAZARA_RENDERER_API RenderImage + { + public: + RenderImage() = default; + virtual ~RenderImage(); + + virtual void Execute(const std::function& callback, bool isGraphical) = 0; + + virtual UploadPool& GetUploadPool() = 0; + + virtual void SubmitCommandBuffer(CommandBuffer* commandBuffer, bool isGraphical) = 0; + + virtual void Present() = 0; + + protected: + RenderImage(const RenderImage&) = delete; + RenderImage(RenderImage&&) = default; + }; +} + +#include + +#endif // NAZARA_RENDERIMAGE_HPP diff --git a/include/Nazara/Renderer/RenderImage.inl b/include/Nazara/Renderer/RenderImage.inl new file mode 100644 index 000000000..20f3103f8 --- /dev/null +++ b/include/Nazara/Renderer/RenderImage.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ +} + +#include diff --git a/include/Nazara/Renderer/RenderWindowImpl.hpp b/include/Nazara/Renderer/RenderWindowImpl.hpp index df67001c5..f0636e77a 100644 --- a/include/Nazara/Renderer/RenderWindowImpl.hpp +++ b/include/Nazara/Renderer/RenderWindowImpl.hpp @@ -13,11 +13,14 @@ #include #include #include -#include +#include namespace Nz { + class CommandBuffer; + class CommandBufferBuilder; class RendererImpl; + class RenderImage; class RenderSurface; class NAZARA_RENDERER_API RenderWindowImpl @@ -26,6 +29,10 @@ namespace Nz RenderWindowImpl() = default; virtual ~RenderWindowImpl(); + virtual RenderImage& Acquire() = 0; + + virtual std::unique_ptr BuildCommandBuffer(const std::function& callback) = 0; + virtual bool Create(RendererImpl* renderer, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) = 0; virtual std::shared_ptr GetRenderDevice() = 0; diff --git a/include/Nazara/Renderer/UploadPool.hpp b/include/Nazara/Renderer/UploadPool.hpp new file mode 100644 index 000000000..85368e413 --- /dev/null +++ b/include/Nazara/Renderer/UploadPool.hpp @@ -0,0 +1,52 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_RENDERER_UPLOADPOOL_HPP +#define NAZARA_RENDERER_UPLOADPOOL_HPP + +#include +#include + +namespace Nz +{ + class NAZARA_RENDERER_API UploadPool + { + public: + struct Allocation; + + UploadPool() = default; + UploadPool(const UploadPool&) = delete; + UploadPool(UploadPool&&) noexcept = default; + ~UploadPool() = default; + + virtual Allocation& Allocate(UInt64 size) = 0; + virtual Allocation& Allocate(UInt64 size, UInt64 alignment) = 0; + + virtual void Reset() = 0; + + UploadPool& operator=(const UploadPool&) = delete; + UploadPool& operator=(UploadPool&&) = delete; + + struct NAZARA_RENDERER_API Allocation + { + Allocation() = default; + Allocation(const Allocation&) = delete; + Allocation(Allocation&&) = default; + ~Allocation(); + + Allocation& operator=(const Allocation&) = delete; + Allocation& operator=(Allocation&&) = default; + + void* mappedPtr; + UInt64 offset; + UInt64 size; + }; + }; +} + +#include + +#endif // NAZARA_RENDERER_UPLOADPOOL_HPP diff --git a/include/Nazara/Renderer/UploadPool.inl b/include/Nazara/Renderer/UploadPool.inl new file mode 100644 index 000000000..346aa1076 --- /dev/null +++ b/include/Nazara/Renderer/UploadPool.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ +} + +#include diff --git a/include/Nazara/Utility/AbstractBuffer.hpp b/include/Nazara/Utility/AbstractBuffer.hpp index a2d36ce2e..346e96bab 100644 --- a/include/Nazara/Utility/AbstractBuffer.hpp +++ b/include/Nazara/Utility/AbstractBuffer.hpp @@ -18,13 +18,14 @@ namespace Nz AbstractBuffer() = default; virtual ~AbstractBuffer(); - virtual bool Fill(const void* data, UInt32 offset, UInt32 size) = 0; + virtual bool Fill(const void* data, UInt64 offset, UInt64 size) = 0; - virtual bool Initialize(UInt32 size, BufferUsageFlags usage) = 0; + virtual bool Initialize(UInt64 size, BufferUsageFlags usage) = 0; + virtual UInt64 GetSize() const = 0; virtual DataStorage GetStorage() const = 0; - virtual void* Map(BufferAccess access, UInt32 offset = 0, UInt32 size = 0) = 0; + virtual void* Map(BufferAccess access, UInt64 offset = 0, UInt64 size = 0) = 0; virtual bool Unmap() = 0; }; } diff --git a/include/Nazara/Utility/SoftwareBuffer.hpp b/include/Nazara/Utility/SoftwareBuffer.hpp index 574aebb50..25e951795 100644 --- a/include/Nazara/Utility/SoftwareBuffer.hpp +++ b/include/Nazara/Utility/SoftwareBuffer.hpp @@ -19,16 +19,17 @@ namespace Nz { public: SoftwareBuffer(Buffer* parent, BufferType type); - ~SoftwareBuffer(); + ~SoftwareBuffer() = default; - bool Fill(const void* data, UInt32 offset, UInt32 size) override; + bool Fill(const void* data, UInt64 offset, UInt64 size) override; - bool Initialize(UInt32 size, BufferUsageFlags usage) override; + bool Initialize(UInt64 size, BufferUsageFlags usage) override; const UInt8* GetData() const; + UInt64 GetSize() const; DataStorage GetStorage() const override; - void* Map(BufferAccess access, UInt32 offset = 0, UInt32 size = 0) override; + void* Map(BufferAccess access, UInt64 offset = 0, UInt64 size = 0) override; bool Unmap() override; private: diff --git a/include/Nazara/VulkanRenderer.hpp b/include/Nazara/VulkanRenderer.hpp index 6cc1db9dd..b3a003a2a 100644 --- a/include/Nazara/VulkanRenderer.hpp +++ b/include/Nazara/VulkanRenderer.hpp @@ -35,8 +35,11 @@ #include #include #include +#include +#include #include #include +#include #include #include #include diff --git a/include/Nazara/VulkanRenderer/VkRenderTarget.hpp b/include/Nazara/VulkanRenderer/VkRenderTarget.hpp index c98580e67..e120d1184 100644 --- a/include/Nazara/VulkanRenderer/VkRenderTarget.hpp +++ b/include/Nazara/VulkanRenderer/VkRenderTarget.hpp @@ -26,15 +26,11 @@ namespace Nz VkRenderTarget(VkRenderTarget&&) = delete; ///TOOD? virtual ~VkRenderTarget(); - virtual bool Acquire(UInt32* imageIndex, VkSemaphore signalSemaphore = VK_NULL_HANDLE, VkFence signalFence = VK_NULL_HANDLE) const = 0; - virtual const Vk::Framebuffer& GetFrameBuffer(UInt32 imageIndex) const = 0; virtual UInt32 GetFramebufferCount() const = 0; inline const Vk::RenderPass& GetRenderPass() const; - virtual void Present(UInt32 imageIndex, VkSemaphore waitSemaphore = VK_NULL_HANDLE) = 0; - VkRenderTarget& operator=(const VkRenderTarget&) = delete; VkRenderTarget& operator=(VkRenderTarget&&) = delete; ///TOOD? diff --git a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp index d58dbe883..719e9bd8e 100644 --- a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp +++ b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -37,7 +38,9 @@ namespace Nz VkRenderWindow(VkRenderWindow&&) = delete; ///TODO virtual ~VkRenderWindow(); - bool Acquire(UInt32* index, VkSemaphore signalSemaphore = VK_NULL_HANDLE, VkFence signalFence = VK_NULL_HANDLE) const override; + VulkanRenderImage& Acquire() override; + + std::unique_ptr BuildCommandBuffer(const std::function& callback) override; bool Create(RendererImpl* renderer, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) override; @@ -45,12 +48,12 @@ namespace Nz inline UInt32 GetFramebufferCount() const override; inline VulkanDevice& GetDevice(); inline const VulkanDevice& GetDevice() const; - inline UInt32 GetPresentableFamilyQueue() const; + inline Vk::QueueHandle& GetGraphicsQueue(); inline const Vk::Swapchain& GetSwapchain() const; std::shared_ptr GetRenderDevice() override; - void Present(UInt32 imageIndex, VkSemaphore waitSemaphore = VK_NULL_HANDLE) override; + void Present(UInt32 imageIndex, VkSemaphore waitSemaphore = VK_NULL_HANDLE); VkRenderWindow& operator=(const VkRenderWindow&) = delete; VkRenderWindow& operator=(VkRenderWindow&&) = delete; ///TODO @@ -60,18 +63,27 @@ namespace Nz bool SetupRenderPass(); bool SetupSwapchain(const Vk::PhysicalDevice& deviceInfo, Vk::Surface& surface, const Vector2ui& size); + struct ImageData + { + Vk::Framebuffer framebuffer; + Vk::Fence* inFlightFence = nullptr; + }; + + std::size_t m_currentFrame; Clock m_clock; VkColorSpaceKHR m_colorSpace; VkFormat m_colorFormat; VkFormat m_depthStencilFormat; std::shared_ptr m_device; - std::vector m_frameBuffers; + std::vector m_imageData; + std::vector m_concurrentImageData; + Vk::CommandPool m_graphicsCommandPool; Vk::DeviceMemory m_depthBufferMemory; Vk::Image m_depthBuffer; Vk::ImageView m_depthBufferView; + Vk::QueueHandle m_graphicsQueue; Vk::QueueHandle m_presentQueue; Vk::Swapchain m_swapchain; - UInt32 m_presentableFamilyQueue; }; } diff --git a/include/Nazara/VulkanRenderer/VkRenderWindow.inl b/include/Nazara/VulkanRenderer/VkRenderWindow.inl index 4d9cf9e92..c3700bf21 100644 --- a/include/Nazara/VulkanRenderer/VkRenderWindow.inl +++ b/include/Nazara/VulkanRenderer/VkRenderWindow.inl @@ -17,19 +17,19 @@ namespace Nz return *m_device; } + inline Vk::QueueHandle& VkRenderWindow::GetGraphicsQueue() + { + return m_graphicsQueue; + } + inline const Vk::Framebuffer& VkRenderWindow::GetFrameBuffer(UInt32 imageIndex) const { - return m_frameBuffers[imageIndex]; + return m_imageData[imageIndex].framebuffer; } inline UInt32 VkRenderWindow::GetFramebufferCount() const { - return static_cast(m_frameBuffers.size()); - } - - inline UInt32 VkRenderWindow::GetPresentableFamilyQueue() const - { - return m_presentableFamilyQueue; + return static_cast(m_imageData.size()); } inline const Vk::Swapchain& VkRenderWindow::GetSwapchain() const @@ -44,9 +44,11 @@ namespace Nz inline void VkRenderWindow::Present(UInt32 imageIndex, VkSemaphore waitSemaphore) { - NazaraAssert(imageIndex < m_frameBuffers.size(), "Invalid image index"); + NazaraAssert(imageIndex < m_imageData.size(), "Invalid image index"); m_presentQueue.Present(m_swapchain, imageIndex, waitSemaphore); + + m_currentFrame = (m_currentFrame + 1) % m_imageData.size(); } } diff --git a/include/Nazara/VulkanRenderer/Vulkan.hpp b/include/Nazara/VulkanRenderer/Vulkan.hpp index f3c40959c..d87afbec1 100644 --- a/include/Nazara/VulkanRenderer/Vulkan.hpp +++ b/include/Nazara/VulkanRenderer/Vulkan.hpp @@ -36,7 +36,7 @@ namespace Nz ~Vulkan() = delete; static std::shared_ptr CreateDevice(const Vk::PhysicalDevice& deviceInfo); - static std::shared_ptr CreateDevice(const Vk::PhysicalDevice& deviceInfo, const Vk::Surface& surface, UInt32* presentableFamilyQueue); + static std::shared_ptr CreateDevice(const Vk::PhysicalDevice& deviceInfo, const Vk::Surface& surface, UInt32* graphicsFamilyIndex, UInt32* presentableFamilyIndex); static std::shared_ptr CreateDevice(const Vk::PhysicalDevice& deviceInfo, const QueueFamily* queueFamilies, std::size_t queueFamilyCount); static Vk::Instance& GetInstance(); @@ -49,7 +49,7 @@ namespace Nz static bool IsInitialized(); static std::shared_ptr SelectDevice(const Vk::PhysicalDevice& deviceInfo); - static std::shared_ptr SelectDevice(const Vk::PhysicalDevice& deviceInfo, const Vk::Surface& surface, UInt32* presentableFamilyQueue); + static std::shared_ptr SelectDevice(const Vk::PhysicalDevice& deviceInfo, const Vk::Surface& surface, UInt32* graphicsFamilyIndex, UInt32* presentableFamilyIndex); static void Uninitialize(); diff --git a/include/Nazara/VulkanRenderer/VulkanBuffer.hpp b/include/Nazara/VulkanRenderer/VulkanBuffer.hpp index 8cdab89f4..cbee94283 100644 --- a/include/Nazara/VulkanRenderer/VulkanBuffer.hpp +++ b/include/Nazara/VulkanRenderer/VulkanBuffer.hpp @@ -26,14 +26,15 @@ namespace Nz VulkanBuffer(VulkanBuffer&&) = delete; ///TODO virtual ~VulkanBuffer(); - bool Fill(const void* data, UInt32 offset, UInt32 size) override; + bool Fill(const void* data, UInt64 offset, UInt64 size) override; + + bool Initialize(UInt64 size, BufferUsageFlags usage) override; inline VkBuffer GetBuffer(); - bool Initialize(UInt32 size, BufferUsageFlags usage) override; - + UInt64 GetSize() const override; DataStorage GetStorage() const override; - void* Map(BufferAccess access, UInt32 offset, UInt32 size) override; + void* Map(BufferAccess access, UInt64 offset, UInt64 size) override; bool Unmap() override; VulkanBuffer& operator=(const VulkanBuffer&) = delete; @@ -42,7 +43,7 @@ namespace Nz private: BufferType m_type; BufferUsageFlags m_usage; - UInt32 m_size; + UInt64 m_size; VkBuffer m_buffer; VkBuffer m_stagingBuffer; VmaAllocation m_allocation; diff --git a/include/Nazara/VulkanRenderer/VulkanCommandBuffer.hpp b/include/Nazara/VulkanRenderer/VulkanCommandBuffer.hpp new file mode 100644 index 000000000..608dda616 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanCommandBuffer.hpp @@ -0,0 +1,37 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VULKANCOMMANDBUFFER_HPP +#define NAZARA_VULKANRENDERER_VULKANCOMMANDBUFFER_HPP + +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_VULKANRENDERER_API VulkanCommandBuffer final : public CommandBuffer + { + public: + inline VulkanCommandBuffer(Vk::AutoCommandBuffer commandBuffer); + VulkanCommandBuffer(const VulkanCommandBuffer&) = delete; + VulkanCommandBuffer(VulkanCommandBuffer&&) noexcept = default; + ~VulkanCommandBuffer() = default; + + inline Vk::CommandBuffer& GetCommandBuffer(); + + VulkanCommandBuffer& operator=(const VulkanCommandBuffer&) = delete; + VulkanCommandBuffer& operator=(VulkanCommandBuffer&&) = delete; + + private: + Vk::AutoCommandBuffer m_commandBuffer; + }; +} + +#include + +#endif // NAZARA_VULKANRENDERER_VULKANCOMMANDBUFFER_HPP diff --git a/include/Nazara/VulkanRenderer/VulkanCommandBuffer.inl b/include/Nazara/VulkanRenderer/VulkanCommandBuffer.inl new file mode 100644 index 000000000..23d1b9f58 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanCommandBuffer.inl @@ -0,0 +1,21 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline VulkanCommandBuffer::VulkanCommandBuffer(Vk::AutoCommandBuffer commandBuffer) : + m_commandBuffer(std::move(commandBuffer)) + { + } + + inline Vk::CommandBuffer& VulkanCommandBuffer::GetCommandBuffer() + { + return m_commandBuffer.Get(); + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/VulkanCommandBufferBuilder.hpp b/include/Nazara/VulkanRenderer/VulkanCommandBufferBuilder.hpp new file mode 100644 index 000000000..66baec47b --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanCommandBufferBuilder.hpp @@ -0,0 +1,57 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VULKANCOMMANDBUFFERBUILDER_HPP +#define NAZARA_VULKANRENDERER_VULKANCOMMANDBUFFERBUILDER_HPP + +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_VULKANRENDERER_API VulkanCommandBufferBuilder final : public CommandBufferBuilder + { + public: + inline VulkanCommandBufferBuilder(Vk::CommandBuffer& commandBuffer); + VulkanCommandBufferBuilder(const VulkanCommandBufferBuilder&) = delete; + VulkanCommandBufferBuilder(VulkanCommandBufferBuilder&&) noexcept = default; + ~VulkanCommandBufferBuilder() = default; + + void BeginDebugRegion(const std::string_view& regionName, const Nz::Color& color) override; + + void BindIndexBuffer(AbstractBuffer* indexBuffer, UInt64 offset = 0) override; + void BindShaderBinding(ShaderBinding& binding) override; + void BindVertexBuffer(UInt32 binding, Nz::AbstractBuffer* vertexBuffer, UInt64 offset = 0) override; + + void CopyBuffer(const RenderBufferView& source, const RenderBufferView& target, UInt64 size, UInt64 sourceOffset = 0, UInt64 targetOffset = 0) override; + void CopyBuffer(const UploadPool::Allocation& allocation, const RenderBufferView& target, UInt64 size, UInt64 sourceOffset = 0, UInt64 targetOffset = 0) override; + + void Draw(UInt32 vertexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0) override; + void DrawIndexed(UInt32 indexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0) override; + + void EndDebugRegion() override; + + inline Vk::CommandBuffer& GetCommandBuffer(); + + void PreTransferBarrier() override; + void PostTransferBarrier() override; + + void SetScissor(Nz::Recti scissorRegion) override; + void SetViewport(Nz::Recti viewportRegion) override; + + VulkanCommandBufferBuilder& operator=(const VulkanCommandBufferBuilder&) = delete; + VulkanCommandBufferBuilder& operator=(VulkanCommandBufferBuilder&&) = delete; + + private: + Vk::CommandBuffer& m_commandBuffer; + }; +} + +#include + +#endif // NAZARA_VULKANRENDERER_VULKANCOMMANDBUFFERBUILDER_HPP diff --git a/include/Nazara/VulkanRenderer/VulkanCommandBufferBuilder.inl b/include/Nazara/VulkanRenderer/VulkanCommandBufferBuilder.inl new file mode 100644 index 000000000..1d4b865cb --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanCommandBufferBuilder.inl @@ -0,0 +1,21 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline VulkanCommandBufferBuilder::VulkanCommandBufferBuilder(Vk::CommandBuffer& commandBuffer) : + m_commandBuffer(commandBuffer) + { + } + + inline Vk::CommandBuffer& VulkanCommandBufferBuilder::GetCommandBuffer() + { + return m_commandBuffer; + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/VulkanRenderImage.hpp b/include/Nazara/VulkanRenderer/VulkanRenderImage.hpp new file mode 100644 index 000000000..576109245 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanRenderImage.hpp @@ -0,0 +1,65 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VULKANRENDERIMAGE_HPP +#define NAZARA_VULKANRENDERER_VULKANRENDERIMAGE_HPP + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class VkRenderWindow; + + class NAZARA_VULKANRENDERER_API VulkanRenderImage : public RenderImage + { + public: + VulkanRenderImage(VkRenderWindow& owner); + VulkanRenderImage(const VulkanRenderImage&) = delete; + VulkanRenderImage(VulkanRenderImage&&) noexcept = default; + ~VulkanRenderImage(); + + void Execute(const std::function& callback, bool isGraphical) override; + + inline Vk::Fence& GetInFlightFence(); + inline Vk::Semaphore& GetImageAvailableSemaphore(); + inline UInt32 GetImageIndex(); + inline Vk::Semaphore& GetRenderFinishedSemaphore(); + VulkanUploadPool& GetUploadPool() override; + + void SubmitCommandBuffer(CommandBuffer* commandBuffer, bool isGraphical) override; + void SubmitCommandBuffer(VkCommandBuffer commandBuffer, bool isGraphical); + + void Present() override; + + inline void Reset(UInt32 imageIndex); + + VulkanRenderImage& operator=(const VulkanRenderImage&) = delete; + VulkanRenderImage& operator=(VulkanRenderImage&&) = delete; + + private: + std::size_t m_currentCommandBuffer; + std::vector m_inFlightCommandBuffers; + std::vector m_graphicalCommandsBuffers; + VkRenderWindow& m_owner; + Vk::CommandPool m_commandPool; + Vk::Fence m_inFlightFence; + Vk::Semaphore m_imageAvailableSemaphore; + Vk::Semaphore m_renderFinishedSemaphore; + VulkanUploadPool m_uploadPool; + UInt32 m_imageIndex; + }; +} + +#include + +#endif // NAZARA_VULKANRENDERER_VULKANRENDERIMAGE_HPP diff --git a/include/Nazara/VulkanRenderer/VulkanRenderImage.inl b/include/Nazara/VulkanRenderer/VulkanRenderImage.inl new file mode 100644 index 000000000..521233611 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanRenderImage.inl @@ -0,0 +1,39 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline Vk::Fence& Nz::VulkanRenderImage::GetInFlightFence() + { + return m_inFlightFence; + } + + inline Vk::Semaphore& VulkanRenderImage::GetImageAvailableSemaphore() + { + return m_imageAvailableSemaphore; + } + + inline UInt32 VulkanRenderImage::GetImageIndex() + { + return m_imageIndex; + } + + inline Vk::Semaphore& VulkanRenderImage::GetRenderFinishedSemaphore() + { + return m_renderFinishedSemaphore; + } + + inline void VulkanRenderImage::Reset(UInt32 imageIndex) + { + m_graphicalCommandsBuffers.clear(); + m_currentCommandBuffer = 0; + m_imageIndex = imageIndex; + m_uploadPool.Reset(); + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/VulkanShaderBinding.hpp b/include/Nazara/VulkanRenderer/VulkanShaderBinding.hpp index 8d92b3697..8fa00eccf 100644 --- a/include/Nazara/VulkanRenderer/VulkanShaderBinding.hpp +++ b/include/Nazara/VulkanRenderer/VulkanShaderBinding.hpp @@ -24,6 +24,7 @@ namespace Nz ~VulkanShaderBinding() = default; inline Vk::DescriptorSet& GetDescriptorSet(); + inline VulkanRenderPipelineLayout& GetOwner(); void Update(std::initializer_list bindings) override; diff --git a/include/Nazara/VulkanRenderer/VulkanShaderBinding.inl b/include/Nazara/VulkanRenderer/VulkanShaderBinding.inl index 4300cf788..f82cd6303 100644 --- a/include/Nazara/VulkanRenderer/VulkanShaderBinding.inl +++ b/include/Nazara/VulkanRenderer/VulkanShaderBinding.inl @@ -17,6 +17,11 @@ namespace Nz { return m_descriptorSet; } + + inline VulkanRenderPipelineLayout& VulkanShaderBinding::GetOwner() + { + return m_owner; + } } #include diff --git a/include/Nazara/VulkanRenderer/VulkanUploadPool.hpp b/include/Nazara/VulkanRenderer/VulkanUploadPool.hpp index 2383f88c8..b2ff27dba 100644 --- a/include/Nazara/VulkanRenderer/VulkanUploadPool.hpp +++ b/include/Nazara/VulkanRenderer/VulkanUploadPool.hpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -16,28 +17,23 @@ namespace Nz { - class NAZARA_VULKANRENDERER_API VulkanUploadPool + class NAZARA_VULKANRENDERER_API VulkanUploadPool : public UploadPool { public: - struct AllocationData; + struct VulkanAllocation : Allocation + { + VkBuffer buffer; + }; inline VulkanUploadPool(Vk::Device& device, UInt64 blockSize); VulkanUploadPool(const VulkanUploadPool&) = delete; VulkanUploadPool(VulkanUploadPool&&) noexcept = default; ~VulkanUploadPool() = default; - std::optional Allocate(UInt64 size); - std::optional Allocate(UInt64 size, UInt64 alignment); + VulkanAllocation& Allocate(UInt64 size) override; + VulkanAllocation& Allocate(UInt64 size, UInt64 alignment) override; - void Reset(); - - struct AllocationData - { - VkBuffer buffer; - void* mappedPtr; - UInt64 offset; - UInt64 size; - }; + void Reset() override; VulkanUploadPool& operator=(const VulkanUploadPool&) = delete; VulkanUploadPool& operator=(VulkanUploadPool&&) = delete; @@ -53,6 +49,7 @@ namespace Nz UInt64 m_blockSize; Vk::Device& m_device; std::vector m_blocks; + std::vector m_allocations; }; } diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp index 47982a0be..b3286b01f 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp @@ -55,7 +55,7 @@ namespace Nz inline void ClearDepthStencilImage(VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue& depthStencil, const VkImageSubresourceRange& range); inline void ClearDepthStencilImage(VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue& depthStencil, UInt32 rangeCount, const VkImageSubresourceRange* ranges); - inline void CopyBuffer(VkBuffer source, VkBuffer target, UInt32 size, UInt32 sourceOffset = 0, UInt32 targetOffset = 0); + inline void CopyBuffer(VkBuffer source, VkBuffer target, UInt64 size, UInt64 sourceOffset = 0, UInt64 targetOffset = 0); inline void CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, UInt32 width, UInt32 height, UInt32 depth = 1); inline void Draw(UInt32 vertexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0); @@ -68,6 +68,8 @@ namespace Nz inline void Free(); + inline CommandPool& GetPool(); + inline void InsertDebugLabel(const char* label); inline void InsertDebugLabel(const char* label, Nz::Color color); diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl index a34dde3f5..96cadade6 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl @@ -216,7 +216,7 @@ namespace Nz return m_pool->GetDevice()->vkCmdClearDepthStencilImage(m_handle, image, imageLayout, &depthStencil, rangeCount, ranges); } - inline void CommandBuffer::CopyBuffer(VkBuffer source, VkBuffer target, UInt32 size, UInt32 sourceOffset, UInt32 targetOffset) + inline void CommandBuffer::CopyBuffer(VkBuffer source, VkBuffer target, UInt64 size, UInt64 sourceOffset, UInt64 targetOffset) { VkBufferCopy region; region.dstOffset = targetOffset; @@ -292,6 +292,11 @@ namespace Nz } } + inline CommandPool& CommandBuffer::GetPool() + { + return *m_pool; + } + inline void CommandBuffer::InsertDebugLabel(const char* label) { Vk::Device* device = m_pool->GetDevice(); diff --git a/include/Nazara/VulkanRenderer/Wrapper/QueueHandle.hpp b/include/Nazara/VulkanRenderer/Wrapper/QueueHandle.hpp index d34649164..e4569efca 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/QueueHandle.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/QueueHandle.hpp @@ -20,13 +20,14 @@ namespace Nz { public: inline QueueHandle(); - inline QueueHandle(Device& device, VkQueue queue); + inline QueueHandle(Device& device, VkQueue queue, UInt32 queueFamilyIndex); QueueHandle(const QueueHandle& queue) = delete; QueueHandle(QueueHandle&& queue) noexcept = default; ~QueueHandle() = default; inline Device& GetDevice() const; inline VkResult GetLastErrorCode() const; + inline UInt32 GetQueueFamilyIndex() const; inline bool Present(const VkPresentInfoKHR& presentInfo) const; inline bool Present(VkSwapchainKHR swapchain, UInt32 imageIndex, VkSemaphore waitSemaphore = VK_NULL_HANDLE) const; @@ -51,6 +52,7 @@ namespace Nz MovablePtr m_device; VkQueue m_handle; mutable VkResult m_lastErrorCode; + UInt32 m_queueFamilyIndex; }; } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/QueueHandle.inl b/include/Nazara/VulkanRenderer/Wrapper/QueueHandle.inl index 20ee10c4e..95462c1af 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/QueueHandle.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/QueueHandle.inl @@ -18,10 +18,11 @@ namespace Nz { } - inline QueueHandle::QueueHandle(Device& device, VkQueue queue) : + inline QueueHandle::QueueHandle(Device& device, VkQueue queue, UInt32 queueFamilyIndex) : m_device(&device), m_handle(queue), - m_lastErrorCode(VkResult::VK_SUCCESS) + m_lastErrorCode(VkResult::VK_SUCCESS), + m_queueFamilyIndex(queueFamilyIndex) { } @@ -35,6 +36,11 @@ namespace Nz return m_lastErrorCode; } + inline UInt32 QueueHandle::GetQueueFamilyIndex() const + { + return m_queueFamilyIndex; + } + inline bool QueueHandle::Present(const VkPresentInfoKHR& presentInfo) const { m_lastErrorCode = m_device->vkQueuePresentKHR(m_handle, &presentInfo); diff --git a/src/Nazara/Renderer/CommandBuffer.cpp b/src/Nazara/Renderer/CommandBuffer.cpp new file mode 100644 index 000000000..c93ff6fee --- /dev/null +++ b/src/Nazara/Renderer/CommandBuffer.cpp @@ -0,0 +1,11 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + CommandBuffer::~CommandBuffer() = default; +} diff --git a/src/Nazara/Renderer/CommandBufferBuilder.cpp b/src/Nazara/Renderer/CommandBufferBuilder.cpp new file mode 100644 index 000000000..e45605d48 --- /dev/null +++ b/src/Nazara/Renderer/CommandBufferBuilder.cpp @@ -0,0 +1,11 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + CommandBufferBuilder::~CommandBufferBuilder() = default; +} diff --git a/src/Nazara/Renderer/RenderBuffer.cpp b/src/Nazara/Renderer/RenderBuffer.cpp index a78660fe3..4526d79f3 100644 --- a/src/Nazara/Renderer/RenderBuffer.cpp +++ b/src/Nazara/Renderer/RenderBuffer.cpp @@ -8,7 +8,7 @@ namespace Nz { - bool RenderBuffer::Fill(const void* data, UInt32 offset, UInt32 size) + bool RenderBuffer::Fill(const void* data, UInt64 offset, UInt64 size) { if (m_softwareBuffer.Fill(data, offset, size)) { @@ -21,7 +21,7 @@ namespace Nz return false; } - bool RenderBuffer::Initialize(UInt32 size, BufferUsageFlags usage) + bool RenderBuffer::Initialize(UInt64 size, BufferUsageFlags usage) { m_size = size; m_softwareBuffer.Initialize(size, usage); @@ -37,12 +37,17 @@ namespace Nz return nullptr; } + UInt64 RenderBuffer::GetSize() const + { + return m_size; + } + DataStorage RenderBuffer::GetStorage() const { return DataStorage::DataStorage_Hardware; } - void* RenderBuffer::Map(BufferAccess access, UInt32 offset, UInt32 size) + void* RenderBuffer::Map(BufferAccess access, UInt64 offset, UInt64 size) { if (void* ptr = m_softwareBuffer.Map(access, offset, size)) { diff --git a/src/Nazara/Renderer/RenderImage.cpp b/src/Nazara/Renderer/RenderImage.cpp new file mode 100644 index 000000000..9724386e2 --- /dev/null +++ b/src/Nazara/Renderer/RenderImage.cpp @@ -0,0 +1,11 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + RenderImage::~RenderImage() = default; +} diff --git a/src/Nazara/Renderer/UploadPool.cpp b/src/Nazara/Renderer/UploadPool.cpp new file mode 100644 index 000000000..5443181f8 --- /dev/null +++ b/src/Nazara/Renderer/UploadPool.cpp @@ -0,0 +1,12 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + UploadPool::Allocation::~Allocation() = default; +} diff --git a/src/Nazara/Utility/SoftwareBuffer.cpp b/src/Nazara/Utility/SoftwareBuffer.cpp index 8867fa517..3b3c51489 100644 --- a/src/Nazara/Utility/SoftwareBuffer.cpp +++ b/src/Nazara/Utility/SoftwareBuffer.cpp @@ -14,11 +14,7 @@ namespace Nz { } - SoftwareBuffer::~SoftwareBuffer() - { - } - - bool SoftwareBuffer::Fill(const void* data, UInt32 offset, UInt32 size) + bool SoftwareBuffer::Fill(const void* data, UInt64 offset, UInt64 size) { NazaraAssert(!m_mapped, "Buffer is already mapped"); @@ -26,7 +22,7 @@ namespace Nz return true; } - bool SoftwareBuffer::Initialize(UInt32 size, BufferUsageFlags /*usage*/) + bool SoftwareBuffer::Initialize(UInt64 size, BufferUsageFlags /*usage*/) { // Protect the allocation to prevent a memory exception to escape the function try @@ -49,12 +45,17 @@ namespace Nz return m_buffer.data(); } + UInt64 SoftwareBuffer::GetSize() const + { + return UInt64(m_buffer.size()); + } + DataStorage SoftwareBuffer::GetStorage() const { return DataStorage_Software; } - void* SoftwareBuffer::Map(BufferAccess /*access*/, UInt32 offset, UInt32 /*size*/) + void* SoftwareBuffer::Map(BufferAccess /*access*/, UInt64 offset, UInt64 /*size*/) { NazaraAssert(!m_mapped, "Buffer is already mapped"); diff --git a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp index 72588bfd4..e9114c6c2 100644 --- a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp +++ b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp @@ -7,6 +7,8 @@ #include #include #include +#include +#include #include #include #include @@ -16,6 +18,7 @@ namespace Nz { VkRenderWindow::VkRenderWindow() : + m_currentFrame(0), m_depthStencilFormat(VK_FORMAT_MAX_ENUM) { } @@ -25,22 +28,52 @@ namespace Nz if (m_device) m_device->WaitForIdle(); - m_frameBuffers.clear(); + m_concurrentImageData.clear(); + m_graphicsCommandPool.Destroy(); + m_imageData.clear(); m_renderPass.Destroy(); m_swapchain.Destroy(); VkRenderTarget::Destroy(); } - bool VkRenderWindow::Acquire(UInt32* imageIndex, VkSemaphore signalSemaphore, VkFence signalFence) const + VulkanRenderImage& VkRenderWindow::Acquire() { - if (!m_swapchain.AcquireNextImage(std::numeric_limits::max(), signalSemaphore, signalFence, imageIndex)) - { - NazaraError("Failed to acquire next image"); - return false; - } + VulkanRenderImage& currentFrame = m_concurrentImageData[m_currentFrame]; + Vk::Fence& inFlightFence = currentFrame.GetInFlightFence(); - return true; + // Wait until previous rendering to this image has been done + inFlightFence.Wait(); + + UInt32 imageIndex; + if (!m_swapchain.AcquireNextImage(std::numeric_limits::max(), currentFrame.GetImageAvailableSemaphore(), VK_NULL_HANDLE, &imageIndex)) + throw std::runtime_error("Failed to acquire next image: " + TranslateVulkanError(m_swapchain.GetLastErrorCode())); + + if (m_imageData[imageIndex].inFlightFence) + m_imageData[imageIndex].inFlightFence->Wait(); + + m_imageData[imageIndex].inFlightFence = &inFlightFence; + m_imageData[imageIndex].inFlightFence->Reset(); + + currentFrame.Reset(imageIndex); + + return currentFrame; + } + + std::unique_ptr VkRenderWindow::BuildCommandBuffer(const std::function& callback) + { + Vk::AutoCommandBuffer commandBuffer = m_graphicsCommandPool.AllocateCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY); + + if (!commandBuffer->Begin()) + throw std::runtime_error("failed to begin command buffer: " + TranslateVulkanError(commandBuffer->GetLastErrorCode())); + + VulkanCommandBufferBuilder builder(commandBuffer.Get()); + callback(builder); + + if (!commandBuffer->End()) + throw std::runtime_error("failed to build command buffer: " + TranslateVulkanError(commandBuffer->GetLastErrorCode())); + + return std::make_unique(std::move(commandBuffer)); } bool VkRenderWindow::Create(RendererImpl* /*renderer*/, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) @@ -49,14 +82,17 @@ namespace Nz Vk::Surface& vulkanSurface = static_cast(surface)->GetSurface(); - m_device = Vulkan::SelectDevice(deviceInfo, vulkanSurface, &m_presentableFamilyQueue); + UInt32 graphicsFamilyQueueIndex; + UInt32 presentableFamilyQueueIndex; + m_device = Vulkan::SelectDevice(deviceInfo, vulkanSurface, &graphicsFamilyQueueIndex, &presentableFamilyQueueIndex); if (!m_device) { NazaraError("Failed to get compatible Vulkan device"); return false; } - m_presentQueue = m_device->GetQueue(m_presentableFamilyQueue, 0); + m_graphicsQueue = m_device->GetQueue(graphicsFamilyQueueIndex, 0); + m_presentQueue = m_device->GetQueue(presentableFamilyQueueIndex, 0); std::vector surfaceFormats; if (!vulkanSurface.GetFormats(deviceInfo.physDevice, &surfaceFormats)) @@ -144,10 +180,10 @@ namespace Nz UInt32 imageCount = m_swapchain.GetBufferCount(); // Framebuffers - m_frameBuffers.resize(imageCount); + m_imageData.resize(imageCount); for (UInt32 i = 0; i < imageCount; ++i) { - std::array attachments = {m_swapchain.GetBuffer(i).view, m_depthBufferView}; + std::array attachments = { m_swapchain.GetBuffer(i).view, m_depthBufferView }; VkFramebufferCreateInfo frameBufferCreate = { VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, // VkStructureType sType; @@ -161,13 +197,25 @@ namespace Nz 1U // uint32_t layers; }; - if (!m_frameBuffers[i].Create(*m_device, frameBufferCreate)) + if (!m_imageData[i].framebuffer.Create(*m_device, frameBufferCreate)) { - NazaraError("Failed to create framebuffer for image #" + String::Number(i)); + NazaraError("Failed to create framebuffer for image #" + String::Number(i) + ": " + TranslateVulkanError(m_imageData[i].framebuffer.GetLastErrorCode())); return false; } } + if (!m_graphicsCommandPool.Create(*m_device, m_graphicsQueue.GetQueueFamilyIndex())) + { + NazaraError("Failed to create graphics command pool: " + TranslateVulkanError(m_graphicsCommandPool.GetLastErrorCode())); + return false; + } + + const std::size_t MaxConcurrentImage = imageCount; + m_concurrentImageData.reserve(MaxConcurrentImage); + + for (std::size_t i = 0; i < MaxConcurrentImage; ++i) + m_concurrentImageData.emplace_back(*this); + m_clock.Restart(); return true; @@ -181,7 +229,7 @@ namespace Nz 0U, // VkImageCreateFlags flags; VK_IMAGE_TYPE_2D, // VkImageType imageType; m_depthStencilFormat, // VkFormat format; - {size.x, size.y, 1U}, // VkExtent3D extent; + {size.x, size.y, 1U}, // VkExtent3D extent; 1U, // uint32_t mipLevels; 1U, // uint32_t arrayLayers; VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples; diff --git a/src/Nazara/VulkanRenderer/Vulkan.cpp b/src/Nazara/VulkanRenderer/Vulkan.cpp index ff9095478..a71043605 100644 --- a/src/Nazara/VulkanRenderer/Vulkan.cpp +++ b/src/Nazara/VulkanRenderer/Vulkan.cpp @@ -297,7 +297,7 @@ namespace Nz return CreateDevice(deviceInfo, queuesFamilies.data(), queuesFamilies.size()); } - std::shared_ptr Vulkan::CreateDevice(const Vk::PhysicalDevice& deviceInfo, const Vk::Surface& surface, UInt32* presentableFamilyQueue) + std::shared_ptr Vulkan::CreateDevice(const Vk::PhysicalDevice& deviceInfo, const Vk::Surface& surface, UInt32* graphicsFamilyIndex, UInt32* presentableFamilyIndex) { Nz::ErrorFlags errFlags(ErrorFlag_ThrowException, true); @@ -362,7 +362,8 @@ namespace Nz } }; - *presentableFamilyQueue = presentQueueNodeIndex; + *graphicsFamilyIndex = graphicsQueueNodeIndex; + *presentableFamilyIndex = presentQueueNodeIndex; return CreateDevice(deviceInfo, queuesFamilies.data(), queuesFamilies.size()); } @@ -496,7 +497,7 @@ namespace Nz return CreateDevice(deviceInfo); } - std::shared_ptr Vulkan::SelectDevice(const Vk::PhysicalDevice& deviceInfo, const Vk::Surface& surface, UInt32* presentableFamilyQueue) + std::shared_ptr Vulkan::SelectDevice(const Vk::PhysicalDevice& deviceInfo, const Vk::Surface& surface, UInt32* graphicsFamilyIndex, UInt32* presentableFamilyIndex) { // First, try to find a device compatible with that surface for (auto it = s_devices.begin(); it != s_devices.end();) @@ -505,6 +506,7 @@ namespace Nz if (devicePtr->GetPhysicalDevice() == deviceInfo.physDevice) { const std::vector& queueFamilyInfo = devicePtr->GetEnabledQueues(); + UInt32 graphicsQueueFamilyIndex = UINT32_MAX; UInt32 presentableQueueFamilyIndex = UINT32_MAX; for (const Vk::Device::QueueFamilyInfo& queueInfo : queueFamilyInfo) { @@ -515,14 +517,29 @@ namespace Nz { presentableQueueFamilyIndex = queueInfo.familyIndex; if (queueInfo.flags & VK_QUEUE_GRAPHICS_BIT) + { + *graphicsFamilyIndex = queueInfo.familyIndex; break; + } + } + } + } + + if (graphicsQueueFamilyIndex == UINT32_MAX) + { + for (const Vk::Device::QueueFamilyInfo& queueInfo : queueFamilyInfo) + { + if (queueInfo.flags & VK_QUEUE_GRAPHICS_BIT) + { + *graphicsFamilyIndex = queueInfo.familyIndex; + break; } } } if (presentableQueueFamilyIndex != UINT32_MAX) { - *presentableFamilyQueue = presentableQueueFamilyIndex; + *presentableFamilyIndex = presentableQueueFamilyIndex; return devicePtr; } } @@ -531,7 +548,7 @@ namespace Nz } // No device had support for that surface, create one - return CreateDevice(deviceInfo, surface, presentableFamilyQueue); + return CreateDevice(deviceInfo, surface, graphicsFamilyIndex, presentableFamilyIndex); } void Vulkan::Uninitialize() diff --git a/src/Nazara/VulkanRenderer/VulkanBuffer.cpp b/src/Nazara/VulkanRenderer/VulkanBuffer.cpp index d31298e5c..e338ac9e7 100644 --- a/src/Nazara/VulkanRenderer/VulkanBuffer.cpp +++ b/src/Nazara/VulkanRenderer/VulkanBuffer.cpp @@ -17,7 +17,7 @@ namespace Nz vmaDestroyBuffer(m_device.GetMemoryAllocator(), m_buffer, m_allocation); } - bool VulkanBuffer::Fill(const void* data, UInt32 offset, UInt32 size) + bool VulkanBuffer::Fill(const void* data, UInt64 offset, UInt64 size) { void* ptr = Map(BufferAccess_WriteOnly, offset, size); if (!ptr) @@ -30,7 +30,7 @@ namespace Nz return true; } - bool VulkanBuffer::Initialize(UInt32 size, BufferUsageFlags usage) + bool VulkanBuffer::Initialize(UInt64 size, BufferUsageFlags usage) { m_size = size; m_usage = usage; @@ -69,12 +69,17 @@ namespace Nz return true; } + UInt64 VulkanBuffer::GetSize() const + { + return m_size; + } + DataStorage VulkanBuffer::GetStorage() const { return DataStorage_Hardware; } - void* VulkanBuffer::Map(BufferAccess /*access*/, UInt32 offset, UInt32 size) + void* VulkanBuffer::Map(BufferAccess /*access*/, UInt64 offset, UInt64 size) { if (m_usage & BufferUsage_DirectMapping) { diff --git a/src/Nazara/VulkanRenderer/VulkanCommandBuffer.cpp b/src/Nazara/VulkanRenderer/VulkanCommandBuffer.cpp new file mode 100644 index 000000000..92f60a953 --- /dev/null +++ b/src/Nazara/VulkanRenderer/VulkanCommandBuffer.cpp @@ -0,0 +1,10 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ +} diff --git a/src/Nazara/VulkanRenderer/VulkanCommandBufferBuilder.cpp b/src/Nazara/VulkanRenderer/VulkanCommandBufferBuilder.cpp new file mode 100644 index 000000000..1d5063c78 --- /dev/null +++ b/src/Nazara/VulkanRenderer/VulkanCommandBufferBuilder.cpp @@ -0,0 +1,98 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + void VulkanCommandBufferBuilder::BeginDebugRegion(const std::string_view& regionName, const Nz::Color& color) + { + // Ensure \0 at the end of string + StackArray regionNameEOS = NazaraStackArrayNoInit(char, regionName.size() + 1); + std::memcpy(regionNameEOS.data(), regionName.data(), regionName.size()); + regionNameEOS[regionName.size()] = '\0'; + + m_commandBuffer.BeginDebugRegion(regionNameEOS.data(), color); + } + + void VulkanCommandBufferBuilder::BindIndexBuffer(Nz::AbstractBuffer* indexBuffer, UInt64 offset) + { + VulkanBuffer& vkBuffer = *static_cast(indexBuffer); + + m_commandBuffer.BindIndexBuffer(vkBuffer.GetBuffer(), offset, VK_INDEX_TYPE_UINT16); //< Fuck me right? + } + + void VulkanCommandBufferBuilder::BindShaderBinding(ShaderBinding& binding) + { + VulkanShaderBinding& vkBinding = static_cast(binding); + + VulkanRenderPipelineLayout& pipelineLayout = vkBinding.GetOwner(); + + m_commandBuffer.BindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout.GetPipelineLayout(), 0U, vkBinding.GetDescriptorSet()); + } + + void VulkanCommandBufferBuilder::BindVertexBuffer(UInt32 binding, Nz::AbstractBuffer* vertexBuffer, UInt64 offset) + { + VulkanBuffer& vkBuffer = *static_cast(vertexBuffer); + + m_commandBuffer.BindVertexBuffer(binding, vkBuffer.GetBuffer(), offset); + } + + void VulkanCommandBufferBuilder::CopyBuffer(const RenderBufferView& source, const RenderBufferView& target, UInt64 size, UInt64 sourceOffset, UInt64 targetOffset) + { + VulkanBuffer& sourceBuffer = *static_cast(source.GetBuffer()); + VulkanBuffer& targetBuffer = *static_cast(target.GetBuffer()); + + m_commandBuffer.CopyBuffer(sourceBuffer.GetBuffer(), targetBuffer.GetBuffer(), size, sourceOffset + source.GetOffset(), targetOffset + target.GetOffset()); + } + + void VulkanCommandBufferBuilder::CopyBuffer(const UploadPool::Allocation& allocation, const RenderBufferView& target, UInt64 size, UInt64 sourceOffset, UInt64 targetOffset) + { + const auto& vkAllocation = static_cast(allocation); + VulkanBuffer& targetBuffer = *static_cast(target.GetBuffer()); + + m_commandBuffer.CopyBuffer(vkAllocation.buffer, targetBuffer.GetBuffer(), size, vkAllocation.offset + sourceOffset, target.GetOffset() + targetOffset); + } + + void VulkanCommandBufferBuilder::Draw(UInt32 vertexCount, UInt32 instanceCount, UInt32 firstVertex, UInt32 firstInstance) + { + m_commandBuffer.Draw(vertexCount, instanceCount, firstVertex, firstInstance); + } + + void VulkanCommandBufferBuilder::DrawIndexed(UInt32 indexCount, UInt32 instanceCount, UInt32 firstVertex, UInt32 firstInstance) + { + m_commandBuffer.DrawIndexed(indexCount, instanceCount, firstVertex, 0, firstInstance); + } + + void VulkanCommandBufferBuilder::EndDebugRegion() + { + m_commandBuffer.EndDebugRegion(); + } + + void VulkanCommandBufferBuilder::PreTransferBarrier() + { + m_commandBuffer.MemoryBarrier(VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0U, VK_ACCESS_TRANSFER_READ_BIT); + } + + void VulkanCommandBufferBuilder::PostTransferBarrier() + { + m_commandBuffer.MemoryBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_UNIFORM_READ_BIT); + } + + void VulkanCommandBufferBuilder::SetScissor(Nz::Recti scissorRegion) + { + m_commandBuffer.SetScissor(scissorRegion); + } + + void VulkanCommandBufferBuilder::SetViewport(Nz::Recti viewportRegion) + { + m_commandBuffer.SetViewport(Nz::Rectf(viewportRegion), 0.f, 1.f); + } +} diff --git a/src/Nazara/VulkanRenderer/VulkanRenderImage.cpp b/src/Nazara/VulkanRenderer/VulkanRenderImage.cpp new file mode 100644 index 000000000..9cade7921 --- /dev/null +++ b/src/Nazara/VulkanRenderer/VulkanRenderImage.cpp @@ -0,0 +1,93 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + VulkanRenderImage::VulkanRenderImage(VkRenderWindow& owner) : + m_owner(owner), + m_uploadPool(m_owner.GetDevice(), 2 * 1024 * 1024) + { + Vk::QueueHandle& graphicsQueue = m_owner.GetGraphicsQueue(); + if (!m_commandPool.Create(m_owner.GetDevice(), graphicsQueue.GetQueueFamilyIndex(), VK_COMMAND_POOL_CREATE_TRANSIENT_BIT | VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)) + throw std::runtime_error("failed to create command pool: " + TranslateVulkanError(m_commandPool.GetLastErrorCode())); + + if (!m_imageAvailableSemaphore.Create(m_owner.GetDevice())) + throw std::runtime_error("failed to create image available semaphore: " + TranslateVulkanError(m_imageAvailableSemaphore.GetLastErrorCode())); + + if (!m_renderFinishedSemaphore.Create(m_owner.GetDevice())) + throw std::runtime_error("failed to create image finished semaphore: " + TranslateVulkanError(m_imageAvailableSemaphore.GetLastErrorCode())); + + if (!m_inFlightFence.Create(m_owner.GetDevice(), VK_FENCE_CREATE_SIGNALED_BIT)) + throw std::runtime_error("failed to create in-flight fence: " + TranslateVulkanError(m_inFlightFence.GetLastErrorCode())); + } + + VulkanRenderImage::~VulkanRenderImage() + { + m_inFlightCommandBuffers.clear(); + } + + void VulkanRenderImage::Execute(const std::function& callback, bool isGraphical) + { + Vk::CommandBuffer* commandBuffer; + if (m_currentCommandBuffer >= m_inFlightCommandBuffers.size()) + { + Vk::AutoCommandBuffer& newlyAllocatedBuffer = m_inFlightCommandBuffers.emplace_back(m_commandPool.AllocateCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY)); + commandBuffer = &newlyAllocatedBuffer.Get(); + m_currentCommandBuffer++; + } + else + commandBuffer = &m_inFlightCommandBuffers[m_currentCommandBuffer++].Get(); + + if (!commandBuffer->Begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT)) + throw std::runtime_error("failed to begin command buffer: " + TranslateVulkanError(commandBuffer->GetLastErrorCode())); + + VulkanCommandBufferBuilder builder(*commandBuffer); + callback(builder); + + if (!commandBuffer->End()) + throw std::runtime_error("failed to build command buffer: " + TranslateVulkanError(commandBuffer->GetLastErrorCode())); + + SubmitCommandBuffer(*commandBuffer, isGraphical); + } + + VulkanUploadPool& VulkanRenderImage::GetUploadPool() + { + return m_uploadPool; + } + + void VulkanRenderImage::SubmitCommandBuffer(CommandBuffer* commandBuffer, bool isGraphical) + { + VulkanCommandBuffer& vkCommandBuffer = *static_cast(commandBuffer); + + return SubmitCommandBuffer(vkCommandBuffer.GetCommandBuffer(), isGraphical); + } + + void VulkanRenderImage::SubmitCommandBuffer(VkCommandBuffer commandBuffer, bool isGraphical) + { + if (isGraphical) + m_graphicalCommandsBuffers.push_back(commandBuffer); + else + { + Vk::QueueHandle& graphicsQueue = m_owner.GetGraphicsQueue(); + if (!graphicsQueue.Submit(commandBuffer)) + throw std::runtime_error("Failed to submit command buffer: " + TranslateVulkanError(graphicsQueue.GetLastErrorCode())); + } + } + + void VulkanRenderImage::Present() + { + Vk::QueueHandle& graphicsQueue = m_owner.GetGraphicsQueue(); + if (!graphicsQueue.Submit(UInt32(m_graphicalCommandsBuffers.size()), m_graphicalCommandsBuffers.data(), m_imageAvailableSemaphore, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, m_renderFinishedSemaphore, m_inFlightFence)) + throw std::runtime_error("Failed to submit command buffers: " + TranslateVulkanError(graphicsQueue.GetLastErrorCode())); + + m_owner.Present(m_imageIndex, m_renderFinishedSemaphore); + } +} diff --git a/src/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.cpp b/src/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.cpp index 3af7735fc..9257f6d72 100644 --- a/src/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.cpp +++ b/src/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.cpp @@ -39,16 +39,16 @@ namespace Nz DescriptorPool pool; if (!pool.descriptorPool.Create(*m_device, MaxSet, UInt32(poolSizes.size()), poolSizes.data(), VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT)) - { - //return {}; - } + throw std::runtime_error("Failed to allocate new descriptor pool: " + TranslateVulkanError(pool.descriptorPool.GetLastErrorCode())); pool.allocatedSets.reserve(MaxSet); auto& poolData = m_descriptorPools.emplace_back(std::move(pool)); Vk::DescriptorSet descriptorSet = poolData.descriptorPool.AllocateDescriptorSet(m_descriptorSetLayout); - //if (descriptorSet) - return poolData.allocatedSets.emplace_back(*this, std::move(descriptorSet)); + if (!descriptorSet) + throw std::runtime_error("Failed to allocate descriptor set: " + TranslateVulkanError(pool.descriptorPool.GetLastErrorCode())); + + return poolData.allocatedSets.emplace_back(*this, std::move(descriptorSet)); } bool VulkanRenderPipelineLayout::Create(Vk::Device& device, RenderPipelineLayoutInfo layoutInfo) diff --git a/src/Nazara/VulkanRenderer/VulkanUploadPool.cpp b/src/Nazara/VulkanRenderer/VulkanUploadPool.cpp index ffbf17f1a..3d0027332 100644 --- a/src/Nazara/VulkanRenderer/VulkanUploadPool.cpp +++ b/src/Nazara/VulkanRenderer/VulkanUploadPool.cpp @@ -4,11 +4,12 @@ #include #include +#include #include namespace Nz { - auto VulkanUploadPool::Allocate(UInt64 size) -> std::optional + auto VulkanUploadPool::Allocate(UInt64 size) -> VulkanAllocation& { const auto& deviceProperties = m_device.GetPhysicalDeviceInfo().properties; UInt64 preferredAlignement = deviceProperties.limits.optimalBufferCopyOffsetAlignment; @@ -16,7 +17,7 @@ namespace Nz return Allocate(size, preferredAlignement); } - auto VulkanUploadPool::Allocate(UInt64 size, UInt64 alignment) -> std::optional + auto VulkanUploadPool::Allocate(UInt64 size, UInt64 alignment) -> VulkanAllocation& { assert(size <= m_blockSize); @@ -49,37 +50,25 @@ namespace Nz { Block newBlock; if (!newBlock.buffer.Create(m_device, 0U, m_blockSize, VK_BUFFER_USAGE_TRANSFER_SRC_BIT)) - { - NazaraError("Failed to create block buffer: " + TranslateVulkanError(newBlock.buffer.GetLastErrorCode())); - return {}; - } + throw std::runtime_error("Failed to create block buffer: " + TranslateVulkanError(newBlock.buffer.GetLastErrorCode())); VkMemoryRequirements requirement = newBlock.buffer.GetMemoryRequirements(); if (!newBlock.blockMemory.Create(m_device, requirement.size, requirement.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) - { - NazaraError("Failed to allocate block memory: " + TranslateVulkanError(newBlock.blockMemory.GetLastErrorCode())); - return {}; - } + throw std::runtime_error("Failed to allocate block memory: " + TranslateVulkanError(newBlock.blockMemory.GetLastErrorCode())); if (!newBlock.buffer.BindBufferMemory(newBlock.blockMemory)) - { - NazaraError("Failed to bind buffer memory: " + TranslateVulkanError(newBlock.buffer.GetLastErrorCode())); - return {}; - } + throw std::runtime_error("Failed to bind buffer memory: " + TranslateVulkanError(newBlock.buffer.GetLastErrorCode())); if (!newBlock.blockMemory.Map()) - { - NazaraError("Failed to map buffer memory: " + TranslateVulkanError(newBlock.buffer.GetLastErrorCode())); - return {}; - } + throw std::runtime_error("Failed to map buffer memory: " + TranslateVulkanError(newBlock.buffer.GetLastErrorCode())); bestBlock.block = &m_blocks.emplace_back(std::move(newBlock)); bestBlock.alignedOffset = 0; bestBlock.lostSpace = 0; } - AllocationData allocationData; + VulkanAllocation& allocationData = m_allocations.emplace_back(); allocationData.buffer = bestBlock.block->buffer; allocationData.mappedPtr = static_cast(bestBlock.block->blockMemory.GetMappedPointer()) + bestBlock.alignedOffset; allocationData.offset = bestBlock.alignedOffset; @@ -92,5 +81,7 @@ namespace Nz { for (Block& block : m_blocks) block.freeOffset = 0; + + m_allocations.clear(); } } diff --git a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp index 49d22d586..6c02c7381 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp @@ -231,7 +231,7 @@ namespace Nz const auto& queues = GetEnabledQueues(queueFamilyIndex); NazaraAssert(queueIndex < queues.size(), "Invalid queue index"); - return QueueHandle(*this, queues[queueIndex].queue); + return QueueHandle(*this, queues[queueIndex].queue, queueFamilyIndex); } void Device::ResetPointers() From ac8b908079a33a932732ea5d00a210b634ef1cec Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 6 Apr 2020 21:13:59 +0200 Subject: [PATCH 140/316] Vulkan: Replace ShaderBinding& by ShaderBindingPtr --- examples/VulkanTest/main.cpp | 6 +- .../Nazara/Renderer/RenderPipelineLayout.hpp | 8 +- include/Nazara/Renderer/ShaderBinding.hpp | 15 +++ include/Nazara/Renderer/ShaderBinding.inl | 4 + .../VulkanRenderPipelineLayout.hpp | 21 +++- .../VulkanRenderPipelineLayout.inl | 15 +++ .../VulkanRenderer/VulkanShaderBinding.hpp | 8 +- .../VulkanRenderer/VulkanShaderBinding.inl | 16 ++- .../VulkanRenderPipelineLayout.cpp | 114 +++++++++++++----- .../VulkanRenderer/VulkanShaderBinding.cpp | 5 + 10 files changed, 171 insertions(+), 41 deletions(-) diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index 9612cacd9..2d6febd0e 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -166,7 +166,7 @@ int main() std::shared_ptr renderPipelineLayout = device->InstantiateRenderPipelineLayout(pipelineLayoutInfo); - Nz::ShaderBinding& shaderBinding = renderPipelineLayout->AllocateShaderBinding(); + Nz::ShaderBindingPtr shaderBinding = renderPipelineLayout->AllocateShaderBinding(); std::unique_ptr uniformBuffer = device->InstantiateBuffer(Nz::BufferType_Uniform); if (!uniformBuffer->Initialize(uniformSize, Nz::BufferUsage_DeviceLocal)) @@ -175,7 +175,7 @@ int main() return __LINE__; } - shaderBinding.Update({ + shaderBinding->Update({ { 0, Nz::ShaderBinding::UniformBufferBinding { @@ -268,7 +268,7 @@ int main() { builder.BindIndexBuffer(indexBufferImpl); builder.BindVertexBuffer(0, vertexBufferImpl); - builder.BindShaderBinding(shaderBinding); + builder.BindShaderBinding(*shaderBinding); builder.SetScissor(Nz::Recti{ 0, 0, int(windowSize.x), int(windowSize.y) }); builder.SetViewport(Nz::Recti{ 0, 0, int(windowSize.x), int(windowSize.y) }); diff --git a/include/Nazara/Renderer/RenderPipelineLayout.hpp b/include/Nazara/Renderer/RenderPipelineLayout.hpp index 7cbaa54de..c15787c35 100644 --- a/include/Nazara/Renderer/RenderPipelineLayout.hpp +++ b/include/Nazara/Renderer/RenderPipelineLayout.hpp @@ -7,8 +7,10 @@ #ifndef NAZARA_RENDERPIPELINELAYOUT_HPP #define NAZARA_RENDERPIPELINELAYOUT_HPP -#include +#include #include +#include +#include #include #include @@ -27,15 +29,13 @@ namespace Nz std::vector bindings; }; - class ShaderBinding; - class NAZARA_RENDERER_API RenderPipelineLayout { public: RenderPipelineLayout() = default; virtual ~RenderPipelineLayout(); - virtual ShaderBinding& AllocateShaderBinding() = 0; + virtual ShaderBindingPtr AllocateShaderBinding() = 0; }; } diff --git a/include/Nazara/Renderer/ShaderBinding.hpp b/include/Nazara/Renderer/ShaderBinding.hpp index 1a2daba5e..395afff5a 100644 --- a/include/Nazara/Renderer/ShaderBinding.hpp +++ b/include/Nazara/Renderer/ShaderBinding.hpp @@ -9,16 +9,23 @@ #include #include +#include #include namespace Nz { class AbstractBuffer; + class ShaderBinding; + class ShaderBindingDeleter; class Texture; class TextureSampler; + using ShaderBindingPtr = std::unique_ptr; + class NAZARA_RENDERER_API ShaderBinding { + friend ShaderBindingDeleter; + public: struct Binding; @@ -47,9 +54,17 @@ namespace Nz }; protected: + virtual void Release() = 0; + ShaderBinding(const ShaderBinding&) = delete; ShaderBinding(ShaderBinding&&) = default; }; + + class ShaderBindingDeleter + { + public: + inline void operator()(ShaderBinding* binding); + }; } #include diff --git a/include/Nazara/Renderer/ShaderBinding.inl b/include/Nazara/Renderer/ShaderBinding.inl index dccd89939..6d1f7f3d0 100644 --- a/include/Nazara/Renderer/ShaderBinding.inl +++ b/include/Nazara/Renderer/ShaderBinding.inl @@ -7,6 +7,10 @@ namespace Nz { + inline void ShaderBindingDeleter::operator()(ShaderBinding* binding) + { + binding->Release(); + } } #include diff --git a/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.hpp b/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.hpp index 1dc17f883..17e1a8800 100644 --- a/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.hpp +++ b/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.hpp @@ -8,6 +8,7 @@ #define NAZARA_VULKANRENDERER_VULKANRENDERPIPELINELAYOUT_HPP #include +#include #include #include #include @@ -16,17 +17,21 @@ #include #include #include +#include +#include #include namespace Nz { class NAZARA_VULKANRENDERER_API VulkanRenderPipelineLayout : public RenderPipelineLayout { + friend VulkanShaderBinding; + public: VulkanRenderPipelineLayout() = default; - ~VulkanRenderPipelineLayout() = default; + ~VulkanRenderPipelineLayout(); - VulkanShaderBinding& AllocateShaderBinding() override; + ShaderBindingPtr AllocateShaderBinding() override; bool Create(Vk::Device& device, RenderPipelineLayoutInfo layoutInfo); @@ -36,10 +41,20 @@ namespace Nz inline const Vk::PipelineLayout& GetPipelineLayout() const; private: + struct DescriptorPool; + + DescriptorPool& AllocatePool(); + ShaderBindingPtr AllocateFromPool(std::size_t poolIndex); + void Release(ShaderBinding& binding); + inline void TryToShrink(); + struct DescriptorPool { + using BindingStorage = std::aligned_storage_t; + + Bitset freeBindings; Vk::DescriptorPool descriptorPool; - std::vector allocatedSets; + std::unique_ptr storage; }; MovablePtr m_device; diff --git a/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.inl b/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.inl index e4a9f73c4..5dd664b5c 100644 --- a/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.inl +++ b/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.inl @@ -21,6 +21,21 @@ namespace Nz { return m_pipelineLayout; } + + inline void VulkanRenderPipelineLayout::TryToShrink() + { + std::size_t poolCount = m_descriptorPools.size(); + if (poolCount >= 2 && m_descriptorPools.back().freeBindings.TestAll()) + { + for (std::size_t i = poolCount - 1; i > 0; ++i) + { + if (m_descriptorPools[i].freeBindings.TestAll()) + poolCount--; + } + + m_descriptorPools.resize(poolCount); + } + } } #include diff --git a/include/Nazara/VulkanRenderer/VulkanShaderBinding.hpp b/include/Nazara/VulkanRenderer/VulkanShaderBinding.hpp index 8fa00eccf..78051b624 100644 --- a/include/Nazara/VulkanRenderer/VulkanShaderBinding.hpp +++ b/include/Nazara/VulkanRenderer/VulkanShaderBinding.hpp @@ -18,12 +18,14 @@ namespace Nz class NAZARA_VULKANRENDERER_API VulkanShaderBinding : public ShaderBinding { public: - inline VulkanShaderBinding(VulkanRenderPipelineLayout& owner, Vk::DescriptorSet descriptorSet); + inline VulkanShaderBinding(VulkanRenderPipelineLayout& owner, std::size_t poolIndex, std::size_t bindingIndex, Vk::DescriptorSet descriptorSet); VulkanShaderBinding(const VulkanShaderBinding&) = default; VulkanShaderBinding(VulkanShaderBinding&&) noexcept = default; ~VulkanShaderBinding() = default; + inline std::size_t GetBindingIndex() const; inline Vk::DescriptorSet& GetDescriptorSet(); + inline std::size_t GetPoolIndex() const; inline VulkanRenderPipelineLayout& GetOwner(); void Update(std::initializer_list bindings) override; @@ -32,8 +34,12 @@ namespace Nz VulkanShaderBinding& operator=(VulkanShaderBinding&&) = delete; private: + void Release() override; + Vk::AutoDescriptorSet m_descriptorSet; VulkanRenderPipelineLayout& m_owner; + std::size_t m_bindingIndex; + std::size_t m_poolIndex; }; } diff --git a/include/Nazara/VulkanRenderer/VulkanShaderBinding.inl b/include/Nazara/VulkanRenderer/VulkanShaderBinding.inl index f82cd6303..c3b447fcf 100644 --- a/include/Nazara/VulkanRenderer/VulkanShaderBinding.inl +++ b/include/Nazara/VulkanRenderer/VulkanShaderBinding.inl @@ -7,12 +7,24 @@ namespace Nz { - inline VulkanShaderBinding::VulkanShaderBinding(VulkanRenderPipelineLayout& owner, Vk::DescriptorSet descriptorSet) : + inline VulkanShaderBinding::VulkanShaderBinding(VulkanRenderPipelineLayout& owner, std::size_t poolIndex, std::size_t bindingIndex, Vk::DescriptorSet descriptorSet) : m_descriptorSet(std::move(descriptorSet)), - m_owner(owner) + m_owner(owner), + m_bindingIndex(bindingIndex), + m_poolIndex(poolIndex) { } + inline std::size_t VulkanShaderBinding::GetBindingIndex() const + { + return m_bindingIndex; + } + + inline std::size_t VulkanShaderBinding::GetPoolIndex() const + { + return m_poolIndex; + } + inline Vk::DescriptorSet& VulkanShaderBinding::GetDescriptorSet() { return m_descriptorSet; diff --git a/src/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.cpp b/src/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.cpp index 9257f6d72..ad76aa5b9 100644 --- a/src/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.cpp +++ b/src/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -12,43 +13,35 @@ namespace Nz { - VulkanShaderBinding& VulkanRenderPipelineLayout::AllocateShaderBinding() + VulkanRenderPipelineLayout::~VulkanRenderPipelineLayout() { - // TODO: Watch descriptor set count for each pool for (auto& pool : m_descriptorPools) { - if (pool.allocatedSets.capacity() <= pool.allocatedSets.size()) + if (!pool.freeBindings.TestAll()) + NazaraWarning("Not all ShaderBinding have been released!"); + } + } + + ShaderBindingPtr VulkanRenderPipelineLayout::AllocateShaderBinding() + { + for (std::size_t i = 0; i < m_descriptorPools.size(); ++i) + { + ShaderBindingPtr bindingPtr = AllocateFromPool(i); + if (!bindingPtr) continue; - Vk::DescriptorSet descriptorSet = pool.descriptorPool.AllocateDescriptorSet(m_descriptorSetLayout); - if (descriptorSet) - return pool.allocatedSets.emplace_back(*this, std::move(descriptorSet)); + return bindingPtr; } - // Allocate a new descriptor pool - StackVector poolSizes = NazaraStackVector(VkDescriptorPoolSize, m_layoutInfo.bindings.size()); + // No allocation could be made, time to allocate a new pool + std::size_t newPoolIndex = m_descriptorPools.size(); + AllocatePool(); - constexpr UInt32 MaxSet = 100; + ShaderBindingPtr bindingPtr = AllocateFromPool(newPoolIndex); + if (!bindingPtr) + throw std::runtime_error("Failed to allocate shader binding"); - for (const auto& bindingInfo : m_layoutInfo.bindings) - { - VkDescriptorPoolSize& poolSize = poolSizes.emplace_back(); - poolSize.descriptorCount = MaxSet; - poolSize.type = ToVulkan(bindingInfo.type); - } - - DescriptorPool pool; - if (!pool.descriptorPool.Create(*m_device, MaxSet, UInt32(poolSizes.size()), poolSizes.data(), VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT)) - throw std::runtime_error("Failed to allocate new descriptor pool: " + TranslateVulkanError(pool.descriptorPool.GetLastErrorCode())); - - pool.allocatedSets.reserve(MaxSet); - - auto& poolData = m_descriptorPools.emplace_back(std::move(pool)); - Vk::DescriptorSet descriptorSet = poolData.descriptorPool.AllocateDescriptorSet(m_descriptorSetLayout); - if (!descriptorSet) - throw std::runtime_error("Failed to allocate descriptor set: " + TranslateVulkanError(pool.descriptorPool.GetLastErrorCode())); - - return poolData.allocatedSets.emplace_back(*this, std::move(descriptorSet)); + return bindingPtr; } bool VulkanRenderPipelineLayout::Create(Vk::Device& device, RenderPipelineLayoutInfo layoutInfo) @@ -75,4 +68,69 @@ namespace Nz return true; } + + auto VulkanRenderPipelineLayout::AllocatePool() -> DescriptorPool& + { + StackVector poolSizes = NazaraStackVector(VkDescriptorPoolSize, m_layoutInfo.bindings.size()); + + constexpr UInt32 MaxSet = 128; + + for (const auto& bindingInfo : m_layoutInfo.bindings) + { + VkDescriptorPoolSize& poolSize = poolSizes.emplace_back(); + poolSize.descriptorCount = MaxSet; + poolSize.type = ToVulkan(bindingInfo.type); + } + + DescriptorPool pool; + if (!pool.descriptorPool.Create(*m_device, MaxSet, UInt32(poolSizes.size()), poolSizes.data(), VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT)) + throw std::runtime_error("Failed to allocate new descriptor pool: " + TranslateVulkanError(pool.descriptorPool.GetLastErrorCode())); + + pool.freeBindings.Resize(MaxSet, true); + pool.storage = std::make_unique(MaxSet); + + return m_descriptorPools.emplace_back(std::move(pool)); + } + + ShaderBindingPtr VulkanRenderPipelineLayout::AllocateFromPool(std::size_t poolIndex) + { + auto& pool = m_descriptorPools[poolIndex]; + + std::size_t freeBindingId = pool.freeBindings.FindFirst(); + if (freeBindingId == pool.freeBindings.npos) + return {}; //< No free binding in this pool + + Vk::DescriptorSet descriptorSet = pool.descriptorPool.AllocateDescriptorSet(m_descriptorSetLayout); + if (!descriptorSet) + { + NazaraWarning("Failed to allocate descriptor set: " + TranslateVulkanError(pool.descriptorPool.GetLastErrorCode())); + return {}; + } + + pool.freeBindings.Reset(freeBindingId); + + VulkanShaderBinding* freeBindingMemory = reinterpret_cast(&pool.storage[freeBindingId]); + return ShaderBindingPtr(PlacementNew(freeBindingMemory, *this, poolIndex, freeBindingId, std::move(descriptorSet))); + } + + void VulkanRenderPipelineLayout::Release(ShaderBinding& binding) + { + VulkanShaderBinding& vulkanBinding = static_cast(binding); + + std::size_t poolIndex = vulkanBinding.GetPoolIndex(); + std::size_t bindingIndex = vulkanBinding.GetBindingIndex(); + + assert(poolIndex < m_descriptorPools.size()); + auto& pool = m_descriptorPools[poolIndex]; + assert(!pool.freeBindings.Test(bindingIndex)); + + VulkanShaderBinding* bindingMemory = reinterpret_cast(&pool.storage[bindingIndex]); + PlacementDestroy(bindingMemory); + + pool.freeBindings.Set(bindingIndex); + + // Try to free pool if it's one of the last one + if (poolIndex >= m_descriptorPools.size() - 1 && poolIndex <= m_descriptorPools.size()) + TryToShrink(); + } } diff --git a/src/Nazara/VulkanRenderer/VulkanShaderBinding.cpp b/src/Nazara/VulkanRenderer/VulkanShaderBinding.cpp index 4f1d4754b..58f9731ac 100644 --- a/src/Nazara/VulkanRenderer/VulkanShaderBinding.cpp +++ b/src/Nazara/VulkanRenderer/VulkanShaderBinding.cpp @@ -67,4 +67,9 @@ namespace Nz m_owner.GetDevice()->vkUpdateDescriptorSets(*m_owner.GetDevice(), UInt32(writeOps.size()), writeOps.data(), 0U, nullptr); } + + void VulkanShaderBinding::Release() + { + m_owner.Release(*this); + } } From f6d21d066ee29d6b3ff76bf960982c16d81feedb Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 6 Apr 2020 21:14:18 +0200 Subject: [PATCH 141/316] Vulkan: Improve RenderWindow subpass dependencies --- src/Nazara/VulkanRenderer/VkRenderWindow.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp index e9114c6c2..d9719dca5 100644 --- a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp +++ b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp @@ -292,7 +292,7 @@ namespace Nz } bool VkRenderWindow::SetupRenderPass() -{ + { std::array attachments = { { { @@ -344,23 +344,23 @@ namespace Nz }; std::array dependencies; - // First dependency at the start of the renderpass + // First dependency at the start of the render pass // Does the transition from final to initial layout dependencies[0].srcSubpass = VK_SUBPASS_EXTERNAL; // Producer of the dependency - dependencies[0].dstSubpass = 0; // Consumer is our single subpass that will wait for the execution depdendency - dependencies[0].srcStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT; + dependencies[0].dstSubpass = 0; // Consumer is our single subpass that will wait for the execution dependency + dependencies[0].srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; dependencies[0].dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; - dependencies[0].srcAccessMask = VK_ACCESS_MEMORY_READ_BIT; - dependencies[0].dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; + dependencies[0].srcAccessMask = 0; + dependencies[0].dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; dependencies[0].dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT; - // Second dependency at the end the renderpass + // Second dependency at the end the render pass // Does the transition from the initial to the final layout dependencies[1].srcSubpass = 0; // Producer of the dependency is our single subpass - dependencies[1].dstSubpass = VK_SUBPASS_EXTERNAL; // Consumer are all commands outside of the renderpass + dependencies[1].dstSubpass = VK_SUBPASS_EXTERNAL; // Consumer are all commands outside of the render pass dependencies[1].srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; dependencies[1].dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT; - dependencies[1].srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; + dependencies[1].srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; dependencies[1].dstAccessMask = VK_ACCESS_MEMORY_READ_BIT; dependencies[1].dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT; From 87f120932714687c3cce3f2b9ede290beb5ba117 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 7 Apr 2020 21:10:16 +0200 Subject: [PATCH 142/316] Vulkan: Refactor command buffer and introduce command pool --- examples/VulkanTest/main.cpp | 8 ++- include/Nazara/Core/Bitset.inl | 7 +-- include/Nazara/Renderer.hpp | 1 + include/Nazara/Renderer/CommandPool.hpp | 37 +++++++++++ include/Nazara/Renderer/CommandPool.inl | 12 ++++ include/Nazara/Renderer/Enums.hpp | 17 ++++++ include/Nazara/Renderer/RenderDevice.hpp | 2 + include/Nazara/Renderer/RenderImage.hpp | 5 +- include/Nazara/Renderer/RenderWindowImpl.hpp | 7 +-- include/Nazara/VulkanRenderer.hpp | 1 + .../Nazara/VulkanRenderer/VkRenderWindow.hpp | 6 +- include/Nazara/VulkanRenderer/Vulkan.hpp | 4 +- .../VulkanRenderer/VulkanCommandPool.hpp | 38 ++++++++++++ .../VulkanRenderer/VulkanCommandPool.inl | 28 +++++++++ .../Nazara/VulkanRenderer/VulkanDevice.hpp | 1 + .../VulkanRenderer/VulkanRenderImage.hpp | 6 +- .../Nazara/VulkanRenderer/Wrapper/Device.hpp | 13 +++- .../Nazara/VulkanRenderer/Wrapper/Device.inl | 4 +- src/Nazara/Renderer/CommandPool.cpp | 11 ++++ src/Nazara/VulkanRenderer/VkRenderWindow.cpp | 51 ++++++++-------- src/Nazara/VulkanRenderer/Vulkan.cpp | 24 +++++++- src/Nazara/VulkanRenderer/VulkanBuffer.cpp | 4 +- .../VulkanRenderer/VulkanCommandPool.cpp | 28 +++++++++ src/Nazara/VulkanRenderer/VulkanDevice.cpp | 6 ++ .../VulkanRenderer/VulkanRenderImage.cpp | 12 ++-- src/Nazara/VulkanRenderer/VulkanTexture.cpp | 4 +- src/Nazara/VulkanRenderer/Wrapper/Device.cpp | 61 +++++++++++++------ 27 files changed, 313 insertions(+), 85 deletions(-) create mode 100644 include/Nazara/Renderer/CommandPool.hpp create mode 100644 include/Nazara/Renderer/CommandPool.inl create mode 100644 include/Nazara/VulkanRenderer/VulkanCommandPool.hpp create mode 100644 include/Nazara/VulkanRenderer/VulkanCommandPool.inl create mode 100644 src/Nazara/Renderer/CommandPool.cpp create mode 100644 src/Nazara/VulkanRenderer/VulkanCommandPool.cpp diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index 2d6febd0e..14d124da4 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -210,6 +210,8 @@ int main() Nz::VkRenderWindow& vulkanWindow = *static_cast(window.GetImpl()); Nz::VulkanDevice& vulkanDevice = vulkanWindow.GetDevice(); + std::unique_ptr commandPool = vulkanWindow.CreateCommandPool(Nz::QueueType::Graphics); + Nz::UInt32 imageCount = vulkanWindow.GetFramebufferCount(); std::vector> renderCmds(imageCount); @@ -258,7 +260,7 @@ int main() clearValues.data() // const VkClearValue *pClearValues }; - commandBufferPtr = vulkanWindow.BuildCommandBuffer([&](Nz::CommandBufferBuilder& builder) + commandBufferPtr = commandPool->BuildCommandBuffer([&](Nz::CommandBufferBuilder& builder) { Nz::Vk::CommandBuffer& vkCommandBuffer = static_cast(builder).GetCommandBuffer(); @@ -372,11 +374,11 @@ int main() builder.PostTransferBarrier(); } builder.EndDebugRegion(); - }, false); + }, Nz::QueueType::Transfer); Nz::UInt32 imageIndex = renderImage.GetImageIndex(); - renderImage.SubmitCommandBuffer(renderCmds[imageIndex].get(), true); + renderImage.SubmitCommandBuffer(renderCmds[imageIndex].get(), Nz::QueueType::Graphics); renderImage.Present(); diff --git a/include/Nazara/Core/Bitset.inl b/include/Nazara/Core/Bitset.inl index 6100e5171..cc6d97250 100644 --- a/include/Nazara/Core/Bitset.inl +++ b/include/Nazara/Core/Bitset.inl @@ -1208,7 +1208,8 @@ namespace Nz template Block Bitset::GetLastBlockMask() const { - return (Block(1U) << GetBitIndex(m_bitCount)) - 1U; + std::size_t bitIndex = GetBitIndex(m_bitCount); + return (bitIndex) ? (Block(1U) << bitIndex) - 1U : fullBitMask; } /*! @@ -1218,9 +1219,7 @@ namespace Nz template void Bitset::ResetExtraBits() { - Block mask = GetLastBlockMask(); - if (mask) - m_blocks.back() &= mask; + m_blocks.back() &= GetLastBlockMask(); } /*! diff --git a/include/Nazara/Renderer.hpp b/include/Nazara/Renderer.hpp index df330e594..9ab23b09c 100644 --- a/include/Nazara/Renderer.hpp +++ b/include/Nazara/Renderer.hpp @@ -31,6 +31,7 @@ #include #include +#include #include #include #include diff --git a/include/Nazara/Renderer/CommandPool.hpp b/include/Nazara/Renderer/CommandPool.hpp new file mode 100644 index 000000000..ec52d83d2 --- /dev/null +++ b/include/Nazara/Renderer/CommandPool.hpp @@ -0,0 +1,37 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_COMMANDPOOL_HPP +#define NAZARA_COMMANDPOOL_HPP + +#include +#include +#include +#include //< temporary + +namespace Nz +{ + class CommandBuffer; + class CommandBufferBuilder; + + class NAZARA_RENDERER_API CommandPool + { + public: + CommandPool() = default; + CommandPool(const CommandPool&) = delete; + CommandPool(CommandPool&&) = default; + virtual ~CommandPool(); + + virtual std::unique_ptr BuildCommandBuffer(const std::function& callback) = 0; + + CommandPool& operator=(const CommandPool&) = delete; + CommandPool& operator=(CommandPool&&) = default; + }; +} + +#include + +#endif // NAZARA_COMMANDPOOL_HPP diff --git a/include/Nazara/Renderer/CommandPool.inl b/include/Nazara/Renderer/CommandPool.inl new file mode 100644 index 000000000..874c9c648 --- /dev/null +++ b/include/Nazara/Renderer/CommandPool.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ +} + +#include diff --git a/include/Nazara/Renderer/Enums.hpp b/include/Nazara/Renderer/Enums.hpp index 4721662ff..a9b33ba5f 100644 --- a/include/Nazara/Renderer/Enums.hpp +++ b/include/Nazara/Renderer/Enums.hpp @@ -69,6 +69,23 @@ namespace Nz using ShaderStageTypeFlags = Flags; constexpr ShaderStageTypeFlags ShaderStageType_All = ShaderStageType::Fragment | ShaderStageType::Vertex; + + enum class QueueType + { + Compute, + Graphics, + Transfer, + + Max = Transfer + }; + + template<> + struct EnumAsFlags + { + static constexpr QueueType max = QueueType::Max; + }; + + using QueueTypeFlags = Flags; } #endif // NAZARA_ENUMS_RENDERER_HPP diff --git a/include/Nazara/Renderer/RenderDevice.hpp b/include/Nazara/Renderer/RenderDevice.hpp index ad48155a4..df8029bf2 100644 --- a/include/Nazara/Renderer/RenderDevice.hpp +++ b/include/Nazara/Renderer/RenderDevice.hpp @@ -20,6 +20,7 @@ namespace Nz { + class CommandPool; class ShaderStageImpl; class NAZARA_RENDERER_API RenderDevice @@ -29,6 +30,7 @@ namespace Nz virtual ~RenderDevice(); virtual std::unique_ptr InstantiateBuffer(BufferType type) = 0; + virtual std::unique_ptr InstantiateCommandPool(QueueType queueType) = 0; virtual std::unique_ptr InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) = 0; virtual std::shared_ptr InstantiateRenderPipelineLayout(RenderPipelineLayoutInfo pipelineLayoutInfo) = 0; virtual std::shared_ptr InstantiateShaderStage(ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) = 0; diff --git a/include/Nazara/Renderer/RenderImage.hpp b/include/Nazara/Renderer/RenderImage.hpp index 2661f45c7..1ab5310ff 100644 --- a/include/Nazara/Renderer/RenderImage.hpp +++ b/include/Nazara/Renderer/RenderImage.hpp @@ -9,6 +9,7 @@ #include #include +#include #include namespace Nz @@ -23,11 +24,11 @@ namespace Nz RenderImage() = default; virtual ~RenderImage(); - virtual void Execute(const std::function& callback, bool isGraphical) = 0; + virtual void Execute(const std::function& callback, QueueTypeFlags queueTypeFlags) = 0; virtual UploadPool& GetUploadPool() = 0; - virtual void SubmitCommandBuffer(CommandBuffer* commandBuffer, bool isGraphical) = 0; + virtual void SubmitCommandBuffer(CommandBuffer* commandBuffer, QueueTypeFlags queueTypeFlags) = 0; virtual void Present() = 0; diff --git a/include/Nazara/Renderer/RenderWindowImpl.hpp b/include/Nazara/Renderer/RenderWindowImpl.hpp index f0636e77a..3e0e0bce1 100644 --- a/include/Nazara/Renderer/RenderWindowImpl.hpp +++ b/include/Nazara/Renderer/RenderWindowImpl.hpp @@ -13,12 +13,10 @@ #include #include #include -#include namespace Nz { - class CommandBuffer; - class CommandBufferBuilder; + class CommandPool; class RendererImpl; class RenderImage; class RenderSurface; @@ -31,9 +29,8 @@ namespace Nz virtual RenderImage& Acquire() = 0; - virtual std::unique_ptr BuildCommandBuffer(const std::function& callback) = 0; - virtual bool Create(RendererImpl* renderer, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) = 0; + virtual std::unique_ptr CreateCommandPool(QueueType queueType) = 0; virtual std::shared_ptr GetRenderDevice() = 0; }; diff --git a/include/Nazara/VulkanRenderer.hpp b/include/Nazara/VulkanRenderer.hpp index b3a003a2a..ea1ffc4b9 100644 --- a/include/Nazara/VulkanRenderer.hpp +++ b/include/Nazara/VulkanRenderer.hpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include diff --git a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp index 719e9bd8e..ae1771e16 100644 --- a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp +++ b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -40,9 +41,8 @@ namespace Nz VulkanRenderImage& Acquire() override; - std::unique_ptr BuildCommandBuffer(const std::function& callback) override; - bool Create(RendererImpl* renderer, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) override; + std::unique_ptr CreateCommandPool(QueueType queueType) override; inline const Vk::Framebuffer& GetFrameBuffer(UInt32 imageIndex) const override; inline UInt32 GetFramebufferCount() const override; @@ -77,12 +77,12 @@ namespace Nz std::shared_ptr m_device; std::vector m_imageData; std::vector m_concurrentImageData; - Vk::CommandPool m_graphicsCommandPool; Vk::DeviceMemory m_depthBufferMemory; Vk::Image m_depthBuffer; Vk::ImageView m_depthBufferView; Vk::QueueHandle m_graphicsQueue; Vk::QueueHandle m_presentQueue; + Vk::QueueHandle m_transferQueue; Vk::Swapchain m_swapchain; }; } diff --git a/include/Nazara/VulkanRenderer/Vulkan.hpp b/include/Nazara/VulkanRenderer/Vulkan.hpp index d87afbec1..12db5feb9 100644 --- a/include/Nazara/VulkanRenderer/Vulkan.hpp +++ b/include/Nazara/VulkanRenderer/Vulkan.hpp @@ -36,7 +36,7 @@ namespace Nz ~Vulkan() = delete; static std::shared_ptr CreateDevice(const Vk::PhysicalDevice& deviceInfo); - static std::shared_ptr CreateDevice(const Vk::PhysicalDevice& deviceInfo, const Vk::Surface& surface, UInt32* graphicsFamilyIndex, UInt32* presentableFamilyIndex); + static std::shared_ptr CreateDevice(const Vk::PhysicalDevice& deviceInfo, const Vk::Surface& surface, UInt32* graphicsFamilyIndex, UInt32* presentableFamilyIndex, UInt32* transferFamilyIndex); static std::shared_ptr CreateDevice(const Vk::PhysicalDevice& deviceInfo, const QueueFamily* queueFamilies, std::size_t queueFamilyCount); static Vk::Instance& GetInstance(); @@ -49,7 +49,7 @@ namespace Nz static bool IsInitialized(); static std::shared_ptr SelectDevice(const Vk::PhysicalDevice& deviceInfo); - static std::shared_ptr SelectDevice(const Vk::PhysicalDevice& deviceInfo, const Vk::Surface& surface, UInt32* graphicsFamilyIndex, UInt32* presentableFamilyIndex); + static std::shared_ptr SelectDevice(const Vk::PhysicalDevice& deviceInfo, const Vk::Surface& surface, UInt32* graphicsFamilyIndex, UInt32* presentableFamilyIndex, UInt32* transferFamilyIndex); static void Uninitialize(); diff --git a/include/Nazara/VulkanRenderer/VulkanCommandPool.hpp b/include/Nazara/VulkanRenderer/VulkanCommandPool.hpp new file mode 100644 index 000000000..5fbdb6ab9 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanCommandPool.hpp @@ -0,0 +1,38 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VULKANCOMMANDPOOL_HPP +#define NAZARA_VULKANRENDERER_VULKANCOMMANDPOOL_HPP + +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_VULKANRENDERER_API VulkanCommandPool final : public CommandPool + { + public: + inline VulkanCommandPool(Vk::Device& device, QueueType queueType); + inline VulkanCommandPool(Vk::Device& device, UInt32 queueFamilyIndex); + VulkanCommandPool(const VulkanCommandPool&) = delete; + VulkanCommandPool(VulkanCommandPool&&) noexcept = default; + ~VulkanCommandPool() = default; + + std::unique_ptr BuildCommandBuffer(const std::function& callback) override; + + VulkanCommandPool& operator=(const VulkanCommandPool&) = delete; + VulkanCommandPool& operator=(VulkanCommandPool&&) = delete; + + private: + Vk::CommandPool m_commandPool; + }; +} + +#include + +#endif // NAZARA_VULKANRENDERER_VULKANCOMMANDPOOL_HPP diff --git a/include/Nazara/VulkanRenderer/VulkanCommandPool.inl b/include/Nazara/VulkanRenderer/VulkanCommandPool.inl new file mode 100644 index 000000000..77a6066a7 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanCommandPool.inl @@ -0,0 +1,28 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + inline VulkanCommandPool::VulkanCommandPool(Vk::Device& device, QueueType queueType) + { + UInt32 queueFamilyIndex = device.GetDefaultFamilyIndex(queueType); + if (queueFamilyIndex == Vk::Device::InvalidQueue) + throw std::runtime_error("QueueType " + std::to_string(UnderlyingCast(queueType)) + " is not supported"); + + if (!m_commandPool.Create(device, queueFamilyIndex)) + throw std::runtime_error("Failed to create command pool: " + TranslateVulkanError(m_commandPool.GetLastErrorCode())); + } + + inline VulkanCommandPool::VulkanCommandPool(Vk::Device& device, UInt32 queueFamilyIndex) + { + if (!m_commandPool.Create(device, queueFamilyIndex)) + throw std::runtime_error("Failed to create command pool: " + TranslateVulkanError(m_commandPool.GetLastErrorCode())); + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/VulkanDevice.hpp b/include/Nazara/VulkanRenderer/VulkanDevice.hpp index ce717c414..658a81401 100644 --- a/include/Nazara/VulkanRenderer/VulkanDevice.hpp +++ b/include/Nazara/VulkanRenderer/VulkanDevice.hpp @@ -24,6 +24,7 @@ namespace Nz ~VulkanDevice(); std::unique_ptr InstantiateBuffer(BufferType type) override; + std::unique_ptr InstantiateCommandPool(QueueType queueType) override; std::unique_ptr InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) override; std::shared_ptr InstantiateRenderPipelineLayout(RenderPipelineLayoutInfo pipelineLayoutInfo) override; std::shared_ptr InstantiateShaderStage(ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) override; diff --git a/include/Nazara/VulkanRenderer/VulkanRenderImage.hpp b/include/Nazara/VulkanRenderer/VulkanRenderImage.hpp index 576109245..f7033b799 100644 --- a/include/Nazara/VulkanRenderer/VulkanRenderImage.hpp +++ b/include/Nazara/VulkanRenderer/VulkanRenderImage.hpp @@ -28,7 +28,7 @@ namespace Nz VulkanRenderImage(VulkanRenderImage&&) noexcept = default; ~VulkanRenderImage(); - void Execute(const std::function& callback, bool isGraphical) override; + void Execute(const std::function& callback, QueueTypeFlags queueTypeFlags) override; inline Vk::Fence& GetInFlightFence(); inline Vk::Semaphore& GetImageAvailableSemaphore(); @@ -36,8 +36,8 @@ namespace Nz inline Vk::Semaphore& GetRenderFinishedSemaphore(); VulkanUploadPool& GetUploadPool() override; - void SubmitCommandBuffer(CommandBuffer* commandBuffer, bool isGraphical) override; - void SubmitCommandBuffer(VkCommandBuffer commandBuffer, bool isGraphical); + void SubmitCommandBuffer(CommandBuffer* commandBuffer, QueueTypeFlags queueTypeFlags) override; + void SubmitCommandBuffer(VkCommandBuffer commandBuffer, QueueTypeFlags queueTypeFlags); void Present() override; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp index 86c42ad5f..2f3ded74f 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp @@ -8,10 +8,13 @@ #define NAZARA_VULKANRENDERER_VKDEVICE_HPP #include +#include +#include #include #include #include #include +#include #include #include @@ -38,7 +41,7 @@ namespace Nz Device(Device&&) = delete; ~Device(); - AutoCommandBuffer AllocateTransferCommandBuffer(); + AutoCommandBuffer AllocateCommandBuffer(QueueType queueType); bool Create(const Vk::PhysicalDevice& deviceInfo, const VkDeviceCreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); inline void Destroy(); @@ -54,7 +57,7 @@ namespace Nz inline VkPhysicalDevice GetPhysicalDevice() const; inline const Vk::PhysicalDevice& GetPhysicalDeviceInfo() const; - inline UInt32 GetTransferQueueFamilyIndex() const; + inline UInt32 GetDefaultFamilyIndex(QueueType queueType) const; inline bool IsExtensionLoaded(const std::string& extensionName); inline bool IsLayerLoaded(const std::string& layerName); @@ -99,6 +102,8 @@ namespace Nz UInt32 timestampValidBits; }; + static constexpr UInt32 InvalidQueue = std::numeric_limits::max(); + private: void ResetPointers(); void WaitAndDestroyDevice(); @@ -107,6 +112,8 @@ namespace Nz struct InternalData; + static constexpr std::size_t QueueCount = static_cast(QueueType::Max) + 1; + std::unique_ptr m_internalData; Instance& m_instance; const Vk::PhysicalDevice* m_physicalDevice; @@ -114,7 +121,7 @@ namespace Nz VkDevice m_device; VkResult m_lastErrorCode; VmaAllocator m_memAllocator; - UInt32 m_transferQueueFamilyIndex; + std::array m_defaultQueues; std::unordered_set m_loadedExtensions; std::unordered_set m_loadedLayers; std::vector m_enabledQueuesInfos; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Device.inl b/include/Nazara/VulkanRenderer/Wrapper/Device.inl index 1e8617731..e3552e199 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Device.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Device.inl @@ -54,9 +54,9 @@ namespace Nz return *m_physicalDevice; } - inline UInt32 Device::GetTransferQueueFamilyIndex() const + inline UInt32 Device::GetDefaultFamilyIndex(QueueType queueType) const { - return m_transferQueueFamilyIndex; + return m_defaultQueues[UnderlyingCast(queueType)]; } inline bool Device::IsExtensionLoaded(const std::string& extensionName) diff --git a/src/Nazara/Renderer/CommandPool.cpp b/src/Nazara/Renderer/CommandPool.cpp new file mode 100644 index 000000000..6d0b412e4 --- /dev/null +++ b/src/Nazara/Renderer/CommandPool.cpp @@ -0,0 +1,11 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + CommandPool::~CommandPool() = default; +} diff --git a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp index d9719dca5..7e5ce6fff 100644 --- a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp +++ b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp @@ -7,8 +7,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -29,7 +28,6 @@ namespace Nz m_device->WaitForIdle(); m_concurrentImageData.clear(); - m_graphicsCommandPool.Destroy(); m_imageData.clear(); m_renderPass.Destroy(); m_swapchain.Destroy(); @@ -60,22 +58,6 @@ namespace Nz return currentFrame; } - std::unique_ptr VkRenderWindow::BuildCommandBuffer(const std::function& callback) - { - Vk::AutoCommandBuffer commandBuffer = m_graphicsCommandPool.AllocateCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY); - - if (!commandBuffer->Begin()) - throw std::runtime_error("failed to begin command buffer: " + TranslateVulkanError(commandBuffer->GetLastErrorCode())); - - VulkanCommandBufferBuilder builder(commandBuffer.Get()); - callback(builder); - - if (!commandBuffer->End()) - throw std::runtime_error("failed to build command buffer: " + TranslateVulkanError(commandBuffer->GetLastErrorCode())); - - return std::make_unique(std::move(commandBuffer)); - } - bool VkRenderWindow::Create(RendererImpl* /*renderer*/, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) { const auto& deviceInfo = Vulkan::GetPhysicalDevices()[0]; @@ -84,7 +66,8 @@ namespace Nz UInt32 graphicsFamilyQueueIndex; UInt32 presentableFamilyQueueIndex; - m_device = Vulkan::SelectDevice(deviceInfo, vulkanSurface, &graphicsFamilyQueueIndex, &presentableFamilyQueueIndex); + UInt32 transferFamilyQueueIndex; + m_device = Vulkan::SelectDevice(deviceInfo, vulkanSurface, &graphicsFamilyQueueIndex, &presentableFamilyQueueIndex, &transferFamilyQueueIndex); if (!m_device) { NazaraError("Failed to get compatible Vulkan device"); @@ -93,6 +76,7 @@ namespace Nz m_graphicsQueue = m_device->GetQueue(graphicsFamilyQueueIndex, 0); m_presentQueue = m_device->GetQueue(presentableFamilyQueueIndex, 0); + m_transferQueue = m_device->GetQueue(transferFamilyQueueIndex, 0); std::vector surfaceFormats; if (!vulkanSurface.GetFormats(deviceInfo.physDevice, &surfaceFormats)) @@ -204,12 +188,6 @@ namespace Nz } } - if (!m_graphicsCommandPool.Create(*m_device, m_graphicsQueue.GetQueueFamilyIndex())) - { - NazaraError("Failed to create graphics command pool: " + TranslateVulkanError(m_graphicsCommandPool.GetLastErrorCode())); - return false; - } - const std::size_t MaxConcurrentImage = imageCount; m_concurrentImageData.reserve(MaxConcurrentImage); @@ -221,6 +199,27 @@ namespace Nz return true; } + std::unique_ptr VkRenderWindow::CreateCommandPool(QueueType queueType) + { + UInt32 queueFamilyIndex; + switch (queueType) + { + case QueueType::Compute: + queueFamilyIndex = m_device->GetDefaultFamilyIndex(QueueType::Compute); + break; + + case QueueType::Graphics: + queueFamilyIndex = m_graphicsQueue.GetQueueFamilyIndex(); + break; + + case QueueType::Transfer: + queueFamilyIndex = m_transferQueue.GetQueueFamilyIndex(); + break; + } + + return std::make_unique(*m_device, queueFamilyIndex); + } + bool VkRenderWindow::SetupDepthBuffer(const Vector2ui& size) { VkImageCreateInfo imageCreateInfo = { diff --git a/src/Nazara/VulkanRenderer/Vulkan.cpp b/src/Nazara/VulkanRenderer/Vulkan.cpp index a71043605..fd1e8ca9e 100644 --- a/src/Nazara/VulkanRenderer/Vulkan.cpp +++ b/src/Nazara/VulkanRenderer/Vulkan.cpp @@ -297,7 +297,7 @@ namespace Nz return CreateDevice(deviceInfo, queuesFamilies.data(), queuesFamilies.size()); } - std::shared_ptr Vulkan::CreateDevice(const Vk::PhysicalDevice& deviceInfo, const Vk::Surface& surface, UInt32* graphicsFamilyIndex, UInt32* presentableFamilyIndex) + std::shared_ptr Vulkan::CreateDevice(const Vk::PhysicalDevice& deviceInfo, const Vk::Surface& surface, UInt32* graphicsFamilyIndex, UInt32* presentableFamilyIndex, UInt32* transferFamilyIndex) { Nz::ErrorFlags errFlags(ErrorFlag_ThrowException, true); @@ -364,6 +364,7 @@ namespace Nz *graphicsFamilyIndex = graphicsQueueNodeIndex; *presentableFamilyIndex = presentQueueNodeIndex; + *transferFamilyIndex = transferQueueNodeFamily; return CreateDevice(deviceInfo, queuesFamilies.data(), queuesFamilies.size()); } @@ -497,7 +498,7 @@ namespace Nz return CreateDevice(deviceInfo); } - std::shared_ptr Vulkan::SelectDevice(const Vk::PhysicalDevice& deviceInfo, const Vk::Surface& surface, UInt32* graphicsFamilyIndex, UInt32* presentableFamilyIndex) + std::shared_ptr Vulkan::SelectDevice(const Vk::PhysicalDevice& deviceInfo, const Vk::Surface& surface, UInt32* graphicsFamilyIndex, UInt32* presentableFamilyIndex, UInt32* transferFamilyIndex) { // First, try to find a device compatible with that surface for (auto it = s_devices.begin(); it != s_devices.end();) @@ -540,6 +541,23 @@ namespace Nz if (presentableQueueFamilyIndex != UINT32_MAX) { *presentableFamilyIndex = presentableQueueFamilyIndex; + + UInt32 transferQueueNodeFamily = UINT32_MAX; + // Search for a transfer queue (first one being different to the graphics one) + for (const Vk::Device::QueueFamilyInfo& queueInfo : queueFamilyInfo) + { + // Transfer bit is not mandatory if compute and graphics bits are set (as they implicitly support transfer) + if (queueInfo.flags & (VK_QUEUE_COMPUTE_BIT | VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_TRANSFER_BIT)) + { + transferQueueNodeFamily = queueInfo.familyIndex; + if (transferQueueNodeFamily != *graphicsFamilyIndex) + break; + } + } + assert(transferQueueNodeFamily != UINT32_MAX); + + *transferFamilyIndex = transferQueueNodeFamily; + return devicePtr; } } @@ -548,7 +566,7 @@ namespace Nz } // No device had support for that surface, create one - return CreateDevice(deviceInfo, surface, graphicsFamilyIndex, presentableFamilyIndex); + return CreateDevice(deviceInfo, surface, graphicsFamilyIndex, presentableFamilyIndex, transferFamilyIndex); } void Vulkan::Uninitialize() diff --git a/src/Nazara/VulkanRenderer/VulkanBuffer.cpp b/src/Nazara/VulkanRenderer/VulkanBuffer.cpp index e338ac9e7..90ffe3615 100644 --- a/src/Nazara/VulkanRenderer/VulkanBuffer.cpp +++ b/src/Nazara/VulkanRenderer/VulkanBuffer.cpp @@ -126,7 +126,7 @@ namespace Nz } else { - Vk::AutoCommandBuffer copyCommandBuffer = m_device.AllocateTransferCommandBuffer(); + Vk::AutoCommandBuffer copyCommandBuffer = m_device.AllocateCommandBuffer(QueueType::Transfer); if (!copyCommandBuffer->Begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT)) return false; @@ -134,7 +134,7 @@ namespace Nz if (!copyCommandBuffer->End()) return false; - Vk::QueueHandle transferQueue = m_device.GetQueue(m_device.GetTransferQueueFamilyIndex(), 0); + Vk::QueueHandle transferQueue = m_device.GetQueue(m_device.GetDefaultFamilyIndex(QueueType::Transfer), 0); if (!transferQueue.Submit(copyCommandBuffer)) return false; diff --git a/src/Nazara/VulkanRenderer/VulkanCommandPool.cpp b/src/Nazara/VulkanRenderer/VulkanCommandPool.cpp new file mode 100644 index 000000000..771acded3 --- /dev/null +++ b/src/Nazara/VulkanRenderer/VulkanCommandPool.cpp @@ -0,0 +1,28 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include + +namespace Nz +{ + std::unique_ptr VulkanCommandPool::BuildCommandBuffer(const std::function& callback) + { + Vk::AutoCommandBuffer commandBuffer = m_commandPool.AllocateCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY); + + if (!commandBuffer->Begin()) + throw std::runtime_error("failed to begin command buffer: " + TranslateVulkanError(commandBuffer->GetLastErrorCode())); + + VulkanCommandBufferBuilder builder(commandBuffer.Get()); + callback(builder); + + if (!commandBuffer->End()) + throw std::runtime_error("failed to build command buffer: " + TranslateVulkanError(commandBuffer->GetLastErrorCode())); + + return std::make_unique(std::move(commandBuffer)); + } +} diff --git a/src/Nazara/VulkanRenderer/VulkanDevice.cpp b/src/Nazara/VulkanRenderer/VulkanDevice.cpp index 0f8ce9a9f..b20932dda 100644 --- a/src/Nazara/VulkanRenderer/VulkanDevice.cpp +++ b/src/Nazara/VulkanRenderer/VulkanDevice.cpp @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include #include #include @@ -19,6 +20,11 @@ namespace Nz return std::make_unique(*this, type); } + std::unique_ptr VulkanDevice::InstantiateCommandPool(QueueType queueType) + { + return std::make_unique(*this, queueType); + } + std::unique_ptr VulkanDevice::InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) { return std::make_unique(*this, std::move(pipelineInfo)); diff --git a/src/Nazara/VulkanRenderer/VulkanRenderImage.cpp b/src/Nazara/VulkanRenderer/VulkanRenderImage.cpp index 9cade7921..67ed19601 100644 --- a/src/Nazara/VulkanRenderer/VulkanRenderImage.cpp +++ b/src/Nazara/VulkanRenderer/VulkanRenderImage.cpp @@ -34,7 +34,7 @@ namespace Nz m_inFlightCommandBuffers.clear(); } - void VulkanRenderImage::Execute(const std::function& callback, bool isGraphical) + void VulkanRenderImage::Execute(const std::function& callback, QueueTypeFlags queueTypeFlags) { Vk::CommandBuffer* commandBuffer; if (m_currentCommandBuffer >= m_inFlightCommandBuffers.size()) @@ -55,7 +55,7 @@ namespace Nz if (!commandBuffer->End()) throw std::runtime_error("failed to build command buffer: " + TranslateVulkanError(commandBuffer->GetLastErrorCode())); - SubmitCommandBuffer(*commandBuffer, isGraphical); + SubmitCommandBuffer(*commandBuffer, queueTypeFlags); } VulkanUploadPool& VulkanRenderImage::GetUploadPool() @@ -63,16 +63,16 @@ namespace Nz return m_uploadPool; } - void VulkanRenderImage::SubmitCommandBuffer(CommandBuffer* commandBuffer, bool isGraphical) + void VulkanRenderImage::SubmitCommandBuffer(CommandBuffer* commandBuffer, QueueTypeFlags queueTypeFlags) { VulkanCommandBuffer& vkCommandBuffer = *static_cast(commandBuffer); - return SubmitCommandBuffer(vkCommandBuffer.GetCommandBuffer(), isGraphical); + return SubmitCommandBuffer(vkCommandBuffer.GetCommandBuffer(), queueTypeFlags); } - void VulkanRenderImage::SubmitCommandBuffer(VkCommandBuffer commandBuffer, bool isGraphical) + void VulkanRenderImage::SubmitCommandBuffer(VkCommandBuffer commandBuffer, QueueTypeFlags queueTypeFlags) { - if (isGraphical) + if (queueTypeFlags & QueueType::Graphics) m_graphicalCommandsBuffers.push_back(commandBuffer); else { diff --git a/src/Nazara/VulkanRenderer/VulkanTexture.cpp b/src/Nazara/VulkanRenderer/VulkanTexture.cpp index f991051d3..186bbebbb 100644 --- a/src/Nazara/VulkanRenderer/VulkanTexture.cpp +++ b/src/Nazara/VulkanRenderer/VulkanTexture.cpp @@ -207,7 +207,7 @@ namespace Nz std::memcpy(allocationInfo.pMappedData, ptr, textureSize); - Vk::AutoCommandBuffer copyCommandBuffer = m_device.AllocateTransferCommandBuffer(); + Vk::AutoCommandBuffer copyCommandBuffer = m_device.AllocateCommandBuffer(QueueType::Graphics); if (!copyCommandBuffer->Begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT)) return false; @@ -220,7 +220,7 @@ namespace Nz if (!copyCommandBuffer->End()) return false; - Vk::QueueHandle transferQueue = m_device.GetQueue(m_device.GetTransferQueueFamilyIndex(), 0); + Vk::QueueHandle transferQueue = m_device.GetQueue(m_device.GetDefaultFamilyIndex(QueueType::Graphics), 0); if (!transferQueue.Submit(copyCommandBuffer)) return false; diff --git a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp index 6c02c7381..7d9d5f874 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/Device.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Device.cpp @@ -22,7 +22,7 @@ namespace Nz { struct Device::InternalData { - Vk::CommandPool transferCommandPool; + std::array commandPools; }; Device::Device(Instance& instance) : @@ -40,9 +40,9 @@ namespace Nz WaitAndDestroyDevice(); } - AutoCommandBuffer Device::AllocateTransferCommandBuffer() + AutoCommandBuffer Device::AllocateCommandBuffer(QueueType queueType) { - return m_internalData->transferCommandPool.AllocateCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY); + return m_internalData->commandPools[UnderlyingCast(queueType)].AllocateCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY); } bool Device::Create(const Vk::PhysicalDevice& deviceInfo, const VkDeviceCreateInfo& createInfo, const VkAllocationCallbacks* allocator) @@ -107,8 +107,6 @@ namespace Nz } // And retains informations about queues - m_transferQueueFamilyIndex = UINT32_MAX; - UInt32 maxFamilyIndex = 0; m_enabledQueuesInfos.resize(createInfo.queueCreateInfoCount); for (UInt32 i = 0; i < createInfo.queueCreateInfoCount; ++i) @@ -133,17 +131,6 @@ namespace Nz queueInfo.priority = queueCreateInfo.pQueuePriorities[queueIndex]; vkGetDeviceQueue(m_device, info.familyIndex, queueIndex, &queueInfo.queue); } - - if (info.flags & (VK_QUEUE_TRANSFER_BIT | VK_QUEUE_COMPUTE_BIT | VK_QUEUE_GRAPHICS_BIT)) - { - if (m_transferQueueFamilyIndex == UINT32_MAX) - m_transferQueueFamilyIndex = info.familyIndex; - else if ((info.flags & (VK_QUEUE_COMPUTE_BIT | VK_QUEUE_GRAPHICS_BIT)) == 0) - { - m_transferQueueFamilyIndex = info.familyIndex; - break; - } - } } m_queuesByFamily.resize(maxFamilyIndex + 1); @@ -151,12 +138,48 @@ namespace Nz m_queuesByFamily[familyInfo.familyIndex] = &familyInfo.queues; m_internalData = std::make_unique(); - if (!m_internalData->transferCommandPool.Create(*this, m_transferQueueFamilyIndex, VK_COMMAND_POOL_CREATE_TRANSIENT_BIT)) + + m_defaultQueues.fill(InvalidQueue); + for (QueueType queueType : { QueueType::Graphics, QueueType::Compute, QueueType::Transfer }) { - NazaraError("Failed to create transfer command pool: " + TranslateVulkanError(m_internalData->transferCommandPool.GetLastErrorCode())); - return false; + auto QueueTypeToFlags = [](QueueType type) -> VkQueueFlags + { + switch (type) + { + case QueueType::Compute: return VK_QUEUE_COMPUTE_BIT; + case QueueType::Graphics: return VK_QUEUE_GRAPHICS_BIT; + case QueueType::Transfer: return VK_QUEUE_COMPUTE_BIT | VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_TRANSFER_BIT; //< Compute/graphics imply transfer + } + + return 0U; + }; + + std::size_t queueIndex = static_cast(queueType); + for (const QueueFamilyInfo& familyInfo : m_enabledQueuesInfos) + { + if (familyInfo.flags & QueueTypeToFlags(queueType) == 0) + continue; + + m_defaultQueues[queueIndex] = familyInfo.familyIndex; + + // Break only if queue has not been selected before + auto queueBegin = m_defaultQueues.begin(); + auto queueEnd = queueBegin + queueIndex; + + if (std::find(queueBegin, queueEnd, familyInfo.familyIndex) == queueEnd) + break; + } + + Vk::CommandPool& commandPool = m_internalData->commandPools[queueIndex]; + if (!commandPool.Create(*this, m_defaultQueues[queueIndex], VK_COMMAND_POOL_CREATE_TRANSIENT_BIT)) + { + NazaraError("Failed to create command pool: " + TranslateVulkanError(commandPool.GetLastErrorCode())); + return false; + } } + assert(GetDefaultFamilyIndex(QueueType::Transfer) != InvalidQueue); + // Initialize VMA VmaVulkanFunctions vulkanFunctions = { m_instance.vkGetPhysicalDeviceProperties, From 9507c56fc904efa0c32606e761843cabcde04299 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 10 Apr 2020 14:19:36 +0200 Subject: [PATCH 143/316] PixelFormat rename PixelFormatInfo => PixelFormatDescription PixelFormat => PixelFormatInfo PixelFormatType => PixelFormat --- examples/Particles/LogoDemo.cpp | 2 +- examples/Particles/SpacebattleDemo.cpp | 2 +- examples/Particles/main.cpp | 2 +- examples/VulkanTest/main.cpp | 2 +- include/Nazara/Graphics/Light.hpp | 6 +- include/Nazara/Graphics/Light.inl | 6 +- .../Renderer/RenderWindowParameters.hpp | 2 +- include/Nazara/Renderer/Texture.hpp | 4 +- include/Nazara/Utility/AbstractImage.hpp | 2 +- include/Nazara/Utility/Enums.hpp | 110 +-- include/Nazara/Utility/Image.hpp | 16 +- include/Nazara/Utility/PixelFormat.hpp | 52 +- include/Nazara/Utility/PixelFormat.inl | 60 +- .../Nazara/VulkanRenderer/VulkanTexture.hpp | 4 +- src/Nazara/Graphics/DeferredBloomPass.cpp | 2 +- src/Nazara/Graphics/DeferredDOFPass.cpp | 2 +- src/Nazara/Graphics/DeferredGeometryPass.cpp | 10 +- src/Nazara/Graphics/Graphics.cpp | 4 +- .../Graphics/GuillotineTextureAtlas.cpp | 2 +- src/Nazara/Graphics/Light.cpp | 2 +- src/Nazara/Platform/Win32/CursorImpl.cpp | 2 +- src/Nazara/Platform/Win32/IconImpl.cpp | 2 +- src/Nazara/Utility/AbstractImage.cpp | 4 +- src/Nazara/Utility/Formats/DDSLoader.cpp | 36 +- src/Nazara/Utility/Formats/FreeTypeLoader.cpp | 2 +- src/Nazara/Utility/Formats/PCXLoader.cpp | 4 +- src/Nazara/Utility/Formats/STBLoader.cpp | 4 +- src/Nazara/Utility/Formats/STBSaver.cpp | 32 +- src/Nazara/Utility/GuillotineImageAtlas.cpp | 2 +- src/Nazara/Utility/Image.cpp | 96 +-- src/Nazara/Utility/PixelFormat.cpp | 644 +++++++++--------- src/Nazara/Utility/Utility.cpp | 4 +- src/Nazara/VulkanRenderer/VkRenderWindow.cpp | 22 +- src/Nazara/VulkanRenderer/VulkanTexture.cpp | 16 +- .../Components/GraphicsComponent.cpp | 2 +- 35 files changed, 582 insertions(+), 582 deletions(-) diff --git a/examples/Particles/LogoDemo.cpp b/examples/Particles/LogoDemo.cpp index cb2509500..23698cd66 100644 --- a/examples/Particles/LogoDemo.cpp +++ b/examples/Particles/LogoDemo.cpp @@ -124,7 +124,7 @@ LogoExample::LogoExample(ExampleShared& sharedData) : ParticleDemo("Logo", sharedData) { Nz::ImageParams params; - params.loadFormat = Nz::PixelFormatType_RGBA8; + params.loadFormat = Nz::PixelFormat_RGBA8; m_logo = Nz::Image::LoadFromFile("E:/Twitch/avatar_interested.png", params); if (!m_logo) diff --git a/examples/Particles/SpacebattleDemo.cpp b/examples/Particles/SpacebattleDemo.cpp index d0c9e2749..2607c649e 100644 --- a/examples/Particles/SpacebattleDemo.cpp +++ b/examples/Particles/SpacebattleDemo.cpp @@ -294,7 +294,7 @@ ParticleDemo("Space battle", sharedData) } Nz::TextureRef skyboxCubemap = Nz::Texture::New(); - if (skyboxCubemap->Create(Nz::ImageType_Cubemap, Nz::PixelFormatType_RGBA8, 2048, 2048)) + if (skyboxCubemap->Create(Nz::ImageType_Cubemap, Nz::PixelFormat_RGBA8, 2048, 2048)) { skyboxCubemap->LoadFaceFromFile(Nz::CubemapFace_PositiveX, "resources/purple_nebula_skybox/purple_nebula_skybox_right1.png"); skyboxCubemap->LoadFaceFromFile(Nz::CubemapFace_PositiveY, "resources/purple_nebula_skybox/purple_nebula_skybox_top3.png"); diff --git a/examples/Particles/main.cpp b/examples/Particles/main.cpp index e31bfeb88..ea49c4abf 100644 --- a/examples/Particles/main.cpp +++ b/examples/Particles/main.cpp @@ -169,7 +169,7 @@ int main() case Nz::Keyboard::F5: { Nz::Image screenshot; - screenshot.Create(Nz::ImageType_2D, Nz::PixelFormatType_RGBA8, 1920, 1080); + screenshot.Create(Nz::ImageType_2D, Nz::PixelFormat_RGBA8, 1920, 1080); window.CopyToImage(&screenshot); static unsigned int counter = 1; diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index 14d124da4..1e910ec81 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -116,7 +116,7 @@ int main() // Texture Nz::ImageRef drfreakImage = Nz::Image::LoadFromFile("resources/Spaceship/Texture/diffuse.png"); - if (!drfreakImage || !drfreakImage->Convert(Nz::PixelFormatType_RGBA8)) + if (!drfreakImage || !drfreakImage->Convert(Nz::PixelFormat_RGBA8)) { NazaraError("Failed to load image"); return __LINE__; diff --git a/include/Nazara/Graphics/Light.hpp b/include/Nazara/Graphics/Light.hpp index 8c9410d96..a7b26ab17 100644 --- a/include/Nazara/Graphics/Light.hpp +++ b/include/Nazara/Graphics/Light.hpp @@ -47,7 +47,7 @@ namespace Nz inline float GetOuterAngleTangent() const; inline float GetRadius() const; inline TextureRef GetShadowMap() const; - inline PixelFormatType GetShadowMapFormat() const; + inline PixelFormat GetShadowMapFormat() const; inline const Vector2ui& GetShadowMapSize() const; inline bool IsShadowCastingEnabled() const; @@ -60,7 +60,7 @@ namespace Nz inline void SetLightType(LightType type); inline void SetOuterAngle(float outerAngle); inline void SetRadius(float radius); - inline void SetShadowMapFormat(PixelFormatType shadowFormat); + inline void SetShadowMapFormat(PixelFormat shadowFormat); inline void SetShadowMapSize(const Vector2ui& size); void UpdateBoundingVolume(const Matrix4f& transformMatrix) override; @@ -75,7 +75,7 @@ namespace Nz Color m_color; LightType m_type; - PixelFormatType m_shadowMapFormat; + PixelFormat m_shadowMapFormat; Vector2ui m_shadowMapSize; mutable TextureRef m_shadowMap; bool m_shadowCastingEnabled; diff --git a/include/Nazara/Graphics/Light.inl b/include/Nazara/Graphics/Light.inl index e3fb3f78f..103445958 100644 --- a/include/Nazara/Graphics/Light.inl +++ b/include/Nazara/Graphics/Light.inl @@ -194,7 +194,7 @@ namespace Nz * \return Shadow map format */ - inline PixelFormatType Light::GetShadowMapFormat() const + inline PixelFormat Light::GetShadowMapFormat() const { return m_shadowMapFormat; } @@ -331,9 +331,9 @@ namespace Nz * \remark Produces a NazaraAssert if format is not a depth type */ - inline void Light::SetShadowMapFormat(PixelFormatType shadowFormat) + inline void Light::SetShadowMapFormat(PixelFormat shadowFormat) { - NazaraAssert(PixelFormat::GetContent(shadowFormat) == PixelFormatContent_DepthStencil, "Shadow format type is not a depth format"); + NazaraAssert(PixelFormatInfo::GetContent(shadowFormat) == PixelFormatContent_DepthStencil, "Shadow format type is not a depth format"); m_shadowMapFormat = shadowFormat; diff --git a/include/Nazara/Renderer/RenderWindowParameters.hpp b/include/Nazara/Renderer/RenderWindowParameters.hpp index 4a32196c6..9c7fcb576 100644 --- a/include/Nazara/Renderer/RenderWindowParameters.hpp +++ b/include/Nazara/Renderer/RenderWindowParameters.hpp @@ -15,7 +15,7 @@ namespace Nz { struct RenderWindowParameters { - std::vector depthFormats = {Nz::PixelFormatType_Depth32, Nz::PixelFormatType_Depth24}; //< By order of preference + std::vector depthFormats = {Nz::PixelFormat_Depth32, Nz::PixelFormat_Depth24}; //< By order of preference bool verticalSync = false; }; } diff --git a/include/Nazara/Renderer/Texture.hpp b/include/Nazara/Renderer/Texture.hpp index 4d9776879..6aa8502b8 100644 --- a/include/Nazara/Renderer/Texture.hpp +++ b/include/Nazara/Renderer/Texture.hpp @@ -17,7 +17,7 @@ namespace Nz { struct TextureInfo { - PixelFormatType pixelFormat; + PixelFormat pixelFormat; ImageType type; unsigned int depth = 1; unsigned int height; @@ -33,7 +33,7 @@ namespace Nz Texture(Texture&&) = delete; virtual ~Texture(); - virtual PixelFormatType GetFormat() const = 0; + virtual PixelFormat GetFormat() const = 0; virtual UInt8 GetLevelCount() const = 0; virtual Vector3ui GetSize(UInt8 level = 0) const = 0; virtual ImageType GetType() const = 0; diff --git a/include/Nazara/Utility/AbstractImage.hpp b/include/Nazara/Utility/AbstractImage.hpp index d325f660f..44ee7d4f8 100644 --- a/include/Nazara/Utility/AbstractImage.hpp +++ b/include/Nazara/Utility/AbstractImage.hpp @@ -31,7 +31,7 @@ namespace Nz UInt8 GetBytesPerPixel() const; virtual unsigned int GetDepth(UInt8 level = 0) const = 0; - virtual PixelFormatType GetFormat() const = 0; + virtual PixelFormat GetFormat() const = 0; virtual unsigned int GetHeight(UInt8 level = 0) const = 0; virtual UInt8 GetLevelCount() const = 0; virtual UInt8 GetMaxLevel() const = 0; diff --git a/include/Nazara/Utility/Enums.hpp b/include/Nazara/Utility/Enums.hpp index 602c60f0f..7ac18a697 100644 --- a/include/Nazara/Utility/Enums.hpp +++ b/include/Nazara/Utility/Enums.hpp @@ -165,64 +165,64 @@ namespace Nz PixelFormatContent_Max = PixelFormatContent_Stencil }; - enum PixelFormatType + enum PixelFormat { - PixelFormatType_Undefined = -1, + PixelFormat_Undefined = -1, - PixelFormatType_A8, // 1*uint8 - PixelFormatType_BGR8, // 3*uint8 - PixelFormatType_BGRA8, // 4*uint8 - PixelFormatType_DXT1, - PixelFormatType_DXT3, - PixelFormatType_DXT5, - PixelFormatType_L8, // 1*uint8 - PixelFormatType_LA8, // 2*uint8 - PixelFormatType_R8, // 1*uint8 - PixelFormatType_R8I, // 1*int8 - PixelFormatType_R8UI, // 1*uint8 - PixelFormatType_R16, // 1*uint16 - PixelFormatType_R16F, // 1*half - PixelFormatType_R16I, // 1*int16 - PixelFormatType_R16UI, // 1*uint16 - PixelFormatType_R32F, // 1*float - PixelFormatType_R32I, // 1*uint16 - PixelFormatType_R32UI, // 1*uint32 - PixelFormatType_RG8, // 2*int8 - PixelFormatType_RG8I, // 2*int8 - PixelFormatType_RG8UI, // 2*uint8 - PixelFormatType_RG16, // 2*uint16 - PixelFormatType_RG16F, // 2*half - PixelFormatType_RG16I, // 2*int16 - PixelFormatType_RG16UI, // 2*uint16 - PixelFormatType_RG32F, // 2*float - PixelFormatType_RG32I, // 2*uint16 - PixelFormatType_RG32UI, // 2*uint32 - PixelFormatType_RGB5A1, // 3*uint5 + alpha bit - PixelFormatType_RGB8, // 3*uint8 - PixelFormatType_RGB16F, // 3*half - PixelFormatType_RGB16I, // 4*int16 - PixelFormatType_RGB16UI, // 4*uint16 - PixelFormatType_RGB32F, // 3*float - PixelFormatType_RGB32I, // 4*int32 - PixelFormatType_RGB32UI, // 4*uint32 - PixelFormatType_RGBA4, // 4*uint4 - PixelFormatType_RGBA8, // 4*uint8 - PixelFormatType_RGBA16F, // 4*half - PixelFormatType_RGBA16I, // 4*int16 - PixelFormatType_RGBA16UI, // 4*uint16 - PixelFormatType_RGBA32F, // 4*float - PixelFormatType_RGBA32I, // 4*int32 - PixelFormatType_RGBA32UI, // 4*uint32 - PixelFormatType_Depth16, - PixelFormatType_Depth24, - PixelFormatType_Depth24Stencil8, - PixelFormatType_Depth32, - PixelFormatType_Stencil1, - PixelFormatType_Stencil4, - PixelFormatType_Stencil8, - PixelFormatType_Stencil16, + PixelFormat_A8, // 1*uint8 + PixelFormat_BGR8, // 3*uint8 + PixelFormat_BGRA8, // 4*uint8 + PixelFormat_DXT1, + PixelFormat_DXT3, + PixelFormat_DXT5, + PixelFormat_L8, // 1*uint8 + PixelFormat_LA8, // 2*uint8 + PixelFormat_R8, // 1*uint8 + PixelFormat_R8I, // 1*int8 + PixelFormat_R8UI, // 1*uint8 + PixelFormat_R16, // 1*uint16 + PixelFormat_R16F, // 1*half + PixelFormat_R16I, // 1*int16 + PixelFormat_R16UI, // 1*uint16 + PixelFormat_R32F, // 1*float + PixelFormat_R32I, // 1*uint16 + PixelFormat_R32UI, // 1*uint32 + PixelFormat_RG8, // 2*int8 + PixelFormat_RG8I, // 2*int8 + PixelFormat_RG8UI, // 2*uint8 + PixelFormat_RG16, // 2*uint16 + PixelFormat_RG16F, // 2*half + PixelFormat_RG16I, // 2*int16 + PixelFormat_RG16UI, // 2*uint16 + PixelFormat_RG32F, // 2*float + PixelFormat_RG32I, // 2*uint16 + PixelFormat_RG32UI, // 2*uint32 + PixelFormat_RGB5A1, // 3*uint5 + alpha bit + PixelFormat_RGB8, // 3*uint8 + PixelFormat_RGB16F, // 3*half + PixelFormat_RGB16I, // 4*int16 + PixelFormat_RGB16UI, // 4*uint16 + PixelFormat_RGB32F, // 3*float + PixelFormat_RGB32I, // 4*int32 + PixelFormat_RGB32UI, // 4*uint32 + PixelFormat_RGBA4, // 4*uint4 + PixelFormat_RGBA8, // 4*uint8 + PixelFormat_RGBA16F, // 4*half + PixelFormat_RGBA16I, // 4*int16 + PixelFormat_RGBA16UI, // 4*uint16 + PixelFormat_RGBA32F, // 4*float + PixelFormat_RGBA32I, // 4*int32 + PixelFormat_RGBA32UI, // 4*uint32 + PixelFormat_Depth16, + PixelFormat_Depth24, + PixelFormat_Depth24Stencil8, + PixelFormat_Depth32, + PixelFormat_Stencil1, + PixelFormat_Stencil4, + PixelFormat_Stencil8, + PixelFormat_Stencil16, - PixelFormatType_Max = PixelFormatType_Stencil16 + PixelFormat_Max = PixelFormat_Stencil16 }; enum PixelFormatSubType diff --git a/include/Nazara/Utility/Image.hpp b/include/Nazara/Utility/Image.hpp index a07b805a4..6355dc60f 100644 --- a/include/Nazara/Utility/Image.hpp +++ b/include/Nazara/Utility/Image.hpp @@ -27,7 +27,7 @@ namespace Nz struct NAZARA_UTILITY_API ImageParams : ResourceParameters { // Le format dans lequel l'image doit être chargée (Undefined pour le format le plus proche de l'original) - PixelFormatType loadFormat = PixelFormatType_Undefined; + PixelFormat loadFormat = PixelFormat_Undefined; // Le nombre de niveaux de mipmaps maximum devant être créé UInt8 levelCount = 0; @@ -56,16 +56,16 @@ namespace Nz struct SharedImage; Image(); - Image(ImageType type, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth = 1, UInt8 levelCount = 1); + Image(ImageType type, PixelFormat format, unsigned int width, unsigned int height, unsigned int depth = 1, UInt8 levelCount = 1); Image(const Image& image); Image(SharedImage* sharedImage); ~Image(); - bool Convert(PixelFormatType format); + bool Convert(PixelFormat format); void Copy(const Image* source, const Boxui& srcBox, const Vector3ui& dstPos); - bool Create(ImageType type, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth = 1, UInt8 levelCount = 1); + bool Create(ImageType type, PixelFormat format, unsigned int width, unsigned int height, unsigned int depth = 1, UInt8 levelCount = 1); void Destroy(); bool Fill(const Color& color); @@ -77,7 +77,7 @@ namespace Nz const UInt8* GetConstPixels(unsigned int x = 0, unsigned int y = 0, unsigned int z = 0, UInt8 level = 0) const; unsigned int GetDepth(UInt8 level = 0) const override; - PixelFormatType GetFormat() const override; + PixelFormat GetFormat() const override; unsigned int GetHeight(UInt8 level = 0) const override; UInt8 GetLevelCount() const override; UInt8 GetMaxLevel() const override; @@ -113,7 +113,7 @@ namespace Nz Image& operator=(const Image& image); - static void Copy(UInt8* destination, const UInt8* source, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth = 1, unsigned int dstWidth = 0, unsigned int dstHeight = 0, unsigned int srcWidth = 0, unsigned int srcHeight = 0); + static void Copy(UInt8* destination, const UInt8* source, PixelFormat format, unsigned int width, unsigned int height, unsigned int depth = 1, unsigned int dstWidth = 0, unsigned int dstHeight = 0, unsigned int srcWidth = 0, unsigned int srcHeight = 0); static UInt8 GetMaxLevel(unsigned int width, unsigned int height, unsigned int depth = 1); static UInt8 GetMaxLevel(ImageType type, unsigned int width, unsigned int height, unsigned int depth = 1); @@ -140,7 +140,7 @@ namespace Nz { using PixelContainer = std::vector>; - SharedImage(unsigned short RefCount, ImageType Type, PixelFormatType Format, PixelContainer&& Levels, unsigned int Width, unsigned int Height, unsigned int Depth) : + SharedImage(unsigned short RefCount, ImageType Type, PixelFormat Format, PixelContainer&& Levels, unsigned int Width, unsigned int Height, unsigned int Depth) : type(Type), format(Format), levels(std::move(Levels)), @@ -152,7 +152,7 @@ namespace Nz } ImageType type; - PixelFormatType format; + PixelFormat format; PixelContainer levels; unsigned int depth; unsigned int height; diff --git a/include/Nazara/Utility/PixelFormat.hpp b/include/Nazara/Utility/PixelFormat.hpp index 1375a1eb1..bb150680a 100644 --- a/include/Nazara/Utility/PixelFormat.hpp +++ b/include/Nazara/Utility/PixelFormat.hpp @@ -21,13 +21,13 @@ namespace Nz { - struct PixelFormatInfo + struct PixelFormatDescription { - inline PixelFormatInfo(); - inline PixelFormatInfo(PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType); - inline PixelFormatInfo(const String& formatName, PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType); - inline PixelFormatInfo(const String& formatName, PixelFormatContent formatContent, Bitset<> rMask, Bitset<> gMask, Bitset<> bMask, Bitset<> aMask, PixelFormatSubType subType); - inline PixelFormatInfo(const String& formatName, PixelFormatContent formatContent, PixelFormatSubType rType, Bitset<> rMask, PixelFormatSubType gType, Bitset<> gMask, PixelFormatSubType bType, Bitset<> bMask, PixelFormatSubType aType, Bitset<> aMask, UInt8 bpp = 0); + inline PixelFormatDescription(); + inline PixelFormatDescription(PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType); + inline PixelFormatDescription(const String& formatName, PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType); + inline PixelFormatDescription(const String& formatName, PixelFormatContent formatContent, Bitset<> rMask, Bitset<> gMask, Bitset<> bMask, Bitset<> aMask, PixelFormatSubType subType); + inline PixelFormatDescription(const String& formatName, PixelFormatContent formatContent, PixelFormatSubType rType, Bitset<> rMask, PixelFormatSubType gType, Bitset<> gMask, PixelFormatSubType bType, Bitset<> bMask, PixelFormatSubType aType, Bitset<> aMask, UInt8 bpp = 0); inline void Clear(); @@ -52,7 +52,7 @@ namespace Nz UInt8 bitsPerPixel; }; - class NAZARA_UTILITY_API PixelFormat + class NAZARA_UTILITY_API PixelFormatInfo { friend class Utility; @@ -60,37 +60,37 @@ namespace Nz using ConvertFunction = std::function; using FlipFunction = std::function; - static inline std::size_t ComputeSize(PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth); + static inline std::size_t ComputeSize(PixelFormat format, unsigned int width, unsigned int height, unsigned int depth); - static inline bool Convert(PixelFormatType srcFormat, PixelFormatType dstFormat, const void* src, void* dst); - static inline bool Convert(PixelFormatType srcFormat, PixelFormatType dstFormat, const void* start, const void* end, void* dst); + static inline bool Convert(PixelFormat srcFormat, PixelFormat dstFormat, const void* src, void* dst); + static inline bool Convert(PixelFormat srcFormat, PixelFormat dstFormat, const void* start, const void* end, void* dst); - static bool Flip(PixelFlipping flipping, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth, const void* src, void* dst); + static bool Flip(PixelFlipping flipping, PixelFormat format, unsigned int width, unsigned int height, unsigned int depth, const void* src, void* dst); - static inline UInt8 GetBitsPerPixel(PixelFormatType format); - static inline PixelFormatContent GetContent(PixelFormatType format); - static inline UInt8 GetBytesPerPixel(PixelFormatType format); - static inline const PixelFormatInfo& GetInfo(PixelFormatType format); - static inline const String& GetName(PixelFormatType format); + static inline UInt8 GetBitsPerPixel(PixelFormat format); + static inline PixelFormatContent GetContent(PixelFormat format); + static inline UInt8 GetBytesPerPixel(PixelFormat format); + static inline const PixelFormatDescription& GetInfo(PixelFormat format); + static inline const String& GetName(PixelFormat format); - static inline bool HasAlpha(PixelFormatType format); + static inline bool HasAlpha(PixelFormat format); - static PixelFormatType IdentifyFormat(const PixelFormatInfo& info); + static PixelFormat IdentifyFormat(const PixelFormatDescription& info); - static inline bool IsCompressed(PixelFormatType format); - static inline bool IsConversionSupported(PixelFormatType srcFormat, PixelFormatType dstFormat); - static inline bool IsValid(PixelFormatType format); + static inline bool IsCompressed(PixelFormat format); + static inline bool IsConversionSupported(PixelFormat srcFormat, PixelFormat dstFormat); + static inline bool IsValid(PixelFormat format); - static inline void SetConvertFunction(PixelFormatType srcFormat, PixelFormatType dstFormat, ConvertFunction func); - static inline void SetFlipFunction(PixelFlipping flipping, PixelFormatType format, FlipFunction func); + static inline void SetConvertFunction(PixelFormat srcFormat, PixelFormat dstFormat, ConvertFunction func); + static inline void SetFlipFunction(PixelFlipping flipping, PixelFormat format, FlipFunction func); private: static bool Initialize(); static void Uninitialize(); - static PixelFormatInfo s_pixelFormatInfos[PixelFormatType_Max + 1]; - static ConvertFunction s_convertFunctions[PixelFormatType_Max+1][PixelFormatType_Max+1]; - static std::map s_flipFunctions[PixelFlipping_Max+1]; + static PixelFormatDescription s_pixelFormatInfos[PixelFormat_Max + 1]; + static ConvertFunction s_convertFunctions[PixelFormat_Max+1][PixelFormat_Max+1]; + static std::map s_flipFunctions[PixelFlipping_Max+1]; }; } diff --git a/include/Nazara/Utility/PixelFormat.inl b/include/Nazara/Utility/PixelFormat.inl index b1dfdfb0a..82bc3cb91 100644 --- a/include/Nazara/Utility/PixelFormat.inl +++ b/include/Nazara/Utility/PixelFormat.inl @@ -9,13 +9,13 @@ namespace Nz { - inline PixelFormatInfo::PixelFormatInfo() : + inline PixelFormatDescription::PixelFormatDescription() : content(PixelFormatContent_Undefined), bitsPerPixel(0) { } - inline PixelFormatInfo::PixelFormatInfo(PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType) : + inline PixelFormatDescription::PixelFormatDescription(PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType) : content(formatContent), redType(subType), greenType(subType), @@ -25,7 +25,7 @@ namespace Nz { } - inline PixelFormatInfo::PixelFormatInfo(const String& formatName, PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType) : + inline PixelFormatDescription::PixelFormatDescription(const String& formatName, PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType) : content(formatContent), redType(subType), greenType(subType), @@ -36,12 +36,12 @@ namespace Nz { } - inline PixelFormatInfo::PixelFormatInfo(const String& formatName, PixelFormatContent formatContent, Bitset<> rMask, Bitset<> gMask, Bitset<> bMask, Bitset<> aMask, PixelFormatSubType subType) : - PixelFormatInfo(formatName, formatContent, subType, rMask, subType, gMask, subType, bMask, subType, aMask) + inline PixelFormatDescription::PixelFormatDescription(const String& formatName, PixelFormatContent formatContent, Bitset<> rMask, Bitset<> gMask, Bitset<> bMask, Bitset<> aMask, PixelFormatSubType subType) : + PixelFormatDescription(formatName, formatContent, subType, rMask, subType, gMask, subType, bMask, subType, aMask) { } - inline PixelFormatInfo::PixelFormatInfo(const String& formatName, PixelFormatContent formatContent, PixelFormatSubType rType, Bitset<> rMask, PixelFormatSubType gType, Bitset<> gMask, PixelFormatSubType bType, Bitset<> bMask, PixelFormatSubType aType, Bitset<> aMask, UInt8 bpp) : + inline PixelFormatDescription::PixelFormatDescription(const String& formatName, PixelFormatContent formatContent, PixelFormatSubType rType, Bitset<> rMask, PixelFormatSubType gType, Bitset<> gMask, PixelFormatSubType bType, Bitset<> bMask, PixelFormatSubType aType, Bitset<> aMask, UInt8 bpp) : redMask(rMask), greenMask(gMask), blueMask(bMask), @@ -62,7 +62,7 @@ namespace Nz RecomputeBitsPerPixel(); } - inline void PixelFormatInfo::Clear() + inline void PixelFormatDescription::Clear() { bitsPerPixel = 0; alphaMask.Clear(); @@ -72,7 +72,7 @@ namespace Nz name.Clear(); } - inline bool PixelFormatInfo::IsCompressed() const + inline bool PixelFormatDescription::IsCompressed() const { return redType == PixelFormatSubType_Compressed || greenType == PixelFormatSubType_Compressed || @@ -80,12 +80,12 @@ namespace Nz alphaType == PixelFormatSubType_Compressed; } - inline bool PixelFormatInfo::IsValid() const + inline bool PixelFormatDescription::IsValid() const { return bitsPerPixel != 0; } - inline void PixelFormatInfo::RecomputeBitsPerPixel() + inline void PixelFormatDescription::RecomputeBitsPerPixel() { Bitset<> counter; counter |= redMask; @@ -96,7 +96,7 @@ namespace Nz bitsPerPixel = static_cast(counter.Count()); } - inline bool PixelFormatInfo::Validate() const + inline bool PixelFormatDescription::Validate() const { if (!IsValid()) return false; @@ -143,16 +143,16 @@ namespace Nz - inline std::size_t PixelFormat::ComputeSize(PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth) + inline std::size_t PixelFormatInfo::ComputeSize(PixelFormat format, unsigned int width, unsigned int height, unsigned int depth) { if (IsCompressed(format)) { switch (format) { - case PixelFormatType_DXT1: - case PixelFormatType_DXT3: - case PixelFormatType_DXT5: - return (((width + 3) / 4) * ((height + 3) / 4) * ((format == PixelFormatType_DXT1) ? 8 : 16)) * depth; + case PixelFormat_DXT1: + case PixelFormat_DXT3: + case PixelFormat_DXT5: + return (((width + 3) / 4) * ((height + 3) / 4) * ((format == PixelFormat_DXT1) ? 8 : 16)) * depth; default: NazaraError("Unsupported format"); @@ -163,7 +163,7 @@ namespace Nz return width * height * depth * GetBytesPerPixel(format); } - inline bool PixelFormat::Convert(PixelFormatType srcFormat, PixelFormatType dstFormat, const void* src, void* dst) + inline bool PixelFormatInfo::Convert(PixelFormat srcFormat, PixelFormat dstFormat, const void* src, void* dst) { if (srcFormat == dstFormat) { @@ -201,7 +201,7 @@ namespace Nz return true; } - inline bool PixelFormat::Convert(PixelFormatType srcFormat, PixelFormatType dstFormat, const void* start, const void* end, void* dst) + inline bool PixelFormatInfo::Convert(PixelFormat srcFormat, PixelFormat dstFormat, const void* start, const void* end, void* dst) { if (srcFormat == dstFormat) { @@ -225,42 +225,42 @@ namespace Nz return true; } - inline UInt8 PixelFormat::GetBitsPerPixel(PixelFormatType format) + inline UInt8 PixelFormatInfo::GetBitsPerPixel(PixelFormat format) { return s_pixelFormatInfos[format].bitsPerPixel; } - inline UInt8 PixelFormat::GetBytesPerPixel(PixelFormatType format) + inline UInt8 PixelFormatInfo::GetBytesPerPixel(PixelFormat format) { return GetBitsPerPixel(format)/8; } - inline PixelFormatContent PixelFormat::GetContent(PixelFormatType format) + inline PixelFormatContent PixelFormatInfo::GetContent(PixelFormat format) { return s_pixelFormatInfos[format].content; } - inline const PixelFormatInfo& PixelFormat::GetInfo(PixelFormatType format) + inline const PixelFormatDescription& PixelFormatInfo::GetInfo(PixelFormat format) { return s_pixelFormatInfos[format]; } - inline const String& PixelFormat::GetName(PixelFormatType format) + inline const String& PixelFormatInfo::GetName(PixelFormat format) { return s_pixelFormatInfos[format].name; } - inline bool PixelFormat::HasAlpha(PixelFormatType format) + inline bool PixelFormatInfo::HasAlpha(PixelFormat format) { return s_pixelFormatInfos[format].alphaMask.TestAny(); } - inline bool PixelFormat::IsCompressed(PixelFormatType format) + inline bool PixelFormatInfo::IsCompressed(PixelFormat format) { return s_pixelFormatInfos[format].IsCompressed(); } - inline bool PixelFormat::IsConversionSupported(PixelFormatType srcFormat, PixelFormatType dstFormat) + inline bool PixelFormatInfo::IsConversionSupported(PixelFormat srcFormat, PixelFormat dstFormat) { if (srcFormat == dstFormat) return true; @@ -268,17 +268,17 @@ namespace Nz return s_convertFunctions[srcFormat][dstFormat] != nullptr; } - inline bool PixelFormat::IsValid(PixelFormatType format) + inline bool PixelFormatInfo::IsValid(PixelFormat format) { - return format != PixelFormatType_Undefined; + return format != PixelFormat_Undefined; } - inline void PixelFormat::SetConvertFunction(PixelFormatType srcFormat, PixelFormatType dstFormat, ConvertFunction func) + inline void PixelFormatInfo::SetConvertFunction(PixelFormat srcFormat, PixelFormat dstFormat, ConvertFunction func) { s_convertFunctions[srcFormat][dstFormat] = func; } - inline void PixelFormat::SetFlipFunction(PixelFlipping flipping, PixelFormatType format, FlipFunction func) + inline void PixelFormatInfo::SetFlipFunction(PixelFlipping flipping, PixelFormat format, FlipFunction func) { s_flipFunctions[flipping][format] = func; } diff --git a/include/Nazara/VulkanRenderer/VulkanTexture.hpp b/include/Nazara/VulkanRenderer/VulkanTexture.hpp index e5fc61426..1a255aa75 100644 --- a/include/Nazara/VulkanRenderer/VulkanTexture.hpp +++ b/include/Nazara/VulkanRenderer/VulkanTexture.hpp @@ -23,7 +23,7 @@ namespace Nz VulkanTexture(VulkanTexture&&) noexcept = default; ~VulkanTexture(); - PixelFormatType GetFormat() const override; + PixelFormat GetFormat() const override; inline VkImage GetImage() const; inline VkImageView GetImageView() const; UInt8 GetLevelCount() const override; @@ -36,7 +36,7 @@ namespace Nz VulkanTexture& operator=(VulkanTexture&&) = delete; private: - static void InitForFormat(PixelFormatType pixelFormat, VkImageCreateInfo& createImage, VkImageViewCreateInfo& createImageView); + static void InitForFormat(PixelFormat pixelFormat, VkImageCreateInfo& createImage, VkImageViewCreateInfo& createImageView); VkImage m_image; VmaAllocation m_allocation; diff --git a/src/Nazara/Graphics/DeferredBloomPass.cpp b/src/Nazara/Graphics/DeferredBloomPass.cpp index 0ce2985f1..5dc34d3d2 100644 --- a/src/Nazara/Graphics/DeferredBloomPass.cpp +++ b/src/Nazara/Graphics/DeferredBloomPass.cpp @@ -185,7 +185,7 @@ namespace Nz m_bloomRTT.Create(true); for (unsigned int i = 0; i < 2; ++i) { - m_bloomTextures[i]->Create(ImageType_2D, PixelFormatType_RGBA8, dimensions.x / 8, dimensions.y / 8); + m_bloomTextures[i]->Create(ImageType_2D, PixelFormat_RGBA8, dimensions.x / 8, dimensions.y / 8); m_bloomRTT.AttachTexture(AttachmentPoint_Color, i, m_bloomTextures[i]); } m_bloomRTT.Unlock(); diff --git a/src/Nazara/Graphics/DeferredDOFPass.cpp b/src/Nazara/Graphics/DeferredDOFPass.cpp index a13eb31f4..9cf138d2b 100644 --- a/src/Nazara/Graphics/DeferredDOFPass.cpp +++ b/src/Nazara/Graphics/DeferredDOFPass.cpp @@ -197,7 +197,7 @@ namespace Nz m_dofRTT.Create(true); for (unsigned int i = 0; i < 2; ++i) { - m_dofTextures[i]->Create(ImageType_2D, PixelFormatType_RGBA8, dimensions.x/4, dimensions.y/4); + m_dofTextures[i]->Create(ImageType_2D, PixelFormat_RGBA8, dimensions.x/4, dimensions.y/4); m_dofRTT.AttachTexture(AttachmentPoint_Color, i, m_dofTextures[i]); } m_dofRTT.Unlock(); diff --git a/src/Nazara/Graphics/DeferredGeometryPass.cpp b/src/Nazara/Graphics/DeferredGeometryPass.cpp index 18afe9236..3801963b4 100644 --- a/src/Nazara/Graphics/DeferredGeometryPass.cpp +++ b/src/Nazara/Graphics/DeferredGeometryPass.cpp @@ -147,11 +147,11 @@ namespace Nz unsigned int width = dimensions.x; unsigned int height = dimensions.y; - m_depthStencilTexture->Create(ImageType_2D, PixelFormatType_Depth24Stencil8, width, height); + m_depthStencilTexture->Create(ImageType_2D, PixelFormat_Depth24Stencil8, width, height); - m_GBuffer[0]->Create(ImageType_2D, PixelFormatType_RGBA8, width, height); // Texture 0 : Diffuse Color + Specular - m_GBuffer[1]->Create(ImageType_2D, PixelFormatType_RG16F, width, height); // Texture 1 : Encoded normal - m_GBuffer[2]->Create(ImageType_2D, PixelFormatType_RGBA8, width, height); // Texture 2 : Depth (24bits) + Shininess + m_GBuffer[0]->Create(ImageType_2D, PixelFormat_RGBA8, width, height); // Texture 0 : Diffuse Color + Specular + m_GBuffer[1]->Create(ImageType_2D, PixelFormat_RG16F, width, height); // Texture 1 : Encoded normal + m_GBuffer[2]->Create(ImageType_2D, PixelFormat_RGBA8, width, height); // Texture 2 : Depth (24bits) + Shininess m_GBufferRTT->Create(true); @@ -169,7 +169,7 @@ namespace Nz for (unsigned int i = 0; i < 2; ++i) { - m_workTextures[i]->Create(ImageType_2D, PixelFormatType_RGBA8, width, height); + m_workTextures[i]->Create(ImageType_2D, PixelFormat_RGBA8, width, height); m_workRTT->AttachTexture(AttachmentPoint_Color, i, m_workTextures[i]); } diff --git a/src/Nazara/Graphics/Graphics.cpp b/src/Nazara/Graphics/Graphics.cpp index 9757d661b..7120d33cd 100644 --- a/src/Nazara/Graphics/Graphics.cpp +++ b/src/Nazara/Graphics/Graphics.cpp @@ -160,13 +160,13 @@ namespace Nz std::array whitePixels = { { 255, 255, 255, 255, 255, 255 } }; Nz::TextureRef whiteTexture = Nz::Texture::New(); - whiteTexture->Create(ImageType_2D, PixelFormatType_L8, 1, 1); + whiteTexture->Create(ImageType_2D, PixelFormat_L8, 1, 1); whiteTexture->Update(whitePixels.data()); TextureLibrary::Register("White2D", std::move(whiteTexture)); Nz::TextureRef whiteCubemap = Nz::Texture::New(); - whiteCubemap->Create(ImageType_Cubemap, PixelFormatType_L8, 1, 1); + whiteCubemap->Create(ImageType_Cubemap, PixelFormat_L8, 1, 1); whiteCubemap->Update(whitePixels.data()); TextureLibrary::Register("WhiteCubemap", std::move(whiteCubemap)); diff --git a/src/Nazara/Graphics/GuillotineTextureAtlas.cpp b/src/Nazara/Graphics/GuillotineTextureAtlas.cpp index b413ed76a..83ac85be2 100644 --- a/src/Nazara/Graphics/GuillotineTextureAtlas.cpp +++ b/src/Nazara/Graphics/GuillotineTextureAtlas.cpp @@ -37,7 +37,7 @@ namespace Nz AbstractImage* GuillotineTextureAtlas::ResizeImage(AbstractImage* oldImage, const Vector2ui& size) const { std::unique_ptr newTexture(new Texture); - if (newTexture->Create(ImageType_2D, PixelFormatType_A8, size.x, size.y, 1)) + if (newTexture->Create(ImageType_2D, PixelFormat_A8, size.x, size.y, 1)) { if (oldImage) { diff --git a/src/Nazara/Graphics/Light.cpp b/src/Nazara/Graphics/Light.cpp index 4156ee77d..be356fa85 100644 --- a/src/Nazara/Graphics/Light.cpp +++ b/src/Nazara/Graphics/Light.cpp @@ -29,7 +29,7 @@ namespace Nz Light::Light(LightType type) : m_type(type), - m_shadowMapFormat(PixelFormatType_Depth16), + m_shadowMapFormat(PixelFormat_Depth16), m_shadowMapSize(512, 512), m_shadowCastingEnabled(false), m_shadowMapUpdated(false) diff --git a/src/Nazara/Platform/Win32/CursorImpl.cpp b/src/Nazara/Platform/Win32/CursorImpl.cpp index 8af6502fe..8a78917ba 100644 --- a/src/Nazara/Platform/Win32/CursorImpl.cpp +++ b/src/Nazara/Platform/Win32/CursorImpl.cpp @@ -13,7 +13,7 @@ namespace Nz bool CursorImpl::Create(const Image& cursor, int hotSpotX, int hotSpotY) { Image windowsCursor(cursor); - if (!windowsCursor.Convert(PixelFormatType_BGRA8)) + if (!windowsCursor.Convert(PixelFormat_BGRA8)) { NazaraError("Failed to convert cursor to BGRA8"); return false; diff --git a/src/Nazara/Platform/Win32/IconImpl.cpp b/src/Nazara/Platform/Win32/IconImpl.cpp index 47839be16..1ca2c878e 100644 --- a/src/Nazara/Platform/Win32/IconImpl.cpp +++ b/src/Nazara/Platform/Win32/IconImpl.cpp @@ -12,7 +12,7 @@ namespace Nz bool IconImpl::Create(const Image& icon) { Image windowsIcon(icon); // Vive le COW - if (!windowsIcon.Convert(PixelFormatType_BGRA8)) + if (!windowsIcon.Convert(PixelFormat_BGRA8)) { NazaraError("Failed to convert icon to BGRA8"); return false; diff --git a/src/Nazara/Utility/AbstractImage.cpp b/src/Nazara/Utility/AbstractImage.cpp index a5605acd8..72a0f7335 100644 --- a/src/Nazara/Utility/AbstractImage.cpp +++ b/src/Nazara/Utility/AbstractImage.cpp @@ -12,12 +12,12 @@ namespace Nz UInt8 AbstractImage::GetBytesPerPixel() const { - return PixelFormat::GetBytesPerPixel(GetFormat()); + return PixelFormatInfo::GetBytesPerPixel(GetFormat()); } bool AbstractImage::IsCompressed() const { - return PixelFormat::IsCompressed(GetFormat()); + return PixelFormatInfo::IsCompressed(GetFormat()); } bool AbstractImage::IsCubemap() const diff --git a/src/Nazara/Utility/Formats/DDSLoader.cpp b/src/Nazara/Utility/Formats/DDSLoader.cpp index b6d50ce2b..4d2edf50e 100644 --- a/src/Nazara/Utility/Formats/DDSLoader.cpp +++ b/src/Nazara/Utility/Formats/DDSLoader.cpp @@ -84,7 +84,7 @@ namespace Nz return nullptr; // Then the format - PixelFormatType format; + PixelFormat format; if (!IdentifyPixelFormat(header, headerDX10, &format)) return nullptr; @@ -93,7 +93,7 @@ namespace Nz // Read all mipmap levels for (unsigned int i = 0; i < image->GetLevelCount(); i++) { - std::size_t byteCount = PixelFormat::ComputeSize(format, width, height, depth); + std::size_t byteCount = PixelFormatInfo::ComputeSize(format, width, height, depth); UInt8* ptr = image->GetPixels(0, 0, 0, i); @@ -114,7 +114,7 @@ namespace Nz } - if (parameters.loadFormat != PixelFormatType_Undefined) + if (parameters.loadFormat != PixelFormat_Undefined) image->Convert(parameters.loadFormat); return image; @@ -163,11 +163,11 @@ namespace Nz return true; } - static bool IdentifyPixelFormat(const DDSHeader& header, const DDSHeaderDX10Ext& headerExt, PixelFormatType* format) + static bool IdentifyPixelFormat(const DDSHeader& header, const DDSHeaderDX10Ext& headerExt, PixelFormat* format) { if (header.format.flags & (DDPF_RGB | DDPF_ALPHA | DDPF_ALPHAPIXELS | DDPF_LUMINANCE)) { - PixelFormatInfo info(PixelFormatContent_ColorRGBA, header.format.bpp, PixelFormatSubType_Unsigned); + PixelFormatDescription info(PixelFormatContent_ColorRGBA, header.format.bpp, PixelFormatSubType_Unsigned); if (header.format.flags & DDPF_RGB) { @@ -182,8 +182,8 @@ namespace Nz if (header.format.flags & (DDPF_ALPHA | DDPF_ALPHAPIXELS)) info.alphaMask = header.format.alphaMask; - *format = PixelFormat::IdentifyFormat(info); - if (!PixelFormat::IsValid(*format)) + *format = PixelFormatInfo::IdentifyFormat(info); + if (!PixelFormatInfo::IsValid(*format)) return false; } else if (header.format.flags & DDPF_FOURCC) @@ -191,15 +191,15 @@ namespace Nz switch (header.format.fourCC) { case D3DFMT_DXT1: - *format = PixelFormatType_DXT1; + *format = PixelFormat_DXT1; break; case D3DFMT_DXT3: - *format = PixelFormatType_DXT3; + *format = PixelFormat_DXT3; break; case D3DFMT_DXT5: - *format = PixelFormatType_DXT3; + *format = PixelFormat_DXT3; break; case D3DFMT_DX10: @@ -207,30 +207,30 @@ namespace Nz switch (headerExt.dxgiFormat) { case DXGI_FORMAT_R32G32B32A32_FLOAT: - *format = PixelFormatType_RGBA32F; + *format = PixelFormat_RGBA32F; break; case DXGI_FORMAT_R32G32B32A32_UINT: - *format = PixelFormatType_RGBA32UI; + *format = PixelFormat_RGBA32UI; break; case DXGI_FORMAT_R32G32B32A32_SINT: - *format = PixelFormatType_RGBA32I; + *format = PixelFormat_RGBA32I; break; case DXGI_FORMAT_R32G32B32_FLOAT: - *format = PixelFormatType_RGB32F; + *format = PixelFormat_RGB32F; break; case DXGI_FORMAT_R32G32B32_UINT: - //*format = PixelFormatType_RGB32U; + //*format = PixelFormat_RGB32U; return false; case DXGI_FORMAT_R32G32B32_SINT: - *format = PixelFormatType_RGB32I; + *format = PixelFormat_RGB32I; break; case DXGI_FORMAT_R16G16B16A16_SNORM: case DXGI_FORMAT_R16G16B16A16_SINT: case DXGI_FORMAT_R16G16B16A16_UINT: - *format = PixelFormatType_RGBA16I; + *format = PixelFormat_RGBA16I; break; case DXGI_FORMAT_R16G16B16A16_UNORM: - *format = PixelFormatType_RGBA16UI; + *format = PixelFormat_RGBA16UI; break; } break; diff --git a/src/Nazara/Utility/Formats/FreeTypeLoader.cpp b/src/Nazara/Utility/Formats/FreeTypeLoader.cpp index 601f16031..aaba0dc87 100644 --- a/src/Nazara/Utility/Formats/FreeTypeLoader.cpp +++ b/src/Nazara/Utility/Formats/FreeTypeLoader.cpp @@ -201,7 +201,7 @@ namespace Nz if (width > 0 && height > 0) { - dst->image.Create(ImageType_2D, PixelFormatType_A8, width, height); + dst->image.Create(ImageType_2D, PixelFormat_A8, width, height); UInt8* pixels = dst->image.GetPixels(); const UInt8* data = bitmap.buffer; diff --git a/src/Nazara/Utility/Formats/PCXLoader.cpp b/src/Nazara/Utility/Formats/PCXLoader.cpp index 7e9ff82f5..61a0e1d28 100644 --- a/src/Nazara/Utility/Formats/PCXLoader.cpp +++ b/src/Nazara/Utility/Formats/PCXLoader.cpp @@ -92,7 +92,7 @@ namespace Nz unsigned int height = header.ymax - header.ymin+1; ImageRef image = Image::New(); - if (!image->Create(ImageType_2D, PixelFormatType_RGB8, width, height, 1, (parameters.levelCount > 0) ? parameters.levelCount : 1)) + if (!image->Create(ImageType_2D, PixelFormat_RGB8, width, height, 1, (parameters.levelCount > 0) ? parameters.levelCount : 1)) { NazaraError("Failed to create image"); return nullptr; @@ -333,7 +333,7 @@ namespace Nz return nullptr; } - if (parameters.loadFormat != PixelFormatType_Undefined) + if (parameters.loadFormat != PixelFormat_Undefined) image->Convert(parameters.loadFormat); return image; diff --git a/src/Nazara/Utility/Formats/STBLoader.cpp b/src/Nazara/Utility/Formats/STBLoader.cpp index 9e2132906..01f1bd0f4 100644 --- a/src/Nazara/Utility/Formats/STBLoader.cpp +++ b/src/Nazara/Utility/Formats/STBLoader.cpp @@ -74,7 +74,7 @@ namespace Nz }); ImageRef image = Image::New(); - if (!image->Create(ImageType_2D, PixelFormatType_RGBA8, width, height, 1, (parameters.levelCount > 0) ? parameters.levelCount : 1)) + if (!image->Create(ImageType_2D, PixelFormat_RGBA8, width, height, 1, (parameters.levelCount > 0) ? parameters.levelCount : 1)) { NazaraError("Failed to create image"); return nullptr; @@ -84,7 +84,7 @@ namespace Nz freeStbiImage.CallAndReset(); - if (parameters.loadFormat != PixelFormatType_Undefined) + if (parameters.loadFormat != PixelFormat_Undefined) image->Convert(parameters.loadFormat); return image; diff --git a/src/Nazara/Utility/Formats/STBSaver.cpp b/src/Nazara/Utility/Formats/STBSaver.cpp index 77a71b64d..e4af33fb7 100644 --- a/src/Nazara/Utility/Formats/STBSaver.cpp +++ b/src/Nazara/Utility/Formats/STBSaver.cpp @@ -21,30 +21,30 @@ namespace Nz { switch (image.GetFormat()) { - case PixelFormatType_R32F: + case PixelFormat_R32F: return 1; - case PixelFormatType_RG32F: + case PixelFormat_RG32F: return 2; - case PixelFormatType_RGB32F: + case PixelFormat_RGB32F: return 3; - case PixelFormatType_RGBA32F: + case PixelFormat_RGBA32F: return 4; default: { - if (PixelFormat::HasAlpha(image.GetFormat())) + if (PixelFormatInfo::HasAlpha(image.GetFormat())) { - if (!image.Convert(PixelFormatType_RGBA32F)) + if (!image.Convert(PixelFormat_RGBA32F)) break; return 4; } else { - if (!image.Convert(PixelFormatType_RGB32F)) + if (!image.Convert(PixelFormat_RGB32F)) break; return 3; @@ -59,32 +59,32 @@ namespace Nz { switch (image.GetFormat()) { - case PixelFormatType_L8: - case PixelFormatType_R8: + case PixelFormat_L8: + case PixelFormat_R8: return 1; - case PixelFormatType_LA8: - case PixelFormatType_RG8: + case PixelFormat_LA8: + case PixelFormat_RG8: return 2; - case PixelFormatType_RGB8: + case PixelFormat_RGB8: return 3; - case PixelFormatType_RGBA8: + case PixelFormat_RGBA8: return 4; default: { - if (PixelFormat::HasAlpha(image.GetFormat())) + if (PixelFormatInfo::HasAlpha(image.GetFormat())) { - if (!image.Convert(PixelFormatType_RGBA8)) + if (!image.Convert(PixelFormat_RGBA8)) break; return 4; } else { - if (!image.Convert(PixelFormatType_RGB8)) + if (!image.Convert(PixelFormat_RGB8)) break; return 3; diff --git a/src/Nazara/Utility/GuillotineImageAtlas.cpp b/src/Nazara/Utility/GuillotineImageAtlas.cpp index 54dfb813b..2a39e7475 100644 --- a/src/Nazara/Utility/GuillotineImageAtlas.cpp +++ b/src/Nazara/Utility/GuillotineImageAtlas.cpp @@ -161,7 +161,7 @@ namespace Nz AbstractImage* GuillotineImageAtlas::ResizeImage(AbstractImage* oldImage, const Vector2ui& size) const { - std::unique_ptr newImage(new Image(ImageType_2D, PixelFormatType_A8, size.x, size.y)); + std::unique_ptr newImage(new Image(ImageType_2D, PixelFormat_A8, size.x, size.y)); if (oldImage) { newImage->Copy(static_cast(oldImage), Rectui(size), Vector2ui(0, 0)); // Copie des anciennes données diff --git a/src/Nazara/Utility/Image.cpp b/src/Nazara/Utility/Image.cpp index 189acb484..b45c96a2e 100644 --- a/src/Nazara/Utility/Image.cpp +++ b/src/Nazara/Utility/Image.cpp @@ -42,7 +42,7 @@ namespace Nz { } - Image::Image(ImageType type, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth, UInt8 levelCount) : + Image::Image(ImageType type, PixelFormat format, unsigned int width, unsigned int height, unsigned int depth, UInt8 levelCount) : m_sharedImage(&emptyImage) { ErrorFlags flags(ErrorFlag_ThrowException); @@ -70,7 +70,7 @@ namespace Nz Destroy(); } - bool Image::Convert(PixelFormatType newFormat) + bool Image::Convert(PixelFormat newFormat) { #if NAZARA_UTILITY_SAFE if (m_sharedImage == &emptyImage) @@ -79,15 +79,15 @@ namespace Nz return false; } - if (!PixelFormat::IsValid(newFormat)) + if (!PixelFormatInfo::IsValid(newFormat)) { NazaraError("Invalid pixel format"); return false; } - if (!PixelFormat::IsConversionSupported(m_sharedImage->format, newFormat)) + if (!PixelFormatInfo::IsConversionSupported(m_sharedImage->format, newFormat)) { - NazaraError("Conversion from " + PixelFormat::GetName(m_sharedImage->format) + " to " + PixelFormat::GetName(newFormat) + " is not supported"); + NazaraError("Conversion from " + PixelFormatInfo::GetName(m_sharedImage->format) + " to " + PixelFormatInfo::GetName(newFormat) + " is not supported"); return false; } #endif @@ -106,16 +106,16 @@ namespace Nz for (unsigned int i = 0; i < levels.size(); ++i) { unsigned int pixelsPerFace = width * height; - levels[i] = std::make_unique(pixelsPerFace * depth * PixelFormat::GetBytesPerPixel(newFormat)); + levels[i] = std::make_unique(pixelsPerFace * depth * PixelFormatInfo::GetBytesPerPixel(newFormat)); UInt8* dst = levels[i].get(); UInt8* src = m_sharedImage->levels[i].get(); - unsigned int srcStride = pixelsPerFace * PixelFormat::GetBytesPerPixel(m_sharedImage->format); - unsigned int dstStride = pixelsPerFace * PixelFormat::GetBytesPerPixel(newFormat); + unsigned int srcStride = pixelsPerFace * PixelFormatInfo::GetBytesPerPixel(m_sharedImage->format); + unsigned int dstStride = pixelsPerFace * PixelFormatInfo::GetBytesPerPixel(newFormat); for (unsigned int d = 0; d < depth; ++d) { - if (!PixelFormat::Convert(m_sharedImage->format, newFormat, src, &src[srcStride], dst)) + if (!PixelFormatInfo::Convert(m_sharedImage->format, newFormat, src, &src[srcStride], dst)) { NazaraError("Failed to convert image"); return false; @@ -158,18 +158,18 @@ namespace Nz } #endif - UInt8 bpp = PixelFormat::GetBytesPerPixel(m_sharedImage->format); + UInt8 bpp = PixelFormatInfo::GetBytesPerPixel(m_sharedImage->format); UInt8* dstPtr = GetPixelPtr(m_sharedImage->levels[0].get(), bpp, dstPos.x, dstPos.y, dstPos.z, m_sharedImage->width, m_sharedImage->height); Copy(dstPtr, srcPtr, m_sharedImage->format, srcBox.width, srcBox.height, srcBox.depth, m_sharedImage->width, m_sharedImage->height, source->GetWidth(), source->GetHeight()); } - bool Image::Create(ImageType type, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth, UInt8 levelCount) + bool Image::Create(ImageType type, PixelFormat format, unsigned int width, unsigned int height, unsigned int depth, UInt8 levelCount) { Destroy(); #if NAZARA_UTILITY_SAFE - if (!PixelFormat::IsValid(format)) + if (!PixelFormatInfo::IsValid(format)) { NazaraError("Invalid pixel format"); return false; @@ -255,7 +255,7 @@ namespace Nz // Cette allocation est protégée car sa taille dépend directement de paramètres utilisateurs try { - levels[i] = std::make_unique(PixelFormat::ComputeSize(format, w, h, d)); + levels[i] = std::make_unique(PixelFormatInfo::ComputeSize(format, w, h, d)); if (w > 1) w >>= 1; @@ -298,18 +298,18 @@ namespace Nz return false; } - if (PixelFormat::IsCompressed(m_sharedImage->format)) + if (PixelFormatInfo::IsCompressed(m_sharedImage->format)) { NazaraError("Cannot access pixels from compressed image"); return false; } #endif - UInt8 bpp = PixelFormat::GetBytesPerPixel(m_sharedImage->format); + UInt8 bpp = PixelFormatInfo::GetBytesPerPixel(m_sharedImage->format); std::unique_ptr colorBuffer(new UInt8[bpp]); - if (!PixelFormat::Convert(PixelFormatType_RGBA8, m_sharedImage->format, &color.r, colorBuffer.get())) + if (!PixelFormatInfo::Convert(PixelFormat_RGBA8, m_sharedImage->format, &color.r, colorBuffer.get())) { - NazaraError("Failed to convert RGBA8 to " + PixelFormat::GetName(m_sharedImage->format)); + NazaraError("Failed to convert RGBA8 to " + PixelFormatInfo::GetName(m_sharedImage->format)); return false; } @@ -323,7 +323,7 @@ namespace Nz for (auto & level : levels) { - std::size_t size = PixelFormat::ComputeSize(m_sharedImage->format, width, height, depth); + std::size_t size = PixelFormatInfo::ComputeSize(m_sharedImage->format, width, height, depth); level = std::make_unique(size); UInt8* ptr = level.get(); @@ -362,7 +362,7 @@ namespace Nz return false; } - if (PixelFormat::IsCompressed(m_sharedImage->format)) + if (PixelFormatInfo::IsCompressed(m_sharedImage->format)) { NazaraError("Cannot access pixels from compressed image"); return false; @@ -383,11 +383,11 @@ namespace Nz EnsureOwnership(); - UInt8 bpp = PixelFormat::GetBytesPerPixel(m_sharedImage->format); + UInt8 bpp = PixelFormatInfo::GetBytesPerPixel(m_sharedImage->format); std::unique_ptr colorBuffer(new UInt8[bpp]); - if (!PixelFormat::Convert(PixelFormatType_RGBA8, m_sharedImage->format, &color.r, colorBuffer.get())) + if (!PixelFormatInfo::Convert(PixelFormat_RGBA8, m_sharedImage->format, &color.r, colorBuffer.get())) { - NazaraError("Failed to convert RGBA8 to " + PixelFormat::GetName(m_sharedImage->format)); + NazaraError("Failed to convert RGBA8 to " + PixelFormatInfo::GetName(m_sharedImage->format)); return false; } @@ -427,7 +427,7 @@ namespace Nz return false; } - if (PixelFormat::IsCompressed(m_sharedImage->format)) + if (PixelFormatInfo::IsCompressed(m_sharedImage->format)) { NazaraError("Cannot access pixels from compressed image"); return false; @@ -455,11 +455,11 @@ namespace Nz EnsureOwnership(); - UInt8 bpp = PixelFormat::GetBytesPerPixel(m_sharedImage->format); + UInt8 bpp = PixelFormatInfo::GetBytesPerPixel(m_sharedImage->format); std::unique_ptr colorBuffer(new UInt8[bpp]); - if (!PixelFormat::Convert(PixelFormatType_RGBA8, m_sharedImage->format, &color.r, colorBuffer.get())) + if (!PixelFormatInfo::Convert(PixelFormat_RGBA8, m_sharedImage->format, &color.r, colorBuffer.get())) { - NazaraError("Failed to convert RGBA8 to " + PixelFormat::GetName(m_sharedImage->format)); + NazaraError("Failed to convert RGBA8 to " + PixelFormatInfo::GetName(m_sharedImage->format)); return false; } @@ -501,7 +501,7 @@ namespace Nz for (auto& level : m_sharedImage->levels) { UInt8* ptr = level.get(); - if (!PixelFormat::Flip(PixelFlipping_Horizontally, m_sharedImage->format, width, height, depth, ptr, ptr)) + if (!PixelFormatInfo::Flip(PixelFlipping_Horizontally, m_sharedImage->format, width, height, depth, ptr, ptr)) { NazaraError("Failed to flip image"); return false; @@ -529,7 +529,7 @@ namespace Nz return false; } - if (PixelFormat::IsCompressed(m_sharedImage->format)) + if (PixelFormatInfo::IsCompressed(m_sharedImage->format)) { NazaraError("Cannot flip compressed image"); return false; @@ -544,7 +544,7 @@ namespace Nz for (auto& level : m_sharedImage->levels) { UInt8* ptr = level.get(); - if (!PixelFormat::Flip(PixelFlipping_Vertically, m_sharedImage->format, width, height, depth, ptr, ptr)) + if (!PixelFormatInfo::Flip(PixelFlipping_Vertically, m_sharedImage->format, width, height, depth, ptr, ptr)) { NazaraError("Failed to flip image"); return false; @@ -604,7 +604,7 @@ namespace Nz } #endif - return GetPixelPtr(m_sharedImage->levels[level].get(), PixelFormat::GetBytesPerPixel(m_sharedImage->format), x, y, z, width, height); + return GetPixelPtr(m_sharedImage->levels[level].get(), PixelFormatInfo::GetBytesPerPixel(m_sharedImage->format), x, y, z, width, height); } unsigned int Image::GetDepth(UInt8 level) const @@ -620,7 +620,7 @@ namespace Nz return GetLevelSize(m_sharedImage->depth, level); } - PixelFormatType Image::GetFormat() const + PixelFormat Image::GetFormat() const { return m_sharedImage->format; } @@ -672,12 +672,12 @@ namespace Nz if (m_sharedImage->type == ImageType_Cubemap) size *= 6; - return size * PixelFormat::GetBytesPerPixel(m_sharedImage->format); + return size * PixelFormatInfo::GetBytesPerPixel(m_sharedImage->format); } std::size_t Image::GetMemoryUsage(UInt8 level) const { - return PixelFormat::ComputeSize(m_sharedImage->format, GetLevelSize(m_sharedImage->width, level), GetLevelSize(m_sharedImage->height, level), ((m_sharedImage->type == ImageType_Cubemap) ? 6 : GetLevelSize(m_sharedImage->depth, level))); + return PixelFormatInfo::ComputeSize(m_sharedImage->format, GetLevelSize(m_sharedImage->width, level), GetLevelSize(m_sharedImage->height, level), ((m_sharedImage->type == ImageType_Cubemap) ? 6 : GetLevelSize(m_sharedImage->depth, level))); } Color Image::GetPixelColor(unsigned int x, unsigned int y, unsigned int z) const @@ -689,7 +689,7 @@ namespace Nz return Color(); } - if (PixelFormat::IsCompressed(m_sharedImage->format)) + if (PixelFormatInfo::IsCompressed(m_sharedImage->format)) { NazaraError("Cannot access pixels from compressed image"); return Color(); @@ -715,10 +715,10 @@ namespace Nz } #endif - const UInt8* pixel = GetPixelPtr(m_sharedImage->levels[0].get(), PixelFormat::GetBytesPerPixel(m_sharedImage->format), x, y, z, m_sharedImage->width, m_sharedImage->height); + const UInt8* pixel = GetPixelPtr(m_sharedImage->levels[0].get(), PixelFormatInfo::GetBytesPerPixel(m_sharedImage->format), x, y, z, m_sharedImage->width, m_sharedImage->height); Color color; - if (!PixelFormat::Convert(m_sharedImage->format, PixelFormatType_RGBA8, pixel, &color.r)) + if (!PixelFormatInfo::Convert(m_sharedImage->format, PixelFormat_RGBA8, pixel, &color.r)) NazaraError("Failed to convert image's format to RGBA8"); return color; @@ -773,7 +773,7 @@ namespace Nz EnsureOwnership(); - return GetPixelPtr(m_sharedImage->levels[level].get(), PixelFormat::GetBytesPerPixel(m_sharedImage->format), x, y, z, width, height); + return GetPixelPtr(m_sharedImage->levels[level].get(), PixelFormatInfo::GetBytesPerPixel(m_sharedImage->format), x, y, z, width, height); } Vector3ui Image::GetSize(UInt8 level) const @@ -811,12 +811,12 @@ namespace Nz { NazaraAssert(m_sharedImage != &emptyImage, "Image must be valid"); - if (!PixelFormat::HasAlpha(m_sharedImage->format)) + if (!PixelFormatInfo::HasAlpha(m_sharedImage->format)) return false; - if (!PixelFormat::IsCompressed(m_sharedImage->format)) + if (!PixelFormatInfo::IsCompressed(m_sharedImage->format)) { - const PixelFormatInfo& info = PixelFormat::GetInfo(m_sharedImage->format); + const PixelFormatDescription& info = PixelFormatInfo::GetInfo(m_sharedImage->format); Bitset<> workingBitset; std::size_t pixelCount = m_sharedImage->width * m_sharedImage->height * ((m_sharedImage->type == ImageType_Cubemap) ? 6 : m_sharedImage->depth); @@ -1208,7 +1208,7 @@ namespace Nz return false; } - if (PixelFormat::IsCompressed(m_sharedImage->format)) + if (PixelFormatInfo::IsCompressed(m_sharedImage->format)) { NazaraError("Cannot access pixels from compressed image"); return false; @@ -1234,9 +1234,9 @@ namespace Nz } #endif - UInt8* pixel = GetPixelPtr(m_sharedImage->levels[0].get(), PixelFormat::GetBytesPerPixel(m_sharedImage->format), x, y, z, m_sharedImage->width, m_sharedImage->height); + UInt8* pixel = GetPixelPtr(m_sharedImage->levels[0].get(), PixelFormatInfo::GetBytesPerPixel(m_sharedImage->format), x, y, z, m_sharedImage->width, m_sharedImage->height); - if (!PixelFormat::Convert(PixelFormatType_RGBA8, m_sharedImage->format, &color.r, pixel)) + if (!PixelFormatInfo::Convert(PixelFormat_RGBA8, m_sharedImage->format, &color.r, pixel)) { NazaraError("Failed to convert RGBA8 to image's format"); return false; @@ -1322,7 +1322,7 @@ namespace Nz EnsureOwnership(); - UInt8 bpp = PixelFormat::GetBytesPerPixel(m_sharedImage->format); + UInt8 bpp = PixelFormatInfo::GetBytesPerPixel(m_sharedImage->format); UInt8* dstPixels = GetPixelPtr(m_sharedImage->levels[level].get(), bpp, box.x, box.y, box.z, width, height); Copy(dstPixels, pixels, m_sharedImage->format, @@ -1349,7 +1349,7 @@ namespace Nz return *this; } - void Image::Copy(UInt8* destination, const UInt8* source, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth, unsigned int dstWidth, unsigned int dstHeight, unsigned int srcWidth, unsigned int srcHeight) + void Image::Copy(UInt8* destination, const UInt8* source, PixelFormat format, unsigned int width, unsigned int height, unsigned int depth, unsigned int dstWidth, unsigned int dstHeight, unsigned int srcWidth, unsigned int srcHeight) { #if NAZARA_UTILITY_SAFE if (width == 0) @@ -1373,10 +1373,10 @@ namespace Nz srcHeight = height; if ((height == 1 || (dstWidth == width && srcWidth == width)) && (depth == 1 || (dstHeight == height && srcHeight == height))) - std::memcpy(destination, source, PixelFormat::ComputeSize(format, width, height, depth)); + std::memcpy(destination, source, PixelFormatInfo::ComputeSize(format, width, height, depth)); else { - unsigned int bpp = PixelFormat::GetBytesPerPixel(format); + unsigned int bpp = PixelFormatInfo::GetBytesPerPixel(format); unsigned int lineStride = width * bpp; unsigned int dstLineStride = dstWidth * bpp; unsigned int dstFaceStride = dstLineStride * dstHeight; @@ -1498,7 +1498,7 @@ namespace Nz ImageLibrary::Uninitialize(); } - Image::SharedImage Image::emptyImage(0, ImageType_2D, PixelFormatType_Undefined, Image::SharedImage::PixelContainer(), 0, 0, 0); + Image::SharedImage Image::emptyImage(0, ImageType_2D, PixelFormat_Undefined, Image::SharedImage::PixelContainer(), 0, 0, 0); ImageLibrary::LibraryMap Image::s_library; ImageLoader::LoaderList Image::s_loaders; ImageManager::ManagerMap Image::s_managerMap; diff --git a/src/Nazara/Utility/PixelFormat.cpp b/src/Nazara/Utility/PixelFormat.cpp index f19d19276..649e1a27b 100644 --- a/src/Nazara/Utility/PixelFormat.cpp +++ b/src/Nazara/Utility/PixelFormat.cpp @@ -41,20 +41,20 @@ namespace Nz return static_cast(c * (31.f/255.f)); } - template + template UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { NazaraUnused(start); NazaraUnused(dst); NazaraUnused(end); - NazaraInternalError("Conversion from " + PixelFormat::GetName(from) + " to " + PixelFormat::GetName(to) + " is not supported"); + NazaraInternalError("Conversion from " + PixelFormatInfo::GetName(from) + " to " + PixelFormatInfo::GetName(to) + " is not supported"); return nullptr; } /**********************************A8***********************************/ template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -70,7 +70,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -84,7 +84,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { UInt16* ptr = reinterpret_cast(dst); while (start < end) @@ -106,7 +106,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { UInt16* ptr = reinterpret_cast(dst); while (start < end) @@ -125,7 +125,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -142,7 +142,7 @@ namespace Nz /**********************************BGR8***********************************/ template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -158,7 +158,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -171,7 +171,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -185,7 +185,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { UInt16* ptr = reinterpret_cast(dst); while (start < end) @@ -207,7 +207,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -222,7 +222,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { UInt16* ptr = reinterpret_cast(dst); while (start < end) @@ -244,7 +244,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -261,7 +261,7 @@ namespace Nz /**********************************BGRA8**********************************/ template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -274,7 +274,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -289,7 +289,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -302,7 +302,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -316,7 +316,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { UInt16* ptr = reinterpret_cast(dst); while (start < end) @@ -338,7 +338,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { UInt16* ptr = reinterpret_cast(dst); while (start < end) @@ -360,7 +360,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -375,7 +375,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -392,7 +392,7 @@ namespace Nz /***********************************L8************************************/ template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -407,7 +407,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -423,7 +423,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -437,7 +437,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { UInt16* ptr = reinterpret_cast(dst); while (start < end) @@ -461,7 +461,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -476,7 +476,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { UInt16* ptr = reinterpret_cast(dst); while (start < end) @@ -500,7 +500,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -517,7 +517,7 @@ namespace Nz /***********************************LA8***********************************/ template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -530,7 +530,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -545,7 +545,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -561,7 +561,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -574,7 +574,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { UInt16* ptr = reinterpret_cast(dst); while (start < end) @@ -595,7 +595,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -610,7 +610,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { UInt16* ptr = reinterpret_cast(dst); while (start < end) @@ -631,7 +631,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -648,7 +648,7 @@ namespace Nz /*********************************RGBA4***********************************/ template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -667,7 +667,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -688,7 +688,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -710,7 +710,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -733,7 +733,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -757,7 +757,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { UInt16* ptr = reinterpret_cast(dst); while (start < end) @@ -787,7 +787,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -808,7 +808,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -831,7 +831,7 @@ namespace Nz /*********************************RGB5A1**********************************/ template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -850,7 +850,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -871,7 +871,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -893,7 +893,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -916,7 +916,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -940,7 +940,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -961,7 +961,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { UInt16* ptr = reinterpret_cast(dst); while (start < end) @@ -990,7 +990,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -1013,7 +1013,7 @@ namespace Nz /**********************************RGB8***********************************/ template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -1028,7 +1028,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -1044,7 +1044,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -1057,7 +1057,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -1071,7 +1071,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { UInt16* ptr = reinterpret_cast(dst); while (start < end) @@ -1093,7 +1093,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { UInt16* ptr = reinterpret_cast(dst); while (start < end) @@ -1115,7 +1115,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -1132,7 +1132,7 @@ namespace Nz /**********************************RGBA8**********************************/ template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -1145,7 +1145,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -1160,7 +1160,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -1176,7 +1176,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -1189,7 +1189,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -1203,7 +1203,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { UInt16* ptr = reinterpret_cast(dst); while (start < end) @@ -1225,7 +1225,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { while (start < end) { @@ -1240,7 +1240,7 @@ namespace Nz } template<> - UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) + UInt8* ConvertPixels(const UInt8* start, const UInt8* end, UInt8* dst) { UInt16* ptr = reinterpret_cast(dst); while (start < end) @@ -1261,14 +1261,14 @@ namespace Nz return dst; } - template + template void RegisterConverter() { - PixelFormat::SetConvertFunction(format1, format2, &ConvertPixels); + PixelFormatInfo::SetConvertFunction(format1, format2, &ConvertPixels); } } - bool PixelFormat::Flip(PixelFlipping flipping, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth, const void* src, void* dst) + bool PixelFormatInfo::Flip(PixelFlipping flipping, PixelFormat format, unsigned int width, unsigned int height, unsigned int depth, const void* src, void* dst) { #if NAZARA_UTILITY_SAFE if (!IsValid(format)) @@ -1364,320 +1364,320 @@ namespace Nz return true; } - PixelFormatType PixelFormat::IdentifyFormat(const PixelFormatInfo& info) + PixelFormat PixelFormatInfo::IdentifyFormat(const PixelFormatDescription& info) { - for (unsigned int i = 0; i <= PixelFormatType_Max; ++i) + for (unsigned int i = 0; i <= PixelFormat_Max; ++i) { - PixelFormatInfo& info2 = s_pixelFormatInfos[i]; + PixelFormatDescription& info2 = s_pixelFormatInfos[i]; if (info.bitsPerPixel == info2.bitsPerPixel && info.content == info2.content && info.redMask == info2.redMask && info.greenMask == info2.greenMask && info.blueMask == info2.blueMask && info.alphaMask == info2.alphaMask && info.redType == info2.redType && info.greenType == info2.greenType && info.blueType == info2.blueType && info.alphaType == info2.alphaType) - return static_cast(i); + return static_cast(i); } - return PixelFormatType_Undefined; + return PixelFormat_Undefined; } - bool PixelFormat::Initialize() + bool PixelFormatInfo::Initialize() { Bitset<> b32(0xFFFFFFFF); b32.Resize(128); // Setup informations about every pixel format - s_pixelFormatInfos[PixelFormatType_A8] = PixelFormatInfo("A8", PixelFormatContent_ColorRGBA, 0, 0, 0, 0xFF, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_BGR8] = PixelFormatInfo("BGR8", PixelFormatContent_ColorRGBA, 0x0000FF, 0x00FF00, 0xFF0000, 0, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_BGRA8] = PixelFormatInfo("BGRA8", PixelFormatContent_ColorRGBA, 0x0000FF00, 0x00FF0000, 0xFF000000, 0x000000FF, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_DXT1] = PixelFormatInfo("DXT1", PixelFormatContent_ColorRGBA, 8, PixelFormatSubType_Compressed); - s_pixelFormatInfos[PixelFormatType_DXT3] = PixelFormatInfo("DXT3", PixelFormatContent_ColorRGBA, 16, PixelFormatSubType_Compressed); - s_pixelFormatInfos[PixelFormatType_DXT5] = PixelFormatInfo("DXT5", PixelFormatContent_ColorRGBA, 16, PixelFormatSubType_Compressed); - s_pixelFormatInfos[PixelFormatType_L8] = PixelFormatInfo("L8", PixelFormatContent_ColorRGBA, 0xFF, 0xFF, 0xFF, 0, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_LA8] = PixelFormatInfo("LA8", PixelFormatContent_ColorRGBA, 0xFF00, 0xFF00, 0xFF00, 0x00FF, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_R8] = PixelFormatInfo("R8", PixelFormatContent_ColorRGBA, 0xFF, 0, 0, 0, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_R8I] = PixelFormatInfo("R8I", PixelFormatContent_ColorRGBA, 0xFF, 0, 0, 0, PixelFormatSubType_Int); - s_pixelFormatInfos[PixelFormatType_R8UI] = PixelFormatInfo("R8UI", PixelFormatContent_ColorRGBA, 0xFF, 0, 0, 0, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_R16] = PixelFormatInfo("R16", PixelFormatContent_ColorRGBA, 0xFFFF, 0, 0, 0, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_R16F] = PixelFormatInfo("R16F", PixelFormatContent_ColorRGBA, 0xFFFF, 0, 0, 0, PixelFormatSubType_Half); - s_pixelFormatInfos[PixelFormatType_R16I] = PixelFormatInfo("R16I", PixelFormatContent_ColorRGBA, 0xFFFF, 0, 0, 0, PixelFormatSubType_Int); - s_pixelFormatInfos[PixelFormatType_R16UI] = PixelFormatInfo("R16UI", PixelFormatContent_ColorRGBA, 0xFFFF, 0, 0, 0, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_R32F] = PixelFormatInfo("R32F", PixelFormatContent_ColorRGBA, 0xFFFFFFFF, 0, 0, 0, PixelFormatSubType_Float); - s_pixelFormatInfos[PixelFormatType_R32I] = PixelFormatInfo("R32I", PixelFormatContent_ColorRGBA, 0xFFFFFFFF, 0, 0, 0, PixelFormatSubType_Int); - s_pixelFormatInfos[PixelFormatType_R32UI] = PixelFormatInfo("R32UI", PixelFormatContent_ColorRGBA, 0xFFFFFFFF, 0, 0, 0, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_RG8] = PixelFormatInfo("RG8", PixelFormatContent_ColorRGBA, 0xFF00, 0x00FF, 0, 0, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_RG8I] = PixelFormatInfo("RG8I", PixelFormatContent_ColorRGBA, 0xFF00, 0x00FF, 0, 0, PixelFormatSubType_Int); - s_pixelFormatInfos[PixelFormatType_RG8UI] = PixelFormatInfo("RG8UI", PixelFormatContent_ColorRGBA, 0xFF00, 0x00FF, 0, 0, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_RG16] = PixelFormatInfo("RG16", PixelFormatContent_ColorRGBA, 0xFFFF0000, 0x0000FFFF, 0, 0, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_RG16F] = PixelFormatInfo("RG16F", PixelFormatContent_ColorRGBA, 0xFFFF0000, 0x0000FFFF, 0, 0, PixelFormatSubType_Half); - s_pixelFormatInfos[PixelFormatType_RG16I] = PixelFormatInfo("RG16I", PixelFormatContent_ColorRGBA, 0xFFFF0000, 0x0000FFFF, 0, 0, PixelFormatSubType_Int); - s_pixelFormatInfos[PixelFormatType_RG16UI] = PixelFormatInfo("RG16UI", PixelFormatContent_ColorRGBA, 0xFFFF0000, 0x0000FFFF, 0, 0, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_RG32F] = PixelFormatInfo("RG32F", PixelFormatContent_ColorRGBA, 0xFFFFFFFF00000000, 0x00000000FFFFFFFF, 0, 0, PixelFormatSubType_Float); - s_pixelFormatInfos[PixelFormatType_RG32I] = PixelFormatInfo("RG32I", PixelFormatContent_ColorRGBA, 0xFFFFFFFF00000000, 0x00000000FFFFFFFF, 0, 0, PixelFormatSubType_Int); - s_pixelFormatInfos[PixelFormatType_RG32UI] = PixelFormatInfo("RG32UI", PixelFormatContent_ColorRGBA, 0xFFFFFFFF00000000, 0x00000000FFFFFFFF, 0, 0, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_RGB8] = PixelFormatInfo("RGB8", PixelFormatContent_ColorRGBA, 0xFF000000, 0x00FF0000, 0x0000FF00, 0, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_RGB16F] = PixelFormatInfo("RGB16F", PixelFormatContent_ColorRGBA, 0xFFFF00000000, 0x0000FFFF0000, 0x00000000FFFF, 0, PixelFormatSubType_Half); - s_pixelFormatInfos[PixelFormatType_RGB16I] = PixelFormatInfo("RGB16I", PixelFormatContent_ColorRGBA, 0xFFFF00000000, 0x0000FFFF0000, 0x00000000FFFF, 0, PixelFormatSubType_Int); - s_pixelFormatInfos[PixelFormatType_RGB16UI] = PixelFormatInfo("RGB16UI", PixelFormatContent_ColorRGBA, 0xFFFF000000000000, 0x0000FFFF00000000, 0x00000000FFFF0000, 0, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_RGB32F] = PixelFormatInfo("RGB32F", PixelFormatContent_ColorRGBA, b32, b32 >> 32, b32 >> 64, 0, PixelFormatSubType_Float); - s_pixelFormatInfos[PixelFormatType_RGB32I] = PixelFormatInfo("RGB32I", PixelFormatContent_ColorRGBA, b32, b32 >> 32, b32 >> 64, 0, PixelFormatSubType_Int); - s_pixelFormatInfos[PixelFormatType_RGB32UI] = PixelFormatInfo("RGB32UI", PixelFormatContent_ColorRGBA, b32, b32 >> 32, b32 >> 64, 0, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_RGBA4] = PixelFormatInfo("RGBA4", PixelFormatContent_ColorRGBA, 0xF000, 0x0F00, 0x00F0, 0x000F, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_RGB5A1] = PixelFormatInfo("RGB5A1", PixelFormatContent_ColorRGBA, 0xF800, 0x07C0, 0x003E, 0x0001, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_RGBA8] = PixelFormatInfo("RGBA8", PixelFormatContent_ColorRGBA, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_RGBA16F] = PixelFormatInfo("RGBA16F", PixelFormatContent_ColorRGBA, 0xFFFF000000000000, 0x0000FFFF00000000, 0x00000000FFFF0000, 0x000000000000FFFF, PixelFormatSubType_Half); - s_pixelFormatInfos[PixelFormatType_RGBA16I] = PixelFormatInfo("RGBA16I", PixelFormatContent_ColorRGBA, 0xFFFF000000000000, 0x0000FFFF00000000, 0x00000000FFFF0000, 0x000000000000FFFF, PixelFormatSubType_Int); - s_pixelFormatInfos[PixelFormatType_RGBA16UI] = PixelFormatInfo("RGBA16UI", PixelFormatContent_ColorRGBA, 0xFFFF000000000000, 0x0000FFFF00000000, 0x00000000FFFF0000, 0x000000000000FFFF, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_RGBA32F] = PixelFormatInfo("RGBA32F", PixelFormatContent_ColorRGBA, b32, b32 >> 32, b32 >> 64, b32 >> 96, PixelFormatSubType_Float); - s_pixelFormatInfos[PixelFormatType_RGBA32I] = PixelFormatInfo("RGBA32I", PixelFormatContent_ColorRGBA, b32, b32 >> 32, b32 >> 64, b32 >> 96, PixelFormatSubType_Int); - s_pixelFormatInfos[PixelFormatType_RGBA32UI] = PixelFormatInfo("RGBA32UI", PixelFormatContent_ColorRGBA, b32, b32 >> 32, b32 >> 64, b32 >> 96, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_Depth16] = PixelFormatInfo("Depth16", PixelFormatContent_DepthStencil, 0xFFFF, 0, 0, 0, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_Depth24] = PixelFormatInfo("Depth24", PixelFormatContent_DepthStencil, 0xFFFFFF, 0, 0, 0, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_Depth24Stencil8] = PixelFormatInfo("Depth24Stencil8", PixelFormatContent_DepthStencil, 0xFFFFFF00, 0x000000FF, 0, 0, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_Depth32] = PixelFormatInfo("Depth32", PixelFormatContent_DepthStencil, 0xFFFFFFFF, 0, 0, 0, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_Stencil1] = PixelFormatInfo("Stencil1", PixelFormatContent_Stencil, 0x1, 0, 0, 0, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_Stencil4] = PixelFormatInfo("Stencil4", PixelFormatContent_Stencil, 0xF, 0, 0, 0, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_Stencil8] = PixelFormatInfo("Stencil8", PixelFormatContent_Stencil, 0xFF, 0, 0, 0, PixelFormatSubType_Unsigned); - s_pixelFormatInfos[PixelFormatType_Stencil16] = PixelFormatInfo("Stencil16", PixelFormatContent_Stencil, 0xFFFF, 0, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormat_A8] = PixelFormatDescription("A8", PixelFormatContent_ColorRGBA, 0, 0, 0, 0xFF, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormat_BGR8] = PixelFormatDescription("BGR8", PixelFormatContent_ColorRGBA, 0x0000FF, 0x00FF00, 0xFF0000, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormat_BGRA8] = PixelFormatDescription("BGRA8", PixelFormatContent_ColorRGBA, 0x0000FF00, 0x00FF0000, 0xFF000000, 0x000000FF, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormat_DXT1] = PixelFormatDescription("DXT1", PixelFormatContent_ColorRGBA, 8, PixelFormatSubType_Compressed); + s_pixelFormatInfos[PixelFormat_DXT3] = PixelFormatDescription("DXT3", PixelFormatContent_ColorRGBA, 16, PixelFormatSubType_Compressed); + s_pixelFormatInfos[PixelFormat_DXT5] = PixelFormatDescription("DXT5", PixelFormatContent_ColorRGBA, 16, PixelFormatSubType_Compressed); + s_pixelFormatInfos[PixelFormat_L8] = PixelFormatDescription("L8", PixelFormatContent_ColorRGBA, 0xFF, 0xFF, 0xFF, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormat_LA8] = PixelFormatDescription("LA8", PixelFormatContent_ColorRGBA, 0xFF00, 0xFF00, 0xFF00, 0x00FF, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormat_R8] = PixelFormatDescription("R8", PixelFormatContent_ColorRGBA, 0xFF, 0, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormat_R8I] = PixelFormatDescription("R8I", PixelFormatContent_ColorRGBA, 0xFF, 0, 0, 0, PixelFormatSubType_Int); + s_pixelFormatInfos[PixelFormat_R8UI] = PixelFormatDescription("R8UI", PixelFormatContent_ColorRGBA, 0xFF, 0, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormat_R16] = PixelFormatDescription("R16", PixelFormatContent_ColorRGBA, 0xFFFF, 0, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormat_R16F] = PixelFormatDescription("R16F", PixelFormatContent_ColorRGBA, 0xFFFF, 0, 0, 0, PixelFormatSubType_Half); + s_pixelFormatInfos[PixelFormat_R16I] = PixelFormatDescription("R16I", PixelFormatContent_ColorRGBA, 0xFFFF, 0, 0, 0, PixelFormatSubType_Int); + s_pixelFormatInfos[PixelFormat_R16UI] = PixelFormatDescription("R16UI", PixelFormatContent_ColorRGBA, 0xFFFF, 0, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormat_R32F] = PixelFormatDescription("R32F", PixelFormatContent_ColorRGBA, 0xFFFFFFFF, 0, 0, 0, PixelFormatSubType_Float); + s_pixelFormatInfos[PixelFormat_R32I] = PixelFormatDescription("R32I", PixelFormatContent_ColorRGBA, 0xFFFFFFFF, 0, 0, 0, PixelFormatSubType_Int); + s_pixelFormatInfos[PixelFormat_R32UI] = PixelFormatDescription("R32UI", PixelFormatContent_ColorRGBA, 0xFFFFFFFF, 0, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormat_RG8] = PixelFormatDescription("RG8", PixelFormatContent_ColorRGBA, 0xFF00, 0x00FF, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormat_RG8I] = PixelFormatDescription("RG8I", PixelFormatContent_ColorRGBA, 0xFF00, 0x00FF, 0, 0, PixelFormatSubType_Int); + s_pixelFormatInfos[PixelFormat_RG8UI] = PixelFormatDescription("RG8UI", PixelFormatContent_ColorRGBA, 0xFF00, 0x00FF, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormat_RG16] = PixelFormatDescription("RG16", PixelFormatContent_ColorRGBA, 0xFFFF0000, 0x0000FFFF, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormat_RG16F] = PixelFormatDescription("RG16F", PixelFormatContent_ColorRGBA, 0xFFFF0000, 0x0000FFFF, 0, 0, PixelFormatSubType_Half); + s_pixelFormatInfos[PixelFormat_RG16I] = PixelFormatDescription("RG16I", PixelFormatContent_ColorRGBA, 0xFFFF0000, 0x0000FFFF, 0, 0, PixelFormatSubType_Int); + s_pixelFormatInfos[PixelFormat_RG16UI] = PixelFormatDescription("RG16UI", PixelFormatContent_ColorRGBA, 0xFFFF0000, 0x0000FFFF, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormat_RG32F] = PixelFormatDescription("RG32F", PixelFormatContent_ColorRGBA, 0xFFFFFFFF00000000, 0x00000000FFFFFFFF, 0, 0, PixelFormatSubType_Float); + s_pixelFormatInfos[PixelFormat_RG32I] = PixelFormatDescription("RG32I", PixelFormatContent_ColorRGBA, 0xFFFFFFFF00000000, 0x00000000FFFFFFFF, 0, 0, PixelFormatSubType_Int); + s_pixelFormatInfos[PixelFormat_RG32UI] = PixelFormatDescription("RG32UI", PixelFormatContent_ColorRGBA, 0xFFFFFFFF00000000, 0x00000000FFFFFFFF, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormat_RGB8] = PixelFormatDescription("RGB8", PixelFormatContent_ColorRGBA, 0xFF000000, 0x00FF0000, 0x0000FF00, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormat_RGB16F] = PixelFormatDescription("RGB16F", PixelFormatContent_ColorRGBA, 0xFFFF00000000, 0x0000FFFF0000, 0x00000000FFFF, 0, PixelFormatSubType_Half); + s_pixelFormatInfos[PixelFormat_RGB16I] = PixelFormatDescription("RGB16I", PixelFormatContent_ColorRGBA, 0xFFFF00000000, 0x0000FFFF0000, 0x00000000FFFF, 0, PixelFormatSubType_Int); + s_pixelFormatInfos[PixelFormat_RGB16UI] = PixelFormatDescription("RGB16UI", PixelFormatContent_ColorRGBA, 0xFFFF000000000000, 0x0000FFFF00000000, 0x00000000FFFF0000, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormat_RGB32F] = PixelFormatDescription("RGB32F", PixelFormatContent_ColorRGBA, b32, b32 >> 32, b32 >> 64, 0, PixelFormatSubType_Float); + s_pixelFormatInfos[PixelFormat_RGB32I] = PixelFormatDescription("RGB32I", PixelFormatContent_ColorRGBA, b32, b32 >> 32, b32 >> 64, 0, PixelFormatSubType_Int); + s_pixelFormatInfos[PixelFormat_RGB32UI] = PixelFormatDescription("RGB32UI", PixelFormatContent_ColorRGBA, b32, b32 >> 32, b32 >> 64, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormat_RGBA4] = PixelFormatDescription("RGBA4", PixelFormatContent_ColorRGBA, 0xF000, 0x0F00, 0x00F0, 0x000F, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormat_RGB5A1] = PixelFormatDescription("RGB5A1", PixelFormatContent_ColorRGBA, 0xF800, 0x07C0, 0x003E, 0x0001, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormat_RGBA8] = PixelFormatDescription("RGBA8", PixelFormatContent_ColorRGBA, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormat_RGBA16F] = PixelFormatDescription("RGBA16F", PixelFormatContent_ColorRGBA, 0xFFFF000000000000, 0x0000FFFF00000000, 0x00000000FFFF0000, 0x000000000000FFFF, PixelFormatSubType_Half); + s_pixelFormatInfos[PixelFormat_RGBA16I] = PixelFormatDescription("RGBA16I", PixelFormatContent_ColorRGBA, 0xFFFF000000000000, 0x0000FFFF00000000, 0x00000000FFFF0000, 0x000000000000FFFF, PixelFormatSubType_Int); + s_pixelFormatInfos[PixelFormat_RGBA16UI] = PixelFormatDescription("RGBA16UI", PixelFormatContent_ColorRGBA, 0xFFFF000000000000, 0x0000FFFF00000000, 0x00000000FFFF0000, 0x000000000000FFFF, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormat_RGBA32F] = PixelFormatDescription("RGBA32F", PixelFormatContent_ColorRGBA, b32, b32 >> 32, b32 >> 64, b32 >> 96, PixelFormatSubType_Float); + s_pixelFormatInfos[PixelFormat_RGBA32I] = PixelFormatDescription("RGBA32I", PixelFormatContent_ColorRGBA, b32, b32 >> 32, b32 >> 64, b32 >> 96, PixelFormatSubType_Int); + s_pixelFormatInfos[PixelFormat_RGBA32UI] = PixelFormatDescription("RGBA32UI", PixelFormatContent_ColorRGBA, b32, b32 >> 32, b32 >> 64, b32 >> 96, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormat_Depth16] = PixelFormatDescription("Depth16", PixelFormatContent_DepthStencil, 0xFFFF, 0, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormat_Depth24] = PixelFormatDescription("Depth24", PixelFormatContent_DepthStencil, 0xFFFFFF, 0, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormat_Depth24Stencil8] = PixelFormatDescription("Depth24Stencil8", PixelFormatContent_DepthStencil, 0xFFFFFF00, 0x000000FF, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormat_Depth32] = PixelFormatDescription("Depth32", PixelFormatContent_DepthStencil, 0xFFFFFFFF, 0, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormat_Stencil1] = PixelFormatDescription("Stencil1", PixelFormatContent_Stencil, 0x1, 0, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormat_Stencil4] = PixelFormatDescription("Stencil4", PixelFormatContent_Stencil, 0xF, 0, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormat_Stencil8] = PixelFormatDescription("Stencil8", PixelFormatContent_Stencil, 0xFF, 0, 0, 0, PixelFormatSubType_Unsigned); + s_pixelFormatInfos[PixelFormat_Stencil16] = PixelFormatDescription("Stencil16", PixelFormatContent_Stencil, 0xFFFF, 0, 0, 0, PixelFormatSubType_Unsigned); - for (unsigned int i = 0; i <= PixelFormatType_Max; ++i) + for (unsigned int i = 0; i <= PixelFormat_Max; ++i) { if (!s_pixelFormatInfos[i].Validate()) - NazaraWarning("Pixel format 0x" + String::Number(i, 16) + " (" + GetName(static_cast(i)) + ") failed validation tests"); + NazaraWarning("Pixel format 0x" + String::Number(i, 16) + " (" + GetName(static_cast(i)) + ") failed validation tests"); } // Reset functions - std::memset(s_convertFunctions, 0, (PixelFormatType_Max+1)*(PixelFormatType_Max+1)*sizeof(PixelFormat::ConvertFunction)); + std::memset(s_convertFunctions, 0, (PixelFormat_Max+1)*(PixelFormat_Max+1)*sizeof(PixelFormatInfo::ConvertFunction)); /***********************************A8************************************/ - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); /**********************************BGR8***********************************/ - RegisterConverter(); - RegisterConverter(); - RegisterConverter();/* - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter();*/ - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter();/* + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter();*/ + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); /**********************************BGRA8**********************************/ - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter();/* - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter();*/ - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter();/* + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter();*/ + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); /**********************************DXT1***********************************/ ///TODO: Décompresseur DXT1 /* - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); */ /**********************************DXT3***********************************/ ///TODO: Décompresseur DXT3 /* - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); */ /**********************************DXT5***********************************/ ///TODO: Décompresseur DXT5 /* - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); */ /***********************************L8************************************/ - RegisterConverter(); - RegisterConverter(); - RegisterConverter();/* - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter();*/ - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter();/* + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter();*/ + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); /***********************************LA8***********************************/ - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter();/* - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter();*/ - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter();/* + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter();*/ + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); /**********************************RGBA4**********************************/ - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter();/* - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter();*/ - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter();/* + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter();*/ + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); /*********************************RGB5A1**********************************/ - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter();/* - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter();*/ - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter();/* + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter();*/ + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); /**********************************RGB8***********************************/ - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter();/* - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter();*/ - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter();/* + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter();*/ + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); /**********************************RGBA8**********************************/ - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter();/* - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); - RegisterConverter();*/ - RegisterConverter(); - RegisterConverter(); - RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter();/* + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); + RegisterConverter();*/ + RegisterConverter(); + RegisterConverter(); + RegisterConverter(); return true; } - void PixelFormat::Uninitialize() + void PixelFormatInfo::Uninitialize() { - for (unsigned int i = 0; i <= PixelFormatType_Max; ++i) + for (unsigned int i = 0; i <= PixelFormat_Max; ++i) s_pixelFormatInfos[i].Clear(); - std::memset(s_convertFunctions, 0, (PixelFormatType_Max+1)*(PixelFormatType_Max+1)*sizeof(PixelFormat::ConvertFunction)); + std::memset(s_convertFunctions, 0, (PixelFormat_Max+1)*(PixelFormat_Max+1)*sizeof(PixelFormatInfo::ConvertFunction)); for (unsigned int i = 0; i <= PixelFlipping_Max; ++i) s_flipFunctions[i].clear(); } - PixelFormatInfo PixelFormat::s_pixelFormatInfos[PixelFormatType_Max + 1]; - PixelFormat::ConvertFunction PixelFormat::s_convertFunctions[PixelFormatType_Max+1][PixelFormatType_Max+1]; - std::map PixelFormat::s_flipFunctions[PixelFlipping_Max+1]; + PixelFormatDescription PixelFormatInfo::s_pixelFormatInfos[PixelFormat_Max + 1]; + PixelFormatInfo::ConvertFunction PixelFormatInfo::s_convertFunctions[PixelFormat_Max+1][PixelFormat_Max+1]; + std::map PixelFormatInfo::s_flipFunctions[PixelFlipping_Max+1]; } diff --git a/src/Nazara/Utility/Utility.cpp b/src/Nazara/Utility/Utility.cpp index 5feff8f33..8737a93e3 100644 --- a/src/Nazara/Utility/Utility.cpp +++ b/src/Nazara/Utility/Utility.cpp @@ -93,7 +93,7 @@ namespace Nz return false; } - if (!PixelFormat::Initialize()) + if (!PixelFormatInfo::Initialize()) { NazaraError("Failed to initialize pixel formats"); return false; @@ -176,7 +176,7 @@ namespace Nz VertexDeclaration::Uninitialize(); Skeleton::Uninitialize(); - PixelFormat::Uninitialize(); + PixelFormatInfo::Uninitialize(); Mesh::Uninitialize(); Image::Uninitialize(); Font::Uninitialize(); diff --git a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp index 7e5ce6fff..3a6d43eee 100644 --- a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp +++ b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp @@ -94,38 +94,38 @@ namespace Nz if (!parameters.depthFormats.empty()) { - for (PixelFormatType format : parameters.depthFormats) + for (PixelFormat format : parameters.depthFormats) { switch (format) { - case PixelFormatType_Depth16: + case PixelFormat_Depth16: m_depthStencilFormat = VK_FORMAT_D16_UNORM; break; - case PixelFormatType_Depth24: - case PixelFormatType_Depth24Stencil8: + case PixelFormat_Depth24: + case PixelFormat_Depth24Stencil8: m_depthStencilFormat = VK_FORMAT_D24_UNORM_S8_UINT; break; - case PixelFormatType_Depth32: + case PixelFormat_Depth32: m_depthStencilFormat = VK_FORMAT_D32_SFLOAT; break; - case PixelFormatType_Stencil1: - case PixelFormatType_Stencil4: - case PixelFormatType_Stencil8: + case PixelFormat_Stencil1: + case PixelFormat_Stencil4: + case PixelFormat_Stencil8: m_depthStencilFormat = VK_FORMAT_S8_UINT; break; - case PixelFormatType_Stencil16: + case PixelFormat_Stencil16: m_depthStencilFormat = VK_FORMAT_MAX_ENUM; break; default: { - PixelFormatContent formatContent = PixelFormat::GetContent(format); + PixelFormatContent formatContent = PixelFormatInfo::GetContent(format); if (formatContent != PixelFormatContent_DepthStencil && formatContent != PixelFormatContent_Stencil) - NazaraWarning("Invalid format " + PixelFormat::GetName(format) + " for depth-stencil attachment"); + NazaraWarning("Invalid format " + PixelFormatInfo::GetName(format) + " for depth-stencil attachment"); m_depthStencilFormat = VK_FORMAT_MAX_ENUM; break; diff --git a/src/Nazara/VulkanRenderer/VulkanTexture.cpp b/src/Nazara/VulkanRenderer/VulkanTexture.cpp index 186bbebbb..3a83d1c8c 100644 --- a/src/Nazara/VulkanRenderer/VulkanTexture.cpp +++ b/src/Nazara/VulkanRenderer/VulkanTexture.cpp @@ -156,7 +156,7 @@ namespace Nz vmaDestroyImage(m_device.GetMemoryAllocator(), m_image, m_allocation); } - PixelFormatType VulkanTexture::GetFormat() const + PixelFormat VulkanTexture::GetFormat() const { return m_params.pixelFormat; } @@ -178,7 +178,7 @@ namespace Nz bool VulkanTexture::Update(const void* ptr) { - std::size_t textureSize = m_params.width * m_params.height * m_params.depth * PixelFormat::GetBytesPerPixel(m_params.pixelFormat); + std::size_t textureSize = m_params.width * m_params.height * m_params.depth * PixelFormatInfo::GetBytesPerPixel(m_params.pixelFormat); VkBufferCreateInfo createInfo = {}; createInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; @@ -229,7 +229,7 @@ namespace Nz return true; } - void VulkanTexture::InitForFormat(PixelFormatType pixelFormat, VkImageCreateInfo& createImage, VkImageViewCreateInfo& createImageView) + void VulkanTexture::InitForFormat(PixelFormat pixelFormat, VkImageCreateInfo& createImage, VkImageViewCreateInfo& createImageView) { createImageView.components = { VK_COMPONENT_SWIZZLE_R, @@ -240,7 +240,7 @@ namespace Nz switch (pixelFormat) { - case PixelFormatType_L8: + case PixelFormat_L8: { createImage.format = VK_FORMAT_R8_SRGB; createImageView.format = createImage.format; @@ -253,7 +253,7 @@ namespace Nz break; } - case PixelFormatType_LA8: + case PixelFormat_LA8: { createImage.format = VK_FORMAT_R8G8_SRGB; createImageView.format = createImage.format; @@ -266,14 +266,14 @@ namespace Nz break; } - case PixelFormatType_RGB8: + case PixelFormat_RGB8: { createImage.format = VK_FORMAT_R8G8B8_SRGB; createImageView.format = createImage.format; break; } - case PixelFormatType_RGBA8: + case PixelFormat_RGBA8: { createImage.format = VK_FORMAT_R8G8B8A8_SRGB; createImageView.format = createImage.format; @@ -281,7 +281,7 @@ namespace Nz } default: - throw std::runtime_error(("Unsupported pixel format " + PixelFormat::GetName(pixelFormat)).ToStdString()); + throw std::runtime_error(("Unsupported pixel format " + PixelFormatInfo::GetName(pixelFormat)).ToStdString()); } } } diff --git a/src/NazaraSDK/Components/GraphicsComponent.cpp b/src/NazaraSDK/Components/GraphicsComponent.cpp index b7251fd95..80ab3805b 100644 --- a/src/NazaraSDK/Components/GraphicsComponent.cpp +++ b/src/NazaraSDK/Components/GraphicsComponent.cpp @@ -137,7 +137,7 @@ namespace Ndk if (!m_reflectionMap) { m_reflectionMap = Nz::Texture::New(); - if (!m_reflectionMap->Create(Nz::ImageType_Cubemap, Nz::PixelFormatType_RGB8, m_reflectionMapSize, m_reflectionMapSize)) + if (!m_reflectionMap->Create(Nz::ImageType_Cubemap, Nz::PixelFormat_RGB8, m_reflectionMapSize, m_reflectionMapSize)) { NazaraWarning("Failed to create reflection map, reflections will be disabled for this entity"); return; From d9a08640d61858f83e48d688d1480520c19adff6 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 10 Apr 2020 17:36:05 +0200 Subject: [PATCH 144/316] Vulkan: Add renderpass and framebuffers --- .../Nazara/Renderer/CommandBufferBuilder.hpp | 17 +++- include/Nazara/Renderer/Framebuffer.hpp | 30 ++++++ include/Nazara/Renderer/Framebuffer.inl | 12 +++ include/Nazara/Renderer/RenderPass.hpp | 40 ++++++++ include/Nazara/Renderer/RenderPass.inl | 12 +++ include/Nazara/Renderer/RenderWindowImpl.hpp | 4 + .../Nazara/VulkanRenderer/VkRenderTarget.hpp | 10 -- .../Nazara/VulkanRenderer/VkRenderTarget.inl | 4 - .../Nazara/VulkanRenderer/VkRenderWindow.hpp | 17 ++-- .../Nazara/VulkanRenderer/VkRenderWindow.inl | 19 ++-- .../VulkanRenderer/VulkanCommandBuffer.hpp | 6 +- .../VulkanRenderer/VulkanCommandBuffer.inl | 13 ++- .../VulkanCommandBufferBuilder.hpp | 13 ++- .../VulkanCommandBufferBuilder.inl | 11 ++- .../VulkanRenderer/VulkanFramebuffer.hpp | 43 +++++++++ .../VulkanRenderer/VulkanFramebuffer.inl | 21 +++++ .../VulkanMultipleFramebuffer.hpp | 36 +++++++ .../VulkanMultipleFramebuffer.inl | 30 ++++++ .../VulkanRenderer/VulkanRenderPass.hpp | 41 ++++++++ .../VulkanRenderer/VulkanRenderPass.inl | 32 +++++++ .../VulkanRenderer/VulkanRenderPipeline.hpp | 4 +- .../VulkanRenderer/VulkanShaderBinding.hpp | 4 +- .../VulkanRenderer/VulkanShaderBinding.inl | 4 +- .../VulkanSingleFramebuffer.hpp | 35 +++++++ .../VulkanSingleFramebuffer.inl | 27 ++++++ .../VulkanRenderer/Wrapper/DeviceObject.hpp | 2 +- .../VulkanRenderer/Wrapper/DeviceObject.inl | 11 +++ .../VulkanRenderer/Wrapper/RenderPass.hpp | 2 +- .../Components/PhysicsComponent3D.inl | 2 +- src/Nazara/Renderer/Framebuffer.cpp | 11 +++ src/Nazara/Renderer/RenderPass.cpp | 11 +++ src/Nazara/VulkanRenderer/VkRenderTarget.cpp | 5 - src/Nazara/VulkanRenderer/VkRenderWindow.cpp | 60 +++++++----- .../VulkanCommandBufferBuilder.cpp | 93 ++++++++++++++++++- .../VulkanRenderer/VulkanCommandPool.cpp | 26 ++++-- .../VulkanRenderer/VulkanFramebuffer.cpp | 10 ++ .../VulkanMultipleFramebuffer.cpp | 10 ++ .../VulkanRenderer/VulkanRenderImage.cpp | 4 +- .../VulkanRenderer/VulkanRenderPass.cpp | 10 ++ .../VulkanRenderer/VulkanRenderPipeline.cpp | 2 +- .../VulkanSingleFramebuffer.cpp | 10 ++ 41 files changed, 659 insertions(+), 95 deletions(-) create mode 100644 include/Nazara/Renderer/Framebuffer.hpp create mode 100644 include/Nazara/Renderer/Framebuffer.inl create mode 100644 include/Nazara/Renderer/RenderPass.hpp create mode 100644 include/Nazara/Renderer/RenderPass.inl create mode 100644 include/Nazara/VulkanRenderer/VulkanFramebuffer.hpp create mode 100644 include/Nazara/VulkanRenderer/VulkanFramebuffer.inl create mode 100644 include/Nazara/VulkanRenderer/VulkanMultipleFramebuffer.hpp create mode 100644 include/Nazara/VulkanRenderer/VulkanMultipleFramebuffer.inl create mode 100644 include/Nazara/VulkanRenderer/VulkanRenderPass.hpp create mode 100644 include/Nazara/VulkanRenderer/VulkanRenderPass.inl create mode 100644 include/Nazara/VulkanRenderer/VulkanSingleFramebuffer.hpp create mode 100644 include/Nazara/VulkanRenderer/VulkanSingleFramebuffer.inl create mode 100644 src/Nazara/Renderer/Framebuffer.cpp create mode 100644 src/Nazara/Renderer/RenderPass.cpp create mode 100644 src/Nazara/VulkanRenderer/VulkanFramebuffer.cpp create mode 100644 src/Nazara/VulkanRenderer/VulkanMultipleFramebuffer.cpp create mode 100644 src/Nazara/VulkanRenderer/VulkanRenderPass.cpp create mode 100644 src/Nazara/VulkanRenderer/VulkanSingleFramebuffer.cpp diff --git a/include/Nazara/Renderer/CommandBufferBuilder.hpp b/include/Nazara/Renderer/CommandBufferBuilder.hpp index 5d30a5205..4cc05a66a 100644 --- a/include/Nazara/Renderer/CommandBufferBuilder.hpp +++ b/include/Nazara/Renderer/CommandBufferBuilder.hpp @@ -17,20 +17,27 @@ namespace Nz { + class Framebuffer; + class RenderPass; + class RenderPipeline; class ShaderBinding; class NAZARA_RENDERER_API CommandBufferBuilder { public: + struct ClearValues; + CommandBufferBuilder() = default; CommandBufferBuilder(const CommandBufferBuilder&) = delete; CommandBufferBuilder(CommandBufferBuilder&&) = default; virtual ~CommandBufferBuilder(); virtual void BeginDebugRegion(const std::string_view& regionName, const Nz::Color& color) = 0; + virtual void BeginRenderPass(const Framebuffer& framebuffer, const RenderPass& renderPass, Nz::Recti renderRect, std::initializer_list clearValues) = 0; virtual void BindIndexBuffer(Nz::AbstractBuffer* indexBuffer, UInt64 offset = 0) = 0; - virtual void BindShaderBinding(ShaderBinding& binding) = 0; + virtual void BindPipeline(const RenderPipeline& pipeline) = 0; + virtual void BindShaderBinding(const ShaderBinding& binding) = 0; virtual void BindVertexBuffer(UInt32 binding, Nz::AbstractBuffer* vertexBuffer, UInt64 offset = 0) = 0; inline void CopyBuffer(const RenderBufferView& source, const RenderBufferView& target); @@ -42,6 +49,7 @@ namespace Nz virtual void DrawIndexed(UInt32 indexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0) = 0; virtual void EndDebugRegion() = 0; + virtual void EndRenderPass() = 0; virtual void PreTransferBarrier() = 0; virtual void PostTransferBarrier() = 0; @@ -51,6 +59,13 @@ namespace Nz CommandBufferBuilder& operator=(const CommandBufferBuilder&) = delete; CommandBufferBuilder& operator=(CommandBufferBuilder&&) = default; + + struct ClearValues + { + Nz::Color color; + float depth; + UInt32 stencil; + }; }; } diff --git a/include/Nazara/Renderer/Framebuffer.hpp b/include/Nazara/Renderer/Framebuffer.hpp new file mode 100644 index 000000000..2d3ef6623 --- /dev/null +++ b/include/Nazara/Renderer/Framebuffer.hpp @@ -0,0 +1,30 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_FRAMEBUFFER_HPP +#define NAZARA_FRAMEBUFFER_HPP + +#include +#include + +namespace Nz +{ + class NAZARA_RENDERER_API Framebuffer + { + public: + Framebuffer() = default; + Framebuffer(const Framebuffer&) = delete; + Framebuffer(Framebuffer&&) noexcept = default; + virtual ~Framebuffer(); + + Framebuffer& operator=(const Framebuffer&) = delete; + Framebuffer& operator=(Framebuffer&&) noexcept = default; + }; +} + +#include + +#endif // NAZARA_FRAMEBUFFER_HPP diff --git a/include/Nazara/Renderer/Framebuffer.inl b/include/Nazara/Renderer/Framebuffer.inl new file mode 100644 index 000000000..ab61666e6 --- /dev/null +++ b/include/Nazara/Renderer/Framebuffer.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ +} + +#include diff --git a/include/Nazara/Renderer/RenderPass.hpp b/include/Nazara/Renderer/RenderPass.hpp new file mode 100644 index 000000000..10f57ddbe --- /dev/null +++ b/include/Nazara/Renderer/RenderPass.hpp @@ -0,0 +1,40 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_RENDERPASS_HPP +#define NAZARA_RENDERPASS_HPP + +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_RENDERER_API RenderPass + { + public: + struct Attachment; + + RenderPass() = default; + RenderPass(const RenderPass&) = delete; + RenderPass(RenderPass&&) noexcept = default; + virtual ~RenderPass(); + + RenderPass& operator=(const RenderPass&) = delete; + RenderPass& operator=(RenderPass&&) noexcept = default; + + struct Attachment + { + PixelFormat format; + // TODO + }; + }; +} + +#include + +#endif // NAZARA_RENDERPASS_HPP diff --git a/include/Nazara/Renderer/RenderPass.inl b/include/Nazara/Renderer/RenderPass.inl new file mode 100644 index 000000000..c2c3865a3 --- /dev/null +++ b/include/Nazara/Renderer/RenderPass.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ +} + +#include diff --git a/include/Nazara/Renderer/RenderWindowImpl.hpp b/include/Nazara/Renderer/RenderWindowImpl.hpp index 3e0e0bce1..eb6736b74 100644 --- a/include/Nazara/Renderer/RenderWindowImpl.hpp +++ b/include/Nazara/Renderer/RenderWindowImpl.hpp @@ -17,8 +17,10 @@ namespace Nz { class CommandPool; + class Framebuffer; class RendererImpl; class RenderImage; + class RenderPass; class RenderSurface; class NAZARA_RENDERER_API RenderWindowImpl @@ -32,7 +34,9 @@ namespace Nz virtual bool Create(RendererImpl* renderer, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) = 0; virtual std::unique_ptr CreateCommandPool(QueueType queueType) = 0; + virtual const Framebuffer& GetFramebuffer() const = 0; virtual std::shared_ptr GetRenderDevice() = 0; + virtual const RenderPass& GetRenderPass() const = 0; }; } diff --git a/include/Nazara/VulkanRenderer/VkRenderTarget.hpp b/include/Nazara/VulkanRenderer/VkRenderTarget.hpp index e120d1184..81b480cf0 100644 --- a/include/Nazara/VulkanRenderer/VkRenderTarget.hpp +++ b/include/Nazara/VulkanRenderer/VkRenderTarget.hpp @@ -26,22 +26,12 @@ namespace Nz VkRenderTarget(VkRenderTarget&&) = delete; ///TOOD? virtual ~VkRenderTarget(); - virtual const Vk::Framebuffer& GetFrameBuffer(UInt32 imageIndex) const = 0; - virtual UInt32 GetFramebufferCount() const = 0; - - inline const Vk::RenderPass& GetRenderPass() const; - VkRenderTarget& operator=(const VkRenderTarget&) = delete; VkRenderTarget& operator=(VkRenderTarget&&) = delete; ///TOOD? // Signals: NazaraSignal(OnRenderTargetRelease, const VkRenderTarget* /*renderTarget*/); NazaraSignal(OnRenderTargetSizeChange, const VkRenderTarget* /*renderTarget*/); - - protected: - void Destroy(); - - Vk::RenderPass m_renderPass; }; } diff --git a/include/Nazara/VulkanRenderer/VkRenderTarget.inl b/include/Nazara/VulkanRenderer/VkRenderTarget.inl index ffe654e14..12b0b1efd 100644 --- a/include/Nazara/VulkanRenderer/VkRenderTarget.inl +++ b/include/Nazara/VulkanRenderer/VkRenderTarget.inl @@ -7,10 +7,6 @@ namespace Nz { - inline const Vk::RenderPass& VkRenderTarget::GetRenderPass() const - { - return m_renderPass; - } } #include diff --git a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp index ae1771e16..cc71b03ff 100644 --- a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp +++ b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp @@ -16,7 +16,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -27,6 +29,7 @@ #include #include #include +#include #include namespace Nz @@ -44,11 +47,11 @@ namespace Nz bool Create(RendererImpl* renderer, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) override; std::unique_ptr CreateCommandPool(QueueType queueType) override; - inline const Vk::Framebuffer& GetFrameBuffer(UInt32 imageIndex) const override; - inline UInt32 GetFramebufferCount() const override; + inline const VulkanMultipleFramebuffer& GetFramebuffer() const override; inline VulkanDevice& GetDevice(); inline const VulkanDevice& GetDevice() const; inline Vk::QueueHandle& GetGraphicsQueue(); + const VulkanRenderPass& GetRenderPass() const override; inline const Vk::Swapchain& GetSwapchain() const; std::shared_ptr GetRenderDevice() override; @@ -63,19 +66,15 @@ namespace Nz bool SetupRenderPass(); bool SetupSwapchain(const Vk::PhysicalDevice& deviceInfo, Vk::Surface& surface, const Vector2ui& size); - struct ImageData - { - Vk::Framebuffer framebuffer; - Vk::Fence* inFlightFence = nullptr; - }; - std::size_t m_currentFrame; Clock m_clock; VkColorSpaceKHR m_colorSpace; VkFormat m_colorFormat; VkFormat m_depthStencilFormat; + std::optional m_framebuffer; + std::optional m_renderPass; std::shared_ptr m_device; - std::vector m_imageData; + std::vector m_inflightFences; std::vector m_concurrentImageData; Vk::DeviceMemory m_depthBufferMemory; Vk::Image m_depthBuffer; diff --git a/include/Nazara/VulkanRenderer/VkRenderWindow.inl b/include/Nazara/VulkanRenderer/VkRenderWindow.inl index c3700bf21..dc6cf2206 100644 --- a/include/Nazara/VulkanRenderer/VkRenderWindow.inl +++ b/include/Nazara/VulkanRenderer/VkRenderWindow.inl @@ -7,6 +7,11 @@ namespace Nz { + inline const VulkanMultipleFramebuffer& VkRenderWindow::GetFramebuffer() const + { + return *m_framebuffer; + } + inline VulkanDevice& VkRenderWindow::GetDevice() { return *m_device; @@ -22,16 +27,6 @@ namespace Nz return m_graphicsQueue; } - inline const Vk::Framebuffer& VkRenderWindow::GetFrameBuffer(UInt32 imageIndex) const - { - return m_imageData[imageIndex].framebuffer; - } - - inline UInt32 VkRenderWindow::GetFramebufferCount() const - { - return static_cast(m_imageData.size()); - } - inline const Vk::Swapchain& VkRenderWindow::GetSwapchain() const { return m_swapchain; @@ -44,11 +39,11 @@ namespace Nz inline void VkRenderWindow::Present(UInt32 imageIndex, VkSemaphore waitSemaphore) { - NazaraAssert(imageIndex < m_imageData.size(), "Invalid image index"); + NazaraAssert(imageIndex < m_inflightFences.size(), "Invalid image index"); m_presentQueue.Present(m_swapchain, imageIndex, waitSemaphore); - m_currentFrame = (m_currentFrame + 1) % m_imageData.size(); + m_currentFrame = (m_currentFrame + 1) % m_inflightFences.size(); } } diff --git a/include/Nazara/VulkanRenderer/VulkanCommandBuffer.hpp b/include/Nazara/VulkanRenderer/VulkanCommandBuffer.hpp index 608dda616..61607b865 100644 --- a/include/Nazara/VulkanRenderer/VulkanCommandBuffer.hpp +++ b/include/Nazara/VulkanRenderer/VulkanCommandBuffer.hpp @@ -11,6 +11,7 @@ #include #include #include +#include namespace Nz { @@ -18,17 +19,18 @@ namespace Nz { public: inline VulkanCommandBuffer(Vk::AutoCommandBuffer commandBuffer); + inline VulkanCommandBuffer(std::vector commandBuffers); VulkanCommandBuffer(const VulkanCommandBuffer&) = delete; VulkanCommandBuffer(VulkanCommandBuffer&&) noexcept = default; ~VulkanCommandBuffer() = default; - inline Vk::CommandBuffer& GetCommandBuffer(); + inline Vk::CommandBuffer& GetCommandBuffer(std::size_t imageIndex = 0); VulkanCommandBuffer& operator=(const VulkanCommandBuffer&) = delete; VulkanCommandBuffer& operator=(VulkanCommandBuffer&&) = delete; private: - Vk::AutoCommandBuffer m_commandBuffer; + std::vector m_commandBuffers; }; } diff --git a/include/Nazara/VulkanRenderer/VulkanCommandBuffer.inl b/include/Nazara/VulkanRenderer/VulkanCommandBuffer.inl index 23d1b9f58..6e0f8fdf9 100644 --- a/include/Nazara/VulkanRenderer/VulkanCommandBuffer.inl +++ b/include/Nazara/VulkanRenderer/VulkanCommandBuffer.inl @@ -7,14 +7,19 @@ namespace Nz { - inline VulkanCommandBuffer::VulkanCommandBuffer(Vk::AutoCommandBuffer commandBuffer) : - m_commandBuffer(std::move(commandBuffer)) + inline VulkanCommandBuffer::VulkanCommandBuffer(Vk::AutoCommandBuffer commandBuffer) + { + m_commandBuffers.push_back(std::move(commandBuffer)); + } + + inline VulkanCommandBuffer::VulkanCommandBuffer(std::vector commandBuffers) : + m_commandBuffers(std::move(commandBuffers)) { } - inline Vk::CommandBuffer& VulkanCommandBuffer::GetCommandBuffer() + inline Vk::CommandBuffer& VulkanCommandBuffer::GetCommandBuffer(std::size_t imageIndex) { - return m_commandBuffer.Get(); + return m_commandBuffers[imageIndex].Get(); } } diff --git a/include/Nazara/VulkanRenderer/VulkanCommandBufferBuilder.hpp b/include/Nazara/VulkanRenderer/VulkanCommandBufferBuilder.hpp index 66baec47b..7fd23ee13 100644 --- a/include/Nazara/VulkanRenderer/VulkanCommandBufferBuilder.hpp +++ b/include/Nazara/VulkanRenderer/VulkanCommandBufferBuilder.hpp @@ -14,18 +14,22 @@ namespace Nz { + class VulkanRenderPass; + class NAZARA_VULKANRENDERER_API VulkanCommandBufferBuilder final : public CommandBufferBuilder { public: - inline VulkanCommandBufferBuilder(Vk::CommandBuffer& commandBuffer); + inline VulkanCommandBufferBuilder(Vk::CommandBuffer& commandBuffer, std::size_t imageIndex = 0); VulkanCommandBufferBuilder(const VulkanCommandBufferBuilder&) = delete; VulkanCommandBufferBuilder(VulkanCommandBufferBuilder&&) noexcept = default; ~VulkanCommandBufferBuilder() = default; void BeginDebugRegion(const std::string_view& regionName, const Nz::Color& color) override; + void BeginRenderPass(const Framebuffer& framebuffer, const RenderPass& renderPass, Nz::Recti renderRect, std::initializer_list clearValues) override; void BindIndexBuffer(AbstractBuffer* indexBuffer, UInt64 offset = 0) override; - void BindShaderBinding(ShaderBinding& binding) override; + void BindPipeline(const RenderPipeline& pipeline) override; + void BindShaderBinding(const ShaderBinding& binding) override; void BindVertexBuffer(UInt32 binding, Nz::AbstractBuffer* vertexBuffer, UInt64 offset = 0) override; void CopyBuffer(const RenderBufferView& source, const RenderBufferView& target, UInt64 size, UInt64 sourceOffset = 0, UInt64 targetOffset = 0) override; @@ -35,8 +39,10 @@ namespace Nz void DrawIndexed(UInt32 indexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0) override; void EndDebugRegion() override; + void EndRenderPass() override; inline Vk::CommandBuffer& GetCommandBuffer(); + inline std::size_t GetMaxFramebufferCount() const; void PreTransferBarrier() override; void PostTransferBarrier() override; @@ -49,6 +55,9 @@ namespace Nz private: Vk::CommandBuffer& m_commandBuffer; + const VulkanRenderPass* m_currentRenderPass; + std::size_t m_framebufferCount; + std::size_t m_imageIndex; }; } diff --git a/include/Nazara/VulkanRenderer/VulkanCommandBufferBuilder.inl b/include/Nazara/VulkanRenderer/VulkanCommandBufferBuilder.inl index 1d4b865cb..fd5a16870 100644 --- a/include/Nazara/VulkanRenderer/VulkanCommandBufferBuilder.inl +++ b/include/Nazara/VulkanRenderer/VulkanCommandBufferBuilder.inl @@ -7,8 +7,10 @@ namespace Nz { - inline VulkanCommandBufferBuilder::VulkanCommandBufferBuilder(Vk::CommandBuffer& commandBuffer) : - m_commandBuffer(commandBuffer) + inline VulkanCommandBufferBuilder::VulkanCommandBufferBuilder(Vk::CommandBuffer& commandBuffer, std::size_t imageIndex) : + m_commandBuffer(commandBuffer), + m_framebufferCount(0), + m_imageIndex(imageIndex) { } @@ -16,6 +18,11 @@ namespace Nz { return m_commandBuffer; } + + inline std::size_t VulkanCommandBufferBuilder::GetMaxFramebufferCount() const + { + return m_framebufferCount; + } } #include diff --git a/include/Nazara/VulkanRenderer/VulkanFramebuffer.hpp b/include/Nazara/VulkanRenderer/VulkanFramebuffer.hpp new file mode 100644 index 000000000..cbd466406 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanFramebuffer.hpp @@ -0,0 +1,43 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VULKANFRAMEBUFFER_HPP +#define NAZARA_VULKANRENDERER_VULKANFRAMEBUFFER_HPP + +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_VULKANRENDERER_API VulkanFramebuffer : public Framebuffer + { + public: + enum class Type + { + Multiple, + Single + }; + + inline VulkanFramebuffer(Type type); + VulkanFramebuffer(const VulkanFramebuffer&) = delete; + VulkanFramebuffer(VulkanFramebuffer&&) noexcept = default; + ~VulkanFramebuffer() = default; + + inline Type GetType() const; + + VulkanFramebuffer& operator=(const VulkanFramebuffer&) = delete; + VulkanFramebuffer& operator=(VulkanFramebuffer&&) noexcept = default; + + private: + Type m_type; + }; +} + +#include + +#endif // NAZARA_VULKANRENDERER_VULKANFRAMEBUFFER_HPP diff --git a/include/Nazara/VulkanRenderer/VulkanFramebuffer.inl b/include/Nazara/VulkanRenderer/VulkanFramebuffer.inl new file mode 100644 index 000000000..becb3bf39 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanFramebuffer.inl @@ -0,0 +1,21 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline VulkanFramebuffer::VulkanFramebuffer(Type type) : + m_type(type) + { + } + + inline auto VulkanFramebuffer::GetType() const -> Type + { + return m_type; + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/VulkanMultipleFramebuffer.hpp b/include/Nazara/VulkanRenderer/VulkanMultipleFramebuffer.hpp new file mode 100644 index 000000000..c0d01d3e0 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanMultipleFramebuffer.hpp @@ -0,0 +1,36 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VULKANMULTIPLEFRAMEBUFFER_HPP +#define NAZARA_VULKANRENDERER_VULKANMULTIPLEFRAMEBUFFER_HPP + +#include +#include + +namespace Nz +{ + class NAZARA_VULKANRENDERER_API VulkanMultipleFramebuffer final : public VulkanFramebuffer + { + public: + inline VulkanMultipleFramebuffer(Vk::Framebuffer* framebuffers, std::size_t count); + VulkanMultipleFramebuffer(const VulkanMultipleFramebuffer&) = delete; + VulkanMultipleFramebuffer(VulkanMultipleFramebuffer&&) noexcept = default; + ~VulkanMultipleFramebuffer() = default; + + inline const Vk::Framebuffer& GetFramebuffer(std::size_t index) const; + inline std::size_t GetFramebufferCount() const; + + VulkanMultipleFramebuffer& operator=(const VulkanMultipleFramebuffer&) = delete; + VulkanMultipleFramebuffer& operator=(VulkanMultipleFramebuffer&&) noexcept = default; + + private: + std::vector m_framebuffers; + }; +} + +#include + +#endif // NAZARA_VULKANRENDERER_VULKANMULTIPLEFRAMEBUFFER_HPP diff --git a/include/Nazara/VulkanRenderer/VulkanMultipleFramebuffer.inl b/include/Nazara/VulkanRenderer/VulkanMultipleFramebuffer.inl new file mode 100644 index 000000000..6d4d7249f --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanMultipleFramebuffer.inl @@ -0,0 +1,30 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline VulkanMultipleFramebuffer::VulkanMultipleFramebuffer(Vk::Framebuffer* framebuffers, std::size_t count) : + VulkanFramebuffer(Type::Multiple) + { + m_framebuffers.reserve(count); + for (std::size_t i = 0; i < count; ++i) + m_framebuffers.push_back(std::move(framebuffers[i])); + } + + inline const Vk::Framebuffer& Nz::VulkanMultipleFramebuffer::GetFramebuffer(std::size_t index) const + { + assert(index < m_framebuffers.size()); + return m_framebuffers[index]; + } + + inline std::size_t VulkanMultipleFramebuffer::GetFramebufferCount() const + { + return m_framebuffers.size(); + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/VulkanRenderPass.hpp b/include/Nazara/VulkanRenderer/VulkanRenderPass.hpp new file mode 100644 index 000000000..87bc54fa9 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanRenderPass.hpp @@ -0,0 +1,41 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VULKANRENDERPASS_HPP +#define NAZARA_VULKANRENDERER_VULKANRENDERPASS_HPP + +#include +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_VULKANRENDERER_API VulkanRenderPass final : public RenderPass + { + public: + inline VulkanRenderPass(Vk::RenderPass renderPass, std::initializer_list formats); //< FIXME + VulkanRenderPass(const VulkanRenderPass&) = delete; + VulkanRenderPass(VulkanRenderPass&&) noexcept = default; + ~VulkanRenderPass() = default; + + inline PixelFormat GetAttachmentFormat(std::size_t attachmentIndex) const; + inline Vk::RenderPass& GetRenderPass(); + inline const Vk::RenderPass& GetRenderPass() const; + + VulkanRenderPass& operator=(const VulkanRenderPass&) = delete; + VulkanRenderPass& operator=(VulkanRenderPass&&) noexcept = default; + + private: + std::vector m_formats; + Vk::RenderPass m_renderPass; + }; +} + +#include + +#endif // NAZARA_VULKANRENDERER_VULKANRENDERPASS_HPP diff --git a/include/Nazara/VulkanRenderer/VulkanRenderPass.inl b/include/Nazara/VulkanRenderer/VulkanRenderPass.inl new file mode 100644 index 000000000..d21e1a67c --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanRenderPass.inl @@ -0,0 +1,32 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline VulkanRenderPass::VulkanRenderPass(Vk::RenderPass renderPass, std::initializer_list formats) : + m_formats(std::begin(formats), std::end(formats)), + m_renderPass(std::move(renderPass)) + { + } + + inline PixelFormat VulkanRenderPass::GetAttachmentFormat(std::size_t attachmentIndex) const + { + return m_formats[attachmentIndex]; + } + + inline Vk::RenderPass& VulkanRenderPass::GetRenderPass() + { + return m_renderPass; + } + + inline const Vk::RenderPass& VulkanRenderPass::GetRenderPass() const + { + return m_renderPass; + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp b/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp index 6fa836a47..8165d56f0 100644 --- a/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp +++ b/include/Nazara/VulkanRenderer/VulkanRenderPipeline.hpp @@ -26,7 +26,7 @@ namespace Nz VulkanRenderPipeline(Vk::Device& device, RenderPipelineInfo pipelineInfo); ~VulkanRenderPipeline() = default; - VkPipeline Get(const Vk::RenderPass& renderPass); + VkPipeline Get(const Vk::RenderPass& renderPass) const; static std::vector BuildColorBlendAttachmentStateList(const RenderPipelineInfo& pipelineInfo); static VkPipelineColorBlendStateCreateInfo BuildColorBlendInfo(const RenderPipelineInfo& pipelineInfo, const std::vector& attachmentState); @@ -69,7 +69,7 @@ namespace Nz }; private: - std::unordered_map m_pipelines; + mutable std::unordered_map m_pipelines; MovablePtr m_device; CreateInfo m_pipelineCreateInfo; RenderPipelineInfo m_pipelineInfo; diff --git a/include/Nazara/VulkanRenderer/VulkanShaderBinding.hpp b/include/Nazara/VulkanRenderer/VulkanShaderBinding.hpp index 78051b624..72fb993d1 100644 --- a/include/Nazara/VulkanRenderer/VulkanShaderBinding.hpp +++ b/include/Nazara/VulkanRenderer/VulkanShaderBinding.hpp @@ -24,9 +24,9 @@ namespace Nz ~VulkanShaderBinding() = default; inline std::size_t GetBindingIndex() const; - inline Vk::DescriptorSet& GetDescriptorSet(); + inline const Vk::DescriptorSet& GetDescriptorSet() const; inline std::size_t GetPoolIndex() const; - inline VulkanRenderPipelineLayout& GetOwner(); + inline const VulkanRenderPipelineLayout& GetOwner() const; void Update(std::initializer_list bindings) override; diff --git a/include/Nazara/VulkanRenderer/VulkanShaderBinding.inl b/include/Nazara/VulkanRenderer/VulkanShaderBinding.inl index c3b447fcf..e24bf9977 100644 --- a/include/Nazara/VulkanRenderer/VulkanShaderBinding.inl +++ b/include/Nazara/VulkanRenderer/VulkanShaderBinding.inl @@ -25,12 +25,12 @@ namespace Nz return m_poolIndex; } - inline Vk::DescriptorSet& VulkanShaderBinding::GetDescriptorSet() + inline const Vk::DescriptorSet& VulkanShaderBinding::GetDescriptorSet() const { return m_descriptorSet; } - inline VulkanRenderPipelineLayout& VulkanShaderBinding::GetOwner() + inline const VulkanRenderPipelineLayout& VulkanShaderBinding::GetOwner() const { return m_owner; } diff --git a/include/Nazara/VulkanRenderer/VulkanSingleFramebuffer.hpp b/include/Nazara/VulkanRenderer/VulkanSingleFramebuffer.hpp new file mode 100644 index 000000000..c3d7b3d25 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanSingleFramebuffer.hpp @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VULKANSINGLEFRAMEBUFFER_HPP +#define NAZARA_VULKANRENDERER_VULKANSINGLEFRAMEBUFFER_HPP + +#include + +namespace Nz +{ + class NAZARA_VULKANRENDERER_API VulkanSingleFramebuffer final : public VulkanFramebuffer + { + public: + inline VulkanSingleFramebuffer(Vk::Framebuffer renderPass); + VulkanSingleFramebuffer(const VulkanSingleFramebuffer&) = delete; + VulkanSingleFramebuffer(VulkanSingleFramebuffer&&) noexcept = default; + ~VulkanSingleFramebuffer() = default; + + inline Vk::Framebuffer& GetFramebuffer(); + inline const Vk::Framebuffer& GetFramebuffer() const; + + VulkanSingleFramebuffer& operator=(const VulkanSingleFramebuffer&) = delete; + VulkanSingleFramebuffer& operator=(VulkanSingleFramebuffer&&) noexcept = default; + + private: + Vk::Framebuffer m_framebuffer; + }; +} + +#include + +#endif // NAZARA_VULKANRENDERER_VULKANSINGLEFRAMEBUFFER_HPP diff --git a/include/Nazara/VulkanRenderer/VulkanSingleFramebuffer.inl b/include/Nazara/VulkanRenderer/VulkanSingleFramebuffer.inl new file mode 100644 index 000000000..19f5e35c1 --- /dev/null +++ b/include/Nazara/VulkanRenderer/VulkanSingleFramebuffer.inl @@ -0,0 +1,27 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline VulkanSingleFramebuffer::VulkanSingleFramebuffer(Vk::Framebuffer framebuffer) : + VulkanFramebuffer(Type::Single), + m_framebuffer(std::move(framebuffer)) + { + } + + inline Vk::Framebuffer& VulkanSingleFramebuffer::GetFramebuffer() + { + return m_framebuffer; + } + + inline const Vk::Framebuffer& VulkanSingleFramebuffer::GetFramebuffer() const + { + return m_framebuffer; + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp index e16b73c16..812777dbd 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.hpp @@ -38,7 +38,7 @@ namespace Nz void SetDebugName(const std::string& name); DeviceObject& operator=(const DeviceObject&) = delete; - DeviceObject& operator=(DeviceObject&&) = delete; + DeviceObject& operator=(DeviceObject&& object) noexcept; operator VkType() const; diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl index e6728d016..02e2de181 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl @@ -103,6 +103,17 @@ namespace Nz return SetDebugName(name.data()); } + template + auto DeviceObject::operator=(DeviceObject&& object) noexcept -> DeviceObject& + { + std::swap(m_allocator, object.m_allocator); + std::swap(m_device, object.m_device); + std::swap(m_handle, object.m_handle); + std::swap(m_lastErrorCode, object.m_lastErrorCode); + + return *this; + } + template DeviceObject::operator VkType() const { diff --git a/include/Nazara/VulkanRenderer/Wrapper/RenderPass.hpp b/include/Nazara/VulkanRenderer/Wrapper/RenderPass.hpp index c8b93093a..36e492654 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/RenderPass.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/RenderPass.hpp @@ -25,7 +25,7 @@ namespace Nz ~RenderPass() = default; RenderPass& operator=(const RenderPass&) = delete; - RenderPass& operator=(RenderPass&&) = delete; + RenderPass& operator=(RenderPass&&) = default; private: static inline VkResult CreateHelper(Device& device, const VkRenderPassCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkRenderPass* handle); diff --git a/include/NazaraSDK/Components/PhysicsComponent3D.inl b/include/NazaraSDK/Components/PhysicsComponent3D.inl index a5a171a6e..06a082ac9 100644 --- a/include/NazaraSDK/Components/PhysicsComponent3D.inl +++ b/include/NazaraSDK/Components/PhysicsComponent3D.inl @@ -2,8 +2,8 @@ // This file is part of the "Nazara Development Kit" // For conditions of distribution and use, see copyright notice in Prerequisites.hpp +#include #include -#include "PhysicsComponent3D.hpp" namespace Ndk { diff --git a/src/Nazara/Renderer/Framebuffer.cpp b/src/Nazara/Renderer/Framebuffer.cpp new file mode 100644 index 000000000..4fff69eb4 --- /dev/null +++ b/src/Nazara/Renderer/Framebuffer.cpp @@ -0,0 +1,11 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + Framebuffer::~Framebuffer() = default; +} diff --git a/src/Nazara/Renderer/RenderPass.cpp b/src/Nazara/Renderer/RenderPass.cpp new file mode 100644 index 000000000..b6b870c72 --- /dev/null +++ b/src/Nazara/Renderer/RenderPass.cpp @@ -0,0 +1,11 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + RenderPass::~RenderPass() = default; +} diff --git a/src/Nazara/VulkanRenderer/VkRenderTarget.cpp b/src/Nazara/VulkanRenderer/VkRenderTarget.cpp index 69f356d0d..5875d5e45 100644 --- a/src/Nazara/VulkanRenderer/VkRenderTarget.cpp +++ b/src/Nazara/VulkanRenderer/VkRenderTarget.cpp @@ -11,9 +11,4 @@ namespace Nz { OnRenderTargetRelease(this); } - - void VkRenderTarget::Destroy() - { - m_renderPass.Destroy(); - } } diff --git a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp index 3a6d43eee..0553d2a7b 100644 --- a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp +++ b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp @@ -5,6 +5,8 @@ #include #include #include +#include +#include #include #include #include @@ -28,11 +30,9 @@ namespace Nz m_device->WaitForIdle(); m_concurrentImageData.clear(); - m_imageData.clear(); - m_renderPass.Destroy(); + m_renderPass.reset(); + m_framebuffer.reset(); m_swapchain.Destroy(); - - VkRenderTarget::Destroy(); } VulkanRenderImage& VkRenderWindow::Acquire() @@ -47,11 +47,11 @@ namespace Nz if (!m_swapchain.AcquireNextImage(std::numeric_limits::max(), currentFrame.GetImageAvailableSemaphore(), VK_NULL_HANDLE, &imageIndex)) throw std::runtime_error("Failed to acquire next image: " + TranslateVulkanError(m_swapchain.GetLastErrorCode())); - if (m_imageData[imageIndex].inFlightFence) - m_imageData[imageIndex].inFlightFence->Wait(); + if (m_inflightFences[imageIndex]) + m_inflightFences[imageIndex]->Wait(); - m_imageData[imageIndex].inFlightFence = &inFlightFence; - m_imageData[imageIndex].inFlightFence->Reset(); + m_inflightFences[imageIndex] = &inFlightFence; + m_inflightFences[imageIndex]->Reset(); currentFrame.Reset(imageIndex); @@ -164,30 +164,34 @@ namespace Nz UInt32 imageCount = m_swapchain.GetBufferCount(); // Framebuffers - m_imageData.resize(imageCount); + m_inflightFences.resize(imageCount); + + Nz::StackArray framebuffers = NazaraStackArray(Vk::Framebuffer, imageCount); for (UInt32 i = 0; i < imageCount; ++i) { std::array attachments = { m_swapchain.GetBuffer(i).view, m_depthBufferView }; VkFramebufferCreateInfo frameBufferCreate = { - VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, // VkStructureType sType; - nullptr, // const void* pNext; - 0, // VkFramebufferCreateFlags flags; - m_renderPass, // VkRenderPass renderPass; - (attachments[1] != VK_NULL_HANDLE) ? 2U : 1U, // uint32_t attachmentCount; - attachments.data(), // const VkImageView* pAttachments; - size.x, // uint32_t width; - size.y, // uint32_t height; - 1U // uint32_t layers; + VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, + nullptr, + 0, + m_renderPass->GetRenderPass(), + (attachments[1] != VK_NULL_HANDLE) ? 2U : 1U, + attachments.data(), + size.x, + size.y, + 1U }; - if (!m_imageData[i].framebuffer.Create(*m_device, frameBufferCreate)) + if (!framebuffers[i].Create(*m_device, frameBufferCreate)) { - NazaraError("Failed to create framebuffer for image #" + String::Number(i) + ": " + TranslateVulkanError(m_imageData[i].framebuffer.GetLastErrorCode())); + NazaraError("Failed to create framebuffer for image #" + String::Number(i) + ": " + TranslateVulkanError(framebuffers[i].GetLastErrorCode())); return false; } } + m_framebuffer.emplace(framebuffers.data(), framebuffers.size()); + const std::size_t MaxConcurrentImage = imageCount; m_concurrentImageData.reserve(MaxConcurrentImage); @@ -220,6 +224,11 @@ namespace Nz return std::make_unique(*m_device, queueFamilyIndex); } + const VulkanRenderPass& VkRenderWindow::GetRenderPass() const + { + return *m_renderPass; + } + bool VkRenderWindow::SetupDepthBuffer(const Vector2ui& size) { VkImageCreateInfo imageCreateInfo = { @@ -375,7 +384,16 @@ namespace Nz dependencies.data() // const VkSubpassDependency* pDependencies; }; - return m_renderPass.Create(*m_device, createInfo); + Vk::RenderPass renderPass; + if (!renderPass.Create(*m_device, createInfo)) + { + NazaraError("Failed to create render pass: " + TranslateVulkanError(renderPass.GetLastErrorCode())); + return false; + } + + std::initializer_list fixmeplease = { PixelFormat::PixelFormat_RGB8, PixelFormat::PixelFormat_Depth24Stencil8 }; + m_renderPass.emplace(std::move(renderPass), fixmeplease); + return true; } bool VkRenderWindow::SetupSwapchain(const Vk::PhysicalDevice& deviceInfo, Vk::Surface& surface, const Vector2ui& size) diff --git a/src/Nazara/VulkanRenderer/VulkanCommandBufferBuilder.cpp b/src/Nazara/VulkanRenderer/VulkanCommandBufferBuilder.cpp index 1d5063c78..69f839e23 100644 --- a/src/Nazara/VulkanRenderer/VulkanCommandBufferBuilder.cpp +++ b/src/Nazara/VulkanRenderer/VulkanCommandBufferBuilder.cpp @@ -5,7 +5,11 @@ #include #include #include +#include +#include +#include #include +#include #include #include #include @@ -22,6 +26,73 @@ namespace Nz m_commandBuffer.BeginDebugRegion(regionNameEOS.data(), color); } + void VulkanCommandBufferBuilder::BeginRenderPass(const Framebuffer& framebuffer, const RenderPass& renderPass, Nz::Recti renderRect, std::initializer_list clearValues) + { + const VulkanRenderPass& vkRenderPass = static_cast(renderPass); + + const Vk::Framebuffer& vkFramebuffer = [&] () -> const Vk::Framebuffer& + { + const VulkanFramebuffer& vkFramebuffer = static_cast(framebuffer); + switch (vkFramebuffer.GetType()) + { + case VulkanFramebuffer::Type::Multiple: + { + const VulkanMultipleFramebuffer& vkMultipleFramebuffer = static_cast(vkFramebuffer); + m_framebufferCount = std::max(m_framebufferCount, vkMultipleFramebuffer.GetFramebufferCount()); + return vkMultipleFramebuffer.GetFramebuffer(m_imageIndex); + } + + case VulkanFramebuffer::Type::Single: + return static_cast(vkFramebuffer).GetFramebuffer(); + } + + throw std::runtime_error("Unhandled framebuffer type " + std::to_string(UnderlyingCast(vkFramebuffer.GetType()))); + }(); + + VkRect2D renderArea; + renderArea.offset.x = renderRect.x; + renderArea.offset.y = renderRect.y; + renderArea.extent.width = renderRect.width; + renderArea.extent.height = renderRect.height; + + StackArray vkClearValues = NazaraStackArray(VkClearValue, clearValues.size()); + + std::size_t index = 0; + for (const ClearValues& values : clearValues) + { + auto& vkValues = vkClearValues[index]; + + if (PixelFormatInfo::GetContent(vkRenderPass.GetAttachmentFormat(index)) == PixelFormatContent_ColorRGBA) + { + vkValues.color.float32[0] = values.color.r / 255.f; + vkValues.color.float32[1] = values.color.g / 255.f; + vkValues.color.float32[2] = values.color.b / 255.f; + vkValues.color.float32[3] = values.color.a / 255.f; + } + else + { + vkValues.depthStencil.depth = values.depth; + vkValues.depthStencil.stencil = values.stencil; + } + + index++; + } + + VkRenderPassBeginInfo beginInfo = { VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO }; + beginInfo.renderPass = vkRenderPass.GetRenderPass(); + beginInfo.framebuffer = vkFramebuffer; + beginInfo.renderArea.offset.x = renderRect.x; + beginInfo.renderArea.offset.y = renderRect.y; + beginInfo.renderArea.extent.width = renderRect.width; + beginInfo.renderArea.extent.height = renderRect.height; + beginInfo.clearValueCount = vkClearValues.size(); + beginInfo.pClearValues = vkClearValues.data(); + + m_commandBuffer.BeginRenderPass(beginInfo); + + m_currentRenderPass = &vkRenderPass; + } + void VulkanCommandBufferBuilder::BindIndexBuffer(Nz::AbstractBuffer* indexBuffer, UInt64 offset) { VulkanBuffer& vkBuffer = *static_cast(indexBuffer); @@ -29,11 +100,21 @@ namespace Nz m_commandBuffer.BindIndexBuffer(vkBuffer.GetBuffer(), offset, VK_INDEX_TYPE_UINT16); //< Fuck me right? } - void VulkanCommandBufferBuilder::BindShaderBinding(ShaderBinding& binding) + void VulkanCommandBufferBuilder::BindPipeline(const RenderPipeline& pipeline) { - VulkanShaderBinding& vkBinding = static_cast(binding); + if (!m_currentRenderPass) + throw std::runtime_error("BindPipeline must be called in a RenderPass"); - VulkanRenderPipelineLayout& pipelineLayout = vkBinding.GetOwner(); + const VulkanRenderPipeline& vkBinding = static_cast(pipeline); + + m_commandBuffer.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, vkBinding.Get(m_currentRenderPass->GetRenderPass())); + } + + void VulkanCommandBufferBuilder::BindShaderBinding(const ShaderBinding& binding) + { + const VulkanShaderBinding& vkBinding = static_cast(binding); + + const VulkanRenderPipelineLayout& pipelineLayout = vkBinding.GetOwner(); m_commandBuffer.BindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout.GetPipelineLayout(), 0U, vkBinding.GetDescriptorSet()); } @@ -76,6 +157,12 @@ namespace Nz m_commandBuffer.EndDebugRegion(); } + void VulkanCommandBufferBuilder::EndRenderPass() + { + m_commandBuffer.EndRenderPass(); + m_currentRenderPass = nullptr; + } + void VulkanCommandBufferBuilder::PreTransferBarrier() { m_commandBuffer.MemoryBarrier(VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0U, VK_ACCESS_TRANSFER_READ_BIT); diff --git a/src/Nazara/VulkanRenderer/VulkanCommandPool.cpp b/src/Nazara/VulkanRenderer/VulkanCommandPool.cpp index 771acded3..fd514c83e 100644 --- a/src/Nazara/VulkanRenderer/VulkanCommandPool.cpp +++ b/src/Nazara/VulkanRenderer/VulkanCommandPool.cpp @@ -12,17 +12,27 @@ namespace Nz { std::unique_ptr VulkanCommandPool::BuildCommandBuffer(const std::function& callback) { - Vk::AutoCommandBuffer commandBuffer = m_commandPool.AllocateCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY); + std::vector commandBuffers; + auto BuildCommandBuffer = [&](std::size_t imageIndex) + { + Vk::AutoCommandBuffer& commandBuffer = commandBuffers.emplace_back(m_commandPool.AllocateCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY)); - if (!commandBuffer->Begin()) - throw std::runtime_error("failed to begin command buffer: " + TranslateVulkanError(commandBuffer->GetLastErrorCode())); + if (!commandBuffer->Begin(VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT)) + throw std::runtime_error("failed to begin command buffer: " + TranslateVulkanError(commandBuffer->GetLastErrorCode())); - VulkanCommandBufferBuilder builder(commandBuffer.Get()); - callback(builder); + VulkanCommandBufferBuilder builder(commandBuffer.Get(), imageIndex); + callback(builder); - if (!commandBuffer->End()) - throw std::runtime_error("failed to build command buffer: " + TranslateVulkanError(commandBuffer->GetLastErrorCode())); + if (!commandBuffer->End()) + throw std::runtime_error("failed to build command buffer: " + TranslateVulkanError(commandBuffer->GetLastErrorCode())); - return std::make_unique(std::move(commandBuffer)); + return builder.GetMaxFramebufferCount(); + }; + + std::size_t maxFramebufferCount = BuildCommandBuffer(0); + for (std::size_t i = 1; i < maxFramebufferCount; ++i) + BuildCommandBuffer(i); + + return std::make_unique(std::move(commandBuffers)); } } diff --git a/src/Nazara/VulkanRenderer/VulkanFramebuffer.cpp b/src/Nazara/VulkanRenderer/VulkanFramebuffer.cpp new file mode 100644 index 000000000..24ad4e57e --- /dev/null +++ b/src/Nazara/VulkanRenderer/VulkanFramebuffer.cpp @@ -0,0 +1,10 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ +} diff --git a/src/Nazara/VulkanRenderer/VulkanMultipleFramebuffer.cpp b/src/Nazara/VulkanRenderer/VulkanMultipleFramebuffer.cpp new file mode 100644 index 000000000..2129cd1d5 --- /dev/null +++ b/src/Nazara/VulkanRenderer/VulkanMultipleFramebuffer.cpp @@ -0,0 +1,10 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ +} diff --git a/src/Nazara/VulkanRenderer/VulkanRenderImage.cpp b/src/Nazara/VulkanRenderer/VulkanRenderImage.cpp index 67ed19601..a1e8c2db3 100644 --- a/src/Nazara/VulkanRenderer/VulkanRenderImage.cpp +++ b/src/Nazara/VulkanRenderer/VulkanRenderImage.cpp @@ -49,7 +49,7 @@ namespace Nz if (!commandBuffer->Begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT)) throw std::runtime_error("failed to begin command buffer: " + TranslateVulkanError(commandBuffer->GetLastErrorCode())); - VulkanCommandBufferBuilder builder(*commandBuffer); + VulkanCommandBufferBuilder builder(*commandBuffer, m_imageIndex); callback(builder); if (!commandBuffer->End()) @@ -67,7 +67,7 @@ namespace Nz { VulkanCommandBuffer& vkCommandBuffer = *static_cast(commandBuffer); - return SubmitCommandBuffer(vkCommandBuffer.GetCommandBuffer(), queueTypeFlags); + return SubmitCommandBuffer(vkCommandBuffer.GetCommandBuffer(m_imageIndex), queueTypeFlags); } void VulkanRenderImage::SubmitCommandBuffer(VkCommandBuffer commandBuffer, QueueTypeFlags queueTypeFlags) diff --git a/src/Nazara/VulkanRenderer/VulkanRenderPass.cpp b/src/Nazara/VulkanRenderer/VulkanRenderPass.cpp new file mode 100644 index 000000000..e9c406cfc --- /dev/null +++ b/src/Nazara/VulkanRenderer/VulkanRenderPass.cpp @@ -0,0 +1,10 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ +} diff --git a/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp b/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp index d7b790aec..2cf731023 100644 --- a/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp +++ b/src/Nazara/VulkanRenderer/VulkanRenderPipeline.cpp @@ -19,7 +19,7 @@ namespace Nz m_pipelineCreateInfo = BuildCreateInfo(m_pipelineInfo); } - VkPipeline VulkanRenderPipeline::Get(const Vk::RenderPass& renderPass) + VkPipeline VulkanRenderPipeline::Get(const Vk::RenderPass& renderPass) const { if (auto it = m_pipelines.find(renderPass); it != m_pipelines.end()) return it->second; diff --git a/src/Nazara/VulkanRenderer/VulkanSingleFramebuffer.cpp b/src/Nazara/VulkanRenderer/VulkanSingleFramebuffer.cpp new file mode 100644 index 000000000..a8ecb74ad --- /dev/null +++ b/src/Nazara/VulkanRenderer/VulkanSingleFramebuffer.cpp @@ -0,0 +1,10 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ +} From 8eccbe8189e0ed3eeb1149a3f485cdec7463c34c Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 10 Apr 2020 17:36:26 +0200 Subject: [PATCH 145/316] VulkanTest now longer require Vulkan --- examples/VulkanTest/main.cpp | 91 +++++++++++------------------------- 1 file changed, 28 insertions(+), 63 deletions(-) diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index 1e910ec81..8a63435e3 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -39,8 +39,6 @@ int main() return __LINE__; } - Nz::VulkanRenderer* rendererImpl = static_cast(Nz::Renderer::GetRendererImpl()); - Nz::Vk::Instance& instance = Nz::Vulkan::GetInstance(); VkDebugUtilsMessengerCreateInfoEXT callbackCreateInfo = { VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT }; @@ -203,87 +201,56 @@ int main() std::unique_ptr pipeline = device->InstantiateRenderPipeline(pipelineInfo); - std::array clearValues; - clearValues[0].color = {0.0f, 0.0f, 0.0f, 0.0f}; - clearValues[1].depthStencil = {1.f, 0}; + Nz::RenderDevice* renderDevice = window.GetRenderDevice().get(); - Nz::VkRenderWindow& vulkanWindow = *static_cast(window.GetImpl()); - Nz::VulkanDevice& vulkanDevice = vulkanWindow.GetDevice(); - - std::unique_ptr commandPool = vulkanWindow.CreateCommandPool(Nz::QueueType::Graphics); - - Nz::UInt32 imageCount = vulkanWindow.GetFramebufferCount(); - std::vector> renderCmds(imageCount); + Nz::RenderWindowImpl* windowImpl = window.GetImpl(); + std::unique_ptr commandPool = windowImpl->CreateCommandPool(Nz::QueueType::Graphics); Nz::RenderBuffer* renderBufferIB = static_cast(drfreakIB->GetBuffer()->GetImpl()); Nz::RenderBuffer* renderBufferVB = static_cast(drfreakVB->GetBuffer()->GetImpl()); - if (!renderBufferIB->Synchronize(&vulkanDevice)) + if (!renderBufferIB->Synchronize(renderDevice)) { NazaraError("Failed to synchronize render buffer"); return __LINE__; } - if (!renderBufferVB->Synchronize(&vulkanDevice)) + if (!renderBufferVB->Synchronize(renderDevice)) { NazaraError("Failed to synchronize render buffer"); return __LINE__; } - Nz::AbstractBuffer* indexBufferImpl = renderBufferIB->GetHardwareBuffer(&vulkanDevice); - Nz::AbstractBuffer* vertexBufferImpl = renderBufferVB->GetHardwareBuffer(&vulkanDevice); + Nz::AbstractBuffer* indexBufferImpl = renderBufferIB->GetHardwareBuffer(renderDevice); + Nz::AbstractBuffer* vertexBufferImpl = renderBufferVB->GetHardwareBuffer(renderDevice); - Nz::VulkanRenderPipeline* vkPipeline = static_cast(pipeline.get()); - - for (Nz::UInt32 i = 0; i < imageCount; ++i) + std::unique_ptr drawCommandBuffer = commandPool->BuildCommandBuffer([&](Nz::CommandBufferBuilder& builder) { - auto& commandBufferPtr = renderCmds[i]; + Nz::Recti renderRect(0, 0, window.GetSize().x, window.GetSize().y); - VkRect2D renderArea = { - { // VkOffset2D offset - 0, // int32_t x - 0 // int32_t y - }, - { // VkExtent2D extent - windowSize.x, // int32_t width - windowSize.y, // int32_t height - } - }; + Nz::CommandBufferBuilder::ClearValues clearValues[2]; + clearValues[0].color = Nz::Color::Black; + clearValues[1].depth = 1.f; + clearValues[1].stencil = 0; - VkRenderPassBeginInfo render_pass_begin_info = { - VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, // VkStructureType sType - nullptr, // const void *pNext - vulkanWindow.GetRenderPass(), // VkRenderPass renderPass - vulkanWindow.GetFrameBuffer(i), // VkFramebuffer framebuffer - renderArea, - 2U, // uint32_t clearValueCount - clearValues.data() // const VkClearValue *pClearValues - }; - - commandBufferPtr = commandPool->BuildCommandBuffer([&](Nz::CommandBufferBuilder& builder) + builder.BeginDebugRegion("Main window rendering", Nz::Color::Green); { - Nz::Vk::CommandBuffer& vkCommandBuffer = static_cast(builder).GetCommandBuffer(); - - builder.BeginDebugRegion("Main window rendering", Nz::Color::Green); + builder.BeginRenderPass(windowImpl->GetFramebuffer(), windowImpl->GetRenderPass(), renderRect, { clearValues[0], clearValues[1] }); { - vkCommandBuffer.BeginRenderPass(render_pass_begin_info); - { - builder.BindIndexBuffer(indexBufferImpl); - builder.BindVertexBuffer(0, vertexBufferImpl); - builder.BindShaderBinding(*shaderBinding); + builder.BindIndexBuffer(indexBufferImpl); + builder.BindPipeline(*pipeline); + builder.BindVertexBuffer(0, vertexBufferImpl); + builder.BindShaderBinding(*shaderBinding); - builder.SetScissor(Nz::Recti{ 0, 0, int(windowSize.x), int(windowSize.y) }); - builder.SetViewport(Nz::Recti{ 0, 0, int(windowSize.x), int(windowSize.y) }); + builder.SetScissor(Nz::Recti{ 0, 0, int(windowSize.x), int(windowSize.y) }); + builder.SetViewport(Nz::Recti{ 0, 0, int(windowSize.x), int(windowSize.y) }); - vkCommandBuffer.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, vkPipeline->Get(vulkanWindow.GetRenderPass())); //< TODO - - builder.DrawIndexed(drfreakIB->GetIndexCount()); - } - vkCommandBuffer.EndRenderPass(); + builder.DrawIndexed(drfreakIB->GetIndexCount()); } - builder.EndDebugRegion(); - }); - } + builder.EndRenderPass(); + } + builder.EndDebugRegion(); + }); Nz::Vector3f viewerPos = Nz::Vector3f::Zero(); @@ -357,7 +324,7 @@ int main() viewerPos += Nz::Vector3f::Down() * cameraSpeed; } - Nz::VulkanRenderImage& renderImage = vulkanWindow.Acquire(); + Nz::RenderImage& renderImage = windowImpl->Acquire(); ubo.viewMatrix = Nz::Matrix4f::ViewMatrix(viewerPos, camAngles); @@ -376,9 +343,7 @@ int main() builder.EndDebugRegion(); }, Nz::QueueType::Transfer); - Nz::UInt32 imageIndex = renderImage.GetImageIndex(); - - renderImage.SubmitCommandBuffer(renderCmds[imageIndex].get(), Nz::QueueType::Graphics); + renderImage.SubmitCommandBuffer(drawCommandBuffer.get(), Nz::QueueType::Graphics); renderImage.Present(); From b2d3605cf4276e7d45e9024b9af6fac56bb8dad5 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 10 Apr 2020 17:36:43 +0200 Subject: [PATCH 146/316] Fix includes --- include/Nazara/Core/ObjectRef.inl | 2 +- include/Nazara/Math/EulerAngles.inl | 2 +- include/Nazara/Math/Quaternion.inl | 2 +- include/Nazara/Network/ENetPeer.inl | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/Nazara/Core/ObjectRef.inl b/include/Nazara/Core/ObjectRef.inl index f6ec6c44f..d7fa3da3d 100644 --- a/include/Nazara/Core/ObjectRef.inl +++ b/include/Nazara/Core/ObjectRef.inl @@ -2,6 +2,7 @@ // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp +#include #include #include @@ -558,4 +559,3 @@ namespace std } #include -#include "ObjectRef.hpp" diff --git a/include/Nazara/Math/EulerAngles.inl b/include/Nazara/Math/EulerAngles.inl index 7a0dac44f..210407646 100644 --- a/include/Nazara/Math/EulerAngles.inl +++ b/include/Nazara/Math/EulerAngles.inl @@ -2,6 +2,7 @@ // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp +#include #include #include #include @@ -406,4 +407,3 @@ std::ostream& operator<<(std::ostream& out, const Nz::EulerAngles& angles) #undef F #include -#include "EulerAngles.hpp" diff --git a/include/Nazara/Math/Quaternion.inl b/include/Nazara/Math/Quaternion.inl index 6d8937566..7da2c4635 100644 --- a/include/Nazara/Math/Quaternion.inl +++ b/include/Nazara/Math/Quaternion.inl @@ -2,6 +2,7 @@ // This file is part of the "Nazara Engine - Mathematics module" // For conditions of distribution and use, see copyright notice in Config.hpp +#include #include #include #include @@ -896,4 +897,3 @@ std::ostream& operator<<(std::ostream& out, const Nz::Quaternion& quat) #undef F #include -#include "Quaternion.hpp" diff --git a/include/Nazara/Network/ENetPeer.inl b/include/Nazara/Network/ENetPeer.inl index cc27d77f4..3078d4f7c 100644 --- a/include/Nazara/Network/ENetPeer.inl +++ b/include/Nazara/Network/ENetPeer.inl @@ -2,6 +2,7 @@ // This file is part of the "Nazara Engine - Network module" // For conditions of distribution and use, see copyright notice in Config.hpp +#include #include namespace Nz @@ -119,4 +120,3 @@ namespace Nz } #include -#include "ENetPeer.hpp" From f1811df6f6e9c284225f973692e97b052ae77760 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 10 Apr 2020 17:36:52 +0200 Subject: [PATCH 147/316] Add lighting in VulkanTest --- examples/bin/resources/shaders/triangle.frag | 10 +++++++--- .../bin/resources/shaders/triangle.frag.spv | Bin 728 -> 1296 bytes examples/bin/resources/shaders/triangle.vert | 6 +++--- .../bin/resources/shaders/triangle.vert.spv | Bin 1636 -> 1640 bytes 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/examples/bin/resources/shaders/triangle.frag b/examples/bin/resources/shaders/triangle.frag index 58a4eff89..f2ddf7dec 100644 --- a/examples/bin/resources/shaders/triangle.frag +++ b/examples/bin/resources/shaders/triangle.frag @@ -5,12 +5,16 @@ layout(binding = 1) uniform sampler2D texSampler; -layout (location = 0) in vec3 inColor; -layout (location = 1) in vec2 outTexCoords; +layout (location = 0) in vec3 inNormal; +layout (location = 1) in vec2 inUV; layout (location = 0) out vec4 outFragColor; void main() { - outFragColor = texture(texSampler, outTexCoords); + vec3 lightDir = vec3(0.0, -0.707, 0.707); + float lightFactor = dot(inNormal, lightDir); + + float gamma = 2.2; + outFragColor = lightFactor * vec4(pow(texture(texSampler, inUV).xyz, vec3(1.0/gamma)), 1.0); } diff --git a/examples/bin/resources/shaders/triangle.frag.spv b/examples/bin/resources/shaders/triangle.frag.spv index c163dc05af340d2d8646f3c6862a0e40c6286fe1..31ec5000f7bdb18687d5c03d343ffa25591f85d6 100644 GIT binary patch literal 1296 zcmY+CNpBND5QQtTCnUs#gg`DT5`HXQAwT6eyXr+GuCW{&-Y%0!)V}Amqp?5 z&>ci+*#Gb`YG=d$HA*GDIPADyeB|ONY~0@*xb`Ot)M@>vUm;H_kb3U-k@>%qG-*pF_ zNGx;k-lX^T9h#;v{n2s2^cu&+)NsgyYcloxaaGx}^z0bS zzf%>SmWRXEg~^?iaXg+?{O7pw!{f>bZ*53T-60DxW@(N?Qp*D zlH%XLD$kg6SuwNlzfpf)o|)mP2eT`<75$s5^62R|emq{4@}d&x=y$0Q!O;)w_s;!Q zVfwL8^fmd3JRa%6>>kd~e?zg^m#v5Tr>SFh4m1806UcKHJLmiJyI@y*d*hgI4E$8p zXxZ@-)xw>Tu{)0!6{Go{e~o5m6{CTtp5Ac8^kvV~^1cf)@?dsxMaCY$Rrxg;?|iS` z?Eabz4g4Fugn6#Z;4uz6;r;%On~J&jYcby~#q0`xM^n(_whZ1|MJ)Us8U2`(d(iC` xebyC|=Xh>Iv9Iym-GXDL9d+d$bs6>O$urNl;*Iwdljlx$#&-sHtVtfp{sG3ATeAQF literal 728 zcmY+ATT22_6opUfm}PnCqC^l{?;>FlL_rDp;!_4a4ksNZOJ`(e1b<(@s+XYkjY@W8 zyJxMv_BETi*fwTMzk;co<*S;EurWoGPkpaH=(plz)aqQdQIt$J6{0CCFDH*p?KmK? zBdf}4vWm3C)I?udRW{~Ji8-lyefQz{(T%;Cjcnq%@w**)ksH2!c*7+AuTf|m`0m68 z{@nVW+qrDd?C{e#suEJAIYO<9`wiZ#Ng3`xdGg@E=*l^7QegSG%J3#;d diff --git a/examples/bin/resources/shaders/triangle.vert b/examples/bin/resources/shaders/triangle.vert index 8884074ee..b967590b8 100644 --- a/examples/bin/resources/shaders/triangle.vert +++ b/examples/bin/resources/shaders/triangle.vert @@ -4,7 +4,7 @@ #extension GL_ARB_shading_language_420pack : enable layout (location = 0) in vec3 inPos; -layout (location = 1) in vec3 inColor; +layout (location = 1) in vec3 inNormals; layout (location = 2) in vec2 inTexCoord; layout (binding = 0) uniform UBO @@ -14,7 +14,7 @@ layout (binding = 0) uniform UBO mat4 viewMatrix; } ubo; -layout (location = 0) out vec3 outColor; +layout (location = 0) out vec3 outNormal; layout (location = 1) out vec2 outTexCoords; out gl_PerVertex @@ -25,7 +25,7 @@ out gl_PerVertex void main() { - outColor = inColor; + outNormal = inNormals; outTexCoords = inTexCoord; gl_Position = ubo.projectionMatrix * ubo.viewMatrix * ubo.modelMatrix * vec4(inPos, 1.0); } diff --git a/examples/bin/resources/shaders/triangle.vert.spv b/examples/bin/resources/shaders/triangle.vert.spv index d7f5cd1ff8e97ffa881649cefba3b6ba81a09d00..a9b99027fe2cd62c93903fe9b86116b313870e56 100644 GIT binary patch delta 39 ncmaFD^MYr>Z5hA(qTIwB1_lOJAmj$pnRyVQVg`ndp9@(5^T!Lf delta 35 kcmaFC^Mq%@Z3*Z6octmNAYf%+Vc-VRnR#HLjo%Ad0l)JKZvX%Q From 75241ed8f086a912303bf33750fd41be8aba4c7f Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 13 Apr 2020 15:11:35 +0200 Subject: [PATCH 148/316] VkRenderWindow: Default to RGBA8 if supported --- .../Nazara/VulkanRenderer/VkRenderWindow.hpp | 3 +- src/Nazara/VulkanRenderer/VkRenderWindow.cpp | 29 ++++++++++++++----- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp index cc71b03ff..25fe36edc 100644 --- a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp +++ b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp @@ -68,9 +68,8 @@ namespace Nz std::size_t m_currentFrame; Clock m_clock; - VkColorSpaceKHR m_colorSpace; - VkFormat m_colorFormat; VkFormat m_depthStencilFormat; + VkSurfaceFormatKHR m_surfaceFormat; std::optional m_framebuffer; std::optional m_renderPass; std::shared_ptr m_device; diff --git a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp index 0553d2a7b..6f53df0c1 100644 --- a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp +++ b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp @@ -85,12 +85,25 @@ namespace Nz return false; } - if (surfaceFormats.size() == 1 && surfaceFormats[0].format == VK_FORMAT_UNDEFINED) - m_colorFormat = VK_FORMAT_B8G8R8A8_UNORM; - else - m_colorFormat = surfaceFormats[0].format; + m_surfaceFormat = [&] () -> VkSurfaceFormatKHR + { + if (surfaceFormats.size() == 1 && surfaceFormats.front().format == VK_FORMAT_UNDEFINED) + { + // If the list contains one undefined format, it means any format can be used + return { VK_FORMAT_R8G8B8A8_UNORM, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR }; + } + else + { + // Search for RGBA8 and default to first format + for (const VkSurfaceFormatKHR& surfaceFormat : surfaceFormats) + { + if (surfaceFormat.format == VK_FORMAT_R8G8B8A8_UNORM) + return surfaceFormat; + } - m_colorSpace = surfaceFormats[0].colorSpace; + return surfaceFormats.front(); + } + }(); if (!parameters.depthFormats.empty()) { @@ -305,7 +318,7 @@ namespace Nz { { 0, // VkAttachmentDescriptionFlags flags; - m_colorFormat, // VkFormat format; + m_surfaceFormat.format, // VkFormat format; VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples; VK_ATTACHMENT_LOAD_OP_CLEAR, // VkAttachmentLoadOp loadOp; VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp; @@ -444,8 +457,8 @@ namespace Nz 0, surface, imageCount, - m_colorFormat, - m_colorSpace, + m_surfaceFormat.format, + m_surfaceFormat.colorSpace, extent, 1, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, From 7447875753bc53ec39fe76b611195979f3948614 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 13 Apr 2020 15:12:19 +0200 Subject: [PATCH 149/316] Vulkan/Surface: Remove MIR support --- .../VulkanRenderer/Wrapper/Instance.hpp | 4 +- .../VulkanRenderer/Wrapper/Instance.inl | 4 +- .../Wrapper/InstanceFunctions.hpp | 7 -- .../Nazara/VulkanRenderer/Wrapper/Surface.hpp | 13 +-- .../Nazara/VulkanRenderer/Wrapper/Surface.inl | 94 +++++++------------ 5 files changed, 40 insertions(+), 82 deletions(-) diff --git a/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp b/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp index 3d3e86df8..64a70a7fd 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp @@ -45,8 +45,8 @@ namespace Nz inline VkPhysicalDeviceProperties GetPhysicalDeviceProperties(VkPhysicalDevice device); bool GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice device, std::vector* queueFamilyProperties); - inline bool IsExtensionLoaded(const std::string& extensionName); - inline bool IsLayerLoaded(const std::string& layerName); + inline bool IsExtensionLoaded(const std::string& extensionName) const; + inline bool IsLayerLoaded(const std::string& layerName) const; inline bool IsValid() const; Instance& operator=(const Instance&) = delete; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Instance.inl b/include/Nazara/VulkanRenderer/Wrapper/Instance.inl index 64224d746..a9a027d7f 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Instance.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Instance.inl @@ -78,12 +78,12 @@ namespace Nz return m_lastErrorCode; } - inline bool Instance::IsExtensionLoaded(const std::string& extensionName) + inline bool Instance::IsExtensionLoaded(const std::string& extensionName) const { return m_loadedExtensions.count(extensionName) > 0; } - inline bool Instance::IsLayerLoaded(const std::string& layerName) + inline bool Instance::IsLayerLoaded(const std::string& layerName) const { return m_loadedLayers.count(layerName) > 0; } diff --git a/include/Nazara/VulkanRenderer/Wrapper/InstanceFunctions.hpp b/include/Nazara/VulkanRenderer/Wrapper/InstanceFunctions.hpp index ec258bbc3..d25dc48b7 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/InstanceFunctions.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/InstanceFunctions.hpp @@ -55,13 +55,6 @@ NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(VK_KHR_android_surface) NAZARA_VULKANRENDERER_INSTANCE_EXT_END() #endif -#ifdef VK_USE_PLATFORM_MIR_KHR -NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(VK_KHR_mir_surface) - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateMirSurfaceKHR) - NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkGetPhysicalDeviceMirPresentationSupportKHR) -NAZARA_VULKANRENDERER_INSTANCE_EXT_END() -#endif - #ifdef VK_USE_PLATFORM_XCB_KHR NAZARA_VULKANRENDERER_INSTANCE_EXT_BEGIN(VK_KHR_xcb_surface) NAZARA_VULKANRENDERER_INSTANCE_FUNCTION(vkCreateXcbSurfaceKHR) diff --git a/include/Nazara/VulkanRenderer/Wrapper/Surface.hpp b/include/Nazara/VulkanRenderer/Wrapper/Surface.hpp index f49b207cb..70bdf42ee 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Surface.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Surface.hpp @@ -10,14 +10,13 @@ #include #include #include +#include #include namespace Nz { namespace Vk { - class Instance; - class Surface { public: @@ -32,12 +31,6 @@ namespace Nz 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); @@ -69,8 +62,6 @@ namespace Nz bool GetPresentModes(VkPhysicalDevice physicalDevice, std::vector* presentModes) const; bool GetSupportPresentation(VkPhysicalDevice physicalDevice, UInt32 queueFamilyIndex, bool* supported) const; - inline bool IsSupported() const; - inline VkResult GetLastErrorCode() const; Surface& operator=(const Surface&) = delete; @@ -78,6 +69,8 @@ namespace Nz inline operator VkSurfaceKHR() const; + static inline bool IsSupported(const Instance& instance); + private: inline bool Create(const VkAllocationCallbacks* allocator); diff --git a/include/Nazara/VulkanRenderer/Wrapper/Surface.inl b/include/Nazara/VulkanRenderer/Wrapper/Surface.inl index 43101eb4c..bdac5685b 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Surface.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Surface.inl @@ -5,7 +5,6 @@ #include #include #include -#include #include namespace Nz @@ -53,28 +52,6 @@ namespace Nz } #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) { @@ -250,49 +227,44 @@ namespace Nz 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() const { return m_surface; } + inline bool Surface::IsSupported(const Instance& instance) + { + if (!instance.IsExtensionLoaded(VK_KHR_SURFACE_EXTENSION_NAME)) + return false; + +#ifdef VK_USE_PLATFORM_ANDROID_KHR + if (instance.IsExtensionLoaded(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME)) + return true; +#endif + +#ifdef VK_USE_PLATFORM_XCB_KHR + if (instance.IsExtensionLoaded(VK_KHR_XCB_SURFACE_EXTENSION_NAME)) + return true; +#endif + +#ifdef VK_USE_PLATFORM_XLIB_KHR + if (instance.IsExtensionLoaded(VK_KHR_XLIB_SURFACE_EXTENSION_NAME)) + return true; +#endif + +#ifdef VK_USE_PLATFORM_WAYLAND_KHR + if (instance.IsExtensionLoaded(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME)) + return true; +#endif + +#ifdef VK_USE_PLATFORM_WIN32_KHR + if (instance.IsExtensionLoaded(VK_KHR_WIN32_SURFACE_EXTENSION_NAME)) + return true; +#endif + + return false; + } + inline bool Surface::Create(const VkAllocationCallbacks* allocator) { if (m_lastErrorCode != VkResult::VK_SUCCESS) From e905c3a0047432546798f56b578f29e4ffbcc5ea Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 13 Apr 2020 15:12:58 +0200 Subject: [PATCH 150/316] Move Vulkan debug callback to module --- examples/VulkanTest/main.cpp | 51 --------- .../Wrapper/DebugUtilsMessengerEXT.hpp | 41 +++++++ .../Wrapper/DebugUtilsMessengerEXT.inl | 29 +++++ .../Nazara/VulkanRenderer/Wrapper/Device.hpp | 10 +- .../VulkanRenderer/Wrapper/DeviceObject.inl | 2 - .../VulkanRenderer/Wrapper/Instance.hpp | 15 ++- .../VulkanRenderer/Wrapper/Instance.inl | 19 ---- .../VulkanRenderer/Wrapper/InstanceObject.hpp | 53 +++++++++ .../VulkanRenderer/Wrapper/InstanceObject.inl | 103 ++++++++++++++++++ src/Nazara/VulkanRenderer/Vulkan.cpp | 35 ++++-- .../VulkanRenderer/Wrapper/Instance.cpp | 103 +++++++++++++++++- 11 files changed, 366 insertions(+), 95 deletions(-) create mode 100644 include/Nazara/VulkanRenderer/Wrapper/DebugUtilsMessengerEXT.hpp create mode 100644 include/Nazara/VulkanRenderer/Wrapper/DebugUtilsMessengerEXT.inl create mode 100644 include/Nazara/VulkanRenderer/Wrapper/InstanceObject.hpp create mode 100644 include/Nazara/VulkanRenderer/Wrapper/InstanceObject.inl diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index 8a63435e3..fb42fa9aa 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -6,32 +6,8 @@ #include #include -VKAPI_ATTR VkBool32 VKAPI_CALL MyDebugReportCallback( - VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, - VkDebugUtilsMessageTypeFlagsEXT messageTypes, - const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, - void* pUserData) -{ - if (pCallbackData->messageIdNumber != 0) - std::cerr << "#" << pCallbackData->messageIdNumber << " " << pCallbackData->messageIdNumber << ": "; - - std::cerr << pCallbackData->pMessage << std::endl; - return VK_FALSE; -} - int main() { - Nz::ParameterList params; - params.SetParameter("VkInstanceInfo_EnabledExtensionCount", 1LL); - params.SetParameter("VkInstanceInfo_EnabledExtension0", "VK_EXT_debug_report"); - - params.SetParameter("VkDeviceInfo_EnabledLayerCount", 1LL); - params.SetParameter("VkDeviceInfo_EnabledLayer0", "VK_LAYER_LUNARG_standard_validation"); - params.SetParameter("VkInstanceInfo_EnabledLayerCount", 1LL); - params.SetParameter("VkInstanceInfo_EnabledLayer0", "VK_LAYER_LUNARG_standard_validation"); - - Nz::Renderer::SetParameters(params); - Nz::Initializer loader; if (!loader) { @@ -39,31 +15,6 @@ int main() return __LINE__; } - Nz::Vk::Instance& instance = Nz::Vulkan::GetInstance(); - - VkDebugUtilsMessengerCreateInfoEXT callbackCreateInfo = { VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT }; - callbackCreateInfo.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT; - callbackCreateInfo.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT; - callbackCreateInfo.pfnUserCallback = &MyDebugReportCallback; - - /* Register the callback */ - VkDebugUtilsMessengerEXT callback; - - instance.vkCreateDebugUtilsMessengerEXT(instance, &callbackCreateInfo, nullptr, &callback); - - - std::vector layerProperties; - if (!Nz::Vk::Loader::EnumerateInstanceLayerProperties(&layerProperties)) - { - NazaraError("Failed to enumerate instance layer properties"); - return __LINE__; - } - - for (const VkLayerProperties& properties : layerProperties) - { - std::cout << properties.layerName << ": \t" << properties.description << std::endl; - } - Nz::RenderWindow window; Nz::MeshParams meshParams; @@ -370,7 +321,5 @@ int main() } } - instance.vkDestroyDebugUtilsMessengerEXT(instance, callback, nullptr); - return EXIT_SUCCESS; } diff --git a/include/Nazara/VulkanRenderer/Wrapper/DebugUtilsMessengerEXT.hpp b/include/Nazara/VulkanRenderer/Wrapper/DebugUtilsMessengerEXT.hpp new file mode 100644 index 000000000..2a3f6fd97 --- /dev/null +++ b/include/Nazara/VulkanRenderer/Wrapper/DebugUtilsMessengerEXT.hpp @@ -0,0 +1,41 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VKDEBUGUTILSMESSENGEREXT_HPP +#define NAZARA_VULKANRENDERER_VKDEBUGUTILSMESSENGEREXT_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class DebugUtilsMessengerEXT : public InstanceObject + { + friend InstanceObject; + + public: + DebugUtilsMessengerEXT() = default; + DebugUtilsMessengerEXT(const DebugUtilsMessengerEXT&) = delete; + DebugUtilsMessengerEXT(DebugUtilsMessengerEXT&&) = default; + ~DebugUtilsMessengerEXT() = default; + + DebugUtilsMessengerEXT& operator=(const DebugUtilsMessengerEXT&) = delete; + DebugUtilsMessengerEXT& operator=(DebugUtilsMessengerEXT&&) = delete; + + static inline bool IsSupported(Instance& instance); + + private: + static inline VkResult CreateHelper(Instance& instance, const VkDebugUtilsMessengerCreateInfoEXT* createInfo, const VkAllocationCallbacks* allocator, VkDebugUtilsMessengerEXT* handle); + static inline void DestroyHelper(Instance& instance, VkDebugUtilsMessengerEXT handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_VULKANRENDERER_VKDEBUGUTILSMESSENGEREXT_HPP diff --git a/include/Nazara/VulkanRenderer/Wrapper/DebugUtilsMessengerEXT.inl b/include/Nazara/VulkanRenderer/Wrapper/DebugUtilsMessengerEXT.inl new file mode 100644 index 000000000..68d656676 --- /dev/null +++ b/include/Nazara/VulkanRenderer/Wrapper/DebugUtilsMessengerEXT.inl @@ -0,0 +1,29 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + namespace Vk + { + inline bool DebugUtilsMessengerEXT::IsSupported(Instance& instance) + { + return instance.vkCreateDebugUtilsMessengerEXT != nullptr; + } + + inline VkResult DebugUtilsMessengerEXT::CreateHelper(Instance& instance, const VkDebugUtilsMessengerCreateInfoEXT* createInfo, const VkAllocationCallbacks* allocator, VkDebugUtilsMessengerEXT* handle) + { + return instance.vkCreateDebugUtilsMessengerEXT(instance, createInfo, allocator, handle); + } + + inline void DebugUtilsMessengerEXT::DestroyHelper(Instance& instance, VkDebugUtilsMessengerEXT handle, const VkAllocationCallbacks* allocator) + { + return instance.vkDestroyDebugUtilsMessengerEXT(instance, handle, allocator); + } + } +} + +#include diff --git a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp index 2f3ded74f..0dadcdfed 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Device.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Device.hpp @@ -115,17 +115,17 @@ namespace Nz static constexpr std::size_t QueueCount = static_cast(QueueType::Max) + 1; std::unique_ptr m_internalData; + std::array m_defaultQueues; + std::unordered_set m_loadedExtensions; + std::unordered_set m_loadedLayers; + std::vector m_enabledQueuesInfos; + std::vector m_queuesByFamily; Instance& m_instance; const Vk::PhysicalDevice* m_physicalDevice; VkAllocationCallbacks m_allocator; VkDevice m_device; VkResult m_lastErrorCode; VmaAllocator m_memAllocator; - std::array m_defaultQueues; - std::unordered_set m_loadedExtensions; - std::unordered_set m_loadedLayers; - std::vector m_enabledQueuesInfos; - std::vector m_queuesByFamily; }; } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl index 02e2de181..8f80a8e8f 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl @@ -5,8 +5,6 @@ #include #include #include -#include -#include #include namespace Nz diff --git a/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp b/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp index 64a70a7fd..2b17e0ffa 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Instance.hpp @@ -21,10 +21,10 @@ namespace Nz class NAZARA_VULKANRENDERER_API Instance { public: - inline Instance(); + Instance(); Instance(const Instance&) = delete; Instance(Instance&&) = delete; - inline ~Instance(); + ~Instance(); bool Create(const VkInstanceCreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); inline bool Create(const std::string& appName, UInt32 appVersion, const std::string& engineName, UInt32 engineVersion, const std::vector& layers, const std::vector& extensions, const VkAllocationCallbacks* allocator = nullptr); @@ -45,6 +45,8 @@ namespace Nz inline VkPhysicalDeviceProperties GetPhysicalDeviceProperties(VkPhysicalDevice device); bool GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice device, std::vector* queueFamilyProperties); + void InstallDebugMessageCallback(); + inline bool IsExtensionLoaded(const std::string& extensionName) const; inline bool IsLayerLoaded(const std::string& layerName) const; inline bool IsValid() const; @@ -68,17 +70,20 @@ namespace Nz #undef NAZARA_VULKANRENDERER_INSTANCE_FUNCTION private: - inline void DestroyInstance(); + void DestroyInstance(); void ResetPointers(); inline PFN_vkVoidFunction GetProcAddr(const char* name); + struct InternalData; + + std::unique_ptr m_internalData; + std::unordered_set m_loadedExtensions; + std::unordered_set m_loadedLayers; VkAllocationCallbacks m_allocator; VkInstance m_instance; VkResult m_lastErrorCode; UInt32 m_apiVersion; - std::unordered_set m_loadedExtensions; - std::unordered_set m_loadedLayers; }; } } diff --git a/include/Nazara/VulkanRenderer/Wrapper/Instance.inl b/include/Nazara/VulkanRenderer/Wrapper/Instance.inl index a9a027d7f..0a2e6d0b5 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Instance.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/Instance.inl @@ -12,17 +12,6 @@ namespace Nz { namespace Vk { - inline Instance::Instance() : - m_instance(nullptr) - { - } - - inline Instance::~Instance() - { - if (m_instance) - DestroyInstance(); - } - inline bool Instance::Create(const std::string& appName, UInt32 appVersion, const std::string& engineName, UInt32 engineVersion, const std::vector& layers, const std::vector& extensions, const VkAllocationCallbacks* allocator) { VkApplicationInfo appInfo = @@ -142,14 +131,6 @@ namespace Nz return properties; } - inline void Instance::DestroyInstance() - { - assert(m_instance != VK_NULL_HANDLE); - - if (vkDestroyInstance) - vkDestroyInstance(m_instance, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); - } - inline PFN_vkVoidFunction Instance::GetProcAddr(const char* name) { PFN_vkVoidFunction func = Loader::GetInstanceProcAddr(m_instance, name); diff --git a/include/Nazara/VulkanRenderer/Wrapper/InstanceObject.hpp b/include/Nazara/VulkanRenderer/Wrapper/InstanceObject.hpp new file mode 100644 index 000000000..f1b9d431c --- /dev/null +++ b/include/Nazara/VulkanRenderer/Wrapper/InstanceObject.hpp @@ -0,0 +1,53 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_VULKANRENDERER_VKINSTANCEOBJECT_HPP +#define NAZARA_VULKANRENDERER_VKINSTANCEOBJECT_HPP + +#include +#include +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + template + class InstanceObject + { + public: + InstanceObject(); + InstanceObject(const InstanceObject&) = delete; + InstanceObject(InstanceObject&& object) noexcept; + ~InstanceObject(); + + bool Create(Instance& instance, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); + void Destroy(); + + bool IsValid() const; + + Instance* GetInstance() const; + VkResult GetLastErrorCode() const; + + InstanceObject& operator=(const InstanceObject&) = delete; + InstanceObject& operator=(InstanceObject&& object) noexcept; + + operator VkType() const; + + protected: + MovablePtr m_instance; + VkAllocationCallbacks m_allocator; + VkType m_handle; + mutable VkResult m_lastErrorCode; + }; + } +} + +#include + +#endif // NAZARA_VULKANRENDERER_VKINSTANCEOBJECT_HPP diff --git a/include/Nazara/VulkanRenderer/Wrapper/InstanceObject.inl b/include/Nazara/VulkanRenderer/Wrapper/InstanceObject.inl new file mode 100644 index 000000000..586867564 --- /dev/null +++ b/include/Nazara/VulkanRenderer/Wrapper/InstanceObject.inl @@ -0,0 +1,103 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Vulkan Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + template + InstanceObject::InstanceObject() : + m_handle(VK_NULL_HANDLE) + { + } + + template + InstanceObject::InstanceObject(InstanceObject&& object) noexcept : + m_instance(std::move(object.m_instance)), + m_allocator(object.m_allocator), + m_handle(object.m_handle), + m_lastErrorCode(object.m_lastErrorCode) + { + object.m_handle = VK_NULL_HANDLE; + } + + template + InstanceObject::~InstanceObject() + { + Destroy(); + } + + template + bool InstanceObject::Create(Instance& instance, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator) + { + m_instance = &instance; + m_lastErrorCode = C::CreateHelper(*m_instance, &createInfo, allocator, &m_handle); + if (m_lastErrorCode != VkResult::VK_SUCCESS) + { + NazaraError("Failed to create Vulkan object: " + TranslateVulkanError(m_lastErrorCode)); + return false; + } + + // Store the allocator to access them when needed + if (allocator) + m_allocator = *allocator; + else + m_allocator.pfnAllocation = nullptr; + + return true; + } + + template + void InstanceObject::Destroy() + { + if (IsValid()) + { + C::DestroyHelper(*m_instance, m_handle, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); + m_handle = VK_NULL_HANDLE; + } + } + + template + bool InstanceObject::IsValid() const + { + return m_handle != VK_NULL_HANDLE; + } + + template + Instance* InstanceObject::GetInstance() const + { + return m_instance; + } + + template + VkResult InstanceObject::GetLastErrorCode() const + { + return m_lastErrorCode; + } + + template + auto InstanceObject::operator=(InstanceObject&& object) noexcept -> InstanceObject& + { + std::swap(m_allocator, object.m_allocator); + std::swap(m_instance, object.m_instance); + std::swap(m_handle, object.m_handle); + std::swap(m_lastErrorCode, object.m_lastErrorCode); + + return *this; + } + + template + InstanceObject::operator VkType() const + { + return m_handle; + } + } +} + +#include diff --git a/src/Nazara/VulkanRenderer/Vulkan.cpp b/src/Nazara/VulkanRenderer/Vulkan.cpp index fd1e8ca9e..4f55223e1 100644 --- a/src/Nazara/VulkanRenderer/Vulkan.cpp +++ b/src/Nazara/VulkanRenderer/Vulkan.cpp @@ -102,13 +102,28 @@ namespace Nz createFlags = static_cast(iParam); std::vector enabledLayers; - std::vector enabledExtensions; + + // Get supported layer list + std::unordered_set availableLayers; + std::vector layerList; + if (Vk::Loader::EnumerateInstanceLayerProperties(&layerList)) + { + for (VkLayerProperties& extProperty : layerList) + availableLayers.insert(extProperty.layerName); + } if (!parameters.GetBooleanParameter("VkInstanceInfo_OverrideEnabledLayers", &bParam) || !bParam) { //< Nazara default layers goes here + +#ifdef NAZARA_DEBUG + // Enable Vulkan validation if available in debug mode + if (availableLayers.count("VK_LAYER_LUNARG_standard_validation")) + enabledLayers.push_back("VK_LAYER_LUNARG_standard_validation"); +#endif } + std::vector enabledExtensions; std::vector additionalLayers; // Just to keep the String alive if (parameters.GetIntegerParameter("VkInstanceInfo_EnabledLayerCount", &iParam)) { @@ -127,7 +142,7 @@ namespace Nz } } - // Get extension list + // Get supported extension list std::unordered_set availableExtensions; std::vector extensionList; if (Vk::Loader::EnumerateInstanceExtensionProperties(&extensionList)) @@ -138,30 +153,26 @@ namespace Nz if (!parameters.GetBooleanParameter("VkInstanceInfo_OverrideEnabledExtensions", &bParam) || !bParam) { - enabledExtensions.push_back("VK_KHR_surface"); + enabledExtensions.push_back(VK_KHR_SURFACE_EXTENSION_NAME); #ifdef VK_USE_PLATFORM_ANDROID_KHR - enabledExtensions.push_back("VK_KHR_android_surface"); - #endif - - #ifdef VK_USE_PLATFORM_MIR_KHR - enabledExtensions.push_back("VK_KHR_mir_surface"); + enabledExtensions.push_back(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME); #endif #ifdef VK_USE_PLATFORM_XCB_KHR - enabledExtensions.push_back("VK_KHR_xcb_surface"); + enabledExtensions.push_back(VK_KHR_XCB_SURFACE_EXTENSION_NAME); #endif #ifdef VK_USE_PLATFORM_XLIB_KHR - enabledExtensions.push_back("VK_KHR_xlib_surface"); + enabledExtensions.push_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME); #endif #ifdef VK_USE_PLATFORM_WAYLAND_KHR - enabledExtensions.push_back("VK_KHR_wayland_surface"); + enabledExtensions.push_back(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME); #endif #ifdef VK_USE_PLATFORM_WIN32_KHR - enabledExtensions.push_back("VK_KHR_win32_surface"); + enabledExtensions.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME); #endif if (availableExtensions.count(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME)) diff --git a/src/Nazara/VulkanRenderer/Wrapper/Instance.cpp b/src/Nazara/VulkanRenderer/Wrapper/Instance.cpp index 8d88817a4..f30416e34 100644 --- a/src/Nazara/VulkanRenderer/Wrapper/Instance.cpp +++ b/src/Nazara/VulkanRenderer/Wrapper/Instance.cpp @@ -5,19 +5,85 @@ #include #include #include +#include +#include #include +#include #include namespace Nz { namespace Vk { + namespace + { + VKAPI_ATTR VkBool32 VKAPI_CALL DebugCallback( + VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, + VkDebugUtilsMessageTypeFlagsEXT messageTypes, + const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, + void* /*pUserData*/) + { + std::stringstream ss; + ss << "Vulkan log: "; + + if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT) + ss << "[Verbose]"; + + if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT) + ss << "[Info]"; + + if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) + ss << "[Warning]"; + + if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) + ss << "[Error]"; + + + if (messageTypes & VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT) + ss << "[General]"; + + if (messageTypes & VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT) + ss << "[Performance]"; + + if (messageTypes & VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT) + ss << "[Validation]"; + + + ss << "[" << pCallbackData->messageIdNumber << ":" << pCallbackData->pMessageIdName << "]: " << pCallbackData->pMessage; + + if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) + NazaraError(ss.str()); + else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) + NazaraWarning(ss.str()); + else + NazaraNotice(ss.str()); + + return VK_FALSE; //< Should the Vulkan call be aborted + } + } + + struct Instance::InternalData + { + DebugUtilsMessengerEXT debugMessenger; + }; + + Instance::Instance() : + m_instance(nullptr) + { + } + + Instance::~Instance() + { + if (m_instance) + DestroyInstance(); + } + 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"); + NazaraError("Failed to create Vulkan instance: " + TranslateVulkanError(m_lastErrorCode)); return false; } @@ -64,6 +130,9 @@ namespace Nz return false; } + m_internalData = std::make_unique(); + InstallDebugMessageCallback(); + return true; } @@ -140,6 +209,38 @@ namespace Nz return true; } + void Instance::InstallDebugMessageCallback() + { + NazaraAssert(m_internalData, "Instance must be created before callbacks are installed"); + + if (!Vk::DebugUtilsMessengerEXT::IsSupported(*this)) + { + NazaraWarning(VK_EXT_DEBUG_UTILS_EXTENSION_NAME " is not supported, cannot install debug message callback"); + return; + } + + VkDebugUtilsMessengerCreateInfoEXT callbackCreateInfo = { VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT }; + callbackCreateInfo.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT; + callbackCreateInfo.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT; + callbackCreateInfo.pfnUserCallback = &DebugCallback; + + if (!m_internalData->debugMessenger.Create(*this, callbackCreateInfo)) + { + NazaraWarning("failed to install debug message callback"); + return; + } + } + + void Instance::DestroyInstance() + { + assert(m_instance != VK_NULL_HANDLE); + + m_internalData.reset(); + + if (vkDestroyInstance) + vkDestroyInstance(m_instance, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); + } + void Instance::ResetPointers() { assert(m_instance != VK_NULL_HANDLE); From a82c393a05b48496fe62be6ca16a0551f6dfe53d Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 13 Apr 2020 15:13:15 +0200 Subject: [PATCH 151/316] Don't link VulkanTest with VulkanRenderer --- examples/VulkanTest/build.lua | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/examples/VulkanTest/build.lua b/examples/VulkanTest/build.lua index 3137d0f43..d56114640 100644 --- a/examples/VulkanTest/build.lua +++ b/examples/VulkanTest/build.lua @@ -2,12 +2,6 @@ EXAMPLE.Name = "VulkanTest" EXAMPLE.EnableConsole = true -EXAMPLE.OsDefines.Windows = { - "VK_USE_PLATFORM_WIN32_KHR", - "WIN32_LEAN_AND_MEAN", - "NOMINMAX" -} - EXAMPLE.Files = { "main.cpp" } @@ -15,6 +9,6 @@ EXAMPLE.Files = { EXAMPLE.Libraries = { "NazaraCore", "NazaraPlatform", - "NazaraVulkanRenderer", + "NazaraRenderer", "NazaraUtility" } From dd74e5ecc1c8e5bdb972e92ae65da48f8f4e7984 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 13 Apr 2020 16:29:15 +0200 Subject: [PATCH 152/316] Includes fix --- examples/VulkanTest/main.cpp | 5 +---- include/Nazara/Renderer.hpp | 2 ++ include/Nazara/VulkanRenderer.hpp | 4 ++++ include/Nazara/VulkanRenderer/Wrapper.hpp | 2 ++ 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index fb42fa9aa..fdabfd539 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -1,8 +1,5 @@ #include -#include -#include -#include -#include +#include #include #include diff --git a/include/Nazara/Renderer.hpp b/include/Nazara/Renderer.hpp index 9ab23b09c..fad7760fc 100644 --- a/include/Nazara/Renderer.hpp +++ b/include/Nazara/Renderer.hpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -43,6 +44,7 @@ #include #include #include +#include #include #include #include diff --git a/include/Nazara/VulkanRenderer.hpp b/include/Nazara/VulkanRenderer.hpp index ea1ffc4b9..7b52637fc 100644 --- a/include/Nazara/VulkanRenderer.hpp +++ b/include/Nazara/VulkanRenderer.hpp @@ -39,12 +39,16 @@ #include #include #include +#include +#include #include #include +#include #include #include #include #include +#include #include #include #include diff --git a/include/Nazara/VulkanRenderer/Wrapper.hpp b/include/Nazara/VulkanRenderer/Wrapper.hpp index 846542a50..df6896383 100644 --- a/include/Nazara/VulkanRenderer/Wrapper.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper.hpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -20,6 +21,7 @@ #include #include #include +#include #include #include #include From b58b35c322aac378f1c168deccbb178f9099fd07 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 15 Apr 2020 19:37:41 +0200 Subject: [PATCH 153/316] Core: Add SplitString(Ext) --- include/Nazara/Core/StringExt.hpp | 3 +++ include/Nazara/Core/StringExt.inl | 34 +++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/include/Nazara/Core/StringExt.hpp b/include/Nazara/Core/StringExt.hpp index c07f796c0..c4b314fb8 100644 --- a/include/Nazara/Core/StringExt.hpp +++ b/include/Nazara/Core/StringExt.hpp @@ -37,6 +37,9 @@ namespace Nz NAZARA_CORE_API bool StartsWith(const std::string_view& str, const std::string_view& s, CaseIndependent); NAZARA_CORE_API bool StartsWith(const std::string_view& str, const std::string_view& s, CaseIndependent, UnicodeAware); + template bool SplitString(const std::string_view& str, const std::string_view& token, F&& func); + template bool SplitStringAny(const std::string_view& str, const std::string_view& token, F&& func); + inline std::string ToLower(const char* str); NAZARA_CORE_API std::string ToLower(const std::string_view& str); diff --git a/include/Nazara/Core/StringExt.inl b/include/Nazara/Core/StringExt.inl index 72ce07a60..71a04ebff 100644 --- a/include/Nazara/Core/StringExt.inl +++ b/include/Nazara/Core/StringExt.inl @@ -46,6 +46,40 @@ namespace Nz #endif } + template + bool SplitString(const std::string_view& str, const std::string_view& token, F&& func) + { + std::size_t pos = 0; + std::size_t previousPos = 0; + while ((pos = str.find(token, previousPos)) != std::string::npos) + { + std::size_t splitPos = previousPos; + previousPos = pos + token.size(); + + if (!func(str.substr(splitPos, pos - splitPos))) + return false; + } + + return func(str.substr(previousPos)); + } + + template + bool SplitStringAny(const std::string_view& str, const std::string_view& token, F&& func) + { + std::size_t pos = 0; + std::size_t previousPos = 0; + while ((pos = str.find_first_of(token, previousPos)) != std::string::npos) + { + std::size_t splitPos = previousPos; + previousPos = pos + 1; + + if (!func(str.substr(splitPos, pos - splitPos))) + return false; + } + + return func(str.substr(previousPos)); + } + inline std::string ToLower(const char* str) { std::size_t size = std::strlen(str); From ebb271a0896f92189b18485d28c7ebacf3718a60 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 15 Apr 2020 19:38:01 +0200 Subject: [PATCH 154/316] Renderer: Fix crash when choosing another renderer --- src/Nazara/Renderer/Renderer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Renderer/Renderer.cpp b/src/Nazara/Renderer/Renderer.cpp index 541dc4b6e..5de4b2835 100644 --- a/src/Nazara/Renderer/Renderer.cpp +++ b/src/Nazara/Renderer/Renderer.cpp @@ -94,8 +94,8 @@ namespace Nz if (chosenImpl) NazaraDebug("Choose " + impl->QueryAPIString() + " over " + chosenImpl->QueryAPIString()); + chosenImpl = std::move(impl); //< Move (and delete previous) implementation before unloading library chosenLib = std::move(implLib); - chosenImpl = std::move(impl); } } From 68760209c1e367d66c8dd7786febdaf5e098122b Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 15 Apr 2020 19:38:11 +0200 Subject: [PATCH 155/316] Add OpenGLRenderer (WIP) --- build/scripts/tools/openglrenderer.lua | 36 + include/Nazara/OpenGLRenderer/Config.hpp | 53 + include/Nazara/OpenGLRenderer/ConfigCheck.hpp | 22 + include/Nazara/OpenGLRenderer/Debug.hpp | 8 + include/Nazara/OpenGLRenderer/DebugOff.hpp | 9 + include/Nazara/OpenGLRenderer/OpenGL.hpp | 35 + .../Nazara/OpenGLRenderer/OpenGLBuffer.hpp | 57 + .../Nazara/OpenGLRenderer/OpenGLBuffer.inl | 22 + .../OpenGLRenderer/OpenGLCommandBuffer.hpp | 39 + .../OpenGLRenderer/OpenGLCommandBuffer.inl | 26 + .../OpenGLCommandBufferBuilder.hpp | 66 + .../OpenGLCommandBufferBuilder.inl | 28 + .../OpenGLRenderer/OpenGLCommandPool.hpp | 38 + .../OpenGLRenderer/OpenGLCommandPool.inl | 28 + .../Nazara/OpenGLRenderer/OpenGLDevice.hpp | 41 + .../Nazara/OpenGLRenderer/OpenGLDevice.inl | 12 + .../OpenGLRenderer/OpenGLFramebuffer.hpp | 43 + .../OpenGLRenderer/OpenGLFramebuffer.inl | 21 + .../OpenGLRenderer/OpenGLRenderImage.hpp | 65 + .../OpenGLRenderer/OpenGLRenderImage.inl | 39 + .../OpenGLRenderer/OpenGLRenderPass.hpp | 41 + .../OpenGLRenderer/OpenGLRenderPass.inl | 32 + .../OpenGLRenderer/OpenGLRenderPipeline.hpp | 81 + .../OpenGLRenderer/OpenGLRenderPipeline.inl | 12 + .../OpenGLRenderPipelineLayout.hpp | 70 + .../OpenGLRenderPipelineLayout.inl | 41 + .../OpenGLRenderer/OpenGLRenderWindow.hpp | 90 + .../OpenGLRenderer/OpenGLRenderWindow.inl | 50 + .../Nazara/OpenGLRenderer/OpenGLRenderer.hpp | 42 + .../Nazara/OpenGLRenderer/OpenGLRenderer.inl | 12 + .../OpenGLRenderer/OpenGLShaderBinding.hpp | 48 + .../OpenGLRenderer/OpenGLShaderBinding.inl | 39 + .../OpenGLRenderer/OpenGLShaderStage.hpp | 42 + .../OpenGLRenderer/OpenGLShaderStage.inl | 21 + .../Nazara/OpenGLRenderer/OpenGLSurface.hpp | 40 + .../Nazara/OpenGLRenderer/OpenGLSurface.inl | 16 + .../Nazara/OpenGLRenderer/OpenGLTexture.hpp | 51 + .../Nazara/OpenGLRenderer/OpenGLTexture.inl | 21 + .../OpenGLRenderer/OpenGLTextureSampler.hpp | 36 + .../OpenGLRenderer/OpenGLTextureSampler.inl | 16 + .../OpenGLRenderer/OpenGLUploadPool.hpp | 58 + .../OpenGLRenderer/OpenGLUploadPool.inl | 17 + include/Nazara/OpenGLRenderer/Utils.hpp | 39 + include/Nazara/OpenGLRenderer/Utils.inl | 218 + include/Nazara/OpenGLRenderer/Wrapper.hpp | 38 + include/Nazara/OpenGLRenderer/Wrapper/.hpp | 39 + include/Nazara/OpenGLRenderer/Wrapper/.inl | 12 + .../Nazara/OpenGLRenderer/Wrapper/Buffer.hpp | 46 + .../Nazara/OpenGLRenderer/Wrapper/Buffer.inl | 62 + .../Nazara/OpenGLRenderer/Wrapper/Context.hpp | 34 + .../Nazara/OpenGLRenderer/Wrapper/Context.inl | 12 + .../OpenGLRenderer/Wrapper/ContextObject.hpp | 56 + .../OpenGLRenderer/Wrapper/ContextObject.inl | 123 + .../OpenGLRenderer/Wrapper/CoreFunctions.hpp | 140 + .../OpenGLRenderer/Wrapper/Framebuffer.hpp | 39 + .../OpenGLRenderer/Wrapper/Framebuffer.inl | 24 + .../OpenGLRenderer/Wrapper/GLContext.hpp | 52 + .../OpenGLRenderer/Wrapper/GLContext.inl | 12 + .../Nazara/OpenGLRenderer/Wrapper/Loader.hpp | 34 + .../Nazara/OpenGLRenderer/Wrapper/Loader.inl | 12 + .../Wrapper/ProgramPipeline.hpp | 43 + .../Wrapper/ProgramPipeline.inl | 47 + .../OpenGLRenderer/Wrapper/RenderBuffer.hpp | 47 + .../OpenGLRenderer/Wrapper/RenderBuffer.inl | 68 + .../Nazara/OpenGLRenderer/Wrapper/Sampler.hpp | 39 + .../Nazara/OpenGLRenderer/Wrapper/Sampler.inl | 24 + .../Nazara/OpenGLRenderer/Wrapper/Shader.hpp | 42 + .../Nazara/OpenGLRenderer/Wrapper/Shader.inl | 38 + .../Nazara/OpenGLRenderer/Wrapper/Texture.hpp | 43 + .../Nazara/OpenGLRenderer/Wrapper/Texture.inl | 44 + .../OpenGLRenderer/Wrapper/VertexArray.hpp | 39 + .../OpenGLRenderer/Wrapper/VertexArray.inl | 24 + .../Wrapper/Win32/WGLContext.hpp | 71 + .../Wrapper/Win32/WGLContext.inl | 12 + .../Wrapper/Win32/WGLFunctions.hpp | 48 + .../Wrapper/Win32/WGLLoader.hpp | 49 + .../Wrapper/Win32/WGLLoader.inl | 12 + .../Wrapper/Win32/Win32Helper.hpp | 26 + .../OpenGLRenderer/Debug/NewOverload.cpp | 31 + src/Nazara/OpenGLRenderer/Export.cpp | 15 + src/Nazara/OpenGLRenderer/OpenGL.cpp | 72 + src/Nazara/OpenGLRenderer/OpenGLBuffer.cpp | 151 + .../OpenGLRenderer/OpenGLCommandBuffer.cpp | 14 + .../OpenGLCommandBufferBuilder.cpp | 189 + .../OpenGLRenderer/OpenGLCommandPool.cpp | 42 + src/Nazara/OpenGLRenderer/OpenGLDevice.cpp | 64 + .../OpenGLRenderer/OpenGLFramebuffer.cpp | 14 + .../OpenGLRenderer/OpenGLRenderImage.cpp | 97 + .../OpenGLRenderer/OpenGLRenderPass.cpp | 14 + .../OpenGLRenderer/OpenGLRenderPipeline.cpp | 274 ++ .../OpenGLRenderPipelineLayout.cpp | 140 + .../OpenGLRenderer/OpenGLRenderWindow.cpp | 486 ++ src/Nazara/OpenGLRenderer/OpenGLRenderer.cpp | 79 + .../OpenGLRenderer/OpenGLShaderBinding.cpp | 79 + .../OpenGLRenderer/OpenGLShaderStage.cpp | 31 + src/Nazara/OpenGLRenderer/OpenGLSurface.cpp | 49 + src/Nazara/OpenGLRenderer/OpenGLTexture.cpp | 291 ++ .../OpenGLRenderer/OpenGLTextureSampler.cpp | 35 + .../OpenGLRenderer/OpenGLUploadPool.cpp | 91 + .../OpenGLRenderer/Utils_OpenGLRenderer.cpp | 106 + src/Nazara/OpenGLRenderer/Wrapper/Context.cpp | 10 + .../OpenGLRenderer/Wrapper/GLContext.cpp | 44 + src/Nazara/OpenGLRenderer/Wrapper/Loader.cpp | 11 + .../Wrapper/Win32/WGLContext.cpp | 278 ++ .../Wrapper/Win32/WGLLoader.cpp | 70 + src/Nazara/Renderer/Win32/ContextImpl.hpp | 41 - thirdparty/include/EGL/egl.h | 361 ++ thirdparty/include/EGL/eglext.h | 1409 ++++++ thirdparty/include/EGL/eglplatform.h | 182 + thirdparty/include/GL/glcorearb.h | 3091 ++++++++++++- thirdparty/include/GL/glext.h | 1943 +++++++- thirdparty/include/GL/glxext.h | 108 +- thirdparty/include/GL/wgl.h | 955 ++++ thirdparty/include/GL/wglext.h | 61 +- thirdparty/include/GLES2/gl2ext.h | 3911 +++++++++++++++++ thirdparty/include/GLES3/gl3.h | 1211 +++++ thirdparty/include/GLES3/gl3platform.h | 38 + thirdparty/include/KHR/khrplatform.h | 290 ++ 118 files changed, 19236 insertions(+), 414 deletions(-) create mode 100644 build/scripts/tools/openglrenderer.lua create mode 100644 include/Nazara/OpenGLRenderer/Config.hpp create mode 100644 include/Nazara/OpenGLRenderer/ConfigCheck.hpp create mode 100644 include/Nazara/OpenGLRenderer/Debug.hpp create mode 100644 include/Nazara/OpenGLRenderer/DebugOff.hpp create mode 100644 include/Nazara/OpenGLRenderer/OpenGL.hpp create mode 100644 include/Nazara/OpenGLRenderer/OpenGLBuffer.hpp create mode 100644 include/Nazara/OpenGLRenderer/OpenGLBuffer.inl create mode 100644 include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.hpp create mode 100644 include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.inl create mode 100644 include/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.hpp create mode 100644 include/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.inl create mode 100644 include/Nazara/OpenGLRenderer/OpenGLCommandPool.hpp create mode 100644 include/Nazara/OpenGLRenderer/OpenGLCommandPool.inl create mode 100644 include/Nazara/OpenGLRenderer/OpenGLDevice.hpp create mode 100644 include/Nazara/OpenGLRenderer/OpenGLDevice.inl create mode 100644 include/Nazara/OpenGLRenderer/OpenGLFramebuffer.hpp create mode 100644 include/Nazara/OpenGLRenderer/OpenGLFramebuffer.inl create mode 100644 include/Nazara/OpenGLRenderer/OpenGLRenderImage.hpp create mode 100644 include/Nazara/OpenGLRenderer/OpenGLRenderImage.inl create mode 100644 include/Nazara/OpenGLRenderer/OpenGLRenderPass.hpp create mode 100644 include/Nazara/OpenGLRenderer/OpenGLRenderPass.inl create mode 100644 include/Nazara/OpenGLRenderer/OpenGLRenderPipeline.hpp create mode 100644 include/Nazara/OpenGLRenderer/OpenGLRenderPipeline.inl create mode 100644 include/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.hpp create mode 100644 include/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.inl create mode 100644 include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp create mode 100644 include/Nazara/OpenGLRenderer/OpenGLRenderWindow.inl create mode 100644 include/Nazara/OpenGLRenderer/OpenGLRenderer.hpp create mode 100644 include/Nazara/OpenGLRenderer/OpenGLRenderer.inl create mode 100644 include/Nazara/OpenGLRenderer/OpenGLShaderBinding.hpp create mode 100644 include/Nazara/OpenGLRenderer/OpenGLShaderBinding.inl create mode 100644 include/Nazara/OpenGLRenderer/OpenGLShaderStage.hpp create mode 100644 include/Nazara/OpenGLRenderer/OpenGLShaderStage.inl create mode 100644 include/Nazara/OpenGLRenderer/OpenGLSurface.hpp create mode 100644 include/Nazara/OpenGLRenderer/OpenGLSurface.inl create mode 100644 include/Nazara/OpenGLRenderer/OpenGLTexture.hpp create mode 100644 include/Nazara/OpenGLRenderer/OpenGLTexture.inl create mode 100644 include/Nazara/OpenGLRenderer/OpenGLTextureSampler.hpp create mode 100644 include/Nazara/OpenGLRenderer/OpenGLTextureSampler.inl create mode 100644 include/Nazara/OpenGLRenderer/OpenGLUploadPool.hpp create mode 100644 include/Nazara/OpenGLRenderer/OpenGLUploadPool.inl create mode 100644 include/Nazara/OpenGLRenderer/Utils.hpp create mode 100644 include/Nazara/OpenGLRenderer/Utils.inl create mode 100644 include/Nazara/OpenGLRenderer/Wrapper.hpp create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/.hpp create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/.inl create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/Buffer.hpp create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/Buffer.inl create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/Context.hpp create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/Context.inl create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/ContextObject.hpp create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/ContextObject.inl create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/Framebuffer.hpp create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/Framebuffer.inl create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/GLContext.hpp create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/GLContext.inl create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/Loader.hpp create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/Loader.inl create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/ProgramPipeline.hpp create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/ProgramPipeline.inl create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/RenderBuffer.hpp create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/RenderBuffer.inl create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/Sampler.hpp create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/Sampler.inl create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/Shader.hpp create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/Shader.inl create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/Texture.hpp create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/Texture.inl create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/VertexArray.hpp create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/VertexArray.inl create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.hpp create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.inl create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLFunctions.hpp create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.hpp create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.inl create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/Win32/Win32Helper.hpp create mode 100644 src/Nazara/OpenGLRenderer/Debug/NewOverload.cpp create mode 100644 src/Nazara/OpenGLRenderer/Export.cpp create mode 100644 src/Nazara/OpenGLRenderer/OpenGL.cpp create mode 100644 src/Nazara/OpenGLRenderer/OpenGLBuffer.cpp create mode 100644 src/Nazara/OpenGLRenderer/OpenGLCommandBuffer.cpp create mode 100644 src/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.cpp create mode 100644 src/Nazara/OpenGLRenderer/OpenGLCommandPool.cpp create mode 100644 src/Nazara/OpenGLRenderer/OpenGLDevice.cpp create mode 100644 src/Nazara/OpenGLRenderer/OpenGLFramebuffer.cpp create mode 100644 src/Nazara/OpenGLRenderer/OpenGLRenderImage.cpp create mode 100644 src/Nazara/OpenGLRenderer/OpenGLRenderPass.cpp create mode 100644 src/Nazara/OpenGLRenderer/OpenGLRenderPipeline.cpp create mode 100644 src/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.cpp create mode 100644 src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp create mode 100644 src/Nazara/OpenGLRenderer/OpenGLRenderer.cpp create mode 100644 src/Nazara/OpenGLRenderer/OpenGLShaderBinding.cpp create mode 100644 src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp create mode 100644 src/Nazara/OpenGLRenderer/OpenGLSurface.cpp create mode 100644 src/Nazara/OpenGLRenderer/OpenGLTexture.cpp create mode 100644 src/Nazara/OpenGLRenderer/OpenGLTextureSampler.cpp create mode 100644 src/Nazara/OpenGLRenderer/OpenGLUploadPool.cpp create mode 100644 src/Nazara/OpenGLRenderer/Utils_OpenGLRenderer.cpp create mode 100644 src/Nazara/OpenGLRenderer/Wrapper/Context.cpp create mode 100644 src/Nazara/OpenGLRenderer/Wrapper/GLContext.cpp create mode 100644 src/Nazara/OpenGLRenderer/Wrapper/Loader.cpp create mode 100644 src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp create mode 100644 src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.cpp delete mode 100644 src/Nazara/Renderer/Win32/ContextImpl.hpp create mode 100644 thirdparty/include/EGL/egl.h create mode 100644 thirdparty/include/EGL/eglext.h create mode 100644 thirdparty/include/EGL/eglplatform.h create mode 100644 thirdparty/include/GL/wgl.h create mode 100644 thirdparty/include/GLES2/gl2ext.h create mode 100644 thirdparty/include/GLES3/gl3.h create mode 100644 thirdparty/include/GLES3/gl3platform.h create mode 100644 thirdparty/include/KHR/khrplatform.h diff --git a/build/scripts/tools/openglrenderer.lua b/build/scripts/tools/openglrenderer.lua new file mode 100644 index 000000000..32392739c --- /dev/null +++ b/build/scripts/tools/openglrenderer.lua @@ -0,0 +1,36 @@ +TOOL.Name = "OpenGLRenderer" + +TOOL.ClientOnly = true + +TOOL.Kind = "Library" +TOOL.TargetDirectory = "../lib" + +TOOL.Defines = { + "NAZARA_BUILD", + "NAZARA_OPENGLRENDERER_BUILD" +} + +TOOL.Includes = { + "../include", + "../src/", + "../extlibs/include" +} + +TOOL.Files = { + "../include/Nazara/OpenGLRenderer/**.hpp", + "../include/Nazara/OpenGLRenderer/**.inl", + "../src/Nazara/OpenGLRenderer/**.hpp", + "../src/Nazara/OpenGLRenderer/**.inl", + "../src/Nazara/OpenGLRenderer/**.cpp" +} + +TOOL.Libraries = { + "NazaraCore", + "NazaraRenderer", + "NazaraUtility" +} + +TOOL.OsFiles.Windows = { + "../src/Nazara/OpenGLRenderer/Win32/**.hpp", + "../src/Nazara/OpenGLRenderer/Win32/**.cpp" +} diff --git a/include/Nazara/OpenGLRenderer/Config.hpp b/include/Nazara/OpenGLRenderer/Config.hpp new file mode 100644 index 000000000..1ffd4999f --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Config.hpp @@ -0,0 +1,53 @@ +/* + Nazara Engine - OpenGL + + 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_OPENGLRENDERER_HPP +#define NAZARA_CONFIG_OPENGLRENDERER_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_OPENGLRENDERER_MANAGE_MEMORY 0 + +// Active les tests de sécurité basés sur le code (Conseillé pour le développement) +#define NAZARA_OPENGLRENDERER_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_OPENGLRENDERER_BUILD + #define NAZARA_OPENGLRENDERER_API NAZARA_EXPORT + #else + #define NAZARA_OPENGLRENDERER_API NAZARA_IMPORT + #endif +#else + #define NAZARA_OPENGLRENDERER_API +#endif + +#endif // NAZARA_CONFIG_MODULENAME_HPP diff --git a/include/Nazara/OpenGLRenderer/ConfigCheck.hpp b/include/Nazara/OpenGLRenderer/ConfigCheck.hpp new file mode 100644 index 000000000..793b04818 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/ConfigCheck.hpp @@ -0,0 +1,22 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_CONFIG_CHECK_OPENGLE_HPP +#define NAZARA_CONFIG_CHECK_OPENGLE_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_OPENGLRENDERER_MANAGE_MEMORY + #undef NAZARA_MODULENAME_MANAGE_MEMORY + #define NAZARA_MODULENAME_MANAGE_MEMORY 0 +#endif + +#endif // NAZARA_CONFIG_CHECK_OPENGLRENDERER_HPP diff --git a/include/Nazara/OpenGLRenderer/Debug.hpp b/include/Nazara/OpenGLRenderer/Debug.hpp new file mode 100644 index 000000000..36e55c909 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Debug.hpp @@ -0,0 +1,8 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// 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/OpenGLRenderer/DebugOff.hpp b/include/Nazara/OpenGLRenderer/DebugOff.hpp new file mode 100644 index 000000000..c8ee4e470 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/DebugOff.hpp @@ -0,0 +1,9 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// 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/OpenGLRenderer/OpenGL.hpp b/include/Nazara/OpenGLRenderer/OpenGL.hpp new file mode 100644 index 000000000..9684f400d --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGL.hpp @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGL_HPP +#define NAZARA_OPENGL_HPP + +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class OpenGLDevice; + + class NAZARA_OPENGLRENDERER_API OpenGL + { + public: + OpenGL() = delete; + ~OpenGL() = delete; + + static bool Initialize(); + + static bool IsInitialized(); + + static void Uninitialize(); + }; +} + +#endif // NAZARA_OPENGL_HPP diff --git a/include/Nazara/OpenGLRenderer/OpenGLBuffer.hpp b/include/Nazara/OpenGLRenderer/OpenGLBuffer.hpp new file mode 100644 index 000000000..a316d168c --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLBuffer.hpp @@ -0,0 +1,57 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_BUFFER_HPP +#define NAZARA_OPENGLRENDERER_BUFFER_HPP + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_OPENGLRENDERER_API OpenGLBuffer : public AbstractBuffer + { + public: + inline OpenGLBuffer(Vk::Device& device, BufferType type); + OpenGLBuffer(const OpenGLBuffer&) = delete; + OpenGLBuffer(OpenGLBuffer&&) = delete; ///TODO + virtual ~OpenGLBuffer(); + + bool Fill(const void* data, UInt64 offset, UInt64 size) override; + + bool Initialize(UInt64 size, BufferUsageFlags usage) override; + + inline VkBuffer GetBuffer(); + UInt64 GetSize() const override; + DataStorage GetStorage() const override; + + void* Map(BufferAccess access, UInt64 offset, UInt64 size) override; + bool Unmap() override; + + OpenGLBuffer& operator=(const OpenGLBuffer&) = delete; + OpenGLBuffer& operator=(OpenGLBuffer&&) = delete; ///TODO + + private: + BufferType m_type; + BufferUsageFlags m_usage; + UInt64 m_size; + VkBuffer m_buffer; + VkBuffer m_stagingBuffer; + VmaAllocation m_allocation; + VmaAllocation m_stagingAllocation; + Vk::Device& m_device; + }; +} + +#include + +#endif // NAZARA_OPENGLRENDERER_BUFFER_HPP diff --git a/include/Nazara/OpenGLRenderer/OpenGLBuffer.inl b/include/Nazara/OpenGLRenderer/OpenGLBuffer.inl new file mode 100644 index 000000000..d17324fc6 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLBuffer.inl @@ -0,0 +1,22 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline OpenGLBuffer::OpenGLBuffer(Vk::Device& device, BufferType type) : + m_device(device), + m_type(type) + { + } + + inline VkBuffer OpenGLBuffer::GetBuffer() + { + return m_buffer; + } +} + +#include diff --git a/include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.hpp b/include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.hpp new file mode 100644 index 000000000..e45f143bc --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.hpp @@ -0,0 +1,39 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_OPENGLCOMMANDBUFFER_HPP +#define NAZARA_OPENGLRENDERER_OPENGLCOMMANDBUFFER_HPP + +#include +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_OPENGLRENDERER_API OpenGLCommandBuffer final : public CommandBuffer + { + public: + inline OpenGLCommandBuffer(Vk::AutoCommandBuffer commandBuffer); + inline OpenGLCommandBuffer(std::vector commandBuffers); + OpenGLCommandBuffer(const OpenGLCommandBuffer&) = delete; + OpenGLCommandBuffer(OpenGLCommandBuffer&&) noexcept = default; + ~OpenGLCommandBuffer() = default; + + inline Vk::CommandBuffer& GetCommandBuffer(std::size_t imageIndex = 0); + + OpenGLCommandBuffer& operator=(const OpenGLCommandBuffer&) = delete; + OpenGLCommandBuffer& operator=(OpenGLCommandBuffer&&) = delete; + + private: + std::vector m_commandBuffers; + }; +} + +#include + +#endif // NAZARA_OPENGLRENDERER_OPENGLCOMMANDBUFFER_HPP diff --git a/include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.inl b/include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.inl new file mode 100644 index 000000000..21a49438e --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.inl @@ -0,0 +1,26 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline OpenGLCommandBuffer::OpenGLCommandBuffer(Vk::AutoCommandBuffer commandBuffer) + { + m_commandBuffers.push_back(std::move(commandBuffer)); + } + + inline OpenGLCommandBuffer::OpenGLCommandBuffer(std::vector commandBuffers) : + m_commandBuffers(std::move(commandBuffers)) + { + } + + inline Vk::CommandBuffer& OpenGLCommandBuffer::GetCommandBuffer(std::size_t imageIndex) + { + return m_commandBuffers[imageIndex].Get(); + } +} + +#include diff --git a/include/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.hpp b/include/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.hpp new file mode 100644 index 000000000..dce64f6f1 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.hpp @@ -0,0 +1,66 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_OPENGLCOMMANDBUFFERBUILDER_HPP +#define NAZARA_OPENGLRENDERER_OPENGLCOMMANDBUFFERBUILDER_HPP + +#include +#include +#include +#include + +namespace Nz +{ + class OpenGLRenderPass; + + class NAZARA_OPENGLRENDERER_API OpenGLCommandBufferBuilder final : public CommandBufferBuilder + { + public: + inline OpenGLCommandBufferBuilder(Vk::CommandBuffer& commandBuffer, std::size_t imageIndex = 0); + OpenGLCommandBufferBuilder(const OpenGLCommandBufferBuilder&) = delete; + OpenGLCommandBufferBuilder(OpenGLCommandBufferBuilder&&) noexcept = default; + ~OpenGLCommandBufferBuilder() = default; + + void BeginDebugRegion(const std::string_view& regionName, const Nz::Color& color) override; + void BeginRenderPass(const Framebuffer& framebuffer, const RenderPass& renderPass, Nz::Recti renderRect, std::initializer_list clearValues) override; + + void BindIndexBuffer(AbstractBuffer* indexBuffer, UInt64 offset = 0) override; + void BindPipeline(const RenderPipeline& pipeline) override; + void BindShaderBinding(const ShaderBinding& binding) override; + void BindVertexBuffer(UInt32 binding, Nz::AbstractBuffer* vertexBuffer, UInt64 offset = 0) override; + + void CopyBuffer(const RenderBufferView& source, const RenderBufferView& target, UInt64 size, UInt64 sourceOffset = 0, UInt64 targetOffset = 0) override; + void CopyBuffer(const UploadPool::Allocation& allocation, const RenderBufferView& target, UInt64 size, UInt64 sourceOffset = 0, UInt64 targetOffset = 0) override; + + void Draw(UInt32 vertexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0) override; + void DrawIndexed(UInt32 indexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0) override; + + void EndDebugRegion() override; + void EndRenderPass() override; + + inline Vk::CommandBuffer& GetCommandBuffer(); + inline std::size_t GetMaxFramebufferCount() const; + + void PreTransferBarrier() override; + void PostTransferBarrier() override; + + void SetScissor(Nz::Recti scissorRegion) override; + void SetViewport(Nz::Recti viewportRegion) override; + + OpenGLCommandBufferBuilder& operator=(const OpenGLCommandBufferBuilder&) = delete; + OpenGLCommandBufferBuilder& operator=(OpenGLCommandBufferBuilder&&) = delete; + + private: + Vk::CommandBuffer& m_commandBuffer; + const OpenGLRenderPass* m_currentRenderPass; + std::size_t m_framebufferCount; + std::size_t m_imageIndex; + }; +} + +#include + +#endif // NAZARA_OPENGLRENDERER_OPENGLCOMMANDBUFFERBUILDER_HPP diff --git a/include/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.inl b/include/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.inl new file mode 100644 index 000000000..a785ac906 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.inl @@ -0,0 +1,28 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline OpenGLCommandBufferBuilder::OpenGLCommandBufferBuilder(Vk::CommandBuffer& commandBuffer, std::size_t imageIndex) : + m_commandBuffer(commandBuffer), + m_framebufferCount(0), + m_imageIndex(imageIndex) + { + } + + inline Vk::CommandBuffer& OpenGLCommandBufferBuilder::GetCommandBuffer() + { + return m_commandBuffer; + } + + inline std::size_t OpenGLCommandBufferBuilder::GetMaxFramebufferCount() const + { + return m_framebufferCount; + } +} + +#include diff --git a/include/Nazara/OpenGLRenderer/OpenGLCommandPool.hpp b/include/Nazara/OpenGLRenderer/OpenGLCommandPool.hpp new file mode 100644 index 000000000..fa68f0ac4 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLCommandPool.hpp @@ -0,0 +1,38 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_OPENGLCOMMANDPOOL_HPP +#define NAZARA_OPENGLRENDERER_OPENGLCOMMANDPOOL_HPP + +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_OPENGLRENDERER_API OpenGLCommandPool final : public CommandPool + { + public: + inline OpenGLCommandPool(Vk::Device& device, QueueType queueType); + inline OpenGLCommandPool(Vk::Device& device, UInt32 queueFamilyIndex); + OpenGLCommandPool(const OpenGLCommandPool&) = delete; + OpenGLCommandPool(OpenGLCommandPool&&) noexcept = default; + ~OpenGLCommandPool() = default; + + std::unique_ptr BuildCommandBuffer(const std::function& callback) override; + + OpenGLCommandPool& operator=(const OpenGLCommandPool&) = delete; + OpenGLCommandPool& operator=(OpenGLCommandPool&&) = delete; + + private: + Vk::CommandPool m_commandPool; + }; +} + +#include + +#endif // NAZARA_OPENGLRENDERER_OPENGLCOMMANDPOOL_HPP diff --git a/include/Nazara/OpenGLRenderer/OpenGLCommandPool.inl b/include/Nazara/OpenGLRenderer/OpenGLCommandPool.inl new file mode 100644 index 000000000..a8db6b7f3 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLCommandPool.inl @@ -0,0 +1,28 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + inline OpenGLCommandPool::OpenGLCommandPool(Vk::Device& device, QueueType queueType) + { + UInt32 queueFamilyIndex = device.GetDefaultFamilyIndex(queueType); + if (queueFamilyIndex == Vk::Device::InvalidQueue) + throw std::runtime_error("QueueType " + std::to_string(UnderlyingCast(queueType)) + " is not supported"); + + if (!m_commandPool.Create(device, queueFamilyIndex)) + throw std::runtime_error("Failed to create command pool: " + TranslateOpenGLError(m_commandPool.GetLastErrorCode())); + } + + inline OpenGLCommandPool::OpenGLCommandPool(Vk::Device& device, UInt32 queueFamilyIndex) + { + if (!m_commandPool.Create(device, queueFamilyIndex)) + throw std::runtime_error("Failed to create command pool: " + TranslateOpenGLError(m_commandPool.GetLastErrorCode())); + } +} + +#include diff --git a/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp b/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp new file mode 100644 index 000000000..be5426a40 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp @@ -0,0 +1,41 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_OPENGLDEVICE_HPP +#define NAZARA_OPENGLRENDERER_OPENGLDEVICE_HPP + +#include +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_OPENGLRENDERER_API OpenGLDevice : public RenderDevice, public Vk::Device + { + public: + using Device::Device; + OpenGLDevice(const OpenGLDevice&) = delete; + OpenGLDevice(OpenGLDevice&&) = delete; ///TODO? + ~OpenGLDevice(); + + std::unique_ptr InstantiateBuffer(BufferType type) override; + std::unique_ptr InstantiateCommandPool(QueueType queueType) override; + std::unique_ptr InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) override; + std::shared_ptr InstantiateRenderPipelineLayout(RenderPipelineLayoutInfo pipelineLayoutInfo) override; + std::shared_ptr InstantiateShaderStage(ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) override; + std::unique_ptr InstantiateTexture(const TextureInfo& params) override; + std::unique_ptr InstantiateTextureSampler(const TextureSamplerInfo& params) override; + + OpenGLDevice& operator=(const OpenGLDevice&) = delete; + OpenGLDevice& operator=(OpenGLDevice&&) = delete; ///TODO? + }; +} + +#include + +#endif // NAZARA_OPENGLRENDERER_OPENGLDEVICE_HPP diff --git a/include/Nazara/OpenGLRenderer/OpenGLDevice.inl b/include/Nazara/OpenGLRenderer/OpenGLDevice.inl new file mode 100644 index 000000000..42e1a1557 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLDevice.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ +} + +#include diff --git a/include/Nazara/OpenGLRenderer/OpenGLFramebuffer.hpp b/include/Nazara/OpenGLRenderer/OpenGLFramebuffer.hpp new file mode 100644 index 000000000..2a9a5906a --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLFramebuffer.hpp @@ -0,0 +1,43 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_OPENGLFRAMEBUFFER_HPP +#define NAZARA_OPENGLRENDERER_OPENGLFRAMEBUFFER_HPP + +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_OPENGLRENDERER_API OpenGLFramebuffer : public Framebuffer + { + public: + enum class Type + { + Multiple, + Single + }; + + inline OpenGLFramebuffer(Type type); + OpenGLFramebuffer(const OpenGLFramebuffer&) = delete; + OpenGLFramebuffer(OpenGLFramebuffer&&) noexcept = default; + ~OpenGLFramebuffer() = default; + + inline Type GetType() const; + + OpenGLFramebuffer& operator=(const OpenGLFramebuffer&) = delete; + OpenGLFramebuffer& operator=(OpenGLFramebuffer&&) noexcept = default; + + private: + Type m_type; + }; +} + +#include + +#endif // NAZARA_OPENGLRENDERER_OPENGLFRAMEBUFFER_HPP diff --git a/include/Nazara/OpenGLRenderer/OpenGLFramebuffer.inl b/include/Nazara/OpenGLRenderer/OpenGLFramebuffer.inl new file mode 100644 index 000000000..df37fb3dd --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLFramebuffer.inl @@ -0,0 +1,21 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline OpenGLFramebuffer::OpenGLFramebuffer(Type type) : + m_type(type) + { + } + + inline auto OpenGLFramebuffer::GetType() const -> Type + { + return m_type; + } +} + +#include diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderImage.hpp b/include/Nazara/OpenGLRenderer/OpenGLRenderImage.hpp new file mode 100644 index 000000000..fb2b6c30b --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderImage.hpp @@ -0,0 +1,65 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_OPENGLRENDERIMAGE_HPP +#define NAZARA_OPENGLRENDERER_OPENGLRENDERIMAGE_HPP + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class VkRenderWindow; + + class NAZARA_OPENGLRENDERER_API OpenGLRenderImage : public RenderImage + { + public: + OpenGLRenderImage(VkRenderWindow& owner); + OpenGLRenderImage(const OpenGLRenderImage&) = delete; + OpenGLRenderImage(OpenGLRenderImage&&) noexcept = default; + ~OpenGLRenderImage(); + + void Execute(const std::function& callback, QueueTypeFlags queueTypeFlags) override; + + inline Vk::Fence& GetInFlightFence(); + inline Vk::Semaphore& GetImageAvailableSemaphore(); + inline UInt32 GetImageIndex(); + inline Vk::Semaphore& GetRenderFinishedSemaphore(); + OpenGLUploadPool& GetUploadPool() override; + + void SubmitCommandBuffer(CommandBuffer* commandBuffer, QueueTypeFlags queueTypeFlags) override; + void SubmitCommandBuffer(VkCommandBuffer commandBuffer, QueueTypeFlags queueTypeFlags); + + void Present() override; + + inline void Reset(UInt32 imageIndex); + + OpenGLRenderImage& operator=(const OpenGLRenderImage&) = delete; + OpenGLRenderImage& operator=(OpenGLRenderImage&&) = delete; + + private: + std::size_t m_currentCommandBuffer; + std::vector m_inFlightCommandBuffers; + std::vector m_graphicalCommandsBuffers; + VkRenderWindow& m_owner; + Vk::CommandPool m_commandPool; + Vk::Fence m_inFlightFence; + Vk::Semaphore m_imageAvailableSemaphore; + Vk::Semaphore m_renderFinishedSemaphore; + OpenGLUploadPool m_uploadPool; + UInt32 m_imageIndex; + }; +} + +#include + +#endif // NAZARA_OPENGLRENDERER_OPENGLRENDERIMAGE_HPP diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderImage.inl b/include/Nazara/OpenGLRenderer/OpenGLRenderImage.inl new file mode 100644 index 000000000..f89800c06 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderImage.inl @@ -0,0 +1,39 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline Vk::Fence& Nz::OpenGLRenderImage::GetInFlightFence() + { + return m_inFlightFence; + } + + inline Vk::Semaphore& OpenGLRenderImage::GetImageAvailableSemaphore() + { + return m_imageAvailableSemaphore; + } + + inline UInt32 OpenGLRenderImage::GetImageIndex() + { + return m_imageIndex; + } + + inline Vk::Semaphore& OpenGLRenderImage::GetRenderFinishedSemaphore() + { + return m_renderFinishedSemaphore; + } + + inline void OpenGLRenderImage::Reset(UInt32 imageIndex) + { + m_graphicalCommandsBuffers.clear(); + m_currentCommandBuffer = 0; + m_imageIndex = imageIndex; + m_uploadPool.Reset(); + } +} + +#include diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderPass.hpp b/include/Nazara/OpenGLRenderer/OpenGLRenderPass.hpp new file mode 100644 index 000000000..370835853 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderPass.hpp @@ -0,0 +1,41 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_OPENGLRENDERPASS_HPP +#define NAZARA_OPENGLRENDERER_OPENGLRENDERPASS_HPP + +#include +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_OPENGLRENDERER_API OpenGLRenderPass final : public RenderPass + { + public: + inline OpenGLRenderPass(Vk::RenderPass renderPass, std::initializer_list formats); //< FIXME + OpenGLRenderPass(const OpenGLRenderPass&) = delete; + OpenGLRenderPass(OpenGLRenderPass&&) noexcept = default; + ~OpenGLRenderPass() = default; + + inline PixelFormat GetAttachmentFormat(std::size_t attachmentIndex) const; + inline Vk::RenderPass& GetRenderPass(); + inline const Vk::RenderPass& GetRenderPass() const; + + OpenGLRenderPass& operator=(const OpenGLRenderPass&) = delete; + OpenGLRenderPass& operator=(OpenGLRenderPass&&) noexcept = default; + + private: + std::vector m_formats; + Vk::RenderPass m_renderPass; + }; +} + +#include + +#endif // NAZARA_OPENGLRENDERER_OPENGLRENDERPASS_HPP diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderPass.inl b/include/Nazara/OpenGLRenderer/OpenGLRenderPass.inl new file mode 100644 index 000000000..97bafee02 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderPass.inl @@ -0,0 +1,32 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline OpenGLRenderPass::OpenGLRenderPass(Vk::RenderPass renderPass, std::initializer_list formats) : + m_formats(std::begin(formats), std::end(formats)), + m_renderPass(std::move(renderPass)) + { + } + + inline PixelFormat OpenGLRenderPass::GetAttachmentFormat(std::size_t attachmentIndex) const + { + return m_formats[attachmentIndex]; + } + + inline Vk::RenderPass& OpenGLRenderPass::GetRenderPass() + { + return m_renderPass; + } + + inline const Vk::RenderPass& OpenGLRenderPass::GetRenderPass() const + { + return m_renderPass; + } +} + +#include diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderPipeline.hpp b/include/Nazara/OpenGLRenderer/OpenGLRenderPipeline.hpp new file mode 100644 index 000000000..4cddfc828 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderPipeline.hpp @@ -0,0 +1,81 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_OPENGLRENDERPIPELINE_HPP +#define NAZARA_OPENGLRENDERER_OPENGLRENDERPIPELINE_HPP + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_OPENGLRENDERER_API OpenGLRenderPipeline : public RenderPipeline + { + public: + struct CreateInfo; + + OpenGLRenderPipeline(Vk::Device& device, RenderPipelineInfo pipelineInfo); + ~OpenGLRenderPipeline() = default; + + VkPipeline Get(const Vk::RenderPass& renderPass) const; + + static std::vector BuildColorBlendAttachmentStateList(const RenderPipelineInfo& pipelineInfo); + static VkPipelineColorBlendStateCreateInfo BuildColorBlendInfo(const RenderPipelineInfo& pipelineInfo, const std::vector& attachmentState); + static VkPipelineDepthStencilStateCreateInfo BuildDepthStencilInfo(const RenderPipelineInfo& pipelineInfo); + static VkPipelineDynamicStateCreateInfo BuildDynamicStateInfo(const RenderPipelineInfo& pipelineInfo, const std::vector& dynamicStates); + static std::vector BuildDynamicStateList(const RenderPipelineInfo& pipelineInfo); + static VkPipelineInputAssemblyStateCreateInfo BuildInputAssemblyInfo(const RenderPipelineInfo& pipelineInfo); + static VkPipelineMultisampleStateCreateInfo BuildMultisampleInfo(const RenderPipelineInfo& pipelineInfo); + static VkPipelineRasterizationStateCreateInfo BuildRasterizationInfo(const RenderPipelineInfo& pipelineInfo); + static VkPipelineViewportStateCreateInfo BuildViewportInfo(const RenderPipelineInfo& pipelineInfo); + static VkStencilOpState BuildStencilOp(const RenderPipelineInfo& pipelineInfo, bool front); + static std::vector BuildShaderStageInfo(const RenderPipelineInfo& pipelineInfo); + static std::vector BuildVertexAttributeDescription(const RenderPipelineInfo& pipelineInfo); + static std::vector BuildVertexBindingDescription(const RenderPipelineInfo& pipelineInfo); + static VkPipelineVertexInputStateCreateInfo BuildVertexInputInfo(const RenderPipelineInfo& pipelineInfo, const std::vector& vertexAttributes, const std::vector& bindingDescription); + + static CreateInfo BuildCreateInfo(const RenderPipelineInfo& pipelineInfo); + + struct CreateInfo + { + struct StateData + { + VkPipelineColorBlendStateCreateInfo colorBlendState; + VkPipelineDepthStencilStateCreateInfo depthStencilState; + VkPipelineDynamicStateCreateInfo dynamicState; + VkPipelineMultisampleStateCreateInfo multiSampleState; + VkPipelineInputAssemblyStateCreateInfo inputAssemblyState; + VkPipelineRasterizationStateCreateInfo rasterizationState; + VkPipelineVertexInputStateCreateInfo vertexInputState; + VkPipelineViewportStateCreateInfo viewportState; + }; + + std::vector colorBlendAttachmentState; + std::vector dynamicStates; + std::vector shaderStages; + std::vector vertexAttributesDescription; + std::vector vertexBindingDescription; + std::unique_ptr stateData; + VkGraphicsPipelineCreateInfo pipelineInfo; + }; + + private: + mutable std::unordered_map m_pipelines; + MovablePtr m_device; + CreateInfo m_pipelineCreateInfo; + RenderPipelineInfo m_pipelineInfo; + }; +} + +#include + +#endif // NAZARA_OPENGLRENDERER_OPENGLRENDERPIPELINE_HPP diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderPipeline.inl b/include/Nazara/OpenGLRenderer/OpenGLRenderPipeline.inl new file mode 100644 index 000000000..034fea18c --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderPipeline.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ +} + +#include diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.hpp b/include/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.hpp new file mode 100644 index 000000000..272a3fd22 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.hpp @@ -0,0 +1,70 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_OPENGLRENDERPIPELINELAYOUT_HPP +#define NAZARA_OPENGLRENDERER_OPENGLRENDERPIPELINELAYOUT_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_OPENGLRENDERER_API OpenGLRenderPipelineLayout : public RenderPipelineLayout + { + friend OpenGLShaderBinding; + + public: + OpenGLRenderPipelineLayout() = default; + ~OpenGLRenderPipelineLayout(); + + ShaderBindingPtr AllocateShaderBinding() override; + + bool Create(Vk::Device& device, RenderPipelineLayoutInfo layoutInfo); + + inline Vk::Device* GetDevice() const; + + inline const Vk::DescriptorSetLayout& GetDescriptorSetLayout() const; + inline const Vk::PipelineLayout& GetPipelineLayout() const; + + private: + struct DescriptorPool; + + DescriptorPool& AllocatePool(); + ShaderBindingPtr AllocateFromPool(std::size_t poolIndex); + void Release(ShaderBinding& binding); + inline void TryToShrink(); + + struct DescriptorPool + { + using BindingStorage = std::aligned_storage_t; + + Bitset freeBindings; + Vk::DescriptorPool descriptorPool; + std::unique_ptr storage; + }; + + MovablePtr m_device; + std::vector m_descriptorPools; + Vk::DescriptorSetLayout m_descriptorSetLayout; + Vk::PipelineLayout m_pipelineLayout; + RenderPipelineLayoutInfo m_layoutInfo; + }; +} + +#include + +#endif // NAZARA_OPENGLRENDERER_OPENGLRENDERPIPELINE_HPP diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.inl b/include/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.inl new file mode 100644 index 000000000..d4ca1e74d --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.inl @@ -0,0 +1,41 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline Vk::Device* OpenGLRenderPipelineLayout::GetDevice() const + { + return m_device.Get(); + } + + inline const Vk::DescriptorSetLayout& OpenGLRenderPipelineLayout::GetDescriptorSetLayout() const + { + return m_descriptorSetLayout; + } + + inline const Vk::PipelineLayout& OpenGLRenderPipelineLayout::GetPipelineLayout() const + { + return m_pipelineLayout; + } + + inline void OpenGLRenderPipelineLayout::TryToShrink() + { + std::size_t poolCount = m_descriptorPools.size(); + if (poolCount >= 2 && m_descriptorPools.back().freeBindings.TestAll()) + { + for (std::size_t i = poolCount - 1; i > 0; ++i) + { + if (m_descriptorPools[i].freeBindings.TestAll()) + poolCount--; + } + + m_descriptorPools.resize(poolCount); + } + } +} + +#include diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp b/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp new file mode 100644 index 000000000..9a057fc0c --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp @@ -0,0 +1,90 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_RENDERWINDOW_HPP +#define NAZARA_OPENGLRENDERER_RENDERWINDOW_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_OPENGLRENDERER_API OpenGLRenderWindow : public RenderWindowImpl + { + public: + VkRenderWindow(); + VkRenderWindow(const VkRenderWindow&) = delete; + VkRenderWindow(VkRenderWindow&&) = delete; ///TODO + virtual ~VkRenderWindow(); + + OpenGLRenderImage& Acquire() override; + + bool Create(RendererImpl* renderer, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) override; + std::unique_ptr CreateCommandPool(QueueType queueType) override; + + inline const OpenGLFramebuffer& GetFramebuffer() const override; + inline OpenGLDevice& GetDevice(); + inline const OpenGLDevice& GetDevice() const; + inline Vk::QueueHandle& GetGraphicsQueue(); + const OpenGLRenderPass& GetRenderPass() const override; + inline const Vk::Swapchain& GetSwapchain() const; + + std::shared_ptr GetRenderDevice() override; + + void Present(UInt32 imageIndex, VkSemaphore waitSemaphore = VK_NULL_HANDLE); + + VkRenderWindow& operator=(const VkRenderWindow&) = delete; + VkRenderWindow& operator=(VkRenderWindow&&) = delete; ///TODO + + private: + bool SetupDepthBuffer(const Vector2ui& size); + bool SetupRenderPass(); + bool SetupSwapchain(const Vk::PhysicalDevice& deviceInfo, Vk::Surface& surface, const Vector2ui& size); + + std::size_t m_currentFrame; + Clock m_clock; + VkFormat m_depthStencilFormat; + VkSurfaceFormatKHR m_surfaceFormat; + std::optional m_framebuffer; + std::optional m_renderPass; + std::shared_ptr m_device; + std::vector m_inflightFences; + std::vector m_concurrentImageData; + Vk::DeviceMemory m_depthBufferMemory; + Vk::Image m_depthBuffer; + Vk::ImageView m_depthBufferView; + Vk::QueueHandle m_graphicsQueue; + Vk::QueueHandle m_presentQueue; + Vk::QueueHandle m_transferQueue; + Vk::Swapchain m_swapchain; + }; +} + +#include + +#endif // NAZARA_OPENGLRENDERER_RENDERWINDOW_HPP diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.inl b/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.inl new file mode 100644 index 000000000..c0e1dd62d --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.inl @@ -0,0 +1,50 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline const OpenGLMultipleFramebuffer& VkRenderWindow::GetFramebuffer() const + { + return *m_framebuffer; + } + + inline OpenGLDevice& VkRenderWindow::GetDevice() + { + return *m_device; + } + + inline const OpenGLDevice& VkRenderWindow::GetDevice() const + { + return *m_device; + } + + inline Vk::QueueHandle& VkRenderWindow::GetGraphicsQueue() + { + return m_graphicsQueue; + } + + inline const Vk::Swapchain& VkRenderWindow::GetSwapchain() const + { + return m_swapchain; + } + + inline std::shared_ptr Nz::VkRenderWindow::GetRenderDevice() + { + return m_device; + } + + inline void VkRenderWindow::Present(UInt32 imageIndex, VkSemaphore waitSemaphore) + { + NazaraAssert(imageIndex < m_inflightFences.size(), "Invalid image index"); + + m_presentQueue.Present(m_swapchain, imageIndex, waitSemaphore); + + m_currentFrame = (m_currentFrame + 1) % m_inflightFences.size(); + } +} + +#include diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderer.hpp b/include/Nazara/OpenGLRenderer/OpenGLRenderer.hpp new file mode 100644 index 000000000..a177ac3b1 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderer.hpp @@ -0,0 +1,42 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_HPP +#define NAZARA_OPENGLRENDERER_HPP + +#include +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_OPENGLRENDERER_API OpenGLRenderer : public RendererImpl + { + public: + OpenGLRenderer() = default; + ~OpenGLRenderer(); + + std::unique_ptr CreateRenderSurfaceImpl() override; + std::unique_ptr CreateRenderWindowImpl() override; + + std::shared_ptr InstanciateRenderDevice(std::size_t deviceIndex) override; + + bool IsBetterThan(const RendererImpl* other) const override; + + RenderAPI QueryAPI() const override; + std::string QueryAPIString() const override; + UInt32 QueryAPIVersion() const override; + std::vector QueryRenderDevices() const override; + + bool Prepare(const ParameterList& parameters) override; + }; +} + +#include + +#endif // NAZARA_OPENGLRENDERER_HPP diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderer.inl b/include/Nazara/OpenGLRenderer/OpenGLRenderer.inl new file mode 100644 index 000000000..5b0763e98 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderer.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ +} + +#include diff --git a/include/Nazara/OpenGLRenderer/OpenGLShaderBinding.hpp b/include/Nazara/OpenGLRenderer/OpenGLShaderBinding.hpp new file mode 100644 index 000000000..395570ddd --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLShaderBinding.hpp @@ -0,0 +1,48 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_OPENGLSHADERBINDING_HPP +#define NAZARA_OPENGLRENDERER_OPENGLSHADERBINDING_HPP + +#include +#include +#include + +namespace Nz +{ + class OpenGLRenderPipelineLayout; + + class NAZARA_OPENGLRENDERER_API OpenGLShaderBinding : public ShaderBinding + { + public: + inline OpenGLShaderBinding(OpenGLRenderPipelineLayout& owner, std::size_t poolIndex, std::size_t bindingIndex, Vk::DescriptorSet descriptorSet); + OpenGLShaderBinding(const OpenGLShaderBinding&) = default; + OpenGLShaderBinding(OpenGLShaderBinding&&) noexcept = default; + ~OpenGLShaderBinding() = default; + + inline std::size_t GetBindingIndex() const; + inline const Vk::DescriptorSet& GetDescriptorSet() const; + inline std::size_t GetPoolIndex() const; + inline const OpenGLRenderPipelineLayout& GetOwner() const; + + void Update(std::initializer_list bindings) override; + + OpenGLShaderBinding& operator=(const OpenGLShaderBinding&) = delete; + OpenGLShaderBinding& operator=(OpenGLShaderBinding&&) = delete; + + private: + void Release() override; + + Vk::AutoDescriptorSet m_descriptorSet; + OpenGLRenderPipelineLayout& m_owner; + std::size_t m_bindingIndex; + std::size_t m_poolIndex; + }; +} + +#include + +#endif // NAZARA_OPENGLRENDERER_OPENGLSHADERBINDING_HPP diff --git a/include/Nazara/OpenGLRenderer/OpenGLShaderBinding.inl b/include/Nazara/OpenGLRenderer/OpenGLShaderBinding.inl new file mode 100644 index 000000000..8520a13b3 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLShaderBinding.inl @@ -0,0 +1,39 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline OpenGLShaderBinding::OpenGLShaderBinding(OpenGLRenderPipelineLayout& owner, std::size_t poolIndex, std::size_t bindingIndex, Vk::DescriptorSet descriptorSet) : + m_descriptorSet(std::move(descriptorSet)), + m_owner(owner), + m_bindingIndex(bindingIndex), + m_poolIndex(poolIndex) + { + } + + inline std::size_t OpenGLShaderBinding::GetBindingIndex() const + { + return m_bindingIndex; + } + + inline std::size_t OpenGLShaderBinding::GetPoolIndex() const + { + return m_poolIndex; + } + + inline const Vk::DescriptorSet& OpenGLShaderBinding::GetDescriptorSet() const + { + return m_descriptorSet; + } + + inline const OpenGLRenderPipelineLayout& OpenGLShaderBinding::GetOwner() const + { + return m_owner; + } +} + +#include diff --git a/include/Nazara/OpenGLRenderer/OpenGLShaderStage.hpp b/include/Nazara/OpenGLRenderer/OpenGLShaderStage.hpp new file mode 100644 index 000000000..5ed61015d --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLShaderStage.hpp @@ -0,0 +1,42 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_OPENGLSHADERSTAGE_HPP +#define NAZARA_OPENGLRENDERER_OPENGLSHADERSTAGE_HPP + +#include +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_OPENGLRENDERER_API OpenGLShaderStage : public ShaderStageImpl + { + public: + OpenGLShaderStage() = default; + OpenGLShaderStage(const OpenGLShaderStage&) = delete; + OpenGLShaderStage(OpenGLShaderStage&&) noexcept = default; + ~OpenGLShaderStage() = default; + + bool Create(Vk::Device& device, ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize); + + inline const Vk::ShaderModule& GetHandle() const; + inline ShaderStageType GetStageType() const; + + OpenGLShaderStage& operator=(const OpenGLShaderStage&) = delete; + OpenGLShaderStage& operator=(OpenGLShaderStage&&) noexcept = default; + + private: + Vk::ShaderModule m_shaderModule; + ShaderStageType m_stage; + }; +} + +#include + +#endif // NAZARA_OPENGLRENDERER_OPENGLSHADERSTAGE_HPP diff --git a/include/Nazara/OpenGLRenderer/OpenGLShaderStage.inl b/include/Nazara/OpenGLRenderer/OpenGLShaderStage.inl new file mode 100644 index 000000000..bf191a5c8 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLShaderStage.inl @@ -0,0 +1,21 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline const Vk::ShaderModule& OpenGLShaderStage::GetHandle() const + { + return m_shaderModule; + } + + inline ShaderStageType OpenGLShaderStage::GetStageType() const + { + return m_stage; + } +} + +#include diff --git a/include/Nazara/OpenGLRenderer/OpenGLSurface.hpp b/include/Nazara/OpenGLRenderer/OpenGLSurface.hpp new file mode 100644 index 000000000..235813865 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLSurface.hpp @@ -0,0 +1,40 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_SURFACE_HPP +#define NAZARA_OPENGLRENDERER_SURFACE_HPP + +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_OPENGLRENDERER_API OpenGLSurface : public RenderSurface + { + public: + OpenGLSurface(); + OpenGLSurface(const OpenGLSurface&) = delete; + OpenGLSurface(OpenGLSurface&&) = delete; ///TODO + virtual ~OpenGLSurface(); + + bool Create(WindowHandle handle) override; + void Destroy() override; + + inline Vk::Surface& GetSurface(); + + OpenGLSurface& operator=(const OpenGLSurface&) = delete; + OpenGLSurface& operator=(OpenGLSurface&&) = delete; ///TODO + + private: + Vk::Surface m_surface; + }; +} + +#include + +#endif // NAZARA_OPENGLRENDERER_SURFACE_HPP diff --git a/include/Nazara/OpenGLRenderer/OpenGLSurface.inl b/include/Nazara/OpenGLRenderer/OpenGLSurface.inl new file mode 100644 index 000000000..f3af9ae40 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLSurface.inl @@ -0,0 +1,16 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline Vk::Surface& OpenGLSurface::GetSurface() + { + return m_surface; + } +} + +#include diff --git a/include/Nazara/OpenGLRenderer/OpenGLTexture.hpp b/include/Nazara/OpenGLRenderer/OpenGLTexture.hpp new file mode 100644 index 000000000..7dcd68582 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLTexture.hpp @@ -0,0 +1,51 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_OPENGLTEXTURE_HPP +#define NAZARA_OPENGLRENDERER_OPENGLTEXTURE_HPP + +#include +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_OPENGLRENDERER_API OpenGLTexture : public Texture + { + public: + OpenGLTexture(Vk::Device& device, const TextureInfo& params); + OpenGLTexture(const OpenGLTexture&) = default; + OpenGLTexture(OpenGLTexture&&) noexcept = default; + ~OpenGLTexture(); + + PixelFormat GetFormat() const override; + inline VkImage GetImage() const; + inline VkImageView GetImageView() const; + UInt8 GetLevelCount() const override; + Vector3ui GetSize(UInt8 level = 0) const override; + ImageType GetType() const override; + + bool Update(const void* ptr) override; + + OpenGLTexture& operator=(const OpenGLTexture&) = delete; + OpenGLTexture& operator=(OpenGLTexture&&) = delete; + + private: + static void InitForFormat(PixelFormat pixelFormat, VkImageCreateInfo& createImage, VkImageViewCreateInfo& createImageView); + + VkImage m_image; + VmaAllocation m_allocation; + Vk::Device& m_device; + Vk::ImageView m_imageView; + TextureInfo m_params; + }; +} + +#include + +#endif // NAZARA_OPENGLRENDERER_OPENGLTEXTURE_HPP diff --git a/include/Nazara/OpenGLRenderer/OpenGLTexture.inl b/include/Nazara/OpenGLRenderer/OpenGLTexture.inl new file mode 100644 index 000000000..1aef1e297 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLTexture.inl @@ -0,0 +1,21 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline VkImage OpenGLTexture::GetImage() const + { + return m_image; + } + + inline VkImageView OpenGLTexture::GetImageView() const + { + return m_imageView; + } +} + +#include diff --git a/include/Nazara/OpenGLRenderer/OpenGLTextureSampler.hpp b/include/Nazara/OpenGLRenderer/OpenGLTextureSampler.hpp new file mode 100644 index 000000000..4ba930384 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLTextureSampler.hpp @@ -0,0 +1,36 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_OPENGLTEXTURESAMPLER_HPP +#define NAZARA_OPENGLRENDERER_OPENGLTEXTURESAMPLER_HPP + +#include +#include +#include + +namespace Nz +{ + class NAZARA_OPENGLRENDERER_API OpenGLTextureSampler : public TextureSampler + { + public: + OpenGLTextureSampler(Vk::Device& device, TextureSamplerInfo samplerInfo); + OpenGLTextureSampler(const OpenGLTextureSampler&) = default; + OpenGLTextureSampler(OpenGLTextureSampler&&) noexcept = default; + ~OpenGLTextureSampler() = default; + + inline VkSampler GetSampler() const; + + OpenGLTextureSampler& operator=(const OpenGLTextureSampler&) = delete; + OpenGLTextureSampler& operator=(OpenGLTextureSampler&&) = delete; + + private: + Vk::Sampler m_sampler; + }; +} + +#include + +#endif // NAZARA_OPENGLRENDERER_OPENGLTEXTURESAMPLER_HPP diff --git a/include/Nazara/OpenGLRenderer/OpenGLTextureSampler.inl b/include/Nazara/OpenGLRenderer/OpenGLTextureSampler.inl new file mode 100644 index 000000000..1935928c3 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLTextureSampler.inl @@ -0,0 +1,16 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline VkSampler OpenGLTextureSampler::GetSampler() const + { + return m_sampler; + } +} + +#include diff --git a/include/Nazara/OpenGLRenderer/OpenGLUploadPool.hpp b/include/Nazara/OpenGLRenderer/OpenGLUploadPool.hpp new file mode 100644 index 000000000..b668cf5cf --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLUploadPool.hpp @@ -0,0 +1,58 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_OPENGLUPLOADPOOL_HPP +#define NAZARA_OPENGLRENDERER_OPENGLUPLOADPOOL_HPP + +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_OPENGLRENDERER_API OpenGLUploadPool : public UploadPool + { + public: + struct OpenGLAllocation : Allocation + { + VkBuffer buffer; + }; + + inline OpenGLUploadPool(Vk::Device& device, UInt64 blockSize); + OpenGLUploadPool(const OpenGLUploadPool&) = delete; + OpenGLUploadPool(OpenGLUploadPool&&) noexcept = default; + ~OpenGLUploadPool() = default; + + OpenGLAllocation& Allocate(UInt64 size) override; + OpenGLAllocation& Allocate(UInt64 size, UInt64 alignment) override; + + void Reset() override; + + OpenGLUploadPool& operator=(const OpenGLUploadPool&) = delete; + OpenGLUploadPool& operator=(OpenGLUploadPool&&) = delete; + + private: + struct Block + { + Vk::DeviceMemory blockMemory; + Vk::Buffer buffer; + UInt64 freeOffset; + }; + + UInt64 m_blockSize; + Vk::Device& m_device; + std::vector m_blocks; + std::vector m_allocations; + }; +} + +#include + +#endif // NAZARA_OPENGLRENDERER_OPENGLUPLOADPOOL_HPP diff --git a/include/Nazara/OpenGLRenderer/OpenGLUploadPool.inl b/include/Nazara/OpenGLRenderer/OpenGLUploadPool.inl new file mode 100644 index 000000000..2de0a8237 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLUploadPool.inl @@ -0,0 +1,17 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline OpenGLUploadPool::OpenGLUploadPool(Vk::Device& device, UInt64 blockSize) : + m_blockSize(blockSize), + m_device(device) + { + } +} + +#include diff --git a/include/Nazara/OpenGLRenderer/Utils.hpp b/include/Nazara/OpenGLRenderer/Utils.hpp new file mode 100644 index 000000000..cd1b178b5 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Utils.hpp @@ -0,0 +1,39 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_UTILS_OPENGL_HPP +#define NAZARA_UTILS_OPENGL_HPP + +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + inline VkBufferUsageFlags ToOpenGL(BufferType bufferType); + inline VkFormat ToOpenGL(ComponentType componentType); + inline VkCullModeFlagBits ToOpenGL(FaceSide faceSide); + inline VkPolygonMode ToOpenGL(FaceFilling faceFilling); + inline VkPrimitiveTopology ToOpenGL(PrimitiveMode primitiveMode); + inline VkCompareOp ToOpenGL(RendererComparison comparison); + inline VkFilter ToOpenGL(SamplerFilter samplerFilter); + inline VkSamplerMipmapMode ToOpenGL(SamplerMipmapMode samplerMipmap); + inline VkSamplerAddressMode ToOpenGL(SamplerWrap samplerWrap); + inline VkDescriptorType ToOpenGL(ShaderBindingType bindingType); + inline VkShaderStageFlagBits ToOpenGL(ShaderStageType stageType); + inline VkShaderStageFlags ToOpenGL(ShaderStageTypeFlags stageType); + inline VkStencilOp ToOpenGL(StencilOperation stencilOp); + inline VkVertexInputRate ToOpenGL(VertexInputRate inputRate); + + NAZARA_OPENGLRENDERER_API std::string TranslateOpenGLError(VkResult code); +} + +#include + +#endif // NAZARA_UTILS_OPENGL_HPP diff --git a/include/Nazara/OpenGLRenderer/Utils.inl b/include/Nazara/OpenGLRenderer/Utils.inl new file mode 100644 index 000000000..877da7179 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Utils.inl @@ -0,0 +1,218 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include + +namespace Nz +{ + VkBufferUsageFlags ToOpenGL(BufferType bufferType) + { + switch (bufferType) + { + case BufferType_Index: return VK_BUFFER_USAGE_INDEX_BUFFER_BIT; + case BufferType_Vertex: return VK_BUFFER_USAGE_VERTEX_BUFFER_BIT; + case BufferType_Uniform: return VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; + } + + NazaraError("Unhandled BufferType 0x" + String::Number(bufferType, 16)); + return 0; + } + + VkFormat ToOpenGL(ComponentType componentType) + { + switch (componentType) + { + case ComponentType_Color: return VK_FORMAT_R8G8B8A8_UINT; + case ComponentType_Double1: return VK_FORMAT_R64_SFLOAT; + case ComponentType_Double2: return VK_FORMAT_R64G64_SFLOAT; + case ComponentType_Double3: return VK_FORMAT_R64G64B64_SFLOAT; + case ComponentType_Double4: return VK_FORMAT_R64G64B64A64_SFLOAT; + case ComponentType_Float1: return VK_FORMAT_R32_SFLOAT; + case ComponentType_Float2: return VK_FORMAT_R32G32_SFLOAT; + case ComponentType_Float3: return VK_FORMAT_R32G32B32_SFLOAT; + case ComponentType_Float4: return VK_FORMAT_R32G32B32A32_SFLOAT; + case ComponentType_Int1: return VK_FORMAT_R32_SINT; + case ComponentType_Int2: return VK_FORMAT_R32G32_SINT; + case ComponentType_Int3: return VK_FORMAT_R32G32B32_SINT; + case ComponentType_Int4: return VK_FORMAT_R32G32B32A32_SINT; + case ComponentType_Quaternion: return VK_FORMAT_R32G32B32A32_SFLOAT; + } + + NazaraError("Unhandled ComponentType 0x" + String::Number(componentType, 16)); + return VK_FORMAT_UNDEFINED; + } + + VkCullModeFlagBits ToOpenGL(FaceSide faceSide) + { + switch (faceSide) + { + case FaceSide_None: return VK_CULL_MODE_NONE; + case FaceSide_Back: return VK_CULL_MODE_BACK_BIT; + case FaceSide_Front: return VK_CULL_MODE_FRONT_BIT; + case FaceSide_FrontAndBack: return VK_CULL_MODE_FRONT_AND_BACK; + } + + NazaraError("Unhandled FaceSide 0x" + String::Number(faceSide, 16)); + return VK_CULL_MODE_BACK_BIT; + } + + inline VkPolygonMode ToOpenGL(FaceFilling faceFilling) + { + switch (faceFilling) + { + case FaceFilling_Fill: return VK_POLYGON_MODE_FILL; + case FaceFilling_Line: return VK_POLYGON_MODE_LINE; + case FaceFilling_Point: return VK_POLYGON_MODE_POINT; + } + + NazaraError("Unhandled FaceFilling 0x" + String::Number(faceFilling, 16)); + return VK_POLYGON_MODE_FILL; + } + + VkPrimitiveTopology ToOpenGL(PrimitiveMode primitiveMode) + { + switch (primitiveMode) + { + case PrimitiveMode_LineList: return VK_PRIMITIVE_TOPOLOGY_LINE_LIST; + case PrimitiveMode_LineStrip: return VK_PRIMITIVE_TOPOLOGY_LINE_STRIP; + case PrimitiveMode_PointList: return VK_PRIMITIVE_TOPOLOGY_POINT_LIST; + case PrimitiveMode_TriangleList: return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; + case PrimitiveMode_TriangleStrip: return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; + case PrimitiveMode_TriangleFan: return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN; + } + + NazaraError("Unhandled FaceFilling 0x" + String::Number(primitiveMode, 16)); + return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; + } + + inline VkCompareOp ToOpenGL(RendererComparison comparison) + { + switch (comparison) + { + case RendererComparison_Never: return VK_COMPARE_OP_NEVER; + case RendererComparison_Less: return VK_COMPARE_OP_LESS; + case RendererComparison_Equal: return VK_COMPARE_OP_EQUAL; + case RendererComparison_LessOrEqual: return VK_COMPARE_OP_LESS_OR_EQUAL; + case RendererComparison_Greater: return VK_COMPARE_OP_GREATER; + case RendererComparison_NotEqual: return VK_COMPARE_OP_NOT_EQUAL; + case RendererComparison_GreaterOrEqual: return VK_COMPARE_OP_GREATER_OR_EQUAL; + case RendererComparison_Always: return VK_COMPARE_OP_ALWAYS; + } + + NazaraError("Unhandled RendererComparison 0x" + String::Number(comparison, 16)); + return VK_COMPARE_OP_NEVER; + } + + VkFilter ToOpenGL(SamplerFilter samplerFilter) + { + switch (samplerFilter) + { + case SamplerFilter_Linear: return VK_FILTER_LINEAR; + case SamplerFilter_Nearest: return VK_FILTER_NEAREST; + } + + NazaraError("Unhandled SamplerFilter 0x" + String::Number(UnderlyingCast(samplerFilter), 16)); + return VK_FILTER_NEAREST; + } + + VkSamplerMipmapMode ToOpenGL(SamplerMipmapMode samplerMipmap) + { + switch (samplerMipmap) + { + case SamplerMipmapMode_Linear: return VK_SAMPLER_MIPMAP_MODE_LINEAR; + case SamplerMipmapMode_Nearest: return VK_SAMPLER_MIPMAP_MODE_NEAREST; + } + + NazaraError("Unhandled SamplerMipmapMode 0x" + String::Number(UnderlyingCast(samplerMipmap), 16)); + return VK_SAMPLER_MIPMAP_MODE_NEAREST; + } + + VkSamplerAddressMode ToOpenGL(SamplerWrap samplerWrap) + { + switch (samplerWrap) + { + case SamplerWrap_Clamp: return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; + case SamplerWrap_MirroredRepeat: return VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT; + case SamplerWrap_Repeat: return VK_SAMPLER_ADDRESS_MODE_REPEAT; + } + + NazaraError("Unhandled SamplerWrap 0x" + String::Number(UnderlyingCast(samplerWrap), 16)); + return VK_SAMPLER_ADDRESS_MODE_REPEAT; + } + + VkDescriptorType ToOpenGL(ShaderBindingType bindingType) + { + switch (bindingType) + { + case ShaderBindingType::Texture: return VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; + case ShaderBindingType::UniformBuffer: return VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; + } + + NazaraError("Unhandled ShaderBindingType 0x" + String::Number(UnderlyingCast(bindingType), 16)); + return VK_DESCRIPTOR_TYPE_SAMPLER; + } + + VkShaderStageFlagBits ToOpenGL(ShaderStageType stageType) + { + switch (stageType) + { + case ShaderStageType::Fragment: return VK_SHADER_STAGE_FRAGMENT_BIT; + case ShaderStageType::Vertex: return VK_SHADER_STAGE_VERTEX_BIT; + } + + NazaraError("Unhandled ShaderStageType 0x" + String::Number(UnderlyingCast(stageType), 16)); + return {}; + } + + VkShaderStageFlags ToOpenGL(ShaderStageTypeFlags stageType) + { + VkShaderStageFlags shaderStageBits = 0; + + if (stageType.Test(ShaderStageType::Fragment)) + shaderStageBits |= VK_SHADER_STAGE_FRAGMENT_BIT; + + if (stageType.Test(ShaderStageType::Vertex)) + shaderStageBits |= VK_SHADER_STAGE_VERTEX_BIT; + + static_assert(UnderlyingCast(ShaderStageType::Max) + 1 == 2); + + return shaderStageBits; + } + + VkStencilOp ToOpenGL(StencilOperation stencilOp) + { + switch (stencilOp) + { + case StencilOperation_Decrement: return VK_STENCIL_OP_DECREMENT_AND_CLAMP; + case StencilOperation_DecrementNoClamp: return VK_STENCIL_OP_DECREMENT_AND_WRAP; + case StencilOperation_Increment: return VK_STENCIL_OP_INCREMENT_AND_CLAMP; + case StencilOperation_IncrementNoClamp: return VK_STENCIL_OP_INCREMENT_AND_WRAP; + case StencilOperation_Invert: return VK_STENCIL_OP_INVERT; + case StencilOperation_Keep: return VK_STENCIL_OP_KEEP; + case StencilOperation_Replace: return VK_STENCIL_OP_REPLACE; + case StencilOperation_Zero: return VK_STENCIL_OP_ZERO; + } + + NazaraError("Unhandled RendererComparison 0x" + String::Number(stencilOp, 16)); + return VK_STENCIL_OP_KEEP; + } + + VkVertexInputRate ToOpenGL(VertexInputRate inputRate) + { + switch (inputRate) + { + case VertexInputRate::Instance: return VK_VERTEX_INPUT_RATE_INSTANCE; + case VertexInputRate::Vertex: return VK_VERTEX_INPUT_RATE_VERTEX; + } + + NazaraError("Unhandled VertexInputRate 0x" + String::Number(UnderlyingCast(inputRate), 16)); + return VK_VERTEX_INPUT_RATE_VERTEX; + } +} + +#include diff --git a/include/Nazara/OpenGLRenderer/Wrapper.hpp b/include/Nazara/OpenGLRenderer/Wrapper.hpp new file mode 100644 index 000000000..f6b7151d9 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper.hpp @@ -0,0 +1,38 @@ +// This file was automatically generated + +#pragma once + +#ifndef NAZARA_GLOBAL_OPENGLRENDERER_WRAPPER_HPP +#define NAZARA_GLOBAL_OPENGLRENDERER_WRAPPER_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // NAZARA_GLOBAL_OPENGLRENDERER_WRAPPER_HPP diff --git a/include/Nazara/OpenGLRenderer/Wrapper/.hpp b/include/Nazara/OpenGLRenderer/Wrapper/.hpp new file mode 100644 index 000000000..8315628db --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/.hpp @@ -0,0 +1,39 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_GLCONTEXT_HPP +#define NAZARA_OPENGLRENDERER_GLCONTEXT_HPP + +#include +#include +#include + +namespace Nz::GL +{ + struct ContextParams + { + + }; + + class GLContext + { + public: + GLContext() = default; + virtual ~GLContext(); + + virtual bool Activate() = 0; + + virtual bool Create(const ContextParams& params) = 0; + + virtual void EnableVerticalSync(bool enabled) = 0; + + virtual void SwapBuffers() = 0; + }; +} + +#include + +#endif diff --git a/include/Nazara/OpenGLRenderer/Wrapper/.inl b/include/Nazara/OpenGLRenderer/Wrapper/.inl new file mode 100644 index 000000000..4e6fe854b --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz::Vk +{ +} + +#include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Buffer.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Buffer.hpp new file mode 100644 index 000000000..fbe051ec4 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/Buffer.hpp @@ -0,0 +1,46 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_VKBUFFER_HPP +#define NAZARA_OPENGLRENDERER_VKBUFFER_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class Buffer : public DeviceObject + { + friend DeviceObject; + + public: + Buffer() = default; + Buffer(const Buffer&) = delete; + Buffer(Buffer&&) noexcept = default; + ~Buffer() = default; + + bool BindBufferMemory(VkDeviceMemory memory, VkDeviceSize offset = 0); + + using DeviceObject::Create; + inline bool Create(Device& device, VkBufferCreateFlags flags, VkDeviceSize size, VkBufferUsageFlags usage, const VkAllocationCallbacks* allocator = nullptr); + + VkMemoryRequirements GetMemoryRequirements() const; + + Buffer& operator=(const Buffer&) = delete; + Buffer& operator=(Buffer&&) = delete; + + private: + static inline VkResult CreateHelper(Device& device, const VkBufferCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkBuffer* handle); + static inline void DestroyHelper(Device& device, VkBuffer handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_OPENGLRENDERER_VKBUFFER_HPP diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Buffer.inl b/include/Nazara/OpenGLRenderer/Wrapper/Buffer.inl new file mode 100644 index 000000000..4914aa317 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/Buffer.inl @@ -0,0 +1,62 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + namespace Vk + { + inline bool Buffer::BindBufferMemory(VkDeviceMemory memory, VkDeviceSize offset) + { + m_lastErrorCode = m_device->vkBindBufferMemory(*m_device, m_handle, memory, offset); + if (m_lastErrorCode != VK_SUCCESS) + { + NazaraError("Failed to bind buffer memory"); + return false; + } + + return true; + } + + inline bool Buffer::Create(Device& device, VkBufferCreateFlags flags, VkDeviceSize size, VkBufferUsageFlags usage, const VkAllocationCallbacks* allocator) + { + VkBufferCreateInfo createInfo = { + VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + flags, // VkBufferCreateFlags flags; + size, // VkDeviceSize size; + usage, // VkBufferUsageFlags usage; + VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode; + 0, // uint32_t queueFamilyIndexCount; + nullptr // const uint32_t* pQueueFamilyIndices; + }; + + return Create(device, createInfo, allocator); + } + + inline VkMemoryRequirements Buffer::GetMemoryRequirements() const + { + NazaraAssert(IsValid(), "Invalid buffer"); + + VkMemoryRequirements memoryRequirements; + m_device->vkGetBufferMemoryRequirements(*m_device, m_handle, &memoryRequirements); + + return memoryRequirements; + } + + inline VkResult Buffer::CreateHelper(Device& device, const VkBufferCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkBuffer* handle) + { + return device.vkCreateBuffer(device, createInfo, allocator, handle); + } + + inline void Buffer::DestroyHelper(Device& device, VkBuffer handle, const VkAllocationCallbacks* allocator) + { + return device.vkDestroyBuffer(device, handle, allocator); + } + } +} + +#include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp new file mode 100644 index 000000000..44bef0b02 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp @@ -0,0 +1,34 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_CONTEXT_HPP +#define NAZARA_OPENGLRENDERER_CONTEXT_HPP + +#include +#include +#include + +namespace Nz::GL +{ + class Context + { + public: + Context() = default; + Context(const Context&) = delete; + Context(Context&& object) noexcept = default; + ~Context() = default; + + Context& operator=(const Context&) = delete; + Context& operator=(Context&& object) noexcept = default; + + private: + std::unique_ptr m_impl; + }; +} + +#include + +#endif diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Context.inl b/include/Nazara/OpenGLRenderer/Wrapper/Context.inl new file mode 100644 index 000000000..b7ef5ca1b --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/Context.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz::GL +{ +} + +#include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/ContextObject.hpp b/include/Nazara/OpenGLRenderer/Wrapper/ContextObject.hpp new file mode 100644 index 000000000..696427450 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/ContextObject.hpp @@ -0,0 +1,56 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_VKDEVICEOBJECT_HPP +#define NAZARA_OPENGLRENDERER_VKDEVICEOBJECT_HPP + +#include +#include +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + template + class DeviceObject + { + public: + DeviceObject(); + DeviceObject(const DeviceObject&) = delete; + DeviceObject(DeviceObject&& object) noexcept; + ~DeviceObject(); + + bool Create(Device& device, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); + void Destroy(); + + bool IsValid() const; + + Device* GetDevice() const; + VkResult GetLastErrorCode() const; + + void SetDebugName(const char* name); + void SetDebugName(const std::string& name); + + DeviceObject& operator=(const DeviceObject&) = delete; + DeviceObject& operator=(DeviceObject&& object) noexcept; + + operator VkType() const; + + protected: + MovablePtr m_device; + VkAllocationCallbacks m_allocator; + VkType m_handle; + mutable VkResult m_lastErrorCode; + }; + } +} + +#include + +#endif // NAZARA_OPENGLRENDERER_VKDEVICEOBJECT_HPP diff --git a/include/Nazara/OpenGLRenderer/Wrapper/ContextObject.inl b/include/Nazara/OpenGLRenderer/Wrapper/ContextObject.inl new file mode 100644 index 000000000..1dbf21289 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/ContextObject.inl @@ -0,0 +1,123 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + template + DeviceObject::DeviceObject() : + m_handle(VK_NULL_HANDLE) + { + } + + template + DeviceObject::DeviceObject(DeviceObject&& object) noexcept : + m_device(std::move(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 + DeviceObject::~DeviceObject() + { + Destroy(); + } + + template + bool DeviceObject::Create(Device& device, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator) + { + m_device = &device; + m_lastErrorCode = C::CreateHelper(*m_device, &createInfo, allocator, &m_handle); + if (m_lastErrorCode != VkResult::VK_SUCCESS) + { + NazaraError("Failed to create OpenGL object: " + TranslateOpenGLError(m_lastErrorCode)); + return false; + } + + // Store the allocator to access them when needed + if (allocator) + m_allocator = *allocator; + else + m_allocator.pfnAllocation = nullptr; + + return true; + } + + template + void DeviceObject::Destroy() + { + if (IsValid()) + { + C::DestroyHelper(*m_device, m_handle, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); + m_handle = VK_NULL_HANDLE; + } + } + + template + bool DeviceObject::IsValid() const + { + return m_handle != VK_NULL_HANDLE; + } + + template + Device* DeviceObject::GetDevice() const + { + return m_device; + } + + template + VkResult DeviceObject::GetLastErrorCode() const + { + return m_lastErrorCode; + } + + template + void DeviceObject::SetDebugName(const char* name) + { + if (m_device->vkSetDebugUtilsObjectNameEXT) + { + VkDebugUtilsObjectNameInfoEXT debugName = { VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT }; + debugName.objectType = ObjectType; + debugName.objectHandle = static_cast(reinterpret_cast(m_handle)); + debugName.pObjectName = name; + + m_device->vkSetDebugUtilsObjectNameEXT(*m_device, &debugName); + } + } + + template + void DeviceObject::SetDebugName(const std::string& name) + { + return SetDebugName(name.data()); + } + + template + auto DeviceObject::operator=(DeviceObject&& object) noexcept -> DeviceObject& + { + std::swap(m_allocator, object.m_allocator); + std::swap(m_device, object.m_device); + std::swap(m_handle, object.m_handle); + std::swap(m_lastErrorCode, object.m_lastErrorCode); + + return *this; + } + + template + DeviceObject::operator VkType() const + { + return m_handle; + } + } +} + +#include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp b/include/Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp new file mode 100644 index 000000000..81f8fbacd --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp @@ -0,0 +1,140 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_COREFUNCTIONS_HPP +#define NAZARA_OPENGLRENDERER_COREFUNCTIONS_HPP + +#include + +// OpenGL core +#define NAZARA_OPENGLRENDERER_FOREACH_GLES_FUNC(cb) \ + cb(glActiveTexture, PFNGLACTIVETEXTUREPROC) \ + cb(glAttachShader, PFNGLATTACHSHADERPROC) \ + cb(glBeginQuery, PFNGLBEGINQUERYPROC) \ + cb(glBindAttribLocation, PFNGLBINDATTRIBLOCATIONPROC) \ + cb(glBindBuffer, PFNGLBINDBUFFERPROC) \ + cb(glBindFramebuffer, PFNGLBINDFRAMEBUFFERPROC) \ + cb(glBindRenderbuffer, PFNGLBINDRENDERBUFFERPROC) \ + cb(glBindSampler, PFNGLBINDSAMPLERPROC) \ + cb(glBindTexture, PFNGLBINDTEXTUREPROC) \ + cb(glBindVertexArray, PFNGLBINDVERTEXARRAYPROC) \ + cb(glBlendFunc, PFNGLBLENDFUNCPROC) \ + cb(glBlendFuncSeparate, PFNGLBLENDFUNCSEPARATEPROC) \ + cb(glBlitFramebuffer, PFNGLBLITFRAMEBUFFERPROC) \ + cb(glBufferData, PFNGLBUFFERDATAPROC) \ + cb(glBufferSubData, PFNGLBUFFERSUBDATAPROC) \ + cb(glClear, PFNGLCLEARPROC) \ + cb(glClearColor, PFNGLCLEARCOLORPROC) \ + cb(glClearStencil, PFNGLCLEARSTENCILPROC) \ + cb(glCreateProgram, PFNGLCREATEPROGRAMPROC) \ + cb(glCreateShader, PFNGLCREATESHADERPROC) \ + cb(glCheckFramebufferStatus, PFNGLCHECKFRAMEBUFFERSTATUSPROC) \ + cb(glColorMask, PFNGLCOLORMASKPROC) \ + cb(glCompressedTexSubImage2D, PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) \ + cb(glCompressedTexSubImage3D, PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) \ + cb(glCullFace, PFNGLCULLFACEPROC) \ + cb(glCompileShader, PFNGLCOMPILESHADERPROC) \ + cb(glCopyTexSubImage2D, PFNGLCOPYTEXSUBIMAGE2DPROC) \ + cb(glDeleteBuffers, PFNGLDELETEBUFFERSPROC) \ + cb(glDeleteFramebuffers, PFNGLDELETEFRAMEBUFFERSPROC) \ + cb(glDeleteProgram, PFNGLDELETEPROGRAMPROC) \ + cb(glDeleteQueries, PFNGLDELETEQUERIESPROC) \ + cb(glDeleteRenderbuffers, PFNGLDELETERENDERBUFFERSPROC) \ + cb(glDeleteSamplers, PFNGLDELETESAMPLERSPROC) \ + cb(glDeleteShader, PFNGLDELETESHADERPROC) \ + cb(glDeleteTextures, PFNGLDELETETEXTURESPROC) \ + cb(glDeleteVertexArrays, PFNGLDELETEVERTEXARRAYSPROC) \ + cb(glDepthFunc, PFNGLDEPTHFUNCPROC) \ + cb(glDepthMask, PFNGLDEPTHMASKPROC) \ + cb(glDisable, PFNGLDISABLEPROC) \ + cb(glDisableVertexAttribArray, PFNGLDISABLEVERTEXATTRIBARRAYPROC) \ + cb(glDrawArrays, PFNGLDRAWARRAYSPROC) \ + cb(glDrawArraysInstanced, PFNGLDRAWARRAYSINSTANCEDPROC) \ + cb(glDrawBuffers, PFNGLDRAWBUFFERSPROC) \ + cb(glDrawElements, PFNGLDRAWELEMENTSPROC) \ + cb(glDrawElementsInstanced, PFNGLDRAWELEMENTSINSTANCEDPROC) \ + cb(glEnable, PFNGLENABLEPROC) \ + cb(glEnableVertexAttribArray, PFNGLENABLEVERTEXATTRIBARRAYPROC) \ + cb(glEndQuery, PFNGLENDQUERYPROC) \ + cb(glFlush, PFNGLFLUSHPROC) \ + cb(glFramebufferRenderbuffer, PFNGLFRAMEBUFFERRENDERBUFFERPROC) \ + cb(glFramebufferTexture2D, PFNGLFRAMEBUFFERTEXTURE2DPROC) \ + cb(glFramebufferTextureLayer, PFNGLFRAMEBUFFERTEXTURELAYERPROC) \ + cb(glGenerateMipmap, PFNGLGENERATEMIPMAPPROC) \ + cb(glGenBuffers, PFNGLGENBUFFERSPROC) \ + cb(glGenFramebuffers, PFNGLGENFRAMEBUFFERSPROC) \ + cb(glGenRenderbuffers, PFNGLGENRENDERBUFFERSPROC) \ + cb(glGenQueries, PFNGLGENQUERIESPROC) \ + cb(glGenSamplers, PFNGLGENSAMPLERSPROC) \ + cb(glGenTextures, PFNGLGENTEXTURESPROC) \ + cb(glGenVertexArrays, PFNGLGENVERTEXARRAYSPROC) \ + cb(glGetActiveUniform, PFNGLGETACTIVEUNIFORMPROC) \ + cb(glGetBooleanv, PFNGLGETBOOLEANVPROC) \ + cb(glGetBufferParameteriv, PFNGLGETBUFFERPARAMETERIVPROC) \ + cb(glGetError, PFNGLGETERRORPROC) \ + cb(glGetFloatv, PFNGLGETFLOATVPROC) \ + cb(glGetIntegerv, PFNGLGETINTEGERVPROC) \ + cb(glGetProgramBinary, PFNGLGETPROGRAMBINARYPROC) \ + cb(glGetProgramiv, PFNGLGETPROGRAMIVPROC) \ + cb(glGetProgramInfoLog, PFNGLGETPROGRAMINFOLOGPROC) \ + cb(glGetQueryiv, PFNGLGETQUERYIVPROC) \ + cb(glGetQueryObjectuiv, PFNGLGETQUERYOBJECTUIVPROC) \ + cb(glGetShaderInfoLog, PFNGLGETSHADERINFOLOGPROC) \ + cb(glGetShaderiv, PFNGLGETSHADERIVPROC) \ + cb(glGetShaderSource, PFNGLGETSHADERSOURCEPROC) \ + cb(glGetString, PFNGLGETSTRINGPROC) \ + cb(glGetStringi, PFNGLGETSTRINGIPROC) \ + cb(glGetTexParameterfv, PFNGLGETTEXPARAMETERFVPROC) \ + cb(glGetTexParameteriv, PFNGLGETTEXPARAMETERIVPROC) \ + cb(glGetUniformfv, PFNGLGETUNIFORMFVPROC) \ + cb(glGetUniformiv, PFNGLGETUNIFORMIVPROC) \ + cb(glGetUniformLocation, PFNGLGETUNIFORMLOCATIONPROC) \ + cb(glIsEnabled, PFNGLISENABLEDPROC) \ + cb(glLineWidth, PFNGLLINEWIDTHPROC) \ + cb(glLinkProgram, PFNGLLINKPROGRAMPROC) \ + cb(glMapBufferRange, PFNGLMAPBUFFERRANGEPROC) \ + cb(glPixelStorei, PFNGLPIXELSTOREIPROC) \ + cb(glProgramBinary, PFNGLPROGRAMBINARYPROC) \ + cb(glProgramParameteri, PFNGLPROGRAMPARAMETERIPROC) \ + cb(glReadPixels, PFNGLREADPIXELSPROC) \ + cb(glRenderbufferStorage, PFNGLRENDERBUFFERSTORAGEPROC) \ + cb(glSamplerParameterf, PFNGLSAMPLERPARAMETERFPROC) \ + cb(glSamplerParameteri, PFNGLSAMPLERPARAMETERIPROC) \ + cb(glScissor, PFNGLSCISSORPROC) \ + cb(glShaderSource, PFNGLSHADERSOURCEPROC) \ + cb(glStencilFunc, PFNGLSTENCILFUNCPROC) \ + cb(glStencilFuncSeparate, PFNGLSTENCILFUNCSEPARATEPROC) \ + cb(glStencilOp, PFNGLSTENCILOPPROC) \ + cb(glStencilOpSeparate, PFNGLSTENCILOPSEPARATEPROC) \ + cb(glTexImage2D, PFNGLTEXIMAGE2DPROC) \ + cb(glTexImage3D, PFNGLTEXIMAGE3DPROC) \ + cb(glTexParameterf, PFNGLTEXPARAMETERFPROC) \ + cb(glTexParameteri, PFNGLTEXPARAMETERIPROC) \ + cb(glTexStorage2D, PFNGLTEXSTORAGE2DPROC) \ + cb(glTexStorage3D, PFNGLTEXSTORAGE3DPROC) \ + cb(glTexSubImage2D, PFNGLTEXSUBIMAGE2DPROC) \ + cb(glTexSubImage3D, PFNGLTEXSUBIMAGE3DPROC) \ + cb(glUniform1f, PFNGLUNIFORM1FPROC) \ + cb(glUniform1i, PFNGLUNIFORM1IPROC) \ + cb(glUniform1fv, PFNGLUNIFORM1FVPROC) \ + cb(glUniform1iv, PFNGLUNIFORM1IVPROC) \ + cb(glUniform2fv, PFNGLUNIFORM2FVPROC) \ + cb(glUniform2iv, PFNGLUNIFORM2IVPROC) \ + cb(glUniform3fv, PFNGLUNIFORM3FVPROC) \ + cb(glUniform3iv, PFNGLUNIFORM3IVPROC) \ + cb(glUniform4fv, PFNGLUNIFORM4FVPROC) \ + cb(glUniform4iv, PFNGLUNIFORM4IVPROC) \ + cb(glUniformMatrix4fv, PFNGLUNIFORMMATRIX4FVPROC) \ + cb(glUnmapBuffer, PFNGLUNMAPBUFFERPROC) \ + cb(glUseProgram, PFNGLUSEPROGRAMPROC) \ + cb(glValidateProgram, PFNGLVALIDATEPROGRAMPROC) \ + cb(glVertexAttrib4f, PFNGLVERTEXATTRIB4FPROC) \ + cb(glVertexAttribDivisor, PFNGLVERTEXATTRIBDIVISORPROC) \ + cb(glVertexAttribPointer, PFNGLVERTEXATTRIBPOINTERPROC) \ + cb(glVertexAttribIPointer, PFNGLVERTEXATTRIBIPOINTERPROC) \ + cb(glViewport, PFNGLVIEWPORTPROC) \ + +#endif diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Framebuffer.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Framebuffer.hpp new file mode 100644 index 000000000..dcfe84546 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/Framebuffer.hpp @@ -0,0 +1,39 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_VKFRAMEBUFFER_HPP +#define NAZARA_OPENGLRENDERER_VKFRAMEBUFFER_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class Framebuffer : public DeviceObject + { + friend DeviceObject; + + public: + Framebuffer() = default; + Framebuffer(const Framebuffer&) = delete; + Framebuffer(Framebuffer&&) = default; + ~Framebuffer() = default; + + Framebuffer& operator=(const Framebuffer&) = delete; + Framebuffer& operator=(Framebuffer&&) = delete; + + private: + static inline VkResult CreateHelper(Device& device, const VkFramebufferCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkFramebuffer* handle); + static inline void DestroyHelper(Device& device, VkFramebuffer handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_OPENGLRENDERER_VKFRAMEBUFFER_HPP diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Framebuffer.inl b/include/Nazara/OpenGLRenderer/Wrapper/Framebuffer.inl new file mode 100644 index 000000000..3656d27f8 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/Framebuffer.inl @@ -0,0 +1,24 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + namespace Vk + { + inline VkResult Framebuffer::CreateHelper(Device& device, const VkFramebufferCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkFramebuffer* handle) + { + return device.vkCreateFramebuffer(device, createInfo, allocator, handle); + } + + inline void Framebuffer::DestroyHelper(Device& device, VkFramebuffer handle, const VkAllocationCallbacks* allocator) + { + return device.vkDestroyFramebuffer(device, handle, allocator); + } + } +} + +#include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/GLContext.hpp b/include/Nazara/OpenGLRenderer/Wrapper/GLContext.hpp new file mode 100644 index 000000000..fba8d88ea --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/GLContext.hpp @@ -0,0 +1,52 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_CONTEXTIMPL_HPP +#define NAZARA_OPENGLRENDERER_CONTEXTIMPL_HPP + +#include +#include +#include + +namespace Nz::GL +{ + struct ContextParams + { + bool doubleBuffering = true; + unsigned int sampleCount = 1; + unsigned int bitsPerPixel = 32; + unsigned int depthBits = 24; + unsigned int stencilBits = 8; + }; + + class Loader; + + class GLContext + { + public: + GLContext() = default; + virtual ~GLContext(); + + virtual bool Activate() = 0; + + virtual bool Create(const ContextParams& params) = 0; + + virtual void EnableVerticalSync(bool enabled) = 0; + + bool LoadCoreFunctions(Loader& loader); + + virtual void SwapBuffers() = 0; + + private: +#define NAZARA_OPENGLRENDERER_FUNC(name, sig) sig name = nullptr; + NAZARA_OPENGLRENDERER_FOREACH_GLES_FUNC(NAZARA_OPENGLRENDERER_FUNC) +#undef NAZARA_OPENGLRENDERER_FUNC + }; +} + +#include + +#endif diff --git a/include/Nazara/OpenGLRenderer/Wrapper/GLContext.inl b/include/Nazara/OpenGLRenderer/Wrapper/GLContext.inl new file mode 100644 index 000000000..4e6fe854b --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/GLContext.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz::Vk +{ +} + +#include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Loader.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Loader.hpp new file mode 100644 index 000000000..ad48aa92e --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/Loader.hpp @@ -0,0 +1,34 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_LOADER_HPP +#define NAZARA_OPENGLRENDERER_LOADER_HPP + +#include +#include +#include + +namespace Nz::GL +{ + class GLContext; + + using GLFunction = int(*)(); + + class NAZARA_OPENGLRENDERER_API Loader + { + public: + Loader() = default; + virtual ~Loader(); + + virtual std::unique_ptr CreateContext() = 0; + + virtual GLFunction LoadFunction(const char* name) = 0; + }; +} + +#include + +#endif diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Loader.inl b/include/Nazara/OpenGLRenderer/Wrapper/Loader.inl new file mode 100644 index 000000000..3d062c487 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/Loader.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz::GL +{ +} + +#include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/ProgramPipeline.hpp b/include/Nazara/OpenGLRenderer/Wrapper/ProgramPipeline.hpp new file mode 100644 index 000000000..37d83bf40 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/ProgramPipeline.hpp @@ -0,0 +1,43 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_VKIMAGE_HPP +#define NAZARA_OPENGLRENDERER_VKIMAGE_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class Image : public DeviceObject + { + friend DeviceObject; + + public: + Image() = default; + Image(const Image&) = delete; + Image(Image&&) = default; + ~Image() = default; + + bool BindImageMemory(VkDeviceMemory memory, VkDeviceSize offset = 0); + + VkMemoryRequirements GetMemoryRequirements() const; + + Image& operator=(const Image&) = delete; + Image& operator=(Image&&) = delete; + + private: + static inline VkResult CreateHelper(Device& device, const VkImageCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkImage* handle); + static inline void DestroyHelper(Device& device, VkImage handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_OPENGLRENDERER_VKIMAGE_HPP diff --git a/include/Nazara/OpenGLRenderer/Wrapper/ProgramPipeline.inl b/include/Nazara/OpenGLRenderer/Wrapper/ProgramPipeline.inl new file mode 100644 index 000000000..cbc7bcb77 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/ProgramPipeline.inl @@ -0,0 +1,47 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + namespace Vk + { + inline bool Image::BindImageMemory(VkDeviceMemory memory, VkDeviceSize offset) + { + m_lastErrorCode = m_device->vkBindImageMemory(*m_device, m_handle, memory, offset); + if (m_lastErrorCode != VK_SUCCESS) + { + NazaraError("Failed to bind image memory: " + TranslateOpenGLError(m_lastErrorCode)); + return false; + } + + return true; + } + + inline VkMemoryRequirements Image::GetMemoryRequirements() const + { + NazaraAssert(IsValid(), "Invalid image"); + + VkMemoryRequirements memoryRequirements; + m_device->vkGetImageMemoryRequirements(*m_device, m_handle, &memoryRequirements); + + return memoryRequirements; + } + + inline VkResult Image::CreateHelper(Device& device, const VkImageCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkImage* handle) + { + return device.vkCreateImage(device, createInfo, allocator, handle); + } + + inline void Image::DestroyHelper(Device& device, VkImage handle, const VkAllocationCallbacks* allocator) + { + return device.vkDestroyImage(device, handle, allocator); + } + } +} + +#include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/RenderBuffer.hpp b/include/Nazara/OpenGLRenderer/Wrapper/RenderBuffer.hpp new file mode 100644 index 000000000..1dfbd2b62 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/RenderBuffer.hpp @@ -0,0 +1,47 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_VKFENCE_HPP +#define NAZARA_OPENGLRENDERER_VKFENCE_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class Fence : public DeviceObject + { + friend DeviceObject; + + public: + Fence() = default; + Fence(const Fence&) = delete; + Fence(Fence&&) = default; + ~Fence() = default; + + using DeviceObject::Create; + inline bool Create(Device& device, VkFenceCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + + inline bool Reset(); + + inline bool Wait(); + inline bool Wait(UInt64 timeout, bool* didTimeout = nullptr); + + Fence& operator=(const Fence&) = delete; + Fence& operator=(Fence&&) = delete; + + private: + static inline VkResult CreateHelper(Device& device, const VkFenceCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkFence* handle); + static inline void DestroyHelper(Device& device, VkFence handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_OPENGLRENDERER_VKFENCE_HPP diff --git a/include/Nazara/OpenGLRenderer/Wrapper/RenderBuffer.inl b/include/Nazara/OpenGLRenderer/Wrapper/RenderBuffer.inl new file mode 100644 index 000000000..855472b58 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/RenderBuffer.inl @@ -0,0 +1,68 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + namespace Vk + { + inline bool Fence::Create(Device& device, VkFenceCreateFlags flags, const VkAllocationCallbacks* allocator) + { + VkFenceCreateInfo createInfo = + { + VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, + nullptr, + flags + }; + + return Create(device, createInfo, allocator); + } + + inline bool Fence::Reset() + { + m_lastErrorCode = m_device->vkResetFences(*m_device, 1U, &m_handle); + if (m_lastErrorCode != VK_SUCCESS) + { + NazaraError("Failed to reset fence: " + TranslateOpenGLError(m_lastErrorCode)); + return false; + } + + return true; + } + + inline bool Fence::Wait() + { + return Wait(std::numeric_limits::max()); + } + + inline bool Fence::Wait(UInt64 timeout, bool* didTimeout) + { + m_lastErrorCode = m_device->vkWaitForFences(*m_device, 1U, &m_handle, VK_TRUE, timeout); + if (m_lastErrorCode != VK_SUCCESS && m_lastErrorCode != VK_TIMEOUT) + { + NazaraError("Failed to wait for fence: " + TranslateOpenGLError(m_lastErrorCode)); + return false; + } + + if (didTimeout) + *didTimeout = (m_lastErrorCode == VK_TIMEOUT); + + return true; + } + + inline VkResult Fence::CreateHelper(Device& device, const VkFenceCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkFence* handle) + { + return device.vkCreateFence(device, createInfo, allocator, handle); + } + + inline void Fence::DestroyHelper(Device& device, VkFence handle, const VkAllocationCallbacks* allocator) + { + return device.vkDestroyFence(device, handle, allocator); + } + } +} + +#include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Sampler.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Sampler.hpp new file mode 100644 index 000000000..368511917 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/Sampler.hpp @@ -0,0 +1,39 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_VKSAMPLER_HPP +#define NAZARA_OPENGLRENDERER_VKSAMPLER_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class Sampler : public DeviceObject + { + friend DeviceObject; + + public: + Sampler() = default; + Sampler(const Sampler&) = delete; + Sampler(Sampler&&) = default; + ~Sampler() = default; + + Sampler& operator=(const Sampler&) = delete; + Sampler& operator=(Sampler&&) = delete; + + private: + static inline VkResult CreateHelper(Device& device, const VkSamplerCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSampler* handle); + static inline void DestroyHelper(Device& device, VkSampler handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_OPENGLRENDERER_VKSAMPLER_HPP diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Sampler.inl b/include/Nazara/OpenGLRenderer/Wrapper/Sampler.inl new file mode 100644 index 000000000..ab1407c55 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/Sampler.inl @@ -0,0 +1,24 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + namespace Vk + { + inline VkResult Sampler::CreateHelper(Device& device, const VkSamplerCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSampler* handle) + { + return device.vkCreateSampler(device, createInfo, allocator, handle); + } + + inline void Sampler::DestroyHelper(Device& device, VkSampler handle, const VkAllocationCallbacks* allocator) + { + return device.vkDestroySampler(device, handle, allocator); + } + } +} + +#include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Shader.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Shader.hpp new file mode 100644 index 000000000..d0613f1f3 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/Shader.hpp @@ -0,0 +1,42 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_VKSHADERMODULE_HPP +#define NAZARA_OPENGLRENDERER_VKSHADERMODULE_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class ShaderModule : public DeviceObject + { + friend DeviceObject; + + public: + ShaderModule() = default; + ShaderModule(const ShaderModule&) = delete; + ShaderModule(ShaderModule&&) = default; + ~ShaderModule() = default; + + using DeviceObject::Create; + inline bool Create(Device& device, const UInt32* code, std::size_t size, VkShaderModuleCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + + ShaderModule& operator=(const ShaderModule&) = delete; + ShaderModule& operator=(ShaderModule&&) = delete; + + private: + static inline VkResult CreateHelper(Device& device, const VkShaderModuleCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkShaderModule* handle); + static inline void DestroyHelper(Device& device, VkShaderModule handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_OPENGLRENDERER_VKSHADERMODULE_HPP diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Shader.inl b/include/Nazara/OpenGLRenderer/Wrapper/Shader.inl new file mode 100644 index 000000000..1194d21f6 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/Shader.inl @@ -0,0 +1,38 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + namespace Vk + { + inline bool ShaderModule::Create(Device& device, const UInt32* code, std::size_t size, VkShaderModuleCreateFlags flags, const VkAllocationCallbacks* allocator) + { + VkShaderModuleCreateInfo createInfo = + { + VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO, + nullptr, + flags, + size, + code + }; + + return Create(device, createInfo, allocator); + } + + inline VkResult ShaderModule::CreateHelper(Device& device, const VkShaderModuleCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkShaderModule* handle) + { + return device.vkCreateShaderModule(device, createInfo, allocator, handle); + } + + inline void ShaderModule::DestroyHelper(Device& device, VkShaderModule handle, const VkAllocationCallbacks* allocator) + { + return device.vkDestroyShaderModule(device, handle, allocator); + } + } +} + +#include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Texture.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Texture.hpp new file mode 100644 index 000000000..6fc242f3e --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/Texture.hpp @@ -0,0 +1,43 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_VKPIPELINELAYOUT_HPP +#define NAZARA_OPENGLRENDERER_VKPIPELINELAYOUT_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class PipelineLayout : public DeviceObject + { + friend DeviceObject; + + public: + PipelineLayout() = default; + PipelineLayout(const PipelineLayout&) = delete; + PipelineLayout(PipelineLayout&&) = default; + ~PipelineLayout() = default; + + using DeviceObject::Create; + bool Create(Device& device, VkDescriptorSetLayout layout, VkPipelineLayoutCreateFlags flags = 0); + bool Create(Device& device, UInt32 layoutCount, const VkDescriptorSetLayout* layouts, VkPipelineLayoutCreateFlags flags = 0); + + PipelineLayout& operator=(const PipelineLayout&) = delete; + PipelineLayout& operator=(PipelineLayout&&) = delete; + + private: + static inline VkResult CreateHelper(Device& device, const VkPipelineLayoutCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkPipelineLayout* handle); + static inline void DestroyHelper(Device& device, VkPipelineLayout handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_OPENGLRENDERER_VKPIPELINELAYOUT_HPP diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Texture.inl b/include/Nazara/OpenGLRenderer/Wrapper/Texture.inl new file mode 100644 index 000000000..cd86f80a3 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/Texture.inl @@ -0,0 +1,44 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + namespace Vk + { + inline bool PipelineLayout::Create(Device& device, VkDescriptorSetLayout layout, VkPipelineLayoutCreateFlags flags) + { + return Create(device, 1U, &layout, flags); + } + + inline bool PipelineLayout::Create(Device& device, UInt32 layoutCount, const VkDescriptorSetLayout* layouts, VkPipelineLayoutCreateFlags flags) + { + VkPipelineLayoutCreateInfo createInfo = { + VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, + nullptr, + flags, + layoutCount, + layouts, + 0U, + nullptr + }; + + return Create(device, createInfo); + } + + inline VkResult PipelineLayout::CreateHelper(Device& device, const VkPipelineLayoutCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkPipelineLayout* handle) + { + return device.vkCreatePipelineLayout(device, createInfo, allocator, handle); + } + + inline void PipelineLayout::DestroyHelper(Device& device, VkPipelineLayout handle, const VkAllocationCallbacks* allocator) + { + return device.vkDestroyPipelineLayout(device, handle, allocator); + } + } +} + +#include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/VertexArray.hpp b/include/Nazara/OpenGLRenderer/Wrapper/VertexArray.hpp new file mode 100644 index 000000000..df762b109 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/VertexArray.hpp @@ -0,0 +1,39 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_VKIMAGEVIEW_HPP +#define NAZARA_OPENGLRENDERER_VKIMAGEVIEW_HPP + +#include +#include + +namespace Nz +{ + namespace Vk + { + class ImageView : public DeviceObject + { + friend DeviceObject; + + public: + ImageView() = default; + ImageView(const ImageView&) = delete; + ImageView(ImageView&&) = default; + ~ImageView() = default; + + ImageView& operator=(const ImageView&) = delete; + ImageView& operator=(ImageView&&) = delete; + + private: + static inline VkResult CreateHelper(Device& device, const VkImageViewCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkImageView* handle); + static inline void DestroyHelper(Device& device, VkImageView handle, const VkAllocationCallbacks* allocator); + }; + } +} + +#include + +#endif // NAZARA_OPENGLRENDERER_VKIMAGEVIEW_HPP diff --git a/include/Nazara/OpenGLRenderer/Wrapper/VertexArray.inl b/include/Nazara/OpenGLRenderer/Wrapper/VertexArray.inl new file mode 100644 index 000000000..29ae8e968 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/VertexArray.inl @@ -0,0 +1,24 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + namespace Vk + { + inline VkResult ImageView::CreateHelper(Device& device, const VkImageViewCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkImageView* handle) + { + return device.vkCreateImageView(device, createInfo, allocator, handle); + } + + inline void ImageView::DestroyHelper(Device& device, VkImageView handle, const VkAllocationCallbacks* allocator) + { + return device.vkDestroyImageView(device, handle, allocator); + } + } +} + +#include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.hpp new file mode 100644 index 000000000..553600ce4 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.hpp @@ -0,0 +1,71 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_WGLCONTEXT_HPP +#define NAZARA_OPENGLRENDERER_WGLCONTEXT_HPP + +#include +#include +#include +#include +#include +#include +#include +#include + +#undef WIN32_LEAN_AND_MEAN //< Redefined by OpenGL header (ty Khronos) +#include + +namespace Nz::GL +{ + class WGLLoader; + + class WGLContext : public GLContext + { + public: + WGLContext(WGLLoader& loader); + WGLContext(const WGLContext&) = delete; + WGLContext(WGLContext&&) = delete; + ~WGLContext(); + + bool Activate() override; + + bool Create(const ContextParams& params) override; + void Destroy(); + + void EnableVerticalSync(bool enabled) override; + + void SwapBuffers() override; + + WGLContext& operator=(const WGLContext&) = delete; + WGLContext& operator=(WGLContext&&) = delete; + + private: + void Desactivate(); + bool LoadWGLExt(); + bool SetPixelFormat(const ContextParams& params); + +#define NAZARA_OPENGLRENDERER_FUNC(name, sig) +#define NAZARA_OPENGLRENDERER_EXT_BEGIN(ext) +#define NAZARA_OPENGLRENDERER_EXT_END() +#define NAZARA_OPENGLRENDERER_EXT_FUNC(name, sig) sig name = nullptr; + NAZARA_OPENGLRENDERER_FOREACH_WGL_FUNC(NAZARA_OPENGLRENDERER_FUNC, NAZARA_OPENGLRENDERER_EXT_BEGIN, NAZARA_OPENGLRENDERER_EXT_END, NAZARA_OPENGLRENDERER_EXT_FUNC) +#undef NAZARA_OPENGLRENDERER_EXT_BEGIN +#undef NAZARA_OPENGLRENDERER_EXT_END +#undef NAZARA_OPENGLRENDERER_EXT_FUNC +#undef NAZARA_OPENGLRENDERER_FUNC + + std::unordered_set m_supportedExtensions; + WGLLoader& m_loader; + HDC m_deviceContext; + HGLRC m_handle; + HWNDHandle m_window; + }; +} + +#include + +#endif diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.inl b/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.inl new file mode 100644 index 000000000..70a9d82df --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz::Vk +{ +} + +#include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLFunctions.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLFunctions.hpp new file mode 100644 index 000000000..d21480e96 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLFunctions.hpp @@ -0,0 +1,48 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_WGLFUNCTIONS_HPP +#define NAZARA_OPENGLRENDERER_WGLFUNCTIONS_HPP + +#include +#include +#include + +#define NAZARA_OPENGLRENDERER_FOREACH_WGL_FUNC(func, extBegin, extEnd, extFunc) \ + func(wglCreateContext, PFNWGLCREATECONTEXTPROC) \ + func(wglDeleteContext, PFNWGLDELETECONTEXTPROC) \ + func(wglGetCurrentContext, PFNWGLGETCURRENTCONTEXTPROC) \ + func(wglGetProcAddress, PFNWGLGETPROCADDRESSPROC) \ + func(wglMakeCurrent, PFNWGLMAKECURRENTPROC) \ + func(wglShareLists, PFNWGLSHARELISTSPROC) \ + \ + extBegin(WGL_ARB_create_context) \ + extFunc(wglCreateContextAttribsARB, PFNWGLCREATECONTEXTATTRIBSARBPROC) \ + extEnd() \ + \ + extBegin(WGL_ARB_pixel_format) \ + extFunc(wglChoosePixelFormatARB, PFNWGLCHOOSEPIXELFORMATARBPROC) \ + extEnd() \ + \ + extBegin(WGL_EXT_pixel_format) \ + extFunc(wglChoosePixelFormatEXT, PFNWGLCHOOSEPIXELFORMATEXTPROC) \ + extEnd() \ + \ + extBegin(WGL_ARB_extensions_string) \ + extFunc(wglGetExtensionsStringARB, PFNWGLGETEXTENSIONSSTRINGARBPROC) \ + extEnd() \ + \ + extBegin(WGL_EXT_extensions_string) \ + extFunc(wglGetExtensionsStringEXT, PFNWGLGETEXTENSIONSSTRINGEXTPROC) \ + extEnd() \ + +#define NAZARA_OPENGLRENDERER_FOREACH_GDI32_FUNC(func) \ + func(ChoosePixelFormat, PFNCHOOSEPIXELFORMATPROC) \ + func(DescribePixelFormat, PFNDESCRIBEPIXELFORMATPROC) \ + func(SetPixelFormat, PFNSETPIXELFORMATPROC) \ + func(SwapBuffers, PFNSWAPBUFFERSPROC) \ + +#endif diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.hpp new file mode 100644 index 000000000..4a5b6a57a --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.hpp @@ -0,0 +1,49 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_WGLLOADER_HPP +#define NAZARA_OPENGLRENDERER_WGLLOADER_HPP + +#include +#include +#include +#include + +#undef WIN32_LEAN_AND_MEAN //< Redefined by OpenGL header (ty Khronos) +#include + +namespace Nz::GL +{ + class WGLLoader : public Loader + { + public: + WGLLoader(DynLib& openglLib); + ~WGLLoader() = default; + + std::unique_ptr CreateContext() override; + + GLFunction LoadFunction(const char* name) override; + +#define NAZARA_OPENGLRENDERER_FUNC(name, sig) sig name = nullptr; +#define NAZARA_OPENGLRENDERER_EXT_BEGIN(ext) +#define NAZARA_OPENGLRENDERER_EXT_END() +#define NAZARA_OPENGLRENDERER_EXT_FUNC(name, sig) + NAZARA_OPENGLRENDERER_FOREACH_GDI32_FUNC(NAZARA_OPENGLRENDERER_FUNC) + NAZARA_OPENGLRENDERER_FOREACH_WGL_FUNC(NAZARA_OPENGLRENDERER_FUNC, NAZARA_OPENGLRENDERER_EXT_BEGIN, NAZARA_OPENGLRENDERER_EXT_END, NAZARA_OPENGLRENDERER_EXT_FUNC) +#undef NAZARA_OPENGLRENDERER_EXT_BEGIN +#undef NAZARA_OPENGLRENDERER_EXT_END +#undef NAZARA_OPENGLRENDERER_EXT_FUNC +#undef NAZARA_OPENGLRENDERER_FUNC + + private: + DynLib m_gdi32Lib; + DynLib& m_opengl32Lib; + }; +} + +#include + +#endif diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.inl b/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.inl new file mode 100644 index 000000000..bd8092bb7 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz::Vk +{ +} + +#include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Win32/Win32Helper.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Win32/Win32Helper.hpp new file mode 100644 index 000000000..2bfe28d06 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/Win32/Win32Helper.hpp @@ -0,0 +1,26 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_WIN32HELPER_HPP +#define NAZARA_OPENGLRENDERER_WIN32HELPER_HPP + +#include +#include + +namespace Nz::GL +{ + struct WindowDeleter + { + void operator()(HWND handle) const + { + DestroyWindow(handle); + } + }; + + using HWNDHandle = std::unique_ptr, WindowDeleter>; +} + +#endif diff --git a/src/Nazara/OpenGLRenderer/Debug/NewOverload.cpp b/src/Nazara/OpenGLRenderer/Debug/NewOverload.cpp new file mode 100644 index 000000000..5beaf6588 --- /dev/null +++ b/src/Nazara/OpenGLRenderer/Debug/NewOverload.cpp @@ -0,0 +1,31 @@ +// 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_OPENGLRENDERER_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_OPENGLRENDERER_MANAGE_MEMORY diff --git a/src/Nazara/OpenGLRenderer/Export.cpp b/src/Nazara/OpenGLRenderer/Export.cpp new file mode 100644 index 000000000..56d1fdf34 --- /dev/null +++ b/src/Nazara/OpenGLRenderer/Export.cpp @@ -0,0 +1,15 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +extern "C" +{ + NAZARA_EXPORT Nz::RendererImpl* NazaraRenderer_Instantiate() + { + std::unique_ptr renderer = std::make_unique(); + return renderer.release(); + } +} diff --git a/src/Nazara/OpenGLRenderer/OpenGL.cpp b/src/Nazara/OpenGLRenderer/OpenGL.cpp new file mode 100644 index 000000000..7c24521e4 --- /dev/null +++ b/src/Nazara/OpenGLRenderer/OpenGL.cpp @@ -0,0 +1,72 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +#ifdef NAZARA_PLATFORM_WINDOWS +#include +#endif + +#include + +namespace Nz +{ + struct OpenGLImpl + { + DynLib opengl32Lib; + }; + + static std::unique_ptr s_impl; + + bool OpenGL::Initialize() + { + if (s_impl) + return true; + + auto impl = std::make_unique(); + if (!impl->opengl32Lib.Load("opengl32" NAZARA_DYNLIB_EXTENSION)) + { + NazaraError("Failed to load opengl32 library, is OpenGL installed on your system?"); + return false; + } + + std::unique_ptr loader; + +#ifdef NAZARA_PLATFORM_WINDOWS + try + { + loader = std::make_unique(impl->opengl32Lib); + } + catch (const std::exception& e) + { + NazaraWarning(std::string("Failed to load WGL: ") + e.what()); + } +#endif + + if (!loader) + { + NazaraError("Failed to initialize OpenGL loader"); + return false; + } + + s_impl = std::move(impl); + return true; + } + + bool OpenGL::IsInitialized() + { + return s_impl != nullptr; + } + + void OpenGL::Uninitialize() + { + if (!s_impl) + return; + + s_impl.reset(); + } +} + diff --git a/src/Nazara/OpenGLRenderer/OpenGLBuffer.cpp b/src/Nazara/OpenGLRenderer/OpenGLBuffer.cpp new file mode 100644 index 000000000..f77ab4635 --- /dev/null +++ b/src/Nazara/OpenGLRenderer/OpenGLBuffer.cpp @@ -0,0 +1,151 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#if 0 + +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + OpenGLBuffer::~OpenGLBuffer() + { + vmaDestroyBuffer(m_device.GetMemoryAllocator(), m_buffer, m_allocation); + } + + bool OpenGLBuffer::Fill(const void* data, UInt64 offset, UInt64 size) + { + void* ptr = Map(BufferAccess_WriteOnly, offset, size); + if (!ptr) + return false; + + Nz::CallOnExit unmapOnExit([this]() { Unmap(); }); + + std::memcpy(ptr, data, size); + + return true; + } + + bool OpenGLBuffer::Initialize(UInt64 size, BufferUsageFlags usage) + { + m_size = size; + m_usage = usage; + + VkBufferUsageFlags bufferUsage = ToOpenGL(m_type); + + if ((usage & BufferUsage_DirectMapping) == 0) + bufferUsage |= VK_BUFFER_USAGE_TRANSFER_DST_BIT; + + VkBufferCreateInfo createInfo = {}; + createInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; + createInfo.size = size; + createInfo.usage = bufferUsage; + + VmaAllocationCreateInfo allocInfo = {}; + if (usage & BufferUsage_DeviceLocal) + { + if (usage & BufferUsage_DirectMapping) + allocInfo.usage = VMA_MEMORY_USAGE_CPU_TO_GPU; + else + allocInfo.usage = VMA_MEMORY_USAGE_GPU_ONLY; + } + else + allocInfo.usage = VMA_MEMORY_USAGE_CPU_ONLY; + + if (usage & BufferUsage_PersistentMapping) + allocInfo.flags |= VMA_ALLOCATION_CREATE_MAPPED_BIT; + + VkResult result = vmaCreateBuffer(m_device.GetMemoryAllocator(), &createInfo, &allocInfo, &m_buffer, &m_allocation, nullptr); + if (result != VK_SUCCESS) + { + NazaraError("Failed to allocate buffer: " + TranslateOpenGLError(result)); + return false; + } + + return true; + } + + UInt64 OpenGLBuffer::GetSize() const + { + return m_size; + } + + DataStorage OpenGLBuffer::GetStorage() const + { + return DataStorage_Hardware; + } + + void* OpenGLBuffer::Map(BufferAccess /*access*/, UInt64 offset, UInt64 size) + { + if (m_usage & BufferUsage_DirectMapping) + { + void* mappedPtr; + VkResult result = vmaMapMemory(m_device.GetMemoryAllocator(), m_allocation, &mappedPtr); + if (result != VK_SUCCESS) + { + NazaraError("Failed to map buffer: " + TranslateOpenGLError(result)); + return nullptr; + } + + return static_cast(mappedPtr) + offset; + } + else + { + VkBufferCreateInfo createInfo = {}; + createInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; + createInfo.size = size; + createInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT; + + VmaAllocationCreateInfo allocInfo = {}; + allocInfo.flags = VMA_ALLOCATION_CREATE_MAPPED_BIT; + allocInfo.usage = VMA_MEMORY_USAGE_CPU_TO_GPU; + + VmaAllocationInfo allocationInfo; + + VkResult result = vmaCreateBuffer(m_device.GetMemoryAllocator(), &createInfo, &allocInfo, &m_stagingBuffer, &m_stagingAllocation, &allocationInfo); + if (result != VK_SUCCESS) + { + NazaraError("Failed to allocate staging buffer: " + TranslateOpenGLError(result)); + return nullptr; + } + + return allocationInfo.pMappedData; + } + } + + bool OpenGLBuffer::Unmap() + { + if (m_usage & BufferUsage_DirectMapping) + { + vmaUnmapMemory(m_device.GetMemoryAllocator(), m_allocation); + return true; + } + else + { + Vk::AutoCommandBuffer copyCommandBuffer = m_device.AllocateCommandBuffer(QueueType::Transfer); + if (!copyCommandBuffer->Begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT)) + return false; + + copyCommandBuffer->CopyBuffer(m_stagingBuffer, m_buffer, m_size); + if (!copyCommandBuffer->End()) + return false; + + Vk::QueueHandle transferQueue = m_device.GetQueue(m_device.GetDefaultFamilyIndex(QueueType::Transfer), 0); + if (!transferQueue.Submit(copyCommandBuffer)) + return false; + + transferQueue.WaitIdle(); + + vmaDestroyBuffer(m_device.GetMemoryAllocator(), m_stagingBuffer, m_stagingAllocation); + return true; + } + } +} + +#endif diff --git a/src/Nazara/OpenGLRenderer/OpenGLCommandBuffer.cpp b/src/Nazara/OpenGLRenderer/OpenGLCommandBuffer.cpp new file mode 100644 index 000000000..41bf3f3b1 --- /dev/null +++ b/src/Nazara/OpenGLRenderer/OpenGLCommandBuffer.cpp @@ -0,0 +1,14 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#if 0 + +#include +#include + +namespace Nz +{ +} + +#endif diff --git a/src/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.cpp b/src/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.cpp new file mode 100644 index 000000000..4e17054be --- /dev/null +++ b/src/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.cpp @@ -0,0 +1,189 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#if 0 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + void OpenGLCommandBufferBuilder::BeginDebugRegion(const std::string_view& regionName, const Nz::Color& color) + { + // Ensure \0 at the end of string + StackArray regionNameEOS = NazaraStackArrayNoInit(char, regionName.size() + 1); + std::memcpy(regionNameEOS.data(), regionName.data(), regionName.size()); + regionNameEOS[regionName.size()] = '\0'; + + m_commandBuffer.BeginDebugRegion(regionNameEOS.data(), color); + } + + void OpenGLCommandBufferBuilder::BeginRenderPass(const Framebuffer& framebuffer, const RenderPass& renderPass, Nz::Recti renderRect, std::initializer_list clearValues) + { + const OpenGLRenderPass& vkRenderPass = static_cast(renderPass); + + const Vk::Framebuffer& vkFramebuffer = [&] () -> const Vk::Framebuffer& + { + const OpenGLFramebuffer& vkFramebuffer = static_cast(framebuffer); + switch (vkFramebuffer.GetType()) + { + case OpenGLFramebuffer::Type::Multiple: + { + const OpenGLMultipleFramebuffer& vkMultipleFramebuffer = static_cast(vkFramebuffer); + m_framebufferCount = std::max(m_framebufferCount, vkMultipleFramebuffer.GetFramebufferCount()); + return vkMultipleFramebuffer.GetFramebuffer(m_imageIndex); + } + + case OpenGLFramebuffer::Type::Single: + return static_cast(vkFramebuffer).GetFramebuffer(); + } + + throw std::runtime_error("Unhandled framebuffer type " + std::to_string(UnderlyingCast(vkFramebuffer.GetType()))); + }(); + + VkRect2D renderArea; + renderArea.offset.x = renderRect.x; + renderArea.offset.y = renderRect.y; + renderArea.extent.width = renderRect.width; + renderArea.extent.height = renderRect.height; + + StackArray vkClearValues = NazaraStackArray(VkClearValue, clearValues.size()); + + std::size_t index = 0; + for (const ClearValues& values : clearValues) + { + auto& vkValues = vkClearValues[index]; + + if (PixelFormatInfo::GetContent(vkRenderPass.GetAttachmentFormat(index)) == PixelFormatContent_ColorRGBA) + { + vkValues.color.float32[0] = values.color.r / 255.f; + vkValues.color.float32[1] = values.color.g / 255.f; + vkValues.color.float32[2] = values.color.b / 255.f; + vkValues.color.float32[3] = values.color.a / 255.f; + } + else + { + vkValues.depthStencil.depth = values.depth; + vkValues.depthStencil.stencil = values.stencil; + } + + index++; + } + + VkRenderPassBeginInfo beginInfo = { VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO }; + beginInfo.renderPass = vkRenderPass.GetRenderPass(); + beginInfo.framebuffer = vkFramebuffer; + beginInfo.renderArea.offset.x = renderRect.x; + beginInfo.renderArea.offset.y = renderRect.y; + beginInfo.renderArea.extent.width = renderRect.width; + beginInfo.renderArea.extent.height = renderRect.height; + beginInfo.clearValueCount = vkClearValues.size(); + beginInfo.pClearValues = vkClearValues.data(); + + m_commandBuffer.BeginRenderPass(beginInfo); + + m_currentRenderPass = &vkRenderPass; + } + + void OpenGLCommandBufferBuilder::BindIndexBuffer(Nz::AbstractBuffer* indexBuffer, UInt64 offset) + { + OpenGLBuffer& vkBuffer = *static_cast(indexBuffer); + + m_commandBuffer.BindIndexBuffer(vkBuffer.GetBuffer(), offset, VK_INDEX_TYPE_UINT16); //< Fuck me right? + } + + void OpenGLCommandBufferBuilder::BindPipeline(const RenderPipeline& pipeline) + { + if (!m_currentRenderPass) + throw std::runtime_error("BindPipeline must be called in a RenderPass"); + + const OpenGLRenderPipeline& vkBinding = static_cast(pipeline); + + m_commandBuffer.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, vkBinding.Get(m_currentRenderPass->GetRenderPass())); + } + + void OpenGLCommandBufferBuilder::BindShaderBinding(const ShaderBinding& binding) + { + const OpenGLShaderBinding& vkBinding = static_cast(binding); + + const OpenGLRenderPipelineLayout& pipelineLayout = vkBinding.GetOwner(); + + m_commandBuffer.BindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout.GetPipelineLayout(), 0U, vkBinding.GetDescriptorSet()); + } + + void OpenGLCommandBufferBuilder::BindVertexBuffer(UInt32 binding, Nz::AbstractBuffer* vertexBuffer, UInt64 offset) + { + OpenGLBuffer& vkBuffer = *static_cast(vertexBuffer); + + m_commandBuffer.BindVertexBuffer(binding, vkBuffer.GetBuffer(), offset); + } + + void OpenGLCommandBufferBuilder::CopyBuffer(const RenderBufferView& source, const RenderBufferView& target, UInt64 size, UInt64 sourceOffset, UInt64 targetOffset) + { + OpenGLBuffer& sourceBuffer = *static_cast(source.GetBuffer()); + OpenGLBuffer& targetBuffer = *static_cast(target.GetBuffer()); + + m_commandBuffer.CopyBuffer(sourceBuffer.GetBuffer(), targetBuffer.GetBuffer(), size, sourceOffset + source.GetOffset(), targetOffset + target.GetOffset()); + } + + void OpenGLCommandBufferBuilder::CopyBuffer(const UploadPool::Allocation& allocation, const RenderBufferView& target, UInt64 size, UInt64 sourceOffset, UInt64 targetOffset) + { + const auto& vkAllocation = static_cast(allocation); + OpenGLBuffer& targetBuffer = *static_cast(target.GetBuffer()); + + m_commandBuffer.CopyBuffer(vkAllocation.buffer, targetBuffer.GetBuffer(), size, vkAllocation.offset + sourceOffset, target.GetOffset() + targetOffset); + } + + void OpenGLCommandBufferBuilder::Draw(UInt32 vertexCount, UInt32 instanceCount, UInt32 firstVertex, UInt32 firstInstance) + { + m_commandBuffer.Draw(vertexCount, instanceCount, firstVertex, firstInstance); + } + + void OpenGLCommandBufferBuilder::DrawIndexed(UInt32 indexCount, UInt32 instanceCount, UInt32 firstVertex, UInt32 firstInstance) + { + m_commandBuffer.DrawIndexed(indexCount, instanceCount, firstVertex, 0, firstInstance); + } + + void OpenGLCommandBufferBuilder::EndDebugRegion() + { + m_commandBuffer.EndDebugRegion(); + } + + void OpenGLCommandBufferBuilder::EndRenderPass() + { + m_commandBuffer.EndRenderPass(); + m_currentRenderPass = nullptr; + } + + void OpenGLCommandBufferBuilder::PreTransferBarrier() + { + m_commandBuffer.MemoryBarrier(VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0U, VK_ACCESS_TRANSFER_READ_BIT); + } + + void OpenGLCommandBufferBuilder::PostTransferBarrier() + { + m_commandBuffer.MemoryBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_UNIFORM_READ_BIT); + } + + void OpenGLCommandBufferBuilder::SetScissor(Nz::Recti scissorRegion) + { + m_commandBuffer.SetScissor(scissorRegion); + } + + void OpenGLCommandBufferBuilder::SetViewport(Nz::Recti viewportRegion) + { + m_commandBuffer.SetViewport(Nz::Rectf(viewportRegion), 0.f, 1.f); + } +} + +#endif diff --git a/src/Nazara/OpenGLRenderer/OpenGLCommandPool.cpp b/src/Nazara/OpenGLRenderer/OpenGLCommandPool.cpp new file mode 100644 index 000000000..9e13ed935 --- /dev/null +++ b/src/Nazara/OpenGLRenderer/OpenGLCommandPool.cpp @@ -0,0 +1,42 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#if 0 + +#include +#include +#include +#include +#include + +namespace Nz +{ + std::unique_ptr OpenGLCommandPool::BuildCommandBuffer(const std::function& callback) + { + std::vector commandBuffers; + auto BuildCommandBuffer = [&](std::size_t imageIndex) + { + Vk::AutoCommandBuffer& commandBuffer = commandBuffers.emplace_back(m_commandPool.AllocateCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY)); + + if (!commandBuffer->Begin(VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT)) + throw std::runtime_error("failed to begin command buffer: " + TranslateOpenGLError(commandBuffer->GetLastErrorCode())); + + OpenGLCommandBufferBuilder builder(commandBuffer.Get(), imageIndex); + callback(builder); + + if (!commandBuffer->End()) + throw std::runtime_error("failed to build command buffer: " + TranslateOpenGLError(commandBuffer->GetLastErrorCode())); + + return builder.GetMaxFramebufferCount(); + }; + + std::size_t maxFramebufferCount = BuildCommandBuffer(0); + for (std::size_t i = 1; i < maxFramebufferCount; ++i) + BuildCommandBuffer(i); + + return std::make_unique(std::move(commandBuffers)); + } +} + +#endif diff --git a/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp b/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp new file mode 100644 index 000000000..37c7ce0cf --- /dev/null +++ b/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp @@ -0,0 +1,64 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#if 0 + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + OpenGLDevice::~OpenGLDevice() = default; + + std::unique_ptr OpenGLDevice::InstantiateBuffer(BufferType type) + { + return std::make_unique(*this, type); + } + + std::unique_ptr OpenGLDevice::InstantiateCommandPool(QueueType queueType) + { + return std::make_unique(*this, queueType); + } + + std::unique_ptr OpenGLDevice::InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) + { + return std::make_unique(*this, std::move(pipelineInfo)); + } + + std::shared_ptr OpenGLDevice::InstantiateRenderPipelineLayout(RenderPipelineLayoutInfo pipelineLayoutInfo) + { + auto pipelineLayout = std::make_shared(); + if (!pipelineLayout->Create(*this, std::move(pipelineLayoutInfo))) + return {}; + + return pipelineLayout; + } + + std::shared_ptr OpenGLDevice::InstantiateShaderStage(ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) + { + auto stage = std::make_shared(); + if (!stage->Create(*this, type, lang, source, sourceSize)) + return {}; + + return stage; + } + + std::unique_ptr OpenGLDevice::InstantiateTexture(const TextureInfo& params) + { + return std::make_unique(*this, params); + } + + std::unique_ptr OpenGLDevice::InstantiateTextureSampler(const TextureSamplerInfo& params) + { + return std::make_unique(*this, params); + } +} + +#endif diff --git a/src/Nazara/OpenGLRenderer/OpenGLFramebuffer.cpp b/src/Nazara/OpenGLRenderer/OpenGLFramebuffer.cpp new file mode 100644 index 000000000..c93488b3c --- /dev/null +++ b/src/Nazara/OpenGLRenderer/OpenGLFramebuffer.cpp @@ -0,0 +1,14 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#if 0 + +#include +#include + +namespace Nz +{ +} + +#endif diff --git a/src/Nazara/OpenGLRenderer/OpenGLRenderImage.cpp b/src/Nazara/OpenGLRenderer/OpenGLRenderImage.cpp new file mode 100644 index 000000000..b45621dc3 --- /dev/null +++ b/src/Nazara/OpenGLRenderer/OpenGLRenderImage.cpp @@ -0,0 +1,97 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#if 0 + +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + OpenGLRenderImage::OpenGLRenderImage(VkRenderWindow& owner) : + m_owner(owner), + m_uploadPool(m_owner.GetDevice(), 2 * 1024 * 1024) + { + Vk::QueueHandle& graphicsQueue = m_owner.GetGraphicsQueue(); + if (!m_commandPool.Create(m_owner.GetDevice(), graphicsQueue.GetQueueFamilyIndex(), VK_COMMAND_POOL_CREATE_TRANSIENT_BIT | VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)) + throw std::runtime_error("failed to create command pool: " + TranslateOpenGLError(m_commandPool.GetLastErrorCode())); + + if (!m_imageAvailableSemaphore.Create(m_owner.GetDevice())) + throw std::runtime_error("failed to create image available semaphore: " + TranslateOpenGLError(m_imageAvailableSemaphore.GetLastErrorCode())); + + if (!m_renderFinishedSemaphore.Create(m_owner.GetDevice())) + throw std::runtime_error("failed to create image finished semaphore: " + TranslateOpenGLError(m_imageAvailableSemaphore.GetLastErrorCode())); + + if (!m_inFlightFence.Create(m_owner.GetDevice(), VK_FENCE_CREATE_SIGNALED_BIT)) + throw std::runtime_error("failed to create in-flight fence: " + TranslateOpenGLError(m_inFlightFence.GetLastErrorCode())); + } + + OpenGLRenderImage::~OpenGLRenderImage() + { + m_inFlightCommandBuffers.clear(); + } + + void OpenGLRenderImage::Execute(const std::function& callback, QueueTypeFlags queueTypeFlags) + { + Vk::CommandBuffer* commandBuffer; + if (m_currentCommandBuffer >= m_inFlightCommandBuffers.size()) + { + Vk::AutoCommandBuffer& newlyAllocatedBuffer = m_inFlightCommandBuffers.emplace_back(m_commandPool.AllocateCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY)); + commandBuffer = &newlyAllocatedBuffer.Get(); + m_currentCommandBuffer++; + } + else + commandBuffer = &m_inFlightCommandBuffers[m_currentCommandBuffer++].Get(); + + if (!commandBuffer->Begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT)) + throw std::runtime_error("failed to begin command buffer: " + TranslateOpenGLError(commandBuffer->GetLastErrorCode())); + + OpenGLCommandBufferBuilder builder(*commandBuffer, m_imageIndex); + callback(builder); + + if (!commandBuffer->End()) + throw std::runtime_error("failed to build command buffer: " + TranslateOpenGLError(commandBuffer->GetLastErrorCode())); + + SubmitCommandBuffer(*commandBuffer, queueTypeFlags); + } + + OpenGLUploadPool& OpenGLRenderImage::GetUploadPool() + { + return m_uploadPool; + } + + void OpenGLRenderImage::SubmitCommandBuffer(CommandBuffer* commandBuffer, QueueTypeFlags queueTypeFlags) + { + OpenGLCommandBuffer& vkCommandBuffer = *static_cast(commandBuffer); + + return SubmitCommandBuffer(vkCommandBuffer.GetCommandBuffer(m_imageIndex), queueTypeFlags); + } + + void OpenGLRenderImage::SubmitCommandBuffer(VkCommandBuffer commandBuffer, QueueTypeFlags queueTypeFlags) + { + if (queueTypeFlags & QueueType::Graphics) + m_graphicalCommandsBuffers.push_back(commandBuffer); + else + { + Vk::QueueHandle& graphicsQueue = m_owner.GetGraphicsQueue(); + if (!graphicsQueue.Submit(commandBuffer)) + throw std::runtime_error("Failed to submit command buffer: " + TranslateOpenGLError(graphicsQueue.GetLastErrorCode())); + } + } + + void OpenGLRenderImage::Present() + { + Vk::QueueHandle& graphicsQueue = m_owner.GetGraphicsQueue(); + if (!graphicsQueue.Submit(UInt32(m_graphicalCommandsBuffers.size()), m_graphicalCommandsBuffers.data(), m_imageAvailableSemaphore, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, m_renderFinishedSemaphore, m_inFlightFence)) + throw std::runtime_error("Failed to submit command buffers: " + TranslateOpenGLError(graphicsQueue.GetLastErrorCode())); + + m_owner.Present(m_imageIndex, m_renderFinishedSemaphore); + } +} + +#endif diff --git a/src/Nazara/OpenGLRenderer/OpenGLRenderPass.cpp b/src/Nazara/OpenGLRenderer/OpenGLRenderPass.cpp new file mode 100644 index 000000000..e7c7b8100 --- /dev/null +++ b/src/Nazara/OpenGLRenderer/OpenGLRenderPass.cpp @@ -0,0 +1,14 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#if 0 + +#include +#include + +namespace Nz +{ +} + +#endif diff --git a/src/Nazara/OpenGLRenderer/OpenGLRenderPipeline.cpp b/src/Nazara/OpenGLRenderer/OpenGLRenderPipeline.cpp new file mode 100644 index 000000000..a57b7b1ed --- /dev/null +++ b/src/Nazara/OpenGLRenderer/OpenGLRenderPipeline.cpp @@ -0,0 +1,274 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#if 0 + +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + OpenGLRenderPipeline::OpenGLRenderPipeline(Vk::Device& device, RenderPipelineInfo pipelineInfo) : + m_device(&device), + m_pipelineInfo(std::move(pipelineInfo)) + { + m_pipelineCreateInfo = BuildCreateInfo(m_pipelineInfo); + } + + VkPipeline OpenGLRenderPipeline::Get(const Vk::RenderPass& renderPass) const + { + if (auto it = m_pipelines.find(renderPass); it != m_pipelines.end()) + return it->second; + + // Copy create info to make Get re-entrant + VkGraphicsPipelineCreateInfo pipelineCreateInfo = m_pipelineCreateInfo.pipelineInfo; + pipelineCreateInfo.renderPass = renderPass; + + Vk::Pipeline newPipeline; + if (!newPipeline.CreateGraphics(*m_device, pipelineCreateInfo)) + return VK_NULL_HANDLE; + + auto it = m_pipelines.emplace(renderPass, std::move(newPipeline)).first; + return it->second; + } + + std::vector OpenGLRenderPipeline::BuildColorBlendAttachmentStateList(const RenderPipelineInfo& pipelineInfo) + { + std::vector colorBlendStates; + + VkPipelineColorBlendAttachmentState& colorBlendState = colorBlendStates.emplace_back(); + colorBlendState.blendEnable = pipelineInfo.blending; + colorBlendState.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT; //< TODO + + if (pipelineInfo.blending) + { + //TODO + /*switch (pipelineInfo.dstBlend) + { + blendState.dstAlphaBlendFactor + }*/ + } + else + { + colorBlendState.srcColorBlendFactor = VK_BLEND_FACTOR_ONE; + colorBlendState.dstColorBlendFactor = VK_BLEND_FACTOR_ZERO; + colorBlendState.colorBlendOp = VK_BLEND_OP_ADD; + colorBlendState.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE; + colorBlendState.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO; + colorBlendState.alphaBlendOp = VK_BLEND_OP_ADD; + } + + return colorBlendStates; + } + + VkPipelineColorBlendStateCreateInfo OpenGLRenderPipeline::BuildColorBlendInfo(const RenderPipelineInfo& pipelineInfo, const std::vector& attachmentState) + { + VkPipelineColorBlendStateCreateInfo createInfo = {}; + createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; + createInfo.attachmentCount = std::uint32_t(attachmentState.size()); + createInfo.pAttachments = attachmentState.data(); + + return createInfo; + } + + VkPipelineDepthStencilStateCreateInfo OpenGLRenderPipeline::BuildDepthStencilInfo(const RenderPipelineInfo& pipelineInfo) + { + VkPipelineDepthStencilStateCreateInfo createInfo = {}; + createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; + createInfo.depthTestEnable = pipelineInfo.depthBuffer; + createInfo.depthWriteEnable = pipelineInfo.depthWrite; + createInfo.depthCompareOp = ToOpenGL(pipelineInfo.depthCompare); + createInfo.stencilTestEnable = pipelineInfo.stencilTest; + createInfo.front = BuildStencilOp(pipelineInfo, true); + createInfo.back = BuildStencilOp(pipelineInfo, false); + + return createInfo; + } + + VkPipelineDynamicStateCreateInfo OpenGLRenderPipeline::BuildDynamicStateInfo(const RenderPipelineInfo& pipelineInfo, const std::vector& dynamicStates) + { + VkPipelineDynamicStateCreateInfo createInfo = {}; + createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; + createInfo.dynamicStateCount = std::uint32_t(dynamicStates.size()); + createInfo.pDynamicStates = dynamicStates.data(); + + return createInfo; + } + + std::vector OpenGLRenderPipeline::BuildDynamicStateList(const RenderPipelineInfo& pipelineInfo) + { + return { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR }; + } + + VkPipelineInputAssemblyStateCreateInfo OpenGLRenderPipeline::BuildInputAssemblyInfo(const RenderPipelineInfo& pipelineInfo) + { + VkPipelineInputAssemblyStateCreateInfo createInfo = {}; + createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; + createInfo.topology = ToOpenGL(pipelineInfo.primitiveMode); + + return createInfo; + } + + VkPipelineMultisampleStateCreateInfo OpenGLRenderPipeline::BuildMultisampleInfo(const RenderPipelineInfo& pipelineInfo) + { + VkPipelineMultisampleStateCreateInfo createInfo = {}; + createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; + createInfo.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; + createInfo.minSampleShading = 1.0f; //< TODO: Remove + + return createInfo; + } + + VkPipelineRasterizationStateCreateInfo OpenGLRenderPipeline::BuildRasterizationInfo(const RenderPipelineInfo& pipelineInfo) + { + VkPipelineRasterizationStateCreateInfo createInfo = {}; + createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; + createInfo.polygonMode = ToOpenGL(pipelineInfo.faceFilling); + createInfo.cullMode = ToOpenGL(pipelineInfo.cullingSide); + createInfo.frontFace = VK_FRONT_FACE_CLOCKWISE; //< TODO + createInfo.lineWidth = pipelineInfo.lineWidth; + + return createInfo; + } + + VkPipelineViewportStateCreateInfo OpenGLRenderPipeline::BuildViewportInfo(const RenderPipelineInfo& pipelineInfo) + { + VkPipelineViewportStateCreateInfo createInfo = {}; + createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; + createInfo.scissorCount = createInfo.viewportCount = 1; //< TODO + + return createInfo; + } + + VkStencilOpState OpenGLRenderPipeline::BuildStencilOp(const RenderPipelineInfo& pipelineInfo, bool front) + { + const auto& pipelineStencil = (front) ? pipelineInfo.stencilFront : pipelineInfo.stencilBack; + + VkStencilOpState stencilStates; + stencilStates.compareMask = pipelineStencil.compareMask; + stencilStates.compareOp = ToOpenGL(pipelineStencil.compare); + stencilStates.depthFailOp = ToOpenGL(pipelineStencil.depthFail); + stencilStates.failOp = ToOpenGL(pipelineStencil.fail); + stencilStates.passOp = ToOpenGL(pipelineStencil.pass); + stencilStates.reference = pipelineStencil.reference; + stencilStates.writeMask = pipelineStencil.writeMask; + + return stencilStates; + } + + std::vector OpenGLRenderPipeline::BuildShaderStageInfo(const RenderPipelineInfo& pipelineInfo) + { + std::vector shaderStageCreateInfos; + + for (auto&& stagePtr : pipelineInfo.shaderStages) + { + Nz::OpenGLShaderStage& vulkanStage = *static_cast(stagePtr.get()); + + VkPipelineShaderStageCreateInfo& createInfo = shaderStageCreateInfos.emplace_back(); + createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; + createInfo.module = vulkanStage.GetHandle(); + createInfo.pName = "main"; + createInfo.stage = ToOpenGL(vulkanStage.GetStageType()); + } + + return shaderStageCreateInfos; + } + + std::vector OpenGLRenderPipeline::BuildVertexAttributeDescription(const RenderPipelineInfo& pipelineInfo) + { + std::vector vertexAttributes; + + std::uint32_t locationIndex = 0; + + for (const auto& bufferData : pipelineInfo.vertexBuffers) + { + std::uint32_t binding = std::uint32_t(bufferData.binding); + + for (const auto& componentInfo : *bufferData.declaration) + { + auto& bufferAttribute = vertexAttributes.emplace_back(); + bufferAttribute.binding = binding; + bufferAttribute.location = locationIndex++; + bufferAttribute.offset = std::uint32_t(componentInfo.offset); + bufferAttribute.format = ToOpenGL(componentInfo.type); + } + } + + return vertexAttributes; + } + + std::vector OpenGLRenderPipeline::BuildVertexBindingDescription(const RenderPipelineInfo& pipelineInfo) + { + std::vector vertexBindings; + + for (const auto& bufferData : pipelineInfo.vertexBuffers) + { + auto& bufferBinding = vertexBindings.emplace_back(); + bufferBinding.binding = std::uint32_t(bufferData.binding); + bufferBinding.stride = std::uint32_t(bufferData.declaration->GetStride()); + bufferBinding.inputRate = ToOpenGL(bufferData.declaration->GetInputRate()); + } + + return vertexBindings; + } + + VkPipelineVertexInputStateCreateInfo OpenGLRenderPipeline::BuildVertexInputInfo(const RenderPipelineInfo& pipelineInfo, const std::vector& vertexAttributes, const std::vector& bindingDescriptions) + { + VkPipelineVertexInputStateCreateInfo createInfo = {}; + createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; + + createInfo.vertexAttributeDescriptionCount = std::uint32_t(vertexAttributes.size()); + createInfo.pVertexAttributeDescriptions = vertexAttributes.data(); + + createInfo.vertexBindingDescriptionCount = std::uint32_t(bindingDescriptions.size()); + createInfo.pVertexBindingDescriptions = bindingDescriptions.data(); + + return createInfo; + } + + auto OpenGLRenderPipeline::BuildCreateInfo(const RenderPipelineInfo& pipelineInfo) -> CreateInfo + { + CreateInfo createInfo = {}; + createInfo.stateData = std::make_unique(); + + createInfo.colorBlendAttachmentState = BuildColorBlendAttachmentStateList(pipelineInfo); + createInfo.dynamicStates = BuildDynamicStateList(pipelineInfo); + createInfo.shaderStages = BuildShaderStageInfo(pipelineInfo); + createInfo.vertexAttributesDescription = BuildVertexAttributeDescription(pipelineInfo); + createInfo.vertexBindingDescription = BuildVertexBindingDescription(pipelineInfo); + + createInfo.stateData->colorBlendState = BuildColorBlendInfo(pipelineInfo, createInfo.colorBlendAttachmentState); + createInfo.stateData->depthStencilState = BuildDepthStencilInfo(pipelineInfo); + createInfo.stateData->dynamicState = BuildDynamicStateInfo(pipelineInfo, createInfo.dynamicStates); + createInfo.stateData->inputAssemblyState = BuildInputAssemblyInfo(pipelineInfo); + createInfo.stateData->multiSampleState = BuildMultisampleInfo(pipelineInfo); + createInfo.stateData->rasterizationState = BuildRasterizationInfo(pipelineInfo); + createInfo.stateData->viewportState = BuildViewportInfo(pipelineInfo); + createInfo.stateData->vertexInputState = BuildVertexInputInfo(pipelineInfo, createInfo.vertexAttributesDescription, createInfo.vertexBindingDescription); + + createInfo.pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; + createInfo.pipelineInfo.stageCount = std::uint32_t(createInfo.shaderStages.size()); + createInfo.pipelineInfo.pStages = createInfo.shaderStages.data(); + createInfo.pipelineInfo.pColorBlendState = &createInfo.stateData->colorBlendState; + createInfo.pipelineInfo.pDepthStencilState = &createInfo.stateData->depthStencilState; + createInfo.pipelineInfo.pDynamicState = &createInfo.stateData->dynamicState; + createInfo.pipelineInfo.pInputAssemblyState = &createInfo.stateData->inputAssemblyState; + createInfo.pipelineInfo.pMultisampleState = &createInfo.stateData->multiSampleState; + createInfo.pipelineInfo.pRasterizationState = &createInfo.stateData->rasterizationState; + createInfo.pipelineInfo.pVertexInputState = &createInfo.stateData->vertexInputState; + createInfo.pipelineInfo.pViewportState = &createInfo.stateData->viewportState; + + OpenGLRenderPipelineLayout& pipelineLayout = *static_cast(pipelineInfo.pipelineLayout.get()); + createInfo.pipelineInfo.layout = pipelineLayout.GetPipelineLayout(); + + return createInfo; + } +} + +#endif diff --git a/src/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.cpp b/src/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.cpp new file mode 100644 index 000000000..a0c8b8c05 --- /dev/null +++ b/src/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.cpp @@ -0,0 +1,140 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#if 0 + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + OpenGLRenderPipelineLayout::~OpenGLRenderPipelineLayout() + { + for (auto& pool : m_descriptorPools) + { + if (!pool.freeBindings.TestAll()) + NazaraWarning("Not all ShaderBinding have been released!"); + } + } + + ShaderBindingPtr OpenGLRenderPipelineLayout::AllocateShaderBinding() + { + for (std::size_t i = 0; i < m_descriptorPools.size(); ++i) + { + ShaderBindingPtr bindingPtr = AllocateFromPool(i); + if (!bindingPtr) + continue; + + return bindingPtr; + } + + // No allocation could be made, time to allocate a new pool + std::size_t newPoolIndex = m_descriptorPools.size(); + AllocatePool(); + + ShaderBindingPtr bindingPtr = AllocateFromPool(newPoolIndex); + if (!bindingPtr) + throw std::runtime_error("Failed to allocate shader binding"); + + return bindingPtr; + } + + bool OpenGLRenderPipelineLayout::Create(Vk::Device& device, RenderPipelineLayoutInfo layoutInfo) + { + m_device = &device; + m_layoutInfo = std::move(layoutInfo); + + StackVector layoutBindings = NazaraStackVector(VkDescriptorSetLayoutBinding, m_layoutInfo.bindings.size()); + + for (const auto& bindingInfo : m_layoutInfo.bindings) + { + VkDescriptorSetLayoutBinding& layoutBinding = layoutBindings.emplace_back(); + layoutBinding.binding = bindingInfo.index; + layoutBinding.descriptorCount = 1U; + layoutBinding.descriptorType = ToOpenGL(bindingInfo.type); + layoutBinding.stageFlags = ToOpenGL(bindingInfo.shaderStageFlags); + } + + if (!m_descriptorSetLayout.Create(*m_device, UInt32(layoutBindings.size()), layoutBindings.data())) + return false; + + if (!m_pipelineLayout.Create(*m_device, m_descriptorSetLayout)) + return false; + + return true; + } + + auto OpenGLRenderPipelineLayout::AllocatePool() -> DescriptorPool& + { + StackVector poolSizes = NazaraStackVector(VkDescriptorPoolSize, m_layoutInfo.bindings.size()); + + constexpr UInt32 MaxSet = 128; + + for (const auto& bindingInfo : m_layoutInfo.bindings) + { + VkDescriptorPoolSize& poolSize = poolSizes.emplace_back(); + poolSize.descriptorCount = MaxSet; + poolSize.type = ToOpenGL(bindingInfo.type); + } + + DescriptorPool pool; + if (!pool.descriptorPool.Create(*m_device, MaxSet, UInt32(poolSizes.size()), poolSizes.data(), VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT)) + throw std::runtime_error("Failed to allocate new descriptor pool: " + TranslateOpenGLError(pool.descriptorPool.GetLastErrorCode())); + + pool.freeBindings.Resize(MaxSet, true); + pool.storage = std::make_unique(MaxSet); + + return m_descriptorPools.emplace_back(std::move(pool)); + } + + ShaderBindingPtr OpenGLRenderPipelineLayout::AllocateFromPool(std::size_t poolIndex) + { + auto& pool = m_descriptorPools[poolIndex]; + + std::size_t freeBindingId = pool.freeBindings.FindFirst(); + if (freeBindingId == pool.freeBindings.npos) + return {}; //< No free binding in this pool + + Vk::DescriptorSet descriptorSet = pool.descriptorPool.AllocateDescriptorSet(m_descriptorSetLayout); + if (!descriptorSet) + { + NazaraWarning("Failed to allocate descriptor set: " + TranslateOpenGLError(pool.descriptorPool.GetLastErrorCode())); + return {}; + } + + pool.freeBindings.Reset(freeBindingId); + + OpenGLShaderBinding* freeBindingMemory = reinterpret_cast(&pool.storage[freeBindingId]); + return ShaderBindingPtr(PlacementNew(freeBindingMemory, *this, poolIndex, freeBindingId, std::move(descriptorSet))); + } + + void OpenGLRenderPipelineLayout::Release(ShaderBinding& binding) + { + OpenGLShaderBinding& vulkanBinding = static_cast(binding); + + std::size_t poolIndex = vulkanBinding.GetPoolIndex(); + std::size_t bindingIndex = vulkanBinding.GetBindingIndex(); + + assert(poolIndex < m_descriptorPools.size()); + auto& pool = m_descriptorPools[poolIndex]; + assert(!pool.freeBindings.Test(bindingIndex)); + + OpenGLShaderBinding* bindingMemory = reinterpret_cast(&pool.storage[bindingIndex]); + PlacementDestroy(bindingMemory); + + pool.freeBindings.Set(bindingIndex); + + // Try to free pool if it's one of the last one + if (poolIndex >= m_descriptorPools.size() - 1 && poolIndex <= m_descriptorPools.size()) + TryToShrink(); + } +} + +#endif diff --git a/src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp b/src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp new file mode 100644 index 000000000..0c4df36e7 --- /dev/null +++ b/src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp @@ -0,0 +1,486 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#if 0 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + VkRenderWindow::VkRenderWindow() : + m_currentFrame(0), + m_depthStencilFormat(VK_FORMAT_MAX_ENUM) + { + } + + VkRenderWindow::~VkRenderWindow() + { + if (m_device) + m_device->WaitForIdle(); + + m_concurrentImageData.clear(); + m_renderPass.reset(); + m_framebuffer.reset(); + m_swapchain.Destroy(); + } + + OpenGLRenderImage& VkRenderWindow::Acquire() + { + OpenGLRenderImage& currentFrame = m_concurrentImageData[m_currentFrame]; + Vk::Fence& inFlightFence = currentFrame.GetInFlightFence(); + + // Wait until previous rendering to this image has been done + inFlightFence.Wait(); + + UInt32 imageIndex; + if (!m_swapchain.AcquireNextImage(std::numeric_limits::max(), currentFrame.GetImageAvailableSemaphore(), VK_NULL_HANDLE, &imageIndex)) + throw std::runtime_error("Failed to acquire next image: " + TranslateOpenGLError(m_swapchain.GetLastErrorCode())); + + if (m_inflightFences[imageIndex]) + m_inflightFences[imageIndex]->Wait(); + + m_inflightFences[imageIndex] = &inFlightFence; + m_inflightFences[imageIndex]->Reset(); + + currentFrame.Reset(imageIndex); + + return currentFrame; + } + + bool VkRenderWindow::Create(RendererImpl* /*renderer*/, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) + { + const auto& deviceInfo = OpenGL::GetPhysicalDevices()[0]; + + Vk::Surface& vulkanSurface = static_cast(surface)->GetSurface(); + + UInt32 graphicsFamilyQueueIndex; + UInt32 presentableFamilyQueueIndex; + UInt32 transferFamilyQueueIndex; + m_device = OpenGL::SelectDevice(deviceInfo, vulkanSurface, &graphicsFamilyQueueIndex, &presentableFamilyQueueIndex, &transferFamilyQueueIndex); + if (!m_device) + { + NazaraError("Failed to get compatible OpenGL device"); + return false; + } + + m_graphicsQueue = m_device->GetQueue(graphicsFamilyQueueIndex, 0); + m_presentQueue = m_device->GetQueue(presentableFamilyQueueIndex, 0); + m_transferQueue = m_device->GetQueue(transferFamilyQueueIndex, 0); + + std::vector surfaceFormats; + if (!vulkanSurface.GetFormats(deviceInfo.physDevice, &surfaceFormats)) + { + NazaraError("Failed to query supported surface formats"); + return false; + } + + m_surfaceFormat = [&] () -> VkSurfaceFormatKHR + { + if (surfaceFormats.size() == 1 && surfaceFormats.front().format == VK_FORMAT_UNDEFINED) + { + // If the list contains one undefined format, it means any format can be used + return { VK_FORMAT_R8G8B8A8_UNORM, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR }; + } + else + { + // Search for RGBA8 and default to first format + for (const VkSurfaceFormatKHR& surfaceFormat : surfaceFormats) + { + if (surfaceFormat.format == VK_FORMAT_R8G8B8A8_UNORM) + return surfaceFormat; + } + + return surfaceFormats.front(); + } + }(); + + if (!parameters.depthFormats.empty()) + { + for (PixelFormat format : parameters.depthFormats) + { + switch (format) + { + case PixelFormat_Depth16: + m_depthStencilFormat = VK_FORMAT_D16_UNORM; + break; + + case PixelFormat_Depth24: + case PixelFormat_Depth24Stencil8: + m_depthStencilFormat = VK_FORMAT_D24_UNORM_S8_UINT; + break; + + case PixelFormat_Depth32: + m_depthStencilFormat = VK_FORMAT_D32_SFLOAT; + break; + + case PixelFormat_Stencil1: + case PixelFormat_Stencil4: + case PixelFormat_Stencil8: + m_depthStencilFormat = VK_FORMAT_S8_UINT; + break; + + case PixelFormat_Stencil16: + m_depthStencilFormat = VK_FORMAT_MAX_ENUM; + break; + + default: + { + PixelFormatContent formatContent = PixelFormatInfo::GetContent(format); + if (formatContent != PixelFormatContent_DepthStencil && formatContent != PixelFormatContent_Stencil) + NazaraWarning("Invalid format " + PixelFormatInfo::GetName(format) + " for depth-stencil attachment"); + + m_depthStencilFormat = VK_FORMAT_MAX_ENUM; + break; + } + } + + if (m_depthStencilFormat != VK_FORMAT_MAX_ENUM) + { + VkFormatProperties formatProperties = m_device->GetInstance().GetPhysicalDeviceFormatProperties(deviceInfo.physDevice, m_depthStencilFormat); + if (formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) + break; //< Found it + + m_depthStencilFormat = VK_FORMAT_MAX_ENUM; + } + } + } + + if (!SetupSwapchain(deviceInfo, vulkanSurface, size)) + { + NazaraError("Failed to create swapchain"); + return false; + } + + if (m_depthStencilFormat != VK_FORMAT_MAX_ENUM && !SetupDepthBuffer(size)) + { + NazaraError("Failed to create depth buffer"); + return false; + } + + if (!SetupRenderPass()) + { + NazaraError("Failed to create render pass"); + return false; + } + + UInt32 imageCount = m_swapchain.GetBufferCount(); + + // Framebuffers + m_inflightFences.resize(imageCount); + + Nz::StackArray framebuffers = NazaraStackArray(Vk::Framebuffer, imageCount); + for (UInt32 i = 0; i < imageCount; ++i) + { + std::array attachments = { m_swapchain.GetBuffer(i).view, m_depthBufferView }; + + VkFramebufferCreateInfo frameBufferCreate = { + VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, + nullptr, + 0, + m_renderPass->GetRenderPass(), + (attachments[1] != VK_NULL_HANDLE) ? 2U : 1U, + attachments.data(), + size.x, + size.y, + 1U + }; + + if (!framebuffers[i].Create(*m_device, frameBufferCreate)) + { + NazaraError("Failed to create framebuffer for image #" + String::Number(i) + ": " + TranslateOpenGLError(framebuffers[i].GetLastErrorCode())); + return false; + } + } + + m_framebuffer.emplace(framebuffers.data(), framebuffers.size()); + + const std::size_t MaxConcurrentImage = imageCount; + m_concurrentImageData.reserve(MaxConcurrentImage); + + for (std::size_t i = 0; i < MaxConcurrentImage; ++i) + m_concurrentImageData.emplace_back(*this); + + m_clock.Restart(); + + return true; + } + + std::unique_ptr VkRenderWindow::CreateCommandPool(QueueType queueType) + { + UInt32 queueFamilyIndex; + switch (queueType) + { + case QueueType::Compute: + queueFamilyIndex = m_device->GetDefaultFamilyIndex(QueueType::Compute); + break; + + case QueueType::Graphics: + queueFamilyIndex = m_graphicsQueue.GetQueueFamilyIndex(); + break; + + case QueueType::Transfer: + queueFamilyIndex = m_transferQueue.GetQueueFamilyIndex(); + break; + } + + return std::make_unique(*m_device, queueFamilyIndex); + } + + const OpenGLRenderPass& VkRenderWindow::GetRenderPass() const + { + return *m_renderPass; + } + + bool VkRenderWindow::SetupDepthBuffer(const Vector2ui& size) + { + VkImageCreateInfo imageCreateInfo = { + VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + 0U, // VkImageCreateFlags flags; + VK_IMAGE_TYPE_2D, // VkImageType imageType; + m_depthStencilFormat, // VkFormat format; + {size.x, size.y, 1U}, // VkExtent3D extent; + 1U, // uint32_t mipLevels; + 1U, // uint32_t arrayLayers; + VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples; + VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling; + VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT, // VkImageUsageFlags usage; + VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode; + 0U, // uint32_t queueFamilyIndexCount; + nullptr, // const uint32_t* pQueueFamilyIndices; + VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout; + }; + + if (!m_depthBuffer.Create(*m_device, imageCreateInfo)) + { + NazaraError("Failed to create depth buffer"); + return false; + } + + VkMemoryRequirements memoryReq = m_depthBuffer.GetMemoryRequirements(); + if (!m_depthBufferMemory.Create(*m_device, memoryReq.size, memoryReq.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)) + { + NazaraError("Failed to allocate depth buffer memory"); + return false; + } + + if (!m_depthBuffer.BindImageMemory(m_depthBufferMemory)) + { + NazaraError("Failed to bind depth buffer to buffer"); + return false; + } + + VkImageViewCreateInfo imageViewCreateInfo = { + VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + 0, // VkImageViewCreateFlags flags; + m_depthBuffer, // VkImage image; + VK_IMAGE_VIEW_TYPE_2D, // VkImageViewType viewType; + m_depthStencilFormat, // VkFormat format; + { // VkComponentMapping components; + VK_COMPONENT_SWIZZLE_R, // VkComponentSwizzle .r; + VK_COMPONENT_SWIZZLE_G, // VkComponentSwizzle .g; + VK_COMPONENT_SWIZZLE_B, // VkComponentSwizzle .b; + VK_COMPONENT_SWIZZLE_A // VkComponentSwizzle .a; + }, + { // VkImageSubresourceRange subresourceRange; + VK_IMAGE_ASPECT_DEPTH_BIT, // VkImageAspectFlags .aspectMask; + 0, // uint32_t .baseMipLevel; + 1, // uint32_t .levelCount; + 0, // uint32_t .baseArrayLayer; + 1 // uint32_t .layerCount; + } + }; + + if (!m_depthBufferView.Create(*m_device, imageViewCreateInfo)) + { + NazaraError("Failed to create depth buffer view"); + return false; + } + + return true; + } + + bool VkRenderWindow::SetupRenderPass() + { + std::array attachments = { + { + { + 0, // VkAttachmentDescriptionFlags flags; + m_surfaceFormat.format, // VkFormat format; + VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples; + VK_ATTACHMENT_LOAD_OP_CLEAR, // VkAttachmentLoadOp loadOp; + VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp; + VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp; + VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp; + VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout; + VK_IMAGE_LAYOUT_PRESENT_SRC_KHR // VkImageLayout finalLayout; + }, + { + 0, // VkAttachmentDescriptionFlags flags; + m_depthStencilFormat, // VkFormat format; + VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples; + VK_ATTACHMENT_LOAD_OP_CLEAR, // VkAttachmentLoadOp loadOp; + VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp storeOp; + VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp; + VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp; + VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout; + VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL // VkImageLayout finalLayout; + }, + } + }; + + VkAttachmentReference colorReference = { + 0, // uint32_t attachment; + VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout layout; + }; + + VkAttachmentReference depthReference = { + 1, // uint32_t attachment; + VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL // VkImageLayout layout; + }; + + VkSubpassDescription subpass = { + 0, // VkSubpassDescriptionFlags flags; + VK_PIPELINE_BIND_POINT_GRAPHICS, // VkPipelineBindPoint pipelineBindPoint; + 0U, // uint32_t inputAttachmentCount; + nullptr, // const VkAttachmentReference* pInputAttachments; + 1U, // uint32_t colorAttachmentCount; + &colorReference, // const VkAttachmentReference* pColorAttachments; + nullptr, // const VkAttachmentReference* pResolveAttachments; + (m_depthStencilFormat != VK_FORMAT_MAX_ENUM) ? &depthReference : nullptr, // const VkAttachmentReference* pDepthStencilAttachment; + 0U, // uint32_t preserveAttachmentCount; + nullptr // const uint32_t* pPreserveAttachments; + }; + + std::array dependencies; + // First dependency at the start of the render pass + // Does the transition from final to initial layout + dependencies[0].srcSubpass = VK_SUBPASS_EXTERNAL; // Producer of the dependency + dependencies[0].dstSubpass = 0; // Consumer is our single subpass that will wait for the execution dependency + dependencies[0].srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; + dependencies[0].dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; + dependencies[0].srcAccessMask = 0; + dependencies[0].dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; + dependencies[0].dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT; + + // Second dependency at the end the render pass + // Does the transition from the initial to the final layout + dependencies[1].srcSubpass = 0; // Producer of the dependency is our single subpass + dependencies[1].dstSubpass = VK_SUBPASS_EXTERNAL; // Consumer are all commands outside of the render pass + dependencies[1].srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; + dependencies[1].dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT; + dependencies[1].srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; + dependencies[1].dstAccessMask = VK_ACCESS_MEMORY_READ_BIT; + dependencies[1].dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT; + + VkRenderPassCreateInfo createInfo = { + VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, // VkStructureType sType; + nullptr, // const void* pNext; + 0, // VkRenderPassCreateFlags flags; + (m_depthStencilFormat != VK_FORMAT_MAX_ENUM) ? 2U : 1U, // uint32_t attachmentCount; + attachments.data(), // const VkAttachmentDescription* pAttachments; + 1U, // uint32_t subpassCount; + &subpass, // const VkSubpassDescription* pSubpasses; + UInt32(dependencies.size()), // uint32_t dependencyCount; + dependencies.data() // const VkSubpassDependency* pDependencies; + }; + + Vk::RenderPass renderPass; + if (!renderPass.Create(*m_device, createInfo)) + { + NazaraError("Failed to create render pass: " + TranslateOpenGLError(renderPass.GetLastErrorCode())); + return false; + } + + std::initializer_list fixmeplease = { PixelFormat::PixelFormat_RGB8, PixelFormat::PixelFormat_Depth24Stencil8 }; + m_renderPass.emplace(std::move(renderPass), fixmeplease); + return true; + } + + bool VkRenderWindow::SetupSwapchain(const Vk::PhysicalDevice& deviceInfo, Vk::Surface& surface, const Vector2ui& size) + { + VkSurfaceCapabilitiesKHR surfaceCapabilities; + if (!surface.GetCapabilities(deviceInfo.physDevice, &surfaceCapabilities)) + { + NazaraError("Failed to query surface capabilities"); + return false; + } + + Nz::UInt32 imageCount = surfaceCapabilities.minImageCount + 1; + if (surfaceCapabilities.maxImageCount > 0 && imageCount > surfaceCapabilities.maxImageCount) + imageCount = surfaceCapabilities.maxImageCount; + + VkExtent2D extent; + if (surfaceCapabilities.currentExtent.width == -1) + { + extent.width = Nz::Clamp(size.x, surfaceCapabilities.minImageExtent.width, surfaceCapabilities.maxImageExtent.width); + extent.height = Nz::Clamp(size.y, surfaceCapabilities.minImageExtent.height, surfaceCapabilities.maxImageExtent.height); + } + else + extent = surfaceCapabilities.currentExtent; + + std::vector presentModes; + if (!surface.GetPresentModes(deviceInfo.physDevice, &presentModes)) + { + NazaraError("Failed to query supported present modes"); + return false; + } + + VkPresentModeKHR swapchainPresentMode = VK_PRESENT_MODE_FIFO_KHR; + for (VkPresentModeKHR presentMode : presentModes) + { + if (presentMode == VK_PRESENT_MODE_MAILBOX_KHR) + { + swapchainPresentMode = VK_PRESENT_MODE_MAILBOX_KHR; + break; + } + + if (presentMode == VK_PRESENT_MODE_IMMEDIATE_KHR) + swapchainPresentMode = VK_PRESENT_MODE_IMMEDIATE_KHR; + } + + VkSwapchainCreateInfoKHR swapchainInfo = { + VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR, + nullptr, + 0, + surface, + imageCount, + m_surfaceFormat.format, + m_surfaceFormat.colorSpace, + extent, + 1, + VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, + VK_SHARING_MODE_EXCLUSIVE, + 0, nullptr, + surfaceCapabilities.currentTransform, + VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR, + swapchainPresentMode, + VK_TRUE, + VK_NULL_HANDLE + }; + + if (!m_swapchain.Create(*m_device, swapchainInfo)) + { + NazaraError("Failed to create swapchain"); + return false; + } + + return true; + } +} + +#endif diff --git a/src/Nazara/OpenGLRenderer/OpenGLRenderer.cpp b/src/Nazara/OpenGLRenderer/OpenGLRenderer.cpp new file mode 100644 index 000000000..2935ed1b5 --- /dev/null +++ b/src/Nazara/OpenGLRenderer/OpenGLRenderer.cpp @@ -0,0 +1,79 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + OpenGLRenderer::~OpenGLRenderer() + { + OpenGL::Uninitialize(); + } + + std::unique_ptr OpenGLRenderer::CreateRenderSurfaceImpl() + { + return {}; + } + + std::unique_ptr OpenGLRenderer::CreateRenderWindowImpl() + { + return {}; + } + + std::shared_ptr OpenGLRenderer::InstanciateRenderDevice(std::size_t deviceIndex) + { + //assert(deviceIndex < m_physDevices.size()); + //return OpenGL::SelectDevice(m_physDevices[deviceIndex]); + return {}; + } + + bool OpenGLRenderer::IsBetterThan(const RendererImpl* other) const + { + if (other->QueryAPI() == RenderAPI::OpenGL && QueryAPIVersion() > other->QueryAPIVersion()) + return true; + + return false; //< OpenGL is mostly a fallback to other renderers + } + + bool OpenGLRenderer::Prepare(const ParameterList& parameters) + { + return OpenGL::Initialize(); + } + + RenderAPI OpenGLRenderer::QueryAPI() const + { + return RenderAPI::OpenGL; + } + + std::string OpenGLRenderer::QueryAPIString() const + { + std::ostringstream ss; + ss << "OpenGL ES renderer 3.0"; + + return ss.str(); + } + + UInt32 OpenGLRenderer::QueryAPIVersion() const + { + return 300; + } + + std::vector OpenGLRenderer::QueryRenderDevices() const + { + std::vector devices; + auto& dummyDevice = devices.emplace_back(); + dummyDevice.name = "OpenGL Default Device"; + dummyDevice.type = RenderDeviceType::Unknown; + + return devices; + } +} diff --git a/src/Nazara/OpenGLRenderer/OpenGLShaderBinding.cpp b/src/Nazara/OpenGLRenderer/OpenGLShaderBinding.cpp new file mode 100644 index 000000000..3a24e0fb1 --- /dev/null +++ b/src/Nazara/OpenGLRenderer/OpenGLShaderBinding.cpp @@ -0,0 +1,79 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#if 0 + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + void OpenGLShaderBinding::Update(std::initializer_list bindings) + { + StackVector bufferBinding = NazaraStackVector(VkDescriptorBufferInfo, bindings.size()); + StackVector imageBinding = NazaraStackVector(VkDescriptorImageInfo, bindings.size()); + StackVector writeOps = NazaraStackVector(VkWriteDescriptorSet, bindings.size()); + + for (const Binding& binding : bindings) + { + VkWriteDescriptorSet& writeOp = writeOps.emplace_back(); + writeOp.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; + writeOp.dstSet = m_descriptorSet; + writeOp.dstBinding = UInt32(binding.bindingIndex); + + std::visit([&](auto&& arg) + { + using T = std::decay_t; + + if constexpr (std::is_same_v) + { + OpenGLTexture& vkTexture = *static_cast(arg.texture); + OpenGLTextureSampler& vkSampler = *static_cast(arg.sampler); + + VkDescriptorImageInfo& imageInfo = imageBinding.emplace_back(); + imageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; + imageInfo.imageView = vkTexture.GetImageView(); + imageInfo.sampler = vkSampler.GetSampler(); + + writeOp.descriptorCount = 1; + writeOp.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; + + writeOp.pImageInfo = &imageInfo; + } + else if constexpr (std::is_same_v) + { + OpenGLBuffer& vkBuffer = *static_cast(arg.buffer); + + VkDescriptorBufferInfo& bufferInfo = bufferBinding.emplace_back(); + bufferInfo.buffer = vkBuffer.GetBuffer(); + bufferInfo.offset = arg.offset; + bufferInfo.range = arg.range; + + writeOp.descriptorCount = 1; + writeOp.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; + + writeOp.pBufferInfo = &bufferInfo; + } + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + + }, binding.content); + } + + m_owner.GetDevice()->vkUpdateDescriptorSets(*m_owner.GetDevice(), UInt32(writeOps.size()), writeOps.data(), 0U, nullptr); + } + + void OpenGLShaderBinding::Release() + { + m_owner.Release(*this); + } +} + +#endif diff --git a/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp b/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp new file mode 100644 index 000000000..24c18fd3b --- /dev/null +++ b/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#if 0 + +#include +#include + +namespace Nz +{ + bool OpenGLShaderStage::Create(Vk::Device& device, ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) + { + if (lang != ShaderLanguage::SpirV) + { + NazaraError("Only Spir-V is supported for now"); + return false; + } + + if (!m_shaderModule.Create(device, reinterpret_cast(source), sourceSize)) + { + NazaraError("Failed to create shader module"); + return false; + } + + m_stage = type; + return true; + } +} + +#endif diff --git a/src/Nazara/OpenGLRenderer/OpenGLSurface.cpp b/src/Nazara/OpenGLRenderer/OpenGLSurface.cpp new file mode 100644 index 000000000..74f9bd620 --- /dev/null +++ b/src/Nazara/OpenGLRenderer/OpenGLSurface.cpp @@ -0,0 +1,49 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#if 0 + +#include +#include +#include + +namespace Nz +{ + OpenGLSurface::OpenGLSurface() : + m_surface(OpenGL::GetInstance()) + { + } + + OpenGLSurface::~OpenGLSurface() = default; + + bool OpenGLSurface::Create(WindowHandle handle) + { + bool success = false; + #if defined(NAZARA_PLATFORM_WINDOWS) + { + HWND winHandle = reinterpret_cast(handle); + HINSTANCE instance = reinterpret_cast(GetWindowLongPtrW(winHandle, GWLP_HINSTANCE)); + + success = m_surface.Create(instance, winHandle); + } + #else + #error This OS is not supported by OpenGL + #endif + + if (!success) + { + NazaraError("Failed to create OpenGL surface: " + TranslateOpenGLError(m_surface.GetLastErrorCode())); + return false; + } + + return true; + } + + void OpenGLSurface::Destroy() + { + m_surface.Destroy(); + } +} + +#endif diff --git a/src/Nazara/OpenGLRenderer/OpenGLTexture.cpp b/src/Nazara/OpenGLRenderer/OpenGLTexture.cpp new file mode 100644 index 000000000..1d2f5e0f4 --- /dev/null +++ b/src/Nazara/OpenGLRenderer/OpenGLTexture.cpp @@ -0,0 +1,291 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#if 0 + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + namespace + { + inline unsigned int GetLevelSize(unsigned int size, UInt8 level) + { + if (size == 0) // Possible dans le cas d'une image invalide + return 0; + + return std::max(size >> level, 1U); + } + } + + OpenGLTexture::OpenGLTexture(Vk::Device& device, const TextureInfo& params) : + m_image(VK_NULL_HANDLE), + m_allocation(nullptr), + m_device(device), + m_params(params) + { + VkImageCreateInfo createInfo = { VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO }; + createInfo.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; + createInfo.mipLevels = params.mipmapLevel; + createInfo.samples = VK_SAMPLE_COUNT_1_BIT; + createInfo.tiling = VK_IMAGE_TILING_OPTIMAL; + createInfo.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT; + + VkImageViewCreateInfo createInfoView = { VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO }; + createInfoView.subresourceRange = { + VK_IMAGE_ASPECT_COLOR_BIT, + 0, + 1, + 0, + 1 + }; + + InitForFormat(params.pixelFormat, createInfo, createInfoView); + + switch (params.type) + { + case ImageType_1D: + NazaraAssert(params.width > 0, "Width must be over zero"); + + createInfoView.viewType = VK_IMAGE_VIEW_TYPE_1D; + + createInfo.imageType = VK_IMAGE_TYPE_1D; + createInfo.extent.width = params.width; + createInfo.extent.height = 1; + createInfo.extent.depth = 1; + createInfo.arrayLayers = 1; + break; + + case ImageType_1D_Array: + NazaraAssert(params.width > 0, "Width must be over zero"); + NazaraAssert(params.height > 0, "Height must be over zero"); + + createInfoView.viewType = VK_IMAGE_VIEW_TYPE_1D_ARRAY; + + createInfo.imageType = VK_IMAGE_TYPE_1D; + createInfo.extent.width = params.width; + createInfo.extent.height = 1; + createInfo.extent.depth = 1; + createInfo.arrayLayers = params.height; + break; + + case ImageType_2D: + NazaraAssert(params.width > 0, "Width must be over zero"); + NazaraAssert(params.height > 0, "Height must be over zero"); + + createInfoView.viewType = VK_IMAGE_VIEW_TYPE_2D; + + createInfo.imageType = VK_IMAGE_TYPE_2D; + createInfo.extent.width = params.width; + createInfo.extent.height = params.height; + createInfo.extent.depth = 1; + createInfo.arrayLayers = 1; + break; + + case ImageType_2D_Array: + NazaraAssert(params.width > 0, "Width must be over zero"); + NazaraAssert(params.height > 0, "Height must be over zero"); + NazaraAssert(params.depth > 0, "Depth must be over zero"); + + createInfoView.viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY; + + createInfo.imageType = VK_IMAGE_TYPE_2D; + createInfo.extent.width = params.width; + createInfo.extent.height = params.height; + createInfo.extent.depth = 1; + createInfo.arrayLayers = params.height; + break; + + case ImageType_3D: + NazaraAssert(params.width > 0, "Width must be over zero"); + NazaraAssert(params.height > 0, "Height must be over zero"); + NazaraAssert(params.depth > 0, "Depth must be over zero"); + + createInfoView.viewType = VK_IMAGE_VIEW_TYPE_3D; + + createInfo.imageType = VK_IMAGE_TYPE_3D; + createInfo.extent.width = params.width; + createInfo.extent.height = params.height; + createInfo.extent.depth = params.depth; + createInfo.arrayLayers = 1; + break; + + case ImageType_Cubemap: + NazaraAssert(params.width > 0, "Width must be over zero"); + NazaraAssert(params.height > 0, "Height must be over zero"); + + createInfoView.viewType = VK_IMAGE_VIEW_TYPE_CUBE; + + createInfo.imageType = VK_IMAGE_TYPE_2D; + createInfo.extent.width = params.width; + createInfo.extent.height = params.height; + createInfo.extent.depth = 1; + createInfo.arrayLayers = 6; + createInfo.flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT; + break; + + default: + break; + } + + VmaAllocationCreateInfo allocInfo = {}; + allocInfo.usage = VMA_MEMORY_USAGE_GPU_ONLY; + + VkResult result = vmaCreateImage(m_device.GetMemoryAllocator(), &createInfo, &allocInfo, &m_image, &m_allocation, nullptr); + if (result != VK_SUCCESS) + throw std::runtime_error("Failed to allocate image: " + TranslateOpenGLError(result)); + + createInfoView.image = m_image; + + if (!m_imageView.Create(device, createInfoView)) + { + // FIXME + vmaDestroyImage(m_device.GetMemoryAllocator(), m_image, m_allocation); + throw std::runtime_error("Failed to create image view: " + TranslateOpenGLError(m_imageView.GetLastErrorCode())); + } + } + + OpenGLTexture::~OpenGLTexture() + { + vmaDestroyImage(m_device.GetMemoryAllocator(), m_image, m_allocation); + } + + PixelFormat OpenGLTexture::GetFormat() const + { + return m_params.pixelFormat; + } + + UInt8 OpenGLTexture::GetLevelCount() const + { + return m_params.mipmapLevel; + } + + Vector3ui OpenGLTexture::GetSize(UInt8 level) const + { + return Vector3ui(GetLevelSize(m_params.width, level), GetLevelSize(m_params.height, level), GetLevelSize(m_params.depth, level)); + } + + ImageType OpenGLTexture::GetType() const + { + return m_params.type; + } + + bool OpenGLTexture::Update(const void* ptr) + { + std::size_t textureSize = m_params.width * m_params.height * m_params.depth * PixelFormatInfo::GetBytesPerPixel(m_params.pixelFormat); + + VkBufferCreateInfo createInfo = {}; + createInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; + createInfo.size = textureSize; + createInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT; + + VmaAllocationCreateInfo allocInfo = {}; + allocInfo.flags = VMA_ALLOCATION_CREATE_MAPPED_BIT; + allocInfo.usage = VMA_MEMORY_USAGE_CPU_TO_GPU; + + VmaAllocationInfo allocationInfo; + + VkBuffer stagingBuffer; + VmaAllocation stagingAllocation; + + VkResult result = vmaCreateBuffer(m_device.GetMemoryAllocator(), &createInfo, &allocInfo, &stagingBuffer, &stagingAllocation, &allocationInfo); + if (result != VK_SUCCESS) + { + NazaraError("Failed to allocate staging buffer: " + TranslateOpenGLError(result)); + return false; + } + + CallOnExit freeStaging([&] { + vmaDestroyBuffer(m_device.GetMemoryAllocator(), stagingBuffer, stagingAllocation); + }); + + std::memcpy(allocationInfo.pMappedData, ptr, textureSize); + + Vk::AutoCommandBuffer copyCommandBuffer = m_device.AllocateCommandBuffer(QueueType::Graphics); + if (!copyCommandBuffer->Begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT)) + return false; + + copyCommandBuffer->SetImageLayout(m_image, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); + + copyCommandBuffer->CopyBufferToImage(stagingBuffer, m_image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, m_params.width, m_params.height, m_params.depth); + + copyCommandBuffer->SetImageLayout(m_image, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); + + if (!copyCommandBuffer->End()) + return false; + + Vk::QueueHandle transferQueue = m_device.GetQueue(m_device.GetDefaultFamilyIndex(QueueType::Graphics), 0); + if (!transferQueue.Submit(copyCommandBuffer)) + return false; + + transferQueue.WaitIdle(); + + return true; + } + + void OpenGLTexture::InitForFormat(PixelFormat pixelFormat, VkImageCreateInfo& createImage, VkImageViewCreateInfo& createImageView) + { + createImageView.components = { + VK_COMPONENT_SWIZZLE_R, + VK_COMPONENT_SWIZZLE_G, + VK_COMPONENT_SWIZZLE_B, + VK_COMPONENT_SWIZZLE_A + }; + + switch (pixelFormat) + { + case PixelFormat_L8: + { + createImage.format = VK_FORMAT_R8_SRGB; + createImageView.format = createImage.format; + createImageView.components = { + VK_COMPONENT_SWIZZLE_R, + VK_COMPONENT_SWIZZLE_R, + VK_COMPONENT_SWIZZLE_R, + VK_COMPONENT_SWIZZLE_A + }; + break; + } + + case PixelFormat_LA8: + { + createImage.format = VK_FORMAT_R8G8_SRGB; + createImageView.format = createImage.format; + createImageView.components = { + VK_COMPONENT_SWIZZLE_R, + VK_COMPONENT_SWIZZLE_R, + VK_COMPONENT_SWIZZLE_R, + VK_COMPONENT_SWIZZLE_G + }; + break; + } + + case PixelFormat_RGB8: + { + createImage.format = VK_FORMAT_R8G8B8_SRGB; + createImageView.format = createImage.format; + break; + } + + case PixelFormat_RGBA8: + { + createImage.format = VK_FORMAT_R8G8B8A8_SRGB; + createImageView.format = createImage.format; + break; + } + + default: + throw std::runtime_error(("Unsupported pixel format " + PixelFormatInfo::GetName(pixelFormat)).ToStdString()); + } + } +} + +#endif diff --git a/src/Nazara/OpenGLRenderer/OpenGLTextureSampler.cpp b/src/Nazara/OpenGLRenderer/OpenGLTextureSampler.cpp new file mode 100644 index 000000000..6a8dd75eb --- /dev/null +++ b/src/Nazara/OpenGLRenderer/OpenGLTextureSampler.cpp @@ -0,0 +1,35 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#if 0 + +#include +#include +#include + +namespace Nz +{ + OpenGLTextureSampler::OpenGLTextureSampler(Vk::Device& device, TextureSamplerInfo samplerInfo) + { + VkSamplerCreateInfo createInfo = { VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO }; + createInfo.magFilter = ToOpenGL(samplerInfo.magFilter); + createInfo.minFilter = ToOpenGL(samplerInfo.minFilter); + createInfo.addressModeU = ToOpenGL(samplerInfo.wrapModeU); + createInfo.addressModeV = ToOpenGL(samplerInfo.wrapModeV); + createInfo.addressModeW = ToOpenGL(samplerInfo.wrapModeW); + createInfo.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK; + createInfo.mipmapMode = ToOpenGL(samplerInfo.mipmapMode); + + if (samplerInfo.anisotropyLevel > 0.f) + { + createInfo.anisotropyEnable = VK_TRUE; + createInfo.maxAnisotropy = samplerInfo.anisotropyLevel; + } + + if (!m_sampler.Create(device, createInfo)) + throw std::runtime_error("Failed to create sampler: " + TranslateOpenGLError(m_sampler.GetLastErrorCode())); + } +} + +#endif diff --git a/src/Nazara/OpenGLRenderer/OpenGLUploadPool.cpp b/src/Nazara/OpenGLRenderer/OpenGLUploadPool.cpp new file mode 100644 index 000000000..687988f9b --- /dev/null +++ b/src/Nazara/OpenGLRenderer/OpenGLUploadPool.cpp @@ -0,0 +1,91 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#if 0 + +#include +#include +#include +#include + +namespace Nz +{ + auto OpenGLUploadPool::Allocate(UInt64 size) -> OpenGLAllocation& + { + const auto& deviceProperties = m_device.GetPhysicalDeviceInfo().properties; + UInt64 preferredAlignement = deviceProperties.limits.optimalBufferCopyOffsetAlignment; + + return Allocate(size, preferredAlignement); + } + + auto OpenGLUploadPool::Allocate(UInt64 size, UInt64 alignment) -> OpenGLAllocation& + { + assert(size <= m_blockSize); + + // Try to minimize lost space + struct + { + Block* block = nullptr; + UInt64 alignedOffset = 0; + UInt64 lostSpace = 0; + } bestBlock; + + for (Block& block : m_blocks) + { + UInt64 alignedOffset = AlignPow2(block.freeOffset, alignment); + if (alignedOffset + size > m_blockSize) + continue; //< Not enough space + + UInt64 lostSpace = alignedOffset - block.freeOffset; + + if (!bestBlock.block || lostSpace < bestBlock.lostSpace) + { + bestBlock.block = █ + bestBlock.alignedOffset = alignedOffset; + bestBlock.lostSpace = lostSpace; + } + } + + // No block found, allocate a new one + if (!bestBlock.block) + { + Block newBlock; + if (!newBlock.buffer.Create(m_device, 0U, m_blockSize, VK_BUFFER_USAGE_TRANSFER_SRC_BIT)) + throw std::runtime_error("Failed to create block buffer: " + TranslateOpenGLError(newBlock.buffer.GetLastErrorCode())); + + VkMemoryRequirements requirement = newBlock.buffer.GetMemoryRequirements(); + + if (!newBlock.blockMemory.Create(m_device, requirement.size, requirement.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) + throw std::runtime_error("Failed to allocate block memory: " + TranslateOpenGLError(newBlock.blockMemory.GetLastErrorCode())); + + if (!newBlock.buffer.BindBufferMemory(newBlock.blockMemory)) + throw std::runtime_error("Failed to bind buffer memory: " + TranslateOpenGLError(newBlock.buffer.GetLastErrorCode())); + + if (!newBlock.blockMemory.Map()) + throw std::runtime_error("Failed to map buffer memory: " + TranslateOpenGLError(newBlock.buffer.GetLastErrorCode())); + + bestBlock.block = &m_blocks.emplace_back(std::move(newBlock)); + bestBlock.alignedOffset = 0; + bestBlock.lostSpace = 0; + } + + OpenGLAllocation& allocationData = m_allocations.emplace_back(); + allocationData.buffer = bestBlock.block->buffer; + allocationData.mappedPtr = static_cast(bestBlock.block->blockMemory.GetMappedPointer()) + bestBlock.alignedOffset; + allocationData.offset = bestBlock.alignedOffset; + allocationData.size = size; + + return allocationData; + } + + void OpenGLUploadPool::Reset() + { + for (Block& block : m_blocks) + block.freeOffset = 0; + + m_allocations.clear(); + } +} + +#endif diff --git a/src/Nazara/OpenGLRenderer/Utils_OpenGLRenderer.cpp b/src/Nazara/OpenGLRenderer/Utils_OpenGLRenderer.cpp new file mode 100644 index 000000000..80809c949 --- /dev/null +++ b/src/Nazara/OpenGLRenderer/Utils_OpenGLRenderer.cpp @@ -0,0 +1,106 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#if 0 + +#include +#include + +namespace Nz +{ + std::string TranslateOpenGLError(VkResult code) + { + // From https://www.khronos.org/registry/vulkan/specs/1.0-wsi_extensions/xhtml/vkspec.html#VkResult + switch (code) + { + case VK_SUCCESS: + return "No error"; + + case VK_NOT_READY: + return "A fence or query has not yet completed"; + + case VK_TIMEOUT: + return "A wait operation has not completed in the specified time"; + + case VK_EVENT_SET: + return "An event is signaled"; + + case VK_EVENT_RESET: + return "An event is unsignaled"; + + case VK_INCOMPLETE: + return "A return array was too small for the result"; + + case VK_ERROR_OUT_OF_HOST_MEMORY: + return "A host memory allocation has failed"; + + case VK_ERROR_OUT_OF_DEVICE_MEMORY: + return "A device memory allocation has failed"; + + case VK_ERROR_INITIALIZATION_FAILED: + return "Initialization of an object could not be completed for implementation-specific reasons"; + + case VK_ERROR_DEVICE_LOST: + return "The logical or physical device has been lost"; + + case VK_ERROR_MEMORY_MAP_FAILED: + return "Mapping of the memory object has failed"; + + case VK_ERROR_LAYER_NOT_PRESENT: + return "A requested layer is not present or could not be loaded"; + + case VK_ERROR_EXTENSION_NOT_PRESENT: + return "A requested extension is not supported"; + + case VK_ERROR_FEATURE_NOT_PRESENT: + return "A requested feature is not supported"; + + case VK_ERROR_INCOMPATIBLE_DRIVER: + return "The requested version of OpenGL is not supported by the driver or is otherwise incompatible for implementation-specific reasons"; + + case VK_ERROR_TOO_MANY_OBJECTS: + return "Too many objects of the type have already been created"; + + case VK_ERROR_FORMAT_NOT_SUPPORTED: + return "A requested format is not supported on this device"; + + case VK_ERROR_FRAGMENTED_POOL: + return "A requested pool allocation has failed due to fragmentation of the pool’s memory"; + + case VK_ERROR_SURFACE_LOST_KHR: + return "A surface is no longer available"; + + case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR: + return "The requested window is already connected to a VkSurfaceKHR, or to some other non-OpenGL API"; + + case VK_SUBOPTIMAL_KHR: + return "A swapchain no longer matches the surface properties exactly, but can still be used to present to the surface successfully"; + + case VK_ERROR_OUT_OF_DATE_KHR: + return "A surface has changed in such a way that it is no longer compatible with the swapchain, and further presentation requests using the swapchain will fail. Applications must query the new surface properties and recreate their swapchain if they wish to continue presenting to the surface"; + + case VK_ERROR_INCOMPATIBLE_DISPLAY_KHR: + return "The display used by a swapchain does not use the same presentable image layout, or is incompatible in a way that prevents sharing an image"; + + case VK_ERROR_VALIDATION_FAILED_EXT: + return "A validation layer found an error"; + + case VK_ERROR_INVALID_SHADER_NV: + return "One or more shaders failed to compile or link"; + + case VK_ERROR_OUT_OF_POOL_MEMORY_KHR: + return "A requested pool allocation has failed"; + + case VK_ERROR_INVALID_EXTERNAL_HANDLE: + return "An external handle is not a valid handle of the specified type"; + + default: + break; + } + + return "Unknown OpenGL error (0x" + String::Number(code, 16).ToStdString() + ')'; + } +} + +#endif diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp new file mode 100644 index 000000000..06f4578d0 --- /dev/null +++ b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp @@ -0,0 +1,10 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz::GL +{ +} diff --git a/src/Nazara/OpenGLRenderer/Wrapper/GLContext.cpp b/src/Nazara/OpenGLRenderer/Wrapper/GLContext.cpp new file mode 100644 index 000000000..23ba56493 --- /dev/null +++ b/src/Nazara/OpenGLRenderer/Wrapper/GLContext.cpp @@ -0,0 +1,44 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include + +namespace Nz::GL +{ + GLContext::~GLContext() = default; + + bool GLContext::LoadCoreFunctions(Loader& loader) + { + if (!Activate()) + { + NazaraError("failed to activate context"); + return false; + } + + auto LoadSymbol = [&](auto& func, const char* funcName) + { + func = reinterpret_cast>(loader.LoadFunction(funcName)); + if (!func) + throw std::runtime_error("failed to load core function " + std::string(funcName)); + }; + + try + { +#define NAZARA_OPENGLRENDERER_FUNC(name, sig) LoadSymbol(name, #name); + NAZARA_OPENGLRENDERER_FOREACH_GLES_FUNC(NAZARA_OPENGLRENDERER_FUNC) +#undef NAZARA_OPENGLRENDERER_FUNC + } + catch (const std::exception& e) + { + NazaraError(e.what()); + return false; + } + + return true; + } +} diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Loader.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Loader.cpp new file mode 100644 index 000000000..ecfef795e --- /dev/null +++ b/src/Nazara/OpenGLRenderer/Wrapper/Loader.cpp @@ -0,0 +1,11 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz::GL +{ + Loader::~Loader() = default; +} diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp new file mode 100644 index 000000000..edb84f5bd --- /dev/null +++ b/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp @@ -0,0 +1,278 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include +#include +#include + +namespace Nz::GL +{ + thread_local WGLContext* s_currentContext = nullptr; + + GL::WGLContext::WGLContext(WGLLoader& loader) : + m_loader(loader) + { + } + + WGLContext::~WGLContext() + { + Destroy(); + } + + bool WGLContext::Activate() + { + WGLContext*& currentContext = s_currentContext; //< Pay TLS cost only once + if (currentContext) + { + if (currentContext == this) + return true; + + // Only one context can be activated per thread + currentContext->Desactivate(); + } + + bool succeeded = m_loader.wglMakeCurrent(m_deviceContext, m_handle); + if (!succeeded) + { + NazaraError("failed to activate context: " + Error::GetLastSystemError()); + return false; + } + + currentContext = this; + + return true; + } + + bool WGLContext::Create(const ContextParams& params) + { + Destroy(); + + // Creating a context requires a Window + m_window.reset(::CreateWindowA("STATIC", nullptr, WS_DISABLED | WS_POPUP, 0, 0, 1, 1, nullptr, nullptr, GetModuleHandle(nullptr), nullptr)); + if (!m_window) + { + NazaraError("failed to create dummy window: " + Error::GetLastSystemError()); + return false; + } + + ::ShowWindow(m_window.get(), FALSE); + + m_deviceContext = ::GetDC(m_window.get()); + if (!m_deviceContext) + { + NazaraError("failed to retrieve dummy window device context: " + Error::GetLastSystemError()); + return false; + } + + if (!SetPixelFormat(params)) + return false; + + WGLContext* currentContext = s_currentContext; //< Pay TLS cost only once + if (currentContext && currentContext->wglCreateContextAttribsARB) + { + struct OpenGLVersion + { + int major; + int minor; + }; + + std::array supportedVersions = { + { + { 4, 6 }, + { 4, 5 }, + { 4, 4 }, + { 4, 3 }, + { 4, 2 }, + { 4, 1 }, + { 4, 0 }, + { 3, 3 } + } + }; + + for (const OpenGLVersion& version : supportedVersions) + { + std::array attributes = { + WGL_CONTEXT_MAJOR_VERSION_ARB, version.major, + WGL_CONTEXT_MINOR_VERSION_ARB, version.minor, + + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB + }; + + m_handle = currentContext->wglCreateContextAttribsARB(m_deviceContext, nullptr, attributes.data()); + if (m_handle) + break; + } + + if (!m_handle) + { + NazaraError("failed to create WGL context: " + Error::GetLastSystemError()); + return false; + } + } + else + { + m_handle = m_loader.wglCreateContext(m_deviceContext); + if (!m_handle) + { + NazaraError("failed to create WGL context: " + Error::GetLastSystemError()); + return false; + } + } + + LoadWGLExt(); + + return true; + } + + void WGLContext::Destroy() + { + if (m_handle) + { + WGLContext*& currentContext = s_currentContext; //< Pay TLS cost only once + if (currentContext == this) + currentContext = nullptr; + + m_loader.wglDeleteContext(m_handle); + m_handle = nullptr; + } + } + + void WGLContext::EnableVerticalSync(bool enabled) + { + } + + void WGLContext::SwapBuffers() + { + m_loader.SwapBuffers(m_deviceContext); + } + + void WGLContext::Desactivate() + { + WGLContext*& currentContext = s_currentContext; //< Pay TLS cost only once + if (currentContext == this) + { + m_loader.wglMakeCurrent(nullptr, nullptr); + currentContext = nullptr; + } + } + + bool WGLContext::LoadWGLExt() + { + if (!Activate()) + return false; + +#define NAZARA_OPENGLRENDERER_FUNC(name, sig) +#define NAZARA_OPENGLRENDERER_EXT_BEGIN(ext) +#define NAZARA_OPENGLRENDERER_EXT_END() +#define NAZARA_OPENGLRENDERER_EXT_FUNC(name, sig) name = reinterpret_cast(m_loader.wglGetProcAddress(#name)); + NAZARA_OPENGLRENDERER_FOREACH_WGL_FUNC(NAZARA_OPENGLRENDERER_FUNC, NAZARA_OPENGLRENDERER_EXT_BEGIN, NAZARA_OPENGLRENDERER_EXT_END, NAZARA_OPENGLRENDERER_EXT_FUNC) +#undef NAZARA_OPENGLRENDERER_EXT_BEGIN +#undef NAZARA_OPENGLRENDERER_EXT_END +#undef NAZARA_OPENGLRENDERER_EXT_FUNC +#undef NAZARA_OPENGLRENDERER_FUNC + + const char* extensionString = nullptr; + if (wglGetExtensionsStringARB) + extensionString = wglGetExtensionsStringARB(m_deviceContext); + else if (wglGetExtensionsStringEXT) + extensionString = wglGetExtensionsStringEXT(); + + if (extensionString) + { + SplitString(extensionString, " ", [&](std::string_view extension) + { + m_supportedExtensions.emplace(extension); + return true; + }); + } + + return true; + } + + bool WGLContext::SetPixelFormat(const ContextParams& params) + { + PIXELFORMATDESCRIPTOR descriptor = {}; + descriptor.nSize = sizeof(PIXELFORMATDESCRIPTOR); + descriptor.nVersion = 1; + + int pixelFormat = 0; + if (params.sampleCount > 1) + { + WGLContext* currentContext = s_currentContext; //< Pay TLS cost only once + if (currentContext) + { + // WGL_ARB_pixel_format and WGL_EXT_pixel_format are the same, except for the symbol + auto wglChoosePixelFormat = (currentContext->wglChoosePixelFormatARB) ? currentContext->wglChoosePixelFormatARB : currentContext->wglChoosePixelFormatEXT; + + if (wglChoosePixelFormat) + { + std::array attributes = { + WGL_DRAW_TO_WINDOW_ARB, GL_TRUE, + WGL_SUPPORT_OPENGL_ARB, GL_TRUE, + WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB, + WGL_COLOR_BITS_ARB, (params.bitsPerPixel == 32) ? 24 : params.bitsPerPixel, + WGL_ALPHA_BITS_ARB, (params.bitsPerPixel == 32) ? 8 : 0, + WGL_DEPTH_BITS_ARB, params.depthBits, + WGL_STENCIL_BITS_ARB, params.stencilBits, + WGL_DOUBLE_BUFFER_ARB, (params.doubleBuffering) ? GL_TRUE : GL_FALSE, + WGL_SAMPLE_BUFFERS_ARB, GL_TRUE, + WGL_SAMPLES_ARB, params.sampleCount + }; + + int& sampleCount = attributes[attributes.size() - 3]; + + do + { + UINT formatCount; + if (currentContext->wglChoosePixelFormatARB(m_deviceContext, attributes.data(), nullptr, 1, &pixelFormat, &formatCount)) + { + if (formatCount > 0) + break; + } + + sampleCount--; + } + while (sampleCount > 1); + + if (params.sampleCount != sampleCount) + NazaraWarning("couldn't find a pixel format matching " + std::to_string(params.sampleCount) + " sample count, using " + std::to_string(sampleCount) + " sample(s) instead"); + } + } + } + + if (pixelFormat == 0) + { + descriptor.cColorBits = BYTE((params.bitsPerPixel == 32) ? 24 : params.bitsPerPixel); + descriptor.cDepthBits = BYTE(params.depthBits); + descriptor.cStencilBits = BYTE(params.stencilBits); + descriptor.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL; + descriptor.iPixelType = PFD_TYPE_RGBA; + + if (params.bitsPerPixel == 32) + descriptor.cAlphaBits = 8; + + if (params.doubleBuffering) + descriptor.dwFlags |= PFD_DOUBLEBUFFER; + + pixelFormat = m_loader.ChoosePixelFormat(m_deviceContext, &descriptor); + if (pixelFormat == 0) + { + NazaraError("Failed to choose pixel format: " + Error::GetLastSystemError()); + return false; + } + } + + if (!m_loader.SetPixelFormat(m_deviceContext, pixelFormat, &descriptor)) + { + NazaraError("Failed to choose pixel format: " + Error::GetLastSystemError()); + return false; + } + + return true; + } +} diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.cpp new file mode 100644 index 000000000..b813af9c3 --- /dev/null +++ b/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.cpp @@ -0,0 +1,70 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz::GL +{ + WGLLoader::WGLLoader(DynLib& openglLib) : + m_opengl32Lib(openglLib) + { + if (!m_gdi32Lib.Load("gdi32.dll")) + throw std::runtime_error("failed to load gdi32.dll: " + m_gdi32Lib.GetLastError()); + + auto LoadSymbol = [](DynLib& lib, auto& func, const char* funcName) + { + func = reinterpret_cast>(lib.GetSymbol(funcName)); + if (!func) + throw std::runtime_error("failed to load core function " + std::string(funcName)); + }; + + // Load gdi32 functions +#define NAZARA_OPENGLRENDERER_EXT_BEGIN(ext) +#define NAZARA_OPENGLRENDERER_EXT_END() +#define NAZARA_OPENGLRENDERER_EXT_FUNC(name, sig) //< Ignore extensions + +#define NAZARA_OPENGLRENDERER_FUNC(name, sig) LoadSymbol(m_gdi32Lib, name, #name); + NAZARA_OPENGLRENDERER_FOREACH_GDI32_FUNC(NAZARA_OPENGLRENDERER_FUNC) +#undef NAZARA_OPENGLRENDERER_FUNC + + // Load base WGL functions +#define NAZARA_OPENGLRENDERER_FUNC(name, sig) LoadSymbol(m_opengl32Lib, name, #name); + NAZARA_OPENGLRENDERER_FOREACH_WGL_FUNC(NAZARA_OPENGLRENDERER_FUNC, NAZARA_OPENGLRENDERER_EXT_BEGIN, NAZARA_OPENGLRENDERER_EXT_END, NAZARA_OPENGLRENDERER_EXT_FUNC) +#undef NAZARA_OPENGLRENDERER_FUNC + + // In order to load OpenGL functions, we have to create a context first + WGLContext dummyContext(*this); + + if (!dummyContext.Create({})) + throw std::runtime_error("failed to create load context"); + + WGLContext loadContext(*this); + + if (!loadContext.Create({})) + throw std::runtime_error("failed to create load context"); + + if (!loadContext.LoadCoreFunctions(*this)) + throw std::runtime_error("failed to load OpenGL functions"); + +#undef NAZARA_OPENGLRENDERER_EXT_BEGIN +#undef NAZARA_OPENGLRENDERER_EXT_END +#undef NAZARA_OPENGLRENDERER_EXT_FUNC + } + + std::unique_ptr WGLLoader::CreateContext() + { + return {}; //< TODO + } + + GLFunction WGLLoader::LoadFunction(const char* name) + { + GLFunction func = reinterpret_cast(wglGetProcAddress(name)); + if (!func) //< wglGetProcAddress doesn't work for OpenGL 1.1 functions + func = reinterpret_cast(m_opengl32Lib.GetSymbol(name)); + + return func; + } +} diff --git a/src/Nazara/Renderer/Win32/ContextImpl.hpp b/src/Nazara/Renderer/Win32/ContextImpl.hpp deleted file mode 100644 index ffd61e12f..000000000 --- a/src/Nazara/Renderer/Win32/ContextImpl.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_CONTEXTIMPL_HPP -#define NAZARA_CONTEXTIMPL_HPP - -#include -#include -#include - -namespace Nz -{ - class ContextImpl - { - public: - ContextImpl(); - - bool Activate() const; - - bool Create(ContextParameters& parameters); - - void Destroy(); - - void EnableVerticalSync(bool enabled); - - void SwapBuffers(); - - static bool Desactivate(); - - private: - HDC m_deviceContext; - HGLRC m_context; - HWND m_window; - bool m_ownsWindow; - }; -} - -#endif // NAZARA_CONTEXTIMPL_HPP diff --git a/thirdparty/include/EGL/egl.h b/thirdparty/include/EGL/egl.h new file mode 100644 index 000000000..959f175d7 --- /dev/null +++ b/thirdparty/include/EGL/egl.h @@ -0,0 +1,361 @@ +#ifndef __egl_h_ +#define __egl_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2013-2017 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are 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 Materials. +** +** THE MATERIALS ARE 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 +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ +/* +** This header is generated from the Khronos EGL XML API Registry. +** The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** http://www.khronos.org/registry/egl +** +** Khronos $Git commit SHA1: b5409265f3 $ on $Git commit date: 2020-02-20 08:24:34 -0800 $ +*/ + +#include + +#ifndef EGL_EGL_PROTOTYPES +#define EGL_EGL_PROTOTYPES 1 +#endif + +/* Generated on date 20200220 */ + +/* Generated C header for: + * API: egl + * Versions considered: .* + * Versions emitted: .* + * Default extensions included: None + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef EGL_VERSION_1_0 +#define EGL_VERSION_1_0 1 +typedef unsigned int EGLBoolean; +typedef void *EGLDisplay; +#include +#include +typedef void *EGLConfig; +typedef void *EGLSurface; +typedef void *EGLContext; +typedef void (*__eglMustCastToProperFunctionPointerType)(void); +#define EGL_ALPHA_SIZE 0x3021 +#define EGL_BAD_ACCESS 0x3002 +#define EGL_BAD_ALLOC 0x3003 +#define EGL_BAD_ATTRIBUTE 0x3004 +#define EGL_BAD_CONFIG 0x3005 +#define EGL_BAD_CONTEXT 0x3006 +#define EGL_BAD_CURRENT_SURFACE 0x3007 +#define EGL_BAD_DISPLAY 0x3008 +#define EGL_BAD_MATCH 0x3009 +#define EGL_BAD_NATIVE_PIXMAP 0x300A +#define EGL_BAD_NATIVE_WINDOW 0x300B +#define EGL_BAD_PARAMETER 0x300C +#define EGL_BAD_SURFACE 0x300D +#define EGL_BLUE_SIZE 0x3022 +#define EGL_BUFFER_SIZE 0x3020 +#define EGL_CONFIG_CAVEAT 0x3027 +#define EGL_CONFIG_ID 0x3028 +#define EGL_CORE_NATIVE_ENGINE 0x305B +#define EGL_DEPTH_SIZE 0x3025 +#define EGL_DONT_CARE EGL_CAST(EGLint,-1) +#define EGL_DRAW 0x3059 +#define EGL_EXTENSIONS 0x3055 +#define EGL_FALSE 0 +#define EGL_GREEN_SIZE 0x3023 +#define EGL_HEIGHT 0x3056 +#define EGL_LARGEST_PBUFFER 0x3058 +#define EGL_LEVEL 0x3029 +#define EGL_MAX_PBUFFER_HEIGHT 0x302A +#define EGL_MAX_PBUFFER_PIXELS 0x302B +#define EGL_MAX_PBUFFER_WIDTH 0x302C +#define EGL_NATIVE_RENDERABLE 0x302D +#define EGL_NATIVE_VISUAL_ID 0x302E +#define EGL_NATIVE_VISUAL_TYPE 0x302F +#define EGL_NONE 0x3038 +#define EGL_NON_CONFORMANT_CONFIG 0x3051 +#define EGL_NOT_INITIALIZED 0x3001 +#define EGL_NO_CONTEXT EGL_CAST(EGLContext,0) +#define EGL_NO_DISPLAY EGL_CAST(EGLDisplay,0) +#define EGL_NO_SURFACE EGL_CAST(EGLSurface,0) +#define EGL_PBUFFER_BIT 0x0001 +#define EGL_PIXMAP_BIT 0x0002 +#define EGL_READ 0x305A +#define EGL_RED_SIZE 0x3024 +#define EGL_SAMPLES 0x3031 +#define EGL_SAMPLE_BUFFERS 0x3032 +#define EGL_SLOW_CONFIG 0x3050 +#define EGL_STENCIL_SIZE 0x3026 +#define EGL_SUCCESS 0x3000 +#define EGL_SURFACE_TYPE 0x3033 +#define EGL_TRANSPARENT_BLUE_VALUE 0x3035 +#define EGL_TRANSPARENT_GREEN_VALUE 0x3036 +#define EGL_TRANSPARENT_RED_VALUE 0x3037 +#define EGL_TRANSPARENT_RGB 0x3052 +#define EGL_TRANSPARENT_TYPE 0x3034 +#define EGL_TRUE 1 +#define EGL_VENDOR 0x3053 +#define EGL_VERSION 0x3054 +#define EGL_WIDTH 0x3057 +#define EGL_WINDOW_BIT 0x0004 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLCHOOSECONFIGPROC) (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOPYBUFFERSPROC) (EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target); +typedef EGLContext (EGLAPIENTRYP PFNEGLCREATECONTEXTPROC) (EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list); +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPBUFFERSURFACEPROC) (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list); +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEPROC) (EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list); +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEWINDOWSURFACEPROC) (EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYCONTEXTPROC) (EGLDisplay dpy, EGLContext ctx); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSURFACEPROC) (EGLDisplay dpy, EGLSurface surface); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETCONFIGATTRIBPROC) (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETCONFIGSPROC) (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config); +typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETCURRENTDISPLAYPROC) (void); +typedef EGLSurface (EGLAPIENTRYP PFNEGLGETCURRENTSURFACEPROC) (EGLint readdraw); +typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETDISPLAYPROC) (EGLNativeDisplayType display_id); +typedef EGLint (EGLAPIENTRYP PFNEGLGETERRORPROC) (void); +typedef __eglMustCastToProperFunctionPointerType (EGLAPIENTRYP PFNEGLGETPROCADDRESSPROC) (const char *procname); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLINITIALIZEPROC) (EGLDisplay dpy, EGLint *major, EGLint *minor); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLMAKECURRENTPROC) (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYCONTEXTPROC) (EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value); +typedef const char *(EGLAPIENTRYP PFNEGLQUERYSTRINGPROC) (EGLDisplay dpy, EGLint name); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSPROC) (EGLDisplay dpy, EGLSurface surface); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLTERMINATEPROC) (EGLDisplay dpy); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLWAITGLPROC) (void); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLWAITNATIVEPROC) (EGLint engine); +#if EGL_EGL_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config); +EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers (EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target); +EGLAPI EGLContext EGLAPIENTRY eglCreateContext (EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface (EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface (EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext (EGLDisplay dpy, EGLContext ctx); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface (EGLDisplay dpy, EGLSurface surface); +EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value); +EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config); +EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay (void); +EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface (EGLint readdraw); +EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay (EGLNativeDisplayType display_id); +EGLAPI EGLint EGLAPIENTRY eglGetError (void); +EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress (const char *procname); +EGLAPI EGLBoolean EGLAPIENTRY eglInitialize (EGLDisplay dpy, EGLint *major, EGLint *minor); +EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext (EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value); +EGLAPI const char *EGLAPIENTRY eglQueryString (EGLDisplay dpy, EGLint name); +EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value); +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers (EGLDisplay dpy, EGLSurface surface); +EGLAPI EGLBoolean EGLAPIENTRY eglTerminate (EGLDisplay dpy); +EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL (void); +EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative (EGLint engine); +#endif +#endif /* EGL_VERSION_1_0 */ + +#ifndef EGL_VERSION_1_1 +#define EGL_VERSION_1_1 1 +#define EGL_BACK_BUFFER 0x3084 +#define EGL_BIND_TO_TEXTURE_RGB 0x3039 +#define EGL_BIND_TO_TEXTURE_RGBA 0x303A +#define EGL_CONTEXT_LOST 0x300E +#define EGL_MIN_SWAP_INTERVAL 0x303B +#define EGL_MAX_SWAP_INTERVAL 0x303C +#define EGL_MIPMAP_TEXTURE 0x3082 +#define EGL_MIPMAP_LEVEL 0x3083 +#define EGL_NO_TEXTURE 0x305C +#define EGL_TEXTURE_2D 0x305F +#define EGL_TEXTURE_FORMAT 0x3080 +#define EGL_TEXTURE_RGB 0x305D +#define EGL_TEXTURE_RGBA 0x305E +#define EGL_TEXTURE_TARGET 0x3081 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLBINDTEXIMAGEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint buffer); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLRELEASETEXIMAGEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint buffer); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSURFACEATTRIBPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPINTERVALPROC) (EGLDisplay dpy, EGLint interval); +#if EGL_EGL_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer); +EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer); +EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value); +EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval (EGLDisplay dpy, EGLint interval); +#endif +#endif /* EGL_VERSION_1_1 */ + +#ifndef EGL_VERSION_1_2 +#define EGL_VERSION_1_2 1 +typedef unsigned int EGLenum; +typedef void *EGLClientBuffer; +#define EGL_ALPHA_FORMAT 0x3088 +#define EGL_ALPHA_FORMAT_NONPRE 0x308B +#define EGL_ALPHA_FORMAT_PRE 0x308C +#define EGL_ALPHA_MASK_SIZE 0x303E +#define EGL_BUFFER_PRESERVED 0x3094 +#define EGL_BUFFER_DESTROYED 0x3095 +#define EGL_CLIENT_APIS 0x308D +#define EGL_COLORSPACE 0x3087 +#define EGL_COLORSPACE_sRGB 0x3089 +#define EGL_COLORSPACE_LINEAR 0x308A +#define EGL_COLOR_BUFFER_TYPE 0x303F +#define EGL_CONTEXT_CLIENT_TYPE 0x3097 +#define EGL_DISPLAY_SCALING 10000 +#define EGL_HORIZONTAL_RESOLUTION 0x3090 +#define EGL_LUMINANCE_BUFFER 0x308F +#define EGL_LUMINANCE_SIZE 0x303D +#define EGL_OPENGL_ES_BIT 0x0001 +#define EGL_OPENVG_BIT 0x0002 +#define EGL_OPENGL_ES_API 0x30A0 +#define EGL_OPENVG_API 0x30A1 +#define EGL_OPENVG_IMAGE 0x3096 +#define EGL_PIXEL_ASPECT_RATIO 0x3092 +#define EGL_RENDERABLE_TYPE 0x3040 +#define EGL_RENDER_BUFFER 0x3086 +#define EGL_RGB_BUFFER 0x308E +#define EGL_SINGLE_BUFFER 0x3085 +#define EGL_SWAP_BEHAVIOR 0x3093 +#define EGL_UNKNOWN EGL_CAST(EGLint,-1) +#define EGL_VERTICAL_RESOLUTION 0x3091 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLBINDAPIPROC) (EGLenum api); +typedef EGLenum (EGLAPIENTRYP PFNEGLQUERYAPIPROC) (void); +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPBUFFERFROMCLIENTBUFFERPROC) (EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLRELEASETHREADPROC) (void); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLWAITCLIENTPROC) (void); +#if EGL_EGL_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI (EGLenum api); +EGLAPI EGLenum EGLAPIENTRY eglQueryAPI (void); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer (EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread (void); +EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient (void); +#endif +#endif /* EGL_VERSION_1_2 */ + +#ifndef EGL_VERSION_1_3 +#define EGL_VERSION_1_3 1 +#define EGL_CONFORMANT 0x3042 +#define EGL_CONTEXT_CLIENT_VERSION 0x3098 +#define EGL_MATCH_NATIVE_PIXMAP 0x3041 +#define EGL_OPENGL_ES2_BIT 0x0004 +#define EGL_VG_ALPHA_FORMAT 0x3088 +#define EGL_VG_ALPHA_FORMAT_NONPRE 0x308B +#define EGL_VG_ALPHA_FORMAT_PRE 0x308C +#define EGL_VG_ALPHA_FORMAT_PRE_BIT 0x0040 +#define EGL_VG_COLORSPACE 0x3087 +#define EGL_VG_COLORSPACE_sRGB 0x3089 +#define EGL_VG_COLORSPACE_LINEAR 0x308A +#define EGL_VG_COLORSPACE_LINEAR_BIT 0x0020 +#endif /* EGL_VERSION_1_3 */ + +#ifndef EGL_VERSION_1_4 +#define EGL_VERSION_1_4 1 +#define EGL_DEFAULT_DISPLAY EGL_CAST(EGLNativeDisplayType,0) +#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200 +#define EGL_MULTISAMPLE_RESOLVE 0x3099 +#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A +#define EGL_MULTISAMPLE_RESOLVE_BOX 0x309B +#define EGL_OPENGL_API 0x30A2 +#define EGL_OPENGL_BIT 0x0008 +#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400 +typedef EGLContext (EGLAPIENTRYP PFNEGLGETCURRENTCONTEXTPROC) (void); +#if EGL_EGL_PROTOTYPES +EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext (void); +#endif +#endif /* EGL_VERSION_1_4 */ + +#ifndef EGL_VERSION_1_5 +#define EGL_VERSION_1_5 1 +typedef void *EGLSync; +typedef intptr_t EGLAttrib; +typedef khronos_utime_nanoseconds_t EGLTime; +typedef void *EGLImage; +#define EGL_CONTEXT_MAJOR_VERSION 0x3098 +#define EGL_CONTEXT_MINOR_VERSION 0x30FB +#define EGL_CONTEXT_OPENGL_PROFILE_MASK 0x30FD +#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY 0x31BD +#define EGL_NO_RESET_NOTIFICATION 0x31BE +#define EGL_LOSE_CONTEXT_ON_RESET 0x31BF +#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT 0x00000001 +#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT 0x00000002 +#define EGL_CONTEXT_OPENGL_DEBUG 0x31B0 +#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE 0x31B1 +#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS 0x31B2 +#define EGL_OPENGL_ES3_BIT 0x00000040 +#define EGL_CL_EVENT_HANDLE 0x309C +#define EGL_SYNC_CL_EVENT 0x30FE +#define EGL_SYNC_CL_EVENT_COMPLETE 0x30FF +#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE 0x30F0 +#define EGL_SYNC_TYPE 0x30F7 +#define EGL_SYNC_STATUS 0x30F1 +#define EGL_SYNC_CONDITION 0x30F8 +#define EGL_SIGNALED 0x30F2 +#define EGL_UNSIGNALED 0x30F3 +#define EGL_SYNC_FLUSH_COMMANDS_BIT 0x0001 +#define EGL_FOREVER 0xFFFFFFFFFFFFFFFFull +#define EGL_TIMEOUT_EXPIRED 0x30F5 +#define EGL_CONDITION_SATISFIED 0x30F6 +#define EGL_NO_SYNC EGL_CAST(EGLSync,0) +#define EGL_SYNC_FENCE 0x30F9 +#define EGL_GL_COLORSPACE 0x309D +#define EGL_GL_COLORSPACE_SRGB 0x3089 +#define EGL_GL_COLORSPACE_LINEAR 0x308A +#define EGL_GL_RENDERBUFFER 0x30B9 +#define EGL_GL_TEXTURE_2D 0x30B1 +#define EGL_GL_TEXTURE_LEVEL 0x30BC +#define EGL_GL_TEXTURE_3D 0x30B2 +#define EGL_GL_TEXTURE_ZOFFSET 0x30BD +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x30B3 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x30B4 +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x30B5 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x30B6 +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x30B7 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x30B8 +#define EGL_IMAGE_PRESERVED 0x30D2 +#define EGL_NO_IMAGE EGL_CAST(EGLImage,0) +typedef EGLSync (EGLAPIENTRYP PFNEGLCREATESYNCPROC) (EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCPROC) (EGLDisplay dpy, EGLSync sync); +typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCPROC) (EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBPROC) (EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value); +typedef EGLImage (EGLAPIENTRYP PFNEGLCREATEIMAGEPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEPROC) (EGLDisplay dpy, EGLImage image); +typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYPROC) (EGLenum platform, void *native_display, const EGLAttrib *attrib_list); +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMWINDOWSURFACEPROC) (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list); +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMPIXMAPSURFACEPROC) (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLWAITSYNCPROC) (EGLDisplay dpy, EGLSync sync, EGLint flags); +#if EGL_EGL_PROTOTYPES +EGLAPI EGLSync EGLAPIENTRY eglCreateSync (EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroySync (EGLDisplay dpy, EGLSync sync); +EGLAPI EGLint EGLAPIENTRY eglClientWaitSync (EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout); +EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttrib (EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value); +EGLAPI EGLImage EGLAPIENTRY eglCreateImage (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImage (EGLDisplay dpy, EGLImage image); +EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplay (EGLenum platform, void *native_display, const EGLAttrib *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformWindowSurface (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurface (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglWaitSync (EGLDisplay dpy, EGLSync sync, EGLint flags); +#endif +#endif /* EGL_VERSION_1_5 */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/include/EGL/eglext.h b/thirdparty/include/EGL/eglext.h new file mode 100644 index 000000000..a1e5e9468 --- /dev/null +++ b/thirdparty/include/EGL/eglext.h @@ -0,0 +1,1409 @@ +#ifndef __eglext_h_ +#define __eglext_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2013-2017 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are 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 Materials. +** +** THE MATERIALS ARE 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 +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ +/* +** This header is generated from the Khronos EGL XML API Registry. +** The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** http://www.khronos.org/registry/egl +** +** Khronos $Git commit SHA1: b5409265f3 $ on $Git commit date: 2020-02-20 08:24:34 -0800 $ +*/ + +#include + +#define EGL_EGLEXT_VERSION 20200220 + +/* Generated C header for: + * API: egl + * Versions considered: .* + * Versions emitted: _nomatch_^ + * Default extensions included: egl + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef EGL_KHR_cl_event +#define EGL_KHR_cl_event 1 +#define EGL_CL_EVENT_HANDLE_KHR 0x309C +#define EGL_SYNC_CL_EVENT_KHR 0x30FE +#define EGL_SYNC_CL_EVENT_COMPLETE_KHR 0x30FF +#endif /* EGL_KHR_cl_event */ + +#ifndef EGL_KHR_cl_event2 +#define EGL_KHR_cl_event2 1 +typedef void *EGLSyncKHR; +typedef intptr_t EGLAttribKHR; +typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNC64KHRPROC) (EGLDisplay dpy, EGLenum type, const EGLAttribKHR *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSync64KHR (EGLDisplay dpy, EGLenum type, const EGLAttribKHR *attrib_list); +#endif +#endif /* EGL_KHR_cl_event2 */ + +#ifndef EGL_KHR_client_get_all_proc_addresses +#define EGL_KHR_client_get_all_proc_addresses 1 +#endif /* EGL_KHR_client_get_all_proc_addresses */ + +#ifndef EGL_KHR_config_attribs +#define EGL_KHR_config_attribs 1 +#define EGL_CONFORMANT_KHR 0x3042 +#define EGL_VG_COLORSPACE_LINEAR_BIT_KHR 0x0020 +#define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR 0x0040 +#endif /* EGL_KHR_config_attribs */ + +#ifndef EGL_KHR_context_flush_control +#define EGL_KHR_context_flush_control 1 +#define EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR 0 +#define EGL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x2097 +#define EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x2098 +#endif /* EGL_KHR_context_flush_control */ + +#ifndef EGL_KHR_create_context +#define EGL_KHR_create_context 1 +#define EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098 +#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB +#define EGL_CONTEXT_FLAGS_KHR 0x30FC +#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD +#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31BD +#define EGL_NO_RESET_NOTIFICATION_KHR 0x31BE +#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31BF +#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001 +#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002 +#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004 +#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001 +#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002 +#define EGL_OPENGL_ES3_BIT_KHR 0x00000040 +#endif /* EGL_KHR_create_context */ + +#ifndef EGL_KHR_create_context_no_error +#define EGL_KHR_create_context_no_error 1 +#define EGL_CONTEXT_OPENGL_NO_ERROR_KHR 0x31B3 +#endif /* EGL_KHR_create_context_no_error */ + +#ifndef EGL_KHR_debug +#define EGL_KHR_debug 1 +typedef void *EGLLabelKHR; +typedef void *EGLObjectKHR; +typedef void (EGLAPIENTRY *EGLDEBUGPROCKHR)(EGLenum error,const char *command,EGLint messageType,EGLLabelKHR threadLabel,EGLLabelKHR objectLabel,const char* message); +#define EGL_OBJECT_THREAD_KHR 0x33B0 +#define EGL_OBJECT_DISPLAY_KHR 0x33B1 +#define EGL_OBJECT_CONTEXT_KHR 0x33B2 +#define EGL_OBJECT_SURFACE_KHR 0x33B3 +#define EGL_OBJECT_IMAGE_KHR 0x33B4 +#define EGL_OBJECT_SYNC_KHR 0x33B5 +#define EGL_OBJECT_STREAM_KHR 0x33B6 +#define EGL_DEBUG_MSG_CRITICAL_KHR 0x33B9 +#define EGL_DEBUG_MSG_ERROR_KHR 0x33BA +#define EGL_DEBUG_MSG_WARN_KHR 0x33BB +#define EGL_DEBUG_MSG_INFO_KHR 0x33BC +#define EGL_DEBUG_CALLBACK_KHR 0x33B8 +typedef EGLint (EGLAPIENTRYP PFNEGLDEBUGMESSAGECONTROLKHRPROC) (EGLDEBUGPROCKHR callback, const EGLAttrib *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEBUGKHRPROC) (EGLint attribute, EGLAttrib *value); +typedef EGLint (EGLAPIENTRYP PFNEGLLABELOBJECTKHRPROC) (EGLDisplay display, EGLenum objectType, EGLObjectKHR object, EGLLabelKHR label); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLint EGLAPIENTRY eglDebugMessageControlKHR (EGLDEBUGPROCKHR callback, const EGLAttrib *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDebugKHR (EGLint attribute, EGLAttrib *value); +EGLAPI EGLint EGLAPIENTRY eglLabelObjectKHR (EGLDisplay display, EGLenum objectType, EGLObjectKHR object, EGLLabelKHR label); +#endif +#endif /* EGL_KHR_debug */ + +#ifndef EGL_KHR_display_reference +#define EGL_KHR_display_reference 1 +#define EGL_TRACK_REFERENCES_KHR 0x3352 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDISPLAYATTRIBKHRPROC) (EGLDisplay dpy, EGLint name, EGLAttrib *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribKHR (EGLDisplay dpy, EGLint name, EGLAttrib *value); +#endif +#endif /* EGL_KHR_display_reference */ + +#ifndef EGL_KHR_fence_sync +#define EGL_KHR_fence_sync 1 +typedef khronos_utime_nanoseconds_t EGLTimeKHR; +#ifdef KHRONOS_SUPPORT_INT64 +#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR 0x30F0 +#define EGL_SYNC_CONDITION_KHR 0x30F8 +#define EGL_SYNC_FENCE_KHR 0x30F9 +typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNCKHRPROC) (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync); +typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR (EGLDisplay dpy, EGLSyncKHR sync); +EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); +EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); +#endif +#endif /* KHRONOS_SUPPORT_INT64 */ +#endif /* EGL_KHR_fence_sync */ + +#ifndef EGL_KHR_get_all_proc_addresses +#define EGL_KHR_get_all_proc_addresses 1 +#endif /* EGL_KHR_get_all_proc_addresses */ + +#ifndef EGL_KHR_gl_colorspace +#define EGL_KHR_gl_colorspace 1 +#define EGL_GL_COLORSPACE_KHR 0x309D +#define EGL_GL_COLORSPACE_SRGB_KHR 0x3089 +#define EGL_GL_COLORSPACE_LINEAR_KHR 0x308A +#endif /* EGL_KHR_gl_colorspace */ + +#ifndef EGL_KHR_gl_renderbuffer_image +#define EGL_KHR_gl_renderbuffer_image 1 +#define EGL_GL_RENDERBUFFER_KHR 0x30B9 +#endif /* EGL_KHR_gl_renderbuffer_image */ + +#ifndef EGL_KHR_gl_texture_2D_image +#define EGL_KHR_gl_texture_2D_image 1 +#define EGL_GL_TEXTURE_2D_KHR 0x30B1 +#define EGL_GL_TEXTURE_LEVEL_KHR 0x30BC +#endif /* EGL_KHR_gl_texture_2D_image */ + +#ifndef EGL_KHR_gl_texture_3D_image +#define EGL_KHR_gl_texture_3D_image 1 +#define EGL_GL_TEXTURE_3D_KHR 0x30B2 +#define EGL_GL_TEXTURE_ZOFFSET_KHR 0x30BD +#endif /* EGL_KHR_gl_texture_3D_image */ + +#ifndef EGL_KHR_gl_texture_cubemap_image +#define EGL_KHR_gl_texture_cubemap_image 1 +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR 0x30B3 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR 0x30B4 +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR 0x30B5 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR 0x30B6 +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR 0x30B7 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR 0x30B8 +#endif /* EGL_KHR_gl_texture_cubemap_image */ + +#ifndef EGL_KHR_image +#define EGL_KHR_image 1 +typedef void *EGLImageKHR; +#define EGL_NATIVE_PIXMAP_KHR 0x30B0 +#define EGL_NO_IMAGE_KHR EGL_CAST(EGLImageKHR,0) +typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image); +#endif +#endif /* EGL_KHR_image */ + +#ifndef EGL_KHR_image_base +#define EGL_KHR_image_base 1 +#define EGL_IMAGE_PRESERVED_KHR 0x30D2 +#endif /* EGL_KHR_image_base */ + +#ifndef EGL_KHR_image_pixmap +#define EGL_KHR_image_pixmap 1 +#endif /* EGL_KHR_image_pixmap */ + +#ifndef EGL_KHR_lock_surface +#define EGL_KHR_lock_surface 1 +#define EGL_READ_SURFACE_BIT_KHR 0x0001 +#define EGL_WRITE_SURFACE_BIT_KHR 0x0002 +#define EGL_LOCK_SURFACE_BIT_KHR 0x0080 +#define EGL_OPTIMAL_FORMAT_BIT_KHR 0x0100 +#define EGL_MATCH_FORMAT_KHR 0x3043 +#define EGL_FORMAT_RGB_565_EXACT_KHR 0x30C0 +#define EGL_FORMAT_RGB_565_KHR 0x30C1 +#define EGL_FORMAT_RGBA_8888_EXACT_KHR 0x30C2 +#define EGL_FORMAT_RGBA_8888_KHR 0x30C3 +#define EGL_MAP_PRESERVE_PIXELS_KHR 0x30C4 +#define EGL_LOCK_USAGE_HINT_KHR 0x30C5 +#define EGL_BITMAP_POINTER_KHR 0x30C6 +#define EGL_BITMAP_PITCH_KHR 0x30C7 +#define EGL_BITMAP_ORIGIN_KHR 0x30C8 +#define EGL_BITMAP_PIXEL_RED_OFFSET_KHR 0x30C9 +#define EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR 0x30CA +#define EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR 0x30CB +#define EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR 0x30CC +#define EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR 0x30CD +#define EGL_LOWER_LEFT_KHR 0x30CE +#define EGL_UPPER_LEFT_KHR 0x30CF +typedef EGLBoolean (EGLAPIENTRYP PFNEGLLOCKSURFACEKHRPROC) (EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay dpy, EGLSurface surface); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglLockSurfaceKHR (EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR (EGLDisplay dpy, EGLSurface surface); +#endif +#endif /* EGL_KHR_lock_surface */ + +#ifndef EGL_KHR_lock_surface2 +#define EGL_KHR_lock_surface2 1 +#define EGL_BITMAP_PIXEL_SIZE_KHR 0x3110 +#endif /* EGL_KHR_lock_surface2 */ + +#ifndef EGL_KHR_lock_surface3 +#define EGL_KHR_lock_surface3 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACE64KHRPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLAttribKHR *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface64KHR (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLAttribKHR *value); +#endif +#endif /* EGL_KHR_lock_surface3 */ + +#ifndef EGL_KHR_mutable_render_buffer +#define EGL_KHR_mutable_render_buffer 1 +#define EGL_MUTABLE_RENDER_BUFFER_BIT_KHR 0x1000 +#endif /* EGL_KHR_mutable_render_buffer */ + +#ifndef EGL_KHR_no_config_context +#define EGL_KHR_no_config_context 1 +#define EGL_NO_CONFIG_KHR EGL_CAST(EGLConfig,0) +#endif /* EGL_KHR_no_config_context */ + +#ifndef EGL_KHR_partial_update +#define EGL_KHR_partial_update 1 +#define EGL_BUFFER_AGE_KHR 0x313D +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSETDAMAGEREGIONKHRPROC) (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSetDamageRegionKHR (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); +#endif +#endif /* EGL_KHR_partial_update */ + +#ifndef EGL_KHR_platform_android +#define EGL_KHR_platform_android 1 +#define EGL_PLATFORM_ANDROID_KHR 0x3141 +#endif /* EGL_KHR_platform_android */ + +#ifndef EGL_KHR_platform_gbm +#define EGL_KHR_platform_gbm 1 +#define EGL_PLATFORM_GBM_KHR 0x31D7 +#endif /* EGL_KHR_platform_gbm */ + +#ifndef EGL_KHR_platform_wayland +#define EGL_KHR_platform_wayland 1 +#define EGL_PLATFORM_WAYLAND_KHR 0x31D8 +#endif /* EGL_KHR_platform_wayland */ + +#ifndef EGL_KHR_platform_x11 +#define EGL_KHR_platform_x11 1 +#define EGL_PLATFORM_X11_KHR 0x31D5 +#define EGL_PLATFORM_X11_SCREEN_KHR 0x31D6 +#endif /* EGL_KHR_platform_x11 */ + +#ifndef EGL_KHR_reusable_sync +#define EGL_KHR_reusable_sync 1 +#ifdef KHRONOS_SUPPORT_INT64 +#define EGL_SYNC_STATUS_KHR 0x30F1 +#define EGL_SIGNALED_KHR 0x30F2 +#define EGL_UNSIGNALED_KHR 0x30F3 +#define EGL_TIMEOUT_EXPIRED_KHR 0x30F5 +#define EGL_CONDITION_SATISFIED_KHR 0x30F6 +#define EGL_SYNC_TYPE_KHR 0x30F7 +#define EGL_SYNC_REUSABLE_KHR 0x30FA +#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001 +#define EGL_FOREVER_KHR 0xFFFFFFFFFFFFFFFFull +#define EGL_NO_SYNC_KHR EGL_CAST(EGLSyncKHR,0) +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); +#endif +#endif /* KHRONOS_SUPPORT_INT64 */ +#endif /* EGL_KHR_reusable_sync */ + +#ifndef EGL_KHR_stream +#define EGL_KHR_stream 1 +typedef void *EGLStreamKHR; +typedef khronos_uint64_t EGLuint64KHR; +#ifdef KHRONOS_SUPPORT_INT64 +#define EGL_NO_STREAM_KHR EGL_CAST(EGLStreamKHR,0) +#define EGL_CONSUMER_LATENCY_USEC_KHR 0x3210 +#define EGL_PRODUCER_FRAME_KHR 0x3212 +#define EGL_CONSUMER_FRAME_KHR 0x3213 +#define EGL_STREAM_STATE_KHR 0x3214 +#define EGL_STREAM_STATE_CREATED_KHR 0x3215 +#define EGL_STREAM_STATE_CONNECTING_KHR 0x3216 +#define EGL_STREAM_STATE_EMPTY_KHR 0x3217 +#define EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR 0x3218 +#define EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR 0x3219 +#define EGL_STREAM_STATE_DISCONNECTED_KHR 0x321A +#define EGL_BAD_STREAM_KHR 0x321B +#define EGL_BAD_STATE_KHR 0x321C +typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMKHRPROC) (EGLDisplay dpy, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSTREAMKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMU64KHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamKHR (EGLDisplay dpy, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroyStreamKHR (EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamAttribKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamu64KHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value); +#endif +#endif /* KHRONOS_SUPPORT_INT64 */ +#endif /* EGL_KHR_stream */ + +#ifndef EGL_KHR_stream_attrib +#define EGL_KHR_stream_attrib 1 +#ifdef KHRONOS_SUPPORT_INT64 +typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMATTRIBKHRPROC) (EGLDisplay dpy, const EGLAttrib *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSETSTREAMATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLAttrib value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLAttrib *value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamAttribKHR (EGLDisplay dpy, const EGLAttrib *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglSetStreamAttribKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLAttrib value); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamAttribKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLAttrib *value); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireAttribKHR (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerReleaseAttribKHR (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); +#endif +#endif /* KHRONOS_SUPPORT_INT64 */ +#endif /* EGL_KHR_stream_attrib */ + +#ifndef EGL_KHR_stream_consumer_gltexture +#define EGL_KHR_stream_consumer_gltexture 1 +#ifdef EGL_KHR_stream +#define EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR 0x321E +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalKHR (EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireKHR (EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerReleaseKHR (EGLDisplay dpy, EGLStreamKHR stream); +#endif +#endif /* EGL_KHR_stream */ +#endif /* EGL_KHR_stream_consumer_gltexture */ + +#ifndef EGL_KHR_stream_cross_process_fd +#define EGL_KHR_stream_cross_process_fd 1 +typedef int EGLNativeFileDescriptorKHR; +#ifdef EGL_KHR_stream +#define EGL_NO_FILE_DESCRIPTOR_KHR EGL_CAST(EGLNativeFileDescriptorKHR,-1) +typedef EGLNativeFileDescriptorKHR (EGLAPIENTRYP PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC) (EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLNativeFileDescriptorKHR EGLAPIENTRY eglGetStreamFileDescriptorKHR (EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamFromFileDescriptorKHR (EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor); +#endif +#endif /* EGL_KHR_stream */ +#endif /* EGL_KHR_stream_cross_process_fd */ + +#ifndef EGL_KHR_stream_fifo +#define EGL_KHR_stream_fifo 1 +#ifdef EGL_KHR_stream +#define EGL_STREAM_FIFO_LENGTH_KHR 0x31FC +#define EGL_STREAM_TIME_NOW_KHR 0x31FD +#define EGL_STREAM_TIME_CONSUMER_KHR 0x31FE +#define EGL_STREAM_TIME_PRODUCER_KHR 0x31FF +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMTIMEKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamTimeKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value); +#endif +#endif /* EGL_KHR_stream */ +#endif /* EGL_KHR_stream_fifo */ + +#ifndef EGL_KHR_stream_producer_aldatalocator +#define EGL_KHR_stream_producer_aldatalocator 1 +#ifdef EGL_KHR_stream +#endif /* EGL_KHR_stream */ +#endif /* EGL_KHR_stream_producer_aldatalocator */ + +#ifndef EGL_KHR_stream_producer_eglsurface +#define EGL_KHR_stream_producer_eglsurface 1 +#ifdef EGL_KHR_stream +#define EGL_STREAM_BIT_KHR 0x0800 +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC) (EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSurface EGLAPIENTRY eglCreateStreamProducerSurfaceKHR (EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list); +#endif +#endif /* EGL_KHR_stream */ +#endif /* EGL_KHR_stream_producer_eglsurface */ + +#ifndef EGL_KHR_surfaceless_context +#define EGL_KHR_surfaceless_context 1 +#endif /* EGL_KHR_surfaceless_context */ + +#ifndef EGL_KHR_swap_buffers_with_damage +#define EGL_KHR_swap_buffers_with_damage 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEKHRPROC) (EGLDisplay dpy, EGLSurface surface, const EGLint *rects, EGLint n_rects); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageKHR (EGLDisplay dpy, EGLSurface surface, const EGLint *rects, EGLint n_rects); +#endif +#endif /* EGL_KHR_swap_buffers_with_damage */ + +#ifndef EGL_KHR_vg_parent_image +#define EGL_KHR_vg_parent_image 1 +#define EGL_VG_PARENT_IMAGE_KHR 0x30BA +#endif /* EGL_KHR_vg_parent_image */ + +#ifndef EGL_KHR_wait_sync +#define EGL_KHR_wait_sync 1 +typedef EGLint (EGLAPIENTRYP PFNEGLWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLint EGLAPIENTRY eglWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags); +#endif +#endif /* EGL_KHR_wait_sync */ + +#ifndef EGL_ANDROID_GLES_layers +#define EGL_ANDROID_GLES_layers 1 +#endif /* EGL_ANDROID_GLES_layers */ + +#ifndef EGL_ANDROID_blob_cache +#define EGL_ANDROID_blob_cache 1 +typedef khronos_ssize_t EGLsizeiANDROID; +typedef void (*EGLSetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, const void *value, EGLsizeiANDROID valueSize); +typedef EGLsizeiANDROID (*EGLGetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, void *value, EGLsizeiANDROID valueSize); +typedef void (EGLAPIENTRYP PFNEGLSETBLOBCACHEFUNCSANDROIDPROC) (EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI void EGLAPIENTRY eglSetBlobCacheFuncsANDROID (EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get); +#endif +#endif /* EGL_ANDROID_blob_cache */ + +#ifndef EGL_ANDROID_create_native_client_buffer +#define EGL_ANDROID_create_native_client_buffer 1 +#define EGL_NATIVE_BUFFER_USAGE_ANDROID 0x3143 +#define EGL_NATIVE_BUFFER_USAGE_PROTECTED_BIT_ANDROID 0x00000001 +#define EGL_NATIVE_BUFFER_USAGE_RENDERBUFFER_BIT_ANDROID 0x00000002 +#define EGL_NATIVE_BUFFER_USAGE_TEXTURE_BIT_ANDROID 0x00000004 +typedef EGLClientBuffer (EGLAPIENTRYP PFNEGLCREATENATIVECLIENTBUFFERANDROIDPROC) (const EGLint *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLClientBuffer EGLAPIENTRY eglCreateNativeClientBufferANDROID (const EGLint *attrib_list); +#endif +#endif /* EGL_ANDROID_create_native_client_buffer */ + +#ifndef EGL_ANDROID_framebuffer_target +#define EGL_ANDROID_framebuffer_target 1 +#define EGL_FRAMEBUFFER_TARGET_ANDROID 0x3147 +#endif /* EGL_ANDROID_framebuffer_target */ + +#ifndef EGL_ANDROID_front_buffer_auto_refresh +#define EGL_ANDROID_front_buffer_auto_refresh 1 +#define EGL_FRONT_BUFFER_AUTO_REFRESH_ANDROID 0x314C +#endif /* EGL_ANDROID_front_buffer_auto_refresh */ + +#ifndef EGL_ANDROID_get_frame_timestamps +#define EGL_ANDROID_get_frame_timestamps 1 +typedef khronos_stime_nanoseconds_t EGLnsecsANDROID; +#define EGL_TIMESTAMP_PENDING_ANDROID EGL_CAST(EGLnsecsANDROID,-2) +#define EGL_TIMESTAMP_INVALID_ANDROID EGL_CAST(EGLnsecsANDROID,-1) +#define EGL_TIMESTAMPS_ANDROID 0x3430 +#define EGL_COMPOSITE_DEADLINE_ANDROID 0x3431 +#define EGL_COMPOSITE_INTERVAL_ANDROID 0x3432 +#define EGL_COMPOSITE_TO_PRESENT_LATENCY_ANDROID 0x3433 +#define EGL_REQUESTED_PRESENT_TIME_ANDROID 0x3434 +#define EGL_RENDERING_COMPLETE_TIME_ANDROID 0x3435 +#define EGL_COMPOSITION_LATCH_TIME_ANDROID 0x3436 +#define EGL_FIRST_COMPOSITION_START_TIME_ANDROID 0x3437 +#define EGL_LAST_COMPOSITION_START_TIME_ANDROID 0x3438 +#define EGL_FIRST_COMPOSITION_GPU_FINISHED_TIME_ANDROID 0x3439 +#define EGL_DISPLAY_PRESENT_TIME_ANDROID 0x343A +#define EGL_DEQUEUE_READY_TIME_ANDROID 0x343B +#define EGL_READS_DONE_TIME_ANDROID 0x343C +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETCOMPOSITORTIMINGSUPPORTEDANDROIDPROC) (EGLDisplay dpy, EGLSurface surface, EGLint name); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETCOMPOSITORTIMINGANDROIDPROC) (EGLDisplay dpy, EGLSurface surface, EGLint numTimestamps, const EGLint *names, EGLnsecsANDROID *values); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETNEXTFRAMEIDANDROIDPROC) (EGLDisplay dpy, EGLSurface surface, EGLuint64KHR *frameId); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETFRAMETIMESTAMPSUPPORTEDANDROIDPROC) (EGLDisplay dpy, EGLSurface surface, EGLint timestamp); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETFRAMETIMESTAMPSANDROIDPROC) (EGLDisplay dpy, EGLSurface surface, EGLuint64KHR frameId, EGLint numTimestamps, const EGLint *timestamps, EGLnsecsANDROID *values); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglGetCompositorTimingSupportedANDROID (EGLDisplay dpy, EGLSurface surface, EGLint name); +EGLAPI EGLBoolean EGLAPIENTRY eglGetCompositorTimingANDROID (EGLDisplay dpy, EGLSurface surface, EGLint numTimestamps, const EGLint *names, EGLnsecsANDROID *values); +EGLAPI EGLBoolean EGLAPIENTRY eglGetNextFrameIdANDROID (EGLDisplay dpy, EGLSurface surface, EGLuint64KHR *frameId); +EGLAPI EGLBoolean EGLAPIENTRY eglGetFrameTimestampSupportedANDROID (EGLDisplay dpy, EGLSurface surface, EGLint timestamp); +EGLAPI EGLBoolean EGLAPIENTRY eglGetFrameTimestampsANDROID (EGLDisplay dpy, EGLSurface surface, EGLuint64KHR frameId, EGLint numTimestamps, const EGLint *timestamps, EGLnsecsANDROID *values); +#endif +#endif /* EGL_ANDROID_get_frame_timestamps */ + +#ifndef EGL_ANDROID_get_native_client_buffer +#define EGL_ANDROID_get_native_client_buffer 1 +struct AHardwareBuffer; +typedef EGLClientBuffer (EGLAPIENTRYP PFNEGLGETNATIVECLIENTBUFFERANDROIDPROC) (const struct AHardwareBuffer *buffer); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLClientBuffer EGLAPIENTRY eglGetNativeClientBufferANDROID (const struct AHardwareBuffer *buffer); +#endif +#endif /* EGL_ANDROID_get_native_client_buffer */ + +#ifndef EGL_ANDROID_image_native_buffer +#define EGL_ANDROID_image_native_buffer 1 +#define EGL_NATIVE_BUFFER_ANDROID 0x3140 +#endif /* EGL_ANDROID_image_native_buffer */ + +#ifndef EGL_ANDROID_native_fence_sync +#define EGL_ANDROID_native_fence_sync 1 +#define EGL_SYNC_NATIVE_FENCE_ANDROID 0x3144 +#define EGL_SYNC_NATIVE_FENCE_FD_ANDROID 0x3145 +#define EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID 0x3146 +#define EGL_NO_NATIVE_FENCE_FD_ANDROID -1 +typedef EGLint (EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC) (EGLDisplay dpy, EGLSyncKHR sync); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLint EGLAPIENTRY eglDupNativeFenceFDANDROID (EGLDisplay dpy, EGLSyncKHR sync); +#endif +#endif /* EGL_ANDROID_native_fence_sync */ + +#ifndef EGL_ANDROID_presentation_time +#define EGL_ANDROID_presentation_time 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLPRESENTATIONTIMEANDROIDPROC) (EGLDisplay dpy, EGLSurface surface, EGLnsecsANDROID time); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglPresentationTimeANDROID (EGLDisplay dpy, EGLSurface surface, EGLnsecsANDROID time); +#endif +#endif /* EGL_ANDROID_presentation_time */ + +#ifndef EGL_ANDROID_recordable +#define EGL_ANDROID_recordable 1 +#define EGL_RECORDABLE_ANDROID 0x3142 +#endif /* EGL_ANDROID_recordable */ + +#ifndef EGL_ANGLE_d3d_share_handle_client_buffer +#define EGL_ANGLE_d3d_share_handle_client_buffer 1 +#define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200 +#endif /* EGL_ANGLE_d3d_share_handle_client_buffer */ + +#ifndef EGL_ANGLE_device_d3d +#define EGL_ANGLE_device_d3d 1 +#define EGL_D3D9_DEVICE_ANGLE 0x33A0 +#define EGL_D3D11_DEVICE_ANGLE 0x33A1 +#endif /* EGL_ANGLE_device_d3d */ + +#ifndef EGL_ANGLE_query_surface_pointer +#define EGL_ANGLE_query_surface_pointer 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurfacePointerANGLE (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value); +#endif +#endif /* EGL_ANGLE_query_surface_pointer */ + +#ifndef EGL_ANGLE_surface_d3d_texture_2d_share_handle +#define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1 +#endif /* EGL_ANGLE_surface_d3d_texture_2d_share_handle */ + +#ifndef EGL_ANGLE_window_fixed_size +#define EGL_ANGLE_window_fixed_size 1 +#define EGL_FIXED_SIZE_ANGLE 0x3201 +#endif /* EGL_ANGLE_window_fixed_size */ + +#ifndef EGL_ARM_image_format +#define EGL_ARM_image_format 1 +#define EGL_COLOR_COMPONENT_TYPE_UNSIGNED_INTEGER_ARM 0x3287 +#define EGL_COLOR_COMPONENT_TYPE_INTEGER_ARM 0x3288 +#endif /* EGL_ARM_image_format */ + +#ifndef EGL_ARM_implicit_external_sync +#define EGL_ARM_implicit_external_sync 1 +#define EGL_SYNC_PRIOR_COMMANDS_IMPLICIT_EXTERNAL_ARM 0x328A +#endif /* EGL_ARM_implicit_external_sync */ + +#ifndef EGL_ARM_pixmap_multisample_discard +#define EGL_ARM_pixmap_multisample_discard 1 +#define EGL_DISCARD_SAMPLES_ARM 0x3286 +#endif /* EGL_ARM_pixmap_multisample_discard */ + +#ifndef EGL_EXT_bind_to_front +#define EGL_EXT_bind_to_front 1 +#define EGL_FRONT_BUFFER_EXT 0x3464 +#endif /* EGL_EXT_bind_to_front */ + +#ifndef EGL_EXT_buffer_age +#define EGL_EXT_buffer_age 1 +#define EGL_BUFFER_AGE_EXT 0x313D +#endif /* EGL_EXT_buffer_age */ + +#ifndef EGL_EXT_client_extensions +#define EGL_EXT_client_extensions 1 +#endif /* EGL_EXT_client_extensions */ + +#ifndef EGL_EXT_client_sync +#define EGL_EXT_client_sync 1 +#define EGL_SYNC_CLIENT_EXT 0x3364 +#define EGL_SYNC_CLIENT_SIGNAL_EXT 0x3365 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLCLIENTSIGNALSYNCEXTPROC) (EGLDisplay dpy, EGLSync sync, const EGLAttrib *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglClientSignalSyncEXT (EGLDisplay dpy, EGLSync sync, const EGLAttrib *attrib_list); +#endif +#endif /* EGL_EXT_client_sync */ + +#ifndef EGL_EXT_compositor +#define EGL_EXT_compositor 1 +#define EGL_PRIMARY_COMPOSITOR_CONTEXT_EXT 0x3460 +#define EGL_EXTERNAL_REF_ID_EXT 0x3461 +#define EGL_COMPOSITOR_DROP_NEWEST_FRAME_EXT 0x3462 +#define EGL_COMPOSITOR_KEEP_NEWEST_FRAME_EXT 0x3463 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORSETCONTEXTLISTEXTPROC) (const EGLint *external_ref_ids, EGLint num_entries); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORSETCONTEXTATTRIBUTESEXTPROC) (EGLint external_ref_id, const EGLint *context_attributes, EGLint num_entries); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORSETWINDOWLISTEXTPROC) (EGLint external_ref_id, const EGLint *external_win_ids, EGLint num_entries); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORSETWINDOWATTRIBUTESEXTPROC) (EGLint external_win_id, const EGLint *window_attributes, EGLint num_entries); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORBINDTEXWINDOWEXTPROC) (EGLint external_win_id); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORSETSIZEEXTPROC) (EGLint external_win_id, EGLint width, EGLint height); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORSWAPPOLICYEXTPROC) (EGLint external_win_id, EGLint policy); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglCompositorSetContextListEXT (const EGLint *external_ref_ids, EGLint num_entries); +EGLAPI EGLBoolean EGLAPIENTRY eglCompositorSetContextAttributesEXT (EGLint external_ref_id, const EGLint *context_attributes, EGLint num_entries); +EGLAPI EGLBoolean EGLAPIENTRY eglCompositorSetWindowListEXT (EGLint external_ref_id, const EGLint *external_win_ids, EGLint num_entries); +EGLAPI EGLBoolean EGLAPIENTRY eglCompositorSetWindowAttributesEXT (EGLint external_win_id, const EGLint *window_attributes, EGLint num_entries); +EGLAPI EGLBoolean EGLAPIENTRY eglCompositorBindTexWindowEXT (EGLint external_win_id); +EGLAPI EGLBoolean EGLAPIENTRY eglCompositorSetSizeEXT (EGLint external_win_id, EGLint width, EGLint height); +EGLAPI EGLBoolean EGLAPIENTRY eglCompositorSwapPolicyEXT (EGLint external_win_id, EGLint policy); +#endif +#endif /* EGL_EXT_compositor */ + +#ifndef EGL_EXT_create_context_robustness +#define EGL_EXT_create_context_robustness 1 +#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT 0x30BF +#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT 0x3138 +#define EGL_NO_RESET_NOTIFICATION_EXT 0x31BE +#define EGL_LOSE_CONTEXT_ON_RESET_EXT 0x31BF +#endif /* EGL_EXT_create_context_robustness */ + +#ifndef EGL_EXT_device_base +#define EGL_EXT_device_base 1 +typedef void *EGLDeviceEXT; +#define EGL_NO_DEVICE_EXT EGL_CAST(EGLDeviceEXT,0) +#define EGL_BAD_DEVICE_EXT 0x322B +#define EGL_DEVICE_EXT 0x322C +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICEATTRIBEXTPROC) (EGLDeviceEXT device, EGLint attribute, EGLAttrib *value); +typedef const char *(EGLAPIENTRYP PFNEGLQUERYDEVICESTRINGEXTPROC) (EGLDeviceEXT device, EGLint name); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICESEXTPROC) (EGLint max_devices, EGLDeviceEXT *devices, EGLint *num_devices); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDISPLAYATTRIBEXTPROC) (EGLDisplay dpy, EGLint attribute, EGLAttrib *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDeviceAttribEXT (EGLDeviceEXT device, EGLint attribute, EGLAttrib *value); +EGLAPI const char *EGLAPIENTRY eglQueryDeviceStringEXT (EGLDeviceEXT device, EGLint name); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDevicesEXT (EGLint max_devices, EGLDeviceEXT *devices, EGLint *num_devices); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribEXT (EGLDisplay dpy, EGLint attribute, EGLAttrib *value); +#endif +#endif /* EGL_EXT_device_base */ + +#ifndef EGL_EXT_device_drm +#define EGL_EXT_device_drm 1 +#define EGL_DRM_DEVICE_FILE_EXT 0x3233 +#define EGL_DRM_MASTER_FD_EXT 0x333C +#endif /* EGL_EXT_device_drm */ + +#ifndef EGL_EXT_device_enumeration +#define EGL_EXT_device_enumeration 1 +#endif /* EGL_EXT_device_enumeration */ + +#ifndef EGL_EXT_device_openwf +#define EGL_EXT_device_openwf 1 +#define EGL_OPENWF_DEVICE_ID_EXT 0x3237 +#endif /* EGL_EXT_device_openwf */ + +#ifndef EGL_EXT_device_query +#define EGL_EXT_device_query 1 +#endif /* EGL_EXT_device_query */ + +#ifndef EGL_EXT_gl_colorspace_bt2020_linear +#define EGL_EXT_gl_colorspace_bt2020_linear 1 +#define EGL_GL_COLORSPACE_BT2020_LINEAR_EXT 0x333F +#endif /* EGL_EXT_gl_colorspace_bt2020_linear */ + +#ifndef EGL_EXT_gl_colorspace_bt2020_pq +#define EGL_EXT_gl_colorspace_bt2020_pq 1 +#define EGL_GL_COLORSPACE_BT2020_PQ_EXT 0x3340 +#endif /* EGL_EXT_gl_colorspace_bt2020_pq */ + +#ifndef EGL_EXT_gl_colorspace_display_p3 +#define EGL_EXT_gl_colorspace_display_p3 1 +#define EGL_GL_COLORSPACE_DISPLAY_P3_EXT 0x3363 +#endif /* EGL_EXT_gl_colorspace_display_p3 */ + +#ifndef EGL_EXT_gl_colorspace_display_p3_linear +#define EGL_EXT_gl_colorspace_display_p3_linear 1 +#define EGL_GL_COLORSPACE_DISPLAY_P3_LINEAR_EXT 0x3362 +#endif /* EGL_EXT_gl_colorspace_display_p3_linear */ + +#ifndef EGL_EXT_gl_colorspace_display_p3_passthrough +#define EGL_EXT_gl_colorspace_display_p3_passthrough 1 +#define EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT 0x3490 +#endif /* EGL_EXT_gl_colorspace_display_p3_passthrough */ + +#ifndef EGL_EXT_gl_colorspace_scrgb +#define EGL_EXT_gl_colorspace_scrgb 1 +#define EGL_GL_COLORSPACE_SCRGB_EXT 0x3351 +#endif /* EGL_EXT_gl_colorspace_scrgb */ + +#ifndef EGL_EXT_gl_colorspace_scrgb_linear +#define EGL_EXT_gl_colorspace_scrgb_linear 1 +#define EGL_GL_COLORSPACE_SCRGB_LINEAR_EXT 0x3350 +#endif /* EGL_EXT_gl_colorspace_scrgb_linear */ + +#ifndef EGL_EXT_image_dma_buf_import +#define EGL_EXT_image_dma_buf_import 1 +#define EGL_LINUX_DMA_BUF_EXT 0x3270 +#define EGL_LINUX_DRM_FOURCC_EXT 0x3271 +#define EGL_DMA_BUF_PLANE0_FD_EXT 0x3272 +#define EGL_DMA_BUF_PLANE0_OFFSET_EXT 0x3273 +#define EGL_DMA_BUF_PLANE0_PITCH_EXT 0x3274 +#define EGL_DMA_BUF_PLANE1_FD_EXT 0x3275 +#define EGL_DMA_BUF_PLANE1_OFFSET_EXT 0x3276 +#define EGL_DMA_BUF_PLANE1_PITCH_EXT 0x3277 +#define EGL_DMA_BUF_PLANE2_FD_EXT 0x3278 +#define EGL_DMA_BUF_PLANE2_OFFSET_EXT 0x3279 +#define EGL_DMA_BUF_PLANE2_PITCH_EXT 0x327A +#define EGL_YUV_COLOR_SPACE_HINT_EXT 0x327B +#define EGL_SAMPLE_RANGE_HINT_EXT 0x327C +#define EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT 0x327D +#define EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT 0x327E +#define EGL_ITU_REC601_EXT 0x327F +#define EGL_ITU_REC709_EXT 0x3280 +#define EGL_ITU_REC2020_EXT 0x3281 +#define EGL_YUV_FULL_RANGE_EXT 0x3282 +#define EGL_YUV_NARROW_RANGE_EXT 0x3283 +#define EGL_YUV_CHROMA_SITING_0_EXT 0x3284 +#define EGL_YUV_CHROMA_SITING_0_5_EXT 0x3285 +#endif /* EGL_EXT_image_dma_buf_import */ + +#ifndef EGL_EXT_image_dma_buf_import_modifiers +#define EGL_EXT_image_dma_buf_import_modifiers 1 +#define EGL_DMA_BUF_PLANE3_FD_EXT 0x3440 +#define EGL_DMA_BUF_PLANE3_OFFSET_EXT 0x3441 +#define EGL_DMA_BUF_PLANE3_PITCH_EXT 0x3442 +#define EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT 0x3443 +#define EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT 0x3444 +#define EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT 0x3445 +#define EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT 0x3446 +#define EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT 0x3447 +#define EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT 0x3448 +#define EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT 0x3449 +#define EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT 0x344A +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDMABUFFORMATSEXTPROC) (EGLDisplay dpy, EGLint max_formats, EGLint *formats, EGLint *num_formats); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDMABUFMODIFIERSEXTPROC) (EGLDisplay dpy, EGLint format, EGLint max_modifiers, EGLuint64KHR *modifiers, EGLBoolean *external_only, EGLint *num_modifiers); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDmaBufFormatsEXT (EGLDisplay dpy, EGLint max_formats, EGLint *formats, EGLint *num_formats); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDmaBufModifiersEXT (EGLDisplay dpy, EGLint format, EGLint max_modifiers, EGLuint64KHR *modifiers, EGLBoolean *external_only, EGLint *num_modifiers); +#endif +#endif /* EGL_EXT_image_dma_buf_import_modifiers */ + +#ifndef EGL_EXT_image_gl_colorspace +#define EGL_EXT_image_gl_colorspace 1 +#define EGL_GL_COLORSPACE_DEFAULT_EXT 0x314D +#endif /* EGL_EXT_image_gl_colorspace */ + +#ifndef EGL_EXT_image_implicit_sync_control +#define EGL_EXT_image_implicit_sync_control 1 +#define EGL_IMPORT_SYNC_TYPE_EXT 0x3470 +#define EGL_IMPORT_IMPLICIT_SYNC_EXT 0x3471 +#define EGL_IMPORT_EXPLICIT_SYNC_EXT 0x3472 +#endif /* EGL_EXT_image_implicit_sync_control */ + +#ifndef EGL_EXT_multiview_window +#define EGL_EXT_multiview_window 1 +#define EGL_MULTIVIEW_VIEW_COUNT_EXT 0x3134 +#endif /* EGL_EXT_multiview_window */ + +#ifndef EGL_EXT_output_base +#define EGL_EXT_output_base 1 +typedef void *EGLOutputLayerEXT; +typedef void *EGLOutputPortEXT; +#define EGL_NO_OUTPUT_LAYER_EXT EGL_CAST(EGLOutputLayerEXT,0) +#define EGL_NO_OUTPUT_PORT_EXT EGL_CAST(EGLOutputPortEXT,0) +#define EGL_BAD_OUTPUT_LAYER_EXT 0x322D +#define EGL_BAD_OUTPUT_PORT_EXT 0x322E +#define EGL_SWAP_INTERVAL_EXT 0x322F +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETOUTPUTLAYERSEXTPROC) (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputLayerEXT *layers, EGLint max_layers, EGLint *num_layers); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETOUTPUTPORTSEXTPROC) (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputPortEXT *ports, EGLint max_ports, EGLint *num_ports); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLOUTPUTLAYERATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYOUTPUTLAYERATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib *value); +typedef const char *(EGLAPIENTRYP PFNEGLQUERYOUTPUTLAYERSTRINGEXTPROC) (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint name); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLOUTPUTPORTATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYOUTPUTPORTATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib *value); +typedef const char *(EGLAPIENTRYP PFNEGLQUERYOUTPUTPORTSTRINGEXTPROC) (EGLDisplay dpy, EGLOutputPortEXT port, EGLint name); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglGetOutputLayersEXT (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputLayerEXT *layers, EGLint max_layers, EGLint *num_layers); +EGLAPI EGLBoolean EGLAPIENTRY eglGetOutputPortsEXT (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputPortEXT *ports, EGLint max_ports, EGLint *num_ports); +EGLAPI EGLBoolean EGLAPIENTRY eglOutputLayerAttribEXT (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib value); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryOutputLayerAttribEXT (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib *value); +EGLAPI const char *EGLAPIENTRY eglQueryOutputLayerStringEXT (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint name); +EGLAPI EGLBoolean EGLAPIENTRY eglOutputPortAttribEXT (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib value); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryOutputPortAttribEXT (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib *value); +EGLAPI const char *EGLAPIENTRY eglQueryOutputPortStringEXT (EGLDisplay dpy, EGLOutputPortEXT port, EGLint name); +#endif +#endif /* EGL_EXT_output_base */ + +#ifndef EGL_EXT_output_drm +#define EGL_EXT_output_drm 1 +#define EGL_DRM_CRTC_EXT 0x3234 +#define EGL_DRM_PLANE_EXT 0x3235 +#define EGL_DRM_CONNECTOR_EXT 0x3236 +#endif /* EGL_EXT_output_drm */ + +#ifndef EGL_EXT_output_openwf +#define EGL_EXT_output_openwf 1 +#define EGL_OPENWF_PIPELINE_ID_EXT 0x3238 +#define EGL_OPENWF_PORT_ID_EXT 0x3239 +#endif /* EGL_EXT_output_openwf */ + +#ifndef EGL_EXT_pixel_format_float +#define EGL_EXT_pixel_format_float 1 +#define EGL_COLOR_COMPONENT_TYPE_EXT 0x3339 +#define EGL_COLOR_COMPONENT_TYPE_FIXED_EXT 0x333A +#define EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT 0x333B +#endif /* EGL_EXT_pixel_format_float */ + +#ifndef EGL_EXT_platform_base +#define EGL_EXT_platform_base 1 +typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC) (EGLenum platform, void *native_display, const EGLint *attrib_list); +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list); +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMPIXMAPSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplayEXT (EGLenum platform, void *native_display, const EGLint *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformWindowSurfaceEXT (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurfaceEXT (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list); +#endif +#endif /* EGL_EXT_platform_base */ + +#ifndef EGL_EXT_platform_device +#define EGL_EXT_platform_device 1 +#define EGL_PLATFORM_DEVICE_EXT 0x313F +#endif /* EGL_EXT_platform_device */ + +#ifndef EGL_EXT_platform_wayland +#define EGL_EXT_platform_wayland 1 +#define EGL_PLATFORM_WAYLAND_EXT 0x31D8 +#endif /* EGL_EXT_platform_wayland */ + +#ifndef EGL_EXT_platform_x11 +#define EGL_EXT_platform_x11 1 +#define EGL_PLATFORM_X11_EXT 0x31D5 +#define EGL_PLATFORM_X11_SCREEN_EXT 0x31D6 +#endif /* EGL_EXT_platform_x11 */ + +#ifndef EGL_EXT_protected_content +#define EGL_EXT_protected_content 1 +#define EGL_PROTECTED_CONTENT_EXT 0x32C0 +#endif /* EGL_EXT_protected_content */ + +#ifndef EGL_EXT_protected_surface +#define EGL_EXT_protected_surface 1 +#endif /* EGL_EXT_protected_surface */ + +#ifndef EGL_EXT_stream_consumer_egloutput +#define EGL_EXT_stream_consumer_egloutput 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMEROUTPUTEXTPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLOutputLayerEXT layer); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerOutputEXT (EGLDisplay dpy, EGLStreamKHR stream, EGLOutputLayerEXT layer); +#endif +#endif /* EGL_EXT_stream_consumer_egloutput */ + +#ifndef EGL_EXT_surface_CTA861_3_metadata +#define EGL_EXT_surface_CTA861_3_metadata 1 +#define EGL_CTA861_3_MAX_CONTENT_LIGHT_LEVEL_EXT 0x3360 +#define EGL_CTA861_3_MAX_FRAME_AVERAGE_LEVEL_EXT 0x3361 +#endif /* EGL_EXT_surface_CTA861_3_metadata */ + +#ifndef EGL_EXT_surface_SMPTE2086_metadata +#define EGL_EXT_surface_SMPTE2086_metadata 1 +#define EGL_SMPTE2086_DISPLAY_PRIMARY_RX_EXT 0x3341 +#define EGL_SMPTE2086_DISPLAY_PRIMARY_RY_EXT 0x3342 +#define EGL_SMPTE2086_DISPLAY_PRIMARY_GX_EXT 0x3343 +#define EGL_SMPTE2086_DISPLAY_PRIMARY_GY_EXT 0x3344 +#define EGL_SMPTE2086_DISPLAY_PRIMARY_BX_EXT 0x3345 +#define EGL_SMPTE2086_DISPLAY_PRIMARY_BY_EXT 0x3346 +#define EGL_SMPTE2086_WHITE_POINT_X_EXT 0x3347 +#define EGL_SMPTE2086_WHITE_POINT_Y_EXT 0x3348 +#define EGL_SMPTE2086_MAX_LUMINANCE_EXT 0x3349 +#define EGL_SMPTE2086_MIN_LUMINANCE_EXT 0x334A +#define EGL_METADATA_SCALING_EXT 50000 +#endif /* EGL_EXT_surface_SMPTE2086_metadata */ + +#ifndef EGL_EXT_swap_buffers_with_damage +#define EGL_EXT_swap_buffers_with_damage 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC) (EGLDisplay dpy, EGLSurface surface, const EGLint *rects, EGLint n_rects); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageEXT (EGLDisplay dpy, EGLSurface surface, const EGLint *rects, EGLint n_rects); +#endif +#endif /* EGL_EXT_swap_buffers_with_damage */ + +#ifndef EGL_EXT_sync_reuse +#define EGL_EXT_sync_reuse 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNSIGNALSYNCEXTPROC) (EGLDisplay dpy, EGLSync sync, const EGLAttrib *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglUnsignalSyncEXT (EGLDisplay dpy, EGLSync sync, const EGLAttrib *attrib_list); +#endif +#endif /* EGL_EXT_sync_reuse */ + +#ifndef EGL_EXT_yuv_surface +#define EGL_EXT_yuv_surface 1 +#define EGL_YUV_ORDER_EXT 0x3301 +#define EGL_YUV_NUMBER_OF_PLANES_EXT 0x3311 +#define EGL_YUV_SUBSAMPLE_EXT 0x3312 +#define EGL_YUV_DEPTH_RANGE_EXT 0x3317 +#define EGL_YUV_CSC_STANDARD_EXT 0x330A +#define EGL_YUV_PLANE_BPP_EXT 0x331A +#define EGL_YUV_BUFFER_EXT 0x3300 +#define EGL_YUV_ORDER_YUV_EXT 0x3302 +#define EGL_YUV_ORDER_YVU_EXT 0x3303 +#define EGL_YUV_ORDER_YUYV_EXT 0x3304 +#define EGL_YUV_ORDER_UYVY_EXT 0x3305 +#define EGL_YUV_ORDER_YVYU_EXT 0x3306 +#define EGL_YUV_ORDER_VYUY_EXT 0x3307 +#define EGL_YUV_ORDER_AYUV_EXT 0x3308 +#define EGL_YUV_SUBSAMPLE_4_2_0_EXT 0x3313 +#define EGL_YUV_SUBSAMPLE_4_2_2_EXT 0x3314 +#define EGL_YUV_SUBSAMPLE_4_4_4_EXT 0x3315 +#define EGL_YUV_DEPTH_RANGE_LIMITED_EXT 0x3318 +#define EGL_YUV_DEPTH_RANGE_FULL_EXT 0x3319 +#define EGL_YUV_CSC_STANDARD_601_EXT 0x330B +#define EGL_YUV_CSC_STANDARD_709_EXT 0x330C +#define EGL_YUV_CSC_STANDARD_2020_EXT 0x330D +#define EGL_YUV_PLANE_BPP_0_EXT 0x331B +#define EGL_YUV_PLANE_BPP_8_EXT 0x331C +#define EGL_YUV_PLANE_BPP_10_EXT 0x331D +#endif /* EGL_EXT_yuv_surface */ + +#ifndef EGL_HI_clientpixmap +#define EGL_HI_clientpixmap 1 +struct EGLClientPixmapHI { + void *pData; + EGLint iWidth; + EGLint iHeight; + EGLint iStride; +}; +#define EGL_CLIENT_PIXMAP_POINTER_HI 0x8F74 +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEHIPROC) (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI *pixmap); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurfaceHI (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI *pixmap); +#endif +#endif /* EGL_HI_clientpixmap */ + +#ifndef EGL_HI_colorformats +#define EGL_HI_colorformats 1 +#define EGL_COLOR_FORMAT_HI 0x8F70 +#define EGL_COLOR_RGB_HI 0x8F71 +#define EGL_COLOR_RGBA_HI 0x8F72 +#define EGL_COLOR_ARGB_HI 0x8F73 +#endif /* EGL_HI_colorformats */ + +#ifndef EGL_IMG_context_priority +#define EGL_IMG_context_priority 1 +#define EGL_CONTEXT_PRIORITY_LEVEL_IMG 0x3100 +#define EGL_CONTEXT_PRIORITY_HIGH_IMG 0x3101 +#define EGL_CONTEXT_PRIORITY_MEDIUM_IMG 0x3102 +#define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103 +#endif /* EGL_IMG_context_priority */ + +#ifndef EGL_IMG_image_plane_attribs +#define EGL_IMG_image_plane_attribs 1 +#define EGL_NATIVE_BUFFER_MULTIPLANE_SEPARATE_IMG 0x3105 +#define EGL_NATIVE_BUFFER_PLANE_OFFSET_IMG 0x3106 +#endif /* EGL_IMG_image_plane_attribs */ + +#ifndef EGL_MESA_drm_image +#define EGL_MESA_drm_image 1 +#define EGL_DRM_BUFFER_FORMAT_MESA 0x31D0 +#define EGL_DRM_BUFFER_USE_MESA 0x31D1 +#define EGL_DRM_BUFFER_FORMAT_ARGB32_MESA 0x31D2 +#define EGL_DRM_BUFFER_MESA 0x31D3 +#define EGL_DRM_BUFFER_STRIDE_MESA 0x31D4 +#define EGL_DRM_BUFFER_USE_SCANOUT_MESA 0x00000001 +#define EGL_DRM_BUFFER_USE_SHARE_MESA 0x00000002 +#define EGL_DRM_BUFFER_USE_CURSOR_MESA 0x00000004 +typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEDRMIMAGEMESAPROC) (EGLDisplay dpy, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLImageKHR EGLAPIENTRY eglCreateDRMImageMESA (EGLDisplay dpy, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglExportDRMImageMESA (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride); +#endif +#endif /* EGL_MESA_drm_image */ + +#ifndef EGL_MESA_image_dma_buf_export +#define EGL_MESA_image_dma_buf_export 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDMABUFIMAGEQUERYMESAPROC) (EGLDisplay dpy, EGLImageKHR image, int *fourcc, int *num_planes, EGLuint64KHR *modifiers); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDMABUFIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, int *fds, EGLint *strides, EGLint *offsets); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglExportDMABUFImageQueryMESA (EGLDisplay dpy, EGLImageKHR image, int *fourcc, int *num_planes, EGLuint64KHR *modifiers); +EGLAPI EGLBoolean EGLAPIENTRY eglExportDMABUFImageMESA (EGLDisplay dpy, EGLImageKHR image, int *fds, EGLint *strides, EGLint *offsets); +#endif +#endif /* EGL_MESA_image_dma_buf_export */ + +#ifndef EGL_MESA_platform_gbm +#define EGL_MESA_platform_gbm 1 +#define EGL_PLATFORM_GBM_MESA 0x31D7 +#endif /* EGL_MESA_platform_gbm */ + +#ifndef EGL_MESA_platform_surfaceless +#define EGL_MESA_platform_surfaceless 1 +#define EGL_PLATFORM_SURFACELESS_MESA 0x31DD +#endif /* EGL_MESA_platform_surfaceless */ + +#ifndef EGL_MESA_query_driver +#define EGL_MESA_query_driver 1 +typedef char *(EGLAPIENTRYP PFNEGLGETDISPLAYDRIVERCONFIGPROC) (EGLDisplay dpy); +typedef const char *(EGLAPIENTRYP PFNEGLGETDISPLAYDRIVERNAMEPROC) (EGLDisplay dpy); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI char *EGLAPIENTRY eglGetDisplayDriverConfig (EGLDisplay dpy); +EGLAPI const char *EGLAPIENTRY eglGetDisplayDriverName (EGLDisplay dpy); +#endif +#endif /* EGL_MESA_query_driver */ + +#ifndef EGL_NOK_swap_region +#define EGL_NOK_swap_region 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGIONNOKPROC) (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersRegionNOK (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); +#endif +#endif /* EGL_NOK_swap_region */ + +#ifndef EGL_NOK_swap_region2 +#define EGL_NOK_swap_region2 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGION2NOKPROC) (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersRegion2NOK (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); +#endif +#endif /* EGL_NOK_swap_region2 */ + +#ifndef EGL_NOK_texture_from_pixmap +#define EGL_NOK_texture_from_pixmap 1 +#define EGL_Y_INVERTED_NOK 0x307F +#endif /* EGL_NOK_texture_from_pixmap */ + +#ifndef EGL_NV_3dvision_surface +#define EGL_NV_3dvision_surface 1 +#define EGL_AUTO_STEREO_NV 0x3136 +#endif /* EGL_NV_3dvision_surface */ + +#ifndef EGL_NV_context_priority_realtime +#define EGL_NV_context_priority_realtime 1 +#define EGL_CONTEXT_PRIORITY_REALTIME_NV 0x3357 +#endif /* EGL_NV_context_priority_realtime */ + +#ifndef EGL_NV_coverage_sample +#define EGL_NV_coverage_sample 1 +#define EGL_COVERAGE_BUFFERS_NV 0x30E0 +#define EGL_COVERAGE_SAMPLES_NV 0x30E1 +#endif /* EGL_NV_coverage_sample */ + +#ifndef EGL_NV_coverage_sample_resolve +#define EGL_NV_coverage_sample_resolve 1 +#define EGL_COVERAGE_SAMPLE_RESOLVE_NV 0x3131 +#define EGL_COVERAGE_SAMPLE_RESOLVE_DEFAULT_NV 0x3132 +#define EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV 0x3133 +#endif /* EGL_NV_coverage_sample_resolve */ + +#ifndef EGL_NV_cuda_event +#define EGL_NV_cuda_event 1 +#define EGL_CUDA_EVENT_HANDLE_NV 0x323B +#define EGL_SYNC_CUDA_EVENT_NV 0x323C +#define EGL_SYNC_CUDA_EVENT_COMPLETE_NV 0x323D +#endif /* EGL_NV_cuda_event */ + +#ifndef EGL_NV_depth_nonlinear +#define EGL_NV_depth_nonlinear 1 +#define EGL_DEPTH_ENCODING_NV 0x30E2 +#define EGL_DEPTH_ENCODING_NONE_NV 0 +#define EGL_DEPTH_ENCODING_NONLINEAR_NV 0x30E3 +#endif /* EGL_NV_depth_nonlinear */ + +#ifndef EGL_NV_device_cuda +#define EGL_NV_device_cuda 1 +#define EGL_CUDA_DEVICE_NV 0x323A +#endif /* EGL_NV_device_cuda */ + +#ifndef EGL_NV_native_query +#define EGL_NV_native_query 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEDISPLAYNVPROC) (EGLDisplay dpy, EGLNativeDisplayType *display_id); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEWINDOWNVPROC) (EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType *window); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEPIXMAPNVPROC) (EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType *pixmap); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeDisplayNV (EGLDisplay dpy, EGLNativeDisplayType *display_id); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeWindowNV (EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType *window); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativePixmapNV (EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType *pixmap); +#endif +#endif /* EGL_NV_native_query */ + +#ifndef EGL_NV_post_convert_rounding +#define EGL_NV_post_convert_rounding 1 +#endif /* EGL_NV_post_convert_rounding */ + +#ifndef EGL_NV_post_sub_buffer +#define EGL_NV_post_sub_buffer 1 +#define EGL_POST_SUB_BUFFER_SUPPORTED_NV 0x30BE +typedef EGLBoolean (EGLAPIENTRYP PFNEGLPOSTSUBBUFFERNVPROC) (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height); +#endif +#endif /* EGL_NV_post_sub_buffer */ + +#ifndef EGL_NV_quadruple_buffer +#define EGL_NV_quadruple_buffer 1 +#define EGL_QUADRUPLE_BUFFER_NV 0x3231 +#endif /* EGL_NV_quadruple_buffer */ + +#ifndef EGL_NV_robustness_video_memory_purge +#define EGL_NV_robustness_video_memory_purge 1 +#define EGL_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV 0x334C +#endif /* EGL_NV_robustness_video_memory_purge */ + +#ifndef EGL_NV_stream_consumer_gltexture_yuv +#define EGL_NV_stream_consumer_gltexture_yuv 1 +#define EGL_YUV_PLANE0_TEXTURE_UNIT_NV 0x332C +#define EGL_YUV_PLANE1_TEXTURE_UNIT_NV 0x332D +#define EGL_YUV_PLANE2_TEXTURE_UNIT_NV 0x332E +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALATTRIBSNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalAttribsNV (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); +#endif +#endif /* EGL_NV_stream_consumer_gltexture_yuv */ + +#ifndef EGL_NV_stream_cross_display +#define EGL_NV_stream_cross_display 1 +#define EGL_STREAM_CROSS_DISPLAY_NV 0x334E +#endif /* EGL_NV_stream_cross_display */ + +#ifndef EGL_NV_stream_cross_object +#define EGL_NV_stream_cross_object 1 +#define EGL_STREAM_CROSS_OBJECT_NV 0x334D +#endif /* EGL_NV_stream_cross_object */ + +#ifndef EGL_NV_stream_cross_partition +#define EGL_NV_stream_cross_partition 1 +#define EGL_STREAM_CROSS_PARTITION_NV 0x323F +#endif /* EGL_NV_stream_cross_partition */ + +#ifndef EGL_NV_stream_cross_process +#define EGL_NV_stream_cross_process 1 +#define EGL_STREAM_CROSS_PROCESS_NV 0x3245 +#endif /* EGL_NV_stream_cross_process */ + +#ifndef EGL_NV_stream_cross_system +#define EGL_NV_stream_cross_system 1 +#define EGL_STREAM_CROSS_SYSTEM_NV 0x334F +#endif /* EGL_NV_stream_cross_system */ + +#ifndef EGL_NV_stream_dma +#define EGL_NV_stream_dma 1 +#define EGL_STREAM_DMA_NV 0x3371 +#define EGL_STREAM_DMA_SERVER_NV 0x3372 +#endif /* EGL_NV_stream_dma */ + +#ifndef EGL_NV_stream_fifo_next +#define EGL_NV_stream_fifo_next 1 +#define EGL_PENDING_FRAME_NV 0x3329 +#define EGL_STREAM_TIME_PENDING_NV 0x332A +#endif /* EGL_NV_stream_fifo_next */ + +#ifndef EGL_NV_stream_fifo_synchronous +#define EGL_NV_stream_fifo_synchronous 1 +#define EGL_STREAM_FIFO_SYNCHRONOUS_NV 0x3336 +#endif /* EGL_NV_stream_fifo_synchronous */ + +#ifndef EGL_NV_stream_flush +#define EGL_NV_stream_flush 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMFLUSHNVPROC) (EGLDisplay dpy, EGLStreamKHR stream); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglStreamFlushNV (EGLDisplay dpy, EGLStreamKHR stream); +#endif +#endif /* EGL_NV_stream_flush */ + +#ifndef EGL_NV_stream_frame_limits +#define EGL_NV_stream_frame_limits 1 +#define EGL_PRODUCER_MAX_FRAME_HINT_NV 0x3337 +#define EGL_CONSUMER_MAX_FRAME_HINT_NV 0x3338 +#endif /* EGL_NV_stream_frame_limits */ + +#ifndef EGL_NV_stream_metadata +#define EGL_NV_stream_metadata 1 +#define EGL_MAX_STREAM_METADATA_BLOCKS_NV 0x3250 +#define EGL_MAX_STREAM_METADATA_BLOCK_SIZE_NV 0x3251 +#define EGL_MAX_STREAM_METADATA_TOTAL_SIZE_NV 0x3252 +#define EGL_PRODUCER_METADATA_NV 0x3253 +#define EGL_CONSUMER_METADATA_NV 0x3254 +#define EGL_PENDING_METADATA_NV 0x3328 +#define EGL_METADATA0_SIZE_NV 0x3255 +#define EGL_METADATA1_SIZE_NV 0x3256 +#define EGL_METADATA2_SIZE_NV 0x3257 +#define EGL_METADATA3_SIZE_NV 0x3258 +#define EGL_METADATA0_TYPE_NV 0x3259 +#define EGL_METADATA1_TYPE_NV 0x325A +#define EGL_METADATA2_TYPE_NV 0x325B +#define EGL_METADATA3_TYPE_NV 0x325C +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDISPLAYATTRIBNVPROC) (EGLDisplay dpy, EGLint attribute, EGLAttrib *value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSETSTREAMMETADATANVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLint n, EGLint offset, EGLint size, const void *data); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMMETADATANVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum name, EGLint n, EGLint offset, EGLint size, void *data); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribNV (EGLDisplay dpy, EGLint attribute, EGLAttrib *value); +EGLAPI EGLBoolean EGLAPIENTRY eglSetStreamMetadataNV (EGLDisplay dpy, EGLStreamKHR stream, EGLint n, EGLint offset, EGLint size, const void *data); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamMetadataNV (EGLDisplay dpy, EGLStreamKHR stream, EGLenum name, EGLint n, EGLint offset, EGLint size, void *data); +#endif +#endif /* EGL_NV_stream_metadata */ + +#ifndef EGL_NV_stream_origin +#define EGL_NV_stream_origin 1 +#define EGL_STREAM_FRAME_ORIGIN_X_NV 0x3366 +#define EGL_STREAM_FRAME_ORIGIN_Y_NV 0x3367 +#define EGL_STREAM_FRAME_MAJOR_AXIS_NV 0x3368 +#define EGL_CONSUMER_AUTO_ORIENTATION_NV 0x3369 +#define EGL_PRODUCER_AUTO_ORIENTATION_NV 0x336A +#define EGL_LEFT_NV 0x336B +#define EGL_RIGHT_NV 0x336C +#define EGL_TOP_NV 0x336D +#define EGL_BOTTOM_NV 0x336E +#define EGL_X_AXIS_NV 0x336F +#define EGL_Y_AXIS_NV 0x3370 +#endif /* EGL_NV_stream_origin */ + +#ifndef EGL_NV_stream_remote +#define EGL_NV_stream_remote 1 +#define EGL_STREAM_STATE_INITIALIZING_NV 0x3240 +#define EGL_STREAM_TYPE_NV 0x3241 +#define EGL_STREAM_PROTOCOL_NV 0x3242 +#define EGL_STREAM_ENDPOINT_NV 0x3243 +#define EGL_STREAM_LOCAL_NV 0x3244 +#define EGL_STREAM_PRODUCER_NV 0x3247 +#define EGL_STREAM_CONSUMER_NV 0x3248 +#define EGL_STREAM_PROTOCOL_FD_NV 0x3246 +#endif /* EGL_NV_stream_remote */ + +#ifndef EGL_NV_stream_reset +#define EGL_NV_stream_reset 1 +#define EGL_SUPPORT_RESET_NV 0x3334 +#define EGL_SUPPORT_REUSE_NV 0x3335 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLRESETSTREAMNVPROC) (EGLDisplay dpy, EGLStreamKHR stream); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglResetStreamNV (EGLDisplay dpy, EGLStreamKHR stream); +#endif +#endif /* EGL_NV_stream_reset */ + +#ifndef EGL_NV_stream_socket +#define EGL_NV_stream_socket 1 +#define EGL_STREAM_PROTOCOL_SOCKET_NV 0x324B +#define EGL_SOCKET_HANDLE_NV 0x324C +#define EGL_SOCKET_TYPE_NV 0x324D +#endif /* EGL_NV_stream_socket */ + +#ifndef EGL_NV_stream_socket_inet +#define EGL_NV_stream_socket_inet 1 +#define EGL_SOCKET_TYPE_INET_NV 0x324F +#endif /* EGL_NV_stream_socket_inet */ + +#ifndef EGL_NV_stream_socket_unix +#define EGL_NV_stream_socket_unix 1 +#define EGL_SOCKET_TYPE_UNIX_NV 0x324E +#endif /* EGL_NV_stream_socket_unix */ + +#ifndef EGL_NV_stream_sync +#define EGL_NV_stream_sync 1 +#define EGL_SYNC_NEW_FRAME_NV 0x321F +typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESTREAMSYNCNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum type, const EGLint *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateStreamSyncNV (EGLDisplay dpy, EGLStreamKHR stream, EGLenum type, const EGLint *attrib_list); +#endif +#endif /* EGL_NV_stream_sync */ + +#ifndef EGL_NV_sync +#define EGL_NV_sync 1 +typedef void *EGLSyncNV; +typedef khronos_utime_nanoseconds_t EGLTimeNV; +#ifdef KHRONOS_SUPPORT_INT64 +#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_NV 0x30E6 +#define EGL_SYNC_STATUS_NV 0x30E7 +#define EGL_SIGNALED_NV 0x30E8 +#define EGL_UNSIGNALED_NV 0x30E9 +#define EGL_SYNC_FLUSH_COMMANDS_BIT_NV 0x0001 +#define EGL_FOREVER_NV 0xFFFFFFFFFFFFFFFFull +#define EGL_ALREADY_SIGNALED_NV 0x30EA +#define EGL_TIMEOUT_EXPIRED_NV 0x30EB +#define EGL_CONDITION_SATISFIED_NV 0x30EC +#define EGL_SYNC_TYPE_NV 0x30ED +#define EGL_SYNC_CONDITION_NV 0x30EE +#define EGL_SYNC_FENCE_NV 0x30EF +#define EGL_NO_SYNC_NV EGL_CAST(EGLSyncNV,0) +typedef EGLSyncNV (EGLAPIENTRYP PFNEGLCREATEFENCESYNCNVPROC) (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCNVPROC) (EGLSyncNV sync); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLFENCENVPROC) (EGLSyncNV sync); +typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCNVPROC) (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCNVPROC) (EGLSyncNV sync, EGLenum mode); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBNVPROC) (EGLSyncNV sync, EGLint attribute, EGLint *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSyncNV EGLAPIENTRY eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncNV (EGLSyncNV sync); +EGLAPI EGLBoolean EGLAPIENTRY eglFenceNV (EGLSyncNV sync); +EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncNV (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout); +EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncNV (EGLSyncNV sync, EGLenum mode); +EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribNV (EGLSyncNV sync, EGLint attribute, EGLint *value); +#endif +#endif /* KHRONOS_SUPPORT_INT64 */ +#endif /* EGL_NV_sync */ + +#ifndef EGL_NV_system_time +#define EGL_NV_system_time 1 +typedef khronos_utime_nanoseconds_t EGLuint64NV; +#ifdef KHRONOS_SUPPORT_INT64 +typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC) (void); +typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC) (void); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeFrequencyNV (void); +EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV (void); +#endif +#endif /* KHRONOS_SUPPORT_INT64 */ +#endif /* EGL_NV_system_time */ + +#ifndef EGL_NV_triple_buffer +#define EGL_NV_triple_buffer 1 +#define EGL_TRIPLE_BUFFER_NV 0x3230 +#endif /* EGL_NV_triple_buffer */ + +#ifndef EGL_TIZEN_image_native_buffer +#define EGL_TIZEN_image_native_buffer 1 +#define EGL_NATIVE_BUFFER_TIZEN 0x32A0 +#endif /* EGL_TIZEN_image_native_buffer */ + +#ifndef EGL_TIZEN_image_native_surface +#define EGL_TIZEN_image_native_surface 1 +#define EGL_NATIVE_SURFACE_TIZEN 0x32A1 +#endif /* EGL_TIZEN_image_native_surface */ + +#ifndef EGL_WL_bind_wayland_display +#define EGL_WL_bind_wayland_display 1 +#define PFNEGLBINDWAYLANDDISPLAYWL PFNEGLBINDWAYLANDDISPLAYWLPROC +#define PFNEGLUNBINDWAYLANDDISPLAYWL PFNEGLUNBINDWAYLANDDISPLAYWLPROC +#define PFNEGLQUERYWAYLANDBUFFERWL PFNEGLQUERYWAYLANDBUFFERWLPROC +struct wl_display; +struct wl_resource; +#define EGL_WAYLAND_BUFFER_WL 0x31D5 +#define EGL_WAYLAND_PLANE_WL 0x31D6 +#define EGL_TEXTURE_Y_U_V_WL 0x31D7 +#define EGL_TEXTURE_Y_UV_WL 0x31D8 +#define EGL_TEXTURE_Y_XUXV_WL 0x31D9 +#define EGL_TEXTURE_EXTERNAL_WL 0x31DA +#define EGL_WAYLAND_Y_INVERTED_WL 0x31DB +typedef EGLBoolean (EGLAPIENTRYP PFNEGLBINDWAYLANDDISPLAYWLPROC) (EGLDisplay dpy, struct wl_display *display); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNBINDWAYLANDDISPLAYWLPROC) (EGLDisplay dpy, struct wl_display *display); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYWAYLANDBUFFERWLPROC) (EGLDisplay dpy, struct wl_resource *buffer, EGLint attribute, EGLint *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglBindWaylandDisplayWL (EGLDisplay dpy, struct wl_display *display); +EGLAPI EGLBoolean EGLAPIENTRY eglUnbindWaylandDisplayWL (EGLDisplay dpy, struct wl_display *display); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryWaylandBufferWL (EGLDisplay dpy, struct wl_resource *buffer, EGLint attribute, EGLint *value); +#endif +#endif /* EGL_WL_bind_wayland_display */ + +#ifndef EGL_WL_create_wayland_buffer_from_image +#define EGL_WL_create_wayland_buffer_from_image 1 +#define PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWL PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWLPROC +struct wl_buffer; +typedef struct wl_buffer *(EGLAPIENTRYP PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWLPROC) (EGLDisplay dpy, EGLImageKHR image); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI struct wl_buffer *EGLAPIENTRY eglCreateWaylandBufferFromImageWL (EGLDisplay dpy, EGLImageKHR image); +#endif +#endif /* EGL_WL_create_wayland_buffer_from_image */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/include/EGL/eglplatform.h b/thirdparty/include/EGL/eglplatform.h new file mode 100644 index 000000000..eaac469f3 --- /dev/null +++ b/thirdparty/include/EGL/eglplatform.h @@ -0,0 +1,182 @@ +#ifndef __eglplatform_h_ +#define __eglplatform_h_ + +/* +** Copyright (c) 2007-2016 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are 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 Materials. +** +** THE MATERIALS ARE 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 +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Platform-specific types and definitions for egl.h + * $Revision: 30994 $ on $Date: 2015-04-30 13:36:48 -0700 (Thu, 30 Apr 2015) $ + * + * Adopters may modify khrplatform.h and this file to suit their platform. + * You are encouraged to submit all modifications to the Khronos group so that + * they can be included in future versions of this file. Please submit changes + * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) + * by filing a bug against product "EGL" component "Registry". + */ + +#include + +/* Macros used in EGL function prototype declarations. + * + * EGL functions should be prototyped as: + * + * EGLAPI return-type EGLAPIENTRY eglFunction(arguments); + * typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments); + * + * KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h + */ + +#ifndef EGLAPI +#define EGLAPI KHRONOS_APICALL +#endif + +#ifndef EGLAPIENTRY +#define EGLAPIENTRY KHRONOS_APIENTRY +#endif +#define EGLAPIENTRYP EGLAPIENTRY* + +/* The types NativeDisplayType, NativeWindowType, and NativePixmapType + * are aliases of window-system-dependent types, such as X Display * or + * Windows Device Context. They must be defined in platform-specific + * code below. The EGL-prefixed versions of Native*Type are the same + * types, renamed in EGL 1.3 so all types in the API start with "EGL". + * + * Khronos STRONGLY RECOMMENDS that you use the default definitions + * provided below, since these changes affect both binary and source + * portability of applications using EGL running on different EGL + * implementations. + */ + +#if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */ +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif +#include + +typedef HDC EGLNativeDisplayType; +typedef HBITMAP EGLNativePixmapType; +typedef HWND EGLNativeWindowType; + +#elif defined(__EMSCRIPTEN__) + +typedef int EGLNativeDisplayType; +typedef int EGLNativePixmapType; +typedef int EGLNativeWindowType; + +#elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */ + +typedef int EGLNativeDisplayType; +typedef void *EGLNativePixmapType; +typedef void *EGLNativeWindowType; + +#elif defined(WL_EGL_PLATFORM) + +typedef struct wl_display *EGLNativeDisplayType; +typedef struct wl_egl_pixmap *EGLNativePixmapType; +typedef struct wl_egl_window *EGLNativeWindowType; + +#elif defined(__GBM__) + +typedef struct gbm_device *EGLNativeDisplayType; +typedef struct gbm_bo *EGLNativePixmapType; +typedef void *EGLNativeWindowType; + +#elif defined(__ANDROID__) || defined(ANDROID) + +struct ANativeWindow; +struct egl_native_pixmap_t; + +typedef void* EGLNativeDisplayType; +typedef struct egl_native_pixmap_t* EGLNativePixmapType; +typedef struct ANativeWindow* EGLNativeWindowType; + +#elif defined(USE_OZONE) + +typedef intptr_t EGLNativeDisplayType; +typedef intptr_t EGLNativePixmapType; +typedef intptr_t EGLNativeWindowType; + +#elif defined(__unix__) && defined(EGL_NO_X11) + +typedef void *EGLNativeDisplayType; +typedef khronos_uintptr_t EGLNativePixmapType; +typedef khronos_uintptr_t EGLNativeWindowType; + +#elif defined(__unix__) || defined(USE_X11) + +/* X11 (tentative) */ +#include +#include + +typedef Display *EGLNativeDisplayType; +typedef Pixmap EGLNativePixmapType; +typedef Window EGLNativeWindowType; + +#elif defined(__APPLE__) + +typedef int EGLNativeDisplayType; +typedef void *EGLNativePixmapType; +typedef void *EGLNativeWindowType; + +#elif defined(__HAIKU__) + +#include + +typedef void *EGLNativeDisplayType; +typedef khronos_uintptr_t EGLNativePixmapType; +typedef khronos_uintptr_t EGLNativeWindowType; + +#elif defined(__Fuchsia__) + +typedef void *EGLNativeDisplayType; +typedef khronos_uintptr_t EGLNativePixmapType; +typedef khronos_uintptr_t EGLNativeWindowType; + +#else +#error "Platform not recognized" +#endif + +/* EGL 1.2 types, renamed for consistency in EGL 1.3 */ +typedef EGLNativeDisplayType NativeDisplayType; +typedef EGLNativePixmapType NativePixmapType; +typedef EGLNativeWindowType NativeWindowType; + + +/* Define EGLint. This must be a signed integral type large enough to contain + * all legal attribute names and values passed into and out of EGL, whether + * their type is boolean, bitmask, enumerant (symbolic constant), integer, + * handle, or other. While in general a 32-bit integer will suffice, if + * handles are 64 bit types, then EGLint should be defined as a signed 64-bit + * integer type. + */ +typedef khronos_int32_t EGLint; + + +/* C++ / C typecast macros for special EGL handle values */ +#if defined(__cplusplus) +#define EGL_CAST(type, value) (static_cast(value)) +#else +#define EGL_CAST(type, value) ((type) (value)) +#endif + +#endif /* __eglplatform_h */ diff --git a/thirdparty/include/GL/glcorearb.h b/thirdparty/include/GL/glcorearb.h index 7d43f94ce..8d691cccf 100644 --- a/thirdparty/include/GL/glcorearb.h +++ b/thirdparty/include/GL/glcorearb.h @@ -1,12 +1,12 @@ -#ifndef __glcorearb_h_ -#define __glcorearb_h_ 1 +#ifndef __gl_glcorearb_h_ +#define __gl_glcorearb_h_ 1 #ifdef __cplusplus extern "C" { #endif /* -** Copyright (c) 2013-2014 The Khronos Group Inc. +** Copyright (c) 2013-2018 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the @@ -31,9 +31,7 @@ extern "C" { ** This header is generated from the Khronos OpenGL / OpenGL ES XML ** API Registry. The current version of the Registry, generator scripts ** used to make the header, and the header can be found at -** http://www.opengl.org/registry/ -** -** Khronos $Revision: 26007 $ on $Date: 2014-03-19 01:28:09 -0700 (Wed, 19 Mar 2014) $ +** https://github.com/KhronosGroup/OpenGL-Registry */ #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) @@ -81,118 +79,15 @@ extern "C" { #define GL_VERSION_1_0 1 typedef void GLvoid; typedef unsigned int GLenum; -typedef float GLfloat; +#include +typedef khronos_float_t GLfloat; typedef int GLint; typedef int GLsizei; typedef unsigned int GLbitfield; typedef double GLdouble; typedef unsigned int GLuint; typedef unsigned char GLboolean; -typedef unsigned char GLubyte; -typedef void (APIENTRYP PFNGLCULLFACEPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLFRONTFACEPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLHINTPROC) (GLenum target, GLenum mode); -typedef void (APIENTRYP PFNGLLINEWIDTHPROC) (GLfloat width); -typedef void (APIENTRYP PFNGLPOINTSIZEPROC) (GLfloat size); -typedef void (APIENTRYP PFNGLPOLYGONMODEPROC) (GLenum face, GLenum mode); -typedef void (APIENTRYP PFNGLSCISSORPROC) (GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLTEXPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLTEXPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLTEXPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXIMAGE1DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLDRAWBUFFERPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLCLEARPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLCLEARCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -typedef void (APIENTRYP PFNGLCLEARSTENCILPROC) (GLint s); -typedef void (APIENTRYP PFNGLCLEARDEPTHPROC) (GLdouble depth); -typedef void (APIENTRYP PFNGLSTENCILMASKPROC) (GLuint mask); -typedef void (APIENTRYP PFNGLCOLORMASKPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -typedef void (APIENTRYP PFNGLDEPTHMASKPROC) (GLboolean flag); -typedef void (APIENTRYP PFNGLDISABLEPROC) (GLenum cap); -typedef void (APIENTRYP PFNGLENABLEPROC) (GLenum cap); -typedef void (APIENTRYP PFNGLFINISHPROC) (void); -typedef void (APIENTRYP PFNGLFLUSHPROC) (void); -typedef void (APIENTRYP PFNGLBLENDFUNCPROC) (GLenum sfactor, GLenum dfactor); -typedef void (APIENTRYP PFNGLLOGICOPPROC) (GLenum opcode); -typedef void (APIENTRYP PFNGLSTENCILFUNCPROC) (GLenum func, GLint ref, GLuint mask); -typedef void (APIENTRYP PFNGLSTENCILOPPROC) (GLenum fail, GLenum zfail, GLenum zpass); -typedef void (APIENTRYP PFNGLDEPTHFUNCPROC) (GLenum func); -typedef void (APIENTRYP PFNGLPIXELSTOREFPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLREADBUFFERPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); -typedef void (APIENTRYP PFNGLGETBOOLEANVPROC) (GLenum pname, GLboolean *data); -typedef void (APIENTRYP PFNGLGETDOUBLEVPROC) (GLenum pname, GLdouble *data); -typedef GLenum (APIENTRYP PFNGLGETERRORPROC) (void); -typedef void (APIENTRYP PFNGLGETFLOATVPROC) (GLenum pname, GLfloat *data); -typedef void (APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *data); -typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGPROC) (GLenum name); -typedef void (APIENTRYP PFNGLGETTEXIMAGEPROC) (GLenum target, GLint level, GLenum format, GLenum type, void *pixels); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERFVPROC) (GLenum target, GLint level, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERIVPROC) (GLenum target, GLint level, GLenum pname, GLint *params); -typedef GLboolean (APIENTRYP PFNGLISENABLEDPROC) (GLenum cap); -typedef void (APIENTRYP PFNGLDEPTHRANGEPROC) (GLdouble near, GLdouble far); -typedef void (APIENTRYP PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCullFace (GLenum mode); -GLAPI void APIENTRY glFrontFace (GLenum mode); -GLAPI void APIENTRY glHint (GLenum target, GLenum mode); -GLAPI void APIENTRY glLineWidth (GLfloat width); -GLAPI void APIENTRY glPointSize (GLfloat size); -GLAPI void APIENTRY glPolygonMode (GLenum face, GLenum mode); -GLAPI void APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTexImage1D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glDrawBuffer (GLenum mode); -GLAPI void APIENTRY glClear (GLbitfield mask); -GLAPI void APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -GLAPI void APIENTRY glClearStencil (GLint s); -GLAPI void APIENTRY glClearDepth (GLdouble depth); -GLAPI void APIENTRY glStencilMask (GLuint mask); -GLAPI void APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -GLAPI void APIENTRY glDepthMask (GLboolean flag); -GLAPI void APIENTRY glDisable (GLenum cap); -GLAPI void APIENTRY glEnable (GLenum cap); -GLAPI void APIENTRY glFinish (void); -GLAPI void APIENTRY glFlush (void); -GLAPI void APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); -GLAPI void APIENTRY glLogicOp (GLenum opcode); -GLAPI void APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); -GLAPI void APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); -GLAPI void APIENTRY glDepthFunc (GLenum func); -GLAPI void APIENTRY glPixelStoref (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPixelStorei (GLenum pname, GLint param); -GLAPI void APIENTRY glReadBuffer (GLenum mode); -GLAPI void APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); -GLAPI void APIENTRY glGetBooleanv (GLenum pname, GLboolean *data); -GLAPI void APIENTRY glGetDoublev (GLenum pname, GLdouble *data); -GLAPI GLenum APIENTRY glGetError (void); -GLAPI void APIENTRY glGetFloatv (GLenum pname, GLfloat *data); -GLAPI void APIENTRY glGetIntegerv (GLenum pname, GLint *data); -GLAPI const GLubyte *APIENTRY glGetString (GLenum name); -GLAPI void APIENTRY glGetTexImage (GLenum target, GLint level, GLenum format, GLenum type, void *pixels); -GLAPI void APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint *params); -GLAPI GLboolean APIENTRY glIsEnabled (GLenum cap); -GLAPI void APIENTRY glDepthRange (GLdouble near, GLdouble far); -GLAPI void APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); -#endif -#endif /* GL_VERSION_1_0 */ - -#ifndef GL_VERSION_1_1 -#define GL_VERSION_1_1 1 -typedef float GLclampf; -typedef double GLclampd; +typedef khronos_uint8_t GLubyte; #define GL_DEPTH_BUFFER_BIT 0x00000100 #define GL_STENCIL_BUFFER_BIT 0x00000400 #define GL_COLOR_BUFFER_BIT 0x00004000 @@ -274,7 +169,6 @@ typedef double GLclampd; #define GL_BLEND_SRC 0x0BE1 #define GL_BLEND 0x0BE2 #define GL_LOGIC_OP_MODE 0x0BF0 -#define GL_COLOR_LOGIC_OP 0x0BF2 #define GL_DRAW_BUFFER 0x0C01 #define GL_READ_BUFFER 0x0C02 #define GL_SCISSOR_BOX 0x0C10 @@ -302,21 +196,9 @@ typedef double GLclampd; #define GL_SUBPIXEL_BITS 0x0D50 #define GL_TEXTURE_1D 0x0DE0 #define GL_TEXTURE_2D 0x0DE1 -#define GL_POLYGON_OFFSET_UNITS 0x2A00 -#define GL_POLYGON_OFFSET_POINT 0x2A01 -#define GL_POLYGON_OFFSET_LINE 0x2A02 -#define GL_POLYGON_OFFSET_FILL 0x8037 -#define GL_POLYGON_OFFSET_FACTOR 0x8038 -#define GL_TEXTURE_BINDING_1D 0x8068 -#define GL_TEXTURE_BINDING_2D 0x8069 #define GL_TEXTURE_WIDTH 0x1000 #define GL_TEXTURE_HEIGHT 0x1001 -#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 #define GL_TEXTURE_BORDER_COLOR 0x1004 -#define GL_TEXTURE_RED_SIZE 0x805C -#define GL_TEXTURE_GREEN_SIZE 0x805D -#define GL_TEXTURE_BLUE_SIZE 0x805E -#define GL_TEXTURE_ALPHA_SIZE 0x805F #define GL_DONT_CARE 0x1100 #define GL_FASTEST 0x1101 #define GL_NICEST 0x1102 @@ -327,7 +209,6 @@ typedef double GLclampd; #define GL_INT 0x1404 #define GL_UNSIGNED_INT 0x1405 #define GL_FLOAT 0x1406 -#define GL_DOUBLE 0x140A #define GL_STACK_OVERFLOW 0x0503 #define GL_STACK_UNDERFLOW 0x0504 #define GL_CLEAR 0x1500 @@ -379,9 +260,127 @@ typedef double GLclampd; #define GL_TEXTURE_MIN_FILTER 0x2801 #define GL_TEXTURE_WRAP_S 0x2802 #define GL_TEXTURE_WRAP_T 0x2803 +#define GL_REPEAT 0x2901 +typedef void (APIENTRYP PFNGLCULLFACEPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLFRONTFACEPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLHINTPROC) (GLenum target, GLenum mode); +typedef void (APIENTRYP PFNGLLINEWIDTHPROC) (GLfloat width); +typedef void (APIENTRYP PFNGLPOINTSIZEPROC) (GLfloat size); +typedef void (APIENTRYP PFNGLPOLYGONMODEPROC) (GLenum face, GLenum mode); +typedef void (APIENTRYP PFNGLSCISSORPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLTEXPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLTEXPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXIMAGE1DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLDRAWBUFFERPROC) (GLenum buf); +typedef void (APIENTRYP PFNGLCLEARPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLCLEARCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (APIENTRYP PFNGLCLEARSTENCILPROC) (GLint s); +typedef void (APIENTRYP PFNGLCLEARDEPTHPROC) (GLdouble depth); +typedef void (APIENTRYP PFNGLSTENCILMASKPROC) (GLuint mask); +typedef void (APIENTRYP PFNGLCOLORMASKPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +typedef void (APIENTRYP PFNGLDEPTHMASKPROC) (GLboolean flag); +typedef void (APIENTRYP PFNGLDISABLEPROC) (GLenum cap); +typedef void (APIENTRYP PFNGLENABLEPROC) (GLenum cap); +typedef void (APIENTRYP PFNGLFINISHPROC) (void); +typedef void (APIENTRYP PFNGLFLUSHPROC) (void); +typedef void (APIENTRYP PFNGLBLENDFUNCPROC) (GLenum sfactor, GLenum dfactor); +typedef void (APIENTRYP PFNGLLOGICOPPROC) (GLenum opcode); +typedef void (APIENTRYP PFNGLSTENCILFUNCPROC) (GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILOPPROC) (GLenum fail, GLenum zfail, GLenum zpass); +typedef void (APIENTRYP PFNGLDEPTHFUNCPROC) (GLenum func); +typedef void (APIENTRYP PFNGLPIXELSTOREFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLREADBUFFERPROC) (GLenum src); +typedef void (APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); +typedef void (APIENTRYP PFNGLGETBOOLEANVPROC) (GLenum pname, GLboolean *data); +typedef void (APIENTRYP PFNGLGETDOUBLEVPROC) (GLenum pname, GLdouble *data); +typedef GLenum (APIENTRYP PFNGLGETERRORPROC) (void); +typedef void (APIENTRYP PFNGLGETFLOATVPROC) (GLenum pname, GLfloat *data); +typedef void (APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *data); +typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGPROC) (GLenum name); +typedef void (APIENTRYP PFNGLGETTEXIMAGEPROC) (GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERFVPROC) (GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERIVPROC) (GLenum target, GLint level, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISENABLEDPROC) (GLenum cap); +typedef void (APIENTRYP PFNGLDEPTHRANGEPROC) (GLdouble n, GLdouble f); +typedef void (APIENTRYP PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCullFace (GLenum mode); +GLAPI void APIENTRY glFrontFace (GLenum mode); +GLAPI void APIENTRY glHint (GLenum target, GLenum mode); +GLAPI void APIENTRY glLineWidth (GLfloat width); +GLAPI void APIENTRY glPointSize (GLfloat size); +GLAPI void APIENTRY glPolygonMode (GLenum face, GLenum mode); +GLAPI void APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexImage1D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glDrawBuffer (GLenum buf); +GLAPI void APIENTRY glClear (GLbitfield mask); +GLAPI void APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GLAPI void APIENTRY glClearStencil (GLint s); +GLAPI void APIENTRY glClearDepth (GLdouble depth); +GLAPI void APIENTRY glStencilMask (GLuint mask); +GLAPI void APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +GLAPI void APIENTRY glDepthMask (GLboolean flag); +GLAPI void APIENTRY glDisable (GLenum cap); +GLAPI void APIENTRY glEnable (GLenum cap); +GLAPI void APIENTRY glFinish (void); +GLAPI void APIENTRY glFlush (void); +GLAPI void APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); +GLAPI void APIENTRY glLogicOp (GLenum opcode); +GLAPI void APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); +GLAPI void APIENTRY glDepthFunc (GLenum func); +GLAPI void APIENTRY glPixelStoref (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelStorei (GLenum pname, GLint param); +GLAPI void APIENTRY glReadBuffer (GLenum src); +GLAPI void APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); +GLAPI void APIENTRY glGetBooleanv (GLenum pname, GLboolean *data); +GLAPI void APIENTRY glGetDoublev (GLenum pname, GLdouble *data); +GLAPI GLenum APIENTRY glGetError (void); +GLAPI void APIENTRY glGetFloatv (GLenum pname, GLfloat *data); +GLAPI void APIENTRY glGetIntegerv (GLenum pname, GLint *data); +GLAPI const GLubyte *APIENTRY glGetString (GLenum name); +GLAPI void APIENTRY glGetTexImage (GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +GLAPI void APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsEnabled (GLenum cap); +GLAPI void APIENTRY glDepthRange (GLdouble n, GLdouble f); +GLAPI void APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); +#endif +#endif /* GL_VERSION_1_0 */ + +#ifndef GL_VERSION_1_1 +#define GL_VERSION_1_1 1 +typedef khronos_float_t GLclampf; +typedef double GLclampd; +#define GL_COLOR_LOGIC_OP 0x0BF2 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#define GL_POLYGON_OFFSET_POINT 0x2A01 +#define GL_POLYGON_OFFSET_LINE 0x2A02 +#define GL_POLYGON_OFFSET_FILL 0x8037 +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_TEXTURE_BINDING_1D 0x8068 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 +#define GL_TEXTURE_RED_SIZE 0x805C +#define GL_TEXTURE_GREEN_SIZE 0x805D +#define GL_TEXTURE_BLUE_SIZE 0x805E +#define GL_TEXTURE_ALPHA_SIZE 0x805F +#define GL_DOUBLE 0x140A #define GL_PROXY_TEXTURE_1D 0x8063 #define GL_PROXY_TEXTURE_2D 0x8064 -#define GL_REPEAT 0x2901 #define GL_R3_G3_B2 0x2A10 #define GL_RGB4 0x804F #define GL_RGB5 0x8050 @@ -580,15 +579,17 @@ GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, void *i #define GL_TEXTURE_DEPTH_SIZE 0x884A #define GL_TEXTURE_COMPARE_MODE 0x884C #define GL_TEXTURE_COMPARE_FUNC 0x884D -#define GL_FUNC_ADD 0x8006 -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B -#define GL_MIN 0x8007 -#define GL_MAX 0x8008 +#define GL_BLEND_COLOR 0x8005 +#define GL_BLEND_EQUATION 0x8009 #define GL_CONSTANT_COLOR 0x8001 #define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 #define GL_CONSTANT_ALPHA 0x8003 #define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_FUNC_ADD 0x8006 +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_FUNC_SUBTRACT 0x800A +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); @@ -613,9 +614,8 @@ GLAPI void APIENTRY glBlendEquation (GLenum mode); #ifndef GL_VERSION_1_5 #define GL_VERSION_1_5 1 -#include -typedef ptrdiff_t GLsizeiptr; -typedef ptrdiff_t GLintptr; +typedef khronos_ssize_t GLsizeiptr; +typedef khronos_intptr_t GLintptr; #define GL_BUFFER_SIZE 0x8764 #define GL_BUFFER_USAGE 0x8765 #define GL_QUERY_COUNTER_BITS 0x8864 @@ -689,9 +689,9 @@ GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, void **par #ifndef GL_VERSION_2_0 #define GL_VERSION_2_0 1 typedef char GLchar; -typedef short GLshort; -typedef signed char GLbyte; -typedef unsigned short GLushort; +typedef khronos_int16_t GLshort; +typedef khronos_int8_t GLbyte; +typedef khronos_uint16_t GLushort; #define GL_BLEND_EQUATION_RGB 0x8009 #define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 #define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 @@ -998,7 +998,7 @@ GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboole #ifndef GL_VERSION_3_0 #define GL_VERSION_3_0 1 -typedef unsigned short GLhalf; +typedef khronos_uint16_t GLhalf; #define GL_COMPARE_REF_TO_TEXTURE 0x884E #define GL_CLIP_DISTANCE0 0x3000 #define GL_CLIP_DISTANCE1 0x3001 @@ -1160,6 +1160,22 @@ typedef unsigned short GLhalf; #define GL_COLOR_ATTACHMENT13 0x8CED #define GL_COLOR_ATTACHMENT14 0x8CEE #define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_COLOR_ATTACHMENT16 0x8CF0 +#define GL_COLOR_ATTACHMENT17 0x8CF1 +#define GL_COLOR_ATTACHMENT18 0x8CF2 +#define GL_COLOR_ATTACHMENT19 0x8CF3 +#define GL_COLOR_ATTACHMENT20 0x8CF4 +#define GL_COLOR_ATTACHMENT21 0x8CF5 +#define GL_COLOR_ATTACHMENT22 0x8CF6 +#define GL_COLOR_ATTACHMENT23 0x8CF7 +#define GL_COLOR_ATTACHMENT24 0x8CF8 +#define GL_COLOR_ATTACHMENT25 0x8CF9 +#define GL_COLOR_ATTACHMENT26 0x8CFA +#define GL_COLOR_ATTACHMENT27 0x8CFB +#define GL_COLOR_ATTACHMENT28 0x8CFC +#define GL_COLOR_ATTACHMENT29 0x8CFD +#define GL_COLOR_ATTACHMENT30 0x8CFE +#define GL_COLOR_ATTACHMENT31 0x8CFF #define GL_DEPTH_ATTACHMENT 0x8D00 #define GL_STENCIL_ATTACHMENT 0x8D20 #define GL_FRAMEBUFFER 0x8D40 @@ -1421,11 +1437,13 @@ GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); #define GL_UNIFORM_BUFFER_START 0x8A29 #define GL_UNIFORM_BUFFER_SIZE 0x8A2A #define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C #define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D #define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E #define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F #define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 #define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 #define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 #define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 #define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 @@ -1444,6 +1462,7 @@ GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); #define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 #define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 #define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 #define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 #define GL_INVALID_INDEX 0xFFFFFFFFu typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); @@ -1477,45 +1496,8 @@ GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIn #ifndef GL_VERSION_3_2 #define GL_VERSION_3_2 1 typedef struct __GLsync *GLsync; -#ifndef GLEXT_64_TYPES_DEFINED -/* This code block is duplicated in glxext.h, so must be protected */ -#define GLEXT_64_TYPES_DEFINED -/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ -/* (as used in the GL_EXT_timer_query extension). */ -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#include -#elif defined(__sun__) || defined(__digital__) -#include -#if defined(__STDC__) -#if defined(__arch64__) || defined(_LP64) -typedef long int int64_t; -typedef unsigned long int uint64_t; -#else -typedef long long int int64_t; -typedef unsigned long long int uint64_t; -#endif /* __arch64__ */ -#endif /* __STDC__ */ -#elif defined( __VMS ) || defined(__sgi) -#include -#elif defined(__SCO__) || defined(__USLC__) -#include -#elif defined(__UNIXOS2__) || defined(__SOL64__) -typedef long int int32_t; -typedef long long int int64_t; -typedef unsigned long long int uint64_t; -#elif defined(_WIN32) && defined(__GNUC__) -#include -#elif defined(_WIN32) -typedef __int32 int32_t; -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; -#else -/* Fallback if nothing above works */ -#include -#endif -#endif -typedef uint64_t GLuint64; -typedef int64_t GLint64; +typedef khronos_uint64_t GLuint64; +typedef khronos_int64_t GLint64; #define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 #define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 #define GL_LINES_ADJACENCY 0x000A @@ -1591,7 +1573,7 @@ typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *data); -typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values); typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); @@ -1611,7 +1593,7 @@ GLAPI void APIENTRY glDeleteSync (GLsync sync); GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *data); -GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values); GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); @@ -1807,8 +1789,8 @@ typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); @@ -1854,8 +1836,8 @@ GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *pa GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); -GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); @@ -2094,6 +2076,10 @@ GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data) #ifndef GL_VERSION_4_2 #define GL_VERSION_4_2 1 +#define GL_COPY_READ_BUFFER_BINDING 0x8F36 +#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 +#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 #define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 #define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 #define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 @@ -2205,7 +2191,7 @@ GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data) typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); -typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint *params); typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); @@ -2218,7 +2204,7 @@ typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum m GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); -GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint *params); GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers); @@ -2265,6 +2251,7 @@ typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum #define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED #define GL_DISPATCH_INDIRECT_BUFFER 0x90EE #define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF +#define GL_COMPUTE_SHADER_BIT 0x00000020 #define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 #define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 #define GL_DEBUG_CALLBACK_FUNCTION 0x8244 @@ -2497,7 +2484,7 @@ typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint64 *params); typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level); typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); @@ -2509,7 +2496,7 @@ typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum typedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params); typedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); -typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLint *params); typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name); typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); typedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); @@ -2541,7 +2528,7 @@ GLAPI void APIENTRY glDispatchComputeIndirect (GLintptr indirect); GLAPI void APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); GLAPI void APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param); GLAPI void APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetInternalformati64v (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +GLAPI void APIENTRY glGetInternalformati64v (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint64 *params); GLAPI void APIENTRY glInvalidateTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); GLAPI void APIENTRY glInvalidateTexImage (GLuint texture, GLint level); GLAPI void APIENTRY glInvalidateBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr length); @@ -2553,7 +2540,7 @@ GLAPI void APIENTRY glMultiDrawElementsIndirect (GLenum mode, GLenum type, const GLAPI void APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params); GLAPI GLuint APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name); GLAPI void APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); -GLAPI void APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +GLAPI void APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLint *params); GLAPI GLint APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name); GLAPI GLint APIENTRY glGetProgramResourceLocationIndex (GLuint program, GLenum programInterface, const GLchar *name); GLAPI void APIENTRY glShaderStorageBlockBinding (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); @@ -2623,10 +2610,309 @@ GLAPI void APIENTRY glBindVertexBuffers (GLuint first, GLsizei count, const GLui #endif #endif /* GL_VERSION_4_4 */ +#ifndef GL_VERSION_4_5 +#define GL_VERSION_4_5 1 +#define GL_CONTEXT_LOST 0x0507 +#define GL_NEGATIVE_ONE_TO_ONE 0x935E +#define GL_ZERO_TO_ONE 0x935F +#define GL_CLIP_ORIGIN 0x935C +#define GL_CLIP_DEPTH_MODE 0x935D +#define GL_QUERY_WAIT_INVERTED 0x8E17 +#define GL_QUERY_NO_WAIT_INVERTED 0x8E18 +#define GL_QUERY_BY_REGION_WAIT_INVERTED 0x8E19 +#define GL_QUERY_BY_REGION_NO_WAIT_INVERTED 0x8E1A +#define GL_MAX_CULL_DISTANCES 0x82F9 +#define GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES 0x82FA +#define GL_TEXTURE_TARGET 0x1006 +#define GL_QUERY_TARGET 0x82EA +#define GL_GUILTY_CONTEXT_RESET 0x8253 +#define GL_INNOCENT_CONTEXT_RESET 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY 0x8256 +#define GL_LOSE_CONTEXT_ON_RESET 0x8252 +#define GL_NO_RESET_NOTIFICATION 0x8261 +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT 0x00000004 +#define GL_CONTEXT_RELEASE_BEHAVIOR 0x82FB +#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82FC +typedef void (APIENTRYP PFNGLCLIPCONTROLPROC) (GLenum origin, GLenum depth); +typedef void (APIENTRYP PFNGLCREATETRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC) (GLuint xfb, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC) (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKIVPROC) (GLuint xfb, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint *param); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI64_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint64 *param); +typedef void (APIENTRYP PFNGLCREATEBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); +typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +typedef void (APIENTRYP PFNGLCOPYNAMEDBUFFERSUBDATAPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERPROC) (GLuint buffer, GLenum access); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERI64VPROC) (GLuint buffer, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVPROC) (GLuint buffer, GLenum pname, void **params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); +typedef void (APIENTRYP PFNGLCREATEFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC) (GLuint framebuffer, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC) (GLuint framebuffer, GLenum buf); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC) (GLuint framebuffer, GLenum src); +typedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments); +typedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFIPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef void (APIENTRYP PFNGLBLITNAMEDFRAMEBUFFERPROC) (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC) (GLuint framebuffer, GLenum target); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC) (GLuint framebuffer, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCREATERENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC) (GLuint renderbuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCREATETEXTURESPROC) (GLenum target, GLsizei n, GLuint *textures); +typedef void (APIENTRYP PFNGLTEXTUREBUFFERPROC) (GLuint texture, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEPROC) (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFPROC) (GLuint texture, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIPROC) (GLuint texture, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLBINDTEXTUREUNITPROC) (GLuint unit, GLuint texture); +typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVPROC) (GLuint texture, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVPROC) (GLuint texture, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCREATEVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLVERTEXARRAYELEMENTBUFFERPROC) (GLuint vaobj, GLuint buffer); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERSPROC) (GLuint vaobj, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBBINDINGPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBIFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBLFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYBINDINGDIVISORPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYIVPROC) (GLuint vaobj, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINDEXEDIVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINDEXED64IVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint64 *param); +typedef void (APIENTRYP PFNGLCREATESAMPLERSPROC) (GLsizei n, GLuint *samplers); +typedef void (APIENTRYP PFNGLCREATEPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); +typedef void (APIENTRYP PFNGLCREATEQUERIESPROC) (GLenum target, GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTI64VPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTIVPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTUI64VPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTUIVPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void (APIENTRYP PFNGLMEMORYBARRIERBYREGIONPROC) (GLbitfield barriers); +typedef void (APIENTRYP PFNGLGETTEXTURESUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void *pixels); +typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSPROC) (void); +typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint lod, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETNTEXIMAGEPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETNUNIFORMDVPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMFVPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +typedef void (APIENTRYP PFNGLREADNPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +typedef void (APIENTRYP PFNGLTEXTUREBARRIERPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClipControl (GLenum origin, GLenum depth); +GLAPI void APIENTRY glCreateTransformFeedbacks (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glTransformFeedbackBufferBase (GLuint xfb, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackBufferRange (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glGetTransformFeedbackiv (GLuint xfb, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetTransformFeedbacki_v (GLuint xfb, GLenum pname, GLuint index, GLint *param); +GLAPI void APIENTRY glGetTransformFeedbacki64_v (GLuint xfb, GLenum pname, GLuint index, GLint64 *param); +GLAPI void APIENTRY glCreateBuffers (GLsizei n, GLuint *buffers); +GLAPI void APIENTRY glNamedBufferStorage (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); +GLAPI void APIENTRY glNamedBufferData (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); +GLAPI void APIENTRY glNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void APIENTRY glCopyNamedBufferSubData (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glClearNamedBufferData (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearNamedBufferSubData (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void *APIENTRY glMapNamedBuffer (GLuint buffer, GLenum access); +GLAPI void *APIENTRY glMapNamedBufferRange (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI GLboolean APIENTRY glUnmapNamedBuffer (GLuint buffer); +GLAPI void APIENTRY glFlushMappedNamedBufferRange (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glGetNamedBufferParameteriv (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedBufferParameteri64v (GLuint buffer, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetNamedBufferPointerv (GLuint buffer, GLenum pname, void **params); +GLAPI void APIENTRY glGetNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); +GLAPI void APIENTRY glCreateFramebuffers (GLsizei n, GLuint *framebuffers); +GLAPI void APIENTRY glNamedFramebufferRenderbuffer (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glNamedFramebufferParameteri (GLuint framebuffer, GLenum pname, GLint param); +GLAPI void APIENTRY glNamedFramebufferTexture (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTextureLayer (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glNamedFramebufferDrawBuffer (GLuint framebuffer, GLenum buf); +GLAPI void APIENTRY glNamedFramebufferDrawBuffers (GLuint framebuffer, GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glNamedFramebufferReadBuffer (GLuint framebuffer, GLenum src); +GLAPI void APIENTRY glInvalidateNamedFramebufferData (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments); +GLAPI void APIENTRY glInvalidateNamedFramebufferSubData (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glClearNamedFramebufferiv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value); +GLAPI void APIENTRY glClearNamedFramebufferuiv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint *value); +GLAPI void APIENTRY glClearNamedFramebufferfv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value); +GLAPI void APIENTRY glClearNamedFramebufferfi (GLuint framebuffer, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GLAPI void APIENTRY glBlitNamedFramebuffer (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI GLenum APIENTRY glCheckNamedFramebufferStatus (GLuint framebuffer, GLenum target); +GLAPI void APIENTRY glGetNamedFramebufferParameteriv (GLuint framebuffer, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameteriv (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glCreateRenderbuffers (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glNamedRenderbufferStorage (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisample (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetNamedRenderbufferParameteriv (GLuint renderbuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glCreateTextures (GLenum target, GLsizei n, GLuint *textures); +GLAPI void APIENTRY glTextureBuffer (GLuint texture, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glTextureBufferRange (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTextureStorage1D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTextureStorage2D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureStorage3D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glTextureStorage2DMultisample (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage3DMultisample (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCompressedTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCopyTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glCopyTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureParameterf (GLuint texture, GLenum pname, GLfloat param); +GLAPI void APIENTRY glTextureParameterfv (GLuint texture, GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glTextureParameteri (GLuint texture, GLenum pname, GLint param); +GLAPI void APIENTRY glTextureParameterIiv (GLuint texture, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureParameterIuiv (GLuint texture, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glTextureParameteriv (GLuint texture, GLenum pname, const GLint *param); +GLAPI void APIENTRY glGenerateTextureMipmap (GLuint texture); +GLAPI void APIENTRY glBindTextureUnit (GLuint unit, GLuint texture); +GLAPI void APIENTRY glGetTextureImage (GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetCompressedTextureImage (GLuint texture, GLint level, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetTextureLevelParameterfv (GLuint texture, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureLevelParameteriv (GLuint texture, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureParameterfv (GLuint texture, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureParameterIiv (GLuint texture, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureParameterIuiv (GLuint texture, GLenum pname, GLuint *params); +GLAPI void APIENTRY glGetTextureParameteriv (GLuint texture, GLenum pname, GLint *params); +GLAPI void APIENTRY glCreateVertexArrays (GLsizei n, GLuint *arrays); +GLAPI void APIENTRY glDisableVertexArrayAttrib (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glEnableVertexArrayAttrib (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glVertexArrayElementBuffer (GLuint vaobj, GLuint buffer); +GLAPI void APIENTRY glVertexArrayVertexBuffer (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexArrayVertexBuffers (GLuint vaobj, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +GLAPI void APIENTRY glVertexArrayAttribBinding (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexArrayAttribFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayAttribIFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayAttribLFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayBindingDivisor (GLuint vaobj, GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glGetVertexArrayiv (GLuint vaobj, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayIndexediv (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayIndexed64iv (GLuint vaobj, GLuint index, GLenum pname, GLint64 *param); +GLAPI void APIENTRY glCreateSamplers (GLsizei n, GLuint *samplers); +GLAPI void APIENTRY glCreateProgramPipelines (GLsizei n, GLuint *pipelines); +GLAPI void APIENTRY glCreateQueries (GLenum target, GLsizei n, GLuint *ids); +GLAPI void APIENTRY glGetQueryBufferObjecti64v (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +GLAPI void APIENTRY glGetQueryBufferObjectiv (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +GLAPI void APIENTRY glGetQueryBufferObjectui64v (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +GLAPI void APIENTRY glGetQueryBufferObjectuiv (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +GLAPI void APIENTRY glMemoryBarrierByRegion (GLbitfield barriers); +GLAPI void APIENTRY glGetTextureSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetCompressedTextureSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void *pixels); +GLAPI GLenum APIENTRY glGetGraphicsResetStatus (void); +GLAPI void APIENTRY glGetnCompressedTexImage (GLenum target, GLint lod, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetnTexImage (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetnUniformdv (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +GLAPI void APIENTRY glGetnUniformfv (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GLAPI void APIENTRY glGetnUniformiv (GLuint program, GLint location, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetnUniformuiv (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +GLAPI void APIENTRY glReadnPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +GLAPI void APIENTRY glTextureBarrier (void); +#endif +#endif /* GL_VERSION_4_5 */ + +#ifndef GL_VERSION_4_6 +#define GL_VERSION_4_6 1 +#define GL_SHADER_BINARY_FORMAT_SPIR_V 0x9551 +#define GL_SPIR_V_BINARY 0x9552 +#define GL_PARAMETER_BUFFER 0x80EE +#define GL_PARAMETER_BUFFER_BINDING 0x80EF +#define GL_CONTEXT_FLAG_NO_ERROR_BIT 0x00000008 +#define GL_VERTICES_SUBMITTED 0x82EE +#define GL_PRIMITIVES_SUBMITTED 0x82EF +#define GL_VERTEX_SHADER_INVOCATIONS 0x82F0 +#define GL_TESS_CONTROL_SHADER_PATCHES 0x82F1 +#define GL_TESS_EVALUATION_SHADER_INVOCATIONS 0x82F2 +#define GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED 0x82F3 +#define GL_FRAGMENT_SHADER_INVOCATIONS 0x82F4 +#define GL_COMPUTE_SHADER_INVOCATIONS 0x82F5 +#define GL_CLIPPING_INPUT_PRIMITIVES 0x82F6 +#define GL_CLIPPING_OUTPUT_PRIMITIVES 0x82F7 +#define GL_POLYGON_OFFSET_CLAMP 0x8E1B +#define GL_SPIR_V_EXTENSIONS 0x9553 +#define GL_NUM_SPIR_V_EXTENSIONS 0x9554 +#define GL_TEXTURE_MAX_ANISOTROPY 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY 0x84FF +#define GL_TRANSFORM_FEEDBACK_OVERFLOW 0x82EC +#define GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW 0x82ED +typedef void (APIENTRYP PFNGLSPECIALIZESHADERPROC) (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTPROC) (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTPROC) (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLPOLYGONOFFSETCLAMPPROC) (GLfloat factor, GLfloat units, GLfloat clamp); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpecializeShader (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +GLAPI void APIENTRY glMultiDrawArraysIndirectCount (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectCount (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glPolygonOffsetClamp (GLfloat factor, GLfloat units, GLfloat clamp); +#endif +#endif /* GL_VERSION_4_6 */ + #ifndef GL_ARB_ES2_compatibility #define GL_ARB_ES2_compatibility 1 #endif /* GL_ARB_ES2_compatibility */ +#ifndef GL_ARB_ES3_1_compatibility +#define GL_ARB_ES3_1_compatibility 1 +#endif /* GL_ARB_ES3_1_compatibility */ + +#ifndef GL_ARB_ES3_2_compatibility +#define GL_ARB_ES3_2_compatibility 1 +#define GL_PRIMITIVE_BOUNDING_BOX_ARB 0x92BE +#define GL_MULTISAMPLE_LINE_WIDTH_RANGE_ARB 0x9381 +#define GL_MULTISAMPLE_LINE_WIDTH_GRANULARITY_ARB 0x9382 +typedef void (APIENTRYP PFNGLPRIMITIVEBOUNDINGBOXARBPROC) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveBoundingBoxARB (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#endif +#endif /* GL_ARB_ES3_2_compatibility */ + #ifndef GL_ARB_ES3_compatibility #define GL_ARB_ES3_compatibility 1 #endif /* GL_ARB_ES3_compatibility */ @@ -2641,7 +2927,7 @@ GLAPI void APIENTRY glBindVertexBuffers (GLuint first, GLsizei count, const GLui #ifndef GL_ARB_bindless_texture #define GL_ARB_bindless_texture 1 -typedef uint64_t GLuint64EXT; +typedef khronos_uint64_t GLuint64EXT; #define GL_UNSIGNED_INT64_ARB 0x140F typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLEARBPROC) (GLuint texture); typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLEARBPROC) (GLuint texture, GLuint sampler); @@ -2707,13 +2993,16 @@ GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context *context, s #define GL_ARB_clear_texture 1 #endif /* GL_ARB_clear_texture */ +#ifndef GL_ARB_clip_control +#define GL_ARB_clip_control 1 +#endif /* GL_ARB_clip_control */ + #ifndef GL_ARB_compressed_texture_pixel_storage #define GL_ARB_compressed_texture_pixel_storage 1 #endif /* GL_ARB_compressed_texture_pixel_storage */ #ifndef GL_ARB_compute_shader #define GL_ARB_compute_shader 1 -#define GL_COMPUTE_SHADER_BIT 0x00000020 #endif /* GL_ARB_compute_shader */ #ifndef GL_ARB_compute_variable_group_size @@ -2728,20 +3017,26 @@ GLAPI void APIENTRY glDispatchComputeGroupSizeARB (GLuint num_groups_x, GLuint n #endif #endif /* GL_ARB_compute_variable_group_size */ +#ifndef GL_ARB_conditional_render_inverted +#define GL_ARB_conditional_render_inverted 1 +#endif /* GL_ARB_conditional_render_inverted */ + #ifndef GL_ARB_conservative_depth #define GL_ARB_conservative_depth 1 #endif /* GL_ARB_conservative_depth */ #ifndef GL_ARB_copy_buffer #define GL_ARB_copy_buffer 1 -#define GL_COPY_READ_BUFFER_BINDING 0x8F36 -#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 #endif /* GL_ARB_copy_buffer */ #ifndef GL_ARB_copy_image #define GL_ARB_copy_image 1 #endif /* GL_ARB_copy_image */ +#ifndef GL_ARB_cull_distance +#define GL_ARB_cull_distance 1 +#endif /* GL_ARB_cull_distance */ + #ifndef GL_ARB_debug_output #define GL_ARB_debug_output 1 typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); @@ -2787,6 +3082,14 @@ GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufSize, GL #define GL_ARB_depth_clamp 1 #endif /* GL_ARB_depth_clamp */ +#ifndef GL_ARB_derivative_control +#define GL_ARB_derivative_control 1 +#endif /* GL_ARB_derivative_control */ + +#ifndef GL_ARB_direct_state_access +#define GL_ARB_direct_state_access 1 +#endif /* GL_ARB_direct_state_access */ + #ifndef GL_ARB_draw_buffers_blend #define GL_ARB_draw_buffers_blend 1 typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); @@ -2809,6 +3112,16 @@ GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum d #define GL_ARB_draw_indirect 1 #endif /* GL_ARB_draw_indirect */ +#ifndef GL_ARB_draw_instanced +#define GL_ARB_draw_instanced 1 +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#endif +#endif /* GL_ARB_draw_instanced */ + #ifndef GL_ARB_enhanced_layouts #define GL_ARB_enhanced_layouts 1 #endif /* GL_ARB_enhanced_layouts */ @@ -2829,6 +3142,10 @@ GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum d #define GL_ARB_fragment_layer_viewport 1 #endif /* GL_ARB_fragment_layer_viewport */ +#ifndef GL_ARB_fragment_shader_interlock +#define GL_ARB_fragment_shader_interlock 1 +#endif /* GL_ARB_fragment_shader_interlock */ + #ifndef GL_ARB_framebuffer_no_attachments #define GL_ARB_framebuffer_no_attachments 1 #endif /* GL_ARB_framebuffer_no_attachments */ @@ -2841,10 +3158,56 @@ GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum d #define GL_ARB_framebuffer_sRGB 1 #endif /* GL_ARB_framebuffer_sRGB */ +#ifndef GL_ARB_geometry_shader4 +#define GL_ARB_geometry_shader4 1 +#define GL_LINES_ADJACENCY_ARB 0x000A +#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B +#define GL_TRIANGLES_ADJACENCY_ARB 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D +#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 +#define GL_GEOMETRY_SHADER_ARB 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif +#endif /* GL_ARB_geometry_shader4 */ + #ifndef GL_ARB_get_program_binary #define GL_ARB_get_program_binary 1 #endif /* GL_ARB_get_program_binary */ +#ifndef GL_ARB_get_texture_sub_image +#define GL_ARB_get_texture_sub_image 1 +#endif /* GL_ARB_get_texture_sub_image */ + +#ifndef GL_ARB_gl_spirv +#define GL_ARB_gl_spirv 1 +#define GL_SHADER_BINARY_FORMAT_SPIR_V_ARB 0x9551 +#define GL_SPIR_V_BINARY_ARB 0x9552 +typedef void (APIENTRYP PFNGLSPECIALIZESHADERARBPROC) (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpecializeShaderARB (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +#endif +#endif /* GL_ARB_gl_spirv */ + #ifndef GL_ARB_gpu_shader5 #define GL_ARB_gpu_shader5 1 #endif /* GL_ARB_gpu_shader5 */ @@ -2853,28 +3216,120 @@ GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum d #define GL_ARB_gpu_shader_fp64 1 #endif /* GL_ARB_gpu_shader_fp64 */ +#ifndef GL_ARB_gpu_shader_int64 +#define GL_ARB_gpu_shader_int64 1 +#define GL_INT64_ARB 0x140E +#define GL_INT64_VEC2_ARB 0x8FE9 +#define GL_INT64_VEC3_ARB 0x8FEA +#define GL_INT64_VEC4_ARB 0x8FEB +#define GL_UNSIGNED_INT64_VEC2_ARB 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_ARB 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_ARB 0x8FF7 +typedef void (APIENTRYP PFNGLUNIFORM1I64ARBPROC) (GLint location, GLint64 x); +typedef void (APIENTRYP PFNGLUNIFORM2I64ARBPROC) (GLint location, GLint64 x, GLint64 y); +typedef void (APIENTRYP PFNGLUNIFORM3I64ARBPROC) (GLint location, GLint64 x, GLint64 y, GLint64 z); +typedef void (APIENTRYP PFNGLUNIFORM4I64ARBPROC) (GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +typedef void (APIENTRYP PFNGLUNIFORM1I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM2I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM3I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM4I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM1UI64ARBPROC) (GLint location, GLuint64 x); +typedef void (APIENTRYP PFNGLUNIFORM2UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y); +typedef void (APIENTRYP PFNGLUNIFORM3UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +typedef void (APIENTRYP PFNGLUNIFORM4UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +typedef void (APIENTRYP PFNGLUNIFORM1UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM2UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM3UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM4UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLGETUNIFORMI64VARBPROC) (GLuint program, GLint location, GLint64 *params); +typedef void (APIENTRYP PFNGLGETUNIFORMUI64VARBPROC) (GLuint program, GLint location, GLuint64 *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMI64VARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint64 *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUI64VARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint64 *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64ARBPROC) (GLuint program, GLint location, GLint64 x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64ARBPROC) (GLuint program, GLint location, GLuint64 x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniform1i64ARB (GLint location, GLint64 x); +GLAPI void APIENTRY glUniform2i64ARB (GLint location, GLint64 x, GLint64 y); +GLAPI void APIENTRY glUniform3i64ARB (GLint location, GLint64 x, GLint64 y, GLint64 z); +GLAPI void APIENTRY glUniform4i64ARB (GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +GLAPI void APIENTRY glUniform1i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform2i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform3i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform4i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform1ui64ARB (GLint location, GLuint64 x); +GLAPI void APIENTRY glUniform2ui64ARB (GLint location, GLuint64 x, GLuint64 y); +GLAPI void APIENTRY glUniform3ui64ARB (GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +GLAPI void APIENTRY glUniform4ui64ARB (GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +GLAPI void APIENTRY glUniform1ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glUniform2ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glUniform3ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glUniform4ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glGetUniformi64vARB (GLuint program, GLint location, GLint64 *params); +GLAPI void APIENTRY glGetUniformui64vARB (GLuint program, GLint location, GLuint64 *params); +GLAPI void APIENTRY glGetnUniformi64vARB (GLuint program, GLint location, GLsizei bufSize, GLint64 *params); +GLAPI void APIENTRY glGetnUniformui64vARB (GLuint program, GLint location, GLsizei bufSize, GLuint64 *params); +GLAPI void APIENTRY glProgramUniform1i64ARB (GLuint program, GLint location, GLint64 x); +GLAPI void APIENTRY glProgramUniform2i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y); +GLAPI void APIENTRY glProgramUniform3i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z); +GLAPI void APIENTRY glProgramUniform4i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +GLAPI void APIENTRY glProgramUniform1i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform2i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform3i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform4i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform1ui64ARB (GLuint program, GLint location, GLuint64 x); +GLAPI void APIENTRY glProgramUniform2ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y); +GLAPI void APIENTRY glProgramUniform3ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +GLAPI void APIENTRY glProgramUniform4ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +GLAPI void APIENTRY glProgramUniform1ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniform2ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniform3ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniform4ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +#endif +#endif /* GL_ARB_gpu_shader_int64 */ + #ifndef GL_ARB_half_float_vertex #define GL_ARB_half_float_vertex 1 #endif /* GL_ARB_half_float_vertex */ #ifndef GL_ARB_imaging #define GL_ARB_imaging 1 -#define GL_BLEND_COLOR 0x8005 -#define GL_BLEND_EQUATION 0x8009 #endif /* GL_ARB_imaging */ #ifndef GL_ARB_indirect_parameters #define GL_ARB_indirect_parameters 1 #define GL_PARAMETER_BUFFER_ARB 0x80EE #define GL_PARAMETER_BUFFER_BINDING_ARB 0x80EF -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC) (GLenum mode, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC) (GLenum mode, GLenum type, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC) (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC) (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysIndirectCountARB (GLenum mode, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); -GLAPI void APIENTRY glMultiDrawElementsIndirectCountARB (GLenum mode, GLenum type, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawArraysIndirectCountARB (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectCountARB (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); #endif #endif /* GL_ARB_indirect_parameters */ +#ifndef GL_ARB_instanced_arrays +#define GL_ARB_instanced_arrays 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor); +#endif +#endif /* GL_ARB_instanced_arrays */ + #ifndef GL_ARB_internalformat_query #define GL_ARB_internalformat_query 1 #endif /* GL_ARB_internalformat_query */ @@ -2882,6 +3337,25 @@ GLAPI void APIENTRY glMultiDrawElementsIndirectCountARB (GLenum mode, GLenum typ #ifndef GL_ARB_internalformat_query2 #define GL_ARB_internalformat_query2 1 #define GL_SRGB_DECODE_ARB 0x8299 +#define GL_VIEW_CLASS_EAC_R11 0x9383 +#define GL_VIEW_CLASS_EAC_RG11 0x9384 +#define GL_VIEW_CLASS_ETC2_RGB 0x9385 +#define GL_VIEW_CLASS_ETC2_RGBA 0x9386 +#define GL_VIEW_CLASS_ETC2_EAC_RGBA 0x9387 +#define GL_VIEW_CLASS_ASTC_4x4_RGBA 0x9388 +#define GL_VIEW_CLASS_ASTC_5x4_RGBA 0x9389 +#define GL_VIEW_CLASS_ASTC_5x5_RGBA 0x938A +#define GL_VIEW_CLASS_ASTC_6x5_RGBA 0x938B +#define GL_VIEW_CLASS_ASTC_6x6_RGBA 0x938C +#define GL_VIEW_CLASS_ASTC_8x5_RGBA 0x938D +#define GL_VIEW_CLASS_ASTC_8x6_RGBA 0x938E +#define GL_VIEW_CLASS_ASTC_8x8_RGBA 0x938F +#define GL_VIEW_CLASS_ASTC_10x5_RGBA 0x9390 +#define GL_VIEW_CLASS_ASTC_10x6_RGBA 0x9391 +#define GL_VIEW_CLASS_ASTC_10x8_RGBA 0x9392 +#define GL_VIEW_CLASS_ASTC_10x10_RGBA 0x9393 +#define GL_VIEW_CLASS_ASTC_12x10_RGBA 0x9394 +#define GL_VIEW_CLASS_ASTC_12x12_RGBA 0x9395 #endif /* GL_ARB_internalformat_query2 */ #ifndef GL_ARB_invalidate_subdata @@ -2908,6 +3382,46 @@ GLAPI void APIENTRY glMultiDrawElementsIndirectCountARB (GLenum mode, GLenum typ #define GL_ARB_occlusion_query2 1 #endif /* GL_ARB_occlusion_query2 */ +#ifndef GL_ARB_parallel_shader_compile +#define GL_ARB_parallel_shader_compile 1 +#define GL_MAX_SHADER_COMPILER_THREADS_ARB 0x91B0 +#define GL_COMPLETION_STATUS_ARB 0x91B1 +typedef void (APIENTRYP PFNGLMAXSHADERCOMPILERTHREADSARBPROC) (GLuint count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMaxShaderCompilerThreadsARB (GLuint count); +#endif +#endif /* GL_ARB_parallel_shader_compile */ + +#ifndef GL_ARB_pipeline_statistics_query +#define GL_ARB_pipeline_statistics_query 1 +#define GL_VERTICES_SUBMITTED_ARB 0x82EE +#define GL_PRIMITIVES_SUBMITTED_ARB 0x82EF +#define GL_VERTEX_SHADER_INVOCATIONS_ARB 0x82F0 +#define GL_TESS_CONTROL_SHADER_PATCHES_ARB 0x82F1 +#define GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB 0x82F2 +#define GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB 0x82F3 +#define GL_FRAGMENT_SHADER_INVOCATIONS_ARB 0x82F4 +#define GL_COMPUTE_SHADER_INVOCATIONS_ARB 0x82F5 +#define GL_CLIPPING_INPUT_PRIMITIVES_ARB 0x82F6 +#define GL_CLIPPING_OUTPUT_PRIMITIVES_ARB 0x82F7 +#endif /* GL_ARB_pipeline_statistics_query */ + +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 +#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF +#endif /* GL_ARB_pixel_buffer_object */ + +#ifndef GL_ARB_polygon_offset_clamp +#define GL_ARB_polygon_offset_clamp 1 +#endif /* GL_ARB_polygon_offset_clamp */ + +#ifndef GL_ARB_post_depth_coverage +#define GL_ARB_post_depth_coverage 1 +#endif /* GL_ARB_post_depth_coverage */ + #ifndef GL_ARB_program_interface_query #define GL_ARB_program_interface_query 1 #endif /* GL_ARB_program_interface_query */ @@ -2957,6 +3471,26 @@ GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei #define GL_ARB_robustness_isolation 1 #endif /* GL_ARB_robustness_isolation */ +#ifndef GL_ARB_sample_locations +#define GL_ARB_sample_locations 1 +#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_ARB 0x933D +#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB 0x933E +#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB 0x933F +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_ARB 0x9340 +#define GL_SAMPLE_LOCATION_ARB 0x8E50 +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_ARB 0x9341 +#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_ARB 0x9342 +#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_ARB 0x9343 +typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLEVALUATEDEPTHVALUESARBPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferSampleLocationsfvARB (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glNamedFramebufferSampleLocationsfvARB (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glEvaluateDepthValuesARB (void); +#endif +#endif /* GL_ARB_sample_locations */ + #ifndef GL_ARB_sample_shading #define GL_ARB_sample_shading 1 #define GL_SAMPLE_SHADING_ARB 0x8C36 @@ -2983,14 +3517,26 @@ GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value); #define GL_ARB_separate_shader_objects 1 #endif /* GL_ARB_separate_shader_objects */ +#ifndef GL_ARB_shader_atomic_counter_ops +#define GL_ARB_shader_atomic_counter_ops 1 +#endif /* GL_ARB_shader_atomic_counter_ops */ + #ifndef GL_ARB_shader_atomic_counters #define GL_ARB_shader_atomic_counters 1 #endif /* GL_ARB_shader_atomic_counters */ +#ifndef GL_ARB_shader_ballot +#define GL_ARB_shader_ballot 1 +#endif /* GL_ARB_shader_ballot */ + #ifndef GL_ARB_shader_bit_encoding #define GL_ARB_shader_bit_encoding 1 #endif /* GL_ARB_shader_bit_encoding */ +#ifndef GL_ARB_shader_clock +#define GL_ARB_shader_clock 1 +#endif /* GL_ARB_shader_clock */ + #ifndef GL_ARB_shader_draw_parameters #define GL_ARB_shader_draw_parameters 1 #endif /* GL_ARB_shader_draw_parameters */ @@ -3023,6 +3569,14 @@ GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value); #define GL_ARB_shader_subroutine 1 #endif /* GL_ARB_shader_subroutine */ +#ifndef GL_ARB_shader_texture_image_samples +#define GL_ARB_shader_texture_image_samples 1 +#endif /* GL_ARB_shader_texture_image_samples */ + +#ifndef GL_ARB_shader_viewport_layer_array +#define GL_ARB_shader_viewport_layer_array 1 +#endif /* GL_ARB_shader_viewport_layer_array */ + #ifndef GL_ARB_shading_language_420pack #define GL_ARB_shading_language_420pack 1 #endif /* GL_ARB_shading_language_420pack */ @@ -3052,11 +3606,25 @@ GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GL #define GL_ARB_shading_language_packing 1 #endif /* GL_ARB_shading_language_packing */ +#ifndef GL_ARB_sparse_buffer +#define GL_ARB_sparse_buffer 1 +#define GL_SPARSE_STORAGE_BIT_ARB 0x0400 +#define GL_SPARSE_BUFFER_PAGE_SIZE_ARB 0x82F8 +typedef void (APIENTRYP PFNGLBUFFERPAGECOMMITMENTARBPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLboolean commit); +typedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); +typedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTARBPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferPageCommitmentARB (GLenum target, GLintptr offset, GLsizeiptr size, GLboolean commit); +GLAPI void APIENTRY glNamedBufferPageCommitmentEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); +GLAPI void APIENTRY glNamedBufferPageCommitmentARB (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); +#endif +#endif /* GL_ARB_sparse_buffer */ + #ifndef GL_ARB_sparse_texture #define GL_ARB_sparse_texture 1 #define GL_TEXTURE_SPARSE_ARB 0x91A6 #define GL_VIRTUAL_PAGE_SIZE_INDEX_ARB 0x91A7 -#define GL_MIN_SPARSE_LEVEL_ARB 0x919B +#define GL_NUM_SPARSE_LEVELS_ARB 0x91AA #define GL_NUM_VIRTUAL_PAGE_SIZES_ARB 0x91A8 #define GL_VIRTUAL_PAGE_SIZE_X_ARB 0x9195 #define GL_VIRTUAL_PAGE_SIZE_Y_ARB 0x9196 @@ -3065,12 +3633,24 @@ GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GL #define GL_MAX_SPARSE_3D_TEXTURE_SIZE_ARB 0x9199 #define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_ARB 0x919A #define GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB 0x91A9 -typedef void (APIENTRYP PFNGLTEXPAGECOMMITMENTARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident); +typedef void (APIENTRYP PFNGLTEXPAGECOMMITMENTARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexPageCommitmentARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident); +GLAPI void APIENTRY glTexPageCommitmentARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); #endif #endif /* GL_ARB_sparse_texture */ +#ifndef GL_ARB_sparse_texture2 +#define GL_ARB_sparse_texture2 1 +#endif /* GL_ARB_sparse_texture2 */ + +#ifndef GL_ARB_sparse_texture_clamp +#define GL_ARB_sparse_texture_clamp 1 +#endif /* GL_ARB_sparse_texture_clamp */ + +#ifndef GL_ARB_spirv_extensions +#define GL_ARB_spirv_extensions 1 +#endif /* GL_ARB_spirv_extensions */ + #ifndef GL_ARB_stencil_texturing #define GL_ARB_stencil_texturing 1 #endif /* GL_ARB_stencil_texturing */ @@ -3083,6 +3663,28 @@ GLAPI void APIENTRY glTexPageCommitmentARB (GLenum target, GLint level, GLint xo #define GL_ARB_tessellation_shader 1 #endif /* GL_ARB_tessellation_shader */ +#ifndef GL_ARB_texture_barrier +#define GL_ARB_texture_barrier 1 +#endif /* GL_ARB_texture_barrier */ + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 +#define GL_CLAMP_TO_BORDER_ARB 0x812D +#endif /* GL_ARB_texture_border_clamp */ + +#ifndef GL_ARB_texture_buffer_object +#define GL_ARB_texture_buffer_object 1 +#define GL_TEXTURE_BUFFER_ARB 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E +typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer); +#endif +#endif /* GL_ARB_texture_buffer_object */ + #ifndef GL_ARB_texture_buffer_object_rgb32 #define GL_ARB_texture_buffer_object_rgb32 1 #endif /* GL_ARB_texture_buffer_object_rgb32 */ @@ -3114,6 +3716,16 @@ GLAPI void APIENTRY glTexPageCommitmentARB (GLenum target, GLint level, GLint xo #define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F #endif /* GL_ARB_texture_cube_map_array */ +#ifndef GL_ARB_texture_filter_anisotropic +#define GL_ARB_texture_filter_anisotropic 1 +#endif /* GL_ARB_texture_filter_anisotropic */ + +#ifndef GL_ARB_texture_filter_minmax +#define GL_ARB_texture_filter_minmax 1 +#define GL_TEXTURE_REDUCTION_MODE_ARB 0x9366 +#define GL_WEIGHTED_AVERAGE_ARB 0x9367 +#endif /* GL_ARB_texture_filter_minmax */ + #ifndef GL_ARB_texture_gather #define GL_ARB_texture_gather 1 #define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E @@ -3125,10 +3737,19 @@ GLAPI void APIENTRY glTexPageCommitmentARB (GLenum target, GLint level, GLint xo #define GL_ARB_texture_mirror_clamp_to_edge 1 #endif /* GL_ARB_texture_mirror_clamp_to_edge */ +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 +#define GL_MIRRORED_REPEAT_ARB 0x8370 +#endif /* GL_ARB_texture_mirrored_repeat */ + #ifndef GL_ARB_texture_multisample #define GL_ARB_texture_multisample 1 #endif /* GL_ARB_texture_multisample */ +#ifndef GL_ARB_texture_non_power_of_two +#define GL_ARB_texture_non_power_of_two 1 +#endif /* GL_ARB_texture_non_power_of_two */ + #ifndef GL_ARB_texture_query_levels #define GL_ARB_texture_query_levels 1 #endif /* GL_ARB_texture_query_levels */ @@ -3171,8 +3792,6 @@ GLAPI void APIENTRY glTexPageCommitmentARB (GLenum target, GLint level, GLint xo #ifndef GL_ARB_transform_feedback2 #define GL_ARB_transform_feedback2 1 -#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 -#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 #endif /* GL_ARB_transform_feedback2 */ #ifndef GL_ARB_transform_feedback3 @@ -3183,11 +3802,14 @@ GLAPI void APIENTRY glTexPageCommitmentARB (GLenum target, GLint level, GLint xo #define GL_ARB_transform_feedback_instanced 1 #endif /* GL_ARB_transform_feedback_instanced */ +#ifndef GL_ARB_transform_feedback_overflow_query +#define GL_ARB_transform_feedback_overflow_query 1 +#define GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB 0x82EC +#define GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB 0x82ED +#endif /* GL_ARB_transform_feedback_overflow_query */ + #ifndef GL_ARB_uniform_buffer_object #define GL_ARB_uniform_buffer_object 1 -#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C -#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 #endif /* GL_ARB_uniform_buffer_object */ #ifndef GL_ARB_vertex_array_bgra @@ -3216,12 +3838,90 @@ GLAPI void APIENTRY glTexPageCommitmentARB (GLenum target, GLint level, GLint xo #ifndef GL_ARB_viewport_array #define GL_ARB_viewport_array 1 +typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYDVNVPROC) (GLuint first, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDDNVPROC) (GLuint index, GLdouble n, GLdouble f); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthRangeArraydvNV (GLuint first, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glDepthRangeIndexeddNV (GLuint index, GLdouble n, GLdouble f); +#endif #endif /* GL_ARB_viewport_array */ +#ifndef GL_KHR_blend_equation_advanced +#define GL_KHR_blend_equation_advanced 1 +#define GL_MULTIPLY_KHR 0x9294 +#define GL_SCREEN_KHR 0x9295 +#define GL_OVERLAY_KHR 0x9296 +#define GL_DARKEN_KHR 0x9297 +#define GL_LIGHTEN_KHR 0x9298 +#define GL_COLORDODGE_KHR 0x9299 +#define GL_COLORBURN_KHR 0x929A +#define GL_HARDLIGHT_KHR 0x929B +#define GL_SOFTLIGHT_KHR 0x929C +#define GL_DIFFERENCE_KHR 0x929E +#define GL_EXCLUSION_KHR 0x92A0 +#define GL_HSL_HUE_KHR 0x92AD +#define GL_HSL_SATURATION_KHR 0x92AE +#define GL_HSL_COLOR_KHR 0x92AF +#define GL_HSL_LUMINOSITY_KHR 0x92B0 +typedef void (APIENTRYP PFNGLBLENDBARRIERKHRPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendBarrierKHR (void); +#endif +#endif /* GL_KHR_blend_equation_advanced */ + +#ifndef GL_KHR_blend_equation_advanced_coherent +#define GL_KHR_blend_equation_advanced_coherent 1 +#define GL_BLEND_ADVANCED_COHERENT_KHR 0x9285 +#endif /* GL_KHR_blend_equation_advanced_coherent */ + +#ifndef GL_KHR_context_flush_control +#define GL_KHR_context_flush_control 1 +#endif /* GL_KHR_context_flush_control */ + #ifndef GL_KHR_debug #define GL_KHR_debug 1 #endif /* GL_KHR_debug */ +#ifndef GL_KHR_no_error +#define GL_KHR_no_error 1 +#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 +#endif /* GL_KHR_no_error */ + +#ifndef GL_KHR_parallel_shader_compile +#define GL_KHR_parallel_shader_compile 1 +#define GL_MAX_SHADER_COMPILER_THREADS_KHR 0x91B0 +#define GL_COMPLETION_STATUS_KHR 0x91B1 +typedef void (APIENTRYP PFNGLMAXSHADERCOMPILERTHREADSKHRPROC) (GLuint count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMaxShaderCompilerThreadsKHR (GLuint count); +#endif +#endif /* GL_KHR_parallel_shader_compile */ + +#ifndef GL_KHR_robust_buffer_access_behavior +#define GL_KHR_robust_buffer_access_behavior 1 +#endif /* GL_KHR_robust_buffer_access_behavior */ + +#ifndef GL_KHR_robustness +#define GL_KHR_robustness 1 +#define GL_CONTEXT_ROBUST_ACCESS 0x90F3 +#endif /* GL_KHR_robustness */ + +#ifndef GL_KHR_shader_subgroup +#define GL_KHR_shader_subgroup 1 +#define GL_SUBGROUP_SIZE_KHR 0x9532 +#define GL_SUBGROUP_SUPPORTED_STAGES_KHR 0x9533 +#define GL_SUBGROUP_SUPPORTED_FEATURES_KHR 0x9534 +#define GL_SUBGROUP_QUAD_ALL_STAGES_KHR 0x9535 +#define GL_SUBGROUP_FEATURE_BASIC_BIT_KHR 0x00000001 +#define GL_SUBGROUP_FEATURE_VOTE_BIT_KHR 0x00000002 +#define GL_SUBGROUP_FEATURE_ARITHMETIC_BIT_KHR 0x00000004 +#define GL_SUBGROUP_FEATURE_BALLOT_BIT_KHR 0x00000008 +#define GL_SUBGROUP_FEATURE_SHUFFLE_BIT_KHR 0x00000010 +#define GL_SUBGROUP_FEATURE_SHUFFLE_RELATIVE_BIT_KHR 0x00000020 +#define GL_SUBGROUP_FEATURE_CLUSTERED_BIT_KHR 0x00000040 +#define GL_SUBGROUP_FEATURE_QUAD_BIT_KHR 0x00000080 +#endif /* GL_KHR_shader_subgroup */ + #ifndef GL_KHR_texture_compression_astc_hdr #define GL_KHR_texture_compression_astc_hdr 1 #define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 @@ -3258,6 +3958,1981 @@ GLAPI void APIENTRY glTexPageCommitmentARB (GLenum target, GLint level, GLint xo #define GL_KHR_texture_compression_astc_ldr 1 #endif /* GL_KHR_texture_compression_astc_ldr */ +#ifndef GL_KHR_texture_compression_astc_sliced_3d +#define GL_KHR_texture_compression_astc_sliced_3d 1 +#endif /* GL_KHR_texture_compression_astc_sliced_3d */ + +#ifndef GL_AMD_framebuffer_multisample_advanced +#define GL_AMD_framebuffer_multisample_advanced 1 +#define GL_RENDERBUFFER_STORAGE_SAMPLES_AMD 0x91B2 +#define GL_MAX_COLOR_FRAMEBUFFER_SAMPLES_AMD 0x91B3 +#define GL_MAX_COLOR_FRAMEBUFFER_STORAGE_SAMPLES_AMD 0x91B4 +#define GL_MAX_DEPTH_STENCIL_FRAMEBUFFER_SAMPLES_AMD 0x91B5 +#define GL_NUM_SUPPORTED_MULTISAMPLE_MODES_AMD 0x91B6 +#define GL_SUPPORTED_MULTISAMPLE_MODES_AMD 0x91B7 +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEADVANCEDAMDPROC) (GLenum target, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEADVANCEDAMDPROC) (GLuint renderbuffer, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleAdvancedAMD (GLenum target, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleAdvancedAMD (GLuint renderbuffer, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_AMD_framebuffer_multisample_advanced */ + +#ifndef GL_AMD_performance_monitor +#define GL_AMD_performance_monitor 1 +#define GL_COUNTER_TYPE_AMD 0x8BC0 +#define GL_COUNTER_RANGE_AMD 0x8BC1 +#define GL_UNSIGNED_INT64_AMD 0x8BC2 +#define GL_PERCENTAGE_AMD 0x8BC3 +#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 +#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 +#define GL_PERFMON_RESULT_AMD 0x8BC6 +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void *data); +typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, void *data); +GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#endif +#endif /* GL_AMD_performance_monitor */ + +#ifndef GL_APPLE_rgb_422 +#define GL_APPLE_rgb_422 1 +#define GL_RGB_422_APPLE 0x8A1F +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#define GL_RGB_RAW_422_APPLE 0x8A51 +#endif /* GL_APPLE_rgb_422 */ + +#ifndef GL_EXT_EGL_image_storage +#define GL_EXT_EGL_image_storage 1 +typedef void *GLeglImageOES; +typedef void (APIENTRYP PFNGLEGLIMAGETARGETTEXSTORAGEEXTPROC) (GLenum target, GLeglImageOES image, const GLint* attrib_list); +typedef void (APIENTRYP PFNGLEGLIMAGETARGETTEXTURESTORAGEEXTPROC) (GLuint texture, GLeglImageOES image, const GLint* attrib_list); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glEGLImageTargetTexStorageEXT (GLenum target, GLeglImageOES image, const GLint* attrib_list); +GLAPI void APIENTRY glEGLImageTargetTextureStorageEXT (GLuint texture, GLeglImageOES image, const GLint* attrib_list); +#endif +#endif /* GL_EXT_EGL_image_storage */ + +#ifndef GL_EXT_EGL_sync +#define GL_EXT_EGL_sync 1 +#endif /* GL_EXT_EGL_sync */ + +#ifndef GL_EXT_debug_label +#define GL_EXT_debug_label 1 +#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F +#define GL_PROGRAM_OBJECT_EXT 0x8B40 +#define GL_SHADER_OBJECT_EXT 0x8B48 +#define GL_BUFFER_OBJECT_EXT 0x9151 +#define GL_QUERY_OBJECT_EXT 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154 +typedef void (APIENTRYP PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLabelObjectEXT (GLenum type, GLuint object, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectLabelEXT (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif +#endif /* GL_EXT_debug_label */ + +#ifndef GL_EXT_debug_marker +#define GL_EXT_debug_marker 1 +typedef void (APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker); +typedef void (APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker); +typedef void (APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glInsertEventMarkerEXT (GLsizei length, const GLchar *marker); +GLAPI void APIENTRY glPushGroupMarkerEXT (GLsizei length, const GLchar *marker); +GLAPI void APIENTRY glPopGroupMarkerEXT (void); +#endif +#endif /* GL_EXT_debug_marker */ + +#ifndef GL_EXT_direct_state_access +#define GL_EXT_direct_state_access 1 +#define GL_PROGRAM_MATRIX_EXT 0x8E2D +#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E +#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F +typedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +typedef void (APIENTRYP PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +typedef void (APIENTRYP PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data); +typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, void **data); +typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint lod, void *img); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, void *img); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, void **params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLENABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLGETFLOATI_VEXTPROC) (GLenum pname, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETDOUBLEI_VEXTPROC) (GLenum pname, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPOINTERI_VEXTPROC) (GLenum pname, GLuint index, void **params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, void *string); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target); +typedef void (APIENTRYP PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); +typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +typedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYINDEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYNORMALOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); +typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); +typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERVEXTPROC) (GLuint vaobj, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERVEXTPROC) (GLuint vaobj, GLenum pname, void **param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, void **param); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLTEXTUREPAGECOMMITMENTEXTPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBDIVISOREXTPROC) (GLuint vaobj, GLuint index, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum mode); +GLAPI void APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixPopEXT (GLenum mode); +GLAPI void APIENTRY glMatrixPushEXT (GLenum mode); +GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glTextureParameterfEXT (GLuint texture, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glTextureParameteriEXT (GLuint texture, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetTextureImageEXT (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glBindMultiTextureEXT (GLenum texunit, GLenum target, GLuint texture); +GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexEnviEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexGendEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +GLAPI void APIENTRY glMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +GLAPI void APIENTRY glMultiTexGenfEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexGeniEXT (GLenum texunit, GLenum coord, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum target, GLuint index, GLdouble *data); +GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum target, GLuint index, void **data); +GLAPI void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index); +GLAPI void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index); +GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint texture, GLenum target, GLint lod, void *img); +GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target, GLint lod, void *img); +GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); +GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void *APIENTRY glMapNamedBufferEXT (GLuint buffer, GLenum access); +GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint buffer); +GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint buffer, GLenum pname, void **params); +GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); +GLAPI void APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glTextureBufferEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glMultiTexBufferEXT (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint program, GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint program, GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint program, GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint program, GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glEnableClientStateiEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glDisableClientStateiEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glGetFloati_vEXT (GLenum pname, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetDoublei_vEXT (GLenum pname, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetPointeri_vEXT (GLenum pname, GLuint index, void **params); +GLAPI void APIENTRY glNamedProgramStringEXT (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); +GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint program, GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint program, GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint program, GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint program, GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint program, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint program, GLenum target, GLenum pname, void *string); +GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint renderbuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint framebuffer, GLenum target); +GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint texture, GLenum target); +GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum texunit, GLenum target); +GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint framebuffer, GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint texture, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum texunit, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glVertexArrayVertexOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayEdgeFlagOffsetEXT (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayIndexOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayNormalOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayMultiTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayFogCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArraySecondaryColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayVertexAttribOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayVertexAttribIOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glEnableVertexArrayEXT (GLuint vaobj, GLenum array); +GLAPI void APIENTRY glDisableVertexArrayEXT (GLuint vaobj, GLenum array); +GLAPI void APIENTRY glEnableVertexArrayAttribEXT (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glDisableVertexArrayAttribEXT (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glGetVertexArrayIntegervEXT (GLuint vaobj, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayPointervEXT (GLuint vaobj, GLenum pname, void **param); +GLAPI void APIENTRY glGetVertexArrayIntegeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayPointeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, void **param); +GLAPI void *APIENTRY glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glNamedBufferStorageEXT (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); +GLAPI void APIENTRY glClearNamedBufferDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearNamedBufferSubDataEXT (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glNamedFramebufferParameteriEXT (GLuint framebuffer, GLenum pname, GLint param); +GLAPI void APIENTRY glGetNamedFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x); +GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glTextureBufferRangeEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glTextureStorage2DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage3DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glVertexArrayBindVertexBufferEXT (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexArrayVertexAttribFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribIFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribLFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribBindingEXT (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexArrayVertexBindingDivisorEXT (GLuint vaobj, GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glTexturePageCommitmentEXT (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); +GLAPI void APIENTRY glVertexArrayVertexAttribDivisorEXT (GLuint vaobj, GLuint index, GLuint divisor); +#endif +#endif /* GL_EXT_direct_state_access */ + +#ifndef GL_EXT_draw_instanced +#define GL_EXT_draw_instanced 1 +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#endif +#endif /* GL_EXT_draw_instanced */ + +#ifndef GL_EXT_multiview_tessellation_geometry_shader +#define GL_EXT_multiview_tessellation_geometry_shader 1 +#endif /* GL_EXT_multiview_tessellation_geometry_shader */ + +#ifndef GL_EXT_multiview_texture_multisample +#define GL_EXT_multiview_texture_multisample 1 +#endif /* GL_EXT_multiview_texture_multisample */ + +#ifndef GL_EXT_multiview_timer_query +#define GL_EXT_multiview_timer_query 1 +#endif /* GL_EXT_multiview_timer_query */ + +#ifndef GL_EXT_polygon_offset_clamp +#define GL_EXT_polygon_offset_clamp 1 +#define GL_POLYGON_OFFSET_CLAMP_EXT 0x8E1B +typedef void (APIENTRYP PFNGLPOLYGONOFFSETCLAMPEXTPROC) (GLfloat factor, GLfloat units, GLfloat clamp); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPolygonOffsetClampEXT (GLfloat factor, GLfloat units, GLfloat clamp); +#endif +#endif /* GL_EXT_polygon_offset_clamp */ + +#ifndef GL_EXT_post_depth_coverage +#define GL_EXT_post_depth_coverage 1 +#endif /* GL_EXT_post_depth_coverage */ + +#ifndef GL_EXT_raster_multisample +#define GL_EXT_raster_multisample 1 +#define GL_RASTER_MULTISAMPLE_EXT 0x9327 +#define GL_RASTER_SAMPLES_EXT 0x9328 +#define GL_MAX_RASTER_SAMPLES_EXT 0x9329 +#define GL_RASTER_FIXED_SAMPLE_LOCATIONS_EXT 0x932A +#define GL_MULTISAMPLE_RASTERIZATION_ALLOWED_EXT 0x932B +#define GL_EFFECTIVE_RASTER_SAMPLES_EXT 0x932C +typedef void (APIENTRYP PFNGLRASTERSAMPLESEXTPROC) (GLuint samples, GLboolean fixedsamplelocations); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRasterSamplesEXT (GLuint samples, GLboolean fixedsamplelocations); +#endif +#endif /* GL_EXT_raster_multisample */ + +#ifndef GL_EXT_separate_shader_objects +#define GL_EXT_separate_shader_objects 1 +#define GL_ACTIVE_PROGRAM_EXT 0x8B8D +typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program); +typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUseShaderProgramEXT (GLenum type, GLuint program); +GLAPI void APIENTRY glActiveProgramEXT (GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *string); +#endif +#endif /* GL_EXT_separate_shader_objects */ + +#ifndef GL_EXT_shader_framebuffer_fetch +#define GL_EXT_shader_framebuffer_fetch 1 +#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52 +#endif /* GL_EXT_shader_framebuffer_fetch */ + +#ifndef GL_EXT_shader_framebuffer_fetch_non_coherent +#define GL_EXT_shader_framebuffer_fetch_non_coherent 1 +typedef void (APIENTRYP PFNGLFRAMEBUFFERFETCHBARRIEREXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferFetchBarrierEXT (void); +#endif +#endif /* GL_EXT_shader_framebuffer_fetch_non_coherent */ + +#ifndef GL_EXT_shader_integer_mix +#define GL_EXT_shader_integer_mix 1 +#endif /* GL_EXT_shader_integer_mix */ + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_EXT_texture_compression_s3tc 1 +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif /* GL_EXT_texture_compression_s3tc */ + +#ifndef GL_EXT_texture_filter_minmax +#define GL_EXT_texture_filter_minmax 1 +#define GL_TEXTURE_REDUCTION_MODE_EXT 0x9366 +#define GL_WEIGHTED_AVERAGE_EXT 0x9367 +#endif /* GL_EXT_texture_filter_minmax */ + +#ifndef GL_EXT_texture_sRGB_R8 +#define GL_EXT_texture_sRGB_R8 1 +#define GL_SR8_EXT 0x8FBD +#endif /* GL_EXT_texture_sRGB_R8 */ + +#ifndef GL_EXT_texture_sRGB_decode +#define GL_EXT_texture_sRGB_decode 1 +#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 +#define GL_DECODE_EXT 0x8A49 +#define GL_SKIP_DECODE_EXT 0x8A4A +#endif /* GL_EXT_texture_sRGB_decode */ + +#ifndef GL_EXT_texture_shadow_lod +#define GL_EXT_texture_shadow_lod 1 +#endif /* GL_EXT_texture_shadow_lod */ + +#ifndef GL_EXT_window_rectangles +#define GL_EXT_window_rectangles 1 +#define GL_INCLUSIVE_EXT 0x8F10 +#define GL_EXCLUSIVE_EXT 0x8F11 +#define GL_WINDOW_RECTANGLE_EXT 0x8F12 +#define GL_WINDOW_RECTANGLE_MODE_EXT 0x8F13 +#define GL_MAX_WINDOW_RECTANGLES_EXT 0x8F14 +#define GL_NUM_WINDOW_RECTANGLES_EXT 0x8F15 +typedef void (APIENTRYP PFNGLWINDOWRECTANGLESEXTPROC) (GLenum mode, GLsizei count, const GLint *box); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowRectanglesEXT (GLenum mode, GLsizei count, const GLint *box); +#endif +#endif /* GL_EXT_window_rectangles */ + +#ifndef GL_INTEL_blackhole_render +#define GL_INTEL_blackhole_render 1 +#define GL_BLACKHOLE_RENDER_INTEL 0x83FC +#endif /* GL_INTEL_blackhole_render */ + +#ifndef GL_INTEL_conservative_rasterization +#define GL_INTEL_conservative_rasterization 1 +#define GL_CONSERVATIVE_RASTERIZATION_INTEL 0x83FE +#endif /* GL_INTEL_conservative_rasterization */ + +#ifndef GL_INTEL_framebuffer_CMAA +#define GL_INTEL_framebuffer_CMAA 1 +typedef void (APIENTRYP PFNGLAPPLYFRAMEBUFFERATTACHMENTCMAAINTELPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glApplyFramebufferAttachmentCMAAINTEL (void); +#endif +#endif /* GL_INTEL_framebuffer_CMAA */ + +#ifndef GL_INTEL_performance_query +#define GL_INTEL_performance_query 1 +#define GL_PERFQUERY_SINGLE_CONTEXT_INTEL 0x00000000 +#define GL_PERFQUERY_GLOBAL_CONTEXT_INTEL 0x00000001 +#define GL_PERFQUERY_WAIT_INTEL 0x83FB +#define GL_PERFQUERY_FLUSH_INTEL 0x83FA +#define GL_PERFQUERY_DONOT_FLUSH_INTEL 0x83F9 +#define GL_PERFQUERY_COUNTER_EVENT_INTEL 0x94F0 +#define GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL 0x94F1 +#define GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL 0x94F2 +#define GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL 0x94F3 +#define GL_PERFQUERY_COUNTER_RAW_INTEL 0x94F4 +#define GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL 0x94F5 +#define GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL 0x94F8 +#define GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL 0x94F9 +#define GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL 0x94FA +#define GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL 0x94FB +#define GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL 0x94FC +#define GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL 0x94FD +#define GL_PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL 0x94FE +#define GL_PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL 0x94FF +#define GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL 0x9500 +typedef void (APIENTRYP PFNGLBEGINPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (APIENTRYP PFNGLCREATEPERFQUERYINTELPROC) (GLuint queryId, GLuint *queryHandle); +typedef void (APIENTRYP PFNGLDELETEPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (APIENTRYP PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (APIENTRYP PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint *queryId); +typedef void (APIENTRYP PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint *nextQueryId); +typedef void (APIENTRYP PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); +typedef void (APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); +typedef void (APIENTRYP PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar *queryName, GLuint *queryId); +typedef void (APIENTRYP PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginPerfQueryINTEL (GLuint queryHandle); +GLAPI void APIENTRY glCreatePerfQueryINTEL (GLuint queryId, GLuint *queryHandle); +GLAPI void APIENTRY glDeletePerfQueryINTEL (GLuint queryHandle); +GLAPI void APIENTRY glEndPerfQueryINTEL (GLuint queryHandle); +GLAPI void APIENTRY glGetFirstPerfQueryIdINTEL (GLuint *queryId); +GLAPI void APIENTRY glGetNextPerfQueryIdINTEL (GLuint queryId, GLuint *nextQueryId); +GLAPI void APIENTRY glGetPerfCounterInfoINTEL (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); +GLAPI void APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); +GLAPI void APIENTRY glGetPerfQueryIdByNameINTEL (GLchar *queryName, GLuint *queryId); +GLAPI void APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); +#endif +#endif /* GL_INTEL_performance_query */ + +#ifndef GL_MESA_framebuffer_flip_y +#define GL_MESA_framebuffer_flip_y 1 +#define GL_FRAMEBUFFER_FLIP_Y_MESA 0x8BBB +typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIMESAPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVMESAPROC) (GLenum target, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferParameteriMESA (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glGetFramebufferParameterivMESA (GLenum target, GLenum pname, GLint *params); +#endif +#endif /* GL_MESA_framebuffer_flip_y */ + +#ifndef GL_NV_bindless_multi_draw_indirect +#define GL_NV_bindless_multi_draw_indirect 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectBindlessNV (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +GLAPI void APIENTRY glMultiDrawElementsIndirectBindlessNV (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +#endif +#endif /* GL_NV_bindless_multi_draw_indirect */ + +#ifndef GL_NV_bindless_multi_draw_indirect_count +#define GL_NV_bindless_multi_draw_indirect_count 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectBindlessCountNV (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); +GLAPI void APIENTRY glMultiDrawElementsIndirectBindlessCountNV (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); +#endif +#endif /* GL_NV_bindless_multi_draw_indirect_count */ + +#ifndef GL_NV_bindless_texture +#define GL_NV_bindless_texture 1 +typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture); +typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint64 APIENTRY glGetTextureHandleNV (GLuint texture); +GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler); +GLAPI void APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle); +GLAPI void APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle); +GLAPI GLuint64 APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +GLAPI void APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access); +GLAPI void APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle); +GLAPI void APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value); +GLAPI void APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value); +GLAPI void APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +GLAPI GLboolean APIENTRY glIsTextureHandleResidentNV (GLuint64 handle); +GLAPI GLboolean APIENTRY glIsImageHandleResidentNV (GLuint64 handle); +#endif +#endif /* GL_NV_bindless_texture */ + +#ifndef GL_NV_blend_equation_advanced +#define GL_NV_blend_equation_advanced 1 +#define GL_BLEND_OVERLAP_NV 0x9281 +#define GL_BLEND_PREMULTIPLIED_SRC_NV 0x9280 +#define GL_BLUE_NV 0x1905 +#define GL_COLORBURN_NV 0x929A +#define GL_COLORDODGE_NV 0x9299 +#define GL_CONJOINT_NV 0x9284 +#define GL_CONTRAST_NV 0x92A1 +#define GL_DARKEN_NV 0x9297 +#define GL_DIFFERENCE_NV 0x929E +#define GL_DISJOINT_NV 0x9283 +#define GL_DST_ATOP_NV 0x928F +#define GL_DST_IN_NV 0x928B +#define GL_DST_NV 0x9287 +#define GL_DST_OUT_NV 0x928D +#define GL_DST_OVER_NV 0x9289 +#define GL_EXCLUSION_NV 0x92A0 +#define GL_GREEN_NV 0x1904 +#define GL_HARDLIGHT_NV 0x929B +#define GL_HARDMIX_NV 0x92A9 +#define GL_HSL_COLOR_NV 0x92AF +#define GL_HSL_HUE_NV 0x92AD +#define GL_HSL_LUMINOSITY_NV 0x92B0 +#define GL_HSL_SATURATION_NV 0x92AE +#define GL_INVERT_OVG_NV 0x92B4 +#define GL_INVERT_RGB_NV 0x92A3 +#define GL_LIGHTEN_NV 0x9298 +#define GL_LINEARBURN_NV 0x92A5 +#define GL_LINEARDODGE_NV 0x92A4 +#define GL_LINEARLIGHT_NV 0x92A7 +#define GL_MINUS_CLAMPED_NV 0x92B3 +#define GL_MINUS_NV 0x929F +#define GL_MULTIPLY_NV 0x9294 +#define GL_OVERLAY_NV 0x9296 +#define GL_PINLIGHT_NV 0x92A8 +#define GL_PLUS_CLAMPED_ALPHA_NV 0x92B2 +#define GL_PLUS_CLAMPED_NV 0x92B1 +#define GL_PLUS_DARKER_NV 0x9292 +#define GL_PLUS_NV 0x9291 +#define GL_RED_NV 0x1903 +#define GL_SCREEN_NV 0x9295 +#define GL_SOFTLIGHT_NV 0x929C +#define GL_SRC_ATOP_NV 0x928E +#define GL_SRC_IN_NV 0x928A +#define GL_SRC_NV 0x9286 +#define GL_SRC_OUT_NV 0x928C +#define GL_SRC_OVER_NV 0x9288 +#define GL_UNCORRELATED_NV 0x9282 +#define GL_VIVIDLIGHT_NV 0x92A6 +#define GL_XOR_NV 0x1506 +typedef void (APIENTRYP PFNGLBLENDPARAMETERINVPROC) (GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLBLENDBARRIERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendParameteriNV (GLenum pname, GLint value); +GLAPI void APIENTRY glBlendBarrierNV (void); +#endif +#endif /* GL_NV_blend_equation_advanced */ + +#ifndef GL_NV_blend_equation_advanced_coherent +#define GL_NV_blend_equation_advanced_coherent 1 +#define GL_BLEND_ADVANCED_COHERENT_NV 0x9285 +#endif /* GL_NV_blend_equation_advanced_coherent */ + +#ifndef GL_NV_blend_minmax_factor +#define GL_NV_blend_minmax_factor 1 +#define GL_FACTOR_MIN_AMD 0x901C +#define GL_FACTOR_MAX_AMD 0x901D +#endif /* GL_NV_blend_minmax_factor */ + +#ifndef GL_NV_clip_space_w_scaling +#define GL_NV_clip_space_w_scaling 1 +#define GL_VIEWPORT_POSITION_W_SCALE_NV 0x937C +#define GL_VIEWPORT_POSITION_W_SCALE_X_COEFF_NV 0x937D +#define GL_VIEWPORT_POSITION_W_SCALE_Y_COEFF_NV 0x937E +typedef void (APIENTRYP PFNGLVIEWPORTPOSITIONWSCALENVPROC) (GLuint index, GLfloat xcoeff, GLfloat ycoeff); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glViewportPositionWScaleNV (GLuint index, GLfloat xcoeff, GLfloat ycoeff); +#endif +#endif /* GL_NV_clip_space_w_scaling */ + +#ifndef GL_NV_command_list +#define GL_NV_command_list 1 +#define GL_TERMINATE_SEQUENCE_COMMAND_NV 0x0000 +#define GL_NOP_COMMAND_NV 0x0001 +#define GL_DRAW_ELEMENTS_COMMAND_NV 0x0002 +#define GL_DRAW_ARRAYS_COMMAND_NV 0x0003 +#define GL_DRAW_ELEMENTS_STRIP_COMMAND_NV 0x0004 +#define GL_DRAW_ARRAYS_STRIP_COMMAND_NV 0x0005 +#define GL_DRAW_ELEMENTS_INSTANCED_COMMAND_NV 0x0006 +#define GL_DRAW_ARRAYS_INSTANCED_COMMAND_NV 0x0007 +#define GL_ELEMENT_ADDRESS_COMMAND_NV 0x0008 +#define GL_ATTRIBUTE_ADDRESS_COMMAND_NV 0x0009 +#define GL_UNIFORM_ADDRESS_COMMAND_NV 0x000A +#define GL_BLEND_COLOR_COMMAND_NV 0x000B +#define GL_STENCIL_REF_COMMAND_NV 0x000C +#define GL_LINE_WIDTH_COMMAND_NV 0x000D +#define GL_POLYGON_OFFSET_COMMAND_NV 0x000E +#define GL_ALPHA_REF_COMMAND_NV 0x000F +#define GL_VIEWPORT_COMMAND_NV 0x0010 +#define GL_SCISSOR_COMMAND_NV 0x0011 +#define GL_FRONT_FACE_COMMAND_NV 0x0012 +typedef void (APIENTRYP PFNGLCREATESTATESNVPROC) (GLsizei n, GLuint *states); +typedef void (APIENTRYP PFNGLDELETESTATESNVPROC) (GLsizei n, const GLuint *states); +typedef GLboolean (APIENTRYP PFNGLISSTATENVPROC) (GLuint state); +typedef void (APIENTRYP PFNGLSTATECAPTURENVPROC) (GLuint state, GLenum mode); +typedef GLuint (APIENTRYP PFNGLGETCOMMANDHEADERNVPROC) (GLenum tokenID, GLuint size); +typedef GLushort (APIENTRYP PFNGLGETSTAGEINDEXNVPROC) (GLenum shadertype); +typedef void (APIENTRYP PFNGLDRAWCOMMANDSNVPROC) (GLenum primitiveMode, GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, GLuint count); +typedef void (APIENTRYP PFNGLDRAWCOMMANDSADDRESSNVPROC) (GLenum primitiveMode, const GLuint64 *indirects, const GLsizei *sizes, GLuint count); +typedef void (APIENTRYP PFNGLDRAWCOMMANDSSTATESNVPROC) (GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +typedef void (APIENTRYP PFNGLDRAWCOMMANDSSTATESADDRESSNVPROC) (const GLuint64 *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +typedef void (APIENTRYP PFNGLCREATECOMMANDLISTSNVPROC) (GLsizei n, GLuint *lists); +typedef void (APIENTRYP PFNGLDELETECOMMANDLISTSNVPROC) (GLsizei n, const GLuint *lists); +typedef GLboolean (APIENTRYP PFNGLISCOMMANDLISTNVPROC) (GLuint list); +typedef void (APIENTRYP PFNGLLISTDRAWCOMMANDSSTATESCLIENTNVPROC) (GLuint list, GLuint segment, const void **indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +typedef void (APIENTRYP PFNGLCOMMANDLISTSEGMENTSNVPROC) (GLuint list, GLuint segments); +typedef void (APIENTRYP PFNGLCOMPILECOMMANDLISTNVPROC) (GLuint list); +typedef void (APIENTRYP PFNGLCALLCOMMANDLISTNVPROC) (GLuint list); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCreateStatesNV (GLsizei n, GLuint *states); +GLAPI void APIENTRY glDeleteStatesNV (GLsizei n, const GLuint *states); +GLAPI GLboolean APIENTRY glIsStateNV (GLuint state); +GLAPI void APIENTRY glStateCaptureNV (GLuint state, GLenum mode); +GLAPI GLuint APIENTRY glGetCommandHeaderNV (GLenum tokenID, GLuint size); +GLAPI GLushort APIENTRY glGetStageIndexNV (GLenum shadertype); +GLAPI void APIENTRY glDrawCommandsNV (GLenum primitiveMode, GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, GLuint count); +GLAPI void APIENTRY glDrawCommandsAddressNV (GLenum primitiveMode, const GLuint64 *indirects, const GLsizei *sizes, GLuint count); +GLAPI void APIENTRY glDrawCommandsStatesNV (GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +GLAPI void APIENTRY glDrawCommandsStatesAddressNV (const GLuint64 *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +GLAPI void APIENTRY glCreateCommandListsNV (GLsizei n, GLuint *lists); +GLAPI void APIENTRY glDeleteCommandListsNV (GLsizei n, const GLuint *lists); +GLAPI GLboolean APIENTRY glIsCommandListNV (GLuint list); +GLAPI void APIENTRY glListDrawCommandsStatesClientNV (GLuint list, GLuint segment, const void **indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +GLAPI void APIENTRY glCommandListSegmentsNV (GLuint list, GLuint segments); +GLAPI void APIENTRY glCompileCommandListNV (GLuint list); +GLAPI void APIENTRY glCallCommandListNV (GLuint list); +#endif +#endif /* GL_NV_command_list */ + +#ifndef GL_NV_compute_shader_derivatives +#define GL_NV_compute_shader_derivatives 1 +#endif /* GL_NV_compute_shader_derivatives */ + +#ifndef GL_NV_conditional_render +#define GL_NV_conditional_render 1 +#define GL_QUERY_WAIT_NV 0x8E13 +#define GL_QUERY_NO_WAIT_NV 0x8E14 +#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRenderNV (void); +#endif +#endif /* GL_NV_conditional_render */ + +#ifndef GL_NV_conservative_raster +#define GL_NV_conservative_raster 1 +#define GL_CONSERVATIVE_RASTERIZATION_NV 0x9346 +#define GL_SUBPIXEL_PRECISION_BIAS_X_BITS_NV 0x9347 +#define GL_SUBPIXEL_PRECISION_BIAS_Y_BITS_NV 0x9348 +#define GL_MAX_SUBPIXEL_PRECISION_BIAS_BITS_NV 0x9349 +typedef void (APIENTRYP PFNGLSUBPIXELPRECISIONBIASNVPROC) (GLuint xbits, GLuint ybits); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSubpixelPrecisionBiasNV (GLuint xbits, GLuint ybits); +#endif +#endif /* GL_NV_conservative_raster */ + +#ifndef GL_NV_conservative_raster_dilate +#define GL_NV_conservative_raster_dilate 1 +#define GL_CONSERVATIVE_RASTER_DILATE_NV 0x9379 +#define GL_CONSERVATIVE_RASTER_DILATE_RANGE_NV 0x937A +#define GL_CONSERVATIVE_RASTER_DILATE_GRANULARITY_NV 0x937B +typedef void (APIENTRYP PFNGLCONSERVATIVERASTERPARAMETERFNVPROC) (GLenum pname, GLfloat value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConservativeRasterParameterfNV (GLenum pname, GLfloat value); +#endif +#endif /* GL_NV_conservative_raster_dilate */ + +#ifndef GL_NV_conservative_raster_pre_snap +#define GL_NV_conservative_raster_pre_snap 1 +#define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_NV 0x9550 +#endif /* GL_NV_conservative_raster_pre_snap */ + +#ifndef GL_NV_conservative_raster_pre_snap_triangles +#define GL_NV_conservative_raster_pre_snap_triangles 1 +#define GL_CONSERVATIVE_RASTER_MODE_NV 0x954D +#define GL_CONSERVATIVE_RASTER_MODE_POST_SNAP_NV 0x954E +#define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_TRIANGLES_NV 0x954F +typedef void (APIENTRYP PFNGLCONSERVATIVERASTERPARAMETERINVPROC) (GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConservativeRasterParameteriNV (GLenum pname, GLint param); +#endif +#endif /* GL_NV_conservative_raster_pre_snap_triangles */ + +#ifndef GL_NV_conservative_raster_underestimation +#define GL_NV_conservative_raster_underestimation 1 +#endif /* GL_NV_conservative_raster_underestimation */ + +#ifndef GL_NV_depth_buffer_float +#define GL_NV_depth_buffer_float 1 +#define GL_DEPTH_COMPONENT32F_NV 0x8DAB +#define GL_DEPTH32F_STENCIL8_NV 0x8DAC +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD +#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF +typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); +typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glClearDepthdNV (GLdouble depth); +GLAPI void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax); +#endif +#endif /* GL_NV_depth_buffer_float */ + +#ifndef GL_NV_draw_vulkan_image +#define GL_NV_draw_vulkan_image 1 +typedef void (APIENTRY *GLVULKANPROCNV)(void); +typedef void (APIENTRYP PFNGLDRAWVKIMAGENVPROC) (GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +typedef GLVULKANPROCNV (APIENTRYP PFNGLGETVKPROCADDRNVPROC) (const GLchar *name); +typedef void (APIENTRYP PFNGLWAITVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); +typedef void (APIENTRYP PFNGLSIGNALVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); +typedef void (APIENTRYP PFNGLSIGNALVKFENCENVPROC) (GLuint64 vkFence); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawVkImageNV (GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +GLAPI GLVULKANPROCNV APIENTRY glGetVkProcAddrNV (const GLchar *name); +GLAPI void APIENTRY glWaitVkSemaphoreNV (GLuint64 vkSemaphore); +GLAPI void APIENTRY glSignalVkSemaphoreNV (GLuint64 vkSemaphore); +GLAPI void APIENTRY glSignalVkFenceNV (GLuint64 vkFence); +#endif +#endif /* GL_NV_draw_vulkan_image */ + +#ifndef GL_NV_fill_rectangle +#define GL_NV_fill_rectangle 1 +#define GL_FILL_RECTANGLE_NV 0x933C +#endif /* GL_NV_fill_rectangle */ + +#ifndef GL_NV_fragment_coverage_to_color +#define GL_NV_fragment_coverage_to_color 1 +#define GL_FRAGMENT_COVERAGE_TO_COLOR_NV 0x92DD +#define GL_FRAGMENT_COVERAGE_COLOR_NV 0x92DE +typedef void (APIENTRYP PFNGLFRAGMENTCOVERAGECOLORNVPROC) (GLuint color); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFragmentCoverageColorNV (GLuint color); +#endif +#endif /* GL_NV_fragment_coverage_to_color */ + +#ifndef GL_NV_fragment_shader_barycentric +#define GL_NV_fragment_shader_barycentric 1 +#endif /* GL_NV_fragment_shader_barycentric */ + +#ifndef GL_NV_fragment_shader_interlock +#define GL_NV_fragment_shader_interlock 1 +#endif /* GL_NV_fragment_shader_interlock */ + +#ifndef GL_NV_framebuffer_mixed_samples +#define GL_NV_framebuffer_mixed_samples 1 +#define GL_COVERAGE_MODULATION_TABLE_NV 0x9331 +#define GL_COLOR_SAMPLES_NV 0x8E20 +#define GL_DEPTH_SAMPLES_NV 0x932D +#define GL_STENCIL_SAMPLES_NV 0x932E +#define GL_MIXED_DEPTH_SAMPLES_SUPPORTED_NV 0x932F +#define GL_MIXED_STENCIL_SAMPLES_SUPPORTED_NV 0x9330 +#define GL_COVERAGE_MODULATION_NV 0x9332 +#define GL_COVERAGE_MODULATION_TABLE_SIZE_NV 0x9333 +typedef void (APIENTRYP PFNGLCOVERAGEMODULATIONTABLENVPROC) (GLsizei n, const GLfloat *v); +typedef void (APIENTRYP PFNGLGETCOVERAGEMODULATIONTABLENVPROC) (GLsizei bufSize, GLfloat *v); +typedef void (APIENTRYP PFNGLCOVERAGEMODULATIONNVPROC) (GLenum components); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCoverageModulationTableNV (GLsizei n, const GLfloat *v); +GLAPI void APIENTRY glGetCoverageModulationTableNV (GLsizei bufSize, GLfloat *v); +GLAPI void APIENTRY glCoverageModulationNV (GLenum components); +#endif +#endif /* GL_NV_framebuffer_mixed_samples */ + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_NV_framebuffer_multisample_coverage 1 +#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB +#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 +#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 +#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_NV_framebuffer_multisample_coverage */ + +#ifndef GL_NV_geometry_shader_passthrough +#define GL_NV_geometry_shader_passthrough 1 +#endif /* GL_NV_geometry_shader_passthrough */ + +#ifndef GL_NV_gpu_shader5 +#define GL_NV_gpu_shader5 1 +typedef khronos_int64_t GLint64EXT; +#define GL_INT64_NV 0x140E +#define GL_UNSIGNED_INT64_NV 0x140F +#define GL_INT8_NV 0x8FE0 +#define GL_INT8_VEC2_NV 0x8FE1 +#define GL_INT8_VEC3_NV 0x8FE2 +#define GL_INT8_VEC4_NV 0x8FE3 +#define GL_INT16_NV 0x8FE4 +#define GL_INT16_VEC2_NV 0x8FE5 +#define GL_INT16_VEC3_NV 0x8FE6 +#define GL_INT16_VEC4_NV 0x8FE7 +#define GL_INT64_VEC2_NV 0x8FE9 +#define GL_INT64_VEC3_NV 0x8FEA +#define GL_INT64_VEC4_NV 0x8FEB +#define GL_UNSIGNED_INT8_NV 0x8FEC +#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED +#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE +#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF +#define GL_UNSIGNED_INT16_NV 0x8FF0 +#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 +#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 +#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 +#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 +#define GL_FLOAT16_NV 0x8FF8 +#define GL_FLOAT16_VEC2_NV 0x8FF9 +#define GL_FLOAT16_VEC3_NV 0x8FFA +#define GL_FLOAT16_VEC4_NV 0x8FFB +typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniform1i64NV (GLint location, GLint64EXT x); +GLAPI void APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x); +GLAPI void APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params); +GLAPI void APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x); +GLAPI void APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x); +GLAPI void APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif +#endif /* GL_NV_gpu_shader5 */ + +#ifndef GL_NV_internalformat_sample_query +#define GL_NV_internalformat_sample_query 1 +#define GL_MULTISAMPLES_NV 0x9371 +#define GL_SUPERSAMPLE_SCALE_X_NV 0x9372 +#define GL_SUPERSAMPLE_SCALE_Y_NV 0x9373 +#define GL_CONFORMANT_NV 0x9374 +typedef void (APIENTRYP PFNGLGETINTERNALFORMATSAMPLEIVNVPROC) (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei count, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetInternalformatSampleivNV (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei count, GLint *params); +#endif +#endif /* GL_NV_internalformat_sample_query */ + +#ifndef GL_NV_memory_attachment +#define GL_NV_memory_attachment 1 +#define GL_ATTACHED_MEMORY_OBJECT_NV 0x95A4 +#define GL_ATTACHED_MEMORY_OFFSET_NV 0x95A5 +#define GL_MEMORY_ATTACHABLE_ALIGNMENT_NV 0x95A6 +#define GL_MEMORY_ATTACHABLE_SIZE_NV 0x95A7 +#define GL_MEMORY_ATTACHABLE_NV 0x95A8 +#define GL_DETACHED_MEMORY_INCARNATION_NV 0x95A9 +#define GL_DETACHED_TEXTURES_NV 0x95AA +#define GL_DETACHED_BUFFERS_NV 0x95AB +#define GL_MAX_DETACHED_TEXTURES_NV 0x95AC +#define GL_MAX_DETACHED_BUFFERS_NV 0x95AD +typedef void (APIENTRYP PFNGLGETMEMORYOBJECTDETACHEDRESOURCESUIVNVPROC) (GLuint memory, GLenum pname, GLint first, GLsizei count, GLuint *params); +typedef void (APIENTRYP PFNGLRESETMEMORYOBJECTPARAMETERNVPROC) (GLuint memory, GLenum pname); +typedef void (APIENTRYP PFNGLTEXATTACHMEMORYNVPROC) (GLenum target, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLBUFFERATTACHMEMORYNVPROC) (GLenum target, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTUREATTACHMEMORYNVPROC) (GLuint texture, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLNAMEDBUFFERATTACHMEMORYNVPROC) (GLuint buffer, GLuint memory, GLuint64 offset); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetMemoryObjectDetachedResourcesuivNV (GLuint memory, GLenum pname, GLint first, GLsizei count, GLuint *params); +GLAPI void APIENTRY glResetMemoryObjectParameterNV (GLuint memory, GLenum pname); +GLAPI void APIENTRY glTexAttachMemoryNV (GLenum target, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glBufferAttachMemoryNV (GLenum target, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureAttachMemoryNV (GLuint texture, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glNamedBufferAttachMemoryNV (GLuint buffer, GLuint memory, GLuint64 offset); +#endif +#endif /* GL_NV_memory_attachment */ + +#ifndef GL_NV_mesh_shader +#define GL_NV_mesh_shader 1 +#define GL_MESH_SHADER_NV 0x9559 +#define GL_TASK_SHADER_NV 0x955A +#define GL_MAX_MESH_UNIFORM_BLOCKS_NV 0x8E60 +#define GL_MAX_MESH_TEXTURE_IMAGE_UNITS_NV 0x8E61 +#define GL_MAX_MESH_IMAGE_UNIFORMS_NV 0x8E62 +#define GL_MAX_MESH_UNIFORM_COMPONENTS_NV 0x8E63 +#define GL_MAX_MESH_ATOMIC_COUNTER_BUFFERS_NV 0x8E64 +#define GL_MAX_MESH_ATOMIC_COUNTERS_NV 0x8E65 +#define GL_MAX_MESH_SHADER_STORAGE_BLOCKS_NV 0x8E66 +#define GL_MAX_COMBINED_MESH_UNIFORM_COMPONENTS_NV 0x8E67 +#define GL_MAX_TASK_UNIFORM_BLOCKS_NV 0x8E68 +#define GL_MAX_TASK_TEXTURE_IMAGE_UNITS_NV 0x8E69 +#define GL_MAX_TASK_IMAGE_UNIFORMS_NV 0x8E6A +#define GL_MAX_TASK_UNIFORM_COMPONENTS_NV 0x8E6B +#define GL_MAX_TASK_ATOMIC_COUNTER_BUFFERS_NV 0x8E6C +#define GL_MAX_TASK_ATOMIC_COUNTERS_NV 0x8E6D +#define GL_MAX_TASK_SHADER_STORAGE_BLOCKS_NV 0x8E6E +#define GL_MAX_COMBINED_TASK_UNIFORM_COMPONENTS_NV 0x8E6F +#define GL_MAX_MESH_WORK_GROUP_INVOCATIONS_NV 0x95A2 +#define GL_MAX_TASK_WORK_GROUP_INVOCATIONS_NV 0x95A3 +#define GL_MAX_MESH_TOTAL_MEMORY_SIZE_NV 0x9536 +#define GL_MAX_TASK_TOTAL_MEMORY_SIZE_NV 0x9537 +#define GL_MAX_MESH_OUTPUT_VERTICES_NV 0x9538 +#define GL_MAX_MESH_OUTPUT_PRIMITIVES_NV 0x9539 +#define GL_MAX_TASK_OUTPUT_COUNT_NV 0x953A +#define GL_MAX_DRAW_MESH_TASKS_COUNT_NV 0x953D +#define GL_MAX_MESH_VIEWS_NV 0x9557 +#define GL_MESH_OUTPUT_PER_VERTEX_GRANULARITY_NV 0x92DF +#define GL_MESH_OUTPUT_PER_PRIMITIVE_GRANULARITY_NV 0x9543 +#define GL_MAX_MESH_WORK_GROUP_SIZE_NV 0x953B +#define GL_MAX_TASK_WORK_GROUP_SIZE_NV 0x953C +#define GL_MESH_WORK_GROUP_SIZE_NV 0x953E +#define GL_TASK_WORK_GROUP_SIZE_NV 0x953F +#define GL_MESH_VERTICES_OUT_NV 0x9579 +#define GL_MESH_PRIMITIVES_OUT_NV 0x957A +#define GL_MESH_OUTPUT_TYPE_NV 0x957B +#define GL_UNIFORM_BLOCK_REFERENCED_BY_MESH_SHADER_NV 0x959C +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TASK_SHADER_NV 0x959D +#define GL_REFERENCED_BY_MESH_SHADER_NV 0x95A0 +#define GL_REFERENCED_BY_TASK_SHADER_NV 0x95A1 +#define GL_MESH_SHADER_BIT_NV 0x00000040 +#define GL_TASK_SHADER_BIT_NV 0x00000080 +#define GL_MESH_SUBROUTINE_NV 0x957C +#define GL_TASK_SUBROUTINE_NV 0x957D +#define GL_MESH_SUBROUTINE_UNIFORM_NV 0x957E +#define GL_TASK_SUBROUTINE_UNIFORM_NV 0x957F +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_MESH_SHADER_NV 0x959E +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TASK_SHADER_NV 0x959F +typedef void (APIENTRYP PFNGLDRAWMESHTASKSNVPROC) (GLuint first, GLuint count); +typedef void (APIENTRYP PFNGLDRAWMESHTASKSINDIRECTNVPROC) (GLintptr indirect); +typedef void (APIENTRYP PFNGLMULTIDRAWMESHTASKSINDIRECTNVPROC) (GLintptr indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWMESHTASKSINDIRECTCOUNTNVPROC) (GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawMeshTasksNV (GLuint first, GLuint count); +GLAPI void APIENTRY glDrawMeshTasksIndirectNV (GLintptr indirect); +GLAPI void APIENTRY glMultiDrawMeshTasksIndirectNV (GLintptr indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawMeshTasksIndirectCountNV (GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#endif +#endif /* GL_NV_mesh_shader */ + +#ifndef GL_NV_path_rendering +#define GL_NV_path_rendering 1 +#define GL_PATH_FORMAT_SVG_NV 0x9070 +#define GL_PATH_FORMAT_PS_NV 0x9071 +#define GL_STANDARD_FONT_NAME_NV 0x9072 +#define GL_SYSTEM_FONT_NAME_NV 0x9073 +#define GL_FILE_NAME_NV 0x9074 +#define GL_PATH_STROKE_WIDTH_NV 0x9075 +#define GL_PATH_END_CAPS_NV 0x9076 +#define GL_PATH_INITIAL_END_CAP_NV 0x9077 +#define GL_PATH_TERMINAL_END_CAP_NV 0x9078 +#define GL_PATH_JOIN_STYLE_NV 0x9079 +#define GL_PATH_MITER_LIMIT_NV 0x907A +#define GL_PATH_DASH_CAPS_NV 0x907B +#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C +#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D +#define GL_PATH_DASH_OFFSET_NV 0x907E +#define GL_PATH_CLIENT_LENGTH_NV 0x907F +#define GL_PATH_FILL_MODE_NV 0x9080 +#define GL_PATH_FILL_MASK_NV 0x9081 +#define GL_PATH_FILL_COVER_MODE_NV 0x9082 +#define GL_PATH_STROKE_COVER_MODE_NV 0x9083 +#define GL_PATH_STROKE_MASK_NV 0x9084 +#define GL_COUNT_UP_NV 0x9088 +#define GL_COUNT_DOWN_NV 0x9089 +#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A +#define GL_CONVEX_HULL_NV 0x908B +#define GL_BOUNDING_BOX_NV 0x908D +#define GL_TRANSLATE_X_NV 0x908E +#define GL_TRANSLATE_Y_NV 0x908F +#define GL_TRANSLATE_2D_NV 0x9090 +#define GL_TRANSLATE_3D_NV 0x9091 +#define GL_AFFINE_2D_NV 0x9092 +#define GL_AFFINE_3D_NV 0x9094 +#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096 +#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098 +#define GL_UTF8_NV 0x909A +#define GL_UTF16_NV 0x909B +#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C +#define GL_PATH_COMMAND_COUNT_NV 0x909D +#define GL_PATH_COORD_COUNT_NV 0x909E +#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F +#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0 +#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 +#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 +#define GL_SQUARE_NV 0x90A3 +#define GL_ROUND_NV 0x90A4 +#define GL_TRIANGULAR_NV 0x90A5 +#define GL_BEVEL_NV 0x90A6 +#define GL_MITER_REVERT_NV 0x90A7 +#define GL_MITER_TRUNCATE_NV 0x90A8 +#define GL_SKIP_MISSING_GLYPH_NV 0x90A9 +#define GL_USE_MISSING_GLYPH_NV 0x90AA +#define GL_PATH_ERROR_POSITION_NV 0x90AB +#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD +#define GL_ADJACENT_PAIRS_NV 0x90AE +#define GL_FIRST_TO_REST_NV 0x90AF +#define GL_PATH_GEN_MODE_NV 0x90B0 +#define GL_PATH_GEN_COEFF_NV 0x90B1 +#define GL_PATH_GEN_COMPONENTS_NV 0x90B3 +#define GL_PATH_STENCIL_FUNC_NV 0x90B7 +#define GL_PATH_STENCIL_REF_NV 0x90B8 +#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 +#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD +#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE +#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF +#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 +#define GL_MOVE_TO_RESETS_NV 0x90B5 +#define GL_MOVE_TO_CONTINUES_NV 0x90B6 +#define GL_CLOSE_PATH_NV 0x00 +#define GL_MOVE_TO_NV 0x02 +#define GL_RELATIVE_MOVE_TO_NV 0x03 +#define GL_LINE_TO_NV 0x04 +#define GL_RELATIVE_LINE_TO_NV 0x05 +#define GL_HORIZONTAL_LINE_TO_NV 0x06 +#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 +#define GL_VERTICAL_LINE_TO_NV 0x08 +#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 +#define GL_QUADRATIC_CURVE_TO_NV 0x0A +#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B +#define GL_CUBIC_CURVE_TO_NV 0x0C +#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D +#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E +#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F +#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 +#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 +#define GL_SMALL_CCW_ARC_TO_NV 0x12 +#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 +#define GL_SMALL_CW_ARC_TO_NV 0x14 +#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 +#define GL_LARGE_CCW_ARC_TO_NV 0x16 +#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 +#define GL_LARGE_CW_ARC_TO_NV 0x18 +#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 +#define GL_RESTART_PATH_NV 0xF0 +#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2 +#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4 +#define GL_RECT_NV 0xF6 +#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 +#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA +#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC +#define GL_ARC_TO_NV 0xFE +#define GL_RELATIVE_ARC_TO_NV 0xFF +#define GL_BOLD_BIT_NV 0x01 +#define GL_ITALIC_BIT_NV 0x02 +#define GL_GLYPH_WIDTH_BIT_NV 0x01 +#define GL_GLYPH_HEIGHT_BIT_NV 0x02 +#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 +#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 +#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 +#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 +#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 +#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 +#define GL_GLYPH_HAS_KERNING_BIT_NV 0x100 +#define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000 +#define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000 +#define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000 +#define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000 +#define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000 +#define GL_FONT_ASCENDER_BIT_NV 0x00200000 +#define GL_FONT_DESCENDER_BIT_NV 0x00400000 +#define GL_FONT_HEIGHT_BIT_NV 0x00800000 +#define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000 +#define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000 +#define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000 +#define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000 +#define GL_FONT_HAS_KERNING_BIT_NV 0x10000000 +#define GL_ROUNDED_RECT_NV 0xE8 +#define GL_RELATIVE_ROUNDED_RECT_NV 0xE9 +#define GL_ROUNDED_RECT2_NV 0xEA +#define GL_RELATIVE_ROUNDED_RECT2_NV 0xEB +#define GL_ROUNDED_RECT4_NV 0xEC +#define GL_RELATIVE_ROUNDED_RECT4_NV 0xED +#define GL_ROUNDED_RECT8_NV 0xEE +#define GL_RELATIVE_ROUNDED_RECT8_NV 0xEF +#define GL_RELATIVE_RECT_NV 0xF7 +#define GL_FONT_GLYPHS_AVAILABLE_NV 0x9368 +#define GL_FONT_TARGET_UNAVAILABLE_NV 0x9369 +#define GL_FONT_UNAVAILABLE_NV 0x936A +#define GL_FONT_UNINTELLIGIBLE_NV 0x936B +#define GL_CONIC_CURVE_TO_NV 0x1A +#define GL_RELATIVE_CONIC_CURVE_TO_NV 0x1B +#define GL_FONT_NUM_GLYPH_INDICES_BIT_NV 0x20000000 +#define GL_STANDARD_FONT_FORMAT_NV 0x936C +#define GL_PATH_PROJECTION_NV 0x1701 +#define GL_PATH_MODELVIEW_NV 0x1700 +#define GL_PATH_MODELVIEW_STACK_DEPTH_NV 0x0BA3 +#define GL_PATH_MODELVIEW_MATRIX_NV 0x0BA6 +#define GL_PATH_MAX_MODELVIEW_STACK_DEPTH_NV 0x0D36 +#define GL_PATH_TRANSPOSE_MODELVIEW_MATRIX_NV 0x84E3 +#define GL_PATH_PROJECTION_STACK_DEPTH_NV 0x0BA4 +#define GL_PATH_PROJECTION_MATRIX_NV 0x0BA7 +#define GL_PATH_MAX_PROJECTION_STACK_DEPTH_NV 0x0D38 +#define GL_PATH_TRANSPOSE_PROJECTION_MATRIX_NV 0x84E4 +#define GL_FRAGMENT_INPUT_NV 0x936D +typedef GLuint (APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISPATHNVPROC) (GLuint path); +typedef void (APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const void *pathString); +typedef void (APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +typedef void (APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath); +typedef void (APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +typedef void (APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value); +typedef void (APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value); +typedef void (APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value); +typedef void (APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +typedef void (APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units); +typedef void (APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func); +typedef void (APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value); +typedef void (APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands); +typedef void (APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords); +typedef void (APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray); +typedef void (APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +typedef void (APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +typedef void (APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +typedef GLboolean (APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); +typedef GLboolean (APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); +typedef GLfloat (APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); +typedef GLboolean (APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +typedef void (APIENTRYP PFNGLMATRIXLOAD3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOAD3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULT3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULT3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); +typedef void (APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask, GLenum coverMode); +typedef void (APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef GLenum (APIENTRYP PFNGLPATHGLYPHINDEXRANGENVPROC) (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint baseAndCount[2]); +typedef GLenum (APIENTRYP PFNGLPATHGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef GLenum (APIENTRYP PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC) (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEFVNVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenPathsNV (GLsizei range); +GLAPI void APIENTRY glDeletePathsNV (GLuint path, GLsizei range); +GLAPI GLboolean APIENTRY glIsPathNV (GLuint path); +GLAPI void APIENTRY glPathCommandsNV (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathCoordsNV (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathSubCommandsNV (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathSubCoordsNV (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathStringNV (GLuint path, GLenum format, GLsizei length, const void *pathString); +GLAPI void APIENTRY glPathGlyphsNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glPathGlyphRangeNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glWeightPathsNV (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +GLAPI void APIENTRY glCopyPathNV (GLuint resultPath, GLuint srcPath); +GLAPI void APIENTRY glInterpolatePathsNV (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +GLAPI void APIENTRY glTransformPathNV (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glPathParameterivNV (GLuint path, GLenum pname, const GLint *value); +GLAPI void APIENTRY glPathParameteriNV (GLuint path, GLenum pname, GLint value); +GLAPI void APIENTRY glPathParameterfvNV (GLuint path, GLenum pname, const GLfloat *value); +GLAPI void APIENTRY glPathParameterfNV (GLuint path, GLenum pname, GLfloat value); +GLAPI void APIENTRY glPathDashArrayNV (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +GLAPI void APIENTRY glPathStencilFuncNV (GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glPathStencilDepthOffsetNV (GLfloat factor, GLfloat units); +GLAPI void APIENTRY glStencilFillPathNV (GLuint path, GLenum fillMode, GLuint mask); +GLAPI void APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint mask); +GLAPI void APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glPathCoverDepthFuncNV (GLenum func); +GLAPI void APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode); +GLAPI void APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode); +GLAPI void APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glGetPathParameterivNV (GLuint path, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathParameterfvNV (GLuint path, GLenum pname, GLfloat *value); +GLAPI void APIENTRY glGetPathCommandsNV (GLuint path, GLubyte *commands); +GLAPI void APIENTRY glGetPathCoordsNV (GLuint path, GLfloat *coords); +GLAPI void APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray); +GLAPI void APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +GLAPI void APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +GLAPI void APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +GLAPI GLboolean APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y); +GLAPI GLboolean APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y); +GLAPI GLfloat APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments); +GLAPI GLboolean APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +GLAPI void APIENTRY glMatrixLoad3x2fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoad3x3fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoadTranspose3x3fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMult3x2fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMult3x3fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultTranspose3x3fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glStencilThenCoverFillPathNV (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); +GLAPI void APIENTRY glStencilThenCoverStrokePathNV (GLuint path, GLint reference, GLuint mask, GLenum coverMode); +GLAPI void APIENTRY glStencilThenCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glStencilThenCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI GLenum APIENTRY glPathGlyphIndexRangeNV (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint baseAndCount[2]); +GLAPI GLenum APIENTRY glPathGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI GLenum APIENTRY glPathMemoryGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glProgramPathFragmentInputGenNV (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); +GLAPI void APIENTRY glGetProgramResourcefvNV (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLfloat *params); +#endif +#endif /* GL_NV_path_rendering */ + +#ifndef GL_NV_path_rendering_shared_edge +#define GL_NV_path_rendering_shared_edge 1 +#define GL_SHARED_EDGE_NV 0xC0 +#endif /* GL_NV_path_rendering_shared_edge */ + +#ifndef GL_NV_representative_fragment_test +#define GL_NV_representative_fragment_test 1 +#define GL_REPRESENTATIVE_FRAGMENT_TEST_NV 0x937F +#endif /* GL_NV_representative_fragment_test */ + +#ifndef GL_NV_sample_locations +#define GL_NV_sample_locations 1 +#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_NV 0x933D +#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_NV 0x933E +#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_NV 0x933F +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_NV 0x9340 +#define GL_SAMPLE_LOCATION_NV 0x8E50 +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9341 +#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_NV 0x9342 +#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_NV 0x9343 +typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLRESOLVEDEPTHVALUESNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferSampleLocationsfvNV (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glNamedFramebufferSampleLocationsfvNV (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glResolveDepthValuesNV (void); +#endif +#endif /* GL_NV_sample_locations */ + +#ifndef GL_NV_sample_mask_override_coverage +#define GL_NV_sample_mask_override_coverage 1 +#endif /* GL_NV_sample_mask_override_coverage */ + +#ifndef GL_NV_scissor_exclusive +#define GL_NV_scissor_exclusive 1 +#define GL_SCISSOR_TEST_EXCLUSIVE_NV 0x9555 +#define GL_SCISSOR_BOX_EXCLUSIVE_NV 0x9556 +typedef void (APIENTRYP PFNGLSCISSOREXCLUSIVENVPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLSCISSOREXCLUSIVEARRAYVNVPROC) (GLuint first, GLsizei count, const GLint *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glScissorExclusiveNV (GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glScissorExclusiveArrayvNV (GLuint first, GLsizei count, const GLint *v); +#endif +#endif /* GL_NV_scissor_exclusive */ + +#ifndef GL_NV_shader_atomic_counters +#define GL_NV_shader_atomic_counters 1 +#endif /* GL_NV_shader_atomic_counters */ + +#ifndef GL_NV_shader_atomic_float +#define GL_NV_shader_atomic_float 1 +#endif /* GL_NV_shader_atomic_float */ + +#ifndef GL_NV_shader_atomic_float64 +#define GL_NV_shader_atomic_float64 1 +#endif /* GL_NV_shader_atomic_float64 */ + +#ifndef GL_NV_shader_atomic_fp16_vector +#define GL_NV_shader_atomic_fp16_vector 1 +#endif /* GL_NV_shader_atomic_fp16_vector */ + +#ifndef GL_NV_shader_atomic_int64 +#define GL_NV_shader_atomic_int64 1 +#endif /* GL_NV_shader_atomic_int64 */ + +#ifndef GL_NV_shader_buffer_load +#define GL_NV_shader_buffer_load 1 +#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D +#define GL_GPU_ADDRESS_NV 0x8F34 +#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 +typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access); +typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); +typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer); +typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result); +typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access); +GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target); +GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target); +GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access); +GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer); +GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer); +GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result); +GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value); +GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params); +GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value); +GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif +#endif /* GL_NV_shader_buffer_load */ + +#ifndef GL_NV_shader_buffer_store +#define GL_NV_shader_buffer_store 1 +#define GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010 +#endif /* GL_NV_shader_buffer_store */ + +#ifndef GL_NV_shader_subgroup_partitioned +#define GL_NV_shader_subgroup_partitioned 1 +#define GL_SUBGROUP_FEATURE_PARTITIONED_BIT_NV 0x00000100 +#endif /* GL_NV_shader_subgroup_partitioned */ + +#ifndef GL_NV_shader_texture_footprint +#define GL_NV_shader_texture_footprint 1 +#endif /* GL_NV_shader_texture_footprint */ + +#ifndef GL_NV_shader_thread_group +#define GL_NV_shader_thread_group 1 +#define GL_WARP_SIZE_NV 0x9339 +#define GL_WARPS_PER_SM_NV 0x933A +#define GL_SM_COUNT_NV 0x933B +#endif /* GL_NV_shader_thread_group */ + +#ifndef GL_NV_shader_thread_shuffle +#define GL_NV_shader_thread_shuffle 1 +#endif /* GL_NV_shader_thread_shuffle */ + +#ifndef GL_NV_shading_rate_image +#define GL_NV_shading_rate_image 1 +#define GL_SHADING_RATE_IMAGE_NV 0x9563 +#define GL_SHADING_RATE_NO_INVOCATIONS_NV 0x9564 +#define GL_SHADING_RATE_1_INVOCATION_PER_PIXEL_NV 0x9565 +#define GL_SHADING_RATE_1_INVOCATION_PER_1X2_PIXELS_NV 0x9566 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X1_PIXELS_NV 0x9567 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X2_PIXELS_NV 0x9568 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X4_PIXELS_NV 0x9569 +#define GL_SHADING_RATE_1_INVOCATION_PER_4X2_PIXELS_NV 0x956A +#define GL_SHADING_RATE_1_INVOCATION_PER_4X4_PIXELS_NV 0x956B +#define GL_SHADING_RATE_2_INVOCATIONS_PER_PIXEL_NV 0x956C +#define GL_SHADING_RATE_4_INVOCATIONS_PER_PIXEL_NV 0x956D +#define GL_SHADING_RATE_8_INVOCATIONS_PER_PIXEL_NV 0x956E +#define GL_SHADING_RATE_16_INVOCATIONS_PER_PIXEL_NV 0x956F +#define GL_SHADING_RATE_IMAGE_BINDING_NV 0x955B +#define GL_SHADING_RATE_IMAGE_TEXEL_WIDTH_NV 0x955C +#define GL_SHADING_RATE_IMAGE_TEXEL_HEIGHT_NV 0x955D +#define GL_SHADING_RATE_IMAGE_PALETTE_SIZE_NV 0x955E +#define GL_MAX_COARSE_FRAGMENT_SAMPLES_NV 0x955F +#define GL_SHADING_RATE_SAMPLE_ORDER_DEFAULT_NV 0x95AE +#define GL_SHADING_RATE_SAMPLE_ORDER_PIXEL_MAJOR_NV 0x95AF +#define GL_SHADING_RATE_SAMPLE_ORDER_SAMPLE_MAJOR_NV 0x95B0 +typedef void (APIENTRYP PFNGLBINDSHADINGRATEIMAGENVPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLGETSHADINGRATEIMAGEPALETTENVPROC) (GLuint viewport, GLuint entry, GLenum *rate); +typedef void (APIENTRYP PFNGLGETSHADINGRATESAMPLELOCATIONIVNVPROC) (GLenum rate, GLuint samples, GLuint index, GLint *location); +typedef void (APIENTRYP PFNGLSHADINGRATEIMAGEBARRIERNVPROC) (GLboolean synchronize); +typedef void (APIENTRYP PFNGLSHADINGRATEIMAGEPALETTENVPROC) (GLuint viewport, GLuint first, GLsizei count, const GLenum *rates); +typedef void (APIENTRYP PFNGLSHADINGRATESAMPLEORDERNVPROC) (GLenum order); +typedef void (APIENTRYP PFNGLSHADINGRATESAMPLEORDERCUSTOMNVPROC) (GLenum rate, GLuint samples, const GLint *locations); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindShadingRateImageNV (GLuint texture); +GLAPI void APIENTRY glGetShadingRateImagePaletteNV (GLuint viewport, GLuint entry, GLenum *rate); +GLAPI void APIENTRY glGetShadingRateSampleLocationivNV (GLenum rate, GLuint samples, GLuint index, GLint *location); +GLAPI void APIENTRY glShadingRateImageBarrierNV (GLboolean synchronize); +GLAPI void APIENTRY glShadingRateImagePaletteNV (GLuint viewport, GLuint first, GLsizei count, const GLenum *rates); +GLAPI void APIENTRY glShadingRateSampleOrderNV (GLenum order); +GLAPI void APIENTRY glShadingRateSampleOrderCustomNV (GLenum rate, GLuint samples, const GLint *locations); +#endif +#endif /* GL_NV_shading_rate_image */ + +#ifndef GL_NV_stereo_view_rendering +#define GL_NV_stereo_view_rendering 1 +#endif /* GL_NV_stereo_view_rendering */ + +#ifndef GL_NV_texture_barrier +#define GL_NV_texture_barrier 1 +typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureBarrierNV (void); +#endif +#endif /* GL_NV_texture_barrier */ + +#ifndef GL_NV_texture_rectangle_compressed +#define GL_NV_texture_rectangle_compressed 1 +#endif /* GL_NV_texture_rectangle_compressed */ + +#ifndef GL_NV_uniform_buffer_unified_memory +#define GL_NV_uniform_buffer_unified_memory 1 +#define GL_UNIFORM_BUFFER_UNIFIED_NV 0x936E +#define GL_UNIFORM_BUFFER_ADDRESS_NV 0x936F +#define GL_UNIFORM_BUFFER_LENGTH_NV 0x9370 +#endif /* GL_NV_uniform_buffer_unified_memory */ + +#ifndef GL_NV_vertex_attrib_integer_64bit +#define GL_NV_vertex_attrib_integer_64bit 1 +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1i64NV (GLuint index, GLint64EXT x); +GLAPI void APIENTRY glVertexAttribL2i64NV (GLuint index, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glVertexAttribL3i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glVertexAttribL4i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glVertexAttribL1i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL1ui64NV (GLuint index, GLuint64EXT x); +GLAPI void APIENTRY glVertexAttribL2ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glVertexAttribL3ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glVertexAttribL4ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glVertexAttribL1ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glGetVertexAttribLi64vNV (GLuint index, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVertexAttribLui64vNV (GLuint index, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glVertexAttribLFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +#endif +#endif /* GL_NV_vertex_attrib_integer_64bit */ + +#ifndef GL_NV_vertex_buffer_unified_memory +#define GL_NV_vertex_buffer_unified_memory 1 +#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E +#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F +#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 +#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 +#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 +#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 +#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 +#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 +#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 +#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 +#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 +#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 +#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A +#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B +#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C +#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D +#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E +#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F +#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 +#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 +#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 +#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 +#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 +#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 +#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 +typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride); +GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result); +#endif +#endif /* GL_NV_vertex_buffer_unified_memory */ + +#ifndef GL_NV_viewport_array2 +#define GL_NV_viewport_array2 1 +#endif /* GL_NV_viewport_array2 */ + +#ifndef GL_NV_viewport_swizzle +#define GL_NV_viewport_swizzle 1 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_X_NV 0x9350 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_X_NV 0x9351 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_Y_NV 0x9352 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_Y_NV 0x9353 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_Z_NV 0x9354 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_Z_NV 0x9355 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_W_NV 0x9356 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_W_NV 0x9357 +#define GL_VIEWPORT_SWIZZLE_X_NV 0x9358 +#define GL_VIEWPORT_SWIZZLE_Y_NV 0x9359 +#define GL_VIEWPORT_SWIZZLE_Z_NV 0x935A +#define GL_VIEWPORT_SWIZZLE_W_NV 0x935B +typedef void (APIENTRYP PFNGLVIEWPORTSWIZZLENVPROC) (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glViewportSwizzleNV (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); +#endif +#endif /* GL_NV_viewport_swizzle */ + +#ifndef GL_OVR_multiview +#define GL_OVR_multiview 1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR 0x9630 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR 0x9632 +#define GL_MAX_VIEWS_OVR 0x9631 +#define GL_FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR 0x9633 +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferTextureMultiviewOVR (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); +#endif +#endif /* GL_OVR_multiview */ + +#ifndef GL_OVR_multiview2 +#define GL_OVR_multiview2 1 +#endif /* GL_OVR_multiview2 */ + #ifdef __cplusplus } #endif diff --git a/thirdparty/include/GL/glext.h b/thirdparty/include/GL/glext.h index 9dee32469..e7126ce2e 100644 --- a/thirdparty/include/GL/glext.h +++ b/thirdparty/include/GL/glext.h @@ -1,12 +1,12 @@ -#ifndef __glext_h_ -#define __glext_h_ 1 +#ifndef __gl_glext_h_ +#define __gl_glext_h_ 1 #ifdef __cplusplus extern "C" { #endif /* -** Copyright (c) 2013-2014 The Khronos Group Inc. +** Copyright (c) 2013-2018 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the @@ -31,9 +31,7 @@ extern "C" { ** This header is generated from the Khronos OpenGL / OpenGL ES XML ** API Registry. The current version of the Registry, generator scripts ** used to make the header, and the header can be found at -** http://www.opengl.org/registry/ -** -** Khronos $Revision: 27022 $ on $Date: 2014-06-10 08:30:04 -0700 (Tue, 10 Jun 2014) $ +** https://github.com/KhronosGroup/OpenGL-Registry */ #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) @@ -53,7 +51,9 @@ extern "C" { #define GLAPI extern #endif -#define GL_GLEXT_VERSION 20140610 +#define GL_GLEXT_VERSION 20200408 + +#include /* Generated C header for: * API: gl @@ -355,15 +355,17 @@ GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m); #define GL_TEXTURE_FILTER_CONTROL 0x8500 #define GL_DEPTH_TEXTURE_MODE 0x884B #define GL_COMPARE_R_TO_TEXTURE 0x884E -#define GL_FUNC_ADD 0x8006 -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B -#define GL_MIN 0x8007 -#define GL_MAX 0x8008 +#define GL_BLEND_COLOR 0x8005 +#define GL_BLEND_EQUATION 0x8009 #define GL_CONSTANT_COLOR 0x8001 #define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 #define GL_CONSTANT_ALPHA 0x8003 #define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_FUNC_ADD 0x8006 +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_FUNC_SUBTRACT 0x800A +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); @@ -464,9 +466,8 @@ GLAPI void APIENTRY glBlendEquation (GLenum mode); #ifndef GL_VERSION_1_5 #define GL_VERSION_1_5 1 -#include -typedef ptrdiff_t GLsizeiptr; -typedef ptrdiff_t GLintptr; +typedef khronos_ssize_t GLsizeiptr; +typedef khronos_intptr_t GLintptr; #define GL_BUFFER_SIZE 0x8764 #define GL_BUFFER_USAGE 0x8765 #define GL_QUERY_COUNTER_BITS 0x8864 @@ -879,7 +880,7 @@ GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboole #ifndef GL_VERSION_3_0 #define GL_VERSION_3_0 1 -typedef unsigned short GLhalf; +typedef khronos_uint16_t GLhalf; #define GL_COMPARE_REF_TO_TEXTURE 0x884E #define GL_CLIP_DISTANCE0 0x3000 #define GL_CLIP_DISTANCE1 0x3001 @@ -1041,6 +1042,22 @@ typedef unsigned short GLhalf; #define GL_COLOR_ATTACHMENT13 0x8CED #define GL_COLOR_ATTACHMENT14 0x8CEE #define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_COLOR_ATTACHMENT16 0x8CF0 +#define GL_COLOR_ATTACHMENT17 0x8CF1 +#define GL_COLOR_ATTACHMENT18 0x8CF2 +#define GL_COLOR_ATTACHMENT19 0x8CF3 +#define GL_COLOR_ATTACHMENT20 0x8CF4 +#define GL_COLOR_ATTACHMENT21 0x8CF5 +#define GL_COLOR_ATTACHMENT22 0x8CF6 +#define GL_COLOR_ATTACHMENT23 0x8CF7 +#define GL_COLOR_ATTACHMENT24 0x8CF8 +#define GL_COLOR_ATTACHMENT25 0x8CF9 +#define GL_COLOR_ATTACHMENT26 0x8CFA +#define GL_COLOR_ATTACHMENT27 0x8CFB +#define GL_COLOR_ATTACHMENT28 0x8CFC +#define GL_COLOR_ATTACHMENT29 0x8CFD +#define GL_COLOR_ATTACHMENT30 0x8CFE +#define GL_COLOR_ATTACHMENT31 0x8CFF #define GL_DEPTH_ATTACHMENT 0x8D00 #define GL_STENCIL_ATTACHMENT 0x8D20 #define GL_FRAMEBUFFER 0x8D40 @@ -1308,11 +1325,13 @@ GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); #define GL_UNIFORM_BUFFER_START 0x8A29 #define GL_UNIFORM_BUFFER_SIZE 0x8A2A #define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C #define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D #define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E #define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F #define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 #define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 #define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 #define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 #define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 @@ -1331,6 +1350,7 @@ GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); #define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 #define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 #define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 #define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 #define GL_INVALID_INDEX 0xFFFFFFFFu typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); @@ -1364,45 +1384,8 @@ GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIn #ifndef GL_VERSION_3_2 #define GL_VERSION_3_2 1 typedef struct __GLsync *GLsync; -#ifndef GLEXT_64_TYPES_DEFINED -/* This code block is duplicated in glxext.h, so must be protected */ -#define GLEXT_64_TYPES_DEFINED -/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ -/* (as used in the GL_EXT_timer_query extension). */ -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#include -#elif defined(__sun__) || defined(__digital__) -#include -#if defined(__STDC__) -#if defined(__arch64__) || defined(_LP64) -typedef long int int64_t; -typedef unsigned long int uint64_t; -#else -typedef long long int int64_t; -typedef unsigned long long int uint64_t; -#endif /* __arch64__ */ -#endif /* __STDC__ */ -#elif defined( __VMS ) || defined(__sgi) -#include -#elif defined(__SCO__) || defined(__USLC__) -#include -#elif defined(__UNIXOS2__) || defined(__SOL64__) -typedef long int int32_t; -typedef long long int int64_t; -typedef unsigned long long int uint64_t; -#elif defined(_WIN32) && defined(__GNUC__) -#include -#elif defined(_WIN32) -typedef __int32 int32_t; -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; -#else -/* Fallback if nothing above works */ -#include -#endif -#endif -typedef uint64_t GLuint64; -typedef int64_t GLint64; +typedef khronos_uint64_t GLuint64; +typedef khronos_int64_t GLint64; #define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 #define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 #define GL_LINES_ADJACENCY 0x000A @@ -1478,7 +1461,7 @@ typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *data); -typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values); typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); @@ -1498,7 +1481,7 @@ GLAPI void APIENTRY glDeleteSync (GLsync sync); GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *data); -GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values); GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); @@ -1754,8 +1737,8 @@ typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); @@ -1801,8 +1784,8 @@ GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *pa GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); -GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); @@ -2041,6 +2024,10 @@ GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data) #ifndef GL_VERSION_4_2 #define GL_VERSION_4_2 1 +#define GL_COPY_READ_BUFFER_BINDING 0x8F36 +#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 +#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 #define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 #define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 #define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 @@ -2152,7 +2139,7 @@ GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data) typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); -typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint *params); typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); @@ -2165,7 +2152,7 @@ typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum m GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); -GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint *params); GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers); @@ -2212,6 +2199,7 @@ typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum #define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED #define GL_DISPATCH_INDIRECT_BUFFER 0x90EE #define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF +#define GL_COMPUTE_SHADER_BIT 0x00000020 #define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 #define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 #define GL_DEBUG_CALLBACK_FUNCTION 0x8244 @@ -2445,7 +2433,7 @@ typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint64 *params); typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level); typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); @@ -2457,7 +2445,7 @@ typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum typedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params); typedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); -typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLint *params); typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name); typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); typedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); @@ -2489,7 +2477,7 @@ GLAPI void APIENTRY glDispatchComputeIndirect (GLintptr indirect); GLAPI void APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); GLAPI void APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param); GLAPI void APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetInternalformati64v (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +GLAPI void APIENTRY glGetInternalformati64v (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint64 *params); GLAPI void APIENTRY glInvalidateTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); GLAPI void APIENTRY glInvalidateTexImage (GLuint texture, GLint level); GLAPI void APIENTRY glInvalidateBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr length); @@ -2501,7 +2489,7 @@ GLAPI void APIENTRY glMultiDrawElementsIndirect (GLenum mode, GLenum type, const GLAPI void APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params); GLAPI GLuint APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name); GLAPI void APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); -GLAPI void APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +GLAPI void APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLint *params); GLAPI GLint APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name); GLAPI GLint APIENTRY glGetProgramResourceLocationIndex (GLuint program, GLenum programInterface, const GLchar *name); GLAPI void APIENTRY glShaderStorageBlockBinding (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); @@ -2571,10 +2559,333 @@ GLAPI void APIENTRY glBindVertexBuffers (GLuint first, GLsizei count, const GLui #endif #endif /* GL_VERSION_4_4 */ +#ifndef GL_VERSION_4_5 +#define GL_VERSION_4_5 1 +#define GL_CONTEXT_LOST 0x0507 +#define GL_NEGATIVE_ONE_TO_ONE 0x935E +#define GL_ZERO_TO_ONE 0x935F +#define GL_CLIP_ORIGIN 0x935C +#define GL_CLIP_DEPTH_MODE 0x935D +#define GL_QUERY_WAIT_INVERTED 0x8E17 +#define GL_QUERY_NO_WAIT_INVERTED 0x8E18 +#define GL_QUERY_BY_REGION_WAIT_INVERTED 0x8E19 +#define GL_QUERY_BY_REGION_NO_WAIT_INVERTED 0x8E1A +#define GL_MAX_CULL_DISTANCES 0x82F9 +#define GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES 0x82FA +#define GL_TEXTURE_TARGET 0x1006 +#define GL_QUERY_TARGET 0x82EA +#define GL_GUILTY_CONTEXT_RESET 0x8253 +#define GL_INNOCENT_CONTEXT_RESET 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY 0x8256 +#define GL_LOSE_CONTEXT_ON_RESET 0x8252 +#define GL_NO_RESET_NOTIFICATION 0x8261 +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT 0x00000004 +#define GL_CONTEXT_RELEASE_BEHAVIOR 0x82FB +#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82FC +typedef void (APIENTRYP PFNGLCLIPCONTROLPROC) (GLenum origin, GLenum depth); +typedef void (APIENTRYP PFNGLCREATETRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC) (GLuint xfb, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC) (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKIVPROC) (GLuint xfb, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint *param); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI64_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint64 *param); +typedef void (APIENTRYP PFNGLCREATEBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); +typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +typedef void (APIENTRYP PFNGLCOPYNAMEDBUFFERSUBDATAPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERPROC) (GLuint buffer, GLenum access); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERI64VPROC) (GLuint buffer, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVPROC) (GLuint buffer, GLenum pname, void **params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); +typedef void (APIENTRYP PFNGLCREATEFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC) (GLuint framebuffer, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC) (GLuint framebuffer, GLenum buf); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC) (GLuint framebuffer, GLenum src); +typedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments); +typedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFIPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef void (APIENTRYP PFNGLBLITNAMEDFRAMEBUFFERPROC) (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC) (GLuint framebuffer, GLenum target); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC) (GLuint framebuffer, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCREATERENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC) (GLuint renderbuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCREATETEXTURESPROC) (GLenum target, GLsizei n, GLuint *textures); +typedef void (APIENTRYP PFNGLTEXTUREBUFFERPROC) (GLuint texture, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEPROC) (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFPROC) (GLuint texture, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIPROC) (GLuint texture, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLBINDTEXTUREUNITPROC) (GLuint unit, GLuint texture); +typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVPROC) (GLuint texture, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVPROC) (GLuint texture, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCREATEVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLVERTEXARRAYELEMENTBUFFERPROC) (GLuint vaobj, GLuint buffer); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERSPROC) (GLuint vaobj, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBBINDINGPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBIFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBLFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYBINDINGDIVISORPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYIVPROC) (GLuint vaobj, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINDEXEDIVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINDEXED64IVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint64 *param); +typedef void (APIENTRYP PFNGLCREATESAMPLERSPROC) (GLsizei n, GLuint *samplers); +typedef void (APIENTRYP PFNGLCREATEPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); +typedef void (APIENTRYP PFNGLCREATEQUERIESPROC) (GLenum target, GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTI64VPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTIVPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTUI64VPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTUIVPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void (APIENTRYP PFNGLMEMORYBARRIERBYREGIONPROC) (GLbitfield barriers); +typedef void (APIENTRYP PFNGLGETTEXTURESUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void *pixels); +typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSPROC) (void); +typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint lod, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETNTEXIMAGEPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETNUNIFORMDVPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMFVPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +typedef void (APIENTRYP PFNGLREADNPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +typedef void (APIENTRYP PFNGLGETNMAPDVPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +typedef void (APIENTRYP PFNGLGETNMAPFVPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +typedef void (APIENTRYP PFNGLGETNMAPIVPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +typedef void (APIENTRYP PFNGLGETNPIXELMAPFVPROC) (GLenum map, GLsizei bufSize, GLfloat *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVPROC) (GLenum map, GLsizei bufSize, GLuint *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVPROC) (GLenum map, GLsizei bufSize, GLushort *values); +typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEPROC) (GLsizei bufSize, GLubyte *pattern); +typedef void (APIENTRYP PFNGLGETNCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); +typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); +typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); +typedef void (APIENTRYP PFNGLGETNHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +typedef void (APIENTRYP PFNGLGETNMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +typedef void (APIENTRYP PFNGLTEXTUREBARRIERPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClipControl (GLenum origin, GLenum depth); +GLAPI void APIENTRY glCreateTransformFeedbacks (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glTransformFeedbackBufferBase (GLuint xfb, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackBufferRange (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glGetTransformFeedbackiv (GLuint xfb, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetTransformFeedbacki_v (GLuint xfb, GLenum pname, GLuint index, GLint *param); +GLAPI void APIENTRY glGetTransformFeedbacki64_v (GLuint xfb, GLenum pname, GLuint index, GLint64 *param); +GLAPI void APIENTRY glCreateBuffers (GLsizei n, GLuint *buffers); +GLAPI void APIENTRY glNamedBufferStorage (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); +GLAPI void APIENTRY glNamedBufferData (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); +GLAPI void APIENTRY glNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void APIENTRY glCopyNamedBufferSubData (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glClearNamedBufferData (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearNamedBufferSubData (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void *APIENTRY glMapNamedBuffer (GLuint buffer, GLenum access); +GLAPI void *APIENTRY glMapNamedBufferRange (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI GLboolean APIENTRY glUnmapNamedBuffer (GLuint buffer); +GLAPI void APIENTRY glFlushMappedNamedBufferRange (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glGetNamedBufferParameteriv (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedBufferParameteri64v (GLuint buffer, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetNamedBufferPointerv (GLuint buffer, GLenum pname, void **params); +GLAPI void APIENTRY glGetNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); +GLAPI void APIENTRY glCreateFramebuffers (GLsizei n, GLuint *framebuffers); +GLAPI void APIENTRY glNamedFramebufferRenderbuffer (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glNamedFramebufferParameteri (GLuint framebuffer, GLenum pname, GLint param); +GLAPI void APIENTRY glNamedFramebufferTexture (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTextureLayer (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glNamedFramebufferDrawBuffer (GLuint framebuffer, GLenum buf); +GLAPI void APIENTRY glNamedFramebufferDrawBuffers (GLuint framebuffer, GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glNamedFramebufferReadBuffer (GLuint framebuffer, GLenum src); +GLAPI void APIENTRY glInvalidateNamedFramebufferData (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments); +GLAPI void APIENTRY glInvalidateNamedFramebufferSubData (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glClearNamedFramebufferiv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value); +GLAPI void APIENTRY glClearNamedFramebufferuiv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint *value); +GLAPI void APIENTRY glClearNamedFramebufferfv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value); +GLAPI void APIENTRY glClearNamedFramebufferfi (GLuint framebuffer, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GLAPI void APIENTRY glBlitNamedFramebuffer (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI GLenum APIENTRY glCheckNamedFramebufferStatus (GLuint framebuffer, GLenum target); +GLAPI void APIENTRY glGetNamedFramebufferParameteriv (GLuint framebuffer, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameteriv (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glCreateRenderbuffers (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glNamedRenderbufferStorage (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisample (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetNamedRenderbufferParameteriv (GLuint renderbuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glCreateTextures (GLenum target, GLsizei n, GLuint *textures); +GLAPI void APIENTRY glTextureBuffer (GLuint texture, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glTextureBufferRange (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTextureStorage1D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTextureStorage2D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureStorage3D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glTextureStorage2DMultisample (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage3DMultisample (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCompressedTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCopyTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glCopyTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureParameterf (GLuint texture, GLenum pname, GLfloat param); +GLAPI void APIENTRY glTextureParameterfv (GLuint texture, GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glTextureParameteri (GLuint texture, GLenum pname, GLint param); +GLAPI void APIENTRY glTextureParameterIiv (GLuint texture, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureParameterIuiv (GLuint texture, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glTextureParameteriv (GLuint texture, GLenum pname, const GLint *param); +GLAPI void APIENTRY glGenerateTextureMipmap (GLuint texture); +GLAPI void APIENTRY glBindTextureUnit (GLuint unit, GLuint texture); +GLAPI void APIENTRY glGetTextureImage (GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetCompressedTextureImage (GLuint texture, GLint level, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetTextureLevelParameterfv (GLuint texture, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureLevelParameteriv (GLuint texture, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureParameterfv (GLuint texture, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureParameterIiv (GLuint texture, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureParameterIuiv (GLuint texture, GLenum pname, GLuint *params); +GLAPI void APIENTRY glGetTextureParameteriv (GLuint texture, GLenum pname, GLint *params); +GLAPI void APIENTRY glCreateVertexArrays (GLsizei n, GLuint *arrays); +GLAPI void APIENTRY glDisableVertexArrayAttrib (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glEnableVertexArrayAttrib (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glVertexArrayElementBuffer (GLuint vaobj, GLuint buffer); +GLAPI void APIENTRY glVertexArrayVertexBuffer (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexArrayVertexBuffers (GLuint vaobj, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +GLAPI void APIENTRY glVertexArrayAttribBinding (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexArrayAttribFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayAttribIFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayAttribLFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayBindingDivisor (GLuint vaobj, GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glGetVertexArrayiv (GLuint vaobj, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayIndexediv (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayIndexed64iv (GLuint vaobj, GLuint index, GLenum pname, GLint64 *param); +GLAPI void APIENTRY glCreateSamplers (GLsizei n, GLuint *samplers); +GLAPI void APIENTRY glCreateProgramPipelines (GLsizei n, GLuint *pipelines); +GLAPI void APIENTRY glCreateQueries (GLenum target, GLsizei n, GLuint *ids); +GLAPI void APIENTRY glGetQueryBufferObjecti64v (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +GLAPI void APIENTRY glGetQueryBufferObjectiv (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +GLAPI void APIENTRY glGetQueryBufferObjectui64v (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +GLAPI void APIENTRY glGetQueryBufferObjectuiv (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +GLAPI void APIENTRY glMemoryBarrierByRegion (GLbitfield barriers); +GLAPI void APIENTRY glGetTextureSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetCompressedTextureSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void *pixels); +GLAPI GLenum APIENTRY glGetGraphicsResetStatus (void); +GLAPI void APIENTRY glGetnCompressedTexImage (GLenum target, GLint lod, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetnTexImage (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetnUniformdv (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +GLAPI void APIENTRY glGetnUniformfv (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GLAPI void APIENTRY glGetnUniformiv (GLuint program, GLint location, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetnUniformuiv (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +GLAPI void APIENTRY glReadnPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +GLAPI void APIENTRY glGetnMapdv (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +GLAPI void APIENTRY glGetnMapfv (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +GLAPI void APIENTRY glGetnMapiv (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +GLAPI void APIENTRY glGetnPixelMapfv (GLenum map, GLsizei bufSize, GLfloat *values); +GLAPI void APIENTRY glGetnPixelMapuiv (GLenum map, GLsizei bufSize, GLuint *values); +GLAPI void APIENTRY glGetnPixelMapusv (GLenum map, GLsizei bufSize, GLushort *values); +GLAPI void APIENTRY glGetnPolygonStipple (GLsizei bufSize, GLubyte *pattern); +GLAPI void APIENTRY glGetnColorTable (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); +GLAPI void APIENTRY glGetnConvolutionFilter (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); +GLAPI void APIENTRY glGetnSeparableFilter (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); +GLAPI void APIENTRY glGetnHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +GLAPI void APIENTRY glGetnMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +GLAPI void APIENTRY glTextureBarrier (void); +#endif +#endif /* GL_VERSION_4_5 */ + +#ifndef GL_VERSION_4_6 +#define GL_VERSION_4_6 1 +#define GL_SHADER_BINARY_FORMAT_SPIR_V 0x9551 +#define GL_SPIR_V_BINARY 0x9552 +#define GL_PARAMETER_BUFFER 0x80EE +#define GL_PARAMETER_BUFFER_BINDING 0x80EF +#define GL_CONTEXT_FLAG_NO_ERROR_BIT 0x00000008 +#define GL_VERTICES_SUBMITTED 0x82EE +#define GL_PRIMITIVES_SUBMITTED 0x82EF +#define GL_VERTEX_SHADER_INVOCATIONS 0x82F0 +#define GL_TESS_CONTROL_SHADER_PATCHES 0x82F1 +#define GL_TESS_EVALUATION_SHADER_INVOCATIONS 0x82F2 +#define GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED 0x82F3 +#define GL_FRAGMENT_SHADER_INVOCATIONS 0x82F4 +#define GL_COMPUTE_SHADER_INVOCATIONS 0x82F5 +#define GL_CLIPPING_INPUT_PRIMITIVES 0x82F6 +#define GL_CLIPPING_OUTPUT_PRIMITIVES 0x82F7 +#define GL_POLYGON_OFFSET_CLAMP 0x8E1B +#define GL_SPIR_V_EXTENSIONS 0x9553 +#define GL_NUM_SPIR_V_EXTENSIONS 0x9554 +#define GL_TEXTURE_MAX_ANISOTROPY 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY 0x84FF +#define GL_TRANSFORM_FEEDBACK_OVERFLOW 0x82EC +#define GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW 0x82ED +typedef void (APIENTRYP PFNGLSPECIALIZESHADERPROC) (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTPROC) (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTPROC) (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLPOLYGONOFFSETCLAMPPROC) (GLfloat factor, GLfloat units, GLfloat clamp); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpecializeShader (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +GLAPI void APIENTRY glMultiDrawArraysIndirectCount (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectCount (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glPolygonOffsetClamp (GLfloat factor, GLfloat units, GLfloat clamp); +#endif +#endif /* GL_VERSION_4_6 */ + #ifndef GL_ARB_ES2_compatibility #define GL_ARB_ES2_compatibility 1 #endif /* GL_ARB_ES2_compatibility */ +#ifndef GL_ARB_ES3_1_compatibility +#define GL_ARB_ES3_1_compatibility 1 +#endif /* GL_ARB_ES3_1_compatibility */ + +#ifndef GL_ARB_ES3_2_compatibility +#define GL_ARB_ES3_2_compatibility 1 +#define GL_PRIMITIVE_BOUNDING_BOX_ARB 0x92BE +#define GL_MULTISAMPLE_LINE_WIDTH_RANGE_ARB 0x9381 +#define GL_MULTISAMPLE_LINE_WIDTH_GRANULARITY_ARB 0x9382 +typedef void (APIENTRYP PFNGLPRIMITIVEBOUNDINGBOXARBPROC) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveBoundingBoxARB (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#endif +#endif /* GL_ARB_ES3_2_compatibility */ + #ifndef GL_ARB_ES3_compatibility #define GL_ARB_ES3_compatibility 1 #endif /* GL_ARB_ES3_compatibility */ @@ -2589,7 +2900,7 @@ GLAPI void APIENTRY glBindVertexBuffers (GLuint first, GLsizei count, const GLui #ifndef GL_ARB_bindless_texture #define GL_ARB_bindless_texture 1 -typedef uint64_t GLuint64EXT; +typedef khronos_uint64_t GLuint64EXT; #define GL_UNSIGNED_INT64_ARB 0x140F typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLEARBPROC) (GLuint texture); typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLEARBPROC) (GLuint texture, GLuint sampler); @@ -2655,6 +2966,10 @@ GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context *context, s #define GL_ARB_clear_texture 1 #endif /* GL_ARB_clear_texture */ +#ifndef GL_ARB_clip_control +#define GL_ARB_clip_control 1 +#endif /* GL_ARB_clip_control */ + #ifndef GL_ARB_color_buffer_float #define GL_ARB_color_buffer_float 1 #define GL_RGBA_FLOAT_MODE_ARB 0x8820 @@ -2678,7 +2993,6 @@ GLAPI void APIENTRY glClampColorARB (GLenum target, GLenum clamp); #ifndef GL_ARB_compute_shader #define GL_ARB_compute_shader 1 -#define GL_COMPUTE_SHADER_BIT 0x00000020 #endif /* GL_ARB_compute_shader */ #ifndef GL_ARB_compute_variable_group_size @@ -2693,20 +3007,26 @@ GLAPI void APIENTRY glDispatchComputeGroupSizeARB (GLuint num_groups_x, GLuint n #endif #endif /* GL_ARB_compute_variable_group_size */ +#ifndef GL_ARB_conditional_render_inverted +#define GL_ARB_conditional_render_inverted 1 +#endif /* GL_ARB_conditional_render_inverted */ + #ifndef GL_ARB_conservative_depth #define GL_ARB_conservative_depth 1 #endif /* GL_ARB_conservative_depth */ #ifndef GL_ARB_copy_buffer #define GL_ARB_copy_buffer 1 -#define GL_COPY_READ_BUFFER_BINDING 0x8F36 -#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 #endif /* GL_ARB_copy_buffer */ #ifndef GL_ARB_copy_image #define GL_ARB_copy_image 1 #endif /* GL_ARB_copy_image */ +#ifndef GL_ARB_cull_distance +#define GL_ARB_cull_distance 1 +#endif /* GL_ARB_cull_distance */ + #ifndef GL_ARB_debug_output #define GL_ARB_debug_output 1 typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); @@ -2761,6 +3081,14 @@ GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufSize, GL #define GL_DEPTH_TEXTURE_MODE_ARB 0x884B #endif /* GL_ARB_depth_texture */ +#ifndef GL_ARB_derivative_control +#define GL_ARB_derivative_control 1 +#endif /* GL_ARB_derivative_control */ + +#ifndef GL_ARB_direct_state_access +#define GL_ARB_direct_state_access 1 +#endif /* GL_ARB_direct_state_access */ + #ifndef GL_ARB_draw_buffers #define GL_ARB_draw_buffers 1 #define GL_MAX_DRAW_BUFFERS_ARB 0x8824 @@ -2971,6 +3299,10 @@ GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program); #define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B #endif /* GL_ARB_fragment_shader */ +#ifndef GL_ARB_fragment_shader_interlock +#define GL_ARB_fragment_shader_interlock 1 +#endif /* GL_ARB_fragment_shader_interlock */ + #ifndef GL_ARB_framebuffer_no_attachments #define GL_ARB_framebuffer_no_attachments 1 #endif /* GL_ARB_framebuffer_no_attachments */ @@ -3019,6 +3351,20 @@ GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachmen #define GL_ARB_get_program_binary 1 #endif /* GL_ARB_get_program_binary */ +#ifndef GL_ARB_get_texture_sub_image +#define GL_ARB_get_texture_sub_image 1 +#endif /* GL_ARB_get_texture_sub_image */ + +#ifndef GL_ARB_gl_spirv +#define GL_ARB_gl_spirv 1 +#define GL_SHADER_BINARY_FORMAT_SPIR_V_ARB 0x9551 +#define GL_SPIR_V_BINARY_ARB 0x9552 +typedef void (APIENTRYP PFNGLSPECIALIZESHADERARBPROC) (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpecializeShaderARB (GLuint shader, const GLchar *pEntryPoint, GLuint numSpecializationConstants, const GLuint *pConstantIndex, const GLuint *pConstantValue); +#endif +#endif /* GL_ARB_gl_spirv */ + #ifndef GL_ARB_gpu_shader5 #define GL_ARB_gpu_shader5 1 #endif /* GL_ARB_gpu_shader5 */ @@ -3027,9 +3373,94 @@ GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachmen #define GL_ARB_gpu_shader_fp64 1 #endif /* GL_ARB_gpu_shader_fp64 */ +#ifndef GL_ARB_gpu_shader_int64 +#define GL_ARB_gpu_shader_int64 1 +#define GL_INT64_ARB 0x140E +#define GL_INT64_VEC2_ARB 0x8FE9 +#define GL_INT64_VEC3_ARB 0x8FEA +#define GL_INT64_VEC4_ARB 0x8FEB +#define GL_UNSIGNED_INT64_VEC2_ARB 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_ARB 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_ARB 0x8FF7 +typedef void (APIENTRYP PFNGLUNIFORM1I64ARBPROC) (GLint location, GLint64 x); +typedef void (APIENTRYP PFNGLUNIFORM2I64ARBPROC) (GLint location, GLint64 x, GLint64 y); +typedef void (APIENTRYP PFNGLUNIFORM3I64ARBPROC) (GLint location, GLint64 x, GLint64 y, GLint64 z); +typedef void (APIENTRYP PFNGLUNIFORM4I64ARBPROC) (GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +typedef void (APIENTRYP PFNGLUNIFORM1I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM2I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM3I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM4I64VARBPROC) (GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM1UI64ARBPROC) (GLint location, GLuint64 x); +typedef void (APIENTRYP PFNGLUNIFORM2UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y); +typedef void (APIENTRYP PFNGLUNIFORM3UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +typedef void (APIENTRYP PFNGLUNIFORM4UI64ARBPROC) (GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +typedef void (APIENTRYP PFNGLUNIFORM1UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM2UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM3UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLUNIFORM4UI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLGETUNIFORMI64VARBPROC) (GLuint program, GLint location, GLint64 *params); +typedef void (APIENTRYP PFNGLGETUNIFORMUI64VARBPROC) (GLuint program, GLint location, GLuint64 *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMI64VARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint64 *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUI64VARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint64 *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64ARBPROC) (GLuint program, GLint location, GLint64 x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64ARBPROC) (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64ARBPROC) (GLuint program, GLint location, GLuint64 x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64ARBPROC) (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniform1i64ARB (GLint location, GLint64 x); +GLAPI void APIENTRY glUniform2i64ARB (GLint location, GLint64 x, GLint64 y); +GLAPI void APIENTRY glUniform3i64ARB (GLint location, GLint64 x, GLint64 y, GLint64 z); +GLAPI void APIENTRY glUniform4i64ARB (GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +GLAPI void APIENTRY glUniform1i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform2i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform3i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform4i64vARB (GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glUniform1ui64ARB (GLint location, GLuint64 x); +GLAPI void APIENTRY glUniform2ui64ARB (GLint location, GLuint64 x, GLuint64 y); +GLAPI void APIENTRY glUniform3ui64ARB (GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +GLAPI void APIENTRY glUniform4ui64ARB (GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +GLAPI void APIENTRY glUniform1ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glUniform2ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glUniform3ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glUniform4ui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glGetUniformi64vARB (GLuint program, GLint location, GLint64 *params); +GLAPI void APIENTRY glGetUniformui64vARB (GLuint program, GLint location, GLuint64 *params); +GLAPI void APIENTRY glGetnUniformi64vARB (GLuint program, GLint location, GLsizei bufSize, GLint64 *params); +GLAPI void APIENTRY glGetnUniformui64vARB (GLuint program, GLint location, GLsizei bufSize, GLuint64 *params); +GLAPI void APIENTRY glProgramUniform1i64ARB (GLuint program, GLint location, GLint64 x); +GLAPI void APIENTRY glProgramUniform2i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y); +GLAPI void APIENTRY glProgramUniform3i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z); +GLAPI void APIENTRY glProgramUniform4i64ARB (GLuint program, GLint location, GLint64 x, GLint64 y, GLint64 z, GLint64 w); +GLAPI void APIENTRY glProgramUniform1i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform2i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform3i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform4i64vARB (GLuint program, GLint location, GLsizei count, const GLint64 *value); +GLAPI void APIENTRY glProgramUniform1ui64ARB (GLuint program, GLint location, GLuint64 x); +GLAPI void APIENTRY glProgramUniform2ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y); +GLAPI void APIENTRY glProgramUniform3ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z); +GLAPI void APIENTRY glProgramUniform4ui64ARB (GLuint program, GLint location, GLuint64 x, GLuint64 y, GLuint64 z, GLuint64 w); +GLAPI void APIENTRY glProgramUniform1ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniform2ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniform3ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniform4ui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *value); +#endif +#endif /* GL_ARB_gpu_shader_int64 */ + #ifndef GL_ARB_half_float_pixel #define GL_ARB_half_float_pixel 1 -typedef unsigned short GLhalfARB; +typedef khronos_uint16_t GLhalfARB; #define GL_HALF_FLOAT_ARB 0x140B #endif /* GL_ARB_half_float_pixel */ @@ -3039,8 +3470,6 @@ typedef unsigned short GLhalfARB; #ifndef GL_ARB_imaging #define GL_ARB_imaging 1 -#define GL_BLEND_COLOR 0x8005 -#define GL_BLEND_EQUATION 0x8009 #define GL_CONVOLUTION_1D 0x8010 #define GL_CONVOLUTION_2D 0x8011 #define GL_SEPARABLE_2D 0x8012 @@ -3177,11 +3606,11 @@ GLAPI void APIENTRY glResetMinmax (GLenum target); #define GL_ARB_indirect_parameters 1 #define GL_PARAMETER_BUFFER_ARB 0x80EE #define GL_PARAMETER_BUFFER_BINDING_ARB 0x80EF -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC) (GLenum mode, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC) (GLenum mode, GLenum type, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC) (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC) (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysIndirectCountARB (GLenum mode, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); -GLAPI void APIENTRY glMultiDrawElementsIndirectCountARB (GLenum mode, GLenum type, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawArraysIndirectCountARB (GLenum mode, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectCountARB (GLenum mode, GLenum type, const void *indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); #endif #endif /* GL_ARB_indirect_parameters */ @@ -3201,6 +3630,25 @@ GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor); #ifndef GL_ARB_internalformat_query2 #define GL_ARB_internalformat_query2 1 #define GL_SRGB_DECODE_ARB 0x8299 +#define GL_VIEW_CLASS_EAC_R11 0x9383 +#define GL_VIEW_CLASS_EAC_RG11 0x9384 +#define GL_VIEW_CLASS_ETC2_RGB 0x9385 +#define GL_VIEW_CLASS_ETC2_RGBA 0x9386 +#define GL_VIEW_CLASS_ETC2_EAC_RGBA 0x9387 +#define GL_VIEW_CLASS_ASTC_4x4_RGBA 0x9388 +#define GL_VIEW_CLASS_ASTC_5x4_RGBA 0x9389 +#define GL_VIEW_CLASS_ASTC_5x5_RGBA 0x938A +#define GL_VIEW_CLASS_ASTC_6x5_RGBA 0x938B +#define GL_VIEW_CLASS_ASTC_6x6_RGBA 0x938C +#define GL_VIEW_CLASS_ASTC_8x5_RGBA 0x938D +#define GL_VIEW_CLASS_ASTC_8x6_RGBA 0x938E +#define GL_VIEW_CLASS_ASTC_8x8_RGBA 0x938F +#define GL_VIEW_CLASS_ASTC_10x5_RGBA 0x9390 +#define GL_VIEW_CLASS_ASTC_10x6_RGBA 0x9391 +#define GL_VIEW_CLASS_ASTC_10x8_RGBA 0x9392 +#define GL_VIEW_CLASS_ASTC_10x10_RGBA 0x9393 +#define GL_VIEW_CLASS_ASTC_12x10_RGBA 0x9394 +#define GL_VIEW_CLASS_ASTC_12x12_RGBA 0x9395 #endif /* GL_ARB_internalformat_query2 */ #ifndef GL_ARB_invalidate_subdata @@ -3406,6 +3854,30 @@ GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *par #define GL_ARB_occlusion_query2 1 #endif /* GL_ARB_occlusion_query2 */ +#ifndef GL_ARB_parallel_shader_compile +#define GL_ARB_parallel_shader_compile 1 +#define GL_MAX_SHADER_COMPILER_THREADS_ARB 0x91B0 +#define GL_COMPLETION_STATUS_ARB 0x91B1 +typedef void (APIENTRYP PFNGLMAXSHADERCOMPILERTHREADSARBPROC) (GLuint count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMaxShaderCompilerThreadsARB (GLuint count); +#endif +#endif /* GL_ARB_parallel_shader_compile */ + +#ifndef GL_ARB_pipeline_statistics_query +#define GL_ARB_pipeline_statistics_query 1 +#define GL_VERTICES_SUBMITTED_ARB 0x82EE +#define GL_PRIMITIVES_SUBMITTED_ARB 0x82EF +#define GL_VERTEX_SHADER_INVOCATIONS_ARB 0x82F0 +#define GL_TESS_CONTROL_SHADER_PATCHES_ARB 0x82F1 +#define GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB 0x82F2 +#define GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB 0x82F3 +#define GL_FRAGMENT_SHADER_INVOCATIONS_ARB 0x82F4 +#define GL_COMPUTE_SHADER_INVOCATIONS_ARB 0x82F5 +#define GL_CLIPPING_INPUT_PRIMITIVES_ARB 0x82F6 +#define GL_CLIPPING_OUTPUT_PRIMITIVES_ARB 0x82F7 +#endif /* GL_ARB_pipeline_statistics_query */ + #ifndef GL_ARB_pixel_buffer_object #define GL_ARB_pixel_buffer_object 1 #define GL_PIXEL_PACK_BUFFER_ARB 0x88EB @@ -3434,6 +3906,14 @@ GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params); #define GL_COORD_REPLACE_ARB 0x8862 #endif /* GL_ARB_point_sprite */ +#ifndef GL_ARB_polygon_offset_clamp +#define GL_ARB_polygon_offset_clamp 1 +#endif /* GL_ARB_polygon_offset_clamp */ + +#ifndef GL_ARB_post_depth_coverage +#define GL_ARB_post_depth_coverage 1 +#endif /* GL_ARB_post_depth_coverage */ + #ifndef GL_ARB_program_interface_query #define GL_ARB_program_interface_query 1 #endif /* GL_ARB_program_interface_query */ @@ -3507,6 +3987,26 @@ GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum form #define GL_ARB_robustness_isolation 1 #endif /* GL_ARB_robustness_isolation */ +#ifndef GL_ARB_sample_locations +#define GL_ARB_sample_locations 1 +#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_ARB 0x933D +#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_ARB 0x933E +#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_ARB 0x933F +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_ARB 0x9340 +#define GL_SAMPLE_LOCATION_ARB 0x8E50 +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_ARB 0x9341 +#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_ARB 0x9342 +#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_ARB 0x9343 +typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVARBPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLEVALUATEDEPTHVALUESARBPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferSampleLocationsfvARB (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glNamedFramebufferSampleLocationsfvARB (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glEvaluateDepthValuesARB (void); +#endif +#endif /* GL_ARB_sample_locations */ + #ifndef GL_ARB_sample_shading #define GL_ARB_sample_shading 1 #define GL_SAMPLE_SHADING_ARB 0x8C36 @@ -3533,14 +4033,26 @@ GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value); #define GL_ARB_separate_shader_objects 1 #endif /* GL_ARB_separate_shader_objects */ +#ifndef GL_ARB_shader_atomic_counter_ops +#define GL_ARB_shader_atomic_counter_ops 1 +#endif /* GL_ARB_shader_atomic_counter_ops */ + #ifndef GL_ARB_shader_atomic_counters #define GL_ARB_shader_atomic_counters 1 #endif /* GL_ARB_shader_atomic_counters */ +#ifndef GL_ARB_shader_ballot +#define GL_ARB_shader_ballot 1 +#endif /* GL_ARB_shader_ballot */ + #ifndef GL_ARB_shader_bit_encoding #define GL_ARB_shader_bit_encoding 1 #endif /* GL_ARB_shader_bit_encoding */ +#ifndef GL_ARB_shader_clock +#define GL_ARB_shader_clock 1 +#endif /* GL_ARB_shader_clock */ + #ifndef GL_ARB_shader_draw_parameters #define GL_ARB_shader_draw_parameters 1 #endif /* GL_ARB_shader_draw_parameters */ @@ -3697,10 +4209,18 @@ GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GL #define GL_ARB_shader_subroutine 1 #endif /* GL_ARB_shader_subroutine */ +#ifndef GL_ARB_shader_texture_image_samples +#define GL_ARB_shader_texture_image_samples 1 +#endif /* GL_ARB_shader_texture_image_samples */ + #ifndef GL_ARB_shader_texture_lod #define GL_ARB_shader_texture_lod 1 #endif /* GL_ARB_shader_texture_lod */ +#ifndef GL_ARB_shader_viewport_layer_array +#define GL_ARB_shader_viewport_layer_array 1 +#endif /* GL_ARB_shader_viewport_layer_array */ + #ifndef GL_ARB_shading_language_100 #define GL_ARB_shading_language_100 1 #define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C @@ -3747,11 +4267,25 @@ GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GL #define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF #endif /* GL_ARB_shadow_ambient */ +#ifndef GL_ARB_sparse_buffer +#define GL_ARB_sparse_buffer 1 +#define GL_SPARSE_STORAGE_BIT_ARB 0x0400 +#define GL_SPARSE_BUFFER_PAGE_SIZE_ARB 0x82F8 +typedef void (APIENTRYP PFNGLBUFFERPAGECOMMITMENTARBPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLboolean commit); +typedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); +typedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTARBPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferPageCommitmentARB (GLenum target, GLintptr offset, GLsizeiptr size, GLboolean commit); +GLAPI void APIENTRY glNamedBufferPageCommitmentEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); +GLAPI void APIENTRY glNamedBufferPageCommitmentARB (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); +#endif +#endif /* GL_ARB_sparse_buffer */ + #ifndef GL_ARB_sparse_texture #define GL_ARB_sparse_texture 1 #define GL_TEXTURE_SPARSE_ARB 0x91A6 #define GL_VIRTUAL_PAGE_SIZE_INDEX_ARB 0x91A7 -#define GL_MIN_SPARSE_LEVEL_ARB 0x919B +#define GL_NUM_SPARSE_LEVELS_ARB 0x91AA #define GL_NUM_VIRTUAL_PAGE_SIZES_ARB 0x91A8 #define GL_VIRTUAL_PAGE_SIZE_X_ARB 0x9195 #define GL_VIRTUAL_PAGE_SIZE_Y_ARB 0x9196 @@ -3760,12 +4294,24 @@ GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GL #define GL_MAX_SPARSE_3D_TEXTURE_SIZE_ARB 0x9199 #define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_ARB 0x919A #define GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB 0x91A9 -typedef void (APIENTRYP PFNGLTEXPAGECOMMITMENTARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident); +typedef void (APIENTRYP PFNGLTEXPAGECOMMITMENTARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexPageCommitmentARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident); +GLAPI void APIENTRY glTexPageCommitmentARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); #endif #endif /* GL_ARB_sparse_texture */ +#ifndef GL_ARB_sparse_texture2 +#define GL_ARB_sparse_texture2 1 +#endif /* GL_ARB_sparse_texture2 */ + +#ifndef GL_ARB_sparse_texture_clamp +#define GL_ARB_sparse_texture_clamp 1 +#endif /* GL_ARB_sparse_texture_clamp */ + +#ifndef GL_ARB_spirv_extensions +#define GL_ARB_spirv_extensions 1 +#endif /* GL_ARB_spirv_extensions */ + #ifndef GL_ARB_stencil_texturing #define GL_ARB_stencil_texturing 1 #endif /* GL_ARB_stencil_texturing */ @@ -3778,6 +4324,10 @@ GLAPI void APIENTRY glTexPageCommitmentARB (GLenum target, GLint level, GLint xo #define GL_ARB_tessellation_shader 1 #endif /* GL_ARB_tessellation_shader */ +#ifndef GL_ARB_texture_barrier +#define GL_ARB_texture_barrier 1 +#endif /* GL_ARB_texture_barrier */ + #ifndef GL_ARB_texture_border_clamp #define GL_ARB_texture_border_clamp 1 #define GL_CLAMP_TO_BORDER_ARB 0x812D @@ -3914,6 +4464,16 @@ GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, void #define GL_DOT3_RGBA_ARB 0x86AF #endif /* GL_ARB_texture_env_dot3 */ +#ifndef GL_ARB_texture_filter_anisotropic +#define GL_ARB_texture_filter_anisotropic 1 +#endif /* GL_ARB_texture_filter_anisotropic */ + +#ifndef GL_ARB_texture_filter_minmax +#define GL_ARB_texture_filter_minmax 1 +#define GL_TEXTURE_REDUCTION_MODE_ARB 0x9366 +#define GL_WEIGHTED_AVERAGE_ARB 0x9367 +#endif /* GL_ARB_texture_filter_minmax */ + #ifndef GL_ARB_texture_float #define GL_ARB_texture_float 1 #define GL_TEXTURE_RED_TYPE_ARB 0x8C10 @@ -4012,8 +4572,6 @@ GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, void #ifndef GL_ARB_transform_feedback2 #define GL_ARB_transform_feedback2 1 -#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 -#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 #endif /* GL_ARB_transform_feedback2 */ #ifndef GL_ARB_transform_feedback3 @@ -4024,6 +4582,12 @@ GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, void #define GL_ARB_transform_feedback_instanced 1 #endif /* GL_ARB_transform_feedback_instanced */ +#ifndef GL_ARB_transform_feedback_overflow_query +#define GL_ARB_transform_feedback_overflow_query 1 +#define GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB 0x82EC +#define GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB 0x82ED +#endif /* GL_ARB_transform_feedback_overflow_query */ + #ifndef GL_ARB_transpose_matrix #define GL_ARB_transpose_matrix 1 #define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 @@ -4044,9 +4608,6 @@ GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *m); #ifndef GL_ARB_uniform_buffer_object #define GL_ARB_uniform_buffer_object 1 -#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C -#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 #endif /* GL_ARB_uniform_buffer_object */ #ifndef GL_ARB_vertex_array_bgra @@ -4135,8 +4696,8 @@ GLAPI void APIENTRY glVertexBlendARB (GLint count); #ifndef GL_ARB_vertex_buffer_object #define GL_ARB_vertex_buffer_object 1 -typedef ptrdiff_t GLsizeiptrARB; -typedef ptrdiff_t GLintptrARB; +typedef khronos_ssize_t GLsizeiptrARB; +typedef khronos_intptr_t GLintptrARB; #define GL_BUFFER_SIZE_ARB 0x8764 #define GL_BUFFER_USAGE_ARB 0x8765 #define GL_ARRAY_BUFFER_ARB 0x8892 @@ -4331,6 +4892,12 @@ GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB programObj, const GLcha #ifndef GL_ARB_viewport_array #define GL_ARB_viewport_array 1 +typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYDVNVPROC) (GLuint first, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDDNVPROC) (GLuint index, GLdouble n, GLdouble f); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthRangeArraydvNV (GLuint first, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glDepthRangeIndexeddNV (GLuint index, GLdouble n, GLdouble f); +#endif #endif /* GL_ARB_viewport_array */ #ifndef GL_ARB_window_pos @@ -4371,10 +4938,82 @@ GLAPI void APIENTRY glWindowPos3svARB (const GLshort *v); #endif #endif /* GL_ARB_window_pos */ +#ifndef GL_KHR_blend_equation_advanced +#define GL_KHR_blend_equation_advanced 1 +#define GL_MULTIPLY_KHR 0x9294 +#define GL_SCREEN_KHR 0x9295 +#define GL_OVERLAY_KHR 0x9296 +#define GL_DARKEN_KHR 0x9297 +#define GL_LIGHTEN_KHR 0x9298 +#define GL_COLORDODGE_KHR 0x9299 +#define GL_COLORBURN_KHR 0x929A +#define GL_HARDLIGHT_KHR 0x929B +#define GL_SOFTLIGHT_KHR 0x929C +#define GL_DIFFERENCE_KHR 0x929E +#define GL_EXCLUSION_KHR 0x92A0 +#define GL_HSL_HUE_KHR 0x92AD +#define GL_HSL_SATURATION_KHR 0x92AE +#define GL_HSL_COLOR_KHR 0x92AF +#define GL_HSL_LUMINOSITY_KHR 0x92B0 +typedef void (APIENTRYP PFNGLBLENDBARRIERKHRPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendBarrierKHR (void); +#endif +#endif /* GL_KHR_blend_equation_advanced */ + +#ifndef GL_KHR_blend_equation_advanced_coherent +#define GL_KHR_blend_equation_advanced_coherent 1 +#define GL_BLEND_ADVANCED_COHERENT_KHR 0x9285 +#endif /* GL_KHR_blend_equation_advanced_coherent */ + +#ifndef GL_KHR_context_flush_control +#define GL_KHR_context_flush_control 1 +#endif /* GL_KHR_context_flush_control */ + #ifndef GL_KHR_debug #define GL_KHR_debug 1 #endif /* GL_KHR_debug */ +#ifndef GL_KHR_no_error +#define GL_KHR_no_error 1 +#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 +#endif /* GL_KHR_no_error */ + +#ifndef GL_KHR_parallel_shader_compile +#define GL_KHR_parallel_shader_compile 1 +#define GL_MAX_SHADER_COMPILER_THREADS_KHR 0x91B0 +#define GL_COMPLETION_STATUS_KHR 0x91B1 +typedef void (APIENTRYP PFNGLMAXSHADERCOMPILERTHREADSKHRPROC) (GLuint count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMaxShaderCompilerThreadsKHR (GLuint count); +#endif +#endif /* GL_KHR_parallel_shader_compile */ + +#ifndef GL_KHR_robust_buffer_access_behavior +#define GL_KHR_robust_buffer_access_behavior 1 +#endif /* GL_KHR_robust_buffer_access_behavior */ + +#ifndef GL_KHR_robustness +#define GL_KHR_robustness 1 +#define GL_CONTEXT_ROBUST_ACCESS 0x90F3 +#endif /* GL_KHR_robustness */ + +#ifndef GL_KHR_shader_subgroup +#define GL_KHR_shader_subgroup 1 +#define GL_SUBGROUP_SIZE_KHR 0x9532 +#define GL_SUBGROUP_SUPPORTED_STAGES_KHR 0x9533 +#define GL_SUBGROUP_SUPPORTED_FEATURES_KHR 0x9534 +#define GL_SUBGROUP_QUAD_ALL_STAGES_KHR 0x9535 +#define GL_SUBGROUP_FEATURE_BASIC_BIT_KHR 0x00000001 +#define GL_SUBGROUP_FEATURE_VOTE_BIT_KHR 0x00000002 +#define GL_SUBGROUP_FEATURE_ARITHMETIC_BIT_KHR 0x00000004 +#define GL_SUBGROUP_FEATURE_BALLOT_BIT_KHR 0x00000008 +#define GL_SUBGROUP_FEATURE_SHUFFLE_BIT_KHR 0x00000010 +#define GL_SUBGROUP_FEATURE_SHUFFLE_RELATIVE_BIT_KHR 0x00000020 +#define GL_SUBGROUP_FEATURE_CLUSTERED_BIT_KHR 0x00000040 +#define GL_SUBGROUP_FEATURE_QUAD_BIT_KHR 0x00000080 +#endif /* GL_KHR_shader_subgroup */ + #ifndef GL_KHR_texture_compression_astc_hdr #define GL_KHR_texture_compression_astc_hdr 1 #define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 @@ -4411,6 +5050,10 @@ GLAPI void APIENTRY glWindowPos3svARB (const GLshort *v); #define GL_KHR_texture_compression_astc_ldr 1 #endif /* GL_KHR_texture_compression_astc_ldr */ +#ifndef GL_KHR_texture_compression_astc_sliced_3d +#define GL_KHR_texture_compression_astc_sliced_3d 1 +#endif /* GL_KHR_texture_compression_astc_sliced_3d */ + #ifndef GL_OES_byte_coordinates #define GL_OES_byte_coordinates 1 typedef void (APIENTRYP PFNGLMULTITEXCOORD1BOESPROC) (GLenum texture, GLbyte s); @@ -4429,11 +5072,11 @@ typedef void (APIENTRYP PFNGLTEXCOORD3BOESPROC) (GLbyte s, GLbyte t, GLbyte r); typedef void (APIENTRYP PFNGLTEXCOORD3BVOESPROC) (const GLbyte *coords); typedef void (APIENTRYP PFNGLTEXCOORD4BOESPROC) (GLbyte s, GLbyte t, GLbyte r, GLbyte q); typedef void (APIENTRYP PFNGLTEXCOORD4BVOESPROC) (const GLbyte *coords); -typedef void (APIENTRYP PFNGLVERTEX2BOESPROC) (GLbyte x); +typedef void (APIENTRYP PFNGLVERTEX2BOESPROC) (GLbyte x, GLbyte y); typedef void (APIENTRYP PFNGLVERTEX2BVOESPROC) (const GLbyte *coords); -typedef void (APIENTRYP PFNGLVERTEX3BOESPROC) (GLbyte x, GLbyte y); +typedef void (APIENTRYP PFNGLVERTEX3BOESPROC) (GLbyte x, GLbyte y, GLbyte z); typedef void (APIENTRYP PFNGLVERTEX3BVOESPROC) (const GLbyte *coords); -typedef void (APIENTRYP PFNGLVERTEX4BOESPROC) (GLbyte x, GLbyte y, GLbyte z); +typedef void (APIENTRYP PFNGLVERTEX4BOESPROC) (GLbyte x, GLbyte y, GLbyte z, GLbyte w); typedef void (APIENTRYP PFNGLVERTEX4BVOESPROC) (const GLbyte *coords); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glMultiTexCoord1bOES (GLenum texture, GLbyte s); @@ -4452,11 +5095,11 @@ GLAPI void APIENTRY glTexCoord3bOES (GLbyte s, GLbyte t, GLbyte r); GLAPI void APIENTRY glTexCoord3bvOES (const GLbyte *coords); GLAPI void APIENTRY glTexCoord4bOES (GLbyte s, GLbyte t, GLbyte r, GLbyte q); GLAPI void APIENTRY glTexCoord4bvOES (const GLbyte *coords); -GLAPI void APIENTRY glVertex2bOES (GLbyte x); +GLAPI void APIENTRY glVertex2bOES (GLbyte x, GLbyte y); GLAPI void APIENTRY glVertex2bvOES (const GLbyte *coords); -GLAPI void APIENTRY glVertex3bOES (GLbyte x, GLbyte y); +GLAPI void APIENTRY glVertex3bOES (GLbyte x, GLbyte y, GLbyte z); GLAPI void APIENTRY glVertex3bvOES (const GLbyte *coords); -GLAPI void APIENTRY glVertex4bOES (GLbyte x, GLbyte y, GLbyte z); +GLAPI void APIENTRY glVertex4bOES (GLbyte x, GLbyte y, GLbyte z, GLbyte w); GLAPI void APIENTRY glVertex4bvOES (const GLbyte *coords); #endif #endif /* GL_OES_byte_coordinates */ @@ -4477,7 +5120,7 @@ GLAPI void APIENTRY glVertex4bvOES (const GLbyte *coords); #ifndef GL_OES_fixed_point #define GL_OES_fixed_point 1 -typedef GLint GLfixed; +typedef khronos_int32_t GLfixed; #define GL_FIXED_OES 0x140C typedef void (APIENTRYP PFNGLALPHAFUNCXOESPROC) (GLenum func, GLfixed ref); typedef void (APIENTRYP PFNGLCLEARCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); @@ -4508,7 +5151,6 @@ typedef void (APIENTRYP PFNGLPOINTPARAMETERXVOESPROC) (GLenum pname, const GLfix typedef void (APIENTRYP PFNGLPOINTSIZEXOESPROC) (GLfixed size); typedef void (APIENTRYP PFNGLPOLYGONOFFSETXOESPROC) (GLfixed factor, GLfixed units); typedef void (APIENTRYP PFNGLROTATEXOESPROC) (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEOESPROC) (GLfixed value, GLboolean invert); typedef void (APIENTRYP PFNGLSCALEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); typedef void (APIENTRYP PFNGLTEXENVXOESPROC) (GLenum target, GLenum pname, GLfixed param); typedef void (APIENTRYP PFNGLTEXENVXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); @@ -4613,7 +5255,6 @@ GLAPI void APIENTRY glPointParameterxvOES (GLenum pname, const GLfixed *params); GLAPI void APIENTRY glPointSizexOES (GLfixed size); GLAPI void APIENTRY glPolygonOffsetxOES (GLfixed factor, GLfixed units); GLAPI void APIENTRY glRotatexOES (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); -GLAPI void APIENTRY glSampleCoverageOES (GLfixed value, GLboolean invert); GLAPI void APIENTRY glScalexOES (GLfixed x, GLfixed y, GLfixed z); GLAPI void APIENTRY glTexEnvxOES (GLenum target, GLenum pname, GLfixed param); GLAPI void APIENTRY glTexEnvxvOES (GLenum target, GLenum pname, const GLfixed *params); @@ -4775,12 +5416,12 @@ typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severi typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, void *userParam); -typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufSize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, void *userParam); -GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufSize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); #endif #endif /* GL_AMD_debug_output */ @@ -4804,13 +5445,68 @@ GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRG #endif #endif /* GL_AMD_draw_buffers_blend */ +#ifndef GL_AMD_framebuffer_multisample_advanced +#define GL_AMD_framebuffer_multisample_advanced 1 +#define GL_RENDERBUFFER_STORAGE_SAMPLES_AMD 0x91B2 +#define GL_MAX_COLOR_FRAMEBUFFER_SAMPLES_AMD 0x91B3 +#define GL_MAX_COLOR_FRAMEBUFFER_STORAGE_SAMPLES_AMD 0x91B4 +#define GL_MAX_DEPTH_STENCIL_FRAMEBUFFER_SAMPLES_AMD 0x91B5 +#define GL_NUM_SUPPORTED_MULTISAMPLE_MODES_AMD 0x91B6 +#define GL_SUPPORTED_MULTISAMPLE_MODES_AMD 0x91B7 +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEADVANCEDAMDPROC) (GLenum target, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEADVANCEDAMDPROC) (GLuint renderbuffer, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleAdvancedAMD (GLenum target, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleAdvancedAMD (GLuint renderbuffer, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_AMD_framebuffer_multisample_advanced */ + +#ifndef GL_AMD_framebuffer_sample_positions +#define GL_AMD_framebuffer_sample_positions 1 +#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F +#define GL_PIXELS_PER_SAMPLE_PATTERN_X_AMD 0x91AE +#define GL_PIXELS_PER_SAMPLE_PATTERN_Y_AMD 0x91AF +#define GL_ALL_PIXELS_AMD 0xFFFFFFFF +typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLEPOSITIONSFVAMDPROC) (GLenum target, GLuint numsamples, GLuint pixelindex, const GLfloat *values); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLEPOSITIONSFVAMDPROC) (GLuint framebuffer, GLuint numsamples, GLuint pixelindex, const GLfloat *values); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERFVAMDPROC) (GLenum target, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERFVAMDPROC) (GLuint framebuffer, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferSamplePositionsfvAMD (GLenum target, GLuint numsamples, GLuint pixelindex, const GLfloat *values); +GLAPI void APIENTRY glNamedFramebufferSamplePositionsfvAMD (GLuint framebuffer, GLuint numsamples, GLuint pixelindex, const GLfloat *values); +GLAPI void APIENTRY glGetFramebufferParameterfvAMD (GLenum target, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); +GLAPI void APIENTRY glGetNamedFramebufferParameterfvAMD (GLuint framebuffer, GLenum pname, GLuint numsamples, GLuint pixelindex, GLsizei size, GLfloat *values); +#endif +#endif /* GL_AMD_framebuffer_sample_positions */ + #ifndef GL_AMD_gcn_shader #define GL_AMD_gcn_shader 1 #endif /* GL_AMD_gcn_shader */ +#ifndef GL_AMD_gpu_shader_half_float +#define GL_AMD_gpu_shader_half_float 1 +#define GL_FLOAT16_NV 0x8FF8 +#define GL_FLOAT16_VEC2_NV 0x8FF9 +#define GL_FLOAT16_VEC3_NV 0x8FFA +#define GL_FLOAT16_VEC4_NV 0x8FFB +#define GL_FLOAT16_MAT2_AMD 0x91C5 +#define GL_FLOAT16_MAT3_AMD 0x91C6 +#define GL_FLOAT16_MAT4_AMD 0x91C7 +#define GL_FLOAT16_MAT2x3_AMD 0x91C8 +#define GL_FLOAT16_MAT2x4_AMD 0x91C9 +#define GL_FLOAT16_MAT3x2_AMD 0x91CA +#define GL_FLOAT16_MAT3x4_AMD 0x91CB +#define GL_FLOAT16_MAT4x2_AMD 0x91CC +#define GL_FLOAT16_MAT4x3_AMD 0x91CD +#endif /* GL_AMD_gpu_shader_half_float */ + +#ifndef GL_AMD_gpu_shader_int16 +#define GL_AMD_gpu_shader_int16 1 +#endif /* GL_AMD_gpu_shader_int16 */ + #ifndef GL_AMD_gpu_shader_int64 #define GL_AMD_gpu_shader_int64 1 -typedef int64_t GLint64EXT; +typedef khronos_int64_t GLint64EXT; #define GL_INT64_NV 0x140E #define GL_UNSIGNED_INT64_NV 0x140F #define GL_INT8_NV 0x8FE0 @@ -4835,10 +5531,6 @@ typedef int64_t GLint64EXT; #define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 #define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 #define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 -#define GL_FLOAT16_NV 0x8FF8 -#define GL_FLOAT16_VEC2_NV 0x8FF9 -#define GL_FLOAT16_VEC3_NV 0x8FFA -#define GL_FLOAT16_VEC4_NV 0x8FFB typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); @@ -5011,7 +5703,6 @@ GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname #ifndef GL_AMD_sample_positions #define GL_AMD_sample_positions 1 -#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val); @@ -5026,6 +5717,22 @@ GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLf #define GL_AMD_shader_atomic_counter_ops 1 #endif /* GL_AMD_shader_atomic_counter_ops */ +#ifndef GL_AMD_shader_ballot +#define GL_AMD_shader_ballot 1 +#endif /* GL_AMD_shader_ballot */ + +#ifndef GL_AMD_shader_explicit_vertex_parameter +#define GL_AMD_shader_explicit_vertex_parameter 1 +#endif /* GL_AMD_shader_explicit_vertex_parameter */ + +#ifndef GL_AMD_shader_gpu_shader_half_float_fetch +#define GL_AMD_shader_gpu_shader_half_float_fetch 1 +#endif /* GL_AMD_shader_gpu_shader_half_float_fetch */ + +#ifndef GL_AMD_shader_image_load_store_lod +#define GL_AMD_shader_image_load_store_lod 1 +#endif /* GL_AMD_shader_image_load_store_lod */ + #ifndef GL_AMD_shader_stencil_export #define GL_AMD_shader_stencil_export 1 #endif /* GL_AMD_shader_stencil_export */ @@ -5065,6 +5772,10 @@ GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value); #endif #endif /* GL_AMD_stencil_operation_extended */ +#ifndef GL_AMD_texture_gather_bias_lod +#define GL_AMD_texture_gather_bias_lod 1 +#endif /* GL_AMD_texture_gather_bias_lod */ + #ifndef GL_AMD_texture_texture4 #define GL_AMD_texture_texture4 1 #endif /* GL_AMD_texture_texture4 */ @@ -5765,6 +6476,21 @@ GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param); #define GL_422_REV_AVERAGE_EXT 0x80CF #endif /* GL_EXT_422_pixels */ +#ifndef GL_EXT_EGL_image_storage +#define GL_EXT_EGL_image_storage 1 +typedef void *GLeglImageOES; +typedef void (APIENTRYP PFNGLEGLIMAGETARGETTEXSTORAGEEXTPROC) (GLenum target, GLeglImageOES image, const GLint* attrib_list); +typedef void (APIENTRYP PFNGLEGLIMAGETARGETTEXTURESTORAGEEXTPROC) (GLuint texture, GLeglImageOES image, const GLint* attrib_list); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glEGLImageTargetTexStorageEXT (GLenum target, GLeglImageOES image, const GLint* attrib_list); +GLAPI void APIENTRY glEGLImageTargetTextureStorageEXT (GLuint texture, GLeglImageOES image, const GLint* attrib_list); +#endif +#endif /* GL_EXT_EGL_image_storage */ + +#ifndef GL_EXT_EGL_sync +#define GL_EXT_EGL_sync 1 +#endif /* GL_EXT_EGL_sync */ + #ifndef GL_EXT_abgr #define GL_EXT_abgr 1 #define GL_ABGR_EXT 0x8000 @@ -6327,7 +7053,7 @@ typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaob typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); -typedef void (APIENTRYP PFNGLTEXTUREPAGECOMMITMENTEXTPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident); +typedef void (APIENTRYP PFNGLTEXTUREPAGECOMMITMENTEXTPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBDIVISOREXTPROC) (GLuint vaobj, GLuint index, GLuint divisor); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); @@ -6583,7 +7309,7 @@ GLAPI void APIENTRY glVertexArrayVertexAttribLFormatEXT (GLuint vaobj, GLuint at GLAPI void APIENTRY glVertexArrayVertexAttribBindingEXT (GLuint vaobj, GLuint attribindex, GLuint bindingindex); GLAPI void APIENTRY glVertexArrayVertexBindingDivisorEXT (GLuint vaobj, GLuint bindingindex, GLuint divisor); GLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); -GLAPI void APIENTRY glTexturePageCommitmentEXT (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident); +GLAPI void APIENTRY glTexturePageCommitmentEXT (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); GLAPI void APIENTRY glVertexArrayVertexAttribDivisorEXT (GLuint vaobj, GLuint index, GLuint divisor); #endif #endif /* GL_EXT_direct_state_access */ @@ -6616,6 +7342,17 @@ GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint en #endif #endif /* GL_EXT_draw_range_elements */ +#ifndef GL_EXT_external_buffer +#define GL_EXT_external_buffer 1 +typedef void *GLeglClientBufferEXT; +typedef void (APIENTRYP PFNGLBUFFERSTORAGEEXTERNALEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEEXTERNALEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferStorageExternalEXT (GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +GLAPI void APIENTRY glNamedBufferStorageExternalEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +#endif +#endif /* GL_EXT_external_buffer */ + #ifndef GL_EXT_fog_coord #define GL_EXT_fog_coord 1 #define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 @@ -6959,6 +7696,89 @@ GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode); #endif #endif /* GL_EXT_light_texture */ +#ifndef GL_EXT_memory_object +#define GL_EXT_memory_object 1 +#define GL_TEXTURE_TILING_EXT 0x9580 +#define GL_DEDICATED_MEMORY_OBJECT_EXT 0x9581 +#define GL_PROTECTED_MEMORY_OBJECT_EXT 0x959B +#define GL_NUM_TILING_TYPES_EXT 0x9582 +#define GL_TILING_TYPES_EXT 0x9583 +#define GL_OPTIMAL_TILING_EXT 0x9584 +#define GL_LINEAR_TILING_EXT 0x9585 +#define GL_NUM_DEVICE_UUIDS_EXT 0x9596 +#define GL_DEVICE_UUID_EXT 0x9597 +#define GL_DRIVER_UUID_EXT 0x9598 +#define GL_UUID_SIZE_EXT 16 +typedef void (APIENTRYP PFNGLGETUNSIGNEDBYTEVEXTPROC) (GLenum pname, GLubyte *data); +typedef void (APIENTRYP PFNGLGETUNSIGNEDBYTEI_VEXTPROC) (GLenum target, GLuint index, GLubyte *data); +typedef void (APIENTRYP PFNGLDELETEMEMORYOBJECTSEXTPROC) (GLsizei n, const GLuint *memoryObjects); +typedef GLboolean (APIENTRYP PFNGLISMEMORYOBJECTEXTPROC) (GLuint memoryObject); +typedef void (APIENTRYP PFNGLCREATEMEMORYOBJECTSEXTPROC) (GLsizei n, GLuint *memoryObjects); +typedef void (APIENTRYP PFNGLMEMORYOBJECTPARAMETERIVEXTPROC) (GLuint memoryObject, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETMEMORYOBJECTPARAMETERIVEXTPROC) (GLuint memoryObject, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM2DMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM3DMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLBUFFERSTORAGEMEMEXTPROC) (GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM2DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM2DMULTISAMPLEEXTPROC) (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM3DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM3DMULTISAMPLEEXTPROC) (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEMEMEXTPROC) (GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXSTORAGEMEM1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTURESTORAGEMEM1DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUnsignedBytevEXT (GLenum pname, GLubyte *data); +GLAPI void APIENTRY glGetUnsignedBytei_vEXT (GLenum target, GLuint index, GLubyte *data); +GLAPI void APIENTRY glDeleteMemoryObjectsEXT (GLsizei n, const GLuint *memoryObjects); +GLAPI GLboolean APIENTRY glIsMemoryObjectEXT (GLuint memoryObject); +GLAPI void APIENTRY glCreateMemoryObjectsEXT (GLsizei n, GLuint *memoryObjects); +GLAPI void APIENTRY glMemoryObjectParameterivEXT (GLuint memoryObject, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetMemoryObjectParameterivEXT (GLuint memoryObject, GLenum pname, GLint *params); +GLAPI void APIENTRY glTexStorageMem2DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem2DMultisampleEXT (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem3DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem3DMultisampleEXT (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glBufferStorageMemEXT (GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem2DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem2DMultisampleEXT (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem3DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem3DMultisampleEXT (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glNamedBufferStorageMemEXT (GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTexStorageMem1DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureStorageMem1DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLuint memory, GLuint64 offset); +#endif +#endif /* GL_EXT_memory_object */ + +#ifndef GL_EXT_memory_object_fd +#define GL_EXT_memory_object_fd 1 +#define GL_HANDLE_TYPE_OPAQUE_FD_EXT 0x9586 +typedef void (APIENTRYP PFNGLIMPORTMEMORYFDEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, GLint fd); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImportMemoryFdEXT (GLuint memory, GLuint64 size, GLenum handleType, GLint fd); +#endif +#endif /* GL_EXT_memory_object_fd */ + +#ifndef GL_EXT_memory_object_win32 +#define GL_EXT_memory_object_win32 1 +#define GL_HANDLE_TYPE_OPAQUE_WIN32_EXT 0x9587 +#define GL_HANDLE_TYPE_OPAQUE_WIN32_KMT_EXT 0x9588 +#define GL_DEVICE_LUID_EXT 0x9599 +#define GL_DEVICE_NODE_MASK_EXT 0x959A +#define GL_LUID_SIZE_EXT 8 +#define GL_HANDLE_TYPE_D3D12_TILEPOOL_EXT 0x9589 +#define GL_HANDLE_TYPE_D3D12_RESOURCE_EXT 0x958A +#define GL_HANDLE_TYPE_D3D11_IMAGE_EXT 0x958B +#define GL_HANDLE_TYPE_D3D11_IMAGE_KMT_EXT 0x958C +typedef void (APIENTRYP PFNGLIMPORTMEMORYWIN32HANDLEEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, void *handle); +typedef void (APIENTRYP PFNGLIMPORTMEMORYWIN32NAMEEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, const void *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImportMemoryWin32HandleEXT (GLuint memory, GLuint64 size, GLenum handleType, void *handle); +GLAPI void APIENTRY glImportMemoryWin32NameEXT (GLuint memory, GLuint64 size, GLenum handleType, const void *name); +#endif +#endif /* GL_EXT_memory_object_win32 */ + #ifndef GL_EXT_misc_attribute #define GL_EXT_misc_attribute 1 #endif /* GL_EXT_misc_attribute */ @@ -7000,6 +7820,18 @@ GLAPI void APIENTRY glSamplePatternEXT (GLenum pattern); #endif #endif /* GL_EXT_multisample */ +#ifndef GL_EXT_multiview_tessellation_geometry_shader +#define GL_EXT_multiview_tessellation_geometry_shader 1 +#endif /* GL_EXT_multiview_tessellation_geometry_shader */ + +#ifndef GL_EXT_multiview_texture_multisample +#define GL_EXT_multiview_texture_multisample 1 +#endif /* GL_EXT_multiview_texture_multisample */ + +#ifndef GL_EXT_multiview_timer_query +#define GL_EXT_multiview_timer_query 1 +#endif /* GL_EXT_multiview_timer_query */ + #ifndef GL_EXT_packed_depth_stencil #define GL_EXT_packed_depth_stencil 1 #define GL_DEPTH_STENCIL_EXT 0x84F9 @@ -7109,6 +7941,19 @@ GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat factor, GLfloat bias); #endif #endif /* GL_EXT_polygon_offset */ +#ifndef GL_EXT_polygon_offset_clamp +#define GL_EXT_polygon_offset_clamp 1 +#define GL_POLYGON_OFFSET_CLAMP_EXT 0x8E1B +typedef void (APIENTRYP PFNGLPOLYGONOFFSETCLAMPEXTPROC) (GLfloat factor, GLfloat units, GLfloat clamp); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPolygonOffsetClampEXT (GLfloat factor, GLfloat units, GLfloat clamp); +#endif +#endif /* GL_EXT_polygon_offset_clamp */ + +#ifndef GL_EXT_post_depth_coverage +#define GL_EXT_post_depth_coverage 1 +#endif /* GL_EXT_post_depth_coverage */ + #ifndef GL_EXT_provoking_vertex #define GL_EXT_provoking_vertex 1 #define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C @@ -7121,6 +7966,20 @@ GLAPI void APIENTRY glProvokingVertexEXT (GLenum mode); #endif #endif /* GL_EXT_provoking_vertex */ +#ifndef GL_EXT_raster_multisample +#define GL_EXT_raster_multisample 1 +#define GL_RASTER_MULTISAMPLE_EXT 0x9327 +#define GL_RASTER_SAMPLES_EXT 0x9328 +#define GL_MAX_RASTER_SAMPLES_EXT 0x9329 +#define GL_RASTER_FIXED_SAMPLE_LOCATIONS_EXT 0x932A +#define GL_MULTISAMPLE_RASTERIZATION_ALLOWED_EXT 0x932B +#define GL_EFFECTIVE_RASTER_SAMPLES_EXT 0x932C +typedef void (APIENTRYP PFNGLRASTERSAMPLESEXTPROC) (GLuint samples, GLboolean fixedsamplelocations); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRasterSamplesEXT (GLuint samples, GLboolean fixedsamplelocations); +#endif +#endif /* GL_EXT_raster_multisample */ + #ifndef GL_EXT_rescale_normal #define GL_EXT_rescale_normal 1 #define GL_RESCALE_NORMAL_EXT 0x803A @@ -7173,6 +8032,55 @@ GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei #endif #endif /* GL_EXT_secondary_color */ +#ifndef GL_EXT_semaphore +#define GL_EXT_semaphore 1 +#define GL_LAYOUT_GENERAL_EXT 0x958D +#define GL_LAYOUT_COLOR_ATTACHMENT_EXT 0x958E +#define GL_LAYOUT_DEPTH_STENCIL_ATTACHMENT_EXT 0x958F +#define GL_LAYOUT_DEPTH_STENCIL_READ_ONLY_EXT 0x9590 +#define GL_LAYOUT_SHADER_READ_ONLY_EXT 0x9591 +#define GL_LAYOUT_TRANSFER_SRC_EXT 0x9592 +#define GL_LAYOUT_TRANSFER_DST_EXT 0x9593 +#define GL_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_EXT 0x9530 +#define GL_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_EXT 0x9531 +typedef void (APIENTRYP PFNGLGENSEMAPHORESEXTPROC) (GLsizei n, GLuint *semaphores); +typedef void (APIENTRYP PFNGLDELETESEMAPHORESEXTPROC) (GLsizei n, const GLuint *semaphores); +typedef GLboolean (APIENTRYP PFNGLISSEMAPHOREEXTPROC) (GLuint semaphore); +typedef void (APIENTRYP PFNGLSEMAPHOREPARAMETERUI64VEXTPROC) (GLuint semaphore, GLenum pname, const GLuint64 *params); +typedef void (APIENTRYP PFNGLGETSEMAPHOREPARAMETERUI64VEXTPROC) (GLuint semaphore, GLenum pname, GLuint64 *params); +typedef void (APIENTRYP PFNGLWAITSEMAPHOREEXTPROC) (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *srcLayouts); +typedef void (APIENTRYP PFNGLSIGNALSEMAPHOREEXTPROC) (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *dstLayouts); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenSemaphoresEXT (GLsizei n, GLuint *semaphores); +GLAPI void APIENTRY glDeleteSemaphoresEXT (GLsizei n, const GLuint *semaphores); +GLAPI GLboolean APIENTRY glIsSemaphoreEXT (GLuint semaphore); +GLAPI void APIENTRY glSemaphoreParameterui64vEXT (GLuint semaphore, GLenum pname, const GLuint64 *params); +GLAPI void APIENTRY glGetSemaphoreParameterui64vEXT (GLuint semaphore, GLenum pname, GLuint64 *params); +GLAPI void APIENTRY glWaitSemaphoreEXT (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *srcLayouts); +GLAPI void APIENTRY glSignalSemaphoreEXT (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *dstLayouts); +#endif +#endif /* GL_EXT_semaphore */ + +#ifndef GL_EXT_semaphore_fd +#define GL_EXT_semaphore_fd 1 +typedef void (APIENTRYP PFNGLIMPORTSEMAPHOREFDEXTPROC) (GLuint semaphore, GLenum handleType, GLint fd); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImportSemaphoreFdEXT (GLuint semaphore, GLenum handleType, GLint fd); +#endif +#endif /* GL_EXT_semaphore_fd */ + +#ifndef GL_EXT_semaphore_win32 +#define GL_EXT_semaphore_win32 1 +#define GL_HANDLE_TYPE_D3D12_FENCE_EXT 0x9594 +#define GL_D3D12_FENCE_VALUE_EXT 0x9595 +typedef void (APIENTRYP PFNGLIMPORTSEMAPHOREWIN32HANDLEEXTPROC) (GLuint semaphore, GLenum handleType, void *handle); +typedef void (APIENTRYP PFNGLIMPORTSEMAPHOREWIN32NAMEEXTPROC) (GLuint semaphore, GLenum handleType, const void *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImportSemaphoreWin32HandleEXT (GLuint semaphore, GLenum handleType, void *handle); +GLAPI void APIENTRY glImportSemaphoreWin32NameEXT (GLuint semaphore, GLenum handleType, const void *name); +#endif +#endif /* GL_EXT_semaphore_win32 */ + #ifndef GL_EXT_separate_shader_objects #define GL_EXT_separate_shader_objects 1 #define GL_ACTIVE_PROGRAM_EXT 0x8B8D @@ -7193,6 +8101,19 @@ GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *strin #define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA #endif /* GL_EXT_separate_specular_color */ +#ifndef GL_EXT_shader_framebuffer_fetch +#define GL_EXT_shader_framebuffer_fetch 1 +#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52 +#endif /* GL_EXT_shader_framebuffer_fetch */ + +#ifndef GL_EXT_shader_framebuffer_fetch_non_coherent +#define GL_EXT_shader_framebuffer_fetch_non_coherent 1 +typedef void (APIENTRYP PFNGLFRAMEBUFFERFETCHBARRIEREXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferFetchBarrierEXT (void); +#endif +#endif /* GL_EXT_shader_framebuffer_fetch_non_coherent */ + #ifndef GL_EXT_shader_image_load_formatted #define GL_EXT_shader_image_load_formatted 1 #endif /* GL_EXT_shader_image_load_formatted */ @@ -7275,6 +8196,10 @@ GLAPI void APIENTRY glMemoryBarrierEXT (GLbitfield barriers); #define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB #endif /* GL_EXT_shared_texture_palette */ +#ifndef GL_EXT_sparse_texture2 +#define GL_EXT_sparse_texture2 1 +#endif /* GL_EXT_sparse_texture2 */ + #ifndef GL_EXT_stencil_clear_tag #define GL_EXT_stencil_clear_tag 1 #define GL_STENCIL_TAG_BITS_EXT 0x88F2 @@ -7387,6 +8312,10 @@ GLAPI void APIENTRY glTexSubImage3DEXT (GLenum target, GLint level, GLint xoffse #define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D #define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF #define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +#endif #endif /* GL_EXT_texture_array */ #ifndef GL_EXT_texture_buffer_object @@ -7483,6 +8412,12 @@ GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint #define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF #endif /* GL_EXT_texture_filter_anisotropic */ +#ifndef GL_EXT_texture_filter_minmax +#define GL_EXT_texture_filter_minmax 1 +#define GL_TEXTURE_REDUCTION_MODE_EXT 0x9366 +#define GL_WEIGHTED_AVERAGE_EXT 0x9367 +#endif /* GL_EXT_texture_filter_minmax */ + #ifndef GL_EXT_texture_integer #define GL_EXT_texture_integer 1 #define GL_RGBA32UI_EXT 0x8D70 @@ -7615,6 +8550,11 @@ GLAPI void APIENTRY glTextureNormalEXT (GLenum mode); #define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F #endif /* GL_EXT_texture_sRGB */ +#ifndef GL_EXT_texture_sRGB_R8 +#define GL_EXT_texture_sRGB_R8 1 +#define GL_SR8_EXT 0x8FBD +#endif /* GL_EXT_texture_sRGB_R8 */ + #ifndef GL_EXT_texture_sRGB_decode #define GL_EXT_texture_sRGB_decode 1 #define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 @@ -7622,6 +8562,10 @@ GLAPI void APIENTRY glTextureNormalEXT (GLenum mode); #define GL_SKIP_DECODE_EXT 0x8A4A #endif /* GL_EXT_texture_sRGB_decode */ +#ifndef GL_EXT_texture_shadow_lod +#define GL_EXT_texture_shadow_lod 1 +#endif /* GL_EXT_texture_shadow_lod */ + #ifndef GL_EXT_texture_shared_exponent #define GL_EXT_texture_shared_exponent 1 #define GL_RGB9_E5_EXT 0x8C3D @@ -8027,6 +8971,30 @@ GLAPI void APIENTRY glVertexWeightPointerEXT (GLint size, GLenum type, GLsizei s #endif #endif /* GL_EXT_vertex_weighting */ +#ifndef GL_EXT_win32_keyed_mutex +#define GL_EXT_win32_keyed_mutex 1 +typedef GLboolean (APIENTRYP PFNGLACQUIREKEYEDMUTEXWIN32EXTPROC) (GLuint memory, GLuint64 key, GLuint timeout); +typedef GLboolean (APIENTRYP PFNGLRELEASEKEYEDMUTEXWIN32EXTPROC) (GLuint memory, GLuint64 key); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAcquireKeyedMutexWin32EXT (GLuint memory, GLuint64 key, GLuint timeout); +GLAPI GLboolean APIENTRY glReleaseKeyedMutexWin32EXT (GLuint memory, GLuint64 key); +#endif +#endif /* GL_EXT_win32_keyed_mutex */ + +#ifndef GL_EXT_window_rectangles +#define GL_EXT_window_rectangles 1 +#define GL_INCLUSIVE_EXT 0x8F10 +#define GL_EXCLUSIVE_EXT 0x8F11 +#define GL_WINDOW_RECTANGLE_EXT 0x8F12 +#define GL_WINDOW_RECTANGLE_MODE_EXT 0x8F13 +#define GL_MAX_WINDOW_RECTANGLES_EXT 0x8F14 +#define GL_NUM_WINDOW_RECTANGLES_EXT 0x8F15 +typedef void (APIENTRYP PFNGLWINDOWRECTANGLESEXTPROC) (GLenum mode, GLsizei count, const GLint *box); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowRectanglesEXT (GLenum mode, GLsizei count, const GLint *box); +#endif +#endif /* GL_EXT_window_rectangles */ + #ifndef GL_EXT_x11_sync_object #define GL_EXT_x11_sync_object 1 #define GL_SYNC_X11_FENCE_EXT 0x90E1 @@ -8204,10 +9172,28 @@ GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRG #define GL_INTERLACE_READ_INGR 0x8568 #endif /* GL_INGR_interlace_read */ +#ifndef GL_INTEL_blackhole_render +#define GL_INTEL_blackhole_render 1 +#define GL_BLACKHOLE_RENDER_INTEL 0x83FC +#endif /* GL_INTEL_blackhole_render */ + +#ifndef GL_INTEL_conservative_rasterization +#define GL_INTEL_conservative_rasterization 1 +#define GL_CONSERVATIVE_RASTERIZATION_INTEL 0x83FE +#endif /* GL_INTEL_conservative_rasterization */ + #ifndef GL_INTEL_fragment_shader_ordering #define GL_INTEL_fragment_shader_ordering 1 #endif /* GL_INTEL_fragment_shader_ordering */ +#ifndef GL_INTEL_framebuffer_CMAA +#define GL_INTEL_framebuffer_CMAA 1 +typedef void (APIENTRYP PFNGLAPPLYFRAMEBUFFERATTACHMENTCMAAINTELPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glApplyFramebufferAttachmentCMAAINTEL (void); +#endif +#endif /* GL_INTEL_framebuffer_CMAA */ + #ifndef GL_INTEL_map_texture #define GL_INTEL_map_texture 1 #define GL_TEXTURE_MEMORY_LAYOUT_INTEL 0x83FF @@ -8272,7 +9258,7 @@ typedef void (APIENTRYP PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle); typedef void (APIENTRYP PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint *queryId); typedef void (APIENTRYP PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint *nextQueryId); typedef void (APIENTRYP PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); -typedef void (APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten); +typedef void (APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); typedef void (APIENTRYP PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar *queryName, GLuint *queryId); typedef void (APIENTRYP PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); #ifdef GL_GLEXT_PROTOTYPES @@ -8283,7 +9269,7 @@ GLAPI void APIENTRY glEndPerfQueryINTEL (GLuint queryHandle); GLAPI void APIENTRY glGetFirstPerfQueryIdINTEL (GLuint *queryId); GLAPI void APIENTRY glGetNextPerfQueryIdINTEL (GLuint queryId, GLuint *nextQueryId); GLAPI void APIENTRY glGetPerfCounterInfoINTEL (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); -GLAPI void APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten); +GLAPI void APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); GLAPI void APIENTRY glGetPerfQueryIdByNameINTEL (GLchar *queryName, GLuint *queryId); GLAPI void APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); #endif @@ -8299,11 +9285,27 @@ GLAPI void APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLen #define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E #endif /* GL_MESAX_texture_stack */ +#ifndef GL_MESA_framebuffer_flip_y +#define GL_MESA_framebuffer_flip_y 1 +#define GL_FRAMEBUFFER_FLIP_Y_MESA 0x8BBB +typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIMESAPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVMESAPROC) (GLenum target, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferParameteriMESA (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glGetFramebufferParameterivMESA (GLenum target, GLenum pname, GLint *params); +#endif +#endif /* GL_MESA_framebuffer_flip_y */ + #ifndef GL_MESA_pack_invert #define GL_MESA_pack_invert 1 #define GL_PACK_INVERT_MESA 0x8758 #endif /* GL_MESA_pack_invert */ +#ifndef GL_MESA_program_binary_formats +#define GL_MESA_program_binary_formats 1 +#define GL_PROGRAM_BINARY_FORMAT_MESA 0x875F +#endif /* GL_MESA_program_binary_formats */ + #ifndef GL_MESA_resize_buffers #define GL_MESA_resize_buffers 1 typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); @@ -8312,6 +9314,17 @@ GLAPI void APIENTRY glResizeBuffersMESA (void); #endif #endif /* GL_MESA_resize_buffers */ +#ifndef GL_MESA_shader_integer_functions +#define GL_MESA_shader_integer_functions 1 +#endif /* GL_MESA_shader_integer_functions */ + +#ifndef GL_MESA_tile_raster_order +#define GL_MESA_tile_raster_order 1 +#define GL_TILE_RASTER_ORDER_FIXED_MESA 0x8BB8 +#define GL_TILE_RASTER_ORDER_INCREASING_X_MESA 0x8BB9 +#define GL_TILE_RASTER_ORDER_INCREASING_Y_MESA 0x8BBA +#endif /* GL_MESA_tile_raster_order */ + #ifndef GL_MESA_window_pos #define GL_MESA_window_pos 1 typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); @@ -8373,6 +9386,10 @@ GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v); #define GL_YCBCR_MESA 0x8757 #endif /* GL_MESA_ycbcr_texture */ +#ifndef GL_NVX_blend_equation_advanced_multi_draw_buffers +#define GL_NVX_blend_equation_advanced_multi_draw_buffers 1 +#endif /* GL_NVX_blend_equation_advanced_multi_draw_buffers */ + #ifndef GL_NVX_conditional_render #define GL_NVX_conditional_render 1 typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVXPROC) (GLuint id); @@ -8392,6 +9409,65 @@ GLAPI void APIENTRY glEndConditionalRenderNVX (void); #define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B #endif /* GL_NVX_gpu_memory_info */ +#ifndef GL_NVX_gpu_multicast2 +#define GL_NVX_gpu_multicast2 1 +#define GL_UPLOAD_GPU_MASK_NVX 0x954A +typedef void (APIENTRYP PFNGLUPLOADGPUMASKNVXPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLMULTICASTVIEWPORTARRAYVNVXPROC) (GLuint gpu, GLuint first, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTICASTVIEWPORTPOSITIONWSCALENVXPROC) (GLuint gpu, GLuint index, GLfloat xcoeff, GLfloat ycoeff); +typedef void (APIENTRYP PFNGLMULTICASTSCISSORARRAYVNVXPROC) (GLuint gpu, GLuint first, GLsizei count, const GLint *v); +typedef GLuint (APIENTRYP PFNGLASYNCCOPYBUFFERSUBDATANVXPROC) (GLsizei waitSemaphoreCount, const GLuint *waitSemaphoreArray, const GLuint64 *fenceValueArray, GLuint readGpu, GLbitfield writeGpuMask, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size, GLsizei signalSemaphoreCount, const GLuint *signalSemaphoreArray, const GLuint64 *signalValueArray); +typedef GLuint (APIENTRYP PFNGLASYNCCOPYIMAGESUBDATANVXPROC) (GLsizei waitSemaphoreCount, const GLuint *waitSemaphoreArray, const GLuint64 *waitValueArray, GLuint srcGpu, GLbitfield dstGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth, GLsizei signalSemaphoreCount, const GLuint *signalSemaphoreArray, const GLuint64 *signalValueArray); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUploadGpuMaskNVX (GLbitfield mask); +GLAPI void APIENTRY glMulticastViewportArrayvNVX (GLuint gpu, GLuint first, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glMulticastViewportPositionWScaleNVX (GLuint gpu, GLuint index, GLfloat xcoeff, GLfloat ycoeff); +GLAPI void APIENTRY glMulticastScissorArrayvNVX (GLuint gpu, GLuint first, GLsizei count, const GLint *v); +GLAPI GLuint APIENTRY glAsyncCopyBufferSubDataNVX (GLsizei waitSemaphoreCount, const GLuint *waitSemaphoreArray, const GLuint64 *fenceValueArray, GLuint readGpu, GLbitfield writeGpuMask, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size, GLsizei signalSemaphoreCount, const GLuint *signalSemaphoreArray, const GLuint64 *signalValueArray); +GLAPI GLuint APIENTRY glAsyncCopyImageSubDataNVX (GLsizei waitSemaphoreCount, const GLuint *waitSemaphoreArray, const GLuint64 *waitValueArray, GLuint srcGpu, GLbitfield dstGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth, GLsizei signalSemaphoreCount, const GLuint *signalSemaphoreArray, const GLuint64 *signalValueArray); +#endif +#endif /* GL_NVX_gpu_multicast2 */ + +#ifndef GL_NVX_linked_gpu_multicast +#define GL_NVX_linked_gpu_multicast 1 +#define GL_LGPU_SEPARATE_STORAGE_BIT_NVX 0x0800 +#define GL_MAX_LGPU_GPUS_NVX 0x92BA +typedef void (APIENTRYP PFNGLLGPUNAMEDBUFFERSUBDATANVXPROC) (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +typedef void (APIENTRYP PFNGLLGPUCOPYIMAGESUBDATANVXPROC) (GLuint sourceGpu, GLbitfield destinationGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srxY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLLGPUINTERLOCKNVXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLGPUNamedBufferSubDataNVX (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void APIENTRY glLGPUCopyImageSubDataNVX (GLuint sourceGpu, GLbitfield destinationGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srxY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glLGPUInterlockNVX (void); +#endif +#endif /* GL_NVX_linked_gpu_multicast */ + +#ifndef GL_NVX_progress_fence +#define GL_NVX_progress_fence 1 +typedef GLuint (APIENTRYP PFNGLCREATEPROGRESSFENCENVXPROC) (void); +typedef void (APIENTRYP PFNGLSIGNALSEMAPHOREUI64NVXPROC) (GLuint signalGpu, GLsizei fenceObjectCount, const GLuint *semaphoreArray, const GLuint64 *fenceValueArray); +typedef void (APIENTRYP PFNGLWAITSEMAPHOREUI64NVXPROC) (GLuint waitGpu, GLsizei fenceObjectCount, const GLuint *semaphoreArray, const GLuint64 *fenceValueArray); +typedef void (APIENTRYP PFNGLCLIENTWAITSEMAPHOREUI64NVXPROC) (GLsizei fenceObjectCount, const GLuint *semaphoreArray, const GLuint64 *fenceValueArray); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glCreateProgressFenceNVX (void); +GLAPI void APIENTRY glSignalSemaphoreui64NVX (GLuint signalGpu, GLsizei fenceObjectCount, const GLuint *semaphoreArray, const GLuint64 *fenceValueArray); +GLAPI void APIENTRY glWaitSemaphoreui64NVX (GLuint waitGpu, GLsizei fenceObjectCount, const GLuint *semaphoreArray, const GLuint64 *fenceValueArray); +GLAPI void APIENTRY glClientWaitSemaphoreui64NVX (GLsizei fenceObjectCount, const GLuint *semaphoreArray, const GLuint64 *fenceValueArray); +#endif +#endif /* GL_NVX_progress_fence */ + +#ifndef GL_NV_alpha_to_coverage_dither_control +#define GL_NV_alpha_to_coverage_dither_control 1 +#define GL_ALPHA_TO_COVERAGE_DITHER_DEFAULT_NV 0x934D +#define GL_ALPHA_TO_COVERAGE_DITHER_ENABLE_NV 0x934E +#define GL_ALPHA_TO_COVERAGE_DITHER_DISABLE_NV 0x934F +#define GL_ALPHA_TO_COVERAGE_DITHER_MODE_NV 0x92BF +typedef void (APIENTRYP PFNGLALPHATOCOVERAGEDITHERCONTROLNVPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAlphaToCoverageDitherControlNV (GLenum mode); +#endif +#endif /* GL_NV_alpha_to_coverage_dither_control */ + #ifndef GL_NV_bindless_multi_draw_indirect #define GL_NV_bindless_multi_draw_indirect 1 typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); @@ -8402,6 +9478,16 @@ GLAPI void APIENTRY glMultiDrawElementsIndirectBindlessNV (GLenum mode, GLenum t #endif #endif /* GL_NV_bindless_multi_draw_indirect */ +#ifndef GL_NV_bindless_multi_draw_indirect_count +#define GL_NV_bindless_multi_draw_indirect_count 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectBindlessCountNV (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); +GLAPI void APIENTRY glMultiDrawElementsIndirectBindlessCountNV (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); +#endif +#endif /* GL_NV_bindless_multi_draw_indirect_count */ + #ifndef GL_NV_bindless_texture #define GL_NV_bindless_texture 1 typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture); @@ -8498,16 +9584,94 @@ GLAPI void APIENTRY glBlendBarrierNV (void); #define GL_BLEND_ADVANCED_COHERENT_NV 0x9285 #endif /* GL_NV_blend_equation_advanced_coherent */ +#ifndef GL_NV_blend_minmax_factor +#define GL_NV_blend_minmax_factor 1 +#endif /* GL_NV_blend_minmax_factor */ + #ifndef GL_NV_blend_square #define GL_NV_blend_square 1 #endif /* GL_NV_blend_square */ +#ifndef GL_NV_clip_space_w_scaling +#define GL_NV_clip_space_w_scaling 1 +#define GL_VIEWPORT_POSITION_W_SCALE_NV 0x937C +#define GL_VIEWPORT_POSITION_W_SCALE_X_COEFF_NV 0x937D +#define GL_VIEWPORT_POSITION_W_SCALE_Y_COEFF_NV 0x937E +typedef void (APIENTRYP PFNGLVIEWPORTPOSITIONWSCALENVPROC) (GLuint index, GLfloat xcoeff, GLfloat ycoeff); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glViewportPositionWScaleNV (GLuint index, GLfloat xcoeff, GLfloat ycoeff); +#endif +#endif /* GL_NV_clip_space_w_scaling */ + +#ifndef GL_NV_command_list +#define GL_NV_command_list 1 +#define GL_TERMINATE_SEQUENCE_COMMAND_NV 0x0000 +#define GL_NOP_COMMAND_NV 0x0001 +#define GL_DRAW_ELEMENTS_COMMAND_NV 0x0002 +#define GL_DRAW_ARRAYS_COMMAND_NV 0x0003 +#define GL_DRAW_ELEMENTS_STRIP_COMMAND_NV 0x0004 +#define GL_DRAW_ARRAYS_STRIP_COMMAND_NV 0x0005 +#define GL_DRAW_ELEMENTS_INSTANCED_COMMAND_NV 0x0006 +#define GL_DRAW_ARRAYS_INSTANCED_COMMAND_NV 0x0007 +#define GL_ELEMENT_ADDRESS_COMMAND_NV 0x0008 +#define GL_ATTRIBUTE_ADDRESS_COMMAND_NV 0x0009 +#define GL_UNIFORM_ADDRESS_COMMAND_NV 0x000A +#define GL_BLEND_COLOR_COMMAND_NV 0x000B +#define GL_STENCIL_REF_COMMAND_NV 0x000C +#define GL_LINE_WIDTH_COMMAND_NV 0x000D +#define GL_POLYGON_OFFSET_COMMAND_NV 0x000E +#define GL_ALPHA_REF_COMMAND_NV 0x000F +#define GL_VIEWPORT_COMMAND_NV 0x0010 +#define GL_SCISSOR_COMMAND_NV 0x0011 +#define GL_FRONT_FACE_COMMAND_NV 0x0012 +typedef void (APIENTRYP PFNGLCREATESTATESNVPROC) (GLsizei n, GLuint *states); +typedef void (APIENTRYP PFNGLDELETESTATESNVPROC) (GLsizei n, const GLuint *states); +typedef GLboolean (APIENTRYP PFNGLISSTATENVPROC) (GLuint state); +typedef void (APIENTRYP PFNGLSTATECAPTURENVPROC) (GLuint state, GLenum mode); +typedef GLuint (APIENTRYP PFNGLGETCOMMANDHEADERNVPROC) (GLenum tokenID, GLuint size); +typedef GLushort (APIENTRYP PFNGLGETSTAGEINDEXNVPROC) (GLenum shadertype); +typedef void (APIENTRYP PFNGLDRAWCOMMANDSNVPROC) (GLenum primitiveMode, GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, GLuint count); +typedef void (APIENTRYP PFNGLDRAWCOMMANDSADDRESSNVPROC) (GLenum primitiveMode, const GLuint64 *indirects, const GLsizei *sizes, GLuint count); +typedef void (APIENTRYP PFNGLDRAWCOMMANDSSTATESNVPROC) (GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +typedef void (APIENTRYP PFNGLDRAWCOMMANDSSTATESADDRESSNVPROC) (const GLuint64 *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +typedef void (APIENTRYP PFNGLCREATECOMMANDLISTSNVPROC) (GLsizei n, GLuint *lists); +typedef void (APIENTRYP PFNGLDELETECOMMANDLISTSNVPROC) (GLsizei n, const GLuint *lists); +typedef GLboolean (APIENTRYP PFNGLISCOMMANDLISTNVPROC) (GLuint list); +typedef void (APIENTRYP PFNGLLISTDRAWCOMMANDSSTATESCLIENTNVPROC) (GLuint list, GLuint segment, const void **indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +typedef void (APIENTRYP PFNGLCOMMANDLISTSEGMENTSNVPROC) (GLuint list, GLuint segments); +typedef void (APIENTRYP PFNGLCOMPILECOMMANDLISTNVPROC) (GLuint list); +typedef void (APIENTRYP PFNGLCALLCOMMANDLISTNVPROC) (GLuint list); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCreateStatesNV (GLsizei n, GLuint *states); +GLAPI void APIENTRY glDeleteStatesNV (GLsizei n, const GLuint *states); +GLAPI GLboolean APIENTRY glIsStateNV (GLuint state); +GLAPI void APIENTRY glStateCaptureNV (GLuint state, GLenum mode); +GLAPI GLuint APIENTRY glGetCommandHeaderNV (GLenum tokenID, GLuint size); +GLAPI GLushort APIENTRY glGetStageIndexNV (GLenum shadertype); +GLAPI void APIENTRY glDrawCommandsNV (GLenum primitiveMode, GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, GLuint count); +GLAPI void APIENTRY glDrawCommandsAddressNV (GLenum primitiveMode, const GLuint64 *indirects, const GLsizei *sizes, GLuint count); +GLAPI void APIENTRY glDrawCommandsStatesNV (GLuint buffer, const GLintptr *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +GLAPI void APIENTRY glDrawCommandsStatesAddressNV (const GLuint64 *indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +GLAPI void APIENTRY glCreateCommandListsNV (GLsizei n, GLuint *lists); +GLAPI void APIENTRY glDeleteCommandListsNV (GLsizei n, const GLuint *lists); +GLAPI GLboolean APIENTRY glIsCommandListNV (GLuint list); +GLAPI void APIENTRY glListDrawCommandsStatesClientNV (GLuint list, GLuint segment, const void **indirects, const GLsizei *sizes, const GLuint *states, const GLuint *fbos, GLuint count); +GLAPI void APIENTRY glCommandListSegmentsNV (GLuint list, GLuint segments); +GLAPI void APIENTRY glCompileCommandListNV (GLuint list); +GLAPI void APIENTRY glCallCommandListNV (GLuint list); +#endif +#endif /* GL_NV_command_list */ + #ifndef GL_NV_compute_program5 #define GL_NV_compute_program5 1 #define GL_COMPUTE_PROGRAM_NV 0x90FB #define GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV 0x90FC #endif /* GL_NV_compute_program5 */ +#ifndef GL_NV_compute_shader_derivatives +#define GL_NV_compute_shader_derivatives 1 +#endif /* GL_NV_compute_shader_derivatives */ + #ifndef GL_NV_conditional_render #define GL_NV_conditional_render 1 #define GL_QUERY_WAIT_NV 0x8E13 @@ -8522,6 +9686,49 @@ GLAPI void APIENTRY glEndConditionalRenderNV (void); #endif #endif /* GL_NV_conditional_render */ +#ifndef GL_NV_conservative_raster +#define GL_NV_conservative_raster 1 +#define GL_CONSERVATIVE_RASTERIZATION_NV 0x9346 +#define GL_SUBPIXEL_PRECISION_BIAS_X_BITS_NV 0x9347 +#define GL_SUBPIXEL_PRECISION_BIAS_Y_BITS_NV 0x9348 +#define GL_MAX_SUBPIXEL_PRECISION_BIAS_BITS_NV 0x9349 +typedef void (APIENTRYP PFNGLSUBPIXELPRECISIONBIASNVPROC) (GLuint xbits, GLuint ybits); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSubpixelPrecisionBiasNV (GLuint xbits, GLuint ybits); +#endif +#endif /* GL_NV_conservative_raster */ + +#ifndef GL_NV_conservative_raster_dilate +#define GL_NV_conservative_raster_dilate 1 +#define GL_CONSERVATIVE_RASTER_DILATE_NV 0x9379 +#define GL_CONSERVATIVE_RASTER_DILATE_RANGE_NV 0x937A +#define GL_CONSERVATIVE_RASTER_DILATE_GRANULARITY_NV 0x937B +typedef void (APIENTRYP PFNGLCONSERVATIVERASTERPARAMETERFNVPROC) (GLenum pname, GLfloat value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConservativeRasterParameterfNV (GLenum pname, GLfloat value); +#endif +#endif /* GL_NV_conservative_raster_dilate */ + +#ifndef GL_NV_conservative_raster_pre_snap +#define GL_NV_conservative_raster_pre_snap 1 +#define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_NV 0x9550 +#endif /* GL_NV_conservative_raster_pre_snap */ + +#ifndef GL_NV_conservative_raster_pre_snap_triangles +#define GL_NV_conservative_raster_pre_snap_triangles 1 +#define GL_CONSERVATIVE_RASTER_MODE_NV 0x954D +#define GL_CONSERVATIVE_RASTER_MODE_POST_SNAP_NV 0x954E +#define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_TRIANGLES_NV 0x954F +typedef void (APIENTRYP PFNGLCONSERVATIVERASTERPARAMETERINVPROC) (GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConservativeRasterParameteriNV (GLenum pname, GLint param); +#endif +#endif /* GL_NV_conservative_raster_pre_snap_triangles */ + +#ifndef GL_NV_conservative_raster_underestimation +#define GL_NV_conservative_raster_underestimation 1 +#endif /* GL_NV_conservative_raster_underestimation */ + #ifndef GL_NV_copy_depth_to_color #define GL_NV_copy_depth_to_color 1 #define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E @@ -8571,6 +9778,23 @@ GLAPI void APIENTRY glDrawTextureNV (GLuint texture, GLuint sampler, GLfloat x0, #endif #endif /* GL_NV_draw_texture */ +#ifndef GL_NV_draw_vulkan_image +#define GL_NV_draw_vulkan_image 1 +typedef void (APIENTRY *GLVULKANPROCNV)(void); +typedef void (APIENTRYP PFNGLDRAWVKIMAGENVPROC) (GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +typedef GLVULKANPROCNV (APIENTRYP PFNGLGETVKPROCADDRNVPROC) (const GLchar *name); +typedef void (APIENTRYP PFNGLWAITVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); +typedef void (APIENTRYP PFNGLSIGNALVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); +typedef void (APIENTRYP PFNGLSIGNALVKFENCENVPROC) (GLuint64 vkFence); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawVkImageNV (GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +GLAPI GLVULKANPROCNV APIENTRY glGetVkProcAddrNV (const GLchar *name); +GLAPI void APIENTRY glWaitVkSemaphoreNV (GLuint64 vkSemaphore); +GLAPI void APIENTRY glSignalVkSemaphoreNV (GLuint64 vkSemaphore); +GLAPI void APIENTRY glSignalVkFenceNV (GLuint64 vkFence); +#endif +#endif /* GL_NV_draw_vulkan_image */ + #ifndef GL_NV_evaluators #define GL_NV_evaluators 1 #define GL_EVAL_2D_NV 0x86C0 @@ -8664,6 +9888,11 @@ GLAPI void APIENTRY glSetFenceNV (GLuint fence, GLenum condition); #endif #endif /* GL_NV_fence */ +#ifndef GL_NV_fill_rectangle +#define GL_NV_fill_rectangle 1 +#define GL_FILL_RECTANGLE_NV 0x933C +#endif /* GL_NV_fill_rectangle */ + #ifndef GL_NV_float_buffer #define GL_NV_float_buffer 1 #define GL_FLOAT_R_NV 0x8880 @@ -8690,6 +9919,16 @@ GLAPI void APIENTRY glSetFenceNV (GLuint fence, GLenum condition); #define GL_EYE_PLANE_ABSOLUTE_NV 0x855C #endif /* GL_NV_fog_distance */ +#ifndef GL_NV_fragment_coverage_to_color +#define GL_NV_fragment_coverage_to_color 1 +#define GL_FRAGMENT_COVERAGE_TO_COLOR_NV 0x92DD +#define GL_FRAGMENT_COVERAGE_COLOR_NV 0x92DE +typedef void (APIENTRYP PFNGLFRAGMENTCOVERAGECOLORNVPROC) (GLuint color); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFragmentCoverageColorNV (GLuint color); +#endif +#endif /* GL_NV_fragment_coverage_to_color */ + #ifndef GL_NV_fragment_program #define GL_NV_fragment_program 1 #define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 @@ -8731,6 +9970,34 @@ GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, cons #define GL_NV_fragment_program_option 1 #endif /* GL_NV_fragment_program_option */ +#ifndef GL_NV_fragment_shader_barycentric +#define GL_NV_fragment_shader_barycentric 1 +#endif /* GL_NV_fragment_shader_barycentric */ + +#ifndef GL_NV_fragment_shader_interlock +#define GL_NV_fragment_shader_interlock 1 +#endif /* GL_NV_fragment_shader_interlock */ + +#ifndef GL_NV_framebuffer_mixed_samples +#define GL_NV_framebuffer_mixed_samples 1 +#define GL_COVERAGE_MODULATION_TABLE_NV 0x9331 +#define GL_COLOR_SAMPLES_NV 0x8E20 +#define GL_DEPTH_SAMPLES_NV 0x932D +#define GL_STENCIL_SAMPLES_NV 0x932E +#define GL_MIXED_DEPTH_SAMPLES_SUPPORTED_NV 0x932F +#define GL_MIXED_STENCIL_SAMPLES_SUPPORTED_NV 0x9330 +#define GL_COVERAGE_MODULATION_NV 0x9332 +#define GL_COVERAGE_MODULATION_TABLE_SIZE_NV 0x9333 +typedef void (APIENTRYP PFNGLCOVERAGEMODULATIONTABLENVPROC) (GLsizei n, const GLfloat *v); +typedef void (APIENTRYP PFNGLGETCOVERAGEMODULATIONTABLENVPROC) (GLsizei bufSize, GLfloat *v); +typedef void (APIENTRYP PFNGLCOVERAGEMODULATIONNVPROC) (GLenum components); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCoverageModulationTableNV (GLsizei n, const GLfloat *v); +GLAPI void APIENTRY glGetCoverageModulationTableNV (GLsizei bufSize, GLfloat *v); +GLAPI void APIENTRY glCoverageModulationNV (GLenum components); +#endif +#endif /* GL_NV_framebuffer_mixed_samples */ + #ifndef GL_NV_framebuffer_multisample_coverage #define GL_NV_framebuffer_multisample_coverage 1 #define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB @@ -8750,12 +10017,10 @@ GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, G #define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glProgramVertexLimitNV (GLenum target, GLint limit); GLAPI void APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); #endif #endif /* GL_NV_geometry_program4 */ @@ -8764,6 +10029,45 @@ GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachmen #define GL_NV_geometry_shader4 1 #endif /* GL_NV_geometry_shader4 */ +#ifndef GL_NV_geometry_shader_passthrough +#define GL_NV_geometry_shader_passthrough 1 +#endif /* GL_NV_geometry_shader_passthrough */ + +#ifndef GL_NV_gpu_multicast +#define GL_NV_gpu_multicast 1 +#define GL_PER_GPU_STORAGE_BIT_NV 0x0800 +#define GL_MULTICAST_GPUS_NV 0x92BA +#define GL_RENDER_GPU_MASK_NV 0x9558 +#define GL_PER_GPU_STORAGE_NV 0x9548 +#define GL_MULTICAST_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9549 +typedef void (APIENTRYP PFNGLRENDERGPUMASKNVPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLMULTICASTBUFFERSUBDATANVPROC) (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +typedef void (APIENTRYP PFNGLMULTICASTCOPYBUFFERSUBDATANVPROC) (GLuint readGpu, GLbitfield writeGpuMask, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLMULTICASTCOPYIMAGESUBDATANVPROC) (GLuint srcGpu, GLbitfield dstGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +typedef void (APIENTRYP PFNGLMULTICASTBLITFRAMEBUFFERNVPROC) (GLuint srcGpu, GLuint dstGpu, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (APIENTRYP PFNGLMULTICASTFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLuint gpu, GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTICASTBARRIERNVPROC) (void); +typedef void (APIENTRYP PFNGLMULTICASTWAITSYNCNVPROC) (GLuint signalGpu, GLbitfield waitGpuMask); +typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTIVNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTUIVNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTI64VNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLMULTICASTGETQUERYOBJECTUI64VNVPROC) (GLuint gpu, GLuint id, GLenum pname, GLuint64 *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderGpuMaskNV (GLbitfield mask); +GLAPI void APIENTRY glMulticastBufferSubDataNV (GLbitfield gpuMask, GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void APIENTRY glMulticastCopyBufferSubDataNV (GLuint readGpu, GLbitfield writeGpuMask, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glMulticastCopyImageSubDataNV (GLuint srcGpu, GLbitfield dstGpuMask, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +GLAPI void APIENTRY glMulticastBlitFramebufferNV (GLuint srcGpu, GLuint dstGpu, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI void APIENTRY glMulticastFramebufferSampleLocationsfvNV (GLuint gpu, GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glMulticastBarrierNV (void); +GLAPI void APIENTRY glMulticastWaitSyncNV (GLuint signalGpu, GLbitfield waitGpuMask); +GLAPI void APIENTRY glMulticastGetQueryObjectivNV (GLuint gpu, GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glMulticastGetQueryObjectuivNV (GLuint gpu, GLuint id, GLenum pname, GLuint *params); +GLAPI void APIENTRY glMulticastGetQueryObjecti64vNV (GLuint gpu, GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glMulticastGetQueryObjectui64vNV (GLuint gpu, GLuint id, GLenum pname, GLuint64 *params); +#endif +#endif /* GL_NV_gpu_multicast */ + #ifndef GL_NV_gpu_program4 #define GL_NV_gpu_program4 1 #define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 @@ -8936,15 +10240,116 @@ GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint index, GLsizei n, const GLhalfN #endif #endif /* GL_NV_half_float */ +#ifndef GL_NV_internalformat_sample_query +#define GL_NV_internalformat_sample_query 1 +#define GL_MULTISAMPLES_NV 0x9371 +#define GL_SUPERSAMPLE_SCALE_X_NV 0x9372 +#define GL_SUPERSAMPLE_SCALE_Y_NV 0x9373 +#define GL_CONFORMANT_NV 0x9374 +typedef void (APIENTRYP PFNGLGETINTERNALFORMATSAMPLEIVNVPROC) (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei count, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetInternalformatSampleivNV (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei count, GLint *params); +#endif +#endif /* GL_NV_internalformat_sample_query */ + #ifndef GL_NV_light_max_exponent #define GL_NV_light_max_exponent 1 #define GL_MAX_SHININESS_NV 0x8504 #define GL_MAX_SPOT_EXPONENT_NV 0x8505 #endif /* GL_NV_light_max_exponent */ +#ifndef GL_NV_memory_attachment +#define GL_NV_memory_attachment 1 +#define GL_ATTACHED_MEMORY_OBJECT_NV 0x95A4 +#define GL_ATTACHED_MEMORY_OFFSET_NV 0x95A5 +#define GL_MEMORY_ATTACHABLE_ALIGNMENT_NV 0x95A6 +#define GL_MEMORY_ATTACHABLE_SIZE_NV 0x95A7 +#define GL_MEMORY_ATTACHABLE_NV 0x95A8 +#define GL_DETACHED_MEMORY_INCARNATION_NV 0x95A9 +#define GL_DETACHED_TEXTURES_NV 0x95AA +#define GL_DETACHED_BUFFERS_NV 0x95AB +#define GL_MAX_DETACHED_TEXTURES_NV 0x95AC +#define GL_MAX_DETACHED_BUFFERS_NV 0x95AD +typedef void (APIENTRYP PFNGLGETMEMORYOBJECTDETACHEDRESOURCESUIVNVPROC) (GLuint memory, GLenum pname, GLint first, GLsizei count, GLuint *params); +typedef void (APIENTRYP PFNGLRESETMEMORYOBJECTPARAMETERNVPROC) (GLuint memory, GLenum pname); +typedef void (APIENTRYP PFNGLTEXATTACHMEMORYNVPROC) (GLenum target, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLBUFFERATTACHMEMORYNVPROC) (GLenum target, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLTEXTUREATTACHMEMORYNVPROC) (GLuint texture, GLuint memory, GLuint64 offset); +typedef void (APIENTRYP PFNGLNAMEDBUFFERATTACHMEMORYNVPROC) (GLuint buffer, GLuint memory, GLuint64 offset); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetMemoryObjectDetachedResourcesuivNV (GLuint memory, GLenum pname, GLint first, GLsizei count, GLuint *params); +GLAPI void APIENTRY glResetMemoryObjectParameterNV (GLuint memory, GLenum pname); +GLAPI void APIENTRY glTexAttachMemoryNV (GLenum target, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glBufferAttachMemoryNV (GLenum target, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glTextureAttachMemoryNV (GLuint texture, GLuint memory, GLuint64 offset); +GLAPI void APIENTRY glNamedBufferAttachMemoryNV (GLuint buffer, GLuint memory, GLuint64 offset); +#endif +#endif /* GL_NV_memory_attachment */ + +#ifndef GL_NV_mesh_shader +#define GL_NV_mesh_shader 1 +#define GL_MESH_SHADER_NV 0x9559 +#define GL_TASK_SHADER_NV 0x955A +#define GL_MAX_MESH_UNIFORM_BLOCKS_NV 0x8E60 +#define GL_MAX_MESH_TEXTURE_IMAGE_UNITS_NV 0x8E61 +#define GL_MAX_MESH_IMAGE_UNIFORMS_NV 0x8E62 +#define GL_MAX_MESH_UNIFORM_COMPONENTS_NV 0x8E63 +#define GL_MAX_MESH_ATOMIC_COUNTER_BUFFERS_NV 0x8E64 +#define GL_MAX_MESH_ATOMIC_COUNTERS_NV 0x8E65 +#define GL_MAX_MESH_SHADER_STORAGE_BLOCKS_NV 0x8E66 +#define GL_MAX_COMBINED_MESH_UNIFORM_COMPONENTS_NV 0x8E67 +#define GL_MAX_TASK_UNIFORM_BLOCKS_NV 0x8E68 +#define GL_MAX_TASK_TEXTURE_IMAGE_UNITS_NV 0x8E69 +#define GL_MAX_TASK_IMAGE_UNIFORMS_NV 0x8E6A +#define GL_MAX_TASK_UNIFORM_COMPONENTS_NV 0x8E6B +#define GL_MAX_TASK_ATOMIC_COUNTER_BUFFERS_NV 0x8E6C +#define GL_MAX_TASK_ATOMIC_COUNTERS_NV 0x8E6D +#define GL_MAX_TASK_SHADER_STORAGE_BLOCKS_NV 0x8E6E +#define GL_MAX_COMBINED_TASK_UNIFORM_COMPONENTS_NV 0x8E6F +#define GL_MAX_MESH_WORK_GROUP_INVOCATIONS_NV 0x95A2 +#define GL_MAX_TASK_WORK_GROUP_INVOCATIONS_NV 0x95A3 +#define GL_MAX_MESH_TOTAL_MEMORY_SIZE_NV 0x9536 +#define GL_MAX_TASK_TOTAL_MEMORY_SIZE_NV 0x9537 +#define GL_MAX_MESH_OUTPUT_VERTICES_NV 0x9538 +#define GL_MAX_MESH_OUTPUT_PRIMITIVES_NV 0x9539 +#define GL_MAX_TASK_OUTPUT_COUNT_NV 0x953A +#define GL_MAX_DRAW_MESH_TASKS_COUNT_NV 0x953D +#define GL_MAX_MESH_VIEWS_NV 0x9557 +#define GL_MESH_OUTPUT_PER_VERTEX_GRANULARITY_NV 0x92DF +#define GL_MESH_OUTPUT_PER_PRIMITIVE_GRANULARITY_NV 0x9543 +#define GL_MAX_MESH_WORK_GROUP_SIZE_NV 0x953B +#define GL_MAX_TASK_WORK_GROUP_SIZE_NV 0x953C +#define GL_MESH_WORK_GROUP_SIZE_NV 0x953E +#define GL_TASK_WORK_GROUP_SIZE_NV 0x953F +#define GL_MESH_VERTICES_OUT_NV 0x9579 +#define GL_MESH_PRIMITIVES_OUT_NV 0x957A +#define GL_MESH_OUTPUT_TYPE_NV 0x957B +#define GL_UNIFORM_BLOCK_REFERENCED_BY_MESH_SHADER_NV 0x959C +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TASK_SHADER_NV 0x959D +#define GL_REFERENCED_BY_MESH_SHADER_NV 0x95A0 +#define GL_REFERENCED_BY_TASK_SHADER_NV 0x95A1 +#define GL_MESH_SHADER_BIT_NV 0x00000040 +#define GL_TASK_SHADER_BIT_NV 0x00000080 +#define GL_MESH_SUBROUTINE_NV 0x957C +#define GL_TASK_SUBROUTINE_NV 0x957D +#define GL_MESH_SUBROUTINE_UNIFORM_NV 0x957E +#define GL_TASK_SUBROUTINE_UNIFORM_NV 0x957F +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_MESH_SHADER_NV 0x959E +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TASK_SHADER_NV 0x959F +typedef void (APIENTRYP PFNGLDRAWMESHTASKSNVPROC) (GLuint first, GLuint count); +typedef void (APIENTRYP PFNGLDRAWMESHTASKSINDIRECTNVPROC) (GLintptr indirect); +typedef void (APIENTRYP PFNGLMULTIDRAWMESHTASKSINDIRECTNVPROC) (GLintptr indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWMESHTASKSINDIRECTCOUNTNVPROC) (GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawMeshTasksNV (GLuint first, GLuint count); +GLAPI void APIENTRY glDrawMeshTasksIndirectNV (GLintptr indirect); +GLAPI void APIENTRY glMultiDrawMeshTasksIndirectNV (GLintptr indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawMeshTasksIndirectCountNV (GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#endif +#endif /* GL_NV_mesh_shader */ + #ifndef GL_NV_multisample_coverage #define GL_NV_multisample_coverage 1 -#define GL_COLOR_SAMPLES_NV 0x8E20 #endif /* GL_NV_multisample_coverage */ #ifndef GL_NV_multisample_filter_hint @@ -9057,13 +10462,11 @@ GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint bindi #define GL_SKIP_MISSING_GLYPH_NV 0x90A9 #define GL_USE_MISSING_GLYPH_NV 0x90AA #define GL_PATH_ERROR_POSITION_NV 0x90AB -#define GL_PATH_FOG_GEN_MODE_NV 0x90AC #define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD #define GL_ADJACENT_PAIRS_NV 0x90AE #define GL_FIRST_TO_REST_NV 0x90AF #define GL_PATH_GEN_MODE_NV 0x90B0 #define GL_PATH_GEN_COEFF_NV 0x90B1 -#define GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2 #define GL_PATH_GEN_COMPONENTS_NV 0x90B3 #define GL_PATH_STENCIL_FUNC_NV 0x90B7 #define GL_PATH_STENCIL_REF_NV 0x90B8 @@ -9132,8 +10535,44 @@ GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint bindi #define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000 #define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000 #define GL_FONT_HAS_KERNING_BIT_NV 0x10000000 +#define GL_ROUNDED_RECT_NV 0xE8 +#define GL_RELATIVE_ROUNDED_RECT_NV 0xE9 +#define GL_ROUNDED_RECT2_NV 0xEA +#define GL_RELATIVE_ROUNDED_RECT2_NV 0xEB +#define GL_ROUNDED_RECT4_NV 0xEC +#define GL_RELATIVE_ROUNDED_RECT4_NV 0xED +#define GL_ROUNDED_RECT8_NV 0xEE +#define GL_RELATIVE_ROUNDED_RECT8_NV 0xEF +#define GL_RELATIVE_RECT_NV 0xF7 +#define GL_FONT_GLYPHS_AVAILABLE_NV 0x9368 +#define GL_FONT_TARGET_UNAVAILABLE_NV 0x9369 +#define GL_FONT_UNAVAILABLE_NV 0x936A +#define GL_FONT_UNINTELLIGIBLE_NV 0x936B +#define GL_CONIC_CURVE_TO_NV 0x1A +#define GL_RELATIVE_CONIC_CURVE_TO_NV 0x1B +#define GL_FONT_NUM_GLYPH_INDICES_BIT_NV 0x20000000 +#define GL_STANDARD_FONT_FORMAT_NV 0x936C +#define GL_2_BYTES_NV 0x1407 +#define GL_3_BYTES_NV 0x1408 +#define GL_4_BYTES_NV 0x1409 +#define GL_EYE_LINEAR_NV 0x2400 +#define GL_OBJECT_LINEAR_NV 0x2401 +#define GL_CONSTANT_NV 0x8576 +#define GL_PATH_FOG_GEN_MODE_NV 0x90AC #define GL_PRIMARY_COLOR_NV 0x852C #define GL_SECONDARY_COLOR_NV 0x852D +#define GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2 +#define GL_PATH_PROJECTION_NV 0x1701 +#define GL_PATH_MODELVIEW_NV 0x1700 +#define GL_PATH_MODELVIEW_STACK_DEPTH_NV 0x0BA3 +#define GL_PATH_MODELVIEW_MATRIX_NV 0x0BA6 +#define GL_PATH_MAX_MODELVIEW_STACK_DEPTH_NV 0x0D36 +#define GL_PATH_TRANSPOSE_MODELVIEW_MATRIX_NV 0x84E3 +#define GL_PATH_PROJECTION_STACK_DEPTH_NV 0x0BA4 +#define GL_PATH_PROJECTION_MATRIX_NV 0x0BA7 +#define GL_PATH_MAX_PROJECTION_STACK_DEPTH_NV 0x0D38 +#define GL_PATH_TRANSPOSE_PROJECTION_MATRIX_NV 0x84E4 +#define GL_FRAGMENT_INPUT_NV 0x936D typedef GLuint (APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range); typedef void (APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); typedef GLboolean (APIENTRYP PFNGLISPATHNVPROC) (GLuint path); @@ -9160,9 +10599,6 @@ typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint refere typedef void (APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); typedef void (APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func); -typedef void (APIENTRYP PFNGLPATHCOLORGENNVPROC) (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); -typedef void (APIENTRYP PFNGLPATHTEXGENNVPROC) (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); -typedef void (APIENTRYP PFNGLPATHFOGGENNVPROC) (GLenum genMode); typedef void (APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); typedef void (APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode); typedef void (APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); @@ -9175,14 +10611,32 @@ typedef void (APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dash typedef void (APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); typedef void (APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); typedef void (APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); -typedef void (APIENTRYP PFNGLGETPATHCOLORGENIVNVPROC) (GLenum color, GLenum pname, GLint *value); -typedef void (APIENTRYP PFNGLGETPATHCOLORGENFVNVPROC) (GLenum color, GLenum pname, GLfloat *value); -typedef void (APIENTRYP PFNGLGETPATHTEXGENIVNVPROC) (GLenum texCoordSet, GLenum pname, GLint *value); -typedef void (APIENTRYP PFNGLGETPATHTEXGENFVNVPROC) (GLenum texCoordSet, GLenum pname, GLfloat *value); typedef GLboolean (APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); typedef GLboolean (APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); typedef GLfloat (APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); typedef GLboolean (APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +typedef void (APIENTRYP PFNGLMATRIXLOAD3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOAD3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULT3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULT3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); +typedef void (APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask, GLenum coverMode); +typedef void (APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef GLenum (APIENTRYP PFNGLPATHGLYPHINDEXRANGENVPROC) (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint baseAndCount[2]); +typedef GLenum (APIENTRYP PFNGLPATHGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef GLenum (APIENTRYP PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC) (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEFVNVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLfloat *params); +typedef void (APIENTRYP PFNGLPATHCOLORGENNVPROC) (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLPATHTEXGENNVPROC) (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLPATHFOGGENNVPROC) (GLenum genMode); +typedef void (APIENTRYP PFNGLGETPATHCOLORGENIVNVPROC) (GLenum color, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHCOLORGENFVNVPROC) (GLenum color, GLenum pname, GLfloat *value); +typedef void (APIENTRYP PFNGLGETPATHTEXGENIVNVPROC) (GLenum texCoordSet, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHTEXGENFVNVPROC) (GLenum texCoordSet, GLenum pname, GLfloat *value); #ifdef GL_GLEXT_PROTOTYPES GLAPI GLuint APIENTRY glGenPathsNV (GLsizei range); GLAPI void APIENTRY glDeletePathsNV (GLuint path, GLsizei range); @@ -9210,9 +10664,6 @@ GLAPI void APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint GLAPI void APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); GLAPI void APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); GLAPI void APIENTRY glPathCoverDepthFuncNV (GLenum func); -GLAPI void APIENTRY glPathColorGenNV (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); -GLAPI void APIENTRY glPathTexGenNV (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); -GLAPI void APIENTRY glPathFogGenNV (GLenum genMode); GLAPI void APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode); GLAPI void APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode); GLAPI void APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); @@ -9225,17 +10676,40 @@ GLAPI void APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray); GLAPI void APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); GLAPI void APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); GLAPI void APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); -GLAPI void APIENTRY glGetPathColorGenivNV (GLenum color, GLenum pname, GLint *value); -GLAPI void APIENTRY glGetPathColorGenfvNV (GLenum color, GLenum pname, GLfloat *value); -GLAPI void APIENTRY glGetPathTexGenivNV (GLenum texCoordSet, GLenum pname, GLint *value); -GLAPI void APIENTRY glGetPathTexGenfvNV (GLenum texCoordSet, GLenum pname, GLfloat *value); GLAPI GLboolean APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y); GLAPI GLboolean APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y); GLAPI GLfloat APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments); GLAPI GLboolean APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +GLAPI void APIENTRY glMatrixLoad3x2fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoad3x3fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoadTranspose3x3fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMult3x2fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMult3x3fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultTranspose3x3fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glStencilThenCoverFillPathNV (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); +GLAPI void APIENTRY glStencilThenCoverStrokePathNV (GLuint path, GLint reference, GLuint mask, GLenum coverMode); +GLAPI void APIENTRY glStencilThenCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glStencilThenCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI GLenum APIENTRY glPathGlyphIndexRangeNV (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint baseAndCount[2]); +GLAPI GLenum APIENTRY glPathGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI GLenum APIENTRY glPathMemoryGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glProgramPathFragmentInputGenNV (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); +GLAPI void APIENTRY glGetProgramResourcefvNV (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLfloat *params); +GLAPI void APIENTRY glPathColorGenNV (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); +GLAPI void APIENTRY glPathTexGenNV (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); +GLAPI void APIENTRY glPathFogGenNV (GLenum genMode); +GLAPI void APIENTRY glGetPathColorGenivNV (GLenum color, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathColorGenfvNV (GLenum color, GLenum pname, GLfloat *value); +GLAPI void APIENTRY glGetPathTexGenivNV (GLenum texCoordSet, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathTexGenfvNV (GLenum texCoordSet, GLenum pname, GLfloat *value); #endif #endif /* GL_NV_path_rendering */ +#ifndef GL_NV_path_rendering_shared_edge +#define GL_NV_path_rendering_shared_edge 1 +#define GL_SHARED_EDGE_NV 0xC0 +#endif /* GL_NV_path_rendering_shared_edge */ + #ifndef GL_NV_pixel_data_range #define GL_NV_pixel_data_range 1 #define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 @@ -9301,6 +10775,32 @@ GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index); #endif #endif /* GL_NV_primitive_restart */ +#ifndef GL_NV_query_resource +#define GL_NV_query_resource 1 +#define GL_QUERY_RESOURCE_TYPE_VIDMEM_ALLOC_NV 0x9540 +#define GL_QUERY_RESOURCE_MEMTYPE_VIDMEM_NV 0x9542 +#define GL_QUERY_RESOURCE_SYS_RESERVED_NV 0x9544 +#define GL_QUERY_RESOURCE_TEXTURE_NV 0x9545 +#define GL_QUERY_RESOURCE_RENDERBUFFER_NV 0x9546 +#define GL_QUERY_RESOURCE_BUFFEROBJECT_NV 0x9547 +typedef GLint (APIENTRYP PFNGLQUERYRESOURCENVPROC) (GLenum queryType, GLint tagId, GLuint count, GLint *buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glQueryResourceNV (GLenum queryType, GLint tagId, GLuint count, GLint *buffer); +#endif +#endif /* GL_NV_query_resource */ + +#ifndef GL_NV_query_resource_tag +#define GL_NV_query_resource_tag 1 +typedef void (APIENTRYP PFNGLGENQUERYRESOURCETAGNVPROC) (GLsizei n, GLint *tagIds); +typedef void (APIENTRYP PFNGLDELETEQUERYRESOURCETAGNVPROC) (GLsizei n, const GLint *tagIds); +typedef void (APIENTRYP PFNGLQUERYRESOURCETAGNVPROC) (GLint tagId, const GLchar *tagString); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueryResourceTagNV (GLsizei n, GLint *tagIds); +GLAPI void APIENTRY glDeleteQueryResourceTagNV (GLsizei n, const GLint *tagIds); +GLAPI void APIENTRY glQueryResourceTagNV (GLint tagId, const GLchar *tagString); +#endif +#endif /* GL_NV_query_resource_tag */ + #ifndef GL_NV_register_combiners #define GL_NV_register_combiners 1 #define GL_REGISTER_COMBINERS_NV 0x8522 @@ -9393,6 +10893,52 @@ GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, #endif #endif /* GL_NV_register_combiners2 */ +#ifndef GL_NV_representative_fragment_test +#define GL_NV_representative_fragment_test 1 +#define GL_REPRESENTATIVE_FRAGMENT_TEST_NV 0x937F +#endif /* GL_NV_representative_fragment_test */ + +#ifndef GL_NV_robustness_video_memory_purge +#define GL_NV_robustness_video_memory_purge 1 +#define GL_PURGED_CONTEXT_RESET_NV 0x92BB +#endif /* GL_NV_robustness_video_memory_purge */ + +#ifndef GL_NV_sample_locations +#define GL_NV_sample_locations 1 +#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_NV 0x933D +#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_NV 0x933E +#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_NV 0x933F +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_NV 0x9340 +#define GL_SAMPLE_LOCATION_NV 0x8E50 +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9341 +#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_NV 0x9342 +#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_NV 0x9343 +typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLRESOLVEDEPTHVALUESNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferSampleLocationsfvNV (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glNamedFramebufferSampleLocationsfvNV (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glResolveDepthValuesNV (void); +#endif +#endif /* GL_NV_sample_locations */ + +#ifndef GL_NV_sample_mask_override_coverage +#define GL_NV_sample_mask_override_coverage 1 +#endif /* GL_NV_sample_mask_override_coverage */ + +#ifndef GL_NV_scissor_exclusive +#define GL_NV_scissor_exclusive 1 +#define GL_SCISSOR_TEST_EXCLUSIVE_NV 0x9555 +#define GL_SCISSOR_BOX_EXCLUSIVE_NV 0x9556 +typedef void (APIENTRYP PFNGLSCISSOREXCLUSIVENVPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLSCISSOREXCLUSIVEARRAYVNVPROC) (GLuint first, GLsizei count, const GLint *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glScissorExclusiveNV (GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glScissorExclusiveArrayvNV (GLuint first, GLsizei count, const GLint *v); +#endif +#endif /* GL_NV_scissor_exclusive */ + #ifndef GL_NV_shader_atomic_counters #define GL_NV_shader_atomic_counters 1 #endif /* GL_NV_shader_atomic_counters */ @@ -9401,6 +10947,18 @@ GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, #define GL_NV_shader_atomic_float 1 #endif /* GL_NV_shader_atomic_float */ +#ifndef GL_NV_shader_atomic_float64 +#define GL_NV_shader_atomic_float64 1 +#endif /* GL_NV_shader_atomic_float64 */ + +#ifndef GL_NV_shader_atomic_fp16_vector +#define GL_NV_shader_atomic_fp16_vector 1 +#endif /* GL_NV_shader_atomic_fp16_vector */ + +#ifndef GL_NV_shader_atomic_int64 +#define GL_NV_shader_atomic_int64 1 +#endif /* GL_NV_shader_atomic_int64 */ + #ifndef GL_NV_shader_buffer_load #define GL_NV_shader_buffer_load 1 #define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D @@ -9445,6 +11003,15 @@ GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLs #define GL_NV_shader_storage_buffer_object 1 #endif /* GL_NV_shader_storage_buffer_object */ +#ifndef GL_NV_shader_subgroup_partitioned +#define GL_NV_shader_subgroup_partitioned 1 +#define GL_SUBGROUP_FEATURE_PARTITIONED_BIT_NV 0x00000100 +#endif /* GL_NV_shader_subgroup_partitioned */ + +#ifndef GL_NV_shader_texture_footprint +#define GL_NV_shader_texture_footprint 1 +#endif /* GL_NV_shader_texture_footprint */ + #ifndef GL_NV_shader_thread_group #define GL_NV_shader_thread_group 1 #define GL_WARP_SIZE_NV 0x9339 @@ -9456,6 +11023,51 @@ GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLs #define GL_NV_shader_thread_shuffle 1 #endif /* GL_NV_shader_thread_shuffle */ +#ifndef GL_NV_shading_rate_image +#define GL_NV_shading_rate_image 1 +#define GL_SHADING_RATE_IMAGE_NV 0x9563 +#define GL_SHADING_RATE_NO_INVOCATIONS_NV 0x9564 +#define GL_SHADING_RATE_1_INVOCATION_PER_PIXEL_NV 0x9565 +#define GL_SHADING_RATE_1_INVOCATION_PER_1X2_PIXELS_NV 0x9566 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X1_PIXELS_NV 0x9567 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X2_PIXELS_NV 0x9568 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X4_PIXELS_NV 0x9569 +#define GL_SHADING_RATE_1_INVOCATION_PER_4X2_PIXELS_NV 0x956A +#define GL_SHADING_RATE_1_INVOCATION_PER_4X4_PIXELS_NV 0x956B +#define GL_SHADING_RATE_2_INVOCATIONS_PER_PIXEL_NV 0x956C +#define GL_SHADING_RATE_4_INVOCATIONS_PER_PIXEL_NV 0x956D +#define GL_SHADING_RATE_8_INVOCATIONS_PER_PIXEL_NV 0x956E +#define GL_SHADING_RATE_16_INVOCATIONS_PER_PIXEL_NV 0x956F +#define GL_SHADING_RATE_IMAGE_BINDING_NV 0x955B +#define GL_SHADING_RATE_IMAGE_TEXEL_WIDTH_NV 0x955C +#define GL_SHADING_RATE_IMAGE_TEXEL_HEIGHT_NV 0x955D +#define GL_SHADING_RATE_IMAGE_PALETTE_SIZE_NV 0x955E +#define GL_MAX_COARSE_FRAGMENT_SAMPLES_NV 0x955F +#define GL_SHADING_RATE_SAMPLE_ORDER_DEFAULT_NV 0x95AE +#define GL_SHADING_RATE_SAMPLE_ORDER_PIXEL_MAJOR_NV 0x95AF +#define GL_SHADING_RATE_SAMPLE_ORDER_SAMPLE_MAJOR_NV 0x95B0 +typedef void (APIENTRYP PFNGLBINDSHADINGRATEIMAGENVPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLGETSHADINGRATEIMAGEPALETTENVPROC) (GLuint viewport, GLuint entry, GLenum *rate); +typedef void (APIENTRYP PFNGLGETSHADINGRATESAMPLELOCATIONIVNVPROC) (GLenum rate, GLuint samples, GLuint index, GLint *location); +typedef void (APIENTRYP PFNGLSHADINGRATEIMAGEBARRIERNVPROC) (GLboolean synchronize); +typedef void (APIENTRYP PFNGLSHADINGRATEIMAGEPALETTENVPROC) (GLuint viewport, GLuint first, GLsizei count, const GLenum *rates); +typedef void (APIENTRYP PFNGLSHADINGRATESAMPLEORDERNVPROC) (GLenum order); +typedef void (APIENTRYP PFNGLSHADINGRATESAMPLEORDERCUSTOMNVPROC) (GLenum rate, GLuint samples, const GLint *locations); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindShadingRateImageNV (GLuint texture); +GLAPI void APIENTRY glGetShadingRateImagePaletteNV (GLuint viewport, GLuint entry, GLenum *rate); +GLAPI void APIENTRY glGetShadingRateSampleLocationivNV (GLenum rate, GLuint samples, GLuint index, GLint *location); +GLAPI void APIENTRY glShadingRateImageBarrierNV (GLboolean synchronize); +GLAPI void APIENTRY glShadingRateImagePaletteNV (GLuint viewport, GLuint first, GLsizei count, const GLenum *rates); +GLAPI void APIENTRY glShadingRateSampleOrderNV (GLenum order); +GLAPI void APIENTRY glShadingRateSampleOrderCustomNV (GLenum rate, GLuint samples, const GLint *locations); +#endif +#endif /* GL_NV_shading_rate_image */ + +#ifndef GL_NV_stereo_view_rendering +#define GL_NV_stereo_view_rendering 1 +#endif /* GL_NV_stereo_view_rendering */ + #ifndef GL_NV_tessellation_program5 #define GL_NV_tessellation_program5 1 #define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 @@ -9532,6 +11144,10 @@ GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenu #define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 #endif /* GL_NV_texture_rectangle */ +#ifndef GL_NV_texture_rectangle_compressed +#define GL_NV_texture_rectangle_compressed 1 +#endif /* GL_NV_texture_rectangle_compressed */ + #ifndef GL_NV_texture_shader #define GL_NV_texture_shader 1 #define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C @@ -9670,7 +11286,7 @@ GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenu #define GL_SKIP_COMPONENTS1_NV -6 typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLenum bufferMode); typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); @@ -9683,7 +11299,7 @@ typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKSTREAMATTRIBSNVPROC) (GLsizei coun #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum primitiveMode); GLAPI void APIENTRY glEndTransformFeedbackNV (void); -GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLuint count, const GLint *attribs, GLenum bufferMode); +GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLsizei count, const GLint *attribs, GLenum bufferMode); GLAPI void APIENTRY glBindBufferRangeNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); GLAPI void APIENTRY glBindBufferOffsetNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset); GLAPI void APIENTRY glBindBufferBaseNV (GLenum target, GLuint index, GLuint buffer); @@ -9720,6 +11336,13 @@ GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum mode, GLuint id); #endif #endif /* GL_NV_transform_feedback2 */ +#ifndef GL_NV_uniform_buffer_unified_memory +#define GL_NV_uniform_buffer_unified_memory 1 +#define GL_UNIFORM_BUFFER_UNIFIED_NV 0x936E +#define GL_UNIFORM_BUFFER_ADDRESS_NV 0x936F +#define GL_UNIFORM_BUFFER_LENGTH_NV 0x9370 +#endif /* GL_NV_uniform_buffer_unified_memory */ + #ifndef GL_NV_vdpau_interop #define GL_NV_vdpau_interop 1 typedef GLintptr GLvdpauSurfaceNV; @@ -9733,7 +11356,7 @@ typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (const typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); typedef GLboolean (APIENTRYP PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface); typedef void (APIENTRYP PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface); -typedef void (APIENTRYP PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +typedef void (APIENTRYP PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei count, GLsizei *length, GLint *values); typedef void (APIENTRYP PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access); typedef void (APIENTRYP PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); @@ -9744,13 +11367,21 @@ GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (const void *vdpSu GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterOutputSurfaceNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); GLAPI GLboolean APIENTRY glVDPAUIsSurfaceNV (GLvdpauSurfaceNV surface); GLAPI void APIENTRY glVDPAUUnregisterSurfaceNV (GLvdpauSurfaceNV surface); -GLAPI void APIENTRY glVDPAUGetSurfaceivNV (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +GLAPI void APIENTRY glVDPAUGetSurfaceivNV (GLvdpauSurfaceNV surface, GLenum pname, GLsizei count, GLsizei *length, GLint *values); GLAPI void APIENTRY glVDPAUSurfaceAccessNV (GLvdpauSurfaceNV surface, GLenum access); GLAPI void APIENTRY glVDPAUMapSurfacesNV (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); GLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); #endif #endif /* GL_NV_vdpau_interop */ +#ifndef GL_NV_vdpau_interop2 +#define GL_NV_vdpau_interop2 1 +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACEWITHPICTURESTRUCTURENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames, GLboolean isFrameStructure); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceWithPictureStructureNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames, GLboolean isFrameStructure); +#endif +#endif /* GL_NV_vdpau_interop2 */ + #ifndef GL_NV_vertex_array_range #define GL_NV_vertex_array_range 1 #define GL_VERTEX_ARRAY_RANGE_NV 0x851D @@ -10215,6 +11846,30 @@ GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot #endif #endif /* GL_NV_video_capture */ +#ifndef GL_NV_viewport_array2 +#define GL_NV_viewport_array2 1 +#endif /* GL_NV_viewport_array2 */ + +#ifndef GL_NV_viewport_swizzle +#define GL_NV_viewport_swizzle 1 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_X_NV 0x9350 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_X_NV 0x9351 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_Y_NV 0x9352 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_Y_NV 0x9353 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_Z_NV 0x9354 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_Z_NV 0x9355 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_W_NV 0x9356 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_W_NV 0x9357 +#define GL_VIEWPORT_SWIZZLE_X_NV 0x9358 +#define GL_VIEWPORT_SWIZZLE_Y_NV 0x9359 +#define GL_VIEWPORT_SWIZZLE_Z_NV 0x935A +#define GL_VIEWPORT_SWIZZLE_W_NV 0x935B +typedef void (APIENTRYP PFNGLVIEWPORTSWIZZLENVPROC) (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glViewportSwizzleNV (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); +#endif +#endif /* GL_NV_viewport_swizzle */ + #ifndef GL_OML_interlace #define GL_OML_interlace 1 #define GL_INTERLACE_OML 0x8980 @@ -10237,6 +11892,22 @@ GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot #define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 #endif /* GL_OML_subsample */ +#ifndef GL_OVR_multiview +#define GL_OVR_multiview 1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR 0x9630 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR 0x9632 +#define GL_MAX_VIEWS_OVR 0x9631 +#define GL_FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR 0x9633 +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferTextureMultiviewOVR (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); +#endif +#endif /* GL_OVR_multiview */ + +#ifndef GL_OVR_multiview2 +#define GL_OVR_multiview2 1 +#endif /* GL_OVR_multiview2 */ + #ifndef GL_PGI_misc_hints #define GL_PGI_misc_hints 1 #define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 @@ -10793,10 +12464,10 @@ GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *equation); #ifndef GL_SGIX_resample #define GL_SGIX_resample 1 -#define GL_PACK_RESAMPLE_SGIX 0x842C -#define GL_UNPACK_RESAMPLE_SGIX 0x842D -#define GL_RESAMPLE_REPLICATE_SGIX 0x842E -#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F +#define GL_PACK_RESAMPLE_SGIX 0x842E +#define GL_UNPACK_RESAMPLE_SGIX 0x842F +#define GL_RESAMPLE_REPLICATE_SGIX 0x8433 +#define GL_RESAMPLE_ZERO_FILL_SGIX 0x8434 #define GL_RESAMPLE_DECIMATE_SGIX 0x8430 #endif /* GL_SGIX_resample */ diff --git a/thirdparty/include/GL/glxext.h b/thirdparty/include/GL/glxext.h index 269653dd7..8dcc87cec 100644 --- a/thirdparty/include/GL/glxext.h +++ b/thirdparty/include/GL/glxext.h @@ -1,12 +1,12 @@ -#ifndef __glxext_h_ -#define __glxext_h_ 1 +#ifndef __glx_glxext_h_ +#define __glx_glxext_h_ 1 #ifdef __cplusplus extern "C" { #endif /* -** Copyright (c) 2013-2014 The Khronos Group Inc. +** Copyright (c) 2013-2018 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the @@ -31,12 +31,10 @@ extern "C" { ** This header is generated from the Khronos OpenGL / OpenGL ES XML ** API Registry. The current version of the Registry, generator scripts ** used to make the header, and the header can be found at -** http://www.opengl.org/registry/ -** -** Khronos $Revision: 27022 $ on $Date: 2014-06-10 08:30:04 -0700 (Tue, 10 Jun 2014) $ +** https://github.com/KhronosGroup/OpenGL-Registry */ -#define GLX_GLXEXT_VERSION 20140610 +#define GLX_GLXEXT_VERSION 20200408 /* Generated C header for: * API: glx @@ -158,6 +156,13 @@ __GLXextFuncPtr glXGetProcAddress (const GLubyte *procName); #endif #endif /* GLX_VERSION_1_4 */ +#ifndef GLX_ARB_context_flush_control +#define GLX_ARB_context_flush_control 1 +#define GLX_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 +#define GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0 +#define GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 +#endif /* GLX_ARB_context_flush_control */ + #ifndef GLX_ARB_create_context #define GLX_ARB_create_context 1 #define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001 @@ -171,6 +176,11 @@ GLXContext glXCreateContextAttribsARB (Display *dpy, GLXFBConfig config, GLXCont #endif #endif /* GLX_ARB_create_context */ +#ifndef GLX_ARB_create_context_no_error +#define GLX_ARB_create_context_no_error 1 +#define GLX_CONTEXT_OPENGL_NO_ERROR_ARB 0x31B3 +#endif /* GLX_ARB_create_context_no_error */ + #ifndef GLX_ARB_create_context_profile #define GLX_ARB_create_context_profile 1 #define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 @@ -243,6 +253,26 @@ __GLXextFuncPtr glXGetProcAddressARB (const GLubyte *procName); #define GLX_GPU_NUM_SIMD_AMD 0x21A6 #define GLX_GPU_NUM_RB_AMD 0x21A7 #define GLX_GPU_NUM_SPI_AMD 0x21A8 +typedef unsigned int ( *PFNGLXGETGPUIDSAMDPROC) (unsigned int maxCount, unsigned int *ids); +typedef int ( *PFNGLXGETGPUINFOAMDPROC) (unsigned int id, int property, GLenum dataType, unsigned int size, void *data); +typedef unsigned int ( *PFNGLXGETCONTEXTGPUIDAMDPROC) (GLXContext ctx); +typedef GLXContext ( *PFNGLXCREATEASSOCIATEDCONTEXTAMDPROC) (unsigned int id, GLXContext share_list); +typedef GLXContext ( *PFNGLXCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (unsigned int id, GLXContext share_context, const int *attribList); +typedef Bool ( *PFNGLXDELETEASSOCIATEDCONTEXTAMDPROC) (GLXContext ctx); +typedef Bool ( *PFNGLXMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (GLXContext ctx); +typedef GLXContext ( *PFNGLXGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void); +typedef void ( *PFNGLXBLITCONTEXTFRAMEBUFFERAMDPROC) (GLXContext dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#ifdef GLX_GLXEXT_PROTOTYPES +unsigned int glXGetGPUIDsAMD (unsigned int maxCount, unsigned int *ids); +int glXGetGPUInfoAMD (unsigned int id, int property, GLenum dataType, unsigned int size, void *data); +unsigned int glXGetContextGPUIDAMD (GLXContext ctx); +GLXContext glXCreateAssociatedContextAMD (unsigned int id, GLXContext share_list); +GLXContext glXCreateAssociatedContextAttribsAMD (unsigned int id, GLXContext share_context, const int *attribList); +Bool glXDeleteAssociatedContextAMD (GLXContext ctx); +Bool glXMakeAssociatedContextCurrentAMD (GLXContext ctx); +GLXContext glXGetCurrentAssociatedContextAMD (void); +void glXBlitContextFramebufferAMD (GLXContext dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif #endif /* GLX_AMD_gpu_association */ #ifndef GLX_EXT_buffer_age @@ -250,6 +280,14 @@ __GLXextFuncPtr glXGetProcAddressARB (const GLubyte *procName); #define GLX_BACK_BUFFER_AGE_EXT 0x20F4 #endif /* GLX_EXT_buffer_age */ +#ifndef GLX_EXT_context_priority +#define GLX_EXT_context_priority 1 +#define GLX_CONTEXT_PRIORITY_LEVEL_EXT 0x3100 +#define GLX_CONTEXT_PRIORITY_HIGH_EXT 0x3101 +#define GLX_CONTEXT_PRIORITY_MEDIUM_EXT 0x3102 +#define GLX_CONTEXT_PRIORITY_LOW_EXT 0x3103 +#endif /* GLX_EXT_context_priority */ + #ifndef GLX_EXT_create_context_es2_profile #define GLX_EXT_create_context_es2_profile 1 #define GLX_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 @@ -290,6 +328,15 @@ void glXFreeContextEXT (Display *dpy, GLXContext context); #endif #endif /* GLX_EXT_import_context */ +#ifndef GLX_EXT_libglvnd +#define GLX_EXT_libglvnd 1 +#define GLX_VENDOR_NAMES_EXT 0x20F6 +#endif /* GLX_EXT_libglvnd */ + +#ifndef GLX_EXT_no_config_context +#define GLX_EXT_no_config_context 1 +#endif /* GLX_EXT_no_config_context */ + #ifndef GLX_EXT_stereo_tree #define GLX_EXT_stereo_tree 1 typedef struct { @@ -437,7 +484,6 @@ GLXPixmap glXCreateGLXPixmapMESA (Display *dpy, XVisualInfo *visual, Pixmap pixm #define GLX_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION_MESA 0x818B #define GLX_RENDERER_OPENGL_ES_PROFILE_VERSION_MESA 0x818C #define GLX_RENDERER_OPENGL_ES2_PROFILE_VERSION_MESA 0x818D -#define GLX_RENDERER_ID_MESA 0x818E typedef Bool ( *PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC) (int attribute, unsigned int *value); typedef const char *( *PFNGLXQUERYCURRENTRENDERERSTRINGMESAPROC) (int attribute); typedef Bool ( *PFNGLXQUERYRENDERERINTEGERMESAPROC) (Display *dpy, int screen, int renderer, int attribute, unsigned int *value); @@ -462,12 +508,32 @@ Bool glXReleaseBuffersMESA (Display *dpy, GLXDrawable drawable); #define GLX_MESA_set_3dfx_mode 1 #define GLX_3DFX_WINDOW_MODE_MESA 0x1 #define GLX_3DFX_FULLSCREEN_MODE_MESA 0x2 -typedef Bool ( *PFNGLXSET3DFXMODEMESAPROC) (int mode); +typedef GLboolean ( *PFNGLXSET3DFXMODEMESAPROC) (GLint mode); #ifdef GLX_GLXEXT_PROTOTYPES -Bool glXSet3DfxModeMESA (int mode); +GLboolean glXSet3DfxModeMESA (GLint mode); #endif #endif /* GLX_MESA_set_3dfx_mode */ +#ifndef GLX_MESA_swap_control +#define GLX_MESA_swap_control 1 +typedef int ( *PFNGLXGETSWAPINTERVALMESAPROC) (void); +typedef int ( *PFNGLXSWAPINTERVALMESAPROC) (unsigned int interval); +#ifdef GLX_GLXEXT_PROTOTYPES +int glXGetSwapIntervalMESA (void); +int glXSwapIntervalMESA (unsigned int interval); +#endif +#endif /* GLX_MESA_swap_control */ + +#ifndef GLX_NV_copy_buffer +#define GLX_NV_copy_buffer 1 +typedef void ( *PFNGLXCOPYBUFFERSUBDATANVPROC) (Display *dpy, GLXContext readCtx, GLXContext writeCtx, GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void ( *PFNGLXNAMEDCOPYBUFFERSUBDATANVPROC) (Display *dpy, GLXContext readCtx, GLXContext writeCtx, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +#ifdef GLX_GLXEXT_PROTOTYPES +void glXCopyBufferSubDataNV (Display *dpy, GLXContext readCtx, GLXContext writeCtx, GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +void glXNamedCopyBufferSubDataNV (Display *dpy, GLXContext readCtx, GLXContext writeCtx, GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +#endif +#endif /* GLX_NV_copy_buffer */ + #ifndef GLX_NV_copy_image #define GLX_NV_copy_image 1 typedef void ( *PFNGLXCOPYIMAGESUBDATANVPROC) (Display *dpy, GLXContext srcCtx, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLXContext dstCtx, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); @@ -489,6 +555,15 @@ Bool glXDelayBeforeSwapNV (Display *dpy, GLXDrawable drawable, GLfloat seconds); #define GLX_FLOAT_COMPONENTS_NV 0x20B0 #endif /* GLX_NV_float_buffer */ +#ifndef GLX_NV_multigpu_context +#define GLX_NV_multigpu_context 1 +#define GLX_CONTEXT_MULTIGPU_ATTRIB_NV 0x20AA +#define GLX_CONTEXT_MULTIGPU_ATTRIB_SINGLE_NV 0x20AB +#define GLX_CONTEXT_MULTIGPU_ATTRIB_AFR_NV 0x20AC +#define GLX_CONTEXT_MULTIGPU_ATTRIB_MULTICAST_NV 0x20AD +#define GLX_CONTEXT_MULTIGPU_ATTRIB_MULTI_DISPLAY_MULTICAST_NV 0x20AE +#endif /* GLX_NV_multigpu_context */ + #ifndef GLX_NV_multisample_coverage #define GLX_NV_multisample_coverage 1 #define GLX_COVERAGE_SAMPLES_NV 100001 @@ -506,6 +581,11 @@ int glXBindVideoDeviceNV (Display *dpy, unsigned int video_slot, unsigned int vi #endif #endif /* GLX_NV_present_video */ +#ifndef GLX_NV_robustness_video_memory_purge +#define GLX_NV_robustness_video_memory_purge 1 +#define GLX_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV 0x20F7 +#endif /* GLX_NV_robustness_video_memory_purge */ + #ifndef GLX_NV_swap_group #define GLX_NV_swap_group 1 typedef Bool ( *PFNGLXJOINSWAPGROUPNVPROC) (Display *dpy, GLXDrawable drawable, GLuint group); @@ -772,13 +852,13 @@ int glXQueryHyperpipeAttribSGIX (Display *dpy, int timeSlice, int attrib, int si #define GLX_PBUFFER_SGIX 0x8023 typedef GLXPbufferSGIX ( *PFNGLXCREATEGLXPBUFFERSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list); typedef void ( *PFNGLXDESTROYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf); -typedef int ( *PFNGLXQUERYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value); +typedef void ( *PFNGLXQUERYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value); typedef void ( *PFNGLXSELECTEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long mask); typedef void ( *PFNGLXGETSELECTEDEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long *mask); #ifdef GLX_GLXEXT_PROTOTYPES GLXPbufferSGIX glXCreateGLXPbufferSGIX (Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list); void glXDestroyGLXPbufferSGIX (Display *dpy, GLXPbufferSGIX pbuf); -int glXQueryGLXPbufferSGIX (Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value); +void glXQueryGLXPbufferSGIX (Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value); void glXSelectEventSGIX (Display *dpy, GLXDrawable drawable, unsigned long mask); void glXGetSelectedEventSGIX (Display *dpy, GLXDrawable drawable, unsigned long *mask); #endif @@ -876,9 +956,9 @@ int glXWaitVideoSyncSGI (int divisor, int remainder, unsigned int *count); #ifndef GLX_SUN_get_transparent_index #define GLX_SUN_get_transparent_index 1 -typedef Status ( *PFNGLXGETTRANSPARENTINDEXSUNPROC) (Display *dpy, Window overlay, Window underlay, long *pTransparentIndex); +typedef Status ( *PFNGLXGETTRANSPARENTINDEXSUNPROC) (Display *dpy, Window overlay, Window underlay, unsigned long *pTransparentIndex); #ifdef GLX_GLXEXT_PROTOTYPES -Status glXGetTransparentIndexSUN (Display *dpy, Window overlay, Window underlay, long *pTransparentIndex); +Status glXGetTransparentIndexSUN (Display *dpy, Window overlay, Window underlay, unsigned long *pTransparentIndex); #endif #endif /* GLX_SUN_get_transparent_index */ diff --git a/thirdparty/include/GL/wgl.h b/thirdparty/include/GL/wgl.h new file mode 100644 index 000000000..07b4a8ea3 --- /dev/null +++ b/thirdparty/include/GL/wgl.h @@ -0,0 +1,955 @@ +#ifndef __wgl_wgl_h_ +#define __wgl_wgl_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2013-2018 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are 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 Materials. +** +** THE MATERIALS ARE 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 +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ +/* +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** https://github.com/KhronosGroup/OpenGL-Registry +*/ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#define WIN32_LEAN_AND_MEAN 1 +#include +#endif + +/* Generated on date 20200408 */ + +/* Generated C header for: + * API: wgl + * Versions considered: .* + * Versions emitted: .* + * Default extensions included: wgl + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef WGL_VERSION_1_0 +#define WGL_VERSION_1_0 1 +#define WGL_FONT_LINES 0 +#define WGL_FONT_POLYGONS 1 +#define WGL_SWAP_MAIN_PLANE 0x00000001 +#define WGL_SWAP_OVERLAY1 0x00000002 +#define WGL_SWAP_OVERLAY2 0x00000004 +#define WGL_SWAP_OVERLAY3 0x00000008 +#define WGL_SWAP_OVERLAY4 0x00000010 +#define WGL_SWAP_OVERLAY5 0x00000020 +#define WGL_SWAP_OVERLAY6 0x00000040 +#define WGL_SWAP_OVERLAY7 0x00000080 +#define WGL_SWAP_OVERLAY8 0x00000100 +#define WGL_SWAP_OVERLAY9 0x00000200 +#define WGL_SWAP_OVERLAY10 0x00000400 +#define WGL_SWAP_OVERLAY11 0x00000800 +#define WGL_SWAP_OVERLAY12 0x00001000 +#define WGL_SWAP_OVERLAY13 0x00002000 +#define WGL_SWAP_OVERLAY14 0x00004000 +#define WGL_SWAP_OVERLAY15 0x00008000 +#define WGL_SWAP_UNDERLAY1 0x00010000 +#define WGL_SWAP_UNDERLAY2 0x00020000 +#define WGL_SWAP_UNDERLAY3 0x00040000 +#define WGL_SWAP_UNDERLAY4 0x00080000 +#define WGL_SWAP_UNDERLAY5 0x00100000 +#define WGL_SWAP_UNDERLAY6 0x00200000 +#define WGL_SWAP_UNDERLAY7 0x00400000 +#define WGL_SWAP_UNDERLAY8 0x00800000 +#define WGL_SWAP_UNDERLAY9 0x01000000 +#define WGL_SWAP_UNDERLAY10 0x02000000 +#define WGL_SWAP_UNDERLAY11 0x04000000 +#define WGL_SWAP_UNDERLAY12 0x08000000 +#define WGL_SWAP_UNDERLAY13 0x10000000 +#define WGL_SWAP_UNDERLAY14 0x20000000 +#define WGL_SWAP_UNDERLAY15 0x40000000 +typedef int (WINAPI * PFNCHOOSEPIXELFORMATPROC) (HDC hDc, const PIXELFORMATDESCRIPTOR *pPfd); +typedef int (WINAPI * PFNDESCRIBEPIXELFORMATPROC) (HDC hdc, int ipfd, UINT cjpfd, const PIXELFORMATDESCRIPTOR *ppfd); +typedef UINT (WINAPI * PFNGETENHMETAFILEPIXELFORMATPROC) (HENHMETAFILE hemf, const PIXELFORMATDESCRIPTOR *ppfd); +typedef int (WINAPI * PFNGETPIXELFORMATPROC) (HDC hdc); +typedef BOOL (WINAPI * PFNSETPIXELFORMATPROC) (HDC hdc, int ipfd, const PIXELFORMATDESCRIPTOR *ppfd); +typedef BOOL (WINAPI * PFNSWAPBUFFERSPROC) (HDC hdc); +typedef BOOL (WINAPI * PFNWGLCOPYCONTEXTPROC) (HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask); +typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTPROC) (HDC hDc); +typedef HGLRC (WINAPI * PFNWGLCREATELAYERCONTEXTPROC) (HDC hDc, int level); +typedef BOOL (WINAPI * PFNWGLDELETECONTEXTPROC) (HGLRC oldContext); +typedef BOOL (WINAPI * PFNWGLDESCRIBELAYERPLANEPROC) (HDC hDc, int pixelFormat, int layerPlane, UINT nBytes, const LAYERPLANEDESCRIPTOR *plpd); +typedef HGLRC (WINAPI * PFNWGLGETCURRENTCONTEXTPROC) (void); +typedef HDC (WINAPI * PFNWGLGETCURRENTDCPROC) (void); +typedef int (WINAPI * PFNWGLGETLAYERPALETTEENTRIESPROC) (HDC hdc, int iLayerPlane, int iStart, int cEntries, const COLORREF *pcr); +typedef PROC (WINAPI * PFNWGLGETPROCADDRESSPROC) (LPCSTR lpszProc); +typedef BOOL (WINAPI * PFNWGLMAKECURRENTPROC) (HDC hDc, HGLRC newContext); +typedef BOOL (WINAPI * PFNWGLREALIZELAYERPALETTEPROC) (HDC hdc, int iLayerPlane, BOOL bRealize); +typedef int (WINAPI * PFNWGLSETLAYERPALETTEENTRIESPROC) (HDC hdc, int iLayerPlane, int iStart, int cEntries, const COLORREF *pcr); +typedef BOOL (WINAPI * PFNWGLSHARELISTSPROC) (HGLRC hrcSrvShare, HGLRC hrcSrvSource); +typedef BOOL (WINAPI * PFNWGLSWAPLAYERBUFFERSPROC) (HDC hdc, UINT fuFlags); +typedef BOOL (WINAPI * PFNWGLUSEFONTBITMAPSPROC) (HDC hDC, DWORD first, DWORD count, DWORD listBase); +typedef BOOL (WINAPI * PFNWGLUSEFONTBITMAPSAPROC) (HDC hDC, DWORD first, DWORD count, DWORD listBase); +typedef BOOL (WINAPI * PFNWGLUSEFONTBITMAPSWPROC) (HDC hDC, DWORD first, DWORD count, DWORD listBase); +typedef BOOL (WINAPI * PFNWGLUSEFONTOUTLINESPROC) (HDC hDC, DWORD first, DWORD count, DWORD listBase, FLOAT deviation, FLOAT extrusion, int format, LPGLYPHMETRICSFLOAT lpgmf); +typedef BOOL (WINAPI * PFNWGLUSEFONTOUTLINESAPROC) (HDC hDC, DWORD first, DWORD count, DWORD listBase, FLOAT deviation, FLOAT extrusion, int format, LPGLYPHMETRICSFLOAT lpgmf); +typedef BOOL (WINAPI * PFNWGLUSEFONTOUTLINESWPROC) (HDC hDC, DWORD first, DWORD count, DWORD listBase, FLOAT deviation, FLOAT extrusion, int format, LPGLYPHMETRICSFLOAT lpgmf); +#ifdef WGL_WGLEXT_PROTOTYPES +int WINAPI ChoosePixelFormat (HDC hDc, const PIXELFORMATDESCRIPTOR *pPfd); +int WINAPI DescribePixelFormat (HDC hdc, int ipfd, UINT cjpfd, const PIXELFORMATDESCRIPTOR *ppfd); +UINT WINAPI GetEnhMetaFilePixelFormat (HENHMETAFILE hemf, const PIXELFORMATDESCRIPTOR *ppfd); +int WINAPI GetPixelFormat (HDC hdc); +BOOL WINAPI SetPixelFormat (HDC hdc, int ipfd, const PIXELFORMATDESCRIPTOR *ppfd); +BOOL WINAPI SwapBuffers (HDC hdc); +BOOL WINAPI wglCopyContext (HGLRC hglrcSrc, HGLRC hglrcDst, UINT mask); +HGLRC WINAPI wglCreateContext (HDC hDc); +HGLRC WINAPI wglCreateLayerContext (HDC hDc, int level); +BOOL WINAPI wglDeleteContext (HGLRC oldContext); +BOOL WINAPI wglDescribeLayerPlane (HDC hDc, int pixelFormat, int layerPlane, UINT nBytes, const LAYERPLANEDESCRIPTOR *plpd); +HGLRC WINAPI wglGetCurrentContext (void); +HDC WINAPI wglGetCurrentDC (void); +int WINAPI wglGetLayerPaletteEntries (HDC hdc, int iLayerPlane, int iStart, int cEntries, const COLORREF *pcr); +PROC WINAPI wglGetProcAddress (LPCSTR lpszProc); +BOOL WINAPI wglMakeCurrent (HDC hDc, HGLRC newContext); +BOOL WINAPI wglRealizeLayerPalette (HDC hdc, int iLayerPlane, BOOL bRealize); +int WINAPI wglSetLayerPaletteEntries (HDC hdc, int iLayerPlane, int iStart, int cEntries, const COLORREF *pcr); +BOOL WINAPI wglShareLists (HGLRC hrcSrvShare, HGLRC hrcSrvSource); +BOOL WINAPI wglSwapLayerBuffers (HDC hdc, UINT fuFlags); +BOOL WINAPI wglUseFontBitmaps (HDC hDC, DWORD first, DWORD count, DWORD listBase); +BOOL WINAPI wglUseFontBitmapsA (HDC hDC, DWORD first, DWORD count, DWORD listBase); +BOOL WINAPI wglUseFontBitmapsW (HDC hDC, DWORD first, DWORD count, DWORD listBase); +BOOL WINAPI wglUseFontOutlines (HDC hDC, DWORD first, DWORD count, DWORD listBase, FLOAT deviation, FLOAT extrusion, int format, LPGLYPHMETRICSFLOAT lpgmf); +BOOL WINAPI wglUseFontOutlinesA (HDC hDC, DWORD first, DWORD count, DWORD listBase, FLOAT deviation, FLOAT extrusion, int format, LPGLYPHMETRICSFLOAT lpgmf); +BOOL WINAPI wglUseFontOutlinesW (HDC hDC, DWORD first, DWORD count, DWORD listBase, FLOAT deviation, FLOAT extrusion, int format, LPGLYPHMETRICSFLOAT lpgmf); +#endif +#endif /* WGL_VERSION_1_0 */ + +#ifndef WGL_ARB_buffer_region +#define WGL_ARB_buffer_region 1 +#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 +#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002 +#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004 +#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008 +typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType); +typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion); +typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height); +typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); +#ifdef WGL_WGLEXT_PROTOTYPES +HANDLE WINAPI wglCreateBufferRegionARB (HDC hDC, int iLayerPlane, UINT uType); +VOID WINAPI wglDeleteBufferRegionARB (HANDLE hRegion); +BOOL WINAPI wglSaveBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height); +BOOL WINAPI wglRestoreBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); +#endif +#endif /* WGL_ARB_buffer_region */ + +#ifndef WGL_ARB_context_flush_control +#define WGL_ARB_context_flush_control 1 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 +#endif /* WGL_ARB_context_flush_control */ + +#ifndef WGL_ARB_create_context +#define WGL_ARB_create_context 1 +#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001 +#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 +#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 +#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 +#define WGL_CONTEXT_FLAGS_ARB 0x2094 +#define ERROR_INVALID_VERSION_ARB 0x2095 +typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList); +#ifdef WGL_WGLEXT_PROTOTYPES +HGLRC WINAPI wglCreateContextAttribsARB (HDC hDC, HGLRC hShareContext, const int *attribList); +#endif +#endif /* WGL_ARB_create_context */ + +#ifndef WGL_ARB_create_context_no_error +#define WGL_ARB_create_context_no_error 1 +#define WGL_CONTEXT_OPENGL_NO_ERROR_ARB 0x31B3 +#endif /* WGL_ARB_create_context_no_error */ + +#ifndef WGL_ARB_create_context_profile +#define WGL_ARB_create_context_profile 1 +#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 +#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 +#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 +#define ERROR_INVALID_PROFILE_ARB 0x2096 +#endif /* WGL_ARB_create_context_profile */ + +#ifndef WGL_ARB_create_context_robustness +#define WGL_ARB_create_context_robustness 1 +#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 +#endif /* WGL_ARB_create_context_robustness */ + +#ifndef WGL_ARB_extensions_string +#define WGL_ARB_extensions_string 1 +typedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); +#ifdef WGL_WGLEXT_PROTOTYPES +const char *WINAPI wglGetExtensionsStringARB (HDC hdc); +#endif +#endif /* WGL_ARB_extensions_string */ + +#ifndef WGL_ARB_framebuffer_sRGB +#define WGL_ARB_framebuffer_sRGB 1 +#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 +#endif /* WGL_ARB_framebuffer_sRGB */ + +#ifndef WGL_ARB_make_current_read +#define WGL_ARB_make_current_read 1 +#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 +#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 +typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); +typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglMakeContextCurrentARB (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); +HDC WINAPI wglGetCurrentReadDCARB (void); +#endif +#endif /* WGL_ARB_make_current_read */ + +#ifndef WGL_ARB_multisample +#define WGL_ARB_multisample 1 +#define WGL_SAMPLE_BUFFERS_ARB 0x2041 +#define WGL_SAMPLES_ARB 0x2042 +#endif /* WGL_ARB_multisample */ + +#ifndef WGL_ARB_pbuffer +#define WGL_ARB_pbuffer 1 +DECLARE_HANDLE(HPBUFFERARB); +#define WGL_DRAW_TO_PBUFFER_ARB 0x202D +#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E +#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F +#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 +#define WGL_PBUFFER_LARGEST_ARB 0x2033 +#define WGL_PBUFFER_WIDTH_ARB 0x2034 +#define WGL_PBUFFER_HEIGHT_ARB 0x2035 +#define WGL_PBUFFER_LOST_ARB 0x2036 +typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); +typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); +typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); +typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); +typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); +#ifdef WGL_WGLEXT_PROTOTYPES +HPBUFFERARB WINAPI wglCreatePbufferARB (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); +HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB hPbuffer); +int WINAPI wglReleasePbufferDCARB (HPBUFFERARB hPbuffer, HDC hDC); +BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB hPbuffer); +BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); +#endif +#endif /* WGL_ARB_pbuffer */ + +#ifndef WGL_ARB_pixel_format +#define WGL_ARB_pixel_format 1 +#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 +#define WGL_DRAW_TO_WINDOW_ARB 0x2001 +#define WGL_DRAW_TO_BITMAP_ARB 0x2002 +#define WGL_ACCELERATION_ARB 0x2003 +#define WGL_NEED_PALETTE_ARB 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 +#define WGL_SWAP_METHOD_ARB 0x2007 +#define WGL_NUMBER_OVERLAYS_ARB 0x2008 +#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 +#define WGL_TRANSPARENT_ARB 0x200A +#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 +#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 +#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 +#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A +#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B +#define WGL_SHARE_DEPTH_ARB 0x200C +#define WGL_SHARE_STENCIL_ARB 0x200D +#define WGL_SHARE_ACCUM_ARB 0x200E +#define WGL_SUPPORT_GDI_ARB 0x200F +#define WGL_SUPPORT_OPENGL_ARB 0x2010 +#define WGL_DOUBLE_BUFFER_ARB 0x2011 +#define WGL_STEREO_ARB 0x2012 +#define WGL_PIXEL_TYPE_ARB 0x2013 +#define WGL_COLOR_BITS_ARB 0x2014 +#define WGL_RED_BITS_ARB 0x2015 +#define WGL_RED_SHIFT_ARB 0x2016 +#define WGL_GREEN_BITS_ARB 0x2017 +#define WGL_GREEN_SHIFT_ARB 0x2018 +#define WGL_BLUE_BITS_ARB 0x2019 +#define WGL_BLUE_SHIFT_ARB 0x201A +#define WGL_ALPHA_BITS_ARB 0x201B +#define WGL_ALPHA_SHIFT_ARB 0x201C +#define WGL_ACCUM_BITS_ARB 0x201D +#define WGL_ACCUM_RED_BITS_ARB 0x201E +#define WGL_ACCUM_GREEN_BITS_ARB 0x201F +#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 +#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 +#define WGL_DEPTH_BITS_ARB 0x2022 +#define WGL_STENCIL_BITS_ARB 0x2023 +#define WGL_AUX_BUFFERS_ARB 0x2024 +#define WGL_NO_ACCELERATION_ARB 0x2025 +#define WGL_GENERIC_ACCELERATION_ARB 0x2026 +#define WGL_FULL_ACCELERATION_ARB 0x2027 +#define WGL_SWAP_EXCHANGE_ARB 0x2028 +#define WGL_SWAP_COPY_ARB 0x2029 +#define WGL_SWAP_UNDEFINED_ARB 0x202A +#define WGL_TYPE_RGBA_ARB 0x202B +#define WGL_TYPE_COLORINDEX_ARB 0x202C +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); +typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetPixelFormatAttribivARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); +BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); +BOOL WINAPI wglChoosePixelFormatARB (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#endif +#endif /* WGL_ARB_pixel_format */ + +#ifndef WGL_ARB_pixel_format_float +#define WGL_ARB_pixel_format_float 1 +#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 +#endif /* WGL_ARB_pixel_format_float */ + +#ifndef WGL_ARB_render_texture +#define WGL_ARB_render_texture 1 +#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 +#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 +#define WGL_TEXTURE_FORMAT_ARB 0x2072 +#define WGL_TEXTURE_TARGET_ARB 0x2073 +#define WGL_MIPMAP_TEXTURE_ARB 0x2074 +#define WGL_TEXTURE_RGB_ARB 0x2075 +#define WGL_TEXTURE_RGBA_ARB 0x2076 +#define WGL_NO_TEXTURE_ARB 0x2077 +#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078 +#define WGL_TEXTURE_1D_ARB 0x2079 +#define WGL_TEXTURE_2D_ARB 0x207A +#define WGL_MIPMAP_LEVEL_ARB 0x207B +#define WGL_CUBE_MAP_FACE_ARB 0x207C +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 +#define WGL_FRONT_LEFT_ARB 0x2083 +#define WGL_FRONT_RIGHT_ARB 0x2084 +#define WGL_BACK_LEFT_ARB 0x2085 +#define WGL_BACK_RIGHT_ARB 0x2086 +#define WGL_AUX0_ARB 0x2087 +#define WGL_AUX1_ARB 0x2088 +#define WGL_AUX2_ARB 0x2089 +#define WGL_AUX3_ARB 0x208A +#define WGL_AUX4_ARB 0x208B +#define WGL_AUX5_ARB 0x208C +#define WGL_AUX6_ARB 0x208D +#define WGL_AUX7_ARB 0x208E +#define WGL_AUX8_ARB 0x208F +#define WGL_AUX9_ARB 0x2090 +typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); +typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); +typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglBindTexImageARB (HPBUFFERARB hPbuffer, int iBuffer); +BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB hPbuffer, int iBuffer); +BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB hPbuffer, const int *piAttribList); +#endif +#endif /* WGL_ARB_render_texture */ + +#ifndef WGL_ARB_robustness_application_isolation +#define WGL_ARB_robustness_application_isolation 1 +#define WGL_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008 +#endif /* WGL_ARB_robustness_application_isolation */ + +#ifndef WGL_ARB_robustness_share_group_isolation +#define WGL_ARB_robustness_share_group_isolation 1 +#endif /* WGL_ARB_robustness_share_group_isolation */ + +#ifndef WGL_3DFX_multisample +#define WGL_3DFX_multisample 1 +#define WGL_SAMPLE_BUFFERS_3DFX 0x2060 +#define WGL_SAMPLES_3DFX 0x2061 +#endif /* WGL_3DFX_multisample */ + +#ifndef WGL_3DL_stereo_control +#define WGL_3DL_stereo_control 1 +#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055 +#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056 +#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057 +#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058 +typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglSetStereoEmitterState3DL (HDC hDC, UINT uState); +#endif +#endif /* WGL_3DL_stereo_control */ + +#ifndef WGL_AMD_gpu_association +#define WGL_AMD_gpu_association 1 +#define WGL_GPU_VENDOR_AMD 0x1F00 +#define WGL_GPU_RENDERER_STRING_AMD 0x1F01 +#define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02 +#define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2 +#define WGL_GPU_RAM_AMD 0x21A3 +#define WGL_GPU_CLOCK_AMD 0x21A4 +#define WGL_GPU_NUM_PIPES_AMD 0x21A5 +#define WGL_GPU_NUM_SIMD_AMD 0x21A6 +#define WGL_GPU_NUM_RB_AMD 0x21A7 +#define WGL_GPU_NUM_SPI_AMD 0x21A8 +typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT *ids); +typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, INT property, GLenum dataType, UINT size, void *data); +typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc); +typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id); +typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int *attribList); +typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc); +typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc); +typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void); +typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#ifdef WGL_WGLEXT_PROTOTYPES +UINT WINAPI wglGetGPUIDsAMD (UINT maxCount, UINT *ids); +INT WINAPI wglGetGPUInfoAMD (UINT id, INT property, GLenum dataType, UINT size, void *data); +UINT WINAPI wglGetContextGPUIDAMD (HGLRC hglrc); +HGLRC WINAPI wglCreateAssociatedContextAMD (UINT id); +HGLRC WINAPI wglCreateAssociatedContextAttribsAMD (UINT id, HGLRC hShareContext, const int *attribList); +BOOL WINAPI wglDeleteAssociatedContextAMD (HGLRC hglrc); +BOOL WINAPI wglMakeAssociatedContextCurrentAMD (HGLRC hglrc); +HGLRC WINAPI wglGetCurrentAssociatedContextAMD (void); +VOID WINAPI wglBlitContextFramebufferAMD (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +#endif /* WGL_AMD_gpu_association */ + +#ifndef WGL_ATI_pixel_format_float +#define WGL_ATI_pixel_format_float 1 +#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 +#endif /* WGL_ATI_pixel_format_float */ + +#ifndef WGL_ATI_render_texture_rectangle +#define WGL_ATI_render_texture_rectangle 1 +#define WGL_TEXTURE_RECTANGLE_ATI 0x21A5 +#endif /* WGL_ATI_render_texture_rectangle */ + +#ifndef WGL_EXT_colorspace +#define WGL_EXT_colorspace 1 +#define WGL_COLORSPACE_EXT 0x309D +#define WGL_COLORSPACE_SRGB_EXT 0x3089 +#define WGL_COLORSPACE_LINEAR_EXT 0x308A +#endif /* WGL_EXT_colorspace */ + +#ifndef WGL_EXT_create_context_es2_profile +#define WGL_EXT_create_context_es2_profile 1 +#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 +#endif /* WGL_EXT_create_context_es2_profile */ + +#ifndef WGL_EXT_create_context_es_profile +#define WGL_EXT_create_context_es_profile 1 +#define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004 +#endif /* WGL_EXT_create_context_es_profile */ + +#ifndef WGL_EXT_depth_float +#define WGL_EXT_depth_float 1 +#define WGL_DEPTH_FLOAT_EXT 0x2040 +#endif /* WGL_EXT_depth_float */ + +#ifndef WGL_EXT_display_color_table +#define WGL_EXT_display_color_table 1 +typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id); +typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length); +typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id); +typedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id); +#ifdef WGL_WGLEXT_PROTOTYPES +GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort id); +GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *table, GLuint length); +GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort id); +VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort id); +#endif +#endif /* WGL_EXT_display_color_table */ + +#ifndef WGL_EXT_extensions_string +#define WGL_EXT_extensions_string 1 +typedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void); +#ifdef WGL_WGLEXT_PROTOTYPES +const char *WINAPI wglGetExtensionsStringEXT (void); +#endif +#endif /* WGL_EXT_extensions_string */ + +#ifndef WGL_EXT_framebuffer_sRGB +#define WGL_EXT_framebuffer_sRGB 1 +#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9 +#endif /* WGL_EXT_framebuffer_sRGB */ + +#ifndef WGL_EXT_make_current_read +#define WGL_EXT_make_current_read 1 +#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043 +typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); +typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglMakeContextCurrentEXT (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); +HDC WINAPI wglGetCurrentReadDCEXT (void); +#endif +#endif /* WGL_EXT_make_current_read */ + +#ifndef WGL_EXT_multisample +#define WGL_EXT_multisample 1 +#define WGL_SAMPLE_BUFFERS_EXT 0x2041 +#define WGL_SAMPLES_EXT 0x2042 +#endif /* WGL_EXT_multisample */ + +#ifndef WGL_EXT_pbuffer +#define WGL_EXT_pbuffer 1 +DECLARE_HANDLE(HPBUFFEREXT); +#define WGL_DRAW_TO_PBUFFER_EXT 0x202D +#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E +#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F +#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030 +#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031 +#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032 +#define WGL_PBUFFER_LARGEST_EXT 0x2033 +#define WGL_PBUFFER_WIDTH_EXT 0x2034 +#define WGL_PBUFFER_HEIGHT_EXT 0x2035 +typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); +typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer); +typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC); +typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer); +typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); +#ifdef WGL_WGLEXT_PROTOTYPES +HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); +HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT hPbuffer); +int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT hPbuffer, HDC hDC); +BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT hPbuffer); +BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); +#endif +#endif /* WGL_EXT_pbuffer */ + +#ifndef WGL_EXT_pixel_format +#define WGL_EXT_pixel_format 1 +#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000 +#define WGL_DRAW_TO_WINDOW_EXT 0x2001 +#define WGL_DRAW_TO_BITMAP_EXT 0x2002 +#define WGL_ACCELERATION_EXT 0x2003 +#define WGL_NEED_PALETTE_EXT 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006 +#define WGL_SWAP_METHOD_EXT 0x2007 +#define WGL_NUMBER_OVERLAYS_EXT 0x2008 +#define WGL_NUMBER_UNDERLAYS_EXT 0x2009 +#define WGL_TRANSPARENT_EXT 0x200A +#define WGL_TRANSPARENT_VALUE_EXT 0x200B +#define WGL_SHARE_DEPTH_EXT 0x200C +#define WGL_SHARE_STENCIL_EXT 0x200D +#define WGL_SHARE_ACCUM_EXT 0x200E +#define WGL_SUPPORT_GDI_EXT 0x200F +#define WGL_SUPPORT_OPENGL_EXT 0x2010 +#define WGL_DOUBLE_BUFFER_EXT 0x2011 +#define WGL_STEREO_EXT 0x2012 +#define WGL_PIXEL_TYPE_EXT 0x2013 +#define WGL_COLOR_BITS_EXT 0x2014 +#define WGL_RED_BITS_EXT 0x2015 +#define WGL_RED_SHIFT_EXT 0x2016 +#define WGL_GREEN_BITS_EXT 0x2017 +#define WGL_GREEN_SHIFT_EXT 0x2018 +#define WGL_BLUE_BITS_EXT 0x2019 +#define WGL_BLUE_SHIFT_EXT 0x201A +#define WGL_ALPHA_BITS_EXT 0x201B +#define WGL_ALPHA_SHIFT_EXT 0x201C +#define WGL_ACCUM_BITS_EXT 0x201D +#define WGL_ACCUM_RED_BITS_EXT 0x201E +#define WGL_ACCUM_GREEN_BITS_EXT 0x201F +#define WGL_ACCUM_BLUE_BITS_EXT 0x2020 +#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021 +#define WGL_DEPTH_BITS_EXT 0x2022 +#define WGL_STENCIL_BITS_EXT 0x2023 +#define WGL_AUX_BUFFERS_EXT 0x2024 +#define WGL_NO_ACCELERATION_EXT 0x2025 +#define WGL_GENERIC_ACCELERATION_EXT 0x2026 +#define WGL_FULL_ACCELERATION_EXT 0x2027 +#define WGL_SWAP_EXCHANGE_EXT 0x2028 +#define WGL_SWAP_COPY_EXT 0x2029 +#define WGL_SWAP_UNDEFINED_EXT 0x202A +#define WGL_TYPE_RGBA_EXT 0x202B +#define WGL_TYPE_COLORINDEX_EXT 0x202C +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); +typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); +BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); +BOOL WINAPI wglChoosePixelFormatEXT (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#endif +#endif /* WGL_EXT_pixel_format */ + +#ifndef WGL_EXT_pixel_format_packed_float +#define WGL_EXT_pixel_format_packed_float 1 +#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8 +#endif /* WGL_EXT_pixel_format_packed_float */ + +#ifndef WGL_EXT_swap_control +#define WGL_EXT_swap_control 1 +typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); +typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglSwapIntervalEXT (int interval); +int WINAPI wglGetSwapIntervalEXT (void); +#endif +#endif /* WGL_EXT_swap_control */ + +#ifndef WGL_EXT_swap_control_tear +#define WGL_EXT_swap_control_tear 1 +#endif /* WGL_EXT_swap_control_tear */ + +#ifndef WGL_I3D_digital_video_control +#define WGL_I3D_digital_video_control 1 +#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050 +#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051 +#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052 +#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053 +typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); +typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC hDC, int iAttribute, int *piValue); +BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC hDC, int iAttribute, const int *piValue); +#endif +#endif /* WGL_I3D_digital_video_control */ + +#ifndef WGL_I3D_gamma +#define WGL_I3D_gamma 1 +#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E +#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F +typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); +typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); +typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); +typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetGammaTableParametersI3D (HDC hDC, int iAttribute, int *piValue); +BOOL WINAPI wglSetGammaTableParametersI3D (HDC hDC, int iAttribute, const int *piValue); +BOOL WINAPI wglGetGammaTableI3D (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); +BOOL WINAPI wglSetGammaTableI3D (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); +#endif +#endif /* WGL_I3D_gamma */ + +#ifndef WGL_I3D_genlock +#define WGL_I3D_genlock 1 +#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044 +#define WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D 0x2045 +#define WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D 0x2046 +#define WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D 0x2047 +#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048 +#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049 +#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A +#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B +#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C +typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC); +typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC); +typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag); +typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT *uSource); +typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT *uEdge); +typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate); +typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay); +typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglEnableGenlockI3D (HDC hDC); +BOOL WINAPI wglDisableGenlockI3D (HDC hDC); +BOOL WINAPI wglIsEnabledGenlockI3D (HDC hDC, BOOL *pFlag); +BOOL WINAPI wglGenlockSourceI3D (HDC hDC, UINT uSource); +BOOL WINAPI wglGetGenlockSourceI3D (HDC hDC, UINT *uSource); +BOOL WINAPI wglGenlockSourceEdgeI3D (HDC hDC, UINT uEdge); +BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC hDC, UINT *uEdge); +BOOL WINAPI wglGenlockSampleRateI3D (HDC hDC, UINT uRate); +BOOL WINAPI wglGetGenlockSampleRateI3D (HDC hDC, UINT *uRate); +BOOL WINAPI wglGenlockSourceDelayI3D (HDC hDC, UINT uDelay); +BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC hDC, UINT *uDelay); +BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); +#endif +#endif /* WGL_I3D_genlock */ + +#ifndef WGL_I3D_image_buffer +#define WGL_I3D_image_buffer 1 +#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001 +#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002 +typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags); +typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress); +typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); +typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count); +#ifdef WGL_WGLEXT_PROTOTYPES +LPVOID WINAPI wglCreateImageBufferI3D (HDC hDC, DWORD dwSize, UINT uFlags); +BOOL WINAPI wglDestroyImageBufferI3D (HDC hDC, LPVOID pAddress); +BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); +BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC hDC, const LPVOID *pAddress, UINT count); +#endif +#endif /* WGL_I3D_image_buffer */ + +#ifndef WGL_I3D_swap_frame_lock +#define WGL_I3D_swap_frame_lock 1 +typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag); +typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglEnableFrameLockI3D (void); +BOOL WINAPI wglDisableFrameLockI3D (void); +BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *pFlag); +BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *pFlag); +#endif +#endif /* WGL_I3D_swap_frame_lock */ + +#ifndef WGL_I3D_swap_frame_usage +#define WGL_I3D_swap_frame_usage 1 +typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage); +typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetFrameUsageI3D (float *pUsage); +BOOL WINAPI wglBeginFrameTrackingI3D (void); +BOOL WINAPI wglEndFrameTrackingI3D (void); +BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); +#endif +#endif /* WGL_I3D_swap_frame_usage */ + +#ifndef WGL_NV_DX_interop +#define WGL_NV_DX_interop 1 +#define WGL_ACCESS_READ_ONLY_NV 0x00000000 +#define WGL_ACCESS_READ_WRITE_NV 0x00000001 +#define WGL_ACCESS_WRITE_DISCARD_NV 0x00000002 +typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void *dxObject, HANDLE shareHandle); +typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void *dxDevice); +typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice); +typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access); +typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject); +typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access); +typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects); +typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglDXSetResourceShareHandleNV (void *dxObject, HANDLE shareHandle); +HANDLE WINAPI wglDXOpenDeviceNV (void *dxDevice); +BOOL WINAPI wglDXCloseDeviceNV (HANDLE hDevice); +HANDLE WINAPI wglDXRegisterObjectNV (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access); +BOOL WINAPI wglDXUnregisterObjectNV (HANDLE hDevice, HANDLE hObject); +BOOL WINAPI wglDXObjectAccessNV (HANDLE hObject, GLenum access); +BOOL WINAPI wglDXLockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects); +BOOL WINAPI wglDXUnlockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects); +#endif +#endif /* WGL_NV_DX_interop */ + +#ifndef WGL_NV_DX_interop2 +#define WGL_NV_DX_interop2 1 +#endif /* WGL_NV_DX_interop2 */ + +#ifndef WGL_NV_copy_image +#define WGL_NV_copy_image 1 +typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglCopyImageSubDataNV (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif +#endif /* WGL_NV_copy_image */ + +#ifndef WGL_NV_delay_before_swap +#define WGL_NV_delay_before_swap 1 +typedef BOOL (WINAPI * PFNWGLDELAYBEFORESWAPNVPROC) (HDC hDC, GLfloat seconds); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglDelayBeforeSwapNV (HDC hDC, GLfloat seconds); +#endif +#endif /* WGL_NV_delay_before_swap */ + +#ifndef WGL_NV_float_buffer +#define WGL_NV_float_buffer 1 +#define WGL_FLOAT_COMPONENTS_NV 0x20B0 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4 +#define WGL_TEXTURE_FLOAT_R_NV 0x20B5 +#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6 +#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7 +#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8 +#endif /* WGL_NV_float_buffer */ + +#ifndef WGL_NV_gpu_affinity +#define WGL_NV_gpu_affinity 1 +DECLARE_HANDLE(HGPUNV); +struct _GPU_DEVICE { + DWORD cb; + CHAR DeviceName[32]; + CHAR DeviceString[128]; + DWORD Flags; + RECT rcVirtualScreen; +}; +typedef struct _GPU_DEVICE *PGPU_DEVICE; +#define ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0 +#define ERROR_MISSING_AFFINITY_MASK_NV 0x20D1 +typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu); +typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); +typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList); +typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); +typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglEnumGpusNV (UINT iGpuIndex, HGPUNV *phGpu); +BOOL WINAPI wglEnumGpuDevicesNV (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); +HDC WINAPI wglCreateAffinityDCNV (const HGPUNV *phGpuList); +BOOL WINAPI wglEnumGpusFromAffinityDCNV (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); +BOOL WINAPI wglDeleteDCNV (HDC hdc); +#endif +#endif /* WGL_NV_gpu_affinity */ + +#ifndef WGL_NV_multigpu_context +#define WGL_NV_multigpu_context 1 +#define WGL_CONTEXT_MULTIGPU_ATTRIB_NV 0x20AA +#define WGL_CONTEXT_MULTIGPU_ATTRIB_SINGLE_NV 0x20AB +#define WGL_CONTEXT_MULTIGPU_ATTRIB_AFR_NV 0x20AC +#define WGL_CONTEXT_MULTIGPU_ATTRIB_MULTICAST_NV 0x20AD +#define WGL_CONTEXT_MULTIGPU_ATTRIB_MULTI_DISPLAY_MULTICAST_NV 0x20AE +#endif /* WGL_NV_multigpu_context */ + +#ifndef WGL_NV_multisample_coverage +#define WGL_NV_multisample_coverage 1 +#define WGL_COVERAGE_SAMPLES_NV 0x2042 +#define WGL_COLOR_SAMPLES_NV 0x20B9 +#endif /* WGL_NV_multisample_coverage */ + +#ifndef WGL_NV_present_video +#define WGL_NV_present_video 1 +DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV); +#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0 +typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDc, HVIDEOOUTPUTDEVICENV *phDeviceList); +typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDc, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); +typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue); +#ifdef WGL_WGLEXT_PROTOTYPES +int WINAPI wglEnumerateVideoDevicesNV (HDC hDc, HVIDEOOUTPUTDEVICENV *phDeviceList); +BOOL WINAPI wglBindVideoDeviceNV (HDC hDc, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); +BOOL WINAPI wglQueryCurrentContextNV (int iAttribute, int *piValue); +#endif +#endif /* WGL_NV_present_video */ + +#ifndef WGL_NV_render_depth_texture +#define WGL_NV_render_depth_texture 1 +#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4 +#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5 +#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6 +#define WGL_DEPTH_COMPONENT_NV 0x20A7 +#endif /* WGL_NV_render_depth_texture */ + +#ifndef WGL_NV_render_texture_rectangle +#define WGL_NV_render_texture_rectangle 1 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 +#define WGL_TEXTURE_RECTANGLE_NV 0x20A2 +#endif /* WGL_NV_render_texture_rectangle */ + +#ifndef WGL_NV_swap_group +#define WGL_NV_swap_group 1 +typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group); +typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier); +typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint *group, GLuint *barrier); +typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); +typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint *count); +typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglJoinSwapGroupNV (HDC hDC, GLuint group); +BOOL WINAPI wglBindSwapBarrierNV (GLuint group, GLuint barrier); +BOOL WINAPI wglQuerySwapGroupNV (HDC hDC, GLuint *group, GLuint *barrier); +BOOL WINAPI wglQueryMaxSwapGroupsNV (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); +BOOL WINAPI wglQueryFrameCountNV (HDC hDC, GLuint *count); +BOOL WINAPI wglResetFrameCountNV (HDC hDC); +#endif +#endif /* WGL_NV_swap_group */ + +#ifndef WGL_NV_vertex_array_range +#define WGL_NV_vertex_array_range 1 +typedef void *(WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); +typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer); +#ifdef WGL_WGLEXT_PROTOTYPES +void *WINAPI wglAllocateMemoryNV (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); +void WINAPI wglFreeMemoryNV (void *pointer); +#endif +#endif /* WGL_NV_vertex_array_range */ + +#ifndef WGL_NV_video_capture +#define WGL_NV_video_capture 1 +DECLARE_HANDLE(HVIDEOINPUTDEVICENV); +#define WGL_UNIQUE_ID_NV 0x20CE +#define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF +typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); +typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); +typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglBindVideoCaptureDeviceNV (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); +UINT WINAPI wglEnumerateVideoCaptureDevicesNV (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); +BOOL WINAPI wglLockVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +BOOL WINAPI wglQueryVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); +BOOL WINAPI wglReleaseVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +#endif +#endif /* WGL_NV_video_capture */ + +#ifndef WGL_NV_video_output +#define WGL_NV_video_output 1 +DECLARE_HANDLE(HPVIDEODEV); +#define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0 +#define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1 +#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2 +#define WGL_VIDEO_OUT_COLOR_NV 0x20C3 +#define WGL_VIDEO_OUT_ALPHA_NV 0x20C4 +#define WGL_VIDEO_OUT_DEPTH_NV 0x20C5 +#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 +#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 +#define WGL_VIDEO_OUT_FRAME 0x20C8 +#define WGL_VIDEO_OUT_FIELD_1 0x20C9 +#define WGL_VIDEO_OUT_FIELD_2 0x20CA +#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB +#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC +typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice); +typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer); +typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); +typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetVideoDeviceNV (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); +BOOL WINAPI wglReleaseVideoDeviceNV (HPVIDEODEV hVideoDevice); +BOOL WINAPI wglBindVideoImageNV (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); +BOOL WINAPI wglReleaseVideoImageNV (HPBUFFERARB hPbuffer, int iVideoBuffer); +BOOL WINAPI wglSendPbufferToVideoNV (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); +BOOL WINAPI wglGetVideoInfoNV (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); +#endif +#endif /* WGL_NV_video_output */ + +#ifndef WGL_OML_sync_control +#define WGL_OML_sync_control 1 +typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); +typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator); +typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); +typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, INT fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); +typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); +typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetSyncValuesOML (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); +BOOL WINAPI wglGetMscRateOML (HDC hdc, INT32 *numerator, INT32 *denominator); +INT64 WINAPI wglSwapBuffersMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); +INT64 WINAPI wglSwapLayerBuffersMscOML (HDC hdc, INT fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); +BOOL WINAPI wglWaitForMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); +BOOL WINAPI wglWaitForSbcOML (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); +#endif +#endif /* WGL_OML_sync_control */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/include/GL/wglext.h b/thirdparty/include/GL/wglext.h index e9648c37c..ac4b86b98 100644 --- a/thirdparty/include/GL/wglext.h +++ b/thirdparty/include/GL/wglext.h @@ -1,12 +1,12 @@ -#ifndef __wglext_h_ -#define __wglext_h_ 1 +#ifndef __wgl_wglext_h_ +#define __wgl_wglext_h_ 1 #ifdef __cplusplus extern "C" { #endif /* -** Copyright (c) 2013-2014 The Khronos Group Inc. +** Copyright (c) 2013-2018 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the @@ -31,9 +31,7 @@ extern "C" { ** This header is generated from the Khronos OpenGL / OpenGL ES XML ** API Registry. The current version of the Registry, generator scripts ** used to make the header, and the header can be found at -** http://www.opengl.org/registry/ -** -** Khronos $Revision: 26290 $ on $Date: 2014-04-16 05:35:38 -0700 (Wed, 16 Apr 2014) $ +** https://github.com/KhronosGroup/OpenGL-Registry */ #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) @@ -41,7 +39,7 @@ extern "C" { #include #endif -#define WGL_WGLEXT_VERSION 20140416 +#define WGL_WGLEXT_VERSION 20200408 /* Generated C header for: * API: wgl @@ -70,6 +68,13 @@ BOOL WINAPI wglRestoreBufferRegionARB (HANDLE hRegion, int x, int y, int width, #endif #endif /* WGL_ARB_buffer_region */ +#ifndef WGL_ARB_context_flush_control +#define WGL_ARB_context_flush_control 1 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 +#endif /* WGL_ARB_context_flush_control */ + #ifndef WGL_ARB_create_context #define WGL_ARB_create_context 1 #define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001 @@ -85,6 +90,11 @@ HGLRC WINAPI wglCreateContextAttribsARB (HDC hDC, HGLRC hShareContext, const int #endif #endif /* WGL_ARB_create_context */ +#ifndef WGL_ARB_create_context_no_error +#define WGL_ARB_create_context_no_error 1 +#define WGL_CONTEXT_OPENGL_NO_ERROR_ARB 0x31B3 +#endif /* WGL_ARB_create_context_no_error */ + #ifndef WGL_ARB_create_context_profile #define WGL_ARB_create_context_profile 1 #define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 @@ -308,7 +318,7 @@ BOOL WINAPI wglSetStereoEmitterState3DL (HDC hDC, UINT uState); #define WGL_GPU_NUM_RB_AMD 0x21A7 #define WGL_GPU_NUM_SPI_AMD 0x21A8 typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT *ids); -typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, int property, GLenum dataType, UINT size, void *data); +typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, INT property, GLenum dataType, UINT size, void *data); typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc); typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id); typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int *attribList); @@ -318,7 +328,7 @@ typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void); typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); #ifdef WGL_WGLEXT_PROTOTYPES UINT WINAPI wglGetGPUIDsAMD (UINT maxCount, UINT *ids); -INT WINAPI wglGetGPUInfoAMD (UINT id, int property, GLenum dataType, UINT size, void *data); +INT WINAPI wglGetGPUInfoAMD (UINT id, INT property, GLenum dataType, UINT size, void *data); UINT WINAPI wglGetContextGPUIDAMD (HGLRC hglrc); HGLRC WINAPI wglCreateAssociatedContextAMD (UINT id); HGLRC WINAPI wglCreateAssociatedContextAttribsAMD (UINT id, HGLRC hShareContext, const int *attribList); @@ -334,6 +344,18 @@ VOID WINAPI wglBlitContextFramebufferAMD (HGLRC dstCtx, GLint srcX0, GLint srcY0 #define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 #endif /* WGL_ATI_pixel_format_float */ +#ifndef WGL_ATI_render_texture_rectangle +#define WGL_ATI_render_texture_rectangle 1 +#define WGL_TEXTURE_RECTANGLE_ATI 0x21A5 +#endif /* WGL_ATI_render_texture_rectangle */ + +#ifndef WGL_EXT_colorspace +#define WGL_EXT_colorspace 1 +#define WGL_COLORSPACE_EXT 0x309D +#define WGL_COLORSPACE_SRGB_EXT 0x3089 +#define WGL_COLORSPACE_LINEAR_EXT 0x308A +#endif /* WGL_EXT_colorspace */ + #ifndef WGL_EXT_create_context_es2_profile #define WGL_EXT_create_context_es2_profile 1 #define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 @@ -693,6 +715,15 @@ BOOL WINAPI wglDeleteDCNV (HDC hdc); #endif #endif /* WGL_NV_gpu_affinity */ +#ifndef WGL_NV_multigpu_context +#define WGL_NV_multigpu_context 1 +#define WGL_CONTEXT_MULTIGPU_ATTRIB_NV 0x20AA +#define WGL_CONTEXT_MULTIGPU_ATTRIB_SINGLE_NV 0x20AB +#define WGL_CONTEXT_MULTIGPU_ATTRIB_AFR_NV 0x20AC +#define WGL_CONTEXT_MULTIGPU_ATTRIB_MULTICAST_NV 0x20AD +#define WGL_CONTEXT_MULTIGPU_ATTRIB_MULTI_DISPLAY_MULTICAST_NV 0x20AE +#endif /* WGL_NV_multigpu_context */ + #ifndef WGL_NV_multisample_coverage #define WGL_NV_multisample_coverage 1 #define WGL_COVERAGE_SAMPLES_NV 0x2042 @@ -703,12 +734,12 @@ BOOL WINAPI wglDeleteDCNV (HDC hdc); #define WGL_NV_present_video 1 DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV); #define WGL_NUM_VIDEO_SLOTS_NV 0x20F0 -typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList); -typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); +typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDc, HVIDEOOUTPUTDEVICENV *phDeviceList); +typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDc, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue); #ifdef WGL_WGLEXT_PROTOTYPES -int WINAPI wglEnumerateVideoDevicesNV (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList); -BOOL WINAPI wglBindVideoDeviceNV (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); +int WINAPI wglEnumerateVideoDevicesNV (HDC hDc, HVIDEOOUTPUTDEVICENV *phDeviceList); +BOOL WINAPI wglBindVideoDeviceNV (HDC hDc, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); BOOL WINAPI wglQueryCurrentContextNV (int iAttribute, int *piValue); #endif #endif /* WGL_NV_present_video */ @@ -813,14 +844,14 @@ BOOL WINAPI wglGetVideoInfoNV (HPVIDEODEV hpVideoDevice, unsigned long *pulCount typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator); typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); -typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); +typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, INT fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); #ifdef WGL_WGLEXT_PROTOTYPES BOOL WINAPI wglGetSyncValuesOML (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); BOOL WINAPI wglGetMscRateOML (HDC hdc, INT32 *numerator, INT32 *denominator); INT64 WINAPI wglSwapBuffersMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); -INT64 WINAPI wglSwapLayerBuffersMscOML (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); +INT64 WINAPI wglSwapLayerBuffersMscOML (HDC hdc, INT fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); BOOL WINAPI wglWaitForMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); BOOL WINAPI wglWaitForSbcOML (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); #endif diff --git a/thirdparty/include/GLES2/gl2ext.h b/thirdparty/include/GLES2/gl2ext.h new file mode 100644 index 000000000..e3394d2e8 --- /dev/null +++ b/thirdparty/include/GLES2/gl2ext.h @@ -0,0 +1,3911 @@ +#ifndef __gles2_gl2ext_h_ +#define __gles2_gl2ext_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2013-2018 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are 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 Materials. +** +** THE MATERIALS ARE 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 +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ +/* +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** https://github.com/KhronosGroup/OpenGL-Registry +*/ + +#ifndef GL_APIENTRYP +#define GL_APIENTRYP GL_APIENTRY* +#endif + +/* Generated on date 20200408 */ + +/* Generated C header for: + * API: gles2 + * Profile: common + * Versions considered: 2\.[0-9] + * Versions emitted: _nomatch_^ + * Default extensions included: gles2 + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef GL_KHR_blend_equation_advanced +#define GL_KHR_blend_equation_advanced 1 +#define GL_MULTIPLY_KHR 0x9294 +#define GL_SCREEN_KHR 0x9295 +#define GL_OVERLAY_KHR 0x9296 +#define GL_DARKEN_KHR 0x9297 +#define GL_LIGHTEN_KHR 0x9298 +#define GL_COLORDODGE_KHR 0x9299 +#define GL_COLORBURN_KHR 0x929A +#define GL_HARDLIGHT_KHR 0x929B +#define GL_SOFTLIGHT_KHR 0x929C +#define GL_DIFFERENCE_KHR 0x929E +#define GL_EXCLUSION_KHR 0x92A0 +#define GL_HSL_HUE_KHR 0x92AD +#define GL_HSL_SATURATION_KHR 0x92AE +#define GL_HSL_COLOR_KHR 0x92AF +#define GL_HSL_LUMINOSITY_KHR 0x92B0 +typedef void (GL_APIENTRYP PFNGLBLENDBARRIERKHRPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBlendBarrierKHR (void); +#endif +#endif /* GL_KHR_blend_equation_advanced */ + +#ifndef GL_KHR_blend_equation_advanced_coherent +#define GL_KHR_blend_equation_advanced_coherent 1 +#define GL_BLEND_ADVANCED_COHERENT_KHR 0x9285 +#endif /* GL_KHR_blend_equation_advanced_coherent */ + +#ifndef GL_KHR_context_flush_control +#define GL_KHR_context_flush_control 1 +#define GL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x82FB +#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x82FC +#endif /* GL_KHR_context_flush_control */ + +#ifndef GL_KHR_debug +#define GL_KHR_debug 1 +typedef void (GL_APIENTRY *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +#define GL_SAMPLER 0x82E6 +#define GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_KHR 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION_KHR 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM_KHR 0x8245 +#define GL_DEBUG_SOURCE_API_KHR 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_KHR 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER_KHR 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY_KHR 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION_KHR 0x824A +#define GL_DEBUG_SOURCE_OTHER_KHR 0x824B +#define GL_DEBUG_TYPE_ERROR_KHR 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_KHR 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_KHR 0x824E +#define GL_DEBUG_TYPE_PORTABILITY_KHR 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE_KHR 0x8250 +#define GL_DEBUG_TYPE_OTHER_KHR 0x8251 +#define GL_DEBUG_TYPE_MARKER_KHR 0x8268 +#define GL_DEBUG_TYPE_PUSH_GROUP_KHR 0x8269 +#define GL_DEBUG_TYPE_POP_GROUP_KHR 0x826A +#define GL_DEBUG_SEVERITY_NOTIFICATION_KHR 0x826B +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH_KHR 0x826C +#define GL_DEBUG_GROUP_STACK_DEPTH_KHR 0x826D +#define GL_BUFFER_KHR 0x82E0 +#define GL_SHADER_KHR 0x82E1 +#define GL_PROGRAM_KHR 0x82E2 +#define GL_VERTEX_ARRAY_KHR 0x8074 +#define GL_QUERY_KHR 0x82E3 +#define GL_PROGRAM_PIPELINE_KHR 0x82E4 +#define GL_SAMPLER_KHR 0x82E6 +#define GL_MAX_LABEL_LENGTH_KHR 0x82E8 +#define GL_MAX_DEBUG_MESSAGE_LENGTH_KHR 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_KHR 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_KHR 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_KHR 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_KHR 0x9147 +#define GL_DEBUG_SEVERITY_LOW_KHR 0x9148 +#define GL_DEBUG_OUTPUT_KHR 0x92E0 +#define GL_CONTEXT_FLAG_DEBUG_BIT_KHR 0x00000002 +#define GL_STACK_OVERFLOW_KHR 0x0503 +#define GL_STACK_UNDERFLOW_KHR 0x0504 +typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECONTROLKHRPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGEINSERTKHRPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECALLBACKKHRPROC) (GLDEBUGPROCKHR callback, const void *userParam); +typedef GLuint (GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +typedef void (GL_APIENTRYP PFNGLPUSHDEBUGGROUPKHRPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); +typedef void (GL_APIENTRYP PFNGLPOPDEBUGGROUPKHRPROC) (void); +typedef void (GL_APIENTRYP PFNGLOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (GL_APIENTRYP PFNGLOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei length, const GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETPOINTERVKHRPROC) (GLenum pname, void **params); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDebugMessageControlKHR (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GL_APICALL void GL_APIENTRY glDebugMessageInsertKHR (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GL_APICALL void GL_APIENTRY glDebugMessageCallbackKHR (GLDEBUGPROCKHR callback, const void *userParam); +GL_APICALL GLuint GL_APIENTRY glGetDebugMessageLogKHR (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +GL_APICALL void GL_APIENTRY glPushDebugGroupKHR (GLenum source, GLuint id, GLsizei length, const GLchar *message); +GL_APICALL void GL_APIENTRY glPopDebugGroupKHR (void); +GL_APICALL void GL_APIENTRY glObjectLabelKHR (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +GL_APICALL void GL_APIENTRY glGetObjectLabelKHR (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +GL_APICALL void GL_APIENTRY glObjectPtrLabelKHR (const void *ptr, GLsizei length, const GLchar *label); +GL_APICALL void GL_APIENTRY glGetObjectPtrLabelKHR (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +GL_APICALL void GL_APIENTRY glGetPointervKHR (GLenum pname, void **params); +#endif +#endif /* GL_KHR_debug */ + +#ifndef GL_KHR_no_error +#define GL_KHR_no_error 1 +#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 +#endif /* GL_KHR_no_error */ + +#ifndef GL_KHR_parallel_shader_compile +#define GL_KHR_parallel_shader_compile 1 +#define GL_MAX_SHADER_COMPILER_THREADS_KHR 0x91B0 +#define GL_COMPLETION_STATUS_KHR 0x91B1 +typedef void (GL_APIENTRYP PFNGLMAXSHADERCOMPILERTHREADSKHRPROC) (GLuint count); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glMaxShaderCompilerThreadsKHR (GLuint count); +#endif +#endif /* GL_KHR_parallel_shader_compile */ + +#ifndef GL_KHR_robust_buffer_access_behavior +#define GL_KHR_robust_buffer_access_behavior 1 +#endif /* GL_KHR_robust_buffer_access_behavior */ + +#ifndef GL_KHR_robustness +#define GL_KHR_robustness 1 +#define GL_CONTEXT_ROBUST_ACCESS_KHR 0x90F3 +#define GL_LOSE_CONTEXT_ON_RESET_KHR 0x8252 +#define GL_GUILTY_CONTEXT_RESET_KHR 0x8253 +#define GL_INNOCENT_CONTEXT_RESET_KHR 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET_KHR 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY_KHR 0x8256 +#define GL_NO_RESET_NOTIFICATION_KHR 0x8261 +#define GL_CONTEXT_LOST_KHR 0x0507 +typedef GLenum (GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSKHRPROC) (void); +typedef void (GL_APIENTRYP PFNGLREADNPIXELSKHRPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +typedef void (GL_APIENTRYP PFNGLGETNUNIFORMFVKHRPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETNUNIFORMIVKHRPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETNUNIFORMUIVKHRPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL GLenum GL_APIENTRY glGetGraphicsResetStatusKHR (void); +GL_APICALL void GL_APIENTRY glReadnPixelsKHR (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +GL_APICALL void GL_APIENTRY glGetnUniformfvKHR (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetnUniformivKHR (GLuint program, GLint location, GLsizei bufSize, GLint *params); +GL_APICALL void GL_APIENTRY glGetnUniformuivKHR (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +#endif +#endif /* GL_KHR_robustness */ + +#ifndef GL_KHR_shader_subgroup +#define GL_KHR_shader_subgroup 1 +#define GL_SUBGROUP_SIZE_KHR 0x9532 +#define GL_SUBGROUP_SUPPORTED_STAGES_KHR 0x9533 +#define GL_SUBGROUP_SUPPORTED_FEATURES_KHR 0x9534 +#define GL_SUBGROUP_QUAD_ALL_STAGES_KHR 0x9535 +#define GL_SUBGROUP_FEATURE_BASIC_BIT_KHR 0x00000001 +#define GL_SUBGROUP_FEATURE_VOTE_BIT_KHR 0x00000002 +#define GL_SUBGROUP_FEATURE_ARITHMETIC_BIT_KHR 0x00000004 +#define GL_SUBGROUP_FEATURE_BALLOT_BIT_KHR 0x00000008 +#define GL_SUBGROUP_FEATURE_SHUFFLE_BIT_KHR 0x00000010 +#define GL_SUBGROUP_FEATURE_SHUFFLE_RELATIVE_BIT_KHR 0x00000020 +#define GL_SUBGROUP_FEATURE_CLUSTERED_BIT_KHR 0x00000040 +#define GL_SUBGROUP_FEATURE_QUAD_BIT_KHR 0x00000080 +#endif /* GL_KHR_shader_subgroup */ + +#ifndef GL_KHR_texture_compression_astc_hdr +#define GL_KHR_texture_compression_astc_hdr 1 +#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 +#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 +#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 +#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 +#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 +#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 +#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 +#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 +#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 +#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 +#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA +#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB +#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC +#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +#endif /* GL_KHR_texture_compression_astc_hdr */ + +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_KHR_texture_compression_astc_ldr 1 +#endif /* GL_KHR_texture_compression_astc_ldr */ + +#ifndef GL_KHR_texture_compression_astc_sliced_3d +#define GL_KHR_texture_compression_astc_sliced_3d 1 +#endif /* GL_KHR_texture_compression_astc_sliced_3d */ + +#ifndef GL_OES_EGL_image +#define GL_OES_EGL_image 1 +typedef void *GLeglImageOES; +typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image); +typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image); +GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image); +#endif +#endif /* GL_OES_EGL_image */ + +#ifndef GL_OES_EGL_image_external +#define GL_OES_EGL_image_external 1 +#define GL_TEXTURE_EXTERNAL_OES 0x8D65 +#define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67 +#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68 +#define GL_SAMPLER_EXTERNAL_OES 0x8D66 +#endif /* GL_OES_EGL_image_external */ + +#ifndef GL_OES_EGL_image_external_essl3 +#define GL_OES_EGL_image_external_essl3 1 +#endif /* GL_OES_EGL_image_external_essl3 */ + +#ifndef GL_OES_compressed_ETC1_RGB8_sub_texture +#define GL_OES_compressed_ETC1_RGB8_sub_texture 1 +#endif /* GL_OES_compressed_ETC1_RGB8_sub_texture */ + +#ifndef GL_OES_compressed_ETC1_RGB8_texture +#define GL_OES_compressed_ETC1_RGB8_texture 1 +#define GL_ETC1_RGB8_OES 0x8D64 +#endif /* GL_OES_compressed_ETC1_RGB8_texture */ + +#ifndef GL_OES_compressed_paletted_texture +#define GL_OES_compressed_paletted_texture 1 +#define GL_PALETTE4_RGB8_OES 0x8B90 +#define GL_PALETTE4_RGBA8_OES 0x8B91 +#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 +#define GL_PALETTE4_RGBA4_OES 0x8B93 +#define GL_PALETTE4_RGB5_A1_OES 0x8B94 +#define GL_PALETTE8_RGB8_OES 0x8B95 +#define GL_PALETTE8_RGBA8_OES 0x8B96 +#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 +#define GL_PALETTE8_RGBA4_OES 0x8B98 +#define GL_PALETTE8_RGB5_A1_OES 0x8B99 +#endif /* GL_OES_compressed_paletted_texture */ + +#ifndef GL_OES_copy_image +#define GL_OES_copy_image 1 +typedef void (GL_APIENTRYP PFNGLCOPYIMAGESUBDATAOESPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glCopyImageSubDataOES (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +#endif +#endif /* GL_OES_copy_image */ + +#ifndef GL_OES_depth24 +#define GL_OES_depth24 1 +#define GL_DEPTH_COMPONENT24_OES 0x81A6 +#endif /* GL_OES_depth24 */ + +#ifndef GL_OES_depth32 +#define GL_OES_depth32 1 +#define GL_DEPTH_COMPONENT32_OES 0x81A7 +#endif /* GL_OES_depth32 */ + +#ifndef GL_OES_depth_texture +#define GL_OES_depth_texture 1 +#endif /* GL_OES_depth_texture */ + +#ifndef GL_OES_draw_buffers_indexed +#define GL_OES_draw_buffers_indexed 1 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +typedef void (GL_APIENTRYP PFNGLENABLEIOESPROC) (GLenum target, GLuint index); +typedef void (GL_APIENTRYP PFNGLDISABLEIOESPROC) (GLenum target, GLuint index); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONIOESPROC) (GLuint buf, GLenum mode); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEIOESPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCIOESPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEIOESPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (GL_APIENTRYP PFNGLCOLORMASKIOESPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef GLboolean (GL_APIENTRYP PFNGLISENABLEDIOESPROC) (GLenum target, GLuint index); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glEnableiOES (GLenum target, GLuint index); +GL_APICALL void GL_APIENTRY glDisableiOES (GLenum target, GLuint index); +GL_APICALL void GL_APIENTRY glBlendEquationiOES (GLuint buf, GLenum mode); +GL_APICALL void GL_APIENTRY glBlendEquationSeparateiOES (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GL_APICALL void GL_APIENTRY glBlendFunciOES (GLuint buf, GLenum src, GLenum dst); +GL_APICALL void GL_APIENTRY glBlendFuncSeparateiOES (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GL_APICALL void GL_APIENTRY glColorMaskiOES (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GL_APICALL GLboolean GL_APIENTRY glIsEnablediOES (GLenum target, GLuint index); +#endif +#endif /* GL_OES_draw_buffers_indexed */ + +#ifndef GL_OES_draw_elements_base_vertex +#define GL_OES_draw_elements_base_vertex 1 +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXOESPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (GL_APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXOESPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXOESPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, const GLint *basevertex); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawElementsBaseVertexOES (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GL_APICALL void GL_APIENTRY glDrawRangeElementsBaseVertexOES (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedBaseVertexOES (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +GL_APICALL void GL_APIENTRY glMultiDrawElementsBaseVertexEXT (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, const GLint *basevertex); +#endif +#endif /* GL_OES_draw_elements_base_vertex */ + +#ifndef GL_OES_element_index_uint +#define GL_OES_element_index_uint 1 +#endif /* GL_OES_element_index_uint */ + +#ifndef GL_OES_fbo_render_mipmap +#define GL_OES_fbo_render_mipmap 1 +#endif /* GL_OES_fbo_render_mipmap */ + +#ifndef GL_OES_fragment_precision_high +#define GL_OES_fragment_precision_high 1 +#endif /* GL_OES_fragment_precision_high */ + +#ifndef GL_OES_geometry_point_size +#define GL_OES_geometry_point_size 1 +#endif /* GL_OES_geometry_point_size */ + +#ifndef GL_OES_geometry_shader +#define GL_OES_geometry_shader 1 +#define GL_GEOMETRY_SHADER_OES 0x8DD9 +#define GL_GEOMETRY_SHADER_BIT_OES 0x00000004 +#define GL_GEOMETRY_LINKED_VERTICES_OUT_OES 0x8916 +#define GL_GEOMETRY_LINKED_INPUT_TYPE_OES 0x8917 +#define GL_GEOMETRY_LINKED_OUTPUT_TYPE_OES 0x8918 +#define GL_GEOMETRY_SHADER_INVOCATIONS_OES 0x887F +#define GL_LAYER_PROVOKING_VERTEX_OES 0x825E +#define GL_LINES_ADJACENCY_OES 0x000A +#define GL_LINE_STRIP_ADJACENCY_OES 0x000B +#define GL_TRIANGLES_ADJACENCY_OES 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_OES 0x000D +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_OES 0x8DDF +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS_OES 0x8A2C +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_OES 0x8A32 +#define GL_MAX_GEOMETRY_INPUT_COMPONENTS_OES 0x9123 +#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_OES 0x9124 +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_OES 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_OES 0x8DE1 +#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS_OES 0x8E5A +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_OES 0x8C29 +#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_OES 0x92CF +#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS_OES 0x92D5 +#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS_OES 0x90CD +#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_OES 0x90D7 +#define GL_FIRST_VERTEX_CONVENTION_OES 0x8E4D +#define GL_LAST_VERTEX_CONVENTION_OES 0x8E4E +#define GL_UNDEFINED_VERTEX_OES 0x8260 +#define GL_PRIMITIVES_GENERATED_OES 0x8C87 +#define GL_FRAMEBUFFER_DEFAULT_LAYERS_OES 0x9312 +#define GL_MAX_FRAMEBUFFER_LAYERS_OES 0x9317 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_OES 0x8DA8 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_OES 0x8DA7 +#define GL_REFERENCED_BY_GEOMETRY_SHADER_OES 0x9309 +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTUREOESPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferTextureOES (GLenum target, GLenum attachment, GLuint texture, GLint level); +#endif +#endif /* GL_OES_geometry_shader */ + +#ifndef GL_OES_get_program_binary +#define GL_OES_get_program_binary 1 +#define GL_PROGRAM_BINARY_LENGTH_OES 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE +#define GL_PROGRAM_BINARY_FORMATS_OES 0x87FF +typedef void (GL_APIENTRYP PFNGLGETPROGRAMBINARYOESPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +typedef void (GL_APIENTRYP PFNGLPROGRAMBINARYOESPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLint length); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetProgramBinaryOES (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +GL_APICALL void GL_APIENTRY glProgramBinaryOES (GLuint program, GLenum binaryFormat, const void *binary, GLint length); +#endif +#endif /* GL_OES_get_program_binary */ + +#ifndef GL_OES_gpu_shader5 +#define GL_OES_gpu_shader5 1 +#endif /* GL_OES_gpu_shader5 */ + +#ifndef GL_OES_mapbuffer +#define GL_OES_mapbuffer 1 +#define GL_WRITE_ONLY_OES 0x88B9 +#define GL_BUFFER_ACCESS_OES 0x88BB +#define GL_BUFFER_MAPPED_OES 0x88BC +#define GL_BUFFER_MAP_POINTER_OES 0x88BD +typedef void *(GL_APIENTRYP PFNGLMAPBUFFEROESPROC) (GLenum target, GLenum access); +typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFEROESPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname, void **params); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void *GL_APIENTRY glMapBufferOES (GLenum target, GLenum access); +GL_APICALL GLboolean GL_APIENTRY glUnmapBufferOES (GLenum target); +GL_APICALL void GL_APIENTRY glGetBufferPointervOES (GLenum target, GLenum pname, void **params); +#endif +#endif /* GL_OES_mapbuffer */ + +#ifndef GL_OES_packed_depth_stencil +#define GL_OES_packed_depth_stencil 1 +#define GL_DEPTH_STENCIL_OES 0x84F9 +#define GL_UNSIGNED_INT_24_8_OES 0x84FA +#define GL_DEPTH24_STENCIL8_OES 0x88F0 +#endif /* GL_OES_packed_depth_stencil */ + +#ifndef GL_OES_primitive_bounding_box +#define GL_OES_primitive_bounding_box 1 +#define GL_PRIMITIVE_BOUNDING_BOX_OES 0x92BE +typedef void (GL_APIENTRYP PFNGLPRIMITIVEBOUNDINGBOXOESPROC) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glPrimitiveBoundingBoxOES (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#endif +#endif /* GL_OES_primitive_bounding_box */ + +#ifndef GL_OES_required_internalformat +#define GL_OES_required_internalformat 1 +#define GL_ALPHA8_OES 0x803C +#define GL_DEPTH_COMPONENT16_OES 0x81A5 +#define GL_LUMINANCE4_ALPHA4_OES 0x8043 +#define GL_LUMINANCE8_ALPHA8_OES 0x8045 +#define GL_LUMINANCE8_OES 0x8040 +#define GL_RGBA4_OES 0x8056 +#define GL_RGB5_A1_OES 0x8057 +#define GL_RGB565_OES 0x8D62 +#define GL_RGB8_OES 0x8051 +#define GL_RGBA8_OES 0x8058 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB10_A2_EXT 0x8059 +#endif /* GL_OES_required_internalformat */ + +#ifndef GL_OES_rgb8_rgba8 +#define GL_OES_rgb8_rgba8 1 +#endif /* GL_OES_rgb8_rgba8 */ + +#ifndef GL_OES_sample_shading +#define GL_OES_sample_shading 1 +#define GL_SAMPLE_SHADING_OES 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE_OES 0x8C37 +typedef void (GL_APIENTRYP PFNGLMINSAMPLESHADINGOESPROC) (GLfloat value); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glMinSampleShadingOES (GLfloat value); +#endif +#endif /* GL_OES_sample_shading */ + +#ifndef GL_OES_sample_variables +#define GL_OES_sample_variables 1 +#endif /* GL_OES_sample_variables */ + +#ifndef GL_OES_shader_image_atomic +#define GL_OES_shader_image_atomic 1 +#endif /* GL_OES_shader_image_atomic */ + +#ifndef GL_OES_shader_io_blocks +#define GL_OES_shader_io_blocks 1 +#endif /* GL_OES_shader_io_blocks */ + +#ifndef GL_OES_shader_multisample_interpolation +#define GL_OES_shader_multisample_interpolation 1 +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_OES 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_OES 0x8E5C +#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS_OES 0x8E5D +#endif /* GL_OES_shader_multisample_interpolation */ + +#ifndef GL_OES_standard_derivatives +#define GL_OES_standard_derivatives 1 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES 0x8B8B +#endif /* GL_OES_standard_derivatives */ + +#ifndef GL_OES_stencil1 +#define GL_OES_stencil1 1 +#define GL_STENCIL_INDEX1_OES 0x8D46 +#endif /* GL_OES_stencil1 */ + +#ifndef GL_OES_stencil4 +#define GL_OES_stencil4 1 +#define GL_STENCIL_INDEX4_OES 0x8D47 +#endif /* GL_OES_stencil4 */ + +#ifndef GL_OES_surfaceless_context +#define GL_OES_surfaceless_context 1 +#define GL_FRAMEBUFFER_UNDEFINED_OES 0x8219 +#endif /* GL_OES_surfaceless_context */ + +#ifndef GL_OES_tessellation_point_size +#define GL_OES_tessellation_point_size 1 +#endif /* GL_OES_tessellation_point_size */ + +#ifndef GL_OES_tessellation_shader +#define GL_OES_tessellation_shader 1 +#define GL_PATCHES_OES 0x000E +#define GL_PATCH_VERTICES_OES 0x8E72 +#define GL_TESS_CONTROL_OUTPUT_VERTICES_OES 0x8E75 +#define GL_TESS_GEN_MODE_OES 0x8E76 +#define GL_TESS_GEN_SPACING_OES 0x8E77 +#define GL_TESS_GEN_VERTEX_ORDER_OES 0x8E78 +#define GL_TESS_GEN_POINT_MODE_OES 0x8E79 +#define GL_ISOLINES_OES 0x8E7A +#define GL_QUADS_OES 0x0007 +#define GL_FRACTIONAL_ODD_OES 0x8E7B +#define GL_FRACTIONAL_EVEN_OES 0x8E7C +#define GL_MAX_PATCH_VERTICES_OES 0x8E7D +#define GL_MAX_TESS_GEN_LEVEL_OES 0x8E7E +#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS_OES 0x8E7F +#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_OES 0x8E80 +#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS_OES 0x8E81 +#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS_OES 0x8E82 +#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS_OES 0x8E83 +#define GL_MAX_TESS_PATCH_COMPONENTS_OES 0x8E84 +#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_OES 0x8E85 +#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS_OES 0x8E86 +#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS_OES 0x8E89 +#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS_OES 0x8E8A +#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS_OES 0x886C +#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS_OES 0x886D +#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS_OES 0x8E1E +#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_OES 0x8E1F +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS_OES 0x92CD +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS_OES 0x92CE +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS_OES 0x92D3 +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS_OES 0x92D4 +#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS_OES 0x90CB +#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS_OES 0x90CC +#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_OES 0x90D8 +#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_OES 0x90D9 +#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED_OES 0x8221 +#define GL_IS_PER_PATCH_OES 0x92E7 +#define GL_REFERENCED_BY_TESS_CONTROL_SHADER_OES 0x9307 +#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER_OES 0x9308 +#define GL_TESS_CONTROL_SHADER_OES 0x8E88 +#define GL_TESS_EVALUATION_SHADER_OES 0x8E87 +#define GL_TESS_CONTROL_SHADER_BIT_OES 0x00000008 +#define GL_TESS_EVALUATION_SHADER_BIT_OES 0x00000010 +typedef void (GL_APIENTRYP PFNGLPATCHPARAMETERIOESPROC) (GLenum pname, GLint value); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glPatchParameteriOES (GLenum pname, GLint value); +#endif +#endif /* GL_OES_tessellation_shader */ + +#ifndef GL_OES_texture_3D +#define GL_OES_texture_3D 1 +#define GL_TEXTURE_WRAP_R_OES 0x8072 +#define GL_TEXTURE_3D_OES 0x806F +#define GL_TEXTURE_BINDING_3D_OES 0x806A +#define GL_MAX_3D_TEXTURE_SIZE_OES 0x8073 +#define GL_SAMPLER_3D_OES 0x8B5F +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES 0x8CD4 +typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DOESPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glCopyTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glCompressedTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glCompressedTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glFramebufferTexture3DOES (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +#endif +#endif /* GL_OES_texture_3D */ + +#ifndef GL_OES_texture_border_clamp +#define GL_OES_texture_border_clamp 1 +#define GL_TEXTURE_BORDER_COLOR_OES 0x1004 +#define GL_CLAMP_TO_BORDER_OES 0x812D +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIIVOESPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIUIVOESPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIIVOESPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIUIVOESPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIIVOESPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIUIVOESPROC) (GLuint sampler, GLenum pname, const GLuint *param); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIIVOESPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVOESPROC) (GLuint sampler, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexParameterIivOES (GLenum target, GLenum pname, const GLint *params); +GL_APICALL void GL_APIENTRY glTexParameterIuivOES (GLenum target, GLenum pname, const GLuint *params); +GL_APICALL void GL_APIENTRY glGetTexParameterIivOES (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetTexParameterIuivOES (GLenum target, GLenum pname, GLuint *params); +GL_APICALL void GL_APIENTRY glSamplerParameterIivOES (GLuint sampler, GLenum pname, const GLint *param); +GL_APICALL void GL_APIENTRY glSamplerParameterIuivOES (GLuint sampler, GLenum pname, const GLuint *param); +GL_APICALL void GL_APIENTRY glGetSamplerParameterIivOES (GLuint sampler, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetSamplerParameterIuivOES (GLuint sampler, GLenum pname, GLuint *params); +#endif +#endif /* GL_OES_texture_border_clamp */ + +#ifndef GL_OES_texture_buffer +#define GL_OES_texture_buffer 1 +#define GL_TEXTURE_BUFFER_OES 0x8C2A +#define GL_TEXTURE_BUFFER_BINDING_OES 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_OES 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_OES 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_OES 0x8C2D +#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT_OES 0x919F +#define GL_SAMPLER_BUFFER_OES 0x8DC2 +#define GL_INT_SAMPLER_BUFFER_OES 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_OES 0x8DD8 +#define GL_IMAGE_BUFFER_OES 0x9051 +#define GL_INT_IMAGE_BUFFER_OES 0x905C +#define GL_UNSIGNED_INT_IMAGE_BUFFER_OES 0x9067 +#define GL_TEXTURE_BUFFER_OFFSET_OES 0x919D +#define GL_TEXTURE_BUFFER_SIZE_OES 0x919E +typedef void (GL_APIENTRYP PFNGLTEXBUFFEROESPROC) (GLenum target, GLenum internalformat, GLuint buffer); +typedef void (GL_APIENTRYP PFNGLTEXBUFFERRANGEOESPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexBufferOES (GLenum target, GLenum internalformat, GLuint buffer); +GL_APICALL void GL_APIENTRY glTexBufferRangeOES (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +#endif +#endif /* GL_OES_texture_buffer */ + +#ifndef GL_OES_texture_compression_astc +#define GL_OES_texture_compression_astc 1 +#define GL_COMPRESSED_RGBA_ASTC_3x3x3_OES 0x93C0 +#define GL_COMPRESSED_RGBA_ASTC_4x3x3_OES 0x93C1 +#define GL_COMPRESSED_RGBA_ASTC_4x4x3_OES 0x93C2 +#define GL_COMPRESSED_RGBA_ASTC_4x4x4_OES 0x93C3 +#define GL_COMPRESSED_RGBA_ASTC_5x4x4_OES 0x93C4 +#define GL_COMPRESSED_RGBA_ASTC_5x5x4_OES 0x93C5 +#define GL_COMPRESSED_RGBA_ASTC_5x5x5_OES 0x93C6 +#define GL_COMPRESSED_RGBA_ASTC_6x5x5_OES 0x93C7 +#define GL_COMPRESSED_RGBA_ASTC_6x6x5_OES 0x93C8 +#define GL_COMPRESSED_RGBA_ASTC_6x6x6_OES 0x93C9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES 0x93E0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES 0x93E1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES 0x93E2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES 0x93E3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES 0x93E4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES 0x93E5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES 0x93E6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES 0x93E7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES 0x93E8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES 0x93E9 +#endif /* GL_OES_texture_compression_astc */ + +#ifndef GL_OES_texture_cube_map_array +#define GL_OES_texture_cube_map_array 1 +#define GL_TEXTURE_CUBE_MAP_ARRAY_OES 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_OES 0x900A +#define GL_SAMPLER_CUBE_MAP_ARRAY_OES 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_OES 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_OES 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_OES 0x900F +#define GL_IMAGE_CUBE_MAP_ARRAY_OES 0x9054 +#define GL_INT_IMAGE_CUBE_MAP_ARRAY_OES 0x905F +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_OES 0x906A +#endif /* GL_OES_texture_cube_map_array */ + +#ifndef GL_OES_texture_float +#define GL_OES_texture_float 1 +#endif /* GL_OES_texture_float */ + +#ifndef GL_OES_texture_float_linear +#define GL_OES_texture_float_linear 1 +#endif /* GL_OES_texture_float_linear */ + +#ifndef GL_OES_texture_half_float +#define GL_OES_texture_half_float 1 +#define GL_HALF_FLOAT_OES 0x8D61 +#endif /* GL_OES_texture_half_float */ + +#ifndef GL_OES_texture_half_float_linear +#define GL_OES_texture_half_float_linear 1 +#endif /* GL_OES_texture_half_float_linear */ + +#ifndef GL_OES_texture_npot +#define GL_OES_texture_npot 1 +#endif /* GL_OES_texture_npot */ + +#ifndef GL_OES_texture_stencil8 +#define GL_OES_texture_stencil8 1 +#define GL_STENCIL_INDEX_OES 0x1901 +#define GL_STENCIL_INDEX8_OES 0x8D48 +#endif /* GL_OES_texture_stencil8 */ + +#ifndef GL_OES_texture_storage_multisample_2d_array +#define GL_OES_texture_storage_multisample_2d_array 1 +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES 0x9102 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY_OES 0x9105 +#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910B +#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910C +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910D +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEOESPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexStorage3DMultisampleOES (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +#endif +#endif /* GL_OES_texture_storage_multisample_2d_array */ + +#ifndef GL_OES_texture_view +#define GL_OES_texture_view 1 +#define GL_TEXTURE_VIEW_MIN_LEVEL_OES 0x82DB +#define GL_TEXTURE_VIEW_NUM_LEVELS_OES 0x82DC +#define GL_TEXTURE_VIEW_MIN_LAYER_OES 0x82DD +#define GL_TEXTURE_VIEW_NUM_LAYERS_OES 0x82DE +#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF +typedef void (GL_APIENTRYP PFNGLTEXTUREVIEWOESPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTextureViewOES (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +#endif +#endif /* GL_OES_texture_view */ + +#ifndef GL_OES_vertex_array_object +#define GL_OES_vertex_array_object 1 +#define GL_VERTEX_ARRAY_BINDING_OES 0x85B5 +typedef void (GL_APIENTRYP PFNGLBINDVERTEXARRAYOESPROC) (GLuint array); +typedef void (GL_APIENTRYP PFNGLDELETEVERTEXARRAYSOESPROC) (GLsizei n, const GLuint *arrays); +typedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSOESPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBindVertexArrayOES (GLuint array); +GL_APICALL void GL_APIENTRY glDeleteVertexArraysOES (GLsizei n, const GLuint *arrays); +GL_APICALL void GL_APIENTRY glGenVertexArraysOES (GLsizei n, GLuint *arrays); +GL_APICALL GLboolean GL_APIENTRY glIsVertexArrayOES (GLuint array); +#endif +#endif /* GL_OES_vertex_array_object */ + +#ifndef GL_OES_vertex_half_float +#define GL_OES_vertex_half_float 1 +#endif /* GL_OES_vertex_half_float */ + +#ifndef GL_OES_vertex_type_10_10_10_2 +#define GL_OES_vertex_type_10_10_10_2 1 +#define GL_UNSIGNED_INT_10_10_10_2_OES 0x8DF6 +#define GL_INT_10_10_10_2_OES 0x8DF7 +#endif /* GL_OES_vertex_type_10_10_10_2 */ + +#ifndef GL_OES_viewport_array +#define GL_OES_viewport_array 1 +#define GL_MAX_VIEWPORTS_OES 0x825B +#define GL_VIEWPORT_SUBPIXEL_BITS_OES 0x825C +#define GL_VIEWPORT_BOUNDS_RANGE_OES 0x825D +#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX_OES 0x825F +typedef void (GL_APIENTRYP PFNGLVIEWPORTARRAYVOESPROC) (GLuint first, GLsizei count, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVIEWPORTINDEXEDFOESPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +typedef void (GL_APIENTRYP PFNGLVIEWPORTINDEXEDFVOESPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLSCISSORARRAYVOESPROC) (GLuint first, GLsizei count, const GLint *v); +typedef void (GL_APIENTRYP PFNGLSCISSORINDEXEDOESPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLSCISSORINDEXEDVOESPROC) (GLuint index, const GLint *v); +typedef void (GL_APIENTRYP PFNGLDEPTHRANGEARRAYFVOESPROC) (GLuint first, GLsizei count, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLDEPTHRANGEINDEXEDFOESPROC) (GLuint index, GLfloat n, GLfloat f); +typedef void (GL_APIENTRYP PFNGLGETFLOATI_VOESPROC) (GLenum target, GLuint index, GLfloat *data); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glViewportArrayvOES (GLuint first, GLsizei count, const GLfloat *v); +GL_APICALL void GL_APIENTRY glViewportIndexedfOES (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +GL_APICALL void GL_APIENTRY glViewportIndexedfvOES (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glScissorArrayvOES (GLuint first, GLsizei count, const GLint *v); +GL_APICALL void GL_APIENTRY glScissorIndexedOES (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glScissorIndexedvOES (GLuint index, const GLint *v); +GL_APICALL void GL_APIENTRY glDepthRangeArrayfvOES (GLuint first, GLsizei count, const GLfloat *v); +GL_APICALL void GL_APIENTRY glDepthRangeIndexedfOES (GLuint index, GLfloat n, GLfloat f); +GL_APICALL void GL_APIENTRY glGetFloati_vOES (GLenum target, GLuint index, GLfloat *data); +#endif +#endif /* GL_OES_viewport_array */ + +#ifndef GL_AMD_compressed_3DC_texture +#define GL_AMD_compressed_3DC_texture 1 +#define GL_3DC_X_AMD 0x87F9 +#define GL_3DC_XY_AMD 0x87FA +#endif /* GL_AMD_compressed_3DC_texture */ + +#ifndef GL_AMD_compressed_ATC_texture +#define GL_AMD_compressed_ATC_texture 1 +#define GL_ATC_RGB_AMD 0x8C92 +#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93 +#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE +#endif /* GL_AMD_compressed_ATC_texture */ + +#ifndef GL_AMD_framebuffer_multisample_advanced +#define GL_AMD_framebuffer_multisample_advanced 1 +#define GL_RENDERBUFFER_STORAGE_SAMPLES_AMD 0x91B2 +#define GL_MAX_COLOR_FRAMEBUFFER_SAMPLES_AMD 0x91B3 +#define GL_MAX_COLOR_FRAMEBUFFER_STORAGE_SAMPLES_AMD 0x91B4 +#define GL_MAX_DEPTH_STENCIL_FRAMEBUFFER_SAMPLES_AMD 0x91B5 +#define GL_NUM_SUPPORTED_MULTISAMPLE_MODES_AMD 0x91B6 +#define GL_SUPPORTED_MULTISAMPLE_MODES_AMD 0x91B7 +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEADVANCEDAMDPROC) (GLenum target, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEADVANCEDAMDPROC) (GLuint renderbuffer, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleAdvancedAMD (GLenum target, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glNamedRenderbufferStorageMultisampleAdvancedAMD (GLuint renderbuffer, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_AMD_framebuffer_multisample_advanced */ + +#ifndef GL_AMD_performance_monitor +#define GL_AMD_performance_monitor 1 +#define GL_COUNTER_TYPE_AMD 0x8BC0 +#define GL_COUNTER_RANGE_AMD 0x8BC1 +#define GL_UNSIGNED_INT64_AMD 0x8BC2 +#define GL_PERCENTAGE_AMD 0x8BC3 +#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 +#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 +#define GL_PERFMON_RESULT_AMD 0x8BC6 +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void *data); +typedef void (GL_APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (GL_APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (GL_APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +typedef void (GL_APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); +typedef void (GL_APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +GL_APICALL void GL_APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, void *data); +GL_APICALL void GL_APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); +GL_APICALL void GL_APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); +GL_APICALL void GL_APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +GL_APICALL void GL_APIENTRY glBeginPerfMonitorAMD (GLuint monitor); +GL_APICALL void GL_APIENTRY glEndPerfMonitorAMD (GLuint monitor); +GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#endif +#endif /* GL_AMD_performance_monitor */ + +#ifndef GL_AMD_program_binary_Z400 +#define GL_AMD_program_binary_Z400 1 +#define GL_Z400_BINARY_AMD 0x8740 +#endif /* GL_AMD_program_binary_Z400 */ + +#ifndef GL_ANDROID_extension_pack_es31a +#define GL_ANDROID_extension_pack_es31a 1 +#endif /* GL_ANDROID_extension_pack_es31a */ + +#ifndef GL_ANGLE_depth_texture +#define GL_ANGLE_depth_texture 1 +#endif /* GL_ANGLE_depth_texture */ + +#ifndef GL_ANGLE_framebuffer_blit +#define GL_ANGLE_framebuffer_blit 1 +#define GL_READ_FRAMEBUFFER_ANGLE 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_ANGLE 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_ANGLE 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_ANGLE 0x8CAA +typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERANGLEPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBlitFramebufferANGLE (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +#endif /* GL_ANGLE_framebuffer_blit */ + +#ifndef GL_ANGLE_framebuffer_multisample +#define GL_ANGLE_framebuffer_multisample 1 +#define GL_RENDERBUFFER_SAMPLES_ANGLE 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE 0x8D56 +#define GL_MAX_SAMPLES_ANGLE 0x8D57 +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleANGLE (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_ANGLE_framebuffer_multisample */ + +#ifndef GL_ANGLE_instanced_arrays +#define GL_ANGLE_instanced_arrays 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE 0x88FE +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDANGLEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDANGLEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawArraysInstancedANGLE (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedANGLE (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +GL_APICALL void GL_APIENTRY glVertexAttribDivisorANGLE (GLuint index, GLuint divisor); +#endif +#endif /* GL_ANGLE_instanced_arrays */ + +#ifndef GL_ANGLE_pack_reverse_row_order +#define GL_ANGLE_pack_reverse_row_order 1 +#define GL_PACK_REVERSE_ROW_ORDER_ANGLE 0x93A4 +#endif /* GL_ANGLE_pack_reverse_row_order */ + +#ifndef GL_ANGLE_program_binary +#define GL_ANGLE_program_binary 1 +#define GL_PROGRAM_BINARY_ANGLE 0x93A6 +#endif /* GL_ANGLE_program_binary */ + +#ifndef GL_ANGLE_texture_compression_dxt3 +#define GL_ANGLE_texture_compression_dxt3 1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2 +#endif /* GL_ANGLE_texture_compression_dxt3 */ + +#ifndef GL_ANGLE_texture_compression_dxt5 +#define GL_ANGLE_texture_compression_dxt5 1 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3 +#endif /* GL_ANGLE_texture_compression_dxt5 */ + +#ifndef GL_ANGLE_texture_usage +#define GL_ANGLE_texture_usage 1 +#define GL_TEXTURE_USAGE_ANGLE 0x93A2 +#define GL_FRAMEBUFFER_ATTACHMENT_ANGLE 0x93A3 +#endif /* GL_ANGLE_texture_usage */ + +#ifndef GL_ANGLE_translated_shader_source +#define GL_ANGLE_translated_shader_source 1 +#define GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE 0x93A0 +typedef void (GL_APIENTRYP PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetTranslatedShaderSourceANGLE (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +#endif +#endif /* GL_ANGLE_translated_shader_source */ + +#ifndef GL_APPLE_clip_distance +#define GL_APPLE_clip_distance 1 +#define GL_MAX_CLIP_DISTANCES_APPLE 0x0D32 +#define GL_CLIP_DISTANCE0_APPLE 0x3000 +#define GL_CLIP_DISTANCE1_APPLE 0x3001 +#define GL_CLIP_DISTANCE2_APPLE 0x3002 +#define GL_CLIP_DISTANCE3_APPLE 0x3003 +#define GL_CLIP_DISTANCE4_APPLE 0x3004 +#define GL_CLIP_DISTANCE5_APPLE 0x3005 +#define GL_CLIP_DISTANCE6_APPLE 0x3006 +#define GL_CLIP_DISTANCE7_APPLE 0x3007 +#endif /* GL_APPLE_clip_distance */ + +#ifndef GL_APPLE_color_buffer_packed_float +#define GL_APPLE_color_buffer_packed_float 1 +#endif /* GL_APPLE_color_buffer_packed_float */ + +#ifndef GL_APPLE_copy_texture_levels +#define GL_APPLE_copy_texture_levels 1 +typedef void (GL_APIENTRYP PFNGLCOPYTEXTURELEVELSAPPLEPROC) (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glCopyTextureLevelsAPPLE (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount); +#endif +#endif /* GL_APPLE_copy_texture_levels */ + +#ifndef GL_APPLE_framebuffer_multisample +#define GL_APPLE_framebuffer_multisample 1 +#define GL_RENDERBUFFER_SAMPLES_APPLE 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE 0x8D56 +#define GL_MAX_SAMPLES_APPLE 0x8D57 +#define GL_READ_FRAMEBUFFER_APPLE 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_APPLE 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_APPLE 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_APPLE 0x8CAA +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleAPPLE (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glResolveMultisampleFramebufferAPPLE (void); +#endif +#endif /* GL_APPLE_framebuffer_multisample */ + +#ifndef GL_APPLE_rgb_422 +#define GL_APPLE_rgb_422 1 +#define GL_RGB_422_APPLE 0x8A1F +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#define GL_RGB_RAW_422_APPLE 0x8A51 +#endif /* GL_APPLE_rgb_422 */ + +#ifndef GL_APPLE_sync +#define GL_APPLE_sync 1 +#define GL_SYNC_OBJECT_APPLE 0x8A53 +#define GL_MAX_SERVER_WAIT_TIMEOUT_APPLE 0x9111 +#define GL_OBJECT_TYPE_APPLE 0x9112 +#define GL_SYNC_CONDITION_APPLE 0x9113 +#define GL_SYNC_STATUS_APPLE 0x9114 +#define GL_SYNC_FLAGS_APPLE 0x9115 +#define GL_SYNC_FENCE_APPLE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE 0x9117 +#define GL_UNSIGNALED_APPLE 0x9118 +#define GL_SIGNALED_APPLE 0x9119 +#define GL_ALREADY_SIGNALED_APPLE 0x911A +#define GL_TIMEOUT_EXPIRED_APPLE 0x911B +#define GL_CONDITION_SATISFIED_APPLE 0x911C +#define GL_WAIT_FAILED_APPLE 0x911D +#define GL_SYNC_FLUSH_COMMANDS_BIT_APPLE 0x00000001 +#define GL_TIMEOUT_IGNORED_APPLE 0xFFFFFFFFFFFFFFFFull +typedef GLsync (GL_APIENTRYP PFNGLFENCESYNCAPPLEPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (GL_APIENTRYP PFNGLISSYNCAPPLEPROC) (GLsync sync); +typedef void (GL_APIENTRYP PFNGLDELETESYNCAPPLEPROC) (GLsync sync); +typedef GLenum (GL_APIENTRYP PFNGLCLIENTWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLGETINTEGER64VAPPLEPROC) (GLenum pname, GLint64 *params); +typedef void (GL_APIENTRYP PFNGLGETSYNCIVAPPLEPROC) (GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL GLsync GL_APIENTRY glFenceSyncAPPLE (GLenum condition, GLbitfield flags); +GL_APICALL GLboolean GL_APIENTRY glIsSyncAPPLE (GLsync sync); +GL_APICALL void GL_APIENTRY glDeleteSyncAPPLE (GLsync sync); +GL_APICALL GLenum GL_APIENTRY glClientWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glGetInteger64vAPPLE (GLenum pname, GLint64 *params); +GL_APICALL void GL_APIENTRY glGetSyncivAPPLE (GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values); +#endif +#endif /* GL_APPLE_sync */ + +#ifndef GL_APPLE_texture_format_BGRA8888 +#define GL_APPLE_texture_format_BGRA8888 1 +#define GL_BGRA_EXT 0x80E1 +#define GL_BGRA8_EXT 0x93A1 +#endif /* GL_APPLE_texture_format_BGRA8888 */ + +#ifndef GL_APPLE_texture_max_level +#define GL_APPLE_texture_max_level 1 +#define GL_TEXTURE_MAX_LEVEL_APPLE 0x813D +#endif /* GL_APPLE_texture_max_level */ + +#ifndef GL_APPLE_texture_packed_float +#define GL_APPLE_texture_packed_float 1 +#define GL_UNSIGNED_INT_10F_11F_11F_REV_APPLE 0x8C3B +#define GL_UNSIGNED_INT_5_9_9_9_REV_APPLE 0x8C3E +#define GL_R11F_G11F_B10F_APPLE 0x8C3A +#define GL_RGB9_E5_APPLE 0x8C3D +#endif /* GL_APPLE_texture_packed_float */ + +#ifndef GL_ARM_mali_program_binary +#define GL_ARM_mali_program_binary 1 +#define GL_MALI_PROGRAM_BINARY_ARM 0x8F61 +#endif /* GL_ARM_mali_program_binary */ + +#ifndef GL_ARM_mali_shader_binary +#define GL_ARM_mali_shader_binary 1 +#define GL_MALI_SHADER_BINARY_ARM 0x8F60 +#endif /* GL_ARM_mali_shader_binary */ + +#ifndef GL_ARM_rgba8 +#define GL_ARM_rgba8 1 +#endif /* GL_ARM_rgba8 */ + +#ifndef GL_ARM_shader_framebuffer_fetch +#define GL_ARM_shader_framebuffer_fetch 1 +#define GL_FETCH_PER_SAMPLE_ARM 0x8F65 +#define GL_FRAGMENT_SHADER_FRAMEBUFFER_FETCH_MRT_ARM 0x8F66 +#endif /* GL_ARM_shader_framebuffer_fetch */ + +#ifndef GL_ARM_shader_framebuffer_fetch_depth_stencil +#define GL_ARM_shader_framebuffer_fetch_depth_stencil 1 +#endif /* GL_ARM_shader_framebuffer_fetch_depth_stencil */ + +#ifndef GL_ARM_texture_unnormalized_coordinates +#define GL_ARM_texture_unnormalized_coordinates 1 +#define GL_TEXTURE_UNNORMALIZED_COORDINATES_ARM 0x8F6A +#endif /* GL_ARM_texture_unnormalized_coordinates */ + +#ifndef GL_DMP_program_binary +#define GL_DMP_program_binary 1 +#define GL_SMAPHS30_PROGRAM_BINARY_DMP 0x9251 +#define GL_SMAPHS_PROGRAM_BINARY_DMP 0x9252 +#define GL_DMP_PROGRAM_BINARY_DMP 0x9253 +#endif /* GL_DMP_program_binary */ + +#ifndef GL_DMP_shader_binary +#define GL_DMP_shader_binary 1 +#define GL_SHADER_BINARY_DMP 0x9250 +#endif /* GL_DMP_shader_binary */ + +#ifndef GL_EXT_EGL_image_array +#define GL_EXT_EGL_image_array 1 +#endif /* GL_EXT_EGL_image_array */ + +#ifndef GL_EXT_EGL_image_storage +#define GL_EXT_EGL_image_storage 1 +typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXSTORAGEEXTPROC) (GLenum target, GLeglImageOES image, const GLint* attrib_list); +typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURESTORAGEEXTPROC) (GLuint texture, GLeglImageOES image, const GLint* attrib_list); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glEGLImageTargetTexStorageEXT (GLenum target, GLeglImageOES image, const GLint* attrib_list); +GL_APICALL void GL_APIENTRY glEGLImageTargetTextureStorageEXT (GLuint texture, GLeglImageOES image, const GLint* attrib_list); +#endif +#endif /* GL_EXT_EGL_image_storage */ + +#ifndef GL_EXT_YUV_target +#define GL_EXT_YUV_target 1 +#define GL_SAMPLER_EXTERNAL_2D_Y2Y_EXT 0x8BE7 +#endif /* GL_EXT_YUV_target */ + +#ifndef GL_EXT_base_instance +#define GL_EXT_base_instance 1 +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEEXTPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawArraysInstancedBaseInstanceEXT (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedBaseInstanceEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedBaseVertexBaseInstanceEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +#endif +#endif /* GL_EXT_base_instance */ + +#ifndef GL_EXT_blend_func_extended +#define GL_EXT_blend_func_extended 1 +#define GL_SRC1_COLOR_EXT 0x88F9 +#define GL_SRC1_ALPHA_EXT 0x8589 +#define GL_ONE_MINUS_SRC1_COLOR_EXT 0x88FA +#define GL_ONE_MINUS_SRC1_ALPHA_EXT 0x88FB +#define GL_SRC_ALPHA_SATURATE_EXT 0x0308 +#define GL_LOCATION_INDEX_EXT 0x930F +#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT 0x88FC +typedef void (GL_APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDEXTPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (GL_APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXEXTPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef GLint (GL_APIENTRYP PFNGLGETFRAGDATAINDEXEXTPROC) (GLuint program, const GLchar *name); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBindFragDataLocationIndexedEXT (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +GL_APICALL void GL_APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name); +GL_APICALL GLint GL_APIENTRY glGetProgramResourceLocationIndexEXT (GLuint program, GLenum programInterface, const GLchar *name); +GL_APICALL GLint GL_APIENTRY glGetFragDataIndexEXT (GLuint program, const GLchar *name); +#endif +#endif /* GL_EXT_blend_func_extended */ + +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#endif /* GL_EXT_blend_minmax */ + +#ifndef GL_EXT_buffer_storage +#define GL_EXT_buffer_storage 1 +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_PERSISTENT_BIT_EXT 0x0040 +#define GL_MAP_COHERENT_BIT_EXT 0x0080 +#define GL_DYNAMIC_STORAGE_BIT_EXT 0x0100 +#define GL_CLIENT_STORAGE_BIT_EXT 0x0200 +#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT_EXT 0x00004000 +#define GL_BUFFER_IMMUTABLE_STORAGE_EXT 0x821F +#define GL_BUFFER_STORAGE_FLAGS_EXT 0x8220 +typedef void (GL_APIENTRYP PFNGLBUFFERSTORAGEEXTPROC) (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBufferStorageEXT (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); +#endif +#endif /* GL_EXT_buffer_storage */ + +#ifndef GL_EXT_clear_texture +#define GL_EXT_clear_texture 1 +typedef void (GL_APIENTRYP PFNGLCLEARTEXIMAGEEXTPROC) (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); +typedef void (GL_APIENTRYP PFNGLCLEARTEXSUBIMAGEEXTPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glClearTexImageEXT (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); +GL_APICALL void GL_APIENTRY glClearTexSubImageEXT (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); +#endif +#endif /* GL_EXT_clear_texture */ + +#ifndef GL_EXT_clip_control +#define GL_EXT_clip_control 1 +#define GL_LOWER_LEFT_EXT 0x8CA1 +#define GL_UPPER_LEFT_EXT 0x8CA2 +#define GL_NEGATIVE_ONE_TO_ONE_EXT 0x935E +#define GL_ZERO_TO_ONE_EXT 0x935F +#define GL_CLIP_ORIGIN_EXT 0x935C +#define GL_CLIP_DEPTH_MODE_EXT 0x935D +typedef void (GL_APIENTRYP PFNGLCLIPCONTROLEXTPROC) (GLenum origin, GLenum depth); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glClipControlEXT (GLenum origin, GLenum depth); +#endif +#endif /* GL_EXT_clip_control */ + +#ifndef GL_EXT_clip_cull_distance +#define GL_EXT_clip_cull_distance 1 +#define GL_MAX_CLIP_DISTANCES_EXT 0x0D32 +#define GL_MAX_CULL_DISTANCES_EXT 0x82F9 +#define GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES_EXT 0x82FA +#define GL_CLIP_DISTANCE0_EXT 0x3000 +#define GL_CLIP_DISTANCE1_EXT 0x3001 +#define GL_CLIP_DISTANCE2_EXT 0x3002 +#define GL_CLIP_DISTANCE3_EXT 0x3003 +#define GL_CLIP_DISTANCE4_EXT 0x3004 +#define GL_CLIP_DISTANCE5_EXT 0x3005 +#define GL_CLIP_DISTANCE6_EXT 0x3006 +#define GL_CLIP_DISTANCE7_EXT 0x3007 +#endif /* GL_EXT_clip_cull_distance */ + +#ifndef GL_EXT_color_buffer_float +#define GL_EXT_color_buffer_float 1 +#endif /* GL_EXT_color_buffer_float */ + +#ifndef GL_EXT_color_buffer_half_float +#define GL_EXT_color_buffer_half_float 1 +#define GL_RGBA16F_EXT 0x881A +#define GL_RGB16F_EXT 0x881B +#define GL_RG16F_EXT 0x822F +#define GL_R16F_EXT 0x822D +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT 0x8211 +#define GL_UNSIGNED_NORMALIZED_EXT 0x8C17 +#endif /* GL_EXT_color_buffer_half_float */ + +#ifndef GL_EXT_conservative_depth +#define GL_EXT_conservative_depth 1 +#endif /* GL_EXT_conservative_depth */ + +#ifndef GL_EXT_copy_image +#define GL_EXT_copy_image 1 +typedef void (GL_APIENTRYP PFNGLCOPYIMAGESUBDATAEXTPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glCopyImageSubDataEXT (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +#endif +#endif /* GL_EXT_copy_image */ + +#ifndef GL_EXT_debug_label +#define GL_EXT_debug_label 1 +#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F +#define GL_PROGRAM_OBJECT_EXT 0x8B40 +#define GL_SHADER_OBJECT_EXT 0x8B48 +#define GL_BUFFER_OBJECT_EXT 0x9151 +#define GL_QUERY_OBJECT_EXT 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154 +#define GL_TRANSFORM_FEEDBACK 0x8E22 +typedef void (GL_APIENTRYP PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glLabelObjectEXT (GLenum type, GLuint object, GLsizei length, const GLchar *label); +GL_APICALL void GL_APIENTRY glGetObjectLabelEXT (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif +#endif /* GL_EXT_debug_label */ + +#ifndef GL_EXT_debug_marker +#define GL_EXT_debug_marker 1 +typedef void (GL_APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker); +typedef void (GL_APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker); +typedef void (GL_APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glInsertEventMarkerEXT (GLsizei length, const GLchar *marker); +GL_APICALL void GL_APIENTRY glPushGroupMarkerEXT (GLsizei length, const GLchar *marker); +GL_APICALL void GL_APIENTRY glPopGroupMarkerEXT (void); +#endif +#endif /* GL_EXT_debug_marker */ + +#ifndef GL_EXT_depth_clamp +#define GL_EXT_depth_clamp 1 +#define GL_DEPTH_CLAMP_EXT 0x864F +#endif /* GL_EXT_depth_clamp */ + +#ifndef GL_EXT_discard_framebuffer +#define GL_EXT_discard_framebuffer 1 +#define GL_COLOR_EXT 0x1800 +#define GL_DEPTH_EXT 0x1801 +#define GL_STENCIL_EXT 0x1802 +typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDiscardFramebufferEXT (GLenum target, GLsizei numAttachments, const GLenum *attachments); +#endif +#endif /* GL_EXT_discard_framebuffer */ + +#ifndef GL_EXT_disjoint_timer_query +#define GL_EXT_disjoint_timer_query 1 +#define GL_QUERY_COUNTER_BITS_EXT 0x8864 +#define GL_CURRENT_QUERY_EXT 0x8865 +#define GL_QUERY_RESULT_EXT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_EXT 0x8867 +#define GL_TIME_ELAPSED_EXT 0x88BF +#define GL_TIMESTAMP_EXT 0x8E28 +#define GL_GPU_DISJOINT_EXT 0x8FBB +typedef void (GL_APIENTRYP PFNGLGENQUERIESEXTPROC) (GLsizei n, GLuint *ids); +typedef void (GL_APIENTRYP PFNGLDELETEQUERIESEXTPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (GL_APIENTRYP PFNGLISQUERYEXTPROC) (GLuint id); +typedef void (GL_APIENTRYP PFNGLBEGINQUERYEXTPROC) (GLenum target, GLuint id); +typedef void (GL_APIENTRYP PFNGLENDQUERYEXTPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLQUERYCOUNTEREXTPROC) (GLuint id, GLenum target); +typedef void (GL_APIENTRYP PFNGLGETQUERYIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTIVEXTPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUIVEXTPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64 *params); +typedef void (GL_APIENTRYP PFNGLGETINTEGER64VEXTPROC) (GLenum pname, GLint64 *data); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGenQueriesEXT (GLsizei n, GLuint *ids); +GL_APICALL void GL_APIENTRY glDeleteQueriesEXT (GLsizei n, const GLuint *ids); +GL_APICALL GLboolean GL_APIENTRY glIsQueryEXT (GLuint id); +GL_APICALL void GL_APIENTRY glBeginQueryEXT (GLenum target, GLuint id); +GL_APICALL void GL_APIENTRY glEndQueryEXT (GLenum target); +GL_APICALL void GL_APIENTRY glQueryCounterEXT (GLuint id, GLenum target); +GL_APICALL void GL_APIENTRY glGetQueryivEXT (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetQueryObjectivEXT (GLuint id, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetQueryObjectuivEXT (GLuint id, GLenum pname, GLuint *params); +GL_APICALL void GL_APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64 *params); +GL_APICALL void GL_APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64 *params); +GL_APICALL void GL_APIENTRY glGetInteger64vEXT (GLenum pname, GLint64 *data); +#endif +#endif /* GL_EXT_disjoint_timer_query */ + +#ifndef GL_EXT_draw_buffers +#define GL_EXT_draw_buffers 1 +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_MAX_DRAW_BUFFERS_EXT 0x8824 +#define GL_DRAW_BUFFER0_EXT 0x8825 +#define GL_DRAW_BUFFER1_EXT 0x8826 +#define GL_DRAW_BUFFER2_EXT 0x8827 +#define GL_DRAW_BUFFER3_EXT 0x8828 +#define GL_DRAW_BUFFER4_EXT 0x8829 +#define GL_DRAW_BUFFER5_EXT 0x882A +#define GL_DRAW_BUFFER6_EXT 0x882B +#define GL_DRAW_BUFFER7_EXT 0x882C +#define GL_DRAW_BUFFER8_EXT 0x882D +#define GL_DRAW_BUFFER9_EXT 0x882E +#define GL_DRAW_BUFFER10_EXT 0x882F +#define GL_DRAW_BUFFER11_EXT 0x8830 +#define GL_DRAW_BUFFER12_EXT 0x8831 +#define GL_DRAW_BUFFER13_EXT 0x8832 +#define GL_DRAW_BUFFER14_EXT 0x8833 +#define GL_DRAW_BUFFER15_EXT 0x8834 +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSEXTPROC) (GLsizei n, const GLenum *bufs); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawBuffersEXT (GLsizei n, const GLenum *bufs); +#endif +#endif /* GL_EXT_draw_buffers */ + +#ifndef GL_EXT_draw_buffers_indexed +#define GL_EXT_draw_buffers_indexed 1 +typedef void (GL_APIENTRYP PFNGLENABLEIEXTPROC) (GLenum target, GLuint index); +typedef void (GL_APIENTRYP PFNGLDISABLEIEXTPROC) (GLenum target, GLuint index); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONIEXTPROC) (GLuint buf, GLenum mode); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEIEXTPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCIEXTPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEIEXTPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (GL_APIENTRYP PFNGLCOLORMASKIEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef GLboolean (GL_APIENTRYP PFNGLISENABLEDIEXTPROC) (GLenum target, GLuint index); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glEnableiEXT (GLenum target, GLuint index); +GL_APICALL void GL_APIENTRY glDisableiEXT (GLenum target, GLuint index); +GL_APICALL void GL_APIENTRY glBlendEquationiEXT (GLuint buf, GLenum mode); +GL_APICALL void GL_APIENTRY glBlendEquationSeparateiEXT (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GL_APICALL void GL_APIENTRY glBlendFunciEXT (GLuint buf, GLenum src, GLenum dst); +GL_APICALL void GL_APIENTRY glBlendFuncSeparateiEXT (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GL_APICALL void GL_APIENTRY glColorMaskiEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GL_APICALL GLboolean GL_APIENTRY glIsEnablediEXT (GLenum target, GLuint index); +#endif +#endif /* GL_EXT_draw_buffers_indexed */ + +#ifndef GL_EXT_draw_elements_base_vertex +#define GL_EXT_draw_elements_base_vertex 1 +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (GL_APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawElementsBaseVertexEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GL_APICALL void GL_APIENTRY glDrawRangeElementsBaseVertexEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedBaseVertexEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +#endif +#endif /* GL_EXT_draw_elements_base_vertex */ + +#ifndef GL_EXT_draw_instanced +#define GL_EXT_draw_instanced 1 +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#endif +#endif /* GL_EXT_draw_instanced */ + +#ifndef GL_EXT_draw_transform_feedback +#define GL_EXT_draw_transform_feedback 1 +typedef void (GL_APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKEXTPROC) (GLenum mode, GLuint id); +typedef void (GL_APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDEXTPROC) (GLenum mode, GLuint id, GLsizei instancecount); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawTransformFeedbackEXT (GLenum mode, GLuint id); +GL_APICALL void GL_APIENTRY glDrawTransformFeedbackInstancedEXT (GLenum mode, GLuint id, GLsizei instancecount); +#endif +#endif /* GL_EXT_draw_transform_feedback */ + +#ifndef GL_EXT_external_buffer +#define GL_EXT_external_buffer 1 +typedef void *GLeglClientBufferEXT; +typedef void (GL_APIENTRYP PFNGLBUFFERSTORAGEEXTERNALEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +typedef void (GL_APIENTRYP PFNGLNAMEDBUFFERSTORAGEEXTERNALEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBufferStorageExternalEXT (GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +GL_APICALL void GL_APIENTRY glNamedBufferStorageExternalEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +#endif +#endif /* GL_EXT_external_buffer */ + +#ifndef GL_EXT_float_blend +#define GL_EXT_float_blend 1 +#endif /* GL_EXT_float_blend */ + +#ifndef GL_EXT_geometry_point_size +#define GL_EXT_geometry_point_size 1 +#endif /* GL_EXT_geometry_point_size */ + +#ifndef GL_EXT_geometry_shader +#define GL_EXT_geometry_shader 1 +#define GL_GEOMETRY_SHADER_EXT 0x8DD9 +#define GL_GEOMETRY_SHADER_BIT_EXT 0x00000004 +#define GL_GEOMETRY_LINKED_VERTICES_OUT_EXT 0x8916 +#define GL_GEOMETRY_LINKED_INPUT_TYPE_EXT 0x8917 +#define GL_GEOMETRY_LINKED_OUTPUT_TYPE_EXT 0x8918 +#define GL_GEOMETRY_SHADER_INVOCATIONS_EXT 0x887F +#define GL_LAYER_PROVOKING_VERTEX_EXT 0x825E +#define GL_LINES_ADJACENCY_EXT 0x000A +#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B +#define GL_TRIANGLES_ADJACENCY_EXT 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT 0x8A2C +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8A32 +#define GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT 0x9123 +#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_EXT 0x9124 +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 +#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS_EXT 0x8E5A +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 +#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT 0x92CF +#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT 0x92D5 +#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT 0x90CD +#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT 0x90D7 +#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D +#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E +#define GL_UNDEFINED_VERTEX_EXT 0x8260 +#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 +#define GL_FRAMEBUFFER_DEFAULT_LAYERS_EXT 0x9312 +#define GL_MAX_FRAMEBUFFER_LAYERS_EXT 0x9317 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 +#define GL_REFERENCED_BY_GEOMETRY_SHADER_EXT 0x9309 +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level); +#endif +#endif /* GL_EXT_geometry_shader */ + +#ifndef GL_EXT_gpu_shader5 +#define GL_EXT_gpu_shader5 1 +#endif /* GL_EXT_gpu_shader5 */ + +#ifndef GL_EXT_instanced_arrays +#define GL_EXT_instanced_arrays 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_EXT 0x88FE +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISOREXTPROC) (GLuint index, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glVertexAttribDivisorEXT (GLuint index, GLuint divisor); +#endif +#endif /* GL_EXT_instanced_arrays */ + +#ifndef GL_EXT_map_buffer_range +#define GL_EXT_map_buffer_range 1 +#define GL_MAP_READ_BIT_EXT 0x0001 +#define GL_MAP_WRITE_BIT_EXT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT_EXT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT_EXT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT_EXT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT_EXT 0x0020 +typedef void *(GL_APIENTRYP PFNGLMAPBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void *GL_APIENTRY glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GL_APICALL void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length); +#endif +#endif /* GL_EXT_map_buffer_range */ + +#ifndef GL_EXT_memory_object +#define GL_EXT_memory_object 1 +#define GL_TEXTURE_TILING_EXT 0x9580 +#define GL_DEDICATED_MEMORY_OBJECT_EXT 0x9581 +#define GL_PROTECTED_MEMORY_OBJECT_EXT 0x959B +#define GL_NUM_TILING_TYPES_EXT 0x9582 +#define GL_TILING_TYPES_EXT 0x9583 +#define GL_OPTIMAL_TILING_EXT 0x9584 +#define GL_LINEAR_TILING_EXT 0x9585 +#define GL_NUM_DEVICE_UUIDS_EXT 0x9596 +#define GL_DEVICE_UUID_EXT 0x9597 +#define GL_DRIVER_UUID_EXT 0x9598 +#define GL_UUID_SIZE_EXT 16 +typedef void (GL_APIENTRYP PFNGLGETUNSIGNEDBYTEVEXTPROC) (GLenum pname, GLubyte *data); +typedef void (GL_APIENTRYP PFNGLGETUNSIGNEDBYTEI_VEXTPROC) (GLenum target, GLuint index, GLubyte *data); +typedef void (GL_APIENTRYP PFNGLDELETEMEMORYOBJECTSEXTPROC) (GLsizei n, const GLuint *memoryObjects); +typedef GLboolean (GL_APIENTRYP PFNGLISMEMORYOBJECTEXTPROC) (GLuint memoryObject); +typedef void (GL_APIENTRYP PFNGLCREATEMEMORYOBJECTSEXTPROC) (GLsizei n, GLuint *memoryObjects); +typedef void (GL_APIENTRYP PFNGLMEMORYOBJECTPARAMETERIVEXTPROC) (GLuint memoryObject, GLenum pname, const GLint *params); +typedef void (GL_APIENTRYP PFNGLGETMEMORYOBJECTPARAMETERIVEXTPROC) (GLuint memoryObject, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGEMEM2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGEMEM2DMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGEMEM3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGEMEM3DMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLBUFFERSTORAGEMEMEXTPROC) (GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGEMEM2DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGEMEM2DMULTISAMPLEEXTPROC) (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGEMEM3DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGEMEM3DMULTISAMPLEEXTPROC) (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLNAMEDBUFFERSTORAGEMEMEXTPROC) (GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetUnsignedBytevEXT (GLenum pname, GLubyte *data); +GL_APICALL void GL_APIENTRY glGetUnsignedBytei_vEXT (GLenum target, GLuint index, GLubyte *data); +GL_APICALL void GL_APIENTRY glDeleteMemoryObjectsEXT (GLsizei n, const GLuint *memoryObjects); +GL_APICALL GLboolean GL_APIENTRY glIsMemoryObjectEXT (GLuint memoryObject); +GL_APICALL void GL_APIENTRY glCreateMemoryObjectsEXT (GLsizei n, GLuint *memoryObjects); +GL_APICALL void GL_APIENTRY glMemoryObjectParameterivEXT (GLuint memoryObject, GLenum pname, const GLint *params); +GL_APICALL void GL_APIENTRY glGetMemoryObjectParameterivEXT (GLuint memoryObject, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glTexStorageMem2DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTexStorageMem2DMultisampleEXT (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTexStorageMem3DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTexStorageMem3DMultisampleEXT (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glBufferStorageMemEXT (GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTextureStorageMem2DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTextureStorageMem2DMultisampleEXT (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTextureStorageMem3DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTextureStorageMem3DMultisampleEXT (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glNamedBufferStorageMemEXT (GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset); +#endif +#endif /* GL_EXT_memory_object */ + +#ifndef GL_EXT_memory_object_fd +#define GL_EXT_memory_object_fd 1 +#define GL_HANDLE_TYPE_OPAQUE_FD_EXT 0x9586 +typedef void (GL_APIENTRYP PFNGLIMPORTMEMORYFDEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, GLint fd); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glImportMemoryFdEXT (GLuint memory, GLuint64 size, GLenum handleType, GLint fd); +#endif +#endif /* GL_EXT_memory_object_fd */ + +#ifndef GL_EXT_memory_object_win32 +#define GL_EXT_memory_object_win32 1 +#define GL_HANDLE_TYPE_OPAQUE_WIN32_EXT 0x9587 +#define GL_HANDLE_TYPE_OPAQUE_WIN32_KMT_EXT 0x9588 +#define GL_DEVICE_LUID_EXT 0x9599 +#define GL_DEVICE_NODE_MASK_EXT 0x959A +#define GL_LUID_SIZE_EXT 8 +#define GL_HANDLE_TYPE_D3D12_TILEPOOL_EXT 0x9589 +#define GL_HANDLE_TYPE_D3D12_RESOURCE_EXT 0x958A +#define GL_HANDLE_TYPE_D3D11_IMAGE_EXT 0x958B +#define GL_HANDLE_TYPE_D3D11_IMAGE_KMT_EXT 0x958C +typedef void (GL_APIENTRYP PFNGLIMPORTMEMORYWIN32HANDLEEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, void *handle); +typedef void (GL_APIENTRYP PFNGLIMPORTMEMORYWIN32NAMEEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, const void *name); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glImportMemoryWin32HandleEXT (GLuint memory, GLuint64 size, GLenum handleType, void *handle); +GL_APICALL void GL_APIENTRY glImportMemoryWin32NameEXT (GLuint memory, GLuint64 size, GLenum handleType, const void *name); +#endif +#endif /* GL_EXT_memory_object_win32 */ + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GL_APICALL void GL_APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); +#endif +#endif /* GL_EXT_multi_draw_arrays */ + +#ifndef GL_EXT_multi_draw_indirect +#define GL_EXT_multi_draw_indirect 1 +typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTEXTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTEXTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glMultiDrawArraysIndirectEXT (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +GL_APICALL void GL_APIENTRY glMultiDrawElementsIndirectEXT (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +#endif +#endif /* GL_EXT_multi_draw_indirect */ + +#ifndef GL_EXT_multisampled_compatibility +#define GL_EXT_multisampled_compatibility 1 +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#endif /* GL_EXT_multisampled_compatibility */ + +#ifndef GL_EXT_multisampled_render_to_texture +#define GL_EXT_multisampled_render_to_texture 1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); +#endif +#endif /* GL_EXT_multisampled_render_to_texture */ + +#ifndef GL_EXT_multiview_draw_buffers +#define GL_EXT_multiview_draw_buffers 1 +#define GL_COLOR_ATTACHMENT_EXT 0x90F0 +#define GL_MULTIVIEW_EXT 0x90F1 +#define GL_DRAW_BUFFER_EXT 0x0C01 +#define GL_READ_BUFFER_EXT 0x0C02 +#define GL_MAX_MULTIVIEW_BUFFERS_EXT 0x90F2 +typedef void (GL_APIENTRYP PFNGLREADBUFFERINDEXEDEXTPROC) (GLenum src, GLint index); +typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSINDEXEDEXTPROC) (GLint n, const GLenum *location, const GLint *indices); +typedef void (GL_APIENTRYP PFNGLGETINTEGERI_VEXTPROC) (GLenum target, GLuint index, GLint *data); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glReadBufferIndexedEXT (GLenum src, GLint index); +GL_APICALL void GL_APIENTRY glDrawBuffersIndexedEXT (GLint n, const GLenum *location, const GLint *indices); +GL_APICALL void GL_APIENTRY glGetIntegeri_vEXT (GLenum target, GLuint index, GLint *data); +#endif +#endif /* GL_EXT_multiview_draw_buffers */ + +#ifndef GL_EXT_multiview_tessellation_geometry_shader +#define GL_EXT_multiview_tessellation_geometry_shader 1 +#endif /* GL_EXT_multiview_tessellation_geometry_shader */ + +#ifndef GL_EXT_multiview_texture_multisample +#define GL_EXT_multiview_texture_multisample 1 +#endif /* GL_EXT_multiview_texture_multisample */ + +#ifndef GL_EXT_multiview_timer_query +#define GL_EXT_multiview_timer_query 1 +#endif /* GL_EXT_multiview_timer_query */ + +#ifndef GL_EXT_occlusion_query_boolean +#define GL_EXT_occlusion_query_boolean 1 +#define GL_ANY_SAMPLES_PASSED_EXT 0x8C2F +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT 0x8D6A +#endif /* GL_EXT_occlusion_query_boolean */ + +#ifndef GL_EXT_polygon_offset_clamp +#define GL_EXT_polygon_offset_clamp 1 +#define GL_POLYGON_OFFSET_CLAMP_EXT 0x8E1B +typedef void (GL_APIENTRYP PFNGLPOLYGONOFFSETCLAMPEXTPROC) (GLfloat factor, GLfloat units, GLfloat clamp); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glPolygonOffsetClampEXT (GLfloat factor, GLfloat units, GLfloat clamp); +#endif +#endif /* GL_EXT_polygon_offset_clamp */ + +#ifndef GL_EXT_post_depth_coverage +#define GL_EXT_post_depth_coverage 1 +#endif /* GL_EXT_post_depth_coverage */ + +#ifndef GL_EXT_primitive_bounding_box +#define GL_EXT_primitive_bounding_box 1 +#define GL_PRIMITIVE_BOUNDING_BOX_EXT 0x92BE +typedef void (GL_APIENTRYP PFNGLPRIMITIVEBOUNDINGBOXEXTPROC) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glPrimitiveBoundingBoxEXT (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#endif +#endif /* GL_EXT_primitive_bounding_box */ + +#ifndef GL_EXT_protected_textures +#define GL_EXT_protected_textures 1 +#define GL_CONTEXT_FLAG_PROTECTED_CONTENT_BIT_EXT 0x00000010 +#define GL_TEXTURE_PROTECTED_EXT 0x8BFA +#endif /* GL_EXT_protected_textures */ + +#ifndef GL_EXT_pvrtc_sRGB +#define GL_EXT_pvrtc_sRGB 1 +#define GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT 0x8A54 +#define GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT 0x8A55 +#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT 0x8A56 +#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT 0x8A57 +#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG 0x93F0 +#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG 0x93F1 +#endif /* GL_EXT_pvrtc_sRGB */ + +#ifndef GL_EXT_raster_multisample +#define GL_EXT_raster_multisample 1 +#define GL_RASTER_MULTISAMPLE_EXT 0x9327 +#define GL_RASTER_SAMPLES_EXT 0x9328 +#define GL_MAX_RASTER_SAMPLES_EXT 0x9329 +#define GL_RASTER_FIXED_SAMPLE_LOCATIONS_EXT 0x932A +#define GL_MULTISAMPLE_RASTERIZATION_ALLOWED_EXT 0x932B +#define GL_EFFECTIVE_RASTER_SAMPLES_EXT 0x932C +typedef void (GL_APIENTRYP PFNGLRASTERSAMPLESEXTPROC) (GLuint samples, GLboolean fixedsamplelocations); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRasterSamplesEXT (GLuint samples, GLboolean fixedsamplelocations); +#endif +#endif /* GL_EXT_raster_multisample */ + +#ifndef GL_EXT_read_format_bgra +#define GL_EXT_read_format_bgra 1 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT 0x8366 +#endif /* GL_EXT_read_format_bgra */ + +#ifndef GL_EXT_render_snorm +#define GL_EXT_render_snorm 1 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_R16_SNORM_EXT 0x8F98 +#define GL_RG16_SNORM_EXT 0x8F99 +#define GL_RGBA16_SNORM_EXT 0x8F9B +#endif /* GL_EXT_render_snorm */ + +#ifndef GL_EXT_robustness +#define GL_EXT_robustness 1 +#define GL_GUILTY_CONTEXT_RESET_EXT 0x8253 +#define GL_INNOCENT_CONTEXT_RESET_EXT 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET_EXT 0x8255 +#define GL_CONTEXT_ROBUST_ACCESS_EXT 0x90F3 +#define GL_RESET_NOTIFICATION_STRATEGY_EXT 0x8256 +#define GL_LOSE_CONTEXT_ON_RESET_EXT 0x8252 +#define GL_NO_RESET_NOTIFICATION_EXT 0x8261 +typedef GLenum (GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSEXTPROC) (void); +typedef void (GL_APIENTRYP PFNGLREADNPIXELSEXTPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +typedef void (GL_APIENTRYP PFNGLGETNUNIFORMFVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETNUNIFORMIVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL GLenum GL_APIENTRY glGetGraphicsResetStatusEXT (void); +GL_APICALL void GL_APIENTRY glReadnPixelsEXT (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +GL_APICALL void GL_APIENTRY glGetnUniformfvEXT (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetnUniformivEXT (GLuint program, GLint location, GLsizei bufSize, GLint *params); +#endif +#endif /* GL_EXT_robustness */ + +#ifndef GL_EXT_sRGB +#define GL_EXT_sRGB 1 +#define GL_SRGB_EXT 0x8C40 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT 0x8210 +#endif /* GL_EXT_sRGB */ + +#ifndef GL_EXT_sRGB_write_control +#define GL_EXT_sRGB_write_control 1 +#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 +#endif /* GL_EXT_sRGB_write_control */ + +#ifndef GL_EXT_semaphore +#define GL_EXT_semaphore 1 +#define GL_LAYOUT_GENERAL_EXT 0x958D +#define GL_LAYOUT_COLOR_ATTACHMENT_EXT 0x958E +#define GL_LAYOUT_DEPTH_STENCIL_ATTACHMENT_EXT 0x958F +#define GL_LAYOUT_DEPTH_STENCIL_READ_ONLY_EXT 0x9590 +#define GL_LAYOUT_SHADER_READ_ONLY_EXT 0x9591 +#define GL_LAYOUT_TRANSFER_SRC_EXT 0x9592 +#define GL_LAYOUT_TRANSFER_DST_EXT 0x9593 +#define GL_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_EXT 0x9530 +#define GL_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_EXT 0x9531 +typedef void (GL_APIENTRYP PFNGLGENSEMAPHORESEXTPROC) (GLsizei n, GLuint *semaphores); +typedef void (GL_APIENTRYP PFNGLDELETESEMAPHORESEXTPROC) (GLsizei n, const GLuint *semaphores); +typedef GLboolean (GL_APIENTRYP PFNGLISSEMAPHOREEXTPROC) (GLuint semaphore); +typedef void (GL_APIENTRYP PFNGLSEMAPHOREPARAMETERUI64VEXTPROC) (GLuint semaphore, GLenum pname, const GLuint64 *params); +typedef void (GL_APIENTRYP PFNGLGETSEMAPHOREPARAMETERUI64VEXTPROC) (GLuint semaphore, GLenum pname, GLuint64 *params); +typedef void (GL_APIENTRYP PFNGLWAITSEMAPHOREEXTPROC) (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *srcLayouts); +typedef void (GL_APIENTRYP PFNGLSIGNALSEMAPHOREEXTPROC) (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *dstLayouts); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGenSemaphoresEXT (GLsizei n, GLuint *semaphores); +GL_APICALL void GL_APIENTRY glDeleteSemaphoresEXT (GLsizei n, const GLuint *semaphores); +GL_APICALL GLboolean GL_APIENTRY glIsSemaphoreEXT (GLuint semaphore); +GL_APICALL void GL_APIENTRY glSemaphoreParameterui64vEXT (GLuint semaphore, GLenum pname, const GLuint64 *params); +GL_APICALL void GL_APIENTRY glGetSemaphoreParameterui64vEXT (GLuint semaphore, GLenum pname, GLuint64 *params); +GL_APICALL void GL_APIENTRY glWaitSemaphoreEXT (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *srcLayouts); +GL_APICALL void GL_APIENTRY glSignalSemaphoreEXT (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *dstLayouts); +#endif +#endif /* GL_EXT_semaphore */ + +#ifndef GL_EXT_semaphore_fd +#define GL_EXT_semaphore_fd 1 +typedef void (GL_APIENTRYP PFNGLIMPORTSEMAPHOREFDEXTPROC) (GLuint semaphore, GLenum handleType, GLint fd); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glImportSemaphoreFdEXT (GLuint semaphore, GLenum handleType, GLint fd); +#endif +#endif /* GL_EXT_semaphore_fd */ + +#ifndef GL_EXT_semaphore_win32 +#define GL_EXT_semaphore_win32 1 +#define GL_HANDLE_TYPE_D3D12_FENCE_EXT 0x9594 +#define GL_D3D12_FENCE_VALUE_EXT 0x9595 +typedef void (GL_APIENTRYP PFNGLIMPORTSEMAPHOREWIN32HANDLEEXTPROC) (GLuint semaphore, GLenum handleType, void *handle); +typedef void (GL_APIENTRYP PFNGLIMPORTSEMAPHOREWIN32NAMEEXTPROC) (GLuint semaphore, GLenum handleType, const void *name); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glImportSemaphoreWin32HandleEXT (GLuint semaphore, GLenum handleType, void *handle); +GL_APICALL void GL_APIENTRY glImportSemaphoreWin32NameEXT (GLuint semaphore, GLenum handleType, const void *name); +#endif +#endif /* GL_EXT_semaphore_win32 */ + +#ifndef GL_EXT_separate_shader_objects +#define GL_EXT_separate_shader_objects 1 +#define GL_ACTIVE_PROGRAM_EXT 0x8259 +#define GL_VERTEX_SHADER_BIT_EXT 0x00000001 +#define GL_FRAGMENT_SHADER_BIT_EXT 0x00000002 +#define GL_ALL_SHADER_BITS_EXT 0xFFFFFFFF +#define GL_PROGRAM_SEPARABLE_EXT 0x8258 +#define GL_PROGRAM_PIPELINE_BINDING_EXT 0x825A +typedef void (GL_APIENTRYP PFNGLACTIVESHADERPROGRAMEXTPROC) (GLuint pipeline, GLuint program); +typedef void (GL_APIENTRYP PFNGLBINDPROGRAMPIPELINEEXTPROC) (GLuint pipeline); +typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROGRAMVEXTPROC) (GLenum type, GLsizei count, const GLchar **strings); +typedef void (GL_APIENTRYP PFNGLDELETEPROGRAMPIPELINESEXTPROC) (GLsizei n, const GLuint *pipelines); +typedef void (GL_APIENTRYP PFNGLGENPROGRAMPIPELINESEXTPROC) (GLsizei n, GLuint *pipelines); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEIVEXTPROC) (GLuint pipeline, GLenum pname, GLint *params); +typedef GLboolean (GL_APIENTRYP PFNGLISPROGRAMPIPELINEEXTPROC) (GLuint pipeline); +typedef void (GL_APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUSEPROGRAMSTAGESEXTPROC) (GLuint pipeline, GLbitfield stages, GLuint program); +typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEEXTPROC) (GLuint pipeline); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glActiveShaderProgramEXT (GLuint pipeline, GLuint program); +GL_APICALL void GL_APIENTRY glBindProgramPipelineEXT (GLuint pipeline); +GL_APICALL GLuint GL_APIENTRY glCreateShaderProgramvEXT (GLenum type, GLsizei count, const GLchar **strings); +GL_APICALL void GL_APIENTRY glDeleteProgramPipelinesEXT (GLsizei n, const GLuint *pipelines); +GL_APICALL void GL_APIENTRY glGenProgramPipelinesEXT (GLsizei n, GLuint *pipelines); +GL_APICALL void GL_APIENTRY glGetProgramPipelineInfoLogEXT (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GL_APICALL void GL_APIENTRY glGetProgramPipelineivEXT (GLuint pipeline, GLenum pname, GLint *params); +GL_APICALL GLboolean GL_APIENTRY glIsProgramPipelineEXT (GLuint pipeline); +GL_APICALL void GL_APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); +GL_APICALL void GL_APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0); +GL_APICALL void GL_APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0); +GL_APICALL void GL_APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GL_APICALL void GL_APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1); +GL_APICALL void GL_APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GL_APICALL void GL_APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GL_APICALL void GL_APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GL_APICALL void GL_APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GL_APICALL void GL_APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUseProgramStagesEXT (GLuint pipeline, GLbitfield stages, GLuint program); +GL_APICALL void GL_APIENTRY glValidateProgramPipelineEXT (GLuint pipeline); +GL_APICALL void GL_APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0); +GL_APICALL void GL_APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1); +GL_APICALL void GL_APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GL_APICALL void GL_APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GL_APICALL void GL_APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif +#endif /* GL_EXT_separate_shader_objects */ + +#ifndef GL_EXT_shader_framebuffer_fetch +#define GL_EXT_shader_framebuffer_fetch 1 +#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52 +#endif /* GL_EXT_shader_framebuffer_fetch */ + +#ifndef GL_EXT_shader_framebuffer_fetch_non_coherent +#define GL_EXT_shader_framebuffer_fetch_non_coherent 1 +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERFETCHBARRIEREXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferFetchBarrierEXT (void); +#endif +#endif /* GL_EXT_shader_framebuffer_fetch_non_coherent */ + +#ifndef GL_EXT_shader_group_vote +#define GL_EXT_shader_group_vote 1 +#endif /* GL_EXT_shader_group_vote */ + +#ifndef GL_EXT_shader_implicit_conversions +#define GL_EXT_shader_implicit_conversions 1 +#endif /* GL_EXT_shader_implicit_conversions */ + +#ifndef GL_EXT_shader_integer_mix +#define GL_EXT_shader_integer_mix 1 +#endif /* GL_EXT_shader_integer_mix */ + +#ifndef GL_EXT_shader_io_blocks +#define GL_EXT_shader_io_blocks 1 +#endif /* GL_EXT_shader_io_blocks */ + +#ifndef GL_EXT_shader_non_constant_global_initializers +#define GL_EXT_shader_non_constant_global_initializers 1 +#endif /* GL_EXT_shader_non_constant_global_initializers */ + +#ifndef GL_EXT_shader_pixel_local_storage +#define GL_EXT_shader_pixel_local_storage 1 +#define GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_FAST_SIZE_EXT 0x8F63 +#define GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_SIZE_EXT 0x8F67 +#define GL_SHADER_PIXEL_LOCAL_STORAGE_EXT 0x8F64 +#endif /* GL_EXT_shader_pixel_local_storage */ + +#ifndef GL_EXT_shader_pixel_local_storage2 +#define GL_EXT_shader_pixel_local_storage2 1 +#define GL_MAX_SHADER_COMBINED_LOCAL_STORAGE_FAST_SIZE_EXT 0x9650 +#define GL_MAX_SHADER_COMBINED_LOCAL_STORAGE_SIZE_EXT 0x9651 +#define GL_FRAMEBUFFER_INCOMPLETE_INSUFFICIENT_SHADER_COMBINED_LOCAL_STORAGE_EXT 0x9652 +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC) (GLuint target, GLsizei size); +typedef GLsizei (GL_APIENTRYP PFNGLGETFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC) (GLuint target); +typedef void (GL_APIENTRYP PFNGLCLEARPIXELLOCALSTORAGEUIEXTPROC) (GLsizei offset, GLsizei n, const GLuint *values); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferPixelLocalStorageSizeEXT (GLuint target, GLsizei size); +GL_APICALL GLsizei GL_APIENTRY glGetFramebufferPixelLocalStorageSizeEXT (GLuint target); +GL_APICALL void GL_APIENTRY glClearPixelLocalStorageuiEXT (GLsizei offset, GLsizei n, const GLuint *values); +#endif +#endif /* GL_EXT_shader_pixel_local_storage2 */ + +#ifndef GL_EXT_shader_texture_lod +#define GL_EXT_shader_texture_lod 1 +#endif /* GL_EXT_shader_texture_lod */ + +#ifndef GL_EXT_shadow_samplers +#define GL_EXT_shadow_samplers 1 +#define GL_TEXTURE_COMPARE_MODE_EXT 0x884C +#define GL_TEXTURE_COMPARE_FUNC_EXT 0x884D +#define GL_COMPARE_REF_TO_TEXTURE_EXT 0x884E +#define GL_SAMPLER_2D_SHADOW_EXT 0x8B62 +#endif /* GL_EXT_shadow_samplers */ + +#ifndef GL_EXT_sparse_texture +#define GL_EXT_sparse_texture 1 +#define GL_TEXTURE_SPARSE_EXT 0x91A6 +#define GL_VIRTUAL_PAGE_SIZE_INDEX_EXT 0x91A7 +#define GL_NUM_SPARSE_LEVELS_EXT 0x91AA +#define GL_NUM_VIRTUAL_PAGE_SIZES_EXT 0x91A8 +#define GL_VIRTUAL_PAGE_SIZE_X_EXT 0x9195 +#define GL_VIRTUAL_PAGE_SIZE_Y_EXT 0x9196 +#define GL_VIRTUAL_PAGE_SIZE_Z_EXT 0x9197 +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_TEXTURE_3D 0x806F +#define GL_MAX_SPARSE_TEXTURE_SIZE_EXT 0x9198 +#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_EXT 0x9199 +#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_EXT 0x919A +#define GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_EXT 0x91A9 +typedef void (GL_APIENTRYP PFNGLTEXPAGECOMMITMENTEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexPageCommitmentEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); +#endif +#endif /* GL_EXT_sparse_texture */ + +#ifndef GL_EXT_sparse_texture2 +#define GL_EXT_sparse_texture2 1 +#endif /* GL_EXT_sparse_texture2 */ + +#ifndef GL_EXT_tessellation_point_size +#define GL_EXT_tessellation_point_size 1 +#endif /* GL_EXT_tessellation_point_size */ + +#ifndef GL_EXT_tessellation_shader +#define GL_EXT_tessellation_shader 1 +#define GL_PATCHES_EXT 0x000E +#define GL_PATCH_VERTICES_EXT 0x8E72 +#define GL_TESS_CONTROL_OUTPUT_VERTICES_EXT 0x8E75 +#define GL_TESS_GEN_MODE_EXT 0x8E76 +#define GL_TESS_GEN_SPACING_EXT 0x8E77 +#define GL_TESS_GEN_VERTEX_ORDER_EXT 0x8E78 +#define GL_TESS_GEN_POINT_MODE_EXT 0x8E79 +#define GL_ISOLINES_EXT 0x8E7A +#define GL_QUADS_EXT 0x0007 +#define GL_FRACTIONAL_ODD_EXT 0x8E7B +#define GL_FRACTIONAL_EVEN_EXT 0x8E7C +#define GL_MAX_PATCH_VERTICES_EXT 0x8E7D +#define GL_MAX_TESS_GEN_LEVEL_EXT 0x8E7E +#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS_EXT 0x8E7F +#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT 0x8E80 +#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS_EXT 0x8E81 +#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS_EXT 0x8E82 +#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS_EXT 0x8E83 +#define GL_MAX_TESS_PATCH_COMPONENTS_EXT 0x8E84 +#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_EXT 0x8E85 +#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS_EXT 0x8E86 +#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS_EXT 0x8E89 +#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS_EXT 0x8E8A +#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS_EXT 0x886C +#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS_EXT 0x886D +#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS_EXT 0x8E1E +#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT 0x8E1F +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS_EXT 0x92CD +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS_EXT 0x92CE +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS_EXT 0x92D3 +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS_EXT 0x92D4 +#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS_EXT 0x90CB +#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS_EXT 0x90CC +#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_EXT 0x90D8 +#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_EXT 0x90D9 +#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221 +#define GL_IS_PER_PATCH_EXT 0x92E7 +#define GL_REFERENCED_BY_TESS_CONTROL_SHADER_EXT 0x9307 +#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER_EXT 0x9308 +#define GL_TESS_CONTROL_SHADER_EXT 0x8E88 +#define GL_TESS_EVALUATION_SHADER_EXT 0x8E87 +#define GL_TESS_CONTROL_SHADER_BIT_EXT 0x00000008 +#define GL_TESS_EVALUATION_SHADER_BIT_EXT 0x00000010 +typedef void (GL_APIENTRYP PFNGLPATCHPARAMETERIEXTPROC) (GLenum pname, GLint value); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glPatchParameteriEXT (GLenum pname, GLint value); +#endif +#endif /* GL_EXT_tessellation_shader */ + +#ifndef GL_EXT_texture_border_clamp +#define GL_EXT_texture_border_clamp 1 +#define GL_TEXTURE_BORDER_COLOR_EXT 0x1004 +#define GL_CLAMP_TO_BORDER_EXT 0x812D +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIIVEXTPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIUIVEXTPROC) (GLuint sampler, GLenum pname, const GLuint *param); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIIVEXTPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVEXTPROC) (GLuint sampler, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params); +GL_APICALL void GL_APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params); +GL_APICALL void GL_APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params); +GL_APICALL void GL_APIENTRY glSamplerParameterIivEXT (GLuint sampler, GLenum pname, const GLint *param); +GL_APICALL void GL_APIENTRY glSamplerParameterIuivEXT (GLuint sampler, GLenum pname, const GLuint *param); +GL_APICALL void GL_APIENTRY glGetSamplerParameterIivEXT (GLuint sampler, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetSamplerParameterIuivEXT (GLuint sampler, GLenum pname, GLuint *params); +#endif +#endif /* GL_EXT_texture_border_clamp */ + +#ifndef GL_EXT_texture_buffer +#define GL_EXT_texture_buffer 1 +#define GL_TEXTURE_BUFFER_EXT 0x8C2A +#define GL_TEXTURE_BUFFER_BINDING_EXT 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D +#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT_EXT 0x919F +#define GL_SAMPLER_BUFFER_EXT 0x8DC2 +#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 +#define GL_IMAGE_BUFFER_EXT 0x9051 +#define GL_INT_IMAGE_BUFFER_EXT 0x905C +#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 +#define GL_TEXTURE_BUFFER_OFFSET_EXT 0x919D +#define GL_TEXTURE_BUFFER_SIZE_EXT 0x919E +typedef void (GL_APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); +typedef void (GL_APIENTRYP PFNGLTEXBUFFERRANGEEXTPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer); +GL_APICALL void GL_APIENTRY glTexBufferRangeEXT (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +#endif +#endif /* GL_EXT_texture_buffer */ + +#ifndef GL_EXT_texture_compression_astc_decode_mode +#define GL_EXT_texture_compression_astc_decode_mode 1 +#define GL_TEXTURE_ASTC_DECODE_PRECISION_EXT 0x8F69 +#endif /* GL_EXT_texture_compression_astc_decode_mode */ + +#ifndef GL_EXT_texture_compression_bptc +#define GL_EXT_texture_compression_bptc 1 +#define GL_COMPRESSED_RGBA_BPTC_UNORM_EXT 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT 0x8E8F +#endif /* GL_EXT_texture_compression_bptc */ + +#ifndef GL_EXT_texture_compression_dxt1 +#define GL_EXT_texture_compression_dxt1 1 +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#endif /* GL_EXT_texture_compression_dxt1 */ + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_EXT_texture_compression_rgtc 1 +#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC +#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD +#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE +#endif /* GL_EXT_texture_compression_rgtc */ + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_EXT_texture_compression_s3tc 1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif /* GL_EXT_texture_compression_s3tc */ + +#ifndef GL_EXT_texture_compression_s3tc_srgb +#define GL_EXT_texture_compression_s3tc_srgb 1 +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#endif /* GL_EXT_texture_compression_s3tc_srgb */ + +#ifndef GL_EXT_texture_cube_map_array +#define GL_EXT_texture_cube_map_array 1 +#define GL_TEXTURE_CUBE_MAP_ARRAY_EXT 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_EXT 0x900A +#define GL_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_EXT 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900F +#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 +#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A +#endif /* GL_EXT_texture_cube_map_array */ + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif /* GL_EXT_texture_filter_anisotropic */ + +#ifndef GL_EXT_texture_filter_minmax +#define GL_EXT_texture_filter_minmax 1 +#define GL_TEXTURE_REDUCTION_MODE_EXT 0x9366 +#define GL_WEIGHTED_AVERAGE_EXT 0x9367 +#endif /* GL_EXT_texture_filter_minmax */ + +#ifndef GL_EXT_texture_format_BGRA8888 +#define GL_EXT_texture_format_BGRA8888 1 +#endif /* GL_EXT_texture_format_BGRA8888 */ + +#ifndef GL_EXT_texture_format_sRGB_override +#define GL_EXT_texture_format_sRGB_override 1 +#define GL_TEXTURE_FORMAT_SRGB_OVERRIDE_EXT 0x8FBF +#endif /* GL_EXT_texture_format_sRGB_override */ + +#ifndef GL_EXT_texture_mirror_clamp_to_edge +#define GL_EXT_texture_mirror_clamp_to_edge 1 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#endif /* GL_EXT_texture_mirror_clamp_to_edge */ + +#ifndef GL_EXT_texture_norm16 +#define GL_EXT_texture_norm16 1 +#define GL_R16_EXT 0x822A +#define GL_RG16_EXT 0x822C +#define GL_RGBA16_EXT 0x805B +#define GL_RGB16_EXT 0x8054 +#define GL_RGB16_SNORM_EXT 0x8F9A +#endif /* GL_EXT_texture_norm16 */ + +#ifndef GL_EXT_texture_query_lod +#define GL_EXT_texture_query_lod 1 +#endif /* GL_EXT_texture_query_lod */ + +#ifndef GL_EXT_texture_rg +#define GL_EXT_texture_rg 1 +#define GL_RED_EXT 0x1903 +#define GL_RG_EXT 0x8227 +#define GL_R8_EXT 0x8229 +#define GL_RG8_EXT 0x822B +#endif /* GL_EXT_texture_rg */ + +#ifndef GL_EXT_texture_sRGB_R8 +#define GL_EXT_texture_sRGB_R8 1 +#define GL_SR8_EXT 0x8FBD +#endif /* GL_EXT_texture_sRGB_R8 */ + +#ifndef GL_EXT_texture_sRGB_RG8 +#define GL_EXT_texture_sRGB_RG8 1 +#define GL_SRG8_EXT 0x8FBE +#endif /* GL_EXT_texture_sRGB_RG8 */ + +#ifndef GL_EXT_texture_sRGB_decode +#define GL_EXT_texture_sRGB_decode 1 +#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 +#define GL_DECODE_EXT 0x8A49 +#define GL_SKIP_DECODE_EXT 0x8A4A +#endif /* GL_EXT_texture_sRGB_decode */ + +#ifndef GL_EXT_texture_shadow_lod +#define GL_EXT_texture_shadow_lod 1 +#endif /* GL_EXT_texture_shadow_lod */ + +#ifndef GL_EXT_texture_storage +#define GL_EXT_texture_storage 1 +#define GL_TEXTURE_IMMUTABLE_FORMAT_EXT 0x912F +#define GL_ALPHA8_EXT 0x803C +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_RGBA32F_EXT 0x8814 +#define GL_RGB32F_EXT 0x8815 +#define GL_ALPHA32F_EXT 0x8816 +#define GL_LUMINANCE32F_EXT 0x8818 +#define GL_LUMINANCE_ALPHA32F_EXT 0x8819 +#define GL_ALPHA16F_EXT 0x881C +#define GL_LUMINANCE16F_EXT 0x881E +#define GL_LUMINANCE_ALPHA16F_EXT 0x881F +#define GL_R32F_EXT 0x822E +#define GL_RG32F_EXT 0x8230 +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexStorage1DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GL_APICALL void GL_APIENTRY glTexStorage2DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glTexStorage3DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GL_APICALL void GL_APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GL_APICALL void GL_APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#endif +#endif /* GL_EXT_texture_storage */ + +#ifndef GL_EXT_texture_type_2_10_10_10_REV +#define GL_EXT_texture_type_2_10_10_10_REV 1 +#define GL_UNSIGNED_INT_2_10_10_10_REV_EXT 0x8368 +#endif /* GL_EXT_texture_type_2_10_10_10_REV */ + +#ifndef GL_EXT_texture_view +#define GL_EXT_texture_view 1 +#define GL_TEXTURE_VIEW_MIN_LEVEL_EXT 0x82DB +#define GL_TEXTURE_VIEW_NUM_LEVELS_EXT 0x82DC +#define GL_TEXTURE_VIEW_MIN_LAYER_EXT 0x82DD +#define GL_TEXTURE_VIEW_NUM_LAYERS_EXT 0x82DE +typedef void (GL_APIENTRYP PFNGLTEXTUREVIEWEXTPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTextureViewEXT (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +#endif +#endif /* GL_EXT_texture_view */ + +#ifndef GL_EXT_unpack_subimage +#define GL_EXT_unpack_subimage 1 +#define GL_UNPACK_ROW_LENGTH_EXT 0x0CF2 +#define GL_UNPACK_SKIP_ROWS_EXT 0x0CF3 +#define GL_UNPACK_SKIP_PIXELS_EXT 0x0CF4 +#endif /* GL_EXT_unpack_subimage */ + +#ifndef GL_EXT_win32_keyed_mutex +#define GL_EXT_win32_keyed_mutex 1 +typedef GLboolean (GL_APIENTRYP PFNGLACQUIREKEYEDMUTEXWIN32EXTPROC) (GLuint memory, GLuint64 key, GLuint timeout); +typedef GLboolean (GL_APIENTRYP PFNGLRELEASEKEYEDMUTEXWIN32EXTPROC) (GLuint memory, GLuint64 key); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL GLboolean GL_APIENTRY glAcquireKeyedMutexWin32EXT (GLuint memory, GLuint64 key, GLuint timeout); +GL_APICALL GLboolean GL_APIENTRY glReleaseKeyedMutexWin32EXT (GLuint memory, GLuint64 key); +#endif +#endif /* GL_EXT_win32_keyed_mutex */ + +#ifndef GL_EXT_window_rectangles +#define GL_EXT_window_rectangles 1 +#define GL_INCLUSIVE_EXT 0x8F10 +#define GL_EXCLUSIVE_EXT 0x8F11 +#define GL_WINDOW_RECTANGLE_EXT 0x8F12 +#define GL_WINDOW_RECTANGLE_MODE_EXT 0x8F13 +#define GL_MAX_WINDOW_RECTANGLES_EXT 0x8F14 +#define GL_NUM_WINDOW_RECTANGLES_EXT 0x8F15 +typedef void (GL_APIENTRYP PFNGLWINDOWRECTANGLESEXTPROC) (GLenum mode, GLsizei count, const GLint *box); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glWindowRectanglesEXT (GLenum mode, GLsizei count, const GLint *box); +#endif +#endif /* GL_EXT_window_rectangles */ + +#ifndef GL_FJ_shader_binary_GCCSO +#define GL_FJ_shader_binary_GCCSO 1 +#define GL_GCCSO_SHADER_BINARY_FJ 0x9260 +#endif /* GL_FJ_shader_binary_GCCSO */ + +#ifndef GL_IMG_bindless_texture +#define GL_IMG_bindless_texture 1 +typedef GLuint64 (GL_APIENTRYP PFNGLGETTEXTUREHANDLEIMGPROC) (GLuint texture); +typedef GLuint64 (GL_APIENTRYP PFNGLGETTEXTURESAMPLERHANDLEIMGPROC) (GLuint texture, GLuint sampler); +typedef void (GL_APIENTRYP PFNGLUNIFORMHANDLEUI64IMGPROC) (GLint location, GLuint64 value); +typedef void (GL_APIENTRYP PFNGLUNIFORMHANDLEUI64VIMGPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64IMGPROC) (GLuint program, GLint location, GLuint64 value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VIMGPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL GLuint64 GL_APIENTRY glGetTextureHandleIMG (GLuint texture); +GL_APICALL GLuint64 GL_APIENTRY glGetTextureSamplerHandleIMG (GLuint texture, GLuint sampler); +GL_APICALL void GL_APIENTRY glUniformHandleui64IMG (GLint location, GLuint64 value); +GL_APICALL void GL_APIENTRY glUniformHandleui64vIMG (GLint location, GLsizei count, const GLuint64 *value); +GL_APICALL void GL_APIENTRY glProgramUniformHandleui64IMG (GLuint program, GLint location, GLuint64 value); +GL_APICALL void GL_APIENTRY glProgramUniformHandleui64vIMG (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +#endif +#endif /* GL_IMG_bindless_texture */ + +#ifndef GL_IMG_framebuffer_downsample +#define GL_IMG_framebuffer_downsample 1 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_AND_DOWNSAMPLE_IMG 0x913C +#define GL_NUM_DOWNSAMPLE_SCALES_IMG 0x913D +#define GL_DOWNSAMPLE_SCALES_IMG 0x913E +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SCALE_IMG 0x913F +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DDOWNSAMPLEIMGPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint xscale, GLint yscale); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERDOWNSAMPLEIMGPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer, GLint xscale, GLint yscale); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferTexture2DDownsampleIMG (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint xscale, GLint yscale); +GL_APICALL void GL_APIENTRY glFramebufferTextureLayerDownsampleIMG (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer, GLint xscale, GLint yscale); +#endif +#endif /* GL_IMG_framebuffer_downsample */ + +#ifndef GL_IMG_multisampled_render_to_texture +#define GL_IMG_multisampled_render_to_texture 1 +#define GL_RENDERBUFFER_SAMPLES_IMG 0x9133 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG 0x9134 +#define GL_MAX_SAMPLES_IMG 0x9135 +#define GL_TEXTURE_SAMPLES_IMG 0x9136 +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMGPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMGPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); +#endif +#endif /* GL_IMG_multisampled_render_to_texture */ + +#ifndef GL_IMG_program_binary +#define GL_IMG_program_binary 1 +#define GL_SGX_PROGRAM_BINARY_IMG 0x9130 +#endif /* GL_IMG_program_binary */ + +#ifndef GL_IMG_read_format +#define GL_IMG_read_format 1 +#define GL_BGRA_IMG 0x80E1 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG 0x8365 +#endif /* GL_IMG_read_format */ + +#ifndef GL_IMG_shader_binary +#define GL_IMG_shader_binary 1 +#define GL_SGX_BINARY_IMG 0x8C0A +#endif /* GL_IMG_shader_binary */ + +#ifndef GL_IMG_texture_compression_pvrtc +#define GL_IMG_texture_compression_pvrtc 1 +#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 +#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 +#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 +#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 +#endif /* GL_IMG_texture_compression_pvrtc */ + +#ifndef GL_IMG_texture_compression_pvrtc2 +#define GL_IMG_texture_compression_pvrtc2 1 +#define GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG 0x9137 +#define GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG 0x9138 +#endif /* GL_IMG_texture_compression_pvrtc2 */ + +#ifndef GL_IMG_texture_filter_cubic +#define GL_IMG_texture_filter_cubic 1 +#define GL_CUBIC_IMG 0x9139 +#define GL_CUBIC_MIPMAP_NEAREST_IMG 0x913A +#define GL_CUBIC_MIPMAP_LINEAR_IMG 0x913B +#endif /* GL_IMG_texture_filter_cubic */ + +#ifndef GL_INTEL_blackhole_render +#define GL_INTEL_blackhole_render 1 +#define GL_BLACKHOLE_RENDER_INTEL 0x83FC +#endif /* GL_INTEL_blackhole_render */ + +#ifndef GL_INTEL_conservative_rasterization +#define GL_INTEL_conservative_rasterization 1 +#define GL_CONSERVATIVE_RASTERIZATION_INTEL 0x83FE +#endif /* GL_INTEL_conservative_rasterization */ + +#ifndef GL_INTEL_framebuffer_CMAA +#define GL_INTEL_framebuffer_CMAA 1 +typedef void (GL_APIENTRYP PFNGLAPPLYFRAMEBUFFERATTACHMENTCMAAINTELPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glApplyFramebufferAttachmentCMAAINTEL (void); +#endif +#endif /* GL_INTEL_framebuffer_CMAA */ + +#ifndef GL_INTEL_performance_query +#define GL_INTEL_performance_query 1 +#define GL_PERFQUERY_SINGLE_CONTEXT_INTEL 0x00000000 +#define GL_PERFQUERY_GLOBAL_CONTEXT_INTEL 0x00000001 +#define GL_PERFQUERY_WAIT_INTEL 0x83FB +#define GL_PERFQUERY_FLUSH_INTEL 0x83FA +#define GL_PERFQUERY_DONOT_FLUSH_INTEL 0x83F9 +#define GL_PERFQUERY_COUNTER_EVENT_INTEL 0x94F0 +#define GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL 0x94F1 +#define GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL 0x94F2 +#define GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL 0x94F3 +#define GL_PERFQUERY_COUNTER_RAW_INTEL 0x94F4 +#define GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL 0x94F5 +#define GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL 0x94F8 +#define GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL 0x94F9 +#define GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL 0x94FA +#define GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL 0x94FB +#define GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL 0x94FC +#define GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL 0x94FD +#define GL_PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL 0x94FE +#define GL_PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL 0x94FF +#define GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL 0x9500 +typedef void (GL_APIENTRYP PFNGLBEGINPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (GL_APIENTRYP PFNGLCREATEPERFQUERYINTELPROC) (GLuint queryId, GLuint *queryHandle); +typedef void (GL_APIENTRYP PFNGLDELETEPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (GL_APIENTRYP PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (GL_APIENTRYP PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint *queryId); +typedef void (GL_APIENTRYP PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint *nextQueryId); +typedef void (GL_APIENTRYP PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); +typedef void (GL_APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); +typedef void (GL_APIENTRYP PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar *queryName, GLuint *queryId); +typedef void (GL_APIENTRYP PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBeginPerfQueryINTEL (GLuint queryHandle); +GL_APICALL void GL_APIENTRY glCreatePerfQueryINTEL (GLuint queryId, GLuint *queryHandle); +GL_APICALL void GL_APIENTRY glDeletePerfQueryINTEL (GLuint queryHandle); +GL_APICALL void GL_APIENTRY glEndPerfQueryINTEL (GLuint queryHandle); +GL_APICALL void GL_APIENTRY glGetFirstPerfQueryIdINTEL (GLuint *queryId); +GL_APICALL void GL_APIENTRY glGetNextPerfQueryIdINTEL (GLuint queryId, GLuint *nextQueryId); +GL_APICALL void GL_APIENTRY glGetPerfCounterInfoINTEL (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); +GL_APICALL void GL_APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); +GL_APICALL void GL_APIENTRY glGetPerfQueryIdByNameINTEL (GLchar *queryName, GLuint *queryId); +GL_APICALL void GL_APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); +#endif +#endif /* GL_INTEL_performance_query */ + +#ifndef GL_MESA_framebuffer_flip_x +#define GL_MESA_framebuffer_flip_x 1 +#define GL_FRAMEBUFFER_FLIP_X_MESA 0x8BBC +#endif /* GL_MESA_framebuffer_flip_x */ + +#ifndef GL_MESA_framebuffer_flip_y +#define GL_MESA_framebuffer_flip_y 1 +#define GL_FRAMEBUFFER_FLIP_Y_MESA 0x8BBB +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERPARAMETERIMESAPROC) (GLenum target, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVMESAPROC) (GLenum target, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferParameteriMESA (GLenum target, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glGetFramebufferParameterivMESA (GLenum target, GLenum pname, GLint *params); +#endif +#endif /* GL_MESA_framebuffer_flip_y */ + +#ifndef GL_MESA_framebuffer_swap_xy +#define GL_MESA_framebuffer_swap_xy 1 +#define GL_FRAMEBUFFER_SWAP_XY_MESA 0x8BBD +#endif /* GL_MESA_framebuffer_swap_xy */ + +#ifndef GL_MESA_program_binary_formats +#define GL_MESA_program_binary_formats 1 +#define GL_PROGRAM_BINARY_FORMAT_MESA 0x875F +#endif /* GL_MESA_program_binary_formats */ + +#ifndef GL_MESA_shader_integer_functions +#define GL_MESA_shader_integer_functions 1 +#endif /* GL_MESA_shader_integer_functions */ + +#ifndef GL_NVX_blend_equation_advanced_multi_draw_buffers +#define GL_NVX_blend_equation_advanced_multi_draw_buffers 1 +#endif /* GL_NVX_blend_equation_advanced_multi_draw_buffers */ + +#ifndef GL_NV_bindless_texture +#define GL_NV_bindless_texture 1 +typedef GLuint64 (GL_APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture); +typedef GLuint64 (GL_APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler); +typedef void (GL_APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef void (GL_APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef GLuint64 (GL_APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +typedef void (GL_APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access); +typedef void (GL_APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef void (GL_APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value); +typedef void (GL_APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +typedef GLboolean (GL_APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef GLboolean (GL_APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL GLuint64 GL_APIENTRY glGetTextureHandleNV (GLuint texture); +GL_APICALL GLuint64 GL_APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler); +GL_APICALL void GL_APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle); +GL_APICALL void GL_APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle); +GL_APICALL GLuint64 GL_APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +GL_APICALL void GL_APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access); +GL_APICALL void GL_APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle); +GL_APICALL void GL_APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value); +GL_APICALL void GL_APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value); +GL_APICALL void GL_APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value); +GL_APICALL void GL_APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +GL_APICALL GLboolean GL_APIENTRY glIsTextureHandleResidentNV (GLuint64 handle); +GL_APICALL GLboolean GL_APIENTRY glIsImageHandleResidentNV (GLuint64 handle); +#endif +#endif /* GL_NV_bindless_texture */ + +#ifndef GL_NV_blend_equation_advanced +#define GL_NV_blend_equation_advanced 1 +#define GL_BLEND_OVERLAP_NV 0x9281 +#define GL_BLEND_PREMULTIPLIED_SRC_NV 0x9280 +#define GL_BLUE_NV 0x1905 +#define GL_COLORBURN_NV 0x929A +#define GL_COLORDODGE_NV 0x9299 +#define GL_CONJOINT_NV 0x9284 +#define GL_CONTRAST_NV 0x92A1 +#define GL_DARKEN_NV 0x9297 +#define GL_DIFFERENCE_NV 0x929E +#define GL_DISJOINT_NV 0x9283 +#define GL_DST_ATOP_NV 0x928F +#define GL_DST_IN_NV 0x928B +#define GL_DST_NV 0x9287 +#define GL_DST_OUT_NV 0x928D +#define GL_DST_OVER_NV 0x9289 +#define GL_EXCLUSION_NV 0x92A0 +#define GL_GREEN_NV 0x1904 +#define GL_HARDLIGHT_NV 0x929B +#define GL_HARDMIX_NV 0x92A9 +#define GL_HSL_COLOR_NV 0x92AF +#define GL_HSL_HUE_NV 0x92AD +#define GL_HSL_LUMINOSITY_NV 0x92B0 +#define GL_HSL_SATURATION_NV 0x92AE +#define GL_INVERT_OVG_NV 0x92B4 +#define GL_INVERT_RGB_NV 0x92A3 +#define GL_LIGHTEN_NV 0x9298 +#define GL_LINEARBURN_NV 0x92A5 +#define GL_LINEARDODGE_NV 0x92A4 +#define GL_LINEARLIGHT_NV 0x92A7 +#define GL_MINUS_CLAMPED_NV 0x92B3 +#define GL_MINUS_NV 0x929F +#define GL_MULTIPLY_NV 0x9294 +#define GL_OVERLAY_NV 0x9296 +#define GL_PINLIGHT_NV 0x92A8 +#define GL_PLUS_CLAMPED_ALPHA_NV 0x92B2 +#define GL_PLUS_CLAMPED_NV 0x92B1 +#define GL_PLUS_DARKER_NV 0x9292 +#define GL_PLUS_NV 0x9291 +#define GL_RED_NV 0x1903 +#define GL_SCREEN_NV 0x9295 +#define GL_SOFTLIGHT_NV 0x929C +#define GL_SRC_ATOP_NV 0x928E +#define GL_SRC_IN_NV 0x928A +#define GL_SRC_NV 0x9286 +#define GL_SRC_OUT_NV 0x928C +#define GL_SRC_OVER_NV 0x9288 +#define GL_UNCORRELATED_NV 0x9282 +#define GL_VIVIDLIGHT_NV 0x92A6 +#define GL_XOR_NV 0x1506 +typedef void (GL_APIENTRYP PFNGLBLENDPARAMETERINVPROC) (GLenum pname, GLint value); +typedef void (GL_APIENTRYP PFNGLBLENDBARRIERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBlendParameteriNV (GLenum pname, GLint value); +GL_APICALL void GL_APIENTRY glBlendBarrierNV (void); +#endif +#endif /* GL_NV_blend_equation_advanced */ + +#ifndef GL_NV_blend_equation_advanced_coherent +#define GL_NV_blend_equation_advanced_coherent 1 +#define GL_BLEND_ADVANCED_COHERENT_NV 0x9285 +#endif /* GL_NV_blend_equation_advanced_coherent */ + +#ifndef GL_NV_blend_minmax_factor +#define GL_NV_blend_minmax_factor 1 +#define GL_FACTOR_MIN_AMD 0x901C +#define GL_FACTOR_MAX_AMD 0x901D +#endif /* GL_NV_blend_minmax_factor */ + +#ifndef GL_NV_clip_space_w_scaling +#define GL_NV_clip_space_w_scaling 1 +#define GL_VIEWPORT_POSITION_W_SCALE_NV 0x937C +#define GL_VIEWPORT_POSITION_W_SCALE_X_COEFF_NV 0x937D +#define GL_VIEWPORT_POSITION_W_SCALE_Y_COEFF_NV 0x937E +typedef void (GL_APIENTRYP PFNGLVIEWPORTPOSITIONWSCALENVPROC) (GLuint index, GLfloat xcoeff, GLfloat ycoeff); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glViewportPositionWScaleNV (GLuint index, GLfloat xcoeff, GLfloat ycoeff); +#endif +#endif /* GL_NV_clip_space_w_scaling */ + +#ifndef GL_NV_compute_shader_derivatives +#define GL_NV_compute_shader_derivatives 1 +#endif /* GL_NV_compute_shader_derivatives */ + +#ifndef GL_NV_conditional_render +#define GL_NV_conditional_render 1 +#define GL_QUERY_WAIT_NV 0x8E13 +#define GL_QUERY_NO_WAIT_NV 0x8E14 +#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 +typedef void (GL_APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); +typedef void (GL_APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode); +GL_APICALL void GL_APIENTRY glEndConditionalRenderNV (void); +#endif +#endif /* GL_NV_conditional_render */ + +#ifndef GL_NV_conservative_raster +#define GL_NV_conservative_raster 1 +#define GL_CONSERVATIVE_RASTERIZATION_NV 0x9346 +#define GL_SUBPIXEL_PRECISION_BIAS_X_BITS_NV 0x9347 +#define GL_SUBPIXEL_PRECISION_BIAS_Y_BITS_NV 0x9348 +#define GL_MAX_SUBPIXEL_PRECISION_BIAS_BITS_NV 0x9349 +typedef void (GL_APIENTRYP PFNGLSUBPIXELPRECISIONBIASNVPROC) (GLuint xbits, GLuint ybits); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glSubpixelPrecisionBiasNV (GLuint xbits, GLuint ybits); +#endif +#endif /* GL_NV_conservative_raster */ + +#ifndef GL_NV_conservative_raster_pre_snap +#define GL_NV_conservative_raster_pre_snap 1 +#define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_NV 0x9550 +#endif /* GL_NV_conservative_raster_pre_snap */ + +#ifndef GL_NV_conservative_raster_pre_snap_triangles +#define GL_NV_conservative_raster_pre_snap_triangles 1 +#define GL_CONSERVATIVE_RASTER_MODE_NV 0x954D +#define GL_CONSERVATIVE_RASTER_MODE_POST_SNAP_NV 0x954E +#define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_TRIANGLES_NV 0x954F +typedef void (GL_APIENTRYP PFNGLCONSERVATIVERASTERPARAMETERINVPROC) (GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glConservativeRasterParameteriNV (GLenum pname, GLint param); +#endif +#endif /* GL_NV_conservative_raster_pre_snap_triangles */ + +#ifndef GL_NV_copy_buffer +#define GL_NV_copy_buffer 1 +#define GL_COPY_READ_BUFFER_NV 0x8F36 +#define GL_COPY_WRITE_BUFFER_NV 0x8F37 +typedef void (GL_APIENTRYP PFNGLCOPYBUFFERSUBDATANVPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glCopyBufferSubDataNV (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +#endif +#endif /* GL_NV_copy_buffer */ + +#ifndef GL_NV_coverage_sample +#define GL_NV_coverage_sample 1 +#define GL_COVERAGE_COMPONENT_NV 0x8ED0 +#define GL_COVERAGE_COMPONENT4_NV 0x8ED1 +#define GL_COVERAGE_ATTACHMENT_NV 0x8ED2 +#define GL_COVERAGE_BUFFERS_NV 0x8ED3 +#define GL_COVERAGE_SAMPLES_NV 0x8ED4 +#define GL_COVERAGE_ALL_FRAGMENTS_NV 0x8ED5 +#define GL_COVERAGE_EDGE_FRAGMENTS_NV 0x8ED6 +#define GL_COVERAGE_AUTOMATIC_NV 0x8ED7 +#define GL_COVERAGE_BUFFER_BIT_NV 0x00008000 +typedef void (GL_APIENTRYP PFNGLCOVERAGEMASKNVPROC) (GLboolean mask); +typedef void (GL_APIENTRYP PFNGLCOVERAGEOPERATIONNVPROC) (GLenum operation); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glCoverageMaskNV (GLboolean mask); +GL_APICALL void GL_APIENTRY glCoverageOperationNV (GLenum operation); +#endif +#endif /* GL_NV_coverage_sample */ + +#ifndef GL_NV_depth_nonlinear +#define GL_NV_depth_nonlinear 1 +#define GL_DEPTH_COMPONENT16_NONLINEAR_NV 0x8E2C +#endif /* GL_NV_depth_nonlinear */ + +#ifndef GL_NV_draw_buffers +#define GL_NV_draw_buffers 1 +#define GL_MAX_DRAW_BUFFERS_NV 0x8824 +#define GL_DRAW_BUFFER0_NV 0x8825 +#define GL_DRAW_BUFFER1_NV 0x8826 +#define GL_DRAW_BUFFER2_NV 0x8827 +#define GL_DRAW_BUFFER3_NV 0x8828 +#define GL_DRAW_BUFFER4_NV 0x8829 +#define GL_DRAW_BUFFER5_NV 0x882A +#define GL_DRAW_BUFFER6_NV 0x882B +#define GL_DRAW_BUFFER7_NV 0x882C +#define GL_DRAW_BUFFER8_NV 0x882D +#define GL_DRAW_BUFFER9_NV 0x882E +#define GL_DRAW_BUFFER10_NV 0x882F +#define GL_DRAW_BUFFER11_NV 0x8830 +#define GL_DRAW_BUFFER12_NV 0x8831 +#define GL_DRAW_BUFFER13_NV 0x8832 +#define GL_DRAW_BUFFER14_NV 0x8833 +#define GL_DRAW_BUFFER15_NV 0x8834 +#define GL_COLOR_ATTACHMENT0_NV 0x8CE0 +#define GL_COLOR_ATTACHMENT1_NV 0x8CE1 +#define GL_COLOR_ATTACHMENT2_NV 0x8CE2 +#define GL_COLOR_ATTACHMENT3_NV 0x8CE3 +#define GL_COLOR_ATTACHMENT4_NV 0x8CE4 +#define GL_COLOR_ATTACHMENT5_NV 0x8CE5 +#define GL_COLOR_ATTACHMENT6_NV 0x8CE6 +#define GL_COLOR_ATTACHMENT7_NV 0x8CE7 +#define GL_COLOR_ATTACHMENT8_NV 0x8CE8 +#define GL_COLOR_ATTACHMENT9_NV 0x8CE9 +#define GL_COLOR_ATTACHMENT10_NV 0x8CEA +#define GL_COLOR_ATTACHMENT11_NV 0x8CEB +#define GL_COLOR_ATTACHMENT12_NV 0x8CEC +#define GL_COLOR_ATTACHMENT13_NV 0x8CED +#define GL_COLOR_ATTACHMENT14_NV 0x8CEE +#define GL_COLOR_ATTACHMENT15_NV 0x8CEF +typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSNVPROC) (GLsizei n, const GLenum *bufs); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawBuffersNV (GLsizei n, const GLenum *bufs); +#endif +#endif /* GL_NV_draw_buffers */ + +#ifndef GL_NV_draw_instanced +#define GL_NV_draw_instanced 1 +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDNVPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDNVPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawArraysInstancedNV (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedNV (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#endif +#endif /* GL_NV_draw_instanced */ + +#ifndef GL_NV_draw_vulkan_image +#define GL_NV_draw_vulkan_image 1 +typedef void (GL_APIENTRY *GLVULKANPROCNV)(void); +typedef void (GL_APIENTRYP PFNGLDRAWVKIMAGENVPROC) (GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +typedef GLVULKANPROCNV (GL_APIENTRYP PFNGLGETVKPROCADDRNVPROC) (const GLchar *name); +typedef void (GL_APIENTRYP PFNGLWAITVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); +typedef void (GL_APIENTRYP PFNGLSIGNALVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); +typedef void (GL_APIENTRYP PFNGLSIGNALVKFENCENVPROC) (GLuint64 vkFence); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawVkImageNV (GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +GL_APICALL GLVULKANPROCNV GL_APIENTRY glGetVkProcAddrNV (const GLchar *name); +GL_APICALL void GL_APIENTRY glWaitVkSemaphoreNV (GLuint64 vkSemaphore); +GL_APICALL void GL_APIENTRY glSignalVkSemaphoreNV (GLuint64 vkSemaphore); +GL_APICALL void GL_APIENTRY glSignalVkFenceNV (GLuint64 vkFence); +#endif +#endif /* GL_NV_draw_vulkan_image */ + +#ifndef GL_NV_explicit_attrib_location +#define GL_NV_explicit_attrib_location 1 +#endif /* GL_NV_explicit_attrib_location */ + +#ifndef GL_NV_fbo_color_attachments +#define GL_NV_fbo_color_attachments 1 +#define GL_MAX_COLOR_ATTACHMENTS_NV 0x8CDF +#endif /* GL_NV_fbo_color_attachments */ + +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +typedef void (GL_APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (GL_APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (GL_APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (GL_APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (GL_APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (GL_APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); +GL_APICALL void GL_APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); +GL_APICALL GLboolean GL_APIENTRY glIsFenceNV (GLuint fence); +GL_APICALL GLboolean GL_APIENTRY glTestFenceNV (GLuint fence); +GL_APICALL void GL_APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glFinishFenceNV (GLuint fence); +GL_APICALL void GL_APIENTRY glSetFenceNV (GLuint fence, GLenum condition); +#endif +#endif /* GL_NV_fence */ + +#ifndef GL_NV_fill_rectangle +#define GL_NV_fill_rectangle 1 +#define GL_FILL_RECTANGLE_NV 0x933C +#endif /* GL_NV_fill_rectangle */ + +#ifndef GL_NV_fragment_coverage_to_color +#define GL_NV_fragment_coverage_to_color 1 +#define GL_FRAGMENT_COVERAGE_TO_COLOR_NV 0x92DD +#define GL_FRAGMENT_COVERAGE_COLOR_NV 0x92DE +typedef void (GL_APIENTRYP PFNGLFRAGMENTCOVERAGECOLORNVPROC) (GLuint color); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFragmentCoverageColorNV (GLuint color); +#endif +#endif /* GL_NV_fragment_coverage_to_color */ + +#ifndef GL_NV_fragment_shader_barycentric +#define GL_NV_fragment_shader_barycentric 1 +#endif /* GL_NV_fragment_shader_barycentric */ + +#ifndef GL_NV_fragment_shader_interlock +#define GL_NV_fragment_shader_interlock 1 +#endif /* GL_NV_fragment_shader_interlock */ + +#ifndef GL_NV_framebuffer_blit +#define GL_NV_framebuffer_blit 1 +#define GL_READ_FRAMEBUFFER_NV 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_NV 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_NV 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_NV 0x8CAA +typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERNVPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBlitFramebufferNV (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +#endif /* GL_NV_framebuffer_blit */ + +#ifndef GL_NV_framebuffer_mixed_samples +#define GL_NV_framebuffer_mixed_samples 1 +#define GL_COVERAGE_MODULATION_TABLE_NV 0x9331 +#define GL_COLOR_SAMPLES_NV 0x8E20 +#define GL_DEPTH_SAMPLES_NV 0x932D +#define GL_STENCIL_SAMPLES_NV 0x932E +#define GL_MIXED_DEPTH_SAMPLES_SUPPORTED_NV 0x932F +#define GL_MIXED_STENCIL_SAMPLES_SUPPORTED_NV 0x9330 +#define GL_COVERAGE_MODULATION_NV 0x9332 +#define GL_COVERAGE_MODULATION_TABLE_SIZE_NV 0x9333 +typedef void (GL_APIENTRYP PFNGLCOVERAGEMODULATIONTABLENVPROC) (GLsizei n, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLGETCOVERAGEMODULATIONTABLENVPROC) (GLsizei bufSize, GLfloat *v); +typedef void (GL_APIENTRYP PFNGLCOVERAGEMODULATIONNVPROC) (GLenum components); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glCoverageModulationTableNV (GLsizei n, const GLfloat *v); +GL_APICALL void GL_APIENTRY glGetCoverageModulationTableNV (GLsizei bufSize, GLfloat *v); +GL_APICALL void GL_APIENTRY glCoverageModulationNV (GLenum components); +#endif +#endif /* GL_NV_framebuffer_mixed_samples */ + +#ifndef GL_NV_framebuffer_multisample +#define GL_NV_framebuffer_multisample 1 +#define GL_RENDERBUFFER_SAMPLES_NV 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_NV 0x8D56 +#define GL_MAX_SAMPLES_NV 0x8D57 +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLENVPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleNV (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_NV_framebuffer_multisample */ + +#ifndef GL_NV_generate_mipmap_sRGB +#define GL_NV_generate_mipmap_sRGB 1 +#endif /* GL_NV_generate_mipmap_sRGB */ + +#ifndef GL_NV_geometry_shader_passthrough +#define GL_NV_geometry_shader_passthrough 1 +#endif /* GL_NV_geometry_shader_passthrough */ + +#ifndef GL_NV_gpu_shader5 +#define GL_NV_gpu_shader5 1 +typedef khronos_int64_t GLint64EXT; +typedef khronos_uint64_t GLuint64EXT; +#define GL_INT64_NV 0x140E +#define GL_UNSIGNED_INT64_NV 0x140F +#define GL_INT8_NV 0x8FE0 +#define GL_INT8_VEC2_NV 0x8FE1 +#define GL_INT8_VEC3_NV 0x8FE2 +#define GL_INT8_VEC4_NV 0x8FE3 +#define GL_INT16_NV 0x8FE4 +#define GL_INT16_VEC2_NV 0x8FE5 +#define GL_INT16_VEC3_NV 0x8FE6 +#define GL_INT16_VEC4_NV 0x8FE7 +#define GL_INT64_VEC2_NV 0x8FE9 +#define GL_INT64_VEC3_NV 0x8FEA +#define GL_INT64_VEC4_NV 0x8FEB +#define GL_UNSIGNED_INT8_NV 0x8FEC +#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED +#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE +#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF +#define GL_UNSIGNED_INT16_NV 0x8FF0 +#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 +#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 +#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 +#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 +#define GL_FLOAT16_NV 0x8FF8 +#define GL_FLOAT16_VEC2_NV 0x8FF9 +#define GL_FLOAT16_VEC3_NV 0x8FFA +#define GL_FLOAT16_VEC4_NV 0x8FFB +#define GL_PATCHES 0x000E +typedef void (GL_APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); +typedef void (GL_APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); +typedef void (GL_APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (GL_APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (GL_APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); +typedef void (GL_APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (GL_APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (GL_APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (GL_APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (GL_APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glUniform1i64NV (GLint location, GLint64EXT x); +GL_APICALL void GL_APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y); +GL_APICALL void GL_APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GL_APICALL void GL_APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GL_APICALL void GL_APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GL_APICALL void GL_APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GL_APICALL void GL_APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GL_APICALL void GL_APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GL_APICALL void GL_APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x); +GL_APICALL void GL_APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y); +GL_APICALL void GL_APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GL_APICALL void GL_APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GL_APICALL void GL_APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GL_APICALL void GL_APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GL_APICALL void GL_APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GL_APICALL void GL_APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GL_APICALL void GL_APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params); +GL_APICALL void GL_APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x); +GL_APICALL void GL_APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +GL_APICALL void GL_APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GL_APICALL void GL_APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GL_APICALL void GL_APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GL_APICALL void GL_APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GL_APICALL void GL_APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GL_APICALL void GL_APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GL_APICALL void GL_APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x); +GL_APICALL void GL_APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +GL_APICALL void GL_APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GL_APICALL void GL_APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GL_APICALL void GL_APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GL_APICALL void GL_APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GL_APICALL void GL_APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GL_APICALL void GL_APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif +#endif /* GL_NV_gpu_shader5 */ + +#ifndef GL_NV_image_formats +#define GL_NV_image_formats 1 +#endif /* GL_NV_image_formats */ + +#ifndef GL_NV_instanced_arrays +#define GL_NV_instanced_arrays 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_NV 0x88FE +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORNVPROC) (GLuint index, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glVertexAttribDivisorNV (GLuint index, GLuint divisor); +#endif +#endif /* GL_NV_instanced_arrays */ + +#ifndef GL_NV_internalformat_sample_query +#define GL_NV_internalformat_sample_query 1 +#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 +#define GL_MULTISAMPLES_NV 0x9371 +#define GL_SUPERSAMPLE_SCALE_X_NV 0x9372 +#define GL_SUPERSAMPLE_SCALE_Y_NV 0x9373 +#define GL_CONFORMANT_NV 0x9374 +typedef void (GL_APIENTRYP PFNGLGETINTERNALFORMATSAMPLEIVNVPROC) (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei count, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetInternalformatSampleivNV (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei count, GLint *params); +#endif +#endif /* GL_NV_internalformat_sample_query */ + +#ifndef GL_NV_memory_attachment +#define GL_NV_memory_attachment 1 +#define GL_ATTACHED_MEMORY_OBJECT_NV 0x95A4 +#define GL_ATTACHED_MEMORY_OFFSET_NV 0x95A5 +#define GL_MEMORY_ATTACHABLE_ALIGNMENT_NV 0x95A6 +#define GL_MEMORY_ATTACHABLE_SIZE_NV 0x95A7 +#define GL_MEMORY_ATTACHABLE_NV 0x95A8 +#define GL_DETACHED_MEMORY_INCARNATION_NV 0x95A9 +#define GL_DETACHED_TEXTURES_NV 0x95AA +#define GL_DETACHED_BUFFERS_NV 0x95AB +#define GL_MAX_DETACHED_TEXTURES_NV 0x95AC +#define GL_MAX_DETACHED_BUFFERS_NV 0x95AD +typedef void (GL_APIENTRYP PFNGLGETMEMORYOBJECTDETACHEDRESOURCESUIVNVPROC) (GLuint memory, GLenum pname, GLint first, GLsizei count, GLuint *params); +typedef void (GL_APIENTRYP PFNGLRESETMEMORYOBJECTPARAMETERNVPROC) (GLuint memory, GLenum pname); +typedef void (GL_APIENTRYP PFNGLTEXATTACHMEMORYNVPROC) (GLenum target, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLBUFFERATTACHMEMORYNVPROC) (GLenum target, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXTUREATTACHMEMORYNVPROC) (GLuint texture, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLNAMEDBUFFERATTACHMEMORYNVPROC) (GLuint buffer, GLuint memory, GLuint64 offset); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetMemoryObjectDetachedResourcesuivNV (GLuint memory, GLenum pname, GLint first, GLsizei count, GLuint *params); +GL_APICALL void GL_APIENTRY glResetMemoryObjectParameterNV (GLuint memory, GLenum pname); +GL_APICALL void GL_APIENTRY glTexAttachMemoryNV (GLenum target, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glBufferAttachMemoryNV (GLenum target, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTextureAttachMemoryNV (GLuint texture, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glNamedBufferAttachMemoryNV (GLuint buffer, GLuint memory, GLuint64 offset); +#endif +#endif /* GL_NV_memory_attachment */ + +#ifndef GL_NV_mesh_shader +#define GL_NV_mesh_shader 1 +#define GL_MESH_SHADER_NV 0x9559 +#define GL_TASK_SHADER_NV 0x955A +#define GL_MAX_MESH_UNIFORM_BLOCKS_NV 0x8E60 +#define GL_MAX_MESH_TEXTURE_IMAGE_UNITS_NV 0x8E61 +#define GL_MAX_MESH_IMAGE_UNIFORMS_NV 0x8E62 +#define GL_MAX_MESH_UNIFORM_COMPONENTS_NV 0x8E63 +#define GL_MAX_MESH_ATOMIC_COUNTER_BUFFERS_NV 0x8E64 +#define GL_MAX_MESH_ATOMIC_COUNTERS_NV 0x8E65 +#define GL_MAX_MESH_SHADER_STORAGE_BLOCKS_NV 0x8E66 +#define GL_MAX_COMBINED_MESH_UNIFORM_COMPONENTS_NV 0x8E67 +#define GL_MAX_TASK_UNIFORM_BLOCKS_NV 0x8E68 +#define GL_MAX_TASK_TEXTURE_IMAGE_UNITS_NV 0x8E69 +#define GL_MAX_TASK_IMAGE_UNIFORMS_NV 0x8E6A +#define GL_MAX_TASK_UNIFORM_COMPONENTS_NV 0x8E6B +#define GL_MAX_TASK_ATOMIC_COUNTER_BUFFERS_NV 0x8E6C +#define GL_MAX_TASK_ATOMIC_COUNTERS_NV 0x8E6D +#define GL_MAX_TASK_SHADER_STORAGE_BLOCKS_NV 0x8E6E +#define GL_MAX_COMBINED_TASK_UNIFORM_COMPONENTS_NV 0x8E6F +#define GL_MAX_MESH_WORK_GROUP_INVOCATIONS_NV 0x95A2 +#define GL_MAX_TASK_WORK_GROUP_INVOCATIONS_NV 0x95A3 +#define GL_MAX_MESH_TOTAL_MEMORY_SIZE_NV 0x9536 +#define GL_MAX_TASK_TOTAL_MEMORY_SIZE_NV 0x9537 +#define GL_MAX_MESH_OUTPUT_VERTICES_NV 0x9538 +#define GL_MAX_MESH_OUTPUT_PRIMITIVES_NV 0x9539 +#define GL_MAX_TASK_OUTPUT_COUNT_NV 0x953A +#define GL_MAX_DRAW_MESH_TASKS_COUNT_NV 0x953D +#define GL_MAX_MESH_VIEWS_NV 0x9557 +#define GL_MESH_OUTPUT_PER_VERTEX_GRANULARITY_NV 0x92DF +#define GL_MESH_OUTPUT_PER_PRIMITIVE_GRANULARITY_NV 0x9543 +#define GL_MAX_MESH_WORK_GROUP_SIZE_NV 0x953B +#define GL_MAX_TASK_WORK_GROUP_SIZE_NV 0x953C +#define GL_MESH_WORK_GROUP_SIZE_NV 0x953E +#define GL_TASK_WORK_GROUP_SIZE_NV 0x953F +#define GL_MESH_VERTICES_OUT_NV 0x9579 +#define GL_MESH_PRIMITIVES_OUT_NV 0x957A +#define GL_MESH_OUTPUT_TYPE_NV 0x957B +#define GL_UNIFORM_BLOCK_REFERENCED_BY_MESH_SHADER_NV 0x959C +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TASK_SHADER_NV 0x959D +#define GL_REFERENCED_BY_MESH_SHADER_NV 0x95A0 +#define GL_REFERENCED_BY_TASK_SHADER_NV 0x95A1 +#define GL_MESH_SHADER_BIT_NV 0x00000040 +#define GL_TASK_SHADER_BIT_NV 0x00000080 +#define GL_MESH_SUBROUTINE_NV 0x957C +#define GL_TASK_SUBROUTINE_NV 0x957D +#define GL_MESH_SUBROUTINE_UNIFORM_NV 0x957E +#define GL_TASK_SUBROUTINE_UNIFORM_NV 0x957F +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_MESH_SHADER_NV 0x959E +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TASK_SHADER_NV 0x959F +typedef void (GL_APIENTRYP PFNGLDRAWMESHTASKSNVPROC) (GLuint first, GLuint count); +typedef void (GL_APIENTRYP PFNGLDRAWMESHTASKSINDIRECTNVPROC) (GLintptr indirect); +typedef void (GL_APIENTRYP PFNGLMULTIDRAWMESHTASKSINDIRECTNVPROC) (GLintptr indirect, GLsizei drawcount, GLsizei stride); +typedef void (GL_APIENTRYP PFNGLMULTIDRAWMESHTASKSINDIRECTCOUNTNVPROC) (GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawMeshTasksNV (GLuint first, GLuint count); +GL_APICALL void GL_APIENTRY glDrawMeshTasksIndirectNV (GLintptr indirect); +GL_APICALL void GL_APIENTRY glMultiDrawMeshTasksIndirectNV (GLintptr indirect, GLsizei drawcount, GLsizei stride); +GL_APICALL void GL_APIENTRY glMultiDrawMeshTasksIndirectCountNV (GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#endif +#endif /* GL_NV_mesh_shader */ + +#ifndef GL_NV_non_square_matrices +#define GL_NV_non_square_matrices 1 +#define GL_FLOAT_MAT2x3_NV 0x8B65 +#define GL_FLOAT_MAT2x4_NV 0x8B66 +#define GL_FLOAT_MAT3x2_NV 0x8B67 +#define GL_FLOAT_MAT3x4_NV 0x8B68 +#define GL_FLOAT_MAT4x2_NV 0x8B69 +#define GL_FLOAT_MAT4x3_NV 0x8B6A +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2X3FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3X2FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2X4FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4X2FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3X4FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4X3FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glUniformMatrix2x3fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix3x2fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix2x4fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix4x2fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix3x4fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix4x3fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif +#endif /* GL_NV_non_square_matrices */ + +#ifndef GL_NV_path_rendering +#define GL_NV_path_rendering 1 +typedef double GLdouble; +#define GL_PATH_FORMAT_SVG_NV 0x9070 +#define GL_PATH_FORMAT_PS_NV 0x9071 +#define GL_STANDARD_FONT_NAME_NV 0x9072 +#define GL_SYSTEM_FONT_NAME_NV 0x9073 +#define GL_FILE_NAME_NV 0x9074 +#define GL_PATH_STROKE_WIDTH_NV 0x9075 +#define GL_PATH_END_CAPS_NV 0x9076 +#define GL_PATH_INITIAL_END_CAP_NV 0x9077 +#define GL_PATH_TERMINAL_END_CAP_NV 0x9078 +#define GL_PATH_JOIN_STYLE_NV 0x9079 +#define GL_PATH_MITER_LIMIT_NV 0x907A +#define GL_PATH_DASH_CAPS_NV 0x907B +#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C +#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D +#define GL_PATH_DASH_OFFSET_NV 0x907E +#define GL_PATH_CLIENT_LENGTH_NV 0x907F +#define GL_PATH_FILL_MODE_NV 0x9080 +#define GL_PATH_FILL_MASK_NV 0x9081 +#define GL_PATH_FILL_COVER_MODE_NV 0x9082 +#define GL_PATH_STROKE_COVER_MODE_NV 0x9083 +#define GL_PATH_STROKE_MASK_NV 0x9084 +#define GL_COUNT_UP_NV 0x9088 +#define GL_COUNT_DOWN_NV 0x9089 +#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A +#define GL_CONVEX_HULL_NV 0x908B +#define GL_BOUNDING_BOX_NV 0x908D +#define GL_TRANSLATE_X_NV 0x908E +#define GL_TRANSLATE_Y_NV 0x908F +#define GL_TRANSLATE_2D_NV 0x9090 +#define GL_TRANSLATE_3D_NV 0x9091 +#define GL_AFFINE_2D_NV 0x9092 +#define GL_AFFINE_3D_NV 0x9094 +#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096 +#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098 +#define GL_UTF8_NV 0x909A +#define GL_UTF16_NV 0x909B +#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C +#define GL_PATH_COMMAND_COUNT_NV 0x909D +#define GL_PATH_COORD_COUNT_NV 0x909E +#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F +#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0 +#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 +#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 +#define GL_SQUARE_NV 0x90A3 +#define GL_ROUND_NV 0x90A4 +#define GL_TRIANGULAR_NV 0x90A5 +#define GL_BEVEL_NV 0x90A6 +#define GL_MITER_REVERT_NV 0x90A7 +#define GL_MITER_TRUNCATE_NV 0x90A8 +#define GL_SKIP_MISSING_GLYPH_NV 0x90A9 +#define GL_USE_MISSING_GLYPH_NV 0x90AA +#define GL_PATH_ERROR_POSITION_NV 0x90AB +#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD +#define GL_ADJACENT_PAIRS_NV 0x90AE +#define GL_FIRST_TO_REST_NV 0x90AF +#define GL_PATH_GEN_MODE_NV 0x90B0 +#define GL_PATH_GEN_COEFF_NV 0x90B1 +#define GL_PATH_GEN_COMPONENTS_NV 0x90B3 +#define GL_PATH_STENCIL_FUNC_NV 0x90B7 +#define GL_PATH_STENCIL_REF_NV 0x90B8 +#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 +#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD +#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE +#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF +#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 +#define GL_MOVE_TO_RESETS_NV 0x90B5 +#define GL_MOVE_TO_CONTINUES_NV 0x90B6 +#define GL_CLOSE_PATH_NV 0x00 +#define GL_MOVE_TO_NV 0x02 +#define GL_RELATIVE_MOVE_TO_NV 0x03 +#define GL_LINE_TO_NV 0x04 +#define GL_RELATIVE_LINE_TO_NV 0x05 +#define GL_HORIZONTAL_LINE_TO_NV 0x06 +#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 +#define GL_VERTICAL_LINE_TO_NV 0x08 +#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 +#define GL_QUADRATIC_CURVE_TO_NV 0x0A +#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B +#define GL_CUBIC_CURVE_TO_NV 0x0C +#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D +#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E +#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F +#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 +#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 +#define GL_SMALL_CCW_ARC_TO_NV 0x12 +#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 +#define GL_SMALL_CW_ARC_TO_NV 0x14 +#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 +#define GL_LARGE_CCW_ARC_TO_NV 0x16 +#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 +#define GL_LARGE_CW_ARC_TO_NV 0x18 +#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 +#define GL_RESTART_PATH_NV 0xF0 +#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2 +#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4 +#define GL_RECT_NV 0xF6 +#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 +#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA +#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC +#define GL_ARC_TO_NV 0xFE +#define GL_RELATIVE_ARC_TO_NV 0xFF +#define GL_BOLD_BIT_NV 0x01 +#define GL_ITALIC_BIT_NV 0x02 +#define GL_GLYPH_WIDTH_BIT_NV 0x01 +#define GL_GLYPH_HEIGHT_BIT_NV 0x02 +#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 +#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 +#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 +#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 +#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 +#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 +#define GL_GLYPH_HAS_KERNING_BIT_NV 0x100 +#define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000 +#define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000 +#define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000 +#define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000 +#define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000 +#define GL_FONT_ASCENDER_BIT_NV 0x00200000 +#define GL_FONT_DESCENDER_BIT_NV 0x00400000 +#define GL_FONT_HEIGHT_BIT_NV 0x00800000 +#define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000 +#define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000 +#define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000 +#define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000 +#define GL_FONT_HAS_KERNING_BIT_NV 0x10000000 +#define GL_ROUNDED_RECT_NV 0xE8 +#define GL_RELATIVE_ROUNDED_RECT_NV 0xE9 +#define GL_ROUNDED_RECT2_NV 0xEA +#define GL_RELATIVE_ROUNDED_RECT2_NV 0xEB +#define GL_ROUNDED_RECT4_NV 0xEC +#define GL_RELATIVE_ROUNDED_RECT4_NV 0xED +#define GL_ROUNDED_RECT8_NV 0xEE +#define GL_RELATIVE_ROUNDED_RECT8_NV 0xEF +#define GL_RELATIVE_RECT_NV 0xF7 +#define GL_FONT_GLYPHS_AVAILABLE_NV 0x9368 +#define GL_FONT_TARGET_UNAVAILABLE_NV 0x9369 +#define GL_FONT_UNAVAILABLE_NV 0x936A +#define GL_FONT_UNINTELLIGIBLE_NV 0x936B +#define GL_CONIC_CURVE_TO_NV 0x1A +#define GL_RELATIVE_CONIC_CURVE_TO_NV 0x1B +#define GL_FONT_NUM_GLYPH_INDICES_BIT_NV 0x20000000 +#define GL_STANDARD_FONT_FORMAT_NV 0x936C +#define GL_PATH_PROJECTION_NV 0x1701 +#define GL_PATH_MODELVIEW_NV 0x1700 +#define GL_PATH_MODELVIEW_STACK_DEPTH_NV 0x0BA3 +#define GL_PATH_MODELVIEW_MATRIX_NV 0x0BA6 +#define GL_PATH_MAX_MODELVIEW_STACK_DEPTH_NV 0x0D36 +#define GL_PATH_TRANSPOSE_MODELVIEW_MATRIX_NV 0x84E3 +#define GL_PATH_PROJECTION_STACK_DEPTH_NV 0x0BA4 +#define GL_PATH_PROJECTION_MATRIX_NV 0x0BA7 +#define GL_PATH_MAX_PROJECTION_STACK_DEPTH_NV 0x0D38 +#define GL_PATH_TRANSPOSE_PROJECTION_MATRIX_NV 0x84E4 +#define GL_FRAGMENT_INPUT_NV 0x936D +typedef GLuint (GL_APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range); +typedef void (GL_APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); +typedef GLboolean (GL_APIENTRYP PFNGLISPATHNVPROC) (GLuint path); +typedef void (GL_APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (GL_APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (GL_APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (GL_APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (GL_APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const void *pathString); +typedef void (GL_APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (GL_APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (GL_APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +typedef void (GL_APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath); +typedef void (GL_APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +typedef void (GL_APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +typedef void (GL_APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value); +typedef void (GL_APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value); +typedef void (GL_APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +typedef void (GL_APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask); +typedef void (GL_APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units); +typedef void (GL_APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (GL_APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (GL_APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func); +typedef void (GL_APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (GL_APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (GL_APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (GL_APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (GL_APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value); +typedef void (GL_APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value); +typedef void (GL_APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands); +typedef void (GL_APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords); +typedef void (GL_APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray); +typedef void (GL_APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +typedef void (GL_APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +typedef void (GL_APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +typedef GLboolean (GL_APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); +typedef GLboolean (GL_APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); +typedef GLfloat (GL_APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); +typedef GLboolean (GL_APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +typedef void (GL_APIENTRYP PFNGLMATRIXLOAD3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLMATRIXLOAD3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLMATRIXMULT3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLMATRIXMULT3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); +typedef void (GL_APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask, GLenum coverMode); +typedef void (GL_APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (GL_APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef GLenum (GL_APIENTRYP PFNGLPATHGLYPHINDEXRANGENVPROC) (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint baseAndCount[2]); +typedef GLenum (GL_APIENTRYP PFNGLPATHGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef GLenum (GL_APIENTRYP PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (GL_APIENTRYP PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC) (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMRESOURCEFVNVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (GL_APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (GL_APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (GL_APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (GL_APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (GL_APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (GL_APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +typedef void (GL_APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +typedef void (GL_APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (GL_APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (GL_APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (GL_APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL GLuint GL_APIENTRY glGenPathsNV (GLsizei range); +GL_APICALL void GL_APIENTRY glDeletePathsNV (GLuint path, GLsizei range); +GL_APICALL GLboolean GL_APIENTRY glIsPathNV (GLuint path); +GL_APICALL void GL_APIENTRY glPathCommandsNV (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +GL_APICALL void GL_APIENTRY glPathCoordsNV (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); +GL_APICALL void GL_APIENTRY glPathSubCommandsNV (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +GL_APICALL void GL_APIENTRY glPathSubCoordsNV (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); +GL_APICALL void GL_APIENTRY glPathStringNV (GLuint path, GLenum format, GLsizei length, const void *pathString); +GL_APICALL void GL_APIENTRY glPathGlyphsNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GL_APICALL void GL_APIENTRY glPathGlyphRangeNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GL_APICALL void GL_APIENTRY glWeightPathsNV (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +GL_APICALL void GL_APIENTRY glCopyPathNV (GLuint resultPath, GLuint srcPath); +GL_APICALL void GL_APIENTRY glInterpolatePathsNV (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +GL_APICALL void GL_APIENTRY glTransformPathNV (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +GL_APICALL void GL_APIENTRY glPathParameterivNV (GLuint path, GLenum pname, const GLint *value); +GL_APICALL void GL_APIENTRY glPathParameteriNV (GLuint path, GLenum pname, GLint value); +GL_APICALL void GL_APIENTRY glPathParameterfvNV (GLuint path, GLenum pname, const GLfloat *value); +GL_APICALL void GL_APIENTRY glPathParameterfNV (GLuint path, GLenum pname, GLfloat value); +GL_APICALL void GL_APIENTRY glPathDashArrayNV (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +GL_APICALL void GL_APIENTRY glPathStencilFuncNV (GLenum func, GLint ref, GLuint mask); +GL_APICALL void GL_APIENTRY glPathStencilDepthOffsetNV (GLfloat factor, GLfloat units); +GL_APICALL void GL_APIENTRY glStencilFillPathNV (GLuint path, GLenum fillMode, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GL_APICALL void GL_APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GL_APICALL void GL_APIENTRY glPathCoverDepthFuncNV (GLenum func); +GL_APICALL void GL_APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode); +GL_APICALL void GL_APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode); +GL_APICALL void GL_APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GL_APICALL void GL_APIENTRY glCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GL_APICALL void GL_APIENTRY glGetPathParameterivNV (GLuint path, GLenum pname, GLint *value); +GL_APICALL void GL_APIENTRY glGetPathParameterfvNV (GLuint path, GLenum pname, GLfloat *value); +GL_APICALL void GL_APIENTRY glGetPathCommandsNV (GLuint path, GLubyte *commands); +GL_APICALL void GL_APIENTRY glGetPathCoordsNV (GLuint path, GLfloat *coords); +GL_APICALL void GL_APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray); +GL_APICALL void GL_APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +GL_APICALL void GL_APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +GL_APICALL void GL_APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +GL_APICALL GLboolean GL_APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y); +GL_APICALL GLboolean GL_APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y); +GL_APICALL GLfloat GL_APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments); +GL_APICALL GLboolean GL_APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +GL_APICALL void GL_APIENTRY glMatrixLoad3x2fNV (GLenum matrixMode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glMatrixLoad3x3fNV (GLenum matrixMode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glMatrixLoadTranspose3x3fNV (GLenum matrixMode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glMatrixMult3x2fNV (GLenum matrixMode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glMatrixMult3x3fNV (GLenum matrixMode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glMatrixMultTranspose3x3fNV (GLenum matrixMode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glStencilThenCoverFillPathNV (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); +GL_APICALL void GL_APIENTRY glStencilThenCoverStrokePathNV (GLuint path, GLint reference, GLuint mask, GLenum coverMode); +GL_APICALL void GL_APIENTRY glStencilThenCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GL_APICALL void GL_APIENTRY glStencilThenCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GL_APICALL GLenum GL_APIENTRY glPathGlyphIndexRangeNV (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint baseAndCount[2]); +GL_APICALL GLenum GL_APIENTRY glPathGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GL_APICALL GLenum GL_APIENTRY glPathMemoryGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GL_APICALL void GL_APIENTRY glProgramPathFragmentInputGenNV (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); +GL_APICALL void GL_APIENTRY glGetProgramResourcefvNV (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLfloat *params); +GL_APICALL void GL_APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GL_APICALL void GL_APIENTRY glMatrixLoadIdentityEXT (GLenum mode); +GL_APICALL void GL_APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); +GL_APICALL void GL_APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); +GL_APICALL void GL_APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); +GL_APICALL void GL_APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); +GL_APICALL void GL_APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GL_APICALL void GL_APIENTRY glMatrixPopEXT (GLenum mode); +GL_APICALL void GL_APIENTRY glMatrixPushEXT (GLenum mode); +GL_APICALL void GL_APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +GL_APICALL void GL_APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GL_APICALL void GL_APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +#endif +#endif /* GL_NV_path_rendering */ + +#ifndef GL_NV_path_rendering_shared_edge +#define GL_NV_path_rendering_shared_edge 1 +#define GL_SHARED_EDGE_NV 0xC0 +#endif /* GL_NV_path_rendering_shared_edge */ + +#ifndef GL_NV_pixel_buffer_object +#define GL_NV_pixel_buffer_object 1 +#define GL_PIXEL_PACK_BUFFER_NV 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_NV 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_NV 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_NV 0x88EF +#endif /* GL_NV_pixel_buffer_object */ + +#ifndef GL_NV_polygon_mode +#define GL_NV_polygon_mode 1 +#define GL_POLYGON_MODE_NV 0x0B40 +#define GL_POLYGON_OFFSET_POINT_NV 0x2A01 +#define GL_POLYGON_OFFSET_LINE_NV 0x2A02 +#define GL_POINT_NV 0x1B00 +#define GL_LINE_NV 0x1B01 +#define GL_FILL_NV 0x1B02 +typedef void (GL_APIENTRYP PFNGLPOLYGONMODENVPROC) (GLenum face, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glPolygonModeNV (GLenum face, GLenum mode); +#endif +#endif /* GL_NV_polygon_mode */ + +#ifndef GL_NV_read_buffer +#define GL_NV_read_buffer 1 +#define GL_READ_BUFFER_NV 0x0C02 +typedef void (GL_APIENTRYP PFNGLREADBUFFERNVPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glReadBufferNV (GLenum mode); +#endif +#endif /* GL_NV_read_buffer */ + +#ifndef GL_NV_read_buffer_front +#define GL_NV_read_buffer_front 1 +#endif /* GL_NV_read_buffer_front */ + +#ifndef GL_NV_read_depth +#define GL_NV_read_depth 1 +#endif /* GL_NV_read_depth */ + +#ifndef GL_NV_read_depth_stencil +#define GL_NV_read_depth_stencil 1 +#endif /* GL_NV_read_depth_stencil */ + +#ifndef GL_NV_read_stencil +#define GL_NV_read_stencil 1 +#endif /* GL_NV_read_stencil */ + +#ifndef GL_NV_representative_fragment_test +#define GL_NV_representative_fragment_test 1 +#define GL_REPRESENTATIVE_FRAGMENT_TEST_NV 0x937F +#endif /* GL_NV_representative_fragment_test */ + +#ifndef GL_NV_sRGB_formats +#define GL_NV_sRGB_formats 1 +#define GL_SLUMINANCE_NV 0x8C46 +#define GL_SLUMINANCE_ALPHA_NV 0x8C44 +#define GL_SRGB8_NV 0x8C41 +#define GL_SLUMINANCE8_NV 0x8C47 +#define GL_SLUMINANCE8_ALPHA8_NV 0x8C45 +#define GL_COMPRESSED_SRGB_S3TC_DXT1_NV 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV 0x8C4F +#define GL_ETC1_SRGB8_NV 0x88EE +#endif /* GL_NV_sRGB_formats */ + +#ifndef GL_NV_sample_locations +#define GL_NV_sample_locations 1 +#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_NV 0x933D +#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_NV 0x933E +#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_NV 0x933F +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_NV 0x9340 +#define GL_SAMPLE_LOCATION_NV 0x8E50 +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9341 +#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_NV 0x9342 +#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_NV 0x9343 +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLRESOLVEDEPTHVALUESNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferSampleLocationsfvNV (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +GL_APICALL void GL_APIENTRY glNamedFramebufferSampleLocationsfvNV (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +GL_APICALL void GL_APIENTRY glResolveDepthValuesNV (void); +#endif +#endif /* GL_NV_sample_locations */ + +#ifndef GL_NV_sample_mask_override_coverage +#define GL_NV_sample_mask_override_coverage 1 +#endif /* GL_NV_sample_mask_override_coverage */ + +#ifndef GL_NV_scissor_exclusive +#define GL_NV_scissor_exclusive 1 +#define GL_SCISSOR_TEST_EXCLUSIVE_NV 0x9555 +#define GL_SCISSOR_BOX_EXCLUSIVE_NV 0x9556 +typedef void (GL_APIENTRYP PFNGLSCISSOREXCLUSIVENVPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLSCISSOREXCLUSIVEARRAYVNVPROC) (GLuint first, GLsizei count, const GLint *v); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glScissorExclusiveNV (GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glScissorExclusiveArrayvNV (GLuint first, GLsizei count, const GLint *v); +#endif +#endif /* GL_NV_scissor_exclusive */ + +#ifndef GL_NV_shader_atomic_fp16_vector +#define GL_NV_shader_atomic_fp16_vector 1 +#endif /* GL_NV_shader_atomic_fp16_vector */ + +#ifndef GL_NV_shader_noperspective_interpolation +#define GL_NV_shader_noperspective_interpolation 1 +#endif /* GL_NV_shader_noperspective_interpolation */ + +#ifndef GL_NV_shader_subgroup_partitioned +#define GL_NV_shader_subgroup_partitioned 1 +#define GL_SUBGROUP_FEATURE_PARTITIONED_BIT_NV 0x00000100 +#endif /* GL_NV_shader_subgroup_partitioned */ + +#ifndef GL_NV_shader_texture_footprint +#define GL_NV_shader_texture_footprint 1 +#endif /* GL_NV_shader_texture_footprint */ + +#ifndef GL_NV_shading_rate_image +#define GL_NV_shading_rate_image 1 +#define GL_SHADING_RATE_IMAGE_NV 0x9563 +#define GL_SHADING_RATE_NO_INVOCATIONS_NV 0x9564 +#define GL_SHADING_RATE_1_INVOCATION_PER_PIXEL_NV 0x9565 +#define GL_SHADING_RATE_1_INVOCATION_PER_1X2_PIXELS_NV 0x9566 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X1_PIXELS_NV 0x9567 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X2_PIXELS_NV 0x9568 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X4_PIXELS_NV 0x9569 +#define GL_SHADING_RATE_1_INVOCATION_PER_4X2_PIXELS_NV 0x956A +#define GL_SHADING_RATE_1_INVOCATION_PER_4X4_PIXELS_NV 0x956B +#define GL_SHADING_RATE_2_INVOCATIONS_PER_PIXEL_NV 0x956C +#define GL_SHADING_RATE_4_INVOCATIONS_PER_PIXEL_NV 0x956D +#define GL_SHADING_RATE_8_INVOCATIONS_PER_PIXEL_NV 0x956E +#define GL_SHADING_RATE_16_INVOCATIONS_PER_PIXEL_NV 0x956F +#define GL_SHADING_RATE_IMAGE_BINDING_NV 0x955B +#define GL_SHADING_RATE_IMAGE_TEXEL_WIDTH_NV 0x955C +#define GL_SHADING_RATE_IMAGE_TEXEL_HEIGHT_NV 0x955D +#define GL_SHADING_RATE_IMAGE_PALETTE_SIZE_NV 0x955E +#define GL_MAX_COARSE_FRAGMENT_SAMPLES_NV 0x955F +#define GL_SHADING_RATE_SAMPLE_ORDER_DEFAULT_NV 0x95AE +#define GL_SHADING_RATE_SAMPLE_ORDER_PIXEL_MAJOR_NV 0x95AF +#define GL_SHADING_RATE_SAMPLE_ORDER_SAMPLE_MAJOR_NV 0x95B0 +typedef void (GL_APIENTRYP PFNGLBINDSHADINGRATEIMAGENVPROC) (GLuint texture); +typedef void (GL_APIENTRYP PFNGLGETSHADINGRATEIMAGEPALETTENVPROC) (GLuint viewport, GLuint entry, GLenum *rate); +typedef void (GL_APIENTRYP PFNGLGETSHADINGRATESAMPLELOCATIONIVNVPROC) (GLenum rate, GLuint samples, GLuint index, GLint *location); +typedef void (GL_APIENTRYP PFNGLSHADINGRATEIMAGEBARRIERNVPROC) (GLboolean synchronize); +typedef void (GL_APIENTRYP PFNGLSHADINGRATEIMAGEPALETTENVPROC) (GLuint viewport, GLuint first, GLsizei count, const GLenum *rates); +typedef void (GL_APIENTRYP PFNGLSHADINGRATESAMPLEORDERNVPROC) (GLenum order); +typedef void (GL_APIENTRYP PFNGLSHADINGRATESAMPLEORDERCUSTOMNVPROC) (GLenum rate, GLuint samples, const GLint *locations); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBindShadingRateImageNV (GLuint texture); +GL_APICALL void GL_APIENTRY glGetShadingRateImagePaletteNV (GLuint viewport, GLuint entry, GLenum *rate); +GL_APICALL void GL_APIENTRY glGetShadingRateSampleLocationivNV (GLenum rate, GLuint samples, GLuint index, GLint *location); +GL_APICALL void GL_APIENTRY glShadingRateImageBarrierNV (GLboolean synchronize); +GL_APICALL void GL_APIENTRY glShadingRateImagePaletteNV (GLuint viewport, GLuint first, GLsizei count, const GLenum *rates); +GL_APICALL void GL_APIENTRY glShadingRateSampleOrderNV (GLenum order); +GL_APICALL void GL_APIENTRY glShadingRateSampleOrderCustomNV (GLenum rate, GLuint samples, const GLint *locations); +#endif +#endif /* GL_NV_shading_rate_image */ + +#ifndef GL_NV_shadow_samplers_array +#define GL_NV_shadow_samplers_array 1 +#define GL_SAMPLER_2D_ARRAY_SHADOW_NV 0x8DC4 +#endif /* GL_NV_shadow_samplers_array */ + +#ifndef GL_NV_shadow_samplers_cube +#define GL_NV_shadow_samplers_cube 1 +#define GL_SAMPLER_CUBE_SHADOW_NV 0x8DC5 +#endif /* GL_NV_shadow_samplers_cube */ + +#ifndef GL_NV_stereo_view_rendering +#define GL_NV_stereo_view_rendering 1 +#endif /* GL_NV_stereo_view_rendering */ + +#ifndef GL_NV_texture_border_clamp +#define GL_NV_texture_border_clamp 1 +#define GL_TEXTURE_BORDER_COLOR_NV 0x1004 +#define GL_CLAMP_TO_BORDER_NV 0x812D +#endif /* GL_NV_texture_border_clamp */ + +#ifndef GL_NV_texture_compression_s3tc_update +#define GL_NV_texture_compression_s3tc_update 1 +#endif /* GL_NV_texture_compression_s3tc_update */ + +#ifndef GL_NV_texture_npot_2D_mipmap +#define GL_NV_texture_npot_2D_mipmap 1 +#endif /* GL_NV_texture_npot_2D_mipmap */ + +#ifndef GL_NV_viewport_array +#define GL_NV_viewport_array 1 +#define GL_MAX_VIEWPORTS_NV 0x825B +#define GL_VIEWPORT_SUBPIXEL_BITS_NV 0x825C +#define GL_VIEWPORT_BOUNDS_RANGE_NV 0x825D +#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX_NV 0x825F +typedef void (GL_APIENTRYP PFNGLVIEWPORTARRAYVNVPROC) (GLuint first, GLsizei count, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVIEWPORTINDEXEDFNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +typedef void (GL_APIENTRYP PFNGLVIEWPORTINDEXEDFVNVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLSCISSORARRAYVNVPROC) (GLuint first, GLsizei count, const GLint *v); +typedef void (GL_APIENTRYP PFNGLSCISSORINDEXEDNVPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLSCISSORINDEXEDVNVPROC) (GLuint index, const GLint *v); +typedef void (GL_APIENTRYP PFNGLDEPTHRANGEARRAYFVNVPROC) (GLuint first, GLsizei count, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLDEPTHRANGEINDEXEDFNVPROC) (GLuint index, GLfloat n, GLfloat f); +typedef void (GL_APIENTRYP PFNGLGETFLOATI_VNVPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (GL_APIENTRYP PFNGLENABLEINVPROC) (GLenum target, GLuint index); +typedef void (GL_APIENTRYP PFNGLDISABLEINVPROC) (GLenum target, GLuint index); +typedef GLboolean (GL_APIENTRYP PFNGLISENABLEDINVPROC) (GLenum target, GLuint index); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glViewportArrayvNV (GLuint first, GLsizei count, const GLfloat *v); +GL_APICALL void GL_APIENTRY glViewportIndexedfNV (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +GL_APICALL void GL_APIENTRY glViewportIndexedfvNV (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glScissorArrayvNV (GLuint first, GLsizei count, const GLint *v); +GL_APICALL void GL_APIENTRY glScissorIndexedNV (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glScissorIndexedvNV (GLuint index, const GLint *v); +GL_APICALL void GL_APIENTRY glDepthRangeArrayfvNV (GLuint first, GLsizei count, const GLfloat *v); +GL_APICALL void GL_APIENTRY glDepthRangeIndexedfNV (GLuint index, GLfloat n, GLfloat f); +GL_APICALL void GL_APIENTRY glGetFloati_vNV (GLenum target, GLuint index, GLfloat *data); +GL_APICALL void GL_APIENTRY glEnableiNV (GLenum target, GLuint index); +GL_APICALL void GL_APIENTRY glDisableiNV (GLenum target, GLuint index); +GL_APICALL GLboolean GL_APIENTRY glIsEnablediNV (GLenum target, GLuint index); +#endif +#endif /* GL_NV_viewport_array */ + +#ifndef GL_NV_viewport_array2 +#define GL_NV_viewport_array2 1 +#endif /* GL_NV_viewport_array2 */ + +#ifndef GL_NV_viewport_swizzle +#define GL_NV_viewport_swizzle 1 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_X_NV 0x9350 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_X_NV 0x9351 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_Y_NV 0x9352 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_Y_NV 0x9353 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_Z_NV 0x9354 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_Z_NV 0x9355 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_W_NV 0x9356 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_W_NV 0x9357 +#define GL_VIEWPORT_SWIZZLE_X_NV 0x9358 +#define GL_VIEWPORT_SWIZZLE_Y_NV 0x9359 +#define GL_VIEWPORT_SWIZZLE_Z_NV 0x935A +#define GL_VIEWPORT_SWIZZLE_W_NV 0x935B +typedef void (GL_APIENTRYP PFNGLVIEWPORTSWIZZLENVPROC) (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glViewportSwizzleNV (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); +#endif +#endif /* GL_NV_viewport_swizzle */ + +#ifndef GL_OVR_multiview +#define GL_OVR_multiview 1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR 0x9630 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR 0x9632 +#define GL_MAX_VIEWS_OVR 0x9631 +#define GL_FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR 0x9633 +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferTextureMultiviewOVR (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); +#endif +#endif /* GL_OVR_multiview */ + +#ifndef GL_OVR_multiview2 +#define GL_OVR_multiview2 1 +#endif /* GL_OVR_multiview2 */ + +#ifndef GL_OVR_multiview_multisampled_render_to_texture +#define GL_OVR_multiview_multisampled_render_to_texture 1 +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTUREMULTISAMPLEMULTIVIEWOVRPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLsizei samples, GLint baseViewIndex, GLsizei numViews); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferTextureMultisampleMultiviewOVR (GLenum target, GLenum attachment, GLuint texture, GLint level, GLsizei samples, GLint baseViewIndex, GLsizei numViews); +#endif +#endif /* GL_OVR_multiview_multisampled_render_to_texture */ + +#ifndef GL_QCOM_YUV_texture_gather +#define GL_QCOM_YUV_texture_gather 1 +#endif /* GL_QCOM_YUV_texture_gather */ + +#ifndef GL_QCOM_alpha_test +#define GL_QCOM_alpha_test 1 +#define GL_ALPHA_TEST_QCOM 0x0BC0 +#define GL_ALPHA_TEST_FUNC_QCOM 0x0BC1 +#define GL_ALPHA_TEST_REF_QCOM 0x0BC2 +typedef void (GL_APIENTRYP PFNGLALPHAFUNCQCOMPROC) (GLenum func, GLclampf ref); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glAlphaFuncQCOM (GLenum func, GLclampf ref); +#endif +#endif /* GL_QCOM_alpha_test */ + +#ifndef GL_QCOM_binning_control +#define GL_QCOM_binning_control 1 +#define GL_BINNING_CONTROL_HINT_QCOM 0x8FB0 +#define GL_CPU_OPTIMIZED_QCOM 0x8FB1 +#define GL_GPU_OPTIMIZED_QCOM 0x8FB2 +#define GL_RENDER_DIRECT_TO_FRAMEBUFFER_QCOM 0x8FB3 +#endif /* GL_QCOM_binning_control */ + +#ifndef GL_QCOM_driver_control +#define GL_QCOM_driver_control 1 +typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSQCOMPROC) (GLint *num, GLsizei size, GLuint *driverControls); +typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSTRINGQCOMPROC) (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString); +typedef void (GL_APIENTRYP PFNGLENABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl); +typedef void (GL_APIENTRYP PFNGLDISABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetDriverControlsQCOM (GLint *num, GLsizei size, GLuint *driverControls); +GL_APICALL void GL_APIENTRY glGetDriverControlStringQCOM (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString); +GL_APICALL void GL_APIENTRY glEnableDriverControlQCOM (GLuint driverControl); +GL_APICALL void GL_APIENTRY glDisableDriverControlQCOM (GLuint driverControl); +#endif +#endif /* GL_QCOM_driver_control */ + +#ifndef GL_QCOM_extended_get +#define GL_QCOM_extended_get 1 +#define GL_TEXTURE_WIDTH_QCOM 0x8BD2 +#define GL_TEXTURE_HEIGHT_QCOM 0x8BD3 +#define GL_TEXTURE_DEPTH_QCOM 0x8BD4 +#define GL_TEXTURE_INTERNAL_FORMAT_QCOM 0x8BD5 +#define GL_TEXTURE_FORMAT_QCOM 0x8BD6 +#define GL_TEXTURE_TYPE_QCOM 0x8BD7 +#define GL_TEXTURE_IMAGE_VALID_QCOM 0x8BD8 +#define GL_TEXTURE_NUM_LEVELS_QCOM 0x8BD9 +#define GL_TEXTURE_TARGET_QCOM 0x8BDA +#define GL_TEXTURE_OBJECT_VALID_QCOM 0x8BDB +#define GL_STATE_RESTORE 0x8BDC +typedef void (GL_APIENTRYP PFNGLEXTGETTEXTURESQCOMPROC) (GLuint *textures, GLint maxTextures, GLint *numTextures); +typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERSQCOMPROC) (GLuint *buffers, GLint maxBuffers, GLint *numBuffers); +typedef void (GL_APIENTRYP PFNGLEXTGETRENDERBUFFERSQCOMPROC) (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers); +typedef void (GL_APIENTRYP PFNGLEXTGETFRAMEBUFFERSQCOMPROC) (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers); +typedef void (GL_APIENTRYP PFNGLEXTGETTEXLEVELPARAMETERIVQCOMPROC) (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLEXTTEXOBJECTSTATEOVERRIDEIQCOMPROC) (GLenum target, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLEXTGETTEXSUBIMAGEQCOMPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, void *texels); +typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERPOINTERVQCOMPROC) (GLenum target, void **params); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glExtGetTexturesQCOM (GLuint *textures, GLint maxTextures, GLint *numTextures); +GL_APICALL void GL_APIENTRY glExtGetBuffersQCOM (GLuint *buffers, GLint maxBuffers, GLint *numBuffers); +GL_APICALL void GL_APIENTRY glExtGetRenderbuffersQCOM (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers); +GL_APICALL void GL_APIENTRY glExtGetFramebuffersQCOM (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers); +GL_APICALL void GL_APIENTRY glExtGetTexLevelParameterivQCOM (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glExtTexObjectStateOverrideiQCOM (GLenum target, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glExtGetTexSubImageQCOM (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, void *texels); +GL_APICALL void GL_APIENTRY glExtGetBufferPointervQCOM (GLenum target, void **params); +#endif +#endif /* GL_QCOM_extended_get */ + +#ifndef GL_QCOM_extended_get2 +#define GL_QCOM_extended_get2 1 +typedef void (GL_APIENTRYP PFNGLEXTGETSHADERSQCOMPROC) (GLuint *shaders, GLint maxShaders, GLint *numShaders); +typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMSQCOMPROC) (GLuint *programs, GLint maxPrograms, GLint *numPrograms); +typedef GLboolean (GL_APIENTRYP PFNGLEXTISPROGRAMBINARYQCOMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMBINARYSOURCEQCOMPROC) (GLuint program, GLenum shadertype, GLchar *source, GLint *length); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glExtGetShadersQCOM (GLuint *shaders, GLint maxShaders, GLint *numShaders); +GL_APICALL void GL_APIENTRY glExtGetProgramsQCOM (GLuint *programs, GLint maxPrograms, GLint *numPrograms); +GL_APICALL GLboolean GL_APIENTRY glExtIsProgramBinaryQCOM (GLuint program); +GL_APICALL void GL_APIENTRY glExtGetProgramBinarySourceQCOM (GLuint program, GLenum shadertype, GLchar *source, GLint *length); +#endif +#endif /* GL_QCOM_extended_get2 */ + +#ifndef GL_QCOM_framebuffer_foveated +#define GL_QCOM_framebuffer_foveated 1 +#define GL_FOVEATION_ENABLE_BIT_QCOM 0x00000001 +#define GL_FOVEATION_SCALED_BIN_METHOD_BIT_QCOM 0x00000002 +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERFOVEATIONCONFIGQCOMPROC) (GLuint framebuffer, GLuint numLayers, GLuint focalPointsPerLayer, GLuint requestedFeatures, GLuint *providedFeatures); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERFOVEATIONPARAMETERSQCOMPROC) (GLuint framebuffer, GLuint layer, GLuint focalPoint, GLfloat focalX, GLfloat focalY, GLfloat gainX, GLfloat gainY, GLfloat foveaArea); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferFoveationConfigQCOM (GLuint framebuffer, GLuint numLayers, GLuint focalPointsPerLayer, GLuint requestedFeatures, GLuint *providedFeatures); +GL_APICALL void GL_APIENTRY glFramebufferFoveationParametersQCOM (GLuint framebuffer, GLuint layer, GLuint focalPoint, GLfloat focalX, GLfloat focalY, GLfloat gainX, GLfloat gainY, GLfloat foveaArea); +#endif +#endif /* GL_QCOM_framebuffer_foveated */ + +#ifndef GL_QCOM_motion_estimation +#define GL_QCOM_motion_estimation 1 +#define GL_MOTION_ESTIMATION_SEARCH_BLOCK_X_QCOM 0x8C90 +#define GL_MOTION_ESTIMATION_SEARCH_BLOCK_Y_QCOM 0x8C91 +typedef void (GL_APIENTRYP PFNGLTEXESTIMATEMOTIONQCOMPROC) (GLuint ref, GLuint target, GLuint output); +typedef void (GL_APIENTRYP PFNGLTEXESTIMATEMOTIONREGIONSQCOMPROC) (GLuint ref, GLuint target, GLuint output, GLuint mask); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexEstimateMotionQCOM (GLuint ref, GLuint target, GLuint output); +GL_APICALL void GL_APIENTRY glTexEstimateMotionRegionsQCOM (GLuint ref, GLuint target, GLuint output, GLuint mask); +#endif +#endif /* GL_QCOM_motion_estimation */ + +#ifndef GL_QCOM_perfmon_global_mode +#define GL_QCOM_perfmon_global_mode 1 +#define GL_PERFMON_GLOBAL_MODE_QCOM 0x8FA0 +#endif /* GL_QCOM_perfmon_global_mode */ + +#ifndef GL_QCOM_shader_framebuffer_fetch_noncoherent +#define GL_QCOM_shader_framebuffer_fetch_noncoherent 1 +#define GL_FRAMEBUFFER_FETCH_NONCOHERENT_QCOM 0x96A2 +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERFETCHBARRIERQCOMPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferFetchBarrierQCOM (void); +#endif +#endif /* GL_QCOM_shader_framebuffer_fetch_noncoherent */ + +#ifndef GL_QCOM_shader_framebuffer_fetch_rate +#define GL_QCOM_shader_framebuffer_fetch_rate 1 +#endif /* GL_QCOM_shader_framebuffer_fetch_rate */ + +#ifndef GL_QCOM_shading_rate +#define GL_QCOM_shading_rate 1 +#define GL_SHADING_RATE_QCOM 0x96A4 +#define GL_SHADING_RATE_PRESERVE_ASPECT_RATIO_QCOM 0x96A5 +#define GL_SHADING_RATE_1X1_PIXELS_QCOM 0x96A6 +#define GL_SHADING_RATE_1X2_PIXELS_QCOM 0x96A7 +#define GL_SHADING_RATE_2X1_PIXELS_QCOM 0x96A8 +#define GL_SHADING_RATE_2X2_PIXELS_QCOM 0x96A9 +#define GL_SHADING_RATE_4X2_PIXELS_QCOM 0x96AC +#define GL_SHADING_RATE_4X4_PIXELS_QCOM 0x96AE +typedef void (GL_APIENTRYP PFNGLSHADINGRATEQCOMPROC) (GLenum rate); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glShadingRateQCOM (GLenum rate); +#endif +#endif /* GL_QCOM_shading_rate */ + +#ifndef GL_QCOM_texture_foveated +#define GL_QCOM_texture_foveated 1 +#define GL_TEXTURE_FOVEATED_FEATURE_BITS_QCOM 0x8BFB +#define GL_TEXTURE_FOVEATED_MIN_PIXEL_DENSITY_QCOM 0x8BFC +#define GL_TEXTURE_FOVEATED_FEATURE_QUERY_QCOM 0x8BFD +#define GL_TEXTURE_FOVEATED_NUM_FOCAL_POINTS_QUERY_QCOM 0x8BFE +#define GL_FRAMEBUFFER_INCOMPLETE_FOVEATION_QCOM 0x8BFF +typedef void (GL_APIENTRYP PFNGLTEXTUREFOVEATIONPARAMETERSQCOMPROC) (GLuint texture, GLuint layer, GLuint focalPoint, GLfloat focalX, GLfloat focalY, GLfloat gainX, GLfloat gainY, GLfloat foveaArea); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTextureFoveationParametersQCOM (GLuint texture, GLuint layer, GLuint focalPoint, GLfloat focalX, GLfloat focalY, GLfloat gainX, GLfloat gainY, GLfloat foveaArea); +#endif +#endif /* GL_QCOM_texture_foveated */ + +#ifndef GL_QCOM_texture_foveated_subsampled_layout +#define GL_QCOM_texture_foveated_subsampled_layout 1 +#define GL_FOVEATION_SUBSAMPLED_LAYOUT_METHOD_BIT_QCOM 0x00000004 +#define GL_MAX_SHADER_SUBSAMPLED_IMAGE_UNITS_QCOM 0x8FA1 +#endif /* GL_QCOM_texture_foveated_subsampled_layout */ + +#ifndef GL_QCOM_tiled_rendering +#define GL_QCOM_tiled_rendering 1 +#define GL_COLOR_BUFFER_BIT0_QCOM 0x00000001 +#define GL_COLOR_BUFFER_BIT1_QCOM 0x00000002 +#define GL_COLOR_BUFFER_BIT2_QCOM 0x00000004 +#define GL_COLOR_BUFFER_BIT3_QCOM 0x00000008 +#define GL_COLOR_BUFFER_BIT4_QCOM 0x00000010 +#define GL_COLOR_BUFFER_BIT5_QCOM 0x00000020 +#define GL_COLOR_BUFFER_BIT6_QCOM 0x00000040 +#define GL_COLOR_BUFFER_BIT7_QCOM 0x00000080 +#define GL_DEPTH_BUFFER_BIT0_QCOM 0x00000100 +#define GL_DEPTH_BUFFER_BIT1_QCOM 0x00000200 +#define GL_DEPTH_BUFFER_BIT2_QCOM 0x00000400 +#define GL_DEPTH_BUFFER_BIT3_QCOM 0x00000800 +#define GL_DEPTH_BUFFER_BIT4_QCOM 0x00001000 +#define GL_DEPTH_BUFFER_BIT5_QCOM 0x00002000 +#define GL_DEPTH_BUFFER_BIT6_QCOM 0x00004000 +#define GL_DEPTH_BUFFER_BIT7_QCOM 0x00008000 +#define GL_STENCIL_BUFFER_BIT0_QCOM 0x00010000 +#define GL_STENCIL_BUFFER_BIT1_QCOM 0x00020000 +#define GL_STENCIL_BUFFER_BIT2_QCOM 0x00040000 +#define GL_STENCIL_BUFFER_BIT3_QCOM 0x00080000 +#define GL_STENCIL_BUFFER_BIT4_QCOM 0x00100000 +#define GL_STENCIL_BUFFER_BIT5_QCOM 0x00200000 +#define GL_STENCIL_BUFFER_BIT6_QCOM 0x00400000 +#define GL_STENCIL_BUFFER_BIT7_QCOM 0x00800000 +#define GL_MULTISAMPLE_BUFFER_BIT0_QCOM 0x01000000 +#define GL_MULTISAMPLE_BUFFER_BIT1_QCOM 0x02000000 +#define GL_MULTISAMPLE_BUFFER_BIT2_QCOM 0x04000000 +#define GL_MULTISAMPLE_BUFFER_BIT3_QCOM 0x08000000 +#define GL_MULTISAMPLE_BUFFER_BIT4_QCOM 0x10000000 +#define GL_MULTISAMPLE_BUFFER_BIT5_QCOM 0x20000000 +#define GL_MULTISAMPLE_BUFFER_BIT6_QCOM 0x40000000 +#define GL_MULTISAMPLE_BUFFER_BIT7_QCOM 0x80000000 +typedef void (GL_APIENTRYP PFNGLSTARTTILINGQCOMPROC) (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask); +typedef void (GL_APIENTRYP PFNGLENDTILINGQCOMPROC) (GLbitfield preserveMask); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glStartTilingQCOM (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask); +GL_APICALL void GL_APIENTRY glEndTilingQCOM (GLbitfield preserveMask); +#endif +#endif /* GL_QCOM_tiled_rendering */ + +#ifndef GL_QCOM_writeonly_rendering +#define GL_QCOM_writeonly_rendering 1 +#define GL_WRITEONLY_RENDERING_QCOM 0x8823 +#endif /* GL_QCOM_writeonly_rendering */ + +#ifndef GL_VIV_shader_binary +#define GL_VIV_shader_binary 1 +#define GL_SHADER_BINARY_VIV 0x8FC4 +#endif /* GL_VIV_shader_binary */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/include/GLES3/gl3.h b/thirdparty/include/GLES3/gl3.h new file mode 100644 index 000000000..374d95794 --- /dev/null +++ b/thirdparty/include/GLES3/gl3.h @@ -0,0 +1,1211 @@ +#ifndef __gles2_gl3_h_ +#define __gles2_gl3_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2013-2018 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are 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 Materials. +** +** THE MATERIALS ARE 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 +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ +/* +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** https://github.com/KhronosGroup/OpenGL-Registry +*/ + +#include + +#ifndef GL_APIENTRYP +#define GL_APIENTRYP GL_APIENTRY* +#endif + +#ifndef GL_GLES_PROTOTYPES +#define GL_GLES_PROTOTYPES 1 +#endif + +/* Generated on date 20200408 */ + +/* Generated C header for: + * API: gles2 + * Profile: common + * Versions considered: 2\.[0-9]|3\.0 + * Versions emitted: .* + * Default extensions included: None + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef GL_ES_VERSION_2_0 +#define GL_ES_VERSION_2_0 1 +#include +typedef khronos_int8_t GLbyte; +typedef khronos_float_t GLclampf; +typedef khronos_int32_t GLfixed; +typedef khronos_int16_t GLshort; +typedef khronos_uint16_t GLushort; +typedef void GLvoid; +typedef struct __GLsync *GLsync; +typedef khronos_int64_t GLint64; +typedef khronos_uint64_t GLuint64; +typedef unsigned int GLenum; +typedef unsigned int GLuint; +typedef char GLchar; +typedef khronos_float_t GLfloat; +typedef khronos_ssize_t GLsizeiptr; +typedef khronos_intptr_t GLintptr; +typedef unsigned int GLbitfield; +typedef int GLint; +typedef unsigned char GLboolean; +typedef int GLsizei; +typedef khronos_uint8_t GLubyte; +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_COLOR_BUFFER_BIT 0x00004000 +#define GL_FALSE 0 +#define GL_TRUE 1 +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 +#define GL_FUNC_ADD 0x8006 +#define GL_BLEND_EQUATION 0x8009 +#define GL_BLEND_EQUATION_RGB 0x8009 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_STREAM_DRAW 0x88E0 +#define GL_STATIC_DRAW 0x88E4 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_FRONT 0x0404 +#define GL_BACK 0x0405 +#define GL_FRONT_AND_BACK 0x0408 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_CULL_FACE 0x0B44 +#define GL_BLEND 0x0BE2 +#define GL_DITHER 0x0BD0 +#define GL_STENCIL_TEST 0x0B90 +#define GL_DEPTH_TEST 0x0B71 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_POLYGON_OFFSET_FILL 0x8037 +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_OUT_OF_MEMORY 0x0505 +#define GL_CW 0x0900 +#define GL_CCW 0x0901 +#define GL_LINE_WIDTH 0x0B21 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_FRONT_FACE 0x0B46 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#define GL_VIEWPORT 0x0BA2 +#define GL_SCISSOR_BOX 0x0C10 +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_RED_BITS 0x0D52 +#define GL_GREEN_BITS 0x0D53 +#define GL_BLUE_BITS 0x0D54 +#define GL_ALPHA_BITS 0x0D55 +#define GL_DEPTH_BITS 0x0D56 +#define GL_STENCIL_BITS 0x0D57 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_INT 0x1404 +#define GL_UNSIGNED_INT 0x1405 +#define GL_FLOAT 0x1406 +#define GL_FIXED 0x140C +#define GL_DEPTH_COMPONENT 0x1902 +#define GL_ALPHA 0x1906 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE_ALPHA 0x190A +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_SHADER_TYPE 0x8B4F +#define GL_DELETE_STATUS 0x8B80 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_NEVER 0x0200 +#define GL_LESS 0x0201 +#define GL_EQUAL 0x0202 +#define GL_LEQUAL 0x0203 +#define GL_GREATER 0x0204 +#define GL_NOTEQUAL 0x0205 +#define GL_GEQUAL 0x0206 +#define GL_ALWAYS 0x0207 +#define GL_KEEP 0x1E00 +#define GL_REPLACE 0x1E01 +#define GL_INCR 0x1E02 +#define GL_DECR 0x1E03 +#define GL_INVERT 0x150A +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 +#define GL_NEAREST 0x2600 +#define GL_LINEAR 0x2601 +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 +#define GL_TEXTURE 0x1702 +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_REPEAT 0x2901 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_COMPILE_STATUS 0x8B81 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RGBA4 0x8056 +#define GL_RGB5_A1 0x8057 +#define GL_RGB565 0x8D62 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_NONE 0 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +typedef void (GL_APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (GL_APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (GL_APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (GL_APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); +typedef void (GL_APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); +typedef void (GL_APIENTRYP PFNGLBINDTEXTUREPROC) (GLenum target, GLuint texture); +typedef void (GL_APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCPROC) (GLenum sfactor, GLenum dfactor); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (GL_APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +typedef void (GL_APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +typedef GLenum (GL_APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLCLEARPROC) (GLbitfield mask); +typedef void (GL_APIENTRYP PFNGLCLEARCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (GL_APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); +typedef void (GL_APIENTRYP PFNGLCLEARSTENCILPROC) (GLint s); +typedef void (GL_APIENTRYP PFNGLCOLORMASKPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +typedef void (GL_APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLCOPYTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef GLuint (GL_APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (GL_APIENTRYP PFNGLCULLFACEPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (GL_APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (GL_APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (GL_APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (GL_APIENTRYP PFNGLDELETETEXTURESPROC) (GLsizei n, const GLuint *textures); +typedef void (GL_APIENTRYP PFNGLDEPTHFUNCPROC) (GLenum func); +typedef void (GL_APIENTRYP PFNGLDEPTHMASKPROC) (GLboolean flag); +typedef void (GL_APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); +typedef void (GL_APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (GL_APIENTRYP PFNGLDISABLEPROC) (GLenum cap); +typedef void (GL_APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices); +typedef void (GL_APIENTRYP PFNGLENABLEPROC) (GLenum cap); +typedef void (GL_APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (GL_APIENTRYP PFNGLFINISHPROC) (void); +typedef void (GL_APIENTRYP PFNGLFLUSHPROC) (void); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (GL_APIENTRYP PFNGLFRONTFACEPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef void (GL_APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef void (GL_APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (GL_APIENTRYP PFNGLGENTEXTURESPROC) (GLsizei n, GLuint *textures); +typedef void (GL_APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +typedef GLint (GL_APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETBOOLEANVPROC) (GLenum pname, GLboolean *data); +typedef void (GL_APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLenum (GL_APIENTRYP PFNGLGETERRORPROC) (void); +typedef void (GL_APIENTRYP PFNGLGETFLOATVPROC) (GLenum pname, GLfloat *data); +typedef void (GL_APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *data); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (GL_APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (GL_APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void (GL_APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef const GLubyte *(GL_APIENTRYP PFNGLGETSTRINGPROC) (GLenum name); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef GLint (GL_APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void **pointer); +typedef void (GL_APIENTRYP PFNGLHINTPROC) (GLenum target, GLenum mode); +typedef GLboolean (GL_APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef GLboolean (GL_APIENTRYP PFNGLISENABLEDPROC) (GLenum cap); +typedef GLboolean (GL_APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); +typedef GLboolean (GL_APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (GL_APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); +typedef GLboolean (GL_APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef GLboolean (GL_APIENTRYP PFNGLISTEXTUREPROC) (GLuint texture); +typedef void (GL_APIENTRYP PFNGLLINEWIDTHPROC) (GLfloat width); +typedef void (GL_APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLPOLYGONOFFSETPROC) (GLfloat factor, GLfloat units); +typedef void (GL_APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); +typedef void (GL_APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); +typedef void (GL_APIENTRYP PFNGLSCISSORPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length); +typedef void (GL_APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +typedef void (GL_APIENTRYP PFNGLSTENCILFUNCPROC) (GLenum func, GLint ref, GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILMASKPROC) (GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILOPPROC) (GLenum fail, GLenum zfail, GLenum zpass); +typedef void (GL_APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (GL_APIENTRYP PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (GL_APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (GL_APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (GL_APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (GL_APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (GL_APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (GL_APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (GL_APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (GL_APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +typedef void (GL_APIENTRYP PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +#if GL_GLES_PROTOTYPES +GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture); +GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader); +GL_APICALL void GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); +GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); +GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); +GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLuint texture); +GL_APICALL void GL_APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GL_APICALL void GL_APIENTRY glBlendEquation (GLenum mode); +GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); +GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); +GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target); +GL_APICALL void GL_APIENTRY glClear (GLbitfield mask); +GL_APICALL void GL_APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GL_APICALL void GL_APIENTRY glClearDepthf (GLfloat d); +GL_APICALL void GL_APIENTRY glClearStencil (GLint s); +GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader); +GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL GLuint GL_APIENTRY glCreateProgram (void); +GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type); +GL_APICALL void GL_APIENTRY glCullFace (GLenum mode); +GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); +GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); +GL_APICALL void GL_APIENTRY glDeleteProgram (GLuint program); +GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); +GL_APICALL void GL_APIENTRY glDeleteShader (GLuint shader); +GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures); +GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func); +GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag); +GL_APICALL void GL_APIENTRY glDepthRangef (GLfloat n, GLfloat f); +GL_APICALL void GL_APIENTRY glDetachShader (GLuint program, GLuint shader); +GL_APICALL void GL_APIENTRY glDisable (GLenum cap); +GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index); +GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); +GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const void *indices); +GL_APICALL void GL_APIENTRY glEnable (GLenum cap); +GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index); +GL_APICALL void GL_APIENTRY glFinish (void); +GL_APICALL void GL_APIENTRY glFlush (void); +GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode); +GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); +GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target); +GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); +GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); +GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint *textures); +GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +GL_APICALL GLint GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); +GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean *data); +GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); +GL_APICALL GLenum GL_APIENTRY glGetError (void); +GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat *data); +GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint *data); +GL_APICALL void GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +GL_APICALL void GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +GL_APICALL const GLubyte *GL_APIENTRY glGetString (GLenum name); +GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); +GL_APICALL GLint GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); +GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer); +GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode); +GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLuint buffer); +GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap); +GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer); +GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program); +GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader); +GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture); +GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width); +GL_APICALL void GL_APIENTRY glLinkProgram (GLuint program); +GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units); +GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); +GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void); +GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); +GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length); +GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask); +GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); +GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); +GL_APICALL void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GL_APICALL void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params); +GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat v0); +GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint v0); +GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); +GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); +GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); +GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUseProgram (GLuint program); +GL_APICALL void GL_APIENTRY glValidateProgram (GLuint program); +GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); +GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); +GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); +#endif +#endif /* GL_ES_VERSION_2_0 */ + +#ifndef GL_ES_VERSION_3_0 +#define GL_ES_VERSION_3_0 1 +typedef khronos_uint16_t GLhalf; +#define GL_READ_BUFFER 0x0C02 +#define GL_UNPACK_ROW_LENGTH 0x0CF2 +#define GL_UNPACK_SKIP_ROWS 0x0CF3 +#define GL_UNPACK_SKIP_PIXELS 0x0CF4 +#define GL_PACK_ROW_LENGTH 0x0D02 +#define GL_PACK_SKIP_ROWS 0x0D03 +#define GL_PACK_SKIP_PIXELS 0x0D04 +#define GL_COLOR 0x1800 +#define GL_DEPTH 0x1801 +#define GL_STENCIL 0x1802 +#define GL_RED 0x1903 +#define GL_RGB8 0x8051 +#define GL_RGBA8 0x8058 +#define GL_RGB10_A2 0x8059 +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_COMPARE_REF_TO_TEXTURE 0x884E +#define GL_MAJOR_VERSION 0x821B +#define GL_MINOR_VERSION 0x821C +#define GL_NUM_EXTENSIONS 0x821D +#define GL_RGBA32F 0x8814 +#define GL_RGB32F 0x8815 +#define GL_RGBA16F 0x881A +#define GL_RGB16F 0x881B +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_MAX_VARYING_COMPONENTS 0x8B4B +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_RGB9_E5 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_RGBA32UI 0x8D70 +#define GL_RGB32UI 0x8D71 +#define GL_RGBA16UI 0x8D76 +#define GL_RGB16UI 0x8D77 +#define GL_RGBA8UI 0x8D7C +#define GL_RGB8UI 0x8D7D +#define GL_RGBA32I 0x8D82 +#define GL_RGB32I 0x8D83 +#define GL_RGBA16I 0x8D88 +#define GL_RGB16I 0x8D89 +#define GL_RGBA8I 0x8D8E +#define GL_RGB8I 0x8D8F +#define GL_RED_INTEGER 0x8D94 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RGBA_INTEGER 0x8D99 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_BUFFER_ACCESS_FLAGS 0x911F +#define GL_BUFFER_MAP_LENGTH 0x9120 +#define GL_BUFFER_MAP_OFFSET 0x9121 +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_COLOR_ATTACHMENT16 0x8CF0 +#define GL_COLOR_ATTACHMENT17 0x8CF1 +#define GL_COLOR_ATTACHMENT18 0x8CF2 +#define GL_COLOR_ATTACHMENT19 0x8CF3 +#define GL_COLOR_ATTACHMENT20 0x8CF4 +#define GL_COLOR_ATTACHMENT21 0x8CF5 +#define GL_COLOR_ATTACHMENT22 0x8CF6 +#define GL_COLOR_ATTACHMENT23 0x8CF7 +#define GL_COLOR_ATTACHMENT24 0x8CF8 +#define GL_COLOR_ATTACHMENT25 0x8CF9 +#define GL_COLOR_ATTACHMENT26 0x8CFA +#define GL_COLOR_ATTACHMENT27 0x8CFB +#define GL_COLOR_ATTACHMENT28 0x8CFC +#define GL_COLOR_ATTACHMENT29 0x8CFD +#define GL_COLOR_ATTACHMENT30 0x8CFE +#define GL_COLOR_ATTACHMENT31 0x8CFF +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#define GL_HALF_FLOAT 0x140B +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_RG8 0x822B +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 +#define GL_COPY_READ_BUFFER 0x8F36 +#define GL_COPY_WRITE_BUFFER 0x8F37 +#define GL_COPY_READ_BUFFER_BINDING 0x8F36 +#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_INVALID_INDEX 0xFFFFFFFFu +#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 +#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_OBJECT_TYPE 0x9112 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_STATUS 0x9114 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_UNSIGNALED 0x9118 +#define GL_SIGNALED 0x9119 +#define GL_ALREADY_SIGNALED 0x911A +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_CONDITION_SATISFIED 0x911C +#define GL_WAIT_FAILED 0x911D +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A +#define GL_SAMPLER_BINDING 0x8919 +#define GL_RGB10_A2UI 0x906F +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_GREEN 0x1904 +#define GL_BLUE 0x1905 +#define GL_INT_2_10_10_10_REV 0x8D9F +#define GL_TRANSFORM_FEEDBACK 0x8E22 +#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 +#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 +#define GL_PROGRAM_BINARY_LENGTH 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE +#define GL_PROGRAM_BINARY_FORMATS 0x87FF +#define GL_COMPRESSED_R11_EAC 0x9270 +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define GL_COMPRESSED_RG11_EAC 0x9272 +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F +#define GL_MAX_ELEMENT_INDEX 0x8D6B +#define GL_NUM_SAMPLE_COUNTS 0x9380 +#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF +typedef void (GL_APIENTRYP PFNGLREADBUFFERPROC) (GLenum src); +typedef void (GL_APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (GL_APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (GL_APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (GL_APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (GL_APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, void **params); +typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void *(GL_APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +typedef void (GL_APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); +typedef void (GL_APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); +typedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); +typedef void (GL_APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); +typedef void (GL_APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); +typedef void (GL_APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); +typedef void (GL_APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (GL_APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (GL_APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +typedef void (GL_APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); +typedef void (GL_APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); +typedef GLint (GL_APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); +typedef void (GL_APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (GL_APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (GL_APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (GL_APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (GL_APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef const GLubyte *(GL_APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); +typedef void (GL_APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (GL_APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +typedef void (GL_APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +typedef GLuint (GL_APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); +typedef void (GL_APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +typedef void (GL_APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); +typedef GLsync (GL_APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (GL_APIENTRYP PFNGLISSYNCPROC) (GLsync sync); +typedef void (GL_APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); +typedef GLenum (GL_APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *data); +typedef void (GL_APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values); +typedef void (GL_APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); +typedef void (GL_APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); +typedef void (GL_APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); +typedef void (GL_APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); +typedef GLboolean (GL_APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); +typedef void (GL_APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); +typedef void (GL_APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); +typedef void (GL_APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); +typedef void (GL_APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (GL_APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); +typedef void (GL_APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); +typedef void (GL_APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +typedef void (GL_APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); +typedef void (GL_APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); +typedef void (GL_APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); +typedef void (GL_APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (GL_APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint *params); +#if GL_GLES_PROTOTYPES +GL_APICALL void GL_APIENTRY glReadBuffer (GLenum src); +GL_APICALL void GL_APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +GL_APICALL void GL_APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glGenQueries (GLsizei n, GLuint *ids); +GL_APICALL void GL_APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); +GL_APICALL GLboolean GL_APIENTRY glIsQuery (GLuint id); +GL_APICALL void GL_APIENTRY glBeginQuery (GLenum target, GLuint id); +GL_APICALL void GL_APIENTRY glEndQuery (GLenum target); +GL_APICALL void GL_APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); +GL_APICALL GLboolean GL_APIENTRY glUnmapBuffer (GLenum target); +GL_APICALL void GL_APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, void **params); +GL_APICALL void GL_APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); +GL_APICALL void GL_APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GL_APICALL void *GL_APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GL_APICALL void GL_APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); +GL_APICALL void GL_APIENTRY glBindVertexArray (GLuint array); +GL_APICALL void GL_APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); +GL_APICALL void GL_APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); +GL_APICALL GLboolean GL_APIENTRY glIsVertexArray (GLuint array); +GL_APICALL void GL_APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); +GL_APICALL void GL_APIENTRY glBeginTransformFeedback (GLenum primitiveMode); +GL_APICALL void GL_APIENTRY glEndTransformFeedback (void); +GL_APICALL void GL_APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GL_APICALL void GL_APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); +GL_APICALL void GL_APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +GL_APICALL void GL_APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GL_APICALL void GL_APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GL_APICALL void GL_APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); +GL_APICALL void GL_APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); +GL_APICALL void GL_APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GL_APICALL void GL_APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); +GL_APICALL void GL_APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); +GL_APICALL void GL_APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); +GL_APICALL GLint GL_APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); +GL_APICALL void GL_APIENTRY glUniform1ui (GLint location, GLuint v0); +GL_APICALL void GL_APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); +GL_APICALL void GL_APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); +GL_APICALL void GL_APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GL_APICALL void GL_APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); +GL_APICALL void GL_APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); +GL_APICALL void GL_APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); +GL_APICALL void GL_APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GL_APICALL const GLubyte *GL_APIENTRY glGetStringi (GLenum name, GLuint index); +GL_APICALL void GL_APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GL_APICALL void GL_APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +GL_APICALL void GL_APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +GL_APICALL GLuint GL_APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); +GL_APICALL void GL_APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +GL_APICALL void GL_APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +GL_APICALL void GL_APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +GL_APICALL void GL_APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); +GL_APICALL GLsync GL_APIENTRY glFenceSync (GLenum condition, GLbitfield flags); +GL_APICALL GLboolean GL_APIENTRY glIsSync (GLsync sync); +GL_APICALL void GL_APIENTRY glDeleteSync (GLsync sync); +GL_APICALL GLenum GL_APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glGetInteger64v (GLenum pname, GLint64 *data); +GL_APICALL void GL_APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values); +GL_APICALL void GL_APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); +GL_APICALL void GL_APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); +GL_APICALL void GL_APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); +GL_APICALL void GL_APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); +GL_APICALL GLboolean GL_APIENTRY glIsSampler (GLuint sampler); +GL_APICALL void GL_APIENTRY glBindSampler (GLuint unit, GLuint sampler); +GL_APICALL void GL_APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); +GL_APICALL void GL_APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); +GL_APICALL void GL_APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); +GL_APICALL void GL_APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); +GL_APICALL void GL_APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); +GL_APICALL void GL_APIENTRY glBindTransformFeedback (GLenum target, GLuint id); +GL_APICALL void GL_APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); +GL_APICALL void GL_APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); +GL_APICALL GLboolean GL_APIENTRY glIsTransformFeedback (GLuint id); +GL_APICALL void GL_APIENTRY glPauseTransformFeedback (void); +GL_APICALL void GL_APIENTRY glResumeTransformFeedback (void); +GL_APICALL void GL_APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +GL_APICALL void GL_APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); +GL_APICALL void GL_APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); +GL_APICALL void GL_APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments); +GL_APICALL void GL_APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GL_APICALL void GL_APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint *params); +#endif +#endif /* GL_ES_VERSION_3_0 */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/include/GLES3/gl3platform.h b/thirdparty/include/GLES3/gl3platform.h new file mode 100644 index 000000000..ca9d7a6de --- /dev/null +++ b/thirdparty/include/GLES3/gl3platform.h @@ -0,0 +1,38 @@ +#ifndef __gl3platform_h_ +#define __gl3platform_h_ + +/* +** Copyright (c) 2017 The Khronos Group Inc. +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +/* Platform-specific types and definitions for OpenGL ES 3.X gl3.h + * + * Adopters may modify khrplatform.h and this file to suit their platform. + * Please contribute modifications back to Khronos as pull requests on the + * public github repository: + * https://github.com/KhronosGroup/OpenGL-Registry + */ + +#include + +#ifndef GL_APICALL +#define GL_APICALL KHRONOS_APICALL +#endif + +#ifndef GL_APIENTRY +#define GL_APIENTRY KHRONOS_APIENTRY +#endif + +#endif /* __gl3platform_h_ */ diff --git a/thirdparty/include/KHR/khrplatform.h b/thirdparty/include/KHR/khrplatform.h new file mode 100644 index 000000000..5b55ea2b9 --- /dev/null +++ b/thirdparty/include/KHR/khrplatform.h @@ -0,0 +1,290 @@ +#ifndef __khrplatform_h_ +#define __khrplatform_h_ + +/* +** Copyright (c) 2008-2018 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are 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 Materials. +** +** THE MATERIALS ARE 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 +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Khronos platform-specific types and definitions. + * + * The master copy of khrplatform.h is maintained in the Khronos EGL + * Registry repository at https://github.com/KhronosGroup/EGL-Registry + * The last semantic modification to khrplatform.h was at commit ID: + * 67a3e0864c2d75ea5287b9f3d2eb74a745936692 + * + * Adopters may modify this file to suit their platform. Adopters are + * encouraged to submit platform specific modifications to the Khronos + * group so that they can be included in future versions of this file. + * Please submit changes by filing pull requests or issues on + * the EGL Registry repository linked above. + * + * + * See the Implementer's Guidelines for information about where this file + * should be located on your system and for more details of its use: + * http://www.khronos.org/registry/implementers_guide.pdf + * + * This file should be included as + * #include + * by Khronos client API header files that use its types and defines. + * + * The types in khrplatform.h should only be used to define API-specific types. + * + * Types defined in khrplatform.h: + * khronos_int8_t signed 8 bit + * khronos_uint8_t unsigned 8 bit + * khronos_int16_t signed 16 bit + * khronos_uint16_t unsigned 16 bit + * khronos_int32_t signed 32 bit + * khronos_uint32_t unsigned 32 bit + * khronos_int64_t signed 64 bit + * khronos_uint64_t unsigned 64 bit + * khronos_intptr_t signed same number of bits as a pointer + * khronos_uintptr_t unsigned same number of bits as a pointer + * khronos_ssize_t signed size + * khronos_usize_t unsigned size + * khronos_float_t signed 32 bit floating point + * khronos_time_ns_t unsigned 64 bit time in nanoseconds + * khronos_utime_nanoseconds_t unsigned time interval or absolute time in + * nanoseconds + * khronos_stime_nanoseconds_t signed time interval in nanoseconds + * khronos_boolean_enum_t enumerated boolean type. This should + * only be used as a base type when a client API's boolean type is + * an enum. Client APIs which use an integer or other type for + * booleans cannot use this as the base type for their boolean. + * + * Tokens defined in khrplatform.h: + * + * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. + * + * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. + * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. + * + * Calling convention macros defined in this file: + * KHRONOS_APICALL + * KHRONOS_APIENTRY + * KHRONOS_APIATTRIBUTES + * + * These may be used in function prototypes as: + * + * KHRONOS_APICALL void KHRONOS_APIENTRY funcname( + * int arg1, + * int arg2) KHRONOS_APIATTRIBUTES; + */ + +#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC) +# define KHRONOS_STATIC 1 +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APICALL + *------------------------------------------------------------------------- + * This precedes the return type of the function in the function prototype. + */ +#if defined(KHRONOS_STATIC) + /* If the preprocessor constant KHRONOS_STATIC is defined, make the + * header compatible with static linking. */ +# define KHRONOS_APICALL +#elif defined(_WIN32) +# define KHRONOS_APICALL __declspec(dllimport) +#elif defined (__SYMBIAN32__) +# define KHRONOS_APICALL IMPORT_C +#elif defined(__ANDROID__) +# define KHRONOS_APICALL __attribute__((visibility("default"))) +#else +# define KHRONOS_APICALL +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APIENTRY + *------------------------------------------------------------------------- + * This follows the return type of the function and precedes the function + * name in the function prototype. + */ +#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(KHRONOS_STATIC) + /* Win32 but not WinCE */ +# define KHRONOS_APIENTRY __stdcall +#else +# define KHRONOS_APIENTRY +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APIATTRIBUTES + *------------------------------------------------------------------------- + * This follows the closing parenthesis of the function prototype arguments. + */ +#if defined (__ARMCC_2__) +#define KHRONOS_APIATTRIBUTES __softfp +#else +#define KHRONOS_APIATTRIBUTES +#endif + +/*------------------------------------------------------------------------- + * basic type definitions + *-----------------------------------------------------------------------*/ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) + + +/* + * Using + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__VMS ) || defined(__sgi) + +/* + * Using + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(_WIN32) && !defined(__SCITECH_SNAP__) + +/* + * Win32 + */ +typedef __int32 khronos_int32_t; +typedef unsigned __int32 khronos_uint32_t; +typedef __int64 khronos_int64_t; +typedef unsigned __int64 khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__sun__) || defined(__digital__) + +/* + * Sun or Digital + */ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#if defined(__arch64__) || defined(_LP64) +typedef long int khronos_int64_t; +typedef unsigned long int khronos_uint64_t; +#else +typedef long long int khronos_int64_t; +typedef unsigned long long int khronos_uint64_t; +#endif /* __arch64__ */ +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif 0 + +/* + * Hypothetical platform with no float or int64 support + */ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#define KHRONOS_SUPPORT_INT64 0 +#define KHRONOS_SUPPORT_FLOAT 0 + +#else + +/* + * Generic fallback + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#endif + + +/* + * Types that are (so far) the same on all platforms + */ +typedef signed char khronos_int8_t; +typedef unsigned char khronos_uint8_t; +typedef signed short int khronos_int16_t; +typedef unsigned short int khronos_uint16_t; + +/* + * Types that differ between LLP64 and LP64 architectures - in LLP64, + * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears + * to be the only LLP64 architecture in current use. + */ +#ifdef _WIN64 +typedef signed long long int khronos_intptr_t; +typedef unsigned long long int khronos_uintptr_t; +typedef signed long long int khronos_ssize_t; +typedef unsigned long long int khronos_usize_t; +#else +typedef signed long int khronos_intptr_t; +typedef unsigned long int khronos_uintptr_t; +typedef signed long int khronos_ssize_t; +typedef unsigned long int khronos_usize_t; +#endif + +#if KHRONOS_SUPPORT_FLOAT +/* + * Float type + */ +typedef float khronos_float_t; +#endif + +#if KHRONOS_SUPPORT_INT64 +/* Time types + * + * These types can be used to represent a time interval in nanoseconds or + * an absolute Unadjusted System Time. Unadjusted System Time is the number + * of nanoseconds since some arbitrary system event (e.g. since the last + * time the system booted). The Unadjusted System Time is an unsigned + * 64 bit value that wraps back to 0 every 584 years. Time intervals + * may be either signed or unsigned. + */ +typedef khronos_uint64_t khronos_utime_nanoseconds_t; +typedef khronos_int64_t khronos_stime_nanoseconds_t; +#endif + +/* + * Dummy value used to pad enum types to 32 bits. + */ +#ifndef KHRONOS_MAX_ENUM +#define KHRONOS_MAX_ENUM 0x7FFFFFFF +#endif + +/* + * Enumerated boolean type + * + * Values other than zero should be considered to be true. Therefore + * comparisons should not be made against KHRONOS_TRUE. + */ +typedef enum { + KHRONOS_FALSE = 0, + KHRONOS_TRUE = 1, + KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM +} khronos_boolean_enum_t; + +#endif /* __khrplatform_h_ */ From fca3d855bd9702811069f7d80babfde7ebabc769 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 19 Apr 2020 01:23:26 +0200 Subject: [PATCH 156/316] Core: Add MovableValue --- include/Nazara/Core/MovableValue.hpp | 38 +++++++++++++++++ include/Nazara/Core/MovableValue.inl | 61 ++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 include/Nazara/Core/MovableValue.hpp create mode 100644 include/Nazara/Core/MovableValue.inl diff --git a/include/Nazara/Core/MovableValue.hpp b/include/Nazara/Core/MovableValue.hpp new file mode 100644 index 000000000..15f22e19b --- /dev/null +++ b/include/Nazara/Core/MovableValue.hpp @@ -0,0 +1,38 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Core module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_MOVABLE_VALUE_HPP +#define NAZARA_MOVABLE_VALUE_HPP + +namespace Nz +{ + template + class MovableValue + { + public: + MovableValue(T value = T{}); + MovableValue(const MovableValue&) = default; + MovableValue(MovableValue&& ptr) noexcept; + ~MovableValue() = default; + + T& Get(); + const T& Get() const; + + operator T&(); + operator const T&() const; + + MovableValue& operator=(T value); + MovableValue& operator=(const MovableValue&) = default; + MovableValue& operator=(MovableValue&& ptr) noexcept; + + private: + T m_value; + }; +} + +#include + +#endif // NAZARA_MOVABLE_VALUE_HPP diff --git a/include/Nazara/Core/MovableValue.inl b/include/Nazara/Core/MovableValue.inl new file mode 100644 index 000000000..520e32a61 --- /dev/null +++ b/include/Nazara/Core/MovableValue.inl @@ -0,0 +1,61 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Core module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + template + MovableValue::MovableValue(T value) : + m_value(std::move(value)) + { + } + + template + MovableValue::MovableValue(MovableValue&& val) noexcept : + m_value() + { + std::swap(m_value, val.m_value); + } + + template + T& MovableValue::Get() + { + return m_value; + } + + template + const T& MovableValue::Get() const + { + return m_value; + } + + template + MovableValue::operator T&() + { + return m_value; + } + + template + MovableValue::operator const T&() const + { + return m_value; + } + + template + MovableValue& MovableValue::operator=(T value) + { + m_value = std::move(value); + + return *this; + } + + template + MovableValue& MovableValue::operator=(MovableValue&& ptr) noexcept + { + std::swap(m_value, ptr.m_value); + return *this; + } +} From 3b24d020e8e6123b79294e25acfbdc006cbe9aba Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 19 Apr 2020 01:24:37 +0200 Subject: [PATCH 157/316] Minor stuff --- include/Nazara/VulkanRenderer/VkRenderWindow.hpp | 2 +- include/Nazara/VulkanRenderer/VulkanSurface.hpp | 2 +- src/Nazara/VulkanRenderer/VulkanSurface.cpp | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp index 25fe36edc..48c796288 100644 --- a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp +++ b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp @@ -40,7 +40,7 @@ namespace Nz VkRenderWindow(); VkRenderWindow(const VkRenderWindow&) = delete; VkRenderWindow(VkRenderWindow&&) = delete; ///TODO - virtual ~VkRenderWindow(); + ~VkRenderWindow(); VulkanRenderImage& Acquire() override; diff --git a/include/Nazara/VulkanRenderer/VulkanSurface.hpp b/include/Nazara/VulkanRenderer/VulkanSurface.hpp index 56505ce8e..147753c65 100644 --- a/include/Nazara/VulkanRenderer/VulkanSurface.hpp +++ b/include/Nazara/VulkanRenderer/VulkanSurface.hpp @@ -20,7 +20,7 @@ namespace Nz VulkanSurface(); VulkanSurface(const VulkanSurface&) = delete; VulkanSurface(VulkanSurface&&) = delete; ///TODO - virtual ~VulkanSurface(); + ~VulkanSurface() = default; bool Create(WindowHandle handle) override; void Destroy() override; diff --git a/src/Nazara/VulkanRenderer/VulkanSurface.cpp b/src/Nazara/VulkanRenderer/VulkanSurface.cpp index c14799f02..fbb9e0ff7 100644 --- a/src/Nazara/VulkanRenderer/VulkanSurface.cpp +++ b/src/Nazara/VulkanRenderer/VulkanSurface.cpp @@ -13,8 +13,6 @@ namespace Nz { } - VulkanSurface::~VulkanSurface() = default; - bool VulkanSurface::Create(WindowHandle handle) { bool success = false; From 0fa095e8f794c097b459a56d83ea3b17fe4a6fe4 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 19 Apr 2020 01:35:19 +0200 Subject: [PATCH 158/316] OpenGL: Rework contexts --- include/Nazara/OpenGLRenderer/Wrapper/.hpp | 39 ------------ include/Nazara/OpenGLRenderer/Wrapper/.inl | 12 ---- .../Nazara/OpenGLRenderer/Wrapper/Context.hpp | 59 +++++++++++++++---- .../Nazara/OpenGLRenderer/Wrapper/Context.inl | 9 +++ .../OpenGLRenderer/Wrapper/CoreFunctions.hpp | 3 + .../OpenGLRenderer/Wrapper/GLContext.hpp | 52 ---------------- .../OpenGLRenderer/Wrapper/GLContext.inl | 12 ---- .../Wrapper/Win32/WGLContext.hpp | 31 +++++++--- .../Wrapper/Win32/WGLContext.inl | 6 +- .../Wrapper/Win32/WGLLoader.hpp | 7 ++- 10 files changed, 93 insertions(+), 137 deletions(-) delete mode 100644 include/Nazara/OpenGLRenderer/Wrapper/.hpp delete mode 100644 include/Nazara/OpenGLRenderer/Wrapper/.inl delete mode 100644 include/Nazara/OpenGLRenderer/Wrapper/GLContext.hpp delete mode 100644 include/Nazara/OpenGLRenderer/Wrapper/GLContext.inl diff --git a/include/Nazara/OpenGLRenderer/Wrapper/.hpp b/include/Nazara/OpenGLRenderer/Wrapper/.hpp deleted file mode 100644 index 8315628db..000000000 --- a/include/Nazara/OpenGLRenderer/Wrapper/.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - OpenGL Renderer" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_OPENGLRENDERER_GLCONTEXT_HPP -#define NAZARA_OPENGLRENDERER_GLCONTEXT_HPP - -#include -#include -#include - -namespace Nz::GL -{ - struct ContextParams - { - - }; - - class GLContext - { - public: - GLContext() = default; - virtual ~GLContext(); - - virtual bool Activate() = 0; - - virtual bool Create(const ContextParams& params) = 0; - - virtual void EnableVerticalSync(bool enabled) = 0; - - virtual void SwapBuffers() = 0; - }; -} - -#include - -#endif diff --git a/include/Nazara/OpenGLRenderer/Wrapper/.inl b/include/Nazara/OpenGLRenderer/Wrapper/.inl deleted file mode 100644 index 4e6fe854b..000000000 --- a/include/Nazara/OpenGLRenderer/Wrapper/.inl +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - OpenGL Renderer" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include - -namespace Nz::Vk -{ -} - -#include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp index 44bef0b02..b2e0427ee 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp @@ -4,28 +4,65 @@ #pragma once -#ifndef NAZARA_OPENGLRENDERER_CONTEXT_HPP -#define NAZARA_OPENGLRENDERER_CONTEXT_HPP +#ifndef NAZARA_OPENGLRENDERER_CONTEXTIMPL_HPP +#define NAZARA_OPENGLRENDERER_CONTEXTIMPL_HPP #include -#include -#include +#include +#include +#include namespace Nz::GL { + enum class ContextType + { + OpenGL, + OpenGL_ES + }; + + struct ContextParams + { + ContextType type = ContextType::OpenGL_ES; + bool doubleBuffering = true; + unsigned int bitsPerPixel = 32; + unsigned int depthBits = 24; + unsigned int glMajorVersion = 0; + unsigned int glMinorVersion = 0; + unsigned int sampleCount = 1; + unsigned int stencilBits = 8; + }; + + class Loader; + class Context { public: Context() = default; - Context(const Context&) = delete; - Context(Context&& object) noexcept = default; - ~Context() = default; + virtual ~Context(); - Context& operator=(const Context&) = delete; - Context& operator=(Context&& object) noexcept = default; + virtual bool Activate() = 0; - private: - std::unique_ptr m_impl; + virtual void EnableVerticalSync(bool enabled) = 0; + + inline const ContextParams& GetParams() const; + + inline bool IsExtensionSupported(const std::string& extension) const; + + bool Initialize(const ContextParams& params); + + virtual void SwapBuffers() = 0; + +#define NAZARA_OPENGLRENDERER_FUNC(name, sig) sig name = nullptr; + NAZARA_OPENGLRENDERER_FOREACH_GLES_FUNC(NAZARA_OPENGLRENDERER_FUNC) +#undef NAZARA_OPENGLRENDERER_FUNC + + protected: + virtual const Loader& GetLoader() = 0; + + virtual bool ImplementFallback(const std::string_view& function) = 0; + + std::unordered_set m_supportedExtensions; + ContextParams m_params; }; } diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Context.inl b/include/Nazara/OpenGLRenderer/Wrapper/Context.inl index b7ef5ca1b..440ef2d38 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Context.inl +++ b/include/Nazara/OpenGLRenderer/Wrapper/Context.inl @@ -7,6 +7,15 @@ namespace Nz::GL { + inline const ContextParams& Context::GetParams() const + { + return m_params; + } + + inline bool Context::IsExtensionSupported(const std::string& extension) const + { + return m_supportedExtensions.find(extension) != m_supportedExtensions.end(); + } } #include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp b/include/Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp index 81f8fbacd..b7794db79 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp @@ -7,6 +7,7 @@ #ifndef NAZARA_OPENGLRENDERER_COREFUNCTIONS_HPP #define NAZARA_OPENGLRENDERER_COREFUNCTIONS_HPP +#define GL_GLES_PROTOTYPES 0 #include // OpenGL core @@ -28,6 +29,7 @@ cb(glBufferSubData, PFNGLBUFFERSUBDATAPROC) \ cb(glClear, PFNGLCLEARPROC) \ cb(glClearColor, PFNGLCLEARCOLORPROC) \ + cb(glClearDepthf, PFNGLCLEARDEPTHFPROC) \ cb(glClearStencil, PFNGLCLEARSTENCILPROC) \ cb(glCreateProgram, PFNGLCREATEPROGRAMPROC) \ cb(glCreateShader, PFNGLCREATESHADERPROC) \ @@ -104,6 +106,7 @@ cb(glSamplerParameterf, PFNGLSAMPLERPARAMETERFPROC) \ cb(glSamplerParameteri, PFNGLSAMPLERPARAMETERIPROC) \ cb(glScissor, PFNGLSCISSORPROC) \ + cb(glShaderBinary, PFNGLSHADERBINARYPROC) \ cb(glShaderSource, PFNGLSHADERSOURCEPROC) \ cb(glStencilFunc, PFNGLSTENCILFUNCPROC) \ cb(glStencilFuncSeparate, PFNGLSTENCILFUNCSEPARATEPROC) \ diff --git a/include/Nazara/OpenGLRenderer/Wrapper/GLContext.hpp b/include/Nazara/OpenGLRenderer/Wrapper/GLContext.hpp deleted file mode 100644 index fba8d88ea..000000000 --- a/include/Nazara/OpenGLRenderer/Wrapper/GLContext.hpp +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - OpenGL Renderer" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_OPENGLRENDERER_CONTEXTIMPL_HPP -#define NAZARA_OPENGLRENDERER_CONTEXTIMPL_HPP - -#include -#include -#include - -namespace Nz::GL -{ - struct ContextParams - { - bool doubleBuffering = true; - unsigned int sampleCount = 1; - unsigned int bitsPerPixel = 32; - unsigned int depthBits = 24; - unsigned int stencilBits = 8; - }; - - class Loader; - - class GLContext - { - public: - GLContext() = default; - virtual ~GLContext(); - - virtual bool Activate() = 0; - - virtual bool Create(const ContextParams& params) = 0; - - virtual void EnableVerticalSync(bool enabled) = 0; - - bool LoadCoreFunctions(Loader& loader); - - virtual void SwapBuffers() = 0; - - private: -#define NAZARA_OPENGLRENDERER_FUNC(name, sig) sig name = nullptr; - NAZARA_OPENGLRENDERER_FOREACH_GLES_FUNC(NAZARA_OPENGLRENDERER_FUNC) -#undef NAZARA_OPENGLRENDERER_FUNC - }; -} - -#include - -#endif diff --git a/include/Nazara/OpenGLRenderer/Wrapper/GLContext.inl b/include/Nazara/OpenGLRenderer/Wrapper/GLContext.inl deleted file mode 100644 index 4e6fe854b..000000000 --- a/include/Nazara/OpenGLRenderer/Wrapper/GLContext.inl +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - OpenGL Renderer" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include - -namespace Nz::Vk -{ -} - -#include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.hpp index 553600ce4..3280f7a28 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.hpp @@ -9,8 +9,8 @@ #include #include -#include -#include +#include +#include #include #include #include @@ -23,30 +23,37 @@ namespace Nz::GL { class WGLLoader; - class WGLContext : public GLContext + class WGLContext : public Context { public: - WGLContext(WGLLoader& loader); + WGLContext(const WGLLoader& loader); WGLContext(const WGLContext&) = delete; WGLContext(WGLContext&&) = delete; ~WGLContext(); bool Activate() override; - bool Create(const ContextParams& params) override; + bool Create(const WGLContext* baseContext, const ContextParams& params, const WGLContext* shareContext = nullptr); + bool Create(const WGLContext* baseContext, const ContextParams& params, WindowHandle window, const WGLContext* shareContext = nullptr); void Destroy(); void EnableVerticalSync(bool enabled) override; + inline bool HasPlatformExtension(const std::string& str) const; + void SwapBuffers() override; WGLContext& operator=(const WGLContext&) = delete; WGLContext& operator=(WGLContext&&) = delete; private: + bool CreateInternal(const WGLContext* baseContext, const ContextParams& params, const WGLContext* shareContext = nullptr); + bool ImplementFallback(const std::string_view& function) override; + void Desactivate(); + const Loader& GetLoader() override; bool LoadWGLExt(); - bool SetPixelFormat(const ContextParams& params); + bool SetPixelFormat(); #define NAZARA_OPENGLRENDERER_FUNC(name, sig) #define NAZARA_OPENGLRENDERER_EXT_BEGIN(ext) @@ -58,8 +65,16 @@ namespace Nz::GL #undef NAZARA_OPENGLRENDERER_EXT_FUNC #undef NAZARA_OPENGLRENDERER_FUNC - std::unordered_set m_supportedExtensions; - WGLLoader& m_loader; + struct Fallback + { + using glClearDepthProc = void(*)(double depth); + + glClearDepthProc glClearDepth; + }; + Fallback fallbacks; //< m_ omitted + + std::unordered_set m_supportedPlatformExtensions; + const WGLLoader& m_loader; HDC m_deviceContext; HGLRC m_handle; HWNDHandle m_window; diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.inl b/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.inl index 70a9d82df..a4bdc6bda 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.inl +++ b/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.inl @@ -5,8 +5,12 @@ #include #include -namespace Nz::Vk +namespace Nz::GL { + inline bool WGLContext::HasPlatformExtension(const std::string& str) const + { + return m_supportedPlatformExtensions.find(str) != m_supportedPlatformExtensions.end(); + } } #include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.hpp index 4a5b6a57a..a733233af 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #undef WIN32_LEAN_AND_MEAN //< Redefined by OpenGL header (ty Khronos) @@ -23,9 +24,10 @@ namespace Nz::GL WGLLoader(DynLib& openglLib); ~WGLLoader() = default; - std::unique_ptr CreateContext() override; + std::unique_ptr CreateContext(const ContextParams& params, Context* shareContext) const override; + std::unique_ptr CreateContext(const ContextParams& params, WindowHandle handle, Context* shareContext) const override; - GLFunction LoadFunction(const char* name) override; + GLFunction LoadFunction(const char* name) const override; #define NAZARA_OPENGLRENDERER_FUNC(name, sig) sig name = nullptr; #define NAZARA_OPENGLRENDERER_EXT_BEGIN(ext) @@ -41,6 +43,7 @@ namespace Nz::GL private: DynLib m_gdi32Lib; DynLib& m_opengl32Lib; + WGLContext m_baseContext; }; } From 5c3eb31d4af2585c1618b36232b12e1e36cbbeee Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 19 Apr 2020 01:36:44 +0200 Subject: [PATCH 159/316] OpenGL: Implement device --- include/Nazara/OpenGLRenderer/OpenGL.hpp | 35 --------- .../Nazara/OpenGLRenderer/OpenGLDevice.hpp | 18 +++-- .../Nazara/OpenGLRenderer/OpenGLDevice.inl | 4 ++ .../Nazara/OpenGLRenderer/OpenGLRenderer.hpp | 11 ++- src/Nazara/OpenGLRenderer/OpenGL.cpp | 72 ------------------- src/Nazara/OpenGLRenderer/OpenGLDevice.cpp | 49 +++++++------ src/Nazara/OpenGLRenderer/OpenGLRenderer.cpp | 51 ++++++++++--- 7 files changed, 97 insertions(+), 143 deletions(-) delete mode 100644 include/Nazara/OpenGLRenderer/OpenGL.hpp delete mode 100644 src/Nazara/OpenGLRenderer/OpenGL.cpp diff --git a/include/Nazara/OpenGLRenderer/OpenGL.hpp b/include/Nazara/OpenGLRenderer/OpenGL.hpp deleted file mode 100644 index 9684f400d..000000000 --- a/include/Nazara/OpenGLRenderer/OpenGL.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - OpenGL Renderer" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_OPENGL_HPP -#define NAZARA_OPENGL_HPP - -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - class OpenGLDevice; - - class NAZARA_OPENGLRENDERER_API OpenGL - { - public: - OpenGL() = delete; - ~OpenGL() = delete; - - static bool Initialize(); - - static bool IsInitialized(); - - static void Uninitialize(); - }; -} - -#endif // NAZARA_OPENGL_HPP diff --git a/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp b/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp index be5426a40..a7d599f98 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp @@ -8,21 +8,27 @@ #define NAZARA_OPENGLRENDERER_OPENGLDEVICE_HPP #include +#include +#include +#include #include -#include -#include #include namespace Nz { - class NAZARA_OPENGLRENDERER_API OpenGLDevice : public RenderDevice, public Vk::Device + class NAZARA_OPENGLRENDERER_API OpenGLDevice : public RenderDevice { public: - using Device::Device; + OpenGLDevice(GL::Loader& loader); OpenGLDevice(const OpenGLDevice&) = delete; OpenGLDevice(OpenGLDevice&&) = delete; ///TODO? ~OpenGLDevice(); + std::unique_ptr CreateContext(const GL::ContextParams& params) const; + std::unique_ptr CreateContext(const GL::ContextParams& params, WindowHandle handle) const; + + inline const GL::Context& GetReferenceContext() const; + std::unique_ptr InstantiateBuffer(BufferType type) override; std::unique_ptr InstantiateCommandPool(QueueType queueType) override; std::unique_ptr InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) override; @@ -33,6 +39,10 @@ namespace Nz OpenGLDevice& operator=(const OpenGLDevice&) = delete; OpenGLDevice& operator=(OpenGLDevice&&) = delete; ///TODO? + + private: + std::unique_ptr m_referenceContext; + GL::Loader& m_loader; }; } diff --git a/include/Nazara/OpenGLRenderer/OpenGLDevice.inl b/include/Nazara/OpenGLRenderer/OpenGLDevice.inl index 42e1a1557..1dc0fe4ac 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLDevice.inl +++ b/include/Nazara/OpenGLRenderer/OpenGLDevice.inl @@ -7,6 +7,10 @@ namespace Nz { + inline const GL::Context& OpenGLDevice::GetReferenceContext() const + { + return *m_referenceContext; + } } #include diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderer.hpp b/include/Nazara/OpenGLRenderer/OpenGLRenderer.hpp index a177ac3b1..c9cb1ac5d 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLRenderer.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderer.hpp @@ -8,10 +8,12 @@ #define NAZARA_OPENGLRENDERER_HPP #include +#include #include #include -#include -#include +#include +#include +#include namespace Nz { @@ -34,6 +36,11 @@ namespace Nz std::vector QueryRenderDevices() const override; bool Prepare(const ParameterList& parameters) override; + + private: + DynLib m_opengl32Lib; + std::shared_ptr m_device; + std::unique_ptr m_loader; }; } diff --git a/src/Nazara/OpenGLRenderer/OpenGL.cpp b/src/Nazara/OpenGLRenderer/OpenGL.cpp deleted file mode 100644 index 7c24521e4..000000000 --- a/src/Nazara/OpenGLRenderer/OpenGL.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - OpenGL Renderer" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include - -#ifdef NAZARA_PLATFORM_WINDOWS -#include -#endif - -#include - -namespace Nz -{ - struct OpenGLImpl - { - DynLib opengl32Lib; - }; - - static std::unique_ptr s_impl; - - bool OpenGL::Initialize() - { - if (s_impl) - return true; - - auto impl = std::make_unique(); - if (!impl->opengl32Lib.Load("opengl32" NAZARA_DYNLIB_EXTENSION)) - { - NazaraError("Failed to load opengl32 library, is OpenGL installed on your system?"); - return false; - } - - std::unique_ptr loader; - -#ifdef NAZARA_PLATFORM_WINDOWS - try - { - loader = std::make_unique(impl->opengl32Lib); - } - catch (const std::exception& e) - { - NazaraWarning(std::string("Failed to load WGL: ") + e.what()); - } -#endif - - if (!loader) - { - NazaraError("Failed to initialize OpenGL loader"); - return false; - } - - s_impl = std::move(impl); - return true; - } - - bool OpenGL::IsInitialized() - { - return s_impl != nullptr; - } - - void OpenGL::Uninitialize() - { - if (!s_impl) - return; - - s_impl.reset(); - } -} - diff --git a/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp b/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp index 37c7ce0cf..4f6402712 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp @@ -2,63 +2,68 @@ // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#if 0 - #include -#include -#include -#include +#include #include -#include -#include +#include +#include #include namespace Nz { + OpenGLDevice::OpenGLDevice(GL::Loader& loader) : + m_loader(loader) + { + m_referenceContext = loader.CreateContext({}); + if (!m_referenceContext) + throw std::runtime_error("failed to create reference context"); + } + OpenGLDevice::~OpenGLDevice() = default; + std::unique_ptr OpenGLDevice::CreateContext(const GL::ContextParams& params) const + { + return m_loader.CreateContext(params, m_referenceContext.get()); + } + + std::unique_ptr OpenGLDevice::CreateContext(const GL::ContextParams& params, WindowHandle handle) const + { + return m_loader.CreateContext(params, handle, m_referenceContext.get()); + } + std::unique_ptr OpenGLDevice::InstantiateBuffer(BufferType type) { - return std::make_unique(*this, type); + return {}; } std::unique_ptr OpenGLDevice::InstantiateCommandPool(QueueType queueType) { - return std::make_unique(*this, queueType); + return {}; } std::unique_ptr OpenGLDevice::InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) { - return std::make_unique(*this, std::move(pipelineInfo)); + return {}; } std::shared_ptr OpenGLDevice::InstantiateRenderPipelineLayout(RenderPipelineLayoutInfo pipelineLayoutInfo) { - auto pipelineLayout = std::make_shared(); - if (!pipelineLayout->Create(*this, std::move(pipelineLayoutInfo))) - return {}; - - return pipelineLayout; + return {}; } std::shared_ptr OpenGLDevice::InstantiateShaderStage(ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) { - auto stage = std::make_shared(); - if (!stage->Create(*this, type, lang, source, sourceSize)) return {}; - return stage; } std::unique_ptr OpenGLDevice::InstantiateTexture(const TextureInfo& params) { - return std::make_unique(*this, params); + return {}; } std::unique_ptr OpenGLDevice::InstantiateTextureSampler(const TextureSamplerInfo& params) { - return std::make_unique(*this, params); + return {}; } } - -#endif diff --git a/src/Nazara/OpenGLRenderer/OpenGLRenderer.cpp b/src/Nazara/OpenGLRenderer/OpenGLRenderer.cpp index 2935ed1b5..535d2f612 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLRenderer.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLRenderer.cpp @@ -7,33 +7,39 @@ #include #include #include -#include +#include +#include #include #include + +#ifdef NAZARA_PLATFORM_WINDOWS +#include +#endif + #include namespace Nz { OpenGLRenderer::~OpenGLRenderer() { - OpenGL::Uninitialize(); + m_device.reset(); + m_loader.reset(); } std::unique_ptr OpenGLRenderer::CreateRenderSurfaceImpl() { - return {}; + return std::make_unique(); } std::unique_ptr OpenGLRenderer::CreateRenderWindowImpl() { - return {}; + return std::make_unique(); } std::shared_ptr OpenGLRenderer::InstanciateRenderDevice(std::size_t deviceIndex) { - //assert(deviceIndex < m_physDevices.size()); - //return OpenGL::SelectDevice(m_physDevices[deviceIndex]); - return {}; + assert(deviceIndex == 0); + return m_device; } bool OpenGLRenderer::IsBetterThan(const RendererImpl* other) const @@ -46,7 +52,36 @@ namespace Nz bool OpenGLRenderer::Prepare(const ParameterList& parameters) { - return OpenGL::Initialize(); + if (!m_opengl32Lib.Load("opengl32" NAZARA_DYNLIB_EXTENSION)) + { + NazaraError("Failed to load opengl32 library, is OpenGL installed on your system?"); + return false; + } + + std::unique_ptr loader; + +#ifdef NAZARA_PLATFORM_WINDOWS + try + { + loader = std::make_unique(m_opengl32Lib); + } + catch (const std::exception& e) + { + NazaraWarning(std::string("Failed to load WGL: ") + e.what()); + } +#endif + + if (!loader) + { + NazaraError("Failed to initialize OpenGL loader"); + return false; + } + + m_loader = std::move(loader); + + m_device = std::make_shared(*m_loader); + + return true; } RenderAPI OpenGLRenderer::QueryAPI() const From 4dc8920a7379231f6ffbd63ea6d8cdc81690127d Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 19 Apr 2020 01:37:56 +0200 Subject: [PATCH 160/316] Implement some classes --- .../Nazara/OpenGLRenderer/DummySurface.hpp | 34 ++ .../{OpenGLSurface.inl => DummySurface.inl} | 6 +- .../OpenGLRenderer/OpenGLCommandBuffer.hpp | 9 +- .../OpenGLRenderer/OpenGLCommandBuffer.inl | 14 - .../OpenGLCommandBufferBuilder.hpp | 12 +- .../OpenGLCommandBufferBuilder.inl | 16 - .../OpenGLRenderer/OpenGLFramebuffer.hpp | 14 +- .../OpenGLRenderer/OpenGLFramebuffer.inl | 9 - .../OpenGLRenderer/OpenGLRenderImage.hpp | 27 +- .../OpenGLRenderer/OpenGLRenderImage.inl | 27 - .../OpenGLRenderer/OpenGLRenderPass.hpp | 11 +- .../OpenGLRenderer/OpenGLRenderPass.inl | 20 - .../OpenGLRenderer/OpenGLRenderWindow.hpp | 61 +-- .../OpenGLRenderer/OpenGLRenderWindow.inl | 40 +- .../Nazara/OpenGLRenderer/OpenGLSurface.hpp | 40 -- .../OpenGLRenderer/OpenGLUploadPool.hpp | 20 +- .../OpenGLRenderer/OpenGLUploadPool.inl | 5 +- .../OpenGLRenderer/OpenGLFramebuffer.cpp | 4 - .../OpenGLRenderer/OpenGLRenderImage.cpp | 70 +-- .../OpenGLRenderer/OpenGLRenderPass.cpp | 4 - .../OpenGLRenderer/OpenGLRenderWindow.cpp | 473 +----------------- .../OpenGLRenderer/OpenGLShaderStage.cpp | 48 +- src/Nazara/OpenGLRenderer/OpenGLSurface.cpp | 49 -- .../OpenGLRenderer/OpenGLUploadPool.cpp | 76 +-- 24 files changed, 138 insertions(+), 951 deletions(-) create mode 100644 include/Nazara/OpenGLRenderer/DummySurface.hpp rename include/Nazara/OpenGLRenderer/{OpenGLSurface.inl => DummySurface.inl} (69%) delete mode 100644 include/Nazara/OpenGLRenderer/OpenGLSurface.hpp delete mode 100644 src/Nazara/OpenGLRenderer/OpenGLSurface.cpp diff --git a/include/Nazara/OpenGLRenderer/DummySurface.hpp b/include/Nazara/OpenGLRenderer/DummySurface.hpp new file mode 100644 index 000000000..10246a9d1 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/DummySurface.hpp @@ -0,0 +1,34 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_SURFACE_HPP +#define NAZARA_OPENGLRENDERER_SURFACE_HPP + +#include +#include +#include + +namespace Nz +{ + class NAZARA_OPENGLRENDERER_API DummySurface : public RenderSurface + { + public: + DummySurface() = default; + ~DummySurface() = default; + + bool Create(WindowHandle handle) override; + void Destroy() override; + + inline WindowHandle GetWindowHandle() const; + + private: + WindowHandle m_handle; + }; +} + +#include + +#endif // NAZARA_OPENGLRENDERER_SURFACE_HPP diff --git a/include/Nazara/OpenGLRenderer/OpenGLSurface.inl b/include/Nazara/OpenGLRenderer/DummySurface.inl similarity index 69% rename from include/Nazara/OpenGLRenderer/OpenGLSurface.inl rename to include/Nazara/OpenGLRenderer/DummySurface.inl index f3af9ae40..fd4f1e5a3 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLSurface.inl +++ b/include/Nazara/OpenGLRenderer/DummySurface.inl @@ -2,14 +2,14 @@ // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include namespace Nz { - inline Vk::Surface& OpenGLSurface::GetSurface() + inline WindowHandle DummySurface::GetWindowHandle() const { - return m_surface; + return m_handle; } } diff --git a/include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.hpp b/include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.hpp index e45f143bc..a597a2958 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.hpp @@ -10,7 +10,6 @@ #include #include #include -#include #include namespace Nz @@ -18,19 +17,13 @@ namespace Nz class NAZARA_OPENGLRENDERER_API OpenGLCommandBuffer final : public CommandBuffer { public: - inline OpenGLCommandBuffer(Vk::AutoCommandBuffer commandBuffer); - inline OpenGLCommandBuffer(std::vector commandBuffers); + inline OpenGLCommandBuffer(); OpenGLCommandBuffer(const OpenGLCommandBuffer&) = delete; OpenGLCommandBuffer(OpenGLCommandBuffer&&) noexcept = default; ~OpenGLCommandBuffer() = default; - inline Vk::CommandBuffer& GetCommandBuffer(std::size_t imageIndex = 0); - OpenGLCommandBuffer& operator=(const OpenGLCommandBuffer&) = delete; OpenGLCommandBuffer& operator=(OpenGLCommandBuffer&&) = delete; - - private: - std::vector m_commandBuffers; }; } diff --git a/include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.inl b/include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.inl index 21a49438e..7ccd4573a 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.inl +++ b/include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.inl @@ -7,20 +7,6 @@ namespace Nz { - inline OpenGLCommandBuffer::OpenGLCommandBuffer(Vk::AutoCommandBuffer commandBuffer) - { - m_commandBuffers.push_back(std::move(commandBuffer)); - } - - inline OpenGLCommandBuffer::OpenGLCommandBuffer(std::vector commandBuffers) : - m_commandBuffers(std::move(commandBuffers)) - { - } - - inline Vk::CommandBuffer& OpenGLCommandBuffer::GetCommandBuffer(std::size_t imageIndex) - { - return m_commandBuffers[imageIndex].Get(); - } } #include diff --git a/include/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.hpp b/include/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.hpp index dce64f6f1..dc50b94d6 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.hpp @@ -10,7 +10,6 @@ #include #include #include -#include namespace Nz { @@ -19,7 +18,7 @@ namespace Nz class NAZARA_OPENGLRENDERER_API OpenGLCommandBufferBuilder final : public CommandBufferBuilder { public: - inline OpenGLCommandBufferBuilder(Vk::CommandBuffer& commandBuffer, std::size_t imageIndex = 0); + OpenGLCommandBufferBuilder() = default; OpenGLCommandBufferBuilder(const OpenGLCommandBufferBuilder&) = delete; OpenGLCommandBufferBuilder(OpenGLCommandBufferBuilder&&) noexcept = default; ~OpenGLCommandBufferBuilder() = default; @@ -41,9 +40,6 @@ namespace Nz void EndDebugRegion() override; void EndRenderPass() override; - inline Vk::CommandBuffer& GetCommandBuffer(); - inline std::size_t GetMaxFramebufferCount() const; - void PreTransferBarrier() override; void PostTransferBarrier() override; @@ -52,12 +48,6 @@ namespace Nz OpenGLCommandBufferBuilder& operator=(const OpenGLCommandBufferBuilder&) = delete; OpenGLCommandBufferBuilder& operator=(OpenGLCommandBufferBuilder&&) = delete; - - private: - Vk::CommandBuffer& m_commandBuffer; - const OpenGLRenderPass* m_currentRenderPass; - std::size_t m_framebufferCount; - std::size_t m_imageIndex; }; } diff --git a/include/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.inl b/include/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.inl index a785ac906..8649e54e2 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.inl +++ b/include/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.inl @@ -7,22 +7,6 @@ namespace Nz { - inline OpenGLCommandBufferBuilder::OpenGLCommandBufferBuilder(Vk::CommandBuffer& commandBuffer, std::size_t imageIndex) : - m_commandBuffer(commandBuffer), - m_framebufferCount(0), - m_imageIndex(imageIndex) - { - } - - inline Vk::CommandBuffer& OpenGLCommandBufferBuilder::GetCommandBuffer() - { - return m_commandBuffer; - } - - inline std::size_t OpenGLCommandBufferBuilder::GetMaxFramebufferCount() const - { - return m_framebufferCount; - } } #include diff --git a/include/Nazara/OpenGLRenderer/OpenGLFramebuffer.hpp b/include/Nazara/OpenGLRenderer/OpenGLFramebuffer.hpp index 2a9a5906a..87198b8c2 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLFramebuffer.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLFramebuffer.hpp @@ -10,31 +10,19 @@ #include #include #include -#include namespace Nz { class NAZARA_OPENGLRENDERER_API OpenGLFramebuffer : public Framebuffer { public: - enum class Type - { - Multiple, - Single - }; - - inline OpenGLFramebuffer(Type type); + OpenGLFramebuffer() = default; OpenGLFramebuffer(const OpenGLFramebuffer&) = delete; OpenGLFramebuffer(OpenGLFramebuffer&&) noexcept = default; ~OpenGLFramebuffer() = default; - inline Type GetType() const; - OpenGLFramebuffer& operator=(const OpenGLFramebuffer&) = delete; OpenGLFramebuffer& operator=(OpenGLFramebuffer&&) noexcept = default; - - private: - Type m_type; }; } diff --git a/include/Nazara/OpenGLRenderer/OpenGLFramebuffer.inl b/include/Nazara/OpenGLRenderer/OpenGLFramebuffer.inl index df37fb3dd..c629eb72a 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLFramebuffer.inl +++ b/include/Nazara/OpenGLRenderer/OpenGLFramebuffer.inl @@ -7,15 +7,6 @@ namespace Nz { - inline OpenGLFramebuffer::OpenGLFramebuffer(Type type) : - m_type(type) - { - } - - inline auto OpenGLFramebuffer::GetType() const -> Type - { - return m_type; - } } #include diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderImage.hpp b/include/Nazara/OpenGLRenderer/OpenGLRenderImage.hpp index fb2b6c30b..def3104e2 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLRenderImage.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderImage.hpp @@ -10,53 +10,34 @@ #include #include #include -#include -#include -#include -#include #include namespace Nz { - class VkRenderWindow; + class OpenGLRenderWindow; class NAZARA_OPENGLRENDERER_API OpenGLRenderImage : public RenderImage { public: - OpenGLRenderImage(VkRenderWindow& owner); + OpenGLRenderImage(OpenGLRenderWindow& owner); OpenGLRenderImage(const OpenGLRenderImage&) = delete; OpenGLRenderImage(OpenGLRenderImage&&) noexcept = default; - ~OpenGLRenderImage(); + ~OpenGLRenderImage() = default; void Execute(const std::function& callback, QueueTypeFlags queueTypeFlags) override; - inline Vk::Fence& GetInFlightFence(); - inline Vk::Semaphore& GetImageAvailableSemaphore(); - inline UInt32 GetImageIndex(); - inline Vk::Semaphore& GetRenderFinishedSemaphore(); OpenGLUploadPool& GetUploadPool() override; void SubmitCommandBuffer(CommandBuffer* commandBuffer, QueueTypeFlags queueTypeFlags) override; - void SubmitCommandBuffer(VkCommandBuffer commandBuffer, QueueTypeFlags queueTypeFlags); void Present() override; - inline void Reset(UInt32 imageIndex); - OpenGLRenderImage& operator=(const OpenGLRenderImage&) = delete; OpenGLRenderImage& operator=(OpenGLRenderImage&&) = delete; private: - std::size_t m_currentCommandBuffer; - std::vector m_inFlightCommandBuffers; - std::vector m_graphicalCommandsBuffers; - VkRenderWindow& m_owner; - Vk::CommandPool m_commandPool; - Vk::Fence m_inFlightFence; - Vk::Semaphore m_imageAvailableSemaphore; - Vk::Semaphore m_renderFinishedSemaphore; + OpenGLRenderWindow& m_owner; OpenGLUploadPool m_uploadPool; - UInt32 m_imageIndex; }; } diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderImage.inl b/include/Nazara/OpenGLRenderer/OpenGLRenderImage.inl index f89800c06..8fffed84c 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLRenderImage.inl +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderImage.inl @@ -7,33 +7,6 @@ namespace Nz { - inline Vk::Fence& Nz::OpenGLRenderImage::GetInFlightFence() - { - return m_inFlightFence; - } - - inline Vk::Semaphore& OpenGLRenderImage::GetImageAvailableSemaphore() - { - return m_imageAvailableSemaphore; - } - - inline UInt32 OpenGLRenderImage::GetImageIndex() - { - return m_imageIndex; - } - - inline Vk::Semaphore& OpenGLRenderImage::GetRenderFinishedSemaphore() - { - return m_renderFinishedSemaphore; - } - - inline void OpenGLRenderImage::Reset(UInt32 imageIndex) - { - m_graphicalCommandsBuffers.clear(); - m_currentCommandBuffer = 0; - m_imageIndex = imageIndex; - m_uploadPool.Reset(); - } } #include diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderPass.hpp b/include/Nazara/OpenGLRenderer/OpenGLRenderPass.hpp index 370835853..8c4ff18cd 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLRenderPass.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderPass.hpp @@ -10,7 +10,6 @@ #include #include #include -#include #include namespace Nz @@ -18,21 +17,13 @@ namespace Nz class NAZARA_OPENGLRENDERER_API OpenGLRenderPass final : public RenderPass { public: - inline OpenGLRenderPass(Vk::RenderPass renderPass, std::initializer_list formats); //< FIXME + OpenGLRenderPass() = default; OpenGLRenderPass(const OpenGLRenderPass&) = delete; OpenGLRenderPass(OpenGLRenderPass&&) noexcept = default; ~OpenGLRenderPass() = default; - inline PixelFormat GetAttachmentFormat(std::size_t attachmentIndex) const; - inline Vk::RenderPass& GetRenderPass(); - inline const Vk::RenderPass& GetRenderPass() const; - OpenGLRenderPass& operator=(const OpenGLRenderPass&) = delete; OpenGLRenderPass& operator=(OpenGLRenderPass&&) noexcept = default; - - private: - std::vector m_formats; - Vk::RenderPass m_renderPass; }; } diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderPass.inl b/include/Nazara/OpenGLRenderer/OpenGLRenderPass.inl index 97bafee02..1c09020a4 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLRenderPass.inl +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderPass.inl @@ -7,26 +7,6 @@ namespace Nz { - inline OpenGLRenderPass::OpenGLRenderPass(Vk::RenderPass renderPass, std::initializer_list formats) : - m_formats(std::begin(formats), std::end(formats)), - m_renderPass(std::move(renderPass)) - { - } - - inline PixelFormat OpenGLRenderPass::GetAttachmentFormat(std::size_t attachmentIndex) const - { - return m_formats[attachmentIndex]; - } - - inline Vk::RenderPass& OpenGLRenderPass::GetRenderPass() - { - return m_renderPass; - } - - inline const Vk::RenderPass& OpenGLRenderPass::GetRenderPass() const - { - return m_renderPass; - } } #include diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp b/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp index 9a057fc0c..f8673cd44 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp @@ -8,27 +8,13 @@ #define NAZARA_OPENGLRENDERER_RENDERWINDOW_HPP #include -#include -#include -#include -#include -#include -#include #include #include -#include +#include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include #include #include @@ -37,54 +23,31 @@ namespace Nz class NAZARA_OPENGLRENDERER_API OpenGLRenderWindow : public RenderWindowImpl { public: - VkRenderWindow(); - VkRenderWindow(const VkRenderWindow&) = delete; - VkRenderWindow(VkRenderWindow&&) = delete; ///TODO - virtual ~VkRenderWindow(); + OpenGLRenderWindow(); + ~OpenGLRenderWindow() = default; OpenGLRenderImage& Acquire() override; bool Create(RendererImpl* renderer, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) override; std::unique_ptr CreateCommandPool(QueueType queueType) override; - inline const OpenGLFramebuffer& GetFramebuffer() const override; - inline OpenGLDevice& GetDevice(); - inline const OpenGLDevice& GetDevice() const; - inline Vk::QueueHandle& GetGraphicsQueue(); + const OpenGLFramebuffer& GetFramebuffer() const override; const OpenGLRenderPass& GetRenderPass() const override; - inline const Vk::Swapchain& GetSwapchain() const; std::shared_ptr GetRenderDevice() override; - void Present(UInt32 imageIndex, VkSemaphore waitSemaphore = VK_NULL_HANDLE); - - VkRenderWindow& operator=(const VkRenderWindow&) = delete; - VkRenderWindow& operator=(VkRenderWindow&&) = delete; ///TODO + void Present(); private: - bool SetupDepthBuffer(const Vector2ui& size); - bool SetupRenderPass(); - bool SetupSwapchain(const Vk::PhysicalDevice& deviceInfo, Vk::Surface& surface, const Vector2ui& size); - std::size_t m_currentFrame; - Clock m_clock; - VkFormat m_depthStencilFormat; - VkSurfaceFormatKHR m_surfaceFormat; - std::optional m_framebuffer; - std::optional m_renderPass; std::shared_ptr m_device; - std::vector m_inflightFences; - std::vector m_concurrentImageData; - Vk::DeviceMemory m_depthBufferMemory; - Vk::Image m_depthBuffer; - Vk::ImageView m_depthBufferView; - Vk::QueueHandle m_graphicsQueue; - Vk::QueueHandle m_presentQueue; - Vk::QueueHandle m_transferQueue; - Vk::Swapchain m_swapchain; + std::vector m_renderImage; + std::unique_ptr m_context; + OpenGLFramebuffer m_framebuffer; + OpenGLRenderPass m_renderPass; }; } -#include +#include #endif // NAZARA_OPENGLRENDERER_RENDERWINDOW_HPP diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.inl b/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.inl index c0e1dd62d..ba24c776a 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.inl +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.inl @@ -2,49 +2,11 @@ // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include namespace Nz { - inline const OpenGLMultipleFramebuffer& VkRenderWindow::GetFramebuffer() const - { - return *m_framebuffer; - } - - inline OpenGLDevice& VkRenderWindow::GetDevice() - { - return *m_device; - } - - inline const OpenGLDevice& VkRenderWindow::GetDevice() const - { - return *m_device; - } - - inline Vk::QueueHandle& VkRenderWindow::GetGraphicsQueue() - { - return m_graphicsQueue; - } - - inline const Vk::Swapchain& VkRenderWindow::GetSwapchain() const - { - return m_swapchain; - } - - inline std::shared_ptr Nz::VkRenderWindow::GetRenderDevice() - { - return m_device; - } - - inline void VkRenderWindow::Present(UInt32 imageIndex, VkSemaphore waitSemaphore) - { - NazaraAssert(imageIndex < m_inflightFences.size(), "Invalid image index"); - - m_presentQueue.Present(m_swapchain, imageIndex, waitSemaphore); - - m_currentFrame = (m_currentFrame + 1) % m_inflightFences.size(); - } } #include diff --git a/include/Nazara/OpenGLRenderer/OpenGLSurface.hpp b/include/Nazara/OpenGLRenderer/OpenGLSurface.hpp deleted file mode 100644 index 235813865..000000000 --- a/include/Nazara/OpenGLRenderer/OpenGLSurface.hpp +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - OpenGL Renderer" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_OPENGLRENDERER_SURFACE_HPP -#define NAZARA_OPENGLRENDERER_SURFACE_HPP - -#include -#include -#include -#include - -namespace Nz -{ - class NAZARA_OPENGLRENDERER_API OpenGLSurface : public RenderSurface - { - public: - OpenGLSurface(); - OpenGLSurface(const OpenGLSurface&) = delete; - OpenGLSurface(OpenGLSurface&&) = delete; ///TODO - virtual ~OpenGLSurface(); - - bool Create(WindowHandle handle) override; - void Destroy() override; - - inline Vk::Surface& GetSurface(); - - OpenGLSurface& operator=(const OpenGLSurface&) = delete; - OpenGLSurface& operator=(OpenGLSurface&&) = delete; ///TODO - - private: - Vk::Surface m_surface; - }; -} - -#include - -#endif // NAZARA_OPENGLRENDERER_SURFACE_HPP diff --git a/include/Nazara/OpenGLRenderer/OpenGLUploadPool.hpp b/include/Nazara/OpenGLRenderer/OpenGLUploadPool.hpp index b668cf5cf..badfd8901 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLUploadPool.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLUploadPool.hpp @@ -9,9 +9,8 @@ #include #include +#include #include -#include -#include #include #include @@ -20,18 +19,13 @@ namespace Nz class NAZARA_OPENGLRENDERER_API OpenGLUploadPool : public UploadPool { public: - struct OpenGLAllocation : Allocation - { - VkBuffer buffer; - }; - - inline OpenGLUploadPool(Vk::Device& device, UInt64 blockSize); + inline OpenGLUploadPool(UInt64 blockSize); OpenGLUploadPool(const OpenGLUploadPool&) = delete; OpenGLUploadPool(OpenGLUploadPool&&) noexcept = default; ~OpenGLUploadPool() = default; - OpenGLAllocation& Allocate(UInt64 size) override; - OpenGLAllocation& Allocate(UInt64 size, UInt64 alignment) override; + Allocation& Allocate(UInt64 size) override; + Allocation& Allocate(UInt64 size, UInt64 alignment) override; void Reset() override; @@ -41,15 +35,11 @@ namespace Nz private: struct Block { - Vk::DeviceMemory blockMemory; - Vk::Buffer buffer; + //< TODO UInt64 freeOffset; }; UInt64 m_blockSize; - Vk::Device& m_device; - std::vector m_blocks; - std::vector m_allocations; }; } diff --git a/include/Nazara/OpenGLRenderer/OpenGLUploadPool.inl b/include/Nazara/OpenGLRenderer/OpenGLUploadPool.inl index 2de0a8237..afb35ba5f 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLUploadPool.inl +++ b/include/Nazara/OpenGLRenderer/OpenGLUploadPool.inl @@ -7,9 +7,8 @@ namespace Nz { - inline OpenGLUploadPool::OpenGLUploadPool(Vk::Device& device, UInt64 blockSize) : - m_blockSize(blockSize), - m_device(device) + inline OpenGLUploadPool::OpenGLUploadPool(UInt64 blockSize) : + m_blockSize(blockSize) { } } diff --git a/src/Nazara/OpenGLRenderer/OpenGLFramebuffer.cpp b/src/Nazara/OpenGLRenderer/OpenGLFramebuffer.cpp index c93488b3c..ffd56e2e3 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLFramebuffer.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLFramebuffer.cpp @@ -2,13 +2,9 @@ // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#if 0 - #include #include namespace Nz { } - -#endif diff --git a/src/Nazara/OpenGLRenderer/OpenGLRenderImage.cpp b/src/Nazara/OpenGLRenderer/OpenGLRenderImage.cpp index b45621dc3..ee6d1500a 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLRenderImage.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLRenderImage.cpp @@ -2,62 +2,21 @@ // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#if 0 - #include -#include -#include -#include +#include #include #include namespace Nz { - OpenGLRenderImage::OpenGLRenderImage(VkRenderWindow& owner) : + OpenGLRenderImage::OpenGLRenderImage(OpenGLRenderWindow& owner) : m_owner(owner), - m_uploadPool(m_owner.GetDevice(), 2 * 1024 * 1024) + m_uploadPool(2 * 1024 * 1024) { - Vk::QueueHandle& graphicsQueue = m_owner.GetGraphicsQueue(); - if (!m_commandPool.Create(m_owner.GetDevice(), graphicsQueue.GetQueueFamilyIndex(), VK_COMMAND_POOL_CREATE_TRANSIENT_BIT | VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)) - throw std::runtime_error("failed to create command pool: " + TranslateOpenGLError(m_commandPool.GetLastErrorCode())); - - if (!m_imageAvailableSemaphore.Create(m_owner.GetDevice())) - throw std::runtime_error("failed to create image available semaphore: " + TranslateOpenGLError(m_imageAvailableSemaphore.GetLastErrorCode())); - - if (!m_renderFinishedSemaphore.Create(m_owner.GetDevice())) - throw std::runtime_error("failed to create image finished semaphore: " + TranslateOpenGLError(m_imageAvailableSemaphore.GetLastErrorCode())); - - if (!m_inFlightFence.Create(m_owner.GetDevice(), VK_FENCE_CREATE_SIGNALED_BIT)) - throw std::runtime_error("failed to create in-flight fence: " + TranslateOpenGLError(m_inFlightFence.GetLastErrorCode())); - } - - OpenGLRenderImage::~OpenGLRenderImage() - { - m_inFlightCommandBuffers.clear(); } void OpenGLRenderImage::Execute(const std::function& callback, QueueTypeFlags queueTypeFlags) { - Vk::CommandBuffer* commandBuffer; - if (m_currentCommandBuffer >= m_inFlightCommandBuffers.size()) - { - Vk::AutoCommandBuffer& newlyAllocatedBuffer = m_inFlightCommandBuffers.emplace_back(m_commandPool.AllocateCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY)); - commandBuffer = &newlyAllocatedBuffer.Get(); - m_currentCommandBuffer++; - } - else - commandBuffer = &m_inFlightCommandBuffers[m_currentCommandBuffer++].Get(); - - if (!commandBuffer->Begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT)) - throw std::runtime_error("failed to begin command buffer: " + TranslateOpenGLError(commandBuffer->GetLastErrorCode())); - - OpenGLCommandBufferBuilder builder(*commandBuffer, m_imageIndex); - callback(builder); - - if (!commandBuffer->End()) - throw std::runtime_error("failed to build command buffer: " + TranslateOpenGLError(commandBuffer->GetLastErrorCode())); - - SubmitCommandBuffer(*commandBuffer, queueTypeFlags); } OpenGLUploadPool& OpenGLRenderImage::GetUploadPool() @@ -67,31 +26,10 @@ namespace Nz void OpenGLRenderImage::SubmitCommandBuffer(CommandBuffer* commandBuffer, QueueTypeFlags queueTypeFlags) { - OpenGLCommandBuffer& vkCommandBuffer = *static_cast(commandBuffer); - - return SubmitCommandBuffer(vkCommandBuffer.GetCommandBuffer(m_imageIndex), queueTypeFlags); - } - - void OpenGLRenderImage::SubmitCommandBuffer(VkCommandBuffer commandBuffer, QueueTypeFlags queueTypeFlags) - { - if (queueTypeFlags & QueueType::Graphics) - m_graphicalCommandsBuffers.push_back(commandBuffer); - else - { - Vk::QueueHandle& graphicsQueue = m_owner.GetGraphicsQueue(); - if (!graphicsQueue.Submit(commandBuffer)) - throw std::runtime_error("Failed to submit command buffer: " + TranslateOpenGLError(graphicsQueue.GetLastErrorCode())); - } } void OpenGLRenderImage::Present() { - Vk::QueueHandle& graphicsQueue = m_owner.GetGraphicsQueue(); - if (!graphicsQueue.Submit(UInt32(m_graphicalCommandsBuffers.size()), m_graphicalCommandsBuffers.data(), m_imageAvailableSemaphore, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, m_renderFinishedSemaphore, m_inFlightFence)) - throw std::runtime_error("Failed to submit command buffers: " + TranslateOpenGLError(graphicsQueue.GetLastErrorCode())); - - m_owner.Present(m_imageIndex, m_renderFinishedSemaphore); + m_owner.Present(); } } - -#endif diff --git a/src/Nazara/OpenGLRenderer/OpenGLRenderPass.cpp b/src/Nazara/OpenGLRenderer/OpenGLRenderPass.cpp index e7c7b8100..57a8f8afd 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLRenderPass.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLRenderPass.cpp @@ -2,13 +2,9 @@ // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#if 0 - #include #include namespace Nz { } - -#endif diff --git a/src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp b/src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp index 0c4df36e7..9799a9dca 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp @@ -2,485 +2,64 @@ // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp -#if 0 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include #include namespace Nz { - VkRenderWindow::VkRenderWindow() : - m_currentFrame(0), - m_depthStencilFormat(VK_FORMAT_MAX_ENUM) + OpenGLRenderWindow::OpenGLRenderWindow() : + m_currentFrame(0) { } - VkRenderWindow::~VkRenderWindow() + OpenGLRenderImage& OpenGLRenderWindow::Acquire() { - if (m_device) - m_device->WaitForIdle(); - - m_concurrentImageData.clear(); - m_renderPass.reset(); - m_framebuffer.reset(); - m_swapchain.Destroy(); + return m_renderImage[m_currentFrame]; } - OpenGLRenderImage& VkRenderWindow::Acquire() + bool OpenGLRenderWindow::Create(RendererImpl* renderer, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) { - OpenGLRenderImage& currentFrame = m_concurrentImageData[m_currentFrame]; - Vk::Fence& inFlightFence = currentFrame.GetInFlightFence(); + DummySurface* dummySurface = static_cast(surface); + OpenGLRenderer* glRenderer = static_cast(renderer); - // Wait until previous rendering to this image has been done - inFlightFence.Wait(); + m_device = std::static_pointer_cast(glRenderer->InstanciateRenderDevice(0)); - UInt32 imageIndex; - if (!m_swapchain.AcquireNextImage(std::numeric_limits::max(), currentFrame.GetImageAvailableSemaphore(), VK_NULL_HANDLE, &imageIndex)) - throw std::runtime_error("Failed to acquire next image: " + TranslateOpenGLError(m_swapchain.GetLastErrorCode())); + GL::ContextParams contextParams; - if (m_inflightFences[imageIndex]) - m_inflightFences[imageIndex]->Wait(); - - m_inflightFences[imageIndex] = &inFlightFence; - m_inflightFences[imageIndex]->Reset(); - - currentFrame.Reset(imageIndex); - - return currentFrame; - } - - bool VkRenderWindow::Create(RendererImpl* /*renderer*/, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) - { - const auto& deviceInfo = OpenGL::GetPhysicalDevices()[0]; - - Vk::Surface& vulkanSurface = static_cast(surface)->GetSurface(); - - UInt32 graphicsFamilyQueueIndex; - UInt32 presentableFamilyQueueIndex; - UInt32 transferFamilyQueueIndex; - m_device = OpenGL::SelectDevice(deviceInfo, vulkanSurface, &graphicsFamilyQueueIndex, &presentableFamilyQueueIndex, &transferFamilyQueueIndex); - if (!m_device) - { - NazaraError("Failed to get compatible OpenGL device"); + m_context = m_device->CreateContext(contextParams, dummySurface->GetWindowHandle()); + if (!m_context) return false; - } - - m_graphicsQueue = m_device->GetQueue(graphicsFamilyQueueIndex, 0); - m_presentQueue = m_device->GetQueue(presentableFamilyQueueIndex, 0); - m_transferQueue = m_device->GetQueue(transferFamilyQueueIndex, 0); - - std::vector surfaceFormats; - if (!vulkanSurface.GetFormats(deviceInfo.physDevice, &surfaceFormats)) - { - NazaraError("Failed to query supported surface formats"); - return false; - } - - m_surfaceFormat = [&] () -> VkSurfaceFormatKHR - { - if (surfaceFormats.size() == 1 && surfaceFormats.front().format == VK_FORMAT_UNDEFINED) - { - // If the list contains one undefined format, it means any format can be used - return { VK_FORMAT_R8G8B8A8_UNORM, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR }; - } - else - { - // Search for RGBA8 and default to first format - for (const VkSurfaceFormatKHR& surfaceFormat : surfaceFormats) - { - if (surfaceFormat.format == VK_FORMAT_R8G8B8A8_UNORM) - return surfaceFormat; - } - - return surfaceFormats.front(); - } - }(); - - if (!parameters.depthFormats.empty()) - { - for (PixelFormat format : parameters.depthFormats) - { - switch (format) - { - case PixelFormat_Depth16: - m_depthStencilFormat = VK_FORMAT_D16_UNORM; - break; - - case PixelFormat_Depth24: - case PixelFormat_Depth24Stencil8: - m_depthStencilFormat = VK_FORMAT_D24_UNORM_S8_UINT; - break; - - case PixelFormat_Depth32: - m_depthStencilFormat = VK_FORMAT_D32_SFLOAT; - break; - - case PixelFormat_Stencil1: - case PixelFormat_Stencil4: - case PixelFormat_Stencil8: - m_depthStencilFormat = VK_FORMAT_S8_UINT; - break; - - case PixelFormat_Stencil16: - m_depthStencilFormat = VK_FORMAT_MAX_ENUM; - break; - - default: - { - PixelFormatContent formatContent = PixelFormatInfo::GetContent(format); - if (formatContent != PixelFormatContent_DepthStencil && formatContent != PixelFormatContent_Stencil) - NazaraWarning("Invalid format " + PixelFormatInfo::GetName(format) + " for depth-stencil attachment"); - - m_depthStencilFormat = VK_FORMAT_MAX_ENUM; - break; - } - } - - if (m_depthStencilFormat != VK_FORMAT_MAX_ENUM) - { - VkFormatProperties formatProperties = m_device->GetInstance().GetPhysicalDeviceFormatProperties(deviceInfo.physDevice, m_depthStencilFormat); - if (formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT) - break; //< Found it - - m_depthStencilFormat = VK_FORMAT_MAX_ENUM; - } - } - } - - if (!SetupSwapchain(deviceInfo, vulkanSurface, size)) - { - NazaraError("Failed to create swapchain"); - return false; - } - - if (m_depthStencilFormat != VK_FORMAT_MAX_ENUM && !SetupDepthBuffer(size)) - { - NazaraError("Failed to create depth buffer"); - return false; - } - - if (!SetupRenderPass()) - { - NazaraError("Failed to create render pass"); - return false; - } - - UInt32 imageCount = m_swapchain.GetBufferCount(); - - // Framebuffers - m_inflightFences.resize(imageCount); - - Nz::StackArray framebuffers = NazaraStackArray(Vk::Framebuffer, imageCount); - for (UInt32 i = 0; i < imageCount; ++i) - { - std::array attachments = { m_swapchain.GetBuffer(i).view, m_depthBufferView }; - - VkFramebufferCreateInfo frameBufferCreate = { - VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, - nullptr, - 0, - m_renderPass->GetRenderPass(), - (attachments[1] != VK_NULL_HANDLE) ? 2U : 1U, - attachments.data(), - size.x, - size.y, - 1U - }; - - if (!framebuffers[i].Create(*m_device, frameBufferCreate)) - { - NazaraError("Failed to create framebuffer for image #" + String::Number(i) + ": " + TranslateOpenGLError(framebuffers[i].GetLastErrorCode())); - return false; - } - } - - m_framebuffer.emplace(framebuffers.data(), framebuffers.size()); - - const std::size_t MaxConcurrentImage = imageCount; - m_concurrentImageData.reserve(MaxConcurrentImage); - - for (std::size_t i = 0; i < MaxConcurrentImage; ++i) - m_concurrentImageData.emplace_back(*this); - - m_clock.Restart(); return true; } - std::unique_ptr VkRenderWindow::CreateCommandPool(QueueType queueType) + std::unique_ptr OpenGLRenderWindow::CreateCommandPool(QueueType queueType) { - UInt32 queueFamilyIndex; - switch (queueType) - { - case QueueType::Compute: - queueFamilyIndex = m_device->GetDefaultFamilyIndex(QueueType::Compute); - break; - - case QueueType::Graphics: - queueFamilyIndex = m_graphicsQueue.GetQueueFamilyIndex(); - break; - - case QueueType::Transfer: - queueFamilyIndex = m_transferQueue.GetQueueFamilyIndex(); - break; - } - - return std::make_unique(*m_device, queueFamilyIndex); + return {}; } - const OpenGLRenderPass& VkRenderWindow::GetRenderPass() const + const OpenGLFramebuffer& OpenGLRenderWindow::GetFramebuffer() const { - return *m_renderPass; + return m_framebuffer; } - bool VkRenderWindow::SetupDepthBuffer(const Vector2ui& size) + const OpenGLRenderPass& OpenGLRenderWindow::GetRenderPass() const { - VkImageCreateInfo imageCreateInfo = { - VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType; - nullptr, // const void* pNext; - 0U, // VkImageCreateFlags flags; - VK_IMAGE_TYPE_2D, // VkImageType imageType; - m_depthStencilFormat, // VkFormat format; - {size.x, size.y, 1U}, // VkExtent3D extent; - 1U, // uint32_t mipLevels; - 1U, // uint32_t arrayLayers; - VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples; - VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling; - VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT, // VkImageUsageFlags usage; - VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode; - 0U, // uint32_t queueFamilyIndexCount; - nullptr, // const uint32_t* pQueueFamilyIndices; - VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout; - }; - - if (!m_depthBuffer.Create(*m_device, imageCreateInfo)) - { - NazaraError("Failed to create depth buffer"); - return false; - } - - VkMemoryRequirements memoryReq = m_depthBuffer.GetMemoryRequirements(); - if (!m_depthBufferMemory.Create(*m_device, memoryReq.size, memoryReq.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)) - { - NazaraError("Failed to allocate depth buffer memory"); - return false; - } - - if (!m_depthBuffer.BindImageMemory(m_depthBufferMemory)) - { - NazaraError("Failed to bind depth buffer to buffer"); - return false; - } - - VkImageViewCreateInfo imageViewCreateInfo = { - VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, // VkStructureType sType; - nullptr, // const void* pNext; - 0, // VkImageViewCreateFlags flags; - m_depthBuffer, // VkImage image; - VK_IMAGE_VIEW_TYPE_2D, // VkImageViewType viewType; - m_depthStencilFormat, // VkFormat format; - { // VkComponentMapping components; - VK_COMPONENT_SWIZZLE_R, // VkComponentSwizzle .r; - VK_COMPONENT_SWIZZLE_G, // VkComponentSwizzle .g; - VK_COMPONENT_SWIZZLE_B, // VkComponentSwizzle .b; - VK_COMPONENT_SWIZZLE_A // VkComponentSwizzle .a; - }, - { // VkImageSubresourceRange subresourceRange; - VK_IMAGE_ASPECT_DEPTH_BIT, // VkImageAspectFlags .aspectMask; - 0, // uint32_t .baseMipLevel; - 1, // uint32_t .levelCount; - 0, // uint32_t .baseArrayLayer; - 1 // uint32_t .layerCount; - } - }; - - if (!m_depthBufferView.Create(*m_device, imageViewCreateInfo)) - { - NazaraError("Failed to create depth buffer view"); - return false; - } - - return true; + return m_renderPass; } - bool VkRenderWindow::SetupRenderPass() + std::shared_ptr OpenGLRenderWindow::GetRenderDevice() { - std::array attachments = { - { - { - 0, // VkAttachmentDescriptionFlags flags; - m_surfaceFormat.format, // VkFormat format; - VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples; - VK_ATTACHMENT_LOAD_OP_CLEAR, // VkAttachmentLoadOp loadOp; - VK_ATTACHMENT_STORE_OP_STORE, // VkAttachmentStoreOp storeOp; - VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp; - VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp; - VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout; - VK_IMAGE_LAYOUT_PRESENT_SRC_KHR // VkImageLayout finalLayout; - }, - { - 0, // VkAttachmentDescriptionFlags flags; - m_depthStencilFormat, // VkFormat format; - VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples; - VK_ATTACHMENT_LOAD_OP_CLEAR, // VkAttachmentLoadOp loadOp; - VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp storeOp; - VK_ATTACHMENT_LOAD_OP_DONT_CARE, // VkAttachmentLoadOp stencilLoadOp; - VK_ATTACHMENT_STORE_OP_DONT_CARE, // VkAttachmentStoreOp stencilStoreOp; - VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout; - VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL // VkImageLayout finalLayout; - }, - } - }; - - VkAttachmentReference colorReference = { - 0, // uint32_t attachment; - VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // VkImageLayout layout; - }; - - VkAttachmentReference depthReference = { - 1, // uint32_t attachment; - VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL // VkImageLayout layout; - }; - - VkSubpassDescription subpass = { - 0, // VkSubpassDescriptionFlags flags; - VK_PIPELINE_BIND_POINT_GRAPHICS, // VkPipelineBindPoint pipelineBindPoint; - 0U, // uint32_t inputAttachmentCount; - nullptr, // const VkAttachmentReference* pInputAttachments; - 1U, // uint32_t colorAttachmentCount; - &colorReference, // const VkAttachmentReference* pColorAttachments; - nullptr, // const VkAttachmentReference* pResolveAttachments; - (m_depthStencilFormat != VK_FORMAT_MAX_ENUM) ? &depthReference : nullptr, // const VkAttachmentReference* pDepthStencilAttachment; - 0U, // uint32_t preserveAttachmentCount; - nullptr // const uint32_t* pPreserveAttachments; - }; - - std::array dependencies; - // First dependency at the start of the render pass - // Does the transition from final to initial layout - dependencies[0].srcSubpass = VK_SUBPASS_EXTERNAL; // Producer of the dependency - dependencies[0].dstSubpass = 0; // Consumer is our single subpass that will wait for the execution dependency - dependencies[0].srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; - dependencies[0].dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; - dependencies[0].srcAccessMask = 0; - dependencies[0].dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; - dependencies[0].dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT; - - // Second dependency at the end the render pass - // Does the transition from the initial to the final layout - dependencies[1].srcSubpass = 0; // Producer of the dependency is our single subpass - dependencies[1].dstSubpass = VK_SUBPASS_EXTERNAL; // Consumer are all commands outside of the render pass - dependencies[1].srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; - dependencies[1].dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT; - dependencies[1].srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; - dependencies[1].dstAccessMask = VK_ACCESS_MEMORY_READ_BIT; - dependencies[1].dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT; - - VkRenderPassCreateInfo createInfo = { - VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, // VkStructureType sType; - nullptr, // const void* pNext; - 0, // VkRenderPassCreateFlags flags; - (m_depthStencilFormat != VK_FORMAT_MAX_ENUM) ? 2U : 1U, // uint32_t attachmentCount; - attachments.data(), // const VkAttachmentDescription* pAttachments; - 1U, // uint32_t subpassCount; - &subpass, // const VkSubpassDescription* pSubpasses; - UInt32(dependencies.size()), // uint32_t dependencyCount; - dependencies.data() // const VkSubpassDependency* pDependencies; - }; - - Vk::RenderPass renderPass; - if (!renderPass.Create(*m_device, createInfo)) - { - NazaraError("Failed to create render pass: " + TranslateOpenGLError(renderPass.GetLastErrorCode())); - return false; - } - - std::initializer_list fixmeplease = { PixelFormat::PixelFormat_RGB8, PixelFormat::PixelFormat_Depth24Stencil8 }; - m_renderPass.emplace(std::move(renderPass), fixmeplease); - return true; + return m_device; } - bool VkRenderWindow::SetupSwapchain(const Vk::PhysicalDevice& deviceInfo, Vk::Surface& surface, const Vector2ui& size) + void OpenGLRenderWindow::Present() { - VkSurfaceCapabilitiesKHR surfaceCapabilities; - if (!surface.GetCapabilities(deviceInfo.physDevice, &surfaceCapabilities)) - { - NazaraError("Failed to query surface capabilities"); - return false; - } - - Nz::UInt32 imageCount = surfaceCapabilities.minImageCount + 1; - if (surfaceCapabilities.maxImageCount > 0 && imageCount > surfaceCapabilities.maxImageCount) - imageCount = surfaceCapabilities.maxImageCount; - - VkExtent2D extent; - if (surfaceCapabilities.currentExtent.width == -1) - { - extent.width = Nz::Clamp(size.x, surfaceCapabilities.minImageExtent.width, surfaceCapabilities.maxImageExtent.width); - extent.height = Nz::Clamp(size.y, surfaceCapabilities.minImageExtent.height, surfaceCapabilities.maxImageExtent.height); - } - else - extent = surfaceCapabilities.currentExtent; - - std::vector presentModes; - if (!surface.GetPresentModes(deviceInfo.physDevice, &presentModes)) - { - NazaraError("Failed to query supported present modes"); - return false; - } - - VkPresentModeKHR swapchainPresentMode = VK_PRESENT_MODE_FIFO_KHR; - for (VkPresentModeKHR presentMode : presentModes) - { - if (presentMode == VK_PRESENT_MODE_MAILBOX_KHR) - { - swapchainPresentMode = VK_PRESENT_MODE_MAILBOX_KHR; - break; - } - - if (presentMode == VK_PRESENT_MODE_IMMEDIATE_KHR) - swapchainPresentMode = VK_PRESENT_MODE_IMMEDIATE_KHR; - } - - VkSwapchainCreateInfoKHR swapchainInfo = { - VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR, - nullptr, - 0, - surface, - imageCount, - m_surfaceFormat.format, - m_surfaceFormat.colorSpace, - extent, - 1, - VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, - VK_SHARING_MODE_EXCLUSIVE, - 0, nullptr, - surfaceCapabilities.currentTransform, - VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR, - swapchainPresentMode, - VK_TRUE, - VK_NULL_HANDLE - }; - - if (!m_swapchain.Create(*m_device, swapchainInfo)) - { - NazaraError("Failed to create swapchain"); - return false; - } - - return true; + m_context->SwapBuffers(); + m_currentFrame = (m_currentFrame + 1) % m_renderImage.size(); } } -#endif diff --git a/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp b/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp index 24c18fd3b..0d8072596 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp @@ -2,30 +2,50 @@ // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#if 0 - #include +#include +#include #include namespace Nz { - bool OpenGLShaderStage::Create(Vk::Device& device, ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) + bool OpenGLShaderStage::Create(OpenGLDevice& device, ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) { - if (lang != ShaderLanguage::SpirV) + if (!m_shader.Create(device, ToOpenGL(type))) + return false; //< TODO: Handle error message + + switch (lang) { - NazaraError("Only Spir-V is supported for now"); + case ShaderLanguage::GLSL: + m_shader.SetSource(reinterpret_cast(source), GLint(sourceSize)); + break; + + case ShaderLanguage::SpirV: + { + if (!device.GetReferenceContext().IsExtensionSupported("GL_ARB_gl_spirv")) + { + NazaraError("Spir-V is not supported"); + return false; + } + + constexpr GLenum SHADER_BINARY_FORMAT_SPIR_V = 0x9551; + + m_shader.SetBinarySource(SHADER_BINARY_FORMAT_SPIR_V, source, GLsizei(sourceSize)); + break; + } + + default: + NazaraError("Unsupported shader language"); + return false; + } + + std::string errorLog; + if (!m_shader.Compile(&errorLog)) + { + NazaraError("Failed to compile shader: " + errorLog); return false; } - if (!m_shaderModule.Create(device, reinterpret_cast(source), sourceSize)) - { - NazaraError("Failed to create shader module"); - return false; - } - - m_stage = type; return true; } } - -#endif diff --git a/src/Nazara/OpenGLRenderer/OpenGLSurface.cpp b/src/Nazara/OpenGLRenderer/OpenGLSurface.cpp deleted file mode 100644 index 74f9bd620..000000000 --- a/src/Nazara/OpenGLRenderer/OpenGLSurface.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - OpenGL Renderer" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#if 0 - -#include -#include -#include - -namespace Nz -{ - OpenGLSurface::OpenGLSurface() : - m_surface(OpenGL::GetInstance()) - { - } - - OpenGLSurface::~OpenGLSurface() = default; - - bool OpenGLSurface::Create(WindowHandle handle) - { - bool success = false; - #if defined(NAZARA_PLATFORM_WINDOWS) - { - HWND winHandle = reinterpret_cast(handle); - HINSTANCE instance = reinterpret_cast(GetWindowLongPtrW(winHandle, GWLP_HINSTANCE)); - - success = m_surface.Create(instance, winHandle); - } - #else - #error This OS is not supported by OpenGL - #endif - - if (!success) - { - NazaraError("Failed to create OpenGL surface: " + TranslateOpenGLError(m_surface.GetLastErrorCode())); - return false; - } - - return true; - } - - void OpenGLSurface::Destroy() - { - m_surface.Destroy(); - } -} - -#endif diff --git a/src/Nazara/OpenGLRenderer/OpenGLUploadPool.cpp b/src/Nazara/OpenGLRenderer/OpenGLUploadPool.cpp index 687988f9b..f16c2335a 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLUploadPool.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLUploadPool.cpp @@ -2,8 +2,6 @@ // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#if 0 - #include #include #include @@ -11,81 +9,25 @@ namespace Nz { - auto OpenGLUploadPool::Allocate(UInt64 size) -> OpenGLAllocation& + auto OpenGLUploadPool::Allocate(UInt64 size) -> Allocation& { - const auto& deviceProperties = m_device.GetPhysicalDeviceInfo().properties; - UInt64 preferredAlignement = deviceProperties.limits.optimalBufferCopyOffsetAlignment; + /*const auto& deviceProperties = m_device.GetPhysicalDeviceInfo().properties; + UInt64 preferredAlignement = deviceProperties.limits.optimalBufferCopyOffsetAlignment;*/ - return Allocate(size, preferredAlignement); + return Allocate(size, 0); //< FIXME } - auto OpenGLUploadPool::Allocate(UInt64 size, UInt64 alignment) -> OpenGLAllocation& + auto OpenGLUploadPool::Allocate(UInt64 size, UInt64 alignment) -> Allocation& { assert(size <= m_blockSize); - // Try to minimize lost space - struct - { - Block* block = nullptr; - UInt64 alignedOffset = 0; - UInt64 lostSpace = 0; - } bestBlock; - - for (Block& block : m_blocks) - { - UInt64 alignedOffset = AlignPow2(block.freeOffset, alignment); - if (alignedOffset + size > m_blockSize) - continue; //< Not enough space - - UInt64 lostSpace = alignedOffset - block.freeOffset; - - if (!bestBlock.block || lostSpace < bestBlock.lostSpace) - { - bestBlock.block = █ - bestBlock.alignedOffset = alignedOffset; - bestBlock.lostSpace = lostSpace; - } - } - - // No block found, allocate a new one - if (!bestBlock.block) - { - Block newBlock; - if (!newBlock.buffer.Create(m_device, 0U, m_blockSize, VK_BUFFER_USAGE_TRANSFER_SRC_BIT)) - throw std::runtime_error("Failed to create block buffer: " + TranslateOpenGLError(newBlock.buffer.GetLastErrorCode())); - - VkMemoryRequirements requirement = newBlock.buffer.GetMemoryRequirements(); - - if (!newBlock.blockMemory.Create(m_device, requirement.size, requirement.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) - throw std::runtime_error("Failed to allocate block memory: " + TranslateOpenGLError(newBlock.blockMemory.GetLastErrorCode())); - - if (!newBlock.buffer.BindBufferMemory(newBlock.blockMemory)) - throw std::runtime_error("Failed to bind buffer memory: " + TranslateOpenGLError(newBlock.buffer.GetLastErrorCode())); - - if (!newBlock.blockMemory.Map()) - throw std::runtime_error("Failed to map buffer memory: " + TranslateOpenGLError(newBlock.buffer.GetLastErrorCode())); - - bestBlock.block = &m_blocks.emplace_back(std::move(newBlock)); - bestBlock.alignedOffset = 0; - bestBlock.lostSpace = 0; - } - - OpenGLAllocation& allocationData = m_allocations.emplace_back(); - allocationData.buffer = bestBlock.block->buffer; - allocationData.mappedPtr = static_cast(bestBlock.block->blockMemory.GetMappedPointer()) + bestBlock.alignedOffset; - allocationData.offset = bestBlock.alignedOffset; - allocationData.size = size; - - return allocationData; + static Allocation dummy; + return dummy; } void OpenGLUploadPool::Reset() { - for (Block& block : m_blocks) - block.freeOffset = 0; - - m_allocations.clear(); + /*for (Block& block : m_blocks) + block.freeOffset = 0;*/ } } - -#endif From 9dd208c3cf0e5bf8419f2abfdeeb48370d59deae Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 19 Apr 2020 01:38:19 +0200 Subject: [PATCH 161/316] OpenGL: Fix contexts & loaders --- .../Nazara/OpenGLRenderer/Wrapper/Loader.hpp | 9 +- src/Nazara/OpenGLRenderer/Wrapper/Context.cpp | 88 ++++++ .../OpenGLRenderer/Wrapper/GLContext.cpp | 44 --- .../Wrapper/Win32/WGLContext.cpp | 273 ++++++++++++------ .../Wrapper/Win32/WGLLoader.cpp | 69 +++-- 5 files changed, 337 insertions(+), 146 deletions(-) delete mode 100644 src/Nazara/OpenGLRenderer/Wrapper/GLContext.cpp diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Loader.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Loader.hpp index ad48aa92e..13eeafb53 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Loader.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Loader.hpp @@ -8,12 +8,14 @@ #define NAZARA_OPENGLRENDERER_LOADER_HPP #include +#include #include +#include #include namespace Nz::GL { - class GLContext; + class Context; using GLFunction = int(*)(); @@ -23,9 +25,10 @@ namespace Nz::GL Loader() = default; virtual ~Loader(); - virtual std::unique_ptr CreateContext() = 0; + virtual std::unique_ptr CreateContext(const ContextParams& params, Context* shareContext = nullptr) const = 0; + virtual std::unique_ptr CreateContext(const ContextParams& params, WindowHandle handle, Context* shareContext = nullptr) const = 0; - virtual GLFunction LoadFunction(const char* name) = 0; + virtual GLFunction LoadFunction(const char* name) const = 0; }; } diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp index 06f4578d0..8c651ff33 100644 --- a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp +++ b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp @@ -3,8 +3,96 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include +#include +#include +#include #include namespace Nz::GL { + Context::~Context() = default; + + bool Context::Initialize(const ContextParams& params) + { + if (!Activate()) + { + NazaraError("failed to activate context"); + return false; + } + + const Loader& loader = GetLoader(); + + auto LoadSymbol = [&](auto& func, const char* funcName) + { + func = reinterpret_cast>(loader.LoadFunction(funcName)); + if (!func && !ImplementFallback(funcName) && !func) //< Not a mistake + throw std::runtime_error("failed to load core function " + std::string(funcName)); + }; + + try + { +#define NAZARA_OPENGLRENDERER_FUNC(name, sig) LoadSymbol(name, #name); + NAZARA_OPENGLRENDERER_FOREACH_GLES_FUNC(NAZARA_OPENGLRENDERER_FUNC) +#undef NAZARA_OPENGLRENDERER_FUNC + } + catch (const std::exception& e) + { + NazaraError(e.what()); + return false; + } + + // Retrieve OpenGL version + auto DecodeDigit = [](char c) -> int + { + if (c >= '0' && c <= '9') + return c - '0'; + else + return -1; + }; + + std::string_view versionString = reinterpret_cast(glGetString(GL_VERSION)); + if (versionString.size() > 2 && DecodeDigit(versionString[0]) >= 0 && versionString[1] == '.' && DecodeDigit(versionString[2]) >= 0) + { + m_params.glMajorVersion = DecodeDigit(versionString[0]); + m_params.glMinorVersion = DecodeDigit(versionString[2]); + } + else + NazaraWarning("Failed to decode OpenGL version: " + std::string(versionString)); + + // Load extensions + std::string_view extensionList = reinterpret_cast(glGetString(GL_EXTENSIONS)); + SplitString(extensionList, " ", [&](std::string_view extension) + { + m_supportedExtensions.emplace(extension); + return true; + }); + + // If we requested an OpenGL ES context but cannot create one, check for some compatibility extensions + if (params.type == ContextType::OpenGL_ES && m_params.type != params.type) + { + if (m_supportedExtensions.count("GL_ARB_ES3_2_compatibility")) + { + m_params.type = ContextType::OpenGL_ES; + m_params.glMajorVersion = 3; + m_params.glMinorVersion = 2; + } + else if (m_supportedExtensions.count("GL_ARB_ES3_1_compatibility")) + { + m_params.type = ContextType::OpenGL_ES; + m_params.glMajorVersion = 3; + m_params.glMinorVersion = 1; + } + else if (m_supportedExtensions.count("GL_ARB_ES3_compatibility")) + { + m_params.type = ContextType::OpenGL_ES; + m_params.glMajorVersion = 3; + m_params.glMinorVersion = 0; + } + else + NazaraWarning("desktop support for OpenGL ES is missing, falling back to OpenGL..."); + } + + return true; + } } diff --git a/src/Nazara/OpenGLRenderer/Wrapper/GLContext.cpp b/src/Nazara/OpenGLRenderer/Wrapper/GLContext.cpp deleted file mode 100644 index 23ba56493..000000000 --- a/src/Nazara/OpenGLRenderer/Wrapper/GLContext.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - OpenGL Renderer" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include - -namespace Nz::GL -{ - GLContext::~GLContext() = default; - - bool GLContext::LoadCoreFunctions(Loader& loader) - { - if (!Activate()) - { - NazaraError("failed to activate context"); - return false; - } - - auto LoadSymbol = [&](auto& func, const char* funcName) - { - func = reinterpret_cast>(loader.LoadFunction(funcName)); - if (!func) - throw std::runtime_error("failed to load core function " + std::string(funcName)); - }; - - try - { -#define NAZARA_OPENGLRENDERER_FUNC(name, sig) LoadSymbol(name, #name); - NAZARA_OPENGLRENDERER_FOREACH_GLES_FUNC(NAZARA_OPENGLRENDERER_FUNC) -#undef NAZARA_OPENGLRENDERER_FUNC - } - catch (const std::exception& e) - { - NazaraError(e.what()); - return false; - } - - return true; - } -} diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp index edb84f5bd..b46d38e28 100644 --- a/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp +++ b/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp @@ -14,7 +14,7 @@ namespace Nz::GL { thread_local WGLContext* s_currentContext = nullptr; - GL::WGLContext::WGLContext(WGLLoader& loader) : + GL::WGLContext::WGLContext(const WGLLoader& loader) : m_loader(loader) { } @@ -48,11 +48,9 @@ namespace Nz::GL return true; } - bool WGLContext::Create(const ContextParams& params) + bool WGLContext::Create(const WGLContext* baseContext, const ContextParams& params, const WGLContext* shareContext) { - Destroy(); - - // Creating a context requires a Window + // Creating a context requires a device context, create window to get one m_window.reset(::CreateWindowA("STATIC", nullptr, WS_DISABLED | WS_POPUP, 0, 0, 1, 1, nullptr, nullptr, GetModuleHandle(nullptr), nullptr)); if (!m_window) { @@ -62,71 +60,19 @@ namespace Nz::GL ::ShowWindow(m_window.get(), FALSE); - m_deviceContext = ::GetDC(m_window.get()); + return Create(baseContext, params, m_window.get(), shareContext); + } + + bool WGLContext::Create(const WGLContext* baseContext, const ContextParams& params, WindowHandle window, const WGLContext* shareContext) + { + m_deviceContext = ::GetDC(static_cast(window)); if (!m_deviceContext) { - NazaraError("failed to retrieve dummy window device context: " + Error::GetLastSystemError()); + NazaraError("failed to retrieve window device context: " + Error::GetLastSystemError()); return false; } - if (!SetPixelFormat(params)) - return false; - - WGLContext* currentContext = s_currentContext; //< Pay TLS cost only once - if (currentContext && currentContext->wglCreateContextAttribsARB) - { - struct OpenGLVersion - { - int major; - int minor; - }; - - std::array supportedVersions = { - { - { 4, 6 }, - { 4, 5 }, - { 4, 4 }, - { 4, 3 }, - { 4, 2 }, - { 4, 1 }, - { 4, 0 }, - { 3, 3 } - } - }; - - for (const OpenGLVersion& version : supportedVersions) - { - std::array attributes = { - WGL_CONTEXT_MAJOR_VERSION_ARB, version.major, - WGL_CONTEXT_MINOR_VERSION_ARB, version.minor, - - WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB - }; - - m_handle = currentContext->wglCreateContextAttribsARB(m_deviceContext, nullptr, attributes.data()); - if (m_handle) - break; - } - - if (!m_handle) - { - NazaraError("failed to create WGL context: " + Error::GetLastSystemError()); - return false; - } - } - else - { - m_handle = m_loader.wglCreateContext(m_deviceContext); - if (!m_handle) - { - NazaraError("failed to create WGL context: " + Error::GetLastSystemError()); - return false; - } - } - - LoadWGLExt(); - - return true; + return CreateInternal(baseContext, params, shareContext); } void WGLContext::Destroy() @@ -151,6 +97,157 @@ namespace Nz::GL m_loader.SwapBuffers(m_deviceContext); } + bool WGLContext::CreateInternal(const WGLContext* baseContext, const ContextParams& params, const WGLContext* shareContext) + { + Destroy(); + + m_params = params; + + if (!SetPixelFormat()) + return false; + + if (baseContext && baseContext->wglCreateContextAttribsARB) + { + struct Version + { + unsigned int major; + unsigned int minor; + }; + + if (params.type == ContextType::OpenGL_ES) + { + if (baseContext->HasPlatformExtension("WGL_EXT_create_context_es_profile")) + { + // Create OpenGL ES context + std::array supportedGL_ESVersions = { + { + { 3, 2 }, + { 3, 1 }, + { 3, 0 } + } + }; + + for (const Version& version : supportedGL_ESVersions) + { + if (params.glMajorVersion != 0) + { + if (version.major > params.glMajorVersion) + continue; + + if (params.glMinorVersion != 0 && version.minor > params.glMinorVersion) + continue; + } + + std::array attributes = { + WGL_CONTEXT_MAJOR_VERSION_ARB, version.major, + WGL_CONTEXT_MINOR_VERSION_ARB, version.minor, + + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB | WGL_CONTEXT_ES_PROFILE_BIT_EXT + }; + + m_handle = baseContext->wglCreateContextAttribsARB(m_deviceContext, nullptr, attributes.data()); + if (m_handle) + break; + } + } + } + + if (!m_handle) + { + // Create OpenGL context + std::array supportedGLVersions = { + { + { 4, 6 }, + { 4, 5 }, + { 4, 4 }, + { 4, 3 }, + { 4, 2 }, + { 4, 1 }, + { 4, 0 }, + { 3, 3 } + } + }; + + for (const Version& version : supportedGLVersions) + { + if (params.glMajorVersion != 0) + { + if (version.major > params.glMajorVersion) + continue; + + if (params.glMinorVersion != 0 && version.minor > params.glMinorVersion) + continue; + } + + std::array attributes = { + WGL_CONTEXT_MAJOR_VERSION_ARB, version.major, + WGL_CONTEXT_MINOR_VERSION_ARB, version.minor, + + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB + }; + + m_handle = baseContext->wglCreateContextAttribsARB(m_deviceContext, nullptr, attributes.data()); + if (m_handle) + { + m_params.type = ContextType::OpenGL; + break; + } + } + } + + if (!m_handle) + { + NazaraError("failed to create WGL context: " + Error::GetLastSystemError()); + return false; + } + } + else + { + m_handle = m_loader.wglCreateContext(m_deviceContext); + if (!m_handle) + { + NazaraError("failed to create WGL context: " + Error::GetLastSystemError()); + return false; + } + + m_params.type = ContextType::OpenGL; + } + + if (shareContext) + { + if (!m_loader.wglShareLists(shareContext->m_handle, m_handle)) + { + NazaraError("failed to share context objects: " + Error::GetLastSystemError()); + return false; + } + } + + LoadWGLExt(); + + return true; + } + + bool WGLContext::ImplementFallback(const std::string_view& function) + { + if (m_params.type == ContextType::OpenGL_ES) + return false; //< Implement fallback only for OpenGL (when emulating OpenGL ES) + + if (function == "glClearDepthf") + { + fallbacks.glClearDepth = reinterpret_cast(m_loader.LoadFunction("glClearDepth")); + if (!fallbacks.glClearDepth) + return false; + + glClearDepthf = [](GLfloat depth) + { + assert(s_currentContext); + s_currentContext->fallbacks.glClearDepth(depth); + }; + } + + return true; + } + void WGLContext::Desactivate() { WGLContext*& currentContext = s_currentContext; //< Pay TLS cost only once @@ -161,6 +258,11 @@ namespace Nz::GL } } + const Loader& WGLContext::GetLoader() + { + return m_loader; + } + bool WGLContext::LoadWGLExt() { if (!Activate()) @@ -186,7 +288,7 @@ namespace Nz::GL { SplitString(extensionString, " ", [&](std::string_view extension) { - m_supportedExtensions.emplace(extension); + m_supportedPlatformExtensions.emplace(extension); return true; }); } @@ -194,14 +296,14 @@ namespace Nz::GL return true; } - bool WGLContext::SetPixelFormat(const ContextParams& params) + bool WGLContext::SetPixelFormat() { PIXELFORMATDESCRIPTOR descriptor = {}; descriptor.nSize = sizeof(PIXELFORMATDESCRIPTOR); descriptor.nVersion = 1; int pixelFormat = 0; - if (params.sampleCount > 1) + if (m_params.sampleCount > 1) { WGLContext* currentContext = s_currentContext; //< Pay TLS cost only once if (currentContext) @@ -215,13 +317,13 @@ namespace Nz::GL WGL_DRAW_TO_WINDOW_ARB, GL_TRUE, WGL_SUPPORT_OPENGL_ARB, GL_TRUE, WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB, - WGL_COLOR_BITS_ARB, (params.bitsPerPixel == 32) ? 24 : params.bitsPerPixel, - WGL_ALPHA_BITS_ARB, (params.bitsPerPixel == 32) ? 8 : 0, - WGL_DEPTH_BITS_ARB, params.depthBits, - WGL_STENCIL_BITS_ARB, params.stencilBits, - WGL_DOUBLE_BUFFER_ARB, (params.doubleBuffering) ? GL_TRUE : GL_FALSE, + WGL_COLOR_BITS_ARB, (m_params.bitsPerPixel == 32) ? 24 : m_params.bitsPerPixel, + WGL_ALPHA_BITS_ARB, (m_params.bitsPerPixel == 32) ? 8 : 0, + WGL_DEPTH_BITS_ARB, m_params.depthBits, + WGL_STENCIL_BITS_ARB, m_params.stencilBits, + WGL_DOUBLE_BUFFER_ARB, (m_params.doubleBuffering) ? GL_TRUE : GL_FALSE, WGL_SAMPLE_BUFFERS_ARB, GL_TRUE, - WGL_SAMPLES_ARB, params.sampleCount + WGL_SAMPLES_ARB, m_params.sampleCount }; int& sampleCount = attributes[attributes.size() - 3]; @@ -239,24 +341,26 @@ namespace Nz::GL } while (sampleCount > 1); - if (params.sampleCount != sampleCount) - NazaraWarning("couldn't find a pixel format matching " + std::to_string(params.sampleCount) + " sample count, using " + std::to_string(sampleCount) + " sample(s) instead"); + if (m_params.sampleCount != sampleCount) + NazaraWarning("couldn't find a pixel format matching " + std::to_string(m_params.sampleCount) + " sample count, using " + std::to_string(sampleCount) + " sample(s) instead"); + + m_params.sampleCount = sampleCount; } } } if (pixelFormat == 0) { - descriptor.cColorBits = BYTE((params.bitsPerPixel == 32) ? 24 : params.bitsPerPixel); - descriptor.cDepthBits = BYTE(params.depthBits); - descriptor.cStencilBits = BYTE(params.stencilBits); + descriptor.cColorBits = BYTE((m_params.bitsPerPixel == 32) ? 24 : m_params.bitsPerPixel); + descriptor.cDepthBits = BYTE(m_params.depthBits); + descriptor.cStencilBits = BYTE(m_params.stencilBits); descriptor.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL; descriptor.iPixelType = PFD_TYPE_RGBA; - if (params.bitsPerPixel == 32) + if (m_params.bitsPerPixel == 32) descriptor.cAlphaBits = 8; - if (params.doubleBuffering) + if (m_params.doubleBuffering) descriptor.dwFlags |= PFD_DOUBLEBUFFER; pixelFormat = m_loader.ChoosePixelFormat(m_deviceContext, &descriptor); @@ -273,6 +377,13 @@ namespace Nz::GL return false; } + if (DescribePixelFormat(m_deviceContext, pixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &descriptor) != 0) + { + m_params.bitsPerPixel = descriptor.cColorBits + descriptor.cAlphaBits; + m_params.depthBits = descriptor.cDepthBits; + m_params.stencilBits = descriptor.cStencilBits; + } + return true; } } diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.cpp index b813af9c3..bc37dc061 100644 --- a/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.cpp +++ b/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.cpp @@ -3,13 +3,15 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include #include namespace Nz::GL { WGLLoader::WGLLoader(DynLib& openglLib) : - m_opengl32Lib(openglLib) + m_opengl32Lib(openglLib), + m_baseContext(*this) { if (!m_gdi32Lib.Load("gdi32.dll")) throw std::runtime_error("failed to load gdi32.dll: " + m_gdi32Lib.GetLastError()); @@ -35,31 +37,62 @@ namespace Nz::GL NAZARA_OPENGLRENDERER_FOREACH_WGL_FUNC(NAZARA_OPENGLRENDERER_FUNC, NAZARA_OPENGLRENDERER_EXT_BEGIN, NAZARA_OPENGLRENDERER_EXT_END, NAZARA_OPENGLRENDERER_EXT_FUNC) #undef NAZARA_OPENGLRENDERER_FUNC - // In order to load OpenGL functions, we have to create a context first - WGLContext dummyContext(*this); - - if (!dummyContext.Create({})) - throw std::runtime_error("failed to create load context"); - - WGLContext loadContext(*this); - - if (!loadContext.Create({})) - throw std::runtime_error("failed to create load context"); - - if (!loadContext.LoadCoreFunctions(*this)) - throw std::runtime_error("failed to load OpenGL functions"); - #undef NAZARA_OPENGLRENDERER_EXT_BEGIN #undef NAZARA_OPENGLRENDERER_EXT_END #undef NAZARA_OPENGLRENDERER_EXT_FUNC + + // In order to load OpenGL functions, we have to create a context first + WGLContext loadContext(*this); + + if (!loadContext.Create(nullptr, {})) + throw std::runtime_error("failed to create load context"); + + ContextParams params; + + if (!m_baseContext.Create(&loadContext, params)) + throw std::runtime_error("failed to create load context"); + + if (!m_baseContext.Initialize(params)) + throw std::runtime_error("failed to load OpenGL functions"); } - std::unique_ptr WGLLoader::CreateContext() + std::unique_ptr WGLLoader::CreateContext(const ContextParams& params, Context* shareContext) const { - return {}; //< TODO + auto context = std::make_unique(*this); + if (!context->Create(&m_baseContext, params, static_cast(shareContext))) + { + NazaraError("failed to create context"); + return {}; + } + + if (!context->Initialize(params)) + { + NazaraError("failed to initialize context"); + return {}; + } + + return context; } - GLFunction WGLLoader::LoadFunction(const char* name) + std::unique_ptr WGLLoader::CreateContext(const ContextParams& params, WindowHandle handle, Context* shareContext) const + { + auto context = std::make_unique(*this); + if (!context->Create(&m_baseContext, params, handle, static_cast(shareContext))) + { + NazaraError("failed to create context"); + return {}; + } + + if (!context->Initialize(params)) + { + NazaraError("failed to initialize context"); + return {}; + } + + return context; + } + + GLFunction WGLLoader::LoadFunction(const char* name) const { GLFunction func = reinterpret_cast(wglGetProcAddress(name)); if (!func) //< wglGetProcAddress doesn't work for OpenGL 1.1 functions From 506099fcd790ed50f75baa9f0620db407318eb9b Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 19 Apr 2020 01:38:38 +0200 Subject: [PATCH 162/316] OpenGL: Implement ShaderStage --- .../OpenGLRenderer/OpenGLShaderStage.hpp | 11 +- .../OpenGLRenderer/OpenGLShaderStage.inl | 9 - include/Nazara/OpenGLRenderer/Utils.hpp | 17 +- include/Nazara/OpenGLRenderer/Utils.inl | 198 +----------------- .../Nazara/OpenGLRenderer/Wrapper/Shader.hpp | 49 ++--- .../Nazara/OpenGLRenderer/Wrapper/Shader.inl | 80 +++++-- src/Nazara/OpenGLRenderer/OpenGLDevice.cpp | 3 + 7 files changed, 99 insertions(+), 268 deletions(-) diff --git a/include/Nazara/OpenGLRenderer/OpenGLShaderStage.hpp b/include/Nazara/OpenGLRenderer/OpenGLShaderStage.hpp index 5ed61015d..25439872a 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLShaderStage.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLShaderStage.hpp @@ -10,7 +10,8 @@ #include #include #include -#include +#include +#include #include namespace Nz @@ -23,17 +24,13 @@ namespace Nz OpenGLShaderStage(OpenGLShaderStage&&) noexcept = default; ~OpenGLShaderStage() = default; - bool Create(Vk::Device& device, ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize); - - inline const Vk::ShaderModule& GetHandle() const; - inline ShaderStageType GetStageType() const; + bool Create(OpenGLDevice& device, ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize); OpenGLShaderStage& operator=(const OpenGLShaderStage&) = delete; OpenGLShaderStage& operator=(OpenGLShaderStage&&) noexcept = default; private: - Vk::ShaderModule m_shaderModule; - ShaderStageType m_stage; + GL::Shader m_shader; }; } diff --git a/include/Nazara/OpenGLRenderer/OpenGLShaderStage.inl b/include/Nazara/OpenGLRenderer/OpenGLShaderStage.inl index bf191a5c8..305f1968a 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLShaderStage.inl +++ b/include/Nazara/OpenGLRenderer/OpenGLShaderStage.inl @@ -7,15 +7,6 @@ namespace Nz { - inline const Vk::ShaderModule& OpenGLShaderStage::GetHandle() const - { - return m_shaderModule; - } - - inline ShaderStageType OpenGLShaderStage::GetStageType() const - { - return m_stage; - } } #include diff --git a/include/Nazara/OpenGLRenderer/Utils.hpp b/include/Nazara/OpenGLRenderer/Utils.hpp index cd1b178b5..ad330277d 100644 --- a/include/Nazara/OpenGLRenderer/Utils.hpp +++ b/include/Nazara/OpenGLRenderer/Utils.hpp @@ -16,22 +16,9 @@ namespace Nz { - inline VkBufferUsageFlags ToOpenGL(BufferType bufferType); - inline VkFormat ToOpenGL(ComponentType componentType); - inline VkCullModeFlagBits ToOpenGL(FaceSide faceSide); - inline VkPolygonMode ToOpenGL(FaceFilling faceFilling); - inline VkPrimitiveTopology ToOpenGL(PrimitiveMode primitiveMode); - inline VkCompareOp ToOpenGL(RendererComparison comparison); - inline VkFilter ToOpenGL(SamplerFilter samplerFilter); - inline VkSamplerMipmapMode ToOpenGL(SamplerMipmapMode samplerMipmap); - inline VkSamplerAddressMode ToOpenGL(SamplerWrap samplerWrap); - inline VkDescriptorType ToOpenGL(ShaderBindingType bindingType); - inline VkShaderStageFlagBits ToOpenGL(ShaderStageType stageType); - inline VkShaderStageFlags ToOpenGL(ShaderStageTypeFlags stageType); - inline VkStencilOp ToOpenGL(StencilOperation stencilOp); - inline VkVertexInputRate ToOpenGL(VertexInputRate inputRate); + inline GLenum ToOpenGL(ShaderStageType stageType); - NAZARA_OPENGLRENDERER_API std::string TranslateOpenGLError(VkResult code); + //NAZARA_OPENGLRENDERER_API std::string TranslateOpenGLError(GLenum code); } #include diff --git a/include/Nazara/OpenGLRenderer/Utils.inl b/include/Nazara/OpenGLRenderer/Utils.inl index 877da7179..4e6be66cc 100644 --- a/include/Nazara/OpenGLRenderer/Utils.inl +++ b/include/Nazara/OpenGLRenderer/Utils.inl @@ -10,209 +10,17 @@ namespace Nz { - VkBufferUsageFlags ToOpenGL(BufferType bufferType) - { - switch (bufferType) - { - case BufferType_Index: return VK_BUFFER_USAGE_INDEX_BUFFER_BIT; - case BufferType_Vertex: return VK_BUFFER_USAGE_VERTEX_BUFFER_BIT; - case BufferType_Uniform: return VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; - } - - NazaraError("Unhandled BufferType 0x" + String::Number(bufferType, 16)); - return 0; - } - - VkFormat ToOpenGL(ComponentType componentType) - { - switch (componentType) - { - case ComponentType_Color: return VK_FORMAT_R8G8B8A8_UINT; - case ComponentType_Double1: return VK_FORMAT_R64_SFLOAT; - case ComponentType_Double2: return VK_FORMAT_R64G64_SFLOAT; - case ComponentType_Double3: return VK_FORMAT_R64G64B64_SFLOAT; - case ComponentType_Double4: return VK_FORMAT_R64G64B64A64_SFLOAT; - case ComponentType_Float1: return VK_FORMAT_R32_SFLOAT; - case ComponentType_Float2: return VK_FORMAT_R32G32_SFLOAT; - case ComponentType_Float3: return VK_FORMAT_R32G32B32_SFLOAT; - case ComponentType_Float4: return VK_FORMAT_R32G32B32A32_SFLOAT; - case ComponentType_Int1: return VK_FORMAT_R32_SINT; - case ComponentType_Int2: return VK_FORMAT_R32G32_SINT; - case ComponentType_Int3: return VK_FORMAT_R32G32B32_SINT; - case ComponentType_Int4: return VK_FORMAT_R32G32B32A32_SINT; - case ComponentType_Quaternion: return VK_FORMAT_R32G32B32A32_SFLOAT; - } - - NazaraError("Unhandled ComponentType 0x" + String::Number(componentType, 16)); - return VK_FORMAT_UNDEFINED; - } - - VkCullModeFlagBits ToOpenGL(FaceSide faceSide) - { - switch (faceSide) - { - case FaceSide_None: return VK_CULL_MODE_NONE; - case FaceSide_Back: return VK_CULL_MODE_BACK_BIT; - case FaceSide_Front: return VK_CULL_MODE_FRONT_BIT; - case FaceSide_FrontAndBack: return VK_CULL_MODE_FRONT_AND_BACK; - } - - NazaraError("Unhandled FaceSide 0x" + String::Number(faceSide, 16)); - return VK_CULL_MODE_BACK_BIT; - } - - inline VkPolygonMode ToOpenGL(FaceFilling faceFilling) - { - switch (faceFilling) - { - case FaceFilling_Fill: return VK_POLYGON_MODE_FILL; - case FaceFilling_Line: return VK_POLYGON_MODE_LINE; - case FaceFilling_Point: return VK_POLYGON_MODE_POINT; - } - - NazaraError("Unhandled FaceFilling 0x" + String::Number(faceFilling, 16)); - return VK_POLYGON_MODE_FILL; - } - - VkPrimitiveTopology ToOpenGL(PrimitiveMode primitiveMode) - { - switch (primitiveMode) - { - case PrimitiveMode_LineList: return VK_PRIMITIVE_TOPOLOGY_LINE_LIST; - case PrimitiveMode_LineStrip: return VK_PRIMITIVE_TOPOLOGY_LINE_STRIP; - case PrimitiveMode_PointList: return VK_PRIMITIVE_TOPOLOGY_POINT_LIST; - case PrimitiveMode_TriangleList: return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; - case PrimitiveMode_TriangleStrip: return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; - case PrimitiveMode_TriangleFan: return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN; - } - - NazaraError("Unhandled FaceFilling 0x" + String::Number(primitiveMode, 16)); - return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; - } - - inline VkCompareOp ToOpenGL(RendererComparison comparison) - { - switch (comparison) - { - case RendererComparison_Never: return VK_COMPARE_OP_NEVER; - case RendererComparison_Less: return VK_COMPARE_OP_LESS; - case RendererComparison_Equal: return VK_COMPARE_OP_EQUAL; - case RendererComparison_LessOrEqual: return VK_COMPARE_OP_LESS_OR_EQUAL; - case RendererComparison_Greater: return VK_COMPARE_OP_GREATER; - case RendererComparison_NotEqual: return VK_COMPARE_OP_NOT_EQUAL; - case RendererComparison_GreaterOrEqual: return VK_COMPARE_OP_GREATER_OR_EQUAL; - case RendererComparison_Always: return VK_COMPARE_OP_ALWAYS; - } - - NazaraError("Unhandled RendererComparison 0x" + String::Number(comparison, 16)); - return VK_COMPARE_OP_NEVER; - } - - VkFilter ToOpenGL(SamplerFilter samplerFilter) - { - switch (samplerFilter) - { - case SamplerFilter_Linear: return VK_FILTER_LINEAR; - case SamplerFilter_Nearest: return VK_FILTER_NEAREST; - } - - NazaraError("Unhandled SamplerFilter 0x" + String::Number(UnderlyingCast(samplerFilter), 16)); - return VK_FILTER_NEAREST; - } - - VkSamplerMipmapMode ToOpenGL(SamplerMipmapMode samplerMipmap) - { - switch (samplerMipmap) - { - case SamplerMipmapMode_Linear: return VK_SAMPLER_MIPMAP_MODE_LINEAR; - case SamplerMipmapMode_Nearest: return VK_SAMPLER_MIPMAP_MODE_NEAREST; - } - - NazaraError("Unhandled SamplerMipmapMode 0x" + String::Number(UnderlyingCast(samplerMipmap), 16)); - return VK_SAMPLER_MIPMAP_MODE_NEAREST; - } - - VkSamplerAddressMode ToOpenGL(SamplerWrap samplerWrap) - { - switch (samplerWrap) - { - case SamplerWrap_Clamp: return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; - case SamplerWrap_MirroredRepeat: return VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT; - case SamplerWrap_Repeat: return VK_SAMPLER_ADDRESS_MODE_REPEAT; - } - - NazaraError("Unhandled SamplerWrap 0x" + String::Number(UnderlyingCast(samplerWrap), 16)); - return VK_SAMPLER_ADDRESS_MODE_REPEAT; - } - - VkDescriptorType ToOpenGL(ShaderBindingType bindingType) - { - switch (bindingType) - { - case ShaderBindingType::Texture: return VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; - case ShaderBindingType::UniformBuffer: return VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; - } - - NazaraError("Unhandled ShaderBindingType 0x" + String::Number(UnderlyingCast(bindingType), 16)); - return VK_DESCRIPTOR_TYPE_SAMPLER; - } - - VkShaderStageFlagBits ToOpenGL(ShaderStageType stageType) + GLenum ToOpenGL(ShaderStageType stageType) { switch (stageType) { - case ShaderStageType::Fragment: return VK_SHADER_STAGE_FRAGMENT_BIT; - case ShaderStageType::Vertex: return VK_SHADER_STAGE_VERTEX_BIT; + case ShaderStageType::Fragment: return GL_FRAGMENT_SHADER; + case ShaderStageType::Vertex: return GL_VERTEX_SHADER; } NazaraError("Unhandled ShaderStageType 0x" + String::Number(UnderlyingCast(stageType), 16)); return {}; } - - VkShaderStageFlags ToOpenGL(ShaderStageTypeFlags stageType) - { - VkShaderStageFlags shaderStageBits = 0; - - if (stageType.Test(ShaderStageType::Fragment)) - shaderStageBits |= VK_SHADER_STAGE_FRAGMENT_BIT; - - if (stageType.Test(ShaderStageType::Vertex)) - shaderStageBits |= VK_SHADER_STAGE_VERTEX_BIT; - - static_assert(UnderlyingCast(ShaderStageType::Max) + 1 == 2); - - return shaderStageBits; - } - - VkStencilOp ToOpenGL(StencilOperation stencilOp) - { - switch (stencilOp) - { - case StencilOperation_Decrement: return VK_STENCIL_OP_DECREMENT_AND_CLAMP; - case StencilOperation_DecrementNoClamp: return VK_STENCIL_OP_DECREMENT_AND_WRAP; - case StencilOperation_Increment: return VK_STENCIL_OP_INCREMENT_AND_CLAMP; - case StencilOperation_IncrementNoClamp: return VK_STENCIL_OP_INCREMENT_AND_WRAP; - case StencilOperation_Invert: return VK_STENCIL_OP_INVERT; - case StencilOperation_Keep: return VK_STENCIL_OP_KEEP; - case StencilOperation_Replace: return VK_STENCIL_OP_REPLACE; - case StencilOperation_Zero: return VK_STENCIL_OP_ZERO; - } - - NazaraError("Unhandled RendererComparison 0x" + String::Number(stencilOp, 16)); - return VK_STENCIL_OP_KEEP; - } - - VkVertexInputRate ToOpenGL(VertexInputRate inputRate) - { - switch (inputRate) - { - case VertexInputRate::Instance: return VK_VERTEX_INPUT_RATE_INSTANCE; - case VertexInputRate::Vertex: return VK_VERTEX_INPUT_RATE_VERTEX; - } - - NazaraError("Unhandled VertexInputRate 0x" + String::Number(UnderlyingCast(inputRate), 16)); - return VK_VERTEX_INPUT_RATE_VERTEX; - } } #include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Shader.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Shader.hpp index d0613f1f3..62d4effb7 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Shader.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Shader.hpp @@ -4,39 +4,40 @@ #pragma once -#ifndef NAZARA_OPENGLRENDERER_VKSHADERMODULE_HPP -#define NAZARA_OPENGLRENDERER_VKSHADERMODULE_HPP +#ifndef NAZARA_OPENGLRENDERER_GLSHADER_HPP +#define NAZARA_OPENGLRENDERER_GLSHADER_HPP #include -#include +#include +#include -namespace Nz +namespace Nz::GL { - namespace Vk + class Shader { - class ShaderModule : public DeviceObject - { - friend DeviceObject; + public: + Shader() = default; + Shader(const Shader&) = delete; + Shader(Shader&&) noexcept = default; + inline ~Shader(); - public: - ShaderModule() = default; - ShaderModule(const ShaderModule&) = delete; - ShaderModule(ShaderModule&&) = default; - ~ShaderModule() = default; + inline bool Compile(std::string* error = nullptr); - using DeviceObject::Create; - inline bool Create(Device& device, const UInt32* code, std::size_t size, VkShaderModuleCreateFlags flags = 0, const VkAllocationCallbacks* allocator = nullptr); + inline bool Create(OpenGLDevice& device, GLenum type); + inline void Destroy(); - ShaderModule& operator=(const ShaderModule&) = delete; - ShaderModule& operator=(ShaderModule&&) = delete; + inline void SetBinarySource(GLenum binaryFormat, const void* binary, GLsizei length); + inline void SetSource(const char* source, GLint length); - private: - static inline VkResult CreateHelper(Device& device, const VkShaderModuleCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkShaderModule* handle); - static inline void DestroyHelper(Device& device, VkShaderModule handle, const VkAllocationCallbacks* allocator); - }; - } + Shader& operator=(const Shader&) = delete; + Shader& operator=(Shader&&) noexcept = default; + + private: + MovablePtr m_device; + MovableValue m_shader; + }; } -#include +#include -#endif // NAZARA_OPENGLRENDERER_VKSHADERMODULE_HPP +#endif diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Shader.inl b/include/Nazara/OpenGLRenderer/Wrapper/Shader.inl index 1194d21f6..aa4cf82bd 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Shader.inl +++ b/include/Nazara/OpenGLRenderer/Wrapper/Shader.inl @@ -2,36 +2,80 @@ // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include +#include #include -namespace Nz +namespace Nz::GL { - namespace Vk + inline Shader::~Shader() { - inline bool ShaderModule::Create(Device& device, const UInt32* code, std::size_t size, VkShaderModuleCreateFlags flags, const VkAllocationCallbacks* allocator) + Destroy(); + } + + inline bool Shader::Compile(std::string* error) + { + assert(m_shader); + const GL::Context& context = m_device->GetReferenceContext(); + context.glCompileShader(m_shader); + + GLint success; + context.glGetShaderiv(m_shader, GL_COMPILE_STATUS, &success); + if (!success) { - VkShaderModuleCreateInfo createInfo = + if (error) { - VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO, - nullptr, - flags, - size, - code - }; + GLint logLength; + context.glGetShaderiv(m_shader, GL_INFO_LOG_LENGTH, &logLength); - return Create(device, createInfo, allocator); + error->resize(logLength); + + if (logLength > 0) + { + GLsizei dummy; + context.glGetShaderInfoLog(m_shader, logLength, &dummy, error->data()); + } + } + + return false; } - inline VkResult ShaderModule::CreateHelper(Device& device, const VkShaderModuleCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkShaderModule* handle) + return true; + } + + inline bool Shader::Create(OpenGLDevice& device, GLenum type) + { + Destroy(); + + m_device = &device; + m_shader = device.GetReferenceContext().glCreateShader(type); + if (!m_shader) + return false; //< TODO: Handle error messages + + return true; + } + + inline void Shader::Destroy() + { + if (m_shader) { - return device.vkCreateShaderModule(device, createInfo, allocator, handle); + m_device->GetReferenceContext().glDeleteShader(m_shader); + m_shader = 0; } + } - inline void ShaderModule::DestroyHelper(Device& device, VkShaderModule handle, const VkAllocationCallbacks* allocator) - { - return device.vkDestroyShaderModule(device, handle, allocator); - } + inline void Shader::SetBinarySource(GLenum binaryFormat, const void* binary, GLsizei length) + { + assert(m_shader); + + m_device->GetReferenceContext().glShaderBinary(1U, &m_shader.Get(), binaryFormat, binary, length); + } + + inline void Shader::SetSource(const char* source, GLint length) + { + assert(m_shader); + + m_device->GetReferenceContext().glShaderSource(m_shader, 1U, &source, &length); } } diff --git a/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp b/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp index 4f6402712..c62cb2cd1 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp @@ -53,8 +53,11 @@ namespace Nz std::shared_ptr OpenGLDevice::InstantiateShaderStage(ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) { + auto shaderStage = std::make_shared(); + if (!shaderStage->Create(*this, type, lang, source, sourceSize)) return {}; + return shaderStage; } std::unique_ptr OpenGLDevice::InstantiateTexture(const TextureInfo& params) From a842e89881af9cc208f7dfec7f14bc5472d4a0c3 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 19 Apr 2020 01:38:52 +0200 Subject: [PATCH 163/316] Fix some missing files --- .../OpenGLRenderer/Wrapper/ContextObject.hpp | 56 ------------------- .../OpenGLRenderer/Wrapper/DeviceObject.hpp | 49 ++++++++++++++++ .../{ContextObject.inl => DeviceObject.inl} | 0 src/Nazara/OpenGLRenderer/DummySurface.cpp | 20 +++++++ 4 files changed, 69 insertions(+), 56 deletions(-) delete mode 100644 include/Nazara/OpenGLRenderer/Wrapper/ContextObject.hpp create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/DeviceObject.hpp rename include/Nazara/OpenGLRenderer/Wrapper/{ContextObject.inl => DeviceObject.inl} (100%) create mode 100644 src/Nazara/OpenGLRenderer/DummySurface.cpp diff --git a/include/Nazara/OpenGLRenderer/Wrapper/ContextObject.hpp b/include/Nazara/OpenGLRenderer/Wrapper/ContextObject.hpp deleted file mode 100644 index 696427450..000000000 --- a/include/Nazara/OpenGLRenderer/Wrapper/ContextObject.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - OpenGL Renderer" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_OPENGLRENDERER_VKDEVICEOBJECT_HPP -#define NAZARA_OPENGLRENDERER_VKDEVICEOBJECT_HPP - -#include -#include -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - template - class DeviceObject - { - public: - DeviceObject(); - DeviceObject(const DeviceObject&) = delete; - DeviceObject(DeviceObject&& object) noexcept; - ~DeviceObject(); - - bool Create(Device& device, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator = nullptr); - void Destroy(); - - bool IsValid() const; - - Device* GetDevice() const; - VkResult GetLastErrorCode() const; - - void SetDebugName(const char* name); - void SetDebugName(const std::string& name); - - DeviceObject& operator=(const DeviceObject&) = delete; - DeviceObject& operator=(DeviceObject&& object) noexcept; - - operator VkType() const; - - protected: - MovablePtr m_device; - VkAllocationCallbacks m_allocator; - VkType m_handle; - mutable VkResult m_lastErrorCode; - }; - } -} - -#include - -#endif // NAZARA_OPENGLRENDERER_VKDEVICEOBJECT_HPP diff --git a/include/Nazara/OpenGLRenderer/Wrapper/DeviceObject.hpp b/include/Nazara/OpenGLRenderer/Wrapper/DeviceObject.hpp new file mode 100644 index 000000000..495297289 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/DeviceObject.hpp @@ -0,0 +1,49 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_GLDEVICEOBJECT_HPP +#define NAZARA_OPENGLRENDERER_GLDEVICEOBJECT_HPP + +#include +#include +#include + +namespace Nz::GL +{ + template + class DeviceObject + { + public: + DeviceObject(); + DeviceObject(const DeviceObject&) = delete; + DeviceObject(DeviceObject&& object) noexcept; + ~DeviceObject(); + + bool Create(OpenGLDevice& device); + void Destroy(); + + bool IsValid() const; + + Device* GetDevice() const; + VkResult GetLastErrorCode() const; + + void SetDebugName(const char* name); + void SetDebugName(const std::string& name); + + DeviceObject& operator=(const DeviceObject&) = delete; + DeviceObject& operator=(DeviceObject&& object) noexcept; + + operator VkType() const; + + protected: + MovablePtr m_device; + GLuint m_handle; + }; +} + +#include + +#endif // NAZARA_OPENGLRENDERER_VKDEVICEOBJECT_HPP diff --git a/include/Nazara/OpenGLRenderer/Wrapper/ContextObject.inl b/include/Nazara/OpenGLRenderer/Wrapper/DeviceObject.inl similarity index 100% rename from include/Nazara/OpenGLRenderer/Wrapper/ContextObject.inl rename to include/Nazara/OpenGLRenderer/Wrapper/DeviceObject.inl diff --git a/src/Nazara/OpenGLRenderer/DummySurface.cpp b/src/Nazara/OpenGLRenderer/DummySurface.cpp new file mode 100644 index 000000000..ec74f480e --- /dev/null +++ b/src/Nazara/OpenGLRenderer/DummySurface.cpp @@ -0,0 +1,20 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + bool DummySurface::Create(WindowHandle handle) + { + m_handle = handle; + return true; + } + + void DummySurface::Destroy() + { + m_handle = nullptr; + } +} From d62e99091f678c278e3668892040674872524134 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 19 Apr 2020 15:19:16 +0200 Subject: [PATCH 164/316] OpenGL: Implement debug callback --- .../Nazara/OpenGLRenderer/Wrapper/Context.hpp | 6 +- .../OpenGLRenderer/Wrapper/CoreFunctions.hpp | 8 +- src/Nazara/OpenGLRenderer/Wrapper/Context.cpp | 142 +++++++++++++++++- .../Wrapper/Win32/WGLContext.cpp | 3 + 4 files changed, 154 insertions(+), 5 deletions(-) diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp index b2e0427ee..9dd6a868e 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp @@ -59,10 +59,14 @@ namespace Nz::GL protected: virtual const Loader& GetLoader() = 0; - virtual bool ImplementFallback(const std::string_view& function) = 0; + virtual bool ImplementFallback(const std::string_view& function); std::unordered_set m_supportedExtensions; ContextParams m_params; + + private: + void GL_APIENTRY HandleDebugMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message) const; + }; } diff --git a/include/Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp b/include/Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp index b7794db79..20057430b 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp @@ -8,10 +8,12 @@ #define NAZARA_OPENGLRENDERER_COREFUNCTIONS_HPP #define GL_GLES_PROTOTYPES 0 -#include +#include +#include + // OpenGL core -#define NAZARA_OPENGLRENDERER_FOREACH_GLES_FUNC(cb) \ +#define NAZARA_OPENGLRENDERER_FOREACH_GLES_FUNC(cb, extCb) \ cb(glActiveTexture, PFNGLACTIVETEXTUREPROC) \ cb(glAttachShader, PFNGLATTACHSHADERPROC) \ cb(glBeginQuery, PFNGLBEGINQUERYPROC) \ @@ -139,5 +141,7 @@ cb(glVertexAttribPointer, PFNGLVERTEXATTRIBPOINTERPROC) \ cb(glVertexAttribIPointer, PFNGLVERTEXATTRIBIPOINTERPROC) \ cb(glViewport, PFNGLVIEWPORTPROC) \ + \ + extCb(glDebugMessageCallback, PFNGLDEBUGMESSAGECALLBACKPROC) \ #endif diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp index 8c651ff33..a431a9c72 100644 --- a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp +++ b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp @@ -32,8 +32,10 @@ namespace Nz::GL try { -#define NAZARA_OPENGLRENDERER_FUNC(name, sig) LoadSymbol(name, #name); - NAZARA_OPENGLRENDERER_FOREACH_GLES_FUNC(NAZARA_OPENGLRENDERER_FUNC) +#define NAZARA_OPENGLRENDERER_FUNC(name, sig) LoadSymbol(name, #name, true); +#define NAZARA_OPENGLRENDERER_EXT_FUNC(name, sig) //< Do nothing + NAZARA_OPENGLRENDERER_FOREACH_GLES_FUNC(NAZARA_OPENGLRENDERER_FUNC, NAZARA_OPENGLRENDERER_EXT_FUNC) +#undef NAZARA_OPENGLRENDERER_EXT_FUNC #undef NAZARA_OPENGLRENDERER_FUNC } catch (const std::exception& e) @@ -68,6 +70,12 @@ namespace Nz::GL return true; }); +#define NAZARA_OPENGLRENDERER_FUNC(name, sig) +#define NAZARA_OPENGLRENDERER_EXT_FUNC(name, sig) LoadSymbol(name, #name, false); + NAZARA_OPENGLRENDERER_FOREACH_GLES_FUNC(NAZARA_OPENGLRENDERER_FUNC, NAZARA_OPENGLRENDERER_EXT_FUNC) +#undef NAZARA_OPENGLRENDERER_EXT_FUNC +#undef NAZARA_OPENGLRENDERER_FUNC + // If we requested an OpenGL ES context but cannot create one, check for some compatibility extensions if (params.type == ContextType::OpenGL_ES && m_params.type != params.type) { @@ -93,6 +101,136 @@ namespace Nz::GL NazaraWarning("desktop support for OpenGL ES is missing, falling back to OpenGL..."); } + // Set debug callback (if supported) + if (glDebugMessageCallback) + { + glDebugMessageCallback([](GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam) + { + const Context* context = static_cast(userParam); + context->HandleDebugMessage(source, type, id, severity, length, message); + }, this); + } + return true; } + + bool Context::ImplementFallback(const std::string_view& function) + { + const Loader& loader = GetLoader(); + + auto LoadSymbol = [&](auto& func, const char* funcName) -> bool + { + func = reinterpret_cast>(loader.LoadFunction(funcName)); + return func; + }; + + if (function == "glDebugMessageCallback") + { + if (!LoadSymbol(glDebugMessageCallback, "glDebugMessageCallbackARB")) + return LoadSymbol(glDebugMessageCallback, "DebugMessageCallbackAMD"); + + return true; + } + + return false; + } + + void Context::HandleDebugMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message) const + { + std::stringstream ss; + ss << "OpenGL debug message (ID: 0x" << std::to_string(id) << "):\n"; + ss << "Sent by context: " << this; + ss << "\n-Source: "; + switch (source) + { + case GL_DEBUG_SOURCE_API: + ss << "OpenGL API"; + break; + + case GL_DEBUG_SOURCE_WINDOW_SYSTEM: + ss << "Operating system"; + break; + + case GL_DEBUG_SOURCE_SHADER_COMPILER: + ss << "Shader compiler"; + break; + + case GL_DEBUG_SOURCE_THIRD_PARTY: + ss << "Third party"; + break; + + case GL_DEBUG_SOURCE_APPLICATION: + ss << "Application"; + break; + + case GL_DEBUG_SOURCE_OTHER: + ss << "Other"; + break; + + default: + // Peut être rajouté par une extension + ss << "Unknown"; + break; + } + ss << '\n'; + + ss << "-Type: "; + switch (type) + { + case GL_DEBUG_TYPE_ERROR: + ss << "Error"; + break; + + case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: + ss << "Deprecated behavior"; + break; + + case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: + ss << "Undefined behavior"; + break; + + case GL_DEBUG_TYPE_PORTABILITY: + ss << "Portability"; + break; + + case GL_DEBUG_TYPE_PERFORMANCE: + ss << "Performance"; + break; + + case GL_DEBUG_TYPE_OTHER: + ss << "Other"; + break; + + default: + // Peut être rajouté par une extension + ss << "Unknown"; + break; + } + ss << '\n'; + + ss << "-Severity: "; + switch (severity) + { + case GL_DEBUG_SEVERITY_HIGH: + ss << "High"; + break; + + case GL_DEBUG_SEVERITY_MEDIUM: + ss << "Medium"; + break; + + case GL_DEBUG_SEVERITY_LOW: + ss << "Low"; + break; + + default: + ss << "Unknown"; + break; + } + ss << '\n'; + + ss << "Message: " << std::string_view(message, length) << '\n'; + + NazaraNotice(ss.str()); + } } diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp index b46d38e28..c354032db 100644 --- a/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp +++ b/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp @@ -229,6 +229,9 @@ namespace Nz::GL bool WGLContext::ImplementFallback(const std::string_view& function) { + if (Context::ImplementFallback(function)) + return true; + if (m_params.type == ContextType::OpenGL_ES) return false; //< Implement fallback only for OpenGL (when emulating OpenGL ES) From f63d0456766922ef596f3c7a35d6ada3c21fa58e Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 19 Apr 2020 15:28:59 +0200 Subject: [PATCH 165/316] OpenGL: Better handling for activation/desactivation --- .../Nazara/OpenGLRenderer/Wrapper/Context.hpp | 9 ++- .../Wrapper/Win32/WGLContext.hpp | 5 +- src/Nazara/OpenGLRenderer/Wrapper/Context.cpp | 39 +++++++++- .../Wrapper/Win32/WGLContext.cpp | 77 +++++++------------ 4 files changed, 76 insertions(+), 54 deletions(-) diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp index 9dd6a868e..f808e5aa3 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp @@ -56,17 +56,24 @@ namespace Nz::GL NAZARA_OPENGLRENDERER_FOREACH_GLES_FUNC(NAZARA_OPENGLRENDERER_FUNC) #undef NAZARA_OPENGLRENDERER_FUNC + static const Context* GetCurrentContext(); + static bool SetCurrentContext(const Context* context); + protected: + virtual bool Activate() const = 0; + virtual void Desactivate() const = 0; virtual const Loader& GetLoader() = 0; virtual bool ImplementFallback(const std::string_view& function); - std::unordered_set m_supportedExtensions; + static void NotifyContextDestruction(Context* context); + ContextParams m_params; private: void GL_APIENTRY HandleDebugMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message) const; + std::unordered_set m_supportedExtensions; }; } diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.hpp index 3280f7a28..7c300a92c 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.hpp @@ -31,8 +31,6 @@ namespace Nz::GL WGLContext(WGLContext&&) = delete; ~WGLContext(); - bool Activate() override; - bool Create(const WGLContext* baseContext, const ContextParams& params, const WGLContext* shareContext = nullptr); bool Create(const WGLContext* baseContext, const ContextParams& params, WindowHandle window, const WGLContext* shareContext = nullptr); void Destroy(); @@ -50,7 +48,8 @@ namespace Nz::GL bool CreateInternal(const WGLContext* baseContext, const ContextParams& params, const WGLContext* shareContext = nullptr); bool ImplementFallback(const std::string_view& function) override; - void Desactivate(); + bool Activate() const override; + void Desactivate() const override; const Loader& GetLoader() override; bool LoadWGLExt(); bool SetPixelFormat(); diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp index a431a9c72..5ef19ecf1 100644 --- a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp +++ b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp @@ -23,10 +23,10 @@ namespace Nz::GL const Loader& loader = GetLoader(); - auto LoadSymbol = [&](auto& func, const char* funcName) + auto LoadSymbol = [&](auto& func, const char* funcName, bool mandatory) { func = reinterpret_cast>(loader.LoadFunction(funcName)); - if (!func && !ImplementFallback(funcName) && !func) //< Not a mistake + if (!func && !ImplementFallback(funcName) && !func && mandatory) //< Not a mistake throw std::runtime_error("failed to load core function " + std::string(funcName)); }; @@ -114,6 +114,34 @@ namespace Nz::GL return true; } + const Context* Context::GetCurrentContext() + { + return s_currentContext; + } + + bool Context::SetCurrentContext(const Context* context) + { + const Context*& currentContext = s_currentContext; //< Pay TLS cost only once + if (currentContext == context) + return true; + + if (currentContext) + { + currentContext->Desactivate(); + currentContext = nullptr; + } + + if (context) + { + if (!context->Activate()) + return false; + + currentContext = context; + } + + return true; + } + bool Context::ImplementFallback(const std::string_view& function) { const Loader& loader = GetLoader(); @@ -135,6 +163,13 @@ namespace Nz::GL return false; } + void Context::NotifyContextDestruction(Context* context) + { + const Context*& currentContext = s_currentContext; //< Pay TLS cost only once + if (currentContext == context) + currentContext = nullptr; + } + void Context::HandleDebugMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message) const { std::stringstream ss; diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp index c354032db..d732a5da6 100644 --- a/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp +++ b/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp @@ -12,8 +12,6 @@ namespace Nz::GL { - thread_local WGLContext* s_currentContext = nullptr; - GL::WGLContext::WGLContext(const WGLLoader& loader) : m_loader(loader) { @@ -24,30 +22,6 @@ namespace Nz::GL Destroy(); } - bool WGLContext::Activate() - { - WGLContext*& currentContext = s_currentContext; //< Pay TLS cost only once - if (currentContext) - { - if (currentContext == this) - return true; - - // Only one context can be activated per thread - currentContext->Desactivate(); - } - - bool succeeded = m_loader.wglMakeCurrent(m_deviceContext, m_handle); - if (!succeeded) - { - NazaraError("failed to activate context: " + Error::GetLastSystemError()); - return false; - } - - currentContext = this; - - return true; - } - bool WGLContext::Create(const WGLContext* baseContext, const ContextParams& params, const WGLContext* shareContext) { // Creating a context requires a device context, create window to get one @@ -79,9 +53,7 @@ namespace Nz::GL { if (m_handle) { - WGLContext*& currentContext = s_currentContext; //< Pay TLS cost only once - if (currentContext == this) - currentContext = nullptr; + NotifyContextDestruction(this); m_loader.wglDeleteContext(m_handle); m_handle = nullptr; @@ -139,8 +111,8 @@ namespace Nz::GL } std::array attributes = { - WGL_CONTEXT_MAJOR_VERSION_ARB, version.major, - WGL_CONTEXT_MINOR_VERSION_ARB, version.minor, + WGL_CONTEXT_MAJOR_VERSION_ARB, int(version.major), + WGL_CONTEXT_MINOR_VERSION_ARB, int(version.minor), WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB | WGL_CONTEXT_ES_PROFILE_BIT_EXT }; @@ -180,8 +152,8 @@ namespace Nz::GL } std::array attributes = { - WGL_CONTEXT_MAJOR_VERSION_ARB, version.major, - WGL_CONTEXT_MINOR_VERSION_ARB, version.minor, + WGL_CONTEXT_MAJOR_VERSION_ARB, int(version.major), + WGL_CONTEXT_MINOR_VERSION_ARB, int(version.minor), WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB }; @@ -243,22 +215,31 @@ namespace Nz::GL glClearDepthf = [](GLfloat depth) { - assert(s_currentContext); - s_currentContext->fallbacks.glClearDepth(depth); + const WGLContext* context = static_cast(GetCurrentContext()); + assert(context); + context->fallbacks.glClearDepth(depth); }; } return true; } - void WGLContext::Desactivate() + bool WGLContext::Activate() const { - WGLContext*& currentContext = s_currentContext; //< Pay TLS cost only once - if (currentContext == this) + bool succeeded = m_loader.wglMakeCurrent(m_deviceContext, m_handle); + if (!succeeded) { - m_loader.wglMakeCurrent(nullptr, nullptr); - currentContext = nullptr; + NazaraError("failed to activate context: " + Error::GetLastSystemError()); + return false; } + + return true; + } + + void WGLContext::Desactivate() const + { + assert(GetCurrentContext() == this); + m_loader.wglMakeCurrent(nullptr, nullptr); } const Loader& WGLContext::GetLoader() @@ -308,7 +289,7 @@ namespace Nz::GL int pixelFormat = 0; if (m_params.sampleCount > 1) { - WGLContext* currentContext = s_currentContext; //< Pay TLS cost only once + const WGLContext* currentContext = static_cast(GetCurrentContext()); //< Pay TLS cost only once if (currentContext) { // WGL_ARB_pixel_format and WGL_EXT_pixel_format are the same, except for the symbol @@ -320,13 +301,13 @@ namespace Nz::GL WGL_DRAW_TO_WINDOW_ARB, GL_TRUE, WGL_SUPPORT_OPENGL_ARB, GL_TRUE, WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB, - WGL_COLOR_BITS_ARB, (m_params.bitsPerPixel == 32) ? 24 : m_params.bitsPerPixel, - WGL_ALPHA_BITS_ARB, (m_params.bitsPerPixel == 32) ? 8 : 0, - WGL_DEPTH_BITS_ARB, m_params.depthBits, - WGL_STENCIL_BITS_ARB, m_params.stencilBits, - WGL_DOUBLE_BUFFER_ARB, (m_params.doubleBuffering) ? GL_TRUE : GL_FALSE, + WGL_COLOR_BITS_ARB, int((m_params.bitsPerPixel == 32) ? 24 : m_params.bitsPerPixel), + WGL_ALPHA_BITS_ARB, int((m_params.bitsPerPixel == 32) ? 8 : 0), + WGL_DEPTH_BITS_ARB, int(m_params.depthBits), + WGL_STENCIL_BITS_ARB, int(m_params.stencilBits), + WGL_DOUBLE_BUFFER_ARB, int((m_params.doubleBuffering) ? GL_TRUE : GL_FALSE), WGL_SAMPLE_BUFFERS_ARB, GL_TRUE, - WGL_SAMPLES_ARB, m_params.sampleCount + WGL_SAMPLES_ARB, int(m_params.sampleCount) }; int& sampleCount = attributes[attributes.size() - 3]; @@ -344,7 +325,7 @@ namespace Nz::GL } while (sampleCount > 1); - if (m_params.sampleCount != sampleCount) + if (int(m_params.sampleCount) != sampleCount) NazaraWarning("couldn't find a pixel format matching " + std::to_string(m_params.sampleCount) + " sample count, using " + std::to_string(sampleCount) + " sample(s) instead"); m_params.sampleCount = sampleCount; From bd6924d66db95cbbd8b8bfff57c0247a032f2301 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 19 Apr 2020 15:31:48 +0200 Subject: [PATCH 166/316] OpenGL: Handle Spir-V --- .../OpenGLRenderer/OpenGLShaderStage.hpp | 4 +- .../Nazara/OpenGLRenderer/Wrapper/Context.hpp | 23 +- .../Nazara/OpenGLRenderer/Wrapper/Context.inl | 11 + .../OpenGLRenderer/Wrapper/CoreFunctions.hpp | 6 + .../Nazara/OpenGLRenderer/Wrapper/Shader.hpp | 7 +- .../Nazara/OpenGLRenderer/Wrapper/Shader.inl | 60 +- src/Nazara/OpenGLRenderer/OpenGLDevice.cpp | 6 +- .../OpenGLRenderer/OpenGLShaderStage.cpp | 30 +- src/Nazara/OpenGLRenderer/Wrapper/Context.cpp | 7 +- thirdparty/include/GLES3/gl31.h | 1526 ++++++++++++++ thirdparty/include/GLES3/gl32.h | 1827 +++++++++++++++++ 11 files changed, 3454 insertions(+), 53 deletions(-) create mode 100644 thirdparty/include/GLES3/gl31.h create mode 100644 thirdparty/include/GLES3/gl32.h diff --git a/include/Nazara/OpenGLRenderer/OpenGLShaderStage.hpp b/include/Nazara/OpenGLRenderer/OpenGLShaderStage.hpp index 25439872a..579704ffe 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLShaderStage.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLShaderStage.hpp @@ -19,13 +19,11 @@ namespace Nz class NAZARA_OPENGLRENDERER_API OpenGLShaderStage : public ShaderStageImpl { public: - OpenGLShaderStage() = default; + OpenGLShaderStage(OpenGLDevice& device, ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize); OpenGLShaderStage(const OpenGLShaderStage&) = delete; OpenGLShaderStage(OpenGLShaderStage&&) noexcept = default; ~OpenGLShaderStage() = default; - bool Create(OpenGLDevice& device, ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize); - OpenGLShaderStage& operator=(const OpenGLShaderStage&) = delete; OpenGLShaderStage& operator=(OpenGLShaderStage&&) noexcept = default; diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp index f808e5aa3..17cb668cf 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp @@ -8,7 +8,9 @@ #define NAZARA_OPENGLRENDERER_CONTEXTIMPL_HPP #include +#include #include +#include #include #include @@ -20,6 +22,22 @@ namespace Nz::GL OpenGL_ES }; + enum class Extension + { + SpirV, + + Max = SpirV + }; + + enum class ExtensionStatus + { + NotSupported, + + ARB, + EXT, + KHR + }; + struct ContextParams { ContextType type = ContextType::OpenGL_ES; @@ -44,8 +62,10 @@ namespace Nz::GL virtual void EnableVerticalSync(bool enabled) = 0; + inline ExtensionStatus GetExtensionStatus(Extension extension) const; inline const ContextParams& GetParams() const; + inline bool IsExtensionSupported(Extension extension) const; inline bool IsExtensionSupported(const std::string& extension) const; bool Initialize(const ContextParams& params); @@ -53,7 +73,7 @@ namespace Nz::GL virtual void SwapBuffers() = 0; #define NAZARA_OPENGLRENDERER_FUNC(name, sig) sig name = nullptr; - NAZARA_OPENGLRENDERER_FOREACH_GLES_FUNC(NAZARA_OPENGLRENDERER_FUNC) + NAZARA_OPENGLRENDERER_FOREACH_GLES_FUNC(NAZARA_OPENGLRENDERER_FUNC, NAZARA_OPENGLRENDERER_FUNC) #undef NAZARA_OPENGLRENDERER_FUNC static const Context* GetCurrentContext(); @@ -73,6 +93,7 @@ namespace Nz::GL private: void GL_APIENTRY HandleDebugMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message) const; + std::array m_extensionStatus; std::unordered_set m_supportedExtensions; }; } diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Context.inl b/include/Nazara/OpenGLRenderer/Wrapper/Context.inl index 440ef2d38..c384dbc31 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Context.inl +++ b/include/Nazara/OpenGLRenderer/Wrapper/Context.inl @@ -7,11 +7,22 @@ namespace Nz::GL { + + inline ExtensionStatus Context::GetExtensionStatus(Extension extension) const + { + return m_extensionStatus[UnderlyingCast(extension)]; + } + inline const ContextParams& Context::GetParams() const { return m_params; } + inline bool Context::IsExtensionSupported(Extension extension) const + { + return GetExtensionStatus(extension) != ExtensionStatus::NotSupported; + } + inline bool Context::IsExtensionSupported(const std::string& extension) const { return m_supportedExtensions.find(extension) != m_supportedExtensions.end(); diff --git a/include/Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp b/include/Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp index 20057430b..ac90702c9 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp @@ -11,6 +11,10 @@ #include #include +// Define some OpenGL (not ES) extensions +#define GL_SHADER_BINARY_FORMAT_SPIR_V_ARB 0x9551 +#define GL_SPIR_V_BINARY_ARB 0x9552 +typedef void (GL_APIENTRYP PFNGLSPECIALIZESHADERARBPROC) (GLuint shader, const GLchar* pEntryPoint, GLuint numSpecializationConstants, const GLuint* pConstantIndex, const GLuint* pConstantValue); // OpenGL core #define NAZARA_OPENGLRENDERER_FOREACH_GLES_FUNC(cb, extCb) \ @@ -143,5 +147,7 @@ cb(glViewport, PFNGLVIEWPORTPROC) \ \ extCb(glDebugMessageCallback, PFNGLDEBUGMESSAGECALLBACKPROC) \ + \ + extCb(glSpecializeShaderARB, PFNGLSPECIALIZESHADERARBPROC) \ #endif diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Shader.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Shader.hpp index 62d4effb7..13eda392b 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Shader.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Shader.hpp @@ -21,14 +21,19 @@ namespace Nz::GL Shader(Shader&&) noexcept = default; inline ~Shader(); - inline bool Compile(std::string* error = nullptr); + inline void Compile(); inline bool Create(OpenGLDevice& device, GLenum type); inline void Destroy(); + inline bool GetCompilationStatus(std::string* error = nullptr); + inline void SetBinarySource(GLenum binaryFormat, const void* binary, GLsizei length); inline void SetSource(const char* source, GLint length); + // GL_ARB_gl_spirv + inline void SpecializeShader(const GLchar* pEntryPoint, GLuint numSpecializationConstants, const GLuint* pConstantIndex, const GLuint* pConstantValue); + Shader& operator=(const Shader&) = delete; Shader& operator=(Shader&&) noexcept = default; diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Shader.inl b/include/Nazara/OpenGLRenderer/Wrapper/Shader.inl index aa4cf82bd..e7a5e4f11 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Shader.inl +++ b/include/Nazara/OpenGLRenderer/Wrapper/Shader.inl @@ -13,11 +13,37 @@ namespace Nz::GL Destroy(); } - inline bool Shader::Compile(std::string* error) + inline void Shader::Compile() + { + assert(m_shader); + m_device->GetReferenceContext().glCompileShader(m_shader); + } + + inline bool Shader::Create(OpenGLDevice& device, GLenum type) + { + Destroy(); + + m_device = &device; + m_shader = device.GetReferenceContext().glCreateShader(type); + if (!m_shader) + return false; //< TODO: Handle error messages + + return true; + } + + inline void Shader::Destroy() + { + if (m_shader) + { + m_device->GetReferenceContext().glDeleteShader(m_shader); + m_shader = 0; + } + } + + inline bool Shader::GetCompilationStatus(std::string* error) { assert(m_shader); const GL::Context& context = m_device->GetReferenceContext(); - context.glCompileShader(m_shader); GLint success; context.glGetShaderiv(m_shader, GL_COMPILE_STATUS, &success); @@ -43,27 +69,6 @@ namespace Nz::GL return true; } - inline bool Shader::Create(OpenGLDevice& device, GLenum type) - { - Destroy(); - - m_device = &device; - m_shader = device.GetReferenceContext().glCreateShader(type); - if (!m_shader) - return false; //< TODO: Handle error messages - - return true; - } - - inline void Shader::Destroy() - { - if (m_shader) - { - m_device->GetReferenceContext().glDeleteShader(m_shader); - m_shader = 0; - } - } - inline void Shader::SetBinarySource(GLenum binaryFormat, const void* binary, GLsizei length) { assert(m_shader); @@ -77,6 +82,15 @@ namespace Nz::GL m_device->GetReferenceContext().glShaderSource(m_shader, 1U, &source, &length); } + + inline void Shader::SpecializeShader(const GLchar* pEntryPoint, GLuint numSpecializationConstants, const GLuint* pConstantIndex, const GLuint* pConstantValue) + { + assert(m_shader); + const GL::Context& context = m_device->GetReferenceContext(); + assert(context.glSpecializeShaderARB); + + context.glSpecializeShaderARB(m_shader, pEntryPoint, numSpecializationConstants, pConstantIndex, pConstantValue); + } } #include diff --git a/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp b/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp index c62cb2cd1..afc0da3d5 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp @@ -53,11 +53,7 @@ namespace Nz std::shared_ptr OpenGLDevice::InstantiateShaderStage(ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) { - auto shaderStage = std::make_shared(); - if (!shaderStage->Create(*this, type, lang, source, sourceSize)) - return {}; - - return shaderStage; + return std::make_shared(*this, type, lang, source, sourceSize); } std::unique_ptr OpenGLDevice::InstantiateTexture(const TextureInfo& params) diff --git a/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp b/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp index 0d8072596..3364e4f11 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp @@ -5,47 +5,39 @@ #include #include #include +#include #include namespace Nz { - bool OpenGLShaderStage::Create(OpenGLDevice& device, ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) + OpenGLShaderStage::OpenGLShaderStage(OpenGLDevice& device, ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) { if (!m_shader.Create(device, ToOpenGL(type))) - return false; //< TODO: Handle error message + throw std::runtime_error("failed to create shader"); //< TODO: Handle error message switch (lang) { case ShaderLanguage::GLSL: m_shader.SetSource(reinterpret_cast(source), GLint(sourceSize)); + m_shader.Compile(); break; case ShaderLanguage::SpirV: { - if (!device.GetReferenceContext().IsExtensionSupported("GL_ARB_gl_spirv")) - { - NazaraError("Spir-V is not supported"); - return false; - } + if (!device.GetReferenceContext().IsExtensionSupported(GL::Extension::SpirV)) + throw std::runtime_error("SpirV is not supported by this OpenGL implementation"); - constexpr GLenum SHADER_BINARY_FORMAT_SPIR_V = 0x9551; - - m_shader.SetBinarySource(SHADER_BINARY_FORMAT_SPIR_V, source, GLsizei(sourceSize)); + m_shader.SetBinarySource(GL_SHADER_BINARY_FORMAT_SPIR_V_ARB, source, GLsizei(sourceSize)); + m_shader.SpecializeShader("main", 0U, nullptr, nullptr); break; } default: - NazaraError("Unsupported shader language"); - return false; + throw std::runtime_error("Unsupported shader language"); } std::string errorLog; - if (!m_shader.Compile(&errorLog)) - { - NazaraError("Failed to compile shader: " + errorLog); - return false; - } - - return true; + if (!m_shader.GetCompilationStatus(&errorLog)) + throw std::runtime_error("Failed to compile shader: " + errorLog); } } diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp index 5ef19ecf1..08e8077db 100644 --- a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp +++ b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp @@ -11,7 +11,8 @@ namespace Nz::GL { - Context::~Context() = default; + thread_local const Context* s_currentContext = nullptr; + bool Context::Initialize(const ContextParams& params) { @@ -70,6 +71,10 @@ namespace Nz::GL return true; }); + m_extensionStatus.fill(ExtensionStatus::NotSupported); + if (m_supportedExtensions.count("GL_ARB_gl_spirv")) + m_extensionStatus[UnderlyingCast(Extension::SpirV)] = ExtensionStatus::ARB; + #define NAZARA_OPENGLRENDERER_FUNC(name, sig) #define NAZARA_OPENGLRENDERER_EXT_FUNC(name, sig) LoadSymbol(name, #name, false); NAZARA_OPENGLRENDERER_FOREACH_GLES_FUNC(NAZARA_OPENGLRENDERER_FUNC, NAZARA_OPENGLRENDERER_EXT_FUNC) diff --git a/thirdparty/include/GLES3/gl31.h b/thirdparty/include/GLES3/gl31.h new file mode 100644 index 000000000..0015beca1 --- /dev/null +++ b/thirdparty/include/GLES3/gl31.h @@ -0,0 +1,1526 @@ +#ifndef __gles2_gl31_h_ +#define __gles2_gl31_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2013-2018 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are 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 Materials. +** +** THE MATERIALS ARE 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 +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ +/* +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** https://github.com/KhronosGroup/OpenGL-Registry +*/ + +#include + +#ifndef GL_APIENTRYP +#define GL_APIENTRYP GL_APIENTRY* +#endif + +#ifndef GL_GLES_PROTOTYPES +#define GL_GLES_PROTOTYPES 1 +#endif + +/* Generated on date 20191013 */ + +/* Generated C header for: + * API: gles2 + * Profile: common + * Versions considered: 2\.[0-9]|3\.[01] + * Versions emitted: .* + * Default extensions included: None + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef GL_ES_VERSION_2_0 +#define GL_ES_VERSION_2_0 1 +#include +typedef khronos_int8_t GLbyte; +typedef khronos_float_t GLclampf; +typedef khronos_int32_t GLfixed; +typedef khronos_int16_t GLshort; +typedef khronos_uint16_t GLushort; +typedef void GLvoid; +typedef struct __GLsync *GLsync; +typedef khronos_int64_t GLint64; +typedef khronos_uint64_t GLuint64; +typedef unsigned int GLenum; +typedef unsigned int GLuint; +typedef char GLchar; +typedef khronos_float_t GLfloat; +typedef khronos_ssize_t GLsizeiptr; +typedef khronos_intptr_t GLintptr; +typedef unsigned int GLbitfield; +typedef int GLint; +typedef unsigned char GLboolean; +typedef int GLsizei; +typedef khronos_uint8_t GLubyte; +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_COLOR_BUFFER_BIT 0x00004000 +#define GL_FALSE 0 +#define GL_TRUE 1 +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 +#define GL_FUNC_ADD 0x8006 +#define GL_BLEND_EQUATION 0x8009 +#define GL_BLEND_EQUATION_RGB 0x8009 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_STREAM_DRAW 0x88E0 +#define GL_STATIC_DRAW 0x88E4 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_FRONT 0x0404 +#define GL_BACK 0x0405 +#define GL_FRONT_AND_BACK 0x0408 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_CULL_FACE 0x0B44 +#define GL_BLEND 0x0BE2 +#define GL_DITHER 0x0BD0 +#define GL_STENCIL_TEST 0x0B90 +#define GL_DEPTH_TEST 0x0B71 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_POLYGON_OFFSET_FILL 0x8037 +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_OUT_OF_MEMORY 0x0505 +#define GL_CW 0x0900 +#define GL_CCW 0x0901 +#define GL_LINE_WIDTH 0x0B21 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_FRONT_FACE 0x0B46 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#define GL_VIEWPORT 0x0BA2 +#define GL_SCISSOR_BOX 0x0C10 +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_RED_BITS 0x0D52 +#define GL_GREEN_BITS 0x0D53 +#define GL_BLUE_BITS 0x0D54 +#define GL_ALPHA_BITS 0x0D55 +#define GL_DEPTH_BITS 0x0D56 +#define GL_STENCIL_BITS 0x0D57 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_INT 0x1404 +#define GL_UNSIGNED_INT 0x1405 +#define GL_FLOAT 0x1406 +#define GL_FIXED 0x140C +#define GL_DEPTH_COMPONENT 0x1902 +#define GL_ALPHA 0x1906 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE_ALPHA 0x190A +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_SHADER_TYPE 0x8B4F +#define GL_DELETE_STATUS 0x8B80 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_NEVER 0x0200 +#define GL_LESS 0x0201 +#define GL_EQUAL 0x0202 +#define GL_LEQUAL 0x0203 +#define GL_GREATER 0x0204 +#define GL_NOTEQUAL 0x0205 +#define GL_GEQUAL 0x0206 +#define GL_ALWAYS 0x0207 +#define GL_KEEP 0x1E00 +#define GL_REPLACE 0x1E01 +#define GL_INCR 0x1E02 +#define GL_DECR 0x1E03 +#define GL_INVERT 0x150A +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 +#define GL_NEAREST 0x2600 +#define GL_LINEAR 0x2601 +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 +#define GL_TEXTURE 0x1702 +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_REPEAT 0x2901 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_COMPILE_STATUS 0x8B81 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RGBA4 0x8056 +#define GL_RGB5_A1 0x8057 +#define GL_RGB565 0x8D62 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_NONE 0 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +typedef void (GL_APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (GL_APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (GL_APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (GL_APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); +typedef void (GL_APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); +typedef void (GL_APIENTRYP PFNGLBINDTEXTUREPROC) (GLenum target, GLuint texture); +typedef void (GL_APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCPROC) (GLenum sfactor, GLenum dfactor); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (GL_APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +typedef void (GL_APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +typedef GLenum (GL_APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLCLEARPROC) (GLbitfield mask); +typedef void (GL_APIENTRYP PFNGLCLEARCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (GL_APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); +typedef void (GL_APIENTRYP PFNGLCLEARSTENCILPROC) (GLint s); +typedef void (GL_APIENTRYP PFNGLCOLORMASKPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +typedef void (GL_APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLCOPYTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef GLuint (GL_APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (GL_APIENTRYP PFNGLCULLFACEPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (GL_APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (GL_APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (GL_APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (GL_APIENTRYP PFNGLDELETETEXTURESPROC) (GLsizei n, const GLuint *textures); +typedef void (GL_APIENTRYP PFNGLDEPTHFUNCPROC) (GLenum func); +typedef void (GL_APIENTRYP PFNGLDEPTHMASKPROC) (GLboolean flag); +typedef void (GL_APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); +typedef void (GL_APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (GL_APIENTRYP PFNGLDISABLEPROC) (GLenum cap); +typedef void (GL_APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices); +typedef void (GL_APIENTRYP PFNGLENABLEPROC) (GLenum cap); +typedef void (GL_APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (GL_APIENTRYP PFNGLFINISHPROC) (void); +typedef void (GL_APIENTRYP PFNGLFLUSHPROC) (void); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (GL_APIENTRYP PFNGLFRONTFACEPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef void (GL_APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef void (GL_APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (GL_APIENTRYP PFNGLGENTEXTURESPROC) (GLsizei n, GLuint *textures); +typedef void (GL_APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +typedef GLint (GL_APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETBOOLEANVPROC) (GLenum pname, GLboolean *data); +typedef void (GL_APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLenum (GL_APIENTRYP PFNGLGETERRORPROC) (void); +typedef void (GL_APIENTRYP PFNGLGETFLOATVPROC) (GLenum pname, GLfloat *data); +typedef void (GL_APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *data); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (GL_APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (GL_APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void (GL_APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef const GLubyte *(GL_APIENTRYP PFNGLGETSTRINGPROC) (GLenum name); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef GLint (GL_APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void **pointer); +typedef void (GL_APIENTRYP PFNGLHINTPROC) (GLenum target, GLenum mode); +typedef GLboolean (GL_APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef GLboolean (GL_APIENTRYP PFNGLISENABLEDPROC) (GLenum cap); +typedef GLboolean (GL_APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); +typedef GLboolean (GL_APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (GL_APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); +typedef GLboolean (GL_APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef GLboolean (GL_APIENTRYP PFNGLISTEXTUREPROC) (GLuint texture); +typedef void (GL_APIENTRYP PFNGLLINEWIDTHPROC) (GLfloat width); +typedef void (GL_APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLPOLYGONOFFSETPROC) (GLfloat factor, GLfloat units); +typedef void (GL_APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); +typedef void (GL_APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); +typedef void (GL_APIENTRYP PFNGLSCISSORPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length); +typedef void (GL_APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +typedef void (GL_APIENTRYP PFNGLSTENCILFUNCPROC) (GLenum func, GLint ref, GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILMASKPROC) (GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILOPPROC) (GLenum fail, GLenum zfail, GLenum zpass); +typedef void (GL_APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (GL_APIENTRYP PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (GL_APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (GL_APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (GL_APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (GL_APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (GL_APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (GL_APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (GL_APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (GL_APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +typedef void (GL_APIENTRYP PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +#if GL_GLES_PROTOTYPES +GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture); +GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader); +GL_APICALL void GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); +GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); +GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); +GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLuint texture); +GL_APICALL void GL_APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GL_APICALL void GL_APIENTRY glBlendEquation (GLenum mode); +GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); +GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); +GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target); +GL_APICALL void GL_APIENTRY glClear (GLbitfield mask); +GL_APICALL void GL_APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GL_APICALL void GL_APIENTRY glClearDepthf (GLfloat d); +GL_APICALL void GL_APIENTRY glClearStencil (GLint s); +GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader); +GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL GLuint GL_APIENTRY glCreateProgram (void); +GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type); +GL_APICALL void GL_APIENTRY glCullFace (GLenum mode); +GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); +GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); +GL_APICALL void GL_APIENTRY glDeleteProgram (GLuint program); +GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); +GL_APICALL void GL_APIENTRY glDeleteShader (GLuint shader); +GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures); +GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func); +GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag); +GL_APICALL void GL_APIENTRY glDepthRangef (GLfloat n, GLfloat f); +GL_APICALL void GL_APIENTRY glDetachShader (GLuint program, GLuint shader); +GL_APICALL void GL_APIENTRY glDisable (GLenum cap); +GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index); +GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); +GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const void *indices); +GL_APICALL void GL_APIENTRY glEnable (GLenum cap); +GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index); +GL_APICALL void GL_APIENTRY glFinish (void); +GL_APICALL void GL_APIENTRY glFlush (void); +GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode); +GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); +GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target); +GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); +GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); +GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint *textures); +GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +GL_APICALL GLint GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); +GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean *data); +GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); +GL_APICALL GLenum GL_APIENTRY glGetError (void); +GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat *data); +GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint *data); +GL_APICALL void GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +GL_APICALL void GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +GL_APICALL const GLubyte *GL_APIENTRY glGetString (GLenum name); +GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); +GL_APICALL GLint GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); +GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer); +GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode); +GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLuint buffer); +GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap); +GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer); +GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program); +GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader); +GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture); +GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width); +GL_APICALL void GL_APIENTRY glLinkProgram (GLuint program); +GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units); +GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); +GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void); +GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); +GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length); +GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask); +GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); +GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); +GL_APICALL void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GL_APICALL void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params); +GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat v0); +GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint v0); +GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); +GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); +GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); +GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUseProgram (GLuint program); +GL_APICALL void GL_APIENTRY glValidateProgram (GLuint program); +GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); +GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); +GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); +#endif +#endif /* GL_ES_VERSION_2_0 */ + +#ifndef GL_ES_VERSION_3_0 +#define GL_ES_VERSION_3_0 1 +typedef khronos_uint16_t GLhalf; +#define GL_READ_BUFFER 0x0C02 +#define GL_UNPACK_ROW_LENGTH 0x0CF2 +#define GL_UNPACK_SKIP_ROWS 0x0CF3 +#define GL_UNPACK_SKIP_PIXELS 0x0CF4 +#define GL_PACK_ROW_LENGTH 0x0D02 +#define GL_PACK_SKIP_ROWS 0x0D03 +#define GL_PACK_SKIP_PIXELS 0x0D04 +#define GL_COLOR 0x1800 +#define GL_DEPTH 0x1801 +#define GL_STENCIL 0x1802 +#define GL_RED 0x1903 +#define GL_RGB8 0x8051 +#define GL_RGBA8 0x8058 +#define GL_RGB10_A2 0x8059 +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_COMPARE_REF_TO_TEXTURE 0x884E +#define GL_MAJOR_VERSION 0x821B +#define GL_MINOR_VERSION 0x821C +#define GL_NUM_EXTENSIONS 0x821D +#define GL_RGBA32F 0x8814 +#define GL_RGB32F 0x8815 +#define GL_RGBA16F 0x881A +#define GL_RGB16F 0x881B +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_MAX_VARYING_COMPONENTS 0x8B4B +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_RGB9_E5 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_RGBA32UI 0x8D70 +#define GL_RGB32UI 0x8D71 +#define GL_RGBA16UI 0x8D76 +#define GL_RGB16UI 0x8D77 +#define GL_RGBA8UI 0x8D7C +#define GL_RGB8UI 0x8D7D +#define GL_RGBA32I 0x8D82 +#define GL_RGB32I 0x8D83 +#define GL_RGBA16I 0x8D88 +#define GL_RGB16I 0x8D89 +#define GL_RGBA8I 0x8D8E +#define GL_RGB8I 0x8D8F +#define GL_RED_INTEGER 0x8D94 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RGBA_INTEGER 0x8D99 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_BUFFER_ACCESS_FLAGS 0x911F +#define GL_BUFFER_MAP_LENGTH 0x9120 +#define GL_BUFFER_MAP_OFFSET 0x9121 +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_COLOR_ATTACHMENT16 0x8CF0 +#define GL_COLOR_ATTACHMENT17 0x8CF1 +#define GL_COLOR_ATTACHMENT18 0x8CF2 +#define GL_COLOR_ATTACHMENT19 0x8CF3 +#define GL_COLOR_ATTACHMENT20 0x8CF4 +#define GL_COLOR_ATTACHMENT21 0x8CF5 +#define GL_COLOR_ATTACHMENT22 0x8CF6 +#define GL_COLOR_ATTACHMENT23 0x8CF7 +#define GL_COLOR_ATTACHMENT24 0x8CF8 +#define GL_COLOR_ATTACHMENT25 0x8CF9 +#define GL_COLOR_ATTACHMENT26 0x8CFA +#define GL_COLOR_ATTACHMENT27 0x8CFB +#define GL_COLOR_ATTACHMENT28 0x8CFC +#define GL_COLOR_ATTACHMENT29 0x8CFD +#define GL_COLOR_ATTACHMENT30 0x8CFE +#define GL_COLOR_ATTACHMENT31 0x8CFF +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#define GL_HALF_FLOAT 0x140B +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_RG8 0x822B +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 +#define GL_COPY_READ_BUFFER 0x8F36 +#define GL_COPY_WRITE_BUFFER 0x8F37 +#define GL_COPY_READ_BUFFER_BINDING 0x8F36 +#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_INVALID_INDEX 0xFFFFFFFFu +#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 +#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_OBJECT_TYPE 0x9112 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_STATUS 0x9114 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_UNSIGNALED 0x9118 +#define GL_SIGNALED 0x9119 +#define GL_ALREADY_SIGNALED 0x911A +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_CONDITION_SATISFIED 0x911C +#define GL_WAIT_FAILED 0x911D +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A +#define GL_SAMPLER_BINDING 0x8919 +#define GL_RGB10_A2UI 0x906F +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_GREEN 0x1904 +#define GL_BLUE 0x1905 +#define GL_INT_2_10_10_10_REV 0x8D9F +#define GL_TRANSFORM_FEEDBACK 0x8E22 +#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 +#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 +#define GL_PROGRAM_BINARY_LENGTH 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE +#define GL_PROGRAM_BINARY_FORMATS 0x87FF +#define GL_COMPRESSED_R11_EAC 0x9270 +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define GL_COMPRESSED_RG11_EAC 0x9272 +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F +#define GL_MAX_ELEMENT_INDEX 0x8D6B +#define GL_NUM_SAMPLE_COUNTS 0x9380 +#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF +typedef void (GL_APIENTRYP PFNGLREADBUFFERPROC) (GLenum src); +typedef void (GL_APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (GL_APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (GL_APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (GL_APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (GL_APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, void **params); +typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void *(GL_APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +typedef void (GL_APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); +typedef void (GL_APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); +typedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); +typedef void (GL_APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); +typedef void (GL_APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); +typedef void (GL_APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); +typedef void (GL_APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (GL_APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (GL_APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +typedef void (GL_APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); +typedef void (GL_APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); +typedef GLint (GL_APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); +typedef void (GL_APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (GL_APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (GL_APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (GL_APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (GL_APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef const GLubyte *(GL_APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); +typedef void (GL_APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (GL_APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +typedef void (GL_APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +typedef GLuint (GL_APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); +typedef void (GL_APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +typedef void (GL_APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); +typedef GLsync (GL_APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (GL_APIENTRYP PFNGLISSYNCPROC) (GLsync sync); +typedef void (GL_APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); +typedef GLenum (GL_APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *data); +typedef void (GL_APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +typedef void (GL_APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); +typedef void (GL_APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); +typedef void (GL_APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); +typedef void (GL_APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); +typedef GLboolean (GL_APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); +typedef void (GL_APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); +typedef void (GL_APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); +typedef void (GL_APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); +typedef void (GL_APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (GL_APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); +typedef void (GL_APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); +typedef void (GL_APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +typedef void (GL_APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); +typedef void (GL_APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); +typedef void (GL_APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); +typedef void (GL_APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (GL_APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +#if GL_GLES_PROTOTYPES +GL_APICALL void GL_APIENTRY glReadBuffer (GLenum src); +GL_APICALL void GL_APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +GL_APICALL void GL_APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glGenQueries (GLsizei n, GLuint *ids); +GL_APICALL void GL_APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); +GL_APICALL GLboolean GL_APIENTRY glIsQuery (GLuint id); +GL_APICALL void GL_APIENTRY glBeginQuery (GLenum target, GLuint id); +GL_APICALL void GL_APIENTRY glEndQuery (GLenum target); +GL_APICALL void GL_APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); +GL_APICALL GLboolean GL_APIENTRY glUnmapBuffer (GLenum target); +GL_APICALL void GL_APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, void **params); +GL_APICALL void GL_APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); +GL_APICALL void GL_APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GL_APICALL void *GL_APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GL_APICALL void GL_APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); +GL_APICALL void GL_APIENTRY glBindVertexArray (GLuint array); +GL_APICALL void GL_APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); +GL_APICALL void GL_APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); +GL_APICALL GLboolean GL_APIENTRY glIsVertexArray (GLuint array); +GL_APICALL void GL_APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); +GL_APICALL void GL_APIENTRY glBeginTransformFeedback (GLenum primitiveMode); +GL_APICALL void GL_APIENTRY glEndTransformFeedback (void); +GL_APICALL void GL_APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GL_APICALL void GL_APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); +GL_APICALL void GL_APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +GL_APICALL void GL_APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GL_APICALL void GL_APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GL_APICALL void GL_APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); +GL_APICALL void GL_APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); +GL_APICALL void GL_APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GL_APICALL void GL_APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); +GL_APICALL void GL_APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); +GL_APICALL void GL_APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); +GL_APICALL GLint GL_APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); +GL_APICALL void GL_APIENTRY glUniform1ui (GLint location, GLuint v0); +GL_APICALL void GL_APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); +GL_APICALL void GL_APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); +GL_APICALL void GL_APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GL_APICALL void GL_APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); +GL_APICALL void GL_APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); +GL_APICALL void GL_APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); +GL_APICALL void GL_APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GL_APICALL const GLubyte *GL_APIENTRY glGetStringi (GLenum name, GLuint index); +GL_APICALL void GL_APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GL_APICALL void GL_APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +GL_APICALL void GL_APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +GL_APICALL GLuint GL_APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); +GL_APICALL void GL_APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +GL_APICALL void GL_APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +GL_APICALL void GL_APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +GL_APICALL void GL_APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); +GL_APICALL GLsync GL_APIENTRY glFenceSync (GLenum condition, GLbitfield flags); +GL_APICALL GLboolean GL_APIENTRY glIsSync (GLsync sync); +GL_APICALL void GL_APIENTRY glDeleteSync (GLsync sync); +GL_APICALL GLenum GL_APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glGetInteger64v (GLenum pname, GLint64 *data); +GL_APICALL void GL_APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +GL_APICALL void GL_APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); +GL_APICALL void GL_APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); +GL_APICALL void GL_APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); +GL_APICALL void GL_APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); +GL_APICALL GLboolean GL_APIENTRY glIsSampler (GLuint sampler); +GL_APICALL void GL_APIENTRY glBindSampler (GLuint unit, GLuint sampler); +GL_APICALL void GL_APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); +GL_APICALL void GL_APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); +GL_APICALL void GL_APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); +GL_APICALL void GL_APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); +GL_APICALL void GL_APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); +GL_APICALL void GL_APIENTRY glBindTransformFeedback (GLenum target, GLuint id); +GL_APICALL void GL_APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); +GL_APICALL void GL_APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); +GL_APICALL GLboolean GL_APIENTRY glIsTransformFeedback (GLuint id); +GL_APICALL void GL_APIENTRY glPauseTransformFeedback (void); +GL_APICALL void GL_APIENTRY glResumeTransformFeedback (void); +GL_APICALL void GL_APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +GL_APICALL void GL_APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); +GL_APICALL void GL_APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); +GL_APICALL void GL_APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments); +GL_APICALL void GL_APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GL_APICALL void GL_APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +#endif +#endif /* GL_ES_VERSION_3_0 */ + +#ifndef GL_ES_VERSION_3_1 +#define GL_ES_VERSION_3_1 1 +#define GL_COMPUTE_SHADER 0x91B9 +#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB +#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC +#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD +#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 +#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 +#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 +#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 +#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 +#define GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS 0x90EB +#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE +#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF +#define GL_COMPUTE_WORK_GROUP_SIZE 0x8267 +#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE +#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF +#define GL_COMPUTE_SHADER_BIT 0x00000020 +#define GL_DRAW_INDIRECT_BUFFER 0x8F3F +#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 +#define GL_MAX_UNIFORM_LOCATIONS 0x826E +#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 +#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 +#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313 +#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314 +#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315 +#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316 +#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318 +#define GL_UNIFORM 0x92E1 +#define GL_UNIFORM_BLOCK 0x92E2 +#define GL_PROGRAM_INPUT 0x92E3 +#define GL_PROGRAM_OUTPUT 0x92E4 +#define GL_BUFFER_VARIABLE 0x92E5 +#define GL_SHADER_STORAGE_BLOCK 0x92E6 +#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 +#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 +#define GL_ACTIVE_RESOURCES 0x92F5 +#define GL_MAX_NAME_LENGTH 0x92F6 +#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 +#define GL_NAME_LENGTH 0x92F9 +#define GL_TYPE 0x92FA +#define GL_ARRAY_SIZE 0x92FB +#define GL_OFFSET 0x92FC +#define GL_BLOCK_INDEX 0x92FD +#define GL_ARRAY_STRIDE 0x92FE +#define GL_MATRIX_STRIDE 0x92FF +#define GL_IS_ROW_MAJOR 0x9300 +#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 +#define GL_BUFFER_BINDING 0x9302 +#define GL_BUFFER_DATA_SIZE 0x9303 +#define GL_NUM_ACTIVE_VARIABLES 0x9304 +#define GL_ACTIVE_VARIABLES 0x9305 +#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 +#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A +#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B +#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C +#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D +#define GL_LOCATION 0x930E +#define GL_VERTEX_SHADER_BIT 0x00000001 +#define GL_FRAGMENT_SHADER_BIT 0x00000002 +#define GL_ALL_SHADER_BITS 0xFFFFFFFF +#define GL_PROGRAM_SEPARABLE 0x8258 +#define GL_ACTIVE_PROGRAM 0x8259 +#define GL_PROGRAM_PIPELINE_BINDING 0x825A +#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 +#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 +#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 +#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC +#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 +#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 +#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 +#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 +#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC +#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 +#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB +#define GL_MAX_IMAGE_UNITS 0x8F38 +#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA +#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE +#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF +#define GL_IMAGE_BINDING_NAME 0x8F3A +#define GL_IMAGE_BINDING_LEVEL 0x8F3B +#define GL_IMAGE_BINDING_LAYERED 0x8F3C +#define GL_IMAGE_BINDING_LAYER 0x8F3D +#define GL_IMAGE_BINDING_ACCESS 0x8F3E +#define GL_IMAGE_BINDING_FORMAT 0x906E +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 +#define GL_COMMAND_BARRIER_BIT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 +#define GL_ALL_BARRIER_BITS 0xFFFFFFFF +#define GL_IMAGE_2D 0x904D +#define GL_IMAGE_3D 0x904E +#define GL_IMAGE_CUBE 0x9050 +#define GL_IMAGE_2D_ARRAY 0x9053 +#define GL_INT_IMAGE_2D 0x9058 +#define GL_INT_IMAGE_3D 0x9059 +#define GL_INT_IMAGE_CUBE 0x905B +#define GL_INT_IMAGE_2D_ARRAY 0x905E +#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 +#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 +#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_SHADER_STORAGE_BUFFER 0x90D2 +#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 +#define GL_SHADER_STORAGE_BUFFER_START 0x90D4 +#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 +#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 +#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA +#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB +#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC +#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD +#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE +#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF +#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 +#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 +#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA +#define GL_STENCIL_INDEX 0x1901 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F +#define GL_SAMPLE_POSITION 0x8E50 +#define GL_SAMPLE_MASK 0x8E51 +#define GL_SAMPLE_MASK_VALUE 0x8E52 +#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 +#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E +#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F +#define GL_MAX_INTEGER_SAMPLES 0x9110 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 +#define GL_TEXTURE_SAMPLES 0x9106 +#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 +#define GL_TEXTURE_WIDTH 0x1000 +#define GL_TEXTURE_HEIGHT 0x1001 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 +#define GL_TEXTURE_RED_SIZE 0x805C +#define GL_TEXTURE_GREEN_SIZE 0x805D +#define GL_TEXTURE_BLUE_SIZE 0x805E +#define GL_TEXTURE_ALPHA_SIZE 0x805F +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_TEXTURE_SHARED_SIZE 0x8C3F +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 +#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A +#define GL_VERTEX_ATTRIB_BINDING 0x82D4 +#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 +#define GL_VERTEX_BINDING_DIVISOR 0x82D6 +#define GL_VERTEX_BINDING_OFFSET 0x82D7 +#define GL_VERTEX_BINDING_STRIDE 0x82D8 +#define GL_VERTEX_BINDING_BUFFER 0x8F4F +#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 +#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA +#define GL_MAX_VERTEX_ATTRIB_STRIDE 0x82E5 +typedef void (GL_APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +typedef void (GL_APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +typedef GLuint (GL_APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +typedef GLint (GL_APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); +typedef void (GL_APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); +typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar *const*strings); +typedef void (GL_APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (GL_APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); +typedef void (GL_APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); +typedef GLboolean (GL_APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (GL_APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +typedef void (GL_APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (GL_APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); +typedef void (GL_APIENTRYP PFNGLMEMORYBARRIERBYREGIONPROC) (GLbitfield barriers); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (GL_APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (GL_APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint maskNumber, GLbitfield mask); +typedef void (GL_APIENTRYP PFNGLGETTEXLEVELPARAMETERIVPROC) (GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETTEXLEVELPARAMETERFVPROC) (GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex); +typedef void (GL_APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor); +#if GL_GLES_PROTOTYPES +GL_APICALL void GL_APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +GL_APICALL void GL_APIENTRY glDispatchComputeIndirect (GLintptr indirect); +GL_APICALL void GL_APIENTRY glDrawArraysIndirect (GLenum mode, const void *indirect); +GL_APICALL void GL_APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect); +GL_APICALL void GL_APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +GL_APICALL GLuint GL_APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name); +GL_APICALL void GL_APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +GL_APICALL void GL_APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +GL_APICALL GLint GL_APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name); +GL_APICALL void GL_APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); +GL_APICALL void GL_APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); +GL_APICALL GLuint GL_APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar *const*strings); +GL_APICALL void GL_APIENTRY glBindProgramPipeline (GLuint pipeline); +GL_APICALL void GL_APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); +GL_APICALL void GL_APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); +GL_APICALL GLboolean GL_APIENTRY glIsProgramPipeline (GLuint pipeline); +GL_APICALL void GL_APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); +GL_APICALL void GL_APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); +GL_APICALL void GL_APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GL_APICALL void GL_APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GL_APICALL void GL_APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); +GL_APICALL void GL_APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); +GL_APICALL void GL_APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GL_APICALL void GL_APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GL_APICALL void GL_APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); +GL_APICALL void GL_APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GL_APICALL void GL_APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GL_APICALL void GL_APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GL_APICALL void GL_APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glValidateProgramPipeline (GLuint pipeline); +GL_APICALL void GL_APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GL_APICALL void GL_APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +GL_APICALL void GL_APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); +GL_APICALL void GL_APIENTRY glMemoryBarrier (GLbitfield barriers); +GL_APICALL void GL_APIENTRY glMemoryBarrierByRegion (GLbitfield barriers); +GL_APICALL void GL_APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GL_APICALL void GL_APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); +GL_APICALL void GL_APIENTRY glSampleMaski (GLuint maskNumber, GLbitfield mask); +GL_APICALL void GL_APIENTRY glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat *params); +GL_APICALL void GL_APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GL_APICALL void GL_APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GL_APICALL void GL_APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GL_APICALL void GL_APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex); +GL_APICALL void GL_APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor); +#endif +#endif /* GL_ES_VERSION_3_1 */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/include/GLES3/gl32.h b/thirdparty/include/GLES3/gl32.h new file mode 100644 index 000000000..3b2487e2f --- /dev/null +++ b/thirdparty/include/GLES3/gl32.h @@ -0,0 +1,1827 @@ +#ifndef __gles2_gl32_h_ +#define __gles2_gl32_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2013-2018 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are 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 Materials. +** +** THE MATERIALS ARE 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 +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ +/* +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** https://github.com/KhronosGroup/OpenGL-Registry +*/ + +#include + +#ifndef GL_APIENTRYP +#define GL_APIENTRYP GL_APIENTRY* +#endif + +#ifndef GL_GLES_PROTOTYPES +#define GL_GLES_PROTOTYPES 1 +#endif + +/* Generated on date 20191013 */ + +/* Generated C header for: + * API: gles2 + * Profile: common + * Versions considered: 2\.[0-9]|3\.[012] + * Versions emitted: .* + * Default extensions included: None + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef GL_ES_VERSION_2_0 +#define GL_ES_VERSION_2_0 1 +#include +typedef khronos_int8_t GLbyte; +typedef khronos_float_t GLclampf; +typedef khronos_int32_t GLfixed; +typedef khronos_int16_t GLshort; +typedef khronos_uint16_t GLushort; +typedef void GLvoid; +typedef struct __GLsync *GLsync; +typedef khronos_int64_t GLint64; +typedef khronos_uint64_t GLuint64; +typedef unsigned int GLenum; +typedef unsigned int GLuint; +typedef char GLchar; +typedef khronos_float_t GLfloat; +typedef khronos_ssize_t GLsizeiptr; +typedef khronos_intptr_t GLintptr; +typedef unsigned int GLbitfield; +typedef int GLint; +typedef unsigned char GLboolean; +typedef int GLsizei; +typedef khronos_uint8_t GLubyte; +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_COLOR_BUFFER_BIT 0x00004000 +#define GL_FALSE 0 +#define GL_TRUE 1 +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 +#define GL_FUNC_ADD 0x8006 +#define GL_BLEND_EQUATION 0x8009 +#define GL_BLEND_EQUATION_RGB 0x8009 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_STREAM_DRAW 0x88E0 +#define GL_STATIC_DRAW 0x88E4 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_FRONT 0x0404 +#define GL_BACK 0x0405 +#define GL_FRONT_AND_BACK 0x0408 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_CULL_FACE 0x0B44 +#define GL_BLEND 0x0BE2 +#define GL_DITHER 0x0BD0 +#define GL_STENCIL_TEST 0x0B90 +#define GL_DEPTH_TEST 0x0B71 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_POLYGON_OFFSET_FILL 0x8037 +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_OUT_OF_MEMORY 0x0505 +#define GL_CW 0x0900 +#define GL_CCW 0x0901 +#define GL_LINE_WIDTH 0x0B21 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_FRONT_FACE 0x0B46 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#define GL_VIEWPORT 0x0BA2 +#define GL_SCISSOR_BOX 0x0C10 +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_RED_BITS 0x0D52 +#define GL_GREEN_BITS 0x0D53 +#define GL_BLUE_BITS 0x0D54 +#define GL_ALPHA_BITS 0x0D55 +#define GL_DEPTH_BITS 0x0D56 +#define GL_STENCIL_BITS 0x0D57 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_INT 0x1404 +#define GL_UNSIGNED_INT 0x1405 +#define GL_FLOAT 0x1406 +#define GL_FIXED 0x140C +#define GL_DEPTH_COMPONENT 0x1902 +#define GL_ALPHA 0x1906 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE_ALPHA 0x190A +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_SHADER_TYPE 0x8B4F +#define GL_DELETE_STATUS 0x8B80 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_NEVER 0x0200 +#define GL_LESS 0x0201 +#define GL_EQUAL 0x0202 +#define GL_LEQUAL 0x0203 +#define GL_GREATER 0x0204 +#define GL_NOTEQUAL 0x0205 +#define GL_GEQUAL 0x0206 +#define GL_ALWAYS 0x0207 +#define GL_KEEP 0x1E00 +#define GL_REPLACE 0x1E01 +#define GL_INCR 0x1E02 +#define GL_DECR 0x1E03 +#define GL_INVERT 0x150A +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 +#define GL_NEAREST 0x2600 +#define GL_LINEAR 0x2601 +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 +#define GL_TEXTURE 0x1702 +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_REPEAT 0x2901 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_COMPILE_STATUS 0x8B81 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RGBA4 0x8056 +#define GL_RGB5_A1 0x8057 +#define GL_RGB565 0x8D62 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_NONE 0 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +typedef void (GL_APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (GL_APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (GL_APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (GL_APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); +typedef void (GL_APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); +typedef void (GL_APIENTRYP PFNGLBINDTEXTUREPROC) (GLenum target, GLuint texture); +typedef void (GL_APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCPROC) (GLenum sfactor, GLenum dfactor); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (GL_APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +typedef void (GL_APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +typedef GLenum (GL_APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLCLEARPROC) (GLbitfield mask); +typedef void (GL_APIENTRYP PFNGLCLEARCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (GL_APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); +typedef void (GL_APIENTRYP PFNGLCLEARSTENCILPROC) (GLint s); +typedef void (GL_APIENTRYP PFNGLCOLORMASKPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +typedef void (GL_APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLCOPYTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef GLuint (GL_APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (GL_APIENTRYP PFNGLCULLFACEPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (GL_APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (GL_APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (GL_APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (GL_APIENTRYP PFNGLDELETETEXTURESPROC) (GLsizei n, const GLuint *textures); +typedef void (GL_APIENTRYP PFNGLDEPTHFUNCPROC) (GLenum func); +typedef void (GL_APIENTRYP PFNGLDEPTHMASKPROC) (GLboolean flag); +typedef void (GL_APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); +typedef void (GL_APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (GL_APIENTRYP PFNGLDISABLEPROC) (GLenum cap); +typedef void (GL_APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices); +typedef void (GL_APIENTRYP PFNGLENABLEPROC) (GLenum cap); +typedef void (GL_APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (GL_APIENTRYP PFNGLFINISHPROC) (void); +typedef void (GL_APIENTRYP PFNGLFLUSHPROC) (void); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (GL_APIENTRYP PFNGLFRONTFACEPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef void (GL_APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef void (GL_APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (GL_APIENTRYP PFNGLGENTEXTURESPROC) (GLsizei n, GLuint *textures); +typedef void (GL_APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +typedef GLint (GL_APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETBOOLEANVPROC) (GLenum pname, GLboolean *data); +typedef void (GL_APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLenum (GL_APIENTRYP PFNGLGETERRORPROC) (void); +typedef void (GL_APIENTRYP PFNGLGETFLOATVPROC) (GLenum pname, GLfloat *data); +typedef void (GL_APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *data); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (GL_APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (GL_APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void (GL_APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef const GLubyte *(GL_APIENTRYP PFNGLGETSTRINGPROC) (GLenum name); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef GLint (GL_APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void **pointer); +typedef void (GL_APIENTRYP PFNGLHINTPROC) (GLenum target, GLenum mode); +typedef GLboolean (GL_APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef GLboolean (GL_APIENTRYP PFNGLISENABLEDPROC) (GLenum cap); +typedef GLboolean (GL_APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); +typedef GLboolean (GL_APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (GL_APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); +typedef GLboolean (GL_APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef GLboolean (GL_APIENTRYP PFNGLISTEXTUREPROC) (GLuint texture); +typedef void (GL_APIENTRYP PFNGLLINEWIDTHPROC) (GLfloat width); +typedef void (GL_APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLPOLYGONOFFSETPROC) (GLfloat factor, GLfloat units); +typedef void (GL_APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); +typedef void (GL_APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); +typedef void (GL_APIENTRYP PFNGLSCISSORPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length); +typedef void (GL_APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +typedef void (GL_APIENTRYP PFNGLSTENCILFUNCPROC) (GLenum func, GLint ref, GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILMASKPROC) (GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILOPPROC) (GLenum fail, GLenum zfail, GLenum zpass); +typedef void (GL_APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (GL_APIENTRYP PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (GL_APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (GL_APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (GL_APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (GL_APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (GL_APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (GL_APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (GL_APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (GL_APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +typedef void (GL_APIENTRYP PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +#if GL_GLES_PROTOTYPES +GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture); +GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader); +GL_APICALL void GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); +GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); +GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); +GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLuint texture); +GL_APICALL void GL_APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GL_APICALL void GL_APIENTRY glBlendEquation (GLenum mode); +GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); +GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); +GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target); +GL_APICALL void GL_APIENTRY glClear (GLbitfield mask); +GL_APICALL void GL_APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GL_APICALL void GL_APIENTRY glClearDepthf (GLfloat d); +GL_APICALL void GL_APIENTRY glClearStencil (GLint s); +GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader); +GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL GLuint GL_APIENTRY glCreateProgram (void); +GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type); +GL_APICALL void GL_APIENTRY glCullFace (GLenum mode); +GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); +GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); +GL_APICALL void GL_APIENTRY glDeleteProgram (GLuint program); +GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); +GL_APICALL void GL_APIENTRY glDeleteShader (GLuint shader); +GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures); +GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func); +GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag); +GL_APICALL void GL_APIENTRY glDepthRangef (GLfloat n, GLfloat f); +GL_APICALL void GL_APIENTRY glDetachShader (GLuint program, GLuint shader); +GL_APICALL void GL_APIENTRY glDisable (GLenum cap); +GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index); +GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); +GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const void *indices); +GL_APICALL void GL_APIENTRY glEnable (GLenum cap); +GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index); +GL_APICALL void GL_APIENTRY glFinish (void); +GL_APICALL void GL_APIENTRY glFlush (void); +GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode); +GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); +GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target); +GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); +GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); +GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint *textures); +GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +GL_APICALL GLint GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); +GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean *data); +GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); +GL_APICALL GLenum GL_APIENTRY glGetError (void); +GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat *data); +GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint *data); +GL_APICALL void GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +GL_APICALL void GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +GL_APICALL const GLubyte *GL_APIENTRY glGetString (GLenum name); +GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); +GL_APICALL GLint GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); +GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer); +GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode); +GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLuint buffer); +GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap); +GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer); +GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program); +GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader); +GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture); +GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width); +GL_APICALL void GL_APIENTRY glLinkProgram (GLuint program); +GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units); +GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); +GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void); +GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); +GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length); +GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask); +GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); +GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); +GL_APICALL void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GL_APICALL void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params); +GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat v0); +GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint v0); +GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); +GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); +GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); +GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUseProgram (GLuint program); +GL_APICALL void GL_APIENTRY glValidateProgram (GLuint program); +GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); +GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); +GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); +#endif +#endif /* GL_ES_VERSION_2_0 */ + +#ifndef GL_ES_VERSION_3_0 +#define GL_ES_VERSION_3_0 1 +typedef khronos_uint16_t GLhalf; +#define GL_READ_BUFFER 0x0C02 +#define GL_UNPACK_ROW_LENGTH 0x0CF2 +#define GL_UNPACK_SKIP_ROWS 0x0CF3 +#define GL_UNPACK_SKIP_PIXELS 0x0CF4 +#define GL_PACK_ROW_LENGTH 0x0D02 +#define GL_PACK_SKIP_ROWS 0x0D03 +#define GL_PACK_SKIP_PIXELS 0x0D04 +#define GL_COLOR 0x1800 +#define GL_DEPTH 0x1801 +#define GL_STENCIL 0x1802 +#define GL_RED 0x1903 +#define GL_RGB8 0x8051 +#define GL_RGBA8 0x8058 +#define GL_RGB10_A2 0x8059 +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_COMPARE_REF_TO_TEXTURE 0x884E +#define GL_MAJOR_VERSION 0x821B +#define GL_MINOR_VERSION 0x821C +#define GL_NUM_EXTENSIONS 0x821D +#define GL_RGBA32F 0x8814 +#define GL_RGB32F 0x8815 +#define GL_RGBA16F 0x881A +#define GL_RGB16F 0x881B +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_MAX_VARYING_COMPONENTS 0x8B4B +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_RGB9_E5 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_RGBA32UI 0x8D70 +#define GL_RGB32UI 0x8D71 +#define GL_RGBA16UI 0x8D76 +#define GL_RGB16UI 0x8D77 +#define GL_RGBA8UI 0x8D7C +#define GL_RGB8UI 0x8D7D +#define GL_RGBA32I 0x8D82 +#define GL_RGB32I 0x8D83 +#define GL_RGBA16I 0x8D88 +#define GL_RGB16I 0x8D89 +#define GL_RGBA8I 0x8D8E +#define GL_RGB8I 0x8D8F +#define GL_RED_INTEGER 0x8D94 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RGBA_INTEGER 0x8D99 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_BUFFER_ACCESS_FLAGS 0x911F +#define GL_BUFFER_MAP_LENGTH 0x9120 +#define GL_BUFFER_MAP_OFFSET 0x9121 +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_COLOR_ATTACHMENT16 0x8CF0 +#define GL_COLOR_ATTACHMENT17 0x8CF1 +#define GL_COLOR_ATTACHMENT18 0x8CF2 +#define GL_COLOR_ATTACHMENT19 0x8CF3 +#define GL_COLOR_ATTACHMENT20 0x8CF4 +#define GL_COLOR_ATTACHMENT21 0x8CF5 +#define GL_COLOR_ATTACHMENT22 0x8CF6 +#define GL_COLOR_ATTACHMENT23 0x8CF7 +#define GL_COLOR_ATTACHMENT24 0x8CF8 +#define GL_COLOR_ATTACHMENT25 0x8CF9 +#define GL_COLOR_ATTACHMENT26 0x8CFA +#define GL_COLOR_ATTACHMENT27 0x8CFB +#define GL_COLOR_ATTACHMENT28 0x8CFC +#define GL_COLOR_ATTACHMENT29 0x8CFD +#define GL_COLOR_ATTACHMENT30 0x8CFE +#define GL_COLOR_ATTACHMENT31 0x8CFF +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#define GL_HALF_FLOAT 0x140B +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_RG8 0x822B +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 +#define GL_COPY_READ_BUFFER 0x8F36 +#define GL_COPY_WRITE_BUFFER 0x8F37 +#define GL_COPY_READ_BUFFER_BINDING 0x8F36 +#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_INVALID_INDEX 0xFFFFFFFFu +#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 +#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_OBJECT_TYPE 0x9112 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_STATUS 0x9114 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_UNSIGNALED 0x9118 +#define GL_SIGNALED 0x9119 +#define GL_ALREADY_SIGNALED 0x911A +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_CONDITION_SATISFIED 0x911C +#define GL_WAIT_FAILED 0x911D +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A +#define GL_SAMPLER_BINDING 0x8919 +#define GL_RGB10_A2UI 0x906F +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_GREEN 0x1904 +#define GL_BLUE 0x1905 +#define GL_INT_2_10_10_10_REV 0x8D9F +#define GL_TRANSFORM_FEEDBACK 0x8E22 +#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 +#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 +#define GL_PROGRAM_BINARY_LENGTH 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE +#define GL_PROGRAM_BINARY_FORMATS 0x87FF +#define GL_COMPRESSED_R11_EAC 0x9270 +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define GL_COMPRESSED_RG11_EAC 0x9272 +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F +#define GL_MAX_ELEMENT_INDEX 0x8D6B +#define GL_NUM_SAMPLE_COUNTS 0x9380 +#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF +typedef void (GL_APIENTRYP PFNGLREADBUFFERPROC) (GLenum src); +typedef void (GL_APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (GL_APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (GL_APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (GL_APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (GL_APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, void **params); +typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void *(GL_APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +typedef void (GL_APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); +typedef void (GL_APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); +typedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); +typedef void (GL_APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); +typedef void (GL_APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); +typedef void (GL_APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); +typedef void (GL_APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (GL_APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (GL_APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +typedef void (GL_APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); +typedef void (GL_APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); +typedef GLint (GL_APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); +typedef void (GL_APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (GL_APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (GL_APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (GL_APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (GL_APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef const GLubyte *(GL_APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); +typedef void (GL_APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (GL_APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +typedef void (GL_APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +typedef GLuint (GL_APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); +typedef void (GL_APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +typedef void (GL_APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); +typedef GLsync (GL_APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (GL_APIENTRYP PFNGLISSYNCPROC) (GLsync sync); +typedef void (GL_APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); +typedef GLenum (GL_APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *data); +typedef void (GL_APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +typedef void (GL_APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); +typedef void (GL_APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); +typedef void (GL_APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); +typedef void (GL_APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); +typedef GLboolean (GL_APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); +typedef void (GL_APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); +typedef void (GL_APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); +typedef void (GL_APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); +typedef void (GL_APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (GL_APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); +typedef void (GL_APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); +typedef void (GL_APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +typedef void (GL_APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); +typedef void (GL_APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); +typedef void (GL_APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); +typedef void (GL_APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (GL_APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +#if GL_GLES_PROTOTYPES +GL_APICALL void GL_APIENTRY glReadBuffer (GLenum src); +GL_APICALL void GL_APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +GL_APICALL void GL_APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glGenQueries (GLsizei n, GLuint *ids); +GL_APICALL void GL_APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); +GL_APICALL GLboolean GL_APIENTRY glIsQuery (GLuint id); +GL_APICALL void GL_APIENTRY glBeginQuery (GLenum target, GLuint id); +GL_APICALL void GL_APIENTRY glEndQuery (GLenum target); +GL_APICALL void GL_APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); +GL_APICALL GLboolean GL_APIENTRY glUnmapBuffer (GLenum target); +GL_APICALL void GL_APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, void **params); +GL_APICALL void GL_APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); +GL_APICALL void GL_APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GL_APICALL void *GL_APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GL_APICALL void GL_APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); +GL_APICALL void GL_APIENTRY glBindVertexArray (GLuint array); +GL_APICALL void GL_APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); +GL_APICALL void GL_APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); +GL_APICALL GLboolean GL_APIENTRY glIsVertexArray (GLuint array); +GL_APICALL void GL_APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); +GL_APICALL void GL_APIENTRY glBeginTransformFeedback (GLenum primitiveMode); +GL_APICALL void GL_APIENTRY glEndTransformFeedback (void); +GL_APICALL void GL_APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GL_APICALL void GL_APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); +GL_APICALL void GL_APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +GL_APICALL void GL_APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GL_APICALL void GL_APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GL_APICALL void GL_APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); +GL_APICALL void GL_APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); +GL_APICALL void GL_APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GL_APICALL void GL_APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); +GL_APICALL void GL_APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); +GL_APICALL void GL_APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); +GL_APICALL GLint GL_APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); +GL_APICALL void GL_APIENTRY glUniform1ui (GLint location, GLuint v0); +GL_APICALL void GL_APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); +GL_APICALL void GL_APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); +GL_APICALL void GL_APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GL_APICALL void GL_APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); +GL_APICALL void GL_APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); +GL_APICALL void GL_APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); +GL_APICALL void GL_APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GL_APICALL const GLubyte *GL_APIENTRY glGetStringi (GLenum name, GLuint index); +GL_APICALL void GL_APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GL_APICALL void GL_APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +GL_APICALL void GL_APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +GL_APICALL GLuint GL_APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); +GL_APICALL void GL_APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +GL_APICALL void GL_APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +GL_APICALL void GL_APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +GL_APICALL void GL_APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); +GL_APICALL GLsync GL_APIENTRY glFenceSync (GLenum condition, GLbitfield flags); +GL_APICALL GLboolean GL_APIENTRY glIsSync (GLsync sync); +GL_APICALL void GL_APIENTRY glDeleteSync (GLsync sync); +GL_APICALL GLenum GL_APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glGetInteger64v (GLenum pname, GLint64 *data); +GL_APICALL void GL_APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +GL_APICALL void GL_APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); +GL_APICALL void GL_APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); +GL_APICALL void GL_APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); +GL_APICALL void GL_APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); +GL_APICALL GLboolean GL_APIENTRY glIsSampler (GLuint sampler); +GL_APICALL void GL_APIENTRY glBindSampler (GLuint unit, GLuint sampler); +GL_APICALL void GL_APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); +GL_APICALL void GL_APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); +GL_APICALL void GL_APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); +GL_APICALL void GL_APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); +GL_APICALL void GL_APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); +GL_APICALL void GL_APIENTRY glBindTransformFeedback (GLenum target, GLuint id); +GL_APICALL void GL_APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); +GL_APICALL void GL_APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); +GL_APICALL GLboolean GL_APIENTRY glIsTransformFeedback (GLuint id); +GL_APICALL void GL_APIENTRY glPauseTransformFeedback (void); +GL_APICALL void GL_APIENTRY glResumeTransformFeedback (void); +GL_APICALL void GL_APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +GL_APICALL void GL_APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); +GL_APICALL void GL_APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); +GL_APICALL void GL_APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments); +GL_APICALL void GL_APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GL_APICALL void GL_APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +#endif +#endif /* GL_ES_VERSION_3_0 */ + +#ifndef GL_ES_VERSION_3_1 +#define GL_ES_VERSION_3_1 1 +#define GL_COMPUTE_SHADER 0x91B9 +#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB +#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC +#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD +#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 +#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 +#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 +#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 +#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 +#define GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS 0x90EB +#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE +#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF +#define GL_COMPUTE_WORK_GROUP_SIZE 0x8267 +#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE +#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF +#define GL_COMPUTE_SHADER_BIT 0x00000020 +#define GL_DRAW_INDIRECT_BUFFER 0x8F3F +#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 +#define GL_MAX_UNIFORM_LOCATIONS 0x826E +#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 +#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 +#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313 +#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314 +#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315 +#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316 +#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318 +#define GL_UNIFORM 0x92E1 +#define GL_UNIFORM_BLOCK 0x92E2 +#define GL_PROGRAM_INPUT 0x92E3 +#define GL_PROGRAM_OUTPUT 0x92E4 +#define GL_BUFFER_VARIABLE 0x92E5 +#define GL_SHADER_STORAGE_BLOCK 0x92E6 +#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 +#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 +#define GL_ACTIVE_RESOURCES 0x92F5 +#define GL_MAX_NAME_LENGTH 0x92F6 +#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 +#define GL_NAME_LENGTH 0x92F9 +#define GL_TYPE 0x92FA +#define GL_ARRAY_SIZE 0x92FB +#define GL_OFFSET 0x92FC +#define GL_BLOCK_INDEX 0x92FD +#define GL_ARRAY_STRIDE 0x92FE +#define GL_MATRIX_STRIDE 0x92FF +#define GL_IS_ROW_MAJOR 0x9300 +#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 +#define GL_BUFFER_BINDING 0x9302 +#define GL_BUFFER_DATA_SIZE 0x9303 +#define GL_NUM_ACTIVE_VARIABLES 0x9304 +#define GL_ACTIVE_VARIABLES 0x9305 +#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 +#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A +#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B +#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C +#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D +#define GL_LOCATION 0x930E +#define GL_VERTEX_SHADER_BIT 0x00000001 +#define GL_FRAGMENT_SHADER_BIT 0x00000002 +#define GL_ALL_SHADER_BITS 0xFFFFFFFF +#define GL_PROGRAM_SEPARABLE 0x8258 +#define GL_ACTIVE_PROGRAM 0x8259 +#define GL_PROGRAM_PIPELINE_BINDING 0x825A +#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 +#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 +#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 +#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC +#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 +#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 +#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 +#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 +#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC +#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 +#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB +#define GL_MAX_IMAGE_UNITS 0x8F38 +#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA +#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE +#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF +#define GL_IMAGE_BINDING_NAME 0x8F3A +#define GL_IMAGE_BINDING_LEVEL 0x8F3B +#define GL_IMAGE_BINDING_LAYERED 0x8F3C +#define GL_IMAGE_BINDING_LAYER 0x8F3D +#define GL_IMAGE_BINDING_ACCESS 0x8F3E +#define GL_IMAGE_BINDING_FORMAT 0x906E +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 +#define GL_COMMAND_BARRIER_BIT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 +#define GL_ALL_BARRIER_BITS 0xFFFFFFFF +#define GL_IMAGE_2D 0x904D +#define GL_IMAGE_3D 0x904E +#define GL_IMAGE_CUBE 0x9050 +#define GL_IMAGE_2D_ARRAY 0x9053 +#define GL_INT_IMAGE_2D 0x9058 +#define GL_INT_IMAGE_3D 0x9059 +#define GL_INT_IMAGE_CUBE 0x905B +#define GL_INT_IMAGE_2D_ARRAY 0x905E +#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 +#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 +#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_SHADER_STORAGE_BUFFER 0x90D2 +#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 +#define GL_SHADER_STORAGE_BUFFER_START 0x90D4 +#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 +#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 +#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA +#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB +#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC +#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD +#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE +#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF +#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 +#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 +#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA +#define GL_STENCIL_INDEX 0x1901 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F +#define GL_SAMPLE_POSITION 0x8E50 +#define GL_SAMPLE_MASK 0x8E51 +#define GL_SAMPLE_MASK_VALUE 0x8E52 +#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 +#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E +#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F +#define GL_MAX_INTEGER_SAMPLES 0x9110 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 +#define GL_TEXTURE_SAMPLES 0x9106 +#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 +#define GL_TEXTURE_WIDTH 0x1000 +#define GL_TEXTURE_HEIGHT 0x1001 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 +#define GL_TEXTURE_RED_SIZE 0x805C +#define GL_TEXTURE_GREEN_SIZE 0x805D +#define GL_TEXTURE_BLUE_SIZE 0x805E +#define GL_TEXTURE_ALPHA_SIZE 0x805F +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_TEXTURE_SHARED_SIZE 0x8C3F +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 +#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A +#define GL_VERTEX_ATTRIB_BINDING 0x82D4 +#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 +#define GL_VERTEX_BINDING_DIVISOR 0x82D6 +#define GL_VERTEX_BINDING_OFFSET 0x82D7 +#define GL_VERTEX_BINDING_STRIDE 0x82D8 +#define GL_VERTEX_BINDING_BUFFER 0x8F4F +#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 +#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA +#define GL_MAX_VERTEX_ATTRIB_STRIDE 0x82E5 +typedef void (GL_APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +typedef void (GL_APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +typedef GLuint (GL_APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +typedef GLint (GL_APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); +typedef void (GL_APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); +typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar *const*strings); +typedef void (GL_APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (GL_APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); +typedef void (GL_APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); +typedef GLboolean (GL_APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (GL_APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +typedef void (GL_APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (GL_APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); +typedef void (GL_APIENTRYP PFNGLMEMORYBARRIERBYREGIONPROC) (GLbitfield barriers); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (GL_APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (GL_APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint maskNumber, GLbitfield mask); +typedef void (GL_APIENTRYP PFNGLGETTEXLEVELPARAMETERIVPROC) (GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETTEXLEVELPARAMETERFVPROC) (GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex); +typedef void (GL_APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor); +#if GL_GLES_PROTOTYPES +GL_APICALL void GL_APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +GL_APICALL void GL_APIENTRY glDispatchComputeIndirect (GLintptr indirect); +GL_APICALL void GL_APIENTRY glDrawArraysIndirect (GLenum mode, const void *indirect); +GL_APICALL void GL_APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect); +GL_APICALL void GL_APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +GL_APICALL GLuint GL_APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name); +GL_APICALL void GL_APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +GL_APICALL void GL_APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +GL_APICALL GLint GL_APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name); +GL_APICALL void GL_APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); +GL_APICALL void GL_APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); +GL_APICALL GLuint GL_APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar *const*strings); +GL_APICALL void GL_APIENTRY glBindProgramPipeline (GLuint pipeline); +GL_APICALL void GL_APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); +GL_APICALL void GL_APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); +GL_APICALL GLboolean GL_APIENTRY glIsProgramPipeline (GLuint pipeline); +GL_APICALL void GL_APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); +GL_APICALL void GL_APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); +GL_APICALL void GL_APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GL_APICALL void GL_APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GL_APICALL void GL_APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); +GL_APICALL void GL_APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); +GL_APICALL void GL_APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GL_APICALL void GL_APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GL_APICALL void GL_APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); +GL_APICALL void GL_APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GL_APICALL void GL_APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GL_APICALL void GL_APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GL_APICALL void GL_APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glValidateProgramPipeline (GLuint pipeline); +GL_APICALL void GL_APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GL_APICALL void GL_APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +GL_APICALL void GL_APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); +GL_APICALL void GL_APIENTRY glMemoryBarrier (GLbitfield barriers); +GL_APICALL void GL_APIENTRY glMemoryBarrierByRegion (GLbitfield barriers); +GL_APICALL void GL_APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GL_APICALL void GL_APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); +GL_APICALL void GL_APIENTRY glSampleMaski (GLuint maskNumber, GLbitfield mask); +GL_APICALL void GL_APIENTRY glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat *params); +GL_APICALL void GL_APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GL_APICALL void GL_APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GL_APICALL void GL_APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GL_APICALL void GL_APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex); +GL_APICALL void GL_APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor); +#endif +#endif /* GL_ES_VERSION_3_1 */ + +#ifndef GL_ES_VERSION_3_2 +#define GL_ES_VERSION_3_2 1 +typedef void (GL_APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +#define GL_MULTISAMPLE_LINE_WIDTH_RANGE 0x9381 +#define GL_MULTISAMPLE_LINE_WIDTH_GRANULARITY 0x9382 +#define GL_MULTIPLY 0x9294 +#define GL_SCREEN 0x9295 +#define GL_OVERLAY 0x9296 +#define GL_DARKEN 0x9297 +#define GL_LIGHTEN 0x9298 +#define GL_COLORDODGE 0x9299 +#define GL_COLORBURN 0x929A +#define GL_HARDLIGHT 0x929B +#define GL_SOFTLIGHT 0x929C +#define GL_DIFFERENCE 0x929E +#define GL_EXCLUSION 0x92A0 +#define GL_HSL_HUE 0x92AD +#define GL_HSL_SATURATION 0x92AE +#define GL_HSL_COLOR 0x92AF +#define GL_HSL_LUMINOSITY 0x92B0 +#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 +#define GL_DEBUG_SOURCE_API 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION 0x824A +#define GL_DEBUG_SOURCE_OTHER 0x824B +#define GL_DEBUG_TYPE_ERROR 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E +#define GL_DEBUG_TYPE_PORTABILITY 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 +#define GL_DEBUG_TYPE_OTHER 0x8251 +#define GL_DEBUG_TYPE_MARKER 0x8268 +#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 +#define GL_DEBUG_TYPE_POP_GROUP 0x826A +#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C +#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D +#define GL_BUFFER 0x82E0 +#define GL_SHADER 0x82E1 +#define GL_PROGRAM 0x82E2 +#define GL_VERTEX_ARRAY 0x8074 +#define GL_QUERY 0x82E3 +#define GL_PROGRAM_PIPELINE 0x82E4 +#define GL_SAMPLER 0x82E6 +#define GL_MAX_LABEL_LENGTH 0x82E8 +#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES 0x9145 +#define GL_DEBUG_SEVERITY_HIGH 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 +#define GL_DEBUG_SEVERITY_LOW 0x9148 +#define GL_DEBUG_OUTPUT 0x92E0 +#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 +#define GL_STACK_OVERFLOW 0x0503 +#define GL_STACK_UNDERFLOW 0x0504 +#define GL_GEOMETRY_SHADER 0x8DD9 +#define GL_GEOMETRY_SHADER_BIT 0x00000004 +#define GL_GEOMETRY_VERTICES_OUT 0x8916 +#define GL_GEOMETRY_INPUT_TYPE 0x8917 +#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 +#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F +#define GL_LAYER_PROVOKING_VERTEX 0x825E +#define GL_LINES_ADJACENCY 0x000A +#define GL_LINE_STRIP_ADJACENCY 0x000B +#define GL_TRIANGLES_ADJACENCY 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 +#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 +#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 +#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 +#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF +#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 +#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD +#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 +#define GL_FIRST_VERTEX_CONVENTION 0x8E4D +#define GL_LAST_VERTEX_CONVENTION 0x8E4E +#define GL_UNDEFINED_VERTEX 0x8260 +#define GL_PRIMITIVES_GENERATED 0x8C87 +#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312 +#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 +#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 +#define GL_PRIMITIVE_BOUNDING_BOX 0x92BE +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT 0x00000004 +#define GL_CONTEXT_FLAGS 0x821E +#define GL_LOSE_CONTEXT_ON_RESET 0x8252 +#define GL_GUILTY_CONTEXT_RESET 0x8253 +#define GL_INNOCENT_CONTEXT_RESET 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY 0x8256 +#define GL_NO_RESET_NOTIFICATION 0x8261 +#define GL_CONTEXT_LOST 0x0507 +#define GL_SAMPLE_SHADING 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C +#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D +#define GL_PATCHES 0x000E +#define GL_PATCH_VERTICES 0x8E72 +#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 +#define GL_TESS_GEN_MODE 0x8E76 +#define GL_TESS_GEN_SPACING 0x8E77 +#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 +#define GL_TESS_GEN_POINT_MODE 0x8E79 +#define GL_ISOLINES 0x8E7A +#define GL_QUADS 0x0007 +#define GL_FRACTIONAL_ODD 0x8E7B +#define GL_FRACTIONAL_EVEN 0x8E7C +#define GL_MAX_PATCH_VERTICES 0x8E7D +#define GL_MAX_TESS_GEN_LEVEL 0x8E7E +#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F +#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 +#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 +#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 +#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 +#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 +#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 +#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 +#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 +#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A +#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C +#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D +#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E +#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 +#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB +#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC +#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 +#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 +#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221 +#define GL_IS_PER_PATCH 0x92E7 +#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 +#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 +#define GL_TESS_CONTROL_SHADER 0x8E88 +#define GL_TESS_EVALUATION_SHADER 0x8E87 +#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 +#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 +#define GL_TEXTURE_BORDER_COLOR 0x1004 +#define GL_CLAMP_TO_BORDER 0x812D +#define GL_TEXTURE_BUFFER 0x8C2A +#define GL_TEXTURE_BUFFER_BINDING 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D +#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F +#define GL_SAMPLER_BUFFER 0x8DC2 +#define GL_INT_SAMPLER_BUFFER 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 +#define GL_IMAGE_BUFFER 0x9051 +#define GL_INT_IMAGE_BUFFER 0x905C +#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 +#define GL_TEXTURE_BUFFER_OFFSET 0x919D +#define GL_TEXTURE_BUFFER_SIZE 0x919E +#define GL_COMPRESSED_RGBA_ASTC_4x4 0x93B0 +#define GL_COMPRESSED_RGBA_ASTC_5x4 0x93B1 +#define GL_COMPRESSED_RGBA_ASTC_5x5 0x93B2 +#define GL_COMPRESSED_RGBA_ASTC_6x5 0x93B3 +#define GL_COMPRESSED_RGBA_ASTC_6x6 0x93B4 +#define GL_COMPRESSED_RGBA_ASTC_8x5 0x93B5 +#define GL_COMPRESSED_RGBA_ASTC_8x6 0x93B6 +#define GL_COMPRESSED_RGBA_ASTC_8x8 0x93B7 +#define GL_COMPRESSED_RGBA_ASTC_10x5 0x93B8 +#define GL_COMPRESSED_RGBA_ASTC_10x6 0x93B9 +#define GL_COMPRESSED_RGBA_ASTC_10x8 0x93BA +#define GL_COMPRESSED_RGBA_ASTC_10x10 0x93BB +#define GL_COMPRESSED_RGBA_ASTC_12x10 0x93BC +#define GL_COMPRESSED_RGBA_ASTC_12x12 0x93BD +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4 0x93D0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4 0x93D1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5 0x93D2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5 0x93D3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6 0x93D4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5 0x93D5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6 0x93D6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8 0x93D7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5 0x93D8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6 0x93D9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8 0x93DA +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10 0x93DB +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10 0x93DC +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12 0x93DD +#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A +#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F +#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 +#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 +#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B +#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D +typedef void (GL_APIENTRYP PFNGLBLENDBARRIERPROC) (void); +typedef void (GL_APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); +typedef GLuint (GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +typedef void (GL_APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); +typedef void (GL_APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void); +typedef void (GL_APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (GL_APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETPOINTERVPROC) (GLenum pname, void **params); +typedef void (GL_APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); +typedef void (GL_APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (GL_APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef GLboolean (GL_APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (GL_APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (GL_APIENTRYP PFNGLPRIMITIVEBOUNDINGBOXPROC) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +typedef GLenum (GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSPROC) (void); +typedef void (GL_APIENTRYP PFNGLREADNPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +typedef void (GL_APIENTRYP PFNGLGETNUNIFORMFVPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETNUNIFORMIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETNUNIFORMUIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +typedef void (GL_APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLfloat value); +typedef void (GL_APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); +typedef void (GL_APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); +typedef void (GL_APIENTRYP PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +#if GL_GLES_PROTOTYPES +GL_APICALL void GL_APIENTRY glBlendBarrier (void); +GL_APICALL void GL_APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +GL_APICALL void GL_APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GL_APICALL void GL_APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GL_APICALL void GL_APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam); +GL_APICALL GLuint GL_APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +GL_APICALL void GL_APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message); +GL_APICALL void GL_APIENTRY glPopDebugGroup (void); +GL_APICALL void GL_APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +GL_APICALL void GL_APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +GL_APICALL void GL_APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label); +GL_APICALL void GL_APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +GL_APICALL void GL_APIENTRY glGetPointerv (GLenum pname, void **params); +GL_APICALL void GL_APIENTRY glEnablei (GLenum target, GLuint index); +GL_APICALL void GL_APIENTRY glDisablei (GLenum target, GLuint index); +GL_APICALL void GL_APIENTRY glBlendEquationi (GLuint buf, GLenum mode); +GL_APICALL void GL_APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GL_APICALL void GL_APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst); +GL_APICALL void GL_APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GL_APICALL void GL_APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GL_APICALL GLboolean GL_APIENTRY glIsEnabledi (GLenum target, GLuint index); +GL_APICALL void GL_APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GL_APICALL void GL_APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +GL_APICALL void GL_APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); +GL_APICALL void GL_APIENTRY glPrimitiveBoundingBox (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +GL_APICALL GLenum GL_APIENTRY glGetGraphicsResetStatus (void); +GL_APICALL void GL_APIENTRY glReadnPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +GL_APICALL void GL_APIENTRY glGetnUniformfv (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetnUniformiv (GLuint program, GLint location, GLsizei bufSize, GLint *params); +GL_APICALL void GL_APIENTRY glGetnUniformuiv (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +GL_APICALL void GL_APIENTRY glMinSampleShading (GLfloat value); +GL_APICALL void GL_APIENTRY glPatchParameteri (GLenum pname, GLint value); +GL_APICALL void GL_APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); +GL_APICALL void GL_APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); +GL_APICALL void GL_APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); +GL_APICALL void GL_APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); +GL_APICALL void GL_APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); +GL_APICALL void GL_APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); +GL_APICALL void GL_APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer); +GL_APICALL void GL_APIENTRY glTexBufferRange (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GL_APICALL void GL_APIENTRY glTexStorage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +#endif +#endif /* GL_ES_VERSION_3_2 */ + +#ifdef __cplusplus +} +#endif + +#endif From 349e915e10805bffbd859fc414fa52c9ac324ccf Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 19 Apr 2020 15:33:36 +0200 Subject: [PATCH 167/316] OpenGL: Link contexts to device --- include/Nazara/OpenGLRenderer/OpenGLDevice.hpp | 8 ++++++++ include/Nazara/OpenGLRenderer/OpenGLDevice.inl | 11 +++++++++++ include/Nazara/OpenGLRenderer/Wrapper/Context.hpp | 10 ++++++++-- include/Nazara/OpenGLRenderer/Wrapper/Context.inl | 9 +++++++++ include/Nazara/OpenGLRenderer/Wrapper/Loader.hpp | 9 +++++++-- .../OpenGLRenderer/Wrapper/Win32/WGLContext.hpp | 2 +- .../OpenGLRenderer/Wrapper/Win32/WGLContext.inl | 6 ++++++ .../OpenGLRenderer/Wrapper/Win32/WGLLoader.hpp | 4 ++-- src/Nazara/OpenGLRenderer/OpenGLDevice.cpp | 14 +++++++++++--- src/Nazara/OpenGLRenderer/Wrapper/Context.cpp | 9 +++++++++ .../OpenGLRenderer/Wrapper/Win32/WGLContext.cpp | 5 ----- .../OpenGLRenderer/Wrapper/Win32/WGLLoader.cpp | 12 ++++++------ 12 files changed, 78 insertions(+), 21 deletions(-) diff --git a/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp b/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp index a7d599f98..2434549b2 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp @@ -12,12 +12,15 @@ #include #include #include +#include #include namespace Nz { class NAZARA_OPENGLRENDERER_API OpenGLDevice : public RenderDevice { + friend GL::Context; + public: OpenGLDevice(GL::Loader& loader); OpenGLDevice(const OpenGLDevice&) = delete; @@ -37,11 +40,16 @@ namespace Nz std::unique_ptr InstantiateTexture(const TextureInfo& params) override; std::unique_ptr InstantiateTextureSampler(const TextureSamplerInfo& params) override; + inline void NotifyTextureDestruction(GLuint texture) const; + OpenGLDevice& operator=(const OpenGLDevice&) = delete; OpenGLDevice& operator=(OpenGLDevice&&) = delete; ///TODO? private: + inline void NotifyContextDestruction(const GL::Context& context) const; + std::unique_ptr m_referenceContext; + mutable std::unordered_set m_contexts; GL::Loader& m_loader; }; } diff --git a/include/Nazara/OpenGLRenderer/OpenGLDevice.inl b/include/Nazara/OpenGLRenderer/OpenGLDevice.inl index 1dc0fe4ac..0c77347a6 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLDevice.inl +++ b/include/Nazara/OpenGLRenderer/OpenGLDevice.inl @@ -11,6 +11,17 @@ namespace Nz { return *m_referenceContext; } + + inline void OpenGLDevice::NotifyTextureDestruction(GLuint texture) const + { + for (const GL::Context* context : m_contexts) + context->NotifyTextureDestruction(texture); + } + + inline void OpenGLDevice::NotifyContextDestruction(const GL::Context& context) const + { + m_contexts.erase(&context); + } } #include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp index 17cb668cf..691099911 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp @@ -14,6 +14,11 @@ #include #include +namespace Nz +{ + class OpenGLDevice; +} + namespace Nz::GL { enum class ContextType @@ -55,13 +60,13 @@ namespace Nz::GL class Context { public: - Context() = default; + inline Context(const OpenGLDevice* device); virtual ~Context(); - virtual bool Activate() = 0; virtual void EnableVerticalSync(bool enabled) = 0; + inline const OpenGLDevice* GetDevice() const; inline ExtensionStatus GetExtensionStatus(Extension extension) const; inline const ContextParams& GetParams() const; @@ -95,6 +100,7 @@ namespace Nz::GL std::array m_extensionStatus; std::unordered_set m_supportedExtensions; + const OpenGLDevice* m_device; }; } diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Context.inl b/include/Nazara/OpenGLRenderer/Wrapper/Context.inl index c384dbc31..ff296f5ec 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Context.inl +++ b/include/Nazara/OpenGLRenderer/Wrapper/Context.inl @@ -7,6 +7,15 @@ namespace Nz::GL { + inline Context::Context(const OpenGLDevice* device) : + m_device(device) + { + } + + inline const OpenGLDevice* Context::GetDevice() const + { + return m_device; + } inline ExtensionStatus Context::GetExtensionStatus(Extension extension) const { diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Loader.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Loader.hpp index 13eeafb53..2db76c99c 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Loader.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Loader.hpp @@ -13,6 +13,11 @@ #include #include +namespace Nz +{ + class OpenGLDevice; +} + namespace Nz::GL { class Context; @@ -25,8 +30,8 @@ namespace Nz::GL Loader() = default; virtual ~Loader(); - virtual std::unique_ptr CreateContext(const ContextParams& params, Context* shareContext = nullptr) const = 0; - virtual std::unique_ptr CreateContext(const ContextParams& params, WindowHandle handle, Context* shareContext = nullptr) const = 0; + virtual std::unique_ptr CreateContext(const OpenGLDevice* device, const ContextParams& params, Context* shareContext = nullptr) const = 0; + virtual std::unique_ptr CreateContext(const OpenGLDevice* device, const ContextParams& params, WindowHandle handle, Context* shareContext = nullptr) const = 0; virtual GLFunction LoadFunction(const char* name) const = 0; }; diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.hpp index 7c300a92c..7f684af03 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.hpp @@ -26,7 +26,7 @@ namespace Nz::GL class WGLContext : public Context { public: - WGLContext(const WGLLoader& loader); + inline WGLContext(const OpenGLDevice* device, const WGLLoader& loader); WGLContext(const WGLContext&) = delete; WGLContext(WGLContext&&) = delete; ~WGLContext(); diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.inl b/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.inl index a4bdc6bda..5dc6e0b31 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.inl +++ b/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.inl @@ -7,6 +7,12 @@ namespace Nz::GL { + inline GL::WGLContext::WGLContext(const OpenGLDevice* device, const WGLLoader& loader) : + Context(device), + m_loader(loader) + { + } + inline bool WGLContext::HasPlatformExtension(const std::string& str) const { return m_supportedPlatformExtensions.find(str) != m_supportedPlatformExtensions.end(); diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.hpp index a733233af..e5ad9395d 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.hpp @@ -24,8 +24,8 @@ namespace Nz::GL WGLLoader(DynLib& openglLib); ~WGLLoader() = default; - std::unique_ptr CreateContext(const ContextParams& params, Context* shareContext) const override; - std::unique_ptr CreateContext(const ContextParams& params, WindowHandle handle, Context* shareContext) const override; + std::unique_ptr CreateContext(const OpenGLDevice* device, const ContextParams& params, Context* shareContext) const override; + std::unique_ptr CreateContext(const OpenGLDevice* device, const ContextParams& params, WindowHandle handle, Context* shareContext) const override; GLFunction LoadFunction(const char* name) const override; diff --git a/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp b/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp index afc0da3d5..a5df5efcb 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp @@ -14,21 +14,29 @@ namespace Nz OpenGLDevice::OpenGLDevice(GL::Loader& loader) : m_loader(loader) { - m_referenceContext = loader.CreateContext({}); + m_referenceContext = loader.CreateContext(this, {}); if (!m_referenceContext) throw std::runtime_error("failed to create reference context"); + + m_contexts.insert(m_referenceContext.get()); } OpenGLDevice::~OpenGLDevice() = default; std::unique_ptr OpenGLDevice::CreateContext(const GL::ContextParams& params) const { - return m_loader.CreateContext(params, m_referenceContext.get()); + auto contextPtr = m_loader.CreateContext(this, params, m_referenceContext.get()); + m_contexts.insert(contextPtr.get()); + + return contextPtr; } std::unique_ptr OpenGLDevice::CreateContext(const GL::ContextParams& params, WindowHandle handle) const { - return m_loader.CreateContext(params, handle, m_referenceContext.get()); + auto contextPtr = m_loader.CreateContext(this, params, handle, m_referenceContext.get()); + m_contexts.insert(contextPtr.get()); + + return contextPtr; } std::unique_ptr OpenGLDevice::InstantiateBuffer(BufferType type) diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp index 08e8077db..4259b8924 100644 --- a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp +++ b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp @@ -4,8 +4,11 @@ #include #include +#include #include +#include #include +#include #include #include @@ -13,6 +16,12 @@ namespace Nz::GL { thread_local const Context* s_currentContext = nullptr; + Context::~Context() + { + if (m_device) + m_device->NotifyContextDestruction(*this); + } + bool Context::Initialize(const ContextParams& params) { diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp index d732a5da6..8f056bc62 100644 --- a/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp +++ b/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp @@ -12,11 +12,6 @@ namespace Nz::GL { - GL::WGLContext::WGLContext(const WGLLoader& loader) : - m_loader(loader) - { - } - WGLContext::~WGLContext() { Destroy(); diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.cpp index bc37dc061..e30bde76b 100644 --- a/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.cpp +++ b/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLLoader.cpp @@ -11,7 +11,7 @@ namespace Nz::GL { WGLLoader::WGLLoader(DynLib& openglLib) : m_opengl32Lib(openglLib), - m_baseContext(*this) + m_baseContext(nullptr, *this) { if (!m_gdi32Lib.Load("gdi32.dll")) throw std::runtime_error("failed to load gdi32.dll: " + m_gdi32Lib.GetLastError()); @@ -42,7 +42,7 @@ namespace Nz::GL #undef NAZARA_OPENGLRENDERER_EXT_FUNC // In order to load OpenGL functions, we have to create a context first - WGLContext loadContext(*this); + WGLContext loadContext(nullptr, *this); if (!loadContext.Create(nullptr, {})) throw std::runtime_error("failed to create load context"); @@ -56,9 +56,9 @@ namespace Nz::GL throw std::runtime_error("failed to load OpenGL functions"); } - std::unique_ptr WGLLoader::CreateContext(const ContextParams& params, Context* shareContext) const + std::unique_ptr WGLLoader::CreateContext(const OpenGLDevice* device, const ContextParams& params, Context* shareContext) const { - auto context = std::make_unique(*this); + auto context = std::make_unique(device, *this); if (!context->Create(&m_baseContext, params, static_cast(shareContext))) { NazaraError("failed to create context"); @@ -74,9 +74,9 @@ namespace Nz::GL return context; } - std::unique_ptr WGLLoader::CreateContext(const ContextParams& params, WindowHandle handle, Context* shareContext) const + std::unique_ptr WGLLoader::CreateContext(const OpenGLDevice* device, const ContextParams& params, WindowHandle handle, Context* shareContext) const { - auto context = std::make_unique(*this); + auto context = std::make_unique(device, *this); if (!context->Create(&m_baseContext, params, handle, static_cast(shareContext))) { NazaraError("failed to create context"); From b4b15f826d20085e88fd8bfefba5570608c92430 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 19 Apr 2020 15:33:56 +0200 Subject: [PATCH 168/316] OpenGL: Implement textures --- .../Nazara/OpenGLRenderer/OpenGLTexture.hpp | 17 +- .../Nazara/OpenGLRenderer/OpenGLTexture.inl | 9 - .../Nazara/OpenGLRenderer/Wrapper/Context.hpp | 19 ++ .../Nazara/OpenGLRenderer/Wrapper/Context.inl | 9 + .../Nazara/OpenGLRenderer/Wrapper/Texture.hpp | 51 ++-- .../Nazara/OpenGLRenderer/Wrapper/Texture.inl | 98 +++++-- include/Nazara/Renderer/Texture.hpp | 2 + include/Nazara/Renderer/Texture.inl | 7 + src/Nazara/OpenGLRenderer/OpenGLDevice.cpp | 3 +- src/Nazara/OpenGLRenderer/OpenGLTexture.cpp | 262 ++++-------------- src/Nazara/OpenGLRenderer/Wrapper/Context.cpp | 37 +++ src/Nazara/VulkanRenderer/VulkanTexture.cpp | 11 - 12 files changed, 227 insertions(+), 298 deletions(-) diff --git a/include/Nazara/OpenGLRenderer/OpenGLTexture.hpp b/include/Nazara/OpenGLRenderer/OpenGLTexture.hpp index 7dcd68582..d4552823c 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLTexture.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLTexture.hpp @@ -10,22 +10,20 @@ #include #include #include -#include -#include +#include +#include namespace Nz { class NAZARA_OPENGLRENDERER_API OpenGLTexture : public Texture { public: - OpenGLTexture(Vk::Device& device, const TextureInfo& params); + OpenGLTexture(OpenGLDevice& device, const TextureInfo& params); OpenGLTexture(const OpenGLTexture&) = default; OpenGLTexture(OpenGLTexture&&) noexcept = default; - ~OpenGLTexture(); + ~OpenGLTexture() = default; PixelFormat GetFormat() const override; - inline VkImage GetImage() const; - inline VkImageView GetImageView() const; UInt8 GetLevelCount() const override; Vector3ui GetSize(UInt8 level = 0) const override; ImageType GetType() const override; @@ -36,12 +34,7 @@ namespace Nz OpenGLTexture& operator=(OpenGLTexture&&) = delete; private: - static void InitForFormat(PixelFormat pixelFormat, VkImageCreateInfo& createImage, VkImageViewCreateInfo& createImageView); - - VkImage m_image; - VmaAllocation m_allocation; - Vk::Device& m_device; - Vk::ImageView m_imageView; + GL::Texture m_texture; TextureInfo m_params; }; } diff --git a/include/Nazara/OpenGLRenderer/OpenGLTexture.inl b/include/Nazara/OpenGLRenderer/OpenGLTexture.inl index 1aef1e297..227f8c478 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLTexture.inl +++ b/include/Nazara/OpenGLRenderer/OpenGLTexture.inl @@ -7,15 +7,6 @@ namespace Nz { - inline VkImage OpenGLTexture::GetImage() const - { - return m_image; - } - - inline VkImageView OpenGLTexture::GetImageView() const - { - return m_imageView; - } } #include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp index 691099911..b0d731bac 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp @@ -43,6 +43,16 @@ namespace Nz::GL KHR }; + enum class TextureTarget + { + Cubemap, + Target2D, + Target2D_Array, + Target3D, + + Max = Target3D + }; + struct ContextParams { ContextType type = ContextType::OpenGL_ES; @@ -63,6 +73,7 @@ namespace Nz::GL inline Context(const OpenGLDevice* device); virtual ~Context(); + void BindTexture(TextureTarget target, GLuint texture) const; virtual void EnableVerticalSync(bool enabled) = 0; @@ -75,6 +86,8 @@ namespace Nz::GL bool Initialize(const ContextParams& params); + inline void NotifyTextureDestruction(GLuint texture) const; + virtual void SwapBuffers() = 0; #define NAZARA_OPENGLRENDERER_FUNC(name, sig) sig name = nullptr; @@ -98,9 +111,15 @@ namespace Nz::GL private: void GL_APIENTRY HandleDebugMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message) const; + struct State + { + std::array boundTextures; + }; + std::array m_extensionStatus; std::unordered_set m_supportedExtensions; const OpenGLDevice* m_device; + mutable State m_state; }; } diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Context.inl b/include/Nazara/OpenGLRenderer/Wrapper/Context.inl index ff296f5ec..d72897342 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Context.inl +++ b/include/Nazara/OpenGLRenderer/Wrapper/Context.inl @@ -36,6 +36,15 @@ namespace Nz::GL { return m_supportedExtensions.find(extension) != m_supportedExtensions.end(); } + + inline void Context::NotifyTextureDestruction(GLuint texture) const + { + for (GLuint& boundTexture : m_state.boundTextures) + { + if (boundTexture == texture) + boundTexture = 0; + } + } } #include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Texture.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Texture.hpp index 6fc242f3e..af71a484b 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Texture.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Texture.hpp @@ -4,40 +4,41 @@ #pragma once -#ifndef NAZARA_OPENGLRENDERER_VKPIPELINELAYOUT_HPP -#define NAZARA_OPENGLRENDERER_VKPIPELINELAYOUT_HPP +#ifndef NAZARA_OPENGLRENDERER_GLTEXTURE_HPP +#define NAZARA_OPENGLRENDERER_GLTEXTURE_HPP #include -#include +#include +#include -namespace Nz +namespace Nz::GL { - namespace Vk + class Texture { - class PipelineLayout : public DeviceObject - { - friend DeviceObject; + public: + Texture() = default; + Texture(const Texture&) = delete; + Texture(Texture&&) noexcept = default; + inline ~Texture(); - public: - PipelineLayout() = default; - PipelineLayout(const PipelineLayout&) = delete; - PipelineLayout(PipelineLayout&&) = default; - ~PipelineLayout() = default; + inline bool Create(OpenGLDevice& device); + inline void Destroy(); - using DeviceObject::Create; - bool Create(Device& device, VkDescriptorSetLayout layout, VkPipelineLayoutCreateFlags flags = 0); - bool Create(Device& device, UInt32 layoutCount, const VkDescriptorSetLayout* layouts, VkPipelineLayoutCreateFlags flags = 0); + inline void TexImage2D(GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border); + inline void TexImage2D(GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* data); + inline void TexSubImage2D(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* data); - PipelineLayout& operator=(const PipelineLayout&) = delete; - PipelineLayout& operator=(PipelineLayout&&) = delete; + Texture& operator=(const Texture&) = delete; + Texture& operator=(Texture&&) noexcept = default; - private: - static inline VkResult CreateHelper(Device& device, const VkPipelineLayoutCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkPipelineLayout* handle); - static inline void DestroyHelper(Device& device, VkPipelineLayout handle, const VkAllocationCallbacks* allocator); - }; - } + private: + const Context& EnsureDeviceContext(); + + MovablePtr m_device; + MovableValue m_texture; + }; } -#include +#include -#endif // NAZARA_OPENGLRENDERER_VKPIPELINELAYOUT_HPP +#endif diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Texture.inl b/include/Nazara/OpenGLRenderer/Wrapper/Texture.inl index cd86f80a3..3d50a8997 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Texture.inl +++ b/include/Nazara/OpenGLRenderer/Wrapper/Texture.inl @@ -2,42 +2,82 @@ // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include +#include #include -namespace Nz +namespace Nz::GL { - namespace Vk + inline Texture::~Texture() { - inline bool PipelineLayout::Create(Device& device, VkDescriptorSetLayout layout, VkPipelineLayoutCreateFlags flags) + Destroy(); + } + + inline bool Texture::Create(OpenGLDevice& device) + { + Destroy(); + + m_device = &device; + + const Context& context = EnsureDeviceContext(); + context.glGenTextures(1U, &m_texture.Get()); + if (!m_texture) + return false; //< TODO: Handle error messages + + return true; + } + + inline void Texture::Destroy() + { + if (m_texture) { - return Create(device, 1U, &layout, flags); + const Context& context = EnsureDeviceContext(); + context.glDeleteTextures(1U, &m_texture.Get()); + + m_device->NotifyTextureDestruction(m_texture); + + m_texture = 0; + } + } + + inline void Texture::TexImage2D(GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border) + { + return TexImage2D(level, internalFormat, width, height, border, GL_RGB, GL_UNSIGNED_BYTE, nullptr); + } + + inline void Texture::TexImage2D(GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* data) + { + const Context& context = EnsureDeviceContext(); + context.BindTexture(TextureTarget::Target2D, m_texture); + + context.glTexImage2D(GL_TEXTURE_2D, level, internalFormat, width, height, border, format, type, data); + //< TODO: Handle errors + } + + inline void Texture::TexSubImage2D(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* data) + { + const Context& context = EnsureDeviceContext(); + context.BindTexture(TextureTarget::Target2D, m_texture); + + context.glTexSubImage2D(GL_TEXTURE_2D, level, xoffset, yoffset, width, height, format, type, data); + //< TODO: Handle errors + } + + inline const Context& Texture::EnsureDeviceContext() + { + assert(m_device); + + const Context* activeContext = Context::GetCurrentContext(); + if (!activeContext || activeContext->GetDevice() != m_device) + { + const Context& referenceContext = m_device->GetReferenceContext(); + if (!Context::SetCurrentContext(&referenceContext)) + throw std::runtime_error("failed to activate context"); + + return referenceContext; } - inline bool PipelineLayout::Create(Device& device, UInt32 layoutCount, const VkDescriptorSetLayout* layouts, VkPipelineLayoutCreateFlags flags) - { - VkPipelineLayoutCreateInfo createInfo = { - VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, - nullptr, - flags, - layoutCount, - layouts, - 0U, - nullptr - }; - - return Create(device, createInfo); - } - - inline VkResult PipelineLayout::CreateHelper(Device& device, const VkPipelineLayoutCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkPipelineLayout* handle) - { - return device.vkCreatePipelineLayout(device, createInfo, allocator, handle); - } - - inline void PipelineLayout::DestroyHelper(Device& device, VkPipelineLayout handle, const VkAllocationCallbacks* allocator) - { - return device.vkDestroyPipelineLayout(device, handle, allocator); - } + return *activeContext; } } diff --git a/include/Nazara/Renderer/Texture.hpp b/include/Nazara/Renderer/Texture.hpp index 6aa8502b8..4fa0ebc75 100644 --- a/include/Nazara/Renderer/Texture.hpp +++ b/include/Nazara/Renderer/Texture.hpp @@ -40,6 +40,8 @@ namespace Nz virtual bool Update(const void* ptr) = 0; + static inline unsigned int GetLevelSize(unsigned int size, unsigned int level); + Texture& operator=(const Texture&) = delete; Texture& operator=(Texture&&) = delete; }; diff --git a/include/Nazara/Renderer/Texture.inl b/include/Nazara/Renderer/Texture.inl index f389a6984..bc1d1aaee 100644 --- a/include/Nazara/Renderer/Texture.inl +++ b/include/Nazara/Renderer/Texture.inl @@ -7,6 +7,13 @@ namespace Nz { + inline unsigned int Texture::GetLevelSize(unsigned int size, unsigned int level) + { + if (size == 0) // Possible dans le cas d'une image invalide + return 0; + + return std::max(size >> level, 1U); + } } #include diff --git a/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp b/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp index a5df5efcb..706396e15 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -66,7 +67,7 @@ namespace Nz std::unique_ptr OpenGLDevice::InstantiateTexture(const TextureInfo& params) { - return {}; + return std::make_unique(*this, params); } std::unique_ptr OpenGLDevice::InstantiateTextureSampler(const TextureSamplerInfo& params) diff --git a/src/Nazara/OpenGLRenderer/OpenGLTexture.cpp b/src/Nazara/OpenGLRenderer/OpenGLTexture.cpp index 1d2f5e0f4..55e5efa0c 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLTexture.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLTexture.cpp @@ -2,160 +2,62 @@ // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#if 0 - #include #include #include -#include -#include #include #include #include namespace Nz { - namespace - { - inline unsigned int GetLevelSize(unsigned int size, UInt8 level) - { - if (size == 0) // Possible dans le cas d'une image invalide - return 0; - - return std::max(size >> level, 1U); - } - } - - OpenGLTexture::OpenGLTexture(Vk::Device& device, const TextureInfo& params) : - m_image(VK_NULL_HANDLE), - m_allocation(nullptr), - m_device(device), + OpenGLTexture::OpenGLTexture(OpenGLDevice& device, const TextureInfo& params) : m_params(params) { - VkImageCreateInfo createInfo = { VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO }; - createInfo.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; - createInfo.mipLevels = params.mipmapLevel; - createInfo.samples = VK_SAMPLE_COUNT_1_BIT; - createInfo.tiling = VK_IMAGE_TILING_OPTIMAL; - createInfo.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT; + if (!m_texture.Create(device)) + throw std::runtime_error("failed to create texture object"); - VkImageViewCreateInfo createInfoView = { VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO }; - createInfoView.subresourceRange = { - VK_IMAGE_ASPECT_COLOR_BIT, - 0, - 1, - 0, - 1 - }; + GLint internalFormat; + switch (params.pixelFormat) + { + case PixelFormat_RGB8: + { + internalFormat = GL_RGB8; + break; + } - InitForFormat(params.pixelFormat, createInfo, createInfoView); + case PixelFormat_RGBA8: + { + internalFormat = GL_RGBA8; + break; + } + } switch (params.type) { case ImageType_1D: - NazaraAssert(params.width > 0, "Width must be over zero"); - - createInfoView.viewType = VK_IMAGE_VIEW_TYPE_1D; - - createInfo.imageType = VK_IMAGE_TYPE_1D; - createInfo.extent.width = params.width; - createInfo.extent.height = 1; - createInfo.extent.depth = 1; - createInfo.arrayLayers = 1; break; case ImageType_1D_Array: - NazaraAssert(params.width > 0, "Width must be over zero"); - NazaraAssert(params.height > 0, "Height must be over zero"); - - createInfoView.viewType = VK_IMAGE_VIEW_TYPE_1D_ARRAY; - - createInfo.imageType = VK_IMAGE_TYPE_1D; - createInfo.extent.width = params.width; - createInfo.extent.height = 1; - createInfo.extent.depth = 1; - createInfo.arrayLayers = params.height; break; case ImageType_2D: - NazaraAssert(params.width > 0, "Width must be over zero"); - NazaraAssert(params.height > 0, "Height must be over zero"); - - createInfoView.viewType = VK_IMAGE_VIEW_TYPE_2D; - - createInfo.imageType = VK_IMAGE_TYPE_2D; - createInfo.extent.width = params.width; - createInfo.extent.height = params.height; - createInfo.extent.depth = 1; - createInfo.arrayLayers = 1; + for (unsigned int level = 0; level < m_params.mipmapLevel; ++level) + m_texture.TexImage2D(0, internalFormat, GetLevelSize(params.width, level), GetLevelSize(params.height, level), 0); break; case ImageType_2D_Array: - NazaraAssert(params.width > 0, "Width must be over zero"); - NazaraAssert(params.height > 0, "Height must be over zero"); - NazaraAssert(params.depth > 0, "Depth must be over zero"); - - createInfoView.viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY; - - createInfo.imageType = VK_IMAGE_TYPE_2D; - createInfo.extent.width = params.width; - createInfo.extent.height = params.height; - createInfo.extent.depth = 1; - createInfo.arrayLayers = params.height; break; case ImageType_3D: - NazaraAssert(params.width > 0, "Width must be over zero"); - NazaraAssert(params.height > 0, "Height must be over zero"); - NazaraAssert(params.depth > 0, "Depth must be over zero"); - - createInfoView.viewType = VK_IMAGE_VIEW_TYPE_3D; - - createInfo.imageType = VK_IMAGE_TYPE_3D; - createInfo.extent.width = params.width; - createInfo.extent.height = params.height; - createInfo.extent.depth = params.depth; - createInfo.arrayLayers = 1; break; case ImageType_Cubemap: - NazaraAssert(params.width > 0, "Width must be over zero"); - NazaraAssert(params.height > 0, "Height must be over zero"); - - createInfoView.viewType = VK_IMAGE_VIEW_TYPE_CUBE; - - createInfo.imageType = VK_IMAGE_TYPE_2D; - createInfo.extent.width = params.width; - createInfo.extent.height = params.height; - createInfo.extent.depth = 1; - createInfo.arrayLayers = 6; - createInfo.flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT; break; default: break; } - - VmaAllocationCreateInfo allocInfo = {}; - allocInfo.usage = VMA_MEMORY_USAGE_GPU_ONLY; - - VkResult result = vmaCreateImage(m_device.GetMemoryAllocator(), &createInfo, &allocInfo, &m_image, &m_allocation, nullptr); - if (result != VK_SUCCESS) - throw std::runtime_error("Failed to allocate image: " + TranslateOpenGLError(result)); - - createInfoView.image = m_image; - - if (!m_imageView.Create(device, createInfoView)) - { - // FIXME - vmaDestroyImage(m_device.GetMemoryAllocator(), m_image, m_allocation); - throw std::runtime_error("Failed to create image view: " + TranslateOpenGLError(m_imageView.GetLastErrorCode())); - } - } - - OpenGLTexture::~OpenGLTexture() - { - vmaDestroyImage(m_device.GetMemoryAllocator(), m_image, m_allocation); } PixelFormat OpenGLTexture::GetFormat() const @@ -180,112 +82,50 @@ namespace Nz bool OpenGLTexture::Update(const void* ptr) { - std::size_t textureSize = m_params.width * m_params.height * m_params.depth * PixelFormatInfo::GetBytesPerPixel(m_params.pixelFormat); - - VkBufferCreateInfo createInfo = {}; - createInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; - createInfo.size = textureSize; - createInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT; - - VmaAllocationCreateInfo allocInfo = {}; - allocInfo.flags = VMA_ALLOCATION_CREATE_MAPPED_BIT; - allocInfo.usage = VMA_MEMORY_USAGE_CPU_TO_GPU; - - VmaAllocationInfo allocationInfo; - - VkBuffer stagingBuffer; - VmaAllocation stagingAllocation; - - VkResult result = vmaCreateBuffer(m_device.GetMemoryAllocator(), &createInfo, &allocInfo, &stagingBuffer, &stagingAllocation, &allocationInfo); - if (result != VK_SUCCESS) + GLint format; + GLint type; + switch (m_params.pixelFormat) { - NazaraError("Failed to allocate staging buffer: " + TranslateOpenGLError(result)); - return false; - } - - CallOnExit freeStaging([&] { - vmaDestroyBuffer(m_device.GetMemoryAllocator(), stagingBuffer, stagingAllocation); - }); - - std::memcpy(allocationInfo.pMappedData, ptr, textureSize); - - Vk::AutoCommandBuffer copyCommandBuffer = m_device.AllocateCommandBuffer(QueueType::Graphics); - if (!copyCommandBuffer->Begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT)) - return false; - - copyCommandBuffer->SetImageLayout(m_image, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); - - copyCommandBuffer->CopyBufferToImage(stagingBuffer, m_image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, m_params.width, m_params.height, m_params.depth); - - copyCommandBuffer->SetImageLayout(m_image, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); - - if (!copyCommandBuffer->End()) - return false; - - Vk::QueueHandle transferQueue = m_device.GetQueue(m_device.GetDefaultFamilyIndex(QueueType::Graphics), 0); - if (!transferQueue.Submit(copyCommandBuffer)) - return false; - - transferQueue.WaitIdle(); - - return true; - } - - void OpenGLTexture::InitForFormat(PixelFormat pixelFormat, VkImageCreateInfo& createImage, VkImageViewCreateInfo& createImageView) - { - createImageView.components = { - VK_COMPONENT_SWIZZLE_R, - VK_COMPONENT_SWIZZLE_G, - VK_COMPONENT_SWIZZLE_B, - VK_COMPONENT_SWIZZLE_A - }; - - switch (pixelFormat) - { - case PixelFormat_L8: - { - createImage.format = VK_FORMAT_R8_SRGB; - createImageView.format = createImage.format; - createImageView.components = { - VK_COMPONENT_SWIZZLE_R, - VK_COMPONENT_SWIZZLE_R, - VK_COMPONENT_SWIZZLE_R, - VK_COMPONENT_SWIZZLE_A - }; - break; - } - - case PixelFormat_LA8: - { - createImage.format = VK_FORMAT_R8G8_SRGB; - createImageView.format = createImage.format; - createImageView.components = { - VK_COMPONENT_SWIZZLE_R, - VK_COMPONENT_SWIZZLE_R, - VK_COMPONENT_SWIZZLE_R, - VK_COMPONENT_SWIZZLE_G - }; - break; - } - case PixelFormat_RGB8: { - createImage.format = VK_FORMAT_R8G8B8_SRGB; - createImageView.format = createImage.format; + format = GL_RGB; + type = GL_UNSIGNED_BYTE; break; } case PixelFormat_RGBA8: { - createImage.format = VK_FORMAT_R8G8B8A8_SRGB; - createImageView.format = createImage.format; + format = GL_RGBA; + type = GL_UNSIGNED_BYTE; break; } + } + + switch (m_params.type) + { + case ImageType_1D: + break; + + case ImageType_1D_Array: + break; + + case ImageType_2D: + m_texture.TexSubImage2D(0, 0, 0, m_params.width, m_params.height, format, type, ptr); + break; + + case ImageType_2D_Array: + break; + + case ImageType_3D: + break; + + case ImageType_Cubemap: + break; default: - throw std::runtime_error(("Unsupported pixel format " + PixelFormatInfo::GetName(pixelFormat)).ToStdString()); + break; } + + return true; } } - -#endif diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp index 4259b8924..156e21af3 100644 --- a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp +++ b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp @@ -22,6 +22,41 @@ namespace Nz::GL m_device->NotifyContextDestruction(*this); } + void Context::BindTexture(TextureTarget target, GLuint texture) const + { + if (!SetCurrentContext(this)) + throw std::runtime_error("failed to activate context"); + + if (m_state.boundTextures[UnderlyingCast(target)] != texture) + { + GLenum glTarget; + switch (target) + { + case TextureTarget::Cubemap: + glTarget = GL_TEXTURE_CUBE_MAP; + break; + + case TextureTarget::Target2D: + glTarget = GL_TEXTURE_2D; + break; + + case TextureTarget::Target2D_Array: + glTarget = GL_TEXTURE_2D_ARRAY; + break; + + case TextureTarget::Target3D: + glTarget = GL_TEXTURE_3D; + break; + + default: + break; + } + + glBindTexture(glTarget, texture); + + m_state.boundTextures[UnderlyingCast(target)] = texture; + } + } bool Context::Initialize(const ContextParams& params) { @@ -31,6 +66,8 @@ namespace Nz::GL return false; } + m_state.boundTextures.fill(0); + const Loader& loader = GetLoader(); auto LoadSymbol = [&](auto& func, const char* funcName, bool mandatory) diff --git a/src/Nazara/VulkanRenderer/VulkanTexture.cpp b/src/Nazara/VulkanRenderer/VulkanTexture.cpp index 3a83d1c8c..55d71c3e6 100644 --- a/src/Nazara/VulkanRenderer/VulkanTexture.cpp +++ b/src/Nazara/VulkanRenderer/VulkanTexture.cpp @@ -13,17 +13,6 @@ namespace Nz { - namespace - { - inline unsigned int GetLevelSize(unsigned int size, UInt8 level) - { - if (size == 0) // Possible dans le cas d'une image invalide - return 0; - - return std::max(size >> level, 1U); - } - } - VulkanTexture::VulkanTexture(Vk::Device& device, const TextureInfo& params) : m_image(VK_NULL_HANDLE), m_allocation(nullptr), From 1c239496081c0a59715eb41eb0a37d23f57c95bd Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 26 Apr 2020 16:26:08 +0200 Subject: [PATCH 169/316] OpenGLRenderer: Use generic DeviceObject --- .../OpenGLRenderer/Wrapper/DeviceObject.hpp | 26 +-- .../OpenGLRenderer/Wrapper/DeviceObject.inl | 176 ++++++++---------- .../Nazara/OpenGLRenderer/Wrapper/Shader.hpp | 14 +- .../Nazara/OpenGLRenderer/Wrapper/Shader.inl | 64 +++---- .../Nazara/OpenGLRenderer/Wrapper/Texture.hpp | 16 +- .../Nazara/OpenGLRenderer/Wrapper/Texture.inl | 56 ++---- 6 files changed, 137 insertions(+), 215 deletions(-) diff --git a/include/Nazara/OpenGLRenderer/Wrapper/DeviceObject.hpp b/include/Nazara/OpenGLRenderer/Wrapper/DeviceObject.hpp index 495297289..e9a241ad4 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/DeviceObject.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/DeviceObject.hpp @@ -9,41 +9,43 @@ #include #include +#include #include namespace Nz::GL { - template + template class DeviceObject { public: - DeviceObject(); + DeviceObject() = default; DeviceObject(const DeviceObject&) = delete; - DeviceObject(DeviceObject&& object) noexcept; + DeviceObject(DeviceObject&& object) noexcept = default; ~DeviceObject(); - bool Create(OpenGLDevice& device); + bool Create(OpenGLDevice& device, CreateArgs... args); void Destroy(); bool IsValid() const; - Device* GetDevice() const; - VkResult GetLastErrorCode() const; + OpenGLDevice* GetDevice() const; + GLuint GetObjectId() const; - void SetDebugName(const char* name); - void SetDebugName(const std::string& name); + void SetDebugName(const std::string_view& name); DeviceObject& operator=(const DeviceObject&) = delete; - DeviceObject& operator=(DeviceObject&& object) noexcept; + DeviceObject& operator=(DeviceObject&& object) noexcept = default; - operator VkType() const; + static constexpr GLuint InvalidObject = 0; protected: + const Context& EnsureDeviceContext(); + MovablePtr m_device; - GLuint m_handle; + MovableValue m_objectId; }; } #include -#endif // NAZARA_OPENGLRENDERER_VKDEVICEOBJECT_HPP +#endif diff --git a/include/Nazara/OpenGLRenderer/Wrapper/DeviceObject.inl b/include/Nazara/OpenGLRenderer/Wrapper/DeviceObject.inl index 1dbf21289..08d029c79 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/DeviceObject.inl +++ b/include/Nazara/OpenGLRenderer/Wrapper/DeviceObject.inl @@ -7,116 +7,88 @@ #include #include -namespace Nz +namespace Nz::GL { - namespace Vk + template + DeviceObject::~DeviceObject() { - template - DeviceObject::DeviceObject() : - m_handle(VK_NULL_HANDLE) + Destroy(); + } + + template + bool DeviceObject::Create(OpenGLDevice& device, CreateArgs... args) + { + Destroy(); + + m_device = &device; + + const Context& context = EnsureDeviceContext(); + + m_objectId = C::CreateHelper(*m_device, context, args...); + if (m_objectId == InvalidObject) { + NazaraError("Failed to create OpenGL object"); //< TODO: Handle error message + return false; } - template - DeviceObject::DeviceObject(DeviceObject&& object) noexcept : - m_device(std::move(object.m_device)), - m_allocator(object.m_allocator), - m_handle(object.m_handle), - m_lastErrorCode(object.m_lastErrorCode) + return true; + } + + template + void DeviceObject::Destroy() + { + if (IsValid()) { - object.m_handle = VK_NULL_HANDLE; + const Context& context = EnsureDeviceContext(); + + C::DestroyHelper(*m_device, context, m_objectId); + m_objectId = InvalidObject; + } + } + + template + bool DeviceObject::IsValid() const + { + return m_objectId != InvalidObject; + } + + template + OpenGLDevice* DeviceObject::GetDevice() const + { + return m_device; + } + + template + GLuint DeviceObject::GetObjectId() const + { + return m_objectId; + } + + template + void DeviceObject::SetDebugName(const std::string_view& name) + { + const Context& context = EnsureDeviceContext(); + + if (context.glObjectLabel) + context.glObjectLabel(ObjectType, m_objectId, name.size(), name.data()); + } + + template + const Context& DeviceObject::EnsureDeviceContext() + { + assert(m_device); + + const Context* activeContext = Context::GetCurrentContext(); + if (!activeContext || activeContext->GetDevice() != m_device) + { + const Context& referenceContext = m_device->GetReferenceContext(); + if (!Context::SetCurrentContext(&referenceContext)) + throw std::runtime_error("failed to activate context"); + + return referenceContext; } - template - DeviceObject::~DeviceObject() - { - Destroy(); - } - - template - bool DeviceObject::Create(Device& device, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator) - { - m_device = &device; - m_lastErrorCode = C::CreateHelper(*m_device, &createInfo, allocator, &m_handle); - if (m_lastErrorCode != VkResult::VK_SUCCESS) - { - NazaraError("Failed to create OpenGL object: " + TranslateOpenGLError(m_lastErrorCode)); - return false; - } - - // Store the allocator to access them when needed - if (allocator) - m_allocator = *allocator; - else - m_allocator.pfnAllocation = nullptr; - - return true; - } - - template - void DeviceObject::Destroy() - { - if (IsValid()) - { - C::DestroyHelper(*m_device, m_handle, (m_allocator.pfnAllocation) ? &m_allocator : nullptr); - m_handle = VK_NULL_HANDLE; - } - } - - template - bool DeviceObject::IsValid() const - { - return m_handle != VK_NULL_HANDLE; - } - - template - Device* DeviceObject::GetDevice() const - { - return m_device; - } - - template - VkResult DeviceObject::GetLastErrorCode() const - { - return m_lastErrorCode; - } - - template - void DeviceObject::SetDebugName(const char* name) - { - if (m_device->vkSetDebugUtilsObjectNameEXT) - { - VkDebugUtilsObjectNameInfoEXT debugName = { VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT }; - debugName.objectType = ObjectType; - debugName.objectHandle = static_cast(reinterpret_cast(m_handle)); - debugName.pObjectName = name; - - m_device->vkSetDebugUtilsObjectNameEXT(*m_device, &debugName); - } - } - - template - void DeviceObject::SetDebugName(const std::string& name) - { - return SetDebugName(name.data()); - } - - template - auto DeviceObject::operator=(DeviceObject&& object) noexcept -> DeviceObject& - { - std::swap(m_allocator, object.m_allocator); - std::swap(m_device, object.m_device); - std::swap(m_handle, object.m_handle); - std::swap(m_lastErrorCode, object.m_lastErrorCode); - - return *this; - } - - template - DeviceObject::operator VkType() const - { - return m_handle; - } + return *activeContext; } } diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Shader.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Shader.hpp index 13eda392b..b99e752fa 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Shader.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Shader.hpp @@ -10,22 +10,22 @@ #include #include #include +#include namespace Nz::GL { - class Shader + class Shader : public DeviceObject { + friend DeviceObject; + public: Shader() = default; Shader(const Shader&) = delete; Shader(Shader&&) noexcept = default; - inline ~Shader(); + ~Shader() = default; inline void Compile(); - inline bool Create(OpenGLDevice& device, GLenum type); - inline void Destroy(); - inline bool GetCompilationStatus(std::string* error = nullptr); inline void SetBinarySource(GLenum binaryFormat, const void* binary, GLsizei length); @@ -38,8 +38,8 @@ namespace Nz::GL Shader& operator=(Shader&&) noexcept = default; private: - MovablePtr m_device; - MovableValue m_shader; + static inline GLuint CreateHelper(OpenGLDevice& device, const Context& context, GLenum shaderStage); + static inline void DestroyHelper(OpenGLDevice& device, const Context& context, GLuint objectId); }; } diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Shader.inl b/include/Nazara/OpenGLRenderer/Wrapper/Shader.inl index e7a5e4f11..ee6ebf850 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Shader.inl +++ b/include/Nazara/OpenGLRenderer/Wrapper/Shader.inl @@ -8,58 +8,32 @@ namespace Nz::GL { - inline Shader::~Shader() - { - Destroy(); - } - inline void Shader::Compile() { - assert(m_shader); - m_device->GetReferenceContext().glCompileShader(m_shader); - } - - inline bool Shader::Create(OpenGLDevice& device, GLenum type) - { - Destroy(); - - m_device = &device; - m_shader = device.GetReferenceContext().glCreateShader(type); - if (!m_shader) - return false; //< TODO: Handle error messages - - return true; - } - - inline void Shader::Destroy() - { - if (m_shader) - { - m_device->GetReferenceContext().glDeleteShader(m_shader); - m_shader = 0; - } + assert(m_objectId); + m_device->GetReferenceContext().glCompileShader(m_objectId); } inline bool Shader::GetCompilationStatus(std::string* error) { - assert(m_shader); - const GL::Context& context = m_device->GetReferenceContext(); + assert(m_objectId); + const Context& context = EnsureDeviceContext(); GLint success; - context.glGetShaderiv(m_shader, GL_COMPILE_STATUS, &success); + context.glGetShaderiv(m_objectId, GL_COMPILE_STATUS, &success); if (!success) { if (error) { GLint logLength; - context.glGetShaderiv(m_shader, GL_INFO_LOG_LENGTH, &logLength); + context.glGetShaderiv(m_objectId, GL_INFO_LOG_LENGTH, &logLength); error->resize(logLength); if (logLength > 0) { GLsizei dummy; - context.glGetShaderInfoLog(m_shader, logLength, &dummy, error->data()); + context.glGetShaderInfoLog(m_objectId, logLength, &dummy, error->data()); } } @@ -71,25 +45,35 @@ namespace Nz::GL inline void Shader::SetBinarySource(GLenum binaryFormat, const void* binary, GLsizei length) { - assert(m_shader); + assert(m_objectId); - m_device->GetReferenceContext().glShaderBinary(1U, &m_shader.Get(), binaryFormat, binary, length); + m_device->GetReferenceContext().glShaderBinary(1U, &m_objectId.Get(), binaryFormat, binary, length); } inline void Shader::SetSource(const char* source, GLint length) { - assert(m_shader); + assert(m_objectId); - m_device->GetReferenceContext().glShaderSource(m_shader, 1U, &source, &length); + m_device->GetReferenceContext().glShaderSource(m_objectId, 1U, &source, &length); } inline void Shader::SpecializeShader(const GLchar* pEntryPoint, GLuint numSpecializationConstants, const GLuint* pConstantIndex, const GLuint* pConstantValue) { - assert(m_shader); - const GL::Context& context = m_device->GetReferenceContext(); + assert(m_objectId); + const Context& context = EnsureDeviceContext(); assert(context.glSpecializeShaderARB); - context.glSpecializeShaderARB(m_shader, pEntryPoint, numSpecializationConstants, pConstantIndex, pConstantValue); + context.glSpecializeShaderARB(m_objectId, pEntryPoint, numSpecializationConstants, pConstantIndex, pConstantValue); + } + + inline GLuint Shader::CreateHelper(OpenGLDevice& device, const Context& context, GLenum shaderStage) + { + return context.glCreateShader(shaderStage); + } + + inline void Shader::DestroyHelper(OpenGLDevice& device, const Context& context, GLuint objectId) + { + context.glDeleteShader(objectId); } } diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Texture.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Texture.hpp index af71a484b..1e6198146 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Texture.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Texture.hpp @@ -10,19 +10,19 @@ #include #include #include +#include namespace Nz::GL { - class Texture + class Texture : public DeviceObject { + friend DeviceObject; + public: Texture() = default; Texture(const Texture&) = delete; Texture(Texture&&) noexcept = default; - inline ~Texture(); - - inline bool Create(OpenGLDevice& device); - inline void Destroy(); + ~Texture() = default; inline void TexImage2D(GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border); inline void TexImage2D(GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* data); @@ -32,10 +32,8 @@ namespace Nz::GL Texture& operator=(Texture&&) noexcept = default; private: - const Context& EnsureDeviceContext(); - - MovablePtr m_device; - MovableValue m_texture; + static inline GLuint CreateHelper(OpenGLDevice& device, const Context& context); + static inline void DestroyHelper(OpenGLDevice& device, const Context& context, GLuint objectId); }; } diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Texture.inl b/include/Nazara/OpenGLRenderer/Wrapper/Texture.inl index 3d50a8997..14ef42866 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Texture.inl +++ b/include/Nazara/OpenGLRenderer/Wrapper/Texture.inl @@ -8,38 +8,6 @@ namespace Nz::GL { - inline Texture::~Texture() - { - Destroy(); - } - - inline bool Texture::Create(OpenGLDevice& device) - { - Destroy(); - - m_device = &device; - - const Context& context = EnsureDeviceContext(); - context.glGenTextures(1U, &m_texture.Get()); - if (!m_texture) - return false; //< TODO: Handle error messages - - return true; - } - - inline void Texture::Destroy() - { - if (m_texture) - { - const Context& context = EnsureDeviceContext(); - context.glDeleteTextures(1U, &m_texture.Get()); - - m_device->NotifyTextureDestruction(m_texture); - - m_texture = 0; - } - } - inline void Texture::TexImage2D(GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border) { return TexImage2D(level, internalFormat, width, height, border, GL_RGB, GL_UNSIGNED_BYTE, nullptr); @@ -48,7 +16,7 @@ namespace Nz::GL inline void Texture::TexImage2D(GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* data) { const Context& context = EnsureDeviceContext(); - context.BindTexture(TextureTarget::Target2D, m_texture); + context.BindTexture(TextureTarget::Target2D, m_objectId); context.glTexImage2D(GL_TEXTURE_2D, level, internalFormat, width, height, border, format, type, data); //< TODO: Handle errors @@ -57,27 +25,25 @@ namespace Nz::GL inline void Texture::TexSubImage2D(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* data) { const Context& context = EnsureDeviceContext(); - context.BindTexture(TextureTarget::Target2D, m_texture); + context.BindTexture(TextureTarget::Target2D, m_objectId); context.glTexSubImage2D(GL_TEXTURE_2D, level, xoffset, yoffset, width, height, format, type, data); //< TODO: Handle errors } - inline const Context& Texture::EnsureDeviceContext() + inline GLuint Texture::CreateHelper(OpenGLDevice& device, const Context& context) { - assert(m_device); + GLuint sampler = 0; + context.glGenTextures(1U, &sampler); - const Context* activeContext = Context::GetCurrentContext(); - if (!activeContext || activeContext->GetDevice() != m_device) - { - const Context& referenceContext = m_device->GetReferenceContext(); - if (!Context::SetCurrentContext(&referenceContext)) - throw std::runtime_error("failed to activate context"); + return sampler; + } - return referenceContext; - } + inline void Texture::DestroyHelper(OpenGLDevice& device, const Context& context, GLuint objectId) + { + context.glDeleteTextures(1U, &objectId); - return *activeContext; + device.NotifyTextureDestruction(objectId); } } From cbd81e3abff899d3f896a95edb71bad8eed68eef Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 26 Apr 2020 16:26:24 +0200 Subject: [PATCH 170/316] Vulkan: Fix DeviceObject not destroying previous object --- include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl index 8f80a8e8f..6da9b14b3 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/DeviceObject.inl @@ -36,6 +36,8 @@ namespace Nz template bool DeviceObject::Create(Device& device, const CreateInfo& createInfo, const VkAllocationCallbacks* allocator) { + Destroy(); + m_device = &device; m_lastErrorCode = C::CreateHelper(*m_device, &createInfo, allocator, &m_handle); if (m_lastErrorCode != VkResult::VK_SUCCESS) From e9f0b01e0267ab7101ee5ac5dc5a73e16ec4107a Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 26 Apr 2020 16:29:31 +0200 Subject: [PATCH 171/316] OpenGLRenderer: Implement TextureSampler (and texture units) --- .../Nazara/OpenGLRenderer/OpenGLDevice.hpp | 1 + .../Nazara/OpenGLRenderer/OpenGLDevice.inl | 6 ++ .../OpenGLRenderer/OpenGLTextureSampler.hpp | 7 ++- .../OpenGLRenderer/OpenGLTextureSampler.inl | 4 +- include/Nazara/OpenGLRenderer/Utils.hpp | 3 + include/Nazara/OpenGLRenderer/Utils.inl | 58 +++++++++++++++++++ .../Nazara/OpenGLRenderer/Wrapper/Context.hpp | 17 +++++- .../Nazara/OpenGLRenderer/Wrapper/Context.inl | 27 ++++++++- .../OpenGLRenderer/Wrapper/CoreFunctions.hpp | 2 + .../Nazara/OpenGLRenderer/Wrapper/Sampler.hpp | 44 +++++++------- .../Nazara/OpenGLRenderer/Wrapper/Sampler.inl | 54 +++++++++++++---- .../OpenGLRenderer/OpenGLTextureSampler.cpp | 34 +++++------ src/Nazara/OpenGLRenderer/Wrapper/Context.cpp | 53 +++++++++++++++-- 13 files changed, 244 insertions(+), 66 deletions(-) diff --git a/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp b/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp index 2434549b2..6d30b56be 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp @@ -40,6 +40,7 @@ namespace Nz std::unique_ptr InstantiateTexture(const TextureInfo& params) override; std::unique_ptr InstantiateTextureSampler(const TextureSamplerInfo& params) override; + inline void NotifySamplerDestruction(GLuint texture) const; inline void NotifyTextureDestruction(GLuint texture) const; OpenGLDevice& operator=(const OpenGLDevice&) = delete; diff --git a/include/Nazara/OpenGLRenderer/OpenGLDevice.inl b/include/Nazara/OpenGLRenderer/OpenGLDevice.inl index 0c77347a6..98208b40e 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLDevice.inl +++ b/include/Nazara/OpenGLRenderer/OpenGLDevice.inl @@ -12,6 +12,12 @@ namespace Nz return *m_referenceContext; } + inline void OpenGLDevice::NotifySamplerDestruction(GLuint texture) const + { + for (const GL::Context* context : m_contexts) + context->NotifySamplerDestruction(texture); + } + inline void OpenGLDevice::NotifyTextureDestruction(GLuint texture) const { for (const GL::Context* context : m_contexts) diff --git a/include/Nazara/OpenGLRenderer/OpenGLTextureSampler.hpp b/include/Nazara/OpenGLRenderer/OpenGLTextureSampler.hpp index 4ba930384..efe9b37bf 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLTextureSampler.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLTextureSampler.hpp @@ -9,6 +9,7 @@ #include #include +#include #include namespace Nz @@ -16,18 +17,18 @@ namespace Nz class NAZARA_OPENGLRENDERER_API OpenGLTextureSampler : public TextureSampler { public: - OpenGLTextureSampler(Vk::Device& device, TextureSamplerInfo samplerInfo); + OpenGLTextureSampler(OpenGLDevice& device, TextureSamplerInfo samplerInfo); OpenGLTextureSampler(const OpenGLTextureSampler&) = default; OpenGLTextureSampler(OpenGLTextureSampler&&) noexcept = default; ~OpenGLTextureSampler() = default; - inline VkSampler GetSampler() const; + inline const GL::Sampler& GetSampler() const; OpenGLTextureSampler& operator=(const OpenGLTextureSampler&) = delete; OpenGLTextureSampler& operator=(OpenGLTextureSampler&&) = delete; private: - Vk::Sampler m_sampler; + GL::Sampler m_sampler; }; } diff --git a/include/Nazara/OpenGLRenderer/OpenGLTextureSampler.inl b/include/Nazara/OpenGLRenderer/OpenGLTextureSampler.inl index 1935928c3..710e835fb 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLTextureSampler.inl +++ b/include/Nazara/OpenGLRenderer/OpenGLTextureSampler.inl @@ -2,12 +2,12 @@ // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include namespace Nz { - inline VkSampler OpenGLTextureSampler::GetSampler() const + inline const GL::Sampler& OpenGLTextureSampler::GetSampler() const { return m_sampler; } diff --git a/include/Nazara/OpenGLRenderer/Utils.hpp b/include/Nazara/OpenGLRenderer/Utils.hpp index ad330277d..b7f4c4200 100644 --- a/include/Nazara/OpenGLRenderer/Utils.hpp +++ b/include/Nazara/OpenGLRenderer/Utils.hpp @@ -16,6 +16,9 @@ namespace Nz { + inline GLenum ToOpenGL(SamplerFilter filter); + inline GLenum ToOpenGL(SamplerFilter minFilter, SamplerMipmapMode mipmapFilter); + inline GLenum ToOpenGL(SamplerWrap wrapMode); inline GLenum ToOpenGL(ShaderStageType stageType); //NAZARA_OPENGLRENDERER_API std::string TranslateOpenGLError(GLenum code); diff --git a/include/Nazara/OpenGLRenderer/Utils.inl b/include/Nazara/OpenGLRenderer/Utils.inl index 4e6be66cc..279648237 100644 --- a/include/Nazara/OpenGLRenderer/Utils.inl +++ b/include/Nazara/OpenGLRenderer/Utils.inl @@ -10,6 +10,64 @@ namespace Nz { + GLenum ToOpenGL(SamplerFilter filter) + { + switch (filter) + { + case SamplerFilter::SamplerFilter_Linear: return GL_LINEAR; + case SamplerFilter::SamplerFilter_Nearest: return GL_NEAREST; + } + + NazaraError("Unhandled SamplerFilter 0x" + String::Number(UnderlyingCast(filter), 16)); + return {}; + } + + GLenum ToOpenGL(SamplerFilter minFilter, SamplerMipmapMode mipmapFilter) + { + switch (minFilter) + { + case SamplerFilter::SamplerFilter_Linear: + { + switch (mipmapFilter) + { + case SamplerMipmapMode_Linear: return GL_LINEAR_MIPMAP_LINEAR; + case SamplerMipmapMode_Nearest: return GL_LINEAR_MIPMAP_NEAREST; + } + + NazaraError("Unhandled SamplerFilter 0x" + String::Number(UnderlyingCast(mipmapFilter), 16)); + return {}; + } + + case SamplerFilter::SamplerFilter_Nearest: + { + switch (mipmapFilter) + { + case SamplerMipmapMode_Linear: return GL_NEAREST_MIPMAP_LINEAR; + case SamplerMipmapMode_Nearest: return GL_NEAREST_MIPMAP_NEAREST; + } + + NazaraError("Unhandled SamplerFilter 0x" + String::Number(UnderlyingCast(mipmapFilter), 16)); + return {}; + } + } + + NazaraError("Unhandled SamplerFilter 0x" + String::Number(UnderlyingCast(minFilter), 16)); + return {}; + } + + GLenum ToOpenGL(SamplerWrap wrapMode) + { + switch (wrapMode) + { + case SamplerWrap::SamplerWrap_Clamp: return GL_CLAMP_TO_EDGE; + case SamplerWrap::SamplerWrap_MirroredRepeat: return GL_MIRRORED_REPEAT; + case SamplerWrap::SamplerWrap_Repeat: return GL_REPEAT; + } + + NazaraError("Unhandled SamplerWrap 0x" + String::Number(UnderlyingCast(wrapMode), 16)); + return {}; + } + GLenum ToOpenGL(ShaderStageType stageType) { switch (stageType) diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp index b0d731bac..d24d56650 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp @@ -30,8 +30,9 @@ namespace Nz::GL enum class Extension { SpirV, + TextureFilterAnisotropic, - Max = SpirV + Max = TextureFilterAnisotropic }; enum class ExtensionStatus @@ -73,7 +74,9 @@ namespace Nz::GL inline Context(const OpenGLDevice* device); virtual ~Context(); + void BindSampler(UInt32 textureUnit, GLuint sampler) const; void BindTexture(TextureTarget target, GLuint texture) const; + void BindTexture(UInt32 textureUnit, TextureTarget target, GLuint texture) const; virtual void EnableVerticalSync(bool enabled) = 0; @@ -86,8 +89,11 @@ namespace Nz::GL bool Initialize(const ContextParams& params); + inline void NotifySamplerDestruction(GLuint sampler) const; inline void NotifyTextureDestruction(GLuint texture) const; + inline void SetCurrentTextureUnit(UInt32 textureUnit) const; + virtual void SwapBuffers() = 0; #define NAZARA_OPENGLRENDERER_FUNC(name, sig) sig name = nullptr; @@ -113,7 +119,14 @@ namespace Nz::GL struct State { - std::array boundTextures; + struct TextureUnit + { + GLuint sampler = 0; + std::array textureTargets = { 0 }; + }; + + std::vector textureUnits; + UInt32 currentTextureUnit = 0; }; std::array m_extensionStatus; diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Context.inl b/include/Nazara/OpenGLRenderer/Wrapper/Context.inl index d72897342..88429dd1d 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Context.inl +++ b/include/Nazara/OpenGLRenderer/Wrapper/Context.inl @@ -37,12 +37,33 @@ namespace Nz::GL return m_supportedExtensions.find(extension) != m_supportedExtensions.end(); } + inline void Context::NotifySamplerDestruction(GLuint sampler) const + { + for (auto& unit : m_state.textureUnits) + { + if (unit.sampler == sampler) + unit.sampler = 0; + } + } + inline void Context::NotifyTextureDestruction(GLuint texture) const { - for (GLuint& boundTexture : m_state.boundTextures) + for (auto& unit : m_state.textureUnits) { - if (boundTexture == texture) - boundTexture = 0; + for (GLuint& boundTexture : unit.textureTargets) + { + if (boundTexture == texture) + boundTexture = 0; + } + } + } + + inline void Context::SetCurrentTextureUnit(UInt32 textureUnit) const + { + if (m_state.currentTextureUnit != textureUnit) + { + glActiveTexture(GL_TEXTURE0 + textureUnit); + m_state.currentTextureUnit = textureUnit; } } } diff --git a/include/Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp b/include/Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp index ac90702c9..21e4f707a 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp @@ -110,7 +110,9 @@ typedef void (GL_APIENTRYP PFNGLSPECIALIZESHADERARBPROC) (GLuint shader, const G cb(glReadPixels, PFNGLREADPIXELSPROC) \ cb(glRenderbufferStorage, PFNGLRENDERBUFFERSTORAGEPROC) \ cb(glSamplerParameterf, PFNGLSAMPLERPARAMETERFPROC) \ + cb(glSamplerParameterfv, PFNGLSAMPLERPARAMETERFVPROC) \ cb(glSamplerParameteri, PFNGLSAMPLERPARAMETERIPROC) \ + cb(glSamplerParameteriv, PFNGLSAMPLERPARAMETERIVPROC) \ cb(glScissor, PFNGLSCISSORPROC) \ cb(glShaderBinary, PFNGLSHADERBINARYPROC) \ cb(glShaderSource, PFNGLSHADERSOURCEPROC) \ diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Sampler.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Sampler.hpp index 368511917..38fd5b542 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Sampler.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Sampler.hpp @@ -4,36 +4,40 @@ #pragma once -#ifndef NAZARA_OPENGLRENDERER_VKSAMPLER_HPP -#define NAZARA_OPENGLRENDERER_VKSAMPLER_HPP +#ifndef NAZARA_OPENGLRENDERER_GLSAMPLER_HPP +#define NAZARA_OPENGLRENDERER_GLSAMPLER_HPP #include +#include +#include #include -namespace Nz +namespace Nz::GL { - namespace Vk + class Sampler : public DeviceObject { - class Sampler : public DeviceObject - { - friend DeviceObject; + friend DeviceObject; - public: - Sampler() = default; - Sampler(const Sampler&) = delete; - Sampler(Sampler&&) = default; - ~Sampler() = default; + public: + Sampler() = default; + Sampler(const Sampler&) = delete; + Sampler(Sampler&&) noexcept = default; + ~Sampler() = default; - Sampler& operator=(const Sampler&) = delete; - Sampler& operator=(Sampler&&) = delete; + inline void SetParameterf(GLenum pname, GLfloat param); + inline void SetParameteri(GLenum pname, GLint param); + inline void SetParameterfv(GLenum pname, const GLfloat* param); + inline void SetParameteriv(GLenum pname, const GLint* param); - private: - static inline VkResult CreateHelper(Device& device, const VkSamplerCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSampler* handle); - static inline void DestroyHelper(Device& device, VkSampler handle, const VkAllocationCallbacks* allocator); - }; - } + Sampler& operator=(const Sampler&) = delete; + Sampler& operator=(Sampler&&) noexcept = default; + + private: + static inline GLuint CreateHelper(OpenGLDevice& device, const Context& context); + static inline void DestroyHelper(OpenGLDevice& device, const Context& context, GLuint objectId); + }; } #include -#endif // NAZARA_OPENGLRENDERER_VKSAMPLER_HPP +#endif diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Sampler.inl b/include/Nazara/OpenGLRenderer/Wrapper/Sampler.inl index ab1407c55..b48ab4c03 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Sampler.inl +++ b/include/Nazara/OpenGLRenderer/Wrapper/Sampler.inl @@ -5,19 +5,53 @@ #include #include -namespace Nz +namespace Nz::GL { - namespace Vk + inline void Sampler::SetParameterf(GLenum pname, GLfloat param) { - inline VkResult Sampler::CreateHelper(Device& device, const VkSamplerCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkSampler* handle) - { - return device.vkCreateSampler(device, createInfo, allocator, handle); - } + assert(m_objectId); - inline void Sampler::DestroyHelper(Device& device, VkSampler handle, const VkAllocationCallbacks* allocator) - { - return device.vkDestroySampler(device, handle, allocator); - } + const Context& context = EnsureDeviceContext(); + context.glSamplerParameterf(m_objectId, pname, param); + } + + inline void Sampler::SetParameteri(GLenum pname, GLint param) + { + assert(m_objectId); + + const Context& context = EnsureDeviceContext(); + context.glSamplerParameteri(m_objectId, pname, param); + } + + inline void Sampler::SetParameterfv(GLenum pname, const GLfloat* param) + { + assert(m_objectId); + + const Context& context = EnsureDeviceContext(); + context.glSamplerParameterfv(m_objectId, pname, param); + } + + inline void Sampler::SetParameteriv(GLenum pname, const GLint* param) + { + assert(m_objectId); + + const Context& context = EnsureDeviceContext(); + context.glSamplerParameteriv(m_objectId, pname, param); + } + + inline GLuint Sampler::CreateHelper(OpenGLDevice& device, const Context& context) + { + GLuint sampler = 0; + context.glGenSamplers(1U, &sampler); + + return sampler; + } + + inline void Sampler::DestroyHelper(OpenGLDevice& device, const Context& context, GLuint objectId) + { + context.glDeleteSamplers(1U, &objectId); + + device.NotifySamplerDestruction(objectId); } } diff --git a/src/Nazara/OpenGLRenderer/OpenGLTextureSampler.cpp b/src/Nazara/OpenGLRenderer/OpenGLTextureSampler.cpp index 6a8dd75eb..72dac5f12 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLTextureSampler.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLTextureSampler.cpp @@ -2,34 +2,28 @@ // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#if 0 - #include +#include #include #include namespace Nz { - OpenGLTextureSampler::OpenGLTextureSampler(Vk::Device& device, TextureSamplerInfo samplerInfo) + OpenGLTextureSampler::OpenGLTextureSampler(OpenGLDevice& device, TextureSamplerInfo samplerInfo) { - VkSamplerCreateInfo createInfo = { VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO }; - createInfo.magFilter = ToOpenGL(samplerInfo.magFilter); - createInfo.minFilter = ToOpenGL(samplerInfo.minFilter); - createInfo.addressModeU = ToOpenGL(samplerInfo.wrapModeU); - createInfo.addressModeV = ToOpenGL(samplerInfo.wrapModeV); - createInfo.addressModeW = ToOpenGL(samplerInfo.wrapModeW); - createInfo.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK; - createInfo.mipmapMode = ToOpenGL(samplerInfo.mipmapMode); + if (!m_sampler.Create(device)) + throw std::runtime_error("failed to create sampler object"); - if (samplerInfo.anisotropyLevel > 0.f) - { - createInfo.anisotropyEnable = VK_TRUE; - createInfo.maxAnisotropy = samplerInfo.anisotropyLevel; - } + // In OpenGL, min and mipmap sampler are part of the same enum - if (!m_sampler.Create(device, createInfo)) - throw std::runtime_error("Failed to create sampler: " + TranslateOpenGLError(m_sampler.GetLastErrorCode())); + m_sampler.SetParameteri(GL_TEXTURE_MIN_FILTER, ToOpenGL(samplerInfo.minFilter, samplerInfo.mipmapMode)); + m_sampler.SetParameteri(GL_TEXTURE_MAG_FILTER, ToOpenGL(samplerInfo.magFilter)); + + m_sampler.SetParameteri(GL_TEXTURE_WRAP_S, ToOpenGL(samplerInfo.wrapModeU)); + m_sampler.SetParameteri(GL_TEXTURE_WRAP_T, ToOpenGL(samplerInfo.wrapModeV)); + m_sampler.SetParameteri(GL_TEXTURE_WRAP_R, ToOpenGL(samplerInfo.wrapModeW)); + + if (samplerInfo.anisotropyLevel > 1.f) + m_sampler.SetParameterf(GL_TEXTURE_MAX_ANISOTROPY_EXT, samplerInfo.anisotropyLevel); } } - -#endif diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp index 156e21af3..c4333e90f 100644 --- a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp +++ b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp @@ -22,13 +22,40 @@ namespace Nz::GL m_device->NotifyContextDestruction(*this); } + void Context::BindSampler(UInt32 textureUnit, GLuint sampler) const + { + if (textureUnit >= m_state.textureUnits.size()) + throw std::runtime_error("unsupported texture unit #" + std::to_string(textureUnit)); + + auto& unit = m_state.textureUnits[textureUnit]; + if (unit.sampler != sampler) + { + if (!SetCurrentContext(this)) + throw std::runtime_error("failed to activate context"); + + glBindSampler(textureUnit, sampler); + unit.sampler = sampler; + } + } + void Context::BindTexture(TextureTarget target, GLuint texture) const { - if (!SetCurrentContext(this)) - throw std::runtime_error("failed to activate context"); + BindTexture(m_state.currentTextureUnit, target, texture); + } - if (m_state.boundTextures[UnderlyingCast(target)] != texture) + void Context::BindTexture(UInt32 textureUnit, TextureTarget target, GLuint texture) const + { + if (textureUnit >= m_state.textureUnits.size()) + throw std::runtime_error("unsupported texture unit #" + std::to_string(textureUnit)); + + auto& unit = m_state.textureUnits[textureUnit]; + if (unit.textureTargets[UnderlyingCast(target)] != texture) { + if (!SetCurrentContext(this)) + throw std::runtime_error("failed to activate context"); + + SetCurrentTextureUnit(textureUnit); + GLenum glTarget; switch (target) { @@ -54,7 +81,7 @@ namespace Nz::GL glBindTexture(glTarget, texture); - m_state.boundTextures[UnderlyingCast(target)] = texture; + unit.textureTargets[UnderlyingCast(target)] = texture; } } @@ -66,8 +93,6 @@ namespace Nz::GL return false; } - m_state.boundTextures.fill(0); - const Loader& loader = GetLoader(); auto LoadSymbol = [&](auto& func, const char* funcName, bool mandatory) @@ -118,6 +143,14 @@ namespace Nz::GL }); m_extensionStatus.fill(ExtensionStatus::NotSupported); + + // TextureFilterAnisotropic + if (m_supportedExtensions.count("GL_ARB_texture_filter_anisotropic")) + m_extensionStatus[UnderlyingCast(Extension::TextureFilterAnisotropic)] = ExtensionStatus::ARB; + else if (m_supportedExtensions.count("GL_EXT_texture_filter_anisotropic")) + m_extensionStatus[UnderlyingCast(Extension::TextureFilterAnisotropic)] = ExtensionStatus::EXT; + + // SpirV if (m_supportedExtensions.count("GL_ARB_gl_spirv")) m_extensionStatus[UnderlyingCast(Extension::SpirV)] = ExtensionStatus::ARB; @@ -162,6 +195,14 @@ namespace Nz::GL }, this); } + GLint maxTextureUnits = -1; + glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxTextureUnits); + if (maxTextureUnits < 32) //< OpenGL ES 3.0 requires at least 32 textures units + NazaraWarning("GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS is " + std::to_string(maxTextureUnits) + ", >= 32 expected"); + + assert(maxTextureUnits > 0); + m_state.textureUnits.resize(maxTextureUnits); + return true; } From 494801282db725b58d2ec5ab2d322558040de048 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 26 Apr 2020 16:29:39 +0200 Subject: [PATCH 172/316] Minor fixes --- include/Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp | 2 ++ include/Nazara/VulkanRenderer/VulkanTextureSampler.inl | 2 +- src/Nazara/VulkanRenderer/VulkanTextureSampler.cpp | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp b/include/Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp index 21e4f707a..8898ea174 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp @@ -148,6 +148,8 @@ typedef void (GL_APIENTRYP PFNGLSPECIALIZESHADERARBPROC) (GLuint shader, const G cb(glVertexAttribIPointer, PFNGLVERTEXATTRIBIPOINTERPROC) \ cb(glViewport, PFNGLVIEWPORTPROC) \ \ + extCb(glObjectLabel, PFNGLOBJECTLABELPROC) \ + \ extCb(glDebugMessageCallback, PFNGLDEBUGMESSAGECALLBACKPROC) \ \ extCb(glSpecializeShaderARB, PFNGLSPECIALIZESHADERARBPROC) \ diff --git a/include/Nazara/VulkanRenderer/VulkanTextureSampler.inl b/include/Nazara/VulkanRenderer/VulkanTextureSampler.inl index 710f4ee73..1f0be9bf5 100644 --- a/include/Nazara/VulkanRenderer/VulkanTextureSampler.inl +++ b/include/Nazara/VulkanRenderer/VulkanTextureSampler.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include namespace Nz diff --git a/src/Nazara/VulkanRenderer/VulkanTextureSampler.cpp b/src/Nazara/VulkanRenderer/VulkanTextureSampler.cpp index 053683bd4..2a9d44035 100644 --- a/src/Nazara/VulkanRenderer/VulkanTextureSampler.cpp +++ b/src/Nazara/VulkanRenderer/VulkanTextureSampler.cpp @@ -19,7 +19,7 @@ namespace Nz createInfo.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK; createInfo.mipmapMode = ToVulkan(samplerInfo.mipmapMode); - if (samplerInfo.anisotropyLevel > 0.f) + if (samplerInfo.anisotropyLevel > 1.f) { createInfo.anisotropyEnable = VK_TRUE; createInfo.maxAnisotropy = samplerInfo.anisotropyLevel; From 0b05feb7e388a94eb4eac1b599546dd0e2fa9ebc Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 26 Apr 2020 18:20:36 +0200 Subject: [PATCH 173/316] OpenGL: Implement buffers --- .../Nazara/OpenGLRenderer/OpenGLBuffer.hpp | 20 +-- .../Nazara/OpenGLRenderer/OpenGLBuffer.inl | 13 +- .../Nazara/OpenGLRenderer/OpenGLDevice.hpp | 3 +- .../Nazara/OpenGLRenderer/OpenGLDevice.inl | 10 +- include/Nazara/OpenGLRenderer/Utils.hpp | 2 + include/Nazara/OpenGLRenderer/Utils.inl | 32 ++++ .../Nazara/OpenGLRenderer/Wrapper/Buffer.hpp | 50 +++--- .../Nazara/OpenGLRenderer/Wrapper/Buffer.inl | 79 +++++----- .../Nazara/OpenGLRenderer/Wrapper/Context.hpp | 17 ++ .../Nazara/OpenGLRenderer/Wrapper/Context.inl | 9 ++ src/Nazara/OpenGLRenderer/OpenGLBuffer.cpp | 145 ++++++------------ src/Nazara/OpenGLRenderer/OpenGLDevice.cpp | 3 +- src/Nazara/OpenGLRenderer/Wrapper/Context.cpp | 39 ++--- 13 files changed, 213 insertions(+), 209 deletions(-) diff --git a/include/Nazara/OpenGLRenderer/OpenGLBuffer.hpp b/include/Nazara/OpenGLRenderer/OpenGLBuffer.hpp index a316d168c..c00ad0710 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLBuffer.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLBuffer.hpp @@ -10,9 +10,8 @@ #include #include #include +#include #include -#include -#include #include #include @@ -21,34 +20,31 @@ namespace Nz class NAZARA_OPENGLRENDERER_API OpenGLBuffer : public AbstractBuffer { public: - inline OpenGLBuffer(Vk::Device& device, BufferType type); + OpenGLBuffer(OpenGLDevice& device, BufferType type); OpenGLBuffer(const OpenGLBuffer&) = delete; - OpenGLBuffer(OpenGLBuffer&&) = delete; ///TODO - virtual ~OpenGLBuffer(); + OpenGLBuffer(OpenGLBuffer&&) = delete; + ~OpenGLBuffer() = default; bool Fill(const void* data, UInt64 offset, UInt64 size) override; bool Initialize(UInt64 size, BufferUsageFlags usage) override; - inline VkBuffer GetBuffer(); + inline const GL::Buffer& GetBuffer() const; UInt64 GetSize() const override; DataStorage GetStorage() const override; + inline BufferType GetType() const; void* Map(BufferAccess access, UInt64 offset, UInt64 size) override; bool Unmap() override; OpenGLBuffer& operator=(const OpenGLBuffer&) = delete; - OpenGLBuffer& operator=(OpenGLBuffer&&) = delete; ///TODO + OpenGLBuffer& operator=(OpenGLBuffer&&) = delete; private: + GL::Buffer m_buffer; BufferType m_type; BufferUsageFlags m_usage; UInt64 m_size; - VkBuffer m_buffer; - VkBuffer m_stagingBuffer; - VmaAllocation m_allocation; - VmaAllocation m_stagingAllocation; - Vk::Device& m_device; }; } diff --git a/include/Nazara/OpenGLRenderer/OpenGLBuffer.inl b/include/Nazara/OpenGLRenderer/OpenGLBuffer.inl index d17324fc6..321b71a9f 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLBuffer.inl +++ b/include/Nazara/OpenGLRenderer/OpenGLBuffer.inl @@ -7,16 +7,15 @@ namespace Nz { - inline OpenGLBuffer::OpenGLBuffer(Vk::Device& device, BufferType type) : - m_device(device), - m_type(type) - { - } - - inline VkBuffer OpenGLBuffer::GetBuffer() + inline const GL::Buffer& OpenGLBuffer::GetBuffer() const { return m_buffer; } + + inline BufferType OpenGLBuffer::GetType() const + { + return m_type; + } } #include diff --git a/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp b/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp index 6d30b56be..52effa121 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp @@ -40,7 +40,8 @@ namespace Nz std::unique_ptr InstantiateTexture(const TextureInfo& params) override; std::unique_ptr InstantiateTextureSampler(const TextureSamplerInfo& params) override; - inline void NotifySamplerDestruction(GLuint texture) const; + inline void NotifyBufferDestruction(GLuint buffer) const; + inline void NotifySamplerDestruction(GLuint sampler) const; inline void NotifyTextureDestruction(GLuint texture) const; OpenGLDevice& operator=(const OpenGLDevice&) = delete; diff --git a/include/Nazara/OpenGLRenderer/OpenGLDevice.inl b/include/Nazara/OpenGLRenderer/OpenGLDevice.inl index 98208b40e..66219abc5 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLDevice.inl +++ b/include/Nazara/OpenGLRenderer/OpenGLDevice.inl @@ -12,10 +12,16 @@ namespace Nz return *m_referenceContext; } - inline void OpenGLDevice::NotifySamplerDestruction(GLuint texture) const + inline void OpenGLDevice::NotifyBufferDestruction(GLuint buffer) const { for (const GL::Context* context : m_contexts) - context->NotifySamplerDestruction(texture); + context->NotifyBufferDestruction(buffer); + } + + inline void OpenGLDevice::NotifySamplerDestruction(GLuint sampler) const + { + for (const GL::Context* context : m_contexts) + context->NotifySamplerDestruction(sampler); } inline void OpenGLDevice::NotifyTextureDestruction(GLuint texture) const diff --git a/include/Nazara/OpenGLRenderer/Utils.hpp b/include/Nazara/OpenGLRenderer/Utils.hpp index b7f4c4200..593c59f9a 100644 --- a/include/Nazara/OpenGLRenderer/Utils.hpp +++ b/include/Nazara/OpenGLRenderer/Utils.hpp @@ -20,6 +20,8 @@ namespace Nz inline GLenum ToOpenGL(SamplerFilter minFilter, SamplerMipmapMode mipmapFilter); inline GLenum ToOpenGL(SamplerWrap wrapMode); inline GLenum ToOpenGL(ShaderStageType stageType); + inline GLenum ToOpenGL(GL::BufferTarget bufferTarget); + inline GLenum ToOpenGL(GL::TextureTarget bufferTarget); //NAZARA_OPENGLRENDERER_API std::string TranslateOpenGLError(GLenum code); } diff --git a/include/Nazara/OpenGLRenderer/Utils.inl b/include/Nazara/OpenGLRenderer/Utils.inl index 279648237..890b2f88e 100644 --- a/include/Nazara/OpenGLRenderer/Utils.inl +++ b/include/Nazara/OpenGLRenderer/Utils.inl @@ -79,6 +79,38 @@ namespace Nz NazaraError("Unhandled ShaderStageType 0x" + String::Number(UnderlyingCast(stageType), 16)); return {}; } + + GLenum ToOpenGL(GL::BufferTarget bufferTarget) + { + switch (bufferTarget) + { + case GL::BufferTarget::Array: return GL_ARRAY_BUFFER; + case GL::BufferTarget::CopyRead: return GL_COPY_READ_BUFFER; + case GL::BufferTarget::CopyWrite: return GL_COPY_WRITE_BUFFER; + case GL::BufferTarget::ElementArray: return GL_ELEMENT_ARRAY_BUFFER; + case GL::BufferTarget::PixelPack: return GL_PIXEL_PACK_BUFFER; + case GL::BufferTarget::PixelUnpack: return GL_PIXEL_UNPACK_BUFFER; + case GL::BufferTarget::TransformFeedback: return GL_TRANSFORM_FEEDBACK_BUFFER; + case GL::BufferTarget::Uniform: return GL_UNIFORM_BUFFER; + } + + NazaraError("Unhandled GL::BufferTarget 0x" + String::Number(UnderlyingCast(bufferTarget), 16)); + return {}; + } + + GLenum ToOpenGL(GL::TextureTarget textureTarget) + { + switch (textureTarget) + { + case GL::TextureTarget::Cubemap: return GL_TEXTURE_CUBE_MAP; + case GL::TextureTarget::Target2D: return GL_TEXTURE_2D; + case GL::TextureTarget::Target2D_Array: return GL_TEXTURE_2D_ARRAY; + case GL::TextureTarget::Target3D: return GL_TEXTURE_3D; + } + + NazaraError("Unhandled GL::TextureTarget 0x" + String::Number(UnderlyingCast(textureTarget), 16)); + return {}; + } } #include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Buffer.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Buffer.hpp index fbe051ec4..34e897bf9 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Buffer.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Buffer.hpp @@ -4,43 +4,45 @@ #pragma once -#ifndef NAZARA_OPENGLRENDERER_VKBUFFER_HPP -#define NAZARA_OPENGLRENDERER_VKBUFFER_HPP +#ifndef NAZARA_OPENGLRENDERER_GLBUFFER_HPP +#define NAZARA_OPENGLRENDERER_GLBUFFER_HPP #include +#include +#include #include -namespace Nz +namespace Nz::GL { - namespace Vk + class Buffer : public DeviceObject { - class Buffer : public DeviceObject - { - friend DeviceObject; + friend DeviceObject; - public: - Buffer() = default; - Buffer(const Buffer&) = delete; - Buffer(Buffer&&) noexcept = default; - ~Buffer() = default; + public: + Buffer() = default; + Buffer(const Buffer&) = delete; + Buffer(Buffer&&) noexcept = default; + ~Buffer() = default; - bool BindBufferMemory(VkDeviceMemory memory, VkDeviceSize offset = 0); + inline void* MapRange(GLintptr offset, GLsizeiptr length, GLbitfield access); - using DeviceObject::Create; - inline bool Create(Device& device, VkBufferCreateFlags flags, VkDeviceSize size, VkBufferUsageFlags usage, const VkAllocationCallbacks* allocator = nullptr); + inline void Reset(BufferTarget target, GLsizeiptr size, const void* initialData, GLenum usage); - VkMemoryRequirements GetMemoryRequirements() const; + inline void SubData(GLintptr offset, GLsizeiptr size, const void* data); - Buffer& operator=(const Buffer&) = delete; - Buffer& operator=(Buffer&&) = delete; + inline bool Unmap(); - private: - static inline VkResult CreateHelper(Device& device, const VkBufferCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkBuffer* handle); - static inline void DestroyHelper(Device& device, VkBuffer handle, const VkAllocationCallbacks* allocator); - }; - } + Buffer& operator=(const Buffer&) = delete; + Buffer& operator=(Buffer&&) noexcept = default; + + private: + static inline GLuint CreateHelper(OpenGLDevice& device, const Context& context); + static inline void DestroyHelper(OpenGLDevice& device, const Context& context, GLuint objectId); + + BufferTarget m_target; + }; } #include -#endif // NAZARA_OPENGLRENDERER_VKBUFFER_HPP +#endif diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Buffer.inl b/include/Nazara/OpenGLRenderer/Wrapper/Buffer.inl index 4914aa317..943369d0e 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Buffer.inl +++ b/include/Nazara/OpenGLRenderer/Wrapper/Buffer.inl @@ -5,57 +5,54 @@ #include #include -namespace Nz +namespace Nz::GL { - namespace Vk + inline void* Buffer::MapRange(GLintptr offset, GLsizeiptr length, GLbitfield access) { - inline bool Buffer::BindBufferMemory(VkDeviceMemory memory, VkDeviceSize offset) - { - m_lastErrorCode = m_device->vkBindBufferMemory(*m_device, m_handle, memory, offset); - if (m_lastErrorCode != VK_SUCCESS) - { - NazaraError("Failed to bind buffer memory"); - return false; - } + const Context& context = EnsureDeviceContext(); + context.BindBuffer(m_target, m_objectId); + return context.glMapBufferRange(ToOpenGL(m_target), offset, length, access); + } - return true; - } + inline void Buffer::Reset(BufferTarget target, GLsizeiptr size, const void* initialData, GLenum usage) + { + m_target = target; - inline bool Buffer::Create(Device& device, VkBufferCreateFlags flags, VkDeviceSize size, VkBufferUsageFlags usage, const VkAllocationCallbacks* allocator) - { - VkBufferCreateInfo createInfo = { - VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // VkStructureType sType; - nullptr, // const void* pNext; - flags, // VkBufferCreateFlags flags; - size, // VkDeviceSize size; - usage, // VkBufferUsageFlags usage; - VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode; - 0, // uint32_t queueFamilyIndexCount; - nullptr // const uint32_t* pQueueFamilyIndices; - }; + const Context& context = EnsureDeviceContext(); - return Create(device, createInfo, allocator); - } + context.BindBuffer(m_target, m_objectId); - inline VkMemoryRequirements Buffer::GetMemoryRequirements() const - { - NazaraAssert(IsValid(), "Invalid buffer"); + context.glBufferData(ToOpenGL(m_target), size, initialData, usage); + } - VkMemoryRequirements memoryRequirements; - m_device->vkGetBufferMemoryRequirements(*m_device, m_handle, &memoryRequirements); + inline void Buffer::SubData(GLintptr offset, GLsizeiptr size, const void* data) + { + const Context& context = EnsureDeviceContext(); + context.BindBuffer(m_target, m_objectId); - return memoryRequirements; - } + context.glBufferSubData(ToOpenGL(m_target), offset, size, data); + } - inline VkResult Buffer::CreateHelper(Device& device, const VkBufferCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkBuffer* handle) - { - return device.vkCreateBuffer(device, createInfo, allocator, handle); - } + inline bool Buffer::Unmap() + { + const Context& context = EnsureDeviceContext(); + context.BindBuffer(m_target, m_objectId); + return context.glUnmapBuffer(ToOpenGL(m_target)) == GL_TRUE; + } - inline void Buffer::DestroyHelper(Device& device, VkBuffer handle, const VkAllocationCallbacks* allocator) - { - return device.vkDestroyBuffer(device, handle, allocator); - } + inline GLuint Buffer::CreateHelper(OpenGLDevice& device, const Context& context) + { + GLuint sampler = 0; + context.glGenBuffers(1U, &sampler); + + return sampler; + } + + inline void Buffer::DestroyHelper(OpenGLDevice& device, const Context& context, GLuint objectId) + { + context.glDeleteBuffers(1U, &objectId); + + device.NotifyBufferDestruction(objectId); } } diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp index d24d56650..50eea5c7b 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp @@ -21,6 +21,20 @@ namespace Nz namespace Nz::GL { + enum class BufferTarget + { + Array, + CopyRead, + CopyWrite, + ElementArray, + PixelPack, + PixelUnpack, + TransformFeedback, + Uniform, + + Max = Uniform + }; + enum class ContextType { OpenGL, @@ -74,6 +88,7 @@ namespace Nz::GL inline Context(const OpenGLDevice* device); virtual ~Context(); + void BindBuffer(BufferTarget target, GLuint buffer) const; void BindSampler(UInt32 textureUnit, GLuint sampler) const; void BindTexture(TextureTarget target, GLuint texture) const; void BindTexture(UInt32 textureUnit, TextureTarget target, GLuint texture) const; @@ -89,6 +104,7 @@ namespace Nz::GL bool Initialize(const ContextParams& params); + inline void NotifyBufferDestruction(GLuint buffer) const; inline void NotifySamplerDestruction(GLuint sampler) const; inline void NotifyTextureDestruction(GLuint texture) const; @@ -125,6 +141,7 @@ namespace Nz::GL std::array textureTargets = { 0 }; }; + std::array bufferTargets = { 0 }; std::vector textureUnits; UInt32 currentTextureUnit = 0; }; diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Context.inl b/include/Nazara/OpenGLRenderer/Wrapper/Context.inl index 88429dd1d..b7d5139a2 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Context.inl +++ b/include/Nazara/OpenGLRenderer/Wrapper/Context.inl @@ -37,6 +37,15 @@ namespace Nz::GL return m_supportedExtensions.find(extension) != m_supportedExtensions.end(); } + inline void Context::NotifyBufferDestruction(GLuint buffer) const + { + for (GLuint& boundBuffer : m_state.bufferTargets) + { + if (boundBuffer == buffer) + boundBuffer = 0; + } + } + inline void Context::NotifySamplerDestruction(GLuint sampler) const { for (auto& unit : m_state.textureUnits) diff --git a/src/Nazara/OpenGLRenderer/OpenGLBuffer.cpp b/src/Nazara/OpenGLRenderer/OpenGLBuffer.cpp index f77ab4635..66b546c8a 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLBuffer.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLBuffer.cpp @@ -2,33 +2,25 @@ // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#if 0 - #include #include #include -#include -#include -#include +#include #include namespace Nz { - OpenGLBuffer::~OpenGLBuffer() + + OpenGLBuffer::OpenGLBuffer(OpenGLDevice& device, BufferType type) : + m_type(type) { - vmaDestroyBuffer(m_device.GetMemoryAllocator(), m_buffer, m_allocation); + if (!m_buffer.Create(device)) + throw std::runtime_error("failed to create buffer"); //< TODO: Handle error } bool OpenGLBuffer::Fill(const void* data, UInt64 offset, UInt64 size) { - void* ptr = Map(BufferAccess_WriteOnly, offset, size); - if (!ptr) - return false; - - Nz::CallOnExit unmapOnExit([this]() { Unmap(); }); - - std::memcpy(ptr, data, size); - + m_buffer.SubData(offset, size, data); return true; } @@ -37,37 +29,26 @@ namespace Nz m_size = size; m_usage = usage; - VkBufferUsageFlags bufferUsage = ToOpenGL(m_type); + GL::BufferTarget target; + switch (m_type) + { + case BufferType_Index: target = GL::BufferTarget::ElementArray; break; + case BufferType_Uniform: target = GL::BufferTarget::Uniform; break; + case BufferType_Vertex: target = GL::BufferTarget::Array; break; - if ((usage & BufferUsage_DirectMapping) == 0) - bufferUsage |= VK_BUFFER_USAGE_TRANSFER_DST_BIT; + default: + throw std::runtime_error("unknown buffer type 0x" + String::Number(UnderlyingCast(m_type), 16).ToStdString()); + } - VkBufferCreateInfo createInfo = {}; - createInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; - createInfo.size = size; - createInfo.usage = bufferUsage; + GLenum hint = GL_STREAM_COPY; - VmaAllocationCreateInfo allocInfo = {}; if (usage & BufferUsage_DeviceLocal) - { - if (usage & BufferUsage_DirectMapping) - allocInfo.usage = VMA_MEMORY_USAGE_CPU_TO_GPU; - else - allocInfo.usage = VMA_MEMORY_USAGE_GPU_ONLY; - } - else - allocInfo.usage = VMA_MEMORY_USAGE_CPU_ONLY; + hint = GL_STATIC_DRAW; - if (usage & BufferUsage_PersistentMapping) - allocInfo.flags |= VMA_ALLOCATION_CREATE_MAPPED_BIT; - - VkResult result = vmaCreateBuffer(m_device.GetMemoryAllocator(), &createInfo, &allocInfo, &m_buffer, &m_allocation, nullptr); - if (result != VK_SUCCESS) - { - NazaraError("Failed to allocate buffer: " + TranslateOpenGLError(result)); - return false; - } + if (usage & BufferUsage_DirectMapping) + hint = GL_DYNAMIC_COPY; + m_buffer.Reset(target, size, nullptr, hint); return true; } @@ -81,71 +62,41 @@ namespace Nz return DataStorage_Hardware; } - void* OpenGLBuffer::Map(BufferAccess /*access*/, UInt64 offset, UInt64 size) + void* OpenGLBuffer::Map(BufferAccess access, UInt64 offset, UInt64 size) { - if (m_usage & BufferUsage_DirectMapping) + GLbitfield accessBit = 0; + switch (access) { - void* mappedPtr; - VkResult result = vmaMapMemory(m_device.GetMemoryAllocator(), m_allocation, &mappedPtr); - if (result != VK_SUCCESS) - { - NazaraError("Failed to map buffer: " + TranslateOpenGLError(result)); - return nullptr; - } + case BufferAccess_DiscardAndWrite: + accessBit |= GL_MAP_WRITE_BIT; + if (offset == 0 && size == m_size) + accessBit |= GL_MAP_INVALIDATE_BUFFER_BIT; + else + accessBit |= GL_MAP_INVALIDATE_RANGE_BIT; - return static_cast(mappedPtr) + offset; + break; + + case BufferAccess_ReadOnly: + accessBit |= GL_MAP_READ_BIT; + break; + + case BufferAccess_ReadWrite: + accessBit |= GL_MAP_READ_BIT | GL_MAP_WRITE_BIT; + break; + + case BufferAccess_WriteOnly: + accessBit |= GL_MAP_WRITE_BIT; + break; + + default: + break; } - else - { - VkBufferCreateInfo createInfo = {}; - createInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; - createInfo.size = size; - createInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT; - VmaAllocationCreateInfo allocInfo = {}; - allocInfo.flags = VMA_ALLOCATION_CREATE_MAPPED_BIT; - allocInfo.usage = VMA_MEMORY_USAGE_CPU_TO_GPU; - - VmaAllocationInfo allocationInfo; - - VkResult result = vmaCreateBuffer(m_device.GetMemoryAllocator(), &createInfo, &allocInfo, &m_stagingBuffer, &m_stagingAllocation, &allocationInfo); - if (result != VK_SUCCESS) - { - NazaraError("Failed to allocate staging buffer: " + TranslateOpenGLError(result)); - return nullptr; - } - - return allocationInfo.pMappedData; - } + return m_buffer.MapRange(offset, size, accessBit); } bool OpenGLBuffer::Unmap() { - if (m_usage & BufferUsage_DirectMapping) - { - vmaUnmapMemory(m_device.GetMemoryAllocator(), m_allocation); - return true; - } - else - { - Vk::AutoCommandBuffer copyCommandBuffer = m_device.AllocateCommandBuffer(QueueType::Transfer); - if (!copyCommandBuffer->Begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT)) - return false; - - copyCommandBuffer->CopyBuffer(m_stagingBuffer, m_buffer, m_size); - if (!copyCommandBuffer->End()) - return false; - - Vk::QueueHandle transferQueue = m_device.GetQueue(m_device.GetDefaultFamilyIndex(QueueType::Transfer), 0); - if (!transferQueue.Submit(copyCommandBuffer)) - return false; - - transferQueue.WaitIdle(); - - vmaDestroyBuffer(m_device.GetMemoryAllocator(), m_stagingBuffer, m_stagingAllocation); - return true; - } + return m_buffer.Unmap(); } } - -#endif diff --git a/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp b/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp index 706396e15..afe768ef3 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -42,7 +43,7 @@ namespace Nz std::unique_ptr OpenGLDevice::InstantiateBuffer(BufferType type) { - return {}; + return std::make_unique(*this, type); } std::unique_ptr OpenGLDevice::InstantiateCommandPool(QueueType queueType) diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp index c4333e90f..e1240d365 100644 --- a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp +++ b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -22,6 +23,19 @@ namespace Nz::GL m_device->NotifyContextDestruction(*this); } + void Context::BindBuffer(BufferTarget target, GLuint buffer) const + { + if (m_state.bufferTargets[UnderlyingCast(target)] != buffer) + { + if (!SetCurrentContext(this)) + throw std::runtime_error("failed to activate context"); + + glBindBuffer(ToOpenGL(target), buffer); + + m_state.bufferTargets[UnderlyingCast(target)] = buffer; + } + } + void Context::BindSampler(UInt32 textureUnit, GLuint sampler) const { if (textureUnit >= m_state.textureUnits.size()) @@ -56,30 +70,7 @@ namespace Nz::GL SetCurrentTextureUnit(textureUnit); - GLenum glTarget; - switch (target) - { - case TextureTarget::Cubemap: - glTarget = GL_TEXTURE_CUBE_MAP; - break; - - case TextureTarget::Target2D: - glTarget = GL_TEXTURE_2D; - break; - - case TextureTarget::Target2D_Array: - glTarget = GL_TEXTURE_2D_ARRAY; - break; - - case TextureTarget::Target3D: - glTarget = GL_TEXTURE_3D; - break; - - default: - break; - } - - glBindTexture(glTarget, texture); + glBindTexture(ToOpenGL(target), texture); unit.textureTargets[UnderlyingCast(target)] = texture; } From 32157503e8f864662e55bbaf5bd971621ae1cb54 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 26 Apr 2020 18:21:38 +0200 Subject: [PATCH 174/316] OpenGL: Implement RenderPipelineLayout --- .../OpenGLRenderPipelineLayout.hpp | 44 ++++++--- .../OpenGLRenderPipelineLayout.inl | 12 +-- .../OpenGLRenderer/OpenGLShaderBinding.hpp | 6 +- .../OpenGLRenderer/OpenGLShaderBinding.inl | 8 +- .../Nazara/OpenGLRenderer/OpenGLTexture.hpp | 1 + .../Nazara/OpenGLRenderer/OpenGLTexture.inl | 4 + src/Nazara/OpenGLRenderer/OpenGLDevice.cpp | 3 +- .../OpenGLRenderPipelineLayout.cpp | 95 +++++++++---------- .../OpenGLRenderer/OpenGLShaderBinding.cpp | 73 +++++++------- 9 files changed, 127 insertions(+), 119 deletions(-) diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.hpp b/include/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.hpp index 272a3fd22..2107d9379 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.hpp @@ -12,11 +12,7 @@ #include #include #include -#include -#include -#include -#include -#include +#include #include #include #include @@ -28,39 +24,59 @@ namespace Nz friend OpenGLShaderBinding; public: - OpenGLRenderPipelineLayout() = default; + OpenGLRenderPipelineLayout(RenderPipelineLayoutInfo layoutInfo); + OpenGLRenderPipelineLayout(const OpenGLRenderPipelineLayout&) = delete; + OpenGLRenderPipelineLayout(OpenGLRenderPipelineLayout&&) = delete; ~OpenGLRenderPipelineLayout(); ShaderBindingPtr AllocateShaderBinding() override; - bool Create(Vk::Device& device, RenderPipelineLayoutInfo layoutInfo); + inline const RenderPipelineLayoutInfo& GetLayoutInfo() const; - inline Vk::Device* GetDevice() const; + inline std::size_t GetTextureDescriptorCount() const; + inline std::size_t GetUniformBufferDescriptorCount() const; - inline const Vk::DescriptorSetLayout& GetDescriptorSetLayout() const; - inline const Vk::PipelineLayout& GetPipelineLayout() const; + OpenGLRenderPipelineLayout& operator=(const OpenGLRenderPipelineLayout&) = delete; + OpenGLRenderPipelineLayout& operator=(OpenGLRenderPipelineLayout&&) = delete; private: struct DescriptorPool; + struct TextureDescriptor; + struct UniformBufferDescriptor; DescriptorPool& AllocatePool(); ShaderBindingPtr AllocateFromPool(std::size_t poolIndex); + TextureDescriptor& GetTextureDescriptor(std::size_t poolIndex, std::size_t bindingIndex, std::size_t textureIndex); + UniformBufferDescriptor& GetUniformBufferDescriptor(std::size_t poolIndex, std::size_t bindingIndex, std::size_t uniformBufferIndex); void Release(ShaderBinding& binding); inline void TryToShrink(); + struct TextureDescriptor + { + GLuint texture; + GLuint sampler; + }; + + struct UniformBufferDescriptor + { + GLuint buffer; + GLintptr offset; + GLsizeiptr size; + }; + struct DescriptorPool { using BindingStorage = std::aligned_storage_t; Bitset freeBindings; - Vk::DescriptorPool descriptorPool; + std::vector textureDescriptor; + std::vector uniformBufferDescriptor; std::unique_ptr storage; }; - MovablePtr m_device; + std::size_t m_textureDescriptorCount; + std::size_t m_uniformBufferDescriptorCount; std::vector m_descriptorPools; - Vk::DescriptorSetLayout m_descriptorSetLayout; - Vk::PipelineLayout m_pipelineLayout; RenderPipelineLayoutInfo m_layoutInfo; }; } diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.inl b/include/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.inl index d4ca1e74d..a5646b1d9 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.inl +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.inl @@ -7,19 +7,19 @@ namespace Nz { - inline Vk::Device* OpenGLRenderPipelineLayout::GetDevice() const + inline const RenderPipelineLayoutInfo& OpenGLRenderPipelineLayout::GetLayoutInfo() const { - return m_device.Get(); + return m_layoutInfo; } - inline const Vk::DescriptorSetLayout& OpenGLRenderPipelineLayout::GetDescriptorSetLayout() const + inline std::size_t OpenGLRenderPipelineLayout::GetTextureDescriptorCount() const { - return m_descriptorSetLayout; + return m_textureDescriptorCount; } - inline const Vk::PipelineLayout& OpenGLRenderPipelineLayout::GetPipelineLayout() const + inline std::size_t OpenGLRenderPipelineLayout::GetUniformBufferDescriptorCount() const { - return m_pipelineLayout; + return m_uniformBufferDescriptorCount; } inline void OpenGLRenderPipelineLayout::TryToShrink() diff --git a/include/Nazara/OpenGLRenderer/OpenGLShaderBinding.hpp b/include/Nazara/OpenGLRenderer/OpenGLShaderBinding.hpp index 395570ddd..d920c2929 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLShaderBinding.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLShaderBinding.hpp @@ -8,8 +8,8 @@ #define NAZARA_OPENGLRENDERER_OPENGLSHADERBINDING_HPP #include +#include #include -#include namespace Nz { @@ -18,13 +18,12 @@ namespace Nz class NAZARA_OPENGLRENDERER_API OpenGLShaderBinding : public ShaderBinding { public: - inline OpenGLShaderBinding(OpenGLRenderPipelineLayout& owner, std::size_t poolIndex, std::size_t bindingIndex, Vk::DescriptorSet descriptorSet); + inline OpenGLShaderBinding(OpenGLRenderPipelineLayout& owner, std::size_t poolIndex, std::size_t bindingIndex); OpenGLShaderBinding(const OpenGLShaderBinding&) = default; OpenGLShaderBinding(OpenGLShaderBinding&&) noexcept = default; ~OpenGLShaderBinding() = default; inline std::size_t GetBindingIndex() const; - inline const Vk::DescriptorSet& GetDescriptorSet() const; inline std::size_t GetPoolIndex() const; inline const OpenGLRenderPipelineLayout& GetOwner() const; @@ -36,7 +35,6 @@ namespace Nz private: void Release() override; - Vk::AutoDescriptorSet m_descriptorSet; OpenGLRenderPipelineLayout& m_owner; std::size_t m_bindingIndex; std::size_t m_poolIndex; diff --git a/include/Nazara/OpenGLRenderer/OpenGLShaderBinding.inl b/include/Nazara/OpenGLRenderer/OpenGLShaderBinding.inl index 8520a13b3..f823e2ffc 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLShaderBinding.inl +++ b/include/Nazara/OpenGLRenderer/OpenGLShaderBinding.inl @@ -7,8 +7,7 @@ namespace Nz { - inline OpenGLShaderBinding::OpenGLShaderBinding(OpenGLRenderPipelineLayout& owner, std::size_t poolIndex, std::size_t bindingIndex, Vk::DescriptorSet descriptorSet) : - m_descriptorSet(std::move(descriptorSet)), + inline OpenGLShaderBinding::OpenGLShaderBinding(OpenGLRenderPipelineLayout& owner, std::size_t poolIndex, std::size_t bindingIndex) : m_owner(owner), m_bindingIndex(bindingIndex), m_poolIndex(poolIndex) @@ -25,11 +24,6 @@ namespace Nz return m_poolIndex; } - inline const Vk::DescriptorSet& OpenGLShaderBinding::GetDescriptorSet() const - { - return m_descriptorSet; - } - inline const OpenGLRenderPipelineLayout& OpenGLShaderBinding::GetOwner() const { return m_owner; diff --git a/include/Nazara/OpenGLRenderer/OpenGLTexture.hpp b/include/Nazara/OpenGLRenderer/OpenGLTexture.hpp index d4552823c..47a60b42a 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLTexture.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLTexture.hpp @@ -26,6 +26,7 @@ namespace Nz PixelFormat GetFormat() const override; UInt8 GetLevelCount() const override; Vector3ui GetSize(UInt8 level = 0) const override; + inline const GL::Texture& GetTexture() const; ImageType GetType() const override; bool Update(const void* ptr) override; diff --git a/include/Nazara/OpenGLRenderer/OpenGLTexture.inl b/include/Nazara/OpenGLRenderer/OpenGLTexture.inl index 227f8c478..a9c2cfec4 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLTexture.inl +++ b/include/Nazara/OpenGLRenderer/OpenGLTexture.inl @@ -7,6 +7,10 @@ namespace Nz { + inline const GL::Texture& OpenGLTexture::GetTexture() const + { + return m_texture; + } } #include diff --git a/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp b/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp index afe768ef3..19ebfd99c 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -58,7 +59,7 @@ namespace Nz std::shared_ptr OpenGLDevice::InstantiateRenderPipelineLayout(RenderPipelineLayoutInfo pipelineLayoutInfo) { - return {}; + return std::make_shared(std::move(pipelineLayoutInfo)); } std::shared_ptr OpenGLDevice::InstantiateShaderStage(ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) diff --git a/src/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.cpp b/src/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.cpp index a0c8b8c05..4ab8d0c06 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.cpp @@ -2,8 +2,6 @@ // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#if 0 - #include #include #include @@ -15,6 +13,29 @@ namespace Nz { + OpenGLRenderPipelineLayout::OpenGLRenderPipelineLayout(RenderPipelineLayoutInfo layoutInfo) : + m_textureDescriptorCount(0), + m_uniformBufferDescriptorCount(0), + m_layoutInfo(std::move(layoutInfo)) + { + for (const auto& bindingInfo : m_layoutInfo.bindings) + { + switch (bindingInfo.type) + { + case ShaderBindingType::Texture: + m_textureDescriptorCount++; + break; + + case ShaderBindingType::UniformBuffer: + m_uniformBufferDescriptorCount++; + break; + + default: + throw std::runtime_error(("unknown binding type 0x" + String::Number(UnderlyingCast(bindingInfo.type), 16)).ToStdString()); + } + } + } + OpenGLRenderPipelineLayout::~OpenGLRenderPipelineLayout() { for (auto& pool : m_descriptorPools) @@ -46,50 +67,15 @@ namespace Nz return bindingPtr; } - bool OpenGLRenderPipelineLayout::Create(Vk::Device& device, RenderPipelineLayoutInfo layoutInfo) - { - m_device = &device; - m_layoutInfo = std::move(layoutInfo); - - StackVector layoutBindings = NazaraStackVector(VkDescriptorSetLayoutBinding, m_layoutInfo.bindings.size()); - - for (const auto& bindingInfo : m_layoutInfo.bindings) - { - VkDescriptorSetLayoutBinding& layoutBinding = layoutBindings.emplace_back(); - layoutBinding.binding = bindingInfo.index; - layoutBinding.descriptorCount = 1U; - layoutBinding.descriptorType = ToOpenGL(bindingInfo.type); - layoutBinding.stageFlags = ToOpenGL(bindingInfo.shaderStageFlags); - } - - if (!m_descriptorSetLayout.Create(*m_device, UInt32(layoutBindings.size()), layoutBindings.data())) - return false; - - if (!m_pipelineLayout.Create(*m_device, m_descriptorSetLayout)) - return false; - - return true; - } - auto OpenGLRenderPipelineLayout::AllocatePool() -> DescriptorPool& { - StackVector poolSizes = NazaraStackVector(VkDescriptorPoolSize, m_layoutInfo.bindings.size()); - constexpr UInt32 MaxSet = 128; - for (const auto& bindingInfo : m_layoutInfo.bindings) - { - VkDescriptorPoolSize& poolSize = poolSizes.emplace_back(); - poolSize.descriptorCount = MaxSet; - poolSize.type = ToOpenGL(bindingInfo.type); - } - DescriptorPool pool; - if (!pool.descriptorPool.Create(*m_device, MaxSet, UInt32(poolSizes.size()), poolSizes.data(), VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT)) - throw std::runtime_error("Failed to allocate new descriptor pool: " + TranslateOpenGLError(pool.descriptorPool.GetLastErrorCode())); - pool.freeBindings.Resize(MaxSet, true); pool.storage = std::make_unique(MaxSet); + pool.textureDescriptor.resize(m_textureDescriptorCount * MaxSet); + pool.uniformBufferDescriptor.resize(m_uniformBufferDescriptorCount * MaxSet); return m_descriptorPools.emplace_back(std::move(pool)); } @@ -102,17 +88,30 @@ namespace Nz if (freeBindingId == pool.freeBindings.npos) return {}; //< No free binding in this pool - Vk::DescriptorSet descriptorSet = pool.descriptorPool.AllocateDescriptorSet(m_descriptorSetLayout); - if (!descriptorSet) - { - NazaraWarning("Failed to allocate descriptor set: " + TranslateOpenGLError(pool.descriptorPool.GetLastErrorCode())); - return {}; - } - pool.freeBindings.Reset(freeBindingId); OpenGLShaderBinding* freeBindingMemory = reinterpret_cast(&pool.storage[freeBindingId]); - return ShaderBindingPtr(PlacementNew(freeBindingMemory, *this, poolIndex, freeBindingId, std::move(descriptorSet))); + return ShaderBindingPtr(PlacementNew(freeBindingMemory, *this, poolIndex, freeBindingId)); + } + + auto OpenGLRenderPipelineLayout::GetTextureDescriptor(std::size_t poolIndex, std::size_t bindingIndex, std::size_t textureIndex) -> TextureDescriptor& + { + assert(poolIndex < m_descriptorPools.size()); + auto& pool = m_descriptorPools[poolIndex]; + assert(!pool.freeBindings.Test(bindingIndex)); + assert(textureIndex < m_textureDescriptorCount); + + return pool.textureDescriptor[bindingIndex * m_textureDescriptorCount + textureIndex]; + } + + auto OpenGLRenderPipelineLayout::GetUniformBufferDescriptor(std::size_t poolIndex, std::size_t bindingIndex, std::size_t uniformBufferIndex) -> UniformBufferDescriptor& + { + assert(poolIndex < m_descriptorPools.size()); + auto& pool = m_descriptorPools[poolIndex]; + assert(!pool.freeBindings.Test(bindingIndex)); + assert(uniformBufferIndex < m_uniformBufferDescriptorCount); + + return pool.uniformBufferDescriptor[bindingIndex * m_uniformBufferDescriptorCount + uniformBufferIndex]; } void OpenGLRenderPipelineLayout::Release(ShaderBinding& binding) @@ -136,5 +135,3 @@ namespace Nz TryToShrink(); } } - -#endif diff --git a/src/Nazara/OpenGLRenderer/OpenGLShaderBinding.cpp b/src/Nazara/OpenGLRenderer/OpenGLShaderBinding.cpp index 3a24e0fb1..8a36d9c97 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLShaderBinding.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLShaderBinding.cpp @@ -2,8 +2,6 @@ // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#if 0 - #include #include #include @@ -17,57 +15,58 @@ namespace Nz { void OpenGLShaderBinding::Update(std::initializer_list bindings) { - StackVector bufferBinding = NazaraStackVector(VkDescriptorBufferInfo, bindings.size()); - StackVector imageBinding = NazaraStackVector(VkDescriptorImageInfo, bindings.size()); - StackVector writeOps = NazaraStackVector(VkWriteDescriptorSet, bindings.size()); + const auto& layoutInfo = m_owner.GetLayoutInfo(); for (const Binding& binding : bindings) { - VkWriteDescriptorSet& writeOp = writeOps.emplace_back(); - writeOp.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; - writeOp.dstSet = m_descriptorSet; - writeOp.dstBinding = UInt32(binding.bindingIndex); + assert(binding.bindingIndex < layoutInfo.bindings.size()); + const auto& bindingDesc = layoutInfo.bindings[binding.bindingIndex]; - std::visit([&](auto&& arg) + std::size_t resourceIndex = 0; + for (std::size_t i = binding.bindingIndex; i > 0; --i) { - using T = std::decay_t; + // Use i-1 to prevent underflow in for loop + if (layoutInfo.bindings[i - 1].type == bindingDesc.type) + resourceIndex++; + } - if constexpr (std::is_same_v) + switch (bindingDesc.type) + { + case ShaderBindingType::Texture: { - OpenGLTexture& vkTexture = *static_cast(arg.texture); - OpenGLTextureSampler& vkSampler = *static_cast(arg.sampler); + if (!std::holds_alternative(binding.content)) + throw std::runtime_error("binding #" + std::to_string(binding.bindingIndex) + " is a texture but another binding type has been supplied"); - VkDescriptorImageInfo& imageInfo = imageBinding.emplace_back(); - imageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; - imageInfo.imageView = vkTexture.GetImageView(); - imageInfo.sampler = vkSampler.GetSampler(); + const TextureBinding& texBinding = std::get(binding.content); - writeOp.descriptorCount = 1; - writeOp.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; + OpenGLTexture& glTexture = *static_cast(texBinding.texture); + OpenGLTextureSampler& glSampler = *static_cast(texBinding.sampler); - writeOp.pImageInfo = &imageInfo; + auto& textureDescriptor = m_owner.GetTextureDescriptor(m_poolIndex, m_bindingIndex, resourceIndex); + textureDescriptor.sampler = glSampler.GetSampler().GetObjectId(); + textureDescriptor.texture = glTexture.GetTexture().GetObjectId(); + break; } - else if constexpr (std::is_same_v) + + case ShaderBindingType::UniformBuffer: { - OpenGLBuffer& vkBuffer = *static_cast(arg.buffer); + if (!std::holds_alternative(binding.content)) + throw std::runtime_error("binding #" + std::to_string(binding.bindingIndex) + " is an uniform buffer but another binding type has been supplied"); - VkDescriptorBufferInfo& bufferInfo = bufferBinding.emplace_back(); - bufferInfo.buffer = vkBuffer.GetBuffer(); - bufferInfo.offset = arg.offset; - bufferInfo.range = arg.range; + const UniformBufferBinding& uboBinding = std::get(binding.content); - writeOp.descriptorCount = 1; - writeOp.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; + OpenGLBuffer& glBuffer = *static_cast(uboBinding.buffer); + if (glBuffer.GetType() != BufferType_Uniform) + throw std::runtime_error("expected uniform buffer"); - writeOp.pBufferInfo = &bufferInfo; + auto& uboDescriptor = m_owner.GetUniformBufferDescriptor(m_poolIndex, m_bindingIndex, resourceIndex); + uboDescriptor.buffer = glBuffer.GetBuffer().GetObjectId(); + uboDescriptor.offset = uboBinding.offset; + uboDescriptor.size = uboBinding.range; + break; } - else - static_assert(AlwaysFalse::value, "non-exhaustive visitor"); - - }, binding.content); + } } - - m_owner.GetDevice()->vkUpdateDescriptorSets(*m_owner.GetDevice(), UInt32(writeOps.size()), writeOps.data(), 0U, nullptr); } void OpenGLShaderBinding::Release() @@ -75,5 +74,3 @@ namespace Nz m_owner.Release(*this); } } - -#endif From b7a7c84a893fe29bd5d8a9b4887f4e4295cba86d Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 26 Apr 2020 18:22:07 +0200 Subject: [PATCH 175/316] Minor fixes --- examples/VulkanTest/main.cpp | 2 +- include/Nazara/OpenGLRenderer/Wrapper/Sampler.inl | 2 +- include/Nazara/OpenGLRenderer/Wrapper/Shader.inl | 4 +++- src/Nazara/OpenGLRenderer/OpenGLDevice.cpp | 4 +++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index fdabfd539..1411ac0ab 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -110,7 +110,7 @@ int main() textureBinding.shaderStageFlags = Nz::ShaderStageType::Fragment; textureBinding.type = Nz::ShaderBindingType::Texture; - std::shared_ptr renderPipelineLayout = device->InstantiateRenderPipelineLayout(pipelineLayoutInfo); + std::shared_ptr renderPipelineLayout = device->InstantiateRenderPipelineLayout(std::move(pipelineLayoutInfo)); Nz::ShaderBindingPtr shaderBinding = renderPipelineLayout->AllocateShaderBinding(); diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Sampler.inl b/include/Nazara/OpenGLRenderer/Wrapper/Sampler.inl index b48ab4c03..6edf4cf5b 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Sampler.inl +++ b/include/Nazara/OpenGLRenderer/Wrapper/Sampler.inl @@ -39,7 +39,7 @@ namespace Nz::GL context.glSamplerParameteriv(m_objectId, pname, param); } - inline GLuint Sampler::CreateHelper(OpenGLDevice& device, const Context& context) + inline GLuint Sampler::CreateHelper(OpenGLDevice& /*device*/, const Context& context) { GLuint sampler = 0; context.glGenSamplers(1U, &sampler); diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Shader.inl b/include/Nazara/OpenGLRenderer/Wrapper/Shader.inl index ee6ebf850..fe062149f 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Shader.inl +++ b/include/Nazara/OpenGLRenderer/Wrapper/Shader.inl @@ -11,7 +11,9 @@ namespace Nz::GL inline void Shader::Compile() { assert(m_objectId); - m_device->GetReferenceContext().glCompileShader(m_objectId); + + const Context& context = EnsureDeviceContext(); + context.glCompileShader(m_objectId); } inline bool Shader::GetCompilationStatus(std::string* error) diff --git a/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp b/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp index 19ebfd99c..333d5d424 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -74,6 +75,7 @@ namespace Nz std::unique_ptr OpenGLDevice::InstantiateTextureSampler(const TextureSamplerInfo& params) { - return {}; + return std::make_unique(*this, params); } + } From eba0571f03c81ee2f1c119c4549069f9c1bddddc Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 26 Apr 2020 18:22:31 +0200 Subject: [PATCH 176/316] OpenGL: Implement program wrapper --- .../Nazara/OpenGLRenderer/OpenGLDevice.hpp | 1 + .../Nazara/OpenGLRenderer/OpenGLDevice.inl | 6 ++ .../Nazara/OpenGLRenderer/Wrapper/Context.hpp | 2 + .../Nazara/OpenGLRenderer/Wrapper/Context.inl | 6 ++ .../Nazara/OpenGLRenderer/Wrapper/Program.hpp | 44 ++++++++++++ .../Nazara/OpenGLRenderer/Wrapper/Program.inl | 69 +++++++++++++++++++ .../Wrapper/ProgramPipeline.hpp | 43 ------------ .../Wrapper/ProgramPipeline.inl | 47 ------------- 8 files changed, 128 insertions(+), 90 deletions(-) create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/Program.hpp create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/Program.inl delete mode 100644 include/Nazara/OpenGLRenderer/Wrapper/ProgramPipeline.hpp delete mode 100644 include/Nazara/OpenGLRenderer/Wrapper/ProgramPipeline.inl diff --git a/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp b/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp index 52effa121..2bbb95c33 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp @@ -41,6 +41,7 @@ namespace Nz std::unique_ptr InstantiateTextureSampler(const TextureSamplerInfo& params) override; inline void NotifyBufferDestruction(GLuint buffer) const; + inline void NotifyProgramDestruction(GLuint program) const; inline void NotifySamplerDestruction(GLuint sampler) const; inline void NotifyTextureDestruction(GLuint texture) const; diff --git a/include/Nazara/OpenGLRenderer/OpenGLDevice.inl b/include/Nazara/OpenGLRenderer/OpenGLDevice.inl index 66219abc5..a9c823a7e 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLDevice.inl +++ b/include/Nazara/OpenGLRenderer/OpenGLDevice.inl @@ -18,6 +18,12 @@ namespace Nz context->NotifyBufferDestruction(buffer); } + inline void OpenGLDevice::NotifyProgramDestruction(GLuint program) const + { + for (const GL::Context* context : m_contexts) + context->NotifyProgramDestruction(program); + } + inline void OpenGLDevice::NotifySamplerDestruction(GLuint sampler) const { for (const GL::Context* context : m_contexts) diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp index 50eea5c7b..d18843c08 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp @@ -105,6 +105,7 @@ namespace Nz::GL bool Initialize(const ContextParams& params); inline void NotifyBufferDestruction(GLuint buffer) const; + inline void NotifyProgramDestruction(GLuint program) const; inline void NotifySamplerDestruction(GLuint sampler) const; inline void NotifyTextureDestruction(GLuint texture) const; @@ -143,6 +144,7 @@ namespace Nz::GL std::array bufferTargets = { 0 }; std::vector textureUnits; + GLuint boundProgram = 0; UInt32 currentTextureUnit = 0; }; diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Context.inl b/include/Nazara/OpenGLRenderer/Wrapper/Context.inl index b7d5139a2..bf2dbe86b 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Context.inl +++ b/include/Nazara/OpenGLRenderer/Wrapper/Context.inl @@ -46,6 +46,12 @@ namespace Nz::GL } } + inline void Context::NotifyProgramDestruction(GLuint program) const + { + if (m_state.boundProgram == program) + m_state.boundProgram = 0; + } + inline void Context::NotifySamplerDestruction(GLuint sampler) const { for (auto& unit : m_state.textureUnits) diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Program.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Program.hpp new file mode 100644 index 000000000..5bdae0efc --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/Program.hpp @@ -0,0 +1,44 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_GLSHADER_HPP +#define NAZARA_OPENGLRENDERER_GLSHADER_HPP + +#include +#include +#include +#include + +namespace Nz::GL +{ + class Program : public DeviceObject + { + friend DeviceObject; + + public: + Program() = default; + Program(const Program&) = delete; + Program(Program&&) noexcept = default; + ~Program() = default; + + inline void AttachShader(GLuint shader); + + inline bool GetLinkStatus(std::string* error = nullptr); + + inline void Link(); + + Program& operator=(const Program&) = delete; + Program& operator=(Program&&) noexcept = default; + + private: + static inline GLuint CreateHelper(OpenGLDevice& device, const Context& context); + static inline void DestroyHelper(OpenGLDevice& device, const Context& context, GLuint objectId); + }; +} + +#include + +#endif diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Program.inl b/include/Nazara/OpenGLRenderer/Wrapper/Program.inl new file mode 100644 index 000000000..ca8795d70 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/Program.inl @@ -0,0 +1,69 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz::GL +{ + inline void Program::AttachShader(GLuint shader) + { + assert(m_objectId); + + const Context& context = EnsureDeviceContext(); + context.glAttachShader(m_objectId, shader); + } + + inline bool Program::GetLinkStatus(std::string* error) + { + assert(m_objectId); + const Context& context = EnsureDeviceContext(); + + GLint success; + context.glGetProgramiv(m_objectId, GL_LINK_STATUS, &success); + if (!success) + { + if (error) + { + GLint logLength; + context.glGetProgramiv(m_objectId, GL_INFO_LOG_LENGTH, &logLength); + + error->resize(logLength); + + if (logLength > 0) + { + GLsizei dummy; + context.glGetProgramInfoLog(m_objectId, logLength, &dummy, error->data()); + } + } + + return false; + } + + return true; + } + + inline void Program::Link() + { + assert(m_objectId); + + const Context& context = EnsureDeviceContext(); + context.glLinkProgram(m_objectId); + } + + inline GLuint Program::CreateHelper(OpenGLDevice& /*device*/, const Context& context) + { + return context.glCreateProgram(); + } + + inline void Program::DestroyHelper(OpenGLDevice& device, const Context& context, GLuint objectId) + { + context.glDeleteProgram(objectId); + + device.NotifyProgramDestruction(objectId); + } +} + +#include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/ProgramPipeline.hpp b/include/Nazara/OpenGLRenderer/Wrapper/ProgramPipeline.hpp deleted file mode 100644 index 37d83bf40..000000000 --- a/include/Nazara/OpenGLRenderer/Wrapper/ProgramPipeline.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - OpenGL Renderer" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_OPENGLRENDERER_VKIMAGE_HPP -#define NAZARA_OPENGLRENDERER_VKIMAGE_HPP - -#include -#include - -namespace Nz -{ - namespace Vk - { - class Image : public DeviceObject - { - friend DeviceObject; - - public: - Image() = default; - Image(const Image&) = delete; - Image(Image&&) = default; - ~Image() = default; - - bool BindImageMemory(VkDeviceMemory memory, VkDeviceSize offset = 0); - - VkMemoryRequirements GetMemoryRequirements() const; - - Image& operator=(const Image&) = delete; - Image& operator=(Image&&) = delete; - - private: - static inline VkResult CreateHelper(Device& device, const VkImageCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkImage* handle); - static inline void DestroyHelper(Device& device, VkImage handle, const VkAllocationCallbacks* allocator); - }; - } -} - -#include - -#endif // NAZARA_OPENGLRENDERER_VKIMAGE_HPP diff --git a/include/Nazara/OpenGLRenderer/Wrapper/ProgramPipeline.inl b/include/Nazara/OpenGLRenderer/Wrapper/ProgramPipeline.inl deleted file mode 100644 index cbc7bcb77..000000000 --- a/include/Nazara/OpenGLRenderer/Wrapper/ProgramPipeline.inl +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - OpenGL Renderer" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include - -namespace Nz -{ - namespace Vk - { - inline bool Image::BindImageMemory(VkDeviceMemory memory, VkDeviceSize offset) - { - m_lastErrorCode = m_device->vkBindImageMemory(*m_device, m_handle, memory, offset); - if (m_lastErrorCode != VK_SUCCESS) - { - NazaraError("Failed to bind image memory: " + TranslateOpenGLError(m_lastErrorCode)); - return false; - } - - return true; - } - - inline VkMemoryRequirements Image::GetMemoryRequirements() const - { - NazaraAssert(IsValid(), "Invalid image"); - - VkMemoryRequirements memoryRequirements; - m_device->vkGetImageMemoryRequirements(*m_device, m_handle, &memoryRequirements); - - return memoryRequirements; - } - - inline VkResult Image::CreateHelper(Device& device, const VkImageCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkImage* handle) - { - return device.vkCreateImage(device, createInfo, allocator, handle); - } - - inline void Image::DestroyHelper(Device& device, VkImage handle, const VkAllocationCallbacks* allocator) - { - return device.vkDestroyImage(device, handle, allocator); - } - } -} - -#include From 332f02aab0f255c4176ca7f029123c92e6b2276d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Mon, 11 May 2020 11:01:47 +0200 Subject: [PATCH 177/316] Create FUNDING.yml --- .github/FUNDING.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 000000000..1eca8dcbd --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +github: [SirLynix] +custom: ['https://paypal.me/sirlynixvanfrietjes'] From 6073d8f592c70c07ded73b4a755611927ee71c43 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 11 May 2020 13:57:11 +0200 Subject: [PATCH 178/316] OpenGL: Implement UploadPool --- .../OpenGLRenderer/OpenGLUploadPool.hpp | 6 ++- .../OpenGLRenderer/OpenGLUploadPool.cpp | 51 +++++++++++++++---- 2 files changed, 46 insertions(+), 11 deletions(-) diff --git a/include/Nazara/OpenGLRenderer/OpenGLUploadPool.hpp b/include/Nazara/OpenGLRenderer/OpenGLUploadPool.hpp index badfd8901..cd7a71db3 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLUploadPool.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLUploadPool.hpp @@ -35,10 +35,12 @@ namespace Nz private: struct Block { - //< TODO - UInt64 freeOffset; + std::vector memory; + UInt64 freeOffset = 0; }; + std::vector m_blocks; + std::vector m_allocations; UInt64 m_blockSize; }; } diff --git a/src/Nazara/OpenGLRenderer/OpenGLUploadPool.cpp b/src/Nazara/OpenGLRenderer/OpenGLUploadPool.cpp index f16c2335a..454c75840 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLUploadPool.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLUploadPool.cpp @@ -11,23 +11,56 @@ namespace Nz { auto OpenGLUploadPool::Allocate(UInt64 size) -> Allocation& { - /*const auto& deviceProperties = m_device.GetPhysicalDeviceInfo().properties; - UInt64 preferredAlignement = deviceProperties.limits.optimalBufferCopyOffsetAlignment;*/ - - return Allocate(size, 0); //< FIXME + return Allocate(size, 1); //< Alignment doesn't matter } - auto OpenGLUploadPool::Allocate(UInt64 size, UInt64 alignment) -> Allocation& + auto OpenGLUploadPool::Allocate(UInt64 size, UInt64 /*alignment*/) -> Allocation& { assert(size <= m_blockSize); - static Allocation dummy; - return dummy; + // Try to minimize lost space + struct + { + Block* block = nullptr; + UInt64 offset = 0; + } bestBlock; + + for (Block& block : m_blocks) + { + UInt64 alignedOffset = block.freeOffset; + if (block.freeOffset + size > m_blockSize) + continue; //< Not enough space + + if (!bestBlock.block) + { + bestBlock.block = █ + bestBlock.offset = block.freeOffset; + break; //< Since we have no alignment constraint, the first block is good + } + } + + // No block found, allocate a new one + if (!bestBlock.block) + { + Block newBlock; + newBlock.memory.resize(m_blockSize); + + bestBlock.block = &m_blocks.emplace_back(std::move(newBlock)); + bestBlock.offset = 0; + } + + Allocation& allocationData = m_allocations.emplace_back(); + allocationData.mappedPtr = static_cast(bestBlock.block->memory.data()) + bestBlock.offset; + allocationData.size = size; + + return allocationData; } void OpenGLUploadPool::Reset() { - /*for (Block& block : m_blocks) - block.freeOffset = 0;*/ + for (Block& block : m_blocks) + block.freeOffset = 0; + + m_allocations.clear(); } } From 49c68e581aa28581ac76b98cd6d2ff9946911c65 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 11 May 2020 13:58:12 +0200 Subject: [PATCH 179/316] OpenGL: Fix TextureSampler mipmap issue --- .../OpenGLRenderer/OpenGLTextureSampler.hpp | 9 ++++--- .../OpenGLRenderer/OpenGLTextureSampler.inl | 4 +-- .../OpenGLRenderer/OpenGLShaderBinding.cpp | 2 +- .../OpenGLRenderer/OpenGLTextureSampler.cpp | 27 ++++++++++++------- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/include/Nazara/OpenGLRenderer/OpenGLTextureSampler.hpp b/include/Nazara/OpenGLRenderer/OpenGLTextureSampler.hpp index efe9b37bf..f6ac10f0d 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLTextureSampler.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLTextureSampler.hpp @@ -17,18 +17,21 @@ namespace Nz class NAZARA_OPENGLRENDERER_API OpenGLTextureSampler : public TextureSampler { public: - OpenGLTextureSampler(OpenGLDevice& device, TextureSamplerInfo samplerInfo); + OpenGLTextureSampler(OpenGLDevice& device, const TextureSamplerInfo& samplerInfo); OpenGLTextureSampler(const OpenGLTextureSampler&) = default; OpenGLTextureSampler(OpenGLTextureSampler&&) noexcept = default; ~OpenGLTextureSampler() = default; - inline const GL::Sampler& GetSampler() const; + inline const GL::Sampler& GetSampler(bool mipmaps) const; OpenGLTextureSampler& operator=(const OpenGLTextureSampler&) = delete; OpenGLTextureSampler& operator=(OpenGLTextureSampler&&) = delete; private: - GL::Sampler m_sampler; + static void BuildSampler(OpenGLDevice& device, GL::Sampler& sampler, const TextureSamplerInfo& samplerInfo, bool withMipmaps); + + GL::Sampler m_samplerWithMipmaps; + GL::Sampler m_samplerWithoutMipmaps; }; } diff --git a/include/Nazara/OpenGLRenderer/OpenGLTextureSampler.inl b/include/Nazara/OpenGLRenderer/OpenGLTextureSampler.inl index 710e835fb..a9df7fba4 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLTextureSampler.inl +++ b/include/Nazara/OpenGLRenderer/OpenGLTextureSampler.inl @@ -7,9 +7,9 @@ namespace Nz { - inline const GL::Sampler& OpenGLTextureSampler::GetSampler() const + inline const GL::Sampler& OpenGLTextureSampler::GetSampler(bool withMipmaps) const { - return m_sampler; + return (withMipmaps) ? m_samplerWithMipmaps : m_samplerWithoutMipmaps; } } diff --git a/src/Nazara/OpenGLRenderer/OpenGLShaderBinding.cpp b/src/Nazara/OpenGLRenderer/OpenGLShaderBinding.cpp index 8a36d9c97..371aa6248 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLShaderBinding.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLShaderBinding.cpp @@ -43,8 +43,8 @@ namespace Nz OpenGLTextureSampler& glSampler = *static_cast(texBinding.sampler); auto& textureDescriptor = m_owner.GetTextureDescriptor(m_poolIndex, m_bindingIndex, resourceIndex); - textureDescriptor.sampler = glSampler.GetSampler().GetObjectId(); textureDescriptor.texture = glTexture.GetTexture().GetObjectId(); + textureDescriptor.sampler = glSampler.GetSampler(glTexture.GetLevelCount() > 1).GetObjectId(); break; } diff --git a/src/Nazara/OpenGLRenderer/OpenGLTextureSampler.cpp b/src/Nazara/OpenGLRenderer/OpenGLTextureSampler.cpp index 72dac5f12..1f49bbc30 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLTextureSampler.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLTextureSampler.cpp @@ -9,21 +9,30 @@ namespace Nz { - OpenGLTextureSampler::OpenGLTextureSampler(OpenGLDevice& device, TextureSamplerInfo samplerInfo) + OpenGLTextureSampler::OpenGLTextureSampler(OpenGLDevice& device, const TextureSamplerInfo& samplerInfo) { - if (!m_sampler.Create(device)) + BuildSampler(device, m_samplerWithMipmaps, samplerInfo, true); + BuildSampler(device, m_samplerWithoutMipmaps, samplerInfo, false); + } + + void OpenGLTextureSampler::BuildSampler(OpenGLDevice& device, GL::Sampler& sampler, const TextureSamplerInfo& samplerInfo, bool withMipmaps) + { + if (!sampler.Create(device)) throw std::runtime_error("failed to create sampler object"); - // In OpenGL, min and mipmap sampler are part of the same enum + // In OpenGL, min and mipmap sampler are part of the same enum (and mipmaps filter should only be used with mipmaps) + if (withMipmaps) + sampler.SetParameteri(GL_TEXTURE_MIN_FILTER, ToOpenGL(samplerInfo.minFilter, samplerInfo.mipmapMode)); + else + sampler.SetParameteri(GL_TEXTURE_MIN_FILTER, ToOpenGL(samplerInfo.minFilter)); - m_sampler.SetParameteri(GL_TEXTURE_MIN_FILTER, ToOpenGL(samplerInfo.minFilter, samplerInfo.mipmapMode)); - m_sampler.SetParameteri(GL_TEXTURE_MAG_FILTER, ToOpenGL(samplerInfo.magFilter)); + sampler.SetParameteri(GL_TEXTURE_MAG_FILTER, ToOpenGL(samplerInfo.magFilter)); - m_sampler.SetParameteri(GL_TEXTURE_WRAP_S, ToOpenGL(samplerInfo.wrapModeU)); - m_sampler.SetParameteri(GL_TEXTURE_WRAP_T, ToOpenGL(samplerInfo.wrapModeV)); - m_sampler.SetParameteri(GL_TEXTURE_WRAP_R, ToOpenGL(samplerInfo.wrapModeW)); + sampler.SetParameteri(GL_TEXTURE_WRAP_S, ToOpenGL(samplerInfo.wrapModeU)); + sampler.SetParameteri(GL_TEXTURE_WRAP_T, ToOpenGL(samplerInfo.wrapModeV)); + sampler.SetParameteri(GL_TEXTURE_WRAP_R, ToOpenGL(samplerInfo.wrapModeW)); if (samplerInfo.anisotropyLevel > 1.f) - m_sampler.SetParameterf(GL_TEXTURE_MAX_ANISOTROPY_EXT, samplerInfo.anisotropyLevel); + sampler.SetParameterf(GL_TEXTURE_MAX_ANISOTROPY_EXT, samplerInfo.anisotropyLevel); } } From 3cf53c4d9a11f78a9f9403ddefe41cdc8c7fd35f Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 11 May 2020 14:01:17 +0200 Subject: [PATCH 180/316] OpenGL: Implement RenderPipeline --- .../OpenGLRenderer/OpenGLRenderPipeline.hpp | 54 +--- .../OpenGLRenderer/OpenGLRenderPipeline.inl | 4 + .../Nazara/OpenGLRenderer/Wrapper/Context.hpp | 2 + .../OpenGLRenderer/OpenGLRenderPipeline.cpp | 264 +----------------- src/Nazara/OpenGLRenderer/Wrapper/Context.cpp | 151 ++++++++++ 5 files changed, 177 insertions(+), 298 deletions(-) diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderPipeline.hpp b/include/Nazara/OpenGLRenderer/OpenGLRenderPipeline.hpp index 4cddfc828..ddc6526af 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLRenderPipeline.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderPipeline.hpp @@ -11,9 +11,7 @@ #include #include #include -#include -#include -#include +#include #include namespace Nz @@ -21,58 +19,16 @@ namespace Nz class NAZARA_OPENGLRENDERER_API OpenGLRenderPipeline : public RenderPipeline { public: - struct CreateInfo; - - OpenGLRenderPipeline(Vk::Device& device, RenderPipelineInfo pipelineInfo); + OpenGLRenderPipeline(OpenGLDevice& device, RenderPipelineInfo pipelineInfo); ~OpenGLRenderPipeline() = default; - VkPipeline Get(const Vk::RenderPass& renderPass) const; + void Apply(const GL::Context& context) const; - static std::vector BuildColorBlendAttachmentStateList(const RenderPipelineInfo& pipelineInfo); - static VkPipelineColorBlendStateCreateInfo BuildColorBlendInfo(const RenderPipelineInfo& pipelineInfo, const std::vector& attachmentState); - static VkPipelineDepthStencilStateCreateInfo BuildDepthStencilInfo(const RenderPipelineInfo& pipelineInfo); - static VkPipelineDynamicStateCreateInfo BuildDynamicStateInfo(const RenderPipelineInfo& pipelineInfo, const std::vector& dynamicStates); - static std::vector BuildDynamicStateList(const RenderPipelineInfo& pipelineInfo); - static VkPipelineInputAssemblyStateCreateInfo BuildInputAssemblyInfo(const RenderPipelineInfo& pipelineInfo); - static VkPipelineMultisampleStateCreateInfo BuildMultisampleInfo(const RenderPipelineInfo& pipelineInfo); - static VkPipelineRasterizationStateCreateInfo BuildRasterizationInfo(const RenderPipelineInfo& pipelineInfo); - static VkPipelineViewportStateCreateInfo BuildViewportInfo(const RenderPipelineInfo& pipelineInfo); - static VkStencilOpState BuildStencilOp(const RenderPipelineInfo& pipelineInfo, bool front); - static std::vector BuildShaderStageInfo(const RenderPipelineInfo& pipelineInfo); - static std::vector BuildVertexAttributeDescription(const RenderPipelineInfo& pipelineInfo); - static std::vector BuildVertexBindingDescription(const RenderPipelineInfo& pipelineInfo); - static VkPipelineVertexInputStateCreateInfo BuildVertexInputInfo(const RenderPipelineInfo& pipelineInfo, const std::vector& vertexAttributes, const std::vector& bindingDescription); - - static CreateInfo BuildCreateInfo(const RenderPipelineInfo& pipelineInfo); - - struct CreateInfo - { - struct StateData - { - VkPipelineColorBlendStateCreateInfo colorBlendState; - VkPipelineDepthStencilStateCreateInfo depthStencilState; - VkPipelineDynamicStateCreateInfo dynamicState; - VkPipelineMultisampleStateCreateInfo multiSampleState; - VkPipelineInputAssemblyStateCreateInfo inputAssemblyState; - VkPipelineRasterizationStateCreateInfo rasterizationState; - VkPipelineVertexInputStateCreateInfo vertexInputState; - VkPipelineViewportStateCreateInfo viewportState; - }; - - std::vector colorBlendAttachmentState; - std::vector dynamicStates; - std::vector shaderStages; - std::vector vertexAttributesDescription; - std::vector vertexBindingDescription; - std::unique_ptr stateData; - VkGraphicsPipelineCreateInfo pipelineInfo; - }; + inline const RenderPipelineInfo& GetPipelineInfo() const; private: - mutable std::unordered_map m_pipelines; - MovablePtr m_device; - CreateInfo m_pipelineCreateInfo; RenderPipelineInfo m_pipelineInfo; + GL::Program m_program; }; } diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderPipeline.inl b/include/Nazara/OpenGLRenderer/OpenGLRenderPipeline.inl index 034fea18c..0b4dc1a95 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLRenderPipeline.inl +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderPipeline.inl @@ -7,6 +7,10 @@ namespace Nz { + inline const RenderPipelineInfo& OpenGLRenderPipeline::GetPipelineInfo() const + { + return m_pipelineInfo; + } } #include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp index d18843c08..96378fa22 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp @@ -113,6 +113,8 @@ namespace Nz::GL virtual void SwapBuffers() = 0; + void UpdateStates(const RenderStates& renderStates) const; + #define NAZARA_OPENGLRENDERER_FUNC(name, sig) sig name = nullptr; NAZARA_OPENGLRENDERER_FOREACH_GLES_FUNC(NAZARA_OPENGLRENDERER_FUNC, NAZARA_OPENGLRENDERER_FUNC) #undef NAZARA_OPENGLRENDERER_FUNC diff --git a/src/Nazara/OpenGLRenderer/OpenGLRenderPipeline.cpp b/src/Nazara/OpenGLRenderer/OpenGLRenderPipeline.cpp index a57b7b1ed..d3378c941 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLRenderPipeline.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLRenderPipeline.cpp @@ -2,273 +2,39 @@ // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#if 0 - #include #include #include #include #include #include +#include #include namespace Nz { - OpenGLRenderPipeline::OpenGLRenderPipeline(Vk::Device& device, RenderPipelineInfo pipelineInfo) : - m_device(&device), + OpenGLRenderPipeline::OpenGLRenderPipeline(OpenGLDevice& device, RenderPipelineInfo pipelineInfo) : m_pipelineInfo(std::move(pipelineInfo)) { - m_pipelineCreateInfo = BuildCreateInfo(m_pipelineInfo); - } + if (!m_program.Create(device)) + throw std::runtime_error("failed to create program"); - VkPipeline OpenGLRenderPipeline::Get(const Vk::RenderPass& renderPass) const - { - if (auto it = m_pipelines.find(renderPass); it != m_pipelines.end()) - return it->second; - - // Copy create info to make Get re-entrant - VkGraphicsPipelineCreateInfo pipelineCreateInfo = m_pipelineCreateInfo.pipelineInfo; - pipelineCreateInfo.renderPass = renderPass; - - Vk::Pipeline newPipeline; - if (!newPipeline.CreateGraphics(*m_device, pipelineCreateInfo)) - return VK_NULL_HANDLE; - - auto it = m_pipelines.emplace(renderPass, std::move(newPipeline)).first; - return it->second; - } - - std::vector OpenGLRenderPipeline::BuildColorBlendAttachmentStateList(const RenderPipelineInfo& pipelineInfo) - { - std::vector colorBlendStates; - - VkPipelineColorBlendAttachmentState& colorBlendState = colorBlendStates.emplace_back(); - colorBlendState.blendEnable = pipelineInfo.blending; - colorBlendState.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT; //< TODO - - if (pipelineInfo.blending) + for (const auto& shaderStagePtr : m_pipelineInfo.shaderStages) { - //TODO - /*switch (pipelineInfo.dstBlend) - { - blendState.dstAlphaBlendFactor - }*/ - } - else - { - colorBlendState.srcColorBlendFactor = VK_BLEND_FACTOR_ONE; - colorBlendState.dstColorBlendFactor = VK_BLEND_FACTOR_ZERO; - colorBlendState.colorBlendOp = VK_BLEND_OP_ADD; - colorBlendState.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE; - colorBlendState.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO; - colorBlendState.alphaBlendOp = VK_BLEND_OP_ADD; + OpenGLShaderStage& shaderStage = static_cast(*shaderStagePtr); + m_program.AttachShader(shaderStage.GetShader().GetObjectId()); } - return colorBlendStates; + m_program.Link(); + + std::string errLog; + if (!m_program.GetLinkStatus(&errLog)) + throw std::runtime_error("failed to link program: " + errLog); } - VkPipelineColorBlendStateCreateInfo OpenGLRenderPipeline::BuildColorBlendInfo(const RenderPipelineInfo& pipelineInfo, const std::vector& attachmentState) + void OpenGLRenderPipeline::Apply(const GL::Context& context) const { - VkPipelineColorBlendStateCreateInfo createInfo = {}; - createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; - createInfo.attachmentCount = std::uint32_t(attachmentState.size()); - createInfo.pAttachments = attachmentState.data(); - - return createInfo; - } - - VkPipelineDepthStencilStateCreateInfo OpenGLRenderPipeline::BuildDepthStencilInfo(const RenderPipelineInfo& pipelineInfo) - { - VkPipelineDepthStencilStateCreateInfo createInfo = {}; - createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; - createInfo.depthTestEnable = pipelineInfo.depthBuffer; - createInfo.depthWriteEnable = pipelineInfo.depthWrite; - createInfo.depthCompareOp = ToOpenGL(pipelineInfo.depthCompare); - createInfo.stencilTestEnable = pipelineInfo.stencilTest; - createInfo.front = BuildStencilOp(pipelineInfo, true); - createInfo.back = BuildStencilOp(pipelineInfo, false); - - return createInfo; - } - - VkPipelineDynamicStateCreateInfo OpenGLRenderPipeline::BuildDynamicStateInfo(const RenderPipelineInfo& pipelineInfo, const std::vector& dynamicStates) - { - VkPipelineDynamicStateCreateInfo createInfo = {}; - createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; - createInfo.dynamicStateCount = std::uint32_t(dynamicStates.size()); - createInfo.pDynamicStates = dynamicStates.data(); - - return createInfo; - } - - std::vector OpenGLRenderPipeline::BuildDynamicStateList(const RenderPipelineInfo& pipelineInfo) - { - return { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR }; - } - - VkPipelineInputAssemblyStateCreateInfo OpenGLRenderPipeline::BuildInputAssemblyInfo(const RenderPipelineInfo& pipelineInfo) - { - VkPipelineInputAssemblyStateCreateInfo createInfo = {}; - createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; - createInfo.topology = ToOpenGL(pipelineInfo.primitiveMode); - - return createInfo; - } - - VkPipelineMultisampleStateCreateInfo OpenGLRenderPipeline::BuildMultisampleInfo(const RenderPipelineInfo& pipelineInfo) - { - VkPipelineMultisampleStateCreateInfo createInfo = {}; - createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; - createInfo.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; - createInfo.minSampleShading = 1.0f; //< TODO: Remove - - return createInfo; - } - - VkPipelineRasterizationStateCreateInfo OpenGLRenderPipeline::BuildRasterizationInfo(const RenderPipelineInfo& pipelineInfo) - { - VkPipelineRasterizationStateCreateInfo createInfo = {}; - createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; - createInfo.polygonMode = ToOpenGL(pipelineInfo.faceFilling); - createInfo.cullMode = ToOpenGL(pipelineInfo.cullingSide); - createInfo.frontFace = VK_FRONT_FACE_CLOCKWISE; //< TODO - createInfo.lineWidth = pipelineInfo.lineWidth; - - return createInfo; - } - - VkPipelineViewportStateCreateInfo OpenGLRenderPipeline::BuildViewportInfo(const RenderPipelineInfo& pipelineInfo) - { - VkPipelineViewportStateCreateInfo createInfo = {}; - createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; - createInfo.scissorCount = createInfo.viewportCount = 1; //< TODO - - return createInfo; - } - - VkStencilOpState OpenGLRenderPipeline::BuildStencilOp(const RenderPipelineInfo& pipelineInfo, bool front) - { - const auto& pipelineStencil = (front) ? pipelineInfo.stencilFront : pipelineInfo.stencilBack; - - VkStencilOpState stencilStates; - stencilStates.compareMask = pipelineStencil.compareMask; - stencilStates.compareOp = ToOpenGL(pipelineStencil.compare); - stencilStates.depthFailOp = ToOpenGL(pipelineStencil.depthFail); - stencilStates.failOp = ToOpenGL(pipelineStencil.fail); - stencilStates.passOp = ToOpenGL(pipelineStencil.pass); - stencilStates.reference = pipelineStencil.reference; - stencilStates.writeMask = pipelineStencil.writeMask; - - return stencilStates; - } - - std::vector OpenGLRenderPipeline::BuildShaderStageInfo(const RenderPipelineInfo& pipelineInfo) - { - std::vector shaderStageCreateInfos; - - for (auto&& stagePtr : pipelineInfo.shaderStages) - { - Nz::OpenGLShaderStage& vulkanStage = *static_cast(stagePtr.get()); - - VkPipelineShaderStageCreateInfo& createInfo = shaderStageCreateInfos.emplace_back(); - createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; - createInfo.module = vulkanStage.GetHandle(); - createInfo.pName = "main"; - createInfo.stage = ToOpenGL(vulkanStage.GetStageType()); - } - - return shaderStageCreateInfos; - } - - std::vector OpenGLRenderPipeline::BuildVertexAttributeDescription(const RenderPipelineInfo& pipelineInfo) - { - std::vector vertexAttributes; - - std::uint32_t locationIndex = 0; - - for (const auto& bufferData : pipelineInfo.vertexBuffers) - { - std::uint32_t binding = std::uint32_t(bufferData.binding); - - for (const auto& componentInfo : *bufferData.declaration) - { - auto& bufferAttribute = vertexAttributes.emplace_back(); - bufferAttribute.binding = binding; - bufferAttribute.location = locationIndex++; - bufferAttribute.offset = std::uint32_t(componentInfo.offset); - bufferAttribute.format = ToOpenGL(componentInfo.type); - } - } - - return vertexAttributes; - } - - std::vector OpenGLRenderPipeline::BuildVertexBindingDescription(const RenderPipelineInfo& pipelineInfo) - { - std::vector vertexBindings; - - for (const auto& bufferData : pipelineInfo.vertexBuffers) - { - auto& bufferBinding = vertexBindings.emplace_back(); - bufferBinding.binding = std::uint32_t(bufferData.binding); - bufferBinding.stride = std::uint32_t(bufferData.declaration->GetStride()); - bufferBinding.inputRate = ToOpenGL(bufferData.declaration->GetInputRate()); - } - - return vertexBindings; - } - - VkPipelineVertexInputStateCreateInfo OpenGLRenderPipeline::BuildVertexInputInfo(const RenderPipelineInfo& pipelineInfo, const std::vector& vertexAttributes, const std::vector& bindingDescriptions) - { - VkPipelineVertexInputStateCreateInfo createInfo = {}; - createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; - - createInfo.vertexAttributeDescriptionCount = std::uint32_t(vertexAttributes.size()); - createInfo.pVertexAttributeDescriptions = vertexAttributes.data(); - - createInfo.vertexBindingDescriptionCount = std::uint32_t(bindingDescriptions.size()); - createInfo.pVertexBindingDescriptions = bindingDescriptions.data(); - - return createInfo; - } - - auto OpenGLRenderPipeline::BuildCreateInfo(const RenderPipelineInfo& pipelineInfo) -> CreateInfo - { - CreateInfo createInfo = {}; - createInfo.stateData = std::make_unique(); - - createInfo.colorBlendAttachmentState = BuildColorBlendAttachmentStateList(pipelineInfo); - createInfo.dynamicStates = BuildDynamicStateList(pipelineInfo); - createInfo.shaderStages = BuildShaderStageInfo(pipelineInfo); - createInfo.vertexAttributesDescription = BuildVertexAttributeDescription(pipelineInfo); - createInfo.vertexBindingDescription = BuildVertexBindingDescription(pipelineInfo); - - createInfo.stateData->colorBlendState = BuildColorBlendInfo(pipelineInfo, createInfo.colorBlendAttachmentState); - createInfo.stateData->depthStencilState = BuildDepthStencilInfo(pipelineInfo); - createInfo.stateData->dynamicState = BuildDynamicStateInfo(pipelineInfo, createInfo.dynamicStates); - createInfo.stateData->inputAssemblyState = BuildInputAssemblyInfo(pipelineInfo); - createInfo.stateData->multiSampleState = BuildMultisampleInfo(pipelineInfo); - createInfo.stateData->rasterizationState = BuildRasterizationInfo(pipelineInfo); - createInfo.stateData->viewportState = BuildViewportInfo(pipelineInfo); - createInfo.stateData->vertexInputState = BuildVertexInputInfo(pipelineInfo, createInfo.vertexAttributesDescription, createInfo.vertexBindingDescription); - - createInfo.pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; - createInfo.pipelineInfo.stageCount = std::uint32_t(createInfo.shaderStages.size()); - createInfo.pipelineInfo.pStages = createInfo.shaderStages.data(); - createInfo.pipelineInfo.pColorBlendState = &createInfo.stateData->colorBlendState; - createInfo.pipelineInfo.pDepthStencilState = &createInfo.stateData->depthStencilState; - createInfo.pipelineInfo.pDynamicState = &createInfo.stateData->dynamicState; - createInfo.pipelineInfo.pInputAssemblyState = &createInfo.stateData->inputAssemblyState; - createInfo.pipelineInfo.pMultisampleState = &createInfo.stateData->multiSampleState; - createInfo.pipelineInfo.pRasterizationState = &createInfo.stateData->rasterizationState; - createInfo.pipelineInfo.pVertexInputState = &createInfo.stateData->vertexInputState; - createInfo.pipelineInfo.pViewportState = &createInfo.stateData->viewportState; - - OpenGLRenderPipelineLayout& pipelineLayout = *static_cast(pipelineInfo.pipelineLayout.get()); - createInfo.pipelineInfo.layout = pipelineLayout.GetPipelineLayout(); - - return createInfo; + context.UpdateStates(m_pipelineInfo); + context.BindProgram(m_program.GetObjectId()); //< Bind program after states } } - -#endif diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp index e1240d365..3d7417f6d 100644 --- a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp +++ b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp @@ -197,6 +197,157 @@ namespace Nz::GL return true; } + void Context::UpdateStates(const RenderStates& renderStates) const + { + if (!SetCurrentContext(this)) + throw std::runtime_error("failed to activate context"); + + if (renderStates.blending) + { + if (m_state.renderStates.dstBlend != renderStates.dstBlend || + m_state.renderStates.srcBlend != renderStates.srcBlend) + { + glBlendFunc(ToOpenGL(renderStates.srcBlend), ToOpenGL(renderStates.dstBlend)); + m_state.renderStates.dstBlend = renderStates.dstBlend; + m_state.renderStates.srcBlend = renderStates.srcBlend; + } + } + + if (renderStates.depthBuffer) + { + if (m_state.renderStates.depthCompare != renderStates.depthCompare) + { + glDepthFunc(ToOpenGL(m_state.renderStates.depthCompare)); + m_state.renderStates.depthCompare = renderStates.depthCompare; + } + + if (m_state.renderStates.depthWrite != renderStates.depthWrite) + { + glDepthMask((renderStates.depthWrite) ? GL_TRUE : GL_FALSE); + m_state.renderStates.depthWrite = renderStates.depthWrite; + } + } + + if (renderStates.faceCulling) + { + if (m_state.renderStates.cullingSide != renderStates.cullingSide) + { + glCullFace(ToOpenGL(m_state.renderStates.cullingSide)); + m_state.renderStates.cullingSide = renderStates.cullingSide; + } + } + + /* + TODO: Use glPolyonMode if available (OpenGL) + if (m_state.renderStates.faceFilling != renderStates.faceFilling) + { + glPolygonMode(GL_FRONT_AND_BACK, FaceFilling[states.faceFilling]); + m_state.renderStates.faceFilling = renderStates.faceFilling; + }*/ + + if (renderStates.stencilTest) + { + auto ApplyStencilStates = [&](bool front) + { + auto& currentStencilData = (front) ? m_state.renderStates.stencilFront : m_state.renderStates.stencilBack; + auto& newStencilData = (front) ? renderStates.stencilFront : renderStates.stencilBack; + + if (currentStencilData.compare != newStencilData.compare || + currentStencilData.reference != newStencilData.reference || + currentStencilData.writeMask != newStencilData.writeMask) + { + glStencilFuncSeparate((front) ? GL_FRONT : GL_BACK, ToOpenGL(newStencilData.compare), newStencilData.reference, newStencilData.writeMask); + currentStencilData.compare = newStencilData.compare; + currentStencilData.reference = newStencilData.reference; + currentStencilData.writeMask = newStencilData.writeMask; + } + + if (currentStencilData.depthFail != newStencilData.depthFail || + currentStencilData.fail != newStencilData.fail || + currentStencilData.pass != newStencilData.pass) + { + glStencilOpSeparate((front) ? GL_FRONT : GL_BACK, ToOpenGL(newStencilData.fail), ToOpenGL(newStencilData.depthFail), ToOpenGL(newStencilData.pass)); + currentStencilData.depthFail = newStencilData.depthFail; + currentStencilData.fail = newStencilData.fail; + currentStencilData.pass = newStencilData.pass; + } + }; + + ApplyStencilStates(true); + ApplyStencilStates(false); + } + + if (!NumberEquals(m_state.renderStates.lineWidth, renderStates.lineWidth, 0.001f)) + { + glLineWidth(renderStates.lineWidth); + m_state.renderStates.lineWidth = renderStates.lineWidth; + } + + /*if (!NumberEquals(m_state.renderStates.pointSize, renderStates.pointSize, 0.001f)) + { + glPointSize(renderStates.pointSize); + m_state.renderStates.pointSize = renderStates.pointSize; + }*/ + + if (m_state.renderStates.blending != renderStates.blending) + { + if (renderStates.blending) + glEnable(GL_BLEND); + else + glDisable(GL_BLEND); + + m_state.renderStates.blending = renderStates.blending; + } + + if (m_state.renderStates.colorWrite != renderStates.colorWrite) + { + GLboolean param = (renderStates.colorWrite) ? GL_TRUE : GL_FALSE; + glColorMask(param, param, param, param); + + m_state.renderStates.colorWrite = renderStates.colorWrite; + } + + if (m_state.renderStates.depthBuffer != renderStates.depthBuffer) + { + if (renderStates.depthBuffer) + glEnable(GL_DEPTH_TEST); + else + glDisable(GL_DEPTH_TEST); + + m_state.renderStates.depthBuffer = renderStates.depthBuffer; + } + + if (m_state.renderStates.faceCulling != renderStates.faceCulling) + { + if (renderStates.faceCulling) + glEnable(GL_CULL_FACE); + else + glDisable(GL_CULL_FACE); + + m_state.renderStates.faceCulling = renderStates.faceCulling; + } + + if (m_state.renderStates.scissorTest != renderStates.scissorTest) + { + if (renderStates.scissorTest) + glEnable(GL_SCISSOR_TEST); + else + glDisable(GL_SCISSOR_TEST); + + m_state.renderStates.scissorTest = renderStates.scissorTest; + } + + if (m_state.renderStates.stencilTest != renderStates.stencilTest) + { + if (renderStates.stencilTest) + glEnable(GL_STENCIL_TEST); + else + glDisable(GL_STENCIL_TEST); + + m_state.renderStates.stencilTest = renderStates.stencilTest; + } + } + const Context* Context::GetCurrentContext() { return s_currentContext; From 51009cd745542ae1ff7b2601932c79038886935a Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 11 May 2020 14:01:45 +0200 Subject: [PATCH 181/316] OpenGL: Switch to SRGB formats --- src/Nazara/OpenGLRenderer/OpenGLTexture.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nazara/OpenGLRenderer/OpenGLTexture.cpp b/src/Nazara/OpenGLRenderer/OpenGLTexture.cpp index 55e5efa0c..417830cd3 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLTexture.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLTexture.cpp @@ -22,13 +22,13 @@ namespace Nz { case PixelFormat_RGB8: { - internalFormat = GL_RGB8; + internalFormat = GL_SRGB8; break; } case PixelFormat_RGBA8: { - internalFormat = GL_RGBA8; + internalFormat = GL_SRGB8_ALPHA8; break; } } From 34804189d80584cdd2ff1cf2fcbf369dc9cb542d Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 11 May 2020 14:01:57 +0200 Subject: [PATCH 182/316] OpenGL: Set GL_TEXTURE_MAX_LEVEL --- src/Nazara/OpenGLRenderer/OpenGLTexture.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Nazara/OpenGLRenderer/OpenGLTexture.cpp b/src/Nazara/OpenGLRenderer/OpenGLTexture.cpp index 417830cd3..d89da0d49 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLTexture.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLTexture.cpp @@ -58,6 +58,8 @@ namespace Nz default: break; } + + m_texture.SetParameteri(GL_TEXTURE_MAX_LEVEL, m_params.mipmapLevel); } PixelFormat OpenGLTexture::GetFormat() const From 2ea03fe05f1674e69cb8437764a690b5ec34fff8 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 11 May 2020 14:03:54 +0200 Subject: [PATCH 183/316] OpenGL: Implement Framebuffers --- .../OpenGLRenderer/OpenGLFramebuffer.hpp | 14 +++++++ .../OpenGLRenderer/OpenGLFramebuffer.inl | 9 +++++ .../OpenGLRenderer/OpenGLRenderWindow.hpp | 4 +- .../OpenGLWindowFramebuffer.hpp | 37 +++++++++++++++++++ .../OpenGLWindowFramebuffer.inl | 17 +++++++++ .../Nazara/OpenGLRenderer/Wrapper/Context.hpp | 11 ++++++ .../OpenGLWindowFramebuffer.cpp | 20 ++++++++++ src/Nazara/OpenGLRenderer/Wrapper/Context.cpp | 13 +++++++ 8 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 include/Nazara/OpenGLRenderer/OpenGLWindowFramebuffer.hpp create mode 100644 include/Nazara/OpenGLRenderer/OpenGLWindowFramebuffer.inl create mode 100644 src/Nazara/OpenGLRenderer/OpenGLWindowFramebuffer.cpp diff --git a/include/Nazara/OpenGLRenderer/OpenGLFramebuffer.hpp b/include/Nazara/OpenGLRenderer/OpenGLFramebuffer.hpp index 87198b8c2..d6bc34dee 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLFramebuffer.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLFramebuffer.hpp @@ -16,13 +16,27 @@ namespace Nz class NAZARA_OPENGLRENDERER_API OpenGLFramebuffer : public Framebuffer { public: + enum class Type + { + FBO, + Window + }; + + inline OpenGLFramebuffer(Type type); OpenGLFramebuffer() = default; OpenGLFramebuffer(const OpenGLFramebuffer&) = delete; OpenGLFramebuffer(OpenGLFramebuffer&&) noexcept = default; ~OpenGLFramebuffer() = default; + virtual void Activate() const = 0; + + inline Type GetType() const; + OpenGLFramebuffer& operator=(const OpenGLFramebuffer&) = delete; OpenGLFramebuffer& operator=(OpenGLFramebuffer&&) noexcept = default; + + private: + Type m_type; }; } diff --git a/include/Nazara/OpenGLRenderer/OpenGLFramebuffer.inl b/include/Nazara/OpenGLRenderer/OpenGLFramebuffer.inl index c629eb72a..df37fb3dd 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLFramebuffer.inl +++ b/include/Nazara/OpenGLRenderer/OpenGLFramebuffer.inl @@ -7,6 +7,15 @@ namespace Nz { + inline OpenGLFramebuffer::OpenGLFramebuffer(Type type) : + m_type(type) + { + } + + inline auto OpenGLFramebuffer::GetType() const -> Type + { + return m_type; + } } #include diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp b/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp index f8673cd44..fde356958 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp @@ -10,9 +10,9 @@ #include #include #include -#include #include #include +#include #include #include #include @@ -43,8 +43,8 @@ namespace Nz std::shared_ptr m_device; std::vector m_renderImage; std::unique_ptr m_context; - OpenGLFramebuffer m_framebuffer; OpenGLRenderPass m_renderPass; + OpenGLWindowFramebuffer m_framebuffer; }; } diff --git a/include/Nazara/OpenGLRenderer/OpenGLWindowFramebuffer.hpp b/include/Nazara/OpenGLRenderer/OpenGLWindowFramebuffer.hpp new file mode 100644 index 000000000..b1a08cb26 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLWindowFramebuffer.hpp @@ -0,0 +1,37 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_OPENGLWINDOWFRAMEBUFFER_HPP +#define NAZARA_OPENGLRENDERER_OPENGLWINDOWFRAMEBUFFER_HPP + +#include +#include + +namespace Nz +{ + class OpenGLRenderWindow; + + class NAZARA_OPENGLRENDERER_API OpenGLWindowFramebuffer : public OpenGLFramebuffer + { + public: + inline OpenGLWindowFramebuffer(OpenGLRenderWindow& renderWindow); + OpenGLWindowFramebuffer(const OpenGLWindowFramebuffer&) = delete; + OpenGLWindowFramebuffer(OpenGLWindowFramebuffer&&) noexcept = default; + ~OpenGLWindowFramebuffer() = default; + + void Activate() const override; + + OpenGLWindowFramebuffer& operator=(const OpenGLWindowFramebuffer&) = delete; + OpenGLWindowFramebuffer& operator=(OpenGLWindowFramebuffer&&) noexcept = default; + + private: + OpenGLRenderWindow& m_renderWindow; + }; +} + +#include + +#endif // NAZARA_OPENGLRENDERER_OpenGLWindowFramebuffer_HPP diff --git a/include/Nazara/OpenGLRenderer/OpenGLWindowFramebuffer.inl b/include/Nazara/OpenGLRenderer/OpenGLWindowFramebuffer.inl new file mode 100644 index 000000000..9549a0467 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLWindowFramebuffer.inl @@ -0,0 +1,17 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline OpenGLWindowFramebuffer::OpenGLWindowFramebuffer(OpenGLRenderWindow& renderWindow) : + OpenGLFramebuffer(OpenGLFramebuffer::Type::Window), + m_renderWindow(renderWindow) + { + } +} + +#include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp index 96378fa22..ae0fd627f 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp @@ -58,6 +58,12 @@ namespace Nz::GL KHR }; + enum class FramebufferTarget + { + Draw, + Read + }; + enum class TextureTarget { Cubemap, @@ -89,6 +95,8 @@ namespace Nz::GL virtual ~Context(); void BindBuffer(BufferTarget target, GLuint buffer) const; + void BindFramebuffer(GLuint fbo) const; + void BindFramebuffer(FramebufferTarget target, GLuint fbo) const; void BindSampler(UInt32 textureUnit, GLuint sampler) const; void BindTexture(TextureTarget target, GLuint texture) const; void BindTexture(UInt32 textureUnit, TextureTarget target, GLuint texture) const; @@ -147,7 +155,10 @@ namespace Nz::GL std::array bufferTargets = { 0 }; std::vector textureUnits; GLuint boundProgram = 0; + GLuint boundDrawFBO = 0; + GLuint boundReadFBO = 0; UInt32 currentTextureUnit = 0; + RenderStates renderStates; }; std::array m_extensionStatus; diff --git a/src/Nazara/OpenGLRenderer/OpenGLWindowFramebuffer.cpp b/src/Nazara/OpenGLRenderer/OpenGLWindowFramebuffer.cpp new file mode 100644 index 000000000..48b900a5c --- /dev/null +++ b/src/Nazara/OpenGLRenderer/OpenGLWindowFramebuffer.cpp @@ -0,0 +1,20 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include + +namespace Nz +{ + void OpenGLWindowFramebuffer::Activate() const + { + GL::Context& context = m_renderWindow.GetContext(); + if (!GL::Context::SetCurrentContext(&context)) + throw std::runtime_error("failed to bind window context"); + + context.BindFramebuffer(GL::FramebufferTarget::Draw, 0); + } +} diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp index 3d7417f6d..e4344b3be 100644 --- a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp +++ b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp @@ -36,6 +36,19 @@ namespace Nz::GL } } + void Context::BindFramebuffer(GLuint fbo) const + { + if (m_state.boundDrawFBO != fbo || m_state.boundReadFBO != fbo) + { + if (!SetCurrentContext(this)) + throw std::runtime_error("failed to activate context"); + + glBindFramebuffer(GL_FRAMEBUFFER, fbo); + m_state.boundDrawFBO = fbo; + m_state.boundReadFBO = fbo; + } + } + void Context::BindSampler(UInt32 textureUnit, GLuint sampler) const { if (textureUnit >= m_state.textureUnits.size()) From 332278dded3e94a980e480d28e7e529812677638 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 11 May 2020 14:05:40 +0200 Subject: [PATCH 184/316] OpenGL: Random stuff I forgot --- .../OpenGLRenderer/OpenGLRenderWindow.hpp | 1 + .../OpenGLRenderer/OpenGLRenderWindow.inl | 6 ++ include/Nazara/OpenGLRenderer/Utils.hpp | 3 + include/Nazara/OpenGLRenderer/Utils.inl | 84 +++++++++++++++++-- .../OpenGLRenderer/Wrapper/CoreFunctions.hpp | 6 +- .../Nazara/OpenGLRenderer/Wrapper/Program.hpp | 4 +- .../Nazara/OpenGLRenderer/Wrapper/Texture.hpp | 5 ++ .../Nazara/OpenGLRenderer/Wrapper/Texture.inl | 32 +++++++ include/Nazara/Renderer/RenderBufferView.hpp | 4 +- include/Nazara/Renderer/UploadPool.hpp | 1 - include/Nazara/VulkanRenderer/Utils.inl | 24 +++--- .../VulkanRenderer/VulkanUploadPool.hpp | 1 + src/Nazara/OpenGLRenderer/OpenGLDevice.cpp | 8 +- .../OpenGLRenderer/OpenGLRenderWindow.cpp | 12 ++- src/Nazara/OpenGLRenderer/Wrapper/Context.cpp | 13 +++ 15 files changed, 176 insertions(+), 28 deletions(-) diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp b/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp index fde356958..9fdb69561 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp @@ -31,6 +31,7 @@ namespace Nz bool Create(RendererImpl* renderer, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) override; std::unique_ptr CreateCommandPool(QueueType queueType) override; + inline GL::Context& GetContext(); const OpenGLFramebuffer& GetFramebuffer() const override; const OpenGLRenderPass& GetRenderPass() const override; diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.inl b/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.inl index ba24c776a..25c95ac05 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.inl +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.inl @@ -3,10 +3,16 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include namespace Nz { + inline GL::Context& OpenGLRenderWindow::GetContext() + { + assert(m_context); + return *m_context; + } } #include diff --git a/include/Nazara/OpenGLRenderer/Utils.hpp b/include/Nazara/OpenGLRenderer/Utils.hpp index 593c59f9a..55f1d6cff 100644 --- a/include/Nazara/OpenGLRenderer/Utils.hpp +++ b/include/Nazara/OpenGLRenderer/Utils.hpp @@ -16,10 +16,13 @@ namespace Nz { + inline GLenum ToOpenGL(BlendFunc blendFunc); + inline GLenum ToOpenGL(FaceSide filter); inline GLenum ToOpenGL(SamplerFilter filter); inline GLenum ToOpenGL(SamplerFilter minFilter, SamplerMipmapMode mipmapFilter); inline GLenum ToOpenGL(SamplerWrap wrapMode); inline GLenum ToOpenGL(ShaderStageType stageType); + inline GLenum ToOpenGL(StencilOperation stencilOp); inline GLenum ToOpenGL(GL::BufferTarget bufferTarget); inline GLenum ToOpenGL(GL::TextureTarget bufferTarget); diff --git a/include/Nazara/OpenGLRenderer/Utils.inl b/include/Nazara/OpenGLRenderer/Utils.inl index 890b2f88e..6d64a18ec 100644 --- a/include/Nazara/OpenGLRenderer/Utils.inl +++ b/include/Nazara/OpenGLRenderer/Utils.inl @@ -10,7 +10,61 @@ namespace Nz { - GLenum ToOpenGL(SamplerFilter filter) + inline GLenum ToOpenGL(BlendFunc blendFunc) + { + switch (blendFunc) + { + case BlendFunc_DestAlpha: return GL_DST_ALPHA; + case BlendFunc_DestColor: return GL_DST_COLOR; + case BlendFunc_SrcAlpha: return GL_SRC_ALPHA; + case BlendFunc_SrcColor: return GL_SRC_COLOR; + case BlendFunc_InvDestAlpha: return GL_ONE_MINUS_DST_ALPHA; + case BlendFunc_InvDestColor: return GL_ONE_MINUS_DST_COLOR; + case BlendFunc_InvSrcAlpha: return GL_ONE_MINUS_SRC_ALPHA; + case BlendFunc_InvSrcColor: return GL_ONE_MINUS_SRC_COLOR; + case BlendFunc_One: return GL_ONE; + case BlendFunc_Zero: return GL_ZERO; + } + + NazaraError("Unhandled BlendFunc 0x" + String::Number(UnderlyingCast(blendFunc), 16)); + return {}; + } + + inline GLenum ToOpenGL(FaceSide filter) + { + switch (filter) + { + case FaceSide_None: + break; + + case FaceSide_Back: return GL_BACK; + case FaceSide_Front: return GL_FRONT; + case FaceSide_FrontAndBack: return GL_FRONT_AND_BACK; + } + + NazaraError("Unhandled FaceSide 0x" + String::Number(UnderlyingCast(filter), 16)); + return {}; + } + + inline GLenum ToOpenGL(RendererComparison comparison) + { + switch (comparison) + { + case RendererComparison_Always: return GL_ALWAYS; + case RendererComparison_Equal: return GL_EQUAL; + case RendererComparison_Greater: return GL_GREATER; + case RendererComparison_GreaterOrEqual: return GL_GEQUAL; + case RendererComparison_Less: return GL_LESS; + case RendererComparison_LessOrEqual: return GL_LEQUAL; + case RendererComparison_Never: return GL_NEVER; + case RendererComparison_NotEqual: return GL_NOTEQUAL; + } + + NazaraError("Unhandled RendererComparison 0x" + String::Number(UnderlyingCast(comparison), 16)); + return {}; + } + + inline GLenum ToOpenGL(SamplerFilter filter) { switch (filter) { @@ -22,7 +76,7 @@ namespace Nz return {}; } - GLenum ToOpenGL(SamplerFilter minFilter, SamplerMipmapMode mipmapFilter) + inline GLenum ToOpenGL(SamplerFilter minFilter, SamplerMipmapMode mipmapFilter) { switch (minFilter) { @@ -55,7 +109,7 @@ namespace Nz return {}; } - GLenum ToOpenGL(SamplerWrap wrapMode) + inline GLenum ToOpenGL(SamplerWrap wrapMode) { switch (wrapMode) { @@ -68,7 +122,7 @@ namespace Nz return {}; } - GLenum ToOpenGL(ShaderStageType stageType) + inline GLenum ToOpenGL(ShaderStageType stageType) { switch (stageType) { @@ -80,7 +134,25 @@ namespace Nz return {}; } - GLenum ToOpenGL(GL::BufferTarget bufferTarget) + inline GLenum ToOpenGL(StencilOperation stencilOp) + { + switch (stencilOp) + { + case StencilOperation_Decrement: return GL_DECR; + case StencilOperation_DecrementNoClamp: return GL_DECR_WRAP; + case StencilOperation_Increment: return GL_INCR; + case StencilOperation_IncrementNoClamp: return GL_INCR_WRAP; + case StencilOperation_Invert: return GL_INVERT; + case StencilOperation_Keep: return GL_KEEP; + case StencilOperation_Replace: return GL_REPLACE; + case StencilOperation_Zero: return GL_ZERO; + } + + NazaraError("Unhandled StencilOperation 0x" + String::Number(UnderlyingCast(stencilOp), 16)); + return {}; + } + + inline GLenum ToOpenGL(GL::BufferTarget bufferTarget) { switch (bufferTarget) { @@ -98,7 +170,7 @@ namespace Nz return {}; } - GLenum ToOpenGL(GL::TextureTarget textureTarget) + inline GLenum ToOpenGL(GL::TextureTarget textureTarget) { switch (textureTarget) { diff --git a/include/Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp b/include/Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp index 8898ea174..1996b8e4f 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/CoreFunctions.hpp @@ -23,6 +23,7 @@ typedef void (GL_APIENTRYP PFNGLSPECIALIZESHADERARBPROC) (GLuint shader, const G cb(glBeginQuery, PFNGLBEGINQUERYPROC) \ cb(glBindAttribLocation, PFNGLBINDATTRIBLOCATIONPROC) \ cb(glBindBuffer, PFNGLBINDBUFFERPROC) \ + cb(glBindBufferRange, PFNGLBINDBUFFERRANGEPROC) \ cb(glBindFramebuffer, PFNGLBINDFRAMEBUFFERPROC) \ cb(glBindRenderbuffer, PFNGLBINDRENDERBUFFERPROC) \ cb(glBindSampler, PFNGLBINDSAMPLERPROC) \ @@ -43,9 +44,10 @@ typedef void (GL_APIENTRYP PFNGLSPECIALIZESHADERARBPROC) (GLuint shader, const G cb(glColorMask, PFNGLCOLORMASKPROC) \ cb(glCompressedTexSubImage2D, PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) \ cb(glCompressedTexSubImage3D, PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) \ - cb(glCullFace, PFNGLCULLFACEPROC) \ cb(glCompileShader, PFNGLCOMPILESHADERPROC) \ + cb(glCopyBufferSubData, PFNGLCOPYBUFFERSUBDATAPROC) \ cb(glCopyTexSubImage2D, PFNGLCOPYTEXSUBIMAGE2DPROC) \ + cb(glCullFace, PFNGLCULLFACEPROC) \ cb(glDeleteBuffers, PFNGLDELETEBUFFERSPROC) \ cb(glDeleteFramebuffers, PFNGLDELETEFRAMEBUFFERSPROC) \ cb(glDeleteProgram, PFNGLDELETEPROGRAMPROC) \ @@ -123,7 +125,9 @@ typedef void (GL_APIENTRYP PFNGLSPECIALIZESHADERARBPROC) (GLuint shader, const G cb(glTexImage2D, PFNGLTEXIMAGE2DPROC) \ cb(glTexImage3D, PFNGLTEXIMAGE3DPROC) \ cb(glTexParameterf, PFNGLTEXPARAMETERFPROC) \ + cb(glTexParameterfv, PFNGLTEXPARAMETERFVPROC) \ cb(glTexParameteri, PFNGLTEXPARAMETERIPROC) \ + cb(glTexParameteriv, PFNGLTEXPARAMETERIVPROC) \ cb(glTexStorage2D, PFNGLTEXSTORAGE2DPROC) \ cb(glTexStorage3D, PFNGLTEXSTORAGE3DPROC) \ cb(glTexSubImage2D, PFNGLTEXSUBIMAGE2DPROC) \ diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Program.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Program.hpp index 5bdae0efc..6acc1eb7b 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Program.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Program.hpp @@ -4,8 +4,8 @@ #pragma once -#ifndef NAZARA_OPENGLRENDERER_GLSHADER_HPP -#define NAZARA_OPENGLRENDERER_GLSHADER_HPP +#ifndef NAZARA_OPENGLRENDERER_GLPROGRAM_HPP +#define NAZARA_OPENGLRENDERER_GLPROGRAM_HPP #include #include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Texture.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Texture.hpp index 1e6198146..12b3e5c08 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Texture.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Texture.hpp @@ -24,6 +24,11 @@ namespace Nz::GL Texture(Texture&&) noexcept = default; ~Texture() = default; + inline void SetParameterf(GLenum pname, GLfloat param); + inline void SetParameteri(GLenum pname, GLint param); + inline void SetParameterfv(GLenum pname, const GLfloat* param); + inline void SetParameteriv(GLenum pname, const GLint* param); + inline void TexImage2D(GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border); inline void TexImage2D(GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* data); inline void TexSubImage2D(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* data); diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Texture.inl b/include/Nazara/OpenGLRenderer/Wrapper/Texture.inl index 14ef42866..b63dcb0fe 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Texture.inl +++ b/include/Nazara/OpenGLRenderer/Wrapper/Texture.inl @@ -8,6 +8,38 @@ namespace Nz::GL { + inline void Texture::SetParameterf(GLenum pname, GLfloat param) + { + assert(m_objectId); + + const Context& context = EnsureDeviceContext(); + context.glTexParameterf(m_objectId, pname, param); + } + + inline void Texture::SetParameteri(GLenum pname, GLint param) + { + assert(m_objectId); + + const Context& context = EnsureDeviceContext(); + context.glTexParameteri(m_objectId, pname, param); + } + + inline void Texture::SetParameterfv(GLenum pname, const GLfloat* param) + { + assert(m_objectId); + + const Context& context = EnsureDeviceContext(); + context.glTexParameterfv(m_objectId, pname, param); + } + + inline void Texture::SetParameteriv(GLenum pname, const GLint* param) + { + assert(m_objectId); + + const Context& context = EnsureDeviceContext(); + context.glTexParameteriv(m_objectId, pname, param); + } + inline void Texture::TexImage2D(GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border) { return TexImage2D(level, internalFormat, width, height, border, GL_RGB, GL_UNSIGNED_BYTE, nullptr); diff --git a/include/Nazara/Renderer/RenderBufferView.hpp b/include/Nazara/Renderer/RenderBufferView.hpp index f653866eb..4f606b630 100644 --- a/include/Nazara/Renderer/RenderBufferView.hpp +++ b/include/Nazara/Renderer/RenderBufferView.hpp @@ -18,7 +18,7 @@ namespace Nz public: inline RenderBufferView(AbstractBuffer* buffer); inline RenderBufferView(AbstractBuffer* buffer, UInt64 offset, UInt64 size); - RenderBufferView(const RenderBufferView&) = delete; + RenderBufferView(const RenderBufferView&) = default; RenderBufferView(RenderBufferView&&) = default; ~RenderBufferView() = default; @@ -26,7 +26,7 @@ namespace Nz inline UInt64 GetOffset() const; inline UInt64 GetSize() const; - RenderBufferView& operator=(const RenderBufferView&) = delete; + RenderBufferView& operator=(const RenderBufferView&) = default; RenderBufferView& operator=(RenderBufferView&&) = default; private: diff --git a/include/Nazara/Renderer/UploadPool.hpp b/include/Nazara/Renderer/UploadPool.hpp index 85368e413..5127a192d 100644 --- a/include/Nazara/Renderer/UploadPool.hpp +++ b/include/Nazara/Renderer/UploadPool.hpp @@ -41,7 +41,6 @@ namespace Nz Allocation& operator=(Allocation&&) = default; void* mappedPtr; - UInt64 offset; UInt64 size; }; }; diff --git a/include/Nazara/VulkanRenderer/Utils.inl b/include/Nazara/VulkanRenderer/Utils.inl index a843b67f5..616680324 100644 --- a/include/Nazara/VulkanRenderer/Utils.inl +++ b/include/Nazara/VulkanRenderer/Utils.inl @@ -10,7 +10,7 @@ namespace Nz { - VkBufferUsageFlags ToVulkan(BufferType bufferType) + inline VkBufferUsageFlags ToVulkan(BufferType bufferType) { switch (bufferType) { @@ -23,7 +23,7 @@ namespace Nz return 0; } - VkFormat ToVulkan(ComponentType componentType) + inline VkFormat ToVulkan(ComponentType componentType) { switch (componentType) { @@ -47,7 +47,7 @@ namespace Nz return VK_FORMAT_UNDEFINED; } - VkCullModeFlagBits ToVulkan(FaceSide faceSide) + inline VkCullModeFlagBits ToVulkan(FaceSide faceSide) { switch (faceSide) { @@ -74,7 +74,7 @@ namespace Nz return VK_POLYGON_MODE_FILL; } - VkPrimitiveTopology ToVulkan(PrimitiveMode primitiveMode) + inline VkPrimitiveTopology ToVulkan(PrimitiveMode primitiveMode) { switch (primitiveMode) { @@ -108,7 +108,7 @@ namespace Nz return VK_COMPARE_OP_NEVER; } - VkFilter ToVulkan(SamplerFilter samplerFilter) + inline VkFilter ToVulkan(SamplerFilter samplerFilter) { switch (samplerFilter) { @@ -120,7 +120,7 @@ namespace Nz return VK_FILTER_NEAREST; } - VkSamplerMipmapMode ToVulkan(SamplerMipmapMode samplerMipmap) + inline VkSamplerMipmapMode ToVulkan(SamplerMipmapMode samplerMipmap) { switch (samplerMipmap) { @@ -132,7 +132,7 @@ namespace Nz return VK_SAMPLER_MIPMAP_MODE_NEAREST; } - VkSamplerAddressMode ToVulkan(SamplerWrap samplerWrap) + inline VkSamplerAddressMode ToVulkan(SamplerWrap samplerWrap) { switch (samplerWrap) { @@ -145,7 +145,7 @@ namespace Nz return VK_SAMPLER_ADDRESS_MODE_REPEAT; } - VkDescriptorType ToVulkan(ShaderBindingType bindingType) + inline VkDescriptorType ToVulkan(ShaderBindingType bindingType) { switch (bindingType) { @@ -157,7 +157,7 @@ namespace Nz return VK_DESCRIPTOR_TYPE_SAMPLER; } - VkShaderStageFlagBits ToVulkan(ShaderStageType stageType) + inline VkShaderStageFlagBits ToVulkan(ShaderStageType stageType) { switch (stageType) { @@ -169,7 +169,7 @@ namespace Nz return {}; } - VkShaderStageFlags ToVulkan(ShaderStageTypeFlags stageType) + inline VkShaderStageFlags ToVulkan(ShaderStageTypeFlags stageType) { VkShaderStageFlags shaderStageBits = 0; @@ -184,7 +184,7 @@ namespace Nz return shaderStageBits; } - VkStencilOp ToVulkan(StencilOperation stencilOp) + inline VkStencilOp ToVulkan(StencilOperation stencilOp) { switch (stencilOp) { @@ -202,7 +202,7 @@ namespace Nz return VK_STENCIL_OP_KEEP; } - VkVertexInputRate ToVulkan(VertexInputRate inputRate) + inline VkVertexInputRate ToVulkan(VertexInputRate inputRate) { switch (inputRate) { diff --git a/include/Nazara/VulkanRenderer/VulkanUploadPool.hpp b/include/Nazara/VulkanRenderer/VulkanUploadPool.hpp index b2ff27dba..fc8c9daf5 100644 --- a/include/Nazara/VulkanRenderer/VulkanUploadPool.hpp +++ b/include/Nazara/VulkanRenderer/VulkanUploadPool.hpp @@ -23,6 +23,7 @@ namespace Nz struct VulkanAllocation : Allocation { VkBuffer buffer; + UInt64 offset; }; inline VulkanUploadPool(Vk::Device& device, UInt64 blockSize); diff --git a/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp b/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp index 333d5d424..4590e144e 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -25,7 +26,10 @@ namespace Nz m_contexts.insert(m_referenceContext.get()); } - OpenGLDevice::~OpenGLDevice() = default; + OpenGLDevice::~OpenGLDevice() + { + m_referenceContext.reset(); + } std::unique_ptr OpenGLDevice::CreateContext(const GL::ContextParams& params) const { @@ -55,7 +59,7 @@ namespace Nz std::unique_ptr OpenGLDevice::InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) { - return {}; + return std::make_unique(*this, std::move(pipelineInfo)); } std::shared_ptr OpenGLDevice::InstantiateRenderPipelineLayout(RenderPipelineLayoutInfo pipelineLayoutInfo) diff --git a/src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp b/src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp index 9799a9dca..317c8d0ff 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -11,7 +12,8 @@ namespace Nz { OpenGLRenderWindow::OpenGLRenderWindow() : - m_currentFrame(0) + m_currentFrame(0), + m_framebuffer(*this) { } @@ -33,12 +35,18 @@ namespace Nz if (!m_context) return false; + constexpr std::size_t RenderImageCount = 2; + + m_renderImage.reserve(RenderImageCount); + for (std::size_t i = 0; i < RenderImageCount; ++i) + m_renderImage.emplace_back(*this); + return true; } std::unique_ptr OpenGLRenderWindow::CreateCommandPool(QueueType queueType) { - return {}; + return std::make_unique(); } const OpenGLFramebuffer& OpenGLRenderWindow::GetFramebuffer() const diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp index e4344b3be..9b9adff90 100644 --- a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp +++ b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp @@ -49,6 +49,19 @@ namespace Nz::GL } } + void Context::BindFramebuffer(FramebufferTarget target, GLuint fbo) const + { + auto& currentFbo = (target == FramebufferTarget::Draw) ? m_state.boundDrawFBO : m_state.boundReadFBO; + if (currentFbo != fbo) + { + if (!SetCurrentContext(this)) + throw std::runtime_error("failed to activate context"); + + glBindFramebuffer((target == FramebufferTarget::Draw) ? GL_DRAW_FRAMEBUFFER : GL_READ_FRAMEBUFFER, fbo); + currentFbo = fbo; + } + } + void Context::BindSampler(UInt32 textureUnit, GLuint sampler) const { if (textureUnit >= m_state.textureUnits.size()) From fe5b70ae1cfd62c94e83e41caa1d68ef4c3f989e Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 11 May 2020 14:10:36 +0200 Subject: [PATCH 185/316] OpenGL: Implement VAOs --- .../Nazara/OpenGLRenderer/OpenGLVaoCache.hpp | 73 +++++++++++++++ .../Nazara/OpenGLRenderer/OpenGLVaoCache.inl | 81 +++++++++++++++++ .../OpenGLRenderer/Wrapper/ContextObject.hpp | 51 +++++++++++ .../OpenGLRenderer/Wrapper/ContextObject.inl | 88 +++++++++++++++++++ .../OpenGLRenderer/Wrapper/VertexArray.hpp | 44 +++++----- .../OpenGLRenderer/Wrapper/VertexArray.inl | 39 +++++--- src/Nazara/OpenGLRenderer/OpenGLVaoCache.cpp | 78 ++++++++++++++++ .../Wrapper/Win32/WGLContext.cpp | 1 + 8 files changed, 422 insertions(+), 33 deletions(-) create mode 100644 include/Nazara/OpenGLRenderer/OpenGLVaoCache.hpp create mode 100644 include/Nazara/OpenGLRenderer/OpenGLVaoCache.inl create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/ContextObject.hpp create mode 100644 include/Nazara/OpenGLRenderer/Wrapper/ContextObject.inl create mode 100644 src/Nazara/OpenGLRenderer/OpenGLVaoCache.cpp diff --git a/include/Nazara/OpenGLRenderer/OpenGLVaoCache.hpp b/include/Nazara/OpenGLRenderer/OpenGLVaoCache.hpp new file mode 100644 index 000000000..0a9bc14d1 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLVaoCache.hpp @@ -0,0 +1,73 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_OPENGLVAOCACHE_HPP +#define NAZARA_OPENGLRENDERER_OPENGLVAOCACHE_HPP + +#include +#include +#include +#include +#include +#include +#include + +namespace Nz::GL +{ + struct OpenGLVaoSetup + { + struct Attribs + { + GLuint vertexBuffer; + GLint size; + GLenum type; + GLboolean normalized; + GLsizei stride; + const void* pointer; + }; + + GLuint indexBuffer = 0; + std::array, 16> vertexAttribs; + + inline friend bool operator==(const OpenGLVaoSetup& lhs, const OpenGLVaoSetup& rhs); + }; + + struct OpenGLVaoSetupHasher + { + inline std::size_t operator()(const OpenGLVaoSetup& setup) const; + }; + + class Context; + class VertexArray; + + class NAZARA_OPENGLRENDERER_API OpenGLVaoCache + { + friend Context; + + public: + OpenGLVaoCache(Context& owner); + OpenGLVaoCache(const OpenGLVaoCache&) = delete; + OpenGLVaoCache(OpenGLVaoCache&&) = delete; + ~OpenGLVaoCache(); + + void Clear(); + + const VertexArray& Get(const OpenGLVaoSetup& setup) const; + + OpenGLVaoCache& operator=(const OpenGLVaoCache&) = delete; + OpenGLVaoCache& operator=(OpenGLVaoCache&&) = delete; + + private: + void NotifyBufferDestruction(GLuint buffer); + + mutable std::unordered_map, OpenGLVaoSetupHasher> m_vertexArrays; + Context& m_context; + }; +} + +#include + +#endif diff --git a/include/Nazara/OpenGLRenderer/OpenGLVaoCache.inl b/include/Nazara/OpenGLRenderer/OpenGLVaoCache.inl new file mode 100644 index 000000000..07a08dc12 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/OpenGLVaoCache.inl @@ -0,0 +1,81 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz::GL +{ + inline bool operator==(const OpenGLVaoSetup& lhs, const OpenGLVaoSetup& rhs) + { + if (lhs.indexBuffer != rhs.indexBuffer) + return false; + + const auto& compareAttribs = [](const auto& lAttribOpt, const auto& rAttribOpt) + { + if (lAttribOpt.has_value() != rAttribOpt.has_value()) + return false; + + if (lAttribOpt) + { + const auto& lAttrib = *lAttribOpt; + const auto& rAttrib = *rAttribOpt; + + if (lAttrib.vertexBuffer != rAttrib.vertexBuffer) + return false; + + if (lAttrib.size != rAttrib.size) + return false; + + if (lAttrib.type != rAttrib.type) + return false; + + if (lAttrib.normalized != rAttrib.normalized) + return false; + + if (lAttrib.stride != rAttrib.stride) + return false; + + if (lAttrib.pointer != rAttrib.pointer) + return false; + } + + + return true; + }; + + return std::equal(lhs.vertexAttribs.begin(), lhs.vertexAttribs.end(), rhs.vertexAttribs.begin(), compareAttribs); + } + + inline std::size_t OpenGLVaoSetupHasher::operator()(const OpenGLVaoSetup& setup) const + { + std::size_t seed = 0; + + HashCombine(seed, setup.indexBuffer); + + std::size_t bindingIndex = 0; + for (const auto& attribOpt : setup.vertexAttribs) + { + if (attribOpt) + { + const auto& attrib = attribOpt.value(); + + HashCombine(seed, bindingIndex); + HashCombine(seed, attrib.vertexBuffer); + HashCombine(seed, attrib.size); + HashCombine(seed, attrib.type); + HashCombine(seed, attrib.normalized); + HashCombine(seed, attrib.stride); + HashCombine(seed, attrib.pointer); + } + + bindingIndex++; + } + + return seed; + } +} + +#include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/ContextObject.hpp b/include/Nazara/OpenGLRenderer/Wrapper/ContextObject.hpp new file mode 100644 index 000000000..cc5d0d4af --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/ContextObject.hpp @@ -0,0 +1,51 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_OPENGLRENDERER_GLCONTEXTOBJECT_HPP +#define NAZARA_OPENGLRENDERER_GLCONTEXTOBJECT_HPP + +#include +#include +#include +#include + +namespace Nz::GL +{ + template + class ContextObject + { + public: + ContextObject() = default; + ContextObject(const ContextObject&) = delete; + ContextObject(ContextObject&& object) noexcept = default; + ~ContextObject(); + + bool Create(const Context& context, CreateArgs... args); + void Destroy(); + + bool IsValid() const; + + const Context* GetContext() const; + GLuint GetObjectId() const; + + void SetDebugName(const std::string_view& name); + + ContextObject& operator=(const ContextObject&) = delete; + ContextObject& operator=(ContextObject&& object) noexcept = default; + + static constexpr GLuint InvalidObject = 0; + + protected: + void EnsureContext(); + + MovablePtr m_context; + MovableValue m_objectId; + }; +} + +#include + +#endif diff --git a/include/Nazara/OpenGLRenderer/Wrapper/ContextObject.inl b/include/Nazara/OpenGLRenderer/Wrapper/ContextObject.inl new file mode 100644 index 000000000..a48a71a94 --- /dev/null +++ b/include/Nazara/OpenGLRenderer/Wrapper/ContextObject.inl @@ -0,0 +1,88 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include + +namespace Nz::GL +{ + template + ContextObject::~ContextObject() + { + Destroy(); + } + + template + bool ContextObject::Create(const Context& context, CreateArgs... args) + { + Destroy(); + + m_context = &context; + + EnsureContext(); + + m_objectId = C::CreateHelper(*m_context, args...); + if (m_objectId == InvalidObject) + { + NazaraError("Failed to create OpenGL object"); //< TODO: Handle error message + return false; + } + + return true; + } + + template + void ContextObject::Destroy() + { + if (IsValid()) + { + EnsureContext(); + + C::DestroyHelper(*m_context, m_objectId); + m_objectId = InvalidObject; + } + } + + template + bool ContextObject::IsValid() const + { + return m_objectId != InvalidObject; + } + + template + const Context* ContextObject::GetContext() const + { + return m_context.Get(); + } + + template + GLuint ContextObject::GetObjectId() const + { + return m_objectId; + } + + template + void ContextObject::SetDebugName(const std::string_view& name) + { + EnsureContext(); + + if (m_context->glObjectLabel) + m_context->glObjectLabel(ObjectType, m_objectId, name.size(), name.data()); + } + + template + void ContextObject::EnsureContext() + { + const Context* activeContext = Context::GetCurrentContext(); + if (activeContext != m_context.Get()) + { + if (!Context::SetCurrentContext(m_context.Get())) + throw std::runtime_error("failed to activate context"); + } + } +} + +#include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/VertexArray.hpp b/include/Nazara/OpenGLRenderer/Wrapper/VertexArray.hpp index df762b109..6adcee7e1 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/VertexArray.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/VertexArray.hpp @@ -4,36 +4,36 @@ #pragma once -#ifndef NAZARA_OPENGLRENDERER_VKIMAGEVIEW_HPP -#define NAZARA_OPENGLRENDERER_VKIMAGEVIEW_HPP +#ifndef NAZARA_OPENGLRENDERER_GLVERTEXARRAY_HPP +#define NAZARA_OPENGLRENDERER_GLVERTEXARRAY_HPP #include -#include +#include -namespace Nz +namespace Nz::GL { - namespace Vk + class VertexArray : public ContextObject { - class ImageView : public DeviceObject - { - friend DeviceObject; + friend ContextObject; - public: - ImageView() = default; - ImageView(const ImageView&) = delete; - ImageView(ImageView&&) = default; - ~ImageView() = default; + public: + VertexArray(const VertexArray&) = delete; + VertexArray(VertexArray&&) = default; + ~VertexArray() = default; - ImageView& operator=(const ImageView&) = delete; - ImageView& operator=(ImageView&&) = delete; + VertexArray& operator=(const VertexArray&) = delete; + VertexArray& operator=(VertexArray&&) = delete; - private: - static inline VkResult CreateHelper(Device& device, const VkImageViewCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkImageView* handle); - static inline void DestroyHelper(Device& device, VkImageView handle, const VkAllocationCallbacks* allocator); - }; - } + template static VertexArray Build(const Context& context, F&& callback); + + private: + VertexArray() = default; + + static inline GLuint CreateHelper(const Context& context); + static inline void DestroyHelper(const Context& context, GLuint objectId); + }; } -#include +#include -#endif // NAZARA_OPENGLRENDERER_VKIMAGEVIEW_HPP +#endif diff --git a/include/Nazara/OpenGLRenderer/Wrapper/VertexArray.inl b/include/Nazara/OpenGLRenderer/Wrapper/VertexArray.inl index 29ae8e968..91bbe698b 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/VertexArray.inl +++ b/include/Nazara/OpenGLRenderer/Wrapper/VertexArray.inl @@ -2,22 +2,39 @@ // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include +#include #include -namespace Nz +namespace Nz::GL { - namespace Vk + template + static VertexArray VertexArray::Build(const Context& context, F&& callback) { - inline VkResult ImageView::CreateHelper(Device& device, const VkImageViewCreateInfo* createInfo, const VkAllocationCallbacks* allocator, VkImageView* handle) - { - return device.vkCreateImageView(device, createInfo, allocator, handle); - } + VertexArray vao; + if (!vao.Create(context)) + throw std::runtime_error("failed to create vao"); - inline void ImageView::DestroyHelper(Device& device, VkImageView handle, const VkAllocationCallbacks* allocator) - { - return device.vkDestroyImageView(device, handle, allocator); - } + context.BindVertexArray(vao.GetObjectId(), true); + callback(); + context.BindVertexArray(0, true); + + return vao; + } + + inline GLuint VertexArray::CreateHelper(const Context& context) + { + GLuint vao = 0; + context.glGenVertexArrays(1U, &vao); + + return vao; + } + + inline void VertexArray::DestroyHelper(const Context& context, GLuint objectId) + { + context.glDeleteVertexArrays(1U, &objectId); + + context.NotifyVertexArrayDestruction(objectId); } } diff --git a/src/Nazara/OpenGLRenderer/OpenGLVaoCache.cpp b/src/Nazara/OpenGLRenderer/OpenGLVaoCache.cpp new file mode 100644 index 000000000..8602d70c2 --- /dev/null +++ b/src/Nazara/OpenGLRenderer/OpenGLVaoCache.cpp @@ -0,0 +1,78 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - OpenGL Renderer" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz::GL +{ + OpenGLVaoCache::OpenGLVaoCache(Context& context) : + m_context(context) + { + } + + OpenGLVaoCache::~OpenGLVaoCache() = default; + + void OpenGLVaoCache::Clear() + { + m_vertexArrays.clear(); + } + + const VertexArray& OpenGLVaoCache::Get(const OpenGLVaoSetup& setup) const + { + auto it = m_vertexArrays.find(setup); + if (it == m_vertexArrays.end()) + { + VertexArray vao = VertexArray::Build(m_context, [&] + { + if (setup.indexBuffer != 0) + m_context.BindBuffer(BufferTarget::ElementArray, setup.indexBuffer, true); + + std::size_t bindingIndex = 0; + for (const auto& attribOpt : setup.vertexAttribs) + { + if (attribOpt) + { + const auto& attrib = attribOpt.value(); + + assert(attrib.vertexBuffer != 0); + m_context.BindBuffer(BufferTarget::Array, attrib.vertexBuffer, true); + + m_context.glEnableVertexAttribArray(bindingIndex); + m_context.glVertexAttribPointer(bindingIndex, attrib.size, attrib.type, attrib.normalized, attrib.stride, attrib.pointer); + } + + bindingIndex++; + } + }); + + it = m_vertexArrays.emplace(setup, std::make_unique(std::move(vao))).first; + } + + return *it->second; + } + + void OpenGLVaoCache::NotifyBufferDestruction(GLuint buffer) + { + for (auto it = m_vertexArrays.begin(); it != m_vertexArrays.end();) + { + const OpenGLVaoSetup& setup = it->first; + + // If a VAO is based on at least one of these buffers, delete it + auto FindVertexBuffer = [&](const auto& attribOpt) + { + if (!attribOpt) + return false; + + return attribOpt->vertexBuffer == buffer; + }; + + if (setup.indexBuffer == buffer || std::any_of(setup.vertexAttribs.begin(), setup.vertexAttribs.end(), FindVertexBuffer)) + it = m_vertexArrays.erase(it); + else + ++it; + } + } +} diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp index 8f056bc62..1593cef1c 100644 --- a/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp +++ b/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp @@ -48,6 +48,7 @@ namespace Nz::GL { if (m_handle) { + OnContextRelease(); NotifyContextDestruction(this); m_loader.wglDeleteContext(m_handle); From 6a23d51147bfbe8c422068673e33d8cb05080ee2 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 11 May 2020 14:12:13 +0200 Subject: [PATCH 186/316] OpenGL: Implement commands buffers --- .../OpenGLRenderer/OpenGLCommandBuffer.hpp | 118 ++++++++++++++- .../OpenGLRenderer/OpenGLCommandBuffer.inl | 114 +++++++++++++++ .../OpenGLCommandBufferBuilder.hpp | 9 +- .../OpenGLCommandBufferBuilder.inl | 4 + .../OpenGLRenderer/OpenGLCommandPool.hpp | 7 +- .../OpenGLRenderer/OpenGLCommandPool.inl | 15 -- .../OpenGLRenderer/OpenGLRenderImage.hpp | 1 + .../OpenGLRenderPipelineLayout.hpp | 4 + .../OpenGLRenderer/OpenGLShaderBinding.hpp | 3 + .../OpenGLRenderer/OpenGLShaderStage.hpp | 2 + .../OpenGLRenderer/OpenGLShaderStage.inl | 4 + .../Nazara/OpenGLRenderer/Wrapper/Context.hpp | 32 ++++- .../Nazara/OpenGLRenderer/Wrapper/Context.inl | 15 +- .../OpenGLRenderer/OpenGLCommandBuffer.cpp | 136 +++++++++++++++++- .../OpenGLCommandBufferBuilder.cpp | 113 ++------------- .../OpenGLRenderer/OpenGLCommandPool.cpp | 29 +--- .../OpenGLRenderer/OpenGLRenderImage.cpp | 9 ++ .../OpenGLRenderer/OpenGLShaderBinding.cpp | 50 +++++++ src/Nazara/OpenGLRenderer/Wrapper/Context.cpp | 118 ++++++++++++++- 19 files changed, 621 insertions(+), 162 deletions(-) diff --git a/include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.hpp b/include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.hpp index a597a2958..fc80a9ada 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.hpp @@ -8,22 +8,138 @@ #define NAZARA_OPENGLRENDERER_OPENGLCOMMANDBUFFER_HPP #include +#include +#include #include +#include #include +#include +#include +#include +#include +#include #include namespace Nz { + class OpenGLFramebuffer; + class NAZARA_OPENGLRENDERER_API OpenGLCommandBuffer final : public CommandBuffer { public: - inline OpenGLCommandBuffer(); + OpenGLCommandBuffer() = default; OpenGLCommandBuffer(const OpenGLCommandBuffer&) = delete; OpenGLCommandBuffer(OpenGLCommandBuffer&&) noexcept = default; ~OpenGLCommandBuffer() = default; + inline void BeginDebugRegion(const std::string_view& regionName, const Nz::Color& color); + + inline void BindIndexBuffer(GLuint indexBuffer, UInt64 offset = 0); + inline void BindPipeline(const OpenGLRenderPipeline* pipeline); + inline void BindShaderBinding(const OpenGLShaderBinding* binding); + inline void BindVertexBuffer(UInt32 binding, GLuint vertexBuffer, UInt64 offset = 0); + + inline void CopyBuffer(GLuint source, GLuint target, UInt64 size, UInt64 sourceOffset = 0, UInt64 targetOffset = 0); + inline void CopyBuffer(const UploadPool::Allocation& allocation, GLuint target, UInt64 size, UInt64 sourceOffset = 0, UInt64 targetOffset = 0); + + inline void Draw(UInt32 vertexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0); + inline void DrawIndexed(UInt32 indexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0); + + inline void EndDebugRegion(); + + void Execute(); + + inline void SetFramebuffer(const OpenGLFramebuffer& framebuffer, const RenderPass& renderPass, std::initializer_list clearValues); + inline void SetScissor(Nz::Recti scissorRegion); + inline void SetViewport(Nz::Recti viewportRegion); + OpenGLCommandBuffer& operator=(const OpenGLCommandBuffer&) = delete; OpenGLCommandBuffer& operator=(OpenGLCommandBuffer&&) = delete; + + private: + struct DrawStates; + + void ApplyStates(const GL::Context& context, const DrawStates& states); + + struct BeginDebugRegionData + { + std::string regionName; + Nz::Color color; + }; + + struct CopyBufferData + { + GLuint source; + GLuint target; + UInt64 size; + UInt64 sourceOffset; + UInt64 targetOffset; + }; + + struct CopyBufferFromMemoryData + { + const void* memory; + GLuint target; + UInt64 size; + UInt64 targetOffset; + }; + + struct DrawStates + { + struct VertexBuffer + { + GLuint vertexBuffer = 0; + UInt64 offset; + }; + + GLuint indexBuffer = 0; + const OpenGLRenderPipeline* pipeline = nullptr; + const OpenGLShaderBinding* shaderBindings = nullptr; + UInt64 indexBufferOffset; + std::optional scissorRegion; + std::optional viewportRegion; + std::vector vertexBuffers; + }; + + struct DrawData + { + DrawStates states; + UInt32 firstInstance; + UInt32 firstVertex; + UInt32 instanceCount; + UInt32 vertexCount; + }; + + struct DrawIndexedData + { + DrawStates states; + UInt32 firstInstance; + UInt32 firstVertex; + UInt32 indexCount; + UInt32 instanceCount; + }; + + struct EndDebugRegionData + { + }; + + struct SetFrameBufferData + { + const OpenGLFramebuffer* framebuffer; + }; + + using CommandData = std::variant< + BeginDebugRegionData, + CopyBufferData, + CopyBufferFromMemoryData, + DrawData, + DrawIndexedData, + EndDebugRegionData, + SetFrameBufferData + >; + + DrawStates m_currentStates; + std::vector m_commands; }; } diff --git a/include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.inl b/include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.inl index 7ccd4573a..892550d8e 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.inl +++ b/include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.inl @@ -3,10 +3,124 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include +#include #include namespace Nz { + inline void OpenGLCommandBuffer::BeginDebugRegion(const std::string_view& regionName, const Nz::Color& color) + { + BeginDebugRegionData beginDebugRegion; + beginDebugRegion.color = color; + beginDebugRegion.regionName = regionName; + + m_commands.emplace_back(std::move(beginDebugRegion)); + } + + inline void OpenGLCommandBuffer::BindIndexBuffer(GLuint indexBuffer, UInt64 offset) + { + m_currentStates.indexBuffer = indexBuffer; + m_currentStates.indexBufferOffset = offset; + } + + inline void OpenGLCommandBuffer::BindPipeline(const OpenGLRenderPipeline* pipeline) + { + m_currentStates.pipeline = pipeline; + } + + inline void OpenGLCommandBuffer::BindShaderBinding(const OpenGLShaderBinding* binding) + { + m_currentStates.shaderBindings = binding; + } + + inline void OpenGLCommandBuffer::BindVertexBuffer(UInt32 binding, GLuint vertexBuffer, UInt64 offset) + { + if (binding >= m_currentStates.vertexBuffers.size()) + m_currentStates.vertexBuffers.resize(binding + 1); + + auto& vertexBufferData = m_currentStates.vertexBuffers[binding]; + vertexBufferData.offset = offset; + vertexBufferData.vertexBuffer = vertexBuffer; + } + + inline void OpenGLCommandBuffer::CopyBuffer(GLuint source, GLuint target, UInt64 size, UInt64 sourceOffset, UInt64 targetOffset) + { + CopyBufferData copyBuffer = { + source, + target, + size, + sourceOffset, + targetOffset + }; + + m_commands.emplace_back(std::move(copyBuffer)); + } + + inline void OpenGLCommandBuffer::CopyBuffer(const UploadPool::Allocation& allocation, GLuint target, UInt64 size, UInt64 sourceOffset, UInt64 targetOffset) + { + CopyBufferFromMemoryData copyBuffer = { + static_cast(allocation.mappedPtr) + sourceOffset, + target, + size, + targetOffset + }; + + m_commands.emplace_back(std::move(copyBuffer)); + } + + inline void OpenGLCommandBuffer::Draw(UInt32 vertexCount, UInt32 instanceCount, UInt32 firstVertex, UInt32 firstInstance) + { + if (!m_currentStates.pipeline) + throw std::runtime_error("no pipeline bound"); + + DrawData draw; + draw.states = m_currentStates; + draw.firstInstance = firstInstance; + draw.firstVertex = firstVertex; + draw.instanceCount = instanceCount; + draw.vertexCount = vertexCount; + + m_commands.emplace_back(std::move(draw)); + } + + inline void OpenGLCommandBuffer::DrawIndexed(UInt32 indexCount, UInt32 instanceCount, UInt32 firstVertex, UInt32 firstInstance) + { + if (!m_currentStates.pipeline) + throw std::runtime_error("no pipeline bound"); + + DrawIndexedData draw; + draw.states = m_currentStates; + draw.firstInstance = firstInstance; + draw.firstVertex = firstVertex; + draw.indexCount = indexCount; + draw.instanceCount = instanceCount; + + m_commands.emplace_back(std::move(draw)); + } + + inline void OpenGLCommandBuffer::EndDebugRegion() + { + m_commands.emplace_back(EndDebugRegionData{}); + } + + inline void OpenGLCommandBuffer::SetFramebuffer(const OpenGLFramebuffer& framebuffer, const RenderPass& /*renderPass*/, std::initializer_list clearValues) + { + SetFrameBufferData setFramebuffer; + setFramebuffer.framebuffer = &framebuffer; + + m_commands.emplace_back(std::move(setFramebuffer)); + } + + inline void OpenGLCommandBuffer::SetScissor(Nz::Recti scissorRegion) + { + m_currentStates.scissorRegion = scissorRegion; + } + + inline void OpenGLCommandBuffer::SetViewport(Nz::Recti viewportRegion) + { + m_currentStates.viewportRegion = viewportRegion; + } } #include diff --git a/include/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.hpp b/include/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.hpp index dc50b94d6..14199c665 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.hpp @@ -13,12 +13,12 @@ namespace Nz { - class OpenGLRenderPass; + class OpenGLCommandBuffer; class NAZARA_OPENGLRENDERER_API OpenGLCommandBufferBuilder final : public CommandBufferBuilder { public: - OpenGLCommandBufferBuilder() = default; + inline OpenGLCommandBufferBuilder(OpenGLCommandBuffer& commandBuffer); OpenGLCommandBufferBuilder(const OpenGLCommandBufferBuilder&) = delete; OpenGLCommandBufferBuilder(OpenGLCommandBufferBuilder&&) noexcept = default; ~OpenGLCommandBufferBuilder() = default; @@ -48,9 +48,12 @@ namespace Nz OpenGLCommandBufferBuilder& operator=(const OpenGLCommandBufferBuilder&) = delete; OpenGLCommandBufferBuilder& operator=(OpenGLCommandBufferBuilder&&) = delete; + + private: + OpenGLCommandBuffer& m_commandBuffer; }; } #include -#endif // NAZARA_OPENGLRENDERER_OPENGLCOMMANDBUFFERBUILDER_HPP +#endif diff --git a/include/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.inl b/include/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.inl index 8649e54e2..54d7f17c4 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.inl +++ b/include/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.inl @@ -7,6 +7,10 @@ namespace Nz { + inline OpenGLCommandBufferBuilder::OpenGLCommandBufferBuilder(OpenGLCommandBuffer& commandBuffer) : + m_commandBuffer(commandBuffer) + { + } } #include diff --git a/include/Nazara/OpenGLRenderer/OpenGLCommandPool.hpp b/include/Nazara/OpenGLRenderer/OpenGLCommandPool.hpp index fa68f0ac4..bc79593b9 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLCommandPool.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLCommandPool.hpp @@ -10,15 +10,13 @@ #include #include #include -#include namespace Nz { class NAZARA_OPENGLRENDERER_API OpenGLCommandPool final : public CommandPool { public: - inline OpenGLCommandPool(Vk::Device& device, QueueType queueType); - inline OpenGLCommandPool(Vk::Device& device, UInt32 queueFamilyIndex); + OpenGLCommandPool() = default; OpenGLCommandPool(const OpenGLCommandPool&) = delete; OpenGLCommandPool(OpenGLCommandPool&&) noexcept = default; ~OpenGLCommandPool() = default; @@ -27,9 +25,6 @@ namespace Nz OpenGLCommandPool& operator=(const OpenGLCommandPool&) = delete; OpenGLCommandPool& operator=(OpenGLCommandPool&&) = delete; - - private: - Vk::CommandPool m_commandPool; }; } diff --git a/include/Nazara/OpenGLRenderer/OpenGLCommandPool.inl b/include/Nazara/OpenGLRenderer/OpenGLCommandPool.inl index a8db6b7f3..3da51fb3b 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLCommandPool.inl +++ b/include/Nazara/OpenGLRenderer/OpenGLCommandPool.inl @@ -8,21 +8,6 @@ namespace Nz { - inline OpenGLCommandPool::OpenGLCommandPool(Vk::Device& device, QueueType queueType) - { - UInt32 queueFamilyIndex = device.GetDefaultFamilyIndex(queueType); - if (queueFamilyIndex == Vk::Device::InvalidQueue) - throw std::runtime_error("QueueType " + std::to_string(UnderlyingCast(queueType)) + " is not supported"); - - if (!m_commandPool.Create(device, queueFamilyIndex)) - throw std::runtime_error("Failed to create command pool: " + TranslateOpenGLError(m_commandPool.GetLastErrorCode())); - } - - inline OpenGLCommandPool::OpenGLCommandPool(Vk::Device& device, UInt32 queueFamilyIndex) - { - if (!m_commandPool.Create(device, queueFamilyIndex)) - throw std::runtime_error("Failed to create command pool: " + TranslateOpenGLError(m_commandPool.GetLastErrorCode())); - } } #include diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderImage.hpp b/include/Nazara/OpenGLRenderer/OpenGLRenderImage.hpp index def3104e2..2c8507e7f 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLRenderImage.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderImage.hpp @@ -14,6 +14,7 @@ namespace Nz { + class OpenGLCommandBuffer; class OpenGLRenderWindow; class NAZARA_OPENGLRENDERER_API OpenGLRenderImage : public RenderImage diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.hpp b/include/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.hpp index 2107d9379..30ceb101c 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.hpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -53,12 +54,15 @@ namespace Nz struct TextureDescriptor { + UInt32 bindingIndex; GLuint texture; GLuint sampler; + GL::TextureTarget textureTarget; }; struct UniformBufferDescriptor { + UInt32 bindingIndex; GLuint buffer; GLintptr offset; GLsizeiptr size; diff --git a/include/Nazara/OpenGLRenderer/OpenGLShaderBinding.hpp b/include/Nazara/OpenGLRenderer/OpenGLShaderBinding.hpp index d920c2929..f74cc904d 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLShaderBinding.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLShaderBinding.hpp @@ -9,6 +9,7 @@ #include #include +#include #include namespace Nz @@ -23,6 +24,8 @@ namespace Nz OpenGLShaderBinding(OpenGLShaderBinding&&) noexcept = default; ~OpenGLShaderBinding() = default; + void Apply(const GL::Context& context) const; + inline std::size_t GetBindingIndex() const; inline std::size_t GetPoolIndex() const; inline const OpenGLRenderPipelineLayout& GetOwner() const; diff --git a/include/Nazara/OpenGLRenderer/OpenGLShaderStage.hpp b/include/Nazara/OpenGLRenderer/OpenGLShaderStage.hpp index 579704ffe..f72f282ad 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLShaderStage.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLShaderStage.hpp @@ -24,6 +24,8 @@ namespace Nz OpenGLShaderStage(OpenGLShaderStage&&) noexcept = default; ~OpenGLShaderStage() = default; + inline const GL::Shader& GetShader() const; + OpenGLShaderStage& operator=(const OpenGLShaderStage&) = delete; OpenGLShaderStage& operator=(OpenGLShaderStage&&) noexcept = default; diff --git a/include/Nazara/OpenGLRenderer/OpenGLShaderStage.inl b/include/Nazara/OpenGLRenderer/OpenGLShaderStage.inl index 305f1968a..6d1ccb62f 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLShaderStage.inl +++ b/include/Nazara/OpenGLRenderer/OpenGLShaderStage.inl @@ -7,6 +7,10 @@ namespace Nz { + inline const GL::Shader& OpenGLShaderStage::GetShader() const + { + return m_shader; + } } #include diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp index ae0fd627f..1c648054e 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Context.hpp @@ -9,7 +9,9 @@ #include #include +#include #include +#include #include #include #include @@ -94,17 +96,21 @@ namespace Nz::GL inline Context(const OpenGLDevice* device); virtual ~Context(); - void BindBuffer(BufferTarget target, GLuint buffer) const; + void BindBuffer(BufferTarget target, GLuint buffer, bool force = false) const; void BindFramebuffer(GLuint fbo) const; void BindFramebuffer(FramebufferTarget target, GLuint fbo) const; + void BindProgram(GLuint program) const; void BindSampler(UInt32 textureUnit, GLuint sampler) const; void BindTexture(TextureTarget target, GLuint texture) const; void BindTexture(UInt32 textureUnit, TextureTarget target, GLuint texture) const; + void BindUniformBuffer(UInt32 uboUnit, GLuint buffer, GLintptr offset, GLsizeiptr size) const; + void BindVertexArray(GLuint vertexArray, bool force = false) const; virtual void EnableVerticalSync(bool enabled) = 0; inline const OpenGLDevice* GetDevice() const; inline ExtensionStatus GetExtensionStatus(Extension extension) const; + inline const OpenGLVaoCache& GetVaoCache() const; inline const ContextParams& GetParams() const; inline bool IsExtensionSupported(Extension extension) const; @@ -116,8 +122,11 @@ namespace Nz::GL inline void NotifyProgramDestruction(GLuint program) const; inline void NotifySamplerDestruction(GLuint sampler) const; inline void NotifyTextureDestruction(GLuint texture) const; + inline void NotifyVertexArrayDestruction(GLuint vao) const; - inline void SetCurrentTextureUnit(UInt32 textureUnit) const; + void SetCurrentTextureUnit(UInt32 textureUnit) const; + void SetScissorBox(GLint x, GLint y, GLsizei width, GLsizei height) const; + void SetViewport(GLint x, GLint y, GLsizei width, GLsizei height) const; virtual void SwapBuffers() = 0; @@ -134,6 +143,7 @@ namespace Nz::GL virtual bool Activate() const = 0; virtual void Desactivate() const = 0; virtual const Loader& GetLoader() = 0; + void OnContextRelease(); virtual bool ImplementFallback(const std::string_view& function); @@ -146,23 +156,41 @@ namespace Nz::GL struct State { + struct Box + { + GLint x, y; + GLsizei width, height; + }; + struct TextureUnit { GLuint sampler = 0; std::array textureTargets = { 0 }; }; + struct UniformBufferUnit + { + GLuint buffer = 0; + GLintptr offset = 0; + GLsizeiptr size = 0; + }; + std::array bufferTargets = { 0 }; std::vector textureUnits; + std::vector uboUnits; + Box scissorBox; + Box viewport; GLuint boundProgram = 0; GLuint boundDrawFBO = 0; GLuint boundReadFBO = 0; + GLuint boundVertexArray = 0; UInt32 currentTextureUnit = 0; RenderStates renderStates; }; std::array m_extensionStatus; std::unordered_set m_supportedExtensions; + OpenGLVaoCache m_vaoCache; const OpenGLDevice* m_device; mutable State m_state; }; diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Context.inl b/include/Nazara/OpenGLRenderer/Wrapper/Context.inl index bf2dbe86b..59c44805b 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Context.inl +++ b/include/Nazara/OpenGLRenderer/Wrapper/Context.inl @@ -8,6 +8,7 @@ namespace Nz::GL { inline Context::Context(const OpenGLDevice* device) : + m_vaoCache(*this), m_device(device) { } @@ -22,6 +23,11 @@ namespace Nz::GL return m_extensionStatus[UnderlyingCast(extension)]; } + inline const OpenGLVaoCache& Context::GetVaoCache() const + { + return m_vaoCache; + } + inline const ContextParams& Context::GetParams() const { return m_params; @@ -73,13 +79,10 @@ namespace Nz::GL } } - inline void Context::SetCurrentTextureUnit(UInt32 textureUnit) const + inline void Context::NotifyVertexArrayDestruction(GLuint vao) const { - if (m_state.currentTextureUnit != textureUnit) - { - glActiveTexture(GL_TEXTURE0 + textureUnit); - m_state.currentTextureUnit = textureUnit; - } + if (m_state.boundVertexArray == vao) + m_state.boundVertexArray = 0; } } diff --git a/src/Nazara/OpenGLRenderer/OpenGLCommandBuffer.cpp b/src/Nazara/OpenGLRenderer/OpenGLCommandBuffer.cpp index 41bf3f3b1..eac73f9ca 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLCommandBuffer.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLCommandBuffer.cpp @@ -2,13 +2,141 @@ // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#if 0 - #include +#include +#include +#include #include namespace Nz { -} + namespace + { + void BuildAttrib(GL::OpenGLVaoSetup::Attribs& attrib, ComponentType component) + { + switch (component) + { + case ComponentType_Color: + attrib.normalized = GL_TRUE; + attrib.size = 4; + attrib.type = GL_UNSIGNED_BYTE; + return; -#endif + case ComponentType_Float1: + case ComponentType_Float2: + case ComponentType_Float3: + case ComponentType_Float4: + attrib.normalized = GL_FALSE; + attrib.size = (component - ComponentType_Float1 + 1); + attrib.type = GL_FLOAT; + return; + + case ComponentType_Int1: + case ComponentType_Int2: + case ComponentType_Int3: + case ComponentType_Int4: + attrib.normalized = GL_FALSE; + attrib.size = (component - ComponentType_Int1 + 1); + attrib.type = GL_INT; + return; + + case ComponentType_Double1: + case ComponentType_Double2: + case ComponentType_Double3: + case ComponentType_Double4: + case ComponentType_Quaternion: + break; + } + + throw std::runtime_error(("component type 0x" + String::Number(component, 16) + " is not handled").ToStdString()); + } + } + + void OpenGLCommandBuffer::Execute() + { + const GL::Context* context = GL::Context::GetCurrentContext(); + + for (const auto& command : m_commands) + { + std::visit([&](auto&& command) + { + using T = std::decay_t; + + if constexpr (std::is_same_v || std::is_same_v) + { + // TODO + } + else if constexpr (std::is_same_v) + { + context->BindBuffer(GL::BufferTarget::CopyRead, command.source); + context->BindBuffer(GL::BufferTarget::CopyWrite, command.target); + context->glCopyBufferSubData(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, command.sourceOffset, command.targetOffset, command.size); + } + else if constexpr (std::is_same_v) + { + context->BindBuffer(GL::BufferTarget::CopyWrite, command.target); + context->glBufferSubData(GL_COPY_WRITE_BUFFER, command.targetOffset, command.size, command.memory); + } + else if constexpr (std::is_same_v) + { + ApplyStates(*context, m_currentStates); + context->glDrawArraysInstanced(GL_TRIANGLES, command.firstVertex, command.vertexCount, command.instanceCount); + } + else if constexpr (std::is_same_v) + { + ApplyStates(*context, m_currentStates); + context->glDrawElementsInstanced(GL_TRIANGLES, command.indexCount, GL_UNSIGNED_SHORT, nullptr, command.instanceCount); + } + else if constexpr (std::is_same_v) + { + command.framebuffer->Activate(); + + context = GL::Context::GetCurrentContext(); + context->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + } + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + + }, command); + } + } + + void OpenGLCommandBuffer::ApplyStates(const GL::Context& context, const DrawStates& states) + { + states.shaderBindings->Apply(context); + states.pipeline->Apply(context); + + if (states.scissorRegion) + context.SetScissorBox(states.scissorRegion->x, states.scissorRegion->y, states.scissorRegion->width, states.scissorRegion->height); + + if (states.viewportRegion) + context.SetViewport(states.viewportRegion->x, states.viewportRegion->y, states.viewportRegion->width, states.viewportRegion->height); + + GL::OpenGLVaoSetup vaoSetup; + vaoSetup.indexBuffer = states.indexBuffer; + + std::uint32_t locationIndex = 0; + const std::uint8_t* originPtr = 0; + + for (const auto& bufferData : states.pipeline->GetPipelineInfo().vertexBuffers) + { + assert(bufferData.binding < states.vertexBuffers.size()); + const auto& vertexBufferInfo = states.vertexBuffers[bufferData.binding]; + + GLsizei stride = GLsizei(bufferData.declaration->GetStride()); + + for (const auto& componentInfo : *bufferData.declaration) + { + auto& bufferAttribute = vaoSetup.vertexAttribs[locationIndex++].emplace(); + BuildAttrib(bufferAttribute, componentInfo.type); + + bufferAttribute.pointer = originPtr + vertexBufferInfo.offset + componentInfo.offset; + bufferAttribute.stride = stride; + bufferAttribute.vertexBuffer = vertexBufferInfo.vertexBuffer; + } + } + + const GL::VertexArray& vao = context.GetVaoCache().Get(vaoSetup); + context.BindVertexArray(vao.GetObjectId(), true); + } +} diff --git a/src/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.cpp b/src/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.cpp index 4e17054be..e10d0de22 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLCommandBufferBuilder.cpp @@ -2,16 +2,12 @@ // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#if 0 - #include #include -#include -#include +#include #include #include #include -#include #include #include #include @@ -20,112 +16,40 @@ namespace Nz { void OpenGLCommandBufferBuilder::BeginDebugRegion(const std::string_view& regionName, const Nz::Color& color) { - // Ensure \0 at the end of string - StackArray regionNameEOS = NazaraStackArrayNoInit(char, regionName.size() + 1); - std::memcpy(regionNameEOS.data(), regionName.data(), regionName.size()); - regionNameEOS[regionName.size()] = '\0'; - - m_commandBuffer.BeginDebugRegion(regionNameEOS.data(), color); + m_commandBuffer.BeginDebugRegion(regionName, color); } void OpenGLCommandBufferBuilder::BeginRenderPass(const Framebuffer& framebuffer, const RenderPass& renderPass, Nz::Recti renderRect, std::initializer_list clearValues) { - const OpenGLRenderPass& vkRenderPass = static_cast(renderPass); - - const Vk::Framebuffer& vkFramebuffer = [&] () -> const Vk::Framebuffer& - { - const OpenGLFramebuffer& vkFramebuffer = static_cast(framebuffer); - switch (vkFramebuffer.GetType()) - { - case OpenGLFramebuffer::Type::Multiple: - { - const OpenGLMultipleFramebuffer& vkMultipleFramebuffer = static_cast(vkFramebuffer); - m_framebufferCount = std::max(m_framebufferCount, vkMultipleFramebuffer.GetFramebufferCount()); - return vkMultipleFramebuffer.GetFramebuffer(m_imageIndex); - } - - case OpenGLFramebuffer::Type::Single: - return static_cast(vkFramebuffer).GetFramebuffer(); - } - - throw std::runtime_error("Unhandled framebuffer type " + std::to_string(UnderlyingCast(vkFramebuffer.GetType()))); - }(); - - VkRect2D renderArea; - renderArea.offset.x = renderRect.x; - renderArea.offset.y = renderRect.y; - renderArea.extent.width = renderRect.width; - renderArea.extent.height = renderRect.height; - - StackArray vkClearValues = NazaraStackArray(VkClearValue, clearValues.size()); - - std::size_t index = 0; - for (const ClearValues& values : clearValues) - { - auto& vkValues = vkClearValues[index]; - - if (PixelFormatInfo::GetContent(vkRenderPass.GetAttachmentFormat(index)) == PixelFormatContent_ColorRGBA) - { - vkValues.color.float32[0] = values.color.r / 255.f; - vkValues.color.float32[1] = values.color.g / 255.f; - vkValues.color.float32[2] = values.color.b / 255.f; - vkValues.color.float32[3] = values.color.a / 255.f; - } - else - { - vkValues.depthStencil.depth = values.depth; - vkValues.depthStencil.stencil = values.stencil; - } - - index++; - } - - VkRenderPassBeginInfo beginInfo = { VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO }; - beginInfo.renderPass = vkRenderPass.GetRenderPass(); - beginInfo.framebuffer = vkFramebuffer; - beginInfo.renderArea.offset.x = renderRect.x; - beginInfo.renderArea.offset.y = renderRect.y; - beginInfo.renderArea.extent.width = renderRect.width; - beginInfo.renderArea.extent.height = renderRect.height; - beginInfo.clearValueCount = vkClearValues.size(); - beginInfo.pClearValues = vkClearValues.data(); - - m_commandBuffer.BeginRenderPass(beginInfo); - - m_currentRenderPass = &vkRenderPass; + m_commandBuffer.SetFramebuffer(static_cast(framebuffer), renderPass, clearValues); } void OpenGLCommandBufferBuilder::BindIndexBuffer(Nz::AbstractBuffer* indexBuffer, UInt64 offset) { - OpenGLBuffer& vkBuffer = *static_cast(indexBuffer); + OpenGLBuffer* glBuffer = static_cast(indexBuffer); - m_commandBuffer.BindIndexBuffer(vkBuffer.GetBuffer(), offset, VK_INDEX_TYPE_UINT16); //< Fuck me right? + m_commandBuffer.BindIndexBuffer(glBuffer->GetBuffer().GetObjectId()); } void OpenGLCommandBufferBuilder::BindPipeline(const RenderPipeline& pipeline) { - if (!m_currentRenderPass) - throw std::runtime_error("BindPipeline must be called in a RenderPass"); + const OpenGLRenderPipeline& glPipeline = static_cast(pipeline); - const OpenGLRenderPipeline& vkBinding = static_cast(pipeline); - - m_commandBuffer.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, vkBinding.Get(m_currentRenderPass->GetRenderPass())); + m_commandBuffer.BindPipeline(&glPipeline); } void OpenGLCommandBufferBuilder::BindShaderBinding(const ShaderBinding& binding) { - const OpenGLShaderBinding& vkBinding = static_cast(binding); + const OpenGLShaderBinding& glBinding = static_cast(binding); - const OpenGLRenderPipelineLayout& pipelineLayout = vkBinding.GetOwner(); - - m_commandBuffer.BindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout.GetPipelineLayout(), 0U, vkBinding.GetDescriptorSet()); + m_commandBuffer.BindShaderBinding(&glBinding); } void OpenGLCommandBufferBuilder::BindVertexBuffer(UInt32 binding, Nz::AbstractBuffer* vertexBuffer, UInt64 offset) { - OpenGLBuffer& vkBuffer = *static_cast(vertexBuffer); + OpenGLBuffer* glBuffer = static_cast(vertexBuffer); - m_commandBuffer.BindVertexBuffer(binding, vkBuffer.GetBuffer(), offset); + m_commandBuffer.BindVertexBuffer(binding, glBuffer->GetBuffer().GetObjectId(), offset); } void OpenGLCommandBufferBuilder::CopyBuffer(const RenderBufferView& source, const RenderBufferView& target, UInt64 size, UInt64 sourceOffset, UInt64 targetOffset) @@ -133,15 +57,14 @@ namespace Nz OpenGLBuffer& sourceBuffer = *static_cast(source.GetBuffer()); OpenGLBuffer& targetBuffer = *static_cast(target.GetBuffer()); - m_commandBuffer.CopyBuffer(sourceBuffer.GetBuffer(), targetBuffer.GetBuffer(), size, sourceOffset + source.GetOffset(), targetOffset + target.GetOffset()); + m_commandBuffer.CopyBuffer(sourceBuffer.GetBuffer().GetObjectId(), targetBuffer.GetBuffer().GetObjectId(), size, sourceOffset + source.GetOffset(), targetOffset + target.GetOffset()); } void OpenGLCommandBufferBuilder::CopyBuffer(const UploadPool::Allocation& allocation, const RenderBufferView& target, UInt64 size, UInt64 sourceOffset, UInt64 targetOffset) { - const auto& vkAllocation = static_cast(allocation); OpenGLBuffer& targetBuffer = *static_cast(target.GetBuffer()); - m_commandBuffer.CopyBuffer(vkAllocation.buffer, targetBuffer.GetBuffer(), size, vkAllocation.offset + sourceOffset, target.GetOffset() + targetOffset); + m_commandBuffer.CopyBuffer(allocation, targetBuffer.GetBuffer().GetObjectId(), size, sourceOffset, target.GetOffset() + targetOffset); } void OpenGLCommandBufferBuilder::Draw(UInt32 vertexCount, UInt32 instanceCount, UInt32 firstVertex, UInt32 firstInstance) @@ -151,7 +74,7 @@ namespace Nz void OpenGLCommandBufferBuilder::DrawIndexed(UInt32 indexCount, UInt32 instanceCount, UInt32 firstVertex, UInt32 firstInstance) { - m_commandBuffer.DrawIndexed(indexCount, instanceCount, firstVertex, 0, firstInstance); + m_commandBuffer.DrawIndexed(indexCount, instanceCount, firstVertex, firstInstance); } void OpenGLCommandBufferBuilder::EndDebugRegion() @@ -161,18 +84,14 @@ namespace Nz void OpenGLCommandBufferBuilder::EndRenderPass() { - m_commandBuffer.EndRenderPass(); - m_currentRenderPass = nullptr; } void OpenGLCommandBufferBuilder::PreTransferBarrier() { - m_commandBuffer.MemoryBarrier(VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0U, VK_ACCESS_TRANSFER_READ_BIT); } void OpenGLCommandBufferBuilder::PostTransferBarrier() { - m_commandBuffer.MemoryBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_UNIFORM_READ_BIT); } void OpenGLCommandBufferBuilder::SetScissor(Nz::Recti scissorRegion) @@ -182,8 +101,6 @@ namespace Nz void OpenGLCommandBufferBuilder::SetViewport(Nz::Recti viewportRegion) { - m_commandBuffer.SetViewport(Nz::Rectf(viewportRegion), 0.f, 1.f); + m_commandBuffer.SetViewport(viewportRegion); } } - -#endif diff --git a/src/Nazara/OpenGLRenderer/OpenGLCommandPool.cpp b/src/Nazara/OpenGLRenderer/OpenGLCommandPool.cpp index 9e13ed935..90bfd3593 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLCommandPool.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLCommandPool.cpp @@ -2,41 +2,20 @@ // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp -#if 0 - #include #include #include -#include #include namespace Nz { std::unique_ptr OpenGLCommandPool::BuildCommandBuffer(const std::function& callback) { - std::vector commandBuffers; - auto BuildCommandBuffer = [&](std::size_t imageIndex) - { - Vk::AutoCommandBuffer& commandBuffer = commandBuffers.emplace_back(m_commandPool.AllocateCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY)); + std::unique_ptr commandBuffer = std::make_unique(); - if (!commandBuffer->Begin(VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT)) - throw std::runtime_error("failed to begin command buffer: " + TranslateOpenGLError(commandBuffer->GetLastErrorCode())); + OpenGLCommandBufferBuilder builder(*commandBuffer); + callback(builder); - OpenGLCommandBufferBuilder builder(commandBuffer.Get(), imageIndex); - callback(builder); - - if (!commandBuffer->End()) - throw std::runtime_error("failed to build command buffer: " + TranslateOpenGLError(commandBuffer->GetLastErrorCode())); - - return builder.GetMaxFramebufferCount(); - }; - - std::size_t maxFramebufferCount = BuildCommandBuffer(0); - for (std::size_t i = 1; i < maxFramebufferCount; ++i) - BuildCommandBuffer(i); - - return std::make_unique(std::move(commandBuffers)); + return commandBuffer; } } - -#endif diff --git a/src/Nazara/OpenGLRenderer/OpenGLRenderImage.cpp b/src/Nazara/OpenGLRenderer/OpenGLRenderImage.cpp index ee6d1500a..34946874b 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLRenderImage.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLRenderImage.cpp @@ -3,6 +3,8 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include +#include #include #include #include @@ -17,6 +19,11 @@ namespace Nz void OpenGLRenderImage::Execute(const std::function& callback, QueueTypeFlags queueTypeFlags) { + OpenGLCommandBuffer commandBuffer; + OpenGLCommandBufferBuilder builder(commandBuffer); + callback(builder); + + commandBuffer.Execute(); } OpenGLUploadPool& OpenGLRenderImage::GetUploadPool() @@ -26,6 +33,8 @@ namespace Nz void OpenGLRenderImage::SubmitCommandBuffer(CommandBuffer* commandBuffer, QueueTypeFlags queueTypeFlags) { + OpenGLCommandBuffer* oglCommandBuffer = static_cast(commandBuffer); + oglCommandBuffer->Execute(); } void OpenGLRenderImage::Present() diff --git a/src/Nazara/OpenGLRenderer/OpenGLShaderBinding.cpp b/src/Nazara/OpenGLRenderer/OpenGLShaderBinding.cpp index 371aa6248..b73dd76d2 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLShaderBinding.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLShaderBinding.cpp @@ -13,6 +13,29 @@ namespace Nz { + void OpenGLShaderBinding::Apply(const GL::Context& context) const + { + std::size_t textureDescriptorCount = m_owner.GetTextureDescriptorCount(); + std::size_t uniformBufferDescriptorCount = m_owner.GetUniformBufferDescriptorCount(); + + for (std::size_t i = 0; i < textureDescriptorCount; ++i) + { + const auto& textureDescriptor = m_owner.GetTextureDescriptor(m_poolIndex, m_bindingIndex, i); + + UInt32 textureIndex = textureDescriptor.bindingIndex; + + context.BindSampler(textureIndex, textureDescriptor.sampler); + context.BindTexture(textureIndex, textureDescriptor.textureTarget, textureDescriptor.texture); + } + + for (std::size_t i = 0; i < textureDescriptorCount; ++i) + { + const auto& uboDescriptor = m_owner.GetUniformBufferDescriptor(m_poolIndex, m_bindingIndex, i); + + context.BindUniformBuffer(uboDescriptor.bindingIndex, uboDescriptor.buffer, uboDescriptor.offset, uboDescriptor.size); + } + } + void OpenGLShaderBinding::Update(std::initializer_list bindings) { const auto& layoutInfo = m_owner.GetLayoutInfo(); @@ -43,8 +66,34 @@ namespace Nz OpenGLTextureSampler& glSampler = *static_cast(texBinding.sampler); auto& textureDescriptor = m_owner.GetTextureDescriptor(m_poolIndex, m_bindingIndex, resourceIndex); + textureDescriptor.bindingIndex = binding.bindingIndex; + textureDescriptor.texture = glTexture.GetTexture().GetObjectId(); textureDescriptor.sampler = glSampler.GetSampler(glTexture.GetLevelCount() > 1).GetObjectId(); + + switch (glTexture.GetType()) + { + case ImageType_2D: + textureDescriptor.textureTarget = GL::TextureTarget::Target2D; + break; + + case ImageType_2D_Array: + textureDescriptor.textureTarget = GL::TextureTarget::Target2D_Array; + break; + + case ImageType_3D: + textureDescriptor.textureTarget = GL::TextureTarget::Target3D; + break; + + case ImageType_Cubemap: + textureDescriptor.textureTarget = GL::TextureTarget::Cubemap; + break; + + case ImageType_1D: + case ImageType_1D_Array: + default: + throw std::runtime_error("unsupported texture type"); + } break; } @@ -60,6 +109,7 @@ namespace Nz throw std::runtime_error("expected uniform buffer"); auto& uboDescriptor = m_owner.GetUniformBufferDescriptor(m_poolIndex, m_bindingIndex, resourceIndex); + uboDescriptor.bindingIndex = binding.bindingIndex; uboDescriptor.buffer = glBuffer.GetBuffer().GetObjectId(); uboDescriptor.offset = uboBinding.offset; uboDescriptor.size = uboBinding.range; diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp index 9b9adff90..5d2c9f366 100644 --- a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp +++ b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp @@ -23,9 +23,9 @@ namespace Nz::GL m_device->NotifyContextDestruction(*this); } - void Context::BindBuffer(BufferTarget target, GLuint buffer) const + void Context::BindBuffer(BufferTarget target, GLuint buffer, bool force) const { - if (m_state.bufferTargets[UnderlyingCast(target)] != buffer) + if (m_state.bufferTargets[UnderlyingCast(target)] != buffer || force) { if (!SetCurrentContext(this)) throw std::runtime_error("failed to activate context"); @@ -62,6 +62,18 @@ namespace Nz::GL } } + void Context::BindProgram(GLuint program) const + { + if (m_state.boundProgram != program) + { + if (!SetCurrentContext(this)) + throw std::runtime_error("failed to activate context"); + + glUseProgram(program); + m_state.boundProgram = program; + } + } + void Context::BindSampler(UInt32 textureUnit, GLuint sampler) const { if (textureUnit >= m_state.textureUnits.size()) @@ -102,6 +114,37 @@ namespace Nz::GL } } + void Context::BindUniformBuffer(UInt32 uboUnit, GLuint buffer, GLintptr offset, GLsizeiptr size) const + { + if (uboUnit >= m_state.uboUnits.size()) + throw std::runtime_error("unsupported uniform buffer unit #" + std::to_string(uboUnit)); + + auto& unit = m_state.uboUnits[uboUnit]; + if (unit.buffer != buffer || unit.offset != offset || unit.size != size) + { + if (!SetCurrentContext(this)) + throw std::runtime_error("failed to activate context"); + + glBindBufferRange(GL_UNIFORM_BUFFER, uboUnit, buffer, offset, size); + + unit.buffer = buffer; + unit.offset = offset; + unit.size = size; + } + } + + void Context::BindVertexArray(GLuint vertexArray, bool force) const + { + if (m_state.boundVertexArray != vertexArray || force) + { + if (!SetCurrentContext(this)) + throw std::runtime_error("failed to activate context"); + + glBindVertexArray(vertexArray); + m_state.boundVertexArray = vertexArray; + } + } + bool Context::Initialize(const ContextParams& params) { if (!Activate()) @@ -220,9 +263,75 @@ namespace Nz::GL assert(maxTextureUnits > 0); m_state.textureUnits.resize(maxTextureUnits); + GLint maxUniformBufferUnits = -1; + glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &maxUniformBufferUnits); + if (maxUniformBufferUnits < 24) //< OpenGL ES 3.0 requires at least 24 uniform buffers units + NazaraWarning("GL_MAX_UNIFORM_BUFFER_BINDINGS is " + std::to_string(maxUniformBufferUnits) + ", >= 24 expected"); + + assert(maxUniformBufferUnits > 0); + m_state.uboUnits.resize(maxUniformBufferUnits); + + std::array res; + + glGetIntegerv(GL_SCISSOR_BOX, res.data()); + m_state.scissorBox = { res[0], res[1], res[2], res[3] }; + + glGetIntegerv(GL_VIEWPORT, res.data()); + m_state.viewport = { res[0], res[1], res[2], res[3] }; + return true; } + void Context::SetCurrentTextureUnit(UInt32 textureUnit) const + { + if (m_state.currentTextureUnit != textureUnit) + { + if (!SetCurrentContext(this)) + throw std::runtime_error("failed to activate context"); + + glActiveTexture(GL_TEXTURE0 + textureUnit); + m_state.currentTextureUnit = textureUnit; + } + } + + void Context::SetScissorBox(GLint x, GLint y, GLsizei width, GLsizei height) const + { + if (m_state.scissorBox.x != x || + m_state.scissorBox.y != y || + m_state.scissorBox.width != width || + m_state.scissorBox.height != height) + { + if (!SetCurrentContext(this)) + throw std::runtime_error("failed to activate context"); + + glScissor(x, y, width, height); + + m_state.scissorBox.x = x; + m_state.scissorBox.y = y; + m_state.scissorBox.width = width; + m_state.scissorBox.height = height; + } + } + + void Context::SetViewport(GLint x, GLint y, GLsizei width, GLsizei height) const + { + if (m_state.viewport.x != x || + m_state.viewport.y != y || + m_state.viewport.width != width || + m_state.viewport.height != height) + { + if (!SetCurrentContext(this)) + throw std::runtime_error("failed to activate context"); + + glViewport(x, y, width, height); + + m_state.viewport.x = x; + m_state.viewport.y = y; + m_state.viewport.width = width; + m_state.viewport.height = height; + } + } + void Context::UpdateStates(const RenderStates& renderStates) const { if (!SetCurrentContext(this)) @@ -402,6 +511,11 @@ namespace Nz::GL return true; } + void Context::OnContextRelease() + { + m_vaoCache.Clear(); + } + bool Context::ImplementFallback(const std::string_view& function) { const Loader& loader = GetLoader(); From 77186ba4564b164463555d76433b9ee8382b2fbc Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 11 May 2020 14:12:38 +0200 Subject: [PATCH 187/316] Update VulkanTest demo --- examples/VulkanTest/main.cpp | 18 ++++++++++++++++++ .../bin/resources/shaders/spirv-triangle.bat | 4 ++-- .../bin/resources/shaders/triangle.frag.spv | Bin 1296 -> 1296 bytes examples/bin/resources/shaders/triangle.vert | 1 + .../bin/resources/shaders/triangle.vert.spv | Bin 1640 -> 1912 bytes 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index 1411ac0ab..c777a65b2 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -3,6 +3,8 @@ #include #include +#define SPIRV 0 + int main() { Nz::Initializer loader; @@ -27,6 +29,7 @@ int main() std::shared_ptr device = window.GetRenderDevice(); +#if SPIRV auto fragmentShader = device->InstantiateShaderStage(Nz::ShaderStageType::Fragment, Nz::ShaderLanguage::SpirV, "resources/shaders/triangle.frag.spv"); if (!fragmentShader) { @@ -40,6 +43,21 @@ int main() std::cout << "Failed to instantiate fragment shader" << std::endl; return __LINE__; } +#else + auto fragmentShader = device->InstantiateShaderStage(Nz::ShaderStageType::Fragment, Nz::ShaderLanguage::GLSL, "resources/shaders/triangle.frag"); + if (!fragmentShader) + { + std::cout << "Failed to instantiate fragment shader" << std::endl; + return __LINE__; + } + + auto vertexShader = device->InstantiateShaderStage(Nz::ShaderStageType::Vertex, Nz::ShaderLanguage::GLSL, "resources/shaders/triangle.vert"); + if (!vertexShader) + { + std::cout << "Failed to instantiate fragment shader" << std::endl; + return __LINE__; + } +#endif Nz::MeshRef drfreak = Nz::Mesh::LoadFromFile("resources/Spaceship/spaceship.obj", meshParams); diff --git a/examples/bin/resources/shaders/spirv-triangle.bat b/examples/bin/resources/shaders/spirv-triangle.bat index 0459876df..af7bd2eda 100644 --- a/examples/bin/resources/shaders/spirv-triangle.bat +++ b/examples/bin/resources/shaders/spirv-triangle.bat @@ -1,3 +1,3 @@ -glslangvalidator -V triangle.vert -o triangle.vert.spv -glslangvalidator -V triangle.frag -o triangle.frag.spv +glslangvalidator -V triangle.vert -o triangle.vert.spv --client opengl100 +glslangvalidator -V triangle.frag -o triangle.frag.spv --client opengl100 diff --git a/examples/bin/resources/shaders/triangle.frag.spv b/examples/bin/resources/shaders/triangle.frag.spv index 31ec5000f7bdb18687d5c03d343ffa25591f85d6..855cf613abcacf778f7aa6a6e5a9c4483ac84a76 100644 GIT binary patch delta 23 ecmbQhHGzwhnMs+Qfq{{MV;ydk delta 23 ecmbQhHGzwhnMs+Qfq{{MaUy3tBm2h8 zR(QGqMc5duA!43+#U+V($*G<$o3ApuGs?O%uz;0w1EpDk7{muD1@YN7OEMp3j1>h6 z83DNpKnw!fP`)vc%?QK_K)wl(W(Hz5DBluDgXF}4*cvDg;)7fT5`*zU)-Z0q$h(X5N0=0sSGy`IgTs@R;4i$sxvjFmu_1OU(0}=zN`wO(x0*C>@ C3LwD% delta 54 zcmeyt_kxF)nMs+Qfq@YSIT(y4@|rSoPjuGYSdzoInTN@RadQFl0mjV}SX&r5{sNU) G05JePoeSCk From db0b2ba27b61d6022a95bb0d7977b3f1587ecca8 Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Sun, 17 May 2020 22:21:21 +0200 Subject: [PATCH 189/316] Fix warning -Wreorder on linux in SimpleTextDrawer --- include/Nazara/Utility/SimpleTextDrawer.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Nazara/Utility/SimpleTextDrawer.inl b/include/Nazara/Utility/SimpleTextDrawer.inl index a203bfa8e..fddb6b893 100644 --- a/include/Nazara/Utility/SimpleTextDrawer.inl +++ b/include/Nazara/Utility/SimpleTextDrawer.inl @@ -24,11 +24,11 @@ namespace Nz inline SimpleTextDrawer::SimpleTextDrawer(const SimpleTextDrawer& drawer) : m_color(drawer.m_color), + m_outlineColor(drawer.m_outlineColor), m_text(drawer.m_text), m_style(drawer.m_style), m_colorUpdated(false), m_glyphUpdated(false), - m_outlineColor(drawer.m_outlineColor), m_characterSpacingOffset(drawer.m_characterSpacingOffset), m_lineSpacingOffset(drawer.m_lineSpacingOffset), m_maxLineWidth(drawer.m_maxLineWidth), From 6ffbfd99412f55d20f74a1864de909762810a79b Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 18 May 2020 13:57:10 +0200 Subject: [PATCH 190/316] Allow examples to setup their own includes/libs --- build/scripts/common.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/build/scripts/common.lua b/build/scripts/common.lua index aca8527eb..29c230d8e 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -298,16 +298,19 @@ function NazaraBuild:Execute() debugdir(destPath) includedirs({ "../include", - "../thirdparty/include" + "../thirdparty/include", + exampleTable.Includes + }) + libdirs({ + "../lib", + exampleTable.LibDir }) - libdirs("../lib") files(exampleTable.Files) excludes(exampleTable.FilesExcluded) defines(exampleTable.Defines) flags(exampleTable.Flags) - includedirs(exampleTable.Includes) links(exampleTable.Libraries) targetdir(destPath) From 8d8f44f4b9469e305eed907879825d90051888ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Mon, 18 May 2020 17:04:52 +0200 Subject: [PATCH 191/316] Make Windows implementation DPI-Aware (+ fix issue with window position) (#322) * WindowImpl : Fix windows centering on desktop * WindowImpl : Make nazara DPI aware * Refactor dpi stuff * Minor aesthetic stuff * More minor stuff Co-authored-by: HardCPP --- src/Nazara/Platform/Win32/WindowImpl.cpp | 60 ++++++++++++++++++++++-- src/Nazara/Platform/Win32/WindowImpl.hpp | 2 + 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/src/Nazara/Platform/Win32/WindowImpl.cpp b/src/Nazara/Platform/Win32/WindowImpl.cpp index 6ee3365ac..a8f8a91aa 100644 --- a/src/Nazara/Platform/Win32/WindowImpl.cpp +++ b/src/Nazara/Platform/Win32/WindowImpl.cpp @@ -5,6 +5,7 @@ // Un grand merci à Laurent Gomila pour la SFML qui m'aura bien aidé à réaliser cette implémentation #include +#include #include #include #include @@ -61,7 +62,7 @@ namespace Nz bool async = (style & WindowStyle_Threaded) != 0; bool fullscreen = (style & WindowStyle_Fullscreen) != 0; DWORD win32Style, win32StyleEx; - unsigned int x, y; + int x, y; unsigned int width = mode.width; unsigned int height = mode.height; if (fullscreen) @@ -117,8 +118,14 @@ namespace Nz width = rect.right-rect.left; height = rect.bottom-rect.top; - x = (GetSystemMetrics(SM_CXSCREEN) - width)/2; - y = (GetSystemMetrics(SM_CYSCREEN) - height)/2; + + // Grab desktop rect in order to center our window on the main display + // TODO: Handle multiple displays + RECT desktopRect; + GetClientRect(GetDesktopWindow(), &desktopRect); + + x = (desktopRect.right / 2) - (width / 2); + y = (desktopRect.bottom / 2) - (height / 2); } m_callback = 0; @@ -939,6 +946,9 @@ namespace Nz bool WindowImpl::Initialize() { + if (!SetProcessDpiAware()) + NazaraWarning("failed to make process DPI-aware"); + // Nous devons faire un type Unicode pour que la fenêtre le soit également // http://msdn.microsoft.com/en-us/library/windows/desktop/ms633574(v=vs.85).aspx WNDCLASSW windowClass; @@ -961,6 +971,50 @@ namespace Nz UnregisterClassW(className, GetModuleHandle(nullptr)); } + bool WindowImpl::SetProcessDpiAware() + { + // MSDN : https://docs.microsoft.com/en-us/windows/win32/hidpi/setting-the-default-dpi-awareness-for-a-process + // This will work only for windows Vista & above + + HINSTANCE shcoreLib = LoadLibraryW(L"SHCore.dll"); + if (shcoreLib) + { + CallOnExit closeLibOnExit([&] { FreeLibrary(shcoreLib); }); + + /// shellscalingapi.h + enum PROCESS_DPI_AWARENESS + { + PROCESS_DPI_UNAWARE, + PROCESS_SYSTEM_DPI_AWARE, + PROCESS_PER_MONITOR_DPI_AWARE + }; + + using SetProcessDpiAwarenessFunc = HRESULT (WINAPI*)(PROCESS_DPI_AWARENESS); + auto SetProcessDpiAwareness = reinterpret_cast(GetProcAddress(shcoreLib, "SetProcessDpiAwareness")); + + if (SetProcessDpiAwareness) + { + HRESULT result = SetProcessDpiAwareness(PROCESS_SYSTEM_DPI_AWARE); + + if (result == S_OK || result == E_ACCESSDENIED) //< E_ACCESSDENIED means it has already been set, probably by the .exe manifest + return true; + } + } + + // If SetProcessDpiAwareness doesn't exist, we call old user32 function + HMODULE user32 = GetModuleHandleW(L"user32.dll"); + if (!user32) + return false; //< Shouldn't happen as user32 is linked + + using SetProcessDPIAwareFunc = BOOL (WINAPI*)(); + auto SetProcessDPIAware = reinterpret_cast(GetProcAddress(user32, "SetProcessDPIAware")); + + if (!SetProcessDPIAware || !SetProcessDPIAware()) + return false; + + return true; + } + Keyboard::Key WindowImpl::ConvertVirtualKey(WPARAM key, LPARAM flags) { switch (key) diff --git a/src/Nazara/Platform/Win32/WindowImpl.hpp b/src/Nazara/Platform/Win32/WindowImpl.hpp index e05a86fdf..668108032 100644 --- a/src/Nazara/Platform/Win32/WindowImpl.hpp +++ b/src/Nazara/Platform/Win32/WindowImpl.hpp @@ -84,6 +84,8 @@ namespace Nz bool HandleMessage(HWND window, UINT message, WPARAM wParam, LPARAM lParam); void PrepareWindow(bool fullscreen); + static bool SetProcessDpiAware(); + static Keyboard::Key ConvertVirtualKey(WPARAM key, LPARAM flags); static LRESULT CALLBACK MessageHandler(HWND window, UINT message, WPARAM wParam, LPARAM lParam); static UInt32 RetrieveStyle(HWND window); From 8c0d34313ee4e4286d0c27e910a1d53f379696c0 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 18 May 2020 19:55:00 +0200 Subject: [PATCH 192/316] GlslWriter: Fix bug --- src/Nazara/Renderer/GlslWriter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Renderer/GlslWriter.cpp b/src/Nazara/Renderer/GlslWriter.cpp index 3d023993c..1c0752b85 100644 --- a/src/Nazara/Renderer/GlslWriter.cpp +++ b/src/Nazara/Renderer/GlslWriter.cpp @@ -245,7 +245,7 @@ namespace Nz break; case ShaderAst::ExpressionType::Float4: - Append("vec4(" + String::Number(node.values.vec4.x) + ", " + String::Number(node.values.vec4.y) + ", " + String::Number(node.values.vec4.z) + ", " + String::Number(node.values.vec4.z) + ")"); + Append("vec4(" + String::Number(node.values.vec4.x) + ", " + String::Number(node.values.vec4.y) + ", " + String::Number(node.values.vec4.z) + ", " + String::Number(node.values.vec4.w) + ")"); break; default: From c26f3b9b71b114e4ad3fc41d4c2a3cc3f55ee3f4 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 18 May 2020 19:55:12 +0200 Subject: [PATCH 193/316] Add shadernode (big WIP) --- .gitignore | 3 +- build/scripts/tools/shadernodes.lua | 42 ++++++ src/ShaderNode/DataModels/FragmentOutput.cpp | 44 +++++++ src/ShaderNode/DataModels/FragmentOutput.hpp | 31 +++++ src/ShaderNode/DataModels/FragmentOutput.inl | 1 + src/ShaderNode/DataModels/ShaderNode.cpp | 1 + src/ShaderNode/DataModels/ShaderNode.hpp | 17 +++ src/ShaderNode/DataModels/ShaderNode.inl | 1 + src/ShaderNode/DataModels/VecValue.cpp | 34 +++++ src/ShaderNode/DataModels/VecValue.hpp | 66 ++++++++++ src/ShaderNode/DataModels/VecValue.inl | 44 +++++++ src/ShaderNode/main.cpp | 127 +++++++++++++++++++ 12 files changed, 410 insertions(+), 1 deletion(-) create mode 100644 build/scripts/tools/shadernodes.lua create mode 100644 src/ShaderNode/DataModels/FragmentOutput.cpp create mode 100644 src/ShaderNode/DataModels/FragmentOutput.hpp create mode 100644 src/ShaderNode/DataModels/FragmentOutput.inl create mode 100644 src/ShaderNode/DataModels/ShaderNode.cpp create mode 100644 src/ShaderNode/DataModels/ShaderNode.hpp create mode 100644 src/ShaderNode/DataModels/ShaderNode.inl create mode 100644 src/ShaderNode/DataModels/VecValue.cpp create mode 100644 src/ShaderNode/DataModels/VecValue.hpp create mode 100644 src/ShaderNode/DataModels/VecValue.inl create mode 100644 src/ShaderNode/main.cpp diff --git a/.gitignore b/.gitignore index af2c0073f..2a1c7ff50 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ # Nazara build build/config.lua -# Nazara libraries +# Nazara binaries +bin/* lib/* # Self-hosted thirdparty libraries binaries diff --git a/build/scripts/tools/shadernodes.lua b/build/scripts/tools/shadernodes.lua new file mode 100644 index 000000000..33f9628e9 --- /dev/null +++ b/build/scripts/tools/shadernodes.lua @@ -0,0 +1,42 @@ +TOOL.Name = "ShaderNodes" + +TOOL.ClientOnly = true +TOOL.EnableConsole = true +TOOL.Kind = "Application" +TOOL.TargetDirectory = "../bin" + +TOOL.Defines = { + "NODE_EDITOR_SHARED" +} + +TOOL.Includes = { + "../include", + "../extlibs/include", + "../src/ShaderNode", + [[E:\Qt\5.14.1\msvc2017_64\include]], + [[E:\Qt\5.14.1\msvc2017_64\include\QtCore]], + [[E:\Qt\5.14.1\msvc2017_64\include\QtGui]], + [[E:\Qt\5.14.1\msvc2017_64\include\QtWidgets]], + [[C:\Users\Lynix\Documents\GitHub\nodeeditor\include]], +} + +TOOL.Files = { + "../src/ShaderNode/**.hpp", + "../src/ShaderNode/**.inl", + "../src/ShaderNode/**.cpp" +} + +TOOL.Libraries = { + "NazaraCore", + "NazaraRenderer", + "NazaraUtility", + "Qt5Cored", + "Qt5Guid", + "Qt5Widgetsd", + "nodes" +} + +TOOL.LibraryPaths.x64 = { + [[E:\Qt\5.14.1\msvc2017_64\lib]], + [[C:\Users\Lynix\Documents\GitHub\nodeeditor\build\lib\Debug]] +} diff --git a/src/ShaderNode/DataModels/FragmentOutput.cpp b/src/ShaderNode/DataModels/FragmentOutput.cpp new file mode 100644 index 000000000..15244e0d8 --- /dev/null +++ b/src/ShaderNode/DataModels/FragmentOutput.cpp @@ -0,0 +1,44 @@ +#include +#include +#include + +Nz::ShaderAst::ExpressionPtr FragmentOutput::GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const +{ + using namespace Nz::ShaderAst; + using namespace Nz::ShaderBuilder; + + assert(count == 1); + + auto output = Nz::ShaderBuilder::Output("RenderTarget0", ExpressionType::Float4); + + return Nz::ShaderBuilder::Assign(output, *expressions); +} + +QtNodes::NodeDataType FragmentOutput::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const +{ + assert(portType == QtNodes::PortType::In); + assert(portIndex == 0); + + return Vec4Data::Type(); +} + +QWidget* FragmentOutput::embeddedWidget() +{ + return nullptr; +} + +unsigned int FragmentOutput::nPorts(QtNodes::PortType portType) const +{ + switch (portType) + { + case QtNodes::PortType::In: return 1; + case QtNodes::PortType::Out: return 0; + } + + return 0; +} + +std::shared_ptr FragmentOutput::outData(QtNodes::PortIndex /*port*/) +{ + return {}; +} diff --git a/src/ShaderNode/DataModels/FragmentOutput.hpp b/src/ShaderNode/DataModels/FragmentOutput.hpp new file mode 100644 index 000000000..30aa74b90 --- /dev/null +++ b/src/ShaderNode/DataModels/FragmentOutput.hpp @@ -0,0 +1,31 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_FRAGMENTOUTPUT_HPP +#define NAZARA_SHADERNODES_FRAGMENTOUTPUT_HPP + +#include +#include +#include + +class FragmentOutput : public ShaderNode +{ + public: + Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const override; + + QString caption() const override { return "Fragment shader output"; } + QString name() const override { return "FragmentShaderOutput"; } + + QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; + + QWidget* embeddedWidget() override; + unsigned int nPorts(QtNodes::PortType portType) const override; + + std::shared_ptr outData(QtNodes::PortIndex port) override; + + void setInData(std::shared_ptr, int) override {}; + +}; + +#include + +#endif diff --git a/src/ShaderNode/DataModels/FragmentOutput.inl b/src/ShaderNode/DataModels/FragmentOutput.inl new file mode 100644 index 000000000..f8287a921 --- /dev/null +++ b/src/ShaderNode/DataModels/FragmentOutput.inl @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/DataModels/ShaderNode.cpp b/src/ShaderNode/DataModels/ShaderNode.cpp new file mode 100644 index 000000000..fba232649 --- /dev/null +++ b/src/ShaderNode/DataModels/ShaderNode.cpp @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/DataModels/ShaderNode.hpp b/src/ShaderNode/DataModels/ShaderNode.hpp new file mode 100644 index 000000000..5c8f6e7f8 --- /dev/null +++ b/src/ShaderNode/DataModels/ShaderNode.hpp @@ -0,0 +1,17 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_SHADERNODE_HPP +#define NAZARA_SHADERNODES_SHADERNODE_HPP + +#include +#include + +class ShaderNode : public QtNodes::NodeDataModel +{ + public: + virtual Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const = 0; +}; + +#include + +#endif diff --git a/src/ShaderNode/DataModels/ShaderNode.inl b/src/ShaderNode/DataModels/ShaderNode.inl new file mode 100644 index 000000000..fba232649 --- /dev/null +++ b/src/ShaderNode/DataModels/ShaderNode.inl @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/DataModels/VecValue.cpp b/src/ShaderNode/DataModels/VecValue.cpp new file mode 100644 index 000000000..7986f0b9d --- /dev/null +++ b/src/ShaderNode/DataModels/VecValue.cpp @@ -0,0 +1,34 @@ +#include +#include + +Nz::ShaderAst::ExpressionPtr Vec4Value::GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const +{ + assert(count == 0); + + return Nz::ShaderBuilder::Constant(GetValue()); +} + +auto Vec4Value::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const -> QtNodes::NodeDataType +{ + assert(portType == QtNodes::PortType::Out); + assert(portIndex == 0); + + return Vec4Data::Type(); +} + +std::shared_ptr Vec4Value::outData(QtNodes::PortIndex port) +{ + assert(port == 0); + + return std::make_shared(GetValue()); +} + +Nz::Vector4f Vec4Value::GetValue() const +{ + float x = float(m_values[0]->value()); + float y = float(m_values[1]->value()); + float z = float(m_values[2]->value()); + float w = float(m_values[3]->value()); + + return Nz::Vector4f(x, y, z, w); +} diff --git a/src/ShaderNode/DataModels/VecValue.hpp b/src/ShaderNode/DataModels/VecValue.hpp new file mode 100644 index 000000000..83bd8b3a8 --- /dev/null +++ b/src/ShaderNode/DataModels/VecValue.hpp @@ -0,0 +1,66 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_VECVALUE_HPP +#define NAZARA_SHADERNODES_VECVALUE_HPP + +#include +#include +#include +#include + +template +class VecValue : public ShaderNode +{ + public: + VecValue(); + ~VecValue() = default; + + QWidget* embeddedWidget() override; + unsigned int nPorts(QtNodes::PortType portType) const override; + + protected: + QWidget* m_widget; + QFormLayout* m_layout; + std::array m_values; +}; + +class Vec4Data : public QtNodes::NodeData +{ + public: + inline Vec4Data(const Nz::Vector4f& vec); + + QtNodes::NodeDataType type() const override + { + return Type(); + } + + static QtNodes::NodeDataType Type() + { + return { "vec4", "Vec4" }; + } + + Nz::Vector4f value; +}; + +class Vec4Value : public VecValue<4> +{ + public: + Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const override; + + QString caption() const override { return "Vec4 value"; } + bool captionVisible() const override { return true; } + QString name() const override { return "Vec4Value"; } + + QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; + + std::shared_ptr outData(QtNodes::PortIndex port) override; + + void setInData(std::shared_ptr, int) override {}; + + private: + Nz::Vector4f GetValue() const; +}; + +#include + +#endif diff --git a/src/ShaderNode/DataModels/VecValue.inl b/src/ShaderNode/DataModels/VecValue.inl new file mode 100644 index 000000000..7377fdbad --- /dev/null +++ b/src/ShaderNode/DataModels/VecValue.inl @@ -0,0 +1,44 @@ +#include +#include + +template +VecValue::VecValue() +{ + constexpr std::array componentName = { 'X', 'Y', 'Z', 'W' }; + static_assert(N <= componentName.size()); + + m_layout = new QFormLayout; + for (std::size_t i = 0; i < N; ++i) + { + m_values[i] = new QDoubleSpinBox; + m_values[i]->setStyleSheet("background-color: rgba(255,255,255,255)"); + m_layout->addRow(QString::fromUtf8(&componentName[i], 1), m_values[i]); + } + + m_widget = new QWidget; + m_widget->setStyleSheet("background-color: rgba(0,0,0,0)"); + m_widget->setLayout(m_layout); +} + +template +QWidget* VecValue::embeddedWidget() +{ + return m_widget; +} + +template +unsigned int VecValue::nPorts(QtNodes::PortType portType) const +{ + switch (portType) + { + case QtNodes::PortType::In: return 0; + case QtNodes::PortType::Out: return 1; + } + + return 0; +} + +Vec4Data::Vec4Data(const Nz::Vector4f& vec) : +value(vec) +{ +} diff --git a/src/ShaderNode/main.cpp b/src/ShaderNode/main.cpp new file mode 100644 index 000000000..34141730c --- /dev/null +++ b/src/ShaderNode/main.cpp @@ -0,0 +1,127 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +std::shared_ptr registerDataModels() +{ + auto ret = std::make_shared(); + ret->registerModel(); + ret->registerModel(); + + return ret; +} + +void GenerateGLSL(QtNodes::FlowScene* scene) +{ + /*using namespace ShaderBuilder; + using ShaderAst::BuiltinEntry; + using ShaderAst::ExpressionType; + + // Fragment shader + { + auto rt0 = Output("RenderTarget0", ExpressionType::Float4); + auto color = Uniform("Color", ExpressionType::Float4); + + fragmentShader = writer.Generate(ExprStatement(Assign(rt0, color))); + }*/ + + Nz::GlslWriter writer; + std::vector statements; + + std::function HandleNode; + HandleNode = [&](QtNodes::Node* node) -> Nz::ShaderAst::ExpressionPtr + { + ShaderNode* shaderNode = static_cast(node->nodeDataModel()); + + qDebug() << shaderNode->name(); + std::size_t inputCount = shaderNode->nPorts(QtNodes::PortType::In); + Nz::StackArray expressions = NazaraStackArray(Nz::ShaderAst::ExpressionPtr, inputCount); + std::size_t i = 0; + + for (const auto& connectionSet : node->nodeState().getEntries(QtNodes::PortType::In)) + { + for (const auto& [uuid, conn] : connectionSet) + { + assert(i < expressions.size()); + expressions[i] = HandleNode(conn->getNode(QtNodes::PortType::Out)); + i++; + } + } + + return shaderNode->GetExpression(expressions.data(), expressions.size()); + }; + + scene->iterateOverNodes([&](QtNodes::Node* node) + { + if (node->nodeDataModel()->nPorts(QtNodes::PortType::Out) == 0) + { + statements.emplace_back(Nz::ShaderBuilder::ExprStatement(HandleNode(node))); + //qDebug() << node->nodeDataModel()->name(); + } + }); + + Nz::String glsl = writer.Generate(std::make_shared(std::move(statements))); + + QTextEdit* output = new QTextEdit; + output->setText(QString::fromUtf8(glsl.GetConstBuffer(), glsl.GetSize())); + output->setAttribute(Qt::WA_DeleteOnClose, true); + output->setWindowTitle("GLSL Output"); + output->show(); + + std::cout << glsl << std::endl; +} + +void SetupTestScene(QtNodes::FlowScene* scene) +{ + auto& node1 = scene->createNode(std::make_unique()); + node1.nodeGraphicsObject().setPos(200, 200); + + auto& node2 = scene->createNode(std::make_unique()); + node2.nodeGraphicsObject().setPos(500, 300); + + scene->createConnection(node2, 0, node1, 0); +} + +int main(int argc, char* argv[]) +{ + QApplication app(argc, argv); + + QWidget mainWindow; + QVBoxLayout* layout = new QVBoxLayout; + layout->setContentsMargins(0, 0, 0, 0); + layout->setSpacing(0); + + QtNodes::FlowScene* scene = new QtNodes::FlowScene(registerDataModels()); + SetupTestScene(scene); + + QMenuBar* menuBar = new QMenuBar; + QAction* glslCode = menuBar->addAction("To GLSL"); + QObject::connect(glslCode, &QAction::triggered, [&](bool) { GenerateGLSL(scene); }); + + layout->addWidget(new QtNodes::FlowView(scene)); + layout->addWidget(menuBar); + + mainWindow.setLayout(layout); + mainWindow.setWindowTitle("Nazara Shader nodes"); + mainWindow.resize(1280, 720); + mainWindow.show(); + + return app.exec(); +} From e23eb74802ff5fe920a0971642e4ca956c5cecbc Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 19 May 2020 20:06:11 +0200 Subject: [PATCH 194/316] Renderer/ShaderAst: Add Sample2D --- include/Nazara/Renderer/GlslWriter.hpp | 1 + include/Nazara/Renderer/ShaderAst.hpp | 28 ++++++++++++++++++----- include/Nazara/Renderer/ShaderAst.inl | 12 ++++++++++ include/Nazara/Renderer/ShaderBuilder.hpp | 1 + include/Nazara/Renderer/ShaderWriter.hpp | 1 + src/Nazara/Renderer/GlslWriter.cpp | 12 ++++++++++ src/Nazara/Renderer/ShaderAst.cpp | 20 ++++++++++++++-- 7 files changed, 67 insertions(+), 8 deletions(-) diff --git a/include/Nazara/Renderer/GlslWriter.hpp b/include/Nazara/Renderer/GlslWriter.hpp index 8a06a3fbe..d4042e882 100644 --- a/include/Nazara/Renderer/GlslWriter.hpp +++ b/include/Nazara/Renderer/GlslWriter.hpp @@ -40,6 +40,7 @@ namespace Nz void Write(const ShaderAst::ExpressionStatement& node) override; void Write(const ShaderAst::NamedVariable& node) override; void Write(const ShaderAst::NodePtr& node) override; + void Write(const ShaderAst::Sample2D& node) override; void Write(const ShaderAst::StatementBlock& node) override; void Write(const ShaderAst::SwizzleOp& node) override; diff --git a/include/Nazara/Renderer/ShaderAst.hpp b/include/Nazara/Renderer/ShaderAst.hpp index 549b45194..d6cc45789 100644 --- a/include/Nazara/Renderer/ShaderAst.hpp +++ b/include/Nazara/Renderer/ShaderAst.hpp @@ -42,12 +42,13 @@ namespace Nz enum class ExpressionType { - Boolean, // bool - Float1, // float - Float2, // vec2 - Float3, // vec3 - Float4, // vec4 - Mat4x4, // mat4 + Boolean, // bool + Float1, // float + Float2, // vec2 + Float3, // vec3 + Float4, // vec4 + Mat4x4, // mat4 + Sampler2D, // sampler2D Void // void }; @@ -284,6 +285,21 @@ namespace Nz std::size_t componentCount; ExpressionPtr expression; }; + + ////////////////////////////////////////////////////////////////////////// + + class NAZARA_RENDERER_API Sample2D : public Expression + { + public: + inline Sample2D(ExpressionPtr samplerPtr, ExpressionPtr coordinatesPtr); + + ExpressionType GetExpressionType() const override; + void Register(ShaderWriter& visitor) override; + void Visit(ShaderWriter& visitor) override; + + ExpressionPtr sampler; + ExpressionPtr coordinates; + }; } } diff --git a/include/Nazara/Renderer/ShaderAst.inl b/include/Nazara/Renderer/ShaderAst.inl index 2235c9a74..cb9024b48 100644 --- a/include/Nazara/Renderer/ShaderAst.inl +++ b/include/Nazara/Renderer/ShaderAst.inl @@ -2,6 +2,7 @@ // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp +#include #include namespace Nz @@ -225,6 +226,17 @@ namespace Nz std::copy(swizzleComponents.begin(), swizzleComponents.end(), components.begin()); } + + inline Sample2D::Sample2D(ExpressionPtr samplerPtr, ExpressionPtr coordinatesPtr) : + sampler(std::move(samplerPtr)), + coordinates(std::move(coordinatesPtr)) + { + if (sampler->GetExpressionType() != ExpressionType::Sampler2D) + throw std::runtime_error("Sampler must be a Sampler2D"); + + if (coordinates->GetExpressionType() != ExpressionType::Float2) + throw std::runtime_error("Coordinates must be a Float2"); + } } } diff --git a/include/Nazara/Renderer/ShaderBuilder.hpp b/include/Nazara/Renderer/ShaderBuilder.hpp index 79512e90f..b0ba09cc4 100644 --- a/include/Nazara/Renderer/ShaderBuilder.hpp +++ b/include/Nazara/Renderer/ShaderBuilder.hpp @@ -66,6 +66,7 @@ namespace Nz { namespace ShaderBuilder constexpr BinOpBuilder Multiply; constexpr VarBuilder Output; constexpr VarBuilder Parameter; + constexpr GenBuilder Sample2D; constexpr GenBuilder Swizzle; constexpr BinOpBuilder Substract; constexpr VarBuilder Uniform; diff --git a/include/Nazara/Renderer/ShaderWriter.hpp b/include/Nazara/Renderer/ShaderWriter.hpp index f20061e05..64dddcf9f 100644 --- a/include/Nazara/Renderer/ShaderWriter.hpp +++ b/include/Nazara/Renderer/ShaderWriter.hpp @@ -41,6 +41,7 @@ namespace Nz virtual void Write(const ShaderAst::ExpressionStatement& node) = 0; virtual void Write(const ShaderAst::NamedVariable& node) = 0; virtual void Write(const ShaderAst::NodePtr& node) = 0; + virtual void Write(const ShaderAst::Sample2D& node) = 0; virtual void Write(const ShaderAst::StatementBlock& node) = 0; virtual void Write(const ShaderAst::SwizzleOp& node) = 0; diff --git a/src/Nazara/Renderer/GlslWriter.cpp b/src/Nazara/Renderer/GlslWriter.cpp index 1c0752b85..badf3648f 100644 --- a/src/Nazara/Renderer/GlslWriter.cpp +++ b/src/Nazara/Renderer/GlslWriter.cpp @@ -128,6 +128,15 @@ namespace Nz node->Visit(*this); } + void GlslWriter::Write(const ShaderAst::Sample2D& node) + { + Append("texture("); + Write(node.sampler); + Append(", "); + Write(node.coordinates); + Append(")"); + } + void GlslWriter::Write(const ShaderAst::AssignOp& node) { Write(node.variable); @@ -338,6 +347,9 @@ namespace Nz case ShaderAst::ExpressionType::Mat4x4: Append("mat4"); break; + case ShaderAst::ExpressionType::Sampler2D: + Append("sampler2D"); + break; case ShaderAst::ExpressionType::Void: Append("void"); break; diff --git a/src/Nazara/Renderer/ShaderAst.cpp b/src/Nazara/Renderer/ShaderAst.cpp index 180930595..d45c8b739 100644 --- a/src/Nazara/Renderer/ShaderAst.cpp +++ b/src/Nazara/Renderer/ShaderAst.cpp @@ -6,7 +6,7 @@ #include #include -namespace Nz { namespace ShaderAst +namespace Nz::ShaderAst { void ExpressionStatement::Register(ShaderWriter& visitor) { @@ -192,5 +192,21 @@ namespace Nz { namespace ShaderAst { visitor.Write(*this); } -} + + + ExpressionType Sample2D::GetExpressionType() const + { + return ExpressionType::Float4; + } + + void Sample2D::Register(ShaderWriter& visitor) + { + sampler->Register(visitor); + coordinates->Register(visitor); + } + + void Sample2D::Visit(ShaderWriter& visitor) + { + visitor.Write(*this); + } } From effaa9b88fbf956d0e583a58a4433d8a7d174610 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 19 May 2020 20:06:32 +0200 Subject: [PATCH 195/316] Update ShaderNode --- src/ShaderNode/DataModels/FragmentOutput.hpp | 2 + src/ShaderNode/DataModels/FragmentOutput.inl | 5 + src/ShaderNode/DataModels/SampleTexture.cpp | 106 +++++++++++++++++++ src/ShaderNode/DataModels/SampleTexture.hpp | 47 ++++++++ src/ShaderNode/DataModels/SampleTexture.inl | 2 + src/ShaderNode/DataModels/ShaderNode.hpp | 11 ++ src/ShaderNode/DataModels/ShaderNode.inl | 15 +++ src/ShaderNode/DataModels/VecBinOp.cpp | 1 + src/ShaderNode/DataModels/VecBinOp.hpp | 60 +++++++++++ src/ShaderNode/DataModels/VecBinOp.inl | 93 ++++++++++++++++ src/ShaderNode/DataModels/VecValue.cpp | 55 ++++++++++ src/ShaderNode/DataModels/VecValue.hpp | 62 +++++++++-- src/ShaderNode/DataModels/VecValue.inl | 34 +++++- src/ShaderNode/ShaderGraph.cpp | 95 +++++++++++++++++ src/ShaderNode/ShaderGraph.hpp | 45 ++++++++ src/ShaderNode/ShaderGraph.inl | 11 ++ src/ShaderNode/main.cpp | 86 ++------------- 17 files changed, 646 insertions(+), 84 deletions(-) create mode 100644 src/ShaderNode/DataModels/SampleTexture.cpp create mode 100644 src/ShaderNode/DataModels/SampleTexture.hpp create mode 100644 src/ShaderNode/DataModels/SampleTexture.inl create mode 100644 src/ShaderNode/DataModels/VecBinOp.cpp create mode 100644 src/ShaderNode/DataModels/VecBinOp.hpp create mode 100644 src/ShaderNode/DataModels/VecBinOp.inl create mode 100644 src/ShaderNode/ShaderGraph.cpp create mode 100644 src/ShaderNode/ShaderGraph.hpp create mode 100644 src/ShaderNode/ShaderGraph.inl diff --git a/src/ShaderNode/DataModels/FragmentOutput.hpp b/src/ShaderNode/DataModels/FragmentOutput.hpp index 30aa74b90..a682d40a4 100644 --- a/src/ShaderNode/DataModels/FragmentOutput.hpp +++ b/src/ShaderNode/DataModels/FragmentOutput.hpp @@ -10,6 +10,8 @@ class FragmentOutput : public ShaderNode { public: + inline FragmentOutput(ShaderGraph& graph); + Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const override; QString caption() const override { return "Fragment shader output"; } diff --git a/src/ShaderNode/DataModels/FragmentOutput.inl b/src/ShaderNode/DataModels/FragmentOutput.inl index f8287a921..539b8091f 100644 --- a/src/ShaderNode/DataModels/FragmentOutput.inl +++ b/src/ShaderNode/DataModels/FragmentOutput.inl @@ -1 +1,6 @@ #include + +inline FragmentOutput::FragmentOutput(ShaderGraph& graph) : +ShaderNode(graph) +{ +} diff --git a/src/ShaderNode/DataModels/SampleTexture.cpp b/src/ShaderNode/DataModels/SampleTexture.cpp new file mode 100644 index 000000000..1f4bd4f80 --- /dev/null +++ b/src/ShaderNode/DataModels/SampleTexture.cpp @@ -0,0 +1,106 @@ +#include +#include +#include +#include + +SampleTexture::SampleTexture(ShaderGraph& graph) : +ShaderNode(graph) +{ + m_layout = new QVBoxLayout; + + m_textureSelection = new QComboBox; + m_textureSelection->setStyleSheet("background-color: rgba(255,255,255,255)"); + + m_layout->addWidget(m_textureSelection); + + m_pixmap = QPixmap(64, 64); + m_pixmap.fill(); + + m_pixmapLabel = new QLabel; + m_pixmapLabel->setPixmap(m_pixmap); + + m_layout->addWidget(m_pixmapLabel); + + m_widget = new QWidget; + m_widget->setStyleSheet("background-color: rgba(0,0,0,0)"); + m_widget->setLayout(m_layout); + + m_onTextureListUpdate.Connect(GetGraph().OnTextureListUpdate, [&](ShaderGraph*) { UpdateTextureList(); }); + UpdateTextureList(); +} + +QWidget* SampleTexture::embeddedWidget() +{ + return m_widget; +} + +unsigned int SampleTexture::nPorts(QtNodes::PortType portType) const +{ + switch (portType) + { + case QtNodes::PortType::In: return 1; + case QtNodes::PortType::Out: return 1; + } + + return 0; +} + +void SampleTexture::UpdatePreview() +{ + ComputePreview(m_pixmap); + m_pixmapLabel->setPixmap(m_pixmap); +} + +void SampleTexture::UpdateTextureList() +{ + QString currentTexture = m_textureSelection->currentText(); + m_textureSelection->clear(); + + for (const auto& textureEntry : GetGraph().GetTextures()) + m_textureSelection->addItem(QString::fromStdString(textureEntry.name)); + + m_textureSelection->setCurrentText(currentTexture); +} + +void SampleTexture::ComputePreview(QPixmap& pixmap) const +{ + pixmap.fill(); +} + +Nz::ShaderAst::ExpressionPtr SampleTexture::GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const +{ + assert(count == 1); + + auto sampler = Nz::ShaderBuilder::Uniform("Texture0", Nz::ShaderAst::ExpressionType::Sampler2D); + + return Nz::ShaderBuilder::Sample2D(sampler, expressions[0]); +} + +auto SampleTexture::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const -> QtNodes::NodeDataType +{ + switch (portType) + { + case QtNodes::PortType::In: + { + assert(portIndex == 0); + return Vec2Data::Type(); + } + + case QtNodes::PortType::Out: + { + assert(portIndex == 0); + return Vec4Data::Type(); + } + + default: + assert(false); + throw std::runtime_error("Invalid PortType"); + } +} + +std::shared_ptr SampleTexture::outData(QtNodes::PortIndex port) +{ + assert(port == 0); + + return std::make_shared(Nz::Vector4f::Zero()); +} diff --git a/src/ShaderNode/DataModels/SampleTexture.hpp b/src/ShaderNode/DataModels/SampleTexture.hpp new file mode 100644 index 000000000..df107169c --- /dev/null +++ b/src/ShaderNode/DataModels/SampleTexture.hpp @@ -0,0 +1,47 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_SAMPLETEXTURE_HPP +#define NAZARA_SHADERNODES_SAMPLETEXTURE_HPP + +#include +#include +#include +#include +#include +#include + +class SampleTexture : public ShaderNode +{ + public: + SampleTexture(ShaderGraph& graph); + ~SampleTexture() = default; + + Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const override; + + QString caption() const override { return "Sample texture"; } + QString name() const override { return "SampleTexture"; } + + QWidget* embeddedWidget() override; + unsigned int nPorts(QtNodes::PortType portType) const override; + + QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; + std::shared_ptr outData(QtNodes::PortIndex port) override; + + protected: + void UpdatePreview(); + void UpdateTextureList(); + + void ComputePreview(QPixmap& pixmap) const; + + NazaraSlot(ShaderGraph, OnTextureListUpdate, m_onTextureListUpdate); + + QComboBox* m_textureSelection; + QLabel* m_pixmapLabel; + QPixmap m_pixmap; + QWidget* m_widget; + QVBoxLayout* m_layout; +}; + +#include + +#endif diff --git a/src/ShaderNode/DataModels/SampleTexture.inl b/src/ShaderNode/DataModels/SampleTexture.inl new file mode 100644 index 000000000..78d12b21d --- /dev/null +++ b/src/ShaderNode/DataModels/SampleTexture.inl @@ -0,0 +1,2 @@ +#include +#include diff --git a/src/ShaderNode/DataModels/ShaderNode.hpp b/src/ShaderNode/DataModels/ShaderNode.hpp index 5c8f6e7f8..71a279120 100644 --- a/src/ShaderNode/DataModels/ShaderNode.hpp +++ b/src/ShaderNode/DataModels/ShaderNode.hpp @@ -6,10 +6,21 @@ #include #include +class ShaderGraph; + class ShaderNode : public QtNodes::NodeDataModel { public: + inline ShaderNode(ShaderGraph& graph); + virtual Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const = 0; + inline ShaderGraph& GetGraph(); + inline const ShaderGraph& GetGraph() const; + + void setInData(std::shared_ptr, int) override {}; + + private: + ShaderGraph& m_graph; }; #include diff --git a/src/ShaderNode/DataModels/ShaderNode.inl b/src/ShaderNode/DataModels/ShaderNode.inl index fba232649..a244d78b5 100644 --- a/src/ShaderNode/DataModels/ShaderNode.inl +++ b/src/ShaderNode/DataModels/ShaderNode.inl @@ -1 +1,16 @@ #include + +inline ShaderNode::ShaderNode(ShaderGraph& graph) : +m_graph(graph) +{ +} + +inline ShaderGraph& ShaderNode::GetGraph() +{ + return m_graph; +} + +inline const ShaderGraph& ShaderNode::GetGraph() const +{ + return m_graph; +} diff --git a/src/ShaderNode/DataModels/VecBinOp.cpp b/src/ShaderNode/DataModels/VecBinOp.cpp new file mode 100644 index 000000000..dd13b5b56 --- /dev/null +++ b/src/ShaderNode/DataModels/VecBinOp.cpp @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/DataModels/VecBinOp.hpp b/src/ShaderNode/DataModels/VecBinOp.hpp new file mode 100644 index 000000000..131a05f6d --- /dev/null +++ b/src/ShaderNode/DataModels/VecBinOp.hpp @@ -0,0 +1,60 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_VECBINOP_HPP +#define NAZARA_SHADERNODES_VECBINOP_HPP + +#include +#include + +template +class VecBinOp : public ShaderNode +{ + public: + VecBinOp(ShaderGraph& graph); + ~VecBinOp() = default; + + Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const override; + + QWidget* embeddedWidget() override; + unsigned int nPorts(QtNodes::PortType portType) const override; + + QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; + + std::shared_ptr outData(QtNodes::PortIndex port) override; + + void setInData(std::shared_ptr value, int index) override; + + private: + void UpdatePreview(); + + using InternalType = typename Data::InternalType; + + InternalType GetValue() const; + + QLabel* m_pixmapLabel; + QPixmap m_preview; + std::shared_ptr m_lhs; + std::shared_ptr m_rhs; +}; + +class Vec4Add : public VecBinOp +{ + public: + using VecBinOp::VecBinOp; + + QString caption() const override { return "Vec4 addition"; } + QString name() const override { return "Vec4Add"; } +}; + +class Vec4Mul : public VecBinOp +{ + public: + using VecBinOp::VecBinOp; + + QString caption() const override { return "Vec4 multiplication"; } + QString name() const override { return "Vec4Mul"; } +}; + +#include + +#endif diff --git a/src/ShaderNode/DataModels/VecBinOp.inl b/src/ShaderNode/DataModels/VecBinOp.inl new file mode 100644 index 000000000..371905221 --- /dev/null +++ b/src/ShaderNode/DataModels/VecBinOp.inl @@ -0,0 +1,93 @@ +#include +#include + +template +VecBinOp::VecBinOp(ShaderGraph& graph) : +ShaderNode(graph) +{ + m_preview = QPixmap(64, 64); + + m_pixmapLabel = new QLabel; + m_pixmapLabel->setPixmap(m_preview); +} + +template +Nz::ShaderAst::ExpressionPtr VecBinOp::GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const +{ + assert(count == 2); + using BuilderType = typename Nz::ShaderBuilder::template BinOpBuilder; + constexpr BuilderType builder; + return builder(expressions[0], expressions[1]); +} + +template +QWidget* VecBinOp::embeddedWidget() +{ + return m_pixmapLabel; +} + +template +QtNodes::NodeDataType VecBinOp::dataType(QtNodes::PortType /*portType*/, QtNodes::PortIndex portIndex) const +{ + assert(portIndex == 0 || portIndex == 1); + + return Data::Type(); +} + +template +unsigned int VecBinOp::nPorts(QtNodes::PortType portType) const +{ + switch (portType) + { + case QtNodes::PortType::In: return 2; + case QtNodes::PortType::Out: return 1; + } + + return 0; +} + +template +std::shared_ptr VecBinOp::outData(QtNodes::PortIndex port) +{ + assert(port == 0); + return std::make_shared(GetValue()); +} + +template +void VecBinOp::setInData(std::shared_ptr value, int index) +{ + std::shared_ptr castedValue; + if (value) + { + assert(dynamic_cast(value.get()) != nullptr); + assert(index == 0 || index == 1); + + castedValue = std::static_pointer_cast(value); + } + + if (index == 0) + m_lhs = std::move(castedValue); + else + m_rhs = std::move(castedValue); + + UpdatePreview(); + + Q_EMIT dataUpdated(0); +} + +template +void VecBinOp::UpdatePreview() +{ + InternalType value = GetValue(); + m_preview.fill(QColor::fromRgbF(value.x, value.y, value.z, value.w)); + m_pixmapLabel->setPixmap(m_preview); +} + +template +auto VecBinOp::GetValue() const -> InternalType +{ + if (!m_lhs || !m_rhs) + return InternalType::Zero(); + + return m_lhs->value * m_rhs->value; +} diff --git a/src/ShaderNode/DataModels/VecValue.cpp b/src/ShaderNode/DataModels/VecValue.cpp index 7986f0b9d..84f1f4ea8 100644 --- a/src/ShaderNode/DataModels/VecValue.cpp +++ b/src/ShaderNode/DataModels/VecValue.cpp @@ -1,6 +1,55 @@ #include #include +Vec2Value::Vec2Value(ShaderGraph& graph) : +VecValue(graph) +{ + UpdatePreview(); +} + +Nz::ShaderAst::ExpressionPtr Vec2Value::GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const +{ + assert(count == 0); + + return Nz::ShaderBuilder::Constant(GetValue()); +} + +auto Vec2Value::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const -> QtNodes::NodeDataType +{ + assert(portType == QtNodes::PortType::Out); + assert(portIndex == 0); + + return Vec2Data::Type(); +} + +std::shared_ptr Vec2Value::outData(QtNodes::PortIndex port) +{ + assert(port == 0); + + return std::make_shared(GetValue()); +} + +void Vec2Value::ComputePreview(QPixmap& pixmap) const +{ + Nz::Vector4f value = GetValue(); + pixmap.fill(QColor::fromRgbF(value.x, value.y, value.z, value.w)); +} + +Nz::Vector2f Vec2Value::GetValue() const +{ + float x = float(m_values[0]->value()); + float y = float(m_values[1]->value()); + + return Nz::Vector2f(x, y); +} + + +Vec4Value::Vec4Value(ShaderGraph& graph) : +VecValue(graph) +{ + UpdatePreview(); +} + Nz::ShaderAst::ExpressionPtr Vec4Value::GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const { assert(count == 0); @@ -23,6 +72,12 @@ std::shared_ptr Vec4Value::outData(QtNodes::PortIndex port) return std::make_shared(GetValue()); } +void Vec4Value::ComputePreview(QPixmap& pixmap) const +{ + Nz::Vector4f value = GetValue(); + pixmap.fill(QColor::fromRgbF(value.x, value.y, value.z, value.w)); +} + Nz::Vector4f Vec4Value::GetValue() const { float x = float(m_values[0]->value()); diff --git a/src/ShaderNode/DataModels/VecValue.hpp b/src/ShaderNode/DataModels/VecValue.hpp index 83bd8b3a8..10e215971 100644 --- a/src/ShaderNode/DataModels/VecValue.hpp +++ b/src/ShaderNode/DataModels/VecValue.hpp @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -12,22 +13,50 @@ template class VecValue : public ShaderNode { public: - VecValue(); + VecValue(ShaderGraph& graph); ~VecValue() = default; QWidget* embeddedWidget() override; unsigned int nPorts(QtNodes::PortType portType) const override; protected: + void UpdatePreview(); + + virtual void ComputePreview(QPixmap& pixmap) const = 0; + + QLabel* m_pixmapLabel; + QPixmap m_pixmap; QWidget* m_widget; QFormLayout* m_layout; std::array m_values; }; +class Vec2Data : public QtNodes::NodeData +{ + public: + using InternalType = Nz::Vector2f; + + inline Vec2Data(const InternalType& vec); + + QtNodes::NodeDataType type() const override + { + return Type(); + } + + static QtNodes::NodeDataType Type() + { + return { "vec2", "Vec2" }; + } + + InternalType value; +}; + class Vec4Data : public QtNodes::NodeData { public: - inline Vec4Data(const Nz::Vector4f& vec); + using InternalType = Nz::Vector4f; + + inline Vec4Data(const InternalType& vec); QtNodes::NodeDataType type() const override { @@ -39,25 +68,46 @@ class Vec4Data : public QtNodes::NodeData return { "vec4", "Vec4" }; } - Nz::Vector4f value; + InternalType value; +}; + +class Vec2Value : public VecValue<2> +{ + public: + Vec2Value(ShaderGraph& graph); + + Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const override; + + QString caption() const override { return "Vec2 value"; } + QString name() const override { return "Vec2Value"; } + + QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; + + std::shared_ptr outData(QtNodes::PortIndex port) override; + + private: + void ComputePreview(QPixmap& pixmap) const override; + + Nz::Vector2f GetValue() const; }; class Vec4Value : public VecValue<4> { public: + Vec4Value(ShaderGraph& graph); + Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const override; QString caption() const override { return "Vec4 value"; } - bool captionVisible() const override { return true; } QString name() const override { return "Vec4Value"; } QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; std::shared_ptr outData(QtNodes::PortIndex port) override; - void setInData(std::shared_ptr, int) override {}; - private: + void ComputePreview(QPixmap& pixmap) const override; + Nz::Vector4f GetValue() const; }; diff --git a/src/ShaderNode/DataModels/VecValue.inl b/src/ShaderNode/DataModels/VecValue.inl index 7377fdbad..e79eef3dc 100644 --- a/src/ShaderNode/DataModels/VecValue.inl +++ b/src/ShaderNode/DataModels/VecValue.inl @@ -2,7 +2,8 @@ #include template -VecValue::VecValue() +VecValue::VecValue(ShaderGraph& graph) : +ShaderNode(graph) { constexpr std::array componentName = { 'X', 'Y', 'Z', 'W' }; static_assert(N <= componentName.size()); @@ -11,10 +12,27 @@ VecValue::VecValue() for (std::size_t i = 0; i < N; ++i) { m_values[i] = new QDoubleSpinBox; + m_values[i]->setDecimals(6); + m_values[i]->setValue(1.0); m_values[i]->setStyleSheet("background-color: rgba(255,255,255,255)"); + connect(m_values[i], qOverload(&QDoubleSpinBox::valueChanged), [this](double) + { + UpdatePreview(); + + Q_EMIT dataUpdated(0); + }); + m_layout->addRow(QString::fromUtf8(&componentName[i], 1), m_values[i]); } + m_pixmap = QPixmap(64, 64); + m_pixmap.fill(); + + m_pixmapLabel = new QLabel; + m_pixmapLabel->setPixmap(m_pixmap); + + m_layout->addWidget(m_pixmapLabel); + m_widget = new QWidget; m_widget->setStyleSheet("background-color: rgba(0,0,0,0)"); m_widget->setLayout(m_layout); @@ -38,7 +56,19 @@ unsigned int VecValue::nPorts(QtNodes::PortType portType) const return 0; } -Vec4Data::Vec4Data(const Nz::Vector4f& vec) : +template +void VecValue::UpdatePreview() +{ + ComputePreview(m_pixmap); + m_pixmapLabel->setPixmap(m_pixmap); +} + +Vec2Data::Vec2Data(const InternalType& vec) : +value(vec) +{ +} + +Vec4Data::Vec4Data(const InternalType& vec) : value(vec) { } diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp new file mode 100644 index 000000000..478e99408 --- /dev/null +++ b/src/ShaderNode/ShaderGraph.cpp @@ -0,0 +1,95 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace +{ + template + void RegisterShaderNode(ShaderGraph& graph, std::shared_ptr registry) + { + auto creator = [&] { return std::make_unique(graph); }; + registry->registerModel(std::move(creator)); + } +} + +ShaderGraph::ShaderGraph() : +m_flowScene(BuildRegistry()) +{ + auto& node1 = m_flowScene.createNode(std::make_unique(*this)); + node1.nodeGraphicsObject().setPos(200, 200); + + auto& node2 = m_flowScene.createNode(std::make_unique(*this)); + node2.nodeGraphicsObject().setPos(500, 300); + + m_flowScene.createConnection(node2, 0, node1, 0); +} + +void ShaderGraph::AddTexture(std::string name, Nz::ShaderAst::ExpressionType type) +{ + auto& textureEntry = m_textures.emplace_back(); + textureEntry.name = std::move(name); + textureEntry.type = type; + + OnTextureListUpdate(this); +} + +Nz::ShaderAst::StatementPtr ShaderGraph::Generate() +{ + std::vector statements; + + std::function HandleNode; + HandleNode = [&](QtNodes::Node* node) -> Nz::ShaderAst::ExpressionPtr + { + ShaderNode* shaderNode = static_cast(node->nodeDataModel()); + + qDebug() << shaderNode->name(); + std::size_t inputCount = shaderNode->nPorts(QtNodes::PortType::In); + Nz::StackArray expressions = NazaraStackArray(Nz::ShaderAst::ExpressionPtr, inputCount); + std::size_t i = 0; + + for (const auto& connectionSet : node->nodeState().getEntries(QtNodes::PortType::In)) + { + for (const auto& [uuid, conn] : connectionSet) + { + assert(i < expressions.size()); + expressions[i] = HandleNode(conn->getNode(QtNodes::PortType::Out)); + i++; + } + } + + return shaderNode->GetExpression(expressions.data(), expressions.size()); + }; + + m_flowScene.iterateOverNodes([&](QtNodes::Node* node) + { + if (node->nodeDataModel()->nPorts(QtNodes::PortType::Out) == 0) + { + statements.emplace_back(Nz::ShaderBuilder::ExprStatement(HandleNode(node))); + } + }); + + return std::make_shared(std::move(statements)); +} + +std::shared_ptr ShaderGraph::BuildRegistry() +{ + auto registry = std::make_shared(); + RegisterShaderNode(*this, registry); + RegisterShaderNode(*this, registry); + RegisterShaderNode(*this, registry); + RegisterShaderNode(*this, registry); + RegisterShaderNode(*this, registry); + + return registry; +} diff --git a/src/ShaderNode/ShaderGraph.hpp b/src/ShaderNode/ShaderGraph.hpp new file mode 100644 index 000000000..8e61175f1 --- /dev/null +++ b/src/ShaderNode/ShaderGraph.hpp @@ -0,0 +1,45 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_SHADERGRAPH_HPP +#define NAZARA_SHADERNODES_SHADERGRAPH_HPP + +#include +#include +#include +#include +#include +#include + +class ShaderGraph +{ + public: + struct TextureEntry; + + ShaderGraph(); + ~ShaderGraph() = default; + + void AddTexture(std::string name, Nz::ShaderAst::ExpressionType type); + + Nz::ShaderAst::StatementPtr Generate(); + + inline QtNodes::FlowScene& GetScene(); + inline const std::vector& GetTextures(); + + NazaraSignal(OnTextureListUpdate, ShaderGraph*); + + struct TextureEntry + { + std::string name; + Nz::ShaderAst::ExpressionType type; + }; + + private: + std::shared_ptr BuildRegistry(); + + QtNodes::FlowScene m_flowScene; + std::vector m_textures; +}; + +#include + +#endif diff --git a/src/ShaderNode/ShaderGraph.inl b/src/ShaderNode/ShaderGraph.inl new file mode 100644 index 000000000..07c20a134 --- /dev/null +++ b/src/ShaderNode/ShaderGraph.inl @@ -0,0 +1,11 @@ +#include + +inline QtNodes::FlowScene& ShaderGraph::GetScene() +{ + return m_flowScene; +} + +inline auto ShaderGraph::GetTextures() -> const std::vector& +{ + return m_textures; +} diff --git a/src/ShaderNode/main.cpp b/src/ShaderNode/main.cpp index 34141730c..7878bec22 100644 --- a/src/ShaderNode/main.cpp +++ b/src/ShaderNode/main.cpp @@ -1,10 +1,6 @@ -#include #include #include #include -#include -#include -#include #include #include #include @@ -17,103 +13,41 @@ #include #include #include +#include #include -std::shared_ptr registerDataModels() +void GenerateGLSL(ShaderGraph& graph) { - auto ret = std::make_shared(); - ret->registerModel(); - ret->registerModel(); - - return ret; -} - -void GenerateGLSL(QtNodes::FlowScene* scene) -{ - /*using namespace ShaderBuilder; - using ShaderAst::BuiltinEntry; - using ShaderAst::ExpressionType; - - // Fragment shader - { - auto rt0 = Output("RenderTarget0", ExpressionType::Float4); - auto color = Uniform("Color", ExpressionType::Float4); - - fragmentShader = writer.Generate(ExprStatement(Assign(rt0, color))); - }*/ - Nz::GlslWriter writer; - std::vector statements; + Nz::String glsl = writer.Generate(graph.Generate()); - std::function HandleNode; - HandleNode = [&](QtNodes::Node* node) -> Nz::ShaderAst::ExpressionPtr - { - ShaderNode* shaderNode = static_cast(node->nodeDataModel()); - - qDebug() << shaderNode->name(); - std::size_t inputCount = shaderNode->nPorts(QtNodes::PortType::In); - Nz::StackArray expressions = NazaraStackArray(Nz::ShaderAst::ExpressionPtr, inputCount); - std::size_t i = 0; - - for (const auto& connectionSet : node->nodeState().getEntries(QtNodes::PortType::In)) - { - for (const auto& [uuid, conn] : connectionSet) - { - assert(i < expressions.size()); - expressions[i] = HandleNode(conn->getNode(QtNodes::PortType::Out)); - i++; - } - } - - return shaderNode->GetExpression(expressions.data(), expressions.size()); - }; - - scene->iterateOverNodes([&](QtNodes::Node* node) - { - if (node->nodeDataModel()->nPorts(QtNodes::PortType::Out) == 0) - { - statements.emplace_back(Nz::ShaderBuilder::ExprStatement(HandleNode(node))); - //qDebug() << node->nodeDataModel()->name(); - } - }); - - Nz::String glsl = writer.Generate(std::make_shared(std::move(statements))); + std::cout << glsl << std::endl; QTextEdit* output = new QTextEdit; + output->setReadOnly(true); output->setText(QString::fromUtf8(glsl.GetConstBuffer(), glsl.GetSize())); output->setAttribute(Qt::WA_DeleteOnClose, true); output->setWindowTitle("GLSL Output"); output->show(); - - std::cout << glsl << std::endl; -} - -void SetupTestScene(QtNodes::FlowScene* scene) -{ - auto& node1 = scene->createNode(std::make_unique()); - node1.nodeGraphicsObject().setPos(200, 200); - - auto& node2 = scene->createNode(std::make_unique()); - node2.nodeGraphicsObject().setPos(500, 300); - - scene->createConnection(node2, 0, node1, 0); } int main(int argc, char* argv[]) { QApplication app(argc, argv); + ShaderGraph shaderGraph; + shaderGraph.AddTexture("TextureMachin", Nz::ShaderAst::ExpressionType::Sampler2D); + QWidget mainWindow; QVBoxLayout* layout = new QVBoxLayout; layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); - QtNodes::FlowScene* scene = new QtNodes::FlowScene(registerDataModels()); - SetupTestScene(scene); + QtNodes::FlowScene* scene = &shaderGraph.GetScene(); QMenuBar* menuBar = new QMenuBar; QAction* glslCode = menuBar->addAction("To GLSL"); - QObject::connect(glslCode, &QAction::triggered, [&](bool) { GenerateGLSL(scene); }); + QObject::connect(glslCode, &QAction::triggered, [&](bool) { GenerateGLSL(shaderGraph); }); layout->addWidget(new QtNodes::FlowView(scene)); layout->addWidget(menuBar); From 33c8fe2562a87c684d80ca62a26b9247b4ebd8fe Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 22 May 2020 15:39:10 +0200 Subject: [PATCH 196/316] ShaderNode: Add texture support --- src/ShaderNode/DataModels/SampleTexture.cpp | 36 +++++- src/ShaderNode/DataModels/SampleTexture.hpp | 7 +- src/ShaderNode/DataModels/ShaderNode.cpp | 4 + src/ShaderNode/DataModels/ShaderNode.hpp | 2 +- src/ShaderNode/DataModels/VecBinOp.cpp | 22 ++++ src/ShaderNode/DataModels/VecBinOp.hpp | 10 +- src/ShaderNode/DataModels/VecBinOp.inl | 54 ++++++--- src/ShaderNode/DataModels/VecValue.cpp | 88 -------------- src/ShaderNode/DataModels/VecValue.hpp | 125 ++++++++++---------- src/ShaderNode/DataModels/VecValue.inl | 104 ++++++++++++---- src/ShaderNode/ShaderGraph.cpp | 32 +++-- src/ShaderNode/ShaderGraph.hpp | 13 +- src/ShaderNode/ShaderGraph.inl | 7 ++ src/ShaderNode/Widgets/MainWindow.cpp | 50 ++++++++ src/ShaderNode/Widgets/MainWindow.hpp | 26 ++++ src/ShaderNode/Widgets/MainWindow.inl | 1 + src/ShaderNode/Widgets/TextureEditor.cpp | 81 +++++++++++++ src/ShaderNode/Widgets/TextureEditor.hpp | 40 +++++++ src/ShaderNode/Widgets/TextureEditor.inl | 1 + src/ShaderNode/main.cpp | 50 +------- 20 files changed, 493 insertions(+), 260 deletions(-) create mode 100644 src/ShaderNode/Widgets/MainWindow.cpp create mode 100644 src/ShaderNode/Widgets/MainWindow.hpp create mode 100644 src/ShaderNode/Widgets/MainWindow.inl create mode 100644 src/ShaderNode/Widgets/TextureEditor.cpp create mode 100644 src/ShaderNode/Widgets/TextureEditor.hpp create mode 100644 src/ShaderNode/Widgets/TextureEditor.inl diff --git a/src/ShaderNode/DataModels/SampleTexture.cpp b/src/ShaderNode/DataModels/SampleTexture.cpp index 1f4bd4f80..6d222abb6 100644 --- a/src/ShaderNode/DataModels/SampleTexture.cpp +++ b/src/ShaderNode/DataModels/SampleTexture.cpp @@ -4,12 +4,21 @@ #include SampleTexture::SampleTexture(ShaderGraph& graph) : -ShaderNode(graph) +ShaderNode(graph), +m_currentTextureIndex(0) { m_layout = new QVBoxLayout; m_textureSelection = new QComboBox; m_textureSelection->setStyleSheet("background-color: rgba(255,255,255,255)"); + connect(m_textureSelection, qOverload(&QComboBox::currentIndexChanged), [&](int index) + { + if (index < 0) + return; + + m_currentTextureIndex = static_cast(index); + UpdatePreview(); + }); m_layout->addWidget(m_textureSelection); @@ -25,8 +34,15 @@ ShaderNode(graph) m_widget->setStyleSheet("background-color: rgba(0,0,0,0)"); m_widget->setLayout(m_layout); - m_onTextureListUpdate.Connect(GetGraph().OnTextureListUpdate, [&](ShaderGraph*) { UpdateTextureList(); }); + m_onTextureListUpdateSlot.Connect(GetGraph().OnTextureListUpdate, [&](ShaderGraph*) { UpdateTextureList(); }); + m_onTexturePreviewUpdateSlot.Connect(GetGraph().OnTexturePreviewUpdate, [&](ShaderGraph*, std::size_t textureIndex) + { + if (m_currentTextureIndex == textureIndex) + UpdatePreview(); + }); + UpdateTextureList(); + UpdatePreview(); } QWidget* SampleTexture::embeddedWidget() @@ -47,8 +63,13 @@ unsigned int SampleTexture::nPorts(QtNodes::PortType portType) const void SampleTexture::UpdatePreview() { + if (m_textureSelection->count() == 0) + return; + ComputePreview(m_pixmap); m_pixmapLabel->setPixmap(m_pixmap); + + Q_EMIT dataUpdated(0); } void SampleTexture::UpdateTextureList() @@ -64,7 +85,9 @@ void SampleTexture::UpdateTextureList() void SampleTexture::ComputePreview(QPixmap& pixmap) const { - pixmap.fill(); + const auto& textureEntry = GetGraph().GetTexture(m_currentTextureIndex); + + pixmap = QPixmap::fromImage(textureEntry.preview).scaled(128, 128, Qt::KeepAspectRatio); } Nz::ShaderAst::ExpressionPtr SampleTexture::GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const @@ -102,5 +125,10 @@ std::shared_ptr SampleTexture::outData(QtNodes::PortIndex por { assert(port == 0); - return std::make_shared(Nz::Vector4f::Zero()); + const auto& textureEntry = GetGraph().GetTexture(m_currentTextureIndex); + + auto vecData = std::make_shared(); + vecData->preview = textureEntry.preview; + + return vecData; } diff --git a/src/ShaderNode/DataModels/SampleTexture.hpp b/src/ShaderNode/DataModels/SampleTexture.hpp index df107169c..f717797f2 100644 --- a/src/ShaderNode/DataModels/SampleTexture.hpp +++ b/src/ShaderNode/DataModels/SampleTexture.hpp @@ -28,13 +28,14 @@ class SampleTexture : public ShaderNode std::shared_ptr outData(QtNodes::PortIndex port) override; protected: + void ComputePreview(QPixmap& pixmap) const; void UpdatePreview(); void UpdateTextureList(); - void ComputePreview(QPixmap& pixmap) const; - - NazaraSlot(ShaderGraph, OnTextureListUpdate, m_onTextureListUpdate); + NazaraSlot(ShaderGraph, OnTextureListUpdate, m_onTextureListUpdateSlot); + NazaraSlot(ShaderGraph, OnTexturePreviewUpdate, m_onTexturePreviewUpdateSlot); + std::size_t m_currentTextureIndex; QComboBox* m_textureSelection; QLabel* m_pixmapLabel; QPixmap m_pixmap; diff --git a/src/ShaderNode/DataModels/ShaderNode.cpp b/src/ShaderNode/DataModels/ShaderNode.cpp index fba232649..1f45d3ca5 100644 --- a/src/ShaderNode/DataModels/ShaderNode.cpp +++ b/src/ShaderNode/DataModels/ShaderNode.cpp @@ -1 +1,5 @@ #include + +void ShaderNode::setInData(std::shared_ptr, int) +{ +} diff --git a/src/ShaderNode/DataModels/ShaderNode.hpp b/src/ShaderNode/DataModels/ShaderNode.hpp index 71a279120..d33fc632d 100644 --- a/src/ShaderNode/DataModels/ShaderNode.hpp +++ b/src/ShaderNode/DataModels/ShaderNode.hpp @@ -17,7 +17,7 @@ class ShaderNode : public QtNodes::NodeDataModel inline ShaderGraph& GetGraph(); inline const ShaderGraph& GetGraph() const; - void setInData(std::shared_ptr, int) override {}; + void setInData(std::shared_ptr, int) override; private: ShaderGraph& m_graph; diff --git a/src/ShaderNode/DataModels/VecBinOp.cpp b/src/ShaderNode/DataModels/VecBinOp.cpp index dd13b5b56..7349b708f 100644 --- a/src/ShaderNode/DataModels/VecBinOp.cpp +++ b/src/ShaderNode/DataModels/VecBinOp.cpp @@ -1 +1,23 @@ #include + +void Vec4Add::ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) +{ + for (std::size_t i = 0; i < pixelCount; ++i) + { + unsigned int lValue = left[i]; + unsigned int rValue = right[i]; + + output[i] = static_cast(std::min(lValue + rValue, 255U)); + } +} + +void Vec4Mul::ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) +{ + for (std::size_t i = 0; i < pixelCount; ++i) + { + unsigned int lValue = left[i]; + unsigned int rValue = right[i]; + + output[i] = static_cast(lValue * rValue / 255); + } +} diff --git a/src/ShaderNode/DataModels/VecBinOp.hpp b/src/ShaderNode/DataModels/VecBinOp.hpp index 131a05f6d..97f433048 100644 --- a/src/ShaderNode/DataModels/VecBinOp.hpp +++ b/src/ShaderNode/DataModels/VecBinOp.hpp @@ -25,16 +25,14 @@ class VecBinOp : public ShaderNode void setInData(std::shared_ptr value, int index) override; private: + virtual void ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) = 0; void UpdatePreview(); - using InternalType = typename Data::InternalType; - - InternalType GetValue() const; - QLabel* m_pixmapLabel; QPixmap m_preview; std::shared_ptr m_lhs; std::shared_ptr m_rhs; + std::shared_ptr m_output; }; class Vec4Add : public VecBinOp @@ -44,6 +42,8 @@ class Vec4Add : public VecBinOp QString caption() const override { return "Vec4 addition"; } QString name() const override { return "Vec4Add"; } + + void ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) override; }; class Vec4Mul : public VecBinOp @@ -53,6 +53,8 @@ class Vec4Mul : public VecBinOp QString caption() const override { return "Vec4 multiplication"; } QString name() const override { return "Vec4Mul"; } + + void ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) override; }; #include diff --git a/src/ShaderNode/DataModels/VecBinOp.inl b/src/ShaderNode/DataModels/VecBinOp.inl index 371905221..fea7837a7 100644 --- a/src/ShaderNode/DataModels/VecBinOp.inl +++ b/src/ShaderNode/DataModels/VecBinOp.inl @@ -5,10 +5,11 @@ template VecBinOp::VecBinOp(ShaderGraph& graph) : ShaderNode(graph) { - m_preview = QPixmap(64, 64); + m_output = std::make_shared(); m_pixmapLabel = new QLabel; - m_pixmapLabel->setPixmap(m_preview); + m_pixmapLabel->setStyleSheet("background-color: rgba(0,0,0,0)"); + UpdatePreview(); } template @@ -39,7 +40,7 @@ unsigned int VecBinOp::nPorts(QtNodes::PortType portType) const { switch (portType) { - case QtNodes::PortType::In: return 2; + case QtNodes::PortType::In: return 2; case QtNodes::PortType::Out: return 1; } @@ -50,17 +51,18 @@ template std::shared_ptr VecBinOp::outData(QtNodes::PortIndex port) { assert(port == 0); - return std::make_shared(GetValue()); + return m_output; } template void VecBinOp::setInData(std::shared_ptr value, int index) { + assert(index == 0 || index == 1); + std::shared_ptr castedValue; if (value) { assert(dynamic_cast(value.get()) != nullptr); - assert(index == 0 || index == 1); castedValue = std::static_pointer_cast(value); } @@ -78,16 +80,36 @@ void VecBinOp::setInData(std::shared_ptr value, template void VecBinOp::UpdatePreview() { - InternalType value = GetValue(); - m_preview.fill(QColor::fromRgbF(value.x, value.y, value.z, value.w)); + if (m_lhs && m_rhs) + { + const QImage& leftPreview = m_lhs->preview; + const QImage& rightPreview = m_rhs->preview; + int maxWidth = std::max(leftPreview.width(), rightPreview.width()); + int maxHeight = std::max(leftPreview.height(), rightPreview.height()); + + // Exploit COW + QImage leftResized = leftPreview; + if (leftResized.width() != maxWidth || leftResized.height() != maxHeight) + leftResized = leftResized.scaled(maxWidth, maxHeight); + + QImage rightResized = rightPreview; + if (rightResized.width() != maxWidth || rightResized.height() != maxHeight) + rightResized = rightResized.scaled(maxWidth, maxHeight); + + int w = m_output->preview.width(); + int h = m_output->preview.height(); + + m_output->preview = QImage(maxWidth, maxHeight, QImage::Format_RGBA8888); + ApplyOp(leftResized.constBits(), rightResized.constBits(), m_output->preview.bits(), maxWidth * maxHeight * 4); + m_output->preview = m_output->preview.scaled(w, h); + + m_preview = QPixmap::fromImage(m_output->preview, Qt::AutoColor | Qt::NoOpaqueDetection); + } + else + { + m_preview = QPixmap(64, 64); + m_preview.fill(QColor::fromRgb(255, 255, 0, 0)); + } + m_pixmapLabel->setPixmap(m_preview); } - -template -auto VecBinOp::GetValue() const -> InternalType -{ - if (!m_lhs || !m_rhs) - return InternalType::Zero(); - - return m_lhs->value * m_rhs->value; -} diff --git a/src/ShaderNode/DataModels/VecValue.cpp b/src/ShaderNode/DataModels/VecValue.cpp index 84f1f4ea8..807df2955 100644 --- a/src/ShaderNode/DataModels/VecValue.cpp +++ b/src/ShaderNode/DataModels/VecValue.cpp @@ -1,89 +1 @@ #include -#include - -Vec2Value::Vec2Value(ShaderGraph& graph) : -VecValue(graph) -{ - UpdatePreview(); -} - -Nz::ShaderAst::ExpressionPtr Vec2Value::GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const -{ - assert(count == 0); - - return Nz::ShaderBuilder::Constant(GetValue()); -} - -auto Vec2Value::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const -> QtNodes::NodeDataType -{ - assert(portType == QtNodes::PortType::Out); - assert(portIndex == 0); - - return Vec2Data::Type(); -} - -std::shared_ptr Vec2Value::outData(QtNodes::PortIndex port) -{ - assert(port == 0); - - return std::make_shared(GetValue()); -} - -void Vec2Value::ComputePreview(QPixmap& pixmap) const -{ - Nz::Vector4f value = GetValue(); - pixmap.fill(QColor::fromRgbF(value.x, value.y, value.z, value.w)); -} - -Nz::Vector2f Vec2Value::GetValue() const -{ - float x = float(m_values[0]->value()); - float y = float(m_values[1]->value()); - - return Nz::Vector2f(x, y); -} - - -Vec4Value::Vec4Value(ShaderGraph& graph) : -VecValue(graph) -{ - UpdatePreview(); -} - -Nz::ShaderAst::ExpressionPtr Vec4Value::GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const -{ - assert(count == 0); - - return Nz::ShaderBuilder::Constant(GetValue()); -} - -auto Vec4Value::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const -> QtNodes::NodeDataType -{ - assert(portType == QtNodes::PortType::Out); - assert(portIndex == 0); - - return Vec4Data::Type(); -} - -std::shared_ptr Vec4Value::outData(QtNodes::PortIndex port) -{ - assert(port == 0); - - return std::make_shared(GetValue()); -} - -void Vec4Value::ComputePreview(QPixmap& pixmap) const -{ - Nz::Vector4f value = GetValue(); - pixmap.fill(QColor::fromRgbF(value.x, value.y, value.z, value.w)); -} - -Nz::Vector4f Vec4Value::GetValue() const -{ - float x = float(m_values[0]->value()); - float y = float(m_values[1]->value()); - float z = float(m_values[2]->value()); - float w = float(m_values[3]->value()); - - return Nz::Vector4f(x, y, z, w); -} diff --git a/src/ShaderNode/DataModels/VecValue.hpp b/src/ShaderNode/DataModels/VecValue.hpp index 10e215971..ba7a61f08 100644 --- a/src/ShaderNode/DataModels/VecValue.hpp +++ b/src/ShaderNode/DataModels/VecValue.hpp @@ -3,6 +3,7 @@ #ifndef NAZARA_SHADERNODES_VECVALUE_HPP #define NAZARA_SHADERNODES_VECVALUE_HPP +#include #include #include #include @@ -10,105 +11,105 @@ #include template +struct VecTypeHelper; + +template<> +struct VecTypeHelper<2> +{ + using Type = Nz::Vector2f; +}; + +template<> +struct VecTypeHelper<3> +{ + using Type = Nz::Vector3f; +}; + +template<> +struct VecTypeHelper<4> +{ + using Type = Nz::Vector4f; +}; + +template using VecType = typename VecTypeHelper::template Type; + +template class VecValue : public ShaderNode { public: VecValue(ShaderGraph& graph); ~VecValue() = default; + QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; + QWidget* embeddedWidget() override; unsigned int nPorts(QtNodes::PortType portType) const override; - protected: - void UpdatePreview(); + std::shared_ptr outData(QtNodes::PortIndex port) override; - virtual void ComputePreview(QPixmap& pixmap) const = 0; + Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const override; + + protected: + QColor ToColor() const; + VecType ToVector() const; + void UpdatePreview(); QLabel* m_pixmapLabel; QPixmap m_pixmap; QWidget* m_widget; QFormLayout* m_layout; - std::array m_values; + std::array m_spinboxes; }; -class Vec2Data : public QtNodes::NodeData +struct VecData : public QtNodes::NodeData { - public: - using InternalType = Nz::Vector2f; + inline VecData(); - inline Vec2Data(const InternalType& vec); - - QtNodes::NodeDataType type() const override - { - return Type(); - } - - static QtNodes::NodeDataType Type() - { - return { "vec2", "Vec2" }; - } - - InternalType value; + QImage preview; }; -class Vec4Data : public QtNodes::NodeData +struct Vec2Data : public VecData { - public: - using InternalType = Nz::Vector4f; + QtNodes::NodeDataType type() const override + { + return Type(); + } - inline Vec4Data(const InternalType& vec); - - QtNodes::NodeDataType type() const override - { - return Type(); - } - - static QtNodes::NodeDataType Type() - { - return { "vec4", "Vec4" }; - } - - InternalType value; + static QtNodes::NodeDataType Type() + { + return { "vec2", "Vec2" }; + } }; -class Vec2Value : public VecValue<2> +struct Vec4Data : public VecData +{ + QtNodes::NodeDataType type() const override + { + return Type(); + } + + static QtNodes::NodeDataType Type() + { + return { "vec4", "Vec4" }; + } +}; + +class Vec2Value : public VecValue<2, Vec2Data> { public: - Vec2Value(ShaderGraph& graph); - - Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const override; + using VecValue::VecValue; QString caption() const override { return "Vec2 value"; } QString name() const override { return "Vec2Value"; } - - QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; - - std::shared_ptr outData(QtNodes::PortIndex port) override; - - private: - void ComputePreview(QPixmap& pixmap) const override; - - Nz::Vector2f GetValue() const; }; -class Vec4Value : public VecValue<4> +class Vec4Value : public VecValue<4, Vec4Data> { public: - Vec4Value(ShaderGraph& graph); - - Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const override; + using VecValue::VecValue; QString caption() const override { return "Vec4 value"; } QString name() const override { return "Vec4Value"; } - - QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; - - std::shared_ptr outData(QtNodes::PortIndex port) override; - - private: - void ComputePreview(QPixmap& pixmap) const override; - - Nz::Vector4f GetValue() const; }; #include diff --git a/src/ShaderNode/DataModels/VecValue.inl b/src/ShaderNode/DataModels/VecValue.inl index e79eef3dc..8f8a53fc7 100644 --- a/src/ShaderNode/DataModels/VecValue.inl +++ b/src/ShaderNode/DataModels/VecValue.inl @@ -1,8 +1,10 @@ +#include +#include #include #include -template -VecValue::VecValue(ShaderGraph& graph) : +template +VecValue::VecValue(ShaderGraph& graph) : ShaderNode(graph) { constexpr std::array componentName = { 'X', 'Y', 'Z', 'W' }; @@ -11,21 +13,21 @@ ShaderNode(graph) m_layout = new QFormLayout; for (std::size_t i = 0; i < N; ++i) { - m_values[i] = new QDoubleSpinBox; - m_values[i]->setDecimals(6); - m_values[i]->setValue(1.0); - m_values[i]->setStyleSheet("background-color: rgba(255,255,255,255)"); - connect(m_values[i], qOverload(&QDoubleSpinBox::valueChanged), [this](double) + m_spinboxes[i] = new QDoubleSpinBox; + m_spinboxes[i]->setDecimals(6); + m_spinboxes[i]->setValue(1.0); + m_spinboxes[i]->setStyleSheet("background-color: rgba(255,255,255,255)"); + connect(m_spinboxes[i], qOverload(&QDoubleSpinBox::valueChanged), [this](double) { UpdatePreview(); Q_EMIT dataUpdated(0); }); - m_layout->addRow(QString::fromUtf8(&componentName[i], 1), m_values[i]); + m_layout->addRow(QString::fromUtf8(&componentName[i], 1), m_spinboxes[i]); } - m_pixmap = QPixmap(64, 64); + m_pixmap = QPixmap(32, 32); m_pixmap.fill(); m_pixmapLabel = new QLabel; @@ -36,16 +38,27 @@ ShaderNode(graph) m_widget = new QWidget; m_widget->setStyleSheet("background-color: rgba(0,0,0,0)"); m_widget->setLayout(m_layout); + + UpdatePreview(); } -template -QWidget* VecValue::embeddedWidget() +template +QtNodes::NodeDataType VecValue::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const +{ + assert(portType == QtNodes::PortType::Out); + assert(portIndex == 0); + + return Data::Type(); +} + +template +QWidget* VecValue::embeddedWidget() { return m_widget; } -template -unsigned int VecValue::nPorts(QtNodes::PortType portType) const +template +unsigned int VecValue::nPorts(QtNodes::PortType portType) const { switch (portType) { @@ -56,19 +69,64 @@ unsigned int VecValue::nPorts(QtNodes::PortType portType) const return 0; } -template -void VecValue::UpdatePreview() +template +std::shared_ptr VecValue::outData(QtNodes::PortIndex port) { - ComputePreview(m_pixmap); + assert(port == 0); + + auto out = std::make_shared(); + out->preview = QImage(1, 1, QImage::Format_RGBA8888); + out->preview.fill(ToColor()); + + return out; +} + +template +Nz::ShaderAst::ExpressionPtr VecValue::GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const +{ + assert(count == 0); + + return Nz::ShaderBuilder::Constant(ToVector()); +} + +template +QColor VecValue::ToColor() const +{ + std::array values = { 0.f, 0.f, 0.f, 1.f }; + + for (std::size_t i = 0; i < N; ++i) + values[i] = std::clamp(m_spinboxes[i]->value(), 0.0, 1.0); + + return QColor::fromRgbF(values[0], values[1], values[2], values[3]); +} + +template +VecType VecValue::ToVector() const +{ + std::array values = { 0.f, 0.f, 0.f, 1.f }; + + for (std::size_t i = 0; i < N; ++i) + values[i] = std::clamp(m_spinboxes[i]->value(), 0.0, 1.0); + + if constexpr (N == 2) + return Nz::Vector2f(values[0], values[1]); + else if constexpr (N == 3) + return Nz::Vector3f(values[0], values[1], values[2]); + else if constexpr (N == 4) + return Nz::Vector4f(values[0], values[1], values[2], values[3]); + else + static_assert(Nz::AlwaysFalse>(), "Unhandled vector size"); +} + +template +void VecValue::UpdatePreview() +{ + m_pixmap.fill(ToColor()); m_pixmapLabel->setPixmap(m_pixmap); } -Vec2Data::Vec2Data(const InternalType& vec) : -value(vec) -{ -} - -Vec4Data::Vec4Data(const InternalType& vec) : -value(vec) +inline VecData::VecData() : +preview(64, 64, QImage::Format_RGBA8888) { + preview.fill(QColor::fromRgb(255, 255, 255, 0)); } diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp index 478e99408..ee02e6c11 100644 --- a/src/ShaderNode/ShaderGraph.cpp +++ b/src/ShaderNode/ShaderGraph.cpp @@ -16,10 +16,10 @@ namespace { template - void RegisterShaderNode(ShaderGraph& graph, std::shared_ptr registry) + void RegisterShaderNode(ShaderGraph& graph, std::shared_ptr registry, QString category = QString()) { auto creator = [&] { return std::make_unique(graph); }; - registry->registerModel(std::move(creator)); + registry->registerModel(category, std::move(creator)); } } @@ -35,16 +35,19 @@ m_flowScene(BuildRegistry()) m_flowScene.createConnection(node2, 0, node1, 0); } -void ShaderGraph::AddTexture(std::string name, Nz::ShaderAst::ExpressionType type) +std::size_t ShaderGraph::AddTexture(std::string name, Nz::ShaderAst::ExpressionType type) { + std::size_t index = m_textures.size(); auto& textureEntry = m_textures.emplace_back(); textureEntry.name = std::move(name); textureEntry.type = type; OnTextureListUpdate(this); + + return index; } -Nz::ShaderAst::StatementPtr ShaderGraph::Generate() +Nz::ShaderAst::StatementPtr ShaderGraph::ToAst() { std::vector statements; @@ -82,14 +85,25 @@ Nz::ShaderAst::StatementPtr ShaderGraph::Generate() return std::make_shared(std::move(statements)); } +void ShaderGraph::UpdateTexturePreview(std::size_t textureIndex, QImage preview) +{ + assert(textureIndex < m_textures.size()); + auto& textureEntry = m_textures[textureIndex]; + textureEntry.preview = std::move(preview); + textureEntry.preview.convertTo(QImage::Format_RGBA8888); + + OnTexturePreviewUpdate(this, textureIndex); +} + std::shared_ptr ShaderGraph::BuildRegistry() { auto registry = std::make_shared(); - RegisterShaderNode(*this, registry); - RegisterShaderNode(*this, registry); - RegisterShaderNode(*this, registry); - RegisterShaderNode(*this, registry); - RegisterShaderNode(*this, registry); + RegisterShaderNode(*this, registry, "Output"); + RegisterShaderNode(*this, registry, "Texture"); + RegisterShaderNode(*this, registry, "Vector operations"); + RegisterShaderNode(*this, registry, "Vector operations"); + RegisterShaderNode(*this, registry, "Constants"); + RegisterShaderNode(*this, registry, "Constants"); return registry; } diff --git a/src/ShaderNode/ShaderGraph.hpp b/src/ShaderNode/ShaderGraph.hpp index 8e61175f1..cac252802 100644 --- a/src/ShaderNode/ShaderGraph.hpp +++ b/src/ShaderNode/ShaderGraph.hpp @@ -18,21 +18,26 @@ class ShaderGraph ShaderGraph(); ~ShaderGraph() = default; - void AddTexture(std::string name, Nz::ShaderAst::ExpressionType type); - - Nz::ShaderAst::StatementPtr Generate(); + std::size_t AddTexture(std::string name, Nz::ShaderAst::ExpressionType type); inline QtNodes::FlowScene& GetScene(); + inline const TextureEntry& GetTexture(std::size_t textureIndex) const; inline const std::vector& GetTextures(); - NazaraSignal(OnTextureListUpdate, ShaderGraph*); + Nz::ShaderAst::StatementPtr ToAst(); + + void UpdateTexturePreview(std::size_t texture, QImage preview); struct TextureEntry { std::string name; Nz::ShaderAst::ExpressionType type; + QImage preview; }; + NazaraSignal(OnTextureListUpdate, ShaderGraph*); + NazaraSignal(OnTexturePreviewUpdate, ShaderGraph*, std::size_t /*textureIndex*/); + private: std::shared_ptr BuildRegistry(); diff --git a/src/ShaderNode/ShaderGraph.inl b/src/ShaderNode/ShaderGraph.inl index 07c20a134..1f0b463e9 100644 --- a/src/ShaderNode/ShaderGraph.inl +++ b/src/ShaderNode/ShaderGraph.inl @@ -5,7 +5,14 @@ inline QtNodes::FlowScene& ShaderGraph::GetScene() return m_flowScene; } +inline auto ShaderGraph::GetTexture(std::size_t textureIndex) const -> const TextureEntry& +{ + assert(textureIndex < m_textures.size()); + return m_textures[textureIndex]; +} + inline auto ShaderGraph::GetTextures() -> const std::vector& { return m_textures; } + diff --git a/src/ShaderNode/Widgets/MainWindow.cpp b/src/ShaderNode/Widgets/MainWindow.cpp new file mode 100644 index 000000000..d4a661790 --- /dev/null +++ b/src/ShaderNode/Widgets/MainWindow.cpp @@ -0,0 +1,50 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +MainWindow::MainWindow(ShaderGraph& graph) : +m_shaderGraph(graph) +{ + setWindowTitle("Nazara Shader nodes"); + + QtNodes::FlowScene* scene = &m_shaderGraph.GetScene(); + + QtNodes::FlowView* flowView = new QtNodes::FlowView(scene); + setCentralWidget(flowView); + + QDockWidget* textureDock = new QDockWidget(tr("&Textures")); + + TextureEditor* textureEditor = new TextureEditor(m_shaderGraph); + textureDock->setWidget(textureEditor); + + addDockWidget(Qt::LeftDockWidgetArea, textureDock); + + BuildMenu(); +} + +void MainWindow::BuildMenu() +{ + QMenu* compileMenu = menuBar()->addMenu(tr("&Compilation")); + QAction* compileToGlsl = compileMenu->addAction(tr("GLSL")); + connect(compileToGlsl, &QAction::triggered, [&](bool) { OnCompileToGLSL(); }); +} + +void MainWindow::OnCompileToGLSL() +{ + Nz::GlslWriter writer; + Nz::String glsl = writer.Generate(m_shaderGraph.ToAst()); + + std::cout << glsl << std::endl; + + QTextEdit* output = new QTextEdit; + output->setReadOnly(true); + output->setText(QString::fromUtf8(glsl.GetConstBuffer(), int(glsl.GetSize()))); + output->setAttribute(Qt::WA_DeleteOnClose, true); + output->setWindowTitle("GLSL Output"); + output->show(); +} diff --git a/src/ShaderNode/Widgets/MainWindow.hpp b/src/ShaderNode/Widgets/MainWindow.hpp new file mode 100644 index 000000000..fa8257bcf --- /dev/null +++ b/src/ShaderNode/Widgets/MainWindow.hpp @@ -0,0 +1,26 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_MAINWINDOW_HPP +#define NAZARA_SHADERNODES_MAINWINDOW_HPP + +#include +#include + +class ShaderGraph; + +class MainWindow : public QMainWindow +{ + public: + MainWindow(ShaderGraph& graph); + ~MainWindow() = default; + + private: + void BuildMenu(); + void OnCompileToGLSL(); + + ShaderGraph& m_shaderGraph; +}; + +#include + +#endif diff --git a/src/ShaderNode/Widgets/MainWindow.inl b/src/ShaderNode/Widgets/MainWindow.inl new file mode 100644 index 000000000..48dbe409e --- /dev/null +++ b/src/ShaderNode/Widgets/MainWindow.inl @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/Widgets/TextureEditor.cpp b/src/ShaderNode/Widgets/TextureEditor.cpp new file mode 100644 index 000000000..594262c1a --- /dev/null +++ b/src/ShaderNode/Widgets/TextureEditor.cpp @@ -0,0 +1,81 @@ +#include +#include +#include +#include +#include +#include +#include + +TextureEditor::TextureEditor(ShaderGraph& graph) : +m_shaderGraph(graph) +{ + m_textureList = new QListWidget(this); + connect(m_textureList, &QListWidget::currentRowChanged, this, &TextureEditor::OnTextureSelectionUpdate); + + m_pixmapLabel = new QLabel; + + QPushButton* updateTextureButton = new QPushButton(tr("Load texture...")); + connect(updateTextureButton, &QPushButton::released, this, &TextureEditor::OnLoadTexture); + + m_layout = new QVBoxLayout; + m_layout->addWidget(m_textureList); + m_layout->addWidget(updateTextureButton); + m_layout->addWidget(m_pixmapLabel); + + setLayout(m_layout); + + m_onTextureListUpdateSlot.Connect(m_shaderGraph.OnTextureListUpdate, this, &TextureEditor::OnTextureListUpdate); + m_onTexturePreviewUpdateSlot.Connect(m_shaderGraph.OnTexturePreviewUpdate, this, &TextureEditor::OnTexturePreviewUpdate); + + RefreshTextures(); +} + +void TextureEditor::OnLoadTexture() +{ + if (!m_currentTextureIndex) + return; + + QString fileName = QFileDialog::getOpenFileName(nullptr, tr("Open Image"), QDir::homePath(), tr("Image Files (*.png *.jpg *.bmp)")); + if (fileName.isEmpty()) + return; + + m_shaderGraph.UpdateTexturePreview(m_currentTextureIndex.value(), QImage(fileName)); +} + +void TextureEditor::OnTextureSelectionUpdate(int textureIndex) +{ + if (textureIndex >= 0) + { + m_currentTextureIndex = textureIndex; + UpdateTexturePreview(); + } + else + m_currentTextureIndex.reset(); +} + +void TextureEditor::OnTextureListUpdate(ShaderGraph* graph) +{ + RefreshTextures(); +} + +void TextureEditor::OnTexturePreviewUpdate(ShaderGraph* /*graph*/, std::size_t textureIndex) +{ + if (m_currentTextureIndex && *m_currentTextureIndex == textureIndex) + UpdateTexturePreview(); +} + +void TextureEditor::RefreshTextures() +{ + m_textureList->clear(); + m_textureList->setCurrentRow(-1); + + for (const auto& textureEntry : m_shaderGraph.GetTextures()) + m_textureList->addItem(QString::fromStdString(textureEntry.name)); +} + +void TextureEditor::UpdateTexturePreview() +{ + assert(m_currentTextureIndex); + const auto& textureEntry = m_shaderGraph.GetTexture(*m_currentTextureIndex); + m_pixmapLabel->setPixmap(QPixmap::fromImage(textureEntry.preview).scaled(128, 128, Qt::KeepAspectRatio)); +} diff --git a/src/ShaderNode/Widgets/TextureEditor.hpp b/src/ShaderNode/Widgets/TextureEditor.hpp new file mode 100644 index 000000000..fcdbf3f7c --- /dev/null +++ b/src/ShaderNode/Widgets/TextureEditor.hpp @@ -0,0 +1,40 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_TEXTUREEDITOR_HPP +#define NAZARA_SHADERNODES_TEXTUREEDITOR_HPP + +#include +#include +#include + +class QLabel; +class QListWidget; +class QVBoxLayout; + +class TextureEditor : public QWidget +{ + public: + TextureEditor(ShaderGraph& graph); + ~TextureEditor() = default; + + private: + void OnLoadTexture(); + void OnTextureSelectionUpdate(int textureIndex); + void OnTextureListUpdate(ShaderGraph* graph); + void OnTexturePreviewUpdate(ShaderGraph* graph, std::size_t textureIndex); + void RefreshTextures(); + void UpdateTexturePreview(); + + NazaraSlot(ShaderGraph, OnTextureListUpdate, m_onTextureListUpdateSlot); + NazaraSlot(ShaderGraph, OnTexturePreviewUpdate, m_onTexturePreviewUpdateSlot); + + std::optional m_currentTextureIndex; + ShaderGraph& m_shaderGraph; + QLabel* m_pixmapLabel; + QListWidget* m_textureList; + QVBoxLayout* m_layout; +}; + +#include + +#endif diff --git a/src/ShaderNode/Widgets/TextureEditor.inl b/src/ShaderNode/Widgets/TextureEditor.inl new file mode 100644 index 000000000..d11298db1 --- /dev/null +++ b/src/ShaderNode/Widgets/TextureEditor.inl @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/main.cpp b/src/ShaderNode/main.cpp index 7878bec22..648cbbbbc 100644 --- a/src/ShaderNode/main.cpp +++ b/src/ShaderNode/main.cpp @@ -1,59 +1,17 @@ -#include -#include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include +#include #include -void GenerateGLSL(ShaderGraph& graph) -{ - Nz::GlslWriter writer; - Nz::String glsl = writer.Generate(graph.Generate()); - - std::cout << glsl << std::endl; - - QTextEdit* output = new QTextEdit; - output->setReadOnly(true); - output->setText(QString::fromUtf8(glsl.GetConstBuffer(), glsl.GetSize())); - output->setAttribute(Qt::WA_DeleteOnClose, true); - output->setWindowTitle("GLSL Output"); - output->show(); -} - int main(int argc, char* argv[]) { QApplication app(argc, argv); ShaderGraph shaderGraph; - shaderGraph.AddTexture("TextureMachin", Nz::ShaderAst::ExpressionType::Sampler2D); + shaderGraph.AddTexture("Potato", Nz::ShaderAst::ExpressionType::Sampler2D); + shaderGraph.AddTexture("Blackbird", Nz::ShaderAst::ExpressionType::Sampler2D); - QWidget mainWindow; - QVBoxLayout* layout = new QVBoxLayout; - layout->setContentsMargins(0, 0, 0, 0); - layout->setSpacing(0); - - QtNodes::FlowScene* scene = &shaderGraph.GetScene(); - - QMenuBar* menuBar = new QMenuBar; - QAction* glslCode = menuBar->addAction("To GLSL"); - QObject::connect(glslCode, &QAction::triggered, [&](bool) { GenerateGLSL(shaderGraph); }); - - layout->addWidget(new QtNodes::FlowView(scene)); - layout->addWidget(menuBar); - - mainWindow.setLayout(layout); - mainWindow.setWindowTitle("Nazara Shader nodes"); + MainWindow mainWindow(shaderGraph); mainWindow.resize(1280, 720); mainWindow.show(); From 5169e0fe836d70b0346a4536b7aeff11c91ba12e Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 22 May 2020 19:21:56 +0200 Subject: [PATCH 197/316] ShaderNode: Add captions --- src/ShaderNode/DataModels/SampleTexture.cpp | 27 +++++++++++++++++++++ src/ShaderNode/DataModels/SampleTexture.hpp | 5 ++++ 2 files changed, 32 insertions(+) diff --git a/src/ShaderNode/DataModels/SampleTexture.cpp b/src/ShaderNode/DataModels/SampleTexture.cpp index 6d222abb6..180989226 100644 --- a/src/ShaderNode/DataModels/SampleTexture.cpp +++ b/src/ShaderNode/DataModels/SampleTexture.cpp @@ -121,6 +121,33 @@ auto SampleTexture::dataType(QtNodes::PortType portType, QtNodes::PortIndex port } } +QString SampleTexture::portCaption(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const +{ + switch (portType) + { + case QtNodes::PortType::In: + { + assert(portIndex == 0); + return tr("UV"); + } + + case QtNodes::PortType::Out: + { + assert(portIndex == 0); + return tr("Sample"); + } + + default: + assert(false); + throw std::runtime_error("Invalid PortType"); + } +} + +bool SampleTexture::portCaptionVisible(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const +{ + return true; +} + std::shared_ptr SampleTexture::outData(QtNodes::PortIndex port) { assert(port == 0); diff --git a/src/ShaderNode/DataModels/SampleTexture.hpp b/src/ShaderNode/DataModels/SampleTexture.hpp index f717797f2..af11d14ec 100644 --- a/src/ShaderNode/DataModels/SampleTexture.hpp +++ b/src/ShaderNode/DataModels/SampleTexture.hpp @@ -25,6 +25,11 @@ class SampleTexture : public ShaderNode unsigned int nPorts(QtNodes::PortType portType) const override; QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; + + QString portCaption(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; + + bool portCaptionVisible(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; + std::shared_ptr outData(QtNodes::PortIndex port) override; protected: From 206724c911e008468b85749b8339b8b117bd1720 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 22 May 2020 23:50:46 +0200 Subject: [PATCH 198/316] ShaderNode: Add inputs --- src/ShaderNode/DataModels/InputValue.cpp | 132 ++++++++++++++++++++ src/ShaderNode/DataModels/InputValue.hpp | 47 +++++++ src/ShaderNode/DataModels/InputValue.inl | 2 + src/ShaderNode/DataModels/SampleTexture.cpp | 15 ++- src/ShaderNode/Enums.cpp | 42 +++++++ src/ShaderNode/Enums.hpp | 48 +++++++ src/ShaderNode/Enums.inl | 1 + src/ShaderNode/ShaderGraph.cpp | 32 ++++- src/ShaderNode/ShaderGraph.hpp | 24 +++- src/ShaderNode/ShaderGraph.inl | 13 +- src/ShaderNode/Widgets/InputEditDialog.cpp | 80 ++++++++++++ src/ShaderNode/Widgets/InputEditDialog.hpp | 41 ++++++ src/ShaderNode/Widgets/InputEditDialog.inl | 1 + src/ShaderNode/Widgets/InputEditor.cpp | 97 ++++++++++++++ src/ShaderNode/Widgets/InputEditor.hpp | 39 ++++++ src/ShaderNode/Widgets/InputEditor.inl | 1 + src/ShaderNode/Widgets/MainWindow.cpp | 9 ++ src/ShaderNode/Widgets/TextureEditor.cpp | 2 +- src/ShaderNode/Widgets/TextureEditor.hpp | 2 +- src/ShaderNode/main.cpp | 4 +- 20 files changed, 620 insertions(+), 12 deletions(-) create mode 100644 src/ShaderNode/DataModels/InputValue.cpp create mode 100644 src/ShaderNode/DataModels/InputValue.hpp create mode 100644 src/ShaderNode/DataModels/InputValue.inl create mode 100644 src/ShaderNode/Enums.cpp create mode 100644 src/ShaderNode/Enums.hpp create mode 100644 src/ShaderNode/Enums.inl create mode 100644 src/ShaderNode/Widgets/InputEditDialog.cpp create mode 100644 src/ShaderNode/Widgets/InputEditDialog.hpp create mode 100644 src/ShaderNode/Widgets/InputEditDialog.inl create mode 100644 src/ShaderNode/Widgets/InputEditor.cpp create mode 100644 src/ShaderNode/Widgets/InputEditor.hpp create mode 100644 src/ShaderNode/Widgets/InputEditor.inl diff --git a/src/ShaderNode/DataModels/InputValue.cpp b/src/ShaderNode/DataModels/InputValue.cpp new file mode 100644 index 000000000..f1cc97d0d --- /dev/null +++ b/src/ShaderNode/DataModels/InputValue.cpp @@ -0,0 +1,132 @@ +#include +#include +#include +#include + +InputValue::InputValue(ShaderGraph& graph) : +ShaderNode(graph), +m_currentInputIndex(0) +{ + m_layout = new QVBoxLayout; + + m_inputSelection = new QComboBox; + m_inputSelection->setStyleSheet("background-color: rgba(255,255,255,255)"); + connect(m_inputSelection, qOverload(&QComboBox::currentIndexChanged), [&](int index) + { + if (index < 0) + return; + + m_currentInputIndex = static_cast(index); + UpdatePreview(); + }); + + m_layout->addWidget(m_inputSelection); + + m_previewLabel = new QLabel; + + m_layout->addWidget(m_previewLabel); + + m_widget = new QWidget; + m_widget->setStyleSheet("background-color: rgba(0,0,0,0)"); + m_widget->setLayout(m_layout); + + m_onInputListUpdateSlot.Connect(GetGraph().OnInputListUpdate, [&](ShaderGraph*) { UpdateInputList(); }); + m_onInputUpdateSlot.Connect(GetGraph().OnInputUpdate, [&](ShaderGraph*, std::size_t inputIndex) + { + if (m_currentInputIndex == inputIndex) + UpdatePreview(); + }); + + UpdateInputList(); + UpdatePreview(); +} + +QWidget* InputValue::embeddedWidget() +{ + return m_widget; +} + +unsigned int InputValue::nPorts(QtNodes::PortType portType) const +{ + switch (portType) + { + case QtNodes::PortType::In: return 0; + case QtNodes::PortType::Out: return 1; + } + + return 0; +} + +void InputValue::UpdatePreview() +{ + if (m_inputSelection->count() == 0) + return; + + Q_EMIT dataUpdated(0); +} + +void InputValue::UpdateInputList() +{ + QString currentInput = m_inputSelection->currentText(); + m_inputSelection->clear(); + + for (const auto& inputEntry : GetGraph().GetInputs()) + m_inputSelection->addItem(QString::fromStdString(inputEntry.name)); + + m_inputSelection->setCurrentText(currentInput); +} + +Nz::ShaderAst::ExpressionPtr InputValue::GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const +{ + assert(count == 0); + + const auto& inputEntry = GetGraph().GetInput(m_currentInputIndex); + + Nz::ShaderAst::ExpressionType expression = [&] + { + switch (inputEntry.type) + { + case InputType::Bool: return Nz::ShaderAst::ExpressionType::Boolean; + case InputType::Float1: return Nz::ShaderAst::ExpressionType::Float1; + case InputType::Float2: return Nz::ShaderAst::ExpressionType::Float2; + case InputType::Float3: return Nz::ShaderAst::ExpressionType::Float3; + case InputType::Float4: return Nz::ShaderAst::ExpressionType::Float4; + } + + assert(false); + throw std::runtime_error("Unhandled input type"); + }(); + + return Nz::ShaderBuilder::Input(inputEntry.name, expression); +} + +auto InputValue::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const -> QtNodes::NodeDataType +{ + assert(portType == QtNodes::PortType::Out); + assert(portIndex == 0); + + const auto& inputEntry = GetGraph().GetInput(m_currentInputIndex); + switch (inputEntry.type) + { + //case InputType::Bool: return Nz::ShaderAst::ExpressionType::Boolean; + //case InputType::Float1: return Nz::ShaderAst::ExpressionType::Float1; + case InputType::Float2: return Vec2Data::Type(); + //case InputType::Float3: return Nz::ShaderAst::ExpressionType::Float3; + case InputType::Float4: return Vec4Data::Type(); + } + + assert(false); + throw std::runtime_error("Unhandled input type"); +} + +std::shared_ptr InputValue::outData(QtNodes::PortIndex port) +{ + assert(port == 0); + + const auto& inputEntry = GetGraph().GetInput(m_currentInputIndex); + + auto vecData = std::make_shared(); + vecData->preview = QImage(); + + return vecData; +} diff --git a/src/ShaderNode/DataModels/InputValue.hpp b/src/ShaderNode/DataModels/InputValue.hpp new file mode 100644 index 000000000..63e896adf --- /dev/null +++ b/src/ShaderNode/DataModels/InputValue.hpp @@ -0,0 +1,47 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_INPUTVALUE_HPP +#define NAZARA_SHADERNODES_INPUTVALUE_HPP + +#include +#include +#include +#include +#include +#include + +class InputValue : public ShaderNode +{ + public: + InputValue(ShaderGraph& graph); + ~InputValue() = default; + + Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const override; + + QString caption() const override { return "Input"; } + QString name() const override { return "Input"; } + + QWidget* embeddedWidget() override; + unsigned int nPorts(QtNodes::PortType portType) const override; + + QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; + + std::shared_ptr outData(QtNodes::PortIndex port) override; + + protected: + void UpdatePreview(); + void UpdateInputList(); + + NazaraSlot(ShaderGraph, OnInputListUpdate, m_onInputListUpdateSlot); + NazaraSlot(ShaderGraph, OnInputUpdate, m_onInputUpdateSlot); + + std::size_t m_currentInputIndex; + QComboBox* m_inputSelection; + QLabel* m_previewLabel; + QWidget* m_widget; + QVBoxLayout* m_layout; +}; + +#include + +#endif diff --git a/src/ShaderNode/DataModels/InputValue.inl b/src/ShaderNode/DataModels/InputValue.inl new file mode 100644 index 000000000..ff350c7c4 --- /dev/null +++ b/src/ShaderNode/DataModels/InputValue.inl @@ -0,0 +1,2 @@ +#include +#include diff --git a/src/ShaderNode/DataModels/SampleTexture.cpp b/src/ShaderNode/DataModels/SampleTexture.cpp index 180989226..925094b6b 100644 --- a/src/ShaderNode/DataModels/SampleTexture.cpp +++ b/src/ShaderNode/DataModels/SampleTexture.cpp @@ -94,7 +94,20 @@ Nz::ShaderAst::ExpressionPtr SampleTexture::GetExpression(Nz::ShaderAst::Express { assert(count == 1); - auto sampler = Nz::ShaderBuilder::Uniform("Texture0", Nz::ShaderAst::ExpressionType::Sampler2D); + const auto& textureEntry = GetGraph().GetTexture(m_currentTextureIndex); + + Nz::ShaderAst::ExpressionType expression = [&] + { + switch (textureEntry.type) + { + case TextureType::Sampler2D: return Nz::ShaderAst::ExpressionType::Sampler2D; + } + + assert(false); + throw std::runtime_error("Unhandled texture type"); + }(); + + auto sampler = Nz::ShaderBuilder::Uniform(textureEntry.name, expression); return Nz::ShaderBuilder::Sample2D(sampler, expressions[0]); } diff --git a/src/ShaderNode/Enums.cpp b/src/ShaderNode/Enums.cpp new file mode 100644 index 000000000..f280ce793 --- /dev/null +++ b/src/ShaderNode/Enums.cpp @@ -0,0 +1,42 @@ +#include +#include + +const char* EnumToString(InputRole role) +{ + switch (role) + { + case InputRole::None: return "None"; + case InputRole::Normal: return "Normal"; + case InputRole::Position: return "Position"; + case InputRole::TexCoord: return "TexCoord"; + } + + assert(false); + return ""; +} + +const char* EnumToString(InputType input) +{ + switch (input) + { + case InputType::Bool: return "Bool"; + case InputType::Float1: return "Float"; + case InputType::Float2: return "Float2"; + case InputType::Float3: return "Float3"; + case InputType::Float4: return "Float4"; + } + + assert(false); + return ""; +} + +const char* EnumToString(TextureType textureType) +{ + switch (textureType) + { + case TextureType::Sampler2D: return "Sampler2D"; + } + + assert(false); + return ""; +} diff --git a/src/ShaderNode/Enums.hpp b/src/ShaderNode/Enums.hpp new file mode 100644 index 000000000..6a7a34336 --- /dev/null +++ b/src/ShaderNode/Enums.hpp @@ -0,0 +1,48 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_ENUMS_HPP +#define NAZARA_SHADERNODES_ENUMS_HPP + +#include + +enum class InputRole +{ + None, + Normal, + Position, + TexCoord, + + Max = TexCoord +}; + +constexpr std::size_t InputRoleCount = static_cast(InputRole::Max) + 1; + +enum class InputType +{ + Bool, + Float1, + Float2, + Float3, + Float4, + + Max = Float4 +}; + +constexpr std::size_t InputTypeCount = static_cast(InputType::Max) + 1; + +enum class TextureType +{ + Sampler2D, + + Max = Sampler2D +}; + +constexpr std::size_t TextureTypeCount = static_cast(TextureType::Max) + 1; + +const char* EnumToString(InputRole role); +const char* EnumToString(InputType input); +const char* EnumToString(TextureType textureType); + +#include + +#endif diff --git a/src/ShaderNode/Enums.inl b/src/ShaderNode/Enums.inl new file mode 100644 index 000000000..a23a54efb --- /dev/null +++ b/src/ShaderNode/Enums.inl @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp index ee02e6c11..0b95e137f 100644 --- a/src/ShaderNode/ShaderGraph.cpp +++ b/src/ShaderNode/ShaderGraph.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -35,7 +36,21 @@ m_flowScene(BuildRegistry()) m_flowScene.createConnection(node2, 0, node1, 0); } -std::size_t ShaderGraph::AddTexture(std::string name, Nz::ShaderAst::ExpressionType type) +std::size_t ShaderGraph::AddInput(std::string name, InputType type, InputRole role, std::size_t roleIndex) +{ + std::size_t index = m_inputs.size(); + auto& inputEntry = m_inputs.emplace_back(); + inputEntry.name = std::move(name); + inputEntry.role = role; + inputEntry.roleIndex = roleIndex; + inputEntry.type = type; + + OnInputListUpdate(this); + + return index; +} + +std::size_t ShaderGraph::AddTexture(std::string name, TextureType type) { std::size_t index = m_textures.size(); auto& textureEntry = m_textures.emplace_back(); @@ -85,6 +100,18 @@ Nz::ShaderAst::StatementPtr ShaderGraph::ToAst() return std::make_shared(std::move(statements)); } +void ShaderGraph::UpdateInput(std::size_t inputIndex, std::string name, InputType type, InputRole role, std::size_t roleIndex) +{ + assert(inputIndex < m_inputs.size()); + auto& inputEntry = m_inputs[inputIndex]; + inputEntry.name = std::move(name); + inputEntry.role = role; + inputEntry.roleIndex = roleIndex; + inputEntry.type = type; + + OnInputUpdate(this, inputIndex); +} + void ShaderGraph::UpdateTexturePreview(std::size_t textureIndex, QImage preview) { assert(textureIndex < m_textures.size()); @@ -98,7 +125,8 @@ void ShaderGraph::UpdateTexturePreview(std::size_t textureIndex, QImage preview) std::shared_ptr ShaderGraph::BuildRegistry() { auto registry = std::make_shared(); - RegisterShaderNode(*this, registry, "Output"); + RegisterShaderNode(*this, registry, "Outputs"); + RegisterShaderNode(*this, registry, "Inputs"); RegisterShaderNode(*this, registry, "Texture"); RegisterShaderNode(*this, registry, "Vector operations"); RegisterShaderNode(*this, registry, "Vector operations"); diff --git a/src/ShaderNode/ShaderGraph.hpp b/src/ShaderNode/ShaderGraph.hpp index cac252802..132c9c25b 100644 --- a/src/ShaderNode/ShaderGraph.hpp +++ b/src/ShaderNode/ShaderGraph.hpp @@ -6,35 +6,50 @@ #include #include #include -#include +#include #include #include class ShaderGraph { public: + struct InputEntry; struct TextureEntry; ShaderGraph(); ~ShaderGraph() = default; - std::size_t AddTexture(std::string name, Nz::ShaderAst::ExpressionType type); + std::size_t AddInput(std::string name, InputType type, InputRole role, std::size_t roleIndex); + std::size_t AddTexture(std::string name, TextureType type); + inline const InputEntry& GetInput(std::size_t inputIndex) const; + inline const std::vector& GetInputs() const; inline QtNodes::FlowScene& GetScene(); inline const TextureEntry& GetTexture(std::size_t textureIndex) const; - inline const std::vector& GetTextures(); + inline const std::vector& GetTextures() const; Nz::ShaderAst::StatementPtr ToAst(); + void UpdateInput(std::size_t inputIndex, std::string name, InputType type, InputRole role, std::size_t roleIndex); void UpdateTexturePreview(std::size_t texture, QImage preview); + struct InputEntry + { + std::size_t roleIndex; + std::string name; + InputRole role; + InputType type; + }; + struct TextureEntry { std::string name; - Nz::ShaderAst::ExpressionType type; + TextureType type; QImage preview; }; + NazaraSignal(OnInputListUpdate, ShaderGraph*); + NazaraSignal(OnInputUpdate, ShaderGraph*, std::size_t /*inputIndex*/); NazaraSignal(OnTextureListUpdate, ShaderGraph*); NazaraSignal(OnTexturePreviewUpdate, ShaderGraph*, std::size_t /*textureIndex*/); @@ -42,6 +57,7 @@ class ShaderGraph std::shared_ptr BuildRegistry(); QtNodes::FlowScene m_flowScene; + std::vector m_inputs; std::vector m_textures; }; diff --git a/src/ShaderNode/ShaderGraph.inl b/src/ShaderNode/ShaderGraph.inl index 1f0b463e9..bb39d44f3 100644 --- a/src/ShaderNode/ShaderGraph.inl +++ b/src/ShaderNode/ShaderGraph.inl @@ -1,5 +1,16 @@ #include +inline auto ShaderGraph::GetInput(std::size_t inputIndex) const -> const InputEntry& +{ + assert(inputIndex < m_inputs.size()); + return m_inputs[inputIndex]; +} + +inline auto ShaderGraph::GetInputs() const -> const std::vector& +{ + return m_inputs; +} + inline QtNodes::FlowScene& ShaderGraph::GetScene() { return m_flowScene; @@ -11,7 +22,7 @@ inline auto ShaderGraph::GetTexture(std::size_t textureIndex) const -> const Tex return m_textures[textureIndex]; } -inline auto ShaderGraph::GetTextures() -> const std::vector& +inline auto ShaderGraph::GetTextures() const -> const std::vector& { return m_textures; } diff --git a/src/ShaderNode/Widgets/InputEditDialog.cpp b/src/ShaderNode/Widgets/InputEditDialog.cpp new file mode 100644 index 000000000..d9642966c --- /dev/null +++ b/src/ShaderNode/Widgets/InputEditDialog.cpp @@ -0,0 +1,80 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +InputEditDialog::InputEditDialog(QWidget* parent) : +QDialog(parent) +{ + setWindowTitle(tr("Input edit dialog")); + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + + m_inputName = new QLineEdit; + + m_typeList = new QComboBox; + for (std::size_t i = 0; i < InputTypeCount; ++i) + m_typeList->addItem(EnumToString(static_cast(i))); + + m_roleList = new QComboBox; + for (std::size_t i = 0; i < InputRoleCount; ++i) + m_roleList->addItem(EnumToString(static_cast(i))); + + m_roleIndex = new QSpinBox; + + QFormLayout* formLayout = new QFormLayout; + formLayout->addRow(tr("Name"), m_inputName); + formLayout->addRow(tr("Type"), m_typeList); + formLayout->addRow(tr("Role"), m_roleList); + formLayout->addRow(tr("Role index"), m_roleIndex); + + QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + connect(buttonBox, &QDialogButtonBox::accepted, this, &InputEditDialog::OnAccept); + connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + + QVBoxLayout* verticalLayout = new QVBoxLayout; + verticalLayout->addLayout(formLayout); + verticalLayout->addWidget(buttonBox); + + setLayout(verticalLayout); +} + +InputEditDialog::InputEditDialog(const InputInfo& input, QWidget* parent) : +InputEditDialog(parent) +{ + m_inputName->setText(QString::fromStdString(input.name)); + m_roleIndex->setValue(int(input.roleIndex)); + m_roleList->setCurrentText(EnumToString(input.role)); + m_typeList->setCurrentText(EnumToString(input.type)); +} + +InputInfo InputEditDialog::GetInputInfo() const +{ + InputInfo inputInfo; + inputInfo.name = m_inputName->text().toStdString(); + inputInfo.role = static_cast(m_roleList->currentIndex()); + inputInfo.roleIndex = static_cast(m_roleIndex->value()); + inputInfo.type = static_cast(m_typeList->currentIndex()); + + return inputInfo; +} + +void InputEditDialog::OnAccept() +{ + if (m_inputName->text().isEmpty()) + { + QMessageBox::critical(this, tr("Empty name"), tr("Input name must be set"), QMessageBox::Ok); + return; + } + + if (m_typeList->currentIndex() < 0) + { + QMessageBox::critical(this, tr("Invalid type"), tr("You must select a type"), QMessageBox::Ok); + return; + } + + accept(); +} diff --git a/src/ShaderNode/Widgets/InputEditDialog.hpp b/src/ShaderNode/Widgets/InputEditDialog.hpp new file mode 100644 index 000000000..829697049 --- /dev/null +++ b/src/ShaderNode/Widgets/InputEditDialog.hpp @@ -0,0 +1,41 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_INPUTEDITDIALOG_HPP +#define NAZARA_SHADERNODES_INPUTEDITDIALOG_HPP + +#include +#include + +class QComboBox; +class QLineEdit; +class QSpinBox; + +struct InputInfo +{ + std::size_t roleIndex; + std::string name; + InputRole role; + InputType type; +}; + +class InputEditDialog : public QDialog +{ + public: + InputEditDialog(QWidget* parent = nullptr); + InputEditDialog(const InputInfo& input, QWidget* parent = nullptr); + ~InputEditDialog() = default; + + InputInfo GetInputInfo() const; + + private: + void OnAccept(); + + QComboBox* m_roleList; + QComboBox* m_typeList; + QLineEdit* m_inputName; + QSpinBox* m_roleIndex; +}; + +#include + +#endif diff --git a/src/ShaderNode/Widgets/InputEditDialog.inl b/src/ShaderNode/Widgets/InputEditDialog.inl new file mode 100644 index 000000000..a480716aa --- /dev/null +++ b/src/ShaderNode/Widgets/InputEditDialog.inl @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/Widgets/InputEditor.cpp b/src/ShaderNode/Widgets/InputEditor.cpp new file mode 100644 index 000000000..86a28a2eb --- /dev/null +++ b/src/ShaderNode/Widgets/InputEditor.cpp @@ -0,0 +1,97 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +InputEditor::InputEditor(ShaderGraph& graph) : +m_shaderGraph(graph) +{ + m_inputList = new QListWidget(this); + connect(m_inputList, &QListWidget::currentRowChanged, this, &InputEditor::OnInputSelectionUpdate); + connect(m_inputList, &QListWidget::itemDoubleClicked, [this](QListWidgetItem* item) + { + OnEditInput(m_inputList->row(item)); + }); + + QPushButton* addInputButton = new QPushButton(tr("Add input...")); + connect(addInputButton, &QPushButton::released, this, &InputEditor::OnAddInput); + + m_layout = new QVBoxLayout; + m_layout->addWidget(m_inputList); + m_layout->addWidget(addInputButton); + + setLayout(m_layout); + + m_onInputListUpdateSlot.Connect(m_shaderGraph.OnInputListUpdate, this, &InputEditor::OnInputListUpdate); + m_onInputUpdateSlot.Connect(m_shaderGraph.OnInputUpdate, this, &InputEditor::OnInputUpdate); + + RefreshInputs(); +} + +void InputEditor::OnAddInput() +{ + InputEditDialog* dialog = new InputEditDialog(this); + dialog->setAttribute(Qt::WA_DeleteOnClose, true); + connect(dialog, &QDialog::accepted, [this, dialog] + { + InputInfo inputInfo = dialog->GetInputInfo(); + m_shaderGraph.AddInput(std::move(inputInfo.name), inputInfo.type, inputInfo.role, inputInfo.roleIndex); + }); + + dialog->open(); +} + +void InputEditor::OnEditInput(int inputIndex) +{ + const auto& input = m_shaderGraph.GetInput(inputIndex); + + InputInfo info; + info.name = input.name; + info.type = input.type; + info.role = input.role; + info.roleIndex = input.roleIndex; + + InputEditDialog* dialog = new InputEditDialog(std::move(info), this); + dialog->setAttribute(Qt::WA_DeleteOnClose, true); + connect(dialog, &QDialog::accepted, [this, dialog, inputIndex] + { + InputInfo inputInfo = dialog->GetInputInfo(); + m_shaderGraph.UpdateInput(inputIndex, std::move(inputInfo.name), inputInfo.type, inputInfo.role, inputInfo.roleIndex); + }); + + dialog->open(); +} + +void InputEditor::OnInputSelectionUpdate(int inputIndex) +{ + if (inputIndex >= 0) + { + m_currentInputIndex = inputIndex; + } + else + m_currentInputIndex.reset(); +} + +void InputEditor::OnInputListUpdate(ShaderGraph* /*graph*/) +{ + RefreshInputs(); +} + +void InputEditor::OnInputUpdate(ShaderGraph* /*graph*/, std::size_t inputIndex) +{ + const auto& inputEntry = m_shaderGraph.GetInput(inputIndex); + m_inputList->item(int(inputIndex))->setText(QString::fromStdString(inputEntry.name)); +} + +void InputEditor::RefreshInputs() +{ + m_inputList->clear(); + m_inputList->setCurrentRow(-1); + + for (const auto& inputEntry : m_shaderGraph.GetInputs()) + m_inputList->addItem(QString::fromStdString(inputEntry.name)); +} diff --git a/src/ShaderNode/Widgets/InputEditor.hpp b/src/ShaderNode/Widgets/InputEditor.hpp new file mode 100644 index 000000000..236f9069f --- /dev/null +++ b/src/ShaderNode/Widgets/InputEditor.hpp @@ -0,0 +1,39 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_INPUTEDITOR_HPP +#define NAZARA_SHADERNODES_INPUTEDITOR_HPP + +#include +#include +#include + +class QLabel; +class QListWidget; +class QVBoxLayout; + +class InputEditor : public QWidget +{ + public: + InputEditor(ShaderGraph& graph); + ~InputEditor() = default; + + private: + void OnAddInput(); + void OnEditInput(int inputIndex); + void OnInputSelectionUpdate(int inputIndex); + void OnInputListUpdate(ShaderGraph* graph); + void OnInputUpdate(ShaderGraph* graph, std::size_t inputIndex); + void RefreshInputs(); + + NazaraSlot(ShaderGraph, OnInputListUpdate, m_onInputListUpdateSlot); + NazaraSlot(ShaderGraph, OnInputUpdate, m_onInputUpdateSlot); + + std::optional m_currentInputIndex; + ShaderGraph& m_shaderGraph; + QListWidget* m_inputList; + QVBoxLayout* m_layout; +}; + +#include + +#endif diff --git a/src/ShaderNode/Widgets/InputEditor.inl b/src/ShaderNode/Widgets/InputEditor.inl new file mode 100644 index 000000000..a480716aa --- /dev/null +++ b/src/ShaderNode/Widgets/InputEditor.inl @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/Widgets/MainWindow.cpp b/src/ShaderNode/Widgets/MainWindow.cpp index d4a661790..150770541 100644 --- a/src/ShaderNode/Widgets/MainWindow.cpp +++ b/src/ShaderNode/Widgets/MainWindow.cpp @@ -1,8 +1,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -17,6 +19,13 @@ m_shaderGraph(graph) QtNodes::FlowView* flowView = new QtNodes::FlowView(scene); setCentralWidget(flowView); + QDockWidget* inputDock = new QDockWidget(tr("&Inputs")); + + InputEditor* inputEditor = new InputEditor(m_shaderGraph); + inputDock->setWidget(inputEditor); + + addDockWidget(Qt::LeftDockWidgetArea, inputDock); + QDockWidget* textureDock = new QDockWidget(tr("&Textures")); TextureEditor* textureEditor = new TextureEditor(m_shaderGraph); diff --git a/src/ShaderNode/Widgets/TextureEditor.cpp b/src/ShaderNode/Widgets/TextureEditor.cpp index 594262c1a..44a68fec9 100644 --- a/src/ShaderNode/Widgets/TextureEditor.cpp +++ b/src/ShaderNode/Widgets/TextureEditor.cpp @@ -9,7 +9,7 @@ TextureEditor::TextureEditor(ShaderGraph& graph) : m_shaderGraph(graph) { - m_textureList = new QListWidget(this); + m_textureList = new QListWidget; connect(m_textureList, &QListWidget::currentRowChanged, this, &TextureEditor::OnTextureSelectionUpdate); m_pixmapLabel = new QLabel; diff --git a/src/ShaderNode/Widgets/TextureEditor.hpp b/src/ShaderNode/Widgets/TextureEditor.hpp index fcdbf3f7c..456b9b1d5 100644 --- a/src/ShaderNode/Widgets/TextureEditor.hpp +++ b/src/ShaderNode/Widgets/TextureEditor.hpp @@ -4,7 +4,7 @@ #define NAZARA_SHADERNODES_TEXTUREEDITOR_HPP #include -#include +#include #include class QLabel; diff --git a/src/ShaderNode/main.cpp b/src/ShaderNode/main.cpp index 648cbbbbc..a9554c8bd 100644 --- a/src/ShaderNode/main.cpp +++ b/src/ShaderNode/main.cpp @@ -8,8 +8,8 @@ int main(int argc, char* argv[]) QApplication app(argc, argv); ShaderGraph shaderGraph; - shaderGraph.AddTexture("Potato", Nz::ShaderAst::ExpressionType::Sampler2D); - shaderGraph.AddTexture("Blackbird", Nz::ShaderAst::ExpressionType::Sampler2D); + shaderGraph.AddInput("UV", InputType::Float2, InputRole::TexCoord, 0); + shaderGraph.AddTexture("Potato", TextureType::Sampler2D); MainWindow mainWindow(shaderGraph); mainWindow.resize(1280, 720); From 93e76a17c7ba2888e303db2fa8401e9abb105a4d Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 23 May 2020 22:04:10 +0200 Subject: [PATCH 199/316] ShaderNode: Add preview / cast / texture sampling --- src/ShaderNode/DataModels/Cast.cpp | 0 src/ShaderNode/DataModels/Cast.hpp | 59 ++++++ src/ShaderNode/DataModels/Cast.inl | 201 ++++++++++++++++++++ src/ShaderNode/DataModels/InputValue.cpp | 18 +- src/ShaderNode/DataModels/SampleTexture.cpp | 65 ++++++- src/ShaderNode/DataModels/SampleTexture.hpp | 5 + src/ShaderNode/DataModels/VecBinOp.cpp | 22 --- src/ShaderNode/DataModels/VecBinOp.hpp | 48 +++-- src/ShaderNode/DataModels/VecBinOp.inl | 86 ++++++++- src/ShaderNode/DataModels/VecData.cpp | 1 + src/ShaderNode/DataModels/VecData.hpp | 67 +++++++ src/ShaderNode/DataModels/VecData.inl | 7 + src/ShaderNode/DataModels/VecValue.hpp | 65 ++----- src/ShaderNode/DataModels/VecValue.inl | 83 ++++---- src/ShaderNode/Previews/PreviewModel.cpp | 3 + src/ShaderNode/Previews/PreviewModel.hpp | 21 ++ src/ShaderNode/Previews/PreviewModel.inl | 1 + src/ShaderNode/Previews/QuadPreview.cpp | 24 +++ src/ShaderNode/Previews/QuadPreview.hpp | 20 ++ src/ShaderNode/Previews/QuadPreview.inl | 1 + src/ShaderNode/ShaderGraph.cpp | 23 +++ src/ShaderNode/ShaderGraph.hpp | 5 +- src/ShaderNode/ShaderGraph.inl | 5 + 23 files changed, 686 insertions(+), 144 deletions(-) create mode 100644 src/ShaderNode/DataModels/Cast.cpp create mode 100644 src/ShaderNode/DataModels/Cast.hpp create mode 100644 src/ShaderNode/DataModels/Cast.inl create mode 100644 src/ShaderNode/DataModels/VecData.cpp create mode 100644 src/ShaderNode/DataModels/VecData.hpp create mode 100644 src/ShaderNode/DataModels/VecData.inl create mode 100644 src/ShaderNode/Previews/PreviewModel.cpp create mode 100644 src/ShaderNode/Previews/PreviewModel.hpp create mode 100644 src/ShaderNode/Previews/PreviewModel.inl create mode 100644 src/ShaderNode/Previews/QuadPreview.cpp create mode 100644 src/ShaderNode/Previews/QuadPreview.hpp create mode 100644 src/ShaderNode/Previews/QuadPreview.inl diff --git a/src/ShaderNode/DataModels/Cast.cpp b/src/ShaderNode/DataModels/Cast.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/src/ShaderNode/DataModels/Cast.hpp b/src/ShaderNode/DataModels/Cast.hpp new file mode 100644 index 000000000..f17cff625 --- /dev/null +++ b/src/ShaderNode/DataModels/Cast.hpp @@ -0,0 +1,59 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_CAST_HPP +#define NAZARA_SHADERNODES_CAST_HPP + +#include +#include +#include +#include +#include +#include +#include + +template +class CastVec : public ShaderNode +{ + public: + CastVec(ShaderGraph& graph); + ~CastVec() = default; + + Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const override; + + QString caption() const override; + QString name() const override; + + QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; + QWidget* embeddedWidget() override; + unsigned int nPorts(QtNodes::PortType portType) const override; + + std::shared_ptr outData(QtNodes::PortIndex port) override; + + void setInData(std::shared_ptr value, int index) override; + + private: + static constexpr std::size_t FromComponents = From::ComponentCount; + static constexpr std::size_t ToComponents = To::ComponentCount; + static constexpr std::size_t ComponentDiff = (ToComponents >= FromComponents) ? ToComponents - FromComponents : 0; + + void ComputePreview(QPixmap& pixmap) const; + void UpdatePreview(); + + QLabel* m_pixmapLabel; + QPixmap m_pixmap; + QWidget* m_widget; + std::array m_spinboxes; + std::shared_ptr m_input; + std::shared_ptr m_output; +}; + +using CastVec2ToVec3 = CastVec; +using CastVec2ToVec4 = CastVec; +using CastVec3ToVec2 = CastVec; +using CastVec3ToVec4 = CastVec; +using CastVec4ToVec2 = CastVec; +using CastVec4ToVec3 = CastVec; + +#include + +#endif diff --git a/src/ShaderNode/DataModels/Cast.inl b/src/ShaderNode/DataModels/Cast.inl new file mode 100644 index 000000000..9e70e9f8b --- /dev/null +++ b/src/ShaderNode/DataModels/Cast.inl @@ -0,0 +1,201 @@ +#include +#include +#include + +template +CastVec::CastVec(ShaderGraph& graph) : +ShaderNode(graph) +{ + constexpr std::array componentName = { 'X', 'Y', 'Z', 'W' }; + static_assert(ComponentDiff <= componentName.size()); + + QFormLayout* layout = new QFormLayout; + + if constexpr (ComponentDiff > 0) + { + for (std::size_t i = 0; i < ComponentDiff; ++i) + { + m_spinboxes[i] = new QDoubleSpinBox; + m_spinboxes[i]->setDecimals(6); + m_spinboxes[i]->setValue(1.0); + m_spinboxes[i]->setStyleSheet("background-color: rgba(255,255,255,255)"); + connect(m_spinboxes[i], qOverload(&QDoubleSpinBox::valueChanged), [this](double) + { + UpdatePreview(); + }); + + layout->addRow(QString::fromUtf8(&componentName[FromComponents + i], 1), m_spinboxes[i]); + } + } + + m_pixmap = QPixmap(64, 64); + m_pixmap.fill(); + + m_pixmapLabel = new QLabel; + m_pixmapLabel->setPixmap(m_pixmap); + + layout->addWidget(m_pixmapLabel); + + m_widget = new QWidget; + m_widget->setStyleSheet("background-color: rgba(0,0,0,0)"); + m_widget->setLayout(layout); + + m_output = std::make_shared(); +} + +template +Nz::ShaderAst::ExpressionPtr CastVec::GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const +{ + assert(count == 1); + + if constexpr (ComponentDiff > 0) + { + std::array constants; + for (std::size_t i = 0; i < ComponentDiff; ++i) + constants[i] = Nz::ShaderBuilder::Constant(float(m_spinboxes[i]->value())); + + return std::apply([&](auto&&... values) + { + return Nz::ShaderBuilder::Cast(expressions[0], values...); //< TODO: Forward + }, constants); + } + else + { + std::array swizzleComponents; + for (std::size_t i = 0; i < ToComponents; ++i) + swizzleComponents[i] = static_cast(static_cast(Nz::ShaderAst::SwizzleComponent::First) + i); + + return std::apply([&](auto... components) + { + std::initializer_list componentList{ components... }; + return Nz::ShaderBuilder::Swizzle(expressions[0], componentList); + }, swizzleComponents); + } +} + +template +QString CastVec::caption() const +{ + static QString caption = From::Type().name + " to " + To::Type().name; + return caption; +} + +template +QString CastVec::name() const +{ + static QString name = From::Type().id + "to" + To::Type().id; + return name; +} + +template +QtNodes::NodeDataType CastVec::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const +{ + assert(portIndex == 0); + + switch (portType) + { + case QtNodes::PortType::In: return From::Type(); + case QtNodes::PortType::Out: return To::Type(); + } + + assert(false); + throw std::runtime_error("Invalid port type"); +} + +template +QWidget* CastVec::embeddedWidget() +{ + return m_widget; +} + +template +unsigned int CastVec::nPorts(QtNodes::PortType portType) const +{ + switch (portType) + { + case QtNodes::PortType::In: return 1; + case QtNodes::PortType::Out: return 1; + } + + return 0; +} + +template +std::shared_ptr CastVec::outData(QtNodes::PortIndex port) +{ + assert(port == 0); + return m_output; +} + +template +void CastVec::setInData(std::shared_ptr value, int index) +{ + assert(index == 0); + if (value) + { + assert(dynamic_cast(value.get()) != nullptr); + m_input = std::static_pointer_cast(value); + } + else + m_input.reset(); + + UpdatePreview(); +} + +template +void CastVec::ComputePreview(QPixmap& pixmap) const +{ + assert(m_input); + + const QImage& input = m_input->preview; + + int inputWidth = input.width(); + int inputHeight = input.height(); + + QImage& output = m_output->preview; + output = QImage(inputWidth, inputHeight, QImage::Format_RGBA8888); + + std::array constants; + for (std::size_t i = 0; i < ComponentDiff; ++i) + constants[i] = static_cast(std::clamp(int(m_spinboxes[i]->value() * 255), 0, 255)); + + std::uint8_t* outputPtr = output.bits(); + const std::uint8_t* inputPtr = input.constBits(); + for (int y = 0; y < inputHeight; ++y) + { + for (int x = 0; x < inputWidth; ++x) + { + constexpr std::size_t CommonComponents = std::min(FromComponents, ToComponents); + constexpr std::size_t VoidComponents = 4 - ComponentDiff - CommonComponents; + + for (std::size_t i = 0; i < CommonComponents; ++i) + *outputPtr++ = inputPtr[i]; + + for (std::size_t i = 0; i < ComponentDiff; ++i) + *outputPtr++ = constants[i]; + + for (std::size_t i = 0; i < VoidComponents; ++i) + *outputPtr++ = (i == VoidComponents - 1) ? 255 : 0; + + inputPtr += 4; + } + } + + pixmap = QPixmap::fromImage(output).scaled(64, 64); +} + +template +void CastVec::UpdatePreview() +{ + if (!m_input) + { + m_pixmap = QPixmap(64, 64); + m_pixmap.fill(QColor::fromRgb(255, 255, 255, 0)); + } + else + ComputePreview(m_pixmap); + + m_pixmapLabel->setPixmap(m_pixmap); + + Q_EMIT dataUpdated(0); +} diff --git a/src/ShaderNode/DataModels/InputValue.cpp b/src/ShaderNode/DataModels/InputValue.cpp index f1cc97d0d..1a1bdfb5a 100644 --- a/src/ShaderNode/DataModels/InputValue.cpp +++ b/src/ShaderNode/DataModels/InputValue.cpp @@ -62,6 +62,12 @@ void InputValue::UpdatePreview() if (m_inputSelection->count() == 0) return; + const ShaderGraph& graph = GetGraph(); + const auto& inputEntry = graph.GetInput(m_currentInputIndex); + const auto& preview = graph.GetPreviewModel(); + + m_previewLabel->setPixmap(QPixmap::fromImage(preview.GetImage(inputEntry.role, inputEntry.roleIndex))); + Q_EMIT dataUpdated(0); } @@ -76,7 +82,7 @@ void InputValue::UpdateInputList() m_inputSelection->setCurrentText(currentInput); } -Nz::ShaderAst::ExpressionPtr InputValue::GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const +Nz::ShaderAst::ExpressionPtr InputValue::GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const { assert(count == 0); @@ -111,7 +117,7 @@ auto InputValue::dataType(QtNodes::PortType portType, QtNodes::PortIndex portInd //case InputType::Bool: return Nz::ShaderAst::ExpressionType::Boolean; //case InputType::Float1: return Nz::ShaderAst::ExpressionType::Float1; case InputType::Float2: return Vec2Data::Type(); - //case InputType::Float3: return Nz::ShaderAst::ExpressionType::Float3; + case InputType::Float3: return Vec3Data::Type(); case InputType::Float4: return Vec4Data::Type(); } @@ -123,10 +129,12 @@ std::shared_ptr InputValue::outData(QtNodes::PortIndex port) { assert(port == 0); - const auto& inputEntry = GetGraph().GetInput(m_currentInputIndex); + const ShaderGraph& graph = GetGraph(); + const auto& inputEntry = graph.GetInput(m_currentInputIndex); + const auto& preview = graph.GetPreviewModel(); - auto vecData = std::make_shared(); - vecData->preview = QImage(); + auto vecData = std::make_shared(); + vecData->preview = preview.GetImage(inputEntry.role, inputEntry.roleIndex); return vecData; } diff --git a/src/ShaderNode/DataModels/SampleTexture.cpp b/src/ShaderNode/DataModels/SampleTexture.cpp index 925094b6b..d7ae63713 100644 --- a/src/ShaderNode/DataModels/SampleTexture.cpp +++ b/src/ShaderNode/DataModels/SampleTexture.cpp @@ -7,6 +7,8 @@ SampleTexture::SampleTexture(ShaderGraph& graph) : ShaderNode(graph), m_currentTextureIndex(0) { + m_output = std::make_shared(); + m_layout = new QVBoxLayout; m_textureSelection = new QComboBox; @@ -85,9 +87,45 @@ void SampleTexture::UpdateTextureList() void SampleTexture::ComputePreview(QPixmap& pixmap) const { + if (!m_uv) + return; + const auto& textureEntry = GetGraph().GetTexture(m_currentTextureIndex); - pixmap = QPixmap::fromImage(textureEntry.preview).scaled(128, 128, Qt::KeepAspectRatio); + int textureWidth = textureEntry.preview.width(); + int textureHeight = textureEntry.preview.height(); + + QImage& output = m_output->preview; + const QImage& uv = m_uv->preview; + + int uvWidth = uv.width(); + int uvHeight = uv.height(); + + output = QImage(uvWidth, uvHeight, QImage::Format_RGBA8888); + + std::uint8_t* outputPtr = output.bits(); + const std::uint8_t* uvPtr = uv.constBits(); + const std::uint8_t* texturePtr = textureEntry.preview.constBits(); + for (int y = 0; y < uvHeight; ++y) + { + for (int x = 0; x < uvWidth; ++x) + { + float u = float(uvPtr[0]) / 255; + float v = float(uvPtr[1]) / 255; + + int texX = std::clamp(int(u * textureWidth), 0, textureWidth - 1); + int texY = std::clamp(int(v * textureHeight), 0, textureHeight - 1); + int texPixel = (texY * textureWidth + texX) * 4; + + *outputPtr++ = texturePtr[texPixel + 0]; + *outputPtr++ = texturePtr[texPixel + 1]; + *outputPtr++ = texturePtr[texPixel + 2]; + *outputPtr++ = texturePtr[texPixel + 3]; + uvPtr += 4; + } + } + + pixmap = QPixmap::fromImage(output).scaled(128, 128, Qt::KeepAspectRatio); } Nz::ShaderAst::ExpressionPtr SampleTexture::GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const @@ -156,7 +194,7 @@ QString SampleTexture::portCaption(QtNodes::PortType portType, QtNodes::PortInde } } -bool SampleTexture::portCaptionVisible(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const +bool SampleTexture::portCaptionVisible(QtNodes::PortType /*portType*/, QtNodes::PortIndex /*portIndex*/) const { return true; } @@ -165,10 +203,21 @@ std::shared_ptr SampleTexture::outData(QtNodes::PortIndex por { assert(port == 0); - const auto& textureEntry = GetGraph().GetTexture(m_currentTextureIndex); - - auto vecData = std::make_shared(); - vecData->preview = textureEntry.preview; - - return vecData; + return m_output; +} + +void SampleTexture::setInData(std::shared_ptr value, int index) +{ + assert(index == 0); + + if (value) + { + assert(dynamic_cast(value.get()) != nullptr); + + m_uv = std::static_pointer_cast(value); + } + else + m_uv.reset(); + + UpdatePreview(); } diff --git a/src/ShaderNode/DataModels/SampleTexture.hpp b/src/ShaderNode/DataModels/SampleTexture.hpp index af11d14ec..3621d0c14 100644 --- a/src/ShaderNode/DataModels/SampleTexture.hpp +++ b/src/ShaderNode/DataModels/SampleTexture.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #include class SampleTexture : public ShaderNode @@ -32,6 +33,8 @@ class SampleTexture : public ShaderNode std::shared_ptr outData(QtNodes::PortIndex port) override; + void setInData(std::shared_ptr value, int index) override; + protected: void ComputePreview(QPixmap& pixmap) const; void UpdatePreview(); @@ -41,6 +44,8 @@ class SampleTexture : public ShaderNode NazaraSlot(ShaderGraph, OnTexturePreviewUpdate, m_onTexturePreviewUpdateSlot); std::size_t m_currentTextureIndex; + std::shared_ptr m_uv; + std::shared_ptr m_output; QComboBox* m_textureSelection; QLabel* m_pixmapLabel; QPixmap m_pixmap; diff --git a/src/ShaderNode/DataModels/VecBinOp.cpp b/src/ShaderNode/DataModels/VecBinOp.cpp index 7349b708f..dd13b5b56 100644 --- a/src/ShaderNode/DataModels/VecBinOp.cpp +++ b/src/ShaderNode/DataModels/VecBinOp.cpp @@ -1,23 +1 @@ #include - -void Vec4Add::ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) -{ - for (std::size_t i = 0; i < pixelCount; ++i) - { - unsigned int lValue = left[i]; - unsigned int rValue = right[i]; - - output[i] = static_cast(std::min(lValue + rValue, 255U)); - } -} - -void Vec4Mul::ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) -{ - for (std::size_t i = 0; i < pixelCount; ++i) - { - unsigned int lValue = left[i]; - unsigned int rValue = right[i]; - - output[i] = static_cast(lValue * rValue / 255); - } -} diff --git a/src/ShaderNode/DataModels/VecBinOp.hpp b/src/ShaderNode/DataModels/VecBinOp.hpp index 97f433048..31ae4732e 100644 --- a/src/ShaderNode/DataModels/VecBinOp.hpp +++ b/src/ShaderNode/DataModels/VecBinOp.hpp @@ -30,33 +30,59 @@ class VecBinOp : public ShaderNode QLabel* m_pixmapLabel; QPixmap m_preview; - std::shared_ptr m_lhs; - std::shared_ptr m_rhs; - std::shared_ptr m_output; + std::shared_ptr m_lhs; + std::shared_ptr m_rhs; + std::shared_ptr m_output; }; -class Vec4Add : public VecBinOp +template +class VecAdd : public VecBinOp { public: - using VecBinOp::VecBinOp; + using VecBinOp::VecBinOp; - QString caption() const override { return "Vec4 addition"; } - QString name() const override { return "Vec4Add"; } + QString caption() const override; + QString name() const override; void ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) override; }; -class Vec4Mul : public VecBinOp +template +class VecMul : public VecBinOp { public: - using VecBinOp::VecBinOp; + using VecBinOp::VecBinOp; - QString caption() const override { return "Vec4 multiplication"; } - QString name() const override { return "Vec4Mul"; } + QString caption() const override; + QString name() const override; void ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) override; }; +template +class VecSub : public VecBinOp +{ + public: + using VecBinOp::VecBinOp; + + QString caption() const override; + QString name() const override; + + void ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) override; +}; + +using Vec2Add = VecAdd; +using Vec3Add = VecAdd; +using Vec4Add = VecAdd; + +using Vec2Mul = VecMul; +using Vec3Mul = VecMul; +using Vec4Mul = VecMul; + +using Vec2Sub = VecSub; +using Vec3Sub = VecSub; +using Vec4Sub = VecSub; + #include #endif diff --git a/src/ShaderNode/DataModels/VecBinOp.inl b/src/ShaderNode/DataModels/VecBinOp.inl index fea7837a7..5d5cfc251 100644 --- a/src/ShaderNode/DataModels/VecBinOp.inl +++ b/src/ShaderNode/DataModels/VecBinOp.inl @@ -96,14 +96,10 @@ void VecBinOp::UpdatePreview() if (rightResized.width() != maxWidth || rightResized.height() != maxHeight) rightResized = rightResized.scaled(maxWidth, maxHeight); - int w = m_output->preview.width(); - int h = m_output->preview.height(); - m_output->preview = QImage(maxWidth, maxHeight, QImage::Format_RGBA8888); ApplyOp(leftResized.constBits(), rightResized.constBits(), m_output->preview.bits(), maxWidth * maxHeight * 4); - m_output->preview = m_output->preview.scaled(w, h); - m_preview = QPixmap::fromImage(m_output->preview, Qt::AutoColor | Qt::NoOpaqueDetection); + m_preview = QPixmap::fromImage(m_output->preview).scaled(64, 64); } else { @@ -113,3 +109,83 @@ void VecBinOp::UpdatePreview() m_pixmapLabel->setPixmap(m_preview); } + +template +QString VecAdd::caption() const +{ + static QString caption = Data::Type().name + " addition"; + return caption; +} + +template +QString VecAdd::name() const +{ + static QString name = Data::Type().name + "add"; + return name; +} + +template +void VecAdd::ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) +{ + for (std::size_t i = 0; i < pixelCount; ++i) + { + unsigned int lValue = left[i]; + unsigned int rValue = right[i]; + + output[i] = static_cast(std::min(lValue + rValue, 255U)); + } +} + +template +QString VecMul::caption() const +{ + static QString caption = Data::Type().name + " multiplication"; + return caption; +} + +template +QString VecMul::name() const +{ + static QString name = Data::Type().name + "mul"; + return name; +} + +template +void VecMul::ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) +{ + for (std::size_t i = 0; i < pixelCount; ++i) + { + unsigned int lValue = left[i]; + unsigned int rValue = right[i]; + + output[i] = static_cast(lValue * rValue / 255); + } +} + +template +QString VecSub::caption() const +{ + static QString caption = Data::Type().name + " subtraction"; + return caption; +} + +template +QString VecSub::name() const +{ + static QString name = Data::Type().name + "sub"; + return name; +} + +template +void VecSub::ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) +{ + for (std::size_t i = 0; i < pixelCount; ++i) + { + unsigned int lValue = left[i]; + unsigned int rValue = right[i]; + + unsigned int sub = (lValue >= rValue) ? lValue - rValue : 0u; + + output[i] = static_cast(sub); + } +} diff --git a/src/ShaderNode/DataModels/VecData.cpp b/src/ShaderNode/DataModels/VecData.cpp new file mode 100644 index 000000000..2cf74c1e6 --- /dev/null +++ b/src/ShaderNode/DataModels/VecData.cpp @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/DataModels/VecData.hpp b/src/ShaderNode/DataModels/VecData.hpp new file mode 100644 index 000000000..ad44d68b1 --- /dev/null +++ b/src/ShaderNode/DataModels/VecData.hpp @@ -0,0 +1,67 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_VECDATA_HPP +#define NAZARA_SHADERNODES_VECDATA_HPP + +#include +#include +#include + +struct VecData : public QtNodes::NodeData +{ + inline VecData(); + + QImage preview; +}; + +struct Vec2Data : public VecData +{ + static constexpr std::size_t ComponentCount = 2; + static constexpr Nz::ShaderAst::ExpressionType ExpressionType = Nz::ShaderAst::ExpressionType::Float2; + + QtNodes::NodeDataType type() const override + { + return Type(); + } + + static QtNodes::NodeDataType Type() + { + return { "vec2", "Vec2" }; + } +}; + +struct Vec3Data : public VecData +{ + static constexpr std::size_t ComponentCount = 3; + static constexpr Nz::ShaderAst::ExpressionType ExpressionType = Nz::ShaderAst::ExpressionType::Float3; + + QtNodes::NodeDataType type() const override + { + return Type(); + } + + static QtNodes::NodeDataType Type() + { + return { "vec3", "Vec3" }; + } +}; + +struct Vec4Data : public VecData +{ + static constexpr std::size_t ComponentCount = 4; + static constexpr Nz::ShaderAst::ExpressionType ExpressionType = Nz::ShaderAst::ExpressionType::Float4; + + QtNodes::NodeDataType type() const override + { + return Type(); + } + + static QtNodes::NodeDataType Type() + { + return { "vec4", "Vec4" }; + } +}; + +#include + +#endif diff --git a/src/ShaderNode/DataModels/VecData.inl b/src/ShaderNode/DataModels/VecData.inl new file mode 100644 index 000000000..92765c835 --- /dev/null +++ b/src/ShaderNode/DataModels/VecData.inl @@ -0,0 +1,7 @@ +#include + +inline VecData::VecData() : +preview(64, 64, QImage::Format_RGBA8888) +{ + preview.fill(QColor::fromRgb(255, 255, 255, 0)); +} diff --git a/src/ShaderNode/DataModels/VecValue.hpp b/src/ShaderNode/DataModels/VecValue.hpp index ba7a61f08..77656f373 100644 --- a/src/ShaderNode/DataModels/VecValue.hpp +++ b/src/ShaderNode/DataModels/VecValue.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #include template @@ -33,13 +34,16 @@ struct VecTypeHelper<4> template using VecType = typename VecTypeHelper::template Type; -template +template class VecValue : public ShaderNode { public: VecValue(ShaderGraph& graph); ~VecValue() = default; + QString caption() const override; + QString name() const override; + QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; QWidget* embeddedWidget() override; @@ -50,67 +54,22 @@ class VecValue : public ShaderNode Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const override; protected: + static constexpr std::size_t ComponentCount = Data::ComponentCount; + QColor ToColor() const; - VecType ToVector() const; + VecType ToVector() const; void UpdatePreview(); QLabel* m_pixmapLabel; QPixmap m_pixmap; QWidget* m_widget; QFormLayout* m_layout; - std::array m_spinboxes; + std::array m_spinboxes; }; -struct VecData : public QtNodes::NodeData -{ - inline VecData(); - - QImage preview; -}; - -struct Vec2Data : public VecData -{ - QtNodes::NodeDataType type() const override - { - return Type(); - } - - static QtNodes::NodeDataType Type() - { - return { "vec2", "Vec2" }; - } -}; - -struct Vec4Data : public VecData -{ - QtNodes::NodeDataType type() const override - { - return Type(); - } - - static QtNodes::NodeDataType Type() - { - return { "vec4", "Vec4" }; - } -}; - -class Vec2Value : public VecValue<2, Vec2Data> -{ - public: - using VecValue::VecValue; - - QString caption() const override { return "Vec2 value"; } - QString name() const override { return "Vec2Value"; } -}; - -class Vec4Value : public VecValue<4, Vec4Data> -{ - public: - using VecValue::VecValue; - - QString caption() const override { return "Vec4 value"; } - QString name() const override { return "Vec4Value"; } -}; +using Vec2Value = VecValue; +using Vec3Value = VecValue; +using Vec4Value = VecValue; #include diff --git a/src/ShaderNode/DataModels/VecValue.inl b/src/ShaderNode/DataModels/VecValue.inl index 8f8a53fc7..3ab11cd37 100644 --- a/src/ShaderNode/DataModels/VecValue.inl +++ b/src/ShaderNode/DataModels/VecValue.inl @@ -2,16 +2,17 @@ #include #include #include +#include -template -VecValue::VecValue(ShaderGraph& graph) : +template +VecValue::VecValue(ShaderGraph& graph) : ShaderNode(graph) { constexpr std::array componentName = { 'X', 'Y', 'Z', 'W' }; - static_assert(N <= componentName.size()); + static_assert(ComponentCount <= componentName.size()); m_layout = new QFormLayout; - for (std::size_t i = 0; i < N; ++i) + for (std::size_t i = 0; i < ComponentCount; ++i) { m_spinboxes[i] = new QDoubleSpinBox; m_spinboxes[i]->setDecimals(6); @@ -42,8 +43,22 @@ ShaderNode(graph) UpdatePreview(); } -template -QtNodes::NodeDataType VecValue::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const +template +QString VecValue::caption() const +{ + static QString caption = Data::Type().name + " constant"; + return caption; +} + +template +QString VecValue::name() const +{ + static QString name = Data::Type().id + "Value"; + return name; +} + +template +QtNodes::NodeDataType VecValue::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const { assert(portType == QtNodes::PortType::Out); assert(portIndex == 0); @@ -51,14 +66,14 @@ QtNodes::NodeDataType VecValue::dataType(QtNodes::PortType portType, Qt return Data::Type(); } -template -QWidget* VecValue::embeddedWidget() +template +QWidget* VecValue::embeddedWidget() { return m_widget; } -template -unsigned int VecValue::nPorts(QtNodes::PortType portType) const +template +unsigned int VecValue::nPorts(QtNodes::PortType portType) const { switch (portType) { @@ -69,8 +84,8 @@ unsigned int VecValue::nPorts(QtNodes::PortType portType) const return 0; } -template -std::shared_ptr VecValue::outData(QtNodes::PortIndex port) +template +std::shared_ptr VecValue::outData(QtNodes::PortIndex port) { assert(port == 0); @@ -81,52 +96,42 @@ std::shared_ptr VecValue::outData(QtNodes::PortIndex return out; } -template -Nz::ShaderAst::ExpressionPtr VecValue::GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const +template +Nz::ShaderAst::ExpressionPtr VecValue::GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const { assert(count == 0); return Nz::ShaderBuilder::Constant(ToVector()); } -template -QColor VecValue::ToColor() const +template +QColor VecValue::ToColor() const { std::array values = { 0.f, 0.f, 0.f, 1.f }; - for (std::size_t i = 0; i < N; ++i) - values[i] = std::clamp(m_spinboxes[i]->value(), 0.0, 1.0); + for (std::size_t i = 0; i < ComponentCount; ++i) + values[i] = std::clamp(float(m_spinboxes[i]->value()), 0.f, 1.f); return QColor::fromRgbF(values[0], values[1], values[2], values[3]); } -template -VecType VecValue::ToVector() const +template +auto VecValue::ToVector() const -> VecType { - std::array values = { 0.f, 0.f, 0.f, 1.f }; + std::array values; - for (std::size_t i = 0; i < N; ++i) - values[i] = std::clamp(m_spinboxes[i]->value(), 0.0, 1.0); + for (std::size_t i = 0; i < ComponentCount; ++i) + values[i] = std::clamp(float(m_spinboxes[i]->value()), 0.f, 1.f); - if constexpr (N == 2) - return Nz::Vector2f(values[0], values[1]); - else if constexpr (N == 3) - return Nz::Vector3f(values[0], values[1], values[2]); - else if constexpr (N == 4) - return Nz::Vector4f(values[0], values[1], values[2], values[3]); - else - static_assert(Nz::AlwaysFalse>(), "Unhandled vector size"); + return std::apply([](auto... values) + { + return VecType(values...); + }, values); } -template -void VecValue::UpdatePreview() +template +void VecValue::UpdatePreview() { m_pixmap.fill(ToColor()); m_pixmapLabel->setPixmap(m_pixmap); } - -inline VecData::VecData() : -preview(64, 64, QImage::Format_RGBA8888) -{ - preview.fill(QColor::fromRgb(255, 255, 255, 0)); -} diff --git a/src/ShaderNode/Previews/PreviewModel.cpp b/src/ShaderNode/Previews/PreviewModel.cpp new file mode 100644 index 000000000..845c19fe2 --- /dev/null +++ b/src/ShaderNode/Previews/PreviewModel.cpp @@ -0,0 +1,3 @@ +#include + +PreviewModel::~PreviewModel() = default; diff --git a/src/ShaderNode/Previews/PreviewModel.hpp b/src/ShaderNode/Previews/PreviewModel.hpp new file mode 100644 index 000000000..138374ea4 --- /dev/null +++ b/src/ShaderNode/Previews/PreviewModel.hpp @@ -0,0 +1,21 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_PREVIEWMODEL_HPP +#define NAZARA_SHADERNODES_PREVIEWMODEL_HPP + +#include + +class QImage; + +class PreviewModel +{ + public: + PreviewModel() = default; + virtual ~PreviewModel(); + + virtual QImage GetImage(InputRole role, std::size_t roleIndex) const = 0; +}; + +#include + +#endif diff --git a/src/ShaderNode/Previews/PreviewModel.inl b/src/ShaderNode/Previews/PreviewModel.inl new file mode 100644 index 000000000..d5f2e699b --- /dev/null +++ b/src/ShaderNode/Previews/PreviewModel.inl @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/Previews/QuadPreview.cpp b/src/ShaderNode/Previews/QuadPreview.cpp new file mode 100644 index 000000000..a518287fd --- /dev/null +++ b/src/ShaderNode/Previews/QuadPreview.cpp @@ -0,0 +1,24 @@ +#include +#include + +QImage QuadPreview::GetImage(InputRole role, std::size_t roleIndex) const +{ + assert(role == InputRole::TexCoord); + assert(roleIndex == 0); + + QImage uv(128, 128, QImage::Format_RGBA8888); + + std::uint8_t* content = uv.bits(); + for (std::size_t y = 0; y < 128; ++y) + { + for (std::size_t x = 0; x < 128; ++x) + { + *content++ = (x * 255) / 128; + *content++ = (y * 255) / 128; + *content++ = 0; + *content++ = 255; + } + } + + return uv; +} diff --git a/src/ShaderNode/Previews/QuadPreview.hpp b/src/ShaderNode/Previews/QuadPreview.hpp new file mode 100644 index 000000000..f193e99d0 --- /dev/null +++ b/src/ShaderNode/Previews/QuadPreview.hpp @@ -0,0 +1,20 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_QUADPREVIEW_HPP +#define NAZARA_SHADERNODES_QUADPREVIEW_HPP + +#include +#include + +class QuadPreview : public PreviewModel +{ + public: + QuadPreview() = default; + ~QuadPreview() = default; + + QImage GetImage(InputRole role, std::size_t roleIndex) const override; +}; + +#include + +#endif diff --git a/src/ShaderNode/Previews/QuadPreview.inl b/src/ShaderNode/Previews/QuadPreview.inl new file mode 100644 index 000000000..01178d2d2 --- /dev/null +++ b/src/ShaderNode/Previews/QuadPreview.inl @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp index 0b95e137f..be77909de 100644 --- a/src/ShaderNode/ShaderGraph.cpp +++ b/src/ShaderNode/ShaderGraph.cpp @@ -1,11 +1,13 @@ #include #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -34,6 +36,13 @@ m_flowScene(BuildRegistry()) node2.nodeGraphicsObject().setPos(500, 300); m_flowScene.createConnection(node2, 0, node1, 0); + + m_previewModel = std::make_unique(); +} + +ShaderGraph::~ShaderGraph() +{ + m_flowScene.clearScene(); } std::size_t ShaderGraph::AddInput(std::string name, InputType type, InputRole role, std::size_t roleIndex) @@ -125,12 +134,26 @@ void ShaderGraph::UpdateTexturePreview(std::size_t textureIndex, QImage preview) std::shared_ptr ShaderGraph::BuildRegistry() { auto registry = std::make_shared(); + RegisterShaderNode(*this, registry, "Casts"); + RegisterShaderNode(*this, registry, "Casts"); + RegisterShaderNode(*this, registry, "Casts"); + RegisterShaderNode(*this, registry, "Casts"); + RegisterShaderNode(*this, registry, "Casts"); + RegisterShaderNode(*this, registry, "Casts"); RegisterShaderNode(*this, registry, "Outputs"); RegisterShaderNode(*this, registry, "Inputs"); RegisterShaderNode(*this, registry, "Texture"); + RegisterShaderNode(*this, registry, "Vector operations"); + RegisterShaderNode(*this, registry, "Vector operations"); + RegisterShaderNode(*this, registry, "Vector operations"); + RegisterShaderNode(*this, registry, "Vector operations"); + RegisterShaderNode(*this, registry, "Vector operations"); + RegisterShaderNode(*this, registry, "Vector operations"); RegisterShaderNode(*this, registry, "Vector operations"); RegisterShaderNode(*this, registry, "Vector operations"); + RegisterShaderNode(*this, registry, "Vector operations"); RegisterShaderNode(*this, registry, "Constants"); + RegisterShaderNode(*this, registry, "Constants"); RegisterShaderNode(*this, registry, "Constants"); return registry; diff --git a/src/ShaderNode/ShaderGraph.hpp b/src/ShaderNode/ShaderGraph.hpp index 132c9c25b..dda8dba20 100644 --- a/src/ShaderNode/ShaderGraph.hpp +++ b/src/ShaderNode/ShaderGraph.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -17,13 +18,14 @@ class ShaderGraph struct TextureEntry; ShaderGraph(); - ~ShaderGraph() = default; + ~ShaderGraph(); std::size_t AddInput(std::string name, InputType type, InputRole role, std::size_t roleIndex); std::size_t AddTexture(std::string name, TextureType type); inline const InputEntry& GetInput(std::size_t inputIndex) const; inline const std::vector& GetInputs() const; + inline const PreviewModel& GetPreviewModel() const; inline QtNodes::FlowScene& GetScene(); inline const TextureEntry& GetTexture(std::size_t textureIndex) const; inline const std::vector& GetTextures() const; @@ -59,6 +61,7 @@ class ShaderGraph QtNodes::FlowScene m_flowScene; std::vector m_inputs; std::vector m_textures; + std::unique_ptr m_previewModel; }; #include diff --git a/src/ShaderNode/ShaderGraph.inl b/src/ShaderNode/ShaderGraph.inl index bb39d44f3..fb0a9e556 100644 --- a/src/ShaderNode/ShaderGraph.inl +++ b/src/ShaderNode/ShaderGraph.inl @@ -11,6 +11,11 @@ inline auto ShaderGraph::GetInputs() const -> const std::vector& return m_inputs; } +inline const PreviewModel& ShaderGraph::GetPreviewModel() const +{ + return *m_previewModel; +} + inline QtNodes::FlowScene& ShaderGraph::GetScene() { return m_flowScene; From fdeff2e9d08a3b3c6eb1a04703e9879e88311182 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 23 May 2020 22:05:37 +0200 Subject: [PATCH 200/316] ShaderAst: Fix SwizzleOp::GetExpressionType --- src/Nazara/Renderer/ShaderAst.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Renderer/ShaderAst.cpp b/src/Nazara/Renderer/ShaderAst.cpp index d45c8b739..bb64f4475 100644 --- a/src/Nazara/Renderer/ShaderAst.cpp +++ b/src/Nazara/Renderer/ShaderAst.cpp @@ -180,7 +180,7 @@ namespace Nz::ShaderAst ExpressionType ShaderAst::SwizzleOp::GetExpressionType() const { - return GetComponentType(expression->GetExpressionType()); + return static_cast(UnderlyingCast(GetComponentType(expression->GetExpressionType())) + componentCount - 1); } void SwizzleOp::Register(ShaderWriter& visitor) From 8fa456bdf5ba3a87ec9fef9c6cd0344b8a581828 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 23 May 2020 22:07:22 +0200 Subject: [PATCH 201/316] Renderer: Remake backend selection --- .../Nazara/OpenGLRenderer/OpenGLRenderer.hpp | 2 - include/Nazara/Renderer/RendererImpl.hpp | 2 - .../Nazara/VulkanRenderer/VulkanRenderer.hpp | 2 - src/Nazara/OpenGLRenderer/OpenGLRenderer.cpp | 8 --- src/Nazara/Renderer/Renderer.cpp | 55 ++++++++++++------- src/Nazara/VulkanRenderer/VulkanRenderer.cpp | 8 --- 6 files changed, 34 insertions(+), 43 deletions(-) diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderer.hpp b/include/Nazara/OpenGLRenderer/OpenGLRenderer.hpp index c9cb1ac5d..0fefae4de 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLRenderer.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderer.hpp @@ -28,8 +28,6 @@ namespace Nz std::shared_ptr InstanciateRenderDevice(std::size_t deviceIndex) override; - bool IsBetterThan(const RendererImpl* other) const override; - RenderAPI QueryAPI() const override; std::string QueryAPIString() const override; UInt32 QueryAPIVersion() const override; diff --git a/include/Nazara/Renderer/RendererImpl.hpp b/include/Nazara/Renderer/RendererImpl.hpp index 67eeafe64..99aefe682 100644 --- a/include/Nazara/Renderer/RendererImpl.hpp +++ b/include/Nazara/Renderer/RendererImpl.hpp @@ -38,8 +38,6 @@ namespace Nz virtual std::shared_ptr InstanciateRenderDevice(std::size_t deviceIndex) = 0; - virtual bool IsBetterThan(const RendererImpl* other) const = 0; - virtual RenderAPI QueryAPI() const = 0; virtual std::string QueryAPIString() const = 0; virtual UInt32 QueryAPIVersion() const = 0; diff --git a/include/Nazara/VulkanRenderer/VulkanRenderer.hpp b/include/Nazara/VulkanRenderer/VulkanRenderer.hpp index e228170a4..8f6d66160 100644 --- a/include/Nazara/VulkanRenderer/VulkanRenderer.hpp +++ b/include/Nazara/VulkanRenderer/VulkanRenderer.hpp @@ -30,8 +30,6 @@ namespace Nz std::shared_ptr InstanciateRenderDevice(std::size_t deviceIndex) override; - bool IsBetterThan(const RendererImpl* other) const override; - RenderAPI QueryAPI() const override; std::string QueryAPIString() const override; UInt32 QueryAPIVersion() const override; diff --git a/src/Nazara/OpenGLRenderer/OpenGLRenderer.cpp b/src/Nazara/OpenGLRenderer/OpenGLRenderer.cpp index 535d2f612..3d6b6a109 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLRenderer.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLRenderer.cpp @@ -42,14 +42,6 @@ namespace Nz return m_device; } - bool OpenGLRenderer::IsBetterThan(const RendererImpl* other) const - { - if (other->QueryAPI() == RenderAPI::OpenGL && QueryAPIVersion() > other->QueryAPIVersion()) - return true; - - return false; //< OpenGL is mostly a fallback to other renderers - } - bool OpenGLRenderer::Prepare(const ParameterList& parameters) { if (!m_opengl32Lib.Load("opengl32" NAZARA_DYNLIB_EXTENSION)) diff --git a/src/Nazara/Renderer/Renderer.cpp b/src/Nazara/Renderer/Renderer.cpp index 5de4b2835..477a340f3 100644 --- a/src/Nazara/Renderer/Renderer.cpp +++ b/src/Nazara/Renderer/Renderer.cpp @@ -16,9 +16,9 @@ #include #ifdef NAZARA_DEBUG - #define NazaraRendererPattern "Nazara?*Renderer-d" NAZARA_DYNLIB_EXTENSION + #define NazaraRendererDebugSuffix "-d" #else - #define NazaraRendererPattern "Nazara?*Renderer" NAZARA_DYNLIB_EXTENSION + #define NazaraRendererDebugSuffix "" #endif namespace Nz @@ -48,26 +48,45 @@ namespace Nz CallOnExit onExit(Renderer::Uninitialize); + struct RendererImplementations + { + std::filesystem::path fileName; + int score; + }; + std::vector implementations; + + auto RegisterImpl = [&](std::filesystem::path fileName, auto ComputeScore) + { + fileName.replace_extension(NAZARA_DYNLIB_EXTENSION); + + int score = ComputeScore(); + if (score >= 0) + { + auto& impl = implementations.emplace_back(); + impl.fileName = std::move(fileName); + impl.score = score; + } + }; + + RegisterImpl("NazaraOpenGLRenderer" NazaraRendererDebugSuffix, [] { return 50; }); + RegisterImpl("NazaraVulkanRenderer" NazaraRendererDebugSuffix, [] { return 100; }); + + std::sort(implementations.begin(), implementations.end(), [](const auto& lhs, const auto& rhs) { return lhs.score > rhs.score; }); + NazaraDebug("Searching for renderer implementation"); DynLib chosenLib; std::unique_ptr chosenImpl; - for (auto&& entry : std::filesystem::directory_iterator(".")) + for (auto&& rendererImpl : implementations) { - if (!entry.is_regular_file()) + if (!std::filesystem::exists(rendererImpl.fileName)) continue; - const std::filesystem::path& entryPath = entry.path(); - std::filesystem::path fileName = entryPath.filename(); - std::string fileNameStr = fileName.generic_u8string(); - if (!MatchPattern(fileNameStr, NazaraRendererPattern)) - continue; - - NazaraDebug("Trying to load " + fileNameStr); + std::string fileNameStr = rendererImpl.fileName.generic_u8string(); DynLib implLib; - if (!implLib.Load(entryPath)) + if (!implLib.Load(rendererImpl.fileName)) { NazaraWarning("Failed to load " + fileNameStr + ": " + implLib.GetLastError()); continue; @@ -87,16 +106,10 @@ namespace Nz continue; } - NazaraDebug("Loaded " + impl->QueryAPIString()); + NazaraDebug("Loaded " + fileNameStr); - if (!chosenImpl || impl->IsBetterThan(chosenImpl.get())) - { - if (chosenImpl) - NazaraDebug("Choose " + impl->QueryAPIString() + " over " + chosenImpl->QueryAPIString()); - - chosenImpl = std::move(impl); //< Move (and delete previous) implementation before unloading library - chosenLib = std::move(implLib); - } + chosenImpl = std::move(impl); //< Move (and delete previous) implementation before unloading library + chosenLib = std::move(implLib); } if (!chosenImpl) diff --git a/src/Nazara/VulkanRenderer/VulkanRenderer.cpp b/src/Nazara/VulkanRenderer/VulkanRenderer.cpp index dfc11eeb5..9eed59b0c 100644 --- a/src/Nazara/VulkanRenderer/VulkanRenderer.cpp +++ b/src/Nazara/VulkanRenderer/VulkanRenderer.cpp @@ -36,14 +36,6 @@ namespace Nz return Vulkan::SelectDevice(m_physDevices[deviceIndex]); } - bool VulkanRenderer::IsBetterThan(const RendererImpl* other) const - { - if (other->QueryAPI() == RenderAPI::Vulkan && QueryAPIVersion() < other->QueryAPIVersion()) - return false; - - return true; //< Vulkan FTW - } - bool VulkanRenderer::Prepare(const ParameterList& parameters) { return Vulkan::Initialize(APIVersion, parameters); From 1165093b4e627bc6a9426afba6c632c63039238e Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 23 May 2020 22:08:12 +0200 Subject: [PATCH 202/316] Replace some insert by emplace --- src/Nazara/Renderer/GlslWriter.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Nazara/Renderer/GlslWriter.cpp b/src/Nazara/Renderer/GlslWriter.cpp index badf3648f..7cb734cc5 100644 --- a/src/Nazara/Renderer/GlslWriter.cpp +++ b/src/Nazara/Renderer/GlslWriter.cpp @@ -69,11 +69,11 @@ namespace Nz break; case ShaderAst::VariableType::Input: - m_currentState->inputs.insert(std::make_pair(type, name)); + m_currentState->inputs.emplace(type, name); break; case ShaderAst::VariableType::Output: - m_currentState->outputs.insert(std::make_pair(type, name)); + m_currentState->outputs.emplace(type, name); break; case ShaderAst::VariableType::Parameter: @@ -105,13 +105,13 @@ namespace Nz } case ShaderAst::VariableType::Uniform: - m_currentState->uniforms.insert(std::make_pair(type, name)); + m_currentState->uniforms.emplace(type, name); break; case ShaderAst::VariableType::Variable: { if (m_currentFunction) - m_currentFunction->variables.insert(std::make_pair(type, name)); + m_currentFunction->variables.emplace(type, name); break; } From ca2425f31076fe9bb7ef6443de8b533dbdca7163 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 24 May 2020 16:01:26 +0200 Subject: [PATCH 203/316] Sdk/Physics2D: Fix copy of PhysicsComponent2D --- SDK/include/NDK/Components/PhysicsComponent2D.inl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SDK/include/NDK/Components/PhysicsComponent2D.inl b/SDK/include/NDK/Components/PhysicsComponent2D.inl index 6e0b0b10f..53e01480e 100644 --- a/SDK/include/NDK/Components/PhysicsComponent2D.inl +++ b/SDK/include/NDK/Components/PhysicsComponent2D.inl @@ -20,7 +20,8 @@ namespace Ndk * * \param physics PhysicsComponent2D to copy */ - inline PhysicsComponent2D::PhysicsComponent2D(const PhysicsComponent2D& physics) + inline PhysicsComponent2D::PhysicsComponent2D(const PhysicsComponent2D& physics) : + m_nodeSynchronizationEnabled(physics.m_nodeSynchronizationEnabled) { CopyPhysicsState(*physics.GetRigidBody()); } From 460222e71e5b767bdee5ffe7941ab1b089645187 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 25 May 2020 14:40:46 +0200 Subject: [PATCH 204/316] ShaderNode: Make #include explicit --- build/scripts/tools/shadernodes.lua | 2 +- src/ShaderNode/DataModels/Cast.hpp | 8 ++++---- src/ShaderNode/DataModels/Cast.inl | 2 +- src/ShaderNode/DataModels/FragmentOutput.cpp | 4 ++-- src/ShaderNode/DataModels/FragmentOutput.hpp | 4 ++-- src/ShaderNode/DataModels/FragmentOutput.inl | 2 +- src/ShaderNode/DataModels/InputValue.cpp | 6 +++--- src/ShaderNode/DataModels/InputValue.hpp | 6 +++--- src/ShaderNode/DataModels/InputValue.inl | 2 +- src/ShaderNode/DataModels/SampleTexture.cpp | 6 +++--- src/ShaderNode/DataModels/SampleTexture.hpp | 8 ++++---- src/ShaderNode/DataModels/SampleTexture.inl | 2 +- src/ShaderNode/DataModels/ShaderNode.cpp | 2 +- src/ShaderNode/DataModels/ShaderNode.hpp | 2 +- src/ShaderNode/DataModels/ShaderNode.inl | 2 +- src/ShaderNode/DataModels/VecBinOp.cpp | 2 +- src/ShaderNode/DataModels/VecBinOp.hpp | 6 +++--- src/ShaderNode/DataModels/VecBinOp.inl | 2 +- src/ShaderNode/DataModels/VecData.cpp | 2 +- src/ShaderNode/DataModels/VecData.hpp | 2 +- src/ShaderNode/DataModels/VecData.inl | 2 +- src/ShaderNode/DataModels/VecValue.cpp | 2 +- src/ShaderNode/DataModels/VecValue.hpp | 6 +++--- src/ShaderNode/DataModels/VecValue.inl | 2 +- src/ShaderNode/Enums.cpp | 2 +- src/ShaderNode/Enums.hpp | 2 +- src/ShaderNode/Enums.inl | 2 +- src/ShaderNode/Previews/PreviewModel.cpp | 2 +- src/ShaderNode/Previews/PreviewModel.hpp | 4 ++-- src/ShaderNode/Previews/PreviewModel.inl | 2 +- src/ShaderNode/Previews/QuadPreview.cpp | 2 +- src/ShaderNode/Previews/QuadPreview.hpp | 4 ++-- src/ShaderNode/Previews/QuadPreview.inl | 2 +- src/ShaderNode/ShaderGraph.cpp | 18 +++++++++--------- src/ShaderNode/ShaderGraph.hpp | 6 +++--- src/ShaderNode/ShaderGraph.inl | 2 +- src/ShaderNode/Widgets/InputEditDialog.cpp | 2 +- src/ShaderNode/Widgets/InputEditDialog.hpp | 4 ++-- src/ShaderNode/Widgets/InputEditDialog.inl | 2 +- src/ShaderNode/Widgets/InputEditor.cpp | 6 +++--- src/ShaderNode/Widgets/InputEditor.hpp | 4 ++-- src/ShaderNode/Widgets/InputEditor.inl | 2 +- src/ShaderNode/Widgets/MainWindow.cpp | 8 ++++---- src/ShaderNode/Widgets/MainWindow.hpp | 4 ++-- src/ShaderNode/Widgets/MainWindow.inl | 2 +- src/ShaderNode/Widgets/TextureEditor.cpp | 4 ++-- src/ShaderNode/Widgets/TextureEditor.hpp | 4 ++-- src/ShaderNode/Widgets/TextureEditor.inl | 2 +- src/ShaderNode/main.cpp | 4 ++-- 49 files changed, 90 insertions(+), 90 deletions(-) diff --git a/build/scripts/tools/shadernodes.lua b/build/scripts/tools/shadernodes.lua index 33f9628e9..415b71c75 100644 --- a/build/scripts/tools/shadernodes.lua +++ b/build/scripts/tools/shadernodes.lua @@ -12,7 +12,7 @@ TOOL.Defines = { TOOL.Includes = { "../include", "../extlibs/include", - "../src/ShaderNode", + "../src", [[E:\Qt\5.14.1\msvc2017_64\include]], [[E:\Qt\5.14.1\msvc2017_64\include\QtCore]], [[E:\Qt\5.14.1\msvc2017_64\include\QtGui]], diff --git a/src/ShaderNode/DataModels/Cast.hpp b/src/ShaderNode/DataModels/Cast.hpp index f17cff625..a6709bd2d 100644 --- a/src/ShaderNode/DataModels/Cast.hpp +++ b/src/ShaderNode/DataModels/Cast.hpp @@ -6,9 +6,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include template @@ -54,6 +54,6 @@ using CastVec3ToVec4 = CastVec; using CastVec4ToVec2 = CastVec; using CastVec4ToVec3 = CastVec; -#include +#include #endif diff --git a/src/ShaderNode/DataModels/Cast.inl b/src/ShaderNode/DataModels/Cast.inl index 9e70e9f8b..0133d6cc7 100644 --- a/src/ShaderNode/DataModels/Cast.inl +++ b/src/ShaderNode/DataModels/Cast.inl @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/src/ShaderNode/DataModels/FragmentOutput.cpp b/src/ShaderNode/DataModels/FragmentOutput.cpp index 15244e0d8..86731a0f4 100644 --- a/src/ShaderNode/DataModels/FragmentOutput.cpp +++ b/src/ShaderNode/DataModels/FragmentOutput.cpp @@ -1,6 +1,6 @@ -#include +#include #include -#include +#include Nz::ShaderAst::ExpressionPtr FragmentOutput::GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const { diff --git a/src/ShaderNode/DataModels/FragmentOutput.hpp b/src/ShaderNode/DataModels/FragmentOutput.hpp index a682d40a4..ab89ae419 100644 --- a/src/ShaderNode/DataModels/FragmentOutput.hpp +++ b/src/ShaderNode/DataModels/FragmentOutput.hpp @@ -3,7 +3,7 @@ #ifndef NAZARA_SHADERNODES_FRAGMENTOUTPUT_HPP #define NAZARA_SHADERNODES_FRAGMENTOUTPUT_HPP -#include +#include #include #include @@ -28,6 +28,6 @@ class FragmentOutput : public ShaderNode }; -#include +#include #endif diff --git a/src/ShaderNode/DataModels/FragmentOutput.inl b/src/ShaderNode/DataModels/FragmentOutput.inl index 539b8091f..c809a587d 100644 --- a/src/ShaderNode/DataModels/FragmentOutput.inl +++ b/src/ShaderNode/DataModels/FragmentOutput.inl @@ -1,4 +1,4 @@ -#include +#include inline FragmentOutput::FragmentOutput(ShaderGraph& graph) : ShaderNode(graph) diff --git a/src/ShaderNode/DataModels/InputValue.cpp b/src/ShaderNode/DataModels/InputValue.cpp index 1a1bdfb5a..f2ae0eaa8 100644 --- a/src/ShaderNode/DataModels/InputValue.cpp +++ b/src/ShaderNode/DataModels/InputValue.cpp @@ -1,6 +1,6 @@ -#include -#include -#include +#include +#include +#include #include InputValue::InputValue(ShaderGraph& graph) : diff --git a/src/ShaderNode/DataModels/InputValue.hpp b/src/ShaderNode/DataModels/InputValue.hpp index 63e896adf..273155cc4 100644 --- a/src/ShaderNode/DataModels/InputValue.hpp +++ b/src/ShaderNode/DataModels/InputValue.hpp @@ -6,8 +6,8 @@ #include #include #include -#include -#include +#include +#include #include class InputValue : public ShaderNode @@ -42,6 +42,6 @@ class InputValue : public ShaderNode QVBoxLayout* m_layout; }; -#include +#include #endif diff --git a/src/ShaderNode/DataModels/InputValue.inl b/src/ShaderNode/DataModels/InputValue.inl index ff350c7c4..344e3db41 100644 --- a/src/ShaderNode/DataModels/InputValue.inl +++ b/src/ShaderNode/DataModels/InputValue.inl @@ -1,2 +1,2 @@ -#include +#include #include diff --git a/src/ShaderNode/DataModels/SampleTexture.cpp b/src/ShaderNode/DataModels/SampleTexture.cpp index d7ae63713..81982c83a 100644 --- a/src/ShaderNode/DataModels/SampleTexture.cpp +++ b/src/ShaderNode/DataModels/SampleTexture.cpp @@ -1,6 +1,6 @@ -#include -#include -#include +#include +#include +#include #include SampleTexture::SampleTexture(ShaderGraph& graph) : diff --git a/src/ShaderNode/DataModels/SampleTexture.hpp b/src/ShaderNode/DataModels/SampleTexture.hpp index 3621d0c14..7697d296f 100644 --- a/src/ShaderNode/DataModels/SampleTexture.hpp +++ b/src/ShaderNode/DataModels/SampleTexture.hpp @@ -6,9 +6,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include class SampleTexture : public ShaderNode @@ -53,6 +53,6 @@ class SampleTexture : public ShaderNode QVBoxLayout* m_layout; }; -#include +#include #endif diff --git a/src/ShaderNode/DataModels/SampleTexture.inl b/src/ShaderNode/DataModels/SampleTexture.inl index 78d12b21d..292805b16 100644 --- a/src/ShaderNode/DataModels/SampleTexture.inl +++ b/src/ShaderNode/DataModels/SampleTexture.inl @@ -1,2 +1,2 @@ -#include +#include #include diff --git a/src/ShaderNode/DataModels/ShaderNode.cpp b/src/ShaderNode/DataModels/ShaderNode.cpp index 1f45d3ca5..aeb143452 100644 --- a/src/ShaderNode/DataModels/ShaderNode.cpp +++ b/src/ShaderNode/DataModels/ShaderNode.cpp @@ -1,4 +1,4 @@ -#include +#include void ShaderNode::setInData(std::shared_ptr, int) { diff --git a/src/ShaderNode/DataModels/ShaderNode.hpp b/src/ShaderNode/DataModels/ShaderNode.hpp index d33fc632d..3d73d7330 100644 --- a/src/ShaderNode/DataModels/ShaderNode.hpp +++ b/src/ShaderNode/DataModels/ShaderNode.hpp @@ -23,6 +23,6 @@ class ShaderNode : public QtNodes::NodeDataModel ShaderGraph& m_graph; }; -#include +#include #endif diff --git a/src/ShaderNode/DataModels/ShaderNode.inl b/src/ShaderNode/DataModels/ShaderNode.inl index a244d78b5..defa5aea1 100644 --- a/src/ShaderNode/DataModels/ShaderNode.inl +++ b/src/ShaderNode/DataModels/ShaderNode.inl @@ -1,4 +1,4 @@ -#include +#include inline ShaderNode::ShaderNode(ShaderGraph& graph) : m_graph(graph) diff --git a/src/ShaderNode/DataModels/VecBinOp.cpp b/src/ShaderNode/DataModels/VecBinOp.cpp index dd13b5b56..fd2e0d5c1 100644 --- a/src/ShaderNode/DataModels/VecBinOp.cpp +++ b/src/ShaderNode/DataModels/VecBinOp.cpp @@ -1 +1 @@ -#include +#include diff --git a/src/ShaderNode/DataModels/VecBinOp.hpp b/src/ShaderNode/DataModels/VecBinOp.hpp index 31ae4732e..ef3ee4bca 100644 --- a/src/ShaderNode/DataModels/VecBinOp.hpp +++ b/src/ShaderNode/DataModels/VecBinOp.hpp @@ -3,8 +3,8 @@ #ifndef NAZARA_SHADERNODES_VECBINOP_HPP #define NAZARA_SHADERNODES_VECBINOP_HPP -#include -#include +#include +#include template class VecBinOp : public ShaderNode @@ -83,6 +83,6 @@ using Vec2Sub = VecSub; using Vec3Sub = VecSub; using Vec4Sub = VecSub; -#include +#include #endif diff --git a/src/ShaderNode/DataModels/VecBinOp.inl b/src/ShaderNode/DataModels/VecBinOp.inl index 5d5cfc251..4159193fb 100644 --- a/src/ShaderNode/DataModels/VecBinOp.inl +++ b/src/ShaderNode/DataModels/VecBinOp.inl @@ -1,4 +1,4 @@ -#include +#include #include template diff --git a/src/ShaderNode/DataModels/VecData.cpp b/src/ShaderNode/DataModels/VecData.cpp index 2cf74c1e6..376c8ea5c 100644 --- a/src/ShaderNode/DataModels/VecData.cpp +++ b/src/ShaderNode/DataModels/VecData.cpp @@ -1 +1 @@ -#include +#include diff --git a/src/ShaderNode/DataModels/VecData.hpp b/src/ShaderNode/DataModels/VecData.hpp index ad44d68b1..8a1b152f5 100644 --- a/src/ShaderNode/DataModels/VecData.hpp +++ b/src/ShaderNode/DataModels/VecData.hpp @@ -62,6 +62,6 @@ struct Vec4Data : public VecData } }; -#include +#include #endif diff --git a/src/ShaderNode/DataModels/VecData.inl b/src/ShaderNode/DataModels/VecData.inl index 92765c835..6c2d0379e 100644 --- a/src/ShaderNode/DataModels/VecData.inl +++ b/src/ShaderNode/DataModels/VecData.inl @@ -1,4 +1,4 @@ -#include +#include inline VecData::VecData() : preview(64, 64, QImage::Format_RGBA8888) diff --git a/src/ShaderNode/DataModels/VecValue.cpp b/src/ShaderNode/DataModels/VecValue.cpp index 807df2955..ede5bdfac 100644 --- a/src/ShaderNode/DataModels/VecValue.cpp +++ b/src/ShaderNode/DataModels/VecValue.cpp @@ -1 +1 @@ -#include +#include diff --git a/src/ShaderNode/DataModels/VecValue.hpp b/src/ShaderNode/DataModels/VecValue.hpp index 77656f373..7e8db4d88 100644 --- a/src/ShaderNode/DataModels/VecValue.hpp +++ b/src/ShaderNode/DataModels/VecValue.hpp @@ -7,8 +7,8 @@ #include #include #include -#include -#include +#include +#include #include template @@ -71,6 +71,6 @@ using Vec2Value = VecValue; using Vec3Value = VecValue; using Vec4Value = VecValue; -#include +#include #endif diff --git a/src/ShaderNode/DataModels/VecValue.inl b/src/ShaderNode/DataModels/VecValue.inl index 3ab11cd37..45138b83f 100644 --- a/src/ShaderNode/DataModels/VecValue.inl +++ b/src/ShaderNode/DataModels/VecValue.inl @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include diff --git a/src/ShaderNode/Enums.cpp b/src/ShaderNode/Enums.cpp index f280ce793..22f21c972 100644 --- a/src/ShaderNode/Enums.cpp +++ b/src/ShaderNode/Enums.cpp @@ -1,4 +1,4 @@ -#include +#include #include const char* EnumToString(InputRole role) diff --git a/src/ShaderNode/Enums.hpp b/src/ShaderNode/Enums.hpp index 6a7a34336..b8e944c5c 100644 --- a/src/ShaderNode/Enums.hpp +++ b/src/ShaderNode/Enums.hpp @@ -43,6 +43,6 @@ const char* EnumToString(InputRole role); const char* EnumToString(InputType input); const char* EnumToString(TextureType textureType); -#include +#include #endif diff --git a/src/ShaderNode/Enums.inl b/src/ShaderNode/Enums.inl index a23a54efb..243d12205 100644 --- a/src/ShaderNode/Enums.inl +++ b/src/ShaderNode/Enums.inl @@ -1 +1 @@ -#include +#include diff --git a/src/ShaderNode/Previews/PreviewModel.cpp b/src/ShaderNode/Previews/PreviewModel.cpp index 845c19fe2..d4ab52386 100644 --- a/src/ShaderNode/Previews/PreviewModel.cpp +++ b/src/ShaderNode/Previews/PreviewModel.cpp @@ -1,3 +1,3 @@ -#include +#include PreviewModel::~PreviewModel() = default; diff --git a/src/ShaderNode/Previews/PreviewModel.hpp b/src/ShaderNode/Previews/PreviewModel.hpp index 138374ea4..6ed8ec3ef 100644 --- a/src/ShaderNode/Previews/PreviewModel.hpp +++ b/src/ShaderNode/Previews/PreviewModel.hpp @@ -3,7 +3,7 @@ #ifndef NAZARA_SHADERNODES_PREVIEWMODEL_HPP #define NAZARA_SHADERNODES_PREVIEWMODEL_HPP -#include +#include class QImage; @@ -16,6 +16,6 @@ class PreviewModel virtual QImage GetImage(InputRole role, std::size_t roleIndex) const = 0; }; -#include +#include #endif diff --git a/src/ShaderNode/Previews/PreviewModel.inl b/src/ShaderNode/Previews/PreviewModel.inl index d5f2e699b..f4dccb3fa 100644 --- a/src/ShaderNode/Previews/PreviewModel.inl +++ b/src/ShaderNode/Previews/PreviewModel.inl @@ -1 +1 @@ -#include +#include diff --git a/src/ShaderNode/Previews/QuadPreview.cpp b/src/ShaderNode/Previews/QuadPreview.cpp index a518287fd..55ae86a52 100644 --- a/src/ShaderNode/Previews/QuadPreview.cpp +++ b/src/ShaderNode/Previews/QuadPreview.cpp @@ -1,4 +1,4 @@ -#include +#include #include QImage QuadPreview::GetImage(InputRole role, std::size_t roleIndex) const diff --git a/src/ShaderNode/Previews/QuadPreview.hpp b/src/ShaderNode/Previews/QuadPreview.hpp index f193e99d0..6c980ae34 100644 --- a/src/ShaderNode/Previews/QuadPreview.hpp +++ b/src/ShaderNode/Previews/QuadPreview.hpp @@ -3,7 +3,7 @@ #ifndef NAZARA_SHADERNODES_QUADPREVIEW_HPP #define NAZARA_SHADERNODES_QUADPREVIEW_HPP -#include +#include #include class QuadPreview : public PreviewModel @@ -15,6 +15,6 @@ class QuadPreview : public PreviewModel QImage GetImage(InputRole role, std::size_t roleIndex) const override; }; -#include +#include #endif diff --git a/src/ShaderNode/Previews/QuadPreview.inl b/src/ShaderNode/Previews/QuadPreview.inl index 01178d2d2..b3e26a0ab 100644 --- a/src/ShaderNode/Previews/QuadPreview.inl +++ b/src/ShaderNode/Previews/QuadPreview.inl @@ -1 +1 @@ -#include +#include diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp index be77909de..e29c0129f 100644 --- a/src/ShaderNode/ShaderGraph.cpp +++ b/src/ShaderNode/ShaderGraph.cpp @@ -1,13 +1,13 @@ -#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/ShaderNode/ShaderGraph.hpp b/src/ShaderNode/ShaderGraph.hpp index dda8dba20..aa2188f16 100644 --- a/src/ShaderNode/ShaderGraph.hpp +++ b/src/ShaderNode/ShaderGraph.hpp @@ -6,8 +6,8 @@ #include #include #include -#include -#include +#include +#include #include #include @@ -64,6 +64,6 @@ class ShaderGraph std::unique_ptr m_previewModel; }; -#include +#include #endif diff --git a/src/ShaderNode/ShaderGraph.inl b/src/ShaderNode/ShaderGraph.inl index fb0a9e556..100cd822e 100644 --- a/src/ShaderNode/ShaderGraph.inl +++ b/src/ShaderNode/ShaderGraph.inl @@ -1,4 +1,4 @@ -#include +#include inline auto ShaderGraph::GetInput(std::size_t inputIndex) const -> const InputEntry& { diff --git a/src/ShaderNode/Widgets/InputEditDialog.cpp b/src/ShaderNode/Widgets/InputEditDialog.cpp index d9642966c..71e6b2298 100644 --- a/src/ShaderNode/Widgets/InputEditDialog.cpp +++ b/src/ShaderNode/Widgets/InputEditDialog.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/src/ShaderNode/Widgets/InputEditDialog.hpp b/src/ShaderNode/Widgets/InputEditDialog.hpp index 829697049..ef96d118c 100644 --- a/src/ShaderNode/Widgets/InputEditDialog.hpp +++ b/src/ShaderNode/Widgets/InputEditDialog.hpp @@ -3,7 +3,7 @@ #ifndef NAZARA_SHADERNODES_INPUTEDITDIALOG_HPP #define NAZARA_SHADERNODES_INPUTEDITDIALOG_HPP -#include +#include #include class QComboBox; @@ -36,6 +36,6 @@ class InputEditDialog : public QDialog QSpinBox* m_roleIndex; }; -#include +#include #endif diff --git a/src/ShaderNode/Widgets/InputEditDialog.inl b/src/ShaderNode/Widgets/InputEditDialog.inl index a480716aa..db2681e5c 100644 --- a/src/ShaderNode/Widgets/InputEditDialog.inl +++ b/src/ShaderNode/Widgets/InputEditDialog.inl @@ -1 +1 @@ -#include +#include diff --git a/src/ShaderNode/Widgets/InputEditor.cpp b/src/ShaderNode/Widgets/InputEditor.cpp index 86a28a2eb..a0dee923d 100644 --- a/src/ShaderNode/Widgets/InputEditor.cpp +++ b/src/ShaderNode/Widgets/InputEditor.cpp @@ -1,6 +1,6 @@ -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/src/ShaderNode/Widgets/InputEditor.hpp b/src/ShaderNode/Widgets/InputEditor.hpp index 236f9069f..561a7b362 100644 --- a/src/ShaderNode/Widgets/InputEditor.hpp +++ b/src/ShaderNode/Widgets/InputEditor.hpp @@ -3,7 +3,7 @@ #ifndef NAZARA_SHADERNODES_INPUTEDITOR_HPP #define NAZARA_SHADERNODES_INPUTEDITOR_HPP -#include +#include #include #include @@ -34,6 +34,6 @@ class InputEditor : public QWidget QVBoxLayout* m_layout; }; -#include +#include #endif diff --git a/src/ShaderNode/Widgets/InputEditor.inl b/src/ShaderNode/Widgets/InputEditor.inl index a480716aa..db2681e5c 100644 --- a/src/ShaderNode/Widgets/InputEditor.inl +++ b/src/ShaderNode/Widgets/InputEditor.inl @@ -1 +1 @@ -#include +#include diff --git a/src/ShaderNode/Widgets/MainWindow.cpp b/src/ShaderNode/Widgets/MainWindow.cpp index 150770541..8aa48c353 100644 --- a/src/ShaderNode/Widgets/MainWindow.cpp +++ b/src/ShaderNode/Widgets/MainWindow.cpp @@ -1,8 +1,8 @@ -#include +#include #include -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/src/ShaderNode/Widgets/MainWindow.hpp b/src/ShaderNode/Widgets/MainWindow.hpp index fa8257bcf..3e68ec267 100644 --- a/src/ShaderNode/Widgets/MainWindow.hpp +++ b/src/ShaderNode/Widgets/MainWindow.hpp @@ -4,7 +4,7 @@ #define NAZARA_SHADERNODES_MAINWINDOW_HPP #include -#include +#include class ShaderGraph; @@ -21,6 +21,6 @@ class MainWindow : public QMainWindow ShaderGraph& m_shaderGraph; }; -#include +#include #endif diff --git a/src/ShaderNode/Widgets/MainWindow.inl b/src/ShaderNode/Widgets/MainWindow.inl index 48dbe409e..f10445799 100644 --- a/src/ShaderNode/Widgets/MainWindow.inl +++ b/src/ShaderNode/Widgets/MainWindow.inl @@ -1 +1 @@ -#include +#include diff --git a/src/ShaderNode/Widgets/TextureEditor.cpp b/src/ShaderNode/Widgets/TextureEditor.cpp index 44a68fec9..40cce4652 100644 --- a/src/ShaderNode/Widgets/TextureEditor.cpp +++ b/src/ShaderNode/Widgets/TextureEditor.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include #include #include #include diff --git a/src/ShaderNode/Widgets/TextureEditor.hpp b/src/ShaderNode/Widgets/TextureEditor.hpp index 456b9b1d5..a3497f288 100644 --- a/src/ShaderNode/Widgets/TextureEditor.hpp +++ b/src/ShaderNode/Widgets/TextureEditor.hpp @@ -3,7 +3,7 @@ #ifndef NAZARA_SHADERNODES_TEXTUREEDITOR_HPP #define NAZARA_SHADERNODES_TEXTUREEDITOR_HPP -#include +#include #include #include @@ -35,6 +35,6 @@ class TextureEditor : public QWidget QVBoxLayout* m_layout; }; -#include +#include #endif diff --git a/src/ShaderNode/Widgets/TextureEditor.inl b/src/ShaderNode/Widgets/TextureEditor.inl index d11298db1..318a1e9a3 100644 --- a/src/ShaderNode/Widgets/TextureEditor.inl +++ b/src/ShaderNode/Widgets/TextureEditor.inl @@ -1 +1 @@ -#include +#include diff --git a/src/ShaderNode/main.cpp b/src/ShaderNode/main.cpp index a9554c8bd..a939e708a 100644 --- a/src/ShaderNode/main.cpp +++ b/src/ShaderNode/main.cpp @@ -1,6 +1,6 @@ #include -#include -#include +#include +#include #include int main(int argc, char* argv[]) From 3b440254daad157bf1cecead6adc93f73a56d3d5 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 26 May 2020 15:58:15 +0200 Subject: [PATCH 205/316] Math/Vector[I]: Set method: Replace array by pointer --- include/Nazara/Math/Vector2.hpp | 2 +- include/Nazara/Math/Vector2.inl | 3 +-- include/Nazara/Math/Vector3.hpp | 2 +- include/Nazara/Math/Vector3.inl | 2 +- include/Nazara/Math/Vector4.hpp | 2 +- include/Nazara/Math/Vector4.inl | 3 +-- 6 files changed, 6 insertions(+), 8 deletions(-) diff --git a/include/Nazara/Math/Vector2.hpp b/include/Nazara/Math/Vector2.hpp index c9dba6bfa..72c72da4c 100644 --- a/include/Nazara/Math/Vector2.hpp +++ b/include/Nazara/Math/Vector2.hpp @@ -54,7 +54,7 @@ namespace Nz Vector2& Set(T X, T Y); Vector2& Set(T scale); - Vector2& Set(const T vec[2]); + Vector2& Set(const T* vec); Vector2& Set(const Vector3& vec); Vector2& Set(const Vector4& vec); template Vector2& Set(const Vector2& vec); diff --git a/include/Nazara/Math/Vector2.inl b/include/Nazara/Math/Vector2.inl index e22e00bc2..7d2754955 100644 --- a/include/Nazara/Math/Vector2.inl +++ b/include/Nazara/Math/Vector2.inl @@ -363,9 +363,8 @@ namespace Nz * * \param vec[2] vec[0] is X component and vec[1] is Y component */ - template - Vector2& Vector2::Set(const T vec[2]) + Vector2& Vector2::Set(const T* vec) { x = vec[0]; y = vec[1]; diff --git a/include/Nazara/Math/Vector3.hpp b/include/Nazara/Math/Vector3.hpp index 99e3696df..1603f7d34 100644 --- a/include/Nazara/Math/Vector3.hpp +++ b/include/Nazara/Math/Vector3.hpp @@ -65,7 +65,7 @@ namespace Nz Vector3& Set(T X, T Y, T Z); Vector3& Set(T X, const Vector2& vec); Vector3& Set(T scale); - Vector3& Set(const T vec[3]); + Vector3& Set(const T* vec); Vector3& Set(const Vector2& vec, T Z = 0.0); template Vector3& Set(const Vector3& vec); Vector3& Set(const Vector4& vec); diff --git a/include/Nazara/Math/Vector3.inl b/include/Nazara/Math/Vector3.inl index 1dcf48fe7..a9602a248 100644 --- a/include/Nazara/Math/Vector3.inl +++ b/include/Nazara/Math/Vector3.inl @@ -498,7 +498,7 @@ namespace Nz * \param vec[3] vec[0] is X component, vec[1] is Y component and vec[2] is Z component */ template - Vector3& Vector3::Set(const T vec[3]) + Vector3& Vector3::Set(const T* vec) { x = vec[0]; y = vec[1]; diff --git a/include/Nazara/Math/Vector4.hpp b/include/Nazara/Math/Vector4.hpp index 2938df3bb..24893ee65 100644 --- a/include/Nazara/Math/Vector4.hpp +++ b/include/Nazara/Math/Vector4.hpp @@ -54,7 +54,7 @@ namespace Nz Vector4& Set(T X, const Vector2& vec, T W); Vector4& Set(T X, const Vector3& vec); Vector4& Set(T scale); - Vector4& Set(const T vec[4]); + Vector4& Set(const T* vec); Vector4& Set(const Vector2& vec, T Z = 0.0, T W = 1.0); Vector4& Set(const Vector3& vec, T W = 1.0); template Vector4& Set(const Vector4& vec); diff --git a/include/Nazara/Math/Vector4.inl b/include/Nazara/Math/Vector4.inl index 6deadf5f5..93003da9b 100644 --- a/include/Nazara/Math/Vector4.inl +++ b/include/Nazara/Math/Vector4.inl @@ -413,9 +413,8 @@ namespace Nz * * \param vec[4] vec[0] is X component, vec[1] is Y component, vec[2] is Z component and vec[3] is W component */ - template - Vector4& Vector4::Set(const T vec[4]) + Vector4& Vector4::Set(const T* vec) { x = vec[0]; y = vec[1]; From b1b90303598b5807bc32a2591f0f3d35b87716c0 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 26 May 2020 16:03:57 +0200 Subject: [PATCH 206/316] Math/Vector[I]: Replace implicit pointer conversion by [] operator overload --- include/Nazara/Math/Vector2.hpp | 4 ++-- include/Nazara/Math/Vector2.inl | 24 ++++++++++-------------- include/Nazara/Math/Vector3.hpp | 4 ++-- include/Nazara/Math/Vector3.inl | 22 ++++++++++------------ include/Nazara/Math/Vector4.hpp | 4 ++-- include/Nazara/Math/Vector4.inl | 24 ++++++++++-------------- src/Nazara/Utility/Formats/MD2Loader.cpp | 4 ++-- 7 files changed, 38 insertions(+), 48 deletions(-) diff --git a/include/Nazara/Math/Vector2.hpp b/include/Nazara/Math/Vector2.hpp index 72c72da4c..75e86f709 100644 --- a/include/Nazara/Math/Vector2.hpp +++ b/include/Nazara/Math/Vector2.hpp @@ -63,8 +63,8 @@ namespace Nz String ToString() const; - operator T* (); - operator const T* () const; + T& operator[](std::size_t i); + T operator[](std::size_t i) const; const Vector2& operator+() const; Vector2 operator-() const; diff --git a/include/Nazara/Math/Vector2.inl b/include/Nazara/Math/Vector2.inl index 7d2754955..22eb72566 100644 --- a/include/Nazara/Math/Vector2.inl +++ b/include/Nazara/Math/Vector2.inl @@ -450,29 +450,25 @@ namespace Nz } /*! - * \brief Converts vector to pointer to its own data - * \return A pointer to the own data - * - * \remark Access to index greather than 1 is undefined behavior + * \brief Access a vector component by index + * \return X, Y depending on index (0, 1) */ - template - Vector2::operator T* () + T& Vector2::operator[](std::size_t i) { - return &x; + NazaraAssert(i < 2, "index out of range"); + return *(&x + i); } /*! - * \brief Converts vector to const pointer to its own data - * \return A constant pointer to the own data - * - * \remark Access to index greather than 1 is undefined behavior + * \brief Access a vector component by index + * \return X, Y depending on index (0, 1) */ - template - Vector2::operator const T* () const + T Vector2::operator[](std::size_t i) const { - return &x; + NazaraAssert(i < 2, "index out of range"); + return *(&x + i); } /*! diff --git a/include/Nazara/Math/Vector3.hpp b/include/Nazara/Math/Vector3.hpp index 1603f7d34..4fd965484 100644 --- a/include/Nazara/Math/Vector3.hpp +++ b/include/Nazara/Math/Vector3.hpp @@ -74,8 +74,8 @@ namespace Nz String ToString() const; - operator T* (); - operator const T* () const; + T& operator[](std::size_t i); + T operator[](std::size_t i) const; const Vector3& operator+() const; Vector3 operator-() const; diff --git a/include/Nazara/Math/Vector3.inl b/include/Nazara/Math/Vector3.inl index a9602a248..f9585d91e 100644 --- a/include/Nazara/Math/Vector3.inl +++ b/include/Nazara/Math/Vector3.inl @@ -583,27 +583,25 @@ namespace Nz } /*! - * \brief Converts vector to pointer to its own data - * \return A pointer to the own data - * - * \remark Access to index greather than 2 is undefined behavior + * \brief Access a vector component by index + * \return X, Y, Z depending on index (0, 1, 2) */ template - Vector3::operator T* () + T& Vector3::operator[](std::size_t i) { - return &x; + NazaraAssert(i < 3, "index out of range"); + return *(&x + i); } /*! - * \brief Converts vector to const pointer to its own data - * \return A constant pointer to the own data - * - * \remark Access to index greather than 2 is undefined behavior + * \brief Access a vector component by index + * \return X, Y, Z depending on index (0, 1, 2) */ template - Vector3::operator const T* () const + T Vector3::operator[](std::size_t i) const { - return &x; + NazaraAssert(i < 3, "index out of range"); + return *(&x + i); } /*! diff --git a/include/Nazara/Math/Vector4.hpp b/include/Nazara/Math/Vector4.hpp index 24893ee65..5c5c9721f 100644 --- a/include/Nazara/Math/Vector4.hpp +++ b/include/Nazara/Math/Vector4.hpp @@ -61,8 +61,8 @@ namespace Nz String ToString() const; - operator T* (); - operator const T* () const; + T& operator[](std::size_t i); + T operator[](std::size_t i) const; const Vector4& operator+() const; Vector4 operator-() const; diff --git a/include/Nazara/Math/Vector4.inl b/include/Nazara/Math/Vector4.inl index 93003da9b..dfc39aafe 100644 --- a/include/Nazara/Math/Vector4.inl +++ b/include/Nazara/Math/Vector4.inl @@ -494,29 +494,25 @@ namespace Nz } /*! - * \brief Converts vector to pointer to its own data - * \return A pointer to the own data - * - * \remark Access to index greather than 3 is undefined behavior + * \brief Access a vector component by index + * \return X, Y, Z depending on index (0, 1, 2) */ - template - Vector4::operator T* () + T& Vector4::operator[](std::size_t i) { - return &x; + NazaraAssert(i < 4, "index out of range"); + return *(&x + i); } /*! - * \brief Converts vector to const pointer to its own data - * \return A constant pointer to the own data - * - * \remark Access to index greather than 3 is undefined behavior + * \brief Access a vector component by index + * \return X, Y, Z depending on index (0, 1, 2) */ - template - Vector4::operator const T* () const + T Vector4::operator[](std::size_t i) const { - return &x; + NazaraAssert(i < 4, "index out of range"); + return *(&x + i); } /*! diff --git a/src/Nazara/Utility/Formats/MD2Loader.cpp b/src/Nazara/Utility/Formats/MD2Loader.cpp index 0f369cfe5..890572d35 100644 --- a/src/Nazara/Utility/Formats/MD2Loader.cpp +++ b/src/Nazara/Utility/Formats/MD2Loader.cpp @@ -166,8 +166,8 @@ namespace Nz std::vector vertices(header.num_vertices); Vector3f scale, translate; - stream.Read(scale, sizeof(Vector3f)); - stream.Read(translate, sizeof(Vector3f)); + stream.Read(&scale, sizeof(Vector3f)); + stream.Read(&translate, sizeof(Vector3f)); stream.Read(nullptr, 16*sizeof(char)); //< Frame name, unused stream.Read(vertices.data(), header.num_vertices*sizeof(MD2_Vertex)); From 09e08255fbe4454d582ace7be86449ca0f07c59e Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 26 May 2020 19:22:31 +0200 Subject: [PATCH 207/316] ShaderAst: Add node editor window --- src/ShaderNode/DataModels/Cast.hpp | 12 +- src/ShaderNode/DataModels/Cast.inl | 100 +++++++-------- src/ShaderNode/DataModels/FragmentOutput.cpp | 28 ++++- src/ShaderNode/DataModels/FragmentOutput.hpp | 8 +- src/ShaderNode/DataModels/FragmentOutput.inl | 2 + src/ShaderNode/DataModels/InputValue.cpp | 100 ++++++++------- src/ShaderNode/DataModels/InputValue.hpp | 17 ++- src/ShaderNode/DataModels/SampleTexture.cpp | 126 ++++++++++--------- src/ShaderNode/DataModels/SampleTexture.hpp | 17 ++- src/ShaderNode/DataModels/ShaderNode.cpp | 76 +++++++++++ src/ShaderNode/DataModels/ShaderNode.hpp | 24 +++- src/ShaderNode/DataModels/ShaderNode.inl | 11 +- src/ShaderNode/DataModels/VecBinOp.hpp | 7 +- src/ShaderNode/DataModels/VecBinOp.inl | 75 ++++++----- src/ShaderNode/DataModels/VecData.hpp | 39 ++++++ src/ShaderNode/DataModels/VecValue.hpp | 38 +----- src/ShaderNode/DataModels/VecValue.inl | 97 ++++++-------- src/ShaderNode/ShaderGraph.cpp | 13 +- src/ShaderNode/ShaderGraph.hpp | 3 + src/ShaderNode/Widgets/MainWindow.cpp | 33 ++++- src/ShaderNode/Widgets/MainWindow.hpp | 6 +- src/ShaderNode/Widgets/NodeEditor.cpp | 20 +++ src/ShaderNode/Widgets/NodeEditor.hpp | 27 ++++ src/ShaderNode/Widgets/NodeEditor.inl | 16 +++ 24 files changed, 558 insertions(+), 337 deletions(-) create mode 100644 src/ShaderNode/Widgets/NodeEditor.cpp create mode 100644 src/ShaderNode/Widgets/NodeEditor.hpp create mode 100644 src/ShaderNode/Widgets/NodeEditor.inl diff --git a/src/ShaderNode/DataModels/Cast.hpp b/src/ShaderNode/DataModels/Cast.hpp index a6709bd2d..19d6363af 100644 --- a/src/ShaderNode/DataModels/Cast.hpp +++ b/src/ShaderNode/DataModels/Cast.hpp @@ -18,13 +18,14 @@ class CastVec : public ShaderNode CastVec(ShaderGraph& graph); ~CastVec() = default; + void BuildNodeEdition(QVBoxLayout* layout) override; + Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const override; QString caption() const override; QString name() const override; QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; - QWidget* embeddedWidget() override; unsigned int nPorts(QtNodes::PortType portType) const override; std::shared_ptr outData(QtNodes::PortIndex port) override; @@ -36,13 +37,10 @@ class CastVec : public ShaderNode static constexpr std::size_t ToComponents = To::ComponentCount; static constexpr std::size_t ComponentDiff = (ToComponents >= FromComponents) ? ToComponents - FromComponents : 0; - void ComputePreview(QPixmap& pixmap) const; - void UpdatePreview(); + bool ComputePreview(QPixmap& pixmap) override; + void UpdateOutput(); - QLabel* m_pixmapLabel; - QPixmap m_pixmap; - QWidget* m_widget; - std::array m_spinboxes; + VecType m_overflowComponents; std::shared_ptr m_input; std::shared_ptr m_output; }; diff --git a/src/ShaderNode/DataModels/Cast.inl b/src/ShaderNode/DataModels/Cast.inl index 0133d6cc7..5c0600833 100644 --- a/src/ShaderNode/DataModels/Cast.inl +++ b/src/ShaderNode/DataModels/Cast.inl @@ -6,41 +6,35 @@ template CastVec::CastVec(ShaderGraph& graph) : ShaderNode(graph) { - constexpr std::array componentName = { 'X', 'Y', 'Z', 'W' }; - static_assert(ComponentDiff <= componentName.size()); + static_assert(ComponentDiff <= s_vectorComponents.size()); +} - QFormLayout* layout = new QFormLayout; +template +void CastVec::BuildNodeEdition(QVBoxLayout* layout) +{ + ShaderNode::BuildNodeEdition(layout); if constexpr (ComponentDiff > 0) { + QFormLayout* formLayout = new QFormLayout; + for (std::size_t i = 0; i < ComponentDiff; ++i) { - m_spinboxes[i] = new QDoubleSpinBox; - m_spinboxes[i]->setDecimals(6); - m_spinboxes[i]->setValue(1.0); - m_spinboxes[i]->setStyleSheet("background-color: rgba(255,255,255,255)"); - connect(m_spinboxes[i], qOverload(&QDoubleSpinBox::valueChanged), [this](double) + QDoubleSpinBox* spinbox = new QDoubleSpinBox; + spinbox->setDecimals(6); + spinbox->setValue(m_overflowComponents[i]); + + connect(spinbox, qOverload(&QDoubleSpinBox::valueChanged), [=](double) { - UpdatePreview(); + m_overflowComponents[i] = spinbox->value(); + UpdateOutput(); }); - layout->addRow(QString::fromUtf8(&componentName[FromComponents + i], 1), m_spinboxes[i]); + formLayout->addRow(QString::fromUtf8(&s_vectorComponents[FromComponents + i], 1), spinbox); } + + layout->addLayout(formLayout); } - - m_pixmap = QPixmap(64, 64); - m_pixmap.fill(); - - m_pixmapLabel = new QLabel; - m_pixmapLabel->setPixmap(m_pixmap); - - layout->addWidget(m_pixmapLabel); - - m_widget = new QWidget; - m_widget->setStyleSheet("background-color: rgba(0,0,0,0)"); - m_widget->setLayout(layout); - - m_output = std::make_shared(); } template @@ -52,7 +46,7 @@ Nz::ShaderAst::ExpressionPtr CastVec::GetExpression(Nz::ShaderAst::Exp { std::array constants; for (std::size_t i = 0; i < ComponentDiff; ++i) - constants[i] = Nz::ShaderBuilder::Constant(float(m_spinboxes[i]->value())); + constants[i] = Nz::ShaderBuilder::Constant(m_overflowComponents[i]); return std::apply([&](auto&&... values) { @@ -102,12 +96,6 @@ QtNodes::NodeDataType CastVec::dataType(QtNodes::PortType portType, Qt throw std::runtime_error("Invalid port type"); } -template -QWidget* CastVec::embeddedWidget() -{ - return m_widget; -} - template unsigned int CastVec::nPorts(QtNodes::PortType portType) const { @@ -124,6 +112,10 @@ template std::shared_ptr CastVec::outData(QtNodes::PortIndex port) { assert(port == 0); + + if (!m_input) + return nullptr; + return m_output; } @@ -139,13 +131,28 @@ void CastVec::setInData(std::shared_ptr value, int else m_input.reset(); - UpdatePreview(); + UpdateOutput(); } template -void CastVec::ComputePreview(QPixmap& pixmap) const +bool CastVec::ComputePreview(QPixmap& pixmap) { - assert(m_input); + if (!m_input) + return false; + + pixmap = QPixmap::fromImage(m_output->preview); + return true; +} + +template +void CastVec::UpdateOutput() +{ + if (!m_input) + { + m_output->preview = QImage(1, 1, QImage::Format_RGBA8888); + m_output->preview.fill(QColor::fromRgb(0, 0, 0, 0)); + return; + } const QImage& input = m_input->preview; @@ -156,8 +163,11 @@ void CastVec::ComputePreview(QPixmap& pixmap) const output = QImage(inputWidth, inputHeight, QImage::Format_RGBA8888); std::array constants; - for (std::size_t i = 0; i < ComponentDiff; ++i) - constants[i] = static_cast(std::clamp(int(m_spinboxes[i]->value() * 255), 0, 255)); + if constexpr (ComponentDiff > 0) + { + for (std::size_t i = 0; i < ComponentDiff; ++i) + constants[i] = static_cast(std::clamp(int(m_overflowComponents[i] * 255), 0, 255)); + } std::uint8_t* outputPtr = output.bits(); const std::uint8_t* inputPtr = input.constBits(); @@ -181,21 +191,7 @@ void CastVec::ComputePreview(QPixmap& pixmap) const } } - pixmap = QPixmap::fromImage(output).scaled(64, 64); -} - -template -void CastVec::UpdatePreview() -{ - if (!m_input) - { - m_pixmap = QPixmap(64, 64); - m_pixmap.fill(QColor::fromRgb(255, 255, 255, 0)); - } - else - ComputePreview(m_pixmap); - - m_pixmapLabel->setPixmap(m_pixmap); - Q_EMIT dataUpdated(0); + + UpdatePreview(); } diff --git a/src/ShaderNode/DataModels/FragmentOutput.cpp b/src/ShaderNode/DataModels/FragmentOutput.cpp index 86731a0f4..bfac47bee 100644 --- a/src/ShaderNode/DataModels/FragmentOutput.cpp +++ b/src/ShaderNode/DataModels/FragmentOutput.cpp @@ -22,11 +22,6 @@ QtNodes::NodeDataType FragmentOutput::dataType(QtNodes::PortType portType, QtNod return Vec4Data::Type(); } -QWidget* FragmentOutput::embeddedWidget() -{ - return nullptr; -} - unsigned int FragmentOutput::nPorts(QtNodes::PortType portType) const { switch (portType) @@ -42,3 +37,26 @@ std::shared_ptr FragmentOutput::outData(QtNodes::PortIndex /* { return {}; } + +void FragmentOutput::setInData(std::shared_ptr value, int index) +{ + assert(index == 0); + if (value) + { + assert(dynamic_cast(value.get()) != nullptr); + m_input = std::static_pointer_cast(value); + } + else + m_input.reset(); + + UpdatePreview(); +} + +bool FragmentOutput::ComputePreview(QPixmap& pixmap) +{ + if (!m_input) + return false; + + pixmap = QPixmap::fromImage(m_input->preview); + return true; +} diff --git a/src/ShaderNode/DataModels/FragmentOutput.hpp b/src/ShaderNode/DataModels/FragmentOutput.hpp index ab89ae419..c70f39ff6 100644 --- a/src/ShaderNode/DataModels/FragmentOutput.hpp +++ b/src/ShaderNode/DataModels/FragmentOutput.hpp @@ -4,6 +4,7 @@ #define NAZARA_SHADERNODES_FRAGMENTOUTPUT_HPP #include +#include #include #include @@ -19,13 +20,16 @@ class FragmentOutput : public ShaderNode QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; - QWidget* embeddedWidget() override; unsigned int nPorts(QtNodes::PortType portType) const override; std::shared_ptr outData(QtNodes::PortIndex port) override; - void setInData(std::shared_ptr, int) override {}; + void setInData(std::shared_ptr value, int index) override; + private: + bool ComputePreview(QPixmap& pixmap) override; + + std::shared_ptr m_input; }; #include diff --git a/src/ShaderNode/DataModels/FragmentOutput.inl b/src/ShaderNode/DataModels/FragmentOutput.inl index c809a587d..24fc6cbf9 100644 --- a/src/ShaderNode/DataModels/FragmentOutput.inl +++ b/src/ShaderNode/DataModels/FragmentOutput.inl @@ -3,4 +3,6 @@ inline FragmentOutput::FragmentOutput(ShaderGraph& graph) : ShaderNode(graph) { + SetPreviewSize({ 128, 128 }); + EnablePreview(true); } diff --git a/src/ShaderNode/DataModels/InputValue.cpp b/src/ShaderNode/DataModels/InputValue.cpp index f2ae0eaa8..a6044a229 100644 --- a/src/ShaderNode/DataModels/InputValue.cpp +++ b/src/ShaderNode/DataModels/InputValue.cpp @@ -4,48 +4,18 @@ #include InputValue::InputValue(ShaderGraph& graph) : -ShaderNode(graph), -m_currentInputIndex(0) +ShaderNode(graph) { - m_layout = new QVBoxLayout; - - m_inputSelection = new QComboBox; - m_inputSelection->setStyleSheet("background-color: rgba(255,255,255,255)"); - connect(m_inputSelection, qOverload(&QComboBox::currentIndexChanged), [&](int index) - { - if (index < 0) - return; - - m_currentInputIndex = static_cast(index); - UpdatePreview(); - }); - - m_layout->addWidget(m_inputSelection); - - m_previewLabel = new QLabel; - - m_layout->addWidget(m_previewLabel); - - m_widget = new QWidget; - m_widget->setStyleSheet("background-color: rgba(0,0,0,0)"); - m_widget->setLayout(m_layout); - - m_onInputListUpdateSlot.Connect(GetGraph().OnInputListUpdate, [&](ShaderGraph*) { UpdateInputList(); }); + m_onInputListUpdateSlot.Connect(GetGraph().OnInputListUpdate, [&](ShaderGraph*) { OnInputListUpdate(); }); m_onInputUpdateSlot.Connect(GetGraph().OnInputUpdate, [&](ShaderGraph*, std::size_t inputIndex) { if (m_currentInputIndex == inputIndex) UpdatePreview(); }); - UpdateInputList(); UpdatePreview(); } -QWidget* InputValue::embeddedWidget() -{ - return m_widget; -} - unsigned int InputValue::nPorts(QtNodes::PortType portType) const { switch (portType) @@ -57,36 +27,66 @@ unsigned int InputValue::nPorts(QtNodes::PortType portType) const return 0; } -void InputValue::UpdatePreview() +bool InputValue::ComputePreview(QPixmap& pixmap) { - if (m_inputSelection->count() == 0) - return; + if (!m_currentInputIndex) + return false; const ShaderGraph& graph = GetGraph(); - const auto& inputEntry = graph.GetInput(m_currentInputIndex); + const auto& inputEntry = graph.GetInput(*m_currentInputIndex); const auto& preview = graph.GetPreviewModel(); - m_previewLabel->setPixmap(QPixmap::fromImage(preview.GetImage(inputEntry.role, inputEntry.roleIndex))); - - Q_EMIT dataUpdated(0); + pixmap = QPixmap::fromImage(preview.GetImage(inputEntry.role, inputEntry.roleIndex)); + return true; } -void InputValue::UpdateInputList() +void InputValue::OnInputListUpdate() { - QString currentInput = m_inputSelection->currentText(); - m_inputSelection->clear(); + m_currentInputIndex.reset(); + + std::size_t inputIndex = 0; + for (const auto& inputEntry : GetGraph().GetInputs()) + { + if (inputEntry.name == m_currentInputText) + { + m_currentInputIndex = inputIndex; + break; + } + + inputIndex++; + } +} + +void InputValue::BuildNodeEdition(QVBoxLayout* layout) +{ + ShaderNode::BuildNodeEdition(layout); + + QComboBox* inputSelection = new QComboBox; + + connect(inputSelection, qOverload(&QComboBox::currentIndexChanged), [&](int index) + { + if (index >= 0) + m_currentInputIndex = static_cast(index); + else + m_currentInputIndex.reset(); + + UpdatePreview(); + }); for (const auto& inputEntry : GetGraph().GetInputs()) - m_inputSelection->addItem(QString::fromStdString(inputEntry.name)); + inputSelection->addItem(QString::fromStdString(inputEntry.name)); - m_inputSelection->setCurrentText(currentInput); + layout->addWidget(inputSelection); } Nz::ShaderAst::ExpressionPtr InputValue::GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const { assert(count == 0); - const auto& inputEntry = GetGraph().GetInput(m_currentInputIndex); + if (!m_currentInputIndex) + throw std::runtime_error("no input"); + + const auto& inputEntry = GetGraph().GetInput(*m_currentInputIndex); Nz::ShaderAst::ExpressionType expression = [&] { @@ -108,10 +108,13 @@ Nz::ShaderAst::ExpressionPtr InputValue::GetExpression(Nz::ShaderAst::Expression auto InputValue::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const -> QtNodes::NodeDataType { + if (!m_currentInputIndex) + return Vec4Data::Type(); + assert(portType == QtNodes::PortType::Out); assert(portIndex == 0); - const auto& inputEntry = GetGraph().GetInput(m_currentInputIndex); + const auto& inputEntry = GetGraph().GetInput(*m_currentInputIndex); switch (inputEntry.type) { //case InputType::Bool: return Nz::ShaderAst::ExpressionType::Boolean; @@ -127,10 +130,13 @@ auto InputValue::dataType(QtNodes::PortType portType, QtNodes::PortIndex portInd std::shared_ptr InputValue::outData(QtNodes::PortIndex port) { + if (!m_currentInputIndex) + return nullptr; + assert(port == 0); const ShaderGraph& graph = GetGraph(); - const auto& inputEntry = graph.GetInput(m_currentInputIndex); + const auto& inputEntry = graph.GetInput(*m_currentInputIndex); const auto& preview = graph.GetPreviewModel(); auto vecData = std::make_shared(); diff --git a/src/ShaderNode/DataModels/InputValue.hpp b/src/ShaderNode/DataModels/InputValue.hpp index 273155cc4..84b7d6393 100644 --- a/src/ShaderNode/DataModels/InputValue.hpp +++ b/src/ShaderNode/DataModels/InputValue.hpp @@ -9,6 +9,7 @@ #include #include #include +#include class InputValue : public ShaderNode { @@ -16,30 +17,28 @@ class InputValue : public ShaderNode InputValue(ShaderGraph& graph); ~InputValue() = default; + void BuildNodeEdition(QVBoxLayout* layout) override; + Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const override; QString caption() const override { return "Input"; } QString name() const override { return "Input"; } - QWidget* embeddedWidget() override; unsigned int nPorts(QtNodes::PortType portType) const override; QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; std::shared_ptr outData(QtNodes::PortIndex port) override; - protected: - void UpdatePreview(); - void UpdateInputList(); + private: + bool ComputePreview(QPixmap& pixmap) override; + void OnInputListUpdate(); NazaraSlot(ShaderGraph, OnInputListUpdate, m_onInputListUpdateSlot); NazaraSlot(ShaderGraph, OnInputUpdate, m_onInputUpdateSlot); - std::size_t m_currentInputIndex; - QComboBox* m_inputSelection; - QLabel* m_previewLabel; - QWidget* m_widget; - QVBoxLayout* m_layout; + std::optional m_currentInputIndex; + std::string m_currentInputText; }; #include diff --git a/src/ShaderNode/DataModels/SampleTexture.cpp b/src/ShaderNode/DataModels/SampleTexture.cpp index 81982c83a..f299b6009 100644 --- a/src/ShaderNode/DataModels/SampleTexture.cpp +++ b/src/ShaderNode/DataModels/SampleTexture.cpp @@ -4,52 +4,16 @@ #include SampleTexture::SampleTexture(ShaderGraph& graph) : -ShaderNode(graph), -m_currentTextureIndex(0) +ShaderNode(graph) { m_output = std::make_shared(); - m_layout = new QVBoxLayout; - - m_textureSelection = new QComboBox; - m_textureSelection->setStyleSheet("background-color: rgba(255,255,255,255)"); - connect(m_textureSelection, qOverload(&QComboBox::currentIndexChanged), [&](int index) - { - if (index < 0) - return; - - m_currentTextureIndex = static_cast(index); - UpdatePreview(); - }); - - m_layout->addWidget(m_textureSelection); - - m_pixmap = QPixmap(64, 64); - m_pixmap.fill(); - - m_pixmapLabel = new QLabel; - m_pixmapLabel->setPixmap(m_pixmap); - - m_layout->addWidget(m_pixmapLabel); - - m_widget = new QWidget; - m_widget->setStyleSheet("background-color: rgba(0,0,0,0)"); - m_widget->setLayout(m_layout); - - m_onTextureListUpdateSlot.Connect(GetGraph().OnTextureListUpdate, [&](ShaderGraph*) { UpdateTextureList(); }); + m_onTextureListUpdateSlot.Connect(GetGraph().OnTextureListUpdate, [&](ShaderGraph*) { OnTextureListUpdate(); }); m_onTexturePreviewUpdateSlot.Connect(GetGraph().OnTexturePreviewUpdate, [&](ShaderGraph*, std::size_t textureIndex) { if (m_currentTextureIndex == textureIndex) UpdatePreview(); }); - - UpdateTextureList(); - UpdatePreview(); -} - -QWidget* SampleTexture::embeddedWidget() -{ - return m_widget; } unsigned int SampleTexture::nPorts(QtNodes::PortType portType) const @@ -63,39 +27,39 @@ unsigned int SampleTexture::nPorts(QtNodes::PortType portType) const return 0; } -void SampleTexture::UpdatePreview() +void SampleTexture::OnTextureListUpdate() { - if (m_textureSelection->count() == 0) - return; - - ComputePreview(m_pixmap); - m_pixmapLabel->setPixmap(m_pixmap); - - Q_EMIT dataUpdated(0); -} - -void SampleTexture::UpdateTextureList() -{ - QString currentTexture = m_textureSelection->currentText(); - m_textureSelection->clear(); + m_currentTextureIndex.reset(); + std::size_t inputIndex = 0; for (const auto& textureEntry : GetGraph().GetTextures()) - m_textureSelection->addItem(QString::fromStdString(textureEntry.name)); + { + if (textureEntry.name == m_currentTextureText) + { + m_currentTextureIndex = inputIndex; + break; + } - m_textureSelection->setCurrentText(currentTexture); + inputIndex++; + } } -void SampleTexture::ComputePreview(QPixmap& pixmap) const +void SampleTexture::UpdateOutput() { - if (!m_uv) - return; + QImage& output = m_output->preview; - const auto& textureEntry = GetGraph().GetTexture(m_currentTextureIndex); + if (!m_currentTextureIndex || !m_uv) + { + output = QImage(1, 1, QImage::Format_RGBA8888); + output.fill(QColor::fromRgb(0, 0, 0, 0)); + return; + } + + const auto& textureEntry = GetGraph().GetTexture(*m_currentTextureIndex); int textureWidth = textureEntry.preview.width(); int textureHeight = textureEntry.preview.height(); - QImage& output = m_output->preview; const QImage& uv = m_uv->preview; int uvWidth = uv.width(); @@ -125,14 +89,49 @@ void SampleTexture::ComputePreview(QPixmap& pixmap) const } } - pixmap = QPixmap::fromImage(output).scaled(128, 128, Qt::KeepAspectRatio); + Q_EMIT dataUpdated(0); + + UpdatePreview(); +} + +bool SampleTexture::ComputePreview(QPixmap& pixmap) +{ + if (!m_currentTextureIndex || !m_uv) + return false; + + pixmap = QPixmap::fromImage(m_output->preview); + return true; +} + +void SampleTexture::BuildNodeEdition(QVBoxLayout* layout) +{ + ShaderNode::BuildNodeEdition(layout); + + QComboBox* textureSelection = new QComboBox; + connect(textureSelection, qOverload(&QComboBox::currentIndexChanged), [&](int index) + { + if (index >= 0) + m_currentTextureIndex = static_cast(index); + else + m_currentTextureIndex.reset(); + + UpdateOutput(); + }); + + for (const auto& textureEntry : GetGraph().GetTextures()) + textureSelection->addItem(QString::fromStdString(textureEntry.name)); + + layout->addWidget(textureSelection); } Nz::ShaderAst::ExpressionPtr SampleTexture::GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const { + if (!m_currentTextureIndex || !m_uv) + throw std::runtime_error("invalid inputs"); + assert(count == 1); - const auto& textureEntry = GetGraph().GetTexture(m_currentTextureIndex); + const auto& textureEntry = GetGraph().GetTexture(*m_currentTextureIndex); Nz::ShaderAst::ExpressionType expression = [&] { @@ -203,6 +202,9 @@ std::shared_ptr SampleTexture::outData(QtNodes::PortIndex por { assert(port == 0); + if (!m_currentTextureIndex) + return nullptr; + return m_output; } @@ -219,5 +221,5 @@ void SampleTexture::setInData(std::shared_ptr value, int inde else m_uv.reset(); - UpdatePreview(); + UpdateOutput(); } diff --git a/src/ShaderNode/DataModels/SampleTexture.hpp b/src/ShaderNode/DataModels/SampleTexture.hpp index 7697d296f..738047712 100644 --- a/src/ShaderNode/DataModels/SampleTexture.hpp +++ b/src/ShaderNode/DataModels/SampleTexture.hpp @@ -17,12 +17,13 @@ class SampleTexture : public ShaderNode SampleTexture(ShaderGraph& graph); ~SampleTexture() = default; + void BuildNodeEdition(QVBoxLayout* layout) override; + Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const override; QString caption() const override { return "Sample texture"; } QString name() const override { return "SampleTexture"; } - QWidget* embeddedWidget() override; unsigned int nPorts(QtNodes::PortType portType) const override; QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; @@ -36,21 +37,17 @@ class SampleTexture : public ShaderNode void setInData(std::shared_ptr value, int index) override; protected: - void ComputePreview(QPixmap& pixmap) const; - void UpdatePreview(); - void UpdateTextureList(); + bool ComputePreview(QPixmap& pixmap) override; + void OnTextureListUpdate(); + void UpdateOutput(); NazaraSlot(ShaderGraph, OnTextureListUpdate, m_onTextureListUpdateSlot); NazaraSlot(ShaderGraph, OnTexturePreviewUpdate, m_onTexturePreviewUpdateSlot); - std::size_t m_currentTextureIndex; + std::optional m_currentTextureIndex; std::shared_ptr m_uv; std::shared_ptr m_output; - QComboBox* m_textureSelection; - QLabel* m_pixmapLabel; - QPixmap m_pixmap; - QWidget* m_widget; - QVBoxLayout* m_layout; + std::string m_currentTextureText; }; #include diff --git a/src/ShaderNode/DataModels/ShaderNode.cpp b/src/ShaderNode/DataModels/ShaderNode.cpp index aeb143452..1221d1df6 100644 --- a/src/ShaderNode/DataModels/ShaderNode.cpp +++ b/src/ShaderNode/DataModels/ShaderNode.cpp @@ -1,5 +1,81 @@ #include +#include +#include +#include + +ShaderNode::ShaderNode(ShaderGraph& graph) : +m_previewSize(64, 64), +m_pixmapLabel(nullptr), +m_graph(graph), +m_isPreviewEnabled(false) +{ + m_pixmapLabel = new QLabel; + m_pixmapLabel->setStyleSheet("background-color: rgba(0,0,0,0)"); +} + +void ShaderNode::BuildNodeEdition(QVBoxLayout* layout) +{ + QCheckBox* checkbox = new QCheckBox(tr("Enable preview")); + checkbox->setCheckState((m_isPreviewEnabled) ? Qt::Checked : Qt::Unchecked); + + connect(checkbox, &QCheckBox::stateChanged, [&](int state) + { + EnablePreview(state == Qt::Checked); + }); + + layout->addWidget(checkbox); +} + +void ShaderNode::EnablePreview(bool enable) +{ + if (m_isPreviewEnabled != enable) + { + m_isPreviewEnabled = enable; + + if (m_isPreviewEnabled) + { + m_pixmap.emplace(m_previewSize.x, m_previewSize.y); + + UpdatePreview(); + } + else + { + m_pixmapLabel->clear(); + m_pixmap.reset(); + } + + embeddedWidgetSizeUpdated(); + } +} + +QWidget* ShaderNode::embeddedWidget() +{ + return m_pixmapLabel; +} void ShaderNode::setInData(std::shared_ptr, int) { } + +bool ShaderNode::ComputePreview(QPixmap& /*pixmap*/) +{ + return false; +} + +void ShaderNode::UpdatePreview() +{ + if (!m_pixmap) + return; + + QPixmap& pixmap = *m_pixmap; + + if (!ComputePreview(pixmap)) + { + pixmap = QPixmap(m_previewSize.x, m_previewSize.y); + pixmap.fill(QColor::fromRgb(255, 255, 255, 0)); + } + else + pixmap = pixmap.scaled(m_previewSize.x, m_previewSize.y); + + m_pixmapLabel->setPixmap(pixmap); +} diff --git a/src/ShaderNode/DataModels/ShaderNode.hpp b/src/ShaderNode/DataModels/ShaderNode.hpp index 3d73d7330..3cf16ea06 100644 --- a/src/ShaderNode/DataModels/ShaderNode.hpp +++ b/src/ShaderNode/DataModels/ShaderNode.hpp @@ -3,24 +3,46 @@ #ifndef NAZARA_SHADERNODES_SHADERNODE_HPP #define NAZARA_SHADERNODES_SHADERNODE_HPP +#include #include #include +#include +#include +class QLabel; +class QVBoxLayout; class ShaderGraph; class ShaderNode : public QtNodes::NodeDataModel { public: - inline ShaderNode(ShaderGraph& graph); + ShaderNode(ShaderGraph& graph); + + virtual void BuildNodeEdition(QVBoxLayout* layout); + + void EnablePreview(bool enable); virtual Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const = 0; inline ShaderGraph& GetGraph(); inline const ShaderGraph& GetGraph() const; + void SetPreviewSize(const Nz::Vector2i& size); + + QWidget* embeddedWidget() final; + void setInData(std::shared_ptr, int) override; + protected: + void UpdatePreview(); + private: + virtual bool ComputePreview(QPixmap& pixmap); + + Nz::Vector2i m_previewSize; + QLabel* m_pixmapLabel; + std::optional m_pixmap; ShaderGraph& m_graph; + bool m_isPreviewEnabled; }; #include diff --git a/src/ShaderNode/DataModels/ShaderNode.inl b/src/ShaderNode/DataModels/ShaderNode.inl index defa5aea1..7f80d00ff 100644 --- a/src/ShaderNode/DataModels/ShaderNode.inl +++ b/src/ShaderNode/DataModels/ShaderNode.inl @@ -1,9 +1,5 @@ #include -inline ShaderNode::ShaderNode(ShaderGraph& graph) : -m_graph(graph) -{ -} inline ShaderGraph& ShaderNode::GetGraph() { @@ -14,3 +10,10 @@ inline const ShaderGraph& ShaderNode::GetGraph() const { return m_graph; } + +inline void ShaderNode::SetPreviewSize(const Nz::Vector2i& size) +{ + m_previewSize = size; + if (m_isPreviewEnabled) + UpdatePreview(); +} diff --git a/src/ShaderNode/DataModels/VecBinOp.hpp b/src/ShaderNode/DataModels/VecBinOp.hpp index ef3ee4bca..e56c13461 100644 --- a/src/ShaderNode/DataModels/VecBinOp.hpp +++ b/src/ShaderNode/DataModels/VecBinOp.hpp @@ -15,7 +15,6 @@ class VecBinOp : public ShaderNode Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const override; - QWidget* embeddedWidget() override; unsigned int nPorts(QtNodes::PortType portType) const override; QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; @@ -26,10 +25,10 @@ class VecBinOp : public ShaderNode private: virtual void ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) = 0; - void UpdatePreview(); - QLabel* m_pixmapLabel; - QPixmap m_preview; + bool ComputePreview(QPixmap& pixmap) override; + void UpdateOutput(); + std::shared_ptr m_lhs; std::shared_ptr m_rhs; std::shared_ptr m_output; diff --git a/src/ShaderNode/DataModels/VecBinOp.inl b/src/ShaderNode/DataModels/VecBinOp.inl index 4159193fb..2d33f65c6 100644 --- a/src/ShaderNode/DataModels/VecBinOp.inl +++ b/src/ShaderNode/DataModels/VecBinOp.inl @@ -7,9 +7,7 @@ ShaderNode(graph) { m_output = std::make_shared(); - m_pixmapLabel = new QLabel; - m_pixmapLabel->setStyleSheet("background-color: rgba(0,0,0,0)"); - UpdatePreview(); + UpdateOutput(); } template @@ -21,12 +19,6 @@ Nz::ShaderAst::ExpressionPtr VecBinOp::GetExpression(Nz::ShaderAst: return builder(expressions[0], expressions[1]); } -template -QWidget* VecBinOp::embeddedWidget() -{ - return m_pixmapLabel; -} - template QtNodes::NodeDataType VecBinOp::dataType(QtNodes::PortType /*portType*/, QtNodes::PortIndex portIndex) const { @@ -72,42 +64,49 @@ void VecBinOp::setInData(std::shared_ptr value, else m_rhs = std::move(castedValue); - UpdatePreview(); - - Q_EMIT dataUpdated(0); + UpdateOutput(); } template -void VecBinOp::UpdatePreview() +bool VecBinOp::ComputePreview(QPixmap& pixmap) { - if (m_lhs && m_rhs) + if (!m_lhs || !m_rhs) + return false; + + pixmap = QPixmap::fromImage(m_output->preview); + return true; +} + +template +void VecBinOp::UpdateOutput() +{ + if (!m_lhs || !m_rhs) { - const QImage& leftPreview = m_lhs->preview; - const QImage& rightPreview = m_rhs->preview; - int maxWidth = std::max(leftPreview.width(), rightPreview.width()); - int maxHeight = std::max(leftPreview.height(), rightPreview.height()); - - // Exploit COW - QImage leftResized = leftPreview; - if (leftResized.width() != maxWidth || leftResized.height() != maxHeight) - leftResized = leftResized.scaled(maxWidth, maxHeight); - - QImage rightResized = rightPreview; - if (rightResized.width() != maxWidth || rightResized.height() != maxHeight) - rightResized = rightResized.scaled(maxWidth, maxHeight); - - m_output->preview = QImage(maxWidth, maxHeight, QImage::Format_RGBA8888); - ApplyOp(leftResized.constBits(), rightResized.constBits(), m_output->preview.bits(), maxWidth * maxHeight * 4); - - m_preview = QPixmap::fromImage(m_output->preview).scaled(64, 64); - } - else - { - m_preview = QPixmap(64, 64); - m_preview.fill(QColor::fromRgb(255, 255, 0, 0)); + m_output->preview = QImage(1, 1, QImage::Format_RGBA8888); + m_output->preview.fill(QColor::fromRgb(0, 0, 0, 0)); + return; } - m_pixmapLabel->setPixmap(m_preview); + const QImage& leftPreview = m_lhs->preview; + const QImage& rightPreview = m_rhs->preview; + int maxWidth = std::max(leftPreview.width(), rightPreview.width()); + int maxHeight = std::max(leftPreview.height(), rightPreview.height()); + + // Exploit COW + QImage leftResized = leftPreview; + if (leftResized.width() != maxWidth || leftResized.height() != maxHeight) + leftResized = leftResized.scaled(maxWidth, maxHeight); + + QImage rightResized = rightPreview; + if (rightResized.width() != maxWidth || rightResized.height() != maxHeight) + rightResized = rightResized.scaled(maxWidth, maxHeight); + + m_output->preview = QImage(maxWidth, maxHeight, QImage::Format_RGBA8888); + ApplyOp(leftResized.constBits(), rightResized.constBits(), m_output->preview.bits(), maxWidth * maxHeight * 4); + + Q_EMIT dataUpdated(0); + + UpdatePreview(); } template diff --git a/src/ShaderNode/DataModels/VecData.hpp b/src/ShaderNode/DataModels/VecData.hpp index 8a1b152f5..3882f20f1 100644 --- a/src/ShaderNode/DataModels/VecData.hpp +++ b/src/ShaderNode/DataModels/VecData.hpp @@ -62,6 +62,45 @@ struct Vec4Data : public VecData } }; +struct VecTypeDummy {}; + +template +struct VecTypeHelper; + +template<> +struct VecTypeHelper<0> +{ + using Type = VecTypeDummy; +}; + +template<> +struct VecTypeHelper<1> +{ + using Type = std::array; +}; + +template<> +struct VecTypeHelper<2> +{ + using Type = Nz::Vector2f; +}; + +template<> +struct VecTypeHelper<3> +{ + using Type = Nz::Vector3f; +}; + +template<> +struct VecTypeHelper<4> +{ + using Type = Nz::Vector4f; +}; + +template using VecType = typename VecTypeHelper::template Type; + +constexpr std::array s_vectorComponents = { 'X', 'Y', 'Z', 'W' }; + #include #endif diff --git a/src/ShaderNode/DataModels/VecValue.hpp b/src/ShaderNode/DataModels/VecValue.hpp index 7e8db4d88..27df2757f 100644 --- a/src/ShaderNode/DataModels/VecValue.hpp +++ b/src/ShaderNode/DataModels/VecValue.hpp @@ -11,29 +11,6 @@ #include #include -template -struct VecTypeHelper; - -template<> -struct VecTypeHelper<2> -{ - using Type = Nz::Vector2f; -}; - -template<> -struct VecTypeHelper<3> -{ - using Type = Nz::Vector3f; -}; - -template<> -struct VecTypeHelper<4> -{ - using Type = Nz::Vector4f; -}; - -template using VecType = typename VecTypeHelper::template Type; - template class VecValue : public ShaderNode { @@ -46,25 +23,22 @@ class VecValue : public ShaderNode QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; - QWidget* embeddedWidget() override; unsigned int nPorts(QtNodes::PortType portType) const override; std::shared_ptr outData(QtNodes::PortIndex port) override; + void BuildNodeEdition(QVBoxLayout* layout) override; + Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const override; - protected: + private: + bool ComputePreview(QPixmap& pixmap) override; + static constexpr std::size_t ComponentCount = Data::ComponentCount; QColor ToColor() const; - VecType ToVector() const; - void UpdatePreview(); - QLabel* m_pixmapLabel; - QPixmap m_pixmap; - QWidget* m_widget; - QFormLayout* m_layout; - std::array m_spinboxes; + VecType m_value; }; using Vec2Value = VecValue; diff --git a/src/ShaderNode/DataModels/VecValue.inl b/src/ShaderNode/DataModels/VecValue.inl index 45138b83f..8f9212631 100644 --- a/src/ShaderNode/DataModels/VecValue.inl +++ b/src/ShaderNode/DataModels/VecValue.inl @@ -8,37 +8,14 @@ template VecValue::VecValue(ShaderGraph& graph) : ShaderNode(graph) { - constexpr std::array componentName = { 'X', 'Y', 'Z', 'W' }; - static_assert(ComponentCount <= componentName.size()); + static_assert(ComponentCount <= s_vectorComponents.size()); + + std::array defaultValues; - m_layout = new QFormLayout; for (std::size_t i = 0; i < ComponentCount; ++i) - { - m_spinboxes[i] = new QDoubleSpinBox; - m_spinboxes[i]->setDecimals(6); - m_spinboxes[i]->setValue(1.0); - m_spinboxes[i]->setStyleSheet("background-color: rgba(255,255,255,255)"); - connect(m_spinboxes[i], qOverload(&QDoubleSpinBox::valueChanged), [this](double) - { - UpdatePreview(); + defaultValues[i] = (i == 3) ? 1.f : 0.f; - Q_EMIT dataUpdated(0); - }); - - m_layout->addRow(QString::fromUtf8(&componentName[i], 1), m_spinboxes[i]); - } - - m_pixmap = QPixmap(32, 32); - m_pixmap.fill(); - - m_pixmapLabel = new QLabel; - m_pixmapLabel->setPixmap(m_pixmap); - - m_layout->addWidget(m_pixmapLabel); - - m_widget = new QWidget; - m_widget->setStyleSheet("background-color: rgba(0,0,0,0)"); - m_widget->setLayout(m_layout); + m_value.Set(defaultValues.data()); UpdatePreview(); } @@ -66,12 +43,6 @@ QtNodes::NodeDataType VecValue::dataType(QtNodes::PortType portType, QtNod return Data::Type(); } -template -QWidget* VecValue::embeddedWidget() -{ - return m_widget; -} - template unsigned int VecValue::nPorts(QtNodes::PortType portType) const { @@ -96,12 +67,45 @@ std::shared_ptr VecValue::outData(QtNodes::PortIndex po return out; } +template +void VecValue::BuildNodeEdition(QVBoxLayout* layout) +{ + ShaderNode::BuildNodeEdition(layout); + + QFormLayout* formLayout = new QFormLayout; + for (std::size_t i = 0; i < ComponentCount; ++i) + { + QDoubleSpinBox* spinbox = new QDoubleSpinBox; + spinbox->setDecimals(6); + spinbox->setValue(m_value[i]); + + connect(spinbox, qOverload(&QDoubleSpinBox::valueChanged), [=](double) + { + m_value[i] = spinbox->value(); + Q_EMIT dataUpdated(0); + + UpdatePreview(); + }); + + formLayout->addRow(QString::fromUtf8(&s_vectorComponents[i], 1), spinbox); + } + + layout->addLayout(formLayout); +} + template Nz::ShaderAst::ExpressionPtr VecValue::GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const { assert(count == 0); - return Nz::ShaderBuilder::Constant(ToVector()); + return Nz::ShaderBuilder::Constant(m_value); +} + +template +bool VecValue::ComputePreview(QPixmap& pixmap) +{ + pixmap.fill(ToColor()); + return true; } template @@ -110,28 +114,7 @@ QColor VecValue::ToColor() const std::array values = { 0.f, 0.f, 0.f, 1.f }; for (std::size_t i = 0; i < ComponentCount; ++i) - values[i] = std::clamp(float(m_spinboxes[i]->value()), 0.f, 1.f); + values[i] = std::clamp(m_value[i], 0.f, 1.f); return QColor::fromRgbF(values[0], values[1], values[2], values[3]); } - -template -auto VecValue::ToVector() const -> VecType -{ - std::array values; - - for (std::size_t i = 0; i < ComponentCount; ++i) - values[i] = std::clamp(float(m_spinboxes[i]->value()), 0.f, 1.f); - - return std::apply([](auto... values) - { - return VecType(values...); - }, values); -} - -template -void VecValue::UpdatePreview() -{ - m_pixmap.fill(ToColor()); - m_pixmapLabel->setPixmap(m_pixmap); -} diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp index e29c0129f..bc9d643fd 100644 --- a/src/ShaderNode/ShaderGraph.cpp +++ b/src/ShaderNode/ShaderGraph.cpp @@ -29,6 +29,17 @@ namespace ShaderGraph::ShaderGraph() : m_flowScene(BuildRegistry()) { + m_previewModel = std::make_unique(); + + QObject::connect(&m_flowScene, &QGraphicsScene::selectionChanged, [&] + { + auto selectedNodes = m_flowScene.selectedNodes(); + if (selectedNodes.size() == 1) + OnSelectedNodeUpdate(this, static_cast(selectedNodes.front()->nodeDataModel())); + else + OnSelectedNodeUpdate(this, nullptr); + }); + auto& node1 = m_flowScene.createNode(std::make_unique(*this)); node1.nodeGraphicsObject().setPos(200, 200); @@ -36,8 +47,6 @@ m_flowScene(BuildRegistry()) node2.nodeGraphicsObject().setPos(500, 300); m_flowScene.createConnection(node2, 0, node1, 0); - - m_previewModel = std::make_unique(); } ShaderGraph::~ShaderGraph() diff --git a/src/ShaderNode/ShaderGraph.hpp b/src/ShaderNode/ShaderGraph.hpp index aa2188f16..3ed906edd 100644 --- a/src/ShaderNode/ShaderGraph.hpp +++ b/src/ShaderNode/ShaderGraph.hpp @@ -11,6 +11,8 @@ #include #include +class ShaderNode; + class ShaderGraph { public: @@ -52,6 +54,7 @@ class ShaderGraph NazaraSignal(OnInputListUpdate, ShaderGraph*); NazaraSignal(OnInputUpdate, ShaderGraph*, std::size_t /*inputIndex*/); + NazaraSignal(OnSelectedNodeUpdate, ShaderGraph*, ShaderNode* /*node*/); NazaraSignal(OnTextureListUpdate, ShaderGraph*); NazaraSignal(OnTexturePreviewUpdate, ShaderGraph*, std::size_t /*textureIndex*/); diff --git a/src/ShaderNode/Widgets/MainWindow.cpp b/src/ShaderNode/Widgets/MainWindow.cpp index 8aa48c353..580e5b506 100644 --- a/src/ShaderNode/Widgets/MainWindow.cpp +++ b/src/ShaderNode/Widgets/MainWindow.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -19,20 +20,44 @@ m_shaderGraph(graph) QtNodes::FlowView* flowView = new QtNodes::FlowView(scene); setCentralWidget(flowView); - QDockWidget* inputDock = new QDockWidget(tr("&Inputs")); - InputEditor* inputEditor = new InputEditor(m_shaderGraph); + + QDockWidget* inputDock = new QDockWidget(tr("Inputs")); + inputDock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable); inputDock->setWidget(inputEditor); addDockWidget(Qt::LeftDockWidgetArea, inputDock); - QDockWidget* textureDock = new QDockWidget(tr("&Textures")); - TextureEditor* textureEditor = new TextureEditor(m_shaderGraph); + + QDockWidget* textureDock = new QDockWidget(tr("Textures")); + textureDock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable); textureDock->setWidget(textureEditor); addDockWidget(Qt::LeftDockWidgetArea, textureDock); + m_nodeEditor = new NodeEditor; + + QDockWidget* nodeEditorDock = new QDockWidget(tr("Node editor")); + nodeEditorDock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable); + nodeEditorDock->setWidget(m_nodeEditor); + + addDockWidget(Qt::RightDockWidgetArea, nodeEditorDock); + + m_onSelectedNodeUpdate.Connect(m_shaderGraph.OnSelectedNodeUpdate, [&](ShaderGraph*, ShaderNode* node) + { + if (node) + { + m_nodeEditor->UpdateContent(node->caption(), [node](QVBoxLayout* layout) + { + node->BuildNodeEdition(layout); + }); + } + else + m_nodeEditor->Clear(); + }); + + BuildMenu(); } diff --git a/src/ShaderNode/Widgets/MainWindow.hpp b/src/ShaderNode/Widgets/MainWindow.hpp index 3e68ec267..777c3b92b 100644 --- a/src/ShaderNode/Widgets/MainWindow.hpp +++ b/src/ShaderNode/Widgets/MainWindow.hpp @@ -4,9 +4,10 @@ #define NAZARA_SHADERNODES_MAINWINDOW_HPP #include +#include #include -class ShaderGraph; +class NodeEditor; class MainWindow : public QMainWindow { @@ -18,6 +19,9 @@ class MainWindow : public QMainWindow void BuildMenu(); void OnCompileToGLSL(); + NazaraSlot(ShaderGraph, OnSelectedNodeUpdate, m_onSelectedNodeUpdate); + + NodeEditor* m_nodeEditor; ShaderGraph& m_shaderGraph; }; diff --git a/src/ShaderNode/Widgets/NodeEditor.cpp b/src/ShaderNode/Widgets/NodeEditor.cpp new file mode 100644 index 000000000..ee6b63e5a --- /dev/null +++ b/src/ShaderNode/Widgets/NodeEditor.cpp @@ -0,0 +1,20 @@ +#include +#include +#include + +NodeEditor::NodeEditor() : +m_layout(nullptr) +{ +} + +void NodeEditor::Clear() +{ + if (m_layout) + { + while (QWidget* w = findChild()) + delete w; + + delete m_layout; + m_layout = nullptr; + } +} diff --git a/src/ShaderNode/Widgets/NodeEditor.hpp b/src/ShaderNode/Widgets/NodeEditor.hpp new file mode 100644 index 000000000..65e73c107 --- /dev/null +++ b/src/ShaderNode/Widgets/NodeEditor.hpp @@ -0,0 +1,27 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_NODEEDITOR_HPP +#define NAZARA_SHADERNODES_NODEEDITOR_HPP + +#include +#include +#include +#include + +class NodeEditor : public QWidget +{ + public: + NodeEditor(); + ~NodeEditor() = default; + + void Clear(); + + template void UpdateContent(QString nodeName, F&& callback); + + private: + QVBoxLayout* m_layout; +}; + +#include + +#endif diff --git a/src/ShaderNode/Widgets/NodeEditor.inl b/src/ShaderNode/Widgets/NodeEditor.inl new file mode 100644 index 000000000..a7f916889 --- /dev/null +++ b/src/ShaderNode/Widgets/NodeEditor.inl @@ -0,0 +1,16 @@ +#include +#include + +template +void NodeEditor::UpdateContent(QString nodeName, F&& callback) +{ + Clear(); + + m_layout = new QVBoxLayout; + setLayout(m_layout); + + QLabel* label = new QLabel(nodeName); + m_layout->addWidget(label); + + callback(m_layout); +} From d96bc9db6e5531db5492d68f3a8fc34c0d0826a5 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 26 May 2020 20:30:24 +0200 Subject: [PATCH 208/316] ShaderNode: Add automatic variables --- include/Nazara/Renderer/ShaderAst.hpp | 13 +++- include/Nazara/Renderer/ShaderAst.inl | 7 +- include/Nazara/Renderer/ShaderBuilder.hpp | 2 +- include/Nazara/Renderer/ShaderBuilder.inl | 2 +- src/Nazara/Renderer/GlslWriter.cpp | 2 +- src/Nazara/Renderer/ShaderAst.cpp | 23 +++++- src/ShaderNode/DataModels/InputValue.cpp | 7 ++ src/ShaderNode/DataModels/SampleTexture.cpp | 9 +++ src/ShaderNode/ShaderGraph.cpp | 83 +++++++++++++++++++-- src/ShaderNode/ShaderGraph.hpp | 2 + src/ShaderNode/ShaderGraph.inl | 10 +++ src/ShaderNode/main.cpp | 2 - 12 files changed, 143 insertions(+), 19 deletions(-) diff --git a/include/Nazara/Renderer/ShaderAst.hpp b/include/Nazara/Renderer/ShaderAst.hpp index d6cc45789..dfe7639e4 100644 --- a/include/Nazara/Renderer/ShaderAst.hpp +++ b/include/Nazara/Renderer/ShaderAst.hpp @@ -40,6 +40,12 @@ namespace Nz VertexPosition, // gl_Position }; + enum class ExpressionCategory + { + LValue, + RValue + }; + enum class ExpressionType { Boolean, // bool @@ -104,6 +110,7 @@ namespace Nz class NAZARA_RENDERER_API Expression : public Node { public: + virtual ExpressionCategory GetExpressionCategory() const; virtual ExpressionType GetExpressionType() const = 0; }; @@ -152,6 +159,7 @@ namespace Nz public: inline Variable(VariableType varKind, ExpressionType varType); + ExpressionCategory GetExpressionCategory() const override; ExpressionType GetExpressionType() const override; ExpressionType type; @@ -191,14 +199,14 @@ namespace Nz class NAZARA_RENDERER_API AssignOp : public Expression { public: - inline AssignOp(AssignType Op, VariablePtr Var, ExpressionPtr Right); + inline AssignOp(AssignType Op, ExpressionPtr Left, ExpressionPtr Right); ExpressionType GetExpressionType() const override; void Register(ShaderWriter& visitor) override; void Visit(ShaderWriter& visitor) override; AssignType op; - VariablePtr variable; + ExpressionPtr left; ExpressionPtr right; }; @@ -277,6 +285,7 @@ namespace Nz public: inline SwizzleOp(ExpressionPtr expressionPtr, std::initializer_list swizzleComponents); + ExpressionCategory GetExpressionCategory() const override; ExpressionType GetExpressionType() const override; void Register(ShaderWriter& visitor) override; void Visit(ShaderWriter& visitor) override; diff --git a/include/Nazara/Renderer/ShaderAst.inl b/include/Nazara/Renderer/ShaderAst.inl index cb9024b48..b7d0a42d8 100644 --- a/include/Nazara/Renderer/ShaderAst.inl +++ b/include/Nazara/Renderer/ShaderAst.inl @@ -82,11 +82,14 @@ namespace Nz { } - inline AssignOp::AssignOp(AssignType Op, VariablePtr Var, ExpressionPtr Right) : + inline AssignOp::AssignOp(AssignType Op, ExpressionPtr Left, ExpressionPtr Right) : op(Op), - variable(std::move(Var)), + left(std::move(Left)), right(std::move(Right)) { + if (left->GetExpressionCategory() != ExpressionCategory::LValue) + //TODO: AstParseError + throw std::runtime_error("Assignation is only possible with lvalues"); } inline BinaryOp::BinaryOp(BinaryType Op, ExpressionPtr Left, ExpressionPtr Right) : diff --git a/include/Nazara/Renderer/ShaderBuilder.hpp b/include/Nazara/Renderer/ShaderBuilder.hpp index b0ba09cc4..b514b9c57 100644 --- a/include/Nazara/Renderer/ShaderBuilder.hpp +++ b/include/Nazara/Renderer/ShaderBuilder.hpp @@ -18,7 +18,7 @@ namespace Nz { namespace ShaderBuilder { constexpr AssignOpBuilder() {} - std::shared_ptr operator()(const ShaderAst::VariablePtr& left, const ShaderAst::ExpressionPtr& right) const; + std::shared_ptr operator()(const ShaderAst::ExpressionPtr& left, const ShaderAst::ExpressionPtr& right) const; }; template diff --git a/include/Nazara/Renderer/ShaderBuilder.inl b/include/Nazara/Renderer/ShaderBuilder.inl index 89fa14c35..772c56583 100644 --- a/include/Nazara/Renderer/ShaderBuilder.inl +++ b/include/Nazara/Renderer/ShaderBuilder.inl @@ -15,7 +15,7 @@ namespace Nz { namespace ShaderBuilder } template - std::shared_ptr AssignOpBuilder::operator()(const ShaderAst::VariablePtr& left, const ShaderAst::ExpressionPtr& right) const + std::shared_ptr AssignOpBuilder::operator()(const ShaderAst::ExpressionPtr& left, const ShaderAst::ExpressionPtr& right) const { return std::make_shared(op, left, right); } diff --git a/src/Nazara/Renderer/GlslWriter.cpp b/src/Nazara/Renderer/GlslWriter.cpp index 7cb734cc5..685fc64af 100644 --- a/src/Nazara/Renderer/GlslWriter.cpp +++ b/src/Nazara/Renderer/GlslWriter.cpp @@ -139,7 +139,7 @@ namespace Nz void GlslWriter::Write(const ShaderAst::AssignOp& node) { - Write(node.variable); + Write(node.left); switch (node.op) { diff --git a/src/Nazara/Renderer/ShaderAst.cpp b/src/Nazara/Renderer/ShaderAst.cpp index bb64f4475..96dd0c7f3 100644 --- a/src/Nazara/Renderer/ShaderAst.cpp +++ b/src/Nazara/Renderer/ShaderAst.cpp @@ -8,6 +8,11 @@ namespace Nz::ShaderAst { + ExpressionCategory Expression::GetExpressionCategory() const + { + return ExpressionCategory::RValue; + } + void ExpressionStatement::Register(ShaderWriter& visitor) { expression->Register(visitor); @@ -43,6 +48,10 @@ namespace Nz::ShaderAst visitor.Write(*this); } + ExpressionCategory Variable::GetExpressionCategory() const + { + return ExpressionCategory::LValue; + } ExpressionType Variable::GetExpressionType() const { @@ -60,7 +69,7 @@ namespace Nz::ShaderAst } - void BuiltinVariable::Register(ShaderWriter& visitor) + void BuiltinVariable::Register(ShaderWriter& /*visitor*/) { } @@ -72,12 +81,12 @@ namespace Nz::ShaderAst ExpressionType AssignOp::GetExpressionType() const { - return variable->GetExpressionType(); + return left->GetExpressionType(); } void AssignOp::Register(ShaderWriter& visitor) { - variable->Register(visitor); + left->Register(visitor); right->Register(visitor); } @@ -102,6 +111,7 @@ namespace Nz::ShaderAst case ShaderAst::BinaryType::Equality: exprType = ExpressionType::Boolean; + break; } NazaraAssert(exprType != ShaderAst::ExpressionType::Void, "Unhandled builtin"); @@ -178,7 +188,12 @@ namespace Nz::ShaderAst } - ExpressionType ShaderAst::SwizzleOp::GetExpressionType() const + ExpressionCategory SwizzleOp::GetExpressionCategory() const + { + return ExpressionCategory::LValue; + } + + ExpressionType SwizzleOp::GetExpressionType() const { return static_cast(UnderlyingCast(GetComponentType(expression->GetExpressionType())) + componentCount - 1); } diff --git a/src/ShaderNode/DataModels/InputValue.cpp b/src/ShaderNode/DataModels/InputValue.cpp index a6044a229..810c2862e 100644 --- a/src/ShaderNode/DataModels/InputValue.cpp +++ b/src/ShaderNode/DataModels/InputValue.cpp @@ -13,6 +13,13 @@ ShaderNode(graph) UpdatePreview(); }); + if (graph.GetInputCount() > 0) + { + auto& firstInput = graph.GetInput(0); + m_currentInputIndex = 0; + m_currentInputText = firstInput.name; + } + UpdatePreview(); } diff --git a/src/ShaderNode/DataModels/SampleTexture.cpp b/src/ShaderNode/DataModels/SampleTexture.cpp index f299b6009..7209a69b5 100644 --- a/src/ShaderNode/DataModels/SampleTexture.cpp +++ b/src/ShaderNode/DataModels/SampleTexture.cpp @@ -14,6 +14,15 @@ ShaderNode(graph) if (m_currentTextureIndex == textureIndex) UpdatePreview(); }); + + if (graph.GetTextureCount() > 0) + { + auto& firstInput = graph.GetTexture(0); + m_currentTextureIndex = 0; + m_currentTextureText = firstInput.name; + } + + UpdateOutput(); } unsigned int SampleTexture::nPorts(QtNodes::PortType portType) const diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp index bc9d643fd..5bdfe0284 100644 --- a/src/ShaderNode/ShaderGraph.cpp +++ b/src/ShaderNode/ShaderGraph.cpp @@ -40,13 +40,28 @@ m_flowScene(BuildRegistry()) OnSelectedNodeUpdate(this, nullptr); }); - auto& node1 = m_flowScene.createNode(std::make_unique(*this)); - node1.nodeGraphicsObject().setPos(200, 200); + // Test + AddInput("UV", InputType::Float2, InputRole::TexCoord, 0); + AddTexture("Potato", TextureType::Sampler2D); - auto& node2 = m_flowScene.createNode(std::make_unique(*this)); - node2.nodeGraphicsObject().setPos(500, 300); + UpdateTexturePreview(0, QImage(R"(C:\Users\Lynix\Pictures\potatavril.png)")); + + auto& node1 = m_flowScene.createNode(std::make_unique(*this)); + node1.nodeGraphicsObject().setPos(0, 200); + + auto& node2 = m_flowScene.createNode(std::make_unique(*this)); + node2.nodeGraphicsObject().setPos(200, 200); + + auto& node3 = m_flowScene.createNode(std::make_unique(*this)); + node3.nodeGraphicsObject().setPos(400, 200); + + auto& node4 = m_flowScene.createNode(std::make_unique(*this)); + node4.nodeGraphicsObject().setPos(600, 300); m_flowScene.createConnection(node2, 0, node1, 0); + m_flowScene.createConnection(node3, 0, node2, 0); + m_flowScene.createConnection(node3, 1, node2, 0); + m_flowScene.createConnection(node4, 0, node3, 0); } ShaderGraph::~ShaderGraph() @@ -83,13 +98,51 @@ std::size_t ShaderGraph::AddTexture(std::string name, TextureType type) Nz::ShaderAst::StatementPtr ShaderGraph::ToAst() { std::vector statements; + QHash usageCount; + + unsigned int varCount = 0; + + std::function DetectVariables; + DetectVariables = [&](QtNodes::Node* node) + { + ShaderNode* shaderNode = static_cast(node->nodeDataModel()); + + qDebug() << shaderNode->name() << node->id(); + auto it = usageCount.find(node->id()); + if (it == usageCount.end()) + it = usageCount.insert(node->id(), 0); + + (*it)++; + + for (const auto& connectionSet : node->nodeState().getEntries(QtNodes::PortType::In)) + { + for (const auto& [uuid, conn] : connectionSet) + { + DetectVariables(conn->getNode(QtNodes::PortType::Out)); + } + } + }; + + m_flowScene.iterateOverNodes([&](QtNodes::Node* node) + { + if (node->nodeDataModel()->nPorts(QtNodes::PortType::Out) == 0) + DetectVariables(node); + }); + + QHash variableExpressions; std::function HandleNode; HandleNode = [&](QtNodes::Node* node) -> Nz::ShaderAst::ExpressionPtr { ShaderNode* shaderNode = static_cast(node->nodeDataModel()); - qDebug() << shaderNode->name(); + qDebug() << shaderNode->name() << node->id(); + if (auto it = variableExpressions.find(node->id()); it != variableExpressions.end()) + return *it; + + auto it = usageCount.find(node->id()); + assert(it != usageCount.end()); + std::size_t inputCount = shaderNode->nPorts(QtNodes::PortType::In); Nz::StackArray expressions = NazaraStackArray(Nz::ShaderAst::ExpressionPtr, inputCount); std::size_t i = 0; @@ -104,7 +157,25 @@ Nz::ShaderAst::StatementPtr ShaderGraph::ToAst() } } - return shaderNode->GetExpression(expressions.data(), expressions.size()); + auto expression = shaderNode->GetExpression(expressions.data(), expressions.size()); + + if (*it > 1) + { + Nz::ShaderAst::ExpressionPtr varExpression; + if (expression->GetExpressionCategory() == Nz::ShaderAst::ExpressionCategory::RValue) + { + varExpression = Nz::ShaderBuilder::Variable("var" + std::to_string(varCount++), expression->GetExpressionType()); + statements.emplace_back(Nz::ShaderBuilder::ExprStatement(Nz::ShaderBuilder::Assign(varExpression, expression))); + } + else + varExpression = expression; + + variableExpressions.insert(node->id(), varExpression); + + return varExpression; + } + else + return expression; }; m_flowScene.iterateOverNodes([&](QtNodes::Node* node) diff --git a/src/ShaderNode/ShaderGraph.hpp b/src/ShaderNode/ShaderGraph.hpp index 3ed906edd..ca29ff174 100644 --- a/src/ShaderNode/ShaderGraph.hpp +++ b/src/ShaderNode/ShaderGraph.hpp @@ -26,10 +26,12 @@ class ShaderGraph std::size_t AddTexture(std::string name, TextureType type); inline const InputEntry& GetInput(std::size_t inputIndex) const; + inline std::size_t GetInputCount() const; inline const std::vector& GetInputs() const; inline const PreviewModel& GetPreviewModel() const; inline QtNodes::FlowScene& GetScene(); inline const TextureEntry& GetTexture(std::size_t textureIndex) const; + inline std::size_t GetTextureCount() const; inline const std::vector& GetTextures() const; Nz::ShaderAst::StatementPtr ToAst(); diff --git a/src/ShaderNode/ShaderGraph.inl b/src/ShaderNode/ShaderGraph.inl index 100cd822e..97184906e 100644 --- a/src/ShaderNode/ShaderGraph.inl +++ b/src/ShaderNode/ShaderGraph.inl @@ -6,6 +6,11 @@ inline auto ShaderGraph::GetInput(std::size_t inputIndex) const -> const InputEn return m_inputs[inputIndex]; } +inline std::size_t ShaderGraph::GetInputCount() const +{ + return m_inputs.size(); +} + inline auto ShaderGraph::GetInputs() const -> const std::vector& { return m_inputs; @@ -27,6 +32,11 @@ inline auto ShaderGraph::GetTexture(std::size_t textureIndex) const -> const Tex return m_textures[textureIndex]; } +inline std::size_t ShaderGraph::GetTextureCount() const +{ + return m_textures.size(); +} + inline auto ShaderGraph::GetTextures() const -> const std::vector& { return m_textures; diff --git a/src/ShaderNode/main.cpp b/src/ShaderNode/main.cpp index a939e708a..8cea2a20f 100644 --- a/src/ShaderNode/main.cpp +++ b/src/ShaderNode/main.cpp @@ -8,8 +8,6 @@ int main(int argc, char* argv[]) QApplication app(argc, argv); ShaderGraph shaderGraph; - shaderGraph.AddInput("UV", InputType::Float2, InputRole::TexCoord, 0); - shaderGraph.AddTexture("Potato", TextureType::Sampler2D); MainWindow mainWindow(shaderGraph); mainWindow.resize(1280, 720); From 1d033aabfd2fdfc8d0a7a5bf7d4e2eeb585e98ff Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 27 May 2020 10:00:52 +0200 Subject: [PATCH 209/316] ShaderNode: Fix useless variables generation --- src/ShaderNode/ShaderGraph.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp index 5bdfe0284..6abfe5379 100644 --- a/src/ShaderNode/ShaderGraph.cpp +++ b/src/ShaderNode/ShaderGraph.cpp @@ -110,17 +110,19 @@ Nz::ShaderAst::StatementPtr ShaderGraph::ToAst() qDebug() << shaderNode->name() << node->id(); auto it = usageCount.find(node->id()); if (it == usageCount.end()) + { + for (const auto& connectionSet : node->nodeState().getEntries(QtNodes::PortType::In)) + { + for (const auto& [uuid, conn] : connectionSet) + { + DetectVariables(conn->getNode(QtNodes::PortType::Out)); + } + } + it = usageCount.insert(node->id(), 0); + } (*it)++; - - for (const auto& connectionSet : node->nodeState().getEntries(QtNodes::PortType::In)) - { - for (const auto& [uuid, conn] : connectionSet) - { - DetectVariables(conn->getNode(QtNodes::PortType::Out)); - } - } }; m_flowScene.iterateOverNodes([&](QtNodes::Node* node) From 7d23cafa356ac02a7f38231ec315fb360f11d025 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 27 May 2020 16:58:02 +0200 Subject: [PATCH 210/316] Merge fixes --- .../NDK/Widgets/AbstractTextAreaWidget.cpp | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/SDK/src/NDK/Widgets/AbstractTextAreaWidget.cpp b/SDK/src/NDK/Widgets/AbstractTextAreaWidget.cpp index ddb3467f5..78df17c6f 100644 --- a/SDK/src/NDK/Widgets/AbstractTextAreaWidget.cpp +++ b/SDK/src/NDK/Widgets/AbstractTextAreaWidget.cpp @@ -151,9 +151,9 @@ namespace Ndk { const Nz::AbstractTextDrawer& textDrawer = GetTextDrawer(); - switch (key.code) + switch (key.virtualKey) { - case Nz::Keyboard::Backspace: + case Nz::Keyboard::VKey::Backspace: { bool ignoreDefaultAction = false; OnTextAreaKeyBackspace(this, &ignoreDefaultAction); @@ -175,7 +175,7 @@ namespace Ndk return true; } - case Nz::Keyboard::Delete: + case Nz::Keyboard::VKey::Delete: { if (HasSelection()) EraseSelection(); @@ -185,7 +185,7 @@ namespace Ndk return true; } - case Nz::Keyboard::Down: + case Nz::Keyboard::VKey::Down: { bool ignoreDefaultAction = false; OnTextAreaKeyDown(this, &ignoreDefaultAction); @@ -200,7 +200,7 @@ namespace Ndk return true; } - case Nz::Keyboard::End: + case Nz::Keyboard::VKey::End: { bool ignoreDefaultAction = false; OnTextAreaKeyEnd(this, &ignoreDefaultAction); @@ -217,7 +217,7 @@ namespace Ndk return true; } - case Nz::Keyboard::Home: + case Nz::Keyboard::VKey::Home: { bool ignoreDefaultAction = false; OnTextAreaKeyHome(this, &ignoreDefaultAction); @@ -229,7 +229,7 @@ namespace Ndk return true; } - case Nz::Keyboard::Left: + case Nz::Keyboard::VKey::Left: { bool ignoreDefaultAction = false; OnTextAreaKeyLeft(this, &ignoreDefaultAction); @@ -247,7 +247,7 @@ namespace Ndk return true; } - case Nz::Keyboard::Return: + case Nz::Keyboard::VKey::Return: { bool ignoreDefaultAction = false; OnTextAreaKeyReturn(this, &ignoreDefaultAction); @@ -265,7 +265,7 @@ namespace Ndk return true;; } - case Nz::Keyboard::Right: + case Nz::Keyboard::VKey::Right: { bool ignoreDefaultAction = false; OnTextAreaKeyRight(this, &ignoreDefaultAction); @@ -283,7 +283,7 @@ namespace Ndk return true; } - case Nz::Keyboard::Up: + case Nz::Keyboard::VKey::Up: { bool ignoreDefaultAction = false; OnTextAreaKeyUp(this, &ignoreDefaultAction); @@ -298,7 +298,7 @@ namespace Ndk return true; } - case Nz::Keyboard::Tab: + case Nz::Keyboard::VKey::Tab: { if (!m_tabEnabled) return false; @@ -331,7 +331,7 @@ namespace Ndk Nz::Vector2ui hoveredGlyph = GetHoveredGlyph(float(x), float(y)); // Shift extends selection - if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::LShift) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::RShift)) + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::LShift) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::RShift)) SetSelection(hoveredGlyph, m_selectionCursor); else { From 71c11c5d6f67d9b5f3660e93503def8b44e62780 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 27 May 2020 16:58:21 +0200 Subject: [PATCH 211/316] Add PlatformSDL2_Path config --- build/config.lua | 3 ++- build/scripts/modules/platform.lua | 11 +++++++++++ build/scripts/modules/renderer.lua | 11 +++++++++++ examples/HardwareInfo/build.lua | 5 ++++- 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/build/config.lua b/build/config.lua index fa14d9a90..6589eb3b7 100644 --- a/build/config.lua +++ b/build/config.lua @@ -26,4 +26,5 @@ ServerMode = false UniteModules = false -- Use SDL2 platform -PlatformSDL2 = true \ No newline at end of file +PlatformSDL2 = true +PlatformSDL2_Path = "../../SDL2" \ No newline at end of file diff --git a/build/scripts/modules/platform.lua b/build/scripts/modules/platform.lua index d6201c526..2f5cfb1be 100644 --- a/build/scripts/modules/platform.lua +++ b/build/scripts/modules/platform.lua @@ -15,6 +15,17 @@ if (Config.PlatformSDL2) then table.insert(MODULE.Libraries, "SDL2") + assert(Config.PlatformSDL2_Path) + MODULE.Includes = Config.PlatformSDL2_Path .. "/include" + MODULE.LibraryPaths.x64 = { + Config.PlatformSDL2_Path .. "/lib/x64/", + Config.PlatformSDL2_Path .. "/bin/x64/" + } + MODULE.LibraryPaths.x86 = { + Config.PlatformSDL2_Path .. "/lib/x86/", + Config.PlatformSDL2_Path .. "/bin/x86/" + } + MODULE.FilesExcluded = { "../src/Nazara/Platform/Win32/**", "../src/Nazara/Platform/X11/**" diff --git a/build/scripts/modules/renderer.lua b/build/scripts/modules/renderer.lua index c9f65526f..b28a268ad 100644 --- a/build/scripts/modules/renderer.lua +++ b/build/scripts/modules/renderer.lua @@ -20,6 +20,17 @@ if (Config.PlatformSDL2) then table.insert(MODULE.Libraries, "SDL2") + assert(Config.PlatformSDL2_Path) + MODULE.Includes = Config.PlatformSDL2_Path .. "/include" + MODULE.LibraryPaths.x64 = { + Config.PlatformSDL2_Path .. "/lib/x64/", + Config.PlatformSDL2_Path .. "/bin/x64/" + } + MODULE.LibraryPaths.x86 = { + Config.PlatformSDL2_Path .. "/lib/x86/", + Config.PlatformSDL2_Path .. "/bin/x86/" + } + MODULE.FilesExcluded = { "../src/Nazara/Renderer/Win32/**", "../src/Nazara/Renderer/GLX/**.cpp" diff --git a/examples/HardwareInfo/build.lua b/examples/HardwareInfo/build.lua index c0917e765..6f49557d7 100644 --- a/examples/HardwareInfo/build.lua +++ b/examples/HardwareInfo/build.lua @@ -17,6 +17,9 @@ EXAMPLE.Libraries = { "NazaraUtility" } -if Config.PlatformSDL2 then +if (Config.PlatformSDL2) then table.insert(EXAMPLE.Defines, "NAZARA_PLATFORM_SDL2") + + assert(Config.PlatformSDL2_Path) + EXAMPLE.Includes = Config.PlatformSDL2_Path .. "/include" end From c071f52d8f8a46f8308e6bbcfecfe91e80d89355 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 27 May 2020 17:08:49 +0200 Subject: [PATCH 212/316] Platform/Mouse: Add SetRelativeMouseMode --- examples/FirstScene/main.cpp | 7 ++----- include/Nazara/Platform/Mouse.hpp | 1 + src/Nazara/Platform/Mouse.cpp | 5 +++++ src/Nazara/Platform/SDL2/InputImpl.cpp | 5 +++++ src/Nazara/Platform/SDL2/InputImpl.hpp | 1 + 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/examples/FirstScene/main.cpp b/examples/FirstScene/main.cpp index f67a79f58..25a96ceca 100644 --- a/examples/FirstScene/main.cpp +++ b/examples/FirstScene/main.cpp @@ -272,6 +272,8 @@ int main() //Gestion des Evenements Nz::EventHandler& eventHandler = window.GetEventHandler(); + Nz::Mouse::SetRelativeMouseMode(true); + eventHandler.OnMouseMoved.Connect([&camAngles, &cameraNode, &window](const Nz::EventHandler*, const Nz::WindowEvent::MouseMoveEvent& event) { if (Ndk::Application::Instance()->IsConsoleEnabled()) @@ -291,11 +293,6 @@ int main() // On applique les angles d'Euler à notre caméra cameraNode.SetRotation(camAngles); - - // Pour éviter que le curseur ne sorte de l'écran, nous le renvoyons au centre de la fenétre - // Cette fonction est codée de sorte à ne pas provoquer d'événement MouseMoved - Nz::Vector2ui size = window.GetSize(); - Nz::Mouse::SetPosition(size.x / 2, size.y / 2, window); }); eventHandler.OnKeyPressed.Connect([&targetPos, &cameraNode, &smoothMovement, &window](const Nz::EventHandler*, const Nz::WindowEvent::KeyEvent& event) diff --git a/include/Nazara/Platform/Mouse.hpp b/include/Nazara/Platform/Mouse.hpp index 9a77179f9..70234cd8b 100644 --- a/include/Nazara/Platform/Mouse.hpp +++ b/include/Nazara/Platform/Mouse.hpp @@ -37,6 +37,7 @@ namespace Nz static Vector2i GetPosition(); static Vector2i GetPosition(const Window& relativeTo); static bool IsButtonPressed(Button button); + static bool SetRelativeMouseMode(bool relativeMouseMode); static void SetPosition(const Vector2i& position); static void SetPosition(const Vector2i& position, const Window& relativeTo, bool ignoreEvent = true); static void SetPosition(int x, int y); diff --git a/src/Nazara/Platform/Mouse.cpp b/src/Nazara/Platform/Mouse.cpp index e9b55031a..d79cea389 100644 --- a/src/Nazara/Platform/Mouse.cpp +++ b/src/Nazara/Platform/Mouse.cpp @@ -34,6 +34,11 @@ namespace Nz return EventImpl::IsMouseButtonPressed(button); } + bool Mouse::SetRelativeMouseMode(bool relativeMouseMode) + { + return EventImpl::SetRelativeMouseMode(relativeMouseMode); + } + void Mouse::SetPosition(const Vector2i& position) { EventImpl::SetMousePosition(position.x, position.y); diff --git a/src/Nazara/Platform/SDL2/InputImpl.cpp b/src/Nazara/Platform/SDL2/InputImpl.cpp index 9bf2fd40f..6363fbd54 100644 --- a/src/Nazara/Platform/SDL2/InputImpl.cpp +++ b/src/Nazara/Platform/SDL2/InputImpl.cpp @@ -85,6 +85,11 @@ namespace Nz return (SDL_GetGlobalMouseState(nullptr, nullptr) & vButtons[button]) != 0; } + bool EventImpl::SetRelativeMouseMode(bool relativeMouseMode) + { + return SDL_SetRelativeMouseMode((relativeMouseMode) ? SDL_TRUE : SDL_FALSE) == 0; + } + void EventImpl::SetMousePosition(int x, int y) { if (SDL_WarpMouseGlobal(x, y) != 0) diff --git a/src/Nazara/Platform/SDL2/InputImpl.hpp b/src/Nazara/Platform/SDL2/InputImpl.hpp index 568acb755..20147f602 100644 --- a/src/Nazara/Platform/SDL2/InputImpl.hpp +++ b/src/Nazara/Platform/SDL2/InputImpl.hpp @@ -24,6 +24,7 @@ namespace Nz static bool IsKeyPressed(Keyboard::Scancode key); static bool IsKeyPressed(Keyboard::VKey key); static bool IsMouseButtonPressed(Mouse::Button button); + static bool SetRelativeMouseMode(bool relativeMouseMode); static void SetMousePosition(int x, int y); static void SetMousePosition(int x, int y, const Window& relativeTo); static void StartTextInput(); From b0c72a6101afff92bf86a319ed050e0751bdd6eb Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 27 May 2020 17:47:52 +0200 Subject: [PATCH 213/316] Replace platform backends by SDL --- Dockerfile | 2 +- build/config.lua | 4 - build/scripts/modules/platform.lua | 62 +- build/scripts/modules/renderer.lua | 52 +- examples/HardwareInfo/build.lua | 7 - include/Nazara/Platform/WindowHandle.hpp | 14 - include/Nazara/Prerequisites.hpp | 5 - include/Nazara/Renderer/OpenGL.hpp | 27 - src/Nazara/Platform/Cursor.cpp | 12 +- src/Nazara/Platform/Icon.cpp | 12 +- src/Nazara/Platform/Keyboard.cpp | 12 +- src/Nazara/Platform/Mouse.cpp | 12 +- src/Nazara/Platform/VideoMode.cpp | 12 +- src/Nazara/Platform/Win32/CursorImpl.cpp | 106 - src/Nazara/Platform/Win32/CursorImpl.hpp | 42 - src/Nazara/Platform/Win32/IconImpl.cpp | 53 - src/Nazara/Platform/Win32/IconImpl.hpp | 30 - src/Nazara/Platform/Win32/InputImpl.cpp | 298 - src/Nazara/Platform/Win32/InputImpl.hpp | 30 - src/Nazara/Platform/Win32/VideoModeImpl.cpp | 35 - src/Nazara/Platform/Win32/VideoModeImpl.hpp | 22 - src/Nazara/Platform/Win32/WindowImpl.cpp | 1225 -- src/Nazara/Platform/Win32/WindowImpl.hpp | 116 - src/Nazara/Platform/Window.cpp | 10 - src/Nazara/Platform/X11/CursorImpl.cpp | 270 - src/Nazara/Platform/X11/CursorImpl.hpp | 43 - src/Nazara/Platform/X11/Display.cpp | 247 - src/Nazara/Platform/X11/Display.hpp | 54 - src/Nazara/Platform/X11/IconImpl.cpp | 136 - src/Nazara/Platform/X11/IconImpl.hpp | 34 - src/Nazara/Platform/X11/InputImpl.cpp | 393 - src/Nazara/Platform/X11/InputImpl.hpp | 31 - src/Nazara/Platform/X11/ScopedXCB.cpp | 199 - src/Nazara/Platform/X11/ScopedXCB.hpp | 101 - src/Nazara/Platform/X11/ScopedXCB.inl | 46 - src/Nazara/Platform/X11/VideoModeImpl.cpp | 170 - src/Nazara/Platform/X11/VideoModeImpl.hpp | 23 - src/Nazara/Platform/X11/WindowImpl.cpp | 1589 --- src/Nazara/Platform/X11/WindowImpl.hpp | 127 - src/Nazara/Renderer/Context.cpp | 13 +- src/Nazara/Renderer/GLX/ContextImpl.cpp | 300 - src/Nazara/Renderer/GLX/ContextImpl.hpp | 42 - src/Nazara/Renderer/OpenGL.cpp | 92 - src/Nazara/Renderer/Win32/ContextImpl.cpp | 248 - src/Nazara/Renderer/Win32/ContextImpl.hpp | 41 - thirdparty/include/SDL2/SDL.h | 136 + thirdparty/include/SDL2/SDL_assert.h | 291 + thirdparty/include/SDL2/SDL_atomic.h | 295 + thirdparty/include/SDL2/SDL_audio.h | 859 ++ thirdparty/include/SDL2/SDL_bits.h | 121 + thirdparty/include/SDL2/SDL_blendmode.h | 123 + thirdparty/include/SDL2/SDL_clipboard.h | 71 + thirdparty/include/SDL2/SDL_config.h | 260 + thirdparty/include/SDL2/SDL_config.h.cmake | 445 + thirdparty/include/SDL2/SDL_config.h.in | 389 + thirdparty/include/SDL2/SDL_config_android.h | 157 + thirdparty/include/SDL2/SDL_config_iphoneos.h | 166 + thirdparty/include/SDL2/SDL_config_macosx.h | 197 + .../include/SDL2/SDL_config_macosx.h.orig | 197 + thirdparty/include/SDL2/SDL_config_minimal.h | 82 + thirdparty/include/SDL2/SDL_config_pandora.h | 128 + thirdparty/include/SDL2/SDL_config_psp.h | 144 + thirdparty/include/SDL2/SDL_config_windows.h | 225 + thirdparty/include/SDL2/SDL_config_winrt.h | 215 + thirdparty/include/SDL2/SDL_config_wiz.h | 121 + thirdparty/include/SDL2/SDL_copying.h | 20 + thirdparty/include/SDL2/SDL_cpuinfo.h | 275 + thirdparty/include/SDL2/SDL_egl.h | 1676 +++ thirdparty/include/SDL2/SDL_endian.h | 263 + thirdparty/include/SDL2/SDL_error.h | 76 + thirdparty/include/SDL2/SDL_events.h | 792 ++ thirdparty/include/SDL2/SDL_filesystem.h | 136 + thirdparty/include/SDL2/SDL_gamecontroller.h | 420 + thirdparty/include/SDL2/SDL_gesture.h | 87 + thirdparty/include/SDL2/SDL_haptic.h | 1238 ++ thirdparty/include/SDL2/SDL_hints.h | 1364 ++ thirdparty/include/SDL2/SDL_joystick.h | 418 + thirdparty/include/SDL2/SDL_keyboard.h | 217 + thirdparty/include/SDL2/SDL_keycode.h | 349 + thirdparty/include/SDL2/SDL_loadso.h | 81 + thirdparty/include/SDL2/SDL_log.h | 211 + thirdparty/include/SDL2/SDL_main.h | 180 + thirdparty/include/SDL2/SDL_messagebox.h | 146 + thirdparty/include/SDL2/SDL_metal.h | 91 + thirdparty/include/SDL2/SDL_mouse.h | 302 + thirdparty/include/SDL2/SDL_mutex.h | 251 + thirdparty/include/SDL2/SDL_name.h | 33 + thirdparty/include/SDL2/SDL_opengl.h | 2183 +++ thirdparty/include/SDL2/SDL_opengl_glext.h | 11180 ++++++++++++++++ thirdparty/include/SDL2/SDL_opengles.h | 39 + thirdparty/include/SDL2/SDL_opengles2.h | 52 + thirdparty/include/SDL2/SDL_opengles2_gl2.h | 621 + .../include/SDL2/SDL_opengles2_gl2ext.h | 2050 +++ .../include/SDL2/SDL_opengles2_gl2platform.h | 30 + .../include/SDL2/SDL_opengles2_khrplatform.h | 282 + thirdparty/include/SDL2/SDL_pixels.h | 473 + thirdparty/include/SDL2/SDL_platform.h | 198 + thirdparty/include/SDL2/SDL_power.h | 75 + thirdparty/include/SDL2/SDL_quit.h | 58 + thirdparty/include/SDL2/SDL_rect.h | 174 + thirdparty/include/SDL2/SDL_render.h | 1158 ++ thirdparty/include/SDL2/SDL_revision.h | 2 + thirdparty/include/SDL2/SDL_rwops.h | 291 + thirdparty/include/SDL2/SDL_scancode.h | 413 + thirdparty/include/SDL2/SDL_sensor.h | 251 + thirdparty/include/SDL2/SDL_shape.h | 144 + thirdparty/include/SDL2/SDL_stdinc.h | 617 + thirdparty/include/SDL2/SDL_surface.h | 554 + thirdparty/include/SDL2/SDL_system.h | 316 + thirdparty/include/SDL2/SDL_syswm.h | 331 + thirdparty/include/SDL2/SDL_test.h | 69 + thirdparty/include/SDL2/SDL_test_assert.h | 105 + thirdparty/include/SDL2/SDL_test_common.h | 218 + thirdparty/include/SDL2/SDL_test_compare.h | 69 + thirdparty/include/SDL2/SDL_test_crc32.h | 124 + thirdparty/include/SDL2/SDL_test_font.h | 81 + thirdparty/include/SDL2/SDL_test_fuzzer.h | 384 + thirdparty/include/SDL2/SDL_test_harness.h | 134 + thirdparty/include/SDL2/SDL_test_images.h | 78 + thirdparty/include/SDL2/SDL_test_log.h | 67 + thirdparty/include/SDL2/SDL_test_md5.h | 129 + thirdparty/include/SDL2/SDL_test_memory.h | 63 + thirdparty/include/SDL2/SDL_test_random.h | 115 + thirdparty/include/SDL2/SDL_thread.h | 361 + thirdparty/include/SDL2/SDL_timer.h | 115 + thirdparty/include/SDL2/SDL_touch.h | 102 + thirdparty/include/SDL2/SDL_types.h | 29 + thirdparty/include/SDL2/SDL_version.h | 162 + thirdparty/include/SDL2/SDL_video.h | 1275 ++ thirdparty/include/SDL2/SDL_vulkan.h | 278 + thirdparty/include/SDL2/begin_code.h | 170 + thirdparty/include/SDL2/close_code.h | 40 + 132 files changed, 38933 insertions(+), 6374 deletions(-) delete mode 100644 src/Nazara/Platform/Win32/CursorImpl.cpp delete mode 100644 src/Nazara/Platform/Win32/CursorImpl.hpp delete mode 100644 src/Nazara/Platform/Win32/IconImpl.cpp delete mode 100644 src/Nazara/Platform/Win32/IconImpl.hpp delete mode 100644 src/Nazara/Platform/Win32/InputImpl.cpp delete mode 100644 src/Nazara/Platform/Win32/InputImpl.hpp delete mode 100644 src/Nazara/Platform/Win32/VideoModeImpl.cpp delete mode 100644 src/Nazara/Platform/Win32/VideoModeImpl.hpp delete mode 100644 src/Nazara/Platform/Win32/WindowImpl.cpp delete mode 100644 src/Nazara/Platform/Win32/WindowImpl.hpp delete mode 100644 src/Nazara/Platform/X11/CursorImpl.cpp delete mode 100644 src/Nazara/Platform/X11/CursorImpl.hpp delete mode 100644 src/Nazara/Platform/X11/Display.cpp delete mode 100644 src/Nazara/Platform/X11/Display.hpp delete mode 100644 src/Nazara/Platform/X11/IconImpl.cpp delete mode 100644 src/Nazara/Platform/X11/IconImpl.hpp delete mode 100644 src/Nazara/Platform/X11/InputImpl.cpp delete mode 100644 src/Nazara/Platform/X11/InputImpl.hpp delete mode 100644 src/Nazara/Platform/X11/ScopedXCB.cpp delete mode 100644 src/Nazara/Platform/X11/ScopedXCB.hpp delete mode 100644 src/Nazara/Platform/X11/ScopedXCB.inl delete mode 100644 src/Nazara/Platform/X11/VideoModeImpl.cpp delete mode 100644 src/Nazara/Platform/X11/VideoModeImpl.hpp delete mode 100644 src/Nazara/Platform/X11/WindowImpl.cpp delete mode 100644 src/Nazara/Platform/X11/WindowImpl.hpp delete mode 100644 src/Nazara/Renderer/GLX/ContextImpl.cpp delete mode 100644 src/Nazara/Renderer/GLX/ContextImpl.hpp delete mode 100644 src/Nazara/Renderer/Win32/ContextImpl.cpp delete mode 100644 src/Nazara/Renderer/Win32/ContextImpl.hpp create mode 100644 thirdparty/include/SDL2/SDL.h create mode 100644 thirdparty/include/SDL2/SDL_assert.h create mode 100644 thirdparty/include/SDL2/SDL_atomic.h create mode 100644 thirdparty/include/SDL2/SDL_audio.h create mode 100644 thirdparty/include/SDL2/SDL_bits.h create mode 100644 thirdparty/include/SDL2/SDL_blendmode.h create mode 100644 thirdparty/include/SDL2/SDL_clipboard.h create mode 100644 thirdparty/include/SDL2/SDL_config.h create mode 100644 thirdparty/include/SDL2/SDL_config.h.cmake create mode 100644 thirdparty/include/SDL2/SDL_config.h.in create mode 100644 thirdparty/include/SDL2/SDL_config_android.h create mode 100644 thirdparty/include/SDL2/SDL_config_iphoneos.h create mode 100644 thirdparty/include/SDL2/SDL_config_macosx.h create mode 100644 thirdparty/include/SDL2/SDL_config_macosx.h.orig create mode 100644 thirdparty/include/SDL2/SDL_config_minimal.h create mode 100644 thirdparty/include/SDL2/SDL_config_pandora.h create mode 100644 thirdparty/include/SDL2/SDL_config_psp.h create mode 100644 thirdparty/include/SDL2/SDL_config_windows.h create mode 100644 thirdparty/include/SDL2/SDL_config_winrt.h create mode 100644 thirdparty/include/SDL2/SDL_config_wiz.h create mode 100644 thirdparty/include/SDL2/SDL_copying.h create mode 100644 thirdparty/include/SDL2/SDL_cpuinfo.h create mode 100644 thirdparty/include/SDL2/SDL_egl.h create mode 100644 thirdparty/include/SDL2/SDL_endian.h create mode 100644 thirdparty/include/SDL2/SDL_error.h create mode 100644 thirdparty/include/SDL2/SDL_events.h create mode 100644 thirdparty/include/SDL2/SDL_filesystem.h create mode 100644 thirdparty/include/SDL2/SDL_gamecontroller.h create mode 100644 thirdparty/include/SDL2/SDL_gesture.h create mode 100644 thirdparty/include/SDL2/SDL_haptic.h create mode 100644 thirdparty/include/SDL2/SDL_hints.h create mode 100644 thirdparty/include/SDL2/SDL_joystick.h create mode 100644 thirdparty/include/SDL2/SDL_keyboard.h create mode 100644 thirdparty/include/SDL2/SDL_keycode.h create mode 100644 thirdparty/include/SDL2/SDL_loadso.h create mode 100644 thirdparty/include/SDL2/SDL_log.h create mode 100644 thirdparty/include/SDL2/SDL_main.h create mode 100644 thirdparty/include/SDL2/SDL_messagebox.h create mode 100644 thirdparty/include/SDL2/SDL_metal.h create mode 100644 thirdparty/include/SDL2/SDL_mouse.h create mode 100644 thirdparty/include/SDL2/SDL_mutex.h create mode 100644 thirdparty/include/SDL2/SDL_name.h create mode 100644 thirdparty/include/SDL2/SDL_opengl.h create mode 100644 thirdparty/include/SDL2/SDL_opengl_glext.h create mode 100644 thirdparty/include/SDL2/SDL_opengles.h create mode 100644 thirdparty/include/SDL2/SDL_opengles2.h create mode 100644 thirdparty/include/SDL2/SDL_opengles2_gl2.h create mode 100644 thirdparty/include/SDL2/SDL_opengles2_gl2ext.h create mode 100644 thirdparty/include/SDL2/SDL_opengles2_gl2platform.h create mode 100644 thirdparty/include/SDL2/SDL_opengles2_khrplatform.h create mode 100644 thirdparty/include/SDL2/SDL_pixels.h create mode 100644 thirdparty/include/SDL2/SDL_platform.h create mode 100644 thirdparty/include/SDL2/SDL_power.h create mode 100644 thirdparty/include/SDL2/SDL_quit.h create mode 100644 thirdparty/include/SDL2/SDL_rect.h create mode 100644 thirdparty/include/SDL2/SDL_render.h create mode 100644 thirdparty/include/SDL2/SDL_revision.h create mode 100644 thirdparty/include/SDL2/SDL_rwops.h create mode 100644 thirdparty/include/SDL2/SDL_scancode.h create mode 100644 thirdparty/include/SDL2/SDL_sensor.h create mode 100644 thirdparty/include/SDL2/SDL_shape.h create mode 100644 thirdparty/include/SDL2/SDL_stdinc.h create mode 100644 thirdparty/include/SDL2/SDL_surface.h create mode 100644 thirdparty/include/SDL2/SDL_system.h create mode 100644 thirdparty/include/SDL2/SDL_syswm.h create mode 100644 thirdparty/include/SDL2/SDL_test.h create mode 100644 thirdparty/include/SDL2/SDL_test_assert.h create mode 100644 thirdparty/include/SDL2/SDL_test_common.h create mode 100644 thirdparty/include/SDL2/SDL_test_compare.h create mode 100644 thirdparty/include/SDL2/SDL_test_crc32.h create mode 100644 thirdparty/include/SDL2/SDL_test_font.h create mode 100644 thirdparty/include/SDL2/SDL_test_fuzzer.h create mode 100644 thirdparty/include/SDL2/SDL_test_harness.h create mode 100644 thirdparty/include/SDL2/SDL_test_images.h create mode 100644 thirdparty/include/SDL2/SDL_test_log.h create mode 100644 thirdparty/include/SDL2/SDL_test_md5.h create mode 100644 thirdparty/include/SDL2/SDL_test_memory.h create mode 100644 thirdparty/include/SDL2/SDL_test_random.h create mode 100644 thirdparty/include/SDL2/SDL_thread.h create mode 100644 thirdparty/include/SDL2/SDL_timer.h create mode 100644 thirdparty/include/SDL2/SDL_touch.h create mode 100644 thirdparty/include/SDL2/SDL_types.h create mode 100644 thirdparty/include/SDL2/SDL_version.h create mode 100644 thirdparty/include/SDL2/SDL_video.h create mode 100644 thirdparty/include/SDL2/SDL_vulkan.h create mode 100644 thirdparty/include/SDL2/begin_code.h create mode 100644 thirdparty/include/SDL2/close_code.h diff --git a/Dockerfile b/Dockerfile index e697ccb25..9a920d6b2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM debian:stretch -RUN apt-get update && apt-get install -y build-essential clang libopenal-dev libsndfile1-dev libxcb-cursor-dev libxcb-ewmh-dev libxcb-randr0-dev libxcb-icccm4-dev libxcb-keysyms1-dev libx11-dev libfreetype6-dev mesa-common-dev libgl1-mesa-dev libassimp-dev +RUN apt-get update && apt-get install -y build-essential clang libopenal-dev libsndfile1-dev libfreetype6-dev libassimp-dev libsdl2-dev RUN mkdir /NazaraEngine WORKDIR /NazaraEngine \ No newline at end of file diff --git a/build/config.lua b/build/config.lua index 6589eb3b7..16bf08d33 100644 --- a/build/config.lua +++ b/build/config.lua @@ -24,7 +24,3 @@ ServerMode = false -- Builds modules as one united library (useless on POSIX systems) UniteModules = false - --- Use SDL2 platform -PlatformSDL2 = true -PlatformSDL2_Path = "../../SDL2" \ No newline at end of file diff --git a/build/scripts/modules/platform.lua b/build/scripts/modules/platform.lua index 2f5cfb1be..9a04ca3e8 100644 --- a/build/scripts/modules/platform.lua +++ b/build/scripts/modules/platform.lua @@ -2,57 +2,17 @@ MODULE.Name = "Platform" MODULE.ClientOnly = true -MODULE.Libraries = { - "NazaraCore", - "NazaraUtility" +MODULE.Defines = { + "NAZARA_PLATFORM_SDL2" } -if (Config.PlatformSDL2) then - table.insert(MODULE.Defines, "NAZARA_PLATFORM_SDL2") +MODULE.Libraries = { + "NazaraCore", + "NazaraUtility", + "SDL2" +} - table.insert(MODULE.Files, "../src/Nazara/Platform/SDL2/**.hpp") - table.insert(MODULE.Files, "../src/Nazara/Platform/SDL2/**.cpp") - - table.insert(MODULE.Libraries, "SDL2") - - assert(Config.PlatformSDL2_Path) - MODULE.Includes = Config.PlatformSDL2_Path .. "/include" - MODULE.LibraryPaths.x64 = { - Config.PlatformSDL2_Path .. "/lib/x64/", - Config.PlatformSDL2_Path .. "/bin/x64/" - } - MODULE.LibraryPaths.x86 = { - Config.PlatformSDL2_Path .. "/lib/x86/", - Config.PlatformSDL2_Path .. "/bin/x86/" - } - - MODULE.FilesExcluded = { - "../src/Nazara/Platform/Win32/**", - "../src/Nazara/Platform/X11/**" - } -else - MODULE.OsFiles.Windows = { - "../src/Nazara/Platform/Win32/**.hpp", - "../src/Nazara/Platform/Win32/**.cpp" - } - - MODULE.OsFiles.Posix = { - "../src/Nazara/Platform/X11/**.hpp", - "../src/Nazara/Platform/X11/**.cpp" - } - - MODULE.OsLibraries.Windows = { - "gdi32" - } - - MODULE.OsLibraries.Posix = { - "X11", - "xcb", - "xcb-cursor", - "xcb-ewmh", - "xcb-icccm", - "xcb-keysyms", - "xcb-randr" - } - -end +MODULE.Files = { + "../src/Nazara/Platform/SDL2/**.hpp", + "../src/Nazara/Platform/SDL2/**.cpp" +} diff --git a/build/scripts/modules/renderer.lua b/build/scripts/modules/renderer.lua index b28a268ad..914e587fc 100644 --- a/build/scripts/modules/renderer.lua +++ b/build/scripts/modules/renderer.lua @@ -9,51 +9,11 @@ MODULE.Defines = { MODULE.Libraries = { "NazaraCore", "NazaraUtility", - "NazaraPlatform" + "NazaraPlatform", + "SDL2" } -if (Config.PlatformSDL2) then - table.insert(MODULE.Defines, "NAZARA_PLATFORM_SDL2") - - table.insert(MODULE.Files, "../src/Nazara/Renderer/SDL2/**.hpp") - table.insert(MODULE.Files, "../src/Nazara/Renderer/SDL2/**.cpp") - - table.insert(MODULE.Libraries, "SDL2") - - assert(Config.PlatformSDL2_Path) - MODULE.Includes = Config.PlatformSDL2_Path .. "/include" - MODULE.LibraryPaths.x64 = { - Config.PlatformSDL2_Path .. "/lib/x64/", - Config.PlatformSDL2_Path .. "/bin/x64/" - } - MODULE.LibraryPaths.x86 = { - Config.PlatformSDL2_Path .. "/lib/x86/", - Config.PlatformSDL2_Path .. "/bin/x86/" - } - - MODULE.FilesExcluded = { - "../src/Nazara/Renderer/Win32/**", - "../src/Nazara/Renderer/GLX/**.cpp" - } -else - MODULE.OsFiles.Windows = { - "../src/Nazara/Renderer/Win32/**.hpp", - "../src/Nazara/Renderer/Win32/**.cpp" - } - - MODULE.OsFiles.Posix = { - "../src/Nazara/Renderer/GLX/**.hpp", - "../src/Nazara/Renderer/GLX/**.cpp" - } - - MODULE.OsLibraries.Windows = { - "gdi32", - "opengl32", - "winmm" - } - - MODULE.OsLibraries.Posix = { - "GL", - "X11" - } -end +MODULE.Files = { + "../src/Nazara/Renderer/SDL2/**.hpp", + "../src/Nazara/Renderer/SDL2/**.cpp" +} diff --git a/examples/HardwareInfo/build.lua b/examples/HardwareInfo/build.lua index 6f49557d7..953cba7d9 100644 --- a/examples/HardwareInfo/build.lua +++ b/examples/HardwareInfo/build.lua @@ -16,10 +16,3 @@ EXAMPLE.Libraries = { "NazaraRenderer", "NazaraUtility" } - -if (Config.PlatformSDL2) then - table.insert(EXAMPLE.Defines, "NAZARA_PLATFORM_SDL2") - - assert(Config.PlatformSDL2_Path) - EXAMPLE.Includes = Config.PlatformSDL2_Path .. "/include" -end diff --git a/include/Nazara/Platform/WindowHandle.hpp b/include/Nazara/Platform/WindowHandle.hpp index b220151f7..de6e43304 100644 --- a/include/Nazara/Platform/WindowHandle.hpp +++ b/include/Nazara/Platform/WindowHandle.hpp @@ -8,25 +8,11 @@ #define NAZARA_WINDOWHANDLE_HPP #include -#if defined(NAZARA_PLATFORM_SDL2) -#elif defined(NAZARA_PLATFORM_X11) -#include -#endif namespace Nz { - #if defined(NAZARA_PLATFORM_SDL2) // Real type is SDL_Window using WindowHandle = void*; - #elif defined(NAZARA_PLATFORM_WINDOWS) - // http://msdn.microsoft.com/en-us/library/aa383751(v=vs.85).aspx - using WindowHandle = void*; - #elif defined(NAZARA_PLATFORM_X11) - // http://en.wikipedia.org/wiki/Xlib#Data_types - using WindowHandle = xcb_window_t; - #else - #error Lack of implementation: WindowHandle - #endif } #endif // NAZARA_WINDOWHANDLE_HPP diff --git a/include/Nazara/Prerequisites.hpp b/include/Nazara/Prerequisites.hpp index de3ea8da8..0f4611766 100644 --- a/include/Nazara/Prerequisites.hpp +++ b/include/Nazara/Prerequisites.hpp @@ -119,11 +119,6 @@ #define NAZARA_PLATFORM_LINUX #define NAZARA_PLATFORM_POSIX - #ifndef NAZARA_PLATFORM_SDL2 - #define NAZARA_PLATFORM_GLX - #define NAZARA_PLATFORM_X11 - #endif - #define NAZARA_EXPORT __attribute__((visibility ("default"))) #define NAZARA_IMPORT __attribute__((visibility ("default"))) /*#elif defined(__APPLE__) && defined(__MACH__) diff --git a/include/Nazara/Renderer/OpenGL.hpp b/include/Nazara/Renderer/OpenGL.hpp index 5252bcfbe..52c043e32 100644 --- a/include/Nazara/Renderer/OpenGL.hpp +++ b/include/Nazara/Renderer/OpenGL.hpp @@ -20,20 +20,6 @@ #include #include -#if defined(NAZARA_PLATFORM_SDL2) - #include -#endif - -#if defined(NAZARA_PLATFORM_WINDOWS) - #include -#elif defined(NAZARA_PLATFORM_GLX) -namespace GLX -{ - #include // Defined in a namespace to avoid conflict -} - #include -#endif - namespace Nz { enum OpenGLExtension @@ -334,19 +320,6 @@ namespace Nz NAZARA_RENDERER_API extern PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer; NAZARA_RENDERER_API extern PFNGLVERTEXATTRIBLPOINTERPROC glVertexAttribLPointer; NAZARA_RENDERER_API extern PFNGLVIEWPORTPROC glViewport; -#if defined(NAZARA_PLATFORM_WINDOWS) - NAZARA_RENDERER_API extern PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormat; - NAZARA_RENDERER_API extern PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs; - NAZARA_RENDERER_API extern PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB; - NAZARA_RENDERER_API extern PFNWGLGETEXTENSIONSSTRINGEXTPROC wglGetExtensionsStringEXT; - NAZARA_RENDERER_API extern PFNWGLSWAPINTERVALEXTPROC wglSwapInterval; -#elif defined(NAZARA_PLATFORM_GLX) - NAZARA_RENDERER_API extern GLX::PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs; - NAZARA_RENDERER_API extern GLX::PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT; - NAZARA_RENDERER_API extern GLX::PFNGLXSWAPINTERVALMESAPROC NzglXSwapIntervalMESA; - NAZARA_RENDERER_API extern GLX::PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI; -#endif - } #undef None diff --git a/src/Nazara/Platform/Cursor.cpp b/src/Nazara/Platform/Cursor.cpp index a352d7f8c..2eb9dc67b 100644 --- a/src/Nazara/Platform/Cursor.cpp +++ b/src/Nazara/Platform/Cursor.cpp @@ -3,17 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include - -#if defined(NAZARA_PLATFORM_SDL2) - #include -#elif defined(NAZARA_PLATFORM_WINDOWS) - #include -#elif defined(NAZARA_PLATFORM_X11) - #include -#else - #error Lack of implementation: Cursor -#endif - +#include #include namespace Nz diff --git a/src/Nazara/Platform/Icon.cpp b/src/Nazara/Platform/Icon.cpp index 86ce7559b..d13788374 100644 --- a/src/Nazara/Platform/Icon.cpp +++ b/src/Nazara/Platform/Icon.cpp @@ -3,17 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include - -#if defined(NAZARA_PLATFORM_SDL2) - #include -#elif defined(NAZARA_PLATFORM_WINDOWS) - #include -#elif defined(NAZARA_PLATFORM_X11) - #include -#else - #error Lack of implementation: Icon -#endif - +#include #include namespace Nz diff --git a/src/Nazara/Platform/Keyboard.cpp b/src/Nazara/Platform/Keyboard.cpp index d2a287e32..420e909b5 100644 --- a/src/Nazara/Platform/Keyboard.cpp +++ b/src/Nazara/Platform/Keyboard.cpp @@ -3,17 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include - -#if defined(NAZARA_PLATFORM_SDL2) - #include -#elif defined(NAZARA_PLATFORM_WINDOWS) - #include -#elif defined(NAZARA_PLATFORM_X11) - #include -#else - #error Lack of implementation: Keyboard -#endif - +#include #include namespace Nz diff --git a/src/Nazara/Platform/Mouse.cpp b/src/Nazara/Platform/Mouse.cpp index d79cea389..25c8e0d94 100644 --- a/src/Nazara/Platform/Mouse.cpp +++ b/src/Nazara/Platform/Mouse.cpp @@ -4,17 +4,7 @@ #include #include - -#if defined(NAZARA_PLATFORM_SDL2) - #include -#elif defined(NAZARA_PLATFORM_WINDOWS) - #include -#elif defined(NAZARA_PLATFORM_X11) - #include -#else - #error Lack of implementation: Mouse -#endif - +#include #include namespace Nz diff --git a/src/Nazara/Platform/VideoMode.cpp b/src/Nazara/Platform/VideoMode.cpp index 1cd8b0990..0895a8351 100644 --- a/src/Nazara/Platform/VideoMode.cpp +++ b/src/Nazara/Platform/VideoMode.cpp @@ -5,17 +5,7 @@ #include #include #include - -#if defined(NAZARA_PLATFORM_SDL2) - #include -#elif defined(NAZARA_PLATFORM_WINDOWS) - #include -#elif defined(NAZARA_PLATFORM_X11) - #include -#else - #error Lack of implementation: Window -#endif - +#include #include namespace Nz diff --git a/src/Nazara/Platform/Win32/CursorImpl.cpp b/src/Nazara/Platform/Win32/CursorImpl.cpp deleted file mode 100644 index 48d960f92..000000000 --- a/src/Nazara/Platform/Win32/CursorImpl.cpp +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Platform module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include - -namespace Nz -{ - bool CursorImpl::Create(const Image& cursor, int hotSpotX, int hotSpotY) - { - Image windowsCursor(cursor); - if (!windowsCursor.Convert(PixelFormatType_BGRA8)) - { - NazaraError("Failed to convert cursor to BGRA8"); - return false; - } - - HBITMAP bitmap = CreateBitmap(windowsCursor.GetWidth(), windowsCursor.GetHeight(), 1, 32, windowsCursor.GetConstPixels()); - HBITMAP monoBitmap = CreateBitmap(windowsCursor.GetWidth(), windowsCursor.GetHeight(), 1, 1, nullptr); - - // http://msdn.microsoft.com/en-us/library/windows/desktop/ms648052(v=vs.85).aspx - ICONINFO iconInfo; - iconInfo.fIcon = FALSE; - iconInfo.xHotspot = hotSpotX; - iconInfo.yHotspot = hotSpotY; - iconInfo.hbmMask = monoBitmap; - iconInfo.hbmColor = bitmap; - - m_icon = CreateIconIndirect(&iconInfo); - - DeleteObject(bitmap); - DeleteObject(monoBitmap); - - if (!m_icon) - { - NazaraError("Failed to create cursor: " + Error::GetLastSystemError()); - return false; - } - - m_cursor = m_icon; - - return true; - } - - bool CursorImpl::Create(SystemCursor cursor) - { - if (cursor != SystemCursor_None) - m_cursor = static_cast(LoadImage(nullptr, s_systemCursorIds[cursor], IMAGE_CURSOR, 0, 0, LR_SHARED)); - else - m_cursor = nullptr; - - // No need to free the cursor if shared - // http://msdn.microsoft.com/en-us/library/windows/desktop/ms648045(v=vs.85).aspx - m_icon = nullptr; - - return true; - } - - void CursorImpl::Destroy() - { - if (m_icon) - DestroyIcon(m_icon); - } - - HCURSOR CursorImpl::GetCursor() - { - return m_cursor; - } - - bool CursorImpl::Initialize() - { - return true; - } - - void CursorImpl::Uninitialize() - { - } - - std::array CursorImpl::s_systemCursorIds = - { - IDC_CROSS, // SystemCursor_Crosshair - IDC_ARROW, // SystemCursor_Default - IDC_HAND, // SystemCursor_Hand - IDC_HELP, // SystemCursor_Help - IDC_SIZEALL, // SystemCursor_Move - nullptr, // SystemCursor_None - IDC_HAND, // SystemCursor_Pointer - IDC_APPSTARTING, // SystemCursor_Progress - IDC_SIZEWE, // SystemCursor_ResizeE - IDC_SIZENS, // SystemCursor_ResizeN - IDC_SIZENESW, // SystemCursor_ResizeNE - IDC_SIZENWSE, // SystemCursor_ResizeNW - IDC_SIZENS, // SystemCursor_ResizeS - IDC_SIZENWSE, // SystemCursor_ResizeSE - IDC_SIZENESW, // SystemCursor_ResizeSW - IDC_SIZEWE, // SystemCursor_ResizeW - IDC_IBEAM, // SystemCursor_Text - IDC_WAIT // SystemCursor_Wait - }; - - static_assert(SystemCursor_Max + 1 == 18, "System cursor array is incomplete"); -} diff --git a/src/Nazara/Platform/Win32/CursorImpl.hpp b/src/Nazara/Platform/Win32/CursorImpl.hpp deleted file mode 100644 index c3c1f4040..000000000 --- a/src/Nazara/Platform/Win32/CursorImpl.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Platform module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_CURSORIMPL_HPP -#define NAZARA_CURSORIMPL_HPP - -#include -#include -#include -#include - -namespace Nz -{ - class Image; - - class CursorImpl - { - friend class Cursor; - - public: - bool Create(const Image& image, int hotSpotX, int hotSpotY); - bool Create(SystemCursor cursor); - - void Destroy(); - - HCURSOR GetCursor(); - - private: - static bool Initialize(); - static void Uninitialize(); - - HCURSOR m_cursor = nullptr; - HICON m_icon = nullptr; - - static std::array s_systemCursorIds; - }; -} - -#endif // NAZARA_CURSORIMPL_HPP diff --git a/src/Nazara/Platform/Win32/IconImpl.cpp b/src/Nazara/Platform/Win32/IconImpl.cpp deleted file mode 100644 index 14a67cfba..000000000 --- a/src/Nazara/Platform/Win32/IconImpl.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Platform module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include - -namespace Nz -{ - bool IconImpl::Create(const Image& icon) - { - Image windowsIcon(icon); // Vive le COW - if (!windowsIcon.Convert(PixelFormatType_BGRA8)) - { - NazaraError("Failed to convert icon to BGRA8"); - return false; - } - - HBITMAP bitmap = CreateBitmap(windowsIcon.GetWidth(), windowsIcon.GetHeight(), 1, 32, windowsIcon.GetConstPixels()); - HBITMAP monoBitmap = CreateBitmap(windowsIcon.GetWidth(), windowsIcon.GetHeight(), 1, 1, nullptr); - - // http://msdn.microsoft.com/en-us/library/windows/desktop/ms648052(v=vs.85).aspx - ICONINFO iconInfo; - iconInfo.fIcon = TRUE; - iconInfo.hbmMask = monoBitmap; - iconInfo.hbmColor = bitmap; - - m_icon = CreateIconIndirect(&iconInfo); - - DeleteObject(bitmap); - DeleteObject(monoBitmap); - - if (!m_icon) - { - NazaraError("Failed to create icon: " + Error::GetLastSystemError()); - return false; - } - - return true; - } - - void IconImpl::Destroy() - { - DestroyIcon(m_icon); - } - - HICON IconImpl::GetIcon() - { - return m_icon; - } -} diff --git a/src/Nazara/Platform/Win32/IconImpl.hpp b/src/Nazara/Platform/Win32/IconImpl.hpp deleted file mode 100644 index e3e7b49a9..000000000 --- a/src/Nazara/Platform/Win32/IconImpl.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Platform module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_ICONIMPL_HPP -#define NAZARA_ICONIMPL_HPP - -#include -#include - -namespace Nz -{ - class Image; - - class IconImpl - { - public: - bool Create(const Image& image); - void Destroy(); - - HICON GetIcon(); - - private: - HICON m_icon = nullptr; - }; -} - -#endif // NAZARA_ICONIMPL_HPP diff --git a/src/Nazara/Platform/Win32/InputImpl.cpp b/src/Nazara/Platform/Win32/InputImpl.cpp deleted file mode 100644 index 0858ec7a0..000000000 --- a/src/Nazara/Platform/Win32/InputImpl.cpp +++ /dev/null @@ -1,298 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Platform module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include - -namespace Nz -{ - namespace - { - int vKeys[Keyboard::Count] = { - // Lettres - 0x41, // Key::A - 0x42, // Key::B - 0x43, // Key::C - 0x44, // Key::D - 0x45, // Key::E - 0x46, // Key::F - 0x47, // Key::G - 0x48, // Key::H - 0x49, // Key::I - 0x4A, // Key::J - 0x4B, // Key::K - 0x4C, // Key::L - 0x4D, // Key::M - 0x4E, // Key::N - 0x4F, // Key::O - 0x50, // Key::P - 0x51, // Key::Q - 0x52, // Key::R - 0x53, // Key::S - 0x54, // Key::T - 0x55, // Key::U - 0x56, // Key::V - 0x57, // Key::W - 0x58, // Key::X - 0x59, // Key::Y - 0x5A, // Key::Z - - // Touches de fonction - VK_F1, // Key::F1 - VK_F2, // Key::F2 - VK_F3, // Key::F3 - VK_F4, // Key::F4 - VK_F5, // Key::F5 - VK_F6, // Key::F6 - VK_F7, // Key::F7 - VK_F8, // Key::F8 - VK_F9, // Key::F9 - VK_F10, // Key::F10 - VK_F11, // Key::F11 - VK_F12, // Key::F12 - VK_F13, // Key::F13 - VK_F14, // Key::F14 - VK_F15, // Key::F15 - - // Flèches directionnelles - VK_DOWN, // Key::Down - VK_LEFT, // Key::Left - VK_RIGHT, // Key::Right - VK_UP, // Key::Up - - // Pavé numérique - VK_ADD, // Key::Add - VK_DECIMAL, // Key::Decimal - VK_DIVIDE, // Key::Divide - VK_MULTIPLY, // Key::Multiply - VK_RETURN, // Key::Multiply - VK_NUMPAD0, // Key::Numpad0 - VK_NUMPAD1, // Key::Numpad1 - VK_NUMPAD2, // Key::Numpad2 - VK_NUMPAD3, // Key::Numpad3 - VK_NUMPAD4, // Key::Numpad4 - VK_NUMPAD5, // Key::Numpad5 - VK_NUMPAD6, // Key::Numpad6 - VK_NUMPAD7, // Key::Numpad7 - VK_NUMPAD8, // Key::Numpad8 - VK_NUMPAD9, // Key::Numpad9 - VK_SUBTRACT, // Key::Subtract - - // Diverss - VK_OEM_5, // Key::Backslash - VK_BACK, // Key::Backspace - VK_CLEAR, // Key::Clear - VK_OEM_COMMA, // Key::Comma, - VK_OEM_MINUS, // Key::Dash - VK_DELETE, // Key::Delete - VK_END, // Key::End - VK_OEM_PLUS, // Key::Equal - VK_ESCAPE, // Key::Escape - VK_HOME, // Key::Home - VK_INSERT, // Key::Insert - VK_LMENU, // Key::LAlt - VK_OEM_4, // Key::LBracket - VK_LCONTROL, // Key::LControl - VK_LSHIFT, // Key::LShift - VK_LWIN, // Key::LSystem - 0x30, // Key::Num0 - 0x31, // Key::Num1 - 0x32, // Key::Num2 - 0x33, // Key::Num3 - 0x34, // Key::Num4 - 0x35, // Key::Num5 - 0x36, // Key::Num6 - 0x37, // Key::Num7 - 0x38, // Key::Num8 - 0x39, // Key::Num9 - VK_NEXT, // Key::PageDown - VK_PRIOR, // Key::PageUp - VK_PAUSE, // Key::Pause - VK_OEM_PERIOD, // Key::Period - VK_PRINT, // Key::Print - VK_SNAPSHOT, // Key::PrintScreen - VK_OEM_7, // Key::Quote - VK_RMENU, // Key::RAlt - VK_OEM_6, // Key::RBracket - VK_RCONTROL, // Key::RControl - VK_RETURN, // Key::Return - VK_RSHIFT, // Key::RShift - VK_RWIN, // Key::RSystem - VK_OEM_1, // Key::Semicolon - VK_OEM_2, // Key::Slash - VK_SPACE, // Key::Space - VK_TAB, // Key::Tab - VK_OEM_3, // Key::Tilde - VK_APPS, // Key::Menu - VK_OEM_102, // Key::ISOBackslash102 - - // Touches navigateur - VK_BROWSER_BACK, // Key::Browser_Back - VK_BROWSER_FAVORITES, // Key::Browser_Favorites - VK_BROWSER_FORWARD, // Key::Browser_Forward - VK_BROWSER_HOME, // Key::Browser_Home - VK_BROWSER_REFRESH, // Key::Browser_Refresh - VK_BROWSER_SEARCH, // Key::Browser_Search - VK_BROWSER_STOP, // Key::Browser_Stop - - // Touches de contrôle - VK_MEDIA_NEXT_TRACK, // Key::Media_Next, - VK_MEDIA_PLAY_PAUSE, // Key::Media_PlayPause, - VK_MEDIA_PREV_TRACK, // Key::Media_Previous, - VK_MEDIA_STOP, // Key::Media_Stop, - - // Touches de contrôle du volume - VK_VOLUME_DOWN, // Key::Volume_Down - VK_VOLUME_MUTE, // Key::Volume_Mute - VK_VOLUME_UP, // Key::Volume_Up - - // Touches à verrouillage - VK_CAPITAL, // Key::CapsLock - VK_NUMLOCK, // Key::NumLock - VK_SCROLL // Key::ScrollLock - }; - } - - String EventImpl::GetKeyName(Keyboard::Key key) - { - // http://www.ffuts.org/blog/mapvirtualkey-getkeynametext-and-a-story-of-how-to/ - int vk = vKeys[key]; - unsigned int code = MapVirtualKeyW(vk, 0) << 16; - - ///FIXME: Liste complète ? - switch (vk) - { - case VK_ATTN: - case VK_DOWN: - case VK_DECIMAL: - case VK_DELETE: - case VK_DIVIDE: - case VK_END: - case VK_HOME: - case VK_INSERT: - case VK_LEFT: - case VK_LWIN: - case VK_OEM_1: - case VK_OEM_2: - case VK_OEM_3: - case VK_OEM_4: - case VK_OEM_5: - case VK_OEM_6: - case VK_OEM_7: - case VK_OEM_CLEAR: - case VK_OEM_COMMA: - case VK_OEM_MINUS: - case VK_OEM_PERIOD: - case VK_OEM_PLUS: - case VK_PAUSE: - case VK_NEXT: - case VK_NUMLOCK: - case VK_PRIOR: - case VK_RIGHT: - case VK_RWIN: - case VK_UP: - case VK_RETURN: // TODO check - code |= 0x1000000; // 24ème bit pour l'extension - break; - } - - wchar_t keyName[20]; // Je ne pense pas que ça dépassera 20 caractères - if (!GetKeyNameTextW(code, &keyName[0], 20)) - return "Unknown"; - - return String::Unicode(keyName); - } - - Vector2i EventImpl::GetMousePosition() - { - POINT pos; - GetCursorPos(&pos); - - return Vector2i(pos.x, pos.y); - } - - Vector2i EventImpl::GetMousePosition(const Window& relativeTo) - { - HWND handle = static_cast(relativeTo.GetHandle()); - if (handle) - { - POINT pos; - GetCursorPos(&pos); - ScreenToClient(handle, &pos); - - return Vector2i(pos.x, pos.y); - } - else - { - NazaraError("Invalid window handle"); - - // Attention que (-1, -1) est une position tout à fait valide et ne doit pas servir de test - return Vector2i(-1, -1); - } - } - - bool EventImpl::IsKeyPressed(Keyboard::Key key) - { - switch (key) - { - case Keyboard::CapsLock: - case Keyboard::NumLock: - case Keyboard::ScrollLock: - return GetKeyState(vKeys[key]) != 0; - - default: - return (GetAsyncKeyState(vKeys[key]) & 0x8000) != 0; - } - } - - bool EventImpl::IsMouseButtonPressed(Mouse::Button button) - { - static int vButtons[Mouse::Max + 1] = { - VK_LBUTTON, // Button::Left - VK_MBUTTON, // Button::Middle - VK_RBUTTON, // Button::Right - VK_XBUTTON1, // Button::XButton1 - VK_XBUTTON2 // Button::XButton2 - }; - - // Gestion de l'inversement des boutons de la souris - if (GetSystemMetrics(SM_SWAPBUTTON)) - switch (button) - { - case Mouse::Left: - button = Mouse::Right; - break; - - case Mouse::Right: - button = Mouse::Left; - break; - - default: - break; - } - - return (GetAsyncKeyState(vButtons[button]) & 0x8000) != 0; - } - - void EventImpl::SetMousePosition(int x, int y) - { - SetCursorPos(x, y); - } - - void EventImpl::SetMousePosition(int x, int y, const Window& relativeTo) - { - HWND handle = static_cast(relativeTo.GetHandle()); - if (handle) - { - POINT pos = {x, y}; - ClientToScreen(handle, &pos); - SetCursorPos(pos.x, pos.y); - } - else - NazaraError("Invalid window handle"); - } -} diff --git a/src/Nazara/Platform/Win32/InputImpl.hpp b/src/Nazara/Platform/Win32/InputImpl.hpp deleted file mode 100644 index fc5e226a5..000000000 --- a/src/Nazara/Platform/Win32/InputImpl.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Platform module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_INPUTIMPL_HPP -#define NAZARA_INPUTIMPL_HPP - -#include -#include -#include -#include - -namespace Nz -{ - class EventImpl - { - public: - static String GetKeyName(Keyboard::Key key); - static Vector2i GetMousePosition(); - static Vector2i GetMousePosition(const Window& relativeTo); - static bool IsKeyPressed(Keyboard::Key key); - static bool IsMouseButtonPressed(Mouse::Button button); - static void SetMousePosition(int x, int y); - static void SetMousePosition(int x, int y, const Window& relativeTo); - }; -} - -#endif // NAZARA_INPUTIMPL_HPP diff --git a/src/Nazara/Platform/Win32/VideoModeImpl.cpp b/src/Nazara/Platform/Win32/VideoModeImpl.cpp deleted file mode 100644 index 6102a568e..000000000 --- a/src/Nazara/Platform/Win32/VideoModeImpl.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Platform module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include - -namespace Nz -{ - VideoMode VideoModeImpl::GetDesktopMode() - { - DEVMODE mode; - mode.dmSize = sizeof(DEVMODE); - EnumDisplaySettings(nullptr, ENUM_CURRENT_SETTINGS, &mode); - - return VideoMode(mode.dmPelsWidth, mode.dmPelsHeight, static_cast(mode.dmBitsPerPel)); - } - - void VideoModeImpl::GetFullscreenModes(std::vector& modes) - { - DEVMODE win32Mode; - win32Mode.dmSize = sizeof(DEVMODE); - for (unsigned int i = 0; EnumDisplaySettings(nullptr, i, &win32Mode); ++i) - { - VideoMode mode(win32Mode.dmPelsWidth, win32Mode.dmPelsHeight, static_cast(win32Mode.dmBitsPerPel)); - - // Il existe plusieurs modes avec ces trois caractéristques identiques - if (std::find(modes.begin(), modes.end(), mode) == modes.end()) - modes.push_back(mode); - } -} -} diff --git a/src/Nazara/Platform/Win32/VideoModeImpl.hpp b/src/Nazara/Platform/Win32/VideoModeImpl.hpp deleted file mode 100644 index 39579b9a2..000000000 --- a/src/Nazara/Platform/Win32/VideoModeImpl.hpp +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Platform module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_VIDEOMODEIMPL_HPP -#define NAZARA_VIDEOMODEIMPL_HPP - -#include - -namespace Nz -{ - class VideoModeImpl - { - public: - static VideoMode GetDesktopMode(); - static void GetFullscreenModes(std::vector& modes); - }; -} - -#endif // NNAZARA_VIDEOMODEIMPL_HPP diff --git a/src/Nazara/Platform/Win32/WindowImpl.cpp b/src/Nazara/Platform/Win32/WindowImpl.cpp deleted file mode 100644 index ad9168d9c..000000000 --- a/src/Nazara/Platform/Win32/WindowImpl.cpp +++ /dev/null @@ -1,1225 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Platform module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -// Un grand merci à Laurent Gomila pour la SFML qui m'aura bien aidé à réaliser cette implémentation - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef _WIN64 - #define GCL_HCURSOR GCLP_HCURSOR - #define GWL_USERDATA GWLP_USERDATA -#endif - -// N'est pas défini avec MinGW -#ifndef MAPVK_VK_TO_VSC - #define MAPVK_VK_TO_VSC 0 -#endif - -#undef IsMinimized // Conflit avec la méthode du même nom - -namespace Nz -{ - namespace - { - const wchar_t* className = L"Nazara Window"; - WindowImpl* fullscreenWindow = nullptr; - } - - WindowImpl::WindowImpl(Window* parent) : - m_cursor(nullptr), - m_handle(nullptr), - m_callback(0), - m_style(0), - m_maxSize(-1), - m_minSize(-1), - m_parent(parent), - m_keyRepeat(true), - m_mouseInside(false), - m_smoothScrolling(false), - m_scrolling(0) - { - m_cursor = static_cast(LoadImage(nullptr, IDC_ARROW, IMAGE_CURSOR, 0, 0, LR_SHARED)); - } - - bool WindowImpl::Create(const VideoMode& mode, const String& title, WindowStyleFlags style) - { - bool async = (style & WindowStyle_Threaded) != 0; - bool fullscreen = (style & WindowStyle_Fullscreen) != 0; - DWORD win32Style, win32StyleEx; - int x, y; - unsigned int width = mode.width; - unsigned int height = mode.height; - if (fullscreen) - { - DEVMODE win32Mode; - std::memset(&win32Mode, 0, sizeof(DEVMODE)); - win32Mode.dmBitsPerPel = mode.bitsPerPixel; - win32Mode.dmPelsHeight = mode.height; - win32Mode.dmPelsWidth = mode.width; - win32Mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; - win32Mode.dmSize = sizeof(DEVMODE); - - if (ChangeDisplaySettings(&win32Mode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) - { - // Situation extrêmement rare grâce à VideoMode::IsValid appelé par Window - NazaraError("Failed to change display settings for fullscreen, this video mode is not supported by your computer"); - fullscreen = false; - } - } - - // Testé une seconde fois car sa valeur peut changer - if (fullscreen) - { - x = 0; - y = 0; - win32Style = WS_CLIPCHILDREN | WS_POPUP; - - // Pour cacher la barre des tâches - // http://msdn.microsoft.com/en-us/library/windows/desktop/ff700543(v=vs.85).aspx - win32StyleEx = WS_EX_APPWINDOW; - - fullscreenWindow = this; - } - else - { - win32Style = WS_VISIBLE; - if (style & WindowStyle_Titlebar) - { - win32Style |= WS_CAPTION | WS_MINIMIZEBOX; - if (style & WindowStyle_Closable) - win32Style |= WS_SYSMENU; - - if (style & WindowStyle_Resizable) - win32Style |= WS_MAXIMIZEBOX | WS_SIZEBOX; - } - else - win32Style |= WS_POPUP; - - win32StyleEx = 0; - - RECT rect = {0, 0, static_cast(width), static_cast(height)}; - AdjustWindowRect(&rect, win32Style, false); - width = rect.right - rect.left; - height = rect.bottom - rect.top; - - // Grab desktop rect in order to center our window on the main display - // TODO: Handle multiple displays - RECT desktopRect; - GetClientRect(GetDesktopWindow(), &desktopRect); - - x = (desktopRect.right / 2) - (width / 2); - y = (desktopRect.bottom / 2) - (height / 2); - } - - m_callback = 0; - - m_eventListener = true; - m_ownsWindow = true; - m_sizemove = false; - m_style = style; - - if (async) - { - Mutex mutex; - ConditionVariable condition; - m_threadActive = true; - - // On attend que la fenêtre soit créée - mutex.Lock(); - m_thread = Thread(WindowThread, &m_handle, win32StyleEx, title, win32Style, fullscreen, Rectui(x, y, width, height), this, &mutex, &condition); - condition.Wait(&mutex); - mutex.Unlock(); - } - else - m_handle = CreateWindowExW(win32StyleEx, className, title.GetWideString().data(), win32Style, x, y, width, height, nullptr, nullptr, GetModuleHandle(nullptr), this); - - if (!m_handle) - { - NazaraError("Failed to create window: " + Error::GetLastSystemError()); - return false; - } - - if (!async) - PrepareWindow(fullscreen); - - return true; - } - - bool WindowImpl::Create(WindowHandle handle) - { - m_handle = static_cast(handle); - - if (!m_handle || !IsWindow(m_handle)) - { - NazaraError("Invalid handle"); - return false; - } - - m_eventListener = false; - m_ownsWindow = false; - m_sizemove = false; - m_style = RetrieveStyle(m_handle); - - RECT clientRect, windowRect; - GetClientRect(m_handle, &clientRect); - GetWindowRect(m_handle, &windowRect); - - m_position.Set(windowRect.left, windowRect.top); - m_size.Set(clientRect.right - clientRect.left, clientRect.bottom - clientRect.top); - - return true; - } - - void WindowImpl::Destroy() - { - if (m_ownsWindow) - { - if (m_style & WindowStyle_Threaded) - { - if (m_thread.IsJoinable()) - { - m_threadActive = false; - PostMessageW(m_handle, WM_NULL, 0, 0); // Wake up our thread - - m_thread.Join(); - } - } - else if (m_handle) - DestroyWindow(m_handle); - } - else - SetEventListener(false); - } - - void WindowImpl::EnableKeyRepeat(bool enable) - { - m_keyRepeat = enable; - } - - void WindowImpl::EnableSmoothScrolling(bool enable) - { - m_smoothScrolling = enable; - } - - WindowHandle WindowImpl::GetHandle() const - { - return m_handle; - } - - Vector2i WindowImpl::GetPosition() const - { - return m_position; - } - - Vector2ui WindowImpl::GetSize() const - { - return m_size; - } - - WindowStyleFlags WindowImpl::GetStyle() const - { - return m_style; - } - - String WindowImpl::GetTitle() const - { - unsigned int titleSize = GetWindowTextLengthW(m_handle); - if (titleSize == 0) - return String(); - - titleSize++; // \0 - - std::unique_ptr wTitle(new wchar_t[titleSize]); - GetWindowTextW(m_handle, wTitle.get(), titleSize); - - return String::Unicode(wTitle.get()); - } - - bool WindowImpl::HasFocus() const - { - return GetForegroundWindow() == m_handle; - } - - void WindowImpl::IgnoreNextMouseEvent(int mouseX, int mouseY) - { - // Petite astuce ... - m_mousePos.x = mouseX; - m_mousePos.y = mouseY; - } - - bool WindowImpl::IsMinimized() const - { - return IsIconic(m_handle) == TRUE; - } - - bool WindowImpl::IsVisible() const - { - return IsWindowVisible(m_handle) == TRUE; - } - - void WindowImpl::RefreshCursor() - { - ::SetCursor(m_cursor); - } - - void WindowImpl::ProcessEvents(bool block) - { - if (m_ownsWindow) - { - if (block) - WaitMessage(); - - MSG message; - while (PeekMessageW(&message, nullptr, 0, 0, PM_REMOVE)) - { - TranslateMessage(&message); - DispatchMessageW(&message); - } - } - } - - void WindowImpl::SetCursor(const Cursor& cursor) - { - m_cursor = cursor.m_impl->GetCursor(); - - if (HasFocus()) - RefreshCursor(); - } - - void WindowImpl::SetEventListener(bool listener) - { - if (m_ownsWindow) - m_eventListener = listener; - else if (listener != m_eventListener) - { - if (listener) - { - SetWindowLongPtr(m_handle, GWLP_USERDATA, reinterpret_cast(this)); - m_callback = SetWindowLongPtr(m_handle, GWLP_WNDPROC, reinterpret_cast(MessageHandler)); - m_eventListener = true; - } - else if (m_eventListener) - { - SetWindowLongPtr(m_handle, GWLP_WNDPROC, m_callback); - m_eventListener = false; - } - } - } - - void WindowImpl::SetFocus() - { - SetForegroundWindow(m_handle); - } - - void WindowImpl::SetIcon(const Icon& icon) - { - HICON iconHandle = icon.m_impl->GetIcon(); - - SendMessage(m_handle, WM_SETICON, ICON_BIG, reinterpret_cast(iconHandle)); - SendMessage(m_handle, WM_SETICON, ICON_SMALL, reinterpret_cast(iconHandle)); - } - - void WindowImpl::SetMaximumSize(int width, int height) - { - RECT rect = {0, 0, width, height}; - AdjustWindowRect(&rect, static_cast(GetWindowLongPtr(m_handle, GWL_STYLE)), false); - - if (width != -1) - m_maxSize.x = rect.right - rect.left; - else - m_maxSize.x = -1; - - if (height != -1) - m_maxSize.y = rect.bottom - rect.top; - else - m_maxSize.y = -1; - } - - void WindowImpl::SetMinimumSize(int width, int height) - { - RECT rect = {0, 0, width, height}; - AdjustWindowRect(&rect, static_cast(GetWindowLongPtr(m_handle, GWL_STYLE)), false); - - if (width != -1) - m_minSize.x = rect.right - rect.left; - else - m_minSize.x = -1; - - if (height != -1) - m_minSize.y = rect.bottom - rect.top; - else - m_minSize.y = -1; - } - - void WindowImpl::SetPosition(int x, int y) - { - SetWindowPos(m_handle, nullptr, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_ASYNCWINDOWPOS); - } - - void WindowImpl::SetSize(unsigned int width, unsigned int height) - { - // SetWindowPos demande la taille totale de la fenêtre - RECT rect = {0, 0, static_cast(width), static_cast(height)}; - AdjustWindowRect(&rect, static_cast(GetWindowLongPtr(m_handle, GWL_STYLE)), false); - - SetWindowPos(m_handle, nullptr, 0, 0, rect.right - rect.left, rect.bottom - rect.top, SWP_NOMOVE | SWP_NOZORDER | SWP_ASYNCWINDOWPOS); - } - - void WindowImpl::SetStayOnTop(bool stayOnTop) - { - if (stayOnTop) - SetWindowPos(m_handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW | SWP_ASYNCWINDOWPOS); - else - SetWindowPos(m_handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_ASYNCWINDOWPOS); - } - - void WindowImpl::SetTitle(const String& title) - { - SetWindowTextW(m_handle, title.GetWideString().data()); - } - - void WindowImpl::SetVisible(bool visible) - { - ShowWindow(m_handle, (visible) ? SW_SHOW : SW_HIDE); - } - - bool WindowImpl::HandleMessage(HWND window, UINT message, WPARAM wParam, LPARAM lParam) - { - // Inutile de récupérer des évènements ne venant pas de notre fenêtre - if (m_handle != window) - return false; - - switch (message) - { - case WM_DESTROY: - if (fullscreenWindow == this) - ChangeDisplaySettings(nullptr, 0); - - break; - - /*case WM_SETCURSOR: - // http://msdn.microsoft.com/en-us/library/windows/desktop/ms648382(v=vs.85).aspx - if (LOWORD(lParam) == HTCLIENT) - ::SetCursor(m_cursor); - - break;*/ - - case WM_WINDOWPOSCHANGING: - { - WINDOWPOS* pos = reinterpret_cast(lParam); - - pos->cx = std::max(pos->cx, m_minSize.x); - pos->cy = std::max(pos->cy, m_minSize.y); - - if (m_maxSize.x >= 0) - pos->cx = std::min(pos->cx, m_maxSize.x); - - if (m_maxSize.y >= 0) - pos->cy = std::min(pos->cy, m_maxSize.y); - - break; - } - - default: - break; - } - - if (m_eventListener) - switch (message) - { - case WM_CHAR: - { - // http://msdn.microsoft.com/en-us/library/ms646267(VS.85).aspx - bool repeated = ((HIWORD(lParam) & KF_REPEAT) != 0); - if (m_keyRepeat || !repeated) - { - WindowEvent event; - event.type = WindowEventType_TextEntered; - event.text.character = static_cast(wParam); - event.text.repeated = repeated; - m_parent->PushEvent(event); - } - - break; - } - - case WM_CLOSE: - { - WindowEvent event; - event.type = WindowEventType_Quit; - m_parent->PushEvent(event); - - return true; // Afin que Windows ne ferme pas la fenêtre automatiquement - } - - case WM_ENTERSIZEMOVE: - { - m_sizemove = true; - break; - } - - case WM_EXITSIZEMOVE: - { - m_sizemove = false; - - // In case of threaded window, size and move events are not blocked - if (m_style & WindowStyle_Threaded) - break; - - // On vérifie ce qui a changé - RECT clientRect, windowRect; - GetClientRect(m_handle, &clientRect); - GetWindowRect(m_handle, &windowRect); - - Vector2i position(windowRect.left, windowRect.top); - if (m_position != position) - { - m_position = position; - - WindowEvent event; - event.type = WindowEventType_Moved; - event.position.x = position.x; - event.position.y = position.y; - m_parent->PushEvent(event); - } - - Vector2ui size(clientRect.right - clientRect.left, clientRect.bottom - clientRect.top); - if (m_size != size) - { - m_size = size; - - WindowEvent event; - event.type = WindowEventType_Resized; - event.size.width = size.x; - event.size.height = size.y; - m_parent->PushEvent(event); - } - break; - } - - case WM_KEYDOWN: - case WM_SYSKEYDOWN: - { - // http://msdn.microsoft.com/en-us/library/ms646267(VS.85).aspx - bool repeated = ((HIWORD(lParam) & KF_REPEAT) != 0); - if (m_keyRepeat || !repeated) - { - WindowEvent event; - event.type = WindowEventType_KeyPressed; - event.key.code = ConvertVirtualKey(wParam, lParam); - event.key.alt = ((GetAsyncKeyState(VK_MENU) & 0x8000) != 0); - event.key.control = ((GetAsyncKeyState(VK_CONTROL) & 0x8000) != 0); - event.key.repeated = repeated; - event.key.shift = ((GetAsyncKeyState(VK_SHIFT) & 0x8000) != 0); - event.key.system = (((GetAsyncKeyState(VK_LWIN) & 0x8000) != 0) || ((GetAsyncKeyState(VK_RWIN) & 0x8000) != 0)); - m_parent->PushEvent(event); - } - - break; - } - - case WM_KEYUP: - case WM_SYSKEYUP: - { - // http://msdn.microsoft.com/en-us/library/ms646267(VS.85).aspx - WindowEvent event; - event.type = WindowEventType_KeyReleased; - event.key.code = ConvertVirtualKey(wParam, lParam); - event.key.alt = ((GetAsyncKeyState(VK_MENU) & 0x8000) != 0); - event.key.control = ((GetAsyncKeyState(VK_CONTROL) & 0x8000) != 0); - event.key.shift = ((GetAsyncKeyState(VK_SHIFT) & 0x8000) != 0); - event.key.system = ((GetAsyncKeyState(VK_LWIN) & 0x8000) || (GetAsyncKeyState(VK_RWIN) & 0x8000)); - m_parent->PushEvent(event); - - break; - } - - case WM_KILLFOCUS: - { - WindowEvent event; - event.type = WindowEventType_LostFocus; - m_parent->PushEvent(event); - - break; - } - - case WM_LBUTTONDBLCLK: - { - // Cet évènement est généré à la place d'un WM_LBUTTONDOWN lors d'un double-clic. - // Comme nous désirons quand même notifier chaque clic, nous envoyons les deux évènements. - WindowEvent event; - event.mouseButton.button = Mouse::Left; - event.mouseButton.x = GET_X_LPARAM(lParam); - event.mouseButton.y = GET_Y_LPARAM(lParam); - - event.type = WindowEventType_MouseButtonDoubleClicked; - m_parent->PushEvent(event); - - event.type = WindowEventType_MouseButtonPressed; - m_parent->PushEvent(event); - - break; - } - - case WM_LBUTTONDOWN: - { - WindowEvent event; - event.type = WindowEventType_MouseButtonPressed; - event.mouseButton.button = Mouse::Left; - event.mouseButton.x = GET_X_LPARAM(lParam); - event.mouseButton.y = GET_Y_LPARAM(lParam); - m_parent->PushEvent(event); - - break; - } - - case WM_LBUTTONUP: - { - WindowEvent event; - event.type = WindowEventType_MouseButtonReleased; - event.mouseButton.button = Mouse::Left; - event.mouseButton.x = GET_X_LPARAM(lParam); - event.mouseButton.y = GET_Y_LPARAM(lParam); - m_parent->PushEvent(event); - - break; - } - - case WM_MBUTTONDBLCLK: - { - WindowEvent event; - event.mouseButton.button = Mouse::Middle; - event.mouseButton.x = GET_X_LPARAM(lParam); - event.mouseButton.y = GET_Y_LPARAM(lParam); - - event.type = WindowEventType_MouseButtonDoubleClicked; - m_parent->PushEvent(event); - - event.type = WindowEventType_MouseButtonPressed; - m_parent->PushEvent(event); - - break; - } - - case WM_MBUTTONDOWN: - { - WindowEvent event; - event.type = WindowEventType_MouseButtonPressed; - event.mouseButton.button = Mouse::Middle; - event.mouseButton.x = GET_X_LPARAM(lParam); - event.mouseButton.y = GET_Y_LPARAM(lParam); - m_parent->PushEvent(event); - - break; - } - - case WM_MBUTTONUP: - { - WindowEvent event; - event.type = WindowEventType_MouseButtonReleased; - event.mouseButton.button = Mouse::Middle; - event.mouseButton.x = GET_X_LPARAM(lParam); - event.mouseButton.y = GET_Y_LPARAM(lParam); - m_parent->PushEvent(event); - - break; - } - - // Nécessite un appel précédent à TrackMouseEvent (Fait dans WM_MOUSEMOVE) - // http://msdn.microsoft.com/en-us/library/windows/desktop/ms645615(v=vs.85).aspx - case WM_MOUSELEAVE: - { - m_mouseInside = false; - - WindowEvent event; - event.type = WindowEventType_MouseLeft; - m_parent->PushEvent(event); - break; - } - - case WM_MOUSEMOVE: - { - int currentX = GET_X_LPARAM(lParam); - int currentY = GET_Y_LPARAM(lParam); - - if (!m_mouseInside) - { - m_mouseInside = true; - - // Track mouse event to be notified when mouse leaves window - TRACKMOUSEEVENT mouseEvent; - mouseEvent.cbSize = sizeof(TRACKMOUSEEVENT); - mouseEvent.dwFlags = TME_LEAVE; - mouseEvent.hwndTrack = m_handle; - - TrackMouseEvent(&mouseEvent); - - WindowEvent event; - event.type = WindowEventType_MouseEntered; - m_parent->PushEvent(event); - - event.type = WindowEventType_MouseMoved; - - // Le delta sera 0 - event.mouseMove.deltaX = 0; - event.mouseMove.deltaY = 0; - - event.mouseMove.x = currentX; - event.mouseMove.y = currentY; - - m_mousePos.x = currentX; - m_mousePos.y = currentY; - - m_parent->PushEvent(event); - break; - } - - // Si la souris n'a pas bougé (Ou qu'on veut ignorer l'évènement) - if (m_mousePos.x == currentX && m_mousePos.y == currentY) - break; - - WindowEvent event; - event.type = WindowEventType_MouseMoved; - event.mouseMove.deltaX = currentX - m_mousePos.x; - event.mouseMove.deltaY = currentY - m_mousePos.y; - event.mouseMove.x = currentX; - event.mouseMove.y = currentY; - - m_mousePos.x = currentX; - m_mousePos.y = currentY; - - m_parent->PushEvent(event); - break; - } - - case WM_MOUSEWHEEL: - { - if (m_smoothScrolling) - { - WindowEvent event; - event.type = WindowEventType_MouseWheelMoved; - event.mouseWheel.delta = static_cast(GET_WHEEL_DELTA_WPARAM(wParam)) / WHEEL_DELTA; - - event.mouseWheel.x = GET_X_LPARAM(lParam); - event.mouseWheel.y = GET_Y_LPARAM(lParam); - - m_parent->PushEvent(event); - } - else - { - m_scrolling += GET_WHEEL_DELTA_WPARAM(wParam); - if (std::abs(m_scrolling) >= WHEEL_DELTA) - { - WindowEvent event; - event.type = WindowEventType_MouseWheelMoved; - event.mouseWheel.delta = static_cast(m_scrolling / WHEEL_DELTA); - - event.mouseWheel.x = GET_X_LPARAM(lParam); - event.mouseWheel.y = GET_Y_LPARAM(lParam); - - m_parent->PushEvent(event); - - m_scrolling %= WHEEL_DELTA; - } - } - break; - } - - case WM_MOVE: - { - if (m_sizemove && (m_style & WindowStyle_Threaded) == 0) - break; - - RECT windowRect; - GetWindowRect(m_handle, &windowRect); - - Vector2i position(windowRect.left, windowRect.top); - if (m_position != position) - { - m_position = position; - - WindowEvent event; - event.type = WindowEventType_Moved; - event.position.x = position.x; - event.position.y = position.y; - m_parent->PushEvent(event); - } - break; - } - - case WM_RBUTTONDBLCLK: - { - WindowEvent event; - event.mouseButton.button = Mouse::Right; - event.mouseButton.x = GET_X_LPARAM(lParam); - event.mouseButton.y = GET_Y_LPARAM(lParam); - - event.type = WindowEventType_MouseButtonDoubleClicked; - m_parent->PushEvent(event); - - event.type = WindowEventType_MouseButtonPressed; - m_parent->PushEvent(event); - - break; - } - - case WM_RBUTTONDOWN: - { - WindowEvent event; - event.type = WindowEventType_MouseButtonPressed; - event.mouseButton.button = Mouse::Right; - event.mouseButton.x = GET_X_LPARAM(lParam); - event.mouseButton.y = GET_Y_LPARAM(lParam); - m_parent->PushEvent(event); - - break; - } - - case WM_RBUTTONUP: - { - WindowEvent event; - event.type = WindowEventType_MouseButtonReleased; - event.mouseButton.button = Mouse::Right; - event.mouseButton.x = GET_X_LPARAM(lParam); - event.mouseButton.y = GET_Y_LPARAM(lParam); - m_parent->PushEvent(event); - - break; - } - - case WM_SETFOCUS: - { - WindowEvent event; - event.type = WindowEventType_GainedFocus; - m_parent->PushEvent(event); - - break; - } - - case WM_SIZE: - { - if (m_sizemove && (m_style & WindowStyle_Threaded) == 0) - break; - - if (wParam == SIZE_MINIMIZED) - break; - - RECT rect; - GetClientRect(m_handle, &rect); - - Vector2ui size(rect.right - rect.left, rect.bottom - rect.top); // On récupère uniquement la taille de la zone client - if (m_size == size) - break; - - m_size = size; - - WindowEvent event; - event.type = WindowEventType_Resized; - event.size.width = size.x; - event.size.height = size.y; - m_parent->PushEvent(event); - break; - } - - case WM_UNICHAR: - { - // http://msdn.microsoft.com/en-us/library/windows/desktop/ms646288(v=vs.85).aspx - if (wParam != UNICODE_NOCHAR) - { - bool repeated = ((HIWORD(lParam) & KF_REPEAT) != 0); - if (m_keyRepeat || !repeated) - { - WindowEvent event; - event.type = WindowEventType_TextEntered; - event.text.character = static_cast(wParam); - event.text.repeated = repeated; - m_parent->PushEvent(event); - } - - return true; - } - } - - case WM_XBUTTONDBLCLK: - { - WindowEvent event; - if (HIWORD(wParam) == XBUTTON1) - event.mouseButton.button = Mouse::XButton1; - else - event.mouseButton.button = Mouse::XButton2; - - event.mouseButton.x = GET_X_LPARAM(lParam); - event.mouseButton.y = GET_Y_LPARAM(lParam); - - event.type = WindowEventType_MouseButtonDoubleClicked; - m_parent->PushEvent(event); - - event.type = WindowEventType_MouseButtonPressed; - m_parent->PushEvent(event); - - break; - } - - case WM_XBUTTONDOWN: - { - WindowEvent event; - event.type = WindowEventType_MouseButtonPressed; - - if (HIWORD(wParam) == XBUTTON1) - event.mouseButton.button = Mouse::XButton1; - else - event.mouseButton.button = Mouse::XButton2; - - event.mouseButton.x = GET_X_LPARAM(lParam); - event.mouseButton.y = GET_Y_LPARAM(lParam); - m_parent->PushEvent(event); - - break; - } - - case WM_XBUTTONUP: - { - WindowEvent event; - event.type = WindowEventType_MouseButtonReleased; - - if (HIWORD(wParam) == XBUTTON1) - event.mouseButton.button = Mouse::XButton1; - else - event.mouseButton.button = Mouse::XButton2; - - event.mouseButton.x = GET_X_LPARAM(lParam); - event.mouseButton.y = GET_Y_LPARAM(lParam); - m_parent->PushEvent(event); - - break; - } - - default: - break; - } - - #if NAZARA_PLATFORM_WINDOWS_DISABLE_MENU_KEYS - // http://msdn.microsoft.com/en-us/library/windows/desktop/ms646360(v=vs.85).aspx - if (message == WM_SYSCOMMAND && wParam == SC_KEYMENU) - return true; - #endif - - return false; - } - - void WindowImpl::PrepareWindow(bool fullscreen) - { - if (fullscreen) - { - SetForegroundWindow(m_handle); - ShowWindow(m_handle, SW_SHOW); - } - - // Cache window position/size after creation - RECT clientRect, windowRect; - GetClientRect(m_handle, &clientRect); - GetWindowRect(m_handle, &windowRect); - - m_position.Set(windowRect.left, windowRect.top); - m_size.Set(clientRect.right - clientRect.left, clientRect.bottom - clientRect.top); - } - - bool WindowImpl::Initialize() - { - if (!SetProcessDpiAware()) - NazaraWarning("failed to make process DPI-aware"); - - // Nous devons faire un type Unicode pour que la fenêtre le soit également - // http://msdn.microsoft.com/en-us/library/windows/desktop/ms633574(v=vs.85).aspx - WNDCLASSW windowClass; - windowClass.cbClsExtra = 0; - windowClass.cbWndExtra = 0; - windowClass.hbrBackground = nullptr; - windowClass.hCursor = nullptr; // Le curseur est définit dynamiquement - windowClass.hIcon = nullptr; // L'icône est définie dynamiquement - windowClass.hInstance = GetModuleHandle(nullptr); - windowClass.lpfnWndProc = MessageHandler; - windowClass.lpszClassName = className; - windowClass.lpszMenuName = nullptr; - windowClass.style = CS_DBLCLKS; // Gestion du double-clic - - return RegisterClassW(&windowClass) != 0; - } - - void WindowImpl::Uninitialize() - { - UnregisterClassW(className, GetModuleHandle(nullptr)); - } - - bool WindowImpl::SetProcessDpiAware() - { - // MSDN : https://docs.microsoft.com/en-us/windows/win32/hidpi/setting-the-default-dpi-awareness-for-a-process - // This will work only for windows Vista & above - - HINSTANCE shcoreLib = LoadLibraryW(L"SHCore.dll"); - if (shcoreLib) - { - CallOnExit closeLibOnExit([&] { FreeLibrary(shcoreLib); }); - - /// shellscalingapi.h - enum PROCESS_DPI_AWARENESS - { - PROCESS_DPI_UNAWARE, - PROCESS_SYSTEM_DPI_AWARE, - PROCESS_PER_MONITOR_DPI_AWARE - }; - - using SetProcessDpiAwarenessFunc = HRESULT (WINAPI*)(PROCESS_DPI_AWARENESS); - auto SetProcessDpiAwareness = reinterpret_cast(GetProcAddress(shcoreLib, "SetProcessDpiAwareness")); - - if (SetProcessDpiAwareness) - { - HRESULT result = SetProcessDpiAwareness(PROCESS_SYSTEM_DPI_AWARE); - - if (result == S_OK || result == E_ACCESSDENIED) //< E_ACCESSDENIED means it has already been set, probably by the .exe manifest - return true; - } - } - - // If SetProcessDpiAwareness doesn't exist, we call old user32 function - HMODULE user32 = GetModuleHandleW(L"user32.dll"); - if (!user32) - return false; //< Shouldn't happen as user32 is linked - - using SetProcessDPIAwareFunc = BOOL (WINAPI*)(); - auto SetProcessDPIAware = reinterpret_cast(GetProcAddress(user32, "SetProcessDPIAware")); - - if (!SetProcessDPIAware || !SetProcessDPIAware()) - return false; - - return true; - } - - Keyboard::Key WindowImpl::ConvertVirtualKey(WPARAM key, LPARAM flags) - { - switch (key) - { - case VK_CONTROL: return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::RControl : Keyboard::LControl; - case VK_MENU: return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::RAlt : Keyboard::LAlt; - case VK_RETURN: return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::NumpadReturn : Keyboard::Return; // TODO Check - case VK_SHIFT: - { - static UINT scancode = MapVirtualKey(VK_SHIFT, MAPVK_VK_TO_VSC); - return (((flags >> 16) & 0xFF) == scancode) ? Keyboard::LShift : Keyboard::RShift; - } - - case 0x30: return Keyboard::Num0; - case 0x31: return Keyboard::Num1; - case 0x32: return Keyboard::Num2; - case 0x33: return Keyboard::Num3; - case 0x34: return Keyboard::Num4; - case 0x35: return Keyboard::Num5; - case 0x36: return Keyboard::Num6; - case 0x37: return Keyboard::Num7; - case 0x38: return Keyboard::Num8; - case 0x39: return Keyboard::Num9; - case 0x41: return Keyboard::A; - case 0x42: return Keyboard::B; - case 0x43: return Keyboard::C; - case 0x44: return Keyboard::D; - case 0x45: return Keyboard::E; - case 0x46: return Keyboard::F; - case 0x47: return Keyboard::G; - case 0x48: return Keyboard::H; - case 0x49: return Keyboard::I; - case 0x4A: return Keyboard::J; - case 0x4B: return Keyboard::K; - case 0x4C: return Keyboard::L; - case 0x4D: return Keyboard::M; - case 0x4E: return Keyboard::N; - case 0x4F: return Keyboard::O; - case 0x50: return Keyboard::P; - case 0x51: return Keyboard::Q; - case 0x52: return Keyboard::R; - case 0x53: return Keyboard::S; - case 0x54: return Keyboard::T; - case 0x55: return Keyboard::U; - case 0x56: return Keyboard::V; - case 0x57: return Keyboard::W; - case 0x58: return Keyboard::X; - case 0x59: return Keyboard::Y; - case 0x5A: return Keyboard::Z; - case VK_ADD: return Keyboard::Add; - case VK_BACK: return Keyboard::Backspace; - case VK_BROWSER_BACK: return Keyboard::Browser_Back; - case VK_BROWSER_FAVORITES: return Keyboard::Browser_Favorites; - case VK_BROWSER_FORWARD: return Keyboard::Browser_Forward; - case VK_BROWSER_HOME: return Keyboard::Browser_Home; - case VK_BROWSER_REFRESH: return Keyboard::Browser_Refresh; - case VK_BROWSER_SEARCH: return Keyboard::Browser_Search; - case VK_BROWSER_STOP: return Keyboard::Browser_Stop; - case VK_CAPITAL: return Keyboard::CapsLock; - case VK_CLEAR: return Keyboard::Clear; - case VK_DECIMAL: return Keyboard::Decimal; - case VK_DELETE: return Keyboard::Delete; - case VK_DIVIDE: return Keyboard::Divide; - case VK_DOWN: return Keyboard::Down; - case VK_END: return Keyboard::End; - case VK_ESCAPE: return Keyboard::Escape; - case VK_F1: return Keyboard::F1; - case VK_F2: return Keyboard::F2; - case VK_F3: return Keyboard::F3; - case VK_F4: return Keyboard::F4; - case VK_F5: return Keyboard::F5; - case VK_F6: return Keyboard::F6; - case VK_F7: return Keyboard::F7; - case VK_F8: return Keyboard::F8; - case VK_F9: return Keyboard::F9; - case VK_F10: return Keyboard::F10; - case VK_F11: return Keyboard::F11; - case VK_F12: return Keyboard::F12; - case VK_F13: return Keyboard::F13; - case VK_F14: return Keyboard::F14; - case VK_F15: return Keyboard::F15; - case VK_HOME: return Keyboard::Home; - case VK_INSERT: return Keyboard::Insert; - case VK_LEFT: return Keyboard::Left; - case VK_LWIN: return Keyboard::LSystem; - case VK_MEDIA_NEXT_TRACK: return Keyboard::Media_Next; - case VK_MEDIA_PLAY_PAUSE: return Keyboard::Media_Play; - case VK_MEDIA_PREV_TRACK: return Keyboard::Media_Previous; - case VK_MEDIA_STOP: return Keyboard::Media_Stop; - case VK_MULTIPLY: return Keyboard::Multiply; - case VK_NEXT: return Keyboard::PageDown; - case VK_NUMPAD0: return Keyboard::Numpad0; - case VK_NUMPAD1: return Keyboard::Numpad1; - case VK_NUMPAD2: return Keyboard::Numpad2; - case VK_NUMPAD3: return Keyboard::Numpad3; - case VK_NUMPAD4: return Keyboard::Numpad4; - case VK_NUMPAD5: return Keyboard::Numpad5; - case VK_NUMPAD6: return Keyboard::Numpad6; - case VK_NUMPAD7: return Keyboard::Numpad7; - case VK_NUMPAD8: return Keyboard::Numpad8; - case VK_NUMPAD9: return Keyboard::Numpad9; - case VK_NUMLOCK: return Keyboard::NumLock; - case VK_OEM_1: return Keyboard::Semicolon; - case VK_OEM_2: return Keyboard::Slash; - case VK_OEM_3: return Keyboard::Tilde; - case VK_APPS: return Keyboard::Menu; - case VK_OEM_102: return Keyboard::ISOBackslash102; - case VK_OEM_4: return Keyboard::LBracket; - case VK_OEM_5: return Keyboard::Backslash; - case VK_OEM_6: return Keyboard::RBracket; - case VK_OEM_7: return Keyboard::Quote; - case VK_OEM_COMMA: return Keyboard::Comma; - case VK_OEM_MINUS: return Keyboard::Dash; - case VK_OEM_PERIOD: return Keyboard::Period; - case VK_OEM_PLUS: return Keyboard::Equal; - case VK_RIGHT: return Keyboard::Right; - case VK_PRIOR: return Keyboard::PageUp; - case VK_PAUSE: return Keyboard::Pause; - case VK_PRINT: return Keyboard::Print; - case VK_SCROLL: return Keyboard::ScrollLock; - case VK_SNAPSHOT: return Keyboard::PrintScreen; - case VK_SUBTRACT: return Keyboard::Subtract; - case VK_RWIN: return Keyboard::RSystem; - case VK_SPACE: return Keyboard::Space; - case VK_TAB: return Keyboard::Tab; - case VK_UP: return Keyboard::Up; - case VK_VOLUME_DOWN: return Keyboard::Volume_Down; - case VK_VOLUME_MUTE: return Keyboard::Volume_Mute; - case VK_VOLUME_UP: return Keyboard::Volume_Up; - - default: - return Keyboard::Undefined; - } - } - - LRESULT CALLBACK WindowImpl::MessageHandler(HWND window, UINT message, WPARAM wParam, LPARAM lParam) - { - WindowImpl* me; - if (message == WM_CREATE) - { - me = static_cast(reinterpret_cast(lParam)->lpCreateParams); - SetWindowLongPtr(window, GWL_USERDATA, reinterpret_cast(me)); - } - else - me = reinterpret_cast(GetWindowLongPtr(window, GWL_USERDATA)); - - if (me) - { - if (me->HandleMessage(window, message, wParam, lParam)) - return 0; - else if (me->m_callback) - return CallWindowProcW(reinterpret_cast(me->m_callback), window, message, wParam, lParam); - } - - return DefWindowProcW(window, message, wParam, lParam); - } - - UInt32 WindowImpl::RetrieveStyle(HWND handle) - { - UInt32 style = 0; - - LONG_PTR winStyle = GetWindowLongPtr(handle, GWL_STYLE); - - // http://msdn.microsoft.com/en-us/library/windows/desktop/ms632600(v=vs.85).aspx - if (winStyle & WS_CAPTION) - { - style |= WindowStyle_Titlebar; - if (winStyle & WS_SYSMENU) - style |= WindowStyle_Closable; - - if (winStyle & WS_MAXIMIZEBOX) - style |= WindowStyle_Resizable; - } - - if (winStyle & WS_SIZEBOX) - style |= WindowStyle_Resizable; - - // Pour déterminer si la fenêtre est en plein écran, il suffit de vérifier si elle recouvre l'écran - DEVMODE mode; - mode.dmSize = sizeof(DEVMODE); - EnumDisplaySettings(nullptr, ENUM_CURRENT_SETTINGS, &mode); - - RECT rect; - if (GetWindowRect(handle, &rect)) - if (static_cast(rect.right - rect.left) == mode.dmPelsWidth && static_cast(rect.bottom - rect.top) == mode.dmPelsHeight) - style |= WindowStyle_Fullscreen; - - return style; - } - - void WindowImpl::WindowThread(HWND* handle, DWORD styleEx, const String& title, DWORD style, bool fullscreen, const Rectui& dimensions, WindowImpl* window, Mutex* mutex, ConditionVariable* condition) - { - HWND& winHandle = *handle; - winHandle = CreateWindowExW(styleEx, className, title.GetWideString().data(), style, dimensions.x, dimensions.y, dimensions.width, dimensions.height, nullptr, nullptr, GetModuleHandle(nullptr), window); - - if (winHandle) - window->PrepareWindow(fullscreen); - - mutex->Lock(); - condition->Signal(); - mutex->Unlock(); // mutex and condition may be destroyed after this line - - if (!winHandle) - return; - - while (window->m_threadActive) - window->ProcessEvents(true); - - DestroyWindow(winHandle); - } -} diff --git a/src/Nazara/Platform/Win32/WindowImpl.hpp b/src/Nazara/Platform/Win32/WindowImpl.hpp deleted file mode 100644 index 668108032..000000000 --- a/src/Nazara/Platform/Win32/WindowImpl.hpp +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Platform module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -// Interface inspirée de la SFML par Laurent Gomila - -#pragma once - -#ifndef NAZARA_WINDOWIMPL_HPP -#define NAZARA_WINDOWIMPL_HPP - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - class ConditionVariable; - class Mutex; - class Window; - - #undef IsMinimized // Conflits with windows.h redefinition - - class WindowImpl - { - public: - WindowImpl(Window* parent); - WindowImpl(const WindowImpl&) = delete; - WindowImpl(WindowImpl&&) = delete; ///TODO? - ~WindowImpl() = default; - - bool Create(const VideoMode& mode, const String& title, WindowStyleFlags style); - bool Create(WindowHandle handle); - - void Destroy(); - - void EnableKeyRepeat(bool enable); - void EnableSmoothScrolling(bool enable); - - WindowHandle GetHandle() const; - Vector2i GetPosition() const; - Vector2ui GetSize() const; - WindowStyleFlags GetStyle() const; - String GetTitle() const; - - bool HasFocus() const; - - void IgnoreNextMouseEvent(int mouseX, int mouseY); - - bool IsMinimized() const; - bool IsVisible() const; - - void RefreshCursor(); - - void ProcessEvents(bool block); - - void SetCursor(const Cursor& cursor); - void SetEventListener(bool listener); - void SetFocus(); - void SetIcon(const Icon& icon); - void SetMaximumSize(int width, int height); - void SetMinimumSize(int width, int height); - void SetPosition(int x, int y); - void SetSize(unsigned int width, unsigned int height); - void SetStayOnTop(bool stayOnTop); - void SetTitle(const String& title); - void SetVisible(bool visible); - - WindowImpl& operator=(const WindowImpl&) = delete; - WindowImpl& operator=(WindowImpl&&) = delete; ///TODO? - - static bool Initialize(); - static void Uninitialize(); - - private: - bool HandleMessage(HWND window, UINT message, WPARAM wParam, LPARAM lParam); - void PrepareWindow(bool fullscreen); - - static bool SetProcessDpiAware(); - - static Keyboard::Key ConvertVirtualKey(WPARAM key, LPARAM flags); - static LRESULT CALLBACK MessageHandler(HWND window, UINT message, WPARAM wParam, LPARAM lParam); - static UInt32 RetrieveStyle(HWND window); - static void WindowThread(HWND* handle, DWORD styleEx, const String& title, DWORD style, bool fullscreen, const Rectui& dimensions, WindowImpl* window, Mutex* mutex, ConditionVariable* condition); - - HCURSOR m_cursor; - HWND m_handle; - LONG_PTR m_callback; - WindowStyleFlags m_style; - Vector2i m_maxSize; - Vector2i m_minSize; - Vector2i m_mousePos; - Vector2i m_position; - Vector2ui m_size; - Thread m_thread; - Window* m_parent; - bool m_eventListener; - bool m_keyRepeat; - bool m_mouseInside; - bool m_ownsWindow; - bool m_sizemove; - bool m_smoothScrolling; - bool m_threadActive; - short m_scrolling; - }; -} - -#endif // NAZARA_WINDOWIMPL_HPP diff --git a/src/Nazara/Platform/Window.cpp b/src/Nazara/Platform/Window.cpp index 47c93d290..cfdba8cd1 100644 --- a/src/Nazara/Platform/Window.cpp +++ b/src/Nazara/Platform/Window.cpp @@ -8,17 +8,7 @@ #include #include #include - -#if defined(NAZARA_PLATFORM_SDL2) #include -#elif defined(NAZARA_PLATFORM_WINDOWS) - #include -#elif defined(NAZARA_PLATFORM_X11) - #include -#else - #error Lack of implementation: Window -#endif - #include namespace Nz diff --git a/src/Nazara/Platform/X11/CursorImpl.cpp b/src/Nazara/Platform/X11/CursorImpl.cpp deleted file mode 100644 index cee8cea88..000000000 --- a/src/Nazara/Platform/X11/CursorImpl.cpp +++ /dev/null @@ -1,270 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Platform module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include -#include - -// Some older versions of xcb/util-renderutil (notably the one available on Travis CI) use `template` as an argument name -// This is a fixed bug (https://cgit.freedesktop.org/xcb/util-renderutil/commit/?id=8d15acc45a47dc4c922eee5b99885db42bc62c17) but until Travis-CI -// has upgraded their Ubuntu version, I'm forced to use this ugly trick. -#define template ptemplate -extern "C" -{ - #include -} -#undef template - -#include - -namespace Nz -{ - bool CursorImpl::Create(const Image& cursor, int hotSpotX, int hotSpotY) - { - Image cursorImage(cursor); // Vive le COW - if (!cursorImage.Convert(Nz::PixelFormatType_BGRA8)) - { - NazaraError("Failed to convert cursor to BGRA8"); - return false; - } - - auto width = cursorImage.GetWidth(); - auto height = cursorImage.GetHeight(); - - ScopedXCBConnection connection; - - xcb_screen_t* screen = X11::XCBDefaultScreen(connection); - - ScopedXCB error(nullptr); - ScopedXCB formatsReply = xcb_render_query_pict_formats_reply( - connection, - xcb_render_query_pict_formats(connection), - &error); - - if (!formatsReply || error) - { - NazaraError("Failed to get pict formats"); - return false; - } - - xcb_render_pictforminfo_t* fmt = xcb_render_util_find_standard_format( - formatsReply.get(), - XCB_PICT_STANDARD_ARGB_32); - - if (!fmt) - { - NazaraError("Failed to find format PICT_STANDARD_ARGB_32"); - return false; - } - - xcb_image_t* xi = xcb_image_create( - width, height, - XCB_IMAGE_FORMAT_Z_PIXMAP, - 32, 32, 32, 32, - XCB_IMAGE_ORDER_LSB_FIRST, - XCB_IMAGE_ORDER_MSB_FIRST, - 0, 0, 0); - - if (!xi) - { - NazaraError("Failed to create image for cursor"); - return false; - } - - std::unique_ptr data(new uint8_t[xi->stride * height]); - - if (!data) - { - xcb_image_destroy(xi); - NazaraError("Failed to allocate memory for cursor image"); - return false; - } - - xi->data = data.get(); - - std::copy(cursorImage.GetConstPixels(), cursorImage.GetConstPixels() + cursorImage.GetBytesPerPixel() * width * height, xi->data); - - xcb_render_picture_t pic = XCB_NONE; - - CallOnExit onExit([&](){ - xcb_image_destroy(xi); - if (pic != XCB_NONE) - xcb_render_free_picture(connection, pic); - }); - - XCBPixmap pix(connection); - if (!pix.Create(32, screen->root, width, height)) - { - NazaraError("Failed to create pixmap for cursor"); - return false; - } - - pic = xcb_generate_id(connection); - if (!X11::CheckCookie( - connection, - xcb_render_create_picture( - connection, - pic, - pix, - fmt->id, - 0, - nullptr - ))) - { - NazaraError("Failed to create render picture for cursor"); - return false; - } - - XCBGContext gc(connection); - if (!gc.Create(pix, 0, nullptr)) - { - NazaraError("Failed to create gcontext for cursor"); - return false; - } - - if (!X11::CheckCookie( - connection, - xcb_image_put( - connection, - pix, - gc, - xi, - 0, 0, - 0 - ))) - { - NazaraError("Failed to put image for cursor"); - return false; - } - - m_cursor = xcb_generate_id(connection); - if (!X11::CheckCookie( - connection, - xcb_render_create_cursor( - connection, - m_cursor, - pic, - hotSpotX, hotSpotY - ))) - { - NazaraError("Failed to create cursor"); - return false; - } - - return true; - } - - bool CursorImpl::Create(SystemCursor cursor) - { - ScopedXCBConnection connection; - xcb_screen_t* screen = X11::XCBDefaultScreen(connection); - - const char* cursorName = s_systemCursorIds[cursor]; - if (cursorName) - { - if (xcb_cursor_context_new(connection, screen, &m_cursorContext) >= 0) - m_cursor = xcb_cursor_load_cursor(m_cursorContext, cursorName); - else - { - NazaraError("Failed to create cursor context"); - return false; - } - } - else - m_cursor = s_hiddenCursor; - - return true; - } - - void CursorImpl::Destroy() - { - ScopedXCBConnection connection; - - xcb_free_cursor(connection, m_cursor); - if (m_cursorContext) - xcb_cursor_context_free(m_cursorContext); - } - - xcb_cursor_t CursorImpl::GetCursor() - { - return m_cursor; - } - - bool CursorImpl::Initialize() - { - ScopedXCBConnection connection; - XCBPixmap cursorPixmap(connection); - - xcb_window_t window = X11::XCBDefaultRootWindow(connection); - - if (!cursorPixmap.Create(1, window, 1, 1)) - { - NazaraError("Failed to create pixmap for hidden cursor"); - return false; - } - - s_hiddenCursor = xcb_generate_id(connection); - - // Create the cursor, using the pixmap as both the shape and the mask of the cursor - if (!X11::CheckCookie( - connection, xcb_create_cursor(connection, - s_hiddenCursor, - cursorPixmap, - cursorPixmap, - 0, 0, 0, // Foreground RGB color - 0, 0, 0, // Background RGB color - 0, // X - 0 // Y - ))) - { - NazaraError("Failed to create hidden cursor"); - return false; - } - - return true; - } - - void CursorImpl::Uninitialize() - { - if (s_hiddenCursor) - { - ScopedXCBConnection connection; - xcb_free_cursor(connection, s_hiddenCursor); - s_hiddenCursor = 0; - } - } - - xcb_cursor_t CursorImpl::s_hiddenCursor = 0; - - std::array CursorImpl::s_systemCursorIds = - { - { - // http://gnome-look.org/content/preview.php?preview=1&id=128170&file1=128170-1.png&file2=&file3=&name=Dummy+X11+cursors&PHPSESSID=6 - "crosshair", // SystemCursor_Crosshair - "left_ptr", // SystemCursor_Default - "hand", // SystemCursor_Hand - "help", // SystemCursor_Help - "fleur", // SystemCursor_Move - nullptr, // SystemCursor_None - "hand", // SystemCursor_Pointer - "watch", // SystemCursor_Progress - "right_side", // SystemCursor_ResizeE - "top_side", // SystemCursor_ResizeN - "top_right_corner", // SystemCursor_ResizeNE - "top_left_corner", // SystemCursor_ResizeNW - "bottom_side", // SystemCursor_ResizeS - "bottom_right_corner", // SystemCursor_ResizeSE - "bottom_left_corner", // SystemCursor_ResizeSW - "left_side", // SystemCursor_ResizeW - "xterm", // SystemCursor_Text - "watch" // SystemCursor_Wait - } - }; - - static_assert(SystemCursor_Max + 1 == 18, "System cursor array is incomplete"); -} diff --git a/src/Nazara/Platform/X11/CursorImpl.hpp b/src/Nazara/Platform/X11/CursorImpl.hpp deleted file mode 100644 index 1c3ec15bf..000000000 --- a/src/Nazara/Platform/X11/CursorImpl.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Platform module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_CURSORIMPL_HPP -#define NAZARA_CURSORIMPL_HPP - -#include -#include -#include -#include - -namespace Nz -{ - class Image; - - class CursorImpl - { - friend class Cursor; - - public: - bool Create(const Image& image, int hotSpotX, int hotSpotY); - bool Create(SystemCursor cursor); - - void Destroy(); - - xcb_cursor_t GetCursor(); - - private: - static bool Initialize(); - static void Uninitialize(); - - xcb_cursor_t m_cursor = 0; - xcb_cursor_context_t* m_cursorContext = nullptr; - - static xcb_cursor_t s_hiddenCursor; - static std::array s_systemCursorIds; - }; -} - -#endif // NAZARA_CURSORIMPL_HPP diff --git a/src/Nazara/Platform/X11/Display.cpp b/src/Nazara/Platform/X11/Display.cpp deleted file mode 100644 index e24c1ef2f..000000000 --- a/src/Nazara/Platform/X11/Display.cpp +++ /dev/null @@ -1,247 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Platform module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - namespace - { - // The shared display and its reference counter - xcb_connection_t* sharedConnection = nullptr; - int screen_nbr = 0; - unsigned int referenceCountConnection = 0; - - xcb_key_symbols_t* sharedkeySymbol = nullptr; - unsigned int referenceCountKeySymbol = 0; - - xcb_ewmh_connection_t* sharedEwmhConnection = nullptr; - unsigned int referenceCountEwmhConnection = 0; - - using AtomMap = std::map; - AtomMap atoms; - } - - bool X11::CheckCookie(xcb_connection_t* connection, xcb_void_cookie_t cookie) - { - ScopedXCB error(xcb_request_check( - connection, - cookie - )); - - if (error) - return false; - else - return true; - } - - void X11::CloseConnection(xcb_connection_t* connection) - { - NazaraAssert(connection == sharedConnection, "The model is meant for one connection to X11 server"); - --referenceCountConnection; - } - - void X11::CloseEWMHConnection(xcb_ewmh_connection_t* ewmh_connection) - { - NazaraAssert(ewmh_connection == sharedEwmhConnection, "The model is meant for one connection to X11 server"); - --referenceCountEwmhConnection; - } - - xcb_atom_t X11::GetAtom(const String& name, bool onlyIfExists) - { - AtomMap::const_iterator iter = atoms.find(name); - - if (iter != atoms.end()) - return iter->second; - - ScopedXCB error(nullptr); - - xcb_connection_t* connection = OpenConnection(); - - ScopedXCB reply(xcb_intern_atom_reply( - connection, - xcb_intern_atom( - connection, - onlyIfExists, - name.GetSize(), - name.GetConstBuffer() - ), - &error - )); - - CloseConnection(connection); - - if (error || !reply) - { - NazaraError("Failed to get " + name + " atom."); - return XCB_ATOM_NONE; - } - - atoms[name] = reply->atom; - - return reply->atom; - } - - bool X11::Initialize() - { - if (IsInitialized()) - { - s_moduleReferenceCounter++; - return true; // Déjà initialisé - } - - s_moduleReferenceCounter++; - - NazaraAssert(referenceCountConnection == 0, "Initialize should be called before anything"); - NazaraAssert(referenceCountKeySymbol == 0, "Initialize should be called before anything"); - NazaraAssert(referenceCountEwmhConnection == 0, "Initialize should be called before anything"); - - { - sharedConnection = xcb_connect(nullptr, &screen_nbr); - - // Opening display failed: The best we can do at the moment is to output a meaningful error message - if (!sharedConnection || xcb_connection_has_error(sharedConnection)) - { - NazaraError("Failed to open xcb connection"); - return false; - } - - OpenConnection(); - } - - { - sharedkeySymbol = xcb_key_symbols_alloc(sharedConnection); - - XCBKeySymbolsAlloc(sharedConnection); - } - - { - sharedEwmhConnection = new xcb_ewmh_connection_t; - xcb_intern_atom_cookie_t* ewmh_cookie = xcb_ewmh_init_atoms(sharedConnection, sharedEwmhConnection); - - if(!xcb_ewmh_init_atoms_replies(sharedEwmhConnection, ewmh_cookie, nullptr)) - { - NazaraError("Could not initialize EWMH Connection"); - sharedEwmhConnection = nullptr; - } - - OpenEWMHConnection(sharedConnection); - } - - return true; - } - - bool X11::IsInitialized() - { - return s_moduleReferenceCounter != 0; - } - - xcb_key_symbols_t* X11::XCBKeySymbolsAlloc(xcb_connection_t* connection) - { - NazaraAssert(connection == sharedConnection, "The model is meant for one connection to X11 server"); - - ++referenceCountKeySymbol; - return sharedkeySymbol; - } - - void X11::XCBKeySymbolsFree(xcb_key_symbols_t* keySymbols) - { - NazaraAssert(keySymbols == sharedkeySymbol, "The model is meant for one connection to X11 server"); - - --referenceCountKeySymbol; - } - - xcb_connection_t* X11::OpenConnection() - { - ++referenceCountConnection; - return sharedConnection; - } - - xcb_ewmh_connection_t* X11::OpenEWMHConnection(xcb_connection_t* connection) - { - NazaraAssert(connection == sharedConnection, "The model is meant for one connection to X11 server"); - - ++referenceCountEwmhConnection; - return sharedEwmhConnection; - } - - void X11::Uninitialize() - { - if (s_moduleReferenceCounter != 1) - { - // Le module est soit encore utilisé, soit pas initialisé - if (s_moduleReferenceCounter > 1) - s_moduleReferenceCounter--; - - return; - } - - s_moduleReferenceCounter = 0; - - { - NazaraAssert(referenceCountEwmhConnection == 1, "Uninitialize should be called after anything or a close is missing"); - CloseEWMHConnection(sharedEwmhConnection); - - xcb_ewmh_connection_wipe(sharedEwmhConnection); - delete sharedEwmhConnection; - } - - { - NazaraAssert(referenceCountKeySymbol == 1, "Uninitialize should be called after anything or a free is missing"); - XCBKeySymbolsFree(sharedkeySymbol); - - xcb_key_symbols_free(sharedkeySymbol); - } - - { - NazaraAssert(referenceCountConnection == 1, "Uninitialize should be called after anything or a close is missing"); - CloseConnection(sharedConnection); - - xcb_disconnect(sharedConnection); - } - } - - xcb_window_t X11::XCBDefaultRootWindow(xcb_connection_t* connection) - { - NazaraAssert(connection == sharedConnection, "The model is meant for one connection to X11 server"); - xcb_screen_t* screen = XCBDefaultScreen(connection); - if (screen) - return screen->root; - return XCB_NONE; - } - - xcb_screen_t* X11::XCBDefaultScreen(xcb_connection_t* connection) - { - NazaraAssert(connection == sharedConnection, "The model is meant for one connection to X11 server"); - return XCBScreenOfDisplay(connection, screen_nbr); - } - - int X11::XCBScreen(xcb_connection_t* connection) - { - NazaraAssert(connection == sharedConnection, "The model is meant for one connection to X11 server"); - return screen_nbr; - } - - xcb_screen_t* X11::XCBScreenOfDisplay(xcb_connection_t* connection, int screenIndex) - { - NazaraAssert(connection == sharedConnection, "The model is meant for one connection to X11 server"); - xcb_screen_iterator_t iter = xcb_setup_roots_iterator(xcb_get_setup(connection)); - - for (; iter.rem; --screenIndex, xcb_screen_next (&iter)) - { - if (screenIndex == 0) - return iter.data; - } - - return nullptr; - } - - unsigned int X11::s_moduleReferenceCounter = 0; -} diff --git a/src/Nazara/Platform/X11/Display.hpp b/src/Nazara/Platform/X11/Display.hpp deleted file mode 100644 index 2746f30c1..000000000 --- a/src/Nazara/Platform/X11/Display.hpp +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Platform module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_X11DISPLAY_HPP -#define NAZARA_X11DISPLAY_HPP - -#include -#include -#include -#include - -typedef struct _XCBKeySymbols xcb_key_symbols_t; - -namespace Nz -{ - class String; - - class NAZARA_PLATFORM_API X11 - { - public: - X11() = delete; - ~X11() = delete; - - static bool CheckCookie(xcb_connection_t* connection, xcb_void_cookie_t cookie); - static void CloseConnection(xcb_connection_t* connection); - static void CloseEWMHConnection(xcb_ewmh_connection_t* ewmh_connection); - - static xcb_atom_t GetAtom(const String& name, bool onlyIfExists = false); - - static bool Initialize(); - static bool IsInitialized(); - - static xcb_key_symbols_t* XCBKeySymbolsAlloc(xcb_connection_t* connection); - static void XCBKeySymbolsFree(xcb_key_symbols_t* keySymbols); - - static xcb_connection_t* OpenConnection(); - static xcb_ewmh_connection_t* OpenEWMHConnection(xcb_connection_t* connection); - - static void Uninitialize(); - - static xcb_screen_t* XCBDefaultScreen(xcb_connection_t* connection); - static xcb_window_t XCBDefaultRootWindow(xcb_connection_t* connection); - static int XCBScreen(xcb_connection_t* connection); - static xcb_screen_t* XCBScreenOfDisplay(xcb_connection_t* connection, int screen_nbr); - - private: - static unsigned int s_moduleReferenceCounter; - }; -} - -#endif // NAZARA_X11DISPLAY_HPP diff --git a/src/Nazara/Platform/X11/IconImpl.cpp b/src/Nazara/Platform/X11/IconImpl.cpp deleted file mode 100644 index 5eb266122..000000000 --- a/src/Nazara/Platform/X11/IconImpl.cpp +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Platform module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - IconImpl::IconImpl() - { - ScopedXCBConnection connection; - - m_iconPixmap.Connect(connection); - m_maskPixmap.Connect(connection); - } - - bool IconImpl::Create(const Image& icon) - { - Image iconImage(icon); // Vive le COW - if (!iconImage.Convert(Nz::PixelFormatType_BGRA8)) - { - NazaraError("Failed to convert icon to BGRA8"); - return false; - } - - auto width = iconImage.GetWidth(); - auto height = iconImage.GetHeight(); - - ScopedXCBConnection connection; - - xcb_screen_t* screen = X11::XCBDefaultScreen(connection); - - if (!m_iconPixmap.Create( - screen->root_depth, - screen->root, - width, - height)) - { - NazaraError("Failed to create icon pixmap"); - return false; - } - - CallOnExit onExit([this](){ - Destroy(); - }); - - XCBGContext iconGC(connection); - - if (!iconGC.Create( - m_iconPixmap, - 0, - nullptr)) - { - NazaraError("Failed to create icon gc"); - return false; - } - - if (!X11::CheckCookie( - connection, - xcb_put_image( - connection, - XCB_IMAGE_FORMAT_Z_PIXMAP, - m_iconPixmap, - iconGC, - width, - height, - 0, - 0, - 0, - screen->root_depth, - width * height * 4, - iconImage.GetConstPixels() - ))) - { - NazaraError("Failed to put image for icon"); - return false; - } - - // Create the mask pixmap (must have 1 bit depth) - std::size_t pitch = (width + 7) / 8; - static std::vector maskPixels(pitch * height, 0); - for (std::size_t j = 0; j < height; ++j) - { - for (std::size_t i = 0; i < pitch; ++i) - { - for (std::size_t k = 0; k < 8; ++k) - { - if (i * 8 + k < width) - { - UInt8 opacity = (iconImage.GetConstPixels()[(i * 8 + k + j * width) * 4 + 3] > 0) ? 1 : 0; - maskPixels[i + j * pitch] |= (opacity << k); - } - } - } - } - - if (!m_maskPixmap.CreatePixmapFromBitmapData( - X11::XCBDefaultRootWindow(connection), - reinterpret_cast(&maskPixels[0]), - width, - height, - 1, - 0, - 1, - nullptr)) - { - NazaraError("Failed to create mask pixmap for icon"); - return false; - } - - onExit.Reset(); - - return true; - } - - void IconImpl::Destroy() - { - m_iconPixmap.Destroy(); - m_maskPixmap.Destroy(); - } - - xcb_pixmap_t IconImpl::GetIcon() - { - return m_iconPixmap; - } - - xcb_pixmap_t IconImpl::GetMask() - { - return m_maskPixmap; - } -} diff --git a/src/Nazara/Platform/X11/IconImpl.hpp b/src/Nazara/Platform/X11/IconImpl.hpp deleted file mode 100644 index 4e099d091..000000000 --- a/src/Nazara/Platform/X11/IconImpl.hpp +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Platform module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_ICONIMPL_HPP -#define NAZARA_ICONIMPL_HPP - -#include -#include - -namespace Nz -{ - class Image; - - class IconImpl - { - public: - IconImpl(); - - bool Create(const Image& image); - void Destroy(); - - xcb_pixmap_t GetIcon(); - xcb_pixmap_t GetMask(); - - private: - XCBPixmap m_iconPixmap; - XCBPixmap m_maskPixmap; - }; -} - -#endif // NAZARA_ICONIMPL_HPP diff --git a/src/Nazara/Platform/X11/InputImpl.cpp b/src/Nazara/Platform/X11/InputImpl.cpp deleted file mode 100644 index 5787e2d86..000000000 --- a/src/Nazara/Platform/X11/InputImpl.cpp +++ /dev/null @@ -1,393 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Platform module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - namespace - { - KeySym GetKeySym(Keyboard::Key key) - { - // X11 keysym correspondant - KeySym keysym = 0; - switch (key) - { - // Lettres - case Keyboard::A: keysym = XK_a; break; - case Keyboard::B: keysym = XK_b; break; - case Keyboard::C: keysym = XK_c; break; - case Keyboard::D: keysym = XK_d; break; - case Keyboard::E: keysym = XK_e; break; - case Keyboard::F: keysym = XK_f; break; - case Keyboard::G: keysym = XK_g; break; - case Keyboard::H: keysym = XK_h; break; - case Keyboard::I: keysym = XK_i; break; - case Keyboard::J: keysym = XK_j; break; - case Keyboard::K: keysym = XK_k; break; - case Keyboard::L: keysym = XK_l; break; - case Keyboard::M: keysym = XK_m; break; - case Keyboard::N: keysym = XK_n; break; - case Keyboard::O: keysym = XK_o; break; - case Keyboard::P: keysym = XK_p; break; - case Keyboard::Q: keysym = XK_q; break; - case Keyboard::R: keysym = XK_r; break; - case Keyboard::S: keysym = XK_s; break; - case Keyboard::T: keysym = XK_t; break; - case Keyboard::U: keysym = XK_u; break; - case Keyboard::V: keysym = XK_v; break; - case Keyboard::W: keysym = XK_w; break; - case Keyboard::X: keysym = XK_x; break; - case Keyboard::Y: keysym = XK_y; break; - case Keyboard::Z: keysym = XK_z; break; - - // Touches de fonction - case Keyboard::F1: keysym = XK_F1; break; - case Keyboard::F2: keysym = XK_F2; break; - case Keyboard::F3: keysym = XK_F3; break; - case Keyboard::F4: keysym = XK_F4; break; - case Keyboard::F5: keysym = XK_F5; break; - case Keyboard::F6: keysym = XK_F6; break; - case Keyboard::F7: keysym = XK_F7; break; - case Keyboard::F8: keysym = XK_F8; break; - case Keyboard::F9: keysym = XK_F9; break; - case Keyboard::F10: keysym = XK_F10; break; - case Keyboard::F11: keysym = XK_F11; break; - case Keyboard::F12: keysym = XK_F12; break; - case Keyboard::F13: keysym = XK_F13; break; - case Keyboard::F14: keysym = XK_F14; break; - case Keyboard::F15: keysym = XK_F15; break; - - // Flèches directionnelles - case Keyboard::Down: keysym = XK_Down; break; - case Keyboard::Left: keysym = XK_Left; break; - case Keyboard::Right: keysym = XK_Right; break; - case Keyboard::Up: keysym = XK_Up; break; - - // Pavé numérique - case Keyboard::Add: keysym = XK_KP_Add; break; - case Keyboard::Decimal: keysym = XK_KP_Decimal; break; - case Keyboard::Divide: keysym = XK_KP_Divide; break; - case Keyboard::Multiply: keysym = XK_KP_Multiply; break; - case Keyboard::NumpadReturn: keysym = XK_KP_Enter; break; - case Keyboard::Numpad0: keysym = XK_KP_0; break; - case Keyboard::Numpad1: keysym = XK_KP_1; break; - case Keyboard::Numpad2: keysym = XK_KP_2; break; - case Keyboard::Numpad3: keysym = XK_KP_3; break; - case Keyboard::Numpad4: keysym = XK_KP_4; break; - case Keyboard::Numpad5: keysym = XK_KP_5; break; - case Keyboard::Numpad6: keysym = XK_KP_6; break; - case Keyboard::Numpad7: keysym = XK_KP_7; break; - case Keyboard::Numpad8: keysym = XK_KP_8; break; - case Keyboard::Numpad9: keysym = XK_KP_9; break; - case Keyboard::Subtract: keysym = XK_KP_Subtract; break; - - // Divers - case Keyboard::Backslash: keysym = XK_backslash; break; - case Keyboard::Backspace: keysym = XK_BackSpace; break; - case Keyboard::Clear: keysym = XK_Clear; break; - case Keyboard::Comma: keysym = XK_comma; break; - case Keyboard::Dash: keysym = XK_minus; break; - case Keyboard::Delete: keysym = XK_Delete; break; - case Keyboard::End: keysym = XK_End; break; - case Keyboard::Equal: keysym = XK_equal; break; - case Keyboard::Escape: keysym = XK_Escape; break; - case Keyboard::Home: keysym = XK_Home; break; - case Keyboard::Insert: keysym = XK_Insert; break; - case Keyboard::LAlt: keysym = XK_Alt_L; break; - case Keyboard::LBracket: keysym = XK_bracketleft; break; - case Keyboard::LControl: keysym = XK_Control_L; break; - case Keyboard::LShift: keysym = XK_Shift_L; break; - case Keyboard::LSystem: keysym = XK_Super_L; break; - case Keyboard::Num0: keysym = XK_0; break; - case Keyboard::Num1: keysym = XK_1; break; - case Keyboard::Num2: keysym = XK_2; break; - case Keyboard::Num3: keysym = XK_3; break; - case Keyboard::Num4: keysym = XK_4; break; - case Keyboard::Num5: keysym = XK_5; break; - case Keyboard::Num6: keysym = XK_6; break; - case Keyboard::Num7: keysym = XK_7; break; - case Keyboard::Num8: keysym = XK_8; break; - case Keyboard::Num9: keysym = XK_9; break; - case Keyboard::PageDown: keysym = XK_Page_Down; break; - case Keyboard::PageUp: keysym = XK_Page_Up; break; - case Keyboard::Pause: keysym = XK_Pause; break; - case Keyboard::Period: keysym = XK_period; break; - case Keyboard::Print: keysym = XK_Print; break; - case Keyboard::PrintScreen: keysym = XK_Sys_Req; break; - case Keyboard::Quote: keysym = XK_quotedbl; break; - case Keyboard::RAlt: keysym = XK_Alt_R; break; - case Keyboard::RBracket: keysym = XK_bracketright; break; - case Keyboard::RControl: keysym = XK_Control_R; break; - case Keyboard::Return: keysym = XK_Return; break; - case Keyboard::RShift: keysym = XK_Shift_R; break; - case Keyboard::RSystem: keysym = XK_Super_R; break; - case Keyboard::Semicolon: keysym = XK_semicolon; break; - case Keyboard::Slash: keysym = XK_slash; break; - case Keyboard::Space: keysym = XK_space; break; - case Keyboard::Tab: keysym = XK_Tab; break; - case Keyboard::Tilde: keysym = XK_grave; break; - case Keyboard::Menu: keysym = XK_Menu; break; - case Keyboard::ISOBackslash102: keysym = XK_less; break; - - // Touches navigateur - case Keyboard::Browser_Back: keysym = XF86XK_Back; break; - case Keyboard::Browser_Favorites: keysym = XF86XK_Favorites; break; - case Keyboard::Browser_Forward: keysym = XF86XK_Forward; break; - case Keyboard::Browser_Home: keysym = XF86XK_HomePage; break; - case Keyboard::Browser_Refresh: keysym = XF86XK_Refresh; break; - case Keyboard::Browser_Search: keysym = XF86XK_Search; break; - case Keyboard::Browser_Stop: keysym = XF86XK_Stop; break; - - // Touches de contrôle - case Keyboard::Media_Next: keysym = XF86XK_AudioNext; break; - case Keyboard::Media_Play: keysym = XF86XK_AudioPlay; break; - case Keyboard::Media_Previous: keysym = XF86XK_AudioPrev; break; - case Keyboard::Media_Stop: keysym = XF86XK_AudioStop; break; - - // Touches de contrôle du volume - case Keyboard::Volume_Down: keysym = XF86XK_AudioLowerVolume; break; - case Keyboard::Volume_Mute: keysym = XF86XK_AudioMute; break; - case Keyboard::Volume_Up: keysym = XF86XK_AudioRaiseVolume; break; - - // Touches à verrouillage - case Keyboard::CapsLock: keysym = XK_Caps_Lock; break; - case Keyboard::NumLock: keysym = XK_Num_Lock; break; - case Keyboard::ScrollLock: keysym = XK_Scroll_Lock; break; - - default: break; - } - - // Sanity checks - if (key < 0 || key >= Keyboard::Count || keysym == 0) - NazaraWarning("Key " + String::Number(key) + " is not handled in Keyboard"); - - return keysym; - } - } - - String EventImpl::GetKeyName(Keyboard::Key key) - { - KeySym keySym = GetKeySym(key); - - // XKeysymToString returns a static area. - return XKeysymToString(keySym); - } - - Vector2i EventImpl::GetMousePosition() - { - ScopedXCBConnection connection; - - ScopedXCB error(nullptr); - - ScopedXCB pointer( - xcb_query_pointer_reply( - connection, - xcb_query_pointer( - connection, - X11::XCBDefaultRootWindow(connection) - ), - &error - ) - ); - - if (error) - { - NazaraError("Failed to query pointer"); - return Vector2i(-1, -1); - } - - return Vector2i(pointer->root_x, pointer->root_y); - } - - Vector2i EventImpl::GetMousePosition(const Window& relativeTo) - { - WindowHandle handle = relativeTo.GetHandle(); - if (handle) - { - // Open a connection with the X server - ScopedXCBConnection connection; - - ScopedXCB error(nullptr); - - ScopedXCB pointer( - xcb_query_pointer_reply( - connection, - xcb_query_pointer( - connection, - handle - ), - &error - ) - ); - - if (error) - { - NazaraError("Failed to query pointer"); - return Vector2i(-1, -1); - } - - return Vector2i(pointer->win_x, pointer->win_y); - } - else - { - NazaraError("No window handle"); - return Vector2i(-1, -1); - } - } - - bool EventImpl::IsKeyPressed(Keyboard::Key key) - { - ScopedXCBConnection connection; - - xcb_keysym_t keySym = GetKeySym(key); - - xcb_keycode_t realKeyCode = XCB_NO_SYMBOL; - - xcb_key_symbols_t* keySymbols = X11::XCBKeySymbolsAlloc(connection); - if (!keySymbols) - { - NazaraError("Failed to alloc key symbols"); - return false; - } - - ScopedXCB keyCode = xcb_key_symbols_get_keycode(keySymbols, keySym); - if (!keyCode) - { - NazaraError("Failed to get key code"); - return false; - } - - // One keysym is associated with multiple key codes, we have to find the matching one ... - int i = 0; - while (keyCode.get()[i] != XCB_NO_SYMBOL) - { - xcb_keycode_t toTry = keyCode.get()[i]; - if (keySym == xcb_key_symbols_get_keysym(keySymbols, toTry, 0)) - { - realKeyCode = toTry; - break; - } - ++i; - } - - X11::XCBKeySymbolsFree(keySymbols); - - ScopedXCB error(nullptr); - - // Get the whole keyboard state - ScopedXCB keymap( - xcb_query_keymap_reply( - connection, - xcb_query_keymap(connection), - &error - ) - ); - - if (error) - { - NazaraError("Failed to query keymap"); - return false; - } - - // Check our keycode - return (keymap->keys[realKeyCode / 8] & (1 << (realKeyCode % 8))) != 0; - } - - bool EventImpl::IsMouseButtonPressed(Mouse::Button button) - { - ScopedXCBConnection connection; - - ScopedXCB error(nullptr); - - // Get pointer mask - ScopedXCB pointer( - xcb_query_pointer_reply( - connection, - xcb_query_pointer( - connection, - X11::XCBDefaultRootWindow(connection) - ), - &error - ) - ); - - if (error) - { - NazaraError("Failed to query pointer"); - return false; - } - - uint16_t buttons = pointer->mask; - - switch (button) - { - case Mouse::Left: return buttons & XCB_BUTTON_MASK_1; - case Mouse::Right: return buttons & XCB_BUTTON_MASK_3; - case Mouse::Middle: return buttons & XCB_BUTTON_MASK_2; - case Mouse::XButton1: return false; // not supported by X - case Mouse::XButton2: return false; // not supported by X - } - - NazaraError("Mouse button not supported."); - return false; - } - - void EventImpl::SetMousePosition(int x, int y) - { - ScopedXCBConnection connection; - - xcb_window_t root = X11::XCBDefaultRootWindow(connection); - - if (!X11::CheckCookie( - connection, - xcb_warp_pointer( - connection, - None, // Source window - root, // Destination window - 0, 0, // Source position - 0, 0, // Source size - x, y // Destination position - )) - ) - NazaraError("Failed to set mouse position"); - - xcb_flush(connection); - } - - void EventImpl::SetMousePosition(int x, int y, const Window& relativeTo) - { - ScopedXCBConnection connection; - - WindowHandle handle = relativeTo.GetHandle(); - if (handle) - { - if (!X11::CheckCookie( - connection, - xcb_warp_pointer( - connection, - None, // Source window - handle, // Destination window - 0, 0, // Source position - 0, 0, // Source size - x, y // Destination position - )) - ) - NazaraError("Failed to set mouse position relative to window"); - - xcb_flush(connection); - } - else - NazaraError("No window handle"); - } -} diff --git a/src/Nazara/Platform/X11/InputImpl.hpp b/src/Nazara/Platform/X11/InputImpl.hpp deleted file mode 100644 index 5f82dc8e4..000000000 --- a/src/Nazara/Platform/X11/InputImpl.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Platform module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_INPUTIMPL_HPP -#define NAZARA_INPUTIMPL_HPP - -#include -#include -#include -#include -#include - -namespace Nz -{ - class EventImpl - { - public: - static String GetKeyName(Keyboard::Key key); - static Vector2i GetMousePosition(); - static Vector2i GetMousePosition(const Window& relativeTo); - static bool IsKeyPressed(Keyboard::Key key); - static bool IsMouseButtonPressed(Mouse::Button button); - static void SetMousePosition(int x, int y); - static void SetMousePosition(int x, int y, const Window& relativeTo); - }; -} - -#endif // NAZARA_INPUTIMPL_HPP diff --git a/src/Nazara/Platform/X11/ScopedXCB.cpp b/src/Nazara/Platform/X11/ScopedXCB.cpp deleted file mode 100644 index 9911fa760..000000000 --- a/src/Nazara/Platform/X11/ScopedXCB.cpp +++ /dev/null @@ -1,199 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Platform module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include - -namespace Nz -{ - /*********************************************** - ScopedXCBConnection - ***********************************************/ - - ScopedXCBConnection::ScopedXCBConnection() : - m_connection(nullptr) - { - m_connection = X11::OpenConnection(); - } - - ScopedXCBConnection::~ScopedXCBConnection() - { - X11::CloseConnection(m_connection); - } - - ScopedXCBConnection::operator xcb_connection_t*() const - { - return m_connection; - } - - /*********************************************** - ScopedXCBEWMHConnection - ***********************************************/ - - ScopedXCBEWMHConnection::ScopedXCBEWMHConnection(xcb_connection_t* connection) : - m_ewmhConnection(nullptr) - { - m_ewmhConnection = X11::OpenEWMHConnection(connection); - } - - ScopedXCBEWMHConnection::~ScopedXCBEWMHConnection() - { - X11::CloseEWMHConnection(m_ewmhConnection); - } - - xcb_ewmh_connection_t* ScopedXCBEWMHConnection::operator ->() const - { - return m_ewmhConnection; - } - - ScopedXCBEWMHConnection::operator xcb_ewmh_connection_t*() const - { - return m_ewmhConnection; - } - - /*********************************************** - XCBGContext - ***********************************************/ - - XCBGContext::XCBGContext(xcb_connection_t* connection) : - m_connection(connection), - m_gcontext(XCB_NONE) - { - NazaraAssert(connection, "Connection must have been established"); - } - - XCBGContext::~XCBGContext() - { - Destroy(); - } - - bool XCBGContext::Create(xcb_drawable_t drawable, uint32_t value_mask, const uint32_t* value_list) - { - NazaraAssert(m_gcontext == XCB_NONE, "Context must have been destroyed before or just created"); - - m_gcontext = xcb_generate_id(m_connection); - - return X11::CheckCookie( - m_connection, - xcb_create_gc( - m_connection, - m_gcontext, - drawable, - value_mask, - value_list - )); - } - - void XCBGContext::Destroy() - { - if (m_gcontext == XCB_NONE) - return; - - if (!X11::CheckCookie( - m_connection, - xcb_free_gc( - m_connection, - m_gcontext - )) - ) - NazaraError("Failed to free gcontext"); - - m_gcontext = XCB_NONE; - } - - XCBGContext::operator xcb_gcontext_t() const - { - return m_gcontext; - } - - /*********************************************** - XCBPixmap - ***********************************************/ - - XCBPixmap::XCBPixmap() : - m_connection(nullptr), - m_pixmap(XCB_NONE) - { - } - - XCBPixmap::XCBPixmap(xcb_connection_t* connection) : - m_connection(connection), - m_pixmap(XCB_NONE) - { - } - - XCBPixmap::~XCBPixmap() - { - Destroy(); - } - - void XCBPixmap::Connect(xcb_connection_t* connection) - { - NazaraAssert(connection && !m_connection, "Connection must be established"); - - m_connection = connection; - } - - bool XCBPixmap::Create(uint8_t depth, xcb_drawable_t drawable, uint16_t width, uint16_t height) - { - NazaraAssert(m_pixmap == XCB_NONE, "Pixmap must have been destroyed before or just created"); - - m_pixmap = xcb_generate_id(m_connection); - - return X11::CheckCookie( - m_connection, - xcb_create_pixmap( - m_connection, - depth, - m_pixmap, - drawable, - width, - height - )); - } - - bool XCBPixmap::CreatePixmapFromBitmapData(xcb_drawable_t drawable, uint8_t* data, uint32_t width, uint32_t height, uint32_t depth, uint32_t fg, uint32_t bg, xcb_gcontext_t* gcp) - { - NazaraAssert(m_pixmap == XCB_NONE, "Pixmap must have been destroyed before or just created"); - - m_pixmap = xcb_create_pixmap_from_bitmap_data( - m_connection, - drawable, - data, - width, - height, - depth, - fg, - bg, - gcp - ); - - return m_pixmap != XCB_NONE; - } - - void XCBPixmap::Destroy() - { - if (m_pixmap == XCB_NONE) - return; - - if (!X11::CheckCookie( - m_connection, - xcb_free_pixmap( - m_connection, - m_pixmap - )) - ) - NazaraError("Failed to free pixmap"); - - m_pixmap = XCB_NONE; - } - - XCBPixmap::operator xcb_pixmap_t() const - { - return m_pixmap; - } -} diff --git a/src/Nazara/Platform/X11/ScopedXCB.hpp b/src/Nazara/Platform/X11/ScopedXCB.hpp deleted file mode 100644 index fb4c26dab..000000000 --- a/src/Nazara/Platform/X11/ScopedXCB.hpp +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Platform module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_SCOPEDXCB_HPP -#define NAZARA_SCOPEDXCB_HPP - -#include -#include -#include -#include - -namespace Nz -{ - class ScopedXCBConnection - { - public: - ScopedXCBConnection(); - ~ScopedXCBConnection(); - - operator xcb_connection_t*() const; - - private: - xcb_connection_t* m_connection; - }; - - class ScopedXCBEWMHConnection - { - public: - ScopedXCBEWMHConnection(xcb_connection_t* connection); - ~ScopedXCBEWMHConnection(); - - xcb_ewmh_connection_t* operator ->() const; - - operator xcb_ewmh_connection_t*() const; - - private: - xcb_ewmh_connection_t* m_ewmhConnection; - }; - - template - class ScopedXCB - { - public: - ScopedXCB(T* pointer); - ~ScopedXCB(); - - T* operator ->() const; - T** operator &(); - - operator bool() const; - - T* get() const; - - private: - T* m_pointer; - }; - - class XCBGContext - { - public: - XCBGContext(xcb_connection_t* connection); - ~XCBGContext(); - - bool Create(xcb_drawable_t drawable, uint32_t value_mask, const uint32_t* value_list); - - void Destroy(); - - operator xcb_gcontext_t() const; - - private: - xcb_connection_t* m_connection; - xcb_gcontext_t m_gcontext; - }; - - class XCBPixmap - { - public: - XCBPixmap(); - XCBPixmap(xcb_connection_t* connection); - ~XCBPixmap(); - - void Connect(xcb_connection_t* connection); - bool Create(uint8_t depth, xcb_drawable_t drawable, uint16_t width, uint16_t height); - bool CreatePixmapFromBitmapData(xcb_drawable_t drawable, uint8_t* data, uint32_t width, uint32_t height, uint32_t depth, uint32_t fg, uint32_t bg, xcb_gcontext_t* gcp); - - void Destroy(); - - operator xcb_pixmap_t() const; - - private: - xcb_connection_t* m_connection; - xcb_pixmap_t m_pixmap; - }; -} - -#include - -#endif // NAZARA_SCOPEDXCB_HPP diff --git a/src/Nazara/Platform/X11/ScopedXCB.inl b/src/Nazara/Platform/X11/ScopedXCB.inl deleted file mode 100644 index 13c62bd56..000000000 --- a/src/Nazara/Platform/X11/ScopedXCB.inl +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Platform module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include - -namespace Nz -{ - template - ScopedXCB::ScopedXCB(T* pointer) : - m_pointer(pointer) - { - } - - template - ScopedXCB::~ScopedXCB() - { - std::free(m_pointer); - } - - template - T* ScopedXCB::operator ->() const - { - return m_pointer; - } - - template - T** ScopedXCB::operator &() - { - return &m_pointer; - } - - template - ScopedXCB::operator bool() const - { - return m_pointer != nullptr; - } - - template - T* ScopedXCB::get() const - { - return m_pointer; - } -} - -#include diff --git a/src/Nazara/Platform/X11/VideoModeImpl.cpp b/src/Nazara/Platform/X11/VideoModeImpl.cpp deleted file mode 100644 index 26a2bc32c..000000000 --- a/src/Nazara/Platform/X11/VideoModeImpl.cpp +++ /dev/null @@ -1,170 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Platform module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - VideoMode VideoModeImpl::GetDesktopMode() - { - VideoMode desktopMode; - - ScopedXCBConnection connection; - - // Retrieve the default screen - xcb_screen_t* screen = X11::XCBDefaultScreen(connection); - - ScopedXCB error(nullptr); - - // Check if the RandR extension is present - const xcb_query_extension_reply_t* randrExt = xcb_get_extension_data(connection, &xcb_randr_id); - - if (!randrExt || !randrExt->present) - { - // Randr extension is not supported: we cannot get the video modes - NazaraError("Failed to use the RandR extension while trying to get the desktop video mode"); - return desktopMode; - } - - // Load RandR and check its version - ScopedXCB randrVersion(xcb_randr_query_version_reply( - connection, - xcb_randr_query_version( - connection, - 1, - 1 - ), - &error - )); - - if (error) - { - NazaraError("Failed to load the RandR extension while trying to get the desktop video mode"); - return desktopMode; - } - - // Get the current configuration - ScopedXCB config(xcb_randr_get_screen_info_reply( - connection, - xcb_randr_get_screen_info( - connection, - screen->root - ), - &error - )); - - if (error) - { - // Failed to get the screen configuration - NazaraError("Failed to retrieve the screen configuration while trying to get the desktop video mode"); - return desktopMode; - } - - // Get the current video mode - xcb_randr_mode_t currentMode = config->sizeID; - - // Get the available screen sizes - int nbSizes = xcb_randr_get_screen_info_sizes_length(config.get()); - xcb_randr_screen_size_t* sizes = xcb_randr_get_screen_info_sizes(config.get()); - if (sizes && (nbSizes > 0)) - { - desktopMode = VideoMode(sizes[currentMode].width, sizes[currentMode].height, screen->root_depth); - - if (config->rotation == XCB_RANDR_ROTATION_ROTATE_90 || - config->rotation == XCB_RANDR_ROTATION_ROTATE_270) - std::swap(desktopMode.width, desktopMode.height); - } - else - { - NazaraError("Failed to retrieve any screen sizes while trying to get the desktop video mode"); - } - - return desktopMode; - } - - void VideoModeImpl::GetFullscreenModes(std::vector& modes) - { - ScopedXCBConnection connection; - - // Retrieve the default screen - xcb_screen_t* screen = X11::XCBDefaultScreen(connection); - - ScopedXCB error(nullptr); - - const xcb_query_extension_reply_t* randrExt = xcb_get_extension_data(connection, &xcb_randr_id); - - if (!randrExt || !randrExt->present) - { - // Randr extension is not supported: we cannot get the video modes - NazaraError("Failed to use the RandR extension while trying to get the supported video modes"); - return; - } - - // Load RandR and check its version - ScopedXCB randrVersion(xcb_randr_query_version_reply( - connection, - xcb_randr_query_version( - connection, - 1, - 1 - ), - &error - )); - - if (error) - { - NazaraError("Failed to load the RandR extension while trying to get the supported video modes"); - return; - } - - // Get the current configuration - ScopedXCB config(xcb_randr_get_screen_info_reply( - connection, - xcb_randr_get_screen_info( - connection, - screen->root - ), - &error - )); - - if (error) - { - // Failed to get the screen configuration - NazaraError("Failed to retrieve the screen configuration while trying to get the supported video modes"); - return; - } - - // Get the available screen sizes - xcb_randr_screen_size_t* sizes = xcb_randr_get_screen_info_sizes(config.get()); - if (sizes && (config->nSizes > 0)) - { - // Get the list of supported depths - xcb_depth_iterator_t iter = xcb_screen_allowed_depths_iterator(screen); - // Combine depths and sizes to fill the array of supported modes - for (; iter.rem; xcb_depth_next(&iter)) - { - for (int j = 0; j < config->nSizes; ++j) - { - // Convert to VideoMode - VideoMode mode(sizes[j].width, sizes[j].height, iter.data->depth); - - if (config->rotation == XCB_RANDR_ROTATION_ROTATE_90 || - config->rotation == XCB_RANDR_ROTATION_ROTATE_270) - std::swap(mode.width, mode.height); - - // Add it only if it is not already in the array - if (std::find(modes.begin(), modes.end(), mode) == modes.end()) - modes.push_back(mode); - } - } - } - } -} diff --git a/src/Nazara/Platform/X11/VideoModeImpl.hpp b/src/Nazara/Platform/X11/VideoModeImpl.hpp deleted file mode 100644 index a182239b0..000000000 --- a/src/Nazara/Platform/X11/VideoModeImpl.hpp +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Platform module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_VIDEOMODEIMPL_HPP -#define NAZARA_VIDEOMODEIMPL_HPP - -#include -#include - -namespace Nz -{ - class VideoModeImpl - { - public: - static VideoMode GetDesktopMode(); - static void GetFullscreenModes(std::vector& modes); - }; -} - -#endif // NNAZARA_VIDEOMODEIMPL_HPP diff --git a/src/Nazara/Platform/X11/WindowImpl.cpp b/src/Nazara/Platform/X11/WindowImpl.cpp deleted file mode 100644 index eda4453ea..000000000 --- a/src/Nazara/Platform/X11/WindowImpl.cpp +++ /dev/null @@ -1,1589 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Platform module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -// Un grand merci à Laurent Gomila pour la SFML qui m'aura bien aidé à réaliser cette implémentation - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* - Things to do left: - - Icon working sometimes (No idea) - EnableKeyRepeat (Working but is it the right behaviour ?) - Fullscreen (No alt + tab) - Smooth scroll (No equivalent for X11) - Threaded window (Not tested a lot) - Event listener (Not tested) - Cleanup - IsVisible (Not working as expected) - SetStayOnTop (Equivalent for X11 ?) - Opengl Context (glXCreateContextAttribs should be loaded like in window and the version for the context should be the one of NzContextParameters) - - */ - -namespace Nz -{ - namespace - { - Nz::WindowImpl* fullscreenWindow = nullptr; - - const uint32_t eventMask = XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_BUTTON_PRESS | - XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_BUTTON_MOTION | - XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_KEY_PRESS | - XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_STRUCTURE_NOTIFY | - XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW; - - xcb_connection_t* connection = nullptr; - } - - WindowImpl::WindowImpl(Window* parent) : - m_window(0), - m_style(0), - m_parent(parent), - m_smoothScrolling(false), - m_mousePos(0, 0), - m_keyRepeat(true) - { - std::memset(&m_size_hints, 0, sizeof(m_size_hints)); - } - - WindowImpl::~WindowImpl() - { - // Cleanup graphical resources - CleanUp(); - - // We clean up the event queue - UpdateEventQueue(nullptr); - UpdateEventQueue(nullptr); - } - - bool WindowImpl::Create(const VideoMode& mode, const String& title, WindowStyleFlags style) - { - bool fullscreen = (style & Nz::WindowStyle_Fullscreen) != 0; - m_eventListener = true; - m_ownsWindow = true; - m_style = style; - - std::memset(&m_oldVideoMode, 0, sizeof(m_oldVideoMode)); - - m_screen = X11::XCBDefaultScreen(connection); - - // Compute position and size - int left = fullscreen ? 0 : (m_screen->width_in_pixels - mode.width) / 2; - int top = fullscreen ? 0 : (m_screen->height_in_pixels - mode.height) / 2; - int width = mode.width; - int height = mode.height; - - // Define the window attributes - xcb_colormap_t colormap = xcb_generate_id(connection); - xcb_create_colormap(connection, XCB_COLORMAP_ALLOC_NONE, colormap, m_screen->root, m_screen->root_visual); - const uint32_t value_list[] = { fullscreen, eventMask, colormap }; - - CallOnExit onExit([&](){ - if (!X11::CheckCookie( - connection, - xcb_free_colormap( - connection, - colormap - )) - ) - NazaraError("Failed to free colormap"); - }); - - // Create the window - m_window = xcb_generate_id(connection); - - if (!X11::CheckCookie( - connection, - xcb_create_window_checked( - connection, - XCB_COPY_FROM_PARENT, - m_window, - m_screen->root, - left, top, - width, height, - 0, - XCB_WINDOW_CLASS_INPUT_OUTPUT, - m_screen->root_visual, - XCB_CW_EVENT_MASK | XCB_CW_OVERRIDE_REDIRECT | XCB_CW_COLORMAP, - value_list - ))) - { - NazaraError("Failed to create window"); - return false; - } - - // Flush the commands queue - xcb_flush(connection); - - // We get default normal hints for the new window - ScopedXCB error(nullptr); - xcb_icccm_get_wm_normal_hints_reply( - connection, - xcb_icccm_get_wm_normal_hints( - connection, - m_window), - &m_size_hints, - &error - ); - if (error) - NazaraError("Failed to get size hints"); - - // And we modify the size and the position. - xcb_icccm_size_hints_set_position(&m_size_hints, false, left, top); - xcb_icccm_size_hints_set_size(&m_size_hints, false, width, height); - if (!UpdateNormalHints()) - NazaraError("Failed to set window configuration"); - - // Do some common initializations - CommonInitialize(); - - if (!(m_style & Nz::WindowStyle_Fullscreen)) - SetMotifHints(); - - // Flush the commands queue - xcb_flush(connection); - - // Set the window's name - SetTitle(title); - - if (m_style & WindowStyle_Threaded) - { - Mutex mutex; - ConditionVariable condition; - m_threadActive = true; - - // Wait until the thread is ready - mutex.Lock(); - m_thread = Thread(WindowThread, this, &mutex, &condition); - condition.Wait(&mutex); - mutex.Unlock(); - } - - // Set fullscreen video mode and switch to fullscreen if necessary - if (fullscreen) - { - SetPosition(0, 0); - SetVideoMode(mode); - SwitchToFullscreen(); - } - - return true; - } - - bool WindowImpl::Create(WindowHandle handle) - { - std::memset(&m_oldVideoMode, 0, sizeof(m_oldVideoMode)); - - m_screen = X11::XCBDefaultScreen(connection); - - if (!handle) - { - NazaraError("Invalid handle"); - return false; - } - - // Save the window handle - m_window = handle; - - m_ownsWindow = false; - m_eventListener = false; - - ScopedXCB error(nullptr); - - // We try to get informations from the shared window. - xcb_icccm_get_wm_normal_hints_reply( - connection, - xcb_icccm_get_wm_normal_hints( - connection, - m_window), - &m_size_hints, - &error - ); - - if (error) - { - NazaraError("Failed to obtain sizes and positions"); - return false; - } - - // Do some common initializations - CommonInitialize(); - - // Flush the commands queue - xcb_flush(connection); - - return true; - } - - void WindowImpl::Destroy() - { - if (m_ownsWindow) - { - if (m_style & WindowStyle_Threaded) - if (m_thread.IsJoinable()) - { - m_threadActive = false; - m_thread.Join(); - } - - // Destroy the window - if (m_window && m_ownsWindow) - { - // Unhide the mouse cursor (in case it was hidden) - SetCursor(*Cursor::Get(SystemCursor_Default)); - - if (!X11::CheckCookie( - connection, - xcb_destroy_window( - connection, - m_window - ))) - NazaraError("Failed to destroy window"); - - xcb_flush(connection); - } - } - else - SetEventListener(false); - } - - void WindowImpl::EnableKeyRepeat(bool enable) - { - m_keyRepeat = enable; - } - - void WindowImpl::EnableSmoothScrolling(bool enable) - { - m_smoothScrolling = enable; - } - - WindowHandle WindowImpl::GetHandle() const - { - return m_window; - } - - unsigned int WindowImpl::GetHeight() const - { - return m_size_hints.height; - } - - Vector2i WindowImpl::GetPosition() const - { - return { m_size_hints.x, m_size_hints.y }; - } - - Vector2ui WindowImpl::GetSize() const - { - return Vector2ui(m_size_hints.width, m_size_hints.height); - } - - WindowStyleFlags WindowImpl::GetStyle() const - { - return m_style; - } - - String WindowImpl::GetTitle() const - { - ScopedXCBEWMHConnection ewmhConnection(connection); - - ScopedXCB error(nullptr); - - xcb_ewmh_get_utf8_strings_reply_t data; - xcb_ewmh_get_wm_name_reply(ewmhConnection, - xcb_ewmh_get_wm_name(ewmhConnection, m_window), &data, &error); - - if (error) - NazaraError("Failed to get window's title"); - - String tmp(data.strings, data.strings_len); - - xcb_ewmh_get_utf8_strings_reply_wipe(&data); - - return tmp; - } - - unsigned int WindowImpl::GetWidth() const - { - return m_size_hints.width; - } - - bool WindowImpl::HasFocus() const - { - ScopedXCB error(nullptr); - - ScopedXCB reply(xcb_get_input_focus_reply( - connection, - xcb_get_input_focus_unchecked( - connection - ), - &error - )); - - if (error) - NazaraError("Failed to check if window has focus"); - - return reply->focus == m_window; - } - - void WindowImpl::IgnoreNextMouseEvent(int mouseX, int mouseY) - { - // Petite astuce ... - m_mousePos.x = mouseX; - m_mousePos.y = mouseY; - } - - bool WindowImpl::IsMinimized() const - { - ScopedXCBEWMHConnection ewmhConnection(connection); - - ScopedXCB error(nullptr); - bool isMinimized = false; - - xcb_ewmh_get_atoms_reply_t atomReply; - if (xcb_ewmh_get_wm_state_reply(ewmhConnection, - xcb_ewmh_get_wm_state(ewmhConnection, m_window), &atomReply, &error) == 1) - { - for (unsigned int i = 0; i < atomReply.atoms_len; i++) - if (atomReply.atoms[i] == ewmhConnection->_NET_WM_STATE_HIDDEN) - isMinimized = true; - - xcb_ewmh_get_atoms_reply_wipe(&atomReply); - } - - if (error) - NazaraError("Failed to determine if window is minimized"); - - return isMinimized; - } - - bool WindowImpl::IsVisible() const - { - return !IsMinimized(); // Visibility event ? - } - - void WindowImpl::ProcessEvents(bool block) - { - if (m_ownsWindow) - { - xcb_generic_event_t* event = nullptr; - - if (block) - { - event = xcb_wait_for_event(connection); - if (event) - { - UpdateEventQueue(event); - ProcessEvent(event); - } - } - else - { - event = xcb_poll_for_event(connection); - while (event) - { - UpdateEventQueue(event); - xcb_generic_event_t* tmp = xcb_poll_for_event(connection); - UpdateEventQueue(tmp); - ProcessEvent(event); - if (tmp) - ProcessEvent(tmp); - event = xcb_poll_for_event(connection); - } - } - } - } - - void WindowImpl::RefreshCursor() - { - } - - void WindowImpl::SetCursor(const Cursor& cursor) - { - xcb_cursor_t cursorImpl = cursor.m_impl->GetCursor(); - if (!X11::CheckCookie(connection, xcb_change_window_attributes(connection, m_window, XCB_CW_CURSOR, &cursorImpl))) - NazaraError("Failed to change mouse cursor"); - - xcb_flush(connection); - } - - void WindowImpl::SetEventListener(bool listener) - { - if (m_ownsWindow) - m_eventListener = listener; - else if (listener != m_eventListener) - { - if (listener) - { - const uint32_t value_list[] = { eventMask }; - - if (!X11::CheckCookie( - connection, - xcb_change_window_attributes( - connection, - m_window, - XCB_CW_EVENT_MASK, - value_list - )) - ) - NazaraError("Failed to change event for listener"); - - m_eventListener = true; - } - else if (m_eventListener) - { - const uint32_t value_list[] = { XCB_EVENT_MASK_NO_EVENT }; - - if (!X11::CheckCookie( - connection, - xcb_change_window_attributes( - connection, - m_window, - XCB_CW_EVENT_MASK, - value_list - )) - ) - NazaraError("Failed to change event for listener"); - - m_eventListener = false; - } - } - } - - void WindowImpl::SetFocus() - { - if (!X11::CheckCookie( - connection, - xcb_set_input_focus( - connection, - XCB_INPUT_FOCUS_POINTER_ROOT, - m_window, - XCB_CURRENT_TIME - )) - ) - NazaraError("Failed to set input focus"); - - const uint32_t values[] = { XCB_STACK_MODE_ABOVE }; - - if (!X11::CheckCookie( - connection, - xcb_configure_window( - connection, - m_window, - XCB_CONFIG_WINDOW_STACK_MODE, - values - )) - ) - NazaraError("Failed to set focus"); - } - - void WindowImpl::SetIcon(const Icon& icon) - { - if (!icon.IsValid()) - { - NazaraError("Icon is not valid"); - return; - } - - xcb_pixmap_t icon_pixmap = icon.m_impl->GetIcon(); - xcb_pixmap_t mask_pixmap = icon.m_impl->GetMask(); - - ScopedXCB error(nullptr); - - xcb_icccm_wm_hints_t hints; - std::memset(&hints, 0, sizeof(hints)); - - xcb_icccm_get_wm_hints_reply( - connection, - xcb_icccm_get_wm_hints( - connection, - m_window), - &hints, - &error - ); - - if (error) - NazaraError("Failed to get wm hints"); - - xcb_icccm_wm_hints_set_icon_pixmap(&hints, icon_pixmap); - xcb_icccm_wm_hints_set_icon_mask(&hints, mask_pixmap); - - if (!X11::CheckCookie( - connection, - xcb_icccm_set_wm_hints( - connection, - m_window, - &hints - )) - ) - NazaraError("Failed to set wm hints"); - - xcb_flush(connection); - } - - void WindowImpl::SetMaximumSize(int width, int height) - { - if (width < 0) - width = m_screen->width_in_pixels; - if (height < 0) - height = m_screen->height_in_pixels; - - xcb_icccm_size_hints_set_max_size(&m_size_hints, width, height); - if (!UpdateNormalHints()) - NazaraError("Failed to set maximum size"); - - xcb_flush(connection); - } - - void WindowImpl::SetMinimumSize(int width, int height) - { - xcb_icccm_size_hints_set_min_size(&m_size_hints, width, height); - if (!UpdateNormalHints()) - NazaraError("Failed to set minimum size"); - - xcb_flush(connection); - } - - void WindowImpl::SetPosition(int x, int y) - { - xcb_icccm_size_hints_set_position(&m_size_hints, true, x, y); - if (!UpdateNormalHints()) - NazaraError("Failed to set size hints position"); - - const uint32_t values[] = { static_cast(x), static_cast(y) }; - if (!X11::CheckCookie( - connection, - xcb_configure_window( - connection, - m_window, - XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, - values - )) - ) - NazaraError("Failed to set position"); - - xcb_flush(connection); - } - - void WindowImpl::SetSize(unsigned int width, unsigned int height) - { - xcb_icccm_size_hints_set_size(&m_size_hints, true, width, height); - if (!UpdateNormalHints()) - NazaraError("Failed to set size hints sizes"); - - const uint32_t values[] = { width, height }; - if (!X11::CheckCookie( - connection, - xcb_configure_window( - connection, - m_window, - XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT, - values - )) - ) - NazaraError("Failed to set sizes"); - - xcb_flush(connection); - } - - void WindowImpl::SetStayOnTop(bool stayOnTop) - { - ScopedXCBEWMHConnection ewmhConnection(connection); - - xcb_atom_t onTop; // It is not really working - if (stayOnTop) - onTop = ewmhConnection->_NET_WM_STATE_ABOVE; - else - onTop = ewmhConnection->_NET_WM_STATE_BELOW; - - if (!X11::CheckCookie( - connection, - xcb_ewmh_set_wm_state( - ewmhConnection, - m_window, - 1, - &onTop - )) - ) - NazaraError("Failed to set stay on top"); - - xcb_flush(connection); - } - - void WindowImpl::SetTitle(const String& title) - { - ScopedXCBEWMHConnection ewmhConnection(connection); - - if (!X11::CheckCookie( - connection, - xcb_ewmh_set_wm_name( - ewmhConnection, - m_window, - title.GetSize(), - title.GetConstBuffer() - )) - ) - NazaraError("Failed to set title"); - - xcb_flush(connection); - } - - void WindowImpl::SetVisible(bool visible) - { - if (visible) - { - if (!X11::CheckCookie( - connection, - xcb_map_window( - connection, - m_window - )) - ) - NazaraError("Failed to change window visibility to visible"); - } - else if (!X11::CheckCookie( - connection, - xcb_unmap_window( - connection, - m_window - )) - ) - NazaraError("Failed to change window visibility to invisible"); - - xcb_flush(connection); - } - - bool WindowImpl::Initialize() - { - X11::Initialize(); - - connection = X11::OpenConnection(); - - return true; - } - - void WindowImpl::Uninitialize() - { - X11::CloseConnection(connection); - - X11::Uninitialize(); - } - - void WindowImpl::CleanUp() - { - // Restore the previous video mode (in case we were running in fullscreen) - ResetVideoMode(); - } - - xcb_keysym_t WindowImpl::ConvertKeyCodeToKeySym(xcb_keycode_t keycode, uint16_t state) - { - xcb_key_symbols_t* keysyms = X11::XCBKeySymbolsAlloc(connection); - if (!keysyms) - { - NazaraError("Failed to get key symbols"); - return XCB_NO_SYMBOL; - } - - xcb_keysym_t k0, k1; - - CallOnExit onExit([&](){ - X11::XCBKeySymbolsFree(keysyms); - }); - - // Based on documentation in https://cgit.freedesktop.org/xcb/util-keysyms/tree/keysyms/keysyms.c - // Mode switch = ctlr and alt gr = XCB_MOD_MASK_5 - - // The first four elements of the list are split into two groups of KeySyms. - if (state & XCB_MOD_MASK_1) - { - k0 = xcb_key_symbols_get_keysym(keysyms, keycode, 2); - k1 = xcb_key_symbols_get_keysym(keysyms, keycode, 3); - } - if (state & XCB_MOD_MASK_5) - { - k0 = xcb_key_symbols_get_keysym(keysyms, keycode, 4); - k1 = xcb_key_symbols_get_keysym(keysyms, keycode, 5); - } - else - { - k0 = xcb_key_symbols_get_keysym(keysyms, keycode, 0); - k1 = xcb_key_symbols_get_keysym(keysyms, keycode, 1); - } - - // If the second element of the group is NoSymbol, then the group should be treated as if the second element were the same as the first element. - if (k1 == XCB_NO_SYMBOL) - k1 = k0; - - /* The numlock modifier is on and the second KeySym is a keypad KeySym - The numlock modifier is on and the second KeySym is a keypad KeySym. In - this case, if the Shift modifier is on, or if the Lock modifier is on - and is interpreted as ShiftLock, then the first KeySym is used, - otherwise the second KeySym is used. - */ - if ((state & XCB_MOD_MASK_2) && xcb_is_keypad_key(k1)) - { - if ((state & XCB_MOD_MASK_SHIFT) || (state & XCB_MOD_MASK_LOCK && (state & XCB_MOD_MASK_SHIFT))) - return k0; - else - return k1; - } - - /* The Shift and Lock modifiers are both off. In this case, the first - KeySym is used.*/ - else if (!(state & XCB_MOD_MASK_SHIFT) && !(state & XCB_MOD_MASK_LOCK)) - return k0; - - /* The Shift modifier is off, and the Lock modifier is on and is - interpreted as CapsLock. In this case, the first KeySym is used, but - if that KeySym is lowercase alphabetic, then the corresponding - uppercase KeySym is used instead. */ - else if (!(state & XCB_MOD_MASK_SHIFT) && (state & XCB_MOD_MASK_LOCK && (state & XCB_MOD_MASK_SHIFT))) - return k0; - - /* The Shift modifier is on, and the Lock modifier is on and is - interpreted as CapsLock. In this case, the second KeySym is used, but - if that KeySym is lowercase alphabetic, then the corresponding - uppercase KeySym is used instead.*/ - else if ((state & XCB_MOD_MASK_SHIFT) && (state & XCB_MOD_MASK_LOCK && (state & XCB_MOD_MASK_SHIFT))) - return k1; - - /* The Shift modifier is on, or the Lock modifier is on and is - interpreted as ShiftLock, or both. In this case, the second KeySym is - used. */ - else if ((state & XCB_MOD_MASK_SHIFT) || (state & XCB_MOD_MASK_LOCK && (state & XCB_MOD_MASK_SHIFT))) - return k1; - - return XCB_NO_SYMBOL; - } - - Keyboard::Key WindowImpl::ConvertVirtualKey(xcb_keysym_t symbol) - { - // First convert to uppercase (to avoid dealing with two different keysyms for the same key) - KeySym lower, key; - XConvertCase(symbol, &lower, &key); - - switch (key) - { - // Lettres - case XK_A: return Keyboard::A; - case XK_B: return Keyboard::B; - case XK_C: return Keyboard::C; - case XK_D: return Keyboard::D; - case XK_E: return Keyboard::E; - case XK_F: return Keyboard::F; - case XK_G: return Keyboard::G; - case XK_H: return Keyboard::H; - case XK_I: return Keyboard::I; - case XK_J: return Keyboard::J; - case XK_K: return Keyboard::K; - case XK_L: return Keyboard::L; - case XK_M: return Keyboard::M; - case XK_N: return Keyboard::N; - case XK_O: return Keyboard::O; - case XK_P: return Keyboard::P; - case XK_Q: return Keyboard::Q; - case XK_R: return Keyboard::R; - case XK_S: return Keyboard::S; - case XK_T: return Keyboard::T; - case XK_U: return Keyboard::U; - case XK_V: return Keyboard::V; - case XK_W: return Keyboard::W; - case XK_X: return Keyboard::X; - case XK_Y: return Keyboard::Y; - case XK_Z: return Keyboard::Z; - - // Touches de fonction - case XK_F1: return Keyboard::F1; - case XK_F2: return Keyboard::F2; - case XK_F3: return Keyboard::F3; - case XK_F4: return Keyboard::F4; - case XK_F5: return Keyboard::F5; - case XK_F6: return Keyboard::F6; - case XK_F7: return Keyboard::F7; - case XK_F8: return Keyboard::F8; - case XK_F9: return Keyboard::F9; - case XK_F10: return Keyboard::F10; - case XK_F11: return Keyboard::F11; - case XK_F12: return Keyboard::F12; - case XK_F13: return Keyboard::F13; - case XK_F14: return Keyboard::F14; - case XK_F15: return Keyboard::F15; - - // Flèches directionnelles - case XK_Down: return Keyboard::Down; - case XK_Left: return Keyboard::Left; - case XK_Right: return Keyboard::Right; - case XK_Up: return Keyboard::Up; - - // Pavé numérique - case XK_KP_Add: return Keyboard::Add; - case XK_KP_Decimal: return Keyboard::Decimal; - case XK_KP_Delete: return Keyboard::Decimal; - case XK_KP_Divide: return Keyboard::Divide; - case XK_KP_Multiply: return Keyboard::Multiply; - case XK_KP_Insert: return Keyboard::Numpad0; - case XK_KP_End: return Keyboard::Numpad1; - case XK_KP_Down: return Keyboard::Numpad2; - case XK_KP_Page_Down: return Keyboard::Numpad3; - case XK_KP_Left: return Keyboard::Numpad4; - case XK_KP_Begin: return Keyboard::Numpad5; - case XK_KP_Right: return Keyboard::Numpad6; - case XK_KP_Home: return Keyboard::Numpad7; - case XK_KP_Up: return Keyboard::Numpad8; - case XK_KP_Page_Up: return Keyboard::Numpad9; - case XK_KP_Enter: return Keyboard::NumpadReturn; - case XK_KP_Subtract: return Keyboard::Subtract; - - // Divers - case XK_backslash: return Keyboard::Backslash; - case XK_BackSpace: return Keyboard::Backspace; - case XK_Clear: return Keyboard::Clear; - case XK_comma: return Keyboard::Comma; - case XK_minus: return Keyboard::Dash; - case XK_Delete: return Keyboard::Delete; - case XK_End: return Keyboard::End; - case XK_equal: return Keyboard::Equal; - case XK_Escape: return Keyboard::Escape; - case XK_Home: return Keyboard::Home; - case XK_Insert: return Keyboard::Insert; - case XK_Alt_L: return Keyboard::LAlt; - case XK_bracketleft: return Keyboard::LBracket; - case XK_Control_L: return Keyboard::LControl; - case XK_Shift_L: return Keyboard::LShift; - case XK_Super_L: return Keyboard::LSystem; - case XK_0: return Keyboard::Num0; - case XK_1: return Keyboard::Num1; - case XK_2: return Keyboard::Num2; - case XK_3: return Keyboard::Num3; - case XK_4: return Keyboard::Num4; - case XK_5: return Keyboard::Num5; - case XK_6: return Keyboard::Num6; - case XK_7: return Keyboard::Num7; - case XK_8: return Keyboard::Num8; - case XK_9: return Keyboard::Num9; - case XK_Page_Down: return Keyboard::PageDown; - case XK_Page_Up: return Keyboard::PageUp; - case XK_Pause: return Keyboard::Pause; - case XK_period: return Keyboard::Period; - case XK_Print: return Keyboard::Print; - case XK_Sys_Req: return Keyboard::PrintScreen; - case XK_quotedbl: return Keyboard::Quote; - case XK_Alt_R: return Keyboard::RAlt; - case XK_bracketright: return Keyboard::RBracket; - case XK_Control_R: return Keyboard::RControl; - case XK_Return: return Keyboard::Return; - case XK_Shift_R: return Keyboard::RShift; - case XK_Super_R: return Keyboard::RSystem; - case XK_semicolon: return Keyboard::Semicolon; - case XK_slash: return Keyboard::Slash; - case XK_space: return Keyboard::Space; - case XK_Tab: return Keyboard::Tab; - case XK_grave: return Keyboard::Tilde; - case XK_Menu: return Keyboard::Menu; - case XK_less: return Keyboard::ISOBackslash102; - - // Touches navigateur - case XF86XK_Back: return Keyboard::Browser_Back; - case XF86XK_Favorites: return Keyboard::Browser_Favorites; - case XF86XK_Forward: return Keyboard::Browser_Forward; - case XF86XK_HomePage: return Keyboard::Browser_Home; - case XF86XK_Refresh: return Keyboard::Browser_Refresh; - case XF86XK_Search: return Keyboard::Browser_Search; - case XF86XK_Stop: return Keyboard::Browser_Stop; - - // Touches de contrôle - case XF86XK_AudioNext: return Keyboard::Media_Next; - case XF86XK_AudioPlay: return Keyboard::Media_Play; - case XF86XK_AudioPrev: return Keyboard::Media_Previous; - case XF86XK_AudioStop: return Keyboard::Media_Stop; - - // Touches de contrôle du volume - case XF86XK_AudioLowerVolume: return Keyboard::Volume_Down; - case XF86XK_AudioMute: return Keyboard::Volume_Mute; - case XF86XK_AudioRaiseVolume: return Keyboard::Volume_Up; - - // Touches à verrouillage - case XK_Caps_Lock: return Keyboard::CapsLock; - case XK_Num_Lock: return Keyboard::NumLock; - case XK_Scroll_Lock: return Keyboard::ScrollLock; - - default: - return Keyboard::Undefined; - } - } - - void WindowImpl::CommonInitialize() - { - // Show the window - SetVisible(true); - - // Raise the window and grab input focus - SetFocus(); - - xcb_atom_t protocols[] = - { - X11::GetAtom("WM_DELETE_WINDOW"), - }; - - if (!X11::CheckCookie( - connection, - xcb_icccm_set_wm_protocols( - connection, - m_window, - X11::GetAtom("WM_PROTOCOLS"), - sizeof(protocols), - protocols - )) - ) - NazaraError("Failed to get atom for deleting a window"); - - // Flush the commands queue - xcb_flush(connection); - } - - char32_t WindowImpl::GetRepresentation(xcb_keysym_t keysym) const - { - switch (keysym) - { - case XK_KP_Space: - return ' '; - case XK_BackSpace: - return '\b'; - case XK_Tab: - case XK_KP_Tab: - return '\t'; - case XK_Linefeed: - return '\n'; - case XK_Return: - return '\r'; - // Numpad - case XK_KP_Multiply: - return '*'; - case XK_KP_Add: - return '+'; - case XK_KP_Separator: - return ','; // In french, it's '.' - case XK_KP_Subtract: - return '-'; - case XK_KP_Decimal: - return '.'; // In french, it's ',' - case XK_KP_Divide: - return '/'; - case XK_KP_0: - return '0'; - case XK_KP_1: - return '1'; - case XK_KP_2: - return '2'; - case XK_KP_3: - return '3'; - case XK_KP_4: - return '4'; - case XK_KP_5: - return '5'; - case XK_KP_6: - return '6'; - case XK_KP_7: - return '7'; - case XK_KP_8: - return '8'; - case XK_KP_9: - return '9'; - case XK_KP_Enter: - return '\r'; - default: - if (xcb_is_modifier_key(keysym) == true) - return '\0'; - else - return keysym; - } - } - - void WindowImpl::ProcessEvent(xcb_generic_event_t* windowEvent) - { - if (!m_eventListener) - return; - - // Convert the xcb event to a Event - switch (windowEvent->response_type & ~0x80) - { - // Destroy event - case XCB_DESTROY_NOTIFY: - { - // The window is about to be destroyed: we must cleanup resources - CleanUp(); - break; - } - - // Gain focus event - case XCB_FOCUS_IN: - { - const uint32_t value_list[] = { eventMask }; - if (!X11::CheckCookie( - connection, - xcb_change_window_attributes( - connection, - m_window, - XCB_CW_EVENT_MASK, - value_list - )) - ) - NazaraError("Failed to change event mask"); - - WindowEvent event; - event.type = Nz::WindowEventType_GainedFocus; - m_parent->PushEvent(event); - - break; - } - - // Lost focus event - case XCB_FOCUS_OUT: - { - WindowEvent event; - event.type = Nz::WindowEventType_LostFocus; - m_parent->PushEvent(event); - - const uint32_t values[] = { XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_FOCUS_CHANGE }; - if (!X11::CheckCookie( - connection, - xcb_change_window_attributes( - connection, - m_window, - XCB_CW_EVENT_MASK, - values - )) - ) - NazaraError("Failed to change event mask"); - - break; - } - - // Resize event - case XCB_CONFIGURE_NOTIFY: - { - xcb_configure_notify_event_t* configureNotifyEvent = (xcb_configure_notify_event_t*)windowEvent; - // ConfigureNotify can be triggered for other reasons, check if the size has actually changed - if ((configureNotifyEvent->width != m_size_hints.width) || (configureNotifyEvent->height != m_size_hints.width)) - { - WindowEvent event; - event.type = Nz::WindowEventType_Resized; - event.size.width = configureNotifyEvent->width; - event.size.height = configureNotifyEvent->height; - m_parent->PushEvent(event); - - m_size_hints.width = configureNotifyEvent->width; - m_size_hints.height = configureNotifyEvent->height; - } - if ((configureNotifyEvent->x != m_size_hints.x) || (configureNotifyEvent->y != m_size_hints.y)) - { - WindowEvent event; - event.type = Nz::WindowEventType_Moved; - event.size.width = configureNotifyEvent->x; - event.size.height = configureNotifyEvent->y; - m_parent->PushEvent(event); - - m_size_hints.x = configureNotifyEvent->x; - m_size_hints.y = configureNotifyEvent->y; - } - break; - } - - // Close event - case XCB_CLIENT_MESSAGE: - { - xcb_client_message_event_t* clientMessageEvent = (xcb_client_message_event_t*)windowEvent; - - if (clientMessageEvent->type != X11::GetAtom("WM_PROTOCOLS")) - break; - if (clientMessageEvent->data.data32[0] == X11::GetAtom("WM_DELETE_WINDOW")) - { - WindowEvent event; - event.type = Nz::WindowEventType_Quit; - m_parent->PushEvent(event); - } - - break; - } - - // Key down event - case XCB_KEY_PRESS: - { - xcb_key_press_event_t* keyPressEvent = (xcb_key_press_event_t*)windowEvent; - - if (!m_keyRepeat && m_eventQueue.curr && m_eventQueue.next) - { - xcb_key_press_event_t* current = (xcb_key_release_event_t*)m_eventQueue.curr; - // keyPressEvent == next - - if ((current->time == keyPressEvent->time) && (current->detail == keyPressEvent->detail)) - break; - } - - auto keysym = ConvertKeyCodeToKeySym(keyPressEvent->detail, keyPressEvent->state); - - WindowEvent event; - event.type = Nz::WindowEventType_KeyPressed; - event.key.code = ConvertVirtualKey(keysym); - event.key.alt = keyPressEvent->state & XCB_MOD_MASK_1; - event.key.control = keyPressEvent->state & XCB_MOD_MASK_CONTROL; - event.key.shift = keyPressEvent->state & XCB_MOD_MASK_SHIFT; - event.key.system = keyPressEvent->state & XCB_MOD_MASK_4; - m_parent->PushEvent(event); - - char32_t codePoint = GetRepresentation(keysym); - - // if (std::isprint(codePoint)) Is not working ? + handle combining ? - { - event.type = Nz::WindowEventType_TextEntered; - event.text.character = codePoint; - event.text.repeated = false; - m_parent->PushEvent(event); - } - - break; - } - - // Key up event - case XCB_KEY_RELEASE: - { - xcb_key_release_event_t* keyReleaseEvent = (xcb_key_release_event_t*)windowEvent; - - if (!m_keyRepeat && m_eventQueue.curr && m_eventQueue.next) - { - // keyReleaseEvent == current - xcb_key_press_event_t* next = (xcb_key_press_event_t*)m_eventQueue.next; - - if ((keyReleaseEvent->time == next->time) && (keyReleaseEvent->detail == next->detail)) - break; - } - - auto keysym = ConvertKeyCodeToKeySym(keyReleaseEvent->detail, keyReleaseEvent->state); - - WindowEvent event; - event.type = Nz::WindowEventType_KeyReleased; - event.key.code = ConvertVirtualKey(keysym); - event.key.alt = keyReleaseEvent->state & XCB_MOD_MASK_1; - event.key.control = keyReleaseEvent->state & XCB_MOD_MASK_CONTROL; - event.key.shift = keyReleaseEvent->state & XCB_MOD_MASK_SHIFT; - event.key.system = keyReleaseEvent->state & XCB_MOD_MASK_4; - m_parent->PushEvent(event); - - break; - } - - // Mouse button pressed - case XCB_BUTTON_PRESS: - { - xcb_button_press_event_t* buttonPressEvent = (xcb_button_press_event_t*)windowEvent; - - WindowEvent event; - event.type = Nz::WindowEventType_MouseButtonPressed; - event.mouseButton.x = buttonPressEvent->event_x; - event.mouseButton.y = buttonPressEvent->event_y; - - if (buttonPressEvent->detail == XCB_BUTTON_INDEX_1) - event.mouseButton.button = Mouse::Left; - else if (buttonPressEvent->detail == XCB_BUTTON_INDEX_2) - event.mouseButton.button = Mouse::Middle; - else if (buttonPressEvent->detail == XCB_BUTTON_INDEX_3) - event.mouseButton.button = Mouse::Right; - else if (buttonPressEvent->detail == XCB_BUTTON_INDEX_4) - event.mouseButton.button = Mouse::XButton1; - else if (buttonPressEvent->detail == XCB_BUTTON_INDEX_5) - event.mouseButton.button = Mouse::XButton2; - else - NazaraWarning("Mouse button not handled"); - - m_parent->PushEvent(event); - - break; - } - - // Mouse button released - case XCB_BUTTON_RELEASE: - { - xcb_button_release_event_t* buttonReleaseEvent = (xcb_button_release_event_t*)windowEvent; - - WindowEvent event; - - switch (buttonReleaseEvent->detail) - { - case XCB_BUTTON_INDEX_4: - case XCB_BUTTON_INDEX_5: - { - event.type = Nz::WindowEventType_MouseWheelMoved; - event.mouseWheel.delta = (buttonReleaseEvent->detail == XCB_BUTTON_INDEX_4) ? 1 : -1; - break; - } - default: - { - event.type = Nz::WindowEventType_MouseButtonReleased; - event.mouseButton.x = buttonReleaseEvent->event_x; - event.mouseButton.y = buttonReleaseEvent->event_y; - - if (buttonReleaseEvent->detail == XCB_BUTTON_INDEX_1) - event.mouseButton.button = Mouse::Left; - else if (buttonReleaseEvent->detail == XCB_BUTTON_INDEX_2) - event.mouseButton.button = Mouse::Middle; - else if (buttonReleaseEvent->detail == XCB_BUTTON_INDEX_3) - event.mouseButton.button = Mouse::Right; - else if (buttonReleaseEvent->detail == XCB_BUTTON_INDEX_4) - event.mouseButton.button = Mouse::XButton1; - else if (buttonReleaseEvent->detail == XCB_BUTTON_INDEX_5) - event.mouseButton.button = Mouse::XButton2; - else - NazaraWarning("Mouse button not handled"); - } - } - - m_parent->PushEvent(event); - - break; - } - - // Mouse moved - case XCB_MOTION_NOTIFY: - { - xcb_motion_notify_event_t* motionNotifyEvent = (xcb_motion_notify_event_t*)windowEvent; - - // We use the sequence to determine whether the motion is linked to a Mouse::SetPosition - if (m_mousePos.x == motionNotifyEvent->event_x && m_mousePos.y == motionNotifyEvent->event_y) - break; - - WindowEvent event; - event.type = Nz::WindowEventType_MouseMoved; - event.mouseMove.deltaX = motionNotifyEvent->event_x - m_mousePos.x; - event.mouseMove.deltaY = motionNotifyEvent->event_y - m_mousePos.y; - event.mouseMove.x = motionNotifyEvent->event_x; - event.mouseMove.y = motionNotifyEvent->event_y; - - m_mousePos.x = motionNotifyEvent->event_x; - m_mousePos.y = motionNotifyEvent->event_y; - - m_parent->PushEvent(event); - - break; - } - - // Mouse entered - case XCB_ENTER_NOTIFY: - { - WindowEvent event; - event.type = Nz::WindowEventType_MouseEntered; - m_parent->PushEvent(event); - - break; - } - - // Mouse left - case XCB_LEAVE_NOTIFY: - { - WindowEvent event; - event.type = Nz::WindowEventType_MouseLeft; - m_parent->PushEvent(event); - - break; - } - - // Parent window changed - case XCB_REPARENT_NOTIFY: - { - // Catch reparent events to properly apply fullscreen on - // some "strange" window managers (like Awesome) which - // seem to make use of temporary parents during mapping - if (m_style & WindowStyle_Fullscreen) - SwitchToFullscreen(); - - break; - } - } - } - - void WindowImpl::ResetVideoMode() - { - if (fullscreenWindow == this) - { - // Get current screen info - ScopedXCB error(nullptr); - - // Reset the video mode - ScopedXCB setScreenConfig(xcb_randr_set_screen_config_reply( - connection, - xcb_randr_set_screen_config( - connection, - m_oldVideoMode.root, - XCB_CURRENT_TIME, - m_oldVideoMode.config_timestamp, - m_oldVideoMode.sizeID, - m_oldVideoMode.rotation, - m_oldVideoMode.rate - ), - &error - )); - - if (error) - NazaraError("Failed to reset old screen configuration"); - - // Reset the fullscreen window - fullscreenWindow = nullptr; - } - } - - void WindowImpl::SetMotifHints() - { - ScopedXCB error(nullptr); - - const char MOTIF_WM_HINTS[] = "_MOTIF_WM_HINTS"; - ScopedXCB hintsAtomReply(xcb_intern_atom_reply( - connection, - xcb_intern_atom( - connection, - 0, - sizeof(MOTIF_WM_HINTS) - 1, - MOTIF_WM_HINTS - ), - &error - )); - - if (!error && hintsAtomReply) - { - const uint32_t MWM_HINTS_FUNCTIONS = 1 << 0; - const uint32_t MWM_HINTS_DECORATIONS = 1 << 1; - - //const uint32_t MWM_DECOR_ALL = 1 << 0; - const uint32_t MWM_DECOR_BORDER = 1 << 1; - const uint32_t MWM_DECOR_RESIZEH = 1 << 2; - const uint32_t MWM_DECOR_TITLE = 1 << 3; - const uint32_t MWM_DECOR_MENU = 1 << 4; - const uint32_t MWM_DECOR_MINIMIZE = 1 << 5; - const uint32_t MWM_DECOR_MAXIMIZE = 1 << 6; - - //const uint32_t MWM_FUNC_ALL = 1 << 0; - const uint32_t MWM_FUNC_RESIZE = 1 << 1; - const uint32_t MWM_FUNC_MOVE = 1 << 2; - const uint32_t MWM_FUNC_MINIMIZE = 1 << 3; - const uint32_t MWM_FUNC_MAXIMIZE = 1 << 4; - const uint32_t MWM_FUNC_CLOSE = 1 << 5; - - struct MotifWMHints - { - uint32_t flags; - uint32_t functions; - uint32_t decorations; - int32_t inputMode; - uint32_t state; - }; - - MotifWMHints hints; - hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS; - hints.decorations = 0; - hints.functions = 0; - hints.inputMode = 0; - hints.state = 0; - - if (m_style & Nz::WindowStyle_Titlebar) - { - hints.decorations |= MWM_DECOR_BORDER | MWM_DECOR_TITLE | MWM_DECOR_MINIMIZE | MWM_DECOR_MENU; - hints.functions |= MWM_FUNC_MOVE | MWM_FUNC_MINIMIZE; - } - if (m_style & Nz::WindowStyle_Resizable) - { - hints.decorations |= MWM_DECOR_MAXIMIZE | MWM_DECOR_RESIZEH; - hints.functions |= MWM_FUNC_MAXIMIZE | MWM_FUNC_RESIZE; - } - if (m_style & Nz::WindowStyle_Closable) - { - hints.decorations |= 0; - hints.functions |= MWM_FUNC_CLOSE; - } - - ScopedXCB propertyError(xcb_request_check( - connection, - xcb_change_property_checked( - connection, - XCB_PROP_MODE_REPLACE, - m_window, - hintsAtomReply->atom, - hintsAtomReply->atom, - 32, - 5, - &hints - ) - )); - - if (propertyError) - NazaraError("xcb_change_property failed, could not set window hints"); - } - else - NazaraError("Failed to request _MOTIF_WM_HINTS atom."); - } - - void WindowImpl::SetVideoMode(const VideoMode& mode) - { - // Skip mode switching if the new mode is equal to the desktop mode - if (mode == VideoMode::GetDesktopMode()) - return; - - ScopedXCB error(nullptr); - - // Check if the RandR extension is present - const xcb_query_extension_reply_t* randrExt = xcb_get_extension_data(connection, &xcb_randr_id); - - if (!randrExt || !randrExt->present) - { - // RandR extension is not supported: we cannot use fullscreen mode - NazaraError("Fullscreen is not supported, switching to window mode"); - return; - } - - // Load RandR and check its version - ScopedXCB randrVersion(xcb_randr_query_version_reply( - connection, - xcb_randr_query_version( - connection, - 1, - 1 - ), - &error - )); - - if (error) - { - NazaraError("Failed to load RandR, switching to window mode"); - return; - } - - // Get the current configuration - ScopedXCB config(xcb_randr_get_screen_info_reply( - connection, - xcb_randr_get_screen_info( - connection, - m_screen->root - ), - &error - )); - - if (error || !config) - { - // Failed to get the screen configuration - NazaraError("Failed to get the current screen configuration for fullscreen mode, switching to window mode"); - return; - } - - // Save the current video mode before we switch to fullscreen - m_oldVideoMode = *config.get(); - - // Get the available screen sizes - xcb_randr_screen_size_t* sizes = xcb_randr_get_screen_info_sizes(config.get()); - - if (!sizes || !config->nSizes) - { - NazaraError("Failed to get the fullscreen sizes, switching to window mode"); - return; - } - - // Search for a matching size - for (int i = 0; i < config->nSizes; ++i) - { - if (config->rotation == XCB_RANDR_ROTATION_ROTATE_90 || - config->rotation == XCB_RANDR_ROTATION_ROTATE_270) - std::swap(sizes[i].height, sizes[i].width); - - if ((sizes[i].width == static_cast(mode.width)) && - (sizes[i].height == static_cast(mode.height))) - { - // Switch to fullscreen mode - ScopedXCB setScreenConfig(xcb_randr_set_screen_config_reply( - connection, - xcb_randr_set_screen_config( - connection, - config->root, - XCB_CURRENT_TIME, - config->config_timestamp, - i, - config->rotation, - config->rate - ), - &error - )); - - if (error) - NazaraError("Failed to set new screen configuration"); - - // Set "this" as the current fullscreen window - fullscreenWindow = this; - return; - } - } - - NazaraError("Failed to find matching fullscreen size, switching to window mode"); - } - - void WindowImpl::SwitchToFullscreen() - { - SetFocus(); - - ScopedXCBEWMHConnection ewmhConnection(connection); - - if (!X11::CheckCookie( - connection, - xcb_ewmh_set_wm_state( - ewmhConnection, - m_window, - 1, - &ewmhConnection->_NET_WM_STATE_FULLSCREEN - )) - ) - NazaraError("Failed to switch to fullscreen"); - } - - void WindowImpl::UpdateEventQueue(xcb_generic_event_t* event) - { - std::free(m_eventQueue.curr); - m_eventQueue.curr = m_eventQueue.next; - m_eventQueue.next = event; - } - - bool WindowImpl::UpdateNormalHints() - { - return X11::CheckCookie( - connection, - xcb_icccm_set_wm_normal_hints( - connection, - m_window, - &m_size_hints - )); - } - - void WindowImpl::WindowThread(WindowImpl* window, Mutex* mutex, ConditionVariable* condition) - { - mutex->Lock(); - condition->Signal(); - mutex->Unlock(); // mutex and condition may be destroyed after this line - - if (!window->m_window) - return; - - while (window->m_threadActive) - window->ProcessEvents(true); - - window->Destroy(); - } -} diff --git a/src/Nazara/Platform/X11/WindowImpl.hpp b/src/Nazara/Platform/X11/WindowImpl.hpp deleted file mode 100644 index ecf5e0233..000000000 --- a/src/Nazara/Platform/X11/WindowImpl.hpp +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Platform module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -// Interface inspirée de la SFML par Laurent Gomila - -#pragma once - -#ifndef NAZARA_WINDOWIMPL_HPP -#define NAZARA_WINDOWIMPL_HPP - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - class ConditionVariable; - class Mutex; - class Cursor; - class Icon; - class VideoMode; - class Window; - - class WindowImpl - { - public: - WindowImpl(Window* parent); - WindowImpl(const WindowImpl&) = delete; - WindowImpl(WindowImpl&&) = delete; ///TODO? - ~WindowImpl(); - - bool Create(const VideoMode& mode, const String& title, WindowStyleFlags style); - bool Create(WindowHandle handle); - - void Destroy(); - - void EnableKeyRepeat(bool enable); - void EnableSmoothScrolling(bool enable); - - WindowHandle GetHandle() const; - unsigned int GetHeight() const; - Vector2i GetPosition() const; - Vector2ui GetSize() const; - WindowStyleFlags GetStyle() const; - String GetTitle() const; - unsigned int GetWidth() const; - - bool HasFocus() const; - - void IgnoreNextMouseEvent(int mouseX, int mouseY); - - bool IsMinimized() const; - bool IsVisible() const; - - void RefreshCursor(); - - void ProcessEvents(bool block); - - void SetCursor(const Cursor& cursor); - void SetEventListener(bool listener); - void SetFocus(); - void SetIcon(const Icon& icon); - void SetMaximumSize(int width, int height); - void SetMinimumSize(int width, int height); - void SetPosition(int x, int y); - void SetSize(unsigned int width, unsigned int height); - void SetStayOnTop(bool stayOnTop); - void SetTitle(const String& title); - void SetVisible(bool visible); - - WindowImpl& operator=(const WindowImpl&) = delete; - WindowImpl& operator=(WindowImpl&&) = delete; ///TODO? - - static bool Initialize(); - static void Uninitialize(); - - private: - - void CleanUp(); - xcb_keysym_t ConvertKeyCodeToKeySym(xcb_keycode_t keycode, uint16_t state); - Keyboard::Key ConvertVirtualKey(xcb_keysym_t symbol); - void CommonInitialize(); - - char32_t GetRepresentation(xcb_keysym_t keysym) const; - - void ProcessEvent(xcb_generic_event_t* windowEvent); - - void ResetVideoMode(); - - void SetMotifHints(); - void SetVideoMode(const VideoMode& mode); - void SwitchToFullscreen(); - - bool UpdateNormalHints(); - void UpdateEventQueue(xcb_generic_event_t* event); - - static void WindowThread(WindowImpl* window, Mutex* mutex, ConditionVariable* condition); - - xcb_window_t m_window; - xcb_screen_t* m_screen; - xcb_randr_get_screen_info_reply_t m_oldVideoMode; - xcb_size_hints_t m_size_hints; - Thread m_thread; - WindowStyleFlags m_style; - Window* m_parent; - bool m_eventListener; - bool m_ownsWindow; - bool m_smoothScrolling; - bool m_threadActive; - Vector2i m_mousePos; - bool m_keyRepeat; - - struct - { - xcb_generic_event_t* curr = nullptr; - xcb_generic_event_t* next = nullptr; - } m_eventQueue; - }; -} - -#endif // NAZARA_WINDOWIMPL_HPP diff --git a/src/Nazara/Renderer/Context.cpp b/src/Nazara/Renderer/Context.cpp index ba74b3800..0a1fd7f9c 100644 --- a/src/Nazara/Renderer/Context.cpp +++ b/src/Nazara/Renderer/Context.cpp @@ -12,19 +12,10 @@ #include #include -#if defined(NAZARA_PLATFORM_SDL2) - #include +#include - #if defined(NAZARA_PLATFORM_LINUX) - #define CALLBACK - #endif -#elif defined(NAZARA_PLATFORM_WINDOWS) - #include -#elif defined(NAZARA_PLATFORM_GLX) - #include +#if defined(NAZARA_PLATFORM_LINUX) #define CALLBACK -#else - #error Lack of implementation: Context #endif #include diff --git a/src/Nazara/Renderer/GLX/ContextImpl.cpp b/src/Nazara/Renderer/GLX/ContextImpl.cpp deleted file mode 100644 index 2f25e680d..000000000 --- a/src/Nazara/Renderer/GLX/ContextImpl.cpp +++ /dev/null @@ -1,300 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -// Code inspiré de NeHe (Lesson1) et de la SFML par Laurent Gomila - -#include -#include -#include -#include -#include - -using namespace GLX; - -namespace Nz -{ - namespace - { - Display* m_display; - int m_sharedDisplay = 0; - - bool ctxErrorOccurred = false; - int ctxErrorHandler( Display* /*dpy*/, XErrorEvent* /*ev*/ ) - { - ctxErrorOccurred = true; - return 0; - } - } - - ContextImpl::ContextImpl() : - m_colormap(0), - m_context(0), - m_window(0), - m_ownsWindow(false) - { - if (m_sharedDisplay == 0) - m_display = XOpenDisplay(nullptr); - - ++m_sharedDisplay; - } - - ContextImpl::~ContextImpl() - { - Destroy(); - - if (--m_sharedDisplay == 0) - { - XCloseDisplay(m_display); - m_display = nullptr; - } - } - - bool ContextImpl::Activate() const - { - return glXMakeCurrent(m_display, m_window, m_context) == true; - } - - bool ContextImpl::Create(ContextParameters& parameters) - { - // En cas d'exception, la ressource sera quand même libérée - CallOnExit onExit([this] () - { - Destroy(); - }); - - // Get a matching FB config - static int visual_attribs[] = - { - GLX_X_RENDERABLE, True, - GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, - GLX_RENDER_TYPE, GLX_RGBA_BIT, - GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR, - GLX_BUFFER_SIZE, parameters.bitsPerPixel, - GLX_ALPHA_SIZE, (parameters.bitsPerPixel == 32) ? 8 : 0, - GLX_DEPTH_SIZE, parameters.depthBits, - GLX_STENCIL_SIZE, parameters.stencilBits, - GLX_DOUBLEBUFFER, True, - GLX_SAMPLE_BUFFERS, (parameters.antialiasingLevel > 0) ? True : False, - GLX_SAMPLES, parameters.antialiasingLevel, - None - }; - - int glx_major = 0; - int glx_minor = 0; - // FBConfigs were added in GLX version 1.3. - if (!glXQueryVersion(m_display, &glx_major, &glx_minor) || ((glx_major == 1) && (glx_minor < 3)) || (glx_major < 1)) - { - NazaraError("Invalid GLX version, version > 1.3 is required."); - return false; - } - - int fbcount; - GLXFBConfig* fbc = glXChooseFBConfig(m_display, XDefaultScreen(m_display), visual_attribs, &fbcount); - if (!fbc) - { - NazaraError("Failed to retrieve a framebuffer config"); - return false; - } - - // Pick the FB config/visual with the most samples per pixel - int best_fbc = -1; - int worst_fbc = -1; - int best_num_samp = -1; - int worst_num_samp = 999; - - for (int i = 0; i < fbcount; ++i) - { - XVisualInfo* vi = glXGetVisualFromFBConfig(m_display, fbc[i]); - - if (vi) - { - int samp_buf = 0, samples = 0; - glXGetFBConfigAttrib(m_display, fbc[i], GLX_SAMPLE_BUFFERS, &samp_buf); - glXGetFBConfigAttrib(m_display, fbc[i], GLX_SAMPLES , &samples ); - - if ((best_fbc < 0) || (samp_buf && (samples > best_num_samp))) - { - best_fbc = i; - best_num_samp = samples; - } - if ((worst_fbc < 0) || !samp_buf || (samples < worst_num_samp)) - { - worst_fbc = i; - worst_num_samp = samples; - } - } - XFree(vi); - } - - GLXFBConfig bestFbc = fbc[best_fbc]; - - // Be sure to free the FBConfig list allocated by glXChooseFBConfig() - XFree(fbc); - - // Get a visual - XVisualInfo* vi = glXGetVisualFromFBConfig(m_display, bestFbc); - if (!vi) - { - NazaraError("Failed to get best VisualInfo"); - return false; - } - - // If context is shared by multiple windows - if (parameters.window) - { - m_window = parameters.window; - m_ownsWindow = false; - } - else - { - XSetWindowAttributes swa; - swa.colormap = m_colormap = XCreateColormap( - m_display, - XRootWindow( - m_display, - vi->screen), - vi->visual, - AllocNone - ); - - swa.background_pixmap = None; - swa.border_pixel = 0; - swa.event_mask = StructureNotifyMask; - - if (!m_colormap) - { - NazaraError("Failed to create colormap for context"); - return false; - } - - m_window = XCreateWindow( - m_display, - XRootWindow( - m_display, - vi->screen), - 0, 0, // X, Y - 1, 1, // W H - 0, - vi->depth, - InputOutput, - vi->visual, - CWBorderPixel | CWColormap | CWEventMask, - &swa - ); - - m_ownsWindow = true; - } - - if (!m_window) - { - NazaraError("Failed to create window"); - return false; - } - - // Done with the visual info data - XFree(vi); - - // Install an X error handler so the application won't exit if GL 3.0 - // context allocation fails. - // - // Note this error handler is global. All display connections in all threads - // of a process use the same error handler, so be sure to guard against other - // threads issuing X commands while this code is running. - ctxErrorOccurred = false; - int (*oldHandler)(Display*, XErrorEvent*) = - XSetErrorHandler(&ctxErrorHandler); - - // Check for the GLX_ARB_create_context extension string and the function. - // If either is not present, use GLX 1.3 context creation method. - if (!glXCreateContextAttribs) - { - NazaraWarning("glXCreateContextAttribs() not found. Using old-style GLX context"); - m_context = glXCreateNewContext(m_display, bestFbc, GLX_RGBA_TYPE, parameters.shared ? parameters.shareContext->m_impl->m_context : 0, True); - } - // If it does, try to get a GL 3.0 context! - else - { - int profile = parameters.compatibilityProfile ? GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB : GLX_CONTEXT_CORE_PROFILE_BIT_ARB; - int debug = parameters.debugMode ? GLX_CONTEXT_DEBUG_BIT_ARB : 0; - - int major = 3;//parameters.majorVersion; - int minor = 3;//parameters.minorVersion; - - int context_attribs[] = - { - GLX_CONTEXT_MAJOR_VERSION_ARB, major, - GLX_CONTEXT_MINOR_VERSION_ARB, minor, - GLX_CONTEXT_PROFILE_MASK_ARB, profile, - GLX_CONTEXT_FLAGS_ARB, debug, - None, None - }; - - m_context = glXCreateContextAttribs( - m_display, - bestFbc, - parameters.shared ? parameters.shareContext->m_impl->m_context : 0, - True, - context_attribs - ); - } - - // Sync to ensure any errors generated are processed. - XSync(m_display, False); - XSetErrorHandler(oldHandler); - if (ctxErrorOccurred || !m_context) - { - NazaraError("Failed to create context, check the version"); - return false; - } - - onExit.Reset(); - - return true; - } - - void ContextImpl::Destroy() - { - // Destroy the context - if (m_context) - { - if (glXGetCurrentContext() == m_context) - glXMakeCurrent(m_display, None, nullptr); - glXDestroyContext(m_display, m_context); - m_context = nullptr; - } - - // Destroy the window if we own it - if (m_ownsWindow && m_window) - { - XFreeColormap(m_display, m_colormap); - XDestroyWindow(m_display, m_window); - m_ownsWindow = false; - m_window = 0; - XFlush(m_display); - } - } - - void ContextImpl::EnableVerticalSync(bool enabled) - { - if (glXSwapIntervalEXT) - glXSwapIntervalEXT(m_display, glXGetCurrentDrawable(), enabled ? 1 : 0); - else if (NzglXSwapIntervalMESA) - NzglXSwapIntervalMESA(enabled ? 1 : 0); - else if (glXSwapIntervalSGI) - glXSwapIntervalSGI(enabled ? 1 : 0); - else - NazaraError("Vertical sync not supported"); - } - - void ContextImpl::SwapBuffers() - { - if (m_window) - glXSwapBuffers(m_display, m_window); - } - - bool ContextImpl::Desactivate() - { - return glXMakeCurrent(m_display, None, nullptr) == true; - } -} diff --git a/src/Nazara/Renderer/GLX/ContextImpl.hpp b/src/Nazara/Renderer/GLX/ContextImpl.hpp deleted file mode 100644 index 7aaf6409f..000000000 --- a/src/Nazara/Renderer/GLX/ContextImpl.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_CONTEXTIMPL_HPP -#define NAZARA_CONTEXTIMPL_HPP - -#include - -namespace Nz -{ - struct ContextParameters; - - class ContextImpl - { - public: - ContextImpl(); - ~ContextImpl(); - - bool Activate() const; - - bool Create(ContextParameters& parameters); - - void Destroy(); - - void EnableVerticalSync(bool enabled); - - void SwapBuffers(); - - static bool Desactivate(); - - private: - GLX::Colormap m_colormap; - GLX::GLXContext m_context; - GLX::Window m_window; - bool m_ownsWindow; - }; -} - -#endif // NAZARA_CONTEXTIMPL_HPP diff --git a/src/Nazara/Renderer/OpenGL.cpp b/src/Nazara/Renderer/OpenGL.cpp index 79685d25a..f7f903314 100644 --- a/src/Nazara/Renderer/OpenGL.cpp +++ b/src/Nazara/Renderer/OpenGL.cpp @@ -9,11 +9,7 @@ #include #include #include -#if defined(NAZARA_PLATFORM_SDL2) #include -#elif defined(NAZARA_PLATFORM_GLX) -#include -#endif // NAZARA_PLATFORM_GLX #include #include #include @@ -30,17 +26,7 @@ namespace Nz OpenGLFunc LoadEntry(const char* name, bool launchException = true) { - #if defined(NAZARA_PLATFORM_SDL2) OpenGLFunc entry = reinterpret_cast(SDL_GL_GetProcAddress(name)); - #elif defined(NAZARA_PLATFORM_WINDOWS) - OpenGLFunc entry = reinterpret_cast(wglGetProcAddress(name)); - if (!entry) // wglGetProcAddress ne fonctionne pas sur les fonctions OpenGL <= 1.1 - entry = reinterpret_cast(GetProcAddress(openGLlibrary, name)); - #elif defined(NAZARA_PLATFORM_GLX) - OpenGLFunc entry = reinterpret_cast(GLX::glXGetProcAddress(reinterpret_cast(name))); - #else - #error OS not handled - #endif if (!entry && launchException) { @@ -55,31 +41,19 @@ namespace Nz bool LoadLibrary() { - #if defined(NAZARA_PLATFORM_SDL2) if (SDL_GL_LoadLibrary(nullptr) != 0) { NazaraError(SDL_GetError()); return false; } - return true; - #elif defined(NAZARA_PLATFORM_WINDOWS) - openGLlibrary = ::LoadLibraryA("opengl32.dll"); - - return openGLlibrary != nullptr; - #else return true; - #endif } void UnloadLibrary() { - #if defined(NAZARA_PLATFORM_SDL2) SDL_GL_UnloadLibrary(); - #elif defined(NAZARA_PLATFORM_WINDOWS) - FreeLibrary(openGLlibrary); - #endif } enum GarbageResourceType @@ -742,20 +716,9 @@ namespace Nz if (s_initialized) return true; - - #if defined(NAZARA_PLATFORM_SDL2) if (SDL_VideoInit(NULL) != 0) NazaraError(SDL_GetError()); - #elif defined(NAZARA_PLATFORM_GLX) - Initializer display; - if (!display) - { - NazaraError("Failed to load display library"); - return false; - } - #endif - if (!LoadLibrary()) { NazaraError("Failed to load OpenGL library"); @@ -783,11 +746,6 @@ namespace Nz /****************************Chargement OpenGL****************************/ - ///FIXME: I'm really thinking this is a mistake and GLX has no need to be initialized differently (Lynix) - #if defined(NAZARA_PLATFORM_LINUX) && not defined(NAZARA_PLATFORM_SDL2) - glXCreateContextAttribs = reinterpret_cast(LoadEntry("glXCreateContextAttribsARB", false)); - #endif - Context loadContext; if (!loadContext.Create(parameters)) { @@ -795,13 +753,6 @@ namespace Nz return false; } - #if defined(NAZARA_PLATFORM_WINDOWS) && not defined(NAZARA_PLATFORM_SDL2) - wglCreateContextAttribs = reinterpret_cast(LoadEntry("wglCreateContextAttribsARB", false)); - wglChoosePixelFormat = reinterpret_cast(LoadEntry("wglChoosePixelFormatARB", false)); - if (!wglChoosePixelFormat) - wglChoosePixelFormat = reinterpret_cast(LoadEntry("wglChoosePixelFormatEXT", false)); - #endif - // Récupération de la version d'OpenGL et du GLSL // Ce code se base sur le fait que la carte graphique renverra un contexte de compatibilité avec la plus haute version supportée // Ce qui semble vrai chez AMD, NVidia et Intel, mais j'aimerai une preuve que ça sera toujours le cas... @@ -1047,16 +998,6 @@ namespace Nz glInvalidateBufferData = reinterpret_cast(LoadEntry("glInvalidateBufferData", false)); glVertexAttribLPointer = reinterpret_cast(LoadEntry("glVertexAttribLPointer", false)); - #if defined(NAZARA_PLATFORM_WINDOWS) - wglGetExtensionsStringARB = reinterpret_cast(LoadEntry("wglGetExtensionsStringARB", false)); - wglGetExtensionsStringEXT = reinterpret_cast(LoadEntry("wglGetExtensionsStringEXT", false)); - wglSwapInterval = reinterpret_cast(LoadEntry("wglSwapIntervalEXT", false)); - #elif defined(NAZARA_PLATFORM_GLX) - glXSwapIntervalEXT = reinterpret_cast(LoadEntry("glXSwapIntervalEXT", false)); - NzglXSwapIntervalMESA = reinterpret_cast(LoadEntry("glXSwapIntervalMESA", false)); - glXSwapIntervalSGI = reinterpret_cast(LoadEntry("glXSwapIntervalSGI", false)); - #endif - if (!glGetStringi || !LoadExtensions3()) { NazaraWarning("Failed to load OpenGL 3 extension system, falling back to OpenGL 2 extension system..."); @@ -1065,21 +1006,6 @@ namespace Nz NazaraWarning("Failed to load extension system"); } - #if defined(NAZARA_PLATFORM_WINDOWS) && !defined(NAZARA_PLATFORM_SDL2) - { - bool loaded; - if (wglGetExtensionsStringARB) - loaded = LoadExtensionsString(reinterpret_cast(wglGetExtensionsStringARB(wglGetCurrentDC()))); - else if (wglGetExtensionsStringEXT) - loaded = LoadExtensionsString(reinterpret_cast(wglGetExtensionsStringEXT())); - else - loaded = false; - - if (!loaded) - NazaraWarning("Failed to load wgl extension string"); - } - #endif - // AnisotropicFilter s_openGLextensions[OpenGLExtension_AnisotropicFilter] = IsSupported("GL_EXT_texture_filter_anisotropic"); @@ -1248,11 +1174,7 @@ namespace Nz bool OpenGL::IsSupported(const String& string) { -#ifdef NAZARA_PLATFORM_SDL2 return SDL_GL_ExtensionSupported(string.GetConstBuffer()); -#else - return s_openGLextensionSet.find(string) != s_openGLextensionSet.end(); -#endif } void OpenGL::SetBuffer(BufferType type, GLuint id) @@ -2306,18 +2228,4 @@ namespace Nz PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer = nullptr; PFNGLVERTEXATTRIBLPOINTERPROC glVertexAttribLPointer = nullptr; PFNGLVIEWPORTPROC glViewport = nullptr; - -#if defined(NAZARA_PLATFORM_WINDOWS) - PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormat = nullptr; - PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs = nullptr; - PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = nullptr; - PFNWGLGETEXTENSIONSSTRINGEXTPROC wglGetExtensionsStringEXT = nullptr; - PFNWGLSWAPINTERVALEXTPROC wglSwapInterval = nullptr; -#elif defined(NAZARA_PLATFORM_GLX) - GLX::PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs = nullptr; - GLX::PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT = nullptr; - GLX::PFNGLXSWAPINTERVALMESAPROC NzglXSwapIntervalMESA = nullptr; - GLX::PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI = nullptr; -#endif - } diff --git a/src/Nazara/Renderer/Win32/ContextImpl.cpp b/src/Nazara/Renderer/Win32/ContextImpl.cpp deleted file mode 100644 index fa975747d..000000000 --- a/src/Nazara/Renderer/Win32/ContextImpl.cpp +++ /dev/null @@ -1,248 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -// Code inspiré de NeHe (Lesson1) et de la SFML par Laurent Gomila - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - ContextImpl::ContextImpl() - { - } - - bool ContextImpl::Activate() const - { - return wglMakeCurrent(m_deviceContext, m_context) == TRUE; - } - - bool ContextImpl::Create(ContextParameters& parameters) - { - if (parameters.window) - { - m_window = static_cast(parameters.window); - m_ownsWindow = false; - } - else - { - m_window = CreateWindowA("STATIC", nullptr, WS_DISABLED | WS_POPUP, 0, 0, 1, 1, nullptr, nullptr, GetModuleHandle(nullptr), nullptr); - if (!m_window) - { - NazaraError("Failed to create window"); - return false; - } - - ShowWindow(m_window, SW_HIDE); - m_ownsWindow = true; - } - - // En cas d'exception, la ressource sera quand même libérée - CallOnExit onExit([this] () - { - Destroy(); - }); - - m_deviceContext = GetDC(m_window); - if (!m_deviceContext) - { - NazaraError("Failed to get device context"); - return false; - } - - int pixelFormat = 0; - if (parameters.antialiasingLevel > 0) - { - if (wglChoosePixelFormat) - { - bool valid; - UINT numFormats; - - int attributes[] = { - WGL_DRAW_TO_WINDOW_ARB, GL_TRUE, - WGL_SUPPORT_OPENGL_ARB, GL_TRUE, - WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB, - WGL_COLOR_BITS_ARB, (parameters.bitsPerPixel == 32) ? 24 : parameters.bitsPerPixel, - WGL_ALPHA_BITS_ARB, (parameters.bitsPerPixel == 32) ? 8 : 0, - WGL_DEPTH_BITS_ARB, parameters.depthBits, - WGL_STENCIL_BITS_ARB, parameters.stencilBits, - WGL_DOUBLE_BUFFER_ARB, (parameters.doubleBuffered) ? GL_TRUE : GL_FALSE, - WGL_SAMPLE_BUFFERS_ARB, GL_TRUE, - WGL_SAMPLES_ARB, parameters.antialiasingLevel, - 0, 0 - }; - - do - { - valid = (wglChoosePixelFormat(m_deviceContext, attributes, nullptr, 1, &pixelFormat, &numFormats) == TRUE); - } - while ((!valid || numFormats == 0) && --attributes[19] > 0); - - if (!valid) - { - NazaraWarning("Could not find a format matching requirements, disabling antialiasing..."); - pixelFormat = 0; - } - - parameters.antialiasingLevel = attributes[19]; - } - else - { - NazaraWarning("Antialiasing is not supported"); - parameters.antialiasingLevel = 0; - } - } - - PIXELFORMATDESCRIPTOR descriptor; - ZeroMemory(&descriptor, sizeof(PIXELFORMATDESCRIPTOR)); - descriptor.nSize = sizeof(PIXELFORMATDESCRIPTOR); - descriptor.nVersion = 1; - - if (pixelFormat == 0) - { - descriptor.cColorBits = parameters.bitsPerPixel; - descriptor.cDepthBits = parameters.depthBits; - descriptor.cStencilBits = parameters.stencilBits; - descriptor.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL; - descriptor.iPixelType = PFD_TYPE_RGBA; - - if (parameters.bitsPerPixel == 32) - descriptor.cAlphaBits = 8; - - if (parameters.doubleBuffered) - descriptor.dwFlags |= PFD_DOUBLEBUFFER; - - pixelFormat = ChoosePixelFormat(m_deviceContext, &descriptor); - if (pixelFormat == 0) - { - NazaraError("Failed to choose pixel format"); - return false; - } - } - - if (!SetPixelFormat(m_deviceContext, pixelFormat, &descriptor)) - { - NazaraError("Failed to set pixel format"); - return false; - } - - // Arrivé ici, le format de pixel est choisi, nous récupérons donc les paramètres réels du futur contexte - if (DescribePixelFormat(m_deviceContext, pixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &descriptor) != 0) - { - parameters.bitsPerPixel = descriptor.cColorBits + descriptor.cAlphaBits; - parameters.depthBits = descriptor.cDepthBits; - parameters.stencilBits = descriptor.cDepthBits; - } - else - NazaraWarning("Failed to get context's parameters"); - - HGLRC shareContext = (parameters.shared) ? static_cast(parameters.shareContext->m_impl)->m_context : nullptr; - - m_context = nullptr; - if (wglCreateContextAttribs) - { - int attributes[4*2+1]; - int* attrib = attributes; - - *attrib++ = WGL_CONTEXT_MAJOR_VERSION_ARB; - *attrib++ = parameters.majorVersion; - - *attrib++ = WGL_CONTEXT_MINOR_VERSION_ARB; - *attrib++ = parameters.minorVersion; - - if (parameters.majorVersion >= 3) - { - *attrib++ = WGL_CONTEXT_PROFILE_MASK_ARB; - *attrib++ = (parameters.compatibilityProfile) ? WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB : WGL_CONTEXT_CORE_PROFILE_BIT_ARB; - - // Les contextes forward-compatible ne sont plus utilisés pour cette raison : - // http://www.opengl.org/discussion_boards/showthread.php/175052-Forward-compatible-vs-Core-profile - } - - if (parameters.debugMode) - { - *attrib++ = WGL_CONTEXT_FLAGS_ARB; - *attrib++ = WGL_CONTEXT_DEBUG_BIT_ARB; - } - - *attrib++ = 0; - - m_context = wglCreateContextAttribs(m_deviceContext, shareContext, attributes); - } - - if (!m_context) - { - m_context = wglCreateContext(m_deviceContext); - - if (shareContext) - { - // wglShareLists n'est pas thread-safe (source: SFML) - static Mutex mutex; - LockGuard lock(mutex); - - if (!wglShareLists(shareContext, m_context)) - NazaraWarning("Failed to share the context: " + Error::GetLastSystemError()); - } - } - - if (!m_context) - { - NazaraError("Failed to create context"); - return false; - } - - onExit.Reset(); - - return true; - } - - void ContextImpl::Destroy() - { - if (m_context) - { - if (wglGetCurrentContext() == m_context) - wglMakeCurrent(nullptr, nullptr); - - wglDeleteContext(m_context); - m_context = nullptr; - } - - if (m_deviceContext) - { - ReleaseDC(m_window, m_deviceContext); - m_deviceContext = nullptr; - } - - if (m_ownsWindow) - { - DestroyWindow(m_window); - m_window = nullptr; - } - } - - void ContextImpl::EnableVerticalSync(bool enabled) - { - if (wglSwapInterval) - wglSwapInterval(enabled ? 1 : 0); - else - NazaraError("Vertical sync not supported"); - } - - void ContextImpl::SwapBuffers() - { - ::SwapBuffers(m_deviceContext); - } - - bool ContextImpl::Desactivate() - { - return wglMakeCurrent(nullptr, nullptr) == TRUE; - } -} diff --git a/src/Nazara/Renderer/Win32/ContextImpl.hpp b/src/Nazara/Renderer/Win32/ContextImpl.hpp deleted file mode 100644 index b3cf0d053..000000000 --- a/src/Nazara/Renderer/Win32/ContextImpl.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine". -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_CONTEXTIMPL_HPP -#define NAZARA_CONTEXTIMPL_HPP - -#include -#include -#include - -namespace Nz -{ - class ContextImpl - { - public: - ContextImpl(); - - bool Activate() const; - - bool Create(ContextParameters& parameters); - - void Destroy(); - - void EnableVerticalSync(bool enabled); - - void SwapBuffers(); - - static bool Desactivate(); - - private: - HDC m_deviceContext; - HGLRC m_context; - HWND m_window; - bool m_ownsWindow; - }; -} - -#endif // NAZARA_CONTEXTIMPL_HPP diff --git a/thirdparty/include/SDL2/SDL.h b/thirdparty/include/SDL2/SDL.h new file mode 100644 index 000000000..634bf4b6d --- /dev/null +++ b/thirdparty/include/SDL2/SDL.h @@ -0,0 +1,136 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL.h + * + * Main include header for the SDL library + */ + + +#ifndef SDL_h_ +#define SDL_h_ + +#include "SDL_main.h" +#include "SDL_stdinc.h" +#include "SDL_assert.h" +#include "SDL_atomic.h" +#include "SDL_audio.h" +#include "SDL_clipboard.h" +#include "SDL_cpuinfo.h" +#include "SDL_endian.h" +#include "SDL_error.h" +#include "SDL_events.h" +#include "SDL_filesystem.h" +#include "SDL_gamecontroller.h" +#include "SDL_haptic.h" +#include "SDL_hints.h" +#include "SDL_joystick.h" +#include "SDL_loadso.h" +#include "SDL_log.h" +#include "SDL_messagebox.h" +#include "SDL_metal.h" +#include "SDL_mutex.h" +#include "SDL_power.h" +#include "SDL_render.h" +#include "SDL_rwops.h" +#include "SDL_sensor.h" +#include "SDL_shape.h" +#include "SDL_system.h" +#include "SDL_thread.h" +#include "SDL_timer.h" +#include "SDL_version.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* As of version 0.5, SDL is loaded dynamically into the application */ + +/** + * \name SDL_INIT_* + * + * These are the flags which may be passed to SDL_Init(). You should + * specify the subsystems which you will be using in your application. + */ +/* @{ */ +#define SDL_INIT_TIMER 0x00000001u +#define SDL_INIT_AUDIO 0x00000010u +#define SDL_INIT_VIDEO 0x00000020u /**< SDL_INIT_VIDEO implies SDL_INIT_EVENTS */ +#define SDL_INIT_JOYSTICK 0x00000200u /**< SDL_INIT_JOYSTICK implies SDL_INIT_EVENTS */ +#define SDL_INIT_HAPTIC 0x00001000u +#define SDL_INIT_GAMECONTROLLER 0x00002000u /**< SDL_INIT_GAMECONTROLLER implies SDL_INIT_JOYSTICK */ +#define SDL_INIT_EVENTS 0x00004000u +#define SDL_INIT_SENSOR 0x00008000u +#define SDL_INIT_NOPARACHUTE 0x00100000u /**< compatibility; this flag is ignored. */ +#define SDL_INIT_EVERYTHING ( \ + SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS | \ + SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER | SDL_INIT_SENSOR \ + ) +/* @} */ + +/** + * This function initializes the subsystems specified by \c flags + */ +extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags); + +/** + * This function initializes specific SDL subsystems + * + * Subsystem initialization is ref-counted, you must call + * SDL_QuitSubSystem() for each SDL_InitSubSystem() to correctly + * shutdown a subsystem manually (or call SDL_Quit() to force shutdown). + * If a subsystem is already loaded then this call will + * increase the ref-count and return. + */ +extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags); + +/** + * This function cleans up specific SDL subsystems + */ +extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags); + +/** + * This function returns a mask of the specified subsystems which have + * previously been initialized. + * + * If \c flags is 0, it returns a mask of all initialized subsystems. + */ +extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags); + +/** + * This function cleans up all initialized subsystems. You should + * call it upon all exit conditions. + */ +extern DECLSPEC void SDLCALL SDL_Quit(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_assert.h b/thirdparty/include/SDL2/SDL_assert.h new file mode 100644 index 000000000..21bdad998 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_assert.h @@ -0,0 +1,291 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_assert_h_ +#define SDL_assert_h_ + +#include "SDL_config.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef SDL_ASSERT_LEVEL +#ifdef SDL_DEFAULT_ASSERT_LEVEL +#define SDL_ASSERT_LEVEL SDL_DEFAULT_ASSERT_LEVEL +#elif defined(_DEBUG) || defined(DEBUG) || \ + (defined(__GNUC__) && !defined(__OPTIMIZE__)) +#define SDL_ASSERT_LEVEL 2 +#else +#define SDL_ASSERT_LEVEL 1 +#endif +#endif /* SDL_ASSERT_LEVEL */ + +/* +These are macros and not first class functions so that the debugger breaks +on the assertion line and not in some random guts of SDL, and so each +assert can have unique static variables associated with it. +*/ + +#if defined(_MSC_VER) +/* Don't include intrin.h here because it contains C++ code */ + extern void __cdecl __debugbreak(void); + #define SDL_TriggerBreakpoint() __debugbreak() +#elif ( (!defined(__NACL__)) && ((defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))) ) + #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" ) +#elif defined(__386__) && defined(__WATCOMC__) + #define SDL_TriggerBreakpoint() { _asm { int 0x03 } } +#elif defined(HAVE_SIGNAL_H) && !defined(__WATCOMC__) + #include + #define SDL_TriggerBreakpoint() raise(SIGTRAP) +#else + /* How do we trigger breakpoints on this platform? */ + #define SDL_TriggerBreakpoint() +#endif + +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 supports __func__ as a standard. */ +# define SDL_FUNCTION __func__ +#elif ((__GNUC__ >= 2) || defined(_MSC_VER) || defined (__WATCOMC__)) +# define SDL_FUNCTION __FUNCTION__ +#else +# define SDL_FUNCTION "???" +#endif +#define SDL_FILE __FILE__ +#define SDL_LINE __LINE__ + +/* +sizeof (x) makes the compiler still parse the expression even without +assertions enabled, so the code is always checked at compile time, but +doesn't actually generate code for it, so there are no side effects or +expensive checks at run time, just the constant size of what x WOULD be, +which presumably gets optimized out as unused. +This also solves the problem of... + + int somevalue = blah(); + SDL_assert(somevalue == 1); + +...which would cause compiles to complain that somevalue is unused if we +disable assertions. +*/ + +/* "while (0,0)" fools Microsoft's compiler's /W4 warning level into thinking + this condition isn't constant. And looks like an owl's face! */ +#ifdef _MSC_VER /* stupid /W4 warnings. */ +#define SDL_NULL_WHILE_LOOP_CONDITION (0,0) +#else +#define SDL_NULL_WHILE_LOOP_CONDITION (0) +#endif + +#define SDL_disabled_assert(condition) \ + do { (void) sizeof ((condition)); } while (SDL_NULL_WHILE_LOOP_CONDITION) + +typedef enum +{ + SDL_ASSERTION_RETRY, /**< Retry the assert immediately. */ + SDL_ASSERTION_BREAK, /**< Make the debugger trigger a breakpoint. */ + SDL_ASSERTION_ABORT, /**< Terminate the program. */ + SDL_ASSERTION_IGNORE, /**< Ignore the assert. */ + SDL_ASSERTION_ALWAYS_IGNORE /**< Ignore the assert from now on. */ +} SDL_AssertState; + +typedef struct SDL_AssertData +{ + int always_ignore; + unsigned int trigger_count; + const char *condition; + const char *filename; + int linenum; + const char *function; + const struct SDL_AssertData *next; +} SDL_AssertData; + +#if (SDL_ASSERT_LEVEL > 0) + +/* Never call this directly. Use the SDL_assert* macros. */ +extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *, + const char *, + const char *, int) +#if defined(__clang__) +#if __has_feature(attribute_analyzer_noreturn) +/* this tells Clang's static analysis that we're a custom assert function, + and that the analyzer should assume the condition was always true past this + SDL_assert test. */ + __attribute__((analyzer_noreturn)) +#endif +#endif +; + +/* the do {} while(0) avoids dangling else problems: + if (x) SDL_assert(y); else blah(); + ... without the do/while, the "else" could attach to this macro's "if". + We try to handle just the minimum we need here in a macro...the loop, + the static vars, and break points. The heavy lifting is handled in + SDL_ReportAssertion(), in SDL_assert.c. +*/ +#define SDL_enabled_assert(condition) \ + do { \ + while ( !(condition) ) { \ + static struct SDL_AssertData sdl_assert_data = { \ + 0, 0, #condition, 0, 0, 0, 0 \ + }; \ + const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \ + if (sdl_assert_state == SDL_ASSERTION_RETRY) { \ + continue; /* go again. */ \ + } else if (sdl_assert_state == SDL_ASSERTION_BREAK) { \ + SDL_TriggerBreakpoint(); \ + } \ + break; /* not retrying. */ \ + } \ + } while (SDL_NULL_WHILE_LOOP_CONDITION) + +#endif /* enabled assertions support code */ + +/* Enable various levels of assertions. */ +#if SDL_ASSERT_LEVEL == 0 /* assertions disabled */ +# define SDL_assert(condition) SDL_disabled_assert(condition) +# define SDL_assert_release(condition) SDL_disabled_assert(condition) +# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition) +#elif SDL_ASSERT_LEVEL == 1 /* release settings. */ +# define SDL_assert(condition) SDL_disabled_assert(condition) +# define SDL_assert_release(condition) SDL_enabled_assert(condition) +# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition) +#elif SDL_ASSERT_LEVEL == 2 /* normal settings. */ +# define SDL_assert(condition) SDL_enabled_assert(condition) +# define SDL_assert_release(condition) SDL_enabled_assert(condition) +# define SDL_assert_paranoid(condition) SDL_disabled_assert(condition) +#elif SDL_ASSERT_LEVEL == 3 /* paranoid settings. */ +# define SDL_assert(condition) SDL_enabled_assert(condition) +# define SDL_assert_release(condition) SDL_enabled_assert(condition) +# define SDL_assert_paranoid(condition) SDL_enabled_assert(condition) +#else +# error Unknown assertion level. +#endif + +/* this assertion is never disabled at any level. */ +#define SDL_assert_always(condition) SDL_enabled_assert(condition) + + +typedef SDL_AssertState (SDLCALL *SDL_AssertionHandler)( + const SDL_AssertData* data, void* userdata); + +/** + * \brief Set an application-defined assertion handler. + * + * This allows an app to show its own assertion UI and/or force the + * response to an assertion failure. If the app doesn't provide this, SDL + * will try to do the right thing, popping up a system-specific GUI dialog, + * and probably minimizing any fullscreen windows. + * + * This callback may fire from any thread, but it runs wrapped in a mutex, so + * it will only fire from one thread at a time. + * + * Setting the callback to NULL restores SDL's original internal handler. + * + * This callback is NOT reset to SDL's internal handler upon SDL_Quit()! + * + * Return SDL_AssertState value of how to handle the assertion failure. + * + * \param handler Callback function, called when an assertion fails. + * \param userdata A pointer passed to the callback as-is. + */ +extern DECLSPEC void SDLCALL SDL_SetAssertionHandler( + SDL_AssertionHandler handler, + void *userdata); + +/** + * \brief Get the default assertion handler. + * + * This returns the function pointer that is called by default when an + * assertion is triggered. This is an internal function provided by SDL, + * that is used for assertions when SDL_SetAssertionHandler() hasn't been + * used to provide a different function. + * + * \return The default SDL_AssertionHandler that is called when an assert triggers. + */ +extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetDefaultAssertionHandler(void); + +/** + * \brief Get the current assertion handler. + * + * This returns the function pointer that is called when an assertion is + * triggered. This is either the value last passed to + * SDL_SetAssertionHandler(), or if no application-specified function is + * set, is equivalent to calling SDL_GetDefaultAssertionHandler(). + * + * \param puserdata Pointer to a void*, which will store the "userdata" + * pointer that was passed to SDL_SetAssertionHandler(). + * This value will always be NULL for the default handler. + * If you don't care about this data, it is safe to pass + * a NULL pointer to this function to ignore it. + * \return The SDL_AssertionHandler that is called when an assert triggers. + */ +extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetAssertionHandler(void **puserdata); + +/** + * \brief Get a list of all assertion failures. + * + * Get all assertions triggered since last call to SDL_ResetAssertionReport(), + * or the start of the program. + * + * The proper way to examine this data looks something like this: + * + * + * const SDL_AssertData *item = SDL_GetAssertionReport(); + * while (item) { + * printf("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\\n", + * item->condition, item->function, item->filename, + * item->linenum, item->trigger_count, + * item->always_ignore ? "yes" : "no"); + * item = item->next; + * } + * + * + * \return List of all assertions. + * \sa SDL_ResetAssertionReport + */ +extern DECLSPEC const SDL_AssertData * SDLCALL SDL_GetAssertionReport(void); + +/** + * \brief Reset the list of all assertion failures. + * + * Reset list of all assertions triggered. + * + * \sa SDL_GetAssertionReport + */ +extern DECLSPEC void SDLCALL SDL_ResetAssertionReport(void); + + +/* these had wrong naming conventions until 2.0.4. Please update your app! */ +#define SDL_assert_state SDL_AssertState +#define SDL_assert_data SDL_AssertData + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_assert_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_atomic.h b/thirdparty/include/SDL2/SDL_atomic.h new file mode 100644 index 000000000..e99f1bcc6 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_atomic.h @@ -0,0 +1,295 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_atomic.h + * + * Atomic operations. + * + * IMPORTANT: + * If you are not an expert in concurrent lockless programming, you should + * only be using the atomic lock and reference counting functions in this + * file. In all other cases you should be protecting your data structures + * with full mutexes. + * + * The list of "safe" functions to use are: + * SDL_AtomicLock() + * SDL_AtomicUnlock() + * SDL_AtomicIncRef() + * SDL_AtomicDecRef() + * + * Seriously, here be dragons! + * ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + * + * You can find out a little more about lockless programming and the + * subtle issues that can arise here: + * http://msdn.microsoft.com/en-us/library/ee418650%28v=vs.85%29.aspx + * + * There's also lots of good information here: + * http://www.1024cores.net/home/lock-free-algorithms + * http://preshing.com/ + * + * These operations may or may not actually be implemented using + * processor specific atomic operations. When possible they are + * implemented as true processor specific atomic operations. When that + * is not possible the are implemented using locks that *do* use the + * available atomic operations. + * + * All of the atomic operations that modify memory are full memory barriers. + */ + +#ifndef SDL_atomic_h_ +#define SDL_atomic_h_ + +#include "SDL_stdinc.h" +#include "SDL_platform.h" + +#include "begin_code.h" + +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \name SDL AtomicLock + * + * The atomic locks are efficient spinlocks using CPU instructions, + * but are vulnerable to starvation and can spin forever if a thread + * holding a lock has been terminated. For this reason you should + * minimize the code executed inside an atomic lock and never do + * expensive things like API or system calls while holding them. + * + * The atomic locks are not safe to lock recursively. + * + * Porting Note: + * The spin lock functions and type are required and can not be + * emulated because they are used in the atomic emulation code. + */ +/* @{ */ + +typedef int SDL_SpinLock; + +/** + * \brief Try to lock a spin lock by setting it to a non-zero value. + * + * \param lock Points to the lock. + * + * \return SDL_TRUE if the lock succeeded, SDL_FALSE if the lock is already held. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTryLock(SDL_SpinLock *lock); + +/** + * \brief Lock a spin lock by setting it to a non-zero value. + * + * \param lock Points to the lock. + */ +extern DECLSPEC void SDLCALL SDL_AtomicLock(SDL_SpinLock *lock); + +/** + * \brief Unlock a spin lock by setting it to 0. Always returns immediately + * + * \param lock Points to the lock. + */ +extern DECLSPEC void SDLCALL SDL_AtomicUnlock(SDL_SpinLock *lock); + +/* @} *//* SDL AtomicLock */ + + +/** + * The compiler barrier prevents the compiler from reordering + * reads and writes to globally visible variables across the call. + */ +#if defined(_MSC_VER) && (_MSC_VER > 1200) && !defined(__clang__) +void _ReadWriteBarrier(void); +#pragma intrinsic(_ReadWriteBarrier) +#define SDL_CompilerBarrier() _ReadWriteBarrier() +#elif (defined(__GNUC__) && !defined(__EMSCRIPTEN__)) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120)) +/* This is correct for all CPUs when using GCC or Solaris Studio 12.1+. */ +#define SDL_CompilerBarrier() __asm__ __volatile__ ("" : : : "memory") +#elif defined(__WATCOMC__) +extern _inline void SDL_CompilerBarrier (void); +#pragma aux SDL_CompilerBarrier = "" parm [] modify exact []; +#else +#define SDL_CompilerBarrier() \ +{ SDL_SpinLock _tmp = 0; SDL_AtomicLock(&_tmp); SDL_AtomicUnlock(&_tmp); } +#endif + +/** + * Memory barriers are designed to prevent reads and writes from being + * reordered by the compiler and being seen out of order on multi-core CPUs. + * + * A typical pattern would be for thread A to write some data and a flag, + * and for thread B to read the flag and get the data. In this case you + * would insert a release barrier between writing the data and the flag, + * guaranteeing that the data write completes no later than the flag is + * written, and you would insert an acquire barrier between reading the + * flag and reading the data, to ensure that all the reads associated + * with the flag have completed. + * + * In this pattern you should always see a release barrier paired with + * an acquire barrier and you should gate the data reads/writes with a + * single flag variable. + * + * For more information on these semantics, take a look at the blog post: + * http://preshing.com/20120913/acquire-and-release-semantics + */ +extern DECLSPEC void SDLCALL SDL_MemoryBarrierReleaseFunction(void); +extern DECLSPEC void SDLCALL SDL_MemoryBarrierAcquireFunction(void); + +#if defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) +#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("lwsync" : : : "memory") +#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("lwsync" : : : "memory") +#elif defined(__GNUC__) && defined(__aarch64__) +#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory") +#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory") +#elif defined(__GNUC__) && defined(__arm__) +#if 0 /* defined(__LINUX__) || defined(__ANDROID__) */ +/* Information from: + https://chromium.googlesource.com/chromium/chromium/+/trunk/base/atomicops_internals_arm_gcc.h#19 + + The Linux kernel provides a helper function which provides the right code for a memory barrier, + hard-coded at address 0xffff0fa0 +*/ +typedef void (*SDL_KernelMemoryBarrierFunc)(); +#define SDL_MemoryBarrierRelease() ((SDL_KernelMemoryBarrierFunc)0xffff0fa0)() +#define SDL_MemoryBarrierAcquire() ((SDL_KernelMemoryBarrierFunc)0xffff0fa0)() +#elif 0 /* defined(__QNXNTO__) */ +#include + +#define SDL_MemoryBarrierRelease() __cpu_membarrier() +#define SDL_MemoryBarrierAcquire() __cpu_membarrier() +#else +#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) || defined(__ARM_ARCH_8A__) +#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory") +#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory") +#elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_5TE__) +#ifdef __thumb__ +/* The mcr instruction isn't available in thumb mode, use real functions */ +#define SDL_MEMORY_BARRIER_USES_FUNCTION +#define SDL_MemoryBarrierRelease() SDL_MemoryBarrierReleaseFunction() +#define SDL_MemoryBarrierAcquire() SDL_MemoryBarrierAcquireFunction() +#else +#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r"(0) : "memory") +#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r"(0) : "memory") +#endif /* __thumb__ */ +#else +#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("" : : : "memory") +#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("" : : : "memory") +#endif /* __LINUX__ || __ANDROID__ */ +#endif /* __GNUC__ && __arm__ */ +#else +#if (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120)) +/* This is correct for all CPUs on Solaris when using Solaris Studio 12.1+. */ +#include +#define SDL_MemoryBarrierRelease() __machine_rel_barrier() +#define SDL_MemoryBarrierAcquire() __machine_acq_barrier() +#else +/* This is correct for the x86 and x64 CPUs, and we'll expand this over time. */ +#define SDL_MemoryBarrierRelease() SDL_CompilerBarrier() +#define SDL_MemoryBarrierAcquire() SDL_CompilerBarrier() +#endif +#endif + +/** + * \brief A type representing an atomic integer value. It is a struct + * so people don't accidentally use numeric operations on it. + */ +typedef struct { int value; } SDL_atomic_t; + +/** + * \brief Set an atomic variable to a new value if it is currently an old value. + * + * \return SDL_TRUE if the atomic variable was set, SDL_FALSE otherwise. + * + * \note If you don't know what this function is for, you shouldn't use it! +*/ +extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int newval); + +/** + * \brief Set an atomic variable to a value. + * + * \return The previous value of the atomic variable. + */ +extern DECLSPEC int SDLCALL SDL_AtomicSet(SDL_atomic_t *a, int v); + +/** + * \brief Get the value of an atomic variable + */ +extern DECLSPEC int SDLCALL SDL_AtomicGet(SDL_atomic_t *a); + +/** + * \brief Add to an atomic variable. + * + * \return The previous value of the atomic variable. + * + * \note This same style can be used for any number operation + */ +extern DECLSPEC int SDLCALL SDL_AtomicAdd(SDL_atomic_t *a, int v); + +/** + * \brief Increment an atomic variable used as a reference count. + */ +#ifndef SDL_AtomicIncRef +#define SDL_AtomicIncRef(a) SDL_AtomicAdd(a, 1) +#endif + +/** + * \brief Decrement an atomic variable used as a reference count. + * + * \return SDL_TRUE if the variable reached zero after decrementing, + * SDL_FALSE otherwise + */ +#ifndef SDL_AtomicDecRef +#define SDL_AtomicDecRef(a) (SDL_AtomicAdd(a, -1) == 1) +#endif + +/** + * \brief Set a pointer to a new value if it is currently an old value. + * + * \return SDL_TRUE if the pointer was set, SDL_FALSE otherwise. + * + * \note If you don't know what this function is for, you shouldn't use it! +*/ +extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCASPtr(void **a, void *oldval, void *newval); + +/** + * \brief Set a pointer to a value atomically. + * + * \return The previous value of the pointer. + */ +extern DECLSPEC void* SDLCALL SDL_AtomicSetPtr(void **a, void* v); + +/** + * \brief Get the value of a pointer atomically. + */ +extern DECLSPEC void* SDLCALL SDL_AtomicGetPtr(void **a); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif + +#include "close_code.h" + +#endif /* SDL_atomic_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_audio.h b/thirdparty/include/SDL2/SDL_audio.h new file mode 100644 index 000000000..4ba349147 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_audio.h @@ -0,0 +1,859 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_audio.h + * + * Access to the raw audio mixing buffer for the SDL library. + */ + +#ifndef SDL_audio_h_ +#define SDL_audio_h_ + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_endian.h" +#include "SDL_mutex.h" +#include "SDL_thread.h" +#include "SDL_rwops.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Audio format flags. + * + * These are what the 16 bits in SDL_AudioFormat currently mean... + * (Unspecified bits are always zero). + * + * \verbatim + ++-----------------------sample is signed if set + || + || ++-----------sample is bigendian if set + || || + || || ++---sample is float if set + || || || + || || || +---sample bit size---+ + || || || | | + 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 + \endverbatim + * + * There are macros in SDL 2.0 and later to query these bits. + */ +typedef Uint16 SDL_AudioFormat; + +/** + * \name Audio flags + */ +/* @{ */ + +#define SDL_AUDIO_MASK_BITSIZE (0xFF) +#define SDL_AUDIO_MASK_DATATYPE (1<<8) +#define SDL_AUDIO_MASK_ENDIAN (1<<12) +#define SDL_AUDIO_MASK_SIGNED (1<<15) +#define SDL_AUDIO_BITSIZE(x) (x & SDL_AUDIO_MASK_BITSIZE) +#define SDL_AUDIO_ISFLOAT(x) (x & SDL_AUDIO_MASK_DATATYPE) +#define SDL_AUDIO_ISBIGENDIAN(x) (x & SDL_AUDIO_MASK_ENDIAN) +#define SDL_AUDIO_ISSIGNED(x) (x & SDL_AUDIO_MASK_SIGNED) +#define SDL_AUDIO_ISINT(x) (!SDL_AUDIO_ISFLOAT(x)) +#define SDL_AUDIO_ISLITTLEENDIAN(x) (!SDL_AUDIO_ISBIGENDIAN(x)) +#define SDL_AUDIO_ISUNSIGNED(x) (!SDL_AUDIO_ISSIGNED(x)) + +/** + * \name Audio format flags + * + * Defaults to LSB byte order. + */ +/* @{ */ +#define AUDIO_U8 0x0008 /**< Unsigned 8-bit samples */ +#define AUDIO_S8 0x8008 /**< Signed 8-bit samples */ +#define AUDIO_U16LSB 0x0010 /**< Unsigned 16-bit samples */ +#define AUDIO_S16LSB 0x8010 /**< Signed 16-bit samples */ +#define AUDIO_U16MSB 0x1010 /**< As above, but big-endian byte order */ +#define AUDIO_S16MSB 0x9010 /**< As above, but big-endian byte order */ +#define AUDIO_U16 AUDIO_U16LSB +#define AUDIO_S16 AUDIO_S16LSB +/* @} */ + +/** + * \name int32 support + */ +/* @{ */ +#define AUDIO_S32LSB 0x8020 /**< 32-bit integer samples */ +#define AUDIO_S32MSB 0x9020 /**< As above, but big-endian byte order */ +#define AUDIO_S32 AUDIO_S32LSB +/* @} */ + +/** + * \name float32 support + */ +/* @{ */ +#define AUDIO_F32LSB 0x8120 /**< 32-bit floating point samples */ +#define AUDIO_F32MSB 0x9120 /**< As above, but big-endian byte order */ +#define AUDIO_F32 AUDIO_F32LSB +/* @} */ + +/** + * \name Native audio byte ordering + */ +/* @{ */ +#if SDL_BYTEORDER == SDL_LIL_ENDIAN +#define AUDIO_U16SYS AUDIO_U16LSB +#define AUDIO_S16SYS AUDIO_S16LSB +#define AUDIO_S32SYS AUDIO_S32LSB +#define AUDIO_F32SYS AUDIO_F32LSB +#else +#define AUDIO_U16SYS AUDIO_U16MSB +#define AUDIO_S16SYS AUDIO_S16MSB +#define AUDIO_S32SYS AUDIO_S32MSB +#define AUDIO_F32SYS AUDIO_F32MSB +#endif +/* @} */ + +/** + * \name Allow change flags + * + * Which audio format changes are allowed when opening a device. + */ +/* @{ */ +#define SDL_AUDIO_ALLOW_FREQUENCY_CHANGE 0x00000001 +#define SDL_AUDIO_ALLOW_FORMAT_CHANGE 0x00000002 +#define SDL_AUDIO_ALLOW_CHANNELS_CHANGE 0x00000004 +#define SDL_AUDIO_ALLOW_SAMPLES_CHANGE 0x00000008 +#define SDL_AUDIO_ALLOW_ANY_CHANGE (SDL_AUDIO_ALLOW_FREQUENCY_CHANGE|SDL_AUDIO_ALLOW_FORMAT_CHANGE|SDL_AUDIO_ALLOW_CHANNELS_CHANGE|SDL_AUDIO_ALLOW_SAMPLES_CHANGE) +/* @} */ + +/* @} *//* Audio flags */ + +/** + * This function is called when the audio device needs more data. + * + * \param userdata An application-specific parameter saved in + * the SDL_AudioSpec structure + * \param stream A pointer to the audio data buffer. + * \param len The length of that buffer in bytes. + * + * Once the callback returns, the buffer will no longer be valid. + * Stereo samples are stored in a LRLRLR ordering. + * + * You can choose to avoid callbacks and use SDL_QueueAudio() instead, if + * you like. Just open your audio device with a NULL callback. + */ +typedef void (SDLCALL * SDL_AudioCallback) (void *userdata, Uint8 * stream, + int len); + +/** + * The calculated values in this structure are calculated by SDL_OpenAudio(). + * + * For multi-channel audio, the default SDL channel mapping is: + * 2: FL FR (stereo) + * 3: FL FR LFE (2.1 surround) + * 4: FL FR BL BR (quad) + * 5: FL FR FC BL BR (quad + center) + * 6: FL FR FC LFE SL SR (5.1 surround - last two can also be BL BR) + * 7: FL FR FC LFE BC SL SR (6.1 surround) + * 8: FL FR FC LFE BL BR SL SR (7.1 surround) + */ +typedef struct SDL_AudioSpec +{ + int freq; /**< DSP frequency -- samples per second */ + SDL_AudioFormat format; /**< Audio data format */ + Uint8 channels; /**< Number of channels: 1 mono, 2 stereo */ + Uint8 silence; /**< Audio buffer silence value (calculated) */ + Uint16 samples; /**< Audio buffer size in sample FRAMES (total samples divided by channel count) */ + Uint16 padding; /**< Necessary for some compile environments */ + Uint32 size; /**< Audio buffer size in bytes (calculated) */ + SDL_AudioCallback callback; /**< Callback that feeds the audio device (NULL to use SDL_QueueAudio()). */ + void *userdata; /**< Userdata passed to callback (ignored for NULL callbacks). */ +} SDL_AudioSpec; + + +struct SDL_AudioCVT; +typedef void (SDLCALL * SDL_AudioFilter) (struct SDL_AudioCVT * cvt, + SDL_AudioFormat format); + +/** + * \brief Upper limit of filters in SDL_AudioCVT + * + * The maximum number of SDL_AudioFilter functions in SDL_AudioCVT is + * currently limited to 9. The SDL_AudioCVT.filters array has 10 pointers, + * one of which is the terminating NULL pointer. + */ +#define SDL_AUDIOCVT_MAX_FILTERS 9 + +/** + * \struct SDL_AudioCVT + * \brief A structure to hold a set of audio conversion filters and buffers. + * + * Note that various parts of the conversion pipeline can take advantage + * of SIMD operations (like SSE2, for example). SDL_AudioCVT doesn't require + * you to pass it aligned data, but can possibly run much faster if you + * set both its (buf) field to a pointer that is aligned to 16 bytes, and its + * (len) field to something that's a multiple of 16, if possible. + */ +#ifdef __GNUC__ +/* This structure is 84 bytes on 32-bit architectures, make sure GCC doesn't + pad it out to 88 bytes to guarantee ABI compatibility between compilers. + vvv + The next time we rev the ABI, make sure to size the ints and add padding. +*/ +#define SDL_AUDIOCVT_PACKED __attribute__((packed)) +#else +#define SDL_AUDIOCVT_PACKED +#endif +/* */ +typedef struct SDL_AudioCVT +{ + int needed; /**< Set to 1 if conversion possible */ + SDL_AudioFormat src_format; /**< Source audio format */ + SDL_AudioFormat dst_format; /**< Target audio format */ + double rate_incr; /**< Rate conversion increment */ + Uint8 *buf; /**< Buffer to hold entire audio data */ + int len; /**< Length of original audio buffer */ + int len_cvt; /**< Length of converted audio buffer */ + int len_mult; /**< buffer must be len*len_mult big */ + double len_ratio; /**< Given len, final size is len*len_ratio */ + SDL_AudioFilter filters[SDL_AUDIOCVT_MAX_FILTERS + 1]; /**< NULL-terminated list of filter functions */ + int filter_index; /**< Current audio conversion function */ +} SDL_AUDIOCVT_PACKED SDL_AudioCVT; + + +/* Function prototypes */ + +/** + * \name Driver discovery functions + * + * These functions return the list of built in audio drivers, in the + * order that they are normally initialized by default. + */ +/* @{ */ +extern DECLSPEC int SDLCALL SDL_GetNumAudioDrivers(void); +extern DECLSPEC const char *SDLCALL SDL_GetAudioDriver(int index); +/* @} */ + +/** + * \name Initialization and cleanup + * + * \internal These functions are used internally, and should not be used unless + * you have a specific need to specify the audio driver you want to + * use. You should normally use SDL_Init() or SDL_InitSubSystem(). + */ +/* @{ */ +extern DECLSPEC int SDLCALL SDL_AudioInit(const char *driver_name); +extern DECLSPEC void SDLCALL SDL_AudioQuit(void); +/* @} */ + +/** + * This function returns the name of the current audio driver, or NULL + * if no driver has been initialized. + */ +extern DECLSPEC const char *SDLCALL SDL_GetCurrentAudioDriver(void); + +/** + * This function opens the audio device with the desired parameters, and + * returns 0 if successful, placing the actual hardware parameters in the + * structure pointed to by \c obtained. If \c obtained is NULL, the audio + * data passed to the callback function will be guaranteed to be in the + * requested format, and will be automatically converted to the hardware + * audio format if necessary. This function returns -1 if it failed + * to open the audio device, or couldn't set up the audio thread. + * + * When filling in the desired audio spec structure, + * - \c desired->freq should be the desired audio frequency in samples-per- + * second. + * - \c desired->format should be the desired audio format. + * - \c desired->samples is the desired size of the audio buffer, in + * samples. This number should be a power of two, and may be adjusted by + * the audio driver to a value more suitable for the hardware. Good values + * seem to range between 512 and 8096 inclusive, depending on the + * application and CPU speed. Smaller values yield faster response time, + * but can lead to underflow if the application is doing heavy processing + * and cannot fill the audio buffer in time. A stereo sample consists of + * both right and left channels in LR ordering. + * Note that the number of samples is directly related to time by the + * following formula: \code ms = (samples*1000)/freq \endcode + * - \c desired->size is the size in bytes of the audio buffer, and is + * calculated by SDL_OpenAudio(). + * - \c desired->silence is the value used to set the buffer to silence, + * and is calculated by SDL_OpenAudio(). + * - \c desired->callback should be set to a function that will be called + * when the audio device is ready for more data. It is passed a pointer + * to the audio buffer, and the length in bytes of the audio buffer. + * This function usually runs in a separate thread, and so you should + * protect data structures that it accesses by calling SDL_LockAudio() + * and SDL_UnlockAudio() in your code. Alternately, you may pass a NULL + * pointer here, and call SDL_QueueAudio() with some frequency, to queue + * more audio samples to be played (or for capture devices, call + * SDL_DequeueAudio() with some frequency, to obtain audio samples). + * - \c desired->userdata is passed as the first parameter to your callback + * function. If you passed a NULL callback, this value is ignored. + * + * The audio device starts out playing silence when it's opened, and should + * be enabled for playing by calling \c SDL_PauseAudio(0) when you are ready + * for your audio callback function to be called. Since the audio driver + * may modify the requested size of the audio buffer, you should allocate + * any local mixing buffers after you open the audio device. + */ +extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec * desired, + SDL_AudioSpec * obtained); + +/** + * SDL Audio Device IDs. + * + * A successful call to SDL_OpenAudio() is always device id 1, and legacy + * SDL audio APIs assume you want this device ID. SDL_OpenAudioDevice() calls + * always returns devices >= 2 on success. The legacy calls are good both + * for backwards compatibility and when you don't care about multiple, + * specific, or capture devices. + */ +typedef Uint32 SDL_AudioDeviceID; + +/** + * Get the number of available devices exposed by the current driver. + * Only valid after a successfully initializing the audio subsystem. + * Returns -1 if an explicit list of devices can't be determined; this is + * not an error. For example, if SDL is set up to talk to a remote audio + * server, it can't list every one available on the Internet, but it will + * still allow a specific host to be specified to SDL_OpenAudioDevice(). + * + * In many common cases, when this function returns a value <= 0, it can still + * successfully open the default device (NULL for first argument of + * SDL_OpenAudioDevice()). + */ +extern DECLSPEC int SDLCALL SDL_GetNumAudioDevices(int iscapture); + +/** + * Get the human-readable name of a specific audio device. + * Must be a value between 0 and (number of audio devices-1). + * Only valid after a successfully initializing the audio subsystem. + * The values returned by this function reflect the latest call to + * SDL_GetNumAudioDevices(); recall that function to redetect available + * hardware. + * + * The string returned by this function is UTF-8 encoded, read-only, and + * managed internally. You are not to free it. If you need to keep the + * string for any length of time, you should make your own copy of it, as it + * will be invalid next time any of several other SDL functions is called. + */ +extern DECLSPEC const char *SDLCALL SDL_GetAudioDeviceName(int index, + int iscapture); + + +/** + * Open a specific audio device. Passing in a device name of NULL requests + * the most reasonable default (and is equivalent to calling SDL_OpenAudio()). + * + * The device name is a UTF-8 string reported by SDL_GetAudioDeviceName(), but + * some drivers allow arbitrary and driver-specific strings, such as a + * hostname/IP address for a remote audio server, or a filename in the + * diskaudio driver. + * + * \return 0 on error, a valid device ID that is >= 2 on success. + * + * SDL_OpenAudio(), unlike this function, always acts on device ID 1. + */ +extern DECLSPEC SDL_AudioDeviceID SDLCALL SDL_OpenAudioDevice(const char + *device, + int iscapture, + const + SDL_AudioSpec * + desired, + SDL_AudioSpec * + obtained, + int + allowed_changes); + + + +/** + * \name Audio state + * + * Get the current audio state. + */ +/* @{ */ +typedef enum +{ + SDL_AUDIO_STOPPED = 0, + SDL_AUDIO_PLAYING, + SDL_AUDIO_PAUSED +} SDL_AudioStatus; +extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioStatus(void); + +extern DECLSPEC SDL_AudioStatus SDLCALL +SDL_GetAudioDeviceStatus(SDL_AudioDeviceID dev); +/* @} *//* Audio State */ + +/** + * \name Pause audio functions + * + * These functions pause and unpause the audio callback processing. + * They should be called with a parameter of 0 after opening the audio + * device to start playing sound. This is so you can safely initialize + * data for your callback function after opening the audio device. + * Silence will be written to the audio device during the pause. + */ +/* @{ */ +extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on); +extern DECLSPEC void SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev, + int pause_on); +/* @} *//* Pause audio functions */ + +/** + * \brief Load the audio data of a WAVE file into memory + * + * Loading a WAVE file requires \c src, \c spec, \c audio_buf and \c audio_len + * to be valid pointers. The entire data portion of the file is then loaded + * into memory and decoded if necessary. + * + * If \c freesrc is non-zero, the data source gets automatically closed and + * freed before the function returns. + * + * Supported are RIFF WAVE files with the formats PCM (8, 16, 24, and 32 bits), + * IEEE Float (32 bits), Microsoft ADPCM and IMA ADPCM (4 bits), and A-law and + * µ-law (8 bits). Other formats are currently unsupported and cause an error. + * + * If this function succeeds, the pointer returned by it is equal to \c spec + * and the pointer to the audio data allocated by the function is written to + * \c audio_buf and its length in bytes to \c audio_len. The \ref SDL_AudioSpec + * members \c freq, \c channels, and \c format are set to the values of the + * audio data in the buffer. The \c samples member is set to a sane default and + * all others are set to zero. + * + * It's necessary to use SDL_FreeWAV() to free the audio data returned in + * \c audio_buf when it is no longer used. + * + * Because of the underspecification of the Waveform format, there are many + * problematic files in the wild that cause issues with strict decoders. To + * provide compatibility with these files, this decoder is lenient in regards + * to the truncation of the file, the fact chunk, and the size of the RIFF + * chunk. The hints SDL_HINT_WAVE_RIFF_CHUNK_SIZE, SDL_HINT_WAVE_TRUNCATION, + * and SDL_HINT_WAVE_FACT_CHUNK can be used to tune the behavior of the + * loading process. + * + * Any file that is invalid (due to truncation, corruption, or wrong values in + * the headers), too big, or unsupported causes an error. Additionally, any + * critical I/O error from the data source will terminate the loading process + * with an error. The function returns NULL on error and in all cases (with the + * exception of \c src being NULL), an appropriate error message will be set. + * + * It is required that the data source supports seeking. + * + * Example: + * \code + * SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...); + * \endcode + * + * \param src The data source with the WAVE data + * \param freesrc A integer value that makes the function close the data source if non-zero + * \param spec A pointer filled with the audio format of the audio data + * \param audio_buf A pointer filled with the audio data allocated by the function + * \param audio_len A pointer filled with the length of the audio data buffer in bytes + * \return NULL on error, or non-NULL on success. + */ +extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src, + int freesrc, + SDL_AudioSpec * spec, + Uint8 ** audio_buf, + Uint32 * audio_len); + +/** + * Loads a WAV from a file. + * Compatibility convenience function. + */ +#define SDL_LoadWAV(file, spec, audio_buf, audio_len) \ + SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len) + +/** + * This function frees data previously allocated with SDL_LoadWAV_RW() + */ +extern DECLSPEC void SDLCALL SDL_FreeWAV(Uint8 * audio_buf); + +/** + * This function takes a source format and rate and a destination format + * and rate, and initializes the \c cvt structure with information needed + * by SDL_ConvertAudio() to convert a buffer of audio data from one format + * to the other. An unsupported format causes an error and -1 will be returned. + * + * \return 0 if no conversion is needed, 1 if the audio filter is set up, + * or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT * cvt, + SDL_AudioFormat src_format, + Uint8 src_channels, + int src_rate, + SDL_AudioFormat dst_format, + Uint8 dst_channels, + int dst_rate); + +/** + * Once you have initialized the \c cvt structure using SDL_BuildAudioCVT(), + * created an audio buffer \c cvt->buf, and filled it with \c cvt->len bytes of + * audio data in the source format, this function will convert it in-place + * to the desired format. + * + * The data conversion may expand the size of the audio data, so the buffer + * \c cvt->buf should be allocated after the \c cvt structure is initialized by + * SDL_BuildAudioCVT(), and should be \c cvt->len*cvt->len_mult bytes long. + * + * \return 0 on success or -1 if \c cvt->buf is NULL. + */ +extern DECLSPEC int SDLCALL SDL_ConvertAudio(SDL_AudioCVT * cvt); + +/* SDL_AudioStream is a new audio conversion interface. + The benefits vs SDL_AudioCVT: + - it can handle resampling data in chunks without generating + artifacts, when it doesn't have the complete buffer available. + - it can handle incoming data in any variable size. + - You push data as you have it, and pull it when you need it + */ +/* this is opaque to the outside world. */ +struct _SDL_AudioStream; +typedef struct _SDL_AudioStream SDL_AudioStream; + +/** + * Create a new audio stream + * + * \param src_format The format of the source audio + * \param src_channels The number of channels of the source audio + * \param src_rate The sampling rate of the source audio + * \param dst_format The format of the desired audio output + * \param dst_channels The number of channels of the desired audio output + * \param dst_rate The sampling rate of the desired audio output + * \return 0 on success, or -1 on error. + * + * \sa SDL_AudioStreamPut + * \sa SDL_AudioStreamGet + * \sa SDL_AudioStreamAvailable + * \sa SDL_AudioStreamFlush + * \sa SDL_AudioStreamClear + * \sa SDL_FreeAudioStream + */ +extern DECLSPEC SDL_AudioStream * SDLCALL SDL_NewAudioStream(const SDL_AudioFormat src_format, + const Uint8 src_channels, + const int src_rate, + const SDL_AudioFormat dst_format, + const Uint8 dst_channels, + const int dst_rate); + +/** + * Add data to be converted/resampled to the stream + * + * \param stream The stream the audio data is being added to + * \param buf A pointer to the audio data to add + * \param len The number of bytes to write to the stream + * \return 0 on success, or -1 on error. + * + * \sa SDL_NewAudioStream + * \sa SDL_AudioStreamGet + * \sa SDL_AudioStreamAvailable + * \sa SDL_AudioStreamFlush + * \sa SDL_AudioStreamClear + * \sa SDL_FreeAudioStream + */ +extern DECLSPEC int SDLCALL SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len); + +/** + * Get converted/resampled data from the stream + * + * \param stream The stream the audio is being requested from + * \param buf A buffer to fill with audio data + * \param len The maximum number of bytes to fill + * \return The number of bytes read from the stream, or -1 on error + * + * \sa SDL_NewAudioStream + * \sa SDL_AudioStreamPut + * \sa SDL_AudioStreamAvailable + * \sa SDL_AudioStreamFlush + * \sa SDL_AudioStreamClear + * \sa SDL_FreeAudioStream + */ +extern DECLSPEC int SDLCALL SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len); + +/** + * Get the number of converted/resampled bytes available. The stream may be + * buffering data behind the scenes until it has enough to resample + * correctly, so this number might be lower than what you expect, or even + * be zero. Add more data or flush the stream if you need the data now. + * + * \sa SDL_NewAudioStream + * \sa SDL_AudioStreamPut + * \sa SDL_AudioStreamGet + * \sa SDL_AudioStreamFlush + * \sa SDL_AudioStreamClear + * \sa SDL_FreeAudioStream + */ +extern DECLSPEC int SDLCALL SDL_AudioStreamAvailable(SDL_AudioStream *stream); + +/** + * Tell the stream that you're done sending data, and anything being buffered + * should be converted/resampled and made available immediately. + * + * It is legal to add more data to a stream after flushing, but there will + * be audio gaps in the output. Generally this is intended to signal the + * end of input, so the complete output becomes available. + * + * \sa SDL_NewAudioStream + * \sa SDL_AudioStreamPut + * \sa SDL_AudioStreamGet + * \sa SDL_AudioStreamAvailable + * \sa SDL_AudioStreamClear + * \sa SDL_FreeAudioStream + */ +extern DECLSPEC int SDLCALL SDL_AudioStreamFlush(SDL_AudioStream *stream); + +/** + * Clear any pending data in the stream without converting it + * + * \sa SDL_NewAudioStream + * \sa SDL_AudioStreamPut + * \sa SDL_AudioStreamGet + * \sa SDL_AudioStreamAvailable + * \sa SDL_AudioStreamFlush + * \sa SDL_FreeAudioStream + */ +extern DECLSPEC void SDLCALL SDL_AudioStreamClear(SDL_AudioStream *stream); + +/** + * Free an audio stream + * + * \sa SDL_NewAudioStream + * \sa SDL_AudioStreamPut + * \sa SDL_AudioStreamGet + * \sa SDL_AudioStreamAvailable + * \sa SDL_AudioStreamFlush + * \sa SDL_AudioStreamClear + */ +extern DECLSPEC void SDLCALL SDL_FreeAudioStream(SDL_AudioStream *stream); + +#define SDL_MIX_MAXVOLUME 128 +/** + * This takes two audio buffers of the playing audio format and mixes + * them, performing addition, volume adjustment, and overflow clipping. + * The volume ranges from 0 - 128, and should be set to ::SDL_MIX_MAXVOLUME + * for full audio volume. Note this does not change hardware volume. + * This is provided for convenience -- you can mix your own audio data. + */ +extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 * dst, const Uint8 * src, + Uint32 len, int volume); + +/** + * This works like SDL_MixAudio(), but you specify the audio format instead of + * using the format of audio device 1. Thus it can be used when no audio + * device is open at all. + */ +extern DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 * dst, + const Uint8 * src, + SDL_AudioFormat format, + Uint32 len, int volume); + +/** + * Queue more audio on non-callback devices. + * + * (If you are looking to retrieve queued audio from a non-callback capture + * device, you want SDL_DequeueAudio() instead. This will return -1 to + * signify an error if you use it with capture devices.) + * + * SDL offers two ways to feed audio to the device: you can either supply a + * callback that SDL triggers with some frequency to obtain more audio + * (pull method), or you can supply no callback, and then SDL will expect + * you to supply data at regular intervals (push method) with this function. + * + * There are no limits on the amount of data you can queue, short of + * exhaustion of address space. Queued data will drain to the device as + * necessary without further intervention from you. If the device needs + * audio but there is not enough queued, it will play silence to make up + * the difference. This means you will have skips in your audio playback + * if you aren't routinely queueing sufficient data. + * + * This function copies the supplied data, so you are safe to free it when + * the function returns. This function is thread-safe, but queueing to the + * same device from two threads at once does not promise which buffer will + * be queued first. + * + * You may not queue audio on a device that is using an application-supplied + * callback; doing so returns an error. You have to use the audio callback + * or queue audio with this function, but not both. + * + * You should not call SDL_LockAudio() on the device before queueing; SDL + * handles locking internally for this function. + * + * \param dev The device ID to which we will queue audio. + * \param data The data to queue to the device for later playback. + * \param len The number of bytes (not samples!) to which (data) points. + * \return 0 on success, or -1 on error. + * + * \sa SDL_GetQueuedAudioSize + * \sa SDL_ClearQueuedAudio + */ +extern DECLSPEC int SDLCALL SDL_QueueAudio(SDL_AudioDeviceID dev, const void *data, Uint32 len); + +/** + * Dequeue more audio on non-callback devices. + * + * (If you are looking to queue audio for output on a non-callback playback + * device, you want SDL_QueueAudio() instead. This will always return 0 + * if you use it with playback devices.) + * + * SDL offers two ways to retrieve audio from a capture device: you can + * either supply a callback that SDL triggers with some frequency as the + * device records more audio data, (push method), or you can supply no + * callback, and then SDL will expect you to retrieve data at regular + * intervals (pull method) with this function. + * + * There are no limits on the amount of data you can queue, short of + * exhaustion of address space. Data from the device will keep queuing as + * necessary without further intervention from you. This means you will + * eventually run out of memory if you aren't routinely dequeueing data. + * + * Capture devices will not queue data when paused; if you are expecting + * to not need captured audio for some length of time, use + * SDL_PauseAudioDevice() to stop the capture device from queueing more + * data. This can be useful during, say, level loading times. When + * unpaused, capture devices will start queueing data from that point, + * having flushed any capturable data available while paused. + * + * This function is thread-safe, but dequeueing from the same device from + * two threads at once does not promise which thread will dequeued data + * first. + * + * You may not dequeue audio from a device that is using an + * application-supplied callback; doing so returns an error. You have to use + * the audio callback, or dequeue audio with this function, but not both. + * + * You should not call SDL_LockAudio() on the device before queueing; SDL + * handles locking internally for this function. + * + * \param dev The device ID from which we will dequeue audio. + * \param data A pointer into where audio data should be copied. + * \param len The number of bytes (not samples!) to which (data) points. + * \return number of bytes dequeued, which could be less than requested. + * + * \sa SDL_GetQueuedAudioSize + * \sa SDL_ClearQueuedAudio + */ +extern DECLSPEC Uint32 SDLCALL SDL_DequeueAudio(SDL_AudioDeviceID dev, void *data, Uint32 len); + +/** + * Get the number of bytes of still-queued audio. + * + * For playback device: + * + * This is the number of bytes that have been queued for playback with + * SDL_QueueAudio(), but have not yet been sent to the hardware. This + * number may shrink at any time, so this only informs of pending data. + * + * Once we've sent it to the hardware, this function can not decide the + * exact byte boundary of what has been played. It's possible that we just + * gave the hardware several kilobytes right before you called this + * function, but it hasn't played any of it yet, or maybe half of it, etc. + * + * For capture devices: + * + * This is the number of bytes that have been captured by the device and + * are waiting for you to dequeue. This number may grow at any time, so + * this only informs of the lower-bound of available data. + * + * You may not queue audio on a device that is using an application-supplied + * callback; calling this function on such a device always returns 0. + * You have to queue audio with SDL_QueueAudio()/SDL_DequeueAudio(), or use + * the audio callback, but not both. + * + * You should not call SDL_LockAudio() on the device before querying; SDL + * handles locking internally for this function. + * + * \param dev The device ID of which we will query queued audio size. + * \return Number of bytes (not samples!) of queued audio. + * + * \sa SDL_QueueAudio + * \sa SDL_ClearQueuedAudio + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetQueuedAudioSize(SDL_AudioDeviceID dev); + +/** + * Drop any queued audio data. For playback devices, this is any queued data + * still waiting to be submitted to the hardware. For capture devices, this + * is any data that was queued by the device that hasn't yet been dequeued by + * the application. + * + * Immediately after this call, SDL_GetQueuedAudioSize() will return 0. For + * playback devices, the hardware will start playing silence if more audio + * isn't queued. Unpaused capture devices will start filling the queue again + * as soon as they have more data available (which, depending on the state + * of the hardware and the thread, could be before this function call + * returns!). + * + * This will not prevent playback of queued audio that's already been sent + * to the hardware, as we can not undo that, so expect there to be some + * fraction of a second of audio that might still be heard. This can be + * useful if you want to, say, drop any pending music during a level change + * in your game. + * + * You may not queue audio on a device that is using an application-supplied + * callback; calling this function on such a device is always a no-op. + * You have to queue audio with SDL_QueueAudio()/SDL_DequeueAudio(), or use + * the audio callback, but not both. + * + * You should not call SDL_LockAudio() on the device before clearing the + * queue; SDL handles locking internally for this function. + * + * This function always succeeds and thus returns void. + * + * \param dev The device ID of which to clear the audio queue. + * + * \sa SDL_QueueAudio + * \sa SDL_GetQueuedAudioSize + */ +extern DECLSPEC void SDLCALL SDL_ClearQueuedAudio(SDL_AudioDeviceID dev); + + +/** + * \name Audio lock functions + * + * The lock manipulated by these functions protects the callback function. + * During a SDL_LockAudio()/SDL_UnlockAudio() pair, you can be guaranteed that + * the callback function is not running. Do not call these from the callback + * function or you will cause deadlock. + */ +/* @{ */ +extern DECLSPEC void SDLCALL SDL_LockAudio(void); +extern DECLSPEC void SDLCALL SDL_LockAudioDevice(SDL_AudioDeviceID dev); +extern DECLSPEC void SDLCALL SDL_UnlockAudio(void); +extern DECLSPEC void SDLCALL SDL_UnlockAudioDevice(SDL_AudioDeviceID dev); +/* @} *//* Audio lock functions */ + +/** + * This function shuts down audio processing and closes the audio device. + */ +extern DECLSPEC void SDLCALL SDL_CloseAudio(void); +extern DECLSPEC void SDLCALL SDL_CloseAudioDevice(SDL_AudioDeviceID dev); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_audio_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_bits.h b/thirdparty/include/SDL2/SDL_bits.h new file mode 100644 index 000000000..db150ed08 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_bits.h @@ -0,0 +1,121 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_bits.h + * + * Functions for fiddling with bits and bitmasks. + */ + +#ifndef SDL_bits_h_ +#define SDL_bits_h_ + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \file SDL_bits.h + */ + +/** + * Get the index of the most significant bit. Result is undefined when called + * with 0. This operation can also be stated as "count leading zeroes" and + * "log base 2". + * + * \return Index of the most significant bit, or -1 if the value is 0. + */ +#if defined(__WATCOMC__) && defined(__386__) +extern _inline int _SDL_clz_watcom (Uint32); +#pragma aux _SDL_clz_watcom = \ + "bsr eax, eax" \ + "xor eax, 31" \ + parm [eax] nomemory \ + value [eax] \ + modify exact [eax] nomemory; +#endif + +SDL_FORCE_INLINE int +SDL_MostSignificantBitIndex32(Uint32 x) +{ +#if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) + /* Count Leading Zeroes builtin in GCC. + * http://gcc.gnu.org/onlinedocs/gcc-4.3.4/gcc/Other-Builtins.html + */ + if (x == 0) { + return -1; + } + return 31 - __builtin_clz(x); +#elif defined(__WATCOMC__) && defined(__386__) + if (x == 0) { + return -1; + } + return 31 - _SDL_clz_watcom(x); +#else + /* Based off of Bit Twiddling Hacks by Sean Eron Anderson + * , released in the public domain. + * http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog + */ + const Uint32 b[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000}; + const int S[] = {1, 2, 4, 8, 16}; + + int msbIndex = 0; + int i; + + if (x == 0) { + return -1; + } + + for (i = 4; i >= 0; i--) + { + if (x & b[i]) + { + x >>= S[i]; + msbIndex |= S[i]; + } + } + + return msbIndex; +#endif +} + +SDL_FORCE_INLINE SDL_bool +SDL_HasExactlyOneBitSet32(Uint32 x) +{ + if (x && !(x & (x - 1))) { + return SDL_TRUE; + } + return SDL_FALSE; +} + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_bits_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_blendmode.h b/thirdparty/include/SDL2/SDL_blendmode.h new file mode 100644 index 000000000..5e21a79e6 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_blendmode.h @@ -0,0 +1,123 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_blendmode.h + * + * Header file declaring the SDL_BlendMode enumeration + */ + +#ifndef SDL_blendmode_h_ +#define SDL_blendmode_h_ + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief The blend mode used in SDL_RenderCopy() and drawing operations. + */ +typedef enum +{ + SDL_BLENDMODE_NONE = 0x00000000, /**< no blending + dstRGBA = srcRGBA */ + SDL_BLENDMODE_BLEND = 0x00000001, /**< alpha blending + dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA)) + dstA = srcA + (dstA * (1-srcA)) */ + SDL_BLENDMODE_ADD = 0x00000002, /**< additive blending + dstRGB = (srcRGB * srcA) + dstRGB + dstA = dstA */ + SDL_BLENDMODE_MOD = 0x00000004, /**< color modulate + dstRGB = srcRGB * dstRGB + dstA = dstA */ + SDL_BLENDMODE_MUL = 0x00000008, /**< color multiply + dstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA)) + dstA = (srcA * dstA) + (dstA * (1-srcA)) */ + SDL_BLENDMODE_INVALID = 0x7FFFFFFF + + /* Additional custom blend modes can be returned by SDL_ComposeCustomBlendMode() */ + +} SDL_BlendMode; + +/** + * \brief The blend operation used when combining source and destination pixel components + */ +typedef enum +{ + SDL_BLENDOPERATION_ADD = 0x1, /**< dst + src: supported by all renderers */ + SDL_BLENDOPERATION_SUBTRACT = 0x2, /**< dst - src : supported by D3D9, D3D11, OpenGL, OpenGLES */ + SDL_BLENDOPERATION_REV_SUBTRACT = 0x3, /**< src - dst : supported by D3D9, D3D11, OpenGL, OpenGLES */ + SDL_BLENDOPERATION_MINIMUM = 0x4, /**< min(dst, src) : supported by D3D11 */ + SDL_BLENDOPERATION_MAXIMUM = 0x5 /**< max(dst, src) : supported by D3D11 */ + +} SDL_BlendOperation; + +/** + * \brief The normalized factor used to multiply pixel components + */ +typedef enum +{ + SDL_BLENDFACTOR_ZERO = 0x1, /**< 0, 0, 0, 0 */ + SDL_BLENDFACTOR_ONE = 0x2, /**< 1, 1, 1, 1 */ + SDL_BLENDFACTOR_SRC_COLOR = 0x3, /**< srcR, srcG, srcB, srcA */ + SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR = 0x4, /**< 1-srcR, 1-srcG, 1-srcB, 1-srcA */ + SDL_BLENDFACTOR_SRC_ALPHA = 0x5, /**< srcA, srcA, srcA, srcA */ + SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA = 0x6, /**< 1-srcA, 1-srcA, 1-srcA, 1-srcA */ + SDL_BLENDFACTOR_DST_COLOR = 0x7, /**< dstR, dstG, dstB, dstA */ + SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR = 0x8, /**< 1-dstR, 1-dstG, 1-dstB, 1-dstA */ + SDL_BLENDFACTOR_DST_ALPHA = 0x9, /**< dstA, dstA, dstA, dstA */ + SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA = 0xA /**< 1-dstA, 1-dstA, 1-dstA, 1-dstA */ + +} SDL_BlendFactor; + +/** + * \brief Create a custom blend mode, which may or may not be supported by a given renderer + * + * \param srcColorFactor source color factor + * \param dstColorFactor destination color factor + * \param colorOperation color operation + * \param srcAlphaFactor source alpha factor + * \param dstAlphaFactor destination alpha factor + * \param alphaOperation alpha operation + * + * The result of the blend mode operation will be: + * dstRGB = dstRGB * dstColorFactor colorOperation srcRGB * srcColorFactor + * and + * dstA = dstA * dstAlphaFactor alphaOperation srcA * srcAlphaFactor + */ +extern DECLSPEC SDL_BlendMode SDLCALL SDL_ComposeCustomBlendMode(SDL_BlendFactor srcColorFactor, + SDL_BlendFactor dstColorFactor, + SDL_BlendOperation colorOperation, + SDL_BlendFactor srcAlphaFactor, + SDL_BlendFactor dstAlphaFactor, + SDL_BlendOperation alphaOperation); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_blendmode_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_clipboard.h b/thirdparty/include/SDL2/SDL_clipboard.h new file mode 100644 index 000000000..dbf69fcea --- /dev/null +++ b/thirdparty/include/SDL2/SDL_clipboard.h @@ -0,0 +1,71 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_clipboard.h + * + * Include file for SDL clipboard handling + */ + +#ifndef SDL_clipboard_h_ +#define SDL_clipboard_h_ + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Function prototypes */ + +/** + * \brief Put UTF-8 text into the clipboard + * + * \sa SDL_GetClipboardText() + */ +extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text); + +/** + * \brief Get UTF-8 text from the clipboard, which must be freed with SDL_free() + * + * \sa SDL_SetClipboardText() + */ +extern DECLSPEC char * SDLCALL SDL_GetClipboardText(void); + +/** + * \brief Returns a flag indicating whether the clipboard exists and contains a text string that is non-empty + * + * \sa SDL_GetClipboardText() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_clipboard_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_config.h b/thirdparty/include/SDL2/SDL_config.h new file mode 100644 index 000000000..f269bfc04 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_config.h @@ -0,0 +1,260 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_config_windows_h_ +#define SDL_config_windows_h_ +#define SDL_config_h_ + +#include "SDL_platform.h" + +/* This is a set of defines to configure the SDL features */ + +#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) +#if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) +#define HAVE_STDINT_H 1 +#elif defined(_MSC_VER) +typedef signed __int8 int8_t; +typedef unsigned __int8 uint8_t; +typedef signed __int16 int16_t; +typedef unsigned __int16 uint16_t; +typedef signed __int32 int32_t; +typedef unsigned __int32 uint32_t; +typedef signed __int64 int64_t; +typedef unsigned __int64 uint64_t; +#ifndef _UINTPTR_T_DEFINED +#ifdef _WIN64 +typedef unsigned __int64 uintptr_t; +#else +typedef unsigned int uintptr_t; +#endif +#define _UINTPTR_T_DEFINED +#endif +/* Older Visual C++ headers don't have the Win64-compatible typedefs... */ +#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) +#define DWORD_PTR DWORD +#endif +#if ((_MSC_VER <= 1200) && (!defined(LONG_PTR))) +#define LONG_PTR LONG +#endif +#else /* !__GNUC__ && !_MSC_VER */ +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef signed long long int64_t; +typedef unsigned long long uint64_t; +#ifndef _SIZE_T_DEFINED_ +#define _SIZE_T_DEFINED_ +typedef unsigned int size_t; +#endif +typedef unsigned int uintptr_t; +#endif /* __GNUC__ || _MSC_VER */ +#endif /* !_STDINT_H_ && !HAVE_STDINT_H */ + +#ifdef _WIN64 +# define SIZEOF_VOIDP 8 +#else +# define SIZEOF_VOIDP 4 +#endif + +#define HAVE_DDRAW_H 1 +#define HAVE_DINPUT_H 1 +#define HAVE_DSOUND_H 1 +#define HAVE_DXGI_H 1 +#define HAVE_XINPUT_H 1 +#define HAVE_MMDEVICEAPI_H 1 +#define HAVE_AUDIOCLIENT_H 1 + +/* This is disabled by default to avoid C runtime dependencies and manifest requirements */ +#ifdef HAVE_LIBC +/* Useful headers */ +#define STDC_HEADERS 1 +#define HAVE_CTYPE_H 1 +#define HAVE_FLOAT_H 1 +#define HAVE_LIMITS_H 1 +#define HAVE_MATH_H 1 +#define HAVE_SIGNAL_H 1 +#define HAVE_STDIO_H 1 +#define HAVE_STRING_H 1 + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE__STRREV 1 +/* These functions have security warnings, so we won't use them */ +/* #undef HAVE__STRUPR */ +/* #undef HAVE__STRLWR */ +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +/* #undef HAVE_STRTOK_R */ +#if defined(_MSC_VER) +#define HAVE_STRTOK_S 1 +#endif +/* These functions have security warnings, so we won't use them */ +/* #undef HAVE__LTOA */ +/* #undef HAVE__ULTOA */ +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE__STRICMP 1 +#define HAVE__STRNICMP 1 +#define HAVE_ACOS 1 +#define HAVE_ACOSF 1 +#define HAVE_ASIN 1 +#define HAVE_ASINF 1 +#define HAVE_ATAN 1 +#define HAVE_ATANF 1 +#define HAVE_ATAN2 1 +#define HAVE_ATAN2F 1 +#define HAVE_CEILF 1 +#define HAVE__COPYSIGN 1 +#define HAVE_COS 1 +#define HAVE_COSF 1 +#define HAVE_EXP 1 +#define HAVE_EXPF 1 +#define HAVE_FABS 1 +#define HAVE_FABSF 1 +#define HAVE_FLOOR 1 +#define HAVE_FLOORF 1 +#define HAVE_FMOD 1 +#define HAVE_FMODF 1 +#define HAVE_LOG 1 +#define HAVE_LOGF 1 +#define HAVE_LOG10 1 +#define HAVE_LOG10F 1 +#define HAVE_POW 1 +#define HAVE_POWF 1 +#define HAVE_SIN 1 +#define HAVE_SINF 1 +#define HAVE_SQRT 1 +#define HAVE_SQRTF 1 +#define HAVE_TAN 1 +#define HAVE_TANF 1 +#if defined(_MSC_VER) +/* These functions were added with the VC++ 2013 C runtime library */ +#if _MSC_VER >= 1800 +#define HAVE_STRTOLL 1 +#define HAVE_VSSCANF 1 +#define HAVE_SCALBN 1 +#define HAVE_SCALBNF 1 +#endif +/* This function is available with at least the VC++ 2008 C runtime library */ +#if _MSC_VER >= 1400 +#define HAVE__FSEEKI64 1 +#endif +#endif +#if !defined(_MSC_VER) || defined(_USE_MATH_DEFINES) +#define HAVE_M_PI 1 +#endif +#else +#define HAVE_STDARG_H 1 +#define HAVE_STDDEF_H 1 +#endif + +/* Enable various audio drivers */ +#define SDL_AUDIO_DRIVER_WASAPI 1 +#define SDL_AUDIO_DRIVER_DSOUND 1 +#define SDL_AUDIO_DRIVER_WINMM 1 +#define SDL_AUDIO_DRIVER_DISK 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable various input drivers */ +#define SDL_JOYSTICK_DINPUT 1 +#define SDL_JOYSTICK_XINPUT 1 +#define SDL_JOYSTICK_HIDAPI 1 +#define SDL_HAPTIC_DINPUT 1 +#define SDL_HAPTIC_XINPUT 1 + +/* Enable the dummy sensor driver */ +#define SDL_SENSOR_DUMMY 1 + +/* Enable various shared object loading systems */ +#define SDL_LOADSO_WINDOWS 1 + +/* Enable various threading systems */ +#define SDL_THREAD_WINDOWS 1 + +/* Enable various timer systems */ +#define SDL_TIMER_WINDOWS 1 + +/* Enable various video drivers */ +#define SDL_VIDEO_DRIVER_DUMMY 1 +#define SDL_VIDEO_DRIVER_WINDOWS 1 + +#ifndef SDL_VIDEO_RENDER_D3D +#define SDL_VIDEO_RENDER_D3D 1 +#endif +#ifndef SDL_VIDEO_RENDER_D3D11 +#define SDL_VIDEO_RENDER_D3D11 0 +#endif + +/* Enable OpenGL support */ +#ifndef SDL_VIDEO_OPENGL +#define SDL_VIDEO_OPENGL 1 +#endif +#ifndef SDL_VIDEO_OPENGL_WGL +#define SDL_VIDEO_OPENGL_WGL 1 +#endif +#ifndef SDL_VIDEO_RENDER_OGL +#define SDL_VIDEO_RENDER_OGL 1 +#endif +#ifndef SDL_VIDEO_RENDER_OGL_ES2 +#define SDL_VIDEO_RENDER_OGL_ES2 1 +#endif +#ifndef SDL_VIDEO_OPENGL_ES2 +#define SDL_VIDEO_OPENGL_ES2 1 +#endif +#ifndef SDL_VIDEO_OPENGL_EGL +#define SDL_VIDEO_OPENGL_EGL 1 +#endif + +/* Enable Vulkan support */ +#define SDL_VIDEO_VULKAN 1 + +/* Enable system power support */ +#define SDL_POWER_WINDOWS 1 + +/* Enable filesystem support */ +#define SDL_FILESYSTEM_WINDOWS 1 + +/* Enable assembly routines (Win64 doesn't have inline asm) */ +#ifndef _WIN64 +#define SDL_ASSEMBLY_ROUTINES 1 +#endif + +#endif /* SDL_config_windows_h_ */ diff --git a/thirdparty/include/SDL2/SDL_config.h.cmake b/thirdparty/include/SDL2/SDL_config.h.cmake new file mode 100644 index 000000000..c57266c41 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_config.h.cmake @@ -0,0 +1,445 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_config_h_ +#define SDL_config_h_ + +/** + * \file SDL_config.h.in + * + * This is a set of defines to configure the SDL features + */ + +/* General platform specific identifiers */ +#include "SDL_platform.h" + +/* C language features */ +#cmakedefine const @HAVE_CONST@ +#cmakedefine inline @HAVE_INLINE@ +#cmakedefine volatile @HAVE_VOLATILE@ + +/* C datatypes */ +/* Define SIZEOF_VOIDP for 64/32 architectures */ +#ifdef __LP64__ +#define SIZEOF_VOIDP 8 +#else +#define SIZEOF_VOIDP 4 +#endif + +#cmakedefine HAVE_GCC_ATOMICS @HAVE_GCC_ATOMICS@ +#cmakedefine HAVE_GCC_SYNC_LOCK_TEST_AND_SET @HAVE_GCC_SYNC_LOCK_TEST_AND_SET@ + +#cmakedefine HAVE_D3D_H @HAVE_D3D_H@ +#cmakedefine HAVE_D3D11_H @HAVE_D3D11_H@ +#cmakedefine HAVE_DDRAW_H @HAVE_DDRAW_H@ +#cmakedefine HAVE_DSOUND_H @HAVE_DSOUND_H@ +#cmakedefine HAVE_DINPUT_H @HAVE_DINPUT_H@ +#cmakedefine HAVE_XAUDIO2_H @HAVE_XAUDIO2_H@ +#cmakedefine HAVE_XINPUT_H @HAVE_XINPUT_H@ +#cmakedefine HAVE_DXGI_H @HAVE_DXGI_H@ +#cmakedefine HAVE_XINPUT_GAMEPAD_EX @HAVE_XINPUT_GAMEPAD_EX@ +#cmakedefine HAVE_XINPUT_STATE_EX @HAVE_XINPUT_STATE_EX@ + +/* Comment this if you want to build without any C library requirements */ +#cmakedefine HAVE_LIBC 1 +#if HAVE_LIBC + +/* Useful headers */ +#cmakedefine HAVE_ALLOCA_H 1 +#cmakedefine HAVE_SYS_TYPES_H 1 +#cmakedefine HAVE_STDIO_H 1 +#cmakedefine STDC_HEADERS 1 +#cmakedefine HAVE_STDLIB_H 1 +#cmakedefine HAVE_STDARG_H 1 +#cmakedefine HAVE_MALLOC_H 1 +#cmakedefine HAVE_MEMORY_H 1 +#cmakedefine HAVE_STRING_H 1 +#cmakedefine HAVE_STRINGS_H 1 +#cmakedefine HAVE_WCHAR_H 1 +#cmakedefine HAVE_INTTYPES_H 1 +#cmakedefine HAVE_STDINT_H 1 +#cmakedefine HAVE_CTYPE_H 1 +#cmakedefine HAVE_MATH_H 1 +#cmakedefine HAVE_ICONV_H 1 +#cmakedefine HAVE_SIGNAL_H 1 +#cmakedefine HAVE_ALTIVEC_H 1 +#cmakedefine HAVE_PTHREAD_NP_H 1 +#cmakedefine HAVE_LIBUDEV_H 1 +#cmakedefine HAVE_DBUS_DBUS_H 1 +#cmakedefine HAVE_IBUS_IBUS_H 1 +#cmakedefine HAVE_FCITX_FRONTEND_H 1 +#cmakedefine HAVE_LIBSAMPLERATE_H 1 + +/* C library functions */ +#cmakedefine HAVE_MALLOC 1 +#cmakedefine HAVE_CALLOC 1 +#cmakedefine HAVE_REALLOC 1 +#cmakedefine HAVE_FREE 1 +#cmakedefine HAVE_ALLOCA 1 +#ifndef __WIN32__ /* Don't use C runtime versions of these on Windows */ +#cmakedefine HAVE_GETENV 1 +#cmakedefine HAVE_SETENV 1 +#cmakedefine HAVE_PUTENV 1 +#cmakedefine HAVE_UNSETENV 1 +#endif +#cmakedefine HAVE_QSORT 1 +#cmakedefine HAVE_ABS 1 +#cmakedefine HAVE_BCOPY 1 +#cmakedefine HAVE_MEMSET 1 +#cmakedefine HAVE_MEMCPY 1 +#cmakedefine HAVE_MEMMOVE 1 +#cmakedefine HAVE_MEMCMP 1 +#cmakedefine HAVE_WCSLEN 1 +#cmakedefine HAVE_WCSLCPY 1 +#cmakedefine HAVE_WCSLCAT 1 +#cmakedefine HAVE_WCSCMP 1 +#cmakedefine HAVE_STRLEN 1 +#cmakedefine HAVE_STRLCPY 1 +#cmakedefine HAVE_STRLCAT 1 +#cmakedefine HAVE_STRDUP 1 +#cmakedefine HAVE__STRREV 1 +#cmakedefine HAVE__STRUPR 1 +#cmakedefine HAVE__STRLWR 1 +#cmakedefine HAVE_INDEX 1 +#cmakedefine HAVE_RINDEX 1 +#cmakedefine HAVE_STRCHR 1 +#cmakedefine HAVE_STRRCHR 1 +#cmakedefine HAVE_STRSTR 1 +#cmakedefine HAVE_ITOA 1 +#cmakedefine HAVE__LTOA 1 +#cmakedefine HAVE__UITOA 1 +#cmakedefine HAVE__ULTOA 1 +#cmakedefine HAVE_STRTOL 1 +#cmakedefine HAVE_STRTOUL 1 +#cmakedefine HAVE__I64TOA 1 +#cmakedefine HAVE__UI64TOA 1 +#cmakedefine HAVE_STRTOLL 1 +#cmakedefine HAVE_STRTOULL 1 +#cmakedefine HAVE_STRTOD 1 +#cmakedefine HAVE_ATOI 1 +#cmakedefine HAVE_ATOF 1 +#cmakedefine HAVE_STRCMP 1 +#cmakedefine HAVE_STRNCMP 1 +#cmakedefine HAVE__STRICMP 1 +#cmakedefine HAVE_STRCASECMP 1 +#cmakedefine HAVE__STRNICMP 1 +#cmakedefine HAVE_STRNCASECMP 1 +#cmakedefine HAVE_VSSCANF 1 +#cmakedefine HAVE_VSNPRINTF 1 +#cmakedefine HAVE_M_PI 1 +#cmakedefine HAVE_ATAN 1 +#cmakedefine HAVE_ATAN2 1 +#cmakedefine HAVE_ACOS 1 +#cmakedefine HAVE_ASIN 1 +#cmakedefine HAVE_CEIL 1 +#cmakedefine HAVE_COPYSIGN 1 +#cmakedefine HAVE_COS 1 +#cmakedefine HAVE_COSF 1 +#cmakedefine HAVE_FABS 1 +#cmakedefine HAVE_FLOOR 1 +#cmakedefine HAVE_LOG 1 +#cmakedefine HAVE_POW 1 +#cmakedefine HAVE_SCALBN 1 +#cmakedefine HAVE_SIN 1 +#cmakedefine HAVE_SINF 1 +#cmakedefine HAVE_SQRT 1 +#cmakedefine HAVE_SQRTF 1 +#cmakedefine HAVE_TAN 1 +#cmakedefine HAVE_TANF 1 +#cmakedefine HAVE_FOPEN64 1 +#cmakedefine HAVE_FSEEKO 1 +#cmakedefine HAVE_FSEEKO64 1 +#cmakedefine HAVE_SIGACTION 1 +#cmakedefine HAVE_SA_SIGACTION 1 +#cmakedefine HAVE_SETJMP 1 +#cmakedefine HAVE_NANOSLEEP 1 +#cmakedefine HAVE_SYSCONF 1 +#cmakedefine HAVE_SYSCTLBYNAME 1 +#cmakedefine HAVE_CLOCK_GETTIME 1 +#cmakedefine HAVE_GETPAGESIZE 1 +#cmakedefine HAVE_MPROTECT 1 +#cmakedefine HAVE_ICONV 1 +#cmakedefine HAVE_PTHREAD_SETNAME_NP 1 +#cmakedefine HAVE_PTHREAD_SET_NAME_NP 1 +#cmakedefine HAVE_SEM_TIMEDWAIT 1 +#cmakedefine HAVE_GETAUXVAL 1 +#cmakedefine HAVE_POLL 1 + +#elif __WIN32__ +#cmakedefine HAVE_STDARG_H 1 +#cmakedefine HAVE_STDDEF_H 1 +#else +/* We may need some replacement for stdarg.h here */ +#include +#endif /* HAVE_LIBC */ + +/* SDL internal assertion support */ +#cmakedefine SDL_DEFAULT_ASSERT_LEVEL @SDL_DEFAULT_ASSERT_LEVEL@ + +/* Allow disabling of core subsystems */ +#cmakedefine SDL_ATOMIC_DISABLED @SDL_ATOMIC_DISABLED@ +#cmakedefine SDL_AUDIO_DISABLED @SDL_AUDIO_DISABLED@ +#cmakedefine SDL_CPUINFO_DISABLED @SDL_CPUINFO_DISABLED@ +#cmakedefine SDL_EVENTS_DISABLED @SDL_EVENTS_DISABLED@ +#cmakedefine SDL_FILE_DISABLED @SDL_FILE_DISABLED@ +#cmakedefine SDL_JOYSTICK_DISABLED @SDL_JOYSTICK_DISABLED@ +#cmakedefine SDL_HAPTIC_DISABLED @SDL_HAPTIC_DISABLED@ +#cmakedefine SDL_LOADSO_DISABLED @SDL_LOADSO_DISABLED@ +#cmakedefine SDL_RENDER_DISABLED @SDL_RENDER_DISABLED@ +#cmakedefine SDL_THREADS_DISABLED @SDL_THREADS_DISABLED@ +#cmakedefine SDL_TIMERS_DISABLED @SDL_TIMERS_DISABLED@ +#cmakedefine SDL_VIDEO_DISABLED @SDL_VIDEO_DISABLED@ +#cmakedefine SDL_POWER_DISABLED @SDL_POWER_DISABLED@ +#cmakedefine SDL_FILESYSTEM_DISABLED @SDL_FILESYSTEM_DISABLED@ + +/* Enable various audio drivers */ +#cmakedefine SDL_AUDIO_DRIVER_ALSA @SDL_AUDIO_DRIVER_ALSA@ +#cmakedefine SDL_AUDIO_DRIVER_ALSA_DYNAMIC @SDL_AUDIO_DRIVER_ALSA_DYNAMIC@ +#cmakedefine SDL_AUDIO_DRIVER_ANDROID @SDL_AUDIO_DRIVER_ANDROID@ +#cmakedefine SDL_AUDIO_DRIVER_ARTS @SDL_AUDIO_DRIVER_ARTS@ +#cmakedefine SDL_AUDIO_DRIVER_ARTS_DYNAMIC @SDL_AUDIO_DRIVER_ARTS_DYNAMIC@ +#cmakedefine SDL_AUDIO_DRIVER_COREAUDIO @SDL_AUDIO_DRIVER_COREAUDIO@ +#cmakedefine SDL_AUDIO_DRIVER_DISK @SDL_AUDIO_DRIVER_DISK@ +#cmakedefine SDL_AUDIO_DRIVER_DSOUND @SDL_AUDIO_DRIVER_DSOUND@ +#cmakedefine SDL_AUDIO_DRIVER_DUMMY @SDL_AUDIO_DRIVER_DUMMY@ +#cmakedefine SDL_AUDIO_DRIVER_EMSCRIPTEN @SDL_AUDIO_DRIVER_EMSCRIPTEN@ +#cmakedefine SDL_AUDIO_DRIVER_ESD @SDL_AUDIO_DRIVER_ESD@ +#cmakedefine SDL_AUDIO_DRIVER_ESD_DYNAMIC @SDL_AUDIO_DRIVER_ESD_DYNAMIC@ +#cmakedefine SDL_AUDIO_DRIVER_FUSIONSOUND @SDL_AUDIO_DRIVER_FUSIONSOUND@ +#cmakedefine SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC @SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC@ +#cmakedefine SDL_AUDIO_DRIVER_HAIKU @SDL_AUDIO_DRIVER_HAIKU@ +#cmakedefine SDL_AUDIO_DRIVER_JACK @SDL_AUDIO_DRIVER_JACK@ +#cmakedefine SDL_AUDIO_DRIVER_JACK_DYNAMIC @SDL_AUDIO_DRIVER_JACK_DYNAMIC@ +#cmakedefine SDL_AUDIO_DRIVER_NAS @SDL_AUDIO_DRIVER_NAS@ +#cmakedefine SDL_AUDIO_DRIVER_NAS_DYNAMIC @SDL_AUDIO_DRIVER_NAS_DYNAMIC@ +#cmakedefine SDL_AUDIO_DRIVER_NETBSD @SDL_AUDIO_DRIVER_NETBSD@ +#cmakedefine SDL_AUDIO_DRIVER_OSS @SDL_AUDIO_DRIVER_OSS@ +#cmakedefine SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H @SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H@ +#cmakedefine SDL_AUDIO_DRIVER_PAUDIO @SDL_AUDIO_DRIVER_PAUDIO@ +#cmakedefine SDL_AUDIO_DRIVER_PULSEAUDIO @SDL_AUDIO_DRIVER_PULSEAUDIO@ +#cmakedefine SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC @SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC@ +#cmakedefine SDL_AUDIO_DRIVER_QSA @SDL_AUDIO_DRIVER_QSA@ +#cmakedefine SDL_AUDIO_DRIVER_SNDIO @SDL_AUDIO_DRIVER_SNDIO@ +#cmakedefine SDL_AUDIO_DRIVER_SNDIO_DYNAMIC @SDL_AUDIO_DRIVER_SNDIO_DYNAMIC@ +#cmakedefine SDL_AUDIO_DRIVER_SUNAUDIO @SDL_AUDIO_DRIVER_SUNAUDIO@ +#cmakedefine SDL_AUDIO_DRIVER_WASAPI @SDL_AUDIO_DRIVER_WASAPI@ +#cmakedefine SDL_AUDIO_DRIVER_WINMM @SDL_AUDIO_DRIVER_WINMM@ +#cmakedefine SDL_AUDIO_DRIVER_XAUDIO2 @SDL_AUDIO_DRIVER_XAUDIO2@ + +/* Enable various input drivers */ +#cmakedefine SDL_INPUT_LINUXEV @SDL_INPUT_LINUXEV@ +#cmakedefine SDL_INPUT_LINUXKD @SDL_INPUT_LINUXKD@ +#cmakedefine SDL_INPUT_TSLIB @SDL_INPUT_TSLIB@ +#cmakedefine SDL_JOYSTICK_ANDROID @SDL_JOYSTICK_ANDROID@ +#cmakedefine SDL_JOYSTICK_HAIKU @SDL_JOYSTICK_HAIKU@ +#cmakedefine SDL_JOYSTICK_DINPUT @SDL_JOYSTICK_DINPUT@ +#cmakedefine SDL_JOYSTICK_XINPUT @SDL_JOYSTICK_XINPUT@ +#cmakedefine SDL_JOYSTICK_DUMMY @SDL_JOYSTICK_DUMMY@ +#cmakedefine SDL_JOYSTICK_IOKIT @SDL_JOYSTICK_IOKIT@ +#cmakedefine SDL_JOYSTICK_MFI @SDL_JOYSTICK_MFI@ +#cmakedefine SDL_JOYSTICK_LINUX @SDL_JOYSTICK_LINUX@ +#cmakedefine SDL_JOYSTICK_WINMM @SDL_JOYSTICK_WINMM@ +#cmakedefine SDL_JOYSTICK_USBHID @SDL_JOYSTICK_USBHID@ +#cmakedefine SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H @SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H@ +#cmakedefine SDL_JOYSTICK_EMSCRIPTEN @SDL_JOYSTICK_EMSCRIPTEN@ +#cmakedefine SDL_HAPTIC_DUMMY @SDL_HAPTIC_DUMMY@ +#cmakedefine SDL_HAPTIC_LINUX @SDL_HAPTIC_LINUX@ +#cmakedefine SDL_HAPTIC_IOKIT @SDL_HAPTIC_IOKIT@ +#cmakedefine SDL_HAPTIC_DINPUT @SDL_HAPTIC_DINPUT@ +#cmakedefine SDL_HAPTIC_XINPUT @SDL_HAPTIC_XINPUT@ +#cmakedefine SDL_HAPTIC_ANDROID @SDL_HAPTIC_ANDROID@ + +/* Enable various shared object loading systems */ +#cmakedefine SDL_LOADSO_DLOPEN @SDL_LOADSO_DLOPEN@ +#cmakedefine SDL_LOADSO_DUMMY @SDL_LOADSO_DUMMY@ +#cmakedefine SDL_LOADSO_LDG @SDL_LOADSO_LDG@ +#cmakedefine SDL_LOADSO_WINDOWS @SDL_LOADSO_WINDOWS@ + +/* Enable various threading systems */ +#cmakedefine SDL_THREAD_PTHREAD @SDL_THREAD_PTHREAD@ +#cmakedefine SDL_THREAD_PTHREAD_RECURSIVE_MUTEX @SDL_THREAD_PTHREAD_RECURSIVE_MUTEX@ +#cmakedefine SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP @SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP@ +#cmakedefine SDL_THREAD_WINDOWS @SDL_THREAD_WINDOWS@ + +/* Enable various timer systems */ +#cmakedefine SDL_TIMER_HAIKU @SDL_TIMER_HAIKU@ +#cmakedefine SDL_TIMER_DUMMY @SDL_TIMER_DUMMY@ +#cmakedefine SDL_TIMER_UNIX @SDL_TIMER_UNIX@ +#cmakedefine SDL_TIMER_WINDOWS @SDL_TIMER_WINDOWS@ +#cmakedefine SDL_TIMER_WINCE @SDL_TIMER_WINCE@ + +/* Enable various video drivers */ +#cmakedefine SDL_VIDEO_DRIVER_ANDROID @SDL_VIDEO_DRIVER_ANDROID@ +#cmakedefine SDL_VIDEO_DRIVER_HAIKU @SDL_VIDEO_DRIVER_HAIKU@ +#cmakedefine SDL_VIDEO_DRIVER_COCOA @SDL_VIDEO_DRIVER_COCOA@ +#cmakedefine SDL_VIDEO_DRIVER_DIRECTFB @SDL_VIDEO_DRIVER_DIRECTFB@ +#cmakedefine SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC @SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC@ +#cmakedefine SDL_VIDEO_DRIVER_DUMMY @SDL_VIDEO_DRIVER_DUMMY@ +#cmakedefine SDL_VIDEO_DRIVER_WINDOWS @SDL_VIDEO_DRIVER_WINDOWS@ +#cmakedefine SDL_VIDEO_DRIVER_WAYLAND @SDL_VIDEO_DRIVER_WAYLAND@ +#cmakedefine SDL_VIDEO_DRIVER_RPI @SDL_VIDEO_DRIVER_RPI@ +#cmakedefine SDL_VIDEO_DRIVER_VIVANTE @SDL_VIDEO_DRIVER_VIVANTE@ +#cmakedefine SDL_VIDEO_DRIVER_VIVANTE_VDK @SDL_VIDEO_DRIVER_VIVANTE_VDK@ + +#cmakedefine SDL_VIDEO_DRIVER_KMSDRM @SDL_VIDEO_DRIVER_KMSDRM@ +#cmakedefine SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC @SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC@ +#cmakedefine SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM @SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM@ + +#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH @SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH@ +#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC@ +#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL@ +#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR@ +#cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON@ + +#cmakedefine SDL_VIDEO_DRIVER_MIR @SDL_VIDEO_DRIVER_MIR@ +#cmakedefine SDL_VIDEO_DRIVER_MIR_DYNAMIC @SDL_VIDEO_DRIVER_MIR_DYNAMIC@ +#cmakedefine SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON @SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON@ +#cmakedefine SDL_VIDEO_DRIVER_EMSCRIPTEN @SDL_VIDEO_DRIVER_EMSCRIPTEN@ +#cmakedefine SDL_VIDEO_DRIVER_X11 @SDL_VIDEO_DRIVER_X11@ +#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC @SDL_VIDEO_DRIVER_X11_DYNAMIC@ +#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT @SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT@ +#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR @SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR@ +#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA @SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA@ +#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 @SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2@ +#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR @SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR@ +#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS @SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS@ +#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE @SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE@ +#cmakedefine SDL_VIDEO_DRIVER_X11_XCURSOR @SDL_VIDEO_DRIVER_X11_XCURSOR@ +#cmakedefine SDL_VIDEO_DRIVER_X11_XDBE @SDL_VIDEO_DRIVER_X11_XDBE@ +#cmakedefine SDL_VIDEO_DRIVER_X11_XINERAMA @SDL_VIDEO_DRIVER_X11_XINERAMA@ +#cmakedefine SDL_VIDEO_DRIVER_X11_XINPUT2 @SDL_VIDEO_DRIVER_X11_XINPUT2@ +#cmakedefine SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH @SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH@ +#cmakedefine SDL_VIDEO_DRIVER_X11_XRANDR @SDL_VIDEO_DRIVER_X11_XRANDR@ +#cmakedefine SDL_VIDEO_DRIVER_X11_XSCRNSAVER @SDL_VIDEO_DRIVER_X11_XSCRNSAVER@ +#cmakedefine SDL_VIDEO_DRIVER_X11_XSHAPE @SDL_VIDEO_DRIVER_X11_XSHAPE@ +#cmakedefine SDL_VIDEO_DRIVER_X11_XVIDMODE @SDL_VIDEO_DRIVER_X11_XVIDMODE@ +#cmakedefine SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS @SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS@ +#cmakedefine SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY @SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY@ +#cmakedefine SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM @SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM@ + +#cmakedefine SDL_VIDEO_RENDER_D3D @SDL_VIDEO_RENDER_D3D@ +#cmakedefine SDL_VIDEO_RENDER_D3D11 @SDL_VIDEO_RENDER_D3D11@ +#cmakedefine SDL_VIDEO_RENDER_OGL @SDL_VIDEO_RENDER_OGL@ +#cmakedefine SDL_VIDEO_RENDER_OGL_ES @SDL_VIDEO_RENDER_OGL_ES@ +#cmakedefine SDL_VIDEO_RENDER_OGL_ES2 @SDL_VIDEO_RENDER_OGL_ES2@ +#cmakedefine SDL_VIDEO_RENDER_DIRECTFB @SDL_VIDEO_RENDER_DIRECTFB@ + +/* Enable OpenGL support */ +#cmakedefine SDL_VIDEO_OPENGL @SDL_VIDEO_OPENGL@ +#cmakedefine SDL_VIDEO_OPENGL_ES @SDL_VIDEO_OPENGL_ES@ +#cmakedefine SDL_VIDEO_OPENGL_ES2 @SDL_VIDEO_OPENGL_ES2@ +#cmakedefine SDL_VIDEO_OPENGL_BGL @SDL_VIDEO_OPENGL_BGL@ +#cmakedefine SDL_VIDEO_OPENGL_CGL @SDL_VIDEO_OPENGL_CGL@ +#cmakedefine SDL_VIDEO_OPENGL_GLX @SDL_VIDEO_OPENGL_GLX@ +#cmakedefine SDL_VIDEO_OPENGL_WGL @SDL_VIDEO_OPENGL_WGL@ +#cmakedefine SDL_VIDEO_OPENGL_EGL @SDL_VIDEO_OPENGL_EGL@ +#cmakedefine SDL_VIDEO_OPENGL_OSMESA @SDL_VIDEO_OPENGL_OSMESA@ +#cmakedefine SDL_VIDEO_OPENGL_OSMESA_DYNAMIC @SDL_VIDEO_OPENGL_OSMESA_DYNAMIC@ + +/* Enable Vulkan support */ +#cmakedefine SDL_VIDEO_VULKAN @SDL_VIDEO_VULKAN@ + +/* Enable system power support */ +#cmakedefine SDL_POWER_ANDROID @SDL_POWER_ANDROID@ +#cmakedefine SDL_POWER_LINUX @SDL_POWER_LINUX@ +#cmakedefine SDL_POWER_WINDOWS @SDL_POWER_WINDOWS@ +#cmakedefine SDL_POWER_MACOSX @SDL_POWER_MACOSX@ +#cmakedefine SDL_POWER_HAIKU @SDL_POWER_HAIKU@ +#cmakedefine SDL_POWER_EMSCRIPTEN @SDL_POWER_EMSCRIPTEN@ +#cmakedefine SDL_POWER_HARDWIRED @SDL_POWER_HARDWIRED@ + +/* Enable system filesystem support */ +#cmakedefine SDL_FILESYSTEM_ANDROID @SDL_FILESYSTEM_ANDROID@ +#cmakedefine SDL_FILESYSTEM_HAIKU @SDL_FILESYSTEM_HAIKU@ +#cmakedefine SDL_FILESYSTEM_COCOA @SDL_FILESYSTEM_COCOA@ +#cmakedefine SDL_FILESYSTEM_DUMMY @SDL_FILESYSTEM_DUMMY@ +#cmakedefine SDL_FILESYSTEM_UNIX @SDL_FILESYSTEM_UNIX@ +#cmakedefine SDL_FILESYSTEM_WINDOWS @SDL_FILESYSTEM_WINDOWS@ +#cmakedefine SDL_FILESYSTEM_EMSCRIPTEN @SDL_FILESYSTEM_EMSCRIPTEN@ + +/* Enable assembly routines */ +#cmakedefine SDL_ASSEMBLY_ROUTINES @SDL_ASSEMBLY_ROUTINES@ +#cmakedefine SDL_ALTIVEC_BLITTERS @SDL_ALTIVEC_BLITTERS@ + +/* Enable dynamic libsamplerate support */ +#cmakedefine SDL_LIBSAMPLERATE_DYNAMIC @SDL_LIBSAMPLERATE_DYNAMIC@ + +/* Platform specific definitions */ +#if !defined(__WIN32__) +# if !defined(_STDINT_H_) && !defined(_STDINT_H) && !defined(HAVE_STDINT_H) && !defined(_HAVE_STDINT_H) +typedef unsigned int size_t; +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef signed long long int64_t; +typedef unsigned long long uint64_t; +typedef unsigned long uintptr_t; +# endif /* if (stdint.h isn't available) */ +#else /* __WIN32__ */ +# if !defined(_STDINT_H_) && !defined(HAVE_STDINT_H) && !defined(_HAVE_STDINT_H) +# if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) +#define HAVE_STDINT_H 1 +# elif defined(_MSC_VER) +typedef signed __int8 int8_t; +typedef unsigned __int8 uint8_t; +typedef signed __int16 int16_t; +typedef unsigned __int16 uint16_t; +typedef signed __int32 int32_t; +typedef unsigned __int32 uint32_t; +typedef signed __int64 int64_t; +typedef unsigned __int64 uint64_t; +# ifndef _UINTPTR_T_DEFINED +# ifdef _WIN64 +typedef unsigned __int64 uintptr_t; +# else +typedef unsigned int uintptr_t; +# endif +#define _UINTPTR_T_DEFINED +# endif +/* Older Visual C++ headers don't have the Win64-compatible typedefs... */ +# if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) +#define DWORD_PTR DWORD +# endif +# if ((_MSC_VER <= 1200) && (!defined(LONG_PTR))) +#define LONG_PTR LONG +# endif +# else /* !__GNUC__ && !_MSC_VER */ +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef signed long long int64_t; +typedef unsigned long long uint64_t; +# ifndef _SIZE_T_DEFINED_ +#define _SIZE_T_DEFINED_ +typedef unsigned int size_t; +# endif +typedef unsigned int uintptr_t; +# endif /* __GNUC__ || _MSC_VER */ +# endif /* !_STDINT_H_ && !HAVE_STDINT_H */ +#endif /* __WIN32__ */ + +#endif /* SDL_config_h_ */ diff --git a/thirdparty/include/SDL2/SDL_config.h.in b/thirdparty/include/SDL2/SDL_config.h.in new file mode 100644 index 000000000..8b3d20880 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_config.h.in @@ -0,0 +1,389 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_config_h_ +#define SDL_config_h_ + +/** + * \file SDL_config.h.in + * + * This is a set of defines to configure the SDL features + */ + +/* General platform specific identifiers */ +#include "SDL_platform.h" + +/* Make sure that this isn't included by Visual C++ */ +#ifdef _MSC_VER +#error You should run hg revert SDL_config.h +#endif + +/* C language features */ +#undef const +#undef inline +#undef volatile + +/* C datatypes */ +#ifdef __LP64__ +#define SIZEOF_VOIDP 8 +#else +#define SIZEOF_VOIDP 4 +#endif +#undef HAVE_GCC_ATOMICS +#undef HAVE_GCC_SYNC_LOCK_TEST_AND_SET + +#undef HAVE_DDRAW_H +#undef HAVE_DINPUT_H +#undef HAVE_DSOUND_H +#undef HAVE_DXGI_H +#undef HAVE_XINPUT_H +#undef HAVE_XINPUT_GAMEPAD_EX +#undef HAVE_XINPUT_STATE_EX + +/* Comment this if you want to build without any C library requirements */ +#undef HAVE_LIBC +#if HAVE_LIBC + +/* Useful headers */ +#undef HAVE_ALLOCA_H +#undef HAVE_SYS_TYPES_H +#undef HAVE_STDIO_H +#undef STDC_HEADERS +#undef HAVE_STDLIB_H +#undef HAVE_STDARG_H +#undef HAVE_MALLOC_H +#undef HAVE_MEMORY_H +#undef HAVE_STRING_H +#undef HAVE_STRINGS_H +#undef HAVE_WCHAR_H +#undef HAVE_INTTYPES_H +#undef HAVE_STDINT_H +#undef HAVE_CTYPE_H +#undef HAVE_MATH_H +#undef HAVE_ICONV_H +#undef HAVE_SIGNAL_H +#undef HAVE_ALTIVEC_H +#undef HAVE_PTHREAD_NP_H +#undef HAVE_LIBUDEV_H +#undef HAVE_DBUS_DBUS_H +#undef HAVE_IBUS_IBUS_H +#undef HAVE_FCITX_FRONTEND_H +#undef HAVE_LIBSAMPLERATE_H + +/* C library functions */ +#undef HAVE_MALLOC +#undef HAVE_CALLOC +#undef HAVE_REALLOC +#undef HAVE_FREE +#undef HAVE_ALLOCA +#ifndef __WIN32__ /* Don't use C runtime versions of these on Windows */ +#undef HAVE_GETENV +#undef HAVE_SETENV +#undef HAVE_PUTENV +#undef HAVE_UNSETENV +#endif +#undef HAVE_QSORT +#undef HAVE_ABS +#undef HAVE_BCOPY +#undef HAVE_MEMSET +#undef HAVE_MEMCPY +#undef HAVE_MEMMOVE +#undef HAVE_MEMCMP +#undef HAVE_WCSLEN +#undef HAVE_WCSLCPY +#undef HAVE_WCSLCAT +#undef HAVE_WCSCMP +#undef HAVE_STRLEN +#undef HAVE_STRLCPY +#undef HAVE_STRLCAT +#undef HAVE_STRDUP +#undef HAVE__STRREV +#undef HAVE__STRUPR +#undef HAVE__STRLWR +#undef HAVE_INDEX +#undef HAVE_RINDEX +#undef HAVE_STRCHR +#undef HAVE_STRRCHR +#undef HAVE_STRSTR +#undef HAVE_ITOA +#undef HAVE__LTOA +#undef HAVE__UITOA +#undef HAVE__ULTOA +#undef HAVE_STRTOL +#undef HAVE_STRTOUL +#undef HAVE__I64TOA +#undef HAVE__UI64TOA +#undef HAVE_STRTOLL +#undef HAVE_STRTOULL +#undef HAVE_STRTOD +#undef HAVE_ATOI +#undef HAVE_ATOF +#undef HAVE_STRCMP +#undef HAVE_STRNCMP +#undef HAVE__STRICMP +#undef HAVE_STRCASECMP +#undef HAVE__STRNICMP +#undef HAVE_STRNCASECMP +#undef HAVE_SSCANF +#undef HAVE_VSSCANF +#undef HAVE_SNPRINTF +#undef HAVE_VSNPRINTF +#undef HAVE_M_PI +#undef HAVE_ATAN +#undef HAVE_ATAN2 +#undef HAVE_ACOS +#undef HAVE_ASIN +#undef HAVE_CEIL +#undef HAVE_COPYSIGN +#undef HAVE_COS +#undef HAVE_COSF +#undef HAVE_FABS +#undef HAVE_FLOOR +#undef HAVE_LOG +#undef HAVE_POW +#undef HAVE_SCALBN +#undef HAVE_SIN +#undef HAVE_SINF +#undef HAVE_SQRT +#undef HAVE_SQRTF +#undef HAVE_TAN +#undef HAVE_TANF +#undef HAVE_FOPEN64 +#undef HAVE_FSEEKO +#undef HAVE_FSEEKO64 +#undef HAVE_SIGACTION +#undef HAVE_SA_SIGACTION +#undef HAVE_SETJMP +#undef HAVE_NANOSLEEP +#undef HAVE_SYSCONF +#undef HAVE_SYSCTLBYNAME +#undef HAVE_CLOCK_GETTIME +#undef HAVE_GETPAGESIZE +#undef HAVE_MPROTECT +#undef HAVE_ICONV +#undef HAVE_PTHREAD_SETNAME_NP +#undef HAVE_PTHREAD_SET_NAME_NP +#undef HAVE_SEM_TIMEDWAIT +#undef HAVE_GETAUXVAL +#undef HAVE_POLL + +#else +#define HAVE_STDARG_H 1 +#define HAVE_STDDEF_H 1 +#define HAVE_STDINT_H 1 +#endif /* HAVE_LIBC */ + +/* SDL internal assertion support */ +#undef SDL_DEFAULT_ASSERT_LEVEL + +/* Allow disabling of core subsystems */ +#undef SDL_ATOMIC_DISABLED +#undef SDL_AUDIO_DISABLED +#undef SDL_CPUINFO_DISABLED +#undef SDL_EVENTS_DISABLED +#undef SDL_FILE_DISABLED +#undef SDL_JOYSTICK_DISABLED +#undef SDL_HAPTIC_DISABLED +#undef SDL_LOADSO_DISABLED +#undef SDL_RENDER_DISABLED +#undef SDL_THREADS_DISABLED +#undef SDL_TIMERS_DISABLED +#undef SDL_VIDEO_DISABLED +#undef SDL_POWER_DISABLED +#undef SDL_FILESYSTEM_DISABLED + +/* Enable various audio drivers */ +#undef SDL_AUDIO_DRIVER_ALSA +#undef SDL_AUDIO_DRIVER_ALSA_DYNAMIC +#undef SDL_AUDIO_DRIVER_ANDROID +#undef SDL_AUDIO_DRIVER_ARTS +#undef SDL_AUDIO_DRIVER_ARTS_DYNAMIC +#undef SDL_AUDIO_DRIVER_COREAUDIO +#undef SDL_AUDIO_DRIVER_DISK +#undef SDL_AUDIO_DRIVER_DSOUND +#undef SDL_AUDIO_DRIVER_DUMMY +#undef SDL_AUDIO_DRIVER_EMSCRIPTEN +#undef SDL_AUDIO_DRIVER_ESD +#undef SDL_AUDIO_DRIVER_ESD_DYNAMIC +#undef SDL_AUDIO_DRIVER_FUSIONSOUND +#undef SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC +#undef SDL_AUDIO_DRIVER_HAIKU +#undef SDL_AUDIO_DRIVER_JACK +#undef SDL_AUDIO_DRIVER_JACK_DYNAMIC +#undef SDL_AUDIO_DRIVER_NACL +#undef SDL_AUDIO_DRIVER_NAS +#undef SDL_AUDIO_DRIVER_NAS_DYNAMIC +#undef SDL_AUDIO_DRIVER_NETBSD +#undef SDL_AUDIO_DRIVER_OSS +#undef SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H +#undef SDL_AUDIO_DRIVER_PAUDIO +#undef SDL_AUDIO_DRIVER_PULSEAUDIO +#undef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC +#undef SDL_AUDIO_DRIVER_QSA +#undef SDL_AUDIO_DRIVER_SNDIO +#undef SDL_AUDIO_DRIVER_SNDIO_DYNAMIC +#undef SDL_AUDIO_DRIVER_SUNAUDIO +#undef SDL_AUDIO_DRIVER_WASAPI +#undef SDL_AUDIO_DRIVER_WINMM +#undef SDL_AUDIO_DRIVER_XAUDIO2 + +/* Enable various input drivers */ +#undef SDL_INPUT_LINUXEV +#undef SDL_INPUT_LINUXKD +#undef SDL_INPUT_TSLIB +#undef SDL_JOYSTICK_HAIKU +#undef SDL_JOYSTICK_DINPUT +#undef SDL_JOYSTICK_XINPUT +#undef SDL_JOYSTICK_DUMMY +#undef SDL_JOYSTICK_IOKIT +#undef SDL_JOYSTICK_LINUX +#undef SDL_JOYSTICK_ANDROID +#undef SDL_JOYSTICK_WINMM +#undef SDL_JOYSTICK_USBHID +#undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H +#undef SDL_JOYSTICK_EMSCRIPTEN +#undef SDL_HAPTIC_DUMMY +#undef SDL_HAPTIC_LINUX +#undef SDL_HAPTIC_IOKIT +#undef SDL_HAPTIC_DINPUT +#undef SDL_HAPTIC_XINPUT + +/* Enable various shared object loading systems */ +#undef SDL_LOADSO_DLOPEN +#undef SDL_LOADSO_DUMMY +#undef SDL_LOADSO_LDG +#undef SDL_LOADSO_WINDOWS + +/* Enable various threading systems */ +#undef SDL_THREAD_PTHREAD +#undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX +#undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP +#undef SDL_THREAD_WINDOWS + +/* Enable various timer systems */ +#undef SDL_TIMER_HAIKU +#undef SDL_TIMER_DUMMY +#undef SDL_TIMER_UNIX +#undef SDL_TIMER_WINDOWS + +/* Enable various video drivers */ +#undef SDL_VIDEO_DRIVER_HAIKU +#undef SDL_VIDEO_DRIVER_COCOA +#undef SDL_VIDEO_DRIVER_DIRECTFB +#undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC +#undef SDL_VIDEO_DRIVER_DUMMY +#undef SDL_VIDEO_DRIVER_WINDOWS +#undef SDL_VIDEO_DRIVER_WAYLAND +#undef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH +#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC +#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL +#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR +#undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON +#undef SDL_VIDEO_DRIVER_MIR +#undef SDL_VIDEO_DRIVER_MIR_DYNAMIC +#undef SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON +#undef SDL_VIDEO_DRIVER_X11 +#undef SDL_VIDEO_DRIVER_RPI +#undef SDL_VIDEO_DRIVER_KMSDRM +#undef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC +#undef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM +#undef SDL_VIDEO_DRIVER_ANDROID +#undef SDL_VIDEO_DRIVER_EMSCRIPTEN +#undef SDL_VIDEO_DRIVER_X11_DYNAMIC +#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT +#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR +#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA +#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 +#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR +#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS +#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE +#undef SDL_VIDEO_DRIVER_X11_XCURSOR +#undef SDL_VIDEO_DRIVER_X11_XDBE +#undef SDL_VIDEO_DRIVER_X11_XINERAMA +#undef SDL_VIDEO_DRIVER_X11_XINPUT2 +#undef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH +#undef SDL_VIDEO_DRIVER_X11_XRANDR +#undef SDL_VIDEO_DRIVER_X11_XSCRNSAVER +#undef SDL_VIDEO_DRIVER_X11_XSHAPE +#undef SDL_VIDEO_DRIVER_X11_XVIDMODE +#undef SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS +#undef SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY +#undef SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM +#undef SDL_VIDEO_DRIVER_NACL +#undef SDL_VIDEO_DRIVER_VIVANTE +#undef SDL_VIDEO_DRIVER_VIVANTE_VDK +#undef SDL_VIDEO_DRIVER_QNX + +#undef SDL_VIDEO_RENDER_D3D +#undef SDL_VIDEO_RENDER_D3D11 +#undef SDL_VIDEO_RENDER_OGL +#undef SDL_VIDEO_RENDER_OGL_ES +#undef SDL_VIDEO_RENDER_OGL_ES2 +#undef SDL_VIDEO_RENDER_DIRECTFB + +/* Enable OpenGL support */ +#undef SDL_VIDEO_OPENGL +#undef SDL_VIDEO_OPENGL_ES +#undef SDL_VIDEO_OPENGL_ES2 +#undef SDL_VIDEO_OPENGL_BGL +#undef SDL_VIDEO_OPENGL_CGL +#undef SDL_VIDEO_OPENGL_EGL +#undef SDL_VIDEO_OPENGL_GLX +#undef SDL_VIDEO_OPENGL_WGL +#undef SDL_VIDEO_OPENGL_OSMESA +#undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC + +/* Enable Vulkan support */ +#undef SDL_VIDEO_VULKAN + +/* Enable system power support */ +#undef SDL_POWER_LINUX +#undef SDL_POWER_WINDOWS +#undef SDL_POWER_MACOSX +#undef SDL_POWER_HAIKU +#undef SDL_POWER_ANDROID +#undef SDL_POWER_EMSCRIPTEN +#undef SDL_POWER_HARDWIRED + +/* Enable system filesystem support */ +#undef SDL_FILESYSTEM_HAIKU +#undef SDL_FILESYSTEM_COCOA +#undef SDL_FILESYSTEM_DUMMY +#undef SDL_FILESYSTEM_UNIX +#undef SDL_FILESYSTEM_WINDOWS +#undef SDL_FILESYSTEM_NACL +#undef SDL_FILESYSTEM_ANDROID +#undef SDL_FILESYSTEM_EMSCRIPTEN + +/* Enable assembly routines */ +#undef SDL_ASSEMBLY_ROUTINES +#undef SDL_ALTIVEC_BLITTERS + +/* Enable ime support */ +#undef SDL_USE_IME + +/* Enable dynamic udev support */ +#undef SDL_UDEV_DYNAMIC + +/* Enable dynamic libsamplerate support */ +#undef SDL_LIBSAMPLERATE_DYNAMIC + +#endif /* SDL_config_h_ */ diff --git a/thirdparty/include/SDL2/SDL_config_android.h b/thirdparty/include/SDL2/SDL_config_android.h new file mode 100644 index 000000000..361bad8b7 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_config_android.h @@ -0,0 +1,157 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_config_android_h_ +#define SDL_config_android_h_ +#define SDL_config_h_ + +#include "SDL_platform.h" + +/** + * \file SDL_config_android.h + * + * This is a configuration that can be used to build SDL for Android + */ + +#include + +#define HAVE_GCC_ATOMICS 1 + +#define HAVE_ALLOCA_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_SIGNAL_H 1 + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_GETENV 1 +#define HAVE_SETENV 1 +#define HAVE_PUTENV 1 +#define HAVE_SETENV 1 +#define HAVE_UNSETENV 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE_STRLCPY 1 +#define HAVE_STRLCAT 1 +#define HAVE_STRDUP 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOULL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE_STRCASECMP 1 +#define HAVE_STRNCASECMP 1 +#define HAVE_VSSCANF 1 +#define HAVE_VSNPRINTF 1 +#define HAVE_M_PI 1 +#define HAVE_ATAN 1 +#define HAVE_ATAN2 1 +#define HAVE_ACOS 1 +#define HAVE_ASIN 1 +#define HAVE_CEIL 1 +#define HAVE_COPYSIGN 1 +#define HAVE_COS 1 +#define HAVE_COSF 1 +#define HAVE_FABS 1 +#define HAVE_FLOOR 1 +#define HAVE_LOG 1 +#define HAVE_POW 1 +#define HAVE_SCALBN 1 +#define HAVE_SIN 1 +#define HAVE_SINF 1 +#define HAVE_SQRT 1 +#define HAVE_SQRTF 1 +#define HAVE_TAN 1 +#define HAVE_TANF 1 +#define HAVE_SIGACTION 1 +#define HAVE_SETJMP 1 +#define HAVE_NANOSLEEP 1 +#define HAVE_SYSCONF 1 +#define HAVE_CLOCK_GETTIME 1 + +#define SIZEOF_VOIDP 4 + +/* Enable various audio drivers */ +#define SDL_AUDIO_DRIVER_ANDROID 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable various input drivers */ +#define SDL_JOYSTICK_ANDROID 1 +#define SDL_HAPTIC_ANDROID 1 + +/* Enable various shared object loading systems */ +#define SDL_LOADSO_DLOPEN 1 + +/* Enable various threading systems */ +#define SDL_THREAD_PTHREAD 1 +#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 + +/* Enable various timer systems */ +#define SDL_TIMER_UNIX 1 + +/* Enable various video drivers */ +#define SDL_VIDEO_DRIVER_ANDROID 1 + +/* Enable OpenGL ES */ +#define SDL_VIDEO_OPENGL_ES 1 +#define SDL_VIDEO_OPENGL_ES2 1 +#define SDL_VIDEO_OPENGL_EGL 1 +#define SDL_VIDEO_RENDER_OGL_ES 1 +#define SDL_VIDEO_RENDER_OGL_ES2 1 + +/* Enable Vulkan support */ +/* Android does not support Vulkan in native code using the "armeabi" ABI. */ +#if defined(__ARM_ARCH) && __ARM_ARCH < 7 +#define SDL_VIDEO_VULKAN 0 +#else +#define SDL_VIDEO_VULKAN 1 +#endif + +/* Enable system power support */ +#define SDL_POWER_ANDROID 1 + +/* Enable the filesystem driver */ +#define SDL_FILESYSTEM_ANDROID 1 + +#endif /* SDL_config_android_h_ */ diff --git a/thirdparty/include/SDL2/SDL_config_iphoneos.h b/thirdparty/include/SDL2/SDL_config_iphoneos.h new file mode 100644 index 000000000..deea03046 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_config_iphoneos.h @@ -0,0 +1,166 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_config_iphoneos_h_ +#define SDL_config_iphoneos_h_ +#define SDL_config_h_ + +#include "SDL_platform.h" + +#ifdef __LP64__ +#define SIZEOF_VOIDP 8 +#else +#define SIZEOF_VOIDP 4 +#endif + +#define HAVE_GCC_ATOMICS 1 + +#define HAVE_ALLOCA_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_SIGNAL_H 1 + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_GETENV 1 +#define HAVE_SETENV 1 +#define HAVE_PUTENV 1 +#define HAVE_SETENV 1 +#define HAVE_UNSETENV 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE_STRLCPY 1 +#define HAVE_STRLCAT 1 +#define HAVE_STRDUP 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOULL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE_STRCASECMP 1 +#define HAVE_STRNCASECMP 1 +#define HAVE_VSSCANF 1 +#define HAVE_VSNPRINTF 1 +#define HAVE_M_PI 1 +#define HAVE_ATAN 1 +#define HAVE_ATAN2 1 +#define HAVE_ACOS 1 +#define HAVE_ASIN 1 +#define HAVE_CEIL 1 +#define HAVE_COPYSIGN 1 +#define HAVE_COS 1 +#define HAVE_COSF 1 +#define HAVE_FABS 1 +#define HAVE_FLOOR 1 +#define HAVE_LOG 1 +#define HAVE_POW 1 +#define HAVE_SCALBN 1 +#define HAVE_SIN 1 +#define HAVE_SINF 1 +#define HAVE_SQRT 1 +#define HAVE_SQRTF 1 +#define HAVE_TAN 1 +#define HAVE_TANF 1 +#define HAVE_SIGACTION 1 +#define HAVE_SETJMP 1 +#define HAVE_NANOSLEEP 1 +#define HAVE_SYSCONF 1 +#define HAVE_SYSCTLBYNAME 1 + +/* enable iPhone version of Core Audio driver */ +#define SDL_AUDIO_DRIVER_COREAUDIO 1 +/* Enable the dummy audio driver (src/audio/dummy/\*.c) */ +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable the stub haptic driver (src/haptic/dummy/\*.c) */ +#define SDL_HAPTIC_DUMMY 1 + +/* Enable MFi joystick support */ +#define SDL_JOYSTICK_MFI 1 + +/* Enable Unix style SO loading */ +#define SDL_LOADSO_DLOPEN 1 + +/* Enable various threading systems */ +#define SDL_THREAD_PTHREAD 1 +#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 + +/* Enable various timer systems */ +#define SDL_TIMER_UNIX 1 + +/* Supported video drivers */ +#define SDL_VIDEO_DRIVER_UIKIT 1 +#define SDL_VIDEO_DRIVER_DUMMY 1 + +/* enable OpenGL ES */ +#define SDL_VIDEO_OPENGL_ES2 1 +#define SDL_VIDEO_OPENGL_ES 1 +#define SDL_VIDEO_RENDER_OGL_ES 1 +#define SDL_VIDEO_RENDER_OGL_ES2 1 + +/* Enable Vulkan support */ +#if !TARGET_OS_SIMULATOR && !TARGET_CPU_ARM // Only 64-bit devices have Metal +#define SDL_VIDEO_VULKAN 1 +#else +#define SDL_VIDEO_VULKAN 0 +#endif + +/* Enable system power support */ +#define SDL_POWER_UIKIT 1 + +/* enable iPhone keyboard support */ +#define SDL_IPHONE_KEYBOARD 1 + +/* enable iOS extended launch screen */ +#define SDL_IPHONE_LAUNCHSCREEN 1 + +/* Set max recognized G-force from accelerometer + See src/joystick/uikit/SDL_sysjoystick.m for notes on why this is needed + */ +#define SDL_IPHONE_MAX_GFORCE 5.0 + +/* enable filesystem support */ +#define SDL_FILESYSTEM_COCOA 1 + +#endif /* SDL_config_iphoneos_h_ */ diff --git a/thirdparty/include/SDL2/SDL_config_macosx.h b/thirdparty/include/SDL2/SDL_config_macosx.h new file mode 100644 index 000000000..9b0989952 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_config_macosx.h @@ -0,0 +1,197 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_config_macosx_h_ +#define SDL_config_macosx_h_ +#define SDL_config_h_ + +#include "SDL_platform.h" + +/* This gets us MAC_OS_X_VERSION_MIN_REQUIRED... */ +#include + +/* This is a set of defines to configure the SDL features */ + +#ifdef __LP64__ + #define SIZEOF_VOIDP 8 +#else + #define SIZEOF_VOIDP 4 +#endif + +/* Useful headers */ +#define HAVE_ALLOCA_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_SIGNAL_H 1 + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_GETENV 1 +#define HAVE_SETENV 1 +#define HAVE_PUTENV 1 +#define HAVE_UNSETENV 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE_STRLCPY 1 +#define HAVE_STRLCAT 1 +#define HAVE_STRDUP 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOULL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE_STRCASECMP 1 +#define HAVE_STRNCASECMP 1 +#define HAVE_VSSCANF 1 +#define HAVE_VSNPRINTF 1 +#define HAVE_CEIL 1 +#define HAVE_COPYSIGN 1 +#define HAVE_COS 1 +#define HAVE_COSF 1 +#define HAVE_FABS 1 +#define HAVE_FLOOR 1 +#define HAVE_LOG 1 +#define HAVE_POW 1 +#define HAVE_SCALBN 1 +#define HAVE_SIN 1 +#define HAVE_SINF 1 +#define HAVE_SQRT 1 +#define HAVE_SQRTF 1 +#define HAVE_TAN 1 +#define HAVE_TANF 1 +#define HAVE_SIGACTION 1 +#define HAVE_SETJMP 1 +#define HAVE_NANOSLEEP 1 +#define HAVE_SYSCONF 1 +#define HAVE_SYSCTLBYNAME 1 +#define HAVE_ATAN 1 +#define HAVE_ATAN2 1 +#define HAVE_ACOS 1 +#define HAVE_ASIN 1 + +/* Enable various audio drivers */ +#define SDL_AUDIO_DRIVER_COREAUDIO 1 +#define SDL_AUDIO_DRIVER_DISK 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable various input drivers */ +#define SDL_JOYSTICK_IOKIT 1 +#define SDL_HAPTIC_IOKIT 1 + +/* Enable various shared object loading systems */ +#define SDL_LOADSO_DLOPEN 1 + +/* Enable various threading systems */ +#define SDL_THREAD_PTHREAD 1 +#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 + +/* Enable various timer systems */ +#define SDL_TIMER_UNIX 1 + +/* Enable various video drivers */ +#define SDL_VIDEO_DRIVER_COCOA 1 +#define SDL_VIDEO_DRIVER_DUMMY 1 +#undef SDL_VIDEO_DRIVER_X11 +#define SDL_VIDEO_DRIVER_X11_DYNAMIC "/usr/X11R6/lib/libX11.6.dylib" +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "/usr/X11R6/lib/libXext.6.dylib" +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "/usr/X11R6/lib/libXinerama.1.dylib" +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "/usr/X11R6/lib/libXi.6.dylib" +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "/usr/X11R6/lib/libXrandr.2.dylib" +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "/usr/X11R6/lib/libXss.1.dylib" +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "/usr/X11R6/lib/libXxf86vm.1.dylib" +#define SDL_VIDEO_DRIVER_X11_XDBE 1 +#define SDL_VIDEO_DRIVER_X11_XINERAMA 1 +#define SDL_VIDEO_DRIVER_X11_XRANDR 1 +#define SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1 +#define SDL_VIDEO_DRIVER_X11_XSHAPE 1 +#define SDL_VIDEO_DRIVER_X11_XVIDMODE 1 +#define SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM 1 + +#ifdef MAC_OS_X_VERSION_10_8 +/* + * No matter the versions targeted, this is the 10.8 or later SDK, so you have + * to use the external Xquartz, which is a more modern Xlib. Previous SDKs + * used an older Xlib. + */ +#define SDL_VIDEO_DRIVER_X11_XINPUT2 1 +#define SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1 +#define SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY 1 +#endif + +#ifndef SDL_VIDEO_RENDER_OGL +#define SDL_VIDEO_RENDER_OGL 1 +#endif + +/* Enable OpenGL support */ +#ifndef SDL_VIDEO_OPENGL +#define SDL_VIDEO_OPENGL 1 +#endif +#ifndef SDL_VIDEO_OPENGL_CGL +#define SDL_VIDEO_OPENGL_CGL 1 +#endif +#ifndef SDL_VIDEO_OPENGL_GLX +#define SDL_VIDEO_OPENGL_GLX 1 +#endif + +/* Enable Vulkan support */ +/* Metal/MoltenVK/Vulkan only supported on 64-bit architectures with 10.11+ */ +#if TARGET_CPU_X86_64 && (MAC_OS_X_VERSION_MAX_ALLOWED >= 101100) +#define SDL_VIDEO_VULKAN 1 +#else +#define SDL_VIDEO_VULKAN 0 +#endif + +/* Enable system power support */ +#define SDL_POWER_MACOSX 1 + +/* enable filesystem support */ +#define SDL_FILESYSTEM_COCOA 1 + +/* Enable assembly routines */ +#define SDL_ASSEMBLY_ROUTINES 1 +#ifdef __ppc__ +#define SDL_ALTIVEC_BLITTERS 1 +#endif + +#endif /* SDL_config_macosx_h_ */ diff --git a/thirdparty/include/SDL2/SDL_config_macosx.h.orig b/thirdparty/include/SDL2/SDL_config_macosx.h.orig new file mode 100644 index 000000000..f03f1ae3d --- /dev/null +++ b/thirdparty/include/SDL2/SDL_config_macosx.h.orig @@ -0,0 +1,197 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_config_macosx_h_ +#define SDL_config_macosx_h_ +#define SDL_config_h_ + +#include "SDL_platform.h" + +/* This gets us MAC_OS_X_VERSION_MIN_REQUIRED... */ +#include + +/* This is a set of defines to configure the SDL features */ + +#ifdef __LP64__ + #define SIZEOF_VOIDP 8 +#else + #define SIZEOF_VOIDP 4 +#endif + +/* Useful headers */ +#define HAVE_ALLOCA_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_SIGNAL_H 1 + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_GETENV 1 +#define HAVE_SETENV 1 +#define HAVE_PUTENV 1 +#define HAVE_UNSETENV 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE_STRLCPY 1 +#define HAVE_STRLCAT 1 +#define HAVE_STRDUP 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOULL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE_STRCASECMP 1 +#define HAVE_STRNCASECMP 1 +#define HAVE_VSSCANF 1 +#define HAVE_VSNPRINTF 1 +#define HAVE_CEIL 1 +#define HAVE_COPYSIGN 1 +#define HAVE_COS 1 +#define HAVE_COSF 1 +#define HAVE_FABS 1 +#define HAVE_FLOOR 1 +#define HAVE_LOG 1 +#define HAVE_POW 1 +#define HAVE_SCALBN 1 +#define HAVE_SIN 1 +#define HAVE_SINF 1 +#define HAVE_SQRT 1 +#define HAVE_SQRTF 1 +#define HAVE_TAN 1 +#define HAVE_TANF 1 +#define HAVE_SIGACTION 1 +#define HAVE_SETJMP 1 +#define HAVE_NANOSLEEP 1 +#define HAVE_SYSCONF 1 +#define HAVE_SYSCTLBYNAME 1 +#define HAVE_ATAN 1 +#define HAVE_ATAN2 1 +#define HAVE_ACOS 1 +#define HAVE_ASIN 1 + +/* Enable various audio drivers */ +#define SDL_AUDIO_DRIVER_COREAUDIO 1 +#define SDL_AUDIO_DRIVER_DISK 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable various input drivers */ +#define SDL_JOYSTICK_IOKIT 1 +#define SDL_HAPTIC_IOKIT 1 + +/* Enable various shared object loading systems */ +#define SDL_LOADSO_DLOPEN 1 + +/* Enable various threading systems */ +#define SDL_THREAD_PTHREAD 1 +#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 + +/* Enable various timer systems */ +#define SDL_TIMER_UNIX 1 + +/* Enable various video drivers */ +#define SDL_VIDEO_DRIVER_COCOA 1 +#define SDL_VIDEO_DRIVER_DUMMY 1 +#undef SDL_VIDEO_DRIVER_X11 +#define SDL_VIDEO_DRIVER_X11_DYNAMIC "/usr/X11R6/lib/libX11.6.dylib" +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "/usr/X11R6/lib/libXext.6.dylib" +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "/usr/X11R6/lib/libXinerama.1.dylib" +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "/usr/X11R6/lib/libXi.6.dylib" +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "/usr/X11R6/lib/libXrandr.2.dylib" +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "/usr/X11R6/lib/libXss.1.dylib" +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "/usr/X11R6/lib/libXxf86vm.1.dylib" +#define SDL_VIDEO_DRIVER_X11_XDBE 1 +#define SDL_VIDEO_DRIVER_X11_XINERAMA 1 +#define SDL_VIDEO_DRIVER_X11_XRANDR 1 +#define SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1 +#define SDL_VIDEO_DRIVER_X11_XSHAPE 1 +#define SDL_VIDEO_DRIVER_X11_XVIDMODE 1 +#define SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM 1 + +#ifdef MAC_OS_X_VERSION_10_8 +/* + * No matter the versions targeted, this is the 10.8 or later SDK, so you have + * to use the external Xquartz, which is a more modern Xlib. Previous SDKs + * used an older Xlib. + */ +#define SDL_VIDEO_DRIVER_X11_XINPUT2 1 +#define SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS 1 +#define SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY 1 +#endif + +#ifndef SDL_VIDEO_RENDER_OGL +#define SDL_VIDEO_RENDER_OGL 1 +#endif + +/* Enable OpenGL support */ +#ifndef SDL_VIDEO_OPENGL +#define SDL_VIDEO_OPENGL 1 +#endif +#ifndef SDL_VIDEO_OPENGL_CGL +#define SDL_VIDEO_OPENGL_CGL 1 +#endif +#ifndef SDL_VIDEO_OPENGL_GLX +#define SDL_VIDEO_OPENGL_GLX 1 +#endif + +/* Enable Vulkan support */ +/* Metal/MoltenVK/Vulkan only supported on 64-bit architectures and 10.11+ */ +#if TARGET_CPU_X86_64 +#define SDL_VIDEO_VULKAN 1 +#else +#define SDL_VIDEO_VULKAN 0 +#endif + +/* Enable system power support */ +#define SDL_POWER_MACOSX 1 + +/* enable filesystem support */ +#define SDL_FILESYSTEM_COCOA 1 + +/* Enable assembly routines */ +#define SDL_ASSEMBLY_ROUTINES 1 +#ifdef __ppc__ +#define SDL_ALTIVEC_BLITTERS 1 +#endif + +#endif /* SDL_config_macosx_h_ */ diff --git a/thirdparty/include/SDL2/SDL_config_minimal.h b/thirdparty/include/SDL2/SDL_config_minimal.h new file mode 100644 index 000000000..31127006c --- /dev/null +++ b/thirdparty/include/SDL2/SDL_config_minimal.h @@ -0,0 +1,82 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_config_minimal_h_ +#define SDL_config_minimal_h_ +#define SDL_config_h_ + +#include "SDL_platform.h" + +/** + * \file SDL_config_minimal.h + * + * This is the minimal configuration that can be used to build SDL. + */ + +#define HAVE_STDARG_H 1 +#define HAVE_STDDEF_H 1 + +/* Most everything except Visual Studio 2008 and earlier has stdint.h now */ +#if defined(_MSC_VER) && (_MSC_VER < 1600) +/* Here are some reasonable defaults */ +typedef unsigned int size_t; +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef signed long long int64_t; +typedef unsigned long long uint64_t; +typedef unsigned long uintptr_t; +#else +#define HAVE_STDINT_H 1 +#endif /* Visual Studio 2008 */ + +#ifdef __GNUC__ +#define HAVE_GCC_SYNC_LOCK_TEST_AND_SET 1 +#endif + +/* Enable the dummy audio driver (src/audio/dummy/\*.c) */ +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable the stub joystick driver (src/joystick/dummy/\*.c) */ +#define SDL_JOYSTICK_DISABLED 1 + +/* Enable the stub haptic driver (src/haptic/dummy/\*.c) */ +#define SDL_HAPTIC_DISABLED 1 + +/* Enable the stub shared object loader (src/loadso/dummy/\*.c) */ +#define SDL_LOADSO_DISABLED 1 + +/* Enable the stub thread support (src/thread/generic/\*.c) */ +#define SDL_THREADS_DISABLED 1 + +/* Enable the stub timer support (src/timer/dummy/\*.c) */ +#define SDL_TIMERS_DISABLED 1 + +/* Enable the dummy video driver (src/video/dummy/\*.c) */ +#define SDL_VIDEO_DRIVER_DUMMY 1 + +/* Enable the dummy filesystem driver (src/filesystem/dummy/\*.c) */ +#define SDL_FILESYSTEM_DUMMY 1 + +#endif /* SDL_config_minimal_h_ */ diff --git a/thirdparty/include/SDL2/SDL_config_pandora.h b/thirdparty/include/SDL2/SDL_config_pandora.h new file mode 100644 index 000000000..ea62fe59a --- /dev/null +++ b/thirdparty/include/SDL2/SDL_config_pandora.h @@ -0,0 +1,128 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_config_pandora_h_ +#define SDL_config_pandora_h_ +#define SDL_config_h_ + +/* This is a set of defines to configure the SDL features */ + +/* General platform specific identifiers */ +#include "SDL_platform.h" + +#ifdef __LP64__ +#define SIZEOF_VOIDP 8 +#else +#define SIZEOF_VOIDP 4 +#endif + +#define SDL_BYTEORDER 1234 + +#define HAVE_ALLOCA_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STDARG_H 1 +#define HAVE_MALLOC_H 1 +#define HAVE_MEMORY_H 1 +#define HAVE_STRING_H 1 +#define HAVE_STRINGS_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_ICONV_H 1 +#define HAVE_SIGNAL_H 1 +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_GETENV 1 +#define HAVE_SETENV 1 +#define HAVE_PUTENV 1 +#define HAVE_UNSETENV 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_STRLEN 1 +#define HAVE_STRDUP 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOULL 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE_STRCASECMP 1 +#define HAVE_STRNCASECMP 1 +#define HAVE_VSSCANF 1 +#define HAVE_VSNPRINTF 1 +#define HAVE_M_PI 1 +#define HAVE_CEIL 1 +#define HAVE_COPYSIGN 1 +#define HAVE_COS 1 +#define HAVE_COSF 1 +#define HAVE_FABS 1 +#define HAVE_FLOOR 1 +#define HAVE_LOG 1 +#define HAVE_SCALBN 1 +#define HAVE_SIN 1 +#define HAVE_SINF 1 +#define HAVE_SQRT 1 +#define HAVE_SQRTF 1 +#define HAVE_TAN 1 +#define HAVE_TANF 1 +#define HAVE_SIGACTION 1 +#define HAVE_SETJMP 1 +#define HAVE_NANOSLEEP 1 + +#define SDL_AUDIO_DRIVER_DUMMY 1 +#define SDL_AUDIO_DRIVER_OSS 1 + +#define SDL_INPUT_LINUXEV 1 +#define SDL_INPUT_TSLIB 1 +#define SDL_JOYSTICK_LINUX 1 +#define SDL_HAPTIC_LINUX 1 + +#define SDL_LOADSO_DLOPEN 1 + +#define SDL_THREAD_PTHREAD 1 +#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1 + +#define SDL_TIMER_UNIX 1 +#define SDL_FILESYSTEM_UNIX 1 + +#define SDL_VIDEO_DRIVER_DUMMY 1 +#define SDL_VIDEO_DRIVER_X11 1 +#define SDL_VIDEO_DRIVER_PANDORA 1 +#define SDL_VIDEO_RENDER_OGL_ES 1 +#define SDL_VIDEO_OPENGL_ES 1 + +#endif /* SDL_config_pandora_h_ */ diff --git a/thirdparty/include/SDL2/SDL_config_psp.h b/thirdparty/include/SDL2/SDL_config_psp.h new file mode 100644 index 000000000..28efb4c5c --- /dev/null +++ b/thirdparty/include/SDL2/SDL_config_psp.h @@ -0,0 +1,144 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_config_psp_h_ +#define SDL_config_psp_h_ +#define SDL_config_h_ + +#include "SDL_platform.h" + + + +#ifdef __GNUC__ +#define HAVE_GCC_SYNC_LOCK_TEST_AND_SET 1 +#endif + +#define HAVE_GCC_ATOMICS 1 + +#define HAVE_ALLOCA_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_SIGNAL_H 1 + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_GETENV 1 +#define HAVE_SETENV 1 +#define HAVE_PUTENV 1 +#define HAVE_SETENV 1 +#define HAVE_UNSETENV 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE_STRLCPY 1 +#define HAVE_STRLCAT 1 +#define HAVE_STRDUP 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOULL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE_STRCASECMP 1 +#define HAVE_STRNCASECMP 1 +#define HAVE_VSSCANF 1 +#define HAVE_VSNPRINTF 1 +#define HAVE_M_PI 1 +#define HAVE_ATAN 1 +#define HAVE_ATAN2 1 +#define HAVE_ACOS 1 +#define HAVE_ASIN 1 +#define HAVE_CEIL 1 +#define HAVE_COPYSIGN 1 +#define HAVE_COS 1 +#define HAVE_COSF 1 +#define HAVE_FABS 1 +#define HAVE_FLOOR 1 +#define HAVE_LOG 1 +#define HAVE_POW 1 +#define HAVE_SCALBN 1 +#define HAVE_SIN 1 +#define HAVE_SINF 1 +#define HAVE_SQRT 1 +#define HAVE_SQRTF 1 +#define HAVE_TAN 1 +#define HAVE_TANF 1 +#define HAVE_SETJMP 1 +#define HAVE_NANOSLEEP 1 +/* #define HAVE_SYSCONF 1 */ +/* #define HAVE_SIGACTION 1 */ + + +/* PSP isn't that sophisticated */ +#define LACKS_SYS_MMAN_H 1 + +/* Enable the stub thread support (src/thread/psp/\*.c) */ +#define SDL_THREAD_PSP 1 + +/* Enable the stub timer support (src/timer/psp/\*.c) */ +#define SDL_TIMERS_PSP 1 + +/* Enable the stub joystick driver (src/joystick/psp/\*.c) */ +#define SDL_JOYSTICK_PSP 1 + +/* Enable the stub audio driver (src/audio/psp/\*.c) */ +#define SDL_AUDIO_DRIVER_PSP 1 + +/* PSP video dirver */ +#define SDL_VIDEO_DRIVER_PSP 1 + +/* PSP render dirver */ +#define SDL_VIDEO_RENDER_PSP 1 + +#define SDL_POWER_PSP 1 + +/* !!! FIXME: what does PSP do for filesystem stuff? */ +#define SDL_FILESYSTEM_DUMMY 1 + +/* PSP doesn't have haptic device (src/haptic/dummy/\*.c) */ +#define SDL_HAPTIC_DISABLED 1 + +/* PSP can't load shared object (src/loadso/dummy/\*.c) */ +#define SDL_LOADSO_DISABLED 1 + + +#endif /* SDL_config_psp_h_ */ diff --git a/thirdparty/include/SDL2/SDL_config_windows.h b/thirdparty/include/SDL2/SDL_config_windows.h new file mode 100644 index 000000000..2456c843f --- /dev/null +++ b/thirdparty/include/SDL2/SDL_config_windows.h @@ -0,0 +1,225 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_config_windows_h_ +#define SDL_config_windows_h_ +#define SDL_config_h_ + +#include "SDL_platform.h" + +/* This is a set of defines to configure the SDL features */ + +#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) +#if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) +#define HAVE_STDINT_H 1 +#elif defined(_MSC_VER) +typedef signed __int8 int8_t; +typedef unsigned __int8 uint8_t; +typedef signed __int16 int16_t; +typedef unsigned __int16 uint16_t; +typedef signed __int32 int32_t; +typedef unsigned __int32 uint32_t; +typedef signed __int64 int64_t; +typedef unsigned __int64 uint64_t; +#ifndef _UINTPTR_T_DEFINED +#ifdef _WIN64 +typedef unsigned __int64 uintptr_t; +#else +typedef unsigned int uintptr_t; +#endif +#define _UINTPTR_T_DEFINED +#endif +/* Older Visual C++ headers don't have the Win64-compatible typedefs... */ +#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) +#define DWORD_PTR DWORD +#endif +#if ((_MSC_VER <= 1200) && (!defined(LONG_PTR))) +#define LONG_PTR LONG +#endif +#else /* !__GNUC__ && !_MSC_VER */ +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef signed long long int64_t; +typedef unsigned long long uint64_t; +#ifndef _SIZE_T_DEFINED_ +#define _SIZE_T_DEFINED_ +typedef unsigned int size_t; +#endif +typedef unsigned int uintptr_t; +#endif /* __GNUC__ || _MSC_VER */ +#endif /* !_STDINT_H_ && !HAVE_STDINT_H */ + +#ifdef _WIN64 +# define SIZEOF_VOIDP 8 +#else +# define SIZEOF_VOIDP 4 +#endif + +#define HAVE_DDRAW_H 1 +#define HAVE_DINPUT_H 1 +#define HAVE_DSOUND_H 1 +#define HAVE_DXGI_H 1 +#define HAVE_XINPUT_H 1 + +/* This is disabled by default to avoid C runtime dependencies and manifest requirements */ +#ifdef HAVE_LIBC +/* Useful headers */ +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_SIGNAL_H 1 + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE__STRREV 1 +#define HAVE__STRUPR 1 +#define HAVE__STRLWR 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE__LTOA 1 +#define HAVE__ULTOA 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE__STRICMP 1 +#define HAVE__STRNICMP 1 +#define HAVE_ATAN 1 +#define HAVE_ATAN2 1 +#define HAVE_ACOS 1 +#define HAVE_ASIN 1 +#define HAVE_CEIL 1 +#define HAVE_COS 1 +#define HAVE_COSF 1 +#define HAVE_FABS 1 +#define HAVE_FLOOR 1 +#define HAVE_LOG 1 +#define HAVE_POW 1 +#define HAVE_SIN 1 +#define HAVE_SINF 1 +#define HAVE_SQRT 1 +#define HAVE_SQRTF 1 +#define HAVE_TAN 1 +#define HAVE_TANF 1 +#if _MSC_VER >= 1800 +#define HAVE_STRTOLL 1 +#define HAVE_VSSCANF 1 +#define HAVE_COPYSIGN 1 +#define HAVE_SCALBN 1 +#endif +#if !defined(_MSC_VER) || defined(_USE_MATH_DEFINES) +#define HAVE_M_PI 1 +#endif +#else +#define HAVE_STDARG_H 1 +#define HAVE_STDDEF_H 1 +#endif + +/* Enable various audio drivers */ +#define SDL_AUDIO_DRIVER_WASAPI 1 +#define SDL_AUDIO_DRIVER_DSOUND 1 +#define SDL_AUDIO_DRIVER_XAUDIO2 0 +#define SDL_AUDIO_DRIVER_WINMM 1 +#define SDL_AUDIO_DRIVER_DISK 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable various input drivers */ +#define SDL_JOYSTICK_DINPUT 1 +#define SDL_JOYSTICK_XINPUT 1 +#define SDL_HAPTIC_DINPUT 1 +#define SDL_HAPTIC_XINPUT 1 + +/* Enable various shared object loading systems */ +#define SDL_LOADSO_WINDOWS 1 + +/* Enable various threading systems */ +#define SDL_THREAD_WINDOWS 1 + +/* Enable various timer systems */ +#define SDL_TIMER_WINDOWS 1 + +/* Enable various video drivers */ +#define SDL_VIDEO_DRIVER_DUMMY 1 +#define SDL_VIDEO_DRIVER_WINDOWS 1 + +#ifndef SDL_VIDEO_RENDER_D3D +#define SDL_VIDEO_RENDER_D3D 1 +#endif +#ifndef SDL_VIDEO_RENDER_D3D11 +#define SDL_VIDEO_RENDER_D3D11 0 +#endif + +/* Enable OpenGL support */ +#ifndef SDL_VIDEO_OPENGL +#define SDL_VIDEO_OPENGL 1 +#endif +#ifndef SDL_VIDEO_OPENGL_WGL +#define SDL_VIDEO_OPENGL_WGL 1 +#endif +#ifndef SDL_VIDEO_RENDER_OGL +#define SDL_VIDEO_RENDER_OGL 1 +#endif +#ifndef SDL_VIDEO_RENDER_OGL_ES2 +#define SDL_VIDEO_RENDER_OGL_ES2 1 +#endif +#ifndef SDL_VIDEO_OPENGL_ES2 +#define SDL_VIDEO_OPENGL_ES2 1 +#endif +#ifndef SDL_VIDEO_OPENGL_EGL +#define SDL_VIDEO_OPENGL_EGL 1 +#endif + +/* Enable Vulkan support */ +#define SDL_VIDEO_VULKAN 1 + +/* Enable system power support */ +#define SDL_POWER_WINDOWS 1 + +/* Enable filesystem support */ +#define SDL_FILESYSTEM_WINDOWS 1 + +/* Enable assembly routines (Win64 doesn't have inline asm) */ +#ifndef _WIN64 +#define SDL_ASSEMBLY_ROUTINES 1 +#endif + +#endif /* SDL_config_windows_h_ */ diff --git a/thirdparty/include/SDL2/SDL_config_winrt.h b/thirdparty/include/SDL2/SDL_config_winrt.h new file mode 100644 index 000000000..24f9e17f2 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_config_winrt.h @@ -0,0 +1,215 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_config_winrt_h_ +#define SDL_config_winrt_h_ +#define SDL_config_h_ + +#include "SDL_platform.h" + +/* Make sure the Windows SDK's NTDDI_VERSION macro gets defined. This is used + by SDL to determine which version of the Windows SDK is being used. +*/ +#include + +/* Define possibly-undefined NTDDI values (used when compiling SDL against + older versions of the Windows SDK. +*/ +#ifndef NTDDI_WINBLUE +#define NTDDI_WINBLUE 0x06030000 +#endif +#ifndef NTDDI_WIN10 +#define NTDDI_WIN10 0x0A000000 +#endif + +/* This is a set of defines to configure the SDL features */ + +#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) +#if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) +#define HAVE_STDINT_H 1 +#elif defined(_MSC_VER) +typedef signed __int8 int8_t; +typedef unsigned __int8 uint8_t; +typedef signed __int16 int16_t; +typedef unsigned __int16 uint16_t; +typedef signed __int32 int32_t; +typedef unsigned __int32 uint32_t; +typedef signed __int64 int64_t; +typedef unsigned __int64 uint64_t; +#ifndef _UINTPTR_T_DEFINED +#ifdef _WIN64 +typedef unsigned __int64 uintptr_t; +#else +typedef unsigned int uintptr_t; +#endif +#define _UINTPTR_T_DEFINED +#endif +/* Older Visual C++ headers don't have the Win64-compatible typedefs... */ +#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) +#define DWORD_PTR DWORD +#endif +#if ((_MSC_VER <= 1200) && (!defined(LONG_PTR))) +#define LONG_PTR LONG +#endif +#else /* !__GNUC__ && !_MSC_VER */ +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef signed long long int64_t; +typedef unsigned long long uint64_t; +#ifndef _SIZE_T_DEFINED_ +#define _SIZE_T_DEFINED_ +typedef unsigned int size_t; +#endif +typedef unsigned int uintptr_t; +#endif /* __GNUC__ || _MSC_VER */ +#endif /* !_STDINT_H_ && !HAVE_STDINT_H */ + +#ifdef _WIN64 +# define SIZEOF_VOIDP 8 +#else +# define SIZEOF_VOIDP 4 +#endif + +/* Useful headers */ +#define HAVE_DXGI_H 1 +#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP +#define HAVE_XINPUT_H 1 +#endif +#define HAVE_LIBC 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_FLOAT_H 1 +#define HAVE_SIGNAL_H 1 + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE__STRREV 1 +#define HAVE__STRUPR 1 +//#define HAVE__STRLWR 1 // TODO, WinRT: consider using _strlwr_s instead +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +//#define HAVE_ITOA 1 // TODO, WinRT: consider using _itoa_s instead +//#define HAVE__LTOA 1 // TODO, WinRT: consider using _ltoa_s instead +//#define HAVE__ULTOA 1 // TODO, WinRT: consider using _ultoa_s instead +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +//#define HAVE_STRTOLL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE__STRICMP 1 +#define HAVE__STRNICMP 1 +#define HAVE_VSNPRINTF 1 +//#define HAVE_SSCANF 1 // TODO, WinRT: consider using sscanf_s instead +#define HAVE_M_PI 1 +#define HAVE_ATAN 1 +#define HAVE_ATAN2 1 +#define HAVE_CEIL 1 +#define HAVE__COPYSIGN 1 +#define HAVE_COS 1 +#define HAVE_COSF 1 +#define HAVE_FABS 1 +#define HAVE_FLOOR 1 +#define HAVE_LOG 1 +#define HAVE_POW 1 +//#define HAVE_SCALBN 1 +#define HAVE__SCALB 1 +#define HAVE_SIN 1 +#define HAVE_SINF 1 +#define HAVE_SQRT 1 +#define HAVE_SQRTF 1 +#define HAVE_TAN 1 +#define HAVE_TANF 1 +#define HAVE__FSEEKI64 1 + +/* Enable various audio drivers */ +#define SDL_AUDIO_DRIVER_XAUDIO2 1 +#define SDL_AUDIO_DRIVER_DISK 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable various input drivers */ +#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP +#define SDL_JOYSTICK_DISABLED 1 +#define SDL_HAPTIC_DISABLED 1 +#else +#define SDL_JOYSTICK_XINPUT 1 +#define SDL_HAPTIC_XINPUT 1 +#endif + +/* Enable various shared object loading systems */ +#define SDL_LOADSO_WINDOWS 1 + +/* Enable various threading systems */ +#if (NTDDI_VERSION >= NTDDI_WINBLUE) +#define SDL_THREAD_WINDOWS 1 +#else +/* WinRT on Windows 8.0 and Windows Phone 8.0 don't support CreateThread() */ +#define SDL_THREAD_STDCPP 1 +#endif + +/* Enable various timer systems */ +#define SDL_TIMER_WINDOWS 1 + +/* Enable various video drivers */ +#define SDL_VIDEO_DRIVER_WINRT 1 +#define SDL_VIDEO_DRIVER_DUMMY 1 + +/* Enable OpenGL ES 2.0 (via a modified ANGLE library) */ +#define SDL_VIDEO_OPENGL_ES2 1 +#define SDL_VIDEO_OPENGL_EGL 1 + +/* Enable appropriate renderer(s) */ +#define SDL_VIDEO_RENDER_D3D11 1 + +#if SDL_VIDEO_OPENGL_ES2 +#define SDL_VIDEO_RENDER_OGL_ES2 1 +#endif + +/* Enable system power support */ +#define SDL_POWER_WINRT 1 + +/* Enable assembly routines (Win64 doesn't have inline asm) */ +#ifndef _WIN64 +#define SDL_ASSEMBLY_ROUTINES 1 +#endif + +#endif /* SDL_config_winrt_h_ */ diff --git a/thirdparty/include/SDL2/SDL_config_wiz.h b/thirdparty/include/SDL2/SDL_config_wiz.h new file mode 100644 index 000000000..5bb845a0c --- /dev/null +++ b/thirdparty/include/SDL2/SDL_config_wiz.h @@ -0,0 +1,121 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_config_wiz_h_ +#define SDL_config_wiz_h_ +#define SDL_config_h_ + +/* This is a set of defines to configure the SDL features */ + +/* General platform specific identifiers */ +#include "SDL_platform.h" + +#define SDL_BYTEORDER 1234 + +#define HAVE_ALLOCA_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STDARG_H 1 +#define HAVE_MALLOC_H 1 +#define HAVE_MEMORY_H 1 +#define HAVE_STRING_H 1 +#define HAVE_STRINGS_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_ICONV_H 1 +#define HAVE_SIGNAL_H 1 +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_GETENV 1 +#define HAVE_SETENV 1 +#define HAVE_PUTENV 1 +#define HAVE_UNSETENV 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_STRLEN 1 +#define HAVE_STRDUP 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOULL 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE_STRCASECMP 1 +#define HAVE_STRNCASECMP 1 +#define HAVE_VSSCANF 1 +#define HAVE_VSNPRINTF 1 +#define HAVE_M_PI 1 +#define HAVE_CEIL 1 +#define HAVE_COPYSIGN 1 +#define HAVE_COS 1 +#define HAVE_COSF 1 +#define HAVE_FABS 1 +#define HAVE_FLOOR 1 +#define HAVE_LOG 1 +#define HAVE_SCALBN 1 +#define HAVE_SIN 1 +#define HAVE_SINF 1 +#define HAVE_SQRT 1 +#define HAVE_SQRTF 1 +#define HAVE_TAN 1 +#define HAVE_TANF 1 +#define HAVE_SIGACTION 1 +#define HAVE_SETJMP 1 +#define HAVE_NANOSLEEP 1 +#define HAVE_POW 1 + +#define SDL_AUDIO_DRIVER_DUMMY 1 +#define SDL_AUDIO_DRIVER_OSS 1 + +#define SDL_INPUT_LINUXEV 1 +#define SDL_INPUT_TSLIB 1 +#define SDL_JOYSTICK_LINUX 1 +#define SDL_HAPTIC_LINUX 1 + +#define SDL_LOADSO_DLOPEN 1 + +#define SDL_THREAD_PTHREAD 1 +#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1 + +#define SDL_TIMER_UNIX 1 + +#define SDL_VIDEO_DRIVER_DUMMY 1 +#define SDL_VIDEO_DRIVER_PANDORA 1 +#define SDL_VIDEO_RENDER_OGL_ES 1 +#define SDL_VIDEO_OPENGL_ES 1 + +#endif /* SDL_config_wiz_h_ */ diff --git a/thirdparty/include/SDL2/SDL_copying.h b/thirdparty/include/SDL2/SDL_copying.h new file mode 100644 index 000000000..8f60af6b4 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_copying.h @@ -0,0 +1,20 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ diff --git a/thirdparty/include/SDL2/SDL_cpuinfo.h b/thirdparty/include/SDL2/SDL_cpuinfo.h new file mode 100644 index 000000000..0d9b82131 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_cpuinfo.h @@ -0,0 +1,275 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_cpuinfo.h + * + * CPU feature detection for SDL. + */ + +#ifndef SDL_cpuinfo_h_ +#define SDL_cpuinfo_h_ + +#include "SDL_stdinc.h" + +/* Need to do this here because intrin.h has C++ code in it */ +/* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */ +#if defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_IX86) || defined(_M_X64)) +#ifdef __clang__ +/* Many of the intrinsics SDL uses are not implemented by clang with Visual Studio */ +#undef __MMX__ +#undef __SSE__ +#undef __SSE2__ +#else +#include +#ifndef _WIN64 +#ifndef __MMX__ +#define __MMX__ +#endif +#ifndef __3dNOW__ +#define __3dNOW__ +#endif +#endif +#ifndef __SSE__ +#define __SSE__ +#endif +#ifndef __SSE2__ +#define __SSE2__ +#endif +#endif /* __clang__ */ +#elif defined(__MINGW64_VERSION_MAJOR) +#include +#else +/* altivec.h redefining bool causes a number of problems, see bugs 3993 and 4392, so you need to explicitly define SDL_ENABLE_ALTIVEC_H to have it included. */ +#if defined(HAVE_ALTIVEC_H) && defined(__ALTIVEC__) && !defined(__APPLE_ALTIVEC__) && defined(SDL_ENABLE_ALTIVEC_H) +#include +#endif +#if !defined(SDL_DISABLE_ARM_NEON_H) +# if defined(__ARM_NEON) +# include +# elif defined(__WINDOWS__) || defined(__WINRT__) +/* Visual Studio doesn't define __ARM_ARCH, but _M_ARM (if set, always 7), and _M_ARM64 (if set, always 1). */ +# if defined(_M_ARM) +# include +# include +# define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */ +# endif +# if defined (_M_ARM64) +# include +# include +# define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */ +# endif +# endif +#endif +#if defined(__3dNOW__) && !defined(SDL_DISABLE_MM3DNOW_H) +#include +#endif +#if defined(HAVE_IMMINTRIN_H) && !defined(SDL_DISABLE_IMMINTRIN_H) +#include +#else +#if defined(__MMX__) && !defined(SDL_DISABLE_MMINTRIN_H) +#include +#endif +#if defined(__SSE__) && !defined(SDL_DISABLE_XMMINTRIN_H) +#include +#endif +#if defined(__SSE2__) && !defined(SDL_DISABLE_EMMINTRIN_H) +#include +#endif +#if defined(__SSE3__) && !defined(SDL_DISABLE_PMMINTRIN_H) +#include +#endif +#endif /* HAVE_IMMINTRIN_H */ +#endif /* compiler version */ + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* This is a guess for the cacheline size used for padding. + * Most x86 processors have a 64 byte cache line. + * The 64-bit PowerPC processors have a 128 byte cache line. + * We'll use the larger value to be generally safe. + */ +#define SDL_CACHELINE_SIZE 128 + +/** + * This function returns the number of CPU cores available. + */ +extern DECLSPEC int SDLCALL SDL_GetCPUCount(void); + +/** + * This function returns the L1 cache line size of the CPU + * + * This is useful for determining multi-threaded structure padding + * or SIMD prefetch sizes. + */ +extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void); + +/** + * This function returns true if the CPU has the RDTSC instruction. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void); + +/** + * This function returns true if the CPU has AltiVec features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void); + +/** + * This function returns true if the CPU has MMX features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void); + +/** + * This function returns true if the CPU has 3DNow! features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void); + +/** + * This function returns true if the CPU has SSE features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void); + +/** + * This function returns true if the CPU has SSE2 features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void); + +/** + * This function returns true if the CPU has SSE3 features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void); + +/** + * This function returns true if the CPU has SSE4.1 features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void); + +/** + * This function returns true if the CPU has SSE4.2 features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void); + +/** + * This function returns true if the CPU has AVX features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX(void); + +/** + * This function returns true if the CPU has AVX2 features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX2(void); + +/** + * This function returns true if the CPU has AVX-512F (foundation) features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX512F(void); + +/** + * This function returns true if the CPU has ARM SIMD (ARMv6) features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasARMSIMD(void); + +/** + * This function returns true if the CPU has NEON (ARM SIMD) features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasNEON(void); + +/** + * This function returns the amount of RAM configured in the system, in MB. + */ +extern DECLSPEC int SDLCALL SDL_GetSystemRAM(void); + +/** + * \brief Report the alignment this system needs for SIMD allocations. + * + * This will return the minimum number of bytes to which a pointer must be + * aligned to be compatible with SIMD instructions on the current machine. + * For example, if the machine supports SSE only, it will return 16, but if + * it supports AVX-512F, it'll return 64 (etc). This only reports values for + * instruction sets SDL knows about, so if your SDL build doesn't have + * SDL_HasAVX512F(), then it might return 16 for the SSE support it sees and + * not 64 for the AVX-512 instructions that exist but SDL doesn't know about. + * Plan accordingly. + */ +extern DECLSPEC size_t SDLCALL SDL_SIMDGetAlignment(void); + +/** + * \brief Allocate memory in a SIMD-friendly way. + * + * This will allocate a block of memory that is suitable for use with SIMD + * instructions. Specifically, it will be properly aligned and padded for + * the system's supported vector instructions. + * + * The memory returned will be padded such that it is safe to read or write + * an incomplete vector at the end of the memory block. This can be useful + * so you don't have to drop back to a scalar fallback at the end of your + * SIMD processing loop to deal with the final elements without overflowing + * the allocated buffer. + * + * You must free this memory with SDL_FreeSIMD(), not free() or SDL_free() + * or delete[], etc. + * + * Note that SDL will only deal with SIMD instruction sets it is aware of; + * for example, SDL 2.0.8 knows that SSE wants 16-byte vectors + * (SDL_HasSSE()), and AVX2 wants 32 bytes (SDL_HasAVX2()), but doesn't + * know that AVX-512 wants 64. To be clear: if you can't decide to use an + * instruction set with an SDL_Has*() function, don't use that instruction + * set with memory allocated through here. + * + * SDL_AllocSIMD(0) will return a non-NULL pointer, assuming the system isn't + * out of memory. + * + * \param len The length, in bytes, of the block to allocated. The actual + * allocated block might be larger due to padding, etc. + * \return Pointer to newly-allocated block, NULL if out of memory. + * + * \sa SDL_SIMDAlignment + * \sa SDL_SIMDFree + */ +extern DECLSPEC void * SDLCALL SDL_SIMDAlloc(const size_t len); + +/** + * \brief Deallocate memory obtained from SDL_SIMDAlloc + * + * It is not valid to use this function on a pointer from anything but + * SDL_SIMDAlloc(). It can't be used on pointers from malloc, realloc, + * SDL_malloc, memalign, new[], etc. + * + * However, SDL_SIMDFree(NULL) is a legal no-op. + * + * \sa SDL_SIMDAlloc + */ +extern DECLSPEC void SDLCALL SDL_SIMDFree(void *ptr); + +/* vi: set ts=4 sw=4 expandtab: */ +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_cpuinfo_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_egl.h b/thirdparty/include/SDL2/SDL_egl.h new file mode 100644 index 000000000..531441e68 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_egl.h @@ -0,0 +1,1676 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_egl.h + * + * This is a simple file to encapsulate the EGL API headers. + */ +#if !defined(_MSC_VER) && !defined(__ANDROID__) + +#include +#include + +#else /* _MSC_VER */ + +/* EGL headers for Visual Studio */ + +#ifndef __khrplatform_h_ +#define __khrplatform_h_ + +/* +** Copyright (c) 2008-2009 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are 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 Materials. +** +** THE MATERIALS ARE 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 +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Khronos platform-specific types and definitions. +* +* $Revision: 23298 $ on $Date: 2013-09-30 17:07:13 -0700 (Mon, 30 Sep 2013) $ +* +* Adopters may modify this file to suit their platform. Adopters are +* encouraged to submit platform specific modifications to the Khronos +* group so that they can be included in future versions of this file. +* Please submit changes by sending them to the public Khronos Bugzilla +* (http://khronos.org/bugzilla) by filing a bug against product +* "Khronos (general)" component "Registry". +* +* A predefined template which fills in some of the bug fields can be +* reached using http://tinyurl.com/khrplatform-h-bugreport, but you +* must create a Bugzilla login first. +* +* +* See the Implementer's Guidelines for information about where this file +* should be located on your system and for more details of its use: +* http://www.khronos.org/registry/implementers_guide.pdf +* +* This file should be included as +* #include +* by Khronos client API header files that use its types and defines. +* +* The types in khrplatform.h should only be used to define API-specific types. +* +* Types defined in khrplatform.h: +* khronos_int8_t signed 8 bit +* khronos_uint8_t unsigned 8 bit +* khronos_int16_t signed 16 bit +* khronos_uint16_t unsigned 16 bit +* khronos_int32_t signed 32 bit +* khronos_uint32_t unsigned 32 bit +* khronos_int64_t signed 64 bit +* khronos_uint64_t unsigned 64 bit +* khronos_intptr_t signed same number of bits as a pointer +* khronos_uintptr_t unsigned same number of bits as a pointer +* khronos_ssize_t signed size +* khronos_usize_t unsigned size +* khronos_float_t signed 32 bit floating point +* khronos_time_ns_t unsigned 64 bit time in nanoseconds +* khronos_utime_nanoseconds_t unsigned time interval or absolute time in +* nanoseconds +* khronos_stime_nanoseconds_t signed time interval in nanoseconds +* khronos_boolean_enum_t enumerated boolean type. This should +* only be used as a base type when a client API's boolean type is +* an enum. Client APIs which use an integer or other type for +* booleans cannot use this as the base type for their boolean. +* +* Tokens defined in khrplatform.h: +* +* KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. +* +* KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. +* KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. +* +* Calling convention macros defined in this file: +* KHRONOS_APICALL +* KHRONOS_APIENTRY +* KHRONOS_APIATTRIBUTES +* +* These may be used in function prototypes as: +* +* KHRONOS_APICALL void KHRONOS_APIENTRY funcname( +* int arg1, +* int arg2) KHRONOS_APIATTRIBUTES; +*/ + +/*------------------------------------------------------------------------- +* Definition of KHRONOS_APICALL +*------------------------------------------------------------------------- +* This precedes the return type of the function in the function prototype. +*/ +#if defined(_WIN32) && !defined(__SCITECH_SNAP__) && !defined(SDL_VIDEO_STATIC_ANGLE) +# define KHRONOS_APICALL __declspec(dllimport) +#elif defined (__SYMBIAN32__) +# define KHRONOS_APICALL IMPORT_C +#else +# define KHRONOS_APICALL +#endif + +/*------------------------------------------------------------------------- +* Definition of KHRONOS_APIENTRY +*------------------------------------------------------------------------- +* This follows the return type of the function and precedes the function +* name in the function prototype. +*/ +#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) +/* Win32 but not WinCE */ +# define KHRONOS_APIENTRY __stdcall +#else +# define KHRONOS_APIENTRY +#endif + +/*------------------------------------------------------------------------- +* Definition of KHRONOS_APIATTRIBUTES +*------------------------------------------------------------------------- +* This follows the closing parenthesis of the function prototype arguments. +*/ +#if defined (__ARMCC_2__) +#define KHRONOS_APIATTRIBUTES __softfp +#else +#define KHRONOS_APIATTRIBUTES +#endif + +/*------------------------------------------------------------------------- +* basic type definitions +*-----------------------------------------------------------------------*/ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) + + +/* +* Using +*/ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__VMS ) || defined(__sgi) + +/* +* Using +*/ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(_WIN32) && !defined(__SCITECH_SNAP__) + +/* +* Win32 +*/ +typedef __int32 khronos_int32_t; +typedef unsigned __int32 khronos_uint32_t; +typedef __int64 khronos_int64_t; +typedef unsigned __int64 khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__sun__) || defined(__digital__) + +/* +* Sun or Digital +*/ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#if defined(__arch64__) || defined(_LP64) +typedef long int khronos_int64_t; +typedef unsigned long int khronos_uint64_t; +#else +typedef long long int khronos_int64_t; +typedef unsigned long long int khronos_uint64_t; +#endif /* __arch64__ */ +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif 0 + +/* +* Hypothetical platform with no float or int64 support +*/ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#define KHRONOS_SUPPORT_INT64 0 +#define KHRONOS_SUPPORT_FLOAT 0 + +#else + +/* +* Generic fallback +*/ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#endif + + +/* +* Types that are (so far) the same on all platforms +*/ +typedef signed char khronos_int8_t; +typedef unsigned char khronos_uint8_t; +typedef signed short int khronos_int16_t; +typedef unsigned short int khronos_uint16_t; + +/* +* Types that differ between LLP64 and LP64 architectures - in LLP64, +* pointers are 64 bits, but 'long' is still 32 bits. Win64 appears +* to be the only LLP64 architecture in current use. +*/ +#ifdef _WIN64 +typedef signed long long int khronos_intptr_t; +typedef unsigned long long int khronos_uintptr_t; +typedef signed long long int khronos_ssize_t; +typedef unsigned long long int khronos_usize_t; +#else +typedef signed long int khronos_intptr_t; +typedef unsigned long int khronos_uintptr_t; +typedef signed long int khronos_ssize_t; +typedef unsigned long int khronos_usize_t; +#endif + +#if KHRONOS_SUPPORT_FLOAT +/* +* Float type +*/ +typedef float khronos_float_t; +#endif + +#if KHRONOS_SUPPORT_INT64 +/* Time types +* +* These types can be used to represent a time interval in nanoseconds or +* an absolute Unadjusted System Time. Unadjusted System Time is the number +* of nanoseconds since some arbitrary system event (e.g. since the last +* time the system booted). The Unadjusted System Time is an unsigned +* 64 bit value that wraps back to 0 every 584 years. Time intervals +* may be either signed or unsigned. +*/ +typedef khronos_uint64_t khronos_utime_nanoseconds_t; +typedef khronos_int64_t khronos_stime_nanoseconds_t; +#endif + +/* +* Dummy value used to pad enum types to 32 bits. +*/ +#ifndef KHRONOS_MAX_ENUM +#define KHRONOS_MAX_ENUM 0x7FFFFFFF +#endif + +/* +* Enumerated boolean type +* +* Values other than zero should be considered to be true. Therefore +* comparisons should not be made against KHRONOS_TRUE. +*/ +typedef enum { + KHRONOS_FALSE = 0, + KHRONOS_TRUE = 1, + KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM +} khronos_boolean_enum_t; + +#endif /* __khrplatform_h_ */ + + +#ifndef __eglplatform_h_ +#define __eglplatform_h_ + +/* +** Copyright (c) 2007-2009 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are 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 Materials. +** +** THE MATERIALS ARE 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 +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Platform-specific types and definitions for egl.h +* $Revision: 12306 $ on $Date: 2010-08-25 09:51:28 -0700 (Wed, 25 Aug 2010) $ +* +* Adopters may modify khrplatform.h and this file to suit their platform. +* You are encouraged to submit all modifications to the Khronos group so that +* they can be included in future versions of this file. Please submit changes +* by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) +* by filing a bug against product "EGL" component "Registry". +*/ + +/*#include */ + +/* Macros used in EGL function prototype declarations. +* +* EGL functions should be prototyped as: +* +* EGLAPI return-type EGLAPIENTRY eglFunction(arguments); +* typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments); +* +* KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h +*/ + +#ifndef EGLAPI +#define EGLAPI KHRONOS_APICALL +#endif + +#ifndef EGLAPIENTRY +#define EGLAPIENTRY KHRONOS_APIENTRY +#endif +#define EGLAPIENTRYP EGLAPIENTRY* + +/* The types NativeDisplayType, NativeWindowType, and NativePixmapType +* are aliases of window-system-dependent types, such as X Display * or +* Windows Device Context. They must be defined in platform-specific +* code below. The EGL-prefixed versions of Native*Type are the same +* types, renamed in EGL 1.3 so all types in the API start with "EGL". +* +* Khronos STRONGLY RECOMMENDS that you use the default definitions +* provided below, since these changes affect both binary and source +* portability of applications using EGL running on different EGL +* implementations. +*/ + +#if defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */ +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif +#ifndef NOMINMAX /* don't define min() and max(). */ +#define NOMINMAX +#endif +#include + +#if __WINRT__ +#include +typedef IUnknown * EGLNativeWindowType; +typedef IUnknown * EGLNativePixmapType; +typedef IUnknown * EGLNativeDisplayType; +#else +typedef HDC EGLNativeDisplayType; +typedef HBITMAP EGLNativePixmapType; +typedef HWND EGLNativeWindowType; +#endif + +#elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */ + +typedef int EGLNativeDisplayType; +typedef void *EGLNativeWindowType; +typedef void *EGLNativePixmapType; + +#elif defined(WL_EGL_PLATFORM) + +typedef struct wl_display *EGLNativeDisplayType; +typedef struct wl_egl_pixmap *EGLNativePixmapType; +typedef struct wl_egl_window *EGLNativeWindowType; + +#elif defined(__GBM__) + +typedef struct gbm_device *EGLNativeDisplayType; +typedef struct gbm_bo *EGLNativePixmapType; +typedef void *EGLNativeWindowType; + +#elif defined(__ANDROID__) /* Android */ + +struct ANativeWindow; +struct egl_native_pixmap_t; + +typedef struct ANativeWindow *EGLNativeWindowType; +typedef struct egl_native_pixmap_t *EGLNativePixmapType; +typedef void *EGLNativeDisplayType; + +#elif defined(MIR_EGL_PLATFORM) + +#include +typedef MirEGLNativeDisplayType EGLNativeDisplayType; +typedef void *EGLNativePixmapType; +typedef MirEGLNativeWindowType EGLNativeWindowType; + +#elif defined(__unix__) + +#ifdef MESA_EGL_NO_X11_HEADERS + +typedef void *EGLNativeDisplayType; +typedef khronos_uintptr_t EGLNativePixmapType; +typedef khronos_uintptr_t EGLNativeWindowType; + +#else + +/* X11 (tentative) */ +#include +#include + +typedef Display *EGLNativeDisplayType; +typedef Pixmap EGLNativePixmapType; +typedef Window EGLNativeWindowType; + +#endif /* MESA_EGL_NO_X11_HEADERS */ + +#else +#error "Platform not recognized" +#endif + +/* EGL 1.2 types, renamed for consistency in EGL 1.3 */ +typedef EGLNativeDisplayType NativeDisplayType; +typedef EGLNativePixmapType NativePixmapType; +typedef EGLNativeWindowType NativeWindowType; + + +/* Define EGLint. This must be a signed integral type large enough to contain +* all legal attribute names and values passed into and out of EGL, whether +* their type is boolean, bitmask, enumerant (symbolic constant), integer, +* handle, or other. While in general a 32-bit integer will suffice, if +* handles are 64 bit types, then EGLint should be defined as a signed 64-bit +* integer type. +*/ +typedef khronos_int32_t EGLint; + +#endif /* __eglplatform_h */ + +#ifndef __egl_h_ +#define __egl_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2013-2015 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are 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 Materials. +** +** THE MATERIALS ARE 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 +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ +/* +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** http://www.opengl.org/registry/ +** +** Khronos $Revision: 31566 $ on $Date: 2015-06-23 08:48:48 -0700 (Tue, 23 Jun 2015) $ +*/ + +/*#include */ + +/* Generated on date 20150623 */ + +/* Generated C header for: + * API: egl + * Versions considered: .* + * Versions emitted: .* + * Default extensions included: None + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef EGL_VERSION_1_0 +#define EGL_VERSION_1_0 1 +typedef unsigned int EGLBoolean; +typedef void *EGLDisplay; +typedef void *EGLConfig; +typedef void *EGLSurface; +typedef void *EGLContext; +typedef void (*__eglMustCastToProperFunctionPointerType)(void); +#define EGL_ALPHA_SIZE 0x3021 +#define EGL_BAD_ACCESS 0x3002 +#define EGL_BAD_ALLOC 0x3003 +#define EGL_BAD_ATTRIBUTE 0x3004 +#define EGL_BAD_CONFIG 0x3005 +#define EGL_BAD_CONTEXT 0x3006 +#define EGL_BAD_CURRENT_SURFACE 0x3007 +#define EGL_BAD_DISPLAY 0x3008 +#define EGL_BAD_MATCH 0x3009 +#define EGL_BAD_NATIVE_PIXMAP 0x300A +#define EGL_BAD_NATIVE_WINDOW 0x300B +#define EGL_BAD_PARAMETER 0x300C +#define EGL_BAD_SURFACE 0x300D +#define EGL_BLUE_SIZE 0x3022 +#define EGL_BUFFER_SIZE 0x3020 +#define EGL_CONFIG_CAVEAT 0x3027 +#define EGL_CONFIG_ID 0x3028 +#define EGL_CORE_NATIVE_ENGINE 0x305B +#define EGL_DEPTH_SIZE 0x3025 +#define EGL_DONT_CARE ((EGLint)-1) +#define EGL_DRAW 0x3059 +#define EGL_EXTENSIONS 0x3055 +#define EGL_FALSE 0 +#define EGL_GREEN_SIZE 0x3023 +#define EGL_HEIGHT 0x3056 +#define EGL_LARGEST_PBUFFER 0x3058 +#define EGL_LEVEL 0x3029 +#define EGL_MAX_PBUFFER_HEIGHT 0x302A +#define EGL_MAX_PBUFFER_PIXELS 0x302B +#define EGL_MAX_PBUFFER_WIDTH 0x302C +#define EGL_NATIVE_RENDERABLE 0x302D +#define EGL_NATIVE_VISUAL_ID 0x302E +#define EGL_NATIVE_VISUAL_TYPE 0x302F +#define EGL_NONE 0x3038 +#define EGL_NON_CONFORMANT_CONFIG 0x3051 +#define EGL_NOT_INITIALIZED 0x3001 +#define EGL_NO_CONTEXT ((EGLContext)0) +#define EGL_NO_DISPLAY ((EGLDisplay)0) +#define EGL_NO_SURFACE ((EGLSurface)0) +#define EGL_PBUFFER_BIT 0x0001 +#define EGL_PIXMAP_BIT 0x0002 +#define EGL_READ 0x305A +#define EGL_RED_SIZE 0x3024 +#define EGL_SAMPLES 0x3031 +#define EGL_SAMPLE_BUFFERS 0x3032 +#define EGL_SLOW_CONFIG 0x3050 +#define EGL_STENCIL_SIZE 0x3026 +#define EGL_SUCCESS 0x3000 +#define EGL_SURFACE_TYPE 0x3033 +#define EGL_TRANSPARENT_BLUE_VALUE 0x3035 +#define EGL_TRANSPARENT_GREEN_VALUE 0x3036 +#define EGL_TRANSPARENT_RED_VALUE 0x3037 +#define EGL_TRANSPARENT_RGB 0x3052 +#define EGL_TRANSPARENT_TYPE 0x3034 +#define EGL_TRUE 1 +#define EGL_VENDOR 0x3053 +#define EGL_VERSION 0x3054 +#define EGL_WIDTH 0x3057 +#define EGL_WINDOW_BIT 0x0004 +EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config); +EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers (EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target); +EGLAPI EGLContext EGLAPIENTRY eglCreateContext (EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface (EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface (EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext (EGLDisplay dpy, EGLContext ctx); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface (EGLDisplay dpy, EGLSurface surface); +EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value); +EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config); +EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay (void); +EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface (EGLint readdraw); +EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay (EGLNativeDisplayType display_id); +EGLAPI EGLint EGLAPIENTRY eglGetError (void); +EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress (const char *procname); +EGLAPI EGLBoolean EGLAPIENTRY eglInitialize (EGLDisplay dpy, EGLint *major, EGLint *minor); +EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext (EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value); +EGLAPI const char *EGLAPIENTRY eglQueryString (EGLDisplay dpy, EGLint name); +EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value); +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers (EGLDisplay dpy, EGLSurface surface); +EGLAPI EGLBoolean EGLAPIENTRY eglTerminate (EGLDisplay dpy); +EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL (void); +EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative (EGLint engine); +#endif /* EGL_VERSION_1_0 */ + +#ifndef EGL_VERSION_1_1 +#define EGL_VERSION_1_1 1 +#define EGL_BACK_BUFFER 0x3084 +#define EGL_BIND_TO_TEXTURE_RGB 0x3039 +#define EGL_BIND_TO_TEXTURE_RGBA 0x303A +#define EGL_CONTEXT_LOST 0x300E +#define EGL_MIN_SWAP_INTERVAL 0x303B +#define EGL_MAX_SWAP_INTERVAL 0x303C +#define EGL_MIPMAP_TEXTURE 0x3082 +#define EGL_MIPMAP_LEVEL 0x3083 +#define EGL_NO_TEXTURE 0x305C +#define EGL_TEXTURE_2D 0x305F +#define EGL_TEXTURE_FORMAT 0x3080 +#define EGL_TEXTURE_RGB 0x305D +#define EGL_TEXTURE_RGBA 0x305E +#define EGL_TEXTURE_TARGET 0x3081 +EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer); +EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer); +EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value); +EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval (EGLDisplay dpy, EGLint interval); +#endif /* EGL_VERSION_1_1 */ + +#ifndef EGL_VERSION_1_2 +#define EGL_VERSION_1_2 1 +typedef unsigned int EGLenum; +typedef void *EGLClientBuffer; +#define EGL_ALPHA_FORMAT 0x3088 +#define EGL_ALPHA_FORMAT_NONPRE 0x308B +#define EGL_ALPHA_FORMAT_PRE 0x308C +#define EGL_ALPHA_MASK_SIZE 0x303E +#define EGL_BUFFER_PRESERVED 0x3094 +#define EGL_BUFFER_DESTROYED 0x3095 +#define EGL_CLIENT_APIS 0x308D +#define EGL_COLORSPACE 0x3087 +#define EGL_COLORSPACE_sRGB 0x3089 +#define EGL_COLORSPACE_LINEAR 0x308A +#define EGL_COLOR_BUFFER_TYPE 0x303F +#define EGL_CONTEXT_CLIENT_TYPE 0x3097 +#define EGL_DISPLAY_SCALING 10000 +#define EGL_HORIZONTAL_RESOLUTION 0x3090 +#define EGL_LUMINANCE_BUFFER 0x308F +#define EGL_LUMINANCE_SIZE 0x303D +#define EGL_OPENGL_ES_BIT 0x0001 +#define EGL_OPENVG_BIT 0x0002 +#define EGL_OPENGL_ES_API 0x30A0 +#define EGL_OPENVG_API 0x30A1 +#define EGL_OPENVG_IMAGE 0x3096 +#define EGL_PIXEL_ASPECT_RATIO 0x3092 +#define EGL_RENDERABLE_TYPE 0x3040 +#define EGL_RENDER_BUFFER 0x3086 +#define EGL_RGB_BUFFER 0x308E +#define EGL_SINGLE_BUFFER 0x3085 +#define EGL_SWAP_BEHAVIOR 0x3093 +#define EGL_UNKNOWN ((EGLint)-1) +#define EGL_VERTICAL_RESOLUTION 0x3091 +EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI (EGLenum api); +EGLAPI EGLenum EGLAPIENTRY eglQueryAPI (void); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer (EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread (void); +EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient (void); +#endif /* EGL_VERSION_1_2 */ + +#ifndef EGL_VERSION_1_3 +#define EGL_VERSION_1_3 1 +#define EGL_CONFORMANT 0x3042 +#define EGL_CONTEXT_CLIENT_VERSION 0x3098 +#define EGL_MATCH_NATIVE_PIXMAP 0x3041 +#define EGL_OPENGL_ES2_BIT 0x0004 +#define EGL_VG_ALPHA_FORMAT 0x3088 +#define EGL_VG_ALPHA_FORMAT_NONPRE 0x308B +#define EGL_VG_ALPHA_FORMAT_PRE 0x308C +#define EGL_VG_ALPHA_FORMAT_PRE_BIT 0x0040 +#define EGL_VG_COLORSPACE 0x3087 +#define EGL_VG_COLORSPACE_sRGB 0x3089 +#define EGL_VG_COLORSPACE_LINEAR 0x308A +#define EGL_VG_COLORSPACE_LINEAR_BIT 0x0020 +#endif /* EGL_VERSION_1_3 */ + +#ifndef EGL_VERSION_1_4 +#define EGL_VERSION_1_4 1 +#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0) +#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200 +#define EGL_MULTISAMPLE_RESOLVE 0x3099 +#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A +#define EGL_MULTISAMPLE_RESOLVE_BOX 0x309B +#define EGL_OPENGL_API 0x30A2 +#define EGL_OPENGL_BIT 0x0008 +#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400 +EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext (void); +#endif /* EGL_VERSION_1_4 */ + +#ifndef EGL_VERSION_1_5 +#define EGL_VERSION_1_5 1 +typedef void *EGLSync; +typedef intptr_t EGLAttrib; +typedef khronos_utime_nanoseconds_t EGLTime; +typedef void *EGLImage; +#define EGL_CONTEXT_MAJOR_VERSION 0x3098 +#define EGL_CONTEXT_MINOR_VERSION 0x30FB +#define EGL_CONTEXT_OPENGL_PROFILE_MASK 0x30FD +#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY 0x31BD +#define EGL_NO_RESET_NOTIFICATION 0x31BE +#define EGL_LOSE_CONTEXT_ON_RESET 0x31BF +#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT 0x00000001 +#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT 0x00000002 +#define EGL_CONTEXT_OPENGL_DEBUG 0x31B0 +#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE 0x31B1 +#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS 0x31B2 +#define EGL_OPENGL_ES3_BIT 0x00000040 +#define EGL_CL_EVENT_HANDLE 0x309C +#define EGL_SYNC_CL_EVENT 0x30FE +#define EGL_SYNC_CL_EVENT_COMPLETE 0x30FF +#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE 0x30F0 +#define EGL_SYNC_TYPE 0x30F7 +#define EGL_SYNC_STATUS 0x30F1 +#define EGL_SYNC_CONDITION 0x30F8 +#define EGL_SIGNALED 0x30F2 +#define EGL_UNSIGNALED 0x30F3 +#define EGL_SYNC_FLUSH_COMMANDS_BIT 0x0001 +#define EGL_FOREVER 0xFFFFFFFFFFFFFFFFull +#define EGL_TIMEOUT_EXPIRED 0x30F5 +#define EGL_CONDITION_SATISFIED 0x30F6 +#define EGL_NO_SYNC ((EGLSync)0) +#define EGL_SYNC_FENCE 0x30F9 +#define EGL_GL_COLORSPACE 0x309D +#define EGL_GL_COLORSPACE_SRGB 0x3089 +#define EGL_GL_COLORSPACE_LINEAR 0x308A +#define EGL_GL_RENDERBUFFER 0x30B9 +#define EGL_GL_TEXTURE_2D 0x30B1 +#define EGL_GL_TEXTURE_LEVEL 0x30BC +#define EGL_GL_TEXTURE_3D 0x30B2 +#define EGL_GL_TEXTURE_ZOFFSET 0x30BD +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x30B3 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x30B4 +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x30B5 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x30B6 +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x30B7 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x30B8 +#define EGL_IMAGE_PRESERVED 0x30D2 +#define EGL_NO_IMAGE ((EGLImage)0) +EGLAPI EGLSync EGLAPIENTRY eglCreateSync (EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroySync (EGLDisplay dpy, EGLSync sync); +EGLAPI EGLint EGLAPIENTRY eglClientWaitSync (EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout); +EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttrib (EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value); +EGLAPI EGLImage EGLAPIENTRY eglCreateImage (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImage (EGLDisplay dpy, EGLImage image); +EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplay (EGLenum platform, void *native_display, const EGLAttrib *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformWindowSurface (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurface (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglWaitSync (EGLDisplay dpy, EGLSync sync, EGLint flags); +#endif /* EGL_VERSION_1_5 */ + +#ifdef __cplusplus +} +#endif + +#endif /* __egl_h_ */ + + + +#ifndef __eglext_h_ +#define __eglext_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2013-2015 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are 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 Materials. +** +** THE MATERIALS ARE 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 +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ +/* +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** http://www.opengl.org/registry/ +** +** Khronos $Revision: 31566 $ on $Date: 2015-06-23 08:48:48 -0700 (Tue, 23 Jun 2015) $ +*/ + +/*#include */ + +#define EGL_EGLEXT_VERSION 20150623 + +/* Generated C header for: + * API: egl + * Versions considered: .* + * Versions emitted: _nomatch_^ + * Default extensions included: egl + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef EGL_KHR_cl_event +#define EGL_KHR_cl_event 1 +#define EGL_CL_EVENT_HANDLE_KHR 0x309C +#define EGL_SYNC_CL_EVENT_KHR 0x30FE +#define EGL_SYNC_CL_EVENT_COMPLETE_KHR 0x30FF +#endif /* EGL_KHR_cl_event */ + +#ifndef EGL_KHR_cl_event2 +#define EGL_KHR_cl_event2 1 +typedef void *EGLSyncKHR; +typedef intptr_t EGLAttribKHR; +typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNC64KHRPROC) (EGLDisplay dpy, EGLenum type, const EGLAttribKHR *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSync64KHR (EGLDisplay dpy, EGLenum type, const EGLAttribKHR *attrib_list); +#endif +#endif /* EGL_KHR_cl_event2 */ + +#ifndef EGL_KHR_client_get_all_proc_addresses +#define EGL_KHR_client_get_all_proc_addresses 1 +#endif /* EGL_KHR_client_get_all_proc_addresses */ + +#ifndef EGL_KHR_config_attribs +#define EGL_KHR_config_attribs 1 +#define EGL_CONFORMANT_KHR 0x3042 +#define EGL_VG_COLORSPACE_LINEAR_BIT_KHR 0x0020 +#define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR 0x0040 +#endif /* EGL_KHR_config_attribs */ + +#ifndef EGL_KHR_create_context +#define EGL_KHR_create_context 1 +#define EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098 +#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB +#define EGL_CONTEXT_FLAGS_KHR 0x30FC +#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD +#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31BD +#define EGL_NO_RESET_NOTIFICATION_KHR 0x31BE +#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31BF +#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001 +#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002 +#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004 +#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001 +#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002 +#define EGL_OPENGL_ES3_BIT_KHR 0x00000040 +#endif /* EGL_KHR_create_context */ + +#ifndef EGL_KHR_create_context_no_error +#define EGL_KHR_create_context_no_error 1 +#define EGL_CONTEXT_OPENGL_NO_ERROR_KHR 0x31B3 +#endif /* EGL_KHR_create_context_no_error */ + +#ifndef EGL_KHR_fence_sync +#define EGL_KHR_fence_sync 1 +typedef khronos_utime_nanoseconds_t EGLTimeKHR; +#ifdef KHRONOS_SUPPORT_INT64 +#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR 0x30F0 +#define EGL_SYNC_CONDITION_KHR 0x30F8 +#define EGL_SYNC_FENCE_KHR 0x30F9 +typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNCKHRPROC) (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync); +typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR (EGLDisplay dpy, EGLSyncKHR sync); +EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); +EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); +#endif +#endif /* KHRONOS_SUPPORT_INT64 */ +#endif /* EGL_KHR_fence_sync */ + +#ifndef EGL_KHR_get_all_proc_addresses +#define EGL_KHR_get_all_proc_addresses 1 +#endif /* EGL_KHR_get_all_proc_addresses */ + +#ifndef EGL_KHR_gl_colorspace +#define EGL_KHR_gl_colorspace 1 +#define EGL_GL_COLORSPACE_KHR 0x309D +#define EGL_GL_COLORSPACE_SRGB_KHR 0x3089 +#define EGL_GL_COLORSPACE_LINEAR_KHR 0x308A +#endif /* EGL_KHR_gl_colorspace */ + +#ifndef EGL_KHR_gl_renderbuffer_image +#define EGL_KHR_gl_renderbuffer_image 1 +#define EGL_GL_RENDERBUFFER_KHR 0x30B9 +#endif /* EGL_KHR_gl_renderbuffer_image */ + +#ifndef EGL_KHR_gl_texture_2D_image +#define EGL_KHR_gl_texture_2D_image 1 +#define EGL_GL_TEXTURE_2D_KHR 0x30B1 +#define EGL_GL_TEXTURE_LEVEL_KHR 0x30BC +#endif /* EGL_KHR_gl_texture_2D_image */ + +#ifndef EGL_KHR_gl_texture_3D_image +#define EGL_KHR_gl_texture_3D_image 1 +#define EGL_GL_TEXTURE_3D_KHR 0x30B2 +#define EGL_GL_TEXTURE_ZOFFSET_KHR 0x30BD +#endif /* EGL_KHR_gl_texture_3D_image */ + +#ifndef EGL_KHR_gl_texture_cubemap_image +#define EGL_KHR_gl_texture_cubemap_image 1 +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR 0x30B3 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR 0x30B4 +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR 0x30B5 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR 0x30B6 +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR 0x30B7 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR 0x30B8 +#endif /* EGL_KHR_gl_texture_cubemap_image */ + +#ifndef EGL_KHR_image +#define EGL_KHR_image 1 +typedef void *EGLImageKHR; +#define EGL_NATIVE_PIXMAP_KHR 0x30B0 +#define EGL_NO_IMAGE_KHR ((EGLImageKHR)0) +typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image); +#endif +#endif /* EGL_KHR_image */ + +#ifndef EGL_KHR_image_base +#define EGL_KHR_image_base 1 +#define EGL_IMAGE_PRESERVED_KHR 0x30D2 +#endif /* EGL_KHR_image_base */ + +#ifndef EGL_KHR_image_pixmap +#define EGL_KHR_image_pixmap 1 +#endif /* EGL_KHR_image_pixmap */ + +#ifndef EGL_KHR_lock_surface +#define EGL_KHR_lock_surface 1 +#define EGL_READ_SURFACE_BIT_KHR 0x0001 +#define EGL_WRITE_SURFACE_BIT_KHR 0x0002 +#define EGL_LOCK_SURFACE_BIT_KHR 0x0080 +#define EGL_OPTIMAL_FORMAT_BIT_KHR 0x0100 +#define EGL_MATCH_FORMAT_KHR 0x3043 +#define EGL_FORMAT_RGB_565_EXACT_KHR 0x30C0 +#define EGL_FORMAT_RGB_565_KHR 0x30C1 +#define EGL_FORMAT_RGBA_8888_EXACT_KHR 0x30C2 +#define EGL_FORMAT_RGBA_8888_KHR 0x30C3 +#define EGL_MAP_PRESERVE_PIXELS_KHR 0x30C4 +#define EGL_LOCK_USAGE_HINT_KHR 0x30C5 +#define EGL_BITMAP_POINTER_KHR 0x30C6 +#define EGL_BITMAP_PITCH_KHR 0x30C7 +#define EGL_BITMAP_ORIGIN_KHR 0x30C8 +#define EGL_BITMAP_PIXEL_RED_OFFSET_KHR 0x30C9 +#define EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR 0x30CA +#define EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR 0x30CB +#define EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR 0x30CC +#define EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR 0x30CD +#define EGL_LOWER_LEFT_KHR 0x30CE +#define EGL_UPPER_LEFT_KHR 0x30CF +typedef EGLBoolean (EGLAPIENTRYP PFNEGLLOCKSURFACEKHRPROC) (EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay dpy, EGLSurface surface); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglLockSurfaceKHR (EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR (EGLDisplay dpy, EGLSurface surface); +#endif +#endif /* EGL_KHR_lock_surface */ + +#ifndef EGL_KHR_lock_surface2 +#define EGL_KHR_lock_surface2 1 +#define EGL_BITMAP_PIXEL_SIZE_KHR 0x3110 +#endif /* EGL_KHR_lock_surface2 */ + +#ifndef EGL_KHR_lock_surface3 +#define EGL_KHR_lock_surface3 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACE64KHRPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLAttribKHR *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface64KHR (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLAttribKHR *value); +#endif +#endif /* EGL_KHR_lock_surface3 */ + +#ifndef EGL_KHR_partial_update +#define EGL_KHR_partial_update 1 +#define EGL_BUFFER_AGE_KHR 0x313D +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSETDAMAGEREGIONKHRPROC) (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSetDamageRegionKHR (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); +#endif +#endif /* EGL_KHR_partial_update */ + +#ifndef EGL_KHR_platform_android +#define EGL_KHR_platform_android 1 +#define EGL_PLATFORM_ANDROID_KHR 0x3141 +#endif /* EGL_KHR_platform_android */ + +#ifndef EGL_KHR_platform_gbm +#define EGL_KHR_platform_gbm 1 +#define EGL_PLATFORM_GBM_KHR 0x31D7 +#endif /* EGL_KHR_platform_gbm */ + +#ifndef EGL_KHR_platform_wayland +#define EGL_KHR_platform_wayland 1 +#define EGL_PLATFORM_WAYLAND_KHR 0x31D8 +#endif /* EGL_KHR_platform_wayland */ + +#ifndef EGL_KHR_platform_x11 +#define EGL_KHR_platform_x11 1 +#define EGL_PLATFORM_X11_KHR 0x31D5 +#define EGL_PLATFORM_X11_SCREEN_KHR 0x31D6 +#endif /* EGL_KHR_platform_x11 */ + +#ifndef EGL_KHR_reusable_sync +#define EGL_KHR_reusable_sync 1 +#ifdef KHRONOS_SUPPORT_INT64 +#define EGL_SYNC_STATUS_KHR 0x30F1 +#define EGL_SIGNALED_KHR 0x30F2 +#define EGL_UNSIGNALED_KHR 0x30F3 +#define EGL_TIMEOUT_EXPIRED_KHR 0x30F5 +#define EGL_CONDITION_SATISFIED_KHR 0x30F6 +#define EGL_SYNC_TYPE_KHR 0x30F7 +#define EGL_SYNC_REUSABLE_KHR 0x30FA +#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001 +#define EGL_FOREVER_KHR 0xFFFFFFFFFFFFFFFFull +#define EGL_NO_SYNC_KHR ((EGLSyncKHR)0) +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); +#endif +#endif /* KHRONOS_SUPPORT_INT64 */ +#endif /* EGL_KHR_reusable_sync */ + +#ifndef EGL_KHR_stream +#define EGL_KHR_stream 1 +typedef void *EGLStreamKHR; +typedef khronos_uint64_t EGLuint64KHR; +#ifdef KHRONOS_SUPPORT_INT64 +#define EGL_NO_STREAM_KHR ((EGLStreamKHR)0) +#define EGL_CONSUMER_LATENCY_USEC_KHR 0x3210 +#define EGL_PRODUCER_FRAME_KHR 0x3212 +#define EGL_CONSUMER_FRAME_KHR 0x3213 +#define EGL_STREAM_STATE_KHR 0x3214 +#define EGL_STREAM_STATE_CREATED_KHR 0x3215 +#define EGL_STREAM_STATE_CONNECTING_KHR 0x3216 +#define EGL_STREAM_STATE_EMPTY_KHR 0x3217 +#define EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR 0x3218 +#define EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR 0x3219 +#define EGL_STREAM_STATE_DISCONNECTED_KHR 0x321A +#define EGL_BAD_STREAM_KHR 0x321B +#define EGL_BAD_STATE_KHR 0x321C +typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMKHRPROC) (EGLDisplay dpy, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSTREAMKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMU64KHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamKHR (EGLDisplay dpy, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroyStreamKHR (EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamAttribKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamu64KHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value); +#endif +#endif /* KHRONOS_SUPPORT_INT64 */ +#endif /* EGL_KHR_stream */ + +#ifndef EGL_KHR_stream_consumer_gltexture +#define EGL_KHR_stream_consumer_gltexture 1 +#ifdef EGL_KHR_stream +#define EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR 0x321E +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalKHR (EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireKHR (EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerReleaseKHR (EGLDisplay dpy, EGLStreamKHR stream); +#endif +#endif /* EGL_KHR_stream */ +#endif /* EGL_KHR_stream_consumer_gltexture */ + +#ifndef EGL_KHR_stream_cross_process_fd +#define EGL_KHR_stream_cross_process_fd 1 +typedef int EGLNativeFileDescriptorKHR; +#ifdef EGL_KHR_stream +#define EGL_NO_FILE_DESCRIPTOR_KHR ((EGLNativeFileDescriptorKHR)(-1)) +typedef EGLNativeFileDescriptorKHR (EGLAPIENTRYP PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC) (EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLNativeFileDescriptorKHR EGLAPIENTRY eglGetStreamFileDescriptorKHR (EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamFromFileDescriptorKHR (EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor); +#endif +#endif /* EGL_KHR_stream */ +#endif /* EGL_KHR_stream_cross_process_fd */ + +#ifndef EGL_KHR_stream_fifo +#define EGL_KHR_stream_fifo 1 +#ifdef EGL_KHR_stream +#define EGL_STREAM_FIFO_LENGTH_KHR 0x31FC +#define EGL_STREAM_TIME_NOW_KHR 0x31FD +#define EGL_STREAM_TIME_CONSUMER_KHR 0x31FE +#define EGL_STREAM_TIME_PRODUCER_KHR 0x31FF +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMTIMEKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamTimeKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value); +#endif +#endif /* EGL_KHR_stream */ +#endif /* EGL_KHR_stream_fifo */ + +#ifndef EGL_KHR_stream_producer_aldatalocator +#define EGL_KHR_stream_producer_aldatalocator 1 +#ifdef EGL_KHR_stream +#endif /* EGL_KHR_stream */ +#endif /* EGL_KHR_stream_producer_aldatalocator */ + +#ifndef EGL_KHR_stream_producer_eglsurface +#define EGL_KHR_stream_producer_eglsurface 1 +#ifdef EGL_KHR_stream +#define EGL_STREAM_BIT_KHR 0x0800 +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC) (EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSurface EGLAPIENTRY eglCreateStreamProducerSurfaceKHR (EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list); +#endif +#endif /* EGL_KHR_stream */ +#endif /* EGL_KHR_stream_producer_eglsurface */ + +#ifndef EGL_KHR_surfaceless_context +#define EGL_KHR_surfaceless_context 1 +#endif /* EGL_KHR_surfaceless_context */ + +#ifndef EGL_KHR_swap_buffers_with_damage +#define EGL_KHR_swap_buffers_with_damage 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEKHRPROC) (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageKHR (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); +#endif +#endif /* EGL_KHR_swap_buffers_with_damage */ + +#ifndef EGL_KHR_vg_parent_image +#define EGL_KHR_vg_parent_image 1 +#define EGL_VG_PARENT_IMAGE_KHR 0x30BA +#endif /* EGL_KHR_vg_parent_image */ + +#ifndef EGL_KHR_wait_sync +#define EGL_KHR_wait_sync 1 +typedef EGLint (EGLAPIENTRYP PFNEGLWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLint EGLAPIENTRY eglWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags); +#endif +#endif /* EGL_KHR_wait_sync */ + +#ifndef EGL_ANDROID_blob_cache +#define EGL_ANDROID_blob_cache 1 +typedef khronos_ssize_t EGLsizeiANDROID; +typedef void (*EGLSetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, const void *value, EGLsizeiANDROID valueSize); +typedef EGLsizeiANDROID (*EGLGetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, void *value, EGLsizeiANDROID valueSize); +typedef void (EGLAPIENTRYP PFNEGLSETBLOBCACHEFUNCSANDROIDPROC) (EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI void EGLAPIENTRY eglSetBlobCacheFuncsANDROID (EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get); +#endif +#endif /* EGL_ANDROID_blob_cache */ + +#ifndef EGL_ANDROID_framebuffer_target +#define EGL_ANDROID_framebuffer_target 1 +#define EGL_FRAMEBUFFER_TARGET_ANDROID 0x3147 +#endif /* EGL_ANDROID_framebuffer_target */ + +#ifndef EGL_ANDROID_image_native_buffer +#define EGL_ANDROID_image_native_buffer 1 +#define EGL_NATIVE_BUFFER_ANDROID 0x3140 +#endif /* EGL_ANDROID_image_native_buffer */ + +#ifndef EGL_ANDROID_native_fence_sync +#define EGL_ANDROID_native_fence_sync 1 +#define EGL_SYNC_NATIVE_FENCE_ANDROID 0x3144 +#define EGL_SYNC_NATIVE_FENCE_FD_ANDROID 0x3145 +#define EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID 0x3146 +#define EGL_NO_NATIVE_FENCE_FD_ANDROID -1 +typedef EGLint (EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC) (EGLDisplay dpy, EGLSyncKHR sync); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLint EGLAPIENTRY eglDupNativeFenceFDANDROID (EGLDisplay dpy, EGLSyncKHR sync); +#endif +#endif /* EGL_ANDROID_native_fence_sync */ + +#ifndef EGL_ANDROID_recordable +#define EGL_ANDROID_recordable 1 +#define EGL_RECORDABLE_ANDROID 0x3142 +#endif /* EGL_ANDROID_recordable */ + +#ifndef EGL_ANGLE_d3d_share_handle_client_buffer +#define EGL_ANGLE_d3d_share_handle_client_buffer 1 +#define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200 +#endif /* EGL_ANGLE_d3d_share_handle_client_buffer */ + +#ifndef EGL_ANGLE_device_d3d +#define EGL_ANGLE_device_d3d 1 +#define EGL_D3D9_DEVICE_ANGLE 0x33A0 +#define EGL_D3D11_DEVICE_ANGLE 0x33A1 +#endif /* EGL_ANGLE_device_d3d */ + +#ifndef EGL_ANGLE_query_surface_pointer +#define EGL_ANGLE_query_surface_pointer 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurfacePointerANGLE (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value); +#endif +#endif /* EGL_ANGLE_query_surface_pointer */ + +#ifndef EGL_ANGLE_surface_d3d_texture_2d_share_handle +#define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1 +#endif /* EGL_ANGLE_surface_d3d_texture_2d_share_handle */ + +#ifndef EGL_ANGLE_window_fixed_size +#define EGL_ANGLE_window_fixed_size 1 +#define EGL_FIXED_SIZE_ANGLE 0x3201 +#endif /* EGL_ANGLE_window_fixed_size */ + +#ifndef EGL_ARM_pixmap_multisample_discard +#define EGL_ARM_pixmap_multisample_discard 1 +#define EGL_DISCARD_SAMPLES_ARM 0x3286 +#endif /* EGL_ARM_pixmap_multisample_discard */ + +#ifndef EGL_EXT_buffer_age +#define EGL_EXT_buffer_age 1 +#define EGL_BUFFER_AGE_EXT 0x313D +#endif /* EGL_EXT_buffer_age */ + +#ifndef EGL_EXT_client_extensions +#define EGL_EXT_client_extensions 1 +#endif /* EGL_EXT_client_extensions */ + +#ifndef EGL_EXT_create_context_robustness +#define EGL_EXT_create_context_robustness 1 +#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT 0x30BF +#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT 0x3138 +#define EGL_NO_RESET_NOTIFICATION_EXT 0x31BE +#define EGL_LOSE_CONTEXT_ON_RESET_EXT 0x31BF +#endif /* EGL_EXT_create_context_robustness */ + +#ifndef EGL_EXT_device_base +#define EGL_EXT_device_base 1 +typedef void *EGLDeviceEXT; +#define EGL_NO_DEVICE_EXT ((EGLDeviceEXT)(0)) +#define EGL_BAD_DEVICE_EXT 0x322B +#define EGL_DEVICE_EXT 0x322C +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICEATTRIBEXTPROC) (EGLDeviceEXT device, EGLint attribute, EGLAttrib *value); +typedef const char *(EGLAPIENTRYP PFNEGLQUERYDEVICESTRINGEXTPROC) (EGLDeviceEXT device, EGLint name); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICESEXTPROC) (EGLint max_devices, EGLDeviceEXT *devices, EGLint *num_devices); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDISPLAYATTRIBEXTPROC) (EGLDisplay dpy, EGLint attribute, EGLAttrib *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDeviceAttribEXT (EGLDeviceEXT device, EGLint attribute, EGLAttrib *value); +EGLAPI const char *EGLAPIENTRY eglQueryDeviceStringEXT (EGLDeviceEXT device, EGLint name); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDevicesEXT (EGLint max_devices, EGLDeviceEXT *devices, EGLint *num_devices); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribEXT (EGLDisplay dpy, EGLint attribute, EGLAttrib *value); +#endif +#endif /* EGL_EXT_device_base */ + +#ifndef EGL_EXT_device_drm +#define EGL_EXT_device_drm 1 +#define EGL_DRM_DEVICE_FILE_EXT 0x3233 +#endif /* EGL_EXT_device_drm */ + +#ifndef EGL_EXT_device_enumeration +#define EGL_EXT_device_enumeration 1 +#endif /* EGL_EXT_device_enumeration */ + +#ifndef EGL_EXT_device_openwf +#define EGL_EXT_device_openwf 1 +#define EGL_OPENWF_DEVICE_ID_EXT 0x3237 +#endif /* EGL_EXT_device_openwf */ + +#ifndef EGL_EXT_device_query +#define EGL_EXT_device_query 1 +#endif /* EGL_EXT_device_query */ + +#ifndef EGL_EXT_image_dma_buf_import +#define EGL_EXT_image_dma_buf_import 1 +#define EGL_LINUX_DMA_BUF_EXT 0x3270 +#define EGL_LINUX_DRM_FOURCC_EXT 0x3271 +#define EGL_DMA_BUF_PLANE0_FD_EXT 0x3272 +#define EGL_DMA_BUF_PLANE0_OFFSET_EXT 0x3273 +#define EGL_DMA_BUF_PLANE0_PITCH_EXT 0x3274 +#define EGL_DMA_BUF_PLANE1_FD_EXT 0x3275 +#define EGL_DMA_BUF_PLANE1_OFFSET_EXT 0x3276 +#define EGL_DMA_BUF_PLANE1_PITCH_EXT 0x3277 +#define EGL_DMA_BUF_PLANE2_FD_EXT 0x3278 +#define EGL_DMA_BUF_PLANE2_OFFSET_EXT 0x3279 +#define EGL_DMA_BUF_PLANE2_PITCH_EXT 0x327A +#define EGL_YUV_COLOR_SPACE_HINT_EXT 0x327B +#define EGL_SAMPLE_RANGE_HINT_EXT 0x327C +#define EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT 0x327D +#define EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT 0x327E +#define EGL_ITU_REC601_EXT 0x327F +#define EGL_ITU_REC709_EXT 0x3280 +#define EGL_ITU_REC2020_EXT 0x3281 +#define EGL_YUV_FULL_RANGE_EXT 0x3282 +#define EGL_YUV_NARROW_RANGE_EXT 0x3283 +#define EGL_YUV_CHROMA_SITING_0_EXT 0x3284 +#define EGL_YUV_CHROMA_SITING_0_5_EXT 0x3285 +#endif /* EGL_EXT_image_dma_buf_import */ + +#ifndef EGL_EXT_multiview_window +#define EGL_EXT_multiview_window 1 +#define EGL_MULTIVIEW_VIEW_COUNT_EXT 0x3134 +#endif /* EGL_EXT_multiview_window */ + +#ifndef EGL_EXT_output_base +#define EGL_EXT_output_base 1 +typedef void *EGLOutputLayerEXT; +typedef void *EGLOutputPortEXT; +#define EGL_NO_OUTPUT_LAYER_EXT ((EGLOutputLayerEXT)0) +#define EGL_NO_OUTPUT_PORT_EXT ((EGLOutputPortEXT)0) +#define EGL_BAD_OUTPUT_LAYER_EXT 0x322D +#define EGL_BAD_OUTPUT_PORT_EXT 0x322E +#define EGL_SWAP_INTERVAL_EXT 0x322F +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETOUTPUTLAYERSEXTPROC) (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputLayerEXT *layers, EGLint max_layers, EGLint *num_layers); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETOUTPUTPORTSEXTPROC) (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputPortEXT *ports, EGLint max_ports, EGLint *num_ports); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLOUTPUTLAYERATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYOUTPUTLAYERATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib *value); +typedef const char *(EGLAPIENTRYP PFNEGLQUERYOUTPUTLAYERSTRINGEXTPROC) (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint name); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLOUTPUTPORTATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYOUTPUTPORTATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib *value); +typedef const char *(EGLAPIENTRYP PFNEGLQUERYOUTPUTPORTSTRINGEXTPROC) (EGLDisplay dpy, EGLOutputPortEXT port, EGLint name); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglGetOutputLayersEXT (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputLayerEXT *layers, EGLint max_layers, EGLint *num_layers); +EGLAPI EGLBoolean EGLAPIENTRY eglGetOutputPortsEXT (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputPortEXT *ports, EGLint max_ports, EGLint *num_ports); +EGLAPI EGLBoolean EGLAPIENTRY eglOutputLayerAttribEXT (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib value); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryOutputLayerAttribEXT (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib *value); +EGLAPI const char *EGLAPIENTRY eglQueryOutputLayerStringEXT (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint name); +EGLAPI EGLBoolean EGLAPIENTRY eglOutputPortAttribEXT (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib value); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryOutputPortAttribEXT (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib *value); +EGLAPI const char *EGLAPIENTRY eglQueryOutputPortStringEXT (EGLDisplay dpy, EGLOutputPortEXT port, EGLint name); +#endif +#endif /* EGL_EXT_output_base */ + +#ifndef EGL_EXT_output_drm +#define EGL_EXT_output_drm 1 +#define EGL_DRM_CRTC_EXT 0x3234 +#define EGL_DRM_PLANE_EXT 0x3235 +#define EGL_DRM_CONNECTOR_EXT 0x3236 +#endif /* EGL_EXT_output_drm */ + +#ifndef EGL_EXT_output_openwf +#define EGL_EXT_output_openwf 1 +#define EGL_OPENWF_PIPELINE_ID_EXT 0x3238 +#define EGL_OPENWF_PORT_ID_EXT 0x3239 +#endif /* EGL_EXT_output_openwf */ + +#ifndef EGL_EXT_platform_base +#define EGL_EXT_platform_base 1 +typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC) (EGLenum platform, void *native_display, const EGLint *attrib_list); +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list); +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMPIXMAPSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplayEXT (EGLenum platform, void *native_display, const EGLint *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformWindowSurfaceEXT (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurfaceEXT (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list); +#endif +#endif /* EGL_EXT_platform_base */ + +#ifndef EGL_EXT_platform_device +#define EGL_EXT_platform_device 1 +#define EGL_PLATFORM_DEVICE_EXT 0x313F +#endif /* EGL_EXT_platform_device */ + +#ifndef EGL_EXT_platform_wayland +#define EGL_EXT_platform_wayland 1 +#define EGL_PLATFORM_WAYLAND_EXT 0x31D8 +#endif /* EGL_EXT_platform_wayland */ + +#ifndef EGL_EXT_platform_x11 +#define EGL_EXT_platform_x11 1 +#define EGL_PLATFORM_X11_EXT 0x31D5 +#define EGL_PLATFORM_X11_SCREEN_EXT 0x31D6 +#endif /* EGL_EXT_platform_x11 */ + +#ifndef EGL_EXT_protected_surface +#define EGL_EXT_protected_surface 1 +#define EGL_PROTECTED_CONTENT_EXT 0x32C0 +#endif /* EGL_EXT_protected_surface */ + +#ifndef EGL_EXT_stream_consumer_egloutput +#define EGL_EXT_stream_consumer_egloutput 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMEROUTPUTEXTPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLOutputLayerEXT layer); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerOutputEXT (EGLDisplay dpy, EGLStreamKHR stream, EGLOutputLayerEXT layer); +#endif +#endif /* EGL_EXT_stream_consumer_egloutput */ + +#ifndef EGL_EXT_swap_buffers_with_damage +#define EGL_EXT_swap_buffers_with_damage 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC) (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageEXT (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); +#endif +#endif /* EGL_EXT_swap_buffers_with_damage */ + +#ifndef EGL_EXT_yuv_surface +#define EGL_EXT_yuv_surface 1 +#define EGL_YUV_ORDER_EXT 0x3301 +#define EGL_YUV_NUMBER_OF_PLANES_EXT 0x3311 +#define EGL_YUV_SUBSAMPLE_EXT 0x3312 +#define EGL_YUV_DEPTH_RANGE_EXT 0x3317 +#define EGL_YUV_CSC_STANDARD_EXT 0x330A +#define EGL_YUV_PLANE_BPP_EXT 0x331A +#define EGL_YUV_BUFFER_EXT 0x3300 +#define EGL_YUV_ORDER_YUV_EXT 0x3302 +#define EGL_YUV_ORDER_YVU_EXT 0x3303 +#define EGL_YUV_ORDER_YUYV_EXT 0x3304 +#define EGL_YUV_ORDER_UYVY_EXT 0x3305 +#define EGL_YUV_ORDER_YVYU_EXT 0x3306 +#define EGL_YUV_ORDER_VYUY_EXT 0x3307 +#define EGL_YUV_ORDER_AYUV_EXT 0x3308 +#define EGL_YUV_SUBSAMPLE_4_2_0_EXT 0x3313 +#define EGL_YUV_SUBSAMPLE_4_2_2_EXT 0x3314 +#define EGL_YUV_SUBSAMPLE_4_4_4_EXT 0x3315 +#define EGL_YUV_DEPTH_RANGE_LIMITED_EXT 0x3318 +#define EGL_YUV_DEPTH_RANGE_FULL_EXT 0x3319 +#define EGL_YUV_CSC_STANDARD_601_EXT 0x330B +#define EGL_YUV_CSC_STANDARD_709_EXT 0x330C +#define EGL_YUV_CSC_STANDARD_2020_EXT 0x330D +#define EGL_YUV_PLANE_BPP_0_EXT 0x331B +#define EGL_YUV_PLANE_BPP_8_EXT 0x331C +#define EGL_YUV_PLANE_BPP_10_EXT 0x331D +#endif /* EGL_EXT_yuv_surface */ + +#ifndef EGL_HI_clientpixmap +#define EGL_HI_clientpixmap 1 +struct EGLClientPixmapHI { + void *pData; + EGLint iWidth; + EGLint iHeight; + EGLint iStride; +}; +#define EGL_CLIENT_PIXMAP_POINTER_HI 0x8F74 +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEHIPROC) (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI *pixmap); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurfaceHI (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI *pixmap); +#endif +#endif /* EGL_HI_clientpixmap */ + +#ifndef EGL_HI_colorformats +#define EGL_HI_colorformats 1 +#define EGL_COLOR_FORMAT_HI 0x8F70 +#define EGL_COLOR_RGB_HI 0x8F71 +#define EGL_COLOR_RGBA_HI 0x8F72 +#define EGL_COLOR_ARGB_HI 0x8F73 +#endif /* EGL_HI_colorformats */ + +#ifndef EGL_IMG_context_priority +#define EGL_IMG_context_priority 1 +#define EGL_CONTEXT_PRIORITY_LEVEL_IMG 0x3100 +#define EGL_CONTEXT_PRIORITY_HIGH_IMG 0x3101 +#define EGL_CONTEXT_PRIORITY_MEDIUM_IMG 0x3102 +#define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103 +#endif /* EGL_IMG_context_priority */ + +#ifndef EGL_MESA_drm_image +#define EGL_MESA_drm_image 1 +#define EGL_DRM_BUFFER_FORMAT_MESA 0x31D0 +#define EGL_DRM_BUFFER_USE_MESA 0x31D1 +#define EGL_DRM_BUFFER_FORMAT_ARGB32_MESA 0x31D2 +#define EGL_DRM_BUFFER_MESA 0x31D3 +#define EGL_DRM_BUFFER_STRIDE_MESA 0x31D4 +#define EGL_DRM_BUFFER_USE_SCANOUT_MESA 0x00000001 +#define EGL_DRM_BUFFER_USE_SHARE_MESA 0x00000002 +typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEDRMIMAGEMESAPROC) (EGLDisplay dpy, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLImageKHR EGLAPIENTRY eglCreateDRMImageMESA (EGLDisplay dpy, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglExportDRMImageMESA (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride); +#endif +#endif /* EGL_MESA_drm_image */ + +#ifndef EGL_MESA_image_dma_buf_export +#define EGL_MESA_image_dma_buf_export 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDMABUFIMAGEQUERYMESAPROC) (EGLDisplay dpy, EGLImageKHR image, int *fourcc, int *num_planes, EGLuint64KHR *modifiers); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDMABUFIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, int *fds, EGLint *strides, EGLint *offsets); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglExportDMABUFImageQueryMESA (EGLDisplay dpy, EGLImageKHR image, int *fourcc, int *num_planes, EGLuint64KHR *modifiers); +EGLAPI EGLBoolean EGLAPIENTRY eglExportDMABUFImageMESA (EGLDisplay dpy, EGLImageKHR image, int *fds, EGLint *strides, EGLint *offsets); +#endif +#endif /* EGL_MESA_image_dma_buf_export */ + +#ifndef EGL_MESA_platform_gbm +#define EGL_MESA_platform_gbm 1 +#define EGL_PLATFORM_GBM_MESA 0x31D7 +#endif /* EGL_MESA_platform_gbm */ + +#ifndef EGL_NOK_swap_region +#define EGL_NOK_swap_region 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGIONNOKPROC) (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersRegionNOK (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); +#endif +#endif /* EGL_NOK_swap_region */ + +#ifndef EGL_NOK_swap_region2 +#define EGL_NOK_swap_region2 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGION2NOKPROC) (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersRegion2NOK (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); +#endif +#endif /* EGL_NOK_swap_region2 */ + +#ifndef EGL_NOK_texture_from_pixmap +#define EGL_NOK_texture_from_pixmap 1 +#define EGL_Y_INVERTED_NOK 0x307F +#endif /* EGL_NOK_texture_from_pixmap */ + +#ifndef EGL_NV_3dvision_surface +#define EGL_NV_3dvision_surface 1 +#define EGL_AUTO_STEREO_NV 0x3136 +#endif /* EGL_NV_3dvision_surface */ + +#ifndef EGL_NV_coverage_sample +#define EGL_NV_coverage_sample 1 +#define EGL_COVERAGE_BUFFERS_NV 0x30E0 +#define EGL_COVERAGE_SAMPLES_NV 0x30E1 +#endif /* EGL_NV_coverage_sample */ + +#ifndef EGL_NV_coverage_sample_resolve +#define EGL_NV_coverage_sample_resolve 1 +#define EGL_COVERAGE_SAMPLE_RESOLVE_NV 0x3131 +#define EGL_COVERAGE_SAMPLE_RESOLVE_DEFAULT_NV 0x3132 +#define EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV 0x3133 +#endif /* EGL_NV_coverage_sample_resolve */ + +#ifndef EGL_NV_cuda_event +#define EGL_NV_cuda_event 1 +#define EGL_CUDA_EVENT_HANDLE_NV 0x323B +#define EGL_SYNC_CUDA_EVENT_NV 0x323C +#define EGL_SYNC_CUDA_EVENT_COMPLETE_NV 0x323D +#endif /* EGL_NV_cuda_event */ + +#ifndef EGL_NV_depth_nonlinear +#define EGL_NV_depth_nonlinear 1 +#define EGL_DEPTH_ENCODING_NV 0x30E2 +#define EGL_DEPTH_ENCODING_NONE_NV 0 +#define EGL_DEPTH_ENCODING_NONLINEAR_NV 0x30E3 +#endif /* EGL_NV_depth_nonlinear */ + +#ifndef EGL_NV_device_cuda +#define EGL_NV_device_cuda 1 +#define EGL_CUDA_DEVICE_NV 0x323A +#endif /* EGL_NV_device_cuda */ + +#ifndef EGL_NV_native_query +#define EGL_NV_native_query 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEDISPLAYNVPROC) (EGLDisplay dpy, EGLNativeDisplayType *display_id); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEWINDOWNVPROC) (EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType *window); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEPIXMAPNVPROC) (EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType *pixmap); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeDisplayNV (EGLDisplay dpy, EGLNativeDisplayType *display_id); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeWindowNV (EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType *window); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativePixmapNV (EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType *pixmap); +#endif +#endif /* EGL_NV_native_query */ + +#ifndef EGL_NV_post_convert_rounding +#define EGL_NV_post_convert_rounding 1 +#endif /* EGL_NV_post_convert_rounding */ + +#ifndef EGL_NV_post_sub_buffer +#define EGL_NV_post_sub_buffer 1 +#define EGL_POST_SUB_BUFFER_SUPPORTED_NV 0x30BE +typedef EGLBoolean (EGLAPIENTRYP PFNEGLPOSTSUBBUFFERNVPROC) (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height); +#endif +#endif /* EGL_NV_post_sub_buffer */ + +#ifndef EGL_NV_stream_sync +#define EGL_NV_stream_sync 1 +#define EGL_SYNC_NEW_FRAME_NV 0x321F +typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESTREAMSYNCNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum type, const EGLint *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateStreamSyncNV (EGLDisplay dpy, EGLStreamKHR stream, EGLenum type, const EGLint *attrib_list); +#endif +#endif /* EGL_NV_stream_sync */ + +#ifndef EGL_NV_sync +#define EGL_NV_sync 1 +typedef void *EGLSyncNV; +typedef khronos_utime_nanoseconds_t EGLTimeNV; +#ifdef KHRONOS_SUPPORT_INT64 +#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_NV 0x30E6 +#define EGL_SYNC_STATUS_NV 0x30E7 +#define EGL_SIGNALED_NV 0x30E8 +#define EGL_UNSIGNALED_NV 0x30E9 +#define EGL_SYNC_FLUSH_COMMANDS_BIT_NV 0x0001 +#define EGL_FOREVER_NV 0xFFFFFFFFFFFFFFFFull +#define EGL_ALREADY_SIGNALED_NV 0x30EA +#define EGL_TIMEOUT_EXPIRED_NV 0x30EB +#define EGL_CONDITION_SATISFIED_NV 0x30EC +#define EGL_SYNC_TYPE_NV 0x30ED +#define EGL_SYNC_CONDITION_NV 0x30EE +#define EGL_SYNC_FENCE_NV 0x30EF +#define EGL_NO_SYNC_NV ((EGLSyncNV)0) +typedef EGLSyncNV (EGLAPIENTRYP PFNEGLCREATEFENCESYNCNVPROC) (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCNVPROC) (EGLSyncNV sync); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLFENCENVPROC) (EGLSyncNV sync); +typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCNVPROC) (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCNVPROC) (EGLSyncNV sync, EGLenum mode); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBNVPROC) (EGLSyncNV sync, EGLint attribute, EGLint *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSyncNV EGLAPIENTRY eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncNV (EGLSyncNV sync); +EGLAPI EGLBoolean EGLAPIENTRY eglFenceNV (EGLSyncNV sync); +EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncNV (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout); +EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncNV (EGLSyncNV sync, EGLenum mode); +EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribNV (EGLSyncNV sync, EGLint attribute, EGLint *value); +#endif +#endif /* KHRONOS_SUPPORT_INT64 */ +#endif /* EGL_NV_sync */ + +#ifndef EGL_NV_system_time +#define EGL_NV_system_time 1 +typedef khronos_utime_nanoseconds_t EGLuint64NV; +#ifdef KHRONOS_SUPPORT_INT64 +typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC) (void); +typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC) (void); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeFrequencyNV (void); +EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV (void); +#endif +#endif /* KHRONOS_SUPPORT_INT64 */ +#endif /* EGL_NV_system_time */ + +#ifndef EGL_TIZEN_image_native_buffer +#define EGL_TIZEN_image_native_buffer 1 +#define EGL_NATIVE_BUFFER_TIZEN 0x32A0 +#endif /* EGL_TIZEN_image_native_buffer */ + +#ifndef EGL_TIZEN_image_native_surface +#define EGL_TIZEN_image_native_surface 1 +#define EGL_NATIVE_SURFACE_TIZEN 0x32A1 +#endif /* EGL_TIZEN_image_native_surface */ + +#ifdef __cplusplus +} +#endif + +#endif /* __eglext_h_ */ + + +#endif /* _MSC_VER */ diff --git a/thirdparty/include/SDL2/SDL_endian.h b/thirdparty/include/SDL2/SDL_endian.h new file mode 100644 index 000000000..171c008a8 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_endian.h @@ -0,0 +1,263 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_endian.h + * + * Functions for reading and writing endian-specific values + */ + +#ifndef SDL_endian_h_ +#define SDL_endian_h_ + +#include "SDL_stdinc.h" + +/** + * \name The two types of endianness + */ +/* @{ */ +#define SDL_LIL_ENDIAN 1234 +#define SDL_BIG_ENDIAN 4321 +/* @} */ + +#ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */ +#ifdef __linux__ +#include +#define SDL_BYTEORDER __BYTE_ORDER +#elif defined(__OpenBSD__) +#include +#define SDL_BYTEORDER BYTE_ORDER +#else +#if defined(__hppa__) || \ + defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \ + (defined(__MIPS__) && defined(__MIPSEB__)) || \ + defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \ + defined(__sparc__) +#define SDL_BYTEORDER SDL_BIG_ENDIAN +#else +#define SDL_BYTEORDER SDL_LIL_ENDIAN +#endif +#endif /* __linux__ */ +#endif /* !SDL_BYTEORDER */ + + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \file SDL_endian.h + */ +#if defined(__GNUC__) && defined(__i386__) && \ + !(__GNUC__ == 2 && __GNUC_MINOR__ == 95 /* broken gcc version */) +SDL_FORCE_INLINE Uint16 +SDL_Swap16(Uint16 x) +{ + __asm__("xchgb %b0,%h0": "=q"(x):"0"(x)); + return x; +} +#elif defined(__GNUC__) && defined(__x86_64__) +SDL_FORCE_INLINE Uint16 +SDL_Swap16(Uint16 x) +{ + __asm__("xchgb %b0,%h0": "=Q"(x):"0"(x)); + return x; +} +#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) +SDL_FORCE_INLINE Uint16 +SDL_Swap16(Uint16 x) +{ + int result; + + __asm__("rlwimi %0,%2,8,16,23": "=&r"(result):"0"(x >> 8), "r"(x)); + return (Uint16)result; +} +#elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__) +SDL_FORCE_INLINE Uint16 +SDL_Swap16(Uint16 x) +{ + __asm__("rorw #8,%0": "=d"(x): "0"(x):"cc"); + return x; +} +#elif defined(__WATCOMC__) && defined(__386__) +extern _inline Uint16 SDL_Swap16(Uint16); +#pragma aux SDL_Swap16 = \ + "xchg al, ah" \ + parm [ax] \ + modify [ax]; +#else +SDL_FORCE_INLINE Uint16 +SDL_Swap16(Uint16 x) +{ + return SDL_static_cast(Uint16, ((x << 8) | (x >> 8))); +} +#endif + +#if defined(__GNUC__) && defined(__i386__) +SDL_FORCE_INLINE Uint32 +SDL_Swap32(Uint32 x) +{ + __asm__("bswap %0": "=r"(x):"0"(x)); + return x; +} +#elif defined(__GNUC__) && defined(__x86_64__) +SDL_FORCE_INLINE Uint32 +SDL_Swap32(Uint32 x) +{ + __asm__("bswapl %0": "=r"(x):"0"(x)); + return x; +} +#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) +SDL_FORCE_INLINE Uint32 +SDL_Swap32(Uint32 x) +{ + Uint32 result; + + __asm__("rlwimi %0,%2,24,16,23": "=&r"(result):"0"(x >> 24), "r"(x)); + __asm__("rlwimi %0,%2,8,8,15": "=&r"(result):"0"(result), "r"(x)); + __asm__("rlwimi %0,%2,24,0,7": "=&r"(result):"0"(result), "r"(x)); + return result; +} +#elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__) +SDL_FORCE_INLINE Uint32 +SDL_Swap32(Uint32 x) +{ + __asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0": "=d"(x): "0"(x):"cc"); + return x; +} +#elif defined(__WATCOMC__) && defined(__386__) +extern _inline Uint32 SDL_Swap32(Uint32); +#ifndef __SW_3 /* 486+ */ +#pragma aux SDL_Swap32 = \ + "bswap eax" \ + parm [eax] \ + modify [eax]; +#else /* 386-only */ +#pragma aux SDL_Swap32 = \ + "xchg al, ah" \ + "ror eax, 16" \ + "xchg al, ah" \ + parm [eax] \ + modify [eax]; +#endif +#else +SDL_FORCE_INLINE Uint32 +SDL_Swap32(Uint32 x) +{ + return SDL_static_cast(Uint32, ((x << 24) | ((x << 8) & 0x00FF0000) | + ((x >> 8) & 0x0000FF00) | (x >> 24))); +} +#endif + +#if defined(__GNUC__) && defined(__i386__) +SDL_FORCE_INLINE Uint64 +SDL_Swap64(Uint64 x) +{ + union + { + struct + { + Uint32 a, b; + } s; + Uint64 u; + } v; + v.u = x; + __asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1": "=r"(v.s.a), "=r"(v.s.b):"0"(v.s.a), + "1"(v.s. + b)); + return v.u; +} +#elif defined(__GNUC__) && defined(__x86_64__) +SDL_FORCE_INLINE Uint64 +SDL_Swap64(Uint64 x) +{ + __asm__("bswapq %0": "=r"(x):"0"(x)); + return x; +} +#else +SDL_FORCE_INLINE Uint64 +SDL_Swap64(Uint64 x) +{ + Uint32 hi, lo; + + /* Separate into high and low 32-bit values and swap them */ + lo = SDL_static_cast(Uint32, x & 0xFFFFFFFF); + x >>= 32; + hi = SDL_static_cast(Uint32, x & 0xFFFFFFFF); + x = SDL_Swap32(lo); + x <<= 32; + x |= SDL_Swap32(hi); + return (x); +} +#endif + + +SDL_FORCE_INLINE float +SDL_SwapFloat(float x) +{ + union + { + float f; + Uint32 ui32; + } swapper; + swapper.f = x; + swapper.ui32 = SDL_Swap32(swapper.ui32); + return swapper.f; +} + + +/** + * \name Swap to native + * Byteswap item from the specified endianness to the native endianness. + */ +/* @{ */ +#if SDL_BYTEORDER == SDL_LIL_ENDIAN +#define SDL_SwapLE16(X) (X) +#define SDL_SwapLE32(X) (X) +#define SDL_SwapLE64(X) (X) +#define SDL_SwapFloatLE(X) (X) +#define SDL_SwapBE16(X) SDL_Swap16(X) +#define SDL_SwapBE32(X) SDL_Swap32(X) +#define SDL_SwapBE64(X) SDL_Swap64(X) +#define SDL_SwapFloatBE(X) SDL_SwapFloat(X) +#else +#define SDL_SwapLE16(X) SDL_Swap16(X) +#define SDL_SwapLE32(X) SDL_Swap32(X) +#define SDL_SwapLE64(X) SDL_Swap64(X) +#define SDL_SwapFloatLE(X) SDL_SwapFloat(X) +#define SDL_SwapBE16(X) (X) +#define SDL_SwapBE32(X) (X) +#define SDL_SwapBE64(X) (X) +#define SDL_SwapFloatBE(X) (X) +#endif +/* @} *//* Swap to native */ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_endian_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_error.h b/thirdparty/include/SDL2/SDL_error.h new file mode 100644 index 000000000..aae37c0e4 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_error.h @@ -0,0 +1,76 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_error.h + * + * Simple error message routines for SDL. + */ + +#ifndef SDL_error_h_ +#define SDL_error_h_ + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Public functions */ +/* SDL_SetError() unconditionally returns -1. */ +extern DECLSPEC int SDLCALL SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); +extern DECLSPEC const char *SDLCALL SDL_GetError(void); +extern DECLSPEC void SDLCALL SDL_ClearError(void); + +/** + * \name Internal error functions + * + * \internal + * Private error reporting function - used internally. + */ +/* @{ */ +#define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) +#define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED) +#define SDL_InvalidParamError(param) SDL_SetError("Parameter '%s' is invalid", (param)) +typedef enum +{ + SDL_ENOMEM, + SDL_EFREAD, + SDL_EFWRITE, + SDL_EFSEEK, + SDL_UNSUPPORTED, + SDL_LASTERROR +} SDL_errorcode; +/* SDL_Error() unconditionally returns -1. */ +extern DECLSPEC int SDLCALL SDL_Error(SDL_errorcode code); +/* @} *//* Internal error functions */ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_error_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_events.h b/thirdparty/include/SDL2/SDL_events.h new file mode 100644 index 000000000..32cfbe327 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_events.h @@ -0,0 +1,792 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_events.h + * + * Include file for SDL event handling. + */ + +#ifndef SDL_events_h_ +#define SDL_events_h_ + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_video.h" +#include "SDL_keyboard.h" +#include "SDL_mouse.h" +#include "SDL_joystick.h" +#include "SDL_gamecontroller.h" +#include "SDL_quit.h" +#include "SDL_gesture.h" +#include "SDL_touch.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* General keyboard/mouse state definitions */ +#define SDL_RELEASED 0 +#define SDL_PRESSED 1 + +/** + * \brief The types of events that can be delivered. + */ +typedef enum +{ + SDL_FIRSTEVENT = 0, /**< Unused (do not remove) */ + + /* Application events */ + SDL_QUIT = 0x100, /**< User-requested quit */ + + /* These application events have special meaning on iOS, see README-ios.md for details */ + SDL_APP_TERMINATING, /**< The application is being terminated by the OS + Called on iOS in applicationWillTerminate() + Called on Android in onDestroy() + */ + SDL_APP_LOWMEMORY, /**< The application is low on memory, free memory if possible. + Called on iOS in applicationDidReceiveMemoryWarning() + Called on Android in onLowMemory() + */ + SDL_APP_WILLENTERBACKGROUND, /**< The application is about to enter the background + Called on iOS in applicationWillResignActive() + Called on Android in onPause() + */ + SDL_APP_DIDENTERBACKGROUND, /**< The application did enter the background and may not get CPU for some time + Called on iOS in applicationDidEnterBackground() + Called on Android in onPause() + */ + SDL_APP_WILLENTERFOREGROUND, /**< The application is about to enter the foreground + Called on iOS in applicationWillEnterForeground() + Called on Android in onResume() + */ + SDL_APP_DIDENTERFOREGROUND, /**< The application is now interactive + Called on iOS in applicationDidBecomeActive() + Called on Android in onResume() + */ + + /* Display events */ + SDL_DISPLAYEVENT = 0x150, /**< Display state change */ + + /* Window events */ + SDL_WINDOWEVENT = 0x200, /**< Window state change */ + SDL_SYSWMEVENT, /**< System specific event */ + + /* Keyboard events */ + SDL_KEYDOWN = 0x300, /**< Key pressed */ + SDL_KEYUP, /**< Key released */ + SDL_TEXTEDITING, /**< Keyboard text editing (composition) */ + SDL_TEXTINPUT, /**< Keyboard text input */ + SDL_KEYMAPCHANGED, /**< Keymap changed due to a system event such as an + input language or keyboard layout change. + */ + + /* Mouse events */ + SDL_MOUSEMOTION = 0x400, /**< Mouse moved */ + SDL_MOUSEBUTTONDOWN, /**< Mouse button pressed */ + SDL_MOUSEBUTTONUP, /**< Mouse button released */ + SDL_MOUSEWHEEL, /**< Mouse wheel motion */ + + /* Joystick events */ + SDL_JOYAXISMOTION = 0x600, /**< Joystick axis motion */ + SDL_JOYBALLMOTION, /**< Joystick trackball motion */ + SDL_JOYHATMOTION, /**< Joystick hat position change */ + SDL_JOYBUTTONDOWN, /**< Joystick button pressed */ + SDL_JOYBUTTONUP, /**< Joystick button released */ + SDL_JOYDEVICEADDED, /**< A new joystick has been inserted into the system */ + SDL_JOYDEVICEREMOVED, /**< An opened joystick has been removed */ + + /* Game controller events */ + SDL_CONTROLLERAXISMOTION = 0x650, /**< Game controller axis motion */ + SDL_CONTROLLERBUTTONDOWN, /**< Game controller button pressed */ + SDL_CONTROLLERBUTTONUP, /**< Game controller button released */ + SDL_CONTROLLERDEVICEADDED, /**< A new Game controller has been inserted into the system */ + SDL_CONTROLLERDEVICEREMOVED, /**< An opened Game controller has been removed */ + SDL_CONTROLLERDEVICEREMAPPED, /**< The controller mapping was updated */ + + /* Touch events */ + SDL_FINGERDOWN = 0x700, + SDL_FINGERUP, + SDL_FINGERMOTION, + + /* Gesture events */ + SDL_DOLLARGESTURE = 0x800, + SDL_DOLLARRECORD, + SDL_MULTIGESTURE, + + /* Clipboard events */ + SDL_CLIPBOARDUPDATE = 0x900, /**< The clipboard changed */ + + /* Drag and drop events */ + SDL_DROPFILE = 0x1000, /**< The system requests a file open */ + SDL_DROPTEXT, /**< text/plain drag-and-drop event */ + SDL_DROPBEGIN, /**< A new set of drops is beginning (NULL filename) */ + SDL_DROPCOMPLETE, /**< Current set of drops is now complete (NULL filename) */ + + /* Audio hotplug events */ + SDL_AUDIODEVICEADDED = 0x1100, /**< A new audio device is available */ + SDL_AUDIODEVICEREMOVED, /**< An audio device has been removed. */ + + /* Sensor events */ + SDL_SENSORUPDATE = 0x1200, /**< A sensor was updated */ + + /* Render events */ + SDL_RENDER_TARGETS_RESET = 0x2000, /**< The render targets have been reset and their contents need to be updated */ + SDL_RENDER_DEVICE_RESET, /**< The device has been reset and all textures need to be recreated */ + + /** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use, + * and should be allocated with SDL_RegisterEvents() + */ + SDL_USEREVENT = 0x8000, + + /** + * This last event is only for bounding internal arrays + */ + SDL_LASTEVENT = 0xFFFF +} SDL_EventType; + +/** + * \brief Fields shared by every event + */ +typedef struct SDL_CommonEvent +{ + Uint32 type; + Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ +} SDL_CommonEvent; + +/** + * \brief Display state change event data (event.display.*) + */ +typedef struct SDL_DisplayEvent +{ + Uint32 type; /**< ::SDL_DISPLAYEVENT */ + Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ + Uint32 display; /**< The associated display index */ + Uint8 event; /**< ::SDL_DisplayEventID */ + Uint8 padding1; + Uint8 padding2; + Uint8 padding3; + Sint32 data1; /**< event dependent data */ +} SDL_DisplayEvent; + +/** + * \brief Window state change event data (event.window.*) + */ +typedef struct SDL_WindowEvent +{ + Uint32 type; /**< ::SDL_WINDOWEVENT */ + Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ + Uint32 windowID; /**< The associated window */ + Uint8 event; /**< ::SDL_WindowEventID */ + Uint8 padding1; + Uint8 padding2; + Uint8 padding3; + Sint32 data1; /**< event dependent data */ + Sint32 data2; /**< event dependent data */ +} SDL_WindowEvent; + +/** + * \brief Keyboard button event structure (event.key.*) + */ +typedef struct SDL_KeyboardEvent +{ + Uint32 type; /**< ::SDL_KEYDOWN or ::SDL_KEYUP */ + Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ + Uint32 windowID; /**< The window with keyboard focus, if any */ + Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ + Uint8 repeat; /**< Non-zero if this is a key repeat */ + Uint8 padding2; + Uint8 padding3; + SDL_Keysym keysym; /**< The key that was pressed or released */ +} SDL_KeyboardEvent; + +#define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32) +/** + * \brief Keyboard text editing event structure (event.edit.*) + */ +typedef struct SDL_TextEditingEvent +{ + Uint32 type; /**< ::SDL_TEXTEDITING */ + Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ + Uint32 windowID; /**< The window with keyboard focus, if any */ + char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; /**< The editing text */ + Sint32 start; /**< The start cursor of selected editing text */ + Sint32 length; /**< The length of selected editing text */ +} SDL_TextEditingEvent; + + +#define SDL_TEXTINPUTEVENT_TEXT_SIZE (32) +/** + * \brief Keyboard text input event structure (event.text.*) + */ +typedef struct SDL_TextInputEvent +{ + Uint32 type; /**< ::SDL_TEXTINPUT */ + Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ + Uint32 windowID; /**< The window with keyboard focus, if any */ + char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; /**< The input text */ +} SDL_TextInputEvent; + +/** + * \brief Mouse motion event structure (event.motion.*) + */ +typedef struct SDL_MouseMotionEvent +{ + Uint32 type; /**< ::SDL_MOUSEMOTION */ + Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ + Uint32 windowID; /**< The window with mouse focus, if any */ + Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */ + Uint32 state; /**< The current button state */ + Sint32 x; /**< X coordinate, relative to window */ + Sint32 y; /**< Y coordinate, relative to window */ + Sint32 xrel; /**< The relative motion in the X direction */ + Sint32 yrel; /**< The relative motion in the Y direction */ +} SDL_MouseMotionEvent; + +/** + * \brief Mouse button event structure (event.button.*) + */ +typedef struct SDL_MouseButtonEvent +{ + Uint32 type; /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */ + Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ + Uint32 windowID; /**< The window with mouse focus, if any */ + Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */ + Uint8 button; /**< The mouse button index */ + Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ + Uint8 clicks; /**< 1 for single-click, 2 for double-click, etc. */ + Uint8 padding1; + Sint32 x; /**< X coordinate, relative to window */ + Sint32 y; /**< Y coordinate, relative to window */ +} SDL_MouseButtonEvent; + +/** + * \brief Mouse wheel event structure (event.wheel.*) + */ +typedef struct SDL_MouseWheelEvent +{ + Uint32 type; /**< ::SDL_MOUSEWHEEL */ + Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ + Uint32 windowID; /**< The window with mouse focus, if any */ + Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */ + Sint32 x; /**< The amount scrolled horizontally, positive to the right and negative to the left */ + Sint32 y; /**< The amount scrolled vertically, positive away from the user and negative toward the user */ + Uint32 direction; /**< Set to one of the SDL_MOUSEWHEEL_* defines. When FLIPPED the values in X and Y will be opposite. Multiply by -1 to change them back */ +} SDL_MouseWheelEvent; + +/** + * \brief Joystick axis motion event structure (event.jaxis.*) + */ +typedef struct SDL_JoyAxisEvent +{ + Uint32 type; /**< ::SDL_JOYAXISMOTION */ + Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ + SDL_JoystickID which; /**< The joystick instance id */ + Uint8 axis; /**< The joystick axis index */ + Uint8 padding1; + Uint8 padding2; + Uint8 padding3; + Sint16 value; /**< The axis value (range: -32768 to 32767) */ + Uint16 padding4; +} SDL_JoyAxisEvent; + +/** + * \brief Joystick trackball motion event structure (event.jball.*) + */ +typedef struct SDL_JoyBallEvent +{ + Uint32 type; /**< ::SDL_JOYBALLMOTION */ + Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ + SDL_JoystickID which; /**< The joystick instance id */ + Uint8 ball; /**< The joystick trackball index */ + Uint8 padding1; + Uint8 padding2; + Uint8 padding3; + Sint16 xrel; /**< The relative motion in the X direction */ + Sint16 yrel; /**< The relative motion in the Y direction */ +} SDL_JoyBallEvent; + +/** + * \brief Joystick hat position change event structure (event.jhat.*) + */ +typedef struct SDL_JoyHatEvent +{ + Uint32 type; /**< ::SDL_JOYHATMOTION */ + Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ + SDL_JoystickID which; /**< The joystick instance id */ + Uint8 hat; /**< The joystick hat index */ + Uint8 value; /**< The hat position value. + * \sa ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP + * \sa ::SDL_HAT_LEFT ::SDL_HAT_CENTERED ::SDL_HAT_RIGHT + * \sa ::SDL_HAT_LEFTDOWN ::SDL_HAT_DOWN ::SDL_HAT_RIGHTDOWN + * + * Note that zero means the POV is centered. + */ + Uint8 padding1; + Uint8 padding2; +} SDL_JoyHatEvent; + +/** + * \brief Joystick button event structure (event.jbutton.*) + */ +typedef struct SDL_JoyButtonEvent +{ + Uint32 type; /**< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP */ + Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ + SDL_JoystickID which; /**< The joystick instance id */ + Uint8 button; /**< The joystick button index */ + Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ + Uint8 padding1; + Uint8 padding2; +} SDL_JoyButtonEvent; + +/** + * \brief Joystick device event structure (event.jdevice.*) + */ +typedef struct SDL_JoyDeviceEvent +{ + Uint32 type; /**< ::SDL_JOYDEVICEADDED or ::SDL_JOYDEVICEREMOVED */ + Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ + Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED event */ +} SDL_JoyDeviceEvent; + + +/** + * \brief Game controller axis motion event structure (event.caxis.*) + */ +typedef struct SDL_ControllerAxisEvent +{ + Uint32 type; /**< ::SDL_CONTROLLERAXISMOTION */ + Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ + SDL_JoystickID which; /**< The joystick instance id */ + Uint8 axis; /**< The controller axis (SDL_GameControllerAxis) */ + Uint8 padding1; + Uint8 padding2; + Uint8 padding3; + Sint16 value; /**< The axis value (range: -32768 to 32767) */ + Uint16 padding4; +} SDL_ControllerAxisEvent; + + +/** + * \brief Game controller button event structure (event.cbutton.*) + */ +typedef struct SDL_ControllerButtonEvent +{ + Uint32 type; /**< ::SDL_CONTROLLERBUTTONDOWN or ::SDL_CONTROLLERBUTTONUP */ + Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ + SDL_JoystickID which; /**< The joystick instance id */ + Uint8 button; /**< The controller button (SDL_GameControllerButton) */ + Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ + Uint8 padding1; + Uint8 padding2; +} SDL_ControllerButtonEvent; + + +/** + * \brief Controller device event structure (event.cdevice.*) + */ +typedef struct SDL_ControllerDeviceEvent +{ + Uint32 type; /**< ::SDL_CONTROLLERDEVICEADDED, ::SDL_CONTROLLERDEVICEREMOVED, or ::SDL_CONTROLLERDEVICEREMAPPED */ + Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ + Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event */ +} SDL_ControllerDeviceEvent; + +/** + * \brief Audio device event structure (event.adevice.*) + */ +typedef struct SDL_AudioDeviceEvent +{ + Uint32 type; /**< ::SDL_AUDIODEVICEADDED, or ::SDL_AUDIODEVICEREMOVED */ + Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ + Uint32 which; /**< The audio device index for the ADDED event (valid until next SDL_GetNumAudioDevices() call), SDL_AudioDeviceID for the REMOVED event */ + Uint8 iscapture; /**< zero if an output device, non-zero if a capture device. */ + Uint8 padding1; + Uint8 padding2; + Uint8 padding3; +} SDL_AudioDeviceEvent; + + +/** + * \brief Touch finger event structure (event.tfinger.*) + */ +typedef struct SDL_TouchFingerEvent +{ + Uint32 type; /**< ::SDL_FINGERMOTION or ::SDL_FINGERDOWN or ::SDL_FINGERUP */ + Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ + SDL_TouchID touchId; /**< The touch device id */ + SDL_FingerID fingerId; + float x; /**< Normalized in the range 0...1 */ + float y; /**< Normalized in the range 0...1 */ + float dx; /**< Normalized in the range -1...1 */ + float dy; /**< Normalized in the range -1...1 */ + float pressure; /**< Normalized in the range 0...1 */ + Uint32 windowID; /**< The window underneath the finger, if any */ +} SDL_TouchFingerEvent; + + +/** + * \brief Multiple Finger Gesture Event (event.mgesture.*) + */ +typedef struct SDL_MultiGestureEvent +{ + Uint32 type; /**< ::SDL_MULTIGESTURE */ + Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ + SDL_TouchID touchId; /**< The touch device id */ + float dTheta; + float dDist; + float x; + float y; + Uint16 numFingers; + Uint16 padding; +} SDL_MultiGestureEvent; + + +/** + * \brief Dollar Gesture Event (event.dgesture.*) + */ +typedef struct SDL_DollarGestureEvent +{ + Uint32 type; /**< ::SDL_DOLLARGESTURE or ::SDL_DOLLARRECORD */ + Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ + SDL_TouchID touchId; /**< The touch device id */ + SDL_GestureID gestureId; + Uint32 numFingers; + float error; + float x; /**< Normalized center of gesture */ + float y; /**< Normalized center of gesture */ +} SDL_DollarGestureEvent; + + +/** + * \brief An event used to request a file open by the system (event.drop.*) + * This event is enabled by default, you can disable it with SDL_EventState(). + * \note If this event is enabled, you must free the filename in the event. + */ +typedef struct SDL_DropEvent +{ + Uint32 type; /**< ::SDL_DROPBEGIN or ::SDL_DROPFILE or ::SDL_DROPTEXT or ::SDL_DROPCOMPLETE */ + Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ + char *file; /**< The file name, which should be freed with SDL_free(), is NULL on begin/complete */ + Uint32 windowID; /**< The window that was dropped on, if any */ +} SDL_DropEvent; + + +/** + * \brief Sensor event structure (event.sensor.*) + */ +typedef struct SDL_SensorEvent +{ + Uint32 type; /**< ::SDL_SENSORUPDATE */ + Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ + Sint32 which; /**< The instance ID of the sensor */ + float data[6]; /**< Up to 6 values from the sensor - additional values can be queried using SDL_SensorGetData() */ +} SDL_SensorEvent; + +/** + * \brief The "quit requested" event + */ +typedef struct SDL_QuitEvent +{ + Uint32 type; /**< ::SDL_QUIT */ + Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ +} SDL_QuitEvent; + +/** + * \brief OS Specific event + */ +typedef struct SDL_OSEvent +{ + Uint32 type; /**< ::SDL_QUIT */ + Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ +} SDL_OSEvent; + +/** + * \brief A user-defined event type (event.user.*) + */ +typedef struct SDL_UserEvent +{ + Uint32 type; /**< ::SDL_USEREVENT through ::SDL_LASTEVENT-1 */ + Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ + Uint32 windowID; /**< The associated window if any */ + Sint32 code; /**< User defined event code */ + void *data1; /**< User defined data pointer */ + void *data2; /**< User defined data pointer */ +} SDL_UserEvent; + + +struct SDL_SysWMmsg; +typedef struct SDL_SysWMmsg SDL_SysWMmsg; + +/** + * \brief A video driver dependent system event (event.syswm.*) + * This event is disabled by default, you can enable it with SDL_EventState() + * + * \note If you want to use this event, you should include SDL_syswm.h. + */ +typedef struct SDL_SysWMEvent +{ + Uint32 type; /**< ::SDL_SYSWMEVENT */ + Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ + SDL_SysWMmsg *msg; /**< driver dependent data, defined in SDL_syswm.h */ +} SDL_SysWMEvent; + +/** + * \brief General event structure + */ +typedef union SDL_Event +{ + Uint32 type; /**< Event type, shared with all events */ + SDL_CommonEvent common; /**< Common event data */ + SDL_DisplayEvent display; /**< Display event data */ + SDL_WindowEvent window; /**< Window event data */ + SDL_KeyboardEvent key; /**< Keyboard event data */ + SDL_TextEditingEvent edit; /**< Text editing event data */ + SDL_TextInputEvent text; /**< Text input event data */ + SDL_MouseMotionEvent motion; /**< Mouse motion event data */ + SDL_MouseButtonEvent button; /**< Mouse button event data */ + SDL_MouseWheelEvent wheel; /**< Mouse wheel event data */ + SDL_JoyAxisEvent jaxis; /**< Joystick axis event data */ + SDL_JoyBallEvent jball; /**< Joystick ball event data */ + SDL_JoyHatEvent jhat; /**< Joystick hat event data */ + SDL_JoyButtonEvent jbutton; /**< Joystick button event data */ + SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */ + SDL_ControllerAxisEvent caxis; /**< Game Controller axis event data */ + SDL_ControllerButtonEvent cbutton; /**< Game Controller button event data */ + SDL_ControllerDeviceEvent cdevice; /**< Game Controller device event data */ + SDL_AudioDeviceEvent adevice; /**< Audio device event data */ + SDL_SensorEvent sensor; /**< Sensor event data */ + SDL_QuitEvent quit; /**< Quit request event data */ + SDL_UserEvent user; /**< Custom event data */ + SDL_SysWMEvent syswm; /**< System dependent window event data */ + SDL_TouchFingerEvent tfinger; /**< Touch finger event data */ + SDL_MultiGestureEvent mgesture; /**< Gesture event data */ + SDL_DollarGestureEvent dgesture; /**< Gesture event data */ + SDL_DropEvent drop; /**< Drag and drop event data */ + + /* This is necessary for ABI compatibility between Visual C++ and GCC + Visual C++ will respect the push pack pragma and use 52 bytes for + this structure, and GCC will use the alignment of the largest datatype + within the union, which is 8 bytes. + + So... we'll add padding to force the size to be 56 bytes for both. + */ + Uint8 padding[56]; +} SDL_Event; + +/* Make sure we haven't broken binary compatibility */ +SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event) == 56); + + +/* Function prototypes */ + +/** + * Pumps the event loop, gathering events from the input devices. + * + * This function updates the event queue and internal input device state. + * + * This should only be run in the thread that sets the video mode. + */ +extern DECLSPEC void SDLCALL SDL_PumpEvents(void); + +/* @{ */ +typedef enum +{ + SDL_ADDEVENT, + SDL_PEEKEVENT, + SDL_GETEVENT +} SDL_eventaction; + +/** + * Checks the event queue for messages and optionally returns them. + * + * If \c action is ::SDL_ADDEVENT, up to \c numevents events will be added to + * the back of the event queue. + * + * If \c action is ::SDL_PEEKEVENT, up to \c numevents events at the front + * of the event queue, within the specified minimum and maximum type, + * will be returned and will not be removed from the queue. + * + * If \c action is ::SDL_GETEVENT, up to \c numevents events at the front + * of the event queue, within the specified minimum and maximum type, + * will be returned and will be removed from the queue. + * + * \return The number of events actually stored, or -1 if there was an error. + * + * This function is thread-safe. + */ +extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents, + SDL_eventaction action, + Uint32 minType, Uint32 maxType); +/* @} */ + +/** + * Checks to see if certain event types are in the event queue. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 type); +extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType); + +/** + * This function clears events from the event queue + * This function only affects currently queued events. If you want to make + * sure that all pending OS events are flushed, you can call SDL_PumpEvents() + * on the main thread immediately before the flush call. + */ +extern DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type); +extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType); + +/** + * \brief Polls for currently pending events. + * + * \return 1 if there are any pending events, or 0 if there are none available. + * + * \param event If not NULL, the next event is removed from the queue and + * stored in that area. + */ +extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event * event); + +/** + * \brief Waits indefinitely for the next available event. + * + * \return 1, or 0 if there was an error while waiting for events. + * + * \param event If not NULL, the next event is removed from the queue and + * stored in that area. + */ +extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event * event); + +/** + * \brief Waits until the specified timeout (in milliseconds) for the next + * available event. + * + * \return 1, or 0 if there was an error while waiting for events. + * + * \param event If not NULL, the next event is removed from the queue and + * stored in that area. + * \param timeout The timeout (in milliseconds) to wait for next event. + */ +extern DECLSPEC int SDLCALL SDL_WaitEventTimeout(SDL_Event * event, + int timeout); + +/** + * \brief Add an event to the event queue. + * + * \return 1 on success, 0 if the event was filtered, or -1 if the event queue + * was full or there was some other error. + */ +extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event * event); + +typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event); + +/** + * Sets up a filter to process all events before they change internal state and + * are posted to the internal event queue. + * + * The filter is prototyped as: + * \code + * int SDL_EventFilter(void *userdata, SDL_Event * event); + * \endcode + * + * If the filter returns 1, then the event will be added to the internal queue. + * If it returns 0, then the event will be dropped from the queue, but the + * internal state will still be updated. This allows selective filtering of + * dynamically arriving events. + * + * \warning Be very careful of what you do in the event filter function, as + * it may run in a different thread! + * + * There is one caveat when dealing with the ::SDL_QuitEvent event type. The + * event filter is only called when the window manager desires to close the + * application window. If the event filter returns 1, then the window will + * be closed, otherwise the window will remain open if possible. + * + * If the quit event is generated by an interrupt signal, it will bypass the + * internal queue and be delivered to the application at the next event poll. + */ +extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter, + void *userdata); + +/** + * Return the current event filter - can be used to "chain" filters. + * If there is no event filter set, this function returns SDL_FALSE. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter * filter, + void **userdata); + +/** + * Add a function which is called when an event is added to the queue. + */ +extern DECLSPEC void SDLCALL SDL_AddEventWatch(SDL_EventFilter filter, + void *userdata); + +/** + * Remove an event watch function added with SDL_AddEventWatch() + */ +extern DECLSPEC void SDLCALL SDL_DelEventWatch(SDL_EventFilter filter, + void *userdata); + +/** + * Run the filter function on the current event queue, removing any + * events for which the filter returns 0. + */ +extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter, + void *userdata); + +/* @{ */ +#define SDL_QUERY -1 +#define SDL_IGNORE 0 +#define SDL_DISABLE 0 +#define SDL_ENABLE 1 + +/** + * This function allows you to set the state of processing certain events. + * - If \c state is set to ::SDL_IGNORE, that event will be automatically + * dropped from the event queue and will not be filtered. + * - If \c state is set to ::SDL_ENABLE, that event will be processed + * normally. + * - If \c state is set to ::SDL_QUERY, SDL_EventState() will return the + * current processing state of the specified event. + */ +extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state); +/* @} */ +#define SDL_GetEventState(type) SDL_EventState(type, SDL_QUERY) + +/** + * This function allocates a set of user-defined events, and returns + * the beginning event number for that set of events. + * + * If there aren't enough user-defined events left, this function + * returns (Uint32)-1 + */ +extern DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_events_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_filesystem.h b/thirdparty/include/SDL2/SDL_filesystem.h new file mode 100644 index 000000000..68042b60f --- /dev/null +++ b/thirdparty/include/SDL2/SDL_filesystem.h @@ -0,0 +1,136 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_filesystem.h + * + * \brief Include file for filesystem SDL API functions + */ + +#ifndef SDL_filesystem_h_ +#define SDL_filesystem_h_ + +#include "SDL_stdinc.h" + +#include "begin_code.h" + +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Get the path where the application resides. + * + * Get the "base path". This is the directory where the application was run + * from, which is probably the installation directory, and may or may not + * be the process's current working directory. + * + * This returns an absolute path in UTF-8 encoding, and is guaranteed to + * end with a path separator ('\\' on Windows, '/' most other places). + * + * The pointer returned by this function is owned by you. Please call + * SDL_free() on the pointer when you are done with it, or it will be a + * memory leak. This is not necessarily a fast call, though, so you should + * call this once near startup and save the string if you need it. + * + * Some platforms can't determine the application's path, and on other + * platforms, this might be meaningless. In such cases, this function will + * return NULL. + * + * \return String of base dir in UTF-8 encoding, or NULL on error. + * + * \sa SDL_GetPrefPath + */ +extern DECLSPEC char *SDLCALL SDL_GetBasePath(void); + +/** + * \brief Get the user-and-app-specific path where files can be written. + * + * Get the "pref dir". This is meant to be where users can write personal + * files (preferences and save games, etc) that are specific to your + * application. This directory is unique per user, per application. + * + * This function will decide the appropriate location in the native filesystem, + * create the directory if necessary, and return a string of the absolute + * path to the directory in UTF-8 encoding. + * + * On Windows, the string might look like: + * "C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name\\" + * + * On Linux, the string might look like: + * "/home/bob/.local/share/My Program Name/" + * + * On Mac OS X, the string might look like: + * "/Users/bob/Library/Application Support/My Program Name/" + * + * (etc.) + * + * You specify the name of your organization (if it's not a real organization, + * your name or an Internet domain you own might do) and the name of your + * application. These should be untranslated proper names. + * + * Both the org and app strings may become part of a directory name, so + * please follow these rules: + * + * - Try to use the same org string (including case-sensitivity) for + * all your applications that use this function. + * - Always use a unique app string for each one, and make sure it never + * changes for an app once you've decided on it. + * - Unicode characters are legal, as long as it's UTF-8 encoded, but... + * - ...only use letters, numbers, and spaces. Avoid punctuation like + * "Game Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient. + * + * This returns an absolute path in UTF-8 encoding, and is guaranteed to + * end with a path separator ('\\' on Windows, '/' most other places). + * + * The pointer returned by this function is owned by you. Please call + * SDL_free() on the pointer when you are done with it, or it will be a + * memory leak. This is not necessarily a fast call, though, so you should + * call this once near startup and save the string if you need it. + * + * You should assume the path returned by this function is the only safe + * place to write files (and that SDL_GetBasePath(), while it might be + * writable, or even the parent of the returned path, aren't where you + * should be writing things). + * + * Some platforms can't determine the pref path, and on other + * platforms, this might be meaningless. In such cases, this function will + * return NULL. + * + * \param org The name of your organization. + * \param app The name of your application. + * \return UTF-8 string of user dir in platform-dependent notation. NULL + * if there's a problem (creating directory failed, etc). + * + * \sa SDL_GetBasePath + */ +extern DECLSPEC char *SDLCALL SDL_GetPrefPath(const char *org, const char *app); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_filesystem_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_gamecontroller.h b/thirdparty/include/SDL2/SDL_gamecontroller.h new file mode 100644 index 000000000..21cc1e437 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_gamecontroller.h @@ -0,0 +1,420 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_gamecontroller.h + * + * Include file for SDL game controller event handling + */ + +#ifndef SDL_gamecontroller_h_ +#define SDL_gamecontroller_h_ + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_rwops.h" +#include "SDL_joystick.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \file SDL_gamecontroller.h + * + * In order to use these functions, SDL_Init() must have been called + * with the ::SDL_INIT_GAMECONTROLLER flag. This causes SDL to scan the system + * for game controllers, and load appropriate drivers. + * + * If you would like to receive controller updates while the application + * is in the background, you should set the following hint before calling + * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS + */ + +/** + * The gamecontroller structure used to identify an SDL game controller + */ +struct _SDL_GameController; +typedef struct _SDL_GameController SDL_GameController; + +typedef enum +{ + SDL_CONTROLLER_TYPE_UNKNOWN = 0, + SDL_CONTROLLER_TYPE_XBOX360, + SDL_CONTROLLER_TYPE_XBOXONE, + SDL_CONTROLLER_TYPE_PS3, + SDL_CONTROLLER_TYPE_PS4, + SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO +} SDL_GameControllerType; + +typedef enum +{ + SDL_CONTROLLER_BINDTYPE_NONE = 0, + SDL_CONTROLLER_BINDTYPE_BUTTON, + SDL_CONTROLLER_BINDTYPE_AXIS, + SDL_CONTROLLER_BINDTYPE_HAT +} SDL_GameControllerBindType; + +/** + * Get the SDL joystick layer binding for this controller button/axis mapping + */ +typedef struct SDL_GameControllerButtonBind +{ + SDL_GameControllerBindType bindType; + union + { + int button; + int axis; + struct { + int hat; + int hat_mask; + } hat; + } value; + +} SDL_GameControllerButtonBind; + + +/** + * To count the number of game controllers in the system for the following: + * int nJoysticks = SDL_NumJoysticks(); + * int nGameControllers = 0; + * for (int i = 0; i < nJoysticks; i++) { + * if (SDL_IsGameController(i)) { + * nGameControllers++; + * } + * } + * + * Using the SDL_HINT_GAMECONTROLLERCONFIG hint or the SDL_GameControllerAddMapping() you can add support for controllers SDL is unaware of or cause an existing controller to have a different binding. The format is: + * guid,name,mappings + * + * Where GUID is the string value from SDL_JoystickGetGUIDString(), name is the human readable string for the device and mappings are controller mappings to joystick ones. + * Under Windows there is a reserved GUID of "xinput" that covers any XInput devices. + * The mapping format for joystick is: + * bX - a joystick button, index X + * hX.Y - hat X with value Y + * aX - axis X of the joystick + * Buttons can be used as a controller axis and vice versa. + * + * This string shows an example of a valid mapping for a controller + * "03000000341a00003608000000000000,PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7", + * + */ + +/** + * Load a set of mappings from a seekable SDL data stream (memory or file), filtered by the current SDL_GetPlatform() + * A community sourced database of controllers is available at https://raw.github.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt + * + * If \c freerw is non-zero, the stream will be closed after being read. + * + * \return number of mappings added, -1 on error + */ +extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw, int freerw); + +/** + * Load a set of mappings from a file, filtered by the current SDL_GetPlatform() + * + * Convenience macro. + */ +#define SDL_GameControllerAddMappingsFromFile(file) SDL_GameControllerAddMappingsFromRW(SDL_RWFromFile(file, "rb"), 1) + +/** + * Add or update an existing mapping configuration + * + * \return 1 if mapping is added, 0 if updated, -1 on error + */ +extern DECLSPEC int SDLCALL SDL_GameControllerAddMapping(const char* mappingString); + +/** + * Get the number of mappings installed + * + * \return the number of mappings + */ +extern DECLSPEC int SDLCALL SDL_GameControllerNumMappings(void); + +/** + * Get the mapping at a particular index. + * + * \return the mapping string. Must be freed with SDL_free(). Returns NULL if the index is out of range. + */ +extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForIndex(int mapping_index); + +/** + * Get a mapping string for a GUID + * + * \return the mapping string. Must be freed with SDL_free(). Returns NULL if no mapping is available + */ +extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForGUID(SDL_JoystickGUID guid); + +/** + * Get a mapping string for an open GameController + * + * \return the mapping string. Must be freed with SDL_free(). Returns NULL if no mapping is available + */ +extern DECLSPEC char * SDLCALL SDL_GameControllerMapping(SDL_GameController * gamecontroller); + +/** + * Is the joystick on this index supported by the game controller interface? + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IsGameController(int joystick_index); + +/** + * Get the implementation dependent name of a game controller. + * This can be called before any controllers are opened. + * If no name can be found, this function returns NULL. + */ +extern DECLSPEC const char *SDLCALL SDL_GameControllerNameForIndex(int joystick_index); + +/** + * Get the type of a game controller. + * This can be called before any controllers are opened. + */ +extern DECLSPEC SDL_GameControllerType SDLCALL SDL_GameControllerTypeForIndex(int joystick_index); + +/** + * Get the mapping of a game controller. + * This can be called before any controllers are opened. + * + * \return the mapping string. Must be freed with SDL_free(). Returns NULL if no mapping is available + */ +extern DECLSPEC char *SDLCALL SDL_GameControllerMappingForDeviceIndex(int joystick_index); + +/** + * Open a game controller for use. + * The index passed as an argument refers to the N'th game controller on the system. + * This index is not the value which will identify this controller in future + * controller events. The joystick's instance id (::SDL_JoystickID) will be + * used there instead. + * + * \return A controller identifier, or NULL if an error occurred. + */ +extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerOpen(int joystick_index); + +/** + * Return the SDL_GameController associated with an instance id. + */ +extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromInstanceID(SDL_JoystickID joyid); + +/** + * Return the SDL_GameController associated with a player index. + */ +extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromPlayerIndex(int player_index); + +/** + * Return the name for this currently opened controller + */ +extern DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *gamecontroller); + +/** + * Return the type of this currently opened controller + */ +extern DECLSPEC SDL_GameControllerType SDLCALL SDL_GameControllerGetType(SDL_GameController *gamecontroller); + +/** + * Get the player index of an opened game controller, or -1 if it's not available + * + * For XInput controllers this returns the XInput user index. + */ +extern DECLSPEC int SDLCALL SDL_GameControllerGetPlayerIndex(SDL_GameController *gamecontroller); + +/** + * Set the player index of an opened game controller + */ +extern DECLSPEC void SDLCALL SDL_GameControllerSetPlayerIndex(SDL_GameController *gamecontroller, int player_index); + +/** + * Get the USB vendor ID of an opened controller, if available. + * If the vendor ID isn't available this function returns 0. + */ +extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetVendor(SDL_GameController * gamecontroller); + +/** + * Get the USB product ID of an opened controller, if available. + * If the product ID isn't available this function returns 0. + */ +extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProduct(SDL_GameController * gamecontroller); + +/** + * Get the product version of an opened controller, if available. + * If the product version isn't available this function returns 0. + */ +extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProductVersion(SDL_GameController * gamecontroller); + +/** + * Returns SDL_TRUE if the controller has been opened and currently connected, + * or SDL_FALSE if it has not. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerGetAttached(SDL_GameController *gamecontroller); + +/** + * Get the underlying joystick object used by a controller + */ +extern DECLSPEC SDL_Joystick *SDLCALL SDL_GameControllerGetJoystick(SDL_GameController *gamecontroller); + +/** + * Enable/disable controller event polling. + * + * If controller events are disabled, you must call SDL_GameControllerUpdate() + * yourself and check the state of the controller when you want controller + * information. + * + * The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE. + */ +extern DECLSPEC int SDLCALL SDL_GameControllerEventState(int state); + +/** + * Update the current state of the open game controllers. + * + * This is called automatically by the event loop if any game controller + * events are enabled. + */ +extern DECLSPEC void SDLCALL SDL_GameControllerUpdate(void); + + +/** + * The list of axes available from a controller + * + * Thumbstick axis values range from SDL_JOYSTICK_AXIS_MIN to SDL_JOYSTICK_AXIS_MAX, + * and are centered within ~8000 of zero, though advanced UI will allow users to set + * or autodetect the dead zone, which varies between controllers. + * + * Trigger axis values range from 0 to SDL_JOYSTICK_AXIS_MAX. + */ +typedef enum +{ + SDL_CONTROLLER_AXIS_INVALID = -1, + SDL_CONTROLLER_AXIS_LEFTX, + SDL_CONTROLLER_AXIS_LEFTY, + SDL_CONTROLLER_AXIS_RIGHTX, + SDL_CONTROLLER_AXIS_RIGHTY, + SDL_CONTROLLER_AXIS_TRIGGERLEFT, + SDL_CONTROLLER_AXIS_TRIGGERRIGHT, + SDL_CONTROLLER_AXIS_MAX +} SDL_GameControllerAxis; + +/** + * turn this string into a axis mapping + */ +extern DECLSPEC SDL_GameControllerAxis SDLCALL SDL_GameControllerGetAxisFromString(const char *pchString); + +/** + * turn this axis enum into a string mapping + */ +extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForAxis(SDL_GameControllerAxis axis); + +/** + * Get the SDL joystick layer binding for this controller button mapping + */ +extern DECLSPEC SDL_GameControllerButtonBind SDLCALL +SDL_GameControllerGetBindForAxis(SDL_GameController *gamecontroller, + SDL_GameControllerAxis axis); + +/** + * Get the current state of an axis control on a game controller. + * + * The state is a value ranging from -32768 to 32767 (except for the triggers, + * which range from 0 to 32767). + * + * The axis indices start at index 0. + */ +extern DECLSPEC Sint16 SDLCALL +SDL_GameControllerGetAxis(SDL_GameController *gamecontroller, + SDL_GameControllerAxis axis); + +/** + * The list of buttons available from a controller + */ +typedef enum +{ + SDL_CONTROLLER_BUTTON_INVALID = -1, + SDL_CONTROLLER_BUTTON_A, + SDL_CONTROLLER_BUTTON_B, + SDL_CONTROLLER_BUTTON_X, + SDL_CONTROLLER_BUTTON_Y, + SDL_CONTROLLER_BUTTON_BACK, + SDL_CONTROLLER_BUTTON_GUIDE, + SDL_CONTROLLER_BUTTON_START, + SDL_CONTROLLER_BUTTON_LEFTSTICK, + SDL_CONTROLLER_BUTTON_RIGHTSTICK, + SDL_CONTROLLER_BUTTON_LEFTSHOULDER, + SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, + SDL_CONTROLLER_BUTTON_DPAD_UP, + SDL_CONTROLLER_BUTTON_DPAD_DOWN, + SDL_CONTROLLER_BUTTON_DPAD_LEFT, + SDL_CONTROLLER_BUTTON_DPAD_RIGHT, + SDL_CONTROLLER_BUTTON_MAX +} SDL_GameControllerButton; + +/** + * turn this string into a button mapping + */ +extern DECLSPEC SDL_GameControllerButton SDLCALL SDL_GameControllerGetButtonFromString(const char *pchString); + +/** + * turn this button enum into a string mapping + */ +extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForButton(SDL_GameControllerButton button); + +/** + * Get the SDL joystick layer binding for this controller button mapping + */ +extern DECLSPEC SDL_GameControllerButtonBind SDLCALL +SDL_GameControllerGetBindForButton(SDL_GameController *gamecontroller, + SDL_GameControllerButton button); + + +/** + * Get the current state of a button on a game controller. + * + * The button indices start at index 0. + */ +extern DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController *gamecontroller, + SDL_GameControllerButton button); + +/** + * Trigger a rumble effect + * Each call to this function cancels any previous rumble effect, and calling it with 0 intensity stops any rumbling. + * + * \param gamecontroller The controller to vibrate + * \param low_frequency_rumble The intensity of the low frequency (left) rumble motor, from 0 to 0xFFFF + * \param high_frequency_rumble The intensity of the high frequency (right) rumble motor, from 0 to 0xFFFF + * \param duration_ms The duration of the rumble effect, in milliseconds + * + * \return 0, or -1 if rumble isn't supported on this joystick + */ +extern DECLSPEC int SDLCALL SDL_GameControllerRumble(SDL_GameController *gamecontroller, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms); + +/** + * Close a controller previously opened with SDL_GameControllerOpen(). + */ +extern DECLSPEC void SDLCALL SDL_GameControllerClose(SDL_GameController *gamecontroller); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_gamecontroller_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_gesture.h b/thirdparty/include/SDL2/SDL_gesture.h new file mode 100644 index 000000000..81ed43173 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_gesture.h @@ -0,0 +1,87 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_gesture.h + * + * Include file for SDL gesture event handling. + */ + +#ifndef SDL_gesture_h_ +#define SDL_gesture_h_ + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_video.h" + +#include "SDL_touch.h" + + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +typedef Sint64 SDL_GestureID; + +/* Function prototypes */ + +/** + * \brief Begin Recording a gesture on the specified touch, or all touches (-1) + * + * + */ +extern DECLSPEC int SDLCALL SDL_RecordGesture(SDL_TouchID touchId); + + +/** + * \brief Save all currently loaded Dollar Gesture templates + * + * + */ +extern DECLSPEC int SDLCALL SDL_SaveAllDollarTemplates(SDL_RWops *dst); + +/** + * \brief Save a currently loaded Dollar Gesture template + * + * + */ +extern DECLSPEC int SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_RWops *dst); + + +/** + * \brief Load Dollar Gesture templates from a file + * + * + */ +extern DECLSPEC int SDLCALL SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_gesture_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_haptic.h b/thirdparty/include/SDL2/SDL_haptic.h new file mode 100644 index 000000000..aa6f47fdd --- /dev/null +++ b/thirdparty/include/SDL2/SDL_haptic.h @@ -0,0 +1,1238 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_haptic.h + * + * \brief The SDL haptic subsystem allows you to control haptic (force feedback) + * devices. + * + * The basic usage is as follows: + * - Initialize the subsystem (::SDL_INIT_HAPTIC). + * - Open a haptic device. + * - SDL_HapticOpen() to open from index. + * - SDL_HapticOpenFromJoystick() to open from an existing joystick. + * - Create an effect (::SDL_HapticEffect). + * - Upload the effect with SDL_HapticNewEffect(). + * - Run the effect with SDL_HapticRunEffect(). + * - (optional) Free the effect with SDL_HapticDestroyEffect(). + * - Close the haptic device with SDL_HapticClose(). + * + * \par Simple rumble example: + * \code + * SDL_Haptic *haptic; + * + * // Open the device + * haptic = SDL_HapticOpen( 0 ); + * if (haptic == NULL) + * return -1; + * + * // Initialize simple rumble + * if (SDL_HapticRumbleInit( haptic ) != 0) + * return -1; + * + * // Play effect at 50% strength for 2 seconds + * if (SDL_HapticRumblePlay( haptic, 0.5, 2000 ) != 0) + * return -1; + * SDL_Delay( 2000 ); + * + * // Clean up + * SDL_HapticClose( haptic ); + * \endcode + * + * \par Complete example: + * \code + * int test_haptic( SDL_Joystick * joystick ) { + * SDL_Haptic *haptic; + * SDL_HapticEffect effect; + * int effect_id; + * + * // Open the device + * haptic = SDL_HapticOpenFromJoystick( joystick ); + * if (haptic == NULL) return -1; // Most likely joystick isn't haptic + * + * // See if it can do sine waves + * if ((SDL_HapticQuery(haptic) & SDL_HAPTIC_SINE)==0) { + * SDL_HapticClose(haptic); // No sine effect + * return -1; + * } + * + * // Create the effect + * memset( &effect, 0, sizeof(SDL_HapticEffect) ); // 0 is safe default + * effect.type = SDL_HAPTIC_SINE; + * effect.periodic.direction.type = SDL_HAPTIC_POLAR; // Polar coordinates + * effect.periodic.direction.dir[0] = 18000; // Force comes from south + * effect.periodic.period = 1000; // 1000 ms + * effect.periodic.magnitude = 20000; // 20000/32767 strength + * effect.periodic.length = 5000; // 5 seconds long + * effect.periodic.attack_length = 1000; // Takes 1 second to get max strength + * effect.periodic.fade_length = 1000; // Takes 1 second to fade away + * + * // Upload the effect + * effect_id = SDL_HapticNewEffect( haptic, &effect ); + * + * // Test the effect + * SDL_HapticRunEffect( haptic, effect_id, 1 ); + * SDL_Delay( 5000); // Wait for the effect to finish + * + * // We destroy the effect, although closing the device also does this + * SDL_HapticDestroyEffect( haptic, effect_id ); + * + * // Close the device + * SDL_HapticClose(haptic); + * + * return 0; // Success + * } + * \endcode + */ + +#ifndef SDL_haptic_h_ +#define SDL_haptic_h_ + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_joystick.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* FIXME: For SDL 2.1, adjust all the magnitude variables to be Uint16 (0xFFFF). + * + * At the moment the magnitude variables are mixed between signed/unsigned, and + * it is also not made clear that ALL of those variables expect a max of 0x7FFF. + * + * Some platforms may have higher precision than that (Linux FF, Windows XInput) + * so we should fix the inconsistency in favor of higher possible precision, + * adjusting for platforms that use different scales. + * -flibit + */ + +/** + * \typedef SDL_Haptic + * + * \brief The haptic structure used to identify an SDL haptic. + * + * \sa SDL_HapticOpen + * \sa SDL_HapticOpenFromJoystick + * \sa SDL_HapticClose + */ +struct _SDL_Haptic; +typedef struct _SDL_Haptic SDL_Haptic; + + +/** + * \name Haptic features + * + * Different haptic features a device can have. + */ +/* @{ */ + +/** + * \name Haptic effects + */ +/* @{ */ + +/** + * \brief Constant effect supported. + * + * Constant haptic effect. + * + * \sa SDL_HapticCondition + */ +#define SDL_HAPTIC_CONSTANT (1u<<0) + +/** + * \brief Sine wave effect supported. + * + * Periodic haptic effect that simulates sine waves. + * + * \sa SDL_HapticPeriodic + */ +#define SDL_HAPTIC_SINE (1u<<1) + +/** + * \brief Left/Right effect supported. + * + * Haptic effect for direct control over high/low frequency motors. + * + * \sa SDL_HapticLeftRight + * \warning this value was SDL_HAPTIC_SQUARE right before 2.0.0 shipped. Sorry, + * we ran out of bits, and this is important for XInput devices. + */ +#define SDL_HAPTIC_LEFTRIGHT (1u<<2) + +/* !!! FIXME: put this back when we have more bits in 2.1 */ +/* #define SDL_HAPTIC_SQUARE (1<<2) */ + +/** + * \brief Triangle wave effect supported. + * + * Periodic haptic effect that simulates triangular waves. + * + * \sa SDL_HapticPeriodic + */ +#define SDL_HAPTIC_TRIANGLE (1u<<3) + +/** + * \brief Sawtoothup wave effect supported. + * + * Periodic haptic effect that simulates saw tooth up waves. + * + * \sa SDL_HapticPeriodic + */ +#define SDL_HAPTIC_SAWTOOTHUP (1u<<4) + +/** + * \brief Sawtoothdown wave effect supported. + * + * Periodic haptic effect that simulates saw tooth down waves. + * + * \sa SDL_HapticPeriodic + */ +#define SDL_HAPTIC_SAWTOOTHDOWN (1u<<5) + +/** + * \brief Ramp effect supported. + * + * Ramp haptic effect. + * + * \sa SDL_HapticRamp + */ +#define SDL_HAPTIC_RAMP (1u<<6) + +/** + * \brief Spring effect supported - uses axes position. + * + * Condition haptic effect that simulates a spring. Effect is based on the + * axes position. + * + * \sa SDL_HapticCondition + */ +#define SDL_HAPTIC_SPRING (1u<<7) + +/** + * \brief Damper effect supported - uses axes velocity. + * + * Condition haptic effect that simulates dampening. Effect is based on the + * axes velocity. + * + * \sa SDL_HapticCondition + */ +#define SDL_HAPTIC_DAMPER (1u<<8) + +/** + * \brief Inertia effect supported - uses axes acceleration. + * + * Condition haptic effect that simulates inertia. Effect is based on the axes + * acceleration. + * + * \sa SDL_HapticCondition + */ +#define SDL_HAPTIC_INERTIA (1u<<9) + +/** + * \brief Friction effect supported - uses axes movement. + * + * Condition haptic effect that simulates friction. Effect is based on the + * axes movement. + * + * \sa SDL_HapticCondition + */ +#define SDL_HAPTIC_FRICTION (1u<<10) + +/** + * \brief Custom effect is supported. + * + * User defined custom haptic effect. + */ +#define SDL_HAPTIC_CUSTOM (1u<<11) + +/* @} *//* Haptic effects */ + +/* These last few are features the device has, not effects */ + +/** + * \brief Device can set global gain. + * + * Device supports setting the global gain. + * + * \sa SDL_HapticSetGain + */ +#define SDL_HAPTIC_GAIN (1u<<12) + +/** + * \brief Device can set autocenter. + * + * Device supports setting autocenter. + * + * \sa SDL_HapticSetAutocenter + */ +#define SDL_HAPTIC_AUTOCENTER (1u<<13) + +/** + * \brief Device can be queried for effect status. + * + * Device supports querying effect status. + * + * \sa SDL_HapticGetEffectStatus + */ +#define SDL_HAPTIC_STATUS (1u<<14) + +/** + * \brief Device can be paused. + * + * Devices supports being paused. + * + * \sa SDL_HapticPause + * \sa SDL_HapticUnpause + */ +#define SDL_HAPTIC_PAUSE (1u<<15) + + +/** + * \name Direction encodings + */ +/* @{ */ + +/** + * \brief Uses polar coordinates for the direction. + * + * \sa SDL_HapticDirection + */ +#define SDL_HAPTIC_POLAR 0 + +/** + * \brief Uses cartesian coordinates for the direction. + * + * \sa SDL_HapticDirection + */ +#define SDL_HAPTIC_CARTESIAN 1 + +/** + * \brief Uses spherical coordinates for the direction. + * + * \sa SDL_HapticDirection + */ +#define SDL_HAPTIC_SPHERICAL 2 + +/* @} *//* Direction encodings */ + +/* @} *//* Haptic features */ + +/* + * Misc defines. + */ + +/** + * \brief Used to play a device an infinite number of times. + * + * \sa SDL_HapticRunEffect + */ +#define SDL_HAPTIC_INFINITY 4294967295U + + +/** + * \brief Structure that represents a haptic direction. + * + * This is the direction where the force comes from, + * instead of the direction in which the force is exerted. + * + * Directions can be specified by: + * - ::SDL_HAPTIC_POLAR : Specified by polar coordinates. + * - ::SDL_HAPTIC_CARTESIAN : Specified by cartesian coordinates. + * - ::SDL_HAPTIC_SPHERICAL : Specified by spherical coordinates. + * + * Cardinal directions of the haptic device are relative to the positioning + * of the device. North is considered to be away from the user. + * + * The following diagram represents the cardinal directions: + * \verbatim + .--. + |__| .-------. + |=.| |.-----.| + |--| || || + | | |'-----'| + |__|~')_____(' + [ COMPUTER ] + + + North (0,-1) + ^ + | + | + (-1,0) West <----[ HAPTIC ]----> East (1,0) + | + | + v + South (0,1) + + + [ USER ] + \|||/ + (o o) + ---ooO-(_)-Ooo--- + \endverbatim + * + * If type is ::SDL_HAPTIC_POLAR, direction is encoded by hundredths of a + * degree starting north and turning clockwise. ::SDL_HAPTIC_POLAR only uses + * the first \c dir parameter. The cardinal directions would be: + * - North: 0 (0 degrees) + * - East: 9000 (90 degrees) + * - South: 18000 (180 degrees) + * - West: 27000 (270 degrees) + * + * If type is ::SDL_HAPTIC_CARTESIAN, direction is encoded by three positions + * (X axis, Y axis and Z axis (with 3 axes)). ::SDL_HAPTIC_CARTESIAN uses + * the first three \c dir parameters. The cardinal directions would be: + * - North: 0,-1, 0 + * - East: 1, 0, 0 + * - South: 0, 1, 0 + * - West: -1, 0, 0 + * + * The Z axis represents the height of the effect if supported, otherwise + * it's unused. In cartesian encoding (1, 2) would be the same as (2, 4), you + * can use any multiple you want, only the direction matters. + * + * If type is ::SDL_HAPTIC_SPHERICAL, direction is encoded by two rotations. + * The first two \c dir parameters are used. The \c dir parameters are as + * follows (all values are in hundredths of degrees): + * - Degrees from (1, 0) rotated towards (0, 1). + * - Degrees towards (0, 0, 1) (device needs at least 3 axes). + * + * + * Example of force coming from the south with all encodings (force coming + * from the south means the user will have to pull the stick to counteract): + * \code + * SDL_HapticDirection direction; + * + * // Cartesian directions + * direction.type = SDL_HAPTIC_CARTESIAN; // Using cartesian direction encoding. + * direction.dir[0] = 0; // X position + * direction.dir[1] = 1; // Y position + * // Assuming the device has 2 axes, we don't need to specify third parameter. + * + * // Polar directions + * direction.type = SDL_HAPTIC_POLAR; // We'll be using polar direction encoding. + * direction.dir[0] = 18000; // Polar only uses first parameter + * + * // Spherical coordinates + * direction.type = SDL_HAPTIC_SPHERICAL; // Spherical encoding + * direction.dir[0] = 9000; // Since we only have two axes we don't need more parameters. + * \endcode + * + * \sa SDL_HAPTIC_POLAR + * \sa SDL_HAPTIC_CARTESIAN + * \sa SDL_HAPTIC_SPHERICAL + * \sa SDL_HapticEffect + * \sa SDL_HapticNumAxes + */ +typedef struct SDL_HapticDirection +{ + Uint8 type; /**< The type of encoding. */ + Sint32 dir[3]; /**< The encoded direction. */ +} SDL_HapticDirection; + + +/** + * \brief A structure containing a template for a Constant effect. + * + * This struct is exclusively for the ::SDL_HAPTIC_CONSTANT effect. + * + * A constant effect applies a constant force in the specified direction + * to the joystick. + * + * \sa SDL_HAPTIC_CONSTANT + * \sa SDL_HapticEffect + */ +typedef struct SDL_HapticConstant +{ + /* Header */ + Uint16 type; /**< ::SDL_HAPTIC_CONSTANT */ + SDL_HapticDirection direction; /**< Direction of the effect. */ + + /* Replay */ + Uint32 length; /**< Duration of the effect. */ + Uint16 delay; /**< Delay before starting the effect. */ + + /* Trigger */ + Uint16 button; /**< Button that triggers the effect. */ + Uint16 interval; /**< How soon it can be triggered again after button. */ + + /* Constant */ + Sint16 level; /**< Strength of the constant effect. */ + + /* Envelope */ + Uint16 attack_length; /**< Duration of the attack. */ + Uint16 attack_level; /**< Level at the start of the attack. */ + Uint16 fade_length; /**< Duration of the fade. */ + Uint16 fade_level; /**< Level at the end of the fade. */ +} SDL_HapticConstant; + +/** + * \brief A structure containing a template for a Periodic effect. + * + * The struct handles the following effects: + * - ::SDL_HAPTIC_SINE + * - ::SDL_HAPTIC_LEFTRIGHT + * - ::SDL_HAPTIC_TRIANGLE + * - ::SDL_HAPTIC_SAWTOOTHUP + * - ::SDL_HAPTIC_SAWTOOTHDOWN + * + * A periodic effect consists in a wave-shaped effect that repeats itself + * over time. The type determines the shape of the wave and the parameters + * determine the dimensions of the wave. + * + * Phase is given by hundredth of a degree meaning that giving the phase a value + * of 9000 will displace it 25% of its period. Here are sample values: + * - 0: No phase displacement. + * - 9000: Displaced 25% of its period. + * - 18000: Displaced 50% of its period. + * - 27000: Displaced 75% of its period. + * - 36000: Displaced 100% of its period, same as 0, but 0 is preferred. + * + * Examples: + * \verbatim + SDL_HAPTIC_SINE + __ __ __ __ + / \ / \ / \ / + / \__/ \__/ \__/ + + SDL_HAPTIC_SQUARE + __ __ __ __ __ + | | | | | | | | | | + | |__| |__| |__| |__| | + + SDL_HAPTIC_TRIANGLE + /\ /\ /\ /\ /\ + / \ / \ / \ / \ / + / \/ \/ \/ \/ + + SDL_HAPTIC_SAWTOOTHUP + /| /| /| /| /| /| /| + / | / | / | / | / | / | / | + / |/ |/ |/ |/ |/ |/ | + + SDL_HAPTIC_SAWTOOTHDOWN + \ |\ |\ |\ |\ |\ |\ | + \ | \ | \ | \ | \ | \ | \ | + \| \| \| \| \| \| \| + \endverbatim + * + * \sa SDL_HAPTIC_SINE + * \sa SDL_HAPTIC_LEFTRIGHT + * \sa SDL_HAPTIC_TRIANGLE + * \sa SDL_HAPTIC_SAWTOOTHUP + * \sa SDL_HAPTIC_SAWTOOTHDOWN + * \sa SDL_HapticEffect + */ +typedef struct SDL_HapticPeriodic +{ + /* Header */ + Uint16 type; /**< ::SDL_HAPTIC_SINE, ::SDL_HAPTIC_LEFTRIGHT, + ::SDL_HAPTIC_TRIANGLE, ::SDL_HAPTIC_SAWTOOTHUP or + ::SDL_HAPTIC_SAWTOOTHDOWN */ + SDL_HapticDirection direction; /**< Direction of the effect. */ + + /* Replay */ + Uint32 length; /**< Duration of the effect. */ + Uint16 delay; /**< Delay before starting the effect. */ + + /* Trigger */ + Uint16 button; /**< Button that triggers the effect. */ + Uint16 interval; /**< How soon it can be triggered again after button. */ + + /* Periodic */ + Uint16 period; /**< Period of the wave. */ + Sint16 magnitude; /**< Peak value; if negative, equivalent to 180 degrees extra phase shift. */ + Sint16 offset; /**< Mean value of the wave. */ + Uint16 phase; /**< Positive phase shift given by hundredth of a degree. */ + + /* Envelope */ + Uint16 attack_length; /**< Duration of the attack. */ + Uint16 attack_level; /**< Level at the start of the attack. */ + Uint16 fade_length; /**< Duration of the fade. */ + Uint16 fade_level; /**< Level at the end of the fade. */ +} SDL_HapticPeriodic; + +/** + * \brief A structure containing a template for a Condition effect. + * + * The struct handles the following effects: + * - ::SDL_HAPTIC_SPRING: Effect based on axes position. + * - ::SDL_HAPTIC_DAMPER: Effect based on axes velocity. + * - ::SDL_HAPTIC_INERTIA: Effect based on axes acceleration. + * - ::SDL_HAPTIC_FRICTION: Effect based on axes movement. + * + * Direction is handled by condition internals instead of a direction member. + * The condition effect specific members have three parameters. The first + * refers to the X axis, the second refers to the Y axis and the third + * refers to the Z axis. The right terms refer to the positive side of the + * axis and the left terms refer to the negative side of the axis. Please + * refer to the ::SDL_HapticDirection diagram for which side is positive and + * which is negative. + * + * \sa SDL_HapticDirection + * \sa SDL_HAPTIC_SPRING + * \sa SDL_HAPTIC_DAMPER + * \sa SDL_HAPTIC_INERTIA + * \sa SDL_HAPTIC_FRICTION + * \sa SDL_HapticEffect + */ +typedef struct SDL_HapticCondition +{ + /* Header */ + Uint16 type; /**< ::SDL_HAPTIC_SPRING, ::SDL_HAPTIC_DAMPER, + ::SDL_HAPTIC_INERTIA or ::SDL_HAPTIC_FRICTION */ + SDL_HapticDirection direction; /**< Direction of the effect - Not used ATM. */ + + /* Replay */ + Uint32 length; /**< Duration of the effect. */ + Uint16 delay; /**< Delay before starting the effect. */ + + /* Trigger */ + Uint16 button; /**< Button that triggers the effect. */ + Uint16 interval; /**< How soon it can be triggered again after button. */ + + /* Condition */ + Uint16 right_sat[3]; /**< Level when joystick is to the positive side; max 0xFFFF. */ + Uint16 left_sat[3]; /**< Level when joystick is to the negative side; max 0xFFFF. */ + Sint16 right_coeff[3]; /**< How fast to increase the force towards the positive side. */ + Sint16 left_coeff[3]; /**< How fast to increase the force towards the negative side. */ + Uint16 deadband[3]; /**< Size of the dead zone; max 0xFFFF: whole axis-range when 0-centered. */ + Sint16 center[3]; /**< Position of the dead zone. */ +} SDL_HapticCondition; + +/** + * \brief A structure containing a template for a Ramp effect. + * + * This struct is exclusively for the ::SDL_HAPTIC_RAMP effect. + * + * The ramp effect starts at start strength and ends at end strength. + * It augments in linear fashion. If you use attack and fade with a ramp + * the effects get added to the ramp effect making the effect become + * quadratic instead of linear. + * + * \sa SDL_HAPTIC_RAMP + * \sa SDL_HapticEffect + */ +typedef struct SDL_HapticRamp +{ + /* Header */ + Uint16 type; /**< ::SDL_HAPTIC_RAMP */ + SDL_HapticDirection direction; /**< Direction of the effect. */ + + /* Replay */ + Uint32 length; /**< Duration of the effect. */ + Uint16 delay; /**< Delay before starting the effect. */ + + /* Trigger */ + Uint16 button; /**< Button that triggers the effect. */ + Uint16 interval; /**< How soon it can be triggered again after button. */ + + /* Ramp */ + Sint16 start; /**< Beginning strength level. */ + Sint16 end; /**< Ending strength level. */ + + /* Envelope */ + Uint16 attack_length; /**< Duration of the attack. */ + Uint16 attack_level; /**< Level at the start of the attack. */ + Uint16 fade_length; /**< Duration of the fade. */ + Uint16 fade_level; /**< Level at the end of the fade. */ +} SDL_HapticRamp; + +/** + * \brief A structure containing a template for a Left/Right effect. + * + * This struct is exclusively for the ::SDL_HAPTIC_LEFTRIGHT effect. + * + * The Left/Right effect is used to explicitly control the large and small + * motors, commonly found in modern game controllers. The small (right) motor + * is high frequency, and the large (left) motor is low frequency. + * + * \sa SDL_HAPTIC_LEFTRIGHT + * \sa SDL_HapticEffect + */ +typedef struct SDL_HapticLeftRight +{ + /* Header */ + Uint16 type; /**< ::SDL_HAPTIC_LEFTRIGHT */ + + /* Replay */ + Uint32 length; /**< Duration of the effect in milliseconds. */ + + /* Rumble */ + Uint16 large_magnitude; /**< Control of the large controller motor. */ + Uint16 small_magnitude; /**< Control of the small controller motor. */ +} SDL_HapticLeftRight; + +/** + * \brief A structure containing a template for the ::SDL_HAPTIC_CUSTOM effect. + * + * This struct is exclusively for the ::SDL_HAPTIC_CUSTOM effect. + * + * A custom force feedback effect is much like a periodic effect, where the + * application can define its exact shape. You will have to allocate the + * data yourself. Data should consist of channels * samples Uint16 samples. + * + * If channels is one, the effect is rotated using the defined direction. + * Otherwise it uses the samples in data for the different axes. + * + * \sa SDL_HAPTIC_CUSTOM + * \sa SDL_HapticEffect + */ +typedef struct SDL_HapticCustom +{ + /* Header */ + Uint16 type; /**< ::SDL_HAPTIC_CUSTOM */ + SDL_HapticDirection direction; /**< Direction of the effect. */ + + /* Replay */ + Uint32 length; /**< Duration of the effect. */ + Uint16 delay; /**< Delay before starting the effect. */ + + /* Trigger */ + Uint16 button; /**< Button that triggers the effect. */ + Uint16 interval; /**< How soon it can be triggered again after button. */ + + /* Custom */ + Uint8 channels; /**< Axes to use, minimum of one. */ + Uint16 period; /**< Sample periods. */ + Uint16 samples; /**< Amount of samples. */ + Uint16 *data; /**< Should contain channels*samples items. */ + + /* Envelope */ + Uint16 attack_length; /**< Duration of the attack. */ + Uint16 attack_level; /**< Level at the start of the attack. */ + Uint16 fade_length; /**< Duration of the fade. */ + Uint16 fade_level; /**< Level at the end of the fade. */ +} SDL_HapticCustom; + +/** + * \brief The generic template for any haptic effect. + * + * All values max at 32767 (0x7FFF). Signed values also can be negative. + * Time values unless specified otherwise are in milliseconds. + * + * You can also pass ::SDL_HAPTIC_INFINITY to length instead of a 0-32767 + * value. Neither delay, interval, attack_length nor fade_length support + * ::SDL_HAPTIC_INFINITY. Fade will also not be used since effect never ends. + * + * Additionally, the ::SDL_HAPTIC_RAMP effect does not support a duration of + * ::SDL_HAPTIC_INFINITY. + * + * Button triggers may not be supported on all devices, it is advised to not + * use them if possible. Buttons start at index 1 instead of index 0 like + * the joystick. + * + * If both attack_length and fade_level are 0, the envelope is not used, + * otherwise both values are used. + * + * Common parts: + * \code + * // Replay - All effects have this + * Uint32 length; // Duration of effect (ms). + * Uint16 delay; // Delay before starting effect. + * + * // Trigger - All effects have this + * Uint16 button; // Button that triggers effect. + * Uint16 interval; // How soon before effect can be triggered again. + * + * // Envelope - All effects except condition effects have this + * Uint16 attack_length; // Duration of the attack (ms). + * Uint16 attack_level; // Level at the start of the attack. + * Uint16 fade_length; // Duration of the fade out (ms). + * Uint16 fade_level; // Level at the end of the fade. + * \endcode + * + * + * Here we have an example of a constant effect evolution in time: + * \verbatim + Strength + ^ + | + | effect level --> _________________ + | / \ + | / \ + | / \ + | / \ + | attack_level --> | \ + | | | <--- fade_level + | + +--------------------------------------------------> Time + [--] [---] + attack_length fade_length + + [------------------][-----------------------] + delay length + \endverbatim + * + * Note either the attack_level or the fade_level may be above the actual + * effect level. + * + * \sa SDL_HapticConstant + * \sa SDL_HapticPeriodic + * \sa SDL_HapticCondition + * \sa SDL_HapticRamp + * \sa SDL_HapticLeftRight + * \sa SDL_HapticCustom + */ +typedef union SDL_HapticEffect +{ + /* Common for all force feedback effects */ + Uint16 type; /**< Effect type. */ + SDL_HapticConstant constant; /**< Constant effect. */ + SDL_HapticPeriodic periodic; /**< Periodic effect. */ + SDL_HapticCondition condition; /**< Condition effect. */ + SDL_HapticRamp ramp; /**< Ramp effect. */ + SDL_HapticLeftRight leftright; /**< Left/Right effect. */ + SDL_HapticCustom custom; /**< Custom effect. */ +} SDL_HapticEffect; + + +/* Function prototypes */ +/** + * \brief Count the number of haptic devices attached to the system. + * + * \return Number of haptic devices detected on the system. + */ +extern DECLSPEC int SDLCALL SDL_NumHaptics(void); + +/** + * \brief Get the implementation dependent name of a haptic device. + * + * This can be called before any joysticks are opened. + * If no name can be found, this function returns NULL. + * + * \param device_index Index of the device to get its name. + * \return Name of the device or NULL on error. + * + * \sa SDL_NumHaptics + */ +extern DECLSPEC const char *SDLCALL SDL_HapticName(int device_index); + +/** + * \brief Opens a haptic device for use. + * + * The index passed as an argument refers to the N'th haptic device on this + * system. + * + * When opening a haptic device, its gain will be set to maximum and + * autocenter will be disabled. To modify these values use + * SDL_HapticSetGain() and SDL_HapticSetAutocenter(). + * + * \param device_index Index of the device to open. + * \return Device identifier or NULL on error. + * + * \sa SDL_HapticIndex + * \sa SDL_HapticOpenFromMouse + * \sa SDL_HapticOpenFromJoystick + * \sa SDL_HapticClose + * \sa SDL_HapticSetGain + * \sa SDL_HapticSetAutocenter + * \sa SDL_HapticPause + * \sa SDL_HapticStopAll + */ +extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpen(int device_index); + +/** + * \brief Checks if the haptic device at index has been opened. + * + * \param device_index Index to check to see if it has been opened. + * \return 1 if it has been opened or 0 if it hasn't. + * + * \sa SDL_HapticOpen + * \sa SDL_HapticIndex + */ +extern DECLSPEC int SDLCALL SDL_HapticOpened(int device_index); + +/** + * \brief Gets the index of a haptic device. + * + * \param haptic Haptic device to get the index of. + * \return The index of the haptic device or -1 on error. + * + * \sa SDL_HapticOpen + * \sa SDL_HapticOpened + */ +extern DECLSPEC int SDLCALL SDL_HapticIndex(SDL_Haptic * haptic); + +/** + * \brief Gets whether or not the current mouse has haptic capabilities. + * + * \return SDL_TRUE if the mouse is haptic, SDL_FALSE if it isn't. + * + * \sa SDL_HapticOpenFromMouse + */ +extern DECLSPEC int SDLCALL SDL_MouseIsHaptic(void); + +/** + * \brief Tries to open a haptic device from the current mouse. + * + * \return The haptic device identifier or NULL on error. + * + * \sa SDL_MouseIsHaptic + * \sa SDL_HapticOpen + */ +extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpenFromMouse(void); + +/** + * \brief Checks to see if a joystick has haptic features. + * + * \param joystick Joystick to test for haptic capabilities. + * \return SDL_TRUE if the joystick is haptic, SDL_FALSE if it isn't + * or -1 if an error occurred. + * + * \sa SDL_HapticOpenFromJoystick + */ +extern DECLSPEC int SDLCALL SDL_JoystickIsHaptic(SDL_Joystick * joystick); + +/** + * \brief Opens a haptic device for use from a joystick device. + * + * You must still close the haptic device separately. It will not be closed + * with the joystick. + * + * When opening from a joystick you should first close the haptic device before + * closing the joystick device. If not, on some implementations the haptic + * device will also get unallocated and you'll be unable to use force feedback + * on that device. + * + * \param joystick Joystick to create a haptic device from. + * \return A valid haptic device identifier on success or NULL on error. + * + * \sa SDL_HapticOpen + * \sa SDL_HapticClose + */ +extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpenFromJoystick(SDL_Joystick * + joystick); + +/** + * \brief Closes a haptic device previously opened with SDL_HapticOpen(). + * + * \param haptic Haptic device to close. + */ +extern DECLSPEC void SDLCALL SDL_HapticClose(SDL_Haptic * haptic); + +/** + * \brief Returns the number of effects a haptic device can store. + * + * On some platforms this isn't fully supported, and therefore is an + * approximation. Always check to see if your created effect was actually + * created and do not rely solely on SDL_HapticNumEffects(). + * + * \param haptic The haptic device to query effect max. + * \return The number of effects the haptic device can store or + * -1 on error. + * + * \sa SDL_HapticNumEffectsPlaying + * \sa SDL_HapticQuery + */ +extern DECLSPEC int SDLCALL SDL_HapticNumEffects(SDL_Haptic * haptic); + +/** + * \brief Returns the number of effects a haptic device can play at the same + * time. + * + * This is not supported on all platforms, but will always return a value. + * Added here for the sake of completeness. + * + * \param haptic The haptic device to query maximum playing effects. + * \return The number of effects the haptic device can play at the same time + * or -1 on error. + * + * \sa SDL_HapticNumEffects + * \sa SDL_HapticQuery + */ +extern DECLSPEC int SDLCALL SDL_HapticNumEffectsPlaying(SDL_Haptic * haptic); + +/** + * \brief Gets the haptic device's supported features in bitwise manner. + * + * Example: + * \code + * if (SDL_HapticQuery(haptic) & SDL_HAPTIC_CONSTANT) { + * printf("We have constant haptic effect!\n"); + * } + * \endcode + * + * \param haptic The haptic device to query. + * \return Haptic features in bitwise manner (OR'd). + * + * \sa SDL_HapticNumEffects + * \sa SDL_HapticEffectSupported + */ +extern DECLSPEC unsigned int SDLCALL SDL_HapticQuery(SDL_Haptic * haptic); + + +/** + * \brief Gets the number of haptic axes the device has. + * + * \sa SDL_HapticDirection + */ +extern DECLSPEC int SDLCALL SDL_HapticNumAxes(SDL_Haptic * haptic); + +/** + * \brief Checks to see if effect is supported by haptic. + * + * \param haptic Haptic device to check on. + * \param effect Effect to check to see if it is supported. + * \return SDL_TRUE if effect is supported, SDL_FALSE if it isn't or -1 on error. + * + * \sa SDL_HapticQuery + * \sa SDL_HapticNewEffect + */ +extern DECLSPEC int SDLCALL SDL_HapticEffectSupported(SDL_Haptic * haptic, + SDL_HapticEffect * + effect); + +/** + * \brief Creates a new haptic effect on the device. + * + * \param haptic Haptic device to create the effect on. + * \param effect Properties of the effect to create. + * \return The identifier of the effect on success or -1 on error. + * + * \sa SDL_HapticUpdateEffect + * \sa SDL_HapticRunEffect + * \sa SDL_HapticDestroyEffect + */ +extern DECLSPEC int SDLCALL SDL_HapticNewEffect(SDL_Haptic * haptic, + SDL_HapticEffect * effect); + +/** + * \brief Updates the properties of an effect. + * + * Can be used dynamically, although behavior when dynamically changing + * direction may be strange. Specifically the effect may reupload itself + * and start playing from the start. You cannot change the type either when + * running SDL_HapticUpdateEffect(). + * + * \param haptic Haptic device that has the effect. + * \param effect Identifier of the effect to update. + * \param data New effect properties to use. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticNewEffect + * \sa SDL_HapticRunEffect + * \sa SDL_HapticDestroyEffect + */ +extern DECLSPEC int SDLCALL SDL_HapticUpdateEffect(SDL_Haptic * haptic, + int effect, + SDL_HapticEffect * data); + +/** + * \brief Runs the haptic effect on its associated haptic device. + * + * If iterations are ::SDL_HAPTIC_INFINITY, it'll run the effect over and over + * repeating the envelope (attack and fade) every time. If you only want the + * effect to last forever, set ::SDL_HAPTIC_INFINITY in the effect's length + * parameter. + * + * \param haptic Haptic device to run the effect on. + * \param effect Identifier of the haptic effect to run. + * \param iterations Number of iterations to run the effect. Use + * ::SDL_HAPTIC_INFINITY for infinity. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticStopEffect + * \sa SDL_HapticDestroyEffect + * \sa SDL_HapticGetEffectStatus + */ +extern DECLSPEC int SDLCALL SDL_HapticRunEffect(SDL_Haptic * haptic, + int effect, + Uint32 iterations); + +/** + * \brief Stops the haptic effect on its associated haptic device. + * + * \param haptic Haptic device to stop the effect on. + * \param effect Identifier of the effect to stop. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticRunEffect + * \sa SDL_HapticDestroyEffect + */ +extern DECLSPEC int SDLCALL SDL_HapticStopEffect(SDL_Haptic * haptic, + int effect); + +/** + * \brief Destroys a haptic effect on the device. + * + * This will stop the effect if it's running. Effects are automatically + * destroyed when the device is closed. + * + * \param haptic Device to destroy the effect on. + * \param effect Identifier of the effect to destroy. + * + * \sa SDL_HapticNewEffect + */ +extern DECLSPEC void SDLCALL SDL_HapticDestroyEffect(SDL_Haptic * haptic, + int effect); + +/** + * \brief Gets the status of the current effect on the haptic device. + * + * Device must support the ::SDL_HAPTIC_STATUS feature. + * + * \param haptic Haptic device to query the effect status on. + * \param effect Identifier of the effect to query its status. + * \return 0 if it isn't playing, 1 if it is playing or -1 on error. + * + * \sa SDL_HapticRunEffect + * \sa SDL_HapticStopEffect + */ +extern DECLSPEC int SDLCALL SDL_HapticGetEffectStatus(SDL_Haptic * haptic, + int effect); + +/** + * \brief Sets the global gain of the device. + * + * Device must support the ::SDL_HAPTIC_GAIN feature. + * + * The user may specify the maximum gain by setting the environment variable + * SDL_HAPTIC_GAIN_MAX which should be between 0 and 100. All calls to + * SDL_HapticSetGain() will scale linearly using SDL_HAPTIC_GAIN_MAX as the + * maximum. + * + * \param haptic Haptic device to set the gain on. + * \param gain Value to set the gain to, should be between 0 and 100. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticQuery + */ +extern DECLSPEC int SDLCALL SDL_HapticSetGain(SDL_Haptic * haptic, int gain); + +/** + * \brief Sets the global autocenter of the device. + * + * Autocenter should be between 0 and 100. Setting it to 0 will disable + * autocentering. + * + * Device must support the ::SDL_HAPTIC_AUTOCENTER feature. + * + * \param haptic Haptic device to set autocentering on. + * \param autocenter Value to set autocenter to, 0 disables autocentering. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticQuery + */ +extern DECLSPEC int SDLCALL SDL_HapticSetAutocenter(SDL_Haptic * haptic, + int autocenter); + +/** + * \brief Pauses a haptic device. + * + * Device must support the ::SDL_HAPTIC_PAUSE feature. Call + * SDL_HapticUnpause() to resume playback. + * + * Do not modify the effects nor add new ones while the device is paused. + * That can cause all sorts of weird errors. + * + * \param haptic Haptic device to pause. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticUnpause + */ +extern DECLSPEC int SDLCALL SDL_HapticPause(SDL_Haptic * haptic); + +/** + * \brief Unpauses a haptic device. + * + * Call to unpause after SDL_HapticPause(). + * + * \param haptic Haptic device to unpause. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticPause + */ +extern DECLSPEC int SDLCALL SDL_HapticUnpause(SDL_Haptic * haptic); + +/** + * \brief Stops all the currently playing effects on a haptic device. + * + * \param haptic Haptic device to stop. + * \return 0 on success or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_HapticStopAll(SDL_Haptic * haptic); + +/** + * \brief Checks to see if rumble is supported on a haptic device. + * + * \param haptic Haptic device to check to see if it supports rumble. + * \return SDL_TRUE if effect is supported, SDL_FALSE if it isn't or -1 on error. + * + * \sa SDL_HapticRumbleInit + * \sa SDL_HapticRumblePlay + * \sa SDL_HapticRumbleStop + */ +extern DECLSPEC int SDLCALL SDL_HapticRumbleSupported(SDL_Haptic * haptic); + +/** + * \brief Initializes the haptic device for simple rumble playback. + * + * \param haptic Haptic device to initialize for simple rumble playback. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticOpen + * \sa SDL_HapticRumbleSupported + * \sa SDL_HapticRumblePlay + * \sa SDL_HapticRumbleStop + */ +extern DECLSPEC int SDLCALL SDL_HapticRumbleInit(SDL_Haptic * haptic); + +/** + * \brief Runs simple rumble on a haptic device + * + * \param haptic Haptic device to play rumble effect on. + * \param strength Strength of the rumble to play as a 0-1 float value. + * \param length Length of the rumble to play in milliseconds. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticRumbleSupported + * \sa SDL_HapticRumbleInit + * \sa SDL_HapticRumbleStop + */ +extern DECLSPEC int SDLCALL SDL_HapticRumblePlay(SDL_Haptic * haptic, float strength, Uint32 length ); + +/** + * \brief Stops the simple rumble on a haptic device. + * + * \param haptic Haptic to stop the rumble on. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticRumbleSupported + * \sa SDL_HapticRumbleInit + * \sa SDL_HapticRumblePlay + */ +extern DECLSPEC int SDLCALL SDL_HapticRumbleStop(SDL_Haptic * haptic); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_haptic_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_hints.h b/thirdparty/include/SDL2/SDL_hints.h new file mode 100644 index 000000000..a3a537383 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_hints.h @@ -0,0 +1,1364 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_hints.h + * + * Official documentation for SDL configuration variables + * + * This file contains functions to set and get configuration hints, + * as well as listing each of them alphabetically. + * + * The convention for naming hints is SDL_HINT_X, where "SDL_X" is + * the environment variable that can be used to override the default. + * + * In general these hints are just that - they may or may not be + * supported or applicable on any given platform, but they provide + * a way for an application or user to give the library a hint as + * to how they would like the library to work. + */ + +#ifndef SDL_hints_h_ +#define SDL_hints_h_ + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief A variable controlling how 3D acceleration is used to accelerate the SDL screen surface. + * + * SDL can try to accelerate the SDL screen surface by using streaming + * textures with a 3D rendering engine. This variable controls whether and + * how this is done. + * + * This variable can be set to the following values: + * "0" - Disable 3D acceleration + * "1" - Enable 3D acceleration, using the default renderer. + * "X" - Enable 3D acceleration, using X where X is one of the valid rendering drivers. (e.g. "direct3d", "opengl", etc.) + * + * By default SDL tries to make a best guess for each platform whether + * to use acceleration or not. + */ +#define SDL_HINT_FRAMEBUFFER_ACCELERATION "SDL_FRAMEBUFFER_ACCELERATION" + +/** + * \brief A variable specifying which render driver to use. + * + * If the application doesn't pick a specific renderer to use, this variable + * specifies the name of the preferred renderer. If the preferred renderer + * can't be initialized, the normal default renderer is used. + * + * This variable is case insensitive and can be set to the following values: + * "direct3d" + * "opengl" + * "opengles2" + * "opengles" + * "metal" + * "software" + * + * The default varies by platform, but it's the first one in the list that + * is available on the current platform. + */ +#define SDL_HINT_RENDER_DRIVER "SDL_RENDER_DRIVER" + +/** + * \brief A variable controlling whether the OpenGL render driver uses shaders if they are available. + * + * This variable can be set to the following values: + * "0" - Disable shaders + * "1" - Enable shaders + * + * By default shaders are used if OpenGL supports them. + */ +#define SDL_HINT_RENDER_OPENGL_SHADERS "SDL_RENDER_OPENGL_SHADERS" + +/** + * \brief A variable controlling whether the Direct3D device is initialized for thread-safe operations. + * + * This variable can be set to the following values: + * "0" - Thread-safety is not enabled (faster) + * "1" - Thread-safety is enabled + * + * By default the Direct3D device is created with thread-safety disabled. + */ +#define SDL_HINT_RENDER_DIRECT3D_THREADSAFE "SDL_RENDER_DIRECT3D_THREADSAFE" + +/** + * \brief A variable controlling whether to enable Direct3D 11+'s Debug Layer. + * + * This variable does not have any effect on the Direct3D 9 based renderer. + * + * This variable can be set to the following values: + * "0" - Disable Debug Layer use + * "1" - Enable Debug Layer use + * + * By default, SDL does not use Direct3D Debug Layer. + */ +#define SDL_HINT_RENDER_DIRECT3D11_DEBUG "SDL_RENDER_DIRECT3D11_DEBUG" + +/** + * \brief A variable controlling the scaling policy for SDL_RenderSetLogicalSize. + * + * This variable can be set to the following values: + * "0" or "letterbox" - Uses letterbox/sidebars to fit the entire rendering on screen + * "1" or "overscan" - Will zoom the rendering so it fills the entire screen, allowing edges to be drawn offscreen + * + * By default letterbox is used + */ +#define SDL_HINT_RENDER_LOGICAL_SIZE_MODE "SDL_RENDER_LOGICAL_SIZE_MODE" + +/** + * \brief A variable controlling the scaling quality + * + * This variable can be set to the following values: + * "0" or "nearest" - Nearest pixel sampling + * "1" or "linear" - Linear filtering (supported by OpenGL and Direct3D) + * "2" or "best" - Currently this is the same as "linear" + * + * By default nearest pixel sampling is used + */ +#define SDL_HINT_RENDER_SCALE_QUALITY "SDL_RENDER_SCALE_QUALITY" + +/** + * \brief A variable controlling whether updates to the SDL screen surface should be synchronized with the vertical refresh, to avoid tearing. + * + * This variable can be set to the following values: + * "0" - Disable vsync + * "1" - Enable vsync + * + * By default SDL does not sync screen surface updates with vertical refresh. + */ +#define SDL_HINT_RENDER_VSYNC "SDL_RENDER_VSYNC" + +/** + * \brief A variable controlling whether the screensaver is enabled. + * + * This variable can be set to the following values: + * "0" - Disable screensaver + * "1" - Enable screensaver + * + * By default SDL will disable the screensaver. + */ +#define SDL_HINT_VIDEO_ALLOW_SCREENSAVER "SDL_VIDEO_ALLOW_SCREENSAVER" + +/** + * \brief A variable controlling whether the graphics context is externally managed. + * + * This variable can be set to the following values: + * "0" - SDL will manage graphics contexts that are attached to windows. + * "1" - Disable graphics context management on windows. + * + * By default SDL will manage OpenGL contexts in certain situations. For example, on Android the + * context will be automatically saved and restored when pausing the application. Additionally, some + * platforms will assume usage of OpenGL if Vulkan isn't used. Setting this to "1" will prevent this + * behavior, which is desireable when the application manages the graphics context, such as + * an externally managed OpenGL context or attaching a Vulkan surface to the window. + */ +#define SDL_HINT_VIDEO_EXTERNAL_CONTEXT "SDL_VIDEO_EXTERNAL_CONTEXT" + +/** + * \brief A variable controlling whether the X11 VidMode extension should be used. + * + * This variable can be set to the following values: + * "0" - Disable XVidMode + * "1" - Enable XVidMode + * + * By default SDL will use XVidMode if it is available. + */ +#define SDL_HINT_VIDEO_X11_XVIDMODE "SDL_VIDEO_X11_XVIDMODE" + +/** + * \brief A variable controlling whether the X11 Xinerama extension should be used. + * + * This variable can be set to the following values: + * "0" - Disable Xinerama + * "1" - Enable Xinerama + * + * By default SDL will use Xinerama if it is available. + */ +#define SDL_HINT_VIDEO_X11_XINERAMA "SDL_VIDEO_X11_XINERAMA" + +/** + * \brief A variable controlling whether the X11 XRandR extension should be used. + * + * This variable can be set to the following values: + * "0" - Disable XRandR + * "1" - Enable XRandR + * + * By default SDL will not use XRandR because of window manager issues. + */ +#define SDL_HINT_VIDEO_X11_XRANDR "SDL_VIDEO_X11_XRANDR" + +/** + * \brief A variable forcing the visual ID chosen for new X11 windows + * + */ +#define SDL_HINT_VIDEO_X11_WINDOW_VISUALID "SDL_VIDEO_X11_WINDOW_VISUALID" + +/** + * \brief A variable controlling whether the X11 _NET_WM_PING protocol should be supported. + * + * This variable can be set to the following values: + * "0" - Disable _NET_WM_PING + * "1" - Enable _NET_WM_PING + * + * By default SDL will use _NET_WM_PING, but for applications that know they + * will not always be able to respond to ping requests in a timely manner they can + * turn it off to avoid the window manager thinking the app is hung. + * The hint is checked in CreateWindow. + */ +#define SDL_HINT_VIDEO_X11_NET_WM_PING "SDL_VIDEO_X11_NET_WM_PING" + +/** + * \brief A variable controlling whether the X11 _NET_WM_BYPASS_COMPOSITOR hint should be used. + * + * This variable can be set to the following values: + * "0" - Disable _NET_WM_BYPASS_COMPOSITOR + * "1" - Enable _NET_WM_BYPASS_COMPOSITOR + * + * By default SDL will use _NET_WM_BYPASS_COMPOSITOR + * + */ +#define SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR "SDL_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR" + +/** + * \brief A variable controlling whether X11 should use GLX or EGL by default + * + * This variable can be set to the following values: + * "0" - Use GLX + * "1" - Use EGL + * + * By default SDL will use GLX when both are present. + */ +#define SDL_HINT_VIDEO_X11_FORCE_EGL "SDL_VIDEO_X11_FORCE_EGL" + +/** + * \brief A variable controlling whether the window frame and title bar are interactive when the cursor is hidden + * + * This variable can be set to the following values: + * "0" - The window frame is not interactive when the cursor is hidden (no move, resize, etc) + * "1" - The window frame is interactive when the cursor is hidden + * + * By default SDL will allow interaction with the window frame when the cursor is hidden + */ +#define SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN "SDL_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN" + +/** + * \brief A variable to specify custom icon resource id from RC file on Windows platform + */ +#define SDL_HINT_WINDOWS_INTRESOURCE_ICON "SDL_WINDOWS_INTRESOURCE_ICON" +#define SDL_HINT_WINDOWS_INTRESOURCE_ICON_SMALL "SDL_WINDOWS_INTRESOURCE_ICON_SMALL" + +/** + * \brief A variable controlling whether the windows message loop is processed by SDL + * + * This variable can be set to the following values: + * "0" - The window message loop is not run + * "1" - The window message loop is processed in SDL_PumpEvents() + * + * By default SDL will process the windows message loop + */ +#define SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP "SDL_WINDOWS_ENABLE_MESSAGELOOP" + +/** + * \brief A variable controlling whether grabbing input grabs the keyboard + * + * This variable can be set to the following values: + * "0" - Grab will affect only the mouse + * "1" - Grab will affect mouse and keyboard + * + * By default SDL will not grab the keyboard so system shortcuts still work. + */ +#define SDL_HINT_GRAB_KEYBOARD "SDL_GRAB_KEYBOARD" + +/** + * \brief A variable setting the double click time, in milliseconds. + */ +#define SDL_HINT_MOUSE_DOUBLE_CLICK_TIME "SDL_MOUSE_DOUBLE_CLICK_TIME" + +/** + * \brief A variable setting the double click radius, in pixels. + */ +#define SDL_HINT_MOUSE_DOUBLE_CLICK_RADIUS "SDL_MOUSE_DOUBLE_CLICK_RADIUS" + +/** + * \brief A variable setting the speed scale for mouse motion, in floating point, when the mouse is not in relative mode + */ +#define SDL_HINT_MOUSE_NORMAL_SPEED_SCALE "SDL_MOUSE_NORMAL_SPEED_SCALE" + +/** + * \brief A variable setting the scale for mouse motion, in floating point, when the mouse is in relative mode + */ +#define SDL_HINT_MOUSE_RELATIVE_SPEED_SCALE "SDL_MOUSE_RELATIVE_SPEED_SCALE" + +/** + * \brief A variable controlling whether relative mouse mode is implemented using mouse warping + * + * This variable can be set to the following values: + * "0" - Relative mouse mode uses raw input + * "1" - Relative mouse mode uses mouse warping + * + * By default SDL will use raw input for relative mouse mode + */ +#define SDL_HINT_MOUSE_RELATIVE_MODE_WARP "SDL_MOUSE_RELATIVE_MODE_WARP" + +/** + * \brief Allow mouse click events when clicking to focus an SDL window + * + * This variable can be set to the following values: + * "0" - Ignore mouse clicks that activate a window + * "1" - Generate events for mouse clicks that activate a window + * + * By default SDL will ignore mouse clicks that activate a window + */ +#define SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH "SDL_MOUSE_FOCUS_CLICKTHROUGH" + +/** + * \brief A variable controlling whether touch events should generate synthetic mouse events + * + * This variable can be set to the following values: + * "0" - Touch events will not generate mouse events + * "1" - Touch events will generate mouse events + * + * By default SDL will generate mouse events for touch events + */ +#define SDL_HINT_TOUCH_MOUSE_EVENTS "SDL_TOUCH_MOUSE_EVENTS" + +/** + * \brief A variable controlling whether mouse events should generate synthetic touch events + * + * This variable can be set to the following values: + * "0" - Mouse events will not generate touch events (default for desktop platforms) + * "1" - Mouse events will generate touch events (default for mobile platforms, such as Android and iOS) + */ + +#define SDL_HINT_MOUSE_TOUCH_EVENTS "SDL_MOUSE_TOUCH_EVENTS" + +/** + * \brief Minimize your SDL_Window if it loses key focus when in fullscreen mode. Defaults to true. + * + */ +#define SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS "SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS" + +/** + * \brief A variable controlling whether the idle timer is disabled on iOS. + * + * When an iOS app does not receive touches for some time, the screen is + * dimmed automatically. For games where the accelerometer is the only input + * this is problematic. This functionality can be disabled by setting this + * hint. + * + * As of SDL 2.0.4, SDL_EnableScreenSaver() and SDL_DisableScreenSaver() + * accomplish the same thing on iOS. They should be preferred over this hint. + * + * This variable can be set to the following values: + * "0" - Enable idle timer + * "1" - Disable idle timer + */ +#define SDL_HINT_IDLE_TIMER_DISABLED "SDL_IOS_IDLE_TIMER_DISABLED" + +/** + * \brief A variable controlling which orientations are allowed on iOS/Android. + * + * In some circumstances it is necessary to be able to explicitly control + * which UI orientations are allowed. + * + * This variable is a space delimited list of the following values: + * "LandscapeLeft", "LandscapeRight", "Portrait" "PortraitUpsideDown" + */ +#define SDL_HINT_ORIENTATIONS "SDL_IOS_ORIENTATIONS" + +/** + * \brief A variable controlling whether controllers used with the Apple TV + * generate UI events. + * + * When UI events are generated by controller input, the app will be + * backgrounded when the Apple TV remote's menu button is pressed, and when the + * pause or B buttons on gamepads are pressed. + * + * More information about properly making use of controllers for the Apple TV + * can be found here: + * https://developer.apple.com/tvos/human-interface-guidelines/remote-and-controllers/ + * + * This variable can be set to the following values: + * "0" - Controller input does not generate UI events (the default). + * "1" - Controller input generates UI events. + */ +#define SDL_HINT_APPLE_TV_CONTROLLER_UI_EVENTS "SDL_APPLE_TV_CONTROLLER_UI_EVENTS" + +/** + * \brief A variable controlling whether the Apple TV remote's joystick axes + * will automatically match the rotation of the remote. + * + * This variable can be set to the following values: + * "0" - Remote orientation does not affect joystick axes (the default). + * "1" - Joystick axes are based on the orientation of the remote. + */ +#define SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION "SDL_APPLE_TV_REMOTE_ALLOW_ROTATION" + +/** + * \brief A variable controlling whether the home indicator bar on iPhone X + * should be hidden. + * + * This variable can be set to the following values: + * "0" - The indicator bar is not hidden (default for windowed applications) + * "1" - The indicator bar is hidden and is shown when the screen is touched (useful for movie playback applications) + * "2" - The indicator bar is dim and the first swipe makes it visible and the second swipe performs the "home" action (default for fullscreen applications) + */ +#define SDL_HINT_IOS_HIDE_HOME_INDICATOR "SDL_IOS_HIDE_HOME_INDICATOR" + +/** + * \brief A variable controlling whether the Android / iOS built-in + * accelerometer should be listed as a joystick device. + * + * This variable can be set to the following values: + * "0" - The accelerometer is not listed as a joystick + * "1" - The accelerometer is available as a 3 axis joystick (the default). + */ +#define SDL_HINT_ACCELEROMETER_AS_JOYSTICK "SDL_ACCELEROMETER_AS_JOYSTICK" + +/** + * \brief A variable controlling whether the Android / tvOS remotes + * should be listed as joystick devices, instead of sending keyboard events. + * + * This variable can be set to the following values: + * "0" - Remotes send enter/escape/arrow key events + * "1" - Remotes are available as 2 axis, 2 button joysticks (the default). + */ +#define SDL_HINT_TV_REMOTE_AS_JOYSTICK "SDL_TV_REMOTE_AS_JOYSTICK" + +/** + * \brief A variable that lets you disable the detection and use of Xinput gamepad devices + * + * The variable can be set to the following values: + * "0" - Disable XInput detection (only uses direct input) + * "1" - Enable XInput detection (the default) + */ +#define SDL_HINT_XINPUT_ENABLED "SDL_XINPUT_ENABLED" + +/** + * \brief A variable that causes SDL to use the old axis and button mapping for XInput devices. + * + * This hint is for backwards compatibility only and will be removed in SDL 2.1 + * + * The default value is "0". This hint must be set before SDL_Init() + */ +#define SDL_HINT_XINPUT_USE_OLD_JOYSTICK_MAPPING "SDL_XINPUT_USE_OLD_JOYSTICK_MAPPING" + +/** + * \brief A variable that overrides the automatic controller type detection + * + * The variable should be comma separated entries, in the form: VID/PID=type + * + * The VID and PID should be hexadecimal with exactly 4 digits, e.g. 0x00fd + * + * The type should be one of: + * Xbox360 + * XboxOne + * PS3 + * PS4 + * SwitchPro + * + * This hint affects what driver is used, and must be set before calling SDL_Init(SDL_INIT_GAMECONTROLLER) + */ +#define SDL_HINT_GAMECONTROLLERTYPE "SDL_GAMECONTROLLERTYPE" + +/** + * \brief A variable that lets you manually hint extra gamecontroller db entries. + * + * The variable should be newline delimited rows of gamecontroller config data, see SDL_gamecontroller.h + * + * This hint must be set before calling SDL_Init(SDL_INIT_GAMECONTROLLER) + * You can update mappings after the system is initialized with SDL_GameControllerMappingForGUID() and SDL_GameControllerAddMapping() + */ +#define SDL_HINT_GAMECONTROLLERCONFIG "SDL_GAMECONTROLLERCONFIG" + +/** + * \brief A variable that lets you provide a file with extra gamecontroller db entries. + * + * The file should contain lines of gamecontroller config data, see SDL_gamecontroller.h + * + * This hint must be set before calling SDL_Init(SDL_INIT_GAMECONTROLLER) + * You can update mappings after the system is initialized with SDL_GameControllerMappingForGUID() and SDL_GameControllerAddMapping() + */ +#define SDL_HINT_GAMECONTROLLERCONFIG_FILE "SDL_GAMECONTROLLERCONFIG_FILE" + +/** + * \brief A variable containing a list of devices to skip when scanning for game controllers. + * + * The format of the string is a comma separated list of USB VID/PID pairs + * in hexadecimal form, e.g. + * + * 0xAAAA/0xBBBB,0xCCCC/0xDDDD + * + * The variable can also take the form of @file, in which case the named + * file will be loaded and interpreted as the value of the variable. + */ +#define SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES "SDL_GAMECONTROLLER_IGNORE_DEVICES" + +/** + * \brief If set, all devices will be skipped when scanning for game controllers except for the ones listed in this variable. + * + * The format of the string is a comma separated list of USB VID/PID pairs + * in hexadecimal form, e.g. + * + * 0xAAAA/0xBBBB,0xCCCC/0xDDDD + * + * The variable can also take the form of @file, in which case the named + * file will be loaded and interpreted as the value of the variable. + */ +#define SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT "SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT" + +/** + * \brief If set, game controller face buttons report their values according to their labels instead of their positional layout. + * + * For example, on Nintendo Switch controllers, normally you'd get: + * + * (Y) + * (X) (B) + * (A) + * + * but if this hint is set, you'll get: + * + * (X) + * (Y) (A) + * (B) + * + * The variable can be set to the following values: + * "0" - Report the face buttons by position, as though they were on an Xbox controller. + * "1" - Report the face buttons by label instead of position + * + * The default value is "1". This hint may be set at any time. + */ +#define SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS "SDL_GAMECONTROLLER_USE_BUTTON_LABELS" + +/** + * \brief A variable that lets you enable joystick (and gamecontroller) events even when your app is in the background. + * + * The variable can be set to the following values: + * "0" - Disable joystick & gamecontroller input events when the + * application is in the background. + * "1" - Enable joystick & gamecontroller input events when the + * application is in the background. + * + * The default value is "0". This hint may be set at any time. + */ +#define SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS "SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS" + +/** + * \brief A variable controlling whether the HIDAPI joystick drivers should be used. + * + * This variable can be set to the following values: + * "0" - HIDAPI drivers are not used + * "1" - HIDAPI drivers are used (the default) + * + * This variable is the default for all drivers, but can be overridden by the hints for specific drivers below. + */ +#define SDL_HINT_JOYSTICK_HIDAPI "SDL_JOYSTICK_HIDAPI" + +/** + * \brief A variable controlling whether the HIDAPI driver for PS4 controllers should be used. + * + * This variable can be set to the following values: + * "0" - HIDAPI driver is not used + * "1" - HIDAPI driver is used + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI + */ +#define SDL_HINT_JOYSTICK_HIDAPI_PS4 "SDL_JOYSTICK_HIDAPI_PS4" + +/** + * \brief A variable controlling whether extended input reports should be used for PS4 controllers when using the HIDAPI driver. + * + * This variable can be set to the following values: + * "0" - extended reports are not enabled (the default) + * "1" - extended reports + * + * Extended input reports allow rumble on Bluetooth PS4 controllers, but + * break DirectInput handling for applications that don't use SDL. + * + * Once extended reports are enabled, they can not be disabled without + * power cycling the controller. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE "SDL_JOYSTICK_HIDAPI_PS4_RUMBLE" + +/** + * \brief A variable controlling whether the HIDAPI driver for Steam Controllers should be used. + * + * This variable can be set to the following values: + * "0" - HIDAPI driver is not used + * "1" - HIDAPI driver is used + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI + */ +#define SDL_HINT_JOYSTICK_HIDAPI_STEAM "SDL_JOYSTICK_HIDAPI_STEAM" + +/** + * \brief A variable controlling whether the HIDAPI driver for Nintendo Switch controllers should be used. + * + * This variable can be set to the following values: + * "0" - HIDAPI driver is not used + * "1" - HIDAPI driver is used + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI + */ +#define SDL_HINT_JOYSTICK_HIDAPI_SWITCH "SDL_JOYSTICK_HIDAPI_SWITCH" + +/** + * \brief A variable controlling whether the HIDAPI driver for XBox controllers should be used. + * + * This variable can be set to the following values: + * "0" - HIDAPI driver is not used + * "1" - HIDAPI driver is used + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI + */ +#define SDL_HINT_JOYSTICK_HIDAPI_XBOX "SDL_JOYSTICK_HIDAPI_XBOX" + +/** + * \brief A variable controlling whether the HIDAPI driver for Nintendo GameCube controllers should be used. + * + * This variable can be set to the following values: + * "0" - HIDAPI driver is not used + * "1" - HIDAPI driver is used + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI + */ +#define SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE "SDL_JOYSTICK_HIDAPI_GAMECUBE" + +/** + * \brief A variable that controls whether Steam Controllers should be exposed using the SDL joystick and game controller APIs + * + * The variable can be set to the following values: + * "0" - Do not scan for Steam Controllers + * "1" - Scan for Steam Controllers (the default) + * + * The default value is "1". This hint must be set before initializing the joystick subsystem. + */ +#define SDL_HINT_ENABLE_STEAM_CONTROLLERS "SDL_ENABLE_STEAM_CONTROLLERS" + + +/** + * \brief If set to "0" then never set the top most bit on a SDL Window, even if the video mode expects it. + * This is a debugging aid for developers and not expected to be used by end users. The default is "1" + * + * This variable can be set to the following values: + * "0" - don't allow topmost + * "1" - allow topmost + */ +#define SDL_HINT_ALLOW_TOPMOST "SDL_ALLOW_TOPMOST" + +/** + * \brief A variable that controls the timer resolution, in milliseconds. + * + * The higher resolution the timer, the more frequently the CPU services + * timer interrupts, and the more precise delays are, but this takes up + * power and CPU time. This hint is only used on Windows 7 and earlier. + * + * See this blog post for more information: + * http://randomascii.wordpress.com/2013/07/08/windows-timer-resolution-megawatts-wasted/ + * + * If this variable is set to "0", the system timer resolution is not set. + * + * The default value is "1". This hint may be set at any time. + */ +#define SDL_HINT_TIMER_RESOLUTION "SDL_TIMER_RESOLUTION" + + +/** + * \brief A variable describing the content orientation on QtWayland-based platforms. + * + * On QtWayland platforms, windows are rotated client-side to allow for custom + * transitions. In order to correctly position overlays (e.g. volume bar) and + * gestures (e.g. events view, close/minimize gestures), the system needs to + * know in which orientation the application is currently drawing its contents. + * + * This does not cause the window to be rotated or resized, the application + * needs to take care of drawing the content in the right orientation (the + * framebuffer is always in portrait mode). + * + * This variable can be one of the following values: + * "primary" (default), "portrait", "landscape", "inverted-portrait", "inverted-landscape" + */ +#define SDL_HINT_QTWAYLAND_CONTENT_ORIENTATION "SDL_QTWAYLAND_CONTENT_ORIENTATION" + +/** + * \brief Flags to set on QtWayland windows to integrate with the native window manager. + * + * On QtWayland platforms, this hint controls the flags to set on the windows. + * For example, on Sailfish OS "OverridesSystemGestures" disables swipe gestures. + * + * This variable is a space-separated list of the following values (empty = no flags): + * "OverridesSystemGestures", "StaysOnTop", "BypassWindowManager" + */ +#define SDL_HINT_QTWAYLAND_WINDOW_FLAGS "SDL_QTWAYLAND_WINDOW_FLAGS" + +/** +* \brief A string specifying SDL's threads stack size in bytes or "0" for the backend's default size +* +* Use this hint in case you need to set SDL's threads stack size to other than the default. +* This is specially useful if you build SDL against a non glibc libc library (such as musl) which +* provides a relatively small default thread stack size (a few kilobytes versus the default 8MB glibc uses). +* Support for this hint is currently available only in the pthread, Windows, and PSP backend. +* +* Instead of this hint, in 2.0.9 and later, you can use +* SDL_CreateThreadWithStackSize(). This hint only works with the classic +* SDL_CreateThread(). +*/ +#define SDL_HINT_THREAD_STACK_SIZE "SDL_THREAD_STACK_SIZE" + +/** + * \brief If set to 1, then do not allow high-DPI windows. ("Retina" on Mac and iOS) + */ +#define SDL_HINT_VIDEO_HIGHDPI_DISABLED "SDL_VIDEO_HIGHDPI_DISABLED" + +/** + * \brief A variable that determines whether ctrl+click should generate a right-click event on Mac + * + * If present, holding ctrl while left clicking will generate a right click + * event when on Mac. + */ +#define SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK "SDL_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK" + +/** +* \brief A variable specifying which shader compiler to preload when using the Chrome ANGLE binaries +* +* SDL has EGL and OpenGL ES2 support on Windows via the ANGLE project. It +* can use two different sets of binaries, those compiled by the user from source +* or those provided by the Chrome browser. In the later case, these binaries require +* that SDL loads a DLL providing the shader compiler. +* +* This variable can be set to the following values: +* "d3dcompiler_46.dll" - default, best for Vista or later. +* "d3dcompiler_43.dll" - for XP support. +* "none" - do not load any library, useful if you compiled ANGLE from source and included the compiler in your binaries. +* +*/ +#define SDL_HINT_VIDEO_WIN_D3DCOMPILER "SDL_VIDEO_WIN_D3DCOMPILER" + +/** +* \brief A variable that is the address of another SDL_Window* (as a hex string formatted with "%p"). +* +* If this hint is set before SDL_CreateWindowFrom() and the SDL_Window* it is set to has +* SDL_WINDOW_OPENGL set (and running on WGL only, currently), then two things will occur on the newly +* created SDL_Window: +* +* 1. Its pixel format will be set to the same pixel format as this SDL_Window. This is +* needed for example when sharing an OpenGL context across multiple windows. +* +* 2. The flag SDL_WINDOW_OPENGL will be set on the new window so it can be used for +* OpenGL rendering. +* +* This variable can be set to the following values: +* The address (as a string "%p") of the SDL_Window* that new windows created with SDL_CreateWindowFrom() should +* share a pixel format with. +*/ +#define SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT "SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT" + +/** + * \brief A URL to a WinRT app's privacy policy + * + * All network-enabled WinRT apps must make a privacy policy available to its + * users. On Windows 8, 8.1, and RT, Microsoft mandates that this policy be + * be available in the Windows Settings charm, as accessed from within the app. + * SDL provides code to add a URL-based link there, which can point to the app's + * privacy policy. + * + * To setup a URL to an app's privacy policy, set SDL_HINT_WINRT_PRIVACY_POLICY_URL + * before calling any SDL_Init() functions. The contents of the hint should + * be a valid URL. For example, "http://www.example.com". + * + * The default value is "", which will prevent SDL from adding a privacy policy + * link to the Settings charm. This hint should only be set during app init. + * + * The label text of an app's "Privacy Policy" link may be customized via another + * hint, SDL_HINT_WINRT_PRIVACY_POLICY_LABEL. + * + * Please note that on Windows Phone, Microsoft does not provide standard UI + * for displaying a privacy policy link, and as such, SDL_HINT_WINRT_PRIVACY_POLICY_URL + * will not get used on that platform. Network-enabled phone apps should display + * their privacy policy through some other, in-app means. + */ +#define SDL_HINT_WINRT_PRIVACY_POLICY_URL "SDL_WINRT_PRIVACY_POLICY_URL" + +/** \brief Label text for a WinRT app's privacy policy link + * + * Network-enabled WinRT apps must include a privacy policy. On Windows 8, 8.1, and RT, + * Microsoft mandates that this policy be available via the Windows Settings charm. + * SDL provides code to add a link there, with its label text being set via the + * optional hint, SDL_HINT_WINRT_PRIVACY_POLICY_LABEL. + * + * Please note that a privacy policy's contents are not set via this hint. A separate + * hint, SDL_HINT_WINRT_PRIVACY_POLICY_URL, is used to link to the actual text of the + * policy. + * + * The contents of this hint should be encoded as a UTF8 string. + * + * The default value is "Privacy Policy". This hint should only be set during app + * initialization, preferably before any calls to SDL_Init(). + * + * For additional information on linking to a privacy policy, see the documentation for + * SDL_HINT_WINRT_PRIVACY_POLICY_URL. + */ +#define SDL_HINT_WINRT_PRIVACY_POLICY_LABEL "SDL_WINRT_PRIVACY_POLICY_LABEL" + +/** \brief Allows back-button-press events on Windows Phone to be marked as handled + * + * Windows Phone devices typically feature a Back button. When pressed, + * the OS will emit back-button-press events, which apps are expected to + * handle in an appropriate manner. If apps do not explicitly mark these + * events as 'Handled', then the OS will invoke its default behavior for + * unhandled back-button-press events, which on Windows Phone 8 and 8.1 is to + * terminate the app (and attempt to switch to the previous app, or to the + * device's home screen). + * + * Setting the SDL_HINT_WINRT_HANDLE_BACK_BUTTON hint to "1" will cause SDL + * to mark back-button-press events as Handled, if and when one is sent to + * the app. + * + * Internally, Windows Phone sends back button events as parameters to + * special back-button-press callback functions. Apps that need to respond + * to back-button-press events are expected to register one or more + * callback functions for such, shortly after being launched (during the + * app's initialization phase). After the back button is pressed, the OS + * will invoke these callbacks. If the app's callback(s) do not explicitly + * mark the event as handled by the time they return, or if the app never + * registers one of these callback, the OS will consider the event + * un-handled, and it will apply its default back button behavior (terminate + * the app). + * + * SDL registers its own back-button-press callback with the Windows Phone + * OS. This callback will emit a pair of SDL key-press events (SDL_KEYDOWN + * and SDL_KEYUP), each with a scancode of SDL_SCANCODE_AC_BACK, after which + * it will check the contents of the hint, SDL_HINT_WINRT_HANDLE_BACK_BUTTON. + * If the hint's value is set to "1", the back button event's Handled + * property will get set to 'true'. If the hint's value is set to something + * else, or if it is unset, SDL will leave the event's Handled property + * alone. (By default, the OS sets this property to 'false', to note.) + * + * SDL apps can either set SDL_HINT_WINRT_HANDLE_BACK_BUTTON well before a + * back button is pressed, or can set it in direct-response to a back button + * being pressed. + * + * In order to get notified when a back button is pressed, SDL apps should + * register a callback function with SDL_AddEventWatch(), and have it listen + * for SDL_KEYDOWN events that have a scancode of SDL_SCANCODE_AC_BACK. + * (Alternatively, SDL_KEYUP events can be listened-for. Listening for + * either event type is suitable.) Any value of SDL_HINT_WINRT_HANDLE_BACK_BUTTON + * set by such a callback, will be applied to the OS' current + * back-button-press event. + * + * More details on back button behavior in Windows Phone apps can be found + * at the following page, on Microsoft's developer site: + * http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj247550(v=vs.105).aspx + */ +#define SDL_HINT_WINRT_HANDLE_BACK_BUTTON "SDL_WINRT_HANDLE_BACK_BUTTON" + +/** + * \brief A variable that dictates policy for fullscreen Spaces on Mac OS X. + * + * This hint only applies to Mac OS X. + * + * The variable can be set to the following values: + * "0" - Disable Spaces support (FULLSCREEN_DESKTOP won't use them and + * SDL_WINDOW_RESIZABLE windows won't offer the "fullscreen" + * button on their titlebars). + * "1" - Enable Spaces support (FULLSCREEN_DESKTOP will use them and + * SDL_WINDOW_RESIZABLE windows will offer the "fullscreen" + * button on their titlebars). + * + * The default value is "1". Spaces are disabled regardless of this hint if + * the OS isn't at least Mac OS X Lion (10.7). This hint must be set before + * any windows are created. + */ +#define SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES "SDL_VIDEO_MAC_FULLSCREEN_SPACES" + +/** +* \brief When set don't force the SDL app to become a foreground process +* +* This hint only applies to Mac OS X. +* +*/ +#define SDL_HINT_MAC_BACKGROUND_APP "SDL_MAC_BACKGROUND_APP" + +/** + * \brief Android APK expansion main file version. Should be a string number like "1", "2" etc. + * + * Must be set together with SDL_HINT_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION. + * + * If both hints were set then SDL_RWFromFile() will look into expansion files + * after a given relative path was not found in the internal storage and assets. + * + * By default this hint is not set and the APK expansion files are not searched. + */ +#define SDL_HINT_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION "SDL_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION" + +/** + * \brief Android APK expansion patch file version. Should be a string number like "1", "2" etc. + * + * Must be set together with SDL_HINT_ANDROID_APK_EXPANSION_MAIN_FILE_VERSION. + * + * If both hints were set then SDL_RWFromFile() will look into expansion files + * after a given relative path was not found in the internal storage and assets. + * + * By default this hint is not set and the APK expansion files are not searched. + */ +#define SDL_HINT_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION "SDL_ANDROID_APK_EXPANSION_PATCH_FILE_VERSION" + +/** + * \brief A variable to control whether certain IMEs should handle text editing internally instead of sending SDL_TEXTEDITING events. + * + * The variable can be set to the following values: + * "0" - SDL_TEXTEDITING events are sent, and it is the application's + * responsibility to render the text from these events and + * differentiate it somehow from committed text. (default) + * "1" - If supported by the IME then SDL_TEXTEDITING events are not sent, + * and text that is being composed will be rendered in its own UI. + */ +#define SDL_HINT_IME_INTERNAL_EDITING "SDL_IME_INTERNAL_EDITING" + +/** + * \brief A variable to control whether we trap the Android back button to handle it manually. + * This is necessary for the right mouse button to work on some Android devices, or + * to be able to trap the back button for use in your code reliably. If set to true, + * the back button will show up as an SDL_KEYDOWN / SDL_KEYUP pair with a keycode of + * SDL_SCANCODE_AC_BACK. + * + * The variable can be set to the following values: + * "0" - Back button will be handled as usual for system. (default) + * "1" - Back button will be trapped, allowing you to handle the key press + * manually. (This will also let right mouse click work on systems + * where the right mouse button functions as back.) + * + * The value of this hint is used at runtime, so it can be changed at any time. + */ +#define SDL_HINT_ANDROID_TRAP_BACK_BUTTON "SDL_ANDROID_TRAP_BACK_BUTTON" + +/** + * \brief A variable to control whether the event loop will block itself when the app is paused. + * + * The variable can be set to the following values: + * "0" - Non blocking. + * "1" - Blocking. (default) + * + * The value should be set before SDL is initialized. + */ +#define SDL_HINT_ANDROID_BLOCK_ON_PAUSE "SDL_ANDROID_BLOCK_ON_PAUSE" + + /** + * \brief A variable to control whether the return key on the soft keyboard + * should hide the soft keyboard on Android and iOS. + * + * The variable can be set to the following values: + * "0" - The return key will be handled as a key event. This is the behaviour of SDL <= 2.0.3. (default) + * "1" - The return key will hide the keyboard. + * + * The value of this hint is used at runtime, so it can be changed at any time. + */ +#define SDL_HINT_RETURN_KEY_HIDES_IME "SDL_RETURN_KEY_HIDES_IME" + +/** + * \brief override the binding element for keyboard inputs for Emscripten builds + * + * This hint only applies to the emscripten platform + * + * The variable can be one of + * "#window" - The javascript window object (this is the default) + * "#document" - The javascript document object + * "#screen" - the javascript window.screen object + * "#canvas" - the WebGL canvas element + * any other string without a leading # sign applies to the element on the page with that ID. + */ +#define SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT "SDL_EMSCRIPTEN_KEYBOARD_ELEMENT" + +/** + * \brief Tell SDL not to catch the SIGINT or SIGTERM signals. + * + * This hint only applies to Unix-like platforms. + * + * The variable can be set to the following values: + * "0" - SDL will install a SIGINT and SIGTERM handler, and when it + * catches a signal, convert it into an SDL_QUIT event. + * "1" - SDL will not install a signal handler at all. + */ +#define SDL_HINT_NO_SIGNAL_HANDLERS "SDL_NO_SIGNAL_HANDLERS" + +/** + * \brief Tell SDL not to generate window-close events for Alt+F4 on Windows. + * + * The variable can be set to the following values: + * "0" - SDL will generate a window-close event when it sees Alt+F4. + * "1" - SDL will only do normal key handling for Alt+F4. + */ +#define SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4 "SDL_WINDOWS_NO_CLOSE_ON_ALT_F4" + +/** + * \brief Prevent SDL from using version 4 of the bitmap header when saving BMPs. + * + * The bitmap header version 4 is required for proper alpha channel support and + * SDL will use it when required. Should this not be desired, this hint can + * force the use of the 40 byte header version which is supported everywhere. + * + * The variable can be set to the following values: + * "0" - Surfaces with a colorkey or an alpha channel are saved to a + * 32-bit BMP file with an alpha mask. SDL will use the bitmap + * header version 4 and set the alpha mask accordingly. + * "1" - Surfaces with a colorkey or an alpha channel are saved to a + * 32-bit BMP file without an alpha mask. The alpha channel data + * will be in the file, but applications are going to ignore it. + * + * The default value is "0". + */ +#define SDL_HINT_BMP_SAVE_LEGACY_FORMAT "SDL_BMP_SAVE_LEGACY_FORMAT" + +/** + * \brief Tell SDL not to name threads on Windows with the 0x406D1388 Exception. + * The 0x406D1388 Exception is a trick used to inform Visual Studio of a + * thread's name, but it tends to cause problems with other debuggers, + * and the .NET runtime. Note that SDL 2.0.6 and later will still use + * the (safer) SetThreadDescription API, introduced in the Windows 10 + * Creators Update, if available. + * + * The variable can be set to the following values: + * "0" - SDL will raise the 0x406D1388 Exception to name threads. + * This is the default behavior of SDL <= 2.0.4. + * "1" - SDL will not raise this exception, and threads will be unnamed. (default) + * This is necessary with .NET languages or debuggers that aren't Visual Studio. + */ +#define SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING "SDL_WINDOWS_DISABLE_THREAD_NAMING" + +/** + * \brief Tell SDL which Dispmanx layer to use on a Raspberry PI + * + * Also known as Z-order. The variable can take a negative or positive value. + * The default is 10000. + */ +#define SDL_HINT_RPI_VIDEO_LAYER "SDL_RPI_VIDEO_LAYER" + +/** + * \brief Tell the video driver that we only want a double buffer. + * + * By default, most lowlevel 2D APIs will use a triple buffer scheme that + * wastes no CPU time on waiting for vsync after issuing a flip, but + * introduces a frame of latency. On the other hand, using a double buffer + * scheme instead is recommended for cases where low latency is an important + * factor because we save a whole frame of latency. + * We do so by waiting for vsync immediately after issuing a flip, usually just + * after eglSwapBuffers call in the backend's *_SwapWindow function. + * + * Since it's driver-specific, it's only supported where possible and + * implemented. Currently supported the following drivers: + * - KMSDRM (kmsdrm) + * - Raspberry Pi (raspberrypi) + */ +#define SDL_HINT_VIDEO_DOUBLE_BUFFER "SDL_VIDEO_DOUBLE_BUFFER" + +/** + * \brief A variable controlling what driver to use for OpenGL ES contexts. + * + * On some platforms, currently Windows and X11, OpenGL drivers may support + * creating contexts with an OpenGL ES profile. By default SDL uses these + * profiles, when available, otherwise it attempts to load an OpenGL ES + * library, e.g. that provided by the ANGLE project. This variable controls + * whether SDL follows this default behaviour or will always load an + * OpenGL ES library. + * + * Circumstances where this is useful include + * - Testing an app with a particular OpenGL ES implementation, e.g ANGLE, + * or emulator, e.g. those from ARM, Imagination or Qualcomm. + * - Resolving OpenGL ES function addresses at link time by linking with + * the OpenGL ES library instead of querying them at run time with + * SDL_GL_GetProcAddress(). + * + * Caution: for an application to work with the default behaviour across + * different OpenGL drivers it must query the OpenGL ES function + * addresses at run time using SDL_GL_GetProcAddress(). + * + * This variable is ignored on most platforms because OpenGL ES is native + * or not supported. + * + * This variable can be set to the following values: + * "0" - Use ES profile of OpenGL, if available. (Default when not set.) + * "1" - Load OpenGL ES library using the default library names. + * + */ +#define SDL_HINT_OPENGL_ES_DRIVER "SDL_OPENGL_ES_DRIVER" + +/** + * \brief A variable controlling speed/quality tradeoff of audio resampling. + * + * If available, SDL can use libsamplerate ( http://www.mega-nerd.com/SRC/ ) + * to handle audio resampling. There are different resampling modes available + * that produce different levels of quality, using more CPU. + * + * If this hint isn't specified to a valid setting, or libsamplerate isn't + * available, SDL will use the default, internal resampling algorithm. + * + * Note that this is currently only applicable to resampling audio that is + * being written to a device for playback or audio being read from a device + * for capture. SDL_AudioCVT always uses the default resampler (although this + * might change for SDL 2.1). + * + * This hint is currently only checked at audio subsystem initialization. + * + * This variable can be set to the following values: + * + * "0" or "default" - Use SDL's internal resampling (Default when not set - low quality, fast) + * "1" or "fast" - Use fast, slightly higher quality resampling, if available + * "2" or "medium" - Use medium quality resampling, if available + * "3" or "best" - Use high quality resampling, if available + */ +#define SDL_HINT_AUDIO_RESAMPLING_MODE "SDL_AUDIO_RESAMPLING_MODE" + +/** + * \brief A variable controlling the audio category on iOS and Mac OS X + * + * This variable can be set to the following values: + * + * "ambient" - Use the AVAudioSessionCategoryAmbient audio category, will be muted by the phone mute switch (default) + * "playback" - Use the AVAudioSessionCategoryPlayback category + * + * For more information, see Apple's documentation: + * https://developer.apple.com/library/content/documentation/Audio/Conceptual/AudioSessionProgrammingGuide/AudioSessionCategoriesandModes/AudioSessionCategoriesandModes.html + */ +#define SDL_HINT_AUDIO_CATEGORY "SDL_AUDIO_CATEGORY" + +/** + * \brief A variable controlling whether the 2D render API is compatible or efficient. + * + * This variable can be set to the following values: + * + * "0" - Don't use batching to make rendering more efficient. + * "1" - Use batching, but might cause problems if app makes its own direct OpenGL calls. + * + * Up to SDL 2.0.9, the render API would draw immediately when requested. Now + * it batches up draw requests and sends them all to the GPU only when forced + * to (during SDL_RenderPresent, when changing render targets, by updating a + * texture that the batch needs, etc). This is significantly more efficient, + * but it can cause problems for apps that expect to render on top of the + * render API's output. As such, SDL will disable batching if a specific + * render backend is requested (since this might indicate that the app is + * planning to use the underlying graphics API directly). This hint can + * be used to explicitly request batching in this instance. It is a contract + * that you will either never use the underlying graphics API directly, or + * if you do, you will call SDL_RenderFlush() before you do so any current + * batch goes to the GPU before your work begins. Not following this contract + * will result in undefined behavior. + */ +#define SDL_HINT_RENDER_BATCHING "SDL_RENDER_BATCHING" + + +/** + * \brief A variable controlling whether SDL logs all events pushed onto its internal queue. + * + * This variable can be set to the following values: + * + * "0" - Don't log any events (default) + * "1" - Log all events except mouse and finger motion, which are pretty spammy. + * "2" - Log all events. + * + * This is generally meant to be used to debug SDL itself, but can be useful + * for application developers that need better visibility into what is going + * on in the event queue. Logged events are sent through SDL_Log(), which + * means by default they appear on stdout on most platforms or maybe + * OutputDebugString() on Windows, and can be funneled by the app with + * SDL_LogSetOutputFunction(), etc. + * + * This hint can be toggled on and off at runtime, if you only need to log + * events for a small subset of program execution. + */ +#define SDL_HINT_EVENT_LOGGING "SDL_EVENT_LOGGING" + + + +/** + * \brief Controls how the size of the RIFF chunk affects the loading of a WAVE file. + * + * The size of the RIFF chunk (which includes all the sub-chunks of the WAVE + * file) is not always reliable. In case the size is wrong, it's possible to + * just ignore it and step through the chunks until a fixed limit is reached. + * + * Note that files that have trailing data unrelated to the WAVE file or + * corrupt files may slow down the loading process without a reliable boundary. + * By default, SDL stops after 10000 chunks to prevent wasting time. Use the + * environment variable SDL_WAVE_CHUNK_LIMIT to adjust this value. + * + * This variable can be set to the following values: + * + * "force" - Always use the RIFF chunk size as a boundary for the chunk search + * "ignorezero" - Like "force", but a zero size searches up to 4 GiB (default) + * "ignore" - Ignore the RIFF chunk size and always search up to 4 GiB + * "maximum" - Search for chunks until the end of file (not recommended) + */ +#define SDL_HINT_WAVE_RIFF_CHUNK_SIZE "SDL_WAVE_RIFF_CHUNK_SIZE" + +/** + * \brief Controls how a truncated WAVE file is handled. + * + * A WAVE file is considered truncated if any of the chunks are incomplete or + * the data chunk size is not a multiple of the block size. By default, SDL + * decodes until the first incomplete block, as most applications seem to do. + * + * This variable can be set to the following values: + * + * "verystrict" - Raise an error if the file is truncated + * "strict" - Like "verystrict", but the size of the RIFF chunk is ignored + * "dropframe" - Decode until the first incomplete sample frame + * "dropblock" - Decode until the first incomplete block (default) + */ +#define SDL_HINT_WAVE_TRUNCATION "SDL_WAVE_TRUNCATION" + +/** + * \brief Controls how the fact chunk affects the loading of a WAVE file. + * + * The fact chunk stores information about the number of samples of a WAVE + * file. The Standards Update from Microsoft notes that this value can be used + * to 'determine the length of the data in seconds'. This is especially useful + * for compressed formats (for which this is a mandatory chunk) if they produce + * multiple sample frames per block and truncating the block is not allowed. + * The fact chunk can exactly specify how many sample frames there should be + * in this case. + * + * Unfortunately, most application seem to ignore the fact chunk and so SDL + * ignores it by default as well. + * + * This variable can be set to the following values: + * + * "truncate" - Use the number of samples to truncate the wave data if + * the fact chunk is present and valid + * "strict" - Like "truncate", but raise an error if the fact chunk + * is invalid, not present for non-PCM formats, or if the + * data chunk doesn't have that many samples + * "ignorezero" - Like "truncate", but ignore fact chunk if the number of + * samples is zero + * "ignore" - Ignore fact chunk entirely (default) + */ +#define SDL_HINT_WAVE_FACT_CHUNK "SDL_WAVE_FACT_CHUNK" + +/* + * \brief Override for SDL_GetDisplayUsableBounds() + * + * If set, this hint will override the expected results for + * SDL_GetDisplayUsableBounds() for display index 0. Generally you don't want + * to do this, but this allows an embedded system to request that some of the + * screen be reserved for other uses when paired with a well-behaved + * application. + * + * The contents of this hint must be 4 comma-separated integers, the first + * is the bounds x, then y, width and height, in that order. + */ +#define SDL_HINT_DISPLAY_USABLE_BOUNDS "SDL_DISPLAY_USABLE_BOUNDS" + +/** + * \brief An enumeration of hint priorities + */ +typedef enum +{ + SDL_HINT_DEFAULT, + SDL_HINT_NORMAL, + SDL_HINT_OVERRIDE +} SDL_HintPriority; + + +/** + * \brief Set a hint with a specific priority + * + * The priority controls the behavior when setting a hint that already + * has a value. Hints will replace existing hints of their priority and + * lower. Environment variables are considered to have override priority. + * + * \return SDL_TRUE if the hint was set, SDL_FALSE otherwise + */ +extern DECLSPEC SDL_bool SDLCALL SDL_SetHintWithPriority(const char *name, + const char *value, + SDL_HintPriority priority); + +/** + * \brief Set a hint with normal priority + * + * \return SDL_TRUE if the hint was set, SDL_FALSE otherwise + */ +extern DECLSPEC SDL_bool SDLCALL SDL_SetHint(const char *name, + const char *value); + +/** + * \brief Get a hint + * + * \return The string value of a hint variable. + */ +extern DECLSPEC const char * SDLCALL SDL_GetHint(const char *name); + +/** + * \brief Get a hint + * + * \return The boolean value of a hint variable. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_GetHintBoolean(const char *name, SDL_bool default_value); + +/** + * \brief type definition of the hint callback function. + */ +typedef void (SDLCALL *SDL_HintCallback)(void *userdata, const char *name, const char *oldValue, const char *newValue); + +/** + * \brief Add a function to watch a particular hint + * + * \param name The hint to watch + * \param callback The function to call when the hint value changes + * \param userdata A pointer to pass to the callback function + */ +extern DECLSPEC void SDLCALL SDL_AddHintCallback(const char *name, + SDL_HintCallback callback, + void *userdata); + +/** + * \brief Remove a function watching a particular hint + * + * \param name The hint being watched + * \param callback The function being called when the hint value changes + * \param userdata A pointer being passed to the callback function + */ +extern DECLSPEC void SDLCALL SDL_DelHintCallback(const char *name, + SDL_HintCallback callback, + void *userdata); + +/** + * \brief Clear all hints + * + * This function is called during SDL_Quit() to free stored hints. + */ +extern DECLSPEC void SDLCALL SDL_ClearHints(void); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_hints_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_joystick.h b/thirdparty/include/SDL2/SDL_joystick.h new file mode 100644 index 000000000..a0dd7205d --- /dev/null +++ b/thirdparty/include/SDL2/SDL_joystick.h @@ -0,0 +1,418 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_joystick.h + * + * Include file for SDL joystick event handling + * + * The term "device_index" identifies currently plugged in joystick devices between 0 and SDL_NumJoysticks(), with the exact joystick + * behind a device_index changing as joysticks are plugged and unplugged. + * + * The term "instance_id" is the current instantiation of a joystick device in the system, if the joystick is removed and then re-inserted + * then it will get a new instance_id, instance_id's are monotonically increasing identifiers of a joystick plugged in. + * + * The term JoystickGUID is a stable 128-bit identifier for a joystick device that does not change over time, it identifies class of + * the device (a X360 wired controller for example). This identifier is platform dependent. + * + * + */ + +#ifndef SDL_joystick_h_ +#define SDL_joystick_h_ + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \file SDL_joystick.h + * + * In order to use these functions, SDL_Init() must have been called + * with the ::SDL_INIT_JOYSTICK flag. This causes SDL to scan the system + * for joysticks, and load appropriate drivers. + * + * If you would like to receive joystick updates while the application + * is in the background, you should set the following hint before calling + * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS + */ + +/** + * The joystick structure used to identify an SDL joystick + */ +struct _SDL_Joystick; +typedef struct _SDL_Joystick SDL_Joystick; + +/* A structure that encodes the stable unique id for a joystick device */ +typedef struct { + Uint8 data[16]; +} SDL_JoystickGUID; + +/** + * This is a unique ID for a joystick for the time it is connected to the system, + * and is never reused for the lifetime of the application. If the joystick is + * disconnected and reconnected, it will get a new ID. + * + * The ID value starts at 0 and increments from there. The value -1 is an invalid ID. + */ +typedef Sint32 SDL_JoystickID; + +typedef enum +{ + SDL_JOYSTICK_TYPE_UNKNOWN, + SDL_JOYSTICK_TYPE_GAMECONTROLLER, + SDL_JOYSTICK_TYPE_WHEEL, + SDL_JOYSTICK_TYPE_ARCADE_STICK, + SDL_JOYSTICK_TYPE_FLIGHT_STICK, + SDL_JOYSTICK_TYPE_DANCE_PAD, + SDL_JOYSTICK_TYPE_GUITAR, + SDL_JOYSTICK_TYPE_DRUM_KIT, + SDL_JOYSTICK_TYPE_ARCADE_PAD, + SDL_JOYSTICK_TYPE_THROTTLE +} SDL_JoystickType; + +typedef enum +{ + SDL_JOYSTICK_POWER_UNKNOWN = -1, + SDL_JOYSTICK_POWER_EMPTY, /* <= 5% */ + SDL_JOYSTICK_POWER_LOW, /* <= 20% */ + SDL_JOYSTICK_POWER_MEDIUM, /* <= 70% */ + SDL_JOYSTICK_POWER_FULL, /* <= 100% */ + SDL_JOYSTICK_POWER_WIRED, + SDL_JOYSTICK_POWER_MAX +} SDL_JoystickPowerLevel; + +/* Function prototypes */ + +/** + * Locking for multi-threaded access to the joystick API + * + * If you are using the joystick API or handling events from multiple threads + * you should use these locking functions to protect access to the joysticks. + * + * In particular, you are guaranteed that the joystick list won't change, so + * the API functions that take a joystick index will be valid, and joystick + * and game controller events will not be delivered. + */ +extern DECLSPEC void SDLCALL SDL_LockJoysticks(void); +extern DECLSPEC void SDLCALL SDL_UnlockJoysticks(void); + +/** + * Count the number of joysticks attached to the system right now + */ +extern DECLSPEC int SDLCALL SDL_NumJoysticks(void); + +/** + * Get the implementation dependent name of a joystick. + * This can be called before any joysticks are opened. + * If no name can be found, this function returns NULL. + */ +extern DECLSPEC const char *SDLCALL SDL_JoystickNameForIndex(int device_index); + +/** + * Get the player index of a joystick, or -1 if it's not available + * This can be called before any joysticks are opened. + */ +extern DECLSPEC int SDLCALL SDL_JoystickGetDevicePlayerIndex(int device_index); + +/** + * Return the GUID for the joystick at this index + * This can be called before any joysticks are opened. + */ +extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetDeviceGUID(int device_index); + +/** + * Get the USB vendor ID of a joystick, if available. + * This can be called before any joysticks are opened. + * If the vendor ID isn't available this function returns 0. + */ +extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceVendor(int device_index); + +/** + * Get the USB product ID of a joystick, if available. + * This can be called before any joysticks are opened. + * If the product ID isn't available this function returns 0. + */ +extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceProduct(int device_index); + +/** + * Get the product version of a joystick, if available. + * This can be called before any joysticks are opened. + * If the product version isn't available this function returns 0. + */ +extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceProductVersion(int device_index); + +/** + * Get the type of a joystick, if available. + * This can be called before any joysticks are opened. + */ +extern DECLSPEC SDL_JoystickType SDLCALL SDL_JoystickGetDeviceType(int device_index); + +/** + * Get the instance ID of a joystick. + * This can be called before any joysticks are opened. + * If the index is out of range, this function will return -1. + */ +extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickGetDeviceInstanceID(int device_index); + +/** + * Open a joystick for use. + * The index passed as an argument refers to the N'th joystick on the system. + * This index is not the value which will identify this joystick in future + * joystick events. The joystick's instance id (::SDL_JoystickID) will be used + * there instead. + * + * \return A joystick identifier, or NULL if an error occurred. + */ +extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickOpen(int device_index); + +/** + * Return the SDL_Joystick associated with an instance id. + */ +extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickFromInstanceID(SDL_JoystickID instance_id); + +/** + * Return the SDL_Joystick associated with a player index. + */ +extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickFromPlayerIndex(int player_index); + +/** + * Return the name for this currently opened joystick. + * If no name can be found, this function returns NULL. + */ +extern DECLSPEC const char *SDLCALL SDL_JoystickName(SDL_Joystick * joystick); + +/** + * Get the player index of an opened joystick, or -1 if it's not available + * + * For XInput controllers this returns the XInput user index. + */ +extern DECLSPEC int SDLCALL SDL_JoystickGetPlayerIndex(SDL_Joystick * joystick); + +/** + * Set the player index of an opened joystick + */ +extern DECLSPEC void SDLCALL SDL_JoystickSetPlayerIndex(SDL_Joystick * joystick, int player_index); + +/** + * Return the GUID for this opened joystick + */ +extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUID(SDL_Joystick * joystick); + +/** + * Get the USB vendor ID of an opened joystick, if available. + * If the vendor ID isn't available this function returns 0. + */ +extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetVendor(SDL_Joystick * joystick); + +/** + * Get the USB product ID of an opened joystick, if available. + * If the product ID isn't available this function returns 0. + */ +extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProduct(SDL_Joystick * joystick); + +/** + * Get the product version of an opened joystick, if available. + * If the product version isn't available this function returns 0. + */ +extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProductVersion(SDL_Joystick * joystick); + +/** + * Get the type of an opened joystick. + */ +extern DECLSPEC SDL_JoystickType SDLCALL SDL_JoystickGetType(SDL_Joystick * joystick); + +/** + * Return a string representation for this guid. pszGUID must point to at least 33 bytes + * (32 for the string plus a NULL terminator). + */ +extern DECLSPEC void SDLCALL SDL_JoystickGetGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID); + +/** + * Convert a string into a joystick guid + */ +extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUIDFromString(const char *pchGUID); + +/** + * Returns SDL_TRUE if the joystick has been opened and currently connected, or SDL_FALSE if it has not. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAttached(SDL_Joystick * joystick); + +/** + * Get the instance ID of an opened joystick or -1 if the joystick is invalid. + */ +extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickInstanceID(SDL_Joystick * joystick); + +/** + * Get the number of general axis controls on a joystick. + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick * joystick); + +/** + * Get the number of trackballs on a joystick. + * + * Joystick trackballs have only relative motion events associated + * with them and their state cannot be polled. + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick * joystick); + +/** + * Get the number of POV hats on a joystick. + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick * joystick); + +/** + * Get the number of buttons on a joystick. + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick * joystick); + +/** + * Update the current state of the open joysticks. + * + * This is called automatically by the event loop if any joystick + * events are enabled. + */ +extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void); + +/** + * Enable/disable joystick event polling. + * + * If joystick events are disabled, you must call SDL_JoystickUpdate() + * yourself and check the state of the joystick when you want joystick + * information. + * + * The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE. + */ +extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state); + +#define SDL_JOYSTICK_AXIS_MAX 32767 +#define SDL_JOYSTICK_AXIS_MIN -32768 +/** + * Get the current state of an axis control on a joystick. + * + * The state is a value ranging from -32768 to 32767. + * + * The axis indices start at index 0. + */ +extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick * joystick, + int axis); + +/** + * Get the initial state of an axis control on a joystick. + * + * The state is a value ranging from -32768 to 32767. + * + * The axis indices start at index 0. + * + * \return SDL_TRUE if this axis has any initial value, or SDL_FALSE if not. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAxisInitialState(SDL_Joystick * joystick, + int axis, Sint16 *state); + +/** + * \name Hat positions + */ +/* @{ */ +#define SDL_HAT_CENTERED 0x00 +#define SDL_HAT_UP 0x01 +#define SDL_HAT_RIGHT 0x02 +#define SDL_HAT_DOWN 0x04 +#define SDL_HAT_LEFT 0x08 +#define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP) +#define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN) +#define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP) +#define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN) +/* @} */ + +/** + * Get the current state of a POV hat on a joystick. + * + * The hat indices start at index 0. + * + * \return The return value is one of the following positions: + * - ::SDL_HAT_CENTERED + * - ::SDL_HAT_UP + * - ::SDL_HAT_RIGHT + * - ::SDL_HAT_DOWN + * - ::SDL_HAT_LEFT + * - ::SDL_HAT_RIGHTUP + * - ::SDL_HAT_RIGHTDOWN + * - ::SDL_HAT_LEFTUP + * - ::SDL_HAT_LEFTDOWN + */ +extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick * joystick, + int hat); + +/** + * Get the ball axis change since the last poll. + * + * \return 0, or -1 if you passed it invalid parameters. + * + * The ball indices start at index 0. + */ +extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick * joystick, + int ball, int *dx, int *dy); + +/** + * Get the current state of a button on a joystick. + * + * The button indices start at index 0. + */ +extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick * joystick, + int button); + +/** + * Trigger a rumble effect + * Each call to this function cancels any previous rumble effect, and calling it with 0 intensity stops any rumbling. + * + * \param joystick The joystick to vibrate + * \param low_frequency_rumble The intensity of the low frequency (left) rumble motor, from 0 to 0xFFFF + * \param high_frequency_rumble The intensity of the high frequency (right) rumble motor, from 0 to 0xFFFF + * \param duration_ms The duration of the rumble effect, in milliseconds + * + * \return 0, or -1 if rumble isn't supported on this joystick + */ +extern DECLSPEC int SDLCALL SDL_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms); + +/** + * Close a joystick previously opened with SDL_JoystickOpen(). + */ +extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick * joystick); + +/** + * Return the battery level of this joystick + */ +extern DECLSPEC SDL_JoystickPowerLevel SDLCALL SDL_JoystickCurrentPowerLevel(SDL_Joystick * joystick); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_joystick_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_keyboard.h b/thirdparty/include/SDL2/SDL_keyboard.h new file mode 100644 index 000000000..f6853c647 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_keyboard.h @@ -0,0 +1,217 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_keyboard.h + * + * Include file for SDL keyboard event handling + */ + +#ifndef SDL_keyboard_h_ +#define SDL_keyboard_h_ + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_keycode.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief The SDL keysym structure, used in key events. + * + * \note If you are looking for translated character input, see the ::SDL_TEXTINPUT event. + */ +typedef struct SDL_Keysym +{ + SDL_Scancode scancode; /**< SDL physical key code - see ::SDL_Scancode for details */ + SDL_Keycode sym; /**< SDL virtual key code - see ::SDL_Keycode for details */ + Uint16 mod; /**< current key modifiers */ + Uint32 unused; +} SDL_Keysym; + +/* Function prototypes */ + +/** + * \brief Get the window which currently has keyboard focus. + */ +extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void); + +/** + * \brief Get a snapshot of the current state of the keyboard. + * + * \param numkeys if non-NULL, receives the length of the returned array. + * + * \return An array of key states. Indexes into this array are obtained by using ::SDL_Scancode values. + * + * \b Example: + * \code + * const Uint8 *state = SDL_GetKeyboardState(NULL); + * if ( state[SDL_SCANCODE_RETURN] ) { + * printf(" is pressed.\n"); + * } + * \endcode + */ +extern DECLSPEC const Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys); + +/** + * \brief Get the current key modifier state for the keyboard. + */ +extern DECLSPEC SDL_Keymod SDLCALL SDL_GetModState(void); + +/** + * \brief Set the current key modifier state for the keyboard. + * + * \note This does not change the keyboard state, only the key modifier flags. + */ +extern DECLSPEC void SDLCALL SDL_SetModState(SDL_Keymod modstate); + +/** + * \brief Get the key code corresponding to the given scancode according + * to the current keyboard layout. + * + * See ::SDL_Keycode for details. + * + * \sa SDL_GetKeyName() + */ +extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode); + +/** + * \brief Get the scancode corresponding to the given key code according to the + * current keyboard layout. + * + * See ::SDL_Scancode for details. + * + * \sa SDL_GetScancodeName() + */ +extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromKey(SDL_Keycode key); + +/** + * \brief Get a human-readable name for a scancode. + * + * \return A pointer to the name for the scancode. + * If the scancode doesn't have a name, this function returns + * an empty string (""). + * + * \sa SDL_Scancode + */ +extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_Scancode scancode); + +/** + * \brief Get a scancode from a human-readable name + * + * \return scancode, or SDL_SCANCODE_UNKNOWN if the name wasn't recognized + * + * \sa SDL_Scancode + */ +extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromName(const char *name); + +/** + * \brief Get a human-readable name for a key. + * + * \return A pointer to a UTF-8 string that stays valid at least until the next + * call to this function. If you need it around any longer, you must + * copy it. If the key doesn't have a name, this function returns an + * empty string (""). + * + * \sa SDL_Keycode + */ +extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDL_Keycode key); + +/** + * \brief Get a key code from a human-readable name + * + * \return key code, or SDLK_UNKNOWN if the name wasn't recognized + * + * \sa SDL_Keycode + */ +extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromName(const char *name); + +/** + * \brief Start accepting Unicode text input events. + * This function will show the on-screen keyboard if supported. + * + * \sa SDL_StopTextInput() + * \sa SDL_SetTextInputRect() + * \sa SDL_HasScreenKeyboardSupport() + */ +extern DECLSPEC void SDLCALL SDL_StartTextInput(void); + +/** + * \brief Return whether or not Unicode text input events are enabled. + * + * \sa SDL_StartTextInput() + * \sa SDL_StopTextInput() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IsTextInputActive(void); + +/** + * \brief Stop receiving any text input events. + * This function will hide the on-screen keyboard if supported. + * + * \sa SDL_StartTextInput() + * \sa SDL_HasScreenKeyboardSupport() + */ +extern DECLSPEC void SDLCALL SDL_StopTextInput(void); + +/** + * \brief Set the rectangle used to type Unicode text inputs. + * This is used as a hint for IME and on-screen keyboard placement. + * + * \sa SDL_StartTextInput() + */ +extern DECLSPEC void SDLCALL SDL_SetTextInputRect(SDL_Rect *rect); + +/** + * \brief Returns whether the platform has some screen keyboard support. + * + * \return SDL_TRUE if some keyboard support is available else SDL_FALSE. + * + * \note Not all screen keyboard functions are supported on all platforms. + * + * \sa SDL_IsScreenKeyboardShown() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasScreenKeyboardSupport(void); + +/** + * \brief Returns whether the screen keyboard is shown for given window. + * + * \param window The window for which screen keyboard should be queried. + * + * \return SDL_TRUE if screen keyboard is shown else SDL_FALSE. + * + * \sa SDL_HasScreenKeyboardSupport() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IsScreenKeyboardShown(SDL_Window *window); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_keyboard_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_keycode.h b/thirdparty/include/SDL2/SDL_keycode.h new file mode 100644 index 000000000..a1ce7a44d --- /dev/null +++ b/thirdparty/include/SDL2/SDL_keycode.h @@ -0,0 +1,349 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_keycode.h + * + * Defines constants which identify keyboard keys and modifiers. + */ + +#ifndef SDL_keycode_h_ +#define SDL_keycode_h_ + +#include "SDL_stdinc.h" +#include "SDL_scancode.h" + +/** + * \brief The SDL virtual key representation. + * + * Values of this type are used to represent keyboard keys using the current + * layout of the keyboard. These values include Unicode values representing + * the unmodified character that would be generated by pressing the key, or + * an SDLK_* constant for those keys that do not generate characters. + * + * A special exception is the number keys at the top of the keyboard which + * always map to SDLK_0...SDLK_9, regardless of layout. + */ +typedef Sint32 SDL_Keycode; + +#define SDLK_SCANCODE_MASK (1<<30) +#define SDL_SCANCODE_TO_KEYCODE(X) (X | SDLK_SCANCODE_MASK) + +typedef enum +{ + SDLK_UNKNOWN = 0, + + SDLK_RETURN = '\r', + SDLK_ESCAPE = '\033', + SDLK_BACKSPACE = '\b', + SDLK_TAB = '\t', + SDLK_SPACE = ' ', + SDLK_EXCLAIM = '!', + SDLK_QUOTEDBL = '"', + SDLK_HASH = '#', + SDLK_PERCENT = '%', + SDLK_DOLLAR = '$', + SDLK_AMPERSAND = '&', + SDLK_QUOTE = '\'', + SDLK_LEFTPAREN = '(', + SDLK_RIGHTPAREN = ')', + SDLK_ASTERISK = '*', + SDLK_PLUS = '+', + SDLK_COMMA = ',', + SDLK_MINUS = '-', + SDLK_PERIOD = '.', + SDLK_SLASH = '/', + SDLK_0 = '0', + SDLK_1 = '1', + SDLK_2 = '2', + SDLK_3 = '3', + SDLK_4 = '4', + SDLK_5 = '5', + SDLK_6 = '6', + SDLK_7 = '7', + SDLK_8 = '8', + SDLK_9 = '9', + SDLK_COLON = ':', + SDLK_SEMICOLON = ';', + SDLK_LESS = '<', + SDLK_EQUALS = '=', + SDLK_GREATER = '>', + SDLK_QUESTION = '?', + SDLK_AT = '@', + /* + Skip uppercase letters + */ + SDLK_LEFTBRACKET = '[', + SDLK_BACKSLASH = '\\', + SDLK_RIGHTBRACKET = ']', + SDLK_CARET = '^', + SDLK_UNDERSCORE = '_', + SDLK_BACKQUOTE = '`', + SDLK_a = 'a', + SDLK_b = 'b', + SDLK_c = 'c', + SDLK_d = 'd', + SDLK_e = 'e', + SDLK_f = 'f', + SDLK_g = 'g', + SDLK_h = 'h', + SDLK_i = 'i', + SDLK_j = 'j', + SDLK_k = 'k', + SDLK_l = 'l', + SDLK_m = 'm', + SDLK_n = 'n', + SDLK_o = 'o', + SDLK_p = 'p', + SDLK_q = 'q', + SDLK_r = 'r', + SDLK_s = 's', + SDLK_t = 't', + SDLK_u = 'u', + SDLK_v = 'v', + SDLK_w = 'w', + SDLK_x = 'x', + SDLK_y = 'y', + SDLK_z = 'z', + + SDLK_CAPSLOCK = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CAPSLOCK), + + SDLK_F1 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F1), + SDLK_F2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F2), + SDLK_F3 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F3), + SDLK_F4 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F4), + SDLK_F5 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F5), + SDLK_F6 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F6), + SDLK_F7 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F7), + SDLK_F8 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F8), + SDLK_F9 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F9), + SDLK_F10 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F10), + SDLK_F11 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F11), + SDLK_F12 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F12), + + SDLK_PRINTSCREEN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PRINTSCREEN), + SDLK_SCROLLLOCK = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SCROLLLOCK), + SDLK_PAUSE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAUSE), + SDLK_INSERT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_INSERT), + SDLK_HOME = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_HOME), + SDLK_PAGEUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAGEUP), + SDLK_DELETE = '\177', + SDLK_END = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_END), + SDLK_PAGEDOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAGEDOWN), + SDLK_RIGHT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RIGHT), + SDLK_LEFT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LEFT), + SDLK_DOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DOWN), + SDLK_UP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_UP), + + SDLK_NUMLOCKCLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_NUMLOCKCLEAR), + SDLK_KP_DIVIDE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DIVIDE), + SDLK_KP_MULTIPLY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MULTIPLY), + SDLK_KP_MINUS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MINUS), + SDLK_KP_PLUS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PLUS), + SDLK_KP_ENTER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_ENTER), + SDLK_KP_1 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_1), + SDLK_KP_2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_2), + SDLK_KP_3 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_3), + SDLK_KP_4 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_4), + SDLK_KP_5 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_5), + SDLK_KP_6 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_6), + SDLK_KP_7 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_7), + SDLK_KP_8 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_8), + SDLK_KP_9 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_9), + SDLK_KP_0 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_0), + SDLK_KP_PERIOD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PERIOD), + + SDLK_APPLICATION = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_APPLICATION), + SDLK_POWER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_POWER), + SDLK_KP_EQUALS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EQUALS), + SDLK_F13 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F13), + SDLK_F14 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F14), + SDLK_F15 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F15), + SDLK_F16 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F16), + SDLK_F17 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F17), + SDLK_F18 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F18), + SDLK_F19 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F19), + SDLK_F20 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F20), + SDLK_F21 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F21), + SDLK_F22 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F22), + SDLK_F23 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F23), + SDLK_F24 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_F24), + SDLK_EXECUTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EXECUTE), + SDLK_HELP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_HELP), + SDLK_MENU = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MENU), + SDLK_SELECT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SELECT), + SDLK_STOP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_STOP), + SDLK_AGAIN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AGAIN), + SDLK_UNDO = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_UNDO), + SDLK_CUT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CUT), + SDLK_COPY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_COPY), + SDLK_PASTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PASTE), + SDLK_FIND = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_FIND), + SDLK_MUTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MUTE), + SDLK_VOLUMEUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_VOLUMEUP), + SDLK_VOLUMEDOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_VOLUMEDOWN), + SDLK_KP_COMMA = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_COMMA), + SDLK_KP_EQUALSAS400 = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EQUALSAS400), + + SDLK_ALTERASE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_ALTERASE), + SDLK_SYSREQ = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SYSREQ), + SDLK_CANCEL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CANCEL), + SDLK_CLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CLEAR), + SDLK_PRIOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PRIOR), + SDLK_RETURN2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RETURN2), + SDLK_SEPARATOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SEPARATOR), + SDLK_OUT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_OUT), + SDLK_OPER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_OPER), + SDLK_CLEARAGAIN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CLEARAGAIN), + SDLK_CRSEL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CRSEL), + SDLK_EXSEL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EXSEL), + + SDLK_KP_00 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_00), + SDLK_KP_000 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_000), + SDLK_THOUSANDSSEPARATOR = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_THOUSANDSSEPARATOR), + SDLK_DECIMALSEPARATOR = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DECIMALSEPARATOR), + SDLK_CURRENCYUNIT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CURRENCYUNIT), + SDLK_CURRENCYSUBUNIT = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CURRENCYSUBUNIT), + SDLK_KP_LEFTPAREN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LEFTPAREN), + SDLK_KP_RIGHTPAREN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_RIGHTPAREN), + SDLK_KP_LEFTBRACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LEFTBRACE), + SDLK_KP_RIGHTBRACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_RIGHTBRACE), + SDLK_KP_TAB = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_TAB), + SDLK_KP_BACKSPACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_BACKSPACE), + SDLK_KP_A = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_A), + SDLK_KP_B = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_B), + SDLK_KP_C = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_C), + SDLK_KP_D = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_D), + SDLK_KP_E = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_E), + SDLK_KP_F = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_F), + SDLK_KP_XOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_XOR), + SDLK_KP_POWER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_POWER), + SDLK_KP_PERCENT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PERCENT), + SDLK_KP_LESS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_LESS), + SDLK_KP_GREATER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_GREATER), + SDLK_KP_AMPERSAND = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_AMPERSAND), + SDLK_KP_DBLAMPERSAND = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DBLAMPERSAND), + SDLK_KP_VERTICALBAR = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_VERTICALBAR), + SDLK_KP_DBLVERTICALBAR = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DBLVERTICALBAR), + SDLK_KP_COLON = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_COLON), + SDLK_KP_HASH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_HASH), + SDLK_KP_SPACE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_SPACE), + SDLK_KP_AT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_AT), + SDLK_KP_EXCLAM = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_EXCLAM), + SDLK_KP_MEMSTORE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMSTORE), + SDLK_KP_MEMRECALL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMRECALL), + SDLK_KP_MEMCLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMCLEAR), + SDLK_KP_MEMADD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMADD), + SDLK_KP_MEMSUBTRACT = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMSUBTRACT), + SDLK_KP_MEMMULTIPLY = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMMULTIPLY), + SDLK_KP_MEMDIVIDE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_MEMDIVIDE), + SDLK_KP_PLUSMINUS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_PLUSMINUS), + SDLK_KP_CLEAR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_CLEAR), + SDLK_KP_CLEARENTRY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_CLEARENTRY), + SDLK_KP_BINARY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_BINARY), + SDLK_KP_OCTAL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_OCTAL), + SDLK_KP_DECIMAL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_DECIMAL), + SDLK_KP_HEXADECIMAL = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_HEXADECIMAL), + + SDLK_LCTRL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LCTRL), + SDLK_LSHIFT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LSHIFT), + SDLK_LALT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LALT), + SDLK_LGUI = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_LGUI), + SDLK_RCTRL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RCTRL), + SDLK_RSHIFT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RSHIFT), + SDLK_RALT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RALT), + SDLK_RGUI = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RGUI), + + SDLK_MODE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MODE), + + SDLK_AUDIONEXT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIONEXT), + SDLK_AUDIOPREV = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOPREV), + SDLK_AUDIOSTOP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOSTOP), + SDLK_AUDIOPLAY = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOPLAY), + SDLK_AUDIOMUTE = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOMUTE), + SDLK_MEDIASELECT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MEDIASELECT), + SDLK_WWW = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_WWW), + SDLK_MAIL = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_MAIL), + SDLK_CALCULATOR = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CALCULATOR), + SDLK_COMPUTER = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_COMPUTER), + SDLK_AC_SEARCH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_SEARCH), + SDLK_AC_HOME = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_HOME), + SDLK_AC_BACK = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_BACK), + SDLK_AC_FORWARD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_FORWARD), + SDLK_AC_STOP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_STOP), + SDLK_AC_REFRESH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_REFRESH), + SDLK_AC_BOOKMARKS = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AC_BOOKMARKS), + + SDLK_BRIGHTNESSDOWN = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_BRIGHTNESSDOWN), + SDLK_BRIGHTNESSUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_BRIGHTNESSUP), + SDLK_DISPLAYSWITCH = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_DISPLAYSWITCH), + SDLK_KBDILLUMTOGGLE = + SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KBDILLUMTOGGLE), + SDLK_KBDILLUMDOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KBDILLUMDOWN), + SDLK_KBDILLUMUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KBDILLUMUP), + SDLK_EJECT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EJECT), + SDLK_SLEEP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SLEEP), + SDLK_APP1 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_APP1), + SDLK_APP2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_APP2), + + SDLK_AUDIOREWIND = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOREWIND), + SDLK_AUDIOFASTFORWARD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOFASTFORWARD) +} SDL_KeyCode; + +/** + * \brief Enumeration of valid key mods (possibly OR'd together). + */ +typedef enum +{ + KMOD_NONE = 0x0000, + KMOD_LSHIFT = 0x0001, + KMOD_RSHIFT = 0x0002, + KMOD_LCTRL = 0x0040, + KMOD_RCTRL = 0x0080, + KMOD_LALT = 0x0100, + KMOD_RALT = 0x0200, + KMOD_LGUI = 0x0400, + KMOD_RGUI = 0x0800, + KMOD_NUM = 0x1000, + KMOD_CAPS = 0x2000, + KMOD_MODE = 0x4000, + KMOD_RESERVED = 0x8000 +} SDL_Keymod; + +#define KMOD_CTRL (KMOD_LCTRL|KMOD_RCTRL) +#define KMOD_SHIFT (KMOD_LSHIFT|KMOD_RSHIFT) +#define KMOD_ALT (KMOD_LALT|KMOD_RALT) +#define KMOD_GUI (KMOD_LGUI|KMOD_RGUI) + +#endif /* SDL_keycode_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_loadso.h b/thirdparty/include/SDL2/SDL_loadso.h new file mode 100644 index 000000000..89578a9f6 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_loadso.h @@ -0,0 +1,81 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_loadso.h + * + * System dependent library loading routines + * + * Some things to keep in mind: + * \li These functions only work on C function names. Other languages may + * have name mangling and intrinsic language support that varies from + * compiler to compiler. + * \li Make sure you declare your function pointers with the same calling + * convention as the actual library function. Your code will crash + * mysteriously if you do not do this. + * \li Avoid namespace collisions. If you load a symbol from the library, + * it is not defined whether or not it goes into the global symbol + * namespace for the application. If it does and it conflicts with + * symbols in your code or other shared libraries, you will not get + * the results you expect. :) + */ + +#ifndef SDL_loadso_h_ +#define SDL_loadso_h_ + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * This function dynamically loads a shared object and returns a pointer + * to the object handle (or NULL if there was an error). + * The 'sofile' parameter is a system dependent name of the object file. + */ +extern DECLSPEC void *SDLCALL SDL_LoadObject(const char *sofile); + +/** + * Given an object handle, this function looks up the address of the + * named function in the shared object and returns it. This address + * is no longer valid after calling SDL_UnloadObject(). + */ +extern DECLSPEC void *SDLCALL SDL_LoadFunction(void *handle, + const char *name); + +/** + * Unload a shared object from memory. + */ +extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_loadso_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_log.h b/thirdparty/include/SDL2/SDL_log.h new file mode 100644 index 000000000..c1751fd77 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_log.h @@ -0,0 +1,211 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_log.h + * + * Simple log messages with categories and priorities. + * + * By default logs are quiet, but if you're debugging SDL you might want: + * + * SDL_LogSetAllPriority(SDL_LOG_PRIORITY_WARN); + * + * Here's where the messages go on different platforms: + * Windows: debug output stream + * Android: log output + * Others: standard error output (stderr) + */ + +#ifndef SDL_log_h_ +#define SDL_log_h_ + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * \brief The maximum size of a log message + * + * Messages longer than the maximum size will be truncated + */ +#define SDL_MAX_LOG_MESSAGE 4096 + +/** + * \brief The predefined log categories + * + * By default the application category is enabled at the INFO level, + * the assert category is enabled at the WARN level, test is enabled + * at the VERBOSE level and all other categories are enabled at the + * CRITICAL level. + */ +typedef enum +{ + SDL_LOG_CATEGORY_APPLICATION, + SDL_LOG_CATEGORY_ERROR, + SDL_LOG_CATEGORY_ASSERT, + SDL_LOG_CATEGORY_SYSTEM, + SDL_LOG_CATEGORY_AUDIO, + SDL_LOG_CATEGORY_VIDEO, + SDL_LOG_CATEGORY_RENDER, + SDL_LOG_CATEGORY_INPUT, + SDL_LOG_CATEGORY_TEST, + + /* Reserved for future SDL library use */ + SDL_LOG_CATEGORY_RESERVED1, + SDL_LOG_CATEGORY_RESERVED2, + SDL_LOG_CATEGORY_RESERVED3, + SDL_LOG_CATEGORY_RESERVED4, + SDL_LOG_CATEGORY_RESERVED5, + SDL_LOG_CATEGORY_RESERVED6, + SDL_LOG_CATEGORY_RESERVED7, + SDL_LOG_CATEGORY_RESERVED8, + SDL_LOG_CATEGORY_RESERVED9, + SDL_LOG_CATEGORY_RESERVED10, + + /* Beyond this point is reserved for application use, e.g. + enum { + MYAPP_CATEGORY_AWESOME1 = SDL_LOG_CATEGORY_CUSTOM, + MYAPP_CATEGORY_AWESOME2, + MYAPP_CATEGORY_AWESOME3, + ... + }; + */ + SDL_LOG_CATEGORY_CUSTOM +} SDL_LogCategory; + +/** + * \brief The predefined log priorities + */ +typedef enum +{ + SDL_LOG_PRIORITY_VERBOSE = 1, + SDL_LOG_PRIORITY_DEBUG, + SDL_LOG_PRIORITY_INFO, + SDL_LOG_PRIORITY_WARN, + SDL_LOG_PRIORITY_ERROR, + SDL_LOG_PRIORITY_CRITICAL, + SDL_NUM_LOG_PRIORITIES +} SDL_LogPriority; + + +/** + * \brief Set the priority of all log categories + */ +extern DECLSPEC void SDLCALL SDL_LogSetAllPriority(SDL_LogPriority priority); + +/** + * \brief Set the priority of a particular log category + */ +extern DECLSPEC void SDLCALL SDL_LogSetPriority(int category, + SDL_LogPriority priority); + +/** + * \brief Get the priority of a particular log category + */ +extern DECLSPEC SDL_LogPriority SDLCALL SDL_LogGetPriority(int category); + +/** + * \brief Reset all priorities to default. + * + * \note This is called in SDL_Quit(). + */ +extern DECLSPEC void SDLCALL SDL_LogResetPriorities(void); + +/** + * \brief Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO + */ +extern DECLSPEC void SDLCALL SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); + +/** + * \brief Log a message with SDL_LOG_PRIORITY_VERBOSE + */ +extern DECLSPEC void SDLCALL SDL_LogVerbose(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); + +/** + * \brief Log a message with SDL_LOG_PRIORITY_DEBUG + */ +extern DECLSPEC void SDLCALL SDL_LogDebug(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); + +/** + * \brief Log a message with SDL_LOG_PRIORITY_INFO + */ +extern DECLSPEC void SDLCALL SDL_LogInfo(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); + +/** + * \brief Log a message with SDL_LOG_PRIORITY_WARN + */ +extern DECLSPEC void SDLCALL SDL_LogWarn(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); + +/** + * \brief Log a message with SDL_LOG_PRIORITY_ERROR + */ +extern DECLSPEC void SDLCALL SDL_LogError(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); + +/** + * \brief Log a message with SDL_LOG_PRIORITY_CRITICAL + */ +extern DECLSPEC void SDLCALL SDL_LogCritical(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); + +/** + * \brief Log a message with the specified category and priority. + */ +extern DECLSPEC void SDLCALL SDL_LogMessage(int category, + SDL_LogPriority priority, + SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(3); + +/** + * \brief Log a message with the specified category and priority. + */ +extern DECLSPEC void SDLCALL SDL_LogMessageV(int category, + SDL_LogPriority priority, + const char *fmt, va_list ap); + +/** + * \brief The prototype for the log output function + */ +typedef void (SDLCALL *SDL_LogOutputFunction)(void *userdata, int category, SDL_LogPriority priority, const char *message); + +/** + * \brief Get the current log output function. + */ +extern DECLSPEC void SDLCALL SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata); + +/** + * \brief This function allows you to replace the default log output + * function with one of your own. + */ +extern DECLSPEC void SDLCALL SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_log_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_main.h b/thirdparty/include/SDL2/SDL_main.h new file mode 100644 index 000000000..fcb5c17db --- /dev/null +++ b/thirdparty/include/SDL2/SDL_main.h @@ -0,0 +1,180 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_main_h_ +#define SDL_main_h_ + +#include "SDL_stdinc.h" + +/** + * \file SDL_main.h + * + * Redefine main() on some platforms so that it is called by SDL. + */ + +#ifndef SDL_MAIN_HANDLED +#if defined(__WIN32__) +/* On Windows SDL provides WinMain(), which parses the command line and passes + the arguments to your main function. + + If you provide your own WinMain(), you may define SDL_MAIN_HANDLED + */ +#define SDL_MAIN_AVAILABLE + +#elif defined(__WINRT__) +/* On WinRT, SDL provides a main function that initializes CoreApplication, + creating an instance of IFrameworkView in the process. + + Please note that #include'ing SDL_main.h is not enough to get a main() + function working. In non-XAML apps, the file, + src/main/winrt/SDL_WinRT_main_NonXAML.cpp, or a copy of it, must be compiled + into the app itself. In XAML apps, the function, SDL_WinRTRunApp must be + called, with a pointer to the Direct3D-hosted XAML control passed in. +*/ +#define SDL_MAIN_NEEDED + +#elif defined(__IPHONEOS__) +/* On iOS SDL provides a main function that creates an application delegate + and starts the iOS application run loop. + + If you link with SDL dynamically on iOS, the main function can't be in a + shared library, so you need to link with libSDLmain.a, which includes a + stub main function that calls into the shared library to start execution. + + See src/video/uikit/SDL_uikitappdelegate.m for more details. + */ +#define SDL_MAIN_NEEDED + +#elif defined(__ANDROID__) +/* On Android SDL provides a Java class in SDLActivity.java that is the + main activity entry point. + + See docs/README-android.md for more details on extending that class. + */ +#define SDL_MAIN_NEEDED + +/* We need to export SDL_main so it can be launched from Java */ +#define SDLMAIN_DECLSPEC DECLSPEC + +#elif defined(__NACL__) +/* On NACL we use ppapi_simple to set up the application helper code, + then wait for the first PSE_INSTANCE_DIDCHANGEVIEW event before + starting the user main function. + All user code is run in a separate thread by ppapi_simple, thus + allowing for blocking io to take place via nacl_io +*/ +#define SDL_MAIN_NEEDED + +#endif +#endif /* SDL_MAIN_HANDLED */ + +#ifndef SDLMAIN_DECLSPEC +#define SDLMAIN_DECLSPEC +#endif + +/** + * \file SDL_main.h + * + * The application's main() function must be called with C linkage, + * and should be declared like this: + * \code + * #ifdef __cplusplus + * extern "C" + * #endif + * int main(int argc, char *argv[]) + * { + * } + * \endcode + */ + +#if defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE) +#define main SDL_main +#endif + +#include "begin_code.h" +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The prototype for the application's main() function + */ +typedef int (*SDL_main_func)(int argc, char *argv[]); +extern SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[]); + + +/** + * This is called by the real SDL main function to let the rest of the + * library know that initialization was done properly. + * + * Calling this yourself without knowing what you're doing can cause + * crashes and hard to diagnose problems with your application. + */ +extern DECLSPEC void SDLCALL SDL_SetMainReady(void); + +#ifdef __WIN32__ + +/** + * This can be called to set the application class at startup + */ +extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, void *hInst); +extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); + +#endif /* __WIN32__ */ + + +#ifdef __WINRT__ + +/** + * \brief Initializes and launches an SDL/WinRT application. + * + * \param mainFunction The SDL app's C-style main(). + * \param reserved Reserved for future use; should be NULL + * \return 0 on success, -1 on failure. On failure, use SDL_GetError to retrieve more + * information on the failure. + */ +extern DECLSPEC int SDLCALL SDL_WinRTRunApp(SDL_main_func mainFunction, void * reserved); + +#endif /* __WINRT__ */ + +#if defined(__IPHONEOS__) + +/** + * \brief Initializes and launches an SDL application. + * + * \param argc The argc parameter from the application's main() function + * \param argv The argv parameter from the application's main() function + * \param mainFunction The SDL app's C-style main(). + * \return the return value from mainFunction + */ +extern DECLSPEC int SDLCALL SDL_UIKitRunApp(int argc, char *argv[], SDL_main_func mainFunction); + +#endif /* __IPHONEOS__ */ + + +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_main_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_messagebox.h b/thirdparty/include/SDL2/SDL_messagebox.h new file mode 100644 index 000000000..03639ce4f --- /dev/null +++ b/thirdparty/include/SDL2/SDL_messagebox.h @@ -0,0 +1,146 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_messagebox_h_ +#define SDL_messagebox_h_ + +#include "SDL_stdinc.h" +#include "SDL_video.h" /* For SDL_Window */ + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief SDL_MessageBox flags. If supported will display warning icon, etc. + */ +typedef enum +{ + SDL_MESSAGEBOX_ERROR = 0x00000010, /**< error dialog */ + SDL_MESSAGEBOX_WARNING = 0x00000020, /**< warning dialog */ + SDL_MESSAGEBOX_INFORMATION = 0x00000040, /**< informational dialog */ + SDL_MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT = 0x00000080, /**< buttons placed left to right */ + SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT = 0x00000100 /**< buttons placed right to left */ +} SDL_MessageBoxFlags; + +/** + * \brief Flags for SDL_MessageBoxButtonData. + */ +typedef enum +{ + SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 0x00000001, /**< Marks the default button when return is hit */ + SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 0x00000002 /**< Marks the default button when escape is hit */ +} SDL_MessageBoxButtonFlags; + +/** + * \brief Individual button data. + */ +typedef struct +{ + Uint32 flags; /**< ::SDL_MessageBoxButtonFlags */ + int buttonid; /**< User defined button id (value returned via SDL_ShowMessageBox) */ + const char * text; /**< The UTF-8 button text */ +} SDL_MessageBoxButtonData; + +/** + * \brief RGB value used in a message box color scheme + */ +typedef struct +{ + Uint8 r, g, b; +} SDL_MessageBoxColor; + +typedef enum +{ + SDL_MESSAGEBOX_COLOR_BACKGROUND, + SDL_MESSAGEBOX_COLOR_TEXT, + SDL_MESSAGEBOX_COLOR_BUTTON_BORDER, + SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND, + SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED, + SDL_MESSAGEBOX_COLOR_MAX +} SDL_MessageBoxColorType; + +/** + * \brief A set of colors to use for message box dialogs + */ +typedef struct +{ + SDL_MessageBoxColor colors[SDL_MESSAGEBOX_COLOR_MAX]; +} SDL_MessageBoxColorScheme; + +/** + * \brief MessageBox structure containing title, text, window, etc. + */ +typedef struct +{ + Uint32 flags; /**< ::SDL_MessageBoxFlags */ + SDL_Window *window; /**< Parent window, can be NULL */ + const char *title; /**< UTF-8 title */ + const char *message; /**< UTF-8 message text */ + + int numbuttons; + const SDL_MessageBoxButtonData *buttons; + + const SDL_MessageBoxColorScheme *colorScheme; /**< ::SDL_MessageBoxColorScheme, can be NULL to use system settings */ +} SDL_MessageBoxData; + +/** + * \brief Create a modal message box. + * + * \param messageboxdata The SDL_MessageBoxData structure with title, text, etc. + * \param buttonid The pointer to which user id of hit button should be copied. + * + * \return -1 on error, otherwise 0 and buttonid contains user id of button + * hit or -1 if dialog was closed. + * + * \note This function should be called on the thread that created the parent + * window, or on the main thread if the messagebox has no parent. It will + * block execution of that thread until the user clicks a button or + * closes the messagebox. + */ +extern DECLSPEC int SDLCALL SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid); + +/** + * \brief Create a simple modal message box + * + * \param flags ::SDL_MessageBoxFlags + * \param title UTF-8 title text + * \param message UTF-8 message text + * \param window The parent window, or NULL for no parent + * + * \return 0 on success, -1 on error + * + * \sa SDL_ShowMessageBox + */ +extern DECLSPEC int SDLCALL SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, SDL_Window *window); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_messagebox_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_metal.h b/thirdparty/include/SDL2/SDL_metal.h new file mode 100644 index 000000000..3b7eb18aa --- /dev/null +++ b/thirdparty/include/SDL2/SDL_metal.h @@ -0,0 +1,91 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_metal.h + * + * Header file for functions to creating Metal layers and views on SDL windows. + */ + +#ifndef SDL_metal_h_ +#define SDL_metal_h_ + +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief A handle to a CAMetalLayer-backed NSView (macOS) or UIView (iOS/tvOS). + * + * \note This can be cast directly to an NSView or UIView. + */ +typedef void *SDL_MetalView; + +/** + * \name Metal support functions + */ +/* @{ */ + +/** + * \brief Create a CAMetalLayer-backed NSView/UIView and attach it to the + * specified window. + * + * On macOS, this does *not* associate a MTLDevice with the CAMetalLayer on its + * own. It is up to user code to do that. + * + * The returned handle can be casted directly to a NSView or UIView, and the + * CAMetalLayer can be accessed from the view's 'layer' property. + * + * \code + * SDL_MetalView metalview = SDL_Metal_CreateView(window); + * UIView *uiview = (__bridge UIView *)metalview; + * CAMetalLayer *metallayer = (CAMetalLayer *)uiview.layer; + * // [...] + * SDL_Metal_DestroyView(metalview); + * \endcode + * + * \sa SDL_Metal_DestroyView + */ +extern DECLSPEC SDL_MetalView SDLCALL SDL_Metal_CreateView(SDL_Window * window); + +/** + * \brief Destroy an existing SDL_MetalView object. + * + * This should be called before SDL_DestroyWindow, if SDL_Metal_CreateView was + * called after SDL_CreateWindow. + * + * \sa SDL_Metal_CreateView + */ +extern DECLSPEC void SDLCALL SDL_Metal_DestroyView(SDL_MetalView view); + +/* @} *//* Metal support functions */ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_metal_h_ */ diff --git a/thirdparty/include/SDL2/SDL_mouse.h b/thirdparty/include/SDL2/SDL_mouse.h new file mode 100644 index 000000000..99b658e94 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_mouse.h @@ -0,0 +1,302 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_mouse.h + * + * Include file for SDL mouse event handling. + */ + +#ifndef SDL_mouse_h_ +#define SDL_mouse_h_ + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct SDL_Cursor SDL_Cursor; /**< Implementation dependent */ + +/** + * \brief Cursor types for SDL_CreateSystemCursor(). + */ +typedef enum +{ + SDL_SYSTEM_CURSOR_ARROW, /**< Arrow */ + SDL_SYSTEM_CURSOR_IBEAM, /**< I-beam */ + SDL_SYSTEM_CURSOR_WAIT, /**< Wait */ + SDL_SYSTEM_CURSOR_CROSSHAIR, /**< Crosshair */ + SDL_SYSTEM_CURSOR_WAITARROW, /**< Small wait cursor (or Wait if not available) */ + SDL_SYSTEM_CURSOR_SIZENWSE, /**< Double arrow pointing northwest and southeast */ + SDL_SYSTEM_CURSOR_SIZENESW, /**< Double arrow pointing northeast and southwest */ + SDL_SYSTEM_CURSOR_SIZEWE, /**< Double arrow pointing west and east */ + SDL_SYSTEM_CURSOR_SIZENS, /**< Double arrow pointing north and south */ + SDL_SYSTEM_CURSOR_SIZEALL, /**< Four pointed arrow pointing north, south, east, and west */ + SDL_SYSTEM_CURSOR_NO, /**< Slashed circle or crossbones */ + SDL_SYSTEM_CURSOR_HAND, /**< Hand */ + SDL_NUM_SYSTEM_CURSORS +} SDL_SystemCursor; + +/** + * \brief Scroll direction types for the Scroll event + */ +typedef enum +{ + SDL_MOUSEWHEEL_NORMAL, /**< The scroll direction is normal */ + SDL_MOUSEWHEEL_FLIPPED /**< The scroll direction is flipped / natural */ +} SDL_MouseWheelDirection; + +/* Function prototypes */ + +/** + * \brief Get the window which currently has mouse focus. + */ +extern DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void); + +/** + * \brief Retrieve the current state of the mouse. + * + * The current button state is returned as a button bitmask, which can + * be tested using the SDL_BUTTON(X) macros, and x and y are set to the + * mouse cursor position relative to the focus window for the currently + * selected mouse. You can pass NULL for either x or y. + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetMouseState(int *x, int *y); + +/** + * \brief Get the current state of the mouse, in relation to the desktop + * + * This works just like SDL_GetMouseState(), but the coordinates will be + * reported relative to the top-left of the desktop. This can be useful if + * you need to track the mouse outside of a specific window and + * SDL_CaptureMouse() doesn't fit your needs. For example, it could be + * useful if you need to track the mouse while dragging a window, where + * coordinates relative to a window might not be in sync at all times. + * + * \note SDL_GetMouseState() returns the mouse position as SDL understands + * it from the last pump of the event queue. This function, however, + * queries the OS for the current mouse position, and as such, might + * be a slightly less efficient function. Unless you know what you're + * doing and have a good reason to use this function, you probably want + * SDL_GetMouseState() instead. + * + * \param x Returns the current X coord, relative to the desktop. Can be NULL. + * \param y Returns the current Y coord, relative to the desktop. Can be NULL. + * \return The current button state as a bitmask, which can be tested using the SDL_BUTTON(X) macros. + * + * \sa SDL_GetMouseState + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetGlobalMouseState(int *x, int *y); + +/** + * \brief Retrieve the relative state of the mouse. + * + * The current button state is returned as a button bitmask, which can + * be tested using the SDL_BUTTON(X) macros, and x and y are set to the + * mouse deltas since the last call to SDL_GetRelativeMouseState(). + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetRelativeMouseState(int *x, int *y); + +/** + * \brief Moves the mouse to the given position within the window. + * + * \param window The window to move the mouse into, or NULL for the current mouse focus + * \param x The x coordinate within the window + * \param y The y coordinate within the window + * + * \note This function generates a mouse motion event + */ +extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window, + int x, int y); + +/** + * \brief Moves the mouse to the given position in global screen space. + * + * \param x The x coordinate + * \param y The y coordinate + * \return 0 on success, -1 on error (usually: unsupported by a platform). + * + * \note This function generates a mouse motion event + */ +extern DECLSPEC int SDLCALL SDL_WarpMouseGlobal(int x, int y); + +/** + * \brief Set relative mouse mode. + * + * \param enabled Whether or not to enable relative mode + * + * \return 0 on success, or -1 if relative mode is not supported. + * + * While the mouse is in relative mode, the cursor is hidden, and the + * driver will try to report continuous motion in the current window. + * Only relative motion events will be delivered, the mouse position + * will not change. + * + * \note This function will flush any pending mouse motion. + * + * \sa SDL_GetRelativeMouseMode() + */ +extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled); + +/** + * \brief Capture the mouse, to track input outside an SDL window. + * + * \param enabled Whether or not to enable capturing + * + * Capturing enables your app to obtain mouse events globally, instead of + * just within your window. Not all video targets support this function. + * When capturing is enabled, the current window will get all mouse events, + * but unlike relative mode, no change is made to the cursor and it is + * not restrained to your window. + * + * This function may also deny mouse input to other windows--both those in + * your application and others on the system--so you should use this + * function sparingly, and in small bursts. For example, you might want to + * track the mouse while the user is dragging something, until the user + * releases a mouse button. It is not recommended that you capture the mouse + * for long periods of time, such as the entire time your app is running. + * + * While captured, mouse events still report coordinates relative to the + * current (foreground) window, but those coordinates may be outside the + * bounds of the window (including negative values). Capturing is only + * allowed for the foreground window. If the window loses focus while + * capturing, the capture will be disabled automatically. + * + * While capturing is enabled, the current window will have the + * SDL_WINDOW_MOUSE_CAPTURE flag set. + * + * \return 0 on success, or -1 if not supported. + */ +extern DECLSPEC int SDLCALL SDL_CaptureMouse(SDL_bool enabled); + +/** + * \brief Query whether relative mouse mode is enabled. + * + * \sa SDL_SetRelativeMouseMode() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void); + +/** + * \brief Create a cursor, using the specified bitmap data and + * mask (in MSB format). + * + * The cursor width must be a multiple of 8 bits. + * + * The cursor is created in black and white according to the following: + * + * + * + * + * + * + *
data mask resulting pixel on screen
0 1 White
1 1 Black
0 0 Transparent
1 0 Inverted color if possible, black + * if not.
+ * + * \sa SDL_FreeCursor() + */ +extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data, + const Uint8 * mask, + int w, int h, int hot_x, + int hot_y); + +/** + * \brief Create a color cursor. + * + * \sa SDL_FreeCursor() + */ +extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateColorCursor(SDL_Surface *surface, + int hot_x, + int hot_y); + +/** + * \brief Create a system cursor. + * + * \sa SDL_FreeCursor() + */ +extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateSystemCursor(SDL_SystemCursor id); + +/** + * \brief Set the active cursor. + */ +extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor * cursor); + +/** + * \brief Return the active cursor. + */ +extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void); + +/** + * \brief Return the default cursor. + */ +extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetDefaultCursor(void); + +/** + * \brief Frees a cursor created with SDL_CreateCursor() or similar functions. + * + * \sa SDL_CreateCursor() + * \sa SDL_CreateColorCursor() + * \sa SDL_CreateSystemCursor() + */ +extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor); + +/** + * \brief Toggle whether or not the cursor is shown. + * + * \param toggle 1 to show the cursor, 0 to hide it, -1 to query the current + * state. + * + * \return 1 if the cursor is shown, or 0 if the cursor is hidden. + */ +extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle); + +/** + * Used as a mask when testing buttons in buttonstate. + * - Button 1: Left mouse button + * - Button 2: Middle mouse button + * - Button 3: Right mouse button + */ +#define SDL_BUTTON(X) (1 << ((X)-1)) +#define SDL_BUTTON_LEFT 1 +#define SDL_BUTTON_MIDDLE 2 +#define SDL_BUTTON_RIGHT 3 +#define SDL_BUTTON_X1 4 +#define SDL_BUTTON_X2 5 +#define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT) +#define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE) +#define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT) +#define SDL_BUTTON_X1MASK SDL_BUTTON(SDL_BUTTON_X1) +#define SDL_BUTTON_X2MASK SDL_BUTTON(SDL_BUTTON_X2) + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_mouse_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_mutex.h b/thirdparty/include/SDL2/SDL_mutex.h new file mode 100644 index 000000000..3c5b95574 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_mutex.h @@ -0,0 +1,251 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_mutex_h_ +#define SDL_mutex_h_ + +/** + * \file SDL_mutex.h + * + * Functions to provide thread synchronization primitives. + */ + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Synchronization functions which can time out return this value + * if they time out. + */ +#define SDL_MUTEX_TIMEDOUT 1 + +/** + * This is the timeout value which corresponds to never time out. + */ +#define SDL_MUTEX_MAXWAIT (~(Uint32)0) + + +/** + * \name Mutex functions + */ +/* @{ */ + +/* The SDL mutex structure, defined in SDL_sysmutex.c */ +struct SDL_mutex; +typedef struct SDL_mutex SDL_mutex; + +/** + * Create a mutex, initialized unlocked. + */ +extern DECLSPEC SDL_mutex *SDLCALL SDL_CreateMutex(void); + +/** + * Lock the mutex. + * + * \return 0, or -1 on error. + */ +#define SDL_mutexP(m) SDL_LockMutex(m) +extern DECLSPEC int SDLCALL SDL_LockMutex(SDL_mutex * mutex); + +/** + * Try to lock the mutex + * + * \return 0, SDL_MUTEX_TIMEDOUT, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_TryLockMutex(SDL_mutex * mutex); + +/** + * Unlock the mutex. + * + * \return 0, or -1 on error. + * + * \warning It is an error to unlock a mutex that has not been locked by + * the current thread, and doing so results in undefined behavior. + */ +#define SDL_mutexV(m) SDL_UnlockMutex(m) +extern DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_mutex * mutex); + +/** + * Destroy a mutex. + */ +extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex * mutex); + +/* @} *//* Mutex functions */ + + +/** + * \name Semaphore functions + */ +/* @{ */ + +/* The SDL semaphore structure, defined in SDL_syssem.c */ +struct SDL_semaphore; +typedef struct SDL_semaphore SDL_sem; + +/** + * Create a semaphore, initialized with value, returns NULL on failure. + */ +extern DECLSPEC SDL_sem *SDLCALL SDL_CreateSemaphore(Uint32 initial_value); + +/** + * Destroy a semaphore. + */ +extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem * sem); + +/** + * This function suspends the calling thread until the semaphore pointed + * to by \c sem has a positive count. It then atomically decreases the + * semaphore count. + */ +extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem * sem); + +/** + * Non-blocking variant of SDL_SemWait(). + * + * \return 0 if the wait succeeds, ::SDL_MUTEX_TIMEDOUT if the wait would + * block, and -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem * sem); + +/** + * Variant of SDL_SemWait() with a timeout in milliseconds. + * + * \return 0 if the wait succeeds, ::SDL_MUTEX_TIMEDOUT if the wait does not + * succeed in the allotted time, and -1 on error. + * + * \warning On some platforms this function is implemented by looping with a + * delay of 1 ms, and so should be avoided if possible. + */ +extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem * sem, Uint32 ms); + +/** + * Atomically increases the semaphore's count (not blocking). + * + * \return 0, or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem * sem); + +/** + * Returns the current count of the semaphore. + */ +extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem * sem); + +/* @} *//* Semaphore functions */ + + +/** + * \name Condition variable functions + */ +/* @{ */ + +/* The SDL condition variable structure, defined in SDL_syscond.c */ +struct SDL_cond; +typedef struct SDL_cond SDL_cond; + +/** + * Create a condition variable. + * + * Typical use of condition variables: + * + * Thread A: + * SDL_LockMutex(lock); + * while ( ! condition ) { + * SDL_CondWait(cond, lock); + * } + * SDL_UnlockMutex(lock); + * + * Thread B: + * SDL_LockMutex(lock); + * ... + * condition = true; + * ... + * SDL_CondSignal(cond); + * SDL_UnlockMutex(lock); + * + * There is some discussion whether to signal the condition variable + * with the mutex locked or not. There is some potential performance + * benefit to unlocking first on some platforms, but there are some + * potential race conditions depending on how your code is structured. + * + * In general it's safer to signal the condition variable while the + * mutex is locked. + */ +extern DECLSPEC SDL_cond *SDLCALL SDL_CreateCond(void); + +/** + * Destroy a condition variable. + */ +extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond * cond); + +/** + * Restart one of the threads that are waiting on the condition variable. + * + * \return 0 or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond * cond); + +/** + * Restart all threads that are waiting on the condition variable. + * + * \return 0 or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond * cond); + +/** + * Wait on the condition variable, unlocking the provided mutex. + * + * \warning The mutex must be locked before entering this function! + * + * The mutex is re-locked once the condition variable is signaled. + * + * \return 0 when it is signaled, or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex); + +/** + * Waits for at most \c ms milliseconds, and returns 0 if the condition + * variable is signaled, ::SDL_MUTEX_TIMEDOUT if the condition is not + * signaled in the allotted time, and -1 on error. + * + * \warning On some platforms this function is implemented by looping with a + * delay of 1 ms, and so should be avoided if possible. + */ +extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond * cond, + SDL_mutex * mutex, Uint32 ms); + +/* @} *//* Condition variable functions */ + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_mutex_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_name.h b/thirdparty/include/SDL2/SDL_name.h new file mode 100644 index 000000000..a49c4887b --- /dev/null +++ b/thirdparty/include/SDL2/SDL_name.h @@ -0,0 +1,33 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDLname_h_ +#define SDLname_h_ + +#if defined(__STDC__) || defined(__cplusplus) +#define NeedFunctionPrototypes 1 +#endif + +#define SDL_NAME(X) SDL_##X + +#endif /* SDLname_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_opengl.h b/thirdparty/include/SDL2/SDL_opengl.h new file mode 100644 index 000000000..5cd302cde --- /dev/null +++ b/thirdparty/include/SDL2/SDL_opengl.h @@ -0,0 +1,2183 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_opengl.h + * + * This is a simple file to encapsulate the OpenGL API headers. + */ + +/** + * \def NO_SDL_GLEXT + * + * Define this if you have your own version of glext.h and want to disable the + * version included in SDL_opengl.h. + */ + +#ifndef SDL_opengl_h_ +#define SDL_opengl_h_ + +#include "SDL_config.h" + +#ifndef __IPHONEOS__ /* No OpenGL on iOS. */ + +/* + * Mesa 3-D graphics library + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * 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. + */ + + +#ifndef __gl_h_ +#define __gl_h_ + +#if defined(USE_MGL_NAMESPACE) +#include "gl_mangle.h" +#endif + + +/********************************************************************** + * Begin system-specific stuff. + */ + +#if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) +#define __WIN32__ +#endif + +#if defined(__WIN32__) && !defined(__CYGWIN__) +# if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */ +# define GLAPI __declspec(dllexport) +# elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */ +# define GLAPI __declspec(dllimport) +# else /* for use with static link lib build of Win32 edition only */ +# define GLAPI extern +# endif /* _STATIC_MESA support */ +# if defined(__MINGW32__) && defined(GL_NO_STDCALL) || defined(UNDER_CE) /* The generated DLLs by MingW with STDCALL are not compatible with the ones done by Microsoft's compilers */ +# define GLAPIENTRY +# else +# define GLAPIENTRY __stdcall +# endif +#elif defined(__CYGWIN__) && defined(USE_OPENGL32) /* use native windows opengl32 */ +# define GLAPI extern +# define GLAPIENTRY __stdcall +#elif defined(__OS2__) || defined(__EMX__) /* native os/2 opengl */ +# define GLAPI extern +# define GLAPIENTRY _System +# define APIENTRY _System +# if defined(__GNUC__) && !defined(_System) +# define _System +# endif +#elif (defined(__GNUC__) && __GNUC__ >= 4) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) +# define GLAPI __attribute__((visibility("default"))) +# define GLAPIENTRY +#endif /* WIN32 && !CYGWIN */ + +/* + * WINDOWS: Include windows.h here to define APIENTRY. + * It is also useful when applications include this file by + * including only glut.h, since glut.h depends on windows.h. + * Applications needing to include windows.h with parms other + * than "WIN32_LEAN_AND_MEAN" may include windows.h before + * glut.h or gl.h. + */ +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif +#ifndef NOMINMAX /* don't define min() and max(). */ +#define NOMINMAX +#endif +#include +#endif + +#ifndef GLAPI +#define GLAPI extern +#endif + +#ifndef GLAPIENTRY +#define GLAPIENTRY +#endif + +#ifndef APIENTRY +#define APIENTRY GLAPIENTRY +#endif + +/* "P" suffix to be used for a pointer to a function */ +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif + +#ifndef GLAPIENTRYP +#define GLAPIENTRYP GLAPIENTRY * +#endif + +#if defined(PRAGMA_EXPORT_SUPPORTED) +#pragma export on +#endif + +/* + * End system-specific stuff. + **********************************************************************/ + + + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define GL_VERSION_1_1 1 +#define GL_VERSION_1_2 1 +#define GL_VERSION_1_3 1 +#define GL_ARB_imaging 1 + + +/* + * Datatypes + */ +typedef unsigned int GLenum; +typedef unsigned char GLboolean; +typedef unsigned int GLbitfield; +typedef void GLvoid; +typedef signed char GLbyte; /* 1-byte signed */ +typedef short GLshort; /* 2-byte signed */ +typedef int GLint; /* 4-byte signed */ +typedef unsigned char GLubyte; /* 1-byte unsigned */ +typedef unsigned short GLushort; /* 2-byte unsigned */ +typedef unsigned int GLuint; /* 4-byte unsigned */ +typedef int GLsizei; /* 4-byte signed */ +typedef float GLfloat; /* single precision float */ +typedef float GLclampf; /* single precision float in [0,1] */ +typedef double GLdouble; /* double precision float */ +typedef double GLclampd; /* double precision float in [0,1] */ + + + +/* + * Constants + */ + +/* Boolean values */ +#define GL_FALSE 0 +#define GL_TRUE 1 + +/* Data types */ +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_INT 0x1404 +#define GL_UNSIGNED_INT 0x1405 +#define GL_FLOAT 0x1406 +#define GL_2_BYTES 0x1407 +#define GL_3_BYTES 0x1408 +#define GL_4_BYTES 0x1409 +#define GL_DOUBLE 0x140A + +/* Primitives */ +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 +#define GL_QUADS 0x0007 +#define GL_QUAD_STRIP 0x0008 +#define GL_POLYGON 0x0009 + +/* Vertex Arrays */ +#define GL_VERTEX_ARRAY 0x8074 +#define GL_NORMAL_ARRAY 0x8075 +#define GL_COLOR_ARRAY 0x8076 +#define GL_INDEX_ARRAY 0x8077 +#define GL_TEXTURE_COORD_ARRAY 0x8078 +#define GL_EDGE_FLAG_ARRAY 0x8079 +#define GL_VERTEX_ARRAY_SIZE 0x807A +#define GL_VERTEX_ARRAY_TYPE 0x807B +#define GL_VERTEX_ARRAY_STRIDE 0x807C +#define GL_NORMAL_ARRAY_TYPE 0x807E +#define GL_NORMAL_ARRAY_STRIDE 0x807F +#define GL_COLOR_ARRAY_SIZE 0x8081 +#define GL_COLOR_ARRAY_TYPE 0x8082 +#define GL_COLOR_ARRAY_STRIDE 0x8083 +#define GL_INDEX_ARRAY_TYPE 0x8085 +#define GL_INDEX_ARRAY_STRIDE 0x8086 +#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A +#define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C +#define GL_VERTEX_ARRAY_POINTER 0x808E +#define GL_NORMAL_ARRAY_POINTER 0x808F +#define GL_COLOR_ARRAY_POINTER 0x8090 +#define GL_INDEX_ARRAY_POINTER 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER 0x8093 +#define GL_V2F 0x2A20 +#define GL_V3F 0x2A21 +#define GL_C4UB_V2F 0x2A22 +#define GL_C4UB_V3F 0x2A23 +#define GL_C3F_V3F 0x2A24 +#define GL_N3F_V3F 0x2A25 +#define GL_C4F_N3F_V3F 0x2A26 +#define GL_T2F_V3F 0x2A27 +#define GL_T4F_V4F 0x2A28 +#define GL_T2F_C4UB_V3F 0x2A29 +#define GL_T2F_C3F_V3F 0x2A2A +#define GL_T2F_N3F_V3F 0x2A2B +#define GL_T2F_C4F_N3F_V3F 0x2A2C +#define GL_T4F_C4F_N3F_V4F 0x2A2D + +/* Matrix Mode */ +#define GL_MATRIX_MODE 0x0BA0 +#define GL_MODELVIEW 0x1700 +#define GL_PROJECTION 0x1701 +#define GL_TEXTURE 0x1702 + +/* Points */ +#define GL_POINT_SMOOTH 0x0B10 +#define GL_POINT_SIZE 0x0B11 +#define GL_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_POINT_SIZE_RANGE 0x0B12 + +/* Lines */ +#define GL_LINE_SMOOTH 0x0B20 +#define GL_LINE_STIPPLE 0x0B24 +#define GL_LINE_STIPPLE_PATTERN 0x0B25 +#define GL_LINE_STIPPLE_REPEAT 0x0B26 +#define GL_LINE_WIDTH 0x0B21 +#define GL_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_LINE_WIDTH_RANGE 0x0B22 + +/* Polygons */ +#define GL_POINT 0x1B00 +#define GL_LINE 0x1B01 +#define GL_FILL 0x1B02 +#define GL_CW 0x0900 +#define GL_CCW 0x0901 +#define GL_FRONT 0x0404 +#define GL_BACK 0x0405 +#define GL_POLYGON_MODE 0x0B40 +#define GL_POLYGON_SMOOTH 0x0B41 +#define GL_POLYGON_STIPPLE 0x0B42 +#define GL_EDGE_FLAG 0x0B43 +#define GL_CULL_FACE 0x0B44 +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_FRONT_FACE 0x0B46 +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#define GL_POLYGON_OFFSET_POINT 0x2A01 +#define GL_POLYGON_OFFSET_LINE 0x2A02 +#define GL_POLYGON_OFFSET_FILL 0x8037 + +/* Display Lists */ +#define GL_COMPILE 0x1300 +#define GL_COMPILE_AND_EXECUTE 0x1301 +#define GL_LIST_BASE 0x0B32 +#define GL_LIST_INDEX 0x0B33 +#define GL_LIST_MODE 0x0B30 + +/* Depth buffer */ +#define GL_NEVER 0x0200 +#define GL_LESS 0x0201 +#define GL_EQUAL 0x0202 +#define GL_LEQUAL 0x0203 +#define GL_GREATER 0x0204 +#define GL_NOTEQUAL 0x0205 +#define GL_GEQUAL 0x0206 +#define GL_ALWAYS 0x0207 +#define GL_DEPTH_TEST 0x0B71 +#define GL_DEPTH_BITS 0x0D56 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DEPTH_COMPONENT 0x1902 + +/* Lighting */ +#define GL_LIGHTING 0x0B50 +#define GL_LIGHT0 0x4000 +#define GL_LIGHT1 0x4001 +#define GL_LIGHT2 0x4002 +#define GL_LIGHT3 0x4003 +#define GL_LIGHT4 0x4004 +#define GL_LIGHT5 0x4005 +#define GL_LIGHT6 0x4006 +#define GL_LIGHT7 0x4007 +#define GL_SPOT_EXPONENT 0x1205 +#define GL_SPOT_CUTOFF 0x1206 +#define GL_CONSTANT_ATTENUATION 0x1207 +#define GL_LINEAR_ATTENUATION 0x1208 +#define GL_QUADRATIC_ATTENUATION 0x1209 +#define GL_AMBIENT 0x1200 +#define GL_DIFFUSE 0x1201 +#define GL_SPECULAR 0x1202 +#define GL_SHININESS 0x1601 +#define GL_EMISSION 0x1600 +#define GL_POSITION 0x1203 +#define GL_SPOT_DIRECTION 0x1204 +#define GL_AMBIENT_AND_DIFFUSE 0x1602 +#define GL_COLOR_INDEXES 0x1603 +#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52 +#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51 +#define GL_LIGHT_MODEL_AMBIENT 0x0B53 +#define GL_FRONT_AND_BACK 0x0408 +#define GL_SHADE_MODEL 0x0B54 +#define GL_FLAT 0x1D00 +#define GL_SMOOTH 0x1D01 +#define GL_COLOR_MATERIAL 0x0B57 +#define GL_COLOR_MATERIAL_FACE 0x0B55 +#define GL_COLOR_MATERIAL_PARAMETER 0x0B56 +#define GL_NORMALIZE 0x0BA1 + +/* User clipping planes */ +#define GL_CLIP_PLANE0 0x3000 +#define GL_CLIP_PLANE1 0x3001 +#define GL_CLIP_PLANE2 0x3002 +#define GL_CLIP_PLANE3 0x3003 +#define GL_CLIP_PLANE4 0x3004 +#define GL_CLIP_PLANE5 0x3005 + +/* Accumulation buffer */ +#define GL_ACCUM_RED_BITS 0x0D58 +#define GL_ACCUM_GREEN_BITS 0x0D59 +#define GL_ACCUM_BLUE_BITS 0x0D5A +#define GL_ACCUM_ALPHA_BITS 0x0D5B +#define GL_ACCUM_CLEAR_VALUE 0x0B80 +#define GL_ACCUM 0x0100 +#define GL_ADD 0x0104 +#define GL_LOAD 0x0101 +#define GL_MULT 0x0103 +#define GL_RETURN 0x0102 + +/* Alpha testing */ +#define GL_ALPHA_TEST 0x0BC0 +#define GL_ALPHA_TEST_REF 0x0BC2 +#define GL_ALPHA_TEST_FUNC 0x0BC1 + +/* Blending */ +#define GL_BLEND 0x0BE2 +#define GL_BLEND_SRC 0x0BE1 +#define GL_BLEND_DST 0x0BE0 +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 + +/* Render Mode */ +#define GL_FEEDBACK 0x1C01 +#define GL_RENDER 0x1C00 +#define GL_SELECT 0x1C02 + +/* Feedback */ +#define GL_2D 0x0600 +#define GL_3D 0x0601 +#define GL_3D_COLOR 0x0602 +#define GL_3D_COLOR_TEXTURE 0x0603 +#define GL_4D_COLOR_TEXTURE 0x0604 +#define GL_POINT_TOKEN 0x0701 +#define GL_LINE_TOKEN 0x0702 +#define GL_LINE_RESET_TOKEN 0x0707 +#define GL_POLYGON_TOKEN 0x0703 +#define GL_BITMAP_TOKEN 0x0704 +#define GL_DRAW_PIXEL_TOKEN 0x0705 +#define GL_COPY_PIXEL_TOKEN 0x0706 +#define GL_PASS_THROUGH_TOKEN 0x0700 +#define GL_FEEDBACK_BUFFER_POINTER 0x0DF0 +#define GL_FEEDBACK_BUFFER_SIZE 0x0DF1 +#define GL_FEEDBACK_BUFFER_TYPE 0x0DF2 + +/* Selection */ +#define GL_SELECTION_BUFFER_POINTER 0x0DF3 +#define GL_SELECTION_BUFFER_SIZE 0x0DF4 + +/* Fog */ +#define GL_FOG 0x0B60 +#define GL_FOG_MODE 0x0B65 +#define GL_FOG_DENSITY 0x0B62 +#define GL_FOG_COLOR 0x0B66 +#define GL_FOG_INDEX 0x0B61 +#define GL_FOG_START 0x0B63 +#define GL_FOG_END 0x0B64 +#define GL_LINEAR 0x2601 +#define GL_EXP 0x0800 +#define GL_EXP2 0x0801 + +/* Logic Ops */ +#define GL_LOGIC_OP 0x0BF1 +#define GL_INDEX_LOGIC_OP 0x0BF1 +#define GL_COLOR_LOGIC_OP 0x0BF2 +#define GL_LOGIC_OP_MODE 0x0BF0 +#define GL_CLEAR 0x1500 +#define GL_SET 0x150F +#define GL_COPY 0x1503 +#define GL_COPY_INVERTED 0x150C +#define GL_NOOP 0x1505 +#define GL_INVERT 0x150A +#define GL_AND 0x1501 +#define GL_NAND 0x150E +#define GL_OR 0x1507 +#define GL_NOR 0x1508 +#define GL_XOR 0x1506 +#define GL_EQUIV 0x1509 +#define GL_AND_REVERSE 0x1502 +#define GL_AND_INVERTED 0x1504 +#define GL_OR_REVERSE 0x150B +#define GL_OR_INVERTED 0x150D + +/* Stencil */ +#define GL_STENCIL_BITS 0x0D57 +#define GL_STENCIL_TEST 0x0B90 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_STENCIL_INDEX 0x1901 +#define GL_KEEP 0x1E00 +#define GL_REPLACE 0x1E01 +#define GL_INCR 0x1E02 +#define GL_DECR 0x1E03 + +/* Buffers, Pixel Drawing/Reading */ +#define GL_NONE 0 +#define GL_LEFT 0x0406 +#define GL_RIGHT 0x0407 +/*GL_FRONT 0x0404 */ +/*GL_BACK 0x0405 */ +/*GL_FRONT_AND_BACK 0x0408 */ +#define GL_FRONT_LEFT 0x0400 +#define GL_FRONT_RIGHT 0x0401 +#define GL_BACK_LEFT 0x0402 +#define GL_BACK_RIGHT 0x0403 +#define GL_AUX0 0x0409 +#define GL_AUX1 0x040A +#define GL_AUX2 0x040B +#define GL_AUX3 0x040C +#define GL_COLOR_INDEX 0x1900 +#define GL_RED 0x1903 +#define GL_GREEN 0x1904 +#define GL_BLUE 0x1905 +#define GL_ALPHA 0x1906 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE_ALPHA 0x190A +#define GL_ALPHA_BITS 0x0D55 +#define GL_RED_BITS 0x0D52 +#define GL_GREEN_BITS 0x0D53 +#define GL_BLUE_BITS 0x0D54 +#define GL_INDEX_BITS 0x0D51 +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_AUX_BUFFERS 0x0C00 +#define GL_READ_BUFFER 0x0C02 +#define GL_DRAW_BUFFER 0x0C01 +#define GL_DOUBLEBUFFER 0x0C32 +#define GL_STEREO 0x0C33 +#define GL_BITMAP 0x1A00 +#define GL_COLOR 0x1800 +#define GL_DEPTH 0x1801 +#define GL_STENCIL 0x1802 +#define GL_DITHER 0x0BD0 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 + +/* Implementation limits */ +#define GL_MAX_LIST_NESTING 0x0B31 +#define GL_MAX_EVAL_ORDER 0x0D30 +#define GL_MAX_LIGHTS 0x0D31 +#define GL_MAX_CLIP_PLANES 0x0D32 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_PIXEL_MAP_TABLE 0x0D34 +#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35 +#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 +#define GL_MAX_NAME_STACK_DEPTH 0x0D37 +#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 +#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B + +/* Gets */ +#define GL_ATTRIB_STACK_DEPTH 0x0BB0 +#define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1 +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_CURRENT_INDEX 0x0B01 +#define GL_CURRENT_COLOR 0x0B00 +#define GL_CURRENT_NORMAL 0x0B02 +#define GL_CURRENT_RASTER_COLOR 0x0B04 +#define GL_CURRENT_RASTER_DISTANCE 0x0B09 +#define GL_CURRENT_RASTER_INDEX 0x0B05 +#define GL_CURRENT_RASTER_POSITION 0x0B07 +#define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06 +#define GL_CURRENT_RASTER_POSITION_VALID 0x0B08 +#define GL_CURRENT_TEXTURE_COORDS 0x0B03 +#define GL_INDEX_CLEAR_VALUE 0x0C20 +#define GL_INDEX_MODE 0x0C30 +#define GL_INDEX_WRITEMASK 0x0C21 +#define GL_MODELVIEW_MATRIX 0x0BA6 +#define GL_MODELVIEW_STACK_DEPTH 0x0BA3 +#define GL_NAME_STACK_DEPTH 0x0D70 +#define GL_PROJECTION_MATRIX 0x0BA7 +#define GL_PROJECTION_STACK_DEPTH 0x0BA4 +#define GL_RENDER_MODE 0x0C40 +#define GL_RGBA_MODE 0x0C31 +#define GL_TEXTURE_MATRIX 0x0BA8 +#define GL_TEXTURE_STACK_DEPTH 0x0BA5 +#define GL_VIEWPORT 0x0BA2 + +/* Evaluators */ +#define GL_AUTO_NORMAL 0x0D80 +#define GL_MAP1_COLOR_4 0x0D90 +#define GL_MAP1_INDEX 0x0D91 +#define GL_MAP1_NORMAL 0x0D92 +#define GL_MAP1_TEXTURE_COORD_1 0x0D93 +#define GL_MAP1_TEXTURE_COORD_2 0x0D94 +#define GL_MAP1_TEXTURE_COORD_3 0x0D95 +#define GL_MAP1_TEXTURE_COORD_4 0x0D96 +#define GL_MAP1_VERTEX_3 0x0D97 +#define GL_MAP1_VERTEX_4 0x0D98 +#define GL_MAP2_COLOR_4 0x0DB0 +#define GL_MAP2_INDEX 0x0DB1 +#define GL_MAP2_NORMAL 0x0DB2 +#define GL_MAP2_TEXTURE_COORD_1 0x0DB3 +#define GL_MAP2_TEXTURE_COORD_2 0x0DB4 +#define GL_MAP2_TEXTURE_COORD_3 0x0DB5 +#define GL_MAP2_TEXTURE_COORD_4 0x0DB6 +#define GL_MAP2_VERTEX_3 0x0DB7 +#define GL_MAP2_VERTEX_4 0x0DB8 +#define GL_MAP1_GRID_DOMAIN 0x0DD0 +#define GL_MAP1_GRID_SEGMENTS 0x0DD1 +#define GL_MAP2_GRID_DOMAIN 0x0DD2 +#define GL_MAP2_GRID_SEGMENTS 0x0DD3 +#define GL_COEFF 0x0A00 +#define GL_ORDER 0x0A01 +#define GL_DOMAIN 0x0A02 + +/* Hints */ +#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 +#define GL_POINT_SMOOTH_HINT 0x0C51 +#define GL_LINE_SMOOTH_HINT 0x0C52 +#define GL_POLYGON_SMOOTH_HINT 0x0C53 +#define GL_FOG_HINT 0x0C54 +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 + +/* Scissor box */ +#define GL_SCISSOR_BOX 0x0C10 +#define GL_SCISSOR_TEST 0x0C11 + +/* Pixel Mode / Transfer */ +#define GL_MAP_COLOR 0x0D10 +#define GL_MAP_STENCIL 0x0D11 +#define GL_INDEX_SHIFT 0x0D12 +#define GL_INDEX_OFFSET 0x0D13 +#define GL_RED_SCALE 0x0D14 +#define GL_RED_BIAS 0x0D15 +#define GL_GREEN_SCALE 0x0D18 +#define GL_GREEN_BIAS 0x0D19 +#define GL_BLUE_SCALE 0x0D1A +#define GL_BLUE_BIAS 0x0D1B +#define GL_ALPHA_SCALE 0x0D1C +#define GL_ALPHA_BIAS 0x0D1D +#define GL_DEPTH_SCALE 0x0D1E +#define GL_DEPTH_BIAS 0x0D1F +#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1 +#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0 +#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2 +#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3 +#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4 +#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5 +#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6 +#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7 +#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8 +#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9 +#define GL_PIXEL_MAP_S_TO_S 0x0C71 +#define GL_PIXEL_MAP_I_TO_I 0x0C70 +#define GL_PIXEL_MAP_I_TO_R 0x0C72 +#define GL_PIXEL_MAP_I_TO_G 0x0C73 +#define GL_PIXEL_MAP_I_TO_B 0x0C74 +#define GL_PIXEL_MAP_I_TO_A 0x0C75 +#define GL_PIXEL_MAP_R_TO_R 0x0C76 +#define GL_PIXEL_MAP_G_TO_G 0x0C77 +#define GL_PIXEL_MAP_B_TO_B 0x0C78 +#define GL_PIXEL_MAP_A_TO_A 0x0C79 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_PACK_LSB_FIRST 0x0D01 +#define GL_PACK_ROW_LENGTH 0x0D02 +#define GL_PACK_SKIP_PIXELS 0x0D04 +#define GL_PACK_SKIP_ROWS 0x0D03 +#define GL_PACK_SWAP_BYTES 0x0D00 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_UNPACK_LSB_FIRST 0x0CF1 +#define GL_UNPACK_ROW_LENGTH 0x0CF2 +#define GL_UNPACK_SKIP_PIXELS 0x0CF4 +#define GL_UNPACK_SKIP_ROWS 0x0CF3 +#define GL_UNPACK_SWAP_BYTES 0x0CF0 +#define GL_ZOOM_X 0x0D16 +#define GL_ZOOM_Y 0x0D17 + +/* Texture mapping */ +#define GL_TEXTURE_ENV 0x2300 +#define GL_TEXTURE_ENV_MODE 0x2200 +#define GL_TEXTURE_1D 0x0DE0 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_ENV_COLOR 0x2201 +#define GL_TEXTURE_GEN_S 0x0C60 +#define GL_TEXTURE_GEN_T 0x0C61 +#define GL_TEXTURE_GEN_R 0x0C62 +#define GL_TEXTURE_GEN_Q 0x0C63 +#define GL_TEXTURE_GEN_MODE 0x2500 +#define GL_TEXTURE_BORDER_COLOR 0x1004 +#define GL_TEXTURE_WIDTH 0x1000 +#define GL_TEXTURE_HEIGHT 0x1001 +#define GL_TEXTURE_BORDER 0x1005 +#define GL_TEXTURE_COMPONENTS 0x1003 +#define GL_TEXTURE_RED_SIZE 0x805C +#define GL_TEXTURE_GREEN_SIZE 0x805D +#define GL_TEXTURE_BLUE_SIZE 0x805E +#define GL_TEXTURE_ALPHA_SIZE 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE 0x8061 +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 +#define GL_OBJECT_LINEAR 0x2401 +#define GL_OBJECT_PLANE 0x2501 +#define GL_EYE_LINEAR 0x2400 +#define GL_EYE_PLANE 0x2502 +#define GL_SPHERE_MAP 0x2402 +#define GL_DECAL 0x2101 +#define GL_MODULATE 0x2100 +#define GL_NEAREST 0x2600 +#define GL_REPEAT 0x2901 +#define GL_CLAMP 0x2900 +#define GL_S 0x2000 +#define GL_T 0x2001 +#define GL_R 0x2002 +#define GL_Q 0x2003 + +/* Utility */ +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 + +/* Errors */ +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_STACK_OVERFLOW 0x0503 +#define GL_STACK_UNDERFLOW 0x0504 +#define GL_OUT_OF_MEMORY 0x0505 + +/* glPush/PopAttrib bits */ +#define GL_CURRENT_BIT 0x00000001 +#define GL_POINT_BIT 0x00000002 +#define GL_LINE_BIT 0x00000004 +#define GL_POLYGON_BIT 0x00000008 +#define GL_POLYGON_STIPPLE_BIT 0x00000010 +#define GL_PIXEL_MODE_BIT 0x00000020 +#define GL_LIGHTING_BIT 0x00000040 +#define GL_FOG_BIT 0x00000080 +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_ACCUM_BUFFER_BIT 0x00000200 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_VIEWPORT_BIT 0x00000800 +#define GL_TRANSFORM_BIT 0x00001000 +#define GL_ENABLE_BIT 0x00002000 +#define GL_COLOR_BUFFER_BIT 0x00004000 +#define GL_HINT_BIT 0x00008000 +#define GL_EVAL_BIT 0x00010000 +#define GL_LIST_BIT 0x00020000 +#define GL_TEXTURE_BIT 0x00040000 +#define GL_SCISSOR_BIT 0x00080000 +#define GL_ALL_ATTRIB_BITS 0x000FFFFF + + +/* OpenGL 1.1 */ +#define GL_PROXY_TEXTURE_1D 0x8063 +#define GL_PROXY_TEXTURE_2D 0x8064 +#define GL_TEXTURE_PRIORITY 0x8066 +#define GL_TEXTURE_RESIDENT 0x8067 +#define GL_TEXTURE_BINDING_1D 0x8068 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 +#define GL_ALPHA4 0x803B +#define GL_ALPHA8 0x803C +#define GL_ALPHA12 0x803D +#define GL_ALPHA16 0x803E +#define GL_LUMINANCE4 0x803F +#define GL_LUMINANCE8 0x8040 +#define GL_LUMINANCE12 0x8041 +#define GL_LUMINANCE16 0x8042 +#define GL_LUMINANCE4_ALPHA4 0x8043 +#define GL_LUMINANCE6_ALPHA2 0x8044 +#define GL_LUMINANCE8_ALPHA8 0x8045 +#define GL_LUMINANCE12_ALPHA4 0x8046 +#define GL_LUMINANCE12_ALPHA12 0x8047 +#define GL_LUMINANCE16_ALPHA16 0x8048 +#define GL_INTENSITY 0x8049 +#define GL_INTENSITY4 0x804A +#define GL_INTENSITY8 0x804B +#define GL_INTENSITY12 0x804C +#define GL_INTENSITY16 0x804D +#define GL_R3_G3_B2 0x2A10 +#define GL_RGB4 0x804F +#define GL_RGB5 0x8050 +#define GL_RGB8 0x8051 +#define GL_RGB10 0x8052 +#define GL_RGB12 0x8053 +#define GL_RGB16 0x8054 +#define GL_RGBA2 0x8055 +#define GL_RGBA4 0x8056 +#define GL_RGB5_A1 0x8057 +#define GL_RGBA8 0x8058 +#define GL_RGB10_A2 0x8059 +#define GL_RGBA12 0x805A +#define GL_RGBA16 0x805B +#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001 +#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002 +#define GL_ALL_CLIENT_ATTRIB_BITS 0xFFFFFFFF +#define GL_CLIENT_ALL_ATTRIB_BITS 0xFFFFFFFF + + + +/* + * Miscellaneous + */ + +GLAPI void GLAPIENTRY glClearIndex( GLfloat c ); + +GLAPI void GLAPIENTRY glClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ); + +GLAPI void GLAPIENTRY glClear( GLbitfield mask ); + +GLAPI void GLAPIENTRY glIndexMask( GLuint mask ); + +GLAPI void GLAPIENTRY glColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha ); + +GLAPI void GLAPIENTRY glAlphaFunc( GLenum func, GLclampf ref ); + +GLAPI void GLAPIENTRY glBlendFunc( GLenum sfactor, GLenum dfactor ); + +GLAPI void GLAPIENTRY glLogicOp( GLenum opcode ); + +GLAPI void GLAPIENTRY glCullFace( GLenum mode ); + +GLAPI void GLAPIENTRY glFrontFace( GLenum mode ); + +GLAPI void GLAPIENTRY glPointSize( GLfloat size ); + +GLAPI void GLAPIENTRY glLineWidth( GLfloat width ); + +GLAPI void GLAPIENTRY glLineStipple( GLint factor, GLushort pattern ); + +GLAPI void GLAPIENTRY glPolygonMode( GLenum face, GLenum mode ); + +GLAPI void GLAPIENTRY glPolygonOffset( GLfloat factor, GLfloat units ); + +GLAPI void GLAPIENTRY glPolygonStipple( const GLubyte *mask ); + +GLAPI void GLAPIENTRY glGetPolygonStipple( GLubyte *mask ); + +GLAPI void GLAPIENTRY glEdgeFlag( GLboolean flag ); + +GLAPI void GLAPIENTRY glEdgeFlagv( const GLboolean *flag ); + +GLAPI void GLAPIENTRY glScissor( GLint x, GLint y, GLsizei width, GLsizei height); + +GLAPI void GLAPIENTRY glClipPlane( GLenum plane, const GLdouble *equation ); + +GLAPI void GLAPIENTRY glGetClipPlane( GLenum plane, GLdouble *equation ); + +GLAPI void GLAPIENTRY glDrawBuffer( GLenum mode ); + +GLAPI void GLAPIENTRY glReadBuffer( GLenum mode ); + +GLAPI void GLAPIENTRY glEnable( GLenum cap ); + +GLAPI void GLAPIENTRY glDisable( GLenum cap ); + +GLAPI GLboolean GLAPIENTRY glIsEnabled( GLenum cap ); + + +GLAPI void GLAPIENTRY glEnableClientState( GLenum cap ); /* 1.1 */ + +GLAPI void GLAPIENTRY glDisableClientState( GLenum cap ); /* 1.1 */ + + +GLAPI void GLAPIENTRY glGetBooleanv( GLenum pname, GLboolean *params ); + +GLAPI void GLAPIENTRY glGetDoublev( GLenum pname, GLdouble *params ); + +GLAPI void GLAPIENTRY glGetFloatv( GLenum pname, GLfloat *params ); + +GLAPI void GLAPIENTRY glGetIntegerv( GLenum pname, GLint *params ); + + +GLAPI void GLAPIENTRY glPushAttrib( GLbitfield mask ); + +GLAPI void GLAPIENTRY glPopAttrib( void ); + + +GLAPI void GLAPIENTRY glPushClientAttrib( GLbitfield mask ); /* 1.1 */ + +GLAPI void GLAPIENTRY glPopClientAttrib( void ); /* 1.1 */ + + +GLAPI GLint GLAPIENTRY glRenderMode( GLenum mode ); + +GLAPI GLenum GLAPIENTRY glGetError( void ); + +GLAPI const GLubyte * GLAPIENTRY glGetString( GLenum name ); + +GLAPI void GLAPIENTRY glFinish( void ); + +GLAPI void GLAPIENTRY glFlush( void ); + +GLAPI void GLAPIENTRY glHint( GLenum target, GLenum mode ); + + +/* + * Depth Buffer + */ + +GLAPI void GLAPIENTRY glClearDepth( GLclampd depth ); + +GLAPI void GLAPIENTRY glDepthFunc( GLenum func ); + +GLAPI void GLAPIENTRY glDepthMask( GLboolean flag ); + +GLAPI void GLAPIENTRY glDepthRange( GLclampd near_val, GLclampd far_val ); + + +/* + * Accumulation Buffer + */ + +GLAPI void GLAPIENTRY glClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ); + +GLAPI void GLAPIENTRY glAccum( GLenum op, GLfloat value ); + + +/* + * Transformation + */ + +GLAPI void GLAPIENTRY glMatrixMode( GLenum mode ); + +GLAPI void GLAPIENTRY glOrtho( GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble near_val, GLdouble far_val ); + +GLAPI void GLAPIENTRY glFrustum( GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble near_val, GLdouble far_val ); + +GLAPI void GLAPIENTRY glViewport( GLint x, GLint y, + GLsizei width, GLsizei height ); + +GLAPI void GLAPIENTRY glPushMatrix( void ); + +GLAPI void GLAPIENTRY glPopMatrix( void ); + +GLAPI void GLAPIENTRY glLoadIdentity( void ); + +GLAPI void GLAPIENTRY glLoadMatrixd( const GLdouble *m ); +GLAPI void GLAPIENTRY glLoadMatrixf( const GLfloat *m ); + +GLAPI void GLAPIENTRY glMultMatrixd( const GLdouble *m ); +GLAPI void GLAPIENTRY glMultMatrixf( const GLfloat *m ); + +GLAPI void GLAPIENTRY glRotated( GLdouble angle, + GLdouble x, GLdouble y, GLdouble z ); +GLAPI void GLAPIENTRY glRotatef( GLfloat angle, + GLfloat x, GLfloat y, GLfloat z ); + +GLAPI void GLAPIENTRY glScaled( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void GLAPIENTRY glScalef( GLfloat x, GLfloat y, GLfloat z ); + +GLAPI void GLAPIENTRY glTranslated( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void GLAPIENTRY glTranslatef( GLfloat x, GLfloat y, GLfloat z ); + + +/* + * Display Lists + */ + +GLAPI GLboolean GLAPIENTRY glIsList( GLuint list ); + +GLAPI void GLAPIENTRY glDeleteLists( GLuint list, GLsizei range ); + +GLAPI GLuint GLAPIENTRY glGenLists( GLsizei range ); + +GLAPI void GLAPIENTRY glNewList( GLuint list, GLenum mode ); + +GLAPI void GLAPIENTRY glEndList( void ); + +GLAPI void GLAPIENTRY glCallList( GLuint list ); + +GLAPI void GLAPIENTRY glCallLists( GLsizei n, GLenum type, + const GLvoid *lists ); + +GLAPI void GLAPIENTRY glListBase( GLuint base ); + + +/* + * Drawing Functions + */ + +GLAPI void GLAPIENTRY glBegin( GLenum mode ); + +GLAPI void GLAPIENTRY glEnd( void ); + + +GLAPI void GLAPIENTRY glVertex2d( GLdouble x, GLdouble y ); +GLAPI void GLAPIENTRY glVertex2f( GLfloat x, GLfloat y ); +GLAPI void GLAPIENTRY glVertex2i( GLint x, GLint y ); +GLAPI void GLAPIENTRY glVertex2s( GLshort x, GLshort y ); + +GLAPI void GLAPIENTRY glVertex3d( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void GLAPIENTRY glVertex3f( GLfloat x, GLfloat y, GLfloat z ); +GLAPI void GLAPIENTRY glVertex3i( GLint x, GLint y, GLint z ); +GLAPI void GLAPIENTRY glVertex3s( GLshort x, GLshort y, GLshort z ); + +GLAPI void GLAPIENTRY glVertex4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ); +GLAPI void GLAPIENTRY glVertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ); +GLAPI void GLAPIENTRY glVertex4i( GLint x, GLint y, GLint z, GLint w ); +GLAPI void GLAPIENTRY glVertex4s( GLshort x, GLshort y, GLshort z, GLshort w ); + +GLAPI void GLAPIENTRY glVertex2dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glVertex2fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glVertex2iv( const GLint *v ); +GLAPI void GLAPIENTRY glVertex2sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glVertex3dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glVertex3fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glVertex3iv( const GLint *v ); +GLAPI void GLAPIENTRY glVertex3sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glVertex4dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glVertex4fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glVertex4iv( const GLint *v ); +GLAPI void GLAPIENTRY glVertex4sv( const GLshort *v ); + + +GLAPI void GLAPIENTRY glNormal3b( GLbyte nx, GLbyte ny, GLbyte nz ); +GLAPI void GLAPIENTRY glNormal3d( GLdouble nx, GLdouble ny, GLdouble nz ); +GLAPI void GLAPIENTRY glNormal3f( GLfloat nx, GLfloat ny, GLfloat nz ); +GLAPI void GLAPIENTRY glNormal3i( GLint nx, GLint ny, GLint nz ); +GLAPI void GLAPIENTRY glNormal3s( GLshort nx, GLshort ny, GLshort nz ); + +GLAPI void GLAPIENTRY glNormal3bv( const GLbyte *v ); +GLAPI void GLAPIENTRY glNormal3dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glNormal3fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glNormal3iv( const GLint *v ); +GLAPI void GLAPIENTRY glNormal3sv( const GLshort *v ); + + +GLAPI void GLAPIENTRY glIndexd( GLdouble c ); +GLAPI void GLAPIENTRY glIndexf( GLfloat c ); +GLAPI void GLAPIENTRY glIndexi( GLint c ); +GLAPI void GLAPIENTRY glIndexs( GLshort c ); +GLAPI void GLAPIENTRY glIndexub( GLubyte c ); /* 1.1 */ + +GLAPI void GLAPIENTRY glIndexdv( const GLdouble *c ); +GLAPI void GLAPIENTRY glIndexfv( const GLfloat *c ); +GLAPI void GLAPIENTRY glIndexiv( const GLint *c ); +GLAPI void GLAPIENTRY glIndexsv( const GLshort *c ); +GLAPI void GLAPIENTRY glIndexubv( const GLubyte *c ); /* 1.1 */ + +GLAPI void GLAPIENTRY glColor3b( GLbyte red, GLbyte green, GLbyte blue ); +GLAPI void GLAPIENTRY glColor3d( GLdouble red, GLdouble green, GLdouble blue ); +GLAPI void GLAPIENTRY glColor3f( GLfloat red, GLfloat green, GLfloat blue ); +GLAPI void GLAPIENTRY glColor3i( GLint red, GLint green, GLint blue ); +GLAPI void GLAPIENTRY glColor3s( GLshort red, GLshort green, GLshort blue ); +GLAPI void GLAPIENTRY glColor3ub( GLubyte red, GLubyte green, GLubyte blue ); +GLAPI void GLAPIENTRY glColor3ui( GLuint red, GLuint green, GLuint blue ); +GLAPI void GLAPIENTRY glColor3us( GLushort red, GLushort green, GLushort blue ); + +GLAPI void GLAPIENTRY glColor4b( GLbyte red, GLbyte green, + GLbyte blue, GLbyte alpha ); +GLAPI void GLAPIENTRY glColor4d( GLdouble red, GLdouble green, + GLdouble blue, GLdouble alpha ); +GLAPI void GLAPIENTRY glColor4f( GLfloat red, GLfloat green, + GLfloat blue, GLfloat alpha ); +GLAPI void GLAPIENTRY glColor4i( GLint red, GLint green, + GLint blue, GLint alpha ); +GLAPI void GLAPIENTRY glColor4s( GLshort red, GLshort green, + GLshort blue, GLshort alpha ); +GLAPI void GLAPIENTRY glColor4ub( GLubyte red, GLubyte green, + GLubyte blue, GLubyte alpha ); +GLAPI void GLAPIENTRY glColor4ui( GLuint red, GLuint green, + GLuint blue, GLuint alpha ); +GLAPI void GLAPIENTRY glColor4us( GLushort red, GLushort green, + GLushort blue, GLushort alpha ); + + +GLAPI void GLAPIENTRY glColor3bv( const GLbyte *v ); +GLAPI void GLAPIENTRY glColor3dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glColor3fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glColor3iv( const GLint *v ); +GLAPI void GLAPIENTRY glColor3sv( const GLshort *v ); +GLAPI void GLAPIENTRY glColor3ubv( const GLubyte *v ); +GLAPI void GLAPIENTRY glColor3uiv( const GLuint *v ); +GLAPI void GLAPIENTRY glColor3usv( const GLushort *v ); + +GLAPI void GLAPIENTRY glColor4bv( const GLbyte *v ); +GLAPI void GLAPIENTRY glColor4dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glColor4fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glColor4iv( const GLint *v ); +GLAPI void GLAPIENTRY glColor4sv( const GLshort *v ); +GLAPI void GLAPIENTRY glColor4ubv( const GLubyte *v ); +GLAPI void GLAPIENTRY glColor4uiv( const GLuint *v ); +GLAPI void GLAPIENTRY glColor4usv( const GLushort *v ); + + +GLAPI void GLAPIENTRY glTexCoord1d( GLdouble s ); +GLAPI void GLAPIENTRY glTexCoord1f( GLfloat s ); +GLAPI void GLAPIENTRY glTexCoord1i( GLint s ); +GLAPI void GLAPIENTRY glTexCoord1s( GLshort s ); + +GLAPI void GLAPIENTRY glTexCoord2d( GLdouble s, GLdouble t ); +GLAPI void GLAPIENTRY glTexCoord2f( GLfloat s, GLfloat t ); +GLAPI void GLAPIENTRY glTexCoord2i( GLint s, GLint t ); +GLAPI void GLAPIENTRY glTexCoord2s( GLshort s, GLshort t ); + +GLAPI void GLAPIENTRY glTexCoord3d( GLdouble s, GLdouble t, GLdouble r ); +GLAPI void GLAPIENTRY glTexCoord3f( GLfloat s, GLfloat t, GLfloat r ); +GLAPI void GLAPIENTRY glTexCoord3i( GLint s, GLint t, GLint r ); +GLAPI void GLAPIENTRY glTexCoord3s( GLshort s, GLshort t, GLshort r ); + +GLAPI void GLAPIENTRY glTexCoord4d( GLdouble s, GLdouble t, GLdouble r, GLdouble q ); +GLAPI void GLAPIENTRY glTexCoord4f( GLfloat s, GLfloat t, GLfloat r, GLfloat q ); +GLAPI void GLAPIENTRY glTexCoord4i( GLint s, GLint t, GLint r, GLint q ); +GLAPI void GLAPIENTRY glTexCoord4s( GLshort s, GLshort t, GLshort r, GLshort q ); + +GLAPI void GLAPIENTRY glTexCoord1dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glTexCoord1fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glTexCoord1iv( const GLint *v ); +GLAPI void GLAPIENTRY glTexCoord1sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glTexCoord2dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glTexCoord2fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glTexCoord2iv( const GLint *v ); +GLAPI void GLAPIENTRY glTexCoord2sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glTexCoord3dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glTexCoord3fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glTexCoord3iv( const GLint *v ); +GLAPI void GLAPIENTRY glTexCoord3sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glTexCoord4dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glTexCoord4fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glTexCoord4iv( const GLint *v ); +GLAPI void GLAPIENTRY glTexCoord4sv( const GLshort *v ); + + +GLAPI void GLAPIENTRY glRasterPos2d( GLdouble x, GLdouble y ); +GLAPI void GLAPIENTRY glRasterPos2f( GLfloat x, GLfloat y ); +GLAPI void GLAPIENTRY glRasterPos2i( GLint x, GLint y ); +GLAPI void GLAPIENTRY glRasterPos2s( GLshort x, GLshort y ); + +GLAPI void GLAPIENTRY glRasterPos3d( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void GLAPIENTRY glRasterPos3f( GLfloat x, GLfloat y, GLfloat z ); +GLAPI void GLAPIENTRY glRasterPos3i( GLint x, GLint y, GLint z ); +GLAPI void GLAPIENTRY glRasterPos3s( GLshort x, GLshort y, GLshort z ); + +GLAPI void GLAPIENTRY glRasterPos4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ); +GLAPI void GLAPIENTRY glRasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ); +GLAPI void GLAPIENTRY glRasterPos4i( GLint x, GLint y, GLint z, GLint w ); +GLAPI void GLAPIENTRY glRasterPos4s( GLshort x, GLshort y, GLshort z, GLshort w ); + +GLAPI void GLAPIENTRY glRasterPos2dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glRasterPos2fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glRasterPos2iv( const GLint *v ); +GLAPI void GLAPIENTRY glRasterPos2sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glRasterPos3dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glRasterPos3fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glRasterPos3iv( const GLint *v ); +GLAPI void GLAPIENTRY glRasterPos3sv( const GLshort *v ); + +GLAPI void GLAPIENTRY glRasterPos4dv( const GLdouble *v ); +GLAPI void GLAPIENTRY glRasterPos4fv( const GLfloat *v ); +GLAPI void GLAPIENTRY glRasterPos4iv( const GLint *v ); +GLAPI void GLAPIENTRY glRasterPos4sv( const GLshort *v ); + + +GLAPI void GLAPIENTRY glRectd( GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2 ); +GLAPI void GLAPIENTRY glRectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ); +GLAPI void GLAPIENTRY glRecti( GLint x1, GLint y1, GLint x2, GLint y2 ); +GLAPI void GLAPIENTRY glRects( GLshort x1, GLshort y1, GLshort x2, GLshort y2 ); + + +GLAPI void GLAPIENTRY glRectdv( const GLdouble *v1, const GLdouble *v2 ); +GLAPI void GLAPIENTRY glRectfv( const GLfloat *v1, const GLfloat *v2 ); +GLAPI void GLAPIENTRY glRectiv( const GLint *v1, const GLint *v2 ); +GLAPI void GLAPIENTRY glRectsv( const GLshort *v1, const GLshort *v2 ); + + +/* + * Vertex Arrays (1.1) + */ + +GLAPI void GLAPIENTRY glVertexPointer( GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glNormalPointer( GLenum type, GLsizei stride, + const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glColorPointer( GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glIndexPointer( GLenum type, GLsizei stride, + const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glTexCoordPointer( GLint size, GLenum type, + GLsizei stride, const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glEdgeFlagPointer( GLsizei stride, const GLvoid *ptr ); + +GLAPI void GLAPIENTRY glGetPointerv( GLenum pname, GLvoid **params ); + +GLAPI void GLAPIENTRY glArrayElement( GLint i ); + +GLAPI void GLAPIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count ); + +GLAPI void GLAPIENTRY glDrawElements( GLenum mode, GLsizei count, + GLenum type, const GLvoid *indices ); + +GLAPI void GLAPIENTRY glInterleavedArrays( GLenum format, GLsizei stride, + const GLvoid *pointer ); + +/* + * Lighting + */ + +GLAPI void GLAPIENTRY glShadeModel( GLenum mode ); + +GLAPI void GLAPIENTRY glLightf( GLenum light, GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glLighti( GLenum light, GLenum pname, GLint param ); +GLAPI void GLAPIENTRY glLightfv( GLenum light, GLenum pname, + const GLfloat *params ); +GLAPI void GLAPIENTRY glLightiv( GLenum light, GLenum pname, + const GLint *params ); + +GLAPI void GLAPIENTRY glGetLightfv( GLenum light, GLenum pname, + GLfloat *params ); +GLAPI void GLAPIENTRY glGetLightiv( GLenum light, GLenum pname, + GLint *params ); + +GLAPI void GLAPIENTRY glLightModelf( GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glLightModeli( GLenum pname, GLint param ); +GLAPI void GLAPIENTRY glLightModelfv( GLenum pname, const GLfloat *params ); +GLAPI void GLAPIENTRY glLightModeliv( GLenum pname, const GLint *params ); + +GLAPI void GLAPIENTRY glMaterialf( GLenum face, GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glMateriali( GLenum face, GLenum pname, GLint param ); +GLAPI void GLAPIENTRY glMaterialfv( GLenum face, GLenum pname, const GLfloat *params ); +GLAPI void GLAPIENTRY glMaterialiv( GLenum face, GLenum pname, const GLint *params ); + +GLAPI void GLAPIENTRY glGetMaterialfv( GLenum face, GLenum pname, GLfloat *params ); +GLAPI void GLAPIENTRY glGetMaterialiv( GLenum face, GLenum pname, GLint *params ); + +GLAPI void GLAPIENTRY glColorMaterial( GLenum face, GLenum mode ); + + +/* + * Raster functions + */ + +GLAPI void GLAPIENTRY glPixelZoom( GLfloat xfactor, GLfloat yfactor ); + +GLAPI void GLAPIENTRY glPixelStoref( GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glPixelStorei( GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glPixelTransferf( GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glPixelTransferi( GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glPixelMapfv( GLenum map, GLsizei mapsize, + const GLfloat *values ); +GLAPI void GLAPIENTRY glPixelMapuiv( GLenum map, GLsizei mapsize, + const GLuint *values ); +GLAPI void GLAPIENTRY glPixelMapusv( GLenum map, GLsizei mapsize, + const GLushort *values ); + +GLAPI void GLAPIENTRY glGetPixelMapfv( GLenum map, GLfloat *values ); +GLAPI void GLAPIENTRY glGetPixelMapuiv( GLenum map, GLuint *values ); +GLAPI void GLAPIENTRY glGetPixelMapusv( GLenum map, GLushort *values ); + +GLAPI void GLAPIENTRY glBitmap( GLsizei width, GLsizei height, + GLfloat xorig, GLfloat yorig, + GLfloat xmove, GLfloat ymove, + const GLubyte *bitmap ); + +GLAPI void GLAPIENTRY glReadPixels( GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + GLvoid *pixels ); + +GLAPI void GLAPIENTRY glDrawPixels( GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels ); + +GLAPI void GLAPIENTRY glCopyPixels( GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum type ); + +/* + * Stenciling + */ + +GLAPI void GLAPIENTRY glStencilFunc( GLenum func, GLint ref, GLuint mask ); + +GLAPI void GLAPIENTRY glStencilMask( GLuint mask ); + +GLAPI void GLAPIENTRY glStencilOp( GLenum fail, GLenum zfail, GLenum zpass ); + +GLAPI void GLAPIENTRY glClearStencil( GLint s ); + + + +/* + * Texture mapping + */ + +GLAPI void GLAPIENTRY glTexGend( GLenum coord, GLenum pname, GLdouble param ); +GLAPI void GLAPIENTRY glTexGenf( GLenum coord, GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glTexGeni( GLenum coord, GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glTexGendv( GLenum coord, GLenum pname, const GLdouble *params ); +GLAPI void GLAPIENTRY glTexGenfv( GLenum coord, GLenum pname, const GLfloat *params ); +GLAPI void GLAPIENTRY glTexGeniv( GLenum coord, GLenum pname, const GLint *params ); + +GLAPI void GLAPIENTRY glGetTexGendv( GLenum coord, GLenum pname, GLdouble *params ); +GLAPI void GLAPIENTRY glGetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ); +GLAPI void GLAPIENTRY glGetTexGeniv( GLenum coord, GLenum pname, GLint *params ); + + +GLAPI void GLAPIENTRY glTexEnvf( GLenum target, GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glTexEnvi( GLenum target, GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glTexEnvfv( GLenum target, GLenum pname, const GLfloat *params ); +GLAPI void GLAPIENTRY glTexEnviv( GLenum target, GLenum pname, const GLint *params ); + +GLAPI void GLAPIENTRY glGetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ); +GLAPI void GLAPIENTRY glGetTexEnviv( GLenum target, GLenum pname, GLint *params ); + + +GLAPI void GLAPIENTRY glTexParameterf( GLenum target, GLenum pname, GLfloat param ); +GLAPI void GLAPIENTRY glTexParameteri( GLenum target, GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glTexParameterfv( GLenum target, GLenum pname, + const GLfloat *params ); +GLAPI void GLAPIENTRY glTexParameteriv( GLenum target, GLenum pname, + const GLint *params ); + +GLAPI void GLAPIENTRY glGetTexParameterfv( GLenum target, + GLenum pname, GLfloat *params); +GLAPI void GLAPIENTRY glGetTexParameteriv( GLenum target, + GLenum pname, GLint *params ); + +GLAPI void GLAPIENTRY glGetTexLevelParameterfv( GLenum target, GLint level, + GLenum pname, GLfloat *params ); +GLAPI void GLAPIENTRY glGetTexLevelParameteriv( GLenum target, GLint level, + GLenum pname, GLint *params ); + + +GLAPI void GLAPIENTRY glTexImage1D( GLenum target, GLint level, + GLint internalFormat, + GLsizei width, GLint border, + GLenum format, GLenum type, + const GLvoid *pixels ); + +GLAPI void GLAPIENTRY glTexImage2D( GLenum target, GLint level, + GLint internalFormat, + GLsizei width, GLsizei height, + GLint border, GLenum format, GLenum type, + const GLvoid *pixels ); + +GLAPI void GLAPIENTRY glGetTexImage( GLenum target, GLint level, + GLenum format, GLenum type, + GLvoid *pixels ); + + +/* 1.1 functions */ + +GLAPI void GLAPIENTRY glGenTextures( GLsizei n, GLuint *textures ); + +GLAPI void GLAPIENTRY glDeleteTextures( GLsizei n, const GLuint *textures); + +GLAPI void GLAPIENTRY glBindTexture( GLenum target, GLuint texture ); + +GLAPI void GLAPIENTRY glPrioritizeTextures( GLsizei n, + const GLuint *textures, + const GLclampf *priorities ); + +GLAPI GLboolean GLAPIENTRY glAreTexturesResident( GLsizei n, + const GLuint *textures, + GLboolean *residences ); + +GLAPI GLboolean GLAPIENTRY glIsTexture( GLuint texture ); + + +GLAPI void GLAPIENTRY glTexSubImage1D( GLenum target, GLint level, + GLint xoffset, + GLsizei width, GLenum format, + GLenum type, const GLvoid *pixels ); + + +GLAPI void GLAPIENTRY glTexSubImage2D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels ); + + +GLAPI void GLAPIENTRY glCopyTexImage1D( GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, + GLsizei width, GLint border ); + + +GLAPI void GLAPIENTRY glCopyTexImage2D( GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, + GLsizei width, GLsizei height, + GLint border ); + + +GLAPI void GLAPIENTRY glCopyTexSubImage1D( GLenum target, GLint level, + GLint xoffset, GLint x, GLint y, + GLsizei width ); + + +GLAPI void GLAPIENTRY glCopyTexSubImage2D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, + GLsizei width, GLsizei height ); + + +/* + * Evaluators + */ + +GLAPI void GLAPIENTRY glMap1d( GLenum target, GLdouble u1, GLdouble u2, + GLint stride, + GLint order, const GLdouble *points ); +GLAPI void GLAPIENTRY glMap1f( GLenum target, GLfloat u1, GLfloat u2, + GLint stride, + GLint order, const GLfloat *points ); + +GLAPI void GLAPIENTRY glMap2d( GLenum target, + GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, + GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, + const GLdouble *points ); +GLAPI void GLAPIENTRY glMap2f( GLenum target, + GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, + GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, + const GLfloat *points ); + +GLAPI void GLAPIENTRY glGetMapdv( GLenum target, GLenum query, GLdouble *v ); +GLAPI void GLAPIENTRY glGetMapfv( GLenum target, GLenum query, GLfloat *v ); +GLAPI void GLAPIENTRY glGetMapiv( GLenum target, GLenum query, GLint *v ); + +GLAPI void GLAPIENTRY glEvalCoord1d( GLdouble u ); +GLAPI void GLAPIENTRY glEvalCoord1f( GLfloat u ); + +GLAPI void GLAPIENTRY glEvalCoord1dv( const GLdouble *u ); +GLAPI void GLAPIENTRY glEvalCoord1fv( const GLfloat *u ); + +GLAPI void GLAPIENTRY glEvalCoord2d( GLdouble u, GLdouble v ); +GLAPI void GLAPIENTRY glEvalCoord2f( GLfloat u, GLfloat v ); + +GLAPI void GLAPIENTRY glEvalCoord2dv( const GLdouble *u ); +GLAPI void GLAPIENTRY glEvalCoord2fv( const GLfloat *u ); + +GLAPI void GLAPIENTRY glMapGrid1d( GLint un, GLdouble u1, GLdouble u2 ); +GLAPI void GLAPIENTRY glMapGrid1f( GLint un, GLfloat u1, GLfloat u2 ); + +GLAPI void GLAPIENTRY glMapGrid2d( GLint un, GLdouble u1, GLdouble u2, + GLint vn, GLdouble v1, GLdouble v2 ); +GLAPI void GLAPIENTRY glMapGrid2f( GLint un, GLfloat u1, GLfloat u2, + GLint vn, GLfloat v1, GLfloat v2 ); + +GLAPI void GLAPIENTRY glEvalPoint1( GLint i ); + +GLAPI void GLAPIENTRY glEvalPoint2( GLint i, GLint j ); + +GLAPI void GLAPIENTRY glEvalMesh1( GLenum mode, GLint i1, GLint i2 ); + +GLAPI void GLAPIENTRY glEvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ); + + +/* + * Fog + */ + +GLAPI void GLAPIENTRY glFogf( GLenum pname, GLfloat param ); + +GLAPI void GLAPIENTRY glFogi( GLenum pname, GLint param ); + +GLAPI void GLAPIENTRY glFogfv( GLenum pname, const GLfloat *params ); + +GLAPI void GLAPIENTRY glFogiv( GLenum pname, const GLint *params ); + + +/* + * Selection and Feedback + */ + +GLAPI void GLAPIENTRY glFeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer ); + +GLAPI void GLAPIENTRY glPassThrough( GLfloat token ); + +GLAPI void GLAPIENTRY glSelectBuffer( GLsizei size, GLuint *buffer ); + +GLAPI void GLAPIENTRY glInitNames( void ); + +GLAPI void GLAPIENTRY glLoadName( GLuint name ); + +GLAPI void GLAPIENTRY glPushName( GLuint name ); + +GLAPI void GLAPIENTRY glPopName( void ); + + + +/* + * OpenGL 1.2 + */ + +#define GL_RESCALE_NORMAL 0x803A +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_TEXTURE_BINDING_3D 0x806A + +GLAPI void GLAPIENTRY glDrawRangeElements( GLenum mode, GLuint start, + GLuint end, GLsizei count, GLenum type, const GLvoid *indices ); + +GLAPI void GLAPIENTRY glTexImage3D( GLenum target, GLint level, + GLint internalFormat, + GLsizei width, GLsizei height, + GLsizei depth, GLint border, + GLenum format, GLenum type, + const GLvoid *pixels ); + +GLAPI void GLAPIENTRY glTexSubImage3D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint zoffset, GLsizei width, + GLsizei height, GLsizei depth, + GLenum format, + GLenum type, const GLvoid *pixels); + +GLAPI void GLAPIENTRY glCopyTexSubImage3D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint zoffset, GLint x, + GLint y, GLsizei width, + GLsizei height ); + +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); + + +/* + * GL_ARB_imaging + */ + +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX 0x802E +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_BLEND_EQUATION 0x8009 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_FUNC_ADD 0x8006 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_BLEND_COLOR 0x8005 + + +GLAPI void GLAPIENTRY glColorTable( GLenum target, GLenum internalformat, + GLsizei width, GLenum format, + GLenum type, const GLvoid *table ); + +GLAPI void GLAPIENTRY glColorSubTable( GLenum target, + GLsizei start, GLsizei count, + GLenum format, GLenum type, + const GLvoid *data ); + +GLAPI void GLAPIENTRY glColorTableParameteriv(GLenum target, GLenum pname, + const GLint *params); + +GLAPI void GLAPIENTRY glColorTableParameterfv(GLenum target, GLenum pname, + const GLfloat *params); + +GLAPI void GLAPIENTRY glCopyColorSubTable( GLenum target, GLsizei start, + GLint x, GLint y, GLsizei width ); + +GLAPI void GLAPIENTRY glCopyColorTable( GLenum target, GLenum internalformat, + GLint x, GLint y, GLsizei width ); + +GLAPI void GLAPIENTRY glGetColorTable( GLenum target, GLenum format, + GLenum type, GLvoid *table ); + +GLAPI void GLAPIENTRY glGetColorTableParameterfv( GLenum target, GLenum pname, + GLfloat *params ); + +GLAPI void GLAPIENTRY glGetColorTableParameteriv( GLenum target, GLenum pname, + GLint *params ); + +GLAPI void GLAPIENTRY glBlendEquation( GLenum mode ); + +GLAPI void GLAPIENTRY glBlendColor( GLclampf red, GLclampf green, + GLclampf blue, GLclampf alpha ); + +GLAPI void GLAPIENTRY glHistogram( GLenum target, GLsizei width, + GLenum internalformat, GLboolean sink ); + +GLAPI void GLAPIENTRY glResetHistogram( GLenum target ); + +GLAPI void GLAPIENTRY glGetHistogram( GLenum target, GLboolean reset, + GLenum format, GLenum type, + GLvoid *values ); + +GLAPI void GLAPIENTRY glGetHistogramParameterfv( GLenum target, GLenum pname, + GLfloat *params ); + +GLAPI void GLAPIENTRY glGetHistogramParameteriv( GLenum target, GLenum pname, + GLint *params ); + +GLAPI void GLAPIENTRY glMinmax( GLenum target, GLenum internalformat, + GLboolean sink ); + +GLAPI void GLAPIENTRY glResetMinmax( GLenum target ); + +GLAPI void GLAPIENTRY glGetMinmax( GLenum target, GLboolean reset, + GLenum format, GLenum types, + GLvoid *values ); + +GLAPI void GLAPIENTRY glGetMinmaxParameterfv( GLenum target, GLenum pname, + GLfloat *params ); + +GLAPI void GLAPIENTRY glGetMinmaxParameteriv( GLenum target, GLenum pname, + GLint *params ); + +GLAPI void GLAPIENTRY glConvolutionFilter1D( GLenum target, + GLenum internalformat, GLsizei width, GLenum format, GLenum type, + const GLvoid *image ); + +GLAPI void GLAPIENTRY glConvolutionFilter2D( GLenum target, + GLenum internalformat, GLsizei width, GLsizei height, GLenum format, + GLenum type, const GLvoid *image ); + +GLAPI void GLAPIENTRY glConvolutionParameterf( GLenum target, GLenum pname, + GLfloat params ); + +GLAPI void GLAPIENTRY glConvolutionParameterfv( GLenum target, GLenum pname, + const GLfloat *params ); + +GLAPI void GLAPIENTRY glConvolutionParameteri( GLenum target, GLenum pname, + GLint params ); + +GLAPI void GLAPIENTRY glConvolutionParameteriv( GLenum target, GLenum pname, + const GLint *params ); + +GLAPI void GLAPIENTRY glCopyConvolutionFilter1D( GLenum target, + GLenum internalformat, GLint x, GLint y, GLsizei width ); + +GLAPI void GLAPIENTRY glCopyConvolutionFilter2D( GLenum target, + GLenum internalformat, GLint x, GLint y, GLsizei width, + GLsizei height); + +GLAPI void GLAPIENTRY glGetConvolutionFilter( GLenum target, GLenum format, + GLenum type, GLvoid *image ); + +GLAPI void GLAPIENTRY glGetConvolutionParameterfv( GLenum target, GLenum pname, + GLfloat *params ); + +GLAPI void GLAPIENTRY glGetConvolutionParameteriv( GLenum target, GLenum pname, + GLint *params ); + +GLAPI void GLAPIENTRY glSeparableFilter2D( GLenum target, + GLenum internalformat, GLsizei width, GLsizei height, GLenum format, + GLenum type, const GLvoid *row, const GLvoid *column ); + +GLAPI void GLAPIENTRY glGetSeparableFilter( GLenum target, GLenum format, + GLenum type, GLvoid *row, GLvoid *column, GLvoid *span ); + + + + +/* + * OpenGL 1.3 + */ + +/* multitexture */ +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +/* texture_cube_map */ +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +/* texture_compression */ +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +/* multisample */ +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_MULTISAMPLE_BIT 0x20000000 +/* transpose_matrix */ +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +/* texture_env_combine */ +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_SUBTRACT 0x84E7 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +/* texture_env_dot3 */ +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +/* texture_border_clamp */ +#define GL_CLAMP_TO_BORDER 0x812D + +GLAPI void GLAPIENTRY glActiveTexture( GLenum texture ); + +GLAPI void GLAPIENTRY glClientActiveTexture( GLenum texture ); + +GLAPI void GLAPIENTRY glCompressedTexImage1D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glCompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glCompressedTexImage3D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glCompressedTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glCompressedTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glCompressedTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data ); + +GLAPI void GLAPIENTRY glGetCompressedTexImage( GLenum target, GLint lod, GLvoid *img ); + +GLAPI void GLAPIENTRY glMultiTexCoord1d( GLenum target, GLdouble s ); + +GLAPI void GLAPIENTRY glMultiTexCoord1dv( GLenum target, const GLdouble *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord1f( GLenum target, GLfloat s ); + +GLAPI void GLAPIENTRY glMultiTexCoord1fv( GLenum target, const GLfloat *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord1i( GLenum target, GLint s ); + +GLAPI void GLAPIENTRY glMultiTexCoord1iv( GLenum target, const GLint *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord1s( GLenum target, GLshort s ); + +GLAPI void GLAPIENTRY glMultiTexCoord1sv( GLenum target, const GLshort *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord2d( GLenum target, GLdouble s, GLdouble t ); + +GLAPI void GLAPIENTRY glMultiTexCoord2dv( GLenum target, const GLdouble *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord2f( GLenum target, GLfloat s, GLfloat t ); + +GLAPI void GLAPIENTRY glMultiTexCoord2fv( GLenum target, const GLfloat *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord2i( GLenum target, GLint s, GLint t ); + +GLAPI void GLAPIENTRY glMultiTexCoord2iv( GLenum target, const GLint *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord2s( GLenum target, GLshort s, GLshort t ); + +GLAPI void GLAPIENTRY glMultiTexCoord2sv( GLenum target, const GLshort *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord3d( GLenum target, GLdouble s, GLdouble t, GLdouble r ); + +GLAPI void GLAPIENTRY glMultiTexCoord3dv( GLenum target, const GLdouble *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord3f( GLenum target, GLfloat s, GLfloat t, GLfloat r ); + +GLAPI void GLAPIENTRY glMultiTexCoord3fv( GLenum target, const GLfloat *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord3i( GLenum target, GLint s, GLint t, GLint r ); + +GLAPI void GLAPIENTRY glMultiTexCoord3iv( GLenum target, const GLint *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord3s( GLenum target, GLshort s, GLshort t, GLshort r ); + +GLAPI void GLAPIENTRY glMultiTexCoord3sv( GLenum target, const GLshort *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord4d( GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q ); + +GLAPI void GLAPIENTRY glMultiTexCoord4dv( GLenum target, const GLdouble *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord4f( GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q ); + +GLAPI void GLAPIENTRY glMultiTexCoord4fv( GLenum target, const GLfloat *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord4i( GLenum target, GLint s, GLint t, GLint r, GLint q ); + +GLAPI void GLAPIENTRY glMultiTexCoord4iv( GLenum target, const GLint *v ); + +GLAPI void GLAPIENTRY glMultiTexCoord4s( GLenum target, GLshort s, GLshort t, GLshort r, GLshort q ); + +GLAPI void GLAPIENTRY glMultiTexCoord4sv( GLenum target, const GLshort *v ); + + +GLAPI void GLAPIENTRY glLoadTransposeMatrixd( const GLdouble m[16] ); + +GLAPI void GLAPIENTRY glLoadTransposeMatrixf( const GLfloat m[16] ); + +GLAPI void GLAPIENTRY glMultTransposeMatrixd( const GLdouble m[16] ); + +GLAPI void GLAPIENTRY glMultTransposeMatrixf( const GLfloat m[16] ); + +GLAPI void GLAPIENTRY glSampleCoverage( GLclampf value, GLboolean invert ); + + +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); + + + +/* + * GL_ARB_multitexture (ARB extension 1 and OpenGL 1.2.1) + */ +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 + +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 + +GLAPI void GLAPIENTRY glActiveTextureARB(GLenum texture); +GLAPI void GLAPIENTRY glClientActiveTextureARB(GLenum texture); +GLAPI void GLAPIENTRY glMultiTexCoord1dARB(GLenum target, GLdouble s); +GLAPI void GLAPIENTRY glMultiTexCoord1dvARB(GLenum target, const GLdouble *v); +GLAPI void GLAPIENTRY glMultiTexCoord1fARB(GLenum target, GLfloat s); +GLAPI void GLAPIENTRY glMultiTexCoord1fvARB(GLenum target, const GLfloat *v); +GLAPI void GLAPIENTRY glMultiTexCoord1iARB(GLenum target, GLint s); +GLAPI void GLAPIENTRY glMultiTexCoord1ivARB(GLenum target, const GLint *v); +GLAPI void GLAPIENTRY glMultiTexCoord1sARB(GLenum target, GLshort s); +GLAPI void GLAPIENTRY glMultiTexCoord1svARB(GLenum target, const GLshort *v); +GLAPI void GLAPIENTRY glMultiTexCoord2dARB(GLenum target, GLdouble s, GLdouble t); +GLAPI void GLAPIENTRY glMultiTexCoord2dvARB(GLenum target, const GLdouble *v); +GLAPI void GLAPIENTRY glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t); +GLAPI void GLAPIENTRY glMultiTexCoord2fvARB(GLenum target, const GLfloat *v); +GLAPI void GLAPIENTRY glMultiTexCoord2iARB(GLenum target, GLint s, GLint t); +GLAPI void GLAPIENTRY glMultiTexCoord2ivARB(GLenum target, const GLint *v); +GLAPI void GLAPIENTRY glMultiTexCoord2sARB(GLenum target, GLshort s, GLshort t); +GLAPI void GLAPIENTRY glMultiTexCoord2svARB(GLenum target, const GLshort *v); +GLAPI void GLAPIENTRY glMultiTexCoord3dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void GLAPIENTRY glMultiTexCoord3dvARB(GLenum target, const GLdouble *v); +GLAPI void GLAPIENTRY glMultiTexCoord3fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void GLAPIENTRY glMultiTexCoord3fvARB(GLenum target, const GLfloat *v); +GLAPI void GLAPIENTRY glMultiTexCoord3iARB(GLenum target, GLint s, GLint t, GLint r); +GLAPI void GLAPIENTRY glMultiTexCoord3ivARB(GLenum target, const GLint *v); +GLAPI void GLAPIENTRY glMultiTexCoord3sARB(GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void GLAPIENTRY glMultiTexCoord3svARB(GLenum target, const GLshort *v); +GLAPI void GLAPIENTRY glMultiTexCoord4dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void GLAPIENTRY glMultiTexCoord4dvARB(GLenum target, const GLdouble *v); +GLAPI void GLAPIENTRY glMultiTexCoord4fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void GLAPIENTRY glMultiTexCoord4fvARB(GLenum target, const GLfloat *v); +GLAPI void GLAPIENTRY glMultiTexCoord4iARB(GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void GLAPIENTRY glMultiTexCoord4ivARB(GLenum target, const GLint *v); +GLAPI void GLAPIENTRY glMultiTexCoord4sARB(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void GLAPIENTRY glMultiTexCoord4svARB(GLenum target, const GLshort *v); + +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); + +#endif /* GL_ARB_multitexture */ + + + +/* + * Define this token if you want "old-style" header file behaviour (extensions + * defined in gl.h). Otherwise, extensions will be included from glext.h. + */ +#if !defined(NO_SDL_GLEXT) && !defined(GL_GLEXT_LEGACY) +#include "SDL_opengl_glext.h" +#endif /* GL_GLEXT_LEGACY */ + + + +/* + * ???. GL_MESA_packed_depth_stencil + * XXX obsolete + */ +#ifndef GL_MESA_packed_depth_stencil +#define GL_MESA_packed_depth_stencil 1 + +#define GL_DEPTH_STENCIL_MESA 0x8750 +#define GL_UNSIGNED_INT_24_8_MESA 0x8751 +#define GL_UNSIGNED_INT_8_24_REV_MESA 0x8752 +#define GL_UNSIGNED_SHORT_15_1_MESA 0x8753 +#define GL_UNSIGNED_SHORT_1_15_REV_MESA 0x8754 + +#endif /* GL_MESA_packed_depth_stencil */ + + +#ifndef GL_ATI_blend_equation_separate +#define GL_ATI_blend_equation_separate 1 + +#define GL_ALPHA_BLEND_EQUATION_ATI 0x883D + +GLAPI void GLAPIENTRY glBlendEquationSeparateATI( GLenum modeRGB, GLenum modeA ); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEATIPROC) (GLenum modeRGB, GLenum modeA); + +#endif /* GL_ATI_blend_equation_separate */ + + +/* GL_OES_EGL_image */ +#ifndef GL_OES_EGL_image +typedef void* GLeglImageOES; +#endif + +#ifndef GL_OES_EGL_image +#define GL_OES_EGL_image 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image); +GLAPI void APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image); +#endif +typedef void (APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image); +typedef void (APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image); +#endif + + +/** + ** NOTE!!!!! If you add new functions to this file, or update + ** glext.h be sure to regenerate the gl_mangle.h file. See comments + ** in that file for details. + **/ + + + +/********************************************************************** + * Begin system-specific stuff + */ +#if defined(PRAGMA_EXPORT_SUPPORTED) +#pragma export off +#endif + +/* + * End system-specific stuff + **********************************************************************/ + + +#ifdef __cplusplus +} +#endif + +#endif /* __gl_h_ */ + +#endif /* !__IPHONEOS__ */ + +#endif /* SDL_opengl_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_opengl_glext.h b/thirdparty/include/SDL2/SDL_opengl_glext.h new file mode 100644 index 000000000..6a402b15a --- /dev/null +++ b/thirdparty/include/SDL2/SDL_opengl_glext.h @@ -0,0 +1,11180 @@ +#ifndef __glext_h_ +#define __glext_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2013-2014 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are 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 Materials. +** +** THE MATERIALS ARE 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 +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ +/* +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** http://www.opengl.org/registry/ +** +** Khronos $Revision: 26745 $ on $Date: 2014-05-21 03:12:26 -0700 (Wed, 21 May 2014) $ +*/ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif +#ifndef NOMINMAX /* don't define min() and max(). */ +#define NOMINMAX +#endif +#include +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI +#define GLAPI extern +#endif + +#define GL_GLEXT_VERSION 20140521 + +/* Generated C header for: + * API: gl + * Profile: compatibility + * Versions considered: .* + * Versions emitted: 1\.[2-9]|[234]\.[0-9] + * Default extensions included: gl + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_RESCALE_NORMAL 0x803A +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif +#endif /* GL_VERSION_1_2 */ + +#ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_CLAMP_TO_BORDER 0x812D +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_MULTISAMPLE_BIT 0x20000000 +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_SUBTRACT 0x84E7 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, void *img); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTexture (GLenum texture); +GLAPI void APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); +GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, void *img); +GLAPI void APIENTRY glClientActiveTexture (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1d (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1f (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1i (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1s (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2d (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2f (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2i (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2s (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3d (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3f (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3i (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3s (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4d (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4i (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4s (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m); +#endif +#endif /* GL_VERSION_1_3 */ + +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FOG_COORDINATE 0x8451 +#define GL_FRAGMENT_DEPTH 0x8452 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_COLOR_SUM 0x8458 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_TEXTURE_FILTER_CONTROL 0x8500 +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_COMPARE_R_TO_TEXTURE 0x884E +#define GL_FUNC_ADD 0x8006 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); +GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); +GLAPI void APIENTRY glFogCoordf (GLfloat coord); +GLAPI void APIENTRY glFogCoordfv (const GLfloat *coord); +GLAPI void APIENTRY glFogCoordd (GLdouble coord); +GLAPI void APIENTRY glFogCoorddv (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointer (GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glSecondaryColor3b (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3d (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3f (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3i (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3iv (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3s (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ub (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3ui (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3us (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointer (GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glWindowPos2d (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2f (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2i (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2iv (const GLint *v); +GLAPI void APIENTRY glWindowPos2s (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2sv (const GLshort *v); +GLAPI void APIENTRY glWindowPos3d (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3f (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3i (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3iv (const GLint *v); +GLAPI void APIENTRY glWindowPos3s (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3sv (const GLshort *v); +GLAPI void APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GLAPI void APIENTRY glBlendEquation (GLenum mode); +#endif +#endif /* GL_VERSION_1_4 */ + +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 +#include +#ifdef __MACOSX__ +typedef long GLsizeiptr; +typedef long GLintptr; +#else +typedef ptrdiff_t GLsizeiptr; +typedef ptrdiff_t GLintptr; +#endif +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 +#define GL_SRC1_ALPHA 0x8589 +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E +#define GL_FOG_COORD_SRC 0x8450 +#define GL_FOG_COORD 0x8451 +#define GL_CURRENT_FOG_COORD 0x8453 +#define GL_FOG_COORD_ARRAY_TYPE 0x8454 +#define GL_FOG_COORD_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORD_ARRAY_POINTER 0x8456 +#define GL_FOG_COORD_ARRAY 0x8457 +#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D +#define GL_SRC0_RGB 0x8580 +#define GL_SRC1_RGB 0x8581 +#define GL_SRC2_RGB 0x8582 +#define GL_SRC0_ALPHA 0x8588 +#define GL_SRC2_ALPHA 0x858A +typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, void *data); +typedef void *(APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, void **params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQuery (GLuint id); +GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQuery (GLenum target); +GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); +GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer); +GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, void *data); +GLAPI void *APIENTRY glMapBuffer (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target); +GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, void **params); +#endif +#endif /* GL_VERSION_1_5 */ + +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 +typedef char GLchar; +#define GL_BLEND_EQUATION_RGB 0x8009 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_MAX_VARYING_FLOATS 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_SHADER_TYPE 0x8B4F +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_1D 0x8B5D +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_SAMPLER_1D_SHADOW 0x8B61 +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_DELETE_STATUS 0x8B80 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 +#define GL_POINT_SPRITE 0x8861 +#define GL_COORD_REPLACE 0x8862 +#define GL_MAX_TEXTURE_COORDS 0x8871 +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void **pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); +GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); +GLAPI void APIENTRY glCompileShader (GLuint shader); +GLAPI GLuint APIENTRY glCreateProgram (void); +GLAPI GLuint APIENTRY glCreateShader (GLenum type); +GLAPI void APIENTRY glDeleteProgram (GLuint program); +GLAPI void APIENTRY glDeleteShader (GLuint shader); +GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer); +GLAPI GLboolean APIENTRY glIsProgram (GLuint program); +GLAPI GLboolean APIENTRY glIsShader (GLuint shader); +GLAPI void APIENTRY glLinkProgram (GLuint program); +GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +GLAPI void APIENTRY glUseProgram (GLuint program); +GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glValidateProgram (GLuint program); +GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +#endif +#endif /* GL_VERSION_2_0 */ + +#ifndef GL_VERSION_2_1 +#define GL_VERSION_2_1 1 +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB_ALPHA 0x8C42 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_COMPRESSED_SRGB 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 +#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F +#define GL_SLUMINANCE_ALPHA 0x8C44 +#define GL_SLUMINANCE8_ALPHA8 0x8C45 +#define GL_SLUMINANCE 0x8C46 +#define GL_SLUMINANCE8 0x8C47 +#define GL_COMPRESSED_SLUMINANCE 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif +#endif /* GL_VERSION_2_1 */ + +#ifndef GL_VERSION_3_0 +#define GL_VERSION_3_0 1 +typedef unsigned short GLhalf; +#define GL_COMPARE_REF_TO_TEXTURE 0x884E +#define GL_CLIP_DISTANCE0 0x3000 +#define GL_CLIP_DISTANCE1 0x3001 +#define GL_CLIP_DISTANCE2 0x3002 +#define GL_CLIP_DISTANCE3 0x3003 +#define GL_CLIP_DISTANCE4 0x3004 +#define GL_CLIP_DISTANCE5 0x3005 +#define GL_CLIP_DISTANCE6 0x3006 +#define GL_CLIP_DISTANCE7 0x3007 +#define GL_MAX_CLIP_DISTANCES 0x0D32 +#define GL_MAJOR_VERSION 0x821B +#define GL_MINOR_VERSION 0x821C +#define GL_NUM_EXTENSIONS 0x821D +#define GL_CONTEXT_FLAGS 0x821E +#define GL_COMPRESSED_RED 0x8225 +#define GL_COMPRESSED_RG 0x8226 +#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001 +#define GL_RGBA32F 0x8814 +#define GL_RGB32F 0x8815 +#define GL_RGBA16F 0x881A +#define GL_RGB16F 0x881B +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_CLAMP_READ_COLOR 0x891C +#define GL_FIXED_ONLY 0x891D +#define GL_MAX_VARYING_COMPONENTS 0x8B4B +#define GL_TEXTURE_1D_ARRAY 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_RGB9_E5 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_TEXTURE_SHARED_SIZE 0x8C3F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_PRIMITIVES_GENERATED 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_RGBA32UI 0x8D70 +#define GL_RGB32UI 0x8D71 +#define GL_RGBA16UI 0x8D76 +#define GL_RGB16UI 0x8D77 +#define GL_RGBA8UI 0x8D7C +#define GL_RGB8UI 0x8D7D +#define GL_RGBA32I 0x8D82 +#define GL_RGB32I 0x8D83 +#define GL_RGBA16I 0x8D88 +#define GL_RGB16I 0x8D89 +#define GL_RGBA8I 0x8D8E +#define GL_RGB8I 0x8D8F +#define GL_RED_INTEGER 0x8D94 +#define GL_GREEN_INTEGER 0x8D95 +#define GL_BLUE_INTEGER 0x8D96 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RGBA_INTEGER 0x8D99 +#define GL_BGR_INTEGER 0x8D9A +#define GL_BGRA_INTEGER 0x8D9B +#define GL_SAMPLER_1D_ARRAY 0x8DC0 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_INT_SAMPLER_1D 0x8DC9 +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_QUERY_WAIT 0x8E13 +#define GL_QUERY_NO_WAIT 0x8E14 +#define GL_QUERY_BY_REGION_WAIT 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 +#define GL_BUFFER_ACCESS_FLAGS 0x911F +#define GL_BUFFER_MAP_LENGTH 0x9120 +#define GL_BUFFER_MAP_OFFSET 0x9121 +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_STENCIL_INDEX1 0x8D46 +#define GL_STENCIL_INDEX4 0x8D47 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_STENCIL_INDEX16 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#define GL_INDEX 0x8222 +#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 +#define GL_FRAMEBUFFER_SRGB 0x8DB9 +#define GL_HALF_FLOAT 0x140B +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#define GL_COMPRESSED_RED_RGTC1 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC +#define GL_COMPRESSED_RG_RGTC2 0x8DBD +#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_R16 0x822A +#define GL_RG8 0x822B +#define GL_RG16 0x822C +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#define GL_CLAMP_VERTEX_COLOR 0x891A +#define GL_CLAMP_FRAGMENT_COLOR 0x891B +#define GL_ALPHA_INTEGER 0x8D97 +typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void *(APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glEnablei (GLenum target, GLuint index); +GLAPI void APIENTRY glDisablei (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index); +GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedback (void); +GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp); +GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRender (void); +GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); +GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); +GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); +GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); +GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GLAPI const GLubyte *APIENTRY glGetStringi (GLenum name, GLuint index); +GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmap (GLenum target); +GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void *APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glBindVertexArray (GLuint array); +GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); +#endif +#endif /* GL_VERSION_3_0 */ + +#ifndef GL_VERSION_3_1 +#define GL_VERSION_3_1 1 +#define GL_SAMPLER_2D_RECT 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 +#define GL_SAMPLER_BUFFER 0x8DC2 +#define GL_INT_SAMPLER_2D_RECT 0x8DCD +#define GL_INT_SAMPLER_BUFFER 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 +#define GL_TEXTURE_BUFFER 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D +#define GL_TEXTURE_RECTANGLE 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_R16_SNORM 0x8F98 +#define GL_RG16_SNORM 0x8F99 +#define GL_RGB16_SNORM 0x8F9A +#define GL_RGBA16_SNORM 0x8F9B +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_PRIMITIVE_RESTART 0x8F9D +#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E +#define GL_COPY_READ_BUFFER 0x8F36 +#define GL_COPY_WRITE_BUFFER 0x8F37 +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_INVALID_INDEX 0xFFFFFFFFu +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); +typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); +typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); +GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); +GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); +GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#endif +#endif /* GL_VERSION_3_1 */ + +#ifndef GL_VERSION_3_2 +#define GL_VERSION_3_2 1 +typedef struct __GLsync *GLsync; +#ifndef GLEXT_64_TYPES_DEFINED +/* This code block is duplicated in glxext.h, so must be protected */ +#define GLEXT_64_TYPES_DEFINED +/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ +/* (as used in the GL_EXT_timer_query extension). */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#include +#elif defined(__sun__) || defined(__digital__) +#include +#if defined(__STDC__) +#if defined(__arch64__) || defined(_LP64) +typedef long int int64_t; +typedef unsigned long int uint64_t; +#else +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#endif /* __arch64__ */ +#endif /* __STDC__ */ +#elif defined( __VMS ) || defined(__sgi) +#include +#elif defined(__SCO__) || defined(__USLC__) +#include +#elif defined(__UNIXOS2__) || defined(__SOL64__) +typedef long int int32_t; +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#elif defined(_WIN32) && defined(__GNUC__) +#include +#elif defined(_WIN32) +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +/* Fallback if nothing above works */ +#include +#endif +#endif +typedef uint64_t GLuint64; +typedef int64_t GLint64; +#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 +#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 +#define GL_LINES_ADJACENCY 0x000A +#define GL_LINE_STRIP_ADJACENCY 0x000B +#define GL_TRIANGLES_ADJACENCY 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D +#define GL_PROGRAM_POINT_SIZE 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 +#define GL_GEOMETRY_SHADER 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT 0x8916 +#define GL_GEOMETRY_INPUT_TYPE 0x8917 +#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 +#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 +#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 +#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 +#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 +#define GL_CONTEXT_PROFILE_MASK 0x9126 +#define GL_DEPTH_CLAMP 0x864F +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION 0x8E4D +#define GL_LAST_VERTEX_CONVENTION 0x8E4E +#define GL_PROVOKING_VERTEX 0x8E4F +#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_OBJECT_TYPE 0x9112 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_STATUS 0x9114 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_UNSIGNALED 0x9118 +#define GL_SIGNALED 0x9119 +#define GL_ALREADY_SIGNALED 0x911A +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_CONDITION_SATISFIED 0x911C +#define GL_WAIT_FAILED 0x911D +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_SAMPLE_POSITION 0x8E50 +#define GL_SAMPLE_MASK 0x8E51 +#define GL_SAMPLE_MASK_VALUE 0x8E52 +#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 +#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 +#define GL_TEXTURE_SAMPLES 0x9106 +#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 +#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 +#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A +#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B +#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D +#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E +#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F +#define GL_MAX_INTEGER_SAMPLES 0x9110 +typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); +typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); +typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); +typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *data); +typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint maskNumber, GLbitfield mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); +GLAPI void APIENTRY glProvokingVertex (GLenum mode); +GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags); +GLAPI GLboolean APIENTRY glIsSync (GLsync sync); +GLAPI void APIENTRY glDeleteSync (GLsync sync); +GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *data); +GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); +GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaski (GLuint maskNumber, GLbitfield mask); +#endif +#endif /* GL_VERSION_3_2 */ + +#ifndef GL_VERSION_3_3 +#define GL_VERSION_3_3 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE +#define GL_SRC1_COLOR 0x88F9 +#define GL_ONE_MINUS_SRC1_COLOR 0x88FA +#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB +#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#define GL_SAMPLER_BINDING 0x8919 +#define GL_RGB10_A2UI 0x906F +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 +#define GL_TIME_ELAPSED 0x88BF +#define GL_TIMESTAMP 0x8E28 +#define GL_INT_2_10_10_10_REV 0x8D9F +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); +typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); +typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); +typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); +GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); +GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler); +GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); +GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); +GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); +GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); +GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); +GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target); +GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params); +GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); +GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color); +#endif +#endif /* GL_VERSION_3_3 */ + +#ifndef GL_VERSION_4_0 +#define GL_VERSION_4_0 1 +#define GL_SAMPLE_SHADING 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F +#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F +#define GL_DRAW_INDIRECT_BUFFER 0x8F3F +#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 +#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F +#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C +#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D +#define GL_MAX_VERTEX_STREAMS 0x8E71 +#define GL_DOUBLE_VEC2 0x8FFC +#define GL_DOUBLE_VEC3 0x8FFD +#define GL_DOUBLE_VEC4 0x8FFE +#define GL_DOUBLE_MAT2 0x8F46 +#define GL_DOUBLE_MAT3 0x8F47 +#define GL_DOUBLE_MAT4 0x8F48 +#define GL_DOUBLE_MAT2x3 0x8F49 +#define GL_DOUBLE_MAT2x4 0x8F4A +#define GL_DOUBLE_MAT3x2 0x8F4B +#define GL_DOUBLE_MAT3x4 0x8F4C +#define GL_DOUBLE_MAT4x2 0x8F4D +#define GL_DOUBLE_MAT4x3 0x8F4E +#define GL_ACTIVE_SUBROUTINES 0x8DE5 +#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 +#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 +#define GL_MAX_SUBROUTINES 0x8DE7 +#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 +#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A +#define GL_COMPATIBLE_SUBROUTINES 0x8E4B +#define GL_PATCHES 0x000E +#define GL_PATCH_VERTICES 0x8E72 +#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 +#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 +#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 +#define GL_TESS_GEN_MODE 0x8E76 +#define GL_TESS_GEN_SPACING 0x8E77 +#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 +#define GL_TESS_GEN_POINT_MODE 0x8E79 +#define GL_ISOLINES 0x8E7A +#define GL_FRACTIONAL_ODD 0x8E7B +#define GL_FRACTIONAL_EVEN 0x8E7C +#define GL_MAX_PATCH_VERTICES 0x8E7D +#define GL_MAX_TESS_GEN_LEVEL 0x8E7E +#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F +#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 +#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 +#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 +#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 +#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 +#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 +#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 +#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 +#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A +#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C +#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D +#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E +#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 +#define GL_TESS_EVALUATION_SHADER 0x8E87 +#define GL_TESS_CONTROL_SHADER 0x8E88 +#define GL_TRANSFORM_FEEDBACK 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 +#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLfloat value); +typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect); +typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params); +typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); +typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values); +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); +typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShading (GLfloat value); +GLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const void *indirect); +GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect); +GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x); +GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params); +GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); +GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); +GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value); +GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values); +GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedback (void); +GLAPI void APIENTRY glResumeTransformFeedback (void); +GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id); +GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream); +GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id); +GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index); +GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params); +#endif +#endif /* GL_VERSION_4_0 */ + +#ifndef GL_VERSION_4_1 +#define GL_VERSION_4_1 1 +#define GL_FIXED 0x140C +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_RGB565 0x8D62 +#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 +#define GL_PROGRAM_BINARY_LENGTH 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE +#define GL_PROGRAM_BINARY_FORMATS 0x87FF +#define GL_VERTEX_SHADER_BIT 0x00000001 +#define GL_FRAGMENT_SHADER_BIT 0x00000002 +#define GL_GEOMETRY_SHADER_BIT 0x00000004 +#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 +#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 +#define GL_ALL_SHADER_BITS 0xFFFFFFFF +#define GL_PROGRAM_SEPARABLE 0x8258 +#define GL_ACTIVE_PROGRAM 0x8259 +#define GL_PROGRAM_PIPELINE_BINDING 0x825A +#define GL_MAX_VIEWPORTS 0x825B +#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C +#define GL_VIEWPORT_BOUNDS_RANGE 0x825D +#define GL_LAYER_PROVOKING_VERTEX 0x825E +#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F +#define GL_UNDEFINED_VERTEX 0x8260 +typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); +typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length); +typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); +typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); +typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar *const*strings); +typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); +typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLdouble n, GLdouble f); +typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReleaseShaderCompiler (void); +GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length); +GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +GLAPI void APIENTRY glDepthRangef (GLfloat n, GLfloat f); +GLAPI void APIENTRY glClearDepthf (GLfloat d); +GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); +GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); +GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar *const*strings); +GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); +GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); +GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); +GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0); +GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1); +GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v); +GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v); +GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLdouble n, GLdouble f); +GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); +#endif +#endif /* GL_VERSION_4_1 */ + +#ifndef GL_VERSION_4_2 +#define GL_VERSION_4_2 1 +#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 +#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 +#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 +#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A +#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B +#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C +#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D +#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E +#define GL_NUM_SAMPLE_COUNTS 0x9380 +#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC +#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 +#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 +#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 +#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 +#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB +#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE +#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF +#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 +#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 +#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 +#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 +#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 +#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC +#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 +#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA +#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 +#define GL_COMMAND_BARRIER_BIT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 +#define GL_ALL_BARRIER_BITS 0xFFFFFFFF +#define GL_MAX_IMAGE_UNITS 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 +#define GL_IMAGE_BINDING_NAME 0x8F3A +#define GL_IMAGE_BINDING_LEVEL 0x8F3B +#define GL_IMAGE_BINDING_LAYERED 0x8F3C +#define GL_IMAGE_BINDING_LAYER 0x8F3D +#define GL_IMAGE_BINDING_ACCESS 0x8F3E +#define GL_IMAGE_1D 0x904C +#define GL_IMAGE_2D 0x904D +#define GL_IMAGE_3D 0x904E +#define GL_IMAGE_2D_RECT 0x904F +#define GL_IMAGE_CUBE 0x9050 +#define GL_IMAGE_BUFFER 0x9051 +#define GL_IMAGE_1D_ARRAY 0x9052 +#define GL_IMAGE_2D_ARRAY 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 +#define GL_INT_IMAGE_1D 0x9057 +#define GL_INT_IMAGE_2D 0x9058 +#define GL_INT_IMAGE_3D 0x9059 +#define GL_INT_IMAGE_2D_RECT 0x905A +#define GL_INT_IMAGE_CUBE 0x905B +#define GL_INT_IMAGE_BUFFER 0x905C +#define GL_INT_IMAGE_1D_ARRAY 0x905D +#define GL_INT_IMAGE_2D_ARRAY 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C +#define GL_MAX_IMAGE_SAMPLES 0x906D +#define GL_IMAGE_BINDING_FORMAT 0x906E +#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 +#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA +#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB +#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC +#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD +#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE +#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF +#define GL_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F +#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); +typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers); +GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei instancecount); +GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); +#endif +#endif /* GL_VERSION_4_2 */ + +#ifndef GL_VERSION_4_3 +#define GL_VERSION_4_3 1 +typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +#define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9 +#define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define GL_COMPRESSED_R11_EAC 0x9270 +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define GL_COMPRESSED_RG11_EAC 0x9272 +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A +#define GL_MAX_ELEMENT_INDEX 0x8D6B +#define GL_COMPUTE_SHADER 0x91B9 +#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB +#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC +#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD +#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 +#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 +#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 +#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 +#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 +#define GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS 0x90EB +#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE +#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF +#define GL_COMPUTE_WORK_GROUP_SIZE 0x8267 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED +#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE +#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF +#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 +#define GL_DEBUG_SOURCE_API 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION 0x824A +#define GL_DEBUG_SOURCE_OTHER 0x824B +#define GL_DEBUG_TYPE_ERROR 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E +#define GL_DEBUG_TYPE_PORTABILITY 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 +#define GL_DEBUG_TYPE_OTHER 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES 0x9145 +#define GL_DEBUG_SEVERITY_HIGH 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 +#define GL_DEBUG_SEVERITY_LOW 0x9148 +#define GL_DEBUG_TYPE_MARKER 0x8268 +#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 +#define GL_DEBUG_TYPE_POP_GROUP 0x826A +#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C +#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D +#define GL_BUFFER 0x82E0 +#define GL_SHADER 0x82E1 +#define GL_PROGRAM 0x82E2 +#define GL_QUERY 0x82E3 +#define GL_PROGRAM_PIPELINE 0x82E4 +#define GL_SAMPLER 0x82E6 +#define GL_MAX_LABEL_LENGTH 0x82E8 +#define GL_DEBUG_OUTPUT 0x92E0 +#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 +#define GL_MAX_UNIFORM_LOCATIONS 0x826E +#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 +#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 +#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312 +#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313 +#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314 +#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315 +#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316 +#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317 +#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318 +#define GL_INTERNALFORMAT_SUPPORTED 0x826F +#define GL_INTERNALFORMAT_PREFERRED 0x8270 +#define GL_INTERNALFORMAT_RED_SIZE 0x8271 +#define GL_INTERNALFORMAT_GREEN_SIZE 0x8272 +#define GL_INTERNALFORMAT_BLUE_SIZE 0x8273 +#define GL_INTERNALFORMAT_ALPHA_SIZE 0x8274 +#define GL_INTERNALFORMAT_DEPTH_SIZE 0x8275 +#define GL_INTERNALFORMAT_STENCIL_SIZE 0x8276 +#define GL_INTERNALFORMAT_SHARED_SIZE 0x8277 +#define GL_INTERNALFORMAT_RED_TYPE 0x8278 +#define GL_INTERNALFORMAT_GREEN_TYPE 0x8279 +#define GL_INTERNALFORMAT_BLUE_TYPE 0x827A +#define GL_INTERNALFORMAT_ALPHA_TYPE 0x827B +#define GL_INTERNALFORMAT_DEPTH_TYPE 0x827C +#define GL_INTERNALFORMAT_STENCIL_TYPE 0x827D +#define GL_MAX_WIDTH 0x827E +#define GL_MAX_HEIGHT 0x827F +#define GL_MAX_DEPTH 0x8280 +#define GL_MAX_LAYERS 0x8281 +#define GL_MAX_COMBINED_DIMENSIONS 0x8282 +#define GL_COLOR_COMPONENTS 0x8283 +#define GL_DEPTH_COMPONENTS 0x8284 +#define GL_STENCIL_COMPONENTS 0x8285 +#define GL_COLOR_RENDERABLE 0x8286 +#define GL_DEPTH_RENDERABLE 0x8287 +#define GL_STENCIL_RENDERABLE 0x8288 +#define GL_FRAMEBUFFER_RENDERABLE 0x8289 +#define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A +#define GL_FRAMEBUFFER_BLEND 0x828B +#define GL_READ_PIXELS 0x828C +#define GL_READ_PIXELS_FORMAT 0x828D +#define GL_READ_PIXELS_TYPE 0x828E +#define GL_TEXTURE_IMAGE_FORMAT 0x828F +#define GL_TEXTURE_IMAGE_TYPE 0x8290 +#define GL_GET_TEXTURE_IMAGE_FORMAT 0x8291 +#define GL_GET_TEXTURE_IMAGE_TYPE 0x8292 +#define GL_MIPMAP 0x8293 +#define GL_MANUAL_GENERATE_MIPMAP 0x8294 +#define GL_AUTO_GENERATE_MIPMAP 0x8295 +#define GL_COLOR_ENCODING 0x8296 +#define GL_SRGB_READ 0x8297 +#define GL_SRGB_WRITE 0x8298 +#define GL_FILTER 0x829A +#define GL_VERTEX_TEXTURE 0x829B +#define GL_TESS_CONTROL_TEXTURE 0x829C +#define GL_TESS_EVALUATION_TEXTURE 0x829D +#define GL_GEOMETRY_TEXTURE 0x829E +#define GL_FRAGMENT_TEXTURE 0x829F +#define GL_COMPUTE_TEXTURE 0x82A0 +#define GL_TEXTURE_SHADOW 0x82A1 +#define GL_TEXTURE_GATHER 0x82A2 +#define GL_TEXTURE_GATHER_SHADOW 0x82A3 +#define GL_SHADER_IMAGE_LOAD 0x82A4 +#define GL_SHADER_IMAGE_STORE 0x82A5 +#define GL_SHADER_IMAGE_ATOMIC 0x82A6 +#define GL_IMAGE_TEXEL_SIZE 0x82A7 +#define GL_IMAGE_COMPATIBILITY_CLASS 0x82A8 +#define GL_IMAGE_PIXEL_FORMAT 0x82A9 +#define GL_IMAGE_PIXEL_TYPE 0x82AA +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF +#define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1 +#define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2 +#define GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3 +#define GL_CLEAR_BUFFER 0x82B4 +#define GL_TEXTURE_VIEW 0x82B5 +#define GL_VIEW_COMPATIBILITY_CLASS 0x82B6 +#define GL_FULL_SUPPORT 0x82B7 +#define GL_CAVEAT_SUPPORT 0x82B8 +#define GL_IMAGE_CLASS_4_X_32 0x82B9 +#define GL_IMAGE_CLASS_2_X_32 0x82BA +#define GL_IMAGE_CLASS_1_X_32 0x82BB +#define GL_IMAGE_CLASS_4_X_16 0x82BC +#define GL_IMAGE_CLASS_2_X_16 0x82BD +#define GL_IMAGE_CLASS_1_X_16 0x82BE +#define GL_IMAGE_CLASS_4_X_8 0x82BF +#define GL_IMAGE_CLASS_2_X_8 0x82C0 +#define GL_IMAGE_CLASS_1_X_8 0x82C1 +#define GL_IMAGE_CLASS_11_11_10 0x82C2 +#define GL_IMAGE_CLASS_10_10_10_2 0x82C3 +#define GL_VIEW_CLASS_128_BITS 0x82C4 +#define GL_VIEW_CLASS_96_BITS 0x82C5 +#define GL_VIEW_CLASS_64_BITS 0x82C6 +#define GL_VIEW_CLASS_48_BITS 0x82C7 +#define GL_VIEW_CLASS_32_BITS 0x82C8 +#define GL_VIEW_CLASS_24_BITS 0x82C9 +#define GL_VIEW_CLASS_16_BITS 0x82CA +#define GL_VIEW_CLASS_8_BITS 0x82CB +#define GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC +#define GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD +#define GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE +#define GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF +#define GL_VIEW_CLASS_RGTC1_RED 0x82D0 +#define GL_VIEW_CLASS_RGTC2_RG 0x82D1 +#define GL_VIEW_CLASS_BPTC_UNORM 0x82D2 +#define GL_VIEW_CLASS_BPTC_FLOAT 0x82D3 +#define GL_UNIFORM 0x92E1 +#define GL_UNIFORM_BLOCK 0x92E2 +#define GL_PROGRAM_INPUT 0x92E3 +#define GL_PROGRAM_OUTPUT 0x92E4 +#define GL_BUFFER_VARIABLE 0x92E5 +#define GL_SHADER_STORAGE_BLOCK 0x92E6 +#define GL_VERTEX_SUBROUTINE 0x92E8 +#define GL_TESS_CONTROL_SUBROUTINE 0x92E9 +#define GL_TESS_EVALUATION_SUBROUTINE 0x92EA +#define GL_GEOMETRY_SUBROUTINE 0x92EB +#define GL_FRAGMENT_SUBROUTINE 0x92EC +#define GL_COMPUTE_SUBROUTINE 0x92ED +#define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE +#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF +#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0 +#define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1 +#define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2 +#define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3 +#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 +#define GL_ACTIVE_RESOURCES 0x92F5 +#define GL_MAX_NAME_LENGTH 0x92F6 +#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 +#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8 +#define GL_NAME_LENGTH 0x92F9 +#define GL_TYPE 0x92FA +#define GL_ARRAY_SIZE 0x92FB +#define GL_OFFSET 0x92FC +#define GL_BLOCK_INDEX 0x92FD +#define GL_ARRAY_STRIDE 0x92FE +#define GL_MATRIX_STRIDE 0x92FF +#define GL_IS_ROW_MAJOR 0x9300 +#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 +#define GL_BUFFER_BINDING 0x9302 +#define GL_BUFFER_DATA_SIZE 0x9303 +#define GL_NUM_ACTIVE_VARIABLES 0x9304 +#define GL_ACTIVE_VARIABLES 0x9305 +#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 +#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 +#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 +#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 +#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A +#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B +#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C +#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D +#define GL_LOCATION 0x930E +#define GL_LOCATION_INDEX 0x930F +#define GL_IS_PER_PATCH 0x92E7 +#define GL_SHADER_STORAGE_BUFFER 0x90D2 +#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 +#define GL_SHADER_STORAGE_BUFFER_START 0x90D4 +#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 +#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 +#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 +#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 +#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 +#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA +#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB +#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC +#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD +#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE +#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF +#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 +#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 +#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA +#define GL_TEXTURE_BUFFER_OFFSET 0x919D +#define GL_TEXTURE_BUFFER_SIZE 0x919E +#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F +#define GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB +#define GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC +#define GL_TEXTURE_VIEW_MIN_LAYER 0x82DD +#define GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE +#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF +#define GL_VERTEX_ATTRIB_BINDING 0x82D4 +#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 +#define GL_VERTEX_BINDING_DIVISOR 0x82D6 +#define GL_VERTEX_BINDING_OFFSET 0x82D7 +#define GL_VERTEX_BINDING_STRIDE 0x82D8 +#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 +#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA +#define GL_VERTEX_BINDING_BUFFER 0x8F4F +#define GL_DISPLAY_LIST 0x82E7 +typedef void (APIENTRYP PFNGLCLEARBUFFERDATAPROC) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARBUFFERSUBDATAPROC) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); +typedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +typedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +typedef void (APIENTRYP PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTUREVIEWPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +typedef void (APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); +typedef void (APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void); +typedef void (APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClearBufferData (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearBufferSubData (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +GLAPI void APIENTRY glDispatchComputeIndirect (GLintptr indirect); +GLAPI void APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +GLAPI void APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetInternalformati64v (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +GLAPI void APIENTRY glInvalidateTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glInvalidateTexImage (GLuint texture, GLint level); +GLAPI void APIENTRY glInvalidateBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glInvalidateBufferData (GLuint buffer); +GLAPI void APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments); +GLAPI void APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glMultiDrawArraysIndirect (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +GLAPI GLuint APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI void APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +GLAPI GLint APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI GLint APIENTRY glGetProgramResourceLocationIndex (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI void APIENTRY glShaderStorageBlockBinding (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +GLAPI void APIENTRY glTexBufferRange (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexStorage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureView (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +GLAPI void APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribLFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +GLAPI void APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message); +GLAPI void APIENTRY glPopDebugGroup (void); +GLAPI void APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +GLAPI void APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif +#endif /* GL_VERSION_4_3 */ + +#ifndef GL_VERSION_4_4 +#define GL_VERSION_4_4 1 +#define GL_MAX_VERTEX_ATTRIB_STRIDE 0x82E5 +#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221 +#define GL_TEXTURE_BUFFER_BINDING 0x8C2A +#define GL_MAP_PERSISTENT_BIT 0x0040 +#define GL_MAP_COHERENT_BIT 0x0080 +#define GL_DYNAMIC_STORAGE_BIT 0x0100 +#define GL_CLIENT_STORAGE_BIT 0x0200 +#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT 0x00004000 +#define GL_BUFFER_IMMUTABLE_STORAGE 0x821F +#define GL_BUFFER_STORAGE_FLAGS 0x8220 +#define GL_CLEAR_TEXTURE 0x9365 +#define GL_LOCATION_COMPONENT 0x934A +#define GL_TRANSFORM_FEEDBACK_BUFFER_INDEX 0x934B +#define GL_TRANSFORM_FEEDBACK_BUFFER_STRIDE 0x934C +#define GL_QUERY_BUFFER 0x9192 +#define GL_QUERY_BUFFER_BARRIER_BIT 0x00008000 +#define GL_QUERY_BUFFER_BINDING 0x9193 +#define GL_QUERY_RESULT_NO_WAIT 0x9194 +#define GL_MIRROR_CLAMP_TO_EDGE 0x8743 +typedef void (APIENTRYP PFNGLBUFFERSTORAGEPROC) (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); +typedef void (APIENTRYP PFNGLCLEARTEXIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARTEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLBINDBUFFERSBASEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers); +typedef void (APIENTRYP PFNGLBINDBUFFERSRANGEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes); +typedef void (APIENTRYP PFNGLBINDTEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures); +typedef void (APIENTRYP PFNGLBINDSAMPLERSPROC) (GLuint first, GLsizei count, const GLuint *samplers); +typedef void (APIENTRYP PFNGLBINDIMAGETEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures); +typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERSPROC) (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferStorage (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); +GLAPI void APIENTRY glClearTexImage (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glBindBuffersBase (GLenum target, GLuint first, GLsizei count, const GLuint *buffers); +GLAPI void APIENTRY glBindBuffersRange (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes); +GLAPI void APIENTRY glBindTextures (GLuint first, GLsizei count, const GLuint *textures); +GLAPI void APIENTRY glBindSamplers (GLuint first, GLsizei count, const GLuint *samplers); +GLAPI void APIENTRY glBindImageTextures (GLuint first, GLsizei count, const GLuint *textures); +GLAPI void APIENTRY glBindVertexBuffers (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +#endif +#endif /* GL_VERSION_4_4 */ + +#ifndef GL_ARB_ES2_compatibility +#define GL_ARB_ES2_compatibility 1 +#endif /* GL_ARB_ES2_compatibility */ + +#ifndef GL_ARB_ES3_compatibility +#define GL_ARB_ES3_compatibility 1 +#endif /* GL_ARB_ES3_compatibility */ + +#ifndef GL_ARB_arrays_of_arrays +#define GL_ARB_arrays_of_arrays 1 +#endif /* GL_ARB_arrays_of_arrays */ + +#ifndef GL_ARB_base_instance +#define GL_ARB_base_instance 1 +#endif /* GL_ARB_base_instance */ + +#ifndef GL_ARB_bindless_texture +#define GL_ARB_bindless_texture 1 +typedef uint64_t GLuint64EXT; +#define GL_UNSIGNED_INT64_ARB 0x140F +typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLEARBPROC) (GLuint texture); +typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLEARBPROC) (GLuint texture, GLuint sampler); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTARBPROC) (GLuint64 handle); +typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLEARBPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle, GLenum access); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTARBPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64ARBPROC) (GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64ARBPROC) (GLuint program, GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); +typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64ARBPROC) (GLuint index, GLuint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VARBPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VARBPROC) (GLuint index, GLenum pname, GLuint64EXT *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint64 APIENTRY glGetTextureHandleARB (GLuint texture); +GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleARB (GLuint texture, GLuint sampler); +GLAPI void APIENTRY glMakeTextureHandleResidentARB (GLuint64 handle); +GLAPI void APIENTRY glMakeTextureHandleNonResidentARB (GLuint64 handle); +GLAPI GLuint64 APIENTRY glGetImageHandleARB (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +GLAPI void APIENTRY glMakeImageHandleResidentARB (GLuint64 handle, GLenum access); +GLAPI void APIENTRY glMakeImageHandleNonResidentARB (GLuint64 handle); +GLAPI void APIENTRY glUniformHandleui64ARB (GLint location, GLuint64 value); +GLAPI void APIENTRY glUniformHandleui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniformHandleui64ARB (GLuint program, GLint location, GLuint64 value); +GLAPI void APIENTRY glProgramUniformHandleui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +GLAPI GLboolean APIENTRY glIsTextureHandleResidentARB (GLuint64 handle); +GLAPI GLboolean APIENTRY glIsImageHandleResidentARB (GLuint64 handle); +GLAPI void APIENTRY glVertexAttribL1ui64ARB (GLuint index, GLuint64EXT x); +GLAPI void APIENTRY glVertexAttribL1ui64vARB (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glGetVertexAttribLui64vARB (GLuint index, GLenum pname, GLuint64EXT *params); +#endif +#endif /* GL_ARB_bindless_texture */ + +#ifndef GL_ARB_blend_func_extended +#define GL_ARB_blend_func_extended 1 +#endif /* GL_ARB_blend_func_extended */ + +#ifndef GL_ARB_buffer_storage +#define GL_ARB_buffer_storage 1 +#endif /* GL_ARB_buffer_storage */ + +#ifndef GL_ARB_cl_event +#define GL_ARB_cl_event 1 +struct _cl_context; +struct _cl_event; +#define GL_SYNC_CL_EVENT_ARB 0x8240 +#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 +typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (struct _cl_context *context, struct _cl_event *event, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context *context, struct _cl_event *event, GLbitfield flags); +#endif +#endif /* GL_ARB_cl_event */ + +#ifndef GL_ARB_clear_buffer_object +#define GL_ARB_clear_buffer_object 1 +#endif /* GL_ARB_clear_buffer_object */ + +#ifndef GL_ARB_clear_texture +#define GL_ARB_clear_texture 1 +#endif /* GL_ARB_clear_texture */ + +#ifndef GL_ARB_color_buffer_float +#define GL_ARB_color_buffer_float 1 +#define GL_RGBA_FLOAT_MODE_ARB 0x8820 +#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A +#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B +#define GL_CLAMP_READ_COLOR_ARB 0x891C +#define GL_FIXED_ONLY_ARB 0x891D +typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClampColorARB (GLenum target, GLenum clamp); +#endif +#endif /* GL_ARB_color_buffer_float */ + +#ifndef GL_ARB_compatibility +#define GL_ARB_compatibility 1 +#endif /* GL_ARB_compatibility */ + +#ifndef GL_ARB_compressed_texture_pixel_storage +#define GL_ARB_compressed_texture_pixel_storage 1 +#endif /* GL_ARB_compressed_texture_pixel_storage */ + +#ifndef GL_ARB_compute_shader +#define GL_ARB_compute_shader 1 +#define GL_COMPUTE_SHADER_BIT 0x00000020 +#endif /* GL_ARB_compute_shader */ + +#ifndef GL_ARB_compute_variable_group_size +#define GL_ARB_compute_variable_group_size 1 +#define GL_MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS_ARB 0x9344 +#define GL_MAX_COMPUTE_FIXED_GROUP_INVOCATIONS_ARB 0x90EB +#define GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB 0x9345 +#define GL_MAX_COMPUTE_FIXED_GROUP_SIZE_ARB 0x91BF +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEGROUPSIZEARBPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDispatchComputeGroupSizeARB (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z); +#endif +#endif /* GL_ARB_compute_variable_group_size */ + +#ifndef GL_ARB_conservative_depth +#define GL_ARB_conservative_depth 1 +#endif /* GL_ARB_conservative_depth */ + +#ifndef GL_ARB_copy_buffer +#define GL_ARB_copy_buffer 1 +#define GL_COPY_READ_BUFFER_BINDING 0x8F36 +#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 +#endif /* GL_ARB_copy_buffer */ + +#ifndef GL_ARB_copy_image +#define GL_ARB_copy_image 1 +#endif /* GL_ARB_copy_image */ + +#ifndef GL_ARB_debug_output +#define GL_ARB_debug_output 1 +typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 +#define GL_DEBUG_SOURCE_API_ARB 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A +#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B +#define GL_DEBUG_TYPE_ERROR_ARB 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E +#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 +#define GL_DEBUG_TYPE_OTHER_ARB 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 +#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#endif +#endif /* GL_ARB_debug_output */ + +#ifndef GL_ARB_depth_buffer_float +#define GL_ARB_depth_buffer_float 1 +#endif /* GL_ARB_depth_buffer_float */ + +#ifndef GL_ARB_depth_clamp +#define GL_ARB_depth_clamp 1 +#endif /* GL_ARB_depth_clamp */ + +#ifndef GL_ARB_depth_texture +#define GL_ARB_depth_texture 1 +#define GL_DEPTH_COMPONENT16_ARB 0x81A5 +#define GL_DEPTH_COMPONENT24_ARB 0x81A6 +#define GL_DEPTH_COMPONENT32_ARB 0x81A7 +#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A +#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B +#endif /* GL_ARB_depth_texture */ + +#ifndef GL_ARB_draw_buffers +#define GL_ARB_draw_buffers 1 +#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 +#define GL_DRAW_BUFFER0_ARB 0x8825 +#define GL_DRAW_BUFFER1_ARB 0x8826 +#define GL_DRAW_BUFFER2_ARB 0x8827 +#define GL_DRAW_BUFFER3_ARB 0x8828 +#define GL_DRAW_BUFFER4_ARB 0x8829 +#define GL_DRAW_BUFFER5_ARB 0x882A +#define GL_DRAW_BUFFER6_ARB 0x882B +#define GL_DRAW_BUFFER7_ARB 0x882C +#define GL_DRAW_BUFFER8_ARB 0x882D +#define GL_DRAW_BUFFER9_ARB 0x882E +#define GL_DRAW_BUFFER10_ARB 0x882F +#define GL_DRAW_BUFFER11_ARB 0x8830 +#define GL_DRAW_BUFFER12_ARB 0x8831 +#define GL_DRAW_BUFFER13_ARB 0x8832 +#define GL_DRAW_BUFFER14_ARB 0x8833 +#define GL_DRAW_BUFFER15_ARB 0x8834 +typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersARB (GLsizei n, const GLenum *bufs); +#endif +#endif /* GL_ARB_draw_buffers */ + +#ifndef GL_ARB_draw_buffers_blend +#define GL_ARB_draw_buffers_blend 1 +typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif +#endif /* GL_ARB_draw_buffers_blend */ + +#ifndef GL_ARB_draw_elements_base_vertex +#define GL_ARB_draw_elements_base_vertex 1 +#endif /* GL_ARB_draw_elements_base_vertex */ + +#ifndef GL_ARB_draw_indirect +#define GL_ARB_draw_indirect 1 +#endif /* GL_ARB_draw_indirect */ + +#ifndef GL_ARB_draw_instanced +#define GL_ARB_draw_instanced 1 +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#endif +#endif /* GL_ARB_draw_instanced */ + +#ifndef GL_ARB_enhanced_layouts +#define GL_ARB_enhanced_layouts 1 +#endif /* GL_ARB_enhanced_layouts */ + +#ifndef GL_ARB_explicit_attrib_location +#define GL_ARB_explicit_attrib_location 1 +#endif /* GL_ARB_explicit_attrib_location */ + +#ifndef GL_ARB_explicit_uniform_location +#define GL_ARB_explicit_uniform_location 1 +#endif /* GL_ARB_explicit_uniform_location */ + +#ifndef GL_ARB_fragment_coord_conventions +#define GL_ARB_fragment_coord_conventions 1 +#endif /* GL_ARB_fragment_coord_conventions */ + +#ifndef GL_ARB_fragment_layer_viewport +#define GL_ARB_fragment_layer_viewport 1 +#endif /* GL_ARB_fragment_layer_viewport */ + +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 +#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_PROGRAM_LENGTH_ARB 0x8627 +#define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_BINDING_ARB 0x8677 +#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 +#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 +#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 +#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 +#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 +#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 +#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 +#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 +#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 +#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 +#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA +#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB +#define GL_PROGRAM_ATTRIBS_ARB 0x88AC +#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD +#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE +#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF +#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 +#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 +#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B +#define GL_CURRENT_MATRIX_ARB 0x8641 +#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#define GL_MATRIX0_ARB 0x88C0 +#define GL_MATRIX1_ARB 0x88C1 +#define GL_MATRIX2_ARB 0x88C2 +#define GL_MATRIX3_ARB 0x88C3 +#define GL_MATRIX4_ARB 0x88C4 +#define GL_MATRIX5_ARB 0x88C5 +#define GL_MATRIX6_ARB 0x88C6 +#define GL_MATRIX7_ARB 0x88C7 +#define GL_MATRIX8_ARB 0x88C8 +#define GL_MATRIX9_ARB 0x88C9 +#define GL_MATRIX10_ARB 0x88CA +#define GL_MATRIX11_ARB 0x88CB +#define GL_MATRIX12_ARB 0x88CC +#define GL_MATRIX13_ARB 0x88CD +#define GL_MATRIX14_ARB 0x88CE +#define GL_MATRIX15_ARB 0x88CF +#define GL_MATRIX16_ARB 0x88D0 +#define GL_MATRIX17_ARB 0x88D1 +#define GL_MATRIX18_ARB 0x88D2 +#define GL_MATRIX19_ARB 0x88D3 +#define GL_MATRIX20_ARB 0x88D4 +#define GL_MATRIX21_ARB 0x88D5 +#define GL_MATRIX22_ARB 0x88D6 +#define GL_MATRIX23_ARB 0x88D7 +#define GL_MATRIX24_ARB 0x88D8 +#define GL_MATRIX25_ARB 0x88D9 +#define GL_MATRIX26_ARB 0x88DA +#define GL_MATRIX27_ARB 0x88DB +#define GL_MATRIX28_ARB 0x88DC +#define GL_MATRIX29_ARB 0x88DD +#define GL_MATRIX30_ARB 0x88DE +#define GL_MATRIX31_ARB 0x88DF +typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const void *string); +typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, void *string); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramStringARB (GLenum target, GLenum format, GLsizei len, const void *string); +GLAPI void APIENTRY glBindProgramARB (GLenum target, GLuint program); +GLAPI void APIENTRY glDeleteProgramsARB (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glGenProgramsARB (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringARB (GLenum target, GLenum pname, void *string); +GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program); +#endif +#endif /* GL_ARB_fragment_program */ + +#ifndef GL_ARB_fragment_program_shadow +#define GL_ARB_fragment_program_shadow 1 +#endif /* GL_ARB_fragment_program_shadow */ + +#ifndef GL_ARB_fragment_shader +#define GL_ARB_fragment_shader 1 +#define GL_FRAGMENT_SHADER_ARB 0x8B30 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B +#endif /* GL_ARB_fragment_shader */ + +#ifndef GL_ARB_framebuffer_no_attachments +#define GL_ARB_framebuffer_no_attachments 1 +#endif /* GL_ARB_framebuffer_no_attachments */ + +#ifndef GL_ARB_framebuffer_object +#define GL_ARB_framebuffer_object 1 +#endif /* GL_ARB_framebuffer_object */ + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_ARB_framebuffer_sRGB 1 +#endif /* GL_ARB_framebuffer_sRGB */ + +#ifndef GL_KHR_context_flush_control +#define GL_CONTEXT_RELEASE_BEHAVIOR 0x82FB +#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82FC +#endif /* GL_KHR_context_flush_control */ + +#ifndef GL_ARB_geometry_shader4 +#define GL_ARB_geometry_shader4 1 +#define GL_LINES_ADJACENCY_ARB 0x000A +#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B +#define GL_TRIANGLES_ADJACENCY_ARB 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D +#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 +#define GL_GEOMETRY_SHADER_ARB 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif +#endif /* GL_ARB_geometry_shader4 */ + +#ifndef GL_ARB_get_program_binary +#define GL_ARB_get_program_binary 1 +#endif /* GL_ARB_get_program_binary */ + +#ifndef GL_ARB_gpu_shader5 +#define GL_ARB_gpu_shader5 1 +#endif /* GL_ARB_gpu_shader5 */ + +#ifndef GL_ARB_gpu_shader_fp64 +#define GL_ARB_gpu_shader_fp64 1 +#endif /* GL_ARB_gpu_shader_fp64 */ + +#ifndef GL_ARB_half_float_pixel +#define GL_ARB_half_float_pixel 1 +typedef unsigned short GLhalfARB; +#define GL_HALF_FLOAT_ARB 0x140B +#endif /* GL_ARB_half_float_pixel */ + +#ifndef GL_ARB_half_float_vertex +#define GL_ARB_half_float_vertex 1 +#endif /* GL_ARB_half_float_vertex */ + +#ifndef GL_ARB_imaging +#define GL_ARB_imaging 1 +#define GL_BLEND_COLOR 0x8005 +#define GL_BLEND_EQUATION 0x8009 +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX 0x802E +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, void *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, void *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +GLAPI void APIENTRY glColorTableParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTable (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTable (GLenum target, GLenum format, GLenum type, void *table); +GLAPI void APIENTRY glGetColorTableParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glCopyColorSubTable (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glConvolutionFilter1D (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionParameterf (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteri (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilter (GLenum target, GLenum format, GLenum type, void *image); +GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilter (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +GLAPI void APIENTRY glSeparableFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); +GLAPI void APIENTRY glGetHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetHistogramParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogram (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmax (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogram (GLenum target); +GLAPI void APIENTRY glResetMinmax (GLenum target); +#endif +#endif /* GL_ARB_imaging */ + +#ifndef GL_ARB_indirect_parameters +#define GL_ARB_indirect_parameters 1 +#define GL_PARAMETER_BUFFER_ARB 0x80EE +#define GL_PARAMETER_BUFFER_BINDING_ARB 0x80EF +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC) (GLenum mode, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC) (GLenum mode, GLenum type, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectCountARB (GLenum mode, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectCountARB (GLenum mode, GLenum type, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#endif +#endif /* GL_ARB_indirect_parameters */ + +#ifndef GL_ARB_instanced_arrays +#define GL_ARB_instanced_arrays 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor); +#endif +#endif /* GL_ARB_instanced_arrays */ + +#ifndef GL_ARB_internalformat_query +#define GL_ARB_internalformat_query 1 +#endif /* GL_ARB_internalformat_query */ + +#ifndef GL_ARB_internalformat_query2 +#define GL_ARB_internalformat_query2 1 +#define GL_SRGB_DECODE_ARB 0x8299 +#endif /* GL_ARB_internalformat_query2 */ + +#ifndef GL_ARB_invalidate_subdata +#define GL_ARB_invalidate_subdata 1 +#endif /* GL_ARB_invalidate_subdata */ + +#ifndef GL_ARB_map_buffer_alignment +#define GL_ARB_map_buffer_alignment 1 +#endif /* GL_ARB_map_buffer_alignment */ + +#ifndef GL_ARB_map_buffer_range +#define GL_ARB_map_buffer_range 1 +#endif /* GL_ARB_map_buffer_range */ + +#ifndef GL_ARB_matrix_palette +#define GL_ARB_matrix_palette 1 +#define GL_MATRIX_PALETTE_ARB 0x8840 +#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 +#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 +#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 +#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 +#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 +#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 +typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); +typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint index); +GLAPI void APIENTRY glMatrixIndexubvARB (GLint size, const GLubyte *indices); +GLAPI void APIENTRY glMatrixIndexusvARB (GLint size, const GLushort *indices); +GLAPI void APIENTRY glMatrixIndexuivARB (GLint size, const GLuint *indices); +GLAPI void APIENTRY glMatrixIndexPointerARB (GLint size, GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_ARB_matrix_palette */ + +#ifndef GL_ARB_multi_bind +#define GL_ARB_multi_bind 1 +#endif /* GL_ARB_multi_bind */ + +#ifndef GL_ARB_multi_draw_indirect +#define GL_ARB_multi_draw_indirect 1 +#endif /* GL_ARB_multi_draw_indirect */ + +#ifndef GL_ARB_multisample +#define GL_ARB_multisample 1 +#define GL_MULTISAMPLE_ARB 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F +#define GL_SAMPLE_COVERAGE_ARB 0x80A0 +#define GL_SAMPLE_BUFFERS_ARB 0x80A8 +#define GL_SAMPLES_ARB 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLfloat value, GLboolean invert); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleCoverageARB (GLfloat value, GLboolean invert); +#endif +#endif /* GL_ARB_multisample */ + +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glClientActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum target, const GLshort *v); +#endif +#endif /* GL_ARB_multitexture */ + +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query 1 +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#define GL_SAMPLES_PASSED_ARB 0x8914 +typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueriesARB (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueriesARB (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQueryARB (GLuint id); +GLAPI void APIENTRY glBeginQueryARB (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQueryARB (GLenum target); +GLAPI void APIENTRY glGetQueryivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectivARB (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *params); +#endif +#endif /* GL_ARB_occlusion_query */ + +#ifndef GL_ARB_occlusion_query2 +#define GL_ARB_occlusion_query2 1 +#endif /* GL_ARB_occlusion_query2 */ + +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 +#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF +#endif /* GL_ARB_pixel_buffer_object */ + +#ifndef GL_ARB_point_parameters +#define GL_ARB_point_parameters 1 +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 +typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfARB (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params); +#endif +#endif /* GL_ARB_point_parameters */ + +#ifndef GL_ARB_point_sprite +#define GL_ARB_point_sprite 1 +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 +#endif /* GL_ARB_point_sprite */ + +#ifndef GL_ARB_program_interface_query +#define GL_ARB_program_interface_query 1 +#endif /* GL_ARB_program_interface_query */ + +#ifndef GL_ARB_provoking_vertex +#define GL_ARB_provoking_vertex 1 +#endif /* GL_ARB_provoking_vertex */ + +#ifndef GL_ARB_query_buffer_object +#define GL_ARB_query_buffer_object 1 +#endif /* GL_ARB_query_buffer_object */ + +#ifndef GL_ARB_robust_buffer_access_behavior +#define GL_ARB_robust_buffer_access_behavior 1 +#endif /* GL_ARB_robust_buffer_access_behavior */ + +#ifndef GL_ARB_robustness +#define GL_ARB_robustness 1 +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 +#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define GL_NO_RESET_NOTIFICATION_ARB 0x8261 +typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); +typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *img); +typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, void *img); +typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +typedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +typedef void (APIENTRYP PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +typedef void (APIENTRYP PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort *values); +typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte *pattern); +typedef void (APIENTRYP PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); +typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); +typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); +typedef void (APIENTRYP PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +typedef void (APIENTRYP PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); +GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *img); +GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, void *img); +GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +GLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +GLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +GLAPI void APIENTRY glGetnMapivARB (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +GLAPI void APIENTRY glGetnPixelMapfvARB (GLenum map, GLsizei bufSize, GLfloat *values); +GLAPI void APIENTRY glGetnPixelMapuivARB (GLenum map, GLsizei bufSize, GLuint *values); +GLAPI void APIENTRY glGetnPixelMapusvARB (GLenum map, GLsizei bufSize, GLushort *values); +GLAPI void APIENTRY glGetnPolygonStippleARB (GLsizei bufSize, GLubyte *pattern); +GLAPI void APIENTRY glGetnColorTableARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); +GLAPI void APIENTRY glGetnConvolutionFilterARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); +GLAPI void APIENTRY glGetnSeparableFilterARB (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); +GLAPI void APIENTRY glGetnHistogramARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +#endif +#endif /* GL_ARB_robustness */ + +#ifndef GL_ARB_robustness_isolation +#define GL_ARB_robustness_isolation 1 +#endif /* GL_ARB_robustness_isolation */ + +#ifndef GL_ARB_sample_shading +#define GL_ARB_sample_shading 1 +#define GL_SAMPLE_SHADING_ARB 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLfloat value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value); +#endif +#endif /* GL_ARB_sample_shading */ + +#ifndef GL_ARB_sampler_objects +#define GL_ARB_sampler_objects 1 +#endif /* GL_ARB_sampler_objects */ + +#ifndef GL_ARB_seamless_cube_map +#define GL_ARB_seamless_cube_map 1 +#endif /* GL_ARB_seamless_cube_map */ + +#ifndef GL_ARB_seamless_cubemap_per_texture +#define GL_ARB_seamless_cubemap_per_texture 1 +#endif /* GL_ARB_seamless_cubemap_per_texture */ + +#ifndef GL_ARB_separate_shader_objects +#define GL_ARB_separate_shader_objects 1 +#endif /* GL_ARB_separate_shader_objects */ + +#ifndef GL_ARB_shader_atomic_counters +#define GL_ARB_shader_atomic_counters 1 +#endif /* GL_ARB_shader_atomic_counters */ + +#ifndef GL_ARB_shader_bit_encoding +#define GL_ARB_shader_bit_encoding 1 +#endif /* GL_ARB_shader_bit_encoding */ + +#ifndef GL_ARB_shader_draw_parameters +#define GL_ARB_shader_draw_parameters 1 +#endif /* GL_ARB_shader_draw_parameters */ + +#ifndef GL_ARB_shader_group_vote +#define GL_ARB_shader_group_vote 1 +#endif /* GL_ARB_shader_group_vote */ + +#ifndef GL_ARB_shader_image_load_store +#define GL_ARB_shader_image_load_store 1 +#endif /* GL_ARB_shader_image_load_store */ + +#ifndef GL_ARB_shader_image_size +#define GL_ARB_shader_image_size 1 +#endif /* GL_ARB_shader_image_size */ + +#ifndef GL_ARB_shader_objects +#define GL_ARB_shader_objects 1 +#ifdef __APPLE__ +typedef void *GLhandleARB; +#else +typedef unsigned int GLhandleARB; +#endif +typedef char GLcharARB; +#define GL_PROGRAM_OBJECT_ARB 0x8B40 +#define GL_SHADER_OBJECT_ARB 0x8B48 +#define GL_OBJECT_TYPE_ARB 0x8B4E +#define GL_OBJECT_SUBTYPE_ARB 0x8B4F +#define GL_FLOAT_VEC2_ARB 0x8B50 +#define GL_FLOAT_VEC3_ARB 0x8B51 +#define GL_FLOAT_VEC4_ARB 0x8B52 +#define GL_INT_VEC2_ARB 0x8B53 +#define GL_INT_VEC3_ARB 0x8B54 +#define GL_INT_VEC4_ARB 0x8B55 +#define GL_BOOL_ARB 0x8B56 +#define GL_BOOL_VEC2_ARB 0x8B57 +#define GL_BOOL_VEC3_ARB 0x8B58 +#define GL_BOOL_VEC4_ARB 0x8B59 +#define GL_FLOAT_MAT2_ARB 0x8B5A +#define GL_FLOAT_MAT3_ARB 0x8B5B +#define GL_FLOAT_MAT4_ARB 0x8B5C +#define GL_SAMPLER_1D_ARB 0x8B5D +#define GL_SAMPLER_2D_ARB 0x8B5E +#define GL_SAMPLER_3D_ARB 0x8B5F +#define GL_SAMPLER_CUBE_ARB 0x8B60 +#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 +#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 +#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 +#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 +#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 +#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 +#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 +#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 +typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); +typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); +typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length); +typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); +typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); +typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB obj); +GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum pname); +GLAPI void APIENTRY glDetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj); +GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum shaderType); +GLAPI void APIENTRY glShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length); +GLAPI void APIENTRY glCompileShaderARB (GLhandleARB shaderObj); +GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); +GLAPI void APIENTRY glAttachObjectARB (GLhandleARB containerObj, GLhandleARB obj); +GLAPI void APIENTRY glLinkProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB programObj); +GLAPI void APIENTRY glValidateProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUniform1fARB (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2fARB (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1iARB (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2iARB (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3iARB (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformivARB (GLhandleARB programObj, GLint location, GLint *params); +GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#endif +#endif /* GL_ARB_shader_objects */ + +#ifndef GL_ARB_shader_precision +#define GL_ARB_shader_precision 1 +#endif /* GL_ARB_shader_precision */ + +#ifndef GL_ARB_shader_stencil_export +#define GL_ARB_shader_stencil_export 1 +#endif /* GL_ARB_shader_stencil_export */ + +#ifndef GL_ARB_shader_storage_buffer_object +#define GL_ARB_shader_storage_buffer_object 1 +#endif /* GL_ARB_shader_storage_buffer_object */ + +#ifndef GL_ARB_shader_subroutine +#define GL_ARB_shader_subroutine 1 +#endif /* GL_ARB_shader_subroutine */ + +#ifndef GL_ARB_shader_texture_lod +#define GL_ARB_shader_texture_lod 1 +#endif /* GL_ARB_shader_texture_lod */ + +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 1 +#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C +#endif /* GL_ARB_shading_language_100 */ + +#ifndef GL_ARB_shading_language_420pack +#define GL_ARB_shading_language_420pack 1 +#endif /* GL_ARB_shading_language_420pack */ + +#ifndef GL_ARB_shading_language_include +#define GL_ARB_shading_language_include 1 +#define GL_SHADER_INCLUDE_ARB 0x8DAE +#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 +#define GL_NAMED_STRING_TYPE_ARB 0x8DEA +typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length); +typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length); +GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#endif +#endif /* GL_ARB_shading_language_include */ + +#ifndef GL_ARB_shading_language_packing +#define GL_ARB_shading_language_packing 1 +#endif /* GL_ARB_shading_language_packing */ + +#ifndef GL_ARB_shadow +#define GL_ARB_shadow 1 +#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C +#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D +#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E +#endif /* GL_ARB_shadow */ + +#ifndef GL_ARB_shadow_ambient +#define GL_ARB_shadow_ambient 1 +#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF +#endif /* GL_ARB_shadow_ambient */ + +#ifndef GL_ARB_sparse_texture +#define GL_ARB_sparse_texture 1 +#define GL_TEXTURE_SPARSE_ARB 0x91A6 +#define GL_VIRTUAL_PAGE_SIZE_INDEX_ARB 0x91A7 +#define GL_MIN_SPARSE_LEVEL_ARB 0x919B +#define GL_NUM_VIRTUAL_PAGE_SIZES_ARB 0x91A8 +#define GL_VIRTUAL_PAGE_SIZE_X_ARB 0x9195 +#define GL_VIRTUAL_PAGE_SIZE_Y_ARB 0x9196 +#define GL_VIRTUAL_PAGE_SIZE_Z_ARB 0x9197 +#define GL_MAX_SPARSE_TEXTURE_SIZE_ARB 0x9198 +#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_ARB 0x9199 +#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_ARB 0x919A +#define GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB 0x91A9 +typedef void (APIENTRYP PFNGLTEXPAGECOMMITMENTARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexPageCommitmentARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident); +#endif +#endif /* GL_ARB_sparse_texture */ + +#ifndef GL_ARB_stencil_texturing +#define GL_ARB_stencil_texturing 1 +#endif /* GL_ARB_stencil_texturing */ + +#ifndef GL_ARB_sync +#define GL_ARB_sync 1 +#endif /* GL_ARB_sync */ + +#ifndef GL_ARB_tessellation_shader +#define GL_ARB_tessellation_shader 1 +#endif /* GL_ARB_tessellation_shader */ + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 +#define GL_CLAMP_TO_BORDER_ARB 0x812D +#endif /* GL_ARB_texture_border_clamp */ + +#ifndef GL_ARB_texture_buffer_object +#define GL_ARB_texture_buffer_object 1 +#define GL_TEXTURE_BUFFER_ARB 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E +typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer); +#endif +#endif /* GL_ARB_texture_buffer_object */ + +#ifndef GL_ARB_texture_buffer_object_rgb32 +#define GL_ARB_texture_buffer_object_rgb32 1 +#endif /* GL_ARB_texture_buffer_object_rgb32 */ + +#ifndef GL_ARB_texture_buffer_range +#define GL_ARB_texture_buffer_range 1 +#endif /* GL_ARB_texture_buffer_range */ + +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, void *img); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, void *img); +#endif +#endif /* GL_ARB_texture_compression */ + +#ifndef GL_ARB_texture_compression_bptc +#define GL_ARB_texture_compression_bptc 1 +#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F +#endif /* GL_ARB_texture_compression_bptc */ + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_ARB_texture_compression_rgtc 1 +#endif /* GL_ARB_texture_compression_rgtc */ + +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C +#endif /* GL_ARB_texture_cube_map */ + +#ifndef GL_ARB_texture_cube_map_array +#define GL_ARB_texture_cube_map_array 1 +#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F +#endif /* GL_ARB_texture_cube_map_array */ + +#ifndef GL_ARB_texture_env_add +#define GL_ARB_texture_env_add 1 +#endif /* GL_ARB_texture_env_add */ + +#ifndef GL_ARB_texture_env_combine +#define GL_ARB_texture_env_combine 1 +#define GL_COMBINE_ARB 0x8570 +#define GL_COMBINE_RGB_ARB 0x8571 +#define GL_COMBINE_ALPHA_ARB 0x8572 +#define GL_SOURCE0_RGB_ARB 0x8580 +#define GL_SOURCE1_RGB_ARB 0x8581 +#define GL_SOURCE2_RGB_ARB 0x8582 +#define GL_SOURCE0_ALPHA_ARB 0x8588 +#define GL_SOURCE1_ALPHA_ARB 0x8589 +#define GL_SOURCE2_ALPHA_ARB 0x858A +#define GL_OPERAND0_RGB_ARB 0x8590 +#define GL_OPERAND1_RGB_ARB 0x8591 +#define GL_OPERAND2_RGB_ARB 0x8592 +#define GL_OPERAND0_ALPHA_ARB 0x8598 +#define GL_OPERAND1_ALPHA_ARB 0x8599 +#define GL_OPERAND2_ALPHA_ARB 0x859A +#define GL_RGB_SCALE_ARB 0x8573 +#define GL_ADD_SIGNED_ARB 0x8574 +#define GL_INTERPOLATE_ARB 0x8575 +#define GL_SUBTRACT_ARB 0x84E7 +#define GL_CONSTANT_ARB 0x8576 +#define GL_PRIMARY_COLOR_ARB 0x8577 +#define GL_PREVIOUS_ARB 0x8578 +#endif /* GL_ARB_texture_env_combine */ + +#ifndef GL_ARB_texture_env_crossbar +#define GL_ARB_texture_env_crossbar 1 +#endif /* GL_ARB_texture_env_crossbar */ + +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 +#define GL_DOT3_RGB_ARB 0x86AE +#define GL_DOT3_RGBA_ARB 0x86AF +#endif /* GL_ARB_texture_env_dot3 */ + +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float 1 +#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 +#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 +#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 +#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_ALPHA32F_ARB 0x8816 +#define GL_INTENSITY32F_ARB 0x8817 +#define GL_LUMINANCE32F_ARB 0x8818 +#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 +#define GL_RGBA16F_ARB 0x881A +#define GL_RGB16F_ARB 0x881B +#define GL_ALPHA16F_ARB 0x881C +#define GL_INTENSITY16F_ARB 0x881D +#define GL_LUMINANCE16F_ARB 0x881E +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F +#endif /* GL_ARB_texture_float */ + +#ifndef GL_ARB_texture_gather +#define GL_ARB_texture_gather 1 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F +#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB 0x8F9F +#endif /* GL_ARB_texture_gather */ + +#ifndef GL_ARB_texture_mirror_clamp_to_edge +#define GL_ARB_texture_mirror_clamp_to_edge 1 +#endif /* GL_ARB_texture_mirror_clamp_to_edge */ + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 +#define GL_MIRRORED_REPEAT_ARB 0x8370 +#endif /* GL_ARB_texture_mirrored_repeat */ + +#ifndef GL_ARB_texture_multisample +#define GL_ARB_texture_multisample 1 +#endif /* GL_ARB_texture_multisample */ + +#ifndef GL_ARB_texture_non_power_of_two +#define GL_ARB_texture_non_power_of_two 1 +#endif /* GL_ARB_texture_non_power_of_two */ + +#ifndef GL_ARB_texture_query_levels +#define GL_ARB_texture_query_levels 1 +#endif /* GL_ARB_texture_query_levels */ + +#ifndef GL_ARB_texture_query_lod +#define GL_ARB_texture_query_lod 1 +#endif /* GL_ARB_texture_query_lod */ + +#ifndef GL_ARB_texture_rectangle +#define GL_ARB_texture_rectangle 1 +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#endif /* GL_ARB_texture_rectangle */ + +#ifndef GL_ARB_texture_rg +#define GL_ARB_texture_rg 1 +#endif /* GL_ARB_texture_rg */ + +#ifndef GL_ARB_texture_rgb10_a2ui +#define GL_ARB_texture_rgb10_a2ui 1 +#endif /* GL_ARB_texture_rgb10_a2ui */ + +#ifndef GL_ARB_texture_stencil8 +#define GL_ARB_texture_stencil8 1 +#endif /* GL_ARB_texture_stencil8 */ + +#ifndef GL_ARB_texture_storage +#define GL_ARB_texture_storage 1 +#endif /* GL_ARB_texture_storage */ + +#ifndef GL_ARB_texture_storage_multisample +#define GL_ARB_texture_storage_multisample 1 +#endif /* GL_ARB_texture_storage_multisample */ + +#ifndef GL_ARB_texture_swizzle +#define GL_ARB_texture_swizzle 1 +#endif /* GL_ARB_texture_swizzle */ + +#ifndef GL_ARB_texture_view +#define GL_ARB_texture_view 1 +#endif /* GL_ARB_texture_view */ + +#ifndef GL_ARB_timer_query +#define GL_ARB_timer_query 1 +#endif /* GL_ARB_timer_query */ + +#ifndef GL_ARB_transform_feedback2 +#define GL_ARB_transform_feedback2 1 +#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 +#endif /* GL_ARB_transform_feedback2 */ + +#ifndef GL_ARB_transform_feedback3 +#define GL_ARB_transform_feedback3 1 +#endif /* GL_ARB_transform_feedback3 */ + +#ifndef GL_ARB_transform_feedback_instanced +#define GL_ARB_transform_feedback_instanced 1 +#endif /* GL_ARB_transform_feedback_instanced */ + +#ifndef GL_ARB_transpose_matrix +#define GL_ARB_transpose_matrix 1 +#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *m); +#endif +#endif /* GL_ARB_transpose_matrix */ + +#ifndef GL_ARB_uniform_buffer_object +#define GL_ARB_uniform_buffer_object 1 +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 +#endif /* GL_ARB_uniform_buffer_object */ + +#ifndef GL_ARB_vertex_array_bgra +#define GL_ARB_vertex_array_bgra 1 +#endif /* GL_ARB_vertex_array_bgra */ + +#ifndef GL_ARB_vertex_array_object +#define GL_ARB_vertex_array_object 1 +#endif /* GL_ARB_vertex_array_object */ + +#ifndef GL_ARB_vertex_attrib_64bit +#define GL_ARB_vertex_attrib_64bit 1 +#endif /* GL_ARB_vertex_attrib_64bit */ + +#ifndef GL_ARB_vertex_attrib_binding +#define GL_ARB_vertex_attrib_binding 1 +#endif /* GL_ARB_vertex_attrib_binding */ + +#ifndef GL_ARB_vertex_blend +#define GL_ARB_vertex_blend 1 +#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 +#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 +#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 +#define GL_VERTEX_BLEND_ARB 0x86A7 +#define GL_CURRENT_WEIGHT_ARB 0x86A8 +#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 +#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA +#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB +#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC +#define GL_WEIGHT_ARRAY_ARB 0x86AD +#define GL_MODELVIEW0_ARB 0x1700 +#define GL_MODELVIEW1_ARB 0x850A +#define GL_MODELVIEW2_ARB 0x8722 +#define GL_MODELVIEW3_ARB 0x8723 +#define GL_MODELVIEW4_ARB 0x8724 +#define GL_MODELVIEW5_ARB 0x8725 +#define GL_MODELVIEW6_ARB 0x8726 +#define GL_MODELVIEW7_ARB 0x8727 +#define GL_MODELVIEW8_ARB 0x8728 +#define GL_MODELVIEW9_ARB 0x8729 +#define GL_MODELVIEW10_ARB 0x872A +#define GL_MODELVIEW11_ARB 0x872B +#define GL_MODELVIEW12_ARB 0x872C +#define GL_MODELVIEW13_ARB 0x872D +#define GL_MODELVIEW14_ARB 0x872E +#define GL_MODELVIEW15_ARB 0x872F +#define GL_MODELVIEW16_ARB 0x8730 +#define GL_MODELVIEW17_ARB 0x8731 +#define GL_MODELVIEW18_ARB 0x8732 +#define GL_MODELVIEW19_ARB 0x8733 +#define GL_MODELVIEW20_ARB 0x8734 +#define GL_MODELVIEW21_ARB 0x8735 +#define GL_MODELVIEW22_ARB 0x8736 +#define GL_MODELVIEW23_ARB 0x8737 +#define GL_MODELVIEW24_ARB 0x8738 +#define GL_MODELVIEW25_ARB 0x8739 +#define GL_MODELVIEW26_ARB 0x873A +#define GL_MODELVIEW27_ARB 0x873B +#define GL_MODELVIEW28_ARB 0x873C +#define GL_MODELVIEW29_ARB 0x873D +#define GL_MODELVIEW30_ARB 0x873E +#define GL_MODELVIEW31_ARB 0x873F +typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); +typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); +typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); +typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); +typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); +typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); +typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWeightbvARB (GLint size, const GLbyte *weights); +GLAPI void APIENTRY glWeightsvARB (GLint size, const GLshort *weights); +GLAPI void APIENTRY glWeightivARB (GLint size, const GLint *weights); +GLAPI void APIENTRY glWeightfvARB (GLint size, const GLfloat *weights); +GLAPI void APIENTRY glWeightdvARB (GLint size, const GLdouble *weights); +GLAPI void APIENTRY glWeightubvARB (GLint size, const GLubyte *weights); +GLAPI void APIENTRY glWeightusvARB (GLint size, const GLushort *weights); +GLAPI void APIENTRY glWeightuivARB (GLint size, const GLuint *weights); +GLAPI void APIENTRY glWeightPointerARB (GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glVertexBlendARB (GLint count); +#endif +#endif /* GL_ARB_vertex_blend */ + +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 +#ifdef __MACOSX__ /* The OS X headers haven't caught up with Khronos yet */ +typedef long GLsizeiptrARB; +typedef long GLintptrARB; +#else +typedef ptrdiff_t GLsizeiptrARB; +typedef ptrdiff_t GLintptrARB; +#endif +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F +#define GL_READ_ONLY_ARB 0x88B8 +#define GL_WRITE_ONLY_ARB 0x88B9 +#define GL_READ_WRITE_ARB 0x88BA +#define GL_BUFFER_ACCESS_ARB 0x88BB +#define GL_BUFFER_MAPPED_ARB 0x88BC +#define GL_BUFFER_MAP_POINTER_ARB 0x88BD +#define GL_STREAM_DRAW_ARB 0x88E0 +#define GL_STREAM_READ_ARB 0x88E1 +#define GL_STREAM_COPY_ARB 0x88E2 +#define GL_STATIC_DRAW_ARB 0x88E4 +#define GL_STATIC_READ_ARB 0x88E5 +#define GL_STATIC_COPY_ARB 0x88E6 +#define GL_DYNAMIC_DRAW_ARB 0x88E8 +#define GL_DYNAMIC_READ_ARB 0x88E9 +#define GL_DYNAMIC_COPY_ARB 0x88EA +typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); +typedef void *(APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, void **params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindBufferARB (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffersARB (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffersARB (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBufferARB (GLuint buffer); +GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); +GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); +GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); +GLAPI void *APIENTRY glMapBufferARB (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum target); +GLAPI void APIENTRY glGetBufferParameterivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointervARB (GLenum target, GLenum pname, void **params); +#endif +#endif /* GL_ARB_vertex_buffer_object */ + +#ifndef GL_ARB_vertex_program +#define GL_ARB_vertex_program 1 +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, void **pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttrib1dARB (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fARB (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sARB (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dARB (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fARB (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sARB (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sARB (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4sARB (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointerARB (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivARB (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint index, GLenum pname, void **pointer); +#endif +#endif /* GL_ARB_vertex_program */ + +#ifndef GL_ARB_vertex_shader +#define GL_ARB_vertex_shader 1 +#define GL_VERTEX_SHADER_ARB 0x8B31 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A +#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D +#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 +#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name); +#endif +#endif /* GL_ARB_vertex_shader */ + +#ifndef GL_ARB_vertex_type_10f_11f_11f_rev +#define GL_ARB_vertex_type_10f_11f_11f_rev 1 +#endif /* GL_ARB_vertex_type_10f_11f_11f_rev */ + +#ifndef GL_ARB_vertex_type_2_10_10_10_rev +#define GL_ARB_vertex_type_2_10_10_10_rev 1 +#endif /* GL_ARB_vertex_type_2_10_10_10_rev */ + +#ifndef GL_ARB_viewport_array +#define GL_ARB_viewport_array 1 +#endif /* GL_ARB_viewport_array */ + +#ifndef GL_ARB_window_pos +#define GL_ARB_window_pos 1 +typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dARB (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fARB (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iARB (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos2sARB (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svARB (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dARB (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fARB (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iARB (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos3sARB (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svARB (const GLshort *v); +#endif +#endif /* GL_ARB_window_pos */ + +#ifndef GL_KHR_debug +#define GL_KHR_debug 1 +#endif /* GL_KHR_debug */ + +#ifndef GL_KHR_texture_compression_astc_hdr +#define GL_KHR_texture_compression_astc_hdr 1 +#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 +#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 +#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 +#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 +#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 +#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 +#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 +#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 +#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 +#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 +#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA +#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB +#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC +#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +#endif /* GL_KHR_texture_compression_astc_hdr */ + +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_KHR_texture_compression_astc_ldr 1 +#endif /* GL_KHR_texture_compression_astc_ldr */ + +#ifndef GL_OES_byte_coordinates +#define GL_OES_byte_coordinates 1 +typedef void (APIENTRYP PFNGLMULTITEXCOORD1BOESPROC) (GLenum texture, GLbyte s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2BOESPROC) (GLenum texture, GLbyte s, GLbyte t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD1BOESPROC) (GLbyte s); +typedef void (APIENTRYP PFNGLTEXCOORD1BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD2BOESPROC) (GLbyte s, GLbyte t); +typedef void (APIENTRYP PFNGLTEXCOORD2BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD3BOESPROC) (GLbyte s, GLbyte t, GLbyte r); +typedef void (APIENTRYP PFNGLTEXCOORD3BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD4BOESPROC) (GLbyte s, GLbyte t, GLbyte r, GLbyte q); +typedef void (APIENTRYP PFNGLTEXCOORD4BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX2BOESPROC) (GLbyte x); +typedef void (APIENTRYP PFNGLVERTEX2BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX3BOESPROC) (GLbyte x, GLbyte y); +typedef void (APIENTRYP PFNGLVERTEX3BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX4BOESPROC) (GLbyte x, GLbyte y, GLbyte z); +typedef void (APIENTRYP PFNGLVERTEX4BVOESPROC) (const GLbyte *coords); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiTexCoord1bOES (GLenum texture, GLbyte s); +GLAPI void APIENTRY glMultiTexCoord1bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord2bOES (GLenum texture, GLbyte s, GLbyte t); +GLAPI void APIENTRY glMultiTexCoord2bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord3bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r); +GLAPI void APIENTRY glMultiTexCoord3bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord4bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); +GLAPI void APIENTRY glMultiTexCoord4bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glTexCoord1bOES (GLbyte s); +GLAPI void APIENTRY glTexCoord1bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord2bOES (GLbyte s, GLbyte t); +GLAPI void APIENTRY glTexCoord2bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord3bOES (GLbyte s, GLbyte t, GLbyte r); +GLAPI void APIENTRY glTexCoord3bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord4bOES (GLbyte s, GLbyte t, GLbyte r, GLbyte q); +GLAPI void APIENTRY glTexCoord4bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex2bOES (GLbyte x); +GLAPI void APIENTRY glVertex2bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex3bOES (GLbyte x, GLbyte y); +GLAPI void APIENTRY glVertex3bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex4bOES (GLbyte x, GLbyte y, GLbyte z); +GLAPI void APIENTRY glVertex4bvOES (const GLbyte *coords); +#endif +#endif /* GL_OES_byte_coordinates */ + +#ifndef GL_OES_compressed_paletted_texture +#define GL_OES_compressed_paletted_texture 1 +#define GL_PALETTE4_RGB8_OES 0x8B90 +#define GL_PALETTE4_RGBA8_OES 0x8B91 +#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 +#define GL_PALETTE4_RGBA4_OES 0x8B93 +#define GL_PALETTE4_RGB5_A1_OES 0x8B94 +#define GL_PALETTE8_RGB8_OES 0x8B95 +#define GL_PALETTE8_RGBA8_OES 0x8B96 +#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 +#define GL_PALETTE8_RGBA4_OES 0x8B98 +#define GL_PALETTE8_RGB5_A1_OES 0x8B99 +#endif /* GL_OES_compressed_paletted_texture */ + +#ifndef GL_OES_fixed_point +#define GL_OES_fixed_point 1 +typedef GLint GLfixed; +#define GL_FIXED_OES 0x140C +typedef void (APIENTRYP PFNGLALPHAFUNCXOESPROC) (GLenum func, GLfixed ref); +typedef void (APIENTRYP PFNGLCLEARCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCLEARDEPTHXOESPROC) (GLfixed depth); +typedef void (APIENTRYP PFNGLCLIPPLANEXOESPROC) (GLenum plane, const GLfixed *equation); +typedef void (APIENTRYP PFNGLCOLOR4XOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLDEPTHRANGEXOESPROC) (GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLFOGXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLFOGXVOESPROC) (GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLFRUSTUMXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLGETCLIPPLANEXOESPROC) (GLenum plane, GLfixed *equation); +typedef void (APIENTRYP PFNGLGETFIXEDVOESPROC) (GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXENVXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLLIGHTMODELXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLLIGHTMODELXVOESPROC) (GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLLIGHTXVOESPROC) (GLenum light, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLLINEWIDTHXOESPROC) (GLfixed width); +typedef void (APIENTRYP PFNGLLOADMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLMATERIALXVOESPROC) (GLenum face, GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLMULTMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +typedef void (APIENTRYP PFNGLNORMAL3XOESPROC) (GLfixed nx, GLfixed ny, GLfixed nz); +typedef void (APIENTRYP PFNGLORTHOXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLPOINTPARAMETERXVOESPROC) (GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLPOINTSIZEXOESPROC) (GLfixed size); +typedef void (APIENTRYP PFNGLPOLYGONOFFSETXOESPROC) (GLfixed factor, GLfixed units); +typedef void (APIENTRYP PFNGLROTATEXOESPROC) (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEOESPROC) (GLfixed value, GLboolean invert); +typedef void (APIENTRYP PFNGLSCALEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLTEXENVXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXENVXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLTRANSLATEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLACCUMXOESPROC) (GLenum op, GLfixed value); +typedef void (APIENTRYP PFNGLBITMAPXOESPROC) (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); +typedef void (APIENTRYP PFNGLBLENDCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCLEARACCUMXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCOLOR3XOESPROC) (GLfixed red, GLfixed green, GLfixed blue); +typedef void (APIENTRYP PFNGLCOLOR3XVOESPROC) (const GLfixed *components); +typedef void (APIENTRYP PFNGLCOLOR4XVOESPROC) (const GLfixed *components); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLEVALCOORD1XOESPROC) (GLfixed u); +typedef void (APIENTRYP PFNGLEVALCOORD1XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLEVALCOORD2XOESPROC) (GLfixed u, GLfixed v); +typedef void (APIENTRYP PFNGLEVALCOORD2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLFEEDBACKBUFFERXOESPROC) (GLsizei n, GLenum type, const GLfixed *buffer); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETMAPXVOESPROC) (GLenum target, GLenum query, GLfixed *v); +typedef void (APIENTRYP PFNGLGETMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLGETPIXELMAPXVPROC) (GLenum map, GLint size, GLfixed *values); +typedef void (APIENTRYP PFNGLGETTEXGENXVOESPROC) (GLenum coord, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERXVOESPROC) (GLenum target, GLint level, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLINDEXXOESPROC) (GLfixed component); +typedef void (APIENTRYP PFNGLINDEXXVOESPROC) (const GLfixed *component); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMAP1XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); +typedef void (APIENTRYP PFNGLMAP2XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); +typedef void (APIENTRYP PFNGLMAPGRID1XOESPROC) (GLint n, GLfixed u1, GLfixed u2); +typedef void (APIENTRYP PFNGLMAPGRID2XOESPROC) (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1XOESPROC) (GLenum texture, GLfixed s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2XOESPROC) (GLenum texture, GLfixed s, GLfixed t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLNORMAL3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLPASSTHROUGHXOESPROC) (GLfixed token); +typedef void (APIENTRYP PFNGLPIXELMAPXPROC) (GLenum map, GLint size, const GLfixed *values); +typedef void (APIENTRYP PFNGLPIXELSTOREXPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLPIXELTRANSFERXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLPIXELZOOMXOESPROC) (GLfixed xfactor, GLfixed yfactor); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESXOESPROC) (GLsizei n, const GLuint *textures, const GLfixed *priorities); +typedef void (APIENTRYP PFNGLRASTERPOS2XOESPROC) (GLfixed x, GLfixed y); +typedef void (APIENTRYP PFNGLRASTERPOS2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRASTERPOS3XOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLRASTERPOS3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRASTERPOS4XOESPROC) (GLfixed x, GLfixed y, GLfixed z, GLfixed w); +typedef void (APIENTRYP PFNGLRASTERPOS4XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRECTXOESPROC) (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); +typedef void (APIENTRYP PFNGLRECTXVOESPROC) (const GLfixed *v1, const GLfixed *v2); +typedef void (APIENTRYP PFNGLTEXCOORD1XOESPROC) (GLfixed s); +typedef void (APIENTRYP PFNGLTEXCOORD1XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD2XOESPROC) (GLfixed s, GLfixed t); +typedef void (APIENTRYP PFNGLTEXCOORD2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD3XOESPROC) (GLfixed s, GLfixed t, GLfixed r); +typedef void (APIENTRYP PFNGLTEXCOORD3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD4XOESPROC) (GLfixed s, GLfixed t, GLfixed r, GLfixed q); +typedef void (APIENTRYP PFNGLTEXCOORD4XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXGENXOESPROC) (GLenum coord, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXGENXVOESPROC) (GLenum coord, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLVERTEX2XOESPROC) (GLfixed x); +typedef void (APIENTRYP PFNGLVERTEX2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLVERTEX3XOESPROC) (GLfixed x, GLfixed y); +typedef void (APIENTRYP PFNGLVERTEX3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLVERTEX4XOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLVERTEX4XVOESPROC) (const GLfixed *coords); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAlphaFuncxOES (GLenum func, GLfixed ref); +GLAPI void APIENTRY glClearColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glClearDepthxOES (GLfixed depth); +GLAPI void APIENTRY glClipPlanexOES (GLenum plane, const GLfixed *equation); +GLAPI void APIENTRY glColor4xOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glDepthRangexOES (GLfixed n, GLfixed f); +GLAPI void APIENTRY glFogxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glFogxvOES (GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glFrustumxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +GLAPI void APIENTRY glGetClipPlanexOES (GLenum plane, GLfixed *equation); +GLAPI void APIENTRY glGetFixedvOES (GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexEnvxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glLightModelxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glLightModelxvOES (GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glLightxOES (GLenum light, GLenum pname, GLfixed param); +GLAPI void APIENTRY glLightxvOES (GLenum light, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glLineWidthxOES (GLfixed width); +GLAPI void APIENTRY glLoadMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMaterialxOES (GLenum face, GLenum pname, GLfixed param); +GLAPI void APIENTRY glMaterialxvOES (GLenum face, GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glMultMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMultiTexCoord4xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +GLAPI void APIENTRY glNormal3xOES (GLfixed nx, GLfixed ny, GLfixed nz); +GLAPI void APIENTRY glOrthoxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +GLAPI void APIENTRY glPointParameterxvOES (GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glPointSizexOES (GLfixed size); +GLAPI void APIENTRY glPolygonOffsetxOES (GLfixed factor, GLfixed units); +GLAPI void APIENTRY glRotatexOES (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glSampleCoverageOES (GLfixed value, GLboolean invert); +GLAPI void APIENTRY glScalexOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glTexEnvxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexEnvxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glTexParameterxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glTranslatexOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glAccumxOES (GLenum op, GLfixed value); +GLAPI void APIENTRY glBitmapxOES (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); +GLAPI void APIENTRY glBlendColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glClearAccumxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glColor3xOES (GLfixed red, GLfixed green, GLfixed blue); +GLAPI void APIENTRY glColor3xvOES (const GLfixed *components); +GLAPI void APIENTRY glColor4xvOES (const GLfixed *components); +GLAPI void APIENTRY glConvolutionParameterxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glConvolutionParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glEvalCoord1xOES (GLfixed u); +GLAPI void APIENTRY glEvalCoord1xvOES (const GLfixed *coords); +GLAPI void APIENTRY glEvalCoord2xOES (GLfixed u, GLfixed v); +GLAPI void APIENTRY glEvalCoord2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glFeedbackBufferxOES (GLsizei n, GLenum type, const GLfixed *buffer); +GLAPI void APIENTRY glGetConvolutionParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetHistogramParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetLightxOES (GLenum light, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetMapxvOES (GLenum target, GLenum query, GLfixed *v); +GLAPI void APIENTRY glGetMaterialxOES (GLenum face, GLenum pname, GLfixed param); +GLAPI void APIENTRY glGetPixelMapxv (GLenum map, GLint size, GLfixed *values); +GLAPI void APIENTRY glGetTexGenxvOES (GLenum coord, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexLevelParameterxvOES (GLenum target, GLint level, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glIndexxOES (GLfixed component); +GLAPI void APIENTRY glIndexxvOES (const GLfixed *component); +GLAPI void APIENTRY glLoadTransposeMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMap1xOES (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); +GLAPI void APIENTRY glMap2xOES (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); +GLAPI void APIENTRY glMapGrid1xOES (GLint n, GLfixed u1, GLfixed u2); +GLAPI void APIENTRY glMapGrid2xOES (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); +GLAPI void APIENTRY glMultTransposeMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMultiTexCoord1xOES (GLenum texture, GLfixed s); +GLAPI void APIENTRY glMultiTexCoord1xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord2xOES (GLenum texture, GLfixed s, GLfixed t); +GLAPI void APIENTRY glMultiTexCoord2xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord3xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r); +GLAPI void APIENTRY glMultiTexCoord3xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord4xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glNormal3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glPassThroughxOES (GLfixed token); +GLAPI void APIENTRY glPixelMapx (GLenum map, GLint size, const GLfixed *values); +GLAPI void APIENTRY glPixelStorex (GLenum pname, GLfixed param); +GLAPI void APIENTRY glPixelTransferxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glPixelZoomxOES (GLfixed xfactor, GLfixed yfactor); +GLAPI void APIENTRY glPrioritizeTexturesxOES (GLsizei n, const GLuint *textures, const GLfixed *priorities); +GLAPI void APIENTRY glRasterPos2xOES (GLfixed x, GLfixed y); +GLAPI void APIENTRY glRasterPos2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRasterPos3xOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glRasterPos3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRasterPos4xOES (GLfixed x, GLfixed y, GLfixed z, GLfixed w); +GLAPI void APIENTRY glRasterPos4xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRectxOES (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); +GLAPI void APIENTRY glRectxvOES (const GLfixed *v1, const GLfixed *v2); +GLAPI void APIENTRY glTexCoord1xOES (GLfixed s); +GLAPI void APIENTRY glTexCoord1xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord2xOES (GLfixed s, GLfixed t); +GLAPI void APIENTRY glTexCoord2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord3xOES (GLfixed s, GLfixed t, GLfixed r); +GLAPI void APIENTRY glTexCoord3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord4xOES (GLfixed s, GLfixed t, GLfixed r, GLfixed q); +GLAPI void APIENTRY glTexCoord4xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexGenxOES (GLenum coord, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexGenxvOES (GLenum coord, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glVertex2xOES (GLfixed x); +GLAPI void APIENTRY glVertex2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glVertex3xOES (GLfixed x, GLfixed y); +GLAPI void APIENTRY glVertex3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glVertex4xOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glVertex4xvOES (const GLfixed *coords); +#endif +#endif /* GL_OES_fixed_point */ + +#ifndef GL_OES_query_matrix +#define GL_OES_query_matrix 1 +typedef GLbitfield (APIENTRYP PFNGLQUERYMATRIXXOESPROC) (GLfixed *mantissa, GLint *exponent); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLbitfield APIENTRY glQueryMatrixxOES (GLfixed *mantissa, GLint *exponent); +#endif +#endif /* GL_OES_query_matrix */ + +#ifndef GL_OES_read_format +#define GL_OES_read_format 1 +#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B +#endif /* GL_OES_read_format */ + +#ifndef GL_OES_single_precision +#define GL_OES_single_precision 1 +typedef void (APIENTRYP PFNGLCLEARDEPTHFOESPROC) (GLclampf depth); +typedef void (APIENTRYP PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat *equation); +typedef void (APIENTRYP PFNGLDEPTHRANGEFOESPROC) (GLclampf n, GLclampf f); +typedef void (APIENTRYP PFNGLFRUSTUMFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLGETCLIPPLANEFOESPROC) (GLenum plane, GLfloat *equation); +typedef void (APIENTRYP PFNGLORTHOFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClearDepthfOES (GLclampf depth); +GLAPI void APIENTRY glClipPlanefOES (GLenum plane, const GLfloat *equation); +GLAPI void APIENTRY glDepthRangefOES (GLclampf n, GLclampf f); +GLAPI void APIENTRY glFrustumfOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +GLAPI void APIENTRY glGetClipPlanefOES (GLenum plane, GLfloat *equation); +GLAPI void APIENTRY glOrthofOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +#endif +#endif /* GL_OES_single_precision */ + +#ifndef GL_3DFX_multisample +#define GL_3DFX_multisample 1 +#define GL_MULTISAMPLE_3DFX 0x86B2 +#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 +#define GL_SAMPLES_3DFX 0x86B4 +#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 +#endif /* GL_3DFX_multisample */ + +#ifndef GL_3DFX_tbuffer +#define GL_3DFX_tbuffer 1 +typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTbufferMask3DFX (GLuint mask); +#endif +#endif /* GL_3DFX_tbuffer */ + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_3DFX_texture_compression_FXT1 1 +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 +#endif /* GL_3DFX_texture_compression_FXT1 */ + +#ifndef GL_AMD_blend_minmax_factor +#define GL_AMD_blend_minmax_factor 1 +#define GL_FACTOR_MIN_AMD 0x901C +#define GL_FACTOR_MAX_AMD 0x901D +#endif /* GL_AMD_blend_minmax_factor */ + +#ifndef GL_AMD_conservative_depth +#define GL_AMD_conservative_depth 1 +#endif /* GL_AMD_conservative_depth */ + +#ifndef GL_AMD_debug_output +#define GL_AMD_debug_output 1 +typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam); +#define GL_MAX_DEBUG_MESSAGE_LENGTH_AMD 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 +#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 +#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 +#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A +#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B +#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C +#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D +#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E +#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F +#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 +typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#endif +#endif /* GL_AMD_debug_output */ + +#ifndef GL_AMD_depth_clamp_separate +#define GL_AMD_depth_clamp_separate 1 +#define GL_DEPTH_CLAMP_NEAR_AMD 0x901E +#define GL_DEPTH_CLAMP_FAR_AMD 0x901F +#endif /* GL_AMD_depth_clamp_separate */ + +#ifndef GL_AMD_draw_buffers_blend +#define GL_AMD_draw_buffers_blend 1 +typedef void (APIENTRYP PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncIndexedAMD (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateIndexedAMD (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GLAPI void APIENTRY glBlendEquationIndexedAMD (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#endif +#endif /* GL_AMD_draw_buffers_blend */ + +#ifndef GL_AMD_gcn_shader +#define GL_AMD_gcn_shader 1 +#endif /* GL_AMD_gcn_shader */ + +#ifndef GL_AMD_gpu_shader_int64 +#define GL_AMD_gpu_shader_int64 1 +typedef int64_t GLint64EXT; +#define GL_INT64_NV 0x140E +#define GL_UNSIGNED_INT64_NV 0x140F +#define GL_INT8_NV 0x8FE0 +#define GL_INT8_VEC2_NV 0x8FE1 +#define GL_INT8_VEC3_NV 0x8FE2 +#define GL_INT8_VEC4_NV 0x8FE3 +#define GL_INT16_NV 0x8FE4 +#define GL_INT16_VEC2_NV 0x8FE5 +#define GL_INT16_VEC3_NV 0x8FE6 +#define GL_INT16_VEC4_NV 0x8FE7 +#define GL_INT64_VEC2_NV 0x8FE9 +#define GL_INT64_VEC3_NV 0x8FEA +#define GL_INT64_VEC4_NV 0x8FEB +#define GL_UNSIGNED_INT8_NV 0x8FEC +#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED +#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE +#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF +#define GL_UNSIGNED_INT16_NV 0x8FF0 +#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 +#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 +#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 +#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 +#define GL_FLOAT16_NV 0x8FF8 +#define GL_FLOAT16_VEC2_NV 0x8FF9 +#define GL_FLOAT16_VEC3_NV 0x8FFA +#define GL_FLOAT16_VEC4_NV 0x8FFB +typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniform1i64NV (GLint location, GLint64EXT x); +GLAPI void APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x); +GLAPI void APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params); +GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params); +GLAPI void APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x); +GLAPI void APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x); +GLAPI void APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif +#endif /* GL_AMD_gpu_shader_int64 */ + +#ifndef GL_AMD_interleaved_elements +#define GL_AMD_interleaved_elements 1 +#define GL_VERTEX_ELEMENT_SWIZZLE_AMD 0x91A4 +#define GL_VERTEX_ID_SWIZZLE_AMD 0x91A5 +typedef void (APIENTRYP PFNGLVERTEXATTRIBPARAMETERIAMDPROC) (GLuint index, GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribParameteriAMD (GLuint index, GLenum pname, GLint param); +#endif +#endif /* GL_AMD_interleaved_elements */ + +#ifndef GL_AMD_multi_draw_indirect +#define GL_AMD_multi_draw_indirect 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride); +#endif +#endif /* GL_AMD_multi_draw_indirect */ + +#ifndef GL_AMD_name_gen_delete +#define GL_AMD_name_gen_delete 1 +#define GL_DATA_BUFFER_AMD 0x9151 +#define GL_PERFORMANCE_MONITOR_AMD 0x9152 +#define GL_QUERY_OBJECT_AMD 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_AMD 0x9154 +#define GL_SAMPLER_OBJECT_AMD 0x9155 +typedef void (APIENTRYP PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint *names); +typedef void (APIENTRYP PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint *names); +typedef GLboolean (APIENTRYP PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenNamesAMD (GLenum identifier, GLuint num, GLuint *names); +GLAPI void APIENTRY glDeleteNamesAMD (GLenum identifier, GLuint num, const GLuint *names); +GLAPI GLboolean APIENTRY glIsNameAMD (GLenum identifier, GLuint name); +#endif +#endif /* GL_AMD_name_gen_delete */ + +#ifndef GL_AMD_occlusion_query_event +#define GL_AMD_occlusion_query_event 1 +#define GL_OCCLUSION_QUERY_EVENT_MASK_AMD 0x874F +#define GL_QUERY_DEPTH_PASS_EVENT_BIT_AMD 0x00000001 +#define GL_QUERY_DEPTH_FAIL_EVENT_BIT_AMD 0x00000002 +#define GL_QUERY_STENCIL_FAIL_EVENT_BIT_AMD 0x00000004 +#define GL_QUERY_DEPTH_BOUNDS_FAIL_EVENT_BIT_AMD 0x00000008 +#define GL_QUERY_ALL_EVENT_BITS_AMD 0xFFFFFFFF +typedef void (APIENTRYP PFNGLQUERYOBJECTPARAMETERUIAMDPROC) (GLenum target, GLuint id, GLenum pname, GLuint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glQueryObjectParameteruiAMD (GLenum target, GLuint id, GLenum pname, GLuint param); +#endif +#endif /* GL_AMD_occlusion_query_event */ + +#ifndef GL_AMD_performance_monitor +#define GL_AMD_performance_monitor 1 +#define GL_COUNTER_TYPE_AMD 0x8BC0 +#define GL_COUNTER_RANGE_AMD 0x8BC1 +#define GL_UNSIGNED_INT64_AMD 0x8BC2 +#define GL_PERCENTAGE_AMD 0x8BC3 +#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 +#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 +#define GL_PERFMON_RESULT_AMD 0x8BC6 +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void *data); +typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, void *data); +GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#endif +#endif /* GL_AMD_performance_monitor */ + +#ifndef GL_AMD_pinned_memory +#define GL_AMD_pinned_memory 1 +#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160 +#endif /* GL_AMD_pinned_memory */ + +#ifndef GL_AMD_query_buffer_object +#define GL_AMD_query_buffer_object 1 +#define GL_QUERY_BUFFER_AMD 0x9192 +#define GL_QUERY_BUFFER_BINDING_AMD 0x9193 +#define GL_QUERY_RESULT_NO_WAIT_AMD 0x9194 +#endif /* GL_AMD_query_buffer_object */ + +#ifndef GL_AMD_sample_positions +#define GL_AMD_sample_positions 1 +#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F +typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val); +#endif +#endif /* GL_AMD_sample_positions */ + +#ifndef GL_AMD_seamless_cubemap_per_texture +#define GL_AMD_seamless_cubemap_per_texture 1 +#endif /* GL_AMD_seamless_cubemap_per_texture */ + +#ifndef GL_AMD_shader_atomic_counter_ops +#define GL_AMD_shader_atomic_counter_ops 1 +#endif /* GL_AMD_shader_atomic_counter_ops */ + +#ifndef GL_AMD_shader_stencil_export +#define GL_AMD_shader_stencil_export 1 +#endif /* GL_AMD_shader_stencil_export */ + +#ifndef GL_AMD_shader_trinary_minmax +#define GL_AMD_shader_trinary_minmax 1 +#endif /* GL_AMD_shader_trinary_minmax */ + +#ifndef GL_AMD_sparse_texture +#define GL_AMD_sparse_texture 1 +#define GL_VIRTUAL_PAGE_SIZE_X_AMD 0x9195 +#define GL_VIRTUAL_PAGE_SIZE_Y_AMD 0x9196 +#define GL_VIRTUAL_PAGE_SIZE_Z_AMD 0x9197 +#define GL_MAX_SPARSE_TEXTURE_SIZE_AMD 0x9198 +#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_AMD 0x9199 +#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS 0x919A +#define GL_MIN_SPARSE_LEVEL_AMD 0x919B +#define GL_MIN_LOD_WARNING_AMD 0x919C +#define GL_TEXTURE_STORAGE_SPARSE_BIT_AMD 0x00000001 +typedef void (APIENTRYP PFNGLTEXSTORAGESPARSEAMDPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +typedef void (APIENTRYP PFNGLTEXTURESTORAGESPARSEAMDPROC) (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexStorageSparseAMD (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +GLAPI void APIENTRY glTextureStorageSparseAMD (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +#endif +#endif /* GL_AMD_sparse_texture */ + +#ifndef GL_AMD_stencil_operation_extended +#define GL_AMD_stencil_operation_extended 1 +#define GL_SET_AMD 0x874A +#define GL_REPLACE_VALUE_AMD 0x874B +#define GL_STENCIL_OP_VALUE_AMD 0x874C +#define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D +typedef void (APIENTRYP PFNGLSTENCILOPVALUEAMDPROC) (GLenum face, GLuint value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value); +#endif +#endif /* GL_AMD_stencil_operation_extended */ + +#ifndef GL_AMD_texture_texture4 +#define GL_AMD_texture_texture4 1 +#endif /* GL_AMD_texture_texture4 */ + +#ifndef GL_AMD_transform_feedback3_lines_triangles +#define GL_AMD_transform_feedback3_lines_triangles 1 +#endif /* GL_AMD_transform_feedback3_lines_triangles */ + +#ifndef GL_AMD_transform_feedback4 +#define GL_AMD_transform_feedback4 1 +#define GL_STREAM_RASTERIZATION_AMD 0x91A0 +#endif /* GL_AMD_transform_feedback4 */ + +#ifndef GL_AMD_vertex_shader_layer +#define GL_AMD_vertex_shader_layer 1 +#endif /* GL_AMD_vertex_shader_layer */ + +#ifndef GL_AMD_vertex_shader_tessellator +#define GL_AMD_vertex_shader_tessellator 1 +#define GL_SAMPLER_BUFFER_AMD 0x9001 +#define GL_INT_SAMPLER_BUFFER_AMD 0x9002 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 +#define GL_TESSELLATION_MODE_AMD 0x9004 +#define GL_TESSELLATION_FACTOR_AMD 0x9005 +#define GL_DISCRETE_AMD 0x9006 +#define GL_CONTINUOUS_AMD 0x9007 +typedef void (APIENTRYP PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTessellationFactorAMD (GLfloat factor); +GLAPI void APIENTRY glTessellationModeAMD (GLenum mode); +#endif +#endif /* GL_AMD_vertex_shader_tessellator */ + +#ifndef GL_AMD_vertex_shader_viewport_index +#define GL_AMD_vertex_shader_viewport_index 1 +#endif /* GL_AMD_vertex_shader_viewport_index */ + +#ifndef GL_APPLE_aux_depth_stencil +#define GL_APPLE_aux_depth_stencil 1 +#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14 +#endif /* GL_APPLE_aux_depth_stencil */ + +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 +#endif /* GL_APPLE_client_storage */ + +#ifndef GL_APPLE_element_array +#define GL_APPLE_element_array 1 +#define GL_ELEMENT_ARRAY_APPLE 0x8A0C +#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D +#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E +typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const void *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerAPPLE (GLenum type, const void *pointer); +GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif +#endif /* GL_APPLE_element_array */ + +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 +#define GL_DRAW_PIXELS_APPLE 0x8A0A +#define GL_FENCE_APPLE 0x8A0B +typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); +typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); +typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenFencesAPPLE (GLsizei n, GLuint *fences); +GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glSetFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint fence); +GLAPI void APIENTRY glFinishFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum object, GLuint name); +GLAPI void APIENTRY glFinishObjectAPPLE (GLenum object, GLint name); +#endif +#endif /* GL_APPLE_fence */ + +#ifndef GL_APPLE_float_pixels +#define GL_APPLE_float_pixels 1 +#define GL_HALF_APPLE 0x140B +#define GL_RGBA_FLOAT32_APPLE 0x8814 +#define GL_RGB_FLOAT32_APPLE 0x8815 +#define GL_ALPHA_FLOAT32_APPLE 0x8816 +#define GL_INTENSITY_FLOAT32_APPLE 0x8817 +#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 +#define GL_RGBA_FLOAT16_APPLE 0x881A +#define GL_RGB_FLOAT16_APPLE 0x881B +#define GL_ALPHA_FLOAT16_APPLE 0x881C +#define GL_INTENSITY_FLOAT16_APPLE 0x881D +#define GL_LUMINANCE_FLOAT16_APPLE 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F +#define GL_COLOR_FLOAT_APPLE 0x8A0F +#endif /* GL_APPLE_float_pixels */ + +#ifndef GL_APPLE_flush_buffer_range +#define GL_APPLE_flush_buffer_range 1 +#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 +#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 +typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum target, GLintptr offset, GLsizeiptr size); +#endif +#endif /* GL_APPLE_flush_buffer_range */ + +#ifndef GL_APPLE_object_purgeable +#define GL_APPLE_object_purgeable 1 +#define GL_BUFFER_OBJECT_APPLE 0x85B3 +#define GL_RELEASED_APPLE 0x8A19 +#define GL_VOLATILE_APPLE 0x8A1A +#define GL_RETAINED_APPLE 0x8A1B +#define GL_UNDEFINED_APPLE 0x8A1C +#define GL_PURGEABLE_APPLE 0x8A1D +typedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLenum APIENTRY glObjectPurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI GLenum APIENTRY glObjectUnpurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI void APIENTRY glGetObjectParameterivAPPLE (GLenum objectType, GLuint name, GLenum pname, GLint *params); +#endif +#endif /* GL_APPLE_object_purgeable */ + +#ifndef GL_APPLE_rgb_422 +#define GL_APPLE_rgb_422 1 +#define GL_RGB_422_APPLE 0x8A1F +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#define GL_RGB_RAW_422_APPLE 0x8A51 +#endif /* GL_APPLE_rgb_422 */ + +#ifndef GL_APPLE_row_bytes +#define GL_APPLE_row_bytes 1 +#define GL_PACK_ROW_BYTES_APPLE 0x8A15 +#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16 +#endif /* GL_APPLE_row_bytes */ + +#ifndef GL_APPLE_specular_vector +#define GL_APPLE_specular_vector 1 +#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 +#endif /* GL_APPLE_specular_vector */ + +#ifndef GL_APPLE_texture_range +#define GL_APPLE_texture_range 1 +#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 +#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 +#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC +#define GL_STORAGE_PRIVATE_APPLE 0x85BD +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF +typedef void (APIENTRYP PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const void *pointer); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, void **params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureRangeAPPLE (GLenum target, GLsizei length, const void *pointer); +GLAPI void APIENTRY glGetTexParameterPointervAPPLE (GLenum target, GLenum pname, void **params); +#endif +#endif /* GL_APPLE_texture_range */ + +#ifndef GL_APPLE_transform_hint +#define GL_APPLE_transform_hint 1 +#define GL_TRANSFORM_HINT_APPLE 0x85B1 +#endif /* GL_APPLE_transform_hint */ + +#ifndef GL_APPLE_vertex_array_object +#define GL_APPLE_vertex_array_object 1 +#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint array); +GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint array); +#endif +#endif /* GL_APPLE_vertex_array_object */ + +#ifndef GL_APPLE_vertex_array_range +#define GL_APPLE_vertex_array_range 1 +#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E +#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F +#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 +#define GL_STORAGE_CLIENT_APPLE 0x85B4 +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); +typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei length, void *pointer); +GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei length, void *pointer); +GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum pname, GLint param); +#endif +#endif /* GL_APPLE_vertex_array_range */ + +#ifndef GL_APPLE_vertex_program_evaluators +#define GL_APPLE_vertex_program_evaluators 1 +#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 +#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 +#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 +#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 +#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 +#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 +#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 +#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 +#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 +#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef GLboolean (APIENTRYP PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glEnableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glDisableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI GLboolean APIENTRY glIsVertexAttribEnabledAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glMapVertexAttrib1dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib1fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +GLAPI void APIENTRY glMapVertexAttrib2dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib2fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +#endif +#endif /* GL_APPLE_vertex_program_evaluators */ + +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 +#define GL_YCBCR_422_APPLE 0x85B9 +#endif /* GL_APPLE_ycbcr_422 */ + +#ifndef GL_ATI_draw_buffers +#define GL_ATI_draw_buffers 1 +#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 +#define GL_DRAW_BUFFER0_ATI 0x8825 +#define GL_DRAW_BUFFER1_ATI 0x8826 +#define GL_DRAW_BUFFER2_ATI 0x8827 +#define GL_DRAW_BUFFER3_ATI 0x8828 +#define GL_DRAW_BUFFER4_ATI 0x8829 +#define GL_DRAW_BUFFER5_ATI 0x882A +#define GL_DRAW_BUFFER6_ATI 0x882B +#define GL_DRAW_BUFFER7_ATI 0x882C +#define GL_DRAW_BUFFER8_ATI 0x882D +#define GL_DRAW_BUFFER9_ATI 0x882E +#define GL_DRAW_BUFFER10_ATI 0x882F +#define GL_DRAW_BUFFER11_ATI 0x8830 +#define GL_DRAW_BUFFER12_ATI 0x8831 +#define GL_DRAW_BUFFER13_ATI 0x8832 +#define GL_DRAW_BUFFER14_ATI 0x8833 +#define GL_DRAW_BUFFER15_ATI 0x8834 +typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersATI (GLsizei n, const GLenum *bufs); +#endif +#endif /* GL_ATI_draw_buffers */ + +#ifndef GL_ATI_element_array +#define GL_ATI_element_array 1 +#define GL_ELEMENT_ARRAY_ATI 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A +typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const void *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerATI (GLenum type, const void *pointer); +GLAPI void APIENTRY glDrawElementArrayATI (GLenum mode, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum mode, GLuint start, GLuint end, GLsizei count); +#endif +#endif /* GL_ATI_element_array */ + +#ifndef GL_ATI_envmap_bumpmap +#define GL_ATI_envmap_bumpmap 1 +#define GL_BUMP_ROT_MATRIX_ATI 0x8775 +#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 +#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 +#define GL_BUMP_TEX_UNITS_ATI 0x8778 +#define GL_DUDV_ATI 0x8779 +#define GL_DU8DV8_ATI 0x877A +#define GL_BUMP_ENVMAP_ATI 0x877B +#define GL_BUMP_TARGET_ATI 0x877C +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBumpParameterivATI (GLenum pname, const GLint *param); +GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum pname, GLint *param); +GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum pname, GLfloat *param); +#endif +#endif /* GL_ATI_envmap_bumpmap */ + +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_REG_6_ATI 0x8927 +#define GL_REG_7_ATI 0x8928 +#define GL_REG_8_ATI 0x8929 +#define GL_REG_9_ATI 0x892A +#define GL_REG_10_ATI 0x892B +#define GL_REG_11_ATI 0x892C +#define GL_REG_12_ATI 0x892D +#define GL_REG_13_ATI 0x892E +#define GL_REG_14_ATI 0x892F +#define GL_REG_15_ATI 0x8930 +#define GL_REG_16_ATI 0x8931 +#define GL_REG_17_ATI 0x8932 +#define GL_REG_18_ATI 0x8933 +#define GL_REG_19_ATI 0x8934 +#define GL_REG_20_ATI 0x8935 +#define GL_REG_21_ATI 0x8936 +#define GL_REG_22_ATI 0x8937 +#define GL_REG_23_ATI 0x8938 +#define GL_REG_24_ATI 0x8939 +#define GL_REG_25_ATI 0x893A +#define GL_REG_26_ATI 0x893B +#define GL_REG_27_ATI 0x893C +#define GL_REG_28_ATI 0x893D +#define GL_REG_29_ATI 0x893E +#define GL_REG_30_ATI 0x893F +#define GL_REG_31_ATI 0x8940 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_CON_8_ATI 0x8949 +#define GL_CON_9_ATI 0x894A +#define GL_CON_10_ATI 0x894B +#define GL_CON_11_ATI 0x894C +#define GL_CON_12_ATI 0x894D +#define GL_CON_13_ATI 0x894E +#define GL_CON_14_ATI 0x894F +#define GL_CON_15_ATI 0x8950 +#define GL_CON_16_ATI 0x8951 +#define GL_CON_17_ATI 0x8952 +#define GL_CON_18_ATI 0x8953 +#define GL_CON_19_ATI 0x8954 +#define GL_CON_20_ATI 0x8955 +#define GL_CON_21_ATI 0x8956 +#define GL_CON_22_ATI 0x8957 +#define GL_CON_23_ATI 0x8958 +#define GL_CON_24_ATI 0x8959 +#define GL_CON_25_ATI 0x895A +#define GL_CON_26_ATI 0x895B +#define GL_CON_27_ATI 0x895C +#define GL_CON_28_ATI 0x895D +#define GL_CON_29_ATI 0x895E +#define GL_CON_30_ATI 0x895F +#define GL_CON_31_ATI 0x8960 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896A +#define GL_CND0_ATI 0x896B +#define GL_DOT2_ADD_ATI 0x896C +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D +#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E +#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F +#define GL_NUM_PASSES_ATI 0x8970 +#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 +#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 +#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 +#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 +#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_SWIZZLE_STRQ_ATI 0x897A +#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B +#define GL_RED_BIT_ATI 0x00000001 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 +typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); +typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); +typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint range); +GLAPI void APIENTRY glBindFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glBeginFragmentShaderATI (void); +GLAPI void APIENTRY glEndFragmentShaderATI (void); +GLAPI void APIENTRY glPassTexCoordATI (GLuint dst, GLuint coord, GLenum swizzle); +GLAPI void APIENTRY glSampleMapATI (GLuint dst, GLuint interp, GLenum swizzle); +GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint dst, const GLfloat *value); +#endif +#endif /* GL_ATI_fragment_shader */ + +#ifndef GL_ATI_map_object_buffer +#define GL_ATI_map_object_buffer 1 +typedef void *(APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void *APIENTRY glMapObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint buffer); +#endif +#endif /* GL_ATI_map_object_buffer */ + +#ifndef GL_ATI_meminfo +#define GL_ATI_meminfo 1 +#define GL_VBO_FREE_MEMORY_ATI 0x87FB +#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC +#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD +#endif /* GL_ATI_meminfo */ + +#ifndef GL_ATI_pixel_format_float +#define GL_ATI_pixel_format_float 1 +#define GL_RGBA_FLOAT_MODE_ATI 0x8820 +#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 +#endif /* GL_ATI_pixel_format_float */ + +#ifndef GL_ATI_pn_triangles +#define GL_ATI_pn_triangles 1 +#define GL_PN_TRIANGLES_ATI 0x87F0 +#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 +#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 +#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 +#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 +#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 +#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 +#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 +#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 +typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPNTrianglesiATI (GLenum pname, GLint param); +GLAPI void APIENTRY glPNTrianglesfATI (GLenum pname, GLfloat param); +#endif +#endif /* GL_ATI_pn_triangles */ + +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpSeparateATI (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#endif +#endif /* GL_ATI_separate_stencil */ + +#ifndef GL_ATI_text_fragment_shader +#define GL_ATI_text_fragment_shader 1 +#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 +#endif /* GL_ATI_text_fragment_shader */ + +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 +#endif /* GL_ATI_texture_env_combine3 */ + +#ifndef GL_ATI_texture_float +#define GL_ATI_texture_float 1 +#define GL_RGBA_FLOAT32_ATI 0x8814 +#define GL_RGB_FLOAT32_ATI 0x8815 +#define GL_ALPHA_FLOAT32_ATI 0x8816 +#define GL_INTENSITY_FLOAT32_ATI 0x8817 +#define GL_LUMINANCE_FLOAT32_ATI 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 +#define GL_RGBA_FLOAT16_ATI 0x881A +#define GL_RGB_FLOAT16_ATI 0x881B +#define GL_ALPHA_FLOAT16_ATI 0x881C +#define GL_INTENSITY_FLOAT16_ATI 0x881D +#define GL_LUMINANCE_FLOAT16_ATI 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F +#endif /* GL_ATI_texture_float */ + +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 +#endif /* GL_ATI_texture_mirror_once */ + +#ifndef GL_ATI_vertex_array_object +#define GL_ATI_vertex_array_object 1 +#define GL_STATIC_ATI 0x8760 +#define GL_DYNAMIC_ATI 0x8761 +#define GL_PRESERVE_ATI 0x8762 +#define GL_DISCARD_ATI 0x8763 +#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 +#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 +#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 +#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 +typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const void *pointer, GLenum usage); +typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const void *pointer, GLenum preserve); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei size, const void *pointer, GLenum usage); +GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint buffer, GLuint offset, GLsizei size, const void *pointer, GLenum preserve); +GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint buffer, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectBufferivATI (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glFreeObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glArrayObjectATI (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum array, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetArrayObjectivATI (GLenum array, GLenum pname, GLint *params); +GLAPI void APIENTRY glVariantArrayObjectATI (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint id, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint id, GLenum pname, GLint *params); +#endif +#endif /* GL_ATI_vertex_array_object */ + +#ifndef GL_ATI_vertex_attrib_array_object +#define GL_ATI_vertex_attrib_array_object 1 +typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint index, GLenum pname, GLint *params); +#endif +#endif /* GL_ATI_vertex_attrib_array_object */ + +#ifndef GL_ATI_vertex_streams +#define GL_ATI_vertex_streams 1 +#define GL_MAX_VERTEX_STREAMS_ATI 0x876B +#define GL_VERTEX_STREAM0_ATI 0x876C +#define GL_VERTEX_STREAM1_ATI 0x876D +#define GL_VERTEX_STREAM2_ATI 0x876E +#define GL_VERTEX_STREAM3_ATI 0x876F +#define GL_VERTEX_STREAM4_ATI 0x8770 +#define GL_VERTEX_STREAM5_ATI 0x8771 +#define GL_VERTEX_STREAM6_ATI 0x8772 +#define GL_VERTEX_STREAM7_ATI 0x8773 +#define GL_VERTEX_SOURCE_ATI 0x8774 +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexStream1sATI (GLenum stream, GLshort x); +GLAPI void APIENTRY glVertexStream1svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream1iATI (GLenum stream, GLint x); +GLAPI void APIENTRY glVertexStream1ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream1fATI (GLenum stream, GLfloat x); +GLAPI void APIENTRY glVertexStream1fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream1dATI (GLenum stream, GLdouble x); +GLAPI void APIENTRY glVertexStream1dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream2sATI (GLenum stream, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexStream2svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream2iATI (GLenum stream, GLint x, GLint y); +GLAPI void APIENTRY glVertexStream2ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream2fATI (GLenum stream, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexStream2fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream2dATI (GLenum stream, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexStream2dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream3sATI (GLenum stream, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream3iATI (GLenum stream, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream3fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream3dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream4sATI (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexStream4svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream4iATI (GLenum stream, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexStream4ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream4fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexStream4fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream4dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexStream4dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glNormalStream3bATI (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +GLAPI void APIENTRY glNormalStream3bvATI (GLenum stream, const GLbyte *coords); +GLAPI void APIENTRY glNormalStream3sATI (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +GLAPI void APIENTRY glNormalStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glNormalStream3iATI (GLenum stream, GLint nx, GLint ny, GLint nz); +GLAPI void APIENTRY glNormalStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glNormalStream3fATI (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +GLAPI void APIENTRY glNormalStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glNormalStream3dATI (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +GLAPI void APIENTRY glNormalStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum stream); +GLAPI void APIENTRY glVertexBlendEnviATI (GLenum pname, GLint param); +GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param); +#endif +#endif /* GL_ATI_vertex_streams */ + +#ifndef GL_EXT_422_pixels +#define GL_EXT_422_pixels 1 +#define GL_422_EXT 0x80CC +#define GL_422_REV_EXT 0x80CD +#define GL_422_AVERAGE_EXT 0x80CE +#define GL_422_REV_AVERAGE_EXT 0x80CF +#endif /* GL_EXT_422_pixels */ + +#ifndef GL_EXT_abgr +#define GL_EXT_abgr 1 +#define GL_ABGR_EXT 0x8000 +#endif /* GL_EXT_abgr */ + +#ifndef GL_EXT_bgra +#define GL_EXT_bgra 1 +#define GL_BGR_EXT 0x80E0 +#define GL_BGRA_EXT 0x80E1 +#endif /* GL_EXT_bgra */ + +#ifndef GL_EXT_bindable_uniform +#define GL_EXT_bindable_uniform 1 +#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 +#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 +#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 +#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED +#define GL_UNIFORM_BUFFER_EXT 0x8DEE +#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF +typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); +typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); +typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformBufferEXT (GLuint program, GLint location, GLuint buffer); +GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint program, GLint location); +GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint program, GLint location); +#endif +#endif /* GL_EXT_bindable_uniform */ + +#ifndef GL_EXT_blend_color +#define GL_EXT_blend_color 1 +#define GL_CONSTANT_COLOR_EXT 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 +#define GL_CONSTANT_ALPHA_EXT 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 +#define GL_BLEND_COLOR_EXT 0x8005 +typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColorEXT (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +#endif +#endif /* GL_EXT_blend_color */ + +#ifndef GL_EXT_blend_equation_separate +#define GL_EXT_blend_equation_separate 1 +#define GL_BLEND_EQUATION_RGB_EXT 0x8009 +#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum modeRGB, GLenum modeAlpha); +#endif +#endif /* GL_EXT_blend_equation_separate */ + +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 1 +#define GL_BLEND_DST_RGB_EXT 0x80C8 +#define GL_BLEND_SRC_RGB_EXT 0x80C9 +#define GL_BLEND_DST_ALPHA_EXT 0x80CA +#define GL_BLEND_SRC_ALPHA_EXT 0x80CB +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif +#endif /* GL_EXT_blend_func_separate */ + +#ifndef GL_EXT_blend_logic_op +#define GL_EXT_blend_logic_op 1 +#endif /* GL_EXT_blend_logic_op */ + +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#define GL_FUNC_ADD_EXT 0x8006 +#define GL_BLEND_EQUATION_EXT 0x8009 +typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationEXT (GLenum mode); +#endif +#endif /* GL_EXT_blend_minmax */ + +#ifndef GL_EXT_blend_subtract +#define GL_EXT_blend_subtract 1 +#define GL_FUNC_SUBTRACT_EXT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B +#endif /* GL_EXT_blend_subtract */ + +#ifndef GL_EXT_clip_volume_hint +#define GL_EXT_clip_volume_hint 1 +#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 +#endif /* GL_EXT_clip_volume_hint */ + +#ifndef GL_EXT_cmyka +#define GL_EXT_cmyka 1 +#define GL_CMYK_EXT 0x800C +#define GL_CMYKA_EXT 0x800D +#define GL_PACK_CMYK_HINT_EXT 0x800E +#define GL_UNPACK_CMYK_HINT_EXT 0x800F +#endif /* GL_EXT_cmyka */ + +#ifndef GL_EXT_color_subtable +#define GL_EXT_color_subtable 1 +typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorSubTableEXT (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#endif +#endif /* GL_EXT_color_subtable */ + +#ifndef GL_EXT_compiled_vertex_array +#define GL_EXT_compiled_vertex_array 1 +#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 +#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 +typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLockArraysEXT (GLint first, GLsizei count); +GLAPI void APIENTRY glUnlockArraysEXT (void); +#endif +#endif /* GL_EXT_compiled_vertex_array */ + +#ifndef GL_EXT_convolution +#define GL_EXT_convolution 1 +#define GL_CONVOLUTION_1D_EXT 0x8010 +#define GL_CONVOLUTION_2D_EXT 0x8011 +#define GL_SEPARABLE_2D_EXT 0x8012 +#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 +#define GL_REDUCE_EXT 0x8016 +#define GL_CONVOLUTION_FORMAT_EXT 0x8017 +#define GL_CONVOLUTION_WIDTH_EXT 0x8018 +#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum target, GLenum format, GLenum type, void *image); +GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); +#endif +#endif /* GL_EXT_convolution */ + +#ifndef GL_EXT_coordinate_frame +#define GL_EXT_coordinate_frame 1 +#define GL_TANGENT_ARRAY_EXT 0x8439 +#define GL_BINORMAL_ARRAY_EXT 0x843A +#define GL_CURRENT_TANGENT_EXT 0x843B +#define GL_CURRENT_BINORMAL_EXT 0x843C +#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E +#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F +#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 +#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 +#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 +#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 +#define GL_MAP1_TANGENT_EXT 0x8444 +#define GL_MAP2_TANGENT_EXT 0x8445 +#define GL_MAP1_BINORMAL_EXT 0x8446 +#define GL_MAP2_BINORMAL_EXT 0x8447 +typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); +typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); +typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); +typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); +typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); +typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); +typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); +typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); +typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); +typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); +typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTangent3bEXT (GLbyte tx, GLbyte ty, GLbyte tz); +GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glTangent3dEXT (GLdouble tx, GLdouble ty, GLdouble tz); +GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glTangent3fEXT (GLfloat tx, GLfloat ty, GLfloat tz); +GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glTangent3iEXT (GLint tx, GLint ty, GLint tz); +GLAPI void APIENTRY glTangent3ivEXT (const GLint *v); +GLAPI void APIENTRY glTangent3sEXT (GLshort tx, GLshort ty, GLshort tz); +GLAPI void APIENTRY glTangent3svEXT (const GLshort *v); +GLAPI void APIENTRY glBinormal3bEXT (GLbyte bx, GLbyte by, GLbyte bz); +GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glBinormal3dEXT (GLdouble bx, GLdouble by, GLdouble bz); +GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glBinormal3fEXT (GLfloat bx, GLfloat by, GLfloat bz); +GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glBinormal3iEXT (GLint bx, GLint by, GLint bz); +GLAPI void APIENTRY glBinormal3ivEXT (const GLint *v); +GLAPI void APIENTRY glBinormal3sEXT (GLshort bx, GLshort by, GLshort bz); +GLAPI void APIENTRY glBinormal3svEXT (const GLshort *v); +GLAPI void APIENTRY glTangentPointerEXT (GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glBinormalPointerEXT (GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_coordinate_frame */ + +#ifndef GL_EXT_copy_texture +#define GL_EXT_copy_texture 1 +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif +#endif /* GL_EXT_copy_texture */ + +#ifndef GL_EXT_cull_vertex +#define GL_EXT_cull_vertex 1 +#define GL_CULL_VERTEX_EXT 0x81AA +#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB +#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC +typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCullParameterdvEXT (GLenum pname, GLdouble *params); +GLAPI void APIENTRY glCullParameterfvEXT (GLenum pname, GLfloat *params); +#endif +#endif /* GL_EXT_cull_vertex */ + +#ifndef GL_EXT_debug_label +#define GL_EXT_debug_label 1 +#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F +#define GL_PROGRAM_OBJECT_EXT 0x8B40 +#define GL_SHADER_OBJECT_EXT 0x8B48 +#define GL_BUFFER_OBJECT_EXT 0x9151 +#define GL_QUERY_OBJECT_EXT 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154 +typedef void (APIENTRYP PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLabelObjectEXT (GLenum type, GLuint object, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectLabelEXT (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif +#endif /* GL_EXT_debug_label */ + +#ifndef GL_EXT_debug_marker +#define GL_EXT_debug_marker 1 +typedef void (APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker); +typedef void (APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker); +typedef void (APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glInsertEventMarkerEXT (GLsizei length, const GLchar *marker); +GLAPI void APIENTRY glPushGroupMarkerEXT (GLsizei length, const GLchar *marker); +GLAPI void APIENTRY glPopGroupMarkerEXT (void); +#endif +#endif /* GL_EXT_debug_marker */ + +#ifndef GL_EXT_depth_bounds_test +#define GL_EXT_depth_bounds_test 1 +#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 +#define GL_DEPTH_BOUNDS_EXT 0x8891 +typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthBoundsEXT (GLclampd zmin, GLclampd zmax); +#endif +#endif /* GL_EXT_depth_bounds_test */ + +#ifndef GL_EXT_direct_state_access +#define GL_EXT_direct_state_access 1 +#define GL_PROGRAM_MATRIX_EXT 0x8E2D +#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E +#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F +typedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +typedef void (APIENTRYP PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +typedef void (APIENTRYP PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data); +typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, void **data); +typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint lod, void *img); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, void *img); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, void **params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLENABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLGETFLOATI_VEXTPROC) (GLenum pname, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETDOUBLEI_VEXTPROC) (GLenum pname, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPOINTERI_VEXTPROC) (GLenum pname, GLuint index, void **params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, void *string); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target); +typedef void (APIENTRYP PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); +typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +typedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYINDEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYNORMALOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); +typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); +typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERVEXTPROC) (GLuint vaobj, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERVEXTPROC) (GLuint vaobj, GLenum pname, void **param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, void **param); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLTEXTUREPAGECOMMITMENTEXTPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBDIVISOREXTPROC) (GLuint vaobj, GLuint index, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum mode); +GLAPI void APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixPopEXT (GLenum mode); +GLAPI void APIENTRY glMatrixPushEXT (GLenum mode); +GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glTextureParameterfEXT (GLuint texture, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glTextureParameteriEXT (GLuint texture, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetTextureImageEXT (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glBindMultiTextureEXT (GLenum texunit, GLenum target, GLuint texture); +GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexEnviEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexGendEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +GLAPI void APIENTRY glMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +GLAPI void APIENTRY glMultiTexGenfEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexGeniEXT (GLenum texunit, GLenum coord, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum target, GLuint index, GLdouble *data); +GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum target, GLuint index, void **data); +GLAPI void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index); +GLAPI void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index); +GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint texture, GLenum target, GLint lod, void *img); +GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target, GLint lod, void *img); +GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); +GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void *APIENTRY glMapNamedBufferEXT (GLuint buffer, GLenum access); +GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint buffer); +GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint buffer, GLenum pname, void **params); +GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); +GLAPI void APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glTextureBufferEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glMultiTexBufferEXT (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint program, GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint program, GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint program, GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint program, GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glEnableClientStateiEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glDisableClientStateiEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glGetFloati_vEXT (GLenum pname, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetDoublei_vEXT (GLenum pname, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetPointeri_vEXT (GLenum pname, GLuint index, void **params); +GLAPI void APIENTRY glNamedProgramStringEXT (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); +GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint program, GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint program, GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint program, GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint program, GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint program, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint program, GLenum target, GLenum pname, void *string); +GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint renderbuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint framebuffer, GLenum target); +GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint texture, GLenum target); +GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum texunit, GLenum target); +GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint framebuffer, GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint texture, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum texunit, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glVertexArrayVertexOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayEdgeFlagOffsetEXT (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayIndexOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayNormalOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayMultiTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayFogCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArraySecondaryColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayVertexAttribOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayVertexAttribIOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glEnableVertexArrayEXT (GLuint vaobj, GLenum array); +GLAPI void APIENTRY glDisableVertexArrayEXT (GLuint vaobj, GLenum array); +GLAPI void APIENTRY glEnableVertexArrayAttribEXT (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glDisableVertexArrayAttribEXT (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glGetVertexArrayIntegervEXT (GLuint vaobj, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayPointervEXT (GLuint vaobj, GLenum pname, void **param); +GLAPI void APIENTRY glGetVertexArrayIntegeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayPointeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, void **param); +GLAPI void *APIENTRY glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glNamedBufferStorageEXT (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); +GLAPI void APIENTRY glClearNamedBufferDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearNamedBufferSubDataEXT (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glNamedFramebufferParameteriEXT (GLuint framebuffer, GLenum pname, GLint param); +GLAPI void APIENTRY glGetNamedFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x); +GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glTextureBufferRangeEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glTextureStorage2DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage3DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glVertexArrayBindVertexBufferEXT (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexArrayVertexAttribFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribIFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribLFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribBindingEXT (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexArrayVertexBindingDivisorEXT (GLuint vaobj, GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glTexturePageCommitmentEXT (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident); +GLAPI void APIENTRY glVertexArrayVertexAttribDivisorEXT (GLuint vaobj, GLuint index, GLuint divisor); +#endif +#endif /* GL_EXT_direct_state_access */ + +#ifndef GL_EXT_draw_buffers2 +#define GL_EXT_draw_buffers2 1 +typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +#endif +#endif /* GL_EXT_draw_buffers2 */ + +#ifndef GL_EXT_draw_instanced +#define GL_EXT_draw_instanced 1 +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#endif +#endif /* GL_EXT_draw_instanced */ + +#ifndef GL_EXT_draw_range_elements +#define GL_EXT_draw_range_elements 1 +#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 +#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +#endif +#endif /* GL_EXT_draw_range_elements */ + +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 1 +#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 +#define GL_FOG_COORDINATE_EXT 0x8451 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 +typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogCoordfEXT (GLfloat coord); +GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *coord); +GLAPI void APIENTRY glFogCoorddEXT (GLdouble coord); +GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointerEXT (GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_fog_coord */ + +#ifndef GL_EXT_framebuffer_blit +#define GL_EXT_framebuffer_blit 1 +#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +#endif /* GL_EXT_framebuffer_blit */ + +#ifndef GL_EXT_framebuffer_multisample +#define GL_EXT_framebuffer_multisample 1 +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_EXT_framebuffer_multisample */ + +#ifndef GL_EXT_framebuffer_multisample_blit_scaled +#define GL_EXT_framebuffer_multisample_blit_scaled 1 +#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA +#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB +#endif /* GL_EXT_framebuffer_multisample_blit_scaled */ + +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 +#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_STENCIL_INDEX1_EXT 0x8D46 +#define GL_STENCIL_INDEX4_EXT 0x8D47 +#define GL_STENCIL_INDEX8_EXT 0x8D48 +#define GL_STENCIL_INDEX16_EXT 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbufferEXT (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebufferEXT (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmapEXT (GLenum target); +#endif +#endif /* GL_EXT_framebuffer_object */ + +#ifndef GL_EXT_framebuffer_sRGB +#define GL_EXT_framebuffer_sRGB 1 +#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 +#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA +#endif /* GL_EXT_framebuffer_sRGB */ + +#ifndef GL_EXT_geometry_shader4 +#define GL_EXT_geometry_shader4 1 +#define GL_GEOMETRY_SHADER_EXT 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE +#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 +#define GL_LINES_ADJACENCY_EXT 0x000A +#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B +#define GL_TRIANGLES_ADJACENCY_EXT 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 +#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); +#endif +#endif /* GL_EXT_geometry_shader4 */ + +#ifndef GL_EXT_gpu_program_parameters +#define GL_EXT_gpu_program_parameters 1 +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#endif +#endif /* GL_EXT_gpu_program_parameters */ + +#ifndef GL_EXT_gpu_shader4 +#define GL_EXT_gpu_shader4 1 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT 0x88FD +#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 +#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 +#define GL_SAMPLER_BUFFER_EXT 0x8DC2 +#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 +#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 +#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 +#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 +#define GL_INT_SAMPLER_1D_EXT 0x8DC9 +#define GL_INT_SAMPLER_2D_EXT 0x8DCA +#define GL_INT_SAMPLER_3D_EXT 0x8DCB +#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC +#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD +#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF +#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 +#define GL_MIN_PROGRAM_TEXEL_OFFSET_EXT 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_EXT 0x8905 +typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUniformuivEXT (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1uiEXT (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2uiEXT (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uivEXT (GLint location, GLsizei count, const GLuint *value); +#endif +#endif /* GL_EXT_gpu_shader4 */ + +#ifndef GL_EXT_histogram +#define GL_EXT_histogram 1 +#define GL_HISTOGRAM_EXT 0x8024 +#define GL_PROXY_HISTOGRAM_EXT 0x8025 +#define GL_HISTOGRAM_WIDTH_EXT 0x8026 +#define GL_HISTOGRAM_FORMAT_EXT 0x8027 +#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C +#define GL_HISTOGRAM_SINK_EXT 0x802D +#define GL_MINMAX_EXT 0x802E +#define GL_MINMAX_FORMAT_EXT 0x802F +#define GL_MINMAX_SINK_EXT 0x8030 +#define GL_TABLE_TOO_LARGE_EXT 0x8031 +typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetHistogramEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmaxEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogramEXT (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmaxEXT (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogramEXT (GLenum target); +GLAPI void APIENTRY glResetMinmaxEXT (GLenum target); +#endif +#endif /* GL_EXT_histogram */ + +#ifndef GL_EXT_index_array_formats +#define GL_EXT_index_array_formats 1 +#define GL_IUI_V2F_EXT 0x81AD +#define GL_IUI_V3F_EXT 0x81AE +#define GL_IUI_N3F_V2F_EXT 0x81AF +#define GL_IUI_N3F_V3F_EXT 0x81B0 +#define GL_T2F_IUI_V2F_EXT 0x81B1 +#define GL_T2F_IUI_V3F_EXT 0x81B2 +#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 +#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 +#endif /* GL_EXT_index_array_formats */ + +#ifndef GL_EXT_index_func +#define GL_EXT_index_func 1 +#define GL_INDEX_TEST_EXT 0x81B5 +#define GL_INDEX_TEST_FUNC_EXT 0x81B6 +#define GL_INDEX_TEST_REF_EXT 0x81B7 +typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexFuncEXT (GLenum func, GLclampf ref); +#endif +#endif /* GL_EXT_index_func */ + +#ifndef GL_EXT_index_material +#define GL_EXT_index_material 1 +#define GL_INDEX_MATERIAL_EXT 0x81B8 +#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 +#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA +typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexMaterialEXT (GLenum face, GLenum mode); +#endif +#endif /* GL_EXT_index_material */ + +#ifndef GL_EXT_index_texture +#define GL_EXT_index_texture 1 +#endif /* GL_EXT_index_texture */ + +#ifndef GL_EXT_light_texture +#define GL_EXT_light_texture 1 +#define GL_FRAGMENT_MATERIAL_EXT 0x8349 +#define GL_FRAGMENT_NORMAL_EXT 0x834A +#define GL_FRAGMENT_COLOR_EXT 0x834C +#define GL_ATTENUATION_EXT 0x834D +#define GL_SHADOW_ATTENUATION_EXT 0x834E +#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F +#define GL_TEXTURE_LIGHT_EXT 0x8350 +#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 +#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 +typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glApplyTextureEXT (GLenum mode); +GLAPI void APIENTRY glTextureLightEXT (GLenum pname); +GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode); +#endif +#endif /* GL_EXT_light_texture */ + +#ifndef GL_EXT_misc_attribute +#define GL_EXT_misc_attribute 1 +#endif /* GL_EXT_misc_attribute */ + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); +#endif +#endif /* GL_EXT_multi_draw_arrays */ + +#ifndef GL_EXT_multisample +#define GL_EXT_multisample 1 +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#define GL_SAMPLE_MASK_EXT 0x80A0 +#define GL_1PASS_EXT 0x80A1 +#define GL_2PASS_0_EXT 0x80A2 +#define GL_2PASS_1_EXT 0x80A3 +#define GL_4PASS_0_EXT 0x80A4 +#define GL_4PASS_1_EXT 0x80A5 +#define GL_4PASS_2_EXT 0x80A6 +#define GL_4PASS_3_EXT 0x80A7 +#define GL_SAMPLE_BUFFERS_EXT 0x80A8 +#define GL_SAMPLES_EXT 0x80A9 +#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA +#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB +#define GL_SAMPLE_PATTERN_EXT 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 +typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskEXT (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternEXT (GLenum pattern); +#endif +#endif /* GL_EXT_multisample */ + +#ifndef GL_EXT_packed_depth_stencil +#define GL_EXT_packed_depth_stencil 1 +#define GL_DEPTH_STENCIL_EXT 0x84F9 +#define GL_UNSIGNED_INT_24_8_EXT 0x84FA +#define GL_DEPTH24_STENCIL8_EXT 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 +#endif /* GL_EXT_packed_depth_stencil */ + +#ifndef GL_EXT_packed_float +#define GL_EXT_packed_float 1 +#define GL_R11F_G11F_B10F_EXT 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B +#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C +#endif /* GL_EXT_packed_float */ + +#ifndef GL_EXT_packed_pixels +#define GL_EXT_packed_pixels 1 +#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 +#endif /* GL_EXT_packed_pixels */ + +#ifndef GL_EXT_paletted_texture +#define GL_EXT_paletted_texture 1 +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED +typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, void *data); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableEXT (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void *table); +GLAPI void APIENTRY glGetColorTableEXT (GLenum target, GLenum format, GLenum type, void *data); +GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +#endif +#endif /* GL_EXT_paletted_texture */ + +#ifndef GL_EXT_pixel_buffer_object +#define GL_EXT_pixel_buffer_object 1 +#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF +#endif /* GL_EXT_pixel_buffer_object */ + +#ifndef GL_EXT_pixel_transform +#define GL_EXT_pixel_transform 1 +#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 +#define GL_PIXEL_MAG_FILTER_EXT 0x8331 +#define GL_PIXEL_MIN_FILTER_EXT 0x8332 +#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 +#define GL_CUBIC_EXT 0x8334 +#define GL_AVERAGE_EXT 0x8335 +#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 +#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 +#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetPixelTransformParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetPixelTransformParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +#endif +#endif /* GL_EXT_pixel_transform */ + +#ifndef GL_EXT_pixel_transform_color_table +#define GL_EXT_pixel_transform_color_table 1 +#endif /* GL_EXT_pixel_transform_color_table */ + +#ifndef GL_EXT_point_parameters +#define GL_EXT_point_parameters 1 +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 +typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfEXT (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvEXT (GLenum pname, const GLfloat *params); +#endif +#endif /* GL_EXT_point_parameters */ + +#ifndef GL_EXT_polygon_offset +#define GL_EXT_polygon_offset 1 +#define GL_POLYGON_OFFSET_EXT 0x8037 +#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 +#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 +typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat factor, GLfloat bias); +#endif +#endif /* GL_EXT_polygon_offset */ + +#ifndef GL_EXT_provoking_vertex +#define GL_EXT_provoking_vertex 1 +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D +#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E +#define GL_PROVOKING_VERTEX_EXT 0x8E4F +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProvokingVertexEXT (GLenum mode); +#endif +#endif /* GL_EXT_provoking_vertex */ + +#ifndef GL_EXT_rescale_normal +#define GL_EXT_rescale_normal 1 +#define GL_RESCALE_NORMAL_EXT 0x803A +#endif /* GL_EXT_rescale_normal */ + +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3iEXT (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_secondary_color */ + +#ifndef GL_EXT_separate_shader_objects +#define GL_EXT_separate_shader_objects 1 +#define GL_ACTIVE_PROGRAM_EXT 0x8B8D +typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program); +typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUseShaderProgramEXT (GLenum type, GLuint program); +GLAPI void APIENTRY glActiveProgramEXT (GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *string); +#endif +#endif /* GL_EXT_separate_shader_objects */ + +#ifndef GL_EXT_separate_specular_color +#define GL_EXT_separate_specular_color 1 +#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 +#define GL_SINGLE_COLOR_EXT 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA +#endif /* GL_EXT_separate_specular_color */ + +#ifndef GL_EXT_shader_image_load_formatted +#define GL_EXT_shader_image_load_formatted 1 +#endif /* GL_EXT_shader_image_load_formatted */ + +#ifndef GL_EXT_shader_image_load_store +#define GL_EXT_shader_image_load_store 1 +#define GL_MAX_IMAGE_UNITS_EXT 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39 +#define GL_IMAGE_BINDING_NAME_EXT 0x8F3A +#define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B +#define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C +#define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D +#define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E +#define GL_IMAGE_1D_EXT 0x904C +#define GL_IMAGE_2D_EXT 0x904D +#define GL_IMAGE_3D_EXT 0x904E +#define GL_IMAGE_2D_RECT_EXT 0x904F +#define GL_IMAGE_CUBE_EXT 0x9050 +#define GL_IMAGE_BUFFER_EXT 0x9051 +#define GL_IMAGE_1D_ARRAY_EXT 0x9052 +#define GL_IMAGE_2D_ARRAY_EXT 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056 +#define GL_INT_IMAGE_1D_EXT 0x9057 +#define GL_INT_IMAGE_2D_EXT 0x9058 +#define GL_INT_IMAGE_3D_EXT 0x9059 +#define GL_INT_IMAGE_2D_RECT_EXT 0x905A +#define GL_INT_IMAGE_CUBE_EXT 0x905B +#define GL_INT_IMAGE_BUFFER_EXT 0x905C +#define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D +#define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C +#define GL_MAX_IMAGE_SAMPLES_EXT 0x906D +#define GL_IMAGE_BINDING_FORMAT_EXT 0x906E +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020 +#define GL_COMMAND_BARRIER_BIT_EXT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000 +#define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +typedef void (APIENTRYP PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindImageTextureEXT (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +GLAPI void APIENTRY glMemoryBarrierEXT (GLbitfield barriers); +#endif +#endif /* GL_EXT_shader_image_load_store */ + +#ifndef GL_EXT_shader_integer_mix +#define GL_EXT_shader_integer_mix 1 +#endif /* GL_EXT_shader_integer_mix */ + +#ifndef GL_EXT_shadow_funcs +#define GL_EXT_shadow_funcs 1 +#endif /* GL_EXT_shadow_funcs */ + +#ifndef GL_EXT_shared_texture_palette +#define GL_EXT_shared_texture_palette 1 +#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB +#endif /* GL_EXT_shared_texture_palette */ + +#ifndef GL_EXT_stencil_clear_tag +#define GL_EXT_stencil_clear_tag 1 +#define GL_STENCIL_TAG_BITS_EXT 0x88F2 +#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 +typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilClearTagEXT (GLsizei stencilTagBits, GLuint stencilClearTag); +#endif +#endif /* GL_EXT_stencil_clear_tag */ + +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 +typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum face); +#endif +#endif /* GL_EXT_stencil_two_side */ + +#ifndef GL_EXT_stencil_wrap +#define GL_EXT_stencil_wrap 1 +#define GL_INCR_WRAP_EXT 0x8507 +#define GL_DECR_WRAP_EXT 0x8508 +#endif /* GL_EXT_stencil_wrap */ + +#ifndef GL_EXT_subtexture +#define GL_EXT_subtexture 1 +typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +#endif +#endif /* GL_EXT_subtexture */ + +#ifndef GL_EXT_texture +#define GL_EXT_texture 1 +#define GL_ALPHA4_EXT 0x803B +#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA12_EXT 0x803D +#define GL_ALPHA16_EXT 0x803E +#define GL_LUMINANCE4_EXT 0x803F +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE12_EXT 0x8041 +#define GL_LUMINANCE16_EXT 0x8042 +#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 +#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 +#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 +#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 +#define GL_INTENSITY_EXT 0x8049 +#define GL_INTENSITY4_EXT 0x804A +#define GL_INTENSITY8_EXT 0x804B +#define GL_INTENSITY12_EXT 0x804C +#define GL_INTENSITY16_EXT 0x804D +#define GL_RGB2_EXT 0x804E +#define GL_RGB4_EXT 0x804F +#define GL_RGB5_EXT 0x8050 +#define GL_RGB8_EXT 0x8051 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB12_EXT 0x8053 +#define GL_RGB16_EXT 0x8054 +#define GL_RGBA2_EXT 0x8055 +#define GL_RGBA4_EXT 0x8056 +#define GL_RGB5_A1_EXT 0x8057 +#define GL_RGBA8_EXT 0x8058 +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGBA12_EXT 0x805A +#define GL_RGBA16_EXT 0x805B +#define GL_TEXTURE_RED_SIZE_EXT 0x805C +#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D +#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E +#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 +#define GL_REPLACE_EXT 0x8062 +#define GL_PROXY_TEXTURE_1D_EXT 0x8063 +#define GL_PROXY_TEXTURE_2D_EXT 0x8064 +#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 +#endif /* GL_EXT_texture */ + +#ifndef GL_EXT_texture3D +#define GL_EXT_texture3D 1 +#define GL_PACK_SKIP_IMAGES_EXT 0x806B +#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C +#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D +#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_TEXTURE_DEPTH_EXT 0x8071 +#define GL_TEXTURE_WRAP_R_EXT 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 +typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage3DEXT (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +#endif +#endif /* GL_EXT_texture3D */ + +#ifndef GL_EXT_texture_array +#define GL_EXT_texture_array 1 +#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 +#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D +#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF +#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E +#endif /* GL_EXT_texture_array */ + +#ifndef GL_EXT_texture_buffer_object +#define GL_EXT_texture_buffer_object 1 +#define GL_TEXTURE_BUFFER_EXT 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E +typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer); +#endif +#endif /* GL_EXT_texture_buffer_object */ + +#ifndef GL_EXT_texture_compression_latc +#define GL_EXT_texture_compression_latc 1 +#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 +#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 +#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 +#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 +#endif /* GL_EXT_texture_compression_latc */ + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_EXT_texture_compression_rgtc 1 +#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC +#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD +#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE +#endif /* GL_EXT_texture_compression_rgtc */ + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_EXT_texture_compression_s3tc 1 +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif /* GL_EXT_texture_compression_s3tc */ + +#ifndef GL_EXT_texture_cube_map +#define GL_EXT_texture_cube_map 1 +#define GL_NORMAL_MAP_EXT 0x8511 +#define GL_REFLECTION_MAP_EXT 0x8512 +#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C +#endif /* GL_EXT_texture_cube_map */ + +#ifndef GL_EXT_texture_env_add +#define GL_EXT_texture_env_add 1 +#endif /* GL_EXT_texture_env_add */ + +#ifndef GL_EXT_texture_env_combine +#define GL_EXT_texture_env_combine 1 +#define GL_COMBINE_EXT 0x8570 +#define GL_COMBINE_RGB_EXT 0x8571 +#define GL_COMBINE_ALPHA_EXT 0x8572 +#define GL_RGB_SCALE_EXT 0x8573 +#define GL_ADD_SIGNED_EXT 0x8574 +#define GL_INTERPOLATE_EXT 0x8575 +#define GL_CONSTANT_EXT 0x8576 +#define GL_PRIMARY_COLOR_EXT 0x8577 +#define GL_PREVIOUS_EXT 0x8578 +#define GL_SOURCE0_RGB_EXT 0x8580 +#define GL_SOURCE1_RGB_EXT 0x8581 +#define GL_SOURCE2_RGB_EXT 0x8582 +#define GL_SOURCE0_ALPHA_EXT 0x8588 +#define GL_SOURCE1_ALPHA_EXT 0x8589 +#define GL_SOURCE2_ALPHA_EXT 0x858A +#define GL_OPERAND0_RGB_EXT 0x8590 +#define GL_OPERAND1_RGB_EXT 0x8591 +#define GL_OPERAND2_RGB_EXT 0x8592 +#define GL_OPERAND0_ALPHA_EXT 0x8598 +#define GL_OPERAND1_ALPHA_EXT 0x8599 +#define GL_OPERAND2_ALPHA_EXT 0x859A +#endif /* GL_EXT_texture_env_combine */ + +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 +#endif /* GL_EXT_texture_env_dot3 */ + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif /* GL_EXT_texture_filter_anisotropic */ + +#ifndef GL_EXT_texture_integer +#define GL_EXT_texture_integer 1 +#define GL_RGBA32UI_EXT 0x8D70 +#define GL_RGB32UI_EXT 0x8D71 +#define GL_ALPHA32UI_EXT 0x8D72 +#define GL_INTENSITY32UI_EXT 0x8D73 +#define GL_LUMINANCE32UI_EXT 0x8D74 +#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 +#define GL_RGBA16UI_EXT 0x8D76 +#define GL_RGB16UI_EXT 0x8D77 +#define GL_ALPHA16UI_EXT 0x8D78 +#define GL_INTENSITY16UI_EXT 0x8D79 +#define GL_LUMINANCE16UI_EXT 0x8D7A +#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B +#define GL_RGBA8UI_EXT 0x8D7C +#define GL_RGB8UI_EXT 0x8D7D +#define GL_ALPHA8UI_EXT 0x8D7E +#define GL_INTENSITY8UI_EXT 0x8D7F +#define GL_LUMINANCE8UI_EXT 0x8D80 +#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 +#define GL_RGBA32I_EXT 0x8D82 +#define GL_RGB32I_EXT 0x8D83 +#define GL_ALPHA32I_EXT 0x8D84 +#define GL_INTENSITY32I_EXT 0x8D85 +#define GL_LUMINANCE32I_EXT 0x8D86 +#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 +#define GL_RGBA16I_EXT 0x8D88 +#define GL_RGB16I_EXT 0x8D89 +#define GL_ALPHA16I_EXT 0x8D8A +#define GL_INTENSITY16I_EXT 0x8D8B +#define GL_LUMINANCE16I_EXT 0x8D8C +#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D +#define GL_RGBA8I_EXT 0x8D8E +#define GL_RGB8I_EXT 0x8D8F +#define GL_ALPHA8I_EXT 0x8D90 +#define GL_INTENSITY8I_EXT 0x8D91 +#define GL_LUMINANCE8I_EXT 0x8D92 +#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 +#define GL_RED_INTEGER_EXT 0x8D94 +#define GL_GREEN_INTEGER_EXT 0x8D95 +#define GL_BLUE_INTEGER_EXT 0x8D96 +#define GL_ALPHA_INTEGER_EXT 0x8D97 +#define GL_RGB_INTEGER_EXT 0x8D98 +#define GL_RGBA_INTEGER_EXT 0x8D99 +#define GL_BGR_INTEGER_EXT 0x8D9A +#define GL_BGRA_INTEGER_EXT 0x8D9B +#define GL_LUMINANCE_INTEGER_EXT 0x8D9C +#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D +#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); +typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearColorIiEXT (GLint red, GLint green, GLint blue, GLint alpha); +GLAPI void APIENTRY glClearColorIuiEXT (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#endif +#endif /* GL_EXT_texture_integer */ + +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 +#endif /* GL_EXT_texture_lod_bias */ + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_EXT_texture_mirror_clamp 1 +#define GL_MIRROR_CLAMP_EXT 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 +#endif /* GL_EXT_texture_mirror_clamp */ + +#ifndef GL_EXT_texture_object +#define GL_EXT_texture_object 1 +#define GL_TEXTURE_PRIORITY_EXT 0x8066 +#define GL_TEXTURE_RESIDENT_EXT 0x8067 +#define GL_TEXTURE_1D_BINDING_EXT 0x8068 +#define GL_TEXTURE_2D_BINDING_EXT 0x8069 +#define GL_TEXTURE_3D_BINDING_EXT 0x806A +typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); +typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei n, const GLuint *textures, GLboolean *residences); +GLAPI void APIENTRY glBindTextureEXT (GLenum target, GLuint texture); +GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei n, const GLuint *textures); +GLAPI void APIENTRY glGenTexturesEXT (GLsizei n, GLuint *textures); +GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint texture); +GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#endif +#endif /* GL_EXT_texture_object */ + +#ifndef GL_EXT_texture_perturb_normal +#define GL_EXT_texture_perturb_normal 1 +#define GL_PERTURB_EXT 0x85AE +#define GL_TEXTURE_NORMAL_EXT 0x85AF +typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureNormalEXT (GLenum mode); +#endif +#endif /* GL_EXT_texture_perturb_normal */ + +#ifndef GL_EXT_texture_sRGB +#define GL_EXT_texture_sRGB 1 +#define GL_SRGB_EXT 0x8C40 +#define GL_SRGB8_EXT 0x8C41 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 +#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 +#define GL_SLUMINANCE_EXT 0x8C46 +#define GL_SLUMINANCE8_EXT 0x8C47 +#define GL_COMPRESSED_SRGB_EXT 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 +#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#endif /* GL_EXT_texture_sRGB */ + +#ifndef GL_EXT_texture_sRGB_decode +#define GL_EXT_texture_sRGB_decode 1 +#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 +#define GL_DECODE_EXT 0x8A49 +#define GL_SKIP_DECODE_EXT 0x8A4A +#endif /* GL_EXT_texture_sRGB_decode */ + +#ifndef GL_EXT_texture_shared_exponent +#define GL_EXT_texture_shared_exponent 1 +#define GL_RGB9_E5_EXT 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E +#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F +#endif /* GL_EXT_texture_shared_exponent */ + +#ifndef GL_EXT_texture_snorm +#define GL_EXT_texture_snorm 1 +#define GL_ALPHA_SNORM 0x9010 +#define GL_LUMINANCE_SNORM 0x9011 +#define GL_LUMINANCE_ALPHA_SNORM 0x9012 +#define GL_INTENSITY_SNORM 0x9013 +#define GL_ALPHA8_SNORM 0x9014 +#define GL_LUMINANCE8_SNORM 0x9015 +#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 +#define GL_INTENSITY8_SNORM 0x9017 +#define GL_ALPHA16_SNORM 0x9018 +#define GL_LUMINANCE16_SNORM 0x9019 +#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A +#define GL_INTENSITY16_SNORM 0x901B +#define GL_RED_SNORM 0x8F90 +#define GL_RG_SNORM 0x8F91 +#define GL_RGB_SNORM 0x8F92 +#define GL_RGBA_SNORM 0x8F93 +#endif /* GL_EXT_texture_snorm */ + +#ifndef GL_EXT_texture_swizzle +#define GL_EXT_texture_swizzle 1 +#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 +#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 +#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 +#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 +#endif /* GL_EXT_texture_swizzle */ + +#ifndef GL_EXT_timer_query +#define GL_EXT_timer_query 1 +#define GL_TIME_ELAPSED_EXT 0x88BF +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64 *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64 *params); +#endif +#endif /* GL_EXT_timer_query */ + +#ifndef GL_EXT_transform_feedback +#define GL_EXT_transform_feedback 1 +#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F +#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C +#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D +#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 +#define GL_RASTERIZER_DISCARD_EXT 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackEXT (void); +GLAPI void APIENTRY glBindBufferRangeEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseEXT (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#endif +#endif /* GL_EXT_transform_feedback */ + +#ifndef GL_EXT_vertex_array +#define GL_EXT_vertex_array 1 +#define GL_VERTEX_ARRAY_EXT 0x8074 +#define GL_NORMAL_ARRAY_EXT 0x8075 +#define GL_COLOR_ARRAY_EXT 0x8076 +#define GL_INDEX_ARRAY_EXT 0x8077 +#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 +#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 +#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A +#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B +#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C +#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D +#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E +#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F +#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 +#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 +#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 +#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 +#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 +#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 +#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 +#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 +#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A +#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B +#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C +#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D +#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E +#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F +#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 +#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 +typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); +typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); +typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, void **params); +typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glArrayElementEXT (GLint i); +GLAPI void APIENTRY glColorPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glDrawArraysEXT (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei stride, GLsizei count, const GLboolean *pointer); +GLAPI void APIENTRY glGetPointervEXT (GLenum pname, void **params); +GLAPI void APIENTRY glIndexPointerEXT (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glNormalPointerEXT (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glTexCoordPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glVertexPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +#endif +#endif /* GL_EXT_vertex_array */ + +#ifndef GL_EXT_vertex_array_bgra +#define GL_EXT_vertex_array_bgra 1 +#endif /* GL_EXT_vertex_array_bgra */ + +#ifndef GL_EXT_vertex_attrib_64bit +#define GL_EXT_vertex_attrib_64bit 1 +#define GL_DOUBLE_VEC2_EXT 0x8FFC +#define GL_DOUBLE_VEC3_EXT 0x8FFD +#define GL_DOUBLE_VEC4_EXT 0x8FFE +#define GL_DOUBLE_MAT2_EXT 0x8F46 +#define GL_DOUBLE_MAT3_EXT 0x8F47 +#define GL_DOUBLE_MAT4_EXT 0x8F48 +#define GL_DOUBLE_MAT2x3_EXT 0x8F49 +#define GL_DOUBLE_MAT2x4_EXT 0x8F4A +#define GL_DOUBLE_MAT3x2_EXT 0x8F4B +#define GL_DOUBLE_MAT3x4_EXT 0x8F4C +#define GL_DOUBLE_MAT4x2_EXT 0x8F4D +#define GL_DOUBLE_MAT4x3_EXT 0x8F4E +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1dEXT (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2dEXT (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribLdvEXT (GLuint index, GLenum pname, GLdouble *params); +#endif +#endif /* GL_EXT_vertex_attrib_64bit */ + +#ifndef GL_EXT_vertex_shader +#define GL_EXT_vertex_shader 1 +#define GL_VERTEX_SHADER_EXT 0x8780 +#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 +#define GL_OP_INDEX_EXT 0x8782 +#define GL_OP_NEGATE_EXT 0x8783 +#define GL_OP_DOT3_EXT 0x8784 +#define GL_OP_DOT4_EXT 0x8785 +#define GL_OP_MUL_EXT 0x8786 +#define GL_OP_ADD_EXT 0x8787 +#define GL_OP_MADD_EXT 0x8788 +#define GL_OP_FRAC_EXT 0x8789 +#define GL_OP_MAX_EXT 0x878A +#define GL_OP_MIN_EXT 0x878B +#define GL_OP_SET_GE_EXT 0x878C +#define GL_OP_SET_LT_EXT 0x878D +#define GL_OP_CLAMP_EXT 0x878E +#define GL_OP_FLOOR_EXT 0x878F +#define GL_OP_ROUND_EXT 0x8790 +#define GL_OP_EXP_BASE_2_EXT 0x8791 +#define GL_OP_LOG_BASE_2_EXT 0x8792 +#define GL_OP_POWER_EXT 0x8793 +#define GL_OP_RECIP_EXT 0x8794 +#define GL_OP_RECIP_SQRT_EXT 0x8795 +#define GL_OP_SUB_EXT 0x8796 +#define GL_OP_CROSS_PRODUCT_EXT 0x8797 +#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 +#define GL_OP_MOV_EXT 0x8799 +#define GL_OUTPUT_VERTEX_EXT 0x879A +#define GL_OUTPUT_COLOR0_EXT 0x879B +#define GL_OUTPUT_COLOR1_EXT 0x879C +#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D +#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E +#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F +#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 +#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 +#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 +#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 +#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 +#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 +#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 +#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 +#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 +#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 +#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA +#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB +#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC +#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD +#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE +#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF +#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 +#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 +#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 +#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 +#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 +#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 +#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 +#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 +#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 +#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 +#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA +#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB +#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC +#define GL_OUTPUT_FOG_EXT 0x87BD +#define GL_SCALAR_EXT 0x87BE +#define GL_VECTOR_EXT 0x87BF +#define GL_MATRIX_EXT 0x87C0 +#define GL_VARIANT_EXT 0x87C1 +#define GL_INVARIANT_EXT 0x87C2 +#define GL_LOCAL_CONSTANT_EXT 0x87C3 +#define GL_LOCAL_EXT 0x87C4 +#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 +#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 +#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 +#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 +#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE +#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF +#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 +#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 +#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 +#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 +#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 +#define GL_X_EXT 0x87D5 +#define GL_Y_EXT 0x87D6 +#define GL_Z_EXT 0x87D7 +#define GL_W_EXT 0x87D8 +#define GL_NEGATIVE_X_EXT 0x87D9 +#define GL_NEGATIVE_Y_EXT 0x87DA +#define GL_NEGATIVE_Z_EXT 0x87DB +#define GL_NEGATIVE_W_EXT 0x87DC +#define GL_ZERO_EXT 0x87DD +#define GL_ONE_EXT 0x87DE +#define GL_NEGATIVE_ONE_EXT 0x87DF +#define GL_NORMALIZED_RANGE_EXT 0x87E0 +#define GL_FULL_RANGE_EXT 0x87E1 +#define GL_CURRENT_VERTEX_EXT 0x87E2 +#define GL_MVP_MATRIX_EXT 0x87E3 +#define GL_VARIANT_VALUE_EXT 0x87E4 +#define GL_VARIANT_DATATYPE_EXT 0x87E5 +#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 +#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 +#define GL_VARIANT_ARRAY_EXT 0x87E8 +#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 +#define GL_INVARIANT_VALUE_EXT 0x87EA +#define GL_INVARIANT_DATATYPE_EXT 0x87EB +#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC +#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED +typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); +typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); +typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const void *addr); +typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const void *addr); +typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); +typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); +typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); +typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); +typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); +typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); +typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); +typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); +typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const void *addr); +typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); +typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); +typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, void **data); +typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVertexShaderEXT (void); +GLAPI void APIENTRY glEndVertexShaderEXT (void); +GLAPI void APIENTRY glBindVertexShaderEXT (GLuint id); +GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint range); +GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint id); +GLAPI void APIENTRY glShaderOp1EXT (GLenum op, GLuint res, GLuint arg1); +GLAPI void APIENTRY glShaderOp2EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +GLAPI void APIENTRY glShaderOp3EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +GLAPI void APIENTRY glSwizzleEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glWriteMaskEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glInsertComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI void APIENTRY glExtractComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +GLAPI void APIENTRY glSetInvariantEXT (GLuint id, GLenum type, const void *addr); +GLAPI void APIENTRY glSetLocalConstantEXT (GLuint id, GLenum type, const void *addr); +GLAPI void APIENTRY glVariantbvEXT (GLuint id, const GLbyte *addr); +GLAPI void APIENTRY glVariantsvEXT (GLuint id, const GLshort *addr); +GLAPI void APIENTRY glVariantivEXT (GLuint id, const GLint *addr); +GLAPI void APIENTRY glVariantfvEXT (GLuint id, const GLfloat *addr); +GLAPI void APIENTRY glVariantdvEXT (GLuint id, const GLdouble *addr); +GLAPI void APIENTRY glVariantubvEXT (GLuint id, const GLubyte *addr); +GLAPI void APIENTRY glVariantusvEXT (GLuint id, const GLushort *addr); +GLAPI void APIENTRY glVariantuivEXT (GLuint id, const GLuint *addr); +GLAPI void APIENTRY glVariantPointerEXT (GLuint id, GLenum type, GLuint stride, const void *addr); +GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint id); +GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint id); +GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum light, GLenum value); +GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum face, GLenum value); +GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum unit, GLenum coord, GLenum value); +GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum unit, GLenum value); +GLAPI GLuint APIENTRY glBindParameterEXT (GLenum value); +GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint id, GLenum cap); +GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetVariantPointervEXT (GLuint id, GLenum value, void **data); +GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +#endif +#endif /* GL_EXT_vertex_shader */ + +#ifndef GL_EXT_vertex_weighting +#define GL_EXT_vertex_weighting 1 +#define GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3 +#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 +#define GL_MODELVIEW0_MATRIX_EXT 0x0BA6 +#define GL_MODELVIEW1_MATRIX_EXT 0x8506 +#define GL_VERTEX_WEIGHTING_EXT 0x8509 +#define GL_MODELVIEW0_EXT 0x1700 +#define GL_MODELVIEW1_EXT 0x850A +#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B +#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C +#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D +#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E +#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F +#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexWeightfEXT (GLfloat weight); +GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *weight); +GLAPI void APIENTRY glVertexWeightPointerEXT (GLint size, GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_vertex_weighting */ + +#ifndef GL_EXT_x11_sync_object +#define GL_EXT_x11_sync_object 1 +#define GL_SYNC_X11_FENCE_EXT 0x90E1 +typedef GLsync (APIENTRYP PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +#endif +#endif /* GL_EXT_x11_sync_object */ + +#ifndef GL_GREMEDY_frame_terminator +#define GL_GREMEDY_frame_terminator 1 +typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameTerminatorGREMEDY (void); +#endif +#endif /* GL_GREMEDY_frame_terminator */ + +#ifndef GL_GREMEDY_string_marker +#define GL_GREMEDY_string_marker 1 +typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const void *string); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei len, const void *string); +#endif +#endif /* GL_GREMEDY_string_marker */ + +#ifndef GL_HP_convolution_border_modes +#define GL_HP_convolution_border_modes 1 +#define GL_IGNORE_BORDER_HP 0x8150 +#define GL_CONSTANT_BORDER_HP 0x8151 +#define GL_REPLICATE_BORDER_HP 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 +#endif /* GL_HP_convolution_border_modes */ + +#ifndef GL_HP_image_transform +#define GL_HP_image_transform 1 +#define GL_IMAGE_SCALE_X_HP 0x8155 +#define GL_IMAGE_SCALE_Y_HP 0x8156 +#define GL_IMAGE_TRANSLATE_X_HP 0x8157 +#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 +#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 +#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A +#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B +#define GL_IMAGE_MAG_FILTER_HP 0x815C +#define GL_IMAGE_MIN_FILTER_HP 0x815D +#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E +#define GL_CUBIC_HP 0x815F +#define GL_AVERAGE_HP 0x8160 +#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 +#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 +#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImageTransformParameteriHP (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glImageTransformParameterfHP (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glImageTransformParameterivHP (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum target, GLenum pname, GLfloat *params); +#endif +#endif /* GL_HP_image_transform */ + +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 +#endif /* GL_HP_occlusion_test */ + +#ifndef GL_HP_texture_lighting +#define GL_HP_texture_lighting 1 +#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 +#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 +#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 +#endif /* GL_HP_texture_lighting */ + +#ifndef GL_IBM_cull_vertex +#define GL_IBM_cull_vertex 1 +#define GL_CULL_VERTEX_IBM 103050 +#endif /* GL_IBM_cull_vertex */ + +#ifndef GL_IBM_multimode_draw_arrays +#define GL_IBM_multimode_draw_arrays 1 +typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, GLint modestride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, GLint modestride); +#endif +#endif /* GL_IBM_multimode_draw_arrays */ + +#ifndef GL_IBM_rasterpos_clip +#define GL_IBM_rasterpos_clip 1 +#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 +#endif /* GL_IBM_rasterpos_clip */ + +#ifndef GL_IBM_static_data +#define GL_IBM_static_data 1 +#define GL_ALL_STATIC_DATA_IBM 103060 +#define GL_STATIC_VERTEX_ARRAY_IBM 103061 +typedef void (APIENTRYP PFNGLFLUSHSTATICDATAIBMPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushStaticDataIBM (GLenum target); +#endif +#endif /* GL_IBM_static_data */ + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_IBM_texture_mirrored_repeat 1 +#define GL_MIRRORED_REPEAT_IBM 0x8370 +#endif /* GL_IBM_texture_mirrored_repeat */ + +#ifndef GL_IBM_vertex_array_lists +#define GL_IBM_vertex_array_lists 1 +#define GL_VERTEX_ARRAY_LIST_IBM 103070 +#define GL_NORMAL_ARRAY_LIST_IBM 103071 +#define GL_COLOR_ARRAY_LIST_IBM 103072 +#define GL_INDEX_ARRAY_LIST_IBM 103073 +#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 +#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 +#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 +#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 +#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 +#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 +#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 +#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 +#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 +#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 +#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 +#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 +typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint stride, const GLboolean **pointer, GLint ptrstride); +GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glIndexPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glNormalPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glTexCoordPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glVertexPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +#endif +#endif /* GL_IBM_vertex_array_lists */ + +#ifndef GL_INGR_blend_func_separate +#define GL_INGR_blend_func_separate 1 +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif +#endif /* GL_INGR_blend_func_separate */ + +#ifndef GL_INGR_color_clamp +#define GL_INGR_color_clamp 1 +#define GL_RED_MIN_CLAMP_INGR 0x8560 +#define GL_GREEN_MIN_CLAMP_INGR 0x8561 +#define GL_BLUE_MIN_CLAMP_INGR 0x8562 +#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 +#define GL_RED_MAX_CLAMP_INGR 0x8564 +#define GL_GREEN_MAX_CLAMP_INGR 0x8565 +#define GL_BLUE_MAX_CLAMP_INGR 0x8566 +#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 +#endif /* GL_INGR_color_clamp */ + +#ifndef GL_INGR_interlace_read +#define GL_INGR_interlace_read 1 +#define GL_INTERLACE_READ_INGR 0x8568 +#endif /* GL_INGR_interlace_read */ + +#ifndef GL_INTEL_fragment_shader_ordering +#define GL_INTEL_fragment_shader_ordering 1 +#endif /* GL_INTEL_fragment_shader_ordering */ + +#ifndef GL_INTEL_map_texture +#define GL_INTEL_map_texture 1 +#define GL_TEXTURE_MEMORY_LAYOUT_INTEL 0x83FF +#define GL_LAYOUT_DEFAULT_INTEL 0 +#define GL_LAYOUT_LINEAR_INTEL 1 +#define GL_LAYOUT_LINEAR_CPU_CACHED_INTEL 2 +typedef void (APIENTRYP PFNGLSYNCTEXTUREINTELPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLUNMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level); +typedef void *(APIENTRYP PFNGLMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level, GLbitfield access, GLint *stride, GLenum *layout); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSyncTextureINTEL (GLuint texture); +GLAPI void APIENTRY glUnmapTexture2DINTEL (GLuint texture, GLint level); +GLAPI void *APIENTRY glMapTexture2DINTEL (GLuint texture, GLint level, GLbitfield access, GLint *stride, GLenum *layout); +#endif +#endif /* GL_INTEL_map_texture */ + +#ifndef GL_INTEL_parallel_arrays +#define GL_INTEL_parallel_arrays 1 +#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 +#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 +#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 +#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 +#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 +typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const void **pointer); +typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexPointervINTEL (GLint size, GLenum type, const void **pointer); +GLAPI void APIENTRY glNormalPointervINTEL (GLenum type, const void **pointer); +GLAPI void APIENTRY glColorPointervINTEL (GLint size, GLenum type, const void **pointer); +GLAPI void APIENTRY glTexCoordPointervINTEL (GLint size, GLenum type, const void **pointer); +#endif +#endif /* GL_INTEL_parallel_arrays */ + +#ifndef GL_INTEL_performance_query +#define GL_INTEL_performance_query 1 +#define GL_PERFQUERY_SINGLE_CONTEXT_INTEL 0x00000000 +#define GL_PERFQUERY_GLOBAL_CONTEXT_INTEL 0x00000001 +#define GL_PERFQUERY_WAIT_INTEL 0x83FB +#define GL_PERFQUERY_FLUSH_INTEL 0x83FA +#define GL_PERFQUERY_DONOT_FLUSH_INTEL 0x83F9 +#define GL_PERFQUERY_COUNTER_EVENT_INTEL 0x94F0 +#define GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL 0x94F1 +#define GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL 0x94F2 +#define GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL 0x94F3 +#define GL_PERFQUERY_COUNTER_RAW_INTEL 0x94F4 +#define GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL 0x94F5 +#define GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL 0x94F8 +#define GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL 0x94F9 +#define GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL 0x94FA +#define GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL 0x94FB +#define GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL 0x94FC +#define GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL 0x94FD +#define GL_PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL 0x94FE +#define GL_PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL 0x94FF +#define GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL 0x9500 +typedef void (APIENTRYP PFNGLBEGINPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (APIENTRYP PFNGLCREATEPERFQUERYINTELPROC) (GLuint queryId, GLuint *queryHandle); +typedef void (APIENTRYP PFNGLDELETEPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (APIENTRYP PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (APIENTRYP PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint *queryId); +typedef void (APIENTRYP PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint *nextQueryId); +typedef void (APIENTRYP PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); +typedef void (APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten); +typedef void (APIENTRYP PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar *queryName, GLuint *queryId); +typedef void (APIENTRYP PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginPerfQueryINTEL (GLuint queryHandle); +GLAPI void APIENTRY glCreatePerfQueryINTEL (GLuint queryId, GLuint *queryHandle); +GLAPI void APIENTRY glDeletePerfQueryINTEL (GLuint queryHandle); +GLAPI void APIENTRY glEndPerfQueryINTEL (GLuint queryHandle); +GLAPI void APIENTRY glGetFirstPerfQueryIdINTEL (GLuint *queryId); +GLAPI void APIENTRY glGetNextPerfQueryIdINTEL (GLuint queryId, GLuint *nextQueryId); +GLAPI void APIENTRY glGetPerfCounterInfoINTEL (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); +GLAPI void APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten); +GLAPI void APIENTRY glGetPerfQueryIdByNameINTEL (GLchar *queryName, GLuint *queryId); +GLAPI void APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); +#endif +#endif /* GL_INTEL_performance_query */ + +#ifndef GL_MESAX_texture_stack +#define GL_MESAX_texture_stack 1 +#define GL_TEXTURE_1D_STACK_MESAX 0x8759 +#define GL_TEXTURE_2D_STACK_MESAX 0x875A +#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B +#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C +#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D +#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E +#endif /* GL_MESAX_texture_stack */ + +#ifndef GL_MESA_pack_invert +#define GL_MESA_pack_invert 1 +#define GL_PACK_INVERT_MESA 0x8758 +#endif /* GL_MESA_pack_invert */ + +#ifndef GL_MESA_resize_buffers +#define GL_MESA_resize_buffers 1 +typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glResizeBuffersMESA (void); +#endif +#endif /* GL_MESA_resize_buffers */ + +#ifndef GL_MESA_window_pos +#define GL_MESA_window_pos 1 +typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dMESA (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fMESA (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iMESA (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos2sMESA (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dMESA (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iMESA (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos3sMESA (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos4dMESA (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos4fMESA (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos4iMESA (GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos4sMESA (GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v); +#endif +#endif /* GL_MESA_window_pos */ + +#ifndef GL_MESA_ycbcr_texture +#define GL_MESA_ycbcr_texture 1 +#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB +#define GL_YCBCR_MESA 0x8757 +#endif /* GL_MESA_ycbcr_texture */ + +#ifndef GL_NVX_conditional_render +#define GL_NVX_conditional_render 1 +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVXPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginConditionalRenderNVX (GLuint id); +GLAPI void APIENTRY glEndConditionalRenderNVX (void); +#endif +#endif /* GL_NVX_conditional_render */ + +#ifndef GL_NVX_gpu_memory_info +#define GL_NVX_gpu_memory_info 1 +#define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047 +#define GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048 +#define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049 +#define GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX 0x904A +#define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B +#endif /* GL_NVX_gpu_memory_info */ + +#ifndef GL_NV_bindless_multi_draw_indirect +#define GL_NV_bindless_multi_draw_indirect 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectBindlessNV (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +GLAPI void APIENTRY glMultiDrawElementsIndirectBindlessNV (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +#endif +#endif /* GL_NV_bindless_multi_draw_indirect */ + +#ifndef GL_NV_bindless_texture +#define GL_NV_bindless_texture 1 +typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture); +typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint64 APIENTRY glGetTextureHandleNV (GLuint texture); +GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler); +GLAPI void APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle); +GLAPI void APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle); +GLAPI GLuint64 APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +GLAPI void APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access); +GLAPI void APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle); +GLAPI void APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value); +GLAPI void APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value); +GLAPI void APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +GLAPI GLboolean APIENTRY glIsTextureHandleResidentNV (GLuint64 handle); +GLAPI GLboolean APIENTRY glIsImageHandleResidentNV (GLuint64 handle); +#endif +#endif /* GL_NV_bindless_texture */ + +#ifndef GL_NV_blend_equation_advanced +#define GL_NV_blend_equation_advanced 1 +#define GL_BLEND_OVERLAP_NV 0x9281 +#define GL_BLEND_PREMULTIPLIED_SRC_NV 0x9280 +#define GL_BLUE_NV 0x1905 +#define GL_COLORBURN_NV 0x929A +#define GL_COLORDODGE_NV 0x9299 +#define GL_CONJOINT_NV 0x9284 +#define GL_CONTRAST_NV 0x92A1 +#define GL_DARKEN_NV 0x9297 +#define GL_DIFFERENCE_NV 0x929E +#define GL_DISJOINT_NV 0x9283 +#define GL_DST_ATOP_NV 0x928F +#define GL_DST_IN_NV 0x928B +#define GL_DST_NV 0x9287 +#define GL_DST_OUT_NV 0x928D +#define GL_DST_OVER_NV 0x9289 +#define GL_EXCLUSION_NV 0x92A0 +#define GL_GREEN_NV 0x1904 +#define GL_HARDLIGHT_NV 0x929B +#define GL_HARDMIX_NV 0x92A9 +#define GL_HSL_COLOR_NV 0x92AF +#define GL_HSL_HUE_NV 0x92AD +#define GL_HSL_LUMINOSITY_NV 0x92B0 +#define GL_HSL_SATURATION_NV 0x92AE +#define GL_INVERT_OVG_NV 0x92B4 +#define GL_INVERT_RGB_NV 0x92A3 +#define GL_LIGHTEN_NV 0x9298 +#define GL_LINEARBURN_NV 0x92A5 +#define GL_LINEARDODGE_NV 0x92A4 +#define GL_LINEARLIGHT_NV 0x92A7 +#define GL_MINUS_CLAMPED_NV 0x92B3 +#define GL_MINUS_NV 0x929F +#define GL_MULTIPLY_NV 0x9294 +#define GL_OVERLAY_NV 0x9296 +#define GL_PINLIGHT_NV 0x92A8 +#define GL_PLUS_CLAMPED_ALPHA_NV 0x92B2 +#define GL_PLUS_CLAMPED_NV 0x92B1 +#define GL_PLUS_DARKER_NV 0x9292 +#define GL_PLUS_NV 0x9291 +#define GL_RED_NV 0x1903 +#define GL_SCREEN_NV 0x9295 +#define GL_SOFTLIGHT_NV 0x929C +#define GL_SRC_ATOP_NV 0x928E +#define GL_SRC_IN_NV 0x928A +#define GL_SRC_NV 0x9286 +#define GL_SRC_OUT_NV 0x928C +#define GL_SRC_OVER_NV 0x9288 +#define GL_UNCORRELATED_NV 0x9282 +#define GL_VIVIDLIGHT_NV 0x92A6 +#define GL_XOR_NV 0x1506 +typedef void (APIENTRYP PFNGLBLENDPARAMETERINVPROC) (GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLBLENDBARRIERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendParameteriNV (GLenum pname, GLint value); +GLAPI void APIENTRY glBlendBarrierNV (void); +#endif +#endif /* GL_NV_blend_equation_advanced */ + +#ifndef GL_NV_blend_equation_advanced_coherent +#define GL_NV_blend_equation_advanced_coherent 1 +#define GL_BLEND_ADVANCED_COHERENT_NV 0x9285 +#endif /* GL_NV_blend_equation_advanced_coherent */ + +#ifndef GL_NV_blend_square +#define GL_NV_blend_square 1 +#endif /* GL_NV_blend_square */ + +#ifndef GL_NV_compute_program5 +#define GL_NV_compute_program5 1 +#define GL_COMPUTE_PROGRAM_NV 0x90FB +#define GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV 0x90FC +#endif /* GL_NV_compute_program5 */ + +#ifndef GL_NV_conditional_render +#define GL_NV_conditional_render 1 +#define GL_QUERY_WAIT_NV 0x8E13 +#define GL_QUERY_NO_WAIT_NV 0x8E14 +#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRenderNV (void); +#endif +#endif /* GL_NV_conditional_render */ + +#ifndef GL_NV_copy_depth_to_color +#define GL_NV_copy_depth_to_color 1 +#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E +#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F +#endif /* GL_NV_copy_depth_to_color */ + +#ifndef GL_NV_copy_image +#define GL_NV_copy_image 1 +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyImageSubDataNV (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif +#endif /* GL_NV_copy_image */ + +#ifndef GL_NV_deep_texture3D +#define GL_NV_deep_texture3D 1 +#define GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV 0x90D0 +#define GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV 0x90D1 +#endif /* GL_NV_deep_texture3D */ + +#ifndef GL_NV_depth_buffer_float +#define GL_NV_depth_buffer_float 1 +#define GL_DEPTH_COMPONENT32F_NV 0x8DAB +#define GL_DEPTH32F_STENCIL8_NV 0x8DAC +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD +#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF +typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); +typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glClearDepthdNV (GLdouble depth); +GLAPI void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax); +#endif +#endif /* GL_NV_depth_buffer_float */ + +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 +#define GL_DEPTH_CLAMP_NV 0x864F +#endif /* GL_NV_depth_clamp */ + +#ifndef GL_NV_draw_texture +#define GL_NV_draw_texture 1 +typedef void (APIENTRYP PFNGLDRAWTEXTURENVPROC) (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawTextureNV (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +#endif +#endif /* GL_NV_draw_texture */ + +#ifndef GL_NV_evaluators +#define GL_NV_evaluators 1 +#define GL_EVAL_2D_NV 0x86C0 +#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 +#define GL_MAP_TESSELLATION_NV 0x86C2 +#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 +#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 +#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 +#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 +#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 +#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 +#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 +#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA +#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB +#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC +#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD +#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE +#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF +#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 +#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 +#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 +#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 +#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 +#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 +#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 +#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 +typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void *points); +typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void *points); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void *points); +GLAPI void APIENTRY glMapParameterivNV (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMapParameterfvNV (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void *points); +GLAPI void APIENTRY glGetMapParameterivNV (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapParameterfvNV (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum target, GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glEvalMapsNV (GLenum target, GLenum mode); +#endif +#endif /* GL_NV_evaluators */ + +#ifndef GL_NV_explicit_multisample +#define GL_NV_explicit_multisample 1 +#define GL_SAMPLE_POSITION_NV 0x8E50 +#define GL_SAMPLE_MASK_NV 0x8E51 +#define GL_SAMPLE_MASK_VALUE_NV 0x8E52 +#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 +#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 +#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 +#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 +#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 +#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 +#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); +typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetMultisamplefvNV (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint index, GLbitfield mask); +GLAPI void APIENTRY glTexRenderbufferNV (GLenum target, GLuint renderbuffer); +#endif +#endif /* GL_NV_explicit_multisample */ + +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); +GLAPI GLboolean APIENTRY glIsFenceNV (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceNV (GLuint fence); +GLAPI void APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); +GLAPI void APIENTRY glFinishFenceNV (GLuint fence); +GLAPI void APIENTRY glSetFenceNV (GLuint fence, GLenum condition); +#endif +#endif /* GL_NV_fence */ + +#ifndef GL_NV_float_buffer +#define GL_NV_float_buffer 1 +#define GL_FLOAT_R_NV 0x8880 +#define GL_FLOAT_RG_NV 0x8881 +#define GL_FLOAT_RGB_NV 0x8882 +#define GL_FLOAT_RGBA_NV 0x8883 +#define GL_FLOAT_R16_NV 0x8884 +#define GL_FLOAT_R32_NV 0x8885 +#define GL_FLOAT_RG16_NV 0x8886 +#define GL_FLOAT_RG32_NV 0x8887 +#define GL_FLOAT_RGB16_NV 0x8888 +#define GL_FLOAT_RGB32_NV 0x8889 +#define GL_FLOAT_RGBA16_NV 0x888A +#define GL_FLOAT_RGBA32_NV 0x888B +#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C +#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D +#define GL_FLOAT_RGBA_MODE_NV 0x888E +#endif /* GL_NV_float_buffer */ + +#ifndef GL_NV_fog_distance +#define GL_NV_fog_distance 1 +#define GL_FOG_DISTANCE_MODE_NV 0x855A +#define GL_EYE_RADIAL_NV 0x855B +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C +#endif /* GL_NV_fog_distance */ + +#ifndef GL_NV_fragment_program +#define GL_NV_fragment_program 1 +#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 +#define GL_FRAGMENT_PROGRAM_NV 0x8870 +#define GL_MAX_TEXTURE_COORDS_NV 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 +#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 +#define GL_PROGRAM_ERROR_STRING_NV 0x8874 +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif +#endif /* GL_NV_fragment_program */ + +#ifndef GL_NV_fragment_program2 +#define GL_NV_fragment_program2 1 +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 +#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 +#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 +#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 +#endif /* GL_NV_fragment_program2 */ + +#ifndef GL_NV_fragment_program4 +#define GL_NV_fragment_program4 1 +#endif /* GL_NV_fragment_program4 */ + +#ifndef GL_NV_fragment_program_option +#define GL_NV_fragment_program_option 1 +#endif /* GL_NV_fragment_program_option */ + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_NV_framebuffer_multisample_coverage 1 +#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB +#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 +#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 +#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_NV_framebuffer_multisample_coverage */ + +#ifndef GL_NV_geometry_program4 +#define GL_NV_geometry_program4 1 +#define GL_GEOMETRY_PROGRAM_NV 0x8C26 +#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 +#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 +typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramVertexLimitNV (GLenum target, GLint limit); +GLAPI void APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif +#endif /* GL_NV_geometry_program4 */ + +#ifndef GL_NV_geometry_shader4 +#define GL_NV_geometry_shader4 1 +#endif /* GL_NV_geometry_shader4 */ + +#ifndef GL_NV_gpu_program4 +#define GL_NV_gpu_program4 1 +#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 +#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 +#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 +#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 +#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 +#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 +#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum target, GLuint index, GLuint *params); +#endif +#endif /* GL_NV_gpu_program4 */ + +#ifndef GL_NV_gpu_program5 +#define GL_NV_gpu_program5 1 +#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C +#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F +#define GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV 0x8F44 +#define GL_MAX_PROGRAM_SUBROUTINE_NUM_NV 0x8F45 +typedef void (APIENTRYP PFNGLPROGRAMSUBROUTINEPARAMETERSUIVNVPROC) (GLenum target, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSUBROUTINEPARAMETERUIVNVPROC) (GLenum target, GLuint index, GLuint *param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramSubroutineParametersuivNV (GLenum target, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramSubroutineParameteruivNV (GLenum target, GLuint index, GLuint *param); +#endif +#endif /* GL_NV_gpu_program5 */ + +#ifndef GL_NV_gpu_program5_mem_extended +#define GL_NV_gpu_program5_mem_extended 1 +#endif /* GL_NV_gpu_program5_mem_extended */ + +#ifndef GL_NV_gpu_shader5 +#define GL_NV_gpu_shader5 1 +#endif /* GL_NV_gpu_shader5 */ + +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 +typedef unsigned short GLhalfNV; +#define GL_HALF_FLOAT_NV 0x140B +typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); +typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); +typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertex2hNV (GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex3hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex4hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glNormal3hNV (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor4hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV s); +GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum target, GLhalfNV s); +GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum target, GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glFogCoordhNV (GLhalfNV fog); +GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *fog); +GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV weight); +GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *weight); +GLAPI void APIENTRY glVertexAttrib1hNV (GLuint index, GLhalfNV x); +GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib2hNV (GLuint index, GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib3hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib4hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +#endif +#endif /* GL_NV_half_float */ + +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent 1 +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 +#endif /* GL_NV_light_max_exponent */ + +#ifndef GL_NV_multisample_coverage +#define GL_NV_multisample_coverage 1 +#define GL_COLOR_SAMPLES_NV 0x8E20 +#endif /* GL_NV_multisample_coverage */ + +#ifndef GL_NV_multisample_filter_hint +#define GL_NV_multisample_filter_hint 1 +#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 +#endif /* GL_NV_multisample_filter_hint */ + +#ifndef GL_NV_occlusion_query +#define GL_NV_occlusion_query 1 +#define GL_PIXEL_COUNTER_BITS_NV 0x8864 +#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 +#define GL_PIXEL_COUNT_NV 0x8866 +#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 +typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glEndOcclusionQueryNV (void); +GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint id, GLenum pname, GLuint *params); +#endif +#endif /* GL_NV_occlusion_query */ + +#ifndef GL_NV_packed_depth_stencil +#define GL_NV_packed_depth_stencil 1 +#define GL_DEPTH_STENCIL_NV 0x84F9 +#define GL_UNSIGNED_INT_24_8_NV 0x84FA +#endif /* GL_NV_packed_depth_stencil */ + +#ifndef GL_NV_parameter_buffer_object +#define GL_NV_parameter_buffer_object 1 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 +#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 +#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 +#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); +#endif +#endif /* GL_NV_parameter_buffer_object */ + +#ifndef GL_NV_parameter_buffer_object2 +#define GL_NV_parameter_buffer_object2 1 +#endif /* GL_NV_parameter_buffer_object2 */ + +#ifndef GL_NV_path_rendering +#define GL_NV_path_rendering 1 +#define GL_PATH_FORMAT_SVG_NV 0x9070 +#define GL_PATH_FORMAT_PS_NV 0x9071 +#define GL_STANDARD_FONT_NAME_NV 0x9072 +#define GL_SYSTEM_FONT_NAME_NV 0x9073 +#define GL_FILE_NAME_NV 0x9074 +#define GL_PATH_STROKE_WIDTH_NV 0x9075 +#define GL_PATH_END_CAPS_NV 0x9076 +#define GL_PATH_INITIAL_END_CAP_NV 0x9077 +#define GL_PATH_TERMINAL_END_CAP_NV 0x9078 +#define GL_PATH_JOIN_STYLE_NV 0x9079 +#define GL_PATH_MITER_LIMIT_NV 0x907A +#define GL_PATH_DASH_CAPS_NV 0x907B +#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C +#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D +#define GL_PATH_DASH_OFFSET_NV 0x907E +#define GL_PATH_CLIENT_LENGTH_NV 0x907F +#define GL_PATH_FILL_MODE_NV 0x9080 +#define GL_PATH_FILL_MASK_NV 0x9081 +#define GL_PATH_FILL_COVER_MODE_NV 0x9082 +#define GL_PATH_STROKE_COVER_MODE_NV 0x9083 +#define GL_PATH_STROKE_MASK_NV 0x9084 +#define GL_COUNT_UP_NV 0x9088 +#define GL_COUNT_DOWN_NV 0x9089 +#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A +#define GL_CONVEX_HULL_NV 0x908B +#define GL_BOUNDING_BOX_NV 0x908D +#define GL_TRANSLATE_X_NV 0x908E +#define GL_TRANSLATE_Y_NV 0x908F +#define GL_TRANSLATE_2D_NV 0x9090 +#define GL_TRANSLATE_3D_NV 0x9091 +#define GL_AFFINE_2D_NV 0x9092 +#define GL_AFFINE_3D_NV 0x9094 +#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096 +#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098 +#define GL_UTF8_NV 0x909A +#define GL_UTF16_NV 0x909B +#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C +#define GL_PATH_COMMAND_COUNT_NV 0x909D +#define GL_PATH_COORD_COUNT_NV 0x909E +#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F +#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0 +#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 +#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 +#define GL_SQUARE_NV 0x90A3 +#define GL_ROUND_NV 0x90A4 +#define GL_TRIANGULAR_NV 0x90A5 +#define GL_BEVEL_NV 0x90A6 +#define GL_MITER_REVERT_NV 0x90A7 +#define GL_MITER_TRUNCATE_NV 0x90A8 +#define GL_SKIP_MISSING_GLYPH_NV 0x90A9 +#define GL_USE_MISSING_GLYPH_NV 0x90AA +#define GL_PATH_ERROR_POSITION_NV 0x90AB +#define GL_PATH_FOG_GEN_MODE_NV 0x90AC +#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD +#define GL_ADJACENT_PAIRS_NV 0x90AE +#define GL_FIRST_TO_REST_NV 0x90AF +#define GL_PATH_GEN_MODE_NV 0x90B0 +#define GL_PATH_GEN_COEFF_NV 0x90B1 +#define GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2 +#define GL_PATH_GEN_COMPONENTS_NV 0x90B3 +#define GL_PATH_STENCIL_FUNC_NV 0x90B7 +#define GL_PATH_STENCIL_REF_NV 0x90B8 +#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 +#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD +#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE +#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF +#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 +#define GL_MOVE_TO_RESETS_NV 0x90B5 +#define GL_MOVE_TO_CONTINUES_NV 0x90B6 +#define GL_CLOSE_PATH_NV 0x00 +#define GL_MOVE_TO_NV 0x02 +#define GL_RELATIVE_MOVE_TO_NV 0x03 +#define GL_LINE_TO_NV 0x04 +#define GL_RELATIVE_LINE_TO_NV 0x05 +#define GL_HORIZONTAL_LINE_TO_NV 0x06 +#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 +#define GL_VERTICAL_LINE_TO_NV 0x08 +#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 +#define GL_QUADRATIC_CURVE_TO_NV 0x0A +#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B +#define GL_CUBIC_CURVE_TO_NV 0x0C +#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D +#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E +#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F +#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 +#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 +#define GL_SMALL_CCW_ARC_TO_NV 0x12 +#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 +#define GL_SMALL_CW_ARC_TO_NV 0x14 +#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 +#define GL_LARGE_CCW_ARC_TO_NV 0x16 +#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 +#define GL_LARGE_CW_ARC_TO_NV 0x18 +#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 +#define GL_RESTART_PATH_NV 0xF0 +#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2 +#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4 +#define GL_RECT_NV 0xF6 +#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 +#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA +#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC +#define GL_ARC_TO_NV 0xFE +#define GL_RELATIVE_ARC_TO_NV 0xFF +#define GL_BOLD_BIT_NV 0x01 +#define GL_ITALIC_BIT_NV 0x02 +#define GL_GLYPH_WIDTH_BIT_NV 0x01 +#define GL_GLYPH_HEIGHT_BIT_NV 0x02 +#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 +#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 +#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 +#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 +#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 +#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 +#define GL_GLYPH_HAS_KERNING_BIT_NV 0x100 +#define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000 +#define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000 +#define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000 +#define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000 +#define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000 +#define GL_FONT_ASCENDER_BIT_NV 0x00200000 +#define GL_FONT_DESCENDER_BIT_NV 0x00400000 +#define GL_FONT_HEIGHT_BIT_NV 0x00800000 +#define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000 +#define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000 +#define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000 +#define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000 +#define GL_FONT_HAS_KERNING_BIT_NV 0x10000000 +#define GL_PRIMARY_COLOR_NV 0x852C +#define GL_SECONDARY_COLOR_NV 0x852D +typedef GLuint (APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISPATHNVPROC) (GLuint path); +typedef void (APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const void *pathString); +typedef void (APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +typedef void (APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath); +typedef void (APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +typedef void (APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value); +typedef void (APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value); +typedef void (APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value); +typedef void (APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +typedef void (APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units); +typedef void (APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func); +typedef void (APIENTRYP PFNGLPATHCOLORGENNVPROC) (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLPATHTEXGENNVPROC) (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLPATHFOGGENNVPROC) (GLenum genMode); +typedef void (APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value); +typedef void (APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands); +typedef void (APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords); +typedef void (APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray); +typedef void (APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +typedef void (APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +typedef void (APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +typedef void (APIENTRYP PFNGLGETPATHCOLORGENIVNVPROC) (GLenum color, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHCOLORGENFVNVPROC) (GLenum color, GLenum pname, GLfloat *value); +typedef void (APIENTRYP PFNGLGETPATHTEXGENIVNVPROC) (GLenum texCoordSet, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHTEXGENFVNVPROC) (GLenum texCoordSet, GLenum pname, GLfloat *value); +typedef GLboolean (APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); +typedef GLboolean (APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); +typedef GLfloat (APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); +typedef GLboolean (APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenPathsNV (GLsizei range); +GLAPI void APIENTRY glDeletePathsNV (GLuint path, GLsizei range); +GLAPI GLboolean APIENTRY glIsPathNV (GLuint path); +GLAPI void APIENTRY glPathCommandsNV (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathCoordsNV (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathSubCommandsNV (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathSubCoordsNV (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathStringNV (GLuint path, GLenum format, GLsizei length, const void *pathString); +GLAPI void APIENTRY glPathGlyphsNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glPathGlyphRangeNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glWeightPathsNV (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +GLAPI void APIENTRY glCopyPathNV (GLuint resultPath, GLuint srcPath); +GLAPI void APIENTRY glInterpolatePathsNV (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +GLAPI void APIENTRY glTransformPathNV (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glPathParameterivNV (GLuint path, GLenum pname, const GLint *value); +GLAPI void APIENTRY glPathParameteriNV (GLuint path, GLenum pname, GLint value); +GLAPI void APIENTRY glPathParameterfvNV (GLuint path, GLenum pname, const GLfloat *value); +GLAPI void APIENTRY glPathParameterfNV (GLuint path, GLenum pname, GLfloat value); +GLAPI void APIENTRY glPathDashArrayNV (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +GLAPI void APIENTRY glPathStencilFuncNV (GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glPathStencilDepthOffsetNV (GLfloat factor, GLfloat units); +GLAPI void APIENTRY glStencilFillPathNV (GLuint path, GLenum fillMode, GLuint mask); +GLAPI void APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint mask); +GLAPI void APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glPathCoverDepthFuncNV (GLenum func); +GLAPI void APIENTRY glPathColorGenNV (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); +GLAPI void APIENTRY glPathTexGenNV (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); +GLAPI void APIENTRY glPathFogGenNV (GLenum genMode); +GLAPI void APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode); +GLAPI void APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode); +GLAPI void APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glGetPathParameterivNV (GLuint path, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathParameterfvNV (GLuint path, GLenum pname, GLfloat *value); +GLAPI void APIENTRY glGetPathCommandsNV (GLuint path, GLubyte *commands); +GLAPI void APIENTRY glGetPathCoordsNV (GLuint path, GLfloat *coords); +GLAPI void APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray); +GLAPI void APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +GLAPI void APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +GLAPI void APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +GLAPI void APIENTRY glGetPathColorGenivNV (GLenum color, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathColorGenfvNV (GLenum color, GLenum pname, GLfloat *value); +GLAPI void APIENTRY glGetPathTexGenivNV (GLenum texCoordSet, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathTexGenfvNV (GLenum texCoordSet, GLenum pname, GLfloat *value); +GLAPI GLboolean APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y); +GLAPI GLboolean APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y); +GLAPI GLfloat APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments); +GLAPI GLboolean APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +#endif +#endif /* GL_NV_path_rendering */ + +#ifndef GL_NV_pixel_data_range +#define GL_NV_pixel_data_range 1 +#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 +#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 +#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A +#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B +#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C +#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D +typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, const void *pointer); +typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, const void *pointer); +GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum target); +#endif +#endif /* GL_NV_pixel_data_range */ + +#ifndef GL_NV_point_sprite +#define GL_NV_point_sprite 1 +#define GL_POINT_SPRITE_NV 0x8861 +#define GL_COORD_REPLACE_NV 0x8862 +#define GL_POINT_SPRITE_R_MODE_NV 0x8863 +typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameterivNV (GLenum pname, const GLint *params); +#endif +#endif /* GL_NV_point_sprite */ + +#ifndef GL_NV_present_video +#define GL_NV_present_video 1 +#define GL_FRAME_NV 0x8E26 +#define GL_FIELDS_NV 0x8E27 +#define GL_CURRENT_TIME_NV 0x8E28 +#define GL_NUM_FILL_STREAMS_NV 0x8E29 +#define GL_PRESENT_TIME_NV 0x8E2A +#define GL_PRESENT_DURATION_NV 0x8E2B +typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPresentFrameKeyedNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +GLAPI void APIENTRY glPresentFrameDualFillNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +GLAPI void APIENTRY glGetVideoivNV (GLuint video_slot, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideouivNV (GLuint video_slot, GLenum pname, GLuint *params); +GLAPI void APIENTRY glGetVideoi64vNV (GLuint video_slot, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVideoui64vNV (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#endif +#endif /* GL_NV_present_video */ + +#ifndef GL_NV_primitive_restart +#define GL_NV_primitive_restart 1 +#define GL_PRIMITIVE_RESTART_NV 0x8558 +#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveRestartNV (void); +GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index); +#endif +#endif /* GL_NV_primitive_restart */ + +#ifndef GL_NV_register_combiners +#define GL_NV_register_combiners 1 +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852A +#define GL_CONSTANT_COLOR1_NV 0x852B +#define GL_SPARE0_NV 0x852E +#define GL_SPARE1_NV 0x852F +#define GL_DISCARD_NV 0x8530 +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853A +#define GL_HALF_BIAS_NEGATE_NV 0x853B +#define GL_SIGNED_IDENTITY_NV 0x853C +#define GL_SIGNED_NEGATE_NV 0x853D +#define GL_SCALE_BY_TWO_NV 0x853E +#define GL_SCALE_BY_FOUR_NV 0x853F +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854A +#define GL_COMBINER_CD_OUTPUT_NV 0x854B +#define GL_COMBINER_SUM_OUTPUT_NV 0x854C +#define GL_MAX_GENERAL_COMBINERS_NV 0x854D +#define GL_NUM_GENERAL_COMBINERS_NV 0x854E +#define GL_COLOR_SUM_CLAMP_NV 0x854F +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerParameterfvNV (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glCombinerParameterfNV (GLenum pname, GLfloat param); +GLAPI void APIENTRY glCombinerParameterivNV (GLenum pname, const GLint *params); +GLAPI void APIENTRY glCombinerParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glCombinerInputNV (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glCombinerOutputNV (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +GLAPI void APIENTRY glFinalCombinerInputNV (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum stage, GLenum portion, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum variable, GLenum pname, GLint *params); +#endif +#endif /* GL_NV_register_combiners */ + +#ifndef GL_NV_register_combiners2 +#define GL_NV_register_combiners2 1 +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 +typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, GLfloat *params); +#endif +#endif /* GL_NV_register_combiners2 */ + +#ifndef GL_NV_shader_atomic_counters +#define GL_NV_shader_atomic_counters 1 +#endif /* GL_NV_shader_atomic_counters */ + +#ifndef GL_NV_shader_atomic_float +#define GL_NV_shader_atomic_float 1 +#endif /* GL_NV_shader_atomic_float */ + +#ifndef GL_NV_shader_buffer_load +#define GL_NV_shader_buffer_load 1 +#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D +#define GL_GPU_ADDRESS_NV 0x8F34 +#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 +typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access); +typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); +typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer); +typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result); +typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access); +GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target); +GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target); +GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access); +GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer); +GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer); +GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result); +GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value); +GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value); +GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif +#endif /* GL_NV_shader_buffer_load */ + +#ifndef GL_NV_shader_buffer_store +#define GL_NV_shader_buffer_store 1 +#define GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010 +#endif /* GL_NV_shader_buffer_store */ + +#ifndef GL_NV_shader_storage_buffer_object +#define GL_NV_shader_storage_buffer_object 1 +#endif /* GL_NV_shader_storage_buffer_object */ + +#ifndef GL_NV_shader_thread_group +#define GL_NV_shader_thread_group 1 +#define GL_WARP_SIZE_NV 0x9339 +#define GL_WARPS_PER_SM_NV 0x933A +#define GL_SM_COUNT_NV 0x933B +#endif /* GL_NV_shader_thread_group */ + +#ifndef GL_NV_shader_thread_shuffle +#define GL_NV_shader_thread_shuffle 1 +#endif /* GL_NV_shader_thread_shuffle */ + +#ifndef GL_NV_tessellation_program5 +#define GL_NV_tessellation_program5 1 +#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 +#define GL_TESS_CONTROL_PROGRAM_NV 0x891E +#define GL_TESS_EVALUATION_PROGRAM_NV 0x891F +#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74 +#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75 +#endif /* GL_NV_tessellation_program5 */ + +#ifndef GL_NV_texgen_emboss +#define GL_NV_texgen_emboss 1 +#define GL_EMBOSS_LIGHT_NV 0x855D +#define GL_EMBOSS_CONSTANT_NV 0x855E +#define GL_EMBOSS_MAP_NV 0x855F +#endif /* GL_NV_texgen_emboss */ + +#ifndef GL_NV_texgen_reflection +#define GL_NV_texgen_reflection 1 +#define GL_NORMAL_MAP_NV 0x8511 +#define GL_REFLECTION_MAP_NV 0x8512 +#endif /* GL_NV_texgen_reflection */ + +#ifndef GL_NV_texture_barrier +#define GL_NV_texture_barrier 1 +typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureBarrierNV (void); +#endif +#endif /* GL_NV_texture_barrier */ + +#ifndef GL_NV_texture_compression_vtc +#define GL_NV_texture_compression_vtc 1 +#endif /* GL_NV_texture_compression_vtc */ + +#ifndef GL_NV_texture_env_combine4 +#define GL_NV_texture_env_combine4 1 +#define GL_COMBINE4_NV 0x8503 +#define GL_SOURCE3_RGB_NV 0x8583 +#define GL_SOURCE3_ALPHA_NV 0x858B +#define GL_OPERAND3_RGB_NV 0x8593 +#define GL_OPERAND3_ALPHA_NV 0x859B +#endif /* GL_NV_texture_env_combine4 */ + +#ifndef GL_NV_texture_expand_normal +#define GL_NV_texture_expand_normal 1 +#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F +#endif /* GL_NV_texture_expand_normal */ + +#ifndef GL_NV_texture_multisample +#define GL_NV_texture_multisample 1 +#define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045 +#define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046 +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +#endif +#endif /* GL_NV_texture_multisample */ + +#ifndef GL_NV_texture_rectangle +#define GL_NV_texture_rectangle 1 +#define GL_TEXTURE_RECTANGLE_NV 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 +#endif /* GL_NV_texture_rectangle */ + +#ifndef GL_NV_texture_shader +#define GL_NV_texture_shader 1 +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_SHADER_CONSISTENT_NV 0x86DD +#define GL_TEXTURE_SHADER_NV 0x86DE +#define GL_SHADER_OPERATION_NV 0x86DF +#define GL_CULL_MODES_NV 0x86E0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 +#define GL_OFFSET_TEXTURE_2D_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_2D_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_2D_BIAS_NV 0x86E3 +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 +#define GL_CONST_EYE_NV 0x86E5 +#define GL_PASS_THROUGH_NV 0x86E6 +#define GL_CULL_FRAGMENT_NV 0x86E7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA +#define GL_DOT_PRODUCT_NV 0x86EC +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D +#define GL_HI_SCALE_NV 0x870E +#define GL_LO_SCALE_NV 0x870F +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871A +#define GL_TEXTURE_HI_SIZE_NV 0x871B +#define GL_TEXTURE_LO_SIZE_NV 0x871C +#define GL_TEXTURE_DS_SIZE_NV 0x871D +#define GL_TEXTURE_DT_SIZE_NV 0x871E +#define GL_TEXTURE_MAG_SIZE_NV 0x871F +#endif /* GL_NV_texture_shader */ + +#ifndef GL_NV_texture_shader2 +#define GL_NV_texture_shader2 1 +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF +#endif /* GL_NV_texture_shader2 */ + +#ifndef GL_NV_texture_shader3 +#define GL_NV_texture_shader3 1 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 +#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 +#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 +#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 +#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 +#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A +#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B +#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C +#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D +#define GL_HILO8_NV 0x885E +#define GL_SIGNED_HILO8_NV 0x885F +#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 +#endif /* GL_NV_texture_shader3 */ + +#ifndef GL_NV_transform_feedback +#define GL_NV_transform_feedback 1 +#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 +#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 +#define GL_TEXTURE_COORD_NV 0x8C79 +#define GL_CLIP_DISTANCE_NV 0x8C7A +#define GL_VERTEX_ID_NV 0x8C7B +#define GL_PRIMITIVE_ID_NV 0x8C7C +#define GL_GENERIC_ATTRIB_NV 0x8C7D +#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 +#define GL_ACTIVE_VARYINGS_NV 0x8C81 +#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 +#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 +#define GL_PRIMITIVES_GENERATED_NV 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 +#define GL_RASTERIZER_DISCARD_NV 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B +#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C +#define GL_SEPARATE_ATTRIBS_NV 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F +#define GL_LAYER_NV 0x8DAA +#define GL_NEXT_BUFFER_NV -2 +#define GL_SKIP_COMPONENTS4_NV -3 +#define GL_SKIP_COMPONENTS3_NV -4 +#define GL_SKIP_COMPONENTS2_NV -5 +#define GL_SKIP_COMPONENTS1_NV -6 +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKSTREAMATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackNV (void); +GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLuint count, const GLint *attribs, GLenum bufferMode); +GLAPI void APIENTRY glBindBufferRangeNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseNV (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +GLAPI void APIENTRY glActiveVaryingNV (GLuint program, const GLchar *name); +GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetActiveVaryingNV (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint program, GLuint index, GLint *location); +GLAPI void APIENTRY glTransformFeedbackStreamAttribsNV (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#endif +#endif /* GL_NV_transform_feedback */ + +#ifndef GL_NV_transform_feedback2 +#define GL_NV_transform_feedback2 1 +#define GL_TRANSFORM_FEEDBACK_NV 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindTransformFeedbackNV (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacksNV (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedbackNV (void); +GLAPI void APIENTRY glResumeTransformFeedbackNV (void); +GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum mode, GLuint id); +#endif +#endif /* GL_NV_transform_feedback2 */ + +#ifndef GL_NV_vdpau_interop +#define GL_NV_vdpau_interop 1 +typedef GLintptr GLvdpauSurfaceNV; +#define GL_SURFACE_STATE_NV 0x86EB +#define GL_SURFACE_REGISTERED_NV 0x86FD +#define GL_SURFACE_MAPPED_NV 0x8700 +#define GL_WRITE_DISCARD_NV 0x88BE +typedef void (APIENTRYP PFNGLVDPAUINITNVPROC) (const void *vdpDevice, const void *getProcAddress); +typedef void (APIENTRYP PFNGLVDPAUFININVPROC) (void); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef GLboolean (APIENTRYP PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +typedef void (APIENTRYP PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access); +typedef void (APIENTRYP PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVDPAUInitNV (const void *vdpDevice, const void *getProcAddress); +GLAPI void APIENTRY glVDPAUFiniNV (void); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterOutputSurfaceNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI GLboolean APIENTRY glVDPAUIsSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUUnregisterSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUGetSurfaceivNV (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +GLAPI void APIENTRY glVDPAUSurfaceAccessNV (GLvdpauSurfaceNV surface, GLenum access); +GLAPI void APIENTRY glVDPAUMapSurfacesNV (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +GLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#endif +#endif /* GL_NV_vdpau_interop */ + +#ifndef GL_NV_vertex_array_range +#define GL_NV_vertex_array_range 1 +#define GL_VERTEX_ARRAY_RANGE_NV 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E +#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); +GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei length, const void *pointer); +#endif +#endif /* GL_NV_vertex_array_range */ + +#ifndef GL_NV_vertex_array_range2 +#define GL_NV_vertex_array_range2 1 +#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 +#endif /* GL_NV_vertex_array_range2 */ + +#ifndef GL_NV_vertex_attrib_integer_64bit +#define GL_NV_vertex_attrib_integer_64bit 1 +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1i64NV (GLuint index, GLint64EXT x); +GLAPI void APIENTRY glVertexAttribL2i64NV (GLuint index, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glVertexAttribL3i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glVertexAttribL4i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glVertexAttribL1i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL1ui64NV (GLuint index, GLuint64EXT x); +GLAPI void APIENTRY glVertexAttribL2ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glVertexAttribL3ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glVertexAttribL4ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glVertexAttribL1ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glGetVertexAttribLi64vNV (GLuint index, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVertexAttribLui64vNV (GLuint index, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glVertexAttribLFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +#endif +#endif /* GL_NV_vertex_attrib_integer_64bit */ + +#ifndef GL_NV_vertex_buffer_unified_memory +#define GL_NV_vertex_buffer_unified_memory 1 +#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E +#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F +#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 +#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 +#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 +#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 +#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 +#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 +#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 +#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 +#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 +#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 +#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A +#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B +#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C +#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D +#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E +#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F +#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 +#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 +#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 +#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 +#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 +#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 +#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 +typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride); +GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result); +#endif +#endif /* GL_NV_vertex_buffer_unified_memory */ + +#ifndef GL_NV_vertex_program +#define GL_NV_vertex_program 1 +#define GL_VERTEX_PROGRAM_NV 0x8620 +#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 +#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 +#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 +#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 +#define GL_CURRENT_ATTRIB_NV 0x8626 +#define GL_PROGRAM_LENGTH_NV 0x8627 +#define GL_PROGRAM_STRING_NV 0x8628 +#define GL_MODELVIEW_PROJECTION_NV 0x8629 +#define GL_IDENTITY_NV 0x862A +#define GL_INVERSE_NV 0x862B +#define GL_TRANSPOSE_NV 0x862C +#define GL_INVERSE_TRANSPOSE_NV 0x862D +#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E +#define GL_MAX_TRACK_MATRICES_NV 0x862F +#define GL_MATRIX0_NV 0x8630 +#define GL_MATRIX1_NV 0x8631 +#define GL_MATRIX2_NV 0x8632 +#define GL_MATRIX3_NV 0x8633 +#define GL_MATRIX4_NV 0x8634 +#define GL_MATRIX5_NV 0x8635 +#define GL_MATRIX6_NV 0x8636 +#define GL_MATRIX7_NV 0x8637 +#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 +#define GL_CURRENT_MATRIX_NV 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 +#define GL_PROGRAM_PARAMETER_NV 0x8644 +#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 +#define GL_PROGRAM_TARGET_NV 0x8646 +#define GL_PROGRAM_RESIDENT_NV 0x8647 +#define GL_TRACK_MATRIX_NV 0x8648 +#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 +#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A +#define GL_PROGRAM_ERROR_POSITION_NV 0x864B +#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 +#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 +#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 +#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 +#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 +#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 +#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 +#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 +#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 +#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 +#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A +#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B +#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C +#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D +#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E +#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F +#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 +#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 +#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 +#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 +#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 +#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 +#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 +#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 +#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 +#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 +#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A +#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B +#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C +#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D +#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E +#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F +#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 +#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 +#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 +#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 +#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 +#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 +#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 +#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 +#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 +#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 +#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A +#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B +#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C +#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D +#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E +#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F +typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); +typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); +typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, void **pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei n, const GLuint *programs, GLboolean *residences); +GLAPI void APIENTRY glBindProgramNV (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glExecuteProgramNV (GLenum target, GLuint id, const GLfloat *params); +GLAPI void APIENTRY glGenProgramsNV (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum target, GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetProgramivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringNV (GLuint id, GLenum pname, GLubyte *program); +GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum target, GLuint address, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivNV (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint index, GLenum pname, void **pointer); +GLAPI GLboolean APIENTRY glIsProgramNV (GLuint id); +GLAPI void APIENTRY glLoadProgramNV (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +GLAPI void APIENTRY glProgramParameter4dNV (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramParameter4dvNV (GLenum target, GLuint index, const GLdouble *v); +GLAPI void APIENTRY glProgramParameter4fNV (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramParameter4fvNV (GLenum target, GLuint index, const GLfloat *v); +GLAPI void APIENTRY glProgramParameters4dvNV (GLenum target, GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glProgramParameters4fvNV (GLenum target, GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glTrackMatrixNV (GLenum target, GLuint address, GLenum matrix, GLenum transform); +GLAPI void APIENTRY glVertexAttribPointerNV (GLuint index, GLint fsize, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glVertexAttrib1dNV (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fNV (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sNV (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dNV (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fNV (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sNV (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sNV (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4sNV (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs1svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs2svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs3svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs4svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint index, GLsizei count, const GLubyte *v); +#endif +#endif /* GL_NV_vertex_program */ + +#ifndef GL_NV_vertex_program1_1 +#define GL_NV_vertex_program1_1 1 +#endif /* GL_NV_vertex_program1_1 */ + +#ifndef GL_NV_vertex_program2 +#define GL_NV_vertex_program2 1 +#endif /* GL_NV_vertex_program2 */ + +#ifndef GL_NV_vertex_program2_option +#define GL_NV_vertex_program2_option 1 +#endif /* GL_NV_vertex_program2_option */ + +#ifndef GL_NV_vertex_program3 +#define GL_NV_vertex_program3 1 +#endif /* GL_NV_vertex_program3 */ + +#ifndef GL_NV_vertex_program4 +#define GL_NV_vertex_program4 1 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint *params); +#endif +#endif /* GL_NV_vertex_program4 */ + +#ifndef GL_NV_video_capture +#define GL_NV_video_capture 1 +#define GL_VIDEO_BUFFER_NV 0x9020 +#define GL_VIDEO_BUFFER_BINDING_NV 0x9021 +#define GL_FIELD_UPPER_NV 0x9022 +#define GL_FIELD_LOWER_NV 0x9023 +#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024 +#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025 +#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026 +#define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027 +#define GL_VIDEO_BUFFER_PITCH_NV 0x9028 +#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029 +#define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A +#define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B +#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C +#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D +#define GL_PARTIAL_SUCCESS_NV 0x902E +#define GL_SUCCESS_NV 0x902F +#define GL_FAILURE_NV 0x9030 +#define GL_YCBYCR8_422_NV 0x9031 +#define GL_YCBAYCR8A_4224_NV 0x9032 +#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033 +#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034 +#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035 +#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036 +#define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037 +#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038 +#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039 +#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A +#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B +#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C +typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); +typedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint video_capture_slot); +GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); +GLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); +GLAPI void APIENTRY glEndVideoCaptureNV (GLuint video_capture_slot); +GLAPI void APIENTRY glGetVideoCaptureivNV (GLuint video_capture_slot, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideoCaptureStreamivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideoCaptureStreamfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVideoCaptureStreamdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); +GLAPI GLenum APIENTRY glVideoCaptureNV (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); +GLAPI void APIENTRY glVideoCaptureStreamParameterivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); +GLAPI void APIENTRY glVideoCaptureStreamParameterfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +#endif +#endif /* GL_NV_video_capture */ + +#ifndef GL_OML_interlace +#define GL_OML_interlace 1 +#define GL_INTERLACE_OML 0x8980 +#define GL_INTERLACE_READ_OML 0x8981 +#endif /* GL_OML_interlace */ + +#ifndef GL_OML_resample +#define GL_OML_resample 1 +#define GL_PACK_RESAMPLE_OML 0x8984 +#define GL_UNPACK_RESAMPLE_OML 0x8985 +#define GL_RESAMPLE_REPLICATE_OML 0x8986 +#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 +#define GL_RESAMPLE_AVERAGE_OML 0x8988 +#define GL_RESAMPLE_DECIMATE_OML 0x8989 +#endif /* GL_OML_resample */ + +#ifndef GL_OML_subsample +#define GL_OML_subsample 1 +#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 +#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 +#endif /* GL_OML_subsample */ + +#ifndef GL_PGI_misc_hints +#define GL_PGI_misc_hints 1 +#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 +#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD +#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE +#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 +#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 +#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 +#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C +#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D +#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E +#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F +#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 +#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 +#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 +#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 +#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 +#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 +#define GL_CLIP_NEAR_HINT_PGI 0x1A220 +#define GL_CLIP_FAR_HINT_PGI 0x1A221 +#define GL_WIDE_LINE_HINT_PGI 0x1A222 +#define GL_BACK_NORMALS_HINT_PGI 0x1A223 +typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glHintPGI (GLenum target, GLint mode); +#endif +#endif /* GL_PGI_misc_hints */ + +#ifndef GL_PGI_vertex_hints +#define GL_PGI_vertex_hints 1 +#define GL_VERTEX_DATA_HINT_PGI 0x1A22A +#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B +#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C +#define GL_MAX_VERTEX_HINT_PGI 0x1A22D +#define GL_COLOR3_BIT_PGI 0x00010000 +#define GL_COLOR4_BIT_PGI 0x00020000 +#define GL_EDGEFLAG_BIT_PGI 0x00040000 +#define GL_INDEX_BIT_PGI 0x00080000 +#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 +#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 +#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 +#define GL_MAT_EMISSION_BIT_PGI 0x00800000 +#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 +#define GL_MAT_SHININESS_BIT_PGI 0x02000000 +#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 +#define GL_NORMAL_BIT_PGI 0x08000000 +#define GL_TEXCOORD1_BIT_PGI 0x10000000 +#define GL_TEXCOORD2_BIT_PGI 0x20000000 +#define GL_TEXCOORD3_BIT_PGI 0x40000000 +#define GL_TEXCOORD4_BIT_PGI 0x80000000 +#define GL_VERTEX23_BIT_PGI 0x00000004 +#define GL_VERTEX4_BIT_PGI 0x00000008 +#endif /* GL_PGI_vertex_hints */ + +#ifndef GL_REND_screen_coordinates +#define GL_REND_screen_coordinates 1 +#define GL_SCREEN_COORDINATES_REND 0x8490 +#define GL_INVERTED_SCREEN_W_REND 0x8491 +#endif /* GL_REND_screen_coordinates */ + +#ifndef GL_S3_s3tc +#define GL_S3_s3tc 1 +#define GL_RGB_S3TC 0x83A0 +#define GL_RGB4_S3TC 0x83A1 +#define GL_RGBA_S3TC 0x83A2 +#define GL_RGBA4_S3TC 0x83A3 +#define GL_RGBA_DXT5_S3TC 0x83A4 +#define GL_RGBA4_DXT5_S3TC 0x83A5 +#endif /* GL_S3_s3tc */ + +#ifndef GL_SGIS_detail_texture +#define GL_SGIS_detail_texture 1 +#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 +#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 +#define GL_LINEAR_DETAIL_SGIS 0x8097 +#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 +#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 +#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A +#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B +#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C +typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum target, GLfloat *points); +#endif +#endif /* GL_SGIS_detail_texture */ + +#ifndef GL_SGIS_fog_function +#define GL_SGIS_fog_function 1 +#define GL_FOG_FUNC_SGIS 0x812A +#define GL_FOG_FUNC_POINTS_SGIS 0x812B +#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C +typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogFuncSGIS (GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *points); +#endif +#endif /* GL_SGIS_fog_function */ + +#ifndef GL_SGIS_generate_mipmap +#define GL_SGIS_generate_mipmap 1 +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 +#endif /* GL_SGIS_generate_mipmap */ + +#ifndef GL_SGIS_multisample +#define GL_SGIS_multisample 1 +#define GL_MULTISAMPLE_SGIS 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F +#define GL_SAMPLE_MASK_SGIS 0x80A0 +#define GL_1PASS_SGIS 0x80A1 +#define GL_2PASS_0_SGIS 0x80A2 +#define GL_2PASS_1_SGIS 0x80A3 +#define GL_4PASS_0_SGIS 0x80A4 +#define GL_4PASS_1_SGIS 0x80A5 +#define GL_4PASS_2_SGIS 0x80A6 +#define GL_4PASS_3_SGIS 0x80A7 +#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 +#define GL_SAMPLES_SGIS 0x80A9 +#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA +#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB +#define GL_SAMPLE_PATTERN_SGIS 0x80AC +typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskSGIS (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternSGIS (GLenum pattern); +#endif +#endif /* GL_SGIS_multisample */ + +#ifndef GL_SGIS_pixel_texture +#define GL_SGIS_pixel_texture 1 +#define GL_PIXEL_TEXTURE_SGIS 0x8353 +#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 +#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 +#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum pname, GLint *params); +GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum pname, GLfloat *params); +#endif +#endif /* GL_SGIS_pixel_texture */ + +#ifndef GL_SGIS_point_line_texgen +#define GL_SGIS_point_line_texgen 1 +#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 +#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 +#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 +#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 +#define GL_EYE_POINT_SGIS 0x81F4 +#define GL_OBJECT_POINT_SGIS 0x81F5 +#define GL_EYE_LINE_SGIS 0x81F6 +#define GL_OBJECT_LINE_SGIS 0x81F7 +#endif /* GL_SGIS_point_line_texgen */ + +#ifndef GL_SGIS_point_parameters +#define GL_SGIS_point_parameters 1 +#define GL_POINT_SIZE_MIN_SGIS 0x8126 +#define GL_POINT_SIZE_MAX_SGIS 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 +#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 +typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvSGIS (GLenum pname, const GLfloat *params); +#endif +#endif /* GL_SGIS_point_parameters */ + +#ifndef GL_SGIS_sharpen_texture +#define GL_SGIS_sharpen_texture 1 +#define GL_LINEAR_SHARPEN_SGIS 0x80AD +#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE +#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF +#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 +typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum target, GLfloat *points); +#endif +#endif /* GL_SGIS_sharpen_texture */ + +#ifndef GL_SGIS_texture4D +#define GL_SGIS_texture4D 1 +#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 +#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 +#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 +#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 +#define GL_TEXTURE_4D_SGIS 0x8134 +#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 +#define GL_TEXTURE_4DSIZE_SGIS 0x8136 +#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 +#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 +#define GL_TEXTURE_4D_BINDING_SGIS 0x814F +typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const void *pixels); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage4DSGIS (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const void *pixels); +#endif +#endif /* GL_SGIS_texture4D */ + +#ifndef GL_SGIS_texture_border_clamp +#define GL_SGIS_texture_border_clamp 1 +#define GL_CLAMP_TO_BORDER_SGIS 0x812D +#endif /* GL_SGIS_texture_border_clamp */ + +#ifndef GL_SGIS_texture_color_mask +#define GL_SGIS_texture_color_mask 1 +#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF +typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#endif +#endif /* GL_SGIS_texture_color_mask */ + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_SGIS_texture_edge_clamp 1 +#define GL_CLAMP_TO_EDGE_SGIS 0x812F +#endif /* GL_SGIS_texture_edge_clamp */ + +#ifndef GL_SGIS_texture_filter4 +#define GL_SGIS_texture_filter4 1 +#define GL_FILTER4_SGIS 0x8146 +#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 +typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); +typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum target, GLenum filter, GLfloat *weights); +GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#endif +#endif /* GL_SGIS_texture_filter4 */ + +#ifndef GL_SGIS_texture_lod +#define GL_SGIS_texture_lod 1 +#define GL_TEXTURE_MIN_LOD_SGIS 0x813A +#define GL_TEXTURE_MAX_LOD_SGIS 0x813B +#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C +#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D +#endif /* GL_SGIS_texture_lod */ + +#ifndef GL_SGIS_texture_select +#define GL_SGIS_texture_select 1 +#define GL_DUAL_ALPHA4_SGIS 0x8110 +#define GL_DUAL_ALPHA8_SGIS 0x8111 +#define GL_DUAL_ALPHA12_SGIS 0x8112 +#define GL_DUAL_ALPHA16_SGIS 0x8113 +#define GL_DUAL_LUMINANCE4_SGIS 0x8114 +#define GL_DUAL_LUMINANCE8_SGIS 0x8115 +#define GL_DUAL_LUMINANCE12_SGIS 0x8116 +#define GL_DUAL_LUMINANCE16_SGIS 0x8117 +#define GL_DUAL_INTENSITY4_SGIS 0x8118 +#define GL_DUAL_INTENSITY8_SGIS 0x8119 +#define GL_DUAL_INTENSITY12_SGIS 0x811A +#define GL_DUAL_INTENSITY16_SGIS 0x811B +#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C +#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D +#define GL_QUAD_ALPHA4_SGIS 0x811E +#define GL_QUAD_ALPHA8_SGIS 0x811F +#define GL_QUAD_LUMINANCE4_SGIS 0x8120 +#define GL_QUAD_LUMINANCE8_SGIS 0x8121 +#define GL_QUAD_INTENSITY4_SGIS 0x8122 +#define GL_QUAD_INTENSITY8_SGIS 0x8123 +#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 +#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 +#endif /* GL_SGIS_texture_select */ + +#ifndef GL_SGIX_async +#define GL_SGIX_async 1 +#define GL_ASYNC_MARKER_SGIX 0x8329 +typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); +typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); +typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); +typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint marker); +GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *markerp); +GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *markerp); +GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei range); +GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint marker, GLsizei range); +GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint marker); +#endif +#endif /* GL_SGIX_async */ + +#ifndef GL_SGIX_async_histogram +#define GL_SGIX_async_histogram 1 +#define GL_ASYNC_HISTOGRAM_SGIX 0x832C +#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D +#endif /* GL_SGIX_async_histogram */ + +#ifndef GL_SGIX_async_pixel +#define GL_SGIX_async_pixel 1 +#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C +#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D +#define GL_ASYNC_READ_PIXELS_SGIX 0x835E +#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F +#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 +#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 +#endif /* GL_SGIX_async_pixel */ + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_SGIX_blend_alpha_minmax 1 +#define GL_ALPHA_MIN_SGIX 0x8320 +#define GL_ALPHA_MAX_SGIX 0x8321 +#endif /* GL_SGIX_blend_alpha_minmax */ + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_SGIX_calligraphic_fragment 1 +#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 +#endif /* GL_SGIX_calligraphic_fragment */ + +#ifndef GL_SGIX_clipmap +#define GL_SGIX_clipmap 1 +#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 +#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 +#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 +#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 +#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 +#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 +#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 +#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 +#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 +#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D +#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E +#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F +#endif /* GL_SGIX_clipmap */ + +#ifndef GL_SGIX_convolution_accuracy +#define GL_SGIX_convolution_accuracy 1 +#define GL_CONVOLUTION_HINT_SGIX 0x8316 +#endif /* GL_SGIX_convolution_accuracy */ + +#ifndef GL_SGIX_depth_pass_instrument +#define GL_SGIX_depth_pass_instrument 1 +#endif /* GL_SGIX_depth_pass_instrument */ + +#ifndef GL_SGIX_depth_texture +#define GL_SGIX_depth_texture 1 +#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 +#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 +#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 +#endif /* GL_SGIX_depth_texture */ + +#ifndef GL_SGIX_flush_raster +#define GL_SGIX_flush_raster 1 +typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushRasterSGIX (void); +#endif +#endif /* GL_SGIX_flush_raster */ + +#ifndef GL_SGIX_fog_offset +#define GL_SGIX_fog_offset 1 +#define GL_FOG_OFFSET_SGIX 0x8198 +#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 +#endif /* GL_SGIX_fog_offset */ + +#ifndef GL_SGIX_fragment_lighting +#define GL_SGIX_fragment_lighting 1 +#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 +#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 +#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 +#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 +#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 +#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 +#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 +#define GL_LIGHT_ENV_MODE_SGIX 0x8407 +#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 +#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 +#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A +#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B +#define GL_FRAGMENT_LIGHT0_SGIX 0x840C +#define GL_FRAGMENT_LIGHT1_SGIX 0x840D +#define GL_FRAGMENT_LIGHT2_SGIX 0x840E +#define GL_FRAGMENT_LIGHT3_SGIX 0x840F +#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 +#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 +#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 +#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 +typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum face, GLenum mode); +GLAPI void APIENTRY glFragmentLightfSGIX (GLenum light, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum light, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightiSGIX (GLenum light, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightivSGIX (GLenum light, GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum face, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum face, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum face, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum face, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum light, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum light, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum face, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum face, GLenum pname, GLint *params); +GLAPI void APIENTRY glLightEnviSGIX (GLenum pname, GLint param); +#endif +#endif /* GL_SGIX_fragment_lighting */ + +#ifndef GL_SGIX_framezoom +#define GL_SGIX_framezoom 1 +#define GL_FRAMEZOOM_SGIX 0x818B +#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C +#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D +typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameZoomSGIX (GLint factor); +#endif +#endif /* GL_SGIX_framezoom */ + +#ifndef GL_SGIX_igloo_interface +#define GL_SGIX_igloo_interface 1 +typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const void *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum pname, const void *params); +#endif +#endif /* GL_SGIX_igloo_interface */ + +#ifndef GL_SGIX_instruments +#define GL_SGIX_instruments 1 +#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 +#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 +typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); +typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); +typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); +typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); +GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei size, GLint *buffer); +GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *marker_p); +GLAPI void APIENTRY glReadInstrumentsSGIX (GLint marker); +GLAPI void APIENTRY glStartInstrumentsSGIX (void); +GLAPI void APIENTRY glStopInstrumentsSGIX (GLint marker); +#endif +#endif /* GL_SGIX_instruments */ + +#ifndef GL_SGIX_interlace +#define GL_SGIX_interlace 1 +#define GL_INTERLACE_SGIX 0x8094 +#endif /* GL_SGIX_interlace */ + +#ifndef GL_SGIX_ir_instrument1 +#define GL_SGIX_ir_instrument1 1 +#define GL_IR_INSTRUMENT1_SGIX 0x817F +#endif /* GL_SGIX_ir_instrument1 */ + +#ifndef GL_SGIX_list_priority +#define GL_SGIX_list_priority 1 +#define GL_LIST_PRIORITY_SGIX 0x8182 +typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint list, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetListParameterivSGIX (GLuint list, GLenum pname, GLint *params); +GLAPI void APIENTRY glListParameterfSGIX (GLuint list, GLenum pname, GLfloat param); +GLAPI void APIENTRY glListParameterfvSGIX (GLuint list, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glListParameteriSGIX (GLuint list, GLenum pname, GLint param); +GLAPI void APIENTRY glListParameterivSGIX (GLuint list, GLenum pname, const GLint *params); +#endif +#endif /* GL_SGIX_list_priority */ + +#ifndef GL_SGIX_pixel_texture +#define GL_SGIX_pixel_texture 1 +#define GL_PIXEL_TEX_GEN_SGIX 0x8139 +#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B +typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenSGIX (GLenum mode); +#endif +#endif /* GL_SGIX_pixel_texture */ + +#ifndef GL_SGIX_pixel_tiles +#define GL_SGIX_pixel_tiles 1 +#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E +#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F +#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 +#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 +#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 +#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 +#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 +#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 +#endif /* GL_SGIX_pixel_tiles */ + +#ifndef GL_SGIX_polynomial_ffd +#define GL_SGIX_polynomial_ffd 1 +#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 +#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 +#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 +#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 +#define GL_DEFORMATIONS_MASK_SGIX 0x8196 +#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +GLAPI void APIENTRY glDeformSGIX (GLbitfield mask); +GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield mask); +#endif +#endif /* GL_SGIX_polynomial_ffd */ + +#ifndef GL_SGIX_reference_plane +#define GL_SGIX_reference_plane 1 +#define GL_REFERENCE_PLANE_SGIX 0x817D +#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E +typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *equation); +#endif +#endif /* GL_SGIX_reference_plane */ + +#ifndef GL_SGIX_resample +#define GL_SGIX_resample 1 +#define GL_PACK_RESAMPLE_SGIX 0x842C +#define GL_UNPACK_RESAMPLE_SGIX 0x842D +#define GL_RESAMPLE_REPLICATE_SGIX 0x842E +#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F +#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 +#endif /* GL_SGIX_resample */ + +#ifndef GL_SGIX_scalebias_hint +#define GL_SGIX_scalebias_hint 1 +#define GL_SCALEBIAS_HINT_SGIX 0x8322 +#endif /* GL_SGIX_scalebias_hint */ + +#ifndef GL_SGIX_shadow +#define GL_SGIX_shadow 1 +#define GL_TEXTURE_COMPARE_SGIX 0x819A +#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B +#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C +#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D +#endif /* GL_SGIX_shadow */ + +#ifndef GL_SGIX_shadow_ambient +#define GL_SGIX_shadow_ambient 1 +#define GL_SHADOW_AMBIENT_SGIX 0x80BF +#endif /* GL_SGIX_shadow_ambient */ + +#ifndef GL_SGIX_sprite +#define GL_SGIX_sprite 1 +#define GL_SPRITE_SGIX 0x8148 +#define GL_SPRITE_MODE_SGIX 0x8149 +#define GL_SPRITE_AXIS_SGIX 0x814A +#define GL_SPRITE_TRANSLATION_SGIX 0x814B +#define GL_SPRITE_AXIAL_SGIX 0x814C +#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D +#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum pname, const GLint *params); +#endif +#endif /* GL_SGIX_sprite */ + +#ifndef GL_SGIX_subsample +#define GL_SGIX_subsample 1 +#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 +#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 +#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 +#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 +#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 +#endif /* GL_SGIX_subsample */ + +#ifndef GL_SGIX_tag_sample_buffer +#define GL_SGIX_tag_sample_buffer 1 +typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTagSampleBufferSGIX (void); +#endif +#endif /* GL_SGIX_tag_sample_buffer */ + +#ifndef GL_SGIX_texture_add_env +#define GL_SGIX_texture_add_env 1 +#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE +#endif /* GL_SGIX_texture_add_env */ + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_SGIX_texture_coordinate_clamp 1 +#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 +#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A +#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B +#endif /* GL_SGIX_texture_coordinate_clamp */ + +#ifndef GL_SGIX_texture_lod_bias +#define GL_SGIX_texture_lod_bias 1 +#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E +#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F +#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 +#endif /* GL_SGIX_texture_lod_bias */ + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_SGIX_texture_multi_buffer 1 +#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E +#endif /* GL_SGIX_texture_multi_buffer */ + +#ifndef GL_SGIX_texture_scale_bias +#define GL_SGIX_texture_scale_bias 1 +#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 +#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A +#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B +#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C +#endif /* GL_SGIX_texture_scale_bias */ + +#ifndef GL_SGIX_vertex_preclip +#define GL_SGIX_vertex_preclip 1 +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF +#endif /* GL_SGIX_vertex_preclip */ + +#ifndef GL_SGIX_ycrcb +#define GL_SGIX_ycrcb 1 +#define GL_YCRCB_422_SGIX 0x81BB +#define GL_YCRCB_444_SGIX 0x81BC +#endif /* GL_SGIX_ycrcb */ + +#ifndef GL_SGIX_ycrcb_subsample +#define GL_SGIX_ycrcb_subsample 1 +#endif /* GL_SGIX_ycrcb_subsample */ + +#ifndef GL_SGIX_ycrcba +#define GL_SGIX_ycrcba 1 +#define GL_YCRCB_SGIX 0x8318 +#define GL_YCRCBA_SGIX 0x8319 +#endif /* GL_SGIX_ycrcba */ + +#ifndef GL_SGI_color_matrix +#define GL_SGI_color_matrix 1 +#define GL_COLOR_MATRIX_SGI 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB +#endif /* GL_SGI_color_matrix */ + +#ifndef GL_SGI_color_table +#define GL_SGI_color_table 1 +#define GL_COLOR_TABLE_SGI 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 +#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 +#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 +#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 +#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 +#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF +typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, void *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableSGI (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameterivSGI (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTableSGI (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTableSGI (GLenum target, GLenum format, GLenum type, void *table); +GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum target, GLenum pname, GLint *params); +#endif +#endif /* GL_SGI_color_table */ + +#ifndef GL_SGI_texture_color_table +#define GL_SGI_texture_color_table 1 +#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC +#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD +#endif /* GL_SGI_texture_color_table */ + +#ifndef GL_SUNX_constant_data +#define GL_SUNX_constant_data 1 +#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 +#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 +typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFinishTextureSUNX (void); +#endif +#endif /* GL_SUNX_constant_data */ + +#ifndef GL_SUN_convolution_border_modes +#define GL_SUN_convolution_border_modes 1 +#define GL_WRAP_BORDER_SUN 0x81D4 +#endif /* GL_SUN_convolution_border_modes */ + +#ifndef GL_SUN_global_alpha +#define GL_SUN_global_alpha 1 +#define GL_GLOBAL_ALPHA_SUN 0x81D9 +#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort factor); +GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint factor); +GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat factor); +GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble factor); +GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort factor); +GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint factor); +#endif +#endif /* GL_SUN_global_alpha */ + +#ifndef GL_SUN_mesh_array +#define GL_SUN_mesh_array 1 +#define GL_QUAD_MESH_SUN 0x8614 +#define GL_TRIANGLE_MESH_SUN 0x8615 +typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum mode, GLint first, GLsizei count, GLsizei width); +#endif +#endif /* GL_SUN_mesh_array */ + +#ifndef GL_SUN_slice_accum +#define GL_SUN_slice_accum 1 +#define GL_SLICE_ACCUM_SUN 0x85CC +#endif /* GL_SUN_slice_accum */ + +#ifndef GL_SUN_triangle_list +#define GL_SUN_triangle_list 1 +#define GL_RESTART_SUN 0x0001 +#define GL_REPLACE_MIDDLE_SUN 0x0002 +#define GL_REPLACE_OLDEST_SUN 0x0003 +#define GL_TRIANGLE_LIST_SUN 0x81D7 +#define GL_REPLACEMENT_CODE_SUN 0x81D8 +#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 +#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 +#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 +#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 +#define GL_R1UI_V3F_SUN 0x85C4 +#define GL_R1UI_C4UB_V3F_SUN 0x85C5 +#define GL_R1UI_C3F_V3F_SUN 0x85C6 +#define GL_R1UI_N3F_V3F_SUN 0x85C7 +#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 +#define GL_R1UI_T2F_V3F_SUN 0x85C9 +#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA +#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const void **pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint code); +GLAPI void APIENTRY glReplacementCodeusSUN (GLushort code); +GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte code); +GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *code); +GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *code); +GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *code); +GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum type, GLsizei stride, const void **pointer); +#endif +#endif /* GL_SUN_triangle_list */ + +#ifndef GL_SUN_vertex +#define GL_SUN_vertex 1 +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *rc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *rc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#endif +#endif /* GL_SUN_vertex */ + +#ifndef GL_WIN_phong_shading +#define GL_WIN_phong_shading 1 +#define GL_PHONG_WIN 0x80EA +#define GL_PHONG_HINT_WIN 0x80EB +#endif /* GL_WIN_phong_shading */ + +#ifndef GL_WIN_specular_fog +#define GL_WIN_specular_fog 1 +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC +#endif /* GL_WIN_specular_fog */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/include/SDL2/SDL_opengles.h b/thirdparty/include/SDL2/SDL_opengles.h new file mode 100644 index 000000000..5c2a3e63c --- /dev/null +++ b/thirdparty/include/SDL2/SDL_opengles.h @@ -0,0 +1,39 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_opengles.h + * + * This is a simple file to encapsulate the OpenGL ES 1.X API headers. + */ +#include "SDL_config.h" + +#ifdef __IPHONEOS__ +#include +#include +#else +#include +#include +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif diff --git a/thirdparty/include/SDL2/SDL_opengles2.h b/thirdparty/include/SDL2/SDL_opengles2.h new file mode 100644 index 000000000..00bc180c2 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_opengles2.h @@ -0,0 +1,52 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_opengles2.h + * + * This is a simple file to encapsulate the OpenGL ES 2.0 API headers. + */ +#include "SDL_config.h" + +#ifndef _MSC_VER + +#ifdef __IPHONEOS__ +#include +#include +#else +#include +#include +#include +#endif + +#else /* _MSC_VER */ + +/* OpenGL ES2 headers for Visual Studio */ +#include "SDL_opengles2_khrplatform.h" +#include "SDL_opengles2_gl2platform.h" +#include "SDL_opengles2_gl2.h" +#include "SDL_opengles2_gl2ext.h" + +#endif /* _MSC_VER */ + +#ifndef APIENTRY +#define APIENTRY GL_APIENTRY +#endif diff --git a/thirdparty/include/SDL2/SDL_opengles2_gl2.h b/thirdparty/include/SDL2/SDL_opengles2_gl2.h new file mode 100644 index 000000000..c62fb0a54 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_opengles2_gl2.h @@ -0,0 +1,621 @@ +#ifndef __gl2_h_ +#define __gl2_h_ + +/* $Revision: 20555 $ on $Date:: 2013-02-12 14:32:47 -0800 #$ */ + +/*#include */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This document is licensed under the SGI Free Software B License Version + * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . + */ + +/*------------------------------------------------------------------------- + * Data type definitions + *-----------------------------------------------------------------------*/ + +typedef void GLvoid; +typedef char GLchar; +typedef unsigned int GLenum; +typedef unsigned char GLboolean; +typedef unsigned int GLbitfield; +typedef khronos_int8_t GLbyte; +typedef short GLshort; +typedef int GLint; +typedef int GLsizei; +typedef khronos_uint8_t GLubyte; +typedef unsigned short GLushort; +typedef unsigned int GLuint; +typedef khronos_float_t GLfloat; +typedef khronos_float_t GLclampf; +typedef khronos_int32_t GLfixed; + +/* GL types for handling large vertex buffer objects */ +typedef khronos_intptr_t GLintptr; +typedef khronos_ssize_t GLsizeiptr; + +/* OpenGL ES core versions */ +#define GL_ES_VERSION_2_0 1 + +/* ClearBufferMask */ +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_COLOR_BUFFER_BIT 0x00004000 + +/* Boolean */ +#define GL_FALSE 0 +#define GL_TRUE 1 + +/* BeginMode */ +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 + +/* AlphaFunction (not supported in ES20) */ +/* GL_NEVER */ +/* GL_LESS */ +/* GL_EQUAL */ +/* GL_LEQUAL */ +/* GL_GREATER */ +/* GL_NOTEQUAL */ +/* GL_GEQUAL */ +/* GL_ALWAYS */ + +/* BlendingFactorDest */ +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 + +/* BlendingFactorSrc */ +/* GL_ZERO */ +/* GL_ONE */ +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 +/* GL_SRC_ALPHA */ +/* GL_ONE_MINUS_SRC_ALPHA */ +/* GL_DST_ALPHA */ +/* GL_ONE_MINUS_DST_ALPHA */ + +/* BlendEquationSeparate */ +#define GL_FUNC_ADD 0x8006 +#define GL_BLEND_EQUATION 0x8009 +#define GL_BLEND_EQUATION_RGB 0x8009 /* same as BLEND_EQUATION */ +#define GL_BLEND_EQUATION_ALPHA 0x883D + +/* BlendSubtract */ +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B + +/* Separate Blend Functions */ +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 + +/* Buffer Objects */ +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 + +#define GL_STREAM_DRAW 0x88E0 +#define GL_STATIC_DRAW 0x88E4 +#define GL_DYNAMIC_DRAW 0x88E8 + +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 + +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 + +/* CullFaceMode */ +#define GL_FRONT 0x0404 +#define GL_BACK 0x0405 +#define GL_FRONT_AND_BACK 0x0408 + +/* DepthFunction */ +/* GL_NEVER */ +/* GL_LESS */ +/* GL_EQUAL */ +/* GL_LEQUAL */ +/* GL_GREATER */ +/* GL_NOTEQUAL */ +/* GL_GEQUAL */ +/* GL_ALWAYS */ + +/* EnableCap */ +#define GL_TEXTURE_2D 0x0DE1 +#define GL_CULL_FACE 0x0B44 +#define GL_BLEND 0x0BE2 +#define GL_DITHER 0x0BD0 +#define GL_STENCIL_TEST 0x0B90 +#define GL_DEPTH_TEST 0x0B71 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_POLYGON_OFFSET_FILL 0x8037 +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_COVERAGE 0x80A0 + +/* ErrorCode */ +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_OUT_OF_MEMORY 0x0505 + +/* FrontFaceDirection */ +#define GL_CW 0x0900 +#define GL_CCW 0x0901 + +/* GetPName */ +#define GL_LINE_WIDTH 0x0B21 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_FRONT_FACE 0x0B46 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#define GL_VIEWPORT 0x0BA2 +#define GL_SCISSOR_BOX 0x0C10 +/* GL_SCISSOR_TEST */ +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_RED_BITS 0x0D52 +#define GL_GREEN_BITS 0x0D53 +#define GL_BLUE_BITS 0x0D54 +#define GL_ALPHA_BITS 0x0D55 +#define GL_DEPTH_BITS 0x0D56 +#define GL_STENCIL_BITS 0x0D57 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +/* GL_POLYGON_OFFSET_FILL */ +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB + +/* GetTextureParameter */ +/* GL_TEXTURE_MAG_FILTER */ +/* GL_TEXTURE_MIN_FILTER */ +/* GL_TEXTURE_WRAP_S */ +/* GL_TEXTURE_WRAP_T */ + +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 + +/* HintMode */ +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 + +/* HintTarget */ +#define GL_GENERATE_MIPMAP_HINT 0x8192 + +/* DataType */ +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_INT 0x1404 +#define GL_UNSIGNED_INT 0x1405 +#define GL_FLOAT 0x1406 +#define GL_FIXED 0x140C + +/* PixelFormat */ +#define GL_DEPTH_COMPONENT 0x1902 +#define GL_ALPHA 0x1906 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE_ALPHA 0x190A + +/* PixelType */ +/* GL_UNSIGNED_BYTE */ +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 + +/* Shaders */ +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_SHADER_TYPE 0x8B4F +#define GL_DELETE_STATUS 0x8B80 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D + +/* StencilFunction */ +#define GL_NEVER 0x0200 +#define GL_LESS 0x0201 +#define GL_EQUAL 0x0202 +#define GL_LEQUAL 0x0203 +#define GL_GREATER 0x0204 +#define GL_NOTEQUAL 0x0205 +#define GL_GEQUAL 0x0206 +#define GL_ALWAYS 0x0207 + +/* StencilOp */ +/* GL_ZERO */ +#define GL_KEEP 0x1E00 +#define GL_REPLACE 0x1E01 +#define GL_INCR 0x1E02 +#define GL_DECR 0x1E03 +#define GL_INVERT 0x150A +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 + +/* StringName */ +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 + +/* TextureMagFilter */ +#define GL_NEAREST 0x2600 +#define GL_LINEAR 0x2601 + +/* TextureMinFilter */ +/* GL_NEAREST */ +/* GL_LINEAR */ +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 + +/* TextureParameterName */ +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 + +/* TextureTarget */ +/* GL_TEXTURE_2D */ +#define GL_TEXTURE 0x1702 + +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C + +/* TextureUnit */ +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 + +/* TextureWrapMode */ +#define GL_REPEAT 0x2901 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_MIRRORED_REPEAT 0x8370 + +/* Uniform Types */ +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_CUBE 0x8B60 + +/* Vertex Arrays */ +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F + +/* Read Format */ +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B + +/* Shader Source */ +#define GL_COMPILE_STATUS 0x8B81 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_SHADER_COMPILER 0x8DFA + +/* Shader Binary */ +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 + +/* Shader Precision-Specified Types */ +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 + +/* Framebuffer Object. */ +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 + +#define GL_RGBA4 0x8056 +#define GL_RGB5_A1 0x8057 +#define GL_RGB565 0x8D62 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_STENCIL_INDEX8 0x8D48 + +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 + +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 + +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 + +#define GL_NONE 0 + +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD + +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 + +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 + +/*------------------------------------------------------------------------- + * GL core functions. + *-----------------------------------------------------------------------*/ + +GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture); +GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader); +GL_APICALL void GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar* name); +GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); +GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); +GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLuint texture); +GL_APICALL void GL_APIENTRY glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +GL_APICALL void GL_APIENTRY glBlendEquation ( GLenum mode ); +GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); +GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); +GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage); +GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data); +GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target); +GL_APICALL void GL_APIENTRY glClear (GLbitfield mask); +GL_APICALL void GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +GL_APICALL void GL_APIENTRY glClearDepthf (GLclampf depth); +GL_APICALL void GL_APIENTRY glClearStencil (GLint s); +GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader); +GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data); +GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data); +GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL GLuint GL_APIENTRY glCreateProgram (void); +GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type); +GL_APICALL void GL_APIENTRY glCullFace (GLenum mode); +GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint* buffers); +GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint* framebuffers); +GL_APICALL void GL_APIENTRY glDeleteProgram (GLuint program); +GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint* renderbuffers); +GL_APICALL void GL_APIENTRY glDeleteShader (GLuint shader); +GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint* textures); +GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func); +GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag); +GL_APICALL void GL_APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar); +GL_APICALL void GL_APIENTRY glDetachShader (GLuint program, GLuint shader); +GL_APICALL void GL_APIENTRY glDisable (GLenum cap); +GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index); +GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); +GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices); +GL_APICALL void GL_APIENTRY glEnable (GLenum cap); +GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index); +GL_APICALL void GL_APIENTRY glFinish (void); +GL_APICALL void GL_APIENTRY glFlush (void); +GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode); +GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint* buffers); +GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target); +GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint* framebuffers); +GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint* renderbuffers); +GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint* textures); +GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); +GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); +GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders); +GL_APICALL GLint GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name); +GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean* params); +GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params); +GL_APICALL GLenum GL_APIENTRY glGetError (void); +GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat* params); +GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog); +GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog); +GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); +GL_APICALL void GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source); +GL_APICALL const GLubyte* GL_APIENTRY glGetString (GLenum name); +GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat* params); +GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat* params); +GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint* params); +GL_APICALL GLint GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name); +GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params); +GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid** pointer); +GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode); +GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLuint buffer); +GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap); +GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer); +GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program); +GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader); +GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture); +GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width); +GL_APICALL void GL_APIENTRY glLinkProgram (GLuint program); +GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units); +GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels); +GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void); +GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert); +GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length); +GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length); +GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask); +GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); +GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass); +GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels); +GL_APICALL void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); +GL_APICALL void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat* params); +GL_APICALL void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint* params); +GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels); +GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat x); +GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat* v); +GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint x); +GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint* v); +GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat x, GLfloat y); +GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat* v); +GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint x, GLint y); +GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint* v); +GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat* v); +GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint x, GLint y, GLint z); +GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint* v); +GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat* v); +GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint x, GLint y, GLint z, GLint w); +GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint* v); +GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +GL_APICALL void GL_APIENTRY glUseProgram (GLuint program); +GL_APICALL void GL_APIENTRY glValidateProgram (GLuint program); +GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint indx, GLfloat x); +GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint indx, const GLfloat* values); +GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint indx, GLfloat x, GLfloat y); +GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint indx, const GLfloat* values); +GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint indx, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint indx, const GLfloat* values); +GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint indx, const GLfloat* values); +GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr); +GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); + +#ifdef __cplusplus +} +#endif + +#endif /* __gl2_h_ */ + diff --git a/thirdparty/include/SDL2/SDL_opengles2_gl2ext.h b/thirdparty/include/SDL2/SDL_opengles2_gl2ext.h new file mode 100644 index 000000000..e8ca8b13f --- /dev/null +++ b/thirdparty/include/SDL2/SDL_opengles2_gl2ext.h @@ -0,0 +1,2050 @@ +#ifndef __gl2ext_h_ +#define __gl2ext_h_ + +/* $Revision: 22801 $ on $Date:: 2013-08-21 03:20:48 -0700 #$ */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This document is licensed under the SGI Free Software B License Version + * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . + */ + +#ifndef GL_APIENTRYP +# define GL_APIENTRYP GL_APIENTRY* +#endif + +/* New types shared by several extensions */ + +#ifndef __gl3_h_ +/* These are defined with respect to in the + * Apple extension spec, but they are also used by non-APPLE + * extensions, and in the Khronos header we use the Khronos + * portable types in khrplatform.h, which must be defined. + */ +typedef khronos_int64_t GLint64; +typedef khronos_uint64_t GLuint64; +typedef struct __GLsync *GLsync; +#endif + + +/*------------------------------------------------------------------------* + * OES extension tokens + *------------------------------------------------------------------------*/ + +/* GL_OES_compressed_ETC1_RGB8_texture */ +#ifndef GL_OES_compressed_ETC1_RGB8_texture +#define GL_ETC1_RGB8_OES 0x8D64 +#endif + +/* GL_OES_compressed_paletted_texture */ +#ifndef GL_OES_compressed_paletted_texture +#define GL_PALETTE4_RGB8_OES 0x8B90 +#define GL_PALETTE4_RGBA8_OES 0x8B91 +#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 +#define GL_PALETTE4_RGBA4_OES 0x8B93 +#define GL_PALETTE4_RGB5_A1_OES 0x8B94 +#define GL_PALETTE8_RGB8_OES 0x8B95 +#define GL_PALETTE8_RGBA8_OES 0x8B96 +#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 +#define GL_PALETTE8_RGBA4_OES 0x8B98 +#define GL_PALETTE8_RGB5_A1_OES 0x8B99 +#endif + +/* GL_OES_depth24 */ +#ifndef GL_OES_depth24 +#define GL_DEPTH_COMPONENT24_OES 0x81A6 +#endif + +/* GL_OES_depth32 */ +#ifndef GL_OES_depth32 +#define GL_DEPTH_COMPONENT32_OES 0x81A7 +#endif + +/* GL_OES_depth_texture */ +/* No new tokens introduced by this extension. */ + +/* GL_OES_EGL_image */ +#ifndef GL_OES_EGL_image +typedef void* GLeglImageOES; +#endif + +/* GL_OES_EGL_image_external */ +#ifndef GL_OES_EGL_image_external +/* GLeglImageOES defined in GL_OES_EGL_image already. */ +#define GL_TEXTURE_EXTERNAL_OES 0x8D65 +#define GL_SAMPLER_EXTERNAL_OES 0x8D66 +#define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67 +#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68 +#endif + +/* GL_OES_element_index_uint */ +#ifndef GL_OES_element_index_uint +#define GL_UNSIGNED_INT 0x1405 +#endif + +/* GL_OES_get_program_binary */ +#ifndef GL_OES_get_program_binary +#define GL_PROGRAM_BINARY_LENGTH_OES 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE +#define GL_PROGRAM_BINARY_FORMATS_OES 0x87FF +#endif + +/* GL_OES_mapbuffer */ +#ifndef GL_OES_mapbuffer +#define GL_WRITE_ONLY_OES 0x88B9 +#define GL_BUFFER_ACCESS_OES 0x88BB +#define GL_BUFFER_MAPPED_OES 0x88BC +#define GL_BUFFER_MAP_POINTER_OES 0x88BD +#endif + +/* GL_OES_packed_depth_stencil */ +#ifndef GL_OES_packed_depth_stencil +#define GL_DEPTH_STENCIL_OES 0x84F9 +#define GL_UNSIGNED_INT_24_8_OES 0x84FA +#define GL_DEPTH24_STENCIL8_OES 0x88F0 +#endif + +/* GL_OES_required_internalformat */ +#ifndef GL_OES_required_internalformat +#define GL_ALPHA8_OES 0x803C +#define GL_DEPTH_COMPONENT16_OES 0x81A5 +/* reuse GL_DEPTH_COMPONENT24_OES */ +/* reuse GL_DEPTH24_STENCIL8_OES */ +/* reuse GL_DEPTH_COMPONENT32_OES */ +#define GL_LUMINANCE4_ALPHA4_OES 0x8043 +#define GL_LUMINANCE8_ALPHA8_OES 0x8045 +#define GL_LUMINANCE8_OES 0x8040 +#define GL_RGBA4_OES 0x8056 +#define GL_RGB5_A1_OES 0x8057 +#define GL_RGB565_OES 0x8D62 +/* reuse GL_RGB8_OES */ +/* reuse GL_RGBA8_OES */ +/* reuse GL_RGB10_EXT */ +/* reuse GL_RGB10_A2_EXT */ +#endif + +/* GL_OES_rgb8_rgba8 */ +#ifndef GL_OES_rgb8_rgba8 +#define GL_RGB8_OES 0x8051 +#define GL_RGBA8_OES 0x8058 +#endif + +/* GL_OES_standard_derivatives */ +#ifndef GL_OES_standard_derivatives +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES 0x8B8B +#endif + +/* GL_OES_stencil1 */ +#ifndef GL_OES_stencil1 +#define GL_STENCIL_INDEX1_OES 0x8D46 +#endif + +/* GL_OES_stencil4 */ +#ifndef GL_OES_stencil4 +#define GL_STENCIL_INDEX4_OES 0x8D47 +#endif + +#ifndef GL_OES_surfaceless_context +#define GL_FRAMEBUFFER_UNDEFINED_OES 0x8219 +#endif + +/* GL_OES_texture_3D */ +#ifndef GL_OES_texture_3D +#define GL_TEXTURE_WRAP_R_OES 0x8072 +#define GL_TEXTURE_3D_OES 0x806F +#define GL_TEXTURE_BINDING_3D_OES 0x806A +#define GL_MAX_3D_TEXTURE_SIZE_OES 0x8073 +#define GL_SAMPLER_3D_OES 0x8B5F +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES 0x8CD4 +#endif + +/* GL_OES_texture_float */ +/* No new tokens introduced by this extension. */ + +/* GL_OES_texture_float_linear */ +/* No new tokens introduced by this extension. */ + +/* GL_OES_texture_half_float */ +#ifndef GL_OES_texture_half_float +#define GL_HALF_FLOAT_OES 0x8D61 +#endif + +/* GL_OES_texture_half_float_linear */ +/* No new tokens introduced by this extension. */ + +/* GL_OES_texture_npot */ +/* No new tokens introduced by this extension. */ + +/* GL_OES_vertex_array_object */ +#ifndef GL_OES_vertex_array_object +#define GL_VERTEX_ARRAY_BINDING_OES 0x85B5 +#endif + +/* GL_OES_vertex_half_float */ +/* GL_HALF_FLOAT_OES defined in GL_OES_texture_half_float already. */ + +/* GL_OES_vertex_type_10_10_10_2 */ +#ifndef GL_OES_vertex_type_10_10_10_2 +#define GL_UNSIGNED_INT_10_10_10_2_OES 0x8DF6 +#define GL_INT_10_10_10_2_OES 0x8DF7 +#endif + +/*------------------------------------------------------------------------* + * KHR extension tokens + *------------------------------------------------------------------------*/ + +#ifndef GL_KHR_debug +typedef void (GL_APIENTRYP GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +#define GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_KHR 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION_KHR 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM_KHR 0x8245 +#define GL_DEBUG_SOURCE_API_KHR 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_KHR 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER_KHR 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY_KHR 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION_KHR 0x824A +#define GL_DEBUG_SOURCE_OTHER_KHR 0x824B +#define GL_DEBUG_TYPE_ERROR_KHR 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_KHR 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_KHR 0x824E +#define GL_DEBUG_TYPE_PORTABILITY_KHR 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE_KHR 0x8250 +#define GL_DEBUG_TYPE_OTHER_KHR 0x8251 +#define GL_DEBUG_TYPE_MARKER_KHR 0x8268 +#define GL_DEBUG_TYPE_PUSH_GROUP_KHR 0x8269 +#define GL_DEBUG_TYPE_POP_GROUP_KHR 0x826A +#define GL_DEBUG_SEVERITY_NOTIFICATION_KHR 0x826B +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH_KHR 0x826C +#define GL_DEBUG_GROUP_STACK_DEPTH_KHR 0x826D +#define GL_BUFFER_KHR 0x82E0 +#define GL_SHADER_KHR 0x82E1 +#define GL_PROGRAM_KHR 0x82E2 +#define GL_QUERY_KHR 0x82E3 +/* PROGRAM_PIPELINE only in GL */ +#define GL_SAMPLER_KHR 0x82E6 +/* DISPLAY_LIST only in GL */ +#define GL_MAX_LABEL_LENGTH_KHR 0x82E8 +#define GL_MAX_DEBUG_MESSAGE_LENGTH_KHR 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_KHR 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_KHR 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_KHR 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_KHR 0x9147 +#define GL_DEBUG_SEVERITY_LOW_KHR 0x9148 +#define GL_DEBUG_OUTPUT_KHR 0x92E0 +#define GL_CONTEXT_FLAG_DEBUG_BIT_KHR 0x00000002 +#define GL_STACK_OVERFLOW_KHR 0x0503 +#define GL_STACK_UNDERFLOW_KHR 0x0504 +#endif + +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 +#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 +#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 +#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 +#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 +#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 +#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 +#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 +#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 +#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 +#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA +#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB +#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC +#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +#endif + +/*------------------------------------------------------------------------* + * AMD extension tokens + *------------------------------------------------------------------------*/ + +/* GL_AMD_compressed_3DC_texture */ +#ifndef GL_AMD_compressed_3DC_texture +#define GL_3DC_X_AMD 0x87F9 +#define GL_3DC_XY_AMD 0x87FA +#endif + +/* GL_AMD_compressed_ATC_texture */ +#ifndef GL_AMD_compressed_ATC_texture +#define GL_ATC_RGB_AMD 0x8C92 +#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93 +#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE +#endif + +/* GL_AMD_performance_monitor */ +#ifndef GL_AMD_performance_monitor +#define GL_COUNTER_TYPE_AMD 0x8BC0 +#define GL_COUNTER_RANGE_AMD 0x8BC1 +#define GL_UNSIGNED_INT64_AMD 0x8BC2 +#define GL_PERCENTAGE_AMD 0x8BC3 +#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 +#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 +#define GL_PERFMON_RESULT_AMD 0x8BC6 +#endif + +/* GL_AMD_program_binary_Z400 */ +#ifndef GL_AMD_program_binary_Z400 +#define GL_Z400_BINARY_AMD 0x8740 +#endif + +/*------------------------------------------------------------------------* + * ANGLE extension tokens + *------------------------------------------------------------------------*/ + +/* GL_ANGLE_depth_texture */ +#ifndef GL_ANGLE_depth_texture +#define GL_DEPTH_COMPONENT 0x1902 +#define GL_DEPTH_STENCIL_OES 0x84F9 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_UNSIGNED_INT 0x1405 +#define GL_UNSIGNED_INT_24_8_OES 0x84FA +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT32_OES 0x81A7 +#define GL_DEPTH24_STENCIL8_OES 0x88F0 +#endif + +/* GL_ANGLE_framebuffer_blit */ +#ifndef GL_ANGLE_framebuffer_blit +#define GL_READ_FRAMEBUFFER_ANGLE 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_ANGLE 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_ANGLE 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_ANGLE 0x8CAA +#endif + +/* GL_ANGLE_framebuffer_multisample */ +#ifndef GL_ANGLE_framebuffer_multisample +#define GL_RENDERBUFFER_SAMPLES_ANGLE 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE 0x8D56 +#define GL_MAX_SAMPLES_ANGLE 0x8D57 +#endif + +/* GL_ANGLE_instanced_arrays */ +#ifndef GL_ANGLE_instanced_arrays +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE 0x88FE +#endif + +/* GL_ANGLE_pack_reverse_row_order */ +#ifndef GL_ANGLE_pack_reverse_row_order +#define GL_PACK_REVERSE_ROW_ORDER_ANGLE 0x93A4 +#endif + +/* GL_ANGLE_program_binary */ +#ifndef GL_ANGLE_program_binary +#define GL_PROGRAM_BINARY_ANGLE 0x93A6 +#endif + +/* GL_ANGLE_texture_compression_dxt3 */ +#ifndef GL_ANGLE_texture_compression_dxt3 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2 +#endif + +/* GL_ANGLE_texture_compression_dxt5 */ +#ifndef GL_ANGLE_texture_compression_dxt5 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3 +#endif + +/* GL_ANGLE_texture_usage */ +#ifndef GL_ANGLE_texture_usage +#define GL_TEXTURE_USAGE_ANGLE 0x93A2 +#define GL_FRAMEBUFFER_ATTACHMENT_ANGLE 0x93A3 +#endif + +/* GL_ANGLE_translated_shader_source */ +#ifndef GL_ANGLE_translated_shader_source +#define GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE 0x93A0 +#endif + +/*------------------------------------------------------------------------* + * APPLE extension tokens + *------------------------------------------------------------------------*/ + +/* GL_APPLE_copy_texture_levels */ +/* No new tokens introduced by this extension. */ + +/* GL_APPLE_framebuffer_multisample */ +#ifndef GL_APPLE_framebuffer_multisample +#define GL_RENDERBUFFER_SAMPLES_APPLE 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE 0x8D56 +#define GL_MAX_SAMPLES_APPLE 0x8D57 +#define GL_READ_FRAMEBUFFER_APPLE 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_APPLE 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_APPLE 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_APPLE 0x8CAA +#endif + +/* GL_APPLE_rgb_422 */ +#ifndef GL_APPLE_rgb_422 +#define GL_RGB_422_APPLE 0x8A1F +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#endif + +/* GL_APPLE_sync */ +#ifndef GL_APPLE_sync + +#define GL_SYNC_OBJECT_APPLE 0x8A53 +#define GL_MAX_SERVER_WAIT_TIMEOUT_APPLE 0x9111 +#define GL_OBJECT_TYPE_APPLE 0x9112 +#define GL_SYNC_CONDITION_APPLE 0x9113 +#define GL_SYNC_STATUS_APPLE 0x9114 +#define GL_SYNC_FLAGS_APPLE 0x9115 +#define GL_SYNC_FENCE_APPLE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE 0x9117 +#define GL_UNSIGNALED_APPLE 0x9118 +#define GL_SIGNALED_APPLE 0x9119 +#define GL_ALREADY_SIGNALED_APPLE 0x911A +#define GL_TIMEOUT_EXPIRED_APPLE 0x911B +#define GL_CONDITION_SATISFIED_APPLE 0x911C +#define GL_WAIT_FAILED_APPLE 0x911D +#define GL_SYNC_FLUSH_COMMANDS_BIT_APPLE 0x00000001 +#define GL_TIMEOUT_IGNORED_APPLE 0xFFFFFFFFFFFFFFFFull +#endif + +/* GL_APPLE_texture_format_BGRA8888 */ +#ifndef GL_APPLE_texture_format_BGRA8888 +#define GL_BGRA_EXT 0x80E1 +#endif + +/* GL_APPLE_texture_max_level */ +#ifndef GL_APPLE_texture_max_level +#define GL_TEXTURE_MAX_LEVEL_APPLE 0x813D +#endif + +/*------------------------------------------------------------------------* + * ARM extension tokens + *------------------------------------------------------------------------*/ + +/* GL_ARM_mali_program_binary */ +#ifndef GL_ARM_mali_program_binary +#define GL_MALI_PROGRAM_BINARY_ARM 0x8F61 +#endif + +/* GL_ARM_mali_shader_binary */ +#ifndef GL_ARM_mali_shader_binary +#define GL_MALI_SHADER_BINARY_ARM 0x8F60 +#endif + +/* GL_ARM_rgba8 */ +/* No new tokens introduced by this extension. */ + +/*------------------------------------------------------------------------* + * EXT extension tokens + *------------------------------------------------------------------------*/ + +/* GL_EXT_blend_minmax */ +#ifndef GL_EXT_blend_minmax +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#endif + +/* GL_EXT_color_buffer_half_float */ +#ifndef GL_EXT_color_buffer_half_float +#define GL_RGBA16F_EXT 0x881A +#define GL_RGB16F_EXT 0x881B +#define GL_RG16F_EXT 0x822F +#define GL_R16F_EXT 0x822D +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT 0x8211 +#define GL_UNSIGNED_NORMALIZED_EXT 0x8C17 +#endif + +/* GL_EXT_debug_label */ +#ifndef GL_EXT_debug_label +#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F +#define GL_PROGRAM_OBJECT_EXT 0x8B40 +#define GL_SHADER_OBJECT_EXT 0x8B48 +#define GL_BUFFER_OBJECT_EXT 0x9151 +#define GL_QUERY_OBJECT_EXT 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154 +#endif + +/* GL_EXT_debug_marker */ +/* No new tokens introduced by this extension. */ + +/* GL_EXT_discard_framebuffer */ +#ifndef GL_EXT_discard_framebuffer +#define GL_COLOR_EXT 0x1800 +#define GL_DEPTH_EXT 0x1801 +#define GL_STENCIL_EXT 0x1802 +#endif + +#ifndef GL_EXT_disjoint_timer_query +#define GL_QUERY_COUNTER_BITS_EXT 0x8864 +#define GL_CURRENT_QUERY_EXT 0x8865 +#define GL_QUERY_RESULT_EXT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_EXT 0x8867 +#define GL_TIME_ELAPSED_EXT 0x88BF +#define GL_TIMESTAMP_EXT 0x8E28 +#define GL_GPU_DISJOINT_EXT 0x8FBB +#endif + +#ifndef GL_EXT_draw_buffers +#define GL_EXT_draw_buffers 1 +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_MAX_DRAW_BUFFERS_EXT 0x8824 +#define GL_DRAW_BUFFER0_EXT 0x8825 +#define GL_DRAW_BUFFER1_EXT 0x8826 +#define GL_DRAW_BUFFER2_EXT 0x8827 +#define GL_DRAW_BUFFER3_EXT 0x8828 +#define GL_DRAW_BUFFER4_EXT 0x8829 +#define GL_DRAW_BUFFER5_EXT 0x882A +#define GL_DRAW_BUFFER6_EXT 0x882B +#define GL_DRAW_BUFFER7_EXT 0x882C +#define GL_DRAW_BUFFER8_EXT 0x882D +#define GL_DRAW_BUFFER9_EXT 0x882E +#define GL_DRAW_BUFFER10_EXT 0x882F +#define GL_DRAW_BUFFER11_EXT 0x8830 +#define GL_DRAW_BUFFER12_EXT 0x8831 +#define GL_DRAW_BUFFER13_EXT 0x8832 +#define GL_DRAW_BUFFER14_EXT 0x8833 +#define GL_DRAW_BUFFER15_EXT 0x8834 +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#endif + +/* GL_EXT_map_buffer_range */ +#ifndef GL_EXT_map_buffer_range +#define GL_MAP_READ_BIT_EXT 0x0001 +#define GL_MAP_WRITE_BIT_EXT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT_EXT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT_EXT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT_EXT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT_EXT 0x0020 +#endif + +/* GL_EXT_multisampled_render_to_texture */ +#ifndef GL_EXT_multisampled_render_to_texture +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C +/* reuse values from GL_EXT_framebuffer_multisample (desktop extension) */ +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 +#endif + +/* GL_EXT_multiview_draw_buffers */ +#ifndef GL_EXT_multiview_draw_buffers +#define GL_COLOR_ATTACHMENT_EXT 0x90F0 +#define GL_MULTIVIEW_EXT 0x90F1 +#define GL_DRAW_BUFFER_EXT 0x0C01 +#define GL_READ_BUFFER_EXT 0x0C02 +#define GL_MAX_MULTIVIEW_BUFFERS_EXT 0x90F2 +#endif + +/* GL_EXT_multi_draw_arrays */ +/* No new tokens introduced by this extension. */ + +/* GL_EXT_occlusion_query_boolean */ +#ifndef GL_EXT_occlusion_query_boolean +#define GL_ANY_SAMPLES_PASSED_EXT 0x8C2F +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT 0x8D6A +#define GL_CURRENT_QUERY_EXT 0x8865 +#define GL_QUERY_RESULT_EXT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_EXT 0x8867 +#endif + +/* GL_EXT_read_format_bgra */ +#ifndef GL_EXT_read_format_bgra +#define GL_BGRA_EXT 0x80E1 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT 0x8366 +#endif + +/* GL_EXT_robustness */ +#ifndef GL_EXT_robustness +/* reuse GL_NO_ERROR */ +#define GL_GUILTY_CONTEXT_RESET_EXT 0x8253 +#define GL_INNOCENT_CONTEXT_RESET_EXT 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET_EXT 0x8255 +#define GL_CONTEXT_ROBUST_ACCESS_EXT 0x90F3 +#define GL_RESET_NOTIFICATION_STRATEGY_EXT 0x8256 +#define GL_LOSE_CONTEXT_ON_RESET_EXT 0x8252 +#define GL_NO_RESET_NOTIFICATION_EXT 0x8261 +#endif + +/* GL_EXT_separate_shader_objects */ +#ifndef GL_EXT_separate_shader_objects +#define GL_VERTEX_SHADER_BIT_EXT 0x00000001 +#define GL_FRAGMENT_SHADER_BIT_EXT 0x00000002 +#define GL_ALL_SHADER_BITS_EXT 0xFFFFFFFF +#define GL_PROGRAM_SEPARABLE_EXT 0x8258 +#define GL_ACTIVE_PROGRAM_EXT 0x8259 +#define GL_PROGRAM_PIPELINE_BINDING_EXT 0x825A +#endif + +/* GL_EXT_shader_framebuffer_fetch */ +#ifndef GL_EXT_shader_framebuffer_fetch +#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52 +#endif + +/* GL_EXT_shader_texture_lod */ +/* No new tokens introduced by this extension. */ + +/* GL_EXT_shadow_samplers */ +#ifndef GL_EXT_shadow_samplers +#define GL_TEXTURE_COMPARE_MODE_EXT 0x884C +#define GL_TEXTURE_COMPARE_FUNC_EXT 0x884D +#define GL_COMPARE_REF_TO_TEXTURE_EXT 0x884E +#define GL_SAMPLER_2D_SHADOW_EXT 0x8B62 +#endif + +/* GL_EXT_sRGB */ +#ifndef GL_EXT_sRGB +#define GL_SRGB_EXT 0x8C40 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT 0x8210 +#endif + +/* GL_EXT_sRGB_write_control */ +#ifndef GL_EXT_sRGB_write_control +#define GL_EXT_sRGB_write_control 1 +#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 +#endif + +/* GL_EXT_texture_compression_dxt1 */ +#ifndef GL_EXT_texture_compression_dxt1 +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#endif + +/* GL_EXT_texture_filter_anisotropic */ +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif + +/* GL_EXT_texture_format_BGRA8888 */ +#ifndef GL_EXT_texture_format_BGRA8888 +#define GL_BGRA_EXT 0x80E1 +#endif + +/* GL_EXT_texture_rg */ +#ifndef GL_EXT_texture_rg +#define GL_RED_EXT 0x1903 +#define GL_RG_EXT 0x8227 +#define GL_R8_EXT 0x8229 +#define GL_RG8_EXT 0x822B +#endif + +/* GL_EXT_texture_sRGB_decode */ +#ifndef GL_EXT_texture_sRGB_decode +#define GL_EXT_texture_sRGB_decode 1 +#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 +#define GL_DECODE_EXT 0x8A49 +#define GL_SKIP_DECODE_EXT 0x8A4A +#endif + +/* GL_EXT_texture_storage */ +#ifndef GL_EXT_texture_storage +#define GL_TEXTURE_IMMUTABLE_FORMAT_EXT 0x912F +#define GL_ALPHA8_EXT 0x803C +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_RGBA32F_EXT 0x8814 +#define GL_RGB32F_EXT 0x8815 +#define GL_ALPHA32F_EXT 0x8816 +#define GL_LUMINANCE32F_EXT 0x8818 +#define GL_LUMINANCE_ALPHA32F_EXT 0x8819 +/* reuse GL_RGBA16F_EXT */ +/* reuse GL_RGB16F_EXT */ +#define GL_ALPHA16F_EXT 0x881C +#define GL_LUMINANCE16F_EXT 0x881E +#define GL_LUMINANCE_ALPHA16F_EXT 0x881F +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGB10_EXT 0x8052 +#define GL_BGRA8_EXT 0x93A1 +#define GL_R8_EXT 0x8229 +#define GL_RG8_EXT 0x822B +#define GL_R32F_EXT 0x822E +#define GL_RG32F_EXT 0x8230 +#define GL_R16F_EXT 0x822D +#define GL_RG16F_EXT 0x822F +#endif + +/* GL_EXT_texture_type_2_10_10_10_REV */ +#ifndef GL_EXT_texture_type_2_10_10_10_REV +#define GL_UNSIGNED_INT_2_10_10_10_REV_EXT 0x8368 +#endif + +/* GL_EXT_unpack_subimage */ +#ifndef GL_EXT_unpack_subimage +#define GL_UNPACK_ROW_LENGTH_EXT 0x0CF2 +#define GL_UNPACK_SKIP_ROWS_EXT 0x0CF3 +#define GL_UNPACK_SKIP_PIXELS_EXT 0x0CF4 +#endif + +/*------------------------------------------------------------------------* + * DMP extension tokens + *------------------------------------------------------------------------*/ + +/* GL_DMP_shader_binary */ +#ifndef GL_DMP_shader_binary +#define GL_SHADER_BINARY_DMP 0x9250 +#endif + +/*------------------------------------------------------------------------* + * FJ extension tokens + *------------------------------------------------------------------------*/ + +/* GL_FJ_shader_binary_GCCSO */ +#ifndef GL_FJ_shader_binary_GCCSO +#define GL_GCCSO_SHADER_BINARY_FJ 0x9260 +#endif + +/*------------------------------------------------------------------------* + * IMG extension tokens + *------------------------------------------------------------------------*/ + +/* GL_IMG_program_binary */ +#ifndef GL_IMG_program_binary +#define GL_SGX_PROGRAM_BINARY_IMG 0x9130 +#endif + +/* GL_IMG_read_format */ +#ifndef GL_IMG_read_format +#define GL_BGRA_IMG 0x80E1 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG 0x8365 +#endif + +/* GL_IMG_shader_binary */ +#ifndef GL_IMG_shader_binary +#define GL_SGX_BINARY_IMG 0x8C0A +#endif + +/* GL_IMG_texture_compression_pvrtc */ +#ifndef GL_IMG_texture_compression_pvrtc +#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 +#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 +#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 +#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 +#endif + +/* GL_IMG_texture_compression_pvrtc2 */ +#ifndef GL_IMG_texture_compression_pvrtc2 +#define GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG 0x9137 +#define GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG 0x9138 +#endif + +/* GL_IMG_multisampled_render_to_texture */ +#ifndef GL_IMG_multisampled_render_to_texture +#define GL_RENDERBUFFER_SAMPLES_IMG 0x9133 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG 0x9134 +#define GL_MAX_SAMPLES_IMG 0x9135 +#define GL_TEXTURE_SAMPLES_IMG 0x9136 +#endif + +/*------------------------------------------------------------------------* + * NV extension tokens + *------------------------------------------------------------------------*/ + +/* GL_NV_coverage_sample */ +#ifndef GL_NV_coverage_sample +#define GL_COVERAGE_COMPONENT_NV 0x8ED0 +#define GL_COVERAGE_COMPONENT4_NV 0x8ED1 +#define GL_COVERAGE_ATTACHMENT_NV 0x8ED2 +#define GL_COVERAGE_BUFFERS_NV 0x8ED3 +#define GL_COVERAGE_SAMPLES_NV 0x8ED4 +#define GL_COVERAGE_ALL_FRAGMENTS_NV 0x8ED5 +#define GL_COVERAGE_EDGE_FRAGMENTS_NV 0x8ED6 +#define GL_COVERAGE_AUTOMATIC_NV 0x8ED7 +#define GL_COVERAGE_BUFFER_BIT_NV 0x00008000 +#endif + +/* GL_NV_depth_nonlinear */ +#ifndef GL_NV_depth_nonlinear +#define GL_DEPTH_COMPONENT16_NONLINEAR_NV 0x8E2C +#endif + +/* GL_NV_draw_buffers */ +#ifndef GL_NV_draw_buffers +#define GL_MAX_DRAW_BUFFERS_NV 0x8824 +#define GL_DRAW_BUFFER0_NV 0x8825 +#define GL_DRAW_BUFFER1_NV 0x8826 +#define GL_DRAW_BUFFER2_NV 0x8827 +#define GL_DRAW_BUFFER3_NV 0x8828 +#define GL_DRAW_BUFFER4_NV 0x8829 +#define GL_DRAW_BUFFER5_NV 0x882A +#define GL_DRAW_BUFFER6_NV 0x882B +#define GL_DRAW_BUFFER7_NV 0x882C +#define GL_DRAW_BUFFER8_NV 0x882D +#define GL_DRAW_BUFFER9_NV 0x882E +#define GL_DRAW_BUFFER10_NV 0x882F +#define GL_DRAW_BUFFER11_NV 0x8830 +#define GL_DRAW_BUFFER12_NV 0x8831 +#define GL_DRAW_BUFFER13_NV 0x8832 +#define GL_DRAW_BUFFER14_NV 0x8833 +#define GL_DRAW_BUFFER15_NV 0x8834 +#define GL_COLOR_ATTACHMENT0_NV 0x8CE0 +#define GL_COLOR_ATTACHMENT1_NV 0x8CE1 +#define GL_COLOR_ATTACHMENT2_NV 0x8CE2 +#define GL_COLOR_ATTACHMENT3_NV 0x8CE3 +#define GL_COLOR_ATTACHMENT4_NV 0x8CE4 +#define GL_COLOR_ATTACHMENT5_NV 0x8CE5 +#define GL_COLOR_ATTACHMENT6_NV 0x8CE6 +#define GL_COLOR_ATTACHMENT7_NV 0x8CE7 +#define GL_COLOR_ATTACHMENT8_NV 0x8CE8 +#define GL_COLOR_ATTACHMENT9_NV 0x8CE9 +#define GL_COLOR_ATTACHMENT10_NV 0x8CEA +#define GL_COLOR_ATTACHMENT11_NV 0x8CEB +#define GL_COLOR_ATTACHMENT12_NV 0x8CEC +#define GL_COLOR_ATTACHMENT13_NV 0x8CED +#define GL_COLOR_ATTACHMENT14_NV 0x8CEE +#define GL_COLOR_ATTACHMENT15_NV 0x8CEF +#endif + +/* GL_NV_draw_instanced */ +/* No new tokens introduced by this extension. */ + +/* GL_NV_fbo_color_attachments */ +#ifndef GL_NV_fbo_color_attachments +#define GL_MAX_COLOR_ATTACHMENTS_NV 0x8CDF +/* GL_COLOR_ATTACHMENT{0-15}_NV defined in GL_NV_draw_buffers already. */ +#endif + +/* GL_NV_fence */ +#ifndef GL_NV_fence +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +#endif + +/* GL_NV_framebuffer_blit */ +#ifndef GL_NV_framebuffer_blit +#define GL_READ_FRAMEBUFFER_NV 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_NV 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_NV 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_NV 0x8CAA +#endif + +/* GL_NV_framebuffer_multisample */ +#ifndef GL_NV_framebuffer_multisample +#define GL_RENDERBUFFER_SAMPLES_NV 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_NV 0x8D56 +#define GL_MAX_SAMPLES_NV 0x8D57 +#endif + +/* GL_NV_generate_mipmap_sRGB */ +/* No new tokens introduced by this extension. */ + +/* GL_NV_instanced_arrays */ +#ifndef GL_NV_instanced_arrays +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_NV 0x88FE +#endif + +/* GL_NV_read_buffer */ +#ifndef GL_NV_read_buffer +#define GL_READ_BUFFER_NV 0x0C02 +#endif + +/* GL_NV_read_buffer_front */ +/* No new tokens introduced by this extension. */ + +/* GL_NV_read_depth */ +/* No new tokens introduced by this extension. */ + +/* GL_NV_read_depth_stencil */ +/* No new tokens introduced by this extension. */ + +/* GL_NV_read_stencil */ +/* No new tokens introduced by this extension. */ + +/* GL_NV_shadow_samplers_array */ +#ifndef GL_NV_shadow_samplers_array +#define GL_SAMPLER_2D_ARRAY_SHADOW_NV 0x8DC4 +#endif + +/* GL_NV_shadow_samplers_cube */ +#ifndef GL_NV_shadow_samplers_cube +#define GL_SAMPLER_CUBE_SHADOW_NV 0x8DC5 +#endif + +/* GL_NV_sRGB_formats */ +#ifndef GL_NV_sRGB_formats +#define GL_SLUMINANCE_NV 0x8C46 +#define GL_SLUMINANCE_ALPHA_NV 0x8C44 +#define GL_SRGB8_NV 0x8C41 +#define GL_SLUMINANCE8_NV 0x8C47 +#define GL_SLUMINANCE8_ALPHA8_NV 0x8C45 +#define GL_COMPRESSED_SRGB_S3TC_DXT1_NV 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV 0x8C4F +#define GL_ETC1_SRGB8_NV 0x88EE +#endif + +/* GL_NV_texture_border_clamp */ +#ifndef GL_NV_texture_border_clamp +#define GL_TEXTURE_BORDER_COLOR_NV 0x1004 +#define GL_CLAMP_TO_BORDER_NV 0x812D +#endif + +/* GL_NV_texture_compression_s3tc_update */ +/* No new tokens introduced by this extension. */ + +/* GL_NV_texture_npot_2D_mipmap */ +/* No new tokens introduced by this extension. */ + +/*------------------------------------------------------------------------* + * QCOM extension tokens + *------------------------------------------------------------------------*/ + +/* GL_QCOM_alpha_test */ +#ifndef GL_QCOM_alpha_test +#define GL_ALPHA_TEST_QCOM 0x0BC0 +#define GL_ALPHA_TEST_FUNC_QCOM 0x0BC1 +#define GL_ALPHA_TEST_REF_QCOM 0x0BC2 +#endif + +/* GL_QCOM_binning_control */ +#ifndef GL_QCOM_binning_control +#define GL_BINNING_CONTROL_HINT_QCOM 0x8FB0 +#define GL_CPU_OPTIMIZED_QCOM 0x8FB1 +#define GL_GPU_OPTIMIZED_QCOM 0x8FB2 +#define GL_RENDER_DIRECT_TO_FRAMEBUFFER_QCOM 0x8FB3 +#endif + +/* GL_QCOM_driver_control */ +/* No new tokens introduced by this extension. */ + +/* GL_QCOM_extended_get */ +#ifndef GL_QCOM_extended_get +#define GL_TEXTURE_WIDTH_QCOM 0x8BD2 +#define GL_TEXTURE_HEIGHT_QCOM 0x8BD3 +#define GL_TEXTURE_DEPTH_QCOM 0x8BD4 +#define GL_TEXTURE_INTERNAL_FORMAT_QCOM 0x8BD5 +#define GL_TEXTURE_FORMAT_QCOM 0x8BD6 +#define GL_TEXTURE_TYPE_QCOM 0x8BD7 +#define GL_TEXTURE_IMAGE_VALID_QCOM 0x8BD8 +#define GL_TEXTURE_NUM_LEVELS_QCOM 0x8BD9 +#define GL_TEXTURE_TARGET_QCOM 0x8BDA +#define GL_TEXTURE_OBJECT_VALID_QCOM 0x8BDB +#define GL_STATE_RESTORE 0x8BDC +#endif + +/* GL_QCOM_extended_get2 */ +/* No new tokens introduced by this extension. */ + +/* GL_QCOM_perfmon_global_mode */ +#ifndef GL_QCOM_perfmon_global_mode +#define GL_PERFMON_GLOBAL_MODE_QCOM 0x8FA0 +#endif + +/* GL_QCOM_writeonly_rendering */ +#ifndef GL_QCOM_writeonly_rendering +#define GL_WRITEONLY_RENDERING_QCOM 0x8823 +#endif + +/* GL_QCOM_tiled_rendering */ +#ifndef GL_QCOM_tiled_rendering +#define GL_COLOR_BUFFER_BIT0_QCOM 0x00000001 +#define GL_COLOR_BUFFER_BIT1_QCOM 0x00000002 +#define GL_COLOR_BUFFER_BIT2_QCOM 0x00000004 +#define GL_COLOR_BUFFER_BIT3_QCOM 0x00000008 +#define GL_COLOR_BUFFER_BIT4_QCOM 0x00000010 +#define GL_COLOR_BUFFER_BIT5_QCOM 0x00000020 +#define GL_COLOR_BUFFER_BIT6_QCOM 0x00000040 +#define GL_COLOR_BUFFER_BIT7_QCOM 0x00000080 +#define GL_DEPTH_BUFFER_BIT0_QCOM 0x00000100 +#define GL_DEPTH_BUFFER_BIT1_QCOM 0x00000200 +#define GL_DEPTH_BUFFER_BIT2_QCOM 0x00000400 +#define GL_DEPTH_BUFFER_BIT3_QCOM 0x00000800 +#define GL_DEPTH_BUFFER_BIT4_QCOM 0x00001000 +#define GL_DEPTH_BUFFER_BIT5_QCOM 0x00002000 +#define GL_DEPTH_BUFFER_BIT6_QCOM 0x00004000 +#define GL_DEPTH_BUFFER_BIT7_QCOM 0x00008000 +#define GL_STENCIL_BUFFER_BIT0_QCOM 0x00010000 +#define GL_STENCIL_BUFFER_BIT1_QCOM 0x00020000 +#define GL_STENCIL_BUFFER_BIT2_QCOM 0x00040000 +#define GL_STENCIL_BUFFER_BIT3_QCOM 0x00080000 +#define GL_STENCIL_BUFFER_BIT4_QCOM 0x00100000 +#define GL_STENCIL_BUFFER_BIT5_QCOM 0x00200000 +#define GL_STENCIL_BUFFER_BIT6_QCOM 0x00400000 +#define GL_STENCIL_BUFFER_BIT7_QCOM 0x00800000 +#define GL_MULTISAMPLE_BUFFER_BIT0_QCOM 0x01000000 +#define GL_MULTISAMPLE_BUFFER_BIT1_QCOM 0x02000000 +#define GL_MULTISAMPLE_BUFFER_BIT2_QCOM 0x04000000 +#define GL_MULTISAMPLE_BUFFER_BIT3_QCOM 0x08000000 +#define GL_MULTISAMPLE_BUFFER_BIT4_QCOM 0x10000000 +#define GL_MULTISAMPLE_BUFFER_BIT5_QCOM 0x20000000 +#define GL_MULTISAMPLE_BUFFER_BIT6_QCOM 0x40000000 +#define GL_MULTISAMPLE_BUFFER_BIT7_QCOM 0x80000000 +#endif + +/*------------------------------------------------------------------------* + * VIV extension tokens + *------------------------------------------------------------------------*/ + +/* GL_VIV_shader_binary */ +#ifndef GL_VIV_shader_binary +#define GL_SHADER_BINARY_VIV 0x8FC4 +#endif + +/*------------------------------------------------------------------------* + * End of extension tokens, start of corresponding extension functions + *------------------------------------------------------------------------*/ + +/*------------------------------------------------------------------------* + * OES extension functions + *------------------------------------------------------------------------*/ + +/* GL_OES_compressed_ETC1_RGB8_texture */ +#ifndef GL_OES_compressed_ETC1_RGB8_texture +#define GL_OES_compressed_ETC1_RGB8_texture 1 +#endif + +/* GL_OES_compressed_paletted_texture */ +#ifndef GL_OES_compressed_paletted_texture +#define GL_OES_compressed_paletted_texture 1 +#endif + +/* GL_OES_depth24 */ +#ifndef GL_OES_depth24 +#define GL_OES_depth24 1 +#endif + +/* GL_OES_depth32 */ +#ifndef GL_OES_depth32 +#define GL_OES_depth32 1 +#endif + +/* GL_OES_depth_texture */ +#ifndef GL_OES_depth_texture +#define GL_OES_depth_texture 1 +#endif + +/* GL_OES_EGL_image */ +#ifndef GL_OES_EGL_image +#define GL_OES_EGL_image 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image); +GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image); +#endif +typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image); +typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image); +#endif + +/* GL_OES_EGL_image_external */ +#ifndef GL_OES_EGL_image_external +#define GL_OES_EGL_image_external 1 +/* glEGLImageTargetTexture2DOES defined in GL_OES_EGL_image already. */ +#endif + +/* GL_OES_element_index_uint */ +#ifndef GL_OES_element_index_uint +#define GL_OES_element_index_uint 1 +#endif + +/* GL_OES_fbo_render_mipmap */ +#ifndef GL_OES_fbo_render_mipmap +#define GL_OES_fbo_render_mipmap 1 +#endif + +/* GL_OES_fragment_precision_high */ +#ifndef GL_OES_fragment_precision_high +#define GL_OES_fragment_precision_high 1 +#endif + +/* GL_OES_get_program_binary */ +#ifndef GL_OES_get_program_binary +#define GL_OES_get_program_binary 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetProgramBinaryOES (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); +GL_APICALL void GL_APIENTRY glProgramBinaryOES (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length); +#endif +typedef void (GL_APIENTRYP PFNGLGETPROGRAMBINARYOESPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); +typedef void (GL_APIENTRYP PFNGLPROGRAMBINARYOESPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length); +#endif + +/* GL_OES_mapbuffer */ +#ifndef GL_OES_mapbuffer +#define GL_OES_mapbuffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void* GL_APIENTRY glMapBufferOES (GLenum target, GLenum access); +GL_APICALL GLboolean GL_APIENTRY glUnmapBufferOES (GLenum target); +GL_APICALL void GL_APIENTRY glGetBufferPointervOES (GLenum target, GLenum pname, GLvoid **params); +#endif +typedef void* (GL_APIENTRYP PFNGLMAPBUFFEROESPROC) (GLenum target, GLenum access); +typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFEROESPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname, GLvoid **params); +#endif + +/* GL_OES_packed_depth_stencil */ +#ifndef GL_OES_packed_depth_stencil +#define GL_OES_packed_depth_stencil 1 +#endif + +/* GL_OES_required_internalformat */ +#ifndef GL_OES_required_internalformat +#define GL_OES_required_internalformat 1 +#endif + +/* GL_OES_rgb8_rgba8 */ +#ifndef GL_OES_rgb8_rgba8 +#define GL_OES_rgb8_rgba8 1 +#endif + +/* GL_OES_standard_derivatives */ +#ifndef GL_OES_standard_derivatives +#define GL_OES_standard_derivatives 1 +#endif + +/* GL_OES_stencil1 */ +#ifndef GL_OES_stencil1 +#define GL_OES_stencil1 1 +#endif + +/* GL_OES_stencil4 */ +#ifndef GL_OES_stencil4 +#define GL_OES_stencil4 1 +#endif + +#ifndef GL_OES_surfaceless_context +#define GL_OES_surfaceless_context 1 +#endif + +/* GL_OES_texture_3D */ +#ifndef GL_OES_texture_3D +#define GL_OES_texture_3D 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels); +GL_APICALL void GL_APIENTRY glTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels); +GL_APICALL void GL_APIENTRY glCopyTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glCompressedTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data); +GL_APICALL void GL_APIENTRY glCompressedTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data); +GL_APICALL void GL_APIENTRY glFramebufferTexture3DOES (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +#endif +typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels); +typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels); +typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DOESPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +#endif + +/* GL_OES_texture_float */ +#ifndef GL_OES_texture_float +#define GL_OES_texture_float 1 +#endif + +/* GL_OES_texture_float_linear */ +#ifndef GL_OES_texture_float_linear +#define GL_OES_texture_float_linear 1 +#endif + +/* GL_OES_texture_half_float */ +#ifndef GL_OES_texture_half_float +#define GL_OES_texture_half_float 1 +#endif + +/* GL_OES_texture_half_float_linear */ +#ifndef GL_OES_texture_half_float_linear +#define GL_OES_texture_half_float_linear 1 +#endif + +/* GL_OES_texture_npot */ +#ifndef GL_OES_texture_npot +#define GL_OES_texture_npot 1 +#endif + +/* GL_OES_vertex_array_object */ +#ifndef GL_OES_vertex_array_object +#define GL_OES_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBindVertexArrayOES (GLuint array); +GL_APICALL void GL_APIENTRY glDeleteVertexArraysOES (GLsizei n, const GLuint *arrays); +GL_APICALL void GL_APIENTRY glGenVertexArraysOES (GLsizei n, GLuint *arrays); +GL_APICALL GLboolean GL_APIENTRY glIsVertexArrayOES (GLuint array); +#endif +typedef void (GL_APIENTRYP PFNGLBINDVERTEXARRAYOESPROC) (GLuint array); +typedef void (GL_APIENTRYP PFNGLDELETEVERTEXARRAYSOESPROC) (GLsizei n, const GLuint *arrays); +typedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSOESPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array); +#endif + +/* GL_OES_vertex_half_float */ +#ifndef GL_OES_vertex_half_float +#define GL_OES_vertex_half_float 1 +#endif + +/* GL_OES_vertex_type_10_10_10_2 */ +#ifndef GL_OES_vertex_type_10_10_10_2 +#define GL_OES_vertex_type_10_10_10_2 1 +#endif + +/*------------------------------------------------------------------------* + * KHR extension functions + *------------------------------------------------------------------------*/ + +#ifndef GL_KHR_debug +#define GL_KHR_debug 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDebugMessageControlKHR (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GL_APICALL void GL_APIENTRY glDebugMessageInsertKHR (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GL_APICALL void GL_APIENTRY glDebugMessageCallbackKHR (GLDEBUGPROCKHR callback, const void *userParam); +GL_APICALL GLuint GL_APIENTRY glGetDebugMessageLogKHR (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +GL_APICALL void GL_APIENTRY glPushDebugGroupKHR (GLenum source, GLuint id, GLsizei length, const GLchar *message); +GL_APICALL void GL_APIENTRY glPopDebugGroupKHR (void); +GL_APICALL void GL_APIENTRY glObjectLabelKHR (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +GL_APICALL void GL_APIENTRY glGetObjectLabelKHR (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +GL_APICALL void GL_APIENTRY glObjectPtrLabelKHR (const void *ptr, GLsizei length, const GLchar *label); +GL_APICALL void GL_APIENTRY glGetObjectPtrLabelKHR (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +GL_APICALL void GL_APIENTRY glGetPointervKHR (GLenum pname, GLvoid **params); +#endif +typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECONTROLKHRPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGEINSERTKHRPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECALLBACKKHRPROC) (GLDEBUGPROCKHR callback, const void *userParam); +typedef GLuint (GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +typedef void (GL_APIENTRYP PFNGLPUSHDEBUGGROUPKHRPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); +typedef void (GL_APIENTRYP PFNGLPOPDEBUGGROUPKHRPROC) (void); +typedef void (GL_APIENTRYP PFNGLOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (GL_APIENTRYP PFNGLOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei length, const GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETPOINTERVKHRPROC) (GLenum pname, GLvoid **params); +#endif + +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_KHR_texture_compression_astc_ldr 1 +#endif + + +/*------------------------------------------------------------------------* + * AMD extension functions + *------------------------------------------------------------------------*/ + +/* GL_AMD_compressed_3DC_texture */ +#ifndef GL_AMD_compressed_3DC_texture +#define GL_AMD_compressed_3DC_texture 1 +#endif + +/* GL_AMD_compressed_ATC_texture */ +#ifndef GL_AMD_compressed_ATC_texture +#define GL_AMD_compressed_ATC_texture 1 +#endif + +/* AMD_performance_monitor */ +#ifndef GL_AMD_performance_monitor +#define GL_AMD_performance_monitor 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +GL_APICALL void GL_APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, GLvoid *data); +GL_APICALL void GL_APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); +GL_APICALL void GL_APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); +GL_APICALL void GL_APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList); +GL_APICALL void GL_APIENTRY glBeginPerfMonitorAMD (GLuint monitor); +GL_APICALL void GL_APIENTRY glEndPerfMonitorAMD (GLuint monitor); +GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#endif +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, GLvoid *data); +typedef void (GL_APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (GL_APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (GL_APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList); +typedef void (GL_APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); +typedef void (GL_APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#endif + +/* GL_AMD_program_binary_Z400 */ +#ifndef GL_AMD_program_binary_Z400 +#define GL_AMD_program_binary_Z400 1 +#endif + +/*------------------------------------------------------------------------* + * ANGLE extension functions + *------------------------------------------------------------------------*/ + +/* GL_ANGLE_depth_texture */ +#ifndef GL_ANGLE_depth_texture +#define GL_ANGLE_depth_texture 1 +#endif + +/* GL_ANGLE_framebuffer_blit */ +#ifndef GL_ANGLE_framebuffer_blit +#define GL_ANGLE_framebuffer_blit 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBlitFramebufferANGLE (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERANGLEPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif + +/* GL_ANGLE_framebuffer_multisample */ +#ifndef GL_ANGLE_framebuffer_multisample +#define GL_ANGLE_framebuffer_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleANGLE (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif + +#ifndef GL_ANGLE_instanced_arrays +#define GL_ANGLE_instanced_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawArraysInstancedANGLE (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedANGLE (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +GL_APICALL void GL_APIENTRY glVertexAttribDivisorANGLE (GLuint index, GLuint divisor); +#endif +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDANGLEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDANGLEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLuint divisor); +#endif + +/* GL_ANGLE_pack_reverse_row_order */ +#ifndef GL_ANGLE_pack_reverse_row_order +#define GL_ANGLE_pack_reverse_row_order 1 +#endif + +/* GL_ANGLE_program_binary */ +#ifndef GL_ANGLE_program_binary +#define GL_ANGLE_program_binary 1 +#endif + +/* GL_ANGLE_texture_compression_dxt3 */ +#ifndef GL_ANGLE_texture_compression_dxt3 +#define GL_ANGLE_texture_compression_dxt3 1 +#endif + +/* GL_ANGLE_texture_compression_dxt5 */ +#ifndef GL_ANGLE_texture_compression_dxt5 +#define GL_ANGLE_texture_compression_dxt5 1 +#endif + +/* GL_ANGLE_texture_usage */ +#ifndef GL_ANGLE_texture_usage +#define GL_ANGLE_texture_usage 1 +#endif + +#ifndef GL_ANGLE_translated_shader_source +#define GL_ANGLE_translated_shader_source 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetTranslatedShaderSourceANGLE (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source); +#endif +typedef void (GL_APIENTRYP PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC) (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source); +#endif + +/*------------------------------------------------------------------------* + * APPLE extension functions + *------------------------------------------------------------------------*/ + +/* GL_APPLE_copy_texture_levels */ +#ifndef GL_APPLE_copy_texture_levels +#define GL_APPLE_copy_texture_levels 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glCopyTextureLevelsAPPLE (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount); +#endif +typedef void (GL_APIENTRYP PFNGLCOPYTEXTURELEVELSAPPLEPROC) (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount); +#endif + +/* GL_APPLE_framebuffer_multisample */ +#ifndef GL_APPLE_framebuffer_multisample +#define GL_APPLE_framebuffer_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleAPPLE (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glResolveMultisampleFramebufferAPPLE (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void); +#endif + +/* GL_APPLE_rgb_422 */ +#ifndef GL_APPLE_rgb_422 +#define GL_APPLE_rgb_422 1 +#endif + +/* GL_APPLE_sync */ +#ifndef GL_APPLE_sync +#define GL_APPLE_sync 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL GLsync GL_APIENTRY glFenceSyncAPPLE (GLenum condition, GLbitfield flags); +GL_APICALL GLboolean GL_APIENTRY glIsSyncAPPLE (GLsync sync); +GL_APICALL void GL_APIENTRY glDeleteSyncAPPLE (GLsync sync); +GL_APICALL GLenum GL_APIENTRY glClientWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glGetInteger64vAPPLE (GLenum pname, GLint64 *params); +GL_APICALL void GL_APIENTRY glGetSyncivAPPLE (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +#endif +typedef GLsync (GL_APIENTRYP PFNGLFENCESYNCAPPLEPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (GL_APIENTRYP PFNGLISSYNCAPPLEPROC) (GLsync sync); +typedef void (GL_APIENTRYP PFNGLDELETESYNCAPPLEPROC) (GLsync sync); +typedef GLenum (GL_APIENTRYP PFNGLCLIENTWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLGETINTEGER64VAPPLEPROC) (GLenum pname, GLint64 *params); +typedef void (GL_APIENTRYP PFNGLGETSYNCIVAPPLEPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +#endif + +/* GL_APPLE_texture_format_BGRA8888 */ +#ifndef GL_APPLE_texture_format_BGRA8888 +#define GL_APPLE_texture_format_BGRA8888 1 +#endif + +/* GL_APPLE_texture_max_level */ +#ifndef GL_APPLE_texture_max_level +#define GL_APPLE_texture_max_level 1 +#endif + +/*------------------------------------------------------------------------* + * ARM extension functions + *------------------------------------------------------------------------*/ + +/* GL_ARM_mali_program_binary */ +#ifndef GL_ARM_mali_program_binary +#define GL_ARM_mali_program_binary 1 +#endif + +/* GL_ARM_mali_shader_binary */ +#ifndef GL_ARM_mali_shader_binary +#define GL_ARM_mali_shader_binary 1 +#endif + +/* GL_ARM_rgba8 */ +#ifndef GL_ARM_rgba8 +#define GL_ARM_rgba8 1 +#endif + +/*------------------------------------------------------------------------* + * EXT extension functions + *------------------------------------------------------------------------*/ + +/* GL_EXT_blend_minmax */ +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#endif + +/* GL_EXT_color_buffer_half_float */ +#ifndef GL_EXT_color_buffer_half_float +#define GL_EXT_color_buffer_half_float 1 +#endif + +/* GL_EXT_debug_label */ +#ifndef GL_EXT_debug_label +#define GL_EXT_debug_label 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glLabelObjectEXT (GLenum type, GLuint object, GLsizei length, const GLchar *label); +GL_APICALL void GL_APIENTRY glGetObjectLabelEXT (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif +typedef void (GL_APIENTRYP PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif + +/* GL_EXT_debug_marker */ +#ifndef GL_EXT_debug_marker +#define GL_EXT_debug_marker 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glInsertEventMarkerEXT (GLsizei length, const GLchar *marker); +GL_APICALL void GL_APIENTRY glPushGroupMarkerEXT (GLsizei length, const GLchar *marker); +GL_APICALL void GL_APIENTRY glPopGroupMarkerEXT (void); +#endif +typedef void (GL_APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker); +typedef void (GL_APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker); +typedef void (GL_APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void); +#endif + +/* GL_EXT_discard_framebuffer */ +#ifndef GL_EXT_discard_framebuffer +#define GL_EXT_discard_framebuffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDiscardFramebufferEXT (GLenum target, GLsizei numAttachments, const GLenum *attachments); +#endif +typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); +#endif + +#ifndef GL_EXT_disjoint_timer_query +#define GL_EXT_disjoint_timer_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGenQueriesEXT (GLsizei n, GLuint *ids); +GL_APICALL void GL_APIENTRY glDeleteQueriesEXT (GLsizei n, const GLuint *ids); +GL_APICALL GLboolean GL_APIENTRY glIsQueryEXT (GLuint id); +GL_APICALL void GL_APIENTRY glBeginQueryEXT (GLenum target, GLuint id); +GL_APICALL void GL_APIENTRY glEndQueryEXT (GLenum target); +GL_APICALL void GL_APIENTRY glQueryCounterEXT (GLuint id, GLenum target); +GL_APICALL void GL_APIENTRY glGetQueryivEXT (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetQueryObjectivEXT (GLuint id, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetQueryObjectuivEXT (GLuint id, GLenum pname, GLuint *params); +GL_APICALL void GL_APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64 *params); +GL_APICALL void GL_APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64 *params); +#endif +typedef void (GL_APIENTRYP PFNGLGENQUERIESEXTPROC) (GLsizei n, GLuint *ids); +typedef void (GL_APIENTRYP PFNGLDELETEQUERIESEXTPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (GL_APIENTRYP PFNGLISQUERYEXTPROC) (GLuint id); +typedef void (GL_APIENTRYP PFNGLBEGINQUERYEXTPROC) (GLenum target, GLuint id); +typedef void (GL_APIENTRYP PFNGLENDQUERYEXTPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLQUERYCOUNTEREXTPROC) (GLuint id, GLenum target); +typedef void (GL_APIENTRYP PFNGLGETQUERYIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTIVEXTPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUIVEXTPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64 *params); +#endif /* GL_EXT_disjoint_timer_query */ + +#ifndef GL_EXT_draw_buffers +#define GL_EXT_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawBuffersEXT (GLsizei n, const GLenum *bufs); +#endif +typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSEXTPROC) (GLsizei n, const GLenum *bufs); +#endif /* GL_EXT_draw_buffers */ + +/* GL_EXT_map_buffer_range */ +#ifndef GL_EXT_map_buffer_range +#define GL_EXT_map_buffer_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void* GL_APIENTRY glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GL_APICALL void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length); +#endif +typedef void* (GL_APIENTRYP PFNGLMAPBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +#endif + +/* GL_EXT_multisampled_render_to_texture */ +#ifndef GL_EXT_multisampled_render_to_texture +#define GL_EXT_multisampled_render_to_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); +#endif +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); +#endif + +/* GL_EXT_multiview_draw_buffers */ +#ifndef GL_EXT_multiview_draw_buffers +#define GL_EXT_multiview_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glReadBufferIndexedEXT (GLenum src, GLint index); +GL_APICALL void GL_APIENTRY glDrawBuffersIndexedEXT (GLint n, const GLenum *location, const GLint *indices); +GL_APICALL void GL_APIENTRY glGetIntegeri_vEXT (GLenum target, GLuint index, GLint *data); +#endif +typedef void (GL_APIENTRYP PFNGLREADBUFFERINDEXEDEXTPROC) (GLenum src, GLint index); +typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSINDEXEDEXTPROC) (GLint n, const GLenum *location, const GLint *indices); +typedef void (GL_APIENTRYP PFNGLGETINTEGERI_VEXTPROC) (GLenum target, GLuint index, GLint *data); +#endif + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GL_APICALL void GL_APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount); +#endif + +/* GL_EXT_occlusion_query_boolean */ +#ifndef GL_EXT_occlusion_query_boolean +#define GL_EXT_occlusion_query_boolean 1 +/* All entry points also exist in GL_EXT_disjoint_timer_query */ +#endif + +/* GL_EXT_read_format_bgra */ +#ifndef GL_EXT_read_format_bgra +#define GL_EXT_read_format_bgra 1 +#endif + +/* GL_EXT_robustness */ +#ifndef GL_EXT_robustness +#define GL_EXT_robustness 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL GLenum GL_APIENTRY glGetGraphicsResetStatusEXT (void); +GL_APICALL void GL_APIENTRY glReadnPixelsEXT (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); +GL_APICALL void GL_APIENTRY glGetnUniformfvEXT (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetnUniformivEXT (GLuint program, GLint location, GLsizei bufSize, GLint *params); +#endif +typedef GLenum (GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSEXTPROC) (void); +typedef void (GL_APIENTRYP PFNGLREADNPIXELSEXTPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); +typedef void (GL_APIENTRYP PFNGLGETNUNIFORMFVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETNUNIFORMIVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +#endif + +/* GL_EXT_separate_shader_objects */ +#ifndef GL_EXT_separate_shader_objects +#define GL_EXT_separate_shader_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glUseProgramStagesEXT (GLuint pipeline, GLbitfield stages, GLuint program); +GL_APICALL void GL_APIENTRY glActiveShaderProgramEXT (GLuint pipeline, GLuint program); +GL_APICALL GLuint GL_APIENTRY glCreateShaderProgramvEXT (GLenum type, GLsizei count, const GLchar **strings); +GL_APICALL void GL_APIENTRY glBindProgramPipelineEXT (GLuint pipeline); +GL_APICALL void GL_APIENTRY glDeleteProgramPipelinesEXT (GLsizei n, const GLuint *pipelines); +GL_APICALL void GL_APIENTRY glGenProgramPipelinesEXT (GLsizei n, GLuint *pipelines); +GL_APICALL GLboolean GL_APIENTRY glIsProgramPipelineEXT (GLuint pipeline); +GL_APICALL void GL_APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); +GL_APICALL void GL_APIENTRY glGetProgramPipelineivEXT (GLuint pipeline, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint x); +GL_APICALL void GL_APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint x, GLint y); +GL_APICALL void GL_APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint x, GLint y, GLint z); +GL_APICALL void GL_APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint x, GLint y, GLint z, GLint w); +GL_APICALL void GL_APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat x); +GL_APICALL void GL_APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat x, GLfloat y); +GL_APICALL void GL_APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GL_APICALL void GL_APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glValidateProgramPipelineEXT (GLuint pipeline); +GL_APICALL void GL_APIENTRY glGetProgramPipelineInfoLogEXT (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +#endif +typedef void (GL_APIENTRYP PFNGLUSEPROGRAMSTAGESEXTPROC) (GLuint pipeline, GLbitfield stages, GLuint program); +typedef void (GL_APIENTRYP PFNGLACTIVESHADERPROGRAMEXTPROC) (GLuint pipeline, GLuint program); +typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROGRAMVEXTPROC) (GLenum type, GLsizei count, const GLchar **strings); +typedef void (GL_APIENTRYP PFNGLBINDPROGRAMPIPELINEEXTPROC) (GLuint pipeline); +typedef void (GL_APIENTRYP PFNGLDELETEPROGRAMPIPELINESEXTPROC) (GLsizei n, const GLuint *pipelines); +typedef void (GL_APIENTRYP PFNGLGENPROGRAMPIPELINESEXTPROC) (GLsizei n, GLuint *pipelines); +typedef GLboolean (GL_APIENTRYP PFNGLISPROGRAMPIPELINEEXTPROC) (GLuint pipeline); +typedef void (GL_APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEIVEXTPROC) (GLuint pipeline, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint x); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint x, GLint y); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint x, GLint y, GLint z); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint x, GLint y, GLint z, GLint w); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat x); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat x, GLfloat y); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEEXTPROC) (GLuint pipeline); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +#endif + +/* GL_EXT_shader_framebuffer_fetch */ +#ifndef GL_EXT_shader_framebuffer_fetch +#define GL_EXT_shader_framebuffer_fetch 1 +#endif + +/* GL_EXT_shader_texture_lod */ +#ifndef GL_EXT_shader_texture_lod +#define GL_EXT_shader_texture_lod 1 +#endif + +/* GL_EXT_shadow_samplers */ +#ifndef GL_EXT_shadow_samplers +#define GL_EXT_shadow_samplers 1 +#endif + +/* GL_EXT_sRGB */ +#ifndef GL_EXT_sRGB +#define GL_EXT_sRGB 1 +#endif + +/* GL_EXT_texture_compression_dxt1 */ +#ifndef GL_EXT_texture_compression_dxt1 +#define GL_EXT_texture_compression_dxt1 1 +#endif + +/* GL_EXT_texture_filter_anisotropic */ +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#endif + +/* GL_EXT_texture_format_BGRA8888 */ +#ifndef GL_EXT_texture_format_BGRA8888 +#define GL_EXT_texture_format_BGRA8888 1 +#endif + +/* GL_EXT_texture_rg */ +#ifndef GL_EXT_texture_rg +#define GL_EXT_texture_rg 1 +#endif + +/* GL_EXT_texture_storage */ +#ifndef GL_EXT_texture_storage +#define GL_EXT_texture_storage 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexStorage1DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GL_APICALL void GL_APIENTRY glTexStorage2DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glTexStorage3DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GL_APICALL void GL_APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GL_APICALL void GL_APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#endif +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#endif + +/* GL_EXT_texture_type_2_10_10_10_REV */ +#ifndef GL_EXT_texture_type_2_10_10_10_REV +#define GL_EXT_texture_type_2_10_10_10_REV 1 +#endif + +/* GL_EXT_unpack_subimage */ +#ifndef GL_EXT_unpack_subimage +#define GL_EXT_unpack_subimage 1 +#endif + +/*------------------------------------------------------------------------* + * DMP extension functions + *------------------------------------------------------------------------*/ + +/* GL_DMP_shader_binary */ +#ifndef GL_DMP_shader_binary +#define GL_DMP_shader_binary 1 +#endif + +/*------------------------------------------------------------------------* + * FJ extension functions + *------------------------------------------------------------------------*/ + +/* GL_FJ_shader_binary_GCCSO */ +#ifndef GL_FJ_shader_binary_GCCSO +#define GL_FJ_shader_binary_GCCSO 1 +#endif + +/*------------------------------------------------------------------------* + * IMG extension functions + *------------------------------------------------------------------------*/ + +/* GL_IMG_program_binary */ +#ifndef GL_IMG_program_binary +#define GL_IMG_program_binary 1 +#endif + +/* GL_IMG_read_format */ +#ifndef GL_IMG_read_format +#define GL_IMG_read_format 1 +#endif + +/* GL_IMG_shader_binary */ +#ifndef GL_IMG_shader_binary +#define GL_IMG_shader_binary 1 +#endif + +/* GL_IMG_texture_compression_pvrtc */ +#ifndef GL_IMG_texture_compression_pvrtc +#define GL_IMG_texture_compression_pvrtc 1 +#endif + +/* GL_IMG_texture_compression_pvrtc2 */ +#ifndef GL_IMG_texture_compression_pvrtc2 +#define GL_IMG_texture_compression_pvrtc2 1 +#endif + +/* GL_IMG_multisampled_render_to_texture */ +#ifndef GL_IMG_multisampled_render_to_texture +#define GL_IMG_multisampled_render_to_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); +#endif +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMGPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMGPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); +#endif + +/*------------------------------------------------------------------------* + * NV extension functions + *------------------------------------------------------------------------*/ + +/* GL_NV_coverage_sample */ +#ifndef GL_NV_coverage_sample +#define GL_NV_coverage_sample 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glCoverageMaskNV (GLboolean mask); +GL_APICALL void GL_APIENTRY glCoverageOperationNV (GLenum operation); +#endif +typedef void (GL_APIENTRYP PFNGLCOVERAGEMASKNVPROC) (GLboolean mask); +typedef void (GL_APIENTRYP PFNGLCOVERAGEOPERATIONNVPROC) (GLenum operation); +#endif + +/* GL_NV_depth_nonlinear */ +#ifndef GL_NV_depth_nonlinear +#define GL_NV_depth_nonlinear 1 +#endif + +/* GL_NV_draw_buffers */ +#ifndef GL_NV_draw_buffers +#define GL_NV_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawBuffersNV (GLsizei n, const GLenum *bufs); +#endif +typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSNVPROC) (GLsizei n, const GLenum *bufs); +#endif + +/* GL_NV_draw_instanced */ +#ifndef GL_NV_draw_instanced +#define GL_NV_draw_instanced 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawArraysInstancedNV (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedNV (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDNVPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDNVPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif + +/* GL_NV_fbo_color_attachments */ +#ifndef GL_NV_fbo_color_attachments +#define GL_NV_fbo_color_attachments 1 +#endif + +/* GL_NV_fence */ +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); +GL_APICALL void GL_APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); +GL_APICALL GLboolean GL_APIENTRY glIsFenceNV (GLuint fence); +GL_APICALL GLboolean GL_APIENTRY glTestFenceNV (GLuint fence); +GL_APICALL void GL_APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glFinishFenceNV (GLuint fence); +GL_APICALL void GL_APIENTRY glSetFenceNV (GLuint fence, GLenum condition); +#endif +typedef void (GL_APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (GL_APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (GL_APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (GL_APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (GL_APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (GL_APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#endif + +/* GL_NV_framebuffer_blit */ +#ifndef GL_NV_framebuffer_blit +#define GL_NV_framebuffer_blit 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBlitFramebufferNV (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERNVPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif + +/* GL_NV_framebuffer_multisample */ +#ifndef GL_NV_framebuffer_multisample +#define GL_NV_framebuffer_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleNV ( GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLENVPROC) ( GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif + +/* GL_NV_generate_mipmap_sRGB */ +#ifndef GL_NV_generate_mipmap_sRGB +#define GL_NV_generate_mipmap_sRGB 1 +#endif + +/* GL_NV_instanced_arrays */ +#ifndef GL_NV_instanced_arrays +#define GL_NV_instanced_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glVertexAttribDivisorNV (GLuint index, GLuint divisor); +#endif +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORNVPROC) (GLuint index, GLuint divisor); +#endif + +/* GL_NV_read_buffer */ +#ifndef GL_NV_read_buffer +#define GL_NV_read_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glReadBufferNV (GLenum mode); +#endif +typedef void (GL_APIENTRYP PFNGLREADBUFFERNVPROC) (GLenum mode); +#endif + +/* GL_NV_read_buffer_front */ +#ifndef GL_NV_read_buffer_front +#define GL_NV_read_buffer_front 1 +#endif + +/* GL_NV_read_depth */ +#ifndef GL_NV_read_depth +#define GL_NV_read_depth 1 +#endif + +/* GL_NV_read_depth_stencil */ +#ifndef GL_NV_read_depth_stencil +#define GL_NV_read_depth_stencil 1 +#endif + +/* GL_NV_read_stencil */ +#ifndef GL_NV_read_stencil +#define GL_NV_read_stencil 1 +#endif + +/* GL_NV_shadow_samplers_array */ +#ifndef GL_NV_shadow_samplers_array +#define GL_NV_shadow_samplers_array 1 +#endif + +/* GL_NV_shadow_samplers_cube */ +#ifndef GL_NV_shadow_samplers_cube +#define GL_NV_shadow_samplers_cube 1 +#endif + +/* GL_NV_sRGB_formats */ +#ifndef GL_NV_sRGB_formats +#define GL_NV_sRGB_formats 1 +#endif + +/* GL_NV_texture_border_clamp */ +#ifndef GL_NV_texture_border_clamp +#define GL_NV_texture_border_clamp 1 +#endif + +/* GL_NV_texture_compression_s3tc_update */ +#ifndef GL_NV_texture_compression_s3tc_update +#define GL_NV_texture_compression_s3tc_update 1 +#endif + +/* GL_NV_texture_npot_2D_mipmap */ +#ifndef GL_NV_texture_npot_2D_mipmap +#define GL_NV_texture_npot_2D_mipmap 1 +#endif + +/*------------------------------------------------------------------------* + * QCOM extension functions + *------------------------------------------------------------------------*/ + +/* GL_QCOM_alpha_test */ +#ifndef GL_QCOM_alpha_test +#define GL_QCOM_alpha_test 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glAlphaFuncQCOM (GLenum func, GLclampf ref); +#endif +typedef void (GL_APIENTRYP PFNGLALPHAFUNCQCOMPROC) (GLenum func, GLclampf ref); +#endif + +/* GL_QCOM_binning_control */ +#ifndef GL_QCOM_binning_control +#define GL_QCOM_binning_control 1 +#endif + +/* GL_QCOM_driver_control */ +#ifndef GL_QCOM_driver_control +#define GL_QCOM_driver_control 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetDriverControlsQCOM (GLint *num, GLsizei size, GLuint *driverControls); +GL_APICALL void GL_APIENTRY glGetDriverControlStringQCOM (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString); +GL_APICALL void GL_APIENTRY glEnableDriverControlQCOM (GLuint driverControl); +GL_APICALL void GL_APIENTRY glDisableDriverControlQCOM (GLuint driverControl); +#endif +typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSQCOMPROC) (GLint *num, GLsizei size, GLuint *driverControls); +typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSTRINGQCOMPROC) (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString); +typedef void (GL_APIENTRYP PFNGLENABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl); +typedef void (GL_APIENTRYP PFNGLDISABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl); +#endif + +/* GL_QCOM_extended_get */ +#ifndef GL_QCOM_extended_get +#define GL_QCOM_extended_get 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glExtGetTexturesQCOM (GLuint *textures, GLint maxTextures, GLint *numTextures); +GL_APICALL void GL_APIENTRY glExtGetBuffersQCOM (GLuint *buffers, GLint maxBuffers, GLint *numBuffers); +GL_APICALL void GL_APIENTRY glExtGetRenderbuffersQCOM (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers); +GL_APICALL void GL_APIENTRY glExtGetFramebuffersQCOM (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers); +GL_APICALL void GL_APIENTRY glExtGetTexLevelParameterivQCOM (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glExtTexObjectStateOverrideiQCOM (GLenum target, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glExtGetTexSubImageQCOM (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels); +GL_APICALL void GL_APIENTRY glExtGetBufferPointervQCOM (GLenum target, GLvoid **params); +#endif +typedef void (GL_APIENTRYP PFNGLEXTGETTEXTURESQCOMPROC) (GLuint *textures, GLint maxTextures, GLint *numTextures); +typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERSQCOMPROC) (GLuint *buffers, GLint maxBuffers, GLint *numBuffers); +typedef void (GL_APIENTRYP PFNGLEXTGETRENDERBUFFERSQCOMPROC) (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers); +typedef void (GL_APIENTRYP PFNGLEXTGETFRAMEBUFFERSQCOMPROC) (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers); +typedef void (GL_APIENTRYP PFNGLEXTGETTEXLEVELPARAMETERIVQCOMPROC) (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLEXTTEXOBJECTSTATEOVERRIDEIQCOMPROC) (GLenum target, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLEXTGETTEXSUBIMAGEQCOMPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels); +typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERPOINTERVQCOMPROC) (GLenum target, GLvoid **params); +#endif + +/* GL_QCOM_extended_get2 */ +#ifndef GL_QCOM_extended_get2 +#define GL_QCOM_extended_get2 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glExtGetShadersQCOM (GLuint *shaders, GLint maxShaders, GLint *numShaders); +GL_APICALL void GL_APIENTRY glExtGetProgramsQCOM (GLuint *programs, GLint maxPrograms, GLint *numPrograms); +GL_APICALL GLboolean GL_APIENTRY glExtIsProgramBinaryQCOM (GLuint program); +GL_APICALL void GL_APIENTRY glExtGetProgramBinarySourceQCOM (GLuint program, GLenum shadertype, GLchar *source, GLint *length); +#endif +typedef void (GL_APIENTRYP PFNGLEXTGETSHADERSQCOMPROC) (GLuint *shaders, GLint maxShaders, GLint *numShaders); +typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMSQCOMPROC) (GLuint *programs, GLint maxPrograms, GLint *numPrograms); +typedef GLboolean (GL_APIENTRYP PFNGLEXTISPROGRAMBINARYQCOMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMBINARYSOURCEQCOMPROC) (GLuint program, GLenum shadertype, GLchar *source, GLint *length); +#endif + +/* GL_QCOM_perfmon_global_mode */ +#ifndef GL_QCOM_perfmon_global_mode +#define GL_QCOM_perfmon_global_mode 1 +#endif + +/* GL_QCOM_writeonly_rendering */ +#ifndef GL_QCOM_writeonly_rendering +#define GL_QCOM_writeonly_rendering 1 +#endif + +/* GL_QCOM_tiled_rendering */ +#ifndef GL_QCOM_tiled_rendering +#define GL_QCOM_tiled_rendering 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glStartTilingQCOM (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask); +GL_APICALL void GL_APIENTRY glEndTilingQCOM (GLbitfield preserveMask); +#endif +typedef void (GL_APIENTRYP PFNGLSTARTTILINGQCOMPROC) (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask); +typedef void (GL_APIENTRYP PFNGLENDTILINGQCOMPROC) (GLbitfield preserveMask); +#endif + +/*------------------------------------------------------------------------* + * VIV extension tokens + *------------------------------------------------------------------------*/ + +/* GL_VIV_shader_binary */ +#ifndef GL_VIV_shader_binary +#define GL_VIV_shader_binary 1 +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* __gl2ext_h_ */ diff --git a/thirdparty/include/SDL2/SDL_opengles2_gl2platform.h b/thirdparty/include/SDL2/SDL_opengles2_gl2platform.h new file mode 100644 index 000000000..c325686f0 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_opengles2_gl2platform.h @@ -0,0 +1,30 @@ +#ifndef __gl2platform_h_ +#define __gl2platform_h_ + +/* $Revision: 10602 $ on $Date:: 2010-03-04 22:35:34 -0800 #$ */ + +/* + * This document is licensed under the SGI Free Software B License Version + * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . + */ + +/* Platform-specific types and definitions for OpenGL ES 2.X gl2.h + * + * Adopters may modify khrplatform.h and this file to suit their platform. + * You are encouraged to submit all modifications to the Khronos group so that + * they can be included in future versions of this file. Please submit changes + * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) + * by filing a bug against product "OpenGL-ES" component "Registry". + */ + +/*#include */ + +#ifndef GL_APICALL +#define GL_APICALL KHRONOS_APICALL +#endif + +#ifndef GL_APIENTRY +#define GL_APIENTRY KHRONOS_APIENTRY +#endif + +#endif /* __gl2platform_h_ */ diff --git a/thirdparty/include/SDL2/SDL_opengles2_khrplatform.h b/thirdparty/include/SDL2/SDL_opengles2_khrplatform.h new file mode 100644 index 000000000..c9e6f17d3 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_opengles2_khrplatform.h @@ -0,0 +1,282 @@ +#ifndef __khrplatform_h_ +#define __khrplatform_h_ + +/* +** Copyright (c) 2008-2009 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are 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 Materials. +** +** THE MATERIALS ARE 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 +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Khronos platform-specific types and definitions. + * + * $Revision: 23298 $ on $Date: 2013-09-30 17:07:13 -0700 (Mon, 30 Sep 2013) $ + * + * Adopters may modify this file to suit their platform. Adopters are + * encouraged to submit platform specific modifications to the Khronos + * group so that they can be included in future versions of this file. + * Please submit changes by sending them to the public Khronos Bugzilla + * (http://khronos.org/bugzilla) by filing a bug against product + * "Khronos (general)" component "Registry". + * + * A predefined template which fills in some of the bug fields can be + * reached using http://tinyurl.com/khrplatform-h-bugreport, but you + * must create a Bugzilla login first. + * + * + * See the Implementer's Guidelines for information about where this file + * should be located on your system and for more details of its use: + * http://www.khronos.org/registry/implementers_guide.pdf + * + * This file should be included as + * #include + * by Khronos client API header files that use its types and defines. + * + * The types in khrplatform.h should only be used to define API-specific types. + * + * Types defined in khrplatform.h: + * khronos_int8_t signed 8 bit + * khronos_uint8_t unsigned 8 bit + * khronos_int16_t signed 16 bit + * khronos_uint16_t unsigned 16 bit + * khronos_int32_t signed 32 bit + * khronos_uint32_t unsigned 32 bit + * khronos_int64_t signed 64 bit + * khronos_uint64_t unsigned 64 bit + * khronos_intptr_t signed same number of bits as a pointer + * khronos_uintptr_t unsigned same number of bits as a pointer + * khronos_ssize_t signed size + * khronos_usize_t unsigned size + * khronos_float_t signed 32 bit floating point + * khronos_time_ns_t unsigned 64 bit time in nanoseconds + * khronos_utime_nanoseconds_t unsigned time interval or absolute time in + * nanoseconds + * khronos_stime_nanoseconds_t signed time interval in nanoseconds + * khronos_boolean_enum_t enumerated boolean type. This should + * only be used as a base type when a client API's boolean type is + * an enum. Client APIs which use an integer or other type for + * booleans cannot use this as the base type for their boolean. + * + * Tokens defined in khrplatform.h: + * + * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. + * + * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. + * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. + * + * Calling convention macros defined in this file: + * KHRONOS_APICALL + * KHRONOS_APIENTRY + * KHRONOS_APIATTRIBUTES + * + * These may be used in function prototypes as: + * + * KHRONOS_APICALL void KHRONOS_APIENTRY funcname( + * int arg1, + * int arg2) KHRONOS_APIATTRIBUTES; + */ + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APICALL + *------------------------------------------------------------------------- + * This precedes the return type of the function in the function prototype. + */ +#if defined(_WIN32) && !defined(__SCITECH_SNAP__) +# define KHRONOS_APICALL __declspec(dllimport) +#elif defined (__SYMBIAN32__) +# define KHRONOS_APICALL IMPORT_C +#else +# define KHRONOS_APICALL +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APIENTRY + *------------------------------------------------------------------------- + * This follows the return type of the function and precedes the function + * name in the function prototype. + */ +#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) + /* Win32 but not WinCE */ +# define KHRONOS_APIENTRY __stdcall +#else +# define KHRONOS_APIENTRY +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APIATTRIBUTES + *------------------------------------------------------------------------- + * This follows the closing parenthesis of the function prototype arguments. + */ +#if defined (__ARMCC_2__) +#define KHRONOS_APIATTRIBUTES __softfp +#else +#define KHRONOS_APIATTRIBUTES +#endif + +/*------------------------------------------------------------------------- + * basic type definitions + *-----------------------------------------------------------------------*/ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) + + +/* + * Using + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__VMS ) || defined(__sgi) + +/* + * Using + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(_WIN32) && !defined(__SCITECH_SNAP__) + +/* + * Win32 + */ +typedef __int32 khronos_int32_t; +typedef unsigned __int32 khronos_uint32_t; +typedef __int64 khronos_int64_t; +typedef unsigned __int64 khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__sun__) || defined(__digital__) + +/* + * Sun or Digital + */ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#if defined(__arch64__) || defined(_LP64) +typedef long int khronos_int64_t; +typedef unsigned long int khronos_uint64_t; +#else +typedef long long int khronos_int64_t; +typedef unsigned long long int khronos_uint64_t; +#endif /* __arch64__ */ +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif 0 + +/* + * Hypothetical platform with no float or int64 support + */ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#define KHRONOS_SUPPORT_INT64 0 +#define KHRONOS_SUPPORT_FLOAT 0 + +#else + +/* + * Generic fallback + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#endif + + +/* + * Types that are (so far) the same on all platforms + */ +typedef signed char khronos_int8_t; +typedef unsigned char khronos_uint8_t; +typedef signed short int khronos_int16_t; +typedef unsigned short int khronos_uint16_t; + +/* + * Types that differ between LLP64 and LP64 architectures - in LLP64, + * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears + * to be the only LLP64 architecture in current use. + */ +#ifdef _WIN64 +typedef signed long long int khronos_intptr_t; +typedef unsigned long long int khronos_uintptr_t; +typedef signed long long int khronos_ssize_t; +typedef unsigned long long int khronos_usize_t; +#else +typedef signed long int khronos_intptr_t; +typedef unsigned long int khronos_uintptr_t; +typedef signed long int khronos_ssize_t; +typedef unsigned long int khronos_usize_t; +#endif + +#if KHRONOS_SUPPORT_FLOAT +/* + * Float type + */ +typedef float khronos_float_t; +#endif + +#if KHRONOS_SUPPORT_INT64 +/* Time types + * + * These types can be used to represent a time interval in nanoseconds or + * an absolute Unadjusted System Time. Unadjusted System Time is the number + * of nanoseconds since some arbitrary system event (e.g. since the last + * time the system booted). The Unadjusted System Time is an unsigned + * 64 bit value that wraps back to 0 every 584 years. Time intervals + * may be either signed or unsigned. + */ +typedef khronos_uint64_t khronos_utime_nanoseconds_t; +typedef khronos_int64_t khronos_stime_nanoseconds_t; +#endif + +/* + * Dummy value used to pad enum types to 32 bits. + */ +#ifndef KHRONOS_MAX_ENUM +#define KHRONOS_MAX_ENUM 0x7FFFFFFF +#endif + +/* + * Enumerated boolean type + * + * Values other than zero should be considered to be true. Therefore + * comparisons should not be made against KHRONOS_TRUE. + */ +typedef enum { + KHRONOS_FALSE = 0, + KHRONOS_TRUE = 1, + KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM +} khronos_boolean_enum_t; + +#endif /* __khrplatform_h_ */ diff --git a/thirdparty/include/SDL2/SDL_pixels.h b/thirdparty/include/SDL2/SDL_pixels.h new file mode 100644 index 000000000..1b119e47b --- /dev/null +++ b/thirdparty/include/SDL2/SDL_pixels.h @@ -0,0 +1,473 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_pixels.h + * + * Header for the enumerated pixel format definitions. + */ + +#ifndef SDL_pixels_h_ +#define SDL_pixels_h_ + +#include "SDL_stdinc.h" +#include "SDL_endian.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \name Transparency definitions + * + * These define alpha as the opacity of a surface. + */ +/* @{ */ +#define SDL_ALPHA_OPAQUE 255 +#define SDL_ALPHA_TRANSPARENT 0 +/* @} */ + +/** Pixel type. */ +typedef enum +{ + SDL_PIXELTYPE_UNKNOWN, + SDL_PIXELTYPE_INDEX1, + SDL_PIXELTYPE_INDEX4, + SDL_PIXELTYPE_INDEX8, + SDL_PIXELTYPE_PACKED8, + SDL_PIXELTYPE_PACKED16, + SDL_PIXELTYPE_PACKED32, + SDL_PIXELTYPE_ARRAYU8, + SDL_PIXELTYPE_ARRAYU16, + SDL_PIXELTYPE_ARRAYU32, + SDL_PIXELTYPE_ARRAYF16, + SDL_PIXELTYPE_ARRAYF32 +} SDL_PixelType; + +/** Bitmap pixel order, high bit -> low bit. */ +typedef enum +{ + SDL_BITMAPORDER_NONE, + SDL_BITMAPORDER_4321, + SDL_BITMAPORDER_1234 +} SDL_BitmapOrder; + +/** Packed component order, high bit -> low bit. */ +typedef enum +{ + SDL_PACKEDORDER_NONE, + SDL_PACKEDORDER_XRGB, + SDL_PACKEDORDER_RGBX, + SDL_PACKEDORDER_ARGB, + SDL_PACKEDORDER_RGBA, + SDL_PACKEDORDER_XBGR, + SDL_PACKEDORDER_BGRX, + SDL_PACKEDORDER_ABGR, + SDL_PACKEDORDER_BGRA +} SDL_PackedOrder; + +/** Array component order, low byte -> high byte. */ +/* !!! FIXME: in 2.1, make these not overlap differently with + !!! FIXME: SDL_PACKEDORDER_*, so we can simplify SDL_ISPIXELFORMAT_ALPHA */ +typedef enum +{ + SDL_ARRAYORDER_NONE, + SDL_ARRAYORDER_RGB, + SDL_ARRAYORDER_RGBA, + SDL_ARRAYORDER_ARGB, + SDL_ARRAYORDER_BGR, + SDL_ARRAYORDER_BGRA, + SDL_ARRAYORDER_ABGR +} SDL_ArrayOrder; + +/** Packed component layout. */ +typedef enum +{ + SDL_PACKEDLAYOUT_NONE, + SDL_PACKEDLAYOUT_332, + SDL_PACKEDLAYOUT_4444, + SDL_PACKEDLAYOUT_1555, + SDL_PACKEDLAYOUT_5551, + SDL_PACKEDLAYOUT_565, + SDL_PACKEDLAYOUT_8888, + SDL_PACKEDLAYOUT_2101010, + SDL_PACKEDLAYOUT_1010102 +} SDL_PackedLayout; + +#define SDL_DEFINE_PIXELFOURCC(A, B, C, D) SDL_FOURCC(A, B, C, D) + +#define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \ + ((1 << 28) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \ + ((bits) << 8) | ((bytes) << 0)) + +#define SDL_PIXELFLAG(X) (((X) >> 28) & 0x0F) +#define SDL_PIXELTYPE(X) (((X) >> 24) & 0x0F) +#define SDL_PIXELORDER(X) (((X) >> 20) & 0x0F) +#define SDL_PIXELLAYOUT(X) (((X) >> 16) & 0x0F) +#define SDL_BITSPERPIXEL(X) (((X) >> 8) & 0xFF) +#define SDL_BYTESPERPIXEL(X) \ + (SDL_ISPIXELFORMAT_FOURCC(X) ? \ + ((((X) == SDL_PIXELFORMAT_YUY2) || \ + ((X) == SDL_PIXELFORMAT_UYVY) || \ + ((X) == SDL_PIXELFORMAT_YVYU)) ? 2 : 1) : (((X) >> 0) & 0xFF)) + +#define SDL_ISPIXELFORMAT_INDEXED(format) \ + (!SDL_ISPIXELFORMAT_FOURCC(format) && \ + ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8))) + +#define SDL_ISPIXELFORMAT_PACKED(format) \ + (!SDL_ISPIXELFORMAT_FOURCC(format) && \ + ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED8) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED16) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_PACKED32))) + +#define SDL_ISPIXELFORMAT_ARRAY(format) \ + (!SDL_ISPIXELFORMAT_FOURCC(format) && \ + ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU8) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU16) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYU32) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF16) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_ARRAYF32))) + +#define SDL_ISPIXELFORMAT_ALPHA(format) \ + ((SDL_ISPIXELFORMAT_PACKED(format) && \ + ((SDL_PIXELORDER(format) == SDL_PACKEDORDER_ARGB) || \ + (SDL_PIXELORDER(format) == SDL_PACKEDORDER_RGBA) || \ + (SDL_PIXELORDER(format) == SDL_PACKEDORDER_ABGR) || \ + (SDL_PIXELORDER(format) == SDL_PACKEDORDER_BGRA))) || \ + (SDL_ISPIXELFORMAT_ARRAY(format) && \ + ((SDL_PIXELORDER(format) == SDL_ARRAYORDER_ARGB) || \ + (SDL_PIXELORDER(format) == SDL_ARRAYORDER_RGBA) || \ + (SDL_PIXELORDER(format) == SDL_ARRAYORDER_ABGR) || \ + (SDL_PIXELORDER(format) == SDL_ARRAYORDER_BGRA)))) + +/* The flag is set to 1 because 0x1? is not in the printable ASCII range */ +#define SDL_ISPIXELFORMAT_FOURCC(format) \ + ((format) && (SDL_PIXELFLAG(format) != 1)) + +/* Note: If you modify this list, update SDL_GetPixelFormatName() */ +typedef enum +{ + SDL_PIXELFORMAT_UNKNOWN, + SDL_PIXELFORMAT_INDEX1LSB = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_4321, 0, + 1, 0), + SDL_PIXELFORMAT_INDEX1MSB = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_1234, 0, + 1, 0), + SDL_PIXELFORMAT_INDEX4LSB = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_4321, 0, + 4, 0), + SDL_PIXELFORMAT_INDEX4MSB = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_1234, 0, + 4, 0), + SDL_PIXELFORMAT_INDEX8 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX8, 0, 0, 8, 1), + SDL_PIXELFORMAT_RGB332 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED8, SDL_PACKEDORDER_XRGB, + SDL_PACKEDLAYOUT_332, 8, 1), + SDL_PIXELFORMAT_RGB444 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, + SDL_PACKEDLAYOUT_4444, 12, 2), + SDL_PIXELFORMAT_BGR444 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, + SDL_PACKEDLAYOUT_4444, 12, 2), + SDL_PIXELFORMAT_RGB555 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, + SDL_PACKEDLAYOUT_1555, 15, 2), + SDL_PIXELFORMAT_BGR555 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, + SDL_PACKEDLAYOUT_1555, 15, 2), + SDL_PIXELFORMAT_ARGB4444 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB, + SDL_PACKEDLAYOUT_4444, 16, 2), + SDL_PIXELFORMAT_RGBA4444 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA, + SDL_PACKEDLAYOUT_4444, 16, 2), + SDL_PIXELFORMAT_ABGR4444 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR, + SDL_PACKEDLAYOUT_4444, 16, 2), + SDL_PIXELFORMAT_BGRA4444 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA, + SDL_PACKEDLAYOUT_4444, 16, 2), + SDL_PIXELFORMAT_ARGB1555 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ARGB, + SDL_PACKEDLAYOUT_1555, 16, 2), + SDL_PIXELFORMAT_RGBA5551 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_RGBA, + SDL_PACKEDLAYOUT_5551, 16, 2), + SDL_PIXELFORMAT_ABGR1555 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_ABGR, + SDL_PACKEDLAYOUT_1555, 16, 2), + SDL_PIXELFORMAT_BGRA5551 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_BGRA, + SDL_PACKEDLAYOUT_5551, 16, 2), + SDL_PIXELFORMAT_RGB565 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XRGB, + SDL_PACKEDLAYOUT_565, 16, 2), + SDL_PIXELFORMAT_BGR565 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED16, SDL_PACKEDORDER_XBGR, + SDL_PACKEDLAYOUT_565, 16, 2), + SDL_PIXELFORMAT_RGB24 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_RGB, 0, + 24, 3), + SDL_PIXELFORMAT_BGR24 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_ARRAYU8, SDL_ARRAYORDER_BGR, 0, + 24, 3), + SDL_PIXELFORMAT_RGB888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB, + SDL_PACKEDLAYOUT_8888, 24, 4), + SDL_PIXELFORMAT_RGBX8888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBX, + SDL_PACKEDLAYOUT_8888, 24, 4), + SDL_PIXELFORMAT_BGR888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XBGR, + SDL_PACKEDLAYOUT_8888, 24, 4), + SDL_PIXELFORMAT_BGRX8888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRX, + SDL_PACKEDLAYOUT_8888, 24, 4), + SDL_PIXELFORMAT_ARGB8888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB, + SDL_PACKEDLAYOUT_8888, 32, 4), + SDL_PIXELFORMAT_RGBA8888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBA, + SDL_PACKEDLAYOUT_8888, 32, 4), + SDL_PIXELFORMAT_ABGR8888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ABGR, + SDL_PACKEDLAYOUT_8888, 32, 4), + SDL_PIXELFORMAT_BGRA8888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRA, + SDL_PACKEDLAYOUT_8888, 32, 4), + SDL_PIXELFORMAT_ARGB2101010 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB, + SDL_PACKEDLAYOUT_2101010, 32, 4), + + /* Aliases for RGBA byte arrays of color data, for the current platform */ +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + SDL_PIXELFORMAT_RGBA32 = SDL_PIXELFORMAT_RGBA8888, + SDL_PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_ARGB8888, + SDL_PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_BGRA8888, + SDL_PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_ABGR8888, +#else + SDL_PIXELFORMAT_RGBA32 = SDL_PIXELFORMAT_ABGR8888, + SDL_PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_BGRA8888, + SDL_PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_ARGB8888, + SDL_PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_RGBA8888, +#endif + + SDL_PIXELFORMAT_YV12 = /**< Planar mode: Y + V + U (3 planes) */ + SDL_DEFINE_PIXELFOURCC('Y', 'V', '1', '2'), + SDL_PIXELFORMAT_IYUV = /**< Planar mode: Y + U + V (3 planes) */ + SDL_DEFINE_PIXELFOURCC('I', 'Y', 'U', 'V'), + SDL_PIXELFORMAT_YUY2 = /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */ + SDL_DEFINE_PIXELFOURCC('Y', 'U', 'Y', '2'), + SDL_PIXELFORMAT_UYVY = /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */ + SDL_DEFINE_PIXELFOURCC('U', 'Y', 'V', 'Y'), + SDL_PIXELFORMAT_YVYU = /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */ + SDL_DEFINE_PIXELFOURCC('Y', 'V', 'Y', 'U'), + SDL_PIXELFORMAT_NV12 = /**< Planar mode: Y + U/V interleaved (2 planes) */ + SDL_DEFINE_PIXELFOURCC('N', 'V', '1', '2'), + SDL_PIXELFORMAT_NV21 = /**< Planar mode: Y + V/U interleaved (2 planes) */ + SDL_DEFINE_PIXELFOURCC('N', 'V', '2', '1'), + SDL_PIXELFORMAT_EXTERNAL_OES = /**< Android video texture format */ + SDL_DEFINE_PIXELFOURCC('O', 'E', 'S', ' ') +} SDL_PixelFormatEnum; + +typedef struct SDL_Color +{ + Uint8 r; + Uint8 g; + Uint8 b; + Uint8 a; +} SDL_Color; +#define SDL_Colour SDL_Color + +typedef struct SDL_Palette +{ + int ncolors; + SDL_Color *colors; + Uint32 version; + int refcount; +} SDL_Palette; + +/** + * \note Everything in the pixel format structure is read-only. + */ +typedef struct SDL_PixelFormat +{ + Uint32 format; + SDL_Palette *palette; + Uint8 BitsPerPixel; + Uint8 BytesPerPixel; + Uint8 padding[2]; + Uint32 Rmask; + Uint32 Gmask; + Uint32 Bmask; + Uint32 Amask; + Uint8 Rloss; + Uint8 Gloss; + Uint8 Bloss; + Uint8 Aloss; + Uint8 Rshift; + Uint8 Gshift; + Uint8 Bshift; + Uint8 Ashift; + int refcount; + struct SDL_PixelFormat *next; +} SDL_PixelFormat; + +/** + * \brief Get the human readable name of a pixel format + */ +extern DECLSPEC const char* SDLCALL SDL_GetPixelFormatName(Uint32 format); + +/** + * \brief Convert one of the enumerated pixel formats to a bpp and RGBA masks. + * + * \return SDL_TRUE, or SDL_FALSE if the conversion wasn't possible. + * + * \sa SDL_MasksToPixelFormatEnum() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format, + int *bpp, + Uint32 * Rmask, + Uint32 * Gmask, + Uint32 * Bmask, + Uint32 * Amask); + +/** + * \brief Convert a bpp and RGBA masks to an enumerated pixel format. + * + * \return The pixel format, or ::SDL_PIXELFORMAT_UNKNOWN if the conversion + * wasn't possible. + * + * \sa SDL_PixelFormatEnumToMasks() + */ +extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp, + Uint32 Rmask, + Uint32 Gmask, + Uint32 Bmask, + Uint32 Amask); + +/** + * \brief Create an SDL_PixelFormat structure from a pixel format enum. + */ +extern DECLSPEC SDL_PixelFormat * SDLCALL SDL_AllocFormat(Uint32 pixel_format); + +/** + * \brief Free an SDL_PixelFormat structure. + */ +extern DECLSPEC void SDLCALL SDL_FreeFormat(SDL_PixelFormat *format); + +/** + * \brief Create a palette structure with the specified number of color + * entries. + * + * \return A new palette, or NULL if there wasn't enough memory. + * + * \note The palette entries are initialized to white. + * + * \sa SDL_FreePalette() + */ +extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors); + +/** + * \brief Set the palette for a pixel format structure. + */ +extern DECLSPEC int SDLCALL SDL_SetPixelFormatPalette(SDL_PixelFormat * format, + SDL_Palette *palette); + +/** + * \brief Set a range of colors in a palette. + * + * \param palette The palette to modify. + * \param colors An array of colors to copy into the palette. + * \param firstcolor The index of the first palette entry to modify. + * \param ncolors The number of entries to modify. + * + * \return 0 on success, or -1 if not all of the colors could be set. + */ +extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette, + const SDL_Color * colors, + int firstcolor, int ncolors); + +/** + * \brief Free a palette created with SDL_AllocPalette(). + * + * \sa SDL_AllocPalette() + */ +extern DECLSPEC void SDLCALL SDL_FreePalette(SDL_Palette * palette); + +/** + * \brief Maps an RGB triple to an opaque pixel value for a given pixel format. + * + * \sa SDL_MapRGBA + */ +extern DECLSPEC Uint32 SDLCALL SDL_MapRGB(const SDL_PixelFormat * format, + Uint8 r, Uint8 g, Uint8 b); + +/** + * \brief Maps an RGBA quadruple to a pixel value for a given pixel format. + * + * \sa SDL_MapRGB + */ +extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormat * format, + Uint8 r, Uint8 g, Uint8 b, + Uint8 a); + +/** + * \brief Get the RGB components from a pixel of the specified format. + * + * \sa SDL_GetRGBA + */ +extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel, + const SDL_PixelFormat * format, + Uint8 * r, Uint8 * g, Uint8 * b); + +/** + * \brief Get the RGBA components from a pixel of the specified format. + * + * \sa SDL_GetRGB + */ +extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel, + const SDL_PixelFormat * format, + Uint8 * r, Uint8 * g, Uint8 * b, + Uint8 * a); + +/** + * \brief Calculate a 256 entry gamma ramp for a gamma value. + */ +extern DECLSPEC void SDLCALL SDL_CalculateGammaRamp(float gamma, Uint16 * ramp); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_pixels_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_platform.h b/thirdparty/include/SDL2/SDL_platform.h new file mode 100644 index 000000000..716655792 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_platform.h @@ -0,0 +1,198 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_platform.h + * + * Try to get a standard set of platform defines. + */ + +#ifndef SDL_platform_h_ +#define SDL_platform_h_ + +#if defined(_AIX) +#undef __AIX__ +#define __AIX__ 1 +#endif +#if defined(__HAIKU__) +#undef __HAIKU__ +#define __HAIKU__ 1 +#endif +#if defined(bsdi) || defined(__bsdi) || defined(__bsdi__) +#undef __BSDI__ +#define __BSDI__ 1 +#endif +#if defined(_arch_dreamcast) +#undef __DREAMCAST__ +#define __DREAMCAST__ 1 +#endif +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) +#undef __FREEBSD__ +#define __FREEBSD__ 1 +#endif +#if defined(hpux) || defined(__hpux) || defined(__hpux__) +#undef __HPUX__ +#define __HPUX__ 1 +#endif +#if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE) +#undef __IRIX__ +#define __IRIX__ 1 +#endif +#if (defined(linux) || defined(__linux) || defined(__linux__)) +#undef __LINUX__ +#define __LINUX__ 1 +#endif +#if defined(ANDROID) || defined(__ANDROID__) +#undef __ANDROID__ +#undef __LINUX__ /* do we need to do this? */ +#define __ANDROID__ 1 +#endif + +#if defined(__APPLE__) +/* lets us know what version of Mac OS X we're compiling on */ +#include "AvailabilityMacros.h" +#include "TargetConditionals.h" +#if TARGET_OS_TV +#undef __TVOS__ +#define __TVOS__ 1 +#endif +#if TARGET_OS_IPHONE +/* if compiling for iOS */ +#undef __IPHONEOS__ +#define __IPHONEOS__ 1 +#undef __MACOSX__ +#else +/* if not compiling for iOS */ +#undef __MACOSX__ +#define __MACOSX__ 1 +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 +# error SDL for Mac OS X only supports deploying on 10.6 and above. +#endif /* MAC_OS_X_VERSION_MIN_REQUIRED < 1060 */ +#endif /* TARGET_OS_IPHONE */ +#endif /* defined(__APPLE__) */ + +#if defined(__NetBSD__) +#undef __NETBSD__ +#define __NETBSD__ 1 +#endif +#if defined(__OpenBSD__) +#undef __OPENBSD__ +#define __OPENBSD__ 1 +#endif +#if defined(__OS2__) || defined(__EMX__) +#undef __OS2__ +#define __OS2__ 1 +#endif +#if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE) +#undef __OSF__ +#define __OSF__ 1 +#endif +#if defined(__QNXNTO__) +#undef __QNXNTO__ +#define __QNXNTO__ 1 +#endif +#if defined(riscos) || defined(__riscos) || defined(__riscos__) +#undef __RISCOS__ +#define __RISCOS__ 1 +#endif +#if defined(__sun) && defined(__SVR4) +#undef __SOLARIS__ +#define __SOLARIS__ 1 +#endif + +#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) +/* Try to find out if we're compiling for WinRT or non-WinRT */ +#if defined(_MSC_VER) && defined(__has_include) +#if __has_include() +#define HAVE_WINAPIFAMILY_H 1 +#else +#define HAVE_WINAPIFAMILY_H 0 +#endif + +/* If _USING_V110_SDK71_ is defined it means we are using the Windows XP toolset. */ +#elif defined(_MSC_VER) && (_MSC_VER >= 1700 && !_USING_V110_SDK71_) /* _MSC_VER == 1700 for Visual Studio 2012 */ +#define HAVE_WINAPIFAMILY_H 1 +#else +#define HAVE_WINAPIFAMILY_H 0 +#endif + +#if HAVE_WINAPIFAMILY_H +#include +#define WINAPI_FAMILY_WINRT (!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)) +#else +#define WINAPI_FAMILY_WINRT 0 +#endif /* HAVE_WINAPIFAMILY_H */ + +#if WINAPI_FAMILY_WINRT +#undef __WINRT__ +#define __WINRT__ 1 +#else +#undef __WINDOWS__ +#define __WINDOWS__ 1 +#endif +#endif /* defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) */ + +#if defined(__WINDOWS__) +#undef __WIN32__ +#define __WIN32__ 1 +#endif +#if defined(__PSP__) +#undef __PSP__ +#define __PSP__ 1 +#endif + +/* The NACL compiler defines __native_client__ and __pnacl__ + * Ref: http://www.chromium.org/nativeclient/pnacl/stability-of-the-pnacl-bitcode-abi + */ +#if defined(__native_client__) +#undef __LINUX__ +#undef __NACL__ +#define __NACL__ 1 +#endif +#if defined(__pnacl__) +#undef __LINUX__ +#undef __PNACL__ +#define __PNACL__ 1 +/* PNACL with newlib supports static linking only */ +#define __SDL_NOGETPROCADDR__ +#endif + + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Gets the name of the platform. + */ +extern DECLSPEC const char * SDLCALL SDL_GetPlatform (void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_platform_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_power.h b/thirdparty/include/SDL2/SDL_power.h new file mode 100644 index 000000000..39884cc23 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_power.h @@ -0,0 +1,75 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_power_h_ +#define SDL_power_h_ + +/** + * \file SDL_power.h + * + * Header for the SDL power management routines. + */ + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief The basic state for the system's power supply. + */ +typedef enum +{ + SDL_POWERSTATE_UNKNOWN, /**< cannot determine power status */ + SDL_POWERSTATE_ON_BATTERY, /**< Not plugged in, running on the battery */ + SDL_POWERSTATE_NO_BATTERY, /**< Plugged in, no battery available */ + SDL_POWERSTATE_CHARGING, /**< Plugged in, charging battery */ + SDL_POWERSTATE_CHARGED /**< Plugged in, battery charged */ +} SDL_PowerState; + + +/** + * \brief Get the current power supply details. + * + * \param secs Seconds of battery life left. You can pass a NULL here if + * you don't care. Will return -1 if we can't determine a + * value, or we're not running on a battery. + * + * \param pct Percentage of battery life left, between 0 and 100. You can + * pass a NULL here if you don't care. Will return -1 if we + * can't determine a value, or we're not running on a battery. + * + * \return The state of the battery (if any). + */ +extern DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *secs, int *pct); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_power_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_quit.h b/thirdparty/include/SDL2/SDL_quit.h new file mode 100644 index 000000000..b2bd5da50 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_quit.h @@ -0,0 +1,58 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_quit.h + * + * Include file for SDL quit event handling. + */ + +#ifndef SDL_quit_h_ +#define SDL_quit_h_ + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +/** + * \file SDL_quit.h + * + * An ::SDL_QUIT event is generated when the user tries to close the application + * window. If it is ignored or filtered out, the window will remain open. + * If it is not ignored or filtered, it is queued normally and the window + * is allowed to close. When the window is closed, screen updates will + * complete, but have no effect. + * + * SDL_Init() installs signal handlers for SIGINT (keyboard interrupt) + * and SIGTERM (system termination request), if handlers do not already + * exist, that generate ::SDL_QUIT events as well. There is no way + * to determine the cause of an ::SDL_QUIT event, but setting a signal + * handler in your application will override the default generation of + * quit events for that signal. + * + * \sa SDL_Quit() + */ + +/* There are no functions directly affecting the quit event */ + +#define SDL_QuitRequested() \ + (SDL_PumpEvents(), (SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUIT,SDL_QUIT) > 0)) + +#endif /* SDL_quit_h_ */ diff --git a/thirdparty/include/SDL2/SDL_rect.h b/thirdparty/include/SDL2/SDL_rect.h new file mode 100644 index 000000000..47f0d2078 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_rect.h @@ -0,0 +1,174 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_rect.h + * + * Header file for SDL_rect definition and management functions. + */ + +#ifndef SDL_rect_h_ +#define SDL_rect_h_ + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_pixels.h" +#include "SDL_rwops.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief The structure that defines a point (integer) + * + * \sa SDL_EnclosePoints + * \sa SDL_PointInRect + */ +typedef struct SDL_Point +{ + int x; + int y; +} SDL_Point; + +/** + * \brief The structure that defines a point (floating point) + * + * \sa SDL_EnclosePoints + * \sa SDL_PointInRect + */ +typedef struct SDL_FPoint +{ + float x; + float y; +} SDL_FPoint; + + +/** + * \brief A rectangle, with the origin at the upper left (integer). + * + * \sa SDL_RectEmpty + * \sa SDL_RectEquals + * \sa SDL_HasIntersection + * \sa SDL_IntersectRect + * \sa SDL_UnionRect + * \sa SDL_EnclosePoints + */ +typedef struct SDL_Rect +{ + int x, y; + int w, h; +} SDL_Rect; + + +/** + * \brief A rectangle, with the origin at the upper left (floating point). + */ +typedef struct SDL_FRect +{ + float x; + float y; + float w; + float h; +} SDL_FRect; + + +/** + * \brief Returns true if point resides inside a rectangle. + */ +SDL_FORCE_INLINE SDL_bool SDL_PointInRect(const SDL_Point *p, const SDL_Rect *r) +{ + return ( (p->x >= r->x) && (p->x < (r->x + r->w)) && + (p->y >= r->y) && (p->y < (r->y + r->h)) ) ? SDL_TRUE : SDL_FALSE; +} + +/** + * \brief Returns true if the rectangle has no area. + */ +SDL_FORCE_INLINE SDL_bool SDL_RectEmpty(const SDL_Rect *r) +{ + return ((!r) || (r->w <= 0) || (r->h <= 0)) ? SDL_TRUE : SDL_FALSE; +} + +/** + * \brief Returns true if the two rectangles are equal. + */ +SDL_FORCE_INLINE SDL_bool SDL_RectEquals(const SDL_Rect *a, const SDL_Rect *b) +{ + return (a && b && (a->x == b->x) && (a->y == b->y) && + (a->w == b->w) && (a->h == b->h)) ? SDL_TRUE : SDL_FALSE; +} + +/** + * \brief Determine whether two rectangles intersect. + * + * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersection(const SDL_Rect * A, + const SDL_Rect * B); + +/** + * \brief Calculate the intersection of two rectangles. + * + * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A, + const SDL_Rect * B, + SDL_Rect * result); + +/** + * \brief Calculate the union of two rectangles. + */ +extern DECLSPEC void SDLCALL SDL_UnionRect(const SDL_Rect * A, + const SDL_Rect * B, + SDL_Rect * result); + +/** + * \brief Calculate a minimal rectangle enclosing a set of points + * + * \return SDL_TRUE if any points were within the clipping rect + */ +extern DECLSPEC SDL_bool SDLCALL SDL_EnclosePoints(const SDL_Point * points, + int count, + const SDL_Rect * clip, + SDL_Rect * result); + +/** + * \brief Calculate the intersection of a rectangle and line segment. + * + * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine(const SDL_Rect * + rect, int *X1, + int *Y1, int *X2, + int *Y2); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_rect_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_render.h b/thirdparty/include/SDL2/SDL_render.h new file mode 100644 index 000000000..f26fb7e5f --- /dev/null +++ b/thirdparty/include/SDL2/SDL_render.h @@ -0,0 +1,1158 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_render.h + * + * Header file for SDL 2D rendering functions. + * + * This API supports the following features: + * * single pixel points + * * single pixel lines + * * filled rectangles + * * texture images + * + * The primitives may be drawn in opaque, blended, or additive modes. + * + * The texture images may be drawn in opaque, blended, or additive modes. + * They can have an additional color tint or alpha modulation applied to + * them, and may also be stretched with linear interpolation. + * + * This API is designed to accelerate simple 2D operations. You may + * want more functionality such as polygons and particle effects and + * in that case you should use SDL's OpenGL/Direct3D support or one + * of the many good 3D engines. + * + * These functions must be called from the main thread. + * See this bug for details: http://bugzilla.libsdl.org/show_bug.cgi?id=1995 + */ + +#ifndef SDL_render_h_ +#define SDL_render_h_ + +#include "SDL_stdinc.h" +#include "SDL_rect.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Flags used when creating a rendering context + */ +typedef enum +{ + SDL_RENDERER_SOFTWARE = 0x00000001, /**< The renderer is a software fallback */ + SDL_RENDERER_ACCELERATED = 0x00000002, /**< The renderer uses hardware + acceleration */ + SDL_RENDERER_PRESENTVSYNC = 0x00000004, /**< Present is synchronized + with the refresh rate */ + SDL_RENDERER_TARGETTEXTURE = 0x00000008 /**< The renderer supports + rendering to texture */ +} SDL_RendererFlags; + +/** + * \brief Information on the capabilities of a render driver or context. + */ +typedef struct SDL_RendererInfo +{ + const char *name; /**< The name of the renderer */ + Uint32 flags; /**< Supported ::SDL_RendererFlags */ + Uint32 num_texture_formats; /**< The number of available texture formats */ + Uint32 texture_formats[16]; /**< The available texture formats */ + int max_texture_width; /**< The maximum texture width */ + int max_texture_height; /**< The maximum texture height */ +} SDL_RendererInfo; + +/** + * \brief The scaling mode for a texture. + */ +typedef enum +{ + SDL_ScaleModeNearest, /**< nearest pixel sampling */ + SDL_ScaleModeLinear, /**< linear filtering */ + SDL_ScaleModeBest /**< anisotropic filtering */ +} SDL_ScaleMode; + +/** + * \brief The access pattern allowed for a texture. + */ +typedef enum +{ + SDL_TEXTUREACCESS_STATIC, /**< Changes rarely, not lockable */ + SDL_TEXTUREACCESS_STREAMING, /**< Changes frequently, lockable */ + SDL_TEXTUREACCESS_TARGET /**< Texture can be used as a render target */ +} SDL_TextureAccess; + +/** + * \brief The texture channel modulation used in SDL_RenderCopy(). + */ +typedef enum +{ + SDL_TEXTUREMODULATE_NONE = 0x00000000, /**< No modulation */ + SDL_TEXTUREMODULATE_COLOR = 0x00000001, /**< srcC = srcC * color */ + SDL_TEXTUREMODULATE_ALPHA = 0x00000002 /**< srcA = srcA * alpha */ +} SDL_TextureModulate; + +/** + * \brief Flip constants for SDL_RenderCopyEx + */ +typedef enum +{ + SDL_FLIP_NONE = 0x00000000, /**< Do not flip */ + SDL_FLIP_HORIZONTAL = 0x00000001, /**< flip horizontally */ + SDL_FLIP_VERTICAL = 0x00000002 /**< flip vertically */ +} SDL_RendererFlip; + +/** + * \brief A structure representing rendering state + */ +struct SDL_Renderer; +typedef struct SDL_Renderer SDL_Renderer; + +/** + * \brief An efficient driver-specific representation of pixel data + */ +struct SDL_Texture; +typedef struct SDL_Texture SDL_Texture; + + +/* Function prototypes */ + +/** + * \brief Get the number of 2D rendering drivers available for the current + * display. + * + * A render driver is a set of code that handles rendering and texture + * management on a particular display. Normally there is only one, but + * some drivers may have several available with different capabilities. + * + * \sa SDL_GetRenderDriverInfo() + * \sa SDL_CreateRenderer() + */ +extern DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void); + +/** + * \brief Get information about a specific 2D rendering driver for the current + * display. + * + * \param index The index of the driver to query information about. + * \param info A pointer to an SDL_RendererInfo struct to be filled with + * information on the rendering driver. + * + * \return 0 on success, -1 if the index was out of range. + * + * \sa SDL_CreateRenderer() + */ +extern DECLSPEC int SDLCALL SDL_GetRenderDriverInfo(int index, + SDL_RendererInfo * info); + +/** + * \brief Create a window and default renderer + * + * \param width The width of the window + * \param height The height of the window + * \param window_flags The flags used to create the window + * \param window A pointer filled with the window, or NULL on error + * \param renderer A pointer filled with the renderer, or NULL on error + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_CreateWindowAndRenderer( + int width, int height, Uint32 window_flags, + SDL_Window **window, SDL_Renderer **renderer); + + +/** + * \brief Create a 2D rendering context for a window. + * + * \param window The window where rendering is displayed. + * \param index The index of the rendering driver to initialize, or -1 to + * initialize the first one supporting the requested flags. + * \param flags ::SDL_RendererFlags. + * + * \return A valid rendering context or NULL if there was an error. + * + * \sa SDL_CreateSoftwareRenderer() + * \sa SDL_GetRendererInfo() + * \sa SDL_DestroyRenderer() + */ +extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window * window, + int index, Uint32 flags); + +/** + * \brief Create a 2D software rendering context for a surface. + * + * \param surface The surface where rendering is done. + * + * \return A valid rendering context or NULL if there was an error. + * + * \sa SDL_CreateRenderer() + * \sa SDL_DestroyRenderer() + */ +extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateSoftwareRenderer(SDL_Surface * surface); + +/** + * \brief Get the renderer associated with a window. + */ +extern DECLSPEC SDL_Renderer * SDLCALL SDL_GetRenderer(SDL_Window * window); + +/** + * \brief Get information about a rendering context. + */ +extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_Renderer * renderer, + SDL_RendererInfo * info); + +/** + * \brief Get the output size in pixels of a rendering context. + */ +extern DECLSPEC int SDLCALL SDL_GetRendererOutputSize(SDL_Renderer * renderer, + int *w, int *h); + +/** + * \brief Create a texture for a rendering context. + * + * \param renderer The renderer. + * \param format The format of the texture. + * \param access One of the enumerated values in ::SDL_TextureAccess. + * \param w The width of the texture in pixels. + * \param h The height of the texture in pixels. + * + * \return The created texture is returned, or NULL if no rendering context was + * active, the format was unsupported, or the width or height were out + * of range. + * + * \note The contents of the texture are not defined at creation. + * + * \sa SDL_QueryTexture() + * \sa SDL_UpdateTexture() + * \sa SDL_DestroyTexture() + */ +extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(SDL_Renderer * renderer, + Uint32 format, + int access, int w, + int h); + +/** + * \brief Create a texture from an existing surface. + * + * \param renderer The renderer. + * \param surface The surface containing pixel data used to fill the texture. + * + * \return The created texture is returned, or NULL on error. + * + * \note The surface is not modified or freed by this function. + * + * \sa SDL_QueryTexture() + * \sa SDL_DestroyTexture() + */ +extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface); + +/** + * \brief Query the attributes of a texture + * + * \param texture A texture to be queried. + * \param format A pointer filled in with the raw format of the texture. The + * actual format may differ, but pixel transfers will use this + * format. + * \param access A pointer filled in with the actual access to the texture. + * \param w A pointer filled in with the width of the texture in pixels. + * \param h A pointer filled in with the height of the texture in pixels. + * + * \return 0 on success, or -1 if the texture is not valid. + */ +extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_Texture * texture, + Uint32 * format, int *access, + int *w, int *h); + +/** + * \brief Set an additional color value used in render copy operations. + * + * \param texture The texture to update. + * \param r The red color value multiplied into copy operations. + * \param g The green color value multiplied into copy operations. + * \param b The blue color value multiplied into copy operations. + * + * \return 0 on success, or -1 if the texture is not valid or color modulation + * is not supported. + * + * \sa SDL_GetTextureColorMod() + */ +extern DECLSPEC int SDLCALL SDL_SetTextureColorMod(SDL_Texture * texture, + Uint8 r, Uint8 g, Uint8 b); + + +/** + * \brief Get the additional color value used in render copy operations. + * + * \param texture The texture to query. + * \param r A pointer filled in with the current red color value. + * \param g A pointer filled in with the current green color value. + * \param b A pointer filled in with the current blue color value. + * + * \return 0 on success, or -1 if the texture is not valid. + * + * \sa SDL_SetTextureColorMod() + */ +extern DECLSPEC int SDLCALL SDL_GetTextureColorMod(SDL_Texture * texture, + Uint8 * r, Uint8 * g, + Uint8 * b); + +/** + * \brief Set an additional alpha value used in render copy operations. + * + * \param texture The texture to update. + * \param alpha The alpha value multiplied into copy operations. + * + * \return 0 on success, or -1 if the texture is not valid or alpha modulation + * is not supported. + * + * \sa SDL_GetTextureAlphaMod() + */ +extern DECLSPEC int SDLCALL SDL_SetTextureAlphaMod(SDL_Texture * texture, + Uint8 alpha); + +/** + * \brief Get the additional alpha value used in render copy operations. + * + * \param texture The texture to query. + * \param alpha A pointer filled in with the current alpha value. + * + * \return 0 on success, or -1 if the texture is not valid. + * + * \sa SDL_SetTextureAlphaMod() + */ +extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_Texture * texture, + Uint8 * alpha); + +/** + * \brief Set the blend mode used for texture copy operations. + * + * \param texture The texture to update. + * \param blendMode ::SDL_BlendMode to use for texture blending. + * + * \return 0 on success, or -1 if the texture is not valid or the blend mode is + * not supported. + * + * \note If the blend mode is not supported, the closest supported mode is + * chosen. + * + * \sa SDL_GetTextureBlendMode() + */ +extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_Texture * texture, + SDL_BlendMode blendMode); + +/** + * \brief Get the blend mode used for texture copy operations. + * + * \param texture The texture to query. + * \param blendMode A pointer filled in with the current blend mode. + * + * \return 0 on success, or -1 if the texture is not valid. + * + * \sa SDL_SetTextureBlendMode() + */ +extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture * texture, + SDL_BlendMode *blendMode); + +/** + * \brief Set the scale mode used for texture scale operations. + * + * \param texture The texture to update. + * \param scaleMode ::SDL_ScaleMode to use for texture scaling. + * + * \return 0 on success, or -1 if the texture is not valid. + * + * \note If the scale mode is not supported, the closest supported mode is + * chosen. + * + * \sa SDL_GetTextureScaleMode() + */ +extern DECLSPEC int SDLCALL SDL_SetTextureScaleMode(SDL_Texture * texture, + SDL_ScaleMode scaleMode); + +/** + * \brief Get the scale mode used for texture scale operations. + * + * \param texture The texture to query. + * \param scaleMode A pointer filled in with the current scale mode. + * + * \return 0 on success, or -1 if the texture is not valid. + * + * \sa SDL_SetTextureScaleMode() + */ +extern DECLSPEC int SDLCALL SDL_GetTextureScaleMode(SDL_Texture * texture, + SDL_ScaleMode *scaleMode); + +/** + * \brief Update the given texture rectangle with new pixel data. + * + * \param texture The texture to update + * \param rect A pointer to the rectangle of pixels to update, or NULL to + * update the entire texture. + * \param pixels The raw pixel data in the format of the texture. + * \param pitch The number of bytes in a row of pixel data, including padding between lines. + * + * The pixel data must be in the format of the texture. The pixel format can be + * queried with SDL_QueryTexture. + * + * \return 0 on success, or -1 if the texture is not valid. + * + * \note This is a fairly slow function. + */ +extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_Texture * texture, + const SDL_Rect * rect, + const void *pixels, int pitch); + +/** + * \brief Update a rectangle within a planar YV12 or IYUV texture with new pixel data. + * + * \param texture The texture to update + * \param rect A pointer to the rectangle of pixels to update, or NULL to + * update the entire texture. + * \param Yplane The raw pixel data for the Y plane. + * \param Ypitch The number of bytes between rows of pixel data for the Y plane. + * \param Uplane The raw pixel data for the U plane. + * \param Upitch The number of bytes between rows of pixel data for the U plane. + * \param Vplane The raw pixel data for the V plane. + * \param Vpitch The number of bytes between rows of pixel data for the V plane. + * + * \return 0 on success, or -1 if the texture is not valid. + * + * \note You can use SDL_UpdateTexture() as long as your pixel data is + * a contiguous block of Y and U/V planes in the proper order, but + * this function is available if your pixel data is not contiguous. + */ +extern DECLSPEC int SDLCALL SDL_UpdateYUVTexture(SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch); + +/** + * \brief Lock a portion of the texture for write-only pixel access. + * + * \param texture The texture to lock for access, which was created with + * ::SDL_TEXTUREACCESS_STREAMING. + * \param rect A pointer to the rectangle to lock for access. If the rect + * is NULL, the entire texture will be locked. + * \param pixels This is filled in with a pointer to the locked pixels, + * appropriately offset by the locked area. + * \param pitch This is filled in with the pitch of the locked pixels. + * + * \return 0 on success, or -1 if the texture is not valid or was not created with ::SDL_TEXTUREACCESS_STREAMING. + * + * \sa SDL_UnlockTexture() + */ +extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_Texture * texture, + const SDL_Rect * rect, + void **pixels, int *pitch); + +/** + * \brief Lock a portion of the texture for write-only pixel access. + * Expose it as a SDL surface. + * + * \param texture The texture to lock for access, which was created with + * ::SDL_TEXTUREACCESS_STREAMING. + * \param rect A pointer to the rectangle to lock for access. If the rect + * is NULL, the entire texture will be locked. + * \param surface This is filled in with a SDL surface representing the locked area + * Surface is freed internally after calling SDL_UnlockTexture or SDL_DestroyTexture. + * + * \return 0 on success, or -1 if the texture is not valid or was not created with ::SDL_TEXTUREACCESS_STREAMING. + * + * \sa SDL_UnlockTexture() + */ +extern DECLSPEC int SDLCALL SDL_LockTextureToSurface(SDL_Texture *texture, + const SDL_Rect *rect, + SDL_Surface **surface); + +/** + * \brief Unlock a texture, uploading the changes to video memory, if needed. + * If SDL_LockTextureToSurface() was called for locking, the SDL surface is freed. + * + * \sa SDL_LockTexture() + * \sa SDL_LockTextureToSurface() + */ +extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture * texture); + +/** + * \brief Determines whether a window supports the use of render targets + * + * \param renderer The renderer that will be checked + * + * \return SDL_TRUE if supported, SDL_FALSE if not. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_RenderTargetSupported(SDL_Renderer *renderer); + +/** + * \brief Set a texture as the current rendering target. + * + * \param renderer The renderer. + * \param texture The targeted texture, which must be created with the SDL_TEXTUREACCESS_TARGET flag, or NULL for the default render target + * + * \return 0 on success, or -1 on error + * + * \sa SDL_GetRenderTarget() + */ +extern DECLSPEC int SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer, + SDL_Texture *texture); + +/** + * \brief Get the current render target or NULL for the default render target. + * + * \return The current render target + * + * \sa SDL_SetRenderTarget() + */ +extern DECLSPEC SDL_Texture * SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer); + +/** + * \brief Set device independent resolution for rendering + * + * \param renderer The renderer for which resolution should be set. + * \param w The width of the logical resolution + * \param h The height of the logical resolution + * + * This function uses the viewport and scaling functionality to allow a fixed logical + * resolution for rendering, regardless of the actual output resolution. If the actual + * output resolution doesn't have the same aspect ratio the output rendering will be + * centered within the output display. + * + * If the output display is a window, mouse events in the window will be filtered + * and scaled so they seem to arrive within the logical resolution. + * + * \note If this function results in scaling or subpixel drawing by the + * rendering backend, it will be handled using the appropriate + * quality hints. + * + * \sa SDL_RenderGetLogicalSize() + * \sa SDL_RenderSetScale() + * \sa SDL_RenderSetViewport() + */ +extern DECLSPEC int SDLCALL SDL_RenderSetLogicalSize(SDL_Renderer * renderer, int w, int h); + +/** + * \brief Get device independent resolution for rendering + * + * \param renderer The renderer from which resolution should be queried. + * \param w A pointer filled with the width of the logical resolution + * \param h A pointer filled with the height of the logical resolution + * + * \sa SDL_RenderSetLogicalSize() + */ +extern DECLSPEC void SDLCALL SDL_RenderGetLogicalSize(SDL_Renderer * renderer, int *w, int *h); + +/** + * \brief Set whether to force integer scales for resolution-independent rendering + * + * \param renderer The renderer for which integer scaling should be set. + * \param enable Enable or disable integer scaling + * + * This function restricts the logical viewport to integer values - that is, when + * a resolution is between two multiples of a logical size, the viewport size is + * rounded down to the lower multiple. + * + * \sa SDL_RenderSetLogicalSize() + */ +extern DECLSPEC int SDLCALL SDL_RenderSetIntegerScale(SDL_Renderer * renderer, + SDL_bool enable); + +/** + * \brief Get whether integer scales are forced for resolution-independent rendering + * + * \param renderer The renderer from which integer scaling should be queried. + * + * \sa SDL_RenderSetIntegerScale() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_RenderGetIntegerScale(SDL_Renderer * renderer); + +/** + * \brief Set the drawing area for rendering on the current target. + * + * \param renderer The renderer for which the drawing area should be set. + * \param rect The rectangle representing the drawing area, or NULL to set the viewport to the entire target. + * + * The x,y of the viewport rect represents the origin for rendering. + * + * \return 0 on success, or -1 on error + * + * \note If the window associated with the renderer is resized, the viewport is automatically reset. + * + * \sa SDL_RenderGetViewport() + * \sa SDL_RenderSetLogicalSize() + */ +extern DECLSPEC int SDLCALL SDL_RenderSetViewport(SDL_Renderer * renderer, + const SDL_Rect * rect); + +/** + * \brief Get the drawing area for the current target. + * + * \sa SDL_RenderSetViewport() + */ +extern DECLSPEC void SDLCALL SDL_RenderGetViewport(SDL_Renderer * renderer, + SDL_Rect * rect); + +/** + * \brief Set the clip rectangle for the current target. + * + * \param renderer The renderer for which clip rectangle should be set. + * \param rect A pointer to the rectangle to set as the clip rectangle, + * relative to the viewport, or NULL to disable clipping. + * + * \return 0 on success, or -1 on error + * + * \sa SDL_RenderGetClipRect() + */ +extern DECLSPEC int SDLCALL SDL_RenderSetClipRect(SDL_Renderer * renderer, + const SDL_Rect * rect); + +/** + * \brief Get the clip rectangle for the current target. + * + * \param renderer The renderer from which clip rectangle should be queried. + * \param rect A pointer filled in with the current clip rectangle, or + * an empty rectangle if clipping is disabled. + * + * \sa SDL_RenderSetClipRect() + */ +extern DECLSPEC void SDLCALL SDL_RenderGetClipRect(SDL_Renderer * renderer, + SDL_Rect * rect); + +/** + * \brief Get whether clipping is enabled on the given renderer. + * + * \param renderer The renderer from which clip state should be queried. + * + * \sa SDL_RenderGetClipRect() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_RenderIsClipEnabled(SDL_Renderer * renderer); + + +/** + * \brief Set the drawing scale for rendering on the current target. + * + * \param renderer The renderer for which the drawing scale should be set. + * \param scaleX The horizontal scaling factor + * \param scaleY The vertical scaling factor + * + * The drawing coordinates are scaled by the x/y scaling factors + * before they are used by the renderer. This allows resolution + * independent drawing with a single coordinate system. + * + * \note If this results in scaling or subpixel drawing by the + * rendering backend, it will be handled using the appropriate + * quality hints. For best results use integer scaling factors. + * + * \sa SDL_RenderGetScale() + * \sa SDL_RenderSetLogicalSize() + */ +extern DECLSPEC int SDLCALL SDL_RenderSetScale(SDL_Renderer * renderer, + float scaleX, float scaleY); + +/** + * \brief Get the drawing scale for the current target. + * + * \param renderer The renderer from which drawing scale should be queried. + * \param scaleX A pointer filled in with the horizontal scaling factor + * \param scaleY A pointer filled in with the vertical scaling factor + * + * \sa SDL_RenderSetScale() + */ +extern DECLSPEC void SDLCALL SDL_RenderGetScale(SDL_Renderer * renderer, + float *scaleX, float *scaleY); + +/** + * \brief Set the color used for drawing operations (Rect, Line and Clear). + * + * \param renderer The renderer for which drawing color should be set. + * \param r The red value used to draw on the rendering target. + * \param g The green value used to draw on the rendering target. + * \param b The blue value used to draw on the rendering target. + * \param a The alpha value used to draw on the rendering target, usually + * ::SDL_ALPHA_OPAQUE (255). + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_SetRenderDrawColor(SDL_Renderer * renderer, + Uint8 r, Uint8 g, Uint8 b, + Uint8 a); + +/** + * \brief Get the color used for drawing operations (Rect, Line and Clear). + * + * \param renderer The renderer from which drawing color should be queried. + * \param r A pointer to the red value used to draw on the rendering target. + * \param g A pointer to the green value used to draw on the rendering target. + * \param b A pointer to the blue value used to draw on the rendering target. + * \param a A pointer to the alpha value used to draw on the rendering target, + * usually ::SDL_ALPHA_OPAQUE (255). + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_GetRenderDrawColor(SDL_Renderer * renderer, + Uint8 * r, Uint8 * g, Uint8 * b, + Uint8 * a); + +/** + * \brief Set the blend mode used for drawing operations (Fill and Line). + * + * \param renderer The renderer for which blend mode should be set. + * \param blendMode ::SDL_BlendMode to use for blending. + * + * \return 0 on success, or -1 on error + * + * \note If the blend mode is not supported, the closest supported mode is + * chosen. + * + * \sa SDL_GetRenderDrawBlendMode() + */ +extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer, + SDL_BlendMode blendMode); + +/** + * \brief Get the blend mode used for drawing operations. + * + * \param renderer The renderer from which blend mode should be queried. + * \param blendMode A pointer filled in with the current blend mode. + * + * \return 0 on success, or -1 on error + * + * \sa SDL_SetRenderDrawBlendMode() + */ +extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer, + SDL_BlendMode *blendMode); + +/** + * \brief Clear the current rendering target with the drawing color + * + * This function clears the entire rendering target, ignoring the viewport and + * the clip rectangle. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderClear(SDL_Renderer * renderer); + +/** + * \brief Draw a point on the current rendering target. + * + * \param renderer The renderer which should draw a point. + * \param x The x coordinate of the point. + * \param y The y coordinate of the point. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawPoint(SDL_Renderer * renderer, + int x, int y); + +/** + * \brief Draw multiple points on the current rendering target. + * + * \param renderer The renderer which should draw multiple points. + * \param points The points to draw + * \param count The number of points to draw + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawPoints(SDL_Renderer * renderer, + const SDL_Point * points, + int count); + +/** + * \brief Draw a line on the current rendering target. + * + * \param renderer The renderer which should draw a line. + * \param x1 The x coordinate of the start point. + * \param y1 The y coordinate of the start point. + * \param x2 The x coordinate of the end point. + * \param y2 The y coordinate of the end point. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawLine(SDL_Renderer * renderer, + int x1, int y1, int x2, int y2); + +/** + * \brief Draw a series of connected lines on the current rendering target. + * + * \param renderer The renderer which should draw multiple lines. + * \param points The points along the lines + * \param count The number of points, drawing count-1 lines + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawLines(SDL_Renderer * renderer, + const SDL_Point * points, + int count); + +/** + * \brief Draw a rectangle on the current rendering target. + * + * \param renderer The renderer which should draw a rectangle. + * \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawRect(SDL_Renderer * renderer, + const SDL_Rect * rect); + +/** + * \brief Draw some number of rectangles on the current rendering target. + * + * \param renderer The renderer which should draw multiple rectangles. + * \param rects A pointer to an array of destination rectangles. + * \param count The number of rectangles. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawRects(SDL_Renderer * renderer, + const SDL_Rect * rects, + int count); + +/** + * \brief Fill a rectangle on the current rendering target with the drawing color. + * + * \param renderer The renderer which should fill a rectangle. + * \param rect A pointer to the destination rectangle, or NULL for the entire + * rendering target. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderFillRect(SDL_Renderer * renderer, + const SDL_Rect * rect); + +/** + * \brief Fill some number of rectangles on the current rendering target with the drawing color. + * + * \param renderer The renderer which should fill multiple rectangles. + * \param rects A pointer to an array of destination rectangles. + * \param count The number of rectangles. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderFillRects(SDL_Renderer * renderer, + const SDL_Rect * rects, + int count); + +/** + * \brief Copy a portion of the texture to the current rendering target. + * + * \param renderer The renderer which should copy parts of a texture. + * \param texture The source texture. + * \param srcrect A pointer to the source rectangle, or NULL for the entire + * texture. + * \param dstrect A pointer to the destination rectangle, or NULL for the + * entire rendering target. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Renderer * renderer, + SDL_Texture * texture, + const SDL_Rect * srcrect, + const SDL_Rect * dstrect); + +/** + * \brief Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center + * + * \param renderer The renderer which should copy parts of a texture. + * \param texture The source texture. + * \param srcrect A pointer to the source rectangle, or NULL for the entire + * texture. + * \param dstrect A pointer to the destination rectangle, or NULL for the + * entire rendering target. + * \param angle An angle in degrees that indicates the rotation that will be applied to dstrect, rotating it in a clockwise direction + * \param center A pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done around dstrect.w/2, dstrect.h/2). + * \param flip An SDL_RendererFlip value stating which flipping actions should be performed on the texture + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderCopyEx(SDL_Renderer * renderer, + SDL_Texture * texture, + const SDL_Rect * srcrect, + const SDL_Rect * dstrect, + const double angle, + const SDL_Point *center, + const SDL_RendererFlip flip); + + +/** + * \brief Draw a point on the current rendering target. + * + * \param renderer The renderer which should draw a point. + * \param x The x coordinate of the point. + * \param y The y coordinate of the point. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawPointF(SDL_Renderer * renderer, + float x, float y); + +/** + * \brief Draw multiple points on the current rendering target. + * + * \param renderer The renderer which should draw multiple points. + * \param points The points to draw + * \param count The number of points to draw + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawPointsF(SDL_Renderer * renderer, + const SDL_FPoint * points, + int count); + +/** + * \brief Draw a line on the current rendering target. + * + * \param renderer The renderer which should draw a line. + * \param x1 The x coordinate of the start point. + * \param y1 The y coordinate of the start point. + * \param x2 The x coordinate of the end point. + * \param y2 The y coordinate of the end point. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawLineF(SDL_Renderer * renderer, + float x1, float y1, float x2, float y2); + +/** + * \brief Draw a series of connected lines on the current rendering target. + * + * \param renderer The renderer which should draw multiple lines. + * \param points The points along the lines + * \param count The number of points, drawing count-1 lines + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawLinesF(SDL_Renderer * renderer, + const SDL_FPoint * points, + int count); + +/** + * \brief Draw a rectangle on the current rendering target. + * + * \param renderer The renderer which should draw a rectangle. + * \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawRectF(SDL_Renderer * renderer, + const SDL_FRect * rect); + +/** + * \brief Draw some number of rectangles on the current rendering target. + * + * \param renderer The renderer which should draw multiple rectangles. + * \param rects A pointer to an array of destination rectangles. + * \param count The number of rectangles. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawRectsF(SDL_Renderer * renderer, + const SDL_FRect * rects, + int count); + +/** + * \brief Fill a rectangle on the current rendering target with the drawing color. + * + * \param renderer The renderer which should fill a rectangle. + * \param rect A pointer to the destination rectangle, or NULL for the entire + * rendering target. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderFillRectF(SDL_Renderer * renderer, + const SDL_FRect * rect); + +/** + * \brief Fill some number of rectangles on the current rendering target with the drawing color. + * + * \param renderer The renderer which should fill multiple rectangles. + * \param rects A pointer to an array of destination rectangles. + * \param count The number of rectangles. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderFillRectsF(SDL_Renderer * renderer, + const SDL_FRect * rects, + int count); + +/** + * \brief Copy a portion of the texture to the current rendering target. + * + * \param renderer The renderer which should copy parts of a texture. + * \param texture The source texture. + * \param srcrect A pointer to the source rectangle, or NULL for the entire + * texture. + * \param dstrect A pointer to the destination rectangle, or NULL for the + * entire rendering target. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderCopyF(SDL_Renderer * renderer, + SDL_Texture * texture, + const SDL_Rect * srcrect, + const SDL_FRect * dstrect); + +/** + * \brief Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center + * + * \param renderer The renderer which should copy parts of a texture. + * \param texture The source texture. + * \param srcrect A pointer to the source rectangle, or NULL for the entire + * texture. + * \param dstrect A pointer to the destination rectangle, or NULL for the + * entire rendering target. + * \param angle An angle in degrees that indicates the rotation that will be applied to dstrect, rotating it in a clockwise direction + * \param center A pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done around dstrect.w/2, dstrect.h/2). + * \param flip An SDL_RendererFlip value stating which flipping actions should be performed on the texture + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderCopyExF(SDL_Renderer * renderer, + SDL_Texture * texture, + const SDL_Rect * srcrect, + const SDL_FRect * dstrect, + const double angle, + const SDL_FPoint *center, + const SDL_RendererFlip flip); + +/** + * \brief Read pixels from the current rendering target. + * + * \param renderer The renderer from which pixels should be read. + * \param rect A pointer to the rectangle to read, or NULL for the entire + * render target. + * \param format The desired format of the pixel data, or 0 to use the format + * of the rendering target + * \param pixels A pointer to be filled in with the pixel data + * \param pitch The pitch of the pixels parameter. + * + * \return 0 on success, or -1 if pixel reading is not supported. + * + * \warning This is a very slow operation, and should not be used frequently. + */ +extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer * renderer, + const SDL_Rect * rect, + Uint32 format, + void *pixels, int pitch); + +/** + * \brief Update the screen with rendering performed. + */ +extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer * renderer); + +/** + * \brief Destroy the specified texture. + * + * \sa SDL_CreateTexture() + * \sa SDL_CreateTextureFromSurface() + */ +extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture); + +/** + * \brief Destroy the rendering context for a window and free associated + * textures. + * + * \sa SDL_CreateRenderer() + */ +extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer * renderer); + +/** + * \brief Force the rendering context to flush any pending commands to the + * underlying rendering API. + * + * You do not need to (and in fact, shouldn't) call this function unless + * you are planning to call into OpenGL/Direct3D/Metal/whatever directly + * in addition to using an SDL_Renderer. + * + * This is for a very-specific case: if you are using SDL's render API, + * you asked for a specific renderer backend (OpenGL, Direct3D, etc), + * you set SDL_HINT_RENDER_BATCHING to "1", and you plan to make + * OpenGL/D3D/whatever calls in addition to SDL render API calls. If all of + * this applies, you should call SDL_RenderFlush() between calls to SDL's + * render API and the low-level API you're using in cooperation. + * + * In all other cases, you can ignore this function. This is only here to + * get maximum performance out of a specific situation. In all other cases, + * SDL will do the right thing, perhaps at a performance loss. + * + * This function is first available in SDL 2.0.10, and is not needed in + * 2.0.9 and earlier, as earlier versions did not queue rendering commands + * at all, instead flushing them to the OS immediately. + */ +extern DECLSPEC int SDLCALL SDL_RenderFlush(SDL_Renderer * renderer); + + +/** + * \brief Bind the texture to the current OpenGL/ES/ES2 context for use with + * OpenGL instructions. + * + * \param texture The SDL texture to bind + * \param texw A pointer to a float that will be filled with the texture width + * \param texh A pointer to a float that will be filled with the texture height + * + * \return 0 on success, or -1 if the operation is not supported + */ +extern DECLSPEC int SDLCALL SDL_GL_BindTexture(SDL_Texture *texture, float *texw, float *texh); + +/** + * \brief Unbind a texture from the current OpenGL/ES/ES2 context. + * + * \param texture The SDL texture to unbind + * + * \return 0 on success, or -1 if the operation is not supported + */ +extern DECLSPEC int SDLCALL SDL_GL_UnbindTexture(SDL_Texture *texture); + +/** + * \brief Get the CAMetalLayer associated with the given Metal renderer + * + * \param renderer The renderer to query + * + * \return CAMetalLayer* on success, or NULL if the renderer isn't a Metal renderer + * + * \sa SDL_RenderGetMetalCommandEncoder() + */ +extern DECLSPEC void *SDLCALL SDL_RenderGetMetalLayer(SDL_Renderer * renderer); + +/** + * \brief Get the Metal command encoder for the current frame + * + * \param renderer The renderer to query + * + * \return id on success, or NULL if the renderer isn't a Metal renderer + * + * \sa SDL_RenderGetMetalLayer() + */ +extern DECLSPEC void *SDLCALL SDL_RenderGetMetalCommandEncoder(SDL_Renderer * renderer); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_render_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_revision.h b/thirdparty/include/SDL2/SDL_revision.h new file mode 100644 index 000000000..dfbc057fe --- /dev/null +++ b/thirdparty/include/SDL2/SDL_revision.h @@ -0,0 +1,2 @@ +#define SDL_REVISION "hg-13609:34cc7d3b69d3" +#define SDL_REVISION_NUMBER 13609 diff --git a/thirdparty/include/SDL2/SDL_rwops.h b/thirdparty/include/SDL2/SDL_rwops.h new file mode 100644 index 000000000..6674f5060 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_rwops.h @@ -0,0 +1,291 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_rwops.h + * + * This file provides a general interface for SDL to read and write + * data streams. It can easily be extended to files, memory, etc. + */ + +#ifndef SDL_rwops_h_ +#define SDL_rwops_h_ + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* RWops Types */ +#define SDL_RWOPS_UNKNOWN 0U /**< Unknown stream type */ +#define SDL_RWOPS_WINFILE 1U /**< Win32 file */ +#define SDL_RWOPS_STDFILE 2U /**< Stdio file */ +#define SDL_RWOPS_JNIFILE 3U /**< Android asset */ +#define SDL_RWOPS_MEMORY 4U /**< Memory stream */ +#define SDL_RWOPS_MEMORY_RO 5U /**< Read-Only memory stream */ + +/** + * This is the read/write operation structure -- very basic. + */ +typedef struct SDL_RWops +{ + /** + * Return the size of the file in this rwops, or -1 if unknown + */ + Sint64 (SDLCALL * size) (struct SDL_RWops * context); + + /** + * Seek to \c offset relative to \c whence, one of stdio's whence values: + * RW_SEEK_SET, RW_SEEK_CUR, RW_SEEK_END + * + * \return the final offset in the data stream, or -1 on error. + */ + Sint64 (SDLCALL * seek) (struct SDL_RWops * context, Sint64 offset, + int whence); + + /** + * Read up to \c maxnum objects each of size \c size from the data + * stream to the area pointed at by \c ptr. + * + * \return the number of objects read, or 0 at error or end of file. + */ + size_t (SDLCALL * read) (struct SDL_RWops * context, void *ptr, + size_t size, size_t maxnum); + + /** + * Write exactly \c num objects each of size \c size from the area + * pointed at by \c ptr to data stream. + * + * \return the number of objects written, or 0 at error or end of file. + */ + size_t (SDLCALL * write) (struct SDL_RWops * context, const void *ptr, + size_t size, size_t num); + + /** + * Close and free an allocated SDL_RWops structure. + * + * \return 0 if successful or -1 on write error when flushing data. + */ + int (SDLCALL * close) (struct SDL_RWops * context); + + Uint32 type; + union + { +#if defined(__ANDROID__) + struct + { + void *fileNameRef; + void *inputStreamRef; + void *readableByteChannelRef; + void *readMethod; + void *assetFileDescriptorRef; + long position; + long size; + long offset; + int fd; + } androidio; +#elif defined(__WIN32__) + struct + { + SDL_bool append; + void *h; + struct + { + void *data; + size_t size; + size_t left; + } buffer; + } windowsio; +#endif + +#ifdef HAVE_STDIO_H + struct + { + SDL_bool autoclose; + FILE *fp; + } stdio; +#endif + struct + { + Uint8 *base; + Uint8 *here; + Uint8 *stop; + } mem; + struct + { + void *data1; + void *data2; + } unknown; + } hidden; + +} SDL_RWops; + + +/** + * \name RWFrom functions + * + * Functions to create SDL_RWops structures from various data streams. + */ +/* @{ */ + +extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFile(const char *file, + const char *mode); + +#ifdef HAVE_STDIO_H +extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(FILE * fp, + SDL_bool autoclose); +#else +extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(void * fp, + SDL_bool autoclose); +#endif + +extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromMem(void *mem, int size); +extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromConstMem(const void *mem, + int size); + +/* @} *//* RWFrom functions */ + + +extern DECLSPEC SDL_RWops *SDLCALL SDL_AllocRW(void); +extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area); + +#define RW_SEEK_SET 0 /**< Seek from the beginning of data */ +#define RW_SEEK_CUR 1 /**< Seek relative to current read point */ +#define RW_SEEK_END 2 /**< Seek relative to the end of data */ + +/** + * Return the size of the file in this rwops, or -1 if unknown + */ +extern DECLSPEC Sint64 SDLCALL SDL_RWsize(SDL_RWops *context); + +/** + * Seek to \c offset relative to \c whence, one of stdio's whence values: + * RW_SEEK_SET, RW_SEEK_CUR, RW_SEEK_END + * + * \return the final offset in the data stream, or -1 on error. + */ +extern DECLSPEC Sint64 SDLCALL SDL_RWseek(SDL_RWops *context, + Sint64 offset, int whence); + +/** + * Return the current offset in the data stream, or -1 on error. + */ +extern DECLSPEC Sint64 SDLCALL SDL_RWtell(SDL_RWops *context); + +/** + * Read up to \c maxnum objects each of size \c size from the data + * stream to the area pointed at by \c ptr. + * + * \return the number of objects read, or 0 at error or end of file. + */ +extern DECLSPEC size_t SDLCALL SDL_RWread(SDL_RWops *context, + void *ptr, size_t size, size_t maxnum); + +/** + * Write exactly \c num objects each of size \c size from the area + * pointed at by \c ptr to data stream. + * + * \return the number of objects written, or 0 at error or end of file. + */ +extern DECLSPEC size_t SDLCALL SDL_RWwrite(SDL_RWops *context, + const void *ptr, size_t size, size_t num); + +/** + * Close and free an allocated SDL_RWops structure. + * + * \return 0 if successful or -1 on write error when flushing data. + */ +extern DECLSPEC int SDLCALL SDL_RWclose(SDL_RWops *context); + +/** + * Load all the data from an SDL data stream. + * + * The data is allocated with a zero byte at the end (null terminated) + * + * If \c datasize is not NULL, it is filled with the size of the data read. + * + * If \c freesrc is non-zero, the stream will be closed after being read. + * + * The data should be freed with SDL_free(). + * + * \return the data, or NULL if there was an error. + */ +extern DECLSPEC void *SDLCALL SDL_LoadFile_RW(SDL_RWops * src, size_t *datasize, + int freesrc); + +/** + * Load an entire file. + * + * The data is allocated with a zero byte at the end (null terminated) + * + * If \c datasize is not NULL, it is filled with the size of the data read. + * + * If \c freesrc is non-zero, the stream will be closed after being read. + * + * The data should be freed with SDL_free(). + * + * \return the data, or NULL if there was an error. + */ +extern DECLSPEC void *SDLCALL SDL_LoadFile(const char *file, size_t *datasize); + +/** + * \name Read endian functions + * + * Read an item of the specified endianness and return in native format. + */ +/* @{ */ +extern DECLSPEC Uint8 SDLCALL SDL_ReadU8(SDL_RWops * src); +extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops * src); +extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops * src); +extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops * src); +extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops * src); +extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops * src); +extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops * src); +/* @} *//* Read endian functions */ + +/** + * \name Write endian functions + * + * Write an item of native format to the specified endianness. + */ +/* @{ */ +extern DECLSPEC size_t SDLCALL SDL_WriteU8(SDL_RWops * dst, Uint8 value); +extern DECLSPEC size_t SDLCALL SDL_WriteLE16(SDL_RWops * dst, Uint16 value); +extern DECLSPEC size_t SDLCALL SDL_WriteBE16(SDL_RWops * dst, Uint16 value); +extern DECLSPEC size_t SDLCALL SDL_WriteLE32(SDL_RWops * dst, Uint32 value); +extern DECLSPEC size_t SDLCALL SDL_WriteBE32(SDL_RWops * dst, Uint32 value); +extern DECLSPEC size_t SDLCALL SDL_WriteLE64(SDL_RWops * dst, Uint64 value); +extern DECLSPEC size_t SDLCALL SDL_WriteBE64(SDL_RWops * dst, Uint64 value); +/* @} *//* Write endian functions */ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_rwops_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_scancode.h b/thirdparty/include/SDL2/SDL_scancode.h new file mode 100644 index 000000000..b19197d2b --- /dev/null +++ b/thirdparty/include/SDL2/SDL_scancode.h @@ -0,0 +1,413 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_scancode.h + * + * Defines keyboard scancodes. + */ + +#ifndef SDL_scancode_h_ +#define SDL_scancode_h_ + +#include "SDL_stdinc.h" + +/** + * \brief The SDL keyboard scancode representation. + * + * Values of this type are used to represent keyboard keys, among other places + * in the \link SDL_Keysym::scancode key.keysym.scancode \endlink field of the + * SDL_Event structure. + * + * The values in this enumeration are based on the USB usage page standard: + * https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf + */ +typedef enum +{ + SDL_SCANCODE_UNKNOWN = 0, + + /** + * \name Usage page 0x07 + * + * These values are from usage page 0x07 (USB keyboard page). + */ + /* @{ */ + + SDL_SCANCODE_A = 4, + SDL_SCANCODE_B = 5, + SDL_SCANCODE_C = 6, + SDL_SCANCODE_D = 7, + SDL_SCANCODE_E = 8, + SDL_SCANCODE_F = 9, + SDL_SCANCODE_G = 10, + SDL_SCANCODE_H = 11, + SDL_SCANCODE_I = 12, + SDL_SCANCODE_J = 13, + SDL_SCANCODE_K = 14, + SDL_SCANCODE_L = 15, + SDL_SCANCODE_M = 16, + SDL_SCANCODE_N = 17, + SDL_SCANCODE_O = 18, + SDL_SCANCODE_P = 19, + SDL_SCANCODE_Q = 20, + SDL_SCANCODE_R = 21, + SDL_SCANCODE_S = 22, + SDL_SCANCODE_T = 23, + SDL_SCANCODE_U = 24, + SDL_SCANCODE_V = 25, + SDL_SCANCODE_W = 26, + SDL_SCANCODE_X = 27, + SDL_SCANCODE_Y = 28, + SDL_SCANCODE_Z = 29, + + SDL_SCANCODE_1 = 30, + SDL_SCANCODE_2 = 31, + SDL_SCANCODE_3 = 32, + SDL_SCANCODE_4 = 33, + SDL_SCANCODE_5 = 34, + SDL_SCANCODE_6 = 35, + SDL_SCANCODE_7 = 36, + SDL_SCANCODE_8 = 37, + SDL_SCANCODE_9 = 38, + SDL_SCANCODE_0 = 39, + + SDL_SCANCODE_RETURN = 40, + SDL_SCANCODE_ESCAPE = 41, + SDL_SCANCODE_BACKSPACE = 42, + SDL_SCANCODE_TAB = 43, + SDL_SCANCODE_SPACE = 44, + + SDL_SCANCODE_MINUS = 45, + SDL_SCANCODE_EQUALS = 46, + SDL_SCANCODE_LEFTBRACKET = 47, + SDL_SCANCODE_RIGHTBRACKET = 48, + SDL_SCANCODE_BACKSLASH = 49, /**< Located at the lower left of the return + * key on ISO keyboards and at the right end + * of the QWERTY row on ANSI keyboards. + * Produces REVERSE SOLIDUS (backslash) and + * VERTICAL LINE in a US layout, REVERSE + * SOLIDUS and VERTICAL LINE in a UK Mac + * layout, NUMBER SIGN and TILDE in a UK + * Windows layout, DOLLAR SIGN and POUND SIGN + * in a Swiss German layout, NUMBER SIGN and + * APOSTROPHE in a German layout, GRAVE + * ACCENT and POUND SIGN in a French Mac + * layout, and ASTERISK and MICRO SIGN in a + * French Windows layout. + */ + SDL_SCANCODE_NONUSHASH = 50, /**< ISO USB keyboards actually use this code + * instead of 49 for the same key, but all + * OSes I've seen treat the two codes + * identically. So, as an implementor, unless + * your keyboard generates both of those + * codes and your OS treats them differently, + * you should generate SDL_SCANCODE_BACKSLASH + * instead of this code. As a user, you + * should not rely on this code because SDL + * will never generate it with most (all?) + * keyboards. + */ + SDL_SCANCODE_SEMICOLON = 51, + SDL_SCANCODE_APOSTROPHE = 52, + SDL_SCANCODE_GRAVE = 53, /**< Located in the top left corner (on both ANSI + * and ISO keyboards). Produces GRAVE ACCENT and + * TILDE in a US Windows layout and in US and UK + * Mac layouts on ANSI keyboards, GRAVE ACCENT + * and NOT SIGN in a UK Windows layout, SECTION + * SIGN and PLUS-MINUS SIGN in US and UK Mac + * layouts on ISO keyboards, SECTION SIGN and + * DEGREE SIGN in a Swiss German layout (Mac: + * only on ISO keyboards), CIRCUMFLEX ACCENT and + * DEGREE SIGN in a German layout (Mac: only on + * ISO keyboards), SUPERSCRIPT TWO and TILDE in a + * French Windows layout, COMMERCIAL AT and + * NUMBER SIGN in a French Mac layout on ISO + * keyboards, and LESS-THAN SIGN and GREATER-THAN + * SIGN in a Swiss German, German, or French Mac + * layout on ANSI keyboards. + */ + SDL_SCANCODE_COMMA = 54, + SDL_SCANCODE_PERIOD = 55, + SDL_SCANCODE_SLASH = 56, + + SDL_SCANCODE_CAPSLOCK = 57, + + SDL_SCANCODE_F1 = 58, + SDL_SCANCODE_F2 = 59, + SDL_SCANCODE_F3 = 60, + SDL_SCANCODE_F4 = 61, + SDL_SCANCODE_F5 = 62, + SDL_SCANCODE_F6 = 63, + SDL_SCANCODE_F7 = 64, + SDL_SCANCODE_F8 = 65, + SDL_SCANCODE_F9 = 66, + SDL_SCANCODE_F10 = 67, + SDL_SCANCODE_F11 = 68, + SDL_SCANCODE_F12 = 69, + + SDL_SCANCODE_PRINTSCREEN = 70, + SDL_SCANCODE_SCROLLLOCK = 71, + SDL_SCANCODE_PAUSE = 72, + SDL_SCANCODE_INSERT = 73, /**< insert on PC, help on some Mac keyboards (but + does send code 73, not 117) */ + SDL_SCANCODE_HOME = 74, + SDL_SCANCODE_PAGEUP = 75, + SDL_SCANCODE_DELETE = 76, + SDL_SCANCODE_END = 77, + SDL_SCANCODE_PAGEDOWN = 78, + SDL_SCANCODE_RIGHT = 79, + SDL_SCANCODE_LEFT = 80, + SDL_SCANCODE_DOWN = 81, + SDL_SCANCODE_UP = 82, + + SDL_SCANCODE_NUMLOCKCLEAR = 83, /**< num lock on PC, clear on Mac keyboards + */ + SDL_SCANCODE_KP_DIVIDE = 84, + SDL_SCANCODE_KP_MULTIPLY = 85, + SDL_SCANCODE_KP_MINUS = 86, + SDL_SCANCODE_KP_PLUS = 87, + SDL_SCANCODE_KP_ENTER = 88, + SDL_SCANCODE_KP_1 = 89, + SDL_SCANCODE_KP_2 = 90, + SDL_SCANCODE_KP_3 = 91, + SDL_SCANCODE_KP_4 = 92, + SDL_SCANCODE_KP_5 = 93, + SDL_SCANCODE_KP_6 = 94, + SDL_SCANCODE_KP_7 = 95, + SDL_SCANCODE_KP_8 = 96, + SDL_SCANCODE_KP_9 = 97, + SDL_SCANCODE_KP_0 = 98, + SDL_SCANCODE_KP_PERIOD = 99, + + SDL_SCANCODE_NONUSBACKSLASH = 100, /**< This is the additional key that ISO + * keyboards have over ANSI ones, + * located between left shift and Y. + * Produces GRAVE ACCENT and TILDE in a + * US or UK Mac layout, REVERSE SOLIDUS + * (backslash) and VERTICAL LINE in a + * US or UK Windows layout, and + * LESS-THAN SIGN and GREATER-THAN SIGN + * in a Swiss German, German, or French + * layout. */ + SDL_SCANCODE_APPLICATION = 101, /**< windows contextual menu, compose */ + SDL_SCANCODE_POWER = 102, /**< The USB document says this is a status flag, + * not a physical key - but some Mac keyboards + * do have a power key. */ + SDL_SCANCODE_KP_EQUALS = 103, + SDL_SCANCODE_F13 = 104, + SDL_SCANCODE_F14 = 105, + SDL_SCANCODE_F15 = 106, + SDL_SCANCODE_F16 = 107, + SDL_SCANCODE_F17 = 108, + SDL_SCANCODE_F18 = 109, + SDL_SCANCODE_F19 = 110, + SDL_SCANCODE_F20 = 111, + SDL_SCANCODE_F21 = 112, + SDL_SCANCODE_F22 = 113, + SDL_SCANCODE_F23 = 114, + SDL_SCANCODE_F24 = 115, + SDL_SCANCODE_EXECUTE = 116, + SDL_SCANCODE_HELP = 117, + SDL_SCANCODE_MENU = 118, + SDL_SCANCODE_SELECT = 119, + SDL_SCANCODE_STOP = 120, + SDL_SCANCODE_AGAIN = 121, /**< redo */ + SDL_SCANCODE_UNDO = 122, + SDL_SCANCODE_CUT = 123, + SDL_SCANCODE_COPY = 124, + SDL_SCANCODE_PASTE = 125, + SDL_SCANCODE_FIND = 126, + SDL_SCANCODE_MUTE = 127, + SDL_SCANCODE_VOLUMEUP = 128, + SDL_SCANCODE_VOLUMEDOWN = 129, +/* not sure whether there's a reason to enable these */ +/* SDL_SCANCODE_LOCKINGCAPSLOCK = 130, */ +/* SDL_SCANCODE_LOCKINGNUMLOCK = 131, */ +/* SDL_SCANCODE_LOCKINGSCROLLLOCK = 132, */ + SDL_SCANCODE_KP_COMMA = 133, + SDL_SCANCODE_KP_EQUALSAS400 = 134, + + SDL_SCANCODE_INTERNATIONAL1 = 135, /**< used on Asian keyboards, see + footnotes in USB doc */ + SDL_SCANCODE_INTERNATIONAL2 = 136, + SDL_SCANCODE_INTERNATIONAL3 = 137, /**< Yen */ + SDL_SCANCODE_INTERNATIONAL4 = 138, + SDL_SCANCODE_INTERNATIONAL5 = 139, + SDL_SCANCODE_INTERNATIONAL6 = 140, + SDL_SCANCODE_INTERNATIONAL7 = 141, + SDL_SCANCODE_INTERNATIONAL8 = 142, + SDL_SCANCODE_INTERNATIONAL9 = 143, + SDL_SCANCODE_LANG1 = 144, /**< Hangul/English toggle */ + SDL_SCANCODE_LANG2 = 145, /**< Hanja conversion */ + SDL_SCANCODE_LANG3 = 146, /**< Katakana */ + SDL_SCANCODE_LANG4 = 147, /**< Hiragana */ + SDL_SCANCODE_LANG5 = 148, /**< Zenkaku/Hankaku */ + SDL_SCANCODE_LANG6 = 149, /**< reserved */ + SDL_SCANCODE_LANG7 = 150, /**< reserved */ + SDL_SCANCODE_LANG8 = 151, /**< reserved */ + SDL_SCANCODE_LANG9 = 152, /**< reserved */ + + SDL_SCANCODE_ALTERASE = 153, /**< Erase-Eaze */ + SDL_SCANCODE_SYSREQ = 154, + SDL_SCANCODE_CANCEL = 155, + SDL_SCANCODE_CLEAR = 156, + SDL_SCANCODE_PRIOR = 157, + SDL_SCANCODE_RETURN2 = 158, + SDL_SCANCODE_SEPARATOR = 159, + SDL_SCANCODE_OUT = 160, + SDL_SCANCODE_OPER = 161, + SDL_SCANCODE_CLEARAGAIN = 162, + SDL_SCANCODE_CRSEL = 163, + SDL_SCANCODE_EXSEL = 164, + + SDL_SCANCODE_KP_00 = 176, + SDL_SCANCODE_KP_000 = 177, + SDL_SCANCODE_THOUSANDSSEPARATOR = 178, + SDL_SCANCODE_DECIMALSEPARATOR = 179, + SDL_SCANCODE_CURRENCYUNIT = 180, + SDL_SCANCODE_CURRENCYSUBUNIT = 181, + SDL_SCANCODE_KP_LEFTPAREN = 182, + SDL_SCANCODE_KP_RIGHTPAREN = 183, + SDL_SCANCODE_KP_LEFTBRACE = 184, + SDL_SCANCODE_KP_RIGHTBRACE = 185, + SDL_SCANCODE_KP_TAB = 186, + SDL_SCANCODE_KP_BACKSPACE = 187, + SDL_SCANCODE_KP_A = 188, + SDL_SCANCODE_KP_B = 189, + SDL_SCANCODE_KP_C = 190, + SDL_SCANCODE_KP_D = 191, + SDL_SCANCODE_KP_E = 192, + SDL_SCANCODE_KP_F = 193, + SDL_SCANCODE_KP_XOR = 194, + SDL_SCANCODE_KP_POWER = 195, + SDL_SCANCODE_KP_PERCENT = 196, + SDL_SCANCODE_KP_LESS = 197, + SDL_SCANCODE_KP_GREATER = 198, + SDL_SCANCODE_KP_AMPERSAND = 199, + SDL_SCANCODE_KP_DBLAMPERSAND = 200, + SDL_SCANCODE_KP_VERTICALBAR = 201, + SDL_SCANCODE_KP_DBLVERTICALBAR = 202, + SDL_SCANCODE_KP_COLON = 203, + SDL_SCANCODE_KP_HASH = 204, + SDL_SCANCODE_KP_SPACE = 205, + SDL_SCANCODE_KP_AT = 206, + SDL_SCANCODE_KP_EXCLAM = 207, + SDL_SCANCODE_KP_MEMSTORE = 208, + SDL_SCANCODE_KP_MEMRECALL = 209, + SDL_SCANCODE_KP_MEMCLEAR = 210, + SDL_SCANCODE_KP_MEMADD = 211, + SDL_SCANCODE_KP_MEMSUBTRACT = 212, + SDL_SCANCODE_KP_MEMMULTIPLY = 213, + SDL_SCANCODE_KP_MEMDIVIDE = 214, + SDL_SCANCODE_KP_PLUSMINUS = 215, + SDL_SCANCODE_KP_CLEAR = 216, + SDL_SCANCODE_KP_CLEARENTRY = 217, + SDL_SCANCODE_KP_BINARY = 218, + SDL_SCANCODE_KP_OCTAL = 219, + SDL_SCANCODE_KP_DECIMAL = 220, + SDL_SCANCODE_KP_HEXADECIMAL = 221, + + SDL_SCANCODE_LCTRL = 224, + SDL_SCANCODE_LSHIFT = 225, + SDL_SCANCODE_LALT = 226, /**< alt, option */ + SDL_SCANCODE_LGUI = 227, /**< windows, command (apple), meta */ + SDL_SCANCODE_RCTRL = 228, + SDL_SCANCODE_RSHIFT = 229, + SDL_SCANCODE_RALT = 230, /**< alt gr, option */ + SDL_SCANCODE_RGUI = 231, /**< windows, command (apple), meta */ + + SDL_SCANCODE_MODE = 257, /**< I'm not sure if this is really not covered + * by any of the above, but since there's a + * special KMOD_MODE for it I'm adding it here + */ + + /* @} *//* Usage page 0x07 */ + + /** + * \name Usage page 0x0C + * + * These values are mapped from usage page 0x0C (USB consumer page). + */ + /* @{ */ + + SDL_SCANCODE_AUDIONEXT = 258, + SDL_SCANCODE_AUDIOPREV = 259, + SDL_SCANCODE_AUDIOSTOP = 260, + SDL_SCANCODE_AUDIOPLAY = 261, + SDL_SCANCODE_AUDIOMUTE = 262, + SDL_SCANCODE_MEDIASELECT = 263, + SDL_SCANCODE_WWW = 264, + SDL_SCANCODE_MAIL = 265, + SDL_SCANCODE_CALCULATOR = 266, + SDL_SCANCODE_COMPUTER = 267, + SDL_SCANCODE_AC_SEARCH = 268, + SDL_SCANCODE_AC_HOME = 269, + SDL_SCANCODE_AC_BACK = 270, + SDL_SCANCODE_AC_FORWARD = 271, + SDL_SCANCODE_AC_STOP = 272, + SDL_SCANCODE_AC_REFRESH = 273, + SDL_SCANCODE_AC_BOOKMARKS = 274, + + /* @} *//* Usage page 0x0C */ + + /** + * \name Walther keys + * + * These are values that Christian Walther added (for mac keyboard?). + */ + /* @{ */ + + SDL_SCANCODE_BRIGHTNESSDOWN = 275, + SDL_SCANCODE_BRIGHTNESSUP = 276, + SDL_SCANCODE_DISPLAYSWITCH = 277, /**< display mirroring/dual display + switch, video mode switch */ + SDL_SCANCODE_KBDILLUMTOGGLE = 278, + SDL_SCANCODE_KBDILLUMDOWN = 279, + SDL_SCANCODE_KBDILLUMUP = 280, + SDL_SCANCODE_EJECT = 281, + SDL_SCANCODE_SLEEP = 282, + + SDL_SCANCODE_APP1 = 283, + SDL_SCANCODE_APP2 = 284, + + /* @} *//* Walther keys */ + + /** + * \name Usage page 0x0C (additional media keys) + * + * These values are mapped from usage page 0x0C (USB consumer page). + */ + /* @{ */ + + SDL_SCANCODE_AUDIOREWIND = 285, + SDL_SCANCODE_AUDIOFASTFORWARD = 286, + + /* @} *//* Usage page 0x0C (additional media keys) */ + + /* Add any other keys here. */ + + SDL_NUM_SCANCODES = 512 /**< not a key, just marks the number of scancodes + for array bounds */ +} SDL_Scancode; + +#endif /* SDL_scancode_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_sensor.h b/thirdparty/include/SDL2/SDL_sensor.h new file mode 100644 index 000000000..5122ee153 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_sensor.h @@ -0,0 +1,251 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_sensor.h + * + * Include file for SDL sensor event handling + * + */ + +#ifndef SDL_sensor_h_ +#define SDL_sensor_h_ + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +/* *INDENT-OFF* */ +extern "C" { +/* *INDENT-ON* */ +#endif + +/** + * \brief SDL_sensor.h + * + * In order to use these functions, SDL_Init() must have been called + * with the ::SDL_INIT_SENSOR flag. This causes SDL to scan the system + * for sensors, and load appropriate drivers. + */ + +struct _SDL_Sensor; +typedef struct _SDL_Sensor SDL_Sensor; + +/** + * This is a unique ID for a sensor for the time it is connected to the system, + * and is never reused for the lifetime of the application. + * + * The ID value starts at 0 and increments from there. The value -1 is an invalid ID. + */ +typedef Sint32 SDL_SensorID; + +/* The different sensors defined by SDL + * + * Additional sensors may be available, using platform dependent semantics. + * + * Hare are the additional Android sensors: + * https://developer.android.com/reference/android/hardware/SensorEvent.html#values + */ +typedef enum +{ + SDL_SENSOR_INVALID = -1, /**< Returned for an invalid sensor */ + SDL_SENSOR_UNKNOWN, /**< Unknown sensor type */ + SDL_SENSOR_ACCEL, /**< Accelerometer */ + SDL_SENSOR_GYRO /**< Gyroscope */ +} SDL_SensorType; + +/** + * Accelerometer sensor + * + * The accelerometer returns the current acceleration in SI meters per + * second squared. This includes gravity, so a device at rest will have + * an acceleration of SDL_STANDARD_GRAVITY straight down. + * + * values[0]: Acceleration on the x axis + * values[1]: Acceleration on the y axis + * values[2]: Acceleration on the z axis + * + * For phones held in portrait mode, the axes are defined as follows: + * -X ... +X : left ... right + * -Y ... +Y : bottom ... top + * -Z ... +Z : farther ... closer + * + * The axis data is not changed when the phone is rotated. + * + * \sa SDL_GetDisplayOrientation() + */ +#define SDL_STANDARD_GRAVITY 9.80665f + +/** + * Gyroscope sensor + * + * The gyroscope returns the current rate of rotation in radians per second. + * The rotation is positive in the counter-clockwise direction. That is, + * an observer looking from a positive location on one of the axes would + * see positive rotation on that axis when it appeared to be rotating + * counter-clockwise. + * + * values[0]: Angular speed around the x axis + * values[1]: Angular speed around the y axis + * values[2]: Angular speed around the z axis + * + * For phones held in portrait mode, the axes are defined as follows: + * -X ... +X : left ... right + * -Y ... +Y : bottom ... top + * -Z ... +Z : farther ... closer + * + * The axis data is not changed when the phone is rotated. + * + * \sa SDL_GetDisplayOrientation() + */ + +/* Function prototypes */ + +/** + * \brief Count the number of sensors attached to the system right now + */ +extern DECLSPEC int SDLCALL SDL_NumSensors(void); + +/** + * \brief Get the implementation dependent name of a sensor. + * + * This can be called before any sensors are opened. + * + * \return The sensor name, or NULL if device_index is out of range. + */ +extern DECLSPEC const char *SDLCALL SDL_SensorGetDeviceName(int device_index); + +/** + * \brief Get the type of a sensor. + * + * This can be called before any sensors are opened. + * + * \return The sensor type, or SDL_SENSOR_INVALID if device_index is out of range. + */ +extern DECLSPEC SDL_SensorType SDLCALL SDL_SensorGetDeviceType(int device_index); + +/** + * \brief Get the platform dependent type of a sensor. + * + * This can be called before any sensors are opened. + * + * \return The sensor platform dependent type, or -1 if device_index is out of range. + */ +extern DECLSPEC int SDLCALL SDL_SensorGetDeviceNonPortableType(int device_index); + +/** + * \brief Get the instance ID of a sensor. + * + * This can be called before any sensors are opened. + * + * \return The sensor instance ID, or -1 if device_index is out of range. + */ +extern DECLSPEC SDL_SensorID SDLCALL SDL_SensorGetDeviceInstanceID(int device_index); + +/** + * \brief Open a sensor for use. + * + * The index passed as an argument refers to the N'th sensor on the system. + * + * \return A sensor identifier, or NULL if an error occurred. + */ +extern DECLSPEC SDL_Sensor *SDLCALL SDL_SensorOpen(int device_index); + +/** + * Return the SDL_Sensor associated with an instance id. + */ +extern DECLSPEC SDL_Sensor *SDLCALL SDL_SensorFromInstanceID(SDL_SensorID instance_id); + +/** + * \brief Get the implementation dependent name of a sensor. + * + * \return The sensor name, or NULL if the sensor is NULL. + */ +extern DECLSPEC const char *SDLCALL SDL_SensorGetName(SDL_Sensor *sensor); + +/** + * \brief Get the type of a sensor. + * + * This can be called before any sensors are opened. + * + * \return The sensor type, or SDL_SENSOR_INVALID if the sensor is NULL. + */ +extern DECLSPEC SDL_SensorType SDLCALL SDL_SensorGetType(SDL_Sensor *sensor); + +/** + * \brief Get the platform dependent type of a sensor. + * + * This can be called before any sensors are opened. + * + * \return The sensor platform dependent type, or -1 if the sensor is NULL. + */ +extern DECLSPEC int SDLCALL SDL_SensorGetNonPortableType(SDL_Sensor *sensor); + +/** + * \brief Get the instance ID of a sensor. + * + * This can be called before any sensors are opened. + * + * \return The sensor instance ID, or -1 if the sensor is NULL. + */ +extern DECLSPEC SDL_SensorID SDLCALL SDL_SensorGetInstanceID(SDL_Sensor *sensor); + +/** + * Get the current state of an opened sensor. + * + * The number of values and interpretation of the data is sensor dependent. + * + * \param sensor The sensor to query + * \param data A pointer filled with the current sensor state + * \param num_values The number of values to write to data + * + * \return 0 or -1 if an error occurred. + */ +extern DECLSPEC int SDLCALL SDL_SensorGetData(SDL_Sensor * sensor, float *data, int num_values); + +/** + * Close a sensor previously opened with SDL_SensorOpen() + */ +extern DECLSPEC void SDLCALL SDL_SensorClose(SDL_Sensor * sensor); + +/** + * Update the current state of the open sensors. + * + * This is called automatically by the event loop if sensor events are enabled. + * + * This needs to be called from the thread that initialized the sensor subsystem. + */ +extern DECLSPEC void SDLCALL SDL_SensorUpdate(void); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +/* *INDENT-OFF* */ +} +/* *INDENT-ON* */ +#endif +#include "close_code.h" + +#endif /* SDL_sensor_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_shape.h b/thirdparty/include/SDL2/SDL_shape.h new file mode 100644 index 000000000..cbd9debd6 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_shape.h @@ -0,0 +1,144 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_shape_h_ +#define SDL_shape_h_ + +#include "SDL_stdinc.h" +#include "SDL_pixels.h" +#include "SDL_rect.h" +#include "SDL_surface.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** \file SDL_shape.h + * + * Header file for the shaped window API. + */ + +#define SDL_NONSHAPEABLE_WINDOW -1 +#define SDL_INVALID_SHAPE_ARGUMENT -2 +#define SDL_WINDOW_LACKS_SHAPE -3 + +/** + * \brief Create a window that can be shaped with the specified position, dimensions, and flags. + * + * \param title The title of the window, in UTF-8 encoding. + * \param x The x position of the window, ::SDL_WINDOWPOS_CENTERED, or + * ::SDL_WINDOWPOS_UNDEFINED. + * \param y The y position of the window, ::SDL_WINDOWPOS_CENTERED, or + * ::SDL_WINDOWPOS_UNDEFINED. + * \param w The width of the window. + * \param h The height of the window. + * \param flags The flags for the window, a mask of SDL_WINDOW_BORDERLESS with any of the following: + * ::SDL_WINDOW_OPENGL, ::SDL_WINDOW_INPUT_GRABBED, + * ::SDL_WINDOW_HIDDEN, ::SDL_WINDOW_RESIZABLE, + * ::SDL_WINDOW_MAXIMIZED, ::SDL_WINDOW_MINIMIZED, + * ::SDL_WINDOW_BORDERLESS is always set, and ::SDL_WINDOW_FULLSCREEN is always unset. + * + * \return The window created, or NULL if window creation failed. + * + * \sa SDL_DestroyWindow() + */ +extern DECLSPEC SDL_Window * SDLCALL SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags); + +/** + * \brief Return whether the given window is a shaped window. + * + * \param window The window to query for being shaped. + * + * \return SDL_TRUE if the window is a window that can be shaped, SDL_FALSE if the window is unshaped or NULL. + * + * \sa SDL_CreateShapedWindow + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IsShapedWindow(const SDL_Window *window); + +/** \brief An enum denoting the specific type of contents present in an SDL_WindowShapeParams union. */ +typedef enum { + /** \brief The default mode, a binarized alpha cutoff of 1. */ + ShapeModeDefault, + /** \brief A binarized alpha cutoff with a given integer value. */ + ShapeModeBinarizeAlpha, + /** \brief A binarized alpha cutoff with a given integer value, but with the opposite comparison. */ + ShapeModeReverseBinarizeAlpha, + /** \brief A color key is applied. */ + ShapeModeColorKey +} WindowShapeMode; + +#define SDL_SHAPEMODEALPHA(mode) (mode == ShapeModeDefault || mode == ShapeModeBinarizeAlpha || mode == ShapeModeReverseBinarizeAlpha) + +/** \brief A union containing parameters for shaped windows. */ +typedef union { + /** \brief A cutoff alpha value for binarization of the window shape's alpha channel. */ + Uint8 binarizationCutoff; + SDL_Color colorKey; +} SDL_WindowShapeParams; + +/** \brief A struct that tags the SDL_WindowShapeParams union with an enum describing the type of its contents. */ +typedef struct SDL_WindowShapeMode { + /** \brief The mode of these window-shape parameters. */ + WindowShapeMode mode; + /** \brief Window-shape parameters. */ + SDL_WindowShapeParams parameters; +} SDL_WindowShapeMode; + +/** + * \brief Set the shape and parameters of a shaped window. + * + * \param window The shaped window whose parameters should be set. + * \param shape A surface encoding the desired shape for the window. + * \param shape_mode The parameters to set for the shaped window. + * + * \return 0 on success, SDL_INVALID_SHAPE_ARGUMENT on an invalid shape argument, or SDL_NONSHAPEABLE_WINDOW + * if the SDL_Window given does not reference a valid shaped window. + * + * \sa SDL_WindowShapeMode + * \sa SDL_GetShapedWindowMode. + */ +extern DECLSPEC int SDLCALL SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode); + +/** + * \brief Get the shape parameters of a shaped window. + * + * \param window The shaped window whose parameters should be retrieved. + * \param shape_mode An empty shape-mode structure to fill, or NULL to check whether the window has a shape. + * + * \return 0 if the window has a shape and, provided shape_mode was not NULL, shape_mode has been filled with the mode + * data, SDL_NONSHAPEABLE_WINDOW if the SDL_Window given is not a shaped window, or SDL_WINDOW_LACKS_SHAPE if + * the SDL_Window given is a shapeable window currently lacking a shape. + * + * \sa SDL_WindowShapeMode + * \sa SDL_SetWindowShape + */ +extern DECLSPEC int SDLCALL SDL_GetShapedWindowMode(SDL_Window *window,SDL_WindowShapeMode *shape_mode); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_shape_h_ */ diff --git a/thirdparty/include/SDL2/SDL_stdinc.h b/thirdparty/include/SDL2/SDL_stdinc.h new file mode 100644 index 000000000..d96e18bc2 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_stdinc.h @@ -0,0 +1,617 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_stdinc.h + * + * This is a general header that includes C language support. + */ + +#ifndef SDL_stdinc_h_ +#define SDL_stdinc_h_ + +#include "SDL_config.h" + +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_STDIO_H +#include +#endif +#if defined(STDC_HEADERS) +# include +# include +# include +#else +# if defined(HAVE_STDLIB_H) +# include +# elif defined(HAVE_MALLOC_H) +# include +# endif +# if defined(HAVE_STDDEF_H) +# include +# endif +# if defined(HAVE_STDARG_H) +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H) +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_WCHAR_H +# include +#endif +#if defined(HAVE_INTTYPES_H) +# include +#elif defined(HAVE_STDINT_H) +# include +#endif +#ifdef HAVE_CTYPE_H +# include +#endif +#ifdef HAVE_MATH_H +# if defined(__WINRT__) +/* Defining _USE_MATH_DEFINES is required to get M_PI to be defined on + WinRT. See http://msdn.microsoft.com/en-us/library/4hwaceh6.aspx + for more information. +*/ +# define _USE_MATH_DEFINES +# endif +# include +#endif +#ifdef HAVE_FLOAT_H +# include +#endif +#if defined(HAVE_ALLOCA) && !defined(alloca) +# if defined(HAVE_ALLOCA_H) +# include +# elif defined(__GNUC__) +# define alloca __builtin_alloca +# elif defined(_MSC_VER) +# include +# define alloca _alloca +# elif defined(__WATCOMC__) +# include +# elif defined(__BORLANDC__) +# include +# elif defined(__DMC__) +# include +# elif defined(__AIX__) +#pragma alloca +# elif defined(__MRC__) +void *alloca(unsigned); +# else +char *alloca(); +# endif +#endif + +/** + * The number of elements in an array. + */ +#define SDL_arraysize(array) (sizeof(array)/sizeof(array[0])) +#define SDL_TABLESIZE(table) SDL_arraysize(table) + +/** + * Macro useful for building other macros with strings in them + * + * e.g. #define LOG_ERROR(X) OutputDebugString(SDL_STRINGIFY_ARG(__FUNCTION__) ": " X "\n") + */ +#define SDL_STRINGIFY_ARG(arg) #arg + +/** + * \name Cast operators + * + * Use proper C++ casts when compiled as C++ to be compatible with the option + * -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above). + */ +/* @{ */ +#ifdef __cplusplus +#define SDL_reinterpret_cast(type, expression) reinterpret_cast(expression) +#define SDL_static_cast(type, expression) static_cast(expression) +#define SDL_const_cast(type, expression) const_cast(expression) +#else +#define SDL_reinterpret_cast(type, expression) ((type)(expression)) +#define SDL_static_cast(type, expression) ((type)(expression)) +#define SDL_const_cast(type, expression) ((type)(expression)) +#endif +/* @} *//* Cast operators */ + +/* Define a four character code as a Uint32 */ +#define SDL_FOURCC(A, B, C, D) \ + ((SDL_static_cast(Uint32, SDL_static_cast(Uint8, (A))) << 0) | \ + (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (B))) << 8) | \ + (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (C))) << 16) | \ + (SDL_static_cast(Uint32, SDL_static_cast(Uint8, (D))) << 24)) + +/** + * \name Basic data types + */ +/* @{ */ + +#ifdef __CC_ARM +/* ARM's compiler throws warnings if we use an enum: like "SDL_bool x = a < b;" */ +#define SDL_FALSE 0 +#define SDL_TRUE 1 +typedef int SDL_bool; +#else +typedef enum +{ + SDL_FALSE = 0, + SDL_TRUE = 1 +} SDL_bool; +#endif + +/** + * \brief A signed 8-bit integer type. + */ +#define SDL_MAX_SINT8 ((Sint8)0x7F) /* 127 */ +#define SDL_MIN_SINT8 ((Sint8)(~0x7F)) /* -128 */ +typedef int8_t Sint8; +/** + * \brief An unsigned 8-bit integer type. + */ +#define SDL_MAX_UINT8 ((Uint8)0xFF) /* 255 */ +#define SDL_MIN_UINT8 ((Uint8)0x00) /* 0 */ +typedef uint8_t Uint8; +/** + * \brief A signed 16-bit integer type. + */ +#define SDL_MAX_SINT16 ((Sint16)0x7FFF) /* 32767 */ +#define SDL_MIN_SINT16 ((Sint16)(~0x7FFF)) /* -32768 */ +typedef int16_t Sint16; +/** + * \brief An unsigned 16-bit integer type. + */ +#define SDL_MAX_UINT16 ((Uint16)0xFFFF) /* 65535 */ +#define SDL_MIN_UINT16 ((Uint16)0x0000) /* 0 */ +typedef uint16_t Uint16; +/** + * \brief A signed 32-bit integer type. + */ +#define SDL_MAX_SINT32 ((Sint32)0x7FFFFFFF) /* 2147483647 */ +#define SDL_MIN_SINT32 ((Sint32)(~0x7FFFFFFF)) /* -2147483648 */ +typedef int32_t Sint32; +/** + * \brief An unsigned 32-bit integer type. + */ +#define SDL_MAX_UINT32 ((Uint32)0xFFFFFFFFu) /* 4294967295 */ +#define SDL_MIN_UINT32 ((Uint32)0x00000000) /* 0 */ +typedef uint32_t Uint32; + +/** + * \brief A signed 64-bit integer type. + */ +#define SDL_MAX_SINT64 ((Sint64)0x7FFFFFFFFFFFFFFFll) /* 9223372036854775807 */ +#define SDL_MIN_SINT64 ((Sint64)(~0x7FFFFFFFFFFFFFFFll)) /* -9223372036854775808 */ +typedef int64_t Sint64; +/** + * \brief An unsigned 64-bit integer type. + */ +#define SDL_MAX_UINT64 ((Uint64)0xFFFFFFFFFFFFFFFFull) /* 18446744073709551615 */ +#define SDL_MIN_UINT64 ((Uint64)(0x0000000000000000ull)) /* 0 */ +typedef uint64_t Uint64; + +/* @} *//* Basic data types */ + +/* Make sure we have macros for printing 64 bit values. + * should define these but this is not true all platforms. + * (for example win32) */ +#ifndef SDL_PRIs64 +#ifdef PRIs64 +#define SDL_PRIs64 PRIs64 +#elif defined(__WIN32__) +#define SDL_PRIs64 "I64d" +#elif defined(__LINUX__) && defined(__LP64__) +#define SDL_PRIs64 "ld" +#else +#define SDL_PRIs64 "lld" +#endif +#endif +#ifndef SDL_PRIu64 +#ifdef PRIu64 +#define SDL_PRIu64 PRIu64 +#elif defined(__WIN32__) +#define SDL_PRIu64 "I64u" +#elif defined(__LINUX__) && defined(__LP64__) +#define SDL_PRIu64 "lu" +#else +#define SDL_PRIu64 "llu" +#endif +#endif +#ifndef SDL_PRIx64 +#ifdef PRIx64 +#define SDL_PRIx64 PRIx64 +#elif defined(__WIN32__) +#define SDL_PRIx64 "I64x" +#elif defined(__LINUX__) && defined(__LP64__) +#define SDL_PRIx64 "lx" +#else +#define SDL_PRIx64 "llx" +#endif +#endif +#ifndef SDL_PRIX64 +#ifdef PRIX64 +#define SDL_PRIX64 PRIX64 +#elif defined(__WIN32__) +#define SDL_PRIX64 "I64X" +#elif defined(__LINUX__) && defined(__LP64__) +#define SDL_PRIX64 "lX" +#else +#define SDL_PRIX64 "llX" +#endif +#endif + +/* Annotations to help code analysis tools */ +#ifdef SDL_DISABLE_ANALYZE_MACROS +#define SDL_IN_BYTECAP(x) +#define SDL_INOUT_Z_CAP(x) +#define SDL_OUT_Z_CAP(x) +#define SDL_OUT_CAP(x) +#define SDL_OUT_BYTECAP(x) +#define SDL_OUT_Z_BYTECAP(x) +#define SDL_PRINTF_FORMAT_STRING +#define SDL_SCANF_FORMAT_STRING +#define SDL_PRINTF_VARARG_FUNC( fmtargnumber ) +#define SDL_SCANF_VARARG_FUNC( fmtargnumber ) +#else +#if defined(_MSC_VER) && (_MSC_VER >= 1600) /* VS 2010 and above */ +#include + +#define SDL_IN_BYTECAP(x) _In_bytecount_(x) +#define SDL_INOUT_Z_CAP(x) _Inout_z_cap_(x) +#define SDL_OUT_Z_CAP(x) _Out_z_cap_(x) +#define SDL_OUT_CAP(x) _Out_cap_(x) +#define SDL_OUT_BYTECAP(x) _Out_bytecap_(x) +#define SDL_OUT_Z_BYTECAP(x) _Out_z_bytecap_(x) + +#define SDL_PRINTF_FORMAT_STRING _Printf_format_string_ +#define SDL_SCANF_FORMAT_STRING _Scanf_format_string_impl_ +#else +#define SDL_IN_BYTECAP(x) +#define SDL_INOUT_Z_CAP(x) +#define SDL_OUT_Z_CAP(x) +#define SDL_OUT_CAP(x) +#define SDL_OUT_BYTECAP(x) +#define SDL_OUT_Z_BYTECAP(x) +#define SDL_PRINTF_FORMAT_STRING +#define SDL_SCANF_FORMAT_STRING +#endif +#if defined(__GNUC__) +#define SDL_PRINTF_VARARG_FUNC( fmtargnumber ) __attribute__ (( format( __printf__, fmtargnumber, fmtargnumber+1 ))) +#define SDL_SCANF_VARARG_FUNC( fmtargnumber ) __attribute__ (( format( __scanf__, fmtargnumber, fmtargnumber+1 ))) +#else +#define SDL_PRINTF_VARARG_FUNC( fmtargnumber ) +#define SDL_SCANF_VARARG_FUNC( fmtargnumber ) +#endif +#endif /* SDL_DISABLE_ANALYZE_MACROS */ + +#define SDL_COMPILE_TIME_ASSERT(name, x) \ + typedef int SDL_compile_time_assert_ ## name[(x) * 2 - 1] +/** \cond */ +#ifndef DOXYGEN_SHOULD_IGNORE_THIS +SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1); +SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1); +SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2); +SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2); +SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4); +SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4); +SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8); +SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8); +#endif /* DOXYGEN_SHOULD_IGNORE_THIS */ +/** \endcond */ + +/* Check to make sure enums are the size of ints, for structure packing. + For both Watcom C/C++ and Borland C/C++ the compiler option that makes + enums having the size of an int must be enabled. + This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11). +*/ + +/** \cond */ +#ifndef DOXYGEN_SHOULD_IGNORE_THIS +#if !defined(__ANDROID__) + /* TODO: include/SDL_stdinc.h:174: error: size of array 'SDL_dummy_enum' is negative */ +typedef enum +{ + DUMMY_ENUM_VALUE +} SDL_DUMMY_ENUM; + +SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int)); +#endif +#endif /* DOXYGEN_SHOULD_IGNORE_THIS */ +/** \endcond */ + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef HAVE_ALLOCA +#define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*(count)) +#define SDL_stack_free(data) +#else +#define SDL_stack_alloc(type, count) (type*)SDL_malloc(sizeof(type)*(count)) +#define SDL_stack_free(data) SDL_free(data) +#endif + +extern DECLSPEC void *SDLCALL SDL_malloc(size_t size); +extern DECLSPEC void *SDLCALL SDL_calloc(size_t nmemb, size_t size); +extern DECLSPEC void *SDLCALL SDL_realloc(void *mem, size_t size); +extern DECLSPEC void SDLCALL SDL_free(void *mem); + +typedef void *(SDLCALL *SDL_malloc_func)(size_t size); +typedef void *(SDLCALL *SDL_calloc_func)(size_t nmemb, size_t size); +typedef void *(SDLCALL *SDL_realloc_func)(void *mem, size_t size); +typedef void (SDLCALL *SDL_free_func)(void *mem); + +/** + * \brief Get the current set of SDL memory functions + */ +extern DECLSPEC void SDLCALL SDL_GetMemoryFunctions(SDL_malloc_func *malloc_func, + SDL_calloc_func *calloc_func, + SDL_realloc_func *realloc_func, + SDL_free_func *free_func); + +/** + * \brief Replace SDL's memory allocation functions with a custom set + * + * \note If you are replacing SDL's memory functions, you should call + * SDL_GetNumAllocations() and be very careful if it returns non-zero. + * That means that your free function will be called with memory + * allocated by the previous memory allocation functions. + */ +extern DECLSPEC int SDLCALL SDL_SetMemoryFunctions(SDL_malloc_func malloc_func, + SDL_calloc_func calloc_func, + SDL_realloc_func realloc_func, + SDL_free_func free_func); + +/** + * \brief Get the number of outstanding (unfreed) allocations + */ +extern DECLSPEC int SDLCALL SDL_GetNumAllocations(void); + +extern DECLSPEC char *SDLCALL SDL_getenv(const char *name); +extern DECLSPEC int SDLCALL SDL_setenv(const char *name, const char *value, int overwrite); + +extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, int (*compare) (const void *, const void *)); + +extern DECLSPEC int SDLCALL SDL_abs(int x); + +/* !!! FIXME: these have side effects. You probably shouldn't use them. */ +/* !!! FIXME: Maybe we do forceinline functions of SDL_mini, SDL_minf, etc? */ +#define SDL_min(x, y) (((x) < (y)) ? (x) : (y)) +#define SDL_max(x, y) (((x) > (y)) ? (x) : (y)) + +extern DECLSPEC int SDLCALL SDL_isdigit(int x); +extern DECLSPEC int SDLCALL SDL_isspace(int x); +extern DECLSPEC int SDLCALL SDL_isupper(int x); +extern DECLSPEC int SDLCALL SDL_islower(int x); +extern DECLSPEC int SDLCALL SDL_toupper(int x); +extern DECLSPEC int SDLCALL SDL_tolower(int x); + +extern DECLSPEC void *SDLCALL SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, size_t len); + +#define SDL_zero(x) SDL_memset(&(x), 0, sizeof((x))) +#define SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x))) +#define SDL_zeroa(x) SDL_memset((x), 0, sizeof((x))) + +/* Note that memset() is a byte assignment and this is a 32-bit assignment, so they're not directly equivalent. */ +SDL_FORCE_INLINE void SDL_memset4(void *dst, Uint32 val, size_t dwords) +{ +#ifdef __APPLE__ + memset_pattern4(dst, &val, dwords * 4); +#elif defined(__GNUC__) && defined(i386) + int u0, u1, u2; + __asm__ __volatile__ ( + "cld \n\t" + "rep ; stosl \n\t" + : "=&D" (u0), "=&a" (u1), "=&c" (u2) + : "0" (dst), "1" (val), "2" (SDL_static_cast(Uint32, dwords)) + : "memory" + ); +#else + size_t _n = (dwords + 3) / 4; + Uint32 *_p = SDL_static_cast(Uint32 *, dst); + Uint32 _val = (val); + if (dwords == 0) + return; + switch (dwords % 4) + { + case 0: do { *_p++ = _val; /* fallthrough */ + case 3: *_p++ = _val; /* fallthrough */ + case 2: *_p++ = _val; /* fallthrough */ + case 1: *_p++ = _val; /* fallthrough */ + } while ( --_n ); + } +#endif +} + +extern DECLSPEC void *SDLCALL SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len); + +extern DECLSPEC void *SDLCALL SDL_memmove(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len); +extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len); + +extern DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t *wstr); +extern DECLSPEC size_t SDLCALL SDL_wcslcpy(SDL_OUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen); +extern DECLSPEC size_t SDLCALL SDL_wcslcat(SDL_INOUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen); +extern DECLSPEC wchar_t *SDLCALL SDL_wcsdup(const wchar_t *wstr); +extern DECLSPEC wchar_t *SDLCALL SDL_wcsstr(const wchar_t *haystack, const wchar_t *needle); + +extern DECLSPEC int SDLCALL SDL_wcscmp(const wchar_t *str1, const wchar_t *str2); +extern DECLSPEC int SDLCALL SDL_wcsncmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen); + +extern DECLSPEC size_t SDLCALL SDL_strlen(const char *str); +extern DECLSPEC size_t SDLCALL SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen); +extern DECLSPEC size_t SDLCALL SDL_utf8strlcpy(SDL_OUT_Z_CAP(dst_bytes) char *dst, const char *src, size_t dst_bytes); +extern DECLSPEC size_t SDLCALL SDL_strlcat(SDL_INOUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen); +extern DECLSPEC char *SDLCALL SDL_strdup(const char *str); +extern DECLSPEC char *SDLCALL SDL_strrev(char *str); +extern DECLSPEC char *SDLCALL SDL_strupr(char *str); +extern DECLSPEC char *SDLCALL SDL_strlwr(char *str); +extern DECLSPEC char *SDLCALL SDL_strchr(const char *str, int c); +extern DECLSPEC char *SDLCALL SDL_strrchr(const char *str, int c); +extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, const char *needle); +extern DECLSPEC char *SDLCALL SDL_strtokr(char *s1, const char *s2, char **saveptr); +extern DECLSPEC size_t SDLCALL SDL_utf8strlen(const char *str); + +extern DECLSPEC char *SDLCALL SDL_itoa(int value, char *str, int radix); +extern DECLSPEC char *SDLCALL SDL_uitoa(unsigned int value, char *str, int radix); +extern DECLSPEC char *SDLCALL SDL_ltoa(long value, char *str, int radix); +extern DECLSPEC char *SDLCALL SDL_ultoa(unsigned long value, char *str, int radix); +extern DECLSPEC char *SDLCALL SDL_lltoa(Sint64 value, char *str, int radix); +extern DECLSPEC char *SDLCALL SDL_ulltoa(Uint64 value, char *str, int radix); + +extern DECLSPEC int SDLCALL SDL_atoi(const char *str); +extern DECLSPEC double SDLCALL SDL_atof(const char *str); +extern DECLSPEC long SDLCALL SDL_strtol(const char *str, char **endp, int base); +extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *str, char **endp, int base); +extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *str, char **endp, int base); +extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *str, char **endp, int base); +extern DECLSPEC double SDLCALL SDL_strtod(const char *str, char **endp); + +extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2); +extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen); +extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2); +extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t len); + +extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, ...) SDL_SCANF_VARARG_FUNC(2); +extern DECLSPEC int SDLCALL SDL_vsscanf(const char *text, const char *fmt, va_list ap); +extern DECLSPEC int SDLCALL SDL_snprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ... ) SDL_PRINTF_VARARG_FUNC(3); +extern DECLSPEC int SDLCALL SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, va_list ap); + +#ifndef HAVE_M_PI +#ifndef M_PI +#define M_PI 3.14159265358979323846264338327950288 /**< pi */ +#endif +#endif + +extern DECLSPEC double SDLCALL SDL_acos(double x); +extern DECLSPEC float SDLCALL SDL_acosf(float x); +extern DECLSPEC double SDLCALL SDL_asin(double x); +extern DECLSPEC float SDLCALL SDL_asinf(float x); +extern DECLSPEC double SDLCALL SDL_atan(double x); +extern DECLSPEC float SDLCALL SDL_atanf(float x); +extern DECLSPEC double SDLCALL SDL_atan2(double x, double y); +extern DECLSPEC float SDLCALL SDL_atan2f(float x, float y); +extern DECLSPEC double SDLCALL SDL_ceil(double x); +extern DECLSPEC float SDLCALL SDL_ceilf(float x); +extern DECLSPEC double SDLCALL SDL_copysign(double x, double y); +extern DECLSPEC float SDLCALL SDL_copysignf(float x, float y); +extern DECLSPEC double SDLCALL SDL_cos(double x); +extern DECLSPEC float SDLCALL SDL_cosf(float x); +extern DECLSPEC double SDLCALL SDL_exp(double x); +extern DECLSPEC float SDLCALL SDL_expf(float x); +extern DECLSPEC double SDLCALL SDL_fabs(double x); +extern DECLSPEC float SDLCALL SDL_fabsf(float x); +extern DECLSPEC double SDLCALL SDL_floor(double x); +extern DECLSPEC float SDLCALL SDL_floorf(float x); +extern DECLSPEC double SDLCALL SDL_fmod(double x, double y); +extern DECLSPEC float SDLCALL SDL_fmodf(float x, float y); +extern DECLSPEC double SDLCALL SDL_log(double x); +extern DECLSPEC float SDLCALL SDL_logf(float x); +extern DECLSPEC double SDLCALL SDL_log10(double x); +extern DECLSPEC float SDLCALL SDL_log10f(float x); +extern DECLSPEC double SDLCALL SDL_pow(double x, double y); +extern DECLSPEC float SDLCALL SDL_powf(float x, float y); +extern DECLSPEC double SDLCALL SDL_scalbn(double x, int n); +extern DECLSPEC float SDLCALL SDL_scalbnf(float x, int n); +extern DECLSPEC double SDLCALL SDL_sin(double x); +extern DECLSPEC float SDLCALL SDL_sinf(float x); +extern DECLSPEC double SDLCALL SDL_sqrt(double x); +extern DECLSPEC float SDLCALL SDL_sqrtf(float x); +extern DECLSPEC double SDLCALL SDL_tan(double x); +extern DECLSPEC float SDLCALL SDL_tanf(float x); + +/* The SDL implementation of iconv() returns these error codes */ +#define SDL_ICONV_ERROR (size_t)-1 +#define SDL_ICONV_E2BIG (size_t)-2 +#define SDL_ICONV_EILSEQ (size_t)-3 +#define SDL_ICONV_EINVAL (size_t)-4 + +/* SDL_iconv_* are now always real symbols/types, not macros or inlined. */ +typedef struct _SDL_iconv_t *SDL_iconv_t; +extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode, + const char *fromcode); +extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd); +extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf, + size_t * inbytesleft, char **outbuf, + size_t * outbytesleft); +/** + * This function converts a string between encodings in one pass, returning a + * string that must be freed with SDL_free() or NULL on error. + */ +extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode, + const char *fromcode, + const char *inbuf, + size_t inbytesleft); +#define SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1) +#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2-INTERNAL", "UTF-8", S, SDL_strlen(S)+1) +#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4-INTERNAL", "UTF-8", S, SDL_strlen(S)+1) + +/* force builds using Clang's static analysis tools to use literal C runtime + here, since there are possibly tests that are ineffective otherwise. */ +#if defined(__clang_analyzer__) && !defined(SDL_DISABLE_ANALYZE_MACROS) +#define SDL_malloc malloc +#define SDL_calloc calloc +#define SDL_realloc realloc +#define SDL_free free +#define SDL_memset memset +#define SDL_memcpy memcpy +#define SDL_memmove memmove +#define SDL_memcmp memcmp +#define SDL_strlen strlen +#define SDL_strlcpy strlcpy +#define SDL_strlcat strlcat +#define SDL_strdup strdup +#define SDL_strchr strchr +#define SDL_strrchr strrchr +#define SDL_strstr strstr +#define SDL_strtokr strtok_r +#define SDL_strcmp strcmp +#define SDL_strncmp strncmp +#define SDL_strcasecmp strcasecmp +#define SDL_strncasecmp strncasecmp +#define SDL_sscanf sscanf +#define SDL_vsscanf vsscanf +#define SDL_snprintf snprintf +#define SDL_vsnprintf vsnprintf +#endif + +SDL_FORCE_INLINE void *SDL_memcpy4(SDL_OUT_BYTECAP(dwords*4) void *dst, SDL_IN_BYTECAP(dwords*4) const void *src, size_t dwords) +{ + return SDL_memcpy(dst, src, dwords * 4); +} + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_stdinc_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_surface.h b/thirdparty/include/SDL2/SDL_surface.h new file mode 100644 index 000000000..0f11d178e --- /dev/null +++ b/thirdparty/include/SDL2/SDL_surface.h @@ -0,0 +1,554 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_surface.h + * + * Header file for ::SDL_Surface definition and management functions. + */ + +#ifndef SDL_surface_h_ +#define SDL_surface_h_ + +#include "SDL_stdinc.h" +#include "SDL_pixels.h" +#include "SDL_rect.h" +#include "SDL_blendmode.h" +#include "SDL_rwops.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \name Surface flags + * + * These are the currently supported flags for the ::SDL_Surface. + * + * \internal + * Used internally (read-only). + */ +/* @{ */ +#define SDL_SWSURFACE 0 /**< Just here for compatibility */ +#define SDL_PREALLOC 0x00000001 /**< Surface uses preallocated memory */ +#define SDL_RLEACCEL 0x00000002 /**< Surface is RLE encoded */ +#define SDL_DONTFREE 0x00000004 /**< Surface is referenced internally */ +#define SDL_SIMD_ALIGNED 0x00000008 /**< Surface uses aligned memory */ +/* @} *//* Surface flags */ + +/** + * Evaluates to true if the surface needs to be locked before access. + */ +#define SDL_MUSTLOCK(S) (((S)->flags & SDL_RLEACCEL) != 0) + +/** + * \brief A collection of pixels used in software blitting. + * + * \note This structure should be treated as read-only, except for \c pixels, + * which, if not NULL, contains the raw pixel data for the surface. + */ +typedef struct SDL_Surface +{ + Uint32 flags; /**< Read-only */ + SDL_PixelFormat *format; /**< Read-only */ + int w, h; /**< Read-only */ + int pitch; /**< Read-only */ + void *pixels; /**< Read-write */ + + /** Application data associated with the surface */ + void *userdata; /**< Read-write */ + + /** information needed for surfaces requiring locks */ + int locked; /**< Read-only */ + void *lock_data; /**< Read-only */ + + /** clipping information */ + SDL_Rect clip_rect; /**< Read-only */ + + /** info for fast blit mapping to other surfaces */ + struct SDL_BlitMap *map; /**< Private */ + + /** Reference count -- used when freeing surface */ + int refcount; /**< Read-mostly */ +} SDL_Surface; + +/** + * \brief The type of function used for surface blitting functions. + */ +typedef int (SDLCALL *SDL_blit) (struct SDL_Surface * src, SDL_Rect * srcrect, + struct SDL_Surface * dst, SDL_Rect * dstrect); + +/** + * \brief The formula used for converting between YUV and RGB + */ +typedef enum +{ + SDL_YUV_CONVERSION_JPEG, /**< Full range JPEG */ + SDL_YUV_CONVERSION_BT601, /**< BT.601 (the default) */ + SDL_YUV_CONVERSION_BT709, /**< BT.709 */ + SDL_YUV_CONVERSION_AUTOMATIC /**< BT.601 for SD content, BT.709 for HD content */ +} SDL_YUV_CONVERSION_MODE; + +/** + * Allocate and free an RGB surface. + * + * If the depth is 4 or 8 bits, an empty palette is allocated for the surface. + * If the depth is greater than 8 bits, the pixel format is set using the + * flags '[RGB]mask'. + * + * If the function runs out of memory, it will return NULL. + * + * \param flags The \c flags are obsolete and should be set to 0. + * \param width The width in pixels of the surface to create. + * \param height The height in pixels of the surface to create. + * \param depth The depth in bits of the surface to create. + * \param Rmask The red mask of the surface to create. + * \param Gmask The green mask of the surface to create. + * \param Bmask The blue mask of the surface to create. + * \param Amask The alpha mask of the surface to create. + */ +extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface + (Uint32 flags, int width, int height, int depth, + Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); + +/* !!! FIXME for 2.1: why does this ask for depth? Format provides that. */ +extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceWithFormat + (Uint32 flags, int width, int height, int depth, Uint32 format); + +extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels, + int width, + int height, + int depth, + int pitch, + Uint32 Rmask, + Uint32 Gmask, + Uint32 Bmask, + Uint32 Amask); +extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceWithFormatFrom + (void *pixels, int width, int height, int depth, int pitch, Uint32 format); +extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface * surface); + +/** + * \brief Set the palette used by a surface. + * + * \return 0, or -1 if the surface format doesn't use a palette. + * + * \note A single palette can be shared with many surfaces. + */ +extern DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface * surface, + SDL_Palette * palette); + +/** + * \brief Sets up a surface for directly accessing the pixels. + * + * Between calls to SDL_LockSurface() / SDL_UnlockSurface(), you can write + * to and read from \c surface->pixels, using the pixel format stored in + * \c surface->format. Once you are done accessing the surface, you should + * use SDL_UnlockSurface() to release it. + * + * Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates + * to 0, then you can read and write to the surface at any time, and the + * pixel format of the surface will not change. + * + * No operating system or library calls should be made between lock/unlock + * pairs, as critical system locks may be held during this time. + * + * SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked. + * + * \sa SDL_UnlockSurface() + */ +extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface * surface); +/** \sa SDL_LockSurface() */ +extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface * surface); + +/** + * Load a surface from a seekable SDL data stream (memory or file). + * + * If \c freesrc is non-zero, the stream will be closed after being read. + * + * The new surface should be freed with SDL_FreeSurface(). + * + * \return the new surface, or NULL if there was an error. + */ +extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW(SDL_RWops * src, + int freesrc); + +/** + * Load a surface from a file. + * + * Convenience macro. + */ +#define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1) + +/** + * Save a surface to a seekable SDL data stream (memory or file). + * + * Surfaces with a 24-bit, 32-bit and paletted 8-bit format get saved in the + * BMP directly. Other RGB formats with 8-bit or higher get converted to a + * 24-bit surface or, if they have an alpha mask or a colorkey, to a 32-bit + * surface before they are saved. YUV and paletted 1-bit and 4-bit formats are + * not supported. + * + * If \c freedst is non-zero, the stream will be closed after being written. + * + * \return 0 if successful or -1 if there was an error. + */ +extern DECLSPEC int SDLCALL SDL_SaveBMP_RW + (SDL_Surface * surface, SDL_RWops * dst, int freedst); + +/** + * Save a surface to a file. + * + * Convenience macro. + */ +#define SDL_SaveBMP(surface, file) \ + SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1) + +/** + * \brief Sets the RLE acceleration hint for a surface. + * + * \return 0 on success, or -1 if the surface is not valid + * + * \note If RLE is enabled, colorkey and alpha blending blits are much faster, + * but the surface must be locked before directly accessing the pixels. + */ +extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface * surface, + int flag); + +/** + * \brief Sets the color key (transparent pixel) in a blittable surface. + * + * \param surface The surface to update + * \param flag Non-zero to enable colorkey and 0 to disable colorkey + * \param key The transparent pixel in the native surface format + * + * \return 0 on success, or -1 if the surface is not valid + * + * You can pass SDL_RLEACCEL to enable RLE accelerated blits. + */ +extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface * surface, + int flag, Uint32 key); + +/** + * \brief Returns whether the surface has a color key + * + * \return SDL_TRUE if the surface has a color key, or SDL_FALSE if the surface is NULL or has no color key + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasColorKey(SDL_Surface * surface); + +/** + * \brief Gets the color key (transparent pixel) in a blittable surface. + * + * \param surface The surface to update + * \param key A pointer filled in with the transparent pixel in the native + * surface format + * + * \return 0 on success, or -1 if the surface is not valid or colorkey is not + * enabled. + */ +extern DECLSPEC int SDLCALL SDL_GetColorKey(SDL_Surface * surface, + Uint32 * key); + +/** + * \brief Set an additional color value used in blit operations. + * + * \param surface The surface to update. + * \param r The red color value multiplied into blit operations. + * \param g The green color value multiplied into blit operations. + * \param b The blue color value multiplied into blit operations. + * + * \return 0 on success, or -1 if the surface is not valid. + * + * \sa SDL_GetSurfaceColorMod() + */ +extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface * surface, + Uint8 r, Uint8 g, Uint8 b); + + +/** + * \brief Get the additional color value used in blit operations. + * + * \param surface The surface to query. + * \param r A pointer filled in with the current red color value. + * \param g A pointer filled in with the current green color value. + * \param b A pointer filled in with the current blue color value. + * + * \return 0 on success, or -1 if the surface is not valid. + * + * \sa SDL_SetSurfaceColorMod() + */ +extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface * surface, + Uint8 * r, Uint8 * g, + Uint8 * b); + +/** + * \brief Set an additional alpha value used in blit operations. + * + * \param surface The surface to update. + * \param alpha The alpha value multiplied into blit operations. + * + * \return 0 on success, or -1 if the surface is not valid. + * + * \sa SDL_GetSurfaceAlphaMod() + */ +extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface * surface, + Uint8 alpha); + +/** + * \brief Get the additional alpha value used in blit operations. + * + * \param surface The surface to query. + * \param alpha A pointer filled in with the current alpha value. + * + * \return 0 on success, or -1 if the surface is not valid. + * + * \sa SDL_SetSurfaceAlphaMod() + */ +extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface * surface, + Uint8 * alpha); + +/** + * \brief Set the blend mode used for blit operations. + * + * \param surface The surface to update. + * \param blendMode ::SDL_BlendMode to use for blit blending. + * + * \return 0 on success, or -1 if the parameters are not valid. + * + * \sa SDL_GetSurfaceBlendMode() + */ +extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface, + SDL_BlendMode blendMode); + +/** + * \brief Get the blend mode used for blit operations. + * + * \param surface The surface to query. + * \param blendMode A pointer filled in with the current blend mode. + * + * \return 0 on success, or -1 if the surface is not valid. + * + * \sa SDL_SetSurfaceBlendMode() + */ +extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface, + SDL_BlendMode *blendMode); + +/** + * Sets the clipping rectangle for the destination surface in a blit. + * + * If the clip rectangle is NULL, clipping will be disabled. + * + * If the clip rectangle doesn't intersect the surface, the function will + * return SDL_FALSE and blits will be completely clipped. Otherwise the + * function returns SDL_TRUE and blits to the surface will be clipped to + * the intersection of the surface area and the clipping rectangle. + * + * Note that blits are automatically clipped to the edges of the source + * and destination surfaces. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface * surface, + const SDL_Rect * rect); + +/** + * Gets the clipping rectangle for the destination surface in a blit. + * + * \c rect must be a pointer to a valid rectangle which will be filled + * with the correct values. + */ +extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface * surface, + SDL_Rect * rect); + +/* + * Creates a new surface identical to the existing surface + */ +extern DECLSPEC SDL_Surface *SDLCALL SDL_DuplicateSurface(SDL_Surface * surface); + +/** + * Creates a new surface of the specified format, and then copies and maps + * the given surface to it so the blit of the converted surface will be as + * fast as possible. If this function fails, it returns NULL. + * + * The \c flags parameter is passed to SDL_CreateRGBSurface() and has those + * semantics. You can also pass ::SDL_RLEACCEL in the flags parameter and + * SDL will try to RLE accelerate colorkey and alpha blits in the resulting + * surface. + */ +extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface + (SDL_Surface * src, const SDL_PixelFormat * fmt, Uint32 flags); +extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat + (SDL_Surface * src, Uint32 pixel_format, Uint32 flags); + +/** + * \brief Copy a block of pixels of one format to another format + * + * \return 0 on success, or -1 if there was an error + */ +extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height, + Uint32 src_format, + const void * src, int src_pitch, + Uint32 dst_format, + void * dst, int dst_pitch); + +/** + * Performs a fast fill of the given rectangle with \c color. + * + * If \c rect is NULL, the whole surface will be filled with \c color. + * + * The color should be a pixel of the format used by the surface, and + * can be generated by the SDL_MapRGB() function. + * + * \return 0 on success, or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_FillRect + (SDL_Surface * dst, const SDL_Rect * rect, Uint32 color); +extern DECLSPEC int SDLCALL SDL_FillRects + (SDL_Surface * dst, const SDL_Rect * rects, int count, Uint32 color); + +/** + * Performs a fast blit from the source surface to the destination surface. + * + * This assumes that the source and destination rectangles are + * the same size. If either \c srcrect or \c dstrect are NULL, the entire + * surface (\c src or \c dst) is copied. The final blit rectangles are saved + * in \c srcrect and \c dstrect after all clipping is performed. + * + * \return If the blit is successful, it returns 0, otherwise it returns -1. + * + * The blit function should not be called on a locked surface. + * + * The blit semantics for surfaces with and without blending and colorkey + * are defined as follows: + * \verbatim + RGBA->RGB: + Source surface blend mode set to SDL_BLENDMODE_BLEND: + alpha-blend (using the source alpha-channel and per-surface alpha) + SDL_SRCCOLORKEY ignored. + Source surface blend mode set to SDL_BLENDMODE_NONE: + copy RGB. + if SDL_SRCCOLORKEY set, only copy the pixels matching the + RGB values of the source color key, ignoring alpha in the + comparison. + + RGB->RGBA: + Source surface blend mode set to SDL_BLENDMODE_BLEND: + alpha-blend (using the source per-surface alpha) + Source surface blend mode set to SDL_BLENDMODE_NONE: + copy RGB, set destination alpha to source per-surface alpha value. + both: + if SDL_SRCCOLORKEY set, only copy the pixels matching the + source color key. + + RGBA->RGBA: + Source surface blend mode set to SDL_BLENDMODE_BLEND: + alpha-blend (using the source alpha-channel and per-surface alpha) + SDL_SRCCOLORKEY ignored. + Source surface blend mode set to SDL_BLENDMODE_NONE: + copy all of RGBA to the destination. + if SDL_SRCCOLORKEY set, only copy the pixels matching the + RGB values of the source color key, ignoring alpha in the + comparison. + + RGB->RGB: + Source surface blend mode set to SDL_BLENDMODE_BLEND: + alpha-blend (using the source per-surface alpha) + Source surface blend mode set to SDL_BLENDMODE_NONE: + copy RGB. + both: + if SDL_SRCCOLORKEY set, only copy the pixels matching the + source color key. + \endverbatim + * + * You should call SDL_BlitSurface() unless you know exactly how SDL + * blitting works internally and how to use the other blit functions. + */ +#define SDL_BlitSurface SDL_UpperBlit + +/** + * This is the public blit function, SDL_BlitSurface(), and it performs + * rectangle validation and clipping before passing it to SDL_LowerBlit() + */ +extern DECLSPEC int SDLCALL SDL_UpperBlit + (SDL_Surface * src, const SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect); + +/** + * This is a semi-private blit function and it performs low-level surface + * blitting only. + */ +extern DECLSPEC int SDLCALL SDL_LowerBlit + (SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect); + +/** + * \brief Perform a fast, low quality, stretch blit between two surfaces of the + * same pixel format. + * + * \note This function uses a static buffer, and is not thread-safe. + */ +extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src, + const SDL_Rect * srcrect, + SDL_Surface * dst, + const SDL_Rect * dstrect); + +#define SDL_BlitScaled SDL_UpperBlitScaled + +/** + * This is the public scaled blit function, SDL_BlitScaled(), and it performs + * rectangle validation and clipping before passing it to SDL_LowerBlitScaled() + */ +extern DECLSPEC int SDLCALL SDL_UpperBlitScaled + (SDL_Surface * src, const SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect); + +/** + * This is a semi-private blit function and it performs low-level surface + * scaled blitting only. + */ +extern DECLSPEC int SDLCALL SDL_LowerBlitScaled + (SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect); + +/** + * \brief Set the YUV conversion mode + */ +extern DECLSPEC void SDLCALL SDL_SetYUVConversionMode(SDL_YUV_CONVERSION_MODE mode); + +/** + * \brief Get the YUV conversion mode + */ +extern DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionMode(void); + +/** + * \brief Get the YUV conversion mode, returning the correct mode for the resolution when the current conversion mode is SDL_YUV_CONVERSION_AUTOMATIC + */ +extern DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionModeForResolution(int width, int height); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_surface_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_system.h b/thirdparty/include/SDL2/SDL_system.h new file mode 100644 index 000000000..d7974eb03 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_system.h @@ -0,0 +1,316 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_system.h + * + * Include file for platform specific SDL API functions + */ + +#ifndef SDL_system_h_ +#define SDL_system_h_ + +#include "SDL_stdinc.h" +#include "SDL_keyboard.h" +#include "SDL_render.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + + +/* Platform specific functions for Windows */ +#ifdef __WIN32__ + +/** + \brief Set a function that is called for every windows message, before TranslateMessage() +*/ +typedef void (SDLCALL * SDL_WindowsMessageHook)(void *userdata, void *hWnd, unsigned int message, Uint64 wParam, Sint64 lParam); +extern DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata); + +/** + \brief Returns the D3D9 adapter index that matches the specified display index. + + This adapter index can be passed to IDirect3D9::CreateDevice and controls + on which monitor a full screen application will appear. +*/ +extern DECLSPEC int SDLCALL SDL_Direct3D9GetAdapterIndex( int displayIndex ); + +typedef struct IDirect3DDevice9 IDirect3DDevice9; +/** + \brief Returns the D3D device associated with a renderer, or NULL if it's not a D3D renderer. + + Once you are done using the device, you should release it to avoid a resource leak. + */ +extern DECLSPEC IDirect3DDevice9* SDLCALL SDL_RenderGetD3D9Device(SDL_Renderer * renderer); + +/** + \brief Returns the DXGI Adapter and Output indices for the specified display index. + + These can be passed to EnumAdapters and EnumOutputs respectively to get the objects + required to create a DX10 or DX11 device and swap chain. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_DXGIGetOutputInfo( int displayIndex, int *adapterIndex, int *outputIndex ); + +#endif /* __WIN32__ */ + + +/* Platform specific functions for Linux */ +#ifdef __LINUX__ + +/** + \brief Sets the UNIX nice value for a thread, using setpriority() if possible, and RealtimeKit if available. + + \return 0 on success, or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_LinuxSetThreadPriority(Sint64 threadID, int priority); + +#endif /* __LINUX__ */ + +/* Platform specific functions for iOS */ +#ifdef __IPHONEOS__ + +#define SDL_iOSSetAnimationCallback(window, interval, callback, callbackParam) SDL_iPhoneSetAnimationCallback(window, interval, callback, callbackParam) +extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (*callback)(void*), void *callbackParam); + +#define SDL_iOSSetEventPump(enabled) SDL_iPhoneSetEventPump(enabled) +extern DECLSPEC void SDLCALL SDL_iPhoneSetEventPump(SDL_bool enabled); + +#endif /* __IPHONEOS__ */ + + +/* Platform specific functions for Android */ +#ifdef __ANDROID__ + +/** + \brief Get the JNI environment for the current thread + + This returns JNIEnv*, but the prototype is void* so we don't need jni.h + */ +extern DECLSPEC void * SDLCALL SDL_AndroidGetJNIEnv(void); + +/** + \brief Get the SDL Activity object for the application + + This returns jobject, but the prototype is void* so we don't need jni.h + The jobject returned by SDL_AndroidGetActivity is a local reference. + It is the caller's responsibility to properly release it + (using env->Push/PopLocalFrame or manually with env->DeleteLocalRef) + */ +extern DECLSPEC void * SDLCALL SDL_AndroidGetActivity(void); + +/** + \brief Return API level of the current device + + API level 29: Android 10 + API level 28: Android 9 + API level 27: Android 8.1 + API level 26: Android 8.0 + API level 25: Android 7.1 + API level 24: Android 7.0 + API level 23: Android 6.0 + API level 22: Android 5.1 + API level 21: Android 5.0 + API level 20: Android 4.4W + API level 19: Android 4.4 + API level 18: Android 4.3 + API level 17: Android 4.2 + API level 16: Android 4.1 + API level 15: Android 4.0.3 + API level 14: Android 4.0 + API level 13: Android 3.2 + API level 12: Android 3.1 + API level 11: Android 3.0 + API level 10: Android 2.3.3 + */ +extern DECLSPEC int SDLCALL SDL_GetAndroidSDKVersion(void); + +/** + \brief Return true if the application is running on Android TV + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IsAndroidTV(void); + +/** + \brief Return true if the application is running on a Chromebook + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IsChromebook(void); + +/** + \brief Return true is the application is running on a Samsung DeX docking station + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IsDeXMode(void); + +/** + \brief Trigger the Android system back button behavior. + */ +extern DECLSPEC void SDLCALL SDL_AndroidBackButton(void); + +/** + See the official Android developer guide for more information: + http://developer.android.com/guide/topics/data/data-storage.html +*/ +#define SDL_ANDROID_EXTERNAL_STORAGE_READ 0x01 +#define SDL_ANDROID_EXTERNAL_STORAGE_WRITE 0x02 + +/** + \brief Get the path used for internal storage for this application. + + This path is unique to your application and cannot be written to + by other applications. + */ +extern DECLSPEC const char * SDLCALL SDL_AndroidGetInternalStoragePath(void); + +/** + \brief Get the current state of external storage, a bitmask of these values: + SDL_ANDROID_EXTERNAL_STORAGE_READ + SDL_ANDROID_EXTERNAL_STORAGE_WRITE + + If external storage is currently unavailable, this will return 0. +*/ +extern DECLSPEC int SDLCALL SDL_AndroidGetExternalStorageState(void); + +/** + \brief Get the path used for external storage for this application. + + This path is unique to your application, but is public and can be + written to by other applications. + */ +extern DECLSPEC const char * SDLCALL SDL_AndroidGetExternalStoragePath(void); + +#endif /* __ANDROID__ */ + +/* Platform specific functions for WinRT */ +#ifdef __WINRT__ + +/** + * \brief WinRT / Windows Phone path types + */ +typedef enum +{ + /** \brief The installed app's root directory. + Files here are likely to be read-only. */ + SDL_WINRT_PATH_INSTALLED_LOCATION, + + /** \brief The app's local data store. Files may be written here */ + SDL_WINRT_PATH_LOCAL_FOLDER, + + /** \brief The app's roaming data store. Unsupported on Windows Phone. + Files written here may be copied to other machines via a network + connection. + */ + SDL_WINRT_PATH_ROAMING_FOLDER, + + /** \brief The app's temporary data store. Unsupported on Windows Phone. + Files written here may be deleted at any time. */ + SDL_WINRT_PATH_TEMP_FOLDER +} SDL_WinRT_Path; + + +/** + * \brief WinRT Device Family + */ +typedef enum +{ + /** \brief Unknown family */ + SDL_WINRT_DEVICEFAMILY_UNKNOWN, + + /** \brief Desktop family*/ + SDL_WINRT_DEVICEFAMILY_DESKTOP, + + /** \brief Mobile family (for example smartphone) */ + SDL_WINRT_DEVICEFAMILY_MOBILE, + + /** \brief XBox family */ + SDL_WINRT_DEVICEFAMILY_XBOX, +} SDL_WinRT_DeviceFamily; + + +/** + * \brief Retrieves a WinRT defined path on the local file system + * + * \note Documentation on most app-specific path types on WinRT + * can be found on MSDN, at the URL: + * http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx + * + * \param pathType The type of path to retrieve. + * \return A UCS-2 string (16-bit, wide-char) containing the path, or NULL + * if the path is not available for any reason. Not all paths are + * available on all versions of Windows. This is especially true on + * Windows Phone. Check the documentation for the given + * SDL_WinRT_Path for more information on which path types are + * supported where. + */ +extern DECLSPEC const wchar_t * SDLCALL SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType); + +/** + * \brief Retrieves a WinRT defined path on the local file system + * + * \note Documentation on most app-specific path types on WinRT + * can be found on MSDN, at the URL: + * http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx + * + * \param pathType The type of path to retrieve. + * \return A UTF-8 string (8-bit, multi-byte) containing the path, or NULL + * if the path is not available for any reason. Not all paths are + * available on all versions of Windows. This is especially true on + * Windows Phone. Check the documentation for the given + * SDL_WinRT_Path for more information on which path types are + * supported where. + */ +extern DECLSPEC const char * SDLCALL SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType); + +/** + * \brief Detects the device family of WinRT plattform on runtime + * + * \return Device family + */ +extern DECLSPEC SDL_WinRT_DeviceFamily SDLCALL SDL_WinRTGetDeviceFamily(); + +#endif /* __WINRT__ */ + +/** + \brief Return true if the current device is a tablet. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IsTablet(void); + +/* Functions used by iOS application delegates to notify SDL about state changes */ +extern DECLSPEC void SDLCALL SDL_OnApplicationWillTerminate(void); +extern DECLSPEC void SDLCALL SDL_OnApplicationDidReceiveMemoryWarning(void); +extern DECLSPEC void SDLCALL SDL_OnApplicationWillResignActive(void); +extern DECLSPEC void SDLCALL SDL_OnApplicationDidEnterBackground(void); +extern DECLSPEC void SDLCALL SDL_OnApplicationWillEnterForeground(void); +extern DECLSPEC void SDLCALL SDL_OnApplicationDidBecomeActive(void); +#ifdef __IPHONEOS__ +extern DECLSPEC void SDLCALL SDL_OnApplicationDidChangeStatusBarOrientation(void); +#endif + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_system_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_syswm.h b/thirdparty/include/SDL2/SDL_syswm.h new file mode 100644 index 000000000..e877b2aad --- /dev/null +++ b/thirdparty/include/SDL2/SDL_syswm.h @@ -0,0 +1,331 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_syswm.h + * + * Include file for SDL custom system window manager hooks. + */ + +#ifndef SDL_syswm_h_ +#define SDL_syswm_h_ + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_video.h" +#include "SDL_version.h" + +/** + * \brief SDL_syswm.h + * + * Your application has access to a special type of event ::SDL_SYSWMEVENT, + * which contains window-manager specific information and arrives whenever + * an unhandled window event occurs. This event is ignored by default, but + * you can enable it with SDL_EventState(). + */ +struct SDL_SysWMinfo; + +#if !defined(SDL_PROTOTYPES_ONLY) + +#if defined(SDL_VIDEO_DRIVER_WINDOWS) +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#ifndef NOMINMAX /* don't define min() and max(). */ +#define NOMINMAX +#endif +#include +#endif + +#if defined(SDL_VIDEO_DRIVER_WINRT) +#include +#endif + +/* This is the structure for custom window manager events */ +#if defined(SDL_VIDEO_DRIVER_X11) +#if defined(__APPLE__) && defined(__MACH__) +/* conflicts with Quickdraw.h */ +#define Cursor X11Cursor +#endif + +#include +#include + +#if defined(__APPLE__) && defined(__MACH__) +/* matches the re-define above */ +#undef Cursor +#endif + +#endif /* defined(SDL_VIDEO_DRIVER_X11) */ + +#if defined(SDL_VIDEO_DRIVER_DIRECTFB) +#include +#endif + +#if defined(SDL_VIDEO_DRIVER_COCOA) +#ifdef __OBJC__ +@class NSWindow; +#else +typedef struct _NSWindow NSWindow; +#endif +#endif + +#if defined(SDL_VIDEO_DRIVER_UIKIT) +#ifdef __OBJC__ +#include +#else +typedef struct _UIWindow UIWindow; +typedef struct _UIViewController UIViewController; +#endif +typedef Uint32 GLuint; +#endif + +#if defined(SDL_VIDEO_DRIVER_ANDROID) +typedef struct ANativeWindow ANativeWindow; +typedef void *EGLSurface; +#endif + +#if defined(SDL_VIDEO_DRIVER_VIVANTE) +#include "SDL_egl.h" +#endif +#endif /* SDL_PROTOTYPES_ONLY */ + + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(SDL_PROTOTYPES_ONLY) +/** + * These are the various supported windowing subsystems + */ +typedef enum +{ + SDL_SYSWM_UNKNOWN, + SDL_SYSWM_WINDOWS, + SDL_SYSWM_X11, + SDL_SYSWM_DIRECTFB, + SDL_SYSWM_COCOA, + SDL_SYSWM_UIKIT, + SDL_SYSWM_WAYLAND, + SDL_SYSWM_MIR, /* no longer available, left for API/ABI compatibility. Remove in 2.1! */ + SDL_SYSWM_WINRT, + SDL_SYSWM_ANDROID, + SDL_SYSWM_VIVANTE, + SDL_SYSWM_OS2, + SDL_SYSWM_HAIKU +} SDL_SYSWM_TYPE; + +/** + * The custom event structure. + */ +struct SDL_SysWMmsg +{ + SDL_version version; + SDL_SYSWM_TYPE subsystem; + union + { +#if defined(SDL_VIDEO_DRIVER_WINDOWS) + struct { + HWND hwnd; /**< The window for the message */ + UINT msg; /**< The type of message */ + WPARAM wParam; /**< WORD message parameter */ + LPARAM lParam; /**< LONG message parameter */ + } win; +#endif +#if defined(SDL_VIDEO_DRIVER_X11) + struct { + XEvent event; + } x11; +#endif +#if defined(SDL_VIDEO_DRIVER_DIRECTFB) + struct { + DFBEvent event; + } dfb; +#endif +#if defined(SDL_VIDEO_DRIVER_COCOA) + struct + { + /* Latest version of Xcode clang complains about empty structs in C v. C++: + error: empty struct has size 0 in C, size 1 in C++ + */ + int dummy; + /* No Cocoa window events yet */ + } cocoa; +#endif +#if defined(SDL_VIDEO_DRIVER_UIKIT) + struct + { + int dummy; + /* No UIKit window events yet */ + } uikit; +#endif +#if defined(SDL_VIDEO_DRIVER_VIVANTE) + struct + { + int dummy; + /* No Vivante window events yet */ + } vivante; +#endif + /* Can't have an empty union */ + int dummy; + } msg; +}; + +/** + * The custom window manager information structure. + * + * When this structure is returned, it holds information about which + * low level system it is using, and will be one of SDL_SYSWM_TYPE. + */ +struct SDL_SysWMinfo +{ + SDL_version version; + SDL_SYSWM_TYPE subsystem; + union + { +#if defined(SDL_VIDEO_DRIVER_WINDOWS) + struct + { + HWND window; /**< The window handle */ + HDC hdc; /**< The window device context */ + HINSTANCE hinstance; /**< The instance handle */ + } win; +#endif +#if defined(SDL_VIDEO_DRIVER_WINRT) + struct + { + IInspectable * window; /**< The WinRT CoreWindow */ + } winrt; +#endif +#if defined(SDL_VIDEO_DRIVER_X11) + struct + { + Display *display; /**< The X11 display */ + Window window; /**< The X11 window */ + } x11; +#endif +#if defined(SDL_VIDEO_DRIVER_DIRECTFB) + struct + { + IDirectFB *dfb; /**< The directfb main interface */ + IDirectFBWindow *window; /**< The directfb window handle */ + IDirectFBSurface *surface; /**< The directfb client surface */ + } dfb; +#endif +#if defined(SDL_VIDEO_DRIVER_COCOA) + struct + { +#if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc) + NSWindow __unsafe_unretained *window; /**< The Cocoa window */ +#else + NSWindow *window; /**< The Cocoa window */ +#endif + } cocoa; +#endif +#if defined(SDL_VIDEO_DRIVER_UIKIT) + struct + { +#if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc) + UIWindow __unsafe_unretained *window; /**< The UIKit window */ +#else + UIWindow *window; /**< The UIKit window */ +#endif + GLuint framebuffer; /**< The GL view's Framebuffer Object. It must be bound when rendering to the screen using GL. */ + GLuint colorbuffer; /**< The GL view's color Renderbuffer Object. It must be bound when SDL_GL_SwapWindow is called. */ + GLuint resolveFramebuffer; /**< The Framebuffer Object which holds the resolve color Renderbuffer, when MSAA is used. */ + } uikit; +#endif +#if defined(SDL_VIDEO_DRIVER_WAYLAND) + struct + { + struct wl_display *display; /**< Wayland display */ + struct wl_surface *surface; /**< Wayland surface */ + struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */ + } wl; +#endif +#if defined(SDL_VIDEO_DRIVER_MIR) /* no longer available, left for API/ABI compatibility. Remove in 2.1! */ + struct + { + void *connection; /**< Mir display server connection */ + void *surface; /**< Mir surface */ + } mir; +#endif + +#if defined(SDL_VIDEO_DRIVER_ANDROID) + struct + { + ANativeWindow *window; + EGLSurface surface; + } android; +#endif + +#if defined(SDL_VIDEO_DRIVER_VIVANTE) + struct + { + EGLNativeDisplayType display; + EGLNativeWindowType window; + } vivante; +#endif + + /* Make sure this union is always 64 bytes (8 64-bit pointers). */ + /* Be careful not to overflow this if you add a new target! */ + Uint8 dummy[64]; + } info; +}; + +#endif /* SDL_PROTOTYPES_ONLY */ + +typedef struct SDL_SysWMinfo SDL_SysWMinfo; + +/* Function prototypes */ +/** + * \brief This function allows access to driver-dependent window information. + * + * \param window The window about which information is being requested + * \param info This structure must be initialized with the SDL version, and is + * then filled in with information about the given window. + * + * \return SDL_TRUE if the function is implemented and the version member of + * the \c info struct is valid, SDL_FALSE otherwise. + * + * You typically use this function like this: + * \code + * SDL_SysWMinfo info; + * SDL_VERSION(&info.version); + * if ( SDL_GetWindowWMInfo(window, &info) ) { ... } + * \endcode + */ +extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window, + SDL_SysWMinfo * info); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_syswm_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_test.h b/thirdparty/include/SDL2/SDL_test.h new file mode 100644 index 000000000..7095427ae --- /dev/null +++ b/thirdparty/include/SDL2/SDL_test.h @@ -0,0 +1,69 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_test.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +#ifndef SDL_test_h_ +#define SDL_test_h_ + +#include "SDL.h" +#include "SDL_test_assert.h" +#include "SDL_test_common.h" +#include "SDL_test_compare.h" +#include "SDL_test_crc32.h" +#include "SDL_test_font.h" +#include "SDL_test_fuzzer.h" +#include "SDL_test_harness.h" +#include "SDL_test_images.h" +#include "SDL_test_log.h" +#include "SDL_test_md5.h" +#include "SDL_test_memory.h" +#include "SDL_test_random.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Global definitions */ + +/* + * Note: Maximum size of SDLTest log message is less than SDL's limit + * to ensure we can fit additional information such as the timestamp. + */ +#define SDLTEST_MAX_LOGMESSAGE_LENGTH 3584 + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_test_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_test_assert.h b/thirdparty/include/SDL2/SDL_test_assert.h new file mode 100644 index 000000000..19b90950e --- /dev/null +++ b/thirdparty/include/SDL2/SDL_test_assert.h @@ -0,0 +1,105 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_test_assert.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + * + * Assert API for test code and test cases + * + */ + +#ifndef SDL_test_assert_h_ +#define SDL_test_assert_h_ + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Fails the assert. + */ +#define ASSERT_FAIL 0 + +/** + * \brief Passes the assert. + */ +#define ASSERT_PASS 1 + +/** + * \brief Assert that logs and break execution flow on failures. + * + * \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0). + * \param assertDescription Message to log with the assert describing it. + */ +void SDLTest_Assert(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(2); + +/** + * \brief Assert for test cases that logs but does not break execution flow on failures. Updates assertion counters. + * + * \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0). + * \param assertDescription Message to log with the assert describing it. + * + * \returns Returns the assertCondition so it can be used to externally to break execution flow if desired. + */ +int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(2); + +/** + * \brief Explicitly pass without checking an assertion condition. Updates assertion counter. + * + * \param assertDescription Message to log with the assert describing it. + */ +void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(1); + +/** + * \brief Resets the assert summary counters to zero. + */ +void SDLTest_ResetAssertSummary(void); + +/** + * \brief Logs summary of all assertions (total, pass, fail) since last reset as INFO or ERROR. + */ +void SDLTest_LogAssertSummary(void); + + +/** + * \brief Converts the current assert summary state to a test result. + * + * \returns TEST_RESULT_PASSED, TEST_RESULT_FAILED, or TEST_RESULT_NO_ASSERT + */ +int SDLTest_AssertSummaryToTestResult(void); + +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_test_assert_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_test_common.h b/thirdparty/include/SDL2/SDL_test_common.h new file mode 100644 index 000000000..3ad203055 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_test_common.h @@ -0,0 +1,218 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_test_common.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* Ported from original test\common.h file. */ + +#ifndef SDL_test_common_h_ +#define SDL_test_common_h_ + +#include "SDL.h" + +#if defined(__PSP__) +#define DEFAULT_WINDOW_WIDTH 480 +#define DEFAULT_WINDOW_HEIGHT 272 +#else +#define DEFAULT_WINDOW_WIDTH 640 +#define DEFAULT_WINDOW_HEIGHT 480 +#endif + +#define VERBOSE_VIDEO 0x00000001 +#define VERBOSE_MODES 0x00000002 +#define VERBOSE_RENDER 0x00000004 +#define VERBOSE_EVENT 0x00000008 +#define VERBOSE_AUDIO 0x00000010 + +typedef struct +{ + /* SDL init flags */ + char **argv; + Uint32 flags; + Uint32 verbose; + + /* Video info */ + const char *videodriver; + int display; + const char *window_title; + const char *window_icon; + Uint32 window_flags; + int window_x; + int window_y; + int window_w; + int window_h; + int window_minW; + int window_minH; + int window_maxW; + int window_maxH; + int logical_w; + int logical_h; + float scale; + int depth; + int refresh_rate; + int num_windows; + SDL_Window **windows; + + /* Renderer info */ + const char *renderdriver; + Uint32 render_flags; + SDL_bool skip_renderer; + SDL_Renderer **renderers; + SDL_Texture **targets; + + /* Audio info */ + const char *audiodriver; + SDL_AudioSpec audiospec; + + /* GL settings */ + int gl_red_size; + int gl_green_size; + int gl_blue_size; + int gl_alpha_size; + int gl_buffer_size; + int gl_depth_size; + int gl_stencil_size; + int gl_double_buffer; + int gl_accum_red_size; + int gl_accum_green_size; + int gl_accum_blue_size; + int gl_accum_alpha_size; + int gl_stereo; + int gl_multisamplebuffers; + int gl_multisamplesamples; + int gl_retained_backing; + int gl_accelerated; + int gl_major_version; + int gl_minor_version; + int gl_debug; + int gl_profile_mask; +} SDLTest_CommonState; + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Function prototypes */ + +/** + * \brief Parse command line parameters and create common state. + * + * \param argv Array of command line parameters + * \param flags Flags indicating which subsystem to initialize (i.e. SDL_INIT_VIDEO | SDL_INIT_AUDIO) + * + * \returns Returns a newly allocated common state object. + */ +SDLTest_CommonState *SDLTest_CommonCreateState(char **argv, Uint32 flags); + +/** + * \brief Process one common argument. + * + * \param state The common state describing the test window to create. + * \param index The index of the argument to process in argv[]. + * + * \returns The number of arguments processed (i.e. 1 for --fullscreen, 2 for --video [videodriver], or -1 on error. + */ +int SDLTest_CommonArg(SDLTest_CommonState * state, int index); + + +/** + * \brief Logs command line usage info. + * + * This logs the appropriate command line options for the subsystems in use + * plus other common options, and then any application-specific options. + * This uses the SDL_Log() function and splits up output to be friendly to + * 80-character-wide terminals. + * + * \param state The common state describing the test window for the app. + * \param argv0 argv[0], as passed to main/SDL_main. + * \param options an array of strings for application specific options. The last element of the array should be NULL. + */ +void SDLTest_CommonLogUsage(SDLTest_CommonState * state, const char *argv0, const char **options); + +/** + * \brief Returns common usage information + * + * You should (probably) be using SDLTest_CommonLogUsage() instead, but this + * function remains for binary compatibility. Strings returned from this + * function are valid until SDLTest_CommonQuit() is called, in which case + * those strings' memory is freed and can no longer be used. + * + * \param state The common state describing the test window to create. + * \returns String with usage information + */ +const char *SDLTest_CommonUsage(SDLTest_CommonState * state); + +/** + * \brief Open test window. + * + * \param state The common state describing the test window to create. + * + * \returns True if initialization succeeded, false otherwise + */ +SDL_bool SDLTest_CommonInit(SDLTest_CommonState * state); + +/** + * \brief Easy argument handling when test app doesn't need any custom args. + * + * \param state The common state describing the test window to create. + * \param argc argc, as supplied to SDL_main + * \param argv argv, as supplied to SDL_main + * + * \returns False if app should quit, true otherwise. + */ +SDL_bool SDLTest_CommonDefaultArgs(SDLTest_CommonState * state, const int argc, char **argv); + +/** + * \brief Common event handler for test windows. + * + * \param state The common state used to create test window. + * \param event The event to handle. + * \param done Flag indicating we are done. + * + */ +void SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done); + +/** + * \brief Close test window. + * + * \param state The common state used to create test window. + * + */ +void SDLTest_CommonQuit(SDLTest_CommonState * state); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_test_common_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_test_compare.h b/thirdparty/include/SDL2/SDL_test_compare.h new file mode 100644 index 000000000..38b22bb3b --- /dev/null +++ b/thirdparty/include/SDL2/SDL_test_compare.h @@ -0,0 +1,69 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_test_compare.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + + Defines comparison functions (i.e. for surfaces). + +*/ + +#ifndef SDL_test_compare_h_ +#define SDL_test_compare_h_ + +#include "SDL.h" + +#include "SDL_test_images.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Compares a surface and with reference image data for equality + * + * \param surface Surface used in comparison + * \param referenceSurface Test Surface used in comparison + * \param allowable_error Allowable difference (=sum of squared difference for each RGB component) in blending accuracy. + * + * \returns 0 if comparison succeeded, >0 (=number of pixels for which the comparison failed) if comparison failed, -1 if any of the surfaces were NULL, -2 if the surface sizes differ. + */ +int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_test_compare_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_test_crc32.h b/thirdparty/include/SDL2/SDL_test_crc32.h new file mode 100644 index 000000000..611066abf --- /dev/null +++ b/thirdparty/include/SDL2/SDL_test_crc32.h @@ -0,0 +1,124 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_test_crc32.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + + Implements CRC32 calculations (default output is Perl String::CRC32 compatible). + +*/ + +#ifndef SDL_test_crc32_h_ +#define SDL_test_crc32_h_ + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + + +/* ------------ Definitions --------- */ + +/* Definition shared by all CRC routines */ + +#ifndef CrcUint32 + #define CrcUint32 unsigned int +#endif +#ifndef CrcUint8 + #define CrcUint8 unsigned char +#endif + +#ifdef ORIGINAL_METHOD + #define CRC32_POLY 0x04c11db7 /* AUTODIN II, Ethernet, & FDDI */ +#else + #define CRC32_POLY 0xEDB88320 /* Perl String::CRC32 compatible */ +#endif + +/** + * Data structure for CRC32 (checksum) computation + */ + typedef struct { + CrcUint32 crc32_table[256]; /* CRC table */ + } SDLTest_Crc32Context; + +/* ---------- Function Prototypes ------------- */ + +/** + * \brief Initialize the CRC context + * + * Note: The function initializes the crc table required for all crc calculations. + * + * \param crcContext pointer to context variable + * + * \returns 0 for OK, -1 on error + * + */ + int SDLTest_Crc32Init(SDLTest_Crc32Context * crcContext); + + +/** + * \brief calculate a crc32 from a data block + * + * \param crcContext pointer to context variable + * \param inBuf input buffer to checksum + * \param inLen length of input buffer + * \param crc32 pointer to Uint32 to store the final CRC into + * + * \returns 0 for OK, -1 on error + * + */ +int SDLTest_Crc32Calc(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32); + +/* Same routine broken down into three steps */ +int SDLTest_Crc32CalcStart(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32); +int SDLTest_Crc32CalcEnd(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32); +int SDLTest_Crc32CalcBuffer(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32); + + +/** + * \brief clean up CRC context + * + * \param crcContext pointer to context variable + * + * \returns 0 for OK, -1 on error + * +*/ + +int SDLTest_Crc32Done(SDLTest_Crc32Context * crcContext); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_test_crc32_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_test_font.h b/thirdparty/include/SDL2/SDL_test_font.h new file mode 100644 index 000000000..dc4ce6dd6 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_test_font.h @@ -0,0 +1,81 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_test_font.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +#ifndef SDL_test_font_h_ +#define SDL_test_font_h_ + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Function prototypes */ + +#define FONT_CHARACTER_SIZE 8 + +/** + * \brief Draw a string in the currently set font. + * + * \param renderer The renderer to draw on. + * \param x The X coordinate of the upper left corner of the character. + * \param y The Y coordinate of the upper left corner of the character. + * \param c The character to draw. + * + * \returns Returns 0 on success, -1 on failure. + */ +int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, char c); + +/** + * \brief Draw a string in the currently set font. + * + * \param renderer The renderer to draw on. + * \param x The X coordinate of the upper left corner of the string. + * \param y The Y coordinate of the upper left corner of the string. + * \param s The string to draw. + * + * \returns Returns 0 on success, -1 on failure. + */ +int SDLTest_DrawString(SDL_Renderer *renderer, int x, int y, const char *s); + + +/** + * \brief Cleanup textures used by font drawing functions. + */ +void SDLTest_CleanupTextDrawing(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_test_font_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_test_fuzzer.h b/thirdparty/include/SDL2/SDL_test_fuzzer.h new file mode 100644 index 000000000..cb5a17a10 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_test_fuzzer.h @@ -0,0 +1,384 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_test_fuzzer.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + + Data generators for fuzzing test data in a reproducible way. + +*/ + +#ifndef SDL_test_fuzzer_h_ +#define SDL_test_fuzzer_h_ + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + + +/* + Based on GSOC code by Markus Kauppila +*/ + + +/** + * \file + * Note: The fuzzer implementation uses a static instance of random context + * internally which makes it thread-UNsafe. + */ + +/** + * Initializes the fuzzer for a test + * + * \param execKey Execution "Key" that initializes the random number generator uniquely for the test. + * + */ +void SDLTest_FuzzerInit(Uint64 execKey); + + +/** + * Returns a random Uint8 + * + * \returns Generated integer + */ +Uint8 SDLTest_RandomUint8(void); + +/** + * Returns a random Sint8 + * + * \returns Generated signed integer + */ +Sint8 SDLTest_RandomSint8(void); + + +/** + * Returns a random Uint16 + * + * \returns Generated integer + */ +Uint16 SDLTest_RandomUint16(void); + +/** + * Returns a random Sint16 + * + * \returns Generated signed integer + */ +Sint16 SDLTest_RandomSint16(void); + + +/** + * Returns a random integer + * + * \returns Generated integer + */ +Sint32 SDLTest_RandomSint32(void); + + +/** + * Returns a random positive integer + * + * \returns Generated integer + */ +Uint32 SDLTest_RandomUint32(void); + +/** + * Returns random Uint64. + * + * \returns Generated integer + */ +Uint64 SDLTest_RandomUint64(void); + + +/** + * Returns random Sint64. + * + * \returns Generated signed integer + */ +Sint64 SDLTest_RandomSint64(void); + +/** + * \returns random float in range [0.0 - 1.0[ + */ +float SDLTest_RandomUnitFloat(void); + +/** + * \returns random double in range [0.0 - 1.0[ + */ +double SDLTest_RandomUnitDouble(void); + +/** + * \returns random float. + * + */ +float SDLTest_RandomFloat(void); + +/** + * \returns random double. + * + */ +double SDLTest_RandomDouble(void); + +/** + * Returns a random boundary value for Uint8 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomUint8BoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 + * RandomUint8BoundaryValue(1, 20, SDL_FALSE) returns 0 or 21 + * RandomUint8BoundaryValue(0, 99, SDL_FALSE) returns 100 + * RandomUint8BoundaryValue(0, 255, SDL_FALSE) returns 0 (error set) + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or 0 with error set + */ +Uint8 SDLTest_RandomUint8BoundaryValue(Uint8 boundary1, Uint8 boundary2, SDL_bool validDomain); + +/** + * Returns a random boundary value for Uint16 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomUint16BoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 + * RandomUint16BoundaryValue(1, 20, SDL_FALSE) returns 0 or 21 + * RandomUint16BoundaryValue(0, 99, SDL_FALSE) returns 100 + * RandomUint16BoundaryValue(0, 0xFFFF, SDL_FALSE) returns 0 (error set) + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or 0 with error set + */ +Uint16 SDLTest_RandomUint16BoundaryValue(Uint16 boundary1, Uint16 boundary2, SDL_bool validDomain); + +/** + * Returns a random boundary value for Uint32 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomUint32BoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 + * RandomUint32BoundaryValue(1, 20, SDL_FALSE) returns 0 or 21 + * RandomUint32BoundaryValue(0, 99, SDL_FALSE) returns 100 + * RandomUint32BoundaryValue(0, 0xFFFFFFFF, SDL_FALSE) returns 0 (with error set) + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or 0 with error set + */ +Uint32 SDLTest_RandomUint32BoundaryValue(Uint32 boundary1, Uint32 boundary2, SDL_bool validDomain); + +/** + * Returns a random boundary value for Uint64 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomUint64BoundaryValue(10, 20, SDL_TRUE) returns 10, 11, 19 or 20 + * RandomUint64BoundaryValue(1, 20, SDL_FALSE) returns 0 or 21 + * RandomUint64BoundaryValue(0, 99, SDL_FALSE) returns 100 + * RandomUint64BoundaryValue(0, 0xFFFFFFFFFFFFFFFF, SDL_FALSE) returns 0 (with error set) + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or 0 with error set + */ +Uint64 SDLTest_RandomUint64BoundaryValue(Uint64 boundary1, Uint64 boundary2, SDL_bool validDomain); + +/** + * Returns a random boundary value for Sint8 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomSint8BoundaryValue(-10, 20, SDL_TRUE) returns -11, -10, 19 or 20 + * RandomSint8BoundaryValue(-100, -10, SDL_FALSE) returns -101 or -9 + * RandomSint8BoundaryValue(SINT8_MIN, 99, SDL_FALSE) returns 100 + * RandomSint8BoundaryValue(SINT8_MIN, SINT8_MAX, SDL_FALSE) returns SINT8_MIN (== error value) with error set + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or SINT8_MIN with error set + */ +Sint8 SDLTest_RandomSint8BoundaryValue(Sint8 boundary1, Sint8 boundary2, SDL_bool validDomain); + + +/** + * Returns a random boundary value for Sint16 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomSint16BoundaryValue(-10, 20, SDL_TRUE) returns -11, -10, 19 or 20 + * RandomSint16BoundaryValue(-100, -10, SDL_FALSE) returns -101 or -9 + * RandomSint16BoundaryValue(SINT16_MIN, 99, SDL_FALSE) returns 100 + * RandomSint16BoundaryValue(SINT16_MIN, SINT16_MAX, SDL_FALSE) returns SINT16_MIN (== error value) with error set + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or SINT16_MIN with error set + */ +Sint16 SDLTest_RandomSint16BoundaryValue(Sint16 boundary1, Sint16 boundary2, SDL_bool validDomain); + +/** + * Returns a random boundary value for Sint32 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomSint32BoundaryValue(-10, 20, SDL_TRUE) returns -11, -10, 19 or 20 + * RandomSint32BoundaryValue(-100, -10, SDL_FALSE) returns -101 or -9 + * RandomSint32BoundaryValue(SINT32_MIN, 99, SDL_FALSE) returns 100 + * RandomSint32BoundaryValue(SINT32_MIN, SINT32_MAX, SDL_FALSE) returns SINT32_MIN (== error value) + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or SINT32_MIN with error set + */ +Sint32 SDLTest_RandomSint32BoundaryValue(Sint32 boundary1, Sint32 boundary2, SDL_bool validDomain); + +/** + * Returns a random boundary value for Sint64 within the given boundaries. + * Boundaries are inclusive, see the usage examples below. If validDomain + * is true, the function will only return valid boundaries, otherwise non-valid + * boundaries are also possible. + * If boundary1 > boundary2, the values are swapped + * + * Usage examples: + * RandomSint64BoundaryValue(-10, 20, SDL_TRUE) returns -11, -10, 19 or 20 + * RandomSint64BoundaryValue(-100, -10, SDL_FALSE) returns -101 or -9 + * RandomSint64BoundaryValue(SINT64_MIN, 99, SDL_FALSE) returns 100 + * RandomSint64BoundaryValue(SINT64_MIN, SINT64_MAX, SDL_FALSE) returns SINT64_MIN (== error value) and error set + * + * \param boundary1 Lower boundary limit + * \param boundary2 Upper boundary limit + * \param validDomain Should the generated boundary be valid (=within the bounds) or not? + * + * \returns Random boundary value for the given range and domain or SINT64_MIN with error set + */ +Sint64 SDLTest_RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL_bool validDomain); + + +/** + * Returns integer in range [min, max] (inclusive). + * Min and max values can be negative values. + * If Max in smaller than min, then the values are swapped. + * Min and max are the same value, that value will be returned. + * + * \param min Minimum inclusive value of returned random number + * \param max Maximum inclusive value of returned random number + * + * \returns Generated random integer in range + */ +Sint32 SDLTest_RandomIntegerInRange(Sint32 min, Sint32 max); + + +/** + * Generates random null-terminated string. The minimum length for + * the string is 1 character, maximum length for the string is 255 + * characters and it can contain ASCII characters from 32 to 126. + * + * Note: Returned string needs to be deallocated. + * + * \returns Newly allocated random string; or NULL if length was invalid or string could not be allocated. + */ +char * SDLTest_RandomAsciiString(void); + + +/** + * Generates random null-terminated string. The maximum length for + * the string is defined by the maxLength parameter. + * String can contain ASCII characters from 32 to 126. + * + * Note: Returned string needs to be deallocated. + * + * \param maxLength The maximum length of the generated string. + * + * \returns Newly allocated random string; or NULL if maxLength was invalid or string could not be allocated. + */ +char * SDLTest_RandomAsciiStringWithMaximumLength(int maxLength); + + +/** + * Generates random null-terminated string. The length for + * the string is defined by the size parameter. + * String can contain ASCII characters from 32 to 126. + * + * Note: Returned string needs to be deallocated. + * + * \param size The length of the generated string + * + * \returns Newly allocated random string; or NULL if size was invalid or string could not be allocated. + */ +char * SDLTest_RandomAsciiStringOfSize(int size); + +/** + * Returns the invocation count for the fuzzer since last ...FuzzerInit. + */ +int SDLTest_GetFuzzerInvocationCount(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_test_fuzzer_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_test_harness.h b/thirdparty/include/SDL2/SDL_test_harness.h new file mode 100644 index 000000000..97d981281 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_test_harness.h @@ -0,0 +1,134 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_test_harness.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + Defines types for test case definitions and the test execution harness API. + + Based on original GSOC code by Markus Kauppila +*/ + +#ifndef SDL_test_h_arness_h +#define SDL_test_h_arness_h + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + + +/* ! Definitions for test case structures */ +#define TEST_ENABLED 1 +#define TEST_DISABLED 0 + +/* ! Definition of all the possible test return values of the test case method */ +#define TEST_ABORTED -1 +#define TEST_STARTED 0 +#define TEST_COMPLETED 1 +#define TEST_SKIPPED 2 + +/* ! Definition of all the possible test results for the harness */ +#define TEST_RESULT_PASSED 0 +#define TEST_RESULT_FAILED 1 +#define TEST_RESULT_NO_ASSERT 2 +#define TEST_RESULT_SKIPPED 3 +#define TEST_RESULT_SETUP_FAILURE 4 + +/* !< Function pointer to a test case setup function (run before every test) */ +typedef void (*SDLTest_TestCaseSetUpFp)(void *arg); + +/* !< Function pointer to a test case function */ +typedef int (*SDLTest_TestCaseFp)(void *arg); + +/* !< Function pointer to a test case teardown function (run after every test) */ +typedef void (*SDLTest_TestCaseTearDownFp)(void *arg); + +/** + * Holds information about a single test case. + */ +typedef struct SDLTest_TestCaseReference { + /* !< Func2Stress */ + SDLTest_TestCaseFp testCase; + /* !< Short name (or function name) "Func2Stress" */ + char *name; + /* !< Long name or full description "This test pushes func2() to the limit." */ + char *description; + /* !< Set to TEST_ENABLED or TEST_DISABLED (test won't be run) */ + int enabled; +} SDLTest_TestCaseReference; + +/** + * Holds information about a test suite (multiple test cases). + */ +typedef struct SDLTest_TestSuiteReference { + /* !< "PlatformSuite" */ + char *name; + /* !< The function that is run before each test. NULL skips. */ + SDLTest_TestCaseSetUpFp testSetUp; + /* !< The test cases that are run as part of the suite. Last item should be NULL. */ + const SDLTest_TestCaseReference **testCases; + /* !< The function that is run after each test. NULL skips. */ + SDLTest_TestCaseTearDownFp testTearDown; +} SDLTest_TestSuiteReference; + + +/** + * \brief Generates a random run seed string for the harness. The generated seed will contain alphanumeric characters (0-9A-Z). + * + * Note: The returned string needs to be deallocated by the caller. + * + * \param length The length of the seed string to generate + * + * \returns The generated seed string + */ +char *SDLTest_GenerateRunSeed(const int length); + +/** + * \brief Execute a test suite using the given run seed and execution key. + * + * \param testSuites Suites containing the test case. + * \param userRunSeed Custom run seed provided by user, or NULL to autogenerate one. + * \param userExecKey Custom execution key provided by user, or 0 to autogenerate one. + * \param filter Filter specification. NULL disables. Case sensitive. + * \param testIterations Number of iterations to run each test case. + * + * \returns Test run result; 0 when all tests passed, 1 if any tests failed. + */ +int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *userRunSeed, Uint64 userExecKey, const char *filter, int testIterations); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_test_h_arness_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_test_images.h b/thirdparty/include/SDL2/SDL_test_images.h new file mode 100644 index 000000000..1cc3ee266 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_test_images.h @@ -0,0 +1,78 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_test_images.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + + Defines some images for tests. + +*/ + +#ifndef SDL_test_images_h_ +#define SDL_test_images_h_ + +#include "SDL.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + *Type for test images. + */ +typedef struct SDLTest_SurfaceImage_s { + int width; + int height; + unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */ + const char *pixel_data; +} SDLTest_SurfaceImage_t; + +/* Test images */ +SDL_Surface *SDLTest_ImageBlit(void); +SDL_Surface *SDLTest_ImageBlitColor(void); +SDL_Surface *SDLTest_ImageBlitAlpha(void); +SDL_Surface *SDLTest_ImageBlitBlendAdd(void); +SDL_Surface *SDLTest_ImageBlitBlend(void); +SDL_Surface *SDLTest_ImageBlitBlendMod(void); +SDL_Surface *SDLTest_ImageBlitBlendNone(void); +SDL_Surface *SDLTest_ImageBlitBlendAll(void); +SDL_Surface *SDLTest_ImageFace(void); +SDL_Surface *SDLTest_ImagePrimitives(void); +SDL_Surface *SDLTest_ImagePrimitivesBlend(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_test_images_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_test_log.h b/thirdparty/include/SDL2/SDL_test_log.h new file mode 100644 index 000000000..6066f9041 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_test_log.h @@ -0,0 +1,67 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_test_log.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + * + * Wrapper to log in the TEST category + * + */ + +#ifndef SDL_test_log_h_ +#define SDL_test_log_h_ + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Prints given message with a timestamp in the TEST category and INFO priority. + * + * \param fmt Message to be logged + */ +void SDLTest_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); + +/** + * \brief Prints given message with a timestamp in the TEST category and the ERROR priority. + * + * \param fmt Message to be logged + */ +void SDLTest_LogError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_test_log_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_test_md5.h b/thirdparty/include/SDL2/SDL_test_md5.h new file mode 100644 index 000000000..b1c51d929 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_test_md5.h @@ -0,0 +1,129 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_test_md5.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + *********************************************************************** + ** Header file for implementation of MD5 ** + ** RSA Data Security, Inc. MD5 Message-Digest Algorithm ** + ** Created: 2/17/90 RLR ** + ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version ** + ** Revised (for MD5): RLR 4/27/91 ** + ** -- G modified to have y&~z instead of y&z ** + ** -- FF, GG, HH modified to add in last register done ** + ** -- Access pattern: round 2 works mod 5, round 3 works mod 3 ** + ** -- distinct additive constant for each step ** + ** -- round 4 added, working mod 7 ** + *********************************************************************** +*/ + +/* + *********************************************************************** + ** Message-digest routines: ** + ** To form the message digest for a message M ** + ** (1) Initialize a context buffer mdContext using MD5Init ** + ** (2) Call MD5Update on mdContext and M ** + ** (3) Call MD5Final on mdContext ** + ** The message digest is now in mdContext->digest[0...15] ** + *********************************************************************** +*/ + +#ifndef SDL_test_md5_h_ +#define SDL_test_md5_h_ + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* ------------ Definitions --------- */ + +/* typedef a 32-bit type */ + typedef unsigned long int MD5UINT4; + +/* Data structure for MD5 (Message-Digest) computation */ + typedef struct { + MD5UINT4 i[2]; /* number of _bits_ handled mod 2^64 */ + MD5UINT4 buf[4]; /* scratch buffer */ + unsigned char in[64]; /* input buffer */ + unsigned char digest[16]; /* actual digest after Md5Final call */ + } SDLTest_Md5Context; + +/* ---------- Function Prototypes ------------- */ + +/** + * \brief initialize the context + * + * \param mdContext pointer to context variable + * + * Note: The function initializes the message-digest context + * mdContext. Call before each new use of the context - + * all fields are set to zero. + */ + void SDLTest_Md5Init(SDLTest_Md5Context * mdContext); + + +/** + * \brief update digest from variable length data + * + * \param mdContext pointer to context variable + * \param inBuf pointer to data array/string + * \param inLen length of data array/string + * + * Note: The function updates the message-digest context to account + * for the presence of each of the characters inBuf[0..inLen-1] + * in the message whose digest is being computed. +*/ + + void SDLTest_Md5Update(SDLTest_Md5Context * mdContext, unsigned char *inBuf, + unsigned int inLen); + + +/** + * \brief complete digest computation + * + * \param mdContext pointer to context variable + * + * Note: The function terminates the message-digest computation and + * ends with the desired message digest in mdContext.digest[0..15]. + * Always call before using the digest[] variable. +*/ + + void SDLTest_Md5Final(SDLTest_Md5Context * mdContext); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_test_md5_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_test_memory.h b/thirdparty/include/SDL2/SDL_test_memory.h new file mode 100644 index 000000000..df69f93e8 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_test_memory.h @@ -0,0 +1,63 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_test_memory.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +#ifndef SDL_test_memory_h_ +#define SDL_test_memory_h_ + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * \brief Start tracking SDL memory allocations + * + * \note This should be called before any other SDL functions for complete tracking coverage + */ +int SDLTest_TrackAllocations(void); + +/** + * \brief Print a log of any outstanding allocations + * + * \note This can be called after SDL_Quit() + */ +void SDLTest_LogAllocations(void); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_test_memory_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_test_random.h b/thirdparty/include/SDL2/SDL_test_random.h new file mode 100644 index 000000000..9404e9dcd --- /dev/null +++ b/thirdparty/include/SDL2/SDL_test_random.h @@ -0,0 +1,115 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_test_random.h + * + * Include file for SDL test framework. + * + * This code is a part of the SDL2_test library, not the main SDL library. + */ + +/* + + A "32-bit Multiply with carry random number generator. Very fast. + Includes a list of recommended multipliers. + + multiply-with-carry generator: x(n) = a*x(n-1) + carry mod 2^32. + period: (a*2^31)-1 + +*/ + +#ifndef SDL_test_random_h_ +#define SDL_test_random_h_ + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* --- Definitions */ + +/* + * Macros that return a random number in a specific format. + */ +#define SDLTest_RandomInt(c) ((int)SDLTest_Random(c)) + +/* + * Context structure for the random number generator state. + */ + typedef struct { + unsigned int a; + unsigned int x; + unsigned int c; + unsigned int ah; + unsigned int al; + } SDLTest_RandomContext; + + +/* --- Function prototypes */ + +/** + * \brief Initialize random number generator with two integers. + * + * Note: The random sequence of numbers returned by ...Random() is the + * same for the same two integers and has a period of 2^31. + * + * \param rndContext pointer to context structure + * \param xi integer that defines the random sequence + * \param ci integer that defines the random sequence + * + */ + void SDLTest_RandomInit(SDLTest_RandomContext * rndContext, unsigned int xi, + unsigned int ci); + +/** + * \brief Initialize random number generator based on current system time. + * + * \param rndContext pointer to context structure + * + */ + void SDLTest_RandomInitTime(SDLTest_RandomContext *rndContext); + + +/** + * \brief Initialize random number generator based on current system time. + * + * Note: ...RandomInit() or ...RandomInitTime() must have been called + * before using this function. + * + * \param rndContext pointer to context structure + * + * \returns A random number (32bit unsigned integer) + * + */ + unsigned int SDLTest_Random(SDLTest_RandomContext *rndContext); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_test_random_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_thread.h b/thirdparty/include/SDL2/SDL_thread.h new file mode 100644 index 000000000..cb5301174 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_thread.h @@ -0,0 +1,361 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_thread_h_ +#define SDL_thread_h_ + +/** + * \file SDL_thread.h + * + * Header for the SDL thread management routines. + */ + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +/* Thread synchronization primitives */ +#include "SDL_atomic.h" +#include "SDL_mutex.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* The SDL thread structure, defined in SDL_thread.c */ +struct SDL_Thread; +typedef struct SDL_Thread SDL_Thread; + +/* The SDL thread ID */ +typedef unsigned long SDL_threadID; + +/* Thread local storage ID, 0 is the invalid ID */ +typedef unsigned int SDL_TLSID; + +/** + * The SDL thread priority. + * + * \note On many systems you require special privileges to set high or time critical priority. + */ +typedef enum { + SDL_THREAD_PRIORITY_LOW, + SDL_THREAD_PRIORITY_NORMAL, + SDL_THREAD_PRIORITY_HIGH, + SDL_THREAD_PRIORITY_TIME_CRITICAL +} SDL_ThreadPriority; + +/** + * The function passed to SDL_CreateThread(). + * It is passed a void* user context parameter and returns an int. + */ +typedef int (SDLCALL * SDL_ThreadFunction) (void *data); + +#if defined(__WIN32__) +/** + * \file SDL_thread.h + * + * We compile SDL into a DLL. This means, that it's the DLL which + * creates a new thread for the calling process with the SDL_CreateThread() + * API. There is a problem with this, that only the RTL of the SDL2.DLL will + * be initialized for those threads, and not the RTL of the calling + * application! + * + * To solve this, we make a little hack here. + * + * We'll always use the caller's _beginthread() and _endthread() APIs to + * start a new thread. This way, if it's the SDL2.DLL which uses this API, + * then the RTL of SDL2.DLL will be used to create the new thread, and if it's + * the application, then the RTL of the application will be used. + * + * So, in short: + * Always use the _beginthread() and _endthread() of the calling runtime + * library! + */ +#define SDL_PASSED_BEGINTHREAD_ENDTHREAD +#include /* _beginthreadex() and _endthreadex() */ + +typedef uintptr_t (__cdecl * pfnSDL_CurrentBeginThread) + (void *, unsigned, unsigned (__stdcall *func)(void *), + void * /*arg*/, unsigned, unsigned * /* threadID */); +typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code); + +#ifndef SDL_beginthread +#define SDL_beginthread _beginthreadex +#endif +#ifndef SDL_endthread +#define SDL_endthread _endthreadex +#endif + +/** + * Create a thread. + */ +extern DECLSPEC SDL_Thread *SDLCALL +SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data, + pfnSDL_CurrentBeginThread pfnBeginThread, + pfnSDL_CurrentEndThread pfnEndThread); + +extern DECLSPEC SDL_Thread *SDLCALL +SDL_CreateThreadWithStackSize(int (SDLCALL * fn) (void *), + const char *name, const size_t stacksize, void *data, + pfnSDL_CurrentBeginThread pfnBeginThread, + pfnSDL_CurrentEndThread pfnEndThread); + + +/** + * Create a thread. + */ +#if defined(SDL_CreateThread) && SDL_DYNAMIC_API +#undef SDL_CreateThread +#define SDL_CreateThread(fn, name, data) SDL_CreateThread_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread) +#undef SDL_CreateThreadWithStackSize +#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize_REAL(fn, name, stacksize, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread) +#else +#define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread) +#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthreadex, (pfnSDL_CurrentEndThread)SDL_endthread) +#endif + +#elif defined(__OS2__) +/* + * just like the windows case above: We compile SDL2 + * into a dll with Watcom's runtime statically linked. + */ +#define SDL_PASSED_BEGINTHREAD_ENDTHREAD + +#ifndef __EMX__ +#include +#else +#include +#endif + +typedef int (*pfnSDL_CurrentBeginThread)(void (*func)(void *), void *, unsigned, void * /*arg*/); +typedef void (*pfnSDL_CurrentEndThread)(void); + +#ifndef SDL_beginthread +#define SDL_beginthread _beginthread +#endif +#ifndef SDL_endthread +#define SDL_endthread _endthread +#endif + +extern DECLSPEC SDL_Thread *SDLCALL +SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data, + pfnSDL_CurrentBeginThread pfnBeginThread, + pfnSDL_CurrentEndThread pfnEndThread); +extern DECLSPEC SDL_Thread *SDLCALL +SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn, const char *name, const size_t stacksize, void *data, + pfnSDL_CurrentBeginThread pfnBeginThread, + pfnSDL_CurrentEndThread pfnEndThread); + +#if defined(SDL_CreateThread) && SDL_DYNAMIC_API +#undef SDL_CreateThread +#define SDL_CreateThread(fn, name, data) SDL_CreateThread_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread) +#undef SDL_CreateThreadWithStackSize +#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread) +#else +#define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread) +#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize(fn, name, stacksize, data, (pfnSDL_CurrentBeginThread)SDL_beginthread, (pfnSDL_CurrentEndThread)SDL_endthread) +#endif + +#else + +/** + * Create a thread with a default stack size. + * + * This is equivalent to calling: + * SDL_CreateThreadWithStackSize(fn, name, 0, data); + */ +extern DECLSPEC SDL_Thread *SDLCALL +SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data); + +/** + * Create a thread. + * + * Thread naming is a little complicated: Most systems have very small + * limits for the string length (Haiku has 32 bytes, Linux currently has 16, + * Visual C++ 6.0 has nine!), and possibly other arbitrary rules. You'll + * have to see what happens with your system's debugger. The name should be + * UTF-8 (but using the naming limits of C identifiers is a better bet). + * There are no requirements for thread naming conventions, so long as the + * string is null-terminated UTF-8, but these guidelines are helpful in + * choosing a name: + * + * http://stackoverflow.com/questions/149932/naming-conventions-for-threads + * + * If a system imposes requirements, SDL will try to munge the string for + * it (truncate, etc), but the original string contents will be available + * from SDL_GetThreadName(). + * + * The size (in bytes) of the new stack can be specified. Zero means "use + * the system default" which might be wildly different between platforms + * (x86 Linux generally defaults to eight megabytes, an embedded device + * might be a few kilobytes instead). + * + * In SDL 2.1, stacksize will be folded into the original SDL_CreateThread + * function. + */ +extern DECLSPEC SDL_Thread *SDLCALL +SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn, const char *name, const size_t stacksize, void *data); + +#endif + +/** + * Get the thread name, as it was specified in SDL_CreateThread(). + * This function returns a pointer to a UTF-8 string that names the + * specified thread, or NULL if it doesn't have a name. This is internal + * memory, not to be free()'d by the caller, and remains valid until the + * specified thread is cleaned up by SDL_WaitThread(). + */ +extern DECLSPEC const char *SDLCALL SDL_GetThreadName(SDL_Thread *thread); + +/** + * Get the thread identifier for the current thread. + */ +extern DECLSPEC SDL_threadID SDLCALL SDL_ThreadID(void); + +/** + * Get the thread identifier for the specified thread. + * + * Equivalent to SDL_ThreadID() if the specified thread is NULL. + */ +extern DECLSPEC SDL_threadID SDLCALL SDL_GetThreadID(SDL_Thread * thread); + +/** + * Set the priority for the current thread + */ +extern DECLSPEC int SDLCALL SDL_SetThreadPriority(SDL_ThreadPriority priority); + +/** + * Wait for a thread to finish. Threads that haven't been detached will + * remain (as a "zombie") until this function cleans them up. Not doing so + * is a resource leak. + * + * Once a thread has been cleaned up through this function, the SDL_Thread + * that references it becomes invalid and should not be referenced again. + * As such, only one thread may call SDL_WaitThread() on another. + * + * The return code for the thread function is placed in the area + * pointed to by \c status, if \c status is not NULL. + * + * You may not wait on a thread that has been used in a call to + * SDL_DetachThread(). Use either that function or this one, but not + * both, or behavior is undefined. + * + * It is safe to pass NULL to this function; it is a no-op. + */ +extern DECLSPEC void SDLCALL SDL_WaitThread(SDL_Thread * thread, int *status); + +/** + * A thread may be "detached" to signify that it should not remain until + * another thread has called SDL_WaitThread() on it. Detaching a thread + * is useful for long-running threads that nothing needs to synchronize + * with or further manage. When a detached thread is done, it simply + * goes away. + * + * There is no way to recover the return code of a detached thread. If you + * need this, don't detach the thread and instead use SDL_WaitThread(). + * + * Once a thread is detached, you should usually assume the SDL_Thread isn't + * safe to reference again, as it will become invalid immediately upon + * the detached thread's exit, instead of remaining until someone has called + * SDL_WaitThread() to finally clean it up. As such, don't detach the same + * thread more than once. + * + * If a thread has already exited when passed to SDL_DetachThread(), it will + * stop waiting for a call to SDL_WaitThread() and clean up immediately. + * It is not safe to detach a thread that might be used with SDL_WaitThread(). + * + * You may not call SDL_WaitThread() on a thread that has been detached. + * Use either that function or this one, but not both, or behavior is + * undefined. + * + * It is safe to pass NULL to this function; it is a no-op. + */ +extern DECLSPEC void SDLCALL SDL_DetachThread(SDL_Thread * thread); + +/** + * \brief Create an identifier that is globally visible to all threads but refers to data that is thread-specific. + * + * \return The newly created thread local storage identifier, or 0 on error + * + * \code + * static SDL_SpinLock tls_lock; + * static SDL_TLSID thread_local_storage; + * + * void SetMyThreadData(void *value) + * { + * if (!thread_local_storage) { + * SDL_AtomicLock(&tls_lock); + * if (!thread_local_storage) { + * thread_local_storage = SDL_TLSCreate(); + * } + * SDL_AtomicUnlock(&tls_lock); + * } + * SDL_TLSSet(thread_local_storage, value, 0); + * } + * + * void *GetMyThreadData(void) + * { + * return SDL_TLSGet(thread_local_storage); + * } + * \endcode + * + * \sa SDL_TLSGet() + * \sa SDL_TLSSet() + */ +extern DECLSPEC SDL_TLSID SDLCALL SDL_TLSCreate(void); + +/** + * \brief Get the value associated with a thread local storage ID for the current thread. + * + * \param id The thread local storage ID + * + * \return The value associated with the ID for the current thread, or NULL if no value has been set. + * + * \sa SDL_TLSCreate() + * \sa SDL_TLSSet() + */ +extern DECLSPEC void * SDLCALL SDL_TLSGet(SDL_TLSID id); + +/** + * \brief Set the value associated with a thread local storage ID for the current thread. + * + * \param id The thread local storage ID + * \param value The value to associate with the ID for the current thread + * \param destructor A function called when the thread exits, to free the value. + * + * \return 0 on success, -1 on error + * + * \sa SDL_TLSCreate() + * \sa SDL_TLSGet() + */ +extern DECLSPEC int SDLCALL SDL_TLSSet(SDL_TLSID id, const void *value, void (SDLCALL *destructor)(void*)); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_thread_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_timer.h b/thirdparty/include/SDL2/SDL_timer.h new file mode 100644 index 000000000..aada7178b --- /dev/null +++ b/thirdparty/include/SDL2/SDL_timer.h @@ -0,0 +1,115 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_timer_h_ +#define SDL_timer_h_ + +/** + * \file SDL_timer.h + * + * Header for the SDL time management routines. + */ + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Get the number of milliseconds since the SDL library initialization. + * + * \note This value wraps if the program runs for more than ~49 days. + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void); + +/** + * \brief Compare SDL ticks values, and return true if A has passed B + * + * e.g. if you want to wait 100 ms, you could do this: + * Uint32 timeout = SDL_GetTicks() + 100; + * while (!SDL_TICKS_PASSED(SDL_GetTicks(), timeout)) { + * ... do work until timeout has elapsed + * } + */ +#define SDL_TICKS_PASSED(A, B) ((Sint32)((B) - (A)) <= 0) + +/** + * \brief Get the current value of the high resolution counter + */ +extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceCounter(void); + +/** + * \brief Get the count per second of the high resolution counter + */ +extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceFrequency(void); + +/** + * \brief Wait a specified number of milliseconds before returning. + */ +extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms); + +/** + * Function prototype for the timer callback function. + * + * The callback function is passed the current timer interval and returns + * the next timer interval. If the returned value is the same as the one + * passed in, the periodic alarm continues, otherwise a new alarm is + * scheduled. If the callback returns 0, the periodic alarm is cancelled. + */ +typedef Uint32 (SDLCALL * SDL_TimerCallback) (Uint32 interval, void *param); + +/** + * Definition of the timer ID type. + */ +typedef int SDL_TimerID; + +/** + * \brief Add a new timer to the pool of timers already running. + * + * \return A timer ID, or 0 when an error occurs. + */ +extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, + SDL_TimerCallback callback, + void *param); + +/** + * \brief Remove a timer knowing its ID. + * + * \return A boolean value indicating success or failure. + * + * \warning It is not safe to remove a timer multiple times. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID id); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_timer_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_touch.h b/thirdparty/include/SDL2/SDL_touch.h new file mode 100644 index 000000000..fa5a37ce3 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_touch.h @@ -0,0 +1,102 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_touch.h + * + * Include file for SDL touch event handling. + */ + +#ifndef SDL_touch_h_ +#define SDL_touch_h_ + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +typedef Sint64 SDL_TouchID; +typedef Sint64 SDL_FingerID; + +typedef enum +{ + SDL_TOUCH_DEVICE_INVALID = -1, + SDL_TOUCH_DEVICE_DIRECT, /* touch screen with window-relative coordinates */ + SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE, /* trackpad with absolute device coordinates */ + SDL_TOUCH_DEVICE_INDIRECT_RELATIVE /* trackpad with screen cursor-relative coordinates */ +} SDL_TouchDeviceType; + +typedef struct SDL_Finger +{ + SDL_FingerID id; + float x; + float y; + float pressure; +} SDL_Finger; + +/* Used as the device ID for mouse events simulated with touch input */ +#define SDL_TOUCH_MOUSEID ((Uint32)-1) + +/* Used as the SDL_TouchID for touch events simulated with mouse input */ +#define SDL_MOUSE_TOUCHID ((Sint64)-1) + + +/* Function prototypes */ + +/** + * \brief Get the number of registered touch devices. + */ +extern DECLSPEC int SDLCALL SDL_GetNumTouchDevices(void); + +/** + * \brief Get the touch ID with the given index, or 0 if the index is invalid. + */ +extern DECLSPEC SDL_TouchID SDLCALL SDL_GetTouchDevice(int index); + +/** + * \brief Get the type of the given touch device. + */ +extern DECLSPEC SDL_TouchDeviceType SDLCALL SDL_GetTouchDeviceType(SDL_TouchID touchID); + +/** + * \brief Get the number of active fingers for a given touch device. + */ +extern DECLSPEC int SDLCALL SDL_GetNumTouchFingers(SDL_TouchID touchID); + +/** + * \brief Get the finger object of the given touch, with the given index. + */ +extern DECLSPEC SDL_Finger * SDLCALL SDL_GetTouchFinger(SDL_TouchID touchID, int index); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_touch_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_types.h b/thirdparty/include/SDL2/SDL_types.h new file mode 100644 index 000000000..b6bb57117 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_types.h @@ -0,0 +1,29 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_types.h + * + * \deprecated + */ + +/* DEPRECATED */ +#include "SDL_stdinc.h" diff --git a/thirdparty/include/SDL2/SDL_version.h b/thirdparty/include/SDL2/SDL_version.h new file mode 100644 index 000000000..c824b1d31 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_version.h @@ -0,0 +1,162 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_version.h + * + * This header defines the current SDL version. + */ + +#ifndef SDL_version_h_ +#define SDL_version_h_ + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief Information the version of SDL in use. + * + * Represents the library's version as three levels: major revision + * (increments with massive changes, additions, and enhancements), + * minor revision (increments with backwards-compatible changes to the + * major revision), and patchlevel (increments with fixes to the minor + * revision). + * + * \sa SDL_VERSION + * \sa SDL_GetVersion + */ +typedef struct SDL_version +{ + Uint8 major; /**< major version */ + Uint8 minor; /**< minor version */ + Uint8 patch; /**< update version */ +} SDL_version; + +/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL +*/ +#define SDL_MAJOR_VERSION 2 +#define SDL_MINOR_VERSION 0 +#define SDL_PATCHLEVEL 12 + +/** + * \brief Macro to determine SDL version program was compiled against. + * + * This macro fills in a SDL_version structure with the version of the + * library you compiled against. This is determined by what header the + * compiler uses. Note that if you dynamically linked the library, you might + * have a slightly newer or older version at runtime. That version can be + * determined with SDL_GetVersion(), which, unlike SDL_VERSION(), + * is not a macro. + * + * \param x A pointer to a SDL_version struct to initialize. + * + * \sa SDL_version + * \sa SDL_GetVersion + */ +#define SDL_VERSION(x) \ +{ \ + (x)->major = SDL_MAJOR_VERSION; \ + (x)->minor = SDL_MINOR_VERSION; \ + (x)->patch = SDL_PATCHLEVEL; \ +} + +/** + * This macro turns the version numbers into a numeric value: + * \verbatim + (1,2,3) -> (1203) + \endverbatim + * + * This assumes that there will never be more than 100 patchlevels. + */ +#define SDL_VERSIONNUM(X, Y, Z) \ + ((X)*1000 + (Y)*100 + (Z)) + +/** + * This is the version number macro for the current SDL version. + */ +#define SDL_COMPILEDVERSION \ + SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) + +/** + * This macro will evaluate to true if compiled with SDL at least X.Y.Z. + */ +#define SDL_VERSION_ATLEAST(X, Y, Z) \ + (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) + +/** + * \brief Get the version of SDL that is linked against your program. + * + * If you are linking to SDL dynamically, then it is possible that the + * current version will be different than the version you compiled against. + * This function returns the current version, while SDL_VERSION() is a + * macro that tells you what version you compiled with. + * + * \code + * SDL_version compiled; + * SDL_version linked; + * + * SDL_VERSION(&compiled); + * SDL_GetVersion(&linked); + * printf("We compiled against SDL version %d.%d.%d ...\n", + * compiled.major, compiled.minor, compiled.patch); + * printf("But we linked against SDL version %d.%d.%d.\n", + * linked.major, linked.minor, linked.patch); + * \endcode + * + * This function may be called safely at any time, even before SDL_Init(). + * + * \sa SDL_VERSION + */ +extern DECLSPEC void SDLCALL SDL_GetVersion(SDL_version * ver); + +/** + * \brief Get the code revision of SDL that is linked against your program. + * + * Returns an arbitrary string (a hash value) uniquely identifying the + * exact revision of the SDL library in use, and is only useful in comparing + * against other revisions. It is NOT an incrementing number. + */ +extern DECLSPEC const char *SDLCALL SDL_GetRevision(void); + +/** + * \brief Get the revision number of SDL that is linked against your program. + * + * Returns a number uniquely identifying the exact revision of the SDL + * library in use. It is an incrementing number based on commits to + * hg.libsdl.org. + */ +extern DECLSPEC int SDLCALL SDL_GetRevisionNumber(void); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_version_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_video.h b/thirdparty/include/SDL2/SDL_video.h new file mode 100644 index 000000000..20d4ce2d4 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_video.h @@ -0,0 +1,1275 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_video.h + * + * Header file for SDL video functions. + */ + +#ifndef SDL_video_h_ +#define SDL_video_h_ + +#include "SDL_stdinc.h" +#include "SDL_pixels.h" +#include "SDL_rect.h" +#include "SDL_surface.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief The structure that defines a display mode + * + * \sa SDL_GetNumDisplayModes() + * \sa SDL_GetDisplayMode() + * \sa SDL_GetDesktopDisplayMode() + * \sa SDL_GetCurrentDisplayMode() + * \sa SDL_GetClosestDisplayMode() + * \sa SDL_SetWindowDisplayMode() + * \sa SDL_GetWindowDisplayMode() + */ +typedef struct +{ + Uint32 format; /**< pixel format */ + int w; /**< width, in screen coordinates */ + int h; /**< height, in screen coordinates */ + int refresh_rate; /**< refresh rate (or zero for unspecified) */ + void *driverdata; /**< driver-specific data, initialize to 0 */ +} SDL_DisplayMode; + +/** + * \brief The type used to identify a window + * + * \sa SDL_CreateWindow() + * \sa SDL_CreateWindowFrom() + * \sa SDL_DestroyWindow() + * \sa SDL_GetWindowData() + * \sa SDL_GetWindowFlags() + * \sa SDL_GetWindowGrab() + * \sa SDL_GetWindowPosition() + * \sa SDL_GetWindowSize() + * \sa SDL_GetWindowTitle() + * \sa SDL_HideWindow() + * \sa SDL_MaximizeWindow() + * \sa SDL_MinimizeWindow() + * \sa SDL_RaiseWindow() + * \sa SDL_RestoreWindow() + * \sa SDL_SetWindowData() + * \sa SDL_SetWindowFullscreen() + * \sa SDL_SetWindowGrab() + * \sa SDL_SetWindowIcon() + * \sa SDL_SetWindowPosition() + * \sa SDL_SetWindowSize() + * \sa SDL_SetWindowBordered() + * \sa SDL_SetWindowResizable() + * \sa SDL_SetWindowTitle() + * \sa SDL_ShowWindow() + */ +typedef struct SDL_Window SDL_Window; + +/** + * \brief The flags on a window + * + * \sa SDL_GetWindowFlags() + */ +typedef enum +{ + SDL_WINDOW_FULLSCREEN = 0x00000001, /**< fullscreen window */ + SDL_WINDOW_OPENGL = 0x00000002, /**< window usable with OpenGL context */ + SDL_WINDOW_SHOWN = 0x00000004, /**< window is visible */ + SDL_WINDOW_HIDDEN = 0x00000008, /**< window is not visible */ + SDL_WINDOW_BORDERLESS = 0x00000010, /**< no window decoration */ + SDL_WINDOW_RESIZABLE = 0x00000020, /**< window can be resized */ + SDL_WINDOW_MINIMIZED = 0x00000040, /**< window is minimized */ + SDL_WINDOW_MAXIMIZED = 0x00000080, /**< window is maximized */ + SDL_WINDOW_INPUT_GRABBED = 0x00000100, /**< window has grabbed input focus */ + SDL_WINDOW_INPUT_FOCUS = 0x00000200, /**< window has input focus */ + SDL_WINDOW_MOUSE_FOCUS = 0x00000400, /**< window has mouse focus */ + SDL_WINDOW_FULLSCREEN_DESKTOP = ( SDL_WINDOW_FULLSCREEN | 0x00001000 ), + SDL_WINDOW_FOREIGN = 0x00000800, /**< window not created by SDL */ + SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000, /**< window should be created in high-DPI mode if supported. + On macOS NSHighResolutionCapable must be set true in the + application's Info.plist for this to have any effect. */ + SDL_WINDOW_MOUSE_CAPTURE = 0x00004000, /**< window has mouse captured (unrelated to INPUT_GRABBED) */ + SDL_WINDOW_ALWAYS_ON_TOP = 0x00008000, /**< window should always be above others */ + SDL_WINDOW_SKIP_TASKBAR = 0x00010000, /**< window should not be added to the taskbar */ + SDL_WINDOW_UTILITY = 0x00020000, /**< window should be treated as a utility window */ + SDL_WINDOW_TOOLTIP = 0x00040000, /**< window should be treated as a tooltip */ + SDL_WINDOW_POPUP_MENU = 0x00080000, /**< window should be treated as a popup menu */ + SDL_WINDOW_VULKAN = 0x10000000 /**< window usable for Vulkan surface */ +} SDL_WindowFlags; + +/** + * \brief Used to indicate that you don't care what the window position is. + */ +#define SDL_WINDOWPOS_UNDEFINED_MASK 0x1FFF0000u +#define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X) (SDL_WINDOWPOS_UNDEFINED_MASK|(X)) +#define SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED_DISPLAY(0) +#define SDL_WINDOWPOS_ISUNDEFINED(X) \ + (((X)&0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK) + +/** + * \brief Used to indicate that the window position should be centered. + */ +#define SDL_WINDOWPOS_CENTERED_MASK 0x2FFF0000u +#define SDL_WINDOWPOS_CENTERED_DISPLAY(X) (SDL_WINDOWPOS_CENTERED_MASK|(X)) +#define SDL_WINDOWPOS_CENTERED SDL_WINDOWPOS_CENTERED_DISPLAY(0) +#define SDL_WINDOWPOS_ISCENTERED(X) \ + (((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK) + +/** + * \brief Event subtype for window events + */ +typedef enum +{ + SDL_WINDOWEVENT_NONE, /**< Never used */ + SDL_WINDOWEVENT_SHOWN, /**< Window has been shown */ + SDL_WINDOWEVENT_HIDDEN, /**< Window has been hidden */ + SDL_WINDOWEVENT_EXPOSED, /**< Window has been exposed and should be + redrawn */ + SDL_WINDOWEVENT_MOVED, /**< Window has been moved to data1, data2 + */ + SDL_WINDOWEVENT_RESIZED, /**< Window has been resized to data1xdata2 */ + SDL_WINDOWEVENT_SIZE_CHANGED, /**< The window size has changed, either as + a result of an API call or through the + system or user changing the window size. */ + SDL_WINDOWEVENT_MINIMIZED, /**< Window has been minimized */ + SDL_WINDOWEVENT_MAXIMIZED, /**< Window has been maximized */ + SDL_WINDOWEVENT_RESTORED, /**< Window has been restored to normal size + and position */ + SDL_WINDOWEVENT_ENTER, /**< Window has gained mouse focus */ + SDL_WINDOWEVENT_LEAVE, /**< Window has lost mouse focus */ + SDL_WINDOWEVENT_FOCUS_GAINED, /**< Window has gained keyboard focus */ + SDL_WINDOWEVENT_FOCUS_LOST, /**< Window has lost keyboard focus */ + SDL_WINDOWEVENT_CLOSE, /**< The window manager requests that the window be closed */ + SDL_WINDOWEVENT_TAKE_FOCUS, /**< Window is being offered a focus (should SetWindowInputFocus() on itself or a subwindow, or ignore) */ + SDL_WINDOWEVENT_HIT_TEST /**< Window had a hit test that wasn't SDL_HITTEST_NORMAL. */ +} SDL_WindowEventID; + +/** + * \brief Event subtype for display events + */ +typedef enum +{ + SDL_DISPLAYEVENT_NONE, /**< Never used */ + SDL_DISPLAYEVENT_ORIENTATION /**< Display orientation has changed to data1 */ +} SDL_DisplayEventID; + +typedef enum +{ + SDL_ORIENTATION_UNKNOWN, /**< The display orientation can't be determined */ + SDL_ORIENTATION_LANDSCAPE, /**< The display is in landscape mode, with the right side up, relative to portrait mode */ + SDL_ORIENTATION_LANDSCAPE_FLIPPED, /**< The display is in landscape mode, with the left side up, relative to portrait mode */ + SDL_ORIENTATION_PORTRAIT, /**< The display is in portrait mode */ + SDL_ORIENTATION_PORTRAIT_FLIPPED /**< The display is in portrait mode, upside down */ +} SDL_DisplayOrientation; + +/** + * \brief An opaque handle to an OpenGL context. + */ +typedef void *SDL_GLContext; + +/** + * \brief OpenGL configuration attributes + */ +typedef enum +{ + SDL_GL_RED_SIZE, + SDL_GL_GREEN_SIZE, + SDL_GL_BLUE_SIZE, + SDL_GL_ALPHA_SIZE, + SDL_GL_BUFFER_SIZE, + SDL_GL_DOUBLEBUFFER, + SDL_GL_DEPTH_SIZE, + SDL_GL_STENCIL_SIZE, + SDL_GL_ACCUM_RED_SIZE, + SDL_GL_ACCUM_GREEN_SIZE, + SDL_GL_ACCUM_BLUE_SIZE, + SDL_GL_ACCUM_ALPHA_SIZE, + SDL_GL_STEREO, + SDL_GL_MULTISAMPLEBUFFERS, + SDL_GL_MULTISAMPLESAMPLES, + SDL_GL_ACCELERATED_VISUAL, + SDL_GL_RETAINED_BACKING, + SDL_GL_CONTEXT_MAJOR_VERSION, + SDL_GL_CONTEXT_MINOR_VERSION, + SDL_GL_CONTEXT_EGL, + SDL_GL_CONTEXT_FLAGS, + SDL_GL_CONTEXT_PROFILE_MASK, + SDL_GL_SHARE_WITH_CURRENT_CONTEXT, + SDL_GL_FRAMEBUFFER_SRGB_CAPABLE, + SDL_GL_CONTEXT_RELEASE_BEHAVIOR, + SDL_GL_CONTEXT_RESET_NOTIFICATION, + SDL_GL_CONTEXT_NO_ERROR +} SDL_GLattr; + +typedef enum +{ + SDL_GL_CONTEXT_PROFILE_CORE = 0x0001, + SDL_GL_CONTEXT_PROFILE_COMPATIBILITY = 0x0002, + SDL_GL_CONTEXT_PROFILE_ES = 0x0004 /**< GLX_CONTEXT_ES2_PROFILE_BIT_EXT */ +} SDL_GLprofile; + +typedef enum +{ + SDL_GL_CONTEXT_DEBUG_FLAG = 0x0001, + SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG = 0x0002, + SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG = 0x0004, + SDL_GL_CONTEXT_RESET_ISOLATION_FLAG = 0x0008 +} SDL_GLcontextFlag; + +typedef enum +{ + SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONE = 0x0000, + SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH = 0x0001 +} SDL_GLcontextReleaseFlag; + +typedef enum +{ + SDL_GL_CONTEXT_RESET_NO_NOTIFICATION = 0x0000, + SDL_GL_CONTEXT_RESET_LOSE_CONTEXT = 0x0001 +} SDL_GLContextResetNotification; + +/* Function prototypes */ + +/** + * \brief Get the number of video drivers compiled into SDL + * + * \sa SDL_GetVideoDriver() + */ +extern DECLSPEC int SDLCALL SDL_GetNumVideoDrivers(void); + +/** + * \brief Get the name of a built in video driver. + * + * \note The video drivers are presented in the order in which they are + * normally checked during initialization. + * + * \sa SDL_GetNumVideoDrivers() + */ +extern DECLSPEC const char *SDLCALL SDL_GetVideoDriver(int index); + +/** + * \brief Initialize the video subsystem, optionally specifying a video driver. + * + * \param driver_name Initialize a specific driver by name, or NULL for the + * default video driver. + * + * \return 0 on success, -1 on error + * + * This function initializes the video subsystem; setting up a connection + * to the window manager, etc, and determines the available display modes + * and pixel formats, but does not initialize a window or graphics mode. + * + * \sa SDL_VideoQuit() + */ +extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name); + +/** + * \brief Shuts down the video subsystem. + * + * This function closes all windows, and restores the original video mode. + * + * \sa SDL_VideoInit() + */ +extern DECLSPEC void SDLCALL SDL_VideoQuit(void); + +/** + * \brief Returns the name of the currently initialized video driver. + * + * \return The name of the current video driver or NULL if no driver + * has been initialized + * + * \sa SDL_GetNumVideoDrivers() + * \sa SDL_GetVideoDriver() + */ +extern DECLSPEC const char *SDLCALL SDL_GetCurrentVideoDriver(void); + +/** + * \brief Returns the number of available video displays. + * + * \sa SDL_GetDisplayBounds() + */ +extern DECLSPEC int SDLCALL SDL_GetNumVideoDisplays(void); + +/** + * \brief Get the name of a display in UTF-8 encoding + * + * \return The name of a display, or NULL for an invalid display index. + * + * \sa SDL_GetNumVideoDisplays() + */ +extern DECLSPEC const char * SDLCALL SDL_GetDisplayName(int displayIndex); + +/** + * \brief Get the desktop area represented by a display, with the primary + * display located at 0,0 + * + * \return 0 on success, or -1 if the index is out of range. + * + * \sa SDL_GetNumVideoDisplays() + */ +extern DECLSPEC int SDLCALL SDL_GetDisplayBounds(int displayIndex, SDL_Rect * rect); + +/** + * \brief Get the usable desktop area represented by a display, with the + * primary display located at 0,0 + * + * This is the same area as SDL_GetDisplayBounds() reports, but with portions + * reserved by the system removed. For example, on Mac OS X, this subtracts + * the area occupied by the menu bar and dock. + * + * Setting a window to be fullscreen generally bypasses these unusable areas, + * so these are good guidelines for the maximum space available to a + * non-fullscreen window. + * + * \return 0 on success, or -1 if the index is out of range. + * + * \sa SDL_GetDisplayBounds() + * \sa SDL_GetNumVideoDisplays() + */ +extern DECLSPEC int SDLCALL SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rect * rect); + +/** + * \brief Get the dots/pixels-per-inch for a display + * + * \note Diagonal, horizontal and vertical DPI can all be optionally + * returned if the parameter is non-NULL. + * + * \return 0 on success, or -1 if no DPI information is available or the index is out of range. + * + * \sa SDL_GetNumVideoDisplays() + */ +extern DECLSPEC int SDLCALL SDL_GetDisplayDPI(int displayIndex, float * ddpi, float * hdpi, float * vdpi); + +/** + * \brief Get the orientation of a display + * + * \return The orientation of the display, or SDL_ORIENTATION_UNKNOWN if it isn't available. + * + * \sa SDL_GetNumVideoDisplays() + */ +extern DECLSPEC SDL_DisplayOrientation SDLCALL SDL_GetDisplayOrientation(int displayIndex); + +/** + * \brief Returns the number of available display modes. + * + * \sa SDL_GetDisplayMode() + */ +extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(int displayIndex); + +/** + * \brief Fill in information about a specific display mode. + * + * \note The display modes are sorted in this priority: + * \li bits per pixel -> more colors to fewer colors + * \li width -> largest to smallest + * \li height -> largest to smallest + * \li refresh rate -> highest to lowest + * + * \sa SDL_GetNumDisplayModes() + */ +extern DECLSPEC int SDLCALL SDL_GetDisplayMode(int displayIndex, int modeIndex, + SDL_DisplayMode * mode); + +/** + * \brief Fill in information about the desktop display mode. + */ +extern DECLSPEC int SDLCALL SDL_GetDesktopDisplayMode(int displayIndex, SDL_DisplayMode * mode); + +/** + * \brief Fill in information about the current display mode. + */ +extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(int displayIndex, SDL_DisplayMode * mode); + + +/** + * \brief Get the closest match to the requested display mode. + * + * \param displayIndex The index of display from which mode should be queried. + * \param mode The desired display mode + * \param closest A pointer to a display mode to be filled in with the closest + * match of the available display modes. + * + * \return The passed in value \c closest, or NULL if no matching video mode + * was available. + * + * The available display modes are scanned, and \c closest is filled in with the + * closest mode matching the requested mode and returned. The mode format and + * refresh_rate default to the desktop mode if they are 0. The modes are + * scanned with size being first priority, format being second priority, and + * finally checking the refresh_rate. If all the available modes are too + * small, then NULL is returned. + * + * \sa SDL_GetNumDisplayModes() + * \sa SDL_GetDisplayMode() + */ +extern DECLSPEC SDL_DisplayMode * SDLCALL SDL_GetClosestDisplayMode(int displayIndex, const SDL_DisplayMode * mode, SDL_DisplayMode * closest); + +/** + * \brief Get the display index associated with a window. + * + * \return the display index of the display containing the center of the + * window, or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_GetWindowDisplayIndex(SDL_Window * window); + +/** + * \brief Set the display mode used when a fullscreen window is visible. + * + * By default the window's dimensions and the desktop format and refresh rate + * are used. + * + * \param window The window for which the display mode should be set. + * \param mode The mode to use, or NULL for the default mode. + * + * \return 0 on success, or -1 if setting the display mode failed. + * + * \sa SDL_GetWindowDisplayMode() + * \sa SDL_SetWindowFullscreen() + */ +extern DECLSPEC int SDLCALL SDL_SetWindowDisplayMode(SDL_Window * window, + const SDL_DisplayMode + * mode); + +/** + * \brief Fill in information about the display mode used when a fullscreen + * window is visible. + * + * \sa SDL_SetWindowDisplayMode() + * \sa SDL_SetWindowFullscreen() + */ +extern DECLSPEC int SDLCALL SDL_GetWindowDisplayMode(SDL_Window * window, + SDL_DisplayMode * mode); + +/** + * \brief Get the pixel format associated with the window. + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window * window); + +/** + * \brief Create a window with the specified position, dimensions, and flags. + * + * \param title The title of the window, in UTF-8 encoding. + * \param x The x position of the window, ::SDL_WINDOWPOS_CENTERED, or + * ::SDL_WINDOWPOS_UNDEFINED. + * \param y The y position of the window, ::SDL_WINDOWPOS_CENTERED, or + * ::SDL_WINDOWPOS_UNDEFINED. + * \param w The width of the window, in screen coordinates. + * \param h The height of the window, in screen coordinates. + * \param flags The flags for the window, a mask of any of the following: + * ::SDL_WINDOW_FULLSCREEN, ::SDL_WINDOW_OPENGL, + * ::SDL_WINDOW_HIDDEN, ::SDL_WINDOW_BORDERLESS, + * ::SDL_WINDOW_RESIZABLE, ::SDL_WINDOW_MAXIMIZED, + * ::SDL_WINDOW_MINIMIZED, ::SDL_WINDOW_INPUT_GRABBED, + * ::SDL_WINDOW_ALLOW_HIGHDPI, ::SDL_WINDOW_VULKAN. + * + * \return The created window, or NULL if window creation failed. + * + * If the window is created with the SDL_WINDOW_ALLOW_HIGHDPI flag, its size + * in pixels may differ from its size in screen coordinates on platforms with + * high-DPI support (e.g. iOS and Mac OS X). Use SDL_GetWindowSize() to query + * the client area's size in screen coordinates, and SDL_GL_GetDrawableSize(), + * SDL_Vulkan_GetDrawableSize(), or SDL_GetRendererOutputSize() to query the + * drawable size in pixels. + * + * If the window is created with any of the SDL_WINDOW_OPENGL or + * SDL_WINDOW_VULKAN flags, then the corresponding LoadLibrary function + * (SDL_GL_LoadLibrary or SDL_Vulkan_LoadLibrary) is called and the + * corresponding UnloadLibrary function is called by SDL_DestroyWindow(). + * + * If SDL_WINDOW_VULKAN is specified and there isn't a working Vulkan driver, + * SDL_CreateWindow() will fail because SDL_Vulkan_LoadLibrary() will fail. + * + * \note On non-Apple devices, SDL requires you to either not link to the + * Vulkan loader or link to a dynamic library version. This limitation + * may be removed in a future version of SDL. + * + * \sa SDL_DestroyWindow() + * \sa SDL_GL_LoadLibrary() + * \sa SDL_Vulkan_LoadLibrary() + */ +extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindow(const char *title, + int x, int y, int w, + int h, Uint32 flags); + +/** + * \brief Create an SDL window from an existing native window. + * + * \param data A pointer to driver-dependent window creation data + * + * \return The created window, or NULL if window creation failed. + * + * \sa SDL_DestroyWindow() + */ +extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindowFrom(const void *data); + +/** + * \brief Get the numeric ID of a window, for logging purposes. + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetWindowID(SDL_Window * window); + +/** + * \brief Get a window from a stored ID, or NULL if it doesn't exist. + */ +extern DECLSPEC SDL_Window * SDLCALL SDL_GetWindowFromID(Uint32 id); + +/** + * \brief Get the window flags. + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetWindowFlags(SDL_Window * window); + +/** + * \brief Set the title of a window, in UTF-8 format. + * + * \sa SDL_GetWindowTitle() + */ +extern DECLSPEC void SDLCALL SDL_SetWindowTitle(SDL_Window * window, + const char *title); + +/** + * \brief Get the title of a window, in UTF-8 format. + * + * \sa SDL_SetWindowTitle() + */ +extern DECLSPEC const char *SDLCALL SDL_GetWindowTitle(SDL_Window * window); + +/** + * \brief Set the icon for a window. + * + * \param window The window for which the icon should be set. + * \param icon The icon for the window. + */ +extern DECLSPEC void SDLCALL SDL_SetWindowIcon(SDL_Window * window, + SDL_Surface * icon); + +/** + * \brief Associate an arbitrary named pointer with a window. + * + * \param window The window to associate with the pointer. + * \param name The name of the pointer. + * \param userdata The associated pointer. + * + * \return The previous value associated with 'name' + * + * \note The name is case-sensitive. + * + * \sa SDL_GetWindowData() + */ +extern DECLSPEC void* SDLCALL SDL_SetWindowData(SDL_Window * window, + const char *name, + void *userdata); + +/** + * \brief Retrieve the data pointer associated with a window. + * + * \param window The window to query. + * \param name The name of the pointer. + * + * \return The value associated with 'name' + * + * \sa SDL_SetWindowData() + */ +extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_Window * window, + const char *name); + +/** + * \brief Set the position of a window. + * + * \param window The window to reposition. + * \param x The x coordinate of the window in screen coordinates, or + * ::SDL_WINDOWPOS_CENTERED or ::SDL_WINDOWPOS_UNDEFINED. + * \param y The y coordinate of the window in screen coordinates, or + * ::SDL_WINDOWPOS_CENTERED or ::SDL_WINDOWPOS_UNDEFINED. + * + * \note The window coordinate origin is the upper left of the display. + * + * \sa SDL_GetWindowPosition() + */ +extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_Window * window, + int x, int y); + +/** + * \brief Get the position of a window. + * + * \param window The window to query. + * \param x Pointer to variable for storing the x position, in screen + * coordinates. May be NULL. + * \param y Pointer to variable for storing the y position, in screen + * coordinates. May be NULL. + * + * \sa SDL_SetWindowPosition() + */ +extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window * window, + int *x, int *y); + +/** + * \brief Set the size of a window's client area. + * + * \param window The window to resize. + * \param w The width of the window, in screen coordinates. Must be >0. + * \param h The height of the window, in screen coordinates. Must be >0. + * + * \note Fullscreen windows automatically match the size of the display mode, + * and you should use SDL_SetWindowDisplayMode() to change their size. + * + * The window size in screen coordinates may differ from the size in pixels, if + * the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a platform with + * high-dpi support (e.g. iOS or OS X). Use SDL_GL_GetDrawableSize() or + * SDL_GetRendererOutputSize() to get the real client area size in pixels. + * + * \sa SDL_GetWindowSize() + * \sa SDL_SetWindowDisplayMode() + */ +extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_Window * window, int w, + int h); + +/** + * \brief Get the size of a window's client area. + * + * \param window The window to query. + * \param w Pointer to variable for storing the width, in screen + * coordinates. May be NULL. + * \param h Pointer to variable for storing the height, in screen + * coordinates. May be NULL. + * + * The window size in screen coordinates may differ from the size in pixels, if + * the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a platform with + * high-dpi support (e.g. iOS or OS X). Use SDL_GL_GetDrawableSize() or + * SDL_GetRendererOutputSize() to get the real client area size in pixels. + * + * \sa SDL_SetWindowSize() + */ +extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window * window, int *w, + int *h); + +/** + * \brief Get the size of a window's borders (decorations) around the client area. + * + * \param window The window to query. + * \param top Pointer to variable for storing the size of the top border. NULL is permitted. + * \param left Pointer to variable for storing the size of the left border. NULL is permitted. + * \param bottom Pointer to variable for storing the size of the bottom border. NULL is permitted. + * \param right Pointer to variable for storing the size of the right border. NULL is permitted. + * + * \return 0 on success, or -1 if getting this information is not supported. + * + * \note if this function fails (returns -1), the size values will be + * initialized to 0, 0, 0, 0 (if a non-NULL pointer is provided), as + * if the window in question was borderless. + */ +extern DECLSPEC int SDLCALL SDL_GetWindowBordersSize(SDL_Window * window, + int *top, int *left, + int *bottom, int *right); + +/** + * \brief Set the minimum size of a window's client area. + * + * \param window The window to set a new minimum size. + * \param min_w The minimum width of the window, must be >0 + * \param min_h The minimum height of the window, must be >0 + * + * \note You can't change the minimum size of a fullscreen window, it + * automatically matches the size of the display mode. + * + * \sa SDL_GetWindowMinimumSize() + * \sa SDL_SetWindowMaximumSize() + */ +extern DECLSPEC void SDLCALL SDL_SetWindowMinimumSize(SDL_Window * window, + int min_w, int min_h); + +/** + * \brief Get the minimum size of a window's client area. + * + * \param window The window to query. + * \param w Pointer to variable for storing the minimum width, may be NULL + * \param h Pointer to variable for storing the minimum height, may be NULL + * + * \sa SDL_GetWindowMaximumSize() + * \sa SDL_SetWindowMinimumSize() + */ +extern DECLSPEC void SDLCALL SDL_GetWindowMinimumSize(SDL_Window * window, + int *w, int *h); + +/** + * \brief Set the maximum size of a window's client area. + * + * \param window The window to set a new maximum size. + * \param max_w The maximum width of the window, must be >0 + * \param max_h The maximum height of the window, must be >0 + * + * \note You can't change the maximum size of a fullscreen window, it + * automatically matches the size of the display mode. + * + * \sa SDL_GetWindowMaximumSize() + * \sa SDL_SetWindowMinimumSize() + */ +extern DECLSPEC void SDLCALL SDL_SetWindowMaximumSize(SDL_Window * window, + int max_w, int max_h); + +/** + * \brief Get the maximum size of a window's client area. + * + * \param window The window to query. + * \param w Pointer to variable for storing the maximum width, may be NULL + * \param h Pointer to variable for storing the maximum height, may be NULL + * + * \sa SDL_GetWindowMinimumSize() + * \sa SDL_SetWindowMaximumSize() + */ +extern DECLSPEC void SDLCALL SDL_GetWindowMaximumSize(SDL_Window * window, + int *w, int *h); + +/** + * \brief Set the border state of a window. + * + * This will add or remove the window's SDL_WINDOW_BORDERLESS flag and + * add or remove the border from the actual window. This is a no-op if the + * window's border already matches the requested state. + * + * \param window The window of which to change the border state. + * \param bordered SDL_FALSE to remove border, SDL_TRUE to add border. + * + * \note You can't change the border state of a fullscreen window. + * + * \sa SDL_GetWindowFlags() + */ +extern DECLSPEC void SDLCALL SDL_SetWindowBordered(SDL_Window * window, + SDL_bool bordered); + +/** + * \brief Set the user-resizable state of a window. + * + * This will add or remove the window's SDL_WINDOW_RESIZABLE flag and + * allow/disallow user resizing of the window. This is a no-op if the + * window's resizable state already matches the requested state. + * + * \param window The window of which to change the resizable state. + * \param resizable SDL_TRUE to allow resizing, SDL_FALSE to disallow. + * + * \note You can't change the resizable state of a fullscreen window. + * + * \sa SDL_GetWindowFlags() + */ +extern DECLSPEC void SDLCALL SDL_SetWindowResizable(SDL_Window * window, + SDL_bool resizable); + +/** + * \brief Show a window. + * + * \sa SDL_HideWindow() + */ +extern DECLSPEC void SDLCALL SDL_ShowWindow(SDL_Window * window); + +/** + * \brief Hide a window. + * + * \sa SDL_ShowWindow() + */ +extern DECLSPEC void SDLCALL SDL_HideWindow(SDL_Window * window); + +/** + * \brief Raise a window above other windows and set the input focus. + */ +extern DECLSPEC void SDLCALL SDL_RaiseWindow(SDL_Window * window); + +/** + * \brief Make a window as large as possible. + * + * \sa SDL_RestoreWindow() + */ +extern DECLSPEC void SDLCALL SDL_MaximizeWindow(SDL_Window * window); + +/** + * \brief Minimize a window to an iconic representation. + * + * \sa SDL_RestoreWindow() + */ +extern DECLSPEC void SDLCALL SDL_MinimizeWindow(SDL_Window * window); + +/** + * \brief Restore the size and position of a minimized or maximized window. + * + * \sa SDL_MaximizeWindow() + * \sa SDL_MinimizeWindow() + */ +extern DECLSPEC void SDLCALL SDL_RestoreWindow(SDL_Window * window); + +/** + * \brief Set a window's fullscreen state. + * + * \return 0 on success, or -1 if setting the display mode failed. + * + * \sa SDL_SetWindowDisplayMode() + * \sa SDL_GetWindowDisplayMode() + */ +extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window * window, + Uint32 flags); + +/** + * \brief Get the SDL surface associated with the window. + * + * \return The window's framebuffer surface, or NULL on error. + * + * A new surface will be created with the optimal format for the window, + * if necessary. This surface will be freed when the window is destroyed. + * + * \note You may not combine this with 3D or the rendering API on this window. + * + * \sa SDL_UpdateWindowSurface() + * \sa SDL_UpdateWindowSurfaceRects() + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_GetWindowSurface(SDL_Window * window); + +/** + * \brief Copy the window surface to the screen. + * + * \return 0 on success, or -1 on error. + * + * \sa SDL_GetWindowSurface() + * \sa SDL_UpdateWindowSurfaceRects() + */ +extern DECLSPEC int SDLCALL SDL_UpdateWindowSurface(SDL_Window * window); + +/** + * \brief Copy a number of rectangles on the window surface to the screen. + * + * \return 0 on success, or -1 on error. + * + * \sa SDL_GetWindowSurface() + * \sa SDL_UpdateWindowSurface() + */ +extern DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window * window, + const SDL_Rect * rects, + int numrects); + +/** + * \brief Set a window's input grab mode. + * + * \param window The window for which the input grab mode should be set. + * \param grabbed This is SDL_TRUE to grab input, and SDL_FALSE to release input. + * + * If the caller enables a grab while another window is currently grabbed, + * the other window loses its grab in favor of the caller's window. + * + * \sa SDL_GetWindowGrab() + */ +extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window * window, + SDL_bool grabbed); + +/** + * \brief Get a window's input grab mode. + * + * \return This returns SDL_TRUE if input is grabbed, and SDL_FALSE otherwise. + * + * \sa SDL_SetWindowGrab() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowGrab(SDL_Window * window); + +/** + * \brief Get the window that currently has an input grab enabled. + * + * \return This returns the window if input is grabbed, and NULL otherwise. + * + * \sa SDL_SetWindowGrab() + */ +extern DECLSPEC SDL_Window * SDLCALL SDL_GetGrabbedWindow(void); + +/** + * \brief Set the brightness (gamma correction) for a window. + * + * \return 0 on success, or -1 if setting the brightness isn't supported. + * + * \sa SDL_GetWindowBrightness() + * \sa SDL_SetWindowGammaRamp() + */ +extern DECLSPEC int SDLCALL SDL_SetWindowBrightness(SDL_Window * window, float brightness); + +/** + * \brief Get the brightness (gamma correction) for a window. + * + * \return The last brightness value passed to SDL_SetWindowBrightness() + * + * \sa SDL_SetWindowBrightness() + */ +extern DECLSPEC float SDLCALL SDL_GetWindowBrightness(SDL_Window * window); + +/** + * \brief Set the opacity for a window + * + * \param window The window which will be made transparent or opaque + * \param opacity Opacity (0.0f - transparent, 1.0f - opaque) This will be + * clamped internally between 0.0f and 1.0f. + * + * \return 0 on success, or -1 if setting the opacity isn't supported. + * + * \sa SDL_GetWindowOpacity() + */ +extern DECLSPEC int SDLCALL SDL_SetWindowOpacity(SDL_Window * window, float opacity); + +/** + * \brief Get the opacity of a window. + * + * If transparency isn't supported on this platform, opacity will be reported + * as 1.0f without error. + * + * \param window The window in question. + * \param out_opacity Opacity (0.0f - transparent, 1.0f - opaque) + * + * \return 0 on success, or -1 on error (invalid window, etc). + * + * \sa SDL_SetWindowOpacity() + */ +extern DECLSPEC int SDLCALL SDL_GetWindowOpacity(SDL_Window * window, float * out_opacity); + +/** + * \brief Sets the window as a modal for another window (TODO: reconsider this function and/or its name) + * + * \param modal_window The window that should be modal + * \param parent_window The parent window + * + * \return 0 on success, or -1 otherwise. + */ +extern DECLSPEC int SDLCALL SDL_SetWindowModalFor(SDL_Window * modal_window, SDL_Window * parent_window); + +/** + * \brief Explicitly sets input focus to the window. + * + * You almost certainly want SDL_RaiseWindow() instead of this function. Use + * this with caution, as you might give focus to a window that's completely + * obscured by other windows. + * + * \param window The window that should get the input focus + * + * \return 0 on success, or -1 otherwise. + * \sa SDL_RaiseWindow() + */ +extern DECLSPEC int SDLCALL SDL_SetWindowInputFocus(SDL_Window * window); + +/** + * \brief Set the gamma ramp for a window. + * + * \param window The window for which the gamma ramp should be set. + * \param red The translation table for the red channel, or NULL. + * \param green The translation table for the green channel, or NULL. + * \param blue The translation table for the blue channel, or NULL. + * + * \return 0 on success, or -1 if gamma ramps are unsupported. + * + * Set the gamma translation table for the red, green, and blue channels + * of the video hardware. Each table is an array of 256 16-bit quantities, + * representing a mapping between the input and output for that channel. + * The input is the index into the array, and the output is the 16-bit + * gamma value at that index, scaled to the output color precision. + * + * \sa SDL_GetWindowGammaRamp() + */ +extern DECLSPEC int SDLCALL SDL_SetWindowGammaRamp(SDL_Window * window, + const Uint16 * red, + const Uint16 * green, + const Uint16 * blue); + +/** + * \brief Get the gamma ramp for a window. + * + * \param window The window from which the gamma ramp should be queried. + * \param red A pointer to a 256 element array of 16-bit quantities to hold + * the translation table for the red channel, or NULL. + * \param green A pointer to a 256 element array of 16-bit quantities to hold + * the translation table for the green channel, or NULL. + * \param blue A pointer to a 256 element array of 16-bit quantities to hold + * the translation table for the blue channel, or NULL. + * + * \return 0 on success, or -1 if gamma ramps are unsupported. + * + * \sa SDL_SetWindowGammaRamp() + */ +extern DECLSPEC int SDLCALL SDL_GetWindowGammaRamp(SDL_Window * window, + Uint16 * red, + Uint16 * green, + Uint16 * blue); + +/** + * \brief Possible return values from the SDL_HitTest callback. + * + * \sa SDL_HitTest + */ +typedef enum +{ + SDL_HITTEST_NORMAL, /**< Region is normal. No special properties. */ + SDL_HITTEST_DRAGGABLE, /**< Region can drag entire window. */ + SDL_HITTEST_RESIZE_TOPLEFT, + SDL_HITTEST_RESIZE_TOP, + SDL_HITTEST_RESIZE_TOPRIGHT, + SDL_HITTEST_RESIZE_RIGHT, + SDL_HITTEST_RESIZE_BOTTOMRIGHT, + SDL_HITTEST_RESIZE_BOTTOM, + SDL_HITTEST_RESIZE_BOTTOMLEFT, + SDL_HITTEST_RESIZE_LEFT +} SDL_HitTestResult; + +/** + * \brief Callback used for hit-testing. + * + * \sa SDL_SetWindowHitTest + */ +typedef SDL_HitTestResult (SDLCALL *SDL_HitTest)(SDL_Window *win, + const SDL_Point *area, + void *data); + +/** + * \brief Provide a callback that decides if a window region has special properties. + * + * Normally windows are dragged and resized by decorations provided by the + * system window manager (a title bar, borders, etc), but for some apps, it + * makes sense to drag them from somewhere else inside the window itself; for + * example, one might have a borderless window that wants to be draggable + * from any part, or simulate its own title bar, etc. + * + * This function lets the app provide a callback that designates pieces of + * a given window as special. This callback is run during event processing + * if we need to tell the OS to treat a region of the window specially; the + * use of this callback is known as "hit testing." + * + * Mouse input may not be delivered to your application if it is within + * a special area; the OS will often apply that input to moving the window or + * resizing the window and not deliver it to the application. + * + * Specifying NULL for a callback disables hit-testing. Hit-testing is + * disabled by default. + * + * Platforms that don't support this functionality will return -1 + * unconditionally, even if you're attempting to disable hit-testing. + * + * Your callback may fire at any time, and its firing does not indicate any + * specific behavior (for example, on Windows, this certainly might fire + * when the OS is deciding whether to drag your window, but it fires for lots + * of other reasons, too, some unrelated to anything you probably care about + * _and when the mouse isn't actually at the location it is testing_). + * Since this can fire at any time, you should try to keep your callback + * efficient, devoid of allocations, etc. + * + * \param window The window to set hit-testing on. + * \param callback The callback to call when doing a hit-test. + * \param callback_data An app-defined void pointer passed to the callback. + * \return 0 on success, -1 on error (including unsupported). + */ +extern DECLSPEC int SDLCALL SDL_SetWindowHitTest(SDL_Window * window, + SDL_HitTest callback, + void *callback_data); + +/** + * \brief Destroy a window. + */ +extern DECLSPEC void SDLCALL SDL_DestroyWindow(SDL_Window * window); + + +/** + * \brief Returns whether the screensaver is currently enabled (default off). + * + * \sa SDL_EnableScreenSaver() + * \sa SDL_DisableScreenSaver() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_IsScreenSaverEnabled(void); + +/** + * \brief Allow the screen to be blanked by a screensaver + * + * \sa SDL_IsScreenSaverEnabled() + * \sa SDL_DisableScreenSaver() + */ +extern DECLSPEC void SDLCALL SDL_EnableScreenSaver(void); + +/** + * \brief Prevent the screen from being blanked by a screensaver + * + * \sa SDL_IsScreenSaverEnabled() + * \sa SDL_EnableScreenSaver() + */ +extern DECLSPEC void SDLCALL SDL_DisableScreenSaver(void); + + +/** + * \name OpenGL support functions + */ +/* @{ */ + +/** + * \brief Dynamically load an OpenGL library. + * + * \param path The platform dependent OpenGL library name, or NULL to open the + * default OpenGL library. + * + * \return 0 on success, or -1 if the library couldn't be loaded. + * + * This should be done after initializing the video driver, but before + * creating any OpenGL windows. If no OpenGL library is loaded, the default + * library will be loaded upon creation of the first OpenGL window. + * + * \note If you do this, you need to retrieve all of the GL functions used in + * your program from the dynamic library using SDL_GL_GetProcAddress(). + * + * \sa SDL_GL_GetProcAddress() + * \sa SDL_GL_UnloadLibrary() + */ +extern DECLSPEC int SDLCALL SDL_GL_LoadLibrary(const char *path); + +/** + * \brief Get the address of an OpenGL function. + */ +extern DECLSPEC void *SDLCALL SDL_GL_GetProcAddress(const char *proc); + +/** + * \brief Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary(). + * + * \sa SDL_GL_LoadLibrary() + */ +extern DECLSPEC void SDLCALL SDL_GL_UnloadLibrary(void); + +/** + * \brief Return true if an OpenGL extension is supported for the current + * context. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_GL_ExtensionSupported(const char + *extension); + +/** + * \brief Reset all previously set OpenGL context attributes to their default values + */ +extern DECLSPEC void SDLCALL SDL_GL_ResetAttributes(void); + +/** + * \brief Set an OpenGL window attribute before window creation. + * + * \return 0 on success, or -1 if the attribute could not be set. + */ +extern DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value); + +/** + * \brief Get the actual value for an attribute from the current context. + * + * \return 0 on success, or -1 if the attribute could not be retrieved. + * The integer at \c value will be modified in either case. + */ +extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int *value); + +/** + * \brief Create an OpenGL context for use with an OpenGL window, and make it + * current. + * + * \sa SDL_GL_DeleteContext() + */ +extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_CreateContext(SDL_Window * + window); + +/** + * \brief Set up an OpenGL context for rendering into an OpenGL window. + * + * \note The context must have been created with a compatible window. + */ +extern DECLSPEC int SDLCALL SDL_GL_MakeCurrent(SDL_Window * window, + SDL_GLContext context); + +/** + * \brief Get the currently active OpenGL window. + */ +extern DECLSPEC SDL_Window* SDLCALL SDL_GL_GetCurrentWindow(void); + +/** + * \brief Get the currently active OpenGL context. + */ +extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_GetCurrentContext(void); + +/** + * \brief Get the size of a window's underlying drawable in pixels (for use + * with glViewport). + * + * \param window Window from which the drawable size should be queried + * \param w Pointer to variable for storing the width in pixels, may be NULL + * \param h Pointer to variable for storing the height in pixels, may be NULL + * + * This may differ from SDL_GetWindowSize() if we're rendering to a high-DPI + * drawable, i.e. the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a + * platform with high-DPI support (Apple calls this "Retina"), and not disabled + * by the SDL_HINT_VIDEO_HIGHDPI_DISABLED hint. + * + * \sa SDL_GetWindowSize() + * \sa SDL_CreateWindow() + */ +extern DECLSPEC void SDLCALL SDL_GL_GetDrawableSize(SDL_Window * window, int *w, + int *h); + +/** + * \brief Set the swap interval for the current OpenGL context. + * + * \param interval 0 for immediate updates, 1 for updates synchronized with the + * vertical retrace. If the system supports it, you may + * specify -1 to allow late swaps to happen immediately + * instead of waiting for the next retrace. + * + * \return 0 on success, or -1 if setting the swap interval is not supported. + * + * \sa SDL_GL_GetSwapInterval() + */ +extern DECLSPEC int SDLCALL SDL_GL_SetSwapInterval(int interval); + +/** + * \brief Get the swap interval for the current OpenGL context. + * + * \return 0 if there is no vertical retrace synchronization, 1 if the buffer + * swap is synchronized with the vertical retrace, and -1 if late + * swaps happen immediately instead of waiting for the next retrace. + * If the system can't determine the swap interval, or there isn't a + * valid current context, this will return 0 as a safe default. + * + * \sa SDL_GL_SetSwapInterval() + */ +extern DECLSPEC int SDLCALL SDL_GL_GetSwapInterval(void); + +/** + * \brief Swap the OpenGL buffers for a window, if double-buffering is + * supported. + */ +extern DECLSPEC void SDLCALL SDL_GL_SwapWindow(SDL_Window * window); + +/** + * \brief Delete an OpenGL context. + * + * \sa SDL_GL_CreateContext() + */ +extern DECLSPEC void SDLCALL SDL_GL_DeleteContext(SDL_GLContext context); + +/* @} *//* OpenGL support functions */ + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_video_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/thirdparty/include/SDL2/SDL_vulkan.h b/thirdparty/include/SDL2/SDL_vulkan.h new file mode 100644 index 000000000..d69a436b3 --- /dev/null +++ b/thirdparty/include/SDL2/SDL_vulkan.h @@ -0,0 +1,278 @@ +/* + Simple DirectMedia Layer + Copyright (C) 2017, Mark Callow + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_vulkan.h + * + * Header file for functions to creating Vulkan surfaces on SDL windows. + */ + +#ifndef SDL_vulkan_h_ +#define SDL_vulkan_h_ + +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Avoid including vulkan.h, don't define VkInstance if it's already included */ +#ifdef VULKAN_H_ +#define NO_SDL_VULKAN_TYPEDEFS +#endif +#ifndef NO_SDL_VULKAN_TYPEDEFS +#define VK_DEFINE_HANDLE(object) typedef struct object##_T* object; + +#if defined(__LP64__) || defined(_WIN64) || defined(__x86_64__) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) +#define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef struct object##_T *object; +#else +#define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t object; +#endif + +VK_DEFINE_HANDLE(VkInstance) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSurfaceKHR) + +#endif /* !NO_SDL_VULKAN_TYPEDEFS */ + +typedef VkInstance SDL_vulkanInstance; +typedef VkSurfaceKHR SDL_vulkanSurface; /* for compatibility with Tizen */ + +/** + * \name Vulkan support functions + * + * \note SDL_Vulkan_GetInstanceExtensions & SDL_Vulkan_CreateSurface API + * is compatable with Tizen's implementation of Vulkan in SDL. + */ +/* @{ */ + +/** + * \brief Dynamically load a Vulkan loader library. + * + * \param [in] path The platform dependent Vulkan loader library name, or + * \c NULL. + * + * \return \c 0 on success, or \c -1 if the library couldn't be loaded. + * + * If \a path is NULL SDL will use the value of the environment variable + * \c SDL_VULKAN_LIBRARY, if set, otherwise it loads the default Vulkan + * loader library. + * + * This should be called after initializing the video driver, but before + * creating any Vulkan windows. If no Vulkan loader library is loaded, the + * default library will be loaded upon creation of the first Vulkan window. + * + * \note It is fairly common for Vulkan applications to link with \a libvulkan + * instead of explicitly loading it at run time. This will work with + * SDL provided the application links to a dynamic library and both it + * and SDL use the same search path. + * + * \note If you specify a non-NULL \c path, an application should retrieve all + * of the Vulkan functions it uses from the dynamic library using + * \c SDL_Vulkan_GetVkGetInstanceProcAddr() unless you can guarantee + * \c path points to the same vulkan loader library the application + * linked to. + * + * \note On Apple devices, if \a path is NULL, SDL will attempt to find + * the vkGetInstanceProcAddr address within all the mach-o images of + * the current process. This is because it is fairly common for Vulkan + * applications to link with libvulkan (and historically MoltenVK was + * provided as a static library). If it is not found then, on macOS, SDL + * will attempt to load \c vulkan.framework/vulkan, \c libvulkan.1.dylib, + * followed by \c libvulkan.dylib, in that order. + * On iOS SDL will attempt to load \c libvulkan.dylib only. Applications + * using a dynamic framework or .dylib must ensure it is included in its + * application bundle. + * + * \note On non-Apple devices, application linking with a static libvulkan is + * not supported. Either do not link to the Vulkan loader or link to a + * dynamic library version. + * + * \note This function will fail if there are no working Vulkan drivers + * installed. + * + * \sa SDL_Vulkan_GetVkGetInstanceProcAddr() + * \sa SDL_Vulkan_UnloadLibrary() + */ +extern DECLSPEC int SDLCALL SDL_Vulkan_LoadLibrary(const char *path); + +/** + * \brief Get the address of the \c vkGetInstanceProcAddr function. + * + * \note This should be called after either calling SDL_Vulkan_LoadLibrary + * or creating an SDL_Window with the SDL_WINDOW_VULKAN flag. + */ +extern DECLSPEC void *SDLCALL SDL_Vulkan_GetVkGetInstanceProcAddr(void); + +/** + * \brief Unload the Vulkan loader library previously loaded by + * \c SDL_Vulkan_LoadLibrary(). + * + * \sa SDL_Vulkan_LoadLibrary() + */ +extern DECLSPEC void SDLCALL SDL_Vulkan_UnloadLibrary(void); + +/** + * \brief Get the names of the Vulkan instance extensions needed to create + * a surface with \c SDL_Vulkan_CreateSurface(). + * + * \param [in] \c NULL or window Window for which the required Vulkan instance + * extensions should be retrieved + * \param [in,out] pCount pointer to an \c unsigned related to the number of + * required Vulkan instance extensions + * \param [out] pNames \c NULL or a pointer to an array to be filled with the + * required Vulkan instance extensions + * + * \return \c SDL_TRUE on success, \c SDL_FALSE on error. + * + * If \a pNames is \c NULL, then the number of required Vulkan instance + * extensions is returned in pCount. Otherwise, \a pCount must point to a + * variable set to the number of elements in the \a pNames array, and on + * return the variable is overwritten with the number of names actually + * written to \a pNames. If \a pCount is less than the number of required + * extensions, at most \a pCount structures will be written. If \a pCount + * is smaller than the number of required extensions, \c SDL_FALSE will be + * returned instead of \c SDL_TRUE, to indicate that not all the required + * extensions were returned. + * + * \note If \c window is not NULL, it will be checked against its creation + * flags to ensure that the Vulkan flag is present. This parameter + * will be removed in a future major release. + * + * \note The returned list of extensions will contain \c VK_KHR_surface + * and zero or more platform specific extensions + * + * \note The extension names queried here must be enabled when calling + * VkCreateInstance, otherwise surface creation will fail. + * + * \note \c window should have been created with the \c SDL_WINDOW_VULKAN flag + * or be \c NULL + * + * \code + * unsigned int count; + * // get count of required extensions + * if(!SDL_Vulkan_GetInstanceExtensions(NULL, &count, NULL)) + * handle_error(); + * + * static const char *const additionalExtensions[] = + * { + * VK_EXT_DEBUG_REPORT_EXTENSION_NAME, // example additional extension + * }; + * size_t additionalExtensionsCount = sizeof(additionalExtensions) / sizeof(additionalExtensions[0]); + * size_t extensionCount = count + additionalExtensionsCount; + * const char **names = malloc(sizeof(const char *) * extensionCount); + * if(!names) + * handle_error(); + * + * // get names of required extensions + * if(!SDL_Vulkan_GetInstanceExtensions(NULL, &count, names)) + * handle_error(); + * + * // copy additional extensions after required extensions + * for(size_t i = 0; i < additionalExtensionsCount; i++) + * names[i + count] = additionalExtensions[i]; + * + * VkInstanceCreateInfo instanceCreateInfo = {}; + * instanceCreateInfo.enabledExtensionCount = extensionCount; + * instanceCreateInfo.ppEnabledExtensionNames = names; + * // fill in rest of instanceCreateInfo + * + * VkInstance instance; + * // create the Vulkan instance + * VkResult result = vkCreateInstance(&instanceCreateInfo, NULL, &instance); + * free(names); + * \endcode + * + * \sa SDL_Vulkan_CreateSurface() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_Vulkan_GetInstanceExtensions( + SDL_Window *window, + unsigned int *pCount, + const char **pNames); + +/** + * \brief Create a Vulkan rendering surface for a window. + * + * \param [in] window SDL_Window to which to attach the rendering surface. + * \param [in] instance handle to the Vulkan instance to use. + * \param [out] surface pointer to a VkSurfaceKHR handle to receive the + * handle of the newly created surface. + * + * \return \c SDL_TRUE on success, \c SDL_FALSE on error. + * + * \code + * VkInstance instance; + * SDL_Window *window; + * + * // create instance and window + * + * // create the Vulkan surface + * VkSurfaceKHR surface; + * if(!SDL_Vulkan_CreateSurface(window, instance, &surface)) + * handle_error(); + * \endcode + * + * \note \a window should have been created with the \c SDL_WINDOW_VULKAN flag. + * + * \note \a instance should have been created with the extensions returned + * by \c SDL_Vulkan_CreateSurface() enabled. + * + * \sa SDL_Vulkan_GetInstanceExtensions() + */ +extern DECLSPEC SDL_bool SDLCALL SDL_Vulkan_CreateSurface( + SDL_Window *window, + VkInstance instance, + VkSurfaceKHR* surface); + +/** + * \brief Get the size of a window's underlying drawable in pixels (for use + * with setting viewport, scissor & etc). + * + * \param window SDL_Window from which the drawable size should be queried + * \param w Pointer to variable for storing the width in pixels, + * may be NULL + * \param h Pointer to variable for storing the height in pixels, + * may be NULL + * + * This may differ from SDL_GetWindowSize() if we're rendering to a high-DPI + * drawable, i.e. the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a + * platform with high-DPI support (Apple calls this "Retina"), and not disabled + * by the \c SDL_HINT_VIDEO_HIGHDPI_DISABLED hint. + * + * \note On macOS high-DPI support must be enabled for an application by + * setting NSHighResolutionCapable to true in its Info.plist. + * + * \sa SDL_GetWindowSize() + * \sa SDL_CreateWindow() + */ +extern DECLSPEC void SDLCALL SDL_Vulkan_GetDrawableSize(SDL_Window * window, + int *w, int *h); + +/* @} *//* Vulkan support functions */ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_vulkan_h_ */ diff --git a/thirdparty/include/SDL2/begin_code.h b/thirdparty/include/SDL2/begin_code.h new file mode 100644 index 000000000..170d69ec5 --- /dev/null +++ b/thirdparty/include/SDL2/begin_code.h @@ -0,0 +1,170 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file begin_code.h + * + * This file sets things up for C dynamic library function definitions, + * static inlined functions, and structures aligned at 4-byte alignment. + * If you don't like ugly C preprocessor code, don't look at this file. :) + */ + +/* This shouldn't be nested -- included it around code only. */ +#ifdef _begin_code_h +#error Nested inclusion of begin_code.h +#endif +#define _begin_code_h + +#ifndef SDL_DEPRECATED +# if (__GNUC__ >= 4) /* technically, this arrived in gcc 3.1, but oh well. */ +# define SDL_DEPRECATED __attribute__((deprecated)) +# else +# define SDL_DEPRECATED +# endif +#endif + +#ifndef SDL_UNUSED +# ifdef __GNUC__ +# define SDL_UNUSED __attribute__((unused)) +# else +# define SDL_UNUSED +# endif +#endif + +/* Some compilers use a special export keyword */ +#ifndef DECLSPEC +# if defined(__WIN32__) || defined(__WINRT__) +# ifdef __BORLANDC__ +# ifdef BUILD_SDL +# define DECLSPEC +# else +# define DECLSPEC __declspec(dllimport) +# endif +# else +# define DECLSPEC __declspec(dllexport) +# endif +# elif defined(__OS2__) +# ifdef BUILD_SDL +# define DECLSPEC __declspec(dllexport) +# else +# define DECLSPEC +# endif +# else +# if defined(__GNUC__) && __GNUC__ >= 4 +# define DECLSPEC __attribute__ ((visibility("default"))) +# else +# define DECLSPEC +# endif +# endif +#endif + +/* By default SDL uses the C calling convention */ +#ifndef SDLCALL +#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__) +#define SDLCALL __cdecl +#elif defined(__OS2__) || defined(__EMX__) +#define SDLCALL _System +# if defined (__GNUC__) && !defined(_System) +# define _System /* for old EMX/GCC compat. */ +# endif +#else +#define SDLCALL +#endif +#endif /* SDLCALL */ + +/* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */ +#ifdef __SYMBIAN32__ +#undef DECLSPEC +#define DECLSPEC +#endif /* __SYMBIAN32__ */ + +/* Force structure packing at 4 byte alignment. + This is necessary if the header is included in code which has structure + packing set to an alternate value, say for loading structures from disk. + The packing is reset to the previous value in close_code.h + */ +#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) +#ifdef _MSC_VER +#pragma warning(disable: 4103) +#endif +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wpragma-pack" +#endif +#ifdef __BORLANDC__ +#pragma nopackwarning +#endif +#ifdef _M_X64 +/* Use 8-byte alignment on 64-bit architectures, so pointers are aligned */ +#pragma pack(push,8) +#else +#pragma pack(push,4) +#endif +#endif /* Compiler needs structure packing set */ + +#ifndef SDL_INLINE +#if defined(__GNUC__) +#define SDL_INLINE __inline__ +#elif defined(_MSC_VER) || defined(__BORLANDC__) || \ + defined(__DMC__) || defined(__SC__) || \ + defined(__WATCOMC__) || defined(__LCC__) || \ + defined(__DECC) || defined(__CC_ARM) +#define SDL_INLINE __inline +#ifndef __inline__ +#define __inline__ __inline +#endif +#else +#define SDL_INLINE inline +#ifndef __inline__ +#define __inline__ inline +#endif +#endif +#endif /* SDL_INLINE not defined */ + +#ifndef SDL_FORCE_INLINE +#if defined(_MSC_VER) +#define SDL_FORCE_INLINE __forceinline +#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) ) +#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__ +#else +#define SDL_FORCE_INLINE static SDL_INLINE +#endif +#endif /* SDL_FORCE_INLINE not defined */ + +#ifndef SDL_NORETURN +#if defined(__GNUC__) +#define SDL_NORETURN __attribute__((noreturn)) +#elif defined(_MSC_VER) +#define SDL_NORETURN __declspec(noreturn) +#else +#define SDL_NORETURN +#endif +#endif /* SDL_NORETURN not defined */ + +/* Apparently this is needed by several Windows compilers */ +#if !defined(__MACH__) +#ifndef NULL +#ifdef __cplusplus +#define NULL 0 +#else +#define NULL ((void *)0) +#endif +#endif /* NULL */ +#endif /* ! Mac OS X - breaks precompiled headers */ diff --git a/thirdparty/include/SDL2/close_code.h b/thirdparty/include/SDL2/close_code.h new file mode 100644 index 000000000..6aa411b0d --- /dev/null +++ b/thirdparty/include/SDL2/close_code.h @@ -0,0 +1,40 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file close_code.h + * + * This file reverses the effects of begin_code.h and should be included + * after you finish any function and structure declarations in your headers + */ + +#ifndef _begin_code_h +#error close_code.h included without matching begin_code.h +#endif +#undef _begin_code_h + +/* Reset structure packing at previous byte alignment */ +#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) +#ifdef __BORLANDC__ +#pragma nopackwarning +#endif +#pragma pack(pop) +#endif /* Compiler needs structure packing set */ From 65ee3c5c2af660d553b12380b36834f538155a82 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 27 May 2020 17:48:51 +0200 Subject: [PATCH 214/316] Upgrade docker debian --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9a920d6b2..0b9ee6567 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:stretch +FROM debian:buster RUN apt-get update && apt-get install -y build-essential clang libopenal-dev libsndfile1-dev libfreetype6-dev libassimp-dev libsdl2-dev From 2d189dc85e97aaabdba12906f5f18f3c602e09be Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 27 May 2020 18:55:03 +0200 Subject: [PATCH 215/316] Fix WindowHandles --- include/Nazara/Platform/Window.hpp | 12 +++- include/Nazara/Platform/Window.inl | 12 +++- include/Nazara/Platform/WindowHandle.hpp | 37 +++++++++++- include/Nazara/Prerequisites.hpp | 2 - include/Nazara/Renderer/ContextParameters.hpp | 4 +- include/Nazara/Renderer/RenderWindow.hpp | 4 +- src/Nazara/Platform/SDL2/InputImpl.cpp | 20 ++----- src/Nazara/Platform/SDL2/WindowImpl.cpp | 59 +++++++++++++++++-- src/Nazara/Platform/SDL2/WindowImpl.hpp | 5 +- src/Nazara/Platform/Window.cpp | 33 ++++++----- src/Nazara/Renderer/RenderWindow.cpp | 4 +- 11 files changed, 143 insertions(+), 49 deletions(-) diff --git a/include/Nazara/Platform/Window.hpp b/include/Nazara/Platform/Window.hpp index 47d416930..eabe8e942 100644 --- a/include/Nazara/Platform/Window.hpp +++ b/include/Nazara/Platform/Window.hpp @@ -32,13 +32,14 @@ namespace Nz class NAZARA_PLATFORM_API Window { friend WindowImpl; + friend class EventImpl; friend class Mouse; friend class Platform; public: Window(); inline Window(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default); - inline explicit Window(WindowHandle handle); + inline explicit Window(void* handle); Window(const Window&) = delete; Window(Window&& window); virtual ~Window(); @@ -46,7 +47,7 @@ namespace Nz inline void Close(); bool Create(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default); - bool Create(WindowHandle handle); + bool Create(void* handle); void Destroy(); @@ -61,10 +62,10 @@ namespace Nz inline const CursorRef& GetCursor() const; inline CursorController& GetCursorController(); inline EventHandler& GetEventHandler(); - WindowHandle GetHandle() const; Vector2i GetPosition() const; Vector2ui GetSize() const; WindowStyleFlags GetStyle() const; + WindowHandle GetSystemHandle() const; String GetTitle() const; bool HasFocus() const; @@ -106,6 +107,8 @@ namespace Nz Window& operator=(Window&& window); protected: + void* GetHandle(); + virtual bool OnWindowCreated(); virtual void OnWindowDestroy(); virtual void OnWindowResized(); @@ -116,6 +119,9 @@ namespace Nz void ConnectSlots(); void DisconnectSlots(); + inline WindowImpl* GetImpl(); + inline const WindowImpl* GetImpl() const; + void IgnoreNextMouseEvent(int mouseX, int mouseY) const; void HandleEvent(const WindowEvent& event); diff --git a/include/Nazara/Platform/Window.inl b/include/Nazara/Platform/Window.inl index 1be1a773f..89bb7e76d 100644 --- a/include/Nazara/Platform/Window.inl +++ b/include/Nazara/Platform/Window.inl @@ -20,7 +20,7 @@ namespace Nz Create(mode, title, style); } - inline Window::Window(WindowHandle handle) : + inline Window::Window(void* handle) : Window() { ErrorFlags flags(ErrorFlag_ThrowException, true); @@ -111,6 +111,16 @@ namespace Nz } } } + + inline WindowImpl* Window::GetImpl() + { + return m_impl; + } + + inline const WindowImpl* Window::GetImpl() const + { + return m_impl; + } } #include diff --git a/include/Nazara/Platform/WindowHandle.hpp b/include/Nazara/Platform/WindowHandle.hpp index de6e43304..c6053f4bf 100644 --- a/include/Nazara/Platform/WindowHandle.hpp +++ b/include/Nazara/Platform/WindowHandle.hpp @@ -8,11 +8,44 @@ #define NAZARA_WINDOWHANDLE_HPP #include +#include namespace Nz { - // Real type is SDL_Window - using WindowHandle = void*; + enum class WindowManager + { + None, + + X11, + Wayland, + Windows + }; + + struct WindowHandle + { + WindowManager type = WindowManager::None; + + union + { + struct + { + void* display; //< Display* + void* window; //< Window + } x11; + + struct + { + void* display; //< wl_display* + void* surface; //< wl_surface* + void* shellSurface; //< wl_shell_surface* + } wayland; + + struct + { + void* window; //< HWND + } windows; + }; + }; } #endif // NAZARA_WINDOWHANDLE_HPP diff --git a/include/Nazara/Prerequisites.hpp b/include/Nazara/Prerequisites.hpp index 0f4611766..24bc14dc1 100644 --- a/include/Nazara/Prerequisites.hpp +++ b/include/Nazara/Prerequisites.hpp @@ -122,14 +122,12 @@ #define NAZARA_EXPORT __attribute__((visibility ("default"))) #define NAZARA_IMPORT __attribute__((visibility ("default"))) /*#elif defined(__APPLE__) && defined(__MACH__) - #define NAZARA_CORE_API #define NAZARA_PLATFORM_MACOSX #define NAZARA_PLATFORM_POSIX*/ #else #error This operating system is not fully supported by the Nazara Engine #define NAZARA_PLATFORM_UNKNOWN - #define NAZARA_CORE_API #endif // Detect 64 bits diff --git a/include/Nazara/Renderer/ContextParameters.hpp b/include/Nazara/Renderer/ContextParameters.hpp index 830a1bdcf..8c939bb79 100644 --- a/include/Nazara/Renderer/ContextParameters.hpp +++ b/include/Nazara/Renderer/ContextParameters.hpp @@ -26,7 +26,7 @@ namespace Nz minorVersion(defaultMinorVersion), stencilBits(parameters.stencilBits), shareContext(defaultShareContext), - window(0), + window(nullptr), compatibilityProfile(defaultCompatibilityProfile), debugMode(defaultDebugMode), doubleBuffered(defaultDoubleBuffered), @@ -41,7 +41,7 @@ namespace Nz UInt8 minorVersion; UInt8 stencilBits; const Context* shareContext; - WindowHandle window; + void* window; bool compatibilityProfile; bool debugMode; bool doubleBuffered; diff --git a/include/Nazara/Renderer/RenderWindow.hpp b/include/Nazara/Renderer/RenderWindow.hpp index f5138f4e3..1555effa4 100644 --- a/include/Nazara/Renderer/RenderWindow.hpp +++ b/include/Nazara/Renderer/RenderWindow.hpp @@ -29,7 +29,7 @@ namespace Nz public: RenderWindow() = default; RenderWindow(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default, const ContextParameters& parameters = ContextParameters()); - explicit RenderWindow(WindowHandle handle, const ContextParameters& parameters = ContextParameters()); + explicit RenderWindow(void* handle, const ContextParameters& parameters = ContextParameters()); RenderWindow(const RenderWindow&) = delete; RenderWindow(RenderWindow&&) = delete; ///TODO virtual ~RenderWindow(); @@ -38,7 +38,7 @@ namespace Nz bool CopyToImage(AbstractImage* image, const Rectui& rect, const Vector3ui& dstPos = Vector3ui(0U)) const; bool Create(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default, const ContextParameters& parameters = ContextParameters()); - bool Create(WindowHandle handle, const ContextParameters& parameters = ContextParameters()); + bool Create(void* handle, const ContextParameters& parameters = ContextParameters()); void Display(); diff --git a/src/Nazara/Platform/SDL2/InputImpl.cpp b/src/Nazara/Platform/SDL2/InputImpl.cpp index 6363fbd54..1b609e71c 100644 --- a/src/Nazara/Platform/SDL2/InputImpl.cpp +++ b/src/Nazara/Platform/SDL2/InputImpl.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -45,21 +46,10 @@ namespace Nz Vector2i EventImpl::GetMousePosition(const Window& relativeTo) { - auto handle = relativeTo.GetHandle(); - if (handle) - { - auto windowPos = relativeTo.GetPosition(); - auto mousePos = GetMousePosition(); + auto windowPos = relativeTo.GetPosition(); + auto mousePos = GetMousePosition(); - return mousePos - windowPos; - } - else - { - NazaraError("Invalid window handle"); - - // Attention que (-1, -1) est une position tout à fait valide et ne doit pas servir de test - return Vector2i(-1, -1); - } + return mousePos - windowPos; } bool EventImpl::IsKeyPressed(Keyboard::Scancode key) @@ -98,7 +88,7 @@ namespace Nz void EventImpl::SetMousePosition(int x, int y, const Window& relativeTo) { - auto handle = static_cast(relativeTo.GetHandle()); + SDL_Window* handle = static_cast(relativeTo.GetImpl())->GetHandle(); if (handle) SDL_WarpMouseInWindow(handle, x, y); else diff --git a/src/Nazara/Platform/SDL2/WindowImpl.cpp b/src/Nazara/Platform/SDL2/WindowImpl.cpp index 2db2b55be..a87155be2 100644 --- a/src/Nazara/Platform/SDL2/WindowImpl.cpp +++ b/src/Nazara/Platform/SDL2/WindowImpl.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -17,6 +18,7 @@ #include #include #include +#include namespace Nz { @@ -124,10 +126,9 @@ namespace Nz return true; } - bool WindowImpl::Create(WindowHandle handle) + bool WindowImpl::Create(void* handle) { - m_handle = static_cast(handle); - + m_handle = SDL_CreateWindowFrom(handle); if (!m_handle || !SDL_GetWindowID(m_handle)) { NazaraError("Invalid handle"); @@ -171,7 +172,7 @@ namespace Nz m_smoothScrolling = enable; } - WindowHandle WindowImpl::GetHandle() const + SDL_Window* WindowImpl::GetHandle() const { return m_handle; } @@ -190,6 +191,56 @@ namespace Nz { return m_style; } + + WindowHandle WindowImpl::GetSystemHandle() const + { + SDL_SysWMinfo wmInfo; + if (SDL_GetWindowWMInfo(m_handle, &wmInfo) != SDL_TRUE) + { + ErrorFlags flags(ErrorFlag_ThrowException, true); + NazaraError(std::string("failed to retrieve window manager info: ") + SDL_GetError()); + } + + WindowHandle handle; + + switch (wmInfo.subsystem) + { +#if defined(SDL_VIDEO_DRIVER_X11) + case SDL_SYSWM_X11: + { + handle.type = WindowManager::X11; + handle.x11.display = wmInfo.info.x11.display; + handle.x11.window = wmInfo.info.x11.window; + break; + } +#endif +#if defined(SDL_VIDEO_DRIVER_WAYLAND) + case SDL_SYSWM_WAYLAND: + { + handle.type = WindowManager::Wayland; + handle.wayland.display = wmInfo.info.wl.display; + handle.wayland.surface = wmInfo.info.wl.surface; + handle.wayland.shellSurface = wmInfo.info.wl.shell_surface; + break; + } +#endif +#if defined(SDL_VIDEO_DRIVER_WINDOWS) + case SDL_SYSWM_WINDOWS: + { + handle.type = WindowManager::Windows; + handle.windows.window = wmInfo.info.win.window; + break; + } +#endif + default: + { + ErrorFlags flags(ErrorFlag_ThrowException, true); + NazaraError("unhandled window subsystem"); + } + } + + return handle; + } String WindowImpl::GetTitle() const { diff --git a/src/Nazara/Platform/SDL2/WindowImpl.hpp b/src/Nazara/Platform/SDL2/WindowImpl.hpp index 8d960eaff..9acad3951 100644 --- a/src/Nazara/Platform/SDL2/WindowImpl.hpp +++ b/src/Nazara/Platform/SDL2/WindowImpl.hpp @@ -38,17 +38,18 @@ namespace Nz ~WindowImpl() = default; bool Create(const VideoMode& mode, const String& title, WindowStyleFlags style); - bool Create(WindowHandle handle); + bool Create(void* handle); void Destroy(); void EnableKeyRepeat(bool enable); void EnableSmoothScrolling(bool enable); - WindowHandle GetHandle() const; + SDL_Window* GetHandle() const; Vector2i GetPosition() const; Vector2ui GetSize() const; WindowStyleFlags GetStyle() const; + WindowHandle GetSystemHandle() const; String GetTitle() const; bool HasFocus() const; diff --git a/src/Nazara/Platform/Window.cpp b/src/Nazara/Platform/Window.cpp index cfdba8cd1..3dd044593 100644 --- a/src/Nazara/Platform/Window.cpp +++ b/src/Nazara/Platform/Window.cpp @@ -124,7 +124,7 @@ namespace Nz return true; } - bool Window::Create(WindowHandle handle) + bool Window::Create(void* handle) { Destroy(); @@ -197,19 +197,6 @@ namespace Nz m_impl->EnableSmoothScrolling(enable); } - WindowHandle Window::GetHandle() const - { - #if NAZARA_PLATFORM_SAFE - if (!m_impl) - { - NazaraError("Window not created"); - return static_cast(0); - } - #endif - - return m_impl->GetHandle(); - } - Vector2i Window::GetPosition() const { #if NAZARA_PLATFORM_SAFE @@ -249,6 +236,19 @@ namespace Nz return m_impl->GetStyle(); } + WindowHandle Window::GetSystemHandle() const + { +#if NAZARA_PLATFORM_SAFE + if (!m_impl) + { + NazaraError("Window not created"); + return {}; + } +#endif + + return m_impl->GetSystemHandle(); + } + String Window::GetTitle() const { #if NAZARA_PLATFORM_SAFE @@ -613,6 +613,11 @@ namespace Nz return *this; } + void* Window::GetHandle() + { + return (m_impl) ? m_impl->GetHandle() : nullptr; + } + bool Window::OnWindowCreated() { return true; diff --git a/src/Nazara/Renderer/RenderWindow.cpp b/src/Nazara/Renderer/RenderWindow.cpp index b1ade1d95..36e364508 100644 --- a/src/Nazara/Renderer/RenderWindow.cpp +++ b/src/Nazara/Renderer/RenderWindow.cpp @@ -20,7 +20,7 @@ namespace Nz Create(mode, title, style, parameters); } - RenderWindow::RenderWindow(WindowHandle handle, const ContextParameters& parameters) : + RenderWindow::RenderWindow(void* handle, const ContextParameters& parameters) : RenderTarget(), Window() { ErrorFlags flags(ErrorFlag_ThrowException, true); @@ -125,7 +125,7 @@ namespace Nz return Window::Create(mode, title, style); } - bool RenderWindow::Create(WindowHandle handle, const ContextParameters& parameters) + bool RenderWindow::Create(void* handle, const ContextParameters& parameters) { m_parameters = parameters; return Window::Create(handle); From 81f03f04e5f56b702d2dee1922943920b4effe1d Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 27 May 2020 19:42:53 +0200 Subject: [PATCH 216/316] Revert Renderer to its pre-SDL state --- build/scripts/modules/renderer.lua | 26 +- include/Nazara/Renderer/ContextParameters.hpp | 3 +- include/Nazara/Renderer/OpenGL.hpp | 418 ++++++++------- src/Nazara/Platform/SDL2/WindowImpl.cpp | 49 +- src/Nazara/Renderer/Context.cpp | 9 +- src/Nazara/Renderer/GLX/ContextImpl.cpp | 302 +++++++++++ src/Nazara/Renderer/GLX/ContextImpl.hpp | 42 ++ src/Nazara/Renderer/OpenGL.cpp | 488 ++++++++++-------- src/Nazara/Renderer/RenderWindow.cpp | 2 +- src/Nazara/Renderer/SDL2/ContextImpl.cpp | 147 ------ src/Nazara/Renderer/Win32/ContextImpl.cpp | 248 +++++++++ .../Renderer/{SDL2 => Win32}/ContextImpl.hpp | 9 +- 12 files changed, 1148 insertions(+), 595 deletions(-) create mode 100644 src/Nazara/Renderer/GLX/ContextImpl.cpp create mode 100644 src/Nazara/Renderer/GLX/ContextImpl.hpp delete mode 100644 src/Nazara/Renderer/SDL2/ContextImpl.cpp create mode 100644 src/Nazara/Renderer/Win32/ContextImpl.cpp rename src/Nazara/Renderer/{SDL2 => Win32}/ContextImpl.hpp (85%) diff --git a/build/scripts/modules/renderer.lua b/build/scripts/modules/renderer.lua index 914e587fc..df10e2910 100644 --- a/build/scripts/modules/renderer.lua +++ b/build/scripts/modules/renderer.lua @@ -9,11 +9,27 @@ MODULE.Defines = { MODULE.Libraries = { "NazaraCore", "NazaraUtility", - "NazaraPlatform", - "SDL2" + "NazaraPlatform" } -MODULE.Files = { - "../src/Nazara/Renderer/SDL2/**.hpp", - "../src/Nazara/Renderer/SDL2/**.cpp" +MODULE.OsFiles.Windows = { + "../src/Nazara/Renderer/Win32/**.hpp", + "../src/Nazara/Renderer/Win32/**.cpp" } + +MODULE.OsFiles.Posix = { + "../src/Nazara/Renderer/GLX/**.hpp", + "../src/Nazara/Renderer/GLX/**.cpp" +} + +MODULE.OsLibraries.Windows = { + "gdi32", + "opengl32", + "winmm" +} + +MODULE.OsLibraries.Posix = { + "GL", + "X11" +} + diff --git a/include/Nazara/Renderer/ContextParameters.hpp b/include/Nazara/Renderer/ContextParameters.hpp index 8c939bb79..b55c48761 100644 --- a/include/Nazara/Renderer/ContextParameters.hpp +++ b/include/Nazara/Renderer/ContextParameters.hpp @@ -26,7 +26,6 @@ namespace Nz minorVersion(defaultMinorVersion), stencilBits(parameters.stencilBits), shareContext(defaultShareContext), - window(nullptr), compatibilityProfile(defaultCompatibilityProfile), debugMode(defaultDebugMode), doubleBuffered(defaultDoubleBuffered), @@ -41,7 +40,7 @@ namespace Nz UInt8 minorVersion; UInt8 stencilBits; const Context* shareContext; - void* window; + WindowHandle window; bool compatibilityProfile; bool debugMode; bool doubleBuffered; diff --git a/include/Nazara/Renderer/OpenGL.hpp b/include/Nazara/Renderer/OpenGL.hpp index 52c043e32..77fe10ad3 100644 --- a/include/Nazara/Renderer/OpenGL.hpp +++ b/include/Nazara/Renderer/OpenGL.hpp @@ -6,11 +6,12 @@ #ifndef NAZARA_OPENGL_HPP #define NAZARA_OPENGL_HPP + #ifdef NAZARA_RENDERER_OPENGL +#include #include #include -#include #include #include #include @@ -20,6 +21,16 @@ #include #include +#if defined(NAZARA_PLATFORM_WINDOWS) + #include +#elif defined(NAZARA_PLATFORM_GLX) +namespace GLX +{ + #include // Defined in a namespace to avoid conflict +} + #include +#endif + namespace Nz { enum OpenGLExtension @@ -118,211 +129,222 @@ namespace Nz static void Uninitialize(); - static GLenum Attachment[AttachmentPoint_Max + 1]; - static GLenum BlendFunc[BlendFunc_Max + 1]; - static GLenum BufferLock[BufferAccess_Max + 1]; - static GLenum BufferLockRange[BufferAccess_Max + 1]; - static GLenum BufferTarget[BufferType_Max + 1]; - static GLenum BufferTargetBinding[BufferType_Max + 1]; - static GLenum ComponentType[ComponentType_Max + 1]; + static GLenum Attachment[AttachmentPoint_Max+1]; + static GLenum BlendFunc[BlendFunc_Max+1]; + static GLenum BufferLock[BufferAccess_Max+1]; + static GLenum BufferLockRange[BufferAccess_Max+1]; + static GLenum BufferTarget[BufferType_Max+1]; + static GLenum BufferTargetBinding[BufferType_Max+1]; + static GLenum ComponentType[ComponentType_Max+1]; static GLenum CubemapFace[6]; // Un cube possède six faces et ça n'est pas près de changer - static GLenum FaceFilling[FaceFilling_Max + 1]; - static GLenum FaceSide[FaceSide_Max + 1]; - static GLenum PrimitiveMode[PrimitiveMode_Max + 1]; - static GLenum QueryCondition[GpuQueryCondition_Max + 1]; - static GLenum QueryMode[GpuQueryMode_Max + 1]; - static GLenum RendererComparison[RendererComparison_Max + 1]; - static GLenum RendererParameter[RendererParameter_Max + 1]; - static GLenum SamplerWrapMode[SamplerWrap_Max + 1]; - static GLenum ShaderStage[ShaderStageType_Max + 1]; - static GLenum StencilOperation[StencilOperation_Max + 1]; - static GLenum TextureTarget[ImageType_Max + 1]; - static GLenum TextureTargetBinding[ImageType_Max + 1]; - static GLenum TextureTargetProxy[ImageType_Max + 1]; - static UInt8 VertexComponentIndex[VertexComponent_Max + 1]; + static GLenum FaceFilling[FaceFilling_Max+1]; + static GLenum FaceSide[FaceSide_Max+1]; + static GLenum PrimitiveMode[PrimitiveMode_Max+1]; + static GLenum QueryCondition[GpuQueryCondition_Max+1]; + static GLenum QueryMode[GpuQueryMode_Max+1]; + static GLenum RendererComparison[RendererComparison_Max+1]; + static GLenum RendererParameter[RendererParameter_Max+1]; + static GLenum SamplerWrapMode[SamplerWrap_Max+1]; + static GLenum ShaderStage[ShaderStageType_Max+1]; + static GLenum StencilOperation[StencilOperation_Max+1]; + static GLenum TextureTarget[ImageType_Max+1]; + static GLenum TextureTargetBinding[ImageType_Max+1]; + static GLenum TextureTargetProxy[ImageType_Max+1]; + static UInt8 VertexComponentIndex[VertexComponent_Max+1]; private: static void OnContextChanged(const Context* newContext); static void OnContextDestruction(const Context* context); }; - NAZARA_RENDERER_API extern PFNGLACTIVETEXTUREPROC glActiveTexture; - NAZARA_RENDERER_API extern PFNGLATTACHSHADERPROC glAttachShader; - NAZARA_RENDERER_API extern PFNGLBEGINCONDITIONALRENDERPROC glBeginConditionalRender; - NAZARA_RENDERER_API extern PFNGLBEGINQUERYPROC glBeginQuery; - NAZARA_RENDERER_API extern PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation; - NAZARA_RENDERER_API extern PFNGLBINDBUFFERPROC glBindBuffer; - NAZARA_RENDERER_API extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer; - NAZARA_RENDERER_API extern PFNGLBINDFRAGDATALOCATIONPROC glBindFragDataLocation; - NAZARA_RENDERER_API extern PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer; - NAZARA_RENDERER_API extern PFNGLBINDSAMPLERPROC glBindSampler; - NAZARA_RENDERER_API extern PFNGLBINDTEXTUREPROC glBindTexture; - NAZARA_RENDERER_API extern PFNGLBINDVERTEXARRAYPROC glBindVertexArray; - NAZARA_RENDERER_API extern PFNGLBLENDFUNCPROC glBlendFunc; - NAZARA_RENDERER_API extern PFNGLBLENDFUNCSEPARATEPROC glBlendFuncSeparate; - NAZARA_RENDERER_API extern PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer; - NAZARA_RENDERER_API extern PFNGLBUFFERDATAPROC glBufferData; - NAZARA_RENDERER_API extern PFNGLBUFFERSUBDATAPROC glBufferSubData; - NAZARA_RENDERER_API extern PFNGLCLEARPROC glClear; - NAZARA_RENDERER_API extern PFNGLCLEARCOLORPROC glClearColor; - NAZARA_RENDERER_API extern PFNGLCLEARDEPTHPROC glClearDepth; - NAZARA_RENDERER_API extern PFNGLCLEARSTENCILPROC glClearStencil; - NAZARA_RENDERER_API extern PFNGLCREATEPROGRAMPROC glCreateProgram; - NAZARA_RENDERER_API extern PFNGLCREATESHADERPROC glCreateShader; - NAZARA_RENDERER_API extern PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus; - NAZARA_RENDERER_API extern PFNGLCOLORMASKPROC glColorMask; - NAZARA_RENDERER_API extern PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glCompressedTexSubImage1D; - NAZARA_RENDERER_API extern PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glCompressedTexSubImage2D; - NAZARA_RENDERER_API extern PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glCompressedTexSubImage3D; - NAZARA_RENDERER_API extern PFNGLCULLFACEPROC glCullFace; - NAZARA_RENDERER_API extern PFNGLCOMPILESHADERPROC glCompileShader; - NAZARA_RENDERER_API extern PFNGLCOPYTEXSUBIMAGE2DPROC glCopyTexSubImage2D; - NAZARA_RENDERER_API extern PFNGLDEBUGMESSAGECALLBACKPROC glDebugMessageCallback; - NAZARA_RENDERER_API extern PFNGLDEBUGMESSAGECONTROLPROC glDebugMessageControl; - NAZARA_RENDERER_API extern PFNGLDEBUGMESSAGEINSERTPROC glDebugMessageInsert; - NAZARA_RENDERER_API extern PFNGLDELETEBUFFERSPROC glDeleteBuffers; - NAZARA_RENDERER_API extern PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers; - NAZARA_RENDERER_API extern PFNGLDELETEPROGRAMPROC glDeleteProgram; - NAZARA_RENDERER_API extern PFNGLDELETEQUERIESPROC glDeleteQueries; - NAZARA_RENDERER_API extern PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers; - NAZARA_RENDERER_API extern PFNGLDELETESAMPLERSPROC glDeleteSamplers; - NAZARA_RENDERER_API extern PFNGLDELETESHADERPROC glDeleteShader; - NAZARA_RENDERER_API extern PFNGLDELETETEXTURESPROC glDeleteTextures; - NAZARA_RENDERER_API extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays; - NAZARA_RENDERER_API extern PFNGLDEPTHFUNCPROC glDepthFunc; - NAZARA_RENDERER_API extern PFNGLDEPTHMASKPROC glDepthMask; - NAZARA_RENDERER_API extern PFNGLDISABLEPROC glDisable; - NAZARA_RENDERER_API extern PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray; - NAZARA_RENDERER_API extern PFNGLDRAWARRAYSPROC glDrawArrays; - NAZARA_RENDERER_API extern PFNGLDRAWARRAYSINSTANCEDPROC glDrawArraysInstanced; - NAZARA_RENDERER_API extern PFNGLDRAWBUFFERPROC glDrawBuffer; - NAZARA_RENDERER_API extern PFNGLDRAWBUFFERSPROC glDrawBuffers; - NAZARA_RENDERER_API extern PFNGLDRAWELEMENTSPROC glDrawElements; - NAZARA_RENDERER_API extern PFNGLDRAWELEMENTSINSTANCEDPROC glDrawElementsInstanced; - NAZARA_RENDERER_API extern PFNGLDRAWTEXTURENVPROC glDrawTexture; - NAZARA_RENDERER_API extern PFNGLENABLEPROC glEnable; - NAZARA_RENDERER_API extern PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray; - NAZARA_RENDERER_API extern PFNGLENDCONDITIONALRENDERPROC glEndConditionalRender; - NAZARA_RENDERER_API extern PFNGLENDQUERYPROC glEndQuery; - NAZARA_RENDERER_API extern PFNGLFLUSHPROC glFlush; - NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer; - NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERTEXTUREPROC glFramebufferTexture; - NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D; - NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D; - NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D; - NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer; - NAZARA_RENDERER_API extern PFNGLGENERATEMIPMAPPROC glGenerateMipmap; - NAZARA_RENDERER_API extern PFNGLGENBUFFERSPROC glGenBuffers; - NAZARA_RENDERER_API extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers; - NAZARA_RENDERER_API extern PFNGLGENQUERIESPROC glGenQueries; - NAZARA_RENDERER_API extern PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers; - NAZARA_RENDERER_API extern PFNGLGENSAMPLERSPROC glGenSamplers; - NAZARA_RENDERER_API extern PFNGLGENTEXTURESPROC glGenTextures; - NAZARA_RENDERER_API extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays; - NAZARA_RENDERER_API extern PFNGLGETACTIVEUNIFORMPROC glGetActiveUniform; - NAZARA_RENDERER_API extern PFNGLGETBOOLEANVPROC glGetBooleanv; - NAZARA_RENDERER_API extern PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv; - NAZARA_RENDERER_API extern PFNGLGETDEBUGMESSAGELOGPROC glGetDebugMessageLog; - NAZARA_RENDERER_API extern PFNGLGETERRORPROC glGetError; - NAZARA_RENDERER_API extern PFNGLGETFLOATVPROC glGetFloatv; - NAZARA_RENDERER_API extern PFNGLGETINTEGERVPROC glGetIntegerv; - NAZARA_RENDERER_API extern PFNGLGETPROGRAMBINARYPROC glGetProgramBinary; - NAZARA_RENDERER_API extern PFNGLGETPROGRAMIVPROC glGetProgramiv; - NAZARA_RENDERER_API extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog; - NAZARA_RENDERER_API extern PFNGLGETQUERYIVPROC glGetQueryiv; - NAZARA_RENDERER_API extern PFNGLGETQUERYOBJECTIVPROC glGetQueryObjectiv; - NAZARA_RENDERER_API extern PFNGLGETQUERYOBJECTUIVPROC glGetQueryObjectuiv; - NAZARA_RENDERER_API extern PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog; - NAZARA_RENDERER_API extern PFNGLGETSHADERIVPROC glGetShaderiv; - NAZARA_RENDERER_API extern PFNGLGETSHADERSOURCEPROC glGetShaderSource; - NAZARA_RENDERER_API extern PFNGLGETSTRINGPROC glGetString; - NAZARA_RENDERER_API extern PFNGLGETSTRINGIPROC glGetStringi; - NAZARA_RENDERER_API extern PFNGLGETTEXIMAGEPROC glGetTexImage; - NAZARA_RENDERER_API extern PFNGLGETTEXLEVELPARAMETERFVPROC glGetTexLevelParameterfv; - NAZARA_RENDERER_API extern PFNGLGETTEXLEVELPARAMETERIVPROC glGetTexLevelParameteriv; - NAZARA_RENDERER_API extern PFNGLGETTEXPARAMETERFVPROC glGetTexParameterfv; - NAZARA_RENDERER_API extern PFNGLGETTEXPARAMETERIVPROC glGetTexParameteriv; - NAZARA_RENDERER_API extern PFNGLGETUNIFORMFVPROC glGetUniformfv; - NAZARA_RENDERER_API extern PFNGLGETUNIFORMIVPROC glGetUniformiv; - NAZARA_RENDERER_API extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation; - NAZARA_RENDERER_API extern PFNGLINVALIDATEBUFFERDATAPROC glInvalidateBufferData; - NAZARA_RENDERER_API extern PFNGLISENABLEDPROC glIsEnabled; - NAZARA_RENDERER_API extern PFNGLLINEWIDTHPROC glLineWidth; - NAZARA_RENDERER_API extern PFNGLLINKPROGRAMPROC glLinkProgram; - NAZARA_RENDERER_API extern PFNGLMAPBUFFERPROC glMapBuffer; - NAZARA_RENDERER_API extern PFNGLMAPBUFFERRANGEPROC glMapBufferRange; - NAZARA_RENDERER_API extern PFNGLPIXELSTOREIPROC glPixelStorei; - NAZARA_RENDERER_API extern PFNGLPOINTSIZEPROC glPointSize; - NAZARA_RENDERER_API extern PFNGLPOLYGONMODEPROC glPolygonMode; - NAZARA_RENDERER_API extern PFNGLPROGRAMBINARYPROC glProgramBinary; - NAZARA_RENDERER_API extern PFNGLPROGRAMPARAMETERIPROC glProgramParameteri; - NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1DPROC glProgramUniform1d; - NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1FPROC glProgramUniform1f; - NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1IPROC glProgramUniform1i; - NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1DVPROC glProgramUniform1dv; - NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1FVPROC glProgramUniform1fv; - NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1IVPROC glProgramUniform1iv; - NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM2DVPROC glProgramUniform2dv; - NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM2FVPROC glProgramUniform2fv; - NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM2IVPROC glProgramUniform2iv; - NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM3DVPROC glProgramUniform3dv; - NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM3FVPROC glProgramUniform3fv; - NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM3IVPROC glProgramUniform3iv; - NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM4DVPROC glProgramUniform4dv; - NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM4FVPROC glProgramUniform4fv; - NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM4IVPROC glProgramUniform4iv; - NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORMMATRIX4DVPROC glProgramUniformMatrix4dv; - NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORMMATRIX4FVPROC glProgramUniformMatrix4fv; - NAZARA_RENDERER_API extern PFNGLREADPIXELSPROC glReadPixels; - NAZARA_RENDERER_API extern PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage; - NAZARA_RENDERER_API extern PFNGLSAMPLERPARAMETERFPROC glSamplerParameterf; - NAZARA_RENDERER_API extern PFNGLSAMPLERPARAMETERIPROC glSamplerParameteri; - NAZARA_RENDERER_API extern PFNGLSCISSORPROC glScissor; - NAZARA_RENDERER_API extern PFNGLSHADERSOURCEPROC glShaderSource; - NAZARA_RENDERER_API extern PFNGLSTENCILFUNCPROC glStencilFunc; - NAZARA_RENDERER_API extern PFNGLSTENCILFUNCSEPARATEPROC glStencilFuncSeparate; - NAZARA_RENDERER_API extern PFNGLSTENCILOPPROC glStencilOp; - NAZARA_RENDERER_API extern PFNGLSTENCILOPSEPARATEPROC glStencilOpSeparate; - NAZARA_RENDERER_API extern PFNGLTEXIMAGE1DPROC glTexImage1D; - NAZARA_RENDERER_API extern PFNGLTEXIMAGE2DPROC glTexImage2D; - NAZARA_RENDERER_API extern PFNGLTEXIMAGE3DPROC glTexImage3D; - NAZARA_RENDERER_API extern PFNGLTEXPARAMETERFPROC glTexParameterf; - NAZARA_RENDERER_API extern PFNGLTEXPARAMETERIPROC glTexParameteri; - NAZARA_RENDERER_API extern PFNGLTEXSTORAGE1DPROC glTexStorage1D; - NAZARA_RENDERER_API extern PFNGLTEXSTORAGE2DPROC glTexStorage2D; - NAZARA_RENDERER_API extern PFNGLTEXSTORAGE3DPROC glTexStorage3D; - NAZARA_RENDERER_API extern PFNGLTEXSUBIMAGE1DPROC glTexSubImage1D; - NAZARA_RENDERER_API extern PFNGLTEXSUBIMAGE2DPROC glTexSubImage2D; - NAZARA_RENDERER_API extern PFNGLTEXSUBIMAGE3DPROC glTexSubImage3D; - NAZARA_RENDERER_API extern PFNGLUNIFORM1DPROC glUniform1d; - NAZARA_RENDERER_API extern PFNGLUNIFORM1FPROC glUniform1f; - NAZARA_RENDERER_API extern PFNGLUNIFORM1IPROC glUniform1i; - NAZARA_RENDERER_API extern PFNGLUNIFORM1DVPROC glUniform1dv; - NAZARA_RENDERER_API extern PFNGLUNIFORM1FVPROC glUniform1fv; - NAZARA_RENDERER_API extern PFNGLUNIFORM1IVPROC glUniform1iv; - NAZARA_RENDERER_API extern PFNGLUNIFORM2DVPROC glUniform2dv; - NAZARA_RENDERER_API extern PFNGLUNIFORM2FVPROC glUniform2fv; - NAZARA_RENDERER_API extern PFNGLUNIFORM2IVPROC glUniform2iv; - NAZARA_RENDERER_API extern PFNGLUNIFORM3DVPROC glUniform3dv; - NAZARA_RENDERER_API extern PFNGLUNIFORM3FVPROC glUniform3fv; - NAZARA_RENDERER_API extern PFNGLUNIFORM3IVPROC glUniform3iv; - NAZARA_RENDERER_API extern PFNGLUNIFORM4DVPROC glUniform4dv; - NAZARA_RENDERER_API extern PFNGLUNIFORM4FVPROC glUniform4fv; - NAZARA_RENDERER_API extern PFNGLUNIFORM4IVPROC glUniform4iv; - NAZARA_RENDERER_API extern PFNGLUNIFORMMATRIX4DVPROC glUniformMatrix4dv; - NAZARA_RENDERER_API extern PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv; - NAZARA_RENDERER_API extern PFNGLUNMAPBUFFERPROC glUnmapBuffer; - NAZARA_RENDERER_API extern PFNGLUSEPROGRAMPROC glUseProgram; - NAZARA_RENDERER_API extern PFNGLVALIDATEPROGRAMPROC glValidateProgram; - NAZARA_RENDERER_API extern PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f; - NAZARA_RENDERER_API extern PFNGLVERTEXATTRIBDIVISORPROC glVertexAttribDivisor; - NAZARA_RENDERER_API extern PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer; - NAZARA_RENDERER_API extern PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer; - NAZARA_RENDERER_API extern PFNGLVERTEXATTRIBLPOINTERPROC glVertexAttribLPointer; - NAZARA_RENDERER_API extern PFNGLVIEWPORTPROC glViewport; -} +NAZARA_RENDERER_API extern PFNGLACTIVETEXTUREPROC glActiveTexture; +NAZARA_RENDERER_API extern PFNGLATTACHSHADERPROC glAttachShader; +NAZARA_RENDERER_API extern PFNGLBEGINCONDITIONALRENDERPROC glBeginConditionalRender; +NAZARA_RENDERER_API extern PFNGLBEGINQUERYPROC glBeginQuery; +NAZARA_RENDERER_API extern PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation; +NAZARA_RENDERER_API extern PFNGLBINDBUFFERPROC glBindBuffer; +NAZARA_RENDERER_API extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer; +NAZARA_RENDERER_API extern PFNGLBINDFRAGDATALOCATIONPROC glBindFragDataLocation; +NAZARA_RENDERER_API extern PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer; +NAZARA_RENDERER_API extern PFNGLBINDSAMPLERPROC glBindSampler; +NAZARA_RENDERER_API extern PFNGLBINDTEXTUREPROC glBindTexture; +NAZARA_RENDERER_API extern PFNGLBINDVERTEXARRAYPROC glBindVertexArray; +NAZARA_RENDERER_API extern PFNGLBLENDFUNCPROC glBlendFunc; +NAZARA_RENDERER_API extern PFNGLBLENDFUNCSEPARATEPROC glBlendFuncSeparate; +NAZARA_RENDERER_API extern PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer; +NAZARA_RENDERER_API extern PFNGLBUFFERDATAPROC glBufferData; +NAZARA_RENDERER_API extern PFNGLBUFFERSUBDATAPROC glBufferSubData; +NAZARA_RENDERER_API extern PFNGLCLEARPROC glClear; +NAZARA_RENDERER_API extern PFNGLCLEARCOLORPROC glClearColor; +NAZARA_RENDERER_API extern PFNGLCLEARDEPTHPROC glClearDepth; +NAZARA_RENDERER_API extern PFNGLCLEARSTENCILPROC glClearStencil; +NAZARA_RENDERER_API extern PFNGLCREATEPROGRAMPROC glCreateProgram; +NAZARA_RENDERER_API extern PFNGLCREATESHADERPROC glCreateShader; +NAZARA_RENDERER_API extern PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus; +NAZARA_RENDERER_API extern PFNGLCOLORMASKPROC glColorMask; +NAZARA_RENDERER_API extern PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glCompressedTexSubImage1D; +NAZARA_RENDERER_API extern PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glCompressedTexSubImage2D; +NAZARA_RENDERER_API extern PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glCompressedTexSubImage3D; +NAZARA_RENDERER_API extern PFNGLCULLFACEPROC glCullFace; +NAZARA_RENDERER_API extern PFNGLCOMPILESHADERPROC glCompileShader; +NAZARA_RENDERER_API extern PFNGLCOPYTEXSUBIMAGE2DPROC glCopyTexSubImage2D; +NAZARA_RENDERER_API extern PFNGLDEBUGMESSAGECALLBACKPROC glDebugMessageCallback; +NAZARA_RENDERER_API extern PFNGLDEBUGMESSAGECONTROLPROC glDebugMessageControl; +NAZARA_RENDERER_API extern PFNGLDEBUGMESSAGEINSERTPROC glDebugMessageInsert; +NAZARA_RENDERER_API extern PFNGLDELETEBUFFERSPROC glDeleteBuffers; +NAZARA_RENDERER_API extern PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers; +NAZARA_RENDERER_API extern PFNGLDELETEPROGRAMPROC glDeleteProgram; +NAZARA_RENDERER_API extern PFNGLDELETEQUERIESPROC glDeleteQueries; +NAZARA_RENDERER_API extern PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers; +NAZARA_RENDERER_API extern PFNGLDELETESAMPLERSPROC glDeleteSamplers; +NAZARA_RENDERER_API extern PFNGLDELETESHADERPROC glDeleteShader; +NAZARA_RENDERER_API extern PFNGLDELETETEXTURESPROC glDeleteTextures; +NAZARA_RENDERER_API extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays; +NAZARA_RENDERER_API extern PFNGLDEPTHFUNCPROC glDepthFunc; +NAZARA_RENDERER_API extern PFNGLDEPTHMASKPROC glDepthMask; +NAZARA_RENDERER_API extern PFNGLDISABLEPROC glDisable; +NAZARA_RENDERER_API extern PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray; +NAZARA_RENDERER_API extern PFNGLDRAWARRAYSPROC glDrawArrays; +NAZARA_RENDERER_API extern PFNGLDRAWARRAYSINSTANCEDPROC glDrawArraysInstanced; +NAZARA_RENDERER_API extern PFNGLDRAWBUFFERPROC glDrawBuffer; +NAZARA_RENDERER_API extern PFNGLDRAWBUFFERSPROC glDrawBuffers; +NAZARA_RENDERER_API extern PFNGLDRAWELEMENTSPROC glDrawElements; +NAZARA_RENDERER_API extern PFNGLDRAWELEMENTSINSTANCEDPROC glDrawElementsInstanced; +NAZARA_RENDERER_API extern PFNGLDRAWTEXTURENVPROC glDrawTexture; +NAZARA_RENDERER_API extern PFNGLENABLEPROC glEnable; +NAZARA_RENDERER_API extern PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray; +NAZARA_RENDERER_API extern PFNGLENDCONDITIONALRENDERPROC glEndConditionalRender; +NAZARA_RENDERER_API extern PFNGLENDQUERYPROC glEndQuery; +NAZARA_RENDERER_API extern PFNGLFLUSHPROC glFlush; +NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer; +NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERTEXTUREPROC glFramebufferTexture; +NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D; +NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D; +NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D; +NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer; +NAZARA_RENDERER_API extern PFNGLGENERATEMIPMAPPROC glGenerateMipmap; +NAZARA_RENDERER_API extern PFNGLGENBUFFERSPROC glGenBuffers; +NAZARA_RENDERER_API extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers; +NAZARA_RENDERER_API extern PFNGLGENQUERIESPROC glGenQueries; +NAZARA_RENDERER_API extern PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers; +NAZARA_RENDERER_API extern PFNGLGENSAMPLERSPROC glGenSamplers; +NAZARA_RENDERER_API extern PFNGLGENTEXTURESPROC glGenTextures; +NAZARA_RENDERER_API extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays; +NAZARA_RENDERER_API extern PFNGLGETACTIVEUNIFORMPROC glGetActiveUniform; +NAZARA_RENDERER_API extern PFNGLGETBOOLEANVPROC glGetBooleanv; +NAZARA_RENDERER_API extern PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv; +NAZARA_RENDERER_API extern PFNGLGETDEBUGMESSAGELOGPROC glGetDebugMessageLog; +NAZARA_RENDERER_API extern PFNGLGETERRORPROC glGetError; +NAZARA_RENDERER_API extern PFNGLGETFLOATVPROC glGetFloatv; +NAZARA_RENDERER_API extern PFNGLGETINTEGERVPROC glGetIntegerv; +NAZARA_RENDERER_API extern PFNGLGETPROGRAMBINARYPROC glGetProgramBinary; +NAZARA_RENDERER_API extern PFNGLGETPROGRAMIVPROC glGetProgramiv; +NAZARA_RENDERER_API extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog; +NAZARA_RENDERER_API extern PFNGLGETQUERYIVPROC glGetQueryiv; +NAZARA_RENDERER_API extern PFNGLGETQUERYOBJECTIVPROC glGetQueryObjectiv; +NAZARA_RENDERER_API extern PFNGLGETQUERYOBJECTUIVPROC glGetQueryObjectuiv; +NAZARA_RENDERER_API extern PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog; +NAZARA_RENDERER_API extern PFNGLGETSHADERIVPROC glGetShaderiv; +NAZARA_RENDERER_API extern PFNGLGETSHADERSOURCEPROC glGetShaderSource; +NAZARA_RENDERER_API extern PFNGLGETSTRINGPROC glGetString; +NAZARA_RENDERER_API extern PFNGLGETSTRINGIPROC glGetStringi; +NAZARA_RENDERER_API extern PFNGLGETTEXIMAGEPROC glGetTexImage; +NAZARA_RENDERER_API extern PFNGLGETTEXLEVELPARAMETERFVPROC glGetTexLevelParameterfv; +NAZARA_RENDERER_API extern PFNGLGETTEXLEVELPARAMETERIVPROC glGetTexLevelParameteriv; +NAZARA_RENDERER_API extern PFNGLGETTEXPARAMETERFVPROC glGetTexParameterfv; +NAZARA_RENDERER_API extern PFNGLGETTEXPARAMETERIVPROC glGetTexParameteriv; +NAZARA_RENDERER_API extern PFNGLGETUNIFORMFVPROC glGetUniformfv; +NAZARA_RENDERER_API extern PFNGLGETUNIFORMIVPROC glGetUniformiv; +NAZARA_RENDERER_API extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation; +NAZARA_RENDERER_API extern PFNGLINVALIDATEBUFFERDATAPROC glInvalidateBufferData; +NAZARA_RENDERER_API extern PFNGLISENABLEDPROC glIsEnabled; +NAZARA_RENDERER_API extern PFNGLLINEWIDTHPROC glLineWidth; +NAZARA_RENDERER_API extern PFNGLLINKPROGRAMPROC glLinkProgram; +NAZARA_RENDERER_API extern PFNGLMAPBUFFERPROC glMapBuffer; +NAZARA_RENDERER_API extern PFNGLMAPBUFFERRANGEPROC glMapBufferRange; +NAZARA_RENDERER_API extern PFNGLPIXELSTOREIPROC glPixelStorei; +NAZARA_RENDERER_API extern PFNGLPOINTSIZEPROC glPointSize; +NAZARA_RENDERER_API extern PFNGLPOLYGONMODEPROC glPolygonMode; +NAZARA_RENDERER_API extern PFNGLPROGRAMBINARYPROC glProgramBinary; +NAZARA_RENDERER_API extern PFNGLPROGRAMPARAMETERIPROC glProgramParameteri; +NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1DPROC glProgramUniform1d; +NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1FPROC glProgramUniform1f; +NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1IPROC glProgramUniform1i; +NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1DVPROC glProgramUniform1dv; +NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1FVPROC glProgramUniform1fv; +NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1IVPROC glProgramUniform1iv; +NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM2DVPROC glProgramUniform2dv; +NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM2FVPROC glProgramUniform2fv; +NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM2IVPROC glProgramUniform2iv; +NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM3DVPROC glProgramUniform3dv; +NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM3FVPROC glProgramUniform3fv; +NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM3IVPROC glProgramUniform3iv; +NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM4DVPROC glProgramUniform4dv; +NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM4FVPROC glProgramUniform4fv; +NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM4IVPROC glProgramUniform4iv; +NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORMMATRIX4DVPROC glProgramUniformMatrix4dv; +NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORMMATRIX4FVPROC glProgramUniformMatrix4fv; +NAZARA_RENDERER_API extern PFNGLREADPIXELSPROC glReadPixels; +NAZARA_RENDERER_API extern PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage; +NAZARA_RENDERER_API extern PFNGLSAMPLERPARAMETERFPROC glSamplerParameterf; +NAZARA_RENDERER_API extern PFNGLSAMPLERPARAMETERIPROC glSamplerParameteri; +NAZARA_RENDERER_API extern PFNGLSCISSORPROC glScissor; +NAZARA_RENDERER_API extern PFNGLSHADERSOURCEPROC glShaderSource; +NAZARA_RENDERER_API extern PFNGLSTENCILFUNCPROC glStencilFunc; +NAZARA_RENDERER_API extern PFNGLSTENCILFUNCSEPARATEPROC glStencilFuncSeparate; +NAZARA_RENDERER_API extern PFNGLSTENCILOPPROC glStencilOp; +NAZARA_RENDERER_API extern PFNGLSTENCILOPSEPARATEPROC glStencilOpSeparate; +NAZARA_RENDERER_API extern PFNGLTEXIMAGE1DPROC glTexImage1D; +NAZARA_RENDERER_API extern PFNGLTEXIMAGE2DPROC glTexImage2D; +NAZARA_RENDERER_API extern PFNGLTEXIMAGE3DPROC glTexImage3D; +NAZARA_RENDERER_API extern PFNGLTEXPARAMETERFPROC glTexParameterf; +NAZARA_RENDERER_API extern PFNGLTEXPARAMETERIPROC glTexParameteri; +NAZARA_RENDERER_API extern PFNGLTEXSTORAGE1DPROC glTexStorage1D; +NAZARA_RENDERER_API extern PFNGLTEXSTORAGE2DPROC glTexStorage2D; +NAZARA_RENDERER_API extern PFNGLTEXSTORAGE3DPROC glTexStorage3D; +NAZARA_RENDERER_API extern PFNGLTEXSUBIMAGE1DPROC glTexSubImage1D; +NAZARA_RENDERER_API extern PFNGLTEXSUBIMAGE2DPROC glTexSubImage2D; +NAZARA_RENDERER_API extern PFNGLTEXSUBIMAGE3DPROC glTexSubImage3D; +NAZARA_RENDERER_API extern PFNGLUNIFORM1DPROC glUniform1d; +NAZARA_RENDERER_API extern PFNGLUNIFORM1FPROC glUniform1f; +NAZARA_RENDERER_API extern PFNGLUNIFORM1IPROC glUniform1i; +NAZARA_RENDERER_API extern PFNGLUNIFORM1DVPROC glUniform1dv; +NAZARA_RENDERER_API extern PFNGLUNIFORM1FVPROC glUniform1fv; +NAZARA_RENDERER_API extern PFNGLUNIFORM1IVPROC glUniform1iv; +NAZARA_RENDERER_API extern PFNGLUNIFORM2DVPROC glUniform2dv; +NAZARA_RENDERER_API extern PFNGLUNIFORM2FVPROC glUniform2fv; +NAZARA_RENDERER_API extern PFNGLUNIFORM2IVPROC glUniform2iv; +NAZARA_RENDERER_API extern PFNGLUNIFORM3DVPROC glUniform3dv; +NAZARA_RENDERER_API extern PFNGLUNIFORM3FVPROC glUniform3fv; +NAZARA_RENDERER_API extern PFNGLUNIFORM3IVPROC glUniform3iv; +NAZARA_RENDERER_API extern PFNGLUNIFORM4DVPROC glUniform4dv; +NAZARA_RENDERER_API extern PFNGLUNIFORM4FVPROC glUniform4fv; +NAZARA_RENDERER_API extern PFNGLUNIFORM4IVPROC glUniform4iv; +NAZARA_RENDERER_API extern PFNGLUNIFORMMATRIX4DVPROC glUniformMatrix4dv; +NAZARA_RENDERER_API extern PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv; +NAZARA_RENDERER_API extern PFNGLUNMAPBUFFERPROC glUnmapBuffer; +NAZARA_RENDERER_API extern PFNGLUSEPROGRAMPROC glUseProgram; +NAZARA_RENDERER_API extern PFNGLVALIDATEPROGRAMPROC glValidateProgram; +NAZARA_RENDERER_API extern PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f; +NAZARA_RENDERER_API extern PFNGLVERTEXATTRIBDIVISORPROC glVertexAttribDivisor; +NAZARA_RENDERER_API extern PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer; +NAZARA_RENDERER_API extern PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer; +NAZARA_RENDERER_API extern PFNGLVERTEXATTRIBLPOINTERPROC glVertexAttribLPointer; +NAZARA_RENDERER_API extern PFNGLVIEWPORTPROC glViewport; +#if defined(NAZARA_PLATFORM_WINDOWS) +NAZARA_RENDERER_API extern PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormat; +NAZARA_RENDERER_API extern PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs; +NAZARA_RENDERER_API extern PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB; +NAZARA_RENDERER_API extern PFNWGLGETEXTENSIONSSTRINGEXTPROC wglGetExtensionsStringEXT; +NAZARA_RENDERER_API extern PFNWGLSWAPINTERVALEXTPROC wglSwapInterval; +#elif defined(NAZARA_PLATFORM_GLX) +NAZARA_RENDERER_API extern GLX::PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs; +NAZARA_RENDERER_API extern GLX::PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT; +NAZARA_RENDERER_API extern GLX::PFNGLXSWAPINTERVALMESAPROC NzglXSwapIntervalMESA; +NAZARA_RENDERER_API extern GLX::PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI; +#endif -#undef None +} #endif // NAZARA_RENDERER_OPENGL diff --git a/src/Nazara/Platform/SDL2/WindowImpl.cpp b/src/Nazara/Platform/SDL2/WindowImpl.cpp index a87155be2..acbbc8382 100644 --- a/src/Nazara/Platform/SDL2/WindowImpl.cpp +++ b/src/Nazara/Platform/SDL2/WindowImpl.cpp @@ -48,17 +48,17 @@ namespace Nz } WindowImpl::WindowImpl(Window* parent) : - m_cursor(nullptr), - m_handle(nullptr), - //m_callback(0), - m_style(0), - m_maxSize(-1), - m_minSize(-1), - m_parent(parent), - m_keyRepeat(true), - m_mouseInside(false), - m_smoothScrolling(false), - m_scrolling(0) + m_cursor(nullptr), + m_handle(nullptr), + //m_callback(0), + m_style(0), + m_maxSize(-1), + m_minSize(-1), + m_parent(parent), + m_keyRepeat(true), + m_mouseInside(false), + m_smoothScrolling(false), + m_scrolling(0) { m_cursor = SDL_GetDefaultCursor(); } @@ -76,7 +76,7 @@ namespace Nz bool fullscreen = (style & WindowStyle_Fullscreen) != 0; - Uint32 winStyle = SDL_WINDOW_OPENGL; + Uint32 winStyle = 0; unsigned int x, y; unsigned int width = mode.width; @@ -147,19 +147,18 @@ namespace Nz m_size.Set(width, height); - SDL_AddEventWatch(HandleEvent, this); - return true; } void WindowImpl::Destroy() { if (m_ownsWindow && m_handle) + { + SDL_DelEventWatch(HandleEvent, this); SDL_DestroyWindow(m_handle); + } else SetEventListener(false); - - SDL_DelEventWatch(HandleEvent, this); } void WindowImpl::EnableKeyRepeat(bool enable) @@ -195,6 +194,8 @@ namespace Nz WindowHandle WindowImpl::GetSystemHandle() const { SDL_SysWMinfo wmInfo; + SDL_VERSION(&wmInfo.version); + if (SDL_GetWindowWMInfo(m_handle, &wmInfo) != SDL_TRUE) { ErrorFlags flags(ErrorFlag_ThrowException, true); @@ -545,7 +546,13 @@ namespace Nz void WindowImpl::SetEventListener(bool listener) { + if (m_ownsWindow) + return; + if (listener) + SDL_AddEventWatch(HandleEvent, this); + else + SDL_DelEventWatch(HandleEvent, this); } void WindowImpl::SetFocus() @@ -613,16 +620,6 @@ namespace Nz NazaraError(SDL_GetError()); return false; } - if (SDL_GL_LoadLibrary(nullptr) < 0) - { - NazaraError(SDL_GetError()); - - SDL_Quit(); - return false; - } - - if (SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, true) < 0) - NazaraError("Couldn't set share OpenGL contexes"); return true; } diff --git a/src/Nazara/Renderer/Context.cpp b/src/Nazara/Renderer/Context.cpp index 0a1fd7f9c..90a17122d 100644 --- a/src/Nazara/Renderer/Context.cpp +++ b/src/Nazara/Renderer/Context.cpp @@ -12,10 +12,13 @@ #include #include -#include - -#if defined(NAZARA_PLATFORM_LINUX) +#if defined(NAZARA_PLATFORM_WINDOWS) + #include +#elif defined(NAZARA_PLATFORM_GLX) + #include #define CALLBACK +#else + #error Lack of implementation: Context #endif #include diff --git a/src/Nazara/Renderer/GLX/ContextImpl.cpp b/src/Nazara/Renderer/GLX/ContextImpl.cpp new file mode 100644 index 000000000..d7a4fa425 --- /dev/null +++ b/src/Nazara/Renderer/GLX/ContextImpl.cpp @@ -0,0 +1,302 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +// Code inspiré de NeHe (Lesson1) et de la SFML par Laurent Gomila + +#include +#include +#include +#include +#include + +using namespace GLX; + +namespace Nz +{ + namespace + { + Display* m_display; + int m_sharedDisplay = 0; + + bool ctxErrorOccurred = false; + int ctxErrorHandler( Display* /*dpy*/, XErrorEvent* /*ev*/ ) + { + ctxErrorOccurred = true; + return 0; + } + } + + ContextImpl::ContextImpl() : + m_colormap(0), + m_context(0), + m_window(0), + m_ownsWindow(false) + { + if (m_sharedDisplay == 0) + m_display = XOpenDisplay(nullptr); + + ++m_sharedDisplay; + } + + ContextImpl::~ContextImpl() + { + Destroy(); + + if (--m_sharedDisplay == 0) + { + XCloseDisplay(m_display); + m_display = nullptr; + } + } + + bool ContextImpl::Activate() const + { + return glXMakeCurrent(m_display, m_window, m_context) == true; + } + + bool ContextImpl::Create(ContextParameters& parameters) + { + // En cas d'exception, la ressource sera quand même libérée + CallOnExit onExit([this] () + { + Destroy(); + }); + + // Get a matching FB config + static int visual_attribs[] = + { + GLX_X_RENDERABLE, True, + GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, + GLX_RENDER_TYPE, GLX_RGBA_BIT, + GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR, + GLX_BUFFER_SIZE, parameters.bitsPerPixel, + GLX_ALPHA_SIZE, (parameters.bitsPerPixel == 32) ? 8 : 0, + GLX_DEPTH_SIZE, parameters.depthBits, + GLX_STENCIL_SIZE, parameters.stencilBits, + GLX_DOUBLEBUFFER, True, + GLX_SAMPLE_BUFFERS, (parameters.antialiasingLevel > 0) ? True : False, + GLX_SAMPLES, parameters.antialiasingLevel, + None + }; + + int glx_major = 0; + int glx_minor = 0; + // FBConfigs were added in GLX version 1.3. + if (!glXQueryVersion(m_display, &glx_major, &glx_minor) || ((glx_major == 1) && (glx_minor < 3)) || (glx_major < 1)) + { + NazaraError("Invalid GLX version, version > 1.3 is required."); + return false; + } + + int fbcount; + GLXFBConfig* fbc = glXChooseFBConfig(m_display, XDefaultScreen(m_display), visual_attribs, &fbcount); + if (!fbc) + { + NazaraError("Failed to retrieve a framebuffer config"); + return false; + } + + // Pick the FB config/visual with the most samples per pixel + int best_fbc = -1; + int worst_fbc = -1; + int best_num_samp = -1; + int worst_num_samp = 999; + + for (int i = 0; i < fbcount; ++i) + { + XVisualInfo* vi = glXGetVisualFromFBConfig(m_display, fbc[i]); + + if (vi) + { + int samp_buf = 0, samples = 0; + glXGetFBConfigAttrib(m_display, fbc[i], GLX_SAMPLE_BUFFERS, &samp_buf); + glXGetFBConfigAttrib(m_display, fbc[i], GLX_SAMPLES , &samples ); + + if ((best_fbc < 0) || (samp_buf && (samples > best_num_samp))) + { + best_fbc = i; + best_num_samp = samples; + } + if ((worst_fbc < 0) || !samp_buf || (samples < worst_num_samp)) + { + worst_fbc = i; + worst_num_samp = samples; + } + } + XFree(vi); + } + + GLXFBConfig bestFbc = fbc[best_fbc]; + + // Be sure to free the FBConfig list allocated by glXChooseFBConfig() + XFree(fbc); + + // Get a visual + XVisualInfo* vi = glXGetVisualFromFBConfig(m_display, bestFbc); + if (!vi) + { + NazaraError("Failed to get best VisualInfo"); + return false; + } + + // If context is shared by multiple windows + if (parameters.window) + { + NazaraAssert(parameters.window.type == WindowManager::X11, "Cannot create a context for a non-x11 window"); + + m_window = static_cast(parameters.window.x11.window); + m_ownsWindow = false; + } + else + { + XSetWindowAttributes swa; + swa.colormap = m_colormap = XCreateColormap( + m_display, + XRootWindow( + m_display, + vi->screen), + vi->visual, + AllocNone + ); + + swa.background_pixmap = None; + swa.border_pixel = 0; + swa.event_mask = StructureNotifyMask; + + if (!m_colormap) + { + NazaraError("Failed to create colormap for context"); + return false; + } + + m_window = XCreateWindow( + m_display, + XRootWindow( + m_display, + vi->screen), + 0, 0, // X, Y + 1, 1, // W H + 0, + vi->depth, + InputOutput, + vi->visual, + CWBorderPixel | CWColormap | CWEventMask, + &swa + ); + + m_ownsWindow = true; + } + + if (!m_window) + { + NazaraError("Failed to create window"); + return false; + } + + // Done with the visual info data + XFree(vi); + + // Install an X error handler so the application won't exit if GL 3.0 + // context allocation fails. + // + // Note this error handler is global. All display connections in all threads + // of a process use the same error handler, so be sure to guard against other + // threads issuing X commands while this code is running. + ctxErrorOccurred = false; + int (*oldHandler)(Display*, XErrorEvent*) = + XSetErrorHandler(&ctxErrorHandler); + + // Check for the GLX_ARB_create_context extension string and the function. + // If either is not present, use GLX 1.3 context creation method. + if (!glXCreateContextAttribs) + { + NazaraWarning("glXCreateContextAttribs() not found. Using old-style GLX context"); + m_context = glXCreateNewContext(m_display, bestFbc, GLX_RGBA_TYPE, parameters.shared ? parameters.shareContext->m_impl->m_context : 0, True); + } + // If it does, try to get a GL 3.0 context! + else + { + int profile = parameters.compatibilityProfile ? GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB : GLX_CONTEXT_CORE_PROFILE_BIT_ARB; + int debug = parameters.debugMode ? GLX_CONTEXT_DEBUG_BIT_ARB : 0; + + int major = 3;//parameters.majorVersion; + int minor = 3;//parameters.minorVersion; + + int context_attribs[] = + { + GLX_CONTEXT_MAJOR_VERSION_ARB, major, + GLX_CONTEXT_MINOR_VERSION_ARB, minor, + GLX_CONTEXT_PROFILE_MASK_ARB, profile, + GLX_CONTEXT_FLAGS_ARB, debug, + None, None + }; + + m_context = glXCreateContextAttribs( + m_display, + bestFbc, + parameters.shared ? parameters.shareContext->m_impl->m_context : 0, + True, + context_attribs + ); + } + + // Sync to ensure any errors generated are processed. + XSync(m_display, False); + XSetErrorHandler(oldHandler); + if (ctxErrorOccurred || !m_context) + { + NazaraError("Failed to create context, check the version"); + return false; + } + + onExit.Reset(); + + return true; + } + + void ContextImpl::Destroy() + { + // Destroy the context + if (m_context) + { + if (glXGetCurrentContext() == m_context) + glXMakeCurrent(m_display, None, nullptr); + glXDestroyContext(m_display, m_context); + m_context = nullptr; + } + + // Destroy the window if we own it + if (m_ownsWindow && m_window) + { + XFreeColormap(m_display, m_colormap); + XDestroyWindow(m_display, m_window); + m_ownsWindow = false; + m_window = 0; + XFlush(m_display); + } + } + + void ContextImpl::EnableVerticalSync(bool enabled) + { + if (glXSwapIntervalEXT) + glXSwapIntervalEXT(m_display, glXGetCurrentDrawable(), enabled ? 1 : 0); + else if (NzglXSwapIntervalMESA) + NzglXSwapIntervalMESA(enabled ? 1 : 0); + else if (glXSwapIntervalSGI) + glXSwapIntervalSGI(enabled ? 1 : 0); + else + NazaraError("Vertical sync not supported"); + } + + void ContextImpl::SwapBuffers() + { + if (m_window) + glXSwapBuffers(m_display, m_window); + } + + bool ContextImpl::Desactivate() + { + return glXMakeCurrent(m_display, None, nullptr) == true; + } +} diff --git a/src/Nazara/Renderer/GLX/ContextImpl.hpp b/src/Nazara/Renderer/GLX/ContextImpl.hpp new file mode 100644 index 000000000..7aaf6409f --- /dev/null +++ b/src/Nazara/Renderer/GLX/ContextImpl.hpp @@ -0,0 +1,42 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine". +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_CONTEXTIMPL_HPP +#define NAZARA_CONTEXTIMPL_HPP + +#include + +namespace Nz +{ + struct ContextParameters; + + class ContextImpl + { + public: + ContextImpl(); + ~ContextImpl(); + + bool Activate() const; + + bool Create(ContextParameters& parameters); + + void Destroy(); + + void EnableVerticalSync(bool enabled); + + void SwapBuffers(); + + static bool Desactivate(); + + private: + GLX::Colormap m_colormap; + GLX::GLXContext m_context; + GLX::Window m_window; + bool m_ownsWindow; + }; +} + +#endif // NAZARA_CONTEXTIMPL_HPP diff --git a/src/Nazara/Renderer/OpenGL.cpp b/src/Nazara/Renderer/OpenGL.cpp index f7f903314..1c6ac00dd 100644 --- a/src/Nazara/Renderer/OpenGL.cpp +++ b/src/Nazara/Renderer/OpenGL.cpp @@ -2,19 +2,21 @@ // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp +#include #include #include #include #include -#include #include #include -#include -#include +#if defined(NAZARA_PLATFORM_GLX) +#include +#endif // NAZARA_PLATFORM_GLX #include #include #include #include +#include namespace Nz { @@ -26,7 +28,15 @@ namespace Nz OpenGLFunc LoadEntry(const char* name, bool launchException = true) { - OpenGLFunc entry = reinterpret_cast(SDL_GL_GetProcAddress(name)); + #if defined(NAZARA_PLATFORM_WINDOWS) + OpenGLFunc entry = reinterpret_cast(wglGetProcAddress(name)); + if (!entry) // wglGetProcAddress ne fonctionne pas sur les fonctions OpenGL <= 1.1 + entry = reinterpret_cast(GetProcAddress(openGLlibrary, name)); + #elif defined(NAZARA_PLATFORM_GLX) + OpenGLFunc entry = reinterpret_cast(GLX::glXGetProcAddress(reinterpret_cast(name))); + #else + #error OS not handled + #endif if (!entry && launchException) { @@ -41,19 +51,20 @@ namespace Nz bool LoadLibrary() { - if (SDL_GL_LoadLibrary(nullptr) != 0) - { - NazaraError(SDL_GetError()); - - return false; - } + #ifdef NAZARA_PLATFORM_WINDOWS + openGLlibrary = ::LoadLibraryA("opengl32.dll"); + return openGLlibrary != nullptr; + #else return true; + #endif } void UnloadLibrary() { - SDL_GL_UnloadLibrary(); + #ifdef NAZARA_PLATFORM_WINDOWS + FreeLibrary(openGLlibrary); + #endif } enum GarbageResourceType @@ -64,7 +75,7 @@ namespace Nz struct ContextStates { - std::vector > garbage; // Les ressources à supprimer dès que possible + std::vector> garbage; // Les ressources à supprimer dès que possible GLuint buffersBinding[BufferType_Max + 1] = {0}; GLuint currentProgram = 0; GLuint samplers[32] = {0}; // 32 est pour l'instant la plus haute limite (GL_TEXTURE31) @@ -147,13 +158,15 @@ namespace Nz // Les fonctions de blend n'a aucun intérêt sans blending if (states.blending) + { if (currentRenderStates.dstBlend != states.dstBlend || - currentRenderStates.srcBlend != states.srcBlend) + currentRenderStates.srcBlend != states.srcBlend) { glBlendFunc(BlendFunc[states.srcBlend], BlendFunc[states.dstBlend]); currentRenderStates.dstBlend = states.dstBlend; currentRenderStates.srcBlend = states.srcBlend; } + } if (states.depthBuffer) { @@ -174,11 +187,13 @@ namespace Nz // Inutile de changer le mode de face culling s'il n'est pas actif if (states.faceCulling) + { if (currentRenderStates.cullingSide != states.cullingSide) { glCullFace(FaceSide[states.cullingSide]); currentRenderStates.cullingSide = states.cullingSide; } + } if (currentRenderStates.faceFilling != states.faceFilling) { @@ -190,8 +205,8 @@ namespace Nz if (states.stencilTest) { if (currentRenderStates.stencilCompare.back != states.stencilCompare.back || - currentRenderStates.stencilReference.back != states.stencilReference.back || - currentRenderStates.stencilWriteMask.back != states.stencilWriteMask.back) + currentRenderStates.stencilReference.back != states.stencilReference.back || + currentRenderStates.stencilWriteMask.back != states.stencilWriteMask.back) { glStencilFuncSeparate(GL_BACK, RendererComparison[states.stencilCompare.back], states.stencilReference.back, states.stencilWriteMask.back); currentRenderStates.stencilCompare.back = states.stencilCompare.back; @@ -200,8 +215,8 @@ namespace Nz } if (currentRenderStates.stencilDepthFail.back != states.stencilDepthFail.back || - currentRenderStates.stencilFail.back != states.stencilFail.back || - currentRenderStates.stencilPass.back != states.stencilPass.back) + currentRenderStates.stencilFail.back != states.stencilFail.back || + currentRenderStates.stencilPass.back != states.stencilPass.back) { glStencilOpSeparate(GL_BACK, StencilOperation[states.stencilFail.back], StencilOperation[states.stencilDepthFail.back], StencilOperation[states.stencilPass.back]); currentRenderStates.stencilDepthFail.back = states.stencilDepthFail.back; @@ -210,8 +225,8 @@ namespace Nz } if (currentRenderStates.stencilCompare.front != states.stencilCompare.front || - currentRenderStates.stencilReference.front != states.stencilReference.front || - currentRenderStates.stencilWriteMask.front != states.stencilWriteMask.front) + currentRenderStates.stencilReference.front != states.stencilReference.front || + currentRenderStates.stencilWriteMask.front != states.stencilWriteMask.front) { glStencilFuncSeparate(GL_FRONT, RendererComparison[states.stencilCompare.front], states.stencilReference.front, states.stencilWriteMask.front); currentRenderStates.stencilCompare.front = states.stencilCompare.front; @@ -220,8 +235,8 @@ namespace Nz } if (currentRenderStates.stencilDepthFail.front != states.stencilDepthFail.front || - currentRenderStates.stencilFail.front != states.stencilFail.front || - currentRenderStates.stencilPass.front != states.stencilPass.front) + currentRenderStates.stencilFail.front != states.stencilFail.front || + currentRenderStates.stencilPass.front != states.stencilPass.front) { glStencilOpSeparate(GL_FRONT, StencilOperation[states.stencilFail.front], StencilOperation[states.stencilDepthFail.front], StencilOperation[states.stencilPass.front]); currentRenderStates.stencilDepthFail.front = states.stencilDepthFail.front; @@ -716,8 +731,14 @@ namespace Nz if (s_initialized) return true; - if (SDL_VideoInit(NULL) != 0) - NazaraError(SDL_GetError()); + #if defined(NAZARA_PLATFORM_GLX) + Initializer display; + if (!display) + { + NazaraError("Failed to load display library"); + return false; + } + #endif if (!LoadLibrary()) { @@ -737,15 +758,20 @@ namespace Nz parameters.shared = false; /* - Note: Même le contexte de chargement nécessite quelques fonctions de base pour correctement s'initialiser - Pour cette raison, deux contextes sont créés, le premier sert à récupérer les fonctions permetttant - de créer le second avec les bons paramètres. + Note: Même le contexte de chargement nécessite quelques fonctions de base pour correctement s'initialiser + Pour cette raison, deux contextes sont créés, le premier sert à récupérer les fonctions permetttant + de créer le second avec les bons paramètres. - Non sérieusement si vous avez une meilleure idée, contactez-moi - */ + Non sérieusement si vous avez une meilleure idée, contactez-moi + */ /****************************Chargement OpenGL****************************/ + ///FIXME: I'm really thinking this is a mistake and GLX has no need to be initialized differently (Lynix) + #if defined(NAZARA_PLATFORM_LINUX) + glXCreateContextAttribs = reinterpret_cast(LoadEntry("glXCreateContextAttribsARB", false)); + #endif + Context loadContext; if (!loadContext.Create(parameters)) { @@ -753,6 +779,13 @@ namespace Nz return false; } + #if defined(NAZARA_PLATFORM_WINDOWS) + wglCreateContextAttribs = reinterpret_cast(LoadEntry("wglCreateContextAttribsARB", false)); + wglChoosePixelFormat = reinterpret_cast(LoadEntry("wglChoosePixelFormatARB", false)); + if (!wglChoosePixelFormat) + wglChoosePixelFormat = reinterpret_cast(LoadEntry("wglChoosePixelFormatEXT", false)); + #endif + // Récupération de la version d'OpenGL et du GLSL // Ce code se base sur le fait que la carte graphique renverra un contexte de compatibilité avec la plus haute version supportée // Ce qui semble vrai chez AMD, NVidia et Intel, mais j'aimerai une preuve que ça sera toujours le cas... @@ -998,6 +1031,16 @@ namespace Nz glInvalidateBufferData = reinterpret_cast(LoadEntry("glInvalidateBufferData", false)); glVertexAttribLPointer = reinterpret_cast(LoadEntry("glVertexAttribLPointer", false)); + #if defined(NAZARA_PLATFORM_WINDOWS) + wglGetExtensionsStringARB = reinterpret_cast(LoadEntry("wglGetExtensionsStringARB", false)); + wglGetExtensionsStringEXT = reinterpret_cast(LoadEntry("wglGetExtensionsStringEXT", false)); + wglSwapInterval = reinterpret_cast(LoadEntry("wglSwapIntervalEXT", false)); + #elif defined(NAZARA_PLATFORM_GLX) + glXSwapIntervalEXT = reinterpret_cast(LoadEntry("glXSwapIntervalEXT", false)); + NzglXSwapIntervalMESA = reinterpret_cast(LoadEntry("glXSwapIntervalMESA", false)); + glXSwapIntervalSGI = reinterpret_cast(LoadEntry("glXSwapIntervalSGI", false)); + #endif + if (!glGetStringi || !LoadExtensions3()) { NazaraWarning("Failed to load OpenGL 3 extension system, falling back to OpenGL 2 extension system..."); @@ -1006,6 +1049,21 @@ namespace Nz NazaraWarning("Failed to load extension system"); } + #ifdef NAZARA_PLATFORM_WINDOWS + { + bool loaded; + if (wglGetExtensionsStringARB) + loaded = LoadExtensionsString(reinterpret_cast(wglGetExtensionsStringARB(wglGetCurrentDC()))); + else if (wglGetExtensionsStringEXT) + loaded = LoadExtensionsString(reinterpret_cast(wglGetExtensionsStringEXT())); + else + loaded = false; + + if (!loaded) + NazaraWarning("Failed to load wgl extension string"); + } + #endif + // AnisotropicFilter s_openGLextensions[OpenGLExtension_AnisotropicFilter] = IsSupported("GL_EXT_texture_filter_anisotropic"); @@ -1174,7 +1232,7 @@ namespace Nz bool OpenGL::IsSupported(const String& string) { - return SDL_GL_ExtensionSupported(string.GetConstBuffer()); + return s_openGLextensionSet.find(string) != s_openGLextensionSet.end(); } void OpenGL::SetBuffer(BufferType type, GLuint id) @@ -1840,7 +1898,7 @@ namespace Nz GLenum OpenGL::BufferTarget[] = { GL_ELEMENT_ARRAY_BUFFER, // BufferType_Index, - GL_ARRAY_BUFFER, // BufferType_Vertex + GL_ARRAY_BUFFER, // BufferType_Vertex }; static_assert(BufferType_Max + 1 == 2, "Buffer target array is incomplete"); @@ -1848,7 +1906,7 @@ namespace Nz GLenum OpenGL::BufferTargetBinding[] = { GL_ELEMENT_ARRAY_BUFFER_BINDING, // BufferType_Index, - GL_ARRAY_BUFFER_BINDING, // BufferType_Vertex + GL_ARRAY_BUFFER_BINDING, // BufferType_Vertex }; static_assert(BufferType_Max + 1 == 2, "Buffer target binding array is incomplete"); @@ -1975,9 +2033,9 @@ namespace Nz GLenum OpenGL::ShaderStage[] = { - GL_FRAGMENT_SHADER, // ShaderStage_Fragment - GL_GEOMETRY_SHADER, // ShaderStage_Geometry - GL_VERTEX_SHADER // ShaderStage_Vertex + GL_FRAGMENT_SHADER, // ShaderStage_Fragment + GL_GEOMETRY_SHADER, // ShaderStage_Geometry + GL_VERTEX_SHADER // ShaderStage_Vertex }; static_assert(ShaderStageType_Max + 1 == 3, "Shader stage array is incomplete"); @@ -2054,178 +2112,192 @@ namespace Nz static_assert(VertexComponent_Max + 1 == 16, "Attribute index array is incomplete"); - PFNGLACTIVETEXTUREPROC glActiveTexture = nullptr; - PFNGLATTACHSHADERPROC glAttachShader = nullptr; - PFNGLBEGINCONDITIONALRENDERPROC glBeginConditionalRender = nullptr; - PFNGLBEGINQUERYPROC glBeginQuery = nullptr; - PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation = nullptr; - PFNGLBINDBUFFERPROC glBindBuffer = nullptr; - PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer = nullptr; - PFNGLBINDFRAGDATALOCATIONPROC glBindFragDataLocation = nullptr; - PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer = nullptr; - PFNGLBINDSAMPLERPROC glBindSampler = nullptr; - PFNGLBINDTEXTUREPROC glBindTexture = nullptr; - PFNGLBINDVERTEXARRAYPROC glBindVertexArray = nullptr; - PFNGLBLENDFUNCPROC glBlendFunc = nullptr; - PFNGLBLENDFUNCSEPARATEPROC glBlendFuncSeparate = nullptr; - PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer = nullptr; - PFNGLBUFFERDATAPROC glBufferData = nullptr; - PFNGLBUFFERSUBDATAPROC glBufferSubData = nullptr; - PFNGLCLEARPROC glClear = nullptr; - PFNGLCLEARCOLORPROC glClearColor = nullptr; - PFNGLCLEARDEPTHPROC glClearDepth = nullptr; - PFNGLCLEARSTENCILPROC glClearStencil = nullptr; - PFNGLCREATEPROGRAMPROC glCreateProgram = nullptr; - PFNGLCREATESHADERPROC glCreateShader = nullptr; - PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus = nullptr; - PFNGLCOLORMASKPROC glColorMask = nullptr; - PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glCompressedTexSubImage1D = nullptr; - PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glCompressedTexSubImage2D = nullptr; - PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glCompressedTexSubImage3D = nullptr; - PFNGLCULLFACEPROC glCullFace = nullptr; - PFNGLCOMPILESHADERPROC glCompileShader = nullptr; - PFNGLCOPYTEXSUBIMAGE2DPROC glCopyTexSubImage2D = nullptr; - PFNGLDEBUGMESSAGECALLBACKPROC glDebugMessageCallback = nullptr; - PFNGLDEBUGMESSAGECONTROLPROC glDebugMessageControl = nullptr; - PFNGLDEBUGMESSAGEINSERTPROC glDebugMessageInsert = nullptr; - PFNGLDELETEBUFFERSPROC glDeleteBuffers = nullptr; - PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers = nullptr; - PFNGLDELETEPROGRAMPROC glDeleteProgram = nullptr; - PFNGLDELETEQUERIESPROC glDeleteQueries = nullptr; - PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers = nullptr; - PFNGLDELETESAMPLERSPROC glDeleteSamplers = nullptr; - PFNGLDELETESHADERPROC glDeleteShader = nullptr; - PFNGLDELETETEXTURESPROC glDeleteTextures = nullptr; - PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays = nullptr; - PFNGLDEPTHFUNCPROC glDepthFunc = nullptr; - PFNGLDEPTHMASKPROC glDepthMask = nullptr; - PFNGLDISABLEPROC glDisable = nullptr; - PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray = nullptr; - PFNGLDRAWARRAYSPROC glDrawArrays = nullptr; - PFNGLDRAWARRAYSINSTANCEDPROC glDrawArraysInstanced = nullptr; - PFNGLDRAWBUFFERPROC glDrawBuffer = nullptr; - PFNGLDRAWBUFFERSPROC glDrawBuffers = nullptr; - PFNGLDRAWELEMENTSPROC glDrawElements = nullptr; - PFNGLDRAWELEMENTSINSTANCEDPROC glDrawElementsInstanced = nullptr; - PFNGLDRAWTEXTURENVPROC glDrawTexture = nullptr; - PFNGLENABLEPROC glEnable = nullptr; - PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray = nullptr; - PFNGLENDCONDITIONALRENDERPROC glEndConditionalRender = nullptr; - PFNGLENDQUERYPROC glEndQuery = nullptr; - PFNGLFLUSHPROC glFlush = nullptr; - PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer = nullptr; - PFNGLFRAMEBUFFERTEXTUREPROC glFramebufferTexture = nullptr; - PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D = nullptr; - PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D = nullptr; - PFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D = nullptr; - PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer = nullptr; - PFNGLGENERATEMIPMAPPROC glGenerateMipmap = nullptr; - PFNGLGENBUFFERSPROC glGenBuffers = nullptr; - PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers = nullptr; - PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers = nullptr; - PFNGLGENQUERIESPROC glGenQueries = nullptr; - PFNGLGENSAMPLERSPROC glGenSamplers = nullptr; - PFNGLGENTEXTURESPROC glGenTextures = nullptr; - PFNGLGENVERTEXARRAYSPROC glGenVertexArrays = nullptr; - PFNGLGETACTIVEUNIFORMPROC glGetActiveUniform = nullptr; - PFNGLGETBOOLEANVPROC glGetBooleanv = nullptr; - PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv = nullptr; - PFNGLGETDEBUGMESSAGELOGPROC glGetDebugMessageLog = nullptr; - PFNGLGETERRORPROC glGetError = nullptr; - PFNGLGETFLOATVPROC glGetFloatv = nullptr; - PFNGLGETINTEGERVPROC glGetIntegerv = nullptr; - PFNGLGETPROGRAMBINARYPROC glGetProgramBinary = nullptr; - PFNGLGETPROGRAMIVPROC glGetProgramiv = nullptr; - PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog = nullptr; - PFNGLGETQUERYIVPROC glGetQueryiv = nullptr; - PFNGLGETQUERYOBJECTIVPROC glGetQueryObjectiv = nullptr; - PFNGLGETQUERYOBJECTUIVPROC glGetQueryObjectuiv = nullptr; - PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog = nullptr; - PFNGLGETSHADERIVPROC glGetShaderiv = nullptr; - PFNGLGETSHADERSOURCEPROC glGetShaderSource = nullptr; - PFNGLGETSTRINGPROC glGetString = nullptr; - PFNGLGETSTRINGIPROC glGetStringi = nullptr; - PFNGLGETTEXIMAGEPROC glGetTexImage = nullptr; - PFNGLGETTEXLEVELPARAMETERFVPROC glGetTexLevelParameterfv = nullptr; - PFNGLGETTEXLEVELPARAMETERIVPROC glGetTexLevelParameteriv = nullptr; - PFNGLGETTEXPARAMETERFVPROC glGetTexParameterfv = nullptr; - PFNGLGETTEXPARAMETERIVPROC glGetTexParameteriv = nullptr; - PFNGLGETUNIFORMFVPROC glGetUniformfv = nullptr; - PFNGLGETUNIFORMIVPROC glGetUniformiv = nullptr; - PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation = nullptr; - PFNGLINVALIDATEBUFFERDATAPROC glInvalidateBufferData = nullptr; - PFNGLISENABLEDPROC glIsEnabled = nullptr; - PFNGLLINEWIDTHPROC glLineWidth = nullptr; - PFNGLLINKPROGRAMPROC glLinkProgram = nullptr; - PFNGLMAPBUFFERPROC glMapBuffer = nullptr; - PFNGLMAPBUFFERRANGEPROC glMapBufferRange = nullptr; - PFNGLPIXELSTOREIPROC glPixelStorei = nullptr; - PFNGLPOINTSIZEPROC glPointSize = nullptr; - PFNGLPOLYGONMODEPROC glPolygonMode = nullptr; - PFNGLPROGRAMBINARYPROC glProgramBinary = nullptr; - PFNGLPROGRAMPARAMETERIPROC glProgramParameteri = nullptr; - PFNGLPROGRAMUNIFORM1DPROC glProgramUniform1d = nullptr; - PFNGLPROGRAMUNIFORM1FPROC glProgramUniform1f = nullptr; - PFNGLPROGRAMUNIFORM1IPROC glProgramUniform1i = nullptr; - PFNGLPROGRAMUNIFORM1DVPROC glProgramUniform1dv = nullptr; - PFNGLPROGRAMUNIFORM1FVPROC glProgramUniform1fv = nullptr; - PFNGLPROGRAMUNIFORM1IVPROC glProgramUniform1iv = nullptr; - PFNGLPROGRAMUNIFORM2DVPROC glProgramUniform2dv = nullptr; - PFNGLPROGRAMUNIFORM2FVPROC glProgramUniform2fv = nullptr; - PFNGLPROGRAMUNIFORM2IVPROC glProgramUniform2iv = nullptr; - PFNGLPROGRAMUNIFORM3DVPROC glProgramUniform3dv = nullptr; - PFNGLPROGRAMUNIFORM3FVPROC glProgramUniform3fv = nullptr; - PFNGLPROGRAMUNIFORM3IVPROC glProgramUniform3iv = nullptr; - PFNGLPROGRAMUNIFORM4DVPROC glProgramUniform4dv = nullptr; - PFNGLPROGRAMUNIFORM4FVPROC glProgramUniform4fv = nullptr; - PFNGLPROGRAMUNIFORM4IVPROC glProgramUniform4iv = nullptr; - PFNGLPROGRAMUNIFORMMATRIX4DVPROC glProgramUniformMatrix4dv = nullptr; - PFNGLPROGRAMUNIFORMMATRIX4FVPROC glProgramUniformMatrix4fv = nullptr; - PFNGLREADPIXELSPROC glReadPixels = nullptr; - PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage = nullptr; - PFNGLSAMPLERPARAMETERFPROC glSamplerParameterf = nullptr; - PFNGLSAMPLERPARAMETERIPROC glSamplerParameteri = nullptr; - PFNGLSCISSORPROC glScissor = nullptr; - PFNGLSHADERSOURCEPROC glShaderSource = nullptr; - PFNGLSTENCILFUNCPROC glStencilFunc = nullptr; - PFNGLSTENCILFUNCSEPARATEPROC glStencilFuncSeparate = nullptr; - PFNGLSTENCILOPPROC glStencilOp = nullptr; - PFNGLSTENCILOPSEPARATEPROC glStencilOpSeparate = nullptr; - PFNGLTEXIMAGE1DPROC glTexImage1D = nullptr; - PFNGLTEXIMAGE2DPROC glTexImage2D = nullptr; - PFNGLTEXIMAGE3DPROC glTexImage3D = nullptr; - PFNGLTEXPARAMETERFPROC glTexParameterf = nullptr; - PFNGLTEXPARAMETERIPROC glTexParameteri = nullptr; - PFNGLTEXSTORAGE1DPROC glTexStorage1D = nullptr; - PFNGLTEXSTORAGE2DPROC glTexStorage2D = nullptr; - PFNGLTEXSTORAGE3DPROC glTexStorage3D = nullptr; - PFNGLTEXSUBIMAGE1DPROC glTexSubImage1D = nullptr; - PFNGLTEXSUBIMAGE2DPROC glTexSubImage2D = nullptr; - PFNGLTEXSUBIMAGE3DPROC glTexSubImage3D = nullptr; - PFNGLUNIFORM1DPROC glUniform1d = nullptr; - PFNGLUNIFORM1FPROC glUniform1f = nullptr; - PFNGLUNIFORM1IPROC glUniform1i = nullptr; - PFNGLUNIFORM1DVPROC glUniform1dv = nullptr; - PFNGLUNIFORM1FVPROC glUniform1fv = nullptr; - PFNGLUNIFORM1IVPROC glUniform1iv = nullptr; - PFNGLUNIFORM2DVPROC glUniform2dv = nullptr; - PFNGLUNIFORM2FVPROC glUniform2fv = nullptr; - PFNGLUNIFORM2IVPROC glUniform2iv = nullptr; - PFNGLUNIFORM3DVPROC glUniform3dv = nullptr; - PFNGLUNIFORM3FVPROC glUniform3fv = nullptr; - PFNGLUNIFORM3IVPROC glUniform3iv = nullptr; - PFNGLUNIFORM4DVPROC glUniform4dv = nullptr; - PFNGLUNIFORM4FVPROC glUniform4fv = nullptr; - PFNGLUNIFORM4IVPROC glUniform4iv = nullptr; - PFNGLUNIFORMMATRIX4DVPROC glUniformMatrix4dv = nullptr; - PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv = nullptr; - PFNGLUNMAPBUFFERPROC glUnmapBuffer = nullptr; - PFNGLUSEPROGRAMPROC glUseProgram = nullptr; - PFNGLVALIDATEPROGRAMPROC glValidateProgram = nullptr; - PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f = nullptr; - PFNGLVERTEXATTRIBDIVISORPROC glVertexAttribDivisor = nullptr; - PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer = nullptr; - PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer = nullptr; - PFNGLVERTEXATTRIBLPOINTERPROC glVertexAttribLPointer = nullptr; - PFNGLVIEWPORTPROC glViewport = nullptr; +PFNGLACTIVETEXTUREPROC glActiveTexture = nullptr; +PFNGLATTACHSHADERPROC glAttachShader = nullptr; +PFNGLBEGINCONDITIONALRENDERPROC glBeginConditionalRender = nullptr; +PFNGLBEGINQUERYPROC glBeginQuery = nullptr; +PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation = nullptr; +PFNGLBINDBUFFERPROC glBindBuffer = nullptr; +PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer = nullptr; +PFNGLBINDFRAGDATALOCATIONPROC glBindFragDataLocation = nullptr; +PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer = nullptr; +PFNGLBINDSAMPLERPROC glBindSampler = nullptr; +PFNGLBINDTEXTUREPROC glBindTexture = nullptr; +PFNGLBINDVERTEXARRAYPROC glBindVertexArray = nullptr; +PFNGLBLENDFUNCPROC glBlendFunc = nullptr; +PFNGLBLENDFUNCSEPARATEPROC glBlendFuncSeparate = nullptr; +PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer = nullptr; +PFNGLBUFFERDATAPROC glBufferData = nullptr; +PFNGLBUFFERSUBDATAPROC glBufferSubData = nullptr; +PFNGLCLEARPROC glClear = nullptr; +PFNGLCLEARCOLORPROC glClearColor = nullptr; +PFNGLCLEARDEPTHPROC glClearDepth = nullptr; +PFNGLCLEARSTENCILPROC glClearStencil = nullptr; +PFNGLCREATEPROGRAMPROC glCreateProgram = nullptr; +PFNGLCREATESHADERPROC glCreateShader = nullptr; +PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus = nullptr; +PFNGLCOLORMASKPROC glColorMask = nullptr; +PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glCompressedTexSubImage1D = nullptr; +PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glCompressedTexSubImage2D = nullptr; +PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glCompressedTexSubImage3D = nullptr; +PFNGLCULLFACEPROC glCullFace = nullptr; +PFNGLCOMPILESHADERPROC glCompileShader = nullptr; +PFNGLCOPYTEXSUBIMAGE2DPROC glCopyTexSubImage2D = nullptr; +PFNGLDEBUGMESSAGECALLBACKPROC glDebugMessageCallback = nullptr; +PFNGLDEBUGMESSAGECONTROLPROC glDebugMessageControl = nullptr; +PFNGLDEBUGMESSAGEINSERTPROC glDebugMessageInsert = nullptr; +PFNGLDELETEBUFFERSPROC glDeleteBuffers = nullptr; +PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers = nullptr; +PFNGLDELETEPROGRAMPROC glDeleteProgram = nullptr; +PFNGLDELETEQUERIESPROC glDeleteQueries = nullptr; +PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers = nullptr; +PFNGLDELETESAMPLERSPROC glDeleteSamplers = nullptr; +PFNGLDELETESHADERPROC glDeleteShader = nullptr; +PFNGLDELETETEXTURESPROC glDeleteTextures = nullptr; +PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays = nullptr; +PFNGLDEPTHFUNCPROC glDepthFunc = nullptr; +PFNGLDEPTHMASKPROC glDepthMask = nullptr; +PFNGLDISABLEPROC glDisable = nullptr; +PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray = nullptr; +PFNGLDRAWARRAYSPROC glDrawArrays = nullptr; +PFNGLDRAWARRAYSINSTANCEDPROC glDrawArraysInstanced = nullptr; +PFNGLDRAWBUFFERPROC glDrawBuffer = nullptr; +PFNGLDRAWBUFFERSPROC glDrawBuffers = nullptr; +PFNGLDRAWELEMENTSPROC glDrawElements = nullptr; +PFNGLDRAWELEMENTSINSTANCEDPROC glDrawElementsInstanced = nullptr; +PFNGLDRAWTEXTURENVPROC glDrawTexture = nullptr; +PFNGLENABLEPROC glEnable = nullptr; +PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray = nullptr; +PFNGLENDCONDITIONALRENDERPROC glEndConditionalRender = nullptr; +PFNGLENDQUERYPROC glEndQuery = nullptr; +PFNGLFLUSHPROC glFlush = nullptr; +PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer = nullptr; +PFNGLFRAMEBUFFERTEXTUREPROC glFramebufferTexture = nullptr; +PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D = nullptr; +PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D = nullptr; +PFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D = nullptr; +PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer = nullptr; +PFNGLGENERATEMIPMAPPROC glGenerateMipmap = nullptr; +PFNGLGENBUFFERSPROC glGenBuffers = nullptr; +PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers = nullptr; +PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers = nullptr; +PFNGLGENQUERIESPROC glGenQueries = nullptr; +PFNGLGENSAMPLERSPROC glGenSamplers = nullptr; +PFNGLGENTEXTURESPROC glGenTextures = nullptr; +PFNGLGENVERTEXARRAYSPROC glGenVertexArrays = nullptr; +PFNGLGETACTIVEUNIFORMPROC glGetActiveUniform = nullptr; +PFNGLGETBOOLEANVPROC glGetBooleanv = nullptr; +PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv = nullptr; +PFNGLGETDEBUGMESSAGELOGPROC glGetDebugMessageLog = nullptr; +PFNGLGETERRORPROC glGetError = nullptr; +PFNGLGETFLOATVPROC glGetFloatv = nullptr; +PFNGLGETINTEGERVPROC glGetIntegerv = nullptr; +PFNGLGETPROGRAMBINARYPROC glGetProgramBinary = nullptr; +PFNGLGETPROGRAMIVPROC glGetProgramiv = nullptr; +PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog = nullptr; +PFNGLGETQUERYIVPROC glGetQueryiv = nullptr; +PFNGLGETQUERYOBJECTIVPROC glGetQueryObjectiv = nullptr; +PFNGLGETQUERYOBJECTUIVPROC glGetQueryObjectuiv = nullptr; +PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog = nullptr; +PFNGLGETSHADERIVPROC glGetShaderiv = nullptr; +PFNGLGETSHADERSOURCEPROC glGetShaderSource = nullptr; +PFNGLGETSTRINGPROC glGetString = nullptr; +PFNGLGETSTRINGIPROC glGetStringi = nullptr; +PFNGLGETTEXIMAGEPROC glGetTexImage = nullptr; +PFNGLGETTEXLEVELPARAMETERFVPROC glGetTexLevelParameterfv = nullptr; +PFNGLGETTEXLEVELPARAMETERIVPROC glGetTexLevelParameteriv = nullptr; +PFNGLGETTEXPARAMETERFVPROC glGetTexParameterfv = nullptr; +PFNGLGETTEXPARAMETERIVPROC glGetTexParameteriv = nullptr; +PFNGLGETUNIFORMFVPROC glGetUniformfv = nullptr; +PFNGLGETUNIFORMIVPROC glGetUniformiv = nullptr; +PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation = nullptr; +PFNGLINVALIDATEBUFFERDATAPROC glInvalidateBufferData = nullptr; +PFNGLISENABLEDPROC glIsEnabled = nullptr; +PFNGLLINEWIDTHPROC glLineWidth = nullptr; +PFNGLLINKPROGRAMPROC glLinkProgram = nullptr; +PFNGLMAPBUFFERPROC glMapBuffer = nullptr; +PFNGLMAPBUFFERRANGEPROC glMapBufferRange = nullptr; +PFNGLPIXELSTOREIPROC glPixelStorei = nullptr; +PFNGLPOINTSIZEPROC glPointSize = nullptr; +PFNGLPOLYGONMODEPROC glPolygonMode = nullptr; +PFNGLPROGRAMBINARYPROC glProgramBinary = nullptr; +PFNGLPROGRAMPARAMETERIPROC glProgramParameteri = nullptr; +PFNGLPROGRAMUNIFORM1DPROC glProgramUniform1d = nullptr; +PFNGLPROGRAMUNIFORM1FPROC glProgramUniform1f = nullptr; +PFNGLPROGRAMUNIFORM1IPROC glProgramUniform1i = nullptr; +PFNGLPROGRAMUNIFORM1DVPROC glProgramUniform1dv = nullptr; +PFNGLPROGRAMUNIFORM1FVPROC glProgramUniform1fv = nullptr; +PFNGLPROGRAMUNIFORM1IVPROC glProgramUniform1iv = nullptr; +PFNGLPROGRAMUNIFORM2DVPROC glProgramUniform2dv = nullptr; +PFNGLPROGRAMUNIFORM2FVPROC glProgramUniform2fv = nullptr; +PFNGLPROGRAMUNIFORM2IVPROC glProgramUniform2iv = nullptr; +PFNGLPROGRAMUNIFORM3DVPROC glProgramUniform3dv = nullptr; +PFNGLPROGRAMUNIFORM3FVPROC glProgramUniform3fv = nullptr; +PFNGLPROGRAMUNIFORM3IVPROC glProgramUniform3iv = nullptr; +PFNGLPROGRAMUNIFORM4DVPROC glProgramUniform4dv = nullptr; +PFNGLPROGRAMUNIFORM4FVPROC glProgramUniform4fv = nullptr; +PFNGLPROGRAMUNIFORM4IVPROC glProgramUniform4iv = nullptr; +PFNGLPROGRAMUNIFORMMATRIX4DVPROC glProgramUniformMatrix4dv = nullptr; +PFNGLPROGRAMUNIFORMMATRIX4FVPROC glProgramUniformMatrix4fv = nullptr; +PFNGLREADPIXELSPROC glReadPixels = nullptr; +PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage = nullptr; +PFNGLSAMPLERPARAMETERFPROC glSamplerParameterf = nullptr; +PFNGLSAMPLERPARAMETERIPROC glSamplerParameteri = nullptr; +PFNGLSCISSORPROC glScissor = nullptr; +PFNGLSHADERSOURCEPROC glShaderSource = nullptr; +PFNGLSTENCILFUNCPROC glStencilFunc = nullptr; +PFNGLSTENCILFUNCSEPARATEPROC glStencilFuncSeparate = nullptr; +PFNGLSTENCILOPPROC glStencilOp = nullptr; +PFNGLSTENCILOPSEPARATEPROC glStencilOpSeparate = nullptr; +PFNGLTEXIMAGE1DPROC glTexImage1D = nullptr; +PFNGLTEXIMAGE2DPROC glTexImage2D = nullptr; +PFNGLTEXIMAGE3DPROC glTexImage3D = nullptr; +PFNGLTEXPARAMETERFPROC glTexParameterf = nullptr; +PFNGLTEXPARAMETERIPROC glTexParameteri = nullptr; +PFNGLTEXSTORAGE1DPROC glTexStorage1D = nullptr; +PFNGLTEXSTORAGE2DPROC glTexStorage2D = nullptr; +PFNGLTEXSTORAGE3DPROC glTexStorage3D = nullptr; +PFNGLTEXSUBIMAGE1DPROC glTexSubImage1D = nullptr; +PFNGLTEXSUBIMAGE2DPROC glTexSubImage2D = nullptr; +PFNGLTEXSUBIMAGE3DPROC glTexSubImage3D = nullptr; +PFNGLUNIFORM1DPROC glUniform1d = nullptr; +PFNGLUNIFORM1FPROC glUniform1f = nullptr; +PFNGLUNIFORM1IPROC glUniform1i = nullptr; +PFNGLUNIFORM1DVPROC glUniform1dv = nullptr; +PFNGLUNIFORM1FVPROC glUniform1fv = nullptr; +PFNGLUNIFORM1IVPROC glUniform1iv = nullptr; +PFNGLUNIFORM2DVPROC glUniform2dv = nullptr; +PFNGLUNIFORM2FVPROC glUniform2fv = nullptr; +PFNGLUNIFORM2IVPROC glUniform2iv = nullptr; +PFNGLUNIFORM3DVPROC glUniform3dv = nullptr; +PFNGLUNIFORM3FVPROC glUniform3fv = nullptr; +PFNGLUNIFORM3IVPROC glUniform3iv = nullptr; +PFNGLUNIFORM4DVPROC glUniform4dv = nullptr; +PFNGLUNIFORM4FVPROC glUniform4fv = nullptr; +PFNGLUNIFORM4IVPROC glUniform4iv = nullptr; +PFNGLUNIFORMMATRIX4DVPROC glUniformMatrix4dv = nullptr; +PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv = nullptr; +PFNGLUNMAPBUFFERPROC glUnmapBuffer = nullptr; +PFNGLUSEPROGRAMPROC glUseProgram = nullptr; +PFNGLVALIDATEPROGRAMPROC glValidateProgram = nullptr; +PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f = nullptr; +PFNGLVERTEXATTRIBDIVISORPROC glVertexAttribDivisor = nullptr; +PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer = nullptr; +PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer = nullptr; +PFNGLVERTEXATTRIBLPOINTERPROC glVertexAttribLPointer = nullptr; +PFNGLVIEWPORTPROC glViewport = nullptr; + +#if defined(NAZARA_PLATFORM_WINDOWS) +PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormat = nullptr; +PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs = nullptr; +PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = nullptr; +PFNWGLGETEXTENSIONSSTRINGEXTPROC wglGetExtensionsStringEXT = nullptr; +PFNWGLSWAPINTERVALEXTPROC wglSwapInterval = nullptr; +#elif defined(NAZARA_PLATFORM_GLX) +GLX::PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs = nullptr; +GLX::PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT = nullptr; +GLX::PFNGLXSWAPINTERVALMESAPROC NzglXSwapIntervalMESA = nullptr; +GLX::PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI = nullptr; +#endif + } diff --git a/src/Nazara/Renderer/RenderWindow.cpp b/src/Nazara/Renderer/RenderWindow.cpp index 36e364508..22b7c0a95 100644 --- a/src/Nazara/Renderer/RenderWindow.cpp +++ b/src/Nazara/Renderer/RenderWindow.cpp @@ -234,7 +234,7 @@ namespace Nz bool RenderWindow::OnWindowCreated() { m_parameters.doubleBuffered = true; - m_parameters.window = GetHandle(); + m_parameters.window = GetSystemHandle(); std::unique_ptr context(new Context); if (!context->Create(m_parameters)) diff --git a/src/Nazara/Renderer/SDL2/ContextImpl.cpp b/src/Nazara/Renderer/SDL2/ContextImpl.cpp deleted file mode 100644 index 0a125e58f..000000000 --- a/src/Nazara/Renderer/SDL2/ContextImpl.cpp +++ /dev/null @@ -1,147 +0,0 @@ -// Copyright (C) 2017 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -// Code inspiré de NeHe (Lesson1) et de la SFML par Laurent Gomila - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - ContextImpl::ContextImpl() - { - } - - bool ContextImpl::Activate() const - { - bool success = SDL_GL_MakeCurrent(m_window, m_context) == 0; - - if (!success) - NazaraError(SDL_GetError()); - else - lastActive = m_window; - - return success; - } - - bool ContextImpl::Create(ContextParameters& parameters) - { - if (parameters.window) - { - m_window = static_cast(parameters.window); - m_ownsWindow = false; - } - else - { - m_window = SDL_CreateWindow("STATIC", 0, 0, 1, 1, SDL_WINDOW_OPENGL | SDL_WINDOW_HIDDEN); - if (!m_window) - { - NazaraError("Failed to create window"); - return false; - } - - //SDL_HideWindow(m_window); - m_ownsWindow = true; - } - - // En cas d'exception, la ressource sera quand même libérée - CallOnExit onExit([this] () - { - Destroy(); - }); - - - bool valid = true; - - std::array, 13> attributes{ - std::pair - {SDL_GL_CONTEXT_PROFILE_MASK, parameters.compatibilityProfile ? SDL_GL_CONTEXT_PROFILE_COMPATIBILITY : SDL_GL_CONTEXT_PROFILE_CORE}, - {SDL_GL_CONTEXT_MAJOR_VERSION, parameters.majorVersion}, - {SDL_GL_CONTEXT_MINOR_VERSION, parameters.minorVersion}, - {SDL_GL_CONTEXT_FLAGS, parameters.debugMode ? SDL_GL_CONTEXT_DEBUG_FLAG : 0}, - {SDL_GL_SHARE_WITH_CURRENT_CONTEXT, true}, - {SDL_GL_RED_SIZE, (parameters.bitsPerPixel == 32) ? 8 : parameters.bitsPerPixel / 3}, // sad but I don't have a solution for now - {SDL_GL_GREEN_SIZE, (parameters.bitsPerPixel == 32) ? 8 : parameters.bitsPerPixel / 3}, - {SDL_GL_BLUE_SIZE, (parameters.bitsPerPixel == 32) ? 8 : parameters.bitsPerPixel / 3}, - {SDL_GL_ALPHA_SIZE, (parameters.bitsPerPixel == 32) ? 8 : 0}, - {SDL_GL_DEPTH_SIZE, parameters.depthBits}, - {SDL_GL_STENCIL_SIZE, parameters.stencilBits}, - //{SDL_GL_DOUBLEBUFFER, parameters.doubleBuffered}, // doesn't work if we dont close all windows - {SDL_GL_MULTISAMPLEBUFFERS, parameters.antialiasingLevel > 0 ? GL_TRUE : GL_FALSE}, - {SDL_GL_MULTISAMPLESAMPLES, parameters.antialiasingLevel} - }; - - for (const auto& attribute : attributes) { - valid &= SDL_GL_SetAttribute(attribute.first, attribute.second) == 0; - - if (!valid) { - NazaraWarning(SDL_GetError()); - break; - } - } - - if (!valid) - NazaraWarning("Could not find a format matching requirements, disabling antialiasing..."); - - int antialiasingLevel; - SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &antialiasingLevel); - - parameters.antialiasingLevel = static_cast(antialiasingLevel); - - - onExit.Reset(); - - m_context = SDL_GL_CreateContext(m_window); - - if (!m_context) { - NazaraError(SDL_GetError()); - - return false; - } - - return true; - } - - void ContextImpl::Destroy() - { - if (m_context) - { - SDL_GL_DeleteContext(m_context); - m_context = nullptr; - } - - if (m_ownsWindow) - { - SDL_DestroyWindow(m_window); - m_window = nullptr; - } - } - - void ContextImpl::EnableVerticalSync(bool enabled) - { - - if (SDL_GL_SetSwapInterval(enabled ? 1 : 0) != 0) - NazaraError("Vertical sync not supported"); - } - - void ContextImpl::SwapBuffers() - { - SDL_GL_SwapWindow(m_window); - } - - bool ContextImpl::Desactivate() - { - return SDL_GL_MakeCurrent(nullptr, nullptr) == 0; - } - - SDL_Window* ContextImpl::lastActive = nullptr; -} diff --git a/src/Nazara/Renderer/Win32/ContextImpl.cpp b/src/Nazara/Renderer/Win32/ContextImpl.cpp new file mode 100644 index 000000000..71aa5f1e1 --- /dev/null +++ b/src/Nazara/Renderer/Win32/ContextImpl.cpp @@ -0,0 +1,248 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +// Code inspiré de NeHe (Lesson1) et de la SFML par Laurent Gomila + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + ContextImpl::ContextImpl() = default; + + bool ContextImpl::Activate() const + { + return wglMakeCurrent(m_deviceContext, m_context) == TRUE; + } + + bool ContextImpl::Create(ContextParameters& parameters) + { + if (parameters.window.type != WindowManager::None) + { + NazaraAssert(parameters.window.type == WindowManager::Windows, "Cannot create a context for a non-win32 window"); + + m_window = static_cast(parameters.window.windows.window); + m_ownsWindow = false; + } + else + { + m_window = CreateWindowA("STATIC", nullptr, WS_DISABLED | WS_POPUP, 0, 0, 1, 1, nullptr, nullptr, GetModuleHandle(nullptr), nullptr); + if (!m_window) + { + NazaraError("Failed to create window"); + return false; + } + + ShowWindow(m_window, SW_HIDE); + m_ownsWindow = true; + } + + // En cas d'exception, la ressource sera quand même libérée + CallOnExit onExit([this] () + { + Destroy(); + }); + + m_deviceContext = GetDC(m_window); + if (!m_deviceContext) + { + NazaraError("Failed to get device context"); + return false; + } + + int pixelFormat = 0; + if (parameters.antialiasingLevel > 0) + { + if (wglChoosePixelFormat) + { + bool valid; + UINT numFormats; + + int attributes[] = { + WGL_DRAW_TO_WINDOW_ARB, GL_TRUE, + WGL_SUPPORT_OPENGL_ARB, GL_TRUE, + WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB, + WGL_COLOR_BITS_ARB, (parameters.bitsPerPixel == 32) ? 24 : parameters.bitsPerPixel, + WGL_ALPHA_BITS_ARB, (parameters.bitsPerPixel == 32) ? 8 : 0, + WGL_DEPTH_BITS_ARB, parameters.depthBits, + WGL_STENCIL_BITS_ARB, parameters.stencilBits, + WGL_DOUBLE_BUFFER_ARB, (parameters.doubleBuffered) ? GL_TRUE : GL_FALSE, + WGL_SAMPLE_BUFFERS_ARB, GL_TRUE, + WGL_SAMPLES_ARB, parameters.antialiasingLevel, + 0, 0 + }; + + do + { + valid = (wglChoosePixelFormat(m_deviceContext, attributes, nullptr, 1, &pixelFormat, &numFormats) == TRUE); + } + while ((!valid || numFormats == 0) && --attributes[19] > 0); + + if (!valid) + { + NazaraWarning("Could not find a format matching requirements, disabling antialiasing..."); + pixelFormat = 0; + } + + parameters.antialiasingLevel = attributes[19]; + } + else + { + NazaraWarning("Antialiasing is not supported"); + parameters.antialiasingLevel = 0; + } + } + + PIXELFORMATDESCRIPTOR descriptor; + ZeroMemory(&descriptor, sizeof(PIXELFORMATDESCRIPTOR)); + descriptor.nSize = sizeof(PIXELFORMATDESCRIPTOR); + descriptor.nVersion = 1; + + if (pixelFormat == 0) + { + descriptor.cColorBits = parameters.bitsPerPixel; + descriptor.cDepthBits = parameters.depthBits; + descriptor.cStencilBits = parameters.stencilBits; + descriptor.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL; + descriptor.iPixelType = PFD_TYPE_RGBA; + + if (parameters.bitsPerPixel == 32) + descriptor.cAlphaBits = 8; + + if (parameters.doubleBuffered) + descriptor.dwFlags |= PFD_DOUBLEBUFFER; + + pixelFormat = ChoosePixelFormat(m_deviceContext, &descriptor); + if (pixelFormat == 0) + { + NazaraError("Failed to choose pixel format"); + return false; + } + } + + if (!SetPixelFormat(m_deviceContext, pixelFormat, &descriptor)) + { + NazaraError("Failed to set pixel format"); + return false; + } + + // Arrivé ici, le format de pixel est choisi, nous récupérons donc les paramètres réels du futur contexte + if (DescribePixelFormat(m_deviceContext, pixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &descriptor) != 0) + { + parameters.bitsPerPixel = descriptor.cColorBits + descriptor.cAlphaBits; + parameters.depthBits = descriptor.cDepthBits; + parameters.stencilBits = descriptor.cDepthBits; + } + else + NazaraWarning("Failed to get context's parameters"); + + HGLRC shareContext = (parameters.shared) ? static_cast(parameters.shareContext->m_impl)->m_context : nullptr; + + m_context = nullptr; + if (wglCreateContextAttribs) + { + int attributes[4*2+1]; + int* attrib = attributes; + + *attrib++ = WGL_CONTEXT_MAJOR_VERSION_ARB; + *attrib++ = parameters.majorVersion; + + *attrib++ = WGL_CONTEXT_MINOR_VERSION_ARB; + *attrib++ = parameters.minorVersion; + + if (parameters.majorVersion >= 3) + { + *attrib++ = WGL_CONTEXT_PROFILE_MASK_ARB; + *attrib++ = (parameters.compatibilityProfile) ? WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB : WGL_CONTEXT_CORE_PROFILE_BIT_ARB; + + // Les contextes forward-compatible ne sont plus utilisés pour cette raison : + // http://www.opengl.org/discussion_boards/showthread.php/175052-Forward-compatible-vs-Core-profile + } + + if (parameters.debugMode) + { + *attrib++ = WGL_CONTEXT_FLAGS_ARB; + *attrib++ = WGL_CONTEXT_DEBUG_BIT_ARB; + } + + *attrib++ = 0; + + m_context = wglCreateContextAttribs(m_deviceContext, shareContext, attributes); + } + + if (!m_context) + { + m_context = wglCreateContext(m_deviceContext); + + if (shareContext) + { + // wglShareLists n'est pas thread-safe (source: SFML) + static Mutex mutex; + LockGuard lock(mutex); + + if (!wglShareLists(shareContext, m_context)) + NazaraWarning("Failed to share the context: " + Error::GetLastSystemError()); + } + } + + if (!m_context) + { + NazaraError("Failed to create context"); + return false; + } + + onExit.Reset(); + + return true; + } + + void ContextImpl::Destroy() + { + if (m_context) + { + if (wglGetCurrentContext() == m_context) + wglMakeCurrent(nullptr, nullptr); + + wglDeleteContext(m_context); + m_context = nullptr; + } + + if (m_deviceContext) + { + ReleaseDC(m_window, m_deviceContext); + m_deviceContext = nullptr; + } + + if (m_ownsWindow) + { + DestroyWindow(m_window); + m_window = nullptr; + } + } + + void ContextImpl::EnableVerticalSync(bool enabled) + { + if (wglSwapInterval) + wglSwapInterval(enabled ? 1 : 0); + else + NazaraError("Vertical sync not supported"); + } + + void ContextImpl::SwapBuffers() + { + ::SwapBuffers(m_deviceContext); + } + + bool ContextImpl::Desactivate() + { + return wglMakeCurrent(nullptr, nullptr) == TRUE; + } +} diff --git a/src/Nazara/Renderer/SDL2/ContextImpl.hpp b/src/Nazara/Renderer/Win32/ContextImpl.hpp similarity index 85% rename from src/Nazara/Renderer/SDL2/ContextImpl.hpp rename to src/Nazara/Renderer/Win32/ContextImpl.hpp index ae1f620a1..b3cf0d053 100644 --- a/src/Nazara/Renderer/SDL2/ContextImpl.hpp +++ b/src/Nazara/Renderer/Win32/ContextImpl.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include namespace Nz { @@ -31,11 +31,10 @@ namespace Nz static bool Desactivate(); private: - SDL_GLContext m_context; - SDL_Window* m_window; + HDC m_deviceContext; + HGLRC m_context; + HWND m_window; bool m_ownsWindow; - - static SDL_Window* lastActive; }; } From e0e7435c5541aeafc9f5ac348115d652132da308 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 27 May 2020 20:03:46 +0200 Subject: [PATCH 217/316] Merge fixes --- examples/VulkanTest/main.cpp | 14 +++---- include/Nazara/Renderer/RenderWindow.hpp | 4 +- include/Nazara/Renderer/RenderWindow.inl | 4 +- src/Nazara/OpenGLRenderer/DummySurface.cpp | 2 +- .../Wrapper/Win32/WGLContext.cpp | 13 ++++++- src/Nazara/Platform/SDL2/CursorImpl.cpp | 2 +- src/Nazara/Platform/SDL2/IconImpl.cpp | 2 +- src/Nazara/Platform/SDL2/WindowImpl.cpp | 3 -- src/Nazara/Renderer/RenderWindow.cpp | 39 +++++++++---------- src/Nazara/Renderer/Renderer.cpp | 1 + src/Nazara/VulkanRenderer/VulkanSurface.cpp | 4 +- 11 files changed, 48 insertions(+), 40 deletions(-) diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index c777a65b2..bfda1e2b2 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -3,7 +3,7 @@ #include #include -#define SPIRV 0 +#define SPIRV 1 int main() { @@ -266,27 +266,27 @@ int main() float cameraSpeed = 2.f * updateClock.GetSeconds(); updateClock.Restart(); - if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Up) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Z)) + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::Up) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::Z)) viewerPos += camQuat * Nz::Vector3f::Forward() * cameraSpeed; // Si la flèche du bas ou la touche S est pressée, on recule - if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Down) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::S)) + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::Down) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::S)) viewerPos += camQuat * Nz::Vector3f::Backward() * cameraSpeed; // Etc... - if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Left) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Q)) + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::Left) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::Q)) viewerPos += camQuat * Nz::Vector3f::Left() * cameraSpeed; // Etc... - if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::Right) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::D)) + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::Right) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::D)) viewerPos += camQuat * Nz::Vector3f::Right() * cameraSpeed; // Majuscule pour monter, notez l'utilisation d'une direction globale (Non-affectée par la rotation) - if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::LShift) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::RShift)) + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::LShift) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::RShift)) viewerPos += Nz::Vector3f::Up() * cameraSpeed; // Contrôle (Gauche ou droite) pour descendre dans l'espace global, etc... - if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::LControl) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::RControl)) + if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::LControl) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::RControl)) viewerPos += Nz::Vector3f::Down() * cameraSpeed; } diff --git a/include/Nazara/Renderer/RenderWindow.hpp b/include/Nazara/Renderer/RenderWindow.hpp index c7ce97ffd..0d3521a00 100644 --- a/include/Nazara/Renderer/RenderWindow.hpp +++ b/include/Nazara/Renderer/RenderWindow.hpp @@ -26,11 +26,11 @@ namespace Nz public: inline RenderWindow(); inline RenderWindow(VideoMode mode, const String &title, WindowStyleFlags style = WindowStyle_Default, const RenderWindowParameters ¶meters = RenderWindowParameters()); - inline explicit RenderWindow(void *handle, const RenderWindowParameters ¶meters = RenderWindowParameters()); + inline explicit RenderWindow(void* handle, const RenderWindowParameters ¶meters = RenderWindowParameters()); inline ~RenderWindow(); inline bool Create(VideoMode mode, const String &title, WindowStyleFlags style = WindowStyle_Default, const RenderWindowParameters ¶meters = RenderWindowParameters()); - inline bool Create(void *handle, const RenderWindowParameters ¶meters = RenderWindowParameters()); + inline bool Create(void* handle, const RenderWindowParameters ¶meters = RenderWindowParameters()); void Display(); diff --git a/include/Nazara/Renderer/RenderWindow.inl b/include/Nazara/Renderer/RenderWindow.inl index 7b926ce55..6b868a3b6 100644 --- a/include/Nazara/Renderer/RenderWindow.inl +++ b/include/Nazara/Renderer/RenderWindow.inl @@ -20,7 +20,7 @@ namespace Nz Create(mode, title, style, parameters); } - inline RenderWindow::RenderWindow(WindowHandle handle, const RenderWindowParameters& parameters) + inline RenderWindow::RenderWindow(void* handle, const RenderWindowParameters& parameters) { ErrorFlags errFlags(ErrorFlag_ThrowException, true); @@ -39,7 +39,7 @@ namespace Nz return Window::Create(mode, title, style); } - inline bool RenderWindow::Create(WindowHandle handle, const RenderWindowParameters& parameters) + inline bool RenderWindow::Create(void* handle, const RenderWindowParameters& parameters) { m_parameters = parameters; diff --git a/src/Nazara/OpenGLRenderer/DummySurface.cpp b/src/Nazara/OpenGLRenderer/DummySurface.cpp index ec74f480e..b35e1a6d7 100644 --- a/src/Nazara/OpenGLRenderer/DummySurface.cpp +++ b/src/Nazara/OpenGLRenderer/DummySurface.cpp @@ -15,6 +15,6 @@ namespace Nz void DummySurface::Destroy() { - m_handle = nullptr; + m_handle = WindowHandle{}; } } diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp index 1593cef1c..c5faa2bfa 100644 --- a/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp +++ b/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp @@ -29,12 +29,21 @@ namespace Nz::GL ::ShowWindow(m_window.get(), FALSE); - return Create(baseContext, params, m_window.get(), shareContext); + m_deviceContext = ::GetDC(m_window.get()); + if (!m_deviceContext) + { + NazaraError("failed to retrieve dummy window device context: " + Error::GetLastSystemError()); + return false; + } + + return CreateInternal(baseContext, params, shareContext); } bool WGLContext::Create(const WGLContext* baseContext, const ContextParams& params, WindowHandle window, const WGLContext* shareContext) { - m_deviceContext = ::GetDC(static_cast(window)); + NazaraAssert(window.type == WindowManager::Windows, "expected Windows window"); + + m_deviceContext = ::GetDC(static_cast(window.windows.window)); if (!m_deviceContext) { NazaraError("failed to retrieve window device context: " + Error::GetLastSystemError()); diff --git a/src/Nazara/Platform/SDL2/CursorImpl.cpp b/src/Nazara/Platform/SDL2/CursorImpl.cpp index c9497a2e8..60ddd4bd4 100644 --- a/src/Nazara/Platform/SDL2/CursorImpl.cpp +++ b/src/Nazara/Platform/SDL2/CursorImpl.cpp @@ -13,7 +13,7 @@ namespace Nz bool CursorImpl::Create(const Image& cursor, int hotSpotX, int hotSpotY) { m_iconImage = cursor; - if (!m_iconImage.Convert(PixelFormatType_BGRA8)) + if (!m_iconImage.Convert(PixelFormat_BGRA8)) { NazaraError("Failed to convert icon to BGRA8"); return false; diff --git a/src/Nazara/Platform/SDL2/IconImpl.cpp b/src/Nazara/Platform/SDL2/IconImpl.cpp index b802b1176..50d1dff42 100644 --- a/src/Nazara/Platform/SDL2/IconImpl.cpp +++ b/src/Nazara/Platform/SDL2/IconImpl.cpp @@ -12,7 +12,7 @@ namespace Nz bool IconImpl::Create(const Image& icon) { m_iconImage = icon; - if (!m_iconImage.Convert(PixelFormatType_BGRA8)) + if (!m_iconImage.Convert(PixelFormat_BGRA8)) { NazaraError("Failed to convert icon to BGRA8"); return false; diff --git a/src/Nazara/Platform/SDL2/WindowImpl.cpp b/src/Nazara/Platform/SDL2/WindowImpl.cpp index acbbc8382..20cd731df 100644 --- a/src/Nazara/Platform/SDL2/WindowImpl.cpp +++ b/src/Nazara/Platform/SDL2/WindowImpl.cpp @@ -4,11 +4,8 @@ #include #include -#include #include #include -#include -#include #include #include #include diff --git a/src/Nazara/Renderer/RenderWindow.cpp b/src/Nazara/Renderer/RenderWindow.cpp index 03b475804..a03cf295c 100644 --- a/src/Nazara/Renderer/RenderWindow.cpp +++ b/src/Nazara/Renderer/RenderWindow.cpp @@ -40,7 +40,7 @@ namespace Nz { RendererImpl *rendererImpl = Renderer::GetRendererImpl(); auto surface = rendererImpl->CreateRenderSurfaceImpl(); - if (!surface->Create(GetHandle())) + if (!surface->Create(GetSystemHandle())) { NazaraError("Failed to create render surface: " + Error::GetLastError()); return false; @@ -49,26 +49,25 @@ namespace Nz auto impl = rendererImpl->CreateRenderWindowImpl(); if (!impl->Create(rendererImpl, surface.get(), GetSize(), m_parameters)) { - { - NazaraError("Failed to create render window implementation: " + Error::GetLastError()); - return false; - } - - m_impl = std::move(impl); - m_surface = std::move(surface); - - m_clock.Restart(); - - return true; + NazaraError("Failed to create render window implementation: " + Error::GetLastError()); + return false; } - void RenderWindow::OnWindowDestroy() - { - m_impl.reset(); - m_surface.reset(); - } + m_impl = std::move(impl); + m_surface = std::move(surface); - void RenderWindow::OnWindowResized() - { - } + m_clock.Restart(); + + return true; } + + void RenderWindow::OnWindowDestroy() + { + m_impl.reset(); + m_surface.reset(); + } + + void RenderWindow::OnWindowResized() + { + } +} diff --git a/src/Nazara/Renderer/Renderer.cpp b/src/Nazara/Renderer/Renderer.cpp index 477a340f3..6954f5cf0 100644 --- a/src/Nazara/Renderer/Renderer.cpp +++ b/src/Nazara/Renderer/Renderer.cpp @@ -110,6 +110,7 @@ namespace Nz chosenImpl = std::move(impl); //< Move (and delete previous) implementation before unloading library chosenLib = std::move(implLib); + break; } if (!chosenImpl) diff --git a/src/Nazara/VulkanRenderer/VulkanSurface.cpp b/src/Nazara/VulkanRenderer/VulkanSurface.cpp index fbb9e0ff7..a114b12ca 100644 --- a/src/Nazara/VulkanRenderer/VulkanSurface.cpp +++ b/src/Nazara/VulkanRenderer/VulkanSurface.cpp @@ -18,7 +18,9 @@ namespace Nz bool success = false; #if defined(NAZARA_PLATFORM_WINDOWS) { - HWND winHandle = reinterpret_cast(handle); + NazaraAssert(handle.type == WindowManager::Windows, "expected Windows window"); + + HWND winHandle = reinterpret_cast(handle.windows.window); HINSTANCE instance = reinterpret_cast(GetWindowLongPtrW(winHandle, GWLP_HINSTANCE)); success = m_surface.Create(instance, winHandle); From 3fc4de26e3d2d5b0a040104fbee52a2ec30c2168 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 27 May 2020 20:08:41 +0200 Subject: [PATCH 218/316] ShaderGraph: Improve GLSL generation by introducing DeclareVariable statement --- include/Nazara/Renderer/GlslWriter.hpp | 2 +- include/Nazara/Renderer/ShaderAst.hpp | 12 ++++++++++ include/Nazara/Renderer/ShaderAst.inl | 6 +++++ include/Nazara/Renderer/ShaderBuilder.hpp | 7 +++--- include/Nazara/Renderer/ShaderBuilder.inl | 2 +- include/Nazara/Renderer/ShaderWriter.hpp | 1 + src/Nazara/Renderer/GlslWriter.cpp | 27 ++++++++++++++--------- src/Nazara/Renderer/ShaderAst.cpp | 13 +++++++++++ src/ShaderNode/ShaderGraph.cpp | 7 +++--- 9 files changed, 59 insertions(+), 18 deletions(-) diff --git a/include/Nazara/Renderer/GlslWriter.hpp b/include/Nazara/Renderer/GlslWriter.hpp index d4042e882..13d7c8459 100644 --- a/include/Nazara/Renderer/GlslWriter.hpp +++ b/include/Nazara/Renderer/GlslWriter.hpp @@ -37,6 +37,7 @@ namespace Nz void Write(const ShaderAst::BuiltinVariable& node) override; void Write(const ShaderAst::Cast& node) override; void Write(const ShaderAst::Constant& node) override; + void Write(const ShaderAst::DeclareVariable& node) override; void Write(const ShaderAst::ExpressionStatement& node) override; void Write(const ShaderAst::NamedVariable& node) override; void Write(const ShaderAst::NodePtr& node) override; @@ -63,7 +64,6 @@ namespace Nz struct Function { - VariableContainer variables; std::vector parameters; ShaderAst::ExpressionType retType; ShaderAst::StatementPtr node; diff --git a/include/Nazara/Renderer/ShaderAst.hpp b/include/Nazara/Renderer/ShaderAst.hpp index dfe7639e4..28b808d6c 100644 --- a/include/Nazara/Renderer/ShaderAst.hpp +++ b/include/Nazara/Renderer/ShaderAst.hpp @@ -193,6 +193,18 @@ namespace Nz Nz::String name; }; + + class NAZARA_RENDERER_API DeclareVariable : public Statement + { + public: + inline DeclareVariable(NamedVariablePtr Variable, ExpressionPtr Expression = nullptr); + + void Register(ShaderWriter& visitor) override; + void Visit(ShaderWriter& visitor) override; + + NamedVariablePtr variable; + ExpressionPtr expression; + }; ////////////////////////////////////////////////////////////////////////// diff --git a/include/Nazara/Renderer/ShaderAst.inl b/include/Nazara/Renderer/ShaderAst.inl index b7d0a42d8..ea9e5cddf 100644 --- a/include/Nazara/Renderer/ShaderAst.inl +++ b/include/Nazara/Renderer/ShaderAst.inl @@ -82,6 +82,12 @@ namespace Nz { } + inline DeclareVariable::DeclareVariable(NamedVariablePtr Variable, ExpressionPtr Expression) : + expression(std::move(Expression)), + variable(std::move(Variable)) + { + } + inline AssignOp::AssignOp(AssignType Op, ExpressionPtr Left, ExpressionPtr Right) : op(Op), left(std::move(Left)), diff --git a/include/Nazara/Renderer/ShaderBuilder.hpp b/include/Nazara/Renderer/ShaderBuilder.hpp index b514b9c57..f8140ab42 100644 --- a/include/Nazara/Renderer/ShaderBuilder.hpp +++ b/include/Nazara/Renderer/ShaderBuilder.hpp @@ -11,7 +11,7 @@ #include #include -namespace Nz { namespace ShaderBuilder +namespace Nz::ShaderBuilder { template struct AssignOpBuilder @@ -49,7 +49,7 @@ namespace Nz { namespace ShaderBuilder { constexpr VarBuilder() {} - template std::shared_ptr operator()(Args&&... args) const; + template ShaderAst::NamedVariablePtr operator()(Args&&... args) const; }; constexpr BinOpBuilder Add; @@ -59,6 +59,7 @@ namespace Nz { namespace ShaderBuilder constexpr GenBuilder Branch; constexpr GenBuilder ConditionalStatement; constexpr GenBuilder Constant; + constexpr GenBuilder DeclareVariable; constexpr BinOpBuilder Divide; constexpr BinOpBuilder Equal; constexpr GenBuilder ExprStatement; @@ -73,7 +74,7 @@ namespace Nz { namespace ShaderBuilder constexpr VarBuilder Variable; template std::shared_ptr Cast(Args&&... args); -} } +} #include diff --git a/include/Nazara/Renderer/ShaderBuilder.inl b/include/Nazara/Renderer/ShaderBuilder.inl index 772c56583..76f00d394 100644 --- a/include/Nazara/Renderer/ShaderBuilder.inl +++ b/include/Nazara/Renderer/ShaderBuilder.inl @@ -44,7 +44,7 @@ namespace Nz { namespace ShaderBuilder template template - std::shared_ptr VarBuilder::operator()(Args&&... args) const + ShaderAst::NamedVariablePtr VarBuilder::operator()(Args&&... args) const { return std::make_shared(type, std::forward(args)...); } diff --git a/include/Nazara/Renderer/ShaderWriter.hpp b/include/Nazara/Renderer/ShaderWriter.hpp index 64dddcf9f..634c335ec 100644 --- a/include/Nazara/Renderer/ShaderWriter.hpp +++ b/include/Nazara/Renderer/ShaderWriter.hpp @@ -38,6 +38,7 @@ namespace Nz virtual void Write(const ShaderAst::BuiltinVariable& node) = 0; virtual void Write(const ShaderAst::Cast& node) = 0; virtual void Write(const ShaderAst::Constant& node) = 0; + virtual void Write(const ShaderAst::DeclareVariable& node) = 0; virtual void Write(const ShaderAst::ExpressionStatement& node) = 0; virtual void Write(const ShaderAst::NamedVariable& node) = 0; virtual void Write(const ShaderAst::NodePtr& node) = 0; diff --git a/src/Nazara/Renderer/GlslWriter.cpp b/src/Nazara/Renderer/GlslWriter.cpp index 685fc64af..73abec55f 100644 --- a/src/Nazara/Renderer/GlslWriter.cpp +++ b/src/Nazara/Renderer/GlslWriter.cpp @@ -66,6 +66,7 @@ namespace Nz switch (kind) { case ShaderAst::VariableType::Builtin: //< Only there to make compiler happy + case ShaderAst::VariableType::Variable: break; case ShaderAst::VariableType::Input: @@ -107,14 +108,6 @@ namespace Nz case ShaderAst::VariableType::Uniform: m_currentState->uniforms.emplace(type, name); break; - - case ShaderAst::VariableType::Variable: - { - if (m_currentFunction) - m_currentFunction->variables.emplace(type, name); - - break; - } } } @@ -262,6 +255,22 @@ namespace Nz } } + void GlslWriter::Write(const ShaderAst::DeclareVariable& node) + { + Append(node.variable->GetExpressionType()); + Append(" "); + Append(node.variable->name); + if (node.expression) + { + Append(" "); + Append("="); + Append(" "); + Write(node.expression); + } + + AppendLine(";"); + } + void GlslWriter::Write(const ShaderAst::ExpressionStatement& node) { Write(node.expression); @@ -404,8 +413,6 @@ namespace Nz EnterScope(); { - DeclareVariables(func.variables); - Write(func.node); } LeaveScope(); diff --git a/src/Nazara/Renderer/ShaderAst.cpp b/src/Nazara/Renderer/ShaderAst.cpp index 96dd0c7f3..0899cbdc7 100644 --- a/src/Nazara/Renderer/ShaderAst.cpp +++ b/src/Nazara/Renderer/ShaderAst.cpp @@ -69,6 +69,19 @@ namespace Nz::ShaderAst } + void DeclareVariable::Register(ShaderWriter& visitor) + { + variable->Register(visitor); + + if (expression) + expression->Register(visitor); + } + + void DeclareVariable::Visit(ShaderWriter& visitor) + { + visitor.Write(*this); + } + void BuiltinVariable::Register(ShaderWriter& /*visitor*/) { } diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp index 6abfe5379..3ddffe365 100644 --- a/src/ShaderNode/ShaderGraph.cpp +++ b/src/ShaderNode/ShaderGraph.cpp @@ -107,7 +107,6 @@ Nz::ShaderAst::StatementPtr ShaderGraph::ToAst() { ShaderNode* shaderNode = static_cast(node->nodeDataModel()); - qDebug() << shaderNode->name() << node->id(); auto it = usageCount.find(node->id()); if (it == usageCount.end()) { @@ -166,8 +165,10 @@ Nz::ShaderAst::StatementPtr ShaderGraph::ToAst() Nz::ShaderAst::ExpressionPtr varExpression; if (expression->GetExpressionCategory() == Nz::ShaderAst::ExpressionCategory::RValue) { - varExpression = Nz::ShaderBuilder::Variable("var" + std::to_string(varCount++), expression->GetExpressionType()); - statements.emplace_back(Nz::ShaderBuilder::ExprStatement(Nz::ShaderBuilder::Assign(varExpression, expression))); + auto variable = Nz::ShaderBuilder::Variable("var" + std::to_string(varCount++), expression->GetExpressionType()); + statements.emplace_back(Nz::ShaderBuilder::DeclareVariable(variable, expression)); + + varExpression = variable; } else varExpression = expression; From 0ec927b82e918a638531e0224459b4a03ff748e3 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 28 May 2020 00:11:16 +0200 Subject: [PATCH 219/316] ShaderNode/NodeEditor: Replace QVBoxLayout by QFormLayout --- src/ShaderNode/DataModels/Cast.hpp | 2 +- src/ShaderNode/DataModels/Cast.inl | 8 ++------ src/ShaderNode/DataModels/InputValue.cpp | 4 ++-- src/ShaderNode/DataModels/InputValue.hpp | 2 +- src/ShaderNode/DataModels/SampleTexture.cpp | 4 ++-- src/ShaderNode/DataModels/SampleTexture.hpp | 2 +- src/ShaderNode/DataModels/ShaderNode.cpp | 10 ++++++---- src/ShaderNode/DataModels/ShaderNode.hpp | 7 +++++-- src/ShaderNode/DataModels/ShaderNode.inl | 9 ++++++++- src/ShaderNode/DataModels/VecValue.hpp | 2 +- src/ShaderNode/DataModels/VecValue.inl | 7 ++----- src/ShaderNode/Widgets/MainWindow.cpp | 2 +- src/ShaderNode/Widgets/NodeEditor.hpp | 4 ++-- src/ShaderNode/Widgets/NodeEditor.inl | 2 +- 14 files changed, 35 insertions(+), 30 deletions(-) diff --git a/src/ShaderNode/DataModels/Cast.hpp b/src/ShaderNode/DataModels/Cast.hpp index 19d6363af..3c90f7e99 100644 --- a/src/ShaderNode/DataModels/Cast.hpp +++ b/src/ShaderNode/DataModels/Cast.hpp @@ -18,7 +18,7 @@ class CastVec : public ShaderNode CastVec(ShaderGraph& graph); ~CastVec() = default; - void BuildNodeEdition(QVBoxLayout* layout) override; + void BuildNodeEdition(QFormLayout* layout) override; Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const override; diff --git a/src/ShaderNode/DataModels/Cast.inl b/src/ShaderNode/DataModels/Cast.inl index 5c0600833..bf852a5c0 100644 --- a/src/ShaderNode/DataModels/Cast.inl +++ b/src/ShaderNode/DataModels/Cast.inl @@ -10,14 +10,12 @@ ShaderNode(graph) } template -void CastVec::BuildNodeEdition(QVBoxLayout* layout) +void CastVec::BuildNodeEdition(QFormLayout* layout) { ShaderNode::BuildNodeEdition(layout); if constexpr (ComponentDiff > 0) { - QFormLayout* formLayout = new QFormLayout; - for (std::size_t i = 0; i < ComponentDiff; ++i) { QDoubleSpinBox* spinbox = new QDoubleSpinBox; @@ -30,10 +28,8 @@ void CastVec::BuildNodeEdition(QVBoxLayout* layout) UpdateOutput(); }); - formLayout->addRow(QString::fromUtf8(&s_vectorComponents[FromComponents + i], 1), spinbox); + layout->addRow(QString::fromUtf8(&s_vectorComponents[FromComponents + i], 1), spinbox); } - - layout->addLayout(formLayout); } } diff --git a/src/ShaderNode/DataModels/InputValue.cpp b/src/ShaderNode/DataModels/InputValue.cpp index 810c2862e..9962a101b 100644 --- a/src/ShaderNode/DataModels/InputValue.cpp +++ b/src/ShaderNode/DataModels/InputValue.cpp @@ -64,7 +64,7 @@ void InputValue::OnInputListUpdate() } } -void InputValue::BuildNodeEdition(QVBoxLayout* layout) +void InputValue::BuildNodeEdition(QFormLayout* layout) { ShaderNode::BuildNodeEdition(layout); @@ -83,7 +83,7 @@ void InputValue::BuildNodeEdition(QVBoxLayout* layout) for (const auto& inputEntry : GetGraph().GetInputs()) inputSelection->addItem(QString::fromStdString(inputEntry.name)); - layout->addWidget(inputSelection); + layout->addRow(tr("Input"), inputSelection); } Nz::ShaderAst::ExpressionPtr InputValue::GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const diff --git a/src/ShaderNode/DataModels/InputValue.hpp b/src/ShaderNode/DataModels/InputValue.hpp index 84b7d6393..0170221f5 100644 --- a/src/ShaderNode/DataModels/InputValue.hpp +++ b/src/ShaderNode/DataModels/InputValue.hpp @@ -17,7 +17,7 @@ class InputValue : public ShaderNode InputValue(ShaderGraph& graph); ~InputValue() = default; - void BuildNodeEdition(QVBoxLayout* layout) override; + void BuildNodeEdition(QFormLayout* layout) override; Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const override; diff --git a/src/ShaderNode/DataModels/SampleTexture.cpp b/src/ShaderNode/DataModels/SampleTexture.cpp index 7209a69b5..2ec25b2be 100644 --- a/src/ShaderNode/DataModels/SampleTexture.cpp +++ b/src/ShaderNode/DataModels/SampleTexture.cpp @@ -112,7 +112,7 @@ bool SampleTexture::ComputePreview(QPixmap& pixmap) return true; } -void SampleTexture::BuildNodeEdition(QVBoxLayout* layout) +void SampleTexture::BuildNodeEdition(QFormLayout* layout) { ShaderNode::BuildNodeEdition(layout); @@ -130,7 +130,7 @@ void SampleTexture::BuildNodeEdition(QVBoxLayout* layout) for (const auto& textureEntry : GetGraph().GetTextures()) textureSelection->addItem(QString::fromStdString(textureEntry.name)); - layout->addWidget(textureSelection); + layout->addRow(tr("Texture"), textureSelection); } Nz::ShaderAst::ExpressionPtr SampleTexture::GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const diff --git a/src/ShaderNode/DataModels/SampleTexture.hpp b/src/ShaderNode/DataModels/SampleTexture.hpp index 738047712..fc2550f80 100644 --- a/src/ShaderNode/DataModels/SampleTexture.hpp +++ b/src/ShaderNode/DataModels/SampleTexture.hpp @@ -17,7 +17,7 @@ class SampleTexture : public ShaderNode SampleTexture(ShaderGraph& graph); ~SampleTexture() = default; - void BuildNodeEdition(QVBoxLayout* layout) override; + void BuildNodeEdition(QFormLayout* layout) override; Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const override; diff --git a/src/ShaderNode/DataModels/ShaderNode.cpp b/src/ShaderNode/DataModels/ShaderNode.cpp index 1221d1df6..9daad003b 100644 --- a/src/ShaderNode/DataModels/ShaderNode.cpp +++ b/src/ShaderNode/DataModels/ShaderNode.cpp @@ -1,21 +1,23 @@ #include #include +#include +#include #include -#include ShaderNode::ShaderNode(ShaderGraph& graph) : m_previewSize(64, 64), m_pixmapLabel(nullptr), m_graph(graph), +m_forceVariable(false), m_isPreviewEnabled(false) { m_pixmapLabel = new QLabel; m_pixmapLabel->setStyleSheet("background-color: rgba(0,0,0,0)"); } -void ShaderNode::BuildNodeEdition(QVBoxLayout* layout) +void ShaderNode::BuildNodeEdition(QFormLayout* layout) { - QCheckBox* checkbox = new QCheckBox(tr("Enable preview")); + QCheckBox* checkbox = new QCheckBox; checkbox->setCheckState((m_isPreviewEnabled) ? Qt::Checked : Qt::Unchecked); connect(checkbox, &QCheckBox::stateChanged, [&](int state) @@ -23,7 +25,7 @@ void ShaderNode::BuildNodeEdition(QVBoxLayout* layout) EnablePreview(state == Qt::Checked); }); - layout->addWidget(checkbox); + layout->addRow(tr("Enable preview"), checkbox); } void ShaderNode::EnablePreview(bool enable) diff --git a/src/ShaderNode/DataModels/ShaderNode.hpp b/src/ShaderNode/DataModels/ShaderNode.hpp index 3cf16ea06..6d64c33bd 100644 --- a/src/ShaderNode/DataModels/ShaderNode.hpp +++ b/src/ShaderNode/DataModels/ShaderNode.hpp @@ -10,7 +10,7 @@ #include class QLabel; -class QVBoxLayout; +class QFormLayout; class ShaderGraph; class ShaderNode : public QtNodes::NodeDataModel @@ -18,13 +18,14 @@ class ShaderNode : public QtNodes::NodeDataModel public: ShaderNode(ShaderGraph& graph); - virtual void BuildNodeEdition(QVBoxLayout* layout); + virtual void BuildNodeEdition(QFormLayout* layout); void EnablePreview(bool enable); virtual Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const = 0; inline ShaderGraph& GetGraph(); inline const ShaderGraph& GetGraph() const; + inline const std::string& GetVariableName() const; void SetPreviewSize(const Nz::Vector2i& size); @@ -41,7 +42,9 @@ class ShaderNode : public QtNodes::NodeDataModel Nz::Vector2i m_previewSize; QLabel* m_pixmapLabel; std::optional m_pixmap; + std::string m_variableName; ShaderGraph& m_graph; + bool m_forceVariable; bool m_isPreviewEnabled; }; diff --git a/src/ShaderNode/DataModels/ShaderNode.inl b/src/ShaderNode/DataModels/ShaderNode.inl index 7f80d00ff..d1a92bf73 100644 --- a/src/ShaderNode/DataModels/ShaderNode.inl +++ b/src/ShaderNode/DataModels/ShaderNode.inl @@ -1,6 +1,5 @@ #include - inline ShaderGraph& ShaderNode::GetGraph() { return m_graph; @@ -11,9 +10,17 @@ inline const ShaderGraph& ShaderNode::GetGraph() const return m_graph; } +inline const std::string& ShaderNode::GetVariableName() const +{ + return m_variableName; +} + inline void ShaderNode::SetPreviewSize(const Nz::Vector2i& size) { m_previewSize = size; if (m_isPreviewEnabled) + { UpdatePreview(); + embeddedWidgetSizeUpdated(); + } } diff --git a/src/ShaderNode/DataModels/VecValue.hpp b/src/ShaderNode/DataModels/VecValue.hpp index 27df2757f..ad190f8b1 100644 --- a/src/ShaderNode/DataModels/VecValue.hpp +++ b/src/ShaderNode/DataModels/VecValue.hpp @@ -27,7 +27,7 @@ class VecValue : public ShaderNode std::shared_ptr outData(QtNodes::PortIndex port) override; - void BuildNodeEdition(QVBoxLayout* layout) override; + void BuildNodeEdition(QFormLayout* layout) override; Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const override; diff --git a/src/ShaderNode/DataModels/VecValue.inl b/src/ShaderNode/DataModels/VecValue.inl index 8f9212631..f576bbb4e 100644 --- a/src/ShaderNode/DataModels/VecValue.inl +++ b/src/ShaderNode/DataModels/VecValue.inl @@ -68,11 +68,10 @@ std::shared_ptr VecValue::outData(QtNodes::PortIndex po } template -void VecValue::BuildNodeEdition(QVBoxLayout* layout) +void VecValue::BuildNodeEdition(QFormLayout* layout) { ShaderNode::BuildNodeEdition(layout); - QFormLayout* formLayout = new QFormLayout; for (std::size_t i = 0; i < ComponentCount; ++i) { QDoubleSpinBox* spinbox = new QDoubleSpinBox; @@ -87,10 +86,8 @@ void VecValue::BuildNodeEdition(QVBoxLayout* layout) UpdatePreview(); }); - formLayout->addRow(QString::fromUtf8(&s_vectorComponents[i], 1), spinbox); + layout->addRow(QString::fromUtf8(&s_vectorComponents[i], 1), spinbox); } - - layout->addLayout(formLayout); } template diff --git a/src/ShaderNode/Widgets/MainWindow.cpp b/src/ShaderNode/Widgets/MainWindow.cpp index 580e5b506..6f3d8a5f4 100644 --- a/src/ShaderNode/Widgets/MainWindow.cpp +++ b/src/ShaderNode/Widgets/MainWindow.cpp @@ -48,7 +48,7 @@ m_shaderGraph(graph) { if (node) { - m_nodeEditor->UpdateContent(node->caption(), [node](QVBoxLayout* layout) + m_nodeEditor->UpdateContent(node->caption(), [node](QFormLayout* layout) { node->BuildNodeEdition(layout); }); diff --git a/src/ShaderNode/Widgets/NodeEditor.hpp b/src/ShaderNode/Widgets/NodeEditor.hpp index 65e73c107..1bdb36c77 100644 --- a/src/ShaderNode/Widgets/NodeEditor.hpp +++ b/src/ShaderNode/Widgets/NodeEditor.hpp @@ -4,7 +4,7 @@ #define NAZARA_SHADERNODES_NODEEDITOR_HPP #include -#include +#include #include #include @@ -19,7 +19,7 @@ class NodeEditor : public QWidget template void UpdateContent(QString nodeName, F&& callback); private: - QVBoxLayout* m_layout; + QFormLayout* m_layout; }; #include diff --git a/src/ShaderNode/Widgets/NodeEditor.inl b/src/ShaderNode/Widgets/NodeEditor.inl index a7f916889..3c26b8fe8 100644 --- a/src/ShaderNode/Widgets/NodeEditor.inl +++ b/src/ShaderNode/Widgets/NodeEditor.inl @@ -6,7 +6,7 @@ void NodeEditor::UpdateContent(QString nodeName, F&& callback) { Clear(); - m_layout = new QVBoxLayout; + m_layout = new QFormLayout; setLayout(m_layout); QLabel* label = new QLabel(nodeName); From bc7ffb6ff3bdf4966d72909efe8e9ab2550a0e7b Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 28 May 2020 00:11:34 +0200 Subject: [PATCH 220/316] ShaderNode: Add preview size option --- src/ShaderNode/DataModels/ShaderNode.cpp | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/ShaderNode/DataModels/ShaderNode.cpp b/src/ShaderNode/DataModels/ShaderNode.cpp index 9daad003b..62236ddc0 100644 --- a/src/ShaderNode/DataModels/ShaderNode.cpp +++ b/src/ShaderNode/DataModels/ShaderNode.cpp @@ -26,6 +26,31 @@ void ShaderNode::BuildNodeEdition(QFormLayout* layout) }); layout->addRow(tr("Enable preview"), checkbox); + + QComboBox* previewSize = new QComboBox; + + int index = 0; + for (int size : { 32, 64, 128, 256, 512 }) + { + QString sizeStr = QString::number(size); + previewSize->addItem(sizeStr + "x" + sizeStr, size); + + if (m_previewSize.x == size) + previewSize->setCurrentIndex(index); + + index++; + } + + connect(previewSize, qOverload(&QComboBox::currentIndexChanged), [=](int index) + { + if (index < 0) + return; + + int size = previewSize->itemData(index).toInt(); + SetPreviewSize({ size, size }); + }); + + layout->addRow(tr("Preview size"), previewSize); } void ShaderNode::EnablePreview(bool enable) From 6ff670f13feab24ccd1ae52b3686b57685b0d591 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 28 May 2020 10:47:49 +0200 Subject: [PATCH 221/316] ShaderNode: Move VecData to DataTypes folder --- src/ShaderNode/DataModels/Cast.hpp | 3 +-- src/ShaderNode/DataModels/Cast.inl | 2 ++ src/ShaderNode/DataModels/FragmentOutput.cpp | 2 +- src/ShaderNode/DataModels/FragmentOutput.hpp | 2 +- src/ShaderNode/DataModels/InputValue.cpp | 3 ++- src/ShaderNode/DataModels/SampleTexture.cpp | 1 - src/ShaderNode/DataModels/SampleTexture.hpp | 3 +-- src/ShaderNode/DataModels/VecBinOp.hpp | 2 +- src/ShaderNode/DataModels/VecData.cpp | 1 - src/ShaderNode/DataModels/VecValue.hpp | 2 +- src/ShaderNode/DataModels/VecValue.inl | 3 ++- src/ShaderNode/DataTypes/VecData.cpp | 1 + src/ShaderNode/{DataModels => DataTypes}/VecData.hpp | 2 +- src/ShaderNode/{DataModels => DataTypes}/VecData.inl | 2 +- 14 files changed, 15 insertions(+), 14 deletions(-) delete mode 100644 src/ShaderNode/DataModels/VecData.cpp create mode 100644 src/ShaderNode/DataTypes/VecData.cpp rename src/ShaderNode/{DataModels => DataTypes}/VecData.hpp (97%) rename src/ShaderNode/{DataModels => DataTypes}/VecData.inl (73%) diff --git a/src/ShaderNode/DataModels/Cast.hpp b/src/ShaderNode/DataModels/Cast.hpp index 3c90f7e99..c1b63e8e0 100644 --- a/src/ShaderNode/DataModels/Cast.hpp +++ b/src/ShaderNode/DataModels/Cast.hpp @@ -8,8 +8,7 @@ #include #include #include -#include -#include +#include template class CastVec : public ShaderNode diff --git a/src/ShaderNode/DataModels/Cast.inl b/src/ShaderNode/DataModels/Cast.inl index bf852a5c0..56866aa3e 100644 --- a/src/ShaderNode/DataModels/Cast.inl +++ b/src/ShaderNode/DataModels/Cast.inl @@ -1,5 +1,7 @@ #include #include +#include +#include #include template diff --git a/src/ShaderNode/DataModels/FragmentOutput.cpp b/src/ShaderNode/DataModels/FragmentOutput.cpp index bfac47bee..b3938151b 100644 --- a/src/ShaderNode/DataModels/FragmentOutput.cpp +++ b/src/ShaderNode/DataModels/FragmentOutput.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include Nz::ShaderAst::ExpressionPtr FragmentOutput::GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const { diff --git a/src/ShaderNode/DataModels/FragmentOutput.hpp b/src/ShaderNode/DataModels/FragmentOutput.hpp index c70f39ff6..eb9b18bf9 100644 --- a/src/ShaderNode/DataModels/FragmentOutput.hpp +++ b/src/ShaderNode/DataModels/FragmentOutput.hpp @@ -4,7 +4,7 @@ #define NAZARA_SHADERNODES_FRAGMENTOUTPUT_HPP #include -#include +#include #include #include diff --git a/src/ShaderNode/DataModels/InputValue.cpp b/src/ShaderNode/DataModels/InputValue.cpp index 9962a101b..c36c4a256 100644 --- a/src/ShaderNode/DataModels/InputValue.cpp +++ b/src/ShaderNode/DataModels/InputValue.cpp @@ -1,7 +1,8 @@ #include #include -#include +#include #include +#include InputValue::InputValue(ShaderGraph& graph) : ShaderNode(graph) diff --git a/src/ShaderNode/DataModels/SampleTexture.cpp b/src/ShaderNode/DataModels/SampleTexture.cpp index 2ec25b2be..aa2b9d858 100644 --- a/src/ShaderNode/DataModels/SampleTexture.cpp +++ b/src/ShaderNode/DataModels/SampleTexture.cpp @@ -1,6 +1,5 @@ #include #include -#include #include SampleTexture::SampleTexture(ShaderGraph& graph) : diff --git a/src/ShaderNode/DataModels/SampleTexture.hpp b/src/ShaderNode/DataModels/SampleTexture.hpp index fc2550f80..3b463bb3b 100644 --- a/src/ShaderNode/DataModels/SampleTexture.hpp +++ b/src/ShaderNode/DataModels/SampleTexture.hpp @@ -8,8 +8,7 @@ #include #include #include -#include -#include +#include class SampleTexture : public ShaderNode { diff --git a/src/ShaderNode/DataModels/VecBinOp.hpp b/src/ShaderNode/DataModels/VecBinOp.hpp index e56c13461..6fa8fe875 100644 --- a/src/ShaderNode/DataModels/VecBinOp.hpp +++ b/src/ShaderNode/DataModels/VecBinOp.hpp @@ -4,7 +4,7 @@ #define NAZARA_SHADERNODES_VECBINOP_HPP #include -#include +#include template class VecBinOp : public ShaderNode diff --git a/src/ShaderNode/DataModels/VecData.cpp b/src/ShaderNode/DataModels/VecData.cpp deleted file mode 100644 index 376c8ea5c..000000000 --- a/src/ShaderNode/DataModels/VecData.cpp +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/src/ShaderNode/DataModels/VecValue.hpp b/src/ShaderNode/DataModels/VecValue.hpp index ad190f8b1..50ff1f4e1 100644 --- a/src/ShaderNode/DataModels/VecValue.hpp +++ b/src/ShaderNode/DataModels/VecValue.hpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include template diff --git a/src/ShaderNode/DataModels/VecValue.inl b/src/ShaderNode/DataModels/VecValue.inl index f576bbb4e..7f3a9dc5e 100644 --- a/src/ShaderNode/DataModels/VecValue.inl +++ b/src/ShaderNode/DataModels/VecValue.inl @@ -1,6 +1,7 @@ +#include #include #include -#include +#include #include #include diff --git a/src/ShaderNode/DataTypes/VecData.cpp b/src/ShaderNode/DataTypes/VecData.cpp new file mode 100644 index 000000000..0b1f99d61 --- /dev/null +++ b/src/ShaderNode/DataTypes/VecData.cpp @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/DataModels/VecData.hpp b/src/ShaderNode/DataTypes/VecData.hpp similarity index 97% rename from src/ShaderNode/DataModels/VecData.hpp rename to src/ShaderNode/DataTypes/VecData.hpp index 3882f20f1..447d37686 100644 --- a/src/ShaderNode/DataModels/VecData.hpp +++ b/src/ShaderNode/DataTypes/VecData.hpp @@ -101,6 +101,6 @@ template using VecType = typename VecTypeHelper::template Type constexpr std::array s_vectorComponents = { 'X', 'Y', 'Z', 'W' }; -#include +#include #endif diff --git a/src/ShaderNode/DataModels/VecData.inl b/src/ShaderNode/DataTypes/VecData.inl similarity index 73% rename from src/ShaderNode/DataModels/VecData.inl rename to src/ShaderNode/DataTypes/VecData.inl index 6c2d0379e..255fbd9ab 100644 --- a/src/ShaderNode/DataModels/VecData.inl +++ b/src/ShaderNode/DataTypes/VecData.inl @@ -1,4 +1,4 @@ -#include +#include inline VecData::VecData() : preview(64, 64, QImage::Format_RGBA8888) From eabb8a630d708dd444274e892c72f4776f0184da Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 28 May 2020 10:50:38 +0200 Subject: [PATCH 222/316] ShaderNode: Extract texture from SampleTexture Add TextureData and TextureValue node --- src/ShaderNode/DataModels/SampleTexture.cpp | 150 ++++++++------------ src/ShaderNode/DataModels/SampleTexture.hpp | 10 +- src/ShaderNode/DataModels/TextureValue.cpp | 146 +++++++++++++++++++ src/ShaderNode/DataModels/TextureValue.hpp | 45 ++++++ src/ShaderNode/DataModels/TextureValue.inl | 1 + src/ShaderNode/DataTypes/TextureData.cpp | 1 + src/ShaderNode/DataTypes/TextureData.hpp | 32 +++++ src/ShaderNode/DataTypes/TextureData.inl | 7 + src/ShaderNode/ShaderGraph.cpp | 26 ++-- 9 files changed, 307 insertions(+), 111 deletions(-) create mode 100644 src/ShaderNode/DataModels/TextureValue.cpp create mode 100644 src/ShaderNode/DataModels/TextureValue.hpp create mode 100644 src/ShaderNode/DataModels/TextureValue.inl create mode 100644 src/ShaderNode/DataTypes/TextureData.cpp create mode 100644 src/ShaderNode/DataTypes/TextureData.hpp create mode 100644 src/ShaderNode/DataTypes/TextureData.inl diff --git a/src/ShaderNode/DataModels/SampleTexture.cpp b/src/ShaderNode/DataModels/SampleTexture.cpp index aa2b9d858..e0fa852c3 100644 --- a/src/ShaderNode/DataModels/SampleTexture.cpp +++ b/src/ShaderNode/DataModels/SampleTexture.cpp @@ -7,20 +7,6 @@ ShaderNode(graph) { m_output = std::make_shared(); - m_onTextureListUpdateSlot.Connect(GetGraph().OnTextureListUpdate, [&](ShaderGraph*) { OnTextureListUpdate(); }); - m_onTexturePreviewUpdateSlot.Connect(GetGraph().OnTexturePreviewUpdate, [&](ShaderGraph*, std::size_t textureIndex) - { - if (m_currentTextureIndex == textureIndex) - UpdatePreview(); - }); - - if (graph.GetTextureCount() > 0) - { - auto& firstInput = graph.GetTexture(0); - m_currentTextureIndex = 0; - m_currentTextureText = firstInput.name; - } - UpdateOutput(); } @@ -28,45 +14,28 @@ unsigned int SampleTexture::nPorts(QtNodes::PortType portType) const { switch (portType) { - case QtNodes::PortType::In: return 1; + case QtNodes::PortType::In: return 2; case QtNodes::PortType::Out: return 1; } return 0; } -void SampleTexture::OnTextureListUpdate() -{ - m_currentTextureIndex.reset(); - - std::size_t inputIndex = 0; - for (const auto& textureEntry : GetGraph().GetTextures()) - { - if (textureEntry.name == m_currentTextureText) - { - m_currentTextureIndex = inputIndex; - break; - } - - inputIndex++; - } -} - void SampleTexture::UpdateOutput() { QImage& output = m_output->preview; - if (!m_currentTextureIndex || !m_uv) + if (!m_texture || !m_uv) { output = QImage(1, 1, QImage::Format_RGBA8888); output.fill(QColor::fromRgb(0, 0, 0, 0)); return; } - const auto& textureEntry = GetGraph().GetTexture(*m_currentTextureIndex); + const QImage& texturePreview = m_texture->preview; - int textureWidth = textureEntry.preview.width(); - int textureHeight = textureEntry.preview.height(); + int textureWidth = texturePreview.width(); + int textureHeight = texturePreview.height(); const QImage& uv = m_uv->preview; @@ -77,7 +46,7 @@ void SampleTexture::UpdateOutput() std::uint8_t* outputPtr = output.bits(); const std::uint8_t* uvPtr = uv.constBits(); - const std::uint8_t* texturePtr = textureEntry.preview.constBits(); + const std::uint8_t* texturePtr = texturePreview.constBits(); for (int y = 0; y < uvHeight; ++y) { for (int x = 0; x < uvWidth; ++x) @@ -104,57 +73,21 @@ void SampleTexture::UpdateOutput() bool SampleTexture::ComputePreview(QPixmap& pixmap) { - if (!m_currentTextureIndex || !m_uv) + if (!m_texture || !m_uv) return false; pixmap = QPixmap::fromImage(m_output->preview); return true; } -void SampleTexture::BuildNodeEdition(QFormLayout* layout) -{ - ShaderNode::BuildNodeEdition(layout); - - QComboBox* textureSelection = new QComboBox; - connect(textureSelection, qOverload(&QComboBox::currentIndexChanged), [&](int index) - { - if (index >= 0) - m_currentTextureIndex = static_cast(index); - else - m_currentTextureIndex.reset(); - - UpdateOutput(); - }); - - for (const auto& textureEntry : GetGraph().GetTextures()) - textureSelection->addItem(QString::fromStdString(textureEntry.name)); - - layout->addRow(tr("Texture"), textureSelection); -} - Nz::ShaderAst::ExpressionPtr SampleTexture::GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const { - if (!m_currentTextureIndex || !m_uv) + if (!m_texture || !m_uv) throw std::runtime_error("invalid inputs"); - assert(count == 1); + assert(count == 2); - const auto& textureEntry = GetGraph().GetTexture(*m_currentTextureIndex); - - Nz::ShaderAst::ExpressionType expression = [&] - { - switch (textureEntry.type) - { - case TextureType::Sampler2D: return Nz::ShaderAst::ExpressionType::Sampler2D; - } - - assert(false); - throw std::runtime_error("Unhandled texture type"); - }(); - - auto sampler = Nz::ShaderBuilder::Uniform(textureEntry.name, expression); - - return Nz::ShaderBuilder::Sample2D(sampler, expressions[0]); + return Nz::ShaderBuilder::Sample2D(expressions[0], expressions[1]); } auto SampleTexture::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const -> QtNodes::NodeDataType @@ -163,8 +96,14 @@ auto SampleTexture::dataType(QtNodes::PortType portType, QtNodes::PortIndex port { case QtNodes::PortType::In: { - assert(portIndex == 0); - return Vec2Data::Type(); + switch (portIndex) + { + case 0: return Texture2Data::Type(); + case 1: return Vec2Data::Type(); + } + + assert(false); + throw std::runtime_error("invalid port index"); } case QtNodes::PortType::Out: @@ -175,7 +114,7 @@ auto SampleTexture::dataType(QtNodes::PortType portType, QtNodes::PortIndex port default: assert(false); - throw std::runtime_error("Invalid PortType"); + throw std::runtime_error("invalid PortType"); } } @@ -185,8 +124,14 @@ QString SampleTexture::portCaption(QtNodes::PortType portType, QtNodes::PortInde { case QtNodes::PortType::In: { - assert(portIndex == 0); - return tr("UV"); + switch (portIndex) + { + case 0: return tr("Texture"); + case 1: return tr("UV"); + } + + assert(false); + throw std::runtime_error("invalid port index"); } case QtNodes::PortType::Out: @@ -210,24 +155,45 @@ std::shared_ptr SampleTexture::outData(QtNodes::PortIndex por { assert(port == 0); - if (!m_currentTextureIndex) - return nullptr; - return m_output; } void SampleTexture::setInData(std::shared_ptr value, int index) { - assert(index == 0); - - if (value) + switch (index) { - assert(dynamic_cast(value.get()) != nullptr); + case 0: + { + if (value) + { + assert(dynamic_cast(value.get()) != nullptr); - m_uv = std::static_pointer_cast(value); + m_texture = std::static_pointer_cast(value); + } + else + m_texture.reset(); + + break; + } + + case 1: + { + if (value) + { + assert(dynamic_cast(value.get()) != nullptr); + + m_uv = std::static_pointer_cast(value); + } + else + m_uv.reset(); + + break; + } + + default: + assert(false); + throw std::runtime_error("Invalid PortType"); } - else - m_uv.reset(); UpdateOutput(); } diff --git a/src/ShaderNode/DataModels/SampleTexture.hpp b/src/ShaderNode/DataModels/SampleTexture.hpp index 3b463bb3b..7a24409d0 100644 --- a/src/ShaderNode/DataModels/SampleTexture.hpp +++ b/src/ShaderNode/DataModels/SampleTexture.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #include class SampleTexture : public ShaderNode @@ -16,8 +17,6 @@ class SampleTexture : public ShaderNode SampleTexture(ShaderGraph& graph); ~SampleTexture() = default; - void BuildNodeEdition(QFormLayout* layout) override; - Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const override; QString caption() const override { return "Sample texture"; } @@ -37,16 +36,11 @@ class SampleTexture : public ShaderNode protected: bool ComputePreview(QPixmap& pixmap) override; - void OnTextureListUpdate(); void UpdateOutput(); - NazaraSlot(ShaderGraph, OnTextureListUpdate, m_onTextureListUpdateSlot); - NazaraSlot(ShaderGraph, OnTexturePreviewUpdate, m_onTexturePreviewUpdateSlot); - - std::optional m_currentTextureIndex; + std::shared_ptr m_texture; std::shared_ptr m_uv; std::shared_ptr m_output; - std::string m_currentTextureText; }; #include diff --git a/src/ShaderNode/DataModels/TextureValue.cpp b/src/ShaderNode/DataModels/TextureValue.cpp new file mode 100644 index 000000000..57127005b --- /dev/null +++ b/src/ShaderNode/DataModels/TextureValue.cpp @@ -0,0 +1,146 @@ +#include +#include +#include +#include +#include +#include + +TextureValue::TextureValue(ShaderGraph& graph) : +ShaderNode(graph) +{ + m_onTextureListUpdateSlot.Connect(GetGraph().OnTextureListUpdate, [&](ShaderGraph*) { OnTextureListUpdate(); }); + m_onTexturePreviewUpdateSlot.Connect(GetGraph().OnTexturePreviewUpdate, [&](ShaderGraph*, std::size_t textureIndex) + { + if (m_currentTextureIndex == textureIndex) + UpdatePreview(); + }); + + if (graph.GetTextureCount() > 0) + { + auto& firstInput = graph.GetTexture(0); + m_currentTextureIndex = 0; + m_currentTextureText = firstInput.name; + } + + EnablePreview(true); +} + +unsigned int TextureValue::nPorts(QtNodes::PortType portType) const +{ + switch (portType) + { + case QtNodes::PortType::In: return 0; + case QtNodes::PortType::Out: return 1; + } + + return 0; +} + +void TextureValue::OnTextureListUpdate() +{ + m_currentTextureIndex.reset(); + + std::size_t inputIndex = 0; + for (const auto& textureEntry : GetGraph().GetTextures()) + { + if (textureEntry.name == m_currentTextureText) + { + m_currentTextureIndex = inputIndex; + break; + } + + inputIndex++; + } +} + +bool TextureValue::ComputePreview(QPixmap& pixmap) +{ + if (!m_currentTextureIndex) + return false; + + const ShaderGraph& graph = GetGraph(); + const auto& textureEntry = graph.GetTexture(*m_currentTextureIndex); + + pixmap = QPixmap::fromImage(textureEntry.preview); + return true; +} + +void TextureValue::BuildNodeEdition(QFormLayout* layout) +{ + ShaderNode::BuildNodeEdition(layout); + + QComboBox* textureSelection = new QComboBox; + connect(textureSelection, qOverload(&QComboBox::currentIndexChanged), [&](int index) + { + if (index >= 0) + m_currentTextureIndex = static_cast(index); + else + m_currentTextureIndex.reset(); + + UpdatePreview(); + + Q_EMIT dataUpdated(0); + }); + + for (const auto& textureEntry : GetGraph().GetTextures()) + textureSelection->addItem(QString::fromStdString(textureEntry.name)); + + layout->addRow(tr("Texture"), textureSelection); +} + +Nz::ShaderAst::ExpressionPtr TextureValue::GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const +{ + if (!m_currentTextureIndex) + throw std::runtime_error("invalid inputs"); + + assert(count == 0); + + const auto& textureEntry = GetGraph().GetTexture(*m_currentTextureIndex); + + Nz::ShaderAst::ExpressionType expression = [&] + { + switch (textureEntry.type) + { + case TextureType::Sampler2D: return Nz::ShaderAst::ExpressionType::Sampler2D; + } + + assert(false); + throw std::runtime_error("Unhandled texture type"); + }(); + + return Nz::ShaderBuilder::Uniform(textureEntry.name, expression); +} + +auto TextureValue::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const -> QtNodes::NodeDataType +{ + assert(portType == QtNodes::PortType::Out); + assert(portIndex == 0); + + return Vec4Data::Type(); +} + +std::shared_ptr TextureValue::outData(QtNodes::PortIndex port) +{ + assert(port == 0); + + if (!m_currentTextureIndex) + return nullptr; + + const ShaderGraph& graph = GetGraph(); + const auto& textureEntry = graph.GetTexture(*m_currentTextureIndex); + + std::shared_ptr textureData; + + switch (textureEntry.type) + { + case TextureType::Sampler2D: + textureData = std::make_shared(); + break; + } + + assert(textureData); + + textureData->preview = textureEntry.preview; + + return textureData; +} diff --git a/src/ShaderNode/DataModels/TextureValue.hpp b/src/ShaderNode/DataModels/TextureValue.hpp new file mode 100644 index 000000000..27ae9474a --- /dev/null +++ b/src/ShaderNode/DataModels/TextureValue.hpp @@ -0,0 +1,45 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_TEXTUREVALUE_HPP +#define NAZARA_SHADERNODES_TEXTUREVALUE_HPP + +#include +#include +#include +#include +#include +#include + +class TextureValue : public ShaderNode +{ + public: + TextureValue(ShaderGraph& graph); + ~TextureValue() = default; + + void BuildNodeEdition(QFormLayout* layout) override; + + Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const override; + + QString caption() const override { return "Texture"; } + QString name() const override { return "Texture"; } + + unsigned int nPorts(QtNodes::PortType portType) const override; + + QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; + + std::shared_ptr outData(QtNodes::PortIndex port) override; + + protected: + bool ComputePreview(QPixmap& pixmap) override; + void OnTextureListUpdate(); + + NazaraSlot(ShaderGraph, OnTextureListUpdate, m_onTextureListUpdateSlot); + NazaraSlot(ShaderGraph, OnTexturePreviewUpdate, m_onTexturePreviewUpdateSlot); + + std::optional m_currentTextureIndex; + std::string m_currentTextureText; +}; + +#include + +#endif diff --git a/src/ShaderNode/DataModels/TextureValue.inl b/src/ShaderNode/DataModels/TextureValue.inl new file mode 100644 index 000000000..f28a64549 --- /dev/null +++ b/src/ShaderNode/DataModels/TextureValue.inl @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/DataTypes/TextureData.cpp b/src/ShaderNode/DataTypes/TextureData.cpp new file mode 100644 index 000000000..ad29d24f1 --- /dev/null +++ b/src/ShaderNode/DataTypes/TextureData.cpp @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/DataTypes/TextureData.hpp b/src/ShaderNode/DataTypes/TextureData.hpp new file mode 100644 index 000000000..778e66e05 --- /dev/null +++ b/src/ShaderNode/DataTypes/TextureData.hpp @@ -0,0 +1,32 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_TEXTUREDATA_HPP +#define NAZARA_SHADERNODES_TEXTUREDATA_HPP + +#include +#include +#include + +struct TextureData : public QtNodes::NodeData +{ + inline TextureData(); + + QImage preview; +}; + +struct Texture2Data : public TextureData +{ + QtNodes::NodeDataType type() const override + { + return Type(); + } + + static QtNodes::NodeDataType Type() + { + return { "tex2d", "Texture2D" }; + } +}; + +#include + +#endif diff --git a/src/ShaderNode/DataTypes/TextureData.inl b/src/ShaderNode/DataTypes/TextureData.inl new file mode 100644 index 000000000..e3ae7014f --- /dev/null +++ b/src/ShaderNode/DataTypes/TextureData.inl @@ -0,0 +1,7 @@ +#include + +inline TextureData::TextureData() : +preview(64, 64, QImage::Format_RGBA8888) +{ + preview.fill(QColor::fromRgb(255, 255, 255, 0)); +} diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp index 3ddffe365..6db88c2f0 100644 --- a/src/ShaderNode/ShaderGraph.cpp +++ b/src/ShaderNode/ShaderGraph.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -46,22 +47,26 @@ m_flowScene(BuildRegistry()) UpdateTexturePreview(0, QImage(R"(C:\Users\Lynix\Pictures\potatavril.png)")); - auto& node1 = m_flowScene.createNode(std::make_unique(*this)); + auto& node1 = m_flowScene.createNode(std::make_unique(*this)); node1.nodeGraphicsObject().setPos(0, 200); - auto& node2 = m_flowScene.createNode(std::make_unique(*this)); - node2.nodeGraphicsObject().setPos(200, 200); + auto& node2 = m_flowScene.createNode(std::make_unique(*this)); + node2.nodeGraphicsObject().setPos(50, 350); - auto& node3 = m_flowScene.createNode(std::make_unique(*this)); - node3.nodeGraphicsObject().setPos(400, 200); + auto& node3 = m_flowScene.createNode(std::make_unique(*this)); + node3.nodeGraphicsObject().setPos(200, 200); - auto& node4 = m_flowScene.createNode(std::make_unique(*this)); - node4.nodeGraphicsObject().setPos(600, 300); + auto& node4 = m_flowScene.createNode(std::make_unique(*this)); + node4.nodeGraphicsObject().setPos(400, 200); - m_flowScene.createConnection(node2, 0, node1, 0); - m_flowScene.createConnection(node3, 0, node2, 0); + auto& node5 = m_flowScene.createNode(std::make_unique(*this)); + node5.nodeGraphicsObject().setPos(600, 300); + + m_flowScene.createConnection(node3, 0, node1, 0); m_flowScene.createConnection(node3, 1, node2, 0); m_flowScene.createConnection(node4, 0, node3, 0); + m_flowScene.createConnection(node4, 1, node3, 0); + m_flowScene.createConnection(node5, 0, node4, 0); } ShaderGraph::~ShaderGraph() @@ -105,8 +110,6 @@ Nz::ShaderAst::StatementPtr ShaderGraph::ToAst() std::function DetectVariables; DetectVariables = [&](QtNodes::Node* node) { - ShaderNode* shaderNode = static_cast(node->nodeDataModel()); - auto it = usageCount.find(node->id()); if (it == usageCount.end()) { @@ -226,6 +229,7 @@ std::shared_ptr ShaderGraph::BuildRegistry() RegisterShaderNode(*this, registry, "Outputs"); RegisterShaderNode(*this, registry, "Inputs"); RegisterShaderNode(*this, registry, "Texture"); + RegisterShaderNode(*this, registry, "Texture"); RegisterShaderNode(*this, registry, "Vector operations"); RegisterShaderNode(*this, registry, "Vector operations"); RegisterShaderNode(*this, registry, "Vector operations"); From 0a0dce4109a5a49270d1ed2a2f496e1529d94cab Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 29 May 2020 18:22:58 +0200 Subject: [PATCH 223/316] ShaderNode: Add possibility to set variable name (+ force variables) --- src/ShaderNode/DataModels/FragmentOutput.inl | 1 + src/ShaderNode/DataModels/InputValue.cpp | 1 + src/ShaderNode/DataModels/ShaderNode.cpp | 13 +++++++++++- src/ShaderNode/DataModels/ShaderNode.hpp | 7 +++++-- src/ShaderNode/DataModels/ShaderNode.inl | 17 +++++++++++++++ src/ShaderNode/DataModels/TextureValue.cpp | 1 + src/ShaderNode/ShaderGraph.cpp | 22 ++++++++++++++++---- 7 files changed, 55 insertions(+), 7 deletions(-) diff --git a/src/ShaderNode/DataModels/FragmentOutput.inl b/src/ShaderNode/DataModels/FragmentOutput.inl index 24fc6cbf9..5b93f6699 100644 --- a/src/ShaderNode/DataModels/FragmentOutput.inl +++ b/src/ShaderNode/DataModels/FragmentOutput.inl @@ -4,5 +4,6 @@ inline FragmentOutput::FragmentOutput(ShaderGraph& graph) : ShaderNode(graph) { SetPreviewSize({ 128, 128 }); + DisableCustomVariableName(); EnablePreview(true); } diff --git a/src/ShaderNode/DataModels/InputValue.cpp b/src/ShaderNode/DataModels/InputValue.cpp index c36c4a256..fb53ba0a8 100644 --- a/src/ShaderNode/DataModels/InputValue.cpp +++ b/src/ShaderNode/DataModels/InputValue.cpp @@ -21,6 +21,7 @@ ShaderNode(graph) m_currentInputText = firstInput.name; } + DisableCustomVariableName(); UpdatePreview(); } diff --git a/src/ShaderNode/DataModels/ShaderNode.cpp b/src/ShaderNode/DataModels/ShaderNode.cpp index 62236ddc0..b955c3c42 100644 --- a/src/ShaderNode/DataModels/ShaderNode.cpp +++ b/src/ShaderNode/DataModels/ShaderNode.cpp @@ -3,12 +3,13 @@ #include #include #include +#include ShaderNode::ShaderNode(ShaderGraph& graph) : m_previewSize(64, 64), m_pixmapLabel(nullptr), m_graph(graph), -m_forceVariable(false), +m_enableCustomVariableName(true), m_isPreviewEnabled(false) { m_pixmapLabel = new QLabel; @@ -51,6 +52,16 @@ void ShaderNode::BuildNodeEdition(QFormLayout* layout) }); layout->addRow(tr("Preview size"), previewSize); + + if (m_enableCustomVariableName) + { + QLineEdit* lineEdit = new QLineEdit(QString::fromStdString(m_variableName)); + connect(lineEdit, &QLineEdit::textChanged, [&](const QString& text) + { + SetVariableName(text.toStdString()); + }); + layout->addRow(tr("Variable name"), lineEdit); + } } void ShaderNode::EnablePreview(bool enable) diff --git a/src/ShaderNode/DataModels/ShaderNode.hpp b/src/ShaderNode/DataModels/ShaderNode.hpp index 6d64c33bd..9d82851e2 100644 --- a/src/ShaderNode/DataModels/ShaderNode.hpp +++ b/src/ShaderNode/DataModels/ShaderNode.hpp @@ -27,13 +27,16 @@ class ShaderNode : public QtNodes::NodeDataModel inline const ShaderGraph& GetGraph() const; inline const std::string& GetVariableName() const; - void SetPreviewSize(const Nz::Vector2i& size); + inline void SetPreviewSize(const Nz::Vector2i& size); + inline void SetVariableName(std::string variableName); QWidget* embeddedWidget() final; void setInData(std::shared_ptr, int) override; protected: + inline void DisableCustomVariableName(); + inline void EnableCustomVariableName(bool enable = true); void UpdatePreview(); private: @@ -44,7 +47,7 @@ class ShaderNode : public QtNodes::NodeDataModel std::optional m_pixmap; std::string m_variableName; ShaderGraph& m_graph; - bool m_forceVariable; + bool m_enableCustomVariableName; bool m_isPreviewEnabled; }; diff --git a/src/ShaderNode/DataModels/ShaderNode.inl b/src/ShaderNode/DataModels/ShaderNode.inl index d1a92bf73..1fb9bf67a 100644 --- a/src/ShaderNode/DataModels/ShaderNode.inl +++ b/src/ShaderNode/DataModels/ShaderNode.inl @@ -24,3 +24,20 @@ inline void ShaderNode::SetPreviewSize(const Nz::Vector2i& size) embeddedWidgetSizeUpdated(); } } + +inline void ShaderNode::SetVariableName(std::string variableName) +{ + m_variableName = std::move(variableName); +} + +inline void ShaderNode::DisableCustomVariableName() +{ + return EnableCustomVariableName(false); +} + +inline void ShaderNode::EnableCustomVariableName(bool enable) +{ + m_enableCustomVariableName = enable; + if (!m_enableCustomVariableName) + m_variableName.clear(); +} diff --git a/src/ShaderNode/DataModels/TextureValue.cpp b/src/ShaderNode/DataModels/TextureValue.cpp index 57127005b..976ec7dd7 100644 --- a/src/ShaderNode/DataModels/TextureValue.cpp +++ b/src/ShaderNode/DataModels/TextureValue.cpp @@ -22,6 +22,7 @@ ShaderNode(graph) m_currentTextureText = firstInput.name; } + DisableCustomVariableName(); EnablePreview(true); } diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp index 6db88c2f0..1a80b9cbe 100644 --- a/src/ShaderNode/ShaderGraph.cpp +++ b/src/ShaderNode/ShaderGraph.cpp @@ -16,6 +16,7 @@ #include #include #include +#include namespace { @@ -105,8 +106,6 @@ Nz::ShaderAst::StatementPtr ShaderGraph::ToAst() std::vector statements; QHash usageCount; - unsigned int varCount = 0; - std::function DetectVariables; DetectVariables = [&](QtNodes::Node* node) { @@ -135,6 +134,9 @@ Nz::ShaderAst::StatementPtr ShaderGraph::ToAst() QHash variableExpressions; + unsigned int varCount = 0; + std::unordered_set usedVariableNames; + std::function HandleNode; HandleNode = [&](QtNodes::Node* node) -> Nz::ShaderAst::ExpressionPtr { @@ -163,12 +165,24 @@ Nz::ShaderAst::StatementPtr ShaderGraph::ToAst() auto expression = shaderNode->GetExpression(expressions.data(), expressions.size()); - if (*it > 1) + const std::string& variableName = shaderNode->GetVariableName(); + if (*it > 1 || !variableName.empty()) { Nz::ShaderAst::ExpressionPtr varExpression; if (expression->GetExpressionCategory() == Nz::ShaderAst::ExpressionCategory::RValue) { - auto variable = Nz::ShaderBuilder::Variable("var" + std::to_string(varCount++), expression->GetExpressionType()); + std::string name; + if (variableName.empty()) + name = "var" + std::to_string(varCount++); + else + name = variableName; + + if (usedVariableNames.find(name) != usedVariableNames.end()) + throw std::runtime_error("duplicate variable found: " + name); + + usedVariableNames.insert(name); + + auto variable = Nz::ShaderBuilder::Variable(std::move(name), expression->GetExpressionType()); statements.emplace_back(Nz::ShaderBuilder::DeclareVariable(variable, expression)); varExpression = variable; From 2ecc624fe4fcccc1eb0def852f2d80e50ac741ee Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 30 May 2020 14:31:11 +0200 Subject: [PATCH 224/316] ShaderNode: Add custom output support --- src/ShaderNode/DataModels/FragmentOutput.cpp | 62 ------- src/ShaderNode/DataModels/FragmentOutput.inl | 9 - src/ShaderNode/DataModels/InputValue.cpp | 22 +-- src/ShaderNode/DataModels/OutputValue.cpp | 160 ++++++++++++++++++ .../{FragmentOutput.hpp => OutputValue.hpp} | 25 ++- src/ShaderNode/DataModels/OutputValue.inl | 1 + src/ShaderNode/DataModels/ShaderNode.hpp | 3 +- src/ShaderNode/DataModels/ShaderNode.inl | 5 + src/ShaderNode/Enums.cpp | 12 +- src/ShaderNode/Enums.hpp | 6 +- src/ShaderNode/ShaderGraph.cpp | 53 ++++-- src/ShaderNode/ShaderGraph.hpp | 21 ++- src/ShaderNode/ShaderGraph.inl | 16 ++ src/ShaderNode/Widgets/InputEditDialog.cpp | 6 +- src/ShaderNode/Widgets/InputEditDialog.hpp | 2 +- src/ShaderNode/Widgets/MainWindow.cpp | 13 ++ src/ShaderNode/Widgets/OutputEditDialog.cpp | 67 ++++++++ src/ShaderNode/Widgets/OutputEditDialog.hpp | 36 ++++ src/ShaderNode/Widgets/OutputEditDialog.inl | 1 + src/ShaderNode/Widgets/OutputEditor.cpp | 95 +++++++++++ src/ShaderNode/Widgets/OutputEditor.hpp | 39 +++++ src/ShaderNode/Widgets/OutputEditor.inl | 1 + 22 files changed, 537 insertions(+), 118 deletions(-) delete mode 100644 src/ShaderNode/DataModels/FragmentOutput.cpp delete mode 100644 src/ShaderNode/DataModels/FragmentOutput.inl create mode 100644 src/ShaderNode/DataModels/OutputValue.cpp rename src/ShaderNode/DataModels/{FragmentOutput.hpp => OutputValue.hpp} (54%) create mode 100644 src/ShaderNode/DataModels/OutputValue.inl create mode 100644 src/ShaderNode/Widgets/OutputEditDialog.cpp create mode 100644 src/ShaderNode/Widgets/OutputEditDialog.hpp create mode 100644 src/ShaderNode/Widgets/OutputEditDialog.inl create mode 100644 src/ShaderNode/Widgets/OutputEditor.cpp create mode 100644 src/ShaderNode/Widgets/OutputEditor.hpp create mode 100644 src/ShaderNode/Widgets/OutputEditor.inl diff --git a/src/ShaderNode/DataModels/FragmentOutput.cpp b/src/ShaderNode/DataModels/FragmentOutput.cpp deleted file mode 100644 index b3938151b..000000000 --- a/src/ShaderNode/DataModels/FragmentOutput.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include -#include -#include - -Nz::ShaderAst::ExpressionPtr FragmentOutput::GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const -{ - using namespace Nz::ShaderAst; - using namespace Nz::ShaderBuilder; - - assert(count == 1); - - auto output = Nz::ShaderBuilder::Output("RenderTarget0", ExpressionType::Float4); - - return Nz::ShaderBuilder::Assign(output, *expressions); -} - -QtNodes::NodeDataType FragmentOutput::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const -{ - assert(portType == QtNodes::PortType::In); - assert(portIndex == 0); - - return Vec4Data::Type(); -} - -unsigned int FragmentOutput::nPorts(QtNodes::PortType portType) const -{ - switch (portType) - { - case QtNodes::PortType::In: return 1; - case QtNodes::PortType::Out: return 0; - } - - return 0; -} - -std::shared_ptr FragmentOutput::outData(QtNodes::PortIndex /*port*/) -{ - return {}; -} - -void FragmentOutput::setInData(std::shared_ptr value, int index) -{ - assert(index == 0); - if (value) - { - assert(dynamic_cast(value.get()) != nullptr); - m_input = std::static_pointer_cast(value); - } - else - m_input.reset(); - - UpdatePreview(); -} - -bool FragmentOutput::ComputePreview(QPixmap& pixmap) -{ - if (!m_input) - return false; - - pixmap = QPixmap::fromImage(m_input->preview); - return true; -} diff --git a/src/ShaderNode/DataModels/FragmentOutput.inl b/src/ShaderNode/DataModels/FragmentOutput.inl deleted file mode 100644 index 5b93f6699..000000000 --- a/src/ShaderNode/DataModels/FragmentOutput.inl +++ /dev/null @@ -1,9 +0,0 @@ -#include - -inline FragmentOutput::FragmentOutput(ShaderGraph& graph) : -ShaderNode(graph) -{ - SetPreviewSize({ 128, 128 }); - DisableCustomVariableName(); - EnablePreview(true); -} diff --git a/src/ShaderNode/DataModels/InputValue.cpp b/src/ShaderNode/DataModels/InputValue.cpp index fb53ba0a8..9ff7fd207 100644 --- a/src/ShaderNode/DataModels/InputValue.cpp +++ b/src/ShaderNode/DataModels/InputValue.cpp @@ -101,11 +101,11 @@ Nz::ShaderAst::ExpressionPtr InputValue::GetExpression(Nz::ShaderAst::Expression { switch (inputEntry.type) { - case InputType::Bool: return Nz::ShaderAst::ExpressionType::Boolean; - case InputType::Float1: return Nz::ShaderAst::ExpressionType::Float1; - case InputType::Float2: return Nz::ShaderAst::ExpressionType::Float2; - case InputType::Float3: return Nz::ShaderAst::ExpressionType::Float3; - case InputType::Float4: return Nz::ShaderAst::ExpressionType::Float4; + case InOutType::Bool: return Nz::ShaderAst::ExpressionType::Boolean; + case InOutType::Float1: return Nz::ShaderAst::ExpressionType::Float1; + case InOutType::Float2: return Nz::ShaderAst::ExpressionType::Float2; + case InOutType::Float3: return Nz::ShaderAst::ExpressionType::Float3; + case InOutType::Float4: return Nz::ShaderAst::ExpressionType::Float4; } assert(false); @@ -117,20 +117,20 @@ Nz::ShaderAst::ExpressionPtr InputValue::GetExpression(Nz::ShaderAst::Expression auto InputValue::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const -> QtNodes::NodeDataType { - if (!m_currentInputIndex) - return Vec4Data::Type(); - assert(portType == QtNodes::PortType::Out); assert(portIndex == 0); + if (!m_currentInputIndex) + return Vec4Data::Type(); + const auto& inputEntry = GetGraph().GetInput(*m_currentInputIndex); switch (inputEntry.type) { //case InputType::Bool: return Nz::ShaderAst::ExpressionType::Boolean; //case InputType::Float1: return Nz::ShaderAst::ExpressionType::Float1; - case InputType::Float2: return Vec2Data::Type(); - case InputType::Float3: return Vec3Data::Type(); - case InputType::Float4: return Vec4Data::Type(); + case InOutType::Float2: return Vec2Data::Type(); + case InOutType::Float3: return Vec3Data::Type(); + case InOutType::Float4: return Vec4Data::Type(); } assert(false); diff --git a/src/ShaderNode/DataModels/OutputValue.cpp b/src/ShaderNode/DataModels/OutputValue.cpp new file mode 100644 index 000000000..2d3a8dc14 --- /dev/null +++ b/src/ShaderNode/DataModels/OutputValue.cpp @@ -0,0 +1,160 @@ +#include +#include +#include +#include +#include +#include + +OutputValue::OutputValue(ShaderGraph& graph) : +ShaderNode(graph) +{ + m_onOutputListUpdateSlot.Connect(GetGraph().OnOutputListUpdate, [&](ShaderGraph*) { OnOutputListUpdate(); }); + m_onOutputUpdateSlot.Connect(GetGraph().OnOutputUpdate, [&](ShaderGraph*, std::size_t inputIndex) + { + if (m_currentOutputIndex == inputIndex) + UpdatePreview(); + }); + + if (graph.GetOutputCount() > 0) + { + auto& firstOutput = graph.GetOutput(0); + m_currentOutputIndex = 0; + m_currentOutputText = firstOutput.name; + } + + EnablePreview(); + SetPreviewSize({ 128, 128 }); + DisableCustomVariableName(); +} + +void OutputValue::BuildNodeEdition(QFormLayout* layout) +{ + ShaderNode::BuildNodeEdition(layout); + + QComboBox* outputSelection = new QComboBox; + + connect(outputSelection, qOverload(&QComboBox::currentIndexChanged), [&](int index) + { + if (index >= 0) + m_currentOutputIndex = static_cast(index); + else + m_currentOutputIndex.reset(); + + UpdatePreview(); + }); + + for (const auto& outputEntry : GetGraph().GetOutputs()) + outputSelection->addItem(QString::fromStdString(outputEntry.name)); + + layout->addRow(tr("Output"), outputSelection); +} + +Nz::ShaderAst::ExpressionPtr OutputValue::GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const +{ + using namespace Nz::ShaderAst; + using namespace Nz::ShaderBuilder; + + assert(count == 1); + + if (!m_currentOutputIndex) + throw std::runtime_error("no output"); + + const auto& outputEntry = GetGraph().GetOutput(*m_currentOutputIndex); + + Nz::ShaderAst::ExpressionType expression = [&] + { + switch (outputEntry.type) + { + case InOutType::Bool: return Nz::ShaderAst::ExpressionType::Boolean; + case InOutType::Float1: return Nz::ShaderAst::ExpressionType::Float1; + case InOutType::Float2: return Nz::ShaderAst::ExpressionType::Float2; + case InOutType::Float3: return Nz::ShaderAst::ExpressionType::Float3; + case InOutType::Float4: return Nz::ShaderAst::ExpressionType::Float4; + } + + assert(false); + throw std::runtime_error("Unhandled output type"); + }(); + + auto output = Nz::ShaderBuilder::Output(outputEntry.name, expression); + + return Nz::ShaderBuilder::Assign(std::move(output), *expressions); +} + +QtNodes::NodeDataType OutputValue::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const +{ + assert(portType == QtNodes::PortType::In); + assert(portIndex == 0); + + if (!m_currentOutputIndex) + return Vec4Data::Type(); + + const auto& outputEntry = GetGraph().GetOutput(*m_currentOutputIndex); + switch (outputEntry.type) + { + //case InOutType::Bool: return Nz::ShaderAst::ExpressionType::Boolean; + //case InOutType::Float1: return Nz::ShaderAst::ExpressionType::Float1; + case InOutType::Float2: return Vec2Data::Type(); + case InOutType::Float3: return Vec3Data::Type(); + case InOutType::Float4: return Vec4Data::Type(); + } + + assert(false); + throw std::runtime_error("Unhandled output type"); +} + +unsigned int OutputValue::nPorts(QtNodes::PortType portType) const +{ + switch (portType) + { + case QtNodes::PortType::In: return 1; + case QtNodes::PortType::Out: return 0; + } + + return 0; +} + +std::shared_ptr OutputValue::outData(QtNodes::PortIndex /*port*/) +{ + return {}; +} + +void OutputValue::setInData(std::shared_ptr value, int index) +{ + assert(index == 0); + if (value) + { + assert(dynamic_cast(value.get()) != nullptr); + m_input = std::static_pointer_cast(value); + } + else + m_input.reset(); + + UpdatePreview(); +} + +bool OutputValue::ComputePreview(QPixmap& pixmap) +{ + if (!m_input) + return false; + + pixmap = QPixmap::fromImage(m_input->preview); + return true; +} + +void OutputValue::OnOutputListUpdate() +{ + m_currentOutputIndex.reset(); + + std::size_t inputIndex = 0; + for (const auto& inputEntry : GetGraph().GetOutputs()) + { + if (inputEntry.name == m_currentOutputText) + { + m_currentOutputIndex = inputIndex; + break; + } + + inputIndex++; + } +} diff --git a/src/ShaderNode/DataModels/FragmentOutput.hpp b/src/ShaderNode/DataModels/OutputValue.hpp similarity index 54% rename from src/ShaderNode/DataModels/FragmentOutput.hpp rename to src/ShaderNode/DataModels/OutputValue.hpp index eb9b18bf9..8db611056 100644 --- a/src/ShaderNode/DataModels/FragmentOutput.hpp +++ b/src/ShaderNode/DataModels/OutputValue.hpp @@ -3,20 +3,23 @@ #ifndef NAZARA_SHADERNODES_FRAGMENTOUTPUT_HPP #define NAZARA_SHADERNODES_FRAGMENTOUTPUT_HPP +#include #include #include -#include -#include -class FragmentOutput : public ShaderNode +class QFormLayout; + +class OutputValue : public ShaderNode { public: - inline FragmentOutput(ShaderGraph& graph); + OutputValue(ShaderGraph& graph); + + void BuildNodeEdition(QFormLayout* layout) override; Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const override; - QString caption() const override { return "Fragment shader output"; } - QString name() const override { return "FragmentShaderOutput"; } + QString caption() const override { return "Output"; } + QString name() const override { return "Output"; } QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; @@ -28,10 +31,16 @@ class FragmentOutput : public ShaderNode private: bool ComputePreview(QPixmap& pixmap) override; + void OnOutputListUpdate(); - std::shared_ptr m_input; + NazaraSlot(ShaderGraph, OnOutputListUpdate, m_onOutputListUpdateSlot); + NazaraSlot(ShaderGraph, OnOutputUpdate, m_onOutputUpdateSlot); + + std::optional m_currentOutputIndex; + std::shared_ptr m_input; + std::string m_currentOutputText; }; -#include +#include #endif diff --git a/src/ShaderNode/DataModels/OutputValue.inl b/src/ShaderNode/DataModels/OutputValue.inl new file mode 100644 index 000000000..585e40a7f --- /dev/null +++ b/src/ShaderNode/DataModels/OutputValue.inl @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/DataModels/ShaderNode.hpp b/src/ShaderNode/DataModels/ShaderNode.hpp index 9d82851e2..91f6dc0d3 100644 --- a/src/ShaderNode/DataModels/ShaderNode.hpp +++ b/src/ShaderNode/DataModels/ShaderNode.hpp @@ -20,7 +20,8 @@ class ShaderNode : public QtNodes::NodeDataModel virtual void BuildNodeEdition(QFormLayout* layout); - void EnablePreview(bool enable); + inline void DisablePreview(); + void EnablePreview(bool enable = true); virtual Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const = 0; inline ShaderGraph& GetGraph(); diff --git a/src/ShaderNode/DataModels/ShaderNode.inl b/src/ShaderNode/DataModels/ShaderNode.inl index 1fb9bf67a..558a86165 100644 --- a/src/ShaderNode/DataModels/ShaderNode.inl +++ b/src/ShaderNode/DataModels/ShaderNode.inl @@ -1,5 +1,10 @@ #include +inline void ShaderNode::DisablePreview() +{ + return EnablePreview(false); +} + inline ShaderGraph& ShaderNode::GetGraph() { return m_graph; diff --git a/src/ShaderNode/Enums.cpp b/src/ShaderNode/Enums.cpp index 22f21c972..fd99c5562 100644 --- a/src/ShaderNode/Enums.cpp +++ b/src/ShaderNode/Enums.cpp @@ -15,15 +15,15 @@ const char* EnumToString(InputRole role) return ""; } -const char* EnumToString(InputType input) +const char* EnumToString(InOutType input) { switch (input) { - case InputType::Bool: return "Bool"; - case InputType::Float1: return "Float"; - case InputType::Float2: return "Float2"; - case InputType::Float3: return "Float3"; - case InputType::Float4: return "Float4"; + case InOutType::Bool: return "Bool"; + case InOutType::Float1: return "Float"; + case InOutType::Float2: return "Float2"; + case InOutType::Float3: return "Float3"; + case InOutType::Float4: return "Float4"; } assert(false); diff --git a/src/ShaderNode/Enums.hpp b/src/ShaderNode/Enums.hpp index b8e944c5c..ba990fdcf 100644 --- a/src/ShaderNode/Enums.hpp +++ b/src/ShaderNode/Enums.hpp @@ -17,7 +17,7 @@ enum class InputRole constexpr std::size_t InputRoleCount = static_cast(InputRole::Max) + 1; -enum class InputType +enum class InOutType { Bool, Float1, @@ -28,7 +28,7 @@ enum class InputType Max = Float4 }; -constexpr std::size_t InputTypeCount = static_cast(InputType::Max) + 1; +constexpr std::size_t InOutTypeCount = static_cast(InOutType::Max) + 1; enum class TextureType { @@ -40,7 +40,7 @@ enum class TextureType constexpr std::size_t TextureTypeCount = static_cast(TextureType::Max) + 1; const char* EnumToString(InputRole role); -const char* EnumToString(InputType input); +const char* EnumToString(InOutType input); const char* EnumToString(TextureType textureType); #include diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp index 1a80b9cbe..876b0f1a3 100644 --- a/src/ShaderNode/ShaderGraph.cpp +++ b/src/ShaderNode/ShaderGraph.cpp @@ -1,8 +1,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -43,7 +43,8 @@ m_flowScene(BuildRegistry()) }); // Test - AddInput("UV", InputType::Float2, InputRole::TexCoord, 0); + AddInput("UV", InOutType::Float2, InputRole::TexCoord, 0); + AddOutput("RenderTarget0", InOutType::Float4); AddTexture("Potato", TextureType::Sampler2D); UpdateTexturePreview(0, QImage(R"(C:\Users\Lynix\Pictures\potatavril.png)")); @@ -60,7 +61,7 @@ m_flowScene(BuildRegistry()) auto& node4 = m_flowScene.createNode(std::make_unique(*this)); node4.nodeGraphicsObject().setPos(400, 200); - auto& node5 = m_flowScene.createNode(std::make_unique(*this)); + auto& node5 = m_flowScene.createNode(std::make_unique(*this)); node5.nodeGraphicsObject().setPos(600, 300); m_flowScene.createConnection(node3, 0, node1, 0); @@ -75,7 +76,7 @@ ShaderGraph::~ShaderGraph() m_flowScene.clearScene(); } -std::size_t ShaderGraph::AddInput(std::string name, InputType type, InputRole role, std::size_t roleIndex) +std::size_t ShaderGraph::AddInput(std::string name, InOutType type, InputRole role, std::size_t roleIndex) { std::size_t index = m_inputs.size(); auto& inputEntry = m_inputs.emplace_back(); @@ -89,6 +90,18 @@ std::size_t ShaderGraph::AddInput(std::string name, InputType type, InputRole ro return index; } +std::size_t ShaderGraph::AddOutput(std::string name, InOutType type) +{ + std::size_t index = m_outputs.size(); + auto& outputEntry = m_outputs.emplace_back(); + outputEntry.name = std::move(name); + outputEntry.type = type; + + OnOutputListUpdate(this); + + return index; +} + std::size_t ShaderGraph::AddTexture(std::string name, TextureType type) { std::size_t index = m_textures.size(); @@ -198,18 +211,26 @@ Nz::ShaderAst::StatementPtr ShaderGraph::ToAst() return expression; }; - m_flowScene.iterateOverNodes([&](QtNodes::Node* node) + try { - if (node->nodeDataModel()->nPorts(QtNodes::PortType::Out) == 0) + m_flowScene.iterateOverNodes([&](QtNodes::Node* node) { - statements.emplace_back(Nz::ShaderBuilder::ExprStatement(HandleNode(node))); - } - }); + if (node->nodeDataModel()->nPorts(QtNodes::PortType::Out) == 0) + { + statements.emplace_back(Nz::ShaderBuilder::ExprStatement(HandleNode(node))); + } + }); + } + catch (const std::exception&) + { + + return nullptr; + } return std::make_shared(std::move(statements)); } -void ShaderGraph::UpdateInput(std::size_t inputIndex, std::string name, InputType type, InputRole role, std::size_t roleIndex) +void ShaderGraph::UpdateInput(std::size_t inputIndex, std::string name, InOutType type, InputRole role, std::size_t roleIndex) { assert(inputIndex < m_inputs.size()); auto& inputEntry = m_inputs[inputIndex]; @@ -221,6 +242,16 @@ void ShaderGraph::UpdateInput(std::size_t inputIndex, std::string name, InputTyp OnInputUpdate(this, inputIndex); } +void ShaderGraph::UpdateOutput(std::size_t outputIndex, std::string name, InOutType type) +{ + assert(outputIndex < m_outputs.size()); + auto& outputEntry = m_outputs[outputIndex]; + outputEntry.name = std::move(name); + outputEntry.type = type; + + OnOutputUpdate(this, outputIndex); +} + void ShaderGraph::UpdateTexturePreview(std::size_t textureIndex, QImage preview) { assert(textureIndex < m_textures.size()); @@ -240,8 +271,8 @@ std::shared_ptr ShaderGraph::BuildRegistry() RegisterShaderNode(*this, registry, "Casts"); RegisterShaderNode(*this, registry, "Casts"); RegisterShaderNode(*this, registry, "Casts"); - RegisterShaderNode(*this, registry, "Outputs"); RegisterShaderNode(*this, registry, "Inputs"); + RegisterShaderNode(*this, registry, "Outputs"); RegisterShaderNode(*this, registry, "Texture"); RegisterShaderNode(*this, registry, "Texture"); RegisterShaderNode(*this, registry, "Vector operations"); diff --git a/src/ShaderNode/ShaderGraph.hpp b/src/ShaderNode/ShaderGraph.hpp index ca29ff174..854d5cfb7 100644 --- a/src/ShaderNode/ShaderGraph.hpp +++ b/src/ShaderNode/ShaderGraph.hpp @@ -17,17 +17,22 @@ class ShaderGraph { public: struct InputEntry; + struct OutputEntry; struct TextureEntry; ShaderGraph(); ~ShaderGraph(); - std::size_t AddInput(std::string name, InputType type, InputRole role, std::size_t roleIndex); + std::size_t AddInput(std::string name, InOutType type, InputRole role, std::size_t roleIndex); + std::size_t AddOutput(std::string name, InOutType type); std::size_t AddTexture(std::string name, TextureType type); inline const InputEntry& GetInput(std::size_t inputIndex) const; inline std::size_t GetInputCount() const; inline const std::vector& GetInputs() const; + inline const OutputEntry& GetOutput(std::size_t outputIndex) const; + inline std::size_t GetOutputCount() const; + inline const std::vector& GetOutputs() const; inline const PreviewModel& GetPreviewModel() const; inline QtNodes::FlowScene& GetScene(); inline const TextureEntry& GetTexture(std::size_t textureIndex) const; @@ -36,7 +41,8 @@ class ShaderGraph Nz::ShaderAst::StatementPtr ToAst(); - void UpdateInput(std::size_t inputIndex, std::string name, InputType type, InputRole role, std::size_t roleIndex); + void UpdateInput(std::size_t inputIndex, std::string name, InOutType type, InputRole role, std::size_t roleIndex); + void UpdateOutput(std::size_t outputIndex, std::string name, InOutType type); void UpdateTexturePreview(std::size_t texture, QImage preview); struct InputEntry @@ -44,7 +50,13 @@ class ShaderGraph std::size_t roleIndex; std::string name; InputRole role; - InputType type; + InOutType type; + }; + + struct OutputEntry + { + std::string name; + InOutType type; }; struct TextureEntry @@ -56,6 +68,8 @@ class ShaderGraph NazaraSignal(OnInputListUpdate, ShaderGraph*); NazaraSignal(OnInputUpdate, ShaderGraph*, std::size_t /*inputIndex*/); + NazaraSignal(OnOutputListUpdate, ShaderGraph*); + NazaraSignal(OnOutputUpdate, ShaderGraph*, std::size_t /*outputIndex*/); NazaraSignal(OnSelectedNodeUpdate, ShaderGraph*, ShaderNode* /*node*/); NazaraSignal(OnTextureListUpdate, ShaderGraph*); NazaraSignal(OnTexturePreviewUpdate, ShaderGraph*, std::size_t /*textureIndex*/); @@ -65,6 +79,7 @@ class ShaderGraph QtNodes::FlowScene m_flowScene; std::vector m_inputs; + std::vector m_outputs; std::vector m_textures; std::unique_ptr m_previewModel; }; diff --git a/src/ShaderNode/ShaderGraph.inl b/src/ShaderNode/ShaderGraph.inl index 97184906e..3f839534c 100644 --- a/src/ShaderNode/ShaderGraph.inl +++ b/src/ShaderNode/ShaderGraph.inl @@ -16,6 +16,22 @@ inline auto ShaderGraph::GetInputs() const -> const std::vector& return m_inputs; } +inline auto ShaderGraph::GetOutput(std::size_t outputIndex) const -> const OutputEntry& +{ + assert(outputIndex < m_outputs.size()); + return m_outputs[outputIndex]; +} + +inline std::size_t ShaderGraph::GetOutputCount() const +{ + return m_outputs.size(); +} + +inline auto ShaderGraph::GetOutputs() const -> const std::vector& +{ + return m_outputs; +} + inline const PreviewModel& ShaderGraph::GetPreviewModel() const { return *m_previewModel; diff --git a/src/ShaderNode/Widgets/InputEditDialog.cpp b/src/ShaderNode/Widgets/InputEditDialog.cpp index 71e6b2298..09f711f3d 100644 --- a/src/ShaderNode/Widgets/InputEditDialog.cpp +++ b/src/ShaderNode/Widgets/InputEditDialog.cpp @@ -16,8 +16,8 @@ QDialog(parent) m_inputName = new QLineEdit; m_typeList = new QComboBox; - for (std::size_t i = 0; i < InputTypeCount; ++i) - m_typeList->addItem(EnumToString(static_cast(i))); + for (std::size_t i = 0; i < InOutTypeCount; ++i) + m_typeList->addItem(EnumToString(static_cast(i))); m_roleList = new QComboBox; for (std::size_t i = 0; i < InputRoleCount; ++i) @@ -57,7 +57,7 @@ InputInfo InputEditDialog::GetInputInfo() const inputInfo.name = m_inputName->text().toStdString(); inputInfo.role = static_cast(m_roleList->currentIndex()); inputInfo.roleIndex = static_cast(m_roleIndex->value()); - inputInfo.type = static_cast(m_typeList->currentIndex()); + inputInfo.type = static_cast(m_typeList->currentIndex()); return inputInfo; } diff --git a/src/ShaderNode/Widgets/InputEditDialog.hpp b/src/ShaderNode/Widgets/InputEditDialog.hpp index ef96d118c..633b9c99d 100644 --- a/src/ShaderNode/Widgets/InputEditDialog.hpp +++ b/src/ShaderNode/Widgets/InputEditDialog.hpp @@ -15,7 +15,7 @@ struct InputInfo std::size_t roleIndex; std::string name; InputRole role; - InputType type; + InOutType type; }; class InputEditDialog : public QDialog diff --git a/src/ShaderNode/Widgets/MainWindow.cpp b/src/ShaderNode/Widgets/MainWindow.cpp index 6f3d8a5f4..ca0bd4c0a 100644 --- a/src/ShaderNode/Widgets/MainWindow.cpp +++ b/src/ShaderNode/Widgets/MainWindow.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -20,6 +21,7 @@ m_shaderGraph(graph) QtNodes::FlowView* flowView = new QtNodes::FlowView(scene); setCentralWidget(flowView); + // Input editor InputEditor* inputEditor = new InputEditor(m_shaderGraph); QDockWidget* inputDock = new QDockWidget(tr("Inputs")); @@ -28,6 +30,16 @@ m_shaderGraph(graph) addDockWidget(Qt::LeftDockWidgetArea, inputDock); + // Output editor + OutputEditor* outputEditor = new OutputEditor(m_shaderGraph); + + QDockWidget* outputDock = new QDockWidget(tr("Outputs")); + outputDock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable); + outputDock->setWidget(outputEditor); + + addDockWidget(Qt::LeftDockWidgetArea, outputDock); + + // Texture editor TextureEditor* textureEditor = new TextureEditor(m_shaderGraph); QDockWidget* textureDock = new QDockWidget(tr("Textures")); @@ -36,6 +48,7 @@ m_shaderGraph(graph) addDockWidget(Qt::LeftDockWidgetArea, textureDock); + // Node editor m_nodeEditor = new NodeEditor; QDockWidget* nodeEditorDock = new QDockWidget(tr("Node editor")); diff --git a/src/ShaderNode/Widgets/OutputEditDialog.cpp b/src/ShaderNode/Widgets/OutputEditDialog.cpp new file mode 100644 index 000000000..23f092f75 --- /dev/null +++ b/src/ShaderNode/Widgets/OutputEditDialog.cpp @@ -0,0 +1,67 @@ +#include +#include +#include +#include +#include +#include +#include + +OutputEditDialog::OutputEditDialog(QWidget* parent) : +QDialog(parent) +{ + setWindowTitle(tr("Output edit dialog")); + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + + m_outputName = new QLineEdit; + + m_typeList = new QComboBox; + for (std::size_t i = 0; i < InOutTypeCount; ++i) + m_typeList->addItem(EnumToString(static_cast(i))); + + QFormLayout* formLayout = new QFormLayout; + formLayout->addRow(tr("Name"), m_outputName); + formLayout->addRow(tr("Type"), m_typeList); + + QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + connect(buttonBox, &QDialogButtonBox::accepted, this, &OutputEditDialog::OnAccept); + connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + + QVBoxLayout* verticalLayout = new QVBoxLayout; + verticalLayout->addLayout(formLayout); + verticalLayout->addWidget(buttonBox); + + setLayout(verticalLayout); +} + +OutputEditDialog::OutputEditDialog(const OutputInfo& input, QWidget* parent) : +OutputEditDialog(parent) +{ + m_outputName->setText(QString::fromStdString(input.name)); + m_typeList->setCurrentText(EnumToString(input.type)); +} + +OutputInfo OutputEditDialog::GetOutputInfo() const +{ + OutputInfo inputInfo; + inputInfo.name = m_outputName->text().toStdString(); + inputInfo.type = static_cast(m_typeList->currentIndex()); + + return inputInfo; +} + +void OutputEditDialog::OnAccept() +{ + if (m_outputName->text().isEmpty()) + { + QMessageBox::critical(this, tr("Empty name"), tr("Output name must be set"), QMessageBox::Ok); + return; + } + + if (m_typeList->currentIndex() < 0) + { + QMessageBox::critical(this, tr("Invalid type"), tr("You must select a type"), QMessageBox::Ok); + return; + } + + accept(); +} diff --git a/src/ShaderNode/Widgets/OutputEditDialog.hpp b/src/ShaderNode/Widgets/OutputEditDialog.hpp new file mode 100644 index 000000000..3c06323dd --- /dev/null +++ b/src/ShaderNode/Widgets/OutputEditDialog.hpp @@ -0,0 +1,36 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_OUTPUTEDITDIALOG_HPP +#define NAZARA_SHADERNODES_OUTPUTEDITDIALOG_HPP + +#include +#include + +class QComboBox; +class QLineEdit; + +struct OutputInfo +{ + std::string name; + InOutType type; +}; + +class OutputEditDialog : public QDialog +{ + public: + OutputEditDialog(QWidget* parent = nullptr); + OutputEditDialog(const OutputInfo& input, QWidget* parent = nullptr); + ~OutputEditDialog() = default; + + OutputInfo GetOutputInfo() const; + + private: + void OnAccept(); + + QComboBox* m_typeList; + QLineEdit* m_outputName; +}; + +#include + +#endif diff --git a/src/ShaderNode/Widgets/OutputEditDialog.inl b/src/ShaderNode/Widgets/OutputEditDialog.inl new file mode 100644 index 000000000..9c2c2892b --- /dev/null +++ b/src/ShaderNode/Widgets/OutputEditDialog.inl @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/Widgets/OutputEditor.cpp b/src/ShaderNode/Widgets/OutputEditor.cpp new file mode 100644 index 000000000..ba317de07 --- /dev/null +++ b/src/ShaderNode/Widgets/OutputEditor.cpp @@ -0,0 +1,95 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +OutputEditor::OutputEditor(ShaderGraph& graph) : +m_shaderGraph(graph) +{ + m_outputList = new QListWidget(this); + connect(m_outputList, &QListWidget::currentRowChanged, this, &OutputEditor::OnOutputSelectionUpdate); + connect(m_outputList, &QListWidget::itemDoubleClicked, [this](QListWidgetItem* item) + { + OnEditOutput(m_outputList->row(item)); + }); + + QPushButton* addOutputButton = new QPushButton(tr("Add output...")); + connect(addOutputButton, &QPushButton::released, this, &OutputEditor::OnAddOutput); + + m_layout = new QVBoxLayout; + m_layout->addWidget(m_outputList); + m_layout->addWidget(addOutputButton); + + setLayout(m_layout); + + m_onOutputListUpdateSlot.Connect(m_shaderGraph.OnOutputListUpdate, this, &OutputEditor::OnOutputListUpdate); + m_onOutputUpdateSlot.Connect(m_shaderGraph.OnOutputUpdate, this, &OutputEditor::OnOutputUpdate); + + RefreshOutputs(); +} + +void OutputEditor::OnAddOutput() +{ + OutputEditDialog* dialog = new OutputEditDialog(this); + dialog->setAttribute(Qt::WA_DeleteOnClose, true); + connect(dialog, &QDialog::accepted, [this, dialog] + { + OutputInfo inputInfo = dialog->GetOutputInfo(); + m_shaderGraph.AddOutput(std::move(inputInfo.name), inputInfo.type); + }); + + dialog->open(); +} + +void OutputEditor::OnEditOutput(int inputIndex) +{ + const auto& input = m_shaderGraph.GetOutput(inputIndex); + + OutputInfo info; + info.name = input.name; + info.type = input.type; + + OutputEditDialog* dialog = new OutputEditDialog(std::move(info), this); + dialog->setAttribute(Qt::WA_DeleteOnClose, true); + connect(dialog, &QDialog::accepted, [this, dialog, inputIndex] + { + OutputInfo inputInfo = dialog->GetOutputInfo(); + m_shaderGraph.UpdateOutput(inputIndex, std::move(inputInfo.name), inputInfo.type); + }); + + dialog->open(); +} + +void OutputEditor::OnOutputSelectionUpdate(int inputIndex) +{ + if (inputIndex >= 0) + { + m_currentOutputIndex = inputIndex; + } + else + m_currentOutputIndex.reset(); +} + +void OutputEditor::OnOutputListUpdate(ShaderGraph* /*graph*/) +{ + RefreshOutputs(); +} + +void OutputEditor::OnOutputUpdate(ShaderGraph* /*graph*/, std::size_t inputIndex) +{ + const auto& inputEntry = m_shaderGraph.GetOutput(inputIndex); + m_outputList->item(int(inputIndex))->setText(QString::fromStdString(inputEntry.name)); +} + +void OutputEditor::RefreshOutputs() +{ + m_outputList->clear(); + m_outputList->setCurrentRow(-1); + + for (const auto& inputEntry : m_shaderGraph.GetOutputs()) + m_outputList->addItem(QString::fromStdString(inputEntry.name)); +} diff --git a/src/ShaderNode/Widgets/OutputEditor.hpp b/src/ShaderNode/Widgets/OutputEditor.hpp new file mode 100644 index 000000000..6aa53eda0 --- /dev/null +++ b/src/ShaderNode/Widgets/OutputEditor.hpp @@ -0,0 +1,39 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_OUTPUTEDITOR_HPP +#define NAZARA_SHADERNODES_OUTPUTEDITOR_HPP + +#include +#include +#include + +class QLabel; +class QListWidget; +class QVBoxLayout; + +class OutputEditor : public QWidget +{ + public: + OutputEditor(ShaderGraph& graph); + ~OutputEditor() = default; + + private: + void OnAddOutput(); + void OnEditOutput(int inputIndex); + void OnOutputSelectionUpdate(int inputIndex); + void OnOutputListUpdate(ShaderGraph* graph); + void OnOutputUpdate(ShaderGraph* graph, std::size_t inputIndex); + void RefreshOutputs(); + + NazaraSlot(ShaderGraph, OnOutputListUpdate, m_onOutputListUpdateSlot); + NazaraSlot(ShaderGraph, OnOutputUpdate, m_onOutputUpdateSlot); + + std::optional m_currentOutputIndex; + ShaderGraph& m_shaderGraph; + QListWidget* m_outputList; + QVBoxLayout* m_layout; +}; + +#include + +#endif diff --git a/src/ShaderNode/Widgets/OutputEditor.inl b/src/ShaderNode/Widgets/OutputEditor.inl new file mode 100644 index 000000000..10ed1238b --- /dev/null +++ b/src/ShaderNode/Widgets/OutputEditor.inl @@ -0,0 +1 @@ +#include From effd1b45529115689feab513f12fe897ae503385 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 31 May 2020 18:39:28 +0200 Subject: [PATCH 225/316] ShaderNode: Handle vector component count at runtime --- include/Nazara/Renderer/ShaderAst.hpp | 4 + include/Nazara/Renderer/ShaderAst.inl | 19 ++- src/Nazara/Renderer/ShaderAst.cpp | 17 +++ src/ShaderNode/DataModels/Cast.hpp | 24 ++-- src/ShaderNode/DataModels/Cast.inl | 148 ++++++++++++-------- src/ShaderNode/DataModels/InputValue.cpp | 27 +++- src/ShaderNode/DataModels/InputValue.hpp | 3 + src/ShaderNode/DataModels/OutputValue.cpp | 42 +++++- src/ShaderNode/DataModels/OutputValue.hpp | 3 + src/ShaderNode/DataModels/SampleTexture.cpp | 40 ++++-- src/ShaderNode/DataModels/SampleTexture.hpp | 7 +- src/ShaderNode/DataModels/TextureValue.cpp | 20 ++- src/ShaderNode/DataModels/TextureValue.hpp | 3 + src/ShaderNode/DataModels/VecBinOp.cpp | 72 ++++++++++ src/ShaderNode/DataModels/VecBinOp.hpp | 35 ++--- src/ShaderNode/DataModels/VecBinOp.inl | 127 ++++------------- src/ShaderNode/DataModels/VecValue.hpp | 10 +- src/ShaderNode/DataModels/VecValue.inl | 50 +++---- src/ShaderNode/DataTypes/FloatData.cpp | 1 + src/ShaderNode/DataTypes/FloatData.hpp | 28 ++++ src/ShaderNode/DataTypes/FloatData.inl | 7 + src/ShaderNode/DataTypes/VecData.cpp | 17 +++ src/ShaderNode/DataTypes/VecData.hpp | 65 ++++----- src/ShaderNode/DataTypes/VecData.inl | 13 +- src/ShaderNode/Enums.cpp | 15 ++ src/ShaderNode/Enums.hpp | 2 + src/ShaderNode/ShaderGraph.cpp | 43 ++---- src/ShaderNode/Widgets/MainWindow.cpp | 26 ++-- 28 files changed, 529 insertions(+), 339 deletions(-) create mode 100644 src/ShaderNode/DataTypes/FloatData.cpp create mode 100644 src/ShaderNode/DataTypes/FloatData.hpp create mode 100644 src/ShaderNode/DataTypes/FloatData.inl diff --git a/include/Nazara/Renderer/ShaderAst.hpp b/include/Nazara/Renderer/ShaderAst.hpp index 28b808d6c..08e8e20b2 100644 --- a/include/Nazara/Renderer/ShaderAst.hpp +++ b/include/Nazara/Renderer/ShaderAst.hpp @@ -258,6 +258,7 @@ namespace Nz { public: inline Cast(ExpressionType castTo, ExpressionPtr first, ExpressionPtr second = nullptr, ExpressionPtr third = nullptr, ExpressionPtr fourth = nullptr); + inline Cast(ExpressionType castTo, ExpressionPtr* expressions, std::size_t expressionCount); ExpressionType GetExpressionType() const override; void Register(ShaderWriter& visitor) override; @@ -265,6 +266,9 @@ namespace Nz ExpressionType exprType; std::array expressions; + + private: + void Validate() const; }; class NAZARA_RENDERER_API Constant : public Expression diff --git a/include/Nazara/Renderer/ShaderAst.inl b/include/Nazara/Renderer/ShaderAst.inl index ea9e5cddf..e837cbdb4 100644 --- a/include/Nazara/Renderer/ShaderAst.inl +++ b/include/Nazara/Renderer/ShaderAst.inl @@ -169,19 +169,16 @@ namespace Nz exprType(castTo), expressions({ {first, second, third, fourth} }) { - unsigned int componentCount = 0; - unsigned int requiredComponents = GetComponentCount(exprType); - for (const auto& exprPtr : expressions) - { - if (!exprPtr) - break; + Validate(); + } - componentCount += GetComponentCount(exprPtr->GetExpressionType()); - } + inline Cast::Cast(ExpressionType castTo, ExpressionPtr* Expressions, std::size_t expressionCount) : + exprType(castTo) + { + for (std::size_t i = 0; i < expressionCount; ++i) + expressions[i] = Expressions[i]; - //TODO: AstParseError - if (componentCount != requiredComponents) - throw std::runtime_error("Component count doesn't match required component count"); + Validate(); } inline Constant::Constant(bool value) : diff --git a/src/Nazara/Renderer/ShaderAst.cpp b/src/Nazara/Renderer/ShaderAst.cpp index 0899cbdc7..a0a0cc031 100644 --- a/src/Nazara/Renderer/ShaderAst.cpp +++ b/src/Nazara/Renderer/ShaderAst.cpp @@ -200,6 +200,23 @@ namespace Nz::ShaderAst visitor.Write(*this); } + void Cast::Validate() const + { + unsigned int componentCount = 0; + unsigned int requiredComponents = GetComponentCount(exprType); + for (const auto& exprPtr : expressions) + { + if (!exprPtr) + break; + + componentCount += GetComponentCount(exprPtr->GetExpressionType()); + } + + //TODO: AstParseError + if (componentCount != requiredComponents) + throw std::runtime_error("Component count doesn't match required component count"); + } + ExpressionCategory SwizzleOp::GetExpressionCategory() const { diff --git a/src/ShaderNode/DataModels/Cast.hpp b/src/ShaderNode/DataModels/Cast.hpp index c1b63e8e0..90dad931e 100644 --- a/src/ShaderNode/DataModels/Cast.hpp +++ b/src/ShaderNode/DataModels/Cast.hpp @@ -10,7 +10,7 @@ #include #include -template +template class CastVec : public ShaderNode { public: @@ -31,25 +31,21 @@ class CastVec : public ShaderNode void setInData(std::shared_ptr value, int index) override; - private: - static constexpr std::size_t FromComponents = From::ComponentCount; - static constexpr std::size_t ToComponents = To::ComponentCount; - static constexpr std::size_t ComponentDiff = (ToComponents >= FromComponents) ? ToComponents - FromComponents : 0; + QtNodes::NodeValidationState validationState() const override; + QString validationMessage() const override; + private: bool ComputePreview(QPixmap& pixmap) override; void UpdateOutput(); - VecType m_overflowComponents; - std::shared_ptr m_input; - std::shared_ptr m_output; + std::shared_ptr m_input; + std::shared_ptr m_output; + VecType m_overflowComponents; }; -using CastVec2ToVec3 = CastVec; -using CastVec2ToVec4 = CastVec; -using CastVec3ToVec2 = CastVec; -using CastVec3ToVec4 = CastVec; -using CastVec4ToVec2 = CastVec; -using CastVec4ToVec3 = CastVec; +using CastToVec2 = CastVec<2>; +using CastToVec3 = CastVec<3>; +using CastToVec4 = CastVec<4>; #include diff --git a/src/ShaderNode/DataModels/Cast.inl b/src/ShaderNode/DataModels/Cast.inl index 56866aa3e..64ed934a2 100644 --- a/src/ShaderNode/DataModels/Cast.inl +++ b/src/ShaderNode/DataModels/Cast.inl @@ -4,21 +4,32 @@ #include #include -template -CastVec::CastVec(ShaderGraph& graph) : +template +CastVec::CastVec(ShaderGraph& graph) : ShaderNode(graph) { - static_assert(ComponentDiff <= s_vectorComponents.size()); + static_assert(ToComponentCount <= s_vectorComponents.size()); + + m_overflowComponents.fill(0.f); + + m_output = std::make_shared(ToComponentCount); } -template -void CastVec::BuildNodeEdition(QFormLayout* layout) +template +void CastVec::BuildNodeEdition(QFormLayout* layout) { ShaderNode::BuildNodeEdition(layout); - if constexpr (ComponentDiff > 0) + if (!m_input) + return; + + std::size_t fromComponentCount = m_input->componentCount; + + if (ToComponentCount > fromComponentCount) { - for (std::size_t i = 0; i < ComponentDiff; ++i) + std::size_t overflowComponentCount = ToComponentCount - fromComponentCount; + + for (std::size_t i = 0; i < overflowComponentCount; ++i) { QDoubleSpinBox* spinbox = new QDoubleSpinBox; spinbox->setDecimals(6); @@ -30,31 +41,36 @@ void CastVec::BuildNodeEdition(QFormLayout* layout) UpdateOutput(); }); - layout->addRow(QString::fromUtf8(&s_vectorComponents[FromComponents + i], 1), spinbox); + layout->addRow(QString::fromUtf8(&s_vectorComponents[fromComponentCount + i], 1), spinbox); } } } -template -Nz::ShaderAst::ExpressionPtr CastVec::GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const +template +Nz::ShaderAst::ExpressionPtr CastVec::GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const { + assert(m_input); assert(count == 1); - if constexpr (ComponentDiff > 0) - { - std::array constants; - for (std::size_t i = 0; i < ComponentDiff; ++i) - constants[i] = Nz::ShaderBuilder::Constant(m_overflowComponents[i]); + std::size_t fromComponentCount = m_input->componentCount; - return std::apply([&](auto&&... values) - { - return Nz::ShaderBuilder::Cast(expressions[0], values...); //< TODO: Forward - }, constants); - } - else + if (ToComponentCount > fromComponentCount) { - std::array swizzleComponents; - for (std::size_t i = 0; i < ToComponents; ++i) + std::size_t overflowComponentCount = ToComponentCount - fromComponentCount; + + std::array expr; + expr[0] = expressions[0]; + for (std::size_t i = 0; i < overflowComponentCount; ++i) + expr[i + 1] = Nz::ShaderBuilder::Constant(m_overflowComponents[i]); + + constexpr auto ExpressionType = VecExpressionType; + + return Nz::ShaderBuilder::Cast(expr.data(), overflowComponentCount); + } + else if (ToComponentCount < fromComponentCount) + { + std::array swizzleComponents; + for (std::size_t i = 0; i < ToComponentCount; ++i) swizzleComponents[i] = static_cast(static_cast(Nz::ShaderAst::SwizzleComponent::First) + i); return std::apply([&](auto... components) @@ -63,39 +79,41 @@ Nz::ShaderAst::ExpressionPtr CastVec::GetExpression(Nz::ShaderAst::Exp return Nz::ShaderBuilder::Swizzle(expressions[0], componentList); }, swizzleComponents); } + else + return expressions[0]; //< no-op } -template -QString CastVec::caption() const +template +QString CastVec::caption() const { - static QString caption = From::Type().name + " to " + To::Type().name; + static QString caption = "To Vector" + QString::number(ToComponentCount); return caption; } -template -QString CastVec::name() const +template +QString CastVec::name() const { - static QString name = From::Type().id + "to" + To::Type().id; + static QString name = "cast_vec" + QString::number(ToComponentCount); return name; } -template -QtNodes::NodeDataType CastVec::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const +template +QtNodes::NodeDataType CastVec::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const { assert(portIndex == 0); switch (portType) { - case QtNodes::PortType::In: return From::Type(); - case QtNodes::PortType::Out: return To::Type(); + case QtNodes::PortType::In: return VecData::Type(); + case QtNodes::PortType::Out: return VecData::Type(); } assert(false); throw std::runtime_error("Invalid port type"); } -template -unsigned int CastVec::nPorts(QtNodes::PortType portType) const +template +unsigned int CastVec::nPorts(QtNodes::PortType portType) const { switch (portType) { @@ -106,8 +124,8 @@ unsigned int CastVec::nPorts(QtNodes::PortType portType) const return 0; } -template -std::shared_ptr CastVec::outData(QtNodes::PortIndex port) +template +std::shared_ptr CastVec::outData(QtNodes::PortIndex port) { assert(port == 0); @@ -117,14 +135,14 @@ std::shared_ptr CastVec::outData(QtNodes::PortIndex return m_output; } -template -void CastVec::setInData(std::shared_ptr value, int index) +template +void CastVec::setInData(std::shared_ptr value, int index) { assert(index == 0); if (value) { - assert(dynamic_cast(value.get()) != nullptr); - m_input = std::static_pointer_cast(value); + assert(dynamic_cast(value.get()) != nullptr); + m_input = std::static_pointer_cast(value); } else m_input.reset(); @@ -132,8 +150,26 @@ void CastVec::setInData(std::shared_ptr value, int UpdateOutput(); } -template -bool CastVec::ComputePreview(QPixmap& pixmap) +template +QtNodes::NodeValidationState CastVec::validationState() const +{ + if (!m_input) + return QtNodes::NodeValidationState::Error; + + return QtNodes::NodeValidationState::Valid; +} + +template +QString CastVec::validationMessage() const +{ + if (!m_input) + return "Missing input"; + + return QString(); +} + +template +bool CastVec::ComputePreview(QPixmap& pixmap) { if (!m_input) return false; @@ -142,8 +178,8 @@ bool CastVec::ComputePreview(QPixmap& pixmap) return true; } -template -void CastVec::UpdateOutput() +template +void CastVec::UpdateOutput() { if (!m_input) { @@ -160,10 +196,15 @@ void CastVec::UpdateOutput() QImage& output = m_output->preview; output = QImage(inputWidth, inputHeight, QImage::Format_RGBA8888); - std::array constants; - if constexpr (ComponentDiff > 0) + std::size_t fromComponentCount = m_input->componentCount; + std::size_t commonComponents = std::min(fromComponentCount, ToComponentCount); + std::size_t overflowComponentCount = (ToComponentCount > fromComponentCount) ? ToComponentCount - fromComponentCount : 0; + std::size_t voidComponents = 4 - overflowComponentCount - commonComponents; + + std::array constants; + if (ToComponentCount > fromComponentCount) { - for (std::size_t i = 0; i < ComponentDiff; ++i) + for (std::size_t i = 0; i < overflowComponentCount; ++i) constants[i] = static_cast(std::clamp(int(m_overflowComponents[i] * 255), 0, 255)); } @@ -173,17 +214,14 @@ void CastVec::UpdateOutput() { for (int x = 0; x < inputWidth; ++x) { - constexpr std::size_t CommonComponents = std::min(FromComponents, ToComponents); - constexpr std::size_t VoidComponents = 4 - ComponentDiff - CommonComponents; - - for (std::size_t i = 0; i < CommonComponents; ++i) + for (std::size_t i = 0; i < commonComponents; ++i) *outputPtr++ = inputPtr[i]; - for (std::size_t i = 0; i < ComponentDiff; ++i) + for (std::size_t i = 0; i < overflowComponentCount; ++i) *outputPtr++ = constants[i]; - for (std::size_t i = 0; i < VoidComponents; ++i) - *outputPtr++ = (i == VoidComponents - 1) ? 255 : 0; + for (std::size_t i = 0; i < voidComponents; ++i) + *outputPtr++ = (i == voidComponents - 1) ? 255 : 0; inputPtr += 4; } diff --git a/src/ShaderNode/DataModels/InputValue.cpp b/src/ShaderNode/DataModels/InputValue.cpp index 9ff7fd207..6defcb30f 100644 --- a/src/ShaderNode/DataModels/InputValue.cpp +++ b/src/ShaderNode/DataModels/InputValue.cpp @@ -121,16 +121,17 @@ auto InputValue::dataType(QtNodes::PortType portType, QtNodes::PortIndex portInd assert(portIndex == 0); if (!m_currentInputIndex) - return Vec4Data::Type(); + return VecData::Type(); const auto& inputEntry = GetGraph().GetInput(*m_currentInputIndex); switch (inputEntry.type) { //case InputType::Bool: return Nz::ShaderAst::ExpressionType::Boolean; //case InputType::Float1: return Nz::ShaderAst::ExpressionType::Float1; - case InOutType::Float2: return Vec2Data::Type(); - case InOutType::Float3: return Vec3Data::Type(); - case InOutType::Float4: return Vec4Data::Type(); + case InOutType::Float2: + case InOutType::Float3: + case InOutType::Float4: + return VecData::Type(); } assert(false); @@ -148,8 +149,24 @@ std::shared_ptr InputValue::outData(QtNodes::PortIndex port) const auto& inputEntry = graph.GetInput(*m_currentInputIndex); const auto& preview = graph.GetPreviewModel(); - auto vecData = std::make_shared(); + auto vecData = std::make_shared(GetComponentCount(inputEntry.type)); vecData->preview = preview.GetImage(inputEntry.role, inputEntry.roleIndex); return vecData; } + +QtNodes::NodeValidationState InputValue::validationState() const +{ + if (!m_currentInputIndex) + return QtNodes::NodeValidationState::Error; + + return QtNodes::NodeValidationState::Valid; +} + +QString InputValue::validationMessage() const +{ + if (!m_currentInputIndex) + return "No input selected"; + + return QString(); +} diff --git a/src/ShaderNode/DataModels/InputValue.hpp b/src/ShaderNode/DataModels/InputValue.hpp index 0170221f5..4b4c1b31c 100644 --- a/src/ShaderNode/DataModels/InputValue.hpp +++ b/src/ShaderNode/DataModels/InputValue.hpp @@ -30,6 +30,9 @@ class InputValue : public ShaderNode std::shared_ptr outData(QtNodes::PortIndex port) override; + QtNodes::NodeValidationState validationState() const override; + QString validationMessage() const override; + private: bool ComputePreview(QPixmap& pixmap) override; void OnInputListUpdate(); diff --git a/src/ShaderNode/DataModels/OutputValue.cpp b/src/ShaderNode/DataModels/OutputValue.cpp index 2d3a8dc14..04eeafd48 100644 --- a/src/ShaderNode/DataModels/OutputValue.cpp +++ b/src/ShaderNode/DataModels/OutputValue.cpp @@ -87,16 +87,17 @@ QtNodes::NodeDataType OutputValue::dataType(QtNodes::PortType portType, QtNodes: assert(portIndex == 0); if (!m_currentOutputIndex) - return Vec4Data::Type(); + return VecData::Type(); const auto& outputEntry = GetGraph().GetOutput(*m_currentOutputIndex); switch (outputEntry.type) { //case InOutType::Bool: return Nz::ShaderAst::ExpressionType::Boolean; //case InOutType::Float1: return Nz::ShaderAst::ExpressionType::Float1; - case InOutType::Float2: return Vec2Data::Type(); - case InOutType::Float3: return Vec3Data::Type(); - case InOutType::Float4: return Vec4Data::Type(); + case InOutType::Float2: + case InOutType::Float3: + case InOutType::Float4: + return VecData::Type(); } assert(false); @@ -124,8 +125,8 @@ void OutputValue::setInData(std::shared_ptr value, int index) assert(index == 0); if (value) { - assert(dynamic_cast(value.get()) != nullptr); - m_input = std::static_pointer_cast(value); + assert(dynamic_cast(value.get()) != nullptr); + m_input = std::static_pointer_cast(value); } else m_input.reset(); @@ -133,6 +134,35 @@ void OutputValue::setInData(std::shared_ptr value, int index) UpdatePreview(); } +QtNodes::NodeValidationState OutputValue::validationState() const +{ + if (!m_currentOutputIndex || !m_input) + return QtNodes::NodeValidationState::Error; + + const auto& outputEntry = GetGraph().GetOutput(*m_currentOutputIndex); + if (GetComponentCount(outputEntry.type) != m_input->componentCount) + return QtNodes::NodeValidationState::Error; + + return QtNodes::NodeValidationState::Valid; +} + +QString OutputValue::validationMessage() const +{ + if (!m_currentOutputIndex) + return "No output selected"; + + if (!m_input) + return "Missing input"; + + const auto& outputEntry = GetGraph().GetOutput(*m_currentOutputIndex); + std::size_t outputComponentCount = GetComponentCount(outputEntry.type); + + if (m_input->componentCount != outputComponentCount) + return "Incompatible component count (expected " + QString::number(outputComponentCount) + ", got " + QString::number(m_input->componentCount) + ")"; + + return QString(); +} + bool OutputValue::ComputePreview(QPixmap& pixmap) { if (!m_input) diff --git a/src/ShaderNode/DataModels/OutputValue.hpp b/src/ShaderNode/DataModels/OutputValue.hpp index 8db611056..1e7055da5 100644 --- a/src/ShaderNode/DataModels/OutputValue.hpp +++ b/src/ShaderNode/DataModels/OutputValue.hpp @@ -29,6 +29,9 @@ class OutputValue : public ShaderNode void setInData(std::shared_ptr value, int index) override; + QtNodes::NodeValidationState validationState() const override; + QString validationMessage() const override; + private: bool ComputePreview(QPixmap& pixmap) override; void OnOutputListUpdate(); diff --git a/src/ShaderNode/DataModels/SampleTexture.cpp b/src/ShaderNode/DataModels/SampleTexture.cpp index e0fa852c3..970e8a965 100644 --- a/src/ShaderNode/DataModels/SampleTexture.cpp +++ b/src/ShaderNode/DataModels/SampleTexture.cpp @@ -5,7 +5,7 @@ SampleTexture::SampleTexture(ShaderGraph& graph) : ShaderNode(graph) { - m_output = std::make_shared(); + m_output = std::make_shared(4); UpdateOutput(); } @@ -82,9 +82,8 @@ bool SampleTexture::ComputePreview(QPixmap& pixmap) Nz::ShaderAst::ExpressionPtr SampleTexture::GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const { - if (!m_texture || !m_uv) - throw std::runtime_error("invalid inputs"); - + assert(m_texture); + assert(m_uv); assert(count == 2); return Nz::ShaderBuilder::Sample2D(expressions[0], expressions[1]); @@ -99,7 +98,7 @@ auto SampleTexture::dataType(QtNodes::PortType portType, QtNodes::PortIndex port switch (portIndex) { case 0: return Texture2Data::Type(); - case 1: return Vec2Data::Type(); + case 1: return VecData::Type(); } assert(false); @@ -109,7 +108,7 @@ auto SampleTexture::dataType(QtNodes::PortType portType, QtNodes::PortIndex port case QtNodes::PortType::Out: { assert(portIndex == 0); - return Vec4Data::Type(); + return VecData::Type(); } default: @@ -180,9 +179,9 @@ void SampleTexture::setInData(std::shared_ptr value, int inde { if (value) { - assert(dynamic_cast(value.get()) != nullptr); + assert(dynamic_cast(value.get()) != nullptr); - m_uv = std::static_pointer_cast(value); + m_uv = std::static_pointer_cast(value); } else m_uv.reset(); @@ -197,3 +196,28 @@ void SampleTexture::setInData(std::shared_ptr value, int inde UpdateOutput(); } + +QtNodes::NodeValidationState SampleTexture::validationState() const +{ + if (!m_texture || !m_uv) + return QtNodes::NodeValidationState::Error; + + if (m_uv->componentCount != 2) + return QtNodes::NodeValidationState::Error; + + return QtNodes::NodeValidationState::Valid; +} + +QString SampleTexture::validationMessage() const +{ + if (!m_texture) + return "Missing texture"; + + if (!m_uv) + return "Missing uv"; + + if (m_uv->componentCount != 2) + return "Incompatible UV (expected 2, got " + QString::number(m_uv->componentCount) + ")"; + + return QString(); +} diff --git a/src/ShaderNode/DataModels/SampleTexture.hpp b/src/ShaderNode/DataModels/SampleTexture.hpp index 7a24409d0..7afb77e0f 100644 --- a/src/ShaderNode/DataModels/SampleTexture.hpp +++ b/src/ShaderNode/DataModels/SampleTexture.hpp @@ -34,13 +34,16 @@ class SampleTexture : public ShaderNode void setInData(std::shared_ptr value, int index) override; + QtNodes::NodeValidationState validationState() const override; + QString validationMessage() const override; + protected: bool ComputePreview(QPixmap& pixmap) override; void UpdateOutput(); std::shared_ptr m_texture; - std::shared_ptr m_uv; - std::shared_ptr m_output; + std::shared_ptr m_uv; + std::shared_ptr m_output; }; #include diff --git a/src/ShaderNode/DataModels/TextureValue.cpp b/src/ShaderNode/DataModels/TextureValue.cpp index 976ec7dd7..f78a610a9 100644 --- a/src/ShaderNode/DataModels/TextureValue.cpp +++ b/src/ShaderNode/DataModels/TextureValue.cpp @@ -92,7 +92,7 @@ void TextureValue::BuildNodeEdition(QFormLayout* layout) Nz::ShaderAst::ExpressionPtr TextureValue::GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const { if (!m_currentTextureIndex) - throw std::runtime_error("invalid inputs"); + throw std::runtime_error("invalid texture input"); assert(count == 0); @@ -117,7 +117,7 @@ auto TextureValue::dataType(QtNodes::PortType portType, QtNodes::PortIndex portI assert(portType == QtNodes::PortType::Out); assert(portIndex == 0); - return Vec4Data::Type(); + return VecData::Type(); } std::shared_ptr TextureValue::outData(QtNodes::PortIndex port) @@ -145,3 +145,19 @@ std::shared_ptr TextureValue::outData(QtNodes::PortIndex port return textureData; } + +QtNodes::NodeValidationState TextureValue::validationState() const +{ + if (!m_currentTextureIndex) + return QtNodes::NodeValidationState::Error; + + return QtNodes::NodeValidationState::Valid; +} + +QString TextureValue::validationMessage() const +{ + if (!m_currentTextureIndex) + return "No texture selected"; + + return QString(); +} diff --git a/src/ShaderNode/DataModels/TextureValue.hpp b/src/ShaderNode/DataModels/TextureValue.hpp index 27ae9474a..fdf355828 100644 --- a/src/ShaderNode/DataModels/TextureValue.hpp +++ b/src/ShaderNode/DataModels/TextureValue.hpp @@ -29,6 +29,9 @@ class TextureValue : public ShaderNode std::shared_ptr outData(QtNodes::PortIndex port) override; + QtNodes::NodeValidationState validationState() const override; + QString validationMessage() const override; + protected: bool ComputePreview(QPixmap& pixmap) override; void OnTextureListUpdate(); diff --git a/src/ShaderNode/DataModels/VecBinOp.cpp b/src/ShaderNode/DataModels/VecBinOp.cpp index fd2e0d5c1..8f63c2642 100644 --- a/src/ShaderNode/DataModels/VecBinOp.cpp +++ b/src/ShaderNode/DataModels/VecBinOp.cpp @@ -1 +1,73 @@ #include + +QString VecAdd::caption() const +{ + static QString caption = "Vector addition"; + return caption; +} + +QString VecAdd::name() const +{ + static QString name = "vec_add"; + return name; +} + +void VecAdd::ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) +{ + for (std::size_t i = 0; i < pixelCount; ++i) + { + unsigned int lValue = left[i]; + unsigned int rValue = right[i]; + + output[i] = static_cast(std::min(lValue + rValue, 255U)); + } +} + +QString VecMul::caption() const +{ + static QString caption = "Vector multiplication"; + return caption; +} + +QString VecMul::name() const +{ + static QString name = "vec_mul"; + return name; +} + +void VecMul::ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) +{ + for (std::size_t i = 0; i < pixelCount; ++i) + { + unsigned int lValue = left[i]; + unsigned int rValue = right[i]; + + output[i] = static_cast(lValue * rValue / 255); + } +} + +QString VecSub::caption() const +{ + static QString caption = "Vector subtraction"; + return caption; +} + + +QString VecSub::name() const +{ + static QString name = "vec_sub"; + return name; +} + +void VecSub::ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) +{ + for (std::size_t i = 0; i < pixelCount; ++i) + { + unsigned int lValue = left[i]; + unsigned int rValue = right[i]; + + unsigned int sub = (lValue >= rValue) ? lValue - rValue : 0u; + + output[i] = static_cast(sub); + } +} diff --git a/src/ShaderNode/DataModels/VecBinOp.hpp b/src/ShaderNode/DataModels/VecBinOp.hpp index 6fa8fe875..f8bebc667 100644 --- a/src/ShaderNode/DataModels/VecBinOp.hpp +++ b/src/ShaderNode/DataModels/VecBinOp.hpp @@ -6,7 +6,7 @@ #include #include -template +template class VecBinOp : public ShaderNode { public: @@ -29,16 +29,15 @@ class VecBinOp : public ShaderNode bool ComputePreview(QPixmap& pixmap) override; void UpdateOutput(); - std::shared_ptr m_lhs; - std::shared_ptr m_rhs; - std::shared_ptr m_output; + std::shared_ptr m_lhs; + std::shared_ptr m_rhs; + std::shared_ptr m_output; }; -template -class VecAdd : public VecBinOp +class VecAdd : public VecBinOp { public: - using VecBinOp::VecBinOp; + using VecBinOp::VecBinOp; QString caption() const override; QString name() const override; @@ -46,11 +45,10 @@ class VecAdd : public VecBinOp void ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) override; }; -template -class VecMul : public VecBinOp +class VecMul : public VecBinOp { public: - using VecBinOp::VecBinOp; + using VecBinOp::VecBinOp; QString caption() const override; QString name() const override; @@ -58,11 +56,10 @@ class VecMul : public VecBinOp void ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) override; }; -template -class VecSub : public VecBinOp +class VecSub : public VecBinOp { public: - using VecBinOp::VecBinOp; + using VecBinOp::VecBinOp; QString caption() const override; QString name() const override; @@ -70,18 +67,6 @@ class VecSub : public VecBinOp void ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) override; }; -using Vec2Add = VecAdd; -using Vec3Add = VecAdd; -using Vec4Add = VecAdd; - -using Vec2Mul = VecMul; -using Vec3Mul = VecMul; -using Vec4Mul = VecMul; - -using Vec2Sub = VecSub; -using Vec3Sub = VecSub; -using Vec4Sub = VecSub; - #include #endif diff --git a/src/ShaderNode/DataModels/VecBinOp.inl b/src/ShaderNode/DataModels/VecBinOp.inl index 2d33f65c6..7d3cf1e12 100644 --- a/src/ShaderNode/DataModels/VecBinOp.inl +++ b/src/ShaderNode/DataModels/VecBinOp.inl @@ -1,17 +1,15 @@ #include #include -template -VecBinOp::VecBinOp(ShaderGraph& graph) : +template +VecBinOp::VecBinOp(ShaderGraph& graph) : ShaderNode(graph) { - m_output = std::make_shared(); - UpdateOutput(); } -template -Nz::ShaderAst::ExpressionPtr VecBinOp::GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const +template +Nz::ShaderAst::ExpressionPtr VecBinOp::GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const { assert(count == 2); using BuilderType = typename Nz::ShaderBuilder::template BinOpBuilder; @@ -19,16 +17,16 @@ Nz::ShaderAst::ExpressionPtr VecBinOp::GetExpression(Nz::ShaderAst: return builder(expressions[0], expressions[1]); } -template -QtNodes::NodeDataType VecBinOp::dataType(QtNodes::PortType /*portType*/, QtNodes::PortIndex portIndex) const +template +QtNodes::NodeDataType VecBinOp::dataType(QtNodes::PortType /*portType*/, QtNodes::PortIndex portIndex) const { assert(portIndex == 0 || portIndex == 1); - return Data::Type(); + return VecData::Type(); } -template -unsigned int VecBinOp::nPorts(QtNodes::PortType portType) const +template +unsigned int VecBinOp::nPorts(QtNodes::PortType portType) const { switch (portType) { @@ -39,24 +37,24 @@ unsigned int VecBinOp::nPorts(QtNodes::PortType portType) const return 0; } -template -std::shared_ptr VecBinOp::outData(QtNodes::PortIndex port) +template +std::shared_ptr VecBinOp::outData(QtNodes::PortIndex port) { assert(port == 0); return m_output; } -template -void VecBinOp::setInData(std::shared_ptr value, int index) +template +void VecBinOp::setInData(std::shared_ptr value, int index) { assert(index == 0 || index == 1); - std::shared_ptr castedValue; + std::shared_ptr castedValue; if (value) { - assert(dynamic_cast(value.get()) != nullptr); + assert(dynamic_cast(value.get()) != nullptr); - castedValue = std::static_pointer_cast(value); + castedValue = std::static_pointer_cast(value); } if (index == 0) @@ -67,8 +65,8 @@ void VecBinOp::setInData(std::shared_ptr value, UpdateOutput(); } -template -bool VecBinOp::ComputePreview(QPixmap& pixmap) +template +bool VecBinOp::ComputePreview(QPixmap& pixmap) { if (!m_lhs || !m_rhs) return false; @@ -77,16 +75,19 @@ bool VecBinOp::ComputePreview(QPixmap& pixmap) return true; } -template -void VecBinOp::UpdateOutput() +template +void VecBinOp::UpdateOutput() { - if (!m_lhs || !m_rhs) + if (!m_lhs || !m_rhs || m_lhs->componentCount != m_rhs->componentCount) { + m_output = std::make_shared(4); m_output->preview = QImage(1, 1, QImage::Format_RGBA8888); m_output->preview.fill(QColor::fromRgb(0, 0, 0, 0)); return; } + m_output = std::make_shared(m_lhs->componentCount); + const QImage& leftPreview = m_lhs->preview; const QImage& rightPreview = m_rhs->preview; int maxWidth = std::max(leftPreview.width(), rightPreview.width()); @@ -108,83 +109,3 @@ void VecBinOp::UpdateOutput() UpdatePreview(); } - -template -QString VecAdd::caption() const -{ - static QString caption = Data::Type().name + " addition"; - return caption; -} - -template -QString VecAdd::name() const -{ - static QString name = Data::Type().name + "add"; - return name; -} - -template -void VecAdd::ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) -{ - for (std::size_t i = 0; i < pixelCount; ++i) - { - unsigned int lValue = left[i]; - unsigned int rValue = right[i]; - - output[i] = static_cast(std::min(lValue + rValue, 255U)); - } -} - -template -QString VecMul::caption() const -{ - static QString caption = Data::Type().name + " multiplication"; - return caption; -} - -template -QString VecMul::name() const -{ - static QString name = Data::Type().name + "mul"; - return name; -} - -template -void VecMul::ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) -{ - for (std::size_t i = 0; i < pixelCount; ++i) - { - unsigned int lValue = left[i]; - unsigned int rValue = right[i]; - - output[i] = static_cast(lValue * rValue / 255); - } -} - -template -QString VecSub::caption() const -{ - static QString caption = Data::Type().name + " subtraction"; - return caption; -} - -template -QString VecSub::name() const -{ - static QString name = Data::Type().name + "sub"; - return name; -} - -template -void VecSub::ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) -{ - for (std::size_t i = 0; i < pixelCount; ++i) - { - unsigned int lValue = left[i]; - unsigned int rValue = right[i]; - - unsigned int sub = (lValue >= rValue) ? lValue - rValue : 0u; - - output[i] = static_cast(sub); - } -} diff --git a/src/ShaderNode/DataModels/VecValue.hpp b/src/ShaderNode/DataModels/VecValue.hpp index 50ff1f4e1..b115477e3 100644 --- a/src/ShaderNode/DataModels/VecValue.hpp +++ b/src/ShaderNode/DataModels/VecValue.hpp @@ -11,7 +11,7 @@ #include #include -template +template class VecValue : public ShaderNode { public: @@ -34,16 +34,14 @@ class VecValue : public ShaderNode private: bool ComputePreview(QPixmap& pixmap) override; - static constexpr std::size_t ComponentCount = Data::ComponentCount; - QColor ToColor() const; VecType m_value; }; -using Vec2Value = VecValue; -using Vec3Value = VecValue; -using Vec4Value = VecValue; +using Vec2Value = VecValue<2>; +using Vec3Value = VecValue<3>; +using Vec4Value = VecValue<4>; #include diff --git a/src/ShaderNode/DataModels/VecValue.inl b/src/ShaderNode/DataModels/VecValue.inl index 7f3a9dc5e..fd6d31be1 100644 --- a/src/ShaderNode/DataModels/VecValue.inl +++ b/src/ShaderNode/DataModels/VecValue.inl @@ -5,8 +5,8 @@ #include #include -template -VecValue::VecValue(ShaderGraph& graph) : +template +VecValue::VecValue(ShaderGraph& graph) : ShaderNode(graph) { static_assert(ComponentCount <= s_vectorComponents.size()); @@ -21,55 +21,55 @@ ShaderNode(graph) UpdatePreview(); } -template -QString VecValue::caption() const +template +QString VecValue::caption() const { - static QString caption = Data::Type().name + " constant"; + static QString caption = "Vector" + QString::number(ComponentCount) + " constant"; return caption; } -template -QString VecValue::name() const +template +QString VecValue::name() const { - static QString name = Data::Type().id + "Value"; + static QString name = "vec" + QString::number(ComponentCount) + "_constant"; return name; } -template -QtNodes::NodeDataType VecValue::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const +template +QtNodes::NodeDataType VecValue::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const { assert(portType == QtNodes::PortType::Out); assert(portIndex == 0); - return Data::Type(); + return VecData::Type(); } -template -unsigned int VecValue::nPorts(QtNodes::PortType portType) const +template +unsigned int VecValue::nPorts(QtNodes::PortType portType) const { switch (portType) { - case QtNodes::PortType::In: return 0; + case QtNodes::PortType::In: return 0; case QtNodes::PortType::Out: return 1; } return 0; } -template -std::shared_ptr VecValue::outData(QtNodes::PortIndex port) +template +std::shared_ptr VecValue::outData(QtNodes::PortIndex port) { assert(port == 0); - auto out = std::make_shared(); + auto out = std::make_shared(ComponentCount); out->preview = QImage(1, 1, QImage::Format_RGBA8888); out->preview.fill(ToColor()); return out; } -template -void VecValue::BuildNodeEdition(QFormLayout* layout) +template +void VecValue::BuildNodeEdition(QFormLayout* layout) { ShaderNode::BuildNodeEdition(layout); @@ -91,23 +91,23 @@ void VecValue::BuildNodeEdition(QFormLayout* layout) } } -template -Nz::ShaderAst::ExpressionPtr VecValue::GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const +template +Nz::ShaderAst::ExpressionPtr VecValue::GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const { assert(count == 0); return Nz::ShaderBuilder::Constant(m_value); } -template -bool VecValue::ComputePreview(QPixmap& pixmap) +template +bool VecValue::ComputePreview(QPixmap& pixmap) { pixmap.fill(ToColor()); return true; } -template -QColor VecValue::ToColor() const +template +QColor VecValue::ToColor() const { std::array values = { 0.f, 0.f, 0.f, 1.f }; diff --git a/src/ShaderNode/DataTypes/FloatData.cpp b/src/ShaderNode/DataTypes/FloatData.cpp new file mode 100644 index 000000000..0b1f99d61 --- /dev/null +++ b/src/ShaderNode/DataTypes/FloatData.cpp @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/DataTypes/FloatData.hpp b/src/ShaderNode/DataTypes/FloatData.hpp new file mode 100644 index 000000000..e0f0451d2 --- /dev/null +++ b/src/ShaderNode/DataTypes/FloatData.hpp @@ -0,0 +1,28 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_FLOATDATA_HPP +#define NAZARA_SHADERNODES_FLOATDATA_HPP + +#include +#include + +struct FloatData : public QtNodes::NodeData +{ + inline FloatData(); + + QtNodes::NodeDataType type() const override + { + return Type(); + } + + static QtNodes::NodeDataType Type() + { + return { "float", "Float" }; + } + + QImage preview; +}; + +#include + +#endif diff --git a/src/ShaderNode/DataTypes/FloatData.inl b/src/ShaderNode/DataTypes/FloatData.inl new file mode 100644 index 000000000..3960c5811 --- /dev/null +++ b/src/ShaderNode/DataTypes/FloatData.inl @@ -0,0 +1,7 @@ +#include + +inline FloatData::FloatData() : +preview(1, 1, QImage::Format_RGBA8888) +{ + preview.fill(QColor::fromRgb(255, 255, 255, 0)); +} diff --git a/src/ShaderNode/DataTypes/VecData.cpp b/src/ShaderNode/DataTypes/VecData.cpp index 0b1f99d61..c1f883079 100644 --- a/src/ShaderNode/DataTypes/VecData.cpp +++ b/src/ShaderNode/DataTypes/VecData.cpp @@ -1 +1,18 @@ #include +#include +#include + +Nz::ShaderAst::ExpressionType VecData::GetExpressionType() const +{ + switch (componentCount) + { + case 2: return Nz::ShaderAst::ExpressionType::Float2; + case 3: return Nz::ShaderAst::ExpressionType::Float3; + case 4: return Nz::ShaderAst::ExpressionType::Float4; + default: + break; + } + + assert(false); + throw std::runtime_error("invalid component count"); +} diff --git a/src/ShaderNode/DataTypes/VecData.hpp b/src/ShaderNode/DataTypes/VecData.hpp index 447d37686..5c19be942 100644 --- a/src/ShaderNode/DataTypes/VecData.hpp +++ b/src/ShaderNode/DataTypes/VecData.hpp @@ -9,59 +9,48 @@ struct VecData : public QtNodes::NodeData { - inline VecData(); + inline VecData(std::size_t componentCount); + inline QtNodes::NodeDataType type() const override; + + Nz::ShaderAst::ExpressionType GetExpressionType() const; + + static inline QtNodes::NodeDataType Type(); + + std::size_t componentCount; QImage preview; }; -struct Vec2Data : public VecData +template +struct VecExpressionTypeHelper; + +template<> +struct VecExpressionTypeHelper<1> +{ + static constexpr Nz::ShaderAst::ExpressionType ExpressionType = Nz::ShaderAst::ExpressionType::Float1; +}; + +template<> +struct VecExpressionTypeHelper<2> { - static constexpr std::size_t ComponentCount = 2; static constexpr Nz::ShaderAst::ExpressionType ExpressionType = Nz::ShaderAst::ExpressionType::Float2; - - QtNodes::NodeDataType type() const override - { - return Type(); - } - - static QtNodes::NodeDataType Type() - { - return { "vec2", "Vec2" }; - } }; -struct Vec3Data : public VecData +template<> +struct VecExpressionTypeHelper<3> { - static constexpr std::size_t ComponentCount = 3; static constexpr Nz::ShaderAst::ExpressionType ExpressionType = Nz::ShaderAst::ExpressionType::Float3; - - QtNodes::NodeDataType type() const override - { - return Type(); - } - - static QtNodes::NodeDataType Type() - { - return { "vec3", "Vec3" }; - } }; -struct Vec4Data : public VecData +template<> +struct VecExpressionTypeHelper<4> { - static constexpr std::size_t ComponentCount = 4; static constexpr Nz::ShaderAst::ExpressionType ExpressionType = Nz::ShaderAst::ExpressionType::Float4; - - QtNodes::NodeDataType type() const override - { - return Type(); - } - - static QtNodes::NodeDataType Type() - { - return { "vec4", "Vec4" }; - } }; +template constexpr Nz::ShaderAst::ExpressionType VecExpressionType = VecExpressionTypeHelper::template ExpressionType; + + struct VecTypeDummy {}; template @@ -76,7 +65,7 @@ struct VecTypeHelper<0> template<> struct VecTypeHelper<1> { - using Type = std::array; + using Type = std::array; //< To allow [0] }; template<> diff --git a/src/ShaderNode/DataTypes/VecData.inl b/src/ShaderNode/DataTypes/VecData.inl index 255fbd9ab..a84b5c344 100644 --- a/src/ShaderNode/DataTypes/VecData.inl +++ b/src/ShaderNode/DataTypes/VecData.inl @@ -1,7 +1,18 @@ #include -inline VecData::VecData() : +inline VecData::VecData(std::size_t ComponentCount) : +componentCount(ComponentCount), preview(64, 64, QImage::Format_RGBA8888) { preview.fill(QColor::fromRgb(255, 255, 255, 0)); } + +inline QtNodes::NodeDataType VecData::type() const +{ + return Type(); +} + +inline QtNodes::NodeDataType VecData::Type() +{ + return { "vector", "Vector" }; +} diff --git a/src/ShaderNode/Enums.cpp b/src/ShaderNode/Enums.cpp index fd99c5562..1f756b8de 100644 --- a/src/ShaderNode/Enums.cpp +++ b/src/ShaderNode/Enums.cpp @@ -1,6 +1,21 @@ #include #include +std::size_t GetComponentCount(InOutType type) +{ + switch (type) + { + case InOutType::Bool: return 1; + case InOutType::Float1: return 1; + case InOutType::Float2: return 2; + case InOutType::Float3: return 3; + case InOutType::Float4: return 4; + } + + assert(false); + return 0; +} + const char* EnumToString(InputRole role) { switch (role) diff --git a/src/ShaderNode/Enums.hpp b/src/ShaderNode/Enums.hpp index ba990fdcf..f67623a3f 100644 --- a/src/ShaderNode/Enums.hpp +++ b/src/ShaderNode/Enums.hpp @@ -39,6 +39,8 @@ enum class TextureType constexpr std::size_t TextureTypeCount = static_cast(TextureType::Max) + 1; + +std::size_t GetComponentCount(InOutType type); const char* EnumToString(InputRole role); const char* EnumToString(InOutType input); const char* EnumToString(TextureType textureType); diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp index 876b0f1a3..63a29a6a0 100644 --- a/src/ShaderNode/ShaderGraph.cpp +++ b/src/ShaderNode/ShaderGraph.cpp @@ -58,7 +58,7 @@ m_flowScene(BuildRegistry()) auto& node3 = m_flowScene.createNode(std::make_unique(*this)); node3.nodeGraphicsObject().setPos(200, 200); - auto& node4 = m_flowScene.createNode(std::make_unique(*this)); + auto& node4 = m_flowScene.createNode(std::make_unique(*this)); node4.nodeGraphicsObject().setPos(400, 200); auto& node5 = m_flowScene.createNode(std::make_unique(*this)); @@ -154,6 +154,8 @@ Nz::ShaderAst::StatementPtr ShaderGraph::ToAst() HandleNode = [&](QtNodes::Node* node) -> Nz::ShaderAst::ExpressionPtr { ShaderNode* shaderNode = static_cast(node->nodeDataModel()); + if (shaderNode->validationState() != QtNodes::NodeValidationState::Valid) + throw std::runtime_error(shaderNode->validationMessage().toStdString()); qDebug() << shaderNode->name() << node->id(); if (auto it = variableExpressions.find(node->id()); it != variableExpressions.end()) @@ -211,21 +213,13 @@ Nz::ShaderAst::StatementPtr ShaderGraph::ToAst() return expression; }; - try + m_flowScene.iterateOverNodes([&](QtNodes::Node* node) { - m_flowScene.iterateOverNodes([&](QtNodes::Node* node) + if (node->nodeDataModel()->nPorts(QtNodes::PortType::Out) == 0) { - if (node->nodeDataModel()->nPorts(QtNodes::PortType::Out) == 0) - { - statements.emplace_back(Nz::ShaderBuilder::ExprStatement(HandleNode(node))); - } - }); - } - catch (const std::exception&) - { - - return nullptr; - } + statements.emplace_back(Nz::ShaderBuilder::ExprStatement(HandleNode(node))); + } + }); return std::make_shared(std::move(statements)); } @@ -265,25 +259,16 @@ void ShaderGraph::UpdateTexturePreview(std::size_t textureIndex, QImage preview) std::shared_ptr ShaderGraph::BuildRegistry() { auto registry = std::make_shared(); - RegisterShaderNode(*this, registry, "Casts"); - RegisterShaderNode(*this, registry, "Casts"); - RegisterShaderNode(*this, registry, "Casts"); - RegisterShaderNode(*this, registry, "Casts"); - RegisterShaderNode(*this, registry, "Casts"); - RegisterShaderNode(*this, registry, "Casts"); + RegisterShaderNode(*this, registry, "Casts"); + RegisterShaderNode(*this, registry, "Casts"); + RegisterShaderNode(*this, registry, "Casts"); RegisterShaderNode(*this, registry, "Inputs"); RegisterShaderNode(*this, registry, "Outputs"); RegisterShaderNode(*this, registry, "Texture"); RegisterShaderNode(*this, registry, "Texture"); - RegisterShaderNode(*this, registry, "Vector operations"); - RegisterShaderNode(*this, registry, "Vector operations"); - RegisterShaderNode(*this, registry, "Vector operations"); - RegisterShaderNode(*this, registry, "Vector operations"); - RegisterShaderNode(*this, registry, "Vector operations"); - RegisterShaderNode(*this, registry, "Vector operations"); - RegisterShaderNode(*this, registry, "Vector operations"); - RegisterShaderNode(*this, registry, "Vector operations"); - RegisterShaderNode(*this, registry, "Vector operations"); + RegisterShaderNode(*this, registry, "Vector operations"); + RegisterShaderNode(*this, registry, "Vector operations"); + RegisterShaderNode(*this, registry, "Vector operations"); RegisterShaderNode(*this, registry, "Constants"); RegisterShaderNode(*this, registry, "Constants"); RegisterShaderNode(*this, registry, "Constants"); diff --git a/src/ShaderNode/Widgets/MainWindow.cpp b/src/ShaderNode/Widgets/MainWindow.cpp index ca0bd4c0a..505c1f285 100644 --- a/src/ShaderNode/Widgets/MainWindow.cpp +++ b/src/ShaderNode/Widgets/MainWindow.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -83,15 +84,22 @@ void MainWindow::BuildMenu() void MainWindow::OnCompileToGLSL() { - Nz::GlslWriter writer; - Nz::String glsl = writer.Generate(m_shaderGraph.ToAst()); + try + { + Nz::GlslWriter writer; + Nz::String glsl = writer.Generate(m_shaderGraph.ToAst()); - std::cout << glsl << std::endl; + std::cout << glsl << std::endl; - QTextEdit* output = new QTextEdit; - output->setReadOnly(true); - output->setText(QString::fromUtf8(glsl.GetConstBuffer(), int(glsl.GetSize()))); - output->setAttribute(Qt::WA_DeleteOnClose, true); - output->setWindowTitle("GLSL Output"); - output->show(); + QTextEdit* output = new QTextEdit; + output->setReadOnly(true); + output->setText(QString::fromUtf8(glsl.GetConstBuffer(), int(glsl.GetSize()))); + output->setAttribute(Qt::WA_DeleteOnClose, true); + output->setWindowTitle("GLSL Output"); + output->show(); + } + catch (const std::exception& e) + { + QMessageBox::critical(this, tr("Compilation failed"), QString("Compilation failed: ") + e.what()); + } } From 8c2bfd296f22053a75e95a0429e05083bf8d727c Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 1 Jun 2020 16:16:11 +0200 Subject: [PATCH 226/316] Core/StringExt: Prevent empty match call --- include/Nazara/Core/StringExt.inl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Core/StringExt.inl b/include/Nazara/Core/StringExt.inl index 71a04ebff..0ab5c0cff 100644 --- a/include/Nazara/Core/StringExt.inl +++ b/include/Nazara/Core/StringExt.inl @@ -60,7 +60,10 @@ namespace Nz return false; } - return func(str.substr(previousPos)); + if (previousPos < str.size()) + return func(str.substr(previousPos)); + else + return true; } template From 960a5c2d057d7dbffdae365f368d8fdfb9de2e51 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 1 Jun 2020 16:16:41 +0200 Subject: [PATCH 227/316] OpenGLRenderer: Fix extension loading --- src/Nazara/OpenGLRenderer/Wrapper/Context.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp index 5d2c9f366..13ac8ebfa 100644 --- a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp +++ b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp @@ -195,12 +195,11 @@ namespace Nz::GL NazaraWarning("Failed to decode OpenGL version: " + std::string(versionString)); // Load extensions - std::string_view extensionList = reinterpret_cast(glGetString(GL_EXTENSIONS)); - SplitString(extensionList, " ", [&](std::string_view extension) - { - m_supportedExtensions.emplace(extension); - return true; - }); + GLint extensionCount = 0; + glGetIntegerv(GL_NUM_EXTENSIONS, &extensionCount); + + for (GLint i = 0; i < extensionCount; ++i) + m_supportedExtensions.emplace(reinterpret_cast(glGetStringi(GL_EXTENSIONS, i))); m_extensionStatus.fill(ExtensionStatus::NotSupported); From 8f04412a3ffaf81f56e80fbb5c3d9b117e766925 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 1 Jun 2020 16:17:04 +0200 Subject: [PATCH 228/316] OpenGLRenderer: Fix GLES context creation core profile bit has not meaning to OpenGL ES --- src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp index c5faa2bfa..e07a21294 100644 --- a/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp +++ b/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp @@ -119,7 +119,7 @@ namespace Nz::GL WGL_CONTEXT_MAJOR_VERSION_ARB, int(version.major), WGL_CONTEXT_MINOR_VERSION_ARB, int(version.minor), - WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB | WGL_CONTEXT_ES_PROFILE_BIT_EXT + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_ES_PROFILE_BIT_EXT }; m_handle = baseContext->wglCreateContextAttribsARB(m_deviceContext, nullptr, attributes.data()); From a73251f2dfedbf825ef4a21284ab79f58ff1f6b2 Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 1 Jun 2020 17:11:34 +0200 Subject: [PATCH 229/316] OpenGLRenderer: Fix version parsing OpenGL ES 3.0 implementations don't seem to follow the spec, use GL_MAJOR_VERSION and GL_MINOR_VERSION instead --- src/Nazara/OpenGLRenderer/Wrapper/Context.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp index 13ac8ebfa..902f22813 100644 --- a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp +++ b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp @@ -185,14 +185,14 @@ namespace Nz::GL return -1; }; - std::string_view versionString = reinterpret_cast(glGetString(GL_VERSION)); - if (versionString.size() > 2 && DecodeDigit(versionString[0]) >= 0 && versionString[1] == '.' && DecodeDigit(versionString[2]) >= 0) - { - m_params.glMajorVersion = DecodeDigit(versionString[0]); - m_params.glMinorVersion = DecodeDigit(versionString[2]); - } - else - NazaraWarning("Failed to decode OpenGL version: " + std::string(versionString)); + GLint majorVersion = 0; + glGetIntegerv(GL_MAJOR_VERSION, &majorVersion); + + GLint minorVersion = 0; + glGetIntegerv(GL_MINOR_VERSION, &minorVersion); + + m_params.glMajorVersion = majorVersion; + m_params.glMinorVersion = minorVersion; // Load extensions GLint extensionCount = 0; From e4c95da19ade726b85bf2229fa47afbe6f8fa5ed Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 1 Jun 2020 17:13:58 +0200 Subject: [PATCH 230/316] Update Vulkan shaders --- .../bin/resources/shaders/triangle.frag.spv | Bin 1296 -> 1296 bytes .../bin/resources/shaders/triangle.vert.spv | Bin 1912 -> 1640 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/examples/bin/resources/shaders/triangle.frag.spv b/examples/bin/resources/shaders/triangle.frag.spv index 855cf613abcacf778f7aa6a6e5a9c4483ac84a76..37fc46adf243096a0eb2599f16abb5740e8c4068 100644 GIT binary patch delta 12 TcmbQhHGykF1|$2%%;hWq8U_RU delta 12 TcmbQhHGykF1|!GD%;hWq8Vdva diff --git a/examples/bin/resources/shaders/triangle.vert.spv b/examples/bin/resources/shaders/triangle.vert.spv index 58b0936f4f765cd7332585bf21b61883de859675..5692ffb022500d33c1090ae90e84cac55a4792dc 100644 GIT binary patch delta 54 zcmeyt_kxF)nMs+Qfq{{M0|<>K@|rSoPjuGYSdzoInTN@RadQFl0mjV}SX&r5{sI+Q G05JeQybIv~ delta 318 zcmaFC^Mj9 zR(QGqMc5duA!43+#U+V($*G<$o3ApuGs?O%uz;0w1EpDk7{muD1@YN7OEMp3j1>h6 z83DNpKnw!fP`)vc%?QK_K)wl(W(Hz5DBluDgXF}4*cvDg;)7fT5`*zU)-Z0q$h(X5N0=0sSGy`IgTs@R;4i$sxvjFmu_1OU(0}=zN`wO(x0*C>@ C3LwD% From 41b50eeac3939b7eb6ce23f2c27134aa3af71e32 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 3 Jun 2020 19:09:51 +0200 Subject: [PATCH 231/316] Fix compilation --- src/ShaderNode/DataModels/Cast.inl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ShaderNode/DataModels/Cast.inl b/src/ShaderNode/DataModels/Cast.inl index 64ed934a2..f8870201a 100644 --- a/src/ShaderNode/DataModels/Cast.inl +++ b/src/ShaderNode/DataModels/Cast.inl @@ -10,7 +10,8 @@ ShaderNode(graph) { static_assert(ToComponentCount <= s_vectorComponents.size()); - m_overflowComponents.fill(0.f); + for (std::size_t i = 0; i < ToComponentCount; ++i) + m_overflowComponents[i] = 0.f; m_output = std::make_shared(ToComponentCount); } From 25562a5856315a70fe5ceab57065a6d1ff108bfc Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 4 Jun 2020 18:29:50 +0200 Subject: [PATCH 232/316] Renderer/ShaderAst: Add BinaryFunc --- include/Nazara/Renderer/GlslWriter.hpp | 1 + include/Nazara/Renderer/ShaderAst.hpp | 25 +++++++++++++++++++++++- include/Nazara/Renderer/ShaderAst.inl | 23 ++++++++++++++++++++++ src/Nazara/Renderer/ShaderAst.cpp | 27 ++++++++++++++++++++++++++ 4 files changed, 75 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Renderer/GlslWriter.hpp b/include/Nazara/Renderer/GlslWriter.hpp index 13d7c8459..373a9950e 100644 --- a/include/Nazara/Renderer/GlslWriter.hpp +++ b/include/Nazara/Renderer/GlslWriter.hpp @@ -33,6 +33,7 @@ namespace Nz void Write(const ShaderAst::AssignOp& node) override; void Write(const ShaderAst::Branch& node) override; + void Write(const ShaderAst::BinaryFunc& node) override; void Write(const ShaderAst::BinaryOp& node) override; void Write(const ShaderAst::BuiltinVariable& node) override; void Write(const ShaderAst::Cast& node) override; diff --git a/include/Nazara/Renderer/ShaderAst.hpp b/include/Nazara/Renderer/ShaderAst.hpp index 08e8e20b2..6dd43ea89 100644 --- a/include/Nazara/Renderer/ShaderAst.hpp +++ b/include/Nazara/Renderer/ShaderAst.hpp @@ -26,13 +26,20 @@ namespace Nz Simple //< = }; + enum class BinaryIntrinsic + { + CrossProduct, + DotProduct + }; + enum class BinaryType { Add, //< + Substract, //< - Multiply, //< * Divide, //< / - Equality //< == + + Equality //< == }; enum class BuiltinEntry @@ -325,6 +332,22 @@ namespace Nz ExpressionPtr sampler; ExpressionPtr coordinates; }; + + ////////////////////////////////////////////////////////////////////////// + + class NAZARA_RENDERER_API BinaryFunc : public Expression + { + public: + inline BinaryFunc(BinaryIntrinsic Op, ExpressionPtr Left, ExpressionPtr Right); + + ExpressionType GetExpressionType() const override; + void Register(ShaderWriter& visitor) override; + void Visit(ShaderWriter& visitor) override; + + BinaryIntrinsic intrinsic; + ExpressionPtr left; + ExpressionPtr right; + }; } } diff --git a/include/Nazara/Renderer/ShaderAst.inl b/include/Nazara/Renderer/ShaderAst.inl index e837cbdb4..958baecfe 100644 --- a/include/Nazara/Renderer/ShaderAst.inl +++ b/include/Nazara/Renderer/ShaderAst.inl @@ -243,6 +243,29 @@ namespace Nz if (coordinates->GetExpressionType() != ExpressionType::Float2) throw std::runtime_error("Coordinates must be a Float2"); } + + inline BinaryFunc::BinaryFunc(BinaryIntrinsic Op, ExpressionPtr Left, ExpressionPtr Right) : + intrinsic(Op), + left(Left), + right(Right) + { + ExpressionType leftType = left->GetExpressionType(); + ExpressionType rightType = right->GetExpressionType(); + + if (leftType != rightType) + //TODO: AstParseError + throw std::runtime_error("Left expression type must match right expression type"); + + switch (intrinsic) + { + case BinaryIntrinsic::CrossProduct: + { + if (leftType != ExpressionType::Float3) + //TODO: AstParseError + throw std::runtime_error("CrossProduct only works with Float3 expressions"); + } + } + } } } diff --git a/src/Nazara/Renderer/ShaderAst.cpp b/src/Nazara/Renderer/ShaderAst.cpp index a0a0cc031..0a2373d17 100644 --- a/src/Nazara/Renderer/ShaderAst.cpp +++ b/src/Nazara/Renderer/ShaderAst.cpp @@ -254,4 +254,31 @@ namespace Nz::ShaderAst { visitor.Write(*this); } + + + ExpressionType BinaryFunc::GetExpressionType() const + { + switch (intrinsic) + { + case BinaryIntrinsic::CrossProduct: + return left->GetExpressionType(); + + case BinaryIntrinsic::DotProduct: + return ExpressionType::Float1; + } + + NazaraAssert(false, "Unhandled builtin"); + return ExpressionType::Void; + } + + void BinaryFunc::Register(ShaderWriter& visitor) + { + left->Register(visitor); + right->Register(visitor); + } + + void BinaryFunc::Visit(ShaderWriter& visitor) + { + visitor.Write(*this); + } } From 725ecc76069a14c7f1fda2e99aa2cbc931ba9358 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 4 Jun 2020 18:30:40 +0200 Subject: [PATCH 233/316] ShaderNode: Add FloatValue --- src/ShaderNode/DataModels/FloatValue.cpp | 106 +++++++++++++++++++++++ src/ShaderNode/DataModels/FloatValue.hpp | 45 ++++++++++ src/ShaderNode/DataModels/FloatValue.inl | 1 + src/ShaderNode/DataModels/InputValue.cpp | 4 +- src/ShaderNode/ShaderGraph.cpp | 1 + 5 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 src/ShaderNode/DataModels/FloatValue.cpp create mode 100644 src/ShaderNode/DataModels/FloatValue.hpp create mode 100644 src/ShaderNode/DataModels/FloatValue.inl diff --git a/src/ShaderNode/DataModels/FloatValue.cpp b/src/ShaderNode/DataModels/FloatValue.cpp new file mode 100644 index 000000000..23d5a30d3 --- /dev/null +++ b/src/ShaderNode/DataModels/FloatValue.cpp @@ -0,0 +1,106 @@ +#include +#include +#include +#include + +FloatValue::FloatValue(ShaderGraph& graph) : +ShaderNode(graph), +m_value(1.f) +{ + UpdatePreview(); +} + +QString FloatValue::caption() const +{ + static QString caption = "Float constant"; + return caption; +} + +QString FloatValue::name() const +{ + static QString name = "float_constant"; + return name; +} + +QtNodes::NodeDataType FloatValue::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const +{ + assert(portType == QtNodes::PortType::Out); + assert(portIndex == 0); + + return FloatData::Type(); +} + +unsigned int FloatValue::nPorts(QtNodes::PortType portType) const +{ + switch (portType) + { + case QtNodes::PortType::In: return 0; + case QtNodes::PortType::Out: return 1; + } + + return 0; +} + +std::shared_ptr FloatValue::outData(QtNodes::PortIndex port) +{ + assert(port == 0); + + auto out = std::make_shared(); + out->preview.fill(ToColor()); + + return out; +} + +void FloatValue::BuildNodeEdition(QFormLayout* layout) +{ + ShaderNode::BuildNodeEdition(layout); + + QDoubleSpinBox* spinbox = new QDoubleSpinBox; + spinbox->setDecimals(6); + spinbox->setValue(m_value); + + connect(spinbox, qOverload(&QDoubleSpinBox::valueChanged), [=](double) + { + m_value = spinbox->value(); + Q_EMIT dataUpdated(0); + + UpdatePreview(); + }); + + layout->addRow(tr("Value"), spinbox); +} + +Nz::ShaderAst::ExpressionPtr FloatValue::GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const +{ + assert(count == 0); + + return Nz::ShaderBuilder::Constant(m_value); +} + +bool FloatValue::ComputePreview(QPixmap& pixmap) +{ + pixmap.fill(ToColor()); + return true; +} + +QColor FloatValue::ToColor() const +{ + float value = std::clamp(m_value, 0.f, 1.f); + + return QColor::fromRgbF(value, value, value, value); +} + +void FloatValue::restore(const QJsonObject& data) +{ + m_value = float(data["value"].toDouble(m_value)); + + ShaderNode::restore(data); +} + +QJsonObject FloatValue::save() const +{ + QJsonObject data = ShaderNode::save(); + data["value"] = m_value; + + return data; +} diff --git a/src/ShaderNode/DataModels/FloatValue.hpp b/src/ShaderNode/DataModels/FloatValue.hpp new file mode 100644 index 000000000..44244cd46 --- /dev/null +++ b/src/ShaderNode/DataModels/FloatValue.hpp @@ -0,0 +1,45 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_FLOATVALUE_HPP +#define NAZARA_SHADERNODES_FLOATVALUE_HPP + +#include +#include +#include +#include +#include +#include +#include + +class FloatValue : public ShaderNode +{ + public: + FloatValue(ShaderGraph& graph); + ~FloatValue() = default; + + QString caption() const override; + QString name() const override; + + QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; + + unsigned int nPorts(QtNodes::PortType portType) const override; + + std::shared_ptr outData(QtNodes::PortIndex port) override; + + void BuildNodeEdition(QFormLayout* layout) override; + + Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const override; + + private: + bool ComputePreview(QPixmap& pixmap) override; + QColor ToColor() const; + + void restore(const QJsonObject& data) override; + QJsonObject save() const override; + + float m_value; +}; + +#include + +#endif diff --git a/src/ShaderNode/DataModels/FloatValue.inl b/src/ShaderNode/DataModels/FloatValue.inl new file mode 100644 index 000000000..9f520e6ba --- /dev/null +++ b/src/ShaderNode/DataModels/FloatValue.inl @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/DataModels/InputValue.cpp b/src/ShaderNode/DataModels/InputValue.cpp index 6defcb30f..f6b6bf2e4 100644 --- a/src/ShaderNode/DataModels/InputValue.cpp +++ b/src/ShaderNode/DataModels/InputValue.cpp @@ -127,7 +127,9 @@ auto InputValue::dataType(QtNodes::PortType portType, QtNodes::PortIndex portInd switch (inputEntry.type) { //case InputType::Bool: return Nz::ShaderAst::ExpressionType::Boolean; - //case InputType::Float1: return Nz::ShaderAst::ExpressionType::Float1; + case InOutType::Float1: + return FloatData::Type(); + case InOutType::Float2: case InOutType::Float3: case InOutType::Float4: diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp index 63a29a6a0..fd530e504 100644 --- a/src/ShaderNode/ShaderGraph.cpp +++ b/src/ShaderNode/ShaderGraph.cpp @@ -262,6 +262,7 @@ std::shared_ptr ShaderGraph::BuildRegistry() RegisterShaderNode(*this, registry, "Casts"); RegisterShaderNode(*this, registry, "Casts"); RegisterShaderNode(*this, registry, "Casts"); + RegisterShaderNode(*this, registry, "Constants"); RegisterShaderNode(*this, registry, "Inputs"); RegisterShaderNode(*this, registry, "Outputs"); RegisterShaderNode(*this, registry, "Texture"); From 5790b502f772811c0563815fe6ca1f142ef1feb5 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 4 Jun 2020 18:30:54 +0200 Subject: [PATCH 234/316] ShaderNode: Add VecDiv --- src/ShaderNode/DataModels/VecBinOp.cpp | 32 ++++++++++++++++++++++++++ src/ShaderNode/DataModels/VecBinOp.hpp | 11 +++++++++ src/ShaderNode/ShaderGraph.cpp | 1 + 3 files changed, 44 insertions(+) diff --git a/src/ShaderNode/DataModels/VecBinOp.cpp b/src/ShaderNode/DataModels/VecBinOp.cpp index 8f63c2642..3ea2838f3 100644 --- a/src/ShaderNode/DataModels/VecBinOp.cpp +++ b/src/ShaderNode/DataModels/VecBinOp.cpp @@ -71,3 +71,35 @@ void VecSub::ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::u output[i] = static_cast(sub); } } + +QString VecDiv::caption() const +{ + static QString caption = "Vector divide"; + return caption; +} + + +QString VecDiv::name() const +{ + static QString name = "vec_div"; + return name; +} + +void VecDiv::ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) +{ + for (std::size_t i = 0; i < pixelCount; ++i) + { + unsigned int lValue = left[i]; + unsigned int rValue = right[i]; + + unsigned res; + if (rValue != 0) + res = lValue / rValue; + else if (lValue != 0) + res = 0xFF; //< positive / 0 = +inf, which we clamp to 0xFF + else + res = 0; //< 0 / 0 = NaN, which we set to zero + + output[i] = static_cast(res); + } +} diff --git a/src/ShaderNode/DataModels/VecBinOp.hpp b/src/ShaderNode/DataModels/VecBinOp.hpp index f8bebc667..0fbb93f9c 100644 --- a/src/ShaderNode/DataModels/VecBinOp.hpp +++ b/src/ShaderNode/DataModels/VecBinOp.hpp @@ -67,6 +67,17 @@ class VecSub : public VecBinOp void ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) override; }; +class VecDiv : public VecBinOp +{ + public: + using VecBinOp::VecBinOp; + + QString caption() const override; + QString name() const override; + + void ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) override; +}; + #include #endif diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp index fd530e504..38d1a8dcb 100644 --- a/src/ShaderNode/ShaderGraph.cpp +++ b/src/ShaderNode/ShaderGraph.cpp @@ -268,6 +268,7 @@ std::shared_ptr ShaderGraph::BuildRegistry() RegisterShaderNode(*this, registry, "Texture"); RegisterShaderNode(*this, registry, "Texture"); RegisterShaderNode(*this, registry, "Vector operations"); + RegisterShaderNode(*this, registry, "Vector operations"); RegisterShaderNode(*this, registry, "Vector operations"); RegisterShaderNode(*this, registry, "Vector operations"); RegisterShaderNode(*this, registry, "Constants"); From 088858971600e0e6d4fb875581fcd4cf39de72c7 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 4 Jun 2020 18:31:35 +0200 Subject: [PATCH 235/316] ShaderNode: Add save/load --- src/ShaderNode/DataModels/InputValue.cpp | 20 +++ src/ShaderNode/DataModels/InputValue.hpp | 3 + src/ShaderNode/DataModels/OutputValue.cpp | 16 +++ src/ShaderNode/DataModels/OutputValue.hpp | 3 + src/ShaderNode/DataModels/SampleTexture.cpp | 25 ++-- src/ShaderNode/DataModels/ShaderNode.cpp | 30 ++++- src/ShaderNode/DataModels/ShaderNode.hpp | 3 + src/ShaderNode/DataModels/TextureValue.cpp | 19 +++ src/ShaderNode/DataModels/TextureValue.hpp | 3 + src/ShaderNode/DataModels/VecValue.hpp | 4 +- src/ShaderNode/DataModels/VecValue.inl | 25 ++++ src/ShaderNode/Enums.hpp | 5 +- src/ShaderNode/Enums.inl | 14 +++ src/ShaderNode/ShaderGraph.cpp | 131 ++++++++++++++++++++ src/ShaderNode/ShaderGraph.hpp | 5 + src/ShaderNode/Widgets/MainWindow.cpp | 62 ++++++++- src/ShaderNode/Widgets/MainWindow.hpp | 2 + 17 files changed, 358 insertions(+), 12 deletions(-) diff --git a/src/ShaderNode/DataModels/InputValue.cpp b/src/ShaderNode/DataModels/InputValue.cpp index f6b6bf2e4..3f8d2fbdc 100644 --- a/src/ShaderNode/DataModels/InputValue.cpp +++ b/src/ShaderNode/DataModels/InputValue.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -11,7 +12,10 @@ ShaderNode(graph) m_onInputUpdateSlot.Connect(GetGraph().OnInputUpdate, [&](ShaderGraph*, std::size_t inputIndex) { if (m_currentInputIndex == inputIndex) + { UpdatePreview(); + Q_EMIT dataUpdated(0); + } }); if (graph.GetInputCount() > 0) @@ -172,3 +176,19 @@ QString InputValue::validationMessage() const return QString(); } + +void InputValue::restore(const QJsonObject& data) +{ + m_currentInputText = data["input"].toString().toStdString(); + OnInputListUpdate(); + + ShaderNode::restore(data); +} + +QJsonObject InputValue::save() const +{ + QJsonObject data = ShaderNode::save(); + data["input"] = QString::fromStdString(m_currentInputText); + + return data; +} diff --git a/src/ShaderNode/DataModels/InputValue.hpp b/src/ShaderNode/DataModels/InputValue.hpp index 4b4c1b31c..681a85e8d 100644 --- a/src/ShaderNode/DataModels/InputValue.hpp +++ b/src/ShaderNode/DataModels/InputValue.hpp @@ -37,6 +37,9 @@ class InputValue : public ShaderNode bool ComputePreview(QPixmap& pixmap) override; void OnInputListUpdate(); + void restore(const QJsonObject& data) override; + QJsonObject save() const override; + NazaraSlot(ShaderGraph, OnInputListUpdate, m_onInputListUpdateSlot); NazaraSlot(ShaderGraph, OnInputUpdate, m_onInputUpdateSlot); diff --git a/src/ShaderNode/DataModels/OutputValue.cpp b/src/ShaderNode/DataModels/OutputValue.cpp index 04eeafd48..538884706 100644 --- a/src/ShaderNode/DataModels/OutputValue.cpp +++ b/src/ShaderNode/DataModels/OutputValue.cpp @@ -188,3 +188,19 @@ void OutputValue::OnOutputListUpdate() inputIndex++; } } + +void OutputValue::restore(const QJsonObject& data) +{ + m_currentOutputText = data["input"].toString().toStdString(); + OnOutputListUpdate(); + + ShaderNode::restore(data); +} + +QJsonObject OutputValue::save() const +{ + QJsonObject data = ShaderNode::save(); + data["input"] = QString::fromStdString(m_currentOutputText); + + return data; +} diff --git a/src/ShaderNode/DataModels/OutputValue.hpp b/src/ShaderNode/DataModels/OutputValue.hpp index 1e7055da5..4cc523b66 100644 --- a/src/ShaderNode/DataModels/OutputValue.hpp +++ b/src/ShaderNode/DataModels/OutputValue.hpp @@ -36,6 +36,9 @@ class OutputValue : public ShaderNode bool ComputePreview(QPixmap& pixmap) override; void OnOutputListUpdate(); + void restore(const QJsonObject& data) override; + QJsonObject save() const override; + NazaraSlot(ShaderGraph, OnOutputListUpdate, m_onOutputListUpdateSlot); NazaraSlot(ShaderGraph, OnOutputUpdate, m_onOutputUpdateSlot); diff --git a/src/ShaderNode/DataModels/SampleTexture.cpp b/src/ShaderNode/DataModels/SampleTexture.cpp index 970e8a965..3f0036519 100644 --- a/src/ShaderNode/DataModels/SampleTexture.cpp +++ b/src/ShaderNode/DataModels/SampleTexture.cpp @@ -54,14 +54,25 @@ void SampleTexture::UpdateOutput() float u = float(uvPtr[0]) / 255; float v = float(uvPtr[1]) / 255; - int texX = std::clamp(int(u * textureWidth), 0, textureWidth - 1); - int texY = std::clamp(int(v * textureHeight), 0, textureHeight - 1); - int texPixel = (texY * textureWidth + texX) * 4; + if (textureWidth > 0 && textureHeight > 0) + { + int texX = std::clamp(int(u * textureWidth), 0, textureWidth - 1); + int texY = std::clamp(int(v * textureHeight), 0, textureHeight - 1); + int texPixel = (texY * textureWidth + texX) * 4; + + *outputPtr++ = texturePtr[texPixel + 0]; + *outputPtr++ = texturePtr[texPixel + 1]; + *outputPtr++ = texturePtr[texPixel + 2]; + *outputPtr++ = texturePtr[texPixel + 3]; + } + else + { + *outputPtr++ = 0; + *outputPtr++ = 0; + *outputPtr++ = 0; + *outputPtr++ = 0xFF; + } - *outputPtr++ = texturePtr[texPixel + 0]; - *outputPtr++ = texturePtr[texPixel + 1]; - *outputPtr++ = texturePtr[texPixel + 2]; - *outputPtr++ = texturePtr[texPixel + 3]; uvPtr += 4; } } diff --git a/src/ShaderNode/DataModels/ShaderNode.cpp b/src/ShaderNode/DataModels/ShaderNode.cpp index b955c3c42..a9b06adf8 100644 --- a/src/ShaderNode/DataModels/ShaderNode.cpp +++ b/src/ShaderNode/DataModels/ShaderNode.cpp @@ -81,8 +81,6 @@ void ShaderNode::EnablePreview(bool enable) m_pixmapLabel->clear(); m_pixmap.reset(); } - - embeddedWidgetSizeUpdated(); } } @@ -95,6 +93,29 @@ void ShaderNode::setInData(std::shared_ptr, int) { } +void ShaderNode::restore(const QJsonObject& data) +{ + NodeDataModel::restore(data); + + bool isPreviewEnabled = data["preview_enabled"].toBool(m_isPreviewEnabled); + m_previewSize.x = data["preview_width"].toInt(m_previewSize.x); + m_previewSize.y = data["preview_height"].toInt(m_previewSize.y); + m_variableName = data["variable_name"].toString().toStdString(); + + EnablePreview(isPreviewEnabled); +} + +QJsonObject ShaderNode::save() const +{ + QJsonObject data = NodeDataModel::save(); + data["preview_enabled"] = m_isPreviewEnabled; + data["preview_width"] = m_previewSize.x; + data["preview_height"] = m_previewSize.y; + data["variable_name"] = QString::fromStdString(m_variableName); + + return data; +} + bool ShaderNode::ComputePreview(QPixmap& /*pixmap*/) { return false; @@ -103,7 +124,10 @@ bool ShaderNode::ComputePreview(QPixmap& /*pixmap*/) void ShaderNode::UpdatePreview() { if (!m_pixmap) + { + embeddedWidgetSizeUpdated(); return; + } QPixmap& pixmap = *m_pixmap; @@ -116,4 +140,6 @@ void ShaderNode::UpdatePreview() pixmap = pixmap.scaled(m_previewSize.x, m_previewSize.y); m_pixmapLabel->setPixmap(pixmap); + + embeddedWidgetSizeUpdated(); } diff --git a/src/ShaderNode/DataModels/ShaderNode.hpp b/src/ShaderNode/DataModels/ShaderNode.hpp index 91f6dc0d3..e7ac130c9 100644 --- a/src/ShaderNode/DataModels/ShaderNode.hpp +++ b/src/ShaderNode/DataModels/ShaderNode.hpp @@ -40,6 +40,9 @@ class ShaderNode : public QtNodes::NodeDataModel inline void EnableCustomVariableName(bool enable = true); void UpdatePreview(); + void restore(const QJsonObject& data) override; + QJsonObject save() const override; + private: virtual bool ComputePreview(QPixmap& pixmap); diff --git a/src/ShaderNode/DataModels/TextureValue.cpp b/src/ShaderNode/DataModels/TextureValue.cpp index f78a610a9..78f7df761 100644 --- a/src/ShaderNode/DataModels/TextureValue.cpp +++ b/src/ShaderNode/DataModels/TextureValue.cpp @@ -12,7 +12,10 @@ ShaderNode(graph) m_onTexturePreviewUpdateSlot.Connect(GetGraph().OnTexturePreviewUpdate, [&](ShaderGraph*, std::size_t textureIndex) { if (m_currentTextureIndex == textureIndex) + { UpdatePreview(); + Q_EMIT dataUpdated(0); + } }); if (graph.GetTextureCount() > 0) @@ -161,3 +164,19 @@ QString TextureValue::validationMessage() const return QString(); } + +void TextureValue::restore(const QJsonObject& data) +{ + m_currentTextureText = data["texture"].toString().toStdString(); + OnTextureListUpdate(); + + ShaderNode::restore(data); +} + +QJsonObject TextureValue::save() const +{ + QJsonObject data = ShaderNode::save(); + data["texture"] = QString::fromStdString(m_currentTextureText); + + return data; +} diff --git a/src/ShaderNode/DataModels/TextureValue.hpp b/src/ShaderNode/DataModels/TextureValue.hpp index fdf355828..4b46be4d6 100644 --- a/src/ShaderNode/DataModels/TextureValue.hpp +++ b/src/ShaderNode/DataModels/TextureValue.hpp @@ -36,6 +36,9 @@ class TextureValue : public ShaderNode bool ComputePreview(QPixmap& pixmap) override; void OnTextureListUpdate(); + void restore(const QJsonObject& data) override; + QJsonObject save() const override; + NazaraSlot(ShaderGraph, OnTextureListUpdate, m_onTextureListUpdateSlot); NazaraSlot(ShaderGraph, OnTexturePreviewUpdate, m_onTexturePreviewUpdateSlot); diff --git a/src/ShaderNode/DataModels/VecValue.hpp b/src/ShaderNode/DataModels/VecValue.hpp index b115477e3..fe94e67cb 100644 --- a/src/ShaderNode/DataModels/VecValue.hpp +++ b/src/ShaderNode/DataModels/VecValue.hpp @@ -33,9 +33,11 @@ class VecValue : public ShaderNode private: bool ComputePreview(QPixmap& pixmap) override; - QColor ToColor() const; + void restore(const QJsonObject& data) override; + QJsonObject save() const override; + VecType m_value; }; diff --git a/src/ShaderNode/DataModels/VecValue.inl b/src/ShaderNode/DataModels/VecValue.inl index fd6d31be1..a35a95686 100644 --- a/src/ShaderNode/DataModels/VecValue.inl +++ b/src/ShaderNode/DataModels/VecValue.inl @@ -2,6 +2,7 @@ #include #include #include +#include #include #include @@ -116,3 +117,27 @@ QColor VecValue::ToColor() const return QColor::fromRgbF(values[0], values[1], values[2], values[3]); } + +template +void VecValue::restore(const QJsonObject& data) +{ + QJsonArray vecValues = data["value"].toArray(); + for (std::size_t i = 0; i < ComponentCount; ++i) + m_value[i] = vecValues[int(i)].toInt(m_value[i]); + + ShaderNode::restore(data); +} + +template +QJsonObject VecValue::save() const +{ + QJsonObject data = ShaderNode::save(); + + QJsonArray vecValues; + for (std::size_t i = 0; i < ComponentCount; ++i) + vecValues.push_back(m_value[i]); + + data["value"] = vecValues; + + return data; +} diff --git a/src/ShaderNode/Enums.hpp b/src/ShaderNode/Enums.hpp index f67623a3f..72a5443f7 100644 --- a/src/ShaderNode/Enums.hpp +++ b/src/ShaderNode/Enums.hpp @@ -4,6 +4,8 @@ #define NAZARA_SHADERNODES_ENUMS_HPP #include +#include +#include enum class InputRole { @@ -40,10 +42,11 @@ enum class TextureType constexpr std::size_t TextureTypeCount = static_cast(TextureType::Max) + 1; -std::size_t GetComponentCount(InOutType type); +template std::optional DecodeEnum(const std::string_view& str); const char* EnumToString(InputRole role); const char* EnumToString(InOutType input); const char* EnumToString(TextureType textureType); +std::size_t GetComponentCount(InOutType type); #include diff --git a/src/ShaderNode/Enums.inl b/src/ShaderNode/Enums.inl index 243d12205..f54d0801f 100644 --- a/src/ShaderNode/Enums.inl +++ b/src/ShaderNode/Enums.inl @@ -1 +1,15 @@ #include + +template +std::optional DecodeEnum(const std::string_view& str) +{ + constexpr std::size_t ValueCount = static_cast(T::Max) + 1; + for (std::size_t i = 0; i < ValueCount; ++i) + { + T value = static_cast(i); + if (str == EnumToString(value)) + return value; + } + + return {}; +} diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp index 38d1a8dcb..6fc2fe6aa 100644 --- a/src/ShaderNode/ShaderGraph.cpp +++ b/src/ShaderNode/ShaderGraph.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -114,6 +115,136 @@ std::size_t ShaderGraph::AddTexture(std::string name, TextureType type) return index; } +void ShaderGraph::Clear() +{ + m_flowScene.clearScene(); + m_flowScene.clear(); + + m_inputs.clear(); + m_outputs.clear(); + m_textures.clear(); + + OnInputListUpdate(this); + OnOutputListUpdate(this); + OnTextureListUpdate(this); +} + +void ShaderGraph::Load(const QJsonObject& data) +{ + Clear(); + + QJsonArray inputArray = data["inputs"].toArray(); + for (const auto& inputDocRef : inputArray) + { + QJsonObject inputDoc = inputDocRef.toObject(); + + InputEntry& input = m_inputs.emplace_back(); + input.name = inputDoc["name"].toString().toStdString(); + input.role = DecodeEnum(inputDoc["role"].toString().toStdString()).value(); + input.roleIndex = static_cast(inputDoc["roleIndex"].toInt(0)); + input.type = DecodeEnum(inputDoc["type"].toString().toStdString()).value(); + } + + OnInputListUpdate(this); + + QJsonArray outputArray = data["outputs"].toArray(); + for (const auto& outputDocRef : outputArray) + { + QJsonObject outputDoc = outputDocRef.toObject(); + + OutputEntry& output = m_outputs.emplace_back(); + output.name = outputDoc["name"].toString().toStdString(); + output.type = DecodeEnum(outputDoc["type"].toString().toStdString()).value(); + } + + OnOutputListUpdate(this); + + QJsonArray textureArray = data["textures"].toArray(); + for (const auto& textureDocRef : textureArray) + { + QJsonObject textureDoc = textureDocRef.toObject(); + + TextureEntry& texture = m_textures.emplace_back(); + texture.name = textureDoc["name"].toString().toStdString(); + texture.type = DecodeEnum(textureDoc["type"].toString().toStdString()).value(); + } + + OnTextureListUpdate(this); + + for (QJsonValueRef node : data["nodes"].toArray()) + m_flowScene.restoreNode(node.toObject()); + + for (QJsonValueRef connection : data["connections"].toArray()) + m_flowScene.restoreConnection(connection.toObject()); +} + +QJsonObject ShaderGraph::Save() +{ + QJsonObject sceneJson; + + QJsonArray inputArray; + { + for (const auto& input : m_inputs) + { + QJsonObject inputDoc; + inputDoc["name"] = QString::fromStdString(input.name); + inputDoc["role"] = QString(EnumToString(input.role)); + inputDoc["roleIndex"] = int(input.roleIndex); + inputDoc["type"] = QString(EnumToString(input.type)); + + inputArray.append(inputDoc); + } + } + sceneJson["inputs"] = inputArray; + + QJsonArray outputArray; + { + for (const auto& output : m_outputs) + { + QJsonObject outputDoc; + outputDoc["name"] = QString::fromStdString(output.name); + outputDoc["type"] = QString(EnumToString(output.type)); + + outputArray.append(outputDoc); + } + } + sceneJson["outputs"] = outputArray; + + QJsonArray textureArray; + { + for (const auto& texture : m_textures) + { + QJsonObject textureDoc; + textureDoc["name"] = QString::fromStdString(texture.name); + textureDoc["type"] = QString(EnumToString(texture.type)); + + textureArray.append(textureDoc); + } + } + sceneJson["textures"] = textureArray; + + QJsonArray nodesJsonArray; + { + for (auto&& [uuid, node] : m_flowScene.nodes()) + nodesJsonArray.append(node->save()); + } + sceneJson["nodes"] = nodesJsonArray; + + QJsonArray connectionJsonArray; + { + for (auto&& [uuid, connection] : m_flowScene.connections()) + { + QJsonObject connectionJson = connection->save(); + + if (!connectionJson.isEmpty()) + connectionJsonArray.append(connectionJson); + } + } + sceneJson["connections"] = connectionJsonArray; + + return sceneJson; +} + Nz::ShaderAst::StatementPtr ShaderGraph::ToAst() { std::vector statements; diff --git a/src/ShaderNode/ShaderGraph.hpp b/src/ShaderNode/ShaderGraph.hpp index 854d5cfb7..536a01dcc 100644 --- a/src/ShaderNode/ShaderGraph.hpp +++ b/src/ShaderNode/ShaderGraph.hpp @@ -27,6 +27,8 @@ class ShaderGraph std::size_t AddOutput(std::string name, InOutType type); std::size_t AddTexture(std::string name, TextureType type); + void Clear(); + inline const InputEntry& GetInput(std::size_t inputIndex) const; inline std::size_t GetInputCount() const; inline const std::vector& GetInputs() const; @@ -39,6 +41,9 @@ class ShaderGraph inline std::size_t GetTextureCount() const; inline const std::vector& GetTextures() const; + void Load(const QJsonObject& data); + QJsonObject Save(); + Nz::ShaderAst::StatementPtr ToAst(); void UpdateInput(std::size_t inputIndex, std::string name, InOutType type, InputRole role, std::size_t roleIndex); diff --git a/src/ShaderNode/Widgets/MainWindow.cpp b/src/ShaderNode/Widgets/MainWindow.cpp index 505c1f285..c30007f14 100644 --- a/src/ShaderNode/Widgets/MainWindow.cpp +++ b/src/ShaderNode/Widgets/MainWindow.cpp @@ -6,7 +6,10 @@ #include #include #include +#include +#include #include +#include #include #include #include @@ -77,7 +80,19 @@ m_shaderGraph(graph) void MainWindow::BuildMenu() { - QMenu* compileMenu = menuBar()->addMenu(tr("&Compilation")); + QMenuBar* menu = menuBar(); + + QMenu* shader = menu->addMenu(tr("&Shader")); + { + QtNodes::FlowScene* scene = &m_shaderGraph.GetScene(); + + QAction* loadShader = shader->addAction(tr("Load...")); + QObject::connect(loadShader, &QAction::triggered, this, &MainWindow::OnLoad); + QAction* saveShader = shader->addAction(tr("Save...")); + QObject::connect(saveShader, &QAction::triggered, this, &MainWindow::OnSave); + } + + QMenu* compileMenu = menu->addMenu(tr("&Compilation")); QAction* compileToGlsl = compileMenu->addAction(tr("GLSL")); connect(compileToGlsl, &QAction::triggered, [&](bool) { OnCompileToGLSL(); }); } @@ -103,3 +118,48 @@ void MainWindow::OnCompileToGLSL() QMessageBox::critical(this, tr("Compilation failed"), QString("Compilation failed: ") + e.what()); } } + +void MainWindow::OnLoad() +{ + QString fileName = QFileDialog::getOpenFileName(this, tr("Open shader flow"), QDir::homePath(), tr("Shader Flow Files (*.shaderflow)")); + if (fileName.isEmpty()) + return; + + QFile file(fileName); + if (!file.open(QIODevice::ReadOnly)) + { + QMessageBox::critical(this, tr("Failed to open file"), QString("Failed to open shader flow file: ") + file.errorString()); + return; + } + + QJsonObject jsonDocument = QJsonDocument::fromJson(file.readAll()).object(); + if (jsonDocument.isEmpty()) + { + QMessageBox::critical(this, tr("Invalid file"), tr("Invalid shader flow file")); + return; + } + + try + { + m_shaderGraph.Load(jsonDocument); + } + catch (const std::exception& e) + { + QMessageBox::critical(this, tr("Invalid file"), tr("Invalid shader flow file: ") + e.what()); + return; + } +} + +void MainWindow::OnSave() +{ + QString fileName = QFileDialog::getSaveFileName(nullptr, tr("Open shader flow"), QDir::homePath(), tr("Shader Flow Files (*.shaderflow)")); + if (fileName.isEmpty()) + return; + + if (!fileName.endsWith("flow", Qt::CaseInsensitive)) + fileName += ".shaderflow"; + + QFile file(fileName); + if (file.open(QIODevice::WriteOnly)) + file.write(QJsonDocument(m_shaderGraph.Save()).toJson()); +} diff --git a/src/ShaderNode/Widgets/MainWindow.hpp b/src/ShaderNode/Widgets/MainWindow.hpp index 777c3b92b..ff8b307c1 100644 --- a/src/ShaderNode/Widgets/MainWindow.hpp +++ b/src/ShaderNode/Widgets/MainWindow.hpp @@ -18,6 +18,8 @@ class MainWindow : public QMainWindow private: void BuildMenu(); void OnCompileToGLSL(); + void OnLoad(); + void OnSave(); NazaraSlot(ShaderGraph, OnSelectedNodeUpdate, m_onSelectedNodeUpdate); From de1c64253e6b9b49d426d96c602c5902373e5259 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 4 Jun 2020 18:31:43 +0200 Subject: [PATCH 236/316] Fix missing files --- include/Nazara/Renderer/ShaderWriter.hpp | 1 + src/Nazara/Renderer/GlslWriter.cpp | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/Nazara/Renderer/ShaderWriter.hpp b/include/Nazara/Renderer/ShaderWriter.hpp index 634c335ec..1058fa924 100644 --- a/include/Nazara/Renderer/ShaderWriter.hpp +++ b/include/Nazara/Renderer/ShaderWriter.hpp @@ -34,6 +34,7 @@ namespace Nz virtual void Write(const ShaderAst::AssignOp& node) = 0; virtual void Write(const ShaderAst::Branch& node) = 0; + virtual void Write(const ShaderAst::BinaryFunc& node) = 0; virtual void Write(const ShaderAst::BinaryOp& node) = 0; virtual void Write(const ShaderAst::BuiltinVariable& node) = 0; virtual void Write(const ShaderAst::Cast& node) = 0; diff --git a/src/Nazara/Renderer/GlslWriter.cpp b/src/Nazara/Renderer/GlslWriter.cpp index 73abec55f..b37b9deff 100644 --- a/src/Nazara/Renderer/GlslWriter.cpp +++ b/src/Nazara/Renderer/GlslWriter.cpp @@ -173,6 +173,26 @@ namespace Nz } } + void GlslWriter::Write(const ShaderAst::BinaryFunc& node) + { + switch (node.intrinsic) + { + case ShaderAst::BinaryIntrinsic::CrossProduct: + Append("cross"); + break; + + case ShaderAst::BinaryIntrinsic::DotProduct: + Append("dot"); + break; + } + + Append("("); + Write(node.left); + Append(", "); + Write(node.right); + Append(")"); + } + void GlslWriter::Write(const ShaderAst::BinaryOp& node) { Write(node.left); From 8467c79021982804d951191ced9a36b6ac28698a Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 5 Jun 2020 19:47:29 +0200 Subject: [PATCH 237/316] Renderer: Add shader serialization --- include/Nazara/Renderer/GlslWriter.hpp | 28 +- include/Nazara/Renderer/ShaderAst.hpp | 318 +++++++++------- include/Nazara/Renderer/ShaderAst.inl | 364 ++++++++++-------- include/Nazara/Renderer/ShaderBuilder.inl | 16 +- include/Nazara/Renderer/ShaderSerializer.hpp | 111 ++++++ include/Nazara/Renderer/ShaderSerializer.inl | 79 ++++ include/Nazara/Renderer/ShaderVisitor.hpp | 50 +++ include/Nazara/Renderer/ShaderWriter.hpp | 29 +- src/Nazara/Renderer/GlslWriter.cpp | 65 ++-- src/Nazara/Renderer/Renderer.cpp | 2 +- src/Nazara/Renderer/ShaderAst.cpp | 91 ++--- src/Nazara/Renderer/ShaderSerializer.cpp | 376 +++++++++++++++++++ src/Nazara/Renderer/ShaderVisitor.cpp | 29 ++ src/Nazara/Renderer/ShaderWriter.cpp | 14 - src/ShaderNode/ShaderGraph.cpp | 2 +- 15 files changed, 1131 insertions(+), 443 deletions(-) create mode 100644 include/Nazara/Renderer/ShaderSerializer.hpp create mode 100644 include/Nazara/Renderer/ShaderSerializer.inl create mode 100644 include/Nazara/Renderer/ShaderVisitor.hpp create mode 100644 src/Nazara/Renderer/ShaderSerializer.cpp create mode 100644 src/Nazara/Renderer/ShaderVisitor.cpp diff --git a/include/Nazara/Renderer/GlslWriter.hpp b/include/Nazara/Renderer/GlslWriter.hpp index 373a9950e..2caaa6a75 100644 --- a/include/Nazara/Renderer/GlslWriter.hpp +++ b/include/Nazara/Renderer/GlslWriter.hpp @@ -31,20 +31,20 @@ namespace Nz void SetGlslVersion(unsigned int version); - void Write(const ShaderAst::AssignOp& node) override; - void Write(const ShaderAst::Branch& node) override; - void Write(const ShaderAst::BinaryFunc& node) override; - void Write(const ShaderAst::BinaryOp& node) override; - void Write(const ShaderAst::BuiltinVariable& node) override; - void Write(const ShaderAst::Cast& node) override; - void Write(const ShaderAst::Constant& node) override; - void Write(const ShaderAst::DeclareVariable& node) override; - void Write(const ShaderAst::ExpressionStatement& node) override; - void Write(const ShaderAst::NamedVariable& node) override; - void Write(const ShaderAst::NodePtr& node) override; - void Write(const ShaderAst::Sample2D& node) override; - void Write(const ShaderAst::StatementBlock& node) override; - void Write(const ShaderAst::SwizzleOp& node) override; + using ShaderWriter::Visit; + void Visit(const ShaderAst::AssignOp& node) override; + void Visit(const ShaderAst::Branch& node) override; + void Visit(const ShaderAst::BinaryFunc& node) override; + void Visit(const ShaderAst::BinaryOp& node) override; + void Visit(const ShaderAst::BuiltinVariable& node) override; + void Visit(const ShaderAst::Cast& node) override; + void Visit(const ShaderAst::Constant& node) override; + void Visit(const ShaderAst::DeclareVariable& node) override; + void Visit(const ShaderAst::ExpressionStatement& node) override; + void Visit(const ShaderAst::NamedVariable& node) override; + void Visit(const ShaderAst::Sample2D& node) override; + void Visit(const ShaderAst::StatementBlock& node) override; + void Visit(const ShaderAst::SwizzleOp& node) override; private: struct Function; diff --git a/include/Nazara/Renderer/ShaderAst.hpp b/include/Nazara/Renderer/ShaderAst.hpp index 6dd43ea89..0bbaec9f3 100644 --- a/include/Nazara/Renderer/ShaderAst.hpp +++ b/include/Nazara/Renderer/ShaderAst.hpp @@ -17,6 +17,8 @@ namespace Nz { + class ByteStream; + class ShaderVisitor; class ShaderWriter; namespace ShaderAst @@ -66,6 +68,26 @@ namespace Nz Void // void }; + enum class NodeType + { + None = -1, + + AssignOp, + BinaryFunc, + BinaryOp, + Branch, + BuiltinVariable, + Cast, + Constant, + ConditionalStatement, + DeclareVariable, + ExpressionStatement, + NamedVariable, + Sample2D, + SwizzleOp, + StatementBlock + }; + enum class SwizzleComponent { First, @@ -93,13 +115,21 @@ namespace Nz class NAZARA_RENDERER_API Node { public: - virtual ~Node() = default; + virtual ~Node(); + + inline NodeType GetType() const; virtual void Register(ShaderWriter& visitor) = 0; - virtual void Visit(ShaderWriter& visitor) = 0; + virtual void Visit(ShaderVisitor& visitor) = 0; static inline unsigned int GetComponentCount(ExpressionType type); static inline ExpressionType GetComponentType(ExpressionType type); + + protected: + inline Node(NodeType type); + + private: + NodeType m_type; }; class Statement; @@ -108,6 +138,8 @@ namespace Nz class NAZARA_RENDERER_API Statement : public Node { + public: + using Node::Node; }; class Expression; @@ -117,236 +149,250 @@ namespace Nz class NAZARA_RENDERER_API Expression : public Node { public: + using Node::Node; + virtual ExpressionCategory GetExpressionCategory() const; virtual ExpressionType GetExpressionType() const = 0; }; - class NAZARA_RENDERER_API ExpressionStatement : public Statement + struct NAZARA_RENDERER_API ExpressionStatement : public Statement { - public: - inline explicit ExpressionStatement(ExpressionPtr expr); + inline ExpressionStatement(); - void Register(ShaderWriter& visitor) override; - void Visit(ShaderWriter& visitor) override; + void Register(ShaderWriter& visitor) override; + void Visit(ShaderVisitor& visitor) override; - ExpressionPtr expression; + ExpressionPtr expression; + + static inline std::shared_ptr Build(ExpressionPtr expr); }; ////////////////////////////////////////////////////////////////////////// - class NAZARA_RENDERER_API ConditionalStatement : public Statement + struct NAZARA_RENDERER_API ConditionalStatement : public Statement { - public: - inline ConditionalStatement(const String& condition, StatementPtr statementPtr); + inline ConditionalStatement(); - void Register(ShaderWriter& visitor) override; - void Visit(ShaderWriter& visitor) override; + void Register(ShaderWriter& visitor) override; + void Visit(ShaderVisitor& visitor) override; - String conditionName; - StatementPtr statement; + std::string conditionName; + StatementPtr statement; + + static inline std::shared_ptr Build(std::string condition, StatementPtr statementPtr); }; - class NAZARA_RENDERER_API StatementBlock : public Statement + struct NAZARA_RENDERER_API StatementBlock : public Statement { - public: - template explicit StatementBlock(Args&&... args); + inline StatementBlock(); - void Register(ShaderWriter& visitor) override; - void Visit(ShaderWriter& visitor) override; + void Register(ShaderWriter& visitor) override; + void Visit(ShaderVisitor& visitor) override; - std::vector statements; + std::vector statements; + + template static std::shared_ptr Build(Args&&... args); }; - class Variable; + struct Variable; using VariablePtr = std::shared_ptr; - class NAZARA_RENDERER_API Variable : public Expression + struct NAZARA_RENDERER_API Variable : public Expression { - public: - inline Variable(VariableType varKind, ExpressionType varType); + using Expression::Expression; - ExpressionCategory GetExpressionCategory() const override; - ExpressionType GetExpressionType() const override; + ExpressionCategory GetExpressionCategory() const override; + ExpressionType GetExpressionType() const override; - ExpressionType type; - VariableType kind; + ExpressionType type; + VariableType kind; }; - class NAZARA_RENDERER_API BuiltinVariable : public Variable + struct NAZARA_RENDERER_API BuiltinVariable : public Variable { - public: - inline BuiltinVariable(BuiltinEntry variable, ExpressionType varType); + inline BuiltinVariable(); - void Register(ShaderWriter& visitor) override; - void Visit(ShaderWriter& visitor) override; + void Register(ShaderWriter& visitor) override; + void Visit(ShaderVisitor& visitor) override; - BuiltinEntry var; + BuiltinEntry var; + + static inline std::shared_ptr Build(BuiltinEntry variable, ExpressionType varType); }; - class NamedVariable; + struct NamedVariable; using NamedVariablePtr = std::shared_ptr; - class NAZARA_RENDERER_API NamedVariable : public Variable + struct NAZARA_RENDERER_API NamedVariable : public Variable { - public: - inline NamedVariable(VariableType varKind, const Nz::String& varName, ExpressionType varType); + inline NamedVariable(); - void Register(ShaderWriter& visitor) override; - void Visit(ShaderWriter& visitor) override; + void Register(ShaderWriter& visitor) override; + void Visit(ShaderVisitor& visitor) override; - Nz::String name; + std::string name; + + static inline std::shared_ptr Build(VariableType varType, std::string varName, ExpressionType expressionType); }; - class NAZARA_RENDERER_API DeclareVariable : public Statement + struct NAZARA_RENDERER_API DeclareVariable : public Statement { - public: - inline DeclareVariable(NamedVariablePtr Variable, ExpressionPtr Expression = nullptr); + inline DeclareVariable(); - void Register(ShaderWriter& visitor) override; - void Visit(ShaderWriter& visitor) override; + void Register(ShaderWriter& visitor) override; + void Visit(ShaderVisitor& visitor) override; - NamedVariablePtr variable; - ExpressionPtr expression; + NamedVariablePtr variable; + ExpressionPtr expression; + + static inline std::shared_ptr Build(NamedVariablePtr variable, ExpressionPtr expression = nullptr); }; ////////////////////////////////////////////////////////////////////////// - class NAZARA_RENDERER_API AssignOp : public Expression + struct NAZARA_RENDERER_API AssignOp : public Expression { - public: - inline AssignOp(AssignType Op, ExpressionPtr Left, ExpressionPtr Right); + inline AssignOp(); - ExpressionType GetExpressionType() const override; - void Register(ShaderWriter& visitor) override; - void Visit(ShaderWriter& visitor) override; + ExpressionType GetExpressionType() const override; + void Register(ShaderWriter& visitor) override; + void Visit(ShaderVisitor& visitor) override; - AssignType op; - ExpressionPtr left; - ExpressionPtr right; + AssignType op; + ExpressionPtr left; + ExpressionPtr right; + + static inline std::shared_ptr Build(AssignType op, ExpressionPtr left, ExpressionPtr right); }; - class NAZARA_RENDERER_API BinaryOp : public Expression + struct NAZARA_RENDERER_API BinaryOp : public Expression { - public: - inline BinaryOp(BinaryType Op, ExpressionPtr Left, ExpressionPtr Right); + inline BinaryOp(); - ExpressionType GetExpressionType() const override; - void Register(ShaderWriter& visitor) override; - void Visit(ShaderWriter& visitor) override; + ExpressionType GetExpressionType() const override; + void Register(ShaderWriter& visitor) override; + void Visit(ShaderVisitor& visitor) override; - BinaryType op; - ExpressionPtr left; - ExpressionPtr right; + BinaryType op; + ExpressionPtr left; + ExpressionPtr right; + + static inline std::shared_ptr Build(BinaryType op, ExpressionPtr left, ExpressionPtr right); }; - class NAZARA_RENDERER_API Branch : public Statement + struct NAZARA_RENDERER_API Branch : public Statement { - public: - inline Branch(ExpressionPtr condition, StatementPtr trueStatement, StatementPtr falseStatement = nullptr); + struct ConditionalStatement; - void Register(ShaderWriter& visitor) override; - void Visit(ShaderWriter& visitor) override; + inline Branch(); - struct ConditionalStatement - { - ExpressionPtr condition; - StatementPtr statement; - }; + void Register(ShaderWriter& visitor) override; + void Visit(ShaderVisitor& visitor) override; - std::vector condStatements; - StatementPtr elseStatement; + std::vector condStatements; + StatementPtr elseStatement; + + struct ConditionalStatement + { + ExpressionPtr condition; + StatementPtr statement; + }; + + inline std::shared_ptr Build(ExpressionPtr condition, StatementPtr trueStatement, StatementPtr falseStatement = nullptr); }; - class NAZARA_RENDERER_API Cast : public Expression + struct NAZARA_RENDERER_API Cast : public Expression { - public: - inline Cast(ExpressionType castTo, ExpressionPtr first, ExpressionPtr second = nullptr, ExpressionPtr third = nullptr, ExpressionPtr fourth = nullptr); - inline Cast(ExpressionType castTo, ExpressionPtr* expressions, std::size_t expressionCount); + inline Cast(); - ExpressionType GetExpressionType() const override; - void Register(ShaderWriter& visitor) override; - void Visit(ShaderWriter& visitor) override; + ExpressionType GetExpressionType() const override; + void Register(ShaderWriter& visitor) override; + void Visit(ShaderVisitor& visitor) override; - ExpressionType exprType; - std::array expressions; + ExpressionType exprType; + std::array expressions; - private: - void Validate() const; + static inline std::shared_ptr Build(ExpressionType castTo, ExpressionPtr first, ExpressionPtr second = nullptr, ExpressionPtr third = nullptr, ExpressionPtr fourth = nullptr); + static inline std::shared_ptr Build(ExpressionType castTo, ExpressionPtr* expressions, std::size_t expressionCount); }; - class NAZARA_RENDERER_API Constant : public Expression + struct NAZARA_RENDERER_API Constant : public Expression { - public: - inline explicit Constant(bool value); - inline explicit Constant(float value); - inline explicit Constant(const Vector2f& value); - inline explicit Constant(const Vector3f& value); - inline explicit Constant(const Vector4f& value); + inline Constant(); - ExpressionType GetExpressionType() const override; - void Register(ShaderWriter& visitor) override; - void Visit(ShaderWriter& visitor) override; + ExpressionType GetExpressionType() const override; + void Register(ShaderWriter& visitor) override; + void Visit(ShaderVisitor& visitor) override; - ExpressionType exprType; + ExpressionType exprType; - union - { - bool bool1; - float vec1; - Vector2f vec2; - Vector3f vec3; - Vector4f vec4; - } values; + union + { + bool bool1; + float vec1; + Vector2f vec2; + Vector3f vec3; + Vector4f vec4; + } values; + + static inline std::shared_ptr Build(bool value); + static inline std::shared_ptr Build(float value); + static inline std::shared_ptr Build(const Vector2f& value); + static inline std::shared_ptr Build(const Vector3f& value); + static inline std::shared_ptr Build(const Vector4f& value); }; - class NAZARA_RENDERER_API SwizzleOp : public Expression + struct NAZARA_RENDERER_API SwizzleOp : public Expression { - public: - inline SwizzleOp(ExpressionPtr expressionPtr, std::initializer_list swizzleComponents); + inline SwizzleOp(); - ExpressionCategory GetExpressionCategory() const override; - ExpressionType GetExpressionType() const override; - void Register(ShaderWriter& visitor) override; - void Visit(ShaderWriter& visitor) override; + ExpressionCategory GetExpressionCategory() const override; + ExpressionType GetExpressionType() const override; + void Register(ShaderWriter& visitor) override; + void Visit(ShaderVisitor& visitor) override; - std::array components; - std::size_t componentCount; - ExpressionPtr expression; + std::array components; + std::size_t componentCount; + ExpressionPtr expression; + + static inline std::shared_ptr Build(ExpressionPtr expressionPtr, std::initializer_list swizzleComponents); }; ////////////////////////////////////////////////////////////////////////// - class NAZARA_RENDERER_API Sample2D : public Expression + struct NAZARA_RENDERER_API Sample2D : public Expression { - public: - inline Sample2D(ExpressionPtr samplerPtr, ExpressionPtr coordinatesPtr); + inline Sample2D(); - ExpressionType GetExpressionType() const override; - void Register(ShaderWriter& visitor) override; - void Visit(ShaderWriter& visitor) override; + ExpressionType GetExpressionType() const override; + void Register(ShaderWriter& visitor) override; + void Visit(ShaderVisitor& visitor) override; - ExpressionPtr sampler; - ExpressionPtr coordinates; + ExpressionPtr sampler; + ExpressionPtr coordinates; + + static inline std::shared_ptr Build(ExpressionPtr samplerPtr, ExpressionPtr coordinatesPtr); }; ////////////////////////////////////////////////////////////////////////// - class NAZARA_RENDERER_API BinaryFunc : public Expression + struct NAZARA_RENDERER_API BinaryFunc : public Expression { - public: - inline BinaryFunc(BinaryIntrinsic Op, ExpressionPtr Left, ExpressionPtr Right); + inline BinaryFunc(); - ExpressionType GetExpressionType() const override; - void Register(ShaderWriter& visitor) override; - void Visit(ShaderWriter& visitor) override; + ExpressionType GetExpressionType() const override; + void Register(ShaderWriter& visitor) override; + void Visit(ShaderVisitor& visitor) override; - BinaryIntrinsic intrinsic; - ExpressionPtr left; - ExpressionPtr right; + BinaryIntrinsic intrinsic; + ExpressionPtr left; + ExpressionPtr right; + + static inline std::shared_ptr Build(BinaryIntrinsic intrinsic, ExpressionPtr left, ExpressionPtr right); }; } } diff --git a/include/Nazara/Renderer/ShaderAst.inl b/include/Nazara/Renderer/ShaderAst.inl index 958baecfe..536758832 100644 --- a/include/Nazara/Renderer/ShaderAst.inl +++ b/include/Nazara/Renderer/ShaderAst.inl @@ -9,6 +9,16 @@ namespace Nz { namespace ShaderAst { + inline Node::Node(NodeType type) : + m_type(type) + { + } + + inline NodeType ShaderAst::Node::GetType() const + { + return m_type; + } + inline unsigned int Node::GetComponentCount(ExpressionType type) { switch (type) @@ -47,224 +57,264 @@ namespace Nz } } - inline ExpressionStatement::ExpressionStatement(ExpressionPtr expr) : - expression(std::move(expr)) + inline ExpressionStatement::ExpressionStatement() : + Statement(NodeType::ExpressionStatement) + { + } + + inline std::shared_ptr ExpressionStatement::Build(ExpressionPtr expr) + { + auto node = std::make_shared(); + node->expression = std::move(expr); + + return node; + } + + inline ConditionalStatement::ConditionalStatement() : + Statement(NodeType::ConditionalStatement) { } - inline ConditionalStatement::ConditionalStatement(const String& condition, StatementPtr statementPtr) : - conditionName(condition), - statement(std::move(statementPtr)) + inline std::shared_ptr ConditionalStatement::Build(std::string condition, StatementPtr statementPtr) + { + auto node = std::make_shared(); + node->conditionName = std::move(condition); + node->statement = std::move(statementPtr); + + return node; + } + + + inline StatementBlock::StatementBlock() : + Statement(NodeType::StatementBlock) { } template - StatementBlock::StatementBlock(Args&& ...args) : - statements({std::forward(args)...}) + std::shared_ptr StatementBlock::Build(Args&&... args) + { + auto node = std::make_shared(); + node->statements = std::vector({ std::forward(args)... }); + + return node; + } + + + inline BuiltinVariable::BuiltinVariable() : + Variable(NodeType::BuiltinVariable) + { + kind = VariableType::Builtin; + } + + inline std::shared_ptr BuiltinVariable::Build(BuiltinEntry variable, ExpressionType varType) + { + auto node = std::make_shared(); + node->type = varType; + node->var = variable; + + return node; + } + + + inline NamedVariable::NamedVariable() : + Variable(NodeType::NamedVariable) { } - inline Variable::Variable(VariableType varKind, ExpressionType varType) : - type(varType), - kind(varKind) + inline std::shared_ptr NamedVariable::Build(VariableType type, std::string varName, ExpressionType expressionType) + { + auto node = std::make_shared(); + node->kind = type; + node->name = std::move(varName); + node->type = expressionType; + + return node; + } + + + inline DeclareVariable::DeclareVariable() : + Statement(NodeType::DeclareVariable) { } - inline BuiltinVariable::BuiltinVariable(BuiltinEntry variable, ExpressionType varType) : - Variable(VariableType::Builtin, varType), - var(variable) + inline std::shared_ptr DeclareVariable::Build(NamedVariablePtr variable, ExpressionPtr expression) + { + auto node = std::make_shared(); + node->expression = std::move(expression); + node->variable = std::move(variable); + + return node; + } + + + inline AssignOp::AssignOp() : + Expression(NodeType::AssignOp) { } - inline NamedVariable::NamedVariable(VariableType varKind, const Nz::String& varName, ExpressionType varType) : - Variable(varKind, varType), - name(varName) + inline std::shared_ptr AssignOp::Build(AssignType op, ExpressionPtr left, ExpressionPtr right) + { + auto node = std::make_shared(); + node->op = op; + node->left = std::move(left); + node->right = std::move(right); + + return node; + } + + + inline BinaryOp::BinaryOp() : + Expression(NodeType::BinaryOp) { } - inline DeclareVariable::DeclareVariable(NamedVariablePtr Variable, ExpressionPtr Expression) : - expression(std::move(Expression)), - variable(std::move(Variable)) + inline std::shared_ptr BinaryOp::Build(BinaryType op, ExpressionPtr left, ExpressionPtr right) + { + auto node = std::make_shared(); + node->op = op; + node->left = std::move(left); + node->right = std::move(right); + + return node; + } + + + inline Branch::Branch() : + Statement(NodeType::Branch) { } - inline AssignOp::AssignOp(AssignType Op, ExpressionPtr Left, ExpressionPtr Right) : - op(Op), - left(std::move(Left)), - right(std::move(Right)) + inline std::shared_ptr Branch::Build(ExpressionPtr condition, StatementPtr trueStatement, StatementPtr falseStatement) { - if (left->GetExpressionCategory() != ExpressionCategory::LValue) - //TODO: AstParseError - throw std::runtime_error("Assignation is only possible with lvalues"); + auto node = std::make_shared(); + node->condStatements.emplace_back(ConditionalStatement{ std::move(condition), std::move(trueStatement) }); + node->elseStatement = std::move(falseStatement); + + return node; } - inline BinaryOp::BinaryOp(BinaryType Op, ExpressionPtr Left, ExpressionPtr Right) : - op(Op), - left(std::move(Left)), - right(std::move(Right)) + + inline Cast::Cast() : + Expression(NodeType::Cast) { - ExpressionType leftType = left->GetExpressionType(); - ExpressionType rightType = right->GetExpressionType(); - - if (leftType != rightType) - { - switch (op) - { - case BinaryType::Add: - case BinaryType::Equality: - case BinaryType::Substract: - { - //TODO: AstParseError - throw std::runtime_error("Left expression type must match right expression type"); - } - - case BinaryType::Multiply: - case BinaryType::Divide: - { - switch (leftType) - { - case ExpressionType::Float2: - case ExpressionType::Float3: - case ExpressionType::Float4: - { - if (rightType != ExpressionType::Float1) - throw std::runtime_error("Left expression type is not compatible with right expression type"); - - break; - } - - case ExpressionType::Mat4x4: - { - switch (rightType) - { - case ExpressionType::Float1: - case ExpressionType::Float4: - case ExpressionType::Mat4x4: - break; - - //TODO: AstParseError - default: - throw std::runtime_error("Left expression type is not compatible with right expression type"); - } - - break; - } - - default: - //TODO: AstParseError - throw std::runtime_error("Left expression type must match right expression type"); - } - } - } - } } - inline Branch::Branch(ExpressionPtr condition, StatementPtr trueStatement, StatementPtr falseStatement) + inline std::shared_ptr Cast::Build(ExpressionType castTo, ExpressionPtr first, ExpressionPtr second, ExpressionPtr third, ExpressionPtr fourth) { - condStatements.emplace_back(ConditionalStatement{ std::move(condition), std::move(trueStatement) }); - elseStatement = std::move(falseStatement); + auto node = std::make_shared(); + node->exprType = castTo; + node->expressions = { {first, second, third, fourth} }; + + return node; } - inline Cast::Cast(ExpressionType castTo, ExpressionPtr first, ExpressionPtr second, ExpressionPtr third, ExpressionPtr fourth) : - exprType(castTo), - expressions({ {first, second, third, fourth} }) - { - Validate(); - } - - inline Cast::Cast(ExpressionType castTo, ExpressionPtr* Expressions, std::size_t expressionCount) : - exprType(castTo) + inline std::shared_ptr Cast::Build(ExpressionType castTo, ExpressionPtr* Expressions, std::size_t expressionCount) { + auto node = std::make_shared(); + node->exprType = castTo; for (std::size_t i = 0; i < expressionCount; ++i) - expressions[i] = Expressions[i]; + node->expressions[i] = Expressions[i]; - Validate(); + return node; } - inline Constant::Constant(bool value) : - exprType(ExpressionType::Boolean) + + inline Constant::Constant() : + Expression(NodeType::Constant) { - values.bool1 = value; } - inline Constant::Constant(float value) : - exprType(ExpressionType::Float1) + inline std::shared_ptr Constant::Build(bool value) { - values.vec1 = value; + auto node = std::make_shared(); + node->exprType = ExpressionType::Boolean; + node->values.bool1 = value; + + return node; } - inline Constant::Constant(const Vector2f& value) : - exprType(ExpressionType::Float2) + inline std::shared_ptr Constant::Build(float value) { - values.vec2 = value; + auto node = std::make_shared(); + node->exprType = ExpressionType::Float1; + node->values.vec1 = value; + + return node; } - inline Constant::Constant(const Vector3f& value) : - exprType(ExpressionType::Float3) + inline std::shared_ptr Constant::Build(const Vector2f& value) { - values.vec3 = value; + auto node = std::make_shared(); + node->exprType = ExpressionType::Float2; + node->values.vec2 = value; + + return node; } - inline Constant::Constant(const Vector4f& value) : - exprType(ExpressionType::Float4) + inline std::shared_ptr Constant::Build(const Vector3f& value) { - values.vec4 = value; + auto node = std::make_shared(); + node->exprType = ExpressionType::Float3; + node->values.vec3 = value; + + return node; } - inline SwizzleOp::SwizzleOp(ExpressionPtr expressionPtr, std::initializer_list swizzleComponents) : - componentCount(swizzleComponents.size()), - expression(expressionPtr) + inline std::shared_ptr Constant::Build(const Vector4f& value) { - if (componentCount > 4) - throw std::runtime_error("Cannot swizzle more than four elements"); + auto node = std::make_shared(); + node->exprType = ExpressionType::Float4; + node->values.vec4 = value; - switch (expressionPtr->GetExpressionType()) - { - case ExpressionType::Float1: - case ExpressionType::Float2: - case ExpressionType::Float3: - case ExpressionType::Float4: - break; - - default: - throw std::runtime_error("Cannot swizzle this type"); - } - - std::copy(swizzleComponents.begin(), swizzleComponents.end(), components.begin()); + return node; } - inline Sample2D::Sample2D(ExpressionPtr samplerPtr, ExpressionPtr coordinatesPtr) : - sampler(std::move(samplerPtr)), - coordinates(std::move(coordinatesPtr)) - { - if (sampler->GetExpressionType() != ExpressionType::Sampler2D) - throw std::runtime_error("Sampler must be a Sampler2D"); - if (coordinates->GetExpressionType() != ExpressionType::Float2) - throw std::runtime_error("Coordinates must be a Float2"); + inline SwizzleOp::SwizzleOp() : + Expression(NodeType::SwizzleOp) + { } - inline BinaryFunc::BinaryFunc(BinaryIntrinsic Op, ExpressionPtr Left, ExpressionPtr Right) : - intrinsic(Op), - left(Left), - right(Right) + inline std::shared_ptr SwizzleOp::Build(ExpressionPtr expressionPtr, std::initializer_list swizzleComponents) { - ExpressionType leftType = left->GetExpressionType(); - ExpressionType rightType = right->GetExpressionType(); + auto node = std::make_shared(); + node->componentCount = swizzleComponents.size(); + node->expression = std::move(expressionPtr); - if (leftType != rightType) - //TODO: AstParseError - throw std::runtime_error("Left expression type must match right expression type"); + std::copy(swizzleComponents.begin(), swizzleComponents.end(), node->components.begin()); - switch (intrinsic) - { - case BinaryIntrinsic::CrossProduct: - { - if (leftType != ExpressionType::Float3) - //TODO: AstParseError - throw std::runtime_error("CrossProduct only works with Float3 expressions"); - } - } + return node; + } + + + inline Sample2D::Sample2D() : + Expression(NodeType::Sample2D) + { + } + + inline std::shared_ptr Sample2D::Build(ExpressionPtr samplerPtr, ExpressionPtr coordinatesPtr) + { + auto node = std::make_shared(); + node->coordinates = std::move(coordinatesPtr); + node->sampler = std::move(samplerPtr); + + return node; + } + + + inline BinaryFunc::BinaryFunc() : + Expression(NodeType::BinaryFunc) + { + } + + inline std::shared_ptr BinaryFunc::Build(BinaryIntrinsic intrinsic, ExpressionPtr left, ExpressionPtr right) + { + auto node = std::make_shared(); + node->intrinsic = intrinsic; + node->left = std::move(left); + node->right = std::move(right); + + return node; } } } diff --git a/include/Nazara/Renderer/ShaderBuilder.inl b/include/Nazara/Renderer/ShaderBuilder.inl index 76f00d394..7f9612a11 100644 --- a/include/Nazara/Renderer/ShaderBuilder.inl +++ b/include/Nazara/Renderer/ShaderBuilder.inl @@ -5,25 +5,25 @@ #include #include -namespace Nz { namespace ShaderBuilder +namespace Nz::ShaderBuilder { template template std::shared_ptr GenBuilder::operator()(Args&&... args) const { - return std::make_shared(std::forward(args)...); + return T::Build(std::forward(args)...); } template std::shared_ptr AssignOpBuilder::operator()(const ShaderAst::ExpressionPtr& left, const ShaderAst::ExpressionPtr& right) const { - return std::make_shared(op, left, right); + return ShaderAst::AssignOp::Build(op, left, right); } template std::shared_ptr BinOpBuilder::operator()(const ShaderAst::ExpressionPtr& left, const ShaderAst::ExpressionPtr& right) const { - return std::make_shared(op, left, right); + return ShaderAst::BinaryOp::Build(op, left, right); } inline std::shared_ptr BuiltinBuilder::operator()(ShaderAst::BuiltinEntry builtin) const @@ -39,21 +39,21 @@ namespace Nz { namespace ShaderBuilder NazaraAssert(exprType != ShaderAst::ExpressionType::Void, "Unhandled builtin"); - return std::make_shared(builtin, exprType); + return ShaderAst::BuiltinVariable::Build(builtin, exprType); } template template ShaderAst::NamedVariablePtr VarBuilder::operator()(Args&&... args) const { - return std::make_shared(type, std::forward(args)...); + return ShaderAst::NamedVariable::Build(type, std::forward(args)...); } template std::shared_ptr Cast(Args&&... args) { - return std::make_shared(Type, std::forward(args)...); + return ShaderAst::Cast::Build(Type, std::forward(args)...); } -} } +} #include diff --git a/include/Nazara/Renderer/ShaderSerializer.hpp b/include/Nazara/Renderer/ShaderSerializer.hpp new file mode 100644 index 000000000..521284370 --- /dev/null +++ b/include/Nazara/Renderer/ShaderSerializer.hpp @@ -0,0 +1,111 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_SHADERSERIALIZER_HPP +#define NAZARA_SHADERSERIALIZER_HPP + +#include +#include +#include +#include +#include + +namespace Nz::ShaderAst +{ + class NAZARA_RENDERER_API ShaderSerializerBase + { + public: + ShaderSerializerBase() = default; + ShaderSerializerBase(const ShaderSerializerBase&) = delete; + ShaderSerializerBase(ShaderSerializerBase&&) = delete; + ~ShaderSerializerBase() = default; + + void Serialize(AssignOp& node); + void Serialize(BinaryFunc& node); + void Serialize(BinaryOp& node); + void Serialize(Branch& node); + void Serialize(BuiltinVariable& node); + void Serialize(Cast& node); + void Serialize(Constant& node); + void Serialize(DeclareVariable& node); + void Serialize(ExpressionStatement& node); + void Serialize(NamedVariable& node); + void Serialize(Sample2D& node); + void Serialize(StatementBlock& node); + void Serialize(SwizzleOp& node); + + protected: + template void Container(T& container); + template void Enum(T& enumVal); + + virtual bool IsWriting() const = 0; + + virtual void Node(NodePtr& node) = 0; + template void Node(std::shared_ptr& node); + + virtual void Value(bool& val) = 0; + virtual void Value(float& val) = 0; + virtual void Value(std::string& val) = 0; + virtual void Value(Vector2f& val) = 0; + virtual void Value(Vector3f& val) = 0; + virtual void Value(Vector4f& val) = 0; + virtual void Value(UInt32& val) = 0; + inline void Value(std::size_t& val); + }; + + class NAZARA_RENDERER_API ShaderSerializer final : public ShaderSerializerBase + { + public: + inline ShaderSerializer(ByteArray& byteArray); + ~ShaderSerializer() = default; + + void Serialize(const StatementPtr& shader); + + private: + bool IsWriting() const override; + void Node(NodePtr& node) override; + void Value(bool& val) override; + void Value(float& val) override; + void Value(std::string& val) override; + void Value(Vector2f& val) override; + void Value(Vector3f& val) override; + void Value(Vector4f& val) override; + void Value(UInt32& val) override; + + ByteArray& m_byteArray; + ByteStream m_stream; + }; + + class NAZARA_RENDERER_API ShaderUnserializer final : public ShaderSerializerBase + { + public: + ShaderUnserializer(const ByteArray& byteArray); + ~ShaderUnserializer() = default; + + StatementPtr Unserialize(); + + private: + bool IsWriting() const override; + void Node(NodePtr & node) override; + void Value(bool& val) override; + void Value(float& val) override; + void Value(std::string& val) override; + void Value(Vector2f& val) override; + void Value(Vector3f& val) override; + void Value(Vector4f& val) override; + void Value(UInt32& val) override; + + const ByteArray& m_byteArray; + ByteStream m_stream; + }; + + NAZARA_RENDERER_API ByteArray Serialize(const StatementPtr& shader); + NAZARA_RENDERER_API StatementPtr Unserialize(const ByteArray& data); +} + +#include + +#endif diff --git a/include/Nazara/Renderer/ShaderSerializer.inl b/include/Nazara/Renderer/ShaderSerializer.inl new file mode 100644 index 000000000..2d8f5bc85 --- /dev/null +++ b/include/Nazara/Renderer/ShaderSerializer.inl @@ -0,0 +1,79 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz::ShaderAst +{ + template + void ShaderSerializerBase::Container(T& container) + { + bool isWriting = IsWriting(); + + UInt32 size; + if (isWriting) + size = UInt32(container.size()); + + Value(size); + if (!isWriting) + container.resize(size); + } + + + template + void ShaderSerializerBase::Enum(T& enumVal) + { + bool isWriting = IsWriting(); + + UInt32 value; + if (isWriting) + value = static_cast(enumVal); + + Value(value); + if (!isWriting) + enumVal = static_cast(value); + } + + template + inline void ShaderSerializerBase::Node(std::shared_ptr& node) + { + bool isWriting = IsWriting(); + + NodePtr value; + if (isWriting) + value = node; + + Node(value); + if (!isWriting) + node = std::static_pointer_cast(value); + } + + inline void ShaderSerializerBase::Value(std::size_t& val) + { + bool isWriting = IsWriting(); + + UInt32 value; + if (isWriting) + value = static_cast(val); + + Value(value); + if (!isWriting) + val = static_cast(value); + } + + inline ShaderSerializer::ShaderSerializer(ByteArray& byteArray) : + m_byteArray(byteArray), + m_stream(&m_byteArray, OpenModeFlags(OpenMode_WriteOnly)) + { + } + + inline ShaderUnserializer::ShaderUnserializer(const ByteArray& byteArray) : + m_byteArray(byteArray), + m_stream(const_cast(&m_byteArray), OpenModeFlags(OpenMode_ReadOnly)) + { + } +} + +#include diff --git a/include/Nazara/Renderer/ShaderVisitor.hpp b/include/Nazara/Renderer/ShaderVisitor.hpp new file mode 100644 index 000000000..47a5741f4 --- /dev/null +++ b/include/Nazara/Renderer/ShaderVisitor.hpp @@ -0,0 +1,50 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_SHADERVISITOR_HPP +#define NAZARA_SHADERVISITOR_HPP + +#include +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_RENDERER_API ShaderVisitor + { + public: + ShaderVisitor() = default; + ShaderVisitor(const ShaderVisitor&) = delete; + ShaderVisitor(ShaderVisitor&&) = delete; + virtual ~ShaderVisitor(); + + void EnableCondition(const String& name, bool cond); + + bool IsConditionEnabled(const String& name) const; + + virtual void Visit(const ShaderAst::AssignOp& node) = 0; + virtual void Visit(const ShaderAst::BinaryFunc& node) = 0; + virtual void Visit(const ShaderAst::BinaryOp& node) = 0; + virtual void Visit(const ShaderAst::Branch& node) = 0; + virtual void Visit(const ShaderAst::BuiltinVariable& node) = 0; + virtual void Visit(const ShaderAst::Cast& node) = 0; + virtual void Visit(const ShaderAst::Constant& node) = 0; + virtual void Visit(const ShaderAst::DeclareVariable& node) = 0; + virtual void Visit(const ShaderAst::ExpressionStatement& node) = 0; + virtual void Visit(const ShaderAst::NamedVariable& node) = 0; + void Visit(const ShaderAst::NodePtr& node); + virtual void Visit(const ShaderAst::Sample2D& node) = 0; + virtual void Visit(const ShaderAst::StatementBlock& node) = 0; + virtual void Visit(const ShaderAst::SwizzleOp& node) = 0; + + private: + std::unordered_set m_conditions; + }; +} + +#endif diff --git a/include/Nazara/Renderer/ShaderWriter.hpp b/include/Nazara/Renderer/ShaderWriter.hpp index 1058fa924..ae00f2fa5 100644 --- a/include/Nazara/Renderer/ShaderWriter.hpp +++ b/include/Nazara/Renderer/ShaderWriter.hpp @@ -10,45 +10,22 @@ #include #include #include -#include -#include +#include namespace Nz { - class NAZARA_RENDERER_API ShaderWriter + class NAZARA_RENDERER_API ShaderWriter : public ShaderVisitor { public: ShaderWriter() = default; ShaderWriter(const ShaderWriter&) = delete; ShaderWriter(ShaderWriter&&) = delete; - virtual ~ShaderWriter(); - - void EnableCondition(const String& name, bool cond); - - bool IsConditionEnabled(const String& name) const; + ~ShaderWriter() = default; virtual Nz::String Generate(const ShaderAst::StatementPtr& node) = 0; virtual void RegisterFunction(const String& name, ShaderAst::StatementPtr node, std::initializer_list parameters, ShaderAst::ExpressionType ret) = 0; virtual void RegisterVariable(ShaderAst::VariableType kind, const String& name, ShaderAst::ExpressionType type) = 0; - - virtual void Write(const ShaderAst::AssignOp& node) = 0; - virtual void Write(const ShaderAst::Branch& node) = 0; - virtual void Write(const ShaderAst::BinaryFunc& node) = 0; - virtual void Write(const ShaderAst::BinaryOp& node) = 0; - virtual void Write(const ShaderAst::BuiltinVariable& node) = 0; - virtual void Write(const ShaderAst::Cast& node) = 0; - virtual void Write(const ShaderAst::Constant& node) = 0; - virtual void Write(const ShaderAst::DeclareVariable& node) = 0; - virtual void Write(const ShaderAst::ExpressionStatement& node) = 0; - virtual void Write(const ShaderAst::NamedVariable& node) = 0; - virtual void Write(const ShaderAst::NodePtr& node) = 0; - virtual void Write(const ShaderAst::Sample2D& node) = 0; - virtual void Write(const ShaderAst::StatementBlock& node) = 0; - virtual void Write(const ShaderAst::SwizzleOp& node) = 0; - - private: - std::unordered_set m_conditions; }; } diff --git a/src/Nazara/Renderer/GlslWriter.cpp b/src/Nazara/Renderer/GlslWriter.cpp index b37b9deff..e7b8f6155 100644 --- a/src/Nazara/Renderer/GlslWriter.cpp +++ b/src/Nazara/Renderer/GlslWriter.cpp @@ -116,23 +116,18 @@ namespace Nz m_glslVersion = version; } - void GlslWriter::Write(const ShaderAst::NodePtr& node) - { - node->Visit(*this); - } - - void GlslWriter::Write(const ShaderAst::Sample2D& node) + void GlslWriter::Visit(const ShaderAst::Sample2D& node) { Append("texture("); - Write(node.sampler); + Visit(node.sampler); Append(", "); - Write(node.coordinates); + Visit(node.coordinates); Append(")"); } - void GlslWriter::Write(const ShaderAst::AssignOp& node) + void GlslWriter::Visit(const ShaderAst::AssignOp& node) { - Write(node.left); + Visit(node.left); switch (node.op) { @@ -141,10 +136,10 @@ namespace Nz break; } - Write(node.right); + Visit(node.right); } - void GlslWriter::Write(const ShaderAst::Branch& node) + void GlslWriter::Visit(const ShaderAst::Branch& node) { bool first = true; for (const auto& statement : node.condStatements) @@ -153,11 +148,11 @@ namespace Nz Append("else "); Append("if ("); - Write(statement.condition); + Visit(statement.condition); AppendLine(")"); EnterScope(); - Write(statement.statement); + Visit(statement.statement); LeaveScope(); first = false; @@ -168,12 +163,12 @@ namespace Nz AppendLine("else"); EnterScope(); - Write(node.elseStatement); + Visit(node.elseStatement); LeaveScope(); } } - void GlslWriter::Write(const ShaderAst::BinaryFunc& node) + void GlslWriter::Visit(const ShaderAst::BinaryFunc& node) { switch (node.intrinsic) { @@ -187,15 +182,15 @@ namespace Nz } Append("("); - Write(node.left); + Visit(node.left); Append(", "); - Write(node.right); + Visit(node.right); Append(")"); } - void GlslWriter::Write(const ShaderAst::BinaryOp& node) + void GlslWriter::Visit(const ShaderAst::BinaryOp& node) { - Write(node.left); + Visit(node.left); switch (node.op) { @@ -216,15 +211,15 @@ namespace Nz break; } - Write(node.right); + Visit(node.right); } - void GlslWriter::Write(const ShaderAst::BuiltinVariable& node) + void GlslWriter::Visit(const ShaderAst::BuiltinVariable& node) { Append(node.var); } - void GlslWriter::Write(const ShaderAst::Cast& node) + void GlslWriter::Visit(const ShaderAst::Cast& node) { Append(node.exprType); Append("("); @@ -239,14 +234,14 @@ namespace Nz const auto& exprPtr = node.expressions[i++]; NazaraAssert(exprPtr, "Invalid expression"); - Write(exprPtr); + Visit(exprPtr); requiredComponents -= ShaderAst::Node::GetComponentCount(exprPtr->GetExpressionType()); } Append(")"); } - void GlslWriter::Write(const ShaderAst::Constant& node) + void GlslWriter::Visit(const ShaderAst::Constant& node) { switch (node.exprType) { @@ -275,7 +270,7 @@ namespace Nz } } - void GlslWriter::Write(const ShaderAst::DeclareVariable& node) + void GlslWriter::Visit(const ShaderAst::DeclareVariable& node) { Append(node.variable->GetExpressionType()); Append(" "); @@ -285,24 +280,24 @@ namespace Nz Append(" "); Append("="); Append(" "); - Write(node.expression); + Visit(node.expression); } AppendLine(";"); } - void GlslWriter::Write(const ShaderAst::ExpressionStatement& node) + void GlslWriter::Visit(const ShaderAst::ExpressionStatement& node) { - Write(node.expression); + Visit(node.expression); Append(";"); } - void GlslWriter::Write(const ShaderAst::NamedVariable& node) + void GlslWriter::Visit(const ShaderAst::NamedVariable& node) { Append(node.name); } - void GlslWriter::Write(const ShaderAst::StatementBlock& node) + void GlslWriter::Visit(const ShaderAst::StatementBlock& node) { bool first = true; for (const ShaderAst::StatementPtr& statement : node.statements) @@ -310,15 +305,15 @@ namespace Nz if (!first) AppendLine(); - Write(statement); + Visit(statement); first = false; } } - void GlslWriter::Write(const ShaderAst::SwizzleOp& node) + void GlslWriter::Visit(const ShaderAst::SwizzleOp& node) { - Write(node.expression); + Visit(node.expression); Append("."); for (std::size_t i = 0; i < node.componentCount; ++i) @@ -433,7 +428,7 @@ namespace Nz EnterScope(); { - Write(func.node); + Visit(func.node); } LeaveScope(); } diff --git a/src/Nazara/Renderer/Renderer.cpp b/src/Nazara/Renderer/Renderer.cpp index 6954f5cf0..9df137326 100644 --- a/src/Nazara/Renderer/Renderer.cpp +++ b/src/Nazara/Renderer/Renderer.cpp @@ -69,7 +69,7 @@ namespace Nz }; RegisterImpl("NazaraOpenGLRenderer" NazaraRendererDebugSuffix, [] { return 50; }); - RegisterImpl("NazaraVulkanRenderer" NazaraRendererDebugSuffix, [] { return 100; }); + //RegisterImpl("NazaraVulkanRenderer" NazaraRendererDebugSuffix, [] { return 100; }); std::sort(implementations.begin(), implementations.end(), [](const auto& lhs, const auto& rhs) { return lhs.score > rhs.score; }); diff --git a/src/Nazara/Renderer/ShaderAst.cpp b/src/Nazara/Renderer/ShaderAst.cpp index 0a2373d17..d60ebab6a 100644 --- a/src/Nazara/Renderer/ShaderAst.cpp +++ b/src/Nazara/Renderer/ShaderAst.cpp @@ -3,11 +3,15 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include +#include #include #include namespace Nz::ShaderAst { + Node::~Node() = default; + ExpressionCategory Expression::GetExpressionCategory() const { return ExpressionCategory::RValue; @@ -18,9 +22,9 @@ namespace Nz::ShaderAst expression->Register(visitor); } - void ExpressionStatement::Visit(ShaderWriter& visitor) + void ExpressionStatement::Visit(ShaderVisitor& visitor) { - visitor.Write(*this); + visitor.Visit(*this); } @@ -30,7 +34,7 @@ namespace Nz::ShaderAst statement->Register(visitor); } - void ConditionalStatement::Visit(ShaderWriter& visitor) + void ConditionalStatement::Visit(ShaderVisitor& visitor) { if (visitor.IsConditionEnabled(conditionName)) statement->Visit(visitor); @@ -43,9 +47,9 @@ namespace Nz::ShaderAst statementPtr->Register(visitor); } - void StatementBlock::Visit(ShaderWriter& visitor) + void StatementBlock::Visit(ShaderVisitor& visitor) { - visitor.Write(*this); + visitor.Visit(*this); } ExpressionCategory Variable::GetExpressionCategory() const @@ -58,14 +62,25 @@ namespace Nz::ShaderAst return type; } + + void BuiltinVariable::Register(ShaderWriter& /*visitor*/) + { + } + + void BuiltinVariable::Visit(ShaderVisitor& visitor) + { + visitor.Visit(*this); + } + + void NamedVariable::Register(ShaderWriter& visitor) { visitor.RegisterVariable(kind, name, type); } - void NamedVariable::Visit(ShaderWriter& visitor) + void NamedVariable::Visit(ShaderVisitor& visitor) { - visitor.Write(*this); + visitor.Visit(*this); } @@ -77,18 +92,9 @@ namespace Nz::ShaderAst expression->Register(visitor); } - void DeclareVariable::Visit(ShaderWriter& visitor) + void DeclareVariable::Visit(ShaderVisitor& visitor) { - visitor.Write(*this); - } - - void BuiltinVariable::Register(ShaderWriter& /*visitor*/) - { - } - - void BuiltinVariable::Visit(ShaderWriter& visitor) - { - visitor.Write(*this); + visitor.Visit(*this); } @@ -103,9 +109,9 @@ namespace Nz::ShaderAst right->Register(visitor); } - void AssignOp::Visit(ShaderWriter& visitor) + void AssignOp::Visit(ShaderVisitor& visitor) { - visitor.Write(*this); + visitor.Visit(*this); } @@ -138,9 +144,9 @@ namespace Nz::ShaderAst right->Register(visitor); } - void BinaryOp::Visit(ShaderWriter& visitor) + void BinaryOp::Visit(ShaderVisitor& visitor) { - visitor.Write(*this); + visitor.Visit(*this); } @@ -156,9 +162,9 @@ namespace Nz::ShaderAst elseStatement->Register(visitor); } - void Branch::Visit(ShaderWriter& visitor) + void Branch::Visit(ShaderVisitor& visitor) { - visitor.Write(*this); + visitor.Visit(*this); } @@ -171,9 +177,9 @@ namespace Nz::ShaderAst { } - void Constant::Visit(ShaderWriter& visitor) + void Constant::Visit(ShaderVisitor& visitor) { - visitor.Write(*this); + visitor.Visit(*this); } ExpressionType Cast::GetExpressionType() const @@ -195,26 +201,9 @@ namespace Nz::ShaderAst } } - void Cast::Visit(ShaderWriter& visitor) + void Cast::Visit(ShaderVisitor& visitor) { - visitor.Write(*this); - } - - void Cast::Validate() const - { - unsigned int componentCount = 0; - unsigned int requiredComponents = GetComponentCount(exprType); - for (const auto& exprPtr : expressions) - { - if (!exprPtr) - break; - - componentCount += GetComponentCount(exprPtr->GetExpressionType()); - } - - //TODO: AstParseError - if (componentCount != requiredComponents) - throw std::runtime_error("Component count doesn't match required component count"); + visitor.Visit(*this); } @@ -233,9 +222,9 @@ namespace Nz::ShaderAst expression->Register(visitor); } - void SwizzleOp::Visit(ShaderWriter& visitor) + void SwizzleOp::Visit(ShaderVisitor& visitor) { - visitor.Write(*this); + visitor.Visit(*this); } @@ -250,9 +239,9 @@ namespace Nz::ShaderAst coordinates->Register(visitor); } - void Sample2D::Visit(ShaderWriter& visitor) + void Sample2D::Visit(ShaderVisitor& visitor) { - visitor.Write(*this); + visitor.Visit(*this); } @@ -277,8 +266,8 @@ namespace Nz::ShaderAst right->Register(visitor); } - void BinaryFunc::Visit(ShaderWriter& visitor) + void BinaryFunc::Visit(ShaderVisitor& visitor) { - visitor.Write(*this); + visitor.Visit(*this); } } diff --git a/src/Nazara/Renderer/ShaderSerializer.cpp b/src/Nazara/Renderer/ShaderSerializer.cpp new file mode 100644 index 000000000..6e6e3e8ff --- /dev/null +++ b/src/Nazara/Renderer/ShaderSerializer.cpp @@ -0,0 +1,376 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz::ShaderAst +{ + namespace + { + class ShaderSerializerVisitor : public ShaderVisitor + { + public: + ShaderSerializerVisitor(ShaderSerializerBase& serializer) : + m_serializer(serializer) + { + } + + void Visit(const AssignOp& node) override + { + Serialize(node); + } + + void Visit(const BinaryFunc& node) override + { + Serialize(node); + } + + void Visit(const BinaryOp& node) override + { + Serialize(node); + } + + void Visit(const Branch& node) override + { + Serialize(node); + } + + void Visit(const BuiltinVariable& node) override + { + Serialize(node); + } + + void Visit(const Cast& node) override + { + Serialize(node); + } + + void Visit(const Constant& node) override + { + Serialize(node); + } + + void Visit(const DeclareVariable& node) override + { + Serialize(node); + } + + void Visit(const ExpressionStatement& node) override + { + Serialize(node); + } + + void Visit(const NamedVariable& node) override + { + Serialize(node); + } + + void Visit(const Sample2D& node) override + { + Serialize(node); + } + + void Visit(const StatementBlock& node) override + { + Serialize(node); + } + + void Visit(const SwizzleOp& node) override + { + Serialize(node); + } + + private: + template + void Serialize(const T& node) + { + // I know const_cast is evil but I don't have a better solution here (it's not used to write) + m_serializer.Serialize(const_cast(node)); + } + + ShaderSerializerBase& m_serializer; + }; + } + + void ShaderSerializerBase::Serialize(AssignOp& node) + { + Enum(node.op); + Node(node.left); + Node(node.right); + } + + void ShaderSerializerBase::Serialize(BinaryFunc& node) + { + Enum(node.intrinsic); + Node(node.left); + Node(node.right); + } + + void ShaderSerializerBase::Serialize(BinaryOp& node) + { + Enum(node.op); + Node(node.left); + Node(node.right); + } + + void ShaderSerializerBase::Serialize(Branch& node) + { + Container(node.condStatements); + for (auto& condStatement : node.condStatements) + { + Node(condStatement.condition); + Node(condStatement.statement); + } + + Node(node.elseStatement); + } + + void ShaderSerializerBase::Serialize(BuiltinVariable& node) + { + Enum(node.var); + Enum(node.type); + } + + void ShaderSerializerBase::Serialize(Cast& node) + { + Enum(node.exprType); + for (auto& expr : node.expressions) + Node(expr); + } + + void ShaderSerializerBase::Serialize(Constant& node) + { + Enum(node.exprType); + + switch (node.exprType) + { + case ExpressionType::Boolean: + Value(node.values.bool1); + break; + + case ExpressionType::Float1: + Value(node.values.vec1); + break; + + case ExpressionType::Float2: + Value(node.values.vec2); + break; + + case ExpressionType::Float3: + Value(node.values.vec3); + break; + + case ExpressionType::Float4: + Value(node.values.vec4); + break; + } + } + + void ShaderSerializerBase::Serialize(DeclareVariable& node) + { + Node(node.variable); + Node(node.expression); + } + + void ShaderSerializerBase::Serialize(ExpressionStatement& node) + { + Node(node.expression); + } + + void ShaderSerializerBase::Serialize(NamedVariable& node) + { + Value(node.name); + Enum(node.kind); + Enum(node.type); + } + + void ShaderSerializerBase::Serialize(Sample2D& node) + { + Node(node.sampler); + Node(node.coordinates); + } + + void ShaderSerializerBase::Serialize(StatementBlock& node) + { + Container(node.statements); + for (auto& statement : node.statements) + Node(statement); + } + + void ShaderSerializerBase::Serialize(SwizzleOp& node) + { + Value(node.componentCount); + Node(node.expression); + + for (std::size_t i = 0; i < node.componentCount; ++i) + Enum(node.components[i]); + } + + + void ShaderSerializer::Serialize(const StatementPtr& shader) + { + assert(shader); + m_stream << static_cast(shader->GetType()); + + ShaderSerializerVisitor visitor(*this); + shader->Visit(visitor); + + m_stream.FlushBits(); + } + + bool ShaderSerializer::IsWriting() const + { + return true; + } + + void ShaderSerializer::Node(NodePtr& node) + { + NodeType nodeType = (node) ? node->GetType() : NodeType::None; + m_stream << static_cast(nodeType); + + if (node) + { + ShaderSerializerVisitor visitor(*this); + node->Visit(visitor); + } + } + + void ShaderSerializer::Value(bool& val) + { + m_stream << val; + } + + void ShaderSerializer::Value(float& val) + { + m_stream << val; + } + + void ShaderSerializer::Value(std::string& val) + { + m_stream << val; + } + + void ShaderSerializer::Value(Vector2f& val) + { + m_stream << val; + } + + void ShaderSerializer::Value(Vector3f& val) + { + m_stream << val; + } + + void ShaderSerializer::Value(Vector4f& val) + { + m_stream << val; + } + + void ShaderSerializer::Value(UInt32& val) + { + m_stream << val; + } + + ByteArray Serialize(const StatementPtr& shader) + { + ByteArray byteArray; + ShaderSerializer serializer(byteArray); + serializer.Serialize(shader); + + return byteArray; + } + + StatementPtr Unserialize(const ByteArray& data) + { + ShaderUnserializer unserializer(data); + return unserializer.Unserialize(); + } + + StatementPtr ShaderUnserializer::Unserialize() + { + NodePtr statement; + Node(statement); + if (!statement || statement->GetType() != NodeType::StatementBlock) + throw std::runtime_error("Invalid shader"); + + return std::static_pointer_cast(statement); + } + + bool ShaderUnserializer::IsWriting() const + { + return false; + } + + void ShaderUnserializer::Node(NodePtr& node) + { + Int32 nodeTypeInt; + m_stream >> nodeTypeInt; + + NodeType nodeType = static_cast(nodeTypeInt); + +#define HandleNodeType(Type) case NodeType:: Type : node = std::make_shared(); break + switch (nodeType) + { + case NodeType::None: break; + + HandleNodeType(AssignOp); + HandleNodeType(BinaryFunc); + HandleNodeType(BinaryOp); + HandleNodeType(Branch); + HandleNodeType(BuiltinVariable); + HandleNodeType(Cast); + HandleNodeType(Constant); + HandleNodeType(ConditionalStatement); + HandleNodeType(DeclareVariable); + HandleNodeType(ExpressionStatement); + HandleNodeType(NamedVariable); + HandleNodeType(Sample2D); + HandleNodeType(SwizzleOp); + HandleNodeType(StatementBlock); + } +#undef HandleNodeType + + if (node) + { + ShaderSerializerVisitor visitor(*this); + node->Visit(visitor); + } + } + + void ShaderUnserializer::Value(bool& val) + { + m_stream >> val; + } + + void ShaderUnserializer::Value(float& val) + { + m_stream >> val; + } + + void ShaderUnserializer::Value(std::string& val) + { + m_stream >> val; + } + + void ShaderUnserializer::Value(Vector2f& val) + { + m_stream >> val; + } + + void ShaderUnserializer::Value(Vector3f& val) + { + m_stream >> val; + } + + void ShaderUnserializer::Value(Vector4f& val) + { + m_stream >> val; + } + + void ShaderUnserializer::Value(UInt32& val) + { + m_stream >> val; + } +} + diff --git a/src/Nazara/Renderer/ShaderVisitor.cpp b/src/Nazara/Renderer/ShaderVisitor.cpp new file mode 100644 index 000000000..2b5a590bd --- /dev/null +++ b/src/Nazara/Renderer/ShaderVisitor.cpp @@ -0,0 +1,29 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + ShaderVisitor::~ShaderVisitor() = default; + + void ShaderVisitor::EnableCondition(const String& name, bool cond) + { + if (cond) + m_conditions.insert(name); + else + m_conditions.erase(name); + } + + bool ShaderVisitor::IsConditionEnabled(const String& name) const + { + return m_conditions.count(name) != 0; + } + + void ShaderVisitor::Visit(const ShaderAst::NodePtr& node) + { + node->Visit(*this); + } +} diff --git a/src/Nazara/Renderer/ShaderWriter.cpp b/src/Nazara/Renderer/ShaderWriter.cpp index c862572ab..982251556 100644 --- a/src/Nazara/Renderer/ShaderWriter.cpp +++ b/src/Nazara/Renderer/ShaderWriter.cpp @@ -7,18 +7,4 @@ namespace Nz { - ShaderWriter::~ShaderWriter() = default; - - void ShaderWriter::EnableCondition(const String& name, bool cond) - { - if (cond) - m_conditions.insert(name); - else - m_conditions.erase(name); - } - - bool ShaderWriter::IsConditionEnabled(const String & name) const - { - return m_conditions.count(name) != 0; - } } diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp index 6fc2fe6aa..01b5c6cf9 100644 --- a/src/ShaderNode/ShaderGraph.cpp +++ b/src/ShaderNode/ShaderGraph.cpp @@ -352,7 +352,7 @@ Nz::ShaderAst::StatementPtr ShaderGraph::ToAst() } }); - return std::make_shared(std::move(statements)); + return Nz::ShaderAst::StatementBlock::Build(std::move(statements)); } void ShaderGraph::UpdateInput(std::size_t inputIndex, std::string name, InOutType type, InputRole role, std::size_t roleIndex) From 2258a4f87f27ce98f0719234c4474023f5d263bb Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 6 Jun 2020 16:44:17 +0200 Subject: [PATCH 238/316] Add ShaderValidator --- include/Nazara/Renderer/ShaderValidator.hpp | 54 +++++ include/Nazara/Renderer/ShaderValidator.inl | 12 + src/Nazara/Renderer/GlslWriter.cpp | 6 + src/Nazara/Renderer/ShaderValidator.cpp | 234 ++++++++++++++++++++ 4 files changed, 306 insertions(+) create mode 100644 include/Nazara/Renderer/ShaderValidator.hpp create mode 100644 include/Nazara/Renderer/ShaderValidator.inl create mode 100644 src/Nazara/Renderer/ShaderValidator.cpp diff --git a/include/Nazara/Renderer/ShaderValidator.hpp b/include/Nazara/Renderer/ShaderValidator.hpp new file mode 100644 index 000000000..50075aaf0 --- /dev/null +++ b/include/Nazara/Renderer/ShaderValidator.hpp @@ -0,0 +1,54 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_SHADERVALIDATOR_HPP +#define NAZARA_SHADERVALIDATOR_HPP + +#include +#include +#include +#include +#include + +namespace Nz::ShaderAst +{ + class NAZARA_RENDERER_API ShaderValidator : public ShaderVisitor + { + public: + ShaderValidator() = default; + ShaderValidator(const ShaderValidator&) = delete; + ShaderValidator(ShaderValidator&&) = delete; + ~ShaderValidator() = default; + + bool Validate(const StatementPtr& shader, std::string* error = nullptr); + + private: + const ExpressionPtr& MandatoryExpr(const ExpressionPtr& node); + const NodePtr& MandatoryNode(const NodePtr& node); + void TypeMustMatch(const ExpressionPtr& left, const ExpressionPtr& right); + + using ShaderVisitor::Visit; + void Visit(const AssignOp& node) override; + void Visit(const BinaryFunc& node) override; + void Visit(const BinaryOp& node) override; + void Visit(const Branch& node) override; + void Visit(const BuiltinVariable& node) override; + void Visit(const Cast& node) override; + void Visit(const Constant& node) override; + void Visit(const DeclareVariable& node) override; + void Visit(const ExpressionStatement& node) override; + void Visit(const NamedVariable& node) override; + void Visit(const Sample2D& node) override; + void Visit(const StatementBlock& node) override; + void Visit(const SwizzleOp& node) override; + }; + + NAZARA_RENDERER_API bool Validate(const StatementPtr& shader, std::string* error = nullptr); +} + +#include + +#endif diff --git a/include/Nazara/Renderer/ShaderValidator.inl b/include/Nazara/Renderer/ShaderValidator.inl new file mode 100644 index 000000000..2fb43d576 --- /dev/null +++ b/include/Nazara/Renderer/ShaderValidator.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz::ShaderAst +{ +} + +#include diff --git a/src/Nazara/Renderer/GlslWriter.cpp b/src/Nazara/Renderer/GlslWriter.cpp index e7b8f6155..b982dab90 100644 --- a/src/Nazara/Renderer/GlslWriter.cpp +++ b/src/Nazara/Renderer/GlslWriter.cpp @@ -4,6 +4,8 @@ #include #include +#include +#include #include namespace Nz @@ -17,6 +19,10 @@ namespace Nz String GlslWriter::Generate(const ShaderAst::StatementPtr& node) { + std::string error; + if (!ShaderAst::Validate(node, &error)) + throw std::runtime_error("Invalid shader AST: " + error); + State state; m_currentState = &state; CallOnExit onExit([this]() diff --git a/src/Nazara/Renderer/ShaderValidator.cpp b/src/Nazara/Renderer/ShaderValidator.cpp new file mode 100644 index 000000000..2a4d38f25 --- /dev/null +++ b/src/Nazara/Renderer/ShaderValidator.cpp @@ -0,0 +1,234 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz::ShaderAst +{ + struct AstError + { + std::string errMsg; + }; + + bool ShaderValidator::Validate(const StatementPtr& shader, std::string* error) + { + try + { + shader->Visit(*this); + return true; + } + catch (const AstError& e) + { + if (error) + *error = e.errMsg; + + return false; + } + } + + const ExpressionPtr& ShaderValidator::MandatoryExpr(const ExpressionPtr& node) + { + MandatoryNode(node); + + return node; + } + + const NodePtr& ShaderValidator::MandatoryNode(const NodePtr& node) + { + if (!node) + throw AstError{ "Invalid node" }; + + return node; + } + + void ShaderValidator::TypeMustMatch(const ExpressionPtr& left, const ExpressionPtr& right) + { + if (left->GetExpressionType() != right->GetExpressionType()) + throw AstError{ "Left expression type must match right expression type" }; + } + + void ShaderValidator::Visit(const AssignOp& node) + { + MandatoryNode(node.left); + MandatoryNode(node.right); + TypeMustMatch(node.left, node.right); + + Visit(node.left); + Visit(node.right); + } + + void ShaderValidator::Visit(const BinaryFunc& node) + { + MandatoryNode(node.left); + MandatoryNode(node.right); + TypeMustMatch(node.left, node.right); + + switch (node.intrinsic) + { + case BinaryIntrinsic::CrossProduct: + { + if (node.left->GetExpressionType() != ExpressionType::Float3) + throw AstError{ "CrossProduct only works with Float3 expressions" }; + } + + case BinaryIntrinsic::DotProduct: + break; + } + + Visit(node.left); + Visit(node.right); + } + + void ShaderValidator::Visit(const BinaryOp& node) + { + MandatoryNode(node.left); + MandatoryNode(node.right); + + ExpressionType leftType = node.left->GetExpressionType(); + ExpressionType rightType = node.right->GetExpressionType(); + + switch (node.op) + { + case BinaryType::Add: + case BinaryType::Equality: + case BinaryType::Substract: + TypeMustMatch(node.left, node.right); + break; + + case BinaryType::Multiply: + case BinaryType::Divide: + { + switch (leftType) + { + case ExpressionType::Float2: + case ExpressionType::Float3: + case ExpressionType::Float4: + { + if (leftType != rightType && rightType != ExpressionType::Float1) + throw AstError{ "Left expression type is not compatible with right expression type" }; + + break; + } + + case ExpressionType::Mat4x4: + { + switch (rightType) + { + case ExpressionType::Float1: + case ExpressionType::Float4: + case ExpressionType::Mat4x4: + break; + + default: + TypeMustMatch(node.left, node.right); + } + + break; + } + + default: + TypeMustMatch(node.left, node.right); + } + } + } + + Visit(node.left); + Visit(node.right); + } + + void ShaderValidator::Visit(const Branch& node) + { + for (const auto& condStatement : node.condStatements) + { + Visit(MandatoryNode(condStatement.condition)); + Visit(MandatoryNode(condStatement.statement)); + } + } + + void ShaderValidator::Visit(const BuiltinVariable& /*node*/) + { + } + + void ShaderValidator::Visit(const Cast& node) + { + unsigned int componentCount = 0; + unsigned int requiredComponents = node.GetComponentCount(node.exprType); + for (const auto& exprPtr : node.expressions) + { + if (!exprPtr) + break; + + componentCount += node.GetComponentCount(exprPtr->GetExpressionType()); + Visit(exprPtr); + } + + if (componentCount != requiredComponents) + throw AstError{ "Component count doesn't match required component count" }; + } + + void ShaderValidator::Visit(const Constant& /*node*/) + { + } + + void ShaderValidator::Visit(const DeclareVariable& node) + { + Visit(MandatoryNode(node.expression)); + } + + void ShaderValidator::Visit(const ExpressionStatement& node) + { + Visit(MandatoryNode(node.expression)); + } + + void ShaderValidator::Visit(const NamedVariable& node) + { + if (node.name.empty()) + throw AstError{ "Variable has empty name" }; + } + + void ShaderValidator::Visit(const Sample2D& node) + { + if (MandatoryExpr(node.sampler)->GetExpressionType() != ExpressionType::Sampler2D) + throw AstError{ "Sampler must be a Sampler2D" }; + + if (MandatoryExpr(node.coordinates)->GetExpressionType() != ExpressionType::Float2) + throw AstError{ "Coordinates must be a Float2" }; + + Visit(node.sampler); + Visit(node.coordinates); + } + + void ShaderValidator::Visit(const StatementBlock& node) + { + for (const auto& statement : node.statements) + Visit(MandatoryNode(statement)); + } + + void ShaderValidator::Visit(const SwizzleOp& node) + { + if (node.componentCount > 4) + throw AstError{ "Cannot swizzle more than four elements" }; + + switch (MandatoryExpr(node.expression)->GetExpressionType()) + { + case ExpressionType::Float1: + case ExpressionType::Float2: + case ExpressionType::Float3: + case ExpressionType::Float4: + break; + + default: + throw AstError{ "Cannot swizzle this type" }; + } + + Visit(node.expression); + } + + bool Validate(const StatementPtr& shader, std::string* error) + { + ShaderValidator validator; + return validator.Validate(shader, error); + } +} From 90abb52e4e97cc3402cf11f5e2169bae9a382eef Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 16 Jun 2020 17:44:20 +0200 Subject: [PATCH 239/316] ShaderEditor: Fixes --- src/ShaderNode/DataModels/Cast.hpp | 3 +++ src/ShaderNode/DataModels/Cast.inl | 29 +++++++++++++++++++++- src/ShaderNode/DataModels/FloatValue.cpp | 1 + src/ShaderNode/DataModels/InputValue.cpp | 25 +++++++++++++++---- src/ShaderNode/DataModels/InputValue.hpp | 1 + src/ShaderNode/DataModels/OutputValue.cpp | 27 ++++++++++++++------ src/ShaderNode/DataModels/OutputValue.hpp | 1 + src/ShaderNode/DataModels/TextureValue.cpp | 26 ++++++++++++++----- src/ShaderNode/DataModels/TextureValue.hpp | 1 + src/ShaderNode/DataModels/VecValue.inl | 7 ++++-- src/ShaderNode/Previews/QuadPreview.cpp | 8 ++++-- 11 files changed, 106 insertions(+), 23 deletions(-) diff --git a/src/ShaderNode/DataModels/Cast.hpp b/src/ShaderNode/DataModels/Cast.hpp index 90dad931e..bb287555c 100644 --- a/src/ShaderNode/DataModels/Cast.hpp +++ b/src/ShaderNode/DataModels/Cast.hpp @@ -38,6 +38,9 @@ class CastVec : public ShaderNode bool ComputePreview(QPixmap& pixmap) override; void UpdateOutput(); + void restore(const QJsonObject& data) override; + QJsonObject save() const override; + std::shared_ptr m_input; std::shared_ptr m_output; VecType m_overflowComponents; diff --git a/src/ShaderNode/DataModels/Cast.inl b/src/ShaderNode/DataModels/Cast.inl index f8870201a..1a304c2c7 100644 --- a/src/ShaderNode/DataModels/Cast.inl +++ b/src/ShaderNode/DataModels/Cast.inl @@ -34,6 +34,7 @@ void CastVec::BuildNodeEdition(QFormLayout* layout) { QDoubleSpinBox* spinbox = new QDoubleSpinBox; spinbox->setDecimals(6); + spinbox->setRange(std::numeric_limits::lowest(), std::numeric_limits::max()); spinbox->setValue(m_overflowComponents[i]); connect(spinbox, qOverload(&QDoubleSpinBox::valueChanged), [=](double) @@ -66,7 +67,7 @@ Nz::ShaderAst::ExpressionPtr CastVec::GetExpression(Nz::Shader constexpr auto ExpressionType = VecExpressionType; - return Nz::ShaderBuilder::Cast(expr.data(), overflowComponentCount); + return Nz::ShaderBuilder::Cast(expr.data(), 1 + overflowComponentCount); } else if (ToComponentCount < fromComponentCount) { @@ -232,3 +233,29 @@ void CastVec::UpdateOutput() UpdatePreview(); } + +template +void CastVec::restore(const QJsonObject& data) +{ + QJsonArray vecValues = data["value"].toArray(); + std::size_t commonValues = std::min(static_cast(vecValues.size()), ToComponentCount); + + for (std::size_t i = 0; i < commonValues; ++i) + m_overflowComponents[i] = float(vecValues[int(i)].toDouble(m_overflowComponents[i])); + + ShaderNode::restore(data); +} + +template +QJsonObject CastVec::save() const +{ + QJsonObject data = ShaderNode::save(); + + QJsonArray vecValues; + for (std::size_t i = 0; i < ToComponentCount; ++i) + vecValues.push_back(m_overflowComponents[i]); + + data["value"] = vecValues; + + return data; +} diff --git a/src/ShaderNode/DataModels/FloatValue.cpp b/src/ShaderNode/DataModels/FloatValue.cpp index 23d5a30d3..3da83982e 100644 --- a/src/ShaderNode/DataModels/FloatValue.cpp +++ b/src/ShaderNode/DataModels/FloatValue.cpp @@ -57,6 +57,7 @@ void FloatValue::BuildNodeEdition(QFormLayout* layout) QDoubleSpinBox* spinbox = new QDoubleSpinBox; spinbox->setDecimals(6); + spinbox->setRange(std::numeric_limits::lowest(), std::numeric_limits::max()); spinbox->setValue(m_value); connect(spinbox, qOverload(&QDoubleSpinBox::valueChanged), [=](double) diff --git a/src/ShaderNode/DataModels/InputValue.cpp b/src/ShaderNode/DataModels/InputValue.cpp index 3f8d2fbdc..92d08ba3e 100644 --- a/src/ShaderNode/DataModels/InputValue.cpp +++ b/src/ShaderNode/DataModels/InputValue.cpp @@ -20,9 +20,8 @@ ShaderNode(graph) if (graph.GetInputCount() > 0) { - auto& firstInput = graph.GetInput(0); m_currentInputIndex = 0; - m_currentInputText = firstInput.name; + UpdateInputText(); } DisableCustomVariableName(); @@ -70,11 +69,27 @@ void InputValue::OnInputListUpdate() } } +void InputValue::UpdateInputText() +{ + if (m_currentInputIndex) + { + auto& input = GetGraph().GetInput(*m_currentInputIndex); + m_currentInputText = input.name; + } + else + m_currentInputText.clear(); +} + void InputValue::BuildNodeEdition(QFormLayout* layout) { ShaderNode::BuildNodeEdition(layout); QComboBox* inputSelection = new QComboBox; + for (const auto& inputEntry : GetGraph().GetInputs()) + inputSelection->addItem(QString::fromStdString(inputEntry.name)); + + if (m_currentInputIndex) + inputSelection->setCurrentIndex(int(*m_currentInputIndex)); connect(inputSelection, qOverload(&QComboBox::currentIndexChanged), [&](int index) { @@ -83,11 +98,11 @@ void InputValue::BuildNodeEdition(QFormLayout* layout) else m_currentInputIndex.reset(); + UpdateInputText(); UpdatePreview(); - }); - for (const auto& inputEntry : GetGraph().GetInputs()) - inputSelection->addItem(QString::fromStdString(inputEntry.name)); + Q_EMIT dataUpdated(0); + }); layout->addRow(tr("Input"), inputSelection); } diff --git a/src/ShaderNode/DataModels/InputValue.hpp b/src/ShaderNode/DataModels/InputValue.hpp index 681a85e8d..a5eaabf01 100644 --- a/src/ShaderNode/DataModels/InputValue.hpp +++ b/src/ShaderNode/DataModels/InputValue.hpp @@ -36,6 +36,7 @@ class InputValue : public ShaderNode private: bool ComputePreview(QPixmap& pixmap) override; void OnInputListUpdate(); + void UpdateInputText(); void restore(const QJsonObject& data) override; QJsonObject save() const override; diff --git a/src/ShaderNode/DataModels/OutputValue.cpp b/src/ShaderNode/DataModels/OutputValue.cpp index 538884706..09d7aff78 100644 --- a/src/ShaderNode/DataModels/OutputValue.cpp +++ b/src/ShaderNode/DataModels/OutputValue.cpp @@ -17,9 +17,8 @@ ShaderNode(graph) if (graph.GetOutputCount() > 0) { - auto& firstOutput = graph.GetOutput(0); m_currentOutputIndex = 0; - m_currentOutputText = firstOutput.name; + UpdateOutputText(); } EnablePreview(); @@ -32,7 +31,12 @@ void OutputValue::BuildNodeEdition(QFormLayout* layout) ShaderNode::BuildNodeEdition(layout); QComboBox* outputSelection = new QComboBox; + for (const auto& outputEntry : GetGraph().GetOutputs()) + outputSelection->addItem(QString::fromStdString(outputEntry.name)); + if (m_currentOutputIndex) + outputSelection->setCurrentIndex(int(*m_currentOutputIndex)); + connect(outputSelection, qOverload(&QComboBox::currentIndexChanged), [&](int index) { if (index >= 0) @@ -40,12 +44,10 @@ void OutputValue::BuildNodeEdition(QFormLayout* layout) else m_currentOutputIndex.reset(); + UpdateOutputText(); UpdatePreview(); }); - for (const auto& outputEntry : GetGraph().GetOutputs()) - outputSelection->addItem(QString::fromStdString(outputEntry.name)); - layout->addRow(tr("Output"), outputSelection); } @@ -189,9 +191,20 @@ void OutputValue::OnOutputListUpdate() } } +void OutputValue::UpdateOutputText() +{ + if (m_currentOutputIndex) + { + auto& output = GetGraph().GetOutput(*m_currentOutputIndex); + m_currentOutputText = output.name; + } + else + m_currentOutputText.clear(); +} + void OutputValue::restore(const QJsonObject& data) { - m_currentOutputText = data["input"].toString().toStdString(); + m_currentOutputText = data["output"].toString().toStdString(); OnOutputListUpdate(); ShaderNode::restore(data); @@ -200,7 +213,7 @@ void OutputValue::restore(const QJsonObject& data) QJsonObject OutputValue::save() const { QJsonObject data = ShaderNode::save(); - data["input"] = QString::fromStdString(m_currentOutputText); + data["output"] = QString::fromStdString(m_currentOutputText); return data; } diff --git a/src/ShaderNode/DataModels/OutputValue.hpp b/src/ShaderNode/DataModels/OutputValue.hpp index 4cc523b66..320b2bacb 100644 --- a/src/ShaderNode/DataModels/OutputValue.hpp +++ b/src/ShaderNode/DataModels/OutputValue.hpp @@ -35,6 +35,7 @@ class OutputValue : public ShaderNode private: bool ComputePreview(QPixmap& pixmap) override; void OnOutputListUpdate(); + void UpdateOutputText(); void restore(const QJsonObject& data) override; QJsonObject save() const override; diff --git a/src/ShaderNode/DataModels/TextureValue.cpp b/src/ShaderNode/DataModels/TextureValue.cpp index 78f7df761..d543a502e 100644 --- a/src/ShaderNode/DataModels/TextureValue.cpp +++ b/src/ShaderNode/DataModels/TextureValue.cpp @@ -20,9 +20,8 @@ ShaderNode(graph) if (graph.GetTextureCount() > 0) { - auto& firstInput = graph.GetTexture(0); m_currentTextureIndex = 0; - m_currentTextureText = firstInput.name; + UpdateOutputTexture(); } DisableCustomVariableName(); @@ -57,6 +56,17 @@ void TextureValue::OnTextureListUpdate() } } +void TextureValue::UpdateOutputTexture() +{ + if (m_currentTextureIndex) + { + auto& texture = GetGraph().GetTexture(*m_currentTextureIndex); + m_currentTextureText = texture.name; + } + else + m_currentTextureText.clear(); +} + bool TextureValue::ComputePreview(QPixmap& pixmap) { if (!m_currentTextureIndex) @@ -74,6 +84,12 @@ void TextureValue::BuildNodeEdition(QFormLayout* layout) ShaderNode::BuildNodeEdition(layout); QComboBox* textureSelection = new QComboBox; + for (const auto& textureEntry : GetGraph().GetTextures()) + textureSelection->addItem(QString::fromStdString(textureEntry.name)); + + if (m_currentTextureIndex) + textureSelection->setCurrentIndex(int(*m_currentTextureIndex)); + connect(textureSelection, qOverload(&QComboBox::currentIndexChanged), [&](int index) { if (index >= 0) @@ -81,14 +97,12 @@ void TextureValue::BuildNodeEdition(QFormLayout* layout) else m_currentTextureIndex.reset(); + UpdateOutputTexture(); UpdatePreview(); Q_EMIT dataUpdated(0); }); - for (const auto& textureEntry : GetGraph().GetTextures()) - textureSelection->addItem(QString::fromStdString(textureEntry.name)); - layout->addRow(tr("Texture"), textureSelection); } @@ -120,7 +134,7 @@ auto TextureValue::dataType(QtNodes::PortType portType, QtNodes::PortIndex portI assert(portType == QtNodes::PortType::Out); assert(portIndex == 0); - return VecData::Type(); + return Texture2Data::Type(); } std::shared_ptr TextureValue::outData(QtNodes::PortIndex port) diff --git a/src/ShaderNode/DataModels/TextureValue.hpp b/src/ShaderNode/DataModels/TextureValue.hpp index 4b46be4d6..89cfcff21 100644 --- a/src/ShaderNode/DataModels/TextureValue.hpp +++ b/src/ShaderNode/DataModels/TextureValue.hpp @@ -35,6 +35,7 @@ class TextureValue : public ShaderNode protected: bool ComputePreview(QPixmap& pixmap) override; void OnTextureListUpdate(); + void UpdateOutputTexture(); void restore(const QJsonObject& data) override; QJsonObject save() const override; diff --git a/src/ShaderNode/DataModels/VecValue.inl b/src/ShaderNode/DataModels/VecValue.inl index a35a95686..a3ea2068e 100644 --- a/src/ShaderNode/DataModels/VecValue.inl +++ b/src/ShaderNode/DataModels/VecValue.inl @@ -78,6 +78,7 @@ void VecValue::BuildNodeEdition(QFormLayout* layout) { QDoubleSpinBox* spinbox = new QDoubleSpinBox; spinbox->setDecimals(6); + spinbox->setRange(std::numeric_limits::lowest(), std::numeric_limits::max()); spinbox->setValue(m_value[i]); connect(spinbox, qOverload(&QDoubleSpinBox::valueChanged), [=](double) @@ -122,8 +123,10 @@ template void VecValue::restore(const QJsonObject& data) { QJsonArray vecValues = data["value"].toArray(); - for (std::size_t i = 0; i < ComponentCount; ++i) - m_value[i] = vecValues[int(i)].toInt(m_value[i]); + std::size_t commonValues = std::min(static_cast(vecValues.size()), ComponentCount); + + for (std::size_t i = 0; i < commonValues; ++i) + m_value[i] = float(vecValues[int(i)].toDouble(m_value[i])); ShaderNode::restore(data); } diff --git a/src/ShaderNode/Previews/QuadPreview.cpp b/src/ShaderNode/Previews/QuadPreview.cpp index 55ae86a52..ef064417d 100644 --- a/src/ShaderNode/Previews/QuadPreview.cpp +++ b/src/ShaderNode/Previews/QuadPreview.cpp @@ -3,8 +3,12 @@ QImage QuadPreview::GetImage(InputRole role, std::size_t roleIndex) const { - assert(role == InputRole::TexCoord); - assert(roleIndex == 0); + if (role != InputRole::TexCoord) + { + QImage dummy(1, 1, QImage::Format_RGBA8888); + dummy.fill(QColor::fromRgb(0, 0, 0, 0)); + return dummy; + } QImage uv(128, 128, QImage::Format_RGBA8888); From 9b911ac4bc4df86cceb16f9455befffdc78d0b1a Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 16 Jun 2020 17:44:54 +0200 Subject: [PATCH 240/316] Renderer/ShaderAst: Minor fixes relative to float/vec multiplication --- src/Nazara/Renderer/ShaderAst.cpp | 8 ++++++-- src/Nazara/Renderer/ShaderValidator.cpp | 8 ++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Renderer/ShaderAst.cpp b/src/Nazara/Renderer/ShaderAst.cpp index d60ebab6a..b6623cc48 100644 --- a/src/Nazara/Renderer/ShaderAst.cpp +++ b/src/Nazara/Renderer/ShaderAst.cpp @@ -122,12 +122,16 @@ namespace Nz::ShaderAst switch (op) { case ShaderAst::BinaryType::Add: - case ShaderAst::BinaryType::Divide: - case ShaderAst::BinaryType::Multiply: case ShaderAst::BinaryType::Substract: exprType = left->GetExpressionType(); break; + case ShaderAst::BinaryType::Divide: + case ShaderAst::BinaryType::Multiply: + //FIXME + exprType = static_cast(std::max(UnderlyingCast(left->GetExpressionType()), UnderlyingCast(right->GetExpressionType()))); + break; + case ShaderAst::BinaryType::Equality: exprType = ExpressionType::Boolean; break; diff --git a/src/Nazara/Renderer/ShaderValidator.cpp b/src/Nazara/Renderer/ShaderValidator.cpp index 2a4d38f25..c7a25989f 100644 --- a/src/Nazara/Renderer/ShaderValidator.cpp +++ b/src/Nazara/Renderer/ShaderValidator.cpp @@ -102,6 +102,14 @@ namespace Nz::ShaderAst { switch (leftType) { + case ExpressionType::Float1: + { + if (Node::GetComponentType(rightType) != ExpressionType::Float1) + throw AstError{ "Left expression type is not compatible with right expression type" }; + + break; + } + case ExpressionType::Float2: case ExpressionType::Float3: case ExpressionType::Float4: From d3db22ce224fa659cf19b49910aea348010e316d Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 16 Jun 2020 17:45:21 +0200 Subject: [PATCH 241/316] ShaderEditor/VecBinOp: Add component check --- src/ShaderNode/DataModels/VecBinOp.hpp | 3 +++ src/ShaderNode/DataModels/VecBinOp.inl | 26 +++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/ShaderNode/DataModels/VecBinOp.hpp b/src/ShaderNode/DataModels/VecBinOp.hpp index 0fbb93f9c..977b0d3ba 100644 --- a/src/ShaderNode/DataModels/VecBinOp.hpp +++ b/src/ShaderNode/DataModels/VecBinOp.hpp @@ -23,6 +23,9 @@ class VecBinOp : public ShaderNode void setInData(std::shared_ptr value, int index) override; + QtNodes::NodeValidationState validationState() const override; + QString validationMessage() const override; + private: virtual void ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) = 0; diff --git a/src/ShaderNode/DataModels/VecBinOp.inl b/src/ShaderNode/DataModels/VecBinOp.inl index 7d3cf1e12..5a12aff08 100644 --- a/src/ShaderNode/DataModels/VecBinOp.inl +++ b/src/ShaderNode/DataModels/VecBinOp.inl @@ -65,6 +65,30 @@ void VecBinOp::setInData(std::shared_ptr value, int in UpdateOutput(); } +template +QtNodes::NodeValidationState VecBinOp::validationState() const +{ + if (!m_lhs || !m_rhs) + return QtNodes::NodeValidationState::Error; + + if (m_lhs->componentCount != m_rhs->componentCount) + return QtNodes::NodeValidationState::Error; + + return QtNodes::NodeValidationState::Valid; +} + +template +QString VecBinOp::validationMessage() const +{ + if (!m_lhs || !m_rhs) + return "Missing operands"; + + if (m_lhs->componentCount != m_rhs->componentCount) + return "Incompatible components count (left has " + QString::number(m_lhs->componentCount) + ", right has " + QString::number(m_rhs->componentCount) + ")"; + + return QString(); +} + template bool VecBinOp::ComputePreview(QPixmap& pixmap) { @@ -78,7 +102,7 @@ bool VecBinOp::ComputePreview(QPixmap& pixmap) template void VecBinOp::UpdateOutput() { - if (!m_lhs || !m_rhs || m_lhs->componentCount != m_rhs->componentCount) + if (validationState() != QtNodes::NodeValidationState::Valid) { m_output = std::make_shared(4); m_output->preview = QImage(1, 1, QImage::Format_RGBA8888); From 80527dec3e832d37c6ef60242d361a1626ccaa12 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 16 Jun 2020 17:45:36 +0200 Subject: [PATCH 242/316] ShaderEditor: Add VecDot --- src/ShaderNode/DataModels/VecDot.cpp | 167 +++++++++++++++++++++++++++ src/ShaderNode/DataModels/VecDot.hpp | 43 +++++++ src/ShaderNode/DataModels/VecDot.inl | 1 + src/ShaderNode/ShaderGraph.cpp | 2 + 4 files changed, 213 insertions(+) create mode 100644 src/ShaderNode/DataModels/VecDot.cpp create mode 100644 src/ShaderNode/DataModels/VecDot.hpp create mode 100644 src/ShaderNode/DataModels/VecDot.inl diff --git a/src/ShaderNode/DataModels/VecDot.cpp b/src/ShaderNode/DataModels/VecDot.cpp new file mode 100644 index 000000000..47b67b72c --- /dev/null +++ b/src/ShaderNode/DataModels/VecDot.cpp @@ -0,0 +1,167 @@ +#include +#include + +VecDot::VecDot(ShaderGraph& graph) : +ShaderNode(graph) +{ + m_output = std::make_shared(); + UpdateOutput(); +} + +Nz::ShaderAst::ExpressionPtr VecDot::GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const +{ + assert(count == 2); + using namespace Nz::ShaderAst; + return BinaryFunc::Build(BinaryIntrinsic::DotProduct, expressions[0], expressions[1]); +} + +QString VecDot::caption() const +{ + static QString caption = "Vector dot"; + return caption; +} + +QString VecDot::name() const +{ + static QString name = "vec_dot"; + return name; +} + +QtNodes::NodeDataType VecDot::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const +{ + switch (portType) + { + case QtNodes::PortType::In: + { + assert(portIndex == 0 || portIndex == 1); + return VecData::Type(); + } + + case QtNodes::PortType::Out: + { + assert(portIndex == 0); + return FloatData::Type(); + } + } + + assert(false); + throw std::runtime_error("Invalid port type"); +} + +unsigned int VecDot::nPorts(QtNodes::PortType portType) const +{ + switch (portType) + { + case QtNodes::PortType::In: return 2; + case QtNodes::PortType::Out: return 1; + } + + assert(false); + throw std::runtime_error("Invalid port type"); +} + +std::shared_ptr VecDot::outData(QtNodes::PortIndex port) +{ + assert(port == 0); + return m_output; +} + +void VecDot::setInData(std::shared_ptr value, int index) +{ + assert(index == 0 || index == 1); + + std::shared_ptr castedValue; + if (value) + { + assert(dynamic_cast(value.get()) != nullptr); + + castedValue = std::static_pointer_cast(value); + } + + if (index == 0) + m_lhs = std::move(castedValue); + else + m_rhs = std::move(castedValue); + + UpdateOutput(); +} + +QtNodes::NodeValidationState VecDot::validationState() const +{ + if (!m_lhs || !m_rhs) + return QtNodes::NodeValidationState::Error; + + if (m_lhs->componentCount != m_rhs->componentCount) + return QtNodes::NodeValidationState::Error; + + return QtNodes::NodeValidationState::Valid; +} + +QString VecDot::validationMessage() const +{ + if (!m_lhs || !m_rhs) + return "Missing operands"; + + if (m_lhs->componentCount != m_rhs->componentCount) + return "Incompatible components count (left has " + QString::number(m_lhs->componentCount) + ", right has " + QString::number(m_rhs->componentCount) + ")"; + + return QString(); +} +bool VecDot::ComputePreview(QPixmap& pixmap) +{ + if (validationState() != QtNodes::NodeValidationState::Valid) + return false; + + pixmap = QPixmap::fromImage(m_output->preview); + return true; +} + +void VecDot::UpdateOutput() +{ + if (validationState() != QtNodes::NodeValidationState::Valid) + { + m_output->preview = QImage(1, 1, QImage::Format_RGBA8888); + m_output->preview.fill(QColor::fromRgb(0, 0, 0, 0)); + return; + } + + const QImage& leftPreview = m_lhs->preview; + const QImage& rightPreview = m_rhs->preview; + int maxWidth = std::max(leftPreview.width(), rightPreview.width()); + int maxHeight = std::max(leftPreview.height(), rightPreview.height()); + + // Exploit COW + QImage leftResized = leftPreview; + if (leftResized.width() != maxWidth || leftResized.height() != maxHeight) + leftResized = leftResized.scaled(maxWidth, maxHeight); + + QImage rightResized = rightPreview; + if (rightResized.width() != maxWidth || rightResized.height() != maxHeight) + rightResized = rightResized.scaled(maxWidth, maxHeight); + + m_output->preview = QImage(maxWidth, maxHeight, QImage::Format_RGBA8888); + + const uchar* left = leftResized.constBits(); + const uchar* right = rightPreview.constBits(); + uchar* output = m_output->preview.bits(); + + std::size_t pixelCount = maxWidth * maxHeight; + for (std::size_t i = 0; i < pixelCount; ++i) + { + unsigned int acc = 0; + for (std::size_t j = 0; j < m_lhs->componentCount; ++j) + acc += left[j] * right[j] / 255; + + unsigned int result = static_cast(std::min(acc, 255U)); + for (std::size_t j = 0; j < 3; ++j) + *output++ = result; + *output++ = 255; //< leave alpha at maximum + + left += 4; + right += 4; + } + + Q_EMIT dataUpdated(0); + + UpdatePreview(); +} diff --git a/src/ShaderNode/DataModels/VecDot.hpp b/src/ShaderNode/DataModels/VecDot.hpp new file mode 100644 index 000000000..dc92bb5c8 --- /dev/null +++ b/src/ShaderNode/DataModels/VecDot.hpp @@ -0,0 +1,43 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_VECDOT_HPP +#define NAZARA_SHADERNODES_VECDOT_HPP + +#include +#include +#include + +class VecDot : public ShaderNode +{ + public: + VecDot(ShaderGraph& graph); + ~VecDot() = default; + + Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const override; + + QString caption() const override; + QString name() const override; + + unsigned int nPorts(QtNodes::PortType portType) const override; + + QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; + + std::shared_ptr outData(QtNodes::PortIndex port) override; + + void setInData(std::shared_ptr value, int index) override; + + QtNodes::NodeValidationState validationState() const override; + QString validationMessage() const override; + + private: + bool ComputePreview(QPixmap& pixmap) override; + void UpdateOutput(); + + std::shared_ptr m_lhs; + std::shared_ptr m_rhs; + std::shared_ptr m_output; +}; + +#include + +#endif diff --git a/src/ShaderNode/DataModels/VecDot.inl b/src/ShaderNode/DataModels/VecDot.inl new file mode 100644 index 000000000..ba9301bc9 --- /dev/null +++ b/src/ShaderNode/DataModels/VecDot.inl @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp index 01b5c6cf9..57b9429e3 100644 --- a/src/ShaderNode/ShaderGraph.cpp +++ b/src/ShaderNode/ShaderGraph.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -400,6 +401,7 @@ std::shared_ptr ShaderGraph::BuildRegistry() RegisterShaderNode(*this, registry, "Texture"); RegisterShaderNode(*this, registry, "Vector operations"); RegisterShaderNode(*this, registry, "Vector operations"); + RegisterShaderNode(*this, registry, "Vector operations"); RegisterShaderNode(*this, registry, "Vector operations"); RegisterShaderNode(*this, registry, "Vector operations"); RegisterShaderNode(*this, registry, "Constants"); From 463b54073957c8ac8a4c59af6e23e0d342324eef Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 16 Jun 2020 17:46:03 +0200 Subject: [PATCH 243/316] ShaderEditor: Add VecFloatMul --- src/ShaderNode/DataModels/VecFloatMul.cpp | 183 ++++++++++++++++++++++ src/ShaderNode/DataModels/VecFloatMul.hpp | 43 +++++ src/ShaderNode/DataModels/VecFloatMul.inl | 1 + src/ShaderNode/ShaderGraph.cpp | 2 + 4 files changed, 229 insertions(+) create mode 100644 src/ShaderNode/DataModels/VecFloatMul.cpp create mode 100644 src/ShaderNode/DataModels/VecFloatMul.hpp create mode 100644 src/ShaderNode/DataModels/VecFloatMul.inl diff --git a/src/ShaderNode/DataModels/VecFloatMul.cpp b/src/ShaderNode/DataModels/VecFloatMul.cpp new file mode 100644 index 000000000..f4ec6f957 --- /dev/null +++ b/src/ShaderNode/DataModels/VecFloatMul.cpp @@ -0,0 +1,183 @@ +#include +#include + +VecFloatMul::VecFloatMul(ShaderGraph& graph) : +ShaderNode(graph) +{ + UpdateOutput(); +} + +Nz::ShaderAst::ExpressionPtr VecFloatMul::GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const +{ + assert(count == 2); + using namespace Nz::ShaderAst; + return BinaryOp::Build(BinaryType::Multiply, expressions[0], expressions[1]); +} + +QString VecFloatMul::caption() const +{ + static QString caption = "Float/vector multiplication"; + return caption; +} + +QString VecFloatMul::name() const +{ + static QString name = "vecfloat_mul"; + return name; +} + +QtNodes::NodeDataType VecFloatMul::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const +{ + switch (portType) + { + case QtNodes::PortType::In: + { + assert(portIndex == 0 || portIndex == 1); + switch (portIndex) + { + case 0: return FloatData::Type(); + case 1: return VecData::Type(); + } + } + + case QtNodes::PortType::Out: + { + assert(portIndex == 0); + return VecData::Type(); + } + } + + assert(false); + throw std::runtime_error("Invalid port type"); +} + +unsigned int VecFloatMul::nPorts(QtNodes::PortType portType) const +{ + switch (portType) + { + case QtNodes::PortType::In: return 2; + case QtNodes::PortType::Out: return 1; + } + + assert(false); + throw std::runtime_error("Invalid port type"); +} + +std::shared_ptr VecFloatMul::outData(QtNodes::PortIndex port) +{ + assert(port == 0); + return m_output; +} + +void VecFloatMul::setInData(std::shared_ptr value, int index) +{ + assert(index == 0 || index == 1); + + switch (index) + { + case 0: + { + if (value) + { + assert(dynamic_cast(value.get()) != nullptr); + + m_lhs = std::static_pointer_cast(value); + } + else + m_lhs.reset(); + + break; + } + + case 1: + { + if (value) + { + assert(dynamic_cast(value.get()) != nullptr); + + m_rhs = std::static_pointer_cast(value); + } + else + m_rhs.reset(); + + break; + } + + default: + assert(false); + throw std::runtime_error("Invalid PortType"); + } + + UpdateOutput(); +} + +QtNodes::NodeValidationState VecFloatMul::validationState() const +{ + if (!m_lhs || !m_rhs) + return QtNodes::NodeValidationState::Error; + + return QtNodes::NodeValidationState::Valid; +} + +QString VecFloatMul::validationMessage() const +{ + if (!m_lhs || !m_rhs) + return "Missing operands"; + + return QString(); +} + +bool VecFloatMul::ComputePreview(QPixmap& pixmap) +{ + if (validationState() != QtNodes::NodeValidationState::Valid) + return false; + + pixmap = QPixmap::fromImage(m_output->preview); + return true; +} + +void VecFloatMul::UpdateOutput() +{ + if (validationState() != QtNodes::NodeValidationState::Valid) + { + m_output = std::make_shared(4); + m_output->preview = QImage(1, 1, QImage::Format_RGBA8888); + m_output->preview.fill(QColor::fromRgb(0, 0, 0, 0)); + return; + } + + m_output = std::make_shared(m_rhs->componentCount); + + const QImage& leftPreview = m_lhs->preview; + const QImage& rightPreview = m_rhs->preview; + int maxWidth = std::max(leftPreview.width(), rightPreview.width()); + int maxHeight = std::max(leftPreview.height(), rightPreview.height()); + + // Exploit COW + QImage leftResized = leftPreview; + if (leftResized.width() != maxWidth || leftResized.height() != maxHeight) + leftResized = leftResized.scaled(maxWidth, maxHeight); + + QImage rightResized = rightPreview; + if (rightResized.width() != maxWidth || rightResized.height() != maxHeight) + rightResized = rightResized.scaled(maxWidth, maxHeight); + + m_output->preview = QImage(maxWidth, maxHeight, QImage::Format_RGBA8888); + + const uchar* left = leftResized.constBits(); + const uchar* right = rightPreview.constBits(); + uchar* output = m_output->preview.bits(); + + std::size_t pixelCount = maxWidth * maxHeight * 4; + for (std::size_t i = 0; i < pixelCount; ++i) + { + unsigned int lValue = left[i]; + unsigned int rValue = right[i]; + + output[i] = static_cast(lValue * rValue / 255); + } + + Q_EMIT dataUpdated(0); + + UpdatePreview(); +} diff --git a/src/ShaderNode/DataModels/VecFloatMul.hpp b/src/ShaderNode/DataModels/VecFloatMul.hpp new file mode 100644 index 000000000..c4a9a97f7 --- /dev/null +++ b/src/ShaderNode/DataModels/VecFloatMul.hpp @@ -0,0 +1,43 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_VECFLOATMUL_HPP +#define NAZARA_SHADERNODES_VECFLOATMUL_HPP + +#include +#include +#include + +class VecFloatMul : public ShaderNode +{ + public: + VecFloatMul(ShaderGraph& graph); + ~VecFloatMul() = default; + + Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const override; + + QString caption() const override; + QString name() const override; + + unsigned int nPorts(QtNodes::PortType portType) const override; + + QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; + + std::shared_ptr outData(QtNodes::PortIndex port) override; + + void setInData(std::shared_ptr value, int index) override; + + QtNodes::NodeValidationState validationState() const override; + QString validationMessage() const override; + + private: + bool ComputePreview(QPixmap& pixmap) override; + void UpdateOutput(); + + std::shared_ptr m_lhs; + std::shared_ptr m_rhs; + std::shared_ptr m_output; +}; + +#include + +#endif diff --git a/src/ShaderNode/DataModels/VecFloatMul.inl b/src/ShaderNode/DataModels/VecFloatMul.inl new file mode 100644 index 000000000..a798943a8 --- /dev/null +++ b/src/ShaderNode/DataModels/VecFloatMul.inl @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp index 57b9429e3..06b0ddea0 100644 --- a/src/ShaderNode/ShaderGraph.cpp +++ b/src/ShaderNode/ShaderGraph.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -402,6 +403,7 @@ std::shared_ptr ShaderGraph::BuildRegistry() RegisterShaderNode(*this, registry, "Vector operations"); RegisterShaderNode(*this, registry, "Vector operations"); RegisterShaderNode(*this, registry, "Vector operations"); + RegisterShaderNode(*this, registry, "Vector operations"); RegisterShaderNode(*this, registry, "Vector operations"); RegisterShaderNode(*this, registry, "Vector operations"); RegisterShaderNode(*this, registry, "Constants"); From f38bfdde8a0a43de8a3ba47f153e00111a798f7f Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 17 Jun 2020 16:00:03 +0200 Subject: [PATCH 244/316] ShaderAst: Big refactor + add binding/location support --- SDK/include/NDK/Components.hpp | 9 + SDK/include/NDK/Systems.hpp | 9 + SDK/include/NDK/Widgets.hpp | 9 + include/Nazara/Renderer/GlslWriter.hpp | 86 +-- include/Nazara/Renderer/GlslWriter.inl | 65 +++ include/Nazara/Renderer/ShaderAst.hpp | 434 +++------------ include/Nazara/Renderer/ShaderAst.inl | 369 +++---------- include/Nazara/Renderer/ShaderBuilder.hpp | 70 ++- include/Nazara/Renderer/ShaderBuilder.inl | 37 +- include/Nazara/Renderer/ShaderEnums.hpp | 99 ++++ include/Nazara/Renderer/ShaderNodes.hpp | 272 ++++++++++ include/Nazara/Renderer/ShaderNodes.inl | 300 +++++++++++ include/Nazara/Renderer/ShaderSerializer.hpp | 19 +- include/Nazara/Renderer/ShaderSerializer.inl | 18 +- include/Nazara/Renderer/ShaderValidator.hpp | 47 +- include/Nazara/Renderer/ShaderValidator.inl | 6 +- include/Nazara/Renderer/ShaderVarVisitor.hpp | 34 ++ include/Nazara/Renderer/ShaderVariables.hpp | 127 +++++ include/Nazara/Renderer/ShaderVariables.inl | 65 +++ include/Nazara/Renderer/ShaderVisitor.hpp | 37 +- include/Nazara/Renderer/ShaderWriter.hpp | 14 +- src/Nazara/Renderer/GlslWriter.cpp | 529 +++++++++---------- src/Nazara/Renderer/ShaderAst.cpp | 279 +--------- src/Nazara/Renderer/ShaderNodes.cpp | 179 +++++++ src/Nazara/Renderer/ShaderSerializer.cpp | 149 ++++-- src/Nazara/Renderer/ShaderValidator.cpp | 303 ++++++++--- src/Nazara/Renderer/ShaderVarVisitor.cpp | 16 + src/Nazara/Renderer/ShaderVariables.cpp | 77 +++ src/Nazara/Renderer/ShaderVisitor.cpp | 6 +- src/Nazara/Renderer/ShaderWriter.cpp | 1 + src/ShaderNode/DataModels/Cast.hpp | 2 +- src/ShaderNode/DataModels/Cast.inl | 10 +- src/ShaderNode/DataModels/FloatValue.cpp | 2 +- src/ShaderNode/DataModels/FloatValue.hpp | 2 +- src/ShaderNode/DataModels/InputValue.cpp | 18 +- src/ShaderNode/DataModels/InputValue.hpp | 2 +- src/ShaderNode/DataModels/OutputValue.cpp | 22 +- src/ShaderNode/DataModels/OutputValue.hpp | 2 +- src/ShaderNode/DataModels/SampleTexture.cpp | 2 +- src/ShaderNode/DataModels/SampleTexture.hpp | 2 +- src/ShaderNode/DataModels/ShaderNode.hpp | 4 +- src/ShaderNode/DataModels/TextureValue.cpp | 8 +- src/ShaderNode/DataModels/TextureValue.hpp | 2 +- src/ShaderNode/DataModels/VecBinOp.hpp | 20 +- src/ShaderNode/DataModels/VecBinOp.inl | 22 +- src/ShaderNode/DataModels/VecDot.cpp | 8 +- src/ShaderNode/DataModels/VecDot.hpp | 2 +- src/ShaderNode/DataModels/VecFloatMul.cpp | 6 +- src/ShaderNode/DataModels/VecFloatMul.hpp | 2 +- src/ShaderNode/DataModels/VecValue.hpp | 2 +- src/ShaderNode/DataModels/VecValue.inl | 2 +- src/ShaderNode/DataTypes/TextureData.hpp | 2 +- src/ShaderNode/DataTypes/VecData.cpp | 8 +- src/ShaderNode/DataTypes/VecData.hpp | 14 +- src/ShaderNode/ShaderGraph.cpp | 49 +- src/ShaderNode/ShaderGraph.hpp | 17 +- src/ShaderNode/Widgets/InputEditDialog.cpp | 5 + src/ShaderNode/Widgets/InputEditDialog.hpp | 2 + src/ShaderNode/Widgets/InputEditor.cpp | 4 +- src/ShaderNode/Widgets/MainWindow.cpp | 50 +- src/ShaderNode/Widgets/OutputEditDialog.cpp | 12 +- src/ShaderNode/Widgets/OutputEditDialog.hpp | 5 +- src/ShaderNode/Widgets/OutputEditor.cpp | 8 +- 63 files changed, 2380 insertions(+), 1603 deletions(-) create mode 100644 SDK/include/NDK/Components.hpp create mode 100644 SDK/include/NDK/Systems.hpp create mode 100644 SDK/include/NDK/Widgets.hpp create mode 100644 include/Nazara/Renderer/GlslWriter.inl create mode 100644 include/Nazara/Renderer/ShaderEnums.hpp create mode 100644 include/Nazara/Renderer/ShaderNodes.hpp create mode 100644 include/Nazara/Renderer/ShaderNodes.inl create mode 100644 include/Nazara/Renderer/ShaderVarVisitor.hpp create mode 100644 include/Nazara/Renderer/ShaderVariables.hpp create mode 100644 include/Nazara/Renderer/ShaderVariables.inl create mode 100644 src/Nazara/Renderer/ShaderNodes.cpp create mode 100644 src/Nazara/Renderer/ShaderVarVisitor.cpp create mode 100644 src/Nazara/Renderer/ShaderVariables.cpp diff --git a/SDK/include/NDK/Components.hpp b/SDK/include/NDK/Components.hpp new file mode 100644 index 000000000..97f597990 --- /dev/null +++ b/SDK/include/NDK/Components.hpp @@ -0,0 +1,9 @@ +// This file was automatically generated + +#pragma once + +#ifndef NDK_COMPONENTS_GLOBAL_HPP +#define NDK_COMPONENTS_GLOBAL_HPP + + +#endif // NDK_COMPONENTS_GLOBAL_HPP diff --git a/SDK/include/NDK/Systems.hpp b/SDK/include/NDK/Systems.hpp new file mode 100644 index 000000000..33edfc17a --- /dev/null +++ b/SDK/include/NDK/Systems.hpp @@ -0,0 +1,9 @@ +// This file was automatically generated + +#pragma once + +#ifndef NDK_SYSTEMS_GLOBAL_HPP +#define NDK_SYSTEMS_GLOBAL_HPP + + +#endif // NDK_SYSTEMS_GLOBAL_HPP diff --git a/SDK/include/NDK/Widgets.hpp b/SDK/include/NDK/Widgets.hpp new file mode 100644 index 000000000..b009f3a17 --- /dev/null +++ b/SDK/include/NDK/Widgets.hpp @@ -0,0 +1,9 @@ +// This file was automatically generated + +#pragma once + +#ifndef NDK_WIDGETS_GLOBAL_HPP +#define NDK_WIDGETS_GLOBAL_HPP + + +#endif // NDK_WIDGETS_GLOBAL_HPP diff --git a/include/Nazara/Renderer/GlslWriter.hpp b/include/Nazara/Renderer/GlslWriter.hpp index 2caaa6a75..22d6544f2 100644 --- a/include/Nazara/Renderer/GlslWriter.hpp +++ b/include/Nazara/Renderer/GlslWriter.hpp @@ -8,15 +8,19 @@ #define NAZARA_GLSLWRITER_HPP #include -#include #include +#include +#include +#include #include #include +#include +#include #include namespace Nz { - class NAZARA_RENDERER_API GlslWriter : public ShaderWriter + class NAZARA_RENDERER_API GlslWriter : public ShaderWriter, public ShaderVarVisitor, public ShaderVisitor { public: GlslWriter(); @@ -24,67 +28,65 @@ namespace Nz GlslWriter(GlslWriter&&) = delete; ~GlslWriter() = default; - Nz::String Generate(const ShaderAst::StatementPtr& node) override; - - void RegisterFunction(const String& name, ShaderAst::StatementPtr statement, std::initializer_list parameters, ShaderAst::ExpressionType ret) override; - void RegisterVariable(ShaderAst::VariableType kind, const String& name, ShaderAst::ExpressionType type) override; + std::string Generate(const ShaderAst& shader) override; void SetGlslVersion(unsigned int version); - using ShaderWriter::Visit; - void Visit(const ShaderAst::AssignOp& node) override; - void Visit(const ShaderAst::Branch& node) override; - void Visit(const ShaderAst::BinaryFunc& node) override; - void Visit(const ShaderAst::BinaryOp& node) override; - void Visit(const ShaderAst::BuiltinVariable& node) override; - void Visit(const ShaderAst::Cast& node) override; - void Visit(const ShaderAst::Constant& node) override; - void Visit(const ShaderAst::DeclareVariable& node) override; - void Visit(const ShaderAst::ExpressionStatement& node) override; - void Visit(const ShaderAst::NamedVariable& node) override; - void Visit(const ShaderAst::Sample2D& node) override; - void Visit(const ShaderAst::StatementBlock& node) override; - void Visit(const ShaderAst::SwizzleOp& node) override; - private: - struct Function; - using VariableContainer = std::set>; + void Append(ShaderNodes::BuiltinEntry builtin); + void Append(ShaderNodes::ExpressionType type); + template void Append(const T& param); + void AppendCommentSection(const std::string& section); + void AppendFunction(const ShaderAst::Function& func); + void AppendFunctionPrototype(const ShaderAst::Function& func); + void AppendLine(const std::string& txt = {}); - void Append(ShaderAst::BuiltinEntry builtin); - void Append(ShaderAst::ExpressionType type); - void Append(const String& txt); - void AppendCommentSection(const String& section); - void AppendFunction(Function& func); - void AppendLine(const String& txt = String()); - - void DeclareVariables(const VariableContainer& variables, const String& keyword = String(), const String& section = String()); + template void DeclareVariables(const std::vector& variables, const std::string& keyword = {}, const std::string& section = {}); void EnterScope(); void LeaveScope(); + using ShaderVarVisitor::Visit; + using ShaderVisitor::Visit; + void Visit(const ShaderNodes::AssignOp& node) override; + void Visit(const ShaderNodes::Branch& node) override; + void Visit(const ShaderNodes::BinaryOp& node) override; + void Visit(const ShaderNodes::BuiltinVariable& var) override; + void Visit(const ShaderNodes::Cast& node) override; + void Visit(const ShaderNodes::Constant& node) override; + void Visit(const ShaderNodes::DeclareVariable& node) override; + void Visit(const ShaderNodes::ExpressionStatement& node) override; + void Visit(const ShaderNodes::Identifier& node) override; + void Visit(const ShaderNodes::InputVariable& var) override; + void Visit(const ShaderNodes::IntrinsicCall& node) override; + void Visit(const ShaderNodes::LocalVariable& var) override; + void Visit(const ShaderNodes::ParameterVariable& var) override; + void Visit(const ShaderNodes::OutputVariable& var) override; + void Visit(const ShaderNodes::Sample2D& node) override; + void Visit(const ShaderNodes::StatementBlock& node) override; + void Visit(const ShaderNodes::SwizzleOp& node) override; + void Visit(const ShaderNodes::UniformVariable& var) override; - struct Function + static bool HasExplicitBinding(const ShaderAst& shader); + static bool HasExplicitLocation(const ShaderAst& shader); + + struct Context { - std::vector parameters; - ShaderAst::ExpressionType retType; - ShaderAst::StatementPtr node; - String name; + const ShaderAst::Function* currentFunction = nullptr; }; struct State { - VariableContainer inputs; - VariableContainer outputs; - VariableContainer uniforms; - StringStream stream; + std::stringstream stream; unsigned int indentLevel = 0; }; - std::unordered_map m_functions; - Function* m_currentFunction; + Context m_context; State* m_currentState; unsigned int m_glslVersion; }; } +#include + #endif // NAZARA_GLSLWRITER_HPP diff --git a/include/Nazara/Renderer/GlslWriter.inl b/include/Nazara/Renderer/GlslWriter.inl new file mode 100644 index 000000000..fcaca4b98 --- /dev/null +++ b/include/Nazara/Renderer/GlslWriter.inl @@ -0,0 +1,65 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + template + void GlslWriter::Append(const T& param) + { + NazaraAssert(m_currentState, "This function should only be called while processing an AST"); + + m_currentState->stream << param; + } + + template + void GlslWriter::DeclareVariables(const std::vector& variables, const std::string& keyword, const std::string& section) + { + if (!variables.empty()) + { + if (!section.empty()) + AppendCommentSection(section); + + for (const auto& var : variables) + { + if constexpr (std::is_same_v) + { + if (var.locationIndex) + { + Append("layout(location = "); + Append(*var.locationIndex); + Append(") "); + } + } + else if constexpr (std::is_same_v) + { + if (var.bindingIndex) + { + Append("layout(binding = "); + Append(*var.bindingIndex); + Append(") "); + } + } + + if (!keyword.empty()) + { + Append(keyword); + Append(" "); + } + + Append(var.type); + Append(" "); + Append(var.name); + AppendLine(";"); + } + + AppendLine(); + } + } +} + +#include diff --git a/include/Nazara/Renderer/ShaderAst.hpp b/include/Nazara/Renderer/ShaderAst.hpp index 0bbaec9f3..0aa094a10 100644 --- a/include/Nazara/Renderer/ShaderAst.hpp +++ b/include/Nazara/Renderer/ShaderAst.hpp @@ -8,393 +8,77 @@ #define NAZARA_SHADER_AST_HPP #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include namespace Nz { - class ByteStream; - class ShaderVisitor; - class ShaderWriter; - - namespace ShaderAst + class NAZARA_RENDERER_API ShaderAst { - enum class AssignType - { - Simple //< = - }; - - enum class BinaryIntrinsic - { - CrossProduct, - DotProduct - }; - - enum class BinaryType - { - Add, //< + - Substract, //< - - Multiply, //< * - Divide, //< / - - Equality //< == - }; - - enum class BuiltinEntry - { - VertexPosition, // gl_Position - }; - - enum class ExpressionCategory - { - LValue, - RValue - }; - - enum class ExpressionType - { - Boolean, // bool - Float1, // float - Float2, // vec2 - Float3, // vec3 - Float4, // vec4 - Mat4x4, // mat4 - Sampler2D, // sampler2D - - Void // void - }; - - enum class NodeType - { - None = -1, - - AssignOp, - BinaryFunc, - BinaryOp, - Branch, - BuiltinVariable, - Cast, - Constant, - ConditionalStatement, - DeclareVariable, - ExpressionStatement, - NamedVariable, - Sample2D, - SwizzleOp, - StatementBlock - }; - - enum class SwizzleComponent - { - First, - Second, - Third, - Fourth - }; - - enum class VariableType - { - Builtin, - Input, - Output, - Parameter, - Uniform, - Variable - }; - - ////////////////////////////////////////////////////////////////////////// - - class Node; - - using NodePtr = std::shared_ptr; - - class NAZARA_RENDERER_API Node - { - public: - virtual ~Node(); - - inline NodeType GetType() const; - - virtual void Register(ShaderWriter& visitor) = 0; - virtual void Visit(ShaderVisitor& visitor) = 0; - - static inline unsigned int GetComponentCount(ExpressionType type); - static inline ExpressionType GetComponentType(ExpressionType type); - - protected: - inline Node(NodeType type); - - private: - NodeType m_type; - }; - - class Statement; - - using StatementPtr = std::shared_ptr; - - class NAZARA_RENDERER_API Statement : public Node - { - public: - using Node::Node; - }; - - class Expression; - - using ExpressionPtr = std::shared_ptr; - - class NAZARA_RENDERER_API Expression : public Node - { - public: - using Node::Node; - - virtual ExpressionCategory GetExpressionCategory() const; - virtual ExpressionType GetExpressionType() const = 0; - }; - - struct NAZARA_RENDERER_API ExpressionStatement : public Statement - { - inline ExpressionStatement(); - - void Register(ShaderWriter& visitor) override; - void Visit(ShaderVisitor& visitor) override; - - ExpressionPtr expression; - - static inline std::shared_ptr Build(ExpressionPtr expr); - }; - - ////////////////////////////////////////////////////////////////////////// - - struct NAZARA_RENDERER_API ConditionalStatement : public Statement - { - inline ConditionalStatement(); - - void Register(ShaderWriter& visitor) override; - void Visit(ShaderVisitor& visitor) override; - - std::string conditionName; - StatementPtr statement; - - static inline std::shared_ptr Build(std::string condition, StatementPtr statementPtr); - }; - - struct NAZARA_RENDERER_API StatementBlock : public Statement - { - inline StatementBlock(); - - void Register(ShaderWriter& visitor) override; - void Visit(ShaderVisitor& visitor) override; - - std::vector statements; - - template static std::shared_ptr Build(Args&&... args); - }; - - struct Variable; - - using VariablePtr = std::shared_ptr; - - struct NAZARA_RENDERER_API Variable : public Expression - { - using Expression::Expression; - - ExpressionCategory GetExpressionCategory() const override; - ExpressionType GetExpressionType() const override; - - ExpressionType type; - VariableType kind; - }; - - - struct NAZARA_RENDERER_API BuiltinVariable : public Variable - { - inline BuiltinVariable(); - - void Register(ShaderWriter& visitor) override; - void Visit(ShaderVisitor& visitor) override; - - BuiltinEntry var; - - static inline std::shared_ptr Build(BuiltinEntry variable, ExpressionType varType); - }; - - - struct NamedVariable; - - using NamedVariablePtr = std::shared_ptr; - - struct NAZARA_RENDERER_API NamedVariable : public Variable - { - inline NamedVariable(); - - void Register(ShaderWriter& visitor) override; - void Visit(ShaderVisitor& visitor) override; - - std::string name; - - static inline std::shared_ptr Build(VariableType varType, std::string varName, ExpressionType expressionType); - }; - - struct NAZARA_RENDERER_API DeclareVariable : public Statement - { - inline DeclareVariable(); - - void Register(ShaderWriter& visitor) override; - void Visit(ShaderVisitor& visitor) override; - - NamedVariablePtr variable; - ExpressionPtr expression; - - static inline std::shared_ptr Build(NamedVariablePtr variable, ExpressionPtr expression = nullptr); - }; - - ////////////////////////////////////////////////////////////////////////// - - struct NAZARA_RENDERER_API AssignOp : public Expression - { - inline AssignOp(); - - ExpressionType GetExpressionType() const override; - void Register(ShaderWriter& visitor) override; - void Visit(ShaderVisitor& visitor) override; - - AssignType op; - ExpressionPtr left; - ExpressionPtr right; - - static inline std::shared_ptr Build(AssignType op, ExpressionPtr left, ExpressionPtr right); - }; - - struct NAZARA_RENDERER_API BinaryOp : public Expression - { - inline BinaryOp(); - - ExpressionType GetExpressionType() const override; - void Register(ShaderWriter& visitor) override; - void Visit(ShaderVisitor& visitor) override; - - BinaryType op; - ExpressionPtr left; - ExpressionPtr right; - - static inline std::shared_ptr Build(BinaryType op, ExpressionPtr left, ExpressionPtr right); - }; - - struct NAZARA_RENDERER_API Branch : public Statement - { - struct ConditionalStatement; - - inline Branch(); - - void Register(ShaderWriter& visitor) override; - void Visit(ShaderVisitor& visitor) override; - - std::vector condStatements; - StatementPtr elseStatement; - - struct ConditionalStatement + public: + struct Function; + struct FunctionParameter; + struct InputOutput; + struct VariableBase; + struct Uniform; + + ShaderAst() = default; + ~ShaderAst() = default; + + void AddFunction(std::string name, ShaderNodes::StatementPtr statement, std::vector parameters = {}, ShaderNodes::ExpressionType returnType = ShaderNodes::ExpressionType::Void); + void AddInput(std::string name, ShaderNodes::ExpressionType type, std::optional locationIndex); + void AddOutput(std::string name, ShaderNodes::ExpressionType type, std::optional locationIndex); + void AddUniform(std::string name, ShaderNodes::ExpressionType type, std::optional bindingIndex); + + inline const Function& GetFunction(std::size_t i) const; + inline std::size_t GetFunctionCount() const; + inline const std::vector& GetFunctions() const; + inline const InputOutput& GetInput(std::size_t i) const; + inline std::size_t GetInputCount() const; + inline const std::vector& GetInputs() const; + inline const InputOutput& GetOutput(std::size_t i) const; + inline std::size_t GetOutputCount() const; + inline const std::vector& GetOutputs() const; + inline const Uniform& GetUniform(std::size_t i) const; + inline std::size_t GetUniformCount() const; + inline const std::vector& GetUniforms() const; + + struct VariableBase { - ExpressionPtr condition; - StatementPtr statement; + std::string name; + ShaderNodes::ExpressionType type; }; - inline std::shared_ptr Build(ExpressionPtr condition, StatementPtr trueStatement, StatementPtr falseStatement = nullptr); - }; - - struct NAZARA_RENDERER_API Cast : public Expression - { - inline Cast(); - - ExpressionType GetExpressionType() const override; - void Register(ShaderWriter& visitor) override; - void Visit(ShaderVisitor& visitor) override; - - ExpressionType exprType; - std::array expressions; - - static inline std::shared_ptr Build(ExpressionType castTo, ExpressionPtr first, ExpressionPtr second = nullptr, ExpressionPtr third = nullptr, ExpressionPtr fourth = nullptr); - static inline std::shared_ptr Build(ExpressionType castTo, ExpressionPtr* expressions, std::size_t expressionCount); - }; - - struct NAZARA_RENDERER_API Constant : public Expression - { - inline Constant(); - - ExpressionType GetExpressionType() const override; - void Register(ShaderWriter& visitor) override; - void Visit(ShaderVisitor& visitor) override; - - ExpressionType exprType; - - union + struct FunctionParameter : VariableBase { - bool bool1; - float vec1; - Vector2f vec2; - Vector3f vec3; - Vector4f vec4; - } values; + }; - static inline std::shared_ptr Build(bool value); - static inline std::shared_ptr Build(float value); - static inline std::shared_ptr Build(const Vector2f& value); - static inline std::shared_ptr Build(const Vector3f& value); - static inline std::shared_ptr Build(const Vector4f& value); - }; + struct Function + { + std::string name; + std::vector parameters; + ShaderNodes::ExpressionType returnType; + ShaderNodes::StatementPtr statement; + }; - struct NAZARA_RENDERER_API SwizzleOp : public Expression - { - inline SwizzleOp(); + struct InputOutput : VariableBase + { + std::optional locationIndex; + }; - ExpressionCategory GetExpressionCategory() const override; - ExpressionType GetExpressionType() const override; - void Register(ShaderWriter& visitor) override; - void Visit(ShaderVisitor& visitor) override; + struct Uniform : VariableBase + { + std::optional bindingIndex; + }; - std::array components; - std::size_t componentCount; - ExpressionPtr expression; - - static inline std::shared_ptr Build(ExpressionPtr expressionPtr, std::initializer_list swizzleComponents); - }; - - ////////////////////////////////////////////////////////////////////////// - - struct NAZARA_RENDERER_API Sample2D : public Expression - { - inline Sample2D(); - - ExpressionType GetExpressionType() const override; - void Register(ShaderWriter& visitor) override; - void Visit(ShaderVisitor& visitor) override; - - ExpressionPtr sampler; - ExpressionPtr coordinates; - - static inline std::shared_ptr Build(ExpressionPtr samplerPtr, ExpressionPtr coordinatesPtr); - }; - - ////////////////////////////////////////////////////////////////////////// - - struct NAZARA_RENDERER_API BinaryFunc : public Expression - { - inline BinaryFunc(); - - ExpressionType GetExpressionType() const override; - void Register(ShaderWriter& visitor) override; - void Visit(ShaderVisitor& visitor) override; - - BinaryIntrinsic intrinsic; - ExpressionPtr left; - ExpressionPtr right; - - static inline std::shared_ptr Build(BinaryIntrinsic intrinsic, ExpressionPtr left, ExpressionPtr right); - }; - } + private: + std::vector m_functions; + std::vector m_inputs; + std::vector m_outputs; + std::vector m_uniforms; + }; } #include diff --git a/include/Nazara/Renderer/ShaderAst.inl b/include/Nazara/Renderer/ShaderAst.inl index 536758832..d9f8f88aa 100644 --- a/include/Nazara/Renderer/ShaderAst.inl +++ b/include/Nazara/Renderer/ShaderAst.inl @@ -7,315 +7,68 @@ namespace Nz { - namespace ShaderAst + inline auto ShaderAst::GetFunction(std::size_t i) const -> const Function& { - inline Node::Node(NodeType type) : - m_type(type) - { - } - - inline NodeType ShaderAst::Node::GetType() const - { - return m_type; - } - - inline unsigned int Node::GetComponentCount(ExpressionType type) - { - switch (type) - { - case ExpressionType::Float2: - return 2; - - case ExpressionType::Float3: - return 3; - - case ExpressionType::Float4: - return 4; - - case ExpressionType::Mat4x4: - return 4; - - default: - return 1; - } - } - - inline ExpressionType Node::GetComponentType(ExpressionType type) - { - switch (type) - { - case ExpressionType::Float2: - case ExpressionType::Float3: - case ExpressionType::Float4: - return ExpressionType::Float1; - - case ExpressionType::Mat4x4: - return ExpressionType::Float4; - - default: - return type; - } - } - - inline ExpressionStatement::ExpressionStatement() : - Statement(NodeType::ExpressionStatement) - { - } - - inline std::shared_ptr ExpressionStatement::Build(ExpressionPtr expr) - { - auto node = std::make_shared(); - node->expression = std::move(expr); - - return node; - } - - inline ConditionalStatement::ConditionalStatement() : - Statement(NodeType::ConditionalStatement) - { - } - - inline std::shared_ptr ConditionalStatement::Build(std::string condition, StatementPtr statementPtr) - { - auto node = std::make_shared(); - node->conditionName = std::move(condition); - node->statement = std::move(statementPtr); - - return node; - } - - - inline StatementBlock::StatementBlock() : - Statement(NodeType::StatementBlock) - { - } - - template - std::shared_ptr StatementBlock::Build(Args&&... args) - { - auto node = std::make_shared(); - node->statements = std::vector({ std::forward(args)... }); - - return node; - } - - - inline BuiltinVariable::BuiltinVariable() : - Variable(NodeType::BuiltinVariable) - { - kind = VariableType::Builtin; - } - - inline std::shared_ptr BuiltinVariable::Build(BuiltinEntry variable, ExpressionType varType) - { - auto node = std::make_shared(); - node->type = varType; - node->var = variable; - - return node; - } - - - inline NamedVariable::NamedVariable() : - Variable(NodeType::NamedVariable) - { - } - - inline std::shared_ptr NamedVariable::Build(VariableType type, std::string varName, ExpressionType expressionType) - { - auto node = std::make_shared(); - node->kind = type; - node->name = std::move(varName); - node->type = expressionType; - - return node; - } - - - inline DeclareVariable::DeclareVariable() : - Statement(NodeType::DeclareVariable) - { - } - - inline std::shared_ptr DeclareVariable::Build(NamedVariablePtr variable, ExpressionPtr expression) - { - auto node = std::make_shared(); - node->expression = std::move(expression); - node->variable = std::move(variable); - - return node; - } - - - inline AssignOp::AssignOp() : - Expression(NodeType::AssignOp) - { - } - - inline std::shared_ptr AssignOp::Build(AssignType op, ExpressionPtr left, ExpressionPtr right) - { - auto node = std::make_shared(); - node->op = op; - node->left = std::move(left); - node->right = std::move(right); - - return node; - } - - - inline BinaryOp::BinaryOp() : - Expression(NodeType::BinaryOp) - { - } - - inline std::shared_ptr BinaryOp::Build(BinaryType op, ExpressionPtr left, ExpressionPtr right) - { - auto node = std::make_shared(); - node->op = op; - node->left = std::move(left); - node->right = std::move(right); - - return node; - } - - - inline Branch::Branch() : - Statement(NodeType::Branch) - { - } - - inline std::shared_ptr Branch::Build(ExpressionPtr condition, StatementPtr trueStatement, StatementPtr falseStatement) - { - auto node = std::make_shared(); - node->condStatements.emplace_back(ConditionalStatement{ std::move(condition), std::move(trueStatement) }); - node->elseStatement = std::move(falseStatement); - - return node; - } - - - inline Cast::Cast() : - Expression(NodeType::Cast) - { - } - - inline std::shared_ptr Cast::Build(ExpressionType castTo, ExpressionPtr first, ExpressionPtr second, ExpressionPtr third, ExpressionPtr fourth) - { - auto node = std::make_shared(); - node->exprType = castTo; - node->expressions = { {first, second, third, fourth} }; - - return node; - } - - inline std::shared_ptr Cast::Build(ExpressionType castTo, ExpressionPtr* Expressions, std::size_t expressionCount) - { - auto node = std::make_shared(); - node->exprType = castTo; - for (std::size_t i = 0; i < expressionCount; ++i) - node->expressions[i] = Expressions[i]; - - return node; - } - - - inline Constant::Constant() : - Expression(NodeType::Constant) - { - } - - inline std::shared_ptr Constant::Build(bool value) - { - auto node = std::make_shared(); - node->exprType = ExpressionType::Boolean; - node->values.bool1 = value; - - return node; - } - - inline std::shared_ptr Constant::Build(float value) - { - auto node = std::make_shared(); - node->exprType = ExpressionType::Float1; - node->values.vec1 = value; - - return node; - } - - inline std::shared_ptr Constant::Build(const Vector2f& value) - { - auto node = std::make_shared(); - node->exprType = ExpressionType::Float2; - node->values.vec2 = value; - - return node; - } - - inline std::shared_ptr Constant::Build(const Vector3f& value) - { - auto node = std::make_shared(); - node->exprType = ExpressionType::Float3; - node->values.vec3 = value; - - return node; - } - - inline std::shared_ptr Constant::Build(const Vector4f& value) - { - auto node = std::make_shared(); - node->exprType = ExpressionType::Float4; - node->values.vec4 = value; - - return node; - } - - - inline SwizzleOp::SwizzleOp() : - Expression(NodeType::SwizzleOp) - { - } - - inline std::shared_ptr SwizzleOp::Build(ExpressionPtr expressionPtr, std::initializer_list swizzleComponents) - { - auto node = std::make_shared(); - node->componentCount = swizzleComponents.size(); - node->expression = std::move(expressionPtr); - - std::copy(swizzleComponents.begin(), swizzleComponents.end(), node->components.begin()); - - return node; - } - - - inline Sample2D::Sample2D() : - Expression(NodeType::Sample2D) - { - } - - inline std::shared_ptr Sample2D::Build(ExpressionPtr samplerPtr, ExpressionPtr coordinatesPtr) - { - auto node = std::make_shared(); - node->coordinates = std::move(coordinatesPtr); - node->sampler = std::move(samplerPtr); - - return node; - } - - - inline BinaryFunc::BinaryFunc() : - Expression(NodeType::BinaryFunc) - { - } - - inline std::shared_ptr BinaryFunc::Build(BinaryIntrinsic intrinsic, ExpressionPtr left, ExpressionPtr right) - { - auto node = std::make_shared(); - node->intrinsic = intrinsic; - node->left = std::move(left); - node->right = std::move(right); - - return node; - } + assert(i < m_functions.size()); + return m_functions[i]; + } + + inline std::size_t ShaderAst::GetFunctionCount() const + { + return m_functions.size(); + } + + inline auto ShaderAst::GetFunctions() const -> const std::vector& + { + return m_functions; + } + + inline auto ShaderAst::GetInput(std::size_t i) const -> const InputOutput& + { + assert(i < m_inputs.size()); + return m_inputs[i]; + } + + inline std::size_t ShaderAst::GetInputCount() const + { + return m_inputs.size(); + } + + inline auto ShaderAst::GetInputs() const -> const std::vector& + { + return m_inputs; + } + + inline auto ShaderAst::GetOutput(std::size_t i) const -> const InputOutput& + { + assert(i < m_outputs.size()); + return m_outputs[i]; + } + + inline std::size_t ShaderAst::GetOutputCount() const + { + return m_outputs.size(); + } + + inline auto ShaderAst::GetOutputs() const -> const std::vector& + { + return m_outputs; + } + + inline auto ShaderAst::GetUniform(std::size_t i) const -> const Uniform& + { + assert(i < m_uniforms.size()); + return m_uniforms[i]; + } + + inline std::size_t ShaderAst::GetUniformCount() const + { + return m_uniforms.size(); + } + + inline auto ShaderAst::GetUniforms() const -> const std::vector& + { + return m_uniforms; } } diff --git a/include/Nazara/Renderer/ShaderBuilder.hpp b/include/Nazara/Renderer/ShaderBuilder.hpp index f8140ab42..cc437f45f 100644 --- a/include/Nazara/Renderer/ShaderBuilder.hpp +++ b/include/Nazara/Renderer/ShaderBuilder.hpp @@ -8,72 +8,66 @@ #define NAZARA_SHADER_BUILDER_HPP #include -#include +#include #include namespace Nz::ShaderBuilder { - template + template struct AssignOpBuilder { - constexpr AssignOpBuilder() {} + constexpr AssignOpBuilder() = default; - std::shared_ptr operator()(const ShaderAst::ExpressionPtr& left, const ShaderAst::ExpressionPtr& right) const; + std::shared_ptr operator()(const ShaderNodes::ExpressionPtr& left, const ShaderNodes::ExpressionPtr& right) const; }; - template + template struct BinOpBuilder { - constexpr BinOpBuilder() {} + constexpr BinOpBuilder() = default; - std::shared_ptr operator()(const ShaderAst::ExpressionPtr& left, const ShaderAst::ExpressionPtr& right) const; + std::shared_ptr operator()(const ShaderNodes::ExpressionPtr& left, const ShaderNodes::ExpressionPtr& right) const; }; struct BuiltinBuilder { - constexpr BuiltinBuilder() {} + constexpr BuiltinBuilder() = default; - inline std::shared_ptr operator()(ShaderAst::BuiltinEntry builtin) const; + inline std::shared_ptr operator()(ShaderNodes::BuiltinEntry builtin) const; }; template struct GenBuilder { - constexpr GenBuilder() {} + constexpr GenBuilder() = default; template std::shared_ptr operator()(Args&&... args) const; }; - template - struct VarBuilder - { - constexpr VarBuilder() {} - - template ShaderAst::NamedVariablePtr operator()(Args&&... args) const; - }; - - constexpr BinOpBuilder Add; - constexpr AssignOpBuilder Assign; + constexpr BinOpBuilder Add; + constexpr AssignOpBuilder Assign; constexpr BuiltinBuilder Builtin; - constexpr GenBuilder Block; - constexpr GenBuilder Branch; - constexpr GenBuilder ConditionalStatement; - constexpr GenBuilder Constant; - constexpr GenBuilder DeclareVariable; - constexpr BinOpBuilder Divide; - constexpr BinOpBuilder Equal; - constexpr GenBuilder ExprStatement; - constexpr VarBuilder Input; - constexpr BinOpBuilder Multiply; - constexpr VarBuilder Output; - constexpr VarBuilder Parameter; - constexpr GenBuilder Sample2D; - constexpr GenBuilder Swizzle; - constexpr BinOpBuilder Substract; - constexpr VarBuilder Uniform; - constexpr VarBuilder Variable; + constexpr GenBuilder Block; + constexpr GenBuilder Branch; + constexpr GenBuilder ConditionalStatement; + constexpr GenBuilder Constant; + constexpr GenBuilder DeclareVariable; + constexpr BinOpBuilder Divide; + constexpr BinOpBuilder Equal; + constexpr GenBuilder ExprStatement; + constexpr GenBuilder Identifier; + constexpr GenBuilder IntrinsicCall; + constexpr GenBuilder Input; + constexpr GenBuilder Local; + constexpr BinOpBuilder Multiply; + constexpr GenBuilder Output; + constexpr GenBuilder Parameter; + constexpr GenBuilder Sample2D; + constexpr GenBuilder Swizzle; + constexpr BinOpBuilder Substract; + constexpr GenBuilder Uniform; - template std::shared_ptr Cast(Args&&... args); + template std::shared_ptr Cast(Args&&... args); } #include diff --git a/include/Nazara/Renderer/ShaderBuilder.inl b/include/Nazara/Renderer/ShaderBuilder.inl index 7f9612a11..dda1d730b 100644 --- a/include/Nazara/Renderer/ShaderBuilder.inl +++ b/include/Nazara/Renderer/ShaderBuilder.inl @@ -14,45 +14,38 @@ namespace Nz::ShaderBuilder return T::Build(std::forward(args)...); } - template - std::shared_ptr AssignOpBuilder::operator()(const ShaderAst::ExpressionPtr& left, const ShaderAst::ExpressionPtr& right) const + template + std::shared_ptr AssignOpBuilder::operator()(const ShaderNodes::ExpressionPtr& left, const ShaderNodes::ExpressionPtr& right) const { - return ShaderAst::AssignOp::Build(op, left, right); + return ShaderNodes::AssignOp::Build(op, left, right); } - template - std::shared_ptr BinOpBuilder::operator()(const ShaderAst::ExpressionPtr& left, const ShaderAst::ExpressionPtr& right) const + template + std::shared_ptr BinOpBuilder::operator()(const ShaderNodes::ExpressionPtr& left, const ShaderNodes::ExpressionPtr& right) const { - return ShaderAst::BinaryOp::Build(op, left, right); + return ShaderNodes::BinaryOp::Build(op, left, right); } - inline std::shared_ptr BuiltinBuilder::operator()(ShaderAst::BuiltinEntry builtin) const + inline std::shared_ptr BuiltinBuilder::operator()(ShaderNodes::BuiltinEntry builtin) const { - ShaderAst::ExpressionType exprType = ShaderAst::ExpressionType::Void; + ShaderNodes::ExpressionType exprType = ShaderNodes::ExpressionType::Void; switch (builtin) { - case ShaderAst::BuiltinEntry::VertexPosition: - exprType = ShaderAst::ExpressionType::Float4; + case ShaderNodes::BuiltinEntry::VertexPosition: + exprType = ShaderNodes::ExpressionType::Float4; break; } - NazaraAssert(exprType != ShaderAst::ExpressionType::Void, "Unhandled builtin"); + NazaraAssert(exprType != ShaderNodes::ExpressionType::Void, "Unhandled builtin"); - return ShaderAst::BuiltinVariable::Build(builtin, exprType); + return ShaderNodes::BuiltinVariable::Build(builtin, exprType); } - template - template - ShaderAst::NamedVariablePtr VarBuilder::operator()(Args&&... args) const + template + std::shared_ptr Cast(Args&&... args) { - return ShaderAst::NamedVariable::Build(type, std::forward(args)...); - } - - template - std::shared_ptr Cast(Args&&... args) - { - return ShaderAst::Cast::Build(Type, std::forward(args)...); + return ShaderNodes::Cast::Build(Type, std::forward(args)...); } } diff --git a/include/Nazara/Renderer/ShaderEnums.hpp b/include/Nazara/Renderer/ShaderEnums.hpp new file mode 100644 index 000000000..f400c7516 --- /dev/null +++ b/include/Nazara/Renderer/ShaderEnums.hpp @@ -0,0 +1,99 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_SHADER_ENUMS_HPP +#define NAZARA_SHADER_ENUMS_HPP + +#include + +namespace Nz::ShaderNodes +{ + enum class AssignType + { + Simple //< = + }; + + enum class BinaryType + { + Add, //< + + Substract, //< - + Multiply, //< * + Divide, //< / + + Equality //< == + }; + + enum class BuiltinEntry + { + VertexPosition, // gl_Position + }; + + enum class ExpressionCategory + { + LValue, + RValue + }; + + enum class ExpressionType + { + Boolean, // bool + Float1, // float + Float2, // vec2 + Float3, // vec3 + Float4, // vec4 + Mat4x4, // mat4 + Sampler2D, // sampler2D + + Void // void + }; + + enum class IntrinsicType + { + CrossProduct, + DotProduct + }; + + enum class NodeType + { + None = -1, + + AssignOp, + BinaryOp, + Branch, + Cast, + Constant, + ConditionalStatement, + DeclareVariable, + ExpressionStatement, + Identifier, + IntrinsicCall, + Sample2D, + SwizzleOp, + StatementBlock + }; + + enum class SwizzleComponent + { + First, + Second, + Third, + Fourth + }; + + enum class VariableType + { + None = -1, + + BuiltinVariable, + InputVariable, + LocalVariable, + OutputVariable, + ParameterVariable, + UniformVariable + }; +} + +#endif // NAZARA_SHADER_ENUMS_HPP diff --git a/include/Nazara/Renderer/ShaderNodes.hpp b/include/Nazara/Renderer/ShaderNodes.hpp new file mode 100644 index 000000000..d6bafc911 --- /dev/null +++ b/include/Nazara/Renderer/ShaderNodes.hpp @@ -0,0 +1,272 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_SHADER_NODES_HPP +#define NAZARA_SHADER_NODES_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class ShaderVisitor; + + namespace ShaderNodes + { + class Node; + + using NodePtr = std::shared_ptr; + + class NAZARA_RENDERER_API Node + { + public: + virtual ~Node(); + + inline NodeType GetType() const; + + virtual void Visit(ShaderVisitor& visitor) = 0; + + static inline unsigned int GetComponentCount(ExpressionType type); + static inline ExpressionType GetComponentType(ExpressionType type); + + protected: + inline Node(NodeType type); + + private: + NodeType m_type; + }; + + class Statement; + + using StatementPtr = std::shared_ptr; + + class NAZARA_RENDERER_API Statement : public Node + { + public: + using Node::Node; + }; + + class Expression; + + using ExpressionPtr = std::shared_ptr; + + class NAZARA_RENDERER_API Expression : public Node + { + public: + using Node::Node; + + virtual ExpressionCategory GetExpressionCategory() const; + virtual ExpressionType GetExpressionType() const = 0; + }; + + struct NAZARA_RENDERER_API ExpressionStatement : public Statement + { + inline ExpressionStatement(); + + void Visit(ShaderVisitor& visitor) override; + + ExpressionPtr expression; + + static inline std::shared_ptr Build(ExpressionPtr expr); + }; + + ////////////////////////////////////////////////////////////////////////// + + struct NAZARA_RENDERER_API ConditionalStatement : public Statement + { + inline ConditionalStatement(); + + void Visit(ShaderVisitor& visitor) override; + + std::string conditionName; + StatementPtr statement; + + static inline std::shared_ptr Build(std::string condition, StatementPtr statementPtr); + }; + + struct NAZARA_RENDERER_API StatementBlock : public Statement + { + inline StatementBlock(); + + void Visit(ShaderVisitor& visitor) override; + + std::vector statements; + + template static std::shared_ptr Build(Args&&... args); + }; + + struct NAZARA_RENDERER_API DeclareVariable : public Statement + { + inline DeclareVariable(); + + void Visit(ShaderVisitor& visitor) override; + + LocalVariablePtr variable; + ExpressionPtr expression; + + static inline std::shared_ptr Build(LocalVariablePtr variable, ExpressionPtr expression = nullptr); + }; + + struct NAZARA_RENDERER_API Identifier : public Expression + { + inline Identifier(); + + ExpressionCategory GetExpressionCategory() const override; + ExpressionType GetExpressionType() const override; + void Visit(ShaderVisitor& visitor) override; + + VariablePtr var; + + static inline std::shared_ptr Build(VariablePtr variable); + }; + + ////////////////////////////////////////////////////////////////////////// + + struct NAZARA_RENDERER_API AssignOp : public Expression + { + inline AssignOp(); + + ExpressionType GetExpressionType() const override; + void Visit(ShaderVisitor& visitor) override; + + AssignType op; + ExpressionPtr left; + ExpressionPtr right; + + static inline std::shared_ptr Build(AssignType op, ExpressionPtr left, ExpressionPtr right); + }; + + struct NAZARA_RENDERER_API BinaryOp : public Expression + { + inline BinaryOp(); + + ExpressionType GetExpressionType() const override; + void Visit(ShaderVisitor& visitor) override; + + BinaryType op; + ExpressionPtr left; + ExpressionPtr right; + + static inline std::shared_ptr Build(BinaryType op, ExpressionPtr left, ExpressionPtr right); + }; + + struct NAZARA_RENDERER_API Branch : public Statement + { + struct ConditionalStatement; + + inline Branch(); + + void Visit(ShaderVisitor& visitor) override; + + std::vector condStatements; + StatementPtr elseStatement; + + struct ConditionalStatement + { + ExpressionPtr condition; + StatementPtr statement; + }; + + inline std::shared_ptr Build(ExpressionPtr condition, StatementPtr trueStatement, StatementPtr falseStatement = nullptr); + }; + + struct NAZARA_RENDERER_API Cast : public Expression + { + inline Cast(); + + ExpressionType GetExpressionType() const override; + void Visit(ShaderVisitor& visitor) override; + + ExpressionType exprType; + std::array expressions; + + static inline std::shared_ptr Build(ExpressionType castTo, ExpressionPtr first, ExpressionPtr second = nullptr, ExpressionPtr third = nullptr, ExpressionPtr fourth = nullptr); + static inline std::shared_ptr Build(ExpressionType castTo, ExpressionPtr* expressions, std::size_t expressionCount); + }; + + struct NAZARA_RENDERER_API Constant : public Expression + { + inline Constant(); + + ExpressionType GetExpressionType() const override; + void Visit(ShaderVisitor& visitor) override; + + ExpressionType exprType; + + union + { + bool bool1; + float vec1; + Vector2f vec2; + Vector3f vec3; + Vector4f vec4; + } values; + + static inline std::shared_ptr Build(bool value); + static inline std::shared_ptr Build(float value); + static inline std::shared_ptr Build(const Vector2f& value); + static inline std::shared_ptr Build(const Vector3f& value); + static inline std::shared_ptr Build(const Vector4f& value); + }; + + struct NAZARA_RENDERER_API SwizzleOp : public Expression + { + inline SwizzleOp(); + + ExpressionCategory GetExpressionCategory() const override; + ExpressionType GetExpressionType() const override; + void Visit(ShaderVisitor& visitor) override; + + std::array components; + std::size_t componentCount; + ExpressionPtr expression; + + static inline std::shared_ptr Build(ExpressionPtr expressionPtr, std::initializer_list swizzleComponents); + }; + + ////////////////////////////////////////////////////////////////////////// + + struct NAZARA_RENDERER_API Sample2D : public Expression + { + inline Sample2D(); + + ExpressionType GetExpressionType() const override; + void Visit(ShaderVisitor& visitor) override; + + ExpressionPtr sampler; + ExpressionPtr coordinates; + + static inline std::shared_ptr Build(ExpressionPtr samplerPtr, ExpressionPtr coordinatesPtr); + }; + + ////////////////////////////////////////////////////////////////////////// + + struct NAZARA_RENDERER_API IntrinsicCall : public Expression + { + inline IntrinsicCall(); + + ExpressionType GetExpressionType() const override; + void Visit(ShaderVisitor& visitor) override; + + IntrinsicType intrinsic; + std::vector parameters; + + static inline std::shared_ptr Build(IntrinsicType intrinsic, std::vector parameters); + }; + } +} + +#include + +#endif diff --git a/include/Nazara/Renderer/ShaderNodes.inl b/include/Nazara/Renderer/ShaderNodes.inl new file mode 100644 index 000000000..1bcf4effa --- /dev/null +++ b/include/Nazara/Renderer/ShaderNodes.inl @@ -0,0 +1,300 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz::ShaderNodes +{ + inline Node::Node(NodeType type) : + m_type(type) + { + } + + inline NodeType ShaderNodes::Node::GetType() const + { + return m_type; + } + + inline unsigned int Node::GetComponentCount(ExpressionType type) + { + switch (type) + { + case ExpressionType::Float2: + return 2; + + case ExpressionType::Float3: + return 3; + + case ExpressionType::Float4: + return 4; + + case ExpressionType::Mat4x4: + return 4; + + default: + return 1; + } + } + + inline ExpressionType Node::GetComponentType(ExpressionType type) + { + switch (type) + { + case ExpressionType::Float2: + case ExpressionType::Float3: + case ExpressionType::Float4: + return ExpressionType::Float1; + + case ExpressionType::Mat4x4: + return ExpressionType::Float4; + + default: + return type; + } + } + + inline ExpressionStatement::ExpressionStatement() : + Statement(NodeType::ExpressionStatement) + { + } + + inline std::shared_ptr ExpressionStatement::Build(ExpressionPtr expr) + { + auto node = std::make_shared(); + node->expression = std::move(expr); + + return node; + } + + inline ConditionalStatement::ConditionalStatement() : + Statement(NodeType::ConditionalStatement) + { + } + + inline std::shared_ptr ConditionalStatement::Build(std::string condition, StatementPtr statementPtr) + { + auto node = std::make_shared(); + node->conditionName = std::move(condition); + node->statement = std::move(statementPtr); + + return node; + } + + + inline StatementBlock::StatementBlock() : + Statement(NodeType::StatementBlock) + { + } + + template + std::shared_ptr StatementBlock::Build(Args&&... args) + { + auto node = std::make_shared(); + node->statements = std::vector({ std::forward(args)... }); + + return node; + } + + + inline DeclareVariable::DeclareVariable() : + Statement(NodeType::DeclareVariable) + { + } + + inline std::shared_ptr DeclareVariable::Build(LocalVariablePtr variable, ExpressionPtr expression) + { + auto node = std::make_shared(); + node->expression = std::move(expression); + node->variable = std::move(variable); + + return node; + } + + + inline Identifier::Identifier() : + Expression(NodeType::Identifier) + { + } + + inline std::shared_ptr Identifier::Build(VariablePtr variable) + { + auto node = std::make_shared(); + node->var = std::move(variable); + + return node; + } + + + inline AssignOp::AssignOp() : + Expression(NodeType::AssignOp) + { + } + + inline std::shared_ptr AssignOp::Build(AssignType op, ExpressionPtr left, ExpressionPtr right) + { + auto node = std::make_shared(); + node->op = op; + node->left = std::move(left); + node->right = std::move(right); + + return node; + } + + + inline BinaryOp::BinaryOp() : + Expression(NodeType::BinaryOp) + { + } + + inline std::shared_ptr BinaryOp::Build(BinaryType op, ExpressionPtr left, ExpressionPtr right) + { + auto node = std::make_shared(); + node->op = op; + node->left = std::move(left); + node->right = std::move(right); + + return node; + } + + + inline Branch::Branch() : + Statement(NodeType::Branch) + { + } + + inline std::shared_ptr Branch::Build(ExpressionPtr condition, StatementPtr trueStatement, StatementPtr falseStatement) + { + auto node = std::make_shared(); + node->condStatements.emplace_back(ConditionalStatement{ std::move(condition), std::move(trueStatement) }); + node->elseStatement = std::move(falseStatement); + + return node; + } + + + inline Cast::Cast() : + Expression(NodeType::Cast) + { + } + + inline std::shared_ptr Cast::Build(ExpressionType castTo, ExpressionPtr first, ExpressionPtr second, ExpressionPtr third, ExpressionPtr fourth) + { + auto node = std::make_shared(); + node->exprType = castTo; + node->expressions = { {first, second, third, fourth} }; + + return node; + } + + inline std::shared_ptr Cast::Build(ExpressionType castTo, ExpressionPtr* Expressions, std::size_t expressionCount) + { + auto node = std::make_shared(); + node->exprType = castTo; + for (std::size_t i = 0; i < expressionCount; ++i) + node->expressions[i] = Expressions[i]; + + return node; + } + + + inline Constant::Constant() : + Expression(NodeType::Constant) + { + } + + inline std::shared_ptr Constant::Build(bool value) + { + auto node = std::make_shared(); + node->exprType = ExpressionType::Boolean; + node->values.bool1 = value; + + return node; + } + + inline std::shared_ptr Constant::Build(float value) + { + auto node = std::make_shared(); + node->exprType = ExpressionType::Float1; + node->values.vec1 = value; + + return node; + } + + inline std::shared_ptr Constant::Build(const Vector2f& value) + { + auto node = std::make_shared(); + node->exprType = ExpressionType::Float2; + node->values.vec2 = value; + + return node; + } + + inline std::shared_ptr Constant::Build(const Vector3f& value) + { + auto node = std::make_shared(); + node->exprType = ExpressionType::Float3; + node->values.vec3 = value; + + return node; + } + + inline std::shared_ptr Constant::Build(const Vector4f& value) + { + auto node = std::make_shared(); + node->exprType = ExpressionType::Float4; + node->values.vec4 = value; + + return node; + } + + + inline SwizzleOp::SwizzleOp() : + Expression(NodeType::SwizzleOp) + { + } + + inline std::shared_ptr SwizzleOp::Build(ExpressionPtr expressionPtr, std::initializer_list swizzleComponents) + { + auto node = std::make_shared(); + node->componentCount = swizzleComponents.size(); + node->expression = std::move(expressionPtr); + + std::copy(swizzleComponents.begin(), swizzleComponents.end(), node->components.begin()); + + return node; + } + + + inline Sample2D::Sample2D() : + Expression(NodeType::Sample2D) + { + } + + inline std::shared_ptr Sample2D::Build(ExpressionPtr samplerPtr, ExpressionPtr coordinatesPtr) + { + auto node = std::make_shared(); + node->coordinates = std::move(coordinatesPtr); + node->sampler = std::move(samplerPtr); + + return node; + } + + + inline IntrinsicCall::IntrinsicCall() : + Expression(NodeType::IntrinsicCall) + { + } + + inline std::shared_ptr IntrinsicCall::Build(IntrinsicType intrinsic, std::vector parameters) + { + auto node = std::make_shared(); + node->intrinsic = intrinsic; + node->parameters = std::move(parameters); + + return node; + } +} + +#include diff --git a/include/Nazara/Renderer/ShaderSerializer.hpp b/include/Nazara/Renderer/ShaderSerializer.hpp index 521284370..daeb13e73 100644 --- a/include/Nazara/Renderer/ShaderSerializer.hpp +++ b/include/Nazara/Renderer/ShaderSerializer.hpp @@ -11,9 +11,10 @@ #include #include #include -#include +#include +#include -namespace Nz::ShaderAst +namespace Nz::ShaderNodes { class NAZARA_RENDERER_API ShaderSerializerBase { @@ -24,15 +25,16 @@ namespace Nz::ShaderAst ~ShaderSerializerBase() = default; void Serialize(AssignOp& node); - void Serialize(BinaryFunc& node); void Serialize(BinaryOp& node); + void Serialize(BuiltinVariable& var); void Serialize(Branch& node); - void Serialize(BuiltinVariable& node); void Serialize(Cast& node); void Serialize(Constant& node); void Serialize(DeclareVariable& node); void Serialize(ExpressionStatement& node); - void Serialize(NamedVariable& node); + void Serialize(Identifier& node); + void Serialize(IntrinsicCall& node); + void Serialize(NamedVariable& var); void Serialize(Sample2D& node); void Serialize(StatementBlock& node); void Serialize(SwizzleOp& node); @@ -54,6 +56,9 @@ namespace Nz::ShaderAst virtual void Value(Vector4f& val) = 0; virtual void Value(UInt32& val) = 0; inline void Value(std::size_t& val); + + virtual void Variable(VariablePtr& var) = 0; + template void Variable(std::shared_ptr& var); }; class NAZARA_RENDERER_API ShaderSerializer final : public ShaderSerializerBase @@ -74,6 +79,7 @@ namespace Nz::ShaderAst void Value(Vector3f& val) override; void Value(Vector4f& val) override; void Value(UInt32& val) override; + void Variable(VariablePtr& var) override; ByteArray& m_byteArray; ByteStream m_stream; @@ -89,7 +95,7 @@ namespace Nz::ShaderAst private: bool IsWriting() const override; - void Node(NodePtr & node) override; + void Node(NodePtr& node) override; void Value(bool& val) override; void Value(float& val) override; void Value(std::string& val) override; @@ -97,6 +103,7 @@ namespace Nz::ShaderAst void Value(Vector3f& val) override; void Value(Vector4f& val) override; void Value(UInt32& val) override; + void Variable(VariablePtr& var) override; const ByteArray& m_byteArray; ByteStream m_stream; diff --git a/include/Nazara/Renderer/ShaderSerializer.inl b/include/Nazara/Renderer/ShaderSerializer.inl index 2d8f5bc85..354986bb1 100644 --- a/include/Nazara/Renderer/ShaderSerializer.inl +++ b/include/Nazara/Renderer/ShaderSerializer.inl @@ -5,7 +5,7 @@ #include #include -namespace Nz::ShaderAst +namespace Nz::ShaderNodes { template void ShaderSerializerBase::Container(T& container) @@ -37,7 +37,7 @@ namespace Nz::ShaderAst } template - inline void ShaderSerializerBase::Node(std::shared_ptr& node) + void ShaderSerializerBase::Node(std::shared_ptr& node) { bool isWriting = IsWriting(); @@ -50,6 +50,20 @@ namespace Nz::ShaderAst node = std::static_pointer_cast(value); } + template + void ShaderSerializerBase::Variable(std::shared_ptr& var) + { + bool isWriting = IsWriting(); + + VariablePtr value; + if (isWriting) + value = var; + + Variable(value); + if (!isWriting) + var = std::static_pointer_cast(value); + } + inline void ShaderSerializerBase::Value(std::size_t& val) { bool isWriting = IsWriting(); diff --git a/include/Nazara/Renderer/ShaderValidator.hpp b/include/Nazara/Renderer/ShaderValidator.hpp index 50075aaf0..bfdab9844 100644 --- a/include/Nazara/Renderer/ShaderValidator.hpp +++ b/include/Nazara/Renderer/ShaderValidator.hpp @@ -13,40 +13,47 @@ #include #include -namespace Nz::ShaderAst +namespace Nz { + class ShaderAst; + class NAZARA_RENDERER_API ShaderValidator : public ShaderVisitor { public: - ShaderValidator() = default; + inline ShaderValidator(const ShaderAst& shader); ShaderValidator(const ShaderValidator&) = delete; ShaderValidator(ShaderValidator&&) = delete; ~ShaderValidator() = default; - bool Validate(const StatementPtr& shader, std::string* error = nullptr); + bool Validate(std::string* error = nullptr); private: - const ExpressionPtr& MandatoryExpr(const ExpressionPtr& node); - const NodePtr& MandatoryNode(const NodePtr& node); - void TypeMustMatch(const ExpressionPtr& left, const ExpressionPtr& right); + const ShaderNodes::ExpressionPtr& MandatoryExpr(const ShaderNodes::ExpressionPtr& node); + const ShaderNodes::NodePtr& MandatoryNode(const ShaderNodes::NodePtr& node); + void TypeMustMatch(const ShaderNodes::ExpressionPtr& left, const ShaderNodes::ExpressionPtr& right); + void TypeMustMatch(ShaderNodes::ExpressionType left, ShaderNodes::ExpressionType right); using ShaderVisitor::Visit; - void Visit(const AssignOp& node) override; - void Visit(const BinaryFunc& node) override; - void Visit(const BinaryOp& node) override; - void Visit(const Branch& node) override; - void Visit(const BuiltinVariable& node) override; - void Visit(const Cast& node) override; - void Visit(const Constant& node) override; - void Visit(const DeclareVariable& node) override; - void Visit(const ExpressionStatement& node) override; - void Visit(const NamedVariable& node) override; - void Visit(const Sample2D& node) override; - void Visit(const StatementBlock& node) override; - void Visit(const SwizzleOp& node) override; + void Visit(const ShaderNodes::AssignOp& node) override; + void Visit(const ShaderNodes::BinaryOp& node) override; + void Visit(const ShaderNodes::Branch& node) override; + void Visit(const ShaderNodes::Cast& node) override; + void Visit(const ShaderNodes::Constant& node) override; + void Visit(const ShaderNodes::DeclareVariable& node) override; + void Visit(const ShaderNodes::ExpressionStatement& node) override; + void Visit(const ShaderNodes::Identifier& node) override; + void Visit(const ShaderNodes::IntrinsicCall& node) override; + void Visit(const ShaderNodes::Sample2D& node) override; + void Visit(const ShaderNodes::StatementBlock& node) override; + void Visit(const ShaderNodes::SwizzleOp& node) override; + + struct Context; + + const ShaderAst& m_shader; + Context* m_context; }; - NAZARA_RENDERER_API bool Validate(const StatementPtr& shader, std::string* error = nullptr); + NAZARA_RENDERER_API bool ValidateShader(const ShaderAst& shader, std::string* error = nullptr); } #include diff --git a/include/Nazara/Renderer/ShaderValidator.inl b/include/Nazara/Renderer/ShaderValidator.inl index 2fb43d576..e609a144a 100644 --- a/include/Nazara/Renderer/ShaderValidator.inl +++ b/include/Nazara/Renderer/ShaderValidator.inl @@ -5,8 +5,12 @@ #include #include -namespace Nz::ShaderAst +namespace Nz { + ShaderValidator::ShaderValidator(const ShaderAst& shader) : + m_shader(shader) + { + } } #include diff --git a/include/Nazara/Renderer/ShaderVarVisitor.hpp b/include/Nazara/Renderer/ShaderVarVisitor.hpp new file mode 100644 index 000000000..6df035d74 --- /dev/null +++ b/include/Nazara/Renderer/ShaderVarVisitor.hpp @@ -0,0 +1,34 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_SHADERVARVISITOR_HPP +#define NAZARA_SHADERVARVISITOR_HPP + +#include +#include +#include + +namespace Nz +{ + class NAZARA_RENDERER_API ShaderVarVisitor + { + public: + ShaderVarVisitor() = default; + ShaderVarVisitor(const ShaderVarVisitor&) = delete; + ShaderVarVisitor(ShaderVarVisitor&&) = delete; + virtual ~ShaderVarVisitor(); + + virtual void Visit(const ShaderNodes::BuiltinVariable& var) = 0; + virtual void Visit(const ShaderNodes::InputVariable& var) = 0; + virtual void Visit(const ShaderNodes::LocalVariable& var) = 0; + virtual void Visit(const ShaderNodes::OutputVariable& var) = 0; + virtual void Visit(const ShaderNodes::ParameterVariable& var) = 0; + virtual void Visit(const ShaderNodes::UniformVariable& var) = 0; + void Visit(const ShaderNodes::VariablePtr& node); + }; +} + +#endif diff --git a/include/Nazara/Renderer/ShaderVariables.hpp b/include/Nazara/Renderer/ShaderVariables.hpp new file mode 100644 index 000000000..242f129db --- /dev/null +++ b/include/Nazara/Renderer/ShaderVariables.hpp @@ -0,0 +1,127 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_SHADER_VARIABLES_HPP +#define NAZARA_SHADER_VARIABLES_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class ShaderVarVisitor; + + namespace ShaderNodes + { + struct Variable; + + using VariablePtr = std::shared_ptr; + + struct NAZARA_RENDERER_API Variable + { + virtual ~Variable(); + + virtual VariableType GetType() const = 0; + virtual void Visit(ShaderVarVisitor& visitor) = 0; + + ExpressionType type; + }; + + struct BuiltinVariable; + + using BuiltinVariablePtr = std::shared_ptr; + + struct NAZARA_RENDERER_API BuiltinVariable : public Variable + { + BuiltinEntry entry; + + VariableType GetType() const override; + void Visit(ShaderVarVisitor& visitor) override; + + static inline std::shared_ptr Build(BuiltinEntry entry, ExpressionType varType); + }; + + struct NamedVariable; + + using NamedVariablePtr = std::shared_ptr; + + struct NAZARA_RENDERER_API NamedVariable : public Variable + { + std::string name; + }; + + struct InputVariable; + + using InputVariablePtr = std::shared_ptr; + + struct NAZARA_RENDERER_API InputVariable : public NamedVariable + { + VariableType GetType() const override; + void Visit(ShaderVarVisitor& visitor) override; + + static inline std::shared_ptr Build(std::string varName, ExpressionType varType); + }; + + struct LocalVariable; + + using LocalVariablePtr = std::shared_ptr; + + struct NAZARA_RENDERER_API LocalVariable : public NamedVariable + { + VariableType GetType() const override; + void Visit(ShaderVarVisitor& visitor) override; + + static inline std::shared_ptr Build(std::string varName, ExpressionType varType); + }; + + struct OutputVariable; + + using OutputVariablePtr = std::shared_ptr; + + struct NAZARA_RENDERER_API OutputVariable : public NamedVariable + { + VariableType GetType() const override; + void Visit(ShaderVarVisitor& visitor) override; + + static inline std::shared_ptr Build(std::string varName, ExpressionType varType); + }; + + struct ParameterVariable; + + using ParameterVariablePtr = std::shared_ptr; + + struct NAZARA_RENDERER_API ParameterVariable : public NamedVariable + { + VariableType GetType() const override; + void Visit(ShaderVarVisitor& visitor) override; + + static inline std::shared_ptr Build(std::string varName, ExpressionType varType); + }; + + struct UniformVariable; + + using UniformVariablePtr = std::shared_ptr; + + struct NAZARA_RENDERER_API UniformVariable : public NamedVariable + { + VariableType GetType() const override; + void Visit(ShaderVarVisitor& visitor) override; + + static inline std::shared_ptr Build(std::string varName, ExpressionType varType); + }; + } +} + +#include + +#endif diff --git a/include/Nazara/Renderer/ShaderVariables.inl b/include/Nazara/Renderer/ShaderVariables.inl new file mode 100644 index 000000000..d20c9d6ea --- /dev/null +++ b/include/Nazara/Renderer/ShaderVariables.inl @@ -0,0 +1,65 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz::ShaderNodes +{ + inline std::shared_ptr BuiltinVariable::Build(BuiltinEntry variable, ExpressionType varType) + { + auto node = std::make_shared(); + node->entry = variable; + node->type = varType; + + return node; + } + + inline std::shared_ptr InputVariable::Build(std::string varName, ExpressionType varType) + { + auto node = std::make_shared(); + node->name = std::move(varName); + node->type = varType; + + return node; + } + + inline std::shared_ptr LocalVariable::Build(std::string varName, ExpressionType varType) + { + auto node = std::make_shared(); + node->name = std::move(varName); + node->type = varType; + + return node; + } + + inline std::shared_ptr OutputVariable::Build(std::string varName, ExpressionType varType) + { + auto node = std::make_shared(); + node->name = std::move(varName); + node->type = varType; + + return node; + } + + inline std::shared_ptr ParameterVariable::Build(std::string varName, ExpressionType varType) + { + auto node = std::make_shared(); + node->name = std::move(varName); + node->type = varType; + + return node; + } + + inline std::shared_ptr UniformVariable::Build(std::string varName, ExpressionType varType) + { + auto node = std::make_shared(); + node->name = std::move(varName); + node->type = varType; + + return node; + } +} + +#include diff --git a/include/Nazara/Renderer/ShaderVisitor.hpp b/include/Nazara/Renderer/ShaderVisitor.hpp index 47a5741f4..9db22882c 100644 --- a/include/Nazara/Renderer/ShaderVisitor.hpp +++ b/include/Nazara/Renderer/ShaderVisitor.hpp @@ -8,9 +8,9 @@ #define NAZARA_SHADERVISITOR_HPP #include -#include #include -#include +#include +#include #include namespace Nz @@ -23,27 +23,26 @@ namespace Nz ShaderVisitor(ShaderVisitor&&) = delete; virtual ~ShaderVisitor(); - void EnableCondition(const String& name, bool cond); + void EnableCondition(const std::string& name, bool cond); - bool IsConditionEnabled(const String& name) const; + bool IsConditionEnabled(const std::string& name) const; - virtual void Visit(const ShaderAst::AssignOp& node) = 0; - virtual void Visit(const ShaderAst::BinaryFunc& node) = 0; - virtual void Visit(const ShaderAst::BinaryOp& node) = 0; - virtual void Visit(const ShaderAst::Branch& node) = 0; - virtual void Visit(const ShaderAst::BuiltinVariable& node) = 0; - virtual void Visit(const ShaderAst::Cast& node) = 0; - virtual void Visit(const ShaderAst::Constant& node) = 0; - virtual void Visit(const ShaderAst::DeclareVariable& node) = 0; - virtual void Visit(const ShaderAst::ExpressionStatement& node) = 0; - virtual void Visit(const ShaderAst::NamedVariable& node) = 0; - void Visit(const ShaderAst::NodePtr& node); - virtual void Visit(const ShaderAst::Sample2D& node) = 0; - virtual void Visit(const ShaderAst::StatementBlock& node) = 0; - virtual void Visit(const ShaderAst::SwizzleOp& node) = 0; + virtual void Visit(const ShaderNodes::AssignOp& node) = 0; + virtual void Visit(const ShaderNodes::BinaryOp& node) = 0; + virtual void Visit(const ShaderNodes::Branch& node) = 0; + virtual void Visit(const ShaderNodes::Cast& node) = 0; + virtual void Visit(const ShaderNodes::Constant& node) = 0; + virtual void Visit(const ShaderNodes::DeclareVariable& node) = 0; + virtual void Visit(const ShaderNodes::ExpressionStatement& node) = 0; + virtual void Visit(const ShaderNodes::Identifier& node) = 0; + virtual void Visit(const ShaderNodes::IntrinsicCall& node) = 0; + void Visit(const ShaderNodes::NodePtr& node); + virtual void Visit(const ShaderNodes::Sample2D& node) = 0; + virtual void Visit(const ShaderNodes::StatementBlock& node) = 0; + virtual void Visit(const ShaderNodes::SwizzleOp& node) = 0; private: - std::unordered_set m_conditions; + std::unordered_set m_conditions; }; } diff --git a/include/Nazara/Renderer/ShaderWriter.hpp b/include/Nazara/Renderer/ShaderWriter.hpp index ae00f2fa5..6c2655226 100644 --- a/include/Nazara/Renderer/ShaderWriter.hpp +++ b/include/Nazara/Renderer/ShaderWriter.hpp @@ -8,24 +8,22 @@ #define NAZARA_SHADERWRITER_HPP #include -#include #include -#include +#include namespace Nz { - class NAZARA_RENDERER_API ShaderWriter : public ShaderVisitor + class ShaderAst; + + class NAZARA_RENDERER_API ShaderWriter { public: ShaderWriter() = default; ShaderWriter(const ShaderWriter&) = delete; ShaderWriter(ShaderWriter&&) = delete; - ~ShaderWriter() = default; + virtual ~ShaderWriter(); - virtual Nz::String Generate(const ShaderAst::StatementPtr& node) = 0; - - virtual void RegisterFunction(const String& name, ShaderAst::StatementPtr node, std::initializer_list parameters, ShaderAst::ExpressionType ret) = 0; - virtual void RegisterVariable(ShaderAst::VariableType kind, const String& name, ShaderAst::ExpressionType type) = 0; + virtual std::string Generate(const ShaderAst& shader) = 0; }; } diff --git a/src/Nazara/Renderer/GlslWriter.cpp b/src/Nazara/Renderer/GlslWriter.cpp index b982dab90..8d8e024e7 100644 --- a/src/Nazara/Renderer/GlslWriter.cpp +++ b/src/Nazara/Renderer/GlslWriter.cpp @@ -11,16 +11,15 @@ namespace Nz { GlslWriter::GlslWriter() : - m_currentFunction(nullptr), m_currentState(nullptr), m_glslVersion(110) { } - String GlslWriter::Generate(const ShaderAst::StatementPtr& node) + std::string GlslWriter::Generate(const ShaderAst& shader) { std::string error; - if (!ShaderAst::Validate(node, &error)) + if (!ValidateShader(shader, &error)) throw std::runtime_error("Invalid shader AST: " + error); State state; @@ -30,91 +29,54 @@ namespace Nz m_currentState = nullptr; }); - // Register global variables (uniforms, varying, ..) - node->Register(*this); - // Header Append("#version "); - AppendLine(String::Number(m_glslVersion)); + AppendLine(std::to_string(m_glslVersion)); AppendLine(); - // Global variables (uniforms, input and outputs) - DeclareVariables(state.uniforms, "uniform", "Uniforms"); - DeclareVariables(state.inputs, "in", "Inputs"); - DeclareVariables(state.outputs, "out", "Outputs"); + // Extensions - Function entryPoint; - entryPoint.name = "main"; //< GLSL has only one entry point name possible - entryPoint.node = node; - entryPoint.retType = ShaderAst::ExpressionType::Void; + std::vector requiredExtensions; - AppendFunction(entryPoint); + // GL_ARB_shading_language_420pack (required for layout(binding = X)) + if (m_glslVersion < 420 && HasExplicitBinding(shader)) + requiredExtensions.emplace_back("GL_ARB_shading_language_420pack"); - return state.stream; - } + // GL_ARB_explicit_uniform_location (required for layout(location = X)) + if (m_glslVersion < 430 && HasExplicitLocation(shader)) + requiredExtensions.emplace_back("GL_ARB_explicit_uniform_location"); - void GlslWriter::RegisterFunction(const String& name, ShaderAst::StatementPtr statement, std::initializer_list parameters, ShaderAst::ExpressionType retType) - { - Function func; - func.retType = retType; - func.name = name; - func.node = std::move(statement); - func.parameters.assign(parameters); - - m_functions[name] = std::move(func); - } - - void GlslWriter::RegisterVariable(ShaderAst::VariableType kind, const String& name, ShaderAst::ExpressionType type) - { - NazaraAssert(m_currentState, "This function should only be called while processing an AST"); - NazaraAssert(kind != ShaderAst::VariableType::Builtin, "Builtin variables should not be registered"); - - switch (kind) + if (!requiredExtensions.empty()) { - case ShaderAst::VariableType::Builtin: //< Only there to make compiler happy - case ShaderAst::VariableType::Variable: - break; + for (const std::string& ext : requiredExtensions) + AppendLine("#extension " + ext + " : require"); - case ShaderAst::VariableType::Input: - m_currentState->inputs.emplace(type, name); - break; - - case ShaderAst::VariableType::Output: - m_currentState->outputs.emplace(type, name); - break; - - case ShaderAst::VariableType::Parameter: - { - if (m_currentFunction) - { - bool found = false; - for (const auto& varPtr : m_currentFunction->parameters) - { - if (varPtr->name == name) - { - found = true; - if (varPtr->type != type) - { - //TODO: AstParseError - throw std::runtime_error("Function uses parameter \"" + name.ToStdString() + "\" with a different type than specified in the function arguments"); - } - - break; - } - } - - if (!found) - //TODO: AstParseError - throw std::runtime_error("Function has no parameter \"" + name.ToStdString() + "\""); - } - - break; - } - - case ShaderAst::VariableType::Uniform: - m_currentState->uniforms.emplace(type, name); - break; + AppendLine(); } + + // Global variables (uniforms, input and outputs) + DeclareVariables(shader.GetUniforms(), "uniform", "Uniforms"); + DeclareVariables(shader.GetInputs(), "in", "Inputs"); + DeclareVariables(shader.GetOutputs(), "out", "Outputs"); + + std::size_t functionCount = shader.GetFunctionCount(); + if (functionCount > 1) + { + AppendCommentSection("Prototypes"); + for (const auto& func : shader.GetFunctions()) + { + if (func.name != "main") + { + AppendFunctionPrototype(func); + AppendLine(";"); + } + } + } + + for (const auto& func : shader.GetFunctions()) + AppendFunction(func); + + return state.stream.str(); } void GlslWriter::SetGlslVersion(unsigned int version) @@ -122,22 +84,127 @@ namespace Nz m_glslVersion = version; } - void GlslWriter::Visit(const ShaderAst::Sample2D& node) + void GlslWriter::Append(ShaderNodes::BuiltinEntry builtin) { - Append("texture("); - Visit(node.sampler); - Append(", "); - Visit(node.coordinates); - Append(")"); + switch (builtin) + { + case ShaderNodes::BuiltinEntry::VertexPosition: + Append("gl_Position"); + break; + } } - void GlslWriter::Visit(const ShaderAst::AssignOp& node) + void GlslWriter::Append(ShaderNodes::ExpressionType type) + { + switch (type) + { + case ShaderNodes::ExpressionType::Boolean: + Append("bool"); + break; + case ShaderNodes::ExpressionType::Float1: + Append("float"); + break; + case ShaderNodes::ExpressionType::Float2: + Append("vec2"); + break; + case ShaderNodes::ExpressionType::Float3: + Append("vec3"); + break; + case ShaderNodes::ExpressionType::Float4: + Append("vec4"); + break; + case ShaderNodes::ExpressionType::Mat4x4: + Append("mat4"); + break; + case ShaderNodes::ExpressionType::Sampler2D: + Append("sampler2D"); + break; + case ShaderNodes::ExpressionType::Void: + Append("void"); + break; + } + } + + void GlslWriter::AppendCommentSection(const std::string& section) + { + NazaraAssert(m_currentState, "This function should only be called while processing an AST"); + + String stars((section.size() < 33) ? (36 - section.size()) / 2 : 3, '*'); + m_currentState->stream << "/*" << stars << ' ' << section << ' ' << stars << "*/"; + AppendLine(); + } + + void GlslWriter::AppendFunction(const ShaderAst::Function& func) + { + NazaraAssert(!m_context.currentFunction, "A function is already being processed"); + NazaraAssert(m_currentState, "This function should only be called while processing an AST"); + + AppendFunctionPrototype(func); + + m_context.currentFunction = &func; + CallOnExit onExit([this] () + { + m_context.currentFunction = nullptr; + }); + + EnterScope(); + { + Visit(func.statement); + } + LeaveScope(); + } + + void GlslWriter::AppendFunctionPrototype(const ShaderAst::Function& func) + { + Append(func.returnType); + + Append(" "); + Append(func.name); + + Append("("); + for (std::size_t i = 0; i < func.parameters.size(); ++i) + { + if (i != 0) + Append(", "); + + Append(func.parameters[i].type); + Append(" "); + Append(func.parameters[i].name); + } + Append(")\n"); + } + + void GlslWriter::AppendLine(const std::string& txt) + { + NazaraAssert(m_currentState, "This function should only be called while processing an AST"); + + m_currentState->stream << txt << '\n' << std::string(m_currentState->indentLevel, '\t'); + } + + void GlslWriter::EnterScope() + { + NazaraAssert(m_currentState, "This function should only be called while processing an AST"); + + m_currentState->indentLevel++; + AppendLine("{"); + } + + void GlslWriter::LeaveScope() + { + NazaraAssert(m_currentState, "This function should only be called while processing an AST"); + + m_currentState->indentLevel--; + AppendLine(); + AppendLine("}"); + } + + void GlslWriter::Visit(const ShaderNodes::AssignOp& node) { Visit(node.left); switch (node.op) { - case ShaderAst::AssignType::Simple: + case ShaderNodes::AssignType::Simple: Append(" = "); break; } @@ -145,7 +212,7 @@ namespace Nz Visit(node.right); } - void GlslWriter::Visit(const ShaderAst::Branch& node) + void GlslWriter::Visit(const ShaderNodes::Branch& node) { bool first = true; for (const auto& statement : node.condStatements) @@ -174,45 +241,25 @@ namespace Nz } } - void GlslWriter::Visit(const ShaderAst::BinaryFunc& node) - { - switch (node.intrinsic) - { - case ShaderAst::BinaryIntrinsic::CrossProduct: - Append("cross"); - break; - - case ShaderAst::BinaryIntrinsic::DotProduct: - Append("dot"); - break; - } - - Append("("); - Visit(node.left); - Append(", "); - Visit(node.right); - Append(")"); - } - - void GlslWriter::Visit(const ShaderAst::BinaryOp& node) + void GlslWriter::Visit(const ShaderNodes::BinaryOp& node) { Visit(node.left); switch (node.op) { - case ShaderAst::BinaryType::Add: + case ShaderNodes::BinaryType::Add: Append(" + "); break; - case ShaderAst::BinaryType::Substract: + case ShaderNodes::BinaryType::Substract: Append(" - "); break; - case ShaderAst::BinaryType::Multiply: + case ShaderNodes::BinaryType::Multiply: Append(" * "); break; - case ShaderAst::BinaryType::Divide: + case ShaderNodes::BinaryType::Divide: Append(" / "); break; - case ShaderAst::BinaryType::Equality: + case ShaderNodes::BinaryType::Equality: Append(" == "); break; } @@ -220,18 +267,18 @@ namespace Nz Visit(node.right); } - void GlslWriter::Visit(const ShaderAst::BuiltinVariable& node) + void GlslWriter::Visit(const ShaderNodes::BuiltinVariable& var) { - Append(node.var); + Append(var.type); } - void GlslWriter::Visit(const ShaderAst::Cast& node) + void GlslWriter::Visit(const ShaderNodes::Cast& node) { Append(node.exprType); Append("("); unsigned int i = 0; - unsigned int requiredComponents = ShaderAst::Node::GetComponentCount(node.exprType); + unsigned int requiredComponents = ShaderNodes::Node::GetComponentCount(node.exprType); while (requiredComponents > 0) { if (i != 0) @@ -241,34 +288,34 @@ namespace Nz NazaraAssert(exprPtr, "Invalid expression"); Visit(exprPtr); - requiredComponents -= ShaderAst::Node::GetComponentCount(exprPtr->GetExpressionType()); + requiredComponents -= ShaderNodes::Node::GetComponentCount(exprPtr->GetExpressionType()); } Append(")"); } - void GlslWriter::Visit(const ShaderAst::Constant& node) + void GlslWriter::Visit(const ShaderNodes::Constant& node) { switch (node.exprType) { - case ShaderAst::ExpressionType::Boolean: + case ShaderNodes::ExpressionType::Boolean: Append((node.values.bool1) ? "true" : "false"); break; - case ShaderAst::ExpressionType::Float1: - Append(String::Number(node.values.vec1)); + case ShaderNodes::ExpressionType::Float1: + Append(std::to_string(node.values.vec1)); break; - case ShaderAst::ExpressionType::Float2: - Append("vec2(" + String::Number(node.values.vec2.x) + ", " + String::Number(node.values.vec2.y) + ")"); + case ShaderNodes::ExpressionType::Float2: + Append("vec2(" + std::to_string(node.values.vec2.x) + ", " + std::to_string(node.values.vec2.y) + ")"); break; - case ShaderAst::ExpressionType::Float3: - Append("vec3(" + String::Number(node.values.vec3.x) + ", " + String::Number(node.values.vec3.y) + ", " + String::Number(node.values.vec3.z) + ")"); + case ShaderNodes::ExpressionType::Float3: + Append("vec3(" + std::to_string(node.values.vec3.x) + ", " + std::to_string(node.values.vec3.y) + ", " + std::to_string(node.values.vec3.z) + ")"); break; - case ShaderAst::ExpressionType::Float4: - Append("vec4(" + String::Number(node.values.vec4.x) + ", " + String::Number(node.values.vec4.y) + ", " + String::Number(node.values.vec4.z) + ", " + String::Number(node.values.vec4.w) + ")"); + case ShaderNodes::ExpressionType::Float4: + Append("vec4(" + std::to_string(node.values.vec4.x) + ", " + std::to_string(node.values.vec4.y) + ", " + std::to_string(node.values.vec4.z) + ", " + std::to_string(node.values.vec4.w) + ")"); break; default: @@ -276,9 +323,9 @@ namespace Nz } } - void GlslWriter::Visit(const ShaderAst::DeclareVariable& node) + void GlslWriter::Visit(const ShaderNodes::DeclareVariable& node) { - Append(node.variable->GetExpressionType()); + Append(node.variable->type); Append(" "); Append(node.variable->name); if (node.expression) @@ -292,21 +339,76 @@ namespace Nz AppendLine(";"); } - void GlslWriter::Visit(const ShaderAst::ExpressionStatement& node) + void GlslWriter::Visit(const ShaderNodes::ExpressionStatement& node) { Visit(node.expression); Append(";"); } - void GlslWriter::Visit(const ShaderAst::NamedVariable& node) + void GlslWriter::Visit(const ShaderNodes::Identifier& node) { - Append(node.name); + Visit(node.var); } - void GlslWriter::Visit(const ShaderAst::StatementBlock& node) + void GlslWriter::Visit(const ShaderNodes::InputVariable& var) + { + Append(var.name); + } + + void GlslWriter::Visit(const ShaderNodes::IntrinsicCall& node) + { + switch (node.intrinsic) + { + case ShaderNodes::IntrinsicType::CrossProduct: + Append("cross"); + break; + + case ShaderNodes::IntrinsicType::DotProduct: + Append("dot"); + break; + } + + m_currentState->stream << '('; + for (std::size_t i = 0; i < node.parameters.size(); ++i) + { + if (i != 0) + m_currentState->stream << ", "; + + Visit(node.parameters[i]); + m_currentState->stream << ' '; + Visit(node.parameters[i]); + } + m_currentState->stream << ")\n"; + } + + void GlslWriter::Visit(const ShaderNodes::LocalVariable& var) + { + Append(var.name); + } + + void GlslWriter::Visit(const ShaderNodes::ParameterVariable& var) + { + Append(var.name); + } + + void GlslWriter::Visit(const ShaderNodes::OutputVariable& var) + { + Append(var.name); + } + + void GlslWriter::Visit(const ShaderNodes::Sample2D& node) + { + Append("texture("); + Visit(node.sampler); + Append(", "); + Visit(node.coordinates); + Append(")"); + } + + void GlslWriter::Visit(const ShaderNodes::StatementBlock& node) { bool first = true; - for (const ShaderAst::StatementPtr& statement : node.statements) + for (const ShaderNodes::StatementPtr& statement : node.statements) { if (!first) AppendLine(); @@ -317,7 +419,7 @@ namespace Nz } } - void GlslWriter::Visit(const ShaderAst::SwizzleOp& node) + void GlslWriter::Visit(const ShaderNodes::SwizzleOp& node) { Visit(node.expression); Append("."); @@ -326,166 +428,55 @@ namespace Nz { switch (node.components[i]) { - case ShaderAst::SwizzleComponent::First: + case ShaderNodes::SwizzleComponent::First: Append("x"); break; - case ShaderAst::SwizzleComponent::Second: + case ShaderNodes::SwizzleComponent::Second: Append("y"); break; - case ShaderAst::SwizzleComponent::Third: + case ShaderNodes::SwizzleComponent::Third: Append("z"); break; - case ShaderAst::SwizzleComponent::Fourth: + case ShaderNodes::SwizzleComponent::Fourth: Append("w"); break; } } } - void GlslWriter::Append(ShaderAst::BuiltinEntry builtin) + void GlslWriter::Visit(const ShaderNodes::UniformVariable& var) { - switch (builtin) + Append(var.name); + } + + bool GlslWriter::HasExplicitBinding(const ShaderAst& shader) + { + for (const auto& uniform : shader.GetUniforms()) { - case ShaderAst::BuiltinEntry::VertexPosition: - Append("gl_Position"); - break; + if (uniform.bindingIndex.has_value()) + return true; } + + return false; } - void GlslWriter::Append(ShaderAst::ExpressionType type) + bool GlslWriter::HasExplicitLocation(const ShaderAst& shader) { - switch (type) + for (const auto& input : shader.GetInputs()) { - case ShaderAst::ExpressionType::Boolean: - Append("bool"); - break; - case ShaderAst::ExpressionType::Float1: - Append("float"); - break; - case ShaderAst::ExpressionType::Float2: - Append("vec2"); - break; - case ShaderAst::ExpressionType::Float3: - Append("vec3"); - break; - case ShaderAst::ExpressionType::Float4: - Append("vec4"); - break; - case ShaderAst::ExpressionType::Mat4x4: - Append("mat4"); - break; - case ShaderAst::ExpressionType::Sampler2D: - Append("sampler2D"); - break; - case ShaderAst::ExpressionType::Void: - Append("void"); - break; + if (input.locationIndex.has_value()) + return true; } - } - void GlslWriter::Append(const String& txt) - { - NazaraAssert(m_currentState, "This function should only be called while processing an AST"); - - m_currentState->stream << txt; - } - - void GlslWriter::AppendCommentSection(const String& section) - { - NazaraAssert(m_currentState, "This function should only be called while processing an AST"); - - String stars((section.GetSize() < 33) ? (36 - section.GetSize()) / 2 : 3, '*'); - m_currentState->stream << "/*" << stars << ' ' << section << ' ' << stars << "*/"; - AppendLine(); - } - - void GlslWriter::AppendFunction(Function& func) - { - NazaraAssert(!m_currentFunction, "A function is already being processed"); - NazaraAssert(m_currentState, "This function should only be called while processing an AST"); - - m_currentFunction = &func; - CallOnExit onExit([this] () + for (const auto& output : shader.GetOutputs()) { - m_currentFunction = nullptr; - }); - - func.node->Register(*this); - - Append(func.retType); - - m_currentState->stream << ' '; - Append(func.name); - - m_currentState->stream << '('; - for (std::size_t i = 0; i < func.parameters.size(); ++i) - { - if (i != 0) - m_currentState->stream << ", "; - - Append(func.parameters[i]->type); - m_currentState->stream << ' '; - Append(func.parameters[i]->name); + if (output.locationIndex.has_value()) + return true; } - m_currentState->stream << ")\n"; - EnterScope(); - { - Visit(func.node); - } - LeaveScope(); + return false; } - - void GlslWriter::AppendLine(const String& txt) - { - NazaraAssert(m_currentState, "This function should only be called while processing an AST"); - - m_currentState->stream << txt << '\n' << String(m_currentState->indentLevel, '\t'); - } - - void GlslWriter::DeclareVariables(const VariableContainer& variables, const String& keyword, const String& section) - { - if (!variables.empty()) - { - if (!section.IsEmpty()) - AppendCommentSection(section); - - for (const auto& pair : variables) - { - if (!keyword.IsEmpty()) - { - Append(keyword); - Append(" "); - } - - Append(pair.first); - Append(" "); - Append(pair.second); - AppendLine(";"); - } - - AppendLine(); - } - } - - void GlslWriter::EnterScope() - { - NazaraAssert(m_currentState, "This function should only be called while processing an AST"); - - m_currentState->indentLevel++; - AppendLine("{"); - } - - void GlslWriter::LeaveScope() - { - NazaraAssert(m_currentState, "This function should only be called while processing an AST"); - - m_currentState->indentLevel--; - AppendLine(); - AppendLine("}"); - } - } diff --git a/src/Nazara/Renderer/ShaderAst.cpp b/src/Nazara/Renderer/ShaderAst.cpp index b6623cc48..a52cca657 100644 --- a/src/Nazara/Renderer/ShaderAst.cpp +++ b/src/Nazara/Renderer/ShaderAst.cpp @@ -3,275 +3,40 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include -#include -#include #include -namespace Nz::ShaderAst +namespace Nz { - Node::~Node() = default; - - ExpressionCategory Expression::GetExpressionCategory() const + void ShaderAst::AddFunction(std::string name, ShaderNodes::StatementPtr statement, std::vector parameters, ShaderNodes::ExpressionType returnType) { - return ExpressionCategory::RValue; + auto& functionEntry = m_functions.emplace_back(); + functionEntry.name = std::move(name); + functionEntry.parameters = std::move(parameters); + functionEntry.returnType = returnType; + functionEntry.statement = std::move(statement); } - void ExpressionStatement::Register(ShaderWriter& visitor) + void ShaderAst::AddInput(std::string name, ShaderNodes::ExpressionType type, std::optional locationIndex) { - expression->Register(visitor); + auto& inputEntry = m_inputs.emplace_back(); + inputEntry.name = std::move(name); + inputEntry.locationIndex = std::move(locationIndex); + inputEntry.type = type; } - void ExpressionStatement::Visit(ShaderVisitor& visitor) + void ShaderAst::AddOutput(std::string name, ShaderNodes::ExpressionType type, std::optional locationIndex) { - visitor.Visit(*this); + auto& outputEntry = m_outputs.emplace_back(); + outputEntry.name = std::move(name); + outputEntry.locationIndex = std::move(locationIndex); + outputEntry.type = type; } - - void ConditionalStatement::Register(ShaderWriter& visitor) + void ShaderAst::AddUniform(std::string name, ShaderNodes::ExpressionType type, std::optional bindingIndex) { - if (visitor.IsConditionEnabled(conditionName)) - statement->Register(visitor); - } - - void ConditionalStatement::Visit(ShaderVisitor& visitor) - { - if (visitor.IsConditionEnabled(conditionName)) - statement->Visit(visitor); - } - - - void StatementBlock::Register(ShaderWriter& visitor) - { - for (auto& statementPtr : statements) - statementPtr->Register(visitor); - } - - void StatementBlock::Visit(ShaderVisitor& visitor) - { - visitor.Visit(*this); - } - - ExpressionCategory Variable::GetExpressionCategory() const - { - return ExpressionCategory::LValue; - } - - ExpressionType Variable::GetExpressionType() const - { - return type; - } - - - void BuiltinVariable::Register(ShaderWriter& /*visitor*/) - { - } - - void BuiltinVariable::Visit(ShaderVisitor& visitor) - { - visitor.Visit(*this); - } - - - void NamedVariable::Register(ShaderWriter& visitor) - { - visitor.RegisterVariable(kind, name, type); - } - - void NamedVariable::Visit(ShaderVisitor& visitor) - { - visitor.Visit(*this); - } - - - void DeclareVariable::Register(ShaderWriter& visitor) - { - variable->Register(visitor); - - if (expression) - expression->Register(visitor); - } - - void DeclareVariable::Visit(ShaderVisitor& visitor) - { - visitor.Visit(*this); - } - - - ExpressionType AssignOp::GetExpressionType() const - { - return left->GetExpressionType(); - } - - void AssignOp::Register(ShaderWriter& visitor) - { - left->Register(visitor); - right->Register(visitor); - } - - void AssignOp::Visit(ShaderVisitor& visitor) - { - visitor.Visit(*this); - } - - - ExpressionType BinaryOp::GetExpressionType() const - { - ShaderAst::ExpressionType exprType = ShaderAst::ExpressionType::Void; - - switch (op) - { - case ShaderAst::BinaryType::Add: - case ShaderAst::BinaryType::Substract: - exprType = left->GetExpressionType(); - break; - - case ShaderAst::BinaryType::Divide: - case ShaderAst::BinaryType::Multiply: - //FIXME - exprType = static_cast(std::max(UnderlyingCast(left->GetExpressionType()), UnderlyingCast(right->GetExpressionType()))); - break; - - case ShaderAst::BinaryType::Equality: - exprType = ExpressionType::Boolean; - break; - } - - NazaraAssert(exprType != ShaderAst::ExpressionType::Void, "Unhandled builtin"); - - return exprType; - } - - void BinaryOp::Register(ShaderWriter& visitor) - { - left->Register(visitor); - right->Register(visitor); - } - - void BinaryOp::Visit(ShaderVisitor& visitor) - { - visitor.Visit(*this); - } - - - void Branch::Register(ShaderWriter& visitor) - { - for (ConditionalStatement& statement : condStatements) - { - statement.condition->Register(visitor); - statement.statement->Register(visitor); - } - - if (elseStatement) - elseStatement->Register(visitor); - } - - void Branch::Visit(ShaderVisitor& visitor) - { - visitor.Visit(*this); - } - - - ExpressionType Constant::GetExpressionType() const - { - return exprType; - } - - void Constant::Register(ShaderWriter&) - { - } - - void Constant::Visit(ShaderVisitor& visitor) - { - visitor.Visit(*this); - } - - ExpressionType Cast::GetExpressionType() const - { - return exprType; - } - - void Cast::Register(ShaderWriter& visitor) - { - auto it = expressions.begin(); - (*it)->Register(visitor); - - for (; it != expressions.end(); ++it) - { - if (!*it) - break; - - (*it)->Register(visitor); - } - } - - void Cast::Visit(ShaderVisitor& visitor) - { - visitor.Visit(*this); - } - - - ExpressionCategory SwizzleOp::GetExpressionCategory() const - { - return ExpressionCategory::LValue; - } - - ExpressionType SwizzleOp::GetExpressionType() const - { - return static_cast(UnderlyingCast(GetComponentType(expression->GetExpressionType())) + componentCount - 1); - } - - void SwizzleOp::Register(ShaderWriter& visitor) - { - expression->Register(visitor); - } - - void SwizzleOp::Visit(ShaderVisitor& visitor) - { - visitor.Visit(*this); - } - - - ExpressionType Sample2D::GetExpressionType() const - { - return ExpressionType::Float4; - } - - void Sample2D::Register(ShaderWriter& visitor) - { - sampler->Register(visitor); - coordinates->Register(visitor); - } - - void Sample2D::Visit(ShaderVisitor& visitor) - { - visitor.Visit(*this); - } - - - ExpressionType BinaryFunc::GetExpressionType() const - { - switch (intrinsic) - { - case BinaryIntrinsic::CrossProduct: - return left->GetExpressionType(); - - case BinaryIntrinsic::DotProduct: - return ExpressionType::Float1; - } - - NazaraAssert(false, "Unhandled builtin"); - return ExpressionType::Void; - } - - void BinaryFunc::Register(ShaderWriter& visitor) - { - left->Register(visitor); - right->Register(visitor); - } - - void BinaryFunc::Visit(ShaderVisitor& visitor) - { - visitor.Visit(*this); + auto& uniformEntry = m_uniforms.emplace_back(); + uniformEntry.bindingIndex = std::move(bindingIndex); + uniformEntry.name = std::move(name); + uniformEntry.type = type; } } diff --git a/src/Nazara/Renderer/ShaderNodes.cpp b/src/Nazara/Renderer/ShaderNodes.cpp new file mode 100644 index 000000000..eb4f59160 --- /dev/null +++ b/src/Nazara/Renderer/ShaderNodes.cpp @@ -0,0 +1,179 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include + +namespace Nz::ShaderNodes +{ + Node::~Node() = default; + + ExpressionCategory Expression::GetExpressionCategory() const + { + return ExpressionCategory::RValue; + } + + void ExpressionStatement::Visit(ShaderVisitor& visitor) + { + visitor.Visit(*this); + } + + + void ConditionalStatement::Visit(ShaderVisitor& visitor) + { + if (visitor.IsConditionEnabled(conditionName)) + statement->Visit(visitor); + } + + + void StatementBlock::Visit(ShaderVisitor& visitor) + { + visitor.Visit(*this); + } + + + void DeclareVariable::Visit(ShaderVisitor& visitor) + { + visitor.Visit(*this); + } + + + ExpressionCategory Identifier::GetExpressionCategory() const + { + return ExpressionCategory::LValue; + } + + ExpressionType Identifier::GetExpressionType() const + { + assert(var); + return var->type; + } + + void Identifier::Visit(ShaderVisitor& visitor) + { + visitor.Visit(*this); + } + + + ExpressionType AssignOp::GetExpressionType() const + { + return left->GetExpressionType(); + } + + void AssignOp::Visit(ShaderVisitor& visitor) + { + visitor.Visit(*this); + } + + + ExpressionType BinaryOp::GetExpressionType() const + { + ShaderNodes::ExpressionType exprType = ShaderNodes::ExpressionType::Void; + + switch (op) + { + case ShaderNodes::BinaryType::Add: + case ShaderNodes::BinaryType::Substract: + exprType = left->GetExpressionType(); + break; + + case ShaderNodes::BinaryType::Divide: + case ShaderNodes::BinaryType::Multiply: + //FIXME + exprType = static_cast(std::max(UnderlyingCast(left->GetExpressionType()), UnderlyingCast(right->GetExpressionType()))); + break; + + case ShaderNodes::BinaryType::Equality: + exprType = ExpressionType::Boolean; + break; + } + + NazaraAssert(exprType != ShaderNodes::ExpressionType::Void, "Unhandled builtin"); + + return exprType; + } + + void BinaryOp::Visit(ShaderVisitor& visitor) + { + visitor.Visit(*this); + } + + + void Branch::Visit(ShaderVisitor& visitor) + { + visitor.Visit(*this); + } + + + ExpressionType Constant::GetExpressionType() const + { + return exprType; + } + + void Constant::Visit(ShaderVisitor& visitor) + { + visitor.Visit(*this); + } + + ExpressionType Cast::GetExpressionType() const + { + return exprType; + } + + void Cast::Visit(ShaderVisitor& visitor) + { + visitor.Visit(*this); + } + + + ExpressionCategory SwizzleOp::GetExpressionCategory() const + { + return ExpressionCategory::LValue; + } + + ExpressionType SwizzleOp::GetExpressionType() const + { + return static_cast(UnderlyingCast(GetComponentType(expression->GetExpressionType())) + componentCount - 1); + } + + void SwizzleOp::Visit(ShaderVisitor& visitor) + { + visitor.Visit(*this); + } + + + ExpressionType Sample2D::GetExpressionType() const + { + return ExpressionType::Float4; + } + + void Sample2D::Visit(ShaderVisitor& visitor) + { + visitor.Visit(*this); + } + + + ExpressionType IntrinsicCall::GetExpressionType() const + { + switch (intrinsic) + { + case IntrinsicType::CrossProduct: + return parameters.front()->GetExpressionType(); + + case IntrinsicType::DotProduct: + return ExpressionType::Float1; + } + + NazaraAssert(false, "Unhandled builtin"); + return ExpressionType::Void; + } + + void IntrinsicCall::Visit(ShaderVisitor& visitor) + { + visitor.Visit(*this); + } +} diff --git a/src/Nazara/Renderer/ShaderSerializer.cpp b/src/Nazara/Renderer/ShaderSerializer.cpp index 6e6e3e8ff..909422f52 100644 --- a/src/Nazara/Renderer/ShaderSerializer.cpp +++ b/src/Nazara/Renderer/ShaderSerializer.cpp @@ -3,13 +3,15 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include +#include #include -namespace Nz::ShaderAst +namespace Nz::ShaderNodes { namespace { - class ShaderSerializerVisitor : public ShaderVisitor + class ShaderSerializerVisitor : public ShaderVisitor, public ShaderVarVisitor { public: ShaderSerializerVisitor(ShaderSerializerBase& serializer) : @@ -22,11 +24,6 @@ namespace Nz::ShaderAst Serialize(node); } - void Visit(const BinaryFunc& node) override - { - Serialize(node); - } - void Visit(const BinaryOp& node) override { Serialize(node); @@ -37,11 +34,6 @@ namespace Nz::ShaderAst Serialize(node); } - void Visit(const BuiltinVariable& node) override - { - Serialize(node); - } - void Visit(const Cast& node) override { Serialize(node); @@ -62,7 +54,12 @@ namespace Nz::ShaderAst Serialize(node); } - void Visit(const NamedVariable& node) override + void Visit(const Identifier& node) override + { + Serialize(node); + } + + void Visit(const IntrinsicCall& node) override { Serialize(node); } @@ -82,6 +79,37 @@ namespace Nz::ShaderAst Serialize(node); } + + void Visit(const ShaderNodes::BuiltinVariable& var) override + { + Serialize(var); + } + + void Visit(const ShaderNodes::InputVariable& var) override + { + Serialize(var); + } + + void Visit(const ShaderNodes::LocalVariable& var) override + { + Serialize(var); + } + + void Visit(const ShaderNodes::OutputVariable& var) override + { + Serialize(var); + } + + void Visit(const ShaderNodes::ParameterVariable& var) override + { + Serialize(var); + } + + void Visit(const ShaderNodes::UniformVariable& var) override + { + Serialize(var); + } + private: template void Serialize(const T& node) @@ -101,13 +129,6 @@ namespace Nz::ShaderAst Node(node.right); } - void ShaderSerializerBase::Serialize(BinaryFunc& node) - { - Enum(node.intrinsic); - Node(node.left); - Node(node.right); - } - void ShaderSerializerBase::Serialize(BinaryOp& node) { Enum(node.op); @@ -129,7 +150,7 @@ namespace Nz::ShaderAst void ShaderSerializerBase::Serialize(BuiltinVariable& node) { - Enum(node.var); + Enum(node.type); Enum(node.type); } @@ -170,7 +191,7 @@ namespace Nz::ShaderAst void ShaderSerializerBase::Serialize(DeclareVariable& node) { - Node(node.variable); + Variable(node.variable); Node(node.expression); } @@ -179,10 +200,22 @@ namespace Nz::ShaderAst Node(node.expression); } + void ShaderSerializerBase::Serialize(Identifier& node) + { + Variable(node.var); + } + + void ShaderSerializerBase::Serialize(IntrinsicCall& node) + { + Enum(node.intrinsic); + Container(node.parameters); + for (auto& param : node.parameters) + Node(param); + } + void ShaderSerializerBase::Serialize(NamedVariable& node) { Value(node.name); - Enum(node.kind); Enum(node.type); } @@ -272,6 +305,18 @@ namespace Nz::ShaderAst m_stream << val; } + void ShaderSerializer::Variable(VariablePtr& var) + { + VariableType nodeType = (var) ? var->GetType() : VariableType::None; + m_stream << static_cast(nodeType); + + if (var) + { + ShaderSerializerVisitor visitor(*this); + var->Visit(visitor); + } + } + ByteArray Serialize(const StatementPtr& shader) { ByteArray byteArray; @@ -309,27 +354,26 @@ namespace Nz::ShaderAst NodeType nodeType = static_cast(nodeTypeInt); -#define HandleNodeType(Type) case NodeType:: Type : node = std::make_shared(); break +#define HandleType(Type) case NodeType:: Type : node = std::make_shared(); break switch (nodeType) { case NodeType::None: break; - HandleNodeType(AssignOp); - HandleNodeType(BinaryFunc); - HandleNodeType(BinaryOp); - HandleNodeType(Branch); - HandleNodeType(BuiltinVariable); - HandleNodeType(Cast); - HandleNodeType(Constant); - HandleNodeType(ConditionalStatement); - HandleNodeType(DeclareVariable); - HandleNodeType(ExpressionStatement); - HandleNodeType(NamedVariable); - HandleNodeType(Sample2D); - HandleNodeType(SwizzleOp); - HandleNodeType(StatementBlock); + HandleType(AssignOp); + HandleType(BinaryOp); + HandleType(Branch); + HandleType(Cast); + HandleType(Constant); + HandleType(ConditionalStatement); + HandleType(DeclareVariable); + HandleType(ExpressionStatement); + HandleType(Identifier); + HandleType(IntrinsicCall); + HandleType(Sample2D); + HandleType(SwizzleOp); + HandleType(StatementBlock); } -#undef HandleNodeType +#undef HandleType if (node) { @@ -372,5 +416,32 @@ namespace Nz::ShaderAst { m_stream >> val; } + + void ShaderUnserializer::Variable(VariablePtr& var) + { + Int32 nodeTypeInt; + m_stream >> nodeTypeInt; + + VariableType nodeType = static_cast(nodeTypeInt); + +#define HandleType(Type) case VariableType:: Type : var = std::make_shared(); break + switch (nodeType) + { + case VariableType::None: break; + + HandleType(BuiltinVariable); + HandleType(InputVariable); + HandleType(LocalVariable); + HandleType(OutputVariable); + HandleType(UniformVariable); + } +#undef HandleType + + if (var) + { + ShaderSerializerVisitor visitor(*this); + var->Visit(visitor); + } + } } diff --git a/src/Nazara/Renderer/ShaderValidator.cpp b/src/Nazara/Renderer/ShaderValidator.cpp index c7a25989f..aab559a61 100644 --- a/src/Nazara/Renderer/ShaderValidator.cpp +++ b/src/Nazara/Renderer/ShaderValidator.cpp @@ -3,20 +3,49 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include +#include +#include +#include #include -namespace Nz::ShaderAst +namespace Nz { struct AstError { std::string errMsg; }; - bool ShaderValidator::Validate(const StatementPtr& shader, std::string* error) + struct ShaderValidator::Context + { + struct Local + { + std::string name; + ShaderNodes::ExpressionType type; + }; + + const ShaderAst::Function* currentFunction; + std::vector declaredLocals; + std::vector blockLocalIndex; + }; + + bool ShaderValidator::Validate(std::string* error) { try { - shader->Visit(*this); + for (std::size_t i = 0; i < m_shader.GetFunctionCount(); ++i) + { + const auto& func = m_shader.GetFunction(i); + + Context currentContext; + currentContext.currentFunction = &func; + + m_context = ¤tContext; + CallOnExit resetContext([&] { m_context = nullptr; }); + + func.statement->Visit(*this); + } + return true; } catch (const AstError& e) @@ -28,14 +57,14 @@ namespace Nz::ShaderAst } } - const ExpressionPtr& ShaderValidator::MandatoryExpr(const ExpressionPtr& node) + const ShaderNodes::ExpressionPtr& ShaderValidator::MandatoryExpr(const ShaderNodes::ExpressionPtr& node) { MandatoryNode(node); return node; } - const NodePtr& ShaderValidator::MandatoryNode(const NodePtr& node) + const ShaderNodes::NodePtr& ShaderValidator::MandatoryNode(const ShaderNodes::NodePtr& node) { if (!node) throw AstError{ "Invalid node" }; @@ -43,90 +72,76 @@ namespace Nz::ShaderAst return node; } - void ShaderValidator::TypeMustMatch(const ExpressionPtr& left, const ExpressionPtr& right) + void ShaderValidator::TypeMustMatch(const ShaderNodes::ExpressionPtr& left, const ShaderNodes::ExpressionPtr& right) { - if (left->GetExpressionType() != right->GetExpressionType()) + return TypeMustMatch(left->GetExpressionType(), right->GetExpressionType()); + } + + void ShaderValidator::TypeMustMatch(ShaderNodes::ExpressionType left, ShaderNodes::ExpressionType right) + { + if (left != right) throw AstError{ "Left expression type must match right expression type" }; } - void ShaderValidator::Visit(const AssignOp& node) + void ShaderValidator::Visit(const ShaderNodes::AssignOp& node) { MandatoryNode(node.left); MandatoryNode(node.right); TypeMustMatch(node.left, node.right); - Visit(node.left); - Visit(node.right); - } - - void ShaderValidator::Visit(const BinaryFunc& node) - { - MandatoryNode(node.left); - MandatoryNode(node.right); - TypeMustMatch(node.left, node.right); - - switch (node.intrinsic) - { - case BinaryIntrinsic::CrossProduct: - { - if (node.left->GetExpressionType() != ExpressionType::Float3) - throw AstError{ "CrossProduct only works with Float3 expressions" }; - } - - case BinaryIntrinsic::DotProduct: - break; - } + if (node.left->GetExpressionCategory() != ShaderNodes::ExpressionCategory::LValue) + throw AstError { "Assignation is only possible with a l-value" }; Visit(node.left); Visit(node.right); } - void ShaderValidator::Visit(const BinaryOp& node) + void ShaderValidator::Visit(const ShaderNodes::BinaryOp& node) { MandatoryNode(node.left); MandatoryNode(node.right); - ExpressionType leftType = node.left->GetExpressionType(); - ExpressionType rightType = node.right->GetExpressionType(); + ShaderNodes::ExpressionType leftType = node.left->GetExpressionType(); + ShaderNodes::ExpressionType rightType = node.right->GetExpressionType(); switch (node.op) { - case BinaryType::Add: - case BinaryType::Equality: - case BinaryType::Substract: + case ShaderNodes::BinaryType::Add: + case ShaderNodes::BinaryType::Equality: + case ShaderNodes::BinaryType::Substract: TypeMustMatch(node.left, node.right); break; - case BinaryType::Multiply: - case BinaryType::Divide: + case ShaderNodes::BinaryType::Multiply: + case ShaderNodes::BinaryType::Divide: { switch (leftType) { - case ExpressionType::Float1: + case ShaderNodes::ExpressionType::Float1: { - if (Node::GetComponentType(rightType) != ExpressionType::Float1) + if (ShaderNodes::Node::GetComponentType(rightType) != ShaderNodes::ExpressionType::Float1) throw AstError{ "Left expression type is not compatible with right expression type" }; break; } - case ExpressionType::Float2: - case ExpressionType::Float3: - case ExpressionType::Float4: + case ShaderNodes::ExpressionType::Float2: + case ShaderNodes::ExpressionType::Float3: + case ShaderNodes::ExpressionType::Float4: { - if (leftType != rightType && rightType != ExpressionType::Float1) + if (leftType != rightType && rightType != ShaderNodes::ExpressionType::Float1) throw AstError{ "Left expression type is not compatible with right expression type" }; break; } - case ExpressionType::Mat4x4: + case ShaderNodes::ExpressionType::Mat4x4: { switch (rightType) { - case ExpressionType::Float1: - case ExpressionType::Float4: - case ExpressionType::Mat4x4: + case ShaderNodes::ExpressionType::Float1: + case ShaderNodes::ExpressionType::Float4: + case ShaderNodes::ExpressionType::Mat4x4: break; default: @@ -146,7 +161,7 @@ namespace Nz::ShaderAst Visit(node.right); } - void ShaderValidator::Visit(const Branch& node) + void ShaderValidator::Visit(const ShaderNodes::Branch& node) { for (const auto& condStatement : node.condStatements) { @@ -155,11 +170,7 @@ namespace Nz::ShaderAst } } - void ShaderValidator::Visit(const BuiltinVariable& /*node*/) - { - } - - void ShaderValidator::Visit(const Cast& node) + void ShaderValidator::Visit(const ShaderNodes::Cast& node) { unsigned int componentCount = 0; unsigned int requiredComponents = node.GetComponentCount(node.exprType); @@ -176,55 +187,203 @@ namespace Nz::ShaderAst throw AstError{ "Component count doesn't match required component count" }; } - void ShaderValidator::Visit(const Constant& /*node*/) + void ShaderValidator::Visit(const ShaderNodes::Constant& /*node*/) { } - void ShaderValidator::Visit(const DeclareVariable& node) + void ShaderValidator::Visit(const ShaderNodes::DeclareVariable& node) + { + assert(m_context); + + if (node.expression) + Visit(node.expression); + + auto& local = m_context->declaredLocals.emplace_back(); + local.name = node.variable->name; + local.type = node.variable->type; + } + + void ShaderValidator::Visit(const ShaderNodes::ExpressionStatement& node) { Visit(MandatoryNode(node.expression)); } - void ShaderValidator::Visit(const ExpressionStatement& node) + void ShaderValidator::Visit(const ShaderNodes::Identifier& node) { - Visit(MandatoryNode(node.expression)); + assert(m_context); + + if (!node.var) + throw AstError{ "Invalid variable" }; + + //< FIXME: Use variable visitor + switch (node.var->GetType()) + { + case ShaderNodes::VariableType::BuiltinVariable: + break; + + case ShaderNodes::VariableType::InputVariable: + { + auto& namedVar = static_cast(*node.var); + + for (std::size_t i = 0; i < m_shader.GetInputCount(); ++i) + { + const auto& input = m_shader.GetInput(i); + if (input.name == namedVar.name) + { + TypeMustMatch(input.type, namedVar.type); + return; + } + } + + throw AstError{ "Input not found" }; + } + + case ShaderNodes::VariableType::LocalVariable: + { + auto& localVar = static_cast(*node.var); + const auto& vars = m_context->declaredLocals; + + auto it = std::find_if(vars.begin(), vars.end(), [&](const auto& var) { return var.name == localVar.name; }); + if (it == vars.end()) + throw AstError{ "Local variable not found in this block" }; + + TypeMustMatch(it->type, localVar.type); + break; + } + + case ShaderNodes::VariableType::OutputVariable: + { + auto& outputVar = static_cast(*node.var); + + for (std::size_t i = 0; i < m_shader.GetOutputCount(); ++i) + { + const auto& input = m_shader.GetOutput(i); + if (input.name == outputVar.name) + { + TypeMustMatch(input.type, outputVar.type); + return; + } + } + + throw AstError{ "Output not found" }; + } + + case ShaderNodes::VariableType::ParameterVariable: + { + assert(m_context->currentFunction); + + auto& parameter = static_cast(*node.var); + const auto& parameters = m_context->currentFunction->parameters; + + auto it = std::find_if(parameters.begin(), parameters.end(), [&](const auto& parameter) { return parameter.name == parameter.name; }); + if (it == parameters.end()) + throw AstError{ "Parameter not found in function" }; + + TypeMustMatch(it->type, parameter.type); + break; + } + + case ShaderNodes::VariableType::UniformVariable: + { + auto& uniformVar = static_cast(*node.var); + + for (std::size_t i = 0; i < m_shader.GetUniformCount(); ++i) + { + const auto& uniform = m_shader.GetUniform(i); + if (uniform.name == uniformVar.name) + { + TypeMustMatch(uniform.type, uniformVar.type); + return; + } + } + + throw AstError{ "Uniform not found" }; + } + + default: + break; + } } - void ShaderValidator::Visit(const NamedVariable& node) + void ShaderValidator::Visit(const ShaderNodes::IntrinsicCall& node) { - if (node.name.empty()) - throw AstError{ "Variable has empty name" }; + switch (node.intrinsic) + { + case ShaderNodes::IntrinsicType::CrossProduct: + case ShaderNodes::IntrinsicType::DotProduct: + { + if (node.parameters.size() != 2) + throw AstError { "Expected 2 parameters" }; + + for (auto& param : node.parameters) + MandatoryNode(param); + + ShaderNodes::ExpressionType type = node.parameters.front()->GetExpressionType(); + for (std::size_t i = 1; i < node.parameters.size(); ++i) + { + if (type != node.parameters[i]->GetExpressionType()) + throw AstError{ "All type must match" }; + } + + break; + } + } + + switch (node.intrinsic) + { + case ShaderNodes::IntrinsicType::CrossProduct: + { + if (node.parameters[0]->GetExpressionType() != ShaderNodes::ExpressionType::Float3) + throw AstError{ "CrossProduct only works with Float3 expressions" }; + + break; + } + + case ShaderNodes::IntrinsicType::DotProduct: + break; + } + + for (auto& param : node.parameters) + Visit(param); } - void ShaderValidator::Visit(const Sample2D& node) + void ShaderValidator::Visit(const ShaderNodes::Sample2D& node) { - if (MandatoryExpr(node.sampler)->GetExpressionType() != ExpressionType::Sampler2D) + if (MandatoryExpr(node.sampler)->GetExpressionType() != ShaderNodes::ExpressionType::Sampler2D) throw AstError{ "Sampler must be a Sampler2D" }; - if (MandatoryExpr(node.coordinates)->GetExpressionType() != ExpressionType::Float2) + if (MandatoryExpr(node.coordinates)->GetExpressionType() != ShaderNodes::ExpressionType::Float2) throw AstError{ "Coordinates must be a Float2" }; Visit(node.sampler); Visit(node.coordinates); } - void ShaderValidator::Visit(const StatementBlock& node) + void ShaderValidator::Visit(const ShaderNodes::StatementBlock& node) { + assert(m_context); + + m_context->blockLocalIndex.push_back(m_context->declaredLocals.size()); + for (const auto& statement : node.statements) Visit(MandatoryNode(statement)); + + assert(m_context->declaredLocals.size() >= m_context->blockLocalIndex.back()); + m_context->declaredLocals.resize(m_context->blockLocalIndex.back()); + m_context->blockLocalIndex.pop_back(); } - void ShaderValidator::Visit(const SwizzleOp& node) + void ShaderValidator::Visit(const ShaderNodes::SwizzleOp& node) { if (node.componentCount > 4) throw AstError{ "Cannot swizzle more than four elements" }; switch (MandatoryExpr(node.expression)->GetExpressionType()) { - case ExpressionType::Float1: - case ExpressionType::Float2: - case ExpressionType::Float3: - case ExpressionType::Float4: + case ShaderNodes::ExpressionType::Float1: + case ShaderNodes::ExpressionType::Float2: + case ShaderNodes::ExpressionType::Float3: + case ShaderNodes::ExpressionType::Float4: break; default: @@ -234,9 +393,9 @@ namespace Nz::ShaderAst Visit(node.expression); } - bool Validate(const StatementPtr& shader, std::string* error) + bool ValidateShader(const ShaderAst& shader, std::string* error) { - ShaderValidator validator; - return validator.Validate(shader, error); + ShaderValidator validator(shader); + return validator.Validate(error); } } diff --git a/src/Nazara/Renderer/ShaderVarVisitor.cpp b/src/Nazara/Renderer/ShaderVarVisitor.cpp new file mode 100644 index 000000000..6f3838f26 --- /dev/null +++ b/src/Nazara/Renderer/ShaderVarVisitor.cpp @@ -0,0 +1,16 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + ShaderVarVisitor::~ShaderVarVisitor() = default; + + void ShaderVarVisitor::Visit(const ShaderNodes::VariablePtr& node) + { + node->Visit(*this); + } +} diff --git a/src/Nazara/Renderer/ShaderVariables.cpp b/src/Nazara/Renderer/ShaderVariables.cpp new file mode 100644 index 000000000..93701c4ef --- /dev/null +++ b/src/Nazara/Renderer/ShaderVariables.cpp @@ -0,0 +1,77 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz::ShaderNodes +{ + ShaderNodes::Variable::~Variable() = default; + + VariableType BuiltinVariable::GetType() const + { + return VariableType::BuiltinVariable; + } + + void BuiltinVariable::Visit(ShaderVarVisitor& visitor) + { + visitor.Visit(*this); + } + + + VariableType InputVariable::GetType() const + { + return VariableType::InputVariable; + } + + void InputVariable::Visit(ShaderVarVisitor& visitor) + { + visitor.Visit(*this); + } + + + VariableType LocalVariable::GetType() const + { + return VariableType::LocalVariable; + } + + void LocalVariable::Visit(ShaderVarVisitor& visitor) + { + visitor.Visit(*this); + } + + + VariableType OutputVariable::GetType() const + { + return VariableType::OutputVariable; + } + + void OutputVariable::Visit(ShaderVarVisitor& visitor) + { + visitor.Visit(*this); + } + + + VariableType ParameterVariable::GetType() const + { + return VariableType::ParameterVariable; + } + + void ParameterVariable::Visit(ShaderVarVisitor& visitor) + { + visitor.Visit(*this); + } + + + VariableType UniformVariable::GetType() const + { + return VariableType::UniformVariable; + } + + void UniformVariable::Visit(ShaderVarVisitor& visitor) + { + visitor.Visit(*this); + } +} diff --git a/src/Nazara/Renderer/ShaderVisitor.cpp b/src/Nazara/Renderer/ShaderVisitor.cpp index 2b5a590bd..dd7e01542 100644 --- a/src/Nazara/Renderer/ShaderVisitor.cpp +++ b/src/Nazara/Renderer/ShaderVisitor.cpp @@ -9,7 +9,7 @@ namespace Nz { ShaderVisitor::~ShaderVisitor() = default; - void ShaderVisitor::EnableCondition(const String& name, bool cond) + void ShaderVisitor::EnableCondition(const std::string& name, bool cond) { if (cond) m_conditions.insert(name); @@ -17,12 +17,12 @@ namespace Nz m_conditions.erase(name); } - bool ShaderVisitor::IsConditionEnabled(const String& name) const + bool ShaderVisitor::IsConditionEnabled(const std::string& name) const { return m_conditions.count(name) != 0; } - void ShaderVisitor::Visit(const ShaderAst::NodePtr& node) + void ShaderVisitor::Visit(const ShaderNodes::NodePtr& node) { node->Visit(*this); } diff --git a/src/Nazara/Renderer/ShaderWriter.cpp b/src/Nazara/Renderer/ShaderWriter.cpp index 982251556..8ca48da3e 100644 --- a/src/Nazara/Renderer/ShaderWriter.cpp +++ b/src/Nazara/Renderer/ShaderWriter.cpp @@ -7,4 +7,5 @@ namespace Nz { + ShaderWriter::~ShaderWriter() = default; } diff --git a/src/ShaderNode/DataModels/Cast.hpp b/src/ShaderNode/DataModels/Cast.hpp index bb287555c..c30f3eadc 100644 --- a/src/ShaderNode/DataModels/Cast.hpp +++ b/src/ShaderNode/DataModels/Cast.hpp @@ -19,7 +19,7 @@ class CastVec : public ShaderNode void BuildNodeEdition(QFormLayout* layout) override; - Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const override; + Nz::ShaderNodes::ExpressionPtr GetExpression(Nz::ShaderNodes::ExpressionPtr* expressions, std::size_t count) const override; QString caption() const override; QString name() const override; diff --git a/src/ShaderNode/DataModels/Cast.inl b/src/ShaderNode/DataModels/Cast.inl index 1a304c2c7..ccb15385c 100644 --- a/src/ShaderNode/DataModels/Cast.inl +++ b/src/ShaderNode/DataModels/Cast.inl @@ -49,7 +49,7 @@ void CastVec::BuildNodeEdition(QFormLayout* layout) } template -Nz::ShaderAst::ExpressionPtr CastVec::GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const +Nz::ShaderNodes::ExpressionPtr CastVec::GetExpression(Nz::ShaderNodes::ExpressionPtr* expressions, std::size_t count) const { assert(m_input); assert(count == 1); @@ -60,7 +60,7 @@ Nz::ShaderAst::ExpressionPtr CastVec::GetExpression(Nz::Shader { std::size_t overflowComponentCount = ToComponentCount - fromComponentCount; - std::array expr; + std::array expr; expr[0] = expressions[0]; for (std::size_t i = 0; i < overflowComponentCount; ++i) expr[i + 1] = Nz::ShaderBuilder::Constant(m_overflowComponents[i]); @@ -71,13 +71,13 @@ Nz::ShaderAst::ExpressionPtr CastVec::GetExpression(Nz::Shader } else if (ToComponentCount < fromComponentCount) { - std::array swizzleComponents; + std::array swizzleComponents; for (std::size_t i = 0; i < ToComponentCount; ++i) - swizzleComponents[i] = static_cast(static_cast(Nz::ShaderAst::SwizzleComponent::First) + i); + swizzleComponents[i] = static_cast(static_cast(Nz::ShaderNodes::SwizzleComponent::First) + i); return std::apply([&](auto... components) { - std::initializer_list componentList{ components... }; + std::initializer_list componentList{ components... }; return Nz::ShaderBuilder::Swizzle(expressions[0], componentList); }, swizzleComponents); } diff --git a/src/ShaderNode/DataModels/FloatValue.cpp b/src/ShaderNode/DataModels/FloatValue.cpp index 3da83982e..f9c25074b 100644 --- a/src/ShaderNode/DataModels/FloatValue.cpp +++ b/src/ShaderNode/DataModels/FloatValue.cpp @@ -71,7 +71,7 @@ void FloatValue::BuildNodeEdition(QFormLayout* layout) layout->addRow(tr("Value"), spinbox); } -Nz::ShaderAst::ExpressionPtr FloatValue::GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const +Nz::ShaderNodes::ExpressionPtr FloatValue::GetExpression(Nz::ShaderNodes::ExpressionPtr* /*expressions*/, std::size_t count) const { assert(count == 0); diff --git a/src/ShaderNode/DataModels/FloatValue.hpp b/src/ShaderNode/DataModels/FloatValue.hpp index 44244cd46..fe77e5464 100644 --- a/src/ShaderNode/DataModels/FloatValue.hpp +++ b/src/ShaderNode/DataModels/FloatValue.hpp @@ -28,7 +28,7 @@ class FloatValue : public ShaderNode void BuildNodeEdition(QFormLayout* layout) override; - Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const override; + Nz::ShaderNodes::ExpressionPtr GetExpression(Nz::ShaderNodes::ExpressionPtr* expressions, std::size_t count) const override; private: bool ComputePreview(QPixmap& pixmap) override; diff --git a/src/ShaderNode/DataModels/InputValue.cpp b/src/ShaderNode/DataModels/InputValue.cpp index 92d08ba3e..5a2b088dd 100644 --- a/src/ShaderNode/DataModels/InputValue.cpp +++ b/src/ShaderNode/DataModels/InputValue.cpp @@ -107,7 +107,7 @@ void InputValue::BuildNodeEdition(QFormLayout* layout) layout->addRow(tr("Input"), inputSelection); } -Nz::ShaderAst::ExpressionPtr InputValue::GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const +Nz::ShaderNodes::ExpressionPtr InputValue::GetExpression(Nz::ShaderNodes::ExpressionPtr* /*expressions*/, std::size_t count) const { assert(count == 0); @@ -116,22 +116,22 @@ Nz::ShaderAst::ExpressionPtr InputValue::GetExpression(Nz::ShaderAst::Expression const auto& inputEntry = GetGraph().GetInput(*m_currentInputIndex); - Nz::ShaderAst::ExpressionType expression = [&] + Nz::ShaderNodes::ExpressionType expression = [&] { switch (inputEntry.type) { - case InOutType::Bool: return Nz::ShaderAst::ExpressionType::Boolean; - case InOutType::Float1: return Nz::ShaderAst::ExpressionType::Float1; - case InOutType::Float2: return Nz::ShaderAst::ExpressionType::Float2; - case InOutType::Float3: return Nz::ShaderAst::ExpressionType::Float3; - case InOutType::Float4: return Nz::ShaderAst::ExpressionType::Float4; + case InOutType::Bool: return Nz::ShaderNodes::ExpressionType::Boolean; + case InOutType::Float1: return Nz::ShaderNodes::ExpressionType::Float1; + case InOutType::Float2: return Nz::ShaderNodes::ExpressionType::Float2; + case InOutType::Float3: return Nz::ShaderNodes::ExpressionType::Float3; + case InOutType::Float4: return Nz::ShaderNodes::ExpressionType::Float4; } assert(false); throw std::runtime_error("Unhandled input type"); }(); - return Nz::ShaderBuilder::Input(inputEntry.name, expression); + return Nz::ShaderBuilder::Identifier(Nz::ShaderBuilder::Input(inputEntry.name, expression)); } auto InputValue::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const -> QtNodes::NodeDataType @@ -145,7 +145,7 @@ auto InputValue::dataType(QtNodes::PortType portType, QtNodes::PortIndex portInd const auto& inputEntry = GetGraph().GetInput(*m_currentInputIndex); switch (inputEntry.type) { - //case InputType::Bool: return Nz::ShaderAst::ExpressionType::Boolean; + //case InputType::Bool: return Nz::ShaderNodes::ExpressionType::Boolean; case InOutType::Float1: return FloatData::Type(); diff --git a/src/ShaderNode/DataModels/InputValue.hpp b/src/ShaderNode/DataModels/InputValue.hpp index a5eaabf01..d0e1593b9 100644 --- a/src/ShaderNode/DataModels/InputValue.hpp +++ b/src/ShaderNode/DataModels/InputValue.hpp @@ -19,7 +19,7 @@ class InputValue : public ShaderNode void BuildNodeEdition(QFormLayout* layout) override; - Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const override; + Nz::ShaderNodes::ExpressionPtr GetExpression(Nz::ShaderNodes::ExpressionPtr* /*expressions*/, std::size_t count) const override; QString caption() const override { return "Input"; } QString name() const override { return "Input"; } diff --git a/src/ShaderNode/DataModels/OutputValue.cpp b/src/ShaderNode/DataModels/OutputValue.cpp index 09d7aff78..7cf6fedec 100644 --- a/src/ShaderNode/DataModels/OutputValue.cpp +++ b/src/ShaderNode/DataModels/OutputValue.cpp @@ -51,10 +51,10 @@ void OutputValue::BuildNodeEdition(QFormLayout* layout) layout->addRow(tr("Output"), outputSelection); } -Nz::ShaderAst::ExpressionPtr OutputValue::GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const +Nz::ShaderNodes::ExpressionPtr OutputValue::GetExpression(Nz::ShaderNodes::ExpressionPtr* expressions, std::size_t count) const { - using namespace Nz::ShaderAst; using namespace Nz::ShaderBuilder; + using namespace Nz::ShaderNodes; assert(count == 1); @@ -63,22 +63,22 @@ Nz::ShaderAst::ExpressionPtr OutputValue::GetExpression(Nz::ShaderAst::Expressio const auto& outputEntry = GetGraph().GetOutput(*m_currentOutputIndex); - Nz::ShaderAst::ExpressionType expression = [&] + Nz::ShaderNodes::ExpressionType expression = [&] { switch (outputEntry.type) { - case InOutType::Bool: return Nz::ShaderAst::ExpressionType::Boolean; - case InOutType::Float1: return Nz::ShaderAst::ExpressionType::Float1; - case InOutType::Float2: return Nz::ShaderAst::ExpressionType::Float2; - case InOutType::Float3: return Nz::ShaderAst::ExpressionType::Float3; - case InOutType::Float4: return Nz::ShaderAst::ExpressionType::Float4; + case InOutType::Bool: return Nz::ShaderNodes::ExpressionType::Boolean; + case InOutType::Float1: return Nz::ShaderNodes::ExpressionType::Float1; + case InOutType::Float2: return Nz::ShaderNodes::ExpressionType::Float2; + case InOutType::Float3: return Nz::ShaderNodes::ExpressionType::Float3; + case InOutType::Float4: return Nz::ShaderNodes::ExpressionType::Float4; } assert(false); throw std::runtime_error("Unhandled output type"); }(); - auto output = Nz::ShaderBuilder::Output(outputEntry.name, expression); + auto output = Nz::ShaderBuilder::Identifier(Nz::ShaderBuilder::Output(outputEntry.name, expression)); return Nz::ShaderBuilder::Assign(std::move(output), *expressions); } @@ -94,8 +94,8 @@ QtNodes::NodeDataType OutputValue::dataType(QtNodes::PortType portType, QtNodes: const auto& outputEntry = GetGraph().GetOutput(*m_currentOutputIndex); switch (outputEntry.type) { - //case InOutType::Bool: return Nz::ShaderAst::ExpressionType::Boolean; - //case InOutType::Float1: return Nz::ShaderAst::ExpressionType::Float1; + //case InOutType::Bool: return Nz::ShaderNodes::ExpressionType::Boolean; + //case InOutType::Float1: return Nz::ShaderNodes::ExpressionType::Float1; case InOutType::Float2: case InOutType::Float3: case InOutType::Float4: diff --git a/src/ShaderNode/DataModels/OutputValue.hpp b/src/ShaderNode/DataModels/OutputValue.hpp index 320b2bacb..284e302ea 100644 --- a/src/ShaderNode/DataModels/OutputValue.hpp +++ b/src/ShaderNode/DataModels/OutputValue.hpp @@ -16,7 +16,7 @@ class OutputValue : public ShaderNode void BuildNodeEdition(QFormLayout* layout) override; - Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const override; + Nz::ShaderNodes::ExpressionPtr GetExpression(Nz::ShaderNodes::ExpressionPtr* expressions, std::size_t count) const override; QString caption() const override { return "Output"; } QString name() const override { return "Output"; } diff --git a/src/ShaderNode/DataModels/SampleTexture.cpp b/src/ShaderNode/DataModels/SampleTexture.cpp index 3f0036519..2c9e2dcac 100644 --- a/src/ShaderNode/DataModels/SampleTexture.cpp +++ b/src/ShaderNode/DataModels/SampleTexture.cpp @@ -91,7 +91,7 @@ bool SampleTexture::ComputePreview(QPixmap& pixmap) return true; } -Nz::ShaderAst::ExpressionPtr SampleTexture::GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const +Nz::ShaderNodes::ExpressionPtr SampleTexture::GetExpression(Nz::ShaderNodes::ExpressionPtr* expressions, std::size_t count) const { assert(m_texture); assert(m_uv); diff --git a/src/ShaderNode/DataModels/SampleTexture.hpp b/src/ShaderNode/DataModels/SampleTexture.hpp index 7afb77e0f..5b1dd98fd 100644 --- a/src/ShaderNode/DataModels/SampleTexture.hpp +++ b/src/ShaderNode/DataModels/SampleTexture.hpp @@ -17,7 +17,7 @@ class SampleTexture : public ShaderNode SampleTexture(ShaderGraph& graph); ~SampleTexture() = default; - Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const override; + Nz::ShaderNodes::ExpressionPtr GetExpression(Nz::ShaderNodes::ExpressionPtr* /*expressions*/, std::size_t count) const override; QString caption() const override { return "Sample texture"; } QString name() const override { return "SampleTexture"; } diff --git a/src/ShaderNode/DataModels/ShaderNode.hpp b/src/ShaderNode/DataModels/ShaderNode.hpp index e7ac130c9..30e2504ca 100644 --- a/src/ShaderNode/DataModels/ShaderNode.hpp +++ b/src/ShaderNode/DataModels/ShaderNode.hpp @@ -4,7 +4,7 @@ #define NAZARA_SHADERNODES_SHADERNODE_HPP #include -#include +#include #include #include #include @@ -23,7 +23,7 @@ class ShaderNode : public QtNodes::NodeDataModel inline void DisablePreview(); void EnablePreview(bool enable = true); - virtual Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const = 0; + virtual Nz::ShaderNodes::ExpressionPtr GetExpression(Nz::ShaderNodes::ExpressionPtr* expressions, std::size_t count) const = 0; inline ShaderGraph& GetGraph(); inline const ShaderGraph& GetGraph() const; inline const std::string& GetVariableName() const; diff --git a/src/ShaderNode/DataModels/TextureValue.cpp b/src/ShaderNode/DataModels/TextureValue.cpp index d543a502e..2e25eaa03 100644 --- a/src/ShaderNode/DataModels/TextureValue.cpp +++ b/src/ShaderNode/DataModels/TextureValue.cpp @@ -106,7 +106,7 @@ void TextureValue::BuildNodeEdition(QFormLayout* layout) layout->addRow(tr("Texture"), textureSelection); } -Nz::ShaderAst::ExpressionPtr TextureValue::GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const +Nz::ShaderNodes::ExpressionPtr TextureValue::GetExpression(Nz::ShaderNodes::ExpressionPtr* /*expressions*/, std::size_t count) const { if (!m_currentTextureIndex) throw std::runtime_error("invalid texture input"); @@ -115,18 +115,18 @@ Nz::ShaderAst::ExpressionPtr TextureValue::GetExpression(Nz::ShaderAst::Expressi const auto& textureEntry = GetGraph().GetTexture(*m_currentTextureIndex); - Nz::ShaderAst::ExpressionType expression = [&] + Nz::ShaderNodes::ExpressionType expression = [&] { switch (textureEntry.type) { - case TextureType::Sampler2D: return Nz::ShaderAst::ExpressionType::Sampler2D; + case TextureType::Sampler2D: return Nz::ShaderNodes::ExpressionType::Sampler2D; } assert(false); throw std::runtime_error("Unhandled texture type"); }(); - return Nz::ShaderBuilder::Uniform(textureEntry.name, expression); + return Nz::ShaderBuilder::Identifier(Nz::ShaderBuilder::Uniform(textureEntry.name, expression)); } auto TextureValue::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const -> QtNodes::NodeDataType diff --git a/src/ShaderNode/DataModels/TextureValue.hpp b/src/ShaderNode/DataModels/TextureValue.hpp index 89cfcff21..dfb7efaff 100644 --- a/src/ShaderNode/DataModels/TextureValue.hpp +++ b/src/ShaderNode/DataModels/TextureValue.hpp @@ -18,7 +18,7 @@ class TextureValue : public ShaderNode void BuildNodeEdition(QFormLayout* layout) override; - Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const override; + Nz::ShaderNodes::ExpressionPtr GetExpression(Nz::ShaderNodes::ExpressionPtr* /*expressions*/, std::size_t count) const override; QString caption() const override { return "Texture"; } QString name() const override { return "Texture"; } diff --git a/src/ShaderNode/DataModels/VecBinOp.hpp b/src/ShaderNode/DataModels/VecBinOp.hpp index 977b0d3ba..d00049c04 100644 --- a/src/ShaderNode/DataModels/VecBinOp.hpp +++ b/src/ShaderNode/DataModels/VecBinOp.hpp @@ -6,14 +6,14 @@ #include #include -template +template class VecBinOp : public ShaderNode { public: VecBinOp(ShaderGraph& graph); ~VecBinOp() = default; - Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const override; + Nz::ShaderNodes::ExpressionPtr GetExpression(Nz::ShaderNodes::ExpressionPtr* expressions, std::size_t count) const override; unsigned int nPorts(QtNodes::PortType portType) const override; @@ -37,10 +37,10 @@ class VecBinOp : public ShaderNode std::shared_ptr m_output; }; -class VecAdd : public VecBinOp +class VecAdd : public VecBinOp { public: - using VecBinOp::VecBinOp; + using VecBinOp::VecBinOp; QString caption() const override; QString name() const override; @@ -48,10 +48,10 @@ class VecAdd : public VecBinOp void ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) override; }; -class VecMul : public VecBinOp +class VecMul : public VecBinOp { public: - using VecBinOp::VecBinOp; + using VecBinOp::VecBinOp; QString caption() const override; QString name() const override; @@ -59,10 +59,10 @@ class VecMul : public VecBinOp void ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) override; }; -class VecSub : public VecBinOp +class VecSub : public VecBinOp { public: - using VecBinOp::VecBinOp; + using VecBinOp::VecBinOp; QString caption() const override; QString name() const override; @@ -70,10 +70,10 @@ class VecSub : public VecBinOp void ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) override; }; -class VecDiv : public VecBinOp +class VecDiv : public VecBinOp { public: - using VecBinOp::VecBinOp; + using VecBinOp::VecBinOp; QString caption() const override; QString name() const override; diff --git a/src/ShaderNode/DataModels/VecBinOp.inl b/src/ShaderNode/DataModels/VecBinOp.inl index 5a12aff08..255946543 100644 --- a/src/ShaderNode/DataModels/VecBinOp.inl +++ b/src/ShaderNode/DataModels/VecBinOp.inl @@ -1,15 +1,15 @@ #include #include -template +template VecBinOp::VecBinOp(ShaderGraph& graph) : ShaderNode(graph) { UpdateOutput(); } -template -Nz::ShaderAst::ExpressionPtr VecBinOp::GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const +template +Nz::ShaderNodes::ExpressionPtr VecBinOp::GetExpression(Nz::ShaderNodes::ExpressionPtr* expressions, std::size_t count) const { assert(count == 2); using BuilderType = typename Nz::ShaderBuilder::template BinOpBuilder; @@ -17,7 +17,7 @@ Nz::ShaderAst::ExpressionPtr VecBinOp::GetExpression(Nz::ShaderAst::Expre return builder(expressions[0], expressions[1]); } -template +template QtNodes::NodeDataType VecBinOp::dataType(QtNodes::PortType /*portType*/, QtNodes::PortIndex portIndex) const { assert(portIndex == 0 || portIndex == 1); @@ -25,7 +25,7 @@ QtNodes::NodeDataType VecBinOp::dataType(QtNodes::PortType /*portType*/, return VecData::Type(); } -template +template unsigned int VecBinOp::nPorts(QtNodes::PortType portType) const { switch (portType) @@ -37,14 +37,14 @@ unsigned int VecBinOp::nPorts(QtNodes::PortType portType) const return 0; } -template +template std::shared_ptr VecBinOp::outData(QtNodes::PortIndex port) { assert(port == 0); return m_output; } -template +template void VecBinOp::setInData(std::shared_ptr value, int index) { assert(index == 0 || index == 1); @@ -65,7 +65,7 @@ void VecBinOp::setInData(std::shared_ptr value, int in UpdateOutput(); } -template +template QtNodes::NodeValidationState VecBinOp::validationState() const { if (!m_lhs || !m_rhs) @@ -77,7 +77,7 @@ QtNodes::NodeValidationState VecBinOp::validationState() const return QtNodes::NodeValidationState::Valid; } -template +template QString VecBinOp::validationMessage() const { if (!m_lhs || !m_rhs) @@ -89,7 +89,7 @@ QString VecBinOp::validationMessage() const return QString(); } -template +template bool VecBinOp::ComputePreview(QPixmap& pixmap) { if (!m_lhs || !m_rhs) @@ -99,7 +99,7 @@ bool VecBinOp::ComputePreview(QPixmap& pixmap) return true; } -template +template void VecBinOp::UpdateOutput() { if (validationState() != QtNodes::NodeValidationState::Valid) diff --git a/src/ShaderNode/DataModels/VecDot.cpp b/src/ShaderNode/DataModels/VecDot.cpp index 47b67b72c..48aac108c 100644 --- a/src/ShaderNode/DataModels/VecDot.cpp +++ b/src/ShaderNode/DataModels/VecDot.cpp @@ -1,5 +1,5 @@ #include -#include +#include VecDot::VecDot(ShaderGraph& graph) : ShaderNode(graph) @@ -8,11 +8,11 @@ ShaderNode(graph) UpdateOutput(); } -Nz::ShaderAst::ExpressionPtr VecDot::GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const +Nz::ShaderNodes::ExpressionPtr VecDot::GetExpression(Nz::ShaderNodes::ExpressionPtr* expressions, std::size_t count) const { assert(count == 2); - using namespace Nz::ShaderAst; - return BinaryFunc::Build(BinaryIntrinsic::DotProduct, expressions[0], expressions[1]); + using namespace Nz::ShaderNodes; + return IntrinsicCall::Build(IntrinsicType::DotProduct, { expressions[0], expressions[1] }); } QString VecDot::caption() const diff --git a/src/ShaderNode/DataModels/VecDot.hpp b/src/ShaderNode/DataModels/VecDot.hpp index dc92bb5c8..74e6a7266 100644 --- a/src/ShaderNode/DataModels/VecDot.hpp +++ b/src/ShaderNode/DataModels/VecDot.hpp @@ -13,7 +13,7 @@ class VecDot : public ShaderNode VecDot(ShaderGraph& graph); ~VecDot() = default; - Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const override; + Nz::ShaderNodes::ExpressionPtr GetExpression(Nz::ShaderNodes::ExpressionPtr* expressions, std::size_t count) const override; QString caption() const override; QString name() const override; diff --git a/src/ShaderNode/DataModels/VecFloatMul.cpp b/src/ShaderNode/DataModels/VecFloatMul.cpp index f4ec6f957..3c10d08e2 100644 --- a/src/ShaderNode/DataModels/VecFloatMul.cpp +++ b/src/ShaderNode/DataModels/VecFloatMul.cpp @@ -1,5 +1,5 @@ #include -#include +#include VecFloatMul::VecFloatMul(ShaderGraph& graph) : ShaderNode(graph) @@ -7,10 +7,10 @@ ShaderNode(graph) UpdateOutput(); } -Nz::ShaderAst::ExpressionPtr VecFloatMul::GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const +Nz::ShaderNodes::ExpressionPtr VecFloatMul::GetExpression(Nz::ShaderNodes::ExpressionPtr* expressions, std::size_t count) const { assert(count == 2); - using namespace Nz::ShaderAst; + using namespace Nz::ShaderNodes; return BinaryOp::Build(BinaryType::Multiply, expressions[0], expressions[1]); } diff --git a/src/ShaderNode/DataModels/VecFloatMul.hpp b/src/ShaderNode/DataModels/VecFloatMul.hpp index c4a9a97f7..dd1fbd1af 100644 --- a/src/ShaderNode/DataModels/VecFloatMul.hpp +++ b/src/ShaderNode/DataModels/VecFloatMul.hpp @@ -13,7 +13,7 @@ class VecFloatMul : public ShaderNode VecFloatMul(ShaderGraph& graph); ~VecFloatMul() = default; - Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const override; + Nz::ShaderNodes::ExpressionPtr GetExpression(Nz::ShaderNodes::ExpressionPtr* expressions, std::size_t count) const override; QString caption() const override; QString name() const override; diff --git a/src/ShaderNode/DataModels/VecValue.hpp b/src/ShaderNode/DataModels/VecValue.hpp index fe94e67cb..86cd93692 100644 --- a/src/ShaderNode/DataModels/VecValue.hpp +++ b/src/ShaderNode/DataModels/VecValue.hpp @@ -29,7 +29,7 @@ class VecValue : public ShaderNode void BuildNodeEdition(QFormLayout* layout) override; - Nz::ShaderAst::ExpressionPtr GetExpression(Nz::ShaderAst::ExpressionPtr* expressions, std::size_t count) const override; + Nz::ShaderNodes::ExpressionPtr GetExpression(Nz::ShaderNodes::ExpressionPtr* expressions, std::size_t count) const override; private: bool ComputePreview(QPixmap& pixmap) override; diff --git a/src/ShaderNode/DataModels/VecValue.inl b/src/ShaderNode/DataModels/VecValue.inl index a3ea2068e..8e158b94b 100644 --- a/src/ShaderNode/DataModels/VecValue.inl +++ b/src/ShaderNode/DataModels/VecValue.inl @@ -94,7 +94,7 @@ void VecValue::BuildNodeEdition(QFormLayout* layout) } template -Nz::ShaderAst::ExpressionPtr VecValue::GetExpression(Nz::ShaderAst::ExpressionPtr* /*expressions*/, std::size_t count) const +Nz::ShaderNodes::ExpressionPtr VecValue::GetExpression(Nz::ShaderNodes::ExpressionPtr* /*expressions*/, std::size_t count) const { assert(count == 0); diff --git a/src/ShaderNode/DataTypes/TextureData.hpp b/src/ShaderNode/DataTypes/TextureData.hpp index 778e66e05..632fa5bde 100644 --- a/src/ShaderNode/DataTypes/TextureData.hpp +++ b/src/ShaderNode/DataTypes/TextureData.hpp @@ -3,7 +3,7 @@ #ifndef NAZARA_SHADERNODES_TEXTUREDATA_HPP #define NAZARA_SHADERNODES_TEXTUREDATA_HPP -#include +#include #include #include diff --git a/src/ShaderNode/DataTypes/VecData.cpp b/src/ShaderNode/DataTypes/VecData.cpp index c1f883079..2d4a38001 100644 --- a/src/ShaderNode/DataTypes/VecData.cpp +++ b/src/ShaderNode/DataTypes/VecData.cpp @@ -2,13 +2,13 @@ #include #include -Nz::ShaderAst::ExpressionType VecData::GetExpressionType() const +Nz::ShaderNodes::ExpressionType VecData::GetExpressionType() const { switch (componentCount) { - case 2: return Nz::ShaderAst::ExpressionType::Float2; - case 3: return Nz::ShaderAst::ExpressionType::Float3; - case 4: return Nz::ShaderAst::ExpressionType::Float4; + case 2: return Nz::ShaderNodes::ExpressionType::Float2; + case 3: return Nz::ShaderNodes::ExpressionType::Float3; + case 4: return Nz::ShaderNodes::ExpressionType::Float4; default: break; } diff --git a/src/ShaderNode/DataTypes/VecData.hpp b/src/ShaderNode/DataTypes/VecData.hpp index 5c19be942..f333f9483 100644 --- a/src/ShaderNode/DataTypes/VecData.hpp +++ b/src/ShaderNode/DataTypes/VecData.hpp @@ -3,7 +3,7 @@ #ifndef NAZARA_SHADERNODES_VECDATA_HPP #define NAZARA_SHADERNODES_VECDATA_HPP -#include +#include #include #include @@ -13,7 +13,7 @@ struct VecData : public QtNodes::NodeData inline QtNodes::NodeDataType type() const override; - Nz::ShaderAst::ExpressionType GetExpressionType() const; + Nz::ShaderNodes::ExpressionType GetExpressionType() const; static inline QtNodes::NodeDataType Type(); @@ -27,28 +27,28 @@ struct VecExpressionTypeHelper; template<> struct VecExpressionTypeHelper<1> { - static constexpr Nz::ShaderAst::ExpressionType ExpressionType = Nz::ShaderAst::ExpressionType::Float1; + static constexpr Nz::ShaderNodes::ExpressionType ExpressionType = Nz::ShaderNodes::ExpressionType::Float1; }; template<> struct VecExpressionTypeHelper<2> { - static constexpr Nz::ShaderAst::ExpressionType ExpressionType = Nz::ShaderAst::ExpressionType::Float2; + static constexpr Nz::ShaderNodes::ExpressionType ExpressionType = Nz::ShaderNodes::ExpressionType::Float2; }; template<> struct VecExpressionTypeHelper<3> { - static constexpr Nz::ShaderAst::ExpressionType ExpressionType = Nz::ShaderAst::ExpressionType::Float3; + static constexpr Nz::ShaderNodes::ExpressionType ExpressionType = Nz::ShaderNodes::ExpressionType::Float3; }; template<> struct VecExpressionTypeHelper<4> { - static constexpr Nz::ShaderAst::ExpressionType ExpressionType = Nz::ShaderAst::ExpressionType::Float4; + static constexpr Nz::ShaderNodes::ExpressionType ExpressionType = Nz::ShaderNodes::ExpressionType::Float4; }; -template constexpr Nz::ShaderAst::ExpressionType VecExpressionType = VecExpressionTypeHelper::template ExpressionType; +template constexpr Nz::ShaderNodes::ExpressionType VecExpressionType = VecExpressionTypeHelper::template ExpressionType; struct VecTypeDummy {}; diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp index 06b0ddea0..880afb2a9 100644 --- a/src/ShaderNode/ShaderGraph.cpp +++ b/src/ShaderNode/ShaderGraph.cpp @@ -46,9 +46,9 @@ m_flowScene(BuildRegistry()) }); // Test - AddInput("UV", InOutType::Float2, InputRole::TexCoord, 0); - AddOutput("RenderTarget0", InOutType::Float4); - AddTexture("Potato", TextureType::Sampler2D); + AddInput("UV", InOutType::Float2, InputRole::TexCoord, 0, 0); + AddOutput("RenderTarget0", InOutType::Float4, 0); + AddTexture("Potato", TextureType::Sampler2D, 1); UpdateTexturePreview(0, QImage(R"(C:\Users\Lynix\Pictures\potatavril.png)")); @@ -79,10 +79,11 @@ ShaderGraph::~ShaderGraph() m_flowScene.clearScene(); } -std::size_t ShaderGraph::AddInput(std::string name, InOutType type, InputRole role, std::size_t roleIndex) +std::size_t ShaderGraph::AddInput(std::string name, InOutType type, InputRole role, std::size_t roleIndex, std::size_t locationIndex) { std::size_t index = m_inputs.size(); auto& inputEntry = m_inputs.emplace_back(); + inputEntry.locationIndex = locationIndex; inputEntry.name = std::move(name); inputEntry.role = role; inputEntry.roleIndex = roleIndex; @@ -93,10 +94,11 @@ std::size_t ShaderGraph::AddInput(std::string name, InOutType type, InputRole ro return index; } -std::size_t ShaderGraph::AddOutput(std::string name, InOutType type) +std::size_t ShaderGraph::AddOutput(std::string name, InOutType type, std::size_t locationIndex) { std::size_t index = m_outputs.size(); auto& outputEntry = m_outputs.emplace_back(); + outputEntry.locationIndex = locationIndex; outputEntry.name = std::move(name); outputEntry.type = type; @@ -105,10 +107,11 @@ std::size_t ShaderGraph::AddOutput(std::string name, InOutType type) return index; } -std::size_t ShaderGraph::AddTexture(std::string name, TextureType type) +std::size_t ShaderGraph::AddTexture(std::string name, TextureType type, std::size_t bindingIndex) { std::size_t index = m_textures.size(); auto& textureEntry = m_textures.emplace_back(); + textureEntry.bindingIndex = bindingIndex; textureEntry.name = std::move(name); textureEntry.type = type; @@ -141,6 +144,7 @@ void ShaderGraph::Load(const QJsonObject& data) QJsonObject inputDoc = inputDocRef.toObject(); InputEntry& input = m_inputs.emplace_back(); + input.locationIndex = static_cast(inputDoc["locationIndex"].toInt(0)); input.name = inputDoc["name"].toString().toStdString(); input.role = DecodeEnum(inputDoc["role"].toString().toStdString()).value(); input.roleIndex = static_cast(inputDoc["roleIndex"].toInt(0)); @@ -155,6 +159,7 @@ void ShaderGraph::Load(const QJsonObject& data) QJsonObject outputDoc = outputDocRef.toObject(); OutputEntry& output = m_outputs.emplace_back(); + output.locationIndex = static_cast(outputDoc["locationIndex"].toInt(0)); output.name = outputDoc["name"].toString().toStdString(); output.type = DecodeEnum(outputDoc["type"].toString().toStdString()).value(); } @@ -167,6 +172,7 @@ void ShaderGraph::Load(const QJsonObject& data) QJsonObject textureDoc = textureDocRef.toObject(); TextureEntry& texture = m_textures.emplace_back(); + texture.bindingIndex = static_cast(textureDoc["bindingIndex"].toInt(0)); texture.name = textureDoc["name"].toString().toStdString(); texture.type = DecodeEnum(textureDoc["type"].toString().toStdString()).value(); } @@ -189,6 +195,7 @@ QJsonObject ShaderGraph::Save() for (const auto& input : m_inputs) { QJsonObject inputDoc; + inputDoc["locationIndex"] = int(input.locationIndex); inputDoc["name"] = QString::fromStdString(input.name); inputDoc["role"] = QString(EnumToString(input.role)); inputDoc["roleIndex"] = int(input.roleIndex); @@ -204,6 +211,7 @@ QJsonObject ShaderGraph::Save() for (const auto& output : m_outputs) { QJsonObject outputDoc; + outputDoc["locationIndex"] = int(output.locationIndex); outputDoc["name"] = QString::fromStdString(output.name); outputDoc["type"] = QString(EnumToString(output.type)); @@ -217,6 +225,7 @@ QJsonObject ShaderGraph::Save() for (const auto& texture : m_textures) { QJsonObject textureDoc; + textureDoc["bindingIndex"] = int(texture.bindingIndex); textureDoc["name"] = QString::fromStdString(texture.name); textureDoc["type"] = QString(EnumToString(texture.type)); @@ -247,9 +256,9 @@ QJsonObject ShaderGraph::Save() return sceneJson; } -Nz::ShaderAst::StatementPtr ShaderGraph::ToAst() +Nz::ShaderNodes::StatementPtr ShaderGraph::ToAst() { - std::vector statements; + std::vector statements; QHash usageCount; std::function DetectVariables; @@ -278,13 +287,13 @@ Nz::ShaderAst::StatementPtr ShaderGraph::ToAst() DetectVariables(node); }); - QHash variableExpressions; + QHash variableExpressions; unsigned int varCount = 0; std::unordered_set usedVariableNames; - std::function HandleNode; - HandleNode = [&](QtNodes::Node* node) -> Nz::ShaderAst::ExpressionPtr + std::function HandleNode; + HandleNode = [&](QtNodes::Node* node) -> Nz::ShaderNodes::ExpressionPtr { ShaderNode* shaderNode = static_cast(node->nodeDataModel()); if (shaderNode->validationState() != QtNodes::NodeValidationState::Valid) @@ -298,7 +307,7 @@ Nz::ShaderAst::StatementPtr ShaderGraph::ToAst() assert(it != usageCount.end()); std::size_t inputCount = shaderNode->nPorts(QtNodes::PortType::In); - Nz::StackArray expressions = NazaraStackArray(Nz::ShaderAst::ExpressionPtr, inputCount); + Nz::StackArray expressions = NazaraStackArray(Nz::ShaderNodes::ExpressionPtr, inputCount); std::size_t i = 0; for (const auto& connectionSet : node->nodeState().getEntries(QtNodes::PortType::In)) @@ -316,8 +325,8 @@ Nz::ShaderAst::StatementPtr ShaderGraph::ToAst() const std::string& variableName = shaderNode->GetVariableName(); if (*it > 1 || !variableName.empty()) { - Nz::ShaderAst::ExpressionPtr varExpression; - if (expression->GetExpressionCategory() == Nz::ShaderAst::ExpressionCategory::RValue) + Nz::ShaderNodes::ExpressionPtr varExpression; + if (expression->GetExpressionCategory() == Nz::ShaderNodes::ExpressionCategory::RValue) { std::string name; if (variableName.empty()) @@ -330,10 +339,10 @@ Nz::ShaderAst::StatementPtr ShaderGraph::ToAst() usedVariableNames.insert(name); - auto variable = Nz::ShaderBuilder::Variable(std::move(name), expression->GetExpressionType()); + auto variable = Nz::ShaderBuilder::Local(std::move(name), expression->GetExpressionType()); statements.emplace_back(Nz::ShaderBuilder::DeclareVariable(variable, expression)); - varExpression = variable; + varExpression = Nz::ShaderBuilder::Identifier(variable); } else varExpression = expression; @@ -354,13 +363,14 @@ Nz::ShaderAst::StatementPtr ShaderGraph::ToAst() } }); - return Nz::ShaderAst::StatementBlock::Build(std::move(statements)); + return Nz::ShaderNodes::StatementBlock::Build(std::move(statements)); } -void ShaderGraph::UpdateInput(std::size_t inputIndex, std::string name, InOutType type, InputRole role, std::size_t roleIndex) +void ShaderGraph::UpdateInput(std::size_t inputIndex, std::string name, InOutType type, InputRole role, std::size_t roleIndex, std::size_t locationIndex) { assert(inputIndex < m_inputs.size()); auto& inputEntry = m_inputs[inputIndex]; + inputEntry.locationIndex = locationIndex; inputEntry.name = std::move(name); inputEntry.role = role; inputEntry.roleIndex = roleIndex; @@ -369,10 +379,11 @@ void ShaderGraph::UpdateInput(std::size_t inputIndex, std::string name, InOutTyp OnInputUpdate(this, inputIndex); } -void ShaderGraph::UpdateOutput(std::size_t outputIndex, std::string name, InOutType type) +void ShaderGraph::UpdateOutput(std::size_t outputIndex, std::string name, InOutType type, std::size_t locationIndex) { assert(outputIndex < m_outputs.size()); auto& outputEntry = m_outputs[outputIndex]; + outputEntry.locationIndex = locationIndex; outputEntry.name = std::move(name); outputEntry.type = type; diff --git a/src/ShaderNode/ShaderGraph.hpp b/src/ShaderNode/ShaderGraph.hpp index 536a01dcc..add7e52ab 100644 --- a/src/ShaderNode/ShaderGraph.hpp +++ b/src/ShaderNode/ShaderGraph.hpp @@ -4,7 +4,7 @@ #define NAZARA_SHADERNODES_SHADERGRAPH_HPP #include -#include +#include #include #include #include @@ -23,9 +23,9 @@ class ShaderGraph ShaderGraph(); ~ShaderGraph(); - std::size_t AddInput(std::string name, InOutType type, InputRole role, std::size_t roleIndex); - std::size_t AddOutput(std::string name, InOutType type); - std::size_t AddTexture(std::string name, TextureType type); + std::size_t AddInput(std::string name, InOutType type, InputRole role, std::size_t roleIndex, std::size_t locationIndex); + std::size_t AddOutput(std::string name, InOutType type, std::size_t locationIndex); + std::size_t AddTexture(std::string name, TextureType type, std::size_t bindingIndex); void Clear(); @@ -44,14 +44,15 @@ class ShaderGraph void Load(const QJsonObject& data); QJsonObject Save(); - Nz::ShaderAst::StatementPtr ToAst(); + Nz::ShaderNodes::StatementPtr ToAst(); - void UpdateInput(std::size_t inputIndex, std::string name, InOutType type, InputRole role, std::size_t roleIndex); - void UpdateOutput(std::size_t outputIndex, std::string name, InOutType type); + void UpdateInput(std::size_t inputIndex, std::string name, InOutType type, InputRole role, std::size_t roleIndex, std::size_t locationIndex); + void UpdateOutput(std::size_t outputIndex, std::string name, InOutType type, std::size_t locationIndex); void UpdateTexturePreview(std::size_t texture, QImage preview); struct InputEntry { + std::size_t locationIndex; std::size_t roleIndex; std::string name; InputRole role; @@ -60,12 +61,14 @@ class ShaderGraph struct OutputEntry { + std::size_t locationIndex; std::string name; InOutType type; }; struct TextureEntry { + std::size_t bindingIndex; std::string name; TextureType type; QImage preview; diff --git a/src/ShaderNode/Widgets/InputEditDialog.cpp b/src/ShaderNode/Widgets/InputEditDialog.cpp index 09f711f3d..bd56fd598 100644 --- a/src/ShaderNode/Widgets/InputEditDialog.cpp +++ b/src/ShaderNode/Widgets/InputEditDialog.cpp @@ -23,6 +23,8 @@ QDialog(parent) for (std::size_t i = 0; i < InputRoleCount; ++i) m_roleList->addItem(EnumToString(static_cast(i))); + m_locationIndex = new QSpinBox; + m_roleIndex = new QSpinBox; QFormLayout* formLayout = new QFormLayout; @@ -30,6 +32,7 @@ QDialog(parent) formLayout->addRow(tr("Type"), m_typeList); formLayout->addRow(tr("Role"), m_roleList); formLayout->addRow(tr("Role index"), m_roleIndex); + formLayout->addRow(tr("Input index"), m_locationIndex); QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); connect(buttonBox, &QDialogButtonBox::accepted, this, &InputEditDialog::OnAccept); @@ -46,6 +49,7 @@ InputEditDialog::InputEditDialog(const InputInfo& input, QWidget* parent) : InputEditDialog(parent) { m_inputName->setText(QString::fromStdString(input.name)); + m_locationIndex->setValue(int(input.locationIndex)); m_roleIndex->setValue(int(input.roleIndex)); m_roleList->setCurrentText(EnumToString(input.role)); m_typeList->setCurrentText(EnumToString(input.type)); @@ -54,6 +58,7 @@ InputEditDialog(parent) InputInfo InputEditDialog::GetInputInfo() const { InputInfo inputInfo; + inputInfo.locationIndex = static_cast(m_locationIndex->value()); inputInfo.name = m_inputName->text().toStdString(); inputInfo.role = static_cast(m_roleList->currentIndex()); inputInfo.roleIndex = static_cast(m_roleIndex->value()); diff --git a/src/ShaderNode/Widgets/InputEditDialog.hpp b/src/ShaderNode/Widgets/InputEditDialog.hpp index 633b9c99d..0f6655088 100644 --- a/src/ShaderNode/Widgets/InputEditDialog.hpp +++ b/src/ShaderNode/Widgets/InputEditDialog.hpp @@ -12,6 +12,7 @@ class QSpinBox; struct InputInfo { + std::size_t locationIndex; std::size_t roleIndex; std::string name; InputRole role; @@ -33,6 +34,7 @@ class InputEditDialog : public QDialog QComboBox* m_roleList; QComboBox* m_typeList; QLineEdit* m_inputName; + QSpinBox* m_locationIndex; QSpinBox* m_roleIndex; }; diff --git a/src/ShaderNode/Widgets/InputEditor.cpp b/src/ShaderNode/Widgets/InputEditor.cpp index a0dee923d..f281c327a 100644 --- a/src/ShaderNode/Widgets/InputEditor.cpp +++ b/src/ShaderNode/Widgets/InputEditor.cpp @@ -39,7 +39,7 @@ void InputEditor::OnAddInput() connect(dialog, &QDialog::accepted, [this, dialog] { InputInfo inputInfo = dialog->GetInputInfo(); - m_shaderGraph.AddInput(std::move(inputInfo.name), inputInfo.type, inputInfo.role, inputInfo.roleIndex); + m_shaderGraph.AddInput(std::move(inputInfo.name), inputInfo.type, inputInfo.role, inputInfo.roleIndex, inputInfo.locationIndex); }); dialog->open(); @@ -60,7 +60,7 @@ void InputEditor::OnEditInput(int inputIndex) connect(dialog, &QDialog::accepted, [this, dialog, inputIndex] { InputInfo inputInfo = dialog->GetInputInfo(); - m_shaderGraph.UpdateInput(inputIndex, std::move(inputInfo.name), inputInfo.type, inputInfo.role, inputInfo.roleIndex); + m_shaderGraph.UpdateInput(inputIndex, std::move(inputInfo.name), inputInfo.type, inputInfo.role, inputInfo.roleIndex, inputInfo.locationIndex); }); dialog->open(); diff --git a/src/ShaderNode/Widgets/MainWindow.cpp b/src/ShaderNode/Widgets/MainWindow.cpp index c30007f14..c59a59254 100644 --- a/src/ShaderNode/Widgets/MainWindow.cpp +++ b/src/ShaderNode/Widgets/MainWindow.cpp @@ -1,5 +1,7 @@ #include +#include #include +#include #include #include #include @@ -84,8 +86,6 @@ void MainWindow::BuildMenu() QMenu* shader = menu->addMenu(tr("&Shader")); { - QtNodes::FlowScene* scene = &m_shaderGraph.GetScene(); - QAction* loadShader = shader->addAction(tr("Load...")); QObject::connect(loadShader, &QAction::triggered, this, &MainWindow::OnLoad); QAction* saveShader = shader->addAction(tr("Save...")); @@ -101,8 +101,52 @@ void MainWindow::OnCompileToGLSL() { try { + Nz::ShaderNodes::StatementPtr shaderAst = m_shaderGraph.ToAst(); + + Nz::File file("shader.shader", Nz::OpenMode_WriteOnly); + file.Write(Nz::ShaderNodes::Serialize(shaderAst)); + + //TODO: Put in another function + auto GetExpressionFromInOut = [&] (InOutType type) + { + switch (type) + { + case InOutType::Bool: return Nz::ShaderNodes::ExpressionType::Boolean; + case InOutType::Float1: return Nz::ShaderNodes::ExpressionType::Float1; + case InOutType::Float2: return Nz::ShaderNodes::ExpressionType::Float2; + case InOutType::Float3: return Nz::ShaderNodes::ExpressionType::Float3; + case InOutType::Float4: return Nz::ShaderNodes::ExpressionType::Float4; + } + + assert(false); + throw std::runtime_error("Unhandled input type"); + }; + + auto GetExpressionFromTexture = [&](TextureType type) + { + switch (type) + { + case TextureType::Sampler2D: return Nz::ShaderNodes::ExpressionType::Sampler2D; + } + + assert(false); + throw std::runtime_error("Unhandled texture type"); + }; + + Nz::ShaderAst shader; + for (const auto& input : m_shaderGraph.GetInputs()) + shader.AddInput(input.name, GetExpressionFromInOut(input.type), input.locationIndex); + + for (const auto& output : m_shaderGraph.GetOutputs()) + shader.AddOutput(output.name, GetExpressionFromInOut(output.type), output.locationIndex); + + for (const auto& uniform : m_shaderGraph.GetTextures()) + shader.AddUniform(uniform.name, GetExpressionFromTexture(uniform.type), uniform.bindingIndex); + + shader.AddFunction("main", shaderAst); + Nz::GlslWriter writer; - Nz::String glsl = writer.Generate(m_shaderGraph.ToAst()); + Nz::String glsl = writer.Generate(shader); std::cout << glsl << std::endl; diff --git a/src/ShaderNode/Widgets/OutputEditDialog.cpp b/src/ShaderNode/Widgets/OutputEditDialog.cpp index 23f092f75..d2c83e58e 100644 --- a/src/ShaderNode/Widgets/OutputEditDialog.cpp +++ b/src/ShaderNode/Widgets/OutputEditDialog.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include OutputEditDialog::OutputEditDialog(QWidget* parent) : @@ -18,9 +19,12 @@ QDialog(parent) for (std::size_t i = 0; i < InOutTypeCount; ++i) m_typeList->addItem(EnumToString(static_cast(i))); + m_locationIndex = new QSpinBox; + QFormLayout* formLayout = new QFormLayout; formLayout->addRow(tr("Name"), m_outputName); formLayout->addRow(tr("Type"), m_typeList); + formLayout->addRow(tr("Output index"), m_locationIndex); QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); connect(buttonBox, &QDialogButtonBox::accepted, this, &OutputEditDialog::OnAccept); @@ -33,16 +37,18 @@ QDialog(parent) setLayout(verticalLayout); } -OutputEditDialog::OutputEditDialog(const OutputInfo& input, QWidget* parent) : +OutputEditDialog::OutputEditDialog(const OutputInfo& output, QWidget* parent) : OutputEditDialog(parent) { - m_outputName->setText(QString::fromStdString(input.name)); - m_typeList->setCurrentText(EnumToString(input.type)); + m_locationIndex->setValue(int(output.locationIndex)); + m_outputName->setText(QString::fromStdString(output.name)); + m_typeList->setCurrentText(EnumToString(output.type)); } OutputInfo OutputEditDialog::GetOutputInfo() const { OutputInfo inputInfo; + inputInfo.locationIndex = static_cast(m_locationIndex->value()); inputInfo.name = m_outputName->text().toStdString(); inputInfo.type = static_cast(m_typeList->currentIndex()); diff --git a/src/ShaderNode/Widgets/OutputEditDialog.hpp b/src/ShaderNode/Widgets/OutputEditDialog.hpp index 3c06323dd..6a8cc68fb 100644 --- a/src/ShaderNode/Widgets/OutputEditDialog.hpp +++ b/src/ShaderNode/Widgets/OutputEditDialog.hpp @@ -8,9 +8,11 @@ class QComboBox; class QLineEdit; +class QSpinBox; struct OutputInfo { + std::size_t locationIndex; std::string name; InOutType type; }; @@ -19,7 +21,7 @@ class OutputEditDialog : public QDialog { public: OutputEditDialog(QWidget* parent = nullptr); - OutputEditDialog(const OutputInfo& input, QWidget* parent = nullptr); + OutputEditDialog(const OutputInfo& output, QWidget* parent = nullptr); ~OutputEditDialog() = default; OutputInfo GetOutputInfo() const; @@ -29,6 +31,7 @@ class OutputEditDialog : public QDialog QComboBox* m_typeList; QLineEdit* m_outputName; + QSpinBox* m_locationIndex; }; #include diff --git a/src/ShaderNode/Widgets/OutputEditor.cpp b/src/ShaderNode/Widgets/OutputEditor.cpp index ba317de07..868168c8a 100644 --- a/src/ShaderNode/Widgets/OutputEditor.cpp +++ b/src/ShaderNode/Widgets/OutputEditor.cpp @@ -38,8 +38,8 @@ void OutputEditor::OnAddOutput() dialog->setAttribute(Qt::WA_DeleteOnClose, true); connect(dialog, &QDialog::accepted, [this, dialog] { - OutputInfo inputInfo = dialog->GetOutputInfo(); - m_shaderGraph.AddOutput(std::move(inputInfo.name), inputInfo.type); + OutputInfo outputInfo = dialog->GetOutputInfo(); + m_shaderGraph.AddOutput(std::move(outputInfo.name), outputInfo.type, outputInfo.locationIndex); }); dialog->open(); @@ -57,8 +57,8 @@ void OutputEditor::OnEditOutput(int inputIndex) dialog->setAttribute(Qt::WA_DeleteOnClose, true); connect(dialog, &QDialog::accepted, [this, dialog, inputIndex] { - OutputInfo inputInfo = dialog->GetOutputInfo(); - m_shaderGraph.UpdateOutput(inputIndex, std::move(inputInfo.name), inputInfo.type); + OutputInfo outputInfo = dialog->GetOutputInfo(); + m_shaderGraph.UpdateOutput(inputIndex, std::move(outputInfo.name), outputInfo.type, outputInfo.locationIndex); }); dialog->open(); From 40ade49767d901b73f84b4812b2e48c68a17f10f Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 17 Jun 2020 16:00:16 +0200 Subject: [PATCH 245/316] Update global headers --- include/Nazara/Core.hpp | 1 + include/Nazara/OpenGLRenderer.hpp | 56 +++++++++++++++++++++++++++++++ include/Nazara/Renderer.hpp | 7 ++++ 3 files changed, 64 insertions(+) create mode 100644 include/Nazara/OpenGLRenderer.hpp diff --git a/include/Nazara/Core.hpp b/include/Nazara/Core.hpp index 579a0c267..0bcef73cf 100644 --- a/include/Nazara/Core.hpp +++ b/include/Nazara/Core.hpp @@ -62,6 +62,7 @@ #include #include #include +#include #include #include #include diff --git a/include/Nazara/OpenGLRenderer.hpp b/include/Nazara/OpenGLRenderer.hpp new file mode 100644 index 000000000..e74b11c6a --- /dev/null +++ b/include/Nazara/OpenGLRenderer.hpp @@ -0,0 +1,56 @@ +// This file was automatically generated + +/* + Nazara Engine - OpenGL + + 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_GLOBAL_OPENGLRENDERER_HPP +#define NAZARA_GLOBAL_OPENGLRENDERER_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // NAZARA_GLOBAL_OPENGLRENDERER_HPP diff --git a/include/Nazara/Renderer.hpp b/include/Nazara/Renderer.hpp index fad7760fc..32e4f43de 100644 --- a/include/Nazara/Renderer.hpp +++ b/include/Nazara/Renderer.hpp @@ -55,7 +55,14 @@ #include #include #include +#include +#include +#include #include +#include +#include +#include +#include #include #include #include From 0ff10bf1e2978cc53bd749c895c54c1a2dee4ab7 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 17 Jun 2020 16:07:58 +0200 Subject: [PATCH 246/316] Improve GLSL output when using intrinsic --- src/Nazara/Renderer/GlslWriter.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Nazara/Renderer/GlslWriter.cpp b/src/Nazara/Renderer/GlslWriter.cpp index 8d8e024e7..f32239663 100644 --- a/src/Nazara/Renderer/GlslWriter.cpp +++ b/src/Nazara/Renderer/GlslWriter.cpp @@ -368,17 +368,17 @@ namespace Nz break; } - m_currentState->stream << '('; + Append("("); for (std::size_t i = 0; i < node.parameters.size(); ++i) { if (i != 0) - m_currentState->stream << ", "; + Append(", "); Visit(node.parameters[i]); - m_currentState->stream << ' '; + Append(" "); Visit(node.parameters[i]); } - m_currentState->stream << ")\n"; + Append(")"); } void GlslWriter::Visit(const ShaderNodes::LocalVariable& var) From 736ca1c409ef0f81df0cd39b7f10cb9b13562cfa Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 17 Jun 2020 20:09:21 +0200 Subject: [PATCH 247/316] Renderer/ShaderAst: Add serialization --- include/Nazara/Renderer/ShaderNodes.hpp | 32 +-- include/Nazara/Renderer/ShaderNodes.inl | 23 +- include/Nazara/Renderer/ShaderSerializer.hpp | 54 ++-- include/Nazara/Renderer/ShaderSerializer.inl | 24 +- src/Nazara/Renderer/GlslWriter.cpp | 4 +- src/Nazara/Renderer/ShaderSerializer.cpp | 260 ++++++++++++++----- src/ShaderNode/Widgets/MainWindow.cpp | 6 +- 7 files changed, 285 insertions(+), 118 deletions(-) diff --git a/include/Nazara/Renderer/ShaderNodes.hpp b/include/Nazara/Renderer/ShaderNodes.hpp index d6bafc911..659e643a3 100644 --- a/include/Nazara/Renderer/ShaderNodes.hpp +++ b/include/Nazara/Renderer/ShaderNodes.hpp @@ -34,6 +34,7 @@ namespace Nz virtual ~Node(); inline NodeType GetType() const; + inline bool IsStatement() const; virtual void Visit(ShaderVisitor& visitor) = 0; @@ -41,10 +42,24 @@ namespace Nz static inline ExpressionType GetComponentType(ExpressionType type); protected: - inline Node(NodeType type); + inline Node(NodeType type, bool isStatement); private: NodeType m_type; + bool m_isStatement; + }; + + class Expression; + + using ExpressionPtr = std::shared_ptr; + + class NAZARA_RENDERER_API Expression : public Node + { + public: + inline Expression(NodeType type); + + virtual ExpressionCategory GetExpressionCategory() const; + virtual ExpressionType GetExpressionType() const = 0; }; class Statement; @@ -54,20 +69,7 @@ namespace Nz class NAZARA_RENDERER_API Statement : public Node { public: - using Node::Node; - }; - - class Expression; - - using ExpressionPtr = std::shared_ptr; - - class NAZARA_RENDERER_API Expression : public Node - { - public: - using Node::Node; - - virtual ExpressionCategory GetExpressionCategory() const; - virtual ExpressionType GetExpressionType() const = 0; + inline Statement(NodeType type); }; struct NAZARA_RENDERER_API ExpressionStatement : public Statement diff --git a/include/Nazara/Renderer/ShaderNodes.inl b/include/Nazara/Renderer/ShaderNodes.inl index 1bcf4effa..bafad38f5 100644 --- a/include/Nazara/Renderer/ShaderNodes.inl +++ b/include/Nazara/Renderer/ShaderNodes.inl @@ -7,8 +7,9 @@ namespace Nz::ShaderNodes { - inline Node::Node(NodeType type) : - m_type(type) + inline Node::Node(NodeType type, bool isStatement) : + m_type(type), + m_isStatement(isStatement) { } @@ -17,6 +18,11 @@ namespace Nz::ShaderNodes return m_type; } + inline bool Node::IsStatement() const + { + return m_isStatement; + } + inline unsigned int Node::GetComponentCount(ExpressionType type) { switch (type) @@ -55,6 +61,19 @@ namespace Nz::ShaderNodes } } + + inline Expression::Expression(NodeType type) : + Node(type, false) + { + } + + inline Statement::Statement(NodeType type) : + Node(type, true) + { + } + + + inline ExpressionStatement::ExpressionStatement() : Statement(NodeType::ExpressionStatement) { diff --git a/include/Nazara/Renderer/ShaderSerializer.hpp b/include/Nazara/Renderer/ShaderSerializer.hpp index daeb13e73..a5e012a9c 100644 --- a/include/Nazara/Renderer/ShaderSerializer.hpp +++ b/include/Nazara/Renderer/ShaderSerializer.hpp @@ -14,8 +14,10 @@ #include #include -namespace Nz::ShaderNodes +namespace Nz { + class ShaderAst; + class NAZARA_RENDERER_API ShaderSerializerBase { public: @@ -24,28 +26,29 @@ namespace Nz::ShaderNodes ShaderSerializerBase(ShaderSerializerBase&&) = delete; ~ShaderSerializerBase() = default; - void Serialize(AssignOp& node); - void Serialize(BinaryOp& node); - void Serialize(BuiltinVariable& var); - void Serialize(Branch& node); - void Serialize(Cast& node); - void Serialize(Constant& node); - void Serialize(DeclareVariable& node); - void Serialize(ExpressionStatement& node); - void Serialize(Identifier& node); - void Serialize(IntrinsicCall& node); - void Serialize(NamedVariable& var); - void Serialize(Sample2D& node); - void Serialize(StatementBlock& node); - void Serialize(SwizzleOp& node); + void Serialize(ShaderNodes::AssignOp& node); + void Serialize(ShaderNodes::BinaryOp& node); + void Serialize(ShaderNodes::BuiltinVariable& var); + void Serialize(ShaderNodes::Branch& node); + void Serialize(ShaderNodes::Cast& node); + void Serialize(ShaderNodes::Constant& node); + void Serialize(ShaderNodes::DeclareVariable& node); + void Serialize(ShaderNodes::ExpressionStatement& node); + void Serialize(ShaderNodes::Identifier& node); + void Serialize(ShaderNodes::IntrinsicCall& node); + void Serialize(ShaderNodes::NamedVariable& var); + void Serialize(ShaderNodes::Sample2D& node); + void Serialize(ShaderNodes::StatementBlock& node); + void Serialize(ShaderNodes::SwizzleOp& node); protected: template void Container(T& container); template void Enum(T& enumVal); + template void OptVal(std::optional& optVal); virtual bool IsWriting() const = 0; - virtual void Node(NodePtr& node) = 0; + virtual void Node(ShaderNodes::NodePtr& node) = 0; template void Node(std::shared_ptr& node); virtual void Value(bool& val) = 0; @@ -57,7 +60,7 @@ namespace Nz::ShaderNodes virtual void Value(UInt32& val) = 0; inline void Value(std::size_t& val); - virtual void Variable(VariablePtr& var) = 0; + virtual void Variable(ShaderNodes::VariablePtr& var) = 0; template void Variable(std::shared_ptr& var); }; @@ -67,11 +70,12 @@ namespace Nz::ShaderNodes inline ShaderSerializer(ByteArray& byteArray); ~ShaderSerializer() = default; - void Serialize(const StatementPtr& shader); + void Serialize(const ShaderAst& shader); private: bool IsWriting() const override; - void Node(NodePtr& node) override; + void Node(const ShaderNodes::NodePtr& node); + void Node(ShaderNodes::NodePtr& node) override; void Value(bool& val) override; void Value(float& val) override; void Value(std::string& val) override; @@ -79,7 +83,7 @@ namespace Nz::ShaderNodes void Value(Vector3f& val) override; void Value(Vector4f& val) override; void Value(UInt32& val) override; - void Variable(VariablePtr& var) override; + void Variable(ShaderNodes::VariablePtr& var) override; ByteArray& m_byteArray; ByteStream m_stream; @@ -91,11 +95,11 @@ namespace Nz::ShaderNodes ShaderUnserializer(const ByteArray& byteArray); ~ShaderUnserializer() = default; - StatementPtr Unserialize(); + ShaderAst Unserialize(); private: bool IsWriting() const override; - void Node(NodePtr& node) override; + void Node(ShaderNodes::NodePtr& node) override; void Value(bool& val) override; void Value(float& val) override; void Value(std::string& val) override; @@ -103,14 +107,14 @@ namespace Nz::ShaderNodes void Value(Vector3f& val) override; void Value(Vector4f& val) override; void Value(UInt32& val) override; - void Variable(VariablePtr& var) override; + void Variable(ShaderNodes::VariablePtr& var) override; const ByteArray& m_byteArray; ByteStream m_stream; }; - NAZARA_RENDERER_API ByteArray Serialize(const StatementPtr& shader); - NAZARA_RENDERER_API StatementPtr Unserialize(const ByteArray& data); + NAZARA_RENDERER_API ByteArray SerializeShader(const ShaderAst& shader); + NAZARA_RENDERER_API ShaderAst UnserializeShader(const ByteArray& data); } #include diff --git a/include/Nazara/Renderer/ShaderSerializer.inl b/include/Nazara/Renderer/ShaderSerializer.inl index 354986bb1..a2b680b95 100644 --- a/include/Nazara/Renderer/ShaderSerializer.inl +++ b/include/Nazara/Renderer/ShaderSerializer.inl @@ -5,7 +5,7 @@ #include #include -namespace Nz::ShaderNodes +namespace Nz { template void ShaderSerializerBase::Container(T& container) @@ -36,12 +36,30 @@ namespace Nz::ShaderNodes enumVal = static_cast(value); } + template + void ShaderSerializerBase::OptVal(std::optional& optVal) + { + bool isWriting = IsWriting(); + + bool hasValue; + if (isWriting) + hasValue = optVal.has_value(); + + Value(hasValue); + + if (!isWriting && hasValue) + optVal.emplace(); + + if (optVal.has_value()) + Value(optVal.value()); + } + template void ShaderSerializerBase::Node(std::shared_ptr& node) { bool isWriting = IsWriting(); - NodePtr value; + ShaderNodes::NodePtr value; if (isWriting) value = node; @@ -55,7 +73,7 @@ namespace Nz::ShaderNodes { bool isWriting = IsWriting(); - VariablePtr value; + ShaderNodes::VariablePtr value; if (isWriting) value = var; diff --git a/src/Nazara/Renderer/GlslWriter.cpp b/src/Nazara/Renderer/GlslWriter.cpp index f32239663..8617c522e 100644 --- a/src/Nazara/Renderer/GlslWriter.cpp +++ b/src/Nazara/Renderer/GlslWriter.cpp @@ -330,9 +330,7 @@ namespace Nz Append(node.variable->name); if (node.expression) { - Append(" "); - Append("="); - Append(" "); + Append(" = "); Visit(node.expression); } diff --git a/src/Nazara/Renderer/ShaderSerializer.cpp b/src/Nazara/Renderer/ShaderSerializer.cpp index 909422f52..7d1b7ac2e 100644 --- a/src/Nazara/Renderer/ShaderSerializer.cpp +++ b/src/Nazara/Renderer/ShaderSerializer.cpp @@ -3,14 +3,18 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include #include #include -namespace Nz::ShaderNodes +namespace Nz { namespace { + constexpr UInt32 s_magicNumber = 0x4E534852; + constexpr UInt32 s_currentVersion = 1; + class ShaderSerializerVisitor : public ShaderVisitor, public ShaderVarVisitor { public: @@ -19,62 +23,62 @@ namespace Nz::ShaderNodes { } - void Visit(const AssignOp& node) override + void Visit(const ShaderNodes::AssignOp& node) override { Serialize(node); } - void Visit(const BinaryOp& node) override + void Visit(const ShaderNodes::BinaryOp& node) override { Serialize(node); } - void Visit(const Branch& node) override + void Visit(const ShaderNodes::Branch& node) override { Serialize(node); } - void Visit(const Cast& node) override + void Visit(const ShaderNodes::Cast& node) override { Serialize(node); } - void Visit(const Constant& node) override + void Visit(const ShaderNodes::Constant& node) override { Serialize(node); } - void Visit(const DeclareVariable& node) override + void Visit(const ShaderNodes::DeclareVariable& node) override { Serialize(node); } - void Visit(const ExpressionStatement& node) override + void Visit(const ShaderNodes::ExpressionStatement& node) override { Serialize(node); } - void Visit(const Identifier& node) override + void Visit(const ShaderNodes::Identifier& node) override { Serialize(node); } - void Visit(const IntrinsicCall& node) override + void Visit(const ShaderNodes::IntrinsicCall& node) override { Serialize(node); } - void Visit(const Sample2D& node) override + void Visit(const ShaderNodes::Sample2D& node) override { Serialize(node); } - void Visit(const StatementBlock& node) override + void Visit(const ShaderNodes::StatementBlock& node) override { Serialize(node); } - void Visit(const SwizzleOp& node) override + void Visit(const ShaderNodes::SwizzleOp& node) override { Serialize(node); } @@ -122,21 +126,21 @@ namespace Nz::ShaderNodes }; } - void ShaderSerializerBase::Serialize(AssignOp& node) + void ShaderSerializerBase::Serialize(ShaderNodes::AssignOp& node) { Enum(node.op); Node(node.left); Node(node.right); } - void ShaderSerializerBase::Serialize(BinaryOp& node) + void ShaderSerializerBase::Serialize(ShaderNodes::BinaryOp& node) { Enum(node.op); Node(node.left); Node(node.right); } - void ShaderSerializerBase::Serialize(Branch& node) + void ShaderSerializerBase::Serialize(ShaderNodes::Branch& node) { Container(node.condStatements); for (auto& condStatement : node.condStatements) @@ -148,64 +152,64 @@ namespace Nz::ShaderNodes Node(node.elseStatement); } - void ShaderSerializerBase::Serialize(BuiltinVariable& node) + void ShaderSerializerBase::Serialize(ShaderNodes::BuiltinVariable& node) { Enum(node.type); Enum(node.type); } - void ShaderSerializerBase::Serialize(Cast& node) + void ShaderSerializerBase::Serialize(ShaderNodes::Cast& node) { Enum(node.exprType); for (auto& expr : node.expressions) Node(expr); } - void ShaderSerializerBase::Serialize(Constant& node) + void ShaderSerializerBase::Serialize(ShaderNodes::Constant& node) { Enum(node.exprType); switch (node.exprType) { - case ExpressionType::Boolean: + case ShaderNodes::ExpressionType::Boolean: Value(node.values.bool1); break; - case ExpressionType::Float1: + case ShaderNodes::ExpressionType::Float1: Value(node.values.vec1); break; - case ExpressionType::Float2: + case ShaderNodes::ExpressionType::Float2: Value(node.values.vec2); break; - case ExpressionType::Float3: + case ShaderNodes::ExpressionType::Float3: Value(node.values.vec3); break; - case ExpressionType::Float4: + case ShaderNodes::ExpressionType::Float4: Value(node.values.vec4); break; } } - void ShaderSerializerBase::Serialize(DeclareVariable& node) + void ShaderSerializerBase::Serialize(ShaderNodes::DeclareVariable& node) { Variable(node.variable); Node(node.expression); } - void ShaderSerializerBase::Serialize(ExpressionStatement& node) + void ShaderSerializerBase::Serialize(ShaderNodes::ExpressionStatement& node) { Node(node.expression); } - void ShaderSerializerBase::Serialize(Identifier& node) + void ShaderSerializerBase::Serialize(ShaderNodes::Identifier& node) { Variable(node.var); } - void ShaderSerializerBase::Serialize(IntrinsicCall& node) + void ShaderSerializerBase::Serialize(ShaderNodes::IntrinsicCall& node) { Enum(node.intrinsic); Container(node.parameters); @@ -213,26 +217,26 @@ namespace Nz::ShaderNodes Node(param); } - void ShaderSerializerBase::Serialize(NamedVariable& node) + void ShaderSerializerBase::Serialize(ShaderNodes::NamedVariable& node) { Value(node.name); Enum(node.type); } - void ShaderSerializerBase::Serialize(Sample2D& node) + void ShaderSerializerBase::Serialize(ShaderNodes::Sample2D& node) { Node(node.sampler); Node(node.coordinates); } - void ShaderSerializerBase::Serialize(StatementBlock& node) + void ShaderSerializerBase::Serialize(ShaderNodes::StatementBlock& node) { Container(node.statements); for (auto& statement : node.statements) Node(statement); } - void ShaderSerializerBase::Serialize(SwizzleOp& node) + void ShaderSerializerBase::Serialize(ShaderNodes::SwizzleOp& node) { Value(node.componentCount); Node(node.expression); @@ -242,13 +246,50 @@ namespace Nz::ShaderNodes } - void ShaderSerializer::Serialize(const StatementPtr& shader) + void ShaderSerializer::Serialize(const ShaderAst& shader) { - assert(shader); - m_stream << static_cast(shader->GetType()); + UInt32 magicNumber = s_magicNumber; + UInt32 version = s_currentVersion; - ShaderSerializerVisitor visitor(*this); - shader->Visit(visitor); + m_stream << s_magicNumber << s_currentVersion; + + auto SerializeInputOutput = [&](auto& inout) + { + m_stream << UInt32(inout.size()); + for (const auto& data : inout) + { + m_stream << data.name << UInt32(data.type); + + m_stream << data.locationIndex.has_value(); + if (data.locationIndex) + m_stream << UInt32(data.locationIndex.value()); + } + }; + + SerializeInputOutput(shader.GetInputs()); + SerializeInputOutput(shader.GetOutputs()); + + m_stream << UInt32(shader.GetUniformCount()); + for (const auto& uniform : shader.GetUniforms()) + { + m_stream << uniform.name << UInt32(uniform.type); + + m_stream << uniform.bindingIndex.has_value(); + if (uniform.bindingIndex) + m_stream << UInt32(uniform.bindingIndex.value()); + } + + m_stream << UInt32(shader.GetFunctionCount()); + for (const auto& func : shader.GetFunctions()) + { + m_stream << func.name << UInt32(func.returnType); + + m_stream << UInt32(func.parameters.size()); + for (const auto& param : func.parameters) + m_stream << param.name << UInt32(param.type); + + Node(func.statement); + } m_stream.FlushBits(); } @@ -258,9 +299,9 @@ namespace Nz::ShaderNodes return true; } - void ShaderSerializer::Node(NodePtr& node) + void ShaderSerializer::Node(ShaderNodes::NodePtr& node) { - NodeType nodeType = (node) ? node->GetType() : NodeType::None; + ShaderNodes::NodeType nodeType = (node) ? node->GetType() : ShaderNodes::NodeType::None; m_stream << static_cast(nodeType); if (node) @@ -270,6 +311,11 @@ namespace Nz::ShaderNodes } } + void ShaderSerializer::Node(const ShaderNodes::NodePtr& node) + { + Node(const_cast(node)); //< Yes const_cast is ugly but it won't be used for writing + } + void ShaderSerializer::Value(bool& val) { m_stream << val; @@ -305,9 +351,9 @@ namespace Nz::ShaderNodes m_stream << val; } - void ShaderSerializer::Variable(VariablePtr& var) + void ShaderSerializer::Variable(ShaderNodes::VariablePtr& var) { - VariableType nodeType = (var) ? var->GetType() : VariableType::None; + ShaderNodes::VariableType nodeType = (var) ? var->GetType() : ShaderNodes::VariableType::None; m_stream << static_cast(nodeType); if (var) @@ -317,29 +363,93 @@ namespace Nz::ShaderNodes } } - ByteArray Serialize(const StatementPtr& shader) + ShaderAst ShaderUnserializer::Unserialize() { - ByteArray byteArray; - ShaderSerializer serializer(byteArray); - serializer.Serialize(shader); + UInt32 magicNumber; + UInt32 version; + m_stream >> magicNumber; + if (magicNumber != s_magicNumber) + throw std::runtime_error("invalid shader file"); - return byteArray; - } + m_stream >> version; + if (version > s_currentVersion) + throw std::runtime_error("unsupported version"); - StatementPtr Unserialize(const ByteArray& data) - { - ShaderUnserializer unserializer(data); - return unserializer.Unserialize(); - } + ShaderAst shader; - StatementPtr ShaderUnserializer::Unserialize() - { - NodePtr statement; - Node(statement); - if (!statement || statement->GetType() != NodeType::StatementBlock) - throw std::runtime_error("Invalid shader"); + UInt32 inputCount; + m_stream >> inputCount; + for (UInt32 i = 0; i < inputCount; ++i) + { + std::string inputName; + ShaderNodes::ExpressionType inputType; + std::optional location; - return std::static_pointer_cast(statement); + Value(inputName); + Enum(inputType); + OptVal(location); + + shader.AddInput(std::move(inputName), inputType, location); + } + + UInt32 outputCount; + m_stream >> outputCount; + for (UInt32 i = 0; i < outputCount; ++i) + { + std::string outputName; + ShaderNodes::ExpressionType outputType; + std::optional location; + + Value(outputName); + Enum(outputType); + OptVal(location); + + shader.AddOutput(std::move(outputName), outputType, location); + } + + UInt32 uniformCount; + m_stream >> uniformCount; + for (UInt32 i = 0; i < uniformCount; ++i) + { + std::string name; + ShaderNodes::ExpressionType type; + std::optional binding; + + Value(name); + Enum(type); + OptVal(binding); + + shader.AddUniform(std::move(name), type, binding); + } + + UInt32 funcCount; + m_stream >> funcCount; + for (UInt32 i = 0; i < funcCount; ++i) + { + std::string name; + ShaderNodes::ExpressionType retType; + std::vector parameters; + + Value(name); + Enum(retType); + Container(parameters); + for (auto& param : parameters) + { + Value(param.name); + Enum(param.type); + } + + ShaderNodes::NodePtr node; + Node(node); + if (!node || !node->IsStatement()) + throw std::runtime_error("functions can only have statements"); + + ShaderNodes::StatementPtr statement = std::static_pointer_cast(node); + + shader.AddFunction(std::move(name), std::move(statement), std::move(parameters), retType); + } + + return shader; } bool ShaderUnserializer::IsWriting() const @@ -347,17 +457,17 @@ namespace Nz::ShaderNodes return false; } - void ShaderUnserializer::Node(NodePtr& node) + void ShaderUnserializer::Node(ShaderNodes::NodePtr& node) { Int32 nodeTypeInt; m_stream >> nodeTypeInt; - NodeType nodeType = static_cast(nodeTypeInt); + ShaderNodes::NodeType nodeType = static_cast(nodeTypeInt); -#define HandleType(Type) case NodeType:: Type : node = std::make_shared(); break +#define HandleType(Type) case ShaderNodes::NodeType:: Type : node = std::make_shared(); break switch (nodeType) { - case NodeType::None: break; + case ShaderNodes::NodeType::None: break; HandleType(AssignOp); HandleType(BinaryOp); @@ -417,17 +527,17 @@ namespace Nz::ShaderNodes m_stream >> val; } - void ShaderUnserializer::Variable(VariablePtr& var) + void ShaderUnserializer::Variable(ShaderNodes::VariablePtr& var) { Int32 nodeTypeInt; m_stream >> nodeTypeInt; - VariableType nodeType = static_cast(nodeTypeInt); + ShaderNodes::VariableType nodeType = static_cast(nodeTypeInt); -#define HandleType(Type) case VariableType:: Type : var = std::make_shared(); break +#define HandleType(Type) case ShaderNodes::VariableType:: Type : var = std::make_shared(); break switch (nodeType) { - case VariableType::None: break; + case ShaderNodes::VariableType::None: break; HandleType(BuiltinVariable); HandleType(InputVariable); @@ -443,5 +553,21 @@ namespace Nz::ShaderNodes var->Visit(visitor); } } + + + ByteArray SerializeShader(const ShaderAst& shader) + { + ByteArray byteArray; + ShaderSerializer serializer(byteArray); + serializer.Serialize(shader); + + return byteArray; + } + + ShaderAst UnserializeShader(const ByteArray& data) + { + ShaderUnserializer unserializer(data); + return unserializer.Unserialize(); + } } diff --git a/src/ShaderNode/Widgets/MainWindow.cpp b/src/ShaderNode/Widgets/MainWindow.cpp index c59a59254..7f39eafc3 100644 --- a/src/ShaderNode/Widgets/MainWindow.cpp +++ b/src/ShaderNode/Widgets/MainWindow.cpp @@ -103,9 +103,6 @@ void MainWindow::OnCompileToGLSL() { Nz::ShaderNodes::StatementPtr shaderAst = m_shaderGraph.ToAst(); - Nz::File file("shader.shader", Nz::OpenMode_WriteOnly); - file.Write(Nz::ShaderNodes::Serialize(shaderAst)); - //TODO: Put in another function auto GetExpressionFromInOut = [&] (InOutType type) { @@ -145,6 +142,9 @@ void MainWindow::OnCompileToGLSL() shader.AddFunction("main", shaderAst); + Nz::File file("shader.shader", Nz::OpenMode_WriteOnly); + file.Write(Nz::SerializeShader(shader)); + Nz::GlslWriter writer; Nz::String glsl = writer.Generate(shader); From 66a98b234ff1cf2412730a5552bec90d15255d19 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 18 Jun 2020 20:03:22 +0200 Subject: [PATCH 248/316] Renderer/GlslWriter: Add environment --- include/Nazara/Renderer/GlslWriter.hpp | 15 +++++- src/Nazara/Renderer/GlslWriter.cpp | 73 +++++++++++++++++++++----- 2 files changed, 73 insertions(+), 15 deletions(-) diff --git a/include/Nazara/Renderer/GlslWriter.hpp b/include/Nazara/Renderer/GlslWriter.hpp index 22d6544f2..e0f9bf11e 100644 --- a/include/Nazara/Renderer/GlslWriter.hpp +++ b/include/Nazara/Renderer/GlslWriter.hpp @@ -23,6 +23,9 @@ namespace Nz class NAZARA_RENDERER_API GlslWriter : public ShaderWriter, public ShaderVarVisitor, public ShaderVisitor { public: + struct Environment; + using ExtSupportCallback = std::function; + GlslWriter(); GlslWriter(const GlslWriter&) = delete; GlslWriter(GlslWriter&&) = delete; @@ -30,7 +33,15 @@ namespace Nz std::string Generate(const ShaderAst& shader) override; - void SetGlslVersion(unsigned int version); + void SetEnv(Environment environment); + + struct Environment + { + ExtSupportCallback extCallback; + unsigned int glMajorVersion = 3; + unsigned int glMinorVersion = 0; + bool glES = false; + }; private: void Append(ShaderNodes::BuiltinEntry builtin); @@ -82,8 +93,8 @@ namespace Nz }; Context m_context; + Environment m_environment; State* m_currentState; - unsigned int m_glslVersion; }; } diff --git a/src/Nazara/Renderer/GlslWriter.cpp b/src/Nazara/Renderer/GlslWriter.cpp index 8617c522e..b60083f6f 100644 --- a/src/Nazara/Renderer/GlslWriter.cpp +++ b/src/Nazara/Renderer/GlslWriter.cpp @@ -11,8 +11,7 @@ namespace Nz { GlslWriter::GlslWriter() : - m_currentState(nullptr), - m_glslVersion(110) + m_currentState(nullptr) { } @@ -29,22 +28,67 @@ namespace Nz m_currentState = nullptr; }); + unsigned int glslVersion; + if (m_environment.glES) + { + if (m_environment.glMajorVersion >= 3 && m_environment.glMinorVersion >= 2) + glslVersion = 320; + else if (m_environment.glMajorVersion >= 3 && m_environment.glMinorVersion >= 1) + glslVersion = 310; + else if (m_environment.glMajorVersion >= 3 && m_environment.glMinorVersion >= 0) + glslVersion = 300; + else if (m_environment.glMajorVersion >= 2 && m_environment.glMinorVersion >= 0) + glslVersion = 100; + else + throw std::runtime_error("This version of OpenGL ES does not support shaders"); + } + else + { + if (m_environment.glMajorVersion >= 3 && m_environment.glMinorVersion >= 3) + glslVersion = m_environment.glMajorVersion * 100 + m_environment.glMinorVersion * 10; + else if (m_environment.glMajorVersion >= 3 && m_environment.glMinorVersion >= 2) + glslVersion = 150; + else if (m_environment.glMajorVersion >= 3 && m_environment.glMinorVersion >= 1) + glslVersion = 140; + else if (m_environment.glMajorVersion >= 3 && m_environment.glMinorVersion >= 0) + glslVersion = 130; + else if (m_environment.glMajorVersion >= 2 && m_environment.glMinorVersion >= 1) + glslVersion = 120; + else if (m_environment.glMajorVersion >= 2 && m_environment.glMinorVersion >= 0) + glslVersion = 110; + else + throw std::runtime_error("This version of OpenGL does not support shaders"); + } + // Header Append("#version "); - AppendLine(std::to_string(m_glslVersion)); + Append(glslVersion); + if (m_environment.glES) + Append(" es"); + + AppendLine(); AppendLine(); // Extensions std::vector requiredExtensions; - // GL_ARB_shading_language_420pack (required for layout(binding = X)) - if (m_glslVersion < 420 && HasExplicitBinding(shader)) - requiredExtensions.emplace_back("GL_ARB_shading_language_420pack"); + if (!m_environment.glES && m_environment.extCallback) + { + // GL_ARB_shading_language_420pack (required for layout(binding = X)) + if (glslVersion < 420 && HasExplicitBinding(shader)) + { + if (m_environment.extCallback("GL_ARB_shading_language_420pack")) + requiredExtensions.emplace_back("GL_ARB_shading_language_420pack"); + } - // GL_ARB_explicit_uniform_location (required for layout(location = X)) - if (m_glslVersion < 430 && HasExplicitLocation(shader)) - requiredExtensions.emplace_back("GL_ARB_explicit_uniform_location"); + // GL_ARB_separate_shader_objects (required for layout(location = X)) + if (glslVersion < 410 && HasExplicitLocation(shader)) + { + if (m_environment.extCallback("GL_ARB_separate_shader_objects")) + requiredExtensions.emplace_back("GL_ARB_separate_shader_objects"); + } + } if (!requiredExtensions.empty()) { @@ -55,9 +99,12 @@ namespace Nz } // Global variables (uniforms, input and outputs) + const char* inKeyword = (glslVersion >= 130) ? "in" : "varying"; + const char* outKeyword = (glslVersion >= 130) ? "out" : "varying"; + DeclareVariables(shader.GetUniforms(), "uniform", "Uniforms"); - DeclareVariables(shader.GetInputs(), "in", "Inputs"); - DeclareVariables(shader.GetOutputs(), "out", "Outputs"); + DeclareVariables(shader.GetInputs(), inKeyword, "Inputs"); + DeclareVariables(shader.GetOutputs(), outKeyword, "Outputs"); std::size_t functionCount = shader.GetFunctionCount(); if (functionCount > 1) @@ -79,9 +126,9 @@ namespace Nz return state.stream.str(); } - void GlslWriter::SetGlslVersion(unsigned int version) + void GlslWriter::SetEnv(Environment environment) { - m_glslVersion = version; + m_environment = std::move(environment); } void GlslWriter::Append(ShaderNodes::BuiltinEntry builtin) From bc490a2fe504f29a3dbcff04800f2d2e2682c513 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 18 Jun 2020 20:03:33 +0200 Subject: [PATCH 249/316] Renderer/GlslWriter: Fix double identifier bug --- src/Nazara/Renderer/GlslWriter.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Nazara/Renderer/GlslWriter.cpp b/src/Nazara/Renderer/GlslWriter.cpp index b60083f6f..9116aa3a3 100644 --- a/src/Nazara/Renderer/GlslWriter.cpp +++ b/src/Nazara/Renderer/GlslWriter.cpp @@ -420,8 +420,6 @@ namespace Nz Append(", "); Visit(node.parameters[i]); - Append(" "); - Visit(node.parameters[i]); } Append(")"); } From 691de5b5c421e8506d0fc6ced88df6d159fafd07 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 18 Jun 2020 20:03:56 +0200 Subject: [PATCH 250/316] Renderer/ShaderSerialize: Use ByteStream instead of ByteArray --- include/Nazara/Renderer/ShaderSerializer.hpp | 12 +++++------- include/Nazara/Renderer/ShaderSerializer.inl | 10 ++++------ src/Nazara/Renderer/ShaderSerializer.cpp | 11 +++++------ 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/include/Nazara/Renderer/ShaderSerializer.hpp b/include/Nazara/Renderer/ShaderSerializer.hpp index a5e012a9c..eac0c2bf8 100644 --- a/include/Nazara/Renderer/ShaderSerializer.hpp +++ b/include/Nazara/Renderer/ShaderSerializer.hpp @@ -67,7 +67,7 @@ namespace Nz class NAZARA_RENDERER_API ShaderSerializer final : public ShaderSerializerBase { public: - inline ShaderSerializer(ByteArray& byteArray); + inline ShaderSerializer(ByteStream& stream); ~ShaderSerializer() = default; void Serialize(const ShaderAst& shader); @@ -85,14 +85,13 @@ namespace Nz void Value(UInt32& val) override; void Variable(ShaderNodes::VariablePtr& var) override; - ByteArray& m_byteArray; - ByteStream m_stream; + ByteStream& m_stream; }; class NAZARA_RENDERER_API ShaderUnserializer final : public ShaderSerializerBase { public: - ShaderUnserializer(const ByteArray& byteArray); + ShaderUnserializer(ByteStream& stream); ~ShaderUnserializer() = default; ShaderAst Unserialize(); @@ -109,12 +108,11 @@ namespace Nz void Value(UInt32& val) override; void Variable(ShaderNodes::VariablePtr& var) override; - const ByteArray& m_byteArray; - ByteStream m_stream; + ByteStream& m_stream; }; NAZARA_RENDERER_API ByteArray SerializeShader(const ShaderAst& shader); - NAZARA_RENDERER_API ShaderAst UnserializeShader(const ByteArray& data); + NAZARA_RENDERER_API ShaderAst UnserializeShader(ByteStream& stream); } #include diff --git a/include/Nazara/Renderer/ShaderSerializer.inl b/include/Nazara/Renderer/ShaderSerializer.inl index a2b680b95..0daeb6653 100644 --- a/include/Nazara/Renderer/ShaderSerializer.inl +++ b/include/Nazara/Renderer/ShaderSerializer.inl @@ -95,15 +95,13 @@ namespace Nz val = static_cast(value); } - inline ShaderSerializer::ShaderSerializer(ByteArray& byteArray) : - m_byteArray(byteArray), - m_stream(&m_byteArray, OpenModeFlags(OpenMode_WriteOnly)) + inline ShaderSerializer::ShaderSerializer(ByteStream& stream) : + m_stream(stream) { } - inline ShaderUnserializer::ShaderUnserializer(const ByteArray& byteArray) : - m_byteArray(byteArray), - m_stream(const_cast(&m_byteArray), OpenModeFlags(OpenMode_ReadOnly)) + inline ShaderUnserializer::ShaderUnserializer(ByteStream& stream) : + m_stream(stream) { } } diff --git a/src/Nazara/Renderer/ShaderSerializer.cpp b/src/Nazara/Renderer/ShaderSerializer.cpp index 7d1b7ac2e..f97186acf 100644 --- a/src/Nazara/Renderer/ShaderSerializer.cpp +++ b/src/Nazara/Renderer/ShaderSerializer.cpp @@ -248,9 +248,6 @@ namespace Nz void ShaderSerializer::Serialize(const ShaderAst& shader) { - UInt32 magicNumber = s_magicNumber; - UInt32 version = s_currentVersion; - m_stream << s_magicNumber << s_currentVersion; auto SerializeInputOutput = [&](auto& inout) @@ -558,15 +555,17 @@ namespace Nz ByteArray SerializeShader(const ShaderAst& shader) { ByteArray byteArray; - ShaderSerializer serializer(byteArray); + ByteStream stream(&byteArray, OpenModeFlags(OpenMode_WriteOnly)); + + ShaderSerializer serializer(stream); serializer.Serialize(shader); return byteArray; } - ShaderAst UnserializeShader(const ByteArray& data) + ShaderAst UnserializeShader(ByteStream& stream) { - ShaderUnserializer unserializer(data); + ShaderUnserializer unserializer(stream); return unserializer.Unserialize(); } } From 74acf440fc76d744fb4fd9b3c4efb2576db45e19 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 18 Jun 2020 20:04:25 +0200 Subject: [PATCH 251/316] Minor fixes --- include/Nazara/OpenGLRenderer/Wrapper/Shader.inl | 4 ++-- src/Nazara/OpenGLRenderer/OpenGLRenderImage.cpp | 2 +- src/ShaderNode/Widgets/InputEditor.cpp | 1 + src/ShaderNode/Widgets/OutputEditor.cpp | 9 ++++----- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Shader.inl b/include/Nazara/OpenGLRenderer/Wrapper/Shader.inl index fe062149f..f73421706 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Shader.inl +++ b/include/Nazara/OpenGLRenderer/Wrapper/Shader.inl @@ -68,12 +68,12 @@ namespace Nz::GL context.glSpecializeShaderARB(m_objectId, pEntryPoint, numSpecializationConstants, pConstantIndex, pConstantValue); } - inline GLuint Shader::CreateHelper(OpenGLDevice& device, const Context& context, GLenum shaderStage) + inline GLuint Shader::CreateHelper(OpenGLDevice& /*device*/, const Context& context, GLenum shaderStage) { return context.glCreateShader(shaderStage); } - inline void Shader::DestroyHelper(OpenGLDevice& device, const Context& context, GLuint objectId) + inline void Shader::DestroyHelper(OpenGLDevice& /*device*/, const Context& context, GLuint objectId) { context.glDeleteShader(objectId); } diff --git a/src/Nazara/OpenGLRenderer/OpenGLRenderImage.cpp b/src/Nazara/OpenGLRenderer/OpenGLRenderImage.cpp index 34946874b..39c2be6dd 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLRenderImage.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLRenderImage.cpp @@ -17,7 +17,7 @@ namespace Nz { } - void OpenGLRenderImage::Execute(const std::function& callback, QueueTypeFlags queueTypeFlags) + void OpenGLRenderImage::Execute(const std::function& callback, QueueTypeFlags /*queueTypeFlags*/) { OpenGLCommandBuffer commandBuffer; OpenGLCommandBufferBuilder builder(commandBuffer); diff --git a/src/ShaderNode/Widgets/InputEditor.cpp b/src/ShaderNode/Widgets/InputEditor.cpp index f281c327a..7898c3c27 100644 --- a/src/ShaderNode/Widgets/InputEditor.cpp +++ b/src/ShaderNode/Widgets/InputEditor.cpp @@ -50,6 +50,7 @@ void InputEditor::OnEditInput(int inputIndex) const auto& input = m_shaderGraph.GetInput(inputIndex); InputInfo info; + info.locationIndex = input.locationIndex; info.name = input.name; info.type = input.type; info.role = input.role; diff --git a/src/ShaderNode/Widgets/OutputEditor.cpp b/src/ShaderNode/Widgets/OutputEditor.cpp index 868168c8a..40b8eea49 100644 --- a/src/ShaderNode/Widgets/OutputEditor.cpp +++ b/src/ShaderNode/Widgets/OutputEditor.cpp @@ -47,11 +47,12 @@ void OutputEditor::OnAddOutput() void OutputEditor::OnEditOutput(int inputIndex) { - const auto& input = m_shaderGraph.GetOutput(inputIndex); + const auto& output = m_shaderGraph.GetOutput(inputIndex); OutputInfo info; - info.name = input.name; - info.type = input.type; + info.locationIndex = output.locationIndex; + info.name = output.name; + info.type = output.type; OutputEditDialog* dialog = new OutputEditDialog(std::move(info), this); dialog->setAttribute(Qt::WA_DeleteOnClose, true); @@ -67,9 +68,7 @@ void OutputEditor::OnEditOutput(int inputIndex) void OutputEditor::OnOutputSelectionUpdate(int inputIndex) { if (inputIndex >= 0) - { m_currentOutputIndex = inputIndex; - } else m_currentOutputIndex.reset(); } From 58e59be267f706d6957e56f71175f770a972c551 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 18 Jun 2020 20:04:39 +0200 Subject: [PATCH 252/316] ShaderNode: Add compile to binary action --- src/ShaderNode/Widgets/MainWindow.cpp | 142 +++++++++++++++----------- src/ShaderNode/Widgets/MainWindow.hpp | 9 +- 2 files changed, 92 insertions(+), 59 deletions(-) diff --git a/src/ShaderNode/Widgets/MainWindow.cpp b/src/ShaderNode/Widgets/MainWindow.cpp index 7f39eafc3..e76946738 100644 --- a/src/ShaderNode/Widgets/MainWindow.cpp +++ b/src/ShaderNode/Widgets/MainWindow.cpp @@ -90,72 +90,30 @@ void MainWindow::BuildMenu() QObject::connect(loadShader, &QAction::triggered, this, &MainWindow::OnLoad); QAction* saveShader = shader->addAction(tr("Save...")); QObject::connect(saveShader, &QAction::triggered, this, &MainWindow::OnSave); + QAction* compileShader = shader->addAction(tr("Compile...")); + QObject::connect(compileShader, &QAction::triggered, this, &MainWindow::OnCompile); } - QMenu* compileMenu = menu->addMenu(tr("&Compilation")); - QAction* compileToGlsl = compileMenu->addAction(tr("GLSL")); - connect(compileToGlsl, &QAction::triggered, [&](bool) { OnCompileToGLSL(); }); + QMenu* generateMenu = menu->addMenu(tr("&Generate")); + QAction* generateGlsl = generateMenu->addAction(tr("GLSL")); + connect(generateGlsl, &QAction::triggered, [&](bool) { OnGenerateGLSL(); }); } -void MainWindow::OnCompileToGLSL() +void MainWindow::OnCompile() { try { - Nz::ShaderNodes::StatementPtr shaderAst = m_shaderGraph.ToAst(); + auto shader = ToShader(); - //TODO: Put in another function - auto GetExpressionFromInOut = [&] (InOutType type) - { - switch (type) - { - case InOutType::Bool: return Nz::ShaderNodes::ExpressionType::Boolean; - case InOutType::Float1: return Nz::ShaderNodes::ExpressionType::Float1; - case InOutType::Float2: return Nz::ShaderNodes::ExpressionType::Float2; - case InOutType::Float3: return Nz::ShaderNodes::ExpressionType::Float3; - case InOutType::Float4: return Nz::ShaderNodes::ExpressionType::Float4; - } + QString fileName = QFileDialog::getSaveFileName(nullptr, tr("Save shader"), QString(), tr("Shader Files (*.shader)")); + if (fileName.isEmpty()) + return; - assert(false); - throw std::runtime_error("Unhandled input type"); - }; + if (!fileName.endsWith("shader", Qt::CaseInsensitive)) + fileName += ".shader"; - auto GetExpressionFromTexture = [&](TextureType type) - { - switch (type) - { - case TextureType::Sampler2D: return Nz::ShaderNodes::ExpressionType::Sampler2D; - } - - assert(false); - throw std::runtime_error("Unhandled texture type"); - }; - - Nz::ShaderAst shader; - for (const auto& input : m_shaderGraph.GetInputs()) - shader.AddInput(input.name, GetExpressionFromInOut(input.type), input.locationIndex); - - for (const auto& output : m_shaderGraph.GetOutputs()) - shader.AddOutput(output.name, GetExpressionFromInOut(output.type), output.locationIndex); - - for (const auto& uniform : m_shaderGraph.GetTextures()) - shader.AddUniform(uniform.name, GetExpressionFromTexture(uniform.type), uniform.bindingIndex); - - shader.AddFunction("main", shaderAst); - - Nz::File file("shader.shader", Nz::OpenMode_WriteOnly); + Nz::File file(fileName.toStdString(), Nz::OpenMode_WriteOnly); file.Write(Nz::SerializeShader(shader)); - - Nz::GlslWriter writer; - Nz::String glsl = writer.Generate(shader); - - std::cout << glsl << std::endl; - - QTextEdit* output = new QTextEdit; - output->setReadOnly(true); - output->setText(QString::fromUtf8(glsl.GetConstBuffer(), int(glsl.GetSize()))); - output->setAttribute(Qt::WA_DeleteOnClose, true); - output->setWindowTitle("GLSL Output"); - output->show(); } catch (const std::exception& e) { @@ -163,9 +121,31 @@ void MainWindow::OnCompileToGLSL() } } +void MainWindow::OnGenerateGLSL() +{ + try + { + Nz::GlslWriter writer; + std::string glsl = writer.Generate(ToShader()); + + std::cout << glsl << std::endl; + + QTextEdit* output = new QTextEdit; + output->setReadOnly(true); + output->setText(QString::fromStdString(glsl)); + output->setAttribute(Qt::WA_DeleteOnClose, true); + output->setWindowTitle("GLSL Output"); + output->show(); + } + catch (const std::exception& e) + { + QMessageBox::critical(this, tr("Generation failed"), QString("Generation failed: ") + e.what()); + } +} + void MainWindow::OnLoad() { - QString fileName = QFileDialog::getOpenFileName(this, tr("Open shader flow"), QDir::homePath(), tr("Shader Flow Files (*.shaderflow)")); + QString fileName = QFileDialog::getOpenFileName(this, tr("Open shader flow"), QString(), tr("Shader Flow Files (*.shaderflow)")); if (fileName.isEmpty()) return; @@ -196,14 +176,60 @@ void MainWindow::OnLoad() void MainWindow::OnSave() { - QString fileName = QFileDialog::getSaveFileName(nullptr, tr("Open shader flow"), QDir::homePath(), tr("Shader Flow Files (*.shaderflow)")); + QString fileName = QFileDialog::getSaveFileName(nullptr, tr("Open shader flow"), QString(), tr("Shader Flow Files (*.shaderflow)")); if (fileName.isEmpty()) return; - if (!fileName.endsWith("flow", Qt::CaseInsensitive)) + if (!fileName.endsWith("shaderflow", Qt::CaseInsensitive)) fileName += ".shaderflow"; QFile file(fileName); if (file.open(QIODevice::WriteOnly)) file.write(QJsonDocument(m_shaderGraph.Save()).toJson()); } + +Nz::ShaderAst MainWindow::ToShader() +{ + Nz::ShaderNodes::StatementPtr shaderAst = m_shaderGraph.ToAst(); + + //TODO: Put in another function + auto GetExpressionFromInOut = [&](InOutType type) + { + switch (type) + { + case InOutType::Bool: return Nz::ShaderNodes::ExpressionType::Boolean; + case InOutType::Float1: return Nz::ShaderNodes::ExpressionType::Float1; + case InOutType::Float2: return Nz::ShaderNodes::ExpressionType::Float2; + case InOutType::Float3: return Nz::ShaderNodes::ExpressionType::Float3; + case InOutType::Float4: return Nz::ShaderNodes::ExpressionType::Float4; + } + + assert(false); + throw std::runtime_error("Unhandled input type"); + }; + + auto GetExpressionFromTexture = [&](TextureType type) + { + switch (type) + { + case TextureType::Sampler2D: return Nz::ShaderNodes::ExpressionType::Sampler2D; + } + + assert(false); + throw std::runtime_error("Unhandled texture type"); + }; + + Nz::ShaderAst shader; + for (const auto& input : m_shaderGraph.GetInputs()) + shader.AddInput(input.name, GetExpressionFromInOut(input.type), input.locationIndex); + + for (const auto& output : m_shaderGraph.GetOutputs()) + shader.AddOutput(output.name, GetExpressionFromInOut(output.type), output.locationIndex); + + for (const auto& uniform : m_shaderGraph.GetTextures()) + shader.AddUniform(uniform.name, GetExpressionFromTexture(uniform.type), uniform.bindingIndex); + + shader.AddFunction("main", shaderAst); + + return shader; +} diff --git a/src/ShaderNode/Widgets/MainWindow.hpp b/src/ShaderNode/Widgets/MainWindow.hpp index ff8b307c1..25c742625 100644 --- a/src/ShaderNode/Widgets/MainWindow.hpp +++ b/src/ShaderNode/Widgets/MainWindow.hpp @@ -9,6 +9,11 @@ class NodeEditor; +namespace Nz +{ + class ShaderAst; +} + class MainWindow : public QMainWindow { public: @@ -17,9 +22,11 @@ class MainWindow : public QMainWindow private: void BuildMenu(); - void OnCompileToGLSL(); + void OnCompile(); + void OnGenerateGLSL(); void OnLoad(); void OnSave(); + Nz::ShaderAst ToShader(); NazaraSlot(ShaderGraph, OnSelectedNodeUpdate, m_onSelectedNodeUpdate); From 4f671873c1019f137aeed6f7d41b2dd29f0ef6a4 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 18 Jun 2020 20:05:22 +0200 Subject: [PATCH 253/316] Renderer: Add NazaraBinary shader "language" and handle it in OpenGLRenderer --- examples/VulkanTest/main.cpp | 4 +-- examples/bin/shader.shader | Bin 0 -> 510 bytes include/Nazara/Renderer/Enums.hpp | 1 + .../OpenGLRenderer/OpenGLShaderStage.cpp | 32 ++++++++++++++++++ 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 examples/bin/shader.shader diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index bfda1e2b2..e42aa41ac 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -3,7 +3,7 @@ #include #include -#define SPIRV 1 +#define SPIRV 0 int main() { @@ -44,7 +44,7 @@ int main() return __LINE__; } #else - auto fragmentShader = device->InstantiateShaderStage(Nz::ShaderStageType::Fragment, Nz::ShaderLanguage::GLSL, "resources/shaders/triangle.frag"); + auto fragmentShader = device->InstantiateShaderStage(Nz::ShaderStageType::Fragment, Nz::ShaderLanguage::NazaraBinary, "shader.shader"); if (!fragmentShader) { std::cout << "Failed to instantiate fragment shader" << std::endl; diff --git a/examples/bin/shader.shader b/examples/bin/shader.shader new file mode 100644 index 0000000000000000000000000000000000000000..7828e1b47f93c3a2edd5b8979ee976e5aac39742 GIT binary patch literal 510 zcmah_%L>9U5KJGo)%J6|_n;I{J@~o@ZEK)yptj)AKl7)&itdCgXcb%-Cd^J|lg&4) zwGhG~xP(Zxx$YWS)7gWF@>RRr6T1)?i5~i_lhs1kx`T<`;BZ@9`k^c681MzK-$>P> zPe3IEpAZnt_*zw`eyI@X*&bNj=8trp8P$ literal 0 HcmV?d00001 diff --git a/include/Nazara/Renderer/Enums.hpp b/include/Nazara/Renderer/Enums.hpp index a9b33ba5f..05daee7a5 100644 --- a/include/Nazara/Renderer/Enums.hpp +++ b/include/Nazara/Renderer/Enums.hpp @@ -49,6 +49,7 @@ namespace Nz GLSL, HLSL, MSL, + NazaraBinary, SpirV }; diff --git a/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp b/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp index 3364e4f11..561a1d196 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp @@ -4,7 +4,11 @@ #include #include +#include #include +#include +#include +#include #include #include @@ -22,6 +26,34 @@ namespace Nz m_shader.Compile(); break; + case ShaderLanguage::NazaraBinary: + { + ByteStream byteStream(source, sourceSize); + auto shader = Nz::UnserializeShader(byteStream); + + const auto& context = device.GetReferenceContext(); + const auto& contextParams = context.GetParams(); + + GlslWriter::Environment env; + env.glES = false; + //env.glES = (contextParams.type == GL::ContextType::OpenGL_ES); + env.glMajorVersion = contextParams.glMajorVersion; + env.glMinorVersion = contextParams.glMinorVersion; + env.extCallback = [&](const std::string_view& ext) + { + return context.IsExtensionSupported(std::string(ext)); + }; + + GlslWriter writer; + writer.SetEnv(env); + + std::string code = writer.Generate(shader); + + m_shader.SetSource(code.data(), code.size()); + m_shader.Compile(); + break; + } + case ShaderLanguage::SpirV: { if (!device.GetReferenceContext().IsExtensionSupported(GL::Extension::SpirV)) From 33d94c05f3db230e5b0766f8903ba03316c60600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Fri, 3 Jul 2020 22:53:00 +0200 Subject: [PATCH 254/316] ShaderNodes: Use PreviewValues instead of QImage --- src/ShaderNode/DataModels/Cast.inl | 39 ++++----- src/ShaderNode/DataModels/FloatValue.cpp | 2 +- src/ShaderNode/DataModels/InputValue.cpp | 4 +- src/ShaderNode/DataModels/OutputValue.cpp | 2 +- src/ShaderNode/DataModels/SampleTexture.cpp | 52 ++++------- src/ShaderNode/DataModels/TextureValue.cpp | 13 ++- src/ShaderNode/DataModels/VecBinOp.cpp | 46 ++-------- src/ShaderNode/DataModels/VecBinOp.hpp | 10 +-- src/ShaderNode/DataModels/VecBinOp.inl | 32 +++---- src/ShaderNode/DataModels/VecDot.cpp | 48 +++++------ src/ShaderNode/DataModels/VecFloatMul.cpp | 45 +++++----- src/ShaderNode/DataModels/VecValue.inl | 10 ++- src/ShaderNode/DataTypes/FloatData.hpp | 4 +- src/ShaderNode/DataTypes/FloatData.inl | 4 +- src/ShaderNode/DataTypes/TextureData.hpp | 4 +- src/ShaderNode/DataTypes/TextureData.inl | 4 +- src/ShaderNode/DataTypes/VecData.hpp | 4 +- src/ShaderNode/DataTypes/VecData.inl | 4 +- src/ShaderNode/Previews/PreviewModel.hpp | 4 +- src/ShaderNode/Previews/PreviewValues.cpp | 95 +++++++++++++++++++++ src/ShaderNode/Previews/PreviewValues.hpp | 50 +++++++++++ src/ShaderNode/Previews/PreviewValues.inl | 21 +++++ src/ShaderNode/Previews/QuadPreview.cpp | 17 ++-- src/ShaderNode/Previews/QuadPreview.hpp | 4 +- 24 files changed, 314 insertions(+), 204 deletions(-) create mode 100644 src/ShaderNode/Previews/PreviewValues.cpp create mode 100644 src/ShaderNode/Previews/PreviewValues.hpp create mode 100644 src/ShaderNode/Previews/PreviewValues.inl diff --git a/src/ShaderNode/DataModels/Cast.inl b/src/ShaderNode/DataModels/Cast.inl index ccb15385c..fb088b3a0 100644 --- a/src/ShaderNode/DataModels/Cast.inl +++ b/src/ShaderNode/DataModels/Cast.inl @@ -176,7 +176,7 @@ bool CastVec::ComputePreview(QPixmap& pixmap) if (!m_input) return false; - pixmap = QPixmap::fromImage(m_output->preview); + pixmap = QPixmap::fromImage(m_output->preview.GenerateImage()); return true; } @@ -185,47 +185,38 @@ void CastVec::UpdateOutput() { if (!m_input) { - m_output->preview = QImage(1, 1, QImage::Format_RGBA8888); - m_output->preview.fill(QColor::fromRgb(0, 0, 0, 0)); + m_output->preview = PreviewValues(1, 1); + m_output->preview(0, 0) = Nz::Vector4f::Zero(); return; } - const QImage& input = m_input->preview; + const PreviewValues& input = m_input->preview; - int inputWidth = input.width(); - int inputHeight = input.height(); + std::size_t inputWidth = input.GetWidth(); + std::size_t inputHeight = input.GetHeight(); - QImage& output = m_output->preview; - output = QImage(inputWidth, inputHeight, QImage::Format_RGBA8888); + PreviewValues& output = m_output->preview; + output = PreviewValues(inputWidth, inputHeight); std::size_t fromComponentCount = m_input->componentCount; std::size_t commonComponents = std::min(fromComponentCount, ToComponentCount); std::size_t overflowComponentCount = (ToComponentCount > fromComponentCount) ? ToComponentCount - fromComponentCount : 0; std::size_t voidComponents = 4 - overflowComponentCount - commonComponents; - std::array constants; - if (ToComponentCount > fromComponentCount) + for (std::size_t y = 0; y < inputHeight; ++y) { - for (std::size_t i = 0; i < overflowComponentCount; ++i) - constants[i] = static_cast(std::clamp(int(m_overflowComponents[i] * 255), 0, 255)); - } - - std::uint8_t* outputPtr = output.bits(); - const std::uint8_t* inputPtr = input.constBits(); - for (int y = 0; y < inputHeight; ++y) - { - for (int x = 0; x < inputWidth; ++x) + for (std::size_t x = 0; x < inputWidth; ++x) { - for (std::size_t i = 0; i < commonComponents; ++i) - *outputPtr++ = inputPtr[i]; + Nz::Vector4f color = input(x, y); + float* colorPtr = &color.x; for (std::size_t i = 0; i < overflowComponentCount; ++i) - *outputPtr++ = constants[i]; + *colorPtr++ = m_overflowComponents[i]; for (std::size_t i = 0; i < voidComponents; ++i) - *outputPtr++ = (i == voidComponents - 1) ? 255 : 0; + *colorPtr++ = (i == voidComponents - 1) ? 1.f : 0.f; - inputPtr += 4; + output(x, y) = color; } } diff --git a/src/ShaderNode/DataModels/FloatValue.cpp b/src/ShaderNode/DataModels/FloatValue.cpp index f9c25074b..c30ea8874 100644 --- a/src/ShaderNode/DataModels/FloatValue.cpp +++ b/src/ShaderNode/DataModels/FloatValue.cpp @@ -46,7 +46,7 @@ std::shared_ptr FloatValue::outData(QtNodes::PortIndex port) assert(port == 0); auto out = std::make_shared(); - out->preview.fill(ToColor()); + out->preview(0, 0) = Nz::Vector4f(m_value, m_value, m_value, 1.f); return out; } diff --git a/src/ShaderNode/DataModels/InputValue.cpp b/src/ShaderNode/DataModels/InputValue.cpp index 5a2b088dd..e0b117e83 100644 --- a/src/ShaderNode/DataModels/InputValue.cpp +++ b/src/ShaderNode/DataModels/InputValue.cpp @@ -48,7 +48,7 @@ bool InputValue::ComputePreview(QPixmap& pixmap) const auto& inputEntry = graph.GetInput(*m_currentInputIndex); const auto& preview = graph.GetPreviewModel(); - pixmap = QPixmap::fromImage(preview.GetImage(inputEntry.role, inputEntry.roleIndex)); + pixmap = QPixmap::fromImage(preview.GetPreview(inputEntry.role, inputEntry.roleIndex).GenerateImage()); return true; } @@ -171,7 +171,7 @@ std::shared_ptr InputValue::outData(QtNodes::PortIndex port) const auto& preview = graph.GetPreviewModel(); auto vecData = std::make_shared(GetComponentCount(inputEntry.type)); - vecData->preview = preview.GetImage(inputEntry.role, inputEntry.roleIndex); + vecData->preview = preview.GetPreview(inputEntry.role, inputEntry.roleIndex); return vecData; } diff --git a/src/ShaderNode/DataModels/OutputValue.cpp b/src/ShaderNode/DataModels/OutputValue.cpp index 7cf6fedec..a6b644be3 100644 --- a/src/ShaderNode/DataModels/OutputValue.cpp +++ b/src/ShaderNode/DataModels/OutputValue.cpp @@ -170,7 +170,7 @@ bool OutputValue::ComputePreview(QPixmap& pixmap) if (!m_input) return false; - pixmap = QPixmap::fromImage(m_input->preview); + pixmap = QPixmap::fromImage(m_input->preview.GenerateImage()); return true; } diff --git a/src/ShaderNode/DataModels/SampleTexture.cpp b/src/ShaderNode/DataModels/SampleTexture.cpp index 2c9e2dcac..131a8b161 100644 --- a/src/ShaderNode/DataModels/SampleTexture.cpp +++ b/src/ShaderNode/DataModels/SampleTexture.cpp @@ -23,57 +23,37 @@ unsigned int SampleTexture::nPorts(QtNodes::PortType portType) const void SampleTexture::UpdateOutput() { - QImage& output = m_output->preview; + PreviewValues& output = m_output->preview; if (!m_texture || !m_uv) { - output = QImage(1, 1, QImage::Format_RGBA8888); - output.fill(QColor::fromRgb(0, 0, 0, 0)); + output = PreviewValues(1, 1); + output.Fill(Nz::Vector4f::Zero()); return; } - const QImage& texturePreview = m_texture->preview; + const PreviewValues& texturePreview = m_texture->preview; - int textureWidth = texturePreview.width(); - int textureHeight = texturePreview.height(); + std::size_t textureWidth = texturePreview.GetWidth(); + std::size_t textureHeight = texturePreview.GetHeight(); - const QImage& uv = m_uv->preview; + const PreviewValues& uv = m_uv->preview; - int uvWidth = uv.width(); - int uvHeight = uv.height(); + std::size_t uvWidth = uv.GetWidth(); + std::size_t uvHeight = uv.GetHeight(); - output = QImage(uvWidth, uvHeight, QImage::Format_RGBA8888); + output = PreviewValues(uvWidth, uvHeight); - std::uint8_t* outputPtr = output.bits(); - const std::uint8_t* uvPtr = uv.constBits(); - const std::uint8_t* texturePtr = texturePreview.constBits(); - for (int y = 0; y < uvHeight; ++y) + for (std::size_t y = 0; y < uvHeight; ++y) { - for (int x = 0; x < uvWidth; ++x) + for (std::size_t x = 0; x < uvWidth; ++x) { - float u = float(uvPtr[0]) / 255; - float v = float(uvPtr[1]) / 255; + Nz::Vector4f uvValue = uv(x, y); if (textureWidth > 0 && textureHeight > 0) - { - int texX = std::clamp(int(u * textureWidth), 0, textureWidth - 1); - int texY = std::clamp(int(v * textureHeight), 0, textureHeight - 1); - int texPixel = (texY * textureWidth + texX) * 4; - - *outputPtr++ = texturePtr[texPixel + 0]; - *outputPtr++ = texturePtr[texPixel + 1]; - *outputPtr++ = texturePtr[texPixel + 2]; - *outputPtr++ = texturePtr[texPixel + 3]; - } + output(x, y) = texturePreview.Sample(uvValue.x, uvValue.y); else - { - *outputPtr++ = 0; - *outputPtr++ = 0; - *outputPtr++ = 0; - *outputPtr++ = 0xFF; - } - - uvPtr += 4; + output(x, y) = Nz::Vector4f(0.f, 0.f, 0.f, 1.f); } } @@ -87,7 +67,7 @@ bool SampleTexture::ComputePreview(QPixmap& pixmap) if (!m_texture || !m_uv) return false; - pixmap = QPixmap::fromImage(m_output->preview); + pixmap = QPixmap::fromImage(m_output->preview.GenerateImage()); return true; } diff --git a/src/ShaderNode/DataModels/TextureValue.cpp b/src/ShaderNode/DataModels/TextureValue.cpp index 2e25eaa03..d0237e8bd 100644 --- a/src/ShaderNode/DataModels/TextureValue.cpp +++ b/src/ShaderNode/DataModels/TextureValue.cpp @@ -158,7 +158,18 @@ std::shared_ptr TextureValue::outData(QtNodes::PortIndex port assert(textureData); - textureData->preview = textureEntry.preview; + const QImage& previewImage = textureEntry.preview; + + textureData->preview = PreviewValues(previewImage.width(), previewImage.height()); + for (std::size_t y = 0; y < textureData->preview.GetHeight(); ++y) + { + for (std::size_t x = 0; x < textureData->preview.GetWidth(); ++x) + { + QColor pixelColor = previewImage.pixelColor(int(x), int(y)); + + textureData->preview(x, y) = Nz::Vector4f(pixelColor.redF(), pixelColor.greenF(), pixelColor.blueF(), pixelColor.alphaF()); + } + } return textureData; } diff --git a/src/ShaderNode/DataModels/VecBinOp.cpp b/src/ShaderNode/DataModels/VecBinOp.cpp index 3ea2838f3..f99591420 100644 --- a/src/ShaderNode/DataModels/VecBinOp.cpp +++ b/src/ShaderNode/DataModels/VecBinOp.cpp @@ -12,15 +12,10 @@ QString VecAdd::name() const return name; } -void VecAdd::ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) +void VecAdd::ApplyOp(const Nz::Vector4f* left, const Nz::Vector4f* right, Nz::Vector4f* output, std::size_t pixelCount) { for (std::size_t i = 0; i < pixelCount; ++i) - { - unsigned int lValue = left[i]; - unsigned int rValue = right[i]; - - output[i] = static_cast(std::min(lValue + rValue, 255U)); - } + output[i] = left[i] + right[i]; } QString VecMul::caption() const @@ -35,15 +30,10 @@ QString VecMul::name() const return name; } -void VecMul::ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) +void VecMul::ApplyOp(const Nz::Vector4f* left, const Nz::Vector4f* right, Nz::Vector4f* output, std::size_t pixelCount) { for (std::size_t i = 0; i < pixelCount; ++i) - { - unsigned int lValue = left[i]; - unsigned int rValue = right[i]; - - output[i] = static_cast(lValue * rValue / 255); - } + output[i] = left[i] * right[i]; } QString VecSub::caption() const @@ -59,17 +49,10 @@ QString VecSub::name() const return name; } -void VecSub::ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) +void VecSub::ApplyOp(const Nz::Vector4f* left, const Nz::Vector4f* right, Nz::Vector4f* output, std::size_t pixelCount) { for (std::size_t i = 0; i < pixelCount; ++i) - { - unsigned int lValue = left[i]; - unsigned int rValue = right[i]; - - unsigned int sub = (lValue >= rValue) ? lValue - rValue : 0u; - - output[i] = static_cast(sub); - } + output[i] = left[i] - right[i]; } QString VecDiv::caption() const @@ -85,21 +68,8 @@ QString VecDiv::name() const return name; } -void VecDiv::ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) +void VecDiv::ApplyOp(const Nz::Vector4f* left, const Nz::Vector4f* right, Nz::Vector4f* output, std::size_t pixelCount) { for (std::size_t i = 0; i < pixelCount; ++i) - { - unsigned int lValue = left[i]; - unsigned int rValue = right[i]; - - unsigned res; - if (rValue != 0) - res = lValue / rValue; - else if (lValue != 0) - res = 0xFF; //< positive / 0 = +inf, which we clamp to 0xFF - else - res = 0; //< 0 / 0 = NaN, which we set to zero - - output[i] = static_cast(res); - } + output[i] = left[i] / right[i]; } diff --git a/src/ShaderNode/DataModels/VecBinOp.hpp b/src/ShaderNode/DataModels/VecBinOp.hpp index d00049c04..3c0a5aebd 100644 --- a/src/ShaderNode/DataModels/VecBinOp.hpp +++ b/src/ShaderNode/DataModels/VecBinOp.hpp @@ -27,7 +27,7 @@ class VecBinOp : public ShaderNode QString validationMessage() const override; private: - virtual void ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) = 0; + virtual void ApplyOp(const Nz::Vector4f* left, const Nz::Vector4f* right, Nz::Vector4f* output, std::size_t pixelCount) = 0; bool ComputePreview(QPixmap& pixmap) override; void UpdateOutput(); @@ -45,7 +45,7 @@ class VecAdd : public VecBinOp QString caption() const override; QString name() const override; - void ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) override; + void ApplyOp(const Nz::Vector4f* left, const Nz::Vector4f* right, Nz::Vector4f* output, std::size_t pixelCount) override; }; class VecMul : public VecBinOp @@ -56,7 +56,7 @@ class VecMul : public VecBinOp QString caption() const override; QString name() const override; - void ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) override; + void ApplyOp(const Nz::Vector4f* left, const Nz::Vector4f* right, Nz::Vector4f* output, std::size_t pixelCount) override; }; class VecSub : public VecBinOp @@ -67,7 +67,7 @@ class VecSub : public VecBinOp QString caption() const override; QString name() const override; - void ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) override; + void ApplyOp(const Nz::Vector4f* left, const Nz::Vector4f* right, Nz::Vector4f* output, std::size_t pixelCount) override; }; class VecDiv : public VecBinOp @@ -78,7 +78,7 @@ class VecDiv : public VecBinOp QString caption() const override; QString name() const override; - void ApplyOp(const std::uint8_t* left, const std::uint8_t* right, std::uint8_t* output, std::size_t pixelCount) override; + void ApplyOp(const Nz::Vector4f* left, const Nz::Vector4f* right, Nz::Vector4f* output, std::size_t pixelCount) override; }; #include diff --git a/src/ShaderNode/DataModels/VecBinOp.inl b/src/ShaderNode/DataModels/VecBinOp.inl index 255946543..d159545be 100644 --- a/src/ShaderNode/DataModels/VecBinOp.inl +++ b/src/ShaderNode/DataModels/VecBinOp.inl @@ -95,7 +95,7 @@ bool VecBinOp::ComputePreview(QPixmap& pixmap) if (!m_lhs || !m_rhs) return false; - pixmap = QPixmap::fromImage(m_output->preview); + pixmap = QPixmap::fromImage(m_output->preview.GenerateImage()); return true; } @@ -105,29 +105,29 @@ void VecBinOp::UpdateOutput() if (validationState() != QtNodes::NodeValidationState::Valid) { m_output = std::make_shared(4); - m_output->preview = QImage(1, 1, QImage::Format_RGBA8888); - m_output->preview.fill(QColor::fromRgb(0, 0, 0, 0)); + m_output->preview = PreviewValues(1, 1); + m_output->preview.Fill(Nz::Vector4f::Zero()); return; } m_output = std::make_shared(m_lhs->componentCount); - const QImage& leftPreview = m_lhs->preview; - const QImage& rightPreview = m_rhs->preview; - int maxWidth = std::max(leftPreview.width(), rightPreview.width()); - int maxHeight = std::max(leftPreview.height(), rightPreview.height()); + const PreviewValues& leftPreview = m_lhs->preview; + const PreviewValues& rightPreview = m_rhs->preview; + std::size_t maxWidth = std::max(leftPreview.GetWidth(), rightPreview.GetWidth()); + std::size_t maxHeight = std::max(leftPreview.GetHeight(), rightPreview.GetHeight()); - // Exploit COW - QImage leftResized = leftPreview; - if (leftResized.width() != maxWidth || leftResized.height() != maxHeight) - leftResized = leftResized.scaled(maxWidth, maxHeight); + // FIXME: Prevent useless copy + PreviewValues leftResized = leftPreview; + if (leftResized.GetWidth() != maxWidth || leftResized.GetHeight() != maxHeight) + leftResized = leftResized.Resized(maxWidth, maxHeight); - QImage rightResized = rightPreview; - if (rightResized.width() != maxWidth || rightResized.height() != maxHeight) - rightResized = rightResized.scaled(maxWidth, maxHeight); + PreviewValues rightResized = rightPreview; + if (rightResized.GetWidth() != maxWidth || rightResized.GetHeight() != maxHeight) + rightResized = rightResized.Resized(maxWidth, maxHeight); - m_output->preview = QImage(maxWidth, maxHeight, QImage::Format_RGBA8888); - ApplyOp(leftResized.constBits(), rightResized.constBits(), m_output->preview.bits(), maxWidth * maxHeight * 4); + m_output->preview = PreviewValues(maxWidth, maxHeight); + ApplyOp(leftResized.GetData(), rightResized.GetData(), m_output->preview.GetData(), maxWidth * maxHeight); Q_EMIT dataUpdated(0); diff --git a/src/ShaderNode/DataModels/VecDot.cpp b/src/ShaderNode/DataModels/VecDot.cpp index 48aac108c..818a68a2a 100644 --- a/src/ShaderNode/DataModels/VecDot.cpp +++ b/src/ShaderNode/DataModels/VecDot.cpp @@ -112,7 +112,7 @@ bool VecDot::ComputePreview(QPixmap& pixmap) if (validationState() != QtNodes::NodeValidationState::Valid) return false; - pixmap = QPixmap::fromImage(m_output->preview); + pixmap = QPixmap::fromImage(m_output->preview.GenerateImage()); return true; } @@ -120,45 +120,41 @@ void VecDot::UpdateOutput() { if (validationState() != QtNodes::NodeValidationState::Valid) { - m_output->preview = QImage(1, 1, QImage::Format_RGBA8888); - m_output->preview.fill(QColor::fromRgb(0, 0, 0, 0)); + m_output->preview = PreviewValues(1, 1); + m_output->preview.Fill(Nz::Vector4f::Zero()); return; } - const QImage& leftPreview = m_lhs->preview; - const QImage& rightPreview = m_rhs->preview; - int maxWidth = std::max(leftPreview.width(), rightPreview.width()); - int maxHeight = std::max(leftPreview.height(), rightPreview.height()); + const PreviewValues& leftPreview = m_lhs->preview; + const PreviewValues& rightPreview = m_rhs->preview; + std::size_t maxWidth = std::max(leftPreview.GetWidth(), rightPreview.GetWidth()); + std::size_t maxHeight = std::max(leftPreview.GetHeight(), rightPreview.GetHeight()); - // Exploit COW - QImage leftResized = leftPreview; - if (leftResized.width() != maxWidth || leftResized.height() != maxHeight) - leftResized = leftResized.scaled(maxWidth, maxHeight); + // FIXME: Prevent useless copy + PreviewValues leftResized = leftPreview; + if (leftResized.GetWidth() != maxWidth || leftResized.GetHeight() != maxHeight) + leftResized = leftResized.Resized(maxWidth, maxHeight); - QImage rightResized = rightPreview; - if (rightResized.width() != maxWidth || rightResized.height() != maxHeight) - rightResized = rightResized.scaled(maxWidth, maxHeight); + PreviewValues rightResized = rightPreview; + if (rightResized.GetWidth() != maxWidth || rightResized.GetHeight() != maxHeight) + rightResized = rightResized.Resized(maxWidth, maxHeight); - m_output->preview = QImage(maxWidth, maxHeight, QImage::Format_RGBA8888); + m_output->preview = PreviewValues(maxWidth, maxHeight); - const uchar* left = leftResized.constBits(); - const uchar* right = rightPreview.constBits(); - uchar* output = m_output->preview.bits(); + const Nz::Vector4f* left = leftResized.GetData(); + const Nz::Vector4f* right = rightPreview.GetData(); + Nz::Vector4f* output = m_output->preview.GetData(); std::size_t pixelCount = maxWidth * maxHeight; for (std::size_t i = 0; i < pixelCount; ++i) { - unsigned int acc = 0; + float acc = 0.f; for (std::size_t j = 0; j < m_lhs->componentCount; ++j) - acc += left[j] * right[j] / 255; + acc += left[i][j] * right[i][j]; - unsigned int result = static_cast(std::min(acc, 255U)); for (std::size_t j = 0; j < 3; ++j) - *output++ = result; - *output++ = 255; //< leave alpha at maximum - - left += 4; - right += 4; + output[i][j] = acc; + output[i][3] = 1.f; //< leave alpha at maximum } Q_EMIT dataUpdated(0); diff --git a/src/ShaderNode/DataModels/VecFloatMul.cpp b/src/ShaderNode/DataModels/VecFloatMul.cpp index 3c10d08e2..c1ecf50d2 100644 --- a/src/ShaderNode/DataModels/VecFloatMul.cpp +++ b/src/ShaderNode/DataModels/VecFloatMul.cpp @@ -132,7 +132,7 @@ bool VecFloatMul::ComputePreview(QPixmap& pixmap) if (validationState() != QtNodes::NodeValidationState::Valid) return false; - pixmap = QPixmap::fromImage(m_output->preview); + pixmap = QPixmap::fromImage(m_output->preview.GenerateImage()); return true; } @@ -141,41 +141,36 @@ void VecFloatMul::UpdateOutput() if (validationState() != QtNodes::NodeValidationState::Valid) { m_output = std::make_shared(4); - m_output->preview = QImage(1, 1, QImage::Format_RGBA8888); - m_output->preview.fill(QColor::fromRgb(0, 0, 0, 0)); + m_output->preview = PreviewValues(1, 1); + m_output->preview.Fill(Nz::Vector4f::Zero()); return; } m_output = std::make_shared(m_rhs->componentCount); - const QImage& leftPreview = m_lhs->preview; - const QImage& rightPreview = m_rhs->preview; - int maxWidth = std::max(leftPreview.width(), rightPreview.width()); - int maxHeight = std::max(leftPreview.height(), rightPreview.height()); + const PreviewValues& leftPreview = m_lhs->preview; + const PreviewValues& rightPreview = m_rhs->preview; + std::size_t maxWidth = std::max(leftPreview.GetWidth(), rightPreview.GetWidth()); + std::size_t maxHeight = std::max(leftPreview.GetHeight(), rightPreview.GetHeight()); - // Exploit COW - QImage leftResized = leftPreview; - if (leftResized.width() != maxWidth || leftResized.height() != maxHeight) - leftResized = leftResized.scaled(maxWidth, maxHeight); + // FIXME: Prevent useless copy + PreviewValues leftResized = leftPreview; + if (leftResized.GetWidth() != maxWidth || leftResized.GetHeight() != maxHeight) + leftResized = leftResized.Resized(maxWidth, maxHeight); - QImage rightResized = rightPreview; - if (rightResized.width() != maxWidth || rightResized.height() != maxHeight) - rightResized = rightResized.scaled(maxWidth, maxHeight); + PreviewValues rightResized = rightPreview; + if (rightResized.GetWidth() != maxWidth || rightResized.GetHeight() != maxHeight) + rightResized = rightResized.Resized(maxWidth, maxHeight); - m_output->preview = QImage(maxWidth, maxHeight, QImage::Format_RGBA8888); + m_output->preview = PreviewValues(maxWidth, maxHeight); - const uchar* left = leftResized.constBits(); - const uchar* right = rightPreview.constBits(); - uchar* output = m_output->preview.bits(); + const Nz::Vector4f* left = leftResized.GetData(); + const Nz::Vector4f* right = rightPreview.GetData(); + Nz::Vector4f* output = m_output->preview.GetData(); - std::size_t pixelCount = maxWidth * maxHeight * 4; + std::size_t pixelCount = maxWidth * maxHeight; for (std::size_t i = 0; i < pixelCount; ++i) - { - unsigned int lValue = left[i]; - unsigned int rValue = right[i]; - - output[i] = static_cast(lValue * rValue / 255); - } + output[i] = left[i] * right[i]; Q_EMIT dataUpdated(0); diff --git a/src/ShaderNode/DataModels/VecValue.inl b/src/ShaderNode/DataModels/VecValue.inl index 8e158b94b..8b72d1186 100644 --- a/src/ShaderNode/DataModels/VecValue.inl +++ b/src/ShaderNode/DataModels/VecValue.inl @@ -63,8 +63,14 @@ std::shared_ptr VecValue::outData(QtNodes::Po assert(port == 0); auto out = std::make_shared(ComponentCount); - out->preview = QImage(1, 1, QImage::Format_RGBA8888); - out->preview.fill(ToColor()); + + std::array values = { 0.f, 0.f, 0.f, 1.f }; + + for (std::size_t i = 0; i < ComponentCount; ++i) + values[i] = m_value[i]; + + out->preview = PreviewValues(1, 1); + out->preview(0, 0) = Nz::Vector4f(values[0], values[1], values[2], values[3]); return out; } diff --git a/src/ShaderNode/DataTypes/FloatData.hpp b/src/ShaderNode/DataTypes/FloatData.hpp index e0f0451d2..d33d12b5d 100644 --- a/src/ShaderNode/DataTypes/FloatData.hpp +++ b/src/ShaderNode/DataTypes/FloatData.hpp @@ -3,8 +3,8 @@ #ifndef NAZARA_SHADERNODES_FLOATDATA_HPP #define NAZARA_SHADERNODES_FLOATDATA_HPP +#include #include -#include struct FloatData : public QtNodes::NodeData { @@ -20,7 +20,7 @@ struct FloatData : public QtNodes::NodeData return { "float", "Float" }; } - QImage preview; + PreviewValues preview; }; #include diff --git a/src/ShaderNode/DataTypes/FloatData.inl b/src/ShaderNode/DataTypes/FloatData.inl index 3960c5811..4f889aa90 100644 --- a/src/ShaderNode/DataTypes/FloatData.inl +++ b/src/ShaderNode/DataTypes/FloatData.inl @@ -1,7 +1,7 @@ #include inline FloatData::FloatData() : -preview(1, 1, QImage::Format_RGBA8888) +preview(1, 1) { - preview.fill(QColor::fromRgb(255, 255, 255, 0)); + preview(0, 0) = Nz::Vector4f(1.f, 1.f, 1.f, 0.f); } diff --git a/src/ShaderNode/DataTypes/TextureData.hpp b/src/ShaderNode/DataTypes/TextureData.hpp index 632fa5bde..b6f7b4433 100644 --- a/src/ShaderNode/DataTypes/TextureData.hpp +++ b/src/ShaderNode/DataTypes/TextureData.hpp @@ -3,15 +3,15 @@ #ifndef NAZARA_SHADERNODES_TEXTUREDATA_HPP #define NAZARA_SHADERNODES_TEXTUREDATA_HPP +#include #include #include -#include struct TextureData : public QtNodes::NodeData { inline TextureData(); - QImage preview; + PreviewValues preview; }; struct Texture2Data : public TextureData diff --git a/src/ShaderNode/DataTypes/TextureData.inl b/src/ShaderNode/DataTypes/TextureData.inl index e3ae7014f..b542dff60 100644 --- a/src/ShaderNode/DataTypes/TextureData.inl +++ b/src/ShaderNode/DataTypes/TextureData.inl @@ -1,7 +1,7 @@ #include inline TextureData::TextureData() : -preview(64, 64, QImage::Format_RGBA8888) +preview(64, 64) { - preview.fill(QColor::fromRgb(255, 255, 255, 0)); + preview.Fill(Nz::Vector4f(1.f, 1.f, 1.f, 0.f)); } diff --git a/src/ShaderNode/DataTypes/VecData.hpp b/src/ShaderNode/DataTypes/VecData.hpp index f333f9483..3c6a8f096 100644 --- a/src/ShaderNode/DataTypes/VecData.hpp +++ b/src/ShaderNode/DataTypes/VecData.hpp @@ -4,8 +4,8 @@ #define NAZARA_SHADERNODES_VECDATA_HPP #include +#include #include -#include struct VecData : public QtNodes::NodeData { @@ -18,7 +18,7 @@ struct VecData : public QtNodes::NodeData static inline QtNodes::NodeDataType Type(); std::size_t componentCount; - QImage preview; + PreviewValues preview; }; template diff --git a/src/ShaderNode/DataTypes/VecData.inl b/src/ShaderNode/DataTypes/VecData.inl index a84b5c344..7264ca7e9 100644 --- a/src/ShaderNode/DataTypes/VecData.inl +++ b/src/ShaderNode/DataTypes/VecData.inl @@ -2,9 +2,9 @@ inline VecData::VecData(std::size_t ComponentCount) : componentCount(ComponentCount), -preview(64, 64, QImage::Format_RGBA8888) +preview(64, 64) { - preview.fill(QColor::fromRgb(255, 255, 255, 0)); + preview.Fill(Nz::Vector4f(1.f, 1.f, 1.f, 0.f)); } inline QtNodes::NodeDataType VecData::type() const diff --git a/src/ShaderNode/Previews/PreviewModel.hpp b/src/ShaderNode/Previews/PreviewModel.hpp index 6ed8ec3ef..17b49fef2 100644 --- a/src/ShaderNode/Previews/PreviewModel.hpp +++ b/src/ShaderNode/Previews/PreviewModel.hpp @@ -5,7 +5,7 @@ #include -class QImage; +class PreviewValues; class PreviewModel { @@ -13,7 +13,7 @@ class PreviewModel PreviewModel() = default; virtual ~PreviewModel(); - virtual QImage GetImage(InputRole role, std::size_t roleIndex) const = 0; + virtual PreviewValues GetPreview(InputRole role, std::size_t roleIndex) const = 0; }; #include diff --git a/src/ShaderNode/Previews/PreviewValues.cpp b/src/ShaderNode/Previews/PreviewValues.cpp new file mode 100644 index 000000000..e44055333 --- /dev/null +++ b/src/ShaderNode/Previews/PreviewValues.cpp @@ -0,0 +1,95 @@ +#include +#include + +PreviewValues::PreviewValues() : +PreviewValues(0, 0) +{ +} + +PreviewValues::PreviewValues(std::size_t width, std::size_t height) : +m_height(height), +m_width(width) +{ + m_values.resize(m_width * m_height); //< RGBA +} + +void PreviewValues::Fill(const Nz::Vector4f& value) +{ + std::fill(m_values.begin(), m_values.end(), value); +} + +QImage PreviewValues::GenerateImage() const +{ + QImage preview(int(m_width), int(m_height), QImage::Format_RGBA8888); + + Nz::UInt8* ptr = preview.bits(); + + const Nz::Vector4f* src = m_values.data(); + for (std::size_t i = 0; i < m_values.size(); ++i) + { + for (std::size_t y = 0; y < 4; ++y) + *ptr++ = static_cast(std::clamp((*src)[y] * 0xFF, 0.f, 255.f)); + + *src++; + } + + return preview; +} + +PreviewValues PreviewValues::Resized(std::size_t newWidth, std::size_t newHeight) const +{ + PreviewValues resizedPreview(newWidth, newHeight); + + float xStep = 1.f / newWidth; + float yStep = 1.f / newHeight; + + for (std::size_t y = 0; y < newHeight; ++y) + { + for (std::size_t x = 0; x < newWidth; ++x) + resizedPreview(x, y) = Sample(x * xStep, y * yStep); + } + + return resizedPreview; +} + +Nz::Vector4f PreviewValues::Sample(float u, float v) const +{ + // Bilinear filtering + float x = std::clamp(u * m_width, 0.f, m_width - 1.f); + float y = std::clamp(v * m_height, 0.f, m_height - 1.f); + + std::size_t iX = static_cast(x); + std::size_t iY = static_cast(y); + + float dX = x - iX; + float dY = y - iY; + + auto ColorAt = [&](std::size_t x, std::size_t y) -> Nz::Vector4f + { + x = std::min(x, m_width - 1); + y = std::min(y, m_height - 1); + + return m_values[y * m_width + x]; + }; + + Nz::Vector4f d00 = ColorAt(iX, iY); + Nz::Vector4f d10 = ColorAt(iX + 1, iY); + Nz::Vector4f d01 = ColorAt(iX, iY + 1); + Nz::Vector4f d11 = ColorAt(iX + 1, iY + 1); + + return Nz::Lerp(Nz::Lerp(d00, d10, dX), Nz::Lerp(d01, d11, dX), dY); +} + +Nz::Vector4f& PreviewValues::operator()(std::size_t x, std::size_t y) +{ + assert(x < m_width); + assert(y < m_height); + return m_values[y * m_width + x]; +} + +Nz::Vector4f PreviewValues::operator()(std::size_t x, std::size_t y) const +{ + assert(x < m_width); + assert(y < m_height); + return m_values[y * m_width + x]; +} diff --git a/src/ShaderNode/Previews/PreviewValues.hpp b/src/ShaderNode/Previews/PreviewValues.hpp new file mode 100644 index 000000000..47ce14680 --- /dev/null +++ b/src/ShaderNode/Previews/PreviewValues.hpp @@ -0,0 +1,50 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_PREVIEWVALUES_HPP +#define NAZARA_SHADERNODES_PREVIEWVALUES_HPP + +#include +#include +#include +#include +#include + +class QImage; + +class PreviewValues +{ + public: + PreviewValues(); + PreviewValues(std::size_t width, std::size_t height); + PreviewValues(const PreviewValues&) = default; + PreviewValues(PreviewValues&&) = default; + ~PreviewValues() = default; + + void Fill(const Nz::Vector4f& value); + + QImage GenerateImage() const; + + inline Nz::Vector4f* GetData(); + inline const Nz::Vector4f* GetData() const; + inline std::size_t GetHeight() const; + inline std::size_t GetWidth() const; + + PreviewValues Resized(std::size_t newWidth, std::size_t newHeight) const; + + Nz::Vector4f Sample(float u, float v) const; + + Nz::Vector4f& operator()(std::size_t x, std::size_t y); + Nz::Vector4f operator()(std::size_t x, std::size_t y) const; + + PreviewValues& operator=(const PreviewValues&) = default; + PreviewValues& operator=(PreviewValues&&) = default; + + private: + std::size_t m_height; + std::size_t m_width; + std::vector m_values; +}; + +#include + +#endif diff --git a/src/ShaderNode/Previews/PreviewValues.inl b/src/ShaderNode/Previews/PreviewValues.inl new file mode 100644 index 000000000..06ca202ec --- /dev/null +++ b/src/ShaderNode/Previews/PreviewValues.inl @@ -0,0 +1,21 @@ +#include + +inline Nz::Vector4f* PreviewValues::GetData() +{ + return m_values.data(); +} + +inline const Nz::Vector4f* PreviewValues::GetData() const +{ + return m_values.data(); +} + +inline std::size_t PreviewValues::GetHeight() const +{ + return m_width; +} + +inline std::size_t PreviewValues::GetWidth() const +{ + return m_height; +} diff --git a/src/ShaderNode/Previews/QuadPreview.cpp b/src/ShaderNode/Previews/QuadPreview.cpp index ef064417d..a4edc9267 100644 --- a/src/ShaderNode/Previews/QuadPreview.cpp +++ b/src/ShaderNode/Previews/QuadPreview.cpp @@ -1,27 +1,22 @@ #include #include -QImage QuadPreview::GetImage(InputRole role, std::size_t roleIndex) const +PreviewValues QuadPreview::GetPreview(InputRole role, std::size_t roleIndex) const { if (role != InputRole::TexCoord) { - QImage dummy(1, 1, QImage::Format_RGBA8888); - dummy.fill(QColor::fromRgb(0, 0, 0, 0)); + PreviewValues dummy(1, 1); + dummy(0, 0) = Nz::Vector4f::Zero(); + return dummy; } - QImage uv(128, 128, QImage::Format_RGBA8888); + PreviewValues uv(128, 128); - std::uint8_t* content = uv.bits(); for (std::size_t y = 0; y < 128; ++y) { for (std::size_t x = 0; x < 128; ++x) - { - *content++ = (x * 255) / 128; - *content++ = (y * 255) / 128; - *content++ = 0; - *content++ = 255; - } + uv(x, y) = Nz::Vector4f(x / 128.f, y / 128.f, 0.f, 1.f); } return uv; diff --git a/src/ShaderNode/Previews/QuadPreview.hpp b/src/ShaderNode/Previews/QuadPreview.hpp index 6c980ae34..947b4d637 100644 --- a/src/ShaderNode/Previews/QuadPreview.hpp +++ b/src/ShaderNode/Previews/QuadPreview.hpp @@ -4,7 +4,7 @@ #define NAZARA_SHADERNODES_QUADPREVIEW_HPP #include -#include +#include class QuadPreview : public PreviewModel { @@ -12,7 +12,7 @@ class QuadPreview : public PreviewModel QuadPreview() = default; ~QuadPreview() = default; - QImage GetImage(InputRole role, std::size_t roleIndex) const override; + PreviewValues GetPreview(InputRole role, std::size_t roleIndex) const override; }; #include From 5164294bec74694c92b24a027e9633997d56f807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sat, 4 Jul 2020 22:52:17 +0200 Subject: [PATCH 255/316] ShaderNodes: Add TextureEdit dialog --- build/scripts/tools/shadernodes.lua | 14 ++-- src/ShaderNode/DataModels/TextureValue.cpp | 14 ++-- src/ShaderNode/DataModels/TextureValue.hpp | 3 +- src/ShaderNode/Previews/QuadPreview.cpp | 11 +-- src/ShaderNode/ShaderGraph.cpp | 11 +++ src/ShaderNode/ShaderGraph.hpp | 2 + src/ShaderNode/Widgets/TextureEditDialog.cpp | 73 ++++++++++++++++++++ src/ShaderNode/Widgets/TextureEditDialog.hpp | 39 +++++++++++ src/ShaderNode/Widgets/TextureEditDialog.inl | 1 + src/ShaderNode/Widgets/TextureEditor.cpp | 45 ++++++++++++ src/ShaderNode/Widgets/TextureEditor.hpp | 4 ++ 11 files changed, 200 insertions(+), 17 deletions(-) create mode 100644 src/ShaderNode/Widgets/TextureEditDialog.cpp create mode 100644 src/ShaderNode/Widgets/TextureEditDialog.hpp create mode 100644 src/ShaderNode/Widgets/TextureEditDialog.inl diff --git a/build/scripts/tools/shadernodes.lua b/build/scripts/tools/shadernodes.lua index 415b71c75..3abeaa658 100644 --- a/build/scripts/tools/shadernodes.lua +++ b/build/scripts/tools/shadernodes.lua @@ -13,11 +13,11 @@ TOOL.Includes = { "../include", "../extlibs/include", "../src", - [[E:\Qt\5.14.1\msvc2017_64\include]], - [[E:\Qt\5.14.1\msvc2017_64\include\QtCore]], - [[E:\Qt\5.14.1\msvc2017_64\include\QtGui]], - [[E:\Qt\5.14.1\msvc2017_64\include\QtWidgets]], - [[C:\Users\Lynix\Documents\GitHub\nodeeditor\include]], + [[C:\Projets\Libs\Qt\5.15.0\msvc2019_64\include]], + [[C:\Projets\Libs\Qt\5.15.0\msvc2019_64\include\QtCore]], + [[C:\Projets\Libs\Qt\5.15.0\msvc2019_64\include\QtGui]], + [[C:\Projets\Libs\Qt\5.15.0\msvc2019_64\include\QtWidgets]], + [[C:\Projets\Libs\nodeeditor\include]], } TOOL.Files = { @@ -37,6 +37,6 @@ TOOL.Libraries = { } TOOL.LibraryPaths.x64 = { - [[E:\Qt\5.14.1\msvc2017_64\lib]], - [[C:\Users\Lynix\Documents\GitHub\nodeeditor\build\lib\Debug]] + [[C:\Projets\Libs\Qt\5.15.0\msvc2019_64\lib]], + [[C:\Projets\Libs\nodeeditor\build\lib\Debug]] } diff --git a/src/ShaderNode/DataModels/TextureValue.cpp b/src/ShaderNode/DataModels/TextureValue.cpp index d0237e8bd..6a6402cf4 100644 --- a/src/ShaderNode/DataModels/TextureValue.cpp +++ b/src/ShaderNode/DataModels/TextureValue.cpp @@ -9,19 +9,23 @@ TextureValue::TextureValue(ShaderGraph& graph) : ShaderNode(graph) { m_onTextureListUpdateSlot.Connect(GetGraph().OnTextureListUpdate, [&](ShaderGraph*) { OnTextureListUpdate(); }); - m_onTexturePreviewUpdateSlot.Connect(GetGraph().OnTexturePreviewUpdate, [&](ShaderGraph*, std::size_t textureIndex) + + auto HandleTextureUpdate = [&](ShaderGraph*, std::size_t textureIndex) { if (m_currentTextureIndex == textureIndex) { UpdatePreview(); Q_EMIT dataUpdated(0); } - }); + }; + + m_onTexturePreviewUpdateSlot.Connect(GetGraph().OnTexturePreviewUpdate, HandleTextureUpdate); + m_onTextureUpdateSlot.Connect(GetGraph().OnTextureUpdate, HandleTextureUpdate); if (graph.GetTextureCount() > 0) { m_currentTextureIndex = 0; - UpdateOutputTexture(); + UpdateTexture(); } DisableCustomVariableName(); @@ -56,7 +60,7 @@ void TextureValue::OnTextureListUpdate() } } -void TextureValue::UpdateOutputTexture() +void TextureValue::UpdateTexture() { if (m_currentTextureIndex) { @@ -97,7 +101,7 @@ void TextureValue::BuildNodeEdition(QFormLayout* layout) else m_currentTextureIndex.reset(); - UpdateOutputTexture(); + UpdateTexture(); UpdatePreview(); Q_EMIT dataUpdated(0); diff --git a/src/ShaderNode/DataModels/TextureValue.hpp b/src/ShaderNode/DataModels/TextureValue.hpp index dfb7efaff..d328e2f05 100644 --- a/src/ShaderNode/DataModels/TextureValue.hpp +++ b/src/ShaderNode/DataModels/TextureValue.hpp @@ -35,13 +35,14 @@ class TextureValue : public ShaderNode protected: bool ComputePreview(QPixmap& pixmap) override; void OnTextureListUpdate(); - void UpdateOutputTexture(); + void UpdateTexture(); void restore(const QJsonObject& data) override; QJsonObject save() const override; NazaraSlot(ShaderGraph, OnTextureListUpdate, m_onTextureListUpdateSlot); NazaraSlot(ShaderGraph, OnTexturePreviewUpdate, m_onTexturePreviewUpdateSlot); + NazaraSlot(ShaderGraph, OnTextureUpdate, m_onTextureUpdateSlot); std::optional m_currentTextureIndex; std::string m_currentTextureText; diff --git a/src/ShaderNode/Previews/QuadPreview.cpp b/src/ShaderNode/Previews/QuadPreview.cpp index a4edc9267..ce6155903 100644 --- a/src/ShaderNode/Previews/QuadPreview.cpp +++ b/src/ShaderNode/Previews/QuadPreview.cpp @@ -11,12 +11,15 @@ PreviewValues QuadPreview::GetPreview(InputRole role, std::size_t roleIndex) con return dummy; } - PreviewValues uv(128, 128); + PreviewValues uv(128, 128); - for (std::size_t y = 0; y < 128; ++y) + float invWidth = 1.f / uv.GetWidth(); + float invHeight = 1.f / uv.GetHeight(); + + for (std::size_t y = 0; y < uv.GetHeight(); ++y) { - for (std::size_t x = 0; x < 128; ++x) - uv(x, y) = Nz::Vector4f(x / 128.f, y / 128.f, 0.f, 1.f); + for (std::size_t x = 0; x < uv.GetWidth(); ++x) + uv(x, y) = Nz::Vector4f(x * invWidth, y * invHeight, 0.f, 1.f); } return uv; diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp index 880afb2a9..5788e1f8b 100644 --- a/src/ShaderNode/ShaderGraph.cpp +++ b/src/ShaderNode/ShaderGraph.cpp @@ -390,6 +390,17 @@ void ShaderGraph::UpdateOutput(std::size_t outputIndex, std::string name, InOutT OnOutputUpdate(this, outputIndex); } +void ShaderGraph::UpdateTexture(std::size_t textureIndex, std::string name, TextureType type, std::size_t bindingIndex) +{ + assert(textureIndex < m_textures.size()); + auto& textureEntry = m_textures[textureIndex]; + textureEntry.bindingIndex = bindingIndex; + textureEntry.name = std::move(name); + textureEntry.type = type; + + OnTextureUpdate(this, textureIndex); +} + void ShaderGraph::UpdateTexturePreview(std::size_t textureIndex, QImage preview) { assert(textureIndex < m_textures.size()); diff --git a/src/ShaderNode/ShaderGraph.hpp b/src/ShaderNode/ShaderGraph.hpp index add7e52ab..b65694f65 100644 --- a/src/ShaderNode/ShaderGraph.hpp +++ b/src/ShaderNode/ShaderGraph.hpp @@ -48,6 +48,7 @@ class ShaderGraph void UpdateInput(std::size_t inputIndex, std::string name, InOutType type, InputRole role, std::size_t roleIndex, std::size_t locationIndex); void UpdateOutput(std::size_t outputIndex, std::string name, InOutType type, std::size_t locationIndex); + void UpdateTexture(std::size_t textureIndex, std::string name, TextureType type, std::size_t bindingIndex); void UpdateTexturePreview(std::size_t texture, QImage preview); struct InputEntry @@ -81,6 +82,7 @@ class ShaderGraph NazaraSignal(OnSelectedNodeUpdate, ShaderGraph*, ShaderNode* /*node*/); NazaraSignal(OnTextureListUpdate, ShaderGraph*); NazaraSignal(OnTexturePreviewUpdate, ShaderGraph*, std::size_t /*textureIndex*/); + NazaraSignal(OnTextureUpdate, ShaderGraph*, std::size_t /*textureIndex*/); private: std::shared_ptr BuildRegistry(); diff --git a/src/ShaderNode/Widgets/TextureEditDialog.cpp b/src/ShaderNode/Widgets/TextureEditDialog.cpp new file mode 100644 index 000000000..f16530e1f --- /dev/null +++ b/src/ShaderNode/Widgets/TextureEditDialog.cpp @@ -0,0 +1,73 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +TextureEditDialog::TextureEditDialog(QWidget* parent) : +QDialog(parent) +{ + setWindowTitle(tr("Texture edit dialog")); + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + + m_textureName = new QLineEdit; + + m_typeList = new QComboBox; + for (std::size_t i = 0; i < TextureTypeCount; ++i) + m_typeList->addItem(EnumToString(static_cast(i))); + + m_bindingIndex = new QSpinBox; + + QFormLayout* formLayout = new QFormLayout; + formLayout->addRow(tr("Name"), m_textureName); + formLayout->addRow(tr("Type"), m_typeList); + formLayout->addRow(tr("Binding index"), m_bindingIndex); + + QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + connect(buttonBox, &QDialogButtonBox::accepted, this, &TextureEditDialog::OnAccept); + connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + + QVBoxLayout* verticalLayout = new QVBoxLayout; + verticalLayout->addLayout(formLayout); + verticalLayout->addWidget(buttonBox); + + setLayout(verticalLayout); +} + +TextureEditDialog::TextureEditDialog(const TextureInfo& texture, QWidget* parent) : +TextureEditDialog(parent) +{ + m_bindingIndex->setValue(int(texture.bindingIndex)); + m_textureName->setText(QString::fromStdString(texture.name)); + m_typeList->setCurrentText(EnumToString(texture.type)); +} + +TextureInfo TextureEditDialog::GetTextureInfo() const +{ + TextureInfo inputInfo; + inputInfo.bindingIndex = static_cast(m_bindingIndex->value()); + inputInfo.name = m_textureName->text().toStdString(); + inputInfo.type = static_cast(m_typeList->currentIndex()); + + return inputInfo; +} + +void TextureEditDialog::OnAccept() +{ + if (m_textureName->text().isEmpty()) + { + QMessageBox::critical(this, tr("Empty name"), tr("Texture name must be set"), QMessageBox::Ok); + return; + } + + if (m_typeList->currentIndex() < 0) + { + QMessageBox::critical(this, tr("Invalid type"), tr("You must select a type"), QMessageBox::Ok); + return; + } + + accept(); +} diff --git a/src/ShaderNode/Widgets/TextureEditDialog.hpp b/src/ShaderNode/Widgets/TextureEditDialog.hpp new file mode 100644 index 000000000..ea402f31d --- /dev/null +++ b/src/ShaderNode/Widgets/TextureEditDialog.hpp @@ -0,0 +1,39 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_TEXTUREEDITDIALOG_HPP +#define NAZARA_SHADERNODES_TEXTUREEDITDIALOG_HPP + +#include +#include + +class QComboBox; +class QLineEdit; +class QSpinBox; + +struct TextureInfo +{ + std::size_t bindingIndex; + std::string name; + TextureType type; +}; + +class TextureEditDialog : public QDialog +{ + public: + TextureEditDialog(QWidget* parent = nullptr); + TextureEditDialog(const TextureInfo& Texture, QWidget* parent = nullptr); + ~TextureEditDialog() = default; + + TextureInfo GetTextureInfo() const; + + private: + void OnAccept(); + + QComboBox* m_typeList; + QLineEdit* m_textureName; + QSpinBox* m_bindingIndex; +}; + +#include + +#endif diff --git a/src/ShaderNode/Widgets/TextureEditDialog.inl b/src/ShaderNode/Widgets/TextureEditDialog.inl new file mode 100644 index 000000000..c15d4e41c --- /dev/null +++ b/src/ShaderNode/Widgets/TextureEditDialog.inl @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/Widgets/TextureEditor.cpp b/src/ShaderNode/Widgets/TextureEditor.cpp index 40cce4652..99b40316a 100644 --- a/src/ShaderNode/Widgets/TextureEditor.cpp +++ b/src/ShaderNode/Widgets/TextureEditor.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -11,6 +12,10 @@ m_shaderGraph(graph) { m_textureList = new QListWidget; connect(m_textureList, &QListWidget::currentRowChanged, this, &TextureEditor::OnTextureSelectionUpdate); + connect(m_textureList, &QListWidget::itemDoubleClicked, [this](QListWidgetItem* item) + { + OnEditTexture(m_textureList->row(item)); + }); m_pixmapLabel = new QLabel; @@ -26,10 +31,44 @@ m_shaderGraph(graph) m_onTextureListUpdateSlot.Connect(m_shaderGraph.OnTextureListUpdate, this, &TextureEditor::OnTextureListUpdate); m_onTexturePreviewUpdateSlot.Connect(m_shaderGraph.OnTexturePreviewUpdate, this, &TextureEditor::OnTexturePreviewUpdate); + m_onTextureUpdateSlot.Connect(m_shaderGraph.OnTextureUpdate, this, &TextureEditor::OnTextureUpdate); RefreshTextures(); } +void TextureEditor::OnAddTexture() +{ + TextureEditDialog* dialog = new TextureEditDialog(this); + dialog->setAttribute(Qt::WA_DeleteOnClose, true); + connect(dialog, &QDialog::accepted, [this, dialog] + { + TextureInfo outputInfo = dialog->GetTextureInfo(); + m_shaderGraph.AddTexture(std::move(outputInfo.name), outputInfo.type, outputInfo.bindingIndex); + }); + + dialog->open(); +} + +void TextureEditor::OnEditTexture(int inputIndex) +{ + const auto& output = m_shaderGraph.GetTexture(inputIndex); + + TextureInfo info; + info.bindingIndex = output.bindingIndex; + info.name = output.name; + info.type = output.type; + + TextureEditDialog* dialog = new TextureEditDialog(std::move(info), this); + dialog->setAttribute(Qt::WA_DeleteOnClose, true); + connect(dialog, &QDialog::accepted, [this, dialog, inputIndex] + { + TextureInfo textureInfo = dialog->GetTextureInfo(); + m_shaderGraph.UpdateTexture(inputIndex, std::move(textureInfo.name), textureInfo.type, textureInfo.bindingIndex); + }); + + dialog->open(); +} + void TextureEditor::OnLoadTexture() { if (!m_currentTextureIndex) @@ -64,6 +103,12 @@ void TextureEditor::OnTexturePreviewUpdate(ShaderGraph* /*graph*/, std::size_t t UpdateTexturePreview(); } +void TextureEditor::OnTextureUpdate(ShaderGraph* /*graph*/, std::size_t inputIndex) +{ + const auto& inputEntry = m_shaderGraph.GetTexture(inputIndex); + m_textureList->item(int(inputIndex))->setText(QString::fromStdString(inputEntry.name)); +} + void TextureEditor::RefreshTextures() { m_textureList->clear(); diff --git a/src/ShaderNode/Widgets/TextureEditor.hpp b/src/ShaderNode/Widgets/TextureEditor.hpp index a3497f288..1c006e0ab 100644 --- a/src/ShaderNode/Widgets/TextureEditor.hpp +++ b/src/ShaderNode/Widgets/TextureEditor.hpp @@ -18,15 +18,19 @@ class TextureEditor : public QWidget ~TextureEditor() = default; private: + void OnAddTexture(); + void OnEditTexture(int inputIndex); void OnLoadTexture(); void OnTextureSelectionUpdate(int textureIndex); void OnTextureListUpdate(ShaderGraph* graph); void OnTexturePreviewUpdate(ShaderGraph* graph, std::size_t textureIndex); + void OnTextureUpdate(ShaderGraph* graph, std::size_t textureIndex); void RefreshTextures(); void UpdateTexturePreview(); NazaraSlot(ShaderGraph, OnTextureListUpdate, m_onTextureListUpdateSlot); NazaraSlot(ShaderGraph, OnTexturePreviewUpdate, m_onTexturePreviewUpdateSlot); + NazaraSlot(ShaderGraph, OnTextureUpdate, m_onTextureUpdateSlot); std::optional m_currentTextureIndex; ShaderGraph& m_shaderGraph; From ee936800830a9654ab827635bd0a792756510833 Mon Sep 17 00:00:00 2001 From: ImperatorS79 Date: Wed, 8 Jul 2020 16:06:47 +0200 Subject: [PATCH 256/316] Fix arrayLayers not being correctly computed in VulkanTexture.cpp for ImageType_2D_array --- src/Nazara/VulkanRenderer/VulkanTexture.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/VulkanRenderer/VulkanTexture.cpp b/src/Nazara/VulkanRenderer/VulkanTexture.cpp index 55d71c3e6..968e1496e 100644 --- a/src/Nazara/VulkanRenderer/VulkanTexture.cpp +++ b/src/Nazara/VulkanRenderer/VulkanTexture.cpp @@ -88,7 +88,7 @@ namespace Nz createInfo.extent.width = params.width; createInfo.extent.height = params.height; createInfo.extent.depth = 1; - createInfo.arrayLayers = params.height; + createInfo.arrayLayers = params.depth; break; case ImageType_3D: From cd01facd01a311709876c75a1fd0b0c27385a7c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 8 Jul 2020 22:52:33 +0200 Subject: [PATCH 257/316] GlslWriter: Handle OpenGL ES precision qualifier --- src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp | 3 +-- src/Nazara/Renderer/GlslWriter.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp b/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp index 561a1d196..b7cc63c9f 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp @@ -35,8 +35,7 @@ namespace Nz const auto& contextParams = context.GetParams(); GlslWriter::Environment env; - env.glES = false; - //env.glES = (contextParams.type == GL::ContextType::OpenGL_ES); + env.glES = (contextParams.type == GL::ContextType::OpenGL_ES); env.glMajorVersion = contextParams.glMajorVersion; env.glMinorVersion = contextParams.glMinorVersion; env.extCallback = [&](const std::string_view& ext) diff --git a/src/Nazara/Renderer/GlslWriter.cpp b/src/Nazara/Renderer/GlslWriter.cpp index 9116aa3a3..61dc030da 100644 --- a/src/Nazara/Renderer/GlslWriter.cpp +++ b/src/Nazara/Renderer/GlslWriter.cpp @@ -98,6 +98,16 @@ namespace Nz AppendLine(); } + if (m_environment.glES) + { + AppendLine("#if GL_FRAGMENT_PRECISION_HIGH"); + AppendLine("precision highp float;"); + AppendLine("#else"); + AppendLine("precision mediump float;"); + AppendLine("#endif"); + AppendLine(); + } + // Global variables (uniforms, input and outputs) const char* inKeyword = (glslVersion >= 130) ? "in" : "varying"; const char* outKeyword = (glslVersion >= 130) ? "out" : "varying"; From 4c0dc7813d9e0bf69846d6d243c5b834af8d68d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Tue, 14 Jul 2020 21:59:25 +0200 Subject: [PATCH 258/316] VulkanTest: Enable relative mouse mode --- examples/VulkanTest/main.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index e42aa41ac..e0cb14437 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -229,6 +229,8 @@ int main() Nz::Clock secondClock; unsigned int fps = 0; + Nz::Mouse::SetRelativeMouseMode(true); + while (window.IsOpen()) { Nz::WindowEvent event; @@ -252,10 +254,6 @@ int main() camAngles.pitch = Nz::Clamp(camAngles.pitch + event.mouseMove.deltaY*sensitivity, -89.f, 89.f); camQuat = camAngles; - - // Pour éviter que le curseur ne sorte de l'écran, nous le renvoyons au centre de la fenêtre - // Cette fonction est codée de sorte à ne pas provoquer d'évènement MouseMoved - Nz::Mouse::SetPosition(windowSize.x / 2, windowSize.y / 2, window); break; } } From fbba281d14d6300290f7f4637e2277a47f2dfc5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Tue, 14 Jul 2020 21:59:49 +0200 Subject: [PATCH 259/316] Renderer: Add support for struct and UBO --- include/Nazara/Renderer/GlslWriter.hpp | 4 +- include/Nazara/Renderer/GlslWriter.inl | 95 +++++++++++-- include/Nazara/Renderer/ShaderAst.hpp | 34 ++++- include/Nazara/Renderer/ShaderAst.inl | 16 +++ include/Nazara/Renderer/ShaderEnums.hpp | 5 + include/Nazara/Renderer/ShaderSerializer.hpp | 11 +- include/Nazara/Renderer/ShaderSerializer.inl | 18 +++ include/Nazara/Renderer/ShaderValidator.hpp | 5 +- src/Nazara/Renderer/GlslWriter.cpp | 46 +++++- src/Nazara/Renderer/ShaderAst.cpp | 20 ++- src/Nazara/Renderer/ShaderSerializer.cpp | 139 +++++++++++++++++-- src/Nazara/Renderer/ShaderValidator.cpp | 2 +- 12 files changed, 346 insertions(+), 49 deletions(-) diff --git a/include/Nazara/Renderer/GlslWriter.hpp b/include/Nazara/Renderer/GlslWriter.hpp index e0f9bf11e..999a93c48 100644 --- a/include/Nazara/Renderer/GlslWriter.hpp +++ b/include/Nazara/Renderer/GlslWriter.hpp @@ -44,15 +44,17 @@ namespace Nz }; private: + void Append(ShaderAst::Type type); void Append(ShaderNodes::BuiltinEntry builtin); void Append(ShaderNodes::ExpressionType type); + void Append(ShaderNodes::MemoryLayout layout); template void Append(const T& param); void AppendCommentSection(const std::string& section); void AppendFunction(const ShaderAst::Function& func); void AppendFunctionPrototype(const ShaderAst::Function& func); void AppendLine(const std::string& txt = {}); - template void DeclareVariables(const std::vector& variables, const std::string& keyword = {}, const std::string& section = {}); + template void DeclareVariables(const ShaderAst& shader, const std::vector& variables, const std::string& keyword = {}, const std::string& section = {}); void EnterScope(); void LeaveScope(); diff --git a/include/Nazara/Renderer/GlslWriter.inl b/include/Nazara/Renderer/GlslWriter.inl index fcaca4b98..9b67eaa89 100644 --- a/include/Nazara/Renderer/GlslWriter.inl +++ b/include/Nazara/Renderer/GlslWriter.inl @@ -17,7 +17,7 @@ namespace Nz } template - void GlslWriter::DeclareVariables(const std::vector& variables, const std::string& keyword, const std::string& section) + void GlslWriter::DeclareVariables(const ShaderAst& shader, const std::vector& variables, const std::string& keyword, const std::string& section) { if (!variables.empty()) { @@ -34,27 +34,94 @@ namespace Nz Append(*var.locationIndex); Append(") "); } + + if (!keyword.empty()) + { + Append(keyword); + Append(" "); + } + + Append(var.type); + Append(" "); + Append(var.name); + AppendLine(";"); } else if constexpr (std::is_same_v) { - if (var.bindingIndex) + if (var.bindingIndex || var.memoryLayout) { - Append("layout(binding = "); - Append(*var.bindingIndex); + Append("layout("); + + bool first = true; + if (var.bindingIndex) + { + if (!first) + Append(", "); + + Append("binding = "); + Append(*var.bindingIndex); + + first = false; + } + + if (var.memoryLayout) + { + if (!first) + Append(", "); + + Append(*var.memoryLayout); + + first = false; + } + Append(") "); } - } - if (!keyword.empty()) - { - Append(keyword); - Append(" "); - } + if (!keyword.empty()) + { + Append(keyword); + Append(" "); + } - Append(var.type); - Append(" "); - Append(var.name); - AppendLine(";"); + std::visit([&](auto&& arg) + { + using T = std::decay_t; + if constexpr (std::is_same_v) + { + Append(arg); + Append(" "); + Append(var.name); + } + else if constexpr (std::is_same_v) + { + const auto& structs = shader.GetStructs(); + auto it = std::find_if(structs.begin(), structs.end(), [&](const auto& s) { return s.name == arg; }); + if (it == structs.end()) + throw std::runtime_error("struct " + arg + " has not been defined"); + + const auto& s = *it; + + AppendLine(var.name + "_interface"); + AppendLine("{"); + for (const auto& m : s.members) + { + Append("\t"); + Append(m.type); + Append(" "); + Append(m.name); + AppendLine(";"); + } + Append("} "); + Append(var.name); + } + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + + }, var.type); + + AppendLine(";"); + AppendLine(); + } } AppendLine(); diff --git a/include/Nazara/Renderer/ShaderAst.hpp b/include/Nazara/Renderer/ShaderAst.hpp index 0aa094a10..4b57bbced 100644 --- a/include/Nazara/Renderer/ShaderAst.hpp +++ b/include/Nazara/Renderer/ShaderAst.hpp @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include namespace Nz @@ -21,16 +23,21 @@ namespace Nz struct Function; struct FunctionParameter; struct InputOutput; - struct VariableBase; + struct Struct; + struct StructMember; struct Uniform; + struct VariableBase; + + using Type = std::variant; ShaderAst() = default; ~ShaderAst() = default; void AddFunction(std::string name, ShaderNodes::StatementPtr statement, std::vector parameters = {}, ShaderNodes::ExpressionType returnType = ShaderNodes::ExpressionType::Void); - void AddInput(std::string name, ShaderNodes::ExpressionType type, std::optional locationIndex); - void AddOutput(std::string name, ShaderNodes::ExpressionType type, std::optional locationIndex); - void AddUniform(std::string name, ShaderNodes::ExpressionType type, std::optional bindingIndex); + void AddInput(std::string name, Type type, std::optional locationIndex); + void AddOutput(std::string name, Type type, std::optional locationIndex); + void AddStruct(std::string name, std::vector members); + void AddUniform(std::string name, Type type, std::optional bindingIndex, std::optional memoryLayout); inline const Function& GetFunction(std::size_t i) const; inline std::size_t GetFunctionCount() const; @@ -41,6 +48,9 @@ namespace Nz inline const InputOutput& GetOutput(std::size_t i) const; inline std::size_t GetOutputCount() const; inline const std::vector& GetOutputs() const; + inline const Struct& GetStruct(std::size_t i) const; + inline std::size_t GetStructCount() const; + inline const std::vector& GetStructs() const; inline const Uniform& GetUniform(std::size_t i) const; inline std::size_t GetUniformCount() const; inline const std::vector& GetUniforms() const; @@ -48,7 +58,7 @@ namespace Nz struct VariableBase { std::string name; - ShaderNodes::ExpressionType type; + Type type; }; struct FunctionParameter : VariableBase @@ -71,12 +81,26 @@ namespace Nz struct Uniform : VariableBase { std::optional bindingIndex; + std::optional memoryLayout; + }; + + struct Struct + { + std::string name; + std::vector members; + }; + + struct StructMember + { + std::string name; + Type type; }; private: std::vector m_functions; std::vector m_inputs; std::vector m_outputs; + std::vector m_structs; std::vector m_uniforms; }; } diff --git a/include/Nazara/Renderer/ShaderAst.inl b/include/Nazara/Renderer/ShaderAst.inl index d9f8f88aa..c42c1e9c1 100644 --- a/include/Nazara/Renderer/ShaderAst.inl +++ b/include/Nazara/Renderer/ShaderAst.inl @@ -55,6 +55,22 @@ namespace Nz return m_outputs; } + inline auto ShaderAst::GetStruct(std::size_t i) const -> const Struct& + { + assert(i < m_structs.size()); + return m_structs[i]; + } + + inline std::size_t ShaderAst::GetStructCount() const + { + return m_structs.size(); + } + + inline auto ShaderAst::GetStructs() const -> const std::vector& + { + return m_structs; + } + inline auto ShaderAst::GetUniform(std::size_t i) const -> const Uniform& { assert(i < m_uniforms.size()); diff --git a/include/Nazara/Renderer/ShaderEnums.hpp b/include/Nazara/Renderer/ShaderEnums.hpp index f400c7516..7a93cea7b 100644 --- a/include/Nazara/Renderer/ShaderEnums.hpp +++ b/include/Nazara/Renderer/ShaderEnums.hpp @@ -56,6 +56,11 @@ namespace Nz::ShaderNodes DotProduct }; + enum class MemoryLayout + { + Std140 + }; + enum class NodeType { None = -1, diff --git a/include/Nazara/Renderer/ShaderSerializer.hpp b/include/Nazara/Renderer/ShaderSerializer.hpp index eac0c2bf8..f79040b2c 100644 --- a/include/Nazara/Renderer/ShaderSerializer.hpp +++ b/include/Nazara/Renderer/ShaderSerializer.hpp @@ -11,13 +11,12 @@ #include #include #include +#include #include #include namespace Nz { - class ShaderAst; - class NAZARA_RENDERER_API ShaderSerializerBase { public: @@ -44,6 +43,7 @@ namespace Nz protected: template void Container(T& container); template void Enum(T& enumVal); + template void OptEnum(std::optional& optVal); template void OptVal(std::optional& optVal); virtual bool IsWriting() const = 0; @@ -57,6 +57,8 @@ namespace Nz virtual void Value(Vector2f& val) = 0; virtual void Value(Vector3f& val) = 0; virtual void Value(Vector4f& val) = 0; + virtual void Value(UInt8& val) = 0; + virtual void Value(UInt16& val) = 0; virtual void Value(UInt32& val) = 0; inline void Value(std::size_t& val); @@ -82,6 +84,8 @@ namespace Nz void Value(Vector2f& val) override; void Value(Vector3f& val) override; void Value(Vector4f& val) override; + void Value(UInt8& val) override; + void Value(UInt16& val) override; void Value(UInt32& val) override; void Variable(ShaderNodes::VariablePtr& var) override; @@ -99,12 +103,15 @@ namespace Nz private: bool IsWriting() const override; void Node(ShaderNodes::NodePtr& node) override; + void Type(ShaderAst::Type& type); void Value(bool& val) override; void Value(float& val) override; void Value(std::string& val) override; void Value(Vector2f& val) override; void Value(Vector3f& val) override; void Value(Vector4f& val) override; + void Value(UInt8& val) override; + void Value(UInt16& val) override; void Value(UInt32& val) override; void Variable(ShaderNodes::VariablePtr& var) override; diff --git a/include/Nazara/Renderer/ShaderSerializer.inl b/include/Nazara/Renderer/ShaderSerializer.inl index 0daeb6653..51187d520 100644 --- a/include/Nazara/Renderer/ShaderSerializer.inl +++ b/include/Nazara/Renderer/ShaderSerializer.inl @@ -36,6 +36,24 @@ namespace Nz enumVal = static_cast(value); } + template + void ShaderSerializerBase::OptEnum(std::optional& optVal) + { + bool isWriting = IsWriting(); + + bool hasValue; + if (isWriting) + hasValue = optVal.has_value(); + + Value(hasValue); + + if (!isWriting && hasValue) + optVal.emplace(); + + if (optVal.has_value()) + Enum(optVal.value()); + } + template void ShaderSerializerBase::OptVal(std::optional& optVal) { diff --git a/include/Nazara/Renderer/ShaderValidator.hpp b/include/Nazara/Renderer/ShaderValidator.hpp index bfdab9844..3df9f4ae5 100644 --- a/include/Nazara/Renderer/ShaderValidator.hpp +++ b/include/Nazara/Renderer/ShaderValidator.hpp @@ -11,12 +11,11 @@ #include #include #include +#include #include namespace Nz { - class ShaderAst; - class NAZARA_RENDERER_API ShaderValidator : public ShaderVisitor { public: @@ -31,7 +30,7 @@ namespace Nz const ShaderNodes::ExpressionPtr& MandatoryExpr(const ShaderNodes::ExpressionPtr& node); const ShaderNodes::NodePtr& MandatoryNode(const ShaderNodes::NodePtr& node); void TypeMustMatch(const ShaderNodes::ExpressionPtr& left, const ShaderNodes::ExpressionPtr& right); - void TypeMustMatch(ShaderNodes::ExpressionType left, ShaderNodes::ExpressionType right); + void TypeMustMatch(const ShaderAst::Type& left, const ShaderAst::Type& right); using ShaderVisitor::Visit; void Visit(const ShaderNodes::AssignOp& node) override; diff --git a/src/Nazara/Renderer/GlslWriter.cpp b/src/Nazara/Renderer/GlslWriter.cpp index 61dc030da..accb493b7 100644 --- a/src/Nazara/Renderer/GlslWriter.cpp +++ b/src/Nazara/Renderer/GlslWriter.cpp @@ -108,13 +108,35 @@ namespace Nz AppendLine(); } + // Structures + /*if (shader.GetStructCount() > 0) + { + AppendCommentSection("Structures"); + for (const auto& s : shader.GetStructs()) + { + Append("struct "); + AppendLine(s.name); + AppendLine("{"); + for (const auto& m : s.members) + { + Append("\t"); + Append(m.type); + Append(" "); + Append(m.name); + AppendLine(";"); + } + AppendLine("};"); + AppendLine(); + } + }*/ + // Global variables (uniforms, input and outputs) const char* inKeyword = (glslVersion >= 130) ? "in" : "varying"; const char* outKeyword = (glslVersion >= 130) ? "out" : "varying"; - DeclareVariables(shader.GetUniforms(), "uniform", "Uniforms"); - DeclareVariables(shader.GetInputs(), inKeyword, "Inputs"); - DeclareVariables(shader.GetOutputs(), outKeyword, "Outputs"); + DeclareVariables(shader, shader.GetUniforms(), "uniform", "Uniforms"); + DeclareVariables(shader, shader.GetInputs(), inKeyword, "Inputs"); + DeclareVariables(shader, shader.GetOutputs(), outKeyword, "Outputs"); std::size_t functionCount = shader.GetFunctionCount(); if (functionCount > 1) @@ -141,6 +163,14 @@ namespace Nz m_environment = std::move(environment); } + void GlslWriter::Append(ShaderAst::Type type) + { + std::visit([&](auto&& arg) + { + Append(arg); + }, type); + } + void GlslWriter::Append(ShaderNodes::BuiltinEntry builtin) { switch (builtin) @@ -182,6 +212,16 @@ namespace Nz } } + void GlslWriter::Append(ShaderNodes::MemoryLayout layout) + { + switch (layout) + { + case ShaderNodes::MemoryLayout::Std140: + Append("std140"); + break; + } + } + void GlslWriter::AppendCommentSection(const std::string& section) { NazaraAssert(m_currentState, "This function should only be called while processing an AST"); diff --git a/src/Nazara/Renderer/ShaderAst.cpp b/src/Nazara/Renderer/ShaderAst.cpp index a52cca657..05d3eb94d 100644 --- a/src/Nazara/Renderer/ShaderAst.cpp +++ b/src/Nazara/Renderer/ShaderAst.cpp @@ -16,27 +16,35 @@ namespace Nz functionEntry.statement = std::move(statement); } - void ShaderAst::AddInput(std::string name, ShaderNodes::ExpressionType type, std::optional locationIndex) + void ShaderAst::AddInput(std::string name, Type type, std::optional locationIndex) { auto& inputEntry = m_inputs.emplace_back(); inputEntry.name = std::move(name); inputEntry.locationIndex = std::move(locationIndex); - inputEntry.type = type; + inputEntry.type = std::move(type); } - void ShaderAst::AddOutput(std::string name, ShaderNodes::ExpressionType type, std::optional locationIndex) + void ShaderAst::AddOutput(std::string name, Type type, std::optional locationIndex) { auto& outputEntry = m_outputs.emplace_back(); outputEntry.name = std::move(name); outputEntry.locationIndex = std::move(locationIndex); - outputEntry.type = type; + outputEntry.type = std::move(type); } - void ShaderAst::AddUniform(std::string name, ShaderNodes::ExpressionType type, std::optional bindingIndex) + void ShaderAst::AddStruct(std::string name, std::vector members) + { + auto& structEntry = m_structs.emplace_back(); + structEntry.name = std::move(name); + structEntry.members = std::move(members); + } + + void ShaderAst::AddUniform(std::string name, Type type, std::optional bindingIndex, std::optional memoryLayout) { auto& uniformEntry = m_uniforms.emplace_back(); uniformEntry.bindingIndex = std::move(bindingIndex); + uniformEntry.memoryLayout = std::move(memoryLayout); uniformEntry.name = std::move(name); - uniformEntry.type = type; + uniformEntry.type = std::move(type); } } diff --git a/src/Nazara/Renderer/ShaderSerializer.cpp b/src/Nazara/Renderer/ShaderSerializer.cpp index f97186acf..9cf7c47ff 100644 --- a/src/Nazara/Renderer/ShaderSerializer.cpp +++ b/src/Nazara/Renderer/ShaderSerializer.cpp @@ -3,7 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include #include #include #include @@ -250,12 +249,33 @@ namespace Nz { m_stream << s_magicNumber << s_currentVersion; + auto SerializeType = [&](const ShaderAst::Type& type) + { + std::visit([&](auto&& arg) + { + using T = std::decay_t; + if constexpr (std::is_same_v) + { + m_stream << UInt8(0); + m_stream << UInt32(arg); + } + else if constexpr (std::is_same_v) + { + m_stream << UInt8(1); + m_stream << arg; + } + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + }, type); + }; + auto SerializeInputOutput = [&](auto& inout) { m_stream << UInt32(inout.size()); for (const auto& data : inout) { - m_stream << data.name << UInt32(data.type); + m_stream << data.name; + SerializeType(data.type); m_stream << data.locationIndex.has_value(); if (data.locationIndex) @@ -263,17 +283,34 @@ namespace Nz } }; + m_stream << UInt32(shader.GetStructCount()); + for (const auto& s : shader.GetStructs()) + { + m_stream << s.name; + m_stream << UInt32(s.members.size()); + for (const auto& member : s.members) + { + m_stream << member.name; + SerializeType(member.type); + } + } + SerializeInputOutput(shader.GetInputs()); SerializeInputOutput(shader.GetOutputs()); m_stream << UInt32(shader.GetUniformCount()); for (const auto& uniform : shader.GetUniforms()) { - m_stream << uniform.name << UInt32(uniform.type); + m_stream << uniform.name; + SerializeType(uniform.type); m_stream << uniform.bindingIndex.has_value(); if (uniform.bindingIndex) m_stream << UInt32(uniform.bindingIndex.value()); + + m_stream << uniform.memoryLayout.has_value(); + if (uniform.memoryLayout) + m_stream << UInt32(uniform.memoryLayout.value()); } m_stream << UInt32(shader.GetFunctionCount()); @@ -283,7 +320,10 @@ namespace Nz m_stream << UInt32(func.parameters.size()); for (const auto& param : func.parameters) - m_stream << param.name << UInt32(param.type); + { + m_stream << param.name; + SerializeType(param.type); + } Node(func.statement); } @@ -343,6 +383,16 @@ namespace Nz m_stream << val; } + void ShaderSerializer::Value(UInt8& val) + { + m_stream << val; + } + + void ShaderSerializer::Value(UInt16& val) + { + m_stream << val; + } + void ShaderSerializer::Value(UInt32& val) { m_stream << val; @@ -374,19 +424,38 @@ namespace Nz ShaderAst shader; + UInt32 structCount; + m_stream >> structCount; + for (UInt32 i = 0; i < structCount; ++i) + { + std::string structName; + std::vector members; + + Value(structName); + Container(members); + + for (auto& member : members) + { + Value(member.name); + Type(member.type); + } + + shader.AddStruct(std::move(structName), std::move(members)); + } + UInt32 inputCount; m_stream >> inputCount; for (UInt32 i = 0; i < inputCount; ++i) { std::string inputName; - ShaderNodes::ExpressionType inputType; + ShaderAst::Type inputType; std::optional location; Value(inputName); - Enum(inputType); + Type(inputType); OptVal(location); - shader.AddInput(std::move(inputName), inputType, location); + shader.AddInput(std::move(inputName), std::move(inputType), location); } UInt32 outputCount; @@ -394,14 +463,14 @@ namespace Nz for (UInt32 i = 0; i < outputCount; ++i) { std::string outputName; - ShaderNodes::ExpressionType outputType; + ShaderAst::Type outputType; std::optional location; Value(outputName); - Enum(outputType); + Type(outputType); OptVal(location); - shader.AddOutput(std::move(outputName), outputType, location); + shader.AddOutput(std::move(outputName), std::move(outputType), location); } UInt32 uniformCount; @@ -409,14 +478,16 @@ namespace Nz for (UInt32 i = 0; i < uniformCount; ++i) { std::string name; - ShaderNodes::ExpressionType type; + ShaderAst::Type type; std::optional binding; + std::optional memLayout; Value(name); - Enum(type); + Type(type); OptVal(binding); + OptEnum(memLayout); - shader.AddUniform(std::move(name), type, binding); + shader.AddUniform(std::move(name), std::move(type), std::move(binding), std::move(memLayout)); } UInt32 funcCount; @@ -433,7 +504,7 @@ namespace Nz for (auto& param : parameters) { Value(param.name); - Enum(param.type); + Type(param.type); } ShaderNodes::NodePtr node; @@ -489,6 +560,36 @@ namespace Nz } } + void ShaderUnserializer::Type(ShaderAst::Type& type) + { + UInt8 typeIndex; + Value(typeIndex); + + switch (typeIndex) + { + case 0: //< Primitive + { + ShaderNodes::ExpressionType exprType; + Enum(exprType); + + type = exprType; + break; + } + + case 1: //< Struct (name) + { + std::string structName; + Value(structName); + + type = std::move(structName); + break; + } + + default: + break; + } + } + void ShaderUnserializer::Value(bool& val) { m_stream >> val; @@ -519,6 +620,16 @@ namespace Nz m_stream >> val; } + void ShaderUnserializer::Value(UInt8& val) + { + m_stream >> val; + } + + void ShaderUnserializer::Value(UInt16& val) + { + m_stream >> val; + } + void ShaderUnserializer::Value(UInt32& val) { m_stream >> val; diff --git a/src/Nazara/Renderer/ShaderValidator.cpp b/src/Nazara/Renderer/ShaderValidator.cpp index aab559a61..37eecb767 100644 --- a/src/Nazara/Renderer/ShaderValidator.cpp +++ b/src/Nazara/Renderer/ShaderValidator.cpp @@ -77,7 +77,7 @@ namespace Nz return TypeMustMatch(left->GetExpressionType(), right->GetExpressionType()); } - void ShaderValidator::TypeMustMatch(ShaderNodes::ExpressionType left, ShaderNodes::ExpressionType right) + void ShaderValidator::TypeMustMatch(const ShaderAst::Type& left, const ShaderAst::Type& right) { if (left != right) throw AstError{ "Left expression type must match right expression type" }; From c7a8091e68d0f2225163e0ed333867a8439deee1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Tue, 14 Jul 2020 22:00:17 +0200 Subject: [PATCH 260/316] ShaderNode: Add buffers and structs --- src/ShaderNode/DataModels/InputValue.cpp | 18 +- src/ShaderNode/DataModels/OutputValue.cpp | 16 +- src/ShaderNode/Enums.cpp | 35 ++- src/ShaderNode/Enums.hpp | 18 +- src/ShaderNode/Previews/PreviewValues.inl | 4 +- src/ShaderNode/ShaderGraph.cpp | 170 ++++++++++++- src/ShaderNode/ShaderGraph.hpp | 53 ++++- src/ShaderNode/ShaderGraph.inl | 32 +++ src/ShaderNode/Widgets/BufferEditDialog.cpp | 88 +++++++ src/ShaderNode/Widgets/BufferEditDialog.hpp | 43 ++++ src/ShaderNode/Widgets/BufferEditDialog.inl | 1 + src/ShaderNode/Widgets/BufferEditor.cpp | 85 +++++++ src/ShaderNode/Widgets/BufferEditor.hpp | 36 +++ src/ShaderNode/Widgets/BufferEditor.inl | 1 + src/ShaderNode/Widgets/InputEditDialog.cpp | 6 +- src/ShaderNode/Widgets/InputEditDialog.hpp | 2 +- src/ShaderNode/Widgets/MainWindow.cpp | 63 ++++- src/ShaderNode/Widgets/OutputEditDialog.cpp | 6 +- src/ShaderNode/Widgets/OutputEditDialog.hpp | 2 +- src/ShaderNode/Widgets/StructEditDialog.cpp | 224 ++++++++++++++++++ src/ShaderNode/Widgets/StructEditDialog.hpp | 59 +++++ src/ShaderNode/Widgets/StructEditDialog.inl | 1 + src/ShaderNode/Widgets/StructEditor.cpp | 107 +++++++++ src/ShaderNode/Widgets/StructEditor.hpp | 37 +++ src/ShaderNode/Widgets/StructEditor.inl | 1 + .../Widgets/StructMemberEditDialog.cpp | 86 +++++++ .../Widgets/StructMemberEditDialog.hpp | 39 +++ .../Widgets/StructMemberEditDialog.inl | 1 + 28 files changed, 1169 insertions(+), 65 deletions(-) create mode 100644 src/ShaderNode/Widgets/BufferEditDialog.cpp create mode 100644 src/ShaderNode/Widgets/BufferEditDialog.hpp create mode 100644 src/ShaderNode/Widgets/BufferEditDialog.inl create mode 100644 src/ShaderNode/Widgets/BufferEditor.cpp create mode 100644 src/ShaderNode/Widgets/BufferEditor.hpp create mode 100644 src/ShaderNode/Widgets/BufferEditor.inl create mode 100644 src/ShaderNode/Widgets/StructEditDialog.cpp create mode 100644 src/ShaderNode/Widgets/StructEditDialog.hpp create mode 100644 src/ShaderNode/Widgets/StructEditDialog.inl create mode 100644 src/ShaderNode/Widgets/StructEditor.cpp create mode 100644 src/ShaderNode/Widgets/StructEditor.hpp create mode 100644 src/ShaderNode/Widgets/StructEditor.inl create mode 100644 src/ShaderNode/Widgets/StructMemberEditDialog.cpp create mode 100644 src/ShaderNode/Widgets/StructMemberEditDialog.hpp create mode 100644 src/ShaderNode/Widgets/StructMemberEditDialog.inl diff --git a/src/ShaderNode/DataModels/InputValue.cpp b/src/ShaderNode/DataModels/InputValue.cpp index e0b117e83..a5a3a269b 100644 --- a/src/ShaderNode/DataModels/InputValue.cpp +++ b/src/ShaderNode/DataModels/InputValue.cpp @@ -120,11 +120,11 @@ Nz::ShaderNodes::ExpressionPtr InputValue::GetExpression(Nz::ShaderNodes::Expres { switch (inputEntry.type) { - case InOutType::Bool: return Nz::ShaderNodes::ExpressionType::Boolean; - case InOutType::Float1: return Nz::ShaderNodes::ExpressionType::Float1; - case InOutType::Float2: return Nz::ShaderNodes::ExpressionType::Float2; - case InOutType::Float3: return Nz::ShaderNodes::ExpressionType::Float3; - case InOutType::Float4: return Nz::ShaderNodes::ExpressionType::Float4; + case PrimitiveType::Bool: return Nz::ShaderNodes::ExpressionType::Boolean; + case PrimitiveType::Float1: return Nz::ShaderNodes::ExpressionType::Float1; + case PrimitiveType::Float2: return Nz::ShaderNodes::ExpressionType::Float2; + case PrimitiveType::Float3: return Nz::ShaderNodes::ExpressionType::Float3; + case PrimitiveType::Float4: return Nz::ShaderNodes::ExpressionType::Float4; } assert(false); @@ -146,12 +146,12 @@ auto InputValue::dataType(QtNodes::PortType portType, QtNodes::PortIndex portInd switch (inputEntry.type) { //case InputType::Bool: return Nz::ShaderNodes::ExpressionType::Boolean; - case InOutType::Float1: + case PrimitiveType::Float1: return FloatData::Type(); - case InOutType::Float2: - case InOutType::Float3: - case InOutType::Float4: + case PrimitiveType::Float2: + case PrimitiveType::Float3: + case PrimitiveType::Float4: return VecData::Type(); } diff --git a/src/ShaderNode/DataModels/OutputValue.cpp b/src/ShaderNode/DataModels/OutputValue.cpp index a6b644be3..1f65c5953 100644 --- a/src/ShaderNode/DataModels/OutputValue.cpp +++ b/src/ShaderNode/DataModels/OutputValue.cpp @@ -67,11 +67,11 @@ Nz::ShaderNodes::ExpressionPtr OutputValue::GetExpression(Nz::ShaderNodes::Expre { switch (outputEntry.type) { - case InOutType::Bool: return Nz::ShaderNodes::ExpressionType::Boolean; - case InOutType::Float1: return Nz::ShaderNodes::ExpressionType::Float1; - case InOutType::Float2: return Nz::ShaderNodes::ExpressionType::Float2; - case InOutType::Float3: return Nz::ShaderNodes::ExpressionType::Float3; - case InOutType::Float4: return Nz::ShaderNodes::ExpressionType::Float4; + case PrimitiveType::Bool: return Nz::ShaderNodes::ExpressionType::Boolean; + case PrimitiveType::Float1: return Nz::ShaderNodes::ExpressionType::Float1; + case PrimitiveType::Float2: return Nz::ShaderNodes::ExpressionType::Float2; + case PrimitiveType::Float3: return Nz::ShaderNodes::ExpressionType::Float3; + case PrimitiveType::Float4: return Nz::ShaderNodes::ExpressionType::Float4; } assert(false); @@ -96,9 +96,9 @@ QtNodes::NodeDataType OutputValue::dataType(QtNodes::PortType portType, QtNodes: { //case InOutType::Bool: return Nz::ShaderNodes::ExpressionType::Boolean; //case InOutType::Float1: return Nz::ShaderNodes::ExpressionType::Float1; - case InOutType::Float2: - case InOutType::Float3: - case InOutType::Float4: + case PrimitiveType::Float2: + case PrimitiveType::Float3: + case PrimitiveType::Float4: return VecData::Type(); } diff --git a/src/ShaderNode/Enums.cpp b/src/ShaderNode/Enums.cpp index 1f756b8de..610078d65 100644 --- a/src/ShaderNode/Enums.cpp +++ b/src/ShaderNode/Enums.cpp @@ -1,21 +1,32 @@ #include #include -std::size_t GetComponentCount(InOutType type) +std::size_t GetComponentCount(PrimitiveType type) { switch (type) { - case InOutType::Bool: return 1; - case InOutType::Float1: return 1; - case InOutType::Float2: return 2; - case InOutType::Float3: return 3; - case InOutType::Float4: return 4; + case PrimitiveType::Bool: return 1; + case PrimitiveType::Float1: return 1; + case PrimitiveType::Float2: return 2; + case PrimitiveType::Float3: return 3; + case PrimitiveType::Float4: return 4; } assert(false); return 0; } +const char* EnumToString(BufferType bufferType) +{ + switch (bufferType) + { + case BufferType::UniformBufferObject: return "UniformBufferObject"; + } + + assert(false); + return ""; +} + const char* EnumToString(InputRole role) { switch (role) @@ -30,15 +41,15 @@ const char* EnumToString(InputRole role) return ""; } -const char* EnumToString(InOutType input) +const char* EnumToString(PrimitiveType input) { switch (input) { - case InOutType::Bool: return "Bool"; - case InOutType::Float1: return "Float"; - case InOutType::Float2: return "Float2"; - case InOutType::Float3: return "Float3"; - case InOutType::Float4: return "Float4"; + case PrimitiveType::Bool: return "Bool"; + case PrimitiveType::Float1: return "Float"; + case PrimitiveType::Float2: return "Float2"; + case PrimitiveType::Float3: return "Float3"; + case PrimitiveType::Float4: return "Float4"; } assert(false); diff --git a/src/ShaderNode/Enums.hpp b/src/ShaderNode/Enums.hpp index 72a5443f7..41e8f4360 100644 --- a/src/ShaderNode/Enums.hpp +++ b/src/ShaderNode/Enums.hpp @@ -7,6 +7,15 @@ #include #include +enum class BufferType +{ + UniformBufferObject, + + Max = UniformBufferObject +}; + +constexpr std::size_t BufferTypeCount = static_cast(BufferType::Max) + 1; + enum class InputRole { None, @@ -19,7 +28,7 @@ enum class InputRole constexpr std::size_t InputRoleCount = static_cast(InputRole::Max) + 1; -enum class InOutType +enum class PrimitiveType { Bool, Float1, @@ -30,7 +39,7 @@ enum class InOutType Max = Float4 }; -constexpr std::size_t InOutTypeCount = static_cast(InOutType::Max) + 1; +constexpr std::size_t PrimitiveTypeCount = static_cast(PrimitiveType::Max) + 1; enum class TextureType { @@ -43,10 +52,11 @@ constexpr std::size_t TextureTypeCount = static_cast(TextureType::M template std::optional DecodeEnum(const std::string_view& str); +const char* EnumToString(BufferType bufferType); const char* EnumToString(InputRole role); -const char* EnumToString(InOutType input); +const char* EnumToString(PrimitiveType input); const char* EnumToString(TextureType textureType); -std::size_t GetComponentCount(InOutType type); +std::size_t GetComponentCount(PrimitiveType type); #include diff --git a/src/ShaderNode/Previews/PreviewValues.inl b/src/ShaderNode/Previews/PreviewValues.inl index 06ca202ec..3efbebc39 100644 --- a/src/ShaderNode/Previews/PreviewValues.inl +++ b/src/ShaderNode/Previews/PreviewValues.inl @@ -12,10 +12,10 @@ inline const Nz::Vector4f* PreviewValues::GetData() const inline std::size_t PreviewValues::GetHeight() const { - return m_width; + return m_height; } inline std::size_t PreviewValues::GetWidth() const { - return m_height; + return m_width; } diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp index 5788e1f8b..3648fed82 100644 --- a/src/ShaderNode/ShaderGraph.cpp +++ b/src/ShaderNode/ShaderGraph.cpp @@ -46,9 +46,23 @@ m_flowScene(BuildRegistry()) }); // Test - AddInput("UV", InOutType::Float2, InputRole::TexCoord, 0, 0); - AddOutput("RenderTarget0", InOutType::Float4, 0); + AddInput("UV", PrimitiveType::Float2, InputRole::TexCoord, 0, 0); + AddOutput("RenderTarget0", PrimitiveType::Float4, 0); AddTexture("Potato", TextureType::Sampler2D, 1); + AddStruct("TestStruct", { + { + { "position", PrimitiveType::Float3 }, + { "normal", PrimitiveType::Float3 }, + { "uv", PrimitiveType::Float2 }, + } + }); + AddStruct("TestStruct2", { + { + { "position", PrimitiveType::Float3 }, + { "normal", PrimitiveType::Float3 }, + { "uv", PrimitiveType::Float2 }, + } + }); UpdateTexturePreview(0, QImage(R"(C:\Users\Lynix\Pictures\potatavril.png)")); @@ -79,7 +93,21 @@ ShaderGraph::~ShaderGraph() m_flowScene.clearScene(); } -std::size_t ShaderGraph::AddInput(std::string name, InOutType type, InputRole role, std::size_t roleIndex, std::size_t locationIndex) +std::size_t ShaderGraph::AddBuffer(std::string name, BufferType bufferType, std::size_t structIndex, std::size_t bindingIndex) +{ + std::size_t index = m_buffers.size(); + auto& bufferEntry = m_buffers.emplace_back(); + bufferEntry.bindingIndex = bindingIndex; + bufferEntry.name = std::move(name); + bufferEntry.structIndex = structIndex; + bufferEntry.type = bufferType; + + OnBufferListUpdate(this); + + return index; +} + +std::size_t ShaderGraph::AddInput(std::string name, PrimitiveType type, InputRole role, std::size_t roleIndex, std::size_t locationIndex) { std::size_t index = m_inputs.size(); auto& inputEntry = m_inputs.emplace_back(); @@ -94,7 +122,7 @@ std::size_t ShaderGraph::AddInput(std::string name, InOutType type, InputRole ro return index; } -std::size_t ShaderGraph::AddOutput(std::string name, InOutType type, std::size_t locationIndex) +std::size_t ShaderGraph::AddOutput(std::string name, PrimitiveType type, std::size_t locationIndex) { std::size_t index = m_outputs.size(); auto& outputEntry = m_outputs.emplace_back(); @@ -107,6 +135,18 @@ std::size_t ShaderGraph::AddOutput(std::string name, InOutType type, std::size_t return index; } +std::size_t ShaderGraph::AddStruct(std::string name, std::vector members) +{ + std::size_t index = m_structs.size(); + auto& structEntry = m_structs.emplace_back(); + structEntry.name = std::move(name); + structEntry.members = std::move(members); + + OnStructListUpdate(this); + + return index; +} + std::size_t ShaderGraph::AddTexture(std::string name, TextureType type, std::size_t bindingIndex) { std::size_t index = m_textures.size(); @@ -125,11 +165,15 @@ void ShaderGraph::Clear() m_flowScene.clearScene(); m_flowScene.clear(); + m_buffers.clear(); m_inputs.clear(); + m_structs.clear(); m_outputs.clear(); m_textures.clear(); + OnBufferListUpdate(this); OnInputListUpdate(this); + OnStructListUpdate(this); OnOutputListUpdate(this); OnTextureListUpdate(this); } @@ -138,6 +182,20 @@ void ShaderGraph::Load(const QJsonObject& data) { Clear(); + QJsonArray bufferArray = data["buffers"].toArray(); + for (const auto& bufferDocRef : bufferArray) + { + QJsonObject bufferDoc = bufferDocRef.toObject(); + + BufferEntry& buffer = m_buffers.emplace_back(); + buffer.bindingIndex = static_cast(bufferDoc["bindingIndex"].toInt(0)); + buffer.name = bufferDoc["name"].toString().toStdString(); + buffer.structIndex = bufferDoc["structIndex"].toInt(); + buffer.type = DecodeEnum(bufferDoc["type"].toString().toStdString()).value(); + } + + OnBufferListUpdate(this); + QJsonArray inputArray = data["inputs"].toArray(); for (const auto& inputDocRef : inputArray) { @@ -148,7 +206,7 @@ void ShaderGraph::Load(const QJsonObject& data) input.name = inputDoc["name"].toString().toStdString(); input.role = DecodeEnum(inputDoc["role"].toString().toStdString()).value(); input.roleIndex = static_cast(inputDoc["roleIndex"].toInt(0)); - input.type = DecodeEnum(inputDoc["type"].toString().toStdString()).value(); + input.type = DecodeEnum(inputDoc["type"].toString().toStdString()).value(); } OnInputListUpdate(this); @@ -161,11 +219,37 @@ void ShaderGraph::Load(const QJsonObject& data) OutputEntry& output = m_outputs.emplace_back(); output.locationIndex = static_cast(outputDoc["locationIndex"].toInt(0)); output.name = outputDoc["name"].toString().toStdString(); - output.type = DecodeEnum(outputDoc["type"].toString().toStdString()).value(); + output.type = DecodeEnum(outputDoc["type"].toString().toStdString()).value(); } OnOutputListUpdate(this); + QJsonArray structArray = data["structs"].toArray(); + for (const auto& structDocRef : structArray) + { + QJsonObject structDoc = structDocRef.toObject(); + + StructEntry& structInfo = m_structs.emplace_back(); + structInfo.name = structDoc["name"].toString().toStdString(); + + QJsonArray memberArray = structDoc["members"].toArray(); + for (const auto& memberDocRef : memberArray) + { + QJsonObject memberDoc = memberDocRef.toObject(); + + auto& memberInfo = structInfo.members.emplace_back(); + memberInfo.name = memberDoc["name"].toString().toStdString(); + + const auto& typeDocRef = memberDoc["type"]; + if (typeDocRef.isString()) + memberInfo.type = DecodeEnum(typeDocRef.toString().toStdString()).value(); + else + memberInfo.type = typeDocRef.toInt(); + } + } + + OnStructListUpdate(this); + QJsonArray textureArray = data["textures"].toArray(); for (const auto& textureDocRef : textureArray) { @@ -190,6 +274,21 @@ QJsonObject ShaderGraph::Save() { QJsonObject sceneJson; + QJsonArray bufferArray; + { + for (const auto& buffer : m_buffers) + { + QJsonObject bufferDoc; + bufferDoc["bindingIndex"] = int(buffer.bindingIndex); + bufferDoc["name"] = QString::fromStdString(buffer.name); + bufferDoc["structIndex"] = int(buffer.structIndex); + bufferDoc["type"] = QString(EnumToString(buffer.type)); + + bufferArray.append(bufferDoc); + } + } + sceneJson["buffers"] = bufferArray; + QJsonArray inputArray; { for (const auto& input : m_inputs) @@ -220,6 +319,39 @@ QJsonObject ShaderGraph::Save() } sceneJson["outputs"] = outputArray; + QJsonArray structArray; + { + for (const auto& s : m_structs) + { + QJsonObject structDoc; + structDoc["name"] = QString::fromStdString(s.name); + + QJsonArray memberArray; + for (const auto& member : s.members) + { + QJsonObject memberDoc; + memberDoc["name"] = QString::fromStdString(member.name); + + std::visit([&](auto&& arg) + { + using T = std::decay_t; + if constexpr (std::is_same_v) + memberDoc["type"] = QString(EnumToString(arg)); + else if constexpr (std::is_same_v) + memberDoc["type"] = int(arg); + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + }, member.type); + + memberDoc["type"] = QString::fromStdString(member.name); + } + structDoc["members"] = memberArray; + + structArray.append(structDoc); + } + } + sceneJson["structs"] = structArray; + QJsonArray textureArray; { for (const auto& texture : m_textures) @@ -366,7 +498,19 @@ Nz::ShaderNodes::StatementPtr ShaderGraph::ToAst() return Nz::ShaderNodes::StatementBlock::Build(std::move(statements)); } -void ShaderGraph::UpdateInput(std::size_t inputIndex, std::string name, InOutType type, InputRole role, std::size_t roleIndex, std::size_t locationIndex) +void ShaderGraph::UpdateBuffer(std::size_t bufferIndex, std::string name, BufferType bufferType, std::size_t structIndex, std::size_t bindingIndex) +{ + assert(bufferIndex < m_buffers.size()); + auto& bufferEntry = m_buffers[bufferIndex]; + bufferEntry.bindingIndex = bindingIndex; + bufferEntry.name = std::move(name); + bufferEntry.structIndex = structIndex; + bufferEntry.type = bufferType; + + OnBufferUpdate(this, bufferIndex); +} + +void ShaderGraph::UpdateInput(std::size_t inputIndex, std::string name, PrimitiveType type, InputRole role, std::size_t roleIndex, std::size_t locationIndex) { assert(inputIndex < m_inputs.size()); auto& inputEntry = m_inputs[inputIndex]; @@ -379,7 +523,7 @@ void ShaderGraph::UpdateInput(std::size_t inputIndex, std::string name, InOutTyp OnInputUpdate(this, inputIndex); } -void ShaderGraph::UpdateOutput(std::size_t outputIndex, std::string name, InOutType type, std::size_t locationIndex) +void ShaderGraph::UpdateOutput(std::size_t outputIndex, std::string name, PrimitiveType type, std::size_t locationIndex) { assert(outputIndex < m_outputs.size()); auto& outputEntry = m_outputs[outputIndex]; @@ -390,6 +534,16 @@ void ShaderGraph::UpdateOutput(std::size_t outputIndex, std::string name, InOutT OnOutputUpdate(this, outputIndex); } +void ShaderGraph::UpdateStruct(std::size_t structIndex, std::string name, std::vector members) +{ + assert(structIndex < m_structs.size()); + auto& structEntry = m_structs[structIndex]; + structEntry.name = std::move(name); + structEntry.members = std::move(members); + + OnStructUpdate(this, structIndex); +} + void ShaderGraph::UpdateTexture(std::size_t textureIndex, std::string name, TextureType type, std::size_t bindingIndex) { assert(textureIndex < m_textures.size()); diff --git a/src/ShaderNode/ShaderGraph.hpp b/src/ShaderNode/ShaderGraph.hpp index b65694f65..d0ff63316 100644 --- a/src/ShaderNode/ShaderGraph.hpp +++ b/src/ShaderNode/ShaderGraph.hpp @@ -16,25 +16,36 @@ class ShaderNode; class ShaderGraph { public: + struct BufferEntry; struct InputEntry; struct OutputEntry; + struct StructEntry; + struct StructMemberEntry; struct TextureEntry; ShaderGraph(); ~ShaderGraph(); - std::size_t AddInput(std::string name, InOutType type, InputRole role, std::size_t roleIndex, std::size_t locationIndex); - std::size_t AddOutput(std::string name, InOutType type, std::size_t locationIndex); + std::size_t AddBuffer(std::string name, BufferType bufferType, std::size_t structIndex, std::size_t bindingIndex); + std::size_t AddInput(std::string name, PrimitiveType type, InputRole role, std::size_t roleIndex, std::size_t locationIndex); + std::size_t AddOutput(std::string name, PrimitiveType type, std::size_t locationIndex); + std::size_t AddStruct(std::string name, std::vector members); std::size_t AddTexture(std::string name, TextureType type, std::size_t bindingIndex); void Clear(); - inline const InputEntry& GetInput(std::size_t inputIndex) const; + inline const BufferEntry& GetBuffer(std::size_t bufferIndex) const; + inline std::size_t GetBufferCount() const; + inline const std::vector& GetBuffers() const; + inline const InputEntry& GetInput(std::size_t bufferIndex) const; inline std::size_t GetInputCount() const; inline const std::vector& GetInputs() const; inline const OutputEntry& GetOutput(std::size_t outputIndex) const; inline std::size_t GetOutputCount() const; inline const std::vector& GetOutputs() const; + inline const StructEntry& GetStruct(std::size_t structIndex) const; + inline std::size_t GetStructCount() const; + inline const std::vector& GetStructs() const; inline const PreviewModel& GetPreviewModel() const; inline QtNodes::FlowScene& GetScene(); inline const TextureEntry& GetTexture(std::size_t textureIndex) const; @@ -46,25 +57,47 @@ class ShaderGraph Nz::ShaderNodes::StatementPtr ToAst(); - void UpdateInput(std::size_t inputIndex, std::string name, InOutType type, InputRole role, std::size_t roleIndex, std::size_t locationIndex); - void UpdateOutput(std::size_t outputIndex, std::string name, InOutType type, std::size_t locationIndex); + void UpdateBuffer(std::size_t bufferIndex, std::string name, BufferType bufferType, std::size_t structIndex, std::size_t bindingIndex); + void UpdateInput(std::size_t inputIndex, std::string name, PrimitiveType type, InputRole role, std::size_t roleIndex, std::size_t locationIndex); + void UpdateOutput(std::size_t outputIndex, std::string name, PrimitiveType type, std::size_t locationIndex); + void UpdateStruct(std::size_t structIndex, std::string name, std::vector members); void UpdateTexture(std::size_t textureIndex, std::string name, TextureType type, std::size_t bindingIndex); void UpdateTexturePreview(std::size_t texture, QImage preview); + struct BufferEntry + { + std::size_t bindingIndex; + std::size_t structIndex; + std::string name; + BufferType type; + }; + struct InputEntry { std::size_t locationIndex; std::size_t roleIndex; std::string name; InputRole role; - InOutType type; + PrimitiveType type; }; struct OutputEntry { std::size_t locationIndex; std::string name; - InOutType type; + PrimitiveType type; + }; + + struct StructEntry + { + std::string name; + std::vector members; + }; + + struct StructMemberEntry + { + std::string name; + std::variant type; }; struct TextureEntry @@ -75,11 +108,15 @@ class ShaderGraph QImage preview; }; + NazaraSignal(OnBufferListUpdate, ShaderGraph*); + NazaraSignal(OnBufferUpdate, ShaderGraph*, std::size_t /*outputIndex*/); NazaraSignal(OnInputListUpdate, ShaderGraph*); NazaraSignal(OnInputUpdate, ShaderGraph*, std::size_t /*inputIndex*/); NazaraSignal(OnOutputListUpdate, ShaderGraph*); NazaraSignal(OnOutputUpdate, ShaderGraph*, std::size_t /*outputIndex*/); NazaraSignal(OnSelectedNodeUpdate, ShaderGraph*, ShaderNode* /*node*/); + NazaraSignal(OnStructListUpdate, ShaderGraph*); + NazaraSignal(OnStructUpdate, ShaderGraph*, std::size_t /*structIndex*/); NazaraSignal(OnTextureListUpdate, ShaderGraph*); NazaraSignal(OnTexturePreviewUpdate, ShaderGraph*, std::size_t /*textureIndex*/); NazaraSignal(OnTextureUpdate, ShaderGraph*, std::size_t /*textureIndex*/); @@ -88,8 +125,10 @@ class ShaderGraph std::shared_ptr BuildRegistry(); QtNodes::FlowScene m_flowScene; + std::vector m_buffers; std::vector m_inputs; std::vector m_outputs; + std::vector m_structs; std::vector m_textures; std::unique_ptr m_previewModel; }; diff --git a/src/ShaderNode/ShaderGraph.inl b/src/ShaderNode/ShaderGraph.inl index 3f839534c..04f86834c 100644 --- a/src/ShaderNode/ShaderGraph.inl +++ b/src/ShaderNode/ShaderGraph.inl @@ -1,5 +1,21 @@ #include +inline auto ShaderGraph::GetBuffer(std::size_t bufferIndex) const -> const BufferEntry& +{ + assert(bufferIndex < m_buffers.size()); + return m_buffers[bufferIndex]; +} + +inline std::size_t ShaderGraph::GetBufferCount() const +{ + return m_buffers.size(); +} + +inline auto ShaderGraph::GetBuffers() const -> const std::vector& +{ + return m_buffers; +} + inline auto ShaderGraph::GetInput(std::size_t inputIndex) const -> const InputEntry& { assert(inputIndex < m_inputs.size()); @@ -32,6 +48,22 @@ inline auto ShaderGraph::GetOutputs() const -> const std::vector& return m_outputs; } +inline auto ShaderGraph::GetStruct(std::size_t structIndex) const -> const StructEntry& +{ + assert(structIndex < m_structs.size()); + return m_structs[structIndex]; +} + +inline std::size_t ShaderGraph::GetStructCount() const +{ + return m_structs.size(); +} + +inline auto ShaderGraph::GetStructs() const -> const std::vector& +{ + return m_structs; +} + inline const PreviewModel& ShaderGraph::GetPreviewModel() const { return *m_previewModel; diff --git a/src/ShaderNode/Widgets/BufferEditDialog.cpp b/src/ShaderNode/Widgets/BufferEditDialog.cpp new file mode 100644 index 000000000..3f08ca2fa --- /dev/null +++ b/src/ShaderNode/Widgets/BufferEditDialog.cpp @@ -0,0 +1,88 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +BufferEditDialog::BufferEditDialog(const ShaderGraph& shaderGraph, QWidget* parent) : +QDialog(parent), +m_shaderGraph(shaderGraph) +{ + setWindowTitle(tr("Buffer edit dialog")); + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + + m_outputName = new QLineEdit; + + m_typeList = new QComboBox; + for (std::size_t i = 0; i < BufferTypeCount; ++i) + m_typeList->addItem(EnumToString(static_cast(i))); + + m_structList = new QComboBox; + for (const auto& structEntry : m_shaderGraph.GetStructs()) + m_structList->addItem(QString::fromStdString(structEntry.name)); + + m_bindingIndex = new QSpinBox; + + QFormLayout* formLayout = new QFormLayout; + formLayout->addRow(tr("Name"), m_outputName); + formLayout->addRow(tr("Type"), m_typeList); + formLayout->addRow(tr("Struct"), m_structList); + formLayout->addRow(tr("Binding index"), m_bindingIndex); + + QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + connect(buttonBox, &QDialogButtonBox::accepted, this, &BufferEditDialog::OnAccept); + connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + + QVBoxLayout* verticalLayout = new QVBoxLayout; + verticalLayout->addLayout(formLayout); + verticalLayout->addWidget(buttonBox); + + setLayout(verticalLayout); +} + +BufferEditDialog::BufferEditDialog(const ShaderGraph& shaderGraph, const BufferInfo& buffer, QWidget* parent) : +BufferEditDialog(shaderGraph, parent) +{ + m_bindingIndex->setValue(int(buffer.bindingIndex)); + m_outputName->setText(QString::fromStdString(buffer.name)); + m_structList->setCurrentIndex(buffer.structIndex); + m_typeList->setCurrentIndex(int(buffer.type)); +} + +BufferInfo BufferEditDialog::GetBufferInfo() const +{ + BufferInfo bufferInfo; + bufferInfo.bindingIndex = static_cast(m_bindingIndex->value()); + bufferInfo.name = m_outputName->text().toStdString(); + bufferInfo.structIndex = m_structList->currentIndex(); + bufferInfo.type = static_cast(m_typeList->currentIndex()); + + return bufferInfo; +} + +void BufferEditDialog::OnAccept() +{ + if (m_outputName->text().isEmpty()) + { + QMessageBox::critical(this, tr("Empty name"), tr("Buffer name must be set"), QMessageBox::Ok); + return; + } + + if (m_structList->currentIndex() < 0) + { + QMessageBox::critical(this, tr("Invalid struct"), tr("You must select a struct"), QMessageBox::Ok); + return; + } + + if (m_typeList->currentIndex() < 0) + { + QMessageBox::critical(this, tr("Invalid type"), tr("You must select a type"), QMessageBox::Ok); + return; + } + + accept(); +} diff --git a/src/ShaderNode/Widgets/BufferEditDialog.hpp b/src/ShaderNode/Widgets/BufferEditDialog.hpp new file mode 100644 index 000000000..3e5c12e51 --- /dev/null +++ b/src/ShaderNode/Widgets/BufferEditDialog.hpp @@ -0,0 +1,43 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_BUFFEREDITDIALOG_HPP +#define NAZARA_SHADERNODES_BUFFEREDITDIALOG_HPP + +#include +#include + +class QComboBox; +class QLineEdit; +class QSpinBox; +class ShaderGraph; + +struct BufferInfo +{ + std::size_t bindingIndex; + std::size_t structIndex; + std::string name; + BufferType type; +}; + +class BufferEditDialog : public QDialog +{ + public: + BufferEditDialog(const ShaderGraph& shaderGraph, QWidget* parent = nullptr); + BufferEditDialog(const ShaderGraph& shaderGraph, const BufferInfo& output, QWidget* parent = nullptr); + ~BufferEditDialog() = default; + + BufferInfo GetBufferInfo() const; + + private: + void OnAccept(); + + const ShaderGraph& m_shaderGraph; + QComboBox* m_typeList; + QComboBox* m_structList; + QLineEdit* m_outputName; + QSpinBox* m_bindingIndex; +}; + +#include + +#endif diff --git a/src/ShaderNode/Widgets/BufferEditDialog.inl b/src/ShaderNode/Widgets/BufferEditDialog.inl new file mode 100644 index 000000000..a0add384b --- /dev/null +++ b/src/ShaderNode/Widgets/BufferEditDialog.inl @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/Widgets/BufferEditor.cpp b/src/ShaderNode/Widgets/BufferEditor.cpp new file mode 100644 index 000000000..cd795ee09 --- /dev/null +++ b/src/ShaderNode/Widgets/BufferEditor.cpp @@ -0,0 +1,85 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +BufferEditor::BufferEditor(ShaderGraph& graph) : +m_shaderGraph(graph) +{ + m_bufferList = new QListWidget(this); + connect(m_bufferList, &QListWidget::itemDoubleClicked, [this](QListWidgetItem* item) + { + OnEditBuffer(m_bufferList->row(item)); + }); + + QPushButton* addBufferButton = new QPushButton(tr("Add buffer...")); + connect(addBufferButton, &QPushButton::released, this, &BufferEditor::OnAddBuffer); + + m_layout = new QVBoxLayout; + m_layout->addWidget(m_bufferList); + m_layout->addWidget(addBufferButton); + + setLayout(m_layout); + + m_onBufferListUpdateSlot.Connect(m_shaderGraph.OnBufferListUpdate, this, &BufferEditor::OnBufferListUpdate); + m_onBufferUpdateSlot.Connect(m_shaderGraph.OnBufferUpdate, this, &BufferEditor::OnBufferUpdate); + + RefreshBuffers(); +} + +void BufferEditor::OnAddBuffer() +{ + BufferEditDialog* dialog = new BufferEditDialog(m_shaderGraph, this); + dialog->setAttribute(Qt::WA_DeleteOnClose, true); + connect(dialog, &QDialog::accepted, [this, dialog] + { + BufferInfo bufferInfo = dialog->GetBufferInfo(); + m_shaderGraph.AddBuffer(std::move(bufferInfo.name), bufferInfo.type, bufferInfo.structIndex, bufferInfo.bindingIndex); + }); + + dialog->open(); +} + +void BufferEditor::OnEditBuffer(int inputIndex) +{ + const auto& buffer = m_shaderGraph.GetBuffer(inputIndex); + + BufferInfo info; + info.name = buffer.name; + info.structIndex = buffer.structIndex; + info.type = buffer.type; + + BufferEditDialog* dialog = new BufferEditDialog(m_shaderGraph, std::move(info), this); + dialog->setAttribute(Qt::WA_DeleteOnClose, true); + connect(dialog, &QDialog::accepted, [this, dialog, inputIndex] + { + BufferInfo bufferInfo = dialog->GetBufferInfo(); + m_shaderGraph.UpdateBuffer(inputIndex, std::move(bufferInfo.name), bufferInfo.type, bufferInfo.structIndex, bufferInfo.bindingIndex); + }); + + dialog->open(); +} + +void BufferEditor::OnBufferListUpdate(ShaderGraph* /*graph*/) +{ + RefreshBuffers(); +} + +void BufferEditor::OnBufferUpdate(ShaderGraph* /*graph*/, std::size_t bufferIndex) +{ + const auto& bufferEntry = m_shaderGraph.GetBuffer(bufferIndex); + m_bufferList->item(int(bufferIndex))->setText(QString::fromStdString(bufferEntry.name)); +} + +void BufferEditor::RefreshBuffers() +{ + m_bufferList->clear(); + m_bufferList->setCurrentRow(-1); + + for (const auto& bufferEntry : m_shaderGraph.GetBuffers()) + m_bufferList->addItem(QString::fromStdString(bufferEntry.name)); +} diff --git a/src/ShaderNode/Widgets/BufferEditor.hpp b/src/ShaderNode/Widgets/BufferEditor.hpp new file mode 100644 index 000000000..4d97d161b --- /dev/null +++ b/src/ShaderNode/Widgets/BufferEditor.hpp @@ -0,0 +1,36 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_BUFFEREDITOR_HPP +#define NAZARA_SHADERNODES_BUFFEREDITOR_HPP + +#include +#include + +class QLabel; +class QListWidget; +class QVBoxLayout; + +class BufferEditor : public QWidget +{ + public: + BufferEditor(ShaderGraph& graph); + ~BufferEditor() = default; + + private: + void OnAddBuffer(); + void OnEditBuffer(int inputIndex); + void OnBufferListUpdate(ShaderGraph* graph); + void OnBufferUpdate(ShaderGraph* graph, std::size_t inputIndex); + void RefreshBuffers(); + + NazaraSlot(ShaderGraph, OnBufferListUpdate, m_onBufferListUpdateSlot); + NazaraSlot(ShaderGraph, OnBufferUpdate, m_onBufferUpdateSlot); + + ShaderGraph& m_shaderGraph; + QListWidget* m_bufferList; + QVBoxLayout* m_layout; +}; + +#include + +#endif diff --git a/src/ShaderNode/Widgets/BufferEditor.inl b/src/ShaderNode/Widgets/BufferEditor.inl new file mode 100644 index 000000000..ef7b911cd --- /dev/null +++ b/src/ShaderNode/Widgets/BufferEditor.inl @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/Widgets/InputEditDialog.cpp b/src/ShaderNode/Widgets/InputEditDialog.cpp index bd56fd598..45ceed2c6 100644 --- a/src/ShaderNode/Widgets/InputEditDialog.cpp +++ b/src/ShaderNode/Widgets/InputEditDialog.cpp @@ -16,8 +16,8 @@ QDialog(parent) m_inputName = new QLineEdit; m_typeList = new QComboBox; - for (std::size_t i = 0; i < InOutTypeCount; ++i) - m_typeList->addItem(EnumToString(static_cast(i))); + for (std::size_t i = 0; i < PrimitiveTypeCount; ++i) + m_typeList->addItem(EnumToString(static_cast(i))); m_roleList = new QComboBox; for (std::size_t i = 0; i < InputRoleCount; ++i) @@ -62,7 +62,7 @@ InputInfo InputEditDialog::GetInputInfo() const inputInfo.name = m_inputName->text().toStdString(); inputInfo.role = static_cast(m_roleList->currentIndex()); inputInfo.roleIndex = static_cast(m_roleIndex->value()); - inputInfo.type = static_cast(m_typeList->currentIndex()); + inputInfo.type = static_cast(m_typeList->currentIndex()); return inputInfo; } diff --git a/src/ShaderNode/Widgets/InputEditDialog.hpp b/src/ShaderNode/Widgets/InputEditDialog.hpp index 0f6655088..edd7577bf 100644 --- a/src/ShaderNode/Widgets/InputEditDialog.hpp +++ b/src/ShaderNode/Widgets/InputEditDialog.hpp @@ -16,7 +16,7 @@ struct InputInfo std::size_t roleIndex; std::string name; InputRole role; - InOutType type; + PrimitiveType type; }; class InputEditDialog : public QDialog diff --git a/src/ShaderNode/Widgets/MainWindow.cpp b/src/ShaderNode/Widgets/MainWindow.cpp index e76946738..213d190cb 100644 --- a/src/ShaderNode/Widgets/MainWindow.cpp +++ b/src/ShaderNode/Widgets/MainWindow.cpp @@ -3,9 +3,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -63,6 +65,24 @@ m_shaderGraph(graph) addDockWidget(Qt::RightDockWidgetArea, nodeEditorDock); + // Buffer editor + BufferEditor* bufferEditor = new BufferEditor(m_shaderGraph); + + QDockWidget* bufferDock = new QDockWidget(tr("Buffers")); + bufferDock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable); + bufferDock->setWidget(bufferEditor); + + addDockWidget(Qt::RightDockWidgetArea, bufferDock); + + // Struct editor + StructEditor* structEditor = new StructEditor(m_shaderGraph); + + QDockWidget* structDock = new QDockWidget(tr("Structs")); + structDock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable); + structDock->setWidget(structEditor); + + addDockWidget(Qt::RightDockWidgetArea, structDock); + m_onSelectedNodeUpdate.Connect(m_shaderGraph.OnSelectedNodeUpdate, [&](ShaderGraph*, ShaderNode* node) { if (node) @@ -193,15 +213,15 @@ Nz::ShaderAst MainWindow::ToShader() Nz::ShaderNodes::StatementPtr shaderAst = m_shaderGraph.ToAst(); //TODO: Put in another function - auto GetExpressionFromInOut = [&](InOutType type) + auto GetExpressionFromInOut = [&](PrimitiveType type) { switch (type) { - case InOutType::Bool: return Nz::ShaderNodes::ExpressionType::Boolean; - case InOutType::Float1: return Nz::ShaderNodes::ExpressionType::Float1; - case InOutType::Float2: return Nz::ShaderNodes::ExpressionType::Float2; - case InOutType::Float3: return Nz::ShaderNodes::ExpressionType::Float3; - case InOutType::Float4: return Nz::ShaderNodes::ExpressionType::Float4; + case PrimitiveType::Bool: return Nz::ShaderNodes::ExpressionType::Boolean; + case PrimitiveType::Float1: return Nz::ShaderNodes::ExpressionType::Float1; + case PrimitiveType::Float2: return Nz::ShaderNodes::ExpressionType::Float2; + case PrimitiveType::Float3: return Nz::ShaderNodes::ExpressionType::Float3; + case PrimitiveType::Float4: return Nz::ShaderNodes::ExpressionType::Float4; } assert(false); @@ -226,8 +246,37 @@ Nz::ShaderAst MainWindow::ToShader() for (const auto& output : m_shaderGraph.GetOutputs()) shader.AddOutput(output.name, GetExpressionFromInOut(output.type), output.locationIndex); + for (const auto& buffer : m_shaderGraph.GetBuffers()) + { + const auto& structInfo = m_shaderGraph.GetStruct(buffer.structIndex); + shader.AddUniform(buffer.name, structInfo.name, buffer.bindingIndex, Nz::ShaderNodes::MemoryLayout::Std140); + } + for (const auto& uniform : m_shaderGraph.GetTextures()) - shader.AddUniform(uniform.name, GetExpressionFromTexture(uniform.type), uniform.bindingIndex); + shader.AddUniform(uniform.name, GetExpressionFromTexture(uniform.type), uniform.bindingIndex, {}); + + for (const auto& s : m_shaderGraph.GetStructs()) + { + std::vector members; + for (const auto& sMember : s.members) + { + auto& member = members.emplace_back(); + member.name = sMember.name; + + std::visit([&](auto&& arg) + { + using T = std::decay_t; + if constexpr (std::is_same_v) + member.type = GetExpressionFromInOut(arg); + else if constexpr (std::is_same_v) + member.type = m_shaderGraph.GetStruct(arg).name; + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + }, sMember.type); + } + + shader.AddStruct(s.name, std::move(members)); + } shader.AddFunction("main", shaderAst); diff --git a/src/ShaderNode/Widgets/OutputEditDialog.cpp b/src/ShaderNode/Widgets/OutputEditDialog.cpp index d2c83e58e..c6233e64c 100644 --- a/src/ShaderNode/Widgets/OutputEditDialog.cpp +++ b/src/ShaderNode/Widgets/OutputEditDialog.cpp @@ -16,8 +16,8 @@ QDialog(parent) m_outputName = new QLineEdit; m_typeList = new QComboBox; - for (std::size_t i = 0; i < InOutTypeCount; ++i) - m_typeList->addItem(EnumToString(static_cast(i))); + for (std::size_t i = 0; i < PrimitiveTypeCount; ++i) + m_typeList->addItem(EnumToString(static_cast(i))); m_locationIndex = new QSpinBox; @@ -50,7 +50,7 @@ OutputInfo OutputEditDialog::GetOutputInfo() const OutputInfo inputInfo; inputInfo.locationIndex = static_cast(m_locationIndex->value()); inputInfo.name = m_outputName->text().toStdString(); - inputInfo.type = static_cast(m_typeList->currentIndex()); + inputInfo.type = static_cast(m_typeList->currentIndex()); return inputInfo; } diff --git a/src/ShaderNode/Widgets/OutputEditDialog.hpp b/src/ShaderNode/Widgets/OutputEditDialog.hpp index 6a8cc68fb..5b045faff 100644 --- a/src/ShaderNode/Widgets/OutputEditDialog.hpp +++ b/src/ShaderNode/Widgets/OutputEditDialog.hpp @@ -14,7 +14,7 @@ struct OutputInfo { std::size_t locationIndex; std::string name; - InOutType type; + PrimitiveType type; }; class OutputEditDialog : public QDialog diff --git a/src/ShaderNode/Widgets/StructEditDialog.cpp b/src/ShaderNode/Widgets/StructEditDialog.cpp new file mode 100644 index 000000000..320ad586a --- /dev/null +++ b/src/ShaderNode/Widgets/StructEditDialog.cpp @@ -0,0 +1,224 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +StructEditDialog::StructEditDialog(ShaderGraph& graph, QWidget* parent) : +QDialog(parent), +m_shaderGraph(graph) +{ + setWindowTitle(tr("Struct edit dialog")); + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + + m_structName = new QLineEdit; + connect(m_structName, &QLineEdit::textEdited, [this](QString newText) + { + m_info.name = newText.toStdString(); + }); + + m_memberList = new QListWidget; + connect(m_memberList, &QListWidget::currentRowChanged, this, &StructEditDialog::OnMemberSelected); + connect(m_memberList, &QListWidget::itemDoubleClicked, [this](QListWidgetItem* item) + { + OnEditMember(m_memberList->row(item)); + }); + + m_memberMoveUpButton = new QPushButton(tr("Move up")); + m_memberMoveUpButton->setEnabled(false); + connect(m_memberMoveUpButton, &QPushButton::released, this, &StructEditDialog::OnMemberMoveUp); + + m_memberMoveDownButton = new QPushButton(tr("Move down")); + m_memberMoveDownButton->setEnabled(false); + connect(m_memberMoveDownButton, &QPushButton::released, this, &StructEditDialog::OnMemberMoveDown); + + m_deleteMemberButton = new QPushButton(tr("Delete member")); + m_deleteMemberButton->setEnabled(false); + connect(m_deleteMemberButton, &QPushButton::released, this, &StructEditDialog::OnDeleteMember); + + QPushButton* addMemberButton = new QPushButton(tr("Add member...")); + connect(addMemberButton, &QPushButton::released, this, &StructEditDialog::OnAddMember); + + QVBoxLayout* arrowLayout = new QVBoxLayout; + arrowLayout->addWidget(m_memberMoveUpButton); + arrowLayout->addWidget(m_memberMoveDownButton); + arrowLayout->addWidget(m_deleteMemberButton); + arrowLayout->addWidget(addMemberButton); + + QHBoxLayout* entityListLayout = new QHBoxLayout; + entityListLayout->addWidget(m_memberList); + entityListLayout->addLayout(arrowLayout); + + QFormLayout* formLayout = new QFormLayout; + formLayout->addRow(tr("Name"), m_structName); + formLayout->addRow(tr("Members"), entityListLayout); + + QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + connect(buttonBox, &QDialogButtonBox::accepted, this, &StructEditDialog::OnAccept); + connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + + QVBoxLayout* verticalLayout = new QVBoxLayout; + verticalLayout->addLayout(formLayout); + verticalLayout->addWidget(buttonBox); + + setLayout(verticalLayout); +} + +StructEditDialog::StructEditDialog(ShaderGraph& graph, const StructInfo& structInfo, QWidget* parent) : +StructEditDialog(graph, parent) +{ + m_info = structInfo; + + m_structName->setText(QString::fromStdString(m_info.name)); + UpdateMemberList(); +} + +const StructInfo& StructEditDialog::GetStructInfo() const +{ + return m_info; +} + +QString StructEditDialog::GetMemberName(const StructInfo::Member& member) +{ + QString name = QString::fromStdString(member.name) + " ("; + + std::visit([&](auto&& arg) + { + using T = std::decay_t; + if constexpr (std::is_same_v) + name += QString(EnumToString(arg)); + else if constexpr (std::is_same_v) + name += QString::fromStdString(m_shaderGraph.GetStruct(arg).name); + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + }, + member.type); + + name += ")"; + + return name; +} + +void StructEditDialog::OnAccept() +{ + if (m_info.name.empty()) + { + QMessageBox::critical(this, tr("Empty name"), tr("Struct name must be set"), QMessageBox::Ok); + return; + } + + accept(); +} + +void StructEditDialog::OnAddMember() +{ + StructMemberEditDialog* dialog = new StructMemberEditDialog(m_shaderGraph, this); + dialog->setAttribute(Qt::WA_DeleteOnClose, true); + connect(dialog, &QDialog::accepted, [this, dialog] + { + const StructMemberInfo& structInfo = dialog->GetMemberInfo(); + + auto& memberInfo = m_info.members.emplace_back(); + memberInfo.name = structInfo.name; + memberInfo.type = structInfo.type; + + UpdateMemberList(true); + }); + + dialog->open(); +} + +void StructEditDialog::OnDeleteMember() +{ + int memberIndex = m_memberList->currentRow(); + if (memberIndex < 0) + return; + + m_info.members.erase(m_info.members.begin() + memberIndex); + UpdateMemberList(); +} + +void StructEditDialog::OnEditMember(int memberIndex) +{ + assert(memberIndex >= 0); + + auto& memberInfo = m_info.members[memberIndex]; + + StructMemberInfo info; + info.name = memberInfo.name; + info.type = memberInfo.type; + + StructMemberEditDialog* dialog = new StructMemberEditDialog(m_shaderGraph, std::move(info), this); + dialog->setAttribute(Qt::WA_DeleteOnClose, true); + connect(dialog, &QDialog::accepted, [this, dialog, &memberInfo] + { + const StructMemberInfo& structInfo = dialog->GetMemberInfo(); + memberInfo.name = structInfo.name; + memberInfo.type = structInfo.type; + + UpdateMemberList(true); + }); + + dialog->open(); +} + +void StructEditDialog::OnMemberMoveUp() +{ + int memberIndex = m_memberList->currentRow(); + if (memberIndex <= 0) + return; + + std::size_t newMemberIndex = static_cast(memberIndex - 1); + std::swap(m_info.members[memberIndex], m_info.members[newMemberIndex]); + UpdateMemberList(); + + m_memberList->setCurrentRow(int(newMemberIndex)); +} + +void StructEditDialog::OnMemberMoveDown() +{ + int memberIndex = m_memberList->currentRow(); + if (memberIndex < 0 || memberIndex + 1 >= m_memberList->count()) + return; + + std::size_t newMemberIndex = static_cast(memberIndex + 1); + std::swap(m_info.members[memberIndex], m_info.members[newMemberIndex]); + UpdateMemberList(); + + m_memberList->setCurrentRow(int(newMemberIndex)); +} + +void StructEditDialog::OnMemberSelected(int memberIndex) +{ + if (memberIndex >= 0) + { + m_deleteMemberButton->setEnabled(true); + m_memberMoveDownButton->setEnabled(memberIndex + 1 < m_memberList->count()); + m_memberMoveUpButton->setEnabled(memberIndex != 0); + } + else + { + m_deleteMemberButton->setEnabled(false); + m_memberMoveDownButton->setEnabled(false); + m_memberMoveUpButton->setEnabled(false); + } +} + +void StructEditDialog::UpdateMemberList(bool keepSelection) +{ + int selectionIndex = m_memberList->currentRow(); + + m_memberList->clear(); + for (const auto& memberInfo : m_info.members) + m_memberList->addItem(GetMemberName(memberInfo)); + + if (keepSelection && selectionIndex >= 0 && selectionIndex < m_memberList->count()) + m_memberList->setCurrentRow(selectionIndex); +} diff --git a/src/ShaderNode/Widgets/StructEditDialog.hpp b/src/ShaderNode/Widgets/StructEditDialog.hpp new file mode 100644 index 000000000..992aacddb --- /dev/null +++ b/src/ShaderNode/Widgets/StructEditDialog.hpp @@ -0,0 +1,59 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_STRUCTEDITDIALOG_HPP +#define NAZARA_SHADERNODES_STRUCTEDITDIALOG_HPP + +#include +#include +#include +#include + +class QLineEdit; +class QListWidget; +class QPushButton; +class ShaderGraph; + +struct StructInfo +{ + struct Member + { + std::string name; + std::variant type; + }; + + std::string name; + std::vector members; +}; + +class StructEditDialog : public QDialog +{ + public: + StructEditDialog(ShaderGraph& graph, QWidget* parent = nullptr); + StructEditDialog(ShaderGraph& graph, const StructInfo& output, QWidget* parent = nullptr); + ~StructEditDialog() = default; + + const StructInfo& GetStructInfo() const; + + private: + QString GetMemberName(const StructInfo::Member& member); + void OnAccept(); + void OnAddMember(); + void OnDeleteMember(); + void OnEditMember(int memberIndex); + void OnMemberMoveUp(); + void OnMemberMoveDown(); + void OnMemberSelected(int memberIndex); + void UpdateMemberList(bool keepSelection = false); + + QLineEdit* m_structName; + QListWidget* m_memberList; + QPushButton* m_deleteMemberButton; + QPushButton* m_memberMoveUpButton; + QPushButton* m_memberMoveDownButton; + ShaderGraph& m_shaderGraph; + StructInfo m_info; +}; + +#include + +#endif diff --git a/src/ShaderNode/Widgets/StructEditDialog.inl b/src/ShaderNode/Widgets/StructEditDialog.inl new file mode 100644 index 000000000..474a6f20e --- /dev/null +++ b/src/ShaderNode/Widgets/StructEditDialog.inl @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/Widgets/StructEditor.cpp b/src/ShaderNode/Widgets/StructEditor.cpp new file mode 100644 index 000000000..a68e6106d --- /dev/null +++ b/src/ShaderNode/Widgets/StructEditor.cpp @@ -0,0 +1,107 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +StructEditor::StructEditor(ShaderGraph& graph) : +m_shaderGraph(graph) +{ + m_structList = new QListWidget(this); + connect(m_structList, &QListWidget::itemDoubleClicked, [this](QListWidgetItem* item) + { + OnEditStruct(m_structList->row(item)); + }); + + QPushButton* addStructButton = new QPushButton(tr("Add struct...")); + connect(addStructButton, &QPushButton::released, this, &StructEditor::OnAddStruct); + + m_layout = new QVBoxLayout; + m_layout->addWidget(m_structList); + m_layout->addWidget(addStructButton); + + setLayout(m_layout); + + m_onStructListUpdateSlot.Connect(m_shaderGraph.OnStructListUpdate, this, &StructEditor::OnStructListUpdate); + m_onStructUpdateSlot.Connect(m_shaderGraph.OnStructUpdate, this, &StructEditor::OnStructUpdate); + + RefreshStructs(); +} + +void StructEditor::OnAddStruct() +{ + StructEditDialog* dialog = new StructEditDialog(m_shaderGraph, this); + dialog->setAttribute(Qt::WA_DeleteOnClose, true); + connect(dialog, &QDialog::accepted, [this, dialog] + { + const StructInfo& structInfo = dialog->GetStructInfo(); + + std::vector members; + for (const auto& memberInfo : structInfo.members) + { + auto& member = members.emplace_back(); + member.name = memberInfo.name; + member.type = memberInfo.type; + } + + m_shaderGraph.AddStruct(std::move(structInfo.name), std::move(members)); + }); + + dialog->open(); +} + +void StructEditor::OnEditStruct(int inputIndex) +{ + const auto& structInfo = m_shaderGraph.GetStruct(inputIndex); + + StructInfo info; + info.name = structInfo.name; + for (const auto& memberInfo : structInfo.members) + { + auto& member = info.members.emplace_back(); + member.name = memberInfo.name; + member.type = memberInfo.type; + } + + StructEditDialog* dialog = new StructEditDialog(m_shaderGraph, std::move(info), this); + dialog->setAttribute(Qt::WA_DeleteOnClose, true); + connect(dialog, &QDialog::accepted, [this, dialog, inputIndex] + { + const StructInfo& structInfo = dialog->GetStructInfo(); + + std::vector members; + for (const auto& memberInfo : structInfo.members) + { + auto& member = members.emplace_back(); + member.name = memberInfo.name; + member.type = memberInfo.type; + } + + m_shaderGraph.UpdateStruct(inputIndex, std::move(structInfo.name), std::move(members)); + }); + + dialog->open(); +} + +void StructEditor::OnStructListUpdate(ShaderGraph* /*graph*/) +{ + RefreshStructs(); +} + +void StructEditor::OnStructUpdate(ShaderGraph* /*graph*/, std::size_t structIndex) +{ + const auto& structEntry = m_shaderGraph.GetStruct(structIndex); + m_structList->item(int(structIndex))->setText(QString::fromStdString(structEntry.name)); +} + +void StructEditor::RefreshStructs() +{ + m_structList->clear(); + m_structList->setCurrentRow(-1); + + for (const auto& structEntry : m_shaderGraph.GetStructs()) + m_structList->addItem(QString::fromStdString(structEntry.name)); +} diff --git a/src/ShaderNode/Widgets/StructEditor.hpp b/src/ShaderNode/Widgets/StructEditor.hpp new file mode 100644 index 000000000..3e00fc5bb --- /dev/null +++ b/src/ShaderNode/Widgets/StructEditor.hpp @@ -0,0 +1,37 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_STRUCTEDITOR_HPP +#define NAZARA_SHADERNODES_STRUCTEDITOR_HPP + +#include +#include +#include + +class QLabel; +class QListWidget; +class QVBoxLayout; + +class StructEditor : public QWidget +{ + public: + StructEditor(ShaderGraph& graph); + ~StructEditor() = default; + + private: + void OnAddStruct(); + void OnEditStruct(int inputIndex); + void OnStructListUpdate(ShaderGraph* graph); + void OnStructUpdate(ShaderGraph* graph, std::size_t inputIndex); + void RefreshStructs(); + + NazaraSlot(ShaderGraph, OnStructListUpdate, m_onStructListUpdateSlot); + NazaraSlot(ShaderGraph, OnStructUpdate, m_onStructUpdateSlot); + + ShaderGraph& m_shaderGraph; + QListWidget* m_structList; + QVBoxLayout* m_layout; +}; + +#include + +#endif diff --git a/src/ShaderNode/Widgets/StructEditor.inl b/src/ShaderNode/Widgets/StructEditor.inl new file mode 100644 index 000000000..95ebbea7e --- /dev/null +++ b/src/ShaderNode/Widgets/StructEditor.inl @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/Widgets/StructMemberEditDialog.cpp b/src/ShaderNode/Widgets/StructMemberEditDialog.cpp new file mode 100644 index 000000000..82bc4e1a2 --- /dev/null +++ b/src/ShaderNode/Widgets/StructMemberEditDialog.cpp @@ -0,0 +1,86 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +StructMemberEditDialog::StructMemberEditDialog(const ShaderGraph& shaderGraph, QWidget* parent) : +QDialog(parent), +m_shaderGraph(shaderGraph) +{ + setWindowTitle(tr("Struct member edit dialog")); + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + + m_memberName = new QLineEdit; + + m_typeList = new QComboBox; + for (std::size_t i = 0; i < PrimitiveTypeCount; ++i) + m_typeList->addItem(EnumToString(static_cast(i))); + + for (const auto& structInfo : m_shaderGraph.GetStructs()) + m_typeList->addItem(QString::fromStdString(structInfo.name)); + + QFormLayout* formLayout = new QFormLayout; + formLayout->addRow(tr("Name"), m_memberName); + formLayout->addRow(tr("Type"), m_typeList); + + QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + connect(buttonBox, &QDialogButtonBox::accepted, this, &StructMemberEditDialog::OnAccept); + connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + + QVBoxLayout* verticalLayout = new QVBoxLayout; + verticalLayout->addLayout(formLayout); + verticalLayout->addWidget(buttonBox); + + setLayout(verticalLayout); +} + +StructMemberEditDialog::StructMemberEditDialog(const ShaderGraph& shaderGraph, const StructMemberInfo& member, QWidget* parent) : +StructMemberEditDialog(shaderGraph, parent) +{ + m_memberName->setText(QString::fromStdString(member.name)); + std::visit([&](auto&& arg) + { + using T = std::decay_t; + if constexpr (std::is_same_v) + m_typeList->setCurrentIndex(static_cast(arg)); + else if constexpr (std::is_same_v) + m_typeList->setCurrentIndex(static_cast(PrimitiveTypeCount + arg)); + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + }, + member.type); +} + +StructMemberInfo StructMemberEditDialog::GetMemberInfo() const +{ + StructMemberInfo inputInfo; + inputInfo.name = m_memberName->text().toStdString(); + + if (m_typeList->currentIndex() < PrimitiveTypeCount) + inputInfo.type = static_cast(m_typeList->currentIndex()); + else + inputInfo.type = static_cast(m_typeList->currentIndex() - PrimitiveTypeCount); + + return inputInfo; +} + +void StructMemberEditDialog::OnAccept() +{ + if (m_memberName->text().isEmpty()) + { + QMessageBox::critical(this, tr("Empty name"), tr("Struct member name must be set"), QMessageBox::Ok); + return; + } + + if (m_typeList->currentIndex() < 0) + { + QMessageBox::critical(this, tr("Invalid type"), tr("You must select a type"), QMessageBox::Ok); + return; + } + + accept(); +} diff --git a/src/ShaderNode/Widgets/StructMemberEditDialog.hpp b/src/ShaderNode/Widgets/StructMemberEditDialog.hpp new file mode 100644 index 000000000..e482766dc --- /dev/null +++ b/src/ShaderNode/Widgets/StructMemberEditDialog.hpp @@ -0,0 +1,39 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_OUTPUTEDITDIALOG_HPP +#define NAZARA_SHADERNODES_OUTPUTEDITDIALOG_HPP + +#include +#include +#include + +class QComboBox; +class QLineEdit; +class ShaderGraph; + +struct StructMemberInfo +{ + std::string name; + std::variant type; +}; + +class StructMemberEditDialog : public QDialog +{ + public: + StructMemberEditDialog(const ShaderGraph& shaderGraph, QWidget* parent = nullptr); + StructMemberEditDialog(const ShaderGraph& shaderGraph, const StructMemberInfo& output, QWidget* parent = nullptr); + ~StructMemberEditDialog() = default; + + StructMemberInfo GetMemberInfo() const; + + private: + void OnAccept(); + + const ShaderGraph& m_shaderGraph; + QComboBox* m_typeList; + QLineEdit* m_memberName; +}; + +#include + +#endif diff --git a/src/ShaderNode/Widgets/StructMemberEditDialog.inl b/src/ShaderNode/Widgets/StructMemberEditDialog.inl new file mode 100644 index 000000000..e663ea05a --- /dev/null +++ b/src/ShaderNode/Widgets/StructMemberEditDialog.inl @@ -0,0 +1 @@ +#include From 1d2fb88198a19dc4a6da03fee05c4332d11a9f07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Thu, 16 Jul 2020 18:34:58 +0200 Subject: [PATCH 261/316] Renderer: Rename enums ExpressionType => BasicType ShaderAst::Type => ShaderExpressionType --- include/Nazara/Renderer/GlslWriter.hpp | 4 +- include/Nazara/Renderer/GlslWriter.inl | 2 +- include/Nazara/Renderer/ShaderAst.hpp | 19 ++++---- include/Nazara/Renderer/ShaderBuilder.hpp | 2 +- include/Nazara/Renderer/ShaderBuilder.inl | 8 ++-- include/Nazara/Renderer/ShaderEnums.hpp | 26 +++++------ .../Nazara/Renderer/ShaderExpressionType.hpp | 20 +++++++++ include/Nazara/Renderer/ShaderNodes.hpp | 30 ++++++------- include/Nazara/Renderer/ShaderNodes.inl | 38 ++++++++-------- include/Nazara/Renderer/ShaderSerializer.hpp | 2 +- include/Nazara/Renderer/ShaderValidator.hpp | 2 +- include/Nazara/Renderer/ShaderVariables.hpp | 14 +++--- include/Nazara/Renderer/ShaderVariables.inl | 12 ++--- src/Nazara/OpenGLRenderer/Wrapper/Context.cpp | 2 + .../Wrapper/Win32/WGLContext.cpp | 7 +++ src/Nazara/Renderer/GlslWriter.cpp | 30 ++++++------- src/Nazara/Renderer/ShaderAst.cpp | 8 ++-- src/Nazara/Renderer/ShaderNodes.cpp | 32 +++++++------- src/Nazara/Renderer/ShaderSerializer.cpp | 26 +++++------ src/Nazara/Renderer/ShaderValidator.cpp | 44 +++++++++---------- src/ShaderNode/DataModels/InputValue.cpp | 14 +++--- src/ShaderNode/DataModels/OutputValue.cpp | 16 +++---- src/ShaderNode/DataModels/TextureValue.cpp | 4 +- src/ShaderNode/DataTypes/VecData.cpp | 8 ++-- src/ShaderNode/DataTypes/VecData.hpp | 12 ++--- src/ShaderNode/Widgets/MainWindow.cpp | 12 ++--- 26 files changed, 210 insertions(+), 184 deletions(-) create mode 100644 include/Nazara/Renderer/ShaderExpressionType.hpp diff --git a/include/Nazara/Renderer/GlslWriter.hpp b/include/Nazara/Renderer/GlslWriter.hpp index 999a93c48..94ca21676 100644 --- a/include/Nazara/Renderer/GlslWriter.hpp +++ b/include/Nazara/Renderer/GlslWriter.hpp @@ -44,9 +44,9 @@ namespace Nz }; private: - void Append(ShaderAst::Type type); + void Append(ShaderExpressionType type); void Append(ShaderNodes::BuiltinEntry builtin); - void Append(ShaderNodes::ExpressionType type); + void Append(ShaderNodes::BasicType type); void Append(ShaderNodes::MemoryLayout layout); template void Append(const T& param); void AppendCommentSection(const std::string& section); diff --git a/include/Nazara/Renderer/GlslWriter.inl b/include/Nazara/Renderer/GlslWriter.inl index 9b67eaa89..e543f870f 100644 --- a/include/Nazara/Renderer/GlslWriter.inl +++ b/include/Nazara/Renderer/GlslWriter.inl @@ -86,7 +86,7 @@ namespace Nz std::visit([&](auto&& arg) { using T = std::decay_t; - if constexpr (std::is_same_v) + if constexpr (std::is_same_v) { Append(arg); Append(" "); diff --git a/include/Nazara/Renderer/ShaderAst.hpp b/include/Nazara/Renderer/ShaderAst.hpp index 4b57bbced..035aa5cce 100644 --- a/include/Nazara/Renderer/ShaderAst.hpp +++ b/include/Nazara/Renderer/ShaderAst.hpp @@ -8,11 +8,10 @@ #define NAZARA_SHADER_AST_HPP #include +#include #include #include -#include #include -#include #include namespace Nz @@ -28,16 +27,14 @@ namespace Nz struct Uniform; struct VariableBase; - using Type = std::variant; - ShaderAst() = default; ~ShaderAst() = default; - void AddFunction(std::string name, ShaderNodes::StatementPtr statement, std::vector parameters = {}, ShaderNodes::ExpressionType returnType = ShaderNodes::ExpressionType::Void); - void AddInput(std::string name, Type type, std::optional locationIndex); - void AddOutput(std::string name, Type type, std::optional locationIndex); + void AddFunction(std::string name, ShaderNodes::StatementPtr statement, std::vector parameters = {}, ShaderNodes::BasicType returnType = ShaderNodes::BasicType::Void); + void AddInput(std::string name, ShaderExpressionType type, std::optional locationIndex); + void AddOutput(std::string name, ShaderExpressionType type, std::optional locationIndex); void AddStruct(std::string name, std::vector members); - void AddUniform(std::string name, Type type, std::optional bindingIndex, std::optional memoryLayout); + void AddUniform(std::string name, ShaderExpressionType type, std::optional bindingIndex, std::optional memoryLayout); inline const Function& GetFunction(std::size_t i) const; inline std::size_t GetFunctionCount() const; @@ -58,7 +55,7 @@ namespace Nz struct VariableBase { std::string name; - Type type; + ShaderExpressionType type; }; struct FunctionParameter : VariableBase @@ -69,7 +66,7 @@ namespace Nz { std::string name; std::vector parameters; - ShaderNodes::ExpressionType returnType; + ShaderNodes::BasicType returnType; ShaderNodes::StatementPtr statement; }; @@ -93,7 +90,7 @@ namespace Nz struct StructMember { std::string name; - Type type; + ShaderExpressionType type; }; private: diff --git a/include/Nazara/Renderer/ShaderBuilder.hpp b/include/Nazara/Renderer/ShaderBuilder.hpp index cc437f45f..7d8502151 100644 --- a/include/Nazara/Renderer/ShaderBuilder.hpp +++ b/include/Nazara/Renderer/ShaderBuilder.hpp @@ -67,7 +67,7 @@ namespace Nz::ShaderBuilder constexpr BinOpBuilder Substract; constexpr GenBuilder Uniform; - template std::shared_ptr Cast(Args&&... args); + template std::shared_ptr Cast(Args&&... args); } #include diff --git a/include/Nazara/Renderer/ShaderBuilder.inl b/include/Nazara/Renderer/ShaderBuilder.inl index dda1d730b..8ef833536 100644 --- a/include/Nazara/Renderer/ShaderBuilder.inl +++ b/include/Nazara/Renderer/ShaderBuilder.inl @@ -28,21 +28,21 @@ namespace Nz::ShaderBuilder inline std::shared_ptr BuiltinBuilder::operator()(ShaderNodes::BuiltinEntry builtin) const { - ShaderNodes::ExpressionType exprType = ShaderNodes::ExpressionType::Void; + ShaderNodes::BasicType exprType = ShaderNodes::BasicType::Void; switch (builtin) { case ShaderNodes::BuiltinEntry::VertexPosition: - exprType = ShaderNodes::ExpressionType::Float4; + exprType = ShaderNodes::BasicType::Float4; break; } - NazaraAssert(exprType != ShaderNodes::ExpressionType::Void, "Unhandled builtin"); + NazaraAssert(exprType != ShaderNodes::BasicType::Void, "Unhandled builtin"); return ShaderNodes::BuiltinVariable::Build(builtin, exprType); } - template + template std::shared_ptr Cast(Args&&... args) { return ShaderNodes::Cast::Build(Type, std::forward(args)...); diff --git a/include/Nazara/Renderer/ShaderEnums.hpp b/include/Nazara/Renderer/ShaderEnums.hpp index 7a93cea7b..a9db1abe8 100644 --- a/include/Nazara/Renderer/ShaderEnums.hpp +++ b/include/Nazara/Renderer/ShaderEnums.hpp @@ -16,6 +16,19 @@ namespace Nz::ShaderNodes Simple //< = }; + enum class BasicType + { + Boolean, // bool + Float1, // float + Float2, // vec2 + Float3, // vec3 + Float4, // vec4 + Mat4x4, // mat4 + Sampler2D, // sampler2D + + Void // void + }; + enum class BinaryType { Add, //< + @@ -37,19 +50,6 @@ namespace Nz::ShaderNodes RValue }; - enum class ExpressionType - { - Boolean, // bool - Float1, // float - Float2, // vec2 - Float3, // vec3 - Float4, // vec4 - Mat4x4, // mat4 - Sampler2D, // sampler2D - - Void // void - }; - enum class IntrinsicType { CrossProduct, diff --git a/include/Nazara/Renderer/ShaderExpressionType.hpp b/include/Nazara/Renderer/ShaderExpressionType.hpp new file mode 100644 index 000000000..c937d6a10 --- /dev/null +++ b/include/Nazara/Renderer/ShaderExpressionType.hpp @@ -0,0 +1,20 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_SHADER_EXPRESSIONTYPE_HPP +#define NAZARA_SHADER_EXPRESSIONTYPE_HPP + +#include +#include +#include +#include + +namespace Nz +{ + using ShaderExpressionType = std::variant; +} + +#endif // NAZARA_SHADER_EXPRESSIONTYPE_HPP diff --git a/include/Nazara/Renderer/ShaderNodes.hpp b/include/Nazara/Renderer/ShaderNodes.hpp index 659e643a3..57ff5ab60 100644 --- a/include/Nazara/Renderer/ShaderNodes.hpp +++ b/include/Nazara/Renderer/ShaderNodes.hpp @@ -38,8 +38,8 @@ namespace Nz virtual void Visit(ShaderVisitor& visitor) = 0; - static inline unsigned int GetComponentCount(ExpressionType type); - static inline ExpressionType GetComponentType(ExpressionType type); + static inline unsigned int GetComponentCount(BasicType type); + static inline BasicType GetComponentType(BasicType type); protected: inline Node(NodeType type, bool isStatement); @@ -59,7 +59,7 @@ namespace Nz inline Expression(NodeType type); virtual ExpressionCategory GetExpressionCategory() const; - virtual ExpressionType GetExpressionType() const = 0; + virtual BasicType GetExpressionType() const = 0; }; class Statement; @@ -125,7 +125,7 @@ namespace Nz inline Identifier(); ExpressionCategory GetExpressionCategory() const override; - ExpressionType GetExpressionType() const override; + BasicType GetExpressionType() const override; void Visit(ShaderVisitor& visitor) override; VariablePtr var; @@ -139,7 +139,7 @@ namespace Nz { inline AssignOp(); - ExpressionType GetExpressionType() const override; + BasicType GetExpressionType() const override; void Visit(ShaderVisitor& visitor) override; AssignType op; @@ -153,7 +153,7 @@ namespace Nz { inline BinaryOp(); - ExpressionType GetExpressionType() const override; + BasicType GetExpressionType() const override; void Visit(ShaderVisitor& visitor) override; BinaryType op; @@ -187,24 +187,24 @@ namespace Nz { inline Cast(); - ExpressionType GetExpressionType() const override; + BasicType GetExpressionType() const override; void Visit(ShaderVisitor& visitor) override; - ExpressionType exprType; + BasicType exprType; std::array expressions; - static inline std::shared_ptr Build(ExpressionType castTo, ExpressionPtr first, ExpressionPtr second = nullptr, ExpressionPtr third = nullptr, ExpressionPtr fourth = nullptr); - static inline std::shared_ptr Build(ExpressionType castTo, ExpressionPtr* expressions, std::size_t expressionCount); + static inline std::shared_ptr Build(BasicType castTo, ExpressionPtr first, ExpressionPtr second = nullptr, ExpressionPtr third = nullptr, ExpressionPtr fourth = nullptr); + static inline std::shared_ptr Build(BasicType castTo, ExpressionPtr* expressions, std::size_t expressionCount); }; struct NAZARA_RENDERER_API Constant : public Expression { inline Constant(); - ExpressionType GetExpressionType() const override; + BasicType GetExpressionType() const override; void Visit(ShaderVisitor& visitor) override; - ExpressionType exprType; + BasicType exprType; union { @@ -227,7 +227,7 @@ namespace Nz inline SwizzleOp(); ExpressionCategory GetExpressionCategory() const override; - ExpressionType GetExpressionType() const override; + BasicType GetExpressionType() const override; void Visit(ShaderVisitor& visitor) override; std::array components; @@ -243,7 +243,7 @@ namespace Nz { inline Sample2D(); - ExpressionType GetExpressionType() const override; + BasicType GetExpressionType() const override; void Visit(ShaderVisitor& visitor) override; ExpressionPtr sampler; @@ -258,7 +258,7 @@ namespace Nz { inline IntrinsicCall(); - ExpressionType GetExpressionType() const override; + BasicType GetExpressionType() const override; void Visit(ShaderVisitor& visitor) override; IntrinsicType intrinsic; diff --git a/include/Nazara/Renderer/ShaderNodes.inl b/include/Nazara/Renderer/ShaderNodes.inl index bafad38f5..31d3028ed 100644 --- a/include/Nazara/Renderer/ShaderNodes.inl +++ b/include/Nazara/Renderer/ShaderNodes.inl @@ -23,20 +23,20 @@ namespace Nz::ShaderNodes return m_isStatement; } - inline unsigned int Node::GetComponentCount(ExpressionType type) + inline unsigned int Node::GetComponentCount(BasicType type) { switch (type) { - case ExpressionType::Float2: + case BasicType::Float2: return 2; - case ExpressionType::Float3: + case BasicType::Float3: return 3; - case ExpressionType::Float4: + case BasicType::Float4: return 4; - case ExpressionType::Mat4x4: + case BasicType::Mat4x4: return 4; default: @@ -44,17 +44,17 @@ namespace Nz::ShaderNodes } } - inline ExpressionType Node::GetComponentType(ExpressionType type) + inline BasicType Node::GetComponentType(BasicType type) { switch (type) { - case ExpressionType::Float2: - case ExpressionType::Float3: - case ExpressionType::Float4: - return ExpressionType::Float1; + case BasicType::Float2: + case BasicType::Float3: + case BasicType::Float4: + return BasicType::Float1; - case ExpressionType::Mat4x4: - return ExpressionType::Float4; + case BasicType::Mat4x4: + return BasicType::Float4; default: return type; @@ -198,7 +198,7 @@ namespace Nz::ShaderNodes { } - inline std::shared_ptr Cast::Build(ExpressionType castTo, ExpressionPtr first, ExpressionPtr second, ExpressionPtr third, ExpressionPtr fourth) + inline std::shared_ptr Cast::Build(BasicType castTo, ExpressionPtr first, ExpressionPtr second, ExpressionPtr third, ExpressionPtr fourth) { auto node = std::make_shared(); node->exprType = castTo; @@ -207,7 +207,7 @@ namespace Nz::ShaderNodes return node; } - inline std::shared_ptr Cast::Build(ExpressionType castTo, ExpressionPtr* Expressions, std::size_t expressionCount) + inline std::shared_ptr Cast::Build(BasicType castTo, ExpressionPtr* Expressions, std::size_t expressionCount) { auto node = std::make_shared(); node->exprType = castTo; @@ -226,7 +226,7 @@ namespace Nz::ShaderNodes inline std::shared_ptr Constant::Build(bool value) { auto node = std::make_shared(); - node->exprType = ExpressionType::Boolean; + node->exprType = BasicType::Boolean; node->values.bool1 = value; return node; @@ -235,7 +235,7 @@ namespace Nz::ShaderNodes inline std::shared_ptr Constant::Build(float value) { auto node = std::make_shared(); - node->exprType = ExpressionType::Float1; + node->exprType = BasicType::Float1; node->values.vec1 = value; return node; @@ -244,7 +244,7 @@ namespace Nz::ShaderNodes inline std::shared_ptr Constant::Build(const Vector2f& value) { auto node = std::make_shared(); - node->exprType = ExpressionType::Float2; + node->exprType = BasicType::Float2; node->values.vec2 = value; return node; @@ -253,7 +253,7 @@ namespace Nz::ShaderNodes inline std::shared_ptr Constant::Build(const Vector3f& value) { auto node = std::make_shared(); - node->exprType = ExpressionType::Float3; + node->exprType = BasicType::Float3; node->values.vec3 = value; return node; @@ -262,7 +262,7 @@ namespace Nz::ShaderNodes inline std::shared_ptr Constant::Build(const Vector4f& value) { auto node = std::make_shared(); - node->exprType = ExpressionType::Float4; + node->exprType = BasicType::Float4; node->values.vec4 = value; return node; diff --git a/include/Nazara/Renderer/ShaderSerializer.hpp b/include/Nazara/Renderer/ShaderSerializer.hpp index f79040b2c..e4e6be7b3 100644 --- a/include/Nazara/Renderer/ShaderSerializer.hpp +++ b/include/Nazara/Renderer/ShaderSerializer.hpp @@ -103,7 +103,7 @@ namespace Nz private: bool IsWriting() const override; void Node(ShaderNodes::NodePtr& node) override; - void Type(ShaderAst::Type& type); + void Type(ShaderExpressionType& type); void Value(bool& val) override; void Value(float& val) override; void Value(std::string& val) override; diff --git a/include/Nazara/Renderer/ShaderValidator.hpp b/include/Nazara/Renderer/ShaderValidator.hpp index 3df9f4ae5..ecfea1290 100644 --- a/include/Nazara/Renderer/ShaderValidator.hpp +++ b/include/Nazara/Renderer/ShaderValidator.hpp @@ -30,7 +30,7 @@ namespace Nz const ShaderNodes::ExpressionPtr& MandatoryExpr(const ShaderNodes::ExpressionPtr& node); const ShaderNodes::NodePtr& MandatoryNode(const ShaderNodes::NodePtr& node); void TypeMustMatch(const ShaderNodes::ExpressionPtr& left, const ShaderNodes::ExpressionPtr& right); - void TypeMustMatch(const ShaderAst::Type& left, const ShaderAst::Type& right); + void TypeMustMatch(const ShaderExpressionType& left, const ShaderExpressionType& right); using ShaderVisitor::Visit; void Visit(const ShaderNodes::AssignOp& node) override; diff --git a/include/Nazara/Renderer/ShaderVariables.hpp b/include/Nazara/Renderer/ShaderVariables.hpp index 242f129db..f80386d0c 100644 --- a/include/Nazara/Renderer/ShaderVariables.hpp +++ b/include/Nazara/Renderer/ShaderVariables.hpp @@ -34,7 +34,7 @@ namespace Nz virtual VariableType GetType() const = 0; virtual void Visit(ShaderVarVisitor& visitor) = 0; - ExpressionType type; + BasicType type; }; struct BuiltinVariable; @@ -48,7 +48,7 @@ namespace Nz VariableType GetType() const override; void Visit(ShaderVarVisitor& visitor) override; - static inline std::shared_ptr Build(BuiltinEntry entry, ExpressionType varType); + static inline std::shared_ptr Build(BuiltinEntry entry, BasicType varType); }; struct NamedVariable; @@ -69,7 +69,7 @@ namespace Nz VariableType GetType() const override; void Visit(ShaderVarVisitor& visitor) override; - static inline std::shared_ptr Build(std::string varName, ExpressionType varType); + static inline std::shared_ptr Build(std::string varName, BasicType varType); }; struct LocalVariable; @@ -81,7 +81,7 @@ namespace Nz VariableType GetType() const override; void Visit(ShaderVarVisitor& visitor) override; - static inline std::shared_ptr Build(std::string varName, ExpressionType varType); + static inline std::shared_ptr Build(std::string varName, BasicType varType); }; struct OutputVariable; @@ -93,7 +93,7 @@ namespace Nz VariableType GetType() const override; void Visit(ShaderVarVisitor& visitor) override; - static inline std::shared_ptr Build(std::string varName, ExpressionType varType); + static inline std::shared_ptr Build(std::string varName, BasicType varType); }; struct ParameterVariable; @@ -105,7 +105,7 @@ namespace Nz VariableType GetType() const override; void Visit(ShaderVarVisitor& visitor) override; - static inline std::shared_ptr Build(std::string varName, ExpressionType varType); + static inline std::shared_ptr Build(std::string varName, BasicType varType); }; struct UniformVariable; @@ -117,7 +117,7 @@ namespace Nz VariableType GetType() const override; void Visit(ShaderVarVisitor& visitor) override; - static inline std::shared_ptr Build(std::string varName, ExpressionType varType); + static inline std::shared_ptr Build(std::string varName, BasicType varType); }; } } diff --git a/include/Nazara/Renderer/ShaderVariables.inl b/include/Nazara/Renderer/ShaderVariables.inl index d20c9d6ea..e01ecb33e 100644 --- a/include/Nazara/Renderer/ShaderVariables.inl +++ b/include/Nazara/Renderer/ShaderVariables.inl @@ -7,7 +7,7 @@ namespace Nz::ShaderNodes { - inline std::shared_ptr BuiltinVariable::Build(BuiltinEntry variable, ExpressionType varType) + inline std::shared_ptr BuiltinVariable::Build(BuiltinEntry variable, BasicType varType) { auto node = std::make_shared(); node->entry = variable; @@ -16,7 +16,7 @@ namespace Nz::ShaderNodes return node; } - inline std::shared_ptr InputVariable::Build(std::string varName, ExpressionType varType) + inline std::shared_ptr InputVariable::Build(std::string varName, BasicType varType) { auto node = std::make_shared(); node->name = std::move(varName); @@ -25,7 +25,7 @@ namespace Nz::ShaderNodes return node; } - inline std::shared_ptr LocalVariable::Build(std::string varName, ExpressionType varType) + inline std::shared_ptr LocalVariable::Build(std::string varName, BasicType varType) { auto node = std::make_shared(); node->name = std::move(varName); @@ -34,7 +34,7 @@ namespace Nz::ShaderNodes return node; } - inline std::shared_ptr OutputVariable::Build(std::string varName, ExpressionType varType) + inline std::shared_ptr OutputVariable::Build(std::string varName, BasicType varType) { auto node = std::make_shared(); node->name = std::move(varName); @@ -43,7 +43,7 @@ namespace Nz::ShaderNodes return node; } - inline std::shared_ptr ParameterVariable::Build(std::string varName, ExpressionType varType) + inline std::shared_ptr ParameterVariable::Build(std::string varName, BasicType varType) { auto node = std::make_shared(); node->name = std::move(varName); @@ -52,7 +52,7 @@ namespace Nz::ShaderNodes return node; } - inline std::shared_ptr UniformVariable::Build(std::string varName, ExpressionType varType) + inline std::shared_ptr UniformVariable::Build(std::string varName, BasicType varType) { auto node = std::make_shared(); node->name = std::move(varName); diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp index 902f22813..2cd045504 100644 --- a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp +++ b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp @@ -278,6 +278,8 @@ namespace Nz::GL glGetIntegerv(GL_VIEWPORT, res.data()); m_state.viewport = { res[0], res[1], res[2], res[3] }; + EnableVerticalSync(false); + return true; } diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp index e07a21294..c904a42d4 100644 --- a/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp +++ b/src/Nazara/OpenGLRenderer/Wrapper/Win32/WGLContext.cpp @@ -67,6 +67,13 @@ namespace Nz::GL void WGLContext::EnableVerticalSync(bool enabled) { + if (wglSwapIntervalEXT) + { + if (!SetCurrentContext(this)) + return; + + wglSwapIntervalEXT(enabled); + } } void WGLContext::SwapBuffers() diff --git a/src/Nazara/Renderer/GlslWriter.cpp b/src/Nazara/Renderer/GlslWriter.cpp index accb493b7..4dcbcd4cc 100644 --- a/src/Nazara/Renderer/GlslWriter.cpp +++ b/src/Nazara/Renderer/GlslWriter.cpp @@ -163,7 +163,7 @@ namespace Nz m_environment = std::move(environment); } - void GlslWriter::Append(ShaderAst::Type type) + void GlslWriter::Append(ShaderExpressionType type) { std::visit([&](auto&& arg) { @@ -181,32 +181,32 @@ namespace Nz } } - void GlslWriter::Append(ShaderNodes::ExpressionType type) + void GlslWriter::Append(ShaderNodes::BasicType type) { switch (type) { - case ShaderNodes::ExpressionType::Boolean: + case ShaderNodes::BasicType::Boolean: Append("bool"); break; - case ShaderNodes::ExpressionType::Float1: + case ShaderNodes::BasicType::Float1: Append("float"); break; - case ShaderNodes::ExpressionType::Float2: + case ShaderNodes::BasicType::Float2: Append("vec2"); break; - case ShaderNodes::ExpressionType::Float3: + case ShaderNodes::BasicType::Float3: Append("vec3"); break; - case ShaderNodes::ExpressionType::Float4: + case ShaderNodes::BasicType::Float4: Append("vec4"); break; - case ShaderNodes::ExpressionType::Mat4x4: + case ShaderNodes::BasicType::Mat4x4: Append("mat4"); break; - case ShaderNodes::ExpressionType::Sampler2D: + case ShaderNodes::BasicType::Sampler2D: Append("sampler2D"); break; - case ShaderNodes::ExpressionType::Void: + case ShaderNodes::BasicType::Void: Append("void"); break; } @@ -395,23 +395,23 @@ namespace Nz { switch (node.exprType) { - case ShaderNodes::ExpressionType::Boolean: + case ShaderNodes::BasicType::Boolean: Append((node.values.bool1) ? "true" : "false"); break; - case ShaderNodes::ExpressionType::Float1: + case ShaderNodes::BasicType::Float1: Append(std::to_string(node.values.vec1)); break; - case ShaderNodes::ExpressionType::Float2: + case ShaderNodes::BasicType::Float2: Append("vec2(" + std::to_string(node.values.vec2.x) + ", " + std::to_string(node.values.vec2.y) + ")"); break; - case ShaderNodes::ExpressionType::Float3: + case ShaderNodes::BasicType::Float3: Append("vec3(" + std::to_string(node.values.vec3.x) + ", " + std::to_string(node.values.vec3.y) + ", " + std::to_string(node.values.vec3.z) + ")"); break; - case ShaderNodes::ExpressionType::Float4: + case ShaderNodes::BasicType::Float4: Append("vec4(" + std::to_string(node.values.vec4.x) + ", " + std::to_string(node.values.vec4.y) + ", " + std::to_string(node.values.vec4.z) + ", " + std::to_string(node.values.vec4.w) + ")"); break; diff --git a/src/Nazara/Renderer/ShaderAst.cpp b/src/Nazara/Renderer/ShaderAst.cpp index 05d3eb94d..da009248b 100644 --- a/src/Nazara/Renderer/ShaderAst.cpp +++ b/src/Nazara/Renderer/ShaderAst.cpp @@ -7,7 +7,7 @@ namespace Nz { - void ShaderAst::AddFunction(std::string name, ShaderNodes::StatementPtr statement, std::vector parameters, ShaderNodes::ExpressionType returnType) + void ShaderAst::AddFunction(std::string name, ShaderNodes::StatementPtr statement, std::vector parameters, ShaderNodes::BasicType returnType) { auto& functionEntry = m_functions.emplace_back(); functionEntry.name = std::move(name); @@ -16,7 +16,7 @@ namespace Nz functionEntry.statement = std::move(statement); } - void ShaderAst::AddInput(std::string name, Type type, std::optional locationIndex) + void ShaderAst::AddInput(std::string name, ShaderExpressionType type, std::optional locationIndex) { auto& inputEntry = m_inputs.emplace_back(); inputEntry.name = std::move(name); @@ -24,7 +24,7 @@ namespace Nz inputEntry.type = std::move(type); } - void ShaderAst::AddOutput(std::string name, Type type, std::optional locationIndex) + void ShaderAst::AddOutput(std::string name, ShaderExpressionType type, std::optional locationIndex) { auto& outputEntry = m_outputs.emplace_back(); outputEntry.name = std::move(name); @@ -39,7 +39,7 @@ namespace Nz structEntry.members = std::move(members); } - void ShaderAst::AddUniform(std::string name, Type type, std::optional bindingIndex, std::optional memoryLayout) + void ShaderAst::AddUniform(std::string name, ShaderExpressionType type, std::optional bindingIndex, std::optional memoryLayout) { auto& uniformEntry = m_uniforms.emplace_back(); uniformEntry.bindingIndex = std::move(bindingIndex); diff --git a/src/Nazara/Renderer/ShaderNodes.cpp b/src/Nazara/Renderer/ShaderNodes.cpp index eb4f59160..57ac58ee8 100644 --- a/src/Nazara/Renderer/ShaderNodes.cpp +++ b/src/Nazara/Renderer/ShaderNodes.cpp @@ -47,7 +47,7 @@ namespace Nz::ShaderNodes return ExpressionCategory::LValue; } - ExpressionType Identifier::GetExpressionType() const + BasicType Identifier::GetExpressionType() const { assert(var); return var->type; @@ -59,7 +59,7 @@ namespace Nz::ShaderNodes } - ExpressionType AssignOp::GetExpressionType() const + BasicType AssignOp::GetExpressionType() const { return left->GetExpressionType(); } @@ -70,9 +70,9 @@ namespace Nz::ShaderNodes } - ExpressionType BinaryOp::GetExpressionType() const + BasicType BinaryOp::GetExpressionType() const { - ShaderNodes::ExpressionType exprType = ShaderNodes::ExpressionType::Void; + ShaderNodes::BasicType exprType = ShaderNodes::BasicType::Void; switch (op) { @@ -84,15 +84,15 @@ namespace Nz::ShaderNodes case ShaderNodes::BinaryType::Divide: case ShaderNodes::BinaryType::Multiply: //FIXME - exprType = static_cast(std::max(UnderlyingCast(left->GetExpressionType()), UnderlyingCast(right->GetExpressionType()))); + exprType = static_cast(std::max(UnderlyingCast(left->GetExpressionType()), UnderlyingCast(right->GetExpressionType()))); break; case ShaderNodes::BinaryType::Equality: - exprType = ExpressionType::Boolean; + exprType = BasicType::Boolean; break; } - NazaraAssert(exprType != ShaderNodes::ExpressionType::Void, "Unhandled builtin"); + NazaraAssert(exprType != ShaderNodes::BasicType::Void, "Unhandled builtin"); return exprType; } @@ -109,7 +109,7 @@ namespace Nz::ShaderNodes } - ExpressionType Constant::GetExpressionType() const + BasicType Constant::GetExpressionType() const { return exprType; } @@ -119,7 +119,7 @@ namespace Nz::ShaderNodes visitor.Visit(*this); } - ExpressionType Cast::GetExpressionType() const + BasicType Cast::GetExpressionType() const { return exprType; } @@ -135,9 +135,9 @@ namespace Nz::ShaderNodes return ExpressionCategory::LValue; } - ExpressionType SwizzleOp::GetExpressionType() const + BasicType SwizzleOp::GetExpressionType() const { - return static_cast(UnderlyingCast(GetComponentType(expression->GetExpressionType())) + componentCount - 1); + return static_cast(UnderlyingCast(GetComponentType(expression->GetExpressionType())) + componentCount - 1); } void SwizzleOp::Visit(ShaderVisitor& visitor) @@ -146,9 +146,9 @@ namespace Nz::ShaderNodes } - ExpressionType Sample2D::GetExpressionType() const + BasicType Sample2D::GetExpressionType() const { - return ExpressionType::Float4; + return BasicType::Float4; } void Sample2D::Visit(ShaderVisitor& visitor) @@ -157,7 +157,7 @@ namespace Nz::ShaderNodes } - ExpressionType IntrinsicCall::GetExpressionType() const + BasicType IntrinsicCall::GetExpressionType() const { switch (intrinsic) { @@ -165,11 +165,11 @@ namespace Nz::ShaderNodes return parameters.front()->GetExpressionType(); case IntrinsicType::DotProduct: - return ExpressionType::Float1; + return BasicType::Float1; } NazaraAssert(false, "Unhandled builtin"); - return ExpressionType::Void; + return BasicType::Void; } void IntrinsicCall::Visit(ShaderVisitor& visitor) diff --git a/src/Nazara/Renderer/ShaderSerializer.cpp b/src/Nazara/Renderer/ShaderSerializer.cpp index 9cf7c47ff..17f369037 100644 --- a/src/Nazara/Renderer/ShaderSerializer.cpp +++ b/src/Nazara/Renderer/ShaderSerializer.cpp @@ -170,23 +170,23 @@ namespace Nz switch (node.exprType) { - case ShaderNodes::ExpressionType::Boolean: + case ShaderNodes::BasicType::Boolean: Value(node.values.bool1); break; - case ShaderNodes::ExpressionType::Float1: + case ShaderNodes::BasicType::Float1: Value(node.values.vec1); break; - case ShaderNodes::ExpressionType::Float2: + case ShaderNodes::BasicType::Float2: Value(node.values.vec2); break; - case ShaderNodes::ExpressionType::Float3: + case ShaderNodes::BasicType::Float3: Value(node.values.vec3); break; - case ShaderNodes::ExpressionType::Float4: + case ShaderNodes::BasicType::Float4: Value(node.values.vec4); break; } @@ -249,12 +249,12 @@ namespace Nz { m_stream << s_magicNumber << s_currentVersion; - auto SerializeType = [&](const ShaderAst::Type& type) + auto SerializeType = [&](const ShaderExpressionType& type) { std::visit([&](auto&& arg) { using T = std::decay_t; - if constexpr (std::is_same_v) + if constexpr (std::is_same_v) { m_stream << UInt8(0); m_stream << UInt32(arg); @@ -448,7 +448,7 @@ namespace Nz for (UInt32 i = 0; i < inputCount; ++i) { std::string inputName; - ShaderAst::Type inputType; + ShaderExpressionType inputType; std::optional location; Value(inputName); @@ -463,7 +463,7 @@ namespace Nz for (UInt32 i = 0; i < outputCount; ++i) { std::string outputName; - ShaderAst::Type outputType; + ShaderExpressionType outputType; std::optional location; Value(outputName); @@ -478,7 +478,7 @@ namespace Nz for (UInt32 i = 0; i < uniformCount; ++i) { std::string name; - ShaderAst::Type type; + ShaderExpressionType type; std::optional binding; std::optional memLayout; @@ -495,7 +495,7 @@ namespace Nz for (UInt32 i = 0; i < funcCount; ++i) { std::string name; - ShaderNodes::ExpressionType retType; + ShaderNodes::BasicType retType; std::vector parameters; Value(name); @@ -560,7 +560,7 @@ namespace Nz } } - void ShaderUnserializer::Type(ShaderAst::Type& type) + void ShaderUnserializer::Type(ShaderExpressionType& type) { UInt8 typeIndex; Value(typeIndex); @@ -569,7 +569,7 @@ namespace Nz { case 0: //< Primitive { - ShaderNodes::ExpressionType exprType; + ShaderNodes::BasicType exprType; Enum(exprType); type = exprType; diff --git a/src/Nazara/Renderer/ShaderValidator.cpp b/src/Nazara/Renderer/ShaderValidator.cpp index 37eecb767..1445d4cf1 100644 --- a/src/Nazara/Renderer/ShaderValidator.cpp +++ b/src/Nazara/Renderer/ShaderValidator.cpp @@ -21,7 +21,7 @@ namespace Nz struct Local { std::string name; - ShaderNodes::ExpressionType type; + ShaderNodes::BasicType type; }; const ShaderAst::Function* currentFunction; @@ -77,7 +77,7 @@ namespace Nz return TypeMustMatch(left->GetExpressionType(), right->GetExpressionType()); } - void ShaderValidator::TypeMustMatch(const ShaderAst::Type& left, const ShaderAst::Type& right) + void ShaderValidator::TypeMustMatch(const ShaderExpressionType& left, const ShaderExpressionType& right) { if (left != right) throw AstError{ "Left expression type must match right expression type" }; @@ -101,8 +101,8 @@ namespace Nz MandatoryNode(node.left); MandatoryNode(node.right); - ShaderNodes::ExpressionType leftType = node.left->GetExpressionType(); - ShaderNodes::ExpressionType rightType = node.right->GetExpressionType(); + ShaderNodes::BasicType leftType = node.left->GetExpressionType(); + ShaderNodes::BasicType rightType = node.right->GetExpressionType(); switch (node.op) { @@ -117,31 +117,31 @@ namespace Nz { switch (leftType) { - case ShaderNodes::ExpressionType::Float1: + case ShaderNodes::BasicType::Float1: { - if (ShaderNodes::Node::GetComponentType(rightType) != ShaderNodes::ExpressionType::Float1) + if (ShaderNodes::Node::GetComponentType(rightType) != ShaderNodes::BasicType::Float1) throw AstError{ "Left expression type is not compatible with right expression type" }; break; } - case ShaderNodes::ExpressionType::Float2: - case ShaderNodes::ExpressionType::Float3: - case ShaderNodes::ExpressionType::Float4: + case ShaderNodes::BasicType::Float2: + case ShaderNodes::BasicType::Float3: + case ShaderNodes::BasicType::Float4: { - if (leftType != rightType && rightType != ShaderNodes::ExpressionType::Float1) + if (leftType != rightType && rightType != ShaderNodes::BasicType::Float1) throw AstError{ "Left expression type is not compatible with right expression type" }; break; } - case ShaderNodes::ExpressionType::Mat4x4: + case ShaderNodes::BasicType::Mat4x4: { switch (rightType) { - case ShaderNodes::ExpressionType::Float1: - case ShaderNodes::ExpressionType::Float4: - case ShaderNodes::ExpressionType::Mat4x4: + case ShaderNodes::BasicType::Float1: + case ShaderNodes::BasicType::Float4: + case ShaderNodes::BasicType::Mat4x4: break; default: @@ -318,7 +318,7 @@ namespace Nz for (auto& param : node.parameters) MandatoryNode(param); - ShaderNodes::ExpressionType type = node.parameters.front()->GetExpressionType(); + ShaderNodes::BasicType type = node.parameters.front()->GetExpressionType(); for (std::size_t i = 1; i < node.parameters.size(); ++i) { if (type != node.parameters[i]->GetExpressionType()) @@ -333,7 +333,7 @@ namespace Nz { case ShaderNodes::IntrinsicType::CrossProduct: { - if (node.parameters[0]->GetExpressionType() != ShaderNodes::ExpressionType::Float3) + if (node.parameters[0]->GetExpressionType() != ShaderNodes::BasicType::Float3) throw AstError{ "CrossProduct only works with Float3 expressions" }; break; @@ -349,10 +349,10 @@ namespace Nz void ShaderValidator::Visit(const ShaderNodes::Sample2D& node) { - if (MandatoryExpr(node.sampler)->GetExpressionType() != ShaderNodes::ExpressionType::Sampler2D) + if (MandatoryExpr(node.sampler)->GetExpressionType() != ShaderNodes::BasicType::Sampler2D) throw AstError{ "Sampler must be a Sampler2D" }; - if (MandatoryExpr(node.coordinates)->GetExpressionType() != ShaderNodes::ExpressionType::Float2) + if (MandatoryExpr(node.coordinates)->GetExpressionType() != ShaderNodes::BasicType::Float2) throw AstError{ "Coordinates must be a Float2" }; Visit(node.sampler); @@ -380,10 +380,10 @@ namespace Nz switch (MandatoryExpr(node.expression)->GetExpressionType()) { - case ShaderNodes::ExpressionType::Float1: - case ShaderNodes::ExpressionType::Float2: - case ShaderNodes::ExpressionType::Float3: - case ShaderNodes::ExpressionType::Float4: + case ShaderNodes::BasicType::Float1: + case ShaderNodes::BasicType::Float2: + case ShaderNodes::BasicType::Float3: + case ShaderNodes::BasicType::Float4: break; default: diff --git a/src/ShaderNode/DataModels/InputValue.cpp b/src/ShaderNode/DataModels/InputValue.cpp index a5a3a269b..f9337f262 100644 --- a/src/ShaderNode/DataModels/InputValue.cpp +++ b/src/ShaderNode/DataModels/InputValue.cpp @@ -116,15 +116,15 @@ Nz::ShaderNodes::ExpressionPtr InputValue::GetExpression(Nz::ShaderNodes::Expres const auto& inputEntry = GetGraph().GetInput(*m_currentInputIndex); - Nz::ShaderNodes::ExpressionType expression = [&] + Nz::ShaderNodes::BasicType expression = [&] { switch (inputEntry.type) { - case PrimitiveType::Bool: return Nz::ShaderNodes::ExpressionType::Boolean; - case PrimitiveType::Float1: return Nz::ShaderNodes::ExpressionType::Float1; - case PrimitiveType::Float2: return Nz::ShaderNodes::ExpressionType::Float2; - case PrimitiveType::Float3: return Nz::ShaderNodes::ExpressionType::Float3; - case PrimitiveType::Float4: return Nz::ShaderNodes::ExpressionType::Float4; + case PrimitiveType::Bool: return Nz::ShaderNodes::BasicType::Boolean; + case PrimitiveType::Float1: return Nz::ShaderNodes::BasicType::Float1; + case PrimitiveType::Float2: return Nz::ShaderNodes::BasicType::Float2; + case PrimitiveType::Float3: return Nz::ShaderNodes::BasicType::Float3; + case PrimitiveType::Float4: return Nz::ShaderNodes::BasicType::Float4; } assert(false); @@ -145,7 +145,7 @@ auto InputValue::dataType(QtNodes::PortType portType, QtNodes::PortIndex portInd const auto& inputEntry = GetGraph().GetInput(*m_currentInputIndex); switch (inputEntry.type) { - //case InputType::Bool: return Nz::ShaderNodes::ExpressionType::Boolean; + //case InputType::Bool: return Nz::ShaderNodes::BasicType::Boolean; case PrimitiveType::Float1: return FloatData::Type(); diff --git a/src/ShaderNode/DataModels/OutputValue.cpp b/src/ShaderNode/DataModels/OutputValue.cpp index 1f65c5953..b86c46879 100644 --- a/src/ShaderNode/DataModels/OutputValue.cpp +++ b/src/ShaderNode/DataModels/OutputValue.cpp @@ -63,15 +63,15 @@ Nz::ShaderNodes::ExpressionPtr OutputValue::GetExpression(Nz::ShaderNodes::Expre const auto& outputEntry = GetGraph().GetOutput(*m_currentOutputIndex); - Nz::ShaderNodes::ExpressionType expression = [&] + Nz::ShaderNodes::BasicType expression = [&] { switch (outputEntry.type) { - case PrimitiveType::Bool: return Nz::ShaderNodes::ExpressionType::Boolean; - case PrimitiveType::Float1: return Nz::ShaderNodes::ExpressionType::Float1; - case PrimitiveType::Float2: return Nz::ShaderNodes::ExpressionType::Float2; - case PrimitiveType::Float3: return Nz::ShaderNodes::ExpressionType::Float3; - case PrimitiveType::Float4: return Nz::ShaderNodes::ExpressionType::Float4; + case PrimitiveType::Bool: return Nz::ShaderNodes::BasicType::Boolean; + case PrimitiveType::Float1: return Nz::ShaderNodes::BasicType::Float1; + case PrimitiveType::Float2: return Nz::ShaderNodes::BasicType::Float2; + case PrimitiveType::Float3: return Nz::ShaderNodes::BasicType::Float3; + case PrimitiveType::Float4: return Nz::ShaderNodes::BasicType::Float4; } assert(false); @@ -94,8 +94,8 @@ QtNodes::NodeDataType OutputValue::dataType(QtNodes::PortType portType, QtNodes: const auto& outputEntry = GetGraph().GetOutput(*m_currentOutputIndex); switch (outputEntry.type) { - //case InOutType::Bool: return Nz::ShaderNodes::ExpressionType::Boolean; - //case InOutType::Float1: return Nz::ShaderNodes::ExpressionType::Float1; + //case InOutType::Bool: return Nz::ShaderNodes::BasicType::Boolean; + //case InOutType::Float1: return Nz::ShaderNodes::BasicType::Float1; case PrimitiveType::Float2: case PrimitiveType::Float3: case PrimitiveType::Float4: diff --git a/src/ShaderNode/DataModels/TextureValue.cpp b/src/ShaderNode/DataModels/TextureValue.cpp index 6a6402cf4..79df6de5c 100644 --- a/src/ShaderNode/DataModels/TextureValue.cpp +++ b/src/ShaderNode/DataModels/TextureValue.cpp @@ -119,11 +119,11 @@ Nz::ShaderNodes::ExpressionPtr TextureValue::GetExpression(Nz::ShaderNodes::Expr const auto& textureEntry = GetGraph().GetTexture(*m_currentTextureIndex); - Nz::ShaderNodes::ExpressionType expression = [&] + Nz::ShaderNodes::BasicType expression = [&] { switch (textureEntry.type) { - case TextureType::Sampler2D: return Nz::ShaderNodes::ExpressionType::Sampler2D; + case TextureType::Sampler2D: return Nz::ShaderNodes::BasicType::Sampler2D; } assert(false); diff --git a/src/ShaderNode/DataTypes/VecData.cpp b/src/ShaderNode/DataTypes/VecData.cpp index 2d4a38001..0402864e0 100644 --- a/src/ShaderNode/DataTypes/VecData.cpp +++ b/src/ShaderNode/DataTypes/VecData.cpp @@ -2,13 +2,13 @@ #include #include -Nz::ShaderNodes::ExpressionType VecData::GetExpressionType() const +Nz::ShaderNodes::BasicType VecData::GetExpressionType() const { switch (componentCount) { - case 2: return Nz::ShaderNodes::ExpressionType::Float2; - case 3: return Nz::ShaderNodes::ExpressionType::Float3; - case 4: return Nz::ShaderNodes::ExpressionType::Float4; + case 2: return Nz::ShaderNodes::BasicType::Float2; + case 3: return Nz::ShaderNodes::BasicType::Float3; + case 4: return Nz::ShaderNodes::BasicType::Float4; default: break; } diff --git a/src/ShaderNode/DataTypes/VecData.hpp b/src/ShaderNode/DataTypes/VecData.hpp index 3c6a8f096..7c515a12a 100644 --- a/src/ShaderNode/DataTypes/VecData.hpp +++ b/src/ShaderNode/DataTypes/VecData.hpp @@ -13,7 +13,7 @@ struct VecData : public QtNodes::NodeData inline QtNodes::NodeDataType type() const override; - Nz::ShaderNodes::ExpressionType GetExpressionType() const; + Nz::ShaderNodes::BasicType GetExpressionType() const; static inline QtNodes::NodeDataType Type(); @@ -27,28 +27,28 @@ struct VecExpressionTypeHelper; template<> struct VecExpressionTypeHelper<1> { - static constexpr Nz::ShaderNodes::ExpressionType ExpressionType = Nz::ShaderNodes::ExpressionType::Float1; + static constexpr Nz::ShaderNodes::BasicType ExpressionType = Nz::ShaderNodes::BasicType::Float1; }; template<> struct VecExpressionTypeHelper<2> { - static constexpr Nz::ShaderNodes::ExpressionType ExpressionType = Nz::ShaderNodes::ExpressionType::Float2; + static constexpr Nz::ShaderNodes::BasicType ExpressionType = Nz::ShaderNodes::BasicType::Float2; }; template<> struct VecExpressionTypeHelper<3> { - static constexpr Nz::ShaderNodes::ExpressionType ExpressionType = Nz::ShaderNodes::ExpressionType::Float3; + static constexpr Nz::ShaderNodes::BasicType ExpressionType = Nz::ShaderNodes::BasicType::Float3; }; template<> struct VecExpressionTypeHelper<4> { - static constexpr Nz::ShaderNodes::ExpressionType ExpressionType = Nz::ShaderNodes::ExpressionType::Float4; + static constexpr Nz::ShaderNodes::BasicType ExpressionType = Nz::ShaderNodes::BasicType::Float4; }; -template constexpr Nz::ShaderNodes::ExpressionType VecExpressionType = VecExpressionTypeHelper::template ExpressionType; +template constexpr Nz::ShaderNodes::BasicType VecExpressionType = VecExpressionTypeHelper::template ExpressionType; struct VecTypeDummy {}; diff --git a/src/ShaderNode/Widgets/MainWindow.cpp b/src/ShaderNode/Widgets/MainWindow.cpp index 213d190cb..813d1b5ab 100644 --- a/src/ShaderNode/Widgets/MainWindow.cpp +++ b/src/ShaderNode/Widgets/MainWindow.cpp @@ -217,11 +217,11 @@ Nz::ShaderAst MainWindow::ToShader() { switch (type) { - case PrimitiveType::Bool: return Nz::ShaderNodes::ExpressionType::Boolean; - case PrimitiveType::Float1: return Nz::ShaderNodes::ExpressionType::Float1; - case PrimitiveType::Float2: return Nz::ShaderNodes::ExpressionType::Float2; - case PrimitiveType::Float3: return Nz::ShaderNodes::ExpressionType::Float3; - case PrimitiveType::Float4: return Nz::ShaderNodes::ExpressionType::Float4; + case PrimitiveType::Bool: return Nz::ShaderNodes::BasicType::Boolean; + case PrimitiveType::Float1: return Nz::ShaderNodes::BasicType::Float1; + case PrimitiveType::Float2: return Nz::ShaderNodes::BasicType::Float2; + case PrimitiveType::Float3: return Nz::ShaderNodes::BasicType::Float3; + case PrimitiveType::Float4: return Nz::ShaderNodes::BasicType::Float4; } assert(false); @@ -232,7 +232,7 @@ Nz::ShaderAst MainWindow::ToShader() { switch (type) { - case TextureType::Sampler2D: return Nz::ShaderNodes::ExpressionType::Sampler2D; + case TextureType::Sampler2D: return Nz::ShaderNodes::BasicType::Sampler2D; } assert(false); From 086f76fb97458fe417f95347582a3a9059b743a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sun, 19 Jul 2020 21:05:46 +0200 Subject: [PATCH 262/316] Renderer/ShaderNodes: Add support for accessing struct fields --- include/Nazara/Renderer/GlslWriter.hpp | 2 + include/Nazara/Renderer/ShaderBuilder.hpp | 1 + include/Nazara/Renderer/ShaderEnums.hpp | 1 + .../Nazara/Renderer/ShaderExpressionType.hpp | 2 +- include/Nazara/Renderer/ShaderNodes.hpp | 34 +++++++--- include/Nazara/Renderer/ShaderNodes.inl | 16 +++++ include/Nazara/Renderer/ShaderSerializer.hpp | 6 +- include/Nazara/Renderer/ShaderValidator.hpp | 1 + include/Nazara/Renderer/ShaderVariables.hpp | 16 ++--- include/Nazara/Renderer/ShaderVariables.inl | 12 ++-- include/Nazara/Renderer/ShaderVisitor.hpp | 1 + src/Nazara/Renderer/GlslWriter.cpp | 32 +++++++-- src/Nazara/Renderer/ShaderNodes.cpp | 65 +++++++++++++------ src/Nazara/Renderer/ShaderSerializer.cpp | 38 ++++++++++- src/Nazara/Renderer/ShaderValidator.cpp | 56 +++++++++++++--- 15 files changed, 221 insertions(+), 62 deletions(-) diff --git a/include/Nazara/Renderer/GlslWriter.hpp b/include/Nazara/Renderer/GlslWriter.hpp index 94ca21676..ba2444aec 100644 --- a/include/Nazara/Renderer/GlslWriter.hpp +++ b/include/Nazara/Renderer/GlslWriter.hpp @@ -61,6 +61,7 @@ namespace Nz using ShaderVarVisitor::Visit; using ShaderVisitor::Visit; + void Visit(const ShaderNodes::AccessMember& node) override; void Visit(const ShaderNodes::AssignOp& node) override; void Visit(const ShaderNodes::Branch& node) override; void Visit(const ShaderNodes::BinaryOp& node) override; @@ -85,6 +86,7 @@ namespace Nz struct Context { + const ShaderAst* shader = nullptr; const ShaderAst::Function* currentFunction = nullptr; }; diff --git a/include/Nazara/Renderer/ShaderBuilder.hpp b/include/Nazara/Renderer/ShaderBuilder.hpp index 7d8502151..8f544e018 100644 --- a/include/Nazara/Renderer/ShaderBuilder.hpp +++ b/include/Nazara/Renderer/ShaderBuilder.hpp @@ -44,6 +44,7 @@ namespace Nz::ShaderBuilder template std::shared_ptr operator()(Args&&... args) const; }; + constexpr GenBuilder AccessMember; constexpr BinOpBuilder Add; constexpr AssignOpBuilder Assign; constexpr BuiltinBuilder Builtin; diff --git a/include/Nazara/Renderer/ShaderEnums.hpp b/include/Nazara/Renderer/ShaderEnums.hpp index a9db1abe8..6edaad1de 100644 --- a/include/Nazara/Renderer/ShaderEnums.hpp +++ b/include/Nazara/Renderer/ShaderEnums.hpp @@ -65,6 +65,7 @@ namespace Nz::ShaderNodes { None = -1, + AccessMember, AssignOp, BinaryOp, Branch, diff --git a/include/Nazara/Renderer/ShaderExpressionType.hpp b/include/Nazara/Renderer/ShaderExpressionType.hpp index c937d6a10..68671b07c 100644 --- a/include/Nazara/Renderer/ShaderExpressionType.hpp +++ b/include/Nazara/Renderer/ShaderExpressionType.hpp @@ -8,7 +8,7 @@ #define NAZARA_SHADER_EXPRESSIONTYPE_HPP #include -#include +#include #include #include diff --git a/include/Nazara/Renderer/ShaderNodes.hpp b/include/Nazara/Renderer/ShaderNodes.hpp index 57ff5ab60..0c5049df9 100644 --- a/include/Nazara/Renderer/ShaderNodes.hpp +++ b/include/Nazara/Renderer/ShaderNodes.hpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -59,7 +60,7 @@ namespace Nz inline Expression(NodeType type); virtual ExpressionCategory GetExpressionCategory() const; - virtual BasicType GetExpressionType() const = 0; + virtual ShaderExpressionType GetExpressionType() const = 0; }; class Statement; @@ -125,7 +126,7 @@ namespace Nz inline Identifier(); ExpressionCategory GetExpressionCategory() const override; - BasicType GetExpressionType() const override; + ShaderExpressionType GetExpressionType() const override; void Visit(ShaderVisitor& visitor) override; VariablePtr var; @@ -133,13 +134,28 @@ namespace Nz static inline std::shared_ptr Build(VariablePtr variable); }; + struct NAZARA_RENDERER_API AccessMember : public Expression + { + inline AccessMember(); + + ExpressionCategory GetExpressionCategory() const override; + ShaderExpressionType GetExpressionType() const override; + void Visit(ShaderVisitor& visitor) override; + + std::size_t memberIndex; + ExpressionPtr structExpr; + ShaderExpressionType exprType; //< FIXME: Use ShaderAst to automate + + static inline std::shared_ptr Build(ExpressionPtr structExpr, std::size_t memberIndex, ShaderExpressionType exprType); + }; + ////////////////////////////////////////////////////////////////////////// struct NAZARA_RENDERER_API AssignOp : public Expression { inline AssignOp(); - BasicType GetExpressionType() const override; + ShaderExpressionType GetExpressionType() const override; void Visit(ShaderVisitor& visitor) override; AssignType op; @@ -153,7 +169,7 @@ namespace Nz { inline BinaryOp(); - BasicType GetExpressionType() const override; + ShaderExpressionType GetExpressionType() const override; void Visit(ShaderVisitor& visitor) override; BinaryType op; @@ -187,7 +203,7 @@ namespace Nz { inline Cast(); - BasicType GetExpressionType() const override; + ShaderExpressionType GetExpressionType() const override; void Visit(ShaderVisitor& visitor) override; BasicType exprType; @@ -201,7 +217,7 @@ namespace Nz { inline Constant(); - BasicType GetExpressionType() const override; + ShaderExpressionType GetExpressionType() const override; void Visit(ShaderVisitor& visitor) override; BasicType exprType; @@ -227,7 +243,7 @@ namespace Nz inline SwizzleOp(); ExpressionCategory GetExpressionCategory() const override; - BasicType GetExpressionType() const override; + ShaderExpressionType GetExpressionType() const override; void Visit(ShaderVisitor& visitor) override; std::array components; @@ -243,7 +259,7 @@ namespace Nz { inline Sample2D(); - BasicType GetExpressionType() const override; + ShaderExpressionType GetExpressionType() const override; void Visit(ShaderVisitor& visitor) override; ExpressionPtr sampler; @@ -258,7 +274,7 @@ namespace Nz { inline IntrinsicCall(); - BasicType GetExpressionType() const override; + ShaderExpressionType GetExpressionType() const override; void Visit(ShaderVisitor& visitor) override; IntrinsicType intrinsic; diff --git a/include/Nazara/Renderer/ShaderNodes.inl b/include/Nazara/Renderer/ShaderNodes.inl index 31d3028ed..606487e0c 100644 --- a/include/Nazara/Renderer/ShaderNodes.inl +++ b/include/Nazara/Renderer/ShaderNodes.inl @@ -146,6 +146,22 @@ namespace Nz::ShaderNodes } + inline AccessMember::AccessMember() : + Expression(NodeType::AccessMember) + { + } + + inline std::shared_ptr AccessMember::Build(ExpressionPtr structExpr, std::size_t memberIndex, ShaderExpressionType exprType) + { + auto node = std::make_shared(); + node->exprType = std::move(exprType); + node->memberIndex = memberIndex; + node->structExpr = std::move(structExpr); + + return node; + } + + inline AssignOp::AssignOp() : Expression(NodeType::AssignOp) { diff --git a/include/Nazara/Renderer/ShaderSerializer.hpp b/include/Nazara/Renderer/ShaderSerializer.hpp index e4e6be7b3..c6596b58d 100644 --- a/include/Nazara/Renderer/ShaderSerializer.hpp +++ b/include/Nazara/Renderer/ShaderSerializer.hpp @@ -25,6 +25,7 @@ namespace Nz ShaderSerializerBase(ShaderSerializerBase&&) = delete; ~ShaderSerializerBase() = default; + void Serialize(ShaderNodes::AccessMember& node); void Serialize(ShaderNodes::AssignOp& node); void Serialize(ShaderNodes::BinaryOp& node); void Serialize(ShaderNodes::BuiltinVariable& var); @@ -51,6 +52,8 @@ namespace Nz virtual void Node(ShaderNodes::NodePtr& node) = 0; template void Node(std::shared_ptr& node); + virtual void Type(ShaderExpressionType& type) = 0; + virtual void Value(bool& val) = 0; virtual void Value(float& val) = 0; virtual void Value(std::string& val) = 0; @@ -78,6 +81,7 @@ namespace Nz bool IsWriting() const override; void Node(const ShaderNodes::NodePtr& node); void Node(ShaderNodes::NodePtr& node) override; + void Type(ShaderExpressionType& type) override; void Value(bool& val) override; void Value(float& val) override; void Value(std::string& val) override; @@ -103,7 +107,7 @@ namespace Nz private: bool IsWriting() const override; void Node(ShaderNodes::NodePtr& node) override; - void Type(ShaderExpressionType& type); + void Type(ShaderExpressionType& type) override; void Value(bool& val) override; void Value(float& val) override; void Value(std::string& val) override; diff --git a/include/Nazara/Renderer/ShaderValidator.hpp b/include/Nazara/Renderer/ShaderValidator.hpp index ecfea1290..09015b073 100644 --- a/include/Nazara/Renderer/ShaderValidator.hpp +++ b/include/Nazara/Renderer/ShaderValidator.hpp @@ -33,6 +33,7 @@ namespace Nz void TypeMustMatch(const ShaderExpressionType& left, const ShaderExpressionType& right); using ShaderVisitor::Visit; + void Visit(const ShaderNodes::AccessMember& node) override; void Visit(const ShaderNodes::AssignOp& node) override; void Visit(const ShaderNodes::BinaryOp& node) override; void Visit(const ShaderNodes::Branch& node) override; diff --git a/include/Nazara/Renderer/ShaderVariables.hpp b/include/Nazara/Renderer/ShaderVariables.hpp index f80386d0c..9b52d3913 100644 --- a/include/Nazara/Renderer/ShaderVariables.hpp +++ b/include/Nazara/Renderer/ShaderVariables.hpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include @@ -34,7 +34,7 @@ namespace Nz virtual VariableType GetType() const = 0; virtual void Visit(ShaderVarVisitor& visitor) = 0; - BasicType type; + ShaderExpressionType type; }; struct BuiltinVariable; @@ -48,7 +48,7 @@ namespace Nz VariableType GetType() const override; void Visit(ShaderVarVisitor& visitor) override; - static inline std::shared_ptr Build(BuiltinEntry entry, BasicType varType); + static inline std::shared_ptr Build(BuiltinEntry entry, ShaderExpressionType varType); }; struct NamedVariable; @@ -69,7 +69,7 @@ namespace Nz VariableType GetType() const override; void Visit(ShaderVarVisitor& visitor) override; - static inline std::shared_ptr Build(std::string varName, BasicType varType); + static inline std::shared_ptr Build(std::string varName, ShaderExpressionType varType); }; struct LocalVariable; @@ -81,7 +81,7 @@ namespace Nz VariableType GetType() const override; void Visit(ShaderVarVisitor& visitor) override; - static inline std::shared_ptr Build(std::string varName, BasicType varType); + static inline std::shared_ptr Build(std::string varName, ShaderExpressionType varType); }; struct OutputVariable; @@ -93,7 +93,7 @@ namespace Nz VariableType GetType() const override; void Visit(ShaderVarVisitor& visitor) override; - static inline std::shared_ptr Build(std::string varName, BasicType varType); + static inline std::shared_ptr Build(std::string varName, ShaderExpressionType varType); }; struct ParameterVariable; @@ -105,7 +105,7 @@ namespace Nz VariableType GetType() const override; void Visit(ShaderVarVisitor& visitor) override; - static inline std::shared_ptr Build(std::string varName, BasicType varType); + static inline std::shared_ptr Build(std::string varName, ShaderExpressionType varType); }; struct UniformVariable; @@ -117,7 +117,7 @@ namespace Nz VariableType GetType() const override; void Visit(ShaderVarVisitor& visitor) override; - static inline std::shared_ptr Build(std::string varName, BasicType varType); + static inline std::shared_ptr Build(std::string varName, ShaderExpressionType varType); }; } } diff --git a/include/Nazara/Renderer/ShaderVariables.inl b/include/Nazara/Renderer/ShaderVariables.inl index e01ecb33e..917459c67 100644 --- a/include/Nazara/Renderer/ShaderVariables.inl +++ b/include/Nazara/Renderer/ShaderVariables.inl @@ -7,7 +7,7 @@ namespace Nz::ShaderNodes { - inline std::shared_ptr BuiltinVariable::Build(BuiltinEntry variable, BasicType varType) + inline std::shared_ptr BuiltinVariable::Build(BuiltinEntry variable, ShaderExpressionType varType) { auto node = std::make_shared(); node->entry = variable; @@ -16,7 +16,7 @@ namespace Nz::ShaderNodes return node; } - inline std::shared_ptr InputVariable::Build(std::string varName, BasicType varType) + inline std::shared_ptr InputVariable::Build(std::string varName, ShaderExpressionType varType) { auto node = std::make_shared(); node->name = std::move(varName); @@ -25,7 +25,7 @@ namespace Nz::ShaderNodes return node; } - inline std::shared_ptr LocalVariable::Build(std::string varName, BasicType varType) + inline std::shared_ptr LocalVariable::Build(std::string varName, ShaderExpressionType varType) { auto node = std::make_shared(); node->name = std::move(varName); @@ -34,7 +34,7 @@ namespace Nz::ShaderNodes return node; } - inline std::shared_ptr OutputVariable::Build(std::string varName, BasicType varType) + inline std::shared_ptr OutputVariable::Build(std::string varName, ShaderExpressionType varType) { auto node = std::make_shared(); node->name = std::move(varName); @@ -43,7 +43,7 @@ namespace Nz::ShaderNodes return node; } - inline std::shared_ptr ParameterVariable::Build(std::string varName, BasicType varType) + inline std::shared_ptr ParameterVariable::Build(std::string varName, ShaderExpressionType varType) { auto node = std::make_shared(); node->name = std::move(varName); @@ -52,7 +52,7 @@ namespace Nz::ShaderNodes return node; } - inline std::shared_ptr UniformVariable::Build(std::string varName, BasicType varType) + inline std::shared_ptr UniformVariable::Build(std::string varName, ShaderExpressionType varType) { auto node = std::make_shared(); node->name = std::move(varName); diff --git a/include/Nazara/Renderer/ShaderVisitor.hpp b/include/Nazara/Renderer/ShaderVisitor.hpp index 9db22882c..1cd98fac3 100644 --- a/include/Nazara/Renderer/ShaderVisitor.hpp +++ b/include/Nazara/Renderer/ShaderVisitor.hpp @@ -27,6 +27,7 @@ namespace Nz bool IsConditionEnabled(const std::string& name) const; + virtual void Visit(const ShaderNodes::AccessMember& node) = 0; virtual void Visit(const ShaderNodes::AssignOp& node) = 0; virtual void Visit(const ShaderNodes::BinaryOp& node) = 0; virtual void Visit(const ShaderNodes::Branch& node) = 0; diff --git a/src/Nazara/Renderer/GlslWriter.cpp b/src/Nazara/Renderer/GlslWriter.cpp index 4dcbcd4cc..33ae8c0db 100644 --- a/src/Nazara/Renderer/GlslWriter.cpp +++ b/src/Nazara/Renderer/GlslWriter.cpp @@ -21,6 +21,8 @@ namespace Nz if (!ValidateShader(shader, &error)) throw std::runtime_error("Invalid shader AST: " + error); + m_context.shader = &shader; + State state; m_currentState = &state; CallOnExit onExit([this]() @@ -294,7 +296,30 @@ namespace Nz AppendLine(); AppendLine("}"); } - + + void GlslWriter::Visit(const ShaderNodes::AccessMember& node) + { + Append("("); + Visit(node.structExpr); + Append(")"); + + const ShaderExpressionType& exprType = node.structExpr->GetExpressionType(); + assert(std::holds_alternative(exprType)); + + const std::string& structName = std::get(exprType); + + const auto& structs = m_context.shader->GetStructs(); + auto it = std::find_if(structs.begin(), structs.end(), [&](const auto& s) { return s.name == structName; }); + assert(it != structs.end()); + + const ShaderAst::Struct& s = *it; + assert(node.memberIndex < s.members.size()); + + const auto& member = s.members[node.memberIndex]; + Append("."); + Append(member.name); + } + void GlslWriter::Visit(const ShaderNodes::AssignOp& node) { Visit(node.left); @@ -374,9 +399,7 @@ namespace Nz Append(node.exprType); Append("("); - unsigned int i = 0; - unsigned int requiredComponents = ShaderNodes::Node::GetComponentCount(node.exprType); - while (requiredComponents > 0) + for (std::size_t i = 0; node.expressions[i]; ++i) { if (i != 0) m_currentState->stream << ", "; @@ -385,7 +408,6 @@ namespace Nz NazaraAssert(exprPtr, "Invalid expression"); Visit(exprPtr); - requiredComponents -= ShaderNodes::Node::GetComponentCount(exprPtr->GetExpressionType()); } Append(")"); diff --git a/src/Nazara/Renderer/ShaderNodes.cpp b/src/Nazara/Renderer/ShaderNodes.cpp index 57ac58ee8..794e1217a 100644 --- a/src/Nazara/Renderer/ShaderNodes.cpp +++ b/src/Nazara/Renderer/ShaderNodes.cpp @@ -47,7 +47,7 @@ namespace Nz::ShaderNodes return ExpressionCategory::LValue; } - BasicType Identifier::GetExpressionType() const + ShaderExpressionType Identifier::GetExpressionType() const { assert(var); return var->type; @@ -58,8 +58,22 @@ namespace Nz::ShaderNodes visitor.Visit(*this); } + ExpressionCategory ShaderNodes::AccessMember::GetExpressionCategory() const + { + return ExpressionCategory::LValue; + } - BasicType AssignOp::GetExpressionType() const + ShaderExpressionType AccessMember::GetExpressionType() const + { + return exprType; + } + + void AccessMember::Visit(ShaderVisitor& visitor) + { + visitor.Visit(*this); + } + + ShaderExpressionType AssignOp::GetExpressionType() const { return left->GetExpressionType(); } @@ -70,31 +84,39 @@ namespace Nz::ShaderNodes } - BasicType BinaryOp::GetExpressionType() const + ShaderExpressionType BinaryOp::GetExpressionType() const { - ShaderNodes::BasicType exprType = ShaderNodes::BasicType::Void; + std::optional exprType; switch (op) { - case ShaderNodes::BinaryType::Add: - case ShaderNodes::BinaryType::Substract: + case BinaryType::Add: + case BinaryType::Substract: exprType = left->GetExpressionType(); break; - case ShaderNodes::BinaryType::Divide: - case ShaderNodes::BinaryType::Multiply: - //FIXME - exprType = static_cast(std::max(UnderlyingCast(left->GetExpressionType()), UnderlyingCast(right->GetExpressionType()))); - break; + case BinaryType::Divide: + case BinaryType::Multiply: + { + const ShaderExpressionType& leftExprType = left->GetExpressionType(); + assert(std::holds_alternative(leftExprType)); - case ShaderNodes::BinaryType::Equality: + const ShaderExpressionType& rightExprType = right->GetExpressionType(); + assert(std::holds_alternative(rightExprType)); + + //FIXME + exprType = static_cast(std::max(UnderlyingCast(std::get(leftExprType)), UnderlyingCast(std::get(rightExprType)))); + break; + } + + case BinaryType::Equality: exprType = BasicType::Boolean; break; } - NazaraAssert(exprType != ShaderNodes::BasicType::Void, "Unhandled builtin"); + NazaraAssert(exprType.has_value(), "Unhandled builtin"); - return exprType; + return *exprType; } void BinaryOp::Visit(ShaderVisitor& visitor) @@ -109,7 +131,7 @@ namespace Nz::ShaderNodes } - BasicType Constant::GetExpressionType() const + ShaderExpressionType Constant::GetExpressionType() const { return exprType; } @@ -119,7 +141,7 @@ namespace Nz::ShaderNodes visitor.Visit(*this); } - BasicType Cast::GetExpressionType() const + ShaderExpressionType Cast::GetExpressionType() const { return exprType; } @@ -135,9 +157,12 @@ namespace Nz::ShaderNodes return ExpressionCategory::LValue; } - BasicType SwizzleOp::GetExpressionType() const + ShaderExpressionType SwizzleOp::GetExpressionType() const { - return static_cast(UnderlyingCast(GetComponentType(expression->GetExpressionType())) + componentCount - 1); + const ShaderExpressionType& exprType = expression->GetExpressionType(); + assert(std::holds_alternative(exprType)); + + return static_cast(UnderlyingCast(GetComponentType(std::get(exprType))) + componentCount - 1); } void SwizzleOp::Visit(ShaderVisitor& visitor) @@ -146,7 +171,7 @@ namespace Nz::ShaderNodes } - BasicType Sample2D::GetExpressionType() const + ShaderExpressionType Sample2D::GetExpressionType() const { return BasicType::Float4; } @@ -157,7 +182,7 @@ namespace Nz::ShaderNodes } - BasicType IntrinsicCall::GetExpressionType() const + ShaderExpressionType IntrinsicCall::GetExpressionType() const { switch (intrinsic) { diff --git a/src/Nazara/Renderer/ShaderSerializer.cpp b/src/Nazara/Renderer/ShaderSerializer.cpp index 17f369037..71beead60 100644 --- a/src/Nazara/Renderer/ShaderSerializer.cpp +++ b/src/Nazara/Renderer/ShaderSerializer.cpp @@ -22,6 +22,11 @@ namespace Nz { } + void Visit(const ShaderNodes::AccessMember& node) override + { + Serialize(node); + } + void Visit(const ShaderNodes::AssignOp& node) override { Serialize(node); @@ -125,6 +130,13 @@ namespace Nz }; } + void ShaderSerializerBase::Serialize(ShaderNodes::AccessMember& node) + { + Value(node.memberIndex); + Node(node.structExpr); + Type(node.exprType); + } + void ShaderSerializerBase::Serialize(ShaderNodes::AssignOp& node) { Enum(node.op); @@ -153,8 +165,8 @@ namespace Nz void ShaderSerializerBase::Serialize(ShaderNodes::BuiltinVariable& node) { - Enum(node.type); - Enum(node.type); + Enum(node.entry); + Type(node.type); } void ShaderSerializerBase::Serialize(ShaderNodes::Cast& node) @@ -219,7 +231,7 @@ namespace Nz void ShaderSerializerBase::Serialize(ShaderNodes::NamedVariable& node) { Value(node.name); - Enum(node.type); + Type(node.type); } void ShaderSerializerBase::Serialize(ShaderNodes::Sample2D& node) @@ -348,6 +360,26 @@ namespace Nz } } + void ShaderSerializer::Type(ShaderExpressionType& type) + { + std::visit([&](auto&& arg) + { + using T = std::decay_t; + if constexpr (std::is_same_v) + { + m_stream << UInt8(0); + m_stream << UInt32(arg); + } + else if constexpr (std::is_same_v) + { + m_stream << UInt8(1); + m_stream << arg; + } + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + }, type); + } + void ShaderSerializer::Node(const ShaderNodes::NodePtr& node) { Node(const_cast(node)); //< Yes const_cast is ugly but it won't be used for writing diff --git a/src/Nazara/Renderer/ShaderValidator.cpp b/src/Nazara/Renderer/ShaderValidator.cpp index 1445d4cf1..c181ecd62 100644 --- a/src/Nazara/Renderer/ShaderValidator.cpp +++ b/src/Nazara/Renderer/ShaderValidator.cpp @@ -21,7 +21,7 @@ namespace Nz struct Local { std::string name; - ShaderNodes::BasicType type; + ShaderExpressionType type; }; const ShaderAst::Function* currentFunction; @@ -83,6 +83,28 @@ namespace Nz throw AstError{ "Left expression type must match right expression type" }; } + void ShaderValidator::Visit(const ShaderNodes::AccessMember& node) + { + const ShaderExpressionType& exprType = MandatoryExpr(node.structExpr)->GetExpressionType(); + if (!std::holds_alternative(exprType)) + throw AstError{ "expression is not a structure" }; + + const std::string& structName = std::get(exprType); + + const auto& structs = m_shader.GetStructs(); + auto it = std::find_if(structs.begin(), structs.end(), [&](const auto& s) { return s.name == structName; }); + if (it == structs.end()) + throw AstError{ "invalid structure" }; + + const ShaderAst::Struct& s = *it; + if (node.memberIndex >= s.members.size()) + throw AstError{ "member index out of bounds" }; + + const auto& member = s.members[node.memberIndex]; + if (member.type != node.exprType) + throw AstError{ "member type does not match node type" }; + } + void ShaderValidator::Visit(const ShaderNodes::AssignOp& node) { MandatoryNode(node.left); @@ -101,8 +123,16 @@ namespace Nz MandatoryNode(node.left); MandatoryNode(node.right); - ShaderNodes::BasicType leftType = node.left->GetExpressionType(); - ShaderNodes::BasicType rightType = node.right->GetExpressionType(); + const ShaderExpressionType& leftExprType = MandatoryExpr(node.left)->GetExpressionType(); + if (!std::holds_alternative(leftExprType)) + throw AstError{ "left expression type does not support binary operation" }; + + const ShaderExpressionType& rightExprType = MandatoryExpr(node.right)->GetExpressionType(); + if (!std::holds_alternative(rightExprType)) + throw AstError{ "right expression type does not support binary operation" }; + + ShaderNodes::BasicType leftType = std::get(leftExprType); + ShaderNodes::BasicType rightType = std::get(rightExprType); switch (node.op) { @@ -179,7 +209,11 @@ namespace Nz if (!exprPtr) break; - componentCount += node.GetComponentCount(exprPtr->GetExpressionType()); + const ShaderExpressionType& exprType = exprPtr->GetExpressionType(); + if (!std::holds_alternative(exprType)) + throw AstError{ "incompatible type" }; + + componentCount += node.GetComponentCount(std::get(exprType)); Visit(exprPtr); } @@ -318,7 +352,7 @@ namespace Nz for (auto& param : node.parameters) MandatoryNode(param); - ShaderNodes::BasicType type = node.parameters.front()->GetExpressionType(); + ShaderExpressionType type = node.parameters.front()->GetExpressionType(); for (std::size_t i = 1; i < node.parameters.size(); ++i) { if (type != node.parameters[i]->GetExpressionType()) @@ -333,7 +367,7 @@ namespace Nz { case ShaderNodes::IntrinsicType::CrossProduct: { - if (node.parameters[0]->GetExpressionType() != ShaderNodes::BasicType::Float3) + if (node.parameters[0]->GetExpressionType() != ShaderExpressionType{ ShaderNodes::BasicType::Float3 }) throw AstError{ "CrossProduct only works with Float3 expressions" }; break; @@ -349,10 +383,10 @@ namespace Nz void ShaderValidator::Visit(const ShaderNodes::Sample2D& node) { - if (MandatoryExpr(node.sampler)->GetExpressionType() != ShaderNodes::BasicType::Sampler2D) + if (MandatoryExpr(node.sampler)->GetExpressionType() != ShaderExpressionType{ ShaderNodes::BasicType::Sampler2D }) throw AstError{ "Sampler must be a Sampler2D" }; - if (MandatoryExpr(node.coordinates)->GetExpressionType() != ShaderNodes::BasicType::Float2) + if (MandatoryExpr(node.coordinates)->GetExpressionType() != ShaderExpressionType{ ShaderNodes::BasicType::Float2 }) throw AstError{ "Coordinates must be a Float2" }; Visit(node.sampler); @@ -378,7 +412,11 @@ namespace Nz if (node.componentCount > 4) throw AstError{ "Cannot swizzle more than four elements" }; - switch (MandatoryExpr(node.expression)->GetExpressionType()) + const ShaderExpressionType& exprType = MandatoryExpr(node.expression)->GetExpressionType(); + if (!std::holds_alternative(exprType)) + throw AstError{ "Cannot swizzle this type" }; + + switch (std::get(exprType)) { case ShaderNodes::BasicType::Float1: case ShaderNodes::BasicType::Float2: From 5258f0b61a6e596d76e0884c38a1af35d56b7377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sun, 19 Jul 2020 21:08:21 +0200 Subject: [PATCH 263/316] ShaderNodes: Add BufferField node --- src/ShaderNode/DataModels/BufferField.cpp | 409 ++++++++++++++++++++++ src/ShaderNode/DataModels/BufferField.hpp | 67 ++++ src/ShaderNode/DataModels/BufferField.inl | 2 + src/ShaderNode/DataTypes/BoolData.cpp | 1 + src/ShaderNode/DataTypes/BoolData.hpp | 28 ++ src/ShaderNode/DataTypes/BoolData.inl | 7 + 6 files changed, 514 insertions(+) create mode 100644 src/ShaderNode/DataModels/BufferField.cpp create mode 100644 src/ShaderNode/DataModels/BufferField.hpp create mode 100644 src/ShaderNode/DataModels/BufferField.inl create mode 100644 src/ShaderNode/DataTypes/BoolData.cpp create mode 100644 src/ShaderNode/DataTypes/BoolData.hpp create mode 100644 src/ShaderNode/DataTypes/BoolData.inl diff --git a/src/ShaderNode/DataModels/BufferField.cpp b/src/ShaderNode/DataModels/BufferField.cpp new file mode 100644 index 000000000..c9d81bdcd --- /dev/null +++ b/src/ShaderNode/DataModels/BufferField.cpp @@ -0,0 +1,409 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +BufferField::BufferField(ShaderGraph& graph) : +ShaderNode(graph) +{ + m_onBufferListUpdateSlot.Connect(GetGraph().OnBufferListUpdate, [&](ShaderGraph*) { UpdateCurrentBufferIndex(); }); + m_onBufferUpdateSlot.Connect(GetGraph().OnBufferUpdate, [&](ShaderGraph*, std::size_t bufferIndex) + { + if (m_currentBufferIndex == bufferIndex) + { + UpdatePreview(); + Q_EMIT dataUpdated(0); + } + }); + + if (graph.GetBufferCount() > 0) + { + m_currentBufferIndex = 0; + UpdateBufferText(); + } + + DisableCustomVariableName(); + UpdatePreview(); +} + +unsigned int BufferField::nPorts(QtNodes::PortType portType) const +{ + switch (portType) + { + case QtNodes::PortType::In: return 0; + case QtNodes::PortType::Out: return 1; + } + + return 0; +} + +bool BufferField::ComputePreview(QPixmap& pixmap) +{ + return false; + + /*if (!m_currentBufferIndex) + return false; + + const ShaderGraph& graph = GetGraph(); + const auto& inputEntry = graph.GetBuffer(*m_currentBufferIndex); + const auto& preview = graph.GetPreviewModel(); + + pixmap = QPixmap::fromImage(preview.GetPreview(inputEntry.role, inputEntry.roleIndex).GenerateImage()); + return true;*/ +} + +void BufferField::UpdateCurrentBufferIndex() +{ + Nz::CallOnExit resetIfNotFound([&] + { + m_currentBufferIndex.reset(); + m_currentBufferText.clear(); + m_currentFieldIndex.reset(); + m_currentFieldText.clear(); + }); + + if (m_currentBufferText.empty()) + return; + + std::size_t bufferIndex = 0; + for (const auto& bufferEntry : GetGraph().GetBuffers()) + { + if (bufferEntry.name == m_currentBufferText) + { + m_currentBufferIndex = bufferIndex; + resetIfNotFound.Reset(); + break; + } + + bufferIndex++; + } +} + +void BufferField::UpdateCurrentFieldIndex() +{ + Nz::CallOnExit resetIfNotFound([&] + { + m_currentFieldIndex.reset(); + m_currentFieldText.clear(); + }); + + if (m_currentFieldText.empty()) + return; + + if (!m_currentFieldIndex) + m_currentFieldIndex.emplace(); + + CurrentField& currentField = *m_currentFieldIndex; + currentField.nestedFields.clear(); + + const ShaderGraph& graph = GetGraph(); + auto& buffer = graph.GetBuffer(*m_currentBufferIndex); + + std::function FetchField; + FetchField = [&](std::size_t structIndex, const std::string& prefix) -> bool + { + const auto& s = graph.GetStruct(structIndex); + for (auto it = s.members.begin(); it != s.members.end(); ++it) + { + const auto& member = *it; + + bool found = std::visit([&](auto&& arg) -> bool + { + using T = std::decay_t; + if constexpr (std::is_same_v) + { + if (prefix + member.name == m_currentFieldText) + { + currentField.finalFieldIndex = std::distance(s.members.begin(), it); + return true; + } + else + return false; + } + else if constexpr (std::is_same_v) + { + currentField.nestedFields.push_back(std::distance(s.members.begin(), it)); + bool found = FetchField(arg, prefix + member.name + "."); + if (!found) + { + currentField.nestedFields.pop_back(); + return false; + } + + return true; + } + else + static_assert(Nz::AlwaysFalse::value, "non-exhaustive visitor"); + }, + member.type); + + if (found) + return true; + } + + return false; + }; + + if (FetchField(buffer.structIndex, "")) + resetIfNotFound.Reset(); +} + +void BufferField::PopulateField(QComboBox* fieldList, std::size_t structIndex, const std::string& prefix) +{ + const auto& s = GetGraph().GetStruct(structIndex); + for (const auto& member : s.members) + { + std::visit([&](auto&& arg) + { + using T = std::decay_t; + if constexpr (std::is_same_v) + fieldList->addItem(QString::fromStdString(prefix + member.name)); + else if constexpr (std::is_same_v) + PopulateField(fieldList, arg, prefix + member.name + "."); + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + }, + member.type); + } +} + +const ShaderGraph::StructMemberEntry& BufferField::RetrieveNestedMember() const +{ + const ShaderGraph& graph = GetGraph(); + auto& buffer = graph.GetBuffer(*m_currentBufferIndex); + + assert(m_currentFieldIndex); + const CurrentField& currentField = *m_currentFieldIndex; + + const ShaderGraph::StructEntry* structEntry = &graph.GetStruct(buffer.structIndex); + for (std::size_t nestedIndex : currentField.nestedFields) + { + assert(nestedIndex < structEntry->members.size()); + const auto& memberEntry = structEntry->members[nestedIndex]; + assert(std::holds_alternative(memberEntry.type)); + + std::size_t nestedStructIndex = std::get(memberEntry.type); + structEntry = &graph.GetStruct(nestedStructIndex); + } + + return structEntry->members[currentField.finalFieldIndex]; +} + +void BufferField::UpdateBufferText() +{ + if (m_currentBufferIndex) + { + auto& buffer = GetGraph().GetBuffer(*m_currentBufferIndex); + m_currentBufferText = buffer.name; + } + else + m_currentBufferText.clear(); +} + +void BufferField::BuildNodeEdition(QFormLayout* layout) +{ + ShaderNode::BuildNodeEdition(layout); + + QComboBox* fieldSelection = new QComboBox; + connect(fieldSelection, qOverload(&QComboBox::currentIndexChanged), [=](int index) + { + if (index >= 0) + m_currentFieldText = fieldSelection->itemText(index).toStdString(); + else + m_currentFieldText.clear(); + + UpdateCurrentFieldIndex(); + UpdatePreview(); + + Q_EMIT dataUpdated(0); + }); + + QComboBox* bufferSelection = new QComboBox; + for (const auto& inputEntry : GetGraph().GetBuffers()) + bufferSelection->addItem(QString::fromStdString(inputEntry.name)); + + connect(bufferSelection, qOverload(&QComboBox::currentIndexChanged), [=](int index) + { + fieldSelection->clear(); + fieldSelection->setCurrentIndex(-1); + + if (index >= 0) + { + m_currentBufferIndex = static_cast(index); + + const ShaderGraph& graph = GetGraph(); + const auto& buffer = graph.GetBuffer(*m_currentBufferIndex); + PopulateField(fieldSelection, buffer.structIndex); + } + else + m_currentBufferIndex.reset(); + + UpdateBufferText(); + }); + + if (m_currentBufferIndex) + { + int index = int(*m_currentBufferIndex); + QString currentFieldText = QString::fromStdString(m_currentFieldText); + + bufferSelection->setCurrentIndex(-1); + bufferSelection->setCurrentIndex(index); + + fieldSelection->setCurrentText(currentFieldText); + } + else + { + bufferSelection->setCurrentIndex(-1); + fieldSelection->setCurrentIndex(-1); + } + + layout->addRow(tr("Buffer"), bufferSelection); + layout->addRow(tr("Field"), fieldSelection); +} + +Nz::ShaderNodes::ExpressionPtr BufferField::GetExpression(Nz::ShaderNodes::ExpressionPtr* /*expressions*/, std::size_t count) const +{ + assert(count == 0); + + if (!m_currentBufferIndex) + throw std::runtime_error("no buffer"); + + const ShaderGraph& graph = GetGraph(); + + const auto& bufferEntry = graph.GetBuffer(*m_currentBufferIndex); + const auto& structEntry = graph.GetStruct(bufferEntry.structIndex); + + Nz::ShaderNodes::VariablePtr varPtr; + switch (bufferEntry.type) + { + case BufferType::UniformBufferObject: + varPtr = Nz::ShaderBuilder::Uniform(bufferEntry.name, structEntry.name); + break; + } + + assert(varPtr); + + assert(m_currentFieldIndex); + const CurrentField& currentField = *m_currentFieldIndex; + + Nz::ShaderNodes::ExpressionPtr sourceExpr = Nz::ShaderBuilder::Identifier(varPtr); + + const ShaderGraph::StructEntry* sourceStruct = &structEntry; + for (std::size_t nestedIndex : currentField.nestedFields) + { + assert(nestedIndex < sourceStruct->members.size()); + const auto& memberEntry = sourceStruct->members[nestedIndex]; + assert(std::holds_alternative(memberEntry.type)); + + std::size_t nestedStructIndex = std::get(memberEntry.type); + sourceStruct = &graph.GetStruct(nestedStructIndex); + + sourceExpr = Nz::ShaderBuilder::AccessMember(std::move(sourceExpr), 0, graph.ToShaderExpressionType(memberEntry.type)); + } + + assert(currentField.finalFieldIndex < sourceStruct->members.size()); + const auto& memberEntry = sourceStruct->members[currentField.finalFieldIndex]; + assert(std::holds_alternative(memberEntry.type)); + + return Nz::ShaderBuilder::AccessMember(std::move(sourceExpr), 0, graph.ToShaderExpressionType(std::get(memberEntry.type))); +} + +auto BufferField::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const -> QtNodes::NodeDataType +{ + assert(portType == QtNodes::PortType::Out); + assert(portIndex == 0); + + if (!m_currentBufferIndex || !m_currentFieldIndex) + return VecData::Type(); + + const auto& member = RetrieveNestedMember(); + assert(std::holds_alternative(member.type)); + + switch (std::get(member.type)) + { + case PrimitiveType::Bool: + return BoolData::Type(); + + case PrimitiveType::Float1: + return FloatData::Type(); + + case PrimitiveType::Float2: + case PrimitiveType::Float3: + case PrimitiveType::Float4: + return VecData::Type(); + } + + assert(false); + throw std::runtime_error("Unhandled primitive type"); +} + +std::shared_ptr BufferField::outData(QtNodes::PortIndex port) +{ + if (!m_currentBufferIndex) + return nullptr; + + assert(port == 0); + + if (!m_currentBufferIndex || !m_currentFieldIndex) + return {}; + + const auto& member = RetrieveNestedMember(); + assert(std::holds_alternative(member.type)); + + switch (std::get(member.type)) + { + case PrimitiveType::Bool: return std::make_shared(); + case PrimitiveType::Float1: return std::make_shared(); + case PrimitiveType::Float2: return std::make_shared(2); + case PrimitiveType::Float3: return std::make_shared(3); + case PrimitiveType::Float4: return std::make_shared(4); + } + + assert(false); + throw std::runtime_error("Unhandled primitive type"); +} + +QtNodes::NodeValidationState BufferField::validationState() const +{ + if (!m_currentBufferIndex) + return QtNodes::NodeValidationState::Error; + + if (!m_currentFieldIndex) + return QtNodes::NodeValidationState::Error; + + return QtNodes::NodeValidationState::Valid; +} + +QString BufferField::validationMessage() const +{ + if (!m_currentBufferIndex) + return "No input selected"; + + if (!m_currentFieldIndex) + return "No field selected"; + + return QString(); +} + +void BufferField::restore(const QJsonObject& data) +{ + m_currentBufferText = data["buffer"].toString().toStdString(); + m_currentFieldText = data["field"].toString().toStdString(); + UpdateCurrentBufferIndex(); + + ShaderNode::restore(data); +} + +QJsonObject BufferField::save() const +{ + QJsonObject data = ShaderNode::save(); + data["buffer"] = QString::fromStdString(m_currentBufferText); + data["field"] = QString::fromStdString(m_currentFieldText); + + return data; +} diff --git a/src/ShaderNode/DataModels/BufferField.hpp b/src/ShaderNode/DataModels/BufferField.hpp new file mode 100644 index 000000000..304165386 --- /dev/null +++ b/src/ShaderNode/DataModels/BufferField.hpp @@ -0,0 +1,67 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_BUFFERFIELD_HPP +#define NAZARA_SHADERNODES_BUFFERFIELD_HPP + +#include +#include +#include +#include +#include +#include +#include + +class BufferField : public ShaderNode +{ + public: + BufferField(ShaderGraph& graph); + ~BufferField() = default; + + void BuildNodeEdition(QFormLayout* layout) override; + + Nz::ShaderNodes::ExpressionPtr GetExpression(Nz::ShaderNodes::ExpressionPtr* /*expressions*/, std::size_t count) const override; + + QString caption() const override { return "BufferField"; } + QString name() const override { return "BufferField"; } + + unsigned int nPorts(QtNodes::PortType portType) const override; + + QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; + + std::shared_ptr outData(QtNodes::PortIndex port) override; + + QtNodes::NodeValidationState validationState() const override; + QString validationMessage() const override; + + private: + bool ComputePreview(QPixmap& pixmap) override; + void UpdateCurrentBufferIndex(); + void UpdateCurrentFieldIndex(); + void PopulateField(QComboBox* fieldList, std::size_t structIndex, const std::string& prefix = ""); + const ShaderGraph::StructMemberEntry& RetrieveNestedMember() const; + void UpdateBufferText(); + + void restore(const QJsonObject& data) override; + QJsonObject save() const override; + + NazaraSlot(ShaderGraph, OnBufferListUpdate, m_onBufferListUpdateSlot); + NazaraSlot(ShaderGraph, OnBufferUpdate, m_onBufferUpdateSlot); + + NazaraSlot(ShaderGraph, OnStructListUpdate, m_onStructListUpdateSlot); + NazaraSlot(ShaderGraph, OnStructUpdate, m_onStructUpdateSlot); + + struct CurrentField + { + std::vector nestedFields; + std::size_t finalFieldIndex; + }; + + std::optional m_currentBufferIndex; + std::optional m_currentFieldIndex; + std::string m_currentBufferText; + std::string m_currentFieldText; +}; + +#include + +#endif diff --git a/src/ShaderNode/DataModels/BufferField.inl b/src/ShaderNode/DataModels/BufferField.inl new file mode 100644 index 000000000..67cd1a5e7 --- /dev/null +++ b/src/ShaderNode/DataModels/BufferField.inl @@ -0,0 +1,2 @@ +#include +#include diff --git a/src/ShaderNode/DataTypes/BoolData.cpp b/src/ShaderNode/DataTypes/BoolData.cpp new file mode 100644 index 000000000..7c3123701 --- /dev/null +++ b/src/ShaderNode/DataTypes/BoolData.cpp @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/DataTypes/BoolData.hpp b/src/ShaderNode/DataTypes/BoolData.hpp new file mode 100644 index 000000000..adb410888 --- /dev/null +++ b/src/ShaderNode/DataTypes/BoolData.hpp @@ -0,0 +1,28 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_BOOLDATA_HPP +#define NAZARA_SHADERNODES_BOOLDATA_HPP + +#include +#include + +struct BoolData : public QtNodes::NodeData +{ + inline BoolData(); + + QtNodes::NodeDataType type() const override + { + return Type(); + } + + static QtNodes::NodeDataType Type() + { + return { "bool", "Bool" }; + } + + PreviewValues preview; +}; + +#include + +#endif diff --git a/src/ShaderNode/DataTypes/BoolData.inl b/src/ShaderNode/DataTypes/BoolData.inl new file mode 100644 index 000000000..c12b8f72c --- /dev/null +++ b/src/ShaderNode/DataTypes/BoolData.inl @@ -0,0 +1,7 @@ +#include + +inline BoolData::BoolData() : +preview(1, 1) +{ + preview(0, 0) = Nz::Vector4f(1.f, 1.f, 1.f, 0.f); +} From e342c88e64b47f3f8b65fd01e55e477896f2fcf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sun, 19 Jul 2020 21:08:25 +0200 Subject: [PATCH 264/316] ShaderNodes/InputValue: Fix output type when using Float1 --- src/ShaderNode/DataModels/InputValue.cpp | 18 ++++++++++++++---- src/ShaderNode/DataModels/InputValue.inl | 1 - 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/ShaderNode/DataModels/InputValue.cpp b/src/ShaderNode/DataModels/InputValue.cpp index f9337f262..1b33a8c9b 100644 --- a/src/ShaderNode/DataModels/InputValue.cpp +++ b/src/ShaderNode/DataModels/InputValue.cpp @@ -1,5 +1,5 @@ -#include #include +#include #include #include #include @@ -170,10 +170,20 @@ std::shared_ptr InputValue::outData(QtNodes::PortIndex port) const auto& inputEntry = graph.GetInput(*m_currentInputIndex); const auto& preview = graph.GetPreviewModel(); - auto vecData = std::make_shared(GetComponentCount(inputEntry.type)); - vecData->preview = preview.GetPreview(inputEntry.role, inputEntry.roleIndex); + if (inputEntry.type == PrimitiveType::Float1) + { + auto fData = std::make_shared(); + fData->preview = preview.GetPreview(inputEntry.role, inputEntry.roleIndex); - return vecData; + return fData; + } + else + { + auto vecData = std::make_shared(GetComponentCount(inputEntry.type)); + vecData->preview = preview.GetPreview(inputEntry.role, inputEntry.roleIndex); + + return vecData; + } } QtNodes::NodeValidationState InputValue::validationState() const diff --git a/src/ShaderNode/DataModels/InputValue.inl b/src/ShaderNode/DataModels/InputValue.inl index 344e3db41..ec5e2f581 100644 --- a/src/ShaderNode/DataModels/InputValue.inl +++ b/src/ShaderNode/DataModels/InputValue.inl @@ -1,2 +1 @@ #include -#include From 3c1c61fb5ef0b7d7150820f1d73858b45d47fd44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sun, 19 Jul 2020 21:08:43 +0200 Subject: [PATCH 265/316] Improve code --- src/ShaderNode/ShaderGraph.cpp | 45 +++++++++++++++++++++++++++ src/ShaderNode/ShaderGraph.hpp | 4 +++ src/ShaderNode/Widgets/MainWindow.cpp | 35 +++------------------ 3 files changed, 53 insertions(+), 31 deletions(-) diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp index 3648fed82..2d5ba933d 100644 --- a/src/ShaderNode/ShaderGraph.cpp +++ b/src/ShaderNode/ShaderGraph.cpp @@ -498,6 +498,24 @@ Nz::ShaderNodes::StatementPtr ShaderGraph::ToAst() return Nz::ShaderNodes::StatementBlock::Build(std::move(statements)); } +Nz::ShaderExpressionType ShaderGraph::ToShaderExpressionType(const std::variant& type) const +{ + return std::visit([&](auto&& arg) -> Nz::ShaderExpressionType + { + using T = std::decay_t; + if constexpr (std::is_same_v) + return ToShaderExpressionType(arg); + else if constexpr (std::is_same_v) + { + assert(arg < m_structs.size()); + const auto& s = m_structs[arg]; + return s.name; + } + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + }, type); +}; + void ShaderGraph::UpdateBuffer(std::size_t bufferIndex, std::string name, BufferType bufferType, std::size_t structIndex, std::size_t bindingIndex) { assert(bufferIndex < m_buffers.size()); @@ -565,9 +583,36 @@ void ShaderGraph::UpdateTexturePreview(std::size_t textureIndex, QImage preview) OnTexturePreviewUpdate(this, textureIndex); } +Nz::ShaderExpressionType ShaderGraph::ToShaderExpressionType(PrimitiveType type) +{ + switch (type) + { + case PrimitiveType::Bool: return Nz::ShaderNodes::BasicType::Boolean; + case PrimitiveType::Float1: return Nz::ShaderNodes::BasicType::Float1; + case PrimitiveType::Float2: return Nz::ShaderNodes::BasicType::Float2; + case PrimitiveType::Float3: return Nz::ShaderNodes::BasicType::Float3; + case PrimitiveType::Float4: return Nz::ShaderNodes::BasicType::Float4; + } + + assert(false); + throw std::runtime_error("Unhandled primitive type"); +} + +Nz::ShaderExpressionType ShaderGraph::ToShaderExpressionType(TextureType type) +{ + switch (type) + { + case TextureType::Sampler2D: return Nz::ShaderNodes::BasicType::Sampler2D; + } + + assert(false); + throw std::runtime_error("Unhandled texture type"); +} + std::shared_ptr ShaderGraph::BuildRegistry() { auto registry = std::make_shared(); + RegisterShaderNode(*this, registry, "Inputs"); RegisterShaderNode(*this, registry, "Casts"); RegisterShaderNode(*this, registry, "Casts"); RegisterShaderNode(*this, registry, "Casts"); diff --git a/src/ShaderNode/ShaderGraph.hpp b/src/ShaderNode/ShaderGraph.hpp index d0ff63316..0cab330d0 100644 --- a/src/ShaderNode/ShaderGraph.hpp +++ b/src/ShaderNode/ShaderGraph.hpp @@ -56,6 +56,7 @@ class ShaderGraph QJsonObject Save(); Nz::ShaderNodes::StatementPtr ToAst(); + Nz::ShaderExpressionType ToShaderExpressionType(const std::variant& type) const; void UpdateBuffer(std::size_t bufferIndex, std::string name, BufferType bufferType, std::size_t structIndex, std::size_t bindingIndex); void UpdateInput(std::size_t inputIndex, std::string name, PrimitiveType type, InputRole role, std::size_t roleIndex, std::size_t locationIndex); @@ -121,6 +122,9 @@ class ShaderGraph NazaraSignal(OnTexturePreviewUpdate, ShaderGraph*, std::size_t /*textureIndex*/); NazaraSignal(OnTextureUpdate, ShaderGraph*, std::size_t /*textureIndex*/); + static Nz::ShaderExpressionType ToShaderExpressionType(PrimitiveType type); + static Nz::ShaderExpressionType ToShaderExpressionType(TextureType type); + private: std::shared_ptr BuildRegistry(); diff --git a/src/ShaderNode/Widgets/MainWindow.cpp b/src/ShaderNode/Widgets/MainWindow.cpp index 813d1b5ab..7c7101047 100644 --- a/src/ShaderNode/Widgets/MainWindow.cpp +++ b/src/ShaderNode/Widgets/MainWindow.cpp @@ -212,39 +212,12 @@ Nz::ShaderAst MainWindow::ToShader() { Nz::ShaderNodes::StatementPtr shaderAst = m_shaderGraph.ToAst(); - //TODO: Put in another function - auto GetExpressionFromInOut = [&](PrimitiveType type) - { - switch (type) - { - case PrimitiveType::Bool: return Nz::ShaderNodes::BasicType::Boolean; - case PrimitiveType::Float1: return Nz::ShaderNodes::BasicType::Float1; - case PrimitiveType::Float2: return Nz::ShaderNodes::BasicType::Float2; - case PrimitiveType::Float3: return Nz::ShaderNodes::BasicType::Float3; - case PrimitiveType::Float4: return Nz::ShaderNodes::BasicType::Float4; - } - - assert(false); - throw std::runtime_error("Unhandled input type"); - }; - - auto GetExpressionFromTexture = [&](TextureType type) - { - switch (type) - { - case TextureType::Sampler2D: return Nz::ShaderNodes::BasicType::Sampler2D; - } - - assert(false); - throw std::runtime_error("Unhandled texture type"); - }; - Nz::ShaderAst shader; for (const auto& input : m_shaderGraph.GetInputs()) - shader.AddInput(input.name, GetExpressionFromInOut(input.type), input.locationIndex); + shader.AddInput(input.name, m_shaderGraph.ToShaderExpressionType(input.type), input.locationIndex); for (const auto& output : m_shaderGraph.GetOutputs()) - shader.AddOutput(output.name, GetExpressionFromInOut(output.type), output.locationIndex); + shader.AddOutput(output.name, m_shaderGraph.ToShaderExpressionType(output.type), output.locationIndex); for (const auto& buffer : m_shaderGraph.GetBuffers()) { @@ -253,7 +226,7 @@ Nz::ShaderAst MainWindow::ToShader() } for (const auto& uniform : m_shaderGraph.GetTextures()) - shader.AddUniform(uniform.name, GetExpressionFromTexture(uniform.type), uniform.bindingIndex, {}); + shader.AddUniform(uniform.name, m_shaderGraph.ToShaderExpressionType(uniform.type), uniform.bindingIndex, {}); for (const auto& s : m_shaderGraph.GetStructs()) { @@ -267,7 +240,7 @@ Nz::ShaderAst MainWindow::ToShader() { using T = std::decay_t; if constexpr (std::is_same_v) - member.type = GetExpressionFromInOut(arg); + member.type = m_shaderGraph.ToShaderExpressionType(arg); else if constexpr (std::is_same_v) member.type = m_shaderGraph.GetStruct(arg).name; else From 405c020125c2a49e266717b0afd8635e4fd3d55d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sun, 19 Jul 2020 21:08:53 +0200 Subject: [PATCH 266/316] Set some struct in default scene for testing --- src/ShaderNode/ShaderGraph.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp index 2d5ba933d..22d74dca2 100644 --- a/src/ShaderNode/ShaderGraph.cpp +++ b/src/ShaderNode/ShaderGraph.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -54,15 +55,22 @@ m_flowScene(BuildRegistry()) { "position", PrimitiveType::Float3 }, { "normal", PrimitiveType::Float3 }, { "uv", PrimitiveType::Float2 }, + { "inner", 2 } } }); - AddStruct("TestStruct2", { - { - { "position", PrimitiveType::Float3 }, - { "normal", PrimitiveType::Float3 }, - { "uv", PrimitiveType::Float2 }, - } + AddStruct("InnerStruct", { + { + { "a", PrimitiveType::Float3 }, + } }); + AddStruct("OuterStruct", { + { + { "a", 1 }, + { "b", PrimitiveType::Float1 } + } + }); + + AddBuffer("testUBO", BufferType::UniformBufferObject, 0, 0); UpdateTexturePreview(0, QImage(R"(C:\Users\Lynix\Pictures\potatavril.png)")); From 042eb067a05115bef05382e1b2bec1a8eba1e8c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Mon, 20 Jul 2020 11:21:31 +0200 Subject: [PATCH 267/316] Move and rename functions --- src/ShaderNode/DataModels/BufferField.cpp | 198 +++++++++++----------- src/ShaderNode/DataModels/BufferField.hpp | 4 +- 2 files changed, 101 insertions(+), 101 deletions(-) diff --git a/src/ShaderNode/DataModels/BufferField.cpp b/src/ShaderNode/DataModels/BufferField.cpp index c9d81bdcd..25b626f48 100644 --- a/src/ShaderNode/DataModels/BufferField.cpp +++ b/src/ShaderNode/DataModels/BufferField.cpp @@ -11,7 +11,7 @@ BufferField::BufferField(ShaderGraph& graph) : ShaderNode(graph) { - m_onBufferListUpdateSlot.Connect(GetGraph().OnBufferListUpdate, [&](ShaderGraph*) { UpdateCurrentBufferIndex(); }); + m_onBufferListUpdateSlot.Connect(GetGraph().OnBufferListUpdate, [&](ShaderGraph*) { UpdateBufferIndex(); }); m_onBufferUpdateSlot.Connect(GetGraph().OnBufferUpdate, [&](ShaderGraph*, std::size_t bufferIndex) { if (m_currentBufferIndex == bufferIndex) @@ -57,102 +57,6 @@ bool BufferField::ComputePreview(QPixmap& pixmap) return true;*/ } -void BufferField::UpdateCurrentBufferIndex() -{ - Nz::CallOnExit resetIfNotFound([&] - { - m_currentBufferIndex.reset(); - m_currentBufferText.clear(); - m_currentFieldIndex.reset(); - m_currentFieldText.clear(); - }); - - if (m_currentBufferText.empty()) - return; - - std::size_t bufferIndex = 0; - for (const auto& bufferEntry : GetGraph().GetBuffers()) - { - if (bufferEntry.name == m_currentBufferText) - { - m_currentBufferIndex = bufferIndex; - resetIfNotFound.Reset(); - break; - } - - bufferIndex++; - } -} - -void BufferField::UpdateCurrentFieldIndex() -{ - Nz::CallOnExit resetIfNotFound([&] - { - m_currentFieldIndex.reset(); - m_currentFieldText.clear(); - }); - - if (m_currentFieldText.empty()) - return; - - if (!m_currentFieldIndex) - m_currentFieldIndex.emplace(); - - CurrentField& currentField = *m_currentFieldIndex; - currentField.nestedFields.clear(); - - const ShaderGraph& graph = GetGraph(); - auto& buffer = graph.GetBuffer(*m_currentBufferIndex); - - std::function FetchField; - FetchField = [&](std::size_t structIndex, const std::string& prefix) -> bool - { - const auto& s = graph.GetStruct(structIndex); - for (auto it = s.members.begin(); it != s.members.end(); ++it) - { - const auto& member = *it; - - bool found = std::visit([&](auto&& arg) -> bool - { - using T = std::decay_t; - if constexpr (std::is_same_v) - { - if (prefix + member.name == m_currentFieldText) - { - currentField.finalFieldIndex = std::distance(s.members.begin(), it); - return true; - } - else - return false; - } - else if constexpr (std::is_same_v) - { - currentField.nestedFields.push_back(std::distance(s.members.begin(), it)); - bool found = FetchField(arg, prefix + member.name + "."); - if (!found) - { - currentField.nestedFields.pop_back(); - return false; - } - - return true; - } - else - static_assert(Nz::AlwaysFalse::value, "non-exhaustive visitor"); - }, - member.type); - - if (found) - return true; - } - - return false; - }; - - if (FetchField(buffer.structIndex, "")) - resetIfNotFound.Reset(); -} - void BufferField::PopulateField(QComboBox* fieldList, std::size_t structIndex, const std::string& prefix) { const auto& s = GetGraph().GetStruct(structIndex); @@ -194,6 +98,33 @@ const ShaderGraph::StructMemberEntry& BufferField::RetrieveNestedMember() const return structEntry->members[currentField.finalFieldIndex]; } +void BufferField::UpdateBufferIndex() +{ + Nz::CallOnExit resetIfNotFound([&] + { + m_currentBufferIndex.reset(); + m_currentBufferText.clear(); + m_currentFieldIndex.reset(); + m_currentFieldText.clear(); + }); + + if (m_currentBufferText.empty()) + return; + + std::size_t bufferIndex = 0; + for (const auto& bufferEntry : GetGraph().GetBuffers()) + { + if (bufferEntry.name == m_currentBufferText) + { + m_currentBufferIndex = bufferIndex; + resetIfNotFound.Reset(); + break; + } + + bufferIndex++; + } +} + void BufferField::UpdateBufferText() { if (m_currentBufferIndex) @@ -217,7 +148,7 @@ void BufferField::BuildNodeEdition(QFormLayout* layout) else m_currentFieldText.clear(); - UpdateCurrentFieldIndex(); + UpdateFieldIndex(); UpdatePreview(); Q_EMIT dataUpdated(0); @@ -266,6 +197,75 @@ void BufferField::BuildNodeEdition(QFormLayout* layout) layout->addRow(tr("Field"), fieldSelection); } +void BufferField::UpdateFieldIndex() +{ + Nz::CallOnExit resetIfNotFound([&] + { + m_currentFieldIndex.reset(); + m_currentFieldText.clear(); + }); + + if (m_currentFieldText.empty()) + return; + + if (!m_currentFieldIndex) + m_currentFieldIndex.emplace(); + + CurrentField& currentField = *m_currentFieldIndex; + currentField.nestedFields.clear(); + + const ShaderGraph& graph = GetGraph(); + auto& buffer = graph.GetBuffer(*m_currentBufferIndex); + + std::function FetchField; + FetchField = [&](std::size_t structIndex, const std::string& prefix) -> bool + { + const auto& s = graph.GetStruct(structIndex); + for (auto it = s.members.begin(); it != s.members.end(); ++it) + { + const auto& member = *it; + + bool found = std::visit([&](auto&& arg) -> bool + { + using T = std::decay_t; + if constexpr (std::is_same_v) + { + if (prefix + member.name == m_currentFieldText) + { + currentField.finalFieldIndex = std::distance(s.members.begin(), it); + return true; + } + else + return false; + } + else if constexpr (std::is_same_v) + { + currentField.nestedFields.push_back(std::distance(s.members.begin(), it)); + bool found = FetchField(arg, prefix + member.name + "."); + if (!found) + { + currentField.nestedFields.pop_back(); + return false; + } + + return true; + } + else + static_assert(Nz::AlwaysFalse::value, "non-exhaustive visitor"); + }, + member.type); + + if (found) + return true; + } + + return false; + }; + + if (FetchField(buffer.structIndex, "")) + resetIfNotFound.Reset(); +} + Nz::ShaderNodes::ExpressionPtr BufferField::GetExpression(Nz::ShaderNodes::ExpressionPtr* /*expressions*/, std::size_t count) const { assert(count == 0); @@ -394,7 +394,7 @@ void BufferField::restore(const QJsonObject& data) { m_currentBufferText = data["buffer"].toString().toStdString(); m_currentFieldText = data["field"].toString().toStdString(); - UpdateCurrentBufferIndex(); + UpdateBufferIndex(); ShaderNode::restore(data); } diff --git a/src/ShaderNode/DataModels/BufferField.hpp b/src/ShaderNode/DataModels/BufferField.hpp index 304165386..d4d77bb1d 100644 --- a/src/ShaderNode/DataModels/BufferField.hpp +++ b/src/ShaderNode/DataModels/BufferField.hpp @@ -35,11 +35,11 @@ class BufferField : public ShaderNode private: bool ComputePreview(QPixmap& pixmap) override; - void UpdateCurrentBufferIndex(); - void UpdateCurrentFieldIndex(); void PopulateField(QComboBox* fieldList, std::size_t structIndex, const std::string& prefix = ""); const ShaderGraph::StructMemberEntry& RetrieveNestedMember() const; + void UpdateBufferIndex(); void UpdateBufferText(); + void UpdateFieldIndex(); void restore(const QJsonObject& data) override; QJsonObject save() const override; From 5ce67f434b7f74eaf47f9953e3e1178f91014337 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Mon, 20 Jul 2020 20:41:22 +0200 Subject: [PATCH 268/316] Finish BufferField --- src/ShaderNode/DataModels/BufferField.cpp | 511 ++++++++++++---------- src/ShaderNode/DataModels/BufferField.hpp | 9 +- src/ShaderNode/DataModels/ShaderNode.cpp | 8 +- src/ShaderNode/DataModels/ShaderNode.hpp | 6 +- 4 files changed, 299 insertions(+), 235 deletions(-) diff --git a/src/ShaderNode/DataModels/BufferField.cpp b/src/ShaderNode/DataModels/BufferField.cpp index 25b626f48..a8399509c 100644 --- a/src/ShaderNode/DataModels/BufferField.cpp +++ b/src/ShaderNode/DataModels/BufferField.cpp @@ -7,6 +7,7 @@ #include #include #include +#include BufferField::BufferField(ShaderGraph& graph) : ShaderNode(graph) @@ -17,20 +18,78 @@ ShaderNode(graph) if (m_currentBufferIndex == bufferIndex) { UpdatePreview(); + Q_EMIT dataUpdated(0); } }); - if (graph.GetBufferCount() > 0) + m_onStructListUpdateSlot.Connect(GetGraph().OnStructListUpdate, [&](ShaderGraph*) { - m_currentBufferIndex = 0; - UpdateBufferText(); - } + UpdateFieldIndex(); + UpdatePreview(); + + Q_EMIT dataUpdated(0); + }); + + m_onStructUpdateSlot.Connect(GetGraph().OnStructUpdate, [&](ShaderGraph*, std::size_t) + { + UpdateFieldIndex(); + UpdatePreview(); + + Q_EMIT dataUpdated(0); + }); DisableCustomVariableName(); UpdatePreview(); } +Nz::ShaderNodes::ExpressionPtr BufferField::GetExpression(Nz::ShaderNodes::ExpressionPtr* /*expressions*/, std::size_t count) const +{ + assert(count == 0); + + if (!m_currentBufferIndex) + throw std::runtime_error("no buffer"); + + const ShaderGraph& graph = GetGraph(); + + const auto& bufferEntry = graph.GetBuffer(*m_currentBufferIndex); + const auto& structEntry = graph.GetStruct(bufferEntry.structIndex); + + Nz::ShaderNodes::VariablePtr varPtr; + switch (bufferEntry.type) + { + case BufferType::UniformBufferObject: + varPtr = Nz::ShaderBuilder::Uniform(bufferEntry.name, structEntry.name); + break; + } + + assert(varPtr); + + assert(m_currentFieldIndex); + const CurrentField& currentField = *m_currentFieldIndex; + + Nz::ShaderNodes::ExpressionPtr sourceExpr = Nz::ShaderBuilder::Identifier(varPtr); + + const ShaderGraph::StructEntry* sourceStruct = &structEntry; + for (std::size_t nestedIndex : currentField.nestedFields) + { + assert(nestedIndex < sourceStruct->members.size()); + const auto& memberEntry = sourceStruct->members[nestedIndex]; + assert(std::holds_alternative(memberEntry.type)); + + std::size_t nestedStructIndex = std::get(memberEntry.type); + sourceStruct = &graph.GetStruct(nestedStructIndex); + + sourceExpr = Nz::ShaderBuilder::AccessMember(std::move(sourceExpr), 0, graph.ToShaderExpressionType(memberEntry.type)); + } + + assert(currentField.finalFieldIndex < sourceStruct->members.size()); + const auto& memberEntry = sourceStruct->members[currentField.finalFieldIndex]; + assert(std::holds_alternative(memberEntry.type)); + + return Nz::ShaderBuilder::AccessMember(std::move(sourceExpr), 0, graph.ToShaderExpressionType(std::get(memberEntry.type))); +} + unsigned int BufferField::nPorts(QtNodes::PortType portType) const { switch (portType) @@ -42,100 +101,6 @@ unsigned int BufferField::nPorts(QtNodes::PortType portType) const return 0; } -bool BufferField::ComputePreview(QPixmap& pixmap) -{ - return false; - - /*if (!m_currentBufferIndex) - return false; - - const ShaderGraph& graph = GetGraph(); - const auto& inputEntry = graph.GetBuffer(*m_currentBufferIndex); - const auto& preview = graph.GetPreviewModel(); - - pixmap = QPixmap::fromImage(preview.GetPreview(inputEntry.role, inputEntry.roleIndex).GenerateImage()); - return true;*/ -} - -void BufferField::PopulateField(QComboBox* fieldList, std::size_t structIndex, const std::string& prefix) -{ - const auto& s = GetGraph().GetStruct(structIndex); - for (const auto& member : s.members) - { - std::visit([&](auto&& arg) - { - using T = std::decay_t; - if constexpr (std::is_same_v) - fieldList->addItem(QString::fromStdString(prefix + member.name)); - else if constexpr (std::is_same_v) - PopulateField(fieldList, arg, prefix + member.name + "."); - else - static_assert(AlwaysFalse::value, "non-exhaustive visitor"); - }, - member.type); - } -} - -const ShaderGraph::StructMemberEntry& BufferField::RetrieveNestedMember() const -{ - const ShaderGraph& graph = GetGraph(); - auto& buffer = graph.GetBuffer(*m_currentBufferIndex); - - assert(m_currentFieldIndex); - const CurrentField& currentField = *m_currentFieldIndex; - - const ShaderGraph::StructEntry* structEntry = &graph.GetStruct(buffer.structIndex); - for (std::size_t nestedIndex : currentField.nestedFields) - { - assert(nestedIndex < structEntry->members.size()); - const auto& memberEntry = structEntry->members[nestedIndex]; - assert(std::holds_alternative(memberEntry.type)); - - std::size_t nestedStructIndex = std::get(memberEntry.type); - structEntry = &graph.GetStruct(nestedStructIndex); - } - - return structEntry->members[currentField.finalFieldIndex]; -} - -void BufferField::UpdateBufferIndex() -{ - Nz::CallOnExit resetIfNotFound([&] - { - m_currentBufferIndex.reset(); - m_currentBufferText.clear(); - m_currentFieldIndex.reset(); - m_currentFieldText.clear(); - }); - - if (m_currentBufferText.empty()) - return; - - std::size_t bufferIndex = 0; - for (const auto& bufferEntry : GetGraph().GetBuffers()) - { - if (bufferEntry.name == m_currentBufferText) - { - m_currentBufferIndex = bufferIndex; - resetIfNotFound.Reset(); - break; - } - - bufferIndex++; - } -} - -void BufferField::UpdateBufferText() -{ - if (m_currentBufferIndex) - { - auto& buffer = GetGraph().GetBuffer(*m_currentBufferIndex); - m_currentBufferText = buffer.name; - } - else - m_currentBufferText.clear(); -} - void BufferField::BuildNodeEdition(QFormLayout* layout) { ShaderNode::BuildNodeEdition(layout); @@ -197,122 +162,6 @@ void BufferField::BuildNodeEdition(QFormLayout* layout) layout->addRow(tr("Field"), fieldSelection); } -void BufferField::UpdateFieldIndex() -{ - Nz::CallOnExit resetIfNotFound([&] - { - m_currentFieldIndex.reset(); - m_currentFieldText.clear(); - }); - - if (m_currentFieldText.empty()) - return; - - if (!m_currentFieldIndex) - m_currentFieldIndex.emplace(); - - CurrentField& currentField = *m_currentFieldIndex; - currentField.nestedFields.clear(); - - const ShaderGraph& graph = GetGraph(); - auto& buffer = graph.GetBuffer(*m_currentBufferIndex); - - std::function FetchField; - FetchField = [&](std::size_t structIndex, const std::string& prefix) -> bool - { - const auto& s = graph.GetStruct(structIndex); - for (auto it = s.members.begin(); it != s.members.end(); ++it) - { - const auto& member = *it; - - bool found = std::visit([&](auto&& arg) -> bool - { - using T = std::decay_t; - if constexpr (std::is_same_v) - { - if (prefix + member.name == m_currentFieldText) - { - currentField.finalFieldIndex = std::distance(s.members.begin(), it); - return true; - } - else - return false; - } - else if constexpr (std::is_same_v) - { - currentField.nestedFields.push_back(std::distance(s.members.begin(), it)); - bool found = FetchField(arg, prefix + member.name + "."); - if (!found) - { - currentField.nestedFields.pop_back(); - return false; - } - - return true; - } - else - static_assert(Nz::AlwaysFalse::value, "non-exhaustive visitor"); - }, - member.type); - - if (found) - return true; - } - - return false; - }; - - if (FetchField(buffer.structIndex, "")) - resetIfNotFound.Reset(); -} - -Nz::ShaderNodes::ExpressionPtr BufferField::GetExpression(Nz::ShaderNodes::ExpressionPtr* /*expressions*/, std::size_t count) const -{ - assert(count == 0); - - if (!m_currentBufferIndex) - throw std::runtime_error("no buffer"); - - const ShaderGraph& graph = GetGraph(); - - const auto& bufferEntry = graph.GetBuffer(*m_currentBufferIndex); - const auto& structEntry = graph.GetStruct(bufferEntry.structIndex); - - Nz::ShaderNodes::VariablePtr varPtr; - switch (bufferEntry.type) - { - case BufferType::UniformBufferObject: - varPtr = Nz::ShaderBuilder::Uniform(bufferEntry.name, structEntry.name); - break; - } - - assert(varPtr); - - assert(m_currentFieldIndex); - const CurrentField& currentField = *m_currentFieldIndex; - - Nz::ShaderNodes::ExpressionPtr sourceExpr = Nz::ShaderBuilder::Identifier(varPtr); - - const ShaderGraph::StructEntry* sourceStruct = &structEntry; - for (std::size_t nestedIndex : currentField.nestedFields) - { - assert(nestedIndex < sourceStruct->members.size()); - const auto& memberEntry = sourceStruct->members[nestedIndex]; - assert(std::holds_alternative(memberEntry.type)); - - std::size_t nestedStructIndex = std::get(memberEntry.type); - sourceStruct = &graph.GetStruct(nestedStructIndex); - - sourceExpr = Nz::ShaderBuilder::AccessMember(std::move(sourceExpr), 0, graph.ToShaderExpressionType(memberEntry.type)); - } - - assert(currentField.finalFieldIndex < sourceStruct->members.size()); - const auto& memberEntry = sourceStruct->members[currentField.finalFieldIndex]; - assert(std::holds_alternative(memberEntry.type)); - - return Nz::ShaderBuilder::AccessMember(std::move(sourceExpr), 0, graph.ToShaderExpressionType(std::get(memberEntry.type))); -} - auto BufferField::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const -> QtNodes::NodeDataType { assert(portType == QtNodes::PortType::Out); @@ -342,6 +191,55 @@ auto BufferField::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIn throw std::runtime_error("Unhandled primitive type"); } +QString BufferField::portCaption(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const +{ + assert(portType == QtNodes::PortType::Out); + assert(portIndex == 0); + + if (!m_currentBufferIndex || !m_currentFieldIndex) + return ""; + + std::stringstream ss; + + const ShaderGraph& graph = GetGraph(); + + const auto& bufferEntry = graph.GetBuffer(*m_currentBufferIndex); + const auto& structEntry = graph.GetStruct(bufferEntry.structIndex); + + ss << bufferEntry.name << "."; + + const CurrentField& currentField = *m_currentFieldIndex; + + const ShaderGraph::StructEntry* sourceStruct = &structEntry; + for (std::size_t nestedIndex : currentField.nestedFields) + { + assert(nestedIndex < sourceStruct->members.size()); + const auto& memberEntry = sourceStruct->members[nestedIndex]; + assert(std::holds_alternative(memberEntry.type)); + + std::size_t nestedStructIndex = std::get(memberEntry.type); + sourceStruct = &graph.GetStruct(nestedStructIndex); + + ss << memberEntry.name << "."; + } + + assert(currentField.finalFieldIndex < sourceStruct->members.size()); + const auto& memberEntry = sourceStruct->members[currentField.finalFieldIndex]; + assert(std::holds_alternative(memberEntry.type)); + + ss << memberEntry.name; + + return QString::fromStdString(ss.str()); +} + +bool BufferField::portCaptionVisible(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const +{ + assert(portType == QtNodes::PortType::Out); + assert(portIndex == 0); + + return true; +} + std::shared_ptr BufferField::outData(QtNodes::PortIndex port) { if (!m_currentBufferIndex) @@ -368,6 +266,24 @@ std::shared_ptr BufferField::outData(QtNodes::PortIndex port) throw std::runtime_error("Unhandled primitive type"); } +void BufferField::restore(const QJsonObject& data) +{ + m_currentBufferText = data["buffer"].toString().toStdString(); + m_currentFieldText = data["field"].toString().toStdString(); + UpdateBufferIndex(); + + ShaderNode::restore(data); +} + +QJsonObject BufferField::save() const +{ + QJsonObject data = ShaderNode::save(); + data["buffer"] = QString::fromStdString(m_currentBufferText); + data["field"] = QString::fromStdString(m_currentFieldText); + + return data; +} + QtNodes::NodeValidationState BufferField::validationState() const { if (!m_currentBufferIndex) @@ -390,20 +306,165 @@ QString BufferField::validationMessage() const return QString(); } -void BufferField::restore(const QJsonObject& data) +bool BufferField::ComputePreview(QPixmap& pixmap) { - m_currentBufferText = data["buffer"].toString().toStdString(); - m_currentFieldText = data["field"].toString().toStdString(); - UpdateBufferIndex(); + return false; - ShaderNode::restore(data); + /*if (!m_currentBufferIndex) + return false; + + const ShaderGraph& graph = GetGraph(); + const auto& inputEntry = graph.GetBuffer(*m_currentBufferIndex); + const auto& preview = graph.GetPreviewModel(); + + pixmap = QPixmap::fromImage(preview.GetPreview(inputEntry.role, inputEntry.roleIndex).GenerateImage()); + return true;*/ } -QJsonObject BufferField::save() const +void BufferField::PopulateField(QComboBox* fieldList, std::size_t structIndex, const std::string& prefix) { - QJsonObject data = ShaderNode::save(); - data["buffer"] = QString::fromStdString(m_currentBufferText); - data["field"] = QString::fromStdString(m_currentFieldText); - - return data; + const auto& s = GetGraph().GetStruct(structIndex); + for (const auto& member : s.members) + { + std::visit([&](auto&& arg) + { + using T = std::decay_t; + if constexpr (std::is_same_v) + fieldList->addItem(QString::fromStdString(prefix + member.name)); + else if constexpr (std::is_same_v) + PopulateField(fieldList, arg, prefix + member.name + "."); + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + }, + member.type); + } +} + +const ShaderGraph::StructMemberEntry& BufferField::RetrieveNestedMember() const +{ + const ShaderGraph& graph = GetGraph(); + auto& buffer = graph.GetBuffer(*m_currentBufferIndex); + + assert(m_currentFieldIndex); + const CurrentField& currentField = *m_currentFieldIndex; + + const ShaderGraph::StructEntry* structEntry = &graph.GetStruct(buffer.structIndex); + for (std::size_t nestedIndex : currentField.nestedFields) + { + assert(nestedIndex < structEntry->members.size()); + const auto& memberEntry = structEntry->members[nestedIndex]; + assert(std::holds_alternative(memberEntry.type)); + + std::size_t nestedStructIndex = std::get(memberEntry.type); + structEntry = &graph.GetStruct(nestedStructIndex); + } + + return structEntry->members[currentField.finalFieldIndex]; +} + +void BufferField::UpdateBufferIndex() +{ + Nz::CallOnExit resetIfNotFound([&] + { + m_currentBufferIndex.reset(); + m_currentBufferText.clear(); + m_currentFieldIndex.reset(); + m_currentFieldText.clear(); + }); + + if (m_currentBufferText.empty()) + return; + + std::size_t bufferIndex = 0; + for (const auto& bufferEntry : GetGraph().GetBuffers()) + { + if (bufferEntry.name == m_currentBufferText) + { + m_currentBufferIndex = bufferIndex; + resetIfNotFound.Reset(); + break; + } + + bufferIndex++; + } +} + +void BufferField::UpdateBufferText() +{ + if (m_currentBufferIndex) + { + auto& buffer = GetGraph().GetBuffer(*m_currentBufferIndex); + m_currentBufferText = buffer.name; + } + else + m_currentBufferText.clear(); +} + +void BufferField::UpdateFieldIndex() +{ + Nz::CallOnExit resetIfNotFound([&] + { + m_currentFieldIndex.reset(); + m_currentFieldText.clear(); + }); + + if (m_currentFieldText.empty()) + return; + + if (!m_currentFieldIndex) + m_currentFieldIndex.emplace(); + + CurrentField& currentField = *m_currentFieldIndex; + currentField.nestedFields.clear(); + + const ShaderGraph& graph = GetGraph(); + auto& buffer = graph.GetBuffer(*m_currentBufferIndex); + + std::function FetchField; + FetchField = [&](std::size_t structIndex, const std::string& prefix) -> bool + { + const auto& s = graph.GetStruct(structIndex); + for (auto it = s.members.begin(); it != s.members.end(); ++it) + { + const auto& member = *it; + + bool found = std::visit([&](auto&& arg) -> bool + { + using T = std::decay_t; + if constexpr (std::is_same_v) + { + if (prefix + member.name == m_currentFieldText) + { + currentField.finalFieldIndex = std::distance(s.members.begin(), it); + return true; + } + else + return false; + } + else if constexpr (std::is_same_v) + { + currentField.nestedFields.push_back(std::distance(s.members.begin(), it)); + bool found = FetchField(arg, prefix + member.name + "."); + if (!found) + { + currentField.nestedFields.pop_back(); + return false; + } + + return true; + } + else + static_assert(Nz::AlwaysFalse::value, "non-exhaustive visitor"); + }, + member.type); + + if (found) + return true; + } + + return false; + }; + + if (FetchField(buffer.structIndex, "")) + resetIfNotFound.Reset(); } diff --git a/src/ShaderNode/DataModels/BufferField.hpp b/src/ShaderNode/DataModels/BufferField.hpp index d4d77bb1d..7d1295e99 100644 --- a/src/ShaderNode/DataModels/BufferField.hpp +++ b/src/ShaderNode/DataModels/BufferField.hpp @@ -28,8 +28,14 @@ class BufferField : public ShaderNode QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; + QString portCaption(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; + bool portCaptionVisible(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; + std::shared_ptr outData(QtNodes::PortIndex port) override; + void restore(const QJsonObject& data) override; + QJsonObject save() const override; + QtNodes::NodeValidationState validationState() const override; QString validationMessage() const override; @@ -41,9 +47,6 @@ class BufferField : public ShaderNode void UpdateBufferText(); void UpdateFieldIndex(); - void restore(const QJsonObject& data) override; - QJsonObject save() const override; - NazaraSlot(ShaderGraph, OnBufferListUpdate, m_onBufferListUpdateSlot); NazaraSlot(ShaderGraph, OnBufferUpdate, m_onBufferUpdateSlot); diff --git a/src/ShaderNode/DataModels/ShaderNode.cpp b/src/ShaderNode/DataModels/ShaderNode.cpp index a9b06adf8..7ed3bc84c 100644 --- a/src/ShaderNode/DataModels/ShaderNode.cpp +++ b/src/ShaderNode/DataModels/ShaderNode.cpp @@ -89,10 +89,6 @@ QWidget* ShaderNode::embeddedWidget() return m_pixmapLabel; } -void ShaderNode::setInData(std::shared_ptr, int) -{ -} - void ShaderNode::restore(const QJsonObject& data) { NodeDataModel::restore(data); @@ -116,6 +112,10 @@ QJsonObject ShaderNode::save() const return data; } +void ShaderNode::setInData(std::shared_ptr, int) +{ +} + bool ShaderNode::ComputePreview(QPixmap& /*pixmap*/) { return false; diff --git a/src/ShaderNode/DataModels/ShaderNode.hpp b/src/ShaderNode/DataModels/ShaderNode.hpp index 30e2504ca..1becb5a3d 100644 --- a/src/ShaderNode/DataModels/ShaderNode.hpp +++ b/src/ShaderNode/DataModels/ShaderNode.hpp @@ -33,6 +33,9 @@ class ShaderNode : public QtNodes::NodeDataModel QWidget* embeddedWidget() final; + void restore(const QJsonObject& data) override; + QJsonObject save() const override; + void setInData(std::shared_ptr, int) override; protected: @@ -40,9 +43,6 @@ class ShaderNode : public QtNodes::NodeDataModel inline void EnableCustomVariableName(bool enable = true); void UpdatePreview(); - void restore(const QJsonObject& data) override; - QJsonObject save() const override; - private: virtual bool ComputePreview(QPixmap& pixmap); From f66758f99bbfa3dae7d44b9710ec827294fc8bbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 22 Jul 2020 14:44:49 +0200 Subject: [PATCH 269/316] Renderer/ShaderSerializer: Fix AccessMember --- src/Nazara/Renderer/ShaderSerializer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Nazara/Renderer/ShaderSerializer.cpp b/src/Nazara/Renderer/ShaderSerializer.cpp index 71beead60..350ec2096 100644 --- a/src/Nazara/Renderer/ShaderSerializer.cpp +++ b/src/Nazara/Renderer/ShaderSerializer.cpp @@ -569,6 +569,7 @@ namespace Nz { case ShaderNodes::NodeType::None: break; + HandleType(AccessMember); HandleType(AssignOp); HandleType(BinaryOp); HandleType(Branch); From db945d11fb31f3d3e2264c871bdd839cba7d9264 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 22 Jul 2020 14:45:19 +0200 Subject: [PATCH 270/316] Renderer/GlslWriter: Fix generation bugs --- src/Nazara/Renderer/GlslWriter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Renderer/GlslWriter.cpp b/src/Nazara/Renderer/GlslWriter.cpp index 33ae8c0db..972cdb4d2 100644 --- a/src/Nazara/Renderer/GlslWriter.cpp +++ b/src/Nazara/Renderer/GlslWriter.cpp @@ -391,7 +391,7 @@ namespace Nz void GlslWriter::Visit(const ShaderNodes::BuiltinVariable& var) { - Append(var.type); + Append(var.entry); } void GlslWriter::Visit(const ShaderNodes::Cast& node) @@ -404,7 +404,7 @@ namespace Nz if (i != 0) m_currentState->stream << ", "; - const auto& exprPtr = node.expressions[i++]; + const auto& exprPtr = node.expressions[i]; NazaraAssert(exprPtr, "Invalid expression"); Visit(exprPtr); From b441bab218402c23b3b867f6693af6b19d21e917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 22 Jul 2020 14:45:40 +0200 Subject: [PATCH 271/316] Renderer/ShaderNodes: Fix BinOp expression type --- src/Nazara/Renderer/ShaderNodes.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Nazara/Renderer/ShaderNodes.cpp b/src/Nazara/Renderer/ShaderNodes.cpp index 794e1217a..ddf5e09c7 100644 --- a/src/Nazara/Renderer/ShaderNodes.cpp +++ b/src/Nazara/Renderer/ShaderNodes.cpp @@ -104,8 +104,25 @@ namespace Nz::ShaderNodes const ShaderExpressionType& rightExprType = right->GetExpressionType(); assert(std::holds_alternative(rightExprType)); - //FIXME - exprType = static_cast(std::max(UnderlyingCast(std::get(leftExprType)), UnderlyingCast(std::get(rightExprType)))); + switch (std::get(leftExprType)) + { + case BasicType::Boolean: + case BasicType::Float2: + case BasicType::Float3: + case BasicType::Float4: + exprType = leftExprType; + break; + + case BasicType::Float1: + case BasicType::Mat4x4: + exprType = rightExprType; + break; + + case BasicType::Sampler2D: + case BasicType::Void: + break; + } + break; } From 5a350ee76b69e1c6f88b2028ead32f4ea2d4d55a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 22 Jul 2020 14:46:44 +0200 Subject: [PATCH 272/316] ShaderNode: Add Mat4x4 type and nodes --- src/ShaderNode/DataModels/BufferField.cpp | 18 +-- src/ShaderNode/DataModels/InputValue.cpp | 80 +++++----- src/ShaderNode/DataModels/Mat4BinOp.cpp | 37 +++++ src/ShaderNode/DataModels/Mat4BinOp.hpp | 67 ++++++++ src/ShaderNode/DataModels/Mat4BinOp.inl | 131 +++++++++++++++ src/ShaderNode/DataModels/Mat4VecMul.cpp | 186 ++++++++++++++++++++++ src/ShaderNode/DataModels/Mat4VecMul.hpp | 43 +++++ src/ShaderNode/DataModels/Mat4VecMul.inl | 1 + src/ShaderNode/DataModels/OutputValue.cpp | 131 ++++++++++----- src/ShaderNode/DataModels/OutputValue.hpp | 6 +- src/ShaderNode/DataTypes/Matrix4Data.cpp | 1 + src/ShaderNode/DataTypes/Matrix4Data.hpp | 19 +++ src/ShaderNode/DataTypes/Matrix4Data.inl | 11 ++ src/ShaderNode/Enums.cpp | 2 + src/ShaderNode/Enums.hpp | 3 +- src/ShaderNode/ShaderGraph.cpp | 35 ++++ src/ShaderNode/ShaderGraph.hpp | 1 + 17 files changed, 668 insertions(+), 104 deletions(-) create mode 100644 src/ShaderNode/DataModels/Mat4BinOp.cpp create mode 100644 src/ShaderNode/DataModels/Mat4BinOp.hpp create mode 100644 src/ShaderNode/DataModels/Mat4BinOp.inl create mode 100644 src/ShaderNode/DataModels/Mat4VecMul.cpp create mode 100644 src/ShaderNode/DataModels/Mat4VecMul.hpp create mode 100644 src/ShaderNode/DataModels/Mat4VecMul.inl create mode 100644 src/ShaderNode/DataTypes/Matrix4Data.cpp create mode 100644 src/ShaderNode/DataTypes/Matrix4Data.hpp create mode 100644 src/ShaderNode/DataTypes/Matrix4Data.inl diff --git a/src/ShaderNode/DataModels/BufferField.cpp b/src/ShaderNode/DataModels/BufferField.cpp index a8399509c..480d53c2c 100644 --- a/src/ShaderNode/DataModels/BufferField.cpp +++ b/src/ShaderNode/DataModels/BufferField.cpp @@ -173,22 +173,7 @@ auto BufferField::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIn const auto& member = RetrieveNestedMember(); assert(std::holds_alternative(member.type)); - switch (std::get(member.type)) - { - case PrimitiveType::Bool: - return BoolData::Type(); - - case PrimitiveType::Float1: - return FloatData::Type(); - - case PrimitiveType::Float2: - case PrimitiveType::Float3: - case PrimitiveType::Float4: - return VecData::Type(); - } - - assert(false); - throw std::runtime_error("Unhandled primitive type"); + return ShaderGraph::ToNodeDataType(std::get(member.type)); } QString BufferField::portCaption(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const @@ -260,6 +245,7 @@ std::shared_ptr BufferField::outData(QtNodes::PortIndex port) case PrimitiveType::Float2: return std::make_shared(2); case PrimitiveType::Float3: return std::make_shared(3); case PrimitiveType::Float4: return std::make_shared(4); + case PrimitiveType::Mat4x4: return std::make_shared(); } assert(false); diff --git a/src/ShaderNode/DataModels/InputValue.cpp b/src/ShaderNode/DataModels/InputValue.cpp index 1b33a8c9b..c2c6f6b01 100644 --- a/src/ShaderNode/DataModels/InputValue.cpp +++ b/src/ShaderNode/DataModels/InputValue.cpp @@ -1,6 +1,8 @@ #include #include +#include #include +#include #include #include #include @@ -115,23 +117,7 @@ Nz::ShaderNodes::ExpressionPtr InputValue::GetExpression(Nz::ShaderNodes::Expres throw std::runtime_error("no input"); const auto& inputEntry = GetGraph().GetInput(*m_currentInputIndex); - - Nz::ShaderNodes::BasicType expression = [&] - { - switch (inputEntry.type) - { - case PrimitiveType::Bool: return Nz::ShaderNodes::BasicType::Boolean; - case PrimitiveType::Float1: return Nz::ShaderNodes::BasicType::Float1; - case PrimitiveType::Float2: return Nz::ShaderNodes::BasicType::Float2; - case PrimitiveType::Float3: return Nz::ShaderNodes::BasicType::Float3; - case PrimitiveType::Float4: return Nz::ShaderNodes::BasicType::Float4; - } - - assert(false); - throw std::runtime_error("Unhandled input type"); - }(); - - return Nz::ShaderBuilder::Identifier(Nz::ShaderBuilder::Input(inputEntry.name, expression)); + return Nz::ShaderBuilder::Identifier(Nz::ShaderBuilder::Input(inputEntry.name, ShaderGraph::ToShaderExpressionType(inputEntry.type))); } auto InputValue::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const -> QtNodes::NodeDataType @@ -143,20 +129,7 @@ auto InputValue::dataType(QtNodes::PortType portType, QtNodes::PortIndex portInd return VecData::Type(); const auto& inputEntry = GetGraph().GetInput(*m_currentInputIndex); - switch (inputEntry.type) - { - //case InputType::Bool: return Nz::ShaderNodes::BasicType::Boolean; - case PrimitiveType::Float1: - return FloatData::Type(); - - case PrimitiveType::Float2: - case PrimitiveType::Float3: - case PrimitiveType::Float4: - return VecData::Type(); - } - - assert(false); - throw std::runtime_error("Unhandled input type"); + return ShaderGraph::ToNodeDataType(inputEntry.type); } std::shared_ptr InputValue::outData(QtNodes::PortIndex port) @@ -170,20 +143,45 @@ std::shared_ptr InputValue::outData(QtNodes::PortIndex port) const auto& inputEntry = graph.GetInput(*m_currentInputIndex); const auto& preview = graph.GetPreviewModel(); - if (inputEntry.type == PrimitiveType::Float1) + switch (inputEntry.type) { - auto fData = std::make_shared(); - fData->preview = preview.GetPreview(inputEntry.role, inputEntry.roleIndex); + case PrimitiveType::Bool: + { + auto bData = std::make_shared(); + bData->preview = preview.GetPreview(inputEntry.role, inputEntry.roleIndex); - return fData; - } - else - { - auto vecData = std::make_shared(GetComponentCount(inputEntry.type)); - vecData->preview = preview.GetPreview(inputEntry.role, inputEntry.roleIndex); + return bData; + } - return vecData; + case PrimitiveType::Float1: + { + auto fData = std::make_shared(); + fData->preview = preview.GetPreview(inputEntry.role, inputEntry.roleIndex); + + return fData; + } + + case PrimitiveType::Float2: + case PrimitiveType::Float3: + case PrimitiveType::Float4: + { + auto vecData = std::make_shared(GetComponentCount(inputEntry.type)); + vecData->preview = preview.GetPreview(inputEntry.role, inputEntry.roleIndex); + + return vecData; + } + + case PrimitiveType::Mat4x4: + { + auto matData = std::make_shared(); + //TODO: Handle preview + + return matData; + } } + + assert(false); + throw std::runtime_error("Unhandled input type"); } QtNodes::NodeValidationState InputValue::validationState() const diff --git a/src/ShaderNode/DataModels/Mat4BinOp.cpp b/src/ShaderNode/DataModels/Mat4BinOp.cpp new file mode 100644 index 000000000..4376b2995 --- /dev/null +++ b/src/ShaderNode/DataModels/Mat4BinOp.cpp @@ -0,0 +1,37 @@ +#include + +QString Mat4Add::caption() const +{ + static QString caption = "Matrix4 addition"; + return caption; +} + +QString Mat4Add::name() const +{ + static QString name = "mat4_add"; + return name; +} + +QString Mat4Mul::caption() const +{ + static QString caption = "Matrix4 multiplication"; + return caption; +} + +QString Mat4Mul::name() const +{ + static QString name = "mat4_mul"; + return name; +} + +QString Mat4Sub::caption() const +{ + static QString caption = "Matrix4 subtraction"; + return caption; +} + +QString Mat4Sub::name() const +{ + static QString name = "mat4_sub"; + return name; +} diff --git a/src/ShaderNode/DataModels/Mat4BinOp.hpp b/src/ShaderNode/DataModels/Mat4BinOp.hpp new file mode 100644 index 000000000..c90549bdd --- /dev/null +++ b/src/ShaderNode/DataModels/Mat4BinOp.hpp @@ -0,0 +1,67 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_MAT4BINOP_HPP +#define NAZARA_SHADERNODES_MAT4BINOP_HPP + +#include +#include + +template +class Mat4BinOp : public ShaderNode +{ + public: + Mat4BinOp(ShaderGraph& graph); + ~Mat4BinOp() = default; + + Nz::ShaderNodes::ExpressionPtr GetExpression(Nz::ShaderNodes::ExpressionPtr* expressions, std::size_t count) const override; + + unsigned int nPorts(QtNodes::PortType portType) const override; + + QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; + + std::shared_ptr outData(QtNodes::PortIndex port) override; + + void setInData(std::shared_ptr value, int index) override; + + QtNodes::NodeValidationState validationState() const override; + QString validationMessage() const override; + + private: + bool ComputePreview(QPixmap& pixmap) override; + void UpdateOutput(); + + std::shared_ptr m_lhs; + std::shared_ptr m_rhs; + std::shared_ptr m_output; +}; + +class Mat4Add : public Mat4BinOp +{ + public: + using Mat4BinOp::Mat4BinOp; + + QString caption() const override; + QString name() const override; +}; + +class Mat4Mul : public Mat4BinOp +{ + public: + using Mat4BinOp::Mat4BinOp; + + QString caption() const override; + QString name() const override; +}; + +class Mat4Sub : public Mat4BinOp +{ + public: + using Mat4BinOp::Mat4BinOp; + + QString caption() const override; + QString name() const override; +}; + +#include + +#endif diff --git a/src/ShaderNode/DataModels/Mat4BinOp.inl b/src/ShaderNode/DataModels/Mat4BinOp.inl new file mode 100644 index 000000000..684a6ec79 --- /dev/null +++ b/src/ShaderNode/DataModels/Mat4BinOp.inl @@ -0,0 +1,131 @@ +#include +#include + +template +Mat4BinOp::Mat4BinOp(ShaderGraph& graph) : +ShaderNode(graph) +{ + UpdateOutput(); +} + +template +Nz::ShaderNodes::ExpressionPtr Mat4BinOp::GetExpression(Nz::ShaderNodes::ExpressionPtr* expressions, std::size_t count) const +{ + assert(count == 2); + using BuilderType = typename Nz::ShaderBuilder::template BinOpBuilder; + constexpr BuilderType builder; + return builder(expressions[0], expressions[1]); +} + +template +QtNodes::NodeDataType Mat4BinOp::dataType(QtNodes::PortType /*portType*/, QtNodes::PortIndex portIndex) const +{ + assert(portIndex == 0 || portIndex == 1); + + return Matrix4Data::Type(); +} + +template +unsigned int Mat4BinOp::nPorts(QtNodes::PortType portType) const +{ + switch (portType) + { + case QtNodes::PortType::In: return 2; + case QtNodes::PortType::Out: return 1; + } + + return 0; +} + +template +std::shared_ptr Mat4BinOp::outData(QtNodes::PortIndex port) +{ + assert(port == 0); + return m_output; +} + +template +void Mat4BinOp::setInData(std::shared_ptr value, int index) +{ + assert(index == 0 || index == 1); + + std::shared_ptr castedValue; + if (value) + { + assert(dynamic_cast(value.get()) != nullptr); + + castedValue = std::static_pointer_cast(value); + } + + if (index == 0) + m_lhs = std::move(castedValue); + else + m_rhs = std::move(castedValue); + + UpdateOutput(); +} + +template +QtNodes::NodeValidationState Mat4BinOp::validationState() const +{ + if (!m_lhs || !m_rhs) + return QtNodes::NodeValidationState::Error; + + return QtNodes::NodeValidationState::Valid; +} + +template +QString Mat4BinOp::validationMessage() const +{ + if (!m_lhs || !m_rhs) + return "Missing operands"; + + return QString(); +} + +template +bool Mat4BinOp::ComputePreview(QPixmap& pixmap) +{ + if (!m_lhs || !m_rhs) + return false; + + return false; + + //pixmap = QPixmap::fromImage(m_output->preview.GenerateImage()); + //return true; +} + +template +void Mat4BinOp::UpdateOutput() +{ + if (validationState() != QtNodes::NodeValidationState::Valid) + { + m_output = std::make_shared(); + return; + } + + m_output = std::make_shared(); + + /*m_output = std::make_shared(m_lhs->componentCount); + + const PreviewValues& leftPreview = m_lhs->preview; + const PreviewValues& rightPreview = m_rhs->preview; + std::size_t maxWidth = std::max(leftPreview.GetWidth(), rightPreview.GetWidth()); + std::size_t maxHeight = std::max(leftPreview.GetHeight(), rightPreview.GetHeight()); + + // FIXME: Prevent useless copy + PreviewValues leftResized = leftPreview; + if (leftResized.GetWidth() != maxWidth || leftResized.GetHeight() != maxHeight) + leftResized = leftResized.Resized(maxWidth, maxHeight); + + PreviewValues rightResized = rightPreview; + if (rightResized.GetWidth() != maxWidth || rightResized.GetHeight() != maxHeight) + rightResized = rightResized.Resized(maxWidth, maxHeight); + + m_output->preview = PreviewValues(maxWidth, maxHeight); + ApplyOp(leftResized.GetData(), rightResized.GetData(), m_output->preview.GetData(), maxWidth * maxHeight);*/ + + Q_EMIT dataUpdated(0); + + UpdatePreview(); +} diff --git a/src/ShaderNode/DataModels/Mat4VecMul.cpp b/src/ShaderNode/DataModels/Mat4VecMul.cpp new file mode 100644 index 000000000..2e530e496 --- /dev/null +++ b/src/ShaderNode/DataModels/Mat4VecMul.cpp @@ -0,0 +1,186 @@ +#include +#include + +Mat4VecMul::Mat4VecMul(ShaderGraph& graph) : +ShaderNode(graph) +{ + UpdateOutput(); +} + +Nz::ShaderNodes::ExpressionPtr Mat4VecMul::GetExpression(Nz::ShaderNodes::ExpressionPtr* expressions, std::size_t count) const +{ + assert(count == 2); + using namespace Nz::ShaderNodes; + return BinaryOp::Build(BinaryType::Multiply, expressions[0], expressions[1]); +} + +QString Mat4VecMul::caption() const +{ + static QString caption = "Mat4/Vec multiplication"; + return caption; +} + +QString Mat4VecMul::name() const +{ + static QString name = "mat4vec_mul"; + return name; +} + +QtNodes::NodeDataType Mat4VecMul::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const +{ + switch (portType) + { + case QtNodes::PortType::In: + { + assert(portIndex == 0 || portIndex == 1); + switch (portIndex) + { + case 0: return Matrix4Data::Type(); + case 1: return VecData::Type(); + } + } + + case QtNodes::PortType::Out: + { + assert(portIndex == 0); + return VecData::Type(); + } + } + + assert(false); + throw std::runtime_error("Invalid port type"); +} + +unsigned int Mat4VecMul::nPorts(QtNodes::PortType portType) const +{ + switch (portType) + { + case QtNodes::PortType::In: return 2; + case QtNodes::PortType::Out: return 1; + } + + assert(false); + throw std::runtime_error("Invalid port type"); +} + +std::shared_ptr Mat4VecMul::outData(QtNodes::PortIndex port) +{ + assert(port == 0); + return m_output; +} + +void Mat4VecMul::setInData(std::shared_ptr value, int index) +{ + assert(index == 0 || index == 1); + + switch (index) + { + case 0: + { + if (value) + { + assert(dynamic_cast(value.get()) != nullptr); + m_lhs = std::static_pointer_cast(value); + } + else + m_lhs.reset(); + + break; + } + + case 1: + { + if (value) + { + assert(dynamic_cast(value.get()) != nullptr); + m_rhs = std::static_pointer_cast(value); + } + else + m_rhs.reset(); + + break; + } + + default: + assert(false); + throw std::runtime_error("Invalid PortType"); + } + + UpdateOutput(); +} + +QtNodes::NodeValidationState Mat4VecMul::validationState() const +{ + if (!m_lhs || !m_rhs) + return QtNodes::NodeValidationState::Error; + + if (m_rhs->componentCount != 4) + return QtNodes::NodeValidationState::Error; + + return QtNodes::NodeValidationState::Valid; +} + +QString Mat4VecMul::validationMessage() const +{ + if (!m_lhs || !m_rhs) + return "Missing operands"; + + if (m_rhs->componentCount != 4) + return QString("Expected vector with 4 components, got ") + QString::number(m_rhs->componentCount); + + return QString(); +} + +bool Mat4VecMul::ComputePreview(QPixmap& pixmap) +{ + if (validationState() != QtNodes::NodeValidationState::Valid) + return false; + + pixmap = QPixmap::fromImage(m_output->preview.GenerateImage()); + return true; +} + +void Mat4VecMul::UpdateOutput() +{ + if (validationState() != QtNodes::NodeValidationState::Valid) + { + m_output = std::make_shared(4); + m_output->preview = PreviewValues(1, 1); + m_output->preview.Fill(Nz::Vector4f::Zero()); + return; + } + + m_output = std::make_shared(4); + m_output->preview = PreviewValues(1, 1); + m_output->preview.Fill(Nz::Vector4f::Zero()); + + /*m_output = std::make_shared(m_rhs->componentCount); + + const PreviewValues& leftPreview = m_lhs->preview; + const PreviewValues& rightPreview = m_rhs->preview; + std::size_t maxWidth = std::max(leftPreview.GetWidth(), rightPreview.GetWidth()); + std::size_t maxHeight = std::max(leftPreview.GetHeight(), rightPreview.GetHeight()); + + // FIXME: Prevent useless copy + PreviewValues leftResized = leftPreview; + if (leftResized.GetWidth() != maxWidth || leftResized.GetHeight() != maxHeight) + leftResized = leftResized.Resized(maxWidth, maxHeight); + + PreviewValues rightResized = rightPreview; + if (rightResized.GetWidth() != maxWidth || rightResized.GetHeight() != maxHeight) + rightResized = rightResized.Resized(maxWidth, maxHeight); + + m_output->preview = PreviewValues(maxWidth, maxHeight); + + const Nz::Vector4f* left = leftResized.GetData(); + const Nz::Vector4f* right = rightPreview.GetData(); + Nz::Vector4f* output = m_output->preview.GetData(); + + std::size_t pixelCount = maxWidth * maxHeight; + for (std::size_t i = 0; i < pixelCount; ++i) + output[i] = left[i] * right[i]; + + Q_EMIT dataUpdated(0); + + UpdatePreview();*/ +} diff --git a/src/ShaderNode/DataModels/Mat4VecMul.hpp b/src/ShaderNode/DataModels/Mat4VecMul.hpp new file mode 100644 index 000000000..608439fcb --- /dev/null +++ b/src/ShaderNode/DataModels/Mat4VecMul.hpp @@ -0,0 +1,43 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_MAT4VECMUL_HPP +#define NAZARA_SHADERNODES_MAT4VECMUL_HPP + +#include +#include +#include + +class Mat4VecMul : public ShaderNode +{ + public: + Mat4VecMul(ShaderGraph& graph); + ~Mat4VecMul() = default; + + Nz::ShaderNodes::ExpressionPtr GetExpression(Nz::ShaderNodes::ExpressionPtr* expressions, std::size_t count) const override; + + QString caption() const override; + QString name() const override; + + unsigned int nPorts(QtNodes::PortType portType) const override; + + QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; + + std::shared_ptr outData(QtNodes::PortIndex port) override; + + void setInData(std::shared_ptr value, int index) override; + + QtNodes::NodeValidationState validationState() const override; + QString validationMessage() const override; + + private: + bool ComputePreview(QPixmap& pixmap) override; + void UpdateOutput(); + + std::shared_ptr m_lhs; + std::shared_ptr m_rhs; + std::shared_ptr m_output; +}; + +#include + +#endif diff --git a/src/ShaderNode/DataModels/Mat4VecMul.inl b/src/ShaderNode/DataModels/Mat4VecMul.inl new file mode 100644 index 000000000..a798943a8 --- /dev/null +++ b/src/ShaderNode/DataModels/Mat4VecMul.inl @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/DataModels/OutputValue.cpp b/src/ShaderNode/DataModels/OutputValue.cpp index b86c46879..6f30a9b66 100644 --- a/src/ShaderNode/DataModels/OutputValue.cpp +++ b/src/ShaderNode/DataModels/OutputValue.cpp @@ -1,6 +1,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -62,23 +65,7 @@ Nz::ShaderNodes::ExpressionPtr OutputValue::GetExpression(Nz::ShaderNodes::Expre throw std::runtime_error("no output"); const auto& outputEntry = GetGraph().GetOutput(*m_currentOutputIndex); - - Nz::ShaderNodes::BasicType expression = [&] - { - switch (outputEntry.type) - { - case PrimitiveType::Bool: return Nz::ShaderNodes::BasicType::Boolean; - case PrimitiveType::Float1: return Nz::ShaderNodes::BasicType::Float1; - case PrimitiveType::Float2: return Nz::ShaderNodes::BasicType::Float2; - case PrimitiveType::Float3: return Nz::ShaderNodes::BasicType::Float3; - case PrimitiveType::Float4: return Nz::ShaderNodes::BasicType::Float4; - } - - assert(false); - throw std::runtime_error("Unhandled output type"); - }(); - - auto output = Nz::ShaderBuilder::Identifier(Nz::ShaderBuilder::Output(outputEntry.name, expression)); + auto output = Nz::ShaderBuilder::Identifier(Nz::ShaderBuilder::Output(outputEntry.name, ShaderGraph::ToShaderExpressionType(outputEntry.type))); return Nz::ShaderBuilder::Assign(std::move(output), *expressions); } @@ -92,18 +79,7 @@ QtNodes::NodeDataType OutputValue::dataType(QtNodes::PortType portType, QtNodes: return VecData::Type(); const auto& outputEntry = GetGraph().GetOutput(*m_currentOutputIndex); - switch (outputEntry.type) - { - //case InOutType::Bool: return Nz::ShaderNodes::BasicType::Boolean; - //case InOutType::Float1: return Nz::ShaderNodes::BasicType::Float1; - case PrimitiveType::Float2: - case PrimitiveType::Float3: - case PrimitiveType::Float4: - return VecData::Type(); - } - - assert(false); - throw std::runtime_error("Unhandled output type"); + return ShaderGraph::ToNodeDataType(outputEntry.type); } unsigned int OutputValue::nPorts(QtNodes::PortType portType) const @@ -124,14 +100,11 @@ std::shared_ptr OutputValue::outData(QtNodes::PortIndex /*por void OutputValue::setInData(std::shared_ptr value, int index) { + if (!m_currentOutputIndex) + return; + assert(index == 0); - if (value) - { - assert(dynamic_cast(value.get()) != nullptr); - m_input = std::static_pointer_cast(value); - } - else - m_input.reset(); + m_input = std::move(value); UpdatePreview(); } @@ -142,8 +115,23 @@ QtNodes::NodeValidationState OutputValue::validationState() const return QtNodes::NodeValidationState::Error; const auto& outputEntry = GetGraph().GetOutput(*m_currentOutputIndex); - if (GetComponentCount(outputEntry.type) != m_input->componentCount) - return QtNodes::NodeValidationState::Error; + switch (outputEntry.type) + { + case PrimitiveType::Bool: + case PrimitiveType::Float1: + case PrimitiveType::Mat4x4: + break; + + case PrimitiveType::Float2: + case PrimitiveType::Float3: + case PrimitiveType::Float4: + { + assert(dynamic_cast(m_input.get()) != nullptr); + const VecData& vec = static_cast(*m_input); + if (GetComponentCount(outputEntry.type) != vec.componentCount) + return QtNodes::NodeValidationState::Error; + } + } return QtNodes::NodeValidationState::Valid; } @@ -157,10 +145,26 @@ QString OutputValue::validationMessage() const return "Missing input"; const auto& outputEntry = GetGraph().GetOutput(*m_currentOutputIndex); - std::size_t outputComponentCount = GetComponentCount(outputEntry.type); + switch (outputEntry.type) + { + case PrimitiveType::Bool: + case PrimitiveType::Float1: + case PrimitiveType::Mat4x4: + break; - if (m_input->componentCount != outputComponentCount) - return "Incompatible component count (expected " + QString::number(outputComponentCount) + ", got " + QString::number(m_input->componentCount) + ")"; + case PrimitiveType::Float2: + case PrimitiveType::Float3: + case PrimitiveType::Float4: + { + assert(dynamic_cast(m_input.get()) != nullptr); + const VecData& vec = static_cast(*m_input); + + std::size_t outputComponentCount = GetComponentCount(outputEntry.type); + + if (outputComponentCount != vec.componentCount) + return "Incompatible component count (expected " + QString::number(outputComponentCount) + ", got " + QString::number(vec.componentCount) + ")"; + } + } return QString(); } @@ -170,8 +174,49 @@ bool OutputValue::ComputePreview(QPixmap& pixmap) if (!m_input) return false; - pixmap = QPixmap::fromImage(m_input->preview.GenerateImage()); - return true; + const auto& outputEntry = GetGraph().GetOutput(*m_currentOutputIndex); + switch (outputEntry.type) + { + case PrimitiveType::Bool: + { + assert(dynamic_cast(m_input.get()) != nullptr); + const BoolData& data = static_cast(*m_input); + + pixmap = QPixmap::fromImage(data.preview.GenerateImage()); + return true; + } + + case PrimitiveType::Float1: + { + assert(dynamic_cast(m_input.get()) != nullptr); + const FloatData& data = static_cast(*m_input); + + pixmap = QPixmap::fromImage(data.preview.GenerateImage()); + return true; + } + + case PrimitiveType::Mat4x4: + { + //TODO + /*assert(dynamic_cast(m_input.get()) != nullptr); + const Matrix4Data& data = static_cast(*m_input);*/ + + return false; + } + + case PrimitiveType::Float2: + case PrimitiveType::Float3: + case PrimitiveType::Float4: + { + assert(dynamic_cast(m_input.get()) != nullptr); + const VecData& data = static_cast(*m_input); + + pixmap = QPixmap::fromImage(data.preview.GenerateImage()); + return true; + } + } + + return false; } void OutputValue::OnOutputListUpdate() diff --git a/src/ShaderNode/DataModels/OutputValue.hpp b/src/ShaderNode/DataModels/OutputValue.hpp index 284e302ea..12c812c5c 100644 --- a/src/ShaderNode/DataModels/OutputValue.hpp +++ b/src/ShaderNode/DataModels/OutputValue.hpp @@ -1,7 +1,7 @@ #pragma once -#ifndef NAZARA_SHADERNODES_FRAGMENTOUTPUT_HPP -#define NAZARA_SHADERNODES_FRAGMENTOUTPUT_HPP +#ifndef NAZARA_SHADERNODES_OUTPUTVALUE_HPP +#define NAZARA_SHADERNODES_OUTPUTVALUE_HPP #include #include @@ -44,7 +44,7 @@ class OutputValue : public ShaderNode NazaraSlot(ShaderGraph, OnOutputUpdate, m_onOutputUpdateSlot); std::optional m_currentOutputIndex; - std::shared_ptr m_input; + std::shared_ptr m_input; std::string m_currentOutputText; }; diff --git a/src/ShaderNode/DataTypes/Matrix4Data.cpp b/src/ShaderNode/DataTypes/Matrix4Data.cpp new file mode 100644 index 000000000..24dfe95a2 --- /dev/null +++ b/src/ShaderNode/DataTypes/Matrix4Data.cpp @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/DataTypes/Matrix4Data.hpp b/src/ShaderNode/DataTypes/Matrix4Data.hpp new file mode 100644 index 000000000..fdfbf1897 --- /dev/null +++ b/src/ShaderNode/DataTypes/Matrix4Data.hpp @@ -0,0 +1,19 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_MATRIXDATA_HPP +#define NAZARA_SHADERNODES_MATRIXDATA_HPP + +#include +#include +#include + +struct Matrix4Data : public QtNodes::NodeData +{ + inline QtNodes::NodeDataType type() const override; + + static inline QtNodes::NodeDataType Type(); +}; + +#include + +#endif diff --git a/src/ShaderNode/DataTypes/Matrix4Data.inl b/src/ShaderNode/DataTypes/Matrix4Data.inl new file mode 100644 index 000000000..157e35810 --- /dev/null +++ b/src/ShaderNode/DataTypes/Matrix4Data.inl @@ -0,0 +1,11 @@ +#include + +inline QtNodes::NodeDataType Matrix4Data::type() const +{ + return Type(); +} + +inline QtNodes::NodeDataType Matrix4Data::Type() +{ + return { "mat4", "Matrix4x4" }; +} diff --git a/src/ShaderNode/Enums.cpp b/src/ShaderNode/Enums.cpp index 610078d65..2c924c3ed 100644 --- a/src/ShaderNode/Enums.cpp +++ b/src/ShaderNode/Enums.cpp @@ -10,6 +10,7 @@ std::size_t GetComponentCount(PrimitiveType type) case PrimitiveType::Float2: return 2; case PrimitiveType::Float3: return 3; case PrimitiveType::Float4: return 4; + case PrimitiveType::Mat4x4: return 16; } assert(false); @@ -50,6 +51,7 @@ const char* EnumToString(PrimitiveType input) case PrimitiveType::Float2: return "Float2"; case PrimitiveType::Float3: return "Float3"; case PrimitiveType::Float4: return "Float4"; + case PrimitiveType::Mat4x4: return "Mat4x4"; } assert(false); diff --git a/src/ShaderNode/Enums.hpp b/src/ShaderNode/Enums.hpp index 41e8f4360..e59d66424 100644 --- a/src/ShaderNode/Enums.hpp +++ b/src/ShaderNode/Enums.hpp @@ -35,8 +35,9 @@ enum class PrimitiveType Float2, Float3, Float4, + Mat4x4, - Max = Float4 + Max = Mat4x4 }; constexpr std::size_t PrimitiveTypeCount = static_cast(PrimitiveType::Max) + 1; diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp index 22d74dca2..5b248bfc3 100644 --- a/src/ShaderNode/ShaderGraph.cpp +++ b/src/ShaderNode/ShaderGraph.cpp @@ -8,11 +8,18 @@ #include #include #include +#include +#include #include #include #include #include #include +#include +#include +#include +#include +#include #include #include #include @@ -591,6 +598,29 @@ void ShaderGraph::UpdateTexturePreview(std::size_t textureIndex, QImage preview) OnTexturePreviewUpdate(this, textureIndex); } +QtNodes::NodeDataType ShaderGraph::ToNodeDataType(PrimitiveType type) +{ + switch (type) + { + case PrimitiveType::Bool: + return BoolData::Type(); + + case PrimitiveType::Float1: + return FloatData::Type(); + + case PrimitiveType::Float2: + case PrimitiveType::Float3: + case PrimitiveType::Float4: + return VecData::Type(); + + case PrimitiveType::Mat4x4: + return Matrix4Data::Type(); + } + + assert(false); + throw std::runtime_error("Unhandled input type"); +} + Nz::ShaderExpressionType ShaderGraph::ToShaderExpressionType(PrimitiveType type) { switch (type) @@ -600,6 +630,7 @@ Nz::ShaderExpressionType ShaderGraph::ToShaderExpressionType(PrimitiveType type) case PrimitiveType::Float2: return Nz::ShaderNodes::BasicType::Float2; case PrimitiveType::Float3: return Nz::ShaderNodes::BasicType::Float3; case PrimitiveType::Float4: return Nz::ShaderNodes::BasicType::Float4; + case PrimitiveType::Mat4x4: return Nz::ShaderNodes::BasicType::Mat4x4; } assert(false); @@ -629,6 +660,10 @@ std::shared_ptr ShaderGraph::BuildRegistry() RegisterShaderNode(*this, registry, "Outputs"); RegisterShaderNode(*this, registry, "Texture"); RegisterShaderNode(*this, registry, "Texture"); + RegisterShaderNode(*this, registry, "Matrix operations"); + RegisterShaderNode(*this, registry, "Matrix operations"); + RegisterShaderNode(*this, registry, "Matrix operations"); + RegisterShaderNode(*this, registry, "Matrix operations"); RegisterShaderNode(*this, registry, "Vector operations"); RegisterShaderNode(*this, registry, "Vector operations"); RegisterShaderNode(*this, registry, "Vector operations"); diff --git a/src/ShaderNode/ShaderGraph.hpp b/src/ShaderNode/ShaderGraph.hpp index 0cab330d0..e91127cb5 100644 --- a/src/ShaderNode/ShaderGraph.hpp +++ b/src/ShaderNode/ShaderGraph.hpp @@ -122,6 +122,7 @@ class ShaderGraph NazaraSignal(OnTexturePreviewUpdate, ShaderGraph*, std::size_t /*textureIndex*/); NazaraSignal(OnTextureUpdate, ShaderGraph*, std::size_t /*textureIndex*/); + static QtNodes::NodeDataType ToNodeDataType(PrimitiveType type); static Nz::ShaderExpressionType ToShaderExpressionType(PrimitiveType type); static Nz::ShaderExpressionType ToShaderExpressionType(TextureType type); From 471194ec16e205467702768d2d8f950f9ff7e264 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 22 Jul 2020 14:47:00 +0200 Subject: [PATCH 273/316] ShaderNode: Add PositionOutputValue --- .../DataModels/PositionOutputValue.cpp | 84 +++++++++++++++++++ .../DataModels/PositionOutputValue.hpp | 39 +++++++++ .../DataModels/PositionOutputValue.inl | 1 + src/ShaderNode/ShaderGraph.cpp | 2 + 4 files changed, 126 insertions(+) create mode 100644 src/ShaderNode/DataModels/PositionOutputValue.cpp create mode 100644 src/ShaderNode/DataModels/PositionOutputValue.hpp create mode 100644 src/ShaderNode/DataModels/PositionOutputValue.inl diff --git a/src/ShaderNode/DataModels/PositionOutputValue.cpp b/src/ShaderNode/DataModels/PositionOutputValue.cpp new file mode 100644 index 000000000..ee1be66a2 --- /dev/null +++ b/src/ShaderNode/DataModels/PositionOutputValue.cpp @@ -0,0 +1,84 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +PositionOutputValue::PositionOutputValue(ShaderGraph& graph) : +ShaderNode(graph) +{ + DisableCustomVariableName(); +} + +Nz::ShaderNodes::ExpressionPtr PositionOutputValue::GetExpression(Nz::ShaderNodes::ExpressionPtr* expressions, std::size_t count) const +{ + using namespace Nz::ShaderBuilder; + using namespace Nz::ShaderNodes; + + assert(count == 1); + + auto output = Nz::ShaderBuilder::Identifier(Nz::ShaderBuilder::Builtin(BuiltinEntry::VertexPosition)); + return Nz::ShaderBuilder::Assign(std::move(output), *expressions); +} + +QtNodes::NodeDataType PositionOutputValue::dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const +{ + assert(portType == QtNodes::PortType::In); + assert(portIndex == 0); + + return VecData::Type(); +} + +unsigned int PositionOutputValue::nPorts(QtNodes::PortType portType) const +{ + switch (portType) + { + case QtNodes::PortType::In: return 1; + case QtNodes::PortType::Out: return 0; + } + + return 0; +} + +std::shared_ptr PositionOutputValue::outData(QtNodes::PortIndex /*port*/) +{ + return {}; +} + +void PositionOutputValue::setInData(std::shared_ptr value, int index) +{ + assert(index == 0); + if (value) + { + assert(dynamic_cast(value.get()) != nullptr); + m_input = std::static_pointer_cast(value); + } + else + m_input.reset(); +} + +QtNodes::NodeValidationState PositionOutputValue::validationState() const +{ + if (!m_input) + return QtNodes::NodeValidationState::Error; + + if (m_input->componentCount != 4) + return QtNodes::NodeValidationState::Error; + + return QtNodes::NodeValidationState::Valid; +} + +QString PositionOutputValue::validationMessage() const +{ + if (!m_input) + return "Missing input"; + + if (m_input->componentCount != 4) + return QString("Expected vector with 4 components, got ") + QString::number(m_input->componentCount); + + return QString(); +} diff --git a/src/ShaderNode/DataModels/PositionOutputValue.hpp b/src/ShaderNode/DataModels/PositionOutputValue.hpp new file mode 100644 index 000000000..2c2b6eb54 --- /dev/null +++ b/src/ShaderNode/DataModels/PositionOutputValue.hpp @@ -0,0 +1,39 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_POSITIONOUTPUTVALUE_HPP +#define NAZARA_SHADERNODES_POSITIONOUTPUTVALUE_HPP + +#include +#include +#include + +class QFormLayout; + +class PositionOutputValue : public ShaderNode +{ + public: + PositionOutputValue(ShaderGraph& graph); + + Nz::ShaderNodes::ExpressionPtr GetExpression(Nz::ShaderNodes::ExpressionPtr* expressions, std::size_t count) const override; + + QString caption() const override { return "PositionOutputValue"; } + QString name() const override { return "PositionOutputValue"; } + + QtNodes::NodeDataType dataType(QtNodes::PortType portType, QtNodes::PortIndex portIndex) const override; + + unsigned int nPorts(QtNodes::PortType portType) const override; + + std::shared_ptr outData(QtNodes::PortIndex port) override; + + void setInData(std::shared_ptr value, int index) override; + + QtNodes::NodeValidationState validationState() const override; + QString validationMessage() const override; + + private: + std::shared_ptr m_input; +}; + +#include + +#endif diff --git a/src/ShaderNode/DataModels/PositionOutputValue.inl b/src/ShaderNode/DataModels/PositionOutputValue.inl new file mode 100644 index 000000000..585e40a7f --- /dev/null +++ b/src/ShaderNode/DataModels/PositionOutputValue.inl @@ -0,0 +1 @@ +#include diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp index 5b248bfc3..afa53d2f3 100644 --- a/src/ShaderNode/ShaderGraph.cpp +++ b/src/ShaderNode/ShaderGraph.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -657,6 +658,7 @@ std::shared_ptr ShaderGraph::BuildRegistry() RegisterShaderNode(*this, registry, "Casts"); RegisterShaderNode(*this, registry, "Constants"); RegisterShaderNode(*this, registry, "Inputs"); + RegisterShaderNode(*this, registry, "Outputs"); RegisterShaderNode(*this, registry, "Outputs"); RegisterShaderNode(*this, registry, "Texture"); RegisterShaderNode(*this, registry, "Texture"); From 7b1d712560dc02b1d03d5038203357b49d9c823e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 22 Jul 2020 14:47:13 +0200 Subject: [PATCH 274/316] ShaderNode: Fix struct members serialization --- src/ShaderNode/ShaderGraph.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp index afa53d2f3..b7f9b99a6 100644 --- a/src/ShaderNode/ShaderGraph.cpp +++ b/src/ShaderNode/ShaderGraph.cpp @@ -359,7 +359,7 @@ QJsonObject ShaderGraph::Save() static_assert(AlwaysFalse::value, "non-exhaustive visitor"); }, member.type); - memberDoc["type"] = QString::fromStdString(member.name); + memberArray.append(std::move(memberDoc)); } structDoc["members"] = memberArray; From c6c301c9f58698e7070b2e063123d9325d8d97b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 22 Jul 2020 14:47:57 +0200 Subject: [PATCH 275/316] ShaderNode: Fix BufferField remaining bugs --- src/ShaderNode/DataModels/BufferField.cpp | 35 +++++++++++++++++------ src/ShaderNode/DataModels/BufferField.hpp | 10 +++---- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/src/ShaderNode/DataModels/BufferField.cpp b/src/ShaderNode/DataModels/BufferField.cpp index 480d53c2c..844f56bd8 100644 --- a/src/ShaderNode/DataModels/BufferField.cpp +++ b/src/ShaderNode/DataModels/BufferField.cpp @@ -3,8 +3,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -12,6 +14,8 @@ BufferField::BufferField(ShaderGraph& graph) : ShaderNode(graph) { + UpdateFieldList(); + m_onBufferListUpdateSlot.Connect(GetGraph().OnBufferListUpdate, [&](ShaderGraph*) { UpdateBufferIndex(); }); m_onBufferUpdateSlot.Connect(GetGraph().OnBufferUpdate, [&](ShaderGraph*, std::size_t bufferIndex) { @@ -25,6 +29,7 @@ ShaderNode(graph) m_onStructListUpdateSlot.Connect(GetGraph().OnStructListUpdate, [&](ShaderGraph*) { + UpdateFieldList(); UpdateFieldIndex(); UpdatePreview(); @@ -33,6 +38,7 @@ ShaderNode(graph) m_onStructUpdateSlot.Connect(GetGraph().OnStructUpdate, [&](ShaderGraph*, std::size_t) { + UpdateFieldList(); UpdateFieldIndex(); UpdatePreview(); @@ -87,7 +93,7 @@ Nz::ShaderNodes::ExpressionPtr BufferField::GetExpression(Nz::ShaderNodes::Expre const auto& memberEntry = sourceStruct->members[currentField.finalFieldIndex]; assert(std::holds_alternative(memberEntry.type)); - return Nz::ShaderBuilder::AccessMember(std::move(sourceExpr), 0, graph.ToShaderExpressionType(std::get(memberEntry.type))); + return Nz::ShaderBuilder::AccessMember(std::move(sourceExpr), currentField.finalFieldIndex, graph.ToShaderExpressionType(std::get(memberEntry.type))); } unsigned int BufferField::nPorts(QtNodes::PortType portType) const @@ -109,7 +115,7 @@ void BufferField::BuildNodeEdition(QFormLayout* layout) connect(fieldSelection, qOverload(&QComboBox::currentIndexChanged), [=](int index) { if (index >= 0) - m_currentFieldText = fieldSelection->itemText(index).toStdString(); + m_currentFieldText = m_fieldList[index]; else m_currentFieldText.clear(); @@ -132,9 +138,9 @@ void BufferField::BuildNodeEdition(QFormLayout* layout) { m_currentBufferIndex = static_cast(index); - const ShaderGraph& graph = GetGraph(); - const auto& buffer = graph.GetBuffer(*m_currentBufferIndex); - PopulateField(fieldSelection, buffer.structIndex); + UpdateFieldList(); + for (const std::string& field : m_fieldList) + fieldSelection->addItem(QString::fromStdString(field)); } else m_currentBufferIndex.reset(); @@ -257,6 +263,7 @@ void BufferField::restore(const QJsonObject& data) m_currentBufferText = data["buffer"].toString().toStdString(); m_currentFieldText = data["field"].toString().toStdString(); UpdateBufferIndex(); + UpdateFieldIndex(); ShaderNode::restore(data); } @@ -307,7 +314,7 @@ bool BufferField::ComputePreview(QPixmap& pixmap) return true;*/ } -void BufferField::PopulateField(QComboBox* fieldList, std::size_t structIndex, const std::string& prefix) +void BufferField::PopulateFieldList(std::size_t structIndex, const std::string& prefix) { const auto& s = GetGraph().GetStruct(structIndex); for (const auto& member : s.members) @@ -316,9 +323,9 @@ void BufferField::PopulateField(QComboBox* fieldList, std::size_t structIndex, c { using T = std::decay_t; if constexpr (std::is_same_v) - fieldList->addItem(QString::fromStdString(prefix + member.name)); + m_fieldList.push_back(prefix + member.name); else if constexpr (std::is_same_v) - PopulateField(fieldList, arg, prefix + member.name + "."); + PopulateFieldList(arg, prefix + member.name + "."); else static_assert(AlwaysFalse::value, "non-exhaustive visitor"); }, @@ -454,3 +461,15 @@ void BufferField::UpdateFieldIndex() if (FetchField(buffer.structIndex, "")) resetIfNotFound.Reset(); } + +void BufferField::UpdateFieldList() +{ + m_fieldList.clear(); + if (!m_currentBufferIndex) + return; + + const ShaderGraph& graph = GetGraph(); + const auto& buffer = graph.GetBuffer(*m_currentBufferIndex); + + PopulateFieldList(buffer.structIndex); +} diff --git a/src/ShaderNode/DataModels/BufferField.hpp b/src/ShaderNode/DataModels/BufferField.hpp index 7d1295e99..8bd232a7a 100644 --- a/src/ShaderNode/DataModels/BufferField.hpp +++ b/src/ShaderNode/DataModels/BufferField.hpp @@ -3,13 +3,11 @@ #ifndef NAZARA_SHADERNODES_BUFFERFIELD_HPP #define NAZARA_SHADERNODES_BUFFERFIELD_HPP -#include -#include -#include #include #include -#include #include +#include +#include class BufferField : public ShaderNode { @@ -41,11 +39,12 @@ class BufferField : public ShaderNode private: bool ComputePreview(QPixmap& pixmap) override; - void PopulateField(QComboBox* fieldList, std::size_t structIndex, const std::string& prefix = ""); + void PopulateFieldList(std::size_t structIndex, const std::string& prefix = ""); const ShaderGraph::StructMemberEntry& RetrieveNestedMember() const; void UpdateBufferIndex(); void UpdateBufferText(); void UpdateFieldIndex(); + void UpdateFieldList(); NazaraSlot(ShaderGraph, OnBufferListUpdate, m_onBufferListUpdateSlot); NazaraSlot(ShaderGraph, OnBufferUpdate, m_onBufferUpdateSlot); @@ -63,6 +62,7 @@ class BufferField : public ShaderNode std::optional m_currentFieldIndex; std::string m_currentBufferText; std::string m_currentFieldText; + std::vector m_fieldList; }; #include From 063b7dd6020e10813ff2505e699c5020ca38acaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 22 Jul 2020 14:48:15 +0200 Subject: [PATCH 276/316] Renderer/GlslWriter: Add parenthesis where required (wip) --- include/Nazara/Renderer/GlslWriter.hpp | 1 + src/Nazara/Renderer/GlslWriter.cpp | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/include/Nazara/Renderer/GlslWriter.hpp b/include/Nazara/Renderer/GlslWriter.hpp index ba2444aec..f9694a8f1 100644 --- a/include/Nazara/Renderer/GlslWriter.hpp +++ b/include/Nazara/Renderer/GlslWriter.hpp @@ -61,6 +61,7 @@ namespace Nz using ShaderVarVisitor::Visit; using ShaderVisitor::Visit; + void Visit(const ShaderNodes::ExpressionPtr& expr, bool encloseIfRequired = false); void Visit(const ShaderNodes::AccessMember& node) override; void Visit(const ShaderNodes::AssignOp& node) override; void Visit(const ShaderNodes::Branch& node) override; diff --git a/src/Nazara/Renderer/GlslWriter.cpp b/src/Nazara/Renderer/GlslWriter.cpp index 972cdb4d2..3f2a4a4a3 100644 --- a/src/Nazara/Renderer/GlslWriter.cpp +++ b/src/Nazara/Renderer/GlslWriter.cpp @@ -297,11 +297,22 @@ namespace Nz AppendLine("}"); } + void GlslWriter::Visit(const ShaderNodes::ExpressionPtr& expr, bool encloseIfRequired) + { + bool enclose = encloseIfRequired && (expr->GetExpressionCategory() != ShaderNodes::ExpressionCategory::LValue); + + if (enclose) + Append("("); + + ShaderVisitor::Visit(expr); + + if (enclose) + Append(")"); + } + void GlslWriter::Visit(const ShaderNodes::AccessMember& node) { - Append("("); - Visit(node.structExpr); - Append(")"); + Visit(node.structExpr, true); const ShaderExpressionType& exprType = node.structExpr->GetExpressionType(); assert(std::holds_alternative(exprType)); @@ -365,7 +376,7 @@ namespace Nz void GlslWriter::Visit(const ShaderNodes::BinaryOp& node) { - Visit(node.left); + Visit(node.left, true); switch (node.op) { @@ -386,7 +397,7 @@ namespace Nz break; } - Visit(node.right); + Visit(node.right, true); } void GlslWriter::Visit(const ShaderNodes::BuiltinVariable& var) From 6d0a59caab1650c25b25cf5bbc9ae35eb878c5bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 22 Jul 2020 14:48:35 +0200 Subject: [PATCH 277/316] VulkanTest: Use generated shader nodes --- examples/VulkanTest/main.cpp | 4 ++-- examples/bin/frag.shader | Bin 0 -> 610 bytes examples/bin/shader.shader | Bin 510 -> 0 bytes examples/bin/vert.shader | Bin 0 -> 695 bytes 4 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 examples/bin/frag.shader delete mode 100644 examples/bin/shader.shader create mode 100644 examples/bin/vert.shader diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index e0cb14437..f52e14561 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -44,14 +44,14 @@ int main() return __LINE__; } #else - auto fragmentShader = device->InstantiateShaderStage(Nz::ShaderStageType::Fragment, Nz::ShaderLanguage::NazaraBinary, "shader.shader"); + auto fragmentShader = device->InstantiateShaderStage(Nz::ShaderStageType::Fragment, Nz::ShaderLanguage::NazaraBinary, "frag.shader"); if (!fragmentShader) { std::cout << "Failed to instantiate fragment shader" << std::endl; return __LINE__; } - auto vertexShader = device->InstantiateShaderStage(Nz::ShaderStageType::Vertex, Nz::ShaderLanguage::GLSL, "resources/shaders/triangle.vert"); + auto vertexShader = device->InstantiateShaderStage(Nz::ShaderStageType::Vertex, Nz::ShaderLanguage::NazaraBinary, "vert.shader"); if (!vertexShader) { std::cout << "Failed to instantiate fragment shader" << std::endl; diff --git a/examples/bin/frag.shader b/examples/bin/frag.shader new file mode 100644 index 0000000000000000000000000000000000000000..bf92becd151cdb94d0caf6505eee679eb663e25e GIT binary patch literal 610 zcmdr|%L>9U5R7frYU#gt@ZO7vryg4M9yHWIno7vQzw@WO3hpckKIj)17&e{R>CUEZ zca0EYLcmD~xwiG-dTBtUQOUGD9Kj@DBFaYDvvPasI^|c8vuHqFdUb1Me>KWMn?)P@ zvtDXT>>LuEl8_Sc%{h$jE`Fog3Sk-=#C`pIRD_S_f}6MU7=9LXNz$EUM>iu l)AHb;!fqrOS(jMY;|$cXECun%fE|8cB}j<+e&xSe9U5KJGo)%J6|_n;I{J@~o@ZEK)yptj)AKl7)&itdCgXcb%-Cd^J|lg&4) zwGhG~xP(Zxx$YWS)7gWF@>RRr6T1)?i5~i_lhs1kx`T<`;BZ@9`k^c681MzK-$>P> zPe3IEpAZnt_*zw`eyI@X*&bNj=8trp8P$ diff --git a/examples/bin/vert.shader b/examples/bin/vert.shader new file mode 100644 index 0000000000000000000000000000000000000000..63df1bfb3e72b125fb3222535f8a1ace0f827aa8 GIT binary patch literal 695 zcmah`K@Ng25Uf(77=4omFP@B1KY-Xn4Ny}>Jo+=ArZa^qsU&PNS$1}Jy1Q)l>zxo{ z)M8qsH>)#sMH~V0V$B&|#6)due)5sLYgPMzwXrU@hK(Yk94*o1#@Hgwe>77wT^`h9 zWsG%dV{+pbiK%W)4~U=A9JKFoVy?-L9aTre@9+2w+*01lBGn~=2?^K&kiZmh#qbHh zMgHGvlPnBp2i2z$tkDq&Zh{PF;`+%ovr73RayoyM&?DuH6Z6mf?awR|G$#!|SjhDT o6*(5cLN;{%IwP{nrx5Sf5Qpah)mV2!HcB?W0D1z(XL@e)0UA Date: Mon, 27 Jul 2020 18:52:58 +0200 Subject: [PATCH 278/316] Add shader type --- include/Nazara/Renderer/ShaderAst.hpp | 10 +++- include/Nazara/Renderer/ShaderAst.inl | 10 ++++ include/Nazara/Renderer/ShaderWriter.hpp | 4 +- .../OpenGLRenderer/OpenGLShaderStage.cpp | 3 + src/Nazara/Renderer/ShaderSerializer.cpp | 7 ++- src/ShaderNode/Enums.cpp | 13 +++++ src/ShaderNode/Enums.hpp | 13 +++++ src/ShaderNode/ShaderGraph.cpp | 33 ++++++++++- src/ShaderNode/ShaderGraph.hpp | 6 ++ src/ShaderNode/ShaderGraph.inl | 5 ++ src/ShaderNode/Widgets/MainWindow.cpp | 39 ++++++++++--- src/ShaderNode/Widgets/MainWindow.hpp | 1 + src/ShaderNode/Widgets/ShaderInfoDialog.cpp | 58 +++++++++++++++++++ src/ShaderNode/Widgets/ShaderInfoDialog.hpp | 33 +++++++++++ src/ShaderNode/Widgets/ShaderInfoDialog.inl | 1 + 15 files changed, 224 insertions(+), 12 deletions(-) create mode 100644 src/ShaderNode/Widgets/ShaderInfoDialog.cpp create mode 100644 src/ShaderNode/Widgets/ShaderInfoDialog.hpp create mode 100644 src/ShaderNode/Widgets/ShaderInfoDialog.inl diff --git a/include/Nazara/Renderer/ShaderAst.hpp b/include/Nazara/Renderer/ShaderAst.hpp index 035aa5cce..51117c1d7 100644 --- a/include/Nazara/Renderer/ShaderAst.hpp +++ b/include/Nazara/Renderer/ShaderAst.hpp @@ -8,6 +8,7 @@ #define NAZARA_SHADER_AST_HPP #include +#include #include #include #include @@ -27,7 +28,9 @@ namespace Nz struct Uniform; struct VariableBase; - ShaderAst() = default; + inline ShaderAst(ShaderStageType shaderStage); + ShaderAst(const ShaderAst&) = default; + ShaderAst(ShaderAst&&) = default; ~ShaderAst() = default; void AddFunction(std::string name, ShaderNodes::StatementPtr statement, std::vector parameters = {}, ShaderNodes::BasicType returnType = ShaderNodes::BasicType::Void); @@ -45,6 +48,7 @@ namespace Nz inline const InputOutput& GetOutput(std::size_t i) const; inline std::size_t GetOutputCount() const; inline const std::vector& GetOutputs() const; + inline ShaderStageType GetStage() const; inline const Struct& GetStruct(std::size_t i) const; inline std::size_t GetStructCount() const; inline const std::vector& GetStructs() const; @@ -52,6 +56,9 @@ namespace Nz inline std::size_t GetUniformCount() const; inline const std::vector& GetUniforms() const; + ShaderAst& operator=(const ShaderAst&) = default; + ShaderAst& operator=(ShaderAst&&) = default; + struct VariableBase { std::string name; @@ -99,6 +106,7 @@ namespace Nz std::vector m_outputs; std::vector m_structs; std::vector m_uniforms; + ShaderStageType m_stage; }; } diff --git a/include/Nazara/Renderer/ShaderAst.inl b/include/Nazara/Renderer/ShaderAst.inl index c42c1e9c1..f0bc1aebb 100644 --- a/include/Nazara/Renderer/ShaderAst.inl +++ b/include/Nazara/Renderer/ShaderAst.inl @@ -7,6 +7,11 @@ namespace Nz { + inline ShaderAst::ShaderAst(ShaderStageType shaderStage) : + m_stage(shaderStage) + { + } + inline auto ShaderAst::GetFunction(std::size_t i) const -> const Function& { assert(i < m_functions.size()); @@ -55,6 +60,11 @@ namespace Nz return m_outputs; } + inline ShaderStageType ShaderAst::GetStage() const + { + return m_stage; + } + inline auto ShaderAst::GetStruct(std::size_t i) const -> const Struct& { assert(i < m_structs.size()); diff --git a/include/Nazara/Renderer/ShaderWriter.hpp b/include/Nazara/Renderer/ShaderWriter.hpp index 6c2655226..e4fe2d835 100644 --- a/include/Nazara/Renderer/ShaderWriter.hpp +++ b/include/Nazara/Renderer/ShaderWriter.hpp @@ -19,8 +19,8 @@ namespace Nz { public: ShaderWriter() = default; - ShaderWriter(const ShaderWriter&) = delete; - ShaderWriter(ShaderWriter&&) = delete; + ShaderWriter(const ShaderWriter&) = default; + ShaderWriter(ShaderWriter&&) = default; virtual ~ShaderWriter(); virtual std::string Generate(const ShaderAst& shader) = 0; diff --git a/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp b/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp index b7cc63c9f..a2a3fbf7a 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp @@ -31,6 +31,9 @@ namespace Nz ByteStream byteStream(source, sourceSize); auto shader = Nz::UnserializeShader(byteStream); + if (shader.GetStage() != type) + throw std::runtime_error("incompatible shader stage"); + const auto& context = device.GetReferenceContext(); const auto& contextParams = context.GetParams(); diff --git a/src/Nazara/Renderer/ShaderSerializer.cpp b/src/Nazara/Renderer/ShaderSerializer.cpp index 350ec2096..7441162a0 100644 --- a/src/Nazara/Renderer/ShaderSerializer.cpp +++ b/src/Nazara/Renderer/ShaderSerializer.cpp @@ -261,6 +261,8 @@ namespace Nz { m_stream << s_magicNumber << s_currentVersion; + m_stream << UInt32(shader.GetStage()); + auto SerializeType = [&](const ShaderExpressionType& type) { std::visit([&](auto&& arg) @@ -454,7 +456,10 @@ namespace Nz if (version > s_currentVersion) throw std::runtime_error("unsupported version"); - ShaderAst shader; + UInt32 shaderStage; + m_stream >> shaderStage; + + ShaderAst shader(static_cast(shaderStage)); UInt32 structCount; m_stream >> structCount; diff --git a/src/ShaderNode/Enums.cpp b/src/ShaderNode/Enums.cpp index 2c924c3ed..73af36b06 100644 --- a/src/ShaderNode/Enums.cpp +++ b/src/ShaderNode/Enums.cpp @@ -58,6 +58,19 @@ const char* EnumToString(PrimitiveType input) return ""; } +const char* EnumToString(ShaderType type) +{ + switch (type) + { + case ShaderType::NotSet: return "NotSet"; + case ShaderType::Fragment: return "Fragment"; + case ShaderType::Vertex: return "Vertex"; + } + + assert(false); + return ""; +} + const char* EnumToString(TextureType textureType) { switch (textureType) diff --git a/src/ShaderNode/Enums.hpp b/src/ShaderNode/Enums.hpp index e59d66424..c57969fb2 100644 --- a/src/ShaderNode/Enums.hpp +++ b/src/ShaderNode/Enums.hpp @@ -42,6 +42,18 @@ enum class PrimitiveType constexpr std::size_t PrimitiveTypeCount = static_cast(PrimitiveType::Max) + 1; +enum class ShaderType +{ + NotSet = -1, + + Fragment, + Vertex, + + Max = Vertex +}; + +constexpr std::size_t ShaderTypeCount = static_cast(ShaderType::Max) + 1; + enum class TextureType { Sampler2D, @@ -56,6 +68,7 @@ template std::optional DecodeEnum(const std::string_view& str); const char* EnumToString(BufferType bufferType); const char* EnumToString(InputRole role); const char* EnumToString(PrimitiveType input); +const char* EnumToString(ShaderType type); const char* EnumToString(TextureType textureType); std::size_t GetComponentCount(PrimitiveType type); diff --git a/src/ShaderNode/ShaderGraph.cpp b/src/ShaderNode/ShaderGraph.cpp index b7f9b99a6..a1799df3b 100644 --- a/src/ShaderNode/ShaderGraph.cpp +++ b/src/ShaderNode/ShaderGraph.cpp @@ -41,7 +41,8 @@ namespace } ShaderGraph::ShaderGraph() : -m_flowScene(BuildRegistry()) +m_flowScene(BuildRegistry()), +m_type(ShaderType::NotSet) { m_previewModel = std::make_unique(); @@ -178,6 +179,8 @@ std::size_t ShaderGraph::AddTexture(std::string name, TextureType type, std::siz void ShaderGraph::Clear() { + m_type = ShaderType::NotSet; + m_flowScene.clearScene(); m_flowScene.clear(); @@ -198,6 +201,9 @@ void ShaderGraph::Load(const QJsonObject& data) { Clear(); + if (auto typeOpt = DecodeEnum(data["type"].toString().toStdString())) + m_type = typeOpt.value(); + QJsonArray bufferArray = data["buffers"].toArray(); for (const auto& bufferDocRef : bufferArray) { @@ -289,6 +295,7 @@ void ShaderGraph::Load(const QJsonObject& data) QJsonObject ShaderGraph::Save() { QJsonObject sceneJson; + sceneJson["type"] = QString(EnumToString(m_type)); QJsonArray bufferArray; { @@ -599,6 +606,15 @@ void ShaderGraph::UpdateTexturePreview(std::size_t textureIndex, QImage preview) OnTexturePreviewUpdate(this, textureIndex); } +void ShaderGraph::UpdateType(ShaderType type) +{ + if (m_type != type) + { + m_type = type; + OnTypeUpdated(this); + } +} + QtNodes::NodeDataType ShaderGraph::ToNodeDataType(PrimitiveType type) { switch (type) @@ -649,6 +665,21 @@ Nz::ShaderExpressionType ShaderGraph::ToShaderExpressionType(TextureType type) throw std::runtime_error("Unhandled texture type"); } +Nz::ShaderStageType ShaderGraph::ToShaderStageType(ShaderType type) +{ + switch (type) + { + case ShaderType::NotSet: + throw std::runtime_error("Invalid shader type"); + + case ShaderType::Fragment: return Nz::ShaderStageType::Fragment; + case ShaderType::Vertex: return Nz::ShaderStageType::Vertex; + } + + assert(false); + throw std::runtime_error("Unhandled shader type"); +} + std::shared_ptr ShaderGraph::BuildRegistry() { auto registry = std::make_shared(); diff --git a/src/ShaderNode/ShaderGraph.hpp b/src/ShaderNode/ShaderGraph.hpp index e91127cb5..be7aeba4c 100644 --- a/src/ShaderNode/ShaderGraph.hpp +++ b/src/ShaderNode/ShaderGraph.hpp @@ -4,6 +4,7 @@ #define NAZARA_SHADERNODES_SHADERGRAPH_HPP #include +#include #include #include #include @@ -51,6 +52,7 @@ class ShaderGraph inline const TextureEntry& GetTexture(std::size_t textureIndex) const; inline std::size_t GetTextureCount() const; inline const std::vector& GetTextures() const; + inline ShaderType GetType() const; void Load(const QJsonObject& data); QJsonObject Save(); @@ -64,6 +66,7 @@ class ShaderGraph void UpdateStruct(std::size_t structIndex, std::string name, std::vector members); void UpdateTexture(std::size_t textureIndex, std::string name, TextureType type, std::size_t bindingIndex); void UpdateTexturePreview(std::size_t texture, QImage preview); + void UpdateType(ShaderType type); struct BufferEntry { @@ -121,10 +124,12 @@ class ShaderGraph NazaraSignal(OnTextureListUpdate, ShaderGraph*); NazaraSignal(OnTexturePreviewUpdate, ShaderGraph*, std::size_t /*textureIndex*/); NazaraSignal(OnTextureUpdate, ShaderGraph*, std::size_t /*textureIndex*/); + NazaraSignal(OnTypeUpdated, ShaderGraph*); static QtNodes::NodeDataType ToNodeDataType(PrimitiveType type); static Nz::ShaderExpressionType ToShaderExpressionType(PrimitiveType type); static Nz::ShaderExpressionType ToShaderExpressionType(TextureType type); + static Nz::ShaderStageType ToShaderStageType(ShaderType type); private: std::shared_ptr BuildRegistry(); @@ -136,6 +141,7 @@ class ShaderGraph std::vector m_structs; std::vector m_textures; std::unique_ptr m_previewModel; + ShaderType m_type; }; #include diff --git a/src/ShaderNode/ShaderGraph.inl b/src/ShaderNode/ShaderGraph.inl index 04f86834c..afa867dcd 100644 --- a/src/ShaderNode/ShaderGraph.inl +++ b/src/ShaderNode/ShaderGraph.inl @@ -90,3 +90,8 @@ inline auto ShaderGraph::GetTextures() const -> const std::vector& return m_textures; } +inline ShaderType ShaderGraph::GetType() const +{ + return m_type; +} + diff --git a/src/ShaderNode/Widgets/MainWindow.cpp b/src/ShaderNode/Widgets/MainWindow.cpp index 7c7101047..f25f95a18 100644 --- a/src/ShaderNode/Widgets/MainWindow.cpp +++ b/src/ShaderNode/Widgets/MainWindow.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -104,19 +105,27 @@ void MainWindow::BuildMenu() { QMenuBar* menu = menuBar(); + QMenu* file = menu->addMenu(tr("&File")); + { + QAction* loadShader = file->addAction(tr("Load...")); + QObject::connect(loadShader, &QAction::triggered, this, &MainWindow::OnLoad); + QAction* saveShader = file->addAction(tr("Save...")); + QObject::connect(saveShader, &QAction::triggered, this, &MainWindow::OnSave); + } + QMenu* shader = menu->addMenu(tr("&Shader")); { - QAction* loadShader = shader->addAction(tr("Load...")); - QObject::connect(loadShader, &QAction::triggered, this, &MainWindow::OnLoad); - QAction* saveShader = shader->addAction(tr("Save...")); - QObject::connect(saveShader, &QAction::triggered, this, &MainWindow::OnSave); + QAction* settings = shader->addAction(tr("Settings...")); + QObject::connect(settings, &QAction::triggered, this, &MainWindow::OnUpdateInfo); QAction* compileShader = shader->addAction(tr("Compile...")); QObject::connect(compileShader, &QAction::triggered, this, &MainWindow::OnCompile); } QMenu* generateMenu = menu->addMenu(tr("&Generate")); - QAction* generateGlsl = generateMenu->addAction(tr("GLSL")); - connect(generateGlsl, &QAction::triggered, [&](bool) { OnGenerateGLSL(); }); + { + QAction* generateGlsl = generateMenu->addAction(tr("GLSL")); + connect(generateGlsl, &QAction::triggered, [&](bool) { OnGenerateGLSL(); }); + } } void MainWindow::OnCompile() @@ -208,11 +217,27 @@ void MainWindow::OnSave() file.write(QJsonDocument(m_shaderGraph.Save()).toJson()); } +void MainWindow::OnUpdateInfo() +{ + ShaderInfo info; + info.type = m_shaderGraph.GetType(); + + ShaderInfoDialog* dialog = new ShaderInfoDialog(std::move(info), this); + dialog->setAttribute(Qt::WA_DeleteOnClose, true); + connect(dialog, &QDialog::accepted, [this, dialog] + { + ShaderInfo shaderInfo = dialog->GetShaderInfo(); + m_shaderGraph.UpdateType(shaderInfo.type); + }); + + dialog->open(); +} + Nz::ShaderAst MainWindow::ToShader() { Nz::ShaderNodes::StatementPtr shaderAst = m_shaderGraph.ToAst(); - Nz::ShaderAst shader; + Nz::ShaderAst shader(ShaderGraph::ToShaderStageType(m_shaderGraph.GetType())); //< FIXME for (const auto& input : m_shaderGraph.GetInputs()) shader.AddInput(input.name, m_shaderGraph.ToShaderExpressionType(input.type), input.locationIndex); diff --git a/src/ShaderNode/Widgets/MainWindow.hpp b/src/ShaderNode/Widgets/MainWindow.hpp index 25c742625..76615bb98 100644 --- a/src/ShaderNode/Widgets/MainWindow.hpp +++ b/src/ShaderNode/Widgets/MainWindow.hpp @@ -26,6 +26,7 @@ class MainWindow : public QMainWindow void OnGenerateGLSL(); void OnLoad(); void OnSave(); + void OnUpdateInfo(); Nz::ShaderAst ToShader(); NazaraSlot(ShaderGraph, OnSelectedNodeUpdate, m_onSelectedNodeUpdate); diff --git a/src/ShaderNode/Widgets/ShaderInfoDialog.cpp b/src/ShaderNode/Widgets/ShaderInfoDialog.cpp new file mode 100644 index 000000000..54687a99e --- /dev/null +++ b/src/ShaderNode/Widgets/ShaderInfoDialog.cpp @@ -0,0 +1,58 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +ShaderInfoDialog::ShaderInfoDialog(QWidget* parent) : +QDialog(parent) +{ + setWindowTitle(tr("Shader edit dialog")); + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + + m_typeList = new QComboBox; + for (std::size_t i = 0; i < ShaderTypeCount; ++i) + m_typeList->addItem(EnumToString(static_cast(i))); + + QFormLayout* formLayout = new QFormLayout; + formLayout->addRow(tr("Type"), m_typeList); + + QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + connect(buttonBox, &QDialogButtonBox::accepted, this, &ShaderInfoDialog::OnAccept); + connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + + QVBoxLayout* verticalLayout = new QVBoxLayout; + verticalLayout->addLayout(formLayout); + verticalLayout->addWidget(buttonBox); + + setLayout(verticalLayout); +} + +ShaderInfoDialog::ShaderInfoDialog(const ShaderInfo& shader, QWidget* parent) : +ShaderInfoDialog(parent) +{ + m_typeList->setCurrentText(QString(EnumToString(shader.type))); +} + +ShaderInfo ShaderInfoDialog::GetShaderInfo() const +{ + ShaderInfo bufferInfo; + bufferInfo.type = static_cast(m_typeList->currentIndex()); + + return bufferInfo; +} + +void ShaderInfoDialog::OnAccept() +{ + if (m_typeList->currentIndex() < 0) + { + QMessageBox::critical(this, tr("Invalid shader type"), tr("You must select a shader type"), QMessageBox::Ok); + return; + } + + accept(); +} diff --git a/src/ShaderNode/Widgets/ShaderInfoDialog.hpp b/src/ShaderNode/Widgets/ShaderInfoDialog.hpp new file mode 100644 index 000000000..210323a8e --- /dev/null +++ b/src/ShaderNode/Widgets/ShaderInfoDialog.hpp @@ -0,0 +1,33 @@ +#pragma once + +#ifndef NAZARA_SHADERNODES_BUFFEREDITDIALOG_HPP +#define NAZARA_SHADERNODES_BUFFEREDITDIALOG_HPP + +#include +#include + +class QComboBox; + +struct ShaderInfo +{ + ShaderType type; +}; + +class ShaderInfoDialog : public QDialog +{ + public: + ShaderInfoDialog(QWidget* parent = nullptr); + ShaderInfoDialog(const ShaderInfo& shader, QWidget* parent = nullptr); + ~ShaderInfoDialog() = default; + + ShaderInfo GetShaderInfo() const; + + private: + void OnAccept(); + + QComboBox* m_typeList; +}; + +#include + +#endif diff --git a/src/ShaderNode/Widgets/ShaderInfoDialog.inl b/src/ShaderNode/Widgets/ShaderInfoDialog.inl new file mode 100644 index 000000000..e81e9cd71 --- /dev/null +++ b/src/ShaderNode/Widgets/ShaderInfoDialog.inl @@ -0,0 +1 @@ +#include From 251810ca9929baa72b965e0eea46cd0f974fbc97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 29 Jul 2020 11:22:52 +0200 Subject: [PATCH 279/316] WIP SpirvWriter --- examples/VulkanTest/main.cpp | 33 + examples/bin/frag.shader | Bin 610 -> 610 bytes examples/bin/vert.shader | Bin 695 -> 695 bytes include/Nazara/Renderer/ShaderEnums.hpp | 9 + include/Nazara/Renderer/SpirvWriter.hpp | 100 ++ include/Nazara/Renderer/SpirvWriter.inl | 56 + src/Nazara/Renderer/SpirvWriter.cpp | 178 ++ thirdparty/include/SpirV/GLSL.std.450.h | 131 ++ thirdparty/include/SpirV/spirv.h | 2163 +++++++++++++++++++++++ 9 files changed, 2670 insertions(+) create mode 100644 include/Nazara/Renderer/SpirvWriter.hpp create mode 100644 include/Nazara/Renderer/SpirvWriter.inl create mode 100644 src/Nazara/Renderer/SpirvWriter.cpp create mode 100644 thirdparty/include/SpirV/GLSL.std.450.h create mode 100644 thirdparty/include/SpirV/spirv.h diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index f52e14561..9a5313f9a 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -7,6 +8,38 @@ int main() { + { + Nz::File file("frag.shader"); + if (!file.Open(Nz::OpenMode_ReadOnly)) + return __LINE__; + + std::size_t length = static_cast(file.GetSize()); + + std::vector source(length); + if (file.Read(&source[0], length) != length) + { + NazaraError("Failed to read program file"); + return {}; + } + + + + Nz::SpirvWriter writer; + + Nz::ByteStream byteStream(source.data(), source.size()); + auto shader = Nz::UnserializeShader(byteStream); + + std::vector result = writer.Generate(shader); + + Nz::File target("test.spirv"); + if (!target.Open(Nz::OpenMode_WriteOnly | Nz::OpenMode_Truncate)) + return __LINE__; + + target.Write(result.data(), result.size() * sizeof(Nz::UInt32)); + + return 0; + } + Nz::Initializer loader; if (!loader) { diff --git a/examples/bin/frag.shader b/examples/bin/frag.shader index bf92becd151cdb94d0caf6505eee679eb663e25e..1fbcce530ddddc3a7d749a622786ce22b08df3f9 100644 GIT binary patch delta 51 ycmaFF@`#1UFW4i9fq{V$h#59=xG;*c0vRm!4GawXffz)C@MK5Eh{<~ymjVC+!3xj- delta 28 hcmaFF@`#1QFW4i9fq{W>BaaK?WKkyHiC1bs6aaEJ2jTz# diff --git a/examples/bin/vert.shader b/examples/bin/vert.shader index 63df1bfb3e72b125fb3222535f8a1ace0f827aa8..b1fa132bbaea340fd46bf5c9b7f93ea34411ff74 100644 GIT binary patch delta 46 zcmdnax}BB7FW4i9fq{W>BFhg(=E;tX;*&)f3nsfT3QR6$5}mw?k!SKI#&wg^nF0VB CN(|uu delta 40 vcmdnax}BB9FW4h!BF7I#mdT8a?TqY`7cz-WUc`75$P=DCgHd#H2a`Sk_~r}l diff --git a/include/Nazara/Renderer/ShaderEnums.hpp b/include/Nazara/Renderer/ShaderEnums.hpp index 6edaad1de..ab9ed4953 100644 --- a/include/Nazara/Renderer/ShaderEnums.hpp +++ b/include/Nazara/Renderer/ShaderEnums.hpp @@ -81,6 +81,15 @@ namespace Nz::ShaderNodes StatementBlock }; + enum class SsaInstruction + { + OpAdd, + OpDiv, + OpMul, + OpSub, + OpSample + }; + enum class SwizzleComponent { First, diff --git a/include/Nazara/Renderer/SpirvWriter.hpp b/include/Nazara/Renderer/SpirvWriter.hpp new file mode 100644 index 000000000..6cc4bb780 --- /dev/null +++ b/include/Nazara/Renderer/SpirvWriter.hpp @@ -0,0 +1,100 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_SPIRVWRITER_HPP +#define NAZARA_SPIRVWRITER_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_RENDERER_API SpirvWriter : public ShaderVarVisitor, public ShaderVisitor + { + public: + struct Environment; + + SpirvWriter(); + SpirvWriter(const SpirvWriter&) = delete; + SpirvWriter(SpirvWriter&&) = delete; + ~SpirvWriter() = default; + + std::vector Generate(const ShaderAst& shader); + + void SetEnv(Environment environment); + + struct Environment + { + }; + + private: + struct Opcode; + + inline void Append(const char* str); + void Append(const std::string_view& str); + void Append(const Opcode& opcode, unsigned int wordCount); + void Append(UInt32 codepoint); + void Append(std::initializer_list codepoints); + template void Append(Opcode opcode, const Args&... args); + template void Append(T value); + + void AppendHeader(); + + inline unsigned int CountWord(const char* str); + unsigned int CountWord(const std::string_view& str); + template unsigned int CountWord(const T& value); + template unsigned int CountWord(const T1& value, const T2& value2, const Args&... rest); + + using ShaderVarVisitor::Visit; + using ShaderVisitor::Visit; + void Visit(const ShaderNodes::ExpressionPtr& expr, bool encloseIfRequired = false); + void Visit(const ShaderNodes::AccessMember& node) override; + void Visit(const ShaderNodes::AssignOp& node) override; + void Visit(const ShaderNodes::Branch& node) override; + void Visit(const ShaderNodes::BinaryOp& node) override; + void Visit(const ShaderNodes::BuiltinVariable& var) override; + void Visit(const ShaderNodes::Cast& node) override; + void Visit(const ShaderNodes::Constant& node) override; + void Visit(const ShaderNodes::DeclareVariable& node) override; + void Visit(const ShaderNodes::ExpressionStatement& node) override; + void Visit(const ShaderNodes::Identifier& node) override; + void Visit(const ShaderNodes::InputVariable& var) override; + void Visit(const ShaderNodes::IntrinsicCall& node) override; + void Visit(const ShaderNodes::LocalVariable& var) override; + void Visit(const ShaderNodes::ParameterVariable& var) override; + void Visit(const ShaderNodes::OutputVariable& var) override; + void Visit(const ShaderNodes::Sample2D& node) override; + void Visit(const ShaderNodes::StatementBlock& node) override; + void Visit(const ShaderNodes::SwizzleOp& node) override; + void Visit(const ShaderNodes::UniformVariable& var) override; + + struct Context + { + const ShaderAst* shader = nullptr; + const ShaderAst::Function* currentFunction = nullptr; + }; + + struct State + { + std::vector output; + }; + + Context m_context; + Environment m_environment; + State* m_currentState; + }; +} + +#include + +#endif diff --git a/include/Nazara/Renderer/SpirvWriter.inl b/include/Nazara/Renderer/SpirvWriter.inl new file mode 100644 index 000000000..86f578d3d --- /dev/null +++ b/include/Nazara/Renderer/SpirvWriter.inl @@ -0,0 +1,56 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include + +namespace Nz +{ + inline void SpirvWriter::Append(const char* str) + { + return Append(std::string_view(str)); + } + + template + void SpirvWriter::Append(T value) + { + assert(m_currentState); + m_currentState->output.push_back(static_cast(value)); + } + + template + inline void SpirvWriter::Append(Opcode opcode, const Args&... args) + { + unsigned int wordCount = 1 + (CountWord(args) + ... + 0); + Append(opcode, wordCount); + if constexpr (sizeof...(args) > 0) + (Append(args), ...); + } + + template + inline unsigned int SpirvWriter::CountWord(const T& value) + { + return 1; + } + + template + unsigned int SpirvWriter::CountWord(const T1& value, const T2& value2, const Args&... rest) + { + return CountWord(value) + CountWord(value2) + (CountWord(rest) + ...); + } + + inline unsigned int SpirvWriter::CountWord(const char* str) + { + return CountWord(std::string_view(str)); + } + + inline unsigned int SpirvWriter::CountWord(const std::string_view& str) + { + return (str.size() + 1 + 4 - 1) / 4; //< + 1 for null character + } +} + +#include diff --git a/src/Nazara/Renderer/SpirvWriter.cpp b/src/Nazara/Renderer/SpirvWriter.cpp new file mode 100644 index 000000000..863666588 --- /dev/null +++ b/src/Nazara/Renderer/SpirvWriter.cpp @@ -0,0 +1,178 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + struct SpirvWriter::Opcode + { + SpvOp op; + }; + + SpirvWriter::SpirvWriter() : + m_currentState(nullptr) + { + } + + std::vector SpirvWriter::Generate(const ShaderAst& shader) + { + std::string error; + if (!ValidateShader(shader, &error)) + throw std::runtime_error("Invalid shader AST: " + error); + + m_context.shader = &shader; + + State state; + m_currentState = &state; + CallOnExit onExit([this]() + { + m_currentState = nullptr; + }); + + AppendHeader(); + + // OpImageSampleImplicitLod %23 %31 %35 + + //Append("BONJOUR PRAETONUS"); + + std::vector ret = std::move(state.output); + return ret; + } + + void SpirvWriter::SetEnv(Environment environment) + { + m_environment = std::move(environment); + } + + void SpirvWriter::Append(const std::string_view& str) + { + std::size_t size4 = CountWord(str); + for (std::size_t i = 0; i < size4; ++i) + { + auto GetChar = [&](std::size_t pos) -> UInt32 + { + if (pos < str.size()) + return static_cast(str[pos]); + else + return 0; + }; + + UInt32 codepoint = 0; + for (std::size_t j = 0; j < 4; ++j) + codepoint |= GetChar(i * 4 + j) << (j * 8); + + Append(codepoint); + } + } + + void SpirvWriter::Append(const Opcode& opcode, unsigned int wordCount) + { + Append(UInt32(opcode.op) | UInt32(wordCount) << 16); + } + + void SpirvWriter::Append(UInt32 codepoint) + { + assert(m_currentState); + m_currentState->output.push_back(codepoint); + } + + void SpirvWriter::Append(std::initializer_list codepoints) + { + for (UInt32 cp : codepoints) + Append(cp); + } + + void SpirvWriter::AppendHeader() + { + Append(SpvMagicNumber); //< Spir-V magic number + Append(0x00010000); //< Spir-V version number (1.0 for compatibility) + Append(0); //< Generator magic number (TODO: Register generator to Khronos) + Append(1); //< Bound (ID count) + Append(0); //< Instruction schema (required to be 0 for now) + Append(Opcode{ SpvOpCapability }, SpvCapabilityShader); + Append(Opcode{ SpvOpExtInstImport }, 1, "GLSL.std.450"); + Append(Opcode{ SpvOpMemoryModel }, SpvAddressingModelLogical, SpvMemoryModelGLSL450); + + assert(m_context.shader); + switch (m_context.shader->GetStage()) + { + case ShaderStageType::Fragment: + break; + case ShaderStageType::Vertex: + break; + + default: + break; + } + } + + void SpirvWriter::Visit(const ShaderNodes::ExpressionPtr& expr, bool encloseIfRequired) + { + } + void SpirvWriter::Visit(const ShaderNodes::AccessMember& node) + { + } + void SpirvWriter::Visit(const ShaderNodes::AssignOp& node) + { + } + void SpirvWriter::Visit(const ShaderNodes::Branch& node) + { + } + void SpirvWriter::Visit(const ShaderNodes::BinaryOp& node) + { + } + void SpirvWriter::Visit(const ShaderNodes::BuiltinVariable& var) + { + } + void SpirvWriter::Visit(const ShaderNodes::Cast& node) + { + } + void SpirvWriter::Visit(const ShaderNodes::Constant& node) + { + } + void SpirvWriter::Visit(const ShaderNodes::DeclareVariable& node) + { + } + void SpirvWriter::Visit(const ShaderNodes::ExpressionStatement& node) + { + } + void SpirvWriter::Visit(const ShaderNodes::Identifier& node) + { + } + void SpirvWriter::Visit(const ShaderNodes::InputVariable& var) + { + } + void SpirvWriter::Visit(const ShaderNodes::IntrinsicCall& node) + { + } + void SpirvWriter::Visit(const ShaderNodes::LocalVariable& var) + { + } + void SpirvWriter::Visit(const ShaderNodes::ParameterVariable& var) + { + } + void SpirvWriter::Visit(const ShaderNodes::OutputVariable& var) + { + } + void SpirvWriter::Visit(const ShaderNodes::Sample2D& node) + { + } + void SpirvWriter::Visit(const ShaderNodes::StatementBlock& node) + { + } + void SpirvWriter::Visit(const ShaderNodes::SwizzleOp& node) + { + } + void SpirvWriter::Visit(const ShaderNodes::UniformVariable& var) + { + } +} diff --git a/thirdparty/include/SpirV/GLSL.std.450.h b/thirdparty/include/SpirV/GLSL.std.450.h new file mode 100644 index 000000000..54cc00e9a --- /dev/null +++ b/thirdparty/include/SpirV/GLSL.std.450.h @@ -0,0 +1,131 @@ +/* +** Copyright (c) 2014-2016 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a copy +** of this software and/or associated documentation files (the "Materials"), +** to deal in the Materials without restriction, including without limitation +** the rights to use, copy, modify, merge, publish, distribute, sublicense, +** and/or sell copies of the Materials, and to permit persons to whom the +** Materials are 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 Materials. +** +** MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS +** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND +** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ +** +** THE MATERIALS ARE 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 MATERIALS OR THE USE OR OTHER DEALINGS +** IN THE MATERIALS. +*/ + +#ifndef GLSLstd450_H +#define GLSLstd450_H + +static const int GLSLstd450Version = 100; +static const int GLSLstd450Revision = 3; + +enum GLSLstd450 { + GLSLstd450Bad = 0, // Don't use + + GLSLstd450Round = 1, + GLSLstd450RoundEven = 2, + GLSLstd450Trunc = 3, + GLSLstd450FAbs = 4, + GLSLstd450SAbs = 5, + GLSLstd450FSign = 6, + GLSLstd450SSign = 7, + GLSLstd450Floor = 8, + GLSLstd450Ceil = 9, + GLSLstd450Fract = 10, + + GLSLstd450Radians = 11, + GLSLstd450Degrees = 12, + GLSLstd450Sin = 13, + GLSLstd450Cos = 14, + GLSLstd450Tan = 15, + GLSLstd450Asin = 16, + GLSLstd450Acos = 17, + GLSLstd450Atan = 18, + GLSLstd450Sinh = 19, + GLSLstd450Cosh = 20, + GLSLstd450Tanh = 21, + GLSLstd450Asinh = 22, + GLSLstd450Acosh = 23, + GLSLstd450Atanh = 24, + GLSLstd450Atan2 = 25, + + GLSLstd450Pow = 26, + GLSLstd450Exp = 27, + GLSLstd450Log = 28, + GLSLstd450Exp2 = 29, + GLSLstd450Log2 = 30, + GLSLstd450Sqrt = 31, + GLSLstd450InverseSqrt = 32, + + GLSLstd450Determinant = 33, + GLSLstd450MatrixInverse = 34, + + GLSLstd450Modf = 35, // second operand needs an OpVariable to write to + GLSLstd450ModfStruct = 36, // no OpVariable operand + GLSLstd450FMin = 37, + GLSLstd450UMin = 38, + GLSLstd450SMin = 39, + GLSLstd450FMax = 40, + GLSLstd450UMax = 41, + GLSLstd450SMax = 42, + GLSLstd450FClamp = 43, + GLSLstd450UClamp = 44, + GLSLstd450SClamp = 45, + GLSLstd450FMix = 46, + GLSLstd450IMix = 47, // Reserved + GLSLstd450Step = 48, + GLSLstd450SmoothStep = 49, + + GLSLstd450Fma = 50, + GLSLstd450Frexp = 51, // second operand needs an OpVariable to write to + GLSLstd450FrexpStruct = 52, // no OpVariable operand + GLSLstd450Ldexp = 53, + + GLSLstd450PackSnorm4x8 = 54, + GLSLstd450PackUnorm4x8 = 55, + GLSLstd450PackSnorm2x16 = 56, + GLSLstd450PackUnorm2x16 = 57, + GLSLstd450PackHalf2x16 = 58, + GLSLstd450PackDouble2x32 = 59, + GLSLstd450UnpackSnorm2x16 = 60, + GLSLstd450UnpackUnorm2x16 = 61, + GLSLstd450UnpackHalf2x16 = 62, + GLSLstd450UnpackSnorm4x8 = 63, + GLSLstd450UnpackUnorm4x8 = 64, + GLSLstd450UnpackDouble2x32 = 65, + + GLSLstd450Length = 66, + GLSLstd450Distance = 67, + GLSLstd450Cross = 68, + GLSLstd450Normalize = 69, + GLSLstd450FaceForward = 70, + GLSLstd450Reflect = 71, + GLSLstd450Refract = 72, + + GLSLstd450FindILsb = 73, + GLSLstd450FindSMsb = 74, + GLSLstd450FindUMsb = 75, + + GLSLstd450InterpolateAtCentroid = 76, + GLSLstd450InterpolateAtSample = 77, + GLSLstd450InterpolateAtOffset = 78, + + GLSLstd450NMin = 79, + GLSLstd450NMax = 80, + GLSLstd450NClamp = 81, + + GLSLstd450Count +}; + +#endif // #ifndef GLSLstd450_H diff --git a/thirdparty/include/SpirV/spirv.h b/thirdparty/include/SpirV/spirv.h new file mode 100644 index 000000000..1e999f27b --- /dev/null +++ b/thirdparty/include/SpirV/spirv.h @@ -0,0 +1,2163 @@ +/* +** Copyright (c) 2014-2020 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a copy +** of this software and/or associated documentation files (the "Materials"), +** to deal in the Materials without restriction, including without limitation +** the rights to use, copy, modify, merge, publish, distribute, sublicense, +** and/or sell copies of the Materials, and to permit persons to whom the +** Materials are 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 Materials. +** +** MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS +** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND +** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ +** +** THE MATERIALS ARE 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 MATERIALS OR THE USE OR OTHER DEALINGS +** IN THE MATERIALS. +*/ + +/* +** This header is automatically generated by the same tool that creates +** the Binary Section of the SPIR-V specification. +*/ + +/* +** Enumeration tokens for SPIR-V, in various styles: +** C, C++, C++11, JSON, Lua, Python, C#, D +** +** - C will have tokens with a "Spv" prefix, e.g.: SpvSourceLanguageGLSL +** - C++ will have tokens in the "spv" name space, e.g.: spv::SourceLanguageGLSL +** - C++11 will use enum classes in the spv namespace, e.g.: spv::SourceLanguage::GLSL +** - Lua will use tables, e.g.: spv.SourceLanguage.GLSL +** - Python will use dictionaries, e.g.: spv['SourceLanguage']['GLSL'] +** - C# will use enum classes in the Specification class located in the "Spv" namespace, +** e.g.: Spv.Specification.SourceLanguage.GLSL +** - D will have tokens under the "spv" module, e.g: spv.SourceLanguage.GLSL +** +** Some tokens act like mask values, which can be OR'd together, +** while others are mutually exclusive. The mask-like ones have +** "Mask" in their name, and a parallel enum that has the shift +** amount (1 << x) for each corresponding enumerant. +*/ + +#ifndef spirv_H +#define spirv_H + +typedef unsigned int SpvId; + +#define SPV_VERSION 0x10500 +#define SPV_REVISION 3 + +static const unsigned int SpvMagicNumber = 0x07230203; +static const unsigned int SpvVersion = 0x00010500; +static const unsigned int SpvRevision = 3; +static const unsigned int SpvOpCodeMask = 0xffff; +static const unsigned int SpvWordCountShift = 16; + +typedef enum SpvSourceLanguage_ { + SpvSourceLanguageUnknown = 0, + SpvSourceLanguageESSL = 1, + SpvSourceLanguageGLSL = 2, + SpvSourceLanguageOpenCL_C = 3, + SpvSourceLanguageOpenCL_CPP = 4, + SpvSourceLanguageHLSL = 5, + SpvSourceLanguageMax = 0x7fffffff, +} SpvSourceLanguage; + +typedef enum SpvExecutionModel_ { + SpvExecutionModelVertex = 0, + SpvExecutionModelTessellationControl = 1, + SpvExecutionModelTessellationEvaluation = 2, + SpvExecutionModelGeometry = 3, + SpvExecutionModelFragment = 4, + SpvExecutionModelGLCompute = 5, + SpvExecutionModelKernel = 6, + SpvExecutionModelTaskNV = 5267, + SpvExecutionModelMeshNV = 5268, + SpvExecutionModelRayGenerationKHR = 5313, + SpvExecutionModelRayGenerationNV = 5313, + SpvExecutionModelIntersectionKHR = 5314, + SpvExecutionModelIntersectionNV = 5314, + SpvExecutionModelAnyHitKHR = 5315, + SpvExecutionModelAnyHitNV = 5315, + SpvExecutionModelClosestHitKHR = 5316, + SpvExecutionModelClosestHitNV = 5316, + SpvExecutionModelMissKHR = 5317, + SpvExecutionModelMissNV = 5317, + SpvExecutionModelCallableKHR = 5318, + SpvExecutionModelCallableNV = 5318, + SpvExecutionModelMax = 0x7fffffff, +} SpvExecutionModel; + +typedef enum SpvAddressingModel_ { + SpvAddressingModelLogical = 0, + SpvAddressingModelPhysical32 = 1, + SpvAddressingModelPhysical64 = 2, + SpvAddressingModelPhysicalStorageBuffer64 = 5348, + SpvAddressingModelPhysicalStorageBuffer64EXT = 5348, + SpvAddressingModelMax = 0x7fffffff, +} SpvAddressingModel; + +typedef enum SpvMemoryModel_ { + SpvMemoryModelSimple = 0, + SpvMemoryModelGLSL450 = 1, + SpvMemoryModelOpenCL = 2, + SpvMemoryModelVulkan = 3, + SpvMemoryModelVulkanKHR = 3, + SpvMemoryModelMax = 0x7fffffff, +} SpvMemoryModel; + +typedef enum SpvExecutionMode_ { + SpvExecutionModeInvocations = 0, + SpvExecutionModeSpacingEqual = 1, + SpvExecutionModeSpacingFractionalEven = 2, + SpvExecutionModeSpacingFractionalOdd = 3, + SpvExecutionModeVertexOrderCw = 4, + SpvExecutionModeVertexOrderCcw = 5, + SpvExecutionModePixelCenterInteger = 6, + SpvExecutionModeOriginUpperLeft = 7, + SpvExecutionModeOriginLowerLeft = 8, + SpvExecutionModeEarlyFragmentTests = 9, + SpvExecutionModePointMode = 10, + SpvExecutionModeXfb = 11, + SpvExecutionModeDepthReplacing = 12, + SpvExecutionModeDepthGreater = 14, + SpvExecutionModeDepthLess = 15, + SpvExecutionModeDepthUnchanged = 16, + SpvExecutionModeLocalSize = 17, + SpvExecutionModeLocalSizeHint = 18, + SpvExecutionModeInputPoints = 19, + SpvExecutionModeInputLines = 20, + SpvExecutionModeInputLinesAdjacency = 21, + SpvExecutionModeTriangles = 22, + SpvExecutionModeInputTrianglesAdjacency = 23, + SpvExecutionModeQuads = 24, + SpvExecutionModeIsolines = 25, + SpvExecutionModeOutputVertices = 26, + SpvExecutionModeOutputPoints = 27, + SpvExecutionModeOutputLineStrip = 28, + SpvExecutionModeOutputTriangleStrip = 29, + SpvExecutionModeVecTypeHint = 30, + SpvExecutionModeContractionOff = 31, + SpvExecutionModeInitializer = 33, + SpvExecutionModeFinalizer = 34, + SpvExecutionModeSubgroupSize = 35, + SpvExecutionModeSubgroupsPerWorkgroup = 36, + SpvExecutionModeSubgroupsPerWorkgroupId = 37, + SpvExecutionModeLocalSizeId = 38, + SpvExecutionModeLocalSizeHintId = 39, + SpvExecutionModePostDepthCoverage = 4446, + SpvExecutionModeDenormPreserve = 4459, + SpvExecutionModeDenormFlushToZero = 4460, + SpvExecutionModeSignedZeroInfNanPreserve = 4461, + SpvExecutionModeRoundingModeRTE = 4462, + SpvExecutionModeRoundingModeRTZ = 4463, + SpvExecutionModeStencilRefReplacingEXT = 5027, + SpvExecutionModeOutputLinesNV = 5269, + SpvExecutionModeOutputPrimitivesNV = 5270, + SpvExecutionModeDerivativeGroupQuadsNV = 5289, + SpvExecutionModeDerivativeGroupLinearNV = 5290, + SpvExecutionModeOutputTrianglesNV = 5298, + SpvExecutionModePixelInterlockOrderedEXT = 5366, + SpvExecutionModePixelInterlockUnorderedEXT = 5367, + SpvExecutionModeSampleInterlockOrderedEXT = 5368, + SpvExecutionModeSampleInterlockUnorderedEXT = 5369, + SpvExecutionModeShadingRateInterlockOrderedEXT = 5370, + SpvExecutionModeShadingRateInterlockUnorderedEXT = 5371, + SpvExecutionModeMaxWorkgroupSizeINTEL = 5893, + SpvExecutionModeMaxWorkDimINTEL = 5894, + SpvExecutionModeNoGlobalOffsetINTEL = 5895, + SpvExecutionModeNumSIMDWorkitemsINTEL = 5896, + SpvExecutionModeMax = 0x7fffffff, +} SpvExecutionMode; + +typedef enum SpvStorageClass_ { + SpvStorageClassUniformConstant = 0, + SpvStorageClassInput = 1, + SpvStorageClassUniform = 2, + SpvStorageClassOutput = 3, + SpvStorageClassWorkgroup = 4, + SpvStorageClassCrossWorkgroup = 5, + SpvStorageClassPrivate = 6, + SpvStorageClassFunction = 7, + SpvStorageClassGeneric = 8, + SpvStorageClassPushConstant = 9, + SpvStorageClassAtomicCounter = 10, + SpvStorageClassImage = 11, + SpvStorageClassStorageBuffer = 12, + SpvStorageClassCallableDataKHR = 5328, + SpvStorageClassCallableDataNV = 5328, + SpvStorageClassIncomingCallableDataKHR = 5329, + SpvStorageClassIncomingCallableDataNV = 5329, + SpvStorageClassRayPayloadKHR = 5338, + SpvStorageClassRayPayloadNV = 5338, + SpvStorageClassHitAttributeKHR = 5339, + SpvStorageClassHitAttributeNV = 5339, + SpvStorageClassIncomingRayPayloadKHR = 5342, + SpvStorageClassIncomingRayPayloadNV = 5342, + SpvStorageClassShaderRecordBufferKHR = 5343, + SpvStorageClassShaderRecordBufferNV = 5343, + SpvStorageClassPhysicalStorageBuffer = 5349, + SpvStorageClassPhysicalStorageBufferEXT = 5349, + SpvStorageClassCodeSectionINTEL = 5605, + SpvStorageClassMax = 0x7fffffff, +} SpvStorageClass; + +typedef enum SpvDim_ { + SpvDim1D = 0, + SpvDim2D = 1, + SpvDim3D = 2, + SpvDimCube = 3, + SpvDimRect = 4, + SpvDimBuffer = 5, + SpvDimSubpassData = 6, + SpvDimMax = 0x7fffffff, +} SpvDim; + +typedef enum SpvSamplerAddressingMode_ { + SpvSamplerAddressingModeNone = 0, + SpvSamplerAddressingModeClampToEdge = 1, + SpvSamplerAddressingModeClamp = 2, + SpvSamplerAddressingModeRepeat = 3, + SpvSamplerAddressingModeRepeatMirrored = 4, + SpvSamplerAddressingModeMax = 0x7fffffff, +} SpvSamplerAddressingMode; + +typedef enum SpvSamplerFilterMode_ { + SpvSamplerFilterModeNearest = 0, + SpvSamplerFilterModeLinear = 1, + SpvSamplerFilterModeMax = 0x7fffffff, +} SpvSamplerFilterMode; + +typedef enum SpvImageFormat_ { + SpvImageFormatUnknown = 0, + SpvImageFormatRgba32f = 1, + SpvImageFormatRgba16f = 2, + SpvImageFormatR32f = 3, + SpvImageFormatRgba8 = 4, + SpvImageFormatRgba8Snorm = 5, + SpvImageFormatRg32f = 6, + SpvImageFormatRg16f = 7, + SpvImageFormatR11fG11fB10f = 8, + SpvImageFormatR16f = 9, + SpvImageFormatRgba16 = 10, + SpvImageFormatRgb10A2 = 11, + SpvImageFormatRg16 = 12, + SpvImageFormatRg8 = 13, + SpvImageFormatR16 = 14, + SpvImageFormatR8 = 15, + SpvImageFormatRgba16Snorm = 16, + SpvImageFormatRg16Snorm = 17, + SpvImageFormatRg8Snorm = 18, + SpvImageFormatR16Snorm = 19, + SpvImageFormatR8Snorm = 20, + SpvImageFormatRgba32i = 21, + SpvImageFormatRgba16i = 22, + SpvImageFormatRgba8i = 23, + SpvImageFormatR32i = 24, + SpvImageFormatRg32i = 25, + SpvImageFormatRg16i = 26, + SpvImageFormatRg8i = 27, + SpvImageFormatR16i = 28, + SpvImageFormatR8i = 29, + SpvImageFormatRgba32ui = 30, + SpvImageFormatRgba16ui = 31, + SpvImageFormatRgba8ui = 32, + SpvImageFormatR32ui = 33, + SpvImageFormatRgb10a2ui = 34, + SpvImageFormatRg32ui = 35, + SpvImageFormatRg16ui = 36, + SpvImageFormatRg8ui = 37, + SpvImageFormatR16ui = 38, + SpvImageFormatR8ui = 39, + SpvImageFormatMax = 0x7fffffff, +} SpvImageFormat; + +typedef enum SpvImageChannelOrder_ { + SpvImageChannelOrderR = 0, + SpvImageChannelOrderA = 1, + SpvImageChannelOrderRG = 2, + SpvImageChannelOrderRA = 3, + SpvImageChannelOrderRGB = 4, + SpvImageChannelOrderRGBA = 5, + SpvImageChannelOrderBGRA = 6, + SpvImageChannelOrderARGB = 7, + SpvImageChannelOrderIntensity = 8, + SpvImageChannelOrderLuminance = 9, + SpvImageChannelOrderRx = 10, + SpvImageChannelOrderRGx = 11, + SpvImageChannelOrderRGBx = 12, + SpvImageChannelOrderDepth = 13, + SpvImageChannelOrderDepthStencil = 14, + SpvImageChannelOrdersRGB = 15, + SpvImageChannelOrdersRGBx = 16, + SpvImageChannelOrdersRGBA = 17, + SpvImageChannelOrdersBGRA = 18, + SpvImageChannelOrderABGR = 19, + SpvImageChannelOrderMax = 0x7fffffff, +} SpvImageChannelOrder; + +typedef enum SpvImageChannelDataType_ { + SpvImageChannelDataTypeSnormInt8 = 0, + SpvImageChannelDataTypeSnormInt16 = 1, + SpvImageChannelDataTypeUnormInt8 = 2, + SpvImageChannelDataTypeUnormInt16 = 3, + SpvImageChannelDataTypeUnormShort565 = 4, + SpvImageChannelDataTypeUnormShort555 = 5, + SpvImageChannelDataTypeUnormInt101010 = 6, + SpvImageChannelDataTypeSignedInt8 = 7, + SpvImageChannelDataTypeSignedInt16 = 8, + SpvImageChannelDataTypeSignedInt32 = 9, + SpvImageChannelDataTypeUnsignedInt8 = 10, + SpvImageChannelDataTypeUnsignedInt16 = 11, + SpvImageChannelDataTypeUnsignedInt32 = 12, + SpvImageChannelDataTypeHalfFloat = 13, + SpvImageChannelDataTypeFloat = 14, + SpvImageChannelDataTypeUnormInt24 = 15, + SpvImageChannelDataTypeUnormInt101010_2 = 16, + SpvImageChannelDataTypeMax = 0x7fffffff, +} SpvImageChannelDataType; + +typedef enum SpvImageOperandsShift_ { + SpvImageOperandsBiasShift = 0, + SpvImageOperandsLodShift = 1, + SpvImageOperandsGradShift = 2, + SpvImageOperandsConstOffsetShift = 3, + SpvImageOperandsOffsetShift = 4, + SpvImageOperandsConstOffsetsShift = 5, + SpvImageOperandsSampleShift = 6, + SpvImageOperandsMinLodShift = 7, + SpvImageOperandsMakeTexelAvailableShift = 8, + SpvImageOperandsMakeTexelAvailableKHRShift = 8, + SpvImageOperandsMakeTexelVisibleShift = 9, + SpvImageOperandsMakeTexelVisibleKHRShift = 9, + SpvImageOperandsNonPrivateTexelShift = 10, + SpvImageOperandsNonPrivateTexelKHRShift = 10, + SpvImageOperandsVolatileTexelShift = 11, + SpvImageOperandsVolatileTexelKHRShift = 11, + SpvImageOperandsSignExtendShift = 12, + SpvImageOperandsZeroExtendShift = 13, + SpvImageOperandsMax = 0x7fffffff, +} SpvImageOperandsShift; + +typedef enum SpvImageOperandsMask_ { + SpvImageOperandsMaskNone = 0, + SpvImageOperandsBiasMask = 0x00000001, + SpvImageOperandsLodMask = 0x00000002, + SpvImageOperandsGradMask = 0x00000004, + SpvImageOperandsConstOffsetMask = 0x00000008, + SpvImageOperandsOffsetMask = 0x00000010, + SpvImageOperandsConstOffsetsMask = 0x00000020, + SpvImageOperandsSampleMask = 0x00000040, + SpvImageOperandsMinLodMask = 0x00000080, + SpvImageOperandsMakeTexelAvailableMask = 0x00000100, + SpvImageOperandsMakeTexelAvailableKHRMask = 0x00000100, + SpvImageOperandsMakeTexelVisibleMask = 0x00000200, + SpvImageOperandsMakeTexelVisibleKHRMask = 0x00000200, + SpvImageOperandsNonPrivateTexelMask = 0x00000400, + SpvImageOperandsNonPrivateTexelKHRMask = 0x00000400, + SpvImageOperandsVolatileTexelMask = 0x00000800, + SpvImageOperandsVolatileTexelKHRMask = 0x00000800, + SpvImageOperandsSignExtendMask = 0x00001000, + SpvImageOperandsZeroExtendMask = 0x00002000, +} SpvImageOperandsMask; + +typedef enum SpvFPFastMathModeShift_ { + SpvFPFastMathModeNotNaNShift = 0, + SpvFPFastMathModeNotInfShift = 1, + SpvFPFastMathModeNSZShift = 2, + SpvFPFastMathModeAllowRecipShift = 3, + SpvFPFastMathModeFastShift = 4, + SpvFPFastMathModeMax = 0x7fffffff, +} SpvFPFastMathModeShift; + +typedef enum SpvFPFastMathModeMask_ { + SpvFPFastMathModeMaskNone = 0, + SpvFPFastMathModeNotNaNMask = 0x00000001, + SpvFPFastMathModeNotInfMask = 0x00000002, + SpvFPFastMathModeNSZMask = 0x00000004, + SpvFPFastMathModeAllowRecipMask = 0x00000008, + SpvFPFastMathModeFastMask = 0x00000010, +} SpvFPFastMathModeMask; + +typedef enum SpvFPRoundingMode_ { + SpvFPRoundingModeRTE = 0, + SpvFPRoundingModeRTZ = 1, + SpvFPRoundingModeRTP = 2, + SpvFPRoundingModeRTN = 3, + SpvFPRoundingModeMax = 0x7fffffff, +} SpvFPRoundingMode; + +typedef enum SpvLinkageType_ { + SpvLinkageTypeExport = 0, + SpvLinkageTypeImport = 1, + SpvLinkageTypeMax = 0x7fffffff, +} SpvLinkageType; + +typedef enum SpvAccessQualifier_ { + SpvAccessQualifierReadOnly = 0, + SpvAccessQualifierWriteOnly = 1, + SpvAccessQualifierReadWrite = 2, + SpvAccessQualifierMax = 0x7fffffff, +} SpvAccessQualifier; + +typedef enum SpvFunctionParameterAttribute_ { + SpvFunctionParameterAttributeZext = 0, + SpvFunctionParameterAttributeSext = 1, + SpvFunctionParameterAttributeByVal = 2, + SpvFunctionParameterAttributeSret = 3, + SpvFunctionParameterAttributeNoAlias = 4, + SpvFunctionParameterAttributeNoCapture = 5, + SpvFunctionParameterAttributeNoWrite = 6, + SpvFunctionParameterAttributeNoReadWrite = 7, + SpvFunctionParameterAttributeMax = 0x7fffffff, +} SpvFunctionParameterAttribute; + +typedef enum SpvDecoration_ { + SpvDecorationRelaxedPrecision = 0, + SpvDecorationSpecId = 1, + SpvDecorationBlock = 2, + SpvDecorationBufferBlock = 3, + SpvDecorationRowMajor = 4, + SpvDecorationColMajor = 5, + SpvDecorationArrayStride = 6, + SpvDecorationMatrixStride = 7, + SpvDecorationGLSLShared = 8, + SpvDecorationGLSLPacked = 9, + SpvDecorationCPacked = 10, + SpvDecorationBuiltIn = 11, + SpvDecorationNoPerspective = 13, + SpvDecorationFlat = 14, + SpvDecorationPatch = 15, + SpvDecorationCentroid = 16, + SpvDecorationSample = 17, + SpvDecorationInvariant = 18, + SpvDecorationRestrict = 19, + SpvDecorationAliased = 20, + SpvDecorationVolatile = 21, + SpvDecorationConstant = 22, + SpvDecorationCoherent = 23, + SpvDecorationNonWritable = 24, + SpvDecorationNonReadable = 25, + SpvDecorationUniform = 26, + SpvDecorationUniformId = 27, + SpvDecorationSaturatedConversion = 28, + SpvDecorationStream = 29, + SpvDecorationLocation = 30, + SpvDecorationComponent = 31, + SpvDecorationIndex = 32, + SpvDecorationBinding = 33, + SpvDecorationDescriptorSet = 34, + SpvDecorationOffset = 35, + SpvDecorationXfbBuffer = 36, + SpvDecorationXfbStride = 37, + SpvDecorationFuncParamAttr = 38, + SpvDecorationFPRoundingMode = 39, + SpvDecorationFPFastMathMode = 40, + SpvDecorationLinkageAttributes = 41, + SpvDecorationNoContraction = 42, + SpvDecorationInputAttachmentIndex = 43, + SpvDecorationAlignment = 44, + SpvDecorationMaxByteOffset = 45, + SpvDecorationAlignmentId = 46, + SpvDecorationMaxByteOffsetId = 47, + SpvDecorationNoSignedWrap = 4469, + SpvDecorationNoUnsignedWrap = 4470, + SpvDecorationExplicitInterpAMD = 4999, + SpvDecorationOverrideCoverageNV = 5248, + SpvDecorationPassthroughNV = 5250, + SpvDecorationViewportRelativeNV = 5252, + SpvDecorationSecondaryViewportRelativeNV = 5256, + SpvDecorationPerPrimitiveNV = 5271, + SpvDecorationPerViewNV = 5272, + SpvDecorationPerTaskNV = 5273, + SpvDecorationPerVertexNV = 5285, + SpvDecorationNonUniform = 5300, + SpvDecorationNonUniformEXT = 5300, + SpvDecorationRestrictPointer = 5355, + SpvDecorationRestrictPointerEXT = 5355, + SpvDecorationAliasedPointer = 5356, + SpvDecorationAliasedPointerEXT = 5356, + SpvDecorationReferencedIndirectlyINTEL = 5602, + SpvDecorationCounterBuffer = 5634, + SpvDecorationHlslCounterBufferGOOGLE = 5634, + SpvDecorationHlslSemanticGOOGLE = 5635, + SpvDecorationUserSemantic = 5635, + SpvDecorationUserTypeGOOGLE = 5636, + SpvDecorationRegisterINTEL = 5825, + SpvDecorationMemoryINTEL = 5826, + SpvDecorationNumbanksINTEL = 5827, + SpvDecorationBankwidthINTEL = 5828, + SpvDecorationMaxPrivateCopiesINTEL = 5829, + SpvDecorationSinglepumpINTEL = 5830, + SpvDecorationDoublepumpINTEL = 5831, + SpvDecorationMaxReplicatesINTEL = 5832, + SpvDecorationSimpleDualPortINTEL = 5833, + SpvDecorationMergeINTEL = 5834, + SpvDecorationBankBitsINTEL = 5835, + SpvDecorationForcePow2DepthINTEL = 5836, + SpvDecorationMax = 0x7fffffff, +} SpvDecoration; + +typedef enum SpvBuiltIn_ { + SpvBuiltInPosition = 0, + SpvBuiltInPointSize = 1, + SpvBuiltInClipDistance = 3, + SpvBuiltInCullDistance = 4, + SpvBuiltInVertexId = 5, + SpvBuiltInInstanceId = 6, + SpvBuiltInPrimitiveId = 7, + SpvBuiltInInvocationId = 8, + SpvBuiltInLayer = 9, + SpvBuiltInViewportIndex = 10, + SpvBuiltInTessLevelOuter = 11, + SpvBuiltInTessLevelInner = 12, + SpvBuiltInTessCoord = 13, + SpvBuiltInPatchVertices = 14, + SpvBuiltInFragCoord = 15, + SpvBuiltInPointCoord = 16, + SpvBuiltInFrontFacing = 17, + SpvBuiltInSampleId = 18, + SpvBuiltInSamplePosition = 19, + SpvBuiltInSampleMask = 20, + SpvBuiltInFragDepth = 22, + SpvBuiltInHelperInvocation = 23, + SpvBuiltInNumWorkgroups = 24, + SpvBuiltInWorkgroupSize = 25, + SpvBuiltInWorkgroupId = 26, + SpvBuiltInLocalInvocationId = 27, + SpvBuiltInGlobalInvocationId = 28, + SpvBuiltInLocalInvocationIndex = 29, + SpvBuiltInWorkDim = 30, + SpvBuiltInGlobalSize = 31, + SpvBuiltInEnqueuedWorkgroupSize = 32, + SpvBuiltInGlobalOffset = 33, + SpvBuiltInGlobalLinearId = 34, + SpvBuiltInSubgroupSize = 36, + SpvBuiltInSubgroupMaxSize = 37, + SpvBuiltInNumSubgroups = 38, + SpvBuiltInNumEnqueuedSubgroups = 39, + SpvBuiltInSubgroupId = 40, + SpvBuiltInSubgroupLocalInvocationId = 41, + SpvBuiltInVertexIndex = 42, + SpvBuiltInInstanceIndex = 43, + SpvBuiltInSubgroupEqMask = 4416, + SpvBuiltInSubgroupEqMaskKHR = 4416, + SpvBuiltInSubgroupGeMask = 4417, + SpvBuiltInSubgroupGeMaskKHR = 4417, + SpvBuiltInSubgroupGtMask = 4418, + SpvBuiltInSubgroupGtMaskKHR = 4418, + SpvBuiltInSubgroupLeMask = 4419, + SpvBuiltInSubgroupLeMaskKHR = 4419, + SpvBuiltInSubgroupLtMask = 4420, + SpvBuiltInSubgroupLtMaskKHR = 4420, + SpvBuiltInBaseVertex = 4424, + SpvBuiltInBaseInstance = 4425, + SpvBuiltInDrawIndex = 4426, + SpvBuiltInDeviceIndex = 4438, + SpvBuiltInViewIndex = 4440, + SpvBuiltInBaryCoordNoPerspAMD = 4992, + SpvBuiltInBaryCoordNoPerspCentroidAMD = 4993, + SpvBuiltInBaryCoordNoPerspSampleAMD = 4994, + SpvBuiltInBaryCoordSmoothAMD = 4995, + SpvBuiltInBaryCoordSmoothCentroidAMD = 4996, + SpvBuiltInBaryCoordSmoothSampleAMD = 4997, + SpvBuiltInBaryCoordPullModelAMD = 4998, + SpvBuiltInFragStencilRefEXT = 5014, + SpvBuiltInViewportMaskNV = 5253, + SpvBuiltInSecondaryPositionNV = 5257, + SpvBuiltInSecondaryViewportMaskNV = 5258, + SpvBuiltInPositionPerViewNV = 5261, + SpvBuiltInViewportMaskPerViewNV = 5262, + SpvBuiltInFullyCoveredEXT = 5264, + SpvBuiltInTaskCountNV = 5274, + SpvBuiltInPrimitiveCountNV = 5275, + SpvBuiltInPrimitiveIndicesNV = 5276, + SpvBuiltInClipDistancePerViewNV = 5277, + SpvBuiltInCullDistancePerViewNV = 5278, + SpvBuiltInLayerPerViewNV = 5279, + SpvBuiltInMeshViewCountNV = 5280, + SpvBuiltInMeshViewIndicesNV = 5281, + SpvBuiltInBaryCoordNV = 5286, + SpvBuiltInBaryCoordNoPerspNV = 5287, + SpvBuiltInFragSizeEXT = 5292, + SpvBuiltInFragmentSizeNV = 5292, + SpvBuiltInFragInvocationCountEXT = 5293, + SpvBuiltInInvocationsPerPixelNV = 5293, + SpvBuiltInLaunchIdKHR = 5319, + SpvBuiltInLaunchIdNV = 5319, + SpvBuiltInLaunchSizeKHR = 5320, + SpvBuiltInLaunchSizeNV = 5320, + SpvBuiltInWorldRayOriginKHR = 5321, + SpvBuiltInWorldRayOriginNV = 5321, + SpvBuiltInWorldRayDirectionKHR = 5322, + SpvBuiltInWorldRayDirectionNV = 5322, + SpvBuiltInObjectRayOriginKHR = 5323, + SpvBuiltInObjectRayOriginNV = 5323, + SpvBuiltInObjectRayDirectionKHR = 5324, + SpvBuiltInObjectRayDirectionNV = 5324, + SpvBuiltInRayTminKHR = 5325, + SpvBuiltInRayTminNV = 5325, + SpvBuiltInRayTmaxKHR = 5326, + SpvBuiltInRayTmaxNV = 5326, + SpvBuiltInInstanceCustomIndexKHR = 5327, + SpvBuiltInInstanceCustomIndexNV = 5327, + SpvBuiltInObjectToWorldKHR = 5330, + SpvBuiltInObjectToWorldNV = 5330, + SpvBuiltInWorldToObjectKHR = 5331, + SpvBuiltInWorldToObjectNV = 5331, + SpvBuiltInHitTKHR = 5332, + SpvBuiltInHitTNV = 5332, + SpvBuiltInHitKindKHR = 5333, + SpvBuiltInHitKindNV = 5333, + SpvBuiltInIncomingRayFlagsKHR = 5351, + SpvBuiltInIncomingRayFlagsNV = 5351, + SpvBuiltInRayGeometryIndexKHR = 5352, + SpvBuiltInWarpsPerSMNV = 5374, + SpvBuiltInSMCountNV = 5375, + SpvBuiltInWarpIDNV = 5376, + SpvBuiltInSMIDNV = 5377, + SpvBuiltInMax = 0x7fffffff, +} SpvBuiltIn; + +typedef enum SpvSelectionControlShift_ { + SpvSelectionControlFlattenShift = 0, + SpvSelectionControlDontFlattenShift = 1, + SpvSelectionControlMax = 0x7fffffff, +} SpvSelectionControlShift; + +typedef enum SpvSelectionControlMask_ { + SpvSelectionControlMaskNone = 0, + SpvSelectionControlFlattenMask = 0x00000001, + SpvSelectionControlDontFlattenMask = 0x00000002, +} SpvSelectionControlMask; + +typedef enum SpvLoopControlShift_ { + SpvLoopControlUnrollShift = 0, + SpvLoopControlDontUnrollShift = 1, + SpvLoopControlDependencyInfiniteShift = 2, + SpvLoopControlDependencyLengthShift = 3, + SpvLoopControlMinIterationsShift = 4, + SpvLoopControlMaxIterationsShift = 5, + SpvLoopControlIterationMultipleShift = 6, + SpvLoopControlPeelCountShift = 7, + SpvLoopControlPartialCountShift = 8, + SpvLoopControlInitiationIntervalINTELShift = 16, + SpvLoopControlMaxConcurrencyINTELShift = 17, + SpvLoopControlDependencyArrayINTELShift = 18, + SpvLoopControlPipelineEnableINTELShift = 19, + SpvLoopControlLoopCoalesceINTELShift = 20, + SpvLoopControlMaxInterleavingINTELShift = 21, + SpvLoopControlSpeculatedIterationsINTELShift = 22, + SpvLoopControlMax = 0x7fffffff, +} SpvLoopControlShift; + +typedef enum SpvLoopControlMask_ { + SpvLoopControlMaskNone = 0, + SpvLoopControlUnrollMask = 0x00000001, + SpvLoopControlDontUnrollMask = 0x00000002, + SpvLoopControlDependencyInfiniteMask = 0x00000004, + SpvLoopControlDependencyLengthMask = 0x00000008, + SpvLoopControlMinIterationsMask = 0x00000010, + SpvLoopControlMaxIterationsMask = 0x00000020, + SpvLoopControlIterationMultipleMask = 0x00000040, + SpvLoopControlPeelCountMask = 0x00000080, + SpvLoopControlPartialCountMask = 0x00000100, + SpvLoopControlInitiationIntervalINTELMask = 0x00010000, + SpvLoopControlMaxConcurrencyINTELMask = 0x00020000, + SpvLoopControlDependencyArrayINTELMask = 0x00040000, + SpvLoopControlPipelineEnableINTELMask = 0x00080000, + SpvLoopControlLoopCoalesceINTELMask = 0x00100000, + SpvLoopControlMaxInterleavingINTELMask = 0x00200000, + SpvLoopControlSpeculatedIterationsINTELMask = 0x00400000, +} SpvLoopControlMask; + +typedef enum SpvFunctionControlShift_ { + SpvFunctionControlInlineShift = 0, + SpvFunctionControlDontInlineShift = 1, + SpvFunctionControlPureShift = 2, + SpvFunctionControlConstShift = 3, + SpvFunctionControlMax = 0x7fffffff, +} SpvFunctionControlShift; + +typedef enum SpvFunctionControlMask_ { + SpvFunctionControlMaskNone = 0, + SpvFunctionControlInlineMask = 0x00000001, + SpvFunctionControlDontInlineMask = 0x00000002, + SpvFunctionControlPureMask = 0x00000004, + SpvFunctionControlConstMask = 0x00000008, +} SpvFunctionControlMask; + +typedef enum SpvMemorySemanticsShift_ { + SpvMemorySemanticsAcquireShift = 1, + SpvMemorySemanticsReleaseShift = 2, + SpvMemorySemanticsAcquireReleaseShift = 3, + SpvMemorySemanticsSequentiallyConsistentShift = 4, + SpvMemorySemanticsUniformMemoryShift = 6, + SpvMemorySemanticsSubgroupMemoryShift = 7, + SpvMemorySemanticsWorkgroupMemoryShift = 8, + SpvMemorySemanticsCrossWorkgroupMemoryShift = 9, + SpvMemorySemanticsAtomicCounterMemoryShift = 10, + SpvMemorySemanticsImageMemoryShift = 11, + SpvMemorySemanticsOutputMemoryShift = 12, + SpvMemorySemanticsOutputMemoryKHRShift = 12, + SpvMemorySemanticsMakeAvailableShift = 13, + SpvMemorySemanticsMakeAvailableKHRShift = 13, + SpvMemorySemanticsMakeVisibleShift = 14, + SpvMemorySemanticsMakeVisibleKHRShift = 14, + SpvMemorySemanticsVolatileShift = 15, + SpvMemorySemanticsMax = 0x7fffffff, +} SpvMemorySemanticsShift; + +typedef enum SpvMemorySemanticsMask_ { + SpvMemorySemanticsMaskNone = 0, + SpvMemorySemanticsAcquireMask = 0x00000002, + SpvMemorySemanticsReleaseMask = 0x00000004, + SpvMemorySemanticsAcquireReleaseMask = 0x00000008, + SpvMemorySemanticsSequentiallyConsistentMask = 0x00000010, + SpvMemorySemanticsUniformMemoryMask = 0x00000040, + SpvMemorySemanticsSubgroupMemoryMask = 0x00000080, + SpvMemorySemanticsWorkgroupMemoryMask = 0x00000100, + SpvMemorySemanticsCrossWorkgroupMemoryMask = 0x00000200, + SpvMemorySemanticsAtomicCounterMemoryMask = 0x00000400, + SpvMemorySemanticsImageMemoryMask = 0x00000800, + SpvMemorySemanticsOutputMemoryMask = 0x00001000, + SpvMemorySemanticsOutputMemoryKHRMask = 0x00001000, + SpvMemorySemanticsMakeAvailableMask = 0x00002000, + SpvMemorySemanticsMakeAvailableKHRMask = 0x00002000, + SpvMemorySemanticsMakeVisibleMask = 0x00004000, + SpvMemorySemanticsMakeVisibleKHRMask = 0x00004000, + SpvMemorySemanticsVolatileMask = 0x00008000, +} SpvMemorySemanticsMask; + +typedef enum SpvMemoryAccessShift_ { + SpvMemoryAccessVolatileShift = 0, + SpvMemoryAccessAlignedShift = 1, + SpvMemoryAccessNontemporalShift = 2, + SpvMemoryAccessMakePointerAvailableShift = 3, + SpvMemoryAccessMakePointerAvailableKHRShift = 3, + SpvMemoryAccessMakePointerVisibleShift = 4, + SpvMemoryAccessMakePointerVisibleKHRShift = 4, + SpvMemoryAccessNonPrivatePointerShift = 5, + SpvMemoryAccessNonPrivatePointerKHRShift = 5, + SpvMemoryAccessMax = 0x7fffffff, +} SpvMemoryAccessShift; + +typedef enum SpvMemoryAccessMask_ { + SpvMemoryAccessMaskNone = 0, + SpvMemoryAccessVolatileMask = 0x00000001, + SpvMemoryAccessAlignedMask = 0x00000002, + SpvMemoryAccessNontemporalMask = 0x00000004, + SpvMemoryAccessMakePointerAvailableMask = 0x00000008, + SpvMemoryAccessMakePointerAvailableKHRMask = 0x00000008, + SpvMemoryAccessMakePointerVisibleMask = 0x00000010, + SpvMemoryAccessMakePointerVisibleKHRMask = 0x00000010, + SpvMemoryAccessNonPrivatePointerMask = 0x00000020, + SpvMemoryAccessNonPrivatePointerKHRMask = 0x00000020, +} SpvMemoryAccessMask; + +typedef enum SpvScope_ { + SpvScopeCrossDevice = 0, + SpvScopeDevice = 1, + SpvScopeWorkgroup = 2, + SpvScopeSubgroup = 3, + SpvScopeInvocation = 4, + SpvScopeQueueFamily = 5, + SpvScopeQueueFamilyKHR = 5, + SpvScopeShaderCallKHR = 6, + SpvScopeMax = 0x7fffffff, +} SpvScope; + +typedef enum SpvGroupOperation_ { + SpvGroupOperationReduce = 0, + SpvGroupOperationInclusiveScan = 1, + SpvGroupOperationExclusiveScan = 2, + SpvGroupOperationClusteredReduce = 3, + SpvGroupOperationPartitionedReduceNV = 6, + SpvGroupOperationPartitionedInclusiveScanNV = 7, + SpvGroupOperationPartitionedExclusiveScanNV = 8, + SpvGroupOperationMax = 0x7fffffff, +} SpvGroupOperation; + +typedef enum SpvKernelEnqueueFlags_ { + SpvKernelEnqueueFlagsNoWait = 0, + SpvKernelEnqueueFlagsWaitKernel = 1, + SpvKernelEnqueueFlagsWaitWorkGroup = 2, + SpvKernelEnqueueFlagsMax = 0x7fffffff, +} SpvKernelEnqueueFlags; + +typedef enum SpvKernelProfilingInfoShift_ { + SpvKernelProfilingInfoCmdExecTimeShift = 0, + SpvKernelProfilingInfoMax = 0x7fffffff, +} SpvKernelProfilingInfoShift; + +typedef enum SpvKernelProfilingInfoMask_ { + SpvKernelProfilingInfoMaskNone = 0, + SpvKernelProfilingInfoCmdExecTimeMask = 0x00000001, +} SpvKernelProfilingInfoMask; + +typedef enum SpvCapability_ { + SpvCapabilityMatrix = 0, + SpvCapabilityShader = 1, + SpvCapabilityGeometry = 2, + SpvCapabilityTessellation = 3, + SpvCapabilityAddresses = 4, + SpvCapabilityLinkage = 5, + SpvCapabilityKernel = 6, + SpvCapabilityVector16 = 7, + SpvCapabilityFloat16Buffer = 8, + SpvCapabilityFloat16 = 9, + SpvCapabilityFloat64 = 10, + SpvCapabilityInt64 = 11, + SpvCapabilityInt64Atomics = 12, + SpvCapabilityImageBasic = 13, + SpvCapabilityImageReadWrite = 14, + SpvCapabilityImageMipmap = 15, + SpvCapabilityPipes = 17, + SpvCapabilityGroups = 18, + SpvCapabilityDeviceEnqueue = 19, + SpvCapabilityLiteralSampler = 20, + SpvCapabilityAtomicStorage = 21, + SpvCapabilityInt16 = 22, + SpvCapabilityTessellationPointSize = 23, + SpvCapabilityGeometryPointSize = 24, + SpvCapabilityImageGatherExtended = 25, + SpvCapabilityStorageImageMultisample = 27, + SpvCapabilityUniformBufferArrayDynamicIndexing = 28, + SpvCapabilitySampledImageArrayDynamicIndexing = 29, + SpvCapabilityStorageBufferArrayDynamicIndexing = 30, + SpvCapabilityStorageImageArrayDynamicIndexing = 31, + SpvCapabilityClipDistance = 32, + SpvCapabilityCullDistance = 33, + SpvCapabilityImageCubeArray = 34, + SpvCapabilitySampleRateShading = 35, + SpvCapabilityImageRect = 36, + SpvCapabilitySampledRect = 37, + SpvCapabilityGenericPointer = 38, + SpvCapabilityInt8 = 39, + SpvCapabilityInputAttachment = 40, + SpvCapabilitySparseResidency = 41, + SpvCapabilityMinLod = 42, + SpvCapabilitySampled1D = 43, + SpvCapabilityImage1D = 44, + SpvCapabilitySampledCubeArray = 45, + SpvCapabilitySampledBuffer = 46, + SpvCapabilityImageBuffer = 47, + SpvCapabilityImageMSArray = 48, + SpvCapabilityStorageImageExtendedFormats = 49, + SpvCapabilityImageQuery = 50, + SpvCapabilityDerivativeControl = 51, + SpvCapabilityInterpolationFunction = 52, + SpvCapabilityTransformFeedback = 53, + SpvCapabilityGeometryStreams = 54, + SpvCapabilityStorageImageReadWithoutFormat = 55, + SpvCapabilityStorageImageWriteWithoutFormat = 56, + SpvCapabilityMultiViewport = 57, + SpvCapabilitySubgroupDispatch = 58, + SpvCapabilityNamedBarrier = 59, + SpvCapabilityPipeStorage = 60, + SpvCapabilityGroupNonUniform = 61, + SpvCapabilityGroupNonUniformVote = 62, + SpvCapabilityGroupNonUniformArithmetic = 63, + SpvCapabilityGroupNonUniformBallot = 64, + SpvCapabilityGroupNonUniformShuffle = 65, + SpvCapabilityGroupNonUniformShuffleRelative = 66, + SpvCapabilityGroupNonUniformClustered = 67, + SpvCapabilityGroupNonUniformQuad = 68, + SpvCapabilityShaderLayer = 69, + SpvCapabilityShaderViewportIndex = 70, + SpvCapabilitySubgroupBallotKHR = 4423, + SpvCapabilityDrawParameters = 4427, + SpvCapabilitySubgroupVoteKHR = 4431, + SpvCapabilityStorageBuffer16BitAccess = 4433, + SpvCapabilityStorageUniformBufferBlock16 = 4433, + SpvCapabilityStorageUniform16 = 4434, + SpvCapabilityUniformAndStorageBuffer16BitAccess = 4434, + SpvCapabilityStoragePushConstant16 = 4435, + SpvCapabilityStorageInputOutput16 = 4436, + SpvCapabilityDeviceGroup = 4437, + SpvCapabilityMultiView = 4439, + SpvCapabilityVariablePointersStorageBuffer = 4441, + SpvCapabilityVariablePointers = 4442, + SpvCapabilityAtomicStorageOps = 4445, + SpvCapabilitySampleMaskPostDepthCoverage = 4447, + SpvCapabilityStorageBuffer8BitAccess = 4448, + SpvCapabilityUniformAndStorageBuffer8BitAccess = 4449, + SpvCapabilityStoragePushConstant8 = 4450, + SpvCapabilityDenormPreserve = 4464, + SpvCapabilityDenormFlushToZero = 4465, + SpvCapabilitySignedZeroInfNanPreserve = 4466, + SpvCapabilityRoundingModeRTE = 4467, + SpvCapabilityRoundingModeRTZ = 4468, + SpvCapabilityRayQueryProvisionalKHR = 4471, + SpvCapabilityRayTraversalPrimitiveCullingProvisionalKHR = 4478, + SpvCapabilityFloat16ImageAMD = 5008, + SpvCapabilityImageGatherBiasLodAMD = 5009, + SpvCapabilityFragmentMaskAMD = 5010, + SpvCapabilityStencilExportEXT = 5013, + SpvCapabilityImageReadWriteLodAMD = 5015, + SpvCapabilityShaderClockKHR = 5055, + SpvCapabilitySampleMaskOverrideCoverageNV = 5249, + SpvCapabilityGeometryShaderPassthroughNV = 5251, + SpvCapabilityShaderViewportIndexLayerEXT = 5254, + SpvCapabilityShaderViewportIndexLayerNV = 5254, + SpvCapabilityShaderViewportMaskNV = 5255, + SpvCapabilityShaderStereoViewNV = 5259, + SpvCapabilityPerViewAttributesNV = 5260, + SpvCapabilityFragmentFullyCoveredEXT = 5265, + SpvCapabilityMeshShadingNV = 5266, + SpvCapabilityImageFootprintNV = 5282, + SpvCapabilityFragmentBarycentricNV = 5284, + SpvCapabilityComputeDerivativeGroupQuadsNV = 5288, + SpvCapabilityFragmentDensityEXT = 5291, + SpvCapabilityShadingRateNV = 5291, + SpvCapabilityGroupNonUniformPartitionedNV = 5297, + SpvCapabilityShaderNonUniform = 5301, + SpvCapabilityShaderNonUniformEXT = 5301, + SpvCapabilityRuntimeDescriptorArray = 5302, + SpvCapabilityRuntimeDescriptorArrayEXT = 5302, + SpvCapabilityInputAttachmentArrayDynamicIndexing = 5303, + SpvCapabilityInputAttachmentArrayDynamicIndexingEXT = 5303, + SpvCapabilityUniformTexelBufferArrayDynamicIndexing = 5304, + SpvCapabilityUniformTexelBufferArrayDynamicIndexingEXT = 5304, + SpvCapabilityStorageTexelBufferArrayDynamicIndexing = 5305, + SpvCapabilityStorageTexelBufferArrayDynamicIndexingEXT = 5305, + SpvCapabilityUniformBufferArrayNonUniformIndexing = 5306, + SpvCapabilityUniformBufferArrayNonUniformIndexingEXT = 5306, + SpvCapabilitySampledImageArrayNonUniformIndexing = 5307, + SpvCapabilitySampledImageArrayNonUniformIndexingEXT = 5307, + SpvCapabilityStorageBufferArrayNonUniformIndexing = 5308, + SpvCapabilityStorageBufferArrayNonUniformIndexingEXT = 5308, + SpvCapabilityStorageImageArrayNonUniformIndexing = 5309, + SpvCapabilityStorageImageArrayNonUniformIndexingEXT = 5309, + SpvCapabilityInputAttachmentArrayNonUniformIndexing = 5310, + SpvCapabilityInputAttachmentArrayNonUniformIndexingEXT = 5310, + SpvCapabilityUniformTexelBufferArrayNonUniformIndexing = 5311, + SpvCapabilityUniformTexelBufferArrayNonUniformIndexingEXT = 5311, + SpvCapabilityStorageTexelBufferArrayNonUniformIndexing = 5312, + SpvCapabilityStorageTexelBufferArrayNonUniformIndexingEXT = 5312, + SpvCapabilityRayTracingNV = 5340, + SpvCapabilityVulkanMemoryModel = 5345, + SpvCapabilityVulkanMemoryModelKHR = 5345, + SpvCapabilityVulkanMemoryModelDeviceScope = 5346, + SpvCapabilityVulkanMemoryModelDeviceScopeKHR = 5346, + SpvCapabilityPhysicalStorageBufferAddresses = 5347, + SpvCapabilityPhysicalStorageBufferAddressesEXT = 5347, + SpvCapabilityComputeDerivativeGroupLinearNV = 5350, + SpvCapabilityRayTracingProvisionalKHR = 5353, + SpvCapabilityCooperativeMatrixNV = 5357, + SpvCapabilityFragmentShaderSampleInterlockEXT = 5363, + SpvCapabilityFragmentShaderShadingRateInterlockEXT = 5372, + SpvCapabilityShaderSMBuiltinsNV = 5373, + SpvCapabilityFragmentShaderPixelInterlockEXT = 5378, + SpvCapabilityDemoteToHelperInvocationEXT = 5379, + SpvCapabilitySubgroupShuffleINTEL = 5568, + SpvCapabilitySubgroupBufferBlockIOINTEL = 5569, + SpvCapabilitySubgroupImageBlockIOINTEL = 5570, + SpvCapabilitySubgroupImageMediaBlockIOINTEL = 5579, + SpvCapabilityIntegerFunctions2INTEL = 5584, + SpvCapabilityFunctionPointersINTEL = 5603, + SpvCapabilityIndirectReferencesINTEL = 5604, + SpvCapabilitySubgroupAvcMotionEstimationINTEL = 5696, + SpvCapabilitySubgroupAvcMotionEstimationIntraINTEL = 5697, + SpvCapabilitySubgroupAvcMotionEstimationChromaINTEL = 5698, + SpvCapabilityFPGAMemoryAttributesINTEL = 5824, + SpvCapabilityUnstructuredLoopControlsINTEL = 5886, + SpvCapabilityFPGALoopControlsINTEL = 5888, + SpvCapabilityKernelAttributesINTEL = 5892, + SpvCapabilityFPGAKernelAttributesINTEL = 5897, + SpvCapabilityBlockingPipesINTEL = 5945, + SpvCapabilityFPGARegINTEL = 5948, + SpvCapabilityAtomicFloat32AddEXT = 6033, + SpvCapabilityAtomicFloat64AddEXT = 6034, + SpvCapabilityMax = 0x7fffffff, +} SpvCapability; + +typedef enum SpvRayFlagsShift_ { + SpvRayFlagsOpaqueKHRShift = 0, + SpvRayFlagsNoOpaqueKHRShift = 1, + SpvRayFlagsTerminateOnFirstHitKHRShift = 2, + SpvRayFlagsSkipClosestHitShaderKHRShift = 3, + SpvRayFlagsCullBackFacingTrianglesKHRShift = 4, + SpvRayFlagsCullFrontFacingTrianglesKHRShift = 5, + SpvRayFlagsCullOpaqueKHRShift = 6, + SpvRayFlagsCullNoOpaqueKHRShift = 7, + SpvRayFlagsSkipTrianglesKHRShift = 8, + SpvRayFlagsSkipAABBsKHRShift = 9, + SpvRayFlagsMax = 0x7fffffff, +} SpvRayFlagsShift; + +typedef enum SpvRayFlagsMask_ { + SpvRayFlagsMaskNone = 0, + SpvRayFlagsOpaqueKHRMask = 0x00000001, + SpvRayFlagsNoOpaqueKHRMask = 0x00000002, + SpvRayFlagsTerminateOnFirstHitKHRMask = 0x00000004, + SpvRayFlagsSkipClosestHitShaderKHRMask = 0x00000008, + SpvRayFlagsCullBackFacingTrianglesKHRMask = 0x00000010, + SpvRayFlagsCullFrontFacingTrianglesKHRMask = 0x00000020, + SpvRayFlagsCullOpaqueKHRMask = 0x00000040, + SpvRayFlagsCullNoOpaqueKHRMask = 0x00000080, + SpvRayFlagsSkipTrianglesKHRMask = 0x00000100, + SpvRayFlagsSkipAABBsKHRMask = 0x00000200, +} SpvRayFlagsMask; + +typedef enum SpvRayQueryIntersection_ { + SpvRayQueryIntersectionRayQueryCandidateIntersectionKHR = 0, + SpvRayQueryIntersectionRayQueryCommittedIntersectionKHR = 1, + SpvRayQueryIntersectionMax = 0x7fffffff, +} SpvRayQueryIntersection; + +typedef enum SpvRayQueryCommittedIntersectionType_ { + SpvRayQueryCommittedIntersectionTypeRayQueryCommittedIntersectionNoneKHR = 0, + SpvRayQueryCommittedIntersectionTypeRayQueryCommittedIntersectionTriangleKHR = 1, + SpvRayQueryCommittedIntersectionTypeRayQueryCommittedIntersectionGeneratedKHR = 2, + SpvRayQueryCommittedIntersectionTypeMax = 0x7fffffff, +} SpvRayQueryCommittedIntersectionType; + +typedef enum SpvRayQueryCandidateIntersectionType_ { + SpvRayQueryCandidateIntersectionTypeRayQueryCandidateIntersectionTriangleKHR = 0, + SpvRayQueryCandidateIntersectionTypeRayQueryCandidateIntersectionAABBKHR = 1, + SpvRayQueryCandidateIntersectionTypeMax = 0x7fffffff, +} SpvRayQueryCandidateIntersectionType; + +typedef enum SpvOp_ { + SpvOpNop = 0, + SpvOpUndef = 1, + SpvOpSourceContinued = 2, + SpvOpSource = 3, + SpvOpSourceExtension = 4, + SpvOpName = 5, + SpvOpMemberName = 6, + SpvOpString = 7, + SpvOpLine = 8, + SpvOpExtension = 10, + SpvOpExtInstImport = 11, + SpvOpExtInst = 12, + SpvOpMemoryModel = 14, + SpvOpEntryPoint = 15, + SpvOpExecutionMode = 16, + SpvOpCapability = 17, + SpvOpTypeVoid = 19, + SpvOpTypeBool = 20, + SpvOpTypeInt = 21, + SpvOpTypeFloat = 22, + SpvOpTypeVector = 23, + SpvOpTypeMatrix = 24, + SpvOpTypeImage = 25, + SpvOpTypeSampler = 26, + SpvOpTypeSampledImage = 27, + SpvOpTypeArray = 28, + SpvOpTypeRuntimeArray = 29, + SpvOpTypeStruct = 30, + SpvOpTypeOpaque = 31, + SpvOpTypePointer = 32, + SpvOpTypeFunction = 33, + SpvOpTypeEvent = 34, + SpvOpTypeDeviceEvent = 35, + SpvOpTypeReserveId = 36, + SpvOpTypeQueue = 37, + SpvOpTypePipe = 38, + SpvOpTypeForwardPointer = 39, + SpvOpConstantTrue = 41, + SpvOpConstantFalse = 42, + SpvOpConstant = 43, + SpvOpConstantComposite = 44, + SpvOpConstantSampler = 45, + SpvOpConstantNull = 46, + SpvOpSpecConstantTrue = 48, + SpvOpSpecConstantFalse = 49, + SpvOpSpecConstant = 50, + SpvOpSpecConstantComposite = 51, + SpvOpSpecConstantOp = 52, + SpvOpFunction = 54, + SpvOpFunctionParameter = 55, + SpvOpFunctionEnd = 56, + SpvOpFunctionCall = 57, + SpvOpVariable = 59, + SpvOpImageTexelPointer = 60, + SpvOpLoad = 61, + SpvOpStore = 62, + SpvOpCopyMemory = 63, + SpvOpCopyMemorySized = 64, + SpvOpAccessChain = 65, + SpvOpInBoundsAccessChain = 66, + SpvOpPtrAccessChain = 67, + SpvOpArrayLength = 68, + SpvOpGenericPtrMemSemantics = 69, + SpvOpInBoundsPtrAccessChain = 70, + SpvOpDecorate = 71, + SpvOpMemberDecorate = 72, + SpvOpDecorationGroup = 73, + SpvOpGroupDecorate = 74, + SpvOpGroupMemberDecorate = 75, + SpvOpVectorExtractDynamic = 77, + SpvOpVectorInsertDynamic = 78, + SpvOpVectorShuffle = 79, + SpvOpCompositeConstruct = 80, + SpvOpCompositeExtract = 81, + SpvOpCompositeInsert = 82, + SpvOpCopyObject = 83, + SpvOpTranspose = 84, + SpvOpSampledImage = 86, + SpvOpImageSampleImplicitLod = 87, + SpvOpImageSampleExplicitLod = 88, + SpvOpImageSampleDrefImplicitLod = 89, + SpvOpImageSampleDrefExplicitLod = 90, + SpvOpImageSampleProjImplicitLod = 91, + SpvOpImageSampleProjExplicitLod = 92, + SpvOpImageSampleProjDrefImplicitLod = 93, + SpvOpImageSampleProjDrefExplicitLod = 94, + SpvOpImageFetch = 95, + SpvOpImageGather = 96, + SpvOpImageDrefGather = 97, + SpvOpImageRead = 98, + SpvOpImageWrite = 99, + SpvOpImage = 100, + SpvOpImageQueryFormat = 101, + SpvOpImageQueryOrder = 102, + SpvOpImageQuerySizeLod = 103, + SpvOpImageQuerySize = 104, + SpvOpImageQueryLod = 105, + SpvOpImageQueryLevels = 106, + SpvOpImageQuerySamples = 107, + SpvOpConvertFToU = 109, + SpvOpConvertFToS = 110, + SpvOpConvertSToF = 111, + SpvOpConvertUToF = 112, + SpvOpUConvert = 113, + SpvOpSConvert = 114, + SpvOpFConvert = 115, + SpvOpQuantizeToF16 = 116, + SpvOpConvertPtrToU = 117, + SpvOpSatConvertSToU = 118, + SpvOpSatConvertUToS = 119, + SpvOpConvertUToPtr = 120, + SpvOpPtrCastToGeneric = 121, + SpvOpGenericCastToPtr = 122, + SpvOpGenericCastToPtrExplicit = 123, + SpvOpBitcast = 124, + SpvOpSNegate = 126, + SpvOpFNegate = 127, + SpvOpIAdd = 128, + SpvOpFAdd = 129, + SpvOpISub = 130, + SpvOpFSub = 131, + SpvOpIMul = 132, + SpvOpFMul = 133, + SpvOpUDiv = 134, + SpvOpSDiv = 135, + SpvOpFDiv = 136, + SpvOpUMod = 137, + SpvOpSRem = 138, + SpvOpSMod = 139, + SpvOpFRem = 140, + SpvOpFMod = 141, + SpvOpVectorTimesScalar = 142, + SpvOpMatrixTimesScalar = 143, + SpvOpVectorTimesMatrix = 144, + SpvOpMatrixTimesVector = 145, + SpvOpMatrixTimesMatrix = 146, + SpvOpOuterProduct = 147, + SpvOpDot = 148, + SpvOpIAddCarry = 149, + SpvOpISubBorrow = 150, + SpvOpUMulExtended = 151, + SpvOpSMulExtended = 152, + SpvOpAny = 154, + SpvOpAll = 155, + SpvOpIsNan = 156, + SpvOpIsInf = 157, + SpvOpIsFinite = 158, + SpvOpIsNormal = 159, + SpvOpSignBitSet = 160, + SpvOpLessOrGreater = 161, + SpvOpOrdered = 162, + SpvOpUnordered = 163, + SpvOpLogicalEqual = 164, + SpvOpLogicalNotEqual = 165, + SpvOpLogicalOr = 166, + SpvOpLogicalAnd = 167, + SpvOpLogicalNot = 168, + SpvOpSelect = 169, + SpvOpIEqual = 170, + SpvOpINotEqual = 171, + SpvOpUGreaterThan = 172, + SpvOpSGreaterThan = 173, + SpvOpUGreaterThanEqual = 174, + SpvOpSGreaterThanEqual = 175, + SpvOpULessThan = 176, + SpvOpSLessThan = 177, + SpvOpULessThanEqual = 178, + SpvOpSLessThanEqual = 179, + SpvOpFOrdEqual = 180, + SpvOpFUnordEqual = 181, + SpvOpFOrdNotEqual = 182, + SpvOpFUnordNotEqual = 183, + SpvOpFOrdLessThan = 184, + SpvOpFUnordLessThan = 185, + SpvOpFOrdGreaterThan = 186, + SpvOpFUnordGreaterThan = 187, + SpvOpFOrdLessThanEqual = 188, + SpvOpFUnordLessThanEqual = 189, + SpvOpFOrdGreaterThanEqual = 190, + SpvOpFUnordGreaterThanEqual = 191, + SpvOpShiftRightLogical = 194, + SpvOpShiftRightArithmetic = 195, + SpvOpShiftLeftLogical = 196, + SpvOpBitwiseOr = 197, + SpvOpBitwiseXor = 198, + SpvOpBitwiseAnd = 199, + SpvOpNot = 200, + SpvOpBitFieldInsert = 201, + SpvOpBitFieldSExtract = 202, + SpvOpBitFieldUExtract = 203, + SpvOpBitReverse = 204, + SpvOpBitCount = 205, + SpvOpDPdx = 207, + SpvOpDPdy = 208, + SpvOpFwidth = 209, + SpvOpDPdxFine = 210, + SpvOpDPdyFine = 211, + SpvOpFwidthFine = 212, + SpvOpDPdxCoarse = 213, + SpvOpDPdyCoarse = 214, + SpvOpFwidthCoarse = 215, + SpvOpEmitVertex = 218, + SpvOpEndPrimitive = 219, + SpvOpEmitStreamVertex = 220, + SpvOpEndStreamPrimitive = 221, + SpvOpControlBarrier = 224, + SpvOpMemoryBarrier = 225, + SpvOpAtomicLoad = 227, + SpvOpAtomicStore = 228, + SpvOpAtomicExchange = 229, + SpvOpAtomicCompareExchange = 230, + SpvOpAtomicCompareExchangeWeak = 231, + SpvOpAtomicIIncrement = 232, + SpvOpAtomicIDecrement = 233, + SpvOpAtomicIAdd = 234, + SpvOpAtomicISub = 235, + SpvOpAtomicSMin = 236, + SpvOpAtomicUMin = 237, + SpvOpAtomicSMax = 238, + SpvOpAtomicUMax = 239, + SpvOpAtomicAnd = 240, + SpvOpAtomicOr = 241, + SpvOpAtomicXor = 242, + SpvOpPhi = 245, + SpvOpLoopMerge = 246, + SpvOpSelectionMerge = 247, + SpvOpLabel = 248, + SpvOpBranch = 249, + SpvOpBranchConditional = 250, + SpvOpSwitch = 251, + SpvOpKill = 252, + SpvOpReturn = 253, + SpvOpReturnValue = 254, + SpvOpUnreachable = 255, + SpvOpLifetimeStart = 256, + SpvOpLifetimeStop = 257, + SpvOpGroupAsyncCopy = 259, + SpvOpGroupWaitEvents = 260, + SpvOpGroupAll = 261, + SpvOpGroupAny = 262, + SpvOpGroupBroadcast = 263, + SpvOpGroupIAdd = 264, + SpvOpGroupFAdd = 265, + SpvOpGroupFMin = 266, + SpvOpGroupUMin = 267, + SpvOpGroupSMin = 268, + SpvOpGroupFMax = 269, + SpvOpGroupUMax = 270, + SpvOpGroupSMax = 271, + SpvOpReadPipe = 274, + SpvOpWritePipe = 275, + SpvOpReservedReadPipe = 276, + SpvOpReservedWritePipe = 277, + SpvOpReserveReadPipePackets = 278, + SpvOpReserveWritePipePackets = 279, + SpvOpCommitReadPipe = 280, + SpvOpCommitWritePipe = 281, + SpvOpIsValidReserveId = 282, + SpvOpGetNumPipePackets = 283, + SpvOpGetMaxPipePackets = 284, + SpvOpGroupReserveReadPipePackets = 285, + SpvOpGroupReserveWritePipePackets = 286, + SpvOpGroupCommitReadPipe = 287, + SpvOpGroupCommitWritePipe = 288, + SpvOpEnqueueMarker = 291, + SpvOpEnqueueKernel = 292, + SpvOpGetKernelNDrangeSubGroupCount = 293, + SpvOpGetKernelNDrangeMaxSubGroupSize = 294, + SpvOpGetKernelWorkGroupSize = 295, + SpvOpGetKernelPreferredWorkGroupSizeMultiple = 296, + SpvOpRetainEvent = 297, + SpvOpReleaseEvent = 298, + SpvOpCreateUserEvent = 299, + SpvOpIsValidEvent = 300, + SpvOpSetUserEventStatus = 301, + SpvOpCaptureEventProfilingInfo = 302, + SpvOpGetDefaultQueue = 303, + SpvOpBuildNDRange = 304, + SpvOpImageSparseSampleImplicitLod = 305, + SpvOpImageSparseSampleExplicitLod = 306, + SpvOpImageSparseSampleDrefImplicitLod = 307, + SpvOpImageSparseSampleDrefExplicitLod = 308, + SpvOpImageSparseSampleProjImplicitLod = 309, + SpvOpImageSparseSampleProjExplicitLod = 310, + SpvOpImageSparseSampleProjDrefImplicitLod = 311, + SpvOpImageSparseSampleProjDrefExplicitLod = 312, + SpvOpImageSparseFetch = 313, + SpvOpImageSparseGather = 314, + SpvOpImageSparseDrefGather = 315, + SpvOpImageSparseTexelsResident = 316, + SpvOpNoLine = 317, + SpvOpAtomicFlagTestAndSet = 318, + SpvOpAtomicFlagClear = 319, + SpvOpImageSparseRead = 320, + SpvOpSizeOf = 321, + SpvOpTypePipeStorage = 322, + SpvOpConstantPipeStorage = 323, + SpvOpCreatePipeFromPipeStorage = 324, + SpvOpGetKernelLocalSizeForSubgroupCount = 325, + SpvOpGetKernelMaxNumSubgroups = 326, + SpvOpTypeNamedBarrier = 327, + SpvOpNamedBarrierInitialize = 328, + SpvOpMemoryNamedBarrier = 329, + SpvOpModuleProcessed = 330, + SpvOpExecutionModeId = 331, + SpvOpDecorateId = 332, + SpvOpGroupNonUniformElect = 333, + SpvOpGroupNonUniformAll = 334, + SpvOpGroupNonUniformAny = 335, + SpvOpGroupNonUniformAllEqual = 336, + SpvOpGroupNonUniformBroadcast = 337, + SpvOpGroupNonUniformBroadcastFirst = 338, + SpvOpGroupNonUniformBallot = 339, + SpvOpGroupNonUniformInverseBallot = 340, + SpvOpGroupNonUniformBallotBitExtract = 341, + SpvOpGroupNonUniformBallotBitCount = 342, + SpvOpGroupNonUniformBallotFindLSB = 343, + SpvOpGroupNonUniformBallotFindMSB = 344, + SpvOpGroupNonUniformShuffle = 345, + SpvOpGroupNonUniformShuffleXor = 346, + SpvOpGroupNonUniformShuffleUp = 347, + SpvOpGroupNonUniformShuffleDown = 348, + SpvOpGroupNonUniformIAdd = 349, + SpvOpGroupNonUniformFAdd = 350, + SpvOpGroupNonUniformIMul = 351, + SpvOpGroupNonUniformFMul = 352, + SpvOpGroupNonUniformSMin = 353, + SpvOpGroupNonUniformUMin = 354, + SpvOpGroupNonUniformFMin = 355, + SpvOpGroupNonUniformSMax = 356, + SpvOpGroupNonUniformUMax = 357, + SpvOpGroupNonUniformFMax = 358, + SpvOpGroupNonUniformBitwiseAnd = 359, + SpvOpGroupNonUniformBitwiseOr = 360, + SpvOpGroupNonUniformBitwiseXor = 361, + SpvOpGroupNonUniformLogicalAnd = 362, + SpvOpGroupNonUniformLogicalOr = 363, + SpvOpGroupNonUniformLogicalXor = 364, + SpvOpGroupNonUniformQuadBroadcast = 365, + SpvOpGroupNonUniformQuadSwap = 366, + SpvOpCopyLogical = 400, + SpvOpPtrEqual = 401, + SpvOpPtrNotEqual = 402, + SpvOpPtrDiff = 403, + SpvOpTerminateInvocation = 4416, + SpvOpSubgroupBallotKHR = 4421, + SpvOpSubgroupFirstInvocationKHR = 4422, + SpvOpSubgroupAllKHR = 4428, + SpvOpSubgroupAnyKHR = 4429, + SpvOpSubgroupAllEqualKHR = 4430, + SpvOpSubgroupReadInvocationKHR = 4432, + SpvOpTypeRayQueryProvisionalKHR = 4472, + SpvOpRayQueryInitializeKHR = 4473, + SpvOpRayQueryTerminateKHR = 4474, + SpvOpRayQueryGenerateIntersectionKHR = 4475, + SpvOpRayQueryConfirmIntersectionKHR = 4476, + SpvOpRayQueryProceedKHR = 4477, + SpvOpRayQueryGetIntersectionTypeKHR = 4479, + SpvOpGroupIAddNonUniformAMD = 5000, + SpvOpGroupFAddNonUniformAMD = 5001, + SpvOpGroupFMinNonUniformAMD = 5002, + SpvOpGroupUMinNonUniformAMD = 5003, + SpvOpGroupSMinNonUniformAMD = 5004, + SpvOpGroupFMaxNonUniformAMD = 5005, + SpvOpGroupUMaxNonUniformAMD = 5006, + SpvOpGroupSMaxNonUniformAMD = 5007, + SpvOpFragmentMaskFetchAMD = 5011, + SpvOpFragmentFetchAMD = 5012, + SpvOpReadClockKHR = 5056, + SpvOpImageSampleFootprintNV = 5283, + SpvOpGroupNonUniformPartitionNV = 5296, + SpvOpWritePackedPrimitiveIndices4x8NV = 5299, + SpvOpReportIntersectionKHR = 5334, + SpvOpReportIntersectionNV = 5334, + SpvOpIgnoreIntersectionKHR = 5335, + SpvOpIgnoreIntersectionNV = 5335, + SpvOpTerminateRayKHR = 5336, + SpvOpTerminateRayNV = 5336, + SpvOpTraceNV = 5337, + SpvOpTraceRayKHR = 5337, + SpvOpTypeAccelerationStructureKHR = 5341, + SpvOpTypeAccelerationStructureNV = 5341, + SpvOpExecuteCallableKHR = 5344, + SpvOpExecuteCallableNV = 5344, + SpvOpTypeCooperativeMatrixNV = 5358, + SpvOpCooperativeMatrixLoadNV = 5359, + SpvOpCooperativeMatrixStoreNV = 5360, + SpvOpCooperativeMatrixMulAddNV = 5361, + SpvOpCooperativeMatrixLengthNV = 5362, + SpvOpBeginInvocationInterlockEXT = 5364, + SpvOpEndInvocationInterlockEXT = 5365, + SpvOpDemoteToHelperInvocationEXT = 5380, + SpvOpIsHelperInvocationEXT = 5381, + SpvOpSubgroupShuffleINTEL = 5571, + SpvOpSubgroupShuffleDownINTEL = 5572, + SpvOpSubgroupShuffleUpINTEL = 5573, + SpvOpSubgroupShuffleXorINTEL = 5574, + SpvOpSubgroupBlockReadINTEL = 5575, + SpvOpSubgroupBlockWriteINTEL = 5576, + SpvOpSubgroupImageBlockReadINTEL = 5577, + SpvOpSubgroupImageBlockWriteINTEL = 5578, + SpvOpSubgroupImageMediaBlockReadINTEL = 5580, + SpvOpSubgroupImageMediaBlockWriteINTEL = 5581, + SpvOpUCountLeadingZerosINTEL = 5585, + SpvOpUCountTrailingZerosINTEL = 5586, + SpvOpAbsISubINTEL = 5587, + SpvOpAbsUSubINTEL = 5588, + SpvOpIAddSatINTEL = 5589, + SpvOpUAddSatINTEL = 5590, + SpvOpIAverageINTEL = 5591, + SpvOpUAverageINTEL = 5592, + SpvOpIAverageRoundedINTEL = 5593, + SpvOpUAverageRoundedINTEL = 5594, + SpvOpISubSatINTEL = 5595, + SpvOpUSubSatINTEL = 5596, + SpvOpIMul32x16INTEL = 5597, + SpvOpUMul32x16INTEL = 5598, + SpvOpFunctionPointerINTEL = 5600, + SpvOpFunctionPointerCallINTEL = 5601, + SpvOpDecorateString = 5632, + SpvOpDecorateStringGOOGLE = 5632, + SpvOpMemberDecorateString = 5633, + SpvOpMemberDecorateStringGOOGLE = 5633, + SpvOpVmeImageINTEL = 5699, + SpvOpTypeVmeImageINTEL = 5700, + SpvOpTypeAvcImePayloadINTEL = 5701, + SpvOpTypeAvcRefPayloadINTEL = 5702, + SpvOpTypeAvcSicPayloadINTEL = 5703, + SpvOpTypeAvcMcePayloadINTEL = 5704, + SpvOpTypeAvcMceResultINTEL = 5705, + SpvOpTypeAvcImeResultINTEL = 5706, + SpvOpTypeAvcImeResultSingleReferenceStreamoutINTEL = 5707, + SpvOpTypeAvcImeResultDualReferenceStreamoutINTEL = 5708, + SpvOpTypeAvcImeSingleReferenceStreaminINTEL = 5709, + SpvOpTypeAvcImeDualReferenceStreaminINTEL = 5710, + SpvOpTypeAvcRefResultINTEL = 5711, + SpvOpTypeAvcSicResultINTEL = 5712, + SpvOpSubgroupAvcMceGetDefaultInterBaseMultiReferencePenaltyINTEL = 5713, + SpvOpSubgroupAvcMceSetInterBaseMultiReferencePenaltyINTEL = 5714, + SpvOpSubgroupAvcMceGetDefaultInterShapePenaltyINTEL = 5715, + SpvOpSubgroupAvcMceSetInterShapePenaltyINTEL = 5716, + SpvOpSubgroupAvcMceGetDefaultInterDirectionPenaltyINTEL = 5717, + SpvOpSubgroupAvcMceSetInterDirectionPenaltyINTEL = 5718, + SpvOpSubgroupAvcMceGetDefaultIntraLumaShapePenaltyINTEL = 5719, + SpvOpSubgroupAvcMceGetDefaultInterMotionVectorCostTableINTEL = 5720, + SpvOpSubgroupAvcMceGetDefaultHighPenaltyCostTableINTEL = 5721, + SpvOpSubgroupAvcMceGetDefaultMediumPenaltyCostTableINTEL = 5722, + SpvOpSubgroupAvcMceGetDefaultLowPenaltyCostTableINTEL = 5723, + SpvOpSubgroupAvcMceSetMotionVectorCostFunctionINTEL = 5724, + SpvOpSubgroupAvcMceGetDefaultIntraLumaModePenaltyINTEL = 5725, + SpvOpSubgroupAvcMceGetDefaultNonDcLumaIntraPenaltyINTEL = 5726, + SpvOpSubgroupAvcMceGetDefaultIntraChromaModeBasePenaltyINTEL = 5727, + SpvOpSubgroupAvcMceSetAcOnlyHaarINTEL = 5728, + SpvOpSubgroupAvcMceSetSourceInterlacedFieldPolarityINTEL = 5729, + SpvOpSubgroupAvcMceSetSingleReferenceInterlacedFieldPolarityINTEL = 5730, + SpvOpSubgroupAvcMceSetDualReferenceInterlacedFieldPolaritiesINTEL = 5731, + SpvOpSubgroupAvcMceConvertToImePayloadINTEL = 5732, + SpvOpSubgroupAvcMceConvertToImeResultINTEL = 5733, + SpvOpSubgroupAvcMceConvertToRefPayloadINTEL = 5734, + SpvOpSubgroupAvcMceConvertToRefResultINTEL = 5735, + SpvOpSubgroupAvcMceConvertToSicPayloadINTEL = 5736, + SpvOpSubgroupAvcMceConvertToSicResultINTEL = 5737, + SpvOpSubgroupAvcMceGetMotionVectorsINTEL = 5738, + SpvOpSubgroupAvcMceGetInterDistortionsINTEL = 5739, + SpvOpSubgroupAvcMceGetBestInterDistortionsINTEL = 5740, + SpvOpSubgroupAvcMceGetInterMajorShapeINTEL = 5741, + SpvOpSubgroupAvcMceGetInterMinorShapeINTEL = 5742, + SpvOpSubgroupAvcMceGetInterDirectionsINTEL = 5743, + SpvOpSubgroupAvcMceGetInterMotionVectorCountINTEL = 5744, + SpvOpSubgroupAvcMceGetInterReferenceIdsINTEL = 5745, + SpvOpSubgroupAvcMceGetInterReferenceInterlacedFieldPolaritiesINTEL = 5746, + SpvOpSubgroupAvcImeInitializeINTEL = 5747, + SpvOpSubgroupAvcImeSetSingleReferenceINTEL = 5748, + SpvOpSubgroupAvcImeSetDualReferenceINTEL = 5749, + SpvOpSubgroupAvcImeRefWindowSizeINTEL = 5750, + SpvOpSubgroupAvcImeAdjustRefOffsetINTEL = 5751, + SpvOpSubgroupAvcImeConvertToMcePayloadINTEL = 5752, + SpvOpSubgroupAvcImeSetMaxMotionVectorCountINTEL = 5753, + SpvOpSubgroupAvcImeSetUnidirectionalMixDisableINTEL = 5754, + SpvOpSubgroupAvcImeSetEarlySearchTerminationThresholdINTEL = 5755, + SpvOpSubgroupAvcImeSetWeightedSadINTEL = 5756, + SpvOpSubgroupAvcImeEvaluateWithSingleReferenceINTEL = 5757, + SpvOpSubgroupAvcImeEvaluateWithDualReferenceINTEL = 5758, + SpvOpSubgroupAvcImeEvaluateWithSingleReferenceStreaminINTEL = 5759, + SpvOpSubgroupAvcImeEvaluateWithDualReferenceStreaminINTEL = 5760, + SpvOpSubgroupAvcImeEvaluateWithSingleReferenceStreamoutINTEL = 5761, + SpvOpSubgroupAvcImeEvaluateWithDualReferenceStreamoutINTEL = 5762, + SpvOpSubgroupAvcImeEvaluateWithSingleReferenceStreaminoutINTEL = 5763, + SpvOpSubgroupAvcImeEvaluateWithDualReferenceStreaminoutINTEL = 5764, + SpvOpSubgroupAvcImeConvertToMceResultINTEL = 5765, + SpvOpSubgroupAvcImeGetSingleReferenceStreaminINTEL = 5766, + SpvOpSubgroupAvcImeGetDualReferenceStreaminINTEL = 5767, + SpvOpSubgroupAvcImeStripSingleReferenceStreamoutINTEL = 5768, + SpvOpSubgroupAvcImeStripDualReferenceStreamoutINTEL = 5769, + SpvOpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeMotionVectorsINTEL = 5770, + SpvOpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeDistortionsINTEL = 5771, + SpvOpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeReferenceIdsINTEL = 5772, + SpvOpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeMotionVectorsINTEL = 5773, + SpvOpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeDistortionsINTEL = 5774, + SpvOpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeReferenceIdsINTEL = 5775, + SpvOpSubgroupAvcImeGetBorderReachedINTEL = 5776, + SpvOpSubgroupAvcImeGetTruncatedSearchIndicationINTEL = 5777, + SpvOpSubgroupAvcImeGetUnidirectionalEarlySearchTerminationINTEL = 5778, + SpvOpSubgroupAvcImeGetWeightingPatternMinimumMotionVectorINTEL = 5779, + SpvOpSubgroupAvcImeGetWeightingPatternMinimumDistortionINTEL = 5780, + SpvOpSubgroupAvcFmeInitializeINTEL = 5781, + SpvOpSubgroupAvcBmeInitializeINTEL = 5782, + SpvOpSubgroupAvcRefConvertToMcePayloadINTEL = 5783, + SpvOpSubgroupAvcRefSetBidirectionalMixDisableINTEL = 5784, + SpvOpSubgroupAvcRefSetBilinearFilterEnableINTEL = 5785, + SpvOpSubgroupAvcRefEvaluateWithSingleReferenceINTEL = 5786, + SpvOpSubgroupAvcRefEvaluateWithDualReferenceINTEL = 5787, + SpvOpSubgroupAvcRefEvaluateWithMultiReferenceINTEL = 5788, + SpvOpSubgroupAvcRefEvaluateWithMultiReferenceInterlacedINTEL = 5789, + SpvOpSubgroupAvcRefConvertToMceResultINTEL = 5790, + SpvOpSubgroupAvcSicInitializeINTEL = 5791, + SpvOpSubgroupAvcSicConfigureSkcINTEL = 5792, + SpvOpSubgroupAvcSicConfigureIpeLumaINTEL = 5793, + SpvOpSubgroupAvcSicConfigureIpeLumaChromaINTEL = 5794, + SpvOpSubgroupAvcSicGetMotionVectorMaskINTEL = 5795, + SpvOpSubgroupAvcSicConvertToMcePayloadINTEL = 5796, + SpvOpSubgroupAvcSicSetIntraLumaShapePenaltyINTEL = 5797, + SpvOpSubgroupAvcSicSetIntraLumaModeCostFunctionINTEL = 5798, + SpvOpSubgroupAvcSicSetIntraChromaModeCostFunctionINTEL = 5799, + SpvOpSubgroupAvcSicSetBilinearFilterEnableINTEL = 5800, + SpvOpSubgroupAvcSicSetSkcForwardTransformEnableINTEL = 5801, + SpvOpSubgroupAvcSicSetBlockBasedRawSkipSadINTEL = 5802, + SpvOpSubgroupAvcSicEvaluateIpeINTEL = 5803, + SpvOpSubgroupAvcSicEvaluateWithSingleReferenceINTEL = 5804, + SpvOpSubgroupAvcSicEvaluateWithDualReferenceINTEL = 5805, + SpvOpSubgroupAvcSicEvaluateWithMultiReferenceINTEL = 5806, + SpvOpSubgroupAvcSicEvaluateWithMultiReferenceInterlacedINTEL = 5807, + SpvOpSubgroupAvcSicConvertToMceResultINTEL = 5808, + SpvOpSubgroupAvcSicGetIpeLumaShapeINTEL = 5809, + SpvOpSubgroupAvcSicGetBestIpeLumaDistortionINTEL = 5810, + SpvOpSubgroupAvcSicGetBestIpeChromaDistortionINTEL = 5811, + SpvOpSubgroupAvcSicGetPackedIpeLumaModesINTEL = 5812, + SpvOpSubgroupAvcSicGetIpeChromaModeINTEL = 5813, + SpvOpSubgroupAvcSicGetPackedSkcLumaCountThresholdINTEL = 5814, + SpvOpSubgroupAvcSicGetPackedSkcLumaSumThresholdINTEL = 5815, + SpvOpSubgroupAvcSicGetInterRawSadsINTEL = 5816, + SpvOpLoopControlINTEL = 5887, + SpvOpReadPipeBlockingINTEL = 5946, + SpvOpWritePipeBlockingINTEL = 5947, + SpvOpFPGARegINTEL = 5949, + SpvOpRayQueryGetRayTMinKHR = 6016, + SpvOpRayQueryGetRayFlagsKHR = 6017, + SpvOpRayQueryGetIntersectionTKHR = 6018, + SpvOpRayQueryGetIntersectionInstanceCustomIndexKHR = 6019, + SpvOpRayQueryGetIntersectionInstanceIdKHR = 6020, + SpvOpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR = 6021, + SpvOpRayQueryGetIntersectionGeometryIndexKHR = 6022, + SpvOpRayQueryGetIntersectionPrimitiveIndexKHR = 6023, + SpvOpRayQueryGetIntersectionBarycentricsKHR = 6024, + SpvOpRayQueryGetIntersectionFrontFaceKHR = 6025, + SpvOpRayQueryGetIntersectionCandidateAABBOpaqueKHR = 6026, + SpvOpRayQueryGetIntersectionObjectRayDirectionKHR = 6027, + SpvOpRayQueryGetIntersectionObjectRayOriginKHR = 6028, + SpvOpRayQueryGetWorldRayDirectionKHR = 6029, + SpvOpRayQueryGetWorldRayOriginKHR = 6030, + SpvOpRayQueryGetIntersectionObjectToWorldKHR = 6031, + SpvOpRayQueryGetIntersectionWorldToObjectKHR = 6032, + SpvOpAtomicFAddEXT = 6035, + SpvOpMax = 0x7fffffff, +} SpvOp; + +#ifdef SPV_ENABLE_UTILITY_CODE +inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultType) { + *hasResult = *hasResultType = false; + switch (opcode) { + default: /* unknown opcode */ break; + case SpvOpNop: *hasResult = false; *hasResultType = false; break; + case SpvOpUndef: *hasResult = true; *hasResultType = true; break; + case SpvOpSourceContinued: *hasResult = false; *hasResultType = false; break; + case SpvOpSource: *hasResult = false; *hasResultType = false; break; + case SpvOpSourceExtension: *hasResult = false; *hasResultType = false; break; + case SpvOpName: *hasResult = false; *hasResultType = false; break; + case SpvOpMemberName: *hasResult = false; *hasResultType = false; break; + case SpvOpString: *hasResult = true; *hasResultType = false; break; + case SpvOpLine: *hasResult = false; *hasResultType = false; break; + case SpvOpExtension: *hasResult = false; *hasResultType = false; break; + case SpvOpExtInstImport: *hasResult = true; *hasResultType = false; break; + case SpvOpExtInst: *hasResult = true; *hasResultType = true; break; + case SpvOpMemoryModel: *hasResult = false; *hasResultType = false; break; + case SpvOpEntryPoint: *hasResult = false; *hasResultType = false; break; + case SpvOpExecutionMode: *hasResult = false; *hasResultType = false; break; + case SpvOpCapability: *hasResult = false; *hasResultType = false; break; + case SpvOpTypeVoid: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeBool: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeInt: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeFloat: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeVector: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeMatrix: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeImage: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeSampler: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeSampledImage: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeArray: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeRuntimeArray: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeStruct: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeOpaque: *hasResult = true; *hasResultType = false; break; + case SpvOpTypePointer: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeFunction: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeEvent: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeDeviceEvent: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeReserveId: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeQueue: *hasResult = true; *hasResultType = false; break; + case SpvOpTypePipe: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeForwardPointer: *hasResult = false; *hasResultType = false; break; + case SpvOpConstantTrue: *hasResult = true; *hasResultType = true; break; + case SpvOpConstantFalse: *hasResult = true; *hasResultType = true; break; + case SpvOpConstant: *hasResult = true; *hasResultType = true; break; + case SpvOpConstantComposite: *hasResult = true; *hasResultType = true; break; + case SpvOpConstantSampler: *hasResult = true; *hasResultType = true; break; + case SpvOpConstantNull: *hasResult = true; *hasResultType = true; break; + case SpvOpSpecConstantTrue: *hasResult = true; *hasResultType = true; break; + case SpvOpSpecConstantFalse: *hasResult = true; *hasResultType = true; break; + case SpvOpSpecConstant: *hasResult = true; *hasResultType = true; break; + case SpvOpSpecConstantComposite: *hasResult = true; *hasResultType = true; break; + case SpvOpSpecConstantOp: *hasResult = true; *hasResultType = true; break; + case SpvOpFunction: *hasResult = true; *hasResultType = true; break; + case SpvOpFunctionParameter: *hasResult = true; *hasResultType = true; break; + case SpvOpFunctionEnd: *hasResult = false; *hasResultType = false; break; + case SpvOpFunctionCall: *hasResult = true; *hasResultType = true; break; + case SpvOpVariable: *hasResult = true; *hasResultType = true; break; + case SpvOpImageTexelPointer: *hasResult = true; *hasResultType = true; break; + case SpvOpLoad: *hasResult = true; *hasResultType = true; break; + case SpvOpStore: *hasResult = false; *hasResultType = false; break; + case SpvOpCopyMemory: *hasResult = false; *hasResultType = false; break; + case SpvOpCopyMemorySized: *hasResult = false; *hasResultType = false; break; + case SpvOpAccessChain: *hasResult = true; *hasResultType = true; break; + case SpvOpInBoundsAccessChain: *hasResult = true; *hasResultType = true; break; + case SpvOpPtrAccessChain: *hasResult = true; *hasResultType = true; break; + case SpvOpArrayLength: *hasResult = true; *hasResultType = true; break; + case SpvOpGenericPtrMemSemantics: *hasResult = true; *hasResultType = true; break; + case SpvOpInBoundsPtrAccessChain: *hasResult = true; *hasResultType = true; break; + case SpvOpDecorate: *hasResult = false; *hasResultType = false; break; + case SpvOpMemberDecorate: *hasResult = false; *hasResultType = false; break; + case SpvOpDecorationGroup: *hasResult = true; *hasResultType = false; break; + case SpvOpGroupDecorate: *hasResult = false; *hasResultType = false; break; + case SpvOpGroupMemberDecorate: *hasResult = false; *hasResultType = false; break; + case SpvOpVectorExtractDynamic: *hasResult = true; *hasResultType = true; break; + case SpvOpVectorInsertDynamic: *hasResult = true; *hasResultType = true; break; + case SpvOpVectorShuffle: *hasResult = true; *hasResultType = true; break; + case SpvOpCompositeConstruct: *hasResult = true; *hasResultType = true; break; + case SpvOpCompositeExtract: *hasResult = true; *hasResultType = true; break; + case SpvOpCompositeInsert: *hasResult = true; *hasResultType = true; break; + case SpvOpCopyObject: *hasResult = true; *hasResultType = true; break; + case SpvOpTranspose: *hasResult = true; *hasResultType = true; break; + case SpvOpSampledImage: *hasResult = true; *hasResultType = true; break; + case SpvOpImageSampleImplicitLod: *hasResult = true; *hasResultType = true; break; + case SpvOpImageSampleExplicitLod: *hasResult = true; *hasResultType = true; break; + case SpvOpImageSampleDrefImplicitLod: *hasResult = true; *hasResultType = true; break; + case SpvOpImageSampleDrefExplicitLod: *hasResult = true; *hasResultType = true; break; + case SpvOpImageSampleProjImplicitLod: *hasResult = true; *hasResultType = true; break; + case SpvOpImageSampleProjExplicitLod: *hasResult = true; *hasResultType = true; break; + case SpvOpImageSampleProjDrefImplicitLod: *hasResult = true; *hasResultType = true; break; + case SpvOpImageSampleProjDrefExplicitLod: *hasResult = true; *hasResultType = true; break; + case SpvOpImageFetch: *hasResult = true; *hasResultType = true; break; + case SpvOpImageGather: *hasResult = true; *hasResultType = true; break; + case SpvOpImageDrefGather: *hasResult = true; *hasResultType = true; break; + case SpvOpImageRead: *hasResult = true; *hasResultType = true; break; + case SpvOpImageWrite: *hasResult = false; *hasResultType = false; break; + case SpvOpImage: *hasResult = true; *hasResultType = true; break; + case SpvOpImageQueryFormat: *hasResult = true; *hasResultType = true; break; + case SpvOpImageQueryOrder: *hasResult = true; *hasResultType = true; break; + case SpvOpImageQuerySizeLod: *hasResult = true; *hasResultType = true; break; + case SpvOpImageQuerySize: *hasResult = true; *hasResultType = true; break; + case SpvOpImageQueryLod: *hasResult = true; *hasResultType = true; break; + case SpvOpImageQueryLevels: *hasResult = true; *hasResultType = true; break; + case SpvOpImageQuerySamples: *hasResult = true; *hasResultType = true; break; + case SpvOpConvertFToU: *hasResult = true; *hasResultType = true; break; + case SpvOpConvertFToS: *hasResult = true; *hasResultType = true; break; + case SpvOpConvertSToF: *hasResult = true; *hasResultType = true; break; + case SpvOpConvertUToF: *hasResult = true; *hasResultType = true; break; + case SpvOpUConvert: *hasResult = true; *hasResultType = true; break; + case SpvOpSConvert: *hasResult = true; *hasResultType = true; break; + case SpvOpFConvert: *hasResult = true; *hasResultType = true; break; + case SpvOpQuantizeToF16: *hasResult = true; *hasResultType = true; break; + case SpvOpConvertPtrToU: *hasResult = true; *hasResultType = true; break; + case SpvOpSatConvertSToU: *hasResult = true; *hasResultType = true; break; + case SpvOpSatConvertUToS: *hasResult = true; *hasResultType = true; break; + case SpvOpConvertUToPtr: *hasResult = true; *hasResultType = true; break; + case SpvOpPtrCastToGeneric: *hasResult = true; *hasResultType = true; break; + case SpvOpGenericCastToPtr: *hasResult = true; *hasResultType = true; break; + case SpvOpGenericCastToPtrExplicit: *hasResult = true; *hasResultType = true; break; + case SpvOpBitcast: *hasResult = true; *hasResultType = true; break; + case SpvOpSNegate: *hasResult = true; *hasResultType = true; break; + case SpvOpFNegate: *hasResult = true; *hasResultType = true; break; + case SpvOpIAdd: *hasResult = true; *hasResultType = true; break; + case SpvOpFAdd: *hasResult = true; *hasResultType = true; break; + case SpvOpISub: *hasResult = true; *hasResultType = true; break; + case SpvOpFSub: *hasResult = true; *hasResultType = true; break; + case SpvOpIMul: *hasResult = true; *hasResultType = true; break; + case SpvOpFMul: *hasResult = true; *hasResultType = true; break; + case SpvOpUDiv: *hasResult = true; *hasResultType = true; break; + case SpvOpSDiv: *hasResult = true; *hasResultType = true; break; + case SpvOpFDiv: *hasResult = true; *hasResultType = true; break; + case SpvOpUMod: *hasResult = true; *hasResultType = true; break; + case SpvOpSRem: *hasResult = true; *hasResultType = true; break; + case SpvOpSMod: *hasResult = true; *hasResultType = true; break; + case SpvOpFRem: *hasResult = true; *hasResultType = true; break; + case SpvOpFMod: *hasResult = true; *hasResultType = true; break; + case SpvOpVectorTimesScalar: *hasResult = true; *hasResultType = true; break; + case SpvOpMatrixTimesScalar: *hasResult = true; *hasResultType = true; break; + case SpvOpVectorTimesMatrix: *hasResult = true; *hasResultType = true; break; + case SpvOpMatrixTimesVector: *hasResult = true; *hasResultType = true; break; + case SpvOpMatrixTimesMatrix: *hasResult = true; *hasResultType = true; break; + case SpvOpOuterProduct: *hasResult = true; *hasResultType = true; break; + case SpvOpDot: *hasResult = true; *hasResultType = true; break; + case SpvOpIAddCarry: *hasResult = true; *hasResultType = true; break; + case SpvOpISubBorrow: *hasResult = true; *hasResultType = true; break; + case SpvOpUMulExtended: *hasResult = true; *hasResultType = true; break; + case SpvOpSMulExtended: *hasResult = true; *hasResultType = true; break; + case SpvOpAny: *hasResult = true; *hasResultType = true; break; + case SpvOpAll: *hasResult = true; *hasResultType = true; break; + case SpvOpIsNan: *hasResult = true; *hasResultType = true; break; + case SpvOpIsInf: *hasResult = true; *hasResultType = true; break; + case SpvOpIsFinite: *hasResult = true; *hasResultType = true; break; + case SpvOpIsNormal: *hasResult = true; *hasResultType = true; break; + case SpvOpSignBitSet: *hasResult = true; *hasResultType = true; break; + case SpvOpLessOrGreater: *hasResult = true; *hasResultType = true; break; + case SpvOpOrdered: *hasResult = true; *hasResultType = true; break; + case SpvOpUnordered: *hasResult = true; *hasResultType = true; break; + case SpvOpLogicalEqual: *hasResult = true; *hasResultType = true; break; + case SpvOpLogicalNotEqual: *hasResult = true; *hasResultType = true; break; + case SpvOpLogicalOr: *hasResult = true; *hasResultType = true; break; + case SpvOpLogicalAnd: *hasResult = true; *hasResultType = true; break; + case SpvOpLogicalNot: *hasResult = true; *hasResultType = true; break; + case SpvOpSelect: *hasResult = true; *hasResultType = true; break; + case SpvOpIEqual: *hasResult = true; *hasResultType = true; break; + case SpvOpINotEqual: *hasResult = true; *hasResultType = true; break; + case SpvOpUGreaterThan: *hasResult = true; *hasResultType = true; break; + case SpvOpSGreaterThan: *hasResult = true; *hasResultType = true; break; + case SpvOpUGreaterThanEqual: *hasResult = true; *hasResultType = true; break; + case SpvOpSGreaterThanEqual: *hasResult = true; *hasResultType = true; break; + case SpvOpULessThan: *hasResult = true; *hasResultType = true; break; + case SpvOpSLessThan: *hasResult = true; *hasResultType = true; break; + case SpvOpULessThanEqual: *hasResult = true; *hasResultType = true; break; + case SpvOpSLessThanEqual: *hasResult = true; *hasResultType = true; break; + case SpvOpFOrdEqual: *hasResult = true; *hasResultType = true; break; + case SpvOpFUnordEqual: *hasResult = true; *hasResultType = true; break; + case SpvOpFOrdNotEqual: *hasResult = true; *hasResultType = true; break; + case SpvOpFUnordNotEqual: *hasResult = true; *hasResultType = true; break; + case SpvOpFOrdLessThan: *hasResult = true; *hasResultType = true; break; + case SpvOpFUnordLessThan: *hasResult = true; *hasResultType = true; break; + case SpvOpFOrdGreaterThan: *hasResult = true; *hasResultType = true; break; + case SpvOpFUnordGreaterThan: *hasResult = true; *hasResultType = true; break; + case SpvOpFOrdLessThanEqual: *hasResult = true; *hasResultType = true; break; + case SpvOpFUnordLessThanEqual: *hasResult = true; *hasResultType = true; break; + case SpvOpFOrdGreaterThanEqual: *hasResult = true; *hasResultType = true; break; + case SpvOpFUnordGreaterThanEqual: *hasResult = true; *hasResultType = true; break; + case SpvOpShiftRightLogical: *hasResult = true; *hasResultType = true; break; + case SpvOpShiftRightArithmetic: *hasResult = true; *hasResultType = true; break; + case SpvOpShiftLeftLogical: *hasResult = true; *hasResultType = true; break; + case SpvOpBitwiseOr: *hasResult = true; *hasResultType = true; break; + case SpvOpBitwiseXor: *hasResult = true; *hasResultType = true; break; + case SpvOpBitwiseAnd: *hasResult = true; *hasResultType = true; break; + case SpvOpNot: *hasResult = true; *hasResultType = true; break; + case SpvOpBitFieldInsert: *hasResult = true; *hasResultType = true; break; + case SpvOpBitFieldSExtract: *hasResult = true; *hasResultType = true; break; + case SpvOpBitFieldUExtract: *hasResult = true; *hasResultType = true; break; + case SpvOpBitReverse: *hasResult = true; *hasResultType = true; break; + case SpvOpBitCount: *hasResult = true; *hasResultType = true; break; + case SpvOpDPdx: *hasResult = true; *hasResultType = true; break; + case SpvOpDPdy: *hasResult = true; *hasResultType = true; break; + case SpvOpFwidth: *hasResult = true; *hasResultType = true; break; + case SpvOpDPdxFine: *hasResult = true; *hasResultType = true; break; + case SpvOpDPdyFine: *hasResult = true; *hasResultType = true; break; + case SpvOpFwidthFine: *hasResult = true; *hasResultType = true; break; + case SpvOpDPdxCoarse: *hasResult = true; *hasResultType = true; break; + case SpvOpDPdyCoarse: *hasResult = true; *hasResultType = true; break; + case SpvOpFwidthCoarse: *hasResult = true; *hasResultType = true; break; + case SpvOpEmitVertex: *hasResult = false; *hasResultType = false; break; + case SpvOpEndPrimitive: *hasResult = false; *hasResultType = false; break; + case SpvOpEmitStreamVertex: *hasResult = false; *hasResultType = false; break; + case SpvOpEndStreamPrimitive: *hasResult = false; *hasResultType = false; break; + case SpvOpControlBarrier: *hasResult = false; *hasResultType = false; break; + case SpvOpMemoryBarrier: *hasResult = false; *hasResultType = false; break; + case SpvOpAtomicLoad: *hasResult = true; *hasResultType = true; break; + case SpvOpAtomicStore: *hasResult = false; *hasResultType = false; break; + case SpvOpAtomicExchange: *hasResult = true; *hasResultType = true; break; + case SpvOpAtomicCompareExchange: *hasResult = true; *hasResultType = true; break; + case SpvOpAtomicCompareExchangeWeak: *hasResult = true; *hasResultType = true; break; + case SpvOpAtomicIIncrement: *hasResult = true; *hasResultType = true; break; + case SpvOpAtomicIDecrement: *hasResult = true; *hasResultType = true; break; + case SpvOpAtomicIAdd: *hasResult = true; *hasResultType = true; break; + case SpvOpAtomicISub: *hasResult = true; *hasResultType = true; break; + case SpvOpAtomicSMin: *hasResult = true; *hasResultType = true; break; + case SpvOpAtomicUMin: *hasResult = true; *hasResultType = true; break; + case SpvOpAtomicSMax: *hasResult = true; *hasResultType = true; break; + case SpvOpAtomicUMax: *hasResult = true; *hasResultType = true; break; + case SpvOpAtomicAnd: *hasResult = true; *hasResultType = true; break; + case SpvOpAtomicOr: *hasResult = true; *hasResultType = true; break; + case SpvOpAtomicXor: *hasResult = true; *hasResultType = true; break; + case SpvOpPhi: *hasResult = true; *hasResultType = true; break; + case SpvOpLoopMerge: *hasResult = false; *hasResultType = false; break; + case SpvOpSelectionMerge: *hasResult = false; *hasResultType = false; break; + case SpvOpLabel: *hasResult = true; *hasResultType = false; break; + case SpvOpBranch: *hasResult = false; *hasResultType = false; break; + case SpvOpBranchConditional: *hasResult = false; *hasResultType = false; break; + case SpvOpSwitch: *hasResult = false; *hasResultType = false; break; + case SpvOpKill: *hasResult = false; *hasResultType = false; break; + case SpvOpReturn: *hasResult = false; *hasResultType = false; break; + case SpvOpReturnValue: *hasResult = false; *hasResultType = false; break; + case SpvOpUnreachable: *hasResult = false; *hasResultType = false; break; + case SpvOpLifetimeStart: *hasResult = false; *hasResultType = false; break; + case SpvOpLifetimeStop: *hasResult = false; *hasResultType = false; break; + case SpvOpGroupAsyncCopy: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupWaitEvents: *hasResult = false; *hasResultType = false; break; + case SpvOpGroupAll: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupAny: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupBroadcast: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupIAdd: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupFAdd: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupFMin: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupUMin: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupSMin: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupFMax: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupUMax: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupSMax: *hasResult = true; *hasResultType = true; break; + case SpvOpReadPipe: *hasResult = true; *hasResultType = true; break; + case SpvOpWritePipe: *hasResult = true; *hasResultType = true; break; + case SpvOpReservedReadPipe: *hasResult = true; *hasResultType = true; break; + case SpvOpReservedWritePipe: *hasResult = true; *hasResultType = true; break; + case SpvOpReserveReadPipePackets: *hasResult = true; *hasResultType = true; break; + case SpvOpReserveWritePipePackets: *hasResult = true; *hasResultType = true; break; + case SpvOpCommitReadPipe: *hasResult = false; *hasResultType = false; break; + case SpvOpCommitWritePipe: *hasResult = false; *hasResultType = false; break; + case SpvOpIsValidReserveId: *hasResult = true; *hasResultType = true; break; + case SpvOpGetNumPipePackets: *hasResult = true; *hasResultType = true; break; + case SpvOpGetMaxPipePackets: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupReserveReadPipePackets: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupReserveWritePipePackets: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupCommitReadPipe: *hasResult = false; *hasResultType = false; break; + case SpvOpGroupCommitWritePipe: *hasResult = false; *hasResultType = false; break; + case SpvOpEnqueueMarker: *hasResult = true; *hasResultType = true; break; + case SpvOpEnqueueKernel: *hasResult = true; *hasResultType = true; break; + case SpvOpGetKernelNDrangeSubGroupCount: *hasResult = true; *hasResultType = true; break; + case SpvOpGetKernelNDrangeMaxSubGroupSize: *hasResult = true; *hasResultType = true; break; + case SpvOpGetKernelWorkGroupSize: *hasResult = true; *hasResultType = true; break; + case SpvOpGetKernelPreferredWorkGroupSizeMultiple: *hasResult = true; *hasResultType = true; break; + case SpvOpRetainEvent: *hasResult = false; *hasResultType = false; break; + case SpvOpReleaseEvent: *hasResult = false; *hasResultType = false; break; + case SpvOpCreateUserEvent: *hasResult = true; *hasResultType = true; break; + case SpvOpIsValidEvent: *hasResult = true; *hasResultType = true; break; + case SpvOpSetUserEventStatus: *hasResult = false; *hasResultType = false; break; + case SpvOpCaptureEventProfilingInfo: *hasResult = false; *hasResultType = false; break; + case SpvOpGetDefaultQueue: *hasResult = true; *hasResultType = true; break; + case SpvOpBuildNDRange: *hasResult = true; *hasResultType = true; break; + case SpvOpImageSparseSampleImplicitLod: *hasResult = true; *hasResultType = true; break; + case SpvOpImageSparseSampleExplicitLod: *hasResult = true; *hasResultType = true; break; + case SpvOpImageSparseSampleDrefImplicitLod: *hasResult = true; *hasResultType = true; break; + case SpvOpImageSparseSampleDrefExplicitLod: *hasResult = true; *hasResultType = true; break; + case SpvOpImageSparseSampleProjImplicitLod: *hasResult = true; *hasResultType = true; break; + case SpvOpImageSparseSampleProjExplicitLod: *hasResult = true; *hasResultType = true; break; + case SpvOpImageSparseSampleProjDrefImplicitLod: *hasResult = true; *hasResultType = true; break; + case SpvOpImageSparseSampleProjDrefExplicitLod: *hasResult = true; *hasResultType = true; break; + case SpvOpImageSparseFetch: *hasResult = true; *hasResultType = true; break; + case SpvOpImageSparseGather: *hasResult = true; *hasResultType = true; break; + case SpvOpImageSparseDrefGather: *hasResult = true; *hasResultType = true; break; + case SpvOpImageSparseTexelsResident: *hasResult = true; *hasResultType = true; break; + case SpvOpNoLine: *hasResult = false; *hasResultType = false; break; + case SpvOpAtomicFlagTestAndSet: *hasResult = true; *hasResultType = true; break; + case SpvOpAtomicFlagClear: *hasResult = false; *hasResultType = false; break; + case SpvOpImageSparseRead: *hasResult = true; *hasResultType = true; break; + case SpvOpSizeOf: *hasResult = true; *hasResultType = true; break; + case SpvOpTypePipeStorage: *hasResult = true; *hasResultType = false; break; + case SpvOpConstantPipeStorage: *hasResult = true; *hasResultType = true; break; + case SpvOpCreatePipeFromPipeStorage: *hasResult = true; *hasResultType = true; break; + case SpvOpGetKernelLocalSizeForSubgroupCount: *hasResult = true; *hasResultType = true; break; + case SpvOpGetKernelMaxNumSubgroups: *hasResult = true; *hasResultType = true; break; + case SpvOpTypeNamedBarrier: *hasResult = true; *hasResultType = false; break; + case SpvOpNamedBarrierInitialize: *hasResult = true; *hasResultType = true; break; + case SpvOpMemoryNamedBarrier: *hasResult = false; *hasResultType = false; break; + case SpvOpModuleProcessed: *hasResult = false; *hasResultType = false; break; + case SpvOpExecutionModeId: *hasResult = false; *hasResultType = false; break; + case SpvOpDecorateId: *hasResult = false; *hasResultType = false; break; + case SpvOpGroupNonUniformElect: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformAll: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformAny: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformAllEqual: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformBroadcast: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformBroadcastFirst: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformBallot: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformInverseBallot: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformBallotBitExtract: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformBallotBitCount: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformBallotFindLSB: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformBallotFindMSB: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformShuffle: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformShuffleXor: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformShuffleUp: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformShuffleDown: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformIAdd: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformFAdd: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformIMul: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformFMul: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformSMin: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformUMin: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformFMin: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformSMax: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformUMax: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformFMax: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformBitwiseAnd: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformBitwiseOr: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformBitwiseXor: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformLogicalAnd: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformLogicalOr: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformLogicalXor: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformQuadBroadcast: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformQuadSwap: *hasResult = true; *hasResultType = true; break; + case SpvOpCopyLogical: *hasResult = true; *hasResultType = true; break; + case SpvOpPtrEqual: *hasResult = true; *hasResultType = true; break; + case SpvOpPtrNotEqual: *hasResult = true; *hasResultType = true; break; + case SpvOpPtrDiff: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupBallotKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupFirstInvocationKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpTerminateInvocation: *hasResult = false; *hasResultType = false; break; + case SpvOpSubgroupAllKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAnyKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAllEqualKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupReadInvocationKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpTypeRayQueryProvisionalKHR: *hasResult = true; *hasResultType = false; break; + case SpvOpRayQueryInitializeKHR: *hasResult = false; *hasResultType = false; break; + case SpvOpRayQueryTerminateKHR: *hasResult = false; *hasResultType = false; break; + case SpvOpRayQueryGenerateIntersectionKHR: *hasResult = false; *hasResultType = false; break; + case SpvOpRayQueryConfirmIntersectionKHR: *hasResult = false; *hasResultType = false; break; + case SpvOpRayQueryProceedKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpRayQueryGetIntersectionTypeKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupIAddNonUniformAMD: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupFAddNonUniformAMD: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupFMinNonUniformAMD: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupUMinNonUniformAMD: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupSMinNonUniformAMD: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupFMaxNonUniformAMD: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupUMaxNonUniformAMD: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupSMaxNonUniformAMD: *hasResult = true; *hasResultType = true; break; + case SpvOpFragmentMaskFetchAMD: *hasResult = true; *hasResultType = true; break; + case SpvOpFragmentFetchAMD: *hasResult = true; *hasResultType = true; break; + case SpvOpReadClockKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpImageSampleFootprintNV: *hasResult = true; *hasResultType = true; break; + case SpvOpGroupNonUniformPartitionNV: *hasResult = true; *hasResultType = true; break; + case SpvOpWritePackedPrimitiveIndices4x8NV: *hasResult = false; *hasResultType = false; break; + case SpvOpReportIntersectionNV: *hasResult = true; *hasResultType = true; break; + case SpvOpIgnoreIntersectionNV: *hasResult = false; *hasResultType = false; break; + case SpvOpTerminateRayNV: *hasResult = false; *hasResultType = false; break; + case SpvOpTraceNV: *hasResult = false; *hasResultType = false; break; + case SpvOpTypeAccelerationStructureNV: *hasResult = true; *hasResultType = false; break; + case SpvOpExecuteCallableNV: *hasResult = false; *hasResultType = false; break; + case SpvOpTypeCooperativeMatrixNV: *hasResult = true; *hasResultType = false; break; + case SpvOpCooperativeMatrixLoadNV: *hasResult = true; *hasResultType = true; break; + case SpvOpCooperativeMatrixStoreNV: *hasResult = false; *hasResultType = false; break; + case SpvOpCooperativeMatrixMulAddNV: *hasResult = true; *hasResultType = true; break; + case SpvOpCooperativeMatrixLengthNV: *hasResult = true; *hasResultType = true; break; + case SpvOpBeginInvocationInterlockEXT: *hasResult = false; *hasResultType = false; break; + case SpvOpEndInvocationInterlockEXT: *hasResult = false; *hasResultType = false; break; + case SpvOpDemoteToHelperInvocationEXT: *hasResult = false; *hasResultType = false; break; + case SpvOpIsHelperInvocationEXT: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupShuffleINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupShuffleDownINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupShuffleUpINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupShuffleXorINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupBlockReadINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupBlockWriteINTEL: *hasResult = false; *hasResultType = false; break; + case SpvOpSubgroupImageBlockReadINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupImageBlockWriteINTEL: *hasResult = false; *hasResultType = false; break; + case SpvOpSubgroupImageMediaBlockReadINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupImageMediaBlockWriteINTEL: *hasResult = false; *hasResultType = false; break; + case SpvOpUCountLeadingZerosINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpUCountTrailingZerosINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpAbsISubINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpAbsUSubINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpIAddSatINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpUAddSatINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpIAverageINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpUAverageINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpIAverageRoundedINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpUAverageRoundedINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpISubSatINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpUSubSatINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpIMul32x16INTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpUMul32x16INTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpFunctionPointerINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpFunctionPointerCallINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpDecorateString: *hasResult = false; *hasResultType = false; break; + case SpvOpMemberDecorateString: *hasResult = false; *hasResultType = false; break; + case SpvOpVmeImageINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpTypeVmeImageINTEL: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeAvcImePayloadINTEL: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeAvcRefPayloadINTEL: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeAvcSicPayloadINTEL: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeAvcMcePayloadINTEL: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeAvcMceResultINTEL: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeAvcImeResultINTEL: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeAvcImeResultSingleReferenceStreamoutINTEL: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeAvcImeResultDualReferenceStreamoutINTEL: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeAvcImeSingleReferenceStreaminINTEL: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeAvcImeDualReferenceStreaminINTEL: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeAvcRefResultINTEL: *hasResult = true; *hasResultType = false; break; + case SpvOpTypeAvcSicResultINTEL: *hasResult = true; *hasResultType = false; break; + case SpvOpSubgroupAvcMceGetDefaultInterBaseMultiReferencePenaltyINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceSetInterBaseMultiReferencePenaltyINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceGetDefaultInterShapePenaltyINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceSetInterShapePenaltyINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceGetDefaultInterDirectionPenaltyINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceSetInterDirectionPenaltyINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceGetDefaultIntraLumaShapePenaltyINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceGetDefaultInterMotionVectorCostTableINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceGetDefaultHighPenaltyCostTableINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceGetDefaultMediumPenaltyCostTableINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceGetDefaultLowPenaltyCostTableINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceSetMotionVectorCostFunctionINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceGetDefaultIntraLumaModePenaltyINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceGetDefaultNonDcLumaIntraPenaltyINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceGetDefaultIntraChromaModeBasePenaltyINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceSetAcOnlyHaarINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceSetSourceInterlacedFieldPolarityINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceSetSingleReferenceInterlacedFieldPolarityINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceSetDualReferenceInterlacedFieldPolaritiesINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceConvertToImePayloadINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceConvertToImeResultINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceConvertToRefPayloadINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceConvertToRefResultINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceConvertToSicPayloadINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceConvertToSicResultINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceGetMotionVectorsINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceGetInterDistortionsINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceGetBestInterDistortionsINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceGetInterMajorShapeINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceGetInterMinorShapeINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceGetInterDirectionsINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceGetInterMotionVectorCountINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceGetInterReferenceIdsINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcMceGetInterReferenceInterlacedFieldPolaritiesINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeInitializeINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeSetSingleReferenceINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeSetDualReferenceINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeRefWindowSizeINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeAdjustRefOffsetINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeConvertToMcePayloadINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeSetMaxMotionVectorCountINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeSetUnidirectionalMixDisableINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeSetEarlySearchTerminationThresholdINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeSetWeightedSadINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeEvaluateWithSingleReferenceINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeEvaluateWithDualReferenceINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeEvaluateWithSingleReferenceStreaminINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeEvaluateWithDualReferenceStreaminINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeEvaluateWithSingleReferenceStreamoutINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeEvaluateWithDualReferenceStreamoutINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeEvaluateWithSingleReferenceStreaminoutINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeEvaluateWithDualReferenceStreaminoutINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeConvertToMceResultINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeGetSingleReferenceStreaminINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeGetDualReferenceStreaminINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeStripSingleReferenceStreamoutINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeStripDualReferenceStreamoutINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeMotionVectorsINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeDistortionsINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeReferenceIdsINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeMotionVectorsINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeDistortionsINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeReferenceIdsINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeGetBorderReachedINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeGetTruncatedSearchIndicationINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeGetUnidirectionalEarlySearchTerminationINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeGetWeightingPatternMinimumMotionVectorINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcImeGetWeightingPatternMinimumDistortionINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcFmeInitializeINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcBmeInitializeINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcRefConvertToMcePayloadINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcRefSetBidirectionalMixDisableINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcRefSetBilinearFilterEnableINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcRefEvaluateWithSingleReferenceINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcRefEvaluateWithDualReferenceINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcRefEvaluateWithMultiReferenceINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcRefEvaluateWithMultiReferenceInterlacedINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcRefConvertToMceResultINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcSicInitializeINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcSicConfigureSkcINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcSicConfigureIpeLumaINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcSicConfigureIpeLumaChromaINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcSicGetMotionVectorMaskINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcSicConvertToMcePayloadINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcSicSetIntraLumaShapePenaltyINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcSicSetIntraLumaModeCostFunctionINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcSicSetIntraChromaModeCostFunctionINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcSicSetBilinearFilterEnableINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcSicSetSkcForwardTransformEnableINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcSicSetBlockBasedRawSkipSadINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcSicEvaluateIpeINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcSicEvaluateWithSingleReferenceINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcSicEvaluateWithDualReferenceINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcSicEvaluateWithMultiReferenceINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcSicEvaluateWithMultiReferenceInterlacedINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcSicConvertToMceResultINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcSicGetIpeLumaShapeINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcSicGetBestIpeLumaDistortionINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcSicGetBestIpeChromaDistortionINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcSicGetPackedIpeLumaModesINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcSicGetIpeChromaModeINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcSicGetPackedSkcLumaCountThresholdINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcSicGetPackedSkcLumaSumThresholdINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpSubgroupAvcSicGetInterRawSadsINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpLoopControlINTEL: *hasResult = false; *hasResultType = false; break; + case SpvOpReadPipeBlockingINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpWritePipeBlockingINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpFPGARegINTEL: *hasResult = true; *hasResultType = true; break; + case SpvOpRayQueryGetRayTMinKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpRayQueryGetRayFlagsKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpRayQueryGetIntersectionTKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpRayQueryGetIntersectionInstanceCustomIndexKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpRayQueryGetIntersectionInstanceIdKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpRayQueryGetIntersectionGeometryIndexKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpRayQueryGetIntersectionPrimitiveIndexKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpRayQueryGetIntersectionBarycentricsKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpRayQueryGetIntersectionFrontFaceKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpRayQueryGetIntersectionCandidateAABBOpaqueKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpRayQueryGetIntersectionObjectRayDirectionKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpRayQueryGetIntersectionObjectRayOriginKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpRayQueryGetWorldRayDirectionKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpRayQueryGetWorldRayOriginKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpRayQueryGetIntersectionObjectToWorldKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpRayQueryGetIntersectionWorldToObjectKHR: *hasResult = true; *hasResultType = true; break; + case SpvOpAtomicFAddEXT: *hasResult = true; *hasResultType = true; break; + } +} +#endif /* SPV_ENABLE_UTILITY_CODE */ + +#endif + From a02dd3bf052af7effa4a83423c64b6a90deaf7a9 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 29 Jul 2020 14:31:54 +0200 Subject: [PATCH 280/316] Renderer: Add ShaderRecursiveVisitor --- .../Renderer/ShaderRecursiveVisitor.hpp | 42 +++++++++ .../Renderer/ShaderRecursiveVisitor.inl | 12 +++ include/Nazara/Renderer/ShaderValidator.hpp | 6 +- .../Renderer/ShaderRecursiveVisitor.cpp | 93 +++++++++++++++++++ src/Nazara/Renderer/ShaderValidator.cpp | 36 +++---- 5 files changed, 169 insertions(+), 20 deletions(-) create mode 100644 include/Nazara/Renderer/ShaderRecursiveVisitor.hpp create mode 100644 include/Nazara/Renderer/ShaderRecursiveVisitor.inl create mode 100644 src/Nazara/Renderer/ShaderRecursiveVisitor.cpp diff --git a/include/Nazara/Renderer/ShaderRecursiveVisitor.hpp b/include/Nazara/Renderer/ShaderRecursiveVisitor.hpp new file mode 100644 index 000000000..0e1087a58 --- /dev/null +++ b/include/Nazara/Renderer/ShaderRecursiveVisitor.hpp @@ -0,0 +1,42 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_SHADER_RECURSIVE_VISITOR_HPP +#define NAZARA_SHADER_RECURSIVE_VISITOR_HPP + +#include +#include +#include + +namespace Nz +{ + class NAZARA_RENDERER_API ShaderRecursiveVisitor : public ShaderVisitor + { + public: + ShaderRecursiveVisitor() = default; + ~ShaderRecursiveVisitor() = default; + + using ShaderVisitor::Visit; + + void Visit(const ShaderNodes::AccessMember& node) override; + void Visit(const ShaderNodes::AssignOp& node) override; + void Visit(const ShaderNodes::BinaryOp& node) override; + void Visit(const ShaderNodes::Branch& node) override; + void Visit(const ShaderNodes::Cast& node) override; + void Visit(const ShaderNodes::Constant& node) override; + void Visit(const ShaderNodes::DeclareVariable& node) override; + void Visit(const ShaderNodes::ExpressionStatement& node) override; + void Visit(const ShaderNodes::Identifier& node) override; + void Visit(const ShaderNodes::IntrinsicCall& node) override; + void Visit(const ShaderNodes::Sample2D& node) override; + void Visit(const ShaderNodes::StatementBlock& node) override; + void Visit(const ShaderNodes::SwizzleOp& node) override; + }; +} + +#include + +#endif diff --git a/include/Nazara/Renderer/ShaderRecursiveVisitor.inl b/include/Nazara/Renderer/ShaderRecursiveVisitor.inl new file mode 100644 index 000000000..b107f06e7 --- /dev/null +++ b/include/Nazara/Renderer/ShaderRecursiveVisitor.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ +} + +#include diff --git a/include/Nazara/Renderer/ShaderValidator.hpp b/include/Nazara/Renderer/ShaderValidator.hpp index 09015b073..237ecaa73 100644 --- a/include/Nazara/Renderer/ShaderValidator.hpp +++ b/include/Nazara/Renderer/ShaderValidator.hpp @@ -12,11 +12,11 @@ #include #include #include -#include +#include namespace Nz { - class NAZARA_RENDERER_API ShaderValidator : public ShaderVisitor + class NAZARA_RENDERER_API ShaderValidator : public ShaderRecursiveVisitor { public: inline ShaderValidator(const ShaderAst& shader); @@ -32,7 +32,7 @@ namespace Nz void TypeMustMatch(const ShaderNodes::ExpressionPtr& left, const ShaderNodes::ExpressionPtr& right); void TypeMustMatch(const ShaderExpressionType& left, const ShaderExpressionType& right); - using ShaderVisitor::Visit; + using ShaderRecursiveVisitor::Visit; void Visit(const ShaderNodes::AccessMember& node) override; void Visit(const ShaderNodes::AssignOp& node) override; void Visit(const ShaderNodes::BinaryOp& node) override; diff --git a/src/Nazara/Renderer/ShaderRecursiveVisitor.cpp b/src/Nazara/Renderer/ShaderRecursiveVisitor.cpp new file mode 100644 index 000000000..2116da21c --- /dev/null +++ b/src/Nazara/Renderer/ShaderRecursiveVisitor.cpp @@ -0,0 +1,93 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + void ShaderRecursiveVisitor::Visit(const ShaderNodes::AccessMember& node) + { + Visit(node.structExpr); + } + + void ShaderRecursiveVisitor::Visit(const ShaderNodes::AssignOp& node) + { + Visit(node.left); + Visit(node.right); + } + + void ShaderRecursiveVisitor::Visit(const ShaderNodes::BinaryOp& node) + { + Visit(node.left); + Visit(node.right); + } + + void ShaderRecursiveVisitor::Visit(const ShaderNodes::Branch& node) + { + for (auto& cond : node.condStatements) + { + Visit(cond.condition); + Visit(cond.statement); + } + + if (node.elseStatement) + Visit(node.elseStatement); + } + + void ShaderRecursiveVisitor::Visit(const ShaderNodes::Cast& node) + { + for (auto& expr : node.expressions) + { + if (!expr) + break; + + Visit(expr); + } + } + + void ShaderRecursiveVisitor::Visit(const ShaderNodes::Constant& /*node*/) + { + /* Nothing to do */ + } + + void ShaderRecursiveVisitor::Visit(const ShaderNodes::DeclareVariable& node) + { + if (node.expression) + Visit(node.expression); + } + + void ShaderRecursiveVisitor::Visit(const ShaderNodes::ExpressionStatement& node) + { + Visit(node.expression); + } + + void ShaderRecursiveVisitor::Visit(const ShaderNodes::Identifier& /*node*/) + { + /* Nothing to do */ + } + + void ShaderRecursiveVisitor::Visit(const ShaderNodes::IntrinsicCall& node) + { + for (auto& param : node.parameters) + Visit(param); + } + + void ShaderRecursiveVisitor::Visit(const ShaderNodes::Sample2D& node) + { + Visit(node.sampler); + Visit(node.coordinates); + } + + void ShaderRecursiveVisitor::Visit(const ShaderNodes::StatementBlock& node) + { + for (auto& statement : node.statements) + Visit(statement); + } + + void ShaderRecursiveVisitor::Visit(const ShaderNodes::SwizzleOp& node) + { + Visit(node.expression); + } +} diff --git a/src/Nazara/Renderer/ShaderValidator.cpp b/src/Nazara/Renderer/ShaderValidator.cpp index c181ecd62..01f038217 100644 --- a/src/Nazara/Renderer/ShaderValidator.cpp +++ b/src/Nazara/Renderer/ShaderValidator.cpp @@ -114,8 +114,7 @@ namespace Nz if (node.left->GetExpressionCategory() != ShaderNodes::ExpressionCategory::LValue) throw AstError { "Assignation is only possible with a l-value" }; - Visit(node.left); - Visit(node.right); + ShaderRecursiveVisitor::Visit(node); } void ShaderValidator::Visit(const ShaderNodes::BinaryOp& node) @@ -187,17 +186,18 @@ namespace Nz } } - Visit(node.left); - Visit(node.right); + ShaderRecursiveVisitor::Visit(node); } void ShaderValidator::Visit(const ShaderNodes::Branch& node) { for (const auto& condStatement : node.condStatements) { - Visit(MandatoryNode(condStatement.condition)); - Visit(MandatoryNode(condStatement.statement)); + MandatoryNode(condStatement.condition); + MandatoryNode(condStatement.statement); } + + ShaderRecursiveVisitor::Visit(node); } void ShaderValidator::Visit(const ShaderNodes::Cast& node) @@ -214,11 +214,12 @@ namespace Nz throw AstError{ "incompatible type" }; componentCount += node.GetComponentCount(std::get(exprType)); - Visit(exprPtr); } if (componentCount != requiredComponents) throw AstError{ "Component count doesn't match required component count" }; + + ShaderRecursiveVisitor::Visit(node); } void ShaderValidator::Visit(const ShaderNodes::Constant& /*node*/) @@ -229,17 +230,18 @@ namespace Nz { assert(m_context); - if (node.expression) - Visit(node.expression); - auto& local = m_context->declaredLocals.emplace_back(); local.name = node.variable->name; local.type = node.variable->type; + + ShaderRecursiveVisitor::Visit(node); } void ShaderValidator::Visit(const ShaderNodes::ExpressionStatement& node) { - Visit(MandatoryNode(node.expression)); + MandatoryNode(node.expression); + + ShaderRecursiveVisitor::Visit(node); } void ShaderValidator::Visit(const ShaderNodes::Identifier& node) @@ -377,8 +379,7 @@ namespace Nz break; } - for (auto& param : node.parameters) - Visit(param); + ShaderRecursiveVisitor::Visit(node); } void ShaderValidator::Visit(const ShaderNodes::Sample2D& node) @@ -389,8 +390,7 @@ namespace Nz if (MandatoryExpr(node.coordinates)->GetExpressionType() != ShaderExpressionType{ ShaderNodes::BasicType::Float2 }) throw AstError{ "Coordinates must be a Float2" }; - Visit(node.sampler); - Visit(node.coordinates); + ShaderRecursiveVisitor::Visit(node); } void ShaderValidator::Visit(const ShaderNodes::StatementBlock& node) @@ -400,11 +400,13 @@ namespace Nz m_context->blockLocalIndex.push_back(m_context->declaredLocals.size()); for (const auto& statement : node.statements) - Visit(MandatoryNode(statement)); + MandatoryNode(statement); assert(m_context->declaredLocals.size() >= m_context->blockLocalIndex.back()); m_context->declaredLocals.resize(m_context->blockLocalIndex.back()); m_context->blockLocalIndex.pop_back(); + + ShaderRecursiveVisitor::Visit(node); } void ShaderValidator::Visit(const ShaderNodes::SwizzleOp& node) @@ -428,7 +430,7 @@ namespace Nz throw AstError{ "Cannot swizzle this type" }; } - Visit(node.expression); + ShaderRecursiveVisitor::Visit(node); } bool ValidateShader(const ShaderAst& shader, std::string* error) From 22714327485f83d3042fc1434bf658f3a7f56c47 Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 29 Jul 2020 14:39:34 +0200 Subject: [PATCH 281/316] Renderer/ShaderValidator: Use ShaderVarVisitor instead of switch --- include/Nazara/Renderer/ShaderValidator.hpp | 11 +- src/Nazara/Renderer/ShaderValidator.cpp | 163 +++++++++----------- 2 files changed, 85 insertions(+), 89 deletions(-) diff --git a/include/Nazara/Renderer/ShaderValidator.hpp b/include/Nazara/Renderer/ShaderValidator.hpp index 237ecaa73..edf54370f 100644 --- a/include/Nazara/Renderer/ShaderValidator.hpp +++ b/include/Nazara/Renderer/ShaderValidator.hpp @@ -13,10 +13,11 @@ #include #include #include +#include namespace Nz { - class NAZARA_RENDERER_API ShaderValidator : public ShaderRecursiveVisitor + class NAZARA_RENDERER_API ShaderValidator : public ShaderRecursiveVisitor, public ShaderVarVisitor { public: inline ShaderValidator(const ShaderAst& shader); @@ -47,6 +48,14 @@ namespace Nz void Visit(const ShaderNodes::StatementBlock& node) override; void Visit(const ShaderNodes::SwizzleOp& node) override; + using ShaderVarVisitor::Visit; + void Visit(const ShaderNodes::BuiltinVariable& var) override; + void Visit(const ShaderNodes::InputVariable& var) override; + void Visit(const ShaderNodes::LocalVariable& var) override; + void Visit(const ShaderNodes::OutputVariable& var) override; + void Visit(const ShaderNodes::ParameterVariable& var) override; + void Visit(const ShaderNodes::UniformVariable& var) override; + struct Context; const ShaderAst& m_shader; diff --git a/src/Nazara/Renderer/ShaderValidator.cpp b/src/Nazara/Renderer/ShaderValidator.cpp index 01f038217..351a46839 100644 --- a/src/Nazara/Renderer/ShaderValidator.cpp +++ b/src/Nazara/Renderer/ShaderValidator.cpp @@ -251,94 +251,7 @@ namespace Nz if (!node.var) throw AstError{ "Invalid variable" }; - //< FIXME: Use variable visitor - switch (node.var->GetType()) - { - case ShaderNodes::VariableType::BuiltinVariable: - break; - - case ShaderNodes::VariableType::InputVariable: - { - auto& namedVar = static_cast(*node.var); - - for (std::size_t i = 0; i < m_shader.GetInputCount(); ++i) - { - const auto& input = m_shader.GetInput(i); - if (input.name == namedVar.name) - { - TypeMustMatch(input.type, namedVar.type); - return; - } - } - - throw AstError{ "Input not found" }; - } - - case ShaderNodes::VariableType::LocalVariable: - { - auto& localVar = static_cast(*node.var); - const auto& vars = m_context->declaredLocals; - - auto it = std::find_if(vars.begin(), vars.end(), [&](const auto& var) { return var.name == localVar.name; }); - if (it == vars.end()) - throw AstError{ "Local variable not found in this block" }; - - TypeMustMatch(it->type, localVar.type); - break; - } - - case ShaderNodes::VariableType::OutputVariable: - { - auto& outputVar = static_cast(*node.var); - - for (std::size_t i = 0; i < m_shader.GetOutputCount(); ++i) - { - const auto& input = m_shader.GetOutput(i); - if (input.name == outputVar.name) - { - TypeMustMatch(input.type, outputVar.type); - return; - } - } - - throw AstError{ "Output not found" }; - } - - case ShaderNodes::VariableType::ParameterVariable: - { - assert(m_context->currentFunction); - - auto& parameter = static_cast(*node.var); - const auto& parameters = m_context->currentFunction->parameters; - - auto it = std::find_if(parameters.begin(), parameters.end(), [&](const auto& parameter) { return parameter.name == parameter.name; }); - if (it == parameters.end()) - throw AstError{ "Parameter not found in function" }; - - TypeMustMatch(it->type, parameter.type); - break; - } - - case ShaderNodes::VariableType::UniformVariable: - { - auto& uniformVar = static_cast(*node.var); - - for (std::size_t i = 0; i < m_shader.GetUniformCount(); ++i) - { - const auto& uniform = m_shader.GetUniform(i); - if (uniform.name == uniformVar.name) - { - TypeMustMatch(uniform.type, uniformVar.type); - return; - } - } - - throw AstError{ "Uniform not found" }; - } - - default: - break; - } + Visit(node.var); } void ShaderValidator::Visit(const ShaderNodes::IntrinsicCall& node) @@ -433,6 +346,80 @@ namespace Nz ShaderRecursiveVisitor::Visit(node); } + void ShaderValidator::Visit(const ShaderNodes::BuiltinVariable& /*var*/) + { + /* Nothing to do */ + } + + void ShaderValidator::Visit(const ShaderNodes::InputVariable& var) + { + for (std::size_t i = 0; i < m_shader.GetInputCount(); ++i) + { + const auto& input = m_shader.GetInput(i); + if (input.name == var.name) + { + TypeMustMatch(input.type, var.type); + return; + } + } + + throw AstError{ "Input not found" }; + } + + void ShaderValidator::Visit(const ShaderNodes::LocalVariable& var) + { + const auto& vars = m_context->declaredLocals; + + auto it = std::find_if(vars.begin(), vars.end(), [&](const auto& v) { return v.name == var.name; }); + if (it == vars.end()) + throw AstError{ "Local variable not found in this block" }; + + TypeMustMatch(it->type, var.type); + } + + void ShaderValidator::Visit(const ShaderNodes::OutputVariable& var) + { + for (std::size_t i = 0; i < m_shader.GetOutputCount(); ++i) + { + const auto& input = m_shader.GetOutput(i); + if (input.name == var.name) + { + TypeMustMatch(input.type, var.type); + return; + } + } + + throw AstError{ "Output not found" }; + } + + void ShaderValidator::Visit(const ShaderNodes::ParameterVariable& var) + { + assert(m_context->currentFunction); + + const auto& parameters = m_context->currentFunction->parameters; + + auto it = std::find_if(parameters.begin(), parameters.end(), [&](const auto& parameter) { return parameter.name == var.name; }); + if (it == parameters.end()) + throw AstError{ "Parameter not found in function" }; + + TypeMustMatch(it->type, var.type); + } + + void ShaderValidator::Visit(const ShaderNodes::UniformVariable& var) + { + for (std::size_t i = 0; i < m_shader.GetUniformCount(); ++i) + { + const auto& uniform = m_shader.GetUniform(i); + if (uniform.name == var.name) + { + TypeMustMatch(uniform.type, var.type); + return; + } + } + + throw AstError{ "Uniform not found" }; + } + bool ValidateShader(const ShaderAst& shader, std::string* error) { ShaderValidator validator(shader); From 10860ed5621151b96f710367ef4de852c4ec2fe0 Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 31 Jul 2020 12:36:37 +0200 Subject: [PATCH 282/316] Improve code --- include/Nazara/Renderer/SpirvWriter.inl | 2 +- src/Nazara/Renderer/SpirvWriter.cpp | 18 +++++------------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/include/Nazara/Renderer/SpirvWriter.inl b/include/Nazara/Renderer/SpirvWriter.inl index 86f578d3d..366e8ac46 100644 --- a/include/Nazara/Renderer/SpirvWriter.inl +++ b/include/Nazara/Renderer/SpirvWriter.inl @@ -49,7 +49,7 @@ namespace Nz inline unsigned int SpirvWriter::CountWord(const std::string_view& str) { - return (str.size() + 1 + 4 - 1) / 4; //< + 1 for null character + return (static_cast(str.size() + 1) + sizeof(UInt32) - 1) / sizeof(UInt32); //< + 1 for null character } } diff --git a/src/Nazara/Renderer/SpirvWriter.cpp b/src/Nazara/Renderer/SpirvWriter.cpp index 863666588..ea74e5066 100644 --- a/src/Nazara/Renderer/SpirvWriter.cpp +++ b/src/Nazara/Renderer/SpirvWriter.cpp @@ -40,10 +40,6 @@ namespace Nz AppendHeader(); - // OpImageSampleImplicitLod %23 %31 %35 - - //Append("BONJOUR PRAETONUS"); - std::vector ret = std::move(state.output); return ret; } @@ -58,17 +54,13 @@ namespace Nz std::size_t size4 = CountWord(str); for (std::size_t i = 0; i < size4; ++i) { - auto GetChar = [&](std::size_t pos) -> UInt32 - { - if (pos < str.size()) - return static_cast(str[pos]); - else - return 0; - }; - UInt32 codepoint = 0; for (std::size_t j = 0; j < 4; ++j) - codepoint |= GetChar(i * 4 + j) << (j * 8); + { + std::size_t pos = i * 4 + j; + if (pos < str.size()) + codepoint |= UInt32(str[pos]) << (j * 8); + } Append(codepoint); } From 50bd150345ddb1692acd063dae1de3f129d849be Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 2 Aug 2020 20:42:51 +0200 Subject: [PATCH 283/316] WIP --- include/Nazara/Renderer/ShaderVariables.hpp | 3 +- include/Nazara/Renderer/SpirvWriter.hpp | 43 +- include/Nazara/Renderer/SpirvWriter.inl | 56 +- src/Nazara/Renderer/SpirvWriter.cpp | 426 ++++- src/Nazara/VulkanRenderer/Vulkan.cpp | 2 +- thirdparty/include/tsl/ordered_hash.h | 1628 +++++++++++++++++++ thirdparty/include/tsl/ordered_map.h | 863 ++++++++++ thirdparty/include/tsl/ordered_set.h | 718 ++++++++ 8 files changed, 3626 insertions(+), 113 deletions(-) create mode 100644 thirdparty/include/tsl/ordered_hash.h create mode 100644 thirdparty/include/tsl/ordered_map.h create mode 100644 thirdparty/include/tsl/ordered_set.h diff --git a/include/Nazara/Renderer/ShaderVariables.hpp b/include/Nazara/Renderer/ShaderVariables.hpp index 9b52d3913..4fac1681f 100644 --- a/include/Nazara/Renderer/ShaderVariables.hpp +++ b/include/Nazara/Renderer/ShaderVariables.hpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -27,7 +28,7 @@ namespace Nz using VariablePtr = std::shared_ptr; - struct NAZARA_RENDERER_API Variable + struct NAZARA_RENDERER_API Variable : std::enable_shared_from_this { virtual ~Variable(); diff --git a/include/Nazara/Renderer/SpirvWriter.hpp b/include/Nazara/Renderer/SpirvWriter.hpp index 6cc4bb780..e95bc5a4e 100644 --- a/include/Nazara/Renderer/SpirvWriter.hpp +++ b/include/Nazara/Renderer/SpirvWriter.hpp @@ -13,13 +13,13 @@ #include #include #include -#include +#include #include #include namespace Nz { - class NAZARA_RENDERER_API SpirvWriter : public ShaderVarVisitor, public ShaderVisitor + class NAZARA_RENDERER_API SpirvWriter : public ShaderVisitor { public: struct Environment; @@ -35,48 +35,54 @@ namespace Nz struct Environment { + UInt32 spvMajorVersion = 1; + UInt32 spvMinorVersion = 0; }; private: struct Opcode; - inline void Append(const char* str); - void Append(const std::string_view& str); - void Append(const Opcode& opcode, unsigned int wordCount); - void Append(UInt32 codepoint); - void Append(std::initializer_list codepoints); - template void Append(Opcode opcode, const Args&... args); - template void Append(T value); + inline std::size_t Append(const char* str); + inline std::size_t Append(const std::string_view& str); + inline std::size_t Append(const std::string& str); + std::size_t Append(UInt32 value); + std::size_t Append(const Opcode& opcode, unsigned int wordCount); + inline std::size_t Append(std::initializer_list codepoints); + template std::size_t Append(Opcode opcode, const Args&... args); + template std::size_t Append(T value); + + UInt32 AllocateResultId(); void AppendHeader(); + void AppendTypes(); inline unsigned int CountWord(const char* str); unsigned int CountWord(const std::string_view& str); + inline unsigned int CountWord(const std::string& str); template unsigned int CountWord(const T& value); template unsigned int CountWord(const T1& value, const T2& value2, const Args&... rest); - using ShaderVarVisitor::Visit; + std::size_t GetOutputOffset() const; + + UInt32 ProcessType(ShaderExpressionType type); + using ShaderVisitor::Visit; void Visit(const ShaderNodes::ExpressionPtr& expr, bool encloseIfRequired = false); void Visit(const ShaderNodes::AccessMember& node) override; void Visit(const ShaderNodes::AssignOp& node) override; void Visit(const ShaderNodes::Branch& node) override; void Visit(const ShaderNodes::BinaryOp& node) override; - void Visit(const ShaderNodes::BuiltinVariable& var) override; void Visit(const ShaderNodes::Cast& node) override; void Visit(const ShaderNodes::Constant& node) override; void Visit(const ShaderNodes::DeclareVariable& node) override; void Visit(const ShaderNodes::ExpressionStatement& node) override; void Visit(const ShaderNodes::Identifier& node) override; - void Visit(const ShaderNodes::InputVariable& var) override; void Visit(const ShaderNodes::IntrinsicCall& node) override; - void Visit(const ShaderNodes::LocalVariable& var) override; - void Visit(const ShaderNodes::ParameterVariable& var) override; - void Visit(const ShaderNodes::OutputVariable& var) override; void Visit(const ShaderNodes::Sample2D& node) override; void Visit(const ShaderNodes::StatementBlock& node) override; void Visit(const ShaderNodes::SwizzleOp& node) override; - void Visit(const ShaderNodes::UniformVariable& var) override; + + static void MergeBlocks(std::vector& output, const std::vector& from); struct Context { @@ -84,10 +90,7 @@ namespace Nz const ShaderAst::Function* currentFunction = nullptr; }; - struct State - { - std::vector output; - }; + struct State; Context m_context; Environment m_environment; diff --git a/include/Nazara/Renderer/SpirvWriter.inl b/include/Nazara/Renderer/SpirvWriter.inl index 366e8ac46..5d0bbd328 100644 --- a/include/Nazara/Renderer/SpirvWriter.inl +++ b/include/Nazara/Renderer/SpirvWriter.inl @@ -9,25 +9,62 @@ namespace Nz { - inline void SpirvWriter::Append(const char* str) + inline std::size_t SpirvWriter::Append(const char* str) { return Append(std::string_view(str)); } - template - void SpirvWriter::Append(T value) + inline std::size_t SpirvWriter::Append(const std::string_view& str) { - assert(m_currentState); - m_currentState->output.push_back(static_cast(value)); + std::size_t offset = GetOutputOffset(); + + std::size_t size4 = CountWord(str); + for (std::size_t i = 0; i < size4; ++i) + { + UInt32 codepoint = 0; + for (std::size_t j = 0; j < 4; ++j) + { + std::size_t pos = i * 4 + j; + if (pos < str.size()) + codepoint |= UInt32(str[pos]) << (j * 8); + } + + Append(codepoint); + } + + return offset; + } + + inline std::size_t SpirvWriter::Append(const std::string& str) + { + return Append(std::string_view(str)); + } + + inline std::size_t SpirvWriter::Append(std::initializer_list codepoints) + { + std::size_t offset = GetOutputOffset(); + + for (UInt32 cp : codepoints) + Append(cp); + + return offset; } template - inline void SpirvWriter::Append(Opcode opcode, const Args&... args) + inline std::size_t SpirvWriter::Append(Opcode opcode, const Args&... args) { unsigned int wordCount = 1 + (CountWord(args) + ... + 0); - Append(opcode, wordCount); + std::size_t offset = Append(opcode, wordCount); if constexpr (sizeof...(args) > 0) (Append(args), ...); + + return offset; + } + + template + inline std::size_t SpirvWriter::Append(T value) + { + return Append(static_cast(value)); } template @@ -47,6 +84,11 @@ namespace Nz return CountWord(std::string_view(str)); } + inline unsigned int Nz::SpirvWriter::CountWord(const std::string& str) + { + return CountWord(std::string_view(str)); + } + inline unsigned int SpirvWriter::CountWord(const std::string_view& str) { return (static_cast(str.size() + 1) + sizeof(UInt32) - 1) / sizeof(UInt32); //< + 1 for null character diff --git a/src/Nazara/Renderer/SpirvWriter.cpp b/src/Nazara/Renderer/SpirvWriter.cpp index ea74e5066..24d9fcd84 100644 --- a/src/Nazara/Renderer/SpirvWriter.cpp +++ b/src/Nazara/Renderer/SpirvWriter.cpp @@ -5,19 +5,119 @@ #include #include #include +#include #include #include #include #include +#include +#include #include namespace Nz { + namespace + { + class PreVisitor : public ShaderRecursiveVisitor, public ShaderVarVisitor + { + public: + using BuiltinContainer = std::unordered_set>; + using ExtInstList = std::unordered_set; + using LocalContainer = std::unordered_set>; + using ParameterContainer = std::unordered_set< std::shared_ptr>; + + using ShaderRecursiveVisitor::Visit; + using ShaderVarVisitor::Visit; + + void Visit(const ShaderNodes::DeclareVariable& node) override + { + Visit(node.variable); + } + + void Visit(const ShaderNodes::Identifier& node) override + { + Visit(node.var); + } + + void Visit(const ShaderNodes::IntrinsicCall& node) override + { + ShaderRecursiveVisitor::Visit(node); + + switch (node.intrinsic) + { + // Require GLSL.std.450 + case ShaderNodes::IntrinsicType::CrossProduct: + extInsts.emplace("GLSL.std.450"); + break; + + // Part of SPIR-V core + case ShaderNodes::IntrinsicType::DotProduct: + break; + } + } + + void Visit(const ShaderNodes::BuiltinVariable& var) override + { + builtinVars.insert(std::static_pointer_cast(var.shared_from_this())); + } + + void Visit(const ShaderNodes::InputVariable& var) override + { + /* Handled by ShaderAst */ + } + + void Visit(const ShaderNodes::LocalVariable& var) override + { + localVars.insert(std::static_pointer_cast(var.shared_from_this())); + } + + void Visit(const ShaderNodes::OutputVariable& var) override + { + /* Handled by ShaderAst */ + } + + void Visit(const ShaderNodes::ParameterVariable& var) override + { + paramVars.insert(std::static_pointer_cast(var.shared_from_this())); + } + + void Visit(const ShaderNodes::UniformVariable& var) override + { + /* Handled by ShaderAst */ + } + + BuiltinContainer builtinVars; + ExtInstList extInsts; + LocalContainer localVars; + ParameterContainer paramVars; + }; + } + struct SpirvWriter::Opcode { SpvOp op; }; + struct SpirvWriter::State + { + std::size_t boundIndex; + std::unordered_map extensionInstructions; + std::unordered_map builtinIds; + tsl::ordered_map typeIds; + std::vector funcIds; + std::vector funcTypeIds; + std::vector inputIds; + std::vector outputIds; + std::vector uniformIds; + UInt32 nextVarIndex = 1; + + // Output + std::vector* output; + std::vector header; + std::vector info; + std::vector instructions; + }; + SpirvWriter::SpirvWriter() : m_currentState(nullptr) { @@ -38,63 +138,78 @@ namespace Nz m_currentState = nullptr; }); + PreVisitor preVisitor; + for (const auto& func : shader.GetFunctions()) + preVisitor.Visit(func.statement); + + // Register all extended instruction sets + for (const std::string& extInst : preVisitor.extInsts) + m_currentState->extensionInstructions[extInst] = AllocateResultId(); + + // Register all types + state.output = &state.instructions; + + for (const auto& func : shader.GetFunctions()) + { + ProcessType(func.returnType); + for (const auto& param : func.parameters) + ProcessType(param.type); + + m_currentState->funcTypeIds.push_back(AllocateResultId()); + } + + for (const auto& input : shader.GetInputs()) + ProcessType(input.type); + + for (const auto& output : shader.GetOutputs()) + ProcessType(output.type); + + for (const auto& uniform : shader.GetUniforms()) + ProcessType(uniform.type); + + for (const auto& local : preVisitor.localVars) + ProcessType(local->type); + + // Register result id and debug infos for global variables/functions + state.output = &state.info; + + for (const auto& input : shader.GetInputs()) + { + UInt32 resultId = AllocateResultId(); + Append(Opcode{ SpvOpName }, resultId, input.name); + + m_currentState->inputIds.push_back(resultId); + } + + for (const auto& output : shader.GetOutputs()) + { + UInt32 resultId = AllocateResultId(); + Append(Opcode{ SpvOpName }, resultId, output.name); + + m_currentState->outputIds.push_back(resultId); + } + + for (const auto& uniform : shader.GetUniforms()) + { + UInt32 resultId = AllocateResultId(); + Append(Opcode{ SpvOpName }, resultId, uniform.name); + + m_currentState->uniformIds.push_back(resultId); + } + + for (const auto& func : shader.GetFunctions()) + { + UInt32 resultId = AllocateResultId(); + Append(Opcode{ SpvOpName }, resultId, func.name); + + m_currentState->funcIds.push_back(resultId); + } + + state.output = &state.header; + AppendHeader(); - std::vector ret = std::move(state.output); - return ret; - } - - void SpirvWriter::SetEnv(Environment environment) - { - m_environment = std::move(environment); - } - - void SpirvWriter::Append(const std::string_view& str) - { - std::size_t size4 = CountWord(str); - for (std::size_t i = 0; i < size4; ++i) - { - UInt32 codepoint = 0; - for (std::size_t j = 0; j < 4; ++j) - { - std::size_t pos = i * 4 + j; - if (pos < str.size()) - codepoint |= UInt32(str[pos]) << (j * 8); - } - - Append(codepoint); - } - } - - void SpirvWriter::Append(const Opcode& opcode, unsigned int wordCount) - { - Append(UInt32(opcode.op) | UInt32(wordCount) << 16); - } - - void SpirvWriter::Append(UInt32 codepoint) - { - assert(m_currentState); - m_currentState->output.push_back(codepoint); - } - - void SpirvWriter::Append(std::initializer_list codepoints) - { - for (UInt32 cp : codepoints) - Append(cp); - } - - void SpirvWriter::AppendHeader() - { - Append(SpvMagicNumber); //< Spir-V magic number - Append(0x00010000); //< Spir-V version number (1.0 for compatibility) - Append(0); //< Generator magic number (TODO: Register generator to Khronos) - Append(1); //< Bound (ID count) - Append(0); //< Instruction schema (required to be 0 for now) - Append(Opcode{ SpvOpCapability }, SpvCapabilityShader); - Append(Opcode{ SpvOpExtInstImport }, 1, "GLSL.std.450"); - Append(Opcode{ SpvOpMemoryModel }, SpvAddressingModelLogical, SpvMemoryModelGLSL450); - - assert(m_context.shader); + /*assert(m_context.shader); switch (m_context.shader->GetStage()) { case ShaderStageType::Fragment: @@ -104,67 +219,210 @@ namespace Nz default: break; + }*/ + + state.header[state.boundIndex] = state.nextVarIndex; + + std::vector ret; + ret.reserve(state.header.size() + state.info.size() + state.instructions.size()); + + MergeBlocks(ret, state.header); + MergeBlocks(ret, state.info); + MergeBlocks(ret, state.instructions); + + return ret; + } + + void SpirvWriter::SetEnv(Environment environment) + { + m_environment = std::move(environment); + } + + std::size_t Nz::SpirvWriter::Append(UInt32 value) + { + std::size_t offset = GetOutputOffset(); + m_currentState->output->push_back(value); + + return offset; + } + + std::size_t SpirvWriter::Append(const Opcode& opcode, unsigned int wordCount) + { + return Append(UInt32(opcode.op) | UInt32(wordCount) << 16); + } + + UInt32 Nz::SpirvWriter::AllocateResultId() + { + return m_currentState->nextVarIndex++; + } + + void SpirvWriter::AppendHeader() + { + Append(SpvMagicNumber); //< Spir-V magic number + + UInt32 version = (m_environment.spvMajorVersion << 16) | m_environment.spvMinorVersion << 8; + Append(version); //< Spir-V version number (1.0 for compatibility) + Append(0); //< Generator identifier (TODO: Register generator to Khronos) + + m_currentState->boundIndex = Append(0); //< Bound (ID count), will be filled later + Append(0); //< Instruction schema (required to be 0 for now) + + Append(Opcode{ SpvOpCapability }, SpvCapabilityShader); + + for (const auto& [extInst, resultId] : m_currentState->extensionInstructions) + Append(Opcode{ SpvOpExtInstImport }, resultId, extInst); + + Append(Opcode{ SpvOpMemoryModel }, SpvAddressingModelLogical, SpvMemoryModelGLSL450); + } + + void SpirvWriter::AppendTypes() + { + for (const auto& [type, typeId] : m_currentState->typeIds.values_container()) + { + UInt32 resultId = typeId; + + // Register sub-types, if any + std::visit([&](auto&& arg) + { + using T = std::decay_t; + if constexpr (std::is_same_v) + { + // In SPIR-V, vec3 (for example) depends on float + UInt32 depResultId; + if (ShaderNodes::Node::GetComponentCount(arg) != 1) + depResultId = ProcessType(ShaderNodes::Node::GetComponentType(arg)); + + switch (arg) + { + case ShaderNodes::BasicType::Boolean: + Append(Opcode{ SpvOpTypeBool }, resultId); + break; + + case ShaderNodes::BasicType::Float1: + Append(Opcode{ SpvOpTypeFloat }, resultId); + break; + + case ShaderNodes::BasicType::Float2: + case ShaderNodes::BasicType::Float3: + case ShaderNodes::BasicType::Float4: + case ShaderNodes::BasicType::Mat4x4: + case ShaderNodes::BasicType::Sampler2D: + case ShaderNodes::BasicType::Void: + Append(Opcode{ SpvOpTypeVoid }, resultId); + break; + } + } + else if constexpr (std::is_same_v) + { + // Register struct members type + const auto& structs = m_context.shader->GetStructs(); + auto it = std::find_if(structs.begin(), structs.end(), [&](const auto& s) { return s.name == arg; }); + if (it == structs.end()) + throw std::runtime_error("struct " + arg + " has not been defined"); + + const ShaderAst::Struct& s = *it; + for (const auto& member : s.members) + ProcessType(member.type); + } + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + }, type); } } + std::size_t SpirvWriter::GetOutputOffset() const + { + assert(m_currentState); + return m_currentState->output->size(); + } + + UInt32 SpirvWriter::ProcessType(ShaderExpressionType type) + { + auto it = m_currentState->typeIds.find(type); + if (it == m_currentState->typeIds.end()) + { + // Register sub-types, if any + std::visit([&](auto&& arg) + { + using T = std::decay_t; + if constexpr (std::is_same_v) + { + // In SPIR-V, vec3 (for example) depends on float + if (ShaderNodes::Node::GetComponentCount(arg) != 1) + ProcessType(ShaderNodes::Node::GetComponentType(arg)); + } + else if constexpr (std::is_same_v) + { + // Register struct members type + const auto& structs = m_context.shader->GetStructs(); + auto it = std::find_if(structs.begin(), structs.end(), [&](const auto& s) { return s.name == arg; }); + if (it == structs.end()) + throw std::runtime_error("struct " + arg + " has not been defined"); + + const ShaderAst::Struct& s = *it; + for (const auto& member : s.members) + ProcessType(member.type); + } + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + }, type); + + it = m_currentState->typeIds.emplace(std::move(type), AllocateResultId()).first; + } + + return it->second; + } + void SpirvWriter::Visit(const ShaderNodes::ExpressionPtr& expr, bool encloseIfRequired) { } - void SpirvWriter::Visit(const ShaderNodes::AccessMember& node) + void SpirvWriter::Visit(const ShaderNodes::AccessMember& /*node*/) { } - void SpirvWriter::Visit(const ShaderNodes::AssignOp& node) + void SpirvWriter::Visit(const ShaderNodes::AssignOp& /*node*/) { } - void SpirvWriter::Visit(const ShaderNodes::Branch& node) + void SpirvWriter::Visit(const ShaderNodes::Branch& /*node*/) { } - void SpirvWriter::Visit(const ShaderNodes::BinaryOp& node) + void SpirvWriter::Visit(const ShaderNodes::BinaryOp& /*node*/) { } - void SpirvWriter::Visit(const ShaderNodes::BuiltinVariable& var) + + void SpirvWriter::Visit(const ShaderNodes::Cast& /*node*/) { } - void SpirvWriter::Visit(const ShaderNodes::Cast& node) + void SpirvWriter::Visit(const ShaderNodes::Constant& /*node*/) { } - void SpirvWriter::Visit(const ShaderNodes::Constant& node) + void SpirvWriter::Visit(const ShaderNodes::DeclareVariable& /*node*/) { } - void SpirvWriter::Visit(const ShaderNodes::DeclareVariable& node) + void SpirvWriter::Visit(const ShaderNodes::ExpressionStatement& /*node*/) { } - void SpirvWriter::Visit(const ShaderNodes::ExpressionStatement& node) + void SpirvWriter::Visit(const ShaderNodes::Identifier& /*node*/) { } - void SpirvWriter::Visit(const ShaderNodes::Identifier& node) + + void SpirvWriter::Visit(const ShaderNodes::IntrinsicCall& /*node*/) { } - void SpirvWriter::Visit(const ShaderNodes::InputVariable& var) + + void SpirvWriter::Visit(const ShaderNodes::Sample2D& /*node*/) { } - void SpirvWriter::Visit(const ShaderNodes::IntrinsicCall& node) + void SpirvWriter::Visit(const ShaderNodes::StatementBlock& /*node*/) { } - void SpirvWriter::Visit(const ShaderNodes::LocalVariable& var) + void SpirvWriter::Visit(const ShaderNodes::SwizzleOp& /*node*/) { } - void SpirvWriter::Visit(const ShaderNodes::ParameterVariable& var) - { - } - void SpirvWriter::Visit(const ShaderNodes::OutputVariable& var) - { - } - void SpirvWriter::Visit(const ShaderNodes::Sample2D& node) - { - } - void SpirvWriter::Visit(const ShaderNodes::StatementBlock& node) - { - } - void SpirvWriter::Visit(const ShaderNodes::SwizzleOp& node) - { - } - void SpirvWriter::Visit(const ShaderNodes::UniformVariable& var) + + void SpirvWriter::MergeBlocks(std::vector& output, const std::vector& from) { + std::size_t prevSize = output.size(); + output.resize(prevSize + from.size()); + std::copy(from.begin(), from.end(), output.begin() + prevSize); } } diff --git a/src/Nazara/VulkanRenderer/Vulkan.cpp b/src/Nazara/VulkanRenderer/Vulkan.cpp index 4f55223e1..e6e2d4cfd 100644 --- a/src/Nazara/VulkanRenderer/Vulkan.cpp +++ b/src/Nazara/VulkanRenderer/Vulkan.cpp @@ -57,7 +57,7 @@ namespace Nz String appName = "Another application made with Nazara Engine"; String engineName = "Nazara Engine - Vulkan Renderer"; - UInt32 appVersion = VK_MAKE_VERSION(1, 0, 0); + constexpr UInt32 appVersion = VK_MAKE_VERSION(1, 0, 0); UInt32 engineVersion = VK_MAKE_VERSION(1, 0, 0); parameters.GetStringParameter("VkAppInfo_OverrideApplicationName", &appName); diff --git a/thirdparty/include/tsl/ordered_hash.h b/thirdparty/include/tsl/ordered_hash.h new file mode 100644 index 000000000..5fbbfcb01 --- /dev/null +++ b/thirdparty/include/tsl/ordered_hash.h @@ -0,0 +1,1628 @@ +/** + * MIT License + * + * Copyright (c) 2017 Thibaut Goetghebuer-Planchon + * + * 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. + */ +#ifndef TSL_ORDERED_HASH_H +#define TSL_ORDERED_HASH_H + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +/** + * Macros for compatibility with GCC 4.8 + */ +#if (defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 9)) +# define TSL_OH_NO_CONTAINER_ERASE_CONST_ITERATOR +# define TSL_OH_NO_CONTAINER_EMPLACE_CONST_ITERATOR +#endif + +/** + * Only activate tsl_oh_assert if TSL_DEBUG is defined. + * This way we avoid the performance hit when NDEBUG is not defined with assert as tsl_oh_assert is used a lot + * (people usually compile with "-O3" and not "-O3 -DNDEBUG"). + */ +#ifdef TSL_DEBUG +# define tsl_oh_assert(expr) assert(expr) +#else +# define tsl_oh_assert(expr) (static_cast(0)) +#endif + +/** + * If exceptions are enabled, throw the exception passed in parameter, otherwise call std::terminate. + */ +#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || (defined (_MSC_VER) && defined (_CPPUNWIND))) && !defined(TSL_NO_EXCEPTIONS) +# define TSL_OH_THROW_OR_TERMINATE(ex, msg) throw ex(msg) +#else +# define TSL_OH_NO_EXCEPTIONS +# ifdef NDEBUG +# define TSL_OH_THROW_OR_TERMINATE(ex, msg) std::terminate() +# else +# include +# define TSL_OH_THROW_OR_TERMINATE(ex, msg) do { std::cerr << msg << std::endl; std::terminate(); } while(0) +# endif +#endif + + +namespace tsl { + +namespace detail_ordered_hash { + +template +struct make_void { + using type = void; +}; + +template +struct has_is_transparent: std::false_type { +}; + +template +struct has_is_transparent::type>: std::true_type { +}; + + +template +struct is_vector: std::false_type { +}; + +template +struct is_vector>::value + >::type>: std::true_type { +}; + +// Only available in C++17, we need to be compatible with C++11 +template +const T& clamp( const T& v, const T& lo, const T& hi) { + return std::min(hi, std::max(lo, v)); +} + +template +static T numeric_cast(U value, const char* error_message = "numeric_cast() failed.") { + T ret = static_cast(value); + if(static_cast(ret) != value) { + TSL_OH_THROW_OR_TERMINATE(std::runtime_error, error_message); + } + + const bool is_same_signedness = (std::is_unsigned::value && std::is_unsigned::value) || + (std::is_signed::value && std::is_signed::value); + if(!is_same_signedness && (ret < T{}) != (value < U{})) { + TSL_OH_THROW_OR_TERMINATE(std::runtime_error, error_message); + } + + return ret; +} + + +/** + * Fixed size type used to represent size_type values on serialization. Need to be big enough + * to represent a std::size_t on 32 and 64 bits platforms, and must be the same size on both platforms. + */ +using slz_size_type = std::uint64_t; +static_assert(std::numeric_limits::max() >= std::numeric_limits::max(), + "slz_size_type must be >= std::size_t"); + +template +static T deserialize_value(Deserializer& deserializer) { + // MSVC < 2017 is not conformant, circumvent the problem by removing the template keyword +#if defined (_MSC_VER) && _MSC_VER < 1910 + return deserializer.Deserializer::operator()(); +#else + return deserializer.Deserializer::template operator()(); +#endif +} + + +/** + * Each bucket entry stores an index which is the index in m_values corresponding to the bucket's value + * and a hash (which may be truncated to 32 bits depending on IndexType) corresponding to the hash of the value. + * + * The size of IndexType limits the size of the hash table to std::numeric_limits::max() - 1 elements (-1 due to + * a reserved value used to mark a bucket as empty). + */ +template +class bucket_entry { + static_assert(std::is_unsigned::value, "IndexType must be an unsigned value."); + static_assert(std::numeric_limits::max() <= std::numeric_limits::max(), + "std::numeric_limits::max() must be <= std::numeric_limits::max()."); + +public: + using index_type = IndexType; + using truncated_hash_type = typename std::conditional::max() <= + std::numeric_limits::max(), + std::uint_least32_t, + std::size_t>::type; + + bucket_entry() noexcept: m_index(EMPTY_MARKER_INDEX), m_hash(0) { + } + + bool empty() const noexcept { + return m_index == EMPTY_MARKER_INDEX; + } + + void clear() noexcept { + m_index = EMPTY_MARKER_INDEX; + } + + index_type index() const noexcept { + tsl_oh_assert(!empty()); + return m_index; + } + + index_type& index_ref() noexcept { + tsl_oh_assert(!empty()); + return m_index; + } + + void set_index(index_type index) noexcept { + tsl_oh_assert(index <= max_size()); + + m_index = index; + } + + truncated_hash_type truncated_hash() const noexcept { + tsl_oh_assert(!empty()); + return m_hash; + } + + truncated_hash_type& truncated_hash_ref() noexcept { + tsl_oh_assert(!empty()); + return m_hash; + } + + void set_hash(std::size_t hash) noexcept { + m_hash = truncate_hash(hash); + } + + template + void serialize(Serializer& serializer) const { + const slz_size_type index = m_index; + serializer(index); + + const slz_size_type hash = m_hash; + serializer(hash); + } + + template + static bucket_entry deserialize(Deserializer& deserializer) { + const slz_size_type index = deserialize_value(deserializer); + const slz_size_type hash = deserialize_value(deserializer); + + bucket_entry bentry; + bentry.m_index = numeric_cast(index, "Deserialized index is too big."); + bentry.m_hash = numeric_cast(hash, "Deserialized hash is too big."); + + return bentry; + } + + + + static truncated_hash_type truncate_hash(std::size_t hash) noexcept { + return truncated_hash_type(hash); + } + + static std::size_t max_size() noexcept { + return static_cast(std::numeric_limits::max()) - NB_RESERVED_INDEXES; + } + +private: + static const index_type EMPTY_MARKER_INDEX = std::numeric_limits::max(); + static const std::size_t NB_RESERVED_INDEXES = 1; + + index_type m_index; + truncated_hash_type m_hash; +}; + + + +/** + * Internal common class used by ordered_map and ordered_set. + * + * ValueType is what will be stored by ordered_hash (usually std::pair for map and Key for set). + * + * KeySelect should be a FunctionObject which takes a ValueType in parameter and return a reference to the key. + * + * ValueSelect should be a FunctionObject which takes a ValueType in parameter and return a reference to the value. + * ValueSelect should be void if there is no value (in set for example). + * + * ValueTypeContainer is the container which will be used to store ValueType values. + * Usually a std::deque or std::vector. + * + * + * + * The ordered_hash structure is a hash table which preserves the order of insertion of the elements. + * To do so, it stores the values in the ValueTypeContainer (m_values) using emplace_back at each + * insertion of a new element. Another structure (m_buckets of type std::vector) will + * serve as buckets array for the hash table part. Each bucket stores an index which corresponds to + * the index in m_values where the bucket's value is and the (truncated) hash of this value. An index + * is used instead of a pointer to the value to reduce the size of each bucket entry. + * + * To resolve collisions in the buckets array, the structures use robin hood linear probing with + * backward shift deletion. + */ +template +class ordered_hash: private Hash, private KeyEqual { +private: + template + using has_mapped_type = typename std::integral_constant::value>; + + static_assert(std::is_same::value, + "ValueTypeContainer::value_type != ValueType. " + "Check that the ValueTypeContainer has 'Key' as type for a set or 'std::pair' as type for a map."); + + static_assert(std::is_same::value, + "ValueTypeContainer::allocator_type != Allocator. " + "Check that the allocator for ValueTypeContainer is the same as Allocator."); + + static_assert(std::is_same::value, + "Allocator::value_type != ValueType. " + "Check that the allocator has 'Key' as type for a set or 'std::pair' as type for a map."); + + +public: + template + class ordered_iterator; + + using key_type = typename KeySelect::key_type; + using value_type = ValueType; + using size_type = std::size_t; + using difference_type = std::ptrdiff_t; + using hasher = Hash; + using key_equal = KeyEqual; + using allocator_type = Allocator; + using reference = value_type&; + using const_reference = const value_type&; + using pointer = value_type*; + using const_pointer = const value_type*; + using iterator = ordered_iterator; + using const_iterator = ordered_iterator; + using reverse_iterator = std::reverse_iterator; + using const_reverse_iterator = std::reverse_iterator; + + using values_container_type = ValueTypeContainer; + +public: + template + class ordered_iterator { + friend class ordered_hash; + + private: + using iterator = typename std::conditional::type; + + + ordered_iterator(iterator it) noexcept: m_iterator(it) { + } + + public: + using iterator_category = std::random_access_iterator_tag; + using value_type = const typename ordered_hash::value_type; + using difference_type = typename iterator::difference_type; + using reference = value_type&; + using pointer = value_type*; + + + ordered_iterator() noexcept { + } + + // Copy constructor from iterator to const_iterator. + template::type* = nullptr> + ordered_iterator(const ordered_iterator& other) noexcept: m_iterator(other.m_iterator) { + } + + ordered_iterator(const ordered_iterator& other) = default; + ordered_iterator(ordered_iterator&& other) = default; + ordered_iterator& operator=(const ordered_iterator& other) = default; + ordered_iterator& operator=(ordered_iterator&& other) = default; + + const typename ordered_hash::key_type& key() const { + return KeySelect()(*m_iterator); + } + + template::value && IsConst>::type* = nullptr> + const typename U::value_type& value() const { + return U()(*m_iterator); + } + + template::value && !IsConst>::type* = nullptr> + typename U::value_type& value() { + return U()(*m_iterator); + } + + reference operator*() const { return *m_iterator; } + pointer operator->() const { return m_iterator.operator->(); } + + ordered_iterator& operator++() { ++m_iterator; return *this; } + ordered_iterator& operator--() { --m_iterator; return *this; } + + ordered_iterator operator++(int) { ordered_iterator tmp(*this); ++(*this); return tmp; } + ordered_iterator operator--(int) { ordered_iterator tmp(*this); --(*this); return tmp; } + + reference operator[](difference_type n) const { return m_iterator[n]; } + + ordered_iterator& operator+=(difference_type n) { m_iterator += n; return *this; } + ordered_iterator& operator-=(difference_type n) { m_iterator -= n; return *this; } + + ordered_iterator operator+(difference_type n) { ordered_iterator tmp(*this); tmp += n; return tmp; } + ordered_iterator operator-(difference_type n) { ordered_iterator tmp(*this); tmp -= n; return tmp; } + + friend bool operator==(const ordered_iterator& lhs, const ordered_iterator& rhs) { + return lhs.m_iterator == rhs.m_iterator; + } + + friend bool operator!=(const ordered_iterator& lhs, const ordered_iterator& rhs) { + return lhs.m_iterator != rhs.m_iterator; + } + + friend bool operator<(const ordered_iterator& lhs, const ordered_iterator& rhs) { + return lhs.m_iterator < rhs.m_iterator; + } + + friend bool operator>(const ordered_iterator& lhs, const ordered_iterator& rhs) { + return lhs.m_iterator > rhs.m_iterator; + } + + friend bool operator<=(const ordered_iterator& lhs, const ordered_iterator& rhs) { + return lhs.m_iterator <= rhs.m_iterator; + } + + friend bool operator>=(const ordered_iterator& lhs, const ordered_iterator& rhs) { + return lhs.m_iterator >= rhs.m_iterator; + } + + friend ordered_iterator operator+(difference_type n, const ordered_iterator& it) { + return n + it.m_iterator; + } + + friend difference_type operator-(const ordered_iterator& lhs, const ordered_iterator& rhs) { + return lhs.m_iterator - rhs.m_iterator; + } + + private: + iterator m_iterator; + }; + + +private: + using bucket_entry = tsl::detail_ordered_hash::bucket_entry; + + using buckets_container_allocator = typename + std::allocator_traits::template rebind_alloc; + + using buckets_container_type = std::vector; + + + using truncated_hash_type = typename bucket_entry::truncated_hash_type; + using index_type = typename bucket_entry::index_type; + +public: + ordered_hash(size_type bucket_count, + const Hash& hash, + const KeyEqual& equal, + const Allocator& alloc, + float max_load_factor): Hash(hash), + KeyEqual(equal), + m_buckets_data(alloc), + m_buckets(static_empty_bucket_ptr()), + m_hash_mask(0), + m_values(alloc), + m_grow_on_next_insert(false) + { + if(bucket_count > max_bucket_count()) { + TSL_OH_THROW_OR_TERMINATE(std::length_error, "The map exceeds its maximum size."); + } + + if(bucket_count > 0) { + bucket_count = round_up_to_power_of_two(bucket_count); + + m_buckets_data.resize(bucket_count); + m_buckets = m_buckets_data.data(), + m_hash_mask = bucket_count - 1; + } + + this->max_load_factor(max_load_factor); + } + + ordered_hash(const ordered_hash& other): Hash(other), + KeyEqual(other), + m_buckets_data(other.m_buckets_data), + m_buckets(m_buckets_data.empty()?static_empty_bucket_ptr(): + m_buckets_data.data()), + m_hash_mask(other.m_hash_mask), + m_values(other.m_values), + m_load_threshold(other.m_load_threshold), + m_max_load_factor(other.m_max_load_factor), + m_grow_on_next_insert(other.m_grow_on_next_insert) + { + } + + ordered_hash(ordered_hash&& other) noexcept(std::is_nothrow_move_constructible::value && + std::is_nothrow_move_constructible::value && + std::is_nothrow_move_constructible::value && + std::is_nothrow_move_constructible::value) + : Hash(std::move(static_cast(other))), + KeyEqual(std::move(static_cast(other))), + m_buckets_data(std::move(other.m_buckets_data)), + m_buckets(m_buckets_data.empty()?static_empty_bucket_ptr(): + m_buckets_data.data()), + m_hash_mask(other.m_hash_mask), + m_values(std::move(other.m_values)), + m_load_threshold(other.m_load_threshold), + m_max_load_factor(other.m_max_load_factor), + m_grow_on_next_insert(other.m_grow_on_next_insert) + { + other.m_buckets_data.clear(); + other.m_buckets = static_empty_bucket_ptr(); + other.m_hash_mask = 0; + other.m_values.clear(); + other.m_load_threshold = 0; + other.m_grow_on_next_insert = false; + } + + ordered_hash& operator=(const ordered_hash& other) { + if(&other != this) { + Hash::operator=(other); + KeyEqual::operator=(other); + + m_buckets_data = other.m_buckets_data; + m_buckets = m_buckets_data.empty()?static_empty_bucket_ptr(): + m_buckets_data.data(); + + m_hash_mask = other.m_hash_mask; + m_values = other.m_values; + m_load_threshold = other.m_load_threshold; + m_max_load_factor = other.m_max_load_factor; + m_grow_on_next_insert = other.m_grow_on_next_insert; + } + + return *this; + } + + ordered_hash& operator=(ordered_hash&& other) { + other.swap(*this); + other.clear(); + + return *this; + } + + allocator_type get_allocator() const { + return m_values.get_allocator(); + } + + + /* + * Iterators + */ + iterator begin() noexcept { + return iterator(m_values.begin()); + } + + const_iterator begin() const noexcept { + return cbegin(); + } + + const_iterator cbegin() const noexcept { + return const_iterator(m_values.cbegin()); + } + + iterator end() noexcept { + return iterator(m_values.end()); + } + + const_iterator end() const noexcept { + return cend(); + } + + const_iterator cend() const noexcept { + return const_iterator(m_values.cend()); + } + + + reverse_iterator rbegin() noexcept { + return reverse_iterator(m_values.end()); + } + + const_reverse_iterator rbegin() const noexcept { + return rcbegin(); + } + + const_reverse_iterator rcbegin() const noexcept { + return const_reverse_iterator(m_values.cend()); + } + + reverse_iterator rend() noexcept { + return reverse_iterator(m_values.begin()); + } + + const_reverse_iterator rend() const noexcept { + return rcend(); + } + + const_reverse_iterator rcend() const noexcept { + return const_reverse_iterator(m_values.cbegin()); + } + + + /* + * Capacity + */ + bool empty() const noexcept { + return m_values.empty(); + } + + size_type size() const noexcept { + return m_values.size(); + } + + size_type max_size() const noexcept { + return std::min(bucket_entry::max_size(), m_values.max_size()); + } + + + /* + * Modifiers + */ + void clear() noexcept { + for(auto& bucket: m_buckets_data) { + bucket.clear(); + } + + m_values.clear(); + m_grow_on_next_insert = false; + } + + template + std::pair insert(P&& value) { + return insert_impl(KeySelect()(value), std::forward

(value)); + } + + template + iterator insert_hint(const_iterator hint, P&& value) { + if(hint != cend() && compare_keys(KeySelect()(*hint), KeySelect()(value))) { + return mutable_iterator(hint); + } + + return insert(std::forward

(value)).first; + } + + template + void insert(InputIt first, InputIt last) { + if(std::is_base_of::iterator_category>::value) + { + const auto nb_elements_insert = std::distance(first, last); + const size_type nb_free_buckets = m_load_threshold - size(); + tsl_oh_assert(m_load_threshold >= size()); + + if(nb_elements_insert > 0 && nb_free_buckets < size_type(nb_elements_insert)) { + reserve(size() + size_type(nb_elements_insert)); + } + } + + for(; first != last; ++first) { + insert(*first); + } + } + + + + template + std::pair insert_or_assign(K&& key, M&& value) { + auto it = try_emplace(std::forward(key), std::forward(value)); + if(!it.second) { + it.first.value() = std::forward(value); + } + + return it; + } + + template + iterator insert_or_assign(const_iterator hint, K&& key, M&& obj) { + if(hint != cend() && compare_keys(KeySelect()(*hint), key)) { + auto it = mutable_iterator(hint); + it.value() = std::forward(obj); + + return it; + } + + return insert_or_assign(std::forward(key), std::forward(obj)).first; + } + + + + template + std::pair emplace(Args&&... args) { + return insert(value_type(std::forward(args)...)); + } + + template + iterator emplace_hint(const_iterator hint, Args&&... args) { + return insert_hint(hint, value_type(std::forward(args)...)); + } + + + + template + std::pair try_emplace(K&& key, Args&&... value_args) { + return insert_impl(key, std::piecewise_construct, + std::forward_as_tuple(std::forward(key)), + std::forward_as_tuple(std::forward(value_args)...)); + } + + template + iterator try_emplace_hint(const_iterator hint, K&& key, Args&&... args) { + if(hint != cend() && compare_keys(KeySelect()(*hint), key)) { + return mutable_iterator(hint); + } + + return try_emplace(std::forward(key), std::forward(args)...).first; + } + + + + /** + * Here to avoid `template size_type erase(const K& key)` being used when + * we use an `iterator` instead of a `const_iterator`. + */ + iterator erase(iterator pos) { + return erase(const_iterator(pos)); + } + + iterator erase(const_iterator pos) { + tsl_oh_assert(pos != cend()); + + const std::size_t index_erase = iterator_to_index(pos); + + auto it_bucket = find_key(pos.key(), hash_key(pos.key())); + tsl_oh_assert(it_bucket != m_buckets_data.end()); + + erase_value_from_bucket(it_bucket); + + /* + * One element was removed from m_values, due to the left shift the next element + * is now at the position of the previous element (or end if none). + */ + return begin() + index_erase; + } + + iterator erase(const_iterator first, const_iterator last) { + if(first == last) { + return mutable_iterator(first); + } + + tsl_oh_assert(std::distance(first, last) > 0); + const std::size_t start_index = iterator_to_index(first); + const std::size_t nb_values = std::size_t(std::distance(first, last)); + const std::size_t end_index = start_index + nb_values; + + // Delete all values +#ifdef TSL_OH_NO_CONTAINER_ERASE_CONST_ITERATOR + auto next_it = m_values.erase(mutable_iterator(first).m_iterator, mutable_iterator(last).m_iterator); +#else + auto next_it = m_values.erase(first.m_iterator, last.m_iterator); +#endif + + /* + * Mark the buckets corresponding to the values as empty and do a backward shift. + * + * Also, the erase operation on m_values has shifted all the values on the right of last.m_iterator. + * Adapt the indexes for these values. + */ + std::size_t ibucket = 0; + while(ibucket < m_buckets_data.size()) { + if(m_buckets[ibucket].empty()) { + ibucket++; + } + else if(m_buckets[ibucket].index() >= start_index && m_buckets[ibucket].index() < end_index) { + m_buckets[ibucket].clear(); + backward_shift(ibucket); + // Don't increment ibucket, backward_shift may have replaced current bucket. + } + else if(m_buckets[ibucket].index() >= end_index) { + m_buckets[ibucket].set_index(index_type(m_buckets[ibucket].index() - nb_values)); + ibucket++; + } + else { + ibucket++; + } + } + + return iterator(next_it); + } + + + template + size_type erase(const K& key) { + return erase(key, hash_key(key)); + } + + template + size_type erase(const K& key, std::size_t hash) { + return erase_impl(key, hash); + } + + void swap(ordered_hash& other) { + using std::swap; + + swap(static_cast(*this), static_cast(other)); + swap(static_cast(*this), static_cast(other)); + swap(m_buckets_data, other.m_buckets_data); + swap(m_buckets, other.m_buckets); + swap(m_hash_mask, other.m_hash_mask); + swap(m_values, other.m_values); + swap(m_load_threshold, other.m_load_threshold); + swap(m_max_load_factor, other.m_max_load_factor); + swap(m_grow_on_next_insert, other.m_grow_on_next_insert); + } + + + + + /* + * Lookup + */ + template::value>::type* = nullptr> + typename U::value_type& at(const K& key) { + return at(key, hash_key(key)); + } + + template::value>::type* = nullptr> + typename U::value_type& at(const K& key, std::size_t hash) { + return const_cast(static_cast(this)->at(key, hash)); + } + + template::value>::type* = nullptr> + const typename U::value_type& at(const K& key) const { + return at(key, hash_key(key)); + } + + template::value>::type* = nullptr> + const typename U::value_type& at(const K& key, std::size_t hash) const { + auto it = find(key, hash); + if(it != end()) { + return it.value(); + } + else { + TSL_OH_THROW_OR_TERMINATE(std::out_of_range, "Couldn't find the key."); + } + } + + + template::value>::type* = nullptr> + typename U::value_type& operator[](K&& key) { + return try_emplace(std::forward(key)).first.value(); + } + + + template + size_type count(const K& key) const { + return count(key, hash_key(key)); + } + + template + size_type count(const K& key, std::size_t hash) const { + if(find(key, hash) == cend()) { + return 0; + } + else { + return 1; + } + } + + template + iterator find(const K& key) { + return find(key, hash_key(key)); + } + + template + iterator find(const K& key, std::size_t hash) { + auto it_bucket = find_key(key, hash); + return (it_bucket != m_buckets_data.end())?iterator(m_values.begin() + it_bucket->index()):end(); + } + + template + const_iterator find(const K& key) const { + return find(key, hash_key(key)); + } + + template + const_iterator find(const K& key, std::size_t hash) const { + auto it_bucket = find_key(key, hash); + return (it_bucket != m_buckets_data.cend())?const_iterator(m_values.begin() + it_bucket->index()):end(); + } + + + template + bool contains(const K& key) const { + return contains(key, hash_key(key)); + } + + template + bool contains(const K& key, std::size_t hash) const { + return find(key, hash) != cend(); + } + + + template + std::pair equal_range(const K& key) { + return equal_range(key, hash_key(key)); + } + + template + std::pair equal_range(const K& key, std::size_t hash) { + iterator it = find(key, hash); + return std::make_pair(it, (it == end())?it:std::next(it)); + } + + template + std::pair equal_range(const K& key) const { + return equal_range(key, hash_key(key)); + } + + template + std::pair equal_range(const K& key, std::size_t hash) const { + const_iterator it = find(key, hash); + return std::make_pair(it, (it == cend())?it:std::next(it)); + } + + + /* + * Bucket interface + */ + size_type bucket_count() const { + return m_buckets_data.size(); + } + + size_type max_bucket_count() const { + return m_buckets_data.max_size(); + } + + /* + * Hash policy + */ + float load_factor() const { + if(bucket_count() == 0) { + return 0; + } + + return float(size())/float(bucket_count()); + } + + float max_load_factor() const { + return m_max_load_factor; + } + + void max_load_factor(float ml) { + m_max_load_factor = clamp(ml, float(MAX_LOAD_FACTOR__MINIMUM), + float(MAX_LOAD_FACTOR__MAXIMUM)); + + m_max_load_factor = ml; + m_load_threshold = size_type(float(bucket_count())*m_max_load_factor); + } + + void rehash(size_type count) { + count = std::max(count, size_type(std::ceil(float(size())/max_load_factor()))); + rehash_impl(count); + } + + void reserve(size_type count) { + reserve_space_for_values(count); + + count = size_type(std::ceil(float(count)/max_load_factor())); + rehash(count); + } + + + /* + * Observers + */ + hasher hash_function() const { + return static_cast(*this); + } + + key_equal key_eq() const { + return static_cast(*this); + } + + + /* + * Other + */ + iterator mutable_iterator(const_iterator pos) { + return iterator(m_values.begin() + iterator_to_index(pos)); + } + + iterator nth(size_type index) { + tsl_oh_assert(index <= size()); + return iterator(m_values.begin() + index); + } + + const_iterator nth(size_type index) const { + tsl_oh_assert(index <= size()); + return const_iterator(m_values.cbegin() + index); + } + + const_reference front() const { + tsl_oh_assert(!empty()); + return m_values.front(); + } + + const_reference back() const { + tsl_oh_assert(!empty()); + return m_values.back(); + } + + const values_container_type& values_container() const noexcept { + return m_values; + } + + template::value>::type* = nullptr> + const typename values_container_type::value_type* data() const noexcept { + return m_values.data(); + } + + template::value>::type* = nullptr> + size_type capacity() const noexcept { + return m_values.capacity(); + } + + void shrink_to_fit() { + m_values.shrink_to_fit(); + } + + + template + std::pair insert_at_position(const_iterator pos, P&& value) { + return insert_at_position_impl(pos.m_iterator, KeySelect()(value), std::forward

(value)); + } + + template + std::pair emplace_at_position(const_iterator pos, Args&&... args) { + return insert_at_position(pos, value_type(std::forward(args)...)); + } + + template + std::pair try_emplace_at_position(const_iterator pos, K&& key, Args&&... value_args) { + return insert_at_position_impl(pos.m_iterator, key, + std::piecewise_construct, + std::forward_as_tuple(std::forward(key)), + std::forward_as_tuple(std::forward(value_args)...)); + } + + + void pop_back() { + tsl_oh_assert(!empty()); + erase(std::prev(end())); + } + + + /** + * Here to avoid `template size_type unordered_erase(const K& key)` being used when + * we use a iterator instead of a const_iterator. + */ + iterator unordered_erase(iterator pos) { + return unordered_erase(const_iterator(pos)); + } + + iterator unordered_erase(const_iterator pos) { + const std::size_t index_erase = iterator_to_index(pos); + unordered_erase(pos.key()); + + /* + * One element was deleted, index_erase now points to the next element as the elements after + * the deleted value were shifted to the left in m_values (will be end() if we deleted the last element). + */ + return begin() + index_erase; + } + + template + size_type unordered_erase(const K& key) { + return unordered_erase(key, hash_key(key)); + } + + template + size_type unordered_erase(const K& key, std::size_t hash) { + auto it_bucket_key = find_key(key, hash); + if(it_bucket_key == m_buckets_data.end()) { + return 0; + } + + /** + * If we are not erasing the last element in m_values, we swap + * the element we are erasing with the last element. We then would + * just have to do a pop_back() in m_values. + */ + if(!compare_keys(key, KeySelect()(back()))) { + auto it_bucket_last_elem = find_key(KeySelect()(back()), hash_key(KeySelect()(back()))); + tsl_oh_assert(it_bucket_last_elem != m_buckets_data.end()); + tsl_oh_assert(it_bucket_last_elem->index() == m_values.size() - 1); + + using std::swap; + swap(m_values[it_bucket_key->index()], m_values[it_bucket_last_elem->index()]); + swap(it_bucket_key->index_ref(), it_bucket_last_elem->index_ref()); + } + + erase_value_from_bucket(it_bucket_key); + + return 1; + } + + template + void serialize(Serializer& serializer) const { + serialize_impl(serializer); + } + + template + void deserialize(Deserializer& deserializer, bool hash_compatible) { + deserialize_impl(deserializer, hash_compatible); + } + + friend bool operator==(const ordered_hash& lhs, const ordered_hash& rhs) { + return lhs.m_values == rhs.m_values; + } + + friend bool operator!=(const ordered_hash& lhs, const ordered_hash& rhs) { + return lhs.m_values != rhs.m_values; + } + + friend bool operator<(const ordered_hash& lhs, const ordered_hash& rhs) { + return lhs.m_values < rhs.m_values; + } + + friend bool operator<=(const ordered_hash& lhs, const ordered_hash& rhs) { + return lhs.m_values <= rhs.m_values; + } + + friend bool operator>(const ordered_hash& lhs, const ordered_hash& rhs) { + return lhs.m_values > rhs.m_values; + } + + friend bool operator>=(const ordered_hash& lhs, const ordered_hash& rhs) { + return lhs.m_values >= rhs.m_values; + } + + +private: + template + std::size_t hash_key(const K& key) const { + return Hash::operator()(key); + } + + template + bool compare_keys(const K1& key1, const K2& key2) const { + return KeyEqual::operator()(key1, key2); + } + + template + typename buckets_container_type::iterator find_key(const K& key, std::size_t hash) { + auto it = static_cast(this)->find_key(key, hash); + return m_buckets_data.begin() + std::distance(m_buckets_data.cbegin(), it); + } + + /** + * Return bucket which has the key 'key' or m_buckets_data.end() if none. + * + * From the bucket_for_hash, search for the value until we either find an empty bucket + * or a bucket which has a value with a distance from its ideal bucket longer + * than the probe length for the value we are looking for. + */ + template + typename buckets_container_type::const_iterator find_key(const K& key, std::size_t hash) const { + for(std::size_t ibucket = bucket_for_hash(hash), dist_from_ideal_bucket = 0; ; + ibucket = next_bucket(ibucket), dist_from_ideal_bucket++) + { + if(m_buckets[ibucket].empty()) { + return m_buckets_data.end(); + } + else if(m_buckets[ibucket].truncated_hash() == bucket_entry::truncate_hash(hash) && + compare_keys(key, KeySelect()(m_values[m_buckets[ibucket].index()]))) + { + return m_buckets_data.begin() + ibucket; + } + else if(dist_from_ideal_bucket > distance_from_ideal_bucket(ibucket)) { + return m_buckets_data.end(); + } + } + } + + void rehash_impl(size_type bucket_count) { + tsl_oh_assert(bucket_count >= size_type(std::ceil(float(size())/max_load_factor()))); + + if(bucket_count > max_bucket_count()) { + TSL_OH_THROW_OR_TERMINATE(std::length_error, "The map exceeds its maximum size."); + } + + if(bucket_count > 0) { + bucket_count = round_up_to_power_of_two(bucket_count); + } + + if(bucket_count == this->bucket_count()) { + return; + } + + + buckets_container_type old_buckets(bucket_count); + m_buckets_data.swap(old_buckets); + m_buckets = m_buckets_data.empty()?static_empty_bucket_ptr(): + m_buckets_data.data(); + // Everything should be noexcept from here. + + m_hash_mask = (bucket_count > 0)?(bucket_count - 1):0; + this->max_load_factor(m_max_load_factor); + m_grow_on_next_insert = false; + + + + for(const bucket_entry& old_bucket: old_buckets) { + if(old_bucket.empty()) { + continue; + } + + truncated_hash_type insert_hash = old_bucket.truncated_hash(); + index_type insert_index = old_bucket.index(); + + for(std::size_t ibucket = bucket_for_hash(insert_hash), dist_from_ideal_bucket = 0; ; + ibucket = next_bucket(ibucket), dist_from_ideal_bucket++) + { + if(m_buckets[ibucket].empty()) { + m_buckets[ibucket].set_index(insert_index); + m_buckets[ibucket].set_hash(insert_hash); + break; + } + + const std::size_t distance = distance_from_ideal_bucket(ibucket); + if(dist_from_ideal_bucket > distance) { + std::swap(insert_index, m_buckets[ibucket].index_ref()); + std::swap(insert_hash, m_buckets[ibucket].truncated_hash_ref()); + dist_from_ideal_bucket = distance; + } + } + } + } + + template::value>::type* = nullptr> + void reserve_space_for_values(size_type count) { + m_values.reserve(count); + } + + template::value>::type* = nullptr> + void reserve_space_for_values(size_type /*count*/) { + } + + /** + * Swap the empty bucket with the values on its right until we cross another empty bucket + * or if the other bucket has a distance_from_ideal_bucket == 0. + */ + void backward_shift(std::size_t empty_ibucket) noexcept { + tsl_oh_assert(m_buckets[empty_ibucket].empty()); + + std::size_t previous_ibucket = empty_ibucket; + for(std::size_t current_ibucket = next_bucket(previous_ibucket); + !m_buckets[current_ibucket].empty() && distance_from_ideal_bucket(current_ibucket) > 0; + previous_ibucket = current_ibucket, current_ibucket = next_bucket(current_ibucket)) + { + std::swap(m_buckets[current_ibucket], m_buckets[previous_ibucket]); + } + } + + void erase_value_from_bucket(typename buckets_container_type::iterator it_bucket) { + tsl_oh_assert(it_bucket != m_buckets_data.end() && !it_bucket->empty()); + + m_values.erase(m_values.begin() + it_bucket->index()); + + /* + * m_values.erase shifted all the values on the right of the erased value, + * shift the indexes by -1 in the buckets array for these values. + */ + if(it_bucket->index() != m_values.size()) { + shift_indexes_in_buckets(it_bucket->index(), -1); + } + + // Mark the bucket as empty and do a backward shift of the values on the right + it_bucket->clear(); + backward_shift(std::size_t(std::distance(m_buckets_data.begin(), it_bucket))); + } + + /** + * Go through each value from [from_ivalue, m_values.size()) in m_values and for each + * bucket corresponding to the value, shift the index by delta. + * + * delta must be equal to 1 or -1. + */ + void shift_indexes_in_buckets(index_type from_ivalue, int delta) noexcept { + tsl_oh_assert(delta == 1 || delta == -1); + + for(std::size_t ivalue = from_ivalue; ivalue < m_values.size(); ivalue++) { + // All the values in m_values have been shifted by delta. Find the bucket corresponding + // to the value m_values[ivalue] + const index_type old_index = static_cast(ivalue - delta); + + std::size_t ibucket = bucket_for_hash(hash_key(KeySelect()(m_values[ivalue]))); + while(m_buckets[ibucket].index() != old_index) { + ibucket = next_bucket(ibucket); + } + + m_buckets[ibucket].set_index(index_type(ivalue)); + } + } + + template + size_type erase_impl(const K& key, std::size_t hash) { + auto it_bucket = find_key(key, hash); + if(it_bucket != m_buckets_data.end()) { + erase_value_from_bucket(it_bucket); + + return 1; + } + else { + return 0; + } + } + + /** + * Insert the element at the end. + */ + template + std::pair insert_impl(const K& key, Args&&... value_type_args) { + const std::size_t hash = hash_key(key); + + std::size_t ibucket = bucket_for_hash(hash); + std::size_t dist_from_ideal_bucket = 0; + + while(!m_buckets[ibucket].empty() && dist_from_ideal_bucket <= distance_from_ideal_bucket(ibucket)) { + if(m_buckets[ibucket].truncated_hash() == bucket_entry::truncate_hash(hash) && + compare_keys(key, KeySelect()(m_values[m_buckets[ibucket].index()]))) + { + return std::make_pair(begin() + m_buckets[ibucket].index(), false); + } + + ibucket = next_bucket(ibucket); + dist_from_ideal_bucket++; + } + + if(size() >= max_size()) { + TSL_OH_THROW_OR_TERMINATE(std::length_error, "We reached the maximum size for the hash table."); + } + + + if(grow_on_high_load()) { + ibucket = bucket_for_hash(hash); + dist_from_ideal_bucket = 0; + } + + + m_values.emplace_back(std::forward(value_type_args)...); + insert_index(ibucket, dist_from_ideal_bucket, + index_type(m_values.size() - 1), bucket_entry::truncate_hash(hash)); + + + return std::make_pair(std::prev(end()), true); + } + + /** + * Insert the element before insert_position. + */ + template + std::pair insert_at_position_impl(typename values_container_type::const_iterator insert_position, + const K& key, Args&&... value_type_args) + { + const std::size_t hash = hash_key(key); + + std::size_t ibucket = bucket_for_hash(hash); + std::size_t dist_from_ideal_bucket = 0; + + while(!m_buckets[ibucket].empty() && dist_from_ideal_bucket <= distance_from_ideal_bucket(ibucket)) { + if(m_buckets[ibucket].truncated_hash() == bucket_entry::truncate_hash(hash) && + compare_keys(key, KeySelect()(m_values[m_buckets[ibucket].index()]))) + { + return std::make_pair(begin() + m_buckets[ibucket].index(), false); + } + + ibucket = next_bucket(ibucket); + dist_from_ideal_bucket++; + } + + if(size() >= max_size()) { + TSL_OH_THROW_OR_TERMINATE(std::length_error, "We reached the maximum size for the hash table."); + } + + + if(grow_on_high_load()) { + ibucket = bucket_for_hash(hash); + dist_from_ideal_bucket = 0; + } + + + const index_type index_insert_position = index_type(std::distance(m_values.cbegin(), insert_position)); + +#ifdef TSL_OH_NO_CONTAINER_EMPLACE_CONST_ITERATOR + m_values.emplace(m_values.begin() + std::distance(m_values.cbegin(), insert_position), std::forward(value_type_args)...); +#else + m_values.emplace(insert_position, std::forward(value_type_args)...); +#endif + + insert_index(ibucket, dist_from_ideal_bucket, + index_insert_position, bucket_entry::truncate_hash(hash)); + + /* + * The insertion didn't happend at the end of the m_values container, + * we need to shift the indexes in m_buckets_data. + */ + if(index_insert_position != m_values.size() - 1) { + shift_indexes_in_buckets(index_insert_position + 1, 1); + } + + return std::make_pair(iterator(m_values.begin() + index_insert_position), true); + } + + void insert_index(std::size_t ibucket, std::size_t dist_from_ideal_bucket, + index_type index_insert, truncated_hash_type hash_insert) noexcept + { + while(!m_buckets[ibucket].empty()) { + const std::size_t distance = distance_from_ideal_bucket(ibucket); + if(dist_from_ideal_bucket > distance) { + std::swap(index_insert, m_buckets[ibucket].index_ref()); + std::swap(hash_insert, m_buckets[ibucket].truncated_hash_ref()); + + dist_from_ideal_bucket = distance; + } + + + ibucket = next_bucket(ibucket); + dist_from_ideal_bucket++; + + + if(dist_from_ideal_bucket > REHASH_ON_HIGH_NB_PROBES__NPROBES && !m_grow_on_next_insert && + load_factor() >= REHASH_ON_HIGH_NB_PROBES__MIN_LOAD_FACTOR) + { + // We don't want to grow the map now as we need this method to be noexcept. + // Do it on next insert. + m_grow_on_next_insert = true; + } + } + + + m_buckets[ibucket].set_index(index_insert); + m_buckets[ibucket].set_hash(hash_insert); + } + + std::size_t distance_from_ideal_bucket(std::size_t ibucket) const noexcept { + const std::size_t ideal_bucket = bucket_for_hash(m_buckets[ibucket].truncated_hash()); + + if(ibucket >= ideal_bucket) { + return ibucket - ideal_bucket; + } + // If the bucket is smaller than the ideal bucket for the value, there was a wrapping at the end of the + // bucket array due to the modulo. + else { + return (bucket_count() + ibucket) - ideal_bucket; + } + } + + std::size_t next_bucket(std::size_t index) const noexcept { + tsl_oh_assert(index < m_buckets_data.size()); + + index++; + return (index < m_buckets_data.size())?index:0; + } + + std::size_t bucket_for_hash(std::size_t hash) const noexcept { + return hash & m_hash_mask; + } + + std::size_t iterator_to_index(const_iterator it) const noexcept { + const auto dist = std::distance(cbegin(), it); + tsl_oh_assert(dist >= 0); + + return std::size_t(dist); + } + + /** + * Return true if the map has been rehashed. + */ + bool grow_on_high_load() { + if(m_grow_on_next_insert || size() >= m_load_threshold) { + rehash_impl(std::max(size_type(1), bucket_count() * 2)); + m_grow_on_next_insert = false; + + return true; + } + else { + return false; + } + } + + template + void serialize_impl(Serializer& serializer) const { + const slz_size_type version = SERIALIZATION_PROTOCOL_VERSION; + serializer(version); + + const slz_size_type nb_elements = m_values.size(); + serializer(nb_elements); + + const slz_size_type bucket_count = m_buckets_data.size(); + serializer(bucket_count); + + const float max_load_factor = m_max_load_factor; + serializer(max_load_factor); + + + for(const value_type& value: m_values) { + serializer(value); + } + + for(const bucket_entry& bucket: m_buckets_data) { + bucket.serialize(serializer); + } + } + + template + void deserialize_impl(Deserializer& deserializer, bool hash_compatible) { + tsl_oh_assert(m_buckets_data.empty()); // Current hash table must be empty + + const slz_size_type version = deserialize_value(deserializer); + // For now we only have one version of the serialization protocol. + // If it doesn't match there is a problem with the file. + if(version != SERIALIZATION_PROTOCOL_VERSION) { + TSL_OH_THROW_OR_TERMINATE(std::runtime_error, "Can't deserialize the ordered_map/set. " + "The protocol version header is invalid."); + } + + const slz_size_type nb_elements = deserialize_value(deserializer); + const slz_size_type bucket_count_ds = deserialize_value(deserializer); + const float max_load_factor = deserialize_value(deserializer); + + if(max_load_factor < MAX_LOAD_FACTOR__MINIMUM || max_load_factor > MAX_LOAD_FACTOR__MAXIMUM) { + TSL_OH_THROW_OR_TERMINATE(std::runtime_error, "Invalid max_load_factor. Check that the serializer " + "and deserializer support floats correctly as they " + "can be converted implicitly to ints."); + } + + + this->max_load_factor(max_load_factor); + + if(bucket_count_ds == 0) { + tsl_oh_assert(nb_elements == 0); + return; + } + + + if(!hash_compatible) { + reserve(numeric_cast(nb_elements, "Deserialized nb_elements is too big.")); + for(slz_size_type el = 0; el < nb_elements; el++) { + insert(deserialize_value(deserializer)); + } + } + else { + m_buckets_data.reserve(numeric_cast(bucket_count_ds, "Deserialized bucket_count is too big.")); + m_buckets = m_buckets_data.data(), + m_hash_mask = m_buckets_data.capacity() - 1; + + reserve_space_for_values(numeric_cast(nb_elements, "Deserialized nb_elements is too big.")); + for(slz_size_type el = 0; el < nb_elements; el++) { + m_values.push_back(deserialize_value(deserializer)); + } + + for(slz_size_type b = 0; b < bucket_count_ds; b++) { + m_buckets_data.push_back(bucket_entry::deserialize(deserializer)); + } + } + } + + static std::size_t round_up_to_power_of_two(std::size_t value) { + if(is_power_of_two(value)) { + return value; + } + + if(value == 0) { + return 1; + } + + --value; + for(std::size_t i = 1; i < sizeof(std::size_t) * CHAR_BIT; i *= 2) { + value |= value >> i; + } + + return value + 1; + } + + static constexpr bool is_power_of_two(std::size_t value) { + return value != 0 && (value & (value - 1)) == 0; + } + + +public: + static const size_type DEFAULT_INIT_BUCKETS_SIZE = 0; + static constexpr float DEFAULT_MAX_LOAD_FACTOR = 0.75f; + +private: + static constexpr float MAX_LOAD_FACTOR__MINIMUM = 0.1f; + static constexpr float MAX_LOAD_FACTOR__MAXIMUM = 0.95f; + + static const size_type REHASH_ON_HIGH_NB_PROBES__NPROBES = 128; + static constexpr float REHASH_ON_HIGH_NB_PROBES__MIN_LOAD_FACTOR = 0.15f; + + /** + * Protocol version currenlty used for serialization. + */ + static const slz_size_type SERIALIZATION_PROTOCOL_VERSION = 1; + + /** + * Return an always valid pointer to an static empty bucket_entry with last_bucket() == true. + */ + bucket_entry* static_empty_bucket_ptr() { + static bucket_entry empty_bucket; + return &empty_bucket; + } + +private: + buckets_container_type m_buckets_data; + + /** + * Points to m_buckets_data.data() if !m_buckets_data.empty() otherwise points to static_empty_bucket_ptr. + * This variable is useful to avoid the cost of checking if m_buckets_data is empty when trying + * to find an element. + * + * TODO Remove m_buckets_data and only use a pointer+size instead of a pointer+vector to save some space in the ordered_hash object. + */ + bucket_entry* m_buckets; + + size_type m_hash_mask; + + values_container_type m_values; + + size_type m_load_threshold; + float m_max_load_factor; + + bool m_grow_on_next_insert; +}; + + +} // end namespace detail_ordered_hash + +} // end namespace tsl + +#endif diff --git a/thirdparty/include/tsl/ordered_map.h b/thirdparty/include/tsl/ordered_map.h new file mode 100644 index 000000000..1a20ccae0 --- /dev/null +++ b/thirdparty/include/tsl/ordered_map.h @@ -0,0 +1,863 @@ +/** + * MIT License + * + * Copyright (c) 2017 Thibaut Goetghebuer-Planchon + * + * 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. + */ +#ifndef TSL_ORDERED_MAP_H +#define TSL_ORDERED_MAP_H + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ordered_hash.h" + + +namespace tsl { + + +/** + * Implementation of an hash map using open addressing with robin hood with backshift delete to resolve collisions. + * + * The particularity of this hash map is that it remembers the order in which the elements were added and + * provide a way to access the structure which stores these values through the 'values_container()' method. + * The used container is defined by ValueTypeContainer, by default a std::deque is used (grows faster) but + * a std::vector may be used. In this case the map provides a 'data()' method which give a direct access + * to the memory used to store the values (which can be useful to communicate with C API's). + * + * The Key and T must be copy constructible and/or move constructible. To use `unordered_erase` they both + * must be swappable. + * + * The behaviour of the hash map is undefined if the destructor of Key or T throws an exception. + * + * By default the maximum size of a map is limited to 2^32 - 1 values, if needed this can be changed through + * the IndexType template parameter. Using an `uint64_t` will raise this limit to 2^64 - 1 values but each + * bucket will use 16 bytes instead of 8 bytes in addition to the space needed to store the values. + * + * Iterators invalidation: + * - clear, operator=, reserve, rehash: always invalidate the iterators (also invalidate end()). + * - insert, emplace, emplace_hint, operator[]: when a std::vector is used as ValueTypeContainer + * and if size() < capacity(), only end(). + * Otherwise all the iterators are invalidated if an insert occurs. + * - erase, unordered_erase: when a std::vector is used as ValueTypeContainer invalidate the iterator of + * the erased element and all the ones after the erased element (including end()). + * Otherwise all the iterators are invalidated if an erase occurs. + */ +template, + class KeyEqual = std::equal_to, + class Allocator = std::allocator>, + class ValueTypeContainer = std::deque, Allocator>, + class IndexType = std::uint_least32_t> +class ordered_map { +private: + template + using has_is_transparent = tsl::detail_ordered_hash::has_is_transparent; + + class KeySelect { + public: + using key_type = Key; + + const key_type& operator()(const std::pair& key_value) const noexcept { + return key_value.first; + } + + key_type& operator()(std::pair& key_value) noexcept { + return key_value.first; + } + }; + + class ValueSelect { + public: + using value_type = T; + + const value_type& operator()(const std::pair& key_value) const noexcept { + return key_value.second; + } + + value_type& operator()(std::pair& key_value) noexcept { + return key_value.second; + } + }; + + using ht = detail_ordered_hash::ordered_hash, KeySelect, ValueSelect, + Hash, KeyEqual, Allocator, ValueTypeContainer, IndexType>; + +public: + using key_type = typename ht::key_type; + using mapped_type = T; + using value_type = typename ht::value_type; + using size_type = typename ht::size_type; + using difference_type = typename ht::difference_type; + using hasher = typename ht::hasher; + using key_equal = typename ht::key_equal; + using allocator_type = typename ht::allocator_type; + using reference = typename ht::reference; + using const_reference = typename ht::const_reference; + using pointer = typename ht::pointer; + using const_pointer = typename ht::const_pointer; + using iterator = typename ht::iterator; + using const_iterator = typename ht::const_iterator; + using reverse_iterator = typename ht::reverse_iterator; + using const_reverse_iterator = typename ht::const_reverse_iterator; + + using values_container_type = typename ht::values_container_type; + + + /* + * Constructors + */ + ordered_map(): ordered_map(ht::DEFAULT_INIT_BUCKETS_SIZE) { + } + + explicit ordered_map(size_type bucket_count, + const Hash& hash = Hash(), + const KeyEqual& equal = KeyEqual(), + const Allocator& alloc = Allocator()): + m_ht(bucket_count, hash, equal, alloc, ht::DEFAULT_MAX_LOAD_FACTOR) + { + } + + ordered_map(size_type bucket_count, + const Allocator& alloc): ordered_map(bucket_count, Hash(), KeyEqual(), alloc) + { + } + + ordered_map(size_type bucket_count, + const Hash& hash, + const Allocator& alloc): ordered_map(bucket_count, hash, KeyEqual(), alloc) + { + } + + explicit ordered_map(const Allocator& alloc): ordered_map(ht::DEFAULT_INIT_BUCKETS_SIZE, alloc) { + } + + template + ordered_map(InputIt first, InputIt last, + size_type bucket_count = ht::DEFAULT_INIT_BUCKETS_SIZE, + const Hash& hash = Hash(), + const KeyEqual& equal = KeyEqual(), + const Allocator& alloc = Allocator()): ordered_map(bucket_count, hash, equal, alloc) + { + insert(first, last); + } + + template + ordered_map(InputIt first, InputIt last, + size_type bucket_count, + const Allocator& alloc): ordered_map(first, last, bucket_count, Hash(), KeyEqual(), alloc) + { + } + + template + ordered_map(InputIt first, InputIt last, + size_type bucket_count, + const Hash& hash, + const Allocator& alloc): ordered_map(first, last, bucket_count, hash, KeyEqual(), alloc) + { + } + + ordered_map(std::initializer_list init, + size_type bucket_count = ht::DEFAULT_INIT_BUCKETS_SIZE, + const Hash& hash = Hash(), + const KeyEqual& equal = KeyEqual(), + const Allocator& alloc = Allocator()): + ordered_map(init.begin(), init.end(), bucket_count, hash, equal, alloc) + { + } + + ordered_map(std::initializer_list init, + size_type bucket_count, + const Allocator& alloc): + ordered_map(init.begin(), init.end(), bucket_count, Hash(), KeyEqual(), alloc) + { + } + + ordered_map(std::initializer_list init, + size_type bucket_count, + const Hash& hash, + const Allocator& alloc): + ordered_map(init.begin(), init.end(), bucket_count, hash, KeyEqual(), alloc) + { + } + + + ordered_map& operator=(std::initializer_list ilist) { + m_ht.clear(); + + m_ht.reserve(ilist.size()); + m_ht.insert(ilist.begin(), ilist.end()); + + return *this; + } + + allocator_type get_allocator() const { return m_ht.get_allocator(); } + + + + /* + * Iterators + */ + iterator begin() noexcept { return m_ht.begin(); } + const_iterator begin() const noexcept { return m_ht.begin(); } + const_iterator cbegin() const noexcept { return m_ht.cbegin(); } + + iterator end() noexcept { return m_ht.end(); } + const_iterator end() const noexcept { return m_ht.end(); } + const_iterator cend() const noexcept { return m_ht.cend(); } + + reverse_iterator rbegin() noexcept { return m_ht.rbegin(); } + const_reverse_iterator rbegin() const noexcept { return m_ht.rbegin(); } + const_reverse_iterator rcbegin() const noexcept { return m_ht.rcbegin(); } + + reverse_iterator rend() noexcept { return m_ht.rend(); } + const_reverse_iterator rend() const noexcept { return m_ht.rend(); } + const_reverse_iterator rcend() const noexcept { return m_ht.rcend(); } + + + /* + * Capacity + */ + bool empty() const noexcept { return m_ht.empty(); } + size_type size() const noexcept { return m_ht.size(); } + size_type max_size() const noexcept { return m_ht.max_size(); } + + /* + * Modifiers + */ + void clear() noexcept { m_ht.clear(); } + + + + std::pair insert(const value_type& value) { return m_ht.insert(value); } + + template::value>::type* = nullptr> + std::pair insert(P&& value) { return m_ht.emplace(std::forward

(value)); } + + std::pair insert(value_type&& value) { return m_ht.insert(std::move(value)); } + + + iterator insert(const_iterator hint, const value_type& value) { + return m_ht.insert_hint(hint, value); + } + + template::value>::type* = nullptr> + iterator insert(const_iterator hint, P&& value) { + return m_ht.emplace_hint(hint, std::forward

(value)); + } + + iterator insert(const_iterator hint, value_type&& value) { + return m_ht.insert_hint(hint, std::move(value)); + } + + + template + void insert(InputIt first, InputIt last) { m_ht.insert(first, last); } + void insert(std::initializer_list ilist) { m_ht.insert(ilist.begin(), ilist.end()); } + + + + + template + std::pair insert_or_assign(const key_type& k, M&& obj) { + return m_ht.insert_or_assign(k, std::forward(obj)); + } + + template + std::pair insert_or_assign(key_type&& k, M&& obj) { + return m_ht.insert_or_assign(std::move(k), std::forward(obj)); + } + + + template + iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj) { + return m_ht.insert_or_assign(hint, k, std::forward(obj)); + } + + template + iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj) { + return m_ht.insert_or_assign(hint, std::move(k), std::forward(obj)); + } + + /** + * Due to the way elements are stored, emplace will need to move or copy the key-value once. + * The method is equivalent to insert(value_type(std::forward(args)...)); + * + * Mainly here for compatibility with the std::unordered_map interface. + */ + template + std::pair emplace(Args&&... args) { return m_ht.emplace(std::forward(args)...); } + + /** + * Due to the way elements are stored, emplace_hint will need to move or copy the key-value once. + * The method is equivalent to insert(hint, value_type(std::forward(args)...)); + * + * Mainly here for compatibility with the std::unordered_map interface. + */ + template + iterator emplace_hint(const_iterator hint, Args&&... args) { + return m_ht.emplace_hint(hint, std::forward(args)...); + } + + + + + template + std::pair try_emplace(const key_type& k, Args&&... args) { + return m_ht.try_emplace(k, std::forward(args)...); + } + + template + std::pair try_emplace(key_type&& k, Args&&... args) { + return m_ht.try_emplace(std::move(k), std::forward(args)...); + } + + template + iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args) { + return m_ht.try_emplace_hint(hint, k, std::forward(args)...); + } + + template + iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args) { + return m_ht.try_emplace_hint(hint, std::move(k), std::forward(args)...); + } + + + + + /** + * When erasing an element, the insert order will be preserved and no holes will be present in the container + * returned by 'values_container()'. + * + * The method is in O(n), if the order is not important 'unordered_erase(...)' method is faster with an O(1) + * average complexity. + */ + iterator erase(iterator pos) { return m_ht.erase(pos); } + + /** + * @copydoc erase(iterator pos) + */ + iterator erase(const_iterator pos) { return m_ht.erase(pos); } + + /** + * @copydoc erase(iterator pos) + */ + iterator erase(const_iterator first, const_iterator last) { return m_ht.erase(first, last); } + + /** + * @copydoc erase(iterator pos) + */ + size_type erase(const key_type& key) { return m_ht.erase(key); } + + /** + * @copydoc erase(iterator pos) + * + * Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same + * as hash_function()(key). Useful to speed-up the lookup to the value if you already have the hash. + */ + size_type erase(const key_type& key, std::size_t precalculated_hash) { + return m_ht.erase(key, precalculated_hash); + } + + /** + * @copydoc erase(iterator pos) + * + * This overload only participates in the overload resolution if the typedef KeyEqual::is_transparent exists. + * If so, K must be hashable and comparable to Key. + */ + template::value>::type* = nullptr> + size_type erase(const K& key) { return m_ht.erase(key); } + + /** + * @copydoc erase(const key_type& key, std::size_t precalculated_hash) + * + * This overload only participates in the overload resolution if the typedef KeyEqual::is_transparent exists. + * If so, K must be hashable and comparable to Key. + */ + template::value>::type* = nullptr> + size_type erase(const K& key, std::size_t precalculated_hash) { + return m_ht.erase(key, precalculated_hash); + } + + + + void swap(ordered_map& other) { other.m_ht.swap(m_ht); } + + /* + * Lookup + */ + T& at(const Key& key) { return m_ht.at(key); } + + /** + * Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same + * as hash_function()(key). Useful to speed-up the lookup if you already have the hash. + */ + T& at(const Key& key, std::size_t precalculated_hash) { return m_ht.at(key, precalculated_hash); } + + + const T& at(const Key& key) const { return m_ht.at(key); } + + /** + * @copydoc at(const Key& key, std::size_t precalculated_hash) + */ + const T& at(const Key& key, std::size_t precalculated_hash) const { return m_ht.at(key, precalculated_hash); } + + + /** + * This overload only participates in the overload resolution if the typedef KeyEqual::is_transparent exists. + * If so, K must be hashable and comparable to Key. + */ + template::value>::type* = nullptr> + T& at(const K& key) { return m_ht.at(key); } + + /** + * @copydoc at(const K& key) + * + * Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same + * as hash_function()(key). Useful to speed-up the lookup if you already have the hash. + */ + template::value>::type* = nullptr> + T& at(const K& key, std::size_t precalculated_hash) { return m_ht.at(key, precalculated_hash); } + + /** + * @copydoc at(const K& key) + */ + template::value>::type* = nullptr> + const T& at(const K& key) const { return m_ht.at(key); } + + /** + * @copydoc at(const K& key, std::size_t precalculated_hash) + */ + template::value>::type* = nullptr> + const T& at(const K& key, std::size_t precalculated_hash) const { return m_ht.at(key, precalculated_hash); } + + + + T& operator[](const Key& key) { return m_ht[key]; } + T& operator[](Key&& key) { return m_ht[std::move(key)]; } + + + + size_type count(const Key& key) const { return m_ht.count(key); } + + /** + * Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same + * as hash_function()(key). Useful to speed-up the lookup if you already have the hash. + */ + size_type count(const Key& key, std::size_t precalculated_hash) const { + return m_ht.count(key, precalculated_hash); + } + + /** + * This overload only participates in the overload resolution if the typedef KeyEqual::is_transparent exists. + * If so, K must be hashable and comparable to Key. + */ + template::value>::type* = nullptr> + size_type count(const K& key) const { return m_ht.count(key); } + + /** + * @copydoc count(const K& key) const + * + * Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same + * as hash_function()(key). Useful to speed-up the lookup if you already have the hash. + */ + template::value>::type* = nullptr> + size_type count(const K& key, std::size_t precalculated_hash) const { + return m_ht.count(key, precalculated_hash); + } + + + + iterator find(const Key& key) { return m_ht.find(key); } + + /** + * Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same + * as hash_function()(key). Useful to speed-up the lookup if you already have the hash. + */ + iterator find(const Key& key, std::size_t precalculated_hash) { return m_ht.find(key, precalculated_hash); } + + const_iterator find(const Key& key) const { return m_ht.find(key); } + + /** + * @copydoc find(const Key& key, std::size_t precalculated_hash) + */ + const_iterator find(const Key& key, std::size_t precalculated_hash) const { + return m_ht.find(key, precalculated_hash); + } + + /** + * This overload only participates in the overload resolution if the typedef KeyEqual::is_transparent exists. + * If so, K must be hashable and comparable to Key. + */ + template::value>::type* = nullptr> + iterator find(const K& key) { return m_ht.find(key); } + + /** + * @copydoc find(const K& key) + * + * Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same + * as hash_function()(key). Useful to speed-up the lookup if you already have the hash. + */ + template::value>::type* = nullptr> + iterator find(const K& key, std::size_t precalculated_hash) { return m_ht.find(key, precalculated_hash); } + + /** + * @copydoc find(const K& key) + */ + template::value>::type* = nullptr> + const_iterator find(const K& key) const { return m_ht.find(key); } + + /** + * @copydoc find(const K& key) + * + * Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same + * as hash_function()(key). Useful to speed-up the lookup if you already have the hash. + */ + template::value>::type* = nullptr> + const_iterator find(const K& key, std::size_t precalculated_hash) const { + return m_ht.find(key, precalculated_hash); + } + + + + bool contains(const Key& key) const { return m_ht.contains(key); } + + /** + * Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same + * as hash_function()(key). Useful to speed-up the lookup if you already have the hash. + */ + bool contains(const Key& key, std::size_t precalculated_hash) const { + return m_ht.contains(key, precalculated_hash); + } + + /** + * This overload only participates in the overload resolution if the typedef KeyEqual::is_transparent exists. + * If so, K must be hashable and comparable to Key. + */ + template::value>::type* = nullptr> + bool contains(const K& key) const { return m_ht.contains(key); } + + /** + * @copydoc contains(const K& key) const + * + * Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same + * as hash_function()(key). Useful to speed-up the lookup if you already have the hash. + */ + template::value>::type* = nullptr> + bool contains(const K& key, std::size_t precalculated_hash) const { + return m_ht.contains(key, precalculated_hash); + } + + + + std::pair equal_range(const Key& key) { return m_ht.equal_range(key); } + + /** + * Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same + * as hash_function()(key). Useful to speed-up the lookup if you already have the hash. + */ + std::pair equal_range(const Key& key, std::size_t precalculated_hash) { + return m_ht.equal_range(key, precalculated_hash); + } + + std::pair equal_range(const Key& key) const { return m_ht.equal_range(key); } + + /** + * @copydoc equal_range(const Key& key, std::size_t precalculated_hash) + */ + std::pair equal_range(const Key& key, std::size_t precalculated_hash) const { + return m_ht.equal_range(key, precalculated_hash); + } + + /** + * This overload only participates in the overload resolution if the typedef KeyEqual::is_transparent exists. + * If so, K must be hashable and comparable to Key. + */ + template::value>::type* = nullptr> + std::pair equal_range(const K& key) { return m_ht.equal_range(key); } + + /** + * @copydoc equal_range(const K& key) + * + * Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same + * as hash_function()(key). Useful to speed-up the lookup if you already have the hash. + */ + template::value>::type* = nullptr> + std::pair equal_range(const K& key, std::size_t precalculated_hash) { + return m_ht.equal_range(key, precalculated_hash); + } + + /** + * @copydoc equal_range(const K& key) + */ + template::value>::type* = nullptr> + std::pair equal_range(const K& key) const { return m_ht.equal_range(key); } + + /** + * @copydoc equal_range(const K& key, std::size_t precalculated_hash) + */ + template::value>::type* = nullptr> + std::pair equal_range(const K& key, std::size_t precalculated_hash) const { + return m_ht.equal_range(key, precalculated_hash); + } + + + + /* + * Bucket interface + */ + size_type bucket_count() const { return m_ht.bucket_count(); } + size_type max_bucket_count() const { return m_ht.max_bucket_count(); } + + + /* + * Hash policy + */ + float load_factor() const { return m_ht.load_factor(); } + float max_load_factor() const { return m_ht.max_load_factor(); } + void max_load_factor(float ml) { m_ht.max_load_factor(ml); } + + void rehash(size_type count) { m_ht.rehash(count); } + void reserve(size_type count) { m_ht.reserve(count); } + + + /* + * Observers + */ + hasher hash_function() const { return m_ht.hash_function(); } + key_equal key_eq() const { return m_ht.key_eq(); } + + + + /* + * Other + */ + + /** + * Convert a const_iterator to an iterator. + */ + iterator mutable_iterator(const_iterator pos) { + return m_ht.mutable_iterator(pos); + } + + /** + * Requires index <= size(). + * + * Return an iterator to the element at index. Return end() if index == size(). + */ + iterator nth(size_type index) { return m_ht.nth(index); } + + /** + * @copydoc nth(size_type index) + */ + const_iterator nth(size_type index) const { return m_ht.nth(index); } + + + /** + * Return const_reference to the first element. Requires the container to not be empty. + */ + const_reference front() const { return m_ht.front(); } + + /** + * Return const_reference to the last element. Requires the container to not be empty. + */ + const_reference back() const { return m_ht.back(); } + + + /** + * Only available if ValueTypeContainer is a std::vector. Same as calling 'values_container().data()'. + */ + template::value>::type* = nullptr> + const typename values_container_type::value_type* data() const noexcept { return m_ht.data(); } + + /** + * Return the container in which the values are stored. The values are in the same order as the insertion order + * and are contiguous in the structure, no holes (size() == values_container().size()). + */ + const values_container_type& values_container() const noexcept { return m_ht.values_container(); } + + template::value>::type* = nullptr> + size_type capacity() const noexcept { return m_ht.capacity(); } + + void shrink_to_fit() { m_ht.shrink_to_fit(); } + + + + /** + * Insert the value before pos shifting all the elements on the right of pos (including pos) one position + * to the right. + * + * Amortized linear time-complexity in the distance between pos and end(). + */ + std::pair insert_at_position(const_iterator pos, const value_type& value) { + return m_ht.insert_at_position(pos, value); + } + + /** + * @copydoc insert_at_position(const_iterator pos, const value_type& value) + */ + std::pair insert_at_position(const_iterator pos, value_type&& value) { + return m_ht.insert_at_position(pos, std::move(value)); + } + + /** + * @copydoc insert_at_position(const_iterator pos, const value_type& value) + * + * Same as insert_at_position(pos, value_type(std::forward(args)...), mainly + * here for coherence. + */ + template + std::pair emplace_at_position(const_iterator pos, Args&&... args) { + return m_ht.emplace_at_position(pos, std::forward(args)...); + } + + /** + * @copydoc insert_at_position(const_iterator pos, const value_type& value) + */ + template + std::pair try_emplace_at_position(const_iterator pos, const key_type& k, Args&&... args) { + return m_ht.try_emplace_at_position(pos, k, std::forward(args)...); + } + + /** + * @copydoc insert_at_position(const_iterator pos, const value_type& value) + */ + template + std::pair try_emplace_at_position(const_iterator pos, key_type&& k, Args&&... args) { + return m_ht.try_emplace_at_position(pos, std::move(k), std::forward(args)...); + } + + + + void pop_back() { m_ht.pop_back(); } + + /** + * Faster erase operation with an O(1) average complexity but it doesn't preserve the insertion order. + * + * If an erasure occurs, the last element of the map will take the place of the erased element. + */ + iterator unordered_erase(iterator pos) { return m_ht.unordered_erase(pos); } + + /** + * @copydoc unordered_erase(iterator pos) + */ + iterator unordered_erase(const_iterator pos) { return m_ht.unordered_erase(pos); } + + /** + * @copydoc unordered_erase(iterator pos) + */ + size_type unordered_erase(const key_type& key) { return m_ht.unordered_erase(key); } + + /** + * @copydoc unordered_erase(iterator pos) + * + * Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same + * as hash_function()(key). Useful to speed-up the lookup if you already have the hash. + */ + size_type unordered_erase(const key_type& key, std::size_t precalculated_hash) { + return m_ht.unordered_erase(key, precalculated_hash); + } + + /** + * @copydoc unordered_erase(iterator pos) + * + * This overload only participates in the overload resolution if the typedef KeyEqual::is_transparent exists. + * If so, K must be hashable and comparable to Key. + */ + template::value>::type* = nullptr> + size_type unordered_erase(const K& key) { return m_ht.unordered_erase(key); } + + /** + * @copydoc unordered_erase(const K& key) + * + * Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same + * as hash_function()(key). Useful to speed-up the lookup if you already have the hash. + */ + template::value>::type* = nullptr> + size_type unordered_erase(const K& key, std::size_t precalculated_hash) { + return m_ht.unordered_erase(key, precalculated_hash); + } + + /** + * Serialize the map through the `serializer` parameter. + * + * The `serializer` parameter must be a function object that supports the following call: + * - `template void operator()(const U& value);` where the types `std::uint64_t`, `float` and `std::pair` must be supported for U. + * + * The implementation leaves binary compatibility (endianness, IEEE 754 for floats, ...) of the types it serializes + * in the hands of the `Serializer` function object if compatibility is required. + */ + template + void serialize(Serializer& serializer) const { + m_ht.serialize(serializer); + } + + /** + * Deserialize a previously serialized map through the `deserializer` parameter. + * + * The `deserializer` parameter must be a function object that supports the following calls: + * - `template U operator()();` where the types `std::uint64_t`, `float` and `std::pair` must be supported for U. + * + * If the deserialized hash map type is hash compatible with the serialized map, the deserialization process can be + * sped up by setting `hash_compatible` to true. To be hash compatible, the Hash and KeyEqual must behave the same way + * than the ones used on the serialized map. The `std::size_t` must also be of the same size as the one on the platform used + * to serialize the map, the same apply for `IndexType`. If these criteria are not met, the behaviour is undefined with + * `hash_compatible` sets to true. + * + * The behaviour is undefined if the type `Key` and `T` of the `ordered_map` are not the same as the + * types used during serialization. + * + * The implementation leaves binary compatibility (endianness, IEEE 754 for floats, size of int, ...) of the types it + * deserializes in the hands of the `Deserializer` function object if compatibility is required. + */ + template + static ordered_map deserialize(Deserializer& deserializer, bool hash_compatible = false) { + ordered_map map(0); + map.m_ht.deserialize(deserializer, hash_compatible); + + return map; + } + + + + friend bool operator==(const ordered_map& lhs, const ordered_map& rhs) { return lhs.m_ht == rhs.m_ht; } + friend bool operator!=(const ordered_map& lhs, const ordered_map& rhs) { return lhs.m_ht != rhs.m_ht; } + friend bool operator<(const ordered_map& lhs, const ordered_map& rhs) { return lhs.m_ht < rhs.m_ht; } + friend bool operator<=(const ordered_map& lhs, const ordered_map& rhs) { return lhs.m_ht <= rhs.m_ht; } + friend bool operator>(const ordered_map& lhs, const ordered_map& rhs) { return lhs.m_ht > rhs.m_ht; } + friend bool operator>=(const ordered_map& lhs, const ordered_map& rhs) { return lhs.m_ht >= rhs.m_ht; } + + friend void swap(ordered_map& lhs, ordered_map& rhs) { lhs.swap(rhs); } + +private: + ht m_ht; +}; + +} // end namespace tsl + +#endif diff --git a/thirdparty/include/tsl/ordered_set.h b/thirdparty/include/tsl/ordered_set.h new file mode 100644 index 000000000..90a99eee3 --- /dev/null +++ b/thirdparty/include/tsl/ordered_set.h @@ -0,0 +1,718 @@ +/** + * MIT License + * + * Copyright (c) 2017 Thibaut Goetghebuer-Planchon + * + * 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. + */ +#ifndef TSL_ORDERED_SET_H +#define TSL_ORDERED_SET_H + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ordered_hash.h" + + +namespace tsl { + + +/** + * Implementation of an hash set using open addressing with robin hood with backshift delete to resolve collisions. + * + * The particularity of this hash set is that it remembers the order in which the elements were added and + * provide a way to access the structure which stores these values through the 'values_container()' method. + * The used container is defined by ValueTypeContainer, by default a std::deque is used (grows faster) but + * a std::vector may be used. In this case the set provides a 'data()' method which give a direct access + * to the memory used to store the values (which can be useful to communicate with C API's). + * + * The Key must be copy constructible and/or move constructible. To use `unordered_erase` it also must be swappable. + * + * The behaviour of the hash set is undefined if the destructor of Key throws an exception. + * + * By default the maximum size of a set is limited to 2^32 - 1 values, if needed this can be changed through + * the IndexType template parameter. Using an `uint64_t` will raise this limit to 2^64 - 1 values but each + * bucket will use 16 bytes instead of 8 bytes in addition to the space needed to store the values. + * + * Iterators invalidation: + * - clear, operator=, reserve, rehash: always invalidate the iterators (also invalidate end()). + * - insert, emplace, emplace_hint, operator[]: when a std::vector is used as ValueTypeContainer + * and if size() < capacity(), only end(). + * Otherwise all the iterators are invalidated if an insert occurs. + * - erase, unordered_erase: when a std::vector is used as ValueTypeContainer invalidate the iterator of + * the erased element and all the ones after the erased element (including end()). + * Otherwise all the iterators are invalidated if an erase occurs. + */ +template, + class KeyEqual = std::equal_to, + class Allocator = std::allocator, + class ValueTypeContainer = std::deque, + class IndexType = std::uint_least32_t> +class ordered_set { +private: + template + using has_is_transparent = tsl::detail_ordered_hash::has_is_transparent; + + class KeySelect { + public: + using key_type = Key; + + const key_type& operator()(const Key& key) const noexcept { + return key; + } + + key_type& operator()(Key& key) noexcept { + return key; + } + }; + + using ht = detail_ordered_hash::ordered_hash; + +public: + using key_type = typename ht::key_type; + using value_type = typename ht::value_type; + using size_type = typename ht::size_type; + using difference_type = typename ht::difference_type; + using hasher = typename ht::hasher; + using key_equal = typename ht::key_equal; + using allocator_type = typename ht::allocator_type; + using reference = typename ht::reference; + using const_reference = typename ht::const_reference; + using pointer = typename ht::pointer; + using const_pointer = typename ht::const_pointer; + using iterator = typename ht::iterator; + using const_iterator = typename ht::const_iterator; + using reverse_iterator = typename ht::reverse_iterator; + using const_reverse_iterator = typename ht::const_reverse_iterator; + + using values_container_type = typename ht::values_container_type; + + + /* + * Constructors + */ + ordered_set(): ordered_set(ht::DEFAULT_INIT_BUCKETS_SIZE) { + } + + explicit ordered_set(size_type bucket_count, + const Hash& hash = Hash(), + const KeyEqual& equal = KeyEqual(), + const Allocator& alloc = Allocator()): + m_ht(bucket_count, hash, equal, alloc, ht::DEFAULT_MAX_LOAD_FACTOR) + { + } + + ordered_set(size_type bucket_count, + const Allocator& alloc): ordered_set(bucket_count, Hash(), KeyEqual(), alloc) + { + } + + ordered_set(size_type bucket_count, + const Hash& hash, + const Allocator& alloc): ordered_set(bucket_count, hash, KeyEqual(), alloc) + { + } + + explicit ordered_set(const Allocator& alloc): ordered_set(ht::DEFAULT_INIT_BUCKETS_SIZE, alloc) { + } + + template + ordered_set(InputIt first, InputIt last, + size_type bucket_count = ht::DEFAULT_INIT_BUCKETS_SIZE, + const Hash& hash = Hash(), + const KeyEqual& equal = KeyEqual(), + const Allocator& alloc = Allocator()): ordered_set(bucket_count, hash, equal, alloc) + { + insert(first, last); + } + + template + ordered_set(InputIt first, InputIt last, + size_type bucket_count, + const Allocator& alloc): ordered_set(first, last, bucket_count, Hash(), KeyEqual(), alloc) + { + } + + template + ordered_set(InputIt first, InputIt last, + size_type bucket_count, + const Hash& hash, + const Allocator& alloc): ordered_set(first, last, bucket_count, hash, KeyEqual(), alloc) + { + } + + ordered_set(std::initializer_list init, + size_type bucket_count = ht::DEFAULT_INIT_BUCKETS_SIZE, + const Hash& hash = Hash(), + const KeyEqual& equal = KeyEqual(), + const Allocator& alloc = Allocator()): + ordered_set(init.begin(), init.end(), bucket_count, hash, equal, alloc) + { + } + + ordered_set(std::initializer_list init, + size_type bucket_count, + const Allocator& alloc): + ordered_set(init.begin(), init.end(), bucket_count, Hash(), KeyEqual(), alloc) + { + } + + ordered_set(std::initializer_list init, + size_type bucket_count, + const Hash& hash, + const Allocator& alloc): + ordered_set(init.begin(), init.end(), bucket_count, hash, KeyEqual(), alloc) + { + } + + + ordered_set& operator=(std::initializer_list ilist) { + m_ht.clear(); + + m_ht.reserve(ilist.size()); + m_ht.insert(ilist.begin(), ilist.end()); + + return *this; + } + + allocator_type get_allocator() const { return m_ht.get_allocator(); } + + + /* + * Iterators + */ + iterator begin() noexcept { return m_ht.begin(); } + const_iterator begin() const noexcept { return m_ht.begin(); } + const_iterator cbegin() const noexcept { return m_ht.cbegin(); } + + iterator end() noexcept { return m_ht.end(); } + const_iterator end() const noexcept { return m_ht.end(); } + const_iterator cend() const noexcept { return m_ht.cend(); } + + reverse_iterator rbegin() noexcept { return m_ht.rbegin(); } + const_reverse_iterator rbegin() const noexcept { return m_ht.rbegin(); } + const_reverse_iterator rcbegin() const noexcept { return m_ht.rcbegin(); } + + reverse_iterator rend() noexcept { return m_ht.rend(); } + const_reverse_iterator rend() const noexcept { return m_ht.rend(); } + const_reverse_iterator rcend() const noexcept { return m_ht.rcend(); } + + + /* + * Capacity + */ + bool empty() const noexcept { return m_ht.empty(); } + size_type size() const noexcept { return m_ht.size(); } + size_type max_size() const noexcept { return m_ht.max_size(); } + + /* + * Modifiers + */ + void clear() noexcept { m_ht.clear(); } + + + + std::pair insert(const value_type& value) { return m_ht.insert(value); } + std::pair insert(value_type&& value) { return m_ht.insert(std::move(value)); } + + iterator insert(const_iterator hint, const value_type& value) { + return m_ht.insert_hint(hint, value); + } + + iterator insert(const_iterator hint, value_type&& value) { + return m_ht.insert_hint(hint, std::move(value)); + } + + template + void insert(InputIt first, InputIt last) { m_ht.insert(first, last); } + void insert(std::initializer_list ilist) { m_ht.insert(ilist.begin(), ilist.end()); } + + + + /** + * Due to the way elements are stored, emplace will need to move or copy the key-value once. + * The method is equivalent to insert(value_type(std::forward(args)...)); + * + * Mainly here for compatibility with the std::unordered_map interface. + */ + template + std::pair emplace(Args&&... args) { return m_ht.emplace(std::forward(args)...); } + + /** + * Due to the way elements are stored, emplace_hint will need to move or copy the key-value once. + * The method is equivalent to insert(hint, value_type(std::forward(args)...)); + * + * Mainly here for compatibility with the std::unordered_map interface. + */ + template + iterator emplace_hint(const_iterator hint, Args&&... args) { + return m_ht.emplace_hint(hint, std::forward(args)...); + } + + /** + * When erasing an element, the insert order will be preserved and no holes will be present in the container + * returned by 'values_container()'. + * + * The method is in O(n), if the order is not important 'unordered_erase(...)' method is faster with an O(1) + * average complexity. + */ + iterator erase(iterator pos) { return m_ht.erase(pos); } + + /** + * @copydoc erase(iterator pos) + */ + iterator erase(const_iterator pos) { return m_ht.erase(pos); } + + /** + * @copydoc erase(iterator pos) + */ + iterator erase(const_iterator first, const_iterator last) { return m_ht.erase(first, last); } + + /** + * @copydoc erase(iterator pos) + */ + size_type erase(const key_type& key) { return m_ht.erase(key); } + + /** + * @copydoc erase(iterator pos) + * + * Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same + * as hash_function()(key). Useful to speed-up the lookup to the value if you already have the hash. + */ + size_type erase(const key_type& key, std::size_t precalculated_hash) { + return m_ht.erase(key, precalculated_hash); + } + + /** + * @copydoc erase(iterator pos) + * + * This overload only participates in the overload resolution if the typedef KeyEqual::is_transparent exists. + * If so, K must be hashable and comparable to Key. + */ + template::value>::type* = nullptr> + size_type erase(const K& key) { return m_ht.erase(key); } + + /** + * @copydoc erase(const key_type& key, std::size_t precalculated_hash) + * + * This overload only participates in the overload resolution if the typedef KeyEqual::is_transparent exists. + * If so, K must be hashable and comparable to Key. + */ + template::value>::type* = nullptr> + size_type erase(const K& key, std::size_t precalculated_hash) { + return m_ht.erase(key, precalculated_hash); + } + + + + void swap(ordered_set& other) { other.m_ht.swap(m_ht); } + + /* + * Lookup + */ + size_type count(const Key& key) const { return m_ht.count(key); } + + /** + * Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same + * as hash_function()(key). Useful to speed-up the lookup if you already have the hash. + */ + size_type count(const Key& key, std::size_t precalculated_hash) const { + return m_ht.count(key, precalculated_hash); + } + + /** + * This overload only participates in the overload resolution if the typedef KeyEqual::is_transparent exists. + * If so, K must be hashable and comparable to Key. + */ + template::value>::type* = nullptr> + size_type count(const K& key) const { return m_ht.count(key); } + + /** + * @copydoc count(const K& key) const + * + * Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same + * as hash_function()(key). Useful to speed-up the lookup if you already have the hash. + */ + template::value>::type* = nullptr> + size_type count(const K& key, std::size_t precalculated_hash) const { + return m_ht.count(key, precalculated_hash); + } + + + + + iterator find(const Key& key) { return m_ht.find(key); } + + /** + * Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same + * as hash_function()(key). Useful to speed-up the lookup if you already have the hash. + */ + iterator find(const Key& key, std::size_t precalculated_hash) { return m_ht.find(key, precalculated_hash); } + + const_iterator find(const Key& key) const { return m_ht.find(key); } + + /** + * @copydoc find(const Key& key, std::size_t precalculated_hash) + */ + const_iterator find(const Key& key, std::size_t precalculated_hash) const { + return m_ht.find(key, precalculated_hash); + } + + /** + * This overload only participates in the overload resolution if the typedef KeyEqual::is_transparent exists. + * If so, K must be hashable and comparable to Key. + */ + template::value>::type* = nullptr> + iterator find(const K& key) { return m_ht.find(key); } + + /** + * @copydoc find(const K& key) + * + * Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same + * as hash_function()(key). Useful to speed-up the lookup if you already have the hash. + */ + template::value>::type* = nullptr> + iterator find(const K& key, std::size_t precalculated_hash) { return m_ht.find(key, precalculated_hash); } + + /** + * @copydoc find(const K& key) + */ + template::value>::type* = nullptr> + const_iterator find(const K& key) const { return m_ht.find(key); } + + /** + * @copydoc find(const K& key) + * + * Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same + * as hash_function()(key). Useful to speed-up the lookup if you already have the hash. + */ + template::value>::type* = nullptr> + const_iterator find(const K& key, std::size_t precalculated_hash) const { + return m_ht.find(key, precalculated_hash); + } + + + + bool contains(const Key& key) const { return m_ht.contains(key); } + + /** + * Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same + * as hash_function()(key). Useful to speed-up the lookup if you already have the hash. + */ + bool contains(const Key& key, std::size_t precalculated_hash) const { + return m_ht.contains(key, precalculated_hash); + } + + /** + * This overload only participates in the overload resolution if the typedef KeyEqual::is_transparent exists. + * If so, K must be hashable and comparable to Key. + */ + template::value>::type* = nullptr> + bool contains(const K& key) const { return m_ht.contains(key); } + + /** + * @copydoc contains(const K& key) const + * + * Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same + * as hash_function()(key). Useful to speed-up the lookup if you already have the hash. + */ + template::value>::type* = nullptr> + bool contains(const K& key, std::size_t precalculated_hash) const { + return m_ht.contains(key, precalculated_hash); + } + + + + std::pair equal_range(const Key& key) { return m_ht.equal_range(key); } + + /** + * Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same + * as hash_function()(key). Useful to speed-up the lookup if you already have the hash. + */ + std::pair equal_range(const Key& key, std::size_t precalculated_hash) { + return m_ht.equal_range(key, precalculated_hash); + } + + std::pair equal_range(const Key& key) const { return m_ht.equal_range(key); } + + /** + * @copydoc equal_range(const Key& key, std::size_t precalculated_hash) + */ + std::pair equal_range(const Key& key, std::size_t precalculated_hash) const { + return m_ht.equal_range(key, precalculated_hash); + } + + /** + * This overload only participates in the overload resolution if the typedef KeyEqual::is_transparent exists. + * If so, K must be hashable and comparable to Key. + */ + template::value>::type* = nullptr> + std::pair equal_range(const K& key) { return m_ht.equal_range(key); } + + /** + * @copydoc equal_range(const K& key) + * + * Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same + * as hash_function()(key). Useful to speed-up the lookup if you already have the hash. + */ + template::value>::type* = nullptr> + std::pair equal_range(const K& key, std::size_t precalculated_hash) { + return m_ht.equal_range(key, precalculated_hash); + } + + /** + * @copydoc equal_range(const K& key) + */ + template::value>::type* = nullptr> + std::pair equal_range(const K& key) const { return m_ht.equal_range(key); } + + /** + * @copydoc equal_range(const K& key, std::size_t precalculated_hash) + */ + template::value>::type* = nullptr> + std::pair equal_range(const K& key, std::size_t precalculated_hash) const { + return m_ht.equal_range(key, precalculated_hash); + } + + + /* + * Bucket interface + */ + size_type bucket_count() const { return m_ht.bucket_count(); } + size_type max_bucket_count() const { return m_ht.max_bucket_count(); } + + + /* + * Hash policy + */ + float load_factor() const { return m_ht.load_factor(); } + float max_load_factor() const { return m_ht.max_load_factor(); } + void max_load_factor(float ml) { m_ht.max_load_factor(ml); } + + void rehash(size_type count) { m_ht.rehash(count); } + void reserve(size_type count) { m_ht.reserve(count); } + + + /* + * Observers + */ + hasher hash_function() const { return m_ht.hash_function(); } + key_equal key_eq() const { return m_ht.key_eq(); } + + + /* + * Other + */ + + /** + * Convert a const_iterator to an iterator. + */ + iterator mutable_iterator(const_iterator pos) { + return m_ht.mutable_iterator(pos); + } + + /** + * Requires index <= size(). + * + * Return an iterator to the element at index. Return end() if index == size(). + */ + iterator nth(size_type index) { return m_ht.nth(index); } + + /** + * @copydoc nth(size_type index) + */ + const_iterator nth(size_type index) const { return m_ht.nth(index); } + + + /** + * Return const_reference to the first element. Requires the container to not be empty. + */ + const_reference front() const { return m_ht.front(); } + + /** + * Return const_reference to the last element. Requires the container to not be empty. + */ + const_reference back() const { return m_ht.back(); } + + + /** + * Only available if ValueTypeContainer is a std::vector. Same as calling 'values_container().data()'. + */ + template::value>::type* = nullptr> + const typename values_container_type::value_type* data() const noexcept { return m_ht.data(); } + + /** + * Return the container in which the values are stored. The values are in the same order as the insertion order + * and are contiguous in the structure, no holes (size() == values_container().size()). + */ + const values_container_type& values_container() const noexcept { return m_ht.values_container(); } + + template::value>::type* = nullptr> + size_type capacity() const noexcept { return m_ht.capacity(); } + + void shrink_to_fit() { m_ht.shrink_to_fit(); } + + + + /** + * Insert the value before pos shifting all the elements on the right of pos (including pos) one position + * to the right. + * + * Amortized linear time-complexity in the distance between pos and end(). + */ + std::pair insert_at_position(const_iterator pos, const value_type& value) { + return m_ht.insert_at_position(pos, value); + } + + /** + * @copydoc insert_at_position(const_iterator pos, const value_type& value) + */ + std::pair insert_at_position(const_iterator pos, value_type&& value) { + return m_ht.insert_at_position(pos, std::move(value)); + } + + /** + * @copydoc insert_at_position(const_iterator pos, const value_type& value) + * + * Same as insert_at_position(pos, value_type(std::forward(args)...), mainly + * here for coherence. + */ + template + std::pair emplace_at_position(const_iterator pos, Args&&... args) { + return m_ht.emplace_at_position(pos, std::forward(args)...); + } + + + + void pop_back() { m_ht.pop_back(); } + + /** + * Faster erase operation with an O(1) average complexity but it doesn't preserve the insertion order. + * + * If an erasure occurs, the last element of the map will take the place of the erased element. + */ + iterator unordered_erase(iterator pos) { return m_ht.unordered_erase(pos); } + + /** + * @copydoc unordered_erase(iterator pos) + */ + iterator unordered_erase(const_iterator pos) { return m_ht.unordered_erase(pos); } + + /** + * @copydoc unordered_erase(iterator pos) + */ + size_type unordered_erase(const key_type& key) { return m_ht.unordered_erase(key); } + + /** + * @copydoc unordered_erase(iterator pos) + * + * Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same + * as hash_function()(key). Useful to speed-up the lookup if you already have the hash. + */ + size_type unordered_erase(const key_type& key, std::size_t precalculated_hash) { + return m_ht.unordered_erase(key, precalculated_hash); + } + + /** + * @copydoc unordered_erase(iterator pos) + * + * This overload only participates in the overload resolution if the typedef KeyEqual::is_transparent exists. + * If so, K must be hashable and comparable to Key. + */ + template::value>::type* = nullptr> + size_type unordered_erase(const K& key) { return m_ht.unordered_erase(key); } + + /** + * @copydoc unordered_erase(const K& key) + * + * Use the hash value 'precalculated_hash' instead of hashing the key. The hash value should be the same + * as hash_function()(key). Useful to speed-up the lookup if you already have the hash. + */ + template::value>::type* = nullptr> + size_type unordered_erase(const K& key, std::size_t precalculated_hash) { + return m_ht.unordered_erase(key, precalculated_hash); + } + + /** + * Serialize the set through the `serializer` parameter. + * + * The `serializer` parameter must be a function object that supports the following call: + * - `void operator()(const U& value);` where the types `std::uint64_t`, `float` and `Key` must be supported for U. + * + * The implementation leaves binary compatibility (endianness, IEEE 754 for floats, ...) of the types it serializes + * in the hands of the `Serializer` function object if compatibility is required. + */ + template + void serialize(Serializer& serializer) const { + m_ht.serialize(serializer); + } + + /** + * Deserialize a previously serialized set through the `deserializer` parameter. + * + * The `deserializer` parameter must be a function object that supports the following calls: + * - `template U operator()();` where the types `std::uint64_t`, `float` and `Key` must be supported for U. + * + * If the deserialized hash set type is hash compatible with the serialized set, the deserialization process can be + * sped up by setting `hash_compatible` to true. To be hash compatible, the Hash and KeyEqual must behave the same way + * than the ones used on the serialized map. The `std::size_t` must also be of the same size as the one on the platform used + * to serialize the map, the same apply for `IndexType`. If these criteria are not met, the behaviour is undefined with + * `hash_compatible` sets to true. + * + * The behaviour is undefined if the type `Key` of the `ordered_set` is not the same as the + * type used during serialization. + * + * The implementation leaves binary compatibility (endianness, IEEE 754 for floats, size of int, ...) of the types it + * deserializes in the hands of the `Deserializer` function object if compatibility is required. + */ + template + static ordered_set deserialize(Deserializer& deserializer, bool hash_compatible = false) { + ordered_set set(0); + set.m_ht.deserialize(deserializer, hash_compatible); + + return set; + } + + + + friend bool operator==(const ordered_set& lhs, const ordered_set& rhs) { return lhs.m_ht == rhs.m_ht; } + friend bool operator!=(const ordered_set& lhs, const ordered_set& rhs) { return lhs.m_ht != rhs.m_ht; } + friend bool operator<(const ordered_set& lhs, const ordered_set& rhs) { return lhs.m_ht < rhs.m_ht; } + friend bool operator<=(const ordered_set& lhs, const ordered_set& rhs) { return lhs.m_ht <= rhs.m_ht; } + friend bool operator>(const ordered_set& lhs, const ordered_set& rhs) { return lhs.m_ht > rhs.m_ht; } + friend bool operator>=(const ordered_set& lhs, const ordered_set& rhs) { return lhs.m_ht >= rhs.m_ht; } + + friend void swap(ordered_set& lhs, ordered_set& rhs) { lhs.swap(rhs); } + +private: + ht m_ht; +}; + +} // end namespace tsl + +#endif From 7736312c2f361512ab841f852c1b18349abd6d3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Tue, 4 Aug 2020 01:33:31 +0200 Subject: [PATCH 284/316] ShaderNodes: Replace union by std::variant --- include/Nazara/Renderer/ShaderNodes.hpp | 23 +++++-------- include/Nazara/Renderer/ShaderNodes.inl | 42 ++---------------------- src/Nazara/Renderer/GlslWriter.cpp | 39 +++++++++------------- src/Nazara/Renderer/ShaderNodes.cpp | 19 ++++++++++- src/Nazara/Renderer/ShaderSerializer.cpp | 39 +++++++++++----------- 5 files changed, 66 insertions(+), 96 deletions(-) diff --git a/include/Nazara/Renderer/ShaderNodes.hpp b/include/Nazara/Renderer/ShaderNodes.hpp index 0c5049df9..0b6daec79 100644 --- a/include/Nazara/Renderer/ShaderNodes.hpp +++ b/include/Nazara/Renderer/ShaderNodes.hpp @@ -220,22 +220,17 @@ namespace Nz ShaderExpressionType GetExpressionType() const override; void Visit(ShaderVisitor& visitor) override; - BasicType exprType; + using Variant = std::variant< + bool, + float, + Vector2f, + Vector3f, + Vector4f + >; - union - { - bool bool1; - float vec1; - Vector2f vec2; - Vector3f vec3; - Vector4f vec4; - } values; + Variant value; - static inline std::shared_ptr Build(bool value); - static inline std::shared_ptr Build(float value); - static inline std::shared_ptr Build(const Vector2f& value); - static inline std::shared_ptr Build(const Vector3f& value); - static inline std::shared_ptr Build(const Vector4f& value); + template static std::shared_ptr Build(const T& value); }; struct NAZARA_RENDERER_API SwizzleOp : public Expression diff --git a/include/Nazara/Renderer/ShaderNodes.inl b/include/Nazara/Renderer/ShaderNodes.inl index 606487e0c..27d387bcd 100644 --- a/include/Nazara/Renderer/ShaderNodes.inl +++ b/include/Nazara/Renderer/ShaderNodes.inl @@ -239,47 +239,11 @@ namespace Nz::ShaderNodes { } - inline std::shared_ptr Constant::Build(bool value) + template + std::shared_ptr Nz::ShaderNodes::Constant::Build(const T& value) { auto node = std::make_shared(); - node->exprType = BasicType::Boolean; - node->values.bool1 = value; - - return node; - } - - inline std::shared_ptr Constant::Build(float value) - { - auto node = std::make_shared(); - node->exprType = BasicType::Float1; - node->values.vec1 = value; - - return node; - } - - inline std::shared_ptr Constant::Build(const Vector2f& value) - { - auto node = std::make_shared(); - node->exprType = BasicType::Float2; - node->values.vec2 = value; - - return node; - } - - inline std::shared_ptr Constant::Build(const Vector3f& value) - { - auto node = std::make_shared(); - node->exprType = BasicType::Float3; - node->values.vec3 = value; - - return node; - } - - inline std::shared_ptr Constant::Build(const Vector4f& value) - { - auto node = std::make_shared(); - node->exprType = BasicType::Float4; - node->values.vec4 = value; + node->value = value; return node; } diff --git a/src/Nazara/Renderer/GlslWriter.cpp b/src/Nazara/Renderer/GlslWriter.cpp index 3f2a4a4a3..fcb1847a7 100644 --- a/src/Nazara/Renderer/GlslWriter.cpp +++ b/src/Nazara/Renderer/GlslWriter.cpp @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include #include #include @@ -426,31 +427,23 @@ namespace Nz void GlslWriter::Visit(const ShaderNodes::Constant& node) { - switch (node.exprType) + std::visit([&](auto&& arg) { - case ShaderNodes::BasicType::Boolean: - Append((node.values.bool1) ? "true" : "false"); - break; + using T = std::decay_t; - case ShaderNodes::BasicType::Float1: - Append(std::to_string(node.values.vec1)); - break; - - case ShaderNodes::BasicType::Float2: - Append("vec2(" + std::to_string(node.values.vec2.x) + ", " + std::to_string(node.values.vec2.y) + ")"); - break; - - case ShaderNodes::BasicType::Float3: - Append("vec3(" + std::to_string(node.values.vec3.x) + ", " + std::to_string(node.values.vec3.y) + ", " + std::to_string(node.values.vec3.z) + ")"); - break; - - case ShaderNodes::BasicType::Float4: - Append("vec4(" + std::to_string(node.values.vec4.x) + ", " + std::to_string(node.values.vec4.y) + ", " + std::to_string(node.values.vec4.z) + ", " + std::to_string(node.values.vec4.w) + ")"); - break; - - default: - throw std::runtime_error("Unhandled expression type"); - } + if constexpr (std::is_same_v) + Append((arg) ? "true" : "false"); + else if constexpr (std::is_same_v) + Append(std::to_string(arg)); + else if constexpr (std::is_same_v) + Append("vec2(" + std::to_string(arg.x) + ", " + std::to_string(arg.y) + ")"); + else if constexpr (std::is_same_v) + Append("vec3(" + std::to_string(arg.x) + ", " + std::to_string(arg.y) + ", " + std::to_string(arg.z) + ")"); + else if constexpr (std::is_same_v) + Append("vec4(" + std::to_string(arg.x) + ", " + std::to_string(arg.y) + ", " + std::to_string(arg.z) + ", " + std::to_string(arg.w) + ")"); + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + }, node.value); } void GlslWriter::Visit(const ShaderNodes::DeclareVariable& node) diff --git a/src/Nazara/Renderer/ShaderNodes.cpp b/src/Nazara/Renderer/ShaderNodes.cpp index ddf5e09c7..da2157826 100644 --- a/src/Nazara/Renderer/ShaderNodes.cpp +++ b/src/Nazara/Renderer/ShaderNodes.cpp @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include #include #include @@ -150,7 +151,23 @@ namespace Nz::ShaderNodes ShaderExpressionType Constant::GetExpressionType() const { - return exprType; + return std::visit([&](auto&& arg) + { + using T = std::decay_t; + + if constexpr (std::is_same_v) + return ShaderNodes::BasicType::Boolean; + else if constexpr (std::is_same_v) + return ShaderNodes::BasicType::Float1; + else if constexpr (std::is_same_v) + return ShaderNodes::BasicType::Float2; + else if constexpr (std::is_same_v) + return ShaderNodes::BasicType::Float3; + else if constexpr (std::is_same_v) + return ShaderNodes::BasicType::Float4; + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + }, value); } void Constant::Visit(ShaderVisitor& visitor) diff --git a/src/Nazara/Renderer/ShaderSerializer.cpp b/src/Nazara/Renderer/ShaderSerializer.cpp index 7441162a0..2433bf070 100644 --- a/src/Nazara/Renderer/ShaderSerializer.cpp +++ b/src/Nazara/Renderer/ShaderSerializer.cpp @@ -178,29 +178,30 @@ namespace Nz void ShaderSerializerBase::Serialize(ShaderNodes::Constant& node) { - Enum(node.exprType); + UInt32 typeIndex; + if (IsWriting()) + typeIndex = UInt32(node.value.index()); - switch (node.exprType) + Value(typeIndex); + + // Waiting for template lambda in C++20 + auto SerializeValue = [&](auto dummyType) { - case ShaderNodes::BasicType::Boolean: - Value(node.values.bool1); - break; + using T = std::decay_t; - case ShaderNodes::BasicType::Float1: - Value(node.values.vec1); - break; + auto& value = (IsWriting()) ? std::get(node.value) : node.value.emplace(); + Value(value); + }; - case ShaderNodes::BasicType::Float2: - Value(node.values.vec2); - break; - - case ShaderNodes::BasicType::Float3: - Value(node.values.vec3); - break; - - case ShaderNodes::BasicType::Float4: - Value(node.values.vec4); - break; + static_assert(std::variant_size_v == 5); + switch (typeIndex) + { + case 0: SerializeValue(bool()); break; + case 1: SerializeValue(float()); break; + case 2: SerializeValue(Vector2f()); break; + case 3: SerializeValue(Vector3f()); break; + case 4: SerializeValue(Vector4f()); break; + default: throw std::runtime_error("unexpected data type"); } } From 7fd3264d0823be72f25b03abcb634c9a323fb393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Tue, 4 Aug 2020 01:33:52 +0200 Subject: [PATCH 285/316] Add FieldOffsets class --- include/Nazara/Utility/Enums.hpp | 34 +++++ include/Nazara/Utility/FieldOffsets.hpp | 52 ++++++++ include/Nazara/Utility/FieldOffsets.inl | 169 ++++++++++++++++++++++++ src/Nazara/Utility/FieldOffsets.cpp | 101 ++++++++++++++ 4 files changed, 356 insertions(+) create mode 100644 include/Nazara/Utility/FieldOffsets.hpp create mode 100644 include/Nazara/Utility/FieldOffsets.inl create mode 100644 src/Nazara/Utility/FieldOffsets.cpp diff --git a/include/Nazara/Utility/Enums.hpp b/include/Nazara/Utility/Enums.hpp index 7ac18a697..0e652448e 100644 --- a/include/Nazara/Utility/Enums.hpp +++ b/include/Nazara/Utility/Enums.hpp @@ -309,6 +309,40 @@ namespace Nz SamplerWrap_Max = SamplerWrap_Repeat }; + enum StructFieldType + { + StructFieldType_Bool1, + StructFieldType_Bool2, + StructFieldType_Bool3, + StructFieldType_Bool4, + StructFieldType_Float1, + StructFieldType_Float2, + StructFieldType_Float3, + StructFieldType_Float4, + StructFieldType_Double1, + StructFieldType_Double2, + StructFieldType_Double3, + StructFieldType_Double4, + StructFieldType_Int1, + StructFieldType_Int2, + StructFieldType_Int3, + StructFieldType_Int4, + StructFieldType_UInt1, + StructFieldType_UInt2, + StructFieldType_UInt3, + StructFieldType_UInt4, + + StructFieldType_Max = StructFieldType_UInt4 + }; + + enum StructLayout + { + StructLayout_Packed, + StructLayout_Std140, + + StructLayout_Max = StructLayout_Std140 + }; + enum StencilOperation { StencilOperation_Decrement, diff --git a/include/Nazara/Utility/FieldOffsets.hpp b/include/Nazara/Utility/FieldOffsets.hpp new file mode 100644 index 000000000..7cdeb83a9 --- /dev/null +++ b/include/Nazara/Utility/FieldOffsets.hpp @@ -0,0 +1,52 @@ +// Copyright (C) 2019 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_FIELDOFFSETS_HPP +#define NAZARA_FIELDOFFSETS_HPP + +#include +#include + +namespace Nz +{ + class NAZARA_UTILITY_API FieldOffsets + { + public: + inline FieldOffsets(StructLayout layout); + FieldOffsets(const FieldOffsets&) = default; + FieldOffsets(FieldOffsets&&) = default; + ~FieldOffsets() = default; + + std::size_t AddField(StructFieldType type); + std::size_t AddFieldArray(StructFieldType type, std::size_t arraySize); + std::size_t AddMatrix(StructFieldType cellType, unsigned int columns, unsigned int rows, bool columnMajor); + std::size_t AddMatrixArray(StructFieldType cellType, unsigned int columns, unsigned int rows, bool columnMajor, std::size_t arraySize); + std::size_t AddStruct(const FieldOffsets& fieldStruct); + std::size_t AddStructArray(const FieldOffsets& fieldStruct, std::size_t arraySize); + + inline std::size_t GetLargestFieldAlignement() const; + inline std::size_t GetSize() const; + + FieldOffsets& operator=(const FieldOffsets&) = default; + FieldOffsets& operator=(FieldOffsets&&) = default; + + static std::size_t GetAlignement(StructLayout layout, StructFieldType fieldType); + static std::size_t GetCount(StructFieldType fieldType); + static std::size_t GetSize(StructFieldType fieldType); + + private: + static inline std::size_t Align(std::size_t source, std::size_t alignment); + + std::size_t m_largestFieldAlignment; + std::size_t m_offsetRounding; + std::size_t m_size; + StructLayout m_layout; + }; +} + +#include + +#endif // NAZARA_FIELDOFFSETS_HPP diff --git a/include/Nazara/Utility/FieldOffsets.inl b/include/Nazara/Utility/FieldOffsets.inl new file mode 100644 index 000000000..899e6a241 --- /dev/null +++ b/include/Nazara/Utility/FieldOffsets.inl @@ -0,0 +1,169 @@ +// Copyright (C) 2019 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include + +namespace Nz +{ + inline FieldOffsets::FieldOffsets(StructLayout layout) : + m_largestFieldAlignment(1), + m_offsetRounding(1), + m_size(0), + m_layout(layout) + { + } + + inline std::size_t FieldOffsets::GetLargestFieldAlignement() const + { + return m_largestFieldAlignment; + } + + inline std::size_t FieldOffsets::GetSize() const + { + return m_size; + } + + inline std::size_t FieldOffsets::GetAlignement(StructLayout layout, StructFieldType fieldType) + { + switch (layout) + { + case StructLayout_Packed: + return 1; + + case StructLayout_Std140: + { + switch (fieldType) + { + case StructFieldType_Bool1: + case StructFieldType_Float1: + case StructFieldType_Int1: + case StructFieldType_UInt1: + return 4; + + case StructFieldType_Bool2: + case StructFieldType_Float2: + case StructFieldType_Int2: + case StructFieldType_UInt2: + return 2 * 4; + + case StructFieldType_Bool3: + case StructFieldType_Float3: + case StructFieldType_Int3: + case StructFieldType_UInt3: + case StructFieldType_Bool4: + case StructFieldType_Float4: + case StructFieldType_Int4: + case StructFieldType_UInt4: + return 4 * 4; + + case StructFieldType_Double1: + return 8; + + case StructFieldType_Double2: + return 2 * 8; + + case StructFieldType_Double3: + case StructFieldType_Double4: + return 4 * 8; + } + } + } + + return 0; + } + + inline std::size_t FieldOffsets::GetCount(StructFieldType fieldType) + { + switch (fieldType) + { + case StructFieldType_Bool1: + case StructFieldType_Double1: + case StructFieldType_Float1: + case StructFieldType_Int1: + case StructFieldType_UInt1: + return 1; + + case StructFieldType_Bool2: + case StructFieldType_Double2: + case StructFieldType_Float2: + case StructFieldType_Int2: + case StructFieldType_UInt2: + return 2; + + case StructFieldType_Bool3: + case StructFieldType_Double3: + case StructFieldType_Float3: + case StructFieldType_Int3: + case StructFieldType_UInt3: + return 3; + + case StructFieldType_Bool4: + case StructFieldType_Double4: + case StructFieldType_Float4: + case StructFieldType_Int4: + case StructFieldType_UInt4: + return 4; + } + + return 0; + } + + inline std::size_t FieldOffsets::GetSize(StructFieldType fieldType) + { + switch (fieldType) + { + case StructFieldType_Bool1: + case StructFieldType_Float1: + case StructFieldType_Int1: + case StructFieldType_UInt1: + return 4; + + case StructFieldType_Bool2: + case StructFieldType_Float2: + case StructFieldType_Int2: + case StructFieldType_UInt2: + return 2 * 4; + + case StructFieldType_Bool3: + case StructFieldType_Float3: + case StructFieldType_Int3: + case StructFieldType_UInt3: + return 3 * 4; + + case StructFieldType_Bool4: + case StructFieldType_Float4: + case StructFieldType_Int4: + case StructFieldType_UInt4: + return 4 * 4; + + case StructFieldType_Double1: + return 8; + + case StructFieldType_Double2: + return 2 * 8; + + case StructFieldType_Double3: + return 3 * 8; + + case StructFieldType_Double4: + return 4 * 8; + } + + return 0; + } + + inline std::size_t FieldOffsets::Align(std::size_t source, std::size_t alignment) + { + if (source == 0) + return source; + + assert(alignment > 0); + return ((source + alignment - 1) / alignment) * alignment; + } +} + +#include diff --git a/src/Nazara/Utility/FieldOffsets.cpp b/src/Nazara/Utility/FieldOffsets.cpp new file mode 100644 index 000000000..76cb50e71 --- /dev/null +++ b/src/Nazara/Utility/FieldOffsets.cpp @@ -0,0 +1,101 @@ +// Copyright (C) 2019 Jérôme Leclercq +// This file is part of the "Nazara Engine - Utility module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include + +namespace Nz +{ + std::size_t FieldOffsets::AddField(StructFieldType type) + { + std::size_t fieldAlignement = GetAlignement(m_layout, type); + + m_largestFieldAlignment = std::max(m_largestFieldAlignment, fieldAlignement); + + std::size_t offset = Align(m_size, Align(fieldAlignement, m_offsetRounding)); + m_size = offset + GetSize(type); + + m_offsetRounding = 1; + + return offset; + } + + std::size_t FieldOffsets::AddFieldArray(StructFieldType type, std::size_t arraySize) + { + std::size_t fieldAlignement = GetAlignement(m_layout, type); + if (m_layout == StructLayout_Std140) + fieldAlignement = Align(fieldAlignement, GetAlignement(StructLayout_Std140, StructFieldType_Float4)); + + m_largestFieldAlignment = std::max(fieldAlignement, m_largestFieldAlignment); + + std::size_t offset = Align(m_size, Align(fieldAlignement, m_offsetRounding)); + m_size = offset + GetSize(type) * arraySize; + + m_offsetRounding = 1; + + return offset; + } + + std::size_t FieldOffsets::AddMatrix(StructFieldType cellType, unsigned int columns, unsigned int rows, bool columnMajor) + { + assert(GetCount(cellType) == 1); + assert(columns >= 2 && columns <= 4); + assert(rows >= 2 && rows <= 4); + + if (columnMajor) + return AddFieldArray(static_cast(cellType + rows - 1), columns); + else + return AddFieldArray(static_cast(cellType + columns - 1), rows); + } + + std::size_t FieldOffsets::AddMatrixArray(StructFieldType cellType, unsigned int columns, unsigned int rows, bool columnMajor, std::size_t arraySize) + { + assert(GetCount(cellType) == 1); + assert(columns >= 2 && columns <= 4); + assert(rows >= 2 && rows <= 4); + + if (columnMajor) + return AddFieldArray(static_cast(cellType + rows - 1), columns * arraySize); + else + return AddFieldArray(static_cast(cellType + columns - 1), rows * arraySize); + } + + std::size_t FieldOffsets::AddStruct(const FieldOffsets& fieldStruct) + { + std::size_t fieldAlignement = fieldStruct.GetLargestFieldAlignement(); + if (m_layout == StructLayout_Std140) + fieldAlignement = Align(fieldAlignement, GetAlignement(StructLayout_Std140, StructFieldType_Float4)); + + m_largestFieldAlignment = std::max(m_largestFieldAlignment, fieldAlignement); + + std::size_t offset = Align(m_size, Align(fieldAlignement, m_offsetRounding)); + m_size = offset + fieldStruct.GetSize(); + + m_offsetRounding = std::max(Align(fieldStruct.GetSize(), fieldAlignement) - fieldStruct.GetSize(), 1); + + return offset; + } + + std::size_t FieldOffsets::AddStructArray(const FieldOffsets& fieldStruct, std::size_t arraySize) + { + assert(arraySize > 0); + + std::size_t fieldAlignement = fieldStruct.GetLargestFieldAlignement(); + if (m_layout == StructLayout_Std140) + fieldAlignement = Align(fieldAlignement, GetAlignement(StructLayout_Std140, StructFieldType_Float4)); + + m_largestFieldAlignment = std::max(m_largestFieldAlignment, fieldAlignement); + + std::size_t offset = Align(m_size, Align(fieldAlignement, m_offsetRounding)); + m_size = offset + + fieldStruct.GetSize() * arraySize + + (Align(fieldStruct.GetSize(), fieldAlignement) - fieldStruct.GetSize()) * (arraySize - 1); + + m_offsetRounding = fieldAlignement; + + return offset; + } +} From 7a5f91f74089c39f0ebeacfc607374b542eeefc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Tue, 4 Aug 2020 01:35:30 +0200 Subject: [PATCH 286/316] SpivWriter WIP We have debug label, annotations, types and constants. The big part missing is instructions --- include/Nazara/Renderer/SpirvWriter.hpp | 51 +- include/Nazara/Renderer/SpirvWriter.inl | 37 +- src/Nazara/Renderer/SpirvWriter.cpp | 682 +++++++++++++++++++----- 3 files changed, 594 insertions(+), 176 deletions(-) diff --git a/include/Nazara/Renderer/SpirvWriter.hpp b/include/Nazara/Renderer/SpirvWriter.hpp index e95bc5a4e..5786ea55b 100644 --- a/include/Nazara/Renderer/SpirvWriter.hpp +++ b/include/Nazara/Renderer/SpirvWriter.hpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -41,33 +42,49 @@ namespace Nz private: struct Opcode; + struct Raw; + struct WordCount; - inline std::size_t Append(const char* str); - inline std::size_t Append(const std::string_view& str); - inline std::size_t Append(const std::string& str); - std::size_t Append(UInt32 value); - std::size_t Append(const Opcode& opcode, unsigned int wordCount); - inline std::size_t Append(std::initializer_list codepoints); - template std::size_t Append(Opcode opcode, const Args&... args); - template std::size_t Append(T value); + struct Section + { + inline std::size_t Append(const char* str); + inline std::size_t Append(const std::string_view& str); + inline std::size_t Append(const std::string& str); + inline std::size_t Append(UInt32 value); + std::size_t Append(const Opcode& opcode, const WordCount& wordCount); + std::size_t Append(const Raw& raw); + inline std::size_t Append(std::initializer_list codepoints); + template std::size_t Append(Opcode opcode, const Args&... args); + template std::size_t Append(T value); + + inline unsigned int CountWord(const char* str); + inline unsigned int CountWord(const std::string_view& str); + inline unsigned int CountWord(const std::string& str); + unsigned int CountWord(const Raw& raw); + template unsigned int CountWord(const T& value); + template unsigned int CountWord(const T1& value, const T2& value2, const Args&... rest); + + inline std::size_t GetOutputOffset() const; + + std::vector data; + }; UInt32 AllocateResultId(); + void AppendConstants(); void AppendHeader(); + void AppendStructType(std::size_t structIndex, UInt32 resultId); void AppendTypes(); - inline unsigned int CountWord(const char* str); - unsigned int CountWord(const std::string_view& str); - inline unsigned int CountWord(const std::string& str); - template unsigned int CountWord(const T& value); - template unsigned int CountWord(const T1& value, const T2& value2, const Args&... rest); + UInt32 GetConstantId(const ShaderNodes::Constant::Variant& value) const; + UInt32 GetTypeId(const ShaderExpressionType& type) const; - std::size_t GetOutputOffset() const; + void PushResultId(UInt32 value); + UInt32 PopResultId(); - UInt32 ProcessType(ShaderExpressionType type); + UInt32 RegisterType(ShaderExpressionType type); using ShaderVisitor::Visit; - void Visit(const ShaderNodes::ExpressionPtr& expr, bool encloseIfRequired = false); void Visit(const ShaderNodes::AccessMember& node) override; void Visit(const ShaderNodes::AssignOp& node) override; void Visit(const ShaderNodes::Branch& node) override; @@ -82,7 +99,7 @@ namespace Nz void Visit(const ShaderNodes::StatementBlock& node) override; void Visit(const ShaderNodes::SwizzleOp& node) override; - static void MergeBlocks(std::vector& output, const std::vector& from); + static void MergeBlocks(std::vector& output, const Section& from); struct Context { diff --git a/include/Nazara/Renderer/SpirvWriter.inl b/include/Nazara/Renderer/SpirvWriter.inl index 5d0bbd328..2e75f1271 100644 --- a/include/Nazara/Renderer/SpirvWriter.inl +++ b/include/Nazara/Renderer/SpirvWriter.inl @@ -9,12 +9,12 @@ namespace Nz { - inline std::size_t SpirvWriter::Append(const char* str) + inline std::size_t SpirvWriter::Section::Append(const char* str) { return Append(std::string_view(str)); } - inline std::size_t SpirvWriter::Append(const std::string_view& str) + inline std::size_t SpirvWriter::Section::Append(const std::string_view& str) { std::size_t offset = GetOutputOffset(); @@ -35,12 +35,20 @@ namespace Nz return offset; } - inline std::size_t SpirvWriter::Append(const std::string& str) + inline std::size_t SpirvWriter::Section::Append(const std::string& str) { return Append(std::string_view(str)); } - inline std::size_t SpirvWriter::Append(std::initializer_list codepoints) + inline std::size_t SpirvWriter::Section::Append(UInt32 value) + { + std::size_t offset = GetOutputOffset(); + data.push_back(value); + + return offset; + } + + inline std::size_t SpirvWriter::Section::Append(std::initializer_list codepoints) { std::size_t offset = GetOutputOffset(); @@ -51,10 +59,10 @@ namespace Nz } template - inline std::size_t SpirvWriter::Append(Opcode opcode, const Args&... args) + std::size_t SpirvWriter::Section::Append(Opcode opcode, const Args&... args) { unsigned int wordCount = 1 + (CountWord(args) + ... + 0); - std::size_t offset = Append(opcode, wordCount); + std::size_t offset = Append(opcode, WordCount{ wordCount }); if constexpr (sizeof...(args) > 0) (Append(args), ...); @@ -62,37 +70,42 @@ namespace Nz } template - inline std::size_t SpirvWriter::Append(T value) + std::size_t SpirvWriter::Section::Append(T value) { return Append(static_cast(value)); } template - inline unsigned int SpirvWriter::CountWord(const T& value) + unsigned int SpirvWriter::Section::CountWord(const T& value) { return 1; } template - unsigned int SpirvWriter::CountWord(const T1& value, const T2& value2, const Args&... rest) + unsigned int SpirvWriter::Section::CountWord(const T1& value, const T2& value2, const Args&... rest) { return CountWord(value) + CountWord(value2) + (CountWord(rest) + ...); } - inline unsigned int SpirvWriter::CountWord(const char* str) + inline unsigned int SpirvWriter::Section::CountWord(const char* str) { return CountWord(std::string_view(str)); } - inline unsigned int Nz::SpirvWriter::CountWord(const std::string& str) + inline unsigned int Nz::SpirvWriter::Section::CountWord(const std::string& str) { return CountWord(std::string_view(str)); } - inline unsigned int SpirvWriter::CountWord(const std::string_view& str) + inline unsigned int SpirvWriter::Section::CountWord(const std::string_view& str) { return (static_cast(str.size() + 1) + sizeof(UInt32) - 1) / sizeof(UInt32); //< + 1 for null character } + + std::size_t SpirvWriter::Section::GetOutputOffset() const + { + return data.size(); + } } #include diff --git a/src/Nazara/Renderer/SpirvWriter.cpp b/src/Nazara/Renderer/SpirvWriter.cpp index 24d9fcd84..1ccf23f97 100644 --- a/src/Nazara/Renderer/SpirvWriter.cpp +++ b/src/Nazara/Renderer/SpirvWriter.cpp @@ -4,8 +4,10 @@ #include #include +#include #include #include +#include #include #include #include @@ -18,10 +20,13 @@ namespace Nz { namespace { + using ConstantVariant = ShaderNodes::Constant::Variant; + class PreVisitor : public ShaderRecursiveVisitor, public ShaderVarVisitor { public: using BuiltinContainer = std::unordered_set>; + using ConstantContainer = tsl::ordered_set; using ExtInstList = std::unordered_set; using LocalContainer = std::unordered_set>; using ParameterContainer = std::unordered_set< std::shared_ptr>; @@ -29,14 +34,55 @@ namespace Nz using ShaderRecursiveVisitor::Visit; using ShaderVarVisitor::Visit; + void Visit(const ShaderNodes::Constant& node) override + { + std::visit([&](auto&& arg) + { + using T = std::decay_t; + + if constexpr (std::is_same_v || std::is_same_v) + constants.emplace(arg); + else if constexpr (std::is_same_v) + { + constants.emplace(arg.x); + constants.emplace(arg.y); + constants.emplace(arg); + } + else if constexpr (std::is_same_v) + { + constants.emplace(arg.x); + constants.emplace(arg.y); + constants.emplace(arg.z); + constants.emplace(arg); + } + else if constexpr (std::is_same_v) + { + constants.emplace(arg.x); + constants.emplace(arg.y); + constants.emplace(arg.z); + constants.emplace(arg.w); + constants.emplace(arg); + } + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + }, + node.value); + + ShaderRecursiveVisitor::Visit(node); + } + void Visit(const ShaderNodes::DeclareVariable& node) override { Visit(node.variable); + + ShaderRecursiveVisitor::Visit(node); } void Visit(const ShaderNodes::Identifier& node) override { Visit(node.var); + + ShaderRecursiveVisitor::Visit(node); } void Visit(const ShaderNodes::IntrinsicCall& node) override @@ -87,6 +133,7 @@ namespace Nz } BuiltinContainer builtinVars; + ConstantContainer constants; ExtInstList extInsts; LocalContainer localVars; ParameterContainer paramVars; @@ -98,24 +145,51 @@ namespace Nz SpvOp op; }; + struct SpirvWriter::Raw + { + const void* ptr; + std::size_t size; + }; + + struct SpirvWriter::WordCount + { + unsigned int wc; + }; + struct SpirvWriter::State { - std::size_t boundIndex; + struct Func + { + UInt32 typeId; + UInt32 id; + std::vector paramsId; + }; + + struct ExtVar + { + UInt32 pointerTypeId; + UInt32 varId; + }; + std::unordered_map extensionInstructions; std::unordered_map builtinIds; + tsl::ordered_map constantIds; tsl::ordered_map typeIds; - std::vector funcIds; - std::vector funcTypeIds; - std::vector inputIds; - std::vector outputIds; - std::vector uniformIds; + std::vector funcs; + std::vector inputIds; + std::vector outputIds; + std::vector uniformIds; + std::vector> structFields; + std::vector resultIds; UInt32 nextVarIndex = 1; // Output - std::vector* output; - std::vector header; - std::vector info; - std::vector instructions; + Section header; + Section constants; + Section debugInfo; + Section annotations; + Section types; + Section instructions; }; SpirvWriter::SpirvWriter() : @@ -138,74 +212,154 @@ namespace Nz m_currentState = nullptr; }); + state.structFields.resize(shader.GetStructCount()); + state.annotations.Append(Opcode{ SpvOpNop }); + state.constants.Append(Opcode{ SpvOpNop }); + state.debugInfo.Append(Opcode{ SpvOpNop }); + state.types.Append(Opcode{ SpvOpNop }); + PreVisitor preVisitor; for (const auto& func : shader.GetFunctions()) preVisitor.Visit(func.statement); // Register all extended instruction sets for (const std::string& extInst : preVisitor.extInsts) - m_currentState->extensionInstructions[extInst] = AllocateResultId(); + state.extensionInstructions[extInst] = AllocateResultId(); // Register all types - state.output = &state.instructions; - for (const auto& func : shader.GetFunctions()) { - ProcessType(func.returnType); + RegisterType(func.returnType); for (const auto& param : func.parameters) - ProcessType(param.type); - - m_currentState->funcTypeIds.push_back(AllocateResultId()); + RegisterType(param.type); } for (const auto& input : shader.GetInputs()) - ProcessType(input.type); + RegisterType(input.type); for (const auto& output : shader.GetOutputs()) - ProcessType(output.type); + RegisterType(output.type); for (const auto& uniform : shader.GetUniforms()) - ProcessType(uniform.type); + RegisterType(uniform.type); for (const auto& local : preVisitor.localVars) - ProcessType(local->type); + RegisterType(local->type); + + // Register constant types + for (const auto& constant : preVisitor.constants) + { + std::visit([&](auto&& arg) + { + using T = std::decay_t; + + if constexpr (std::is_same_v) + RegisterType(ShaderNodes::BasicType::Boolean); + else if constexpr (std::is_same_v) + RegisterType(ShaderNodes::BasicType::Float1); + else if constexpr (std::is_same_v) + RegisterType(ShaderNodes::BasicType::Float2); + else if constexpr (std::is_same_v) + RegisterType(ShaderNodes::BasicType::Float3); + else if constexpr (std::is_same_v) + RegisterType(ShaderNodes::BasicType::Float4); + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + }, constant); + } + + AppendTypes(); // Register result id and debug infos for global variables/functions - state.output = &state.info; - for (const auto& input : shader.GetInputs()) { - UInt32 resultId = AllocateResultId(); - Append(Opcode{ SpvOpName }, resultId, input.name); + auto& inputData = state.inputIds.emplace_back(); + inputData.pointerTypeId = AllocateResultId(); + inputData.varId = AllocateResultId(); - m_currentState->inputIds.push_back(resultId); + state.debugInfo.Append(Opcode{ SpvOpName }, inputData.varId, input.name); + state.types.Append(Opcode{ SpvOpTypePointer }, inputData.pointerTypeId, SpvStorageClassInput, GetTypeId(input.type)); + state.types.Append(Opcode{ SpvOpVariable }, inputData.pointerTypeId, inputData.varId, SpvStorageClassInput); + + if (input.locationIndex) + state.annotations.Append(Opcode{ SpvOpDecorate }, inputData.varId, SpvDecorationLocation, *input.locationIndex); } for (const auto& output : shader.GetOutputs()) { - UInt32 resultId = AllocateResultId(); - Append(Opcode{ SpvOpName }, resultId, output.name); + auto& outputData = state.outputIds.emplace_back(); + outputData.pointerTypeId = AllocateResultId(); + outputData.varId = AllocateResultId(); - m_currentState->outputIds.push_back(resultId); + state.debugInfo.Append(Opcode{ SpvOpName }, outputData.varId, output.name); + state.types.Append(Opcode{ SpvOpTypePointer }, outputData.pointerTypeId, SpvStorageClassOutput, GetTypeId(output.type)); + state.types.Append(Opcode{ SpvOpVariable }, outputData.pointerTypeId, outputData.varId, SpvStorageClassOutput); + + if (output.locationIndex) + state.annotations.Append(Opcode{ SpvOpDecorate }, outputData.varId, SpvDecorationLocation, *output.locationIndex); } for (const auto& uniform : shader.GetUniforms()) { - UInt32 resultId = AllocateResultId(); - Append(Opcode{ SpvOpName }, resultId, uniform.name); + auto& uniformData = state.uniformIds.emplace_back(); + uniformData.pointerTypeId = AllocateResultId(); + uniformData.varId = AllocateResultId(); - m_currentState->uniformIds.push_back(resultId); + state.debugInfo.Append(Opcode{ SpvOpName }, uniformData.varId, uniform.name); + state.types.Append(Opcode{ SpvOpTypePointer }, uniformData.pointerTypeId, SpvStorageClassUniform, GetTypeId(uniform.type)); + state.types.Append(Opcode{ SpvOpVariable }, uniformData.pointerTypeId, uniformData.varId, SpvStorageClassUniform); + + if (uniform.bindingIndex) + { + state.annotations.Append(Opcode{ SpvOpDecorate }, uniformData.varId, SpvDecorationBinding, *uniform.bindingIndex); + state.annotations.Append(Opcode{ SpvOpDecorate }, uniformData.varId, SpvDecorationDescriptorSet, 0); + } } for (const auto& func : shader.GetFunctions()) { - UInt32 resultId = AllocateResultId(); - Append(Opcode{ SpvOpName }, resultId, func.name); + auto& funcData = state.funcs.emplace_back(); + funcData.id = AllocateResultId(); + funcData.typeId = AllocateResultId(); - m_currentState->funcIds.push_back(resultId); + state.debugInfo.Append(Opcode{ SpvOpName }, funcData.id, func.name); + + state.types.Append(Opcode{ SpvOpTypeFunction }, WordCount{ 3 + static_cast(func.parameters.size()) }); + state.types.Append(funcData.typeId); + state.types.Append(GetTypeId(func.returnType)); + + for (const auto& param : func.parameters) + state.types.Append(GetTypeId(param.type)); } - state.output = &state.header; + // Register constants + for (const auto& constant : preVisitor.constants) + state.constantIds[constant] = AllocateResultId(); + + AppendConstants(); + + for (std::size_t funcIndex = 0; funcIndex < shader.GetFunctionCount(); ++funcIndex) + { + const auto& func = shader.GetFunction(funcIndex); + + auto& funcData = state.funcs[funcIndex]; + + state.instructions.Append(Opcode{ SpvOpNop }); + + state.instructions.Append(Opcode{ SpvOpFunction }, GetTypeId(func.returnType), funcData.id, 0, funcData.typeId); + + for (const auto& param : func.parameters) + { + UInt32 paramResultId = AllocateResultId(); + funcData.paramsId.push_back(paramResultId); + + state.instructions.Append(Opcode{ SpvOpFunctionParameter }, GetTypeId(param.type), paramResultId); + } + + Visit(func.statement); + + state.instructions.Append(Opcode{ SpvOpFunctionEnd }); + } AppendHeader(); @@ -221,13 +375,12 @@ namespace Nz break; }*/ - state.header[state.boundIndex] = state.nextVarIndex; - std::vector ret; - ret.reserve(state.header.size() + state.info.size() + state.instructions.size()); - MergeBlocks(ret, state.header); - MergeBlocks(ret, state.info); + MergeBlocks(ret, state.debugInfo); + MergeBlocks(ret, state.annotations); + MergeBlocks(ret, state.types); + MergeBlocks(ret, state.constants); MergeBlocks(ret, state.instructions); return ret; @@ -238,41 +391,125 @@ namespace Nz m_environment = std::move(environment); } - std::size_t Nz::SpirvWriter::Append(UInt32 value) - { - std::size_t offset = GetOutputOffset(); - m_currentState->output->push_back(value); - - return offset; - } - - std::size_t SpirvWriter::Append(const Opcode& opcode, unsigned int wordCount) - { - return Append(UInt32(opcode.op) | UInt32(wordCount) << 16); - } - UInt32 Nz::SpirvWriter::AllocateResultId() { return m_currentState->nextVarIndex++; } + void SpirvWriter::AppendConstants() + { + for (const auto& [value, resultId] : m_currentState->constantIds) + { + UInt32 constantId = resultId; + std::visit([&](auto&& arg) + { + using T = std::decay_t; + + if constexpr (std::is_same_v) + m_currentState->constants.Append(Opcode{ (arg) ? SpvOpConstantTrue : SpvOpConstantFalse }, constantId); + else if constexpr (std::is_same_v) + m_currentState->constants.Append(Opcode{ SpvOpConstant }, GetTypeId(ShaderNodes::BasicType::Float1), constantId, Raw{ &arg, sizeof(arg) }); + else if constexpr (std::is_same_v) + m_currentState->constants.Append(Opcode{ SpvOpConstantComposite }, GetTypeId(ShaderNodes::BasicType::Float2), constantId, GetConstantId(arg.x), GetConstantId(arg.y)); + else if constexpr (std::is_same_v) + m_currentState->constants.Append(Opcode{ SpvOpConstantComposite }, GetTypeId(ShaderNodes::BasicType::Float3), constantId, GetConstantId(arg.x), GetConstantId(arg.y), GetConstantId(arg.z)); + else if constexpr (std::is_same_v) + m_currentState->constants.Append(Opcode{ SpvOpConstantComposite }, GetTypeId(ShaderNodes::BasicType::Float3), constantId, GetConstantId(arg.x), GetConstantId(arg.y), GetConstantId(arg.z), GetConstantId(arg.w)); + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + }, value); + } + } + void SpirvWriter::AppendHeader() { - Append(SpvMagicNumber); //< Spir-V magic number + m_currentState->header.Append(SpvMagicNumber); //< Spir-V magic number UInt32 version = (m_environment.spvMajorVersion << 16) | m_environment.spvMinorVersion << 8; - Append(version); //< Spir-V version number (1.0 for compatibility) - Append(0); //< Generator identifier (TODO: Register generator to Khronos) + m_currentState->header.Append(version); //< Spir-V version number (1.0 for compatibility) + m_currentState->header.Append(0); //< Generator identifier (TODO: Register generator to Khronos) - m_currentState->boundIndex = Append(0); //< Bound (ID count), will be filled later - Append(0); //< Instruction schema (required to be 0 for now) + m_currentState->header.Append(m_currentState->nextVarIndex); //< Bound (ID count) + m_currentState->header.Append(0); //< Instruction schema (required to be 0 for now) - Append(Opcode{ SpvOpCapability }, SpvCapabilityShader); + m_currentState->header.Append(Opcode{ SpvOpCapability }, SpvCapabilityShader); for (const auto& [extInst, resultId] : m_currentState->extensionInstructions) - Append(Opcode{ SpvOpExtInstImport }, resultId, extInst); + m_currentState->header.Append(Opcode{ SpvOpExtInstImport }, resultId, extInst); - Append(Opcode{ SpvOpMemoryModel }, SpvAddressingModelLogical, SpvMemoryModelGLSL450); + m_currentState->header.Append(Opcode{ SpvOpMemoryModel }, SpvAddressingModelLogical, SpvMemoryModelGLSL450); + } + + void SpirvWriter::AppendStructType(std::size_t structIndex, UInt32 resultId) + { + const ShaderAst::Struct& s = m_context.shader->GetStruct(structIndex); + + m_currentState->types.Append(Opcode{ SpvOpTypeStruct }, WordCount{ static_cast(1 + 1 + s.members.size()) }); + m_currentState->types.Append(resultId); + + m_currentState->debugInfo.Append(Opcode{ SpvOpName }, resultId, s.name); + + m_currentState->annotations.Append(Opcode{ SpvOpDecorate }, resultId, SpvDecorationBlock); + + FieldOffsets structOffsets(StructLayout_Std140); + + for (std::size_t memberIndex = 0; memberIndex < s.members.size(); ++memberIndex) + { + const auto& member = s.members[memberIndex]; + m_currentState->types.Append(GetTypeId(member.type)); + m_currentState->debugInfo.Append(Opcode{ SpvOpMemberName }, resultId, memberIndex, member.name); + + std::visit([&](auto&& arg) + { + using T = std::decay_t; + if constexpr (std::is_same_v) + { + std::size_t offset = [&] { + switch (arg) + { + case ShaderNodes::BasicType::Boolean: return structOffsets.AddField(StructFieldType_Bool1); + case ShaderNodes::BasicType::Float1: return structOffsets.AddField(StructFieldType_Float1); + case ShaderNodes::BasicType::Float2: return structOffsets.AddField(StructFieldType_Float2); + case ShaderNodes::BasicType::Float3: return structOffsets.AddField(StructFieldType_Float3); + case ShaderNodes::BasicType::Float4: return structOffsets.AddField(StructFieldType_Float4); + case ShaderNodes::BasicType::Mat4x4: return structOffsets.AddMatrix(StructFieldType_Float1, 4, 4, true); + case ShaderNodes::BasicType::Sampler2D: throw std::runtime_error("unexpected sampler2D as struct member"); + case ShaderNodes::BasicType::Void: throw std::runtime_error("unexpected void as struct member"); + } + + assert(false); + throw std::runtime_error("unhandled type"); + }(); + + m_currentState->annotations.Append(Opcode{ SpvOpMemberDecorate }, resultId, memberIndex, SpvDecorationOffset, offset); + + if (arg == ShaderNodes::BasicType::Mat4x4) + { + m_currentState->annotations.Append(Opcode{ SpvOpMemberDecorate }, resultId, memberIndex, SpvDecorationColMajor); + m_currentState->annotations.Append(Opcode{ SpvOpMemberDecorate }, resultId, memberIndex, SpvDecorationMatrixStride, 16); + } + } + else if constexpr (std::is_same_v) + { + // Register struct members type + const auto& structs = m_context.shader->GetStructs(); + auto it = std::find_if(structs.begin(), structs.end(), [&](const auto& s) { return s.name == arg; }); + if (it == structs.end()) + throw std::runtime_error("struct " + arg + " has not been defined"); + + std::size_t nestedStructIndex = std::distance(structs.begin(), it); + std::optional nestedFieldOffset = m_currentState->structFields[nestedStructIndex]; + if (!nestedFieldOffset) + throw std::runtime_error("struct dependency cycle"); + + structOffsets.AddStruct(nestedFieldOffset.value()); + } + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + }, member.type); + } + + m_currentState->structFields[structIndex] = structOffsets; } void SpirvWriter::AppendTypes() @@ -287,28 +524,127 @@ namespace Nz using T = std::decay_t; if constexpr (std::is_same_v) { - // In SPIR-V, vec3 (for example) depends on float - UInt32 depResultId; - if (ShaderNodes::Node::GetComponentCount(arg) != 1) - depResultId = ProcessType(ShaderNodes::Node::GetComponentType(arg)); - switch (arg) { case ShaderNodes::BasicType::Boolean: - Append(Opcode{ SpvOpTypeBool }, resultId); + m_currentState->types.Append(Opcode{ SpvOpTypeBool }, resultId); break; case ShaderNodes::BasicType::Float1: - Append(Opcode{ SpvOpTypeFloat }, resultId); + m_currentState->types.Append(Opcode{ SpvOpTypeFloat }, resultId, 32); break; case ShaderNodes::BasicType::Float2: case ShaderNodes::BasicType::Float3: case ShaderNodes::BasicType::Float4: + { + UInt32 vecSize = UInt32(arg) - UInt32(ShaderNodes::BasicType::Float2) + 1; + + m_currentState->types.Append(Opcode{ SpvOpTypeVector }, resultId, GetTypeId(ShaderNodes::BasicType::Float1), vecSize); + break; + } + case ShaderNodes::BasicType::Mat4x4: + { + m_currentState->types.Append(Opcode{ SpvOpTypeMatrix }, resultId, GetTypeId(ShaderNodes::BasicType::Float4), 4); + break; + } + case ShaderNodes::BasicType::Sampler2D: + { + UInt32 imageTypeId = resultId - 1; + + m_currentState->types.Append(Opcode{ SpvOpTypeImage }, imageTypeId, GetTypeId(ShaderNodes::BasicType::Float1), SpvDim2D, 0, 0, 0, 1, SpvImageFormatUnknown); + m_currentState->types.Append(Opcode{ SpvOpTypeSampledImage }, resultId, imageTypeId); + break; + } + case ShaderNodes::BasicType::Void: - Append(Opcode{ SpvOpTypeVoid }, resultId); + m_currentState->types.Append(Opcode{ SpvOpTypeVoid }, resultId); + break; + } + } + else if constexpr (std::is_same_v) + { + // Register struct members type + const auto& structs = m_context.shader->GetStructs(); + auto it = std::find_if(structs.begin(), structs.end(), [&](const auto& s) { return s.name == arg; }); + if (it == structs.end()) + throw std::runtime_error("struct " + arg + " has not been defined"); + + std::size_t structIndex = std::distance(structs.begin(), it); + AppendStructType(structIndex, resultId); + } + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + }, type); + } + } + + UInt32 SpirvWriter::GetConstantId(const ShaderNodes::Constant::Variant& value) const + { + auto typeIt = m_currentState->constantIds.find(value); + assert(typeIt != m_currentState->constantIds.end()); + + return typeIt->second; + } + + UInt32 SpirvWriter::GetTypeId(const ShaderExpressionType& type) const + { + auto typeIt = m_currentState->typeIds.find(type); + assert(typeIt != m_currentState->typeIds.end()); + + return typeIt->second; + } + + void SpirvWriter::PushResultId(UInt32 value) + { + m_currentState->resultIds.push_back(value); + } + + UInt32 SpirvWriter::PopResultId() + { + if (m_currentState->resultIds.empty()) + throw std::runtime_error("invalid operation"); + + UInt32 resultId = m_currentState->resultIds.back(); + m_currentState->resultIds.pop_back(); + + return resultId; + } + + UInt32 SpirvWriter::RegisterType(ShaderExpressionType type) + { + auto it = m_currentState->typeIds.find(type); + if (it == m_currentState->typeIds.end()) + { + // Register sub-types, if any + std::visit([&](auto&& arg) + { + using T = std::decay_t; + if constexpr (std::is_same_v) + { + switch (arg) + { + case ShaderNodes::BasicType::Boolean: + case ShaderNodes::BasicType::Float1: + case ShaderNodes::BasicType::Void: + break; //< Nothing to do + + // In SPIR-V, vec3 (for example) depends on float + case ShaderNodes::BasicType::Float2: + case ShaderNodes::BasicType::Float3: + case ShaderNodes::BasicType::Float4: + RegisterType(ShaderNodes::BasicType::Float1); + break; + + case ShaderNodes::BasicType::Mat4x4: + RegisterType(ShaderNodes::BasicType::Float4); + break; + + case ShaderNodes::BasicType::Sampler2D: + RegisterType(ShaderNodes::BasicType::Float1); + AllocateResultId(); //< Reserve a result id for the image type break; } } @@ -322,46 +658,7 @@ namespace Nz const ShaderAst::Struct& s = *it; for (const auto& member : s.members) - ProcessType(member.type); - } - else - static_assert(AlwaysFalse::value, "non-exhaustive visitor"); - }, type); - } - } - - std::size_t SpirvWriter::GetOutputOffset() const - { - assert(m_currentState); - return m_currentState->output->size(); - } - - UInt32 SpirvWriter::ProcessType(ShaderExpressionType type) - { - auto it = m_currentState->typeIds.find(type); - if (it == m_currentState->typeIds.end()) - { - // Register sub-types, if any - std::visit([&](auto&& arg) - { - using T = std::decay_t; - if constexpr (std::is_same_v) - { - // In SPIR-V, vec3 (for example) depends on float - if (ShaderNodes::Node::GetComponentCount(arg) != 1) - ProcessType(ShaderNodes::Node::GetComponentType(arg)); - } - else if constexpr (std::is_same_v) - { - // Register struct members type - const auto& structs = m_context.shader->GetStructs(); - auto it = std::find_if(structs.begin(), structs.end(), [&](const auto& s) { return s.name == arg; }); - if (it == structs.end()) - throw std::runtime_error("struct " + arg + " has not been defined"); - - const ShaderAst::Struct& s = *it; - for (const auto& member : s.members) - ProcessType(member.type); + RegisterType(member.type); } else static_assert(AlwaysFalse::value, "non-exhaustive visitor"); @@ -373,56 +670,147 @@ namespace Nz return it->second; } - void SpirvWriter::Visit(const ShaderNodes::ExpressionPtr& expr, bool encloseIfRequired) - { - } - void SpirvWriter::Visit(const ShaderNodes::AccessMember& /*node*/) - { - } - void SpirvWriter::Visit(const ShaderNodes::AssignOp& /*node*/) - { - } - void SpirvWriter::Visit(const ShaderNodes::Branch& /*node*/) - { - } - void SpirvWriter::Visit(const ShaderNodes::BinaryOp& /*node*/) + void SpirvWriter::Visit(const ShaderNodes::AccessMember& node) { + Visit(node.structExpr); } - void SpirvWriter::Visit(const ShaderNodes::Cast& /*node*/) - { - } - void SpirvWriter::Visit(const ShaderNodes::Constant& /*node*/) - { - } - void SpirvWriter::Visit(const ShaderNodes::DeclareVariable& /*node*/) - { - } - void SpirvWriter::Visit(const ShaderNodes::ExpressionStatement& /*node*/) - { - } - void SpirvWriter::Visit(const ShaderNodes::Identifier& /*node*/) + void SpirvWriter::Visit(const ShaderNodes::AssignOp& node) { + Visit(node.left); + Visit(node.right); } - void SpirvWriter::Visit(const ShaderNodes::IntrinsicCall& /*node*/) + void SpirvWriter::Visit(const ShaderNodes::Branch& node) { + throw std::runtime_error("not yet implemented"); } - void SpirvWriter::Visit(const ShaderNodes::Sample2D& /*node*/) - { - } - void SpirvWriter::Visit(const ShaderNodes::StatementBlock& /*node*/) - { - } - void SpirvWriter::Visit(const ShaderNodes::SwizzleOp& /*node*/) + void SpirvWriter::Visit(const ShaderNodes::BinaryOp& node) { + Visit(node.left); + Visit(node.right); + + UInt32 resultId = AllocateResultId(); + UInt32 leftOperand = PopResultId(); + UInt32 rightOperand = PopResultId(); + + SpvOp op = [&] { + switch (node.op) + { + case ShaderNodes::BinaryType::Add: return SpvOpFAdd; + case ShaderNodes::BinaryType::Substract: return SpvOpFSub; + case ShaderNodes::BinaryType::Multiply: return SpvOpFMul; + case ShaderNodes::BinaryType::Divide: return SpvOpFDiv; + case ShaderNodes::BinaryType::Equality: return SpvOpFOrdEqual; + } + + assert(false); + throw std::runtime_error("unexpected binary operation"); + }(); + + m_currentState->instructions.Append(Opcode{ op }, GetTypeId(ShaderNodes::BasicType::Float3), resultId, leftOperand, rightOperand); } - void SpirvWriter::MergeBlocks(std::vector& output, const std::vector& from) + void SpirvWriter::Visit(const ShaderNodes::Cast& node) + { + for (auto& expr : node.expressions) + { + if (!expr) + break; + + Visit(expr); + } + } + + void SpirvWriter::Visit(const ShaderNodes::Constant& node) + { + std::visit([&] (const auto& value) + { + PushResultId(GetConstantId(value)); + }, node.value); + } + + void SpirvWriter::Visit(const ShaderNodes::DeclareVariable& node) + { + if (node.expression) + Visit(node.expression); + } + + void SpirvWriter::Visit(const ShaderNodes::ExpressionStatement& node) + { + Visit(node.expression); + } + + void SpirvWriter::Visit(const ShaderNodes::Identifier& node) + { + PushResultId(42); + } + + void SpirvWriter::Visit(const ShaderNodes::IntrinsicCall& node) + { + for (auto& param : node.parameters) + Visit(param); + } + + void SpirvWriter::Visit(const ShaderNodes::Sample2D& node) + { + Visit(node.sampler); + Visit(node.coordinates); + } + + void SpirvWriter::Visit(const ShaderNodes::StatementBlock& node) + { + for (auto& statement : node.statements) + Visit(statement); + } + + void SpirvWriter::Visit(const ShaderNodes::SwizzleOp& node) + { + Visit(node.expression); + } + + void SpirvWriter::MergeBlocks(std::vector& output, const Section& from) { std::size_t prevSize = output.size(); - output.resize(prevSize + from.size()); - std::copy(from.begin(), from.end(), output.begin() + prevSize); + output.resize(prevSize + from.data.size()); + std::copy(from.data.begin(), from.data.end(), output.begin() + prevSize); + } + + std::size_t SpirvWriter::Section::Append(const Opcode& opcode, const WordCount& wordCount) + { + return Append(UInt32(opcode.op) | UInt32(wordCount.wc) << 16); + } + + std::size_t SpirvWriter::Section::Append(const Raw& raw) + { + std::size_t offset = GetOutputOffset(); + + const UInt8* ptr = static_cast(raw.ptr); + + std::size_t size4 = CountWord(raw); + for (std::size_t i = 0; i < size4; ++i) + { + UInt32 codepoint = 0; + for (std::size_t j = 0; j < 4; ++j) + { + std::size_t pos = i * 4 + j; + if (pos < raw.size) + codepoint |= UInt32(ptr[pos]) << (j * 8); + } + +#ifdef NAZARA_BIG_ENDIAN + SwapBytes(codepoint); +#endif + + Append(codepoint); + } + + return offset; + } + + unsigned int SpirvWriter::Section::CountWord(const Raw& raw) + { + return (raw.size + sizeof(UInt32) - 1) / sizeof(UInt32); } } From 74fb01af28bec892838f47ac14cd26cb15900cc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Tue, 4 Aug 2020 15:31:47 +0200 Subject: [PATCH 287/316] Rename a few classes --- include/Nazara/Renderer.hpp | 9 +- include/Nazara/Renderer/GlslWriter.hpp | 6 +- ...itor.hpp => ShaderAstRecursiveVisitor.hpp} | 12 +-- ...itor.inl => ShaderAstRecursiveVisitor.inl} | 2 +- ...Serializer.hpp => ShaderAstSerializer.hpp} | 24 ++--- ...Serializer.inl => ShaderAstSerializer.inl} | 20 ++-- ...erValidator.hpp => ShaderAstValidator.hpp} | 16 +-- ...erValidator.inl => ShaderAstValidator.inl} | 4 +- ...ShaderVisitor.hpp => ShaderAstVisitor.hpp} | 10 +- include/Nazara/Renderer/ShaderNodes.hpp | 32 +++--- include/Nazara/Renderer/SpirvWriter.hpp | 6 +- include/Nazara/Utility.hpp | 1 + .../OpenGLRenderer/OpenGLShaderStage.cpp | 2 +- src/Nazara/Renderer/GlslWriter.cpp | 4 +- .../Renderer/ShaderAstRecursiveVisitor.cpp | 93 ++++++++++++++++ ...Serializer.cpp => ShaderAstSerializer.cpp} | 102 +++++++++--------- ...erValidator.cpp => ShaderAstValidator.cpp} | 74 ++++++------- ...ShaderVisitor.cpp => ShaderAstVisitor.cpp} | 10 +- src/Nazara/Renderer/ShaderNodes.cpp | 32 +++--- .../Renderer/ShaderRecursiveVisitor.cpp | 93 ---------------- src/Nazara/Renderer/SpirvWriter.cpp | 14 +-- src/ShaderNode/Widgets/MainWindow.cpp | 2 +- 22 files changed, 286 insertions(+), 282 deletions(-) rename include/Nazara/Renderer/{ShaderRecursiveVisitor.hpp => ShaderAstRecursiveVisitor.hpp} (79%) rename include/Nazara/Renderer/{ShaderRecursiveVisitor.inl => ShaderAstRecursiveVisitor.inl} (82%) rename include/Nazara/Renderer/{ShaderSerializer.hpp => ShaderAstSerializer.hpp} (85%) rename include/Nazara/Renderer/{ShaderSerializer.inl => ShaderAstSerializer.inl} (74%) rename include/Nazara/Renderer/{ShaderValidator.hpp => ShaderAstValidator.hpp} (83%) rename include/Nazara/Renderer/{ShaderValidator.inl => ShaderAstValidator.inl} (72%) rename include/Nazara/Renderer/{ShaderVisitor.hpp => ShaderAstVisitor.hpp} (87%) create mode 100644 src/Nazara/Renderer/ShaderAstRecursiveVisitor.cpp rename src/Nazara/Renderer/{ShaderSerializer.cpp => ShaderAstSerializer.cpp} (81%) rename src/Nazara/Renderer/{ShaderValidator.cpp => ShaderAstValidator.cpp} (79%) rename src/Nazara/Renderer/{ShaderVisitor.cpp => ShaderAstVisitor.cpp} (55%) delete mode 100644 src/Nazara/Renderer/ShaderRecursiveVisitor.cpp diff --git a/include/Nazara/Renderer.hpp b/include/Nazara/Renderer.hpp index 32e4f43de..8271bd3c8 100644 --- a/include/Nazara/Renderer.hpp +++ b/include/Nazara/Renderer.hpp @@ -53,17 +53,20 @@ #include #include #include +#include +#include +#include +#include #include #include #include +#include #include -#include #include -#include #include #include -#include #include +#include #include #include #include diff --git a/include/Nazara/Renderer/GlslWriter.hpp b/include/Nazara/Renderer/GlslWriter.hpp index f9694a8f1..8178c73d4 100644 --- a/include/Nazara/Renderer/GlslWriter.hpp +++ b/include/Nazara/Renderer/GlslWriter.hpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include @@ -20,7 +20,7 @@ namespace Nz { - class NAZARA_RENDERER_API GlslWriter : public ShaderWriter, public ShaderVarVisitor, public ShaderVisitor + class NAZARA_RENDERER_API GlslWriter : public ShaderWriter, public ShaderVarVisitor, public ShaderAstVisitor { public: struct Environment; @@ -60,7 +60,7 @@ namespace Nz void LeaveScope(); using ShaderVarVisitor::Visit; - using ShaderVisitor::Visit; + using ShaderAstVisitor::Visit; void Visit(const ShaderNodes::ExpressionPtr& expr, bool encloseIfRequired = false); void Visit(const ShaderNodes::AccessMember& node) override; void Visit(const ShaderNodes::AssignOp& node) override; diff --git a/include/Nazara/Renderer/ShaderRecursiveVisitor.hpp b/include/Nazara/Renderer/ShaderAstRecursiveVisitor.hpp similarity index 79% rename from include/Nazara/Renderer/ShaderRecursiveVisitor.hpp rename to include/Nazara/Renderer/ShaderAstRecursiveVisitor.hpp index 0e1087a58..622c1aef0 100644 --- a/include/Nazara/Renderer/ShaderRecursiveVisitor.hpp +++ b/include/Nazara/Renderer/ShaderAstRecursiveVisitor.hpp @@ -9,17 +9,17 @@ #include #include -#include +#include namespace Nz { - class NAZARA_RENDERER_API ShaderRecursiveVisitor : public ShaderVisitor + class NAZARA_RENDERER_API ShaderAstRecursiveVisitor : public ShaderAstVisitor { public: - ShaderRecursiveVisitor() = default; - ~ShaderRecursiveVisitor() = default; + ShaderAstRecursiveVisitor() = default; + ~ShaderAstRecursiveVisitor() = default; - using ShaderVisitor::Visit; + using ShaderAstVisitor::Visit; void Visit(const ShaderNodes::AccessMember& node) override; void Visit(const ShaderNodes::AssignOp& node) override; @@ -37,6 +37,6 @@ namespace Nz }; } -#include +#include #endif diff --git a/include/Nazara/Renderer/ShaderRecursiveVisitor.inl b/include/Nazara/Renderer/ShaderAstRecursiveVisitor.inl similarity index 82% rename from include/Nazara/Renderer/ShaderRecursiveVisitor.inl rename to include/Nazara/Renderer/ShaderAstRecursiveVisitor.inl index b107f06e7..3b2c6be62 100644 --- a/include/Nazara/Renderer/ShaderRecursiveVisitor.inl +++ b/include/Nazara/Renderer/ShaderAstRecursiveVisitor.inl @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include namespace Nz diff --git a/include/Nazara/Renderer/ShaderSerializer.hpp b/include/Nazara/Renderer/ShaderAstSerializer.hpp similarity index 85% rename from include/Nazara/Renderer/ShaderSerializer.hpp rename to include/Nazara/Renderer/ShaderAstSerializer.hpp index c6596b58d..68380054c 100644 --- a/include/Nazara/Renderer/ShaderSerializer.hpp +++ b/include/Nazara/Renderer/ShaderAstSerializer.hpp @@ -17,13 +17,13 @@ namespace Nz { - class NAZARA_RENDERER_API ShaderSerializerBase + class NAZARA_RENDERER_API ShaderAstSerializerBase { public: - ShaderSerializerBase() = default; - ShaderSerializerBase(const ShaderSerializerBase&) = delete; - ShaderSerializerBase(ShaderSerializerBase&&) = delete; - ~ShaderSerializerBase() = default; + ShaderAstSerializerBase() = default; + ShaderAstSerializerBase(const ShaderAstSerializerBase&) = delete; + ShaderAstSerializerBase(ShaderAstSerializerBase&&) = delete; + ~ShaderAstSerializerBase() = default; void Serialize(ShaderNodes::AccessMember& node); void Serialize(ShaderNodes::AssignOp& node); @@ -69,11 +69,11 @@ namespace Nz template void Variable(std::shared_ptr& var); }; - class NAZARA_RENDERER_API ShaderSerializer final : public ShaderSerializerBase + class NAZARA_RENDERER_API ShaderAstSerializer final : public ShaderAstSerializerBase { public: - inline ShaderSerializer(ByteStream& stream); - ~ShaderSerializer() = default; + inline ShaderAstSerializer(ByteStream& stream); + ~ShaderAstSerializer() = default; void Serialize(const ShaderAst& shader); @@ -96,11 +96,11 @@ namespace Nz ByteStream& m_stream; }; - class NAZARA_RENDERER_API ShaderUnserializer final : public ShaderSerializerBase + class NAZARA_RENDERER_API ShaderAstUnserializer final : public ShaderAstSerializerBase { public: - ShaderUnserializer(ByteStream& stream); - ~ShaderUnserializer() = default; + ShaderAstUnserializer(ByteStream& stream); + ~ShaderAstUnserializer() = default; ShaderAst Unserialize(); @@ -126,6 +126,6 @@ namespace Nz NAZARA_RENDERER_API ShaderAst UnserializeShader(ByteStream& stream); } -#include +#include #endif diff --git a/include/Nazara/Renderer/ShaderSerializer.inl b/include/Nazara/Renderer/ShaderAstSerializer.inl similarity index 74% rename from include/Nazara/Renderer/ShaderSerializer.inl rename to include/Nazara/Renderer/ShaderAstSerializer.inl index 51187d520..dd272e1fa 100644 --- a/include/Nazara/Renderer/ShaderSerializer.inl +++ b/include/Nazara/Renderer/ShaderAstSerializer.inl @@ -2,13 +2,13 @@ // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include namespace Nz { template - void ShaderSerializerBase::Container(T& container) + void ShaderAstSerializerBase::Container(T& container) { bool isWriting = IsWriting(); @@ -23,7 +23,7 @@ namespace Nz template - void ShaderSerializerBase::Enum(T& enumVal) + void ShaderAstSerializerBase::Enum(T& enumVal) { bool isWriting = IsWriting(); @@ -37,7 +37,7 @@ namespace Nz } template - void ShaderSerializerBase::OptEnum(std::optional& optVal) + void ShaderAstSerializerBase::OptEnum(std::optional& optVal) { bool isWriting = IsWriting(); @@ -55,7 +55,7 @@ namespace Nz } template - void ShaderSerializerBase::OptVal(std::optional& optVal) + void ShaderAstSerializerBase::OptVal(std::optional& optVal) { bool isWriting = IsWriting(); @@ -73,7 +73,7 @@ namespace Nz } template - void ShaderSerializerBase::Node(std::shared_ptr& node) + void ShaderAstSerializerBase::Node(std::shared_ptr& node) { bool isWriting = IsWriting(); @@ -87,7 +87,7 @@ namespace Nz } template - void ShaderSerializerBase::Variable(std::shared_ptr& var) + void ShaderAstSerializerBase::Variable(std::shared_ptr& var) { bool isWriting = IsWriting(); @@ -100,7 +100,7 @@ namespace Nz var = std::static_pointer_cast(value); } - inline void ShaderSerializerBase::Value(std::size_t& val) + inline void ShaderAstSerializerBase::Value(std::size_t& val) { bool isWriting = IsWriting(); @@ -113,12 +113,12 @@ namespace Nz val = static_cast(value); } - inline ShaderSerializer::ShaderSerializer(ByteStream& stream) : + inline ShaderAstSerializer::ShaderAstSerializer(ByteStream& stream) : m_stream(stream) { } - inline ShaderUnserializer::ShaderUnserializer(ByteStream& stream) : + inline ShaderAstUnserializer::ShaderAstUnserializer(ByteStream& stream) : m_stream(stream) { } diff --git a/include/Nazara/Renderer/ShaderValidator.hpp b/include/Nazara/Renderer/ShaderAstValidator.hpp similarity index 83% rename from include/Nazara/Renderer/ShaderValidator.hpp rename to include/Nazara/Renderer/ShaderAstValidator.hpp index edf54370f..aa586f99b 100644 --- a/include/Nazara/Renderer/ShaderValidator.hpp +++ b/include/Nazara/Renderer/ShaderAstValidator.hpp @@ -12,18 +12,18 @@ #include #include #include -#include +#include #include namespace Nz { - class NAZARA_RENDERER_API ShaderValidator : public ShaderRecursiveVisitor, public ShaderVarVisitor + class NAZARA_RENDERER_API ShaderAstValidator : public ShaderAstRecursiveVisitor, public ShaderVarVisitor { public: - inline ShaderValidator(const ShaderAst& shader); - ShaderValidator(const ShaderValidator&) = delete; - ShaderValidator(ShaderValidator&&) = delete; - ~ShaderValidator() = default; + inline ShaderAstValidator(const ShaderAst& shader); + ShaderAstValidator(const ShaderAstValidator&) = delete; + ShaderAstValidator(ShaderAstValidator&&) = delete; + ~ShaderAstValidator() = default; bool Validate(std::string* error = nullptr); @@ -33,7 +33,7 @@ namespace Nz void TypeMustMatch(const ShaderNodes::ExpressionPtr& left, const ShaderNodes::ExpressionPtr& right); void TypeMustMatch(const ShaderExpressionType& left, const ShaderExpressionType& right); - using ShaderRecursiveVisitor::Visit; + using ShaderAstRecursiveVisitor::Visit; void Visit(const ShaderNodes::AccessMember& node) override; void Visit(const ShaderNodes::AssignOp& node) override; void Visit(const ShaderNodes::BinaryOp& node) override; @@ -65,6 +65,6 @@ namespace Nz NAZARA_RENDERER_API bool ValidateShader(const ShaderAst& shader, std::string* error = nullptr); } -#include +#include #endif diff --git a/include/Nazara/Renderer/ShaderValidator.inl b/include/Nazara/Renderer/ShaderAstValidator.inl similarity index 72% rename from include/Nazara/Renderer/ShaderValidator.inl rename to include/Nazara/Renderer/ShaderAstValidator.inl index e609a144a..ee2628ce5 100644 --- a/include/Nazara/Renderer/ShaderValidator.inl +++ b/include/Nazara/Renderer/ShaderAstValidator.inl @@ -2,12 +2,12 @@ // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include namespace Nz { - ShaderValidator::ShaderValidator(const ShaderAst& shader) : + ShaderAstValidator::ShaderAstValidator(const ShaderAst& shader) : m_shader(shader) { } diff --git a/include/Nazara/Renderer/ShaderVisitor.hpp b/include/Nazara/Renderer/ShaderAstVisitor.hpp similarity index 87% rename from include/Nazara/Renderer/ShaderVisitor.hpp rename to include/Nazara/Renderer/ShaderAstVisitor.hpp index 1cd98fac3..d955f17e9 100644 --- a/include/Nazara/Renderer/ShaderVisitor.hpp +++ b/include/Nazara/Renderer/ShaderAstVisitor.hpp @@ -15,13 +15,13 @@ namespace Nz { - class NAZARA_RENDERER_API ShaderVisitor + class NAZARA_RENDERER_API ShaderAstVisitor { public: - ShaderVisitor() = default; - ShaderVisitor(const ShaderVisitor&) = delete; - ShaderVisitor(ShaderVisitor&&) = delete; - virtual ~ShaderVisitor(); + ShaderAstVisitor() = default; + ShaderAstVisitor(const ShaderAstVisitor&) = delete; + ShaderAstVisitor(ShaderAstVisitor&&) = delete; + virtual ~ShaderAstVisitor(); void EnableCondition(const std::string& name, bool cond); diff --git a/include/Nazara/Renderer/ShaderNodes.hpp b/include/Nazara/Renderer/ShaderNodes.hpp index 0b6daec79..5bfd47f6b 100644 --- a/include/Nazara/Renderer/ShaderNodes.hpp +++ b/include/Nazara/Renderer/ShaderNodes.hpp @@ -21,7 +21,7 @@ namespace Nz { - class ShaderVisitor; + class ShaderAstVisitor; namespace ShaderNodes { @@ -37,7 +37,7 @@ namespace Nz inline NodeType GetType() const; inline bool IsStatement() const; - virtual void Visit(ShaderVisitor& visitor) = 0; + virtual void Visit(ShaderAstVisitor& visitor) = 0; static inline unsigned int GetComponentCount(BasicType type); static inline BasicType GetComponentType(BasicType type); @@ -77,7 +77,7 @@ namespace Nz { inline ExpressionStatement(); - void Visit(ShaderVisitor& visitor) override; + void Visit(ShaderAstVisitor& visitor) override; ExpressionPtr expression; @@ -90,7 +90,7 @@ namespace Nz { inline ConditionalStatement(); - void Visit(ShaderVisitor& visitor) override; + void Visit(ShaderAstVisitor& visitor) override; std::string conditionName; StatementPtr statement; @@ -102,7 +102,7 @@ namespace Nz { inline StatementBlock(); - void Visit(ShaderVisitor& visitor) override; + void Visit(ShaderAstVisitor& visitor) override; std::vector statements; @@ -113,7 +113,7 @@ namespace Nz { inline DeclareVariable(); - void Visit(ShaderVisitor& visitor) override; + void Visit(ShaderAstVisitor& visitor) override; LocalVariablePtr variable; ExpressionPtr expression; @@ -127,7 +127,7 @@ namespace Nz ExpressionCategory GetExpressionCategory() const override; ShaderExpressionType GetExpressionType() const override; - void Visit(ShaderVisitor& visitor) override; + void Visit(ShaderAstVisitor& visitor) override; VariablePtr var; @@ -140,7 +140,7 @@ namespace Nz ExpressionCategory GetExpressionCategory() const override; ShaderExpressionType GetExpressionType() const override; - void Visit(ShaderVisitor& visitor) override; + void Visit(ShaderAstVisitor& visitor) override; std::size_t memberIndex; ExpressionPtr structExpr; @@ -156,7 +156,7 @@ namespace Nz inline AssignOp(); ShaderExpressionType GetExpressionType() const override; - void Visit(ShaderVisitor& visitor) override; + void Visit(ShaderAstVisitor& visitor) override; AssignType op; ExpressionPtr left; @@ -170,7 +170,7 @@ namespace Nz inline BinaryOp(); ShaderExpressionType GetExpressionType() const override; - void Visit(ShaderVisitor& visitor) override; + void Visit(ShaderAstVisitor& visitor) override; BinaryType op; ExpressionPtr left; @@ -185,7 +185,7 @@ namespace Nz inline Branch(); - void Visit(ShaderVisitor& visitor) override; + void Visit(ShaderAstVisitor& visitor) override; std::vector condStatements; StatementPtr elseStatement; @@ -204,7 +204,7 @@ namespace Nz inline Cast(); ShaderExpressionType GetExpressionType() const override; - void Visit(ShaderVisitor& visitor) override; + void Visit(ShaderAstVisitor& visitor) override; BasicType exprType; std::array expressions; @@ -218,7 +218,7 @@ namespace Nz inline Constant(); ShaderExpressionType GetExpressionType() const override; - void Visit(ShaderVisitor& visitor) override; + void Visit(ShaderAstVisitor& visitor) override; using Variant = std::variant< bool, @@ -239,7 +239,7 @@ namespace Nz ExpressionCategory GetExpressionCategory() const override; ShaderExpressionType GetExpressionType() const override; - void Visit(ShaderVisitor& visitor) override; + void Visit(ShaderAstVisitor& visitor) override; std::array components; std::size_t componentCount; @@ -255,7 +255,7 @@ namespace Nz inline Sample2D(); ShaderExpressionType GetExpressionType() const override; - void Visit(ShaderVisitor& visitor) override; + void Visit(ShaderAstVisitor& visitor) override; ExpressionPtr sampler; ExpressionPtr coordinates; @@ -270,7 +270,7 @@ namespace Nz inline IntrinsicCall(); ShaderExpressionType GetExpressionType() const override; - void Visit(ShaderVisitor& visitor) override; + void Visit(ShaderAstVisitor& visitor) override; IntrinsicType intrinsic; std::vector parameters; diff --git a/include/Nazara/Renderer/SpirvWriter.hpp b/include/Nazara/Renderer/SpirvWriter.hpp index 5786ea55b..2301d6caf 100644 --- a/include/Nazara/Renderer/SpirvWriter.hpp +++ b/include/Nazara/Renderer/SpirvWriter.hpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include @@ -20,7 +20,7 @@ namespace Nz { - class NAZARA_RENDERER_API SpirvWriter : public ShaderVisitor + class NAZARA_RENDERER_API SpirvWriter : public ShaderAstVisitor { public: struct Environment; @@ -84,7 +84,7 @@ namespace Nz UInt32 RegisterType(ShaderExpressionType type); - using ShaderVisitor::Visit; + using ShaderAstVisitor::Visit; void Visit(const ShaderNodes::AccessMember& node) override; void Visit(const ShaderNodes::AssignOp& node) override; void Visit(const ShaderNodes::Branch& node) override; diff --git a/include/Nazara/Utility.hpp b/include/Nazara/Utility.hpp index 735b83c32..29acfe8b9 100644 --- a/include/Nazara/Utility.hpp +++ b/include/Nazara/Utility.hpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include diff --git a/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp b/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp index a2a3fbf7a..07f6de975 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/Nazara/Renderer/GlslWriter.cpp b/src/Nazara/Renderer/GlslWriter.cpp index fcb1847a7..1383da334 100644 --- a/src/Nazara/Renderer/GlslWriter.cpp +++ b/src/Nazara/Renderer/GlslWriter.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include @@ -305,7 +305,7 @@ namespace Nz if (enclose) Append("("); - ShaderVisitor::Visit(expr); + ShaderAstVisitor::Visit(expr); if (enclose) Append(")"); diff --git a/src/Nazara/Renderer/ShaderAstRecursiveVisitor.cpp b/src/Nazara/Renderer/ShaderAstRecursiveVisitor.cpp new file mode 100644 index 000000000..81344bcf0 --- /dev/null +++ b/src/Nazara/Renderer/ShaderAstRecursiveVisitor.cpp @@ -0,0 +1,93 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + void ShaderAstRecursiveVisitor::Visit(const ShaderNodes::AccessMember& node) + { + Visit(node.structExpr); + } + + void ShaderAstRecursiveVisitor::Visit(const ShaderNodes::AssignOp& node) + { + Visit(node.left); + Visit(node.right); + } + + void ShaderAstRecursiveVisitor::Visit(const ShaderNodes::BinaryOp& node) + { + Visit(node.left); + Visit(node.right); + } + + void ShaderAstRecursiveVisitor::Visit(const ShaderNodes::Branch& node) + { + for (auto& cond : node.condStatements) + { + Visit(cond.condition); + Visit(cond.statement); + } + + if (node.elseStatement) + Visit(node.elseStatement); + } + + void ShaderAstRecursiveVisitor::Visit(const ShaderNodes::Cast& node) + { + for (auto& expr : node.expressions) + { + if (!expr) + break; + + Visit(expr); + } + } + + void ShaderAstRecursiveVisitor::Visit(const ShaderNodes::Constant& /*node*/) + { + /* Nothing to do */ + } + + void ShaderAstRecursiveVisitor::Visit(const ShaderNodes::DeclareVariable& node) + { + if (node.expression) + Visit(node.expression); + } + + void ShaderAstRecursiveVisitor::Visit(const ShaderNodes::ExpressionStatement& node) + { + Visit(node.expression); + } + + void ShaderAstRecursiveVisitor::Visit(const ShaderNodes::Identifier& /*node*/) + { + /* Nothing to do */ + } + + void ShaderAstRecursiveVisitor::Visit(const ShaderNodes::IntrinsicCall& node) + { + for (auto& param : node.parameters) + Visit(param); + } + + void ShaderAstRecursiveVisitor::Visit(const ShaderNodes::Sample2D& node) + { + Visit(node.sampler); + Visit(node.coordinates); + } + + void ShaderAstRecursiveVisitor::Visit(const ShaderNodes::StatementBlock& node) + { + for (auto& statement : node.statements) + Visit(statement); + } + + void ShaderAstRecursiveVisitor::Visit(const ShaderNodes::SwizzleOp& node) + { + Visit(node.expression); + } +} diff --git a/src/Nazara/Renderer/ShaderSerializer.cpp b/src/Nazara/Renderer/ShaderAstSerializer.cpp similarity index 81% rename from src/Nazara/Renderer/ShaderSerializer.cpp rename to src/Nazara/Renderer/ShaderAstSerializer.cpp index 2433bf070..b4de31cc7 100644 --- a/src/Nazara/Renderer/ShaderSerializer.cpp +++ b/src/Nazara/Renderer/ShaderAstSerializer.cpp @@ -2,9 +2,9 @@ // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include -#include +#include #include namespace Nz @@ -14,10 +14,10 @@ namespace Nz constexpr UInt32 s_magicNumber = 0x4E534852; constexpr UInt32 s_currentVersion = 1; - class ShaderSerializerVisitor : public ShaderVisitor, public ShaderVarVisitor + class ShaderSerializerVisitor : public ShaderAstVisitor, public ShaderVarVisitor { public: - ShaderSerializerVisitor(ShaderSerializerBase& serializer) : + ShaderSerializerVisitor(ShaderAstSerializerBase& serializer) : m_serializer(serializer) { } @@ -126,32 +126,32 @@ namespace Nz m_serializer.Serialize(const_cast(node)); } - ShaderSerializerBase& m_serializer; + ShaderAstSerializerBase& m_serializer; }; } - void ShaderSerializerBase::Serialize(ShaderNodes::AccessMember& node) + void ShaderAstSerializerBase::Serialize(ShaderNodes::AccessMember& node) { Value(node.memberIndex); Node(node.structExpr); Type(node.exprType); } - void ShaderSerializerBase::Serialize(ShaderNodes::AssignOp& node) + void ShaderAstSerializerBase::Serialize(ShaderNodes::AssignOp& node) { Enum(node.op); Node(node.left); Node(node.right); } - void ShaderSerializerBase::Serialize(ShaderNodes::BinaryOp& node) + void ShaderAstSerializerBase::Serialize(ShaderNodes::BinaryOp& node) { Enum(node.op); Node(node.left); Node(node.right); } - void ShaderSerializerBase::Serialize(ShaderNodes::Branch& node) + void ShaderAstSerializerBase::Serialize(ShaderNodes::Branch& node) { Container(node.condStatements); for (auto& condStatement : node.condStatements) @@ -163,20 +163,20 @@ namespace Nz Node(node.elseStatement); } - void ShaderSerializerBase::Serialize(ShaderNodes::BuiltinVariable& node) + void ShaderAstSerializerBase::Serialize(ShaderNodes::BuiltinVariable& node) { Enum(node.entry); Type(node.type); } - void ShaderSerializerBase::Serialize(ShaderNodes::Cast& node) + void ShaderAstSerializerBase::Serialize(ShaderNodes::Cast& node) { Enum(node.exprType); for (auto& expr : node.expressions) Node(expr); } - void ShaderSerializerBase::Serialize(ShaderNodes::Constant& node) + void ShaderAstSerializerBase::Serialize(ShaderNodes::Constant& node) { UInt32 typeIndex; if (IsWriting()) @@ -205,23 +205,23 @@ namespace Nz } } - void ShaderSerializerBase::Serialize(ShaderNodes::DeclareVariable& node) + void ShaderAstSerializerBase::Serialize(ShaderNodes::DeclareVariable& node) { Variable(node.variable); Node(node.expression); } - void ShaderSerializerBase::Serialize(ShaderNodes::ExpressionStatement& node) + void ShaderAstSerializerBase::Serialize(ShaderNodes::ExpressionStatement& node) { Node(node.expression); } - void ShaderSerializerBase::Serialize(ShaderNodes::Identifier& node) + void ShaderAstSerializerBase::Serialize(ShaderNodes::Identifier& node) { Variable(node.var); } - void ShaderSerializerBase::Serialize(ShaderNodes::IntrinsicCall& node) + void ShaderAstSerializerBase::Serialize(ShaderNodes::IntrinsicCall& node) { Enum(node.intrinsic); Container(node.parameters); @@ -229,26 +229,26 @@ namespace Nz Node(param); } - void ShaderSerializerBase::Serialize(ShaderNodes::NamedVariable& node) + void ShaderAstSerializerBase::Serialize(ShaderNodes::NamedVariable& node) { Value(node.name); Type(node.type); } - void ShaderSerializerBase::Serialize(ShaderNodes::Sample2D& node) + void ShaderAstSerializerBase::Serialize(ShaderNodes::Sample2D& node) { Node(node.sampler); Node(node.coordinates); } - void ShaderSerializerBase::Serialize(ShaderNodes::StatementBlock& node) + void ShaderAstSerializerBase::Serialize(ShaderNodes::StatementBlock& node) { Container(node.statements); for (auto& statement : node.statements) Node(statement); } - void ShaderSerializerBase::Serialize(ShaderNodes::SwizzleOp& node) + void ShaderAstSerializerBase::Serialize(ShaderNodes::SwizzleOp& node) { Value(node.componentCount); Node(node.expression); @@ -258,7 +258,7 @@ namespace Nz } - void ShaderSerializer::Serialize(const ShaderAst& shader) + void ShaderAstSerializer::Serialize(const ShaderAst& shader) { m_stream << s_magicNumber << s_currentVersion; @@ -346,12 +346,12 @@ namespace Nz m_stream.FlushBits(); } - bool ShaderSerializer::IsWriting() const + bool ShaderAstSerializer::IsWriting() const { return true; } - void ShaderSerializer::Node(ShaderNodes::NodePtr& node) + void ShaderAstSerializer::Node(ShaderNodes::NodePtr& node) { ShaderNodes::NodeType nodeType = (node) ? node->GetType() : ShaderNodes::NodeType::None; m_stream << static_cast(nodeType); @@ -363,7 +363,7 @@ namespace Nz } } - void ShaderSerializer::Type(ShaderExpressionType& type) + void ShaderAstSerializer::Type(ShaderExpressionType& type) { std::visit([&](auto&& arg) { @@ -383,57 +383,57 @@ namespace Nz }, type); } - void ShaderSerializer::Node(const ShaderNodes::NodePtr& node) + void ShaderAstSerializer::Node(const ShaderNodes::NodePtr& node) { Node(const_cast(node)); //< Yes const_cast is ugly but it won't be used for writing } - void ShaderSerializer::Value(bool& val) + void ShaderAstSerializer::Value(bool& val) { m_stream << val; } - void ShaderSerializer::Value(float& val) + void ShaderAstSerializer::Value(float& val) { m_stream << val; } - void ShaderSerializer::Value(std::string& val) + void ShaderAstSerializer::Value(std::string& val) { m_stream << val; } - void ShaderSerializer::Value(Vector2f& val) + void ShaderAstSerializer::Value(Vector2f& val) { m_stream << val; } - void ShaderSerializer::Value(Vector3f& val) + void ShaderAstSerializer::Value(Vector3f& val) { m_stream << val; } - void ShaderSerializer::Value(Vector4f& val) + void ShaderAstSerializer::Value(Vector4f& val) { m_stream << val; } - void ShaderSerializer::Value(UInt8& val) + void ShaderAstSerializer::Value(UInt8& val) { m_stream << val; } - void ShaderSerializer::Value(UInt16& val) + void ShaderAstSerializer::Value(UInt16& val) { m_stream << val; } - void ShaderSerializer::Value(UInt32& val) + void ShaderAstSerializer::Value(UInt32& val) { m_stream << val; } - void ShaderSerializer::Variable(ShaderNodes::VariablePtr& var) + void ShaderAstSerializer::Variable(ShaderNodes::VariablePtr& var) { ShaderNodes::VariableType nodeType = (var) ? var->GetType() : ShaderNodes::VariableType::None; m_stream << static_cast(nodeType); @@ -445,7 +445,7 @@ namespace Nz } } - ShaderAst ShaderUnserializer::Unserialize() + ShaderAst ShaderAstUnserializer::Unserialize() { UInt32 magicNumber; UInt32 version; @@ -558,12 +558,12 @@ namespace Nz return shader; } - bool ShaderUnserializer::IsWriting() const + bool ShaderAstUnserializer::IsWriting() const { return false; } - void ShaderUnserializer::Node(ShaderNodes::NodePtr& node) + void ShaderAstUnserializer::Node(ShaderNodes::NodePtr& node) { Int32 nodeTypeInt; m_stream >> nodeTypeInt; @@ -599,7 +599,7 @@ namespace Nz } } - void ShaderUnserializer::Type(ShaderExpressionType& type) + void ShaderAstUnserializer::Type(ShaderExpressionType& type) { UInt8 typeIndex; Value(typeIndex); @@ -629,52 +629,52 @@ namespace Nz } } - void ShaderUnserializer::Value(bool& val) + void ShaderAstUnserializer::Value(bool& val) { m_stream >> val; } - void ShaderUnserializer::Value(float& val) + void ShaderAstUnserializer::Value(float& val) { m_stream >> val; } - void ShaderUnserializer::Value(std::string& val) + void ShaderAstUnserializer::Value(std::string& val) { m_stream >> val; } - void ShaderUnserializer::Value(Vector2f& val) + void ShaderAstUnserializer::Value(Vector2f& val) { m_stream >> val; } - void ShaderUnserializer::Value(Vector3f& val) + void ShaderAstUnserializer::Value(Vector3f& val) { m_stream >> val; } - void ShaderUnserializer::Value(Vector4f& val) + void ShaderAstUnserializer::Value(Vector4f& val) { m_stream >> val; } - void ShaderUnserializer::Value(UInt8& val) + void ShaderAstUnserializer::Value(UInt8& val) { m_stream >> val; } - void ShaderUnserializer::Value(UInt16& val) + void ShaderAstUnserializer::Value(UInt16& val) { m_stream >> val; } - void ShaderUnserializer::Value(UInt32& val) + void ShaderAstUnserializer::Value(UInt32& val) { m_stream >> val; } - void ShaderUnserializer::Variable(ShaderNodes::VariablePtr& var) + void ShaderAstUnserializer::Variable(ShaderNodes::VariablePtr& var) { Int32 nodeTypeInt; m_stream >> nodeTypeInt; @@ -707,7 +707,7 @@ namespace Nz ByteArray byteArray; ByteStream stream(&byteArray, OpenModeFlags(OpenMode_WriteOnly)); - ShaderSerializer serializer(stream); + ShaderAstSerializer serializer(stream); serializer.Serialize(shader); return byteArray; @@ -715,7 +715,7 @@ namespace Nz ShaderAst UnserializeShader(ByteStream& stream) { - ShaderUnserializer unserializer(stream); + ShaderAstUnserializer unserializer(stream); return unserializer.Unserialize(); } } diff --git a/src/Nazara/Renderer/ShaderValidator.cpp b/src/Nazara/Renderer/ShaderAstValidator.cpp similarity index 79% rename from src/Nazara/Renderer/ShaderValidator.cpp rename to src/Nazara/Renderer/ShaderAstValidator.cpp index 351a46839..57404ba6b 100644 --- a/src/Nazara/Renderer/ShaderValidator.cpp +++ b/src/Nazara/Renderer/ShaderAstValidator.cpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include #include #include @@ -16,7 +16,7 @@ namespace Nz std::string errMsg; }; - struct ShaderValidator::Context + struct ShaderAstValidator::Context { struct Local { @@ -29,7 +29,7 @@ namespace Nz std::vector blockLocalIndex; }; - bool ShaderValidator::Validate(std::string* error) + bool ShaderAstValidator::Validate(std::string* error) { try { @@ -57,14 +57,14 @@ namespace Nz } } - const ShaderNodes::ExpressionPtr& ShaderValidator::MandatoryExpr(const ShaderNodes::ExpressionPtr& node) + const ShaderNodes::ExpressionPtr& ShaderAstValidator::MandatoryExpr(const ShaderNodes::ExpressionPtr& node) { MandatoryNode(node); return node; } - const ShaderNodes::NodePtr& ShaderValidator::MandatoryNode(const ShaderNodes::NodePtr& node) + const ShaderNodes::NodePtr& ShaderAstValidator::MandatoryNode(const ShaderNodes::NodePtr& node) { if (!node) throw AstError{ "Invalid node" }; @@ -72,18 +72,18 @@ namespace Nz return node; } - void ShaderValidator::TypeMustMatch(const ShaderNodes::ExpressionPtr& left, const ShaderNodes::ExpressionPtr& right) + void ShaderAstValidator::TypeMustMatch(const ShaderNodes::ExpressionPtr& left, const ShaderNodes::ExpressionPtr& right) { return TypeMustMatch(left->GetExpressionType(), right->GetExpressionType()); } - void ShaderValidator::TypeMustMatch(const ShaderExpressionType& left, const ShaderExpressionType& right) + void ShaderAstValidator::TypeMustMatch(const ShaderExpressionType& left, const ShaderExpressionType& right) { if (left != right) throw AstError{ "Left expression type must match right expression type" }; } - void ShaderValidator::Visit(const ShaderNodes::AccessMember& node) + void ShaderAstValidator::Visit(const ShaderNodes::AccessMember& node) { const ShaderExpressionType& exprType = MandatoryExpr(node.structExpr)->GetExpressionType(); if (!std::holds_alternative(exprType)) @@ -105,7 +105,7 @@ namespace Nz throw AstError{ "member type does not match node type" }; } - void ShaderValidator::Visit(const ShaderNodes::AssignOp& node) + void ShaderAstValidator::Visit(const ShaderNodes::AssignOp& node) { MandatoryNode(node.left); MandatoryNode(node.right); @@ -114,10 +114,10 @@ namespace Nz if (node.left->GetExpressionCategory() != ShaderNodes::ExpressionCategory::LValue) throw AstError { "Assignation is only possible with a l-value" }; - ShaderRecursiveVisitor::Visit(node); + ShaderAstRecursiveVisitor::Visit(node); } - void ShaderValidator::Visit(const ShaderNodes::BinaryOp& node) + void ShaderAstValidator::Visit(const ShaderNodes::BinaryOp& node) { MandatoryNode(node.left); MandatoryNode(node.right); @@ -186,10 +186,10 @@ namespace Nz } } - ShaderRecursiveVisitor::Visit(node); + ShaderAstRecursiveVisitor::Visit(node); } - void ShaderValidator::Visit(const ShaderNodes::Branch& node) + void ShaderAstValidator::Visit(const ShaderNodes::Branch& node) { for (const auto& condStatement : node.condStatements) { @@ -197,10 +197,10 @@ namespace Nz MandatoryNode(condStatement.statement); } - ShaderRecursiveVisitor::Visit(node); + ShaderAstRecursiveVisitor::Visit(node); } - void ShaderValidator::Visit(const ShaderNodes::Cast& node) + void ShaderAstValidator::Visit(const ShaderNodes::Cast& node) { unsigned int componentCount = 0; unsigned int requiredComponents = node.GetComponentCount(node.exprType); @@ -219,14 +219,14 @@ namespace Nz if (componentCount != requiredComponents) throw AstError{ "Component count doesn't match required component count" }; - ShaderRecursiveVisitor::Visit(node); + ShaderAstRecursiveVisitor::Visit(node); } - void ShaderValidator::Visit(const ShaderNodes::Constant& /*node*/) + void ShaderAstValidator::Visit(const ShaderNodes::Constant& /*node*/) { } - void ShaderValidator::Visit(const ShaderNodes::DeclareVariable& node) + void ShaderAstValidator::Visit(const ShaderNodes::DeclareVariable& node) { assert(m_context); @@ -234,17 +234,17 @@ namespace Nz local.name = node.variable->name; local.type = node.variable->type; - ShaderRecursiveVisitor::Visit(node); + ShaderAstRecursiveVisitor::Visit(node); } - void ShaderValidator::Visit(const ShaderNodes::ExpressionStatement& node) + void ShaderAstValidator::Visit(const ShaderNodes::ExpressionStatement& node) { MandatoryNode(node.expression); - ShaderRecursiveVisitor::Visit(node); + ShaderAstRecursiveVisitor::Visit(node); } - void ShaderValidator::Visit(const ShaderNodes::Identifier& node) + void ShaderAstValidator::Visit(const ShaderNodes::Identifier& node) { assert(m_context); @@ -254,7 +254,7 @@ namespace Nz Visit(node.var); } - void ShaderValidator::Visit(const ShaderNodes::IntrinsicCall& node) + void ShaderAstValidator::Visit(const ShaderNodes::IntrinsicCall& node) { switch (node.intrinsic) { @@ -292,10 +292,10 @@ namespace Nz break; } - ShaderRecursiveVisitor::Visit(node); + ShaderAstRecursiveVisitor::Visit(node); } - void ShaderValidator::Visit(const ShaderNodes::Sample2D& node) + void ShaderAstValidator::Visit(const ShaderNodes::Sample2D& node) { if (MandatoryExpr(node.sampler)->GetExpressionType() != ShaderExpressionType{ ShaderNodes::BasicType::Sampler2D }) throw AstError{ "Sampler must be a Sampler2D" }; @@ -303,10 +303,10 @@ namespace Nz if (MandatoryExpr(node.coordinates)->GetExpressionType() != ShaderExpressionType{ ShaderNodes::BasicType::Float2 }) throw AstError{ "Coordinates must be a Float2" }; - ShaderRecursiveVisitor::Visit(node); + ShaderAstRecursiveVisitor::Visit(node); } - void ShaderValidator::Visit(const ShaderNodes::StatementBlock& node) + void ShaderAstValidator::Visit(const ShaderNodes::StatementBlock& node) { assert(m_context); @@ -319,10 +319,10 @@ namespace Nz m_context->declaredLocals.resize(m_context->blockLocalIndex.back()); m_context->blockLocalIndex.pop_back(); - ShaderRecursiveVisitor::Visit(node); + ShaderAstRecursiveVisitor::Visit(node); } - void ShaderValidator::Visit(const ShaderNodes::SwizzleOp& node) + void ShaderAstValidator::Visit(const ShaderNodes::SwizzleOp& node) { if (node.componentCount > 4) throw AstError{ "Cannot swizzle more than four elements" }; @@ -343,15 +343,15 @@ namespace Nz throw AstError{ "Cannot swizzle this type" }; } - ShaderRecursiveVisitor::Visit(node); + ShaderAstRecursiveVisitor::Visit(node); } - void ShaderValidator::Visit(const ShaderNodes::BuiltinVariable& /*var*/) + void ShaderAstValidator::Visit(const ShaderNodes::BuiltinVariable& /*var*/) { /* Nothing to do */ } - void ShaderValidator::Visit(const ShaderNodes::InputVariable& var) + void ShaderAstValidator::Visit(const ShaderNodes::InputVariable& var) { for (std::size_t i = 0; i < m_shader.GetInputCount(); ++i) { @@ -366,7 +366,7 @@ namespace Nz throw AstError{ "Input not found" }; } - void ShaderValidator::Visit(const ShaderNodes::LocalVariable& var) + void ShaderAstValidator::Visit(const ShaderNodes::LocalVariable& var) { const auto& vars = m_context->declaredLocals; @@ -377,7 +377,7 @@ namespace Nz TypeMustMatch(it->type, var.type); } - void ShaderValidator::Visit(const ShaderNodes::OutputVariable& var) + void ShaderAstValidator::Visit(const ShaderNodes::OutputVariable& var) { for (std::size_t i = 0; i < m_shader.GetOutputCount(); ++i) { @@ -392,7 +392,7 @@ namespace Nz throw AstError{ "Output not found" }; } - void ShaderValidator::Visit(const ShaderNodes::ParameterVariable& var) + void ShaderAstValidator::Visit(const ShaderNodes::ParameterVariable& var) { assert(m_context->currentFunction); @@ -405,7 +405,7 @@ namespace Nz TypeMustMatch(it->type, var.type); } - void ShaderValidator::Visit(const ShaderNodes::UniformVariable& var) + void ShaderAstValidator::Visit(const ShaderNodes::UniformVariable& var) { for (std::size_t i = 0; i < m_shader.GetUniformCount(); ++i) { @@ -422,7 +422,7 @@ namespace Nz bool ValidateShader(const ShaderAst& shader, std::string* error) { - ShaderValidator validator(shader); + ShaderAstValidator validator(shader); return validator.Validate(error); } } diff --git a/src/Nazara/Renderer/ShaderVisitor.cpp b/src/Nazara/Renderer/ShaderAstVisitor.cpp similarity index 55% rename from src/Nazara/Renderer/ShaderVisitor.cpp rename to src/Nazara/Renderer/ShaderAstVisitor.cpp index dd7e01542..49760f028 100644 --- a/src/Nazara/Renderer/ShaderVisitor.cpp +++ b/src/Nazara/Renderer/ShaderAstVisitor.cpp @@ -2,14 +2,14 @@ // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include namespace Nz { - ShaderVisitor::~ShaderVisitor() = default; + ShaderAstVisitor::~ShaderAstVisitor() = default; - void ShaderVisitor::EnableCondition(const std::string& name, bool cond) + void ShaderAstVisitor::EnableCondition(const std::string& name, bool cond) { if (cond) m_conditions.insert(name); @@ -17,12 +17,12 @@ namespace Nz m_conditions.erase(name); } - bool ShaderVisitor::IsConditionEnabled(const std::string& name) const + bool ShaderAstVisitor::IsConditionEnabled(const std::string& name) const { return m_conditions.count(name) != 0; } - void ShaderVisitor::Visit(const ShaderNodes::NodePtr& node) + void ShaderAstVisitor::Visit(const ShaderNodes::NodePtr& node) { node->Visit(*this); } diff --git a/src/Nazara/Renderer/ShaderNodes.cpp b/src/Nazara/Renderer/ShaderNodes.cpp index da2157826..7ea148cb6 100644 --- a/src/Nazara/Renderer/ShaderNodes.cpp +++ b/src/Nazara/Renderer/ShaderNodes.cpp @@ -4,8 +4,8 @@ #include #include -#include -#include +#include +#include #include #include @@ -18,26 +18,26 @@ namespace Nz::ShaderNodes return ExpressionCategory::RValue; } - void ExpressionStatement::Visit(ShaderVisitor& visitor) + void ExpressionStatement::Visit(ShaderAstVisitor& visitor) { visitor.Visit(*this); } - void ConditionalStatement::Visit(ShaderVisitor& visitor) + void ConditionalStatement::Visit(ShaderAstVisitor& visitor) { if (visitor.IsConditionEnabled(conditionName)) statement->Visit(visitor); } - void StatementBlock::Visit(ShaderVisitor& visitor) + void StatementBlock::Visit(ShaderAstVisitor& visitor) { visitor.Visit(*this); } - void DeclareVariable::Visit(ShaderVisitor& visitor) + void DeclareVariable::Visit(ShaderAstVisitor& visitor) { visitor.Visit(*this); } @@ -54,7 +54,7 @@ namespace Nz::ShaderNodes return var->type; } - void Identifier::Visit(ShaderVisitor& visitor) + void Identifier::Visit(ShaderAstVisitor& visitor) { visitor.Visit(*this); } @@ -69,7 +69,7 @@ namespace Nz::ShaderNodes return exprType; } - void AccessMember::Visit(ShaderVisitor& visitor) + void AccessMember::Visit(ShaderAstVisitor& visitor) { visitor.Visit(*this); } @@ -79,7 +79,7 @@ namespace Nz::ShaderNodes return left->GetExpressionType(); } - void AssignOp::Visit(ShaderVisitor& visitor) + void AssignOp::Visit(ShaderAstVisitor& visitor) { visitor.Visit(*this); } @@ -137,13 +137,13 @@ namespace Nz::ShaderNodes return *exprType; } - void BinaryOp::Visit(ShaderVisitor& visitor) + void BinaryOp::Visit(ShaderAstVisitor& visitor) { visitor.Visit(*this); } - void Branch::Visit(ShaderVisitor& visitor) + void Branch::Visit(ShaderAstVisitor& visitor) { visitor.Visit(*this); } @@ -170,7 +170,7 @@ namespace Nz::ShaderNodes }, value); } - void Constant::Visit(ShaderVisitor& visitor) + void Constant::Visit(ShaderAstVisitor& visitor) { visitor.Visit(*this); } @@ -180,7 +180,7 @@ namespace Nz::ShaderNodes return exprType; } - void Cast::Visit(ShaderVisitor& visitor) + void Cast::Visit(ShaderAstVisitor& visitor) { visitor.Visit(*this); } @@ -199,7 +199,7 @@ namespace Nz::ShaderNodes return static_cast(UnderlyingCast(GetComponentType(std::get(exprType))) + componentCount - 1); } - void SwizzleOp::Visit(ShaderVisitor& visitor) + void SwizzleOp::Visit(ShaderAstVisitor& visitor) { visitor.Visit(*this); } @@ -210,7 +210,7 @@ namespace Nz::ShaderNodes return BasicType::Float4; } - void Sample2D::Visit(ShaderVisitor& visitor) + void Sample2D::Visit(ShaderAstVisitor& visitor) { visitor.Visit(*this); } @@ -231,7 +231,7 @@ namespace Nz::ShaderNodes return BasicType::Void; } - void IntrinsicCall::Visit(ShaderVisitor& visitor) + void IntrinsicCall::Visit(ShaderAstVisitor& visitor) { visitor.Visit(*this); } diff --git a/src/Nazara/Renderer/ShaderRecursiveVisitor.cpp b/src/Nazara/Renderer/ShaderRecursiveVisitor.cpp deleted file mode 100644 index 2116da21c..000000000 --- a/src/Nazara/Renderer/ShaderRecursiveVisitor.cpp +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include - -namespace Nz -{ - void ShaderRecursiveVisitor::Visit(const ShaderNodes::AccessMember& node) - { - Visit(node.structExpr); - } - - void ShaderRecursiveVisitor::Visit(const ShaderNodes::AssignOp& node) - { - Visit(node.left); - Visit(node.right); - } - - void ShaderRecursiveVisitor::Visit(const ShaderNodes::BinaryOp& node) - { - Visit(node.left); - Visit(node.right); - } - - void ShaderRecursiveVisitor::Visit(const ShaderNodes::Branch& node) - { - for (auto& cond : node.condStatements) - { - Visit(cond.condition); - Visit(cond.statement); - } - - if (node.elseStatement) - Visit(node.elseStatement); - } - - void ShaderRecursiveVisitor::Visit(const ShaderNodes::Cast& node) - { - for (auto& expr : node.expressions) - { - if (!expr) - break; - - Visit(expr); - } - } - - void ShaderRecursiveVisitor::Visit(const ShaderNodes::Constant& /*node*/) - { - /* Nothing to do */ - } - - void ShaderRecursiveVisitor::Visit(const ShaderNodes::DeclareVariable& node) - { - if (node.expression) - Visit(node.expression); - } - - void ShaderRecursiveVisitor::Visit(const ShaderNodes::ExpressionStatement& node) - { - Visit(node.expression); - } - - void ShaderRecursiveVisitor::Visit(const ShaderNodes::Identifier& /*node*/) - { - /* Nothing to do */ - } - - void ShaderRecursiveVisitor::Visit(const ShaderNodes::IntrinsicCall& node) - { - for (auto& param : node.parameters) - Visit(param); - } - - void ShaderRecursiveVisitor::Visit(const ShaderNodes::Sample2D& node) - { - Visit(node.sampler); - Visit(node.coordinates); - } - - void ShaderRecursiveVisitor::Visit(const ShaderNodes::StatementBlock& node) - { - for (auto& statement : node.statements) - Visit(statement); - } - - void ShaderRecursiveVisitor::Visit(const ShaderNodes::SwizzleOp& node) - { - Visit(node.expression); - } -} diff --git a/src/Nazara/Renderer/SpirvWriter.cpp b/src/Nazara/Renderer/SpirvWriter.cpp index 1ccf23f97..a94cd6ec9 100644 --- a/src/Nazara/Renderer/SpirvWriter.cpp +++ b/src/Nazara/Renderer/SpirvWriter.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include @@ -22,7 +22,7 @@ namespace Nz { using ConstantVariant = ShaderNodes::Constant::Variant; - class PreVisitor : public ShaderRecursiveVisitor, public ShaderVarVisitor + class PreVisitor : public ShaderAstRecursiveVisitor, public ShaderVarVisitor { public: using BuiltinContainer = std::unordered_set>; @@ -31,7 +31,7 @@ namespace Nz using LocalContainer = std::unordered_set>; using ParameterContainer = std::unordered_set< std::shared_ptr>; - using ShaderRecursiveVisitor::Visit; + using ShaderAstRecursiveVisitor::Visit; using ShaderVarVisitor::Visit; void Visit(const ShaderNodes::Constant& node) override @@ -68,26 +68,26 @@ namespace Nz }, node.value); - ShaderRecursiveVisitor::Visit(node); + ShaderAstRecursiveVisitor::Visit(node); } void Visit(const ShaderNodes::DeclareVariable& node) override { Visit(node.variable); - ShaderRecursiveVisitor::Visit(node); + ShaderAstRecursiveVisitor::Visit(node); } void Visit(const ShaderNodes::Identifier& node) override { Visit(node.var); - ShaderRecursiveVisitor::Visit(node); + ShaderAstRecursiveVisitor::Visit(node); } void Visit(const ShaderNodes::IntrinsicCall& node) override { - ShaderRecursiveVisitor::Visit(node); + ShaderAstRecursiveVisitor::Visit(node); switch (node.intrinsic) { diff --git a/src/ShaderNode/Widgets/MainWindow.cpp b/src/ShaderNode/Widgets/MainWindow.cpp index f25f95a18..31665bb8d 100644 --- a/src/ShaderNode/Widgets/MainWindow.cpp +++ b/src/ShaderNode/Widgets/MainWindow.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include #include From d6d452d43dbed397957f74407491eef0d70738ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 5 Aug 2020 15:30:23 +0200 Subject: [PATCH 288/316] Add ShaderAstCloner --- include/Nazara/Renderer.hpp | 1 + include/Nazara/Renderer/ShaderAstCloner.hpp | 73 ++++++ include/Nazara/Renderer/ShaderAstCloner.inl | 12 + include/Nazara/Renderer/ShaderNodes.hpp | 9 +- include/Nazara/Renderer/ShaderNodes.inl | 33 ++- src/Nazara/Renderer/GlslWriter.cpp | 8 +- src/Nazara/Renderer/ShaderAstCloner.cpp | 246 ++++++++++++++++++++ src/Nazara/Renderer/ShaderAstValidator.cpp | 9 +- 8 files changed, 383 insertions(+), 8 deletions(-) create mode 100644 include/Nazara/Renderer/ShaderAstCloner.hpp create mode 100644 include/Nazara/Renderer/ShaderAstCloner.inl create mode 100644 src/Nazara/Renderer/ShaderAstCloner.cpp diff --git a/include/Nazara/Renderer.hpp b/include/Nazara/Renderer.hpp index 8271bd3c8..ff9193d3f 100644 --- a/include/Nazara/Renderer.hpp +++ b/include/Nazara/Renderer.hpp @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include diff --git a/include/Nazara/Renderer/ShaderAstCloner.hpp b/include/Nazara/Renderer/ShaderAstCloner.hpp new file mode 100644 index 000000000..b48de17b8 --- /dev/null +++ b/include/Nazara/Renderer/ShaderAstCloner.hpp @@ -0,0 +1,73 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_SHADERASTCLONER_HPP +#define NAZARA_SHADERASTCLONER_HPP + +#include +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_RENDERER_API ShaderAstCloner : public ShaderAstVisitor, public ShaderVarVisitor + { + public: + ShaderAstCloner() = default; + ShaderAstCloner(const ShaderAstCloner&) = default; + ShaderAstCloner(ShaderAstCloner&&) = default; + ~ShaderAstCloner() = default; + + ShaderNodes::StatementPtr Clone(const ShaderNodes::StatementPtr& statement); + + ShaderAstCloner& operator=(const ShaderAstCloner&) = default; + ShaderAstCloner& operator=(ShaderAstCloner&&) = default; + + private: + void Visit(const ShaderNodes::ExpressionPtr& expr); + void Visit(const ShaderNodes::StatementPtr& statement); + + void Visit(const ShaderNodes::AccessMember& node) override; + void Visit(const ShaderNodes::AssignOp& node) override; + void Visit(const ShaderNodes::BinaryOp& node) override; + void Visit(const ShaderNodes::Branch& node) override; + void Visit(const ShaderNodes::Cast& node) override; + void Visit(const ShaderNodes::Constant& node) override; + void Visit(const ShaderNodes::DeclareVariable& node) override; + void Visit(const ShaderNodes::ExpressionStatement& node) override; + void Visit(const ShaderNodes::Identifier& node) override; + void Visit(const ShaderNodes::IntrinsicCall& node) override; + void Visit(const ShaderNodes::Sample2D& node) override; + void Visit(const ShaderNodes::StatementBlock& node) override; + void Visit(const ShaderNodes::SwizzleOp& node) override; + + using ShaderVarVisitor::Visit; + void Visit(const ShaderNodes::BuiltinVariable& var) override; + void Visit(const ShaderNodes::InputVariable& var) override; + void Visit(const ShaderNodes::LocalVariable& var) override; + void Visit(const ShaderNodes::OutputVariable& var) override; + void Visit(const ShaderNodes::ParameterVariable& var) override; + void Visit(const ShaderNodes::UniformVariable& var) override; + + void PushExpression(ShaderNodes::ExpressionPtr expression); + void PushStatement(ShaderNodes::StatementPtr statement); + void PushVariable(ShaderNodes::VariablePtr variable); + + ShaderNodes::ExpressionPtr PopExpression(); + ShaderNodes::StatementPtr PopStatement(); + ShaderNodes::VariablePtr PopVariable(); + + std::vector m_expressionStack; + std::vector m_statementStack; + std::vector m_variableStack; + }; +} + +#include + +#endif diff --git a/include/Nazara/Renderer/ShaderAstCloner.inl b/include/Nazara/Renderer/ShaderAstCloner.inl new file mode 100644 index 000000000..1acdd41ab --- /dev/null +++ b/include/Nazara/Renderer/ShaderAstCloner.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ +} + +#include diff --git a/include/Nazara/Renderer/ShaderNodes.hpp b/include/Nazara/Renderer/ShaderNodes.hpp index 5bfd47f6b..c0b8688e2 100644 --- a/include/Nazara/Renderer/ShaderNodes.hpp +++ b/include/Nazara/Renderer/ShaderNodes.hpp @@ -106,6 +106,7 @@ namespace Nz std::vector statements; + static inline std::shared_ptr Build(std::vector statements); template static std::shared_ptr Build(Args&&... args); }; @@ -115,10 +116,10 @@ namespace Nz void Visit(ShaderAstVisitor& visitor) override; - LocalVariablePtr variable; ExpressionPtr expression; + VariablePtr variable; - static inline std::shared_ptr Build(LocalVariablePtr variable, ExpressionPtr expression = nullptr); + static inline std::shared_ptr Build(VariablePtr variable, ExpressionPtr expression = nullptr); }; struct NAZARA_RENDERER_API Identifier : public Expression @@ -196,7 +197,8 @@ namespace Nz StatementPtr statement; }; - inline std::shared_ptr Build(ExpressionPtr condition, StatementPtr trueStatement, StatementPtr falseStatement = nullptr); + static inline std::shared_ptr Build(ExpressionPtr condition, StatementPtr trueStatement, StatementPtr falseStatement = nullptr); + static inline std::shared_ptr Build(std::vector statements, StatementPtr elseStatement = nullptr); }; struct NAZARA_RENDERER_API Cast : public Expression @@ -246,6 +248,7 @@ namespace Nz ExpressionPtr expression; static inline std::shared_ptr Build(ExpressionPtr expressionPtr, std::initializer_list swizzleComponents); + static inline std::shared_ptr Build(ExpressionPtr expressionPtr, const SwizzleComponent* components, std::size_t componentCount); }; ////////////////////////////////////////////////////////////////////////// diff --git a/include/Nazara/Renderer/ShaderNodes.inl b/include/Nazara/Renderer/ShaderNodes.inl index 27d387bcd..0e9307ff4 100644 --- a/include/Nazara/Renderer/ShaderNodes.inl +++ b/include/Nazara/Renderer/ShaderNodes.inl @@ -107,6 +107,14 @@ namespace Nz::ShaderNodes { } + inline std::shared_ptr StatementBlock::Build(std::vector statements) + { + auto node = std::make_shared(); + node->statements = std::move(statements); + + return node; + } + template std::shared_ptr StatementBlock::Build(Args&&... args) { @@ -122,7 +130,7 @@ namespace Nz::ShaderNodes { } - inline std::shared_ptr DeclareVariable::Build(LocalVariablePtr variable, ExpressionPtr expression) + inline std::shared_ptr DeclareVariable::Build(VariablePtr variable, ExpressionPtr expression) { auto node = std::make_shared(); node->expression = std::move(expression); @@ -208,6 +216,15 @@ namespace Nz::ShaderNodes return node; } + inline std::shared_ptr Branch::Build(std::vector statements, StatementPtr elseStatement) + { + auto node = std::make_shared(); + node->condStatements = std::move(statements); + node->elseStatement = std::move(elseStatement); + + return node; + } + inline Cast::Cast() : Expression(NodeType::Cast) @@ -265,6 +282,20 @@ namespace Nz::ShaderNodes return node; } + inline std::shared_ptr SwizzleOp::Build(ExpressionPtr expressionPtr, const SwizzleComponent* components, std::size_t componentCount) + { + auto node = std::make_shared(); + + assert(componentCount < node->components.size()); + + node->componentCount = componentCount; + node->expression = std::move(expressionPtr); + + std::copy(components, components + componentCount, node->components.begin()); + + return node; + } + inline Sample2D::Sample2D() : Expression(NodeType::Sample2D) diff --git a/src/Nazara/Renderer/GlslWriter.cpp b/src/Nazara/Renderer/GlslWriter.cpp index 1383da334..8fa23755a 100644 --- a/src/Nazara/Renderer/GlslWriter.cpp +++ b/src/Nazara/Renderer/GlslWriter.cpp @@ -448,9 +448,13 @@ namespace Nz void GlslWriter::Visit(const ShaderNodes::DeclareVariable& node) { - Append(node.variable->type); + assert(node.variable->GetType() == ShaderNodes::VariableType::LocalVariable); + + const auto& localVar = static_cast(*node.variable); + + Append(localVar.type); Append(" "); - Append(node.variable->name); + Append(localVar.name); if (node.expression) { Append(" = "); diff --git a/src/Nazara/Renderer/ShaderAstCloner.cpp b/src/Nazara/Renderer/ShaderAstCloner.cpp new file mode 100644 index 000000000..f4ec37329 --- /dev/null +++ b/src/Nazara/Renderer/ShaderAstCloner.cpp @@ -0,0 +1,246 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + ShaderNodes::StatementPtr ShaderAstCloner::Clone(const ShaderNodes::StatementPtr& statement) + { + ShaderAstVisitor::Visit(statement); + + if (!m_expressionStack.empty() || !m_variableStack.empty() || m_statementStack.size() != 1) + throw std::runtime_error("An error occured during clone"); + + return PopStatement(); + } + + void ShaderAstCloner::Visit(const ShaderNodes::ExpressionPtr& expr) + { + if (expr) + ShaderAstVisitor::Visit(expr); + else + PushExpression(nullptr); + } + + void ShaderAstCloner::Visit(const ShaderNodes::StatementPtr& statement) + { + if (statement) + ShaderAstVisitor::Visit(statement); + else + PushStatement(nullptr); + } + + void ShaderAstCloner::Visit(const ShaderNodes::AccessMember& node) + { + Visit(node.structExpr); + + PushExpression(ShaderNodes::AccessMember::Build(PopExpression(), node.memberIndex, node.exprType)); + } + + void ShaderAstCloner::Visit(const ShaderNodes::AssignOp& node) + { + Visit(node.left); + Visit(node.right); + + auto right = PopExpression(); + auto left = PopExpression(); + + PushExpression(ShaderNodes::AssignOp::Build(node.op, std::move(left), std::move(right))); + } + + void ShaderAstCloner::Visit(const ShaderNodes::BinaryOp& node) + { + Visit(node.left); + Visit(node.right); + + auto right = PopExpression(); + auto left = PopExpression(); + + PushExpression(ShaderNodes::BinaryOp::Build(node.op, std::move(left), std::move(right))); + } + + void ShaderAstCloner::Visit(const ShaderNodes::Branch& node) + { + for (auto& cond : node.condStatements) + { + Visit(cond.condition); + Visit(cond.statement); + } + + Visit(node.elseStatement); + + auto elseStatement = PopStatement(); + + std::vector condStatements(node.condStatements.size()); + for (std::size_t i = 0; i < condStatements.size(); ++i) + { + auto& condStatement = condStatements[condStatements.size() - i - 1]; + condStatement.condition = PopExpression(); + condStatement.statement = PopStatement(); + } + + PushStatement(ShaderNodes::Branch::Build(std::move(condStatements), std::move(elseStatement))); + } + + void ShaderAstCloner::Visit(const ShaderNodes::Cast& node) + { + std::size_t expressionCount = 0; + std::array expressions; + for (const auto& expr : node.expressions) + { + Visit(expr); + expressionCount++; + } + + for (std::size_t i = 0; i < expressionCount; ++i) + expressions[expressionCount - i - 1] = PopExpression(); + + PushExpression(ShaderNodes::Cast::Build(node.exprType, expressions.data(), expressionCount)); + } + + void ShaderAstCloner::Visit(const ShaderNodes::Constant& node) + { + PushExpression(ShaderNodes::Constant::Build(node.value)); + } + + void ShaderAstCloner::Visit(const ShaderNodes::DeclareVariable& node) + { + Visit(node.expression); + Visit(node.variable); + + PushStatement(ShaderNodes::DeclareVariable::Build(PopVariable(), PopExpression())); + } + + void ShaderAstCloner::Visit(const ShaderNodes::ExpressionStatement& node) + { + Visit(node.expression); + + PushStatement(ShaderNodes::ExpressionStatement::Build(PopExpression())); + } + + void ShaderAstCloner::Visit(const ShaderNodes::Identifier& node) + { + Visit(node.var); + + PushExpression(ShaderNodes::Identifier::Build(PopVariable())); + } + + void ShaderAstCloner::Visit(const ShaderNodes::IntrinsicCall& node) + { + for (auto& parameter : node.parameters) + Visit(parameter); + + std::vector parameters(node.parameters.size()); + for (std::size_t i = 0; i < parameters.size(); ++i) + parameters[parameters.size() - i - 1] = PopExpression(); + + PushExpression(ShaderNodes::IntrinsicCall::Build(node.intrinsic, std::move(parameters))); + } + + void ShaderAstCloner::Visit(const ShaderNodes::Sample2D& node) + { + Visit(node.coordinates); + Visit(node.sampler); + + auto sampler = PopExpression(); + auto coordinates = PopExpression(); + + PushExpression(ShaderNodes::Sample2D::Build(std::move(sampler), std::move(coordinates))); + } + + void ShaderAstCloner::Visit(const ShaderNodes::StatementBlock& node) + { + for (auto& statement : node.statements) + Visit(statement); + + std::vector statements(node.statements.size()); + for (std::size_t i = 0; i < statements.size(); ++i) + statements[statements.size() - i - 1] = PopStatement(); + + PushStatement(ShaderNodes::StatementBlock::Build(std::move(statements))); + } + + void ShaderAstCloner::Visit(const ShaderNodes::SwizzleOp& node) + { + PushExpression(ShaderNodes::SwizzleOp::Build(PopExpression(), node.components.data(), node.componentCount)); + } + + void ShaderAstCloner::Visit(const ShaderNodes::BuiltinVariable& var) + { + PushVariable(ShaderNodes::BuiltinVariable::Build(var.entry, var.type)); + } + + void ShaderAstCloner::Visit(const ShaderNodes::InputVariable& var) + { + PushVariable(ShaderNodes::InputVariable::Build(var.name, var.type)); + } + + void ShaderAstCloner::Visit(const ShaderNodes::LocalVariable& var) + { + PushVariable(ShaderNodes::LocalVariable::Build(var.name, var.type)); + } + + void ShaderAstCloner::Visit(const ShaderNodes::OutputVariable& var) + { + PushVariable(ShaderNodes::OutputVariable::Build(var.name, var.type)); + } + + void ShaderAstCloner::Visit(const ShaderNodes::ParameterVariable& var) + { + PushVariable(ShaderNodes::ParameterVariable::Build(var.name, var.type)); + } + + void ShaderAstCloner::Visit(const ShaderNodes::UniformVariable& var) + { + PushVariable(ShaderNodes::UniformVariable::Build(var.name, var.type)); + } + + void ShaderAstCloner::PushExpression(ShaderNodes::ExpressionPtr expression) + { + m_expressionStack.emplace_back(std::move(expression)); + } + + void ShaderAstCloner::PushStatement(ShaderNodes::StatementPtr statement) + { + m_statementStack.emplace_back(std::move(statement)); + } + + void ShaderAstCloner::PushVariable(ShaderNodes::VariablePtr variable) + { + m_variableStack.emplace_back(std::move(variable)); + } + + ShaderNodes::ExpressionPtr ShaderAstCloner::PopExpression() + { + assert(!m_expressionStack.empty()); + + ShaderNodes::ExpressionPtr expr = std::move(m_expressionStack.back()); + m_expressionStack.pop_back(); + + return expr; + } + + ShaderNodes::StatementPtr ShaderAstCloner::PopStatement() + { + assert(!m_statementStack.empty()); + + ShaderNodes::StatementPtr expr = std::move(m_statementStack.back()); + m_statementStack.pop_back(); + + return expr; + } + + ShaderNodes::VariablePtr ShaderAstCloner::PopVariable() + { + assert(!m_variableStack.empty()); + + ShaderNodes::VariablePtr var = std::move(m_variableStack.back()); + m_variableStack.pop_back(); + + return var; + } +} diff --git a/src/Nazara/Renderer/ShaderAstValidator.cpp b/src/Nazara/Renderer/ShaderAstValidator.cpp index 57404ba6b..8e161d532 100644 --- a/src/Nazara/Renderer/ShaderAstValidator.cpp +++ b/src/Nazara/Renderer/ShaderAstValidator.cpp @@ -230,9 +230,14 @@ namespace Nz { assert(m_context); + if (node.variable->GetType() != ShaderNodes::VariableType::LocalVariable) + throw AstError{ "Only local variables can be declared in a statement" }; + + const auto& localVar = static_cast(*node.variable); + auto& local = m_context->declaredLocals.emplace_back(); - local.name = node.variable->name; - local.type = node.variable->type; + local.name = localVar.name; + local.type = localVar.type; ShaderAstRecursiveVisitor::Visit(node); } From 3829f0a002ffbb77ad5f24f1699f7598b19557cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Wed, 5 Aug 2020 16:28:41 +0200 Subject: [PATCH 289/316] ShaderAstCloner: Improve code readability --- include/Nazara/Renderer/ShaderAstCloner.hpp | 6 +- src/Nazara/Renderer/ShaderAstCloner.cpp | 124 ++++++++------------ 2 files changed, 52 insertions(+), 78 deletions(-) diff --git a/include/Nazara/Renderer/ShaderAstCloner.hpp b/include/Nazara/Renderer/ShaderAstCloner.hpp index b48de17b8..20d1ed52b 100644 --- a/include/Nazara/Renderer/ShaderAstCloner.hpp +++ b/include/Nazara/Renderer/ShaderAstCloner.hpp @@ -29,8 +29,9 @@ namespace Nz ShaderAstCloner& operator=(ShaderAstCloner&&) = default; private: - void Visit(const ShaderNodes::ExpressionPtr& expr); - void Visit(const ShaderNodes::StatementPtr& statement); + ShaderNodes::ExpressionPtr CloneExpression(const ShaderNodes::ExpressionPtr& expr); + ShaderNodes::StatementPtr CloneStatement(const ShaderNodes::StatementPtr& statement); + ShaderNodes::VariablePtr CloneVariable(const ShaderNodes::VariablePtr& statement); void Visit(const ShaderNodes::AccessMember& node) override; void Visit(const ShaderNodes::AssignOp& node) override; @@ -46,7 +47,6 @@ namespace Nz void Visit(const ShaderNodes::StatementBlock& node) override; void Visit(const ShaderNodes::SwizzleOp& node) override; - using ShaderVarVisitor::Visit; void Visit(const ShaderNodes::BuiltinVariable& var) override; void Visit(const ShaderNodes::InputVariable& var) override; void Visit(const ShaderNodes::LocalVariable& var) override; diff --git a/src/Nazara/Renderer/ShaderAstCloner.cpp b/src/Nazara/Renderer/ShaderAstCloner.cpp index f4ec37329..75ac0634c 100644 --- a/src/Nazara/Renderer/ShaderAstCloner.cpp +++ b/src/Nazara/Renderer/ShaderAstCloner.cpp @@ -13,92 +13,81 @@ namespace Nz ShaderAstVisitor::Visit(statement); if (!m_expressionStack.empty() || !m_variableStack.empty() || m_statementStack.size() != 1) - throw std::runtime_error("An error occured during clone"); + throw std::runtime_error("An error occurred during clone"); return PopStatement(); } - void ShaderAstCloner::Visit(const ShaderNodes::ExpressionPtr& expr) + ShaderNodes::ExpressionPtr ShaderAstCloner::CloneExpression(const ShaderNodes::ExpressionPtr& expr) { - if (expr) - ShaderAstVisitor::Visit(expr); - else - PushExpression(nullptr); + if (!expr) + return nullptr; + + ShaderAstVisitor::Visit(expr); + return PopExpression(); } - void ShaderAstCloner::Visit(const ShaderNodes::StatementPtr& statement) + ShaderNodes::StatementPtr ShaderAstCloner::CloneStatement(const ShaderNodes::StatementPtr& statement) { - if (statement) - ShaderAstVisitor::Visit(statement); - else - PushStatement(nullptr); + if (!statement) + return nullptr; + + ShaderAstVisitor::Visit(statement); + return PopStatement(); + } + + ShaderNodes::VariablePtr ShaderAstCloner::CloneVariable(const ShaderNodes::VariablePtr& variable) + { + if (!variable) + return nullptr; + + ShaderVarVisitor::Visit(variable); + return PopVariable(); } void ShaderAstCloner::Visit(const ShaderNodes::AccessMember& node) { - Visit(node.structExpr); - - PushExpression(ShaderNodes::AccessMember::Build(PopExpression(), node.memberIndex, node.exprType)); + PushExpression(ShaderNodes::AccessMember::Build(CloneExpression(node.structExpr), node.memberIndex, node.exprType)); } void ShaderAstCloner::Visit(const ShaderNodes::AssignOp& node) { - Visit(node.left); - Visit(node.right); - - auto right = PopExpression(); - auto left = PopExpression(); - - PushExpression(ShaderNodes::AssignOp::Build(node.op, std::move(left), std::move(right))); + PushExpression(ShaderNodes::AssignOp::Build(node.op, CloneExpression(node.left), CloneExpression(node.right))); } void ShaderAstCloner::Visit(const ShaderNodes::BinaryOp& node) { - Visit(node.left); - Visit(node.right); - - auto right = PopExpression(); - auto left = PopExpression(); - - PushExpression(ShaderNodes::BinaryOp::Build(node.op, std::move(left), std::move(right))); + PushExpression(ShaderNodes::BinaryOp::Build(node.op, CloneExpression(node.left), CloneExpression(node.right))); } void ShaderAstCloner::Visit(const ShaderNodes::Branch& node) { + std::vector condStatements; + condStatements.reserve(node.condStatements.size()); + for (auto& cond : node.condStatements) { - Visit(cond.condition); - Visit(cond.statement); + auto& condStatement = condStatements.emplace_back(); + condStatement.condition = CloneExpression(cond.condition); + condStatement.statement = CloneStatement(cond.statement); } - Visit(node.elseStatement); - - auto elseStatement = PopStatement(); - - std::vector condStatements(node.condStatements.size()); - for (std::size_t i = 0; i < condStatements.size(); ++i) - { - auto& condStatement = condStatements[condStatements.size() - i - 1]; - condStatement.condition = PopExpression(); - condStatement.statement = PopStatement(); - } - - PushStatement(ShaderNodes::Branch::Build(std::move(condStatements), std::move(elseStatement))); + PushStatement(ShaderNodes::Branch::Build(std::move(condStatements), CloneStatement(node.elseStatement))); } void ShaderAstCloner::Visit(const ShaderNodes::Cast& node) { std::size_t expressionCount = 0; std::array expressions; - for (const auto& expr : node.expressions) + for (auto& expr : node.expressions) { - Visit(expr); + if (!expr) + break; + + expressions[expressionCount] = CloneExpression(expr); expressionCount++; } - for (std::size_t i = 0; i < expressionCount; ++i) - expressions[expressionCount - i - 1] = PopExpression(); - PushExpression(ShaderNodes::Cast::Build(node.exprType, expressions.data(), expressionCount)); } @@ -109,57 +98,42 @@ namespace Nz void ShaderAstCloner::Visit(const ShaderNodes::DeclareVariable& node) { - Visit(node.expression); - Visit(node.variable); - - PushStatement(ShaderNodes::DeclareVariable::Build(PopVariable(), PopExpression())); + PushStatement(ShaderNodes::DeclareVariable::Build(CloneVariable(node.variable), CloneExpression(node.expression))); } void ShaderAstCloner::Visit(const ShaderNodes::ExpressionStatement& node) { - Visit(node.expression); - - PushStatement(ShaderNodes::ExpressionStatement::Build(PopExpression())); + PushStatement(ShaderNodes::ExpressionStatement::Build(CloneExpression(node.expression))); } void ShaderAstCloner::Visit(const ShaderNodes::Identifier& node) { - Visit(node.var); - - PushExpression(ShaderNodes::Identifier::Build(PopVariable())); + PushExpression(ShaderNodes::Identifier::Build(CloneVariable(node.var))); } void ShaderAstCloner::Visit(const ShaderNodes::IntrinsicCall& node) { - for (auto& parameter : node.parameters) - Visit(parameter); + std::vector parameters; + parameters.reserve(node.parameters.size()); - std::vector parameters(node.parameters.size()); - for (std::size_t i = 0; i < parameters.size(); ++i) - parameters[parameters.size() - i - 1] = PopExpression(); + for (auto& parameter : node.parameters) + parameters.push_back(CloneExpression(parameter)); PushExpression(ShaderNodes::IntrinsicCall::Build(node.intrinsic, std::move(parameters))); } void ShaderAstCloner::Visit(const ShaderNodes::Sample2D& node) { - Visit(node.coordinates); - Visit(node.sampler); - - auto sampler = PopExpression(); - auto coordinates = PopExpression(); - - PushExpression(ShaderNodes::Sample2D::Build(std::move(sampler), std::move(coordinates))); + PushExpression(ShaderNodes::Sample2D::Build(CloneExpression(node.sampler), CloneExpression(node.coordinates))); } void ShaderAstCloner::Visit(const ShaderNodes::StatementBlock& node) { - for (auto& statement : node.statements) - Visit(statement); + std::vector statements; + statements.reserve(node.statements.size()); - std::vector statements(node.statements.size()); - for (std::size_t i = 0; i < statements.size(); ++i) - statements[statements.size() - i - 1] = PopStatement(); + for (auto& statement : node.statements) + statements.push_back(CloneStatement(statement)); PushStatement(ShaderNodes::StatementBlock::Build(std::move(statements))); } From 0da2ee6c99adf1b47b2c342af4c6ed18dc05e1bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sun, 9 Aug 2020 00:24:07 +0200 Subject: [PATCH 290/316] First rendering using Spir-V generated shaders \o/ --- examples/VulkanTest/main.cpp | 7 +- examples/bin/frag.shader | Bin 610 -> 610 bytes examples/bin/test.spirv | Bin 0 -> 824 bytes examples/bin/vert.shader | Bin 695 -> 695 bytes include/Nazara/Renderer/GlslWriter.hpp | 40 +- include/Nazara/Renderer/ShaderAstCloner.hpp | 38 +- .../Renderer/ShaderAstRecursiveVisitor.hpp | 26 +- .../Nazara/Renderer/ShaderAstSerializer.hpp | 12 + .../Nazara/Renderer/ShaderAstValidator.hpp | 38 +- include/Nazara/Renderer/ShaderAstVisitor.hpp | 26 +- include/Nazara/Renderer/ShaderEnums.hpp | 20 +- include/Nazara/Renderer/ShaderNodes.hpp | 8 +- include/Nazara/Renderer/ShaderNodes.inl | 8 + include/Nazara/Renderer/ShaderVarVisitor.hpp | 13 +- include/Nazara/Renderer/SpirvWriter.hpp | 42 +- src/Nazara/Renderer/GlslWriter.cpp | 87 +- src/Nazara/Renderer/Renderer.cpp | 2 +- src/Nazara/Renderer/ShaderAstCloner.cpp | 38 +- .../Renderer/ShaderAstRecursiveVisitor.cpp | 26 +- src/Nazara/Renderer/ShaderAstSerializer.cpp | 91 +- src/Nazara/Renderer/ShaderAstValidator.cpp | 63 +- src/Nazara/Renderer/ShaderNodes.cpp | 14 +- src/Nazara/Renderer/SpirvWriter.cpp | 829 +++++++++++++++--- src/Nazara/VulkanRenderer/Vulkan.cpp | 2 +- .../VulkanRenderer/VulkanShaderStage.cpp | 60 +- 25 files changed, 1117 insertions(+), 373 deletions(-) create mode 100644 examples/bin/test.spirv diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index 9a5313f9a..706cf047c 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -7,8 +8,8 @@ #define SPIRV 0 int main() -{ - { +{ + /*{ Nz::File file("frag.shader"); if (!file.Open(Nz::OpenMode_ReadOnly)) return __LINE__; @@ -39,7 +40,7 @@ int main() return 0; } - + */ Nz::Initializer loader; if (!loader) { diff --git a/examples/bin/frag.shader b/examples/bin/frag.shader index 1fbcce530ddddc3a7d749a622786ce22b08df3f9..cd71692bdb4ea28ccc2c395eea9cff48ef20d9e3 100644 GIT binary patch delta 80 zcmaFF@`zlC Sro`NWoYW!^lWXz{#$5nOYYy-L delta 68 zcmaFF@`zCB;>BD7r@2sA+Spq8|L{*)*pT>s zce@Eo9=mVe?97{ma_M;4Y{^)I{M)Q)r94u%avnk5w3=14H-t%)qzEg*ny?`>l#8Zf z7U+YPq_=O`BpU0eNF~or(#NNQSMz&!arzQx4^j3SPfzo_K)uYS@yC5Mc^}7Fad)xr zjcQT+3pm7a!*?h51(X9wp} z@WSuR!rPx*b+uo~AN}?O-seZT`0cqEKFDFteSsO_yxW1mn?36ez4=d&L;Tyt`Yukr VFBc1S#wXgfy7R7~Fqg{<;U7&^Dfa*X literal 0 HcmV?d00001 diff --git a/examples/bin/vert.shader b/examples/bin/vert.shader index b1fa132bbaea340fd46bf5c9b7f93ea34411ff74..2d5c2daca53655ae10ead8e456b58e596ff8c89c 100644 GIT binary patch delta 74 zcmdnax}9}`jtnOQ0|RS$eo;;ekih`rv6N+|mV-GHJ=Sn?gIGYoJGqfje6k4RIY!RO Qj~O+9Bo7maG-YZ603DzXasU7T delta 74 zcmdnax}9}`jtnaU0|RS$eo;;ekih`rv6N+|mV-GHJ=SotgIGYoJGqfje6k4RIY!pW Qj~O+9Bo7maG-YZ602&YuRsaA1 diff --git a/include/Nazara/Renderer/GlslWriter.hpp b/include/Nazara/Renderer/GlslWriter.hpp index 8178c73d4..d7229f1d9 100644 --- a/include/Nazara/Renderer/GlslWriter.hpp +++ b/include/Nazara/Renderer/GlslWriter.hpp @@ -61,26 +61,26 @@ namespace Nz using ShaderVarVisitor::Visit; using ShaderAstVisitor::Visit; - void Visit(const ShaderNodes::ExpressionPtr& expr, bool encloseIfRequired = false); - void Visit(const ShaderNodes::AccessMember& node) override; - void Visit(const ShaderNodes::AssignOp& node) override; - void Visit(const ShaderNodes::Branch& node) override; - void Visit(const ShaderNodes::BinaryOp& node) override; - void Visit(const ShaderNodes::BuiltinVariable& var) override; - void Visit(const ShaderNodes::Cast& node) override; - void Visit(const ShaderNodes::Constant& node) override; - void Visit(const ShaderNodes::DeclareVariable& node) override; - void Visit(const ShaderNodes::ExpressionStatement& node) override; - void Visit(const ShaderNodes::Identifier& node) override; - void Visit(const ShaderNodes::InputVariable& var) override; - void Visit(const ShaderNodes::IntrinsicCall& node) override; - void Visit(const ShaderNodes::LocalVariable& var) override; - void Visit(const ShaderNodes::ParameterVariable& var) override; - void Visit(const ShaderNodes::OutputVariable& var) override; - void Visit(const ShaderNodes::Sample2D& node) override; - void Visit(const ShaderNodes::StatementBlock& node) override; - void Visit(const ShaderNodes::SwizzleOp& node) override; - void Visit(const ShaderNodes::UniformVariable& var) override; + void Visit(ShaderNodes::ExpressionPtr& expr, bool encloseIfRequired = false); + void Visit(ShaderNodes::AccessMember& node) override; + void Visit(ShaderNodes::AssignOp& node) override; + void Visit(ShaderNodes::Branch& node) override; + void Visit(ShaderNodes::BinaryOp& node) override; + void Visit(ShaderNodes::BuiltinVariable& var) override; + void Visit(ShaderNodes::Cast& node) override; + void Visit(ShaderNodes::Constant& node) override; + void Visit(ShaderNodes::DeclareVariable& node) override; + void Visit(ShaderNodes::ExpressionStatement& node) override; + void Visit(ShaderNodes::Identifier& node) override; + void Visit(ShaderNodes::InputVariable& var) override; + void Visit(ShaderNodes::IntrinsicCall& node) override; + void Visit(ShaderNodes::LocalVariable& var) override; + void Visit(ShaderNodes::ParameterVariable& var) override; + void Visit(ShaderNodes::OutputVariable& var) override; + void Visit(ShaderNodes::Sample2D& node) override; + void Visit(ShaderNodes::StatementBlock& node) override; + void Visit(ShaderNodes::SwizzleOp& node) override; + void Visit(ShaderNodes::UniformVariable& var) override; static bool HasExplicitBinding(const ShaderAst& shader); static bool HasExplicitLocation(const ShaderAst& shader); diff --git a/include/Nazara/Renderer/ShaderAstCloner.hpp b/include/Nazara/Renderer/ShaderAstCloner.hpp index 20d1ed52b..ff1f9c5a4 100644 --- a/include/Nazara/Renderer/ShaderAstCloner.hpp +++ b/include/Nazara/Renderer/ShaderAstCloner.hpp @@ -33,26 +33,26 @@ namespace Nz ShaderNodes::StatementPtr CloneStatement(const ShaderNodes::StatementPtr& statement); ShaderNodes::VariablePtr CloneVariable(const ShaderNodes::VariablePtr& statement); - void Visit(const ShaderNodes::AccessMember& node) override; - void Visit(const ShaderNodes::AssignOp& node) override; - void Visit(const ShaderNodes::BinaryOp& node) override; - void Visit(const ShaderNodes::Branch& node) override; - void Visit(const ShaderNodes::Cast& node) override; - void Visit(const ShaderNodes::Constant& node) override; - void Visit(const ShaderNodes::DeclareVariable& node) override; - void Visit(const ShaderNodes::ExpressionStatement& node) override; - void Visit(const ShaderNodes::Identifier& node) override; - void Visit(const ShaderNodes::IntrinsicCall& node) override; - void Visit(const ShaderNodes::Sample2D& node) override; - void Visit(const ShaderNodes::StatementBlock& node) override; - void Visit(const ShaderNodes::SwizzleOp& node) override; + void Visit(ShaderNodes::AccessMember& node) override; + void Visit(ShaderNodes::AssignOp& node) override; + void Visit(ShaderNodes::BinaryOp& node) override; + void Visit(ShaderNodes::Branch& node) override; + void Visit(ShaderNodes::Cast& node) override; + void Visit(ShaderNodes::Constant& node) override; + void Visit(ShaderNodes::DeclareVariable& node) override; + void Visit(ShaderNodes::ExpressionStatement& node) override; + void Visit(ShaderNodes::Identifier& node) override; + void Visit(ShaderNodes::IntrinsicCall& node) override; + void Visit(ShaderNodes::Sample2D& node) override; + void Visit(ShaderNodes::StatementBlock& node) override; + void Visit(ShaderNodes::SwizzleOp& node) override; - void Visit(const ShaderNodes::BuiltinVariable& var) override; - void Visit(const ShaderNodes::InputVariable& var) override; - void Visit(const ShaderNodes::LocalVariable& var) override; - void Visit(const ShaderNodes::OutputVariable& var) override; - void Visit(const ShaderNodes::ParameterVariable& var) override; - void Visit(const ShaderNodes::UniformVariable& var) override; + void Visit(ShaderNodes::BuiltinVariable& var) override; + void Visit(ShaderNodes::InputVariable& var) override; + void Visit(ShaderNodes::LocalVariable& var) override; + void Visit(ShaderNodes::OutputVariable& var) override; + void Visit(ShaderNodes::ParameterVariable& var) override; + void Visit(ShaderNodes::UniformVariable& var) override; void PushExpression(ShaderNodes::ExpressionPtr expression); void PushStatement(ShaderNodes::StatementPtr statement); diff --git a/include/Nazara/Renderer/ShaderAstRecursiveVisitor.hpp b/include/Nazara/Renderer/ShaderAstRecursiveVisitor.hpp index 622c1aef0..0482ea009 100644 --- a/include/Nazara/Renderer/ShaderAstRecursiveVisitor.hpp +++ b/include/Nazara/Renderer/ShaderAstRecursiveVisitor.hpp @@ -21,19 +21,19 @@ namespace Nz using ShaderAstVisitor::Visit; - void Visit(const ShaderNodes::AccessMember& node) override; - void Visit(const ShaderNodes::AssignOp& node) override; - void Visit(const ShaderNodes::BinaryOp& node) override; - void Visit(const ShaderNodes::Branch& node) override; - void Visit(const ShaderNodes::Cast& node) override; - void Visit(const ShaderNodes::Constant& node) override; - void Visit(const ShaderNodes::DeclareVariable& node) override; - void Visit(const ShaderNodes::ExpressionStatement& node) override; - void Visit(const ShaderNodes::Identifier& node) override; - void Visit(const ShaderNodes::IntrinsicCall& node) override; - void Visit(const ShaderNodes::Sample2D& node) override; - void Visit(const ShaderNodes::StatementBlock& node) override; - void Visit(const ShaderNodes::SwizzleOp& node) override; + void Visit(ShaderNodes::AccessMember& node) override; + void Visit(ShaderNodes::AssignOp& node) override; + void Visit(ShaderNodes::BinaryOp& node) override; + void Visit(ShaderNodes::Branch& node) override; + void Visit(ShaderNodes::Cast& node) override; + void Visit(ShaderNodes::Constant& node) override; + void Visit(ShaderNodes::DeclareVariable& node) override; + void Visit(ShaderNodes::ExpressionStatement& node) override; + void Visit(ShaderNodes::Identifier& node) override; + void Visit(ShaderNodes::IntrinsicCall& node) override; + void Visit(ShaderNodes::Sample2D& node) override; + void Visit(ShaderNodes::StatementBlock& node) override; + void Visit(ShaderNodes::SwizzleOp& node) override; }; } diff --git a/include/Nazara/Renderer/ShaderAstSerializer.hpp b/include/Nazara/Renderer/ShaderAstSerializer.hpp index 68380054c..3298d81e6 100644 --- a/include/Nazara/Renderer/ShaderAstSerializer.hpp +++ b/include/Nazara/Renderer/ShaderAstSerializer.hpp @@ -57,9 +57,13 @@ namespace Nz virtual void Value(bool& val) = 0; virtual void Value(float& val) = 0; virtual void Value(std::string& val) = 0; + virtual void Value(Int32& val) = 0; virtual void Value(Vector2f& val) = 0; virtual void Value(Vector3f& val) = 0; virtual void Value(Vector4f& val) = 0; + virtual void Value(Vector2i32& val) = 0; + virtual void Value(Vector3i32& val) = 0; + virtual void Value(Vector4i32& val) = 0; virtual void Value(UInt8& val) = 0; virtual void Value(UInt16& val) = 0; virtual void Value(UInt32& val) = 0; @@ -85,9 +89,13 @@ namespace Nz void Value(bool& val) override; void Value(float& val) override; void Value(std::string& val) override; + void Value(Int32& val) override; void Value(Vector2f& val) override; void Value(Vector3f& val) override; void Value(Vector4f& val) override; + void Value(Vector2i32& val) override; + void Value(Vector3i32& val) override; + void Value(Vector4i32& val) override; void Value(UInt8& val) override; void Value(UInt16& val) override; void Value(UInt32& val) override; @@ -111,9 +119,13 @@ namespace Nz void Value(bool& val) override; void Value(float& val) override; void Value(std::string& val) override; + void Value(Int32& val) override; void Value(Vector2f& val) override; void Value(Vector3f& val) override; void Value(Vector4f& val) override; + void Value(Vector2i32& val) override; + void Value(Vector3i32& val) override; + void Value(Vector4i32& val) override; void Value(UInt8& val) override; void Value(UInt16& val) override; void Value(UInt32& val) override; diff --git a/include/Nazara/Renderer/ShaderAstValidator.hpp b/include/Nazara/Renderer/ShaderAstValidator.hpp index aa586f99b..90aec52aa 100644 --- a/include/Nazara/Renderer/ShaderAstValidator.hpp +++ b/include/Nazara/Renderer/ShaderAstValidator.hpp @@ -34,27 +34,27 @@ namespace Nz void TypeMustMatch(const ShaderExpressionType& left, const ShaderExpressionType& right); using ShaderAstRecursiveVisitor::Visit; - void Visit(const ShaderNodes::AccessMember& node) override; - void Visit(const ShaderNodes::AssignOp& node) override; - void Visit(const ShaderNodes::BinaryOp& node) override; - void Visit(const ShaderNodes::Branch& node) override; - void Visit(const ShaderNodes::Cast& node) override; - void Visit(const ShaderNodes::Constant& node) override; - void Visit(const ShaderNodes::DeclareVariable& node) override; - void Visit(const ShaderNodes::ExpressionStatement& node) override; - void Visit(const ShaderNodes::Identifier& node) override; - void Visit(const ShaderNodes::IntrinsicCall& node) override; - void Visit(const ShaderNodes::Sample2D& node) override; - void Visit(const ShaderNodes::StatementBlock& node) override; - void Visit(const ShaderNodes::SwizzleOp& node) override; + void Visit(ShaderNodes::AccessMember& node) override; + void Visit(ShaderNodes::AssignOp& node) override; + void Visit(ShaderNodes::BinaryOp& node) override; + void Visit(ShaderNodes::Branch& node) override; + void Visit(ShaderNodes::Cast& node) override; + void Visit(ShaderNodes::Constant& node) override; + void Visit(ShaderNodes::DeclareVariable& node) override; + void Visit(ShaderNodes::ExpressionStatement& node) override; + void Visit(ShaderNodes::Identifier& node) override; + void Visit(ShaderNodes::IntrinsicCall& node) override; + void Visit(ShaderNodes::Sample2D& node) override; + void Visit(ShaderNodes::StatementBlock& node) override; + void Visit(ShaderNodes::SwizzleOp& node) override; using ShaderVarVisitor::Visit; - void Visit(const ShaderNodes::BuiltinVariable& var) override; - void Visit(const ShaderNodes::InputVariable& var) override; - void Visit(const ShaderNodes::LocalVariable& var) override; - void Visit(const ShaderNodes::OutputVariable& var) override; - void Visit(const ShaderNodes::ParameterVariable& var) override; - void Visit(const ShaderNodes::UniformVariable& var) override; + void Visit(ShaderNodes::BuiltinVariable& var) override; + void Visit(ShaderNodes::InputVariable& var) override; + void Visit(ShaderNodes::LocalVariable& var) override; + void Visit(ShaderNodes::OutputVariable& var) override; + void Visit(ShaderNodes::ParameterVariable& var) override; + void Visit(ShaderNodes::UniformVariable& var) override; struct Context; diff --git a/include/Nazara/Renderer/ShaderAstVisitor.hpp b/include/Nazara/Renderer/ShaderAstVisitor.hpp index d955f17e9..3ce83f406 100644 --- a/include/Nazara/Renderer/ShaderAstVisitor.hpp +++ b/include/Nazara/Renderer/ShaderAstVisitor.hpp @@ -27,20 +27,20 @@ namespace Nz bool IsConditionEnabled(const std::string& name) const; - virtual void Visit(const ShaderNodes::AccessMember& node) = 0; - virtual void Visit(const ShaderNodes::AssignOp& node) = 0; - virtual void Visit(const ShaderNodes::BinaryOp& node) = 0; - virtual void Visit(const ShaderNodes::Branch& node) = 0; - virtual void Visit(const ShaderNodes::Cast& node) = 0; - virtual void Visit(const ShaderNodes::Constant& node) = 0; - virtual void Visit(const ShaderNodes::DeclareVariable& node) = 0; - virtual void Visit(const ShaderNodes::ExpressionStatement& node) = 0; - virtual void Visit(const ShaderNodes::Identifier& node) = 0; - virtual void Visit(const ShaderNodes::IntrinsicCall& node) = 0; void Visit(const ShaderNodes::NodePtr& node); - virtual void Visit(const ShaderNodes::Sample2D& node) = 0; - virtual void Visit(const ShaderNodes::StatementBlock& node) = 0; - virtual void Visit(const ShaderNodes::SwizzleOp& node) = 0; + virtual void Visit(ShaderNodes::AccessMember& node) = 0; + virtual void Visit(ShaderNodes::AssignOp& node) = 0; + virtual void Visit(ShaderNodes::BinaryOp& node) = 0; + virtual void Visit(ShaderNodes::Branch& node) = 0; + virtual void Visit(ShaderNodes::Cast& node) = 0; + virtual void Visit(ShaderNodes::Constant& node) = 0; + virtual void Visit(ShaderNodes::DeclareVariable& node) = 0; + virtual void Visit(ShaderNodes::ExpressionStatement& node) = 0; + virtual void Visit(ShaderNodes::Identifier& node) = 0; + virtual void Visit(ShaderNodes::IntrinsicCall& node) = 0; + virtual void Visit(ShaderNodes::Sample2D& node) = 0; + virtual void Visit(ShaderNodes::StatementBlock& node) = 0; + virtual void Visit(ShaderNodes::SwizzleOp& node) = 0; private: std::unordered_set m_conditions; diff --git a/include/Nazara/Renderer/ShaderEnums.hpp b/include/Nazara/Renderer/ShaderEnums.hpp index ab9ed4953..46e6a3d74 100644 --- a/include/Nazara/Renderer/ShaderEnums.hpp +++ b/include/Nazara/Renderer/ShaderEnums.hpp @@ -18,15 +18,19 @@ namespace Nz::ShaderNodes enum class BasicType { - Boolean, // bool - Float1, // float - Float2, // vec2 - Float3, // vec3 - Float4, // vec4 - Mat4x4, // mat4 - Sampler2D, // sampler2D + Boolean, //< bool + Float1, //< float + Float2, //< vec2 + Float3, //< vec3 + Float4, //< vec4 + Int1, //< int + Int2, //< ivec2 + Int3, //< ivec3 + Int4, //< ivec4 + Mat4x4, //< mat4 + Sampler2D, //< sampler2D - Void // void + Void //< void }; enum class BinaryType diff --git a/include/Nazara/Renderer/ShaderNodes.hpp b/include/Nazara/Renderer/ShaderNodes.hpp index c0b8688e2..985cde039 100644 --- a/include/Nazara/Renderer/ShaderNodes.hpp +++ b/include/Nazara/Renderer/ShaderNodes.hpp @@ -145,7 +145,7 @@ namespace Nz std::size_t memberIndex; ExpressionPtr structExpr; - ShaderExpressionType exprType; //< FIXME: Use ShaderAst to automate + ShaderExpressionType exprType; static inline std::shared_ptr Build(ExpressionPtr structExpr, std::size_t memberIndex, ShaderExpressionType exprType); }; @@ -225,9 +225,13 @@ namespace Nz using Variant = std::variant< bool, float, + Int32, Vector2f, Vector3f, - Vector4f + Vector4f, + Vector2i32, + Vector3i32, + Vector4i32 >; Variant value; diff --git a/include/Nazara/Renderer/ShaderNodes.inl b/include/Nazara/Renderer/ShaderNodes.inl index 0e9307ff4..e6dbec2ba 100644 --- a/include/Nazara/Renderer/ShaderNodes.inl +++ b/include/Nazara/Renderer/ShaderNodes.inl @@ -28,12 +28,15 @@ namespace Nz::ShaderNodes switch (type) { case BasicType::Float2: + case BasicType::Int2: return 2; case BasicType::Float3: + case BasicType::Int3: return 3; case BasicType::Float4: + case BasicType::Int4: return 4; case BasicType::Mat4x4: @@ -53,6 +56,11 @@ namespace Nz::ShaderNodes case BasicType::Float4: return BasicType::Float1; + case BasicType::Int2: + case BasicType::Int3: + case BasicType::Int4: + return BasicType::Int1; + case BasicType::Mat4x4: return BasicType::Float4; diff --git a/include/Nazara/Renderer/ShaderVarVisitor.hpp b/include/Nazara/Renderer/ShaderVarVisitor.hpp index 6df035d74..bda5e0b4d 100644 --- a/include/Nazara/Renderer/ShaderVarVisitor.hpp +++ b/include/Nazara/Renderer/ShaderVarVisitor.hpp @@ -21,13 +21,14 @@ namespace Nz ShaderVarVisitor(ShaderVarVisitor&&) = delete; virtual ~ShaderVarVisitor(); - virtual void Visit(const ShaderNodes::BuiltinVariable& var) = 0; - virtual void Visit(const ShaderNodes::InputVariable& var) = 0; - virtual void Visit(const ShaderNodes::LocalVariable& var) = 0; - virtual void Visit(const ShaderNodes::OutputVariable& var) = 0; - virtual void Visit(const ShaderNodes::ParameterVariable& var) = 0; - virtual void Visit(const ShaderNodes::UniformVariable& var) = 0; void Visit(const ShaderNodes::VariablePtr& node); + + virtual void Visit(ShaderNodes::BuiltinVariable& var) = 0; + virtual void Visit(ShaderNodes::InputVariable& var) = 0; + virtual void Visit(ShaderNodes::LocalVariable& var) = 0; + virtual void Visit(ShaderNodes::OutputVariable& var) = 0; + virtual void Visit(ShaderNodes::ParameterVariable& var) = 0; + virtual void Visit(ShaderNodes::UniformVariable& var) = 0; }; } diff --git a/include/Nazara/Renderer/SpirvWriter.hpp b/include/Nazara/Renderer/SpirvWriter.hpp index 2301d6caf..b9e48dd12 100644 --- a/include/Nazara/Renderer/SpirvWriter.hpp +++ b/include/Nazara/Renderer/SpirvWriter.hpp @@ -10,8 +10,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -20,7 +20,7 @@ namespace Nz { - class NAZARA_RENDERER_API SpirvWriter : public ShaderAstVisitor + class NAZARA_RENDERER_API SpirvWriter : public ShaderAstVisitor, public ShaderVarVisitor { public: struct Environment; @@ -41,6 +41,7 @@ namespace Nz }; private: + struct ExtVar; struct Opcode; struct Raw; struct WordCount; @@ -76,28 +77,39 @@ namespace Nz void AppendStructType(std::size_t structIndex, UInt32 resultId); void AppendTypes(); + UInt32 EvaluateExpression(const ShaderNodes::ExpressionPtr& expr); + UInt32 GetConstantId(const ShaderNodes::Constant::Variant& value) const; UInt32 GetTypeId(const ShaderExpressionType& type) const; void PushResultId(UInt32 value); UInt32 PopResultId(); + UInt32 ReadVariable(ExtVar& var); UInt32 RegisterType(ShaderExpressionType type); using ShaderAstVisitor::Visit; - void Visit(const ShaderNodes::AccessMember& node) override; - void Visit(const ShaderNodes::AssignOp& node) override; - void Visit(const ShaderNodes::Branch& node) override; - void Visit(const ShaderNodes::BinaryOp& node) override; - void Visit(const ShaderNodes::Cast& node) override; - void Visit(const ShaderNodes::Constant& node) override; - void Visit(const ShaderNodes::DeclareVariable& node) override; - void Visit(const ShaderNodes::ExpressionStatement& node) override; - void Visit(const ShaderNodes::Identifier& node) override; - void Visit(const ShaderNodes::IntrinsicCall& node) override; - void Visit(const ShaderNodes::Sample2D& node) override; - void Visit(const ShaderNodes::StatementBlock& node) override; - void Visit(const ShaderNodes::SwizzleOp& node) override; + void Visit(ShaderNodes::AccessMember& node) override; + void Visit(ShaderNodes::AssignOp& node) override; + void Visit(ShaderNodes::Branch& node) override; + void Visit(ShaderNodes::BinaryOp& node) override; + void Visit(ShaderNodes::Cast& node) override; + void Visit(ShaderNodes::Constant& node) override; + void Visit(ShaderNodes::DeclareVariable& node) override; + void Visit(ShaderNodes::ExpressionStatement& node) override; + void Visit(ShaderNodes::Identifier& node) override; + void Visit(ShaderNodes::IntrinsicCall& node) override; + void Visit(ShaderNodes::Sample2D& node) override; + void Visit(ShaderNodes::StatementBlock& node) override; + void Visit(ShaderNodes::SwizzleOp& node) override; + + using ShaderVarVisitor::Visit; + void Visit(ShaderNodes::BuiltinVariable& var) override; + void Visit(ShaderNodes::InputVariable& var) override; + void Visit(ShaderNodes::LocalVariable& var) override; + void Visit(ShaderNodes::OutputVariable& var) override; + void Visit(ShaderNodes::ParameterVariable& var) override; + void Visit(ShaderNodes::UniformVariable& var) override; static void MergeBlocks(std::vector& output, const Section& from); diff --git a/src/Nazara/Renderer/GlslWriter.cpp b/src/Nazara/Renderer/GlslWriter.cpp index 8fa23755a..3d651a84f 100644 --- a/src/Nazara/Renderer/GlslWriter.cpp +++ b/src/Nazara/Renderer/GlslWriter.cpp @@ -188,30 +188,18 @@ namespace Nz { switch (type) { - case ShaderNodes::BasicType::Boolean: - Append("bool"); - break; - case ShaderNodes::BasicType::Float1: - Append("float"); - break; - case ShaderNodes::BasicType::Float2: - Append("vec2"); - break; - case ShaderNodes::BasicType::Float3: - Append("vec3"); - break; - case ShaderNodes::BasicType::Float4: - Append("vec4"); - break; - case ShaderNodes::BasicType::Mat4x4: - Append("mat4"); - break; - case ShaderNodes::BasicType::Sampler2D: - Append("sampler2D"); - break; - case ShaderNodes::BasicType::Void: - Append("void"); - break; + case ShaderNodes::BasicType::Boolean: return Append("bool"); + case ShaderNodes::BasicType::Float1: return Append("float"); + case ShaderNodes::BasicType::Float2: return Append("vec2"); + case ShaderNodes::BasicType::Float3: return Append("vec3"); + case ShaderNodes::BasicType::Float4: return Append("vec4"); + case ShaderNodes::BasicType::Int1: return Append("int"); + case ShaderNodes::BasicType::Int2: return Append("ivec2"); + case ShaderNodes::BasicType::Int3: return Append("ivec3"); + case ShaderNodes::BasicType::Int4: return Append("ivec4"); + case ShaderNodes::BasicType::Mat4x4: return Append("mat4"); + case ShaderNodes::BasicType::Sampler2D: return Append("sampler2D"); + case ShaderNodes::BasicType::Void: return Append("void"); } } @@ -298,7 +286,7 @@ namespace Nz AppendLine("}"); } - void GlslWriter::Visit(const ShaderNodes::ExpressionPtr& expr, bool encloseIfRequired) + void GlslWriter::Visit(ShaderNodes::ExpressionPtr& expr, bool encloseIfRequired) { bool enclose = encloseIfRequired && (expr->GetExpressionCategory() != ShaderNodes::ExpressionCategory::LValue); @@ -311,7 +299,7 @@ namespace Nz Append(")"); } - void GlslWriter::Visit(const ShaderNodes::AccessMember& node) + void GlslWriter::Visit(ShaderNodes::AccessMember& node) { Visit(node.structExpr, true); @@ -332,7 +320,7 @@ namespace Nz Append(member.name); } - void GlslWriter::Visit(const ShaderNodes::AssignOp& node) + void GlslWriter::Visit(ShaderNodes::AssignOp& node) { Visit(node.left); @@ -346,7 +334,7 @@ namespace Nz Visit(node.right); } - void GlslWriter::Visit(const ShaderNodes::Branch& node) + void GlslWriter::Visit(ShaderNodes::Branch& node) { bool first = true; for (const auto& statement : node.condStatements) @@ -375,7 +363,7 @@ namespace Nz } } - void GlslWriter::Visit(const ShaderNodes::BinaryOp& node) + void GlslWriter::Visit(ShaderNodes::BinaryOp& node) { Visit(node.left, true); @@ -401,12 +389,12 @@ namespace Nz Visit(node.right, true); } - void GlslWriter::Visit(const ShaderNodes::BuiltinVariable& var) + void GlslWriter::Visit(ShaderNodes::BuiltinVariable& var) { Append(var.entry); } - void GlslWriter::Visit(const ShaderNodes::Cast& node) + void GlslWriter::Visit(ShaderNodes::Cast& node) { Append(node.exprType); Append("("); @@ -425,28 +413,31 @@ namespace Nz Append(")"); } - void GlslWriter::Visit(const ShaderNodes::Constant& node) + void GlslWriter::Visit(ShaderNodes::Constant& node) { std::visit([&](auto&& arg) { using T = std::decay_t; + if constexpr (std::is_same_v || std::is_same_v || std::is_same_v) + Append("i"); //< for ivec + if constexpr (std::is_same_v) Append((arg) ? "true" : "false"); - else if constexpr (std::is_same_v) + else if constexpr (std::is_same_v || std::is_same_v) Append(std::to_string(arg)); - else if constexpr (std::is_same_v) + else if constexpr (std::is_same_v || std::is_same_v) Append("vec2(" + std::to_string(arg.x) + ", " + std::to_string(arg.y) + ")"); - else if constexpr (std::is_same_v) + else if constexpr (std::is_same_v || std::is_same_v) Append("vec3(" + std::to_string(arg.x) + ", " + std::to_string(arg.y) + ", " + std::to_string(arg.z) + ")"); - else if constexpr (std::is_same_v) + else if constexpr (std::is_same_v || std::is_same_v) Append("vec4(" + std::to_string(arg.x) + ", " + std::to_string(arg.y) + ", " + std::to_string(arg.z) + ", " + std::to_string(arg.w) + ")"); else static_assert(AlwaysFalse::value, "non-exhaustive visitor"); }, node.value); } - void GlslWriter::Visit(const ShaderNodes::DeclareVariable& node) + void GlslWriter::Visit(ShaderNodes::DeclareVariable& node) { assert(node.variable->GetType() == ShaderNodes::VariableType::LocalVariable); @@ -464,23 +455,23 @@ namespace Nz AppendLine(";"); } - void GlslWriter::Visit(const ShaderNodes::ExpressionStatement& node) + void GlslWriter::Visit(ShaderNodes::ExpressionStatement& node) { Visit(node.expression); Append(";"); } - void GlslWriter::Visit(const ShaderNodes::Identifier& node) + void GlslWriter::Visit(ShaderNodes::Identifier& node) { Visit(node.var); } - void GlslWriter::Visit(const ShaderNodes::InputVariable& var) + void GlslWriter::Visit(ShaderNodes::InputVariable& var) { Append(var.name); } - void GlslWriter::Visit(const ShaderNodes::IntrinsicCall& node) + void GlslWriter::Visit(ShaderNodes::IntrinsicCall& node) { switch (node.intrinsic) { @@ -504,22 +495,22 @@ namespace Nz Append(")"); } - void GlslWriter::Visit(const ShaderNodes::LocalVariable& var) + void GlslWriter::Visit(ShaderNodes::LocalVariable& var) { Append(var.name); } - void GlslWriter::Visit(const ShaderNodes::ParameterVariable& var) + void GlslWriter::Visit(ShaderNodes::ParameterVariable& var) { Append(var.name); } - void GlslWriter::Visit(const ShaderNodes::OutputVariable& var) + void GlslWriter::Visit(ShaderNodes::OutputVariable& var) { Append(var.name); } - void GlslWriter::Visit(const ShaderNodes::Sample2D& node) + void GlslWriter::Visit(ShaderNodes::Sample2D& node) { Append("texture("); Visit(node.sampler); @@ -528,7 +519,7 @@ namespace Nz Append(")"); } - void GlslWriter::Visit(const ShaderNodes::StatementBlock& node) + void GlslWriter::Visit(ShaderNodes::StatementBlock& node) { bool first = true; for (const ShaderNodes::StatementPtr& statement : node.statements) @@ -542,7 +533,7 @@ namespace Nz } } - void GlslWriter::Visit(const ShaderNodes::SwizzleOp& node) + void GlslWriter::Visit(ShaderNodes::SwizzleOp& node) { Visit(node.expression); Append("."); @@ -570,7 +561,7 @@ namespace Nz } } - void GlslWriter::Visit(const ShaderNodes::UniformVariable& var) + void GlslWriter::Visit(ShaderNodes::UniformVariable& var) { Append(var.name); } diff --git a/src/Nazara/Renderer/Renderer.cpp b/src/Nazara/Renderer/Renderer.cpp index 9df137326..6954f5cf0 100644 --- a/src/Nazara/Renderer/Renderer.cpp +++ b/src/Nazara/Renderer/Renderer.cpp @@ -69,7 +69,7 @@ namespace Nz }; RegisterImpl("NazaraOpenGLRenderer" NazaraRendererDebugSuffix, [] { return 50; }); - //RegisterImpl("NazaraVulkanRenderer" NazaraRendererDebugSuffix, [] { return 100; }); + RegisterImpl("NazaraVulkanRenderer" NazaraRendererDebugSuffix, [] { return 100; }); std::sort(implementations.begin(), implementations.end(), [](const auto& lhs, const auto& rhs) { return lhs.score > rhs.score; }); diff --git a/src/Nazara/Renderer/ShaderAstCloner.cpp b/src/Nazara/Renderer/ShaderAstCloner.cpp index 75ac0634c..2b712075c 100644 --- a/src/Nazara/Renderer/ShaderAstCloner.cpp +++ b/src/Nazara/Renderer/ShaderAstCloner.cpp @@ -45,22 +45,22 @@ namespace Nz return PopVariable(); } - void ShaderAstCloner::Visit(const ShaderNodes::AccessMember& node) + void ShaderAstCloner::Visit(ShaderNodes::AccessMember& node) { PushExpression(ShaderNodes::AccessMember::Build(CloneExpression(node.structExpr), node.memberIndex, node.exprType)); } - void ShaderAstCloner::Visit(const ShaderNodes::AssignOp& node) + void ShaderAstCloner::Visit(ShaderNodes::AssignOp& node) { PushExpression(ShaderNodes::AssignOp::Build(node.op, CloneExpression(node.left), CloneExpression(node.right))); } - void ShaderAstCloner::Visit(const ShaderNodes::BinaryOp& node) + void ShaderAstCloner::Visit(ShaderNodes::BinaryOp& node) { PushExpression(ShaderNodes::BinaryOp::Build(node.op, CloneExpression(node.left), CloneExpression(node.right))); } - void ShaderAstCloner::Visit(const ShaderNodes::Branch& node) + void ShaderAstCloner::Visit(ShaderNodes::Branch& node) { std::vector condStatements; condStatements.reserve(node.condStatements.size()); @@ -75,7 +75,7 @@ namespace Nz PushStatement(ShaderNodes::Branch::Build(std::move(condStatements), CloneStatement(node.elseStatement))); } - void ShaderAstCloner::Visit(const ShaderNodes::Cast& node) + void ShaderAstCloner::Visit(ShaderNodes::Cast& node) { std::size_t expressionCount = 0; std::array expressions; @@ -91,27 +91,27 @@ namespace Nz PushExpression(ShaderNodes::Cast::Build(node.exprType, expressions.data(), expressionCount)); } - void ShaderAstCloner::Visit(const ShaderNodes::Constant& node) + void ShaderAstCloner::Visit(ShaderNodes::Constant& node) { PushExpression(ShaderNodes::Constant::Build(node.value)); } - void ShaderAstCloner::Visit(const ShaderNodes::DeclareVariable& node) + void ShaderAstCloner::Visit(ShaderNodes::DeclareVariable& node) { PushStatement(ShaderNodes::DeclareVariable::Build(CloneVariable(node.variable), CloneExpression(node.expression))); } - void ShaderAstCloner::Visit(const ShaderNodes::ExpressionStatement& node) + void ShaderAstCloner::Visit(ShaderNodes::ExpressionStatement& node) { PushStatement(ShaderNodes::ExpressionStatement::Build(CloneExpression(node.expression))); } - void ShaderAstCloner::Visit(const ShaderNodes::Identifier& node) + void ShaderAstCloner::Visit(ShaderNodes::Identifier& node) { PushExpression(ShaderNodes::Identifier::Build(CloneVariable(node.var))); } - void ShaderAstCloner::Visit(const ShaderNodes::IntrinsicCall& node) + void ShaderAstCloner::Visit(ShaderNodes::IntrinsicCall& node) { std::vector parameters; parameters.reserve(node.parameters.size()); @@ -122,12 +122,12 @@ namespace Nz PushExpression(ShaderNodes::IntrinsicCall::Build(node.intrinsic, std::move(parameters))); } - void ShaderAstCloner::Visit(const ShaderNodes::Sample2D& node) + void ShaderAstCloner::Visit(ShaderNodes::Sample2D& node) { PushExpression(ShaderNodes::Sample2D::Build(CloneExpression(node.sampler), CloneExpression(node.coordinates))); } - void ShaderAstCloner::Visit(const ShaderNodes::StatementBlock& node) + void ShaderAstCloner::Visit(ShaderNodes::StatementBlock& node) { std::vector statements; statements.reserve(node.statements.size()); @@ -138,37 +138,37 @@ namespace Nz PushStatement(ShaderNodes::StatementBlock::Build(std::move(statements))); } - void ShaderAstCloner::Visit(const ShaderNodes::SwizzleOp& node) + void ShaderAstCloner::Visit(ShaderNodes::SwizzleOp& node) { PushExpression(ShaderNodes::SwizzleOp::Build(PopExpression(), node.components.data(), node.componentCount)); } - void ShaderAstCloner::Visit(const ShaderNodes::BuiltinVariable& var) + void ShaderAstCloner::Visit(ShaderNodes::BuiltinVariable& var) { PushVariable(ShaderNodes::BuiltinVariable::Build(var.entry, var.type)); } - void ShaderAstCloner::Visit(const ShaderNodes::InputVariable& var) + void ShaderAstCloner::Visit(ShaderNodes::InputVariable& var) { PushVariable(ShaderNodes::InputVariable::Build(var.name, var.type)); } - void ShaderAstCloner::Visit(const ShaderNodes::LocalVariable& var) + void ShaderAstCloner::Visit(ShaderNodes::LocalVariable& var) { PushVariable(ShaderNodes::LocalVariable::Build(var.name, var.type)); } - void ShaderAstCloner::Visit(const ShaderNodes::OutputVariable& var) + void ShaderAstCloner::Visit(ShaderNodes::OutputVariable& var) { PushVariable(ShaderNodes::OutputVariable::Build(var.name, var.type)); } - void ShaderAstCloner::Visit(const ShaderNodes::ParameterVariable& var) + void ShaderAstCloner::Visit(ShaderNodes::ParameterVariable& var) { PushVariable(ShaderNodes::ParameterVariable::Build(var.name, var.type)); } - void ShaderAstCloner::Visit(const ShaderNodes::UniformVariable& var) + void ShaderAstCloner::Visit(ShaderNodes::UniformVariable& var) { PushVariable(ShaderNodes::UniformVariable::Build(var.name, var.type)); } diff --git a/src/Nazara/Renderer/ShaderAstRecursiveVisitor.cpp b/src/Nazara/Renderer/ShaderAstRecursiveVisitor.cpp index 81344bcf0..5a39e68c5 100644 --- a/src/Nazara/Renderer/ShaderAstRecursiveVisitor.cpp +++ b/src/Nazara/Renderer/ShaderAstRecursiveVisitor.cpp @@ -7,24 +7,24 @@ namespace Nz { - void ShaderAstRecursiveVisitor::Visit(const ShaderNodes::AccessMember& node) + void ShaderAstRecursiveVisitor::Visit(ShaderNodes::AccessMember& node) { Visit(node.structExpr); } - void ShaderAstRecursiveVisitor::Visit(const ShaderNodes::AssignOp& node) + void ShaderAstRecursiveVisitor::Visit(ShaderNodes::AssignOp& node) { Visit(node.left); Visit(node.right); } - void ShaderAstRecursiveVisitor::Visit(const ShaderNodes::BinaryOp& node) + void ShaderAstRecursiveVisitor::Visit(ShaderNodes::BinaryOp& node) { Visit(node.left); Visit(node.right); } - void ShaderAstRecursiveVisitor::Visit(const ShaderNodes::Branch& node) + void ShaderAstRecursiveVisitor::Visit(ShaderNodes::Branch& node) { for (auto& cond : node.condStatements) { @@ -36,7 +36,7 @@ namespace Nz Visit(node.elseStatement); } - void ShaderAstRecursiveVisitor::Visit(const ShaderNodes::Cast& node) + void ShaderAstRecursiveVisitor::Visit(ShaderNodes::Cast& node) { for (auto& expr : node.expressions) { @@ -47,46 +47,46 @@ namespace Nz } } - void ShaderAstRecursiveVisitor::Visit(const ShaderNodes::Constant& /*node*/) + void ShaderAstRecursiveVisitor::Visit(ShaderNodes::Constant& /*node*/) { /* Nothing to do */ } - void ShaderAstRecursiveVisitor::Visit(const ShaderNodes::DeclareVariable& node) + void ShaderAstRecursiveVisitor::Visit(ShaderNodes::DeclareVariable& node) { if (node.expression) Visit(node.expression); } - void ShaderAstRecursiveVisitor::Visit(const ShaderNodes::ExpressionStatement& node) + void ShaderAstRecursiveVisitor::Visit(ShaderNodes::ExpressionStatement& node) { Visit(node.expression); } - void ShaderAstRecursiveVisitor::Visit(const ShaderNodes::Identifier& /*node*/) + void ShaderAstRecursiveVisitor::Visit(ShaderNodes::Identifier& /*node*/) { /* Nothing to do */ } - void ShaderAstRecursiveVisitor::Visit(const ShaderNodes::IntrinsicCall& node) + void ShaderAstRecursiveVisitor::Visit(ShaderNodes::IntrinsicCall& node) { for (auto& param : node.parameters) Visit(param); } - void ShaderAstRecursiveVisitor::Visit(const ShaderNodes::Sample2D& node) + void ShaderAstRecursiveVisitor::Visit(ShaderNodes::Sample2D& node) { Visit(node.sampler); Visit(node.coordinates); } - void ShaderAstRecursiveVisitor::Visit(const ShaderNodes::StatementBlock& node) + void ShaderAstRecursiveVisitor::Visit(ShaderNodes::StatementBlock& node) { for (auto& statement : node.statements) Visit(statement); } - void ShaderAstRecursiveVisitor::Visit(const ShaderNodes::SwizzleOp& node) + void ShaderAstRecursiveVisitor::Visit(ShaderNodes::SwizzleOp& node) { Visit(node.expression); } diff --git a/src/Nazara/Renderer/ShaderAstSerializer.cpp b/src/Nazara/Renderer/ShaderAstSerializer.cpp index b4de31cc7..f8afa178c 100644 --- a/src/Nazara/Renderer/ShaderAstSerializer.cpp +++ b/src/Nazara/Renderer/ShaderAstSerializer.cpp @@ -22,98 +22,98 @@ namespace Nz { } - void Visit(const ShaderNodes::AccessMember& node) override + void Visit(ShaderNodes::AccessMember& node) override { Serialize(node); } - void Visit(const ShaderNodes::AssignOp& node) override + void Visit(ShaderNodes::AssignOp& node) override { Serialize(node); } - void Visit(const ShaderNodes::BinaryOp& node) override + void Visit(ShaderNodes::BinaryOp& node) override { Serialize(node); } - void Visit(const ShaderNodes::Branch& node) override + void Visit(ShaderNodes::Branch& node) override { Serialize(node); } - void Visit(const ShaderNodes::Cast& node) override + void Visit(ShaderNodes::Cast& node) override { Serialize(node); } - void Visit(const ShaderNodes::Constant& node) override + void Visit(ShaderNodes::Constant& node) override { Serialize(node); } - void Visit(const ShaderNodes::DeclareVariable& node) override + void Visit(ShaderNodes::DeclareVariable& node) override { Serialize(node); } - void Visit(const ShaderNodes::ExpressionStatement& node) override + void Visit(ShaderNodes::ExpressionStatement& node) override { Serialize(node); } - void Visit(const ShaderNodes::Identifier& node) override + void Visit(ShaderNodes::Identifier& node) override { Serialize(node); } - void Visit(const ShaderNodes::IntrinsicCall& node) override + void Visit(ShaderNodes::IntrinsicCall& node) override { Serialize(node); } - void Visit(const ShaderNodes::Sample2D& node) override + void Visit(ShaderNodes::Sample2D& node) override { Serialize(node); } - void Visit(const ShaderNodes::StatementBlock& node) override + void Visit(ShaderNodes::StatementBlock& node) override { Serialize(node); } - void Visit(const ShaderNodes::SwizzleOp& node) override + void Visit(ShaderNodes::SwizzleOp& node) override { Serialize(node); } - void Visit(const ShaderNodes::BuiltinVariable& var) override + void Visit(ShaderNodes::BuiltinVariable& var) override { Serialize(var); } - void Visit(const ShaderNodes::InputVariable& var) override + void Visit(ShaderNodes::InputVariable& var) override { Serialize(var); } - void Visit(const ShaderNodes::LocalVariable& var) override + void Visit(ShaderNodes::LocalVariable& var) override { Serialize(var); } - void Visit(const ShaderNodes::OutputVariable& var) override + void Visit(ShaderNodes::OutputVariable& var) override { Serialize(var); } - void Visit(const ShaderNodes::ParameterVariable& var) override + void Visit(ShaderNodes::ParameterVariable& var) override { Serialize(var); } - void Visit(const ShaderNodes::UniformVariable& var) override + void Visit(ShaderNodes::UniformVariable& var) override { Serialize(var); } @@ -193,14 +193,18 @@ namespace Nz Value(value); }; - static_assert(std::variant_size_v == 5); + static_assert(std::variant_size_v == 9); switch (typeIndex) { case 0: SerializeValue(bool()); break; case 1: SerializeValue(float()); break; - case 2: SerializeValue(Vector2f()); break; - case 3: SerializeValue(Vector3f()); break; - case 4: SerializeValue(Vector4f()); break; + case 2: SerializeValue(Int32()); break; + case 3: SerializeValue(Vector2f()); break; + case 4: SerializeValue(Vector3f()); break; + case 5: SerializeValue(Vector4f()); break; + case 6: SerializeValue(Vector2i32()); break; + case 7: SerializeValue(Vector3i32()); break; + case 8: SerializeValue(Vector4i32()); break; default: throw std::runtime_error("unexpected data type"); } } @@ -403,6 +407,11 @@ namespace Nz m_stream << val; } + void ShaderAstSerializer::Value(Int32& val) + { + m_stream << val; + } + void ShaderAstSerializer::Value(Vector2f& val) { m_stream << val; @@ -418,6 +427,21 @@ namespace Nz m_stream << val; } + void ShaderAstSerializer::Value(Vector2i32& val) + { + m_stream << val; + } + + void ShaderAstSerializer::Value(Vector3i32& val) + { + m_stream << val; + } + + void ShaderAstSerializer::Value(Vector4i32& val) + { + m_stream << val; + } + void ShaderAstSerializer::Value(UInt8& val) { m_stream << val; @@ -644,6 +668,11 @@ namespace Nz m_stream >> val; } + void ShaderAstUnserializer::Value(Int32& val) + { + m_stream >> val; + } + void ShaderAstUnserializer::Value(Vector2f& val) { m_stream >> val; @@ -659,6 +688,21 @@ namespace Nz m_stream >> val; } + void ShaderAstUnserializer::Value(Vector2i32& val) + { + m_stream >> val; + } + + void ShaderAstUnserializer::Value(Vector3i32& val) + { + m_stream >> val; + } + + void ShaderAstUnserializer::Value(Vector4i32& val) + { + m_stream >> val; + } + void ShaderAstUnserializer::Value(UInt8& val) { m_stream >> val; @@ -689,6 +733,7 @@ namespace Nz HandleType(BuiltinVariable); HandleType(InputVariable); HandleType(LocalVariable); + HandleType(ParameterVariable); HandleType(OutputVariable); HandleType(UniformVariable); } diff --git a/src/Nazara/Renderer/ShaderAstValidator.cpp b/src/Nazara/Renderer/ShaderAstValidator.cpp index 8e161d532..81970e766 100644 --- a/src/Nazara/Renderer/ShaderAstValidator.cpp +++ b/src/Nazara/Renderer/ShaderAstValidator.cpp @@ -83,7 +83,7 @@ namespace Nz throw AstError{ "Left expression type must match right expression type" }; } - void ShaderAstValidator::Visit(const ShaderNodes::AccessMember& node) + void ShaderAstValidator::Visit(ShaderNodes::AccessMember& node) { const ShaderExpressionType& exprType = MandatoryExpr(node.structExpr)->GetExpressionType(); if (!std::holds_alternative(exprType)) @@ -105,7 +105,7 @@ namespace Nz throw AstError{ "member type does not match node type" }; } - void ShaderAstValidator::Visit(const ShaderNodes::AssignOp& node) + void ShaderAstValidator::Visit(ShaderNodes::AssignOp& node) { MandatoryNode(node.left); MandatoryNode(node.right); @@ -117,7 +117,7 @@ namespace Nz ShaderAstRecursiveVisitor::Visit(node); } - void ShaderAstValidator::Visit(const ShaderNodes::BinaryOp& node) + void ShaderAstValidator::Visit(ShaderNodes::BinaryOp& node) { MandatoryNode(node.left); MandatoryNode(node.right); @@ -147,8 +147,9 @@ namespace Nz switch (leftType) { case ShaderNodes::BasicType::Float1: + case ShaderNodes::BasicType::Int1: { - if (ShaderNodes::Node::GetComponentType(rightType) != ShaderNodes::BasicType::Float1) + if (ShaderNodes::Node::GetComponentType(rightType) != leftType) throw AstError{ "Left expression type is not compatible with right expression type" }; break; @@ -157,8 +158,11 @@ namespace Nz case ShaderNodes::BasicType::Float2: case ShaderNodes::BasicType::Float3: case ShaderNodes::BasicType::Float4: + case ShaderNodes::BasicType::Int2: + case ShaderNodes::BasicType::Int3: + case ShaderNodes::BasicType::Int4: { - if (leftType != rightType && rightType != ShaderNodes::BasicType::Float1) + if (leftType != rightType && rightType != ShaderNodes::Node::GetComponentType(leftType)) throw AstError{ "Left expression type is not compatible with right expression type" }; break; @@ -189,7 +193,7 @@ namespace Nz ShaderAstRecursiveVisitor::Visit(node); } - void ShaderAstValidator::Visit(const ShaderNodes::Branch& node) + void ShaderAstValidator::Visit(ShaderNodes::Branch& node) { for (const auto& condStatement : node.condStatements) { @@ -200,7 +204,7 @@ namespace Nz ShaderAstRecursiveVisitor::Visit(node); } - void ShaderAstValidator::Visit(const ShaderNodes::Cast& node) + void ShaderAstValidator::Visit(ShaderNodes::Cast& node) { unsigned int componentCount = 0; unsigned int requiredComponents = node.GetComponentCount(node.exprType); @@ -222,11 +226,11 @@ namespace Nz ShaderAstRecursiveVisitor::Visit(node); } - void ShaderAstValidator::Visit(const ShaderNodes::Constant& /*node*/) + void ShaderAstValidator::Visit(ShaderNodes::Constant& /*node*/) { } - void ShaderAstValidator::Visit(const ShaderNodes::DeclareVariable& node) + void ShaderAstValidator::Visit(ShaderNodes::DeclareVariable& node) { assert(m_context); @@ -242,14 +246,14 @@ namespace Nz ShaderAstRecursiveVisitor::Visit(node); } - void ShaderAstValidator::Visit(const ShaderNodes::ExpressionStatement& node) + void ShaderAstValidator::Visit(ShaderNodes::ExpressionStatement& node) { MandatoryNode(node.expression); ShaderAstRecursiveVisitor::Visit(node); } - void ShaderAstValidator::Visit(const ShaderNodes::Identifier& node) + void ShaderAstValidator::Visit(ShaderNodes::Identifier& node) { assert(m_context); @@ -259,7 +263,7 @@ namespace Nz Visit(node.var); } - void ShaderAstValidator::Visit(const ShaderNodes::IntrinsicCall& node) + void ShaderAstValidator::Visit(ShaderNodes::IntrinsicCall& node) { switch (node.intrinsic) { @@ -300,7 +304,7 @@ namespace Nz ShaderAstRecursiveVisitor::Visit(node); } - void ShaderAstValidator::Visit(const ShaderNodes::Sample2D& node) + void ShaderAstValidator::Visit(ShaderNodes::Sample2D& node) { if (MandatoryExpr(node.sampler)->GetExpressionType() != ShaderExpressionType{ ShaderNodes::BasicType::Sampler2D }) throw AstError{ "Sampler must be a Sampler2D" }; @@ -311,7 +315,7 @@ namespace Nz ShaderAstRecursiveVisitor::Visit(node); } - void ShaderAstValidator::Visit(const ShaderNodes::StatementBlock& node) + void ShaderAstValidator::Visit(ShaderNodes::StatementBlock& node) { assert(m_context); @@ -327,7 +331,7 @@ namespace Nz ShaderAstRecursiveVisitor::Visit(node); } - void ShaderAstValidator::Visit(const ShaderNodes::SwizzleOp& node) + void ShaderAstValidator::Visit(ShaderNodes::SwizzleOp& node) { if (node.componentCount > 4) throw AstError{ "Cannot swizzle more than four elements" }; @@ -342,6 +346,10 @@ namespace Nz case ShaderNodes::BasicType::Float2: case ShaderNodes::BasicType::Float3: case ShaderNodes::BasicType::Float4: + case ShaderNodes::BasicType::Int1: + case ShaderNodes::BasicType::Int2: + case ShaderNodes::BasicType::Int3: + case ShaderNodes::BasicType::Int4: break; default: @@ -351,12 +359,23 @@ namespace Nz ShaderAstRecursiveVisitor::Visit(node); } - void ShaderAstValidator::Visit(const ShaderNodes::BuiltinVariable& /*var*/) + void ShaderAstValidator::Visit(ShaderNodes::BuiltinVariable& var) { - /* Nothing to do */ + switch (var.entry) + { + case ShaderNodes::BuiltinEntry::VertexPosition: + if (!std::holds_alternative(var.type) || + std::get(var.type) != ShaderNodes::BasicType::Float4) + throw AstError{ "Builtin is not of the expected type" }; + + break; + + default: + break; + } } - void ShaderAstValidator::Visit(const ShaderNodes::InputVariable& var) + void ShaderAstValidator::Visit(ShaderNodes::InputVariable& var) { for (std::size_t i = 0; i < m_shader.GetInputCount(); ++i) { @@ -371,7 +390,7 @@ namespace Nz throw AstError{ "Input not found" }; } - void ShaderAstValidator::Visit(const ShaderNodes::LocalVariable& var) + void ShaderAstValidator::Visit(ShaderNodes::LocalVariable& var) { const auto& vars = m_context->declaredLocals; @@ -382,7 +401,7 @@ namespace Nz TypeMustMatch(it->type, var.type); } - void ShaderAstValidator::Visit(const ShaderNodes::OutputVariable& var) + void ShaderAstValidator::Visit(ShaderNodes::OutputVariable& var) { for (std::size_t i = 0; i < m_shader.GetOutputCount(); ++i) { @@ -397,7 +416,7 @@ namespace Nz throw AstError{ "Output not found" }; } - void ShaderAstValidator::Visit(const ShaderNodes::ParameterVariable& var) + void ShaderAstValidator::Visit(ShaderNodes::ParameterVariable& var) { assert(m_context->currentFunction); @@ -410,7 +429,7 @@ namespace Nz TypeMustMatch(it->type, var.type); } - void ShaderAstValidator::Visit(const ShaderNodes::UniformVariable& var) + void ShaderAstValidator::Visit(ShaderNodes::UniformVariable& var) { for (std::size_t i = 0; i < m_shader.GetUniformCount(); ++i) { diff --git a/src/Nazara/Renderer/ShaderNodes.cpp b/src/Nazara/Renderer/ShaderNodes.cpp index 7ea148cb6..29ffb8508 100644 --- a/src/Nazara/Renderer/ShaderNodes.cpp +++ b/src/Nazara/Renderer/ShaderNodes.cpp @@ -59,7 +59,7 @@ namespace Nz::ShaderNodes visitor.Visit(*this); } - ExpressionCategory ShaderNodes::AccessMember::GetExpressionCategory() const + ExpressionCategory AccessMember::GetExpressionCategory() const { return ExpressionCategory::LValue; } @@ -111,10 +111,14 @@ namespace Nz::ShaderNodes case BasicType::Float2: case BasicType::Float3: case BasicType::Float4: + case BasicType::Int2: + case BasicType::Int3: + case BasicType::Int4: exprType = leftExprType; break; case BasicType::Float1: + case BasicType::Int1: case BasicType::Mat4x4: exprType = rightExprType; break; @@ -159,12 +163,20 @@ namespace Nz::ShaderNodes return ShaderNodes::BasicType::Boolean; else if constexpr (std::is_same_v) return ShaderNodes::BasicType::Float1; + else if constexpr (std::is_same_v) + return ShaderNodes::BasicType::Int1; else if constexpr (std::is_same_v) return ShaderNodes::BasicType::Float2; else if constexpr (std::is_same_v) return ShaderNodes::BasicType::Float3; else if constexpr (std::is_same_v) return ShaderNodes::BasicType::Float4; + else if constexpr (std::is_same_v) + return ShaderNodes::BasicType::Int2; + else if constexpr (std::is_same_v) + return ShaderNodes::BasicType::Int3; + else if constexpr (std::is_same_v) + return ShaderNodes::BasicType::Int4; else static_assert(AlwaysFalse::value, "non-exhaustive visitor"); }, value); diff --git a/src/Nazara/Renderer/SpirvWriter.cpp b/src/Nazara/Renderer/SpirvWriter.cpp index a94cd6ec9..1e9218e34 100644 --- a/src/Nazara/Renderer/SpirvWriter.cpp +++ b/src/Nazara/Renderer/SpirvWriter.cpp @@ -5,6 +5,8 @@ #include #include #include +#include +#include #include #include #include @@ -34,28 +36,35 @@ namespace Nz using ShaderAstRecursiveVisitor::Visit; using ShaderVarVisitor::Visit; - void Visit(const ShaderNodes::Constant& node) override + void Visit(ShaderNodes::AccessMember& node) override + { + constants.emplace(Int32(node.memberIndex)); + + ShaderAstRecursiveVisitor::Visit(node); + } + + void Visit(ShaderNodes::Constant& node) override { std::visit([&](auto&& arg) { using T = std::decay_t; - if constexpr (std::is_same_v || std::is_same_v) + if constexpr (std::is_same_v || std::is_same_v || std::is_same_v) constants.emplace(arg); - else if constexpr (std::is_same_v) + else if constexpr (std::is_same_v || std::is_same_v) { constants.emplace(arg.x); constants.emplace(arg.y); constants.emplace(arg); } - else if constexpr (std::is_same_v) + else if constexpr (std::is_same_v || std::is_same_v) { constants.emplace(arg.x); constants.emplace(arg.y); constants.emplace(arg.z); constants.emplace(arg); } - else if constexpr (std::is_same_v) + else if constexpr (std::is_same_v || std::is_same_v) { constants.emplace(arg.x); constants.emplace(arg.y); @@ -71,21 +80,21 @@ namespace Nz ShaderAstRecursiveVisitor::Visit(node); } - void Visit(const ShaderNodes::DeclareVariable& node) override + void Visit(ShaderNodes::DeclareVariable& node) override { Visit(node.variable); ShaderAstRecursiveVisitor::Visit(node); } - void Visit(const ShaderNodes::Identifier& node) override + void Visit(ShaderNodes::Identifier& node) override { Visit(node.var); ShaderAstRecursiveVisitor::Visit(node); } - void Visit(const ShaderNodes::IntrinsicCall& node) override + void Visit(ShaderNodes::IntrinsicCall& node) override { ShaderAstRecursiveVisitor::Visit(node); @@ -102,32 +111,32 @@ namespace Nz } } - void Visit(const ShaderNodes::BuiltinVariable& var) override + void Visit(ShaderNodes::BuiltinVariable& var) override { builtinVars.insert(std::static_pointer_cast(var.shared_from_this())); } - void Visit(const ShaderNodes::InputVariable& var) override + void Visit(ShaderNodes::InputVariable& var) override { /* Handled by ShaderAst */ } - void Visit(const ShaderNodes::LocalVariable& var) override + void Visit(ShaderNodes::LocalVariable& var) override { localVars.insert(std::static_pointer_cast(var.shared_from_this())); } - void Visit(const ShaderNodes::OutputVariable& var) override + void Visit(ShaderNodes::OutputVariable& var) override { /* Handled by ShaderAst */ } - void Visit(const ShaderNodes::ParameterVariable& var) override + void Visit(ShaderNodes::ParameterVariable& var) override { paramVars.insert(std::static_pointer_cast(var.shared_from_this())); } - void Visit(const ShaderNodes::UniformVariable& var) override + void Visit(ShaderNodes::UniformVariable& var) override { /* Handled by ShaderAst */ } @@ -138,8 +147,57 @@ namespace Nz LocalContainer localVars; ParameterContainer paramVars; }; + + class AssignVisitor : public ShaderAstRecursiveVisitor + { + public: + void Visit(ShaderNodes::AccessMember& node) override + { + } + + void Visit(ShaderNodes::Identifier& node) override + { + } + + void Visit(ShaderNodes::SwizzleOp& node) override + { + } + }; + + template + constexpr ShaderNodes::BasicType GetBasicType() + { + if constexpr (std::is_same_v) + return ShaderNodes::BasicType::Boolean; + else if constexpr (std::is_same_v) + return(ShaderNodes::BasicType::Float1); + else if constexpr (std::is_same_v) + return(ShaderNodes::BasicType::Int1); + else if constexpr (std::is_same_v) + return(ShaderNodes::BasicType::Float2); + else if constexpr (std::is_same_v) + return(ShaderNodes::BasicType::Float3); + else if constexpr (std::is_same_v) + return(ShaderNodes::BasicType::Float4); + else if constexpr (std::is_same_v) + return(ShaderNodes::BasicType::Int2); + else if constexpr (std::is_same_v) + return(ShaderNodes::BasicType::Int3); + else if constexpr (std::is_same_v) + return(ShaderNodes::BasicType::Int4); + else + static_assert(AlwaysFalse::value, "unhandled type"); + } } + struct SpirvWriter::ExtVar + { + UInt32 pointerTypeId; + UInt32 typeId; + UInt32 varId; + std::optional valueId; + }; + struct SpirvWriter::Opcode { SpvOp op; @@ -165,20 +223,15 @@ namespace Nz std::vector paramsId; }; - struct ExtVar - { - UInt32 pointerTypeId; - UInt32 varId; - }; - std::unordered_map extensionInstructions; - std::unordered_map builtinIds; + std::unordered_map builtinIds; + std::unordered_map varToResult; tsl::ordered_map constantIds; tsl::ordered_map typeIds; std::vector funcs; - std::vector inputIds; - std::vector outputIds; - std::vector uniformIds; + tsl::ordered_map inputIds; + tsl::ordered_map outputIds; + tsl::ordered_map uniformIds; std::vector> structFields; std::vector resultIds; UInt32 nextVarIndex = 1; @@ -213,14 +266,17 @@ namespace Nz }); state.structFields.resize(shader.GetStructCount()); - state.annotations.Append(Opcode{ SpvOpNop }); - state.constants.Append(Opcode{ SpvOpNop }); - state.debugInfo.Append(Opcode{ SpvOpNop }); - state.types.Append(Opcode{ SpvOpNop }); + + std::vector functionStatements; + + ShaderAstCloner cloner; PreVisitor preVisitor; for (const auto& func : shader.GetFunctions()) + { + functionStatements.emplace_back(cloner.Clone(func.statement)); preVisitor.Visit(func.statement); + } // Register all extended instruction sets for (const std::string& extInst : preVisitor.extInsts) @@ -246,39 +302,67 @@ namespace Nz for (const auto& local : preVisitor.localVars) RegisterType(local->type); + for (const auto& builtin : preVisitor.builtinVars) + RegisterType(builtin->type); + // Register constant types for (const auto& constant : preVisitor.constants) { std::visit([&](auto&& arg) { using T = std::decay_t; - - if constexpr (std::is_same_v) - RegisterType(ShaderNodes::BasicType::Boolean); - else if constexpr (std::is_same_v) - RegisterType(ShaderNodes::BasicType::Float1); - else if constexpr (std::is_same_v) - RegisterType(ShaderNodes::BasicType::Float2); - else if constexpr (std::is_same_v) - RegisterType(ShaderNodes::BasicType::Float3); - else if constexpr (std::is_same_v) - RegisterType(ShaderNodes::BasicType::Float4); - else - static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + RegisterType(GetBasicType()); }, constant); } AppendTypes(); // Register result id and debug infos for global variables/functions + for (const auto& builtin : preVisitor.builtinVars) + { + const ShaderExpressionType& builtinExprType = builtin->type; + assert(std::holds_alternative(builtinExprType)); + + ShaderNodes::BasicType builtinType = std::get(builtinExprType); + + ExtVar builtinData; + builtinData.pointerTypeId = AllocateResultId(); + builtinData.typeId = GetTypeId(builtinType); + builtinData.varId = AllocateResultId(); + + SpvBuiltIn spvBuiltin; + std::string debugName; + switch (builtin->entry) + { + case ShaderNodes::BuiltinEntry::VertexPosition: + debugName = "builtin_VertexPosition"; + spvBuiltin = SpvBuiltInPosition; + break; + + default: + throw std::runtime_error("unexpected builtin type"); + } + + state.debugInfo.Append(Opcode{ SpvOpName }, builtinData.varId, debugName); + state.types.Append(Opcode{ SpvOpTypePointer }, builtinData.pointerTypeId, SpvStorageClassOutput, builtinData.typeId); + state.types.Append(Opcode{ SpvOpVariable }, builtinData.pointerTypeId, builtinData.varId, SpvStorageClassOutput); + + state.annotations.Append(Opcode{ SpvOpDecorate }, builtinData.varId, SpvDecorationBuiltIn, spvBuiltin); + + state.builtinIds.emplace(builtin->entry, builtinData); + } + for (const auto& input : shader.GetInputs()) { - auto& inputData = state.inputIds.emplace_back(); + ExtVar inputData; inputData.pointerTypeId = AllocateResultId(); + inputData.typeId = GetTypeId(input.type); inputData.varId = AllocateResultId(); + state.inputIds.emplace(input.name, inputData); + state.debugInfo.Append(Opcode{ SpvOpName }, inputData.varId, input.name); - state.types.Append(Opcode{ SpvOpTypePointer }, inputData.pointerTypeId, SpvStorageClassInput, GetTypeId(input.type)); + state.types.Append(Opcode{ SpvOpTypePointer }, inputData.pointerTypeId, SpvStorageClassInput, inputData.typeId); state.types.Append(Opcode{ SpvOpVariable }, inputData.pointerTypeId, inputData.varId, SpvStorageClassInput); if (input.locationIndex) @@ -287,12 +371,15 @@ namespace Nz for (const auto& output : shader.GetOutputs()) { - auto& outputData = state.outputIds.emplace_back(); + ExtVar outputData; outputData.pointerTypeId = AllocateResultId(); + outputData.typeId = GetTypeId(output.type); outputData.varId = AllocateResultId(); + state.outputIds.emplace(output.name, outputData); + state.debugInfo.Append(Opcode{ SpvOpName }, outputData.varId, output.name); - state.types.Append(Opcode{ SpvOpTypePointer }, outputData.pointerTypeId, SpvStorageClassOutput, GetTypeId(output.type)); + state.types.Append(Opcode{ SpvOpTypePointer }, outputData.pointerTypeId, SpvStorageClassOutput, outputData.typeId); state.types.Append(Opcode{ SpvOpVariable }, outputData.pointerTypeId, outputData.varId, SpvStorageClassOutput); if (output.locationIndex) @@ -301,12 +388,15 @@ namespace Nz for (const auto& uniform : shader.GetUniforms()) { - auto& uniformData = state.uniformIds.emplace_back(); + ExtVar uniformData; uniformData.pointerTypeId = AllocateResultId(); + uniformData.typeId = GetTypeId(uniform.type); uniformData.varId = AllocateResultId(); + state.uniformIds.emplace(uniform.name, uniformData); + state.debugInfo.Append(Opcode{ SpvOpName }, uniformData.varId, uniform.name); - state.types.Append(Opcode{ SpvOpTypePointer }, uniformData.pointerTypeId, SpvStorageClassUniform, GetTypeId(uniform.type)); + state.types.Append(Opcode{ SpvOpTypePointer }, uniformData.pointerTypeId, SpvStorageClassUniform, uniformData.typeId); state.types.Append(Opcode{ SpvOpVariable }, uniformData.pointerTypeId, uniformData.varId, SpvStorageClassUniform); if (uniform.bindingIndex) @@ -338,16 +428,20 @@ namespace Nz AppendConstants(); + std::size_t entryPointIndex = std::numeric_limits::max(); + for (std::size_t funcIndex = 0; funcIndex < shader.GetFunctionCount(); ++funcIndex) { const auto& func = shader.GetFunction(funcIndex); + if (func.name == "main") + entryPointIndex = funcIndex; auto& funcData = state.funcs[funcIndex]; - state.instructions.Append(Opcode{ SpvOpNop }); - state.instructions.Append(Opcode{ SpvOpFunction }, GetTypeId(func.returnType), funcData.id, 0, funcData.typeId); + state.instructions.Append(Opcode{ SpvOpLabel }, AllocateResultId()); + for (const auto& param : func.parameters) { UInt32 paramResultId = AllocateResultId(); @@ -356,24 +450,56 @@ namespace Nz state.instructions.Append(Opcode{ SpvOpFunctionParameter }, GetTypeId(param.type), paramResultId); } - Visit(func.statement); + Visit(functionStatements[funcIndex]); + + if (func.returnType == ShaderNodes::BasicType::Void) + state.instructions.Append(Opcode{ SpvOpReturn }); state.instructions.Append(Opcode{ SpvOpFunctionEnd }); } + assert(entryPointIndex != std::numeric_limits::max()); + AppendHeader(); - /*assert(m_context.shader); + SpvExecutionModel execModel; + const auto& entryFuncData = shader.GetFunction(entryPointIndex); + const auto& entryFunc = m_currentState->funcs[entryPointIndex]; + + assert(m_context.shader); switch (m_context.shader->GetStage()) { case ShaderStageType::Fragment: + execModel = SpvExecutionModelFragment; break; + case ShaderStageType::Vertex: + execModel = SpvExecutionModelVertex; break; default: - break; - }*/ + throw std::runtime_error("not yet implemented"); + } + + // OpEntryPoint Vertex %main "main" %outNormal %inNormals %outTexCoords %inTexCoord %_ %inPos + + std::size_t nameSize = state.header.CountWord(entryFuncData.name); + + state.header.Append(Opcode{ SpvOpEntryPoint }, WordCount{ static_cast(3 + nameSize + m_currentState->builtinIds.size() + m_currentState->inputIds.size() + m_currentState->outputIds.size()) }); + state.header.Append(execModel); + state.header.Append(entryFunc.id); + state.header.Append(entryFuncData.name); + for (const auto& [name, varData] : m_currentState->builtinIds) + state.header.Append(varData.varId); + + for (const auto& [name, varData] : m_currentState->inputIds) + state.header.Append(varData.varId); + + for (const auto& [name, varData] : m_currentState->outputIds) + state.header.Append(varData.varId); + + if (m_context.shader->GetStage() == ShaderStageType::Fragment) + state.header.Append(Opcode{ SpvOpExecutionMode }, entryFunc.id, SpvExecutionModeOriginUpperLeft); std::vector ret; MergeBlocks(ret, state.header); @@ -407,14 +533,14 @@ namespace Nz if constexpr (std::is_same_v) m_currentState->constants.Append(Opcode{ (arg) ? SpvOpConstantTrue : SpvOpConstantFalse }, constantId); - else if constexpr (std::is_same_v) - m_currentState->constants.Append(Opcode{ SpvOpConstant }, GetTypeId(ShaderNodes::BasicType::Float1), constantId, Raw{ &arg, sizeof(arg) }); - else if constexpr (std::is_same_v) - m_currentState->constants.Append(Opcode{ SpvOpConstantComposite }, GetTypeId(ShaderNodes::BasicType::Float2), constantId, GetConstantId(arg.x), GetConstantId(arg.y)); - else if constexpr (std::is_same_v) - m_currentState->constants.Append(Opcode{ SpvOpConstantComposite }, GetTypeId(ShaderNodes::BasicType::Float3), constantId, GetConstantId(arg.x), GetConstantId(arg.y), GetConstantId(arg.z)); - else if constexpr (std::is_same_v) - m_currentState->constants.Append(Opcode{ SpvOpConstantComposite }, GetTypeId(ShaderNodes::BasicType::Float3), constantId, GetConstantId(arg.x), GetConstantId(arg.y), GetConstantId(arg.z), GetConstantId(arg.w)); + else if constexpr (std::is_same_v || std::is_same_v) + m_currentState->constants.Append(Opcode{ SpvOpConstant }, GetTypeId(GetBasicType()), constantId, Raw{ &arg, sizeof(arg) }); + else if constexpr (std::is_same_v || std::is_same_v) + m_currentState->constants.Append(Opcode{ SpvOpConstantComposite }, GetTypeId(GetBasicType()), constantId, GetConstantId(arg.x), GetConstantId(arg.y)); + else if constexpr (std::is_same_v || std::is_same_v) + m_currentState->constants.Append(Opcode{ SpvOpConstantComposite }, GetTypeId(GetBasicType()), constantId, GetConstantId(arg.x), GetConstantId(arg.y), GetConstantId(arg.z)); + else if constexpr (std::is_same_v || std::is_same_v) + m_currentState->constants.Append(Opcode{ SpvOpConstantComposite }, GetTypeId(GetBasicType()), constantId, GetConstantId(arg.x), GetConstantId(arg.y), GetConstantId(arg.z), GetConstantId(arg.w)); else static_assert(AlwaysFalse::value, "non-exhaustive visitor"); }, value); @@ -467,14 +593,18 @@ namespace Nz std::size_t offset = [&] { switch (arg) { - case ShaderNodes::BasicType::Boolean: return structOffsets.AddField(StructFieldType_Bool1); - case ShaderNodes::BasicType::Float1: return structOffsets.AddField(StructFieldType_Float1); - case ShaderNodes::BasicType::Float2: return structOffsets.AddField(StructFieldType_Float2); - case ShaderNodes::BasicType::Float3: return structOffsets.AddField(StructFieldType_Float3); - case ShaderNodes::BasicType::Float4: return structOffsets.AddField(StructFieldType_Float4); - case ShaderNodes::BasicType::Mat4x4: return structOffsets.AddMatrix(StructFieldType_Float1, 4, 4, true); + case ShaderNodes::BasicType::Boolean: return structOffsets.AddField(StructFieldType_Bool1); + case ShaderNodes::BasicType::Float1: return structOffsets.AddField(StructFieldType_Float1); + case ShaderNodes::BasicType::Float2: return structOffsets.AddField(StructFieldType_Float2); + case ShaderNodes::BasicType::Float3: return structOffsets.AddField(StructFieldType_Float3); + case ShaderNodes::BasicType::Float4: return structOffsets.AddField(StructFieldType_Float4); + case ShaderNodes::BasicType::Int1: return structOffsets.AddField(StructFieldType_Int1); + case ShaderNodes::BasicType::Int2: return structOffsets.AddField(StructFieldType_Int2); + case ShaderNodes::BasicType::Int3: return structOffsets.AddField(StructFieldType_Int3); + case ShaderNodes::BasicType::Int4: return structOffsets.AddField(StructFieldType_Int4); + case ShaderNodes::BasicType::Mat4x4: return structOffsets.AddMatrix(StructFieldType_Float1, 4, 4, true); case ShaderNodes::BasicType::Sampler2D: throw std::runtime_error("unexpected sampler2D as struct member"); - case ShaderNodes::BasicType::Void: throw std::runtime_error("unexpected void as struct member"); + case ShaderNodes::BasicType::Void: throw std::runtime_error("unexpected void as struct member"); } assert(false); @@ -537,13 +667,22 @@ namespace Nz case ShaderNodes::BasicType::Float2: case ShaderNodes::BasicType::Float3: case ShaderNodes::BasicType::Float4: + case ShaderNodes::BasicType::Int2: + case ShaderNodes::BasicType::Int3: + case ShaderNodes::BasicType::Int4: { - UInt32 vecSize = UInt32(arg) - UInt32(ShaderNodes::BasicType::Float2) + 1; + ShaderNodes::BasicType baseType = ShaderNodes::Node::GetComponentType(arg); - m_currentState->types.Append(Opcode{ SpvOpTypeVector }, resultId, GetTypeId(ShaderNodes::BasicType::Float1), vecSize); + UInt32 vecSize = UInt32(arg) - UInt32(baseType) + 1; + + m_currentState->types.Append(Opcode{ SpvOpTypeVector }, resultId, GetTypeId(baseType), vecSize); break; } + case ShaderNodes::BasicType::Int1: + m_currentState->types.Append(Opcode{ SpvOpTypeInt }, resultId, 32, 1); + break; + case ShaderNodes::BasicType::Mat4x4: { m_currentState->types.Append(Opcode{ SpvOpTypeMatrix }, resultId, GetTypeId(ShaderNodes::BasicType::Float4), 4); @@ -581,6 +720,12 @@ namespace Nz } } + UInt32 SpirvWriter::EvaluateExpression(const ShaderNodes::ExpressionPtr& expr) + { + Visit(expr); + return PopResultId(); + } + UInt32 SpirvWriter::GetConstantId(const ShaderNodes::Constant::Variant& value) const { auto typeIt = m_currentState->constantIds.find(value); @@ -613,6 +758,19 @@ namespace Nz return resultId; } + UInt32 SpirvWriter::ReadVariable(ExtVar& var) + { + if (!var.valueId.has_value()) + { + UInt32 resultId = AllocateResultId(); + m_currentState->instructions.Append(Opcode{ SpvOpLoad }, var.typeId, resultId, var.varId); + + var.valueId = resultId; + } + + return var.valueId.value(); + } + UInt32 SpirvWriter::RegisterType(ShaderExpressionType type) { auto it = m_currentState->typeIds.find(type); @@ -628,6 +786,7 @@ namespace Nz { case ShaderNodes::BasicType::Boolean: case ShaderNodes::BasicType::Float1: + case ShaderNodes::BasicType::Int1: case ShaderNodes::BasicType::Void: break; //< Nothing to do @@ -635,11 +794,11 @@ namespace Nz case ShaderNodes::BasicType::Float2: case ShaderNodes::BasicType::Float3: case ShaderNodes::BasicType::Float4: - RegisterType(ShaderNodes::BasicType::Float1); - break; - + case ShaderNodes::BasicType::Int2: + case ShaderNodes::BasicType::Int3: + case ShaderNodes::BasicType::Int4: case ShaderNodes::BasicType::Mat4x4: - RegisterType(ShaderNodes::BasicType::Float4); + RegisterType(ShaderNodes::Node::GetComponentType(arg)); break; case ShaderNodes::BasicType::Sampler2D: @@ -670,60 +829,392 @@ namespace Nz return it->second; } - void SpirvWriter::Visit(const ShaderNodes::AccessMember& node) + void SpirvWriter::Visit(ShaderNodes::AccessMember& node) { - Visit(node.structExpr); + UInt32 pointerId; + SpvStorageClass storage; + + switch (node.structExpr->GetType()) + { + case ShaderNodes::NodeType::Identifier: + { + auto& identifier = static_cast(*node.structExpr); + switch (identifier.var->GetType()) + { + case ShaderNodes::VariableType::BuiltinVariable: + { + auto& builtinvar = static_cast(*identifier.var); + auto it = m_currentState->builtinIds.find(builtinvar.entry); + assert(it != m_currentState->builtinIds.end()); + + pointerId = it->second.varId; + break; + } + + case ShaderNodes::VariableType::InputVariable: + { + auto& inputVar = static_cast(*identifier.var); + auto it = m_currentState->inputIds.find(inputVar.name); + assert(it != m_currentState->inputIds.end()); + + storage = SpvStorageClassInput; + + pointerId = it->second.varId; + break; + } + + case ShaderNodes::VariableType::OutputVariable: + { + auto& outputVar = static_cast(*identifier.var); + auto it = m_currentState->outputIds.find(outputVar.name); + assert(it != m_currentState->outputIds.end()); + + storage = SpvStorageClassOutput; + + pointerId = it->second.varId; + break; + } + + case ShaderNodes::VariableType::UniformVariable: + { + auto& uniformVar = static_cast(*identifier.var); + auto it = m_currentState->uniformIds.find(uniformVar.name); + assert(it != m_currentState->uniformIds.end()); + + storage = SpvStorageClassUniform; + + pointerId = it->second.varId; + break; + } + + case ShaderNodes::VariableType::LocalVariable: + case ShaderNodes::VariableType::ParameterVariable: + default: + throw std::runtime_error("not yet implemented"); + } + break; + } + + case ShaderNodes::NodeType::SwizzleOp: //< TODO + default: + throw std::runtime_error("not yet implemented"); + } + + UInt32 memberPointerId = AllocateResultId(); + UInt32 pointerType = AllocateResultId(); + UInt32 typeId = GetTypeId(node.exprType); + UInt32 indexId = GetConstantId(Int32(node.memberIndex)); + + m_currentState->types.Append(Opcode{ SpvOpTypePointer }, pointerType, storage, typeId); + + m_currentState->instructions.Append(Opcode{ SpvOpAccessChain }, pointerType, memberPointerId, pointerId, indexId); + + UInt32 resultId = AllocateResultId(); + + m_currentState->instructions.Append(Opcode{ SpvOpLoad }, typeId, resultId, memberPointerId); + + PushResultId(resultId); } - void SpirvWriter::Visit(const ShaderNodes::AssignOp& node) + void SpirvWriter::Visit(ShaderNodes::AssignOp& node) { - Visit(node.left); - Visit(node.right); + UInt32 result = EvaluateExpression(node.right); + + switch (node.left->GetType()) + { + case ShaderNodes::NodeType::Identifier: + { + auto& identifier = static_cast(*node.left); + switch (identifier.var->GetType()) + { + case ShaderNodes::VariableType::BuiltinVariable: + { + auto& builtinvar = static_cast(*identifier.var); + auto it = m_currentState->builtinIds.find(builtinvar.entry); + assert(it != m_currentState->builtinIds.end()); + + m_currentState->instructions.Append(Opcode{ SpvOpStore }, it->second.varId, result); + PushResultId(result); + break; + } + + case ShaderNodes::VariableType::OutputVariable: + { + auto& outputVar = static_cast(*identifier.var); + auto it = m_currentState->outputIds.find(outputVar.name); + assert(it != m_currentState->outputIds.end()); + + m_currentState->instructions.Append(Opcode{ SpvOpStore }, it->second.varId, result); + PushResultId(result); + break; + } + + case ShaderNodes::VariableType::InputVariable: + case ShaderNodes::VariableType::LocalVariable: + case ShaderNodes::VariableType::ParameterVariable: + case ShaderNodes::VariableType::UniformVariable: + default: + throw std::runtime_error("not yet implemented"); + } + break; + } + + case ShaderNodes::NodeType::SwizzleOp: //< TODO + default: + throw std::runtime_error("not yet implemented"); + } } - void SpirvWriter::Visit(const ShaderNodes::Branch& node) + void SpirvWriter::Visit(ShaderNodes::Branch& node) { throw std::runtime_error("not yet implemented"); } - void SpirvWriter::Visit(const ShaderNodes::BinaryOp& node) + void SpirvWriter::Visit(ShaderNodes::BinaryOp& node) { - Visit(node.left); - Visit(node.right); + ShaderExpressionType resultExprType = node.GetExpressionType(); + assert(std::holds_alternative(resultExprType)); + const ShaderExpressionType& leftExprType = node.left->GetExpressionType(); + assert(std::holds_alternative(leftExprType)); + + const ShaderExpressionType& rightExprType = node.right->GetExpressionType(); + assert(std::holds_alternative(rightExprType)); + + ShaderNodes::BasicType resultType = std::get(resultExprType); + ShaderNodes::BasicType leftType = std::get(leftExprType); + ShaderNodes::BasicType rightType = std::get(rightExprType); + + + UInt32 leftOperand = EvaluateExpression(node.left); + UInt32 rightOperand = EvaluateExpression(node.right); UInt32 resultId = AllocateResultId(); - UInt32 leftOperand = PopResultId(); - UInt32 rightOperand = PopResultId(); - SpvOp op = [&] { + bool swapOperands = false; + + SpvOp op = [&] + { switch (node.op) { - case ShaderNodes::BinaryType::Add: return SpvOpFAdd; - case ShaderNodes::BinaryType::Substract: return SpvOpFSub; - case ShaderNodes::BinaryType::Multiply: return SpvOpFMul; - case ShaderNodes::BinaryType::Divide: return SpvOpFDiv; - case ShaderNodes::BinaryType::Equality: return SpvOpFOrdEqual; + case ShaderNodes::BinaryType::Add: + { + switch (leftType) + { + case ShaderNodes::BasicType::Float1: + case ShaderNodes::BasicType::Float2: + case ShaderNodes::BasicType::Float3: + case ShaderNodes::BasicType::Float4: + case ShaderNodes::BasicType::Mat4x4: + return SpvOpFAdd; + + case ShaderNodes::BasicType::Int1: + case ShaderNodes::BasicType::Int2: + case ShaderNodes::BasicType::Int3: + case ShaderNodes::BasicType::Int4: + return SpvOpIAdd; + + case ShaderNodes::BasicType::Boolean: + case ShaderNodes::BasicType::Sampler2D: + case ShaderNodes::BasicType::Void: + break; + } + } + + case ShaderNodes::BinaryType::Substract: + { + switch (leftType) + { + case ShaderNodes::BasicType::Float1: + case ShaderNodes::BasicType::Float2: + case ShaderNodes::BasicType::Float3: + case ShaderNodes::BasicType::Float4: + case ShaderNodes::BasicType::Mat4x4: + return SpvOpFSub; + + case ShaderNodes::BasicType::Int1: + case ShaderNodes::BasicType::Int2: + case ShaderNodes::BasicType::Int3: + case ShaderNodes::BasicType::Int4: + return SpvOpISub; + + case ShaderNodes::BasicType::Boolean: + case ShaderNodes::BasicType::Sampler2D: + case ShaderNodes::BasicType::Void: + break; + } + } + + case ShaderNodes::BinaryType::Divide: + { + switch (leftType) + { + case ShaderNodes::BasicType::Float1: + case ShaderNodes::BasicType::Float2: + case ShaderNodes::BasicType::Float3: + case ShaderNodes::BasicType::Float4: + case ShaderNodes::BasicType::Mat4x4: + return SpvOpFDiv; + + case ShaderNodes::BasicType::Int1: + case ShaderNodes::BasicType::Int2: + case ShaderNodes::BasicType::Int3: + case ShaderNodes::BasicType::Int4: + return SpvOpSDiv; + + case ShaderNodes::BasicType::Boolean: + case ShaderNodes::BasicType::Sampler2D: + case ShaderNodes::BasicType::Void: + break; + } + } + + case ShaderNodes::BinaryType::Equality: + { + switch (leftType) + { + case ShaderNodes::BasicType::Boolean: + return SpvOpLogicalEqual; + + case ShaderNodes::BasicType::Float1: + case ShaderNodes::BasicType::Float2: + case ShaderNodes::BasicType::Float3: + case ShaderNodes::BasicType::Float4: + case ShaderNodes::BasicType::Mat4x4: + return SpvOpFOrdEqual; + + case ShaderNodes::BasicType::Int1: + case ShaderNodes::BasicType::Int2: + case ShaderNodes::BasicType::Int3: + case ShaderNodes::BasicType::Int4: + return SpvOpIEqual; + + case ShaderNodes::BasicType::Sampler2D: + case ShaderNodes::BasicType::Void: + break; + } + } + + case ShaderNodes::BinaryType::Multiply: + { + switch (leftType) + { + case ShaderNodes::BasicType::Float1: + { + switch (rightType) + { + case ShaderNodes::BasicType::Float1: + return SpvOpFMul; + + case ShaderNodes::BasicType::Float2: + case ShaderNodes::BasicType::Float3: + case ShaderNodes::BasicType::Float4: + swapOperands = true; + return SpvOpVectorTimesScalar; + + case ShaderNodes::BasicType::Mat4x4: + swapOperands = true; + return SpvOpMatrixTimesScalar; + + default: + break; + } + + break; + } + + case ShaderNodes::BasicType::Float2: + case ShaderNodes::BasicType::Float3: + case ShaderNodes::BasicType::Float4: + { + switch (rightType) + { + case ShaderNodes::BasicType::Float1: + return SpvOpVectorTimesScalar; + + case ShaderNodes::BasicType::Float2: + case ShaderNodes::BasicType::Float3: + case ShaderNodes::BasicType::Float4: + return SpvOpFMul; + + case ShaderNodes::BasicType::Mat4x4: + return SpvOpVectorTimesMatrix; + + default: + break; + } + + break; + } + + case ShaderNodes::BasicType::Int1: + case ShaderNodes::BasicType::Int2: + case ShaderNodes::BasicType::Int3: + case ShaderNodes::BasicType::Int4: + return SpvOpIMul; + + case ShaderNodes::BasicType::Mat4x4: + { + switch (rightType) + { + case ShaderNodes::BasicType::Float1: return SpvOpMatrixTimesScalar; + case ShaderNodes::BasicType::Float4: return SpvOpMatrixTimesVector; + case ShaderNodes::BasicType::Mat4x4: return SpvOpMatrixTimesMatrix; + + default: + break; + } + + break; + } + + default: + break; + } + break; + } } assert(false); throw std::runtime_error("unexpected binary operation"); }(); - m_currentState->instructions.Append(Opcode{ op }, GetTypeId(ShaderNodes::BasicType::Float3), resultId, leftOperand, rightOperand); + if (swapOperands) + std::swap(leftOperand, rightOperand); + + m_currentState->instructions.Append(Opcode{ op }, GetTypeId(resultType), resultId, leftOperand, rightOperand); + PushResultId(resultId); } - void SpirvWriter::Visit(const ShaderNodes::Cast& node) + void SpirvWriter::Visit(ShaderNodes::Cast& node) { - for (auto& expr : node.expressions) + const ShaderExpressionType& targetExprType = node.exprType; + assert(std::holds_alternative(targetExprType)); + + ShaderNodes::BasicType targetType = std::get(targetExprType); + + StackVector exprResults = NazaraStackVector(UInt32, node.expressions.size()); + + for (const auto& exprPtr : node.expressions) { - if (!expr) + if (!exprPtr) break; - Visit(expr); + exprResults.push_back(EvaluateExpression(exprPtr)); } + + UInt32 resultId = AllocateResultId(); + + m_currentState->instructions.Append(Opcode{ SpvOpCompositeConstruct }, WordCount { static_cast(3 + exprResults.size()) }); + m_currentState->instructions.Append(GetTypeId(targetType)); + m_currentState->instructions.Append(resultId); + + for (UInt32 resultId : exprResults) + m_currentState->instructions.Append(resultId); + + PushResultId(resultId); } - void SpirvWriter::Visit(const ShaderNodes::Constant& node) + void SpirvWriter::Visit(ShaderNodes::Constant& node) { std::visit([&] (const auto& value) { @@ -731,43 +1222,150 @@ namespace Nz }, node.value); } - void SpirvWriter::Visit(const ShaderNodes::DeclareVariable& node) + void SpirvWriter::Visit(ShaderNodes::DeclareVariable& node) { if (node.expression) - Visit(node.expression); + { + assert(node.variable->GetType() == ShaderNodes::VariableType::LocalVariable); + + const auto& localVar = static_cast(*node.variable); + m_currentState->varToResult[localVar.name] = EvaluateExpression(node.expression); + } } - void SpirvWriter::Visit(const ShaderNodes::ExpressionStatement& node) + void SpirvWriter::Visit(ShaderNodes::ExpressionStatement& node) { Visit(node.expression); + PopResultId(); } - void SpirvWriter::Visit(const ShaderNodes::Identifier& node) + void SpirvWriter::Visit(ShaderNodes::Identifier& node) { - PushResultId(42); + Visit(node.var); } - void SpirvWriter::Visit(const ShaderNodes::IntrinsicCall& node) + void SpirvWriter::Visit(ShaderNodes::IntrinsicCall& node) { - for (auto& param : node.parameters) - Visit(param); + switch (node.intrinsic) + { + case ShaderNodes::IntrinsicType::DotProduct: + { + const ShaderExpressionType& vecExprType = node.parameters[0]->GetExpressionType(); + assert(std::holds_alternative(vecExprType)); + + ShaderNodes::BasicType vecType = std::get(vecExprType); + + UInt32 typeId = GetTypeId(node.GetComponentType(vecType)); + + UInt32 vec1 = EvaluateExpression(node.parameters[0]); + UInt32 vec2 = EvaluateExpression(node.parameters[1]); + + UInt32 resultId = AllocateResultId(); + + m_currentState->instructions.Append(Opcode{ SpvOpDot }, typeId, resultId, vec1, vec2); + PushResultId(resultId); + break; + } + + case ShaderNodes::IntrinsicType::CrossProduct: + default: + throw std::runtime_error("not yet implemented"); + } } - void SpirvWriter::Visit(const ShaderNodes::Sample2D& node) + void SpirvWriter::Visit(ShaderNodes::Sample2D& node) { - Visit(node.sampler); - Visit(node.coordinates); + // OpImageSampleImplicitLod %v4float %31 %35 + + UInt32 typeId = GetTypeId(ShaderNodes::BasicType::Float4); + + UInt32 samplerId = EvaluateExpression(node.sampler); + UInt32 coordinatesId = EvaluateExpression(node.coordinates); + UInt32 resultId = AllocateResultId(); + + m_currentState->instructions.Append(Opcode{ SpvOpImageSampleImplicitLod }, typeId, resultId, samplerId, coordinatesId); + PushResultId(resultId); } - void SpirvWriter::Visit(const ShaderNodes::StatementBlock& node) + void SpirvWriter::Visit(ShaderNodes::StatementBlock& node) { for (auto& statement : node.statements) Visit(statement); } - void SpirvWriter::Visit(const ShaderNodes::SwizzleOp& node) + void SpirvWriter::Visit(ShaderNodes::SwizzleOp& node) { - Visit(node.expression); + const ShaderExpressionType& targetExprType = node.GetExpressionType(); + assert(std::holds_alternative(targetExprType)); + + ShaderNodes::BasicType targetType = std::get(targetExprType); + + UInt32 exprResultId = EvaluateExpression(node.expression); + UInt32 resultId = AllocateResultId(); + + if (node.componentCount > 1) + { + // Swizzling is implemented via SpvOpVectorShuffle using the same vector twice as operands + m_currentState->instructions.Append(Opcode{ SpvOpVectorShuffle }, WordCount{ static_cast(5 + node.componentCount) }); + m_currentState->instructions.Append(GetTypeId(targetType)); + m_currentState->instructions.Append(resultId); + m_currentState->instructions.Append(exprResultId); + m_currentState->instructions.Append(exprResultId); + + for (std::size_t i = 0; i < node.componentCount; ++i) + m_currentState->instructions.Append(UInt32(node.components[0]) - UInt32(node.components[i])); + } + else + { + // Extract a single component from the vector + assert(node.componentCount == 1); + + m_currentState->instructions.Append(Opcode{ SpvOpCompositeExtract }, GetTypeId(targetType), resultId, exprResultId, UInt32(node.components[0]) - UInt32(ShaderNodes::SwizzleComponent::First) ); + } + + PushResultId(resultId); + } + + void SpirvWriter::Visit(ShaderNodes::BuiltinVariable& var) + { + throw std::runtime_error("not implemented yet"); + } + + void SpirvWriter::Visit(ShaderNodes::InputVariable& var) + { + auto it = m_currentState->inputIds.find(var.name); + assert(it != m_currentState->inputIds.end()); + + PushResultId(ReadVariable(it.value())); + } + + void SpirvWriter::Visit(ShaderNodes::LocalVariable& var) + { + auto it = m_currentState->varToResult.find(var.name); + assert(it != m_currentState->varToResult.end()); + + PushResultId(it->second); + } + + void SpirvWriter::Visit(ShaderNodes::OutputVariable& var) + { + auto it = m_currentState->outputIds.find(var.name); + assert(it != m_currentState->outputIds.end()); + + PushResultId(ReadVariable(it.value())); + } + + void SpirvWriter::Visit(ShaderNodes::ParameterVariable& var) + { + throw std::runtime_error("not implemented yet"); + } + + void SpirvWriter::Visit(ShaderNodes::UniformVariable& var) + { + auto it = m_currentState->uniformIds.find(var.name); + assert(it != m_currentState->uniformIds.end()); + + PushResultId(ReadVariable(it.value())); } void SpirvWriter::MergeBlocks(std::vector& output, const Section& from) @@ -794,15 +1392,16 @@ namespace Nz UInt32 codepoint = 0; for (std::size_t j = 0; j < 4; ++j) { +#ifdef NAZARA_BIG_ENDIAN + std::size_t pos = i * 4 + (3 - j); +#else std::size_t pos = i * 4 + j; +#endif + if (pos < raw.size) codepoint |= UInt32(ptr[pos]) << (j * 8); } -#ifdef NAZARA_BIG_ENDIAN - SwapBytes(codepoint); -#endif - Append(codepoint); } diff --git a/src/Nazara/VulkanRenderer/Vulkan.cpp b/src/Nazara/VulkanRenderer/Vulkan.cpp index e6e2d4cfd..4f55223e1 100644 --- a/src/Nazara/VulkanRenderer/Vulkan.cpp +++ b/src/Nazara/VulkanRenderer/Vulkan.cpp @@ -57,7 +57,7 @@ namespace Nz String appName = "Another application made with Nazara Engine"; String engineName = "Nazara Engine - Vulkan Renderer"; - constexpr UInt32 appVersion = VK_MAKE_VERSION(1, 0, 0); + UInt32 appVersion = VK_MAKE_VERSION(1, 0, 0); UInt32 engineVersion = VK_MAKE_VERSION(1, 0, 0); parameters.GetStringParameter("VkAppInfo_OverrideApplicationName", &appName); diff --git a/src/Nazara/VulkanRenderer/VulkanShaderStage.cpp b/src/Nazara/VulkanRenderer/VulkanShaderStage.cpp index 238bb6468..c0b510dd8 100644 --- a/src/Nazara/VulkanRenderer/VulkanShaderStage.cpp +++ b/src/Nazara/VulkanRenderer/VulkanShaderStage.cpp @@ -3,25 +3,61 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include +#include +#include #include namespace Nz { bool VulkanShaderStage::Create(Vk::Device& device, ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) { - if (lang != ShaderLanguage::SpirV) - { - NazaraError("Only Spir-V is supported for now"); - return false; - } - - if (!m_shaderModule.Create(device, reinterpret_cast(source), sourceSize)) - { - NazaraError("Failed to create shader module"); - return false; - } - m_stage = type; + + switch (lang) + { + case ShaderLanguage::NazaraBinary: + { + ByteStream byteStream(source, sourceSize); + auto shader = Nz::UnserializeShader(byteStream); + + if (shader.GetStage() != type) + throw std::runtime_error("incompatible shader stage"); + + SpirvWriter::Environment env; + + SpirvWriter writer; + writer.SetEnv(env); + + std::vector code = writer.Generate(shader); + + if (!m_shaderModule.Create(device, code.data(), code.size() * sizeof(UInt32))) + { + NazaraError("Failed to create shader module"); + return false; + } + + break; + } + + case ShaderLanguage::SpirV: + { + if (!m_shaderModule.Create(device, reinterpret_cast(source), sourceSize)) + { + NazaraError("Failed to create shader module"); + return false; + } + + break; + } + + default: + { + NazaraError("this language is not supported"); + return false; + } + } + return true; } } From ac7b523bc7e287ea187d6df587819bd83097f435 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sun, 9 Aug 2020 18:38:58 +0200 Subject: [PATCH 291/316] OpenGLRenderer: Fix textures --- include/Nazara/OpenGLRenderer/Utils.hpp | 14 ++++++ include/Nazara/OpenGLRenderer/Utils.inl | 13 ++++++ .../Nazara/OpenGLRenderer/Wrapper/Texture.hpp | 4 +- .../Nazara/OpenGLRenderer/Wrapper/Texture.inl | 34 ++++++++------ src/Nazara/OpenGLRenderer/OpenGLTexture.cpp | 46 +++++-------------- 5 files changed, 60 insertions(+), 51 deletions(-) diff --git a/include/Nazara/OpenGLRenderer/Utils.hpp b/include/Nazara/OpenGLRenderer/Utils.hpp index 55f1d6cff..71c23106c 100644 --- a/include/Nazara/OpenGLRenderer/Utils.hpp +++ b/include/Nazara/OpenGLRenderer/Utils.hpp @@ -12,10 +12,24 @@ #include #include #include +#include #include namespace Nz { + struct GLTextureFormat + { + GLint internalFormat; + GLenum format; + GLenum type; + GLenum swizzleR; + GLenum swizzleG; + GLenum swizzleB; + GLenum swizzleA; + }; + + inline std::optional DescribeTextureFormat(PixelFormat pixelFormat); + inline GLenum ToOpenGL(BlendFunc blendFunc); inline GLenum ToOpenGL(FaceSide filter); inline GLenum ToOpenGL(SamplerFilter filter); diff --git a/include/Nazara/OpenGLRenderer/Utils.inl b/include/Nazara/OpenGLRenderer/Utils.inl index 6d64a18ec..621704a82 100644 --- a/include/Nazara/OpenGLRenderer/Utils.inl +++ b/include/Nazara/OpenGLRenderer/Utils.inl @@ -10,6 +10,19 @@ namespace Nz { + inline std::optional DescribeTextureFormat(PixelFormat pixelFormat) + { + switch (pixelFormat) + { + case PixelFormat_A8: return GLTextureFormat { GL_R8, GL_RED, GL_UNSIGNED_BYTE, GL_ZERO, GL_ZERO, GL_ZERO, GL_RED }; + case PixelFormat_RGB8: return GLTextureFormat { GL_SRGB8, GL_RGB, GL_UNSIGNED_BYTE, GL_RED, GL_GREEN, GL_BLUE, GL_ZERO }; + case PixelFormat_RGBA8: return GLTextureFormat { GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }; + } + + NazaraError("Unhandled PixelFormat 0x" + String::Number(UnderlyingCast(pixelFormat), 16)); + return {}; + } + inline GLenum ToOpenGL(BlendFunc blendFunc) { switch (blendFunc) diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Texture.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Texture.hpp index 12b3e5c08..0b04a5e4a 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Texture.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Texture.hpp @@ -29,7 +29,7 @@ namespace Nz::GL inline void SetParameterfv(GLenum pname, const GLfloat* param); inline void SetParameteriv(GLenum pname, const GLint* param); - inline void TexImage2D(GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border); + inline void TexImage2D(GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type); inline void TexImage2D(GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* data); inline void TexSubImage2D(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* data); @@ -39,6 +39,8 @@ namespace Nz::GL private: static inline GLuint CreateHelper(OpenGLDevice& device, const Context& context); static inline void DestroyHelper(OpenGLDevice& device, const Context& context, GLuint objectId); + + TextureTarget m_target; }; } diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Texture.inl b/include/Nazara/OpenGLRenderer/Wrapper/Texture.inl index b63dcb0fe..b94bbe5d4 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Texture.inl +++ b/include/Nazara/OpenGLRenderer/Wrapper/Texture.inl @@ -13,7 +13,8 @@ namespace Nz::GL assert(m_objectId); const Context& context = EnsureDeviceContext(); - context.glTexParameterf(m_objectId, pname, param); + context.BindTexture(m_target, m_objectId); + context.glTexParameterf(ToOpenGL(m_target), pname, param); } inline void Texture::SetParameteri(GLenum pname, GLint param) @@ -21,7 +22,8 @@ namespace Nz::GL assert(m_objectId); const Context& context = EnsureDeviceContext(); - context.glTexParameteri(m_objectId, pname, param); + context.BindTexture(m_target, m_objectId); + context.glTexParameteri(ToOpenGL(m_target), pname, param); } inline void Texture::SetParameterfv(GLenum pname, const GLfloat* param) @@ -29,7 +31,8 @@ namespace Nz::GL assert(m_objectId); const Context& context = EnsureDeviceContext(); - context.glTexParameterfv(m_objectId, pname, param); + context.BindTexture(m_target, m_objectId); + context.glTexParameterfv(ToOpenGL(m_target), pname, param); } inline void Texture::SetParameteriv(GLenum pname, const GLint* param) @@ -37,38 +40,39 @@ namespace Nz::GL assert(m_objectId); const Context& context = EnsureDeviceContext(); - context.glTexParameteriv(m_objectId, pname, param); + context.BindTexture(m_target, m_objectId); + context.glTexParameteriv(ToOpenGL(m_target), pname, param); } - inline void Texture::TexImage2D(GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border) + inline void Texture::TexImage2D(GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type) { - return TexImage2D(level, internalFormat, width, height, border, GL_RGB, GL_UNSIGNED_BYTE, nullptr); + return TexImage2D(level, internalFormat, width, height, border, format, type, nullptr); } inline void Texture::TexImage2D(GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* data) { - const Context& context = EnsureDeviceContext(); - context.BindTexture(TextureTarget::Target2D, m_objectId); + m_target = TextureTarget::Target2D; - context.glTexImage2D(GL_TEXTURE_2D, level, internalFormat, width, height, border, format, type, data); + const Context& context = EnsureDeviceContext(); + context.BindTexture(m_target, m_objectId); + context.glTexImage2D(ToOpenGL(m_target), level, internalFormat, width, height, border, format, type, data); //< TODO: Handle errors } inline void Texture::TexSubImage2D(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* data) { const Context& context = EnsureDeviceContext(); - context.BindTexture(TextureTarget::Target2D, m_objectId); - - context.glTexSubImage2D(GL_TEXTURE_2D, level, xoffset, yoffset, width, height, format, type, data); + context.BindTexture(m_target, m_objectId); + context.glTexSubImage2D(ToOpenGL(m_target), level, xoffset, yoffset, width, height, format, type, data); //< TODO: Handle errors } inline GLuint Texture::CreateHelper(OpenGLDevice& device, const Context& context) { - GLuint sampler = 0; - context.glGenTextures(1U, &sampler); + GLuint texture = 0; + context.glGenTextures(1U, &texture); - return sampler; + return texture; } inline void Texture::DestroyHelper(OpenGLDevice& device, const Context& context, GLuint objectId) diff --git a/src/Nazara/OpenGLRenderer/OpenGLTexture.cpp b/src/Nazara/OpenGLRenderer/OpenGLTexture.cpp index d89da0d49..8019a7d29 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLTexture.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLTexture.cpp @@ -17,21 +17,9 @@ namespace Nz if (!m_texture.Create(device)) throw std::runtime_error("failed to create texture object"); - GLint internalFormat; - switch (params.pixelFormat) - { - case PixelFormat_RGB8: - { - internalFormat = GL_SRGB8; - break; - } - - case PixelFormat_RGBA8: - { - internalFormat = GL_SRGB8_ALPHA8; - break; - } - } + auto format = DescribeTextureFormat(params.pixelFormat); + if (!format) + throw std::runtime_error("unsupported texture format"); switch (params.type) { @@ -43,7 +31,7 @@ namespace Nz case ImageType_2D: for (unsigned int level = 0; level < m_params.mipmapLevel; ++level) - m_texture.TexImage2D(0, internalFormat, GetLevelSize(params.width, level), GetLevelSize(params.height, level), 0); + m_texture.TexImage2D(0, format->internalFormat, GetLevelSize(params.width, level), GetLevelSize(params.height, level), 0, format->format, format->type); break; case ImageType_2D_Array: @@ -60,6 +48,10 @@ namespace Nz } m_texture.SetParameteri(GL_TEXTURE_MAX_LEVEL, m_params.mipmapLevel); + m_texture.SetParameteri(GL_TEXTURE_SWIZZLE_R, format->swizzleR); + m_texture.SetParameteri(GL_TEXTURE_SWIZZLE_G, format->swizzleG); + m_texture.SetParameteri(GL_TEXTURE_SWIZZLE_B, format->swizzleB); + m_texture.SetParameteri(GL_TEXTURE_SWIZZLE_A, format->swizzleA); } PixelFormat OpenGLTexture::GetFormat() const @@ -84,25 +76,9 @@ namespace Nz bool OpenGLTexture::Update(const void* ptr) { - GLint format; - GLint type; - switch (m_params.pixelFormat) - { - case PixelFormat_RGB8: - { - format = GL_RGB; - type = GL_UNSIGNED_BYTE; - break; - } + auto format = DescribeTextureFormat(m_params.pixelFormat); + assert(format); - case PixelFormat_RGBA8: - { - format = GL_RGBA; - type = GL_UNSIGNED_BYTE; - break; - } - } - switch (m_params.type) { case ImageType_1D: @@ -112,7 +88,7 @@ namespace Nz break; case ImageType_2D: - m_texture.TexSubImage2D(0, 0, 0, m_params.width, m_params.height, format, type, ptr); + m_texture.TexSubImage2D(0, 0, 0, m_params.width, m_params.height, format->format, format->type, ptr); break; case ImageType_2D_Array: From d4f60c174ea601805a6ab2c604da5cb39d20a05d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sun, 9 Aug 2020 18:40:59 +0200 Subject: [PATCH 292/316] OpenGLRenderer: Flip screenspace --- include/Nazara/Renderer/GlslWriter.hpp | 1 + include/Nazara/Renderer/ShaderAstCloner.hpp | 3 +- .../OpenGLRenderer/OpenGLShaderStage.cpp | 1 + src/Nazara/Renderer/GlslWriter.cpp | 37 ++++++++++++++++++- 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/include/Nazara/Renderer/GlslWriter.hpp b/include/Nazara/Renderer/GlslWriter.hpp index d7229f1d9..d423286db 100644 --- a/include/Nazara/Renderer/GlslWriter.hpp +++ b/include/Nazara/Renderer/GlslWriter.hpp @@ -41,6 +41,7 @@ namespace Nz unsigned int glMajorVersion = 3; unsigned int glMinorVersion = 0; bool glES = false; + bool flipYPosition = false; }; private: diff --git a/include/Nazara/Renderer/ShaderAstCloner.hpp b/include/Nazara/Renderer/ShaderAstCloner.hpp index ff1f9c5a4..c8b61b02c 100644 --- a/include/Nazara/Renderer/ShaderAstCloner.hpp +++ b/include/Nazara/Renderer/ShaderAstCloner.hpp @@ -28,7 +28,7 @@ namespace Nz ShaderAstCloner& operator=(const ShaderAstCloner&) = default; ShaderAstCloner& operator=(ShaderAstCloner&&) = default; - private: + protected: ShaderNodes::ExpressionPtr CloneExpression(const ShaderNodes::ExpressionPtr& expr); ShaderNodes::StatementPtr CloneStatement(const ShaderNodes::StatementPtr& statement); ShaderNodes::VariablePtr CloneVariable(const ShaderNodes::VariablePtr& statement); @@ -62,6 +62,7 @@ namespace Nz ShaderNodes::StatementPtr PopStatement(); ShaderNodes::VariablePtr PopVariable(); + private: std::vector m_expressionStack; std::vector m_statementStack; std::vector m_variableStack; diff --git a/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp b/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp index 07f6de975..7f6e92a34 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp @@ -45,6 +45,7 @@ namespace Nz { return context.IsExtensionSupported(std::string(ext)); }; + env.flipYPosition = true; GlslWriter writer; writer.SetEnv(env); diff --git a/src/Nazara/Renderer/GlslWriter.cpp b/src/Nazara/Renderer/GlslWriter.cpp index 3d651a84f..f851a3aa0 100644 --- a/src/Nazara/Renderer/GlslWriter.cpp +++ b/src/Nazara/Renderer/GlslWriter.cpp @@ -5,12 +5,44 @@ #include #include #include +#include +#include #include #include #include namespace Nz { + namespace + { + struct AstAdapter : ShaderAstCloner + { + void Visit(ShaderNodes::AssignOp& node) override + { + if (!flipYPosition) + return ShaderAstCloner::Visit(node); + + if (node.left->GetType() != ShaderNodes::NodeType::Identifier) + return ShaderAstCloner::Visit(node); + + const auto& identifier = static_cast(*node.left); + if (identifier.var->GetType() != ShaderNodes::VariableType::BuiltinVariable) + return ShaderAstCloner::Visit(node); + + const auto& builtinVar = static_cast(*identifier.var); + if (builtinVar.entry != ShaderNodes::BuiltinEntry::VertexPosition) + return ShaderAstCloner::Visit(node); + + auto fixYConstant = ShaderBuilder::Constant(Nz::Vector4f(1.f, -1.f, 1.f, 1.f)); + auto mulFix = ShaderBuilder::Multiply(CloneExpression(node.right), fixYConstant); + + PushExpression(ShaderNodes::AssignOp::Build(node.op, CloneExpression(node.left), mulFix)); + } + + bool flipYPosition = false; + }; + } + GlslWriter::GlslWriter() : m_currentState(nullptr) { @@ -237,7 +269,10 @@ namespace Nz EnterScope(); { - Visit(func.statement); + AstAdapter adapter; + adapter.flipYPosition = m_environment.flipYPosition; + + Visit(adapter.Clone(func.statement)); } LeaveScope(); } From d9b34b4ba8d478c289f292a6090b02be5f3a6dbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sun, 9 Aug 2020 18:41:28 +0200 Subject: [PATCH 293/316] OpenGLRenderer: Handle GL_DEBUG_SEVERITY_NOTIFICATION --- src/Nazara/OpenGLRenderer/Wrapper/Context.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp index 2cd045504..aeb2fe934 100644 --- a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp +++ b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp @@ -633,6 +633,10 @@ namespace Nz::GL ss << "Low"; break; + case GL_DEBUG_SEVERITY_NOTIFICATION: + ss << "Notification"; + break; + default: ss << "Unknown"; break; From 777121dbcedf6616ec71bfd6925d9f94ae8fcf69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sun, 9 Aug 2020 18:42:01 +0200 Subject: [PATCH 294/316] Remove SPIRV handling in demo --- examples/VulkanTest/main.cpp | 52 +----------------------------------- 1 file changed, 1 insertion(+), 51 deletions(-) diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index 706cf047c..cd7132e4a 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -5,42 +5,8 @@ #include #include -#define SPIRV 0 - int main() -{ - /*{ - Nz::File file("frag.shader"); - if (!file.Open(Nz::OpenMode_ReadOnly)) - return __LINE__; - - std::size_t length = static_cast(file.GetSize()); - - std::vector source(length); - if (file.Read(&source[0], length) != length) - { - NazaraError("Failed to read program file"); - return {}; - } - - - - Nz::SpirvWriter writer; - - Nz::ByteStream byteStream(source.data(), source.size()); - auto shader = Nz::UnserializeShader(byteStream); - - std::vector result = writer.Generate(shader); - - Nz::File target("test.spirv"); - if (!target.Open(Nz::OpenMode_WriteOnly | Nz::OpenMode_Truncate)) - return __LINE__; - - target.Write(result.data(), result.size() * sizeof(Nz::UInt32)); - - return 0; - } - */ +{ Nz::Initializer loader; if (!loader) { @@ -63,21 +29,6 @@ int main() std::shared_ptr device = window.GetRenderDevice(); -#if SPIRV - auto fragmentShader = device->InstantiateShaderStage(Nz::ShaderStageType::Fragment, Nz::ShaderLanguage::SpirV, "resources/shaders/triangle.frag.spv"); - if (!fragmentShader) - { - std::cout << "Failed to instantiate fragment shader" << std::endl; - return __LINE__; - } - - auto vertexShader = device->InstantiateShaderStage(Nz::ShaderStageType::Vertex, Nz::ShaderLanguage::SpirV, "resources/shaders/triangle.vert.spv"); - if (!vertexShader) - { - std::cout << "Failed to instantiate fragment shader" << std::endl; - return __LINE__; - } -#else auto fragmentShader = device->InstantiateShaderStage(Nz::ShaderStageType::Fragment, Nz::ShaderLanguage::NazaraBinary, "frag.shader"); if (!fragmentShader) { @@ -91,7 +42,6 @@ int main() std::cout << "Failed to instantiate fragment shader" << std::endl; return __LINE__; } -#endif Nz::MeshRef drfreak = Nz::Mesh::LoadFromFile("resources/Spaceship/spaceship.obj", meshParams); From 0313f2d0a65c4e1af34be92eae14079b3dc3c5fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sun, 9 Aug 2020 18:43:44 +0200 Subject: [PATCH 295/316] Enable GL_DEBUG_OUTPUT --- src/Nazara/OpenGLRenderer/Wrapper/Context.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp index aeb2fe934..81fc4e0af 100644 --- a/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp +++ b/src/Nazara/OpenGLRenderer/Wrapper/Context.cpp @@ -247,6 +247,11 @@ namespace Nz::GL // Set debug callback (if supported) if (glDebugMessageCallback) { + glEnable(GL_DEBUG_OUTPUT); +#ifdef NAZARA_DEBUG + glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); +#endif + glDebugMessageCallback([](GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam) { const Context* context = static_cast(userParam); From 837a6585a187006ae28167df269cd9fc26a07b78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Tue, 11 Aug 2020 00:00:36 +0200 Subject: [PATCH 296/316] Split shader generation to a new module --- build/scripts/modules/renderer.lua | 16 +---- build/scripts/modules/shader.lua | 6 ++ build/scripts/tools/shadernodes.lua | 2 +- examples/VulkanTest/main.cpp | 2 - include/Nazara/OpenGLRenderer/Config.hpp | 2 +- include/Nazara/OpenGLRenderer/ConfigCheck.hpp | 8 +-- include/Nazara/OpenGLRenderer/Debug.hpp | 2 +- include/Nazara/OpenGLRenderer/DebugOff.hpp | 2 +- .../Nazara/OpenGLRenderer/DummySurface.hpp | 2 +- .../Nazara/OpenGLRenderer/OpenGLBuffer.hpp | 2 +- .../Nazara/OpenGLRenderer/OpenGLDevice.hpp | 2 +- .../OpenGLRenderer/OpenGLRenderWindow.hpp | 2 +- .../OpenGLRenderer/OpenGLShaderStage.hpp | 2 +- .../Nazara/OpenGLRenderer/OpenGLVaoCache.hpp | 2 +- include/Nazara/Renderer.hpp | 15 ---- include/Nazara/Renderer/Enums.hpp | 18 ----- .../Nazara/Renderer/RenderPipelineLayout.hpp | 1 + include/Nazara/Renderer/ShaderAstCloner.inl | 12 ---- .../Renderer/ShaderAstRecursiveVisitor.inl | 12 ---- include/Nazara/Shader.hpp | 50 +++++++++++++ include/Nazara/Shader/Config.hpp | 53 ++++++++++++++ include/Nazara/Shader/ConfigCheck.hpp | 22 ++++++ include/Nazara/Shader/Debug.hpp | 8 +++ include/Nazara/Shader/DebugOff.hpp | 9 +++ .../{Renderer => Shader}/GlslWriter.hpp | 14 ++-- .../{Renderer => Shader}/GlslWriter.inl | 8 +-- include/Nazara/Shader/Shader.hpp | 33 +++++++++ .../Nazara/{Renderer => Shader}/ShaderAst.hpp | 10 +-- .../Nazara/{Renderer => Shader}/ShaderAst.inl | 8 +-- .../{Renderer => Shader}/ShaderAstCloner.hpp | 14 ++-- include/Nazara/Shader/ShaderAstCloner.inl | 12 ++++ .../ShaderAstRecursiveVisitor.hpp | 10 +-- .../Shader/ShaderAstRecursiveVisitor.inl | 12 ++++ .../ShaderAstSerializer.hpp | 22 +++--- .../ShaderAstSerializer.inl | 8 +-- .../ShaderAstValidator.hpp | 16 ++--- .../ShaderAstValidator.inl | 8 +-- .../{Renderer => Shader}/ShaderAstVisitor.hpp | 10 +-- .../{Renderer => Shader}/ShaderBuilder.hpp | 6 +- .../{Renderer => Shader}/ShaderBuilder.inl | 8 +-- .../{Renderer => Shader}/ShaderEnums.hpp | 2 +- .../ShaderExpressionType.hpp | 4 +- .../{Renderer => Shader}/ShaderNodes.hpp | 46 ++++++------ .../{Renderer => Shader}/ShaderNodes.inl | 8 +-- .../{Renderer => Shader}/ShaderVarVisitor.hpp | 8 +-- .../{Renderer => Shader}/ShaderVariables.hpp | 24 +++---- .../{Renderer => Shader}/ShaderVariables.inl | 8 +-- .../{Renderer => Shader}/ShaderWriter.hpp | 6 +- .../{Renderer => Shader}/SpirvWriter.hpp | 16 ++--- .../{Renderer => Shader}/SpirvWriter.inl | 8 +-- include/Nazara/Utility/Enums.hpp | 18 +++++ src/Nazara/Renderer/ShaderWriter.cpp | 11 --- src/Nazara/Shader/Debug/NewOverload.cpp | 31 ++++++++ .../{Renderer => Shader}/GlslWriter.cpp | 14 ++-- src/Nazara/Shader/Shader.cpp | 70 +++++++++++++++++++ src/Nazara/{Renderer => Shader}/ShaderAst.cpp | 6 +- .../{Renderer => Shader}/ShaderAstCloner.cpp | 8 +-- .../ShaderAstRecursiveVisitor.cpp | 8 +-- .../ShaderAstSerializer.cpp | 10 +-- .../ShaderAstValidator.cpp | 12 ++-- .../{Renderer => Shader}/ShaderAstVisitor.cpp | 8 +-- .../{Renderer => Shader}/ShaderNodes.cpp | 16 ++--- .../{Renderer => Shader}/ShaderVarVisitor.cpp | 8 +-- .../{Renderer => Shader}/ShaderVariables.cpp | 8 +-- src/Nazara/Shader/ShaderWriter.cpp | 11 +++ .../{Renderer => Shader}/SpirvWriter.cpp | 12 ++-- src/ShaderNode/DataModels/BufferField.cpp | 2 +- src/ShaderNode/DataModels/Cast.inl | 2 +- src/ShaderNode/DataModels/FloatValue.cpp | 2 +- src/ShaderNode/DataModels/InputValue.cpp | 2 +- src/ShaderNode/DataModels/Mat4BinOp.inl | 2 +- src/ShaderNode/DataModels/Mat4VecMul.cpp | 2 +- src/ShaderNode/DataModels/OutputValue.cpp | 2 +- .../DataModels/PositionOutputValue.cpp | 2 +- src/ShaderNode/DataModels/SampleTexture.cpp | 2 +- src/ShaderNode/DataModels/ShaderNode.hpp | 2 +- src/ShaderNode/DataModels/TextureValue.cpp | 2 +- src/ShaderNode/DataModels/VecBinOp.inl | 2 +- src/ShaderNode/DataModels/VecDot.cpp | 2 +- src/ShaderNode/DataModels/VecFloatMul.cpp | 2 +- src/ShaderNode/DataModels/VecValue.inl | 2 +- src/ShaderNode/DataTypes/Matrix4Data.hpp | 2 +- src/ShaderNode/DataTypes/TextureData.hpp | 2 +- src/ShaderNode/DataTypes/VecData.hpp | 2 +- src/ShaderNode/ShaderGraph.hpp | 4 +- src/ShaderNode/Widgets/MainWindow.cpp | 4 +- 86 files changed, 564 insertions(+), 312 deletions(-) create mode 100644 build/scripts/modules/shader.lua delete mode 100644 include/Nazara/Renderer/ShaderAstCloner.inl delete mode 100644 include/Nazara/Renderer/ShaderAstRecursiveVisitor.inl create mode 100644 include/Nazara/Shader.hpp create mode 100644 include/Nazara/Shader/Config.hpp create mode 100644 include/Nazara/Shader/ConfigCheck.hpp create mode 100644 include/Nazara/Shader/Debug.hpp create mode 100644 include/Nazara/Shader/DebugOff.hpp rename include/Nazara/{Renderer => Shader}/GlslWriter.hpp (89%) rename include/Nazara/{Renderer => Shader}/GlslWriter.inl (93%) create mode 100644 include/Nazara/Shader/Shader.hpp rename include/Nazara/{Renderer => Shader}/ShaderAst.hpp (94%) rename include/Nazara/{Renderer => Shader}/ShaderAst.inl (91%) rename include/Nazara/{Renderer => Shader}/ShaderAstCloner.hpp (86%) create mode 100644 include/Nazara/Shader/ShaderAstCloner.inl rename include/Nazara/{Renderer => Shader}/ShaderAstRecursiveVisitor.hpp (80%) create mode 100644 include/Nazara/Shader/ShaderAstRecursiveVisitor.inl rename include/Nazara/{Renderer => Shader}/ShaderAstSerializer.hpp (87%) rename include/Nazara/{Renderer => Shader}/ShaderAstSerializer.inl (92%) rename include/Nazara/{Renderer => Shader}/ShaderAstValidator.hpp (81%) rename include/Nazara/{Renderer => Shader}/ShaderAstValidator.inl (54%) rename include/Nazara/{Renderer => Shader}/ShaderAstVisitor.hpp (86%) rename include/Nazara/{Renderer => Shader}/ShaderBuilder.hpp (94%) rename include/Nazara/{Renderer => Shader}/ShaderBuilder.inl (89%) rename include/Nazara/{Renderer => Shader}/ShaderEnums.hpp (96%) rename include/Nazara/{Renderer => Shader}/ShaderExpressionType.hpp (80%) rename include/Nazara/{Renderer => Shader}/ShaderNodes.hpp (84%) rename include/Nazara/{Renderer => Shader}/ShaderNodes.inl (97%) rename include/Nazara/{Renderer => Shader}/ShaderVarVisitor.hpp (82%) rename include/Nazara/{Renderer => Shader}/ShaderVariables.hpp (78%) rename include/Nazara/{Renderer => Shader}/ShaderVariables.inl (89%) rename include/Nazara/{Renderer => Shader}/ShaderWriter.hpp (79%) rename include/Nazara/{Renderer => Shader}/SpirvWriter.hpp (90%) rename include/Nazara/{Renderer => Shader}/SpirvWriter.inl (93%) delete mode 100644 src/Nazara/Renderer/ShaderWriter.cpp create mode 100644 src/Nazara/Shader/Debug/NewOverload.cpp rename src/Nazara/{Renderer => Shader}/GlslWriter.cpp (97%) create mode 100644 src/Nazara/Shader/Shader.cpp rename src/Nazara/{Renderer => Shader}/ShaderAst.cpp (92%) rename src/Nazara/{Renderer => Shader}/ShaderAstCloner.cpp (97%) rename src/Nazara/{Renderer => Shader}/ShaderAstRecursiveVisitor.cpp (90%) rename src/Nazara/{Renderer => Shader}/ShaderAstSerializer.cpp (98%) rename src/Nazara/{Renderer => Shader}/ShaderAstValidator.cpp (97%) rename src/Nazara/{Renderer => Shader}/ShaderAstVisitor.cpp (73%) rename src/Nazara/{Renderer => Shader}/ShaderNodes.cpp (93%) rename src/Nazara/{Renderer => Shader}/ShaderVarVisitor.cpp (56%) rename src/Nazara/{Renderer => Shader}/ShaderVariables.cpp (86%) create mode 100644 src/Nazara/Shader/ShaderWriter.cpp rename src/Nazara/{Renderer => Shader}/SpirvWriter.cpp (99%) diff --git a/build/scripts/modules/renderer.lua b/build/scripts/modules/renderer.lua index df10e2910..2e3a6619a 100644 --- a/build/scripts/modules/renderer.lua +++ b/build/scripts/modules/renderer.lua @@ -2,12 +2,9 @@ MODULE.Name = "Renderer" MODULE.ClientOnly = true -MODULE.Defines = { - "NAZARA_RENDERER_OPENGL" -} - MODULE.Libraries = { "NazaraCore", + "NazaraShader", "NazaraUtility", "NazaraPlatform" } @@ -22,14 +19,3 @@ MODULE.OsFiles.Posix = { "../src/Nazara/Renderer/GLX/**.cpp" } -MODULE.OsLibraries.Windows = { - "gdi32", - "opengl32", - "winmm" -} - -MODULE.OsLibraries.Posix = { - "GL", - "X11" -} - diff --git a/build/scripts/modules/shader.lua b/build/scripts/modules/shader.lua new file mode 100644 index 000000000..a0a22a663 --- /dev/null +++ b/build/scripts/modules/shader.lua @@ -0,0 +1,6 @@ +MODULE.Name = "Shader" + +MODULE.Libraries = { + "NazaraCore", + "NazaraUtility" +} diff --git a/build/scripts/tools/shadernodes.lua b/build/scripts/tools/shadernodes.lua index 3abeaa658..bcf9a1593 100644 --- a/build/scripts/tools/shadernodes.lua +++ b/build/scripts/tools/shadernodes.lua @@ -28,7 +28,7 @@ TOOL.Files = { TOOL.Libraries = { "NazaraCore", - "NazaraRenderer", + "NazaraShader", "NazaraUtility", "Qt5Cored", "Qt5Guid", diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index cd7132e4a..54c34762c 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -1,7 +1,5 @@ #include #include -#include -#include #include #include diff --git a/include/Nazara/OpenGLRenderer/Config.hpp b/include/Nazara/OpenGLRenderer/Config.hpp index 1ffd4999f..3cc4856f1 100644 --- a/include/Nazara/OpenGLRenderer/Config.hpp +++ b/include/Nazara/OpenGLRenderer/Config.hpp @@ -50,4 +50,4 @@ #define NAZARA_OPENGLRENDERER_API #endif -#endif // NAZARA_CONFIG_MODULENAME_HPP +#endif // NAZARA_CONFIG_OPENGLRENDERER_HPP diff --git a/include/Nazara/OpenGLRenderer/ConfigCheck.hpp b/include/Nazara/OpenGLRenderer/ConfigCheck.hpp index 793b04818..9f59a0119 100644 --- a/include/Nazara/OpenGLRenderer/ConfigCheck.hpp +++ b/include/Nazara/OpenGLRenderer/ConfigCheck.hpp @@ -4,8 +4,8 @@ #pragma once -#ifndef NAZARA_CONFIG_CHECK_OPENGLE_HPP -#define NAZARA_CONFIG_CHECK_OPENGLE_HPP +#ifndef NAZARA_CONFIG_CHECK_OPENGLRENDERER_HPP +#define NAZARA_CONFIG_CHECK_OPENGLRENDERER_HPP /// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp @@ -15,8 +15,8 @@ // On force la valeur de MANAGE_MEMORY en mode debug #if defined(NAZARA_DEBUG) && !NAZARA_OPENGLRENDERER_MANAGE_MEMORY - #undef NAZARA_MODULENAME_MANAGE_MEMORY - #define NAZARA_MODULENAME_MANAGE_MEMORY 0 + #undef NAZARA_OPENGLRENDERER_MANAGE_MEMORY + #define NAZARA_OPENGLRENDERER_MANAGE_MEMORY 0 #endif #endif // NAZARA_CONFIG_CHECK_OPENGLRENDERER_HPP diff --git a/include/Nazara/OpenGLRenderer/Debug.hpp b/include/Nazara/OpenGLRenderer/Debug.hpp index 36e55c909..181fe26d0 100644 --- a/include/Nazara/OpenGLRenderer/Debug.hpp +++ b/include/Nazara/OpenGLRenderer/Debug.hpp @@ -3,6 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#if NAZARA_MODULENAME_MANAGE_MEMORY +#if NAZARA_OPENGLRENDERER_MANAGE_MEMORY #include #endif diff --git a/include/Nazara/OpenGLRenderer/DebugOff.hpp b/include/Nazara/OpenGLRenderer/DebugOff.hpp index c8ee4e470..600f6f117 100644 --- a/include/Nazara/OpenGLRenderer/DebugOff.hpp +++ b/include/Nazara/OpenGLRenderer/DebugOff.hpp @@ -3,7 +3,7 @@ // 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 +#if NAZARA_OPENGLRENDERER_MANAGE_MEMORY #undef delete #undef new #endif diff --git a/include/Nazara/OpenGLRenderer/DummySurface.hpp b/include/Nazara/OpenGLRenderer/DummySurface.hpp index 10246a9d1..51a60783f 100644 --- a/include/Nazara/OpenGLRenderer/DummySurface.hpp +++ b/include/Nazara/OpenGLRenderer/DummySurface.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/OpenGLRenderer/OpenGLBuffer.hpp b/include/Nazara/OpenGLRenderer/OpenGLBuffer.hpp index c00ad0710..17688b5d9 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLBuffer.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLBuffer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp b/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp index 2bbb95c33..9d9b6adef 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLDevice.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp b/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp index 9fdb69561..ceb7b2489 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/OpenGLRenderer/OpenGLShaderStage.hpp b/include/Nazara/OpenGLRenderer/OpenGLShaderStage.hpp index f72f282ad..8768befb7 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLShaderStage.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLShaderStage.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/OpenGLRenderer/OpenGLVaoCache.hpp b/include/Nazara/OpenGLRenderer/OpenGLVaoCache.hpp index 0a9bc14d1..8f7cca48d 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLVaoCache.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLVaoCache.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - OpenGL Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Renderer.hpp b/include/Nazara/Renderer.hpp index ff9193d3f..69153a0d4 100644 --- a/include/Nazara/Renderer.hpp +++ b/include/Nazara/Renderer.hpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -52,22 +51,8 @@ #include #include #include -#include -#include -#include -#include -#include -#include #include -#include -#include -#include -#include #include -#include -#include -#include -#include #include #include #include diff --git a/include/Nazara/Renderer/Enums.hpp b/include/Nazara/Renderer/Enums.hpp index 05daee7a5..0b44ae629 100644 --- a/include/Nazara/Renderer/Enums.hpp +++ b/include/Nazara/Renderer/Enums.hpp @@ -53,24 +53,6 @@ namespace Nz SpirV }; - enum class ShaderStageType - { - Fragment, - Vertex, - - Max = Vertex - }; - - template<> - struct EnumAsFlags - { - static constexpr ShaderStageType max = ShaderStageType::Max; - }; - - using ShaderStageTypeFlags = Flags; - - constexpr ShaderStageTypeFlags ShaderStageType_All = ShaderStageType::Fragment | ShaderStageType::Vertex; - enum class QueueType { Compute, diff --git a/include/Nazara/Renderer/RenderPipelineLayout.hpp b/include/Nazara/Renderer/RenderPipelineLayout.hpp index c15787c35..38c1b6ef3 100644 --- a/include/Nazara/Renderer/RenderPipelineLayout.hpp +++ b/include/Nazara/Renderer/RenderPipelineLayout.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/include/Nazara/Renderer/ShaderAstCloner.inl b/include/Nazara/Renderer/ShaderAstCloner.inl deleted file mode 100644 index 1acdd41ab..000000000 --- a/include/Nazara/Renderer/ShaderAstCloner.inl +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include - -namespace Nz -{ -} - -#include diff --git a/include/Nazara/Renderer/ShaderAstRecursiveVisitor.inl b/include/Nazara/Renderer/ShaderAstRecursiveVisitor.inl deleted file mode 100644 index 3b2c6be62..000000000 --- a/include/Nazara/Renderer/ShaderAstRecursiveVisitor.inl +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include - -namespace Nz -{ -} - -#include diff --git a/include/Nazara/Shader.hpp b/include/Nazara/Shader.hpp new file mode 100644 index 000000000..cd9e02507 --- /dev/null +++ b/include/Nazara/Shader.hpp @@ -0,0 +1,50 @@ +// This file was automatically generated + +/* + Nazara Engine - Module name + + Copyright (C) 2020 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_GLOBAL_SHADER_HPP +#define NAZARA_GLOBAL_SHADER_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif // NAZARA_GLOBAL_SHADER_HPP diff --git a/include/Nazara/Shader/Config.hpp b/include/Nazara/Shader/Config.hpp new file mode 100644 index 000000000..e357579aa --- /dev/null +++ b/include/Nazara/Shader/Config.hpp @@ -0,0 +1,53 @@ +/* + Nazara Engine - Shader generator + + Copyright (C) 2020 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_SHADER_HPP +#define NAZARA_CONFIG_SHADER_HPP + +/// Each modification of a parameter needs a recompilation of the module + +// Use the MemoryManager to manage dynamic allocations (can detect memory leak but allocations/frees are slower) +#define NAZARA_SHADER_MANAGE_MEMORY 0 + +// Activate the security tests based on the code (Advised for development) +#define NAZARA_SHADER_SAFE 1 + +/// Each modification of a parameter following implies a modification (often minor) of the code + +/// Checking the values and types of certain constants +#include + +#if !defined(NAZARA_STATIC) + #ifdef NAZARA_SHADER_BUILD + #define NAZARA_SHADER_API NAZARA_EXPORT + #else + #define NAZARA_SHADER_API NAZARA_IMPORT + #endif +#else + #define NAZARA_SHADER_API +#endif + +#endif // NAZARA_CONFIG_SHADER_HPP diff --git a/include/Nazara/Shader/ConfigCheck.hpp b/include/Nazara/Shader/ConfigCheck.hpp new file mode 100644 index 000000000..48252e452 --- /dev/null +++ b/include/Nazara/Shader/ConfigCheck.hpp @@ -0,0 +1,22 @@ +// Copyright (C) YEAR AUTHORS +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_CONFIG_CHECK_SHADER_HPP +#define NAZARA_CONFIG_CHECK_SHADER_HPP + +/// This file is used to check the constant values defined in 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) + +// We force the value of MANAGE_MEMORY in debug +#if defined(NAZARA_DEBUG) && !NAZARA_SHADER_MANAGE_MEMORY + #undef NAZARA_SHADER_MANAGE_MEMORY + #define NAZARA_SHADER_MANAGE_MEMORY 0 +#endif + +#endif // NAZARA_CONFIG_CHECK_SHADER_HPP diff --git a/include/Nazara/Shader/Debug.hpp b/include/Nazara/Shader/Debug.hpp new file mode 100644 index 000000000..32333d44d --- /dev/null +++ b/include/Nazara/Shader/Debug.hpp @@ -0,0 +1,8 @@ +// Copyright (C) YEAR AUTHORS +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#if NAZARA_SHADER_MANAGE_MEMORY + #include +#endif diff --git a/include/Nazara/Shader/DebugOff.hpp b/include/Nazara/Shader/DebugOff.hpp new file mode 100644 index 000000000..bca09b27c --- /dev/null +++ b/include/Nazara/Shader/DebugOff.hpp @@ -0,0 +1,9 @@ +// Copyright (C) YEAR AUTHORS +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +// We suppose that Debug.hpp is already included, same goes for Config.hpp +#if NAZARA_SHADER_MANAGE_MEMORY + #undef delete + #undef new +#endif diff --git a/include/Nazara/Renderer/GlslWriter.hpp b/include/Nazara/Shader/GlslWriter.hpp similarity index 89% rename from include/Nazara/Renderer/GlslWriter.hpp rename to include/Nazara/Shader/GlslWriter.hpp index d423286db..3212d81cd 100644 --- a/include/Nazara/Renderer/GlslWriter.hpp +++ b/include/Nazara/Shader/GlslWriter.hpp @@ -8,11 +8,11 @@ #define NAZARA_GLSLWRITER_HPP #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include @@ -20,7 +20,7 @@ namespace Nz { - class NAZARA_RENDERER_API GlslWriter : public ShaderWriter, public ShaderVarVisitor, public ShaderAstVisitor + class NAZARA_SHADER_API GlslWriter : public ShaderWriter, public ShaderVarVisitor, public ShaderAstVisitor { public: struct Environment; @@ -104,6 +104,6 @@ namespace Nz }; } -#include +#include #endif // NAZARA_GLSLWRITER_HPP diff --git a/include/Nazara/Renderer/GlslWriter.inl b/include/Nazara/Shader/GlslWriter.inl similarity index 93% rename from include/Nazara/Renderer/GlslWriter.inl rename to include/Nazara/Shader/GlslWriter.inl index e543f870f..76972eec1 100644 --- a/include/Nazara/Renderer/GlslWriter.inl +++ b/include/Nazara/Shader/GlslWriter.inl @@ -1,10 +1,10 @@ // Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include -#include +#include namespace Nz { @@ -129,4 +129,4 @@ namespace Nz } } -#include +#include diff --git a/include/Nazara/Shader/Shader.hpp b/include/Nazara/Shader/Shader.hpp new file mode 100644 index 000000000..e40bd1212 --- /dev/null +++ b/include/Nazara/Shader/Shader.hpp @@ -0,0 +1,33 @@ +// Copyright (C) YEAR AUTHORS +// This file is part of the "Nazara Engine - Module name" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_SHADER_HPP +#define NAZARA_SHADER_HPP + +#include +#include +#include + +namespace Nz +{ + class NAZARA_SHADER_API Shader + { + public: + Shader() = delete; + ~Shader() = delete; + + static bool Initialize(); + + static bool IsInitialized(); + + static void Uninitialize(); + + private: + static unsigned int s_moduleReferenceCounter; + }; +} + +#endif // NAZARA_SHADER_HPP diff --git a/include/Nazara/Renderer/ShaderAst.hpp b/include/Nazara/Shader/ShaderAst.hpp similarity index 94% rename from include/Nazara/Renderer/ShaderAst.hpp rename to include/Nazara/Shader/ShaderAst.hpp index 51117c1d7..11b39d5e9 100644 --- a/include/Nazara/Renderer/ShaderAst.hpp +++ b/include/Nazara/Shader/ShaderAst.hpp @@ -8,16 +8,16 @@ #define NAZARA_SHADER_AST_HPP #include -#include -#include -#include +#include +#include +#include #include #include #include namespace Nz { - class NAZARA_RENDERER_API ShaderAst + class NAZARA_SHADER_API ShaderAst { public: struct Function; @@ -110,6 +110,6 @@ namespace Nz }; } -#include +#include #endif // NAZARA_SHADER_AST_HPP diff --git a/include/Nazara/Renderer/ShaderAst.inl b/include/Nazara/Shader/ShaderAst.inl similarity index 91% rename from include/Nazara/Renderer/ShaderAst.inl rename to include/Nazara/Shader/ShaderAst.inl index f0bc1aebb..4c6c42833 100644 --- a/include/Nazara/Renderer/ShaderAst.inl +++ b/include/Nazara/Shader/ShaderAst.inl @@ -1,9 +1,9 @@ // Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp -#include -#include +#include +#include namespace Nz { @@ -98,4 +98,4 @@ namespace Nz } } -#include +#include diff --git a/include/Nazara/Renderer/ShaderAstCloner.hpp b/include/Nazara/Shader/ShaderAstCloner.hpp similarity index 86% rename from include/Nazara/Renderer/ShaderAstCloner.hpp rename to include/Nazara/Shader/ShaderAstCloner.hpp index c8b61b02c..4c24e689e 100644 --- a/include/Nazara/Renderer/ShaderAstCloner.hpp +++ b/include/Nazara/Shader/ShaderAstCloner.hpp @@ -1,5 +1,5 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once @@ -8,14 +8,14 @@ #define NAZARA_SHADERASTCLONER_HPP #include -#include -#include -#include +#include +#include +#include #include namespace Nz { - class NAZARA_RENDERER_API ShaderAstCloner : public ShaderAstVisitor, public ShaderVarVisitor + class NAZARA_SHADER_API ShaderAstCloner : public ShaderAstVisitor, public ShaderVarVisitor { public: ShaderAstCloner() = default; @@ -69,6 +69,6 @@ namespace Nz }; } -#include +#include #endif diff --git a/include/Nazara/Shader/ShaderAstCloner.inl b/include/Nazara/Shader/ShaderAstCloner.inl new file mode 100644 index 000000000..1182f110d --- /dev/null +++ b/include/Nazara/Shader/ShaderAstCloner.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ +} + +#include diff --git a/include/Nazara/Renderer/ShaderAstRecursiveVisitor.hpp b/include/Nazara/Shader/ShaderAstRecursiveVisitor.hpp similarity index 80% rename from include/Nazara/Renderer/ShaderAstRecursiveVisitor.hpp rename to include/Nazara/Shader/ShaderAstRecursiveVisitor.hpp index 0482ea009..367f9b4ca 100644 --- a/include/Nazara/Renderer/ShaderAstRecursiveVisitor.hpp +++ b/include/Nazara/Shader/ShaderAstRecursiveVisitor.hpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once @@ -8,12 +8,12 @@ #define NAZARA_SHADER_RECURSIVE_VISITOR_HPP #include -#include -#include +#include +#include namespace Nz { - class NAZARA_RENDERER_API ShaderAstRecursiveVisitor : public ShaderAstVisitor + class NAZARA_SHADER_API ShaderAstRecursiveVisitor : public ShaderAstVisitor { public: ShaderAstRecursiveVisitor() = default; @@ -37,6 +37,6 @@ namespace Nz }; } -#include +#include #endif diff --git a/include/Nazara/Shader/ShaderAstRecursiveVisitor.inl b/include/Nazara/Shader/ShaderAstRecursiveVisitor.inl new file mode 100644 index 000000000..8de7f453c --- /dev/null +++ b/include/Nazara/Shader/ShaderAstRecursiveVisitor.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ +} + +#include diff --git a/include/Nazara/Renderer/ShaderAstSerializer.hpp b/include/Nazara/Shader/ShaderAstSerializer.hpp similarity index 87% rename from include/Nazara/Renderer/ShaderAstSerializer.hpp rename to include/Nazara/Shader/ShaderAstSerializer.hpp index 3298d81e6..2e0102e8e 100644 --- a/include/Nazara/Renderer/ShaderAstSerializer.hpp +++ b/include/Nazara/Shader/ShaderAstSerializer.hpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once @@ -10,14 +10,14 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include namespace Nz { - class NAZARA_RENDERER_API ShaderAstSerializerBase + class NAZARA_SHADER_API ShaderAstSerializerBase { public: ShaderAstSerializerBase() = default; @@ -73,7 +73,7 @@ namespace Nz template void Variable(std::shared_ptr& var); }; - class NAZARA_RENDERER_API ShaderAstSerializer final : public ShaderAstSerializerBase + class NAZARA_SHADER_API ShaderAstSerializer final : public ShaderAstSerializerBase { public: inline ShaderAstSerializer(ByteStream& stream); @@ -104,7 +104,7 @@ namespace Nz ByteStream& m_stream; }; - class NAZARA_RENDERER_API ShaderAstUnserializer final : public ShaderAstSerializerBase + class NAZARA_SHADER_API ShaderAstUnserializer final : public ShaderAstSerializerBase { public: ShaderAstUnserializer(ByteStream& stream); @@ -134,10 +134,10 @@ namespace Nz ByteStream& m_stream; }; - NAZARA_RENDERER_API ByteArray SerializeShader(const ShaderAst& shader); - NAZARA_RENDERER_API ShaderAst UnserializeShader(ByteStream& stream); + NAZARA_SHADER_API ByteArray SerializeShader(const ShaderAst& shader); + NAZARA_SHADER_API ShaderAst UnserializeShader(ByteStream& stream); } -#include +#include #endif diff --git a/include/Nazara/Renderer/ShaderAstSerializer.inl b/include/Nazara/Shader/ShaderAstSerializer.inl similarity index 92% rename from include/Nazara/Renderer/ShaderAstSerializer.inl rename to include/Nazara/Shader/ShaderAstSerializer.inl index dd272e1fa..a335f91c2 100644 --- a/include/Nazara/Renderer/ShaderAstSerializer.inl +++ b/include/Nazara/Shader/ShaderAstSerializer.inl @@ -1,9 +1,9 @@ // Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp -#include -#include +#include +#include namespace Nz { @@ -124,4 +124,4 @@ namespace Nz } } -#include +#include diff --git a/include/Nazara/Renderer/ShaderAstValidator.hpp b/include/Nazara/Shader/ShaderAstValidator.hpp similarity index 81% rename from include/Nazara/Renderer/ShaderAstValidator.hpp rename to include/Nazara/Shader/ShaderAstValidator.hpp index 90aec52aa..0f9e99347 100644 --- a/include/Nazara/Renderer/ShaderAstValidator.hpp +++ b/include/Nazara/Shader/ShaderAstValidator.hpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once @@ -10,14 +10,14 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include namespace Nz { - class NAZARA_RENDERER_API ShaderAstValidator : public ShaderAstRecursiveVisitor, public ShaderVarVisitor + class NAZARA_SHADER_API ShaderAstValidator : public ShaderAstRecursiveVisitor, public ShaderVarVisitor { public: inline ShaderAstValidator(const ShaderAst& shader); @@ -62,9 +62,9 @@ namespace Nz Context* m_context; }; - NAZARA_RENDERER_API bool ValidateShader(const ShaderAst& shader, std::string* error = nullptr); + NAZARA_SHADER_API bool ValidateShader(const ShaderAst& shader, std::string* error = nullptr); } -#include +#include #endif diff --git a/include/Nazara/Renderer/ShaderAstValidator.inl b/include/Nazara/Shader/ShaderAstValidator.inl similarity index 54% rename from include/Nazara/Renderer/ShaderAstValidator.inl rename to include/Nazara/Shader/ShaderAstValidator.inl index ee2628ce5..eed116766 100644 --- a/include/Nazara/Renderer/ShaderAstValidator.inl +++ b/include/Nazara/Shader/ShaderAstValidator.inl @@ -1,9 +1,9 @@ // Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp -#include -#include +#include +#include namespace Nz { @@ -13,4 +13,4 @@ namespace Nz } } -#include +#include diff --git a/include/Nazara/Renderer/ShaderAstVisitor.hpp b/include/Nazara/Shader/ShaderAstVisitor.hpp similarity index 86% rename from include/Nazara/Renderer/ShaderAstVisitor.hpp rename to include/Nazara/Shader/ShaderAstVisitor.hpp index 3ce83f406..a6896cb2c 100644 --- a/include/Nazara/Renderer/ShaderAstVisitor.hpp +++ b/include/Nazara/Shader/ShaderAstVisitor.hpp @@ -1,5 +1,5 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once @@ -8,14 +8,14 @@ #define NAZARA_SHADERVISITOR_HPP #include -#include -#include +#include +#include #include #include namespace Nz { - class NAZARA_RENDERER_API ShaderAstVisitor + class NAZARA_SHADER_API ShaderAstVisitor { public: ShaderAstVisitor() = default; diff --git a/include/Nazara/Renderer/ShaderBuilder.hpp b/include/Nazara/Shader/ShaderBuilder.hpp similarity index 94% rename from include/Nazara/Renderer/ShaderBuilder.hpp rename to include/Nazara/Shader/ShaderBuilder.hpp index 8f544e018..074434a44 100644 --- a/include/Nazara/Renderer/ShaderBuilder.hpp +++ b/include/Nazara/Shader/ShaderBuilder.hpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once @@ -8,7 +8,7 @@ #define NAZARA_SHADER_BUILDER_HPP #include -#include +#include #include namespace Nz::ShaderBuilder @@ -71,6 +71,6 @@ namespace Nz::ShaderBuilder template std::shared_ptr Cast(Args&&... args); } -#include +#include #endif // NAZARA_SHADER_BUILDER_HPP diff --git a/include/Nazara/Renderer/ShaderBuilder.inl b/include/Nazara/Shader/ShaderBuilder.inl similarity index 89% rename from include/Nazara/Renderer/ShaderBuilder.inl rename to include/Nazara/Shader/ShaderBuilder.inl index 8ef833536..c3221c84f 100644 --- a/include/Nazara/Renderer/ShaderBuilder.inl +++ b/include/Nazara/Shader/ShaderBuilder.inl @@ -1,9 +1,9 @@ // Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp -#include -#include +#include +#include namespace Nz::ShaderBuilder { @@ -49,4 +49,4 @@ namespace Nz::ShaderBuilder } } -#include +#include diff --git a/include/Nazara/Renderer/ShaderEnums.hpp b/include/Nazara/Shader/ShaderEnums.hpp similarity index 96% rename from include/Nazara/Renderer/ShaderEnums.hpp rename to include/Nazara/Shader/ShaderEnums.hpp index 46e6a3d74..2ddbb5b97 100644 --- a/include/Nazara/Renderer/ShaderEnums.hpp +++ b/include/Nazara/Shader/ShaderEnums.hpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once diff --git a/include/Nazara/Renderer/ShaderExpressionType.hpp b/include/Nazara/Shader/ShaderExpressionType.hpp similarity index 80% rename from include/Nazara/Renderer/ShaderExpressionType.hpp rename to include/Nazara/Shader/ShaderExpressionType.hpp index 68671b07c..69b53b06a 100644 --- a/include/Nazara/Renderer/ShaderExpressionType.hpp +++ b/include/Nazara/Shader/ShaderExpressionType.hpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once @@ -8,7 +8,7 @@ #define NAZARA_SHADER_EXPRESSIONTYPE_HPP #include -#include +#include #include #include diff --git a/include/Nazara/Renderer/ShaderNodes.hpp b/include/Nazara/Shader/ShaderNodes.hpp similarity index 84% rename from include/Nazara/Renderer/ShaderNodes.hpp rename to include/Nazara/Shader/ShaderNodes.hpp index 985cde039..833af1248 100644 --- a/include/Nazara/Renderer/ShaderNodes.hpp +++ b/include/Nazara/Shader/ShaderNodes.hpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once @@ -11,10 +11,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include @@ -29,7 +29,7 @@ namespace Nz using NodePtr = std::shared_ptr; - class NAZARA_RENDERER_API Node + class NAZARA_SHADER_API Node { public: virtual ~Node(); @@ -54,7 +54,7 @@ namespace Nz using ExpressionPtr = std::shared_ptr; - class NAZARA_RENDERER_API Expression : public Node + class NAZARA_SHADER_API Expression : public Node { public: inline Expression(NodeType type); @@ -67,13 +67,13 @@ namespace Nz using StatementPtr = std::shared_ptr; - class NAZARA_RENDERER_API Statement : public Node + class NAZARA_SHADER_API Statement : public Node { public: inline Statement(NodeType type); }; - struct NAZARA_RENDERER_API ExpressionStatement : public Statement + struct NAZARA_SHADER_API ExpressionStatement : public Statement { inline ExpressionStatement(); @@ -86,7 +86,7 @@ namespace Nz ////////////////////////////////////////////////////////////////////////// - struct NAZARA_RENDERER_API ConditionalStatement : public Statement + struct NAZARA_SHADER_API ConditionalStatement : public Statement { inline ConditionalStatement(); @@ -98,7 +98,7 @@ namespace Nz static inline std::shared_ptr Build(std::string condition, StatementPtr statementPtr); }; - struct NAZARA_RENDERER_API StatementBlock : public Statement + struct NAZARA_SHADER_API StatementBlock : public Statement { inline StatementBlock(); @@ -110,7 +110,7 @@ namespace Nz template static std::shared_ptr Build(Args&&... args); }; - struct NAZARA_RENDERER_API DeclareVariable : public Statement + struct NAZARA_SHADER_API DeclareVariable : public Statement { inline DeclareVariable(); @@ -122,7 +122,7 @@ namespace Nz static inline std::shared_ptr Build(VariablePtr variable, ExpressionPtr expression = nullptr); }; - struct NAZARA_RENDERER_API Identifier : public Expression + struct NAZARA_SHADER_API Identifier : public Expression { inline Identifier(); @@ -135,7 +135,7 @@ namespace Nz static inline std::shared_ptr Build(VariablePtr variable); }; - struct NAZARA_RENDERER_API AccessMember : public Expression + struct NAZARA_SHADER_API AccessMember : public Expression { inline AccessMember(); @@ -152,7 +152,7 @@ namespace Nz ////////////////////////////////////////////////////////////////////////// - struct NAZARA_RENDERER_API AssignOp : public Expression + struct NAZARA_SHADER_API AssignOp : public Expression { inline AssignOp(); @@ -166,7 +166,7 @@ namespace Nz static inline std::shared_ptr Build(AssignType op, ExpressionPtr left, ExpressionPtr right); }; - struct NAZARA_RENDERER_API BinaryOp : public Expression + struct NAZARA_SHADER_API BinaryOp : public Expression { inline BinaryOp(); @@ -180,7 +180,7 @@ namespace Nz static inline std::shared_ptr Build(BinaryType op, ExpressionPtr left, ExpressionPtr right); }; - struct NAZARA_RENDERER_API Branch : public Statement + struct NAZARA_SHADER_API Branch : public Statement { struct ConditionalStatement; @@ -201,7 +201,7 @@ namespace Nz static inline std::shared_ptr Build(std::vector statements, StatementPtr elseStatement = nullptr); }; - struct NAZARA_RENDERER_API Cast : public Expression + struct NAZARA_SHADER_API Cast : public Expression { inline Cast(); @@ -215,7 +215,7 @@ namespace Nz static inline std::shared_ptr Build(BasicType castTo, ExpressionPtr* expressions, std::size_t expressionCount); }; - struct NAZARA_RENDERER_API Constant : public Expression + struct NAZARA_SHADER_API Constant : public Expression { inline Constant(); @@ -239,7 +239,7 @@ namespace Nz template static std::shared_ptr Build(const T& value); }; - struct NAZARA_RENDERER_API SwizzleOp : public Expression + struct NAZARA_SHADER_API SwizzleOp : public Expression { inline SwizzleOp(); @@ -257,7 +257,7 @@ namespace Nz ////////////////////////////////////////////////////////////////////////// - struct NAZARA_RENDERER_API Sample2D : public Expression + struct NAZARA_SHADER_API Sample2D : public Expression { inline Sample2D(); @@ -272,7 +272,7 @@ namespace Nz ////////////////////////////////////////////////////////////////////////// - struct NAZARA_RENDERER_API IntrinsicCall : public Expression + struct NAZARA_SHADER_API IntrinsicCall : public Expression { inline IntrinsicCall(); @@ -287,6 +287,6 @@ namespace Nz } } -#include +#include #endif diff --git a/include/Nazara/Renderer/ShaderNodes.inl b/include/Nazara/Shader/ShaderNodes.inl similarity index 97% rename from include/Nazara/Renderer/ShaderNodes.inl rename to include/Nazara/Shader/ShaderNodes.inl index e6dbec2ba..9265fe359 100644 --- a/include/Nazara/Renderer/ShaderNodes.inl +++ b/include/Nazara/Shader/ShaderNodes.inl @@ -1,9 +1,9 @@ // Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp -#include -#include +#include +#include namespace Nz::ShaderNodes { @@ -335,4 +335,4 @@ namespace Nz::ShaderNodes } } -#include +#include diff --git a/include/Nazara/Renderer/ShaderVarVisitor.hpp b/include/Nazara/Shader/ShaderVarVisitor.hpp similarity index 82% rename from include/Nazara/Renderer/ShaderVarVisitor.hpp rename to include/Nazara/Shader/ShaderVarVisitor.hpp index bda5e0b4d..ebee55ab6 100644 --- a/include/Nazara/Renderer/ShaderVarVisitor.hpp +++ b/include/Nazara/Shader/ShaderVarVisitor.hpp @@ -1,5 +1,5 @@ // Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once @@ -8,12 +8,12 @@ #define NAZARA_SHADERVARVISITOR_HPP #include -#include -#include +#include +#include namespace Nz { - class NAZARA_RENDERER_API ShaderVarVisitor + class NAZARA_SHADER_API ShaderVarVisitor { public: ShaderVarVisitor() = default; diff --git a/include/Nazara/Renderer/ShaderVariables.hpp b/include/Nazara/Shader/ShaderVariables.hpp similarity index 78% rename from include/Nazara/Renderer/ShaderVariables.hpp rename to include/Nazara/Shader/ShaderVariables.hpp index 4fac1681f..eb0bc8ede 100644 --- a/include/Nazara/Renderer/ShaderVariables.hpp +++ b/include/Nazara/Shader/ShaderVariables.hpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once @@ -11,8 +11,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -28,7 +28,7 @@ namespace Nz using VariablePtr = std::shared_ptr; - struct NAZARA_RENDERER_API Variable : std::enable_shared_from_this + struct NAZARA_SHADER_API Variable : std::enable_shared_from_this { virtual ~Variable(); @@ -42,7 +42,7 @@ namespace Nz using BuiltinVariablePtr = std::shared_ptr; - struct NAZARA_RENDERER_API BuiltinVariable : public Variable + struct NAZARA_SHADER_API BuiltinVariable : public Variable { BuiltinEntry entry; @@ -56,7 +56,7 @@ namespace Nz using NamedVariablePtr = std::shared_ptr; - struct NAZARA_RENDERER_API NamedVariable : public Variable + struct NAZARA_SHADER_API NamedVariable : public Variable { std::string name; }; @@ -65,7 +65,7 @@ namespace Nz using InputVariablePtr = std::shared_ptr; - struct NAZARA_RENDERER_API InputVariable : public NamedVariable + struct NAZARA_SHADER_API InputVariable : public NamedVariable { VariableType GetType() const override; void Visit(ShaderVarVisitor& visitor) override; @@ -77,7 +77,7 @@ namespace Nz using LocalVariablePtr = std::shared_ptr; - struct NAZARA_RENDERER_API LocalVariable : public NamedVariable + struct NAZARA_SHADER_API LocalVariable : public NamedVariable { VariableType GetType() const override; void Visit(ShaderVarVisitor& visitor) override; @@ -89,7 +89,7 @@ namespace Nz using OutputVariablePtr = std::shared_ptr; - struct NAZARA_RENDERER_API OutputVariable : public NamedVariable + struct NAZARA_SHADER_API OutputVariable : public NamedVariable { VariableType GetType() const override; void Visit(ShaderVarVisitor& visitor) override; @@ -101,7 +101,7 @@ namespace Nz using ParameterVariablePtr = std::shared_ptr; - struct NAZARA_RENDERER_API ParameterVariable : public NamedVariable + struct NAZARA_SHADER_API ParameterVariable : public NamedVariable { VariableType GetType() const override; void Visit(ShaderVarVisitor& visitor) override; @@ -113,7 +113,7 @@ namespace Nz using UniformVariablePtr = std::shared_ptr; - struct NAZARA_RENDERER_API UniformVariable : public NamedVariable + struct NAZARA_SHADER_API UniformVariable : public NamedVariable { VariableType GetType() const override; void Visit(ShaderVarVisitor& visitor) override; @@ -123,6 +123,6 @@ namespace Nz } } -#include +#include #endif diff --git a/include/Nazara/Renderer/ShaderVariables.inl b/include/Nazara/Shader/ShaderVariables.inl similarity index 89% rename from include/Nazara/Renderer/ShaderVariables.inl rename to include/Nazara/Shader/ShaderVariables.inl index 917459c67..9f2415708 100644 --- a/include/Nazara/Renderer/ShaderVariables.inl +++ b/include/Nazara/Shader/ShaderVariables.inl @@ -1,9 +1,9 @@ // Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp -#include -#include +#include +#include namespace Nz::ShaderNodes { @@ -62,4 +62,4 @@ namespace Nz::ShaderNodes } } -#include +#include diff --git a/include/Nazara/Renderer/ShaderWriter.hpp b/include/Nazara/Shader/ShaderWriter.hpp similarity index 79% rename from include/Nazara/Renderer/ShaderWriter.hpp rename to include/Nazara/Shader/ShaderWriter.hpp index e4fe2d835..0e896fa40 100644 --- a/include/Nazara/Renderer/ShaderWriter.hpp +++ b/include/Nazara/Shader/ShaderWriter.hpp @@ -1,5 +1,5 @@ // Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once @@ -8,14 +8,14 @@ #define NAZARA_SHADERWRITER_HPP #include -#include +#include #include namespace Nz { class ShaderAst; - class NAZARA_RENDERER_API ShaderWriter + class NAZARA_SHADER_API ShaderWriter { public: ShaderWriter() = default; diff --git a/include/Nazara/Renderer/SpirvWriter.hpp b/include/Nazara/Shader/SpirvWriter.hpp similarity index 90% rename from include/Nazara/Renderer/SpirvWriter.hpp rename to include/Nazara/Shader/SpirvWriter.hpp index b9e48dd12..90f6b0e3e 100644 --- a/include/Nazara/Renderer/SpirvWriter.hpp +++ b/include/Nazara/Shader/SpirvWriter.hpp @@ -1,5 +1,5 @@ // Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once @@ -8,11 +8,11 @@ #define NAZARA_SPIRVWRITER_HPP #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include @@ -20,7 +20,7 @@ namespace Nz { - class NAZARA_RENDERER_API SpirvWriter : public ShaderAstVisitor, public ShaderVarVisitor + class NAZARA_SHADER_API SpirvWriter : public ShaderAstVisitor, public ShaderVarVisitor { public: struct Environment; @@ -127,6 +127,6 @@ namespace Nz }; } -#include +#include #endif diff --git a/include/Nazara/Renderer/SpirvWriter.inl b/include/Nazara/Shader/SpirvWriter.inl similarity index 93% rename from include/Nazara/Renderer/SpirvWriter.inl rename to include/Nazara/Shader/SpirvWriter.inl index 2e75f1271..4ef96c82b 100644 --- a/include/Nazara/Renderer/SpirvWriter.inl +++ b/include/Nazara/Shader/SpirvWriter.inl @@ -1,11 +1,11 @@ // Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include #include -#include +#include namespace Nz { @@ -108,4 +108,4 @@ namespace Nz } } -#include +#include diff --git a/include/Nazara/Utility/Enums.hpp b/include/Nazara/Utility/Enums.hpp index 0e652448e..99328ecde 100644 --- a/include/Nazara/Utility/Enums.hpp +++ b/include/Nazara/Utility/Enums.hpp @@ -309,6 +309,24 @@ namespace Nz SamplerWrap_Max = SamplerWrap_Repeat }; + enum class ShaderStageType + { + Fragment, + Vertex, + + Max = Vertex + }; + + template<> + struct EnumAsFlags + { + static constexpr ShaderStageType max = ShaderStageType::Max; + }; + + using ShaderStageTypeFlags = Flags; + + constexpr ShaderStageTypeFlags ShaderStageType_All = ShaderStageType::Fragment | ShaderStageType::Vertex; + enum StructFieldType { StructFieldType_Bool1, diff --git a/src/Nazara/Renderer/ShaderWriter.cpp b/src/Nazara/Renderer/ShaderWriter.cpp deleted file mode 100644 index 8ca48da3e..000000000 --- a/src/Nazara/Renderer/ShaderWriter.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include - -namespace Nz -{ - ShaderWriter::~ShaderWriter() = default; -} diff --git a/src/Nazara/Shader/Debug/NewOverload.cpp b/src/Nazara/Shader/Debug/NewOverload.cpp new file mode 100644 index 000000000..d16399d8f --- /dev/null +++ b/src/Nazara/Shader/Debug/NewOverload.cpp @@ -0,0 +1,31 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#if NAZARA_SHADER_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_SHADER_MANAGE_MEMORY diff --git a/src/Nazara/Renderer/GlslWriter.cpp b/src/Nazara/Shader/GlslWriter.cpp similarity index 97% rename from src/Nazara/Renderer/GlslWriter.cpp rename to src/Nazara/Shader/GlslWriter.cpp index f851a3aa0..b17c8d4a3 100644 --- a/src/Nazara/Renderer/GlslWriter.cpp +++ b/src/Nazara/Shader/GlslWriter.cpp @@ -1,15 +1,15 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include #include -#include -#include -#include +#include +#include +#include #include -#include +#include namespace Nz { diff --git a/src/Nazara/Shader/Shader.cpp b/src/Nazara/Shader/Shader.cpp new file mode 100644 index 000000000..44d65fbe6 --- /dev/null +++ b/src/Nazara/Shader/Shader.cpp @@ -0,0 +1,70 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + bool Shader::Initialize() + { + if (s_moduleReferenceCounter > 0) + { + s_moduleReferenceCounter++; + return true; // Already initialized + } + + // Initialize module dependencies + if (!Core::Initialize()) + { + NazaraError("Failed to initialize shader module"); + return false; + } + + s_moduleReferenceCounter++; + + CallOnExit onExit(Shader::Uninitialize); + + // Initialize module here + + onExit.Reset(); + + NazaraNotice("Initialized: Shader module"); + return true; + } + + bool Shader::IsInitialized() + { + return s_moduleReferenceCounter != 0; + } + + void Shader::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: Shader module"); + + // Free module dependencies + Core::Uninitialize(); + } + + unsigned int Shader::s_moduleReferenceCounter = 0; +} + diff --git a/src/Nazara/Renderer/ShaderAst.cpp b/src/Nazara/Shader/ShaderAst.cpp similarity index 92% rename from src/Nazara/Renderer/ShaderAst.cpp rename to src/Nazara/Shader/ShaderAst.cpp index da009248b..236a5e28f 100644 --- a/src/Nazara/Renderer/ShaderAst.cpp +++ b/src/Nazara/Shader/ShaderAst.cpp @@ -1,9 +1,9 @@ // Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp -#include -#include +#include +#include namespace Nz { diff --git a/src/Nazara/Renderer/ShaderAstCloner.cpp b/src/Nazara/Shader/ShaderAstCloner.cpp similarity index 97% rename from src/Nazara/Renderer/ShaderAstCloner.cpp rename to src/Nazara/Shader/ShaderAstCloner.cpp index 2b712075c..1e0f04899 100644 --- a/src/Nazara/Renderer/ShaderAstCloner.cpp +++ b/src/Nazara/Shader/ShaderAstCloner.cpp @@ -1,10 +1,10 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include -#include +#include namespace Nz { diff --git a/src/Nazara/Renderer/ShaderAstRecursiveVisitor.cpp b/src/Nazara/Shader/ShaderAstRecursiveVisitor.cpp similarity index 90% rename from src/Nazara/Renderer/ShaderAstRecursiveVisitor.cpp rename to src/Nazara/Shader/ShaderAstRecursiveVisitor.cpp index 5a39e68c5..98fdbfee6 100644 --- a/src/Nazara/Renderer/ShaderAstRecursiveVisitor.cpp +++ b/src/Nazara/Shader/ShaderAstRecursiveVisitor.cpp @@ -1,9 +1,9 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp -#include -#include +#include +#include namespace Nz { diff --git a/src/Nazara/Renderer/ShaderAstSerializer.cpp b/src/Nazara/Shader/ShaderAstSerializer.cpp similarity index 98% rename from src/Nazara/Renderer/ShaderAstSerializer.cpp rename to src/Nazara/Shader/ShaderAstSerializer.cpp index f8afa178c..6d45cc711 100644 --- a/src/Nazara/Renderer/ShaderAstSerializer.cpp +++ b/src/Nazara/Shader/ShaderAstSerializer.cpp @@ -1,11 +1,11 @@ // Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp -#include -#include -#include -#include +#include +#include +#include +#include namespace Nz { diff --git a/src/Nazara/Renderer/ShaderAstValidator.cpp b/src/Nazara/Shader/ShaderAstValidator.cpp similarity index 97% rename from src/Nazara/Renderer/ShaderAstValidator.cpp rename to src/Nazara/Shader/ShaderAstValidator.cpp index 81970e766..2f3177283 100644 --- a/src/Nazara/Renderer/ShaderAstValidator.cpp +++ b/src/Nazara/Shader/ShaderAstValidator.cpp @@ -1,13 +1,13 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include -#include -#include +#include +#include #include -#include +#include namespace Nz { diff --git a/src/Nazara/Renderer/ShaderAstVisitor.cpp b/src/Nazara/Shader/ShaderAstVisitor.cpp similarity index 73% rename from src/Nazara/Renderer/ShaderAstVisitor.cpp rename to src/Nazara/Shader/ShaderAstVisitor.cpp index 49760f028..53325c9ca 100644 --- a/src/Nazara/Renderer/ShaderAstVisitor.cpp +++ b/src/Nazara/Shader/ShaderAstVisitor.cpp @@ -1,9 +1,9 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp -#include -#include +#include +#include namespace Nz { diff --git a/src/Nazara/Renderer/ShaderNodes.cpp b/src/Nazara/Shader/ShaderNodes.cpp similarity index 93% rename from src/Nazara/Renderer/ShaderNodes.cpp rename to src/Nazara/Shader/ShaderNodes.cpp index 29ffb8508..2f72a1ea0 100644 --- a/src/Nazara/Renderer/ShaderNodes.cpp +++ b/src/Nazara/Shader/ShaderNodes.cpp @@ -1,13 +1,13 @@ // Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include -#include -#include -#include -#include +#include +#include +#include +#include namespace Nz::ShaderNodes { @@ -61,7 +61,7 @@ namespace Nz::ShaderNodes ExpressionCategory AccessMember::GetExpressionCategory() const { - return ExpressionCategory::LValue; + return structExpr->GetExpressionCategory(); } ShaderExpressionType AccessMember::GetExpressionType() const @@ -200,7 +200,7 @@ namespace Nz::ShaderNodes ExpressionCategory SwizzleOp::GetExpressionCategory() const { - return ExpressionCategory::LValue; + return expression->GetExpressionCategory(); } ShaderExpressionType SwizzleOp::GetExpressionType() const diff --git a/src/Nazara/Renderer/ShaderVarVisitor.cpp b/src/Nazara/Shader/ShaderVarVisitor.cpp similarity index 56% rename from src/Nazara/Renderer/ShaderVarVisitor.cpp rename to src/Nazara/Shader/ShaderVarVisitor.cpp index 6f3838f26..108d5c69a 100644 --- a/src/Nazara/Renderer/ShaderVarVisitor.cpp +++ b/src/Nazara/Shader/ShaderVarVisitor.cpp @@ -1,9 +1,9 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp -#include -#include +#include +#include namespace Nz { diff --git a/src/Nazara/Renderer/ShaderVariables.cpp b/src/Nazara/Shader/ShaderVariables.cpp similarity index 86% rename from src/Nazara/Renderer/ShaderVariables.cpp rename to src/Nazara/Shader/ShaderVariables.cpp index 93701c4ef..ebe520a0c 100644 --- a/src/Nazara/Renderer/ShaderVariables.cpp +++ b/src/Nazara/Shader/ShaderVariables.cpp @@ -1,10 +1,10 @@ // Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp -#include -#include -#include +#include +#include +#include namespace Nz::ShaderNodes { diff --git a/src/Nazara/Shader/ShaderWriter.cpp b/src/Nazara/Shader/ShaderWriter.cpp new file mode 100644 index 000000000..6e994f0f0 --- /dev/null +++ b/src/Nazara/Shader/ShaderWriter.cpp @@ -0,0 +1,11 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + ShaderWriter::~ShaderWriter() = default; +} diff --git a/src/Nazara/Renderer/SpirvWriter.cpp b/src/Nazara/Shader/SpirvWriter.cpp similarity index 99% rename from src/Nazara/Renderer/SpirvWriter.cpp rename to src/Nazara/Shader/SpirvWriter.cpp index 1e9218e34..b3b318c63 100644 --- a/src/Nazara/Renderer/SpirvWriter.cpp +++ b/src/Nazara/Shader/SpirvWriter.cpp @@ -1,13 +1,13 @@ -// Copyright (C) 2015 Jérôme Leclercq -// This file is part of the "Nazara Engine - Renderer module" +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include #include #include -#include -#include +#include +#include #include #include #include @@ -16,7 +16,7 @@ #include #include #include -#include +#include namespace Nz { diff --git a/src/ShaderNode/DataModels/BufferField.cpp b/src/ShaderNode/DataModels/BufferField.cpp index 844f56bd8..2d9cde16d 100644 --- a/src/ShaderNode/DataModels/BufferField.cpp +++ b/src/ShaderNode/DataModels/BufferField.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/ShaderNode/DataModels/Cast.inl b/src/ShaderNode/DataModels/Cast.inl index fb088b3a0..cd96d6ccc 100644 --- a/src/ShaderNode/DataModels/Cast.inl +++ b/src/ShaderNode/DataModels/Cast.inl @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/src/ShaderNode/DataModels/FloatValue.cpp b/src/ShaderNode/DataModels/FloatValue.cpp index c30ea8874..23a4c766f 100644 --- a/src/ShaderNode/DataModels/FloatValue.cpp +++ b/src/ShaderNode/DataModels/FloatValue.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include FloatValue::FloatValue(ShaderGraph& graph) : diff --git a/src/ShaderNode/DataModels/InputValue.cpp b/src/ShaderNode/DataModels/InputValue.cpp index c2c6f6b01..e4710e6f5 100644 --- a/src/ShaderNode/DataModels/InputValue.cpp +++ b/src/ShaderNode/DataModels/InputValue.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include InputValue::InputValue(ShaderGraph& graph) : diff --git a/src/ShaderNode/DataModels/Mat4BinOp.inl b/src/ShaderNode/DataModels/Mat4BinOp.inl index 684a6ec79..05cdb0479 100644 --- a/src/ShaderNode/DataModels/Mat4BinOp.inl +++ b/src/ShaderNode/DataModels/Mat4BinOp.inl @@ -1,5 +1,5 @@ #include -#include +#include template Mat4BinOp::Mat4BinOp(ShaderGraph& graph) : diff --git a/src/ShaderNode/DataModels/Mat4VecMul.cpp b/src/ShaderNode/DataModels/Mat4VecMul.cpp index 2e530e496..983545973 100644 --- a/src/ShaderNode/DataModels/Mat4VecMul.cpp +++ b/src/ShaderNode/DataModels/Mat4VecMul.cpp @@ -1,5 +1,5 @@ #include -#include +#include Mat4VecMul::Mat4VecMul(ShaderGraph& graph) : ShaderNode(graph) diff --git a/src/ShaderNode/DataModels/OutputValue.cpp b/src/ShaderNode/DataModels/OutputValue.cpp index 6f30a9b66..63a481588 100644 --- a/src/ShaderNode/DataModels/OutputValue.cpp +++ b/src/ShaderNode/DataModels/OutputValue.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/src/ShaderNode/DataModels/PositionOutputValue.cpp b/src/ShaderNode/DataModels/PositionOutputValue.cpp index ee1be66a2..c3d252f54 100644 --- a/src/ShaderNode/DataModels/PositionOutputValue.cpp +++ b/src/ShaderNode/DataModels/PositionOutputValue.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/src/ShaderNode/DataModels/SampleTexture.cpp b/src/ShaderNode/DataModels/SampleTexture.cpp index 131a8b161..c784b83af 100644 --- a/src/ShaderNode/DataModels/SampleTexture.cpp +++ b/src/ShaderNode/DataModels/SampleTexture.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include SampleTexture::SampleTexture(ShaderGraph& graph) : ShaderNode(graph) diff --git a/src/ShaderNode/DataModels/ShaderNode.hpp b/src/ShaderNode/DataModels/ShaderNode.hpp index 1becb5a3d..6d3dd5cc1 100644 --- a/src/ShaderNode/DataModels/ShaderNode.hpp +++ b/src/ShaderNode/DataModels/ShaderNode.hpp @@ -4,7 +4,7 @@ #define NAZARA_SHADERNODES_SHADERNODE_HPP #include -#include +#include #include #include #include diff --git a/src/ShaderNode/DataModels/TextureValue.cpp b/src/ShaderNode/DataModels/TextureValue.cpp index 79df6de5c..c400d0469 100644 --- a/src/ShaderNode/DataModels/TextureValue.cpp +++ b/src/ShaderNode/DataModels/TextureValue.cpp @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include TextureValue::TextureValue(ShaderGraph& graph) : diff --git a/src/ShaderNode/DataModels/VecBinOp.inl b/src/ShaderNode/DataModels/VecBinOp.inl index d159545be..d16347799 100644 --- a/src/ShaderNode/DataModels/VecBinOp.inl +++ b/src/ShaderNode/DataModels/VecBinOp.inl @@ -1,5 +1,5 @@ #include -#include +#include template VecBinOp::VecBinOp(ShaderGraph& graph) : diff --git a/src/ShaderNode/DataModels/VecDot.cpp b/src/ShaderNode/DataModels/VecDot.cpp index 818a68a2a..b083623d0 100644 --- a/src/ShaderNode/DataModels/VecDot.cpp +++ b/src/ShaderNode/DataModels/VecDot.cpp @@ -1,5 +1,5 @@ #include -#include +#include VecDot::VecDot(ShaderGraph& graph) : ShaderNode(graph) diff --git a/src/ShaderNode/DataModels/VecFloatMul.cpp b/src/ShaderNode/DataModels/VecFloatMul.cpp index c1ecf50d2..9dd3b02c3 100644 --- a/src/ShaderNode/DataModels/VecFloatMul.cpp +++ b/src/ShaderNode/DataModels/VecFloatMul.cpp @@ -1,5 +1,5 @@ #include -#include +#include VecFloatMul::VecFloatMul(ShaderGraph& graph) : ShaderNode(graph) diff --git a/src/ShaderNode/DataModels/VecValue.inl b/src/ShaderNode/DataModels/VecValue.inl index 8b72d1186..b07c46a9b 100644 --- a/src/ShaderNode/DataModels/VecValue.inl +++ b/src/ShaderNode/DataModels/VecValue.inl @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include #include diff --git a/src/ShaderNode/DataTypes/Matrix4Data.hpp b/src/ShaderNode/DataTypes/Matrix4Data.hpp index fdfbf1897..4eb63f136 100644 --- a/src/ShaderNode/DataTypes/Matrix4Data.hpp +++ b/src/ShaderNode/DataTypes/Matrix4Data.hpp @@ -3,7 +3,7 @@ #ifndef NAZARA_SHADERNODES_MATRIXDATA_HPP #define NAZARA_SHADERNODES_MATRIXDATA_HPP -#include +#include #include #include diff --git a/src/ShaderNode/DataTypes/TextureData.hpp b/src/ShaderNode/DataTypes/TextureData.hpp index b6f7b4433..28b2b73d0 100644 --- a/src/ShaderNode/DataTypes/TextureData.hpp +++ b/src/ShaderNode/DataTypes/TextureData.hpp @@ -4,7 +4,7 @@ #define NAZARA_SHADERNODES_TEXTUREDATA_HPP #include -#include +#include #include struct TextureData : public QtNodes::NodeData diff --git a/src/ShaderNode/DataTypes/VecData.hpp b/src/ShaderNode/DataTypes/VecData.hpp index 7c515a12a..d80bff106 100644 --- a/src/ShaderNode/DataTypes/VecData.hpp +++ b/src/ShaderNode/DataTypes/VecData.hpp @@ -3,7 +3,7 @@ #ifndef NAZARA_SHADERNODES_VECDATA_HPP #define NAZARA_SHADERNODES_VECDATA_HPP -#include +#include #include #include diff --git a/src/ShaderNode/ShaderGraph.hpp b/src/ShaderNode/ShaderGraph.hpp index be7aeba4c..1df336ce6 100644 --- a/src/ShaderNode/ShaderGraph.hpp +++ b/src/ShaderNode/ShaderGraph.hpp @@ -4,8 +4,8 @@ #define NAZARA_SHADERNODES_SHADERGRAPH_HPP #include -#include -#include +#include +#include #include #include #include diff --git a/src/ShaderNode/Widgets/MainWindow.cpp b/src/ShaderNode/Widgets/MainWindow.cpp index 31665bb8d..b88bef25f 100644 --- a/src/ShaderNode/Widgets/MainWindow.cpp +++ b/src/ShaderNode/Widgets/MainWindow.cpp @@ -1,7 +1,7 @@ #include #include -#include -#include +#include +#include #include #include #include From 1a12e18a3600075a09e6e0291653a5966443287d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Tue, 11 Aug 2020 00:01:49 +0200 Subject: [PATCH 297/316] Fix copyright dates and some defines --- include/Nazara/Math/Ray.inl | 2 +- include/Nazara/Utility/FieldOffsets.hpp | 2 +- include/Nazara/Utility/FieldOffsets.inl | 2 +- include/Nazara/VulkanRenderer/Config.hpp | 2 +- include/Nazara/VulkanRenderer/ConfigCheck.hpp | 8 ++++---- include/Nazara/VulkanRenderer/Debug.hpp | 2 +- include/Nazara/VulkanRenderer/DebugOff.hpp | 2 +- include/Nazara/VulkanRenderer/VkRenderWindow.hpp | 2 +- include/Nazara/VulkanRenderer/VulkanBuffer.hpp | 2 +- include/Nazara/VulkanRenderer/VulkanDevice.hpp | 2 +- include/Nazara/VulkanRenderer/VulkanShaderStage.hpp | 2 +- include/Nazara/VulkanRenderer/VulkanSurface.hpp | 2 +- src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp | 2 +- src/Nazara/Platform/SDL2/CursorImpl.cpp | 2 +- src/Nazara/Platform/SDL2/IconImpl.cpp | 2 +- src/Nazara/Platform/SDL2/InputImpl.cpp | 2 +- src/Nazara/Platform/SDL2/SDLHelper.cpp | 2 +- src/Nazara/Platform/SDL2/SDLHelper.hpp | 2 +- src/Nazara/Platform/SDL2/VideoModeImpl.cpp | 2 +- src/Nazara/Platform/SDL2/WindowImpl.cpp | 2 +- src/Nazara/Renderer/CommandBuffer.cpp | 2 +- src/Nazara/Renderer/CommandBufferBuilder.cpp | 2 +- src/Nazara/Renderer/CommandPool.cpp | 2 +- src/Nazara/Renderer/Framebuffer.cpp | 2 +- src/Nazara/Renderer/RenderBuffer.cpp | 2 +- src/Nazara/Renderer/RenderDevice.cpp | 2 +- src/Nazara/Renderer/RenderImage.cpp | 2 +- src/Nazara/Renderer/RenderPass.cpp | 2 +- src/Nazara/Renderer/RenderPipeline.cpp | 2 +- src/Nazara/Renderer/RenderPipelineLayout.cpp | 2 +- src/Nazara/Renderer/RenderSurface.cpp | 2 +- src/Nazara/Renderer/RendererImpl.cpp | 2 +- src/Nazara/Renderer/RendererWindowImpl.cpp | 2 +- src/Nazara/Renderer/ShaderBinding.cpp | 2 +- src/Nazara/Renderer/ShaderStageImpl.cpp | 2 +- src/Nazara/Renderer/Texture.cpp | 2 +- src/Nazara/Renderer/TextureSampler.cpp | 2 +- src/Nazara/Utility/FieldOffsets.cpp | 2 +- src/Nazara/Utility/Formats/DDSConstants.hpp | 2 +- src/Nazara/VulkanRenderer/VkRenderWindow.cpp | 2 +- 40 files changed, 43 insertions(+), 43 deletions(-) diff --git a/include/Nazara/Math/Ray.inl b/include/Nazara/Math/Ray.inl index f2248baca..1f98a17ad 100644 --- a/include/Nazara/Math/Ray.inl +++ b/include/Nazara/Math/Ray.inl @@ -400,7 +400,7 @@ namespace Nz if (squaredDistance > squaredRadius) return false; // if the ray is further than the radius - // Calcul des points d'intersection si besoin + // Compute intersections points if required if (closestHit || furthestHit) { T deltaLambda = std::sqrt(squaredRadius - squaredDistance); diff --git a/include/Nazara/Utility/FieldOffsets.hpp b/include/Nazara/Utility/FieldOffsets.hpp index 7cdeb83a9..266f82cd7 100644 --- a/include/Nazara/Utility/FieldOffsets.hpp +++ b/include/Nazara/Utility/FieldOffsets.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/Utility/FieldOffsets.inl b/include/Nazara/Utility/FieldOffsets.inl index 899e6a241..5ca15e88f 100644 --- a/include/Nazara/Utility/FieldOffsets.inl +++ b/include/Nazara/Utility/FieldOffsets.inl @@ -1,4 +1,4 @@ -// Copyright (C) 2019 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/Config.hpp b/include/Nazara/VulkanRenderer/Config.hpp index 12d6c6663..75a7dc4ca 100644 --- a/include/Nazara/VulkanRenderer/Config.hpp +++ b/include/Nazara/VulkanRenderer/Config.hpp @@ -50,4 +50,4 @@ #define NAZARA_VULKANRENDERER_API #endif -#endif // NAZARA_CONFIG_MODULENAME_HPP +#endif // NAZARA_CONFIG_VULKANRENDERER_HPP diff --git a/include/Nazara/VulkanRenderer/ConfigCheck.hpp b/include/Nazara/VulkanRenderer/ConfigCheck.hpp index 2944ecfb9..fb0f78baa 100644 --- a/include/Nazara/VulkanRenderer/ConfigCheck.hpp +++ b/include/Nazara/VulkanRenderer/ConfigCheck.hpp @@ -4,8 +4,8 @@ #pragma once -#ifndef NAZARA_CONFIG_CHECK_VULKANE_HPP -#define NAZARA_CONFIG_CHECK_VULKANE_HPP +#ifndef NAZARA_CONFIG_CHECK_VULKANRENDERER_HPP +#define NAZARA_CONFIG_CHECK_VULKANRENDERER_HPP /// Ce fichier sert à vérifier la valeur des constantes du fichier Config.hpp @@ -15,8 +15,8 @@ // On force la valeur de MANAGE_MEMORY en mode debug #if defined(NAZARA_DEBUG) && !NAZARA_VULKANRENDERER_MANAGE_MEMORY - #undef NAZARA_MODULENAME_MANAGE_MEMORY - #define NAZARA_MODULENAME_MANAGE_MEMORY 0 + #undef NAZARA_VULKANRENDERER_MANAGE_MEMORY + #define NAZARA_VULKANRENDERER_MANAGE_MEMORY 0 #endif #endif // NAZARA_CONFIG_CHECK_VULKANRENDERER_HPP diff --git a/include/Nazara/VulkanRenderer/Debug.hpp b/include/Nazara/VulkanRenderer/Debug.hpp index 1ef1a1f9a..236950793 100644 --- a/include/Nazara/VulkanRenderer/Debug.hpp +++ b/include/Nazara/VulkanRenderer/Debug.hpp @@ -3,6 +3,6 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#if NAZARA_MODULENAME_MANAGE_MEMORY +#if NAZARA_VULKANRENDERER_MANAGE_MEMORY #include #endif diff --git a/include/Nazara/VulkanRenderer/DebugOff.hpp b/include/Nazara/VulkanRenderer/DebugOff.hpp index f80fde373..bf3197f67 100644 --- a/include/Nazara/VulkanRenderer/DebugOff.hpp +++ b/include/Nazara/VulkanRenderer/DebugOff.hpp @@ -3,7 +3,7 @@ // 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 +#if NAZARA_VULKANRENDERER_MANAGE_MEMORY #undef delete #undef new #endif diff --git a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp index 48c796288..3df9c1f66 100644 --- a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp +++ b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/VulkanBuffer.hpp b/include/Nazara/VulkanRenderer/VulkanBuffer.hpp index cbee94283..ffdf39846 100644 --- a/include/Nazara/VulkanRenderer/VulkanBuffer.hpp +++ b/include/Nazara/VulkanRenderer/VulkanBuffer.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/VulkanDevice.hpp b/include/Nazara/VulkanRenderer/VulkanDevice.hpp index 658a81401..88711ba57 100644 --- a/include/Nazara/VulkanRenderer/VulkanDevice.hpp +++ b/include/Nazara/VulkanRenderer/VulkanDevice.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/VulkanShaderStage.hpp b/include/Nazara/VulkanRenderer/VulkanShaderStage.hpp index 5809ba4e7..f6505b1cb 100644 --- a/include/Nazara/VulkanRenderer/VulkanShaderStage.hpp +++ b/include/Nazara/VulkanRenderer/VulkanShaderStage.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/include/Nazara/VulkanRenderer/VulkanSurface.hpp b/include/Nazara/VulkanRenderer/VulkanSurface.hpp index 147753c65..4c3e4e416 100644 --- a/include/Nazara/VulkanRenderer/VulkanSurface.hpp +++ b/include/Nazara/VulkanRenderer/VulkanSurface.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Vulkan Renderer" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp b/src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp index 317c8d0ff..6ddb9f5bf 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Platform/SDL2/CursorImpl.cpp b/src/Nazara/Platform/SDL2/CursorImpl.cpp index 60ddd4bd4..5c963ab99 100644 --- a/src/Nazara/Platform/SDL2/CursorImpl.cpp +++ b/src/Nazara/Platform/SDL2/CursorImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Platform/SDL2/IconImpl.cpp b/src/Nazara/Platform/SDL2/IconImpl.cpp index 50d1dff42..1ef8c4fd8 100644 --- a/src/Nazara/Platform/SDL2/IconImpl.cpp +++ b/src/Nazara/Platform/SDL2/IconImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Platform/SDL2/InputImpl.cpp b/src/Nazara/Platform/SDL2/InputImpl.cpp index 1b609e71c..933d40e60 100644 --- a/src/Nazara/Platform/SDL2/InputImpl.cpp +++ b/src/Nazara/Platform/SDL2/InputImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Platform/SDL2/SDLHelper.cpp b/src/Nazara/Platform/SDL2/SDLHelper.cpp index 447e21c69..41f681e94 100644 --- a/src/Nazara/Platform/SDL2/SDLHelper.cpp +++ b/src/Nazara/Platform/SDL2/SDLHelper.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Platform/SDL2/SDLHelper.hpp b/src/Nazara/Platform/SDL2/SDLHelper.hpp index 700e111a8..ca39f5b1c 100644 --- a/src/Nazara/Platform/SDL2/SDLHelper.hpp +++ b/src/Nazara/Platform/SDL2/SDLHelper.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Platform/SDL2/VideoModeImpl.cpp b/src/Nazara/Platform/SDL2/VideoModeImpl.cpp index a9661c572..621444627 100644 --- a/src/Nazara/Platform/SDL2/VideoModeImpl.cpp +++ b/src/Nazara/Platform/SDL2/VideoModeImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Platform/SDL2/WindowImpl.cpp b/src/Nazara/Platform/SDL2/WindowImpl.cpp index 20cd731df..6ca5857d3 100644 --- a/src/Nazara/Platform/SDL2/WindowImpl.cpp +++ b/src/Nazara/Platform/SDL2/WindowImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2017 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Platform module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/CommandBuffer.cpp b/src/Nazara/Renderer/CommandBuffer.cpp index c93ff6fee..fe876c0c6 100644 --- a/src/Nazara/Renderer/CommandBuffer.cpp +++ b/src/Nazara/Renderer/CommandBuffer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/CommandBufferBuilder.cpp b/src/Nazara/Renderer/CommandBufferBuilder.cpp index e45605d48..0d7d16410 100644 --- a/src/Nazara/Renderer/CommandBufferBuilder.cpp +++ b/src/Nazara/Renderer/CommandBufferBuilder.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/CommandPool.cpp b/src/Nazara/Renderer/CommandPool.cpp index 6d0b412e4..342210e77 100644 --- a/src/Nazara/Renderer/CommandPool.cpp +++ b/src/Nazara/Renderer/CommandPool.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/Framebuffer.cpp b/src/Nazara/Renderer/Framebuffer.cpp index 4fff69eb4..220215d83 100644 --- a/src/Nazara/Renderer/Framebuffer.cpp +++ b/src/Nazara/Renderer/Framebuffer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/RenderBuffer.cpp b/src/Nazara/Renderer/RenderBuffer.cpp index 4526d79f3..96f4bf05d 100644 --- a/src/Nazara/Renderer/RenderBuffer.cpp +++ b/src/Nazara/Renderer/RenderBuffer.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/RenderDevice.cpp b/src/Nazara/Renderer/RenderDevice.cpp index 2ef01974a..a4d377db6 100644 --- a/src/Nazara/Renderer/RenderDevice.cpp +++ b/src/Nazara/Renderer/RenderDevice.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/RenderImage.cpp b/src/Nazara/Renderer/RenderImage.cpp index 9724386e2..68ba064c7 100644 --- a/src/Nazara/Renderer/RenderImage.cpp +++ b/src/Nazara/Renderer/RenderImage.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/RenderPass.cpp b/src/Nazara/Renderer/RenderPass.cpp index b6b870c72..aeae04fdb 100644 --- a/src/Nazara/Renderer/RenderPass.cpp +++ b/src/Nazara/Renderer/RenderPass.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/RenderPipeline.cpp b/src/Nazara/Renderer/RenderPipeline.cpp index c5faed12b..e8b585368 100644 --- a/src/Nazara/Renderer/RenderPipeline.cpp +++ b/src/Nazara/Renderer/RenderPipeline.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/RenderPipelineLayout.cpp b/src/Nazara/Renderer/RenderPipelineLayout.cpp index ec26fad08..b9a357448 100644 --- a/src/Nazara/Renderer/RenderPipelineLayout.cpp +++ b/src/Nazara/Renderer/RenderPipelineLayout.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/RenderSurface.cpp b/src/Nazara/Renderer/RenderSurface.cpp index e48c69f6c..6fe2c4026 100644 --- a/src/Nazara/Renderer/RenderSurface.cpp +++ b/src/Nazara/Renderer/RenderSurface.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/RendererImpl.cpp b/src/Nazara/Renderer/RendererImpl.cpp index f674e1098..9d16ff2fb 100644 --- a/src/Nazara/Renderer/RendererImpl.cpp +++ b/src/Nazara/Renderer/RendererImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/RendererWindowImpl.cpp b/src/Nazara/Renderer/RendererWindowImpl.cpp index b1a2b946f..c677d8e34 100644 --- a/src/Nazara/Renderer/RendererWindowImpl.cpp +++ b/src/Nazara/Renderer/RendererWindowImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/ShaderBinding.cpp b/src/Nazara/Renderer/ShaderBinding.cpp index 240d848c6..ee78fd716 100644 --- a/src/Nazara/Renderer/ShaderBinding.cpp +++ b/src/Nazara/Renderer/ShaderBinding.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/ShaderStageImpl.cpp b/src/Nazara/Renderer/ShaderStageImpl.cpp index 62ae7a7ed..dd3e48a63 100644 --- a/src/Nazara/Renderer/ShaderStageImpl.cpp +++ b/src/Nazara/Renderer/ShaderStageImpl.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/Texture.cpp b/src/Nazara/Renderer/Texture.cpp index 6a3e4b1fb..78e72e65c 100644 --- a/src/Nazara/Renderer/Texture.cpp +++ b/src/Nazara/Renderer/Texture.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Renderer/TextureSampler.cpp b/src/Nazara/Renderer/TextureSampler.cpp index e8571e775..f39f2dc73 100644 --- a/src/Nazara/Renderer/TextureSampler.cpp +++ b/src/Nazara/Renderer/TextureSampler.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/FieldOffsets.cpp b/src/Nazara/Utility/FieldOffsets.cpp index 76cb50e71..5e9f229bb 100644 --- a/src/Nazara/Utility/FieldOffsets.cpp +++ b/src/Nazara/Utility/FieldOffsets.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/Utility/Formats/DDSConstants.hpp b/src/Nazara/Utility/Formats/DDSConstants.hpp index 7233e7497..81be1798e 100644 --- a/src/Nazara/Utility/Formats/DDSConstants.hpp +++ b/src/Nazara/Utility/Formats/DDSConstants.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2009 Cruden BV - 2014 Jérôme Leclercq +// Copyright (C) 2009 Cruden BV - 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp diff --git a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp index 6f53df0c1..bfba96bc1 100644 --- a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp +++ b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2015 Jérôme Leclercq +// Copyright (C) 2020 Jérôme Leclercq // This file is part of the "Nazara Engine - Renderer module" // For conditions of distribution and use, see copyright notice in Config.hpp From 608b80981d7667ea464311d752c52c18306e5dfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Tue, 11 Aug 2020 00:13:00 +0200 Subject: [PATCH 298/316] Fix OpenGL & Vulkan renderers --- build/scripts/tools/openglrenderer.lua | 1 + build/scripts/tools/vulkanrenderer.lua | 1 + src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp | 6 +++--- src/Nazara/VulkanRenderer/VulkanShaderStage.cpp | 6 +++--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/build/scripts/tools/openglrenderer.lua b/build/scripts/tools/openglrenderer.lua index 32392739c..48b198327 100644 --- a/build/scripts/tools/openglrenderer.lua +++ b/build/scripts/tools/openglrenderer.lua @@ -27,6 +27,7 @@ TOOL.Files = { TOOL.Libraries = { "NazaraCore", "NazaraRenderer", + "NazaraShader", "NazaraUtility" } diff --git a/build/scripts/tools/vulkanrenderer.lua b/build/scripts/tools/vulkanrenderer.lua index 6e6a5bed2..4e7f2be10 100644 --- a/build/scripts/tools/vulkanrenderer.lua +++ b/build/scripts/tools/vulkanrenderer.lua @@ -28,6 +28,7 @@ TOOL.Files = { TOOL.Libraries = { "NazaraCore", "NazaraRenderer", + "NazaraShader", "NazaraUtility" } diff --git a/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp b/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp index 7f6e92a34..068ef9634 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLShaderStage.cpp @@ -6,9 +6,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include diff --git a/src/Nazara/VulkanRenderer/VulkanShaderStage.cpp b/src/Nazara/VulkanRenderer/VulkanShaderStage.cpp index c0b510dd8..9459ccfe3 100644 --- a/src/Nazara/VulkanRenderer/VulkanShaderStage.cpp +++ b/src/Nazara/VulkanRenderer/VulkanShaderStage.cpp @@ -3,9 +3,9 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include -#include -#include +#include +#include +#include #include namespace Nz From 581a5344e6885c2e73b32e38632e25c2e4ca70b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Tue, 11 Aug 2020 00:15:34 +0200 Subject: [PATCH 299/316] OpenGLRenderer: Add wglSwapIntervalEXT --- include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLFunctions.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLFunctions.hpp b/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLFunctions.hpp index d21480e96..655373ed8 100644 --- a/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLFunctions.hpp +++ b/include/Nazara/OpenGLRenderer/Wrapper/Win32/WGLFunctions.hpp @@ -38,6 +38,10 @@ extBegin(WGL_EXT_extensions_string) \ extFunc(wglGetExtensionsStringEXT, PFNWGLGETEXTENSIONSSTRINGEXTPROC) \ extEnd() \ + \ + extBegin(WGL_EXT_swap_control) \ + extFunc(wglSwapIntervalEXT, PFNWGLSWAPINTERVALEXTPROC) \ + extEnd() #define NAZARA_OPENGLRENDERER_FOREACH_GDI32_FUNC(func) \ func(ChoosePixelFormat, PFNCHOOSEPIXELFORMATPROC) \ From 73e88a2573118cb1863b86800b24eb75f0a77665 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Mon, 17 Aug 2020 23:59:08 +0200 Subject: [PATCH 300/316] Add Spir-V header/source generator --- build/scripts/actions/spirv.lua | 223 + include/Nazara/Shader/SpirvData.hpp | 1382 +++ src/Nazara/Shader/SpirvData.cpp | 11862 ++++++++++++++++++++++++++ 3 files changed, 13467 insertions(+) create mode 100644 build/scripts/actions/spirv.lua create mode 100644 include/Nazara/Shader/SpirvData.hpp create mode 100644 src/Nazara/Shader/SpirvData.cpp diff --git a/build/scripts/actions/spirv.lua b/build/scripts/actions/spirv.lua new file mode 100644 index 000000000..b47c81fa9 --- /dev/null +++ b/build/scripts/actions/spirv.lua @@ -0,0 +1,223 @@ +ACTION.Name = "UpdateSpirV" +ACTION.Description = "Download and parse the SpirV grammar and generate a .cpp file for it" + +local spirvGrammarURI = "https://raw.githubusercontent.com/KhronosGroup/SPIRV-Headers/master/include/spirv/unified1/spirv.core.grammar.json" + +ACTION.Function = function() + io.write("Downloading Spir-V grammar... ") + local content, resultStr, resultCode = http.get(spirvGrammarURI, { + headers = { "From: Premake", "Referer: Premake" } + }) + + if (resultCode ~= 200) then + error("Failed to download SpirV grammar: " .. resultStr) + end + + print("Done") + + local result, err = json.decode(content) + assert(result, err) + + local instructions = {} + local instructionById = {} + for _, instruction in pairs(result.instructions) do + local duplicateId = instructionById[instruction.opcode] + if (duplicateId == nil) then + table.insert(instructions, instruction) + instructionById[instruction.opcode] = #instructions + else + instructions[duplicateId] = instruction + end + end + + local operands = {} + local operandByInstruction = {} + for _, instruction in pairs(instructions) do + if (instruction.operands) then + local firstId = #operands + local operandCount = #instruction.operands + for _, operand in pairs(instruction.operands) do + table.insert(operands, operand) + end + + operandByInstruction[instruction.opcode] = { firstId = firstId, count = operandCount } + end + end + + local headerFile = io.open("../include/Nazara/Shader/SpirvData.hpp", "w+") + assert(headerFile, "failed to open Spir-V header") + + headerFile:write([[ +// Copyright (C) ]] .. os.date("%Y") .. [[ Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp" + +// This file was generated automatically, please do not edit + +#pragma once + +#ifndef NAZARA_SPIRVDATA_HPP +#define NAZARA_SPIRVDATA_HPP + +#include +#include + +namespace Nz +{ +]]) + + -- SpirV operations + headerFile:write([[ + enum class SpirvOp + { +]]) + + for _, instruction in pairs(result.instructions) do + headerFile:write("\t\t" .. instruction.opname .. " = " .. instruction.opcode .. ",\n") + end + +headerFile:write([[ + }; + +]]) + + -- SpirV operands + headerFile:write([[ + enum class SpirvOperandKind + { +]]) + + for _, operand in pairs(result.operand_kinds) do + headerFile:write("\t\t" .. operand.kind .. ",\n") + end + + headerFile:write([[ + }; + +]]) + + -- SpirV enums + for _, operand in pairs(result.operand_kinds) do + if (operand.category == "ValueEnum") then + headerFile:write([[ + enum class Spirv]] .. operand.kind .. [[ + + { +]]) + + for _, enumerant in pairs(operand.enumerants) do + local eName = enumerant.enumerant:match("^%d") and operand.kind .. enumerant.enumerant or enumerant.enumerant + headerFile:write([[ + ]] .. eName .. [[ = ]] .. enumerant.value .. [[, +]]) + end + + headerFile:write([[ + }; + +]]) + end + end + + -- Struct + headerFile:write([[ + struct SpirvInstruction + { + struct Operand + { + SpirvOperandKind kind; + const char* name; + }; + + SpirvOp op; + const char* name; + const Operand* operands; + std::size_t minOperandCount; + }; + +]]) + + -- Functions signatures + headerFile:write([[ + NAZARA_SHADER_API const SpirvInstruction* GetInstructionData(UInt16 op); +]]) + +headerFile:write([[ +} + +#endif +]]) + + local sourceFile = io.open("../src/Nazara/Shader/SpirvData.cpp", "w+") + assert(sourceFile, "failed to open Spir-V source") + + sourceFile:write([[ +// Copyright (C) ]] .. os.date("%Y") .. [[ Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp" + +// This file was generated automatically, please do not edit + +#include +#include +#include +#include + +namespace Nz +{ + static constexpr std::array s_operands = { + { +]]) + for _, operand in pairs(operands) do + sourceFile:write([[ + { + SpirvOperandKind::]] .. operand.kind .. [[, + R"(]] .. (operand.name or operand.kind) .. [[)" + }, +]]) + end + + sourceFile:write([[ + } + }; + + static std::array s_instructions = { + { +]]) + + for _, instruction in pairs(instructions) do + local opByInstruction = operandByInstruction[instruction.opcode] + + sourceFile:write([[ + { + SpirvOp::]] .. instruction.opname .. [[, + R"(]] .. instruction.opname .. [[)", + ]] .. (opByInstruction and "&s_operands[" .. opByInstruction.firstId .. "]" or "nullptr") .. [[, + ]] .. (opByInstruction and opByInstruction.count or "0") .. [[, + }, +]]) + end + + sourceFile:write([[ + } + }; + +]]) + + -- Operand to string + sourceFile:write([[ + const SpirvInstruction* GetInstructionData(UInt16 op) + { + auto it = std::lower_bound(std::begin(s_instructions), std::end(s_instructions), op, [](const SpirvInstruction& inst, UInt16 op) { return UInt16(inst.op) < op; }); + if (it != std::end(s_instructions) && UInt16(it->op) == op) + return &*it; + else + return nullptr; + } +]]) + + sourceFile:write([[ +} +]]) + +end \ No newline at end of file diff --git a/include/Nazara/Shader/SpirvData.hpp b/include/Nazara/Shader/SpirvData.hpp new file mode 100644 index 000000000..eccc122ad --- /dev/null +++ b/include/Nazara/Shader/SpirvData.hpp @@ -0,0 +1,1382 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp" + +// This file was generated automatically, please do not edit + +#pragma once + +#ifndef NAZARA_SPIRVDATA_HPP +#define NAZARA_SPIRVDATA_HPP + +#include +#include + +namespace Nz +{ + enum class SpirvOp + { + OpNop = 0, + OpUndef = 1, + OpSourceContinued = 2, + OpSource = 3, + OpSourceExtension = 4, + OpName = 5, + OpMemberName = 6, + OpString = 7, + OpLine = 8, + OpExtension = 10, + OpExtInstImport = 11, + OpExtInst = 12, + OpMemoryModel = 14, + OpEntryPoint = 15, + OpExecutionMode = 16, + OpCapability = 17, + OpTypeVoid = 19, + OpTypeBool = 20, + OpTypeInt = 21, + OpTypeFloat = 22, + OpTypeVector = 23, + OpTypeMatrix = 24, + OpTypeImage = 25, + OpTypeSampler = 26, + OpTypeSampledImage = 27, + OpTypeArray = 28, + OpTypeRuntimeArray = 29, + OpTypeStruct = 30, + OpTypeOpaque = 31, + OpTypePointer = 32, + OpTypeFunction = 33, + OpTypeEvent = 34, + OpTypeDeviceEvent = 35, + OpTypeReserveId = 36, + OpTypeQueue = 37, + OpTypePipe = 38, + OpTypeForwardPointer = 39, + OpConstantTrue = 41, + OpConstantFalse = 42, + OpConstant = 43, + OpConstantComposite = 44, + OpConstantSampler = 45, + OpConstantNull = 46, + OpSpecConstantTrue = 48, + OpSpecConstantFalse = 49, + OpSpecConstant = 50, + OpSpecConstantComposite = 51, + OpSpecConstantOp = 52, + OpFunction = 54, + OpFunctionParameter = 55, + OpFunctionEnd = 56, + OpFunctionCall = 57, + OpVariable = 59, + OpImageTexelPointer = 60, + OpLoad = 61, + OpStore = 62, + OpCopyMemory = 63, + OpCopyMemorySized = 64, + OpAccessChain = 65, + OpInBoundsAccessChain = 66, + OpPtrAccessChain = 67, + OpArrayLength = 68, + OpGenericPtrMemSemantics = 69, + OpInBoundsPtrAccessChain = 70, + OpDecorate = 71, + OpMemberDecorate = 72, + OpDecorationGroup = 73, + OpGroupDecorate = 74, + OpGroupMemberDecorate = 75, + OpVectorExtractDynamic = 77, + OpVectorInsertDynamic = 78, + OpVectorShuffle = 79, + OpCompositeConstruct = 80, + OpCompositeExtract = 81, + OpCompositeInsert = 82, + OpCopyObject = 83, + OpTranspose = 84, + OpSampledImage = 86, + OpImageSampleImplicitLod = 87, + OpImageSampleExplicitLod = 88, + OpImageSampleDrefImplicitLod = 89, + OpImageSampleDrefExplicitLod = 90, + OpImageSampleProjImplicitLod = 91, + OpImageSampleProjExplicitLod = 92, + OpImageSampleProjDrefImplicitLod = 93, + OpImageSampleProjDrefExplicitLod = 94, + OpImageFetch = 95, + OpImageGather = 96, + OpImageDrefGather = 97, + OpImageRead = 98, + OpImageWrite = 99, + OpImage = 100, + OpImageQueryFormat = 101, + OpImageQueryOrder = 102, + OpImageQuerySizeLod = 103, + OpImageQuerySize = 104, + OpImageQueryLod = 105, + OpImageQueryLevels = 106, + OpImageQuerySamples = 107, + OpConvertFToU = 109, + OpConvertFToS = 110, + OpConvertSToF = 111, + OpConvertUToF = 112, + OpUConvert = 113, + OpSConvert = 114, + OpFConvert = 115, + OpQuantizeToF16 = 116, + OpConvertPtrToU = 117, + OpSatConvertSToU = 118, + OpSatConvertUToS = 119, + OpConvertUToPtr = 120, + OpPtrCastToGeneric = 121, + OpGenericCastToPtr = 122, + OpGenericCastToPtrExplicit = 123, + OpBitcast = 124, + OpSNegate = 126, + OpFNegate = 127, + OpIAdd = 128, + OpFAdd = 129, + OpISub = 130, + OpFSub = 131, + OpIMul = 132, + OpFMul = 133, + OpUDiv = 134, + OpSDiv = 135, + OpFDiv = 136, + OpUMod = 137, + OpSRem = 138, + OpSMod = 139, + OpFRem = 140, + OpFMod = 141, + OpVectorTimesScalar = 142, + OpMatrixTimesScalar = 143, + OpVectorTimesMatrix = 144, + OpMatrixTimesVector = 145, + OpMatrixTimesMatrix = 146, + OpOuterProduct = 147, + OpDot = 148, + OpIAddCarry = 149, + OpISubBorrow = 150, + OpUMulExtended = 151, + OpSMulExtended = 152, + OpAny = 154, + OpAll = 155, + OpIsNan = 156, + OpIsInf = 157, + OpIsFinite = 158, + OpIsNormal = 159, + OpSignBitSet = 160, + OpLessOrGreater = 161, + OpOrdered = 162, + OpUnordered = 163, + OpLogicalEqual = 164, + OpLogicalNotEqual = 165, + OpLogicalOr = 166, + OpLogicalAnd = 167, + OpLogicalNot = 168, + OpSelect = 169, + OpIEqual = 170, + OpINotEqual = 171, + OpUGreaterThan = 172, + OpSGreaterThan = 173, + OpUGreaterThanEqual = 174, + OpSGreaterThanEqual = 175, + OpULessThan = 176, + OpSLessThan = 177, + OpULessThanEqual = 178, + OpSLessThanEqual = 179, + OpFOrdEqual = 180, + OpFUnordEqual = 181, + OpFOrdNotEqual = 182, + OpFUnordNotEqual = 183, + OpFOrdLessThan = 184, + OpFUnordLessThan = 185, + OpFOrdGreaterThan = 186, + OpFUnordGreaterThan = 187, + OpFOrdLessThanEqual = 188, + OpFUnordLessThanEqual = 189, + OpFOrdGreaterThanEqual = 190, + OpFUnordGreaterThanEqual = 191, + OpShiftRightLogical = 194, + OpShiftRightArithmetic = 195, + OpShiftLeftLogical = 196, + OpBitwiseOr = 197, + OpBitwiseXor = 198, + OpBitwiseAnd = 199, + OpNot = 200, + OpBitFieldInsert = 201, + OpBitFieldSExtract = 202, + OpBitFieldUExtract = 203, + OpBitReverse = 204, + OpBitCount = 205, + OpDPdx = 207, + OpDPdy = 208, + OpFwidth = 209, + OpDPdxFine = 210, + OpDPdyFine = 211, + OpFwidthFine = 212, + OpDPdxCoarse = 213, + OpDPdyCoarse = 214, + OpFwidthCoarse = 215, + OpEmitVertex = 218, + OpEndPrimitive = 219, + OpEmitStreamVertex = 220, + OpEndStreamPrimitive = 221, + OpControlBarrier = 224, + OpMemoryBarrier = 225, + OpAtomicLoad = 227, + OpAtomicStore = 228, + OpAtomicExchange = 229, + OpAtomicCompareExchange = 230, + OpAtomicCompareExchangeWeak = 231, + OpAtomicIIncrement = 232, + OpAtomicIDecrement = 233, + OpAtomicIAdd = 234, + OpAtomicISub = 235, + OpAtomicSMin = 236, + OpAtomicUMin = 237, + OpAtomicSMax = 238, + OpAtomicUMax = 239, + OpAtomicAnd = 240, + OpAtomicOr = 241, + OpAtomicXor = 242, + OpPhi = 245, + OpLoopMerge = 246, + OpSelectionMerge = 247, + OpLabel = 248, + OpBranch = 249, + OpBranchConditional = 250, + OpSwitch = 251, + OpKill = 252, + OpReturn = 253, + OpReturnValue = 254, + OpUnreachable = 255, + OpLifetimeStart = 256, + OpLifetimeStop = 257, + OpGroupAsyncCopy = 259, + OpGroupWaitEvents = 260, + OpGroupAll = 261, + OpGroupAny = 262, + OpGroupBroadcast = 263, + OpGroupIAdd = 264, + OpGroupFAdd = 265, + OpGroupFMin = 266, + OpGroupUMin = 267, + OpGroupSMin = 268, + OpGroupFMax = 269, + OpGroupUMax = 270, + OpGroupSMax = 271, + OpReadPipe = 274, + OpWritePipe = 275, + OpReservedReadPipe = 276, + OpReservedWritePipe = 277, + OpReserveReadPipePackets = 278, + OpReserveWritePipePackets = 279, + OpCommitReadPipe = 280, + OpCommitWritePipe = 281, + OpIsValidReserveId = 282, + OpGetNumPipePackets = 283, + OpGetMaxPipePackets = 284, + OpGroupReserveReadPipePackets = 285, + OpGroupReserveWritePipePackets = 286, + OpGroupCommitReadPipe = 287, + OpGroupCommitWritePipe = 288, + OpEnqueueMarker = 291, + OpEnqueueKernel = 292, + OpGetKernelNDrangeSubGroupCount = 293, + OpGetKernelNDrangeMaxSubGroupSize = 294, + OpGetKernelWorkGroupSize = 295, + OpGetKernelPreferredWorkGroupSizeMultiple = 296, + OpRetainEvent = 297, + OpReleaseEvent = 298, + OpCreateUserEvent = 299, + OpIsValidEvent = 300, + OpSetUserEventStatus = 301, + OpCaptureEventProfilingInfo = 302, + OpGetDefaultQueue = 303, + OpBuildNDRange = 304, + OpImageSparseSampleImplicitLod = 305, + OpImageSparseSampleExplicitLod = 306, + OpImageSparseSampleDrefImplicitLod = 307, + OpImageSparseSampleDrefExplicitLod = 308, + OpImageSparseSampleProjImplicitLod = 309, + OpImageSparseSampleProjExplicitLod = 310, + OpImageSparseSampleProjDrefImplicitLod = 311, + OpImageSparseSampleProjDrefExplicitLod = 312, + OpImageSparseFetch = 313, + OpImageSparseGather = 314, + OpImageSparseDrefGather = 315, + OpImageSparseTexelsResident = 316, + OpNoLine = 317, + OpAtomicFlagTestAndSet = 318, + OpAtomicFlagClear = 319, + OpImageSparseRead = 320, + OpSizeOf = 321, + OpTypePipeStorage = 322, + OpConstantPipeStorage = 323, + OpCreatePipeFromPipeStorage = 324, + OpGetKernelLocalSizeForSubgroupCount = 325, + OpGetKernelMaxNumSubgroups = 326, + OpTypeNamedBarrier = 327, + OpNamedBarrierInitialize = 328, + OpMemoryNamedBarrier = 329, + OpModuleProcessed = 330, + OpExecutionModeId = 331, + OpDecorateId = 332, + OpGroupNonUniformElect = 333, + OpGroupNonUniformAll = 334, + OpGroupNonUniformAny = 335, + OpGroupNonUniformAllEqual = 336, + OpGroupNonUniformBroadcast = 337, + OpGroupNonUniformBroadcastFirst = 338, + OpGroupNonUniformBallot = 339, + OpGroupNonUniformInverseBallot = 340, + OpGroupNonUniformBallotBitExtract = 341, + OpGroupNonUniformBallotBitCount = 342, + OpGroupNonUniformBallotFindLSB = 343, + OpGroupNonUniformBallotFindMSB = 344, + OpGroupNonUniformShuffle = 345, + OpGroupNonUniformShuffleXor = 346, + OpGroupNonUniformShuffleUp = 347, + OpGroupNonUniformShuffleDown = 348, + OpGroupNonUniformIAdd = 349, + OpGroupNonUniformFAdd = 350, + OpGroupNonUniformIMul = 351, + OpGroupNonUniformFMul = 352, + OpGroupNonUniformSMin = 353, + OpGroupNonUniformUMin = 354, + OpGroupNonUniformFMin = 355, + OpGroupNonUniformSMax = 356, + OpGroupNonUniformUMax = 357, + OpGroupNonUniformFMax = 358, + OpGroupNonUniformBitwiseAnd = 359, + OpGroupNonUniformBitwiseOr = 360, + OpGroupNonUniformBitwiseXor = 361, + OpGroupNonUniformLogicalAnd = 362, + OpGroupNonUniformLogicalOr = 363, + OpGroupNonUniformLogicalXor = 364, + OpGroupNonUniformQuadBroadcast = 365, + OpGroupNonUniformQuadSwap = 366, + OpCopyLogical = 400, + OpPtrEqual = 401, + OpPtrNotEqual = 402, + OpPtrDiff = 403, + OpTerminateInvocation = 4416, + OpSubgroupBallotKHR = 4421, + OpSubgroupFirstInvocationKHR = 4422, + OpSubgroupAllKHR = 4428, + OpSubgroupAnyKHR = 4429, + OpSubgroupAllEqualKHR = 4430, + OpSubgroupReadInvocationKHR = 4432, + OpTypeRayQueryProvisionalKHR = 4472, + OpRayQueryInitializeKHR = 4473, + OpRayQueryTerminateKHR = 4474, + OpRayQueryGenerateIntersectionKHR = 4475, + OpRayQueryConfirmIntersectionKHR = 4476, + OpRayQueryProceedKHR = 4477, + OpRayQueryGetIntersectionTypeKHR = 4479, + OpGroupIAddNonUniformAMD = 5000, + OpGroupFAddNonUniformAMD = 5001, + OpGroupFMinNonUniformAMD = 5002, + OpGroupUMinNonUniformAMD = 5003, + OpGroupSMinNonUniformAMD = 5004, + OpGroupFMaxNonUniformAMD = 5005, + OpGroupUMaxNonUniformAMD = 5006, + OpGroupSMaxNonUniformAMD = 5007, + OpFragmentMaskFetchAMD = 5011, + OpFragmentFetchAMD = 5012, + OpReadClockKHR = 5056, + OpImageSampleFootprintNV = 5283, + OpGroupNonUniformPartitionNV = 5296, + OpWritePackedPrimitiveIndices4x8NV = 5299, + OpReportIntersectionNV = 5334, + OpReportIntersectionKHR = 5334, + OpIgnoreIntersectionNV = 5335, + OpIgnoreIntersectionKHR = 5335, + OpTerminateRayNV = 5336, + OpTerminateRayKHR = 5336, + OpTraceNV = 5337, + OpTraceRayKHR = 5337, + OpTypeAccelerationStructureNV = 5341, + OpTypeAccelerationStructureKHR = 5341, + OpExecuteCallableNV = 5344, + OpExecuteCallableKHR = 5344, + OpTypeCooperativeMatrixNV = 5358, + OpCooperativeMatrixLoadNV = 5359, + OpCooperativeMatrixStoreNV = 5360, + OpCooperativeMatrixMulAddNV = 5361, + OpCooperativeMatrixLengthNV = 5362, + OpBeginInvocationInterlockEXT = 5364, + OpEndInvocationInterlockEXT = 5365, + OpDemoteToHelperInvocationEXT = 5380, + OpIsHelperInvocationEXT = 5381, + OpSubgroupShuffleINTEL = 5571, + OpSubgroupShuffleDownINTEL = 5572, + OpSubgroupShuffleUpINTEL = 5573, + OpSubgroupShuffleXorINTEL = 5574, + OpSubgroupBlockReadINTEL = 5575, + OpSubgroupBlockWriteINTEL = 5576, + OpSubgroupImageBlockReadINTEL = 5577, + OpSubgroupImageBlockWriteINTEL = 5578, + OpSubgroupImageMediaBlockReadINTEL = 5580, + OpSubgroupImageMediaBlockWriteINTEL = 5581, + OpUCountLeadingZerosINTEL = 5585, + OpUCountTrailingZerosINTEL = 5586, + OpAbsISubINTEL = 5587, + OpAbsUSubINTEL = 5588, + OpIAddSatINTEL = 5589, + OpUAddSatINTEL = 5590, + OpIAverageINTEL = 5591, + OpUAverageINTEL = 5592, + OpIAverageRoundedINTEL = 5593, + OpUAverageRoundedINTEL = 5594, + OpISubSatINTEL = 5595, + OpUSubSatINTEL = 5596, + OpIMul32x16INTEL = 5597, + OpUMul32x16INTEL = 5598, + OpFunctionPointerINTEL = 5600, + OpFunctionPointerCallINTEL = 5601, + OpDecorateString = 5632, + OpDecorateStringGOOGLE = 5632, + OpMemberDecorateString = 5633, + OpMemberDecorateStringGOOGLE = 5633, + OpVmeImageINTEL = 5699, + OpTypeVmeImageINTEL = 5700, + OpTypeAvcImePayloadINTEL = 5701, + OpTypeAvcRefPayloadINTEL = 5702, + OpTypeAvcSicPayloadINTEL = 5703, + OpTypeAvcMcePayloadINTEL = 5704, + OpTypeAvcMceResultINTEL = 5705, + OpTypeAvcImeResultINTEL = 5706, + OpTypeAvcImeResultSingleReferenceStreamoutINTEL = 5707, + OpTypeAvcImeResultDualReferenceStreamoutINTEL = 5708, + OpTypeAvcImeSingleReferenceStreaminINTEL = 5709, + OpTypeAvcImeDualReferenceStreaminINTEL = 5710, + OpTypeAvcRefResultINTEL = 5711, + OpTypeAvcSicResultINTEL = 5712, + OpSubgroupAvcMceGetDefaultInterBaseMultiReferencePenaltyINTEL = 5713, + OpSubgroupAvcMceSetInterBaseMultiReferencePenaltyINTEL = 5714, + OpSubgroupAvcMceGetDefaultInterShapePenaltyINTEL = 5715, + OpSubgroupAvcMceSetInterShapePenaltyINTEL = 5716, + OpSubgroupAvcMceGetDefaultInterDirectionPenaltyINTEL = 5717, + OpSubgroupAvcMceSetInterDirectionPenaltyINTEL = 5718, + OpSubgroupAvcMceGetDefaultIntraLumaShapePenaltyINTEL = 5719, + OpSubgroupAvcMceGetDefaultInterMotionVectorCostTableINTEL = 5720, + OpSubgroupAvcMceGetDefaultHighPenaltyCostTableINTEL = 5721, + OpSubgroupAvcMceGetDefaultMediumPenaltyCostTableINTEL = 5722, + OpSubgroupAvcMceGetDefaultLowPenaltyCostTableINTEL = 5723, + OpSubgroupAvcMceSetMotionVectorCostFunctionINTEL = 5724, + OpSubgroupAvcMceGetDefaultIntraLumaModePenaltyINTEL = 5725, + OpSubgroupAvcMceGetDefaultNonDcLumaIntraPenaltyINTEL = 5726, + OpSubgroupAvcMceGetDefaultIntraChromaModeBasePenaltyINTEL = 5727, + OpSubgroupAvcMceSetAcOnlyHaarINTEL = 5728, + OpSubgroupAvcMceSetSourceInterlacedFieldPolarityINTEL = 5729, + OpSubgroupAvcMceSetSingleReferenceInterlacedFieldPolarityINTEL = 5730, + OpSubgroupAvcMceSetDualReferenceInterlacedFieldPolaritiesINTEL = 5731, + OpSubgroupAvcMceConvertToImePayloadINTEL = 5732, + OpSubgroupAvcMceConvertToImeResultINTEL = 5733, + OpSubgroupAvcMceConvertToRefPayloadINTEL = 5734, + OpSubgroupAvcMceConvertToRefResultINTEL = 5735, + OpSubgroupAvcMceConvertToSicPayloadINTEL = 5736, + OpSubgroupAvcMceConvertToSicResultINTEL = 5737, + OpSubgroupAvcMceGetMotionVectorsINTEL = 5738, + OpSubgroupAvcMceGetInterDistortionsINTEL = 5739, + OpSubgroupAvcMceGetBestInterDistortionsINTEL = 5740, + OpSubgroupAvcMceGetInterMajorShapeINTEL = 5741, + OpSubgroupAvcMceGetInterMinorShapeINTEL = 5742, + OpSubgroupAvcMceGetInterDirectionsINTEL = 5743, + OpSubgroupAvcMceGetInterMotionVectorCountINTEL = 5744, + OpSubgroupAvcMceGetInterReferenceIdsINTEL = 5745, + OpSubgroupAvcMceGetInterReferenceInterlacedFieldPolaritiesINTEL = 5746, + OpSubgroupAvcImeInitializeINTEL = 5747, + OpSubgroupAvcImeSetSingleReferenceINTEL = 5748, + OpSubgroupAvcImeSetDualReferenceINTEL = 5749, + OpSubgroupAvcImeRefWindowSizeINTEL = 5750, + OpSubgroupAvcImeAdjustRefOffsetINTEL = 5751, + OpSubgroupAvcImeConvertToMcePayloadINTEL = 5752, + OpSubgroupAvcImeSetMaxMotionVectorCountINTEL = 5753, + OpSubgroupAvcImeSetUnidirectionalMixDisableINTEL = 5754, + OpSubgroupAvcImeSetEarlySearchTerminationThresholdINTEL = 5755, + OpSubgroupAvcImeSetWeightedSadINTEL = 5756, + OpSubgroupAvcImeEvaluateWithSingleReferenceINTEL = 5757, + OpSubgroupAvcImeEvaluateWithDualReferenceINTEL = 5758, + OpSubgroupAvcImeEvaluateWithSingleReferenceStreaminINTEL = 5759, + OpSubgroupAvcImeEvaluateWithDualReferenceStreaminINTEL = 5760, + OpSubgroupAvcImeEvaluateWithSingleReferenceStreamoutINTEL = 5761, + OpSubgroupAvcImeEvaluateWithDualReferenceStreamoutINTEL = 5762, + OpSubgroupAvcImeEvaluateWithSingleReferenceStreaminoutINTEL = 5763, + OpSubgroupAvcImeEvaluateWithDualReferenceStreaminoutINTEL = 5764, + OpSubgroupAvcImeConvertToMceResultINTEL = 5765, + OpSubgroupAvcImeGetSingleReferenceStreaminINTEL = 5766, + OpSubgroupAvcImeGetDualReferenceStreaminINTEL = 5767, + OpSubgroupAvcImeStripSingleReferenceStreamoutINTEL = 5768, + OpSubgroupAvcImeStripDualReferenceStreamoutINTEL = 5769, + OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeMotionVectorsINTEL = 5770, + OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeDistortionsINTEL = 5771, + OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeReferenceIdsINTEL = 5772, + OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeMotionVectorsINTEL = 5773, + OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeDistortionsINTEL = 5774, + OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeReferenceIdsINTEL = 5775, + OpSubgroupAvcImeGetBorderReachedINTEL = 5776, + OpSubgroupAvcImeGetTruncatedSearchIndicationINTEL = 5777, + OpSubgroupAvcImeGetUnidirectionalEarlySearchTerminationINTEL = 5778, + OpSubgroupAvcImeGetWeightingPatternMinimumMotionVectorINTEL = 5779, + OpSubgroupAvcImeGetWeightingPatternMinimumDistortionINTEL = 5780, + OpSubgroupAvcFmeInitializeINTEL = 5781, + OpSubgroupAvcBmeInitializeINTEL = 5782, + OpSubgroupAvcRefConvertToMcePayloadINTEL = 5783, + OpSubgroupAvcRefSetBidirectionalMixDisableINTEL = 5784, + OpSubgroupAvcRefSetBilinearFilterEnableINTEL = 5785, + OpSubgroupAvcRefEvaluateWithSingleReferenceINTEL = 5786, + OpSubgroupAvcRefEvaluateWithDualReferenceINTEL = 5787, + OpSubgroupAvcRefEvaluateWithMultiReferenceINTEL = 5788, + OpSubgroupAvcRefEvaluateWithMultiReferenceInterlacedINTEL = 5789, + OpSubgroupAvcRefConvertToMceResultINTEL = 5790, + OpSubgroupAvcSicInitializeINTEL = 5791, + OpSubgroupAvcSicConfigureSkcINTEL = 5792, + OpSubgroupAvcSicConfigureIpeLumaINTEL = 5793, + OpSubgroupAvcSicConfigureIpeLumaChromaINTEL = 5794, + OpSubgroupAvcSicGetMotionVectorMaskINTEL = 5795, + OpSubgroupAvcSicConvertToMcePayloadINTEL = 5796, + OpSubgroupAvcSicSetIntraLumaShapePenaltyINTEL = 5797, + OpSubgroupAvcSicSetIntraLumaModeCostFunctionINTEL = 5798, + OpSubgroupAvcSicSetIntraChromaModeCostFunctionINTEL = 5799, + OpSubgroupAvcSicSetBilinearFilterEnableINTEL = 5800, + OpSubgroupAvcSicSetSkcForwardTransformEnableINTEL = 5801, + OpSubgroupAvcSicSetBlockBasedRawSkipSadINTEL = 5802, + OpSubgroupAvcSicEvaluateIpeINTEL = 5803, + OpSubgroupAvcSicEvaluateWithSingleReferenceINTEL = 5804, + OpSubgroupAvcSicEvaluateWithDualReferenceINTEL = 5805, + OpSubgroupAvcSicEvaluateWithMultiReferenceINTEL = 5806, + OpSubgroupAvcSicEvaluateWithMultiReferenceInterlacedINTEL = 5807, + OpSubgroupAvcSicConvertToMceResultINTEL = 5808, + OpSubgroupAvcSicGetIpeLumaShapeINTEL = 5809, + OpSubgroupAvcSicGetBestIpeLumaDistortionINTEL = 5810, + OpSubgroupAvcSicGetBestIpeChromaDistortionINTEL = 5811, + OpSubgroupAvcSicGetPackedIpeLumaModesINTEL = 5812, + OpSubgroupAvcSicGetIpeChromaModeINTEL = 5813, + OpSubgroupAvcSicGetPackedSkcLumaCountThresholdINTEL = 5814, + OpSubgroupAvcSicGetPackedSkcLumaSumThresholdINTEL = 5815, + OpSubgroupAvcSicGetInterRawSadsINTEL = 5816, + OpLoopControlINTEL = 5887, + OpReadPipeBlockingINTEL = 5946, + OpWritePipeBlockingINTEL = 5947, + OpFPGARegINTEL = 5949, + OpRayQueryGetRayTMinKHR = 6016, + OpRayQueryGetRayFlagsKHR = 6017, + OpRayQueryGetIntersectionTKHR = 6018, + OpRayQueryGetIntersectionInstanceCustomIndexKHR = 6019, + OpRayQueryGetIntersectionInstanceIdKHR = 6020, + OpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR = 6021, + OpRayQueryGetIntersectionGeometryIndexKHR = 6022, + OpRayQueryGetIntersectionPrimitiveIndexKHR = 6023, + OpRayQueryGetIntersectionBarycentricsKHR = 6024, + OpRayQueryGetIntersectionFrontFaceKHR = 6025, + OpRayQueryGetIntersectionCandidateAABBOpaqueKHR = 6026, + OpRayQueryGetIntersectionObjectRayDirectionKHR = 6027, + OpRayQueryGetIntersectionObjectRayOriginKHR = 6028, + OpRayQueryGetWorldRayDirectionKHR = 6029, + OpRayQueryGetWorldRayOriginKHR = 6030, + OpRayQueryGetIntersectionObjectToWorldKHR = 6031, + OpRayQueryGetIntersectionWorldToObjectKHR = 6032, + OpAtomicFAddEXT = 6035, + }; + + enum class SpirvOperandKind + { + ImageOperands, + FPFastMathMode, + SelectionControl, + LoopControl, + FunctionControl, + MemorySemantics, + MemoryAccess, + KernelProfilingInfo, + RayFlags, + SourceLanguage, + ExecutionModel, + AddressingModel, + MemoryModel, + ExecutionMode, + StorageClass, + Dim, + SamplerAddressingMode, + SamplerFilterMode, + ImageFormat, + ImageChannelOrder, + ImageChannelDataType, + FPRoundingMode, + LinkageType, + AccessQualifier, + FunctionParameterAttribute, + Decoration, + BuiltIn, + Scope, + GroupOperation, + KernelEnqueueFlags, + Capability, + RayQueryIntersection, + RayQueryCommittedIntersectionType, + RayQueryCandidateIntersectionType, + IdResultType, + IdResult, + IdMemorySemantics, + IdScope, + IdRef, + LiteralInteger, + LiteralString, + LiteralContextDependentNumber, + LiteralExtInstInteger, + LiteralSpecConstantOpInteger, + PairLiteralIntegerIdRef, + PairIdRefLiteralInteger, + PairIdRefIdRef, + }; + + enum class SpirvSourceLanguage + { + Unknown = 0, + ESSL = 1, + GLSL = 2, + OpenCL_C = 3, + OpenCL_CPP = 4, + HLSL = 5, + }; + + enum class SpirvExecutionModel + { + Vertex = 0, + TessellationControl = 1, + TessellationEvaluation = 2, + Geometry = 3, + Fragment = 4, + GLCompute = 5, + Kernel = 6, + TaskNV = 5267, + MeshNV = 5268, + RayGenerationNV = 5313, + RayGenerationKHR = 5313, + IntersectionNV = 5314, + IntersectionKHR = 5314, + AnyHitNV = 5315, + AnyHitKHR = 5315, + ClosestHitNV = 5316, + ClosestHitKHR = 5316, + MissNV = 5317, + MissKHR = 5317, + CallableNV = 5318, + CallableKHR = 5318, + }; + + enum class SpirvAddressingModel + { + Logical = 0, + Physical32 = 1, + Physical64 = 2, + PhysicalStorageBuffer64 = 5348, + PhysicalStorageBuffer64EXT = 5348, + }; + + enum class SpirvMemoryModel + { + Simple = 0, + GLSL450 = 1, + OpenCL = 2, + Vulkan = 3, + VulkanKHR = 3, + }; + + enum class SpirvExecutionMode + { + Invocations = 0, + SpacingEqual = 1, + SpacingFractionalEven = 2, + SpacingFractionalOdd = 3, + VertexOrderCw = 4, + VertexOrderCcw = 5, + PixelCenterInteger = 6, + OriginUpperLeft = 7, + OriginLowerLeft = 8, + EarlyFragmentTests = 9, + PointMode = 10, + Xfb = 11, + DepthReplacing = 12, + DepthGreater = 14, + DepthLess = 15, + DepthUnchanged = 16, + LocalSize = 17, + LocalSizeHint = 18, + InputPoints = 19, + InputLines = 20, + InputLinesAdjacency = 21, + Triangles = 22, + InputTrianglesAdjacency = 23, + Quads = 24, + Isolines = 25, + OutputVertices = 26, + OutputPoints = 27, + OutputLineStrip = 28, + OutputTriangleStrip = 29, + VecTypeHint = 30, + ContractionOff = 31, + Initializer = 33, + Finalizer = 34, + SubgroupSize = 35, + SubgroupsPerWorkgroup = 36, + SubgroupsPerWorkgroupId = 37, + LocalSizeId = 38, + LocalSizeHintId = 39, + PostDepthCoverage = 4446, + DenormPreserve = 4459, + DenormFlushToZero = 4460, + SignedZeroInfNanPreserve = 4461, + RoundingModeRTE = 4462, + RoundingModeRTZ = 4463, + StencilRefReplacingEXT = 5027, + OutputLinesNV = 5269, + OutputPrimitivesNV = 5270, + DerivativeGroupQuadsNV = 5289, + DerivativeGroupLinearNV = 5290, + OutputTrianglesNV = 5298, + PixelInterlockOrderedEXT = 5366, + PixelInterlockUnorderedEXT = 5367, + SampleInterlockOrderedEXT = 5368, + SampleInterlockUnorderedEXT = 5369, + ShadingRateInterlockOrderedEXT = 5370, + ShadingRateInterlockUnorderedEXT = 5371, + MaxWorkgroupSizeINTEL = 5893, + MaxWorkDimINTEL = 5894, + NoGlobalOffsetINTEL = 5895, + NumSIMDWorkitemsINTEL = 5896, + }; + + enum class SpirvStorageClass + { + UniformConstant = 0, + Input = 1, + Uniform = 2, + Output = 3, + Workgroup = 4, + CrossWorkgroup = 5, + Private = 6, + Function = 7, + Generic = 8, + PushConstant = 9, + AtomicCounter = 10, + Image = 11, + StorageBuffer = 12, + CallableDataNV = 5328, + CallableDataKHR = 5328, + IncomingCallableDataNV = 5329, + IncomingCallableDataKHR = 5329, + RayPayloadNV = 5338, + RayPayloadKHR = 5338, + HitAttributeNV = 5339, + HitAttributeKHR = 5339, + IncomingRayPayloadNV = 5342, + IncomingRayPayloadKHR = 5342, + ShaderRecordBufferNV = 5343, + ShaderRecordBufferKHR = 5343, + PhysicalStorageBuffer = 5349, + PhysicalStorageBufferEXT = 5349, + CodeSectionINTEL = 5605, + }; + + enum class SpirvDim + { + Dim1D = 0, + Dim2D = 1, + Dim3D = 2, + Cube = 3, + Rect = 4, + Buffer = 5, + SubpassData = 6, + }; + + enum class SpirvSamplerAddressingMode + { + None = 0, + ClampToEdge = 1, + Clamp = 2, + Repeat = 3, + RepeatMirrored = 4, + }; + + enum class SpirvSamplerFilterMode + { + Nearest = 0, + Linear = 1, + }; + + enum class SpirvImageFormat + { + Unknown = 0, + Rgba32f = 1, + Rgba16f = 2, + R32f = 3, + Rgba8 = 4, + Rgba8Snorm = 5, + Rg32f = 6, + Rg16f = 7, + R11fG11fB10f = 8, + R16f = 9, + Rgba16 = 10, + Rgb10A2 = 11, + Rg16 = 12, + Rg8 = 13, + R16 = 14, + R8 = 15, + Rgba16Snorm = 16, + Rg16Snorm = 17, + Rg8Snorm = 18, + R16Snorm = 19, + R8Snorm = 20, + Rgba32i = 21, + Rgba16i = 22, + Rgba8i = 23, + R32i = 24, + Rg32i = 25, + Rg16i = 26, + Rg8i = 27, + R16i = 28, + R8i = 29, + Rgba32ui = 30, + Rgba16ui = 31, + Rgba8ui = 32, + R32ui = 33, + Rgb10a2ui = 34, + Rg32ui = 35, + Rg16ui = 36, + Rg8ui = 37, + R16ui = 38, + R8ui = 39, + }; + + enum class SpirvImageChannelOrder + { + R = 0, + A = 1, + RG = 2, + RA = 3, + RGB = 4, + RGBA = 5, + BGRA = 6, + ARGB = 7, + Intensity = 8, + Luminance = 9, + Rx = 10, + RGx = 11, + RGBx = 12, + Depth = 13, + DepthStencil = 14, + sRGB = 15, + sRGBx = 16, + sRGBA = 17, + sBGRA = 18, + ABGR = 19, + }; + + enum class SpirvImageChannelDataType + { + SnormInt8 = 0, + SnormInt16 = 1, + UnormInt8 = 2, + UnormInt16 = 3, + UnormShort565 = 4, + UnormShort555 = 5, + UnormInt101010 = 6, + SignedInt8 = 7, + SignedInt16 = 8, + SignedInt32 = 9, + UnsignedInt8 = 10, + UnsignedInt16 = 11, + UnsignedInt32 = 12, + HalfFloat = 13, + Float = 14, + UnormInt24 = 15, + UnormInt101010_2 = 16, + }; + + enum class SpirvFPRoundingMode + { + RTE = 0, + RTZ = 1, + RTP = 2, + RTN = 3, + }; + + enum class SpirvLinkageType + { + Export = 0, + Import = 1, + }; + + enum class SpirvAccessQualifier + { + ReadOnly = 0, + WriteOnly = 1, + ReadWrite = 2, + }; + + enum class SpirvFunctionParameterAttribute + { + Zext = 0, + Sext = 1, + ByVal = 2, + Sret = 3, + NoAlias = 4, + NoCapture = 5, + NoWrite = 6, + NoReadWrite = 7, + }; + + enum class SpirvDecoration + { + RelaxedPrecision = 0, + SpecId = 1, + Block = 2, + BufferBlock = 3, + RowMajor = 4, + ColMajor = 5, + ArrayStride = 6, + MatrixStride = 7, + GLSLShared = 8, + GLSLPacked = 9, + CPacked = 10, + BuiltIn = 11, + NoPerspective = 13, + Flat = 14, + Patch = 15, + Centroid = 16, + Sample = 17, + Invariant = 18, + Restrict = 19, + Aliased = 20, + Volatile = 21, + Constant = 22, + Coherent = 23, + NonWritable = 24, + NonReadable = 25, + Uniform = 26, + UniformId = 27, + SaturatedConversion = 28, + Stream = 29, + Location = 30, + Component = 31, + Index = 32, + Binding = 33, + DescriptorSet = 34, + Offset = 35, + XfbBuffer = 36, + XfbStride = 37, + FuncParamAttr = 38, + FPRoundingMode = 39, + FPFastMathMode = 40, + LinkageAttributes = 41, + NoContraction = 42, + InputAttachmentIndex = 43, + Alignment = 44, + MaxByteOffset = 45, + AlignmentId = 46, + MaxByteOffsetId = 47, + NoSignedWrap = 4469, + NoUnsignedWrap = 4470, + ExplicitInterpAMD = 4999, + OverrideCoverageNV = 5248, + PassthroughNV = 5250, + ViewportRelativeNV = 5252, + SecondaryViewportRelativeNV = 5256, + PerPrimitiveNV = 5271, + PerViewNV = 5272, + PerTaskNV = 5273, + PerVertexNV = 5285, + NonUniform = 5300, + NonUniformEXT = 5300, + RestrictPointer = 5355, + RestrictPointerEXT = 5355, + AliasedPointer = 5356, + AliasedPointerEXT = 5356, + ReferencedIndirectlyINTEL = 5602, + CounterBuffer = 5634, + HlslCounterBufferGOOGLE = 5634, + UserSemantic = 5635, + HlslSemanticGOOGLE = 5635, + UserTypeGOOGLE = 5636, + RegisterINTEL = 5825, + MemoryINTEL = 5826, + NumbanksINTEL = 5827, + BankwidthINTEL = 5828, + MaxPrivateCopiesINTEL = 5829, + SinglepumpINTEL = 5830, + DoublepumpINTEL = 5831, + MaxReplicatesINTEL = 5832, + SimpleDualPortINTEL = 5833, + MergeINTEL = 5834, + BankBitsINTEL = 5835, + ForcePow2DepthINTEL = 5836, + }; + + enum class SpirvBuiltIn + { + Position = 0, + PointSize = 1, + ClipDistance = 3, + CullDistance = 4, + VertexId = 5, + InstanceId = 6, + PrimitiveId = 7, + InvocationId = 8, + Layer = 9, + ViewportIndex = 10, + TessLevelOuter = 11, + TessLevelInner = 12, + TessCoord = 13, + PatchVertices = 14, + FragCoord = 15, + PointCoord = 16, + FrontFacing = 17, + SampleId = 18, + SamplePosition = 19, + SampleMask = 20, + FragDepth = 22, + HelperInvocation = 23, + NumWorkgroups = 24, + WorkgroupSize = 25, + WorkgroupId = 26, + LocalInvocationId = 27, + GlobalInvocationId = 28, + LocalInvocationIndex = 29, + WorkDim = 30, + GlobalSize = 31, + EnqueuedWorkgroupSize = 32, + GlobalOffset = 33, + GlobalLinearId = 34, + SubgroupSize = 36, + SubgroupMaxSize = 37, + NumSubgroups = 38, + NumEnqueuedSubgroups = 39, + SubgroupId = 40, + SubgroupLocalInvocationId = 41, + VertexIndex = 42, + InstanceIndex = 43, + SubgroupEqMask = 4416, + SubgroupGeMask = 4417, + SubgroupGtMask = 4418, + SubgroupLeMask = 4419, + SubgroupLtMask = 4420, + SubgroupEqMaskKHR = 4416, + SubgroupGeMaskKHR = 4417, + SubgroupGtMaskKHR = 4418, + SubgroupLeMaskKHR = 4419, + SubgroupLtMaskKHR = 4420, + BaseVertex = 4424, + BaseInstance = 4425, + DrawIndex = 4426, + DeviceIndex = 4438, + ViewIndex = 4440, + BaryCoordNoPerspAMD = 4992, + BaryCoordNoPerspCentroidAMD = 4993, + BaryCoordNoPerspSampleAMD = 4994, + BaryCoordSmoothAMD = 4995, + BaryCoordSmoothCentroidAMD = 4996, + BaryCoordSmoothSampleAMD = 4997, + BaryCoordPullModelAMD = 4998, + FragStencilRefEXT = 5014, + ViewportMaskNV = 5253, + SecondaryPositionNV = 5257, + SecondaryViewportMaskNV = 5258, + PositionPerViewNV = 5261, + ViewportMaskPerViewNV = 5262, + FullyCoveredEXT = 5264, + TaskCountNV = 5274, + PrimitiveCountNV = 5275, + PrimitiveIndicesNV = 5276, + ClipDistancePerViewNV = 5277, + CullDistancePerViewNV = 5278, + LayerPerViewNV = 5279, + MeshViewCountNV = 5280, + MeshViewIndicesNV = 5281, + BaryCoordNV = 5286, + BaryCoordNoPerspNV = 5287, + FragSizeEXT = 5292, + FragmentSizeNV = 5292, + FragInvocationCountEXT = 5293, + InvocationsPerPixelNV = 5293, + LaunchIdNV = 5319, + LaunchIdKHR = 5319, + LaunchSizeNV = 5320, + LaunchSizeKHR = 5320, + WorldRayOriginNV = 5321, + WorldRayOriginKHR = 5321, + WorldRayDirectionNV = 5322, + WorldRayDirectionKHR = 5322, + ObjectRayOriginNV = 5323, + ObjectRayOriginKHR = 5323, + ObjectRayDirectionNV = 5324, + ObjectRayDirectionKHR = 5324, + RayTminNV = 5325, + RayTminKHR = 5325, + RayTmaxNV = 5326, + RayTmaxKHR = 5326, + InstanceCustomIndexNV = 5327, + InstanceCustomIndexKHR = 5327, + ObjectToWorldNV = 5330, + ObjectToWorldKHR = 5330, + WorldToObjectNV = 5331, + WorldToObjectKHR = 5331, + HitTNV = 5332, + HitTKHR = 5332, + HitKindNV = 5333, + HitKindKHR = 5333, + IncomingRayFlagsNV = 5351, + IncomingRayFlagsKHR = 5351, + RayGeometryIndexKHR = 5352, + WarpsPerSMNV = 5374, + SMCountNV = 5375, + WarpIDNV = 5376, + SMIDNV = 5377, + }; + + enum class SpirvScope + { + CrossDevice = 0, + Device = 1, + Workgroup = 2, + Subgroup = 3, + Invocation = 4, + QueueFamily = 5, + QueueFamilyKHR = 5, + ShaderCallKHR = 6, + }; + + enum class SpirvGroupOperation + { + Reduce = 0, + InclusiveScan = 1, + ExclusiveScan = 2, + ClusteredReduce = 3, + PartitionedReduceNV = 6, + PartitionedInclusiveScanNV = 7, + PartitionedExclusiveScanNV = 8, + }; + + enum class SpirvKernelEnqueueFlags + { + NoWait = 0, + WaitKernel = 1, + WaitWorkGroup = 2, + }; + + enum class SpirvCapability + { + Matrix = 0, + Shader = 1, + Geometry = 2, + Tessellation = 3, + Addresses = 4, + Linkage = 5, + Kernel = 6, + Vector16 = 7, + Float16Buffer = 8, + Float16 = 9, + Float64 = 10, + Int64 = 11, + Int64Atomics = 12, + ImageBasic = 13, + ImageReadWrite = 14, + ImageMipmap = 15, + Pipes = 17, + Groups = 18, + DeviceEnqueue = 19, + LiteralSampler = 20, + AtomicStorage = 21, + Int16 = 22, + TessellationPointSize = 23, + GeometryPointSize = 24, + ImageGatherExtended = 25, + StorageImageMultisample = 27, + UniformBufferArrayDynamicIndexing = 28, + SampledImageArrayDynamicIndexing = 29, + StorageBufferArrayDynamicIndexing = 30, + StorageImageArrayDynamicIndexing = 31, + ClipDistance = 32, + CullDistance = 33, + ImageCubeArray = 34, + SampleRateShading = 35, + ImageRect = 36, + SampledRect = 37, + GenericPointer = 38, + Int8 = 39, + InputAttachment = 40, + SparseResidency = 41, + MinLod = 42, + Sampled1D = 43, + Image1D = 44, + SampledCubeArray = 45, + SampledBuffer = 46, + ImageBuffer = 47, + ImageMSArray = 48, + StorageImageExtendedFormats = 49, + ImageQuery = 50, + DerivativeControl = 51, + InterpolationFunction = 52, + TransformFeedback = 53, + GeometryStreams = 54, + StorageImageReadWithoutFormat = 55, + StorageImageWriteWithoutFormat = 56, + MultiViewport = 57, + SubgroupDispatch = 58, + NamedBarrier = 59, + PipeStorage = 60, + GroupNonUniform = 61, + GroupNonUniformVote = 62, + GroupNonUniformArithmetic = 63, + GroupNonUniformBallot = 64, + GroupNonUniformShuffle = 65, + GroupNonUniformShuffleRelative = 66, + GroupNonUniformClustered = 67, + GroupNonUniformQuad = 68, + ShaderLayer = 69, + ShaderViewportIndex = 70, + SubgroupBallotKHR = 4423, + DrawParameters = 4427, + SubgroupVoteKHR = 4431, + StorageBuffer16BitAccess = 4433, + StorageUniformBufferBlock16 = 4433, + UniformAndStorageBuffer16BitAccess = 4434, + StorageUniform16 = 4434, + StoragePushConstant16 = 4435, + StorageInputOutput16 = 4436, + DeviceGroup = 4437, + MultiView = 4439, + VariablePointersStorageBuffer = 4441, + VariablePointers = 4442, + AtomicStorageOps = 4445, + SampleMaskPostDepthCoverage = 4447, + StorageBuffer8BitAccess = 4448, + UniformAndStorageBuffer8BitAccess = 4449, + StoragePushConstant8 = 4450, + DenormPreserve = 4464, + DenormFlushToZero = 4465, + SignedZeroInfNanPreserve = 4466, + RoundingModeRTE = 4467, + RoundingModeRTZ = 4468, + RayQueryProvisionalKHR = 4471, + RayTraversalPrimitiveCullingProvisionalKHR = 4478, + Float16ImageAMD = 5008, + ImageGatherBiasLodAMD = 5009, + FragmentMaskAMD = 5010, + StencilExportEXT = 5013, + ImageReadWriteLodAMD = 5015, + ShaderClockKHR = 5055, + SampleMaskOverrideCoverageNV = 5249, + GeometryShaderPassthroughNV = 5251, + ShaderViewportIndexLayerEXT = 5254, + ShaderViewportIndexLayerNV = 5254, + ShaderViewportMaskNV = 5255, + ShaderStereoViewNV = 5259, + PerViewAttributesNV = 5260, + FragmentFullyCoveredEXT = 5265, + MeshShadingNV = 5266, + ImageFootprintNV = 5282, + FragmentBarycentricNV = 5284, + ComputeDerivativeGroupQuadsNV = 5288, + FragmentDensityEXT = 5291, + ShadingRateNV = 5291, + GroupNonUniformPartitionedNV = 5297, + ShaderNonUniform = 5301, + ShaderNonUniformEXT = 5301, + RuntimeDescriptorArray = 5302, + RuntimeDescriptorArrayEXT = 5302, + InputAttachmentArrayDynamicIndexing = 5303, + InputAttachmentArrayDynamicIndexingEXT = 5303, + UniformTexelBufferArrayDynamicIndexing = 5304, + UniformTexelBufferArrayDynamicIndexingEXT = 5304, + StorageTexelBufferArrayDynamicIndexing = 5305, + StorageTexelBufferArrayDynamicIndexingEXT = 5305, + UniformBufferArrayNonUniformIndexing = 5306, + UniformBufferArrayNonUniformIndexingEXT = 5306, + SampledImageArrayNonUniformIndexing = 5307, + SampledImageArrayNonUniformIndexingEXT = 5307, + StorageBufferArrayNonUniformIndexing = 5308, + StorageBufferArrayNonUniformIndexingEXT = 5308, + StorageImageArrayNonUniformIndexing = 5309, + StorageImageArrayNonUniformIndexingEXT = 5309, + InputAttachmentArrayNonUniformIndexing = 5310, + InputAttachmentArrayNonUniformIndexingEXT = 5310, + UniformTexelBufferArrayNonUniformIndexing = 5311, + UniformTexelBufferArrayNonUniformIndexingEXT = 5311, + StorageTexelBufferArrayNonUniformIndexing = 5312, + StorageTexelBufferArrayNonUniformIndexingEXT = 5312, + RayTracingNV = 5340, + VulkanMemoryModel = 5345, + VulkanMemoryModelKHR = 5345, + VulkanMemoryModelDeviceScope = 5346, + VulkanMemoryModelDeviceScopeKHR = 5346, + PhysicalStorageBufferAddresses = 5347, + PhysicalStorageBufferAddressesEXT = 5347, + ComputeDerivativeGroupLinearNV = 5350, + RayTracingProvisionalKHR = 5353, + CooperativeMatrixNV = 5357, + FragmentShaderSampleInterlockEXT = 5363, + FragmentShaderShadingRateInterlockEXT = 5372, + ShaderSMBuiltinsNV = 5373, + FragmentShaderPixelInterlockEXT = 5378, + DemoteToHelperInvocationEXT = 5379, + SubgroupShuffleINTEL = 5568, + SubgroupBufferBlockIOINTEL = 5569, + SubgroupImageBlockIOINTEL = 5570, + SubgroupImageMediaBlockIOINTEL = 5579, + IntegerFunctions2INTEL = 5584, + FunctionPointersINTEL = 5603, + IndirectReferencesINTEL = 5604, + SubgroupAvcMotionEstimationINTEL = 5696, + SubgroupAvcMotionEstimationIntraINTEL = 5697, + SubgroupAvcMotionEstimationChromaINTEL = 5698, + FPGAMemoryAttributesINTEL = 5824, + UnstructuredLoopControlsINTEL = 5886, + FPGALoopControlsINTEL = 5888, + KernelAttributesINTEL = 5892, + FPGAKernelAttributesINTEL = 5897, + BlockingPipesINTEL = 5945, + FPGARegINTEL = 5948, + AtomicFloat32AddEXT = 6033, + AtomicFloat64AddEXT = 6034, + }; + + enum class SpirvRayQueryIntersection + { + RayQueryCandidateIntersectionKHR = 0, + RayQueryCommittedIntersectionKHR = 1, + }; + + enum class SpirvRayQueryCommittedIntersectionType + { + RayQueryCommittedIntersectionNoneKHR = 0, + RayQueryCommittedIntersectionTriangleKHR = 1, + RayQueryCommittedIntersectionGeneratedKHR = 2, + }; + + enum class SpirvRayQueryCandidateIntersectionType + { + RayQueryCandidateIntersectionTriangleKHR = 0, + RayQueryCandidateIntersectionAABBKHR = 1, + }; + + struct SpirvInstruction + { + struct Operand + { + SpirvOperandKind kind; + const char* name; + }; + + SpirvOp op; + const char* name; + const Operand* operands; + std::size_t minOperandCount; + }; + + NAZARA_SHADER_API const SpirvInstruction* GetInstructionData(UInt16 op); +} + +#endif diff --git a/src/Nazara/Shader/SpirvData.cpp b/src/Nazara/Shader/SpirvData.cpp new file mode 100644 index 000000000..dae33b777 --- /dev/null +++ b/src/Nazara/Shader/SpirvData.cpp @@ -0,0 +1,11862 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp" + +// This file was generated automatically, please do not edit + +#include +#include +#include +#include + +namespace Nz +{ + static constexpr std::array s_operands = { + { + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::LiteralString, + R"('Continued Source')" + }, + { + SpirvOperandKind::SourceLanguage, + R"(SourceLanguage)" + }, + { + SpirvOperandKind::LiteralInteger, + R"('Version')" + }, + { + SpirvOperandKind::IdRef, + R"('File')" + }, + { + SpirvOperandKind::LiteralString, + R"('Source')" + }, + { + SpirvOperandKind::LiteralString, + R"('Extension')" + }, + { + SpirvOperandKind::IdRef, + R"('Target')" + }, + { + SpirvOperandKind::LiteralString, + R"('Name')" + }, + { + SpirvOperandKind::IdRef, + R"('Type')" + }, + { + SpirvOperandKind::LiteralInteger, + R"('Member')" + }, + { + SpirvOperandKind::LiteralString, + R"('Name')" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::LiteralString, + R"('String')" + }, + { + SpirvOperandKind::IdRef, + R"('File')" + }, + { + SpirvOperandKind::LiteralInteger, + R"('Line')" + }, + { + SpirvOperandKind::LiteralInteger, + R"('Column')" + }, + { + SpirvOperandKind::LiteralString, + R"('Name')" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::LiteralString, + R"('Name')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Set')" + }, + { + SpirvOperandKind::LiteralExtInstInteger, + R"('Instruction')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1', + +'Operand 2', + +...)" + }, + { + SpirvOperandKind::AddressingModel, + R"(AddressingModel)" + }, + { + SpirvOperandKind::MemoryModel, + R"(MemoryModel)" + }, + { + SpirvOperandKind::ExecutionModel, + R"(ExecutionModel)" + }, + { + SpirvOperandKind::IdRef, + R"('Entry Point')" + }, + { + SpirvOperandKind::LiteralString, + R"('Name')" + }, + { + SpirvOperandKind::IdRef, + R"('Interface')" + }, + { + SpirvOperandKind::IdRef, + R"('Entry Point')" + }, + { + SpirvOperandKind::ExecutionMode, + R"('Mode')" + }, + { + SpirvOperandKind::Capability, + R"('Capability')" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::LiteralInteger, + R"('Width')" + }, + { + SpirvOperandKind::LiteralInteger, + R"('Signedness')" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::LiteralInteger, + R"('Width')" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Component Type')" + }, + { + SpirvOperandKind::LiteralInteger, + R"('Component Count')" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Column Type')" + }, + { + SpirvOperandKind::LiteralInteger, + R"('Column Count')" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Sampled Type')" + }, + { + SpirvOperandKind::Dim, + R"(Dim)" + }, + { + SpirvOperandKind::LiteralInteger, + R"('Depth')" + }, + { + SpirvOperandKind::LiteralInteger, + R"('Arrayed')" + }, + { + SpirvOperandKind::LiteralInteger, + R"('MS')" + }, + { + SpirvOperandKind::LiteralInteger, + R"('Sampled')" + }, + { + SpirvOperandKind::ImageFormat, + R"(ImageFormat)" + }, + { + SpirvOperandKind::AccessQualifier, + R"(AccessQualifier)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Image Type')" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Element Type')" + }, + { + SpirvOperandKind::IdRef, + R"('Length')" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Element Type')" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Member 0 type', + +'member 1 type', + +...)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::LiteralString, + R"(The name of the opaque type.)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::StorageClass, + R"(StorageClass)" + }, + { + SpirvOperandKind::IdRef, + R"('Type')" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Return Type')" + }, + { + SpirvOperandKind::IdRef, + R"('Parameter 0 Type', + +'Parameter 1 Type', + +...)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::AccessQualifier, + R"('Qualifier')" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer Type')" + }, + { + SpirvOperandKind::StorageClass, + R"(StorageClass)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::LiteralContextDependentNumber, + R"('Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Constituents')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::SamplerAddressingMode, + R"(SamplerAddressingMode)" + }, + { + SpirvOperandKind::LiteralInteger, + R"('Param')" + }, + { + SpirvOperandKind::SamplerFilterMode, + R"(SamplerFilterMode)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::LiteralContextDependentNumber, + R"('Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Constituents')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::LiteralSpecConstantOpInteger, + R"('Opcode')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::FunctionControl, + R"(FunctionControl)" + }, + { + SpirvOperandKind::IdRef, + R"('Function Type')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Function')" + }, + { + SpirvOperandKind::IdRef, + R"('Argument 0', + +'Argument 1', + +...)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::StorageClass, + R"(StorageClass)" + }, + { + SpirvOperandKind::IdRef, + R"('Initializer')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::IdRef, + R"('Sample')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::MemoryAccess, + R"(MemoryAccess)" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::IdRef, + R"('Object')" + }, + { + SpirvOperandKind::MemoryAccess, + R"(MemoryAccess)" + }, + { + SpirvOperandKind::IdRef, + R"('Target')" + }, + { + SpirvOperandKind::IdRef, + R"('Source')" + }, + { + SpirvOperandKind::MemoryAccess, + R"(MemoryAccess)" + }, + { + SpirvOperandKind::MemoryAccess, + R"(MemoryAccess)" + }, + { + SpirvOperandKind::IdRef, + R"('Target')" + }, + { + SpirvOperandKind::IdRef, + R"('Source')" + }, + { + SpirvOperandKind::IdRef, + R"('Size')" + }, + { + SpirvOperandKind::MemoryAccess, + R"(MemoryAccess)" + }, + { + SpirvOperandKind::MemoryAccess, + R"(MemoryAccess)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Base')" + }, + { + SpirvOperandKind::IdRef, + R"('Indexes')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Base')" + }, + { + SpirvOperandKind::IdRef, + R"('Indexes')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Base')" + }, + { + SpirvOperandKind::IdRef, + R"('Element')" + }, + { + SpirvOperandKind::IdRef, + R"('Indexes')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Structure')" + }, + { + SpirvOperandKind::LiteralInteger, + R"('Array member')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Base')" + }, + { + SpirvOperandKind::IdRef, + R"('Element')" + }, + { + SpirvOperandKind::IdRef, + R"('Indexes')" + }, + { + SpirvOperandKind::IdRef, + R"('Target')" + }, + { + SpirvOperandKind::Decoration, + R"(Decoration)" + }, + { + SpirvOperandKind::IdRef, + R"('Structure Type')" + }, + { + SpirvOperandKind::LiteralInteger, + R"('Member')" + }, + { + SpirvOperandKind::Decoration, + R"(Decoration)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Decoration Group')" + }, + { + SpirvOperandKind::IdRef, + R"('Targets')" + }, + { + SpirvOperandKind::IdRef, + R"('Decoration Group')" + }, + { + SpirvOperandKind::PairIdRefLiteralInteger, + R"('Targets')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Vector')" + }, + { + SpirvOperandKind::IdRef, + R"('Index')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Vector')" + }, + { + SpirvOperandKind::IdRef, + R"('Component')" + }, + { + SpirvOperandKind::IdRef, + R"('Index')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Vector 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Vector 2')" + }, + { + SpirvOperandKind::LiteralInteger, + R"('Components')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Constituents')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Composite')" + }, + { + SpirvOperandKind::LiteralInteger, + R"('Indexes')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Object')" + }, + { + SpirvOperandKind::IdRef, + R"('Composite')" + }, + { + SpirvOperandKind::LiteralInteger, + R"('Indexes')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Matrix')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Sampler')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Sampled Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::ImageOperands, + R"(ImageOperands)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Sampled Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::ImageOperands, + R"(ImageOperands)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Sampled Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::IdRef, + R"('D~ref~')" + }, + { + SpirvOperandKind::ImageOperands, + R"(ImageOperands)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Sampled Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::IdRef, + R"('D~ref~')" + }, + { + SpirvOperandKind::ImageOperands, + R"(ImageOperands)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Sampled Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::ImageOperands, + R"(ImageOperands)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Sampled Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::ImageOperands, + R"(ImageOperands)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Sampled Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::IdRef, + R"('D~ref~')" + }, + { + SpirvOperandKind::ImageOperands, + R"(ImageOperands)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Sampled Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::IdRef, + R"('D~ref~')" + }, + { + SpirvOperandKind::ImageOperands, + R"(ImageOperands)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::ImageOperands, + R"(ImageOperands)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Sampled Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::IdRef, + R"('Component')" + }, + { + SpirvOperandKind::ImageOperands, + R"(ImageOperands)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Sampled Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::IdRef, + R"('D~ref~')" + }, + { + SpirvOperandKind::ImageOperands, + R"(ImageOperands)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::ImageOperands, + R"(ImageOperands)" + }, + { + SpirvOperandKind::IdRef, + R"('Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::IdRef, + R"('Texel')" + }, + { + SpirvOperandKind::ImageOperands, + R"(ImageOperands)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Sampled Image')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Image')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Image')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Level of Detail')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Image')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Sampled Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Image')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Image')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Float Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Float Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Signed Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Unsigned Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Unsigned Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Signed Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Float Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Signed Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Unsigned Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Integer Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::StorageClass, + R"('Storage')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Vector')" + }, + { + SpirvOperandKind::IdRef, + R"('Scalar')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Matrix')" + }, + { + SpirvOperandKind::IdRef, + R"('Scalar')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Vector')" + }, + { + SpirvOperandKind::IdRef, + R"('Matrix')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Matrix')" + }, + { + SpirvOperandKind::IdRef, + R"('Vector')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('LeftMatrix')" + }, + { + SpirvOperandKind::IdRef, + R"('RightMatrix')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Vector 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Vector 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Vector 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Vector 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Vector')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Vector')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('x')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('x')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('x')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('x')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('x')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('x')" + }, + { + SpirvOperandKind::IdRef, + R"('y')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('x')" + }, + { + SpirvOperandKind::IdRef, + R"('y')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('x')" + }, + { + SpirvOperandKind::IdRef, + R"('y')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Condition')" + }, + { + SpirvOperandKind::IdRef, + R"('Object 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Object 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Base')" + }, + { + SpirvOperandKind::IdRef, + R"('Shift')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Base')" + }, + { + SpirvOperandKind::IdRef, + R"('Shift')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Base')" + }, + { + SpirvOperandKind::IdRef, + R"('Shift')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Base')" + }, + { + SpirvOperandKind::IdRef, + R"('Insert')" + }, + { + SpirvOperandKind::IdRef, + R"('Offset')" + }, + { + SpirvOperandKind::IdRef, + R"('Count')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Base')" + }, + { + SpirvOperandKind::IdRef, + R"('Offset')" + }, + { + SpirvOperandKind::IdRef, + R"('Count')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Base')" + }, + { + SpirvOperandKind::IdRef, + R"('Offset')" + }, + { + SpirvOperandKind::IdRef, + R"('Count')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Base')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Base')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('P')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('P')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('P')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('P')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('P')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('P')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('P')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('P')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('P')" + }, + { + SpirvOperandKind::IdRef, + R"('Stream')" + }, + { + SpirvOperandKind::IdRef, + R"('Stream')" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::IdScope, + R"('Memory')" + }, + { + SpirvOperandKind::IdMemorySemantics, + R"('Semantics')" + }, + { + SpirvOperandKind::IdScope, + R"('Memory')" + }, + { + SpirvOperandKind::IdMemorySemantics, + R"('Semantics')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::IdScope, + R"('Memory')" + }, + { + SpirvOperandKind::IdMemorySemantics, + R"('Semantics')" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::IdScope, + R"('Memory')" + }, + { + SpirvOperandKind::IdMemorySemantics, + R"('Semantics')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::IdScope, + R"('Memory')" + }, + { + SpirvOperandKind::IdMemorySemantics, + R"('Semantics')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::IdScope, + R"('Memory')" + }, + { + SpirvOperandKind::IdMemorySemantics, + R"('Equal')" + }, + { + SpirvOperandKind::IdMemorySemantics, + R"('Unequal')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdRef, + R"('Comparator')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::IdScope, + R"('Memory')" + }, + { + SpirvOperandKind::IdMemorySemantics, + R"('Equal')" + }, + { + SpirvOperandKind::IdMemorySemantics, + R"('Unequal')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdRef, + R"('Comparator')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::IdScope, + R"('Memory')" + }, + { + SpirvOperandKind::IdMemorySemantics, + R"('Semantics')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::IdScope, + R"('Memory')" + }, + { + SpirvOperandKind::IdMemorySemantics, + R"('Semantics')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::IdScope, + R"('Memory')" + }, + { + SpirvOperandKind::IdMemorySemantics, + R"('Semantics')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::IdScope, + R"('Memory')" + }, + { + SpirvOperandKind::IdMemorySemantics, + R"('Semantics')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::IdScope, + R"('Memory')" + }, + { + SpirvOperandKind::IdMemorySemantics, + R"('Semantics')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::IdScope, + R"('Memory')" + }, + { + SpirvOperandKind::IdMemorySemantics, + R"('Semantics')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::IdScope, + R"('Memory')" + }, + { + SpirvOperandKind::IdMemorySemantics, + R"('Semantics')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::IdScope, + R"('Memory')" + }, + { + SpirvOperandKind::IdMemorySemantics, + R"('Semantics')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::IdScope, + R"('Memory')" + }, + { + SpirvOperandKind::IdMemorySemantics, + R"('Semantics')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::IdScope, + R"('Memory')" + }, + { + SpirvOperandKind::IdMemorySemantics, + R"('Semantics')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::IdScope, + R"('Memory')" + }, + { + SpirvOperandKind::IdMemorySemantics, + R"('Semantics')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::PairIdRefIdRef, + R"('Variable, Parent, ...')" + }, + { + SpirvOperandKind::IdRef, + R"('Merge Block')" + }, + { + SpirvOperandKind::IdRef, + R"('Continue Target')" + }, + { + SpirvOperandKind::LoopControl, + R"(LoopControl)" + }, + { + SpirvOperandKind::IdRef, + R"('Merge Block')" + }, + { + SpirvOperandKind::SelectionControl, + R"(SelectionControl)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Target Label')" + }, + { + SpirvOperandKind::IdRef, + R"('Condition')" + }, + { + SpirvOperandKind::IdRef, + R"('True Label')" + }, + { + SpirvOperandKind::IdRef, + R"('False Label')" + }, + { + SpirvOperandKind::LiteralInteger, + R"('Branch weights')" + }, + { + SpirvOperandKind::IdRef, + R"('Selector')" + }, + { + SpirvOperandKind::IdRef, + R"('Default')" + }, + { + SpirvOperandKind::PairLiteralIntegerIdRef, + R"('Target')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::LiteralInteger, + R"('Size')" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::LiteralInteger, + R"('Size')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::IdRef, + R"('Destination')" + }, + { + SpirvOperandKind::IdRef, + R"('Source')" + }, + { + SpirvOperandKind::IdRef, + R"('Num Elements')" + }, + { + SpirvOperandKind::IdRef, + R"('Stride')" + }, + { + SpirvOperandKind::IdRef, + R"('Event')" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::IdRef, + R"('Num Events')" + }, + { + SpirvOperandKind::IdRef, + R"('Events List')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::IdRef, + R"('Predicate')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::IdRef, + R"('Predicate')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdRef, + R"('LocalId')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('X')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('X')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('X')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('X')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('X')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('X')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('X')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('X')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pipe')" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Size')" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Alignment')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pipe')" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Size')" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Alignment')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pipe')" + }, + { + SpirvOperandKind::IdRef, + R"('Reserve Id')" + }, + { + SpirvOperandKind::IdRef, + R"('Index')" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Size')" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Alignment')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pipe')" + }, + { + SpirvOperandKind::IdRef, + R"('Reserve Id')" + }, + { + SpirvOperandKind::IdRef, + R"('Index')" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Size')" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Alignment')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pipe')" + }, + { + SpirvOperandKind::IdRef, + R"('Num Packets')" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Size')" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Alignment')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pipe')" + }, + { + SpirvOperandKind::IdRef, + R"('Num Packets')" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Size')" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Alignment')" + }, + { + SpirvOperandKind::IdRef, + R"('Pipe')" + }, + { + SpirvOperandKind::IdRef, + R"('Reserve Id')" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Size')" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Alignment')" + }, + { + SpirvOperandKind::IdRef, + R"('Pipe')" + }, + { + SpirvOperandKind::IdRef, + R"('Reserve Id')" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Size')" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Alignment')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Reserve Id')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pipe')" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Size')" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Alignment')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pipe')" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Size')" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Alignment')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::IdRef, + R"('Pipe')" + }, + { + SpirvOperandKind::IdRef, + R"('Num Packets')" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Size')" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Alignment')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::IdRef, + R"('Pipe')" + }, + { + SpirvOperandKind::IdRef, + R"('Num Packets')" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Size')" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Alignment')" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::IdRef, + R"('Pipe')" + }, + { + SpirvOperandKind::IdRef, + R"('Reserve Id')" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Size')" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Alignment')" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::IdRef, + R"('Pipe')" + }, + { + SpirvOperandKind::IdRef, + R"('Reserve Id')" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Size')" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Alignment')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Queue')" + }, + { + SpirvOperandKind::IdRef, + R"('Num Events')" + }, + { + SpirvOperandKind::IdRef, + R"('Wait Events')" + }, + { + SpirvOperandKind::IdRef, + R"('Ret Event')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Queue')" + }, + { + SpirvOperandKind::IdRef, + R"('Flags')" + }, + { + SpirvOperandKind::IdRef, + R"('ND Range')" + }, + { + SpirvOperandKind::IdRef, + R"('Num Events')" + }, + { + SpirvOperandKind::IdRef, + R"('Wait Events')" + }, + { + SpirvOperandKind::IdRef, + R"('Ret Event')" + }, + { + SpirvOperandKind::IdRef, + R"('Invoke')" + }, + { + SpirvOperandKind::IdRef, + R"('Param')" + }, + { + SpirvOperandKind::IdRef, + R"('Param Size')" + }, + { + SpirvOperandKind::IdRef, + R"('Param Align')" + }, + { + SpirvOperandKind::IdRef, + R"('Local Size')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('ND Range')" + }, + { + SpirvOperandKind::IdRef, + R"('Invoke')" + }, + { + SpirvOperandKind::IdRef, + R"('Param')" + }, + { + SpirvOperandKind::IdRef, + R"('Param Size')" + }, + { + SpirvOperandKind::IdRef, + R"('Param Align')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('ND Range')" + }, + { + SpirvOperandKind::IdRef, + R"('Invoke')" + }, + { + SpirvOperandKind::IdRef, + R"('Param')" + }, + { + SpirvOperandKind::IdRef, + R"('Param Size')" + }, + { + SpirvOperandKind::IdRef, + R"('Param Align')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Invoke')" + }, + { + SpirvOperandKind::IdRef, + R"('Param')" + }, + { + SpirvOperandKind::IdRef, + R"('Param Size')" + }, + { + SpirvOperandKind::IdRef, + R"('Param Align')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Invoke')" + }, + { + SpirvOperandKind::IdRef, + R"('Param')" + }, + { + SpirvOperandKind::IdRef, + R"('Param Size')" + }, + { + SpirvOperandKind::IdRef, + R"('Param Align')" + }, + { + SpirvOperandKind::IdRef, + R"('Event')" + }, + { + SpirvOperandKind::IdRef, + R"('Event')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Event')" + }, + { + SpirvOperandKind::IdRef, + R"('Event')" + }, + { + SpirvOperandKind::IdRef, + R"('Status')" + }, + { + SpirvOperandKind::IdRef, + R"('Event')" + }, + { + SpirvOperandKind::IdRef, + R"('Profiling Info')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('GlobalWorkSize')" + }, + { + SpirvOperandKind::IdRef, + R"('LocalWorkSize')" + }, + { + SpirvOperandKind::IdRef, + R"('GlobalWorkOffset')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Sampled Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::ImageOperands, + R"(ImageOperands)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Sampled Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::ImageOperands, + R"(ImageOperands)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Sampled Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::IdRef, + R"('D~ref~')" + }, + { + SpirvOperandKind::ImageOperands, + R"(ImageOperands)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Sampled Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::IdRef, + R"('D~ref~')" + }, + { + SpirvOperandKind::ImageOperands, + R"(ImageOperands)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Sampled Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::ImageOperands, + R"(ImageOperands)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Sampled Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::ImageOperands, + R"(ImageOperands)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Sampled Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::IdRef, + R"('D~ref~')" + }, + { + SpirvOperandKind::ImageOperands, + R"(ImageOperands)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Sampled Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::IdRef, + R"('D~ref~')" + }, + { + SpirvOperandKind::ImageOperands, + R"(ImageOperands)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::ImageOperands, + R"(ImageOperands)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Sampled Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::IdRef, + R"('Component')" + }, + { + SpirvOperandKind::ImageOperands, + R"(ImageOperands)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Sampled Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::IdRef, + R"('D~ref~')" + }, + { + SpirvOperandKind::ImageOperands, + R"(ImageOperands)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Resident Code')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::IdScope, + R"('Memory')" + }, + { + SpirvOperandKind::IdMemorySemantics, + R"('Semantics')" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::IdScope, + R"('Memory')" + }, + { + SpirvOperandKind::IdMemorySemantics, + R"('Semantics')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::ImageOperands, + R"(ImageOperands)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::LiteralInteger, + R"('Packet Size')" + }, + { + SpirvOperandKind::LiteralInteger, + R"('Packet Alignment')" + }, + { + SpirvOperandKind::LiteralInteger, + R"('Capacity')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pipe Storage')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Subgroup Count')" + }, + { + SpirvOperandKind::IdRef, + R"('Invoke')" + }, + { + SpirvOperandKind::IdRef, + R"('Param')" + }, + { + SpirvOperandKind::IdRef, + R"('Param Size')" + }, + { + SpirvOperandKind::IdRef, + R"('Param Align')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Invoke')" + }, + { + SpirvOperandKind::IdRef, + R"('Param')" + }, + { + SpirvOperandKind::IdRef, + R"('Param Size')" + }, + { + SpirvOperandKind::IdRef, + R"('Param Align')" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Subgroup Count')" + }, + { + SpirvOperandKind::IdRef, + R"('Named Barrier')" + }, + { + SpirvOperandKind::IdScope, + R"('Memory')" + }, + { + SpirvOperandKind::IdMemorySemantics, + R"('Semantics')" + }, + { + SpirvOperandKind::LiteralString, + R"('Process')" + }, + { + SpirvOperandKind::IdRef, + R"('Entry Point')" + }, + { + SpirvOperandKind::ExecutionMode, + R"('Mode')" + }, + { + SpirvOperandKind::IdRef, + R"('Target')" + }, + { + SpirvOperandKind::Decoration, + R"(Decoration)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::IdRef, + R"('Predicate')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::IdRef, + R"('Predicate')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdRef, + R"('Id')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::IdRef, + R"('Predicate')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdRef, + R"('Index')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdRef, + R"('Id')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdRef, + R"('Mask')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdRef, + R"('Delta')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdRef, + R"('Delta')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdRef, + R"('ClusterSize')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdRef, + R"('ClusterSize')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdRef, + R"('ClusterSize')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdRef, + R"('ClusterSize')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdRef, + R"('ClusterSize')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdRef, + R"('ClusterSize')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdRef, + R"('ClusterSize')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdRef, + R"('ClusterSize')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdRef, + R"('ClusterSize')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdRef, + R"('ClusterSize')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdRef, + R"('ClusterSize')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdRef, + R"('ClusterSize')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdRef, + R"('ClusterSize')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdRef, + R"('ClusterSize')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdRef, + R"('ClusterSize')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdRef, + R"('ClusterSize')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdRef, + R"('Index')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdRef, + R"('Direction')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Predicate')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Predicate')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Predicate')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Predicate')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdRef, + R"('Index')" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('RayQuery')" + }, + { + SpirvOperandKind::IdRef, + R"('Accel')" + }, + { + SpirvOperandKind::IdRef, + R"('RayFlags')" + }, + { + SpirvOperandKind::IdRef, + R"('CullMask')" + }, + { + SpirvOperandKind::IdRef, + R"('RayOrigin')" + }, + { + SpirvOperandKind::IdRef, + R"('RayTMin')" + }, + { + SpirvOperandKind::IdRef, + R"('RayDirection')" + }, + { + SpirvOperandKind::IdRef, + R"('RayTMax')" + }, + { + SpirvOperandKind::IdRef, + R"('RayQuery')" + }, + { + SpirvOperandKind::IdRef, + R"('RayQuery')" + }, + { + SpirvOperandKind::IdRef, + R"('HitT')" + }, + { + SpirvOperandKind::IdRef, + R"('RayQuery')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('RayQuery')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('RayQuery')" + }, + { + SpirvOperandKind::IdRef, + R"('Intersection')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('X')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('X')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('X')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('X')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('X')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('X')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('X')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::GroupOperation, + R"('Operation')" + }, + { + SpirvOperandKind::IdRef, + R"('X')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::IdRef, + R"('Fragment Index')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Sampled Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::IdRef, + R"('Granularity')" + }, + { + SpirvOperandKind::IdRef, + R"('Coarse')" + }, + { + SpirvOperandKind::ImageOperands, + R"(ImageOperands)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdRef, + R"('Index Offset')" + }, + { + SpirvOperandKind::IdRef, + R"('Packed Indices')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Hit')" + }, + { + SpirvOperandKind::IdRef, + R"('HitKind')" + }, + { + SpirvOperandKind::IdRef, + R"('Accel')" + }, + { + SpirvOperandKind::IdRef, + R"('Ray Flags')" + }, + { + SpirvOperandKind::IdRef, + R"('Cull Mask')" + }, + { + SpirvOperandKind::IdRef, + R"('SBT Offset')" + }, + { + SpirvOperandKind::IdRef, + R"('SBT Stride')" + }, + { + SpirvOperandKind::IdRef, + R"('Miss Index')" + }, + { + SpirvOperandKind::IdRef, + R"('Ray Origin')" + }, + { + SpirvOperandKind::IdRef, + R"('Ray Tmin')" + }, + { + SpirvOperandKind::IdRef, + R"('Ray Direction')" + }, + { + SpirvOperandKind::IdRef, + R"('Ray Tmax')" + }, + { + SpirvOperandKind::IdRef, + R"('PayloadId')" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('SBT Index')" + }, + { + SpirvOperandKind::IdRef, + R"('Callable DataId')" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Component Type')" + }, + { + SpirvOperandKind::IdScope, + R"('Execution')" + }, + { + SpirvOperandKind::IdRef, + R"('Rows')" + }, + { + SpirvOperandKind::IdRef, + R"('Columns')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::IdRef, + R"('Stride')" + }, + { + SpirvOperandKind::IdRef, + R"('Column Major')" + }, + { + SpirvOperandKind::MemoryAccess, + R"(MemoryAccess)" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::IdRef, + R"('Object')" + }, + { + SpirvOperandKind::IdRef, + R"('Stride')" + }, + { + SpirvOperandKind::IdRef, + R"('Column Major')" + }, + { + SpirvOperandKind::MemoryAccess, + R"(MemoryAccess)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('A')" + }, + { + SpirvOperandKind::IdRef, + R"('B')" + }, + { + SpirvOperandKind::IdRef, + R"('C')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Type')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Data')" + }, + { + SpirvOperandKind::IdRef, + R"('InvocationId')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Current')" + }, + { + SpirvOperandKind::IdRef, + R"('Next')" + }, + { + SpirvOperandKind::IdRef, + R"('Delta')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Previous')" + }, + { + SpirvOperandKind::IdRef, + R"('Current')" + }, + { + SpirvOperandKind::IdRef, + R"('Delta')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Data')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Ptr')" + }, + { + SpirvOperandKind::IdRef, + R"('Ptr')" + }, + { + SpirvOperandKind::IdRef, + R"('Data')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::IdRef, + R"('Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::IdRef, + R"('Data')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::IdRef, + R"('Width')" + }, + { + SpirvOperandKind::IdRef, + R"('Height')" + }, + { + SpirvOperandKind::IdRef, + R"('Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Coordinate')" + }, + { + SpirvOperandKind::IdRef, + R"('Width')" + }, + { + SpirvOperandKind::IdRef, + R"('Height')" + }, + { + SpirvOperandKind::IdRef, + R"('Data')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 2')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Function')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Operand 1')" + }, + { + SpirvOperandKind::IdRef, + R"('Target')" + }, + { + SpirvOperandKind::Decoration, + R"(Decoration)" + }, + { + SpirvOperandKind::IdRef, + R"('Struct Type')" + }, + { + SpirvOperandKind::LiteralInteger, + R"('Member')" + }, + { + SpirvOperandKind::Decoration, + R"(Decoration)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Image Type')" + }, + { + SpirvOperandKind::IdRef, + R"('Sampler')" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Image Type')" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Slice Type')" + }, + { + SpirvOperandKind::IdRef, + R"('Qp')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Reference Base Penalty')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Slice Type')" + }, + { + SpirvOperandKind::IdRef, + R"('Qp')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Packed Shape Penalty')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Slice Type')" + }, + { + SpirvOperandKind::IdRef, + R"('Qp')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Direction Cost')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Slice Type')" + }, + { + SpirvOperandKind::IdRef, + R"('Qp')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Slice Type')" + }, + { + SpirvOperandKind::IdRef, + R"('Qp')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Packed Cost Center Delta')" + }, + { + SpirvOperandKind::IdRef, + R"('Packed Cost Table')" + }, + { + SpirvOperandKind::IdRef, + R"('Cost Precision')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Slice Type')" + }, + { + SpirvOperandKind::IdRef, + R"('Qp')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Source Field Polarity')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Reference Field Polarity')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Forward Reference Field Polarity')" + }, + { + SpirvOperandKind::IdRef, + R"('Backward Reference Field Polarity')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Packed Reference Ids')" + }, + { + SpirvOperandKind::IdRef, + R"('Packed Reference Parameter Field Polarities')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Src Coord')" + }, + { + SpirvOperandKind::IdRef, + R"('Partition Mask')" + }, + { + SpirvOperandKind::IdRef, + R"('SAD Adjustment')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Ref Offset')" + }, + { + SpirvOperandKind::IdRef, + R"('Search Window Config')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Fwd Ref Offset')" + }, + { + SpirvOperandKind::IdRef, + R"('Bwd Ref Offset')" + }, + { + SpirvOperandKind::IdRef, + R"('id> Search Window Config')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Search Window Config')" + }, + { + SpirvOperandKind::IdRef, + R"('Dual Ref')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Ref Offset')" + }, + { + SpirvOperandKind::IdRef, + R"('Src Coord')" + }, + { + SpirvOperandKind::IdRef, + R"('Ref Window Size')" + }, + { + SpirvOperandKind::IdRef, + R"('Image Size')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Max Motion Vector Count')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Threshold')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Packed Sad Weights')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Src Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Ref Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Src Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Fwd Ref Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Bwd Ref Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Src Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Ref Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdRef, + R"('Streamin Components')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Src Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Fwd Ref Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Bwd Ref Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdRef, + R"('Streamin Components')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Src Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Ref Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Src Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Fwd Ref Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Bwd Ref Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Src Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Ref Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdRef, + R"('Streamin Components')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Src Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Fwd Ref Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Bwd Ref Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdRef, + R"('Streamin Components')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdRef, + R"('Major Shape')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdRef, + R"('Major Shape')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdRef, + R"('Major Shape')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdRef, + R"('Major Shape')" + }, + { + SpirvOperandKind::IdRef, + R"('Direction')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdRef, + R"('Major Shape')" + }, + { + SpirvOperandKind::IdRef, + R"('Direction')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdRef, + R"('Major Shape')" + }, + { + SpirvOperandKind::IdRef, + R"('Direction')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Image Select')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Src Coord')" + }, + { + SpirvOperandKind::IdRef, + R"('Motion Vectors')" + }, + { + SpirvOperandKind::IdRef, + R"('Major Shapes')" + }, + { + SpirvOperandKind::IdRef, + R"('Minor Shapes')" + }, + { + SpirvOperandKind::IdRef, + R"('Direction')" + }, + { + SpirvOperandKind::IdRef, + R"('Pixel Resolution')" + }, + { + SpirvOperandKind::IdRef, + R"('Sad Adjustment')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Src Coord')" + }, + { + SpirvOperandKind::IdRef, + R"('Motion Vectors')" + }, + { + SpirvOperandKind::IdRef, + R"('Major Shapes')" + }, + { + SpirvOperandKind::IdRef, + R"('Minor Shapes')" + }, + { + SpirvOperandKind::IdRef, + R"('Direction')" + }, + { + SpirvOperandKind::IdRef, + R"('Pixel Resolution')" + }, + { + SpirvOperandKind::IdRef, + R"('Bidirectional Weight')" + }, + { + SpirvOperandKind::IdRef, + R"('Sad Adjustment')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Src Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Ref Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Src Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Fwd Ref Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Bwd Ref Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Src Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Packed Reference Ids')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Src Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Packed Reference Ids')" + }, + { + SpirvOperandKind::IdRef, + R"('Packed Reference Field Polarities')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Src Coord')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Skip Block Partition Type')" + }, + { + SpirvOperandKind::IdRef, + R"('Skip Motion Vector Mask')" + }, + { + SpirvOperandKind::IdRef, + R"('Motion Vectors')" + }, + { + SpirvOperandKind::IdRef, + R"('Bidirectional Weight')" + }, + { + SpirvOperandKind::IdRef, + R"('Sad Adjustment')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Luma Intra Partition Mask')" + }, + { + SpirvOperandKind::IdRef, + R"('Intra Neighbour Availabilty')" + }, + { + SpirvOperandKind::IdRef, + R"('Left Edge Luma Pixels')" + }, + { + SpirvOperandKind::IdRef, + R"('Upper Left Corner Luma Pixel')" + }, + { + SpirvOperandKind::IdRef, + R"('Upper Edge Luma Pixels')" + }, + { + SpirvOperandKind::IdRef, + R"('Upper Right Edge Luma Pixels')" + }, + { + SpirvOperandKind::IdRef, + R"('Sad Adjustment')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Luma Intra Partition Mask')" + }, + { + SpirvOperandKind::IdRef, + R"('Intra Neighbour Availabilty')" + }, + { + SpirvOperandKind::IdRef, + R"('Left Edge Luma Pixels')" + }, + { + SpirvOperandKind::IdRef, + R"('Upper Left Corner Luma Pixel')" + }, + { + SpirvOperandKind::IdRef, + R"('Upper Edge Luma Pixels')" + }, + { + SpirvOperandKind::IdRef, + R"('Upper Right Edge Luma Pixels')" + }, + { + SpirvOperandKind::IdRef, + R"('Left Edge Chroma Pixels')" + }, + { + SpirvOperandKind::IdRef, + R"('Upper Left Corner Chroma Pixel')" + }, + { + SpirvOperandKind::IdRef, + R"('Upper Edge Chroma Pixels')" + }, + { + SpirvOperandKind::IdRef, + R"('Sad Adjustment')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Skip Block Partition Type')" + }, + { + SpirvOperandKind::IdRef, + R"('Direction')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Packed Shape Penalty')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Luma Mode Penalty')" + }, + { + SpirvOperandKind::IdRef, + R"('Luma Packed Neighbor Modes')" + }, + { + SpirvOperandKind::IdRef, + R"('Luma Packed Non Dc Penalty')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Chroma Mode Base Penalty')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Packed Sad Coefficients')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Block Based Skip Type')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Src Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Src Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Ref Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Src Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Fwd Ref Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Bwd Ref Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Src Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Packed Reference Ids')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Src Image')" + }, + { + SpirvOperandKind::IdRef, + R"('Packed Reference Ids')" + }, + { + SpirvOperandKind::IdRef, + R"('Packed Reference Field Polarities')" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Payload')" + }, + { + SpirvOperandKind::LiteralInteger, + R"('Loop Control Parameters')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Size')" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Alignment')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Size')" + }, + { + SpirvOperandKind::IdRef, + R"('Packet Alignment')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Result')" + }, + { + SpirvOperandKind::IdRef, + R"('Input')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('RayQuery')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('RayQuery')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('RayQuery')" + }, + { + SpirvOperandKind::IdRef, + R"('Intersection')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('RayQuery')" + }, + { + SpirvOperandKind::IdRef, + R"('Intersection')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('RayQuery')" + }, + { + SpirvOperandKind::IdRef, + R"('Intersection')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('RayQuery')" + }, + { + SpirvOperandKind::IdRef, + R"('Intersection')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('RayQuery')" + }, + { + SpirvOperandKind::IdRef, + R"('Intersection')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('RayQuery')" + }, + { + SpirvOperandKind::IdRef, + R"('Intersection')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('RayQuery')" + }, + { + SpirvOperandKind::IdRef, + R"('Intersection')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('RayQuery')" + }, + { + SpirvOperandKind::IdRef, + R"('Intersection')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('RayQuery')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('RayQuery')" + }, + { + SpirvOperandKind::IdRef, + R"('Intersection')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('RayQuery')" + }, + { + SpirvOperandKind::IdRef, + R"('Intersection')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('RayQuery')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('RayQuery')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('RayQuery')" + }, + { + SpirvOperandKind::IdRef, + R"('Intersection')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('RayQuery')" + }, + { + SpirvOperandKind::IdRef, + R"('Intersection')" + }, + { + SpirvOperandKind::IdResultType, + R"(IdResultType)" + }, + { + SpirvOperandKind::IdResult, + R"(IdResult)" + }, + { + SpirvOperandKind::IdRef, + R"('Pointer')" + }, + { + SpirvOperandKind::IdScope, + R"('Memory')" + }, + { + SpirvOperandKind::IdMemorySemantics, + R"('Semantics')" + }, + { + SpirvOperandKind::IdRef, + R"('Value')" + }, + } + }; + + static std::array s_instructions = { + { + { + SpirvOp::OpNop, + R"(OpNop)", + nullptr, + 0, + }, + { + SpirvOp::OpUndef, + R"(OpUndef)", + &s_operands[0], + 2, + }, + { + SpirvOp::OpSourceContinued, + R"(OpSourceContinued)", + &s_operands[2], + 1, + }, + { + SpirvOp::OpSource, + R"(OpSource)", + &s_operands[3], + 4, + }, + { + SpirvOp::OpSourceExtension, + R"(OpSourceExtension)", + &s_operands[7], + 1, + }, + { + SpirvOp::OpName, + R"(OpName)", + &s_operands[8], + 2, + }, + { + SpirvOp::OpMemberName, + R"(OpMemberName)", + &s_operands[10], + 3, + }, + { + SpirvOp::OpString, + R"(OpString)", + &s_operands[13], + 2, + }, + { + SpirvOp::OpLine, + R"(OpLine)", + &s_operands[15], + 3, + }, + { + SpirvOp::OpExtension, + R"(OpExtension)", + &s_operands[18], + 1, + }, + { + SpirvOp::OpExtInstImport, + R"(OpExtInstImport)", + &s_operands[19], + 2, + }, + { + SpirvOp::OpExtInst, + R"(OpExtInst)", + &s_operands[21], + 5, + }, + { + SpirvOp::OpMemoryModel, + R"(OpMemoryModel)", + &s_operands[26], + 2, + }, + { + SpirvOp::OpEntryPoint, + R"(OpEntryPoint)", + &s_operands[28], + 4, + }, + { + SpirvOp::OpExecutionMode, + R"(OpExecutionMode)", + &s_operands[32], + 2, + }, + { + SpirvOp::OpCapability, + R"(OpCapability)", + &s_operands[34], + 1, + }, + { + SpirvOp::OpTypeVoid, + R"(OpTypeVoid)", + &s_operands[35], + 1, + }, + { + SpirvOp::OpTypeBool, + R"(OpTypeBool)", + &s_operands[36], + 1, + }, + { + SpirvOp::OpTypeInt, + R"(OpTypeInt)", + &s_operands[37], + 3, + }, + { + SpirvOp::OpTypeFloat, + R"(OpTypeFloat)", + &s_operands[40], + 2, + }, + { + SpirvOp::OpTypeVector, + R"(OpTypeVector)", + &s_operands[42], + 3, + }, + { + SpirvOp::OpTypeMatrix, + R"(OpTypeMatrix)", + &s_operands[45], + 3, + }, + { + SpirvOp::OpTypeImage, + R"(OpTypeImage)", + &s_operands[48], + 9, + }, + { + SpirvOp::OpTypeSampler, + R"(OpTypeSampler)", + &s_operands[57], + 1, + }, + { + SpirvOp::OpTypeSampledImage, + R"(OpTypeSampledImage)", + &s_operands[58], + 2, + }, + { + SpirvOp::OpTypeArray, + R"(OpTypeArray)", + &s_operands[60], + 3, + }, + { + SpirvOp::OpTypeRuntimeArray, + R"(OpTypeRuntimeArray)", + &s_operands[63], + 2, + }, + { + SpirvOp::OpTypeStruct, + R"(OpTypeStruct)", + &s_operands[65], + 2, + }, + { + SpirvOp::OpTypeOpaque, + R"(OpTypeOpaque)", + &s_operands[67], + 2, + }, + { + SpirvOp::OpTypePointer, + R"(OpTypePointer)", + &s_operands[69], + 3, + }, + { + SpirvOp::OpTypeFunction, + R"(OpTypeFunction)", + &s_operands[72], + 3, + }, + { + SpirvOp::OpTypeEvent, + R"(OpTypeEvent)", + &s_operands[75], + 1, + }, + { + SpirvOp::OpTypeDeviceEvent, + R"(OpTypeDeviceEvent)", + &s_operands[76], + 1, + }, + { + SpirvOp::OpTypeReserveId, + R"(OpTypeReserveId)", + &s_operands[77], + 1, + }, + { + SpirvOp::OpTypeQueue, + R"(OpTypeQueue)", + &s_operands[78], + 1, + }, + { + SpirvOp::OpTypePipe, + R"(OpTypePipe)", + &s_operands[79], + 2, + }, + { + SpirvOp::OpTypeForwardPointer, + R"(OpTypeForwardPointer)", + &s_operands[81], + 2, + }, + { + SpirvOp::OpConstantTrue, + R"(OpConstantTrue)", + &s_operands[83], + 2, + }, + { + SpirvOp::OpConstantFalse, + R"(OpConstantFalse)", + &s_operands[85], + 2, + }, + { + SpirvOp::OpConstant, + R"(OpConstant)", + &s_operands[87], + 3, + }, + { + SpirvOp::OpConstantComposite, + R"(OpConstantComposite)", + &s_operands[90], + 3, + }, + { + SpirvOp::OpConstantSampler, + R"(OpConstantSampler)", + &s_operands[93], + 5, + }, + { + SpirvOp::OpConstantNull, + R"(OpConstantNull)", + &s_operands[98], + 2, + }, + { + SpirvOp::OpSpecConstantTrue, + R"(OpSpecConstantTrue)", + &s_operands[100], + 2, + }, + { + SpirvOp::OpSpecConstantFalse, + R"(OpSpecConstantFalse)", + &s_operands[102], + 2, + }, + { + SpirvOp::OpSpecConstant, + R"(OpSpecConstant)", + &s_operands[104], + 3, + }, + { + SpirvOp::OpSpecConstantComposite, + R"(OpSpecConstantComposite)", + &s_operands[107], + 3, + }, + { + SpirvOp::OpSpecConstantOp, + R"(OpSpecConstantOp)", + &s_operands[110], + 3, + }, + { + SpirvOp::OpFunction, + R"(OpFunction)", + &s_operands[113], + 4, + }, + { + SpirvOp::OpFunctionParameter, + R"(OpFunctionParameter)", + &s_operands[117], + 2, + }, + { + SpirvOp::OpFunctionEnd, + R"(OpFunctionEnd)", + nullptr, + 0, + }, + { + SpirvOp::OpFunctionCall, + R"(OpFunctionCall)", + &s_operands[119], + 4, + }, + { + SpirvOp::OpVariable, + R"(OpVariable)", + &s_operands[123], + 4, + }, + { + SpirvOp::OpImageTexelPointer, + R"(OpImageTexelPointer)", + &s_operands[127], + 5, + }, + { + SpirvOp::OpLoad, + R"(OpLoad)", + &s_operands[132], + 4, + }, + { + SpirvOp::OpStore, + R"(OpStore)", + &s_operands[136], + 3, + }, + { + SpirvOp::OpCopyMemory, + R"(OpCopyMemory)", + &s_operands[139], + 4, + }, + { + SpirvOp::OpCopyMemorySized, + R"(OpCopyMemorySized)", + &s_operands[143], + 5, + }, + { + SpirvOp::OpAccessChain, + R"(OpAccessChain)", + &s_operands[148], + 4, + }, + { + SpirvOp::OpInBoundsAccessChain, + R"(OpInBoundsAccessChain)", + &s_operands[152], + 4, + }, + { + SpirvOp::OpPtrAccessChain, + R"(OpPtrAccessChain)", + &s_operands[156], + 5, + }, + { + SpirvOp::OpArrayLength, + R"(OpArrayLength)", + &s_operands[161], + 4, + }, + { + SpirvOp::OpGenericPtrMemSemantics, + R"(OpGenericPtrMemSemantics)", + &s_operands[165], + 3, + }, + { + SpirvOp::OpInBoundsPtrAccessChain, + R"(OpInBoundsPtrAccessChain)", + &s_operands[168], + 5, + }, + { + SpirvOp::OpDecorate, + R"(OpDecorate)", + &s_operands[173], + 2, + }, + { + SpirvOp::OpMemberDecorate, + R"(OpMemberDecorate)", + &s_operands[175], + 3, + }, + { + SpirvOp::OpDecorationGroup, + R"(OpDecorationGroup)", + &s_operands[178], + 1, + }, + { + SpirvOp::OpGroupDecorate, + R"(OpGroupDecorate)", + &s_operands[179], + 2, + }, + { + SpirvOp::OpGroupMemberDecorate, + R"(OpGroupMemberDecorate)", + &s_operands[181], + 2, + }, + { + SpirvOp::OpVectorExtractDynamic, + R"(OpVectorExtractDynamic)", + &s_operands[183], + 4, + }, + { + SpirvOp::OpVectorInsertDynamic, + R"(OpVectorInsertDynamic)", + &s_operands[187], + 5, + }, + { + SpirvOp::OpVectorShuffle, + R"(OpVectorShuffle)", + &s_operands[192], + 5, + }, + { + SpirvOp::OpCompositeConstruct, + R"(OpCompositeConstruct)", + &s_operands[197], + 3, + }, + { + SpirvOp::OpCompositeExtract, + R"(OpCompositeExtract)", + &s_operands[200], + 4, + }, + { + SpirvOp::OpCompositeInsert, + R"(OpCompositeInsert)", + &s_operands[204], + 5, + }, + { + SpirvOp::OpCopyObject, + R"(OpCopyObject)", + &s_operands[209], + 3, + }, + { + SpirvOp::OpTranspose, + R"(OpTranspose)", + &s_operands[212], + 3, + }, + { + SpirvOp::OpSampledImage, + R"(OpSampledImage)", + &s_operands[215], + 4, + }, + { + SpirvOp::OpImageSampleImplicitLod, + R"(OpImageSampleImplicitLod)", + &s_operands[219], + 5, + }, + { + SpirvOp::OpImageSampleExplicitLod, + R"(OpImageSampleExplicitLod)", + &s_operands[224], + 5, + }, + { + SpirvOp::OpImageSampleDrefImplicitLod, + R"(OpImageSampleDrefImplicitLod)", + &s_operands[229], + 6, + }, + { + SpirvOp::OpImageSampleDrefExplicitLod, + R"(OpImageSampleDrefExplicitLod)", + &s_operands[235], + 6, + }, + { + SpirvOp::OpImageSampleProjImplicitLod, + R"(OpImageSampleProjImplicitLod)", + &s_operands[241], + 5, + }, + { + SpirvOp::OpImageSampleProjExplicitLod, + R"(OpImageSampleProjExplicitLod)", + &s_operands[246], + 5, + }, + { + SpirvOp::OpImageSampleProjDrefImplicitLod, + R"(OpImageSampleProjDrefImplicitLod)", + &s_operands[251], + 6, + }, + { + SpirvOp::OpImageSampleProjDrefExplicitLod, + R"(OpImageSampleProjDrefExplicitLod)", + &s_operands[257], + 6, + }, + { + SpirvOp::OpImageFetch, + R"(OpImageFetch)", + &s_operands[263], + 5, + }, + { + SpirvOp::OpImageGather, + R"(OpImageGather)", + &s_operands[268], + 6, + }, + { + SpirvOp::OpImageDrefGather, + R"(OpImageDrefGather)", + &s_operands[274], + 6, + }, + { + SpirvOp::OpImageRead, + R"(OpImageRead)", + &s_operands[280], + 5, + }, + { + SpirvOp::OpImageWrite, + R"(OpImageWrite)", + &s_operands[285], + 4, + }, + { + SpirvOp::OpImage, + R"(OpImage)", + &s_operands[289], + 3, + }, + { + SpirvOp::OpImageQueryFormat, + R"(OpImageQueryFormat)", + &s_operands[292], + 3, + }, + { + SpirvOp::OpImageQueryOrder, + R"(OpImageQueryOrder)", + &s_operands[295], + 3, + }, + { + SpirvOp::OpImageQuerySizeLod, + R"(OpImageQuerySizeLod)", + &s_operands[298], + 4, + }, + { + SpirvOp::OpImageQuerySize, + R"(OpImageQuerySize)", + &s_operands[302], + 3, + }, + { + SpirvOp::OpImageQueryLod, + R"(OpImageQueryLod)", + &s_operands[305], + 4, + }, + { + SpirvOp::OpImageQueryLevels, + R"(OpImageQueryLevels)", + &s_operands[309], + 3, + }, + { + SpirvOp::OpImageQuerySamples, + R"(OpImageQuerySamples)", + &s_operands[312], + 3, + }, + { + SpirvOp::OpConvertFToU, + R"(OpConvertFToU)", + &s_operands[315], + 3, + }, + { + SpirvOp::OpConvertFToS, + R"(OpConvertFToS)", + &s_operands[318], + 3, + }, + { + SpirvOp::OpConvertSToF, + R"(OpConvertSToF)", + &s_operands[321], + 3, + }, + { + SpirvOp::OpConvertUToF, + R"(OpConvertUToF)", + &s_operands[324], + 3, + }, + { + SpirvOp::OpUConvert, + R"(OpUConvert)", + &s_operands[327], + 3, + }, + { + SpirvOp::OpSConvert, + R"(OpSConvert)", + &s_operands[330], + 3, + }, + { + SpirvOp::OpFConvert, + R"(OpFConvert)", + &s_operands[333], + 3, + }, + { + SpirvOp::OpQuantizeToF16, + R"(OpQuantizeToF16)", + &s_operands[336], + 3, + }, + { + SpirvOp::OpConvertPtrToU, + R"(OpConvertPtrToU)", + &s_operands[339], + 3, + }, + { + SpirvOp::OpSatConvertSToU, + R"(OpSatConvertSToU)", + &s_operands[342], + 3, + }, + { + SpirvOp::OpSatConvertUToS, + R"(OpSatConvertUToS)", + &s_operands[345], + 3, + }, + { + SpirvOp::OpConvertUToPtr, + R"(OpConvertUToPtr)", + &s_operands[348], + 3, + }, + { + SpirvOp::OpPtrCastToGeneric, + R"(OpPtrCastToGeneric)", + &s_operands[351], + 3, + }, + { + SpirvOp::OpGenericCastToPtr, + R"(OpGenericCastToPtr)", + &s_operands[354], + 3, + }, + { + SpirvOp::OpGenericCastToPtrExplicit, + R"(OpGenericCastToPtrExplicit)", + &s_operands[357], + 4, + }, + { + SpirvOp::OpBitcast, + R"(OpBitcast)", + &s_operands[361], + 3, + }, + { + SpirvOp::OpSNegate, + R"(OpSNegate)", + &s_operands[364], + 3, + }, + { + SpirvOp::OpFNegate, + R"(OpFNegate)", + &s_operands[367], + 3, + }, + { + SpirvOp::OpIAdd, + R"(OpIAdd)", + &s_operands[370], + 4, + }, + { + SpirvOp::OpFAdd, + R"(OpFAdd)", + &s_operands[374], + 4, + }, + { + SpirvOp::OpISub, + R"(OpISub)", + &s_operands[378], + 4, + }, + { + SpirvOp::OpFSub, + R"(OpFSub)", + &s_operands[382], + 4, + }, + { + SpirvOp::OpIMul, + R"(OpIMul)", + &s_operands[386], + 4, + }, + { + SpirvOp::OpFMul, + R"(OpFMul)", + &s_operands[390], + 4, + }, + { + SpirvOp::OpUDiv, + R"(OpUDiv)", + &s_operands[394], + 4, + }, + { + SpirvOp::OpSDiv, + R"(OpSDiv)", + &s_operands[398], + 4, + }, + { + SpirvOp::OpFDiv, + R"(OpFDiv)", + &s_operands[402], + 4, + }, + { + SpirvOp::OpUMod, + R"(OpUMod)", + &s_operands[406], + 4, + }, + { + SpirvOp::OpSRem, + R"(OpSRem)", + &s_operands[410], + 4, + }, + { + SpirvOp::OpSMod, + R"(OpSMod)", + &s_operands[414], + 4, + }, + { + SpirvOp::OpFRem, + R"(OpFRem)", + &s_operands[418], + 4, + }, + { + SpirvOp::OpFMod, + R"(OpFMod)", + &s_operands[422], + 4, + }, + { + SpirvOp::OpVectorTimesScalar, + R"(OpVectorTimesScalar)", + &s_operands[426], + 4, + }, + { + SpirvOp::OpMatrixTimesScalar, + R"(OpMatrixTimesScalar)", + &s_operands[430], + 4, + }, + { + SpirvOp::OpVectorTimesMatrix, + R"(OpVectorTimesMatrix)", + &s_operands[434], + 4, + }, + { + SpirvOp::OpMatrixTimesVector, + R"(OpMatrixTimesVector)", + &s_operands[438], + 4, + }, + { + SpirvOp::OpMatrixTimesMatrix, + R"(OpMatrixTimesMatrix)", + &s_operands[442], + 4, + }, + { + SpirvOp::OpOuterProduct, + R"(OpOuterProduct)", + &s_operands[446], + 4, + }, + { + SpirvOp::OpDot, + R"(OpDot)", + &s_operands[450], + 4, + }, + { + SpirvOp::OpIAddCarry, + R"(OpIAddCarry)", + &s_operands[454], + 4, + }, + { + SpirvOp::OpISubBorrow, + R"(OpISubBorrow)", + &s_operands[458], + 4, + }, + { + SpirvOp::OpUMulExtended, + R"(OpUMulExtended)", + &s_operands[462], + 4, + }, + { + SpirvOp::OpSMulExtended, + R"(OpSMulExtended)", + &s_operands[466], + 4, + }, + { + SpirvOp::OpAny, + R"(OpAny)", + &s_operands[470], + 3, + }, + { + SpirvOp::OpAll, + R"(OpAll)", + &s_operands[473], + 3, + }, + { + SpirvOp::OpIsNan, + R"(OpIsNan)", + &s_operands[476], + 3, + }, + { + SpirvOp::OpIsInf, + R"(OpIsInf)", + &s_operands[479], + 3, + }, + { + SpirvOp::OpIsFinite, + R"(OpIsFinite)", + &s_operands[482], + 3, + }, + { + SpirvOp::OpIsNormal, + R"(OpIsNormal)", + &s_operands[485], + 3, + }, + { + SpirvOp::OpSignBitSet, + R"(OpSignBitSet)", + &s_operands[488], + 3, + }, + { + SpirvOp::OpLessOrGreater, + R"(OpLessOrGreater)", + &s_operands[491], + 4, + }, + { + SpirvOp::OpOrdered, + R"(OpOrdered)", + &s_operands[495], + 4, + }, + { + SpirvOp::OpUnordered, + R"(OpUnordered)", + &s_operands[499], + 4, + }, + { + SpirvOp::OpLogicalEqual, + R"(OpLogicalEqual)", + &s_operands[503], + 4, + }, + { + SpirvOp::OpLogicalNotEqual, + R"(OpLogicalNotEqual)", + &s_operands[507], + 4, + }, + { + SpirvOp::OpLogicalOr, + R"(OpLogicalOr)", + &s_operands[511], + 4, + }, + { + SpirvOp::OpLogicalAnd, + R"(OpLogicalAnd)", + &s_operands[515], + 4, + }, + { + SpirvOp::OpLogicalNot, + R"(OpLogicalNot)", + &s_operands[519], + 3, + }, + { + SpirvOp::OpSelect, + R"(OpSelect)", + &s_operands[522], + 5, + }, + { + SpirvOp::OpIEqual, + R"(OpIEqual)", + &s_operands[527], + 4, + }, + { + SpirvOp::OpINotEqual, + R"(OpINotEqual)", + &s_operands[531], + 4, + }, + { + SpirvOp::OpUGreaterThan, + R"(OpUGreaterThan)", + &s_operands[535], + 4, + }, + { + SpirvOp::OpSGreaterThan, + R"(OpSGreaterThan)", + &s_operands[539], + 4, + }, + { + SpirvOp::OpUGreaterThanEqual, + R"(OpUGreaterThanEqual)", + &s_operands[543], + 4, + }, + { + SpirvOp::OpSGreaterThanEqual, + R"(OpSGreaterThanEqual)", + &s_operands[547], + 4, + }, + { + SpirvOp::OpULessThan, + R"(OpULessThan)", + &s_operands[551], + 4, + }, + { + SpirvOp::OpSLessThan, + R"(OpSLessThan)", + &s_operands[555], + 4, + }, + { + SpirvOp::OpULessThanEqual, + R"(OpULessThanEqual)", + &s_operands[559], + 4, + }, + { + SpirvOp::OpSLessThanEqual, + R"(OpSLessThanEqual)", + &s_operands[563], + 4, + }, + { + SpirvOp::OpFOrdEqual, + R"(OpFOrdEqual)", + &s_operands[567], + 4, + }, + { + SpirvOp::OpFUnordEqual, + R"(OpFUnordEqual)", + &s_operands[571], + 4, + }, + { + SpirvOp::OpFOrdNotEqual, + R"(OpFOrdNotEqual)", + &s_operands[575], + 4, + }, + { + SpirvOp::OpFUnordNotEqual, + R"(OpFUnordNotEqual)", + &s_operands[579], + 4, + }, + { + SpirvOp::OpFOrdLessThan, + R"(OpFOrdLessThan)", + &s_operands[583], + 4, + }, + { + SpirvOp::OpFUnordLessThan, + R"(OpFUnordLessThan)", + &s_operands[587], + 4, + }, + { + SpirvOp::OpFOrdGreaterThan, + R"(OpFOrdGreaterThan)", + &s_operands[591], + 4, + }, + { + SpirvOp::OpFUnordGreaterThan, + R"(OpFUnordGreaterThan)", + &s_operands[595], + 4, + }, + { + SpirvOp::OpFOrdLessThanEqual, + R"(OpFOrdLessThanEqual)", + &s_operands[599], + 4, + }, + { + SpirvOp::OpFUnordLessThanEqual, + R"(OpFUnordLessThanEqual)", + &s_operands[603], + 4, + }, + { + SpirvOp::OpFOrdGreaterThanEqual, + R"(OpFOrdGreaterThanEqual)", + &s_operands[607], + 4, + }, + { + SpirvOp::OpFUnordGreaterThanEqual, + R"(OpFUnordGreaterThanEqual)", + &s_operands[611], + 4, + }, + { + SpirvOp::OpShiftRightLogical, + R"(OpShiftRightLogical)", + &s_operands[615], + 4, + }, + { + SpirvOp::OpShiftRightArithmetic, + R"(OpShiftRightArithmetic)", + &s_operands[619], + 4, + }, + { + SpirvOp::OpShiftLeftLogical, + R"(OpShiftLeftLogical)", + &s_operands[623], + 4, + }, + { + SpirvOp::OpBitwiseOr, + R"(OpBitwiseOr)", + &s_operands[627], + 4, + }, + { + SpirvOp::OpBitwiseXor, + R"(OpBitwiseXor)", + &s_operands[631], + 4, + }, + { + SpirvOp::OpBitwiseAnd, + R"(OpBitwiseAnd)", + &s_operands[635], + 4, + }, + { + SpirvOp::OpNot, + R"(OpNot)", + &s_operands[639], + 3, + }, + { + SpirvOp::OpBitFieldInsert, + R"(OpBitFieldInsert)", + &s_operands[642], + 6, + }, + { + SpirvOp::OpBitFieldSExtract, + R"(OpBitFieldSExtract)", + &s_operands[648], + 5, + }, + { + SpirvOp::OpBitFieldUExtract, + R"(OpBitFieldUExtract)", + &s_operands[653], + 5, + }, + { + SpirvOp::OpBitReverse, + R"(OpBitReverse)", + &s_operands[658], + 3, + }, + { + SpirvOp::OpBitCount, + R"(OpBitCount)", + &s_operands[661], + 3, + }, + { + SpirvOp::OpDPdx, + R"(OpDPdx)", + &s_operands[664], + 3, + }, + { + SpirvOp::OpDPdy, + R"(OpDPdy)", + &s_operands[667], + 3, + }, + { + SpirvOp::OpFwidth, + R"(OpFwidth)", + &s_operands[670], + 3, + }, + { + SpirvOp::OpDPdxFine, + R"(OpDPdxFine)", + &s_operands[673], + 3, + }, + { + SpirvOp::OpDPdyFine, + R"(OpDPdyFine)", + &s_operands[676], + 3, + }, + { + SpirvOp::OpFwidthFine, + R"(OpFwidthFine)", + &s_operands[679], + 3, + }, + { + SpirvOp::OpDPdxCoarse, + R"(OpDPdxCoarse)", + &s_operands[682], + 3, + }, + { + SpirvOp::OpDPdyCoarse, + R"(OpDPdyCoarse)", + &s_operands[685], + 3, + }, + { + SpirvOp::OpFwidthCoarse, + R"(OpFwidthCoarse)", + &s_operands[688], + 3, + }, + { + SpirvOp::OpEmitVertex, + R"(OpEmitVertex)", + nullptr, + 0, + }, + { + SpirvOp::OpEndPrimitive, + R"(OpEndPrimitive)", + nullptr, + 0, + }, + { + SpirvOp::OpEmitStreamVertex, + R"(OpEmitStreamVertex)", + &s_operands[691], + 1, + }, + { + SpirvOp::OpEndStreamPrimitive, + R"(OpEndStreamPrimitive)", + &s_operands[692], + 1, + }, + { + SpirvOp::OpControlBarrier, + R"(OpControlBarrier)", + &s_operands[693], + 3, + }, + { + SpirvOp::OpMemoryBarrier, + R"(OpMemoryBarrier)", + &s_operands[696], + 2, + }, + { + SpirvOp::OpAtomicLoad, + R"(OpAtomicLoad)", + &s_operands[698], + 5, + }, + { + SpirvOp::OpAtomicStore, + R"(OpAtomicStore)", + &s_operands[703], + 4, + }, + { + SpirvOp::OpAtomicExchange, + R"(OpAtomicExchange)", + &s_operands[707], + 6, + }, + { + SpirvOp::OpAtomicCompareExchange, + R"(OpAtomicCompareExchange)", + &s_operands[713], + 8, + }, + { + SpirvOp::OpAtomicCompareExchangeWeak, + R"(OpAtomicCompareExchangeWeak)", + &s_operands[721], + 8, + }, + { + SpirvOp::OpAtomicIIncrement, + R"(OpAtomicIIncrement)", + &s_operands[729], + 5, + }, + { + SpirvOp::OpAtomicIDecrement, + R"(OpAtomicIDecrement)", + &s_operands[734], + 5, + }, + { + SpirvOp::OpAtomicIAdd, + R"(OpAtomicIAdd)", + &s_operands[739], + 6, + }, + { + SpirvOp::OpAtomicISub, + R"(OpAtomicISub)", + &s_operands[745], + 6, + }, + { + SpirvOp::OpAtomicSMin, + R"(OpAtomicSMin)", + &s_operands[751], + 6, + }, + { + SpirvOp::OpAtomicUMin, + R"(OpAtomicUMin)", + &s_operands[757], + 6, + }, + { + SpirvOp::OpAtomicSMax, + R"(OpAtomicSMax)", + &s_operands[763], + 6, + }, + { + SpirvOp::OpAtomicUMax, + R"(OpAtomicUMax)", + &s_operands[769], + 6, + }, + { + SpirvOp::OpAtomicAnd, + R"(OpAtomicAnd)", + &s_operands[775], + 6, + }, + { + SpirvOp::OpAtomicOr, + R"(OpAtomicOr)", + &s_operands[781], + 6, + }, + { + SpirvOp::OpAtomicXor, + R"(OpAtomicXor)", + &s_operands[787], + 6, + }, + { + SpirvOp::OpPhi, + R"(OpPhi)", + &s_operands[793], + 3, + }, + { + SpirvOp::OpLoopMerge, + R"(OpLoopMerge)", + &s_operands[796], + 3, + }, + { + SpirvOp::OpSelectionMerge, + R"(OpSelectionMerge)", + &s_operands[799], + 2, + }, + { + SpirvOp::OpLabel, + R"(OpLabel)", + &s_operands[801], + 1, + }, + { + SpirvOp::OpBranch, + R"(OpBranch)", + &s_operands[802], + 1, + }, + { + SpirvOp::OpBranchConditional, + R"(OpBranchConditional)", + &s_operands[803], + 4, + }, + { + SpirvOp::OpSwitch, + R"(OpSwitch)", + &s_operands[807], + 3, + }, + { + SpirvOp::OpKill, + R"(OpKill)", + nullptr, + 0, + }, + { + SpirvOp::OpReturn, + R"(OpReturn)", + nullptr, + 0, + }, + { + SpirvOp::OpReturnValue, + R"(OpReturnValue)", + &s_operands[810], + 1, + }, + { + SpirvOp::OpUnreachable, + R"(OpUnreachable)", + nullptr, + 0, + }, + { + SpirvOp::OpLifetimeStart, + R"(OpLifetimeStart)", + &s_operands[811], + 2, + }, + { + SpirvOp::OpLifetimeStop, + R"(OpLifetimeStop)", + &s_operands[813], + 2, + }, + { + SpirvOp::OpGroupAsyncCopy, + R"(OpGroupAsyncCopy)", + &s_operands[815], + 8, + }, + { + SpirvOp::OpGroupWaitEvents, + R"(OpGroupWaitEvents)", + &s_operands[823], + 3, + }, + { + SpirvOp::OpGroupAll, + R"(OpGroupAll)", + &s_operands[826], + 4, + }, + { + SpirvOp::OpGroupAny, + R"(OpGroupAny)", + &s_operands[830], + 4, + }, + { + SpirvOp::OpGroupBroadcast, + R"(OpGroupBroadcast)", + &s_operands[834], + 5, + }, + { + SpirvOp::OpGroupIAdd, + R"(OpGroupIAdd)", + &s_operands[839], + 5, + }, + { + SpirvOp::OpGroupFAdd, + R"(OpGroupFAdd)", + &s_operands[844], + 5, + }, + { + SpirvOp::OpGroupFMin, + R"(OpGroupFMin)", + &s_operands[849], + 5, + }, + { + SpirvOp::OpGroupUMin, + R"(OpGroupUMin)", + &s_operands[854], + 5, + }, + { + SpirvOp::OpGroupSMin, + R"(OpGroupSMin)", + &s_operands[859], + 5, + }, + { + SpirvOp::OpGroupFMax, + R"(OpGroupFMax)", + &s_operands[864], + 5, + }, + { + SpirvOp::OpGroupUMax, + R"(OpGroupUMax)", + &s_operands[869], + 5, + }, + { + SpirvOp::OpGroupSMax, + R"(OpGroupSMax)", + &s_operands[874], + 5, + }, + { + SpirvOp::OpReadPipe, + R"(OpReadPipe)", + &s_operands[879], + 6, + }, + { + SpirvOp::OpWritePipe, + R"(OpWritePipe)", + &s_operands[885], + 6, + }, + { + SpirvOp::OpReservedReadPipe, + R"(OpReservedReadPipe)", + &s_operands[891], + 8, + }, + { + SpirvOp::OpReservedWritePipe, + R"(OpReservedWritePipe)", + &s_operands[899], + 8, + }, + { + SpirvOp::OpReserveReadPipePackets, + R"(OpReserveReadPipePackets)", + &s_operands[907], + 6, + }, + { + SpirvOp::OpReserveWritePipePackets, + R"(OpReserveWritePipePackets)", + &s_operands[913], + 6, + }, + { + SpirvOp::OpCommitReadPipe, + R"(OpCommitReadPipe)", + &s_operands[919], + 4, + }, + { + SpirvOp::OpCommitWritePipe, + R"(OpCommitWritePipe)", + &s_operands[923], + 4, + }, + { + SpirvOp::OpIsValidReserveId, + R"(OpIsValidReserveId)", + &s_operands[927], + 3, + }, + { + SpirvOp::OpGetNumPipePackets, + R"(OpGetNumPipePackets)", + &s_operands[930], + 5, + }, + { + SpirvOp::OpGetMaxPipePackets, + R"(OpGetMaxPipePackets)", + &s_operands[935], + 5, + }, + { + SpirvOp::OpGroupReserveReadPipePackets, + R"(OpGroupReserveReadPipePackets)", + &s_operands[940], + 7, + }, + { + SpirvOp::OpGroupReserveWritePipePackets, + R"(OpGroupReserveWritePipePackets)", + &s_operands[947], + 7, + }, + { + SpirvOp::OpGroupCommitReadPipe, + R"(OpGroupCommitReadPipe)", + &s_operands[954], + 5, + }, + { + SpirvOp::OpGroupCommitWritePipe, + R"(OpGroupCommitWritePipe)", + &s_operands[959], + 5, + }, + { + SpirvOp::OpEnqueueMarker, + R"(OpEnqueueMarker)", + &s_operands[964], + 6, + }, + { + SpirvOp::OpEnqueueKernel, + R"(OpEnqueueKernel)", + &s_operands[970], + 13, + }, + { + SpirvOp::OpGetKernelNDrangeSubGroupCount, + R"(OpGetKernelNDrangeSubGroupCount)", + &s_operands[983], + 7, + }, + { + SpirvOp::OpGetKernelNDrangeMaxSubGroupSize, + R"(OpGetKernelNDrangeMaxSubGroupSize)", + &s_operands[990], + 7, + }, + { + SpirvOp::OpGetKernelWorkGroupSize, + R"(OpGetKernelWorkGroupSize)", + &s_operands[997], + 6, + }, + { + SpirvOp::OpGetKernelPreferredWorkGroupSizeMultiple, + R"(OpGetKernelPreferredWorkGroupSizeMultiple)", + &s_operands[1003], + 6, + }, + { + SpirvOp::OpRetainEvent, + R"(OpRetainEvent)", + &s_operands[1009], + 1, + }, + { + SpirvOp::OpReleaseEvent, + R"(OpReleaseEvent)", + &s_operands[1010], + 1, + }, + { + SpirvOp::OpCreateUserEvent, + R"(OpCreateUserEvent)", + &s_operands[1011], + 2, + }, + { + SpirvOp::OpIsValidEvent, + R"(OpIsValidEvent)", + &s_operands[1013], + 3, + }, + { + SpirvOp::OpSetUserEventStatus, + R"(OpSetUserEventStatus)", + &s_operands[1016], + 2, + }, + { + SpirvOp::OpCaptureEventProfilingInfo, + R"(OpCaptureEventProfilingInfo)", + &s_operands[1018], + 3, + }, + { + SpirvOp::OpGetDefaultQueue, + R"(OpGetDefaultQueue)", + &s_operands[1021], + 2, + }, + { + SpirvOp::OpBuildNDRange, + R"(OpBuildNDRange)", + &s_operands[1023], + 5, + }, + { + SpirvOp::OpImageSparseSampleImplicitLod, + R"(OpImageSparseSampleImplicitLod)", + &s_operands[1028], + 5, + }, + { + SpirvOp::OpImageSparseSampleExplicitLod, + R"(OpImageSparseSampleExplicitLod)", + &s_operands[1033], + 5, + }, + { + SpirvOp::OpImageSparseSampleDrefImplicitLod, + R"(OpImageSparseSampleDrefImplicitLod)", + &s_operands[1038], + 6, + }, + { + SpirvOp::OpImageSparseSampleDrefExplicitLod, + R"(OpImageSparseSampleDrefExplicitLod)", + &s_operands[1044], + 6, + }, + { + SpirvOp::OpImageSparseSampleProjImplicitLod, + R"(OpImageSparseSampleProjImplicitLod)", + &s_operands[1050], + 5, + }, + { + SpirvOp::OpImageSparseSampleProjExplicitLod, + R"(OpImageSparseSampleProjExplicitLod)", + &s_operands[1055], + 5, + }, + { + SpirvOp::OpImageSparseSampleProjDrefImplicitLod, + R"(OpImageSparseSampleProjDrefImplicitLod)", + &s_operands[1060], + 6, + }, + { + SpirvOp::OpImageSparseSampleProjDrefExplicitLod, + R"(OpImageSparseSampleProjDrefExplicitLod)", + &s_operands[1066], + 6, + }, + { + SpirvOp::OpImageSparseFetch, + R"(OpImageSparseFetch)", + &s_operands[1072], + 5, + }, + { + SpirvOp::OpImageSparseGather, + R"(OpImageSparseGather)", + &s_operands[1077], + 6, + }, + { + SpirvOp::OpImageSparseDrefGather, + R"(OpImageSparseDrefGather)", + &s_operands[1083], + 6, + }, + { + SpirvOp::OpImageSparseTexelsResident, + R"(OpImageSparseTexelsResident)", + &s_operands[1089], + 3, + }, + { + SpirvOp::OpNoLine, + R"(OpNoLine)", + nullptr, + 0, + }, + { + SpirvOp::OpAtomicFlagTestAndSet, + R"(OpAtomicFlagTestAndSet)", + &s_operands[1092], + 5, + }, + { + SpirvOp::OpAtomicFlagClear, + R"(OpAtomicFlagClear)", + &s_operands[1097], + 3, + }, + { + SpirvOp::OpImageSparseRead, + R"(OpImageSparseRead)", + &s_operands[1100], + 5, + }, + { + SpirvOp::OpSizeOf, + R"(OpSizeOf)", + &s_operands[1105], + 3, + }, + { + SpirvOp::OpTypePipeStorage, + R"(OpTypePipeStorage)", + &s_operands[1108], + 1, + }, + { + SpirvOp::OpConstantPipeStorage, + R"(OpConstantPipeStorage)", + &s_operands[1109], + 5, + }, + { + SpirvOp::OpCreatePipeFromPipeStorage, + R"(OpCreatePipeFromPipeStorage)", + &s_operands[1114], + 3, + }, + { + SpirvOp::OpGetKernelLocalSizeForSubgroupCount, + R"(OpGetKernelLocalSizeForSubgroupCount)", + &s_operands[1117], + 7, + }, + { + SpirvOp::OpGetKernelMaxNumSubgroups, + R"(OpGetKernelMaxNumSubgroups)", + &s_operands[1124], + 6, + }, + { + SpirvOp::OpTypeNamedBarrier, + R"(OpTypeNamedBarrier)", + &s_operands[1130], + 1, + }, + { + SpirvOp::OpNamedBarrierInitialize, + R"(OpNamedBarrierInitialize)", + &s_operands[1131], + 3, + }, + { + SpirvOp::OpMemoryNamedBarrier, + R"(OpMemoryNamedBarrier)", + &s_operands[1134], + 3, + }, + { + SpirvOp::OpModuleProcessed, + R"(OpModuleProcessed)", + &s_operands[1137], + 1, + }, + { + SpirvOp::OpExecutionModeId, + R"(OpExecutionModeId)", + &s_operands[1138], + 2, + }, + { + SpirvOp::OpDecorateId, + R"(OpDecorateId)", + &s_operands[1140], + 2, + }, + { + SpirvOp::OpGroupNonUniformElect, + R"(OpGroupNonUniformElect)", + &s_operands[1142], + 3, + }, + { + SpirvOp::OpGroupNonUniformAll, + R"(OpGroupNonUniformAll)", + &s_operands[1145], + 4, + }, + { + SpirvOp::OpGroupNonUniformAny, + R"(OpGroupNonUniformAny)", + &s_operands[1149], + 4, + }, + { + SpirvOp::OpGroupNonUniformAllEqual, + R"(OpGroupNonUniformAllEqual)", + &s_operands[1153], + 4, + }, + { + SpirvOp::OpGroupNonUniformBroadcast, + R"(OpGroupNonUniformBroadcast)", + &s_operands[1157], + 5, + }, + { + SpirvOp::OpGroupNonUniformBroadcastFirst, + R"(OpGroupNonUniformBroadcastFirst)", + &s_operands[1162], + 4, + }, + { + SpirvOp::OpGroupNonUniformBallot, + R"(OpGroupNonUniformBallot)", + &s_operands[1166], + 4, + }, + { + SpirvOp::OpGroupNonUniformInverseBallot, + R"(OpGroupNonUniformInverseBallot)", + &s_operands[1170], + 4, + }, + { + SpirvOp::OpGroupNonUniformBallotBitExtract, + R"(OpGroupNonUniformBallotBitExtract)", + &s_operands[1174], + 5, + }, + { + SpirvOp::OpGroupNonUniformBallotBitCount, + R"(OpGroupNonUniformBallotBitCount)", + &s_operands[1179], + 5, + }, + { + SpirvOp::OpGroupNonUniformBallotFindLSB, + R"(OpGroupNonUniformBallotFindLSB)", + &s_operands[1184], + 4, + }, + { + SpirvOp::OpGroupNonUniformBallotFindMSB, + R"(OpGroupNonUniformBallotFindMSB)", + &s_operands[1188], + 4, + }, + { + SpirvOp::OpGroupNonUniformShuffle, + R"(OpGroupNonUniformShuffle)", + &s_operands[1192], + 5, + }, + { + SpirvOp::OpGroupNonUniformShuffleXor, + R"(OpGroupNonUniformShuffleXor)", + &s_operands[1197], + 5, + }, + { + SpirvOp::OpGroupNonUniformShuffleUp, + R"(OpGroupNonUniformShuffleUp)", + &s_operands[1202], + 5, + }, + { + SpirvOp::OpGroupNonUniformShuffleDown, + R"(OpGroupNonUniformShuffleDown)", + &s_operands[1207], + 5, + }, + { + SpirvOp::OpGroupNonUniformIAdd, + R"(OpGroupNonUniformIAdd)", + &s_operands[1212], + 6, + }, + { + SpirvOp::OpGroupNonUniformFAdd, + R"(OpGroupNonUniformFAdd)", + &s_operands[1218], + 6, + }, + { + SpirvOp::OpGroupNonUniformIMul, + R"(OpGroupNonUniformIMul)", + &s_operands[1224], + 6, + }, + { + SpirvOp::OpGroupNonUniformFMul, + R"(OpGroupNonUniformFMul)", + &s_operands[1230], + 6, + }, + { + SpirvOp::OpGroupNonUniformSMin, + R"(OpGroupNonUniformSMin)", + &s_operands[1236], + 6, + }, + { + SpirvOp::OpGroupNonUniformUMin, + R"(OpGroupNonUniformUMin)", + &s_operands[1242], + 6, + }, + { + SpirvOp::OpGroupNonUniformFMin, + R"(OpGroupNonUniformFMin)", + &s_operands[1248], + 6, + }, + { + SpirvOp::OpGroupNonUniformSMax, + R"(OpGroupNonUniformSMax)", + &s_operands[1254], + 6, + }, + { + SpirvOp::OpGroupNonUniformUMax, + R"(OpGroupNonUniformUMax)", + &s_operands[1260], + 6, + }, + { + SpirvOp::OpGroupNonUniformFMax, + R"(OpGroupNonUniformFMax)", + &s_operands[1266], + 6, + }, + { + SpirvOp::OpGroupNonUniformBitwiseAnd, + R"(OpGroupNonUniformBitwiseAnd)", + &s_operands[1272], + 6, + }, + { + SpirvOp::OpGroupNonUniformBitwiseOr, + R"(OpGroupNonUniformBitwiseOr)", + &s_operands[1278], + 6, + }, + { + SpirvOp::OpGroupNonUniformBitwiseXor, + R"(OpGroupNonUniformBitwiseXor)", + &s_operands[1284], + 6, + }, + { + SpirvOp::OpGroupNonUniformLogicalAnd, + R"(OpGroupNonUniformLogicalAnd)", + &s_operands[1290], + 6, + }, + { + SpirvOp::OpGroupNonUniformLogicalOr, + R"(OpGroupNonUniformLogicalOr)", + &s_operands[1296], + 6, + }, + { + SpirvOp::OpGroupNonUniformLogicalXor, + R"(OpGroupNonUniformLogicalXor)", + &s_operands[1302], + 6, + }, + { + SpirvOp::OpGroupNonUniformQuadBroadcast, + R"(OpGroupNonUniformQuadBroadcast)", + &s_operands[1308], + 5, + }, + { + SpirvOp::OpGroupNonUniformQuadSwap, + R"(OpGroupNonUniformQuadSwap)", + &s_operands[1313], + 5, + }, + { + SpirvOp::OpCopyLogical, + R"(OpCopyLogical)", + &s_operands[1318], + 3, + }, + { + SpirvOp::OpPtrEqual, + R"(OpPtrEqual)", + &s_operands[1321], + 4, + }, + { + SpirvOp::OpPtrNotEqual, + R"(OpPtrNotEqual)", + &s_operands[1325], + 4, + }, + { + SpirvOp::OpPtrDiff, + R"(OpPtrDiff)", + &s_operands[1329], + 4, + }, + { + SpirvOp::OpTerminateInvocation, + R"(OpTerminateInvocation)", + nullptr, + 0, + }, + { + SpirvOp::OpSubgroupBallotKHR, + R"(OpSubgroupBallotKHR)", + &s_operands[1333], + 3, + }, + { + SpirvOp::OpSubgroupFirstInvocationKHR, + R"(OpSubgroupFirstInvocationKHR)", + &s_operands[1336], + 3, + }, + { + SpirvOp::OpSubgroupAllKHR, + R"(OpSubgroupAllKHR)", + &s_operands[1339], + 3, + }, + { + SpirvOp::OpSubgroupAnyKHR, + R"(OpSubgroupAnyKHR)", + &s_operands[1342], + 3, + }, + { + SpirvOp::OpSubgroupAllEqualKHR, + R"(OpSubgroupAllEqualKHR)", + &s_operands[1345], + 3, + }, + { + SpirvOp::OpSubgroupReadInvocationKHR, + R"(OpSubgroupReadInvocationKHR)", + &s_operands[1348], + 4, + }, + { + SpirvOp::OpTypeRayQueryProvisionalKHR, + R"(OpTypeRayQueryProvisionalKHR)", + &s_operands[1352], + 1, + }, + { + SpirvOp::OpRayQueryInitializeKHR, + R"(OpRayQueryInitializeKHR)", + &s_operands[1353], + 8, + }, + { + SpirvOp::OpRayQueryTerminateKHR, + R"(OpRayQueryTerminateKHR)", + &s_operands[1361], + 1, + }, + { + SpirvOp::OpRayQueryGenerateIntersectionKHR, + R"(OpRayQueryGenerateIntersectionKHR)", + &s_operands[1362], + 2, + }, + { + SpirvOp::OpRayQueryConfirmIntersectionKHR, + R"(OpRayQueryConfirmIntersectionKHR)", + &s_operands[1364], + 1, + }, + { + SpirvOp::OpRayQueryProceedKHR, + R"(OpRayQueryProceedKHR)", + &s_operands[1365], + 3, + }, + { + SpirvOp::OpRayQueryGetIntersectionTypeKHR, + R"(OpRayQueryGetIntersectionTypeKHR)", + &s_operands[1368], + 4, + }, + { + SpirvOp::OpGroupIAddNonUniformAMD, + R"(OpGroupIAddNonUniformAMD)", + &s_operands[1372], + 5, + }, + { + SpirvOp::OpGroupFAddNonUniformAMD, + R"(OpGroupFAddNonUniformAMD)", + &s_operands[1377], + 5, + }, + { + SpirvOp::OpGroupFMinNonUniformAMD, + R"(OpGroupFMinNonUniformAMD)", + &s_operands[1382], + 5, + }, + { + SpirvOp::OpGroupUMinNonUniformAMD, + R"(OpGroupUMinNonUniformAMD)", + &s_operands[1387], + 5, + }, + { + SpirvOp::OpGroupSMinNonUniformAMD, + R"(OpGroupSMinNonUniformAMD)", + &s_operands[1392], + 5, + }, + { + SpirvOp::OpGroupFMaxNonUniformAMD, + R"(OpGroupFMaxNonUniformAMD)", + &s_operands[1397], + 5, + }, + { + SpirvOp::OpGroupUMaxNonUniformAMD, + R"(OpGroupUMaxNonUniformAMD)", + &s_operands[1402], + 5, + }, + { + SpirvOp::OpGroupSMaxNonUniformAMD, + R"(OpGroupSMaxNonUniformAMD)", + &s_operands[1407], + 5, + }, + { + SpirvOp::OpFragmentMaskFetchAMD, + R"(OpFragmentMaskFetchAMD)", + &s_operands[1412], + 4, + }, + { + SpirvOp::OpFragmentFetchAMD, + R"(OpFragmentFetchAMD)", + &s_operands[1416], + 5, + }, + { + SpirvOp::OpReadClockKHR, + R"(OpReadClockKHR)", + &s_operands[1421], + 3, + }, + { + SpirvOp::OpImageSampleFootprintNV, + R"(OpImageSampleFootprintNV)", + &s_operands[1424], + 7, + }, + { + SpirvOp::OpGroupNonUniformPartitionNV, + R"(OpGroupNonUniformPartitionNV)", + &s_operands[1431], + 3, + }, + { + SpirvOp::OpWritePackedPrimitiveIndices4x8NV, + R"(OpWritePackedPrimitiveIndices4x8NV)", + &s_operands[1434], + 2, + }, + { + SpirvOp::OpReportIntersectionKHR, + R"(OpReportIntersectionKHR)", + &s_operands[1436], + 4, + }, + { + SpirvOp::OpIgnoreIntersectionKHR, + R"(OpIgnoreIntersectionKHR)", + nullptr, + 0, + }, + { + SpirvOp::OpTerminateRayKHR, + R"(OpTerminateRayKHR)", + nullptr, + 0, + }, + { + SpirvOp::OpTraceRayKHR, + R"(OpTraceRayKHR)", + &s_operands[1440], + 11, + }, + { + SpirvOp::OpTypeAccelerationStructureKHR, + R"(OpTypeAccelerationStructureKHR)", + &s_operands[1451], + 1, + }, + { + SpirvOp::OpExecuteCallableKHR, + R"(OpExecuteCallableKHR)", + &s_operands[1452], + 2, + }, + { + SpirvOp::OpTypeCooperativeMatrixNV, + R"(OpTypeCooperativeMatrixNV)", + &s_operands[1454], + 5, + }, + { + SpirvOp::OpCooperativeMatrixLoadNV, + R"(OpCooperativeMatrixLoadNV)", + &s_operands[1459], + 6, + }, + { + SpirvOp::OpCooperativeMatrixStoreNV, + R"(OpCooperativeMatrixStoreNV)", + &s_operands[1465], + 5, + }, + { + SpirvOp::OpCooperativeMatrixMulAddNV, + R"(OpCooperativeMatrixMulAddNV)", + &s_operands[1470], + 5, + }, + { + SpirvOp::OpCooperativeMatrixLengthNV, + R"(OpCooperativeMatrixLengthNV)", + &s_operands[1475], + 3, + }, + { + SpirvOp::OpBeginInvocationInterlockEXT, + R"(OpBeginInvocationInterlockEXT)", + nullptr, + 0, + }, + { + SpirvOp::OpEndInvocationInterlockEXT, + R"(OpEndInvocationInterlockEXT)", + nullptr, + 0, + }, + { + SpirvOp::OpDemoteToHelperInvocationEXT, + R"(OpDemoteToHelperInvocationEXT)", + nullptr, + 0, + }, + { + SpirvOp::OpIsHelperInvocationEXT, + R"(OpIsHelperInvocationEXT)", + &s_operands[1478], + 2, + }, + { + SpirvOp::OpSubgroupShuffleINTEL, + R"(OpSubgroupShuffleINTEL)", + &s_operands[1480], + 4, + }, + { + SpirvOp::OpSubgroupShuffleDownINTEL, + R"(OpSubgroupShuffleDownINTEL)", + &s_operands[1484], + 5, + }, + { + SpirvOp::OpSubgroupShuffleUpINTEL, + R"(OpSubgroupShuffleUpINTEL)", + &s_operands[1489], + 5, + }, + { + SpirvOp::OpSubgroupShuffleXorINTEL, + R"(OpSubgroupShuffleXorINTEL)", + &s_operands[1494], + 4, + }, + { + SpirvOp::OpSubgroupBlockReadINTEL, + R"(OpSubgroupBlockReadINTEL)", + &s_operands[1498], + 3, + }, + { + SpirvOp::OpSubgroupBlockWriteINTEL, + R"(OpSubgroupBlockWriteINTEL)", + &s_operands[1501], + 2, + }, + { + SpirvOp::OpSubgroupImageBlockReadINTEL, + R"(OpSubgroupImageBlockReadINTEL)", + &s_operands[1503], + 4, + }, + { + SpirvOp::OpSubgroupImageBlockWriteINTEL, + R"(OpSubgroupImageBlockWriteINTEL)", + &s_operands[1507], + 3, + }, + { + SpirvOp::OpSubgroupImageMediaBlockReadINTEL, + R"(OpSubgroupImageMediaBlockReadINTEL)", + &s_operands[1510], + 6, + }, + { + SpirvOp::OpSubgroupImageMediaBlockWriteINTEL, + R"(OpSubgroupImageMediaBlockWriteINTEL)", + &s_operands[1516], + 5, + }, + { + SpirvOp::OpUCountLeadingZerosINTEL, + R"(OpUCountLeadingZerosINTEL)", + &s_operands[1521], + 3, + }, + { + SpirvOp::OpUCountTrailingZerosINTEL, + R"(OpUCountTrailingZerosINTEL)", + &s_operands[1524], + 3, + }, + { + SpirvOp::OpAbsISubINTEL, + R"(OpAbsISubINTEL)", + &s_operands[1527], + 4, + }, + { + SpirvOp::OpAbsUSubINTEL, + R"(OpAbsUSubINTEL)", + &s_operands[1531], + 4, + }, + { + SpirvOp::OpIAddSatINTEL, + R"(OpIAddSatINTEL)", + &s_operands[1535], + 4, + }, + { + SpirvOp::OpUAddSatINTEL, + R"(OpUAddSatINTEL)", + &s_operands[1539], + 4, + }, + { + SpirvOp::OpIAverageINTEL, + R"(OpIAverageINTEL)", + &s_operands[1543], + 4, + }, + { + SpirvOp::OpUAverageINTEL, + R"(OpUAverageINTEL)", + &s_operands[1547], + 4, + }, + { + SpirvOp::OpIAverageRoundedINTEL, + R"(OpIAverageRoundedINTEL)", + &s_operands[1551], + 4, + }, + { + SpirvOp::OpUAverageRoundedINTEL, + R"(OpUAverageRoundedINTEL)", + &s_operands[1555], + 4, + }, + { + SpirvOp::OpISubSatINTEL, + R"(OpISubSatINTEL)", + &s_operands[1559], + 4, + }, + { + SpirvOp::OpUSubSatINTEL, + R"(OpUSubSatINTEL)", + &s_operands[1563], + 4, + }, + { + SpirvOp::OpIMul32x16INTEL, + R"(OpIMul32x16INTEL)", + &s_operands[1567], + 4, + }, + { + SpirvOp::OpUMul32x16INTEL, + R"(OpUMul32x16INTEL)", + &s_operands[1571], + 4, + }, + { + SpirvOp::OpFunctionPointerINTEL, + R"(OpFunctionPointerINTEL)", + &s_operands[1575], + 3, + }, + { + SpirvOp::OpFunctionPointerCallINTEL, + R"(OpFunctionPointerCallINTEL)", + &s_operands[1578], + 3, + }, + { + SpirvOp::OpDecorateStringGOOGLE, + R"(OpDecorateStringGOOGLE)", + &s_operands[1581], + 2, + }, + { + SpirvOp::OpMemberDecorateStringGOOGLE, + R"(OpMemberDecorateStringGOOGLE)", + &s_operands[1583], + 3, + }, + { + SpirvOp::OpVmeImageINTEL, + R"(OpVmeImageINTEL)", + &s_operands[1586], + 4, + }, + { + SpirvOp::OpTypeVmeImageINTEL, + R"(OpTypeVmeImageINTEL)", + &s_operands[1590], + 2, + }, + { + SpirvOp::OpTypeAvcImePayloadINTEL, + R"(OpTypeAvcImePayloadINTEL)", + &s_operands[1592], + 1, + }, + { + SpirvOp::OpTypeAvcRefPayloadINTEL, + R"(OpTypeAvcRefPayloadINTEL)", + &s_operands[1593], + 1, + }, + { + SpirvOp::OpTypeAvcSicPayloadINTEL, + R"(OpTypeAvcSicPayloadINTEL)", + &s_operands[1594], + 1, + }, + { + SpirvOp::OpTypeAvcMcePayloadINTEL, + R"(OpTypeAvcMcePayloadINTEL)", + &s_operands[1595], + 1, + }, + { + SpirvOp::OpTypeAvcMceResultINTEL, + R"(OpTypeAvcMceResultINTEL)", + &s_operands[1596], + 1, + }, + { + SpirvOp::OpTypeAvcImeResultINTEL, + R"(OpTypeAvcImeResultINTEL)", + &s_operands[1597], + 1, + }, + { + SpirvOp::OpTypeAvcImeResultSingleReferenceStreamoutINTEL, + R"(OpTypeAvcImeResultSingleReferenceStreamoutINTEL)", + &s_operands[1598], + 1, + }, + { + SpirvOp::OpTypeAvcImeResultDualReferenceStreamoutINTEL, + R"(OpTypeAvcImeResultDualReferenceStreamoutINTEL)", + &s_operands[1599], + 1, + }, + { + SpirvOp::OpTypeAvcImeSingleReferenceStreaminINTEL, + R"(OpTypeAvcImeSingleReferenceStreaminINTEL)", + &s_operands[1600], + 1, + }, + { + SpirvOp::OpTypeAvcImeDualReferenceStreaminINTEL, + R"(OpTypeAvcImeDualReferenceStreaminINTEL)", + &s_operands[1601], + 1, + }, + { + SpirvOp::OpTypeAvcRefResultINTEL, + R"(OpTypeAvcRefResultINTEL)", + &s_operands[1602], + 1, + }, + { + SpirvOp::OpTypeAvcSicResultINTEL, + R"(OpTypeAvcSicResultINTEL)", + &s_operands[1603], + 1, + }, + { + SpirvOp::OpSubgroupAvcMceGetDefaultInterBaseMultiReferencePenaltyINTEL, + R"(OpSubgroupAvcMceGetDefaultInterBaseMultiReferencePenaltyINTEL)", + &s_operands[1604], + 4, + }, + { + SpirvOp::OpSubgroupAvcMceSetInterBaseMultiReferencePenaltyINTEL, + R"(OpSubgroupAvcMceSetInterBaseMultiReferencePenaltyINTEL)", + &s_operands[1608], + 4, + }, + { + SpirvOp::OpSubgroupAvcMceGetDefaultInterShapePenaltyINTEL, + R"(OpSubgroupAvcMceGetDefaultInterShapePenaltyINTEL)", + &s_operands[1612], + 4, + }, + { + SpirvOp::OpSubgroupAvcMceSetInterShapePenaltyINTEL, + R"(OpSubgroupAvcMceSetInterShapePenaltyINTEL)", + &s_operands[1616], + 4, + }, + { + SpirvOp::OpSubgroupAvcMceGetDefaultInterDirectionPenaltyINTEL, + R"(OpSubgroupAvcMceGetDefaultInterDirectionPenaltyINTEL)", + &s_operands[1620], + 4, + }, + { + SpirvOp::OpSubgroupAvcMceSetInterDirectionPenaltyINTEL, + R"(OpSubgroupAvcMceSetInterDirectionPenaltyINTEL)", + &s_operands[1624], + 4, + }, + { + SpirvOp::OpSubgroupAvcMceGetDefaultIntraLumaShapePenaltyINTEL, + R"(OpSubgroupAvcMceGetDefaultIntraLumaShapePenaltyINTEL)", + &s_operands[1628], + 4, + }, + { + SpirvOp::OpSubgroupAvcMceGetDefaultInterMotionVectorCostTableINTEL, + R"(OpSubgroupAvcMceGetDefaultInterMotionVectorCostTableINTEL)", + &s_operands[1632], + 4, + }, + { + SpirvOp::OpSubgroupAvcMceGetDefaultHighPenaltyCostTableINTEL, + R"(OpSubgroupAvcMceGetDefaultHighPenaltyCostTableINTEL)", + &s_operands[1636], + 2, + }, + { + SpirvOp::OpSubgroupAvcMceGetDefaultMediumPenaltyCostTableINTEL, + R"(OpSubgroupAvcMceGetDefaultMediumPenaltyCostTableINTEL)", + &s_operands[1638], + 2, + }, + { + SpirvOp::OpSubgroupAvcMceGetDefaultLowPenaltyCostTableINTEL, + R"(OpSubgroupAvcMceGetDefaultLowPenaltyCostTableINTEL)", + &s_operands[1640], + 2, + }, + { + SpirvOp::OpSubgroupAvcMceSetMotionVectorCostFunctionINTEL, + R"(OpSubgroupAvcMceSetMotionVectorCostFunctionINTEL)", + &s_operands[1642], + 6, + }, + { + SpirvOp::OpSubgroupAvcMceGetDefaultIntraLumaModePenaltyINTEL, + R"(OpSubgroupAvcMceGetDefaultIntraLumaModePenaltyINTEL)", + &s_operands[1648], + 4, + }, + { + SpirvOp::OpSubgroupAvcMceGetDefaultNonDcLumaIntraPenaltyINTEL, + R"(OpSubgroupAvcMceGetDefaultNonDcLumaIntraPenaltyINTEL)", + &s_operands[1652], + 2, + }, + { + SpirvOp::OpSubgroupAvcMceGetDefaultIntraChromaModeBasePenaltyINTEL, + R"(OpSubgroupAvcMceGetDefaultIntraChromaModeBasePenaltyINTEL)", + &s_operands[1654], + 2, + }, + { + SpirvOp::OpSubgroupAvcMceSetAcOnlyHaarINTEL, + R"(OpSubgroupAvcMceSetAcOnlyHaarINTEL)", + &s_operands[1656], + 3, + }, + { + SpirvOp::OpSubgroupAvcMceSetSourceInterlacedFieldPolarityINTEL, + R"(OpSubgroupAvcMceSetSourceInterlacedFieldPolarityINTEL)", + &s_operands[1659], + 4, + }, + { + SpirvOp::OpSubgroupAvcMceSetSingleReferenceInterlacedFieldPolarityINTEL, + R"(OpSubgroupAvcMceSetSingleReferenceInterlacedFieldPolarityINTEL)", + &s_operands[1663], + 4, + }, + { + SpirvOp::OpSubgroupAvcMceSetDualReferenceInterlacedFieldPolaritiesINTEL, + R"(OpSubgroupAvcMceSetDualReferenceInterlacedFieldPolaritiesINTEL)", + &s_operands[1667], + 5, + }, + { + SpirvOp::OpSubgroupAvcMceConvertToImePayloadINTEL, + R"(OpSubgroupAvcMceConvertToImePayloadINTEL)", + &s_operands[1672], + 3, + }, + { + SpirvOp::OpSubgroupAvcMceConvertToImeResultINTEL, + R"(OpSubgroupAvcMceConvertToImeResultINTEL)", + &s_operands[1675], + 3, + }, + { + SpirvOp::OpSubgroupAvcMceConvertToRefPayloadINTEL, + R"(OpSubgroupAvcMceConvertToRefPayloadINTEL)", + &s_operands[1678], + 3, + }, + { + SpirvOp::OpSubgroupAvcMceConvertToRefResultINTEL, + R"(OpSubgroupAvcMceConvertToRefResultINTEL)", + &s_operands[1681], + 3, + }, + { + SpirvOp::OpSubgroupAvcMceConvertToSicPayloadINTEL, + R"(OpSubgroupAvcMceConvertToSicPayloadINTEL)", + &s_operands[1684], + 3, + }, + { + SpirvOp::OpSubgroupAvcMceConvertToSicResultINTEL, + R"(OpSubgroupAvcMceConvertToSicResultINTEL)", + &s_operands[1687], + 3, + }, + { + SpirvOp::OpSubgroupAvcMceGetMotionVectorsINTEL, + R"(OpSubgroupAvcMceGetMotionVectorsINTEL)", + &s_operands[1690], + 3, + }, + { + SpirvOp::OpSubgroupAvcMceGetInterDistortionsINTEL, + R"(OpSubgroupAvcMceGetInterDistortionsINTEL)", + &s_operands[1693], + 3, + }, + { + SpirvOp::OpSubgroupAvcMceGetBestInterDistortionsINTEL, + R"(OpSubgroupAvcMceGetBestInterDistortionsINTEL)", + &s_operands[1696], + 3, + }, + { + SpirvOp::OpSubgroupAvcMceGetInterMajorShapeINTEL, + R"(OpSubgroupAvcMceGetInterMajorShapeINTEL)", + &s_operands[1699], + 3, + }, + { + SpirvOp::OpSubgroupAvcMceGetInterMinorShapeINTEL, + R"(OpSubgroupAvcMceGetInterMinorShapeINTEL)", + &s_operands[1702], + 3, + }, + { + SpirvOp::OpSubgroupAvcMceGetInterDirectionsINTEL, + R"(OpSubgroupAvcMceGetInterDirectionsINTEL)", + &s_operands[1705], + 3, + }, + { + SpirvOp::OpSubgroupAvcMceGetInterMotionVectorCountINTEL, + R"(OpSubgroupAvcMceGetInterMotionVectorCountINTEL)", + &s_operands[1708], + 3, + }, + { + SpirvOp::OpSubgroupAvcMceGetInterReferenceIdsINTEL, + R"(OpSubgroupAvcMceGetInterReferenceIdsINTEL)", + &s_operands[1711], + 3, + }, + { + SpirvOp::OpSubgroupAvcMceGetInterReferenceInterlacedFieldPolaritiesINTEL, + R"(OpSubgroupAvcMceGetInterReferenceInterlacedFieldPolaritiesINTEL)", + &s_operands[1714], + 5, + }, + { + SpirvOp::OpSubgroupAvcImeInitializeINTEL, + R"(OpSubgroupAvcImeInitializeINTEL)", + &s_operands[1719], + 5, + }, + { + SpirvOp::OpSubgroupAvcImeSetSingleReferenceINTEL, + R"(OpSubgroupAvcImeSetSingleReferenceINTEL)", + &s_operands[1724], + 5, + }, + { + SpirvOp::OpSubgroupAvcImeSetDualReferenceINTEL, + R"(OpSubgroupAvcImeSetDualReferenceINTEL)", + &s_operands[1729], + 6, + }, + { + SpirvOp::OpSubgroupAvcImeRefWindowSizeINTEL, + R"(OpSubgroupAvcImeRefWindowSizeINTEL)", + &s_operands[1735], + 4, + }, + { + SpirvOp::OpSubgroupAvcImeAdjustRefOffsetINTEL, + R"(OpSubgroupAvcImeAdjustRefOffsetINTEL)", + &s_operands[1739], + 6, + }, + { + SpirvOp::OpSubgroupAvcImeConvertToMcePayloadINTEL, + R"(OpSubgroupAvcImeConvertToMcePayloadINTEL)", + &s_operands[1745], + 3, + }, + { + SpirvOp::OpSubgroupAvcImeSetMaxMotionVectorCountINTEL, + R"(OpSubgroupAvcImeSetMaxMotionVectorCountINTEL)", + &s_operands[1748], + 4, + }, + { + SpirvOp::OpSubgroupAvcImeSetUnidirectionalMixDisableINTEL, + R"(OpSubgroupAvcImeSetUnidirectionalMixDisableINTEL)", + &s_operands[1752], + 3, + }, + { + SpirvOp::OpSubgroupAvcImeSetEarlySearchTerminationThresholdINTEL, + R"(OpSubgroupAvcImeSetEarlySearchTerminationThresholdINTEL)", + &s_operands[1755], + 4, + }, + { + SpirvOp::OpSubgroupAvcImeSetWeightedSadINTEL, + R"(OpSubgroupAvcImeSetWeightedSadINTEL)", + &s_operands[1759], + 4, + }, + { + SpirvOp::OpSubgroupAvcImeEvaluateWithSingleReferenceINTEL, + R"(OpSubgroupAvcImeEvaluateWithSingleReferenceINTEL)", + &s_operands[1763], + 5, + }, + { + SpirvOp::OpSubgroupAvcImeEvaluateWithDualReferenceINTEL, + R"(OpSubgroupAvcImeEvaluateWithDualReferenceINTEL)", + &s_operands[1768], + 6, + }, + { + SpirvOp::OpSubgroupAvcImeEvaluateWithSingleReferenceStreaminINTEL, + R"(OpSubgroupAvcImeEvaluateWithSingleReferenceStreaminINTEL)", + &s_operands[1774], + 6, + }, + { + SpirvOp::OpSubgroupAvcImeEvaluateWithDualReferenceStreaminINTEL, + R"(OpSubgroupAvcImeEvaluateWithDualReferenceStreaminINTEL)", + &s_operands[1780], + 7, + }, + { + SpirvOp::OpSubgroupAvcImeEvaluateWithSingleReferenceStreamoutINTEL, + R"(OpSubgroupAvcImeEvaluateWithSingleReferenceStreamoutINTEL)", + &s_operands[1787], + 5, + }, + { + SpirvOp::OpSubgroupAvcImeEvaluateWithDualReferenceStreamoutINTEL, + R"(OpSubgroupAvcImeEvaluateWithDualReferenceStreamoutINTEL)", + &s_operands[1792], + 6, + }, + { + SpirvOp::OpSubgroupAvcImeEvaluateWithSingleReferenceStreaminoutINTEL, + R"(OpSubgroupAvcImeEvaluateWithSingleReferenceStreaminoutINTEL)", + &s_operands[1798], + 6, + }, + { + SpirvOp::OpSubgroupAvcImeEvaluateWithDualReferenceStreaminoutINTEL, + R"(OpSubgroupAvcImeEvaluateWithDualReferenceStreaminoutINTEL)", + &s_operands[1804], + 7, + }, + { + SpirvOp::OpSubgroupAvcImeConvertToMceResultINTEL, + R"(OpSubgroupAvcImeConvertToMceResultINTEL)", + &s_operands[1811], + 3, + }, + { + SpirvOp::OpSubgroupAvcImeGetSingleReferenceStreaminINTEL, + R"(OpSubgroupAvcImeGetSingleReferenceStreaminINTEL)", + &s_operands[1814], + 3, + }, + { + SpirvOp::OpSubgroupAvcImeGetDualReferenceStreaminINTEL, + R"(OpSubgroupAvcImeGetDualReferenceStreaminINTEL)", + &s_operands[1817], + 3, + }, + { + SpirvOp::OpSubgroupAvcImeStripSingleReferenceStreamoutINTEL, + R"(OpSubgroupAvcImeStripSingleReferenceStreamoutINTEL)", + &s_operands[1820], + 3, + }, + { + SpirvOp::OpSubgroupAvcImeStripDualReferenceStreamoutINTEL, + R"(OpSubgroupAvcImeStripDualReferenceStreamoutINTEL)", + &s_operands[1823], + 3, + }, + { + SpirvOp::OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeMotionVectorsINTEL, + R"(OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeMotionVectorsINTEL)", + &s_operands[1826], + 4, + }, + { + SpirvOp::OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeDistortionsINTEL, + R"(OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeDistortionsINTEL)", + &s_operands[1830], + 4, + }, + { + SpirvOp::OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeReferenceIdsINTEL, + R"(OpSubgroupAvcImeGetStreamoutSingleReferenceMajorShapeReferenceIdsINTEL)", + &s_operands[1834], + 4, + }, + { + SpirvOp::OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeMotionVectorsINTEL, + R"(OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeMotionVectorsINTEL)", + &s_operands[1838], + 5, + }, + { + SpirvOp::OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeDistortionsINTEL, + R"(OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeDistortionsINTEL)", + &s_operands[1843], + 5, + }, + { + SpirvOp::OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeReferenceIdsINTEL, + R"(OpSubgroupAvcImeGetStreamoutDualReferenceMajorShapeReferenceIdsINTEL)", + &s_operands[1848], + 5, + }, + { + SpirvOp::OpSubgroupAvcImeGetBorderReachedINTEL, + R"(OpSubgroupAvcImeGetBorderReachedINTEL)", + &s_operands[1853], + 4, + }, + { + SpirvOp::OpSubgroupAvcImeGetTruncatedSearchIndicationINTEL, + R"(OpSubgroupAvcImeGetTruncatedSearchIndicationINTEL)", + &s_operands[1857], + 3, + }, + { + SpirvOp::OpSubgroupAvcImeGetUnidirectionalEarlySearchTerminationINTEL, + R"(OpSubgroupAvcImeGetUnidirectionalEarlySearchTerminationINTEL)", + &s_operands[1860], + 3, + }, + { + SpirvOp::OpSubgroupAvcImeGetWeightingPatternMinimumMotionVectorINTEL, + R"(OpSubgroupAvcImeGetWeightingPatternMinimumMotionVectorINTEL)", + &s_operands[1863], + 3, + }, + { + SpirvOp::OpSubgroupAvcImeGetWeightingPatternMinimumDistortionINTEL, + R"(OpSubgroupAvcImeGetWeightingPatternMinimumDistortionINTEL)", + &s_operands[1866], + 3, + }, + { + SpirvOp::OpSubgroupAvcFmeInitializeINTEL, + R"(OpSubgroupAvcFmeInitializeINTEL)", + &s_operands[1869], + 9, + }, + { + SpirvOp::OpSubgroupAvcBmeInitializeINTEL, + R"(OpSubgroupAvcBmeInitializeINTEL)", + &s_operands[1878], + 10, + }, + { + SpirvOp::OpSubgroupAvcRefConvertToMcePayloadINTEL, + R"(OpSubgroupAvcRefConvertToMcePayloadINTEL)", + &s_operands[1888], + 3, + }, + { + SpirvOp::OpSubgroupAvcRefSetBidirectionalMixDisableINTEL, + R"(OpSubgroupAvcRefSetBidirectionalMixDisableINTEL)", + &s_operands[1891], + 3, + }, + { + SpirvOp::OpSubgroupAvcRefSetBilinearFilterEnableINTEL, + R"(OpSubgroupAvcRefSetBilinearFilterEnableINTEL)", + &s_operands[1894], + 3, + }, + { + SpirvOp::OpSubgroupAvcRefEvaluateWithSingleReferenceINTEL, + R"(OpSubgroupAvcRefEvaluateWithSingleReferenceINTEL)", + &s_operands[1897], + 5, + }, + { + SpirvOp::OpSubgroupAvcRefEvaluateWithDualReferenceINTEL, + R"(OpSubgroupAvcRefEvaluateWithDualReferenceINTEL)", + &s_operands[1902], + 6, + }, + { + SpirvOp::OpSubgroupAvcRefEvaluateWithMultiReferenceINTEL, + R"(OpSubgroupAvcRefEvaluateWithMultiReferenceINTEL)", + &s_operands[1908], + 5, + }, + { + SpirvOp::OpSubgroupAvcRefEvaluateWithMultiReferenceInterlacedINTEL, + R"(OpSubgroupAvcRefEvaluateWithMultiReferenceInterlacedINTEL)", + &s_operands[1913], + 6, + }, + { + SpirvOp::OpSubgroupAvcRefConvertToMceResultINTEL, + R"(OpSubgroupAvcRefConvertToMceResultINTEL)", + &s_operands[1919], + 3, + }, + { + SpirvOp::OpSubgroupAvcSicInitializeINTEL, + R"(OpSubgroupAvcSicInitializeINTEL)", + &s_operands[1922], + 3, + }, + { + SpirvOp::OpSubgroupAvcSicConfigureSkcINTEL, + R"(OpSubgroupAvcSicConfigureSkcINTEL)", + &s_operands[1925], + 8, + }, + { + SpirvOp::OpSubgroupAvcSicConfigureIpeLumaINTEL, + R"(OpSubgroupAvcSicConfigureIpeLumaINTEL)", + &s_operands[1933], + 10, + }, + { + SpirvOp::OpSubgroupAvcSicConfigureIpeLumaChromaINTEL, + R"(OpSubgroupAvcSicConfigureIpeLumaChromaINTEL)", + &s_operands[1943], + 13, + }, + { + SpirvOp::OpSubgroupAvcSicGetMotionVectorMaskINTEL, + R"(OpSubgroupAvcSicGetMotionVectorMaskINTEL)", + &s_operands[1956], + 4, + }, + { + SpirvOp::OpSubgroupAvcSicConvertToMcePayloadINTEL, + R"(OpSubgroupAvcSicConvertToMcePayloadINTEL)", + &s_operands[1960], + 3, + }, + { + SpirvOp::OpSubgroupAvcSicSetIntraLumaShapePenaltyINTEL, + R"(OpSubgroupAvcSicSetIntraLumaShapePenaltyINTEL)", + &s_operands[1963], + 4, + }, + { + SpirvOp::OpSubgroupAvcSicSetIntraLumaModeCostFunctionINTEL, + R"(OpSubgroupAvcSicSetIntraLumaModeCostFunctionINTEL)", + &s_operands[1967], + 6, + }, + { + SpirvOp::OpSubgroupAvcSicSetIntraChromaModeCostFunctionINTEL, + R"(OpSubgroupAvcSicSetIntraChromaModeCostFunctionINTEL)", + &s_operands[1973], + 4, + }, + { + SpirvOp::OpSubgroupAvcSicSetBilinearFilterEnableINTEL, + R"(OpSubgroupAvcSicSetBilinearFilterEnableINTEL)", + &s_operands[1977], + 3, + }, + { + SpirvOp::OpSubgroupAvcSicSetSkcForwardTransformEnableINTEL, + R"(OpSubgroupAvcSicSetSkcForwardTransformEnableINTEL)", + &s_operands[1980], + 4, + }, + { + SpirvOp::OpSubgroupAvcSicSetBlockBasedRawSkipSadINTEL, + R"(OpSubgroupAvcSicSetBlockBasedRawSkipSadINTEL)", + &s_operands[1984], + 4, + }, + { + SpirvOp::OpSubgroupAvcSicEvaluateIpeINTEL, + R"(OpSubgroupAvcSicEvaluateIpeINTEL)", + &s_operands[1988], + 4, + }, + { + SpirvOp::OpSubgroupAvcSicEvaluateWithSingleReferenceINTEL, + R"(OpSubgroupAvcSicEvaluateWithSingleReferenceINTEL)", + &s_operands[1992], + 5, + }, + { + SpirvOp::OpSubgroupAvcSicEvaluateWithDualReferenceINTEL, + R"(OpSubgroupAvcSicEvaluateWithDualReferenceINTEL)", + &s_operands[1997], + 6, + }, + { + SpirvOp::OpSubgroupAvcSicEvaluateWithMultiReferenceINTEL, + R"(OpSubgroupAvcSicEvaluateWithMultiReferenceINTEL)", + &s_operands[2003], + 5, + }, + { + SpirvOp::OpSubgroupAvcSicEvaluateWithMultiReferenceInterlacedINTEL, + R"(OpSubgroupAvcSicEvaluateWithMultiReferenceInterlacedINTEL)", + &s_operands[2008], + 6, + }, + { + SpirvOp::OpSubgroupAvcSicConvertToMceResultINTEL, + R"(OpSubgroupAvcSicConvertToMceResultINTEL)", + &s_operands[2014], + 3, + }, + { + SpirvOp::OpSubgroupAvcSicGetIpeLumaShapeINTEL, + R"(OpSubgroupAvcSicGetIpeLumaShapeINTEL)", + &s_operands[2017], + 3, + }, + { + SpirvOp::OpSubgroupAvcSicGetBestIpeLumaDistortionINTEL, + R"(OpSubgroupAvcSicGetBestIpeLumaDistortionINTEL)", + &s_operands[2020], + 3, + }, + { + SpirvOp::OpSubgroupAvcSicGetBestIpeChromaDistortionINTEL, + R"(OpSubgroupAvcSicGetBestIpeChromaDistortionINTEL)", + &s_operands[2023], + 3, + }, + { + SpirvOp::OpSubgroupAvcSicGetPackedIpeLumaModesINTEL, + R"(OpSubgroupAvcSicGetPackedIpeLumaModesINTEL)", + &s_operands[2026], + 3, + }, + { + SpirvOp::OpSubgroupAvcSicGetIpeChromaModeINTEL, + R"(OpSubgroupAvcSicGetIpeChromaModeINTEL)", + &s_operands[2029], + 3, + }, + { + SpirvOp::OpSubgroupAvcSicGetPackedSkcLumaCountThresholdINTEL, + R"(OpSubgroupAvcSicGetPackedSkcLumaCountThresholdINTEL)", + &s_operands[2032], + 3, + }, + { + SpirvOp::OpSubgroupAvcSicGetPackedSkcLumaSumThresholdINTEL, + R"(OpSubgroupAvcSicGetPackedSkcLumaSumThresholdINTEL)", + &s_operands[2035], + 3, + }, + { + SpirvOp::OpSubgroupAvcSicGetInterRawSadsINTEL, + R"(OpSubgroupAvcSicGetInterRawSadsINTEL)", + &s_operands[2038], + 3, + }, + { + SpirvOp::OpLoopControlINTEL, + R"(OpLoopControlINTEL)", + &s_operands[2041], + 1, + }, + { + SpirvOp::OpReadPipeBlockingINTEL, + R"(OpReadPipeBlockingINTEL)", + &s_operands[2042], + 4, + }, + { + SpirvOp::OpWritePipeBlockingINTEL, + R"(OpWritePipeBlockingINTEL)", + &s_operands[2046], + 4, + }, + { + SpirvOp::OpFPGARegINTEL, + R"(OpFPGARegINTEL)", + &s_operands[2050], + 4, + }, + { + SpirvOp::OpRayQueryGetRayTMinKHR, + R"(OpRayQueryGetRayTMinKHR)", + &s_operands[2054], + 3, + }, + { + SpirvOp::OpRayQueryGetRayFlagsKHR, + R"(OpRayQueryGetRayFlagsKHR)", + &s_operands[2057], + 3, + }, + { + SpirvOp::OpRayQueryGetIntersectionTKHR, + R"(OpRayQueryGetIntersectionTKHR)", + &s_operands[2060], + 4, + }, + { + SpirvOp::OpRayQueryGetIntersectionInstanceCustomIndexKHR, + R"(OpRayQueryGetIntersectionInstanceCustomIndexKHR)", + &s_operands[2064], + 4, + }, + { + SpirvOp::OpRayQueryGetIntersectionInstanceIdKHR, + R"(OpRayQueryGetIntersectionInstanceIdKHR)", + &s_operands[2068], + 4, + }, + { + SpirvOp::OpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR, + R"(OpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR)", + &s_operands[2072], + 4, + }, + { + SpirvOp::OpRayQueryGetIntersectionGeometryIndexKHR, + R"(OpRayQueryGetIntersectionGeometryIndexKHR)", + &s_operands[2076], + 4, + }, + { + SpirvOp::OpRayQueryGetIntersectionPrimitiveIndexKHR, + R"(OpRayQueryGetIntersectionPrimitiveIndexKHR)", + &s_operands[2080], + 4, + }, + { + SpirvOp::OpRayQueryGetIntersectionBarycentricsKHR, + R"(OpRayQueryGetIntersectionBarycentricsKHR)", + &s_operands[2084], + 4, + }, + { + SpirvOp::OpRayQueryGetIntersectionFrontFaceKHR, + R"(OpRayQueryGetIntersectionFrontFaceKHR)", + &s_operands[2088], + 4, + }, + { + SpirvOp::OpRayQueryGetIntersectionCandidateAABBOpaqueKHR, + R"(OpRayQueryGetIntersectionCandidateAABBOpaqueKHR)", + &s_operands[2092], + 3, + }, + { + SpirvOp::OpRayQueryGetIntersectionObjectRayDirectionKHR, + R"(OpRayQueryGetIntersectionObjectRayDirectionKHR)", + &s_operands[2095], + 4, + }, + { + SpirvOp::OpRayQueryGetIntersectionObjectRayOriginKHR, + R"(OpRayQueryGetIntersectionObjectRayOriginKHR)", + &s_operands[2099], + 4, + }, + { + SpirvOp::OpRayQueryGetWorldRayDirectionKHR, + R"(OpRayQueryGetWorldRayDirectionKHR)", + &s_operands[2103], + 3, + }, + { + SpirvOp::OpRayQueryGetWorldRayOriginKHR, + R"(OpRayQueryGetWorldRayOriginKHR)", + &s_operands[2106], + 3, + }, + { + SpirvOp::OpRayQueryGetIntersectionObjectToWorldKHR, + R"(OpRayQueryGetIntersectionObjectToWorldKHR)", + &s_operands[2109], + 4, + }, + { + SpirvOp::OpRayQueryGetIntersectionWorldToObjectKHR, + R"(OpRayQueryGetIntersectionWorldToObjectKHR)", + &s_operands[2113], + 4, + }, + { + SpirvOp::OpAtomicFAddEXT, + R"(OpAtomicFAddEXT)", + &s_operands[2117], + 6, + }, + } + }; + + const SpirvInstruction* GetInstructionData(UInt16 op) + { + auto it = std::lower_bound(std::begin(s_instructions), std::end(s_instructions), op, [](const SpirvInstruction& inst, UInt16 op) { return UInt16(inst.op) < op; }); + if (it != std::end(s_instructions) && UInt16(it->op) == op) + return &*it; + else + return nullptr; + } +} From 0b507708f4985579d36d9e11155f53aaecca41a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Tue, 18 Aug 2020 00:00:05 +0200 Subject: [PATCH 301/316] Shader/SpirvWriter: Split section to another class + improve variadic parameters support --- include/Nazara/Shader/SpirvSection.hpp | 73 ++++++ include/Nazara/Shader/SpirvSection.inl | 146 ++++++++++++ include/Nazara/Shader/SpirvWriter.hpp | 31 +-- include/Nazara/Shader/SpirvWriter.inl | 99 --------- src/Nazara/Shader/SpirvSection.cpp | 38 ++++ src/Nazara/Shader/SpirvWriter.cpp | 295 +++++++++++-------------- 6 files changed, 387 insertions(+), 295 deletions(-) create mode 100644 include/Nazara/Shader/SpirvSection.hpp create mode 100644 include/Nazara/Shader/SpirvSection.inl create mode 100644 src/Nazara/Shader/SpirvSection.cpp diff --git a/include/Nazara/Shader/SpirvSection.hpp b/include/Nazara/Shader/SpirvSection.hpp new file mode 100644 index 000000000..b116b212f --- /dev/null +++ b/include/Nazara/Shader/SpirvSection.hpp @@ -0,0 +1,73 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_SPIRVSECTION_HPP +#define NAZARA_SPIRVSECTION_HPP + +#include +#include +#include +#include +#include + +namespace Nz +{ + class NAZARA_SHADER_API SpirvSection + { + public: + struct OpSize; + struct Raw; + + SpirvSection() = default; + SpirvSection(const SpirvSection& cache) = default; + SpirvSection(SpirvSection&& cache) = default; + ~SpirvSection() = default; + + inline std::size_t Append(const char* str); + inline std::size_t Append(const std::string_view& str); + inline std::size_t Append(const std::string& str); + inline std::size_t Append(UInt32 value); + inline std::size_t Append(SpirvOp opcode, const OpSize& wordCount); + std::size_t Append(const Raw& raw); + inline std::size_t Append(std::initializer_list codepoints); + template std::size_t Append(SpirvOp opcode, const Args&... args); + template std::size_t AppendVariadic(SpirvOp opcode, F&& callback); + template std::size_t Append(T value); + + inline unsigned int CountWord(const char* str); + inline unsigned int CountWord(const std::string_view& str); + inline unsigned int CountWord(const std::string& str); + inline unsigned int CountWord(const Raw& raw); + template unsigned int CountWord(const T& value); + template unsigned int CountWord(const T1& value, const T2& value2, const Args&... rest); + + inline const std::vector& GetBytecode() const; + inline std::size_t GetOutputOffset() const; + + SpirvSection& operator=(const SpirvSection& cache) = delete; + SpirvSection& operator=(SpirvSection&& cache) = default; + + struct OpSize + { + unsigned int wc; + }; + + struct Raw + { + const void* ptr; + std::size_t size; + }; + + static inline UInt32 BuildOpcode(SpirvOp opcode, unsigned int wordCount); + + private: + std::vector m_bytecode; + }; +} + +#include + +#endif diff --git a/include/Nazara/Shader/SpirvSection.inl b/include/Nazara/Shader/SpirvSection.inl new file mode 100644 index 000000000..f4770e3f3 --- /dev/null +++ b/include/Nazara/Shader/SpirvSection.inl @@ -0,0 +1,146 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline std::size_t SpirvSection::Append(const char* str) + { + return Append(std::string_view(str)); + } + + inline std::size_t SpirvSection::Append(const std::string_view& str) + { + std::size_t offset = GetOutputOffset(); + + std::size_t size4 = CountWord(str); + for (std::size_t i = 0; i < size4; ++i) + { + UInt32 codepoint = 0; + for (std::size_t j = 0; j < 4; ++j) + { + std::size_t pos = i * 4 + j; + if (pos < str.size()) + codepoint |= UInt32(str[pos]) << (j * 8); + } + + Append(codepoint); + } + + return offset; + } + + inline std::size_t SpirvSection::Append(const std::string& str) + { + return Append(std::string_view(str)); + } + + inline std::size_t SpirvSection::Append(UInt32 value) + { + std::size_t offset = GetOutputOffset(); + m_bytecode.push_back(value); + + return offset; + } + + inline std::size_t SpirvSection::Append(SpirvOp opcode, const OpSize& wordCount) + { + return Append(BuildOpcode(opcode, wordCount.wc)); + } + + inline std::size_t SpirvSection::Append(std::initializer_list codepoints) + { + std::size_t offset = GetOutputOffset(); + + for (UInt32 cp : codepoints) + Append(cp); + + return offset; + } + + template + std::size_t SpirvSection::Append(SpirvOp opcode, const Args&... args) + { + unsigned int wordCount = 1 + (CountWord(args) + ... + 0); + std::size_t offset = Append(opcode, OpSize{ wordCount }); + if constexpr (sizeof...(args) > 0) + (Append(args), ...); + + return offset; + } + + template std::size_t SpirvSection::AppendVariadic(SpirvOp opcode, F&& callback) + { + std::size_t offset = Append(0); //< Will be filled later + + unsigned int wordCount = 1; + auto appendFunctor = [&](const auto& value) + { + wordCount += CountWord(value); + Append(value); + }; + callback(appendFunctor); + + m_bytecode[offset] = BuildOpcode(opcode, wordCount); + + return offset; + } + + template + std::size_t SpirvSection::Append(T value) + { + return Append(static_cast(value)); + } + + template + unsigned int SpirvSection::CountWord(const T& value) + { + return 1; + } + + template + unsigned int SpirvSection::CountWord(const T1& value, const T2& value2, const Args&... rest) + { + return CountWord(value) + CountWord(value2) + (CountWord(rest) + ...); + } + + inline unsigned int SpirvSection::CountWord(const char* str) + { + return CountWord(std::string_view(str)); + } + + inline unsigned int Nz::SpirvSection::CountWord(const std::string& str) + { + return CountWord(std::string_view(str)); + } + + inline unsigned int SpirvSection::CountWord(const Raw& raw) + { + return static_cast((raw.size + sizeof(UInt32) - 1) / sizeof(UInt32)); + } + + inline unsigned int SpirvSection::CountWord(const std::string_view& str) + { + return (static_cast(str.size() + 1) + sizeof(UInt32) - 1) / sizeof(UInt32); //< + 1 for null character + } + + inline const std::vector& SpirvSection::GetBytecode() const + { + return m_bytecode; + } + + inline std::size_t SpirvSection::GetOutputOffset() const + { + return m_bytecode.size(); + } + + inline UInt32 SpirvSection::BuildOpcode(SpirvOp opcode, unsigned int wordCount) + { + return UInt32(opcode) | UInt32(wordCount) << 16; + } +} + +#include diff --git a/include/Nazara/Shader/SpirvWriter.hpp b/include/Nazara/Shader/SpirvWriter.hpp index 90f6b0e3e..71a617eaa 100644 --- a/include/Nazara/Shader/SpirvWriter.hpp +++ b/include/Nazara/Shader/SpirvWriter.hpp @@ -20,6 +20,8 @@ namespace Nz { + class SpirvSection; + class NAZARA_SHADER_API SpirvWriter : public ShaderAstVisitor, public ShaderVarVisitor { public: @@ -42,33 +44,6 @@ namespace Nz private: struct ExtVar; - struct Opcode; - struct Raw; - struct WordCount; - - struct Section - { - inline std::size_t Append(const char* str); - inline std::size_t Append(const std::string_view& str); - inline std::size_t Append(const std::string& str); - inline std::size_t Append(UInt32 value); - std::size_t Append(const Opcode& opcode, const WordCount& wordCount); - std::size_t Append(const Raw& raw); - inline std::size_t Append(std::initializer_list codepoints); - template std::size_t Append(Opcode opcode, const Args&... args); - template std::size_t Append(T value); - - inline unsigned int CountWord(const char* str); - inline unsigned int CountWord(const std::string_view& str); - inline unsigned int CountWord(const std::string& str); - unsigned int CountWord(const Raw& raw); - template unsigned int CountWord(const T& value); - template unsigned int CountWord(const T1& value, const T2& value2, const Args&... rest); - - inline std::size_t GetOutputOffset() const; - - std::vector data; - }; UInt32 AllocateResultId(); @@ -111,7 +86,7 @@ namespace Nz void Visit(ShaderNodes::ParameterVariable& var) override; void Visit(ShaderNodes::UniformVariable& var) override; - static void MergeBlocks(std::vector& output, const Section& from); + static void MergeBlocks(std::vector& output, const SpirvSection& from); struct Context { diff --git a/include/Nazara/Shader/SpirvWriter.inl b/include/Nazara/Shader/SpirvWriter.inl index 4ef96c82b..26012e0d1 100644 --- a/include/Nazara/Shader/SpirvWriter.inl +++ b/include/Nazara/Shader/SpirvWriter.inl @@ -3,109 +3,10 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include -#include -#include #include namespace Nz { - inline std::size_t SpirvWriter::Section::Append(const char* str) - { - return Append(std::string_view(str)); - } - - inline std::size_t SpirvWriter::Section::Append(const std::string_view& str) - { - std::size_t offset = GetOutputOffset(); - - std::size_t size4 = CountWord(str); - for (std::size_t i = 0; i < size4; ++i) - { - UInt32 codepoint = 0; - for (std::size_t j = 0; j < 4; ++j) - { - std::size_t pos = i * 4 + j; - if (pos < str.size()) - codepoint |= UInt32(str[pos]) << (j * 8); - } - - Append(codepoint); - } - - return offset; - } - - inline std::size_t SpirvWriter::Section::Append(const std::string& str) - { - return Append(std::string_view(str)); - } - - inline std::size_t SpirvWriter::Section::Append(UInt32 value) - { - std::size_t offset = GetOutputOffset(); - data.push_back(value); - - return offset; - } - - inline std::size_t SpirvWriter::Section::Append(std::initializer_list codepoints) - { - std::size_t offset = GetOutputOffset(); - - for (UInt32 cp : codepoints) - Append(cp); - - return offset; - } - - template - std::size_t SpirvWriter::Section::Append(Opcode opcode, const Args&... args) - { - unsigned int wordCount = 1 + (CountWord(args) + ... + 0); - std::size_t offset = Append(opcode, WordCount{ wordCount }); - if constexpr (sizeof...(args) > 0) - (Append(args), ...); - - return offset; - } - - template - std::size_t SpirvWriter::Section::Append(T value) - { - return Append(static_cast(value)); - } - - template - unsigned int SpirvWriter::Section::CountWord(const T& value) - { - return 1; - } - - template - unsigned int SpirvWriter::Section::CountWord(const T1& value, const T2& value2, const Args&... rest) - { - return CountWord(value) + CountWord(value2) + (CountWord(rest) + ...); - } - - inline unsigned int SpirvWriter::Section::CountWord(const char* str) - { - return CountWord(std::string_view(str)); - } - - inline unsigned int Nz::SpirvWriter::Section::CountWord(const std::string& str) - { - return CountWord(std::string_view(str)); - } - - inline unsigned int SpirvWriter::Section::CountWord(const std::string_view& str) - { - return (static_cast(str.size() + 1) + sizeof(UInt32) - 1) / sizeof(UInt32); //< + 1 for null character - } - - std::size_t SpirvWriter::Section::GetOutputOffset() const - { - return data.size(); - } } #include diff --git a/src/Nazara/Shader/SpirvSection.cpp b/src/Nazara/Shader/SpirvSection.cpp new file mode 100644 index 000000000..c3d62ade3 --- /dev/null +++ b/src/Nazara/Shader/SpirvSection.cpp @@ -0,0 +1,38 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + std::size_t SpirvSection::Append(const Raw& raw) + { + std::size_t offset = GetOutputOffset(); + + const UInt8* ptr = static_cast(raw.ptr); + + std::size_t size4 = CountWord(raw); + for (std::size_t i = 0; i < size4; ++i) + { + UInt32 codepoint = 0; + for (std::size_t j = 0; j < 4; ++j) + { +#ifdef NAZARA_BIG_ENDIAN + std::size_t pos = i * 4 + (3 - j); +#else + std::size_t pos = i * 4 + j; +#endif + + if (pos < raw.size) + codepoint |= UInt32(ptr[pos]) << (j * 8); + } + + Append(codepoint); + } + + return offset; + } +} diff --git a/src/Nazara/Shader/SpirvWriter.cpp b/src/Nazara/Shader/SpirvWriter.cpp index b3b318c63..fb767d0e8 100644 --- a/src/Nazara/Shader/SpirvWriter.cpp +++ b/src/Nazara/Shader/SpirvWriter.cpp @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include #include #include @@ -198,22 +200,6 @@ namespace Nz std::optional valueId; }; - struct SpirvWriter::Opcode - { - SpvOp op; - }; - - struct SpirvWriter::Raw - { - const void* ptr; - std::size_t size; - }; - - struct SpirvWriter::WordCount - { - unsigned int wc; - }; - struct SpirvWriter::State { struct Func @@ -237,12 +223,12 @@ namespace Nz UInt32 nextVarIndex = 1; // Output - Section header; - Section constants; - Section debugInfo; - Section annotations; - Section types; - Section instructions; + SpirvSection header; + SpirvSection constants; + SpirvSection debugInfo; + SpirvSection annotations; + SpirvSection types; + SpirvSection instructions; }; SpirvWriter::SpirvWriter() : @@ -343,11 +329,11 @@ namespace Nz throw std::runtime_error("unexpected builtin type"); } - state.debugInfo.Append(Opcode{ SpvOpName }, builtinData.varId, debugName); - state.types.Append(Opcode{ SpvOpTypePointer }, builtinData.pointerTypeId, SpvStorageClassOutput, builtinData.typeId); - state.types.Append(Opcode{ SpvOpVariable }, builtinData.pointerTypeId, builtinData.varId, SpvStorageClassOutput); + state.debugInfo.Append(SpirvOp::OpName, builtinData.varId, debugName); + state.types.Append(SpirvOp::OpTypePointer, builtinData.pointerTypeId, SpvStorageClassOutput, builtinData.typeId); + state.types.Append(SpirvOp::OpVariable, builtinData.pointerTypeId, builtinData.varId, SpvStorageClassOutput); - state.annotations.Append(Opcode{ SpvOpDecorate }, builtinData.varId, SpvDecorationBuiltIn, spvBuiltin); + state.annotations.Append(SpirvOp::OpDecorate, builtinData.varId, SpvDecorationBuiltIn, spvBuiltin); state.builtinIds.emplace(builtin->entry, builtinData); } @@ -361,12 +347,12 @@ namespace Nz state.inputIds.emplace(input.name, inputData); - state.debugInfo.Append(Opcode{ SpvOpName }, inputData.varId, input.name); - state.types.Append(Opcode{ SpvOpTypePointer }, inputData.pointerTypeId, SpvStorageClassInput, inputData.typeId); - state.types.Append(Opcode{ SpvOpVariable }, inputData.pointerTypeId, inputData.varId, SpvStorageClassInput); + state.debugInfo.Append(SpirvOp::OpName, inputData.varId, input.name); + state.types.Append(SpirvOp::OpTypePointer, inputData.pointerTypeId, SpvStorageClassInput, inputData.typeId); + state.types.Append(SpirvOp::OpVariable, inputData.pointerTypeId, inputData.varId, SpvStorageClassInput); if (input.locationIndex) - state.annotations.Append(Opcode{ SpvOpDecorate }, inputData.varId, SpvDecorationLocation, *input.locationIndex); + state.annotations.Append(SpirvOp::OpDecorate, inputData.varId, SpvDecorationLocation, *input.locationIndex); } for (const auto& output : shader.GetOutputs()) @@ -378,12 +364,12 @@ namespace Nz state.outputIds.emplace(output.name, outputData); - state.debugInfo.Append(Opcode{ SpvOpName }, outputData.varId, output.name); - state.types.Append(Opcode{ SpvOpTypePointer }, outputData.pointerTypeId, SpvStorageClassOutput, outputData.typeId); - state.types.Append(Opcode{ SpvOpVariable }, outputData.pointerTypeId, outputData.varId, SpvStorageClassOutput); + state.debugInfo.Append(SpirvOp::OpName, outputData.varId, output.name); + state.types.Append(SpirvOp::OpTypePointer, outputData.pointerTypeId, SpvStorageClassOutput, outputData.typeId); + state.types.Append(SpirvOp::OpVariable, outputData.pointerTypeId, outputData.varId, SpvStorageClassOutput); if (output.locationIndex) - state.annotations.Append(Opcode{ SpvOpDecorate }, outputData.varId, SpvDecorationLocation, *output.locationIndex); + state.annotations.Append(SpirvOp::OpDecorate, outputData.varId, SpvDecorationLocation, *output.locationIndex); } for (const auto& uniform : shader.GetUniforms()) @@ -395,14 +381,14 @@ namespace Nz state.uniformIds.emplace(uniform.name, uniformData); - state.debugInfo.Append(Opcode{ SpvOpName }, uniformData.varId, uniform.name); - state.types.Append(Opcode{ SpvOpTypePointer }, uniformData.pointerTypeId, SpvStorageClassUniform, uniformData.typeId); - state.types.Append(Opcode{ SpvOpVariable }, uniformData.pointerTypeId, uniformData.varId, SpvStorageClassUniform); + state.debugInfo.Append(SpirvOp::OpName, uniformData.varId, uniform.name); + state.types.Append(SpirvOp::OpTypePointer, uniformData.pointerTypeId, SpvStorageClassUniform, uniformData.typeId); + state.types.Append(SpirvOp::OpVariable, uniformData.pointerTypeId, uniformData.varId, SpvStorageClassUniform); if (uniform.bindingIndex) { - state.annotations.Append(Opcode{ SpvOpDecorate }, uniformData.varId, SpvDecorationBinding, *uniform.bindingIndex); - state.annotations.Append(Opcode{ SpvOpDecorate }, uniformData.varId, SpvDecorationDescriptorSet, 0); + state.annotations.Append(SpirvOp::OpDecorate, uniformData.varId, SpvDecorationBinding, *uniform.bindingIndex); + state.annotations.Append(SpirvOp::OpDecorate, uniformData.varId, SpvDecorationDescriptorSet, 0); } } @@ -412,14 +398,16 @@ namespace Nz funcData.id = AllocateResultId(); funcData.typeId = AllocateResultId(); - state.debugInfo.Append(Opcode{ SpvOpName }, funcData.id, func.name); + state.debugInfo.Append(SpirvOp::OpName, funcData.id, func.name); - state.types.Append(Opcode{ SpvOpTypeFunction }, WordCount{ 3 + static_cast(func.parameters.size()) }); - state.types.Append(funcData.typeId); - state.types.Append(GetTypeId(func.returnType)); + state.types.AppendVariadic(SpirvOp::OpTypeFunction, [&](const auto& appender) + { + appender(funcData.typeId); + appender(GetTypeId(func.returnType)); - for (const auto& param : func.parameters) - state.types.Append(GetTypeId(param.type)); + for (const auto& param : func.parameters) + appender(GetTypeId(param.type)); + }); } // Register constants @@ -438,24 +426,24 @@ namespace Nz auto& funcData = state.funcs[funcIndex]; - state.instructions.Append(Opcode{ SpvOpFunction }, GetTypeId(func.returnType), funcData.id, 0, funcData.typeId); + state.instructions.Append(SpirvOp::OpFunction, GetTypeId(func.returnType), funcData.id, 0, funcData.typeId); - state.instructions.Append(Opcode{ SpvOpLabel }, AllocateResultId()); + state.instructions.Append(SpirvOp::OpLabel, AllocateResultId()); for (const auto& param : func.parameters) { UInt32 paramResultId = AllocateResultId(); funcData.paramsId.push_back(paramResultId); - state.instructions.Append(Opcode{ SpvOpFunctionParameter }, GetTypeId(param.type), paramResultId); + state.instructions.Append(SpirvOp::OpFunctionParameter, GetTypeId(param.type), paramResultId); } Visit(functionStatements[funcIndex]); if (func.returnType == ShaderNodes::BasicType::Void) - state.instructions.Append(Opcode{ SpvOpReturn }); + state.instructions.Append(SpirvOp::OpReturn); - state.instructions.Append(Opcode{ SpvOpFunctionEnd }); + state.instructions.Append(SpirvOp::OpFunctionEnd); } assert(entryPointIndex != std::numeric_limits::max()); @@ -485,21 +473,24 @@ namespace Nz std::size_t nameSize = state.header.CountWord(entryFuncData.name); - state.header.Append(Opcode{ SpvOpEntryPoint }, WordCount{ static_cast(3 + nameSize + m_currentState->builtinIds.size() + m_currentState->inputIds.size() + m_currentState->outputIds.size()) }); - state.header.Append(execModel); - state.header.Append(entryFunc.id); - state.header.Append(entryFuncData.name); - for (const auto& [name, varData] : m_currentState->builtinIds) - state.header.Append(varData.varId); + state.header.AppendVariadic(SpirvOp::OpEntryPoint, [&](const auto& appender) + { + appender(execModel); + appender(entryFunc.id); + appender(entryFuncData.name); - for (const auto& [name, varData] : m_currentState->inputIds) - state.header.Append(varData.varId); + for (const auto& [name, varData] : m_currentState->builtinIds) + appender(varData.varId); - for (const auto& [name, varData] : m_currentState->outputIds) - state.header.Append(varData.varId); + for (const auto& [name, varData] : m_currentState->inputIds) + appender(varData.varId); + + for (const auto& [name, varData] : m_currentState->outputIds) + appender(varData.varId); + }); if (m_context.shader->GetStage() == ShaderStageType::Fragment) - state.header.Append(Opcode{ SpvOpExecutionMode }, entryFunc.id, SpvExecutionModeOriginUpperLeft); + state.header.Append(SpirvOp::OpExecutionMode, entryFunc.id, SpvExecutionModeOriginUpperLeft); std::vector ret; MergeBlocks(ret, state.header); @@ -532,15 +523,15 @@ namespace Nz using T = std::decay_t; if constexpr (std::is_same_v) - m_currentState->constants.Append(Opcode{ (arg) ? SpvOpConstantTrue : SpvOpConstantFalse }, constantId); + m_currentState->constants.Append((arg) ? SpirvOp::OpConstantTrue : SpirvOp::OpConstantFalse, constantId); else if constexpr (std::is_same_v || std::is_same_v) - m_currentState->constants.Append(Opcode{ SpvOpConstant }, GetTypeId(GetBasicType()), constantId, Raw{ &arg, sizeof(arg) }); + m_currentState->constants.Append(SpirvOp::OpConstant, GetTypeId(GetBasicType()), constantId, SpirvSection::Raw{ &arg, sizeof(arg) }); else if constexpr (std::is_same_v || std::is_same_v) - m_currentState->constants.Append(Opcode{ SpvOpConstantComposite }, GetTypeId(GetBasicType()), constantId, GetConstantId(arg.x), GetConstantId(arg.y)); + m_currentState->constants.Append(SpirvOp::OpConstantComposite, GetTypeId(GetBasicType()), constantId, GetConstantId(arg.x), GetConstantId(arg.y)); else if constexpr (std::is_same_v || std::is_same_v) - m_currentState->constants.Append(Opcode{ SpvOpConstantComposite }, GetTypeId(GetBasicType()), constantId, GetConstantId(arg.x), GetConstantId(arg.y), GetConstantId(arg.z)); + m_currentState->constants.Append(SpirvOp::OpConstantComposite, GetTypeId(GetBasicType()), constantId, GetConstantId(arg.x), GetConstantId(arg.y), GetConstantId(arg.z)); else if constexpr (std::is_same_v || std::is_same_v) - m_currentState->constants.Append(Opcode{ SpvOpConstantComposite }, GetTypeId(GetBasicType()), constantId, GetConstantId(arg.x), GetConstantId(arg.y), GetConstantId(arg.z), GetConstantId(arg.w)); + m_currentState->constants.Append(SpirvOp::OpConstantComposite, GetTypeId(GetBasicType()), constantId, GetConstantId(arg.x), GetConstantId(arg.y), GetConstantId(arg.z), GetConstantId(arg.w)); else static_assert(AlwaysFalse::value, "non-exhaustive visitor"); }, value); @@ -558,24 +549,24 @@ namespace Nz m_currentState->header.Append(m_currentState->nextVarIndex); //< Bound (ID count) m_currentState->header.Append(0); //< Instruction schema (required to be 0 for now) - m_currentState->header.Append(Opcode{ SpvOpCapability }, SpvCapabilityShader); + m_currentState->header.Append(SpirvOp::OpCapability, SpvCapabilityShader); for (const auto& [extInst, resultId] : m_currentState->extensionInstructions) - m_currentState->header.Append(Opcode{ SpvOpExtInstImport }, resultId, extInst); + m_currentState->header.Append(SpirvOp::OpExtInstImport, resultId, extInst); - m_currentState->header.Append(Opcode{ SpvOpMemoryModel }, SpvAddressingModelLogical, SpvMemoryModelGLSL450); + m_currentState->header.Append(SpirvOp::OpMemoryModel, SpvAddressingModelLogical, SpvMemoryModelGLSL450); } void SpirvWriter::AppendStructType(std::size_t structIndex, UInt32 resultId) { const ShaderAst::Struct& s = m_context.shader->GetStruct(structIndex); - m_currentState->types.Append(Opcode{ SpvOpTypeStruct }, WordCount{ static_cast(1 + 1 + s.members.size()) }); + m_currentState->types.Append(SpirvOp::OpTypeStruct, SpirvSection::OpSize{ static_cast(1 + 1 + s.members.size()) }); m_currentState->types.Append(resultId); - m_currentState->debugInfo.Append(Opcode{ SpvOpName }, resultId, s.name); + m_currentState->debugInfo.Append(SpirvOp::OpName, resultId, s.name); - m_currentState->annotations.Append(Opcode{ SpvOpDecorate }, resultId, SpvDecorationBlock); + m_currentState->annotations.Append(SpirvOp::OpDecorate, resultId, SpvDecorationBlock); FieldOffsets structOffsets(StructLayout_Std140); @@ -583,7 +574,7 @@ namespace Nz { const auto& member = s.members[memberIndex]; m_currentState->types.Append(GetTypeId(member.type)); - m_currentState->debugInfo.Append(Opcode{ SpvOpMemberName }, resultId, memberIndex, member.name); + m_currentState->debugInfo.Append(SpirvOp::OpMemberName, resultId, memberIndex, member.name); std::visit([&](auto&& arg) { @@ -611,12 +602,12 @@ namespace Nz throw std::runtime_error("unhandled type"); }(); - m_currentState->annotations.Append(Opcode{ SpvOpMemberDecorate }, resultId, memberIndex, SpvDecorationOffset, offset); + m_currentState->annotations.Append(SpirvOp::OpMemberDecorate, resultId, memberIndex, SpvDecorationOffset, offset); if (arg == ShaderNodes::BasicType::Mat4x4) { - m_currentState->annotations.Append(Opcode{ SpvOpMemberDecorate }, resultId, memberIndex, SpvDecorationColMajor); - m_currentState->annotations.Append(Opcode{ SpvOpMemberDecorate }, resultId, memberIndex, SpvDecorationMatrixStride, 16); + m_currentState->annotations.Append(SpirvOp::OpMemberDecorate, resultId, memberIndex, SpvDecorationColMajor); + m_currentState->annotations.Append(SpirvOp::OpMemberDecorate, resultId, memberIndex, SpvDecorationMatrixStride, 16); } } else if constexpr (std::is_same_v) @@ -657,11 +648,11 @@ namespace Nz switch (arg) { case ShaderNodes::BasicType::Boolean: - m_currentState->types.Append(Opcode{ SpvOpTypeBool }, resultId); + m_currentState->types.Append(SpirvOp::OpTypeBool, resultId); break; case ShaderNodes::BasicType::Float1: - m_currentState->types.Append(Opcode{ SpvOpTypeFloat }, resultId, 32); + m_currentState->types.Append(SpirvOp::OpTypeFloat, resultId, 32); break; case ShaderNodes::BasicType::Float2: @@ -675,17 +666,17 @@ namespace Nz UInt32 vecSize = UInt32(arg) - UInt32(baseType) + 1; - m_currentState->types.Append(Opcode{ SpvOpTypeVector }, resultId, GetTypeId(baseType), vecSize); + m_currentState->types.Append(SpirvOp::OpTypeVector, resultId, GetTypeId(baseType), vecSize); break; } case ShaderNodes::BasicType::Int1: - m_currentState->types.Append(Opcode{ SpvOpTypeInt }, resultId, 32, 1); + m_currentState->types.Append(SpirvOp::OpTypeInt, resultId, 32, 1); break; case ShaderNodes::BasicType::Mat4x4: { - m_currentState->types.Append(Opcode{ SpvOpTypeMatrix }, resultId, GetTypeId(ShaderNodes::BasicType::Float4), 4); + m_currentState->types.Append(SpirvOp::OpTypeMatrix, resultId, GetTypeId(ShaderNodes::BasicType::Float4), 4); break; } @@ -693,13 +684,13 @@ namespace Nz { UInt32 imageTypeId = resultId - 1; - m_currentState->types.Append(Opcode{ SpvOpTypeImage }, imageTypeId, GetTypeId(ShaderNodes::BasicType::Float1), SpvDim2D, 0, 0, 0, 1, SpvImageFormatUnknown); - m_currentState->types.Append(Opcode{ SpvOpTypeSampledImage }, resultId, imageTypeId); + m_currentState->types.Append(SpirvOp::OpTypeImage, imageTypeId, GetTypeId(ShaderNodes::BasicType::Float1), SpvDim2D, 0, 0, 0, 1, SpvImageFormatUnknown); + m_currentState->types.Append(SpirvOp::OpTypeSampledImage, resultId, imageTypeId); break; } case ShaderNodes::BasicType::Void: - m_currentState->types.Append(Opcode{ SpvOpTypeVoid }, resultId); + m_currentState->types.Append(SpirvOp::OpTypeVoid, resultId); break; } } @@ -763,7 +754,7 @@ namespace Nz if (!var.valueId.has_value()) { UInt32 resultId = AllocateResultId(); - m_currentState->instructions.Append(Opcode{ SpvOpLoad }, var.typeId, resultId, var.varId); + m_currentState->instructions.Append(SpirvOp::OpLoad, var.typeId, resultId, var.varId); var.valueId = resultId; } @@ -905,13 +896,13 @@ namespace Nz UInt32 typeId = GetTypeId(node.exprType); UInt32 indexId = GetConstantId(Int32(node.memberIndex)); - m_currentState->types.Append(Opcode{ SpvOpTypePointer }, pointerType, storage, typeId); + m_currentState->types.Append(SpirvOp::OpTypePointer, pointerType, storage, typeId); - m_currentState->instructions.Append(Opcode{ SpvOpAccessChain }, pointerType, memberPointerId, pointerId, indexId); + m_currentState->instructions.Append(SpirvOp::OpAccessChain, pointerType, memberPointerId, pointerId, indexId); UInt32 resultId = AllocateResultId(); - m_currentState->instructions.Append(Opcode{ SpvOpLoad }, typeId, resultId, memberPointerId); + m_currentState->instructions.Append(SpirvOp::OpLoad, typeId, resultId, memberPointerId); PushResultId(resultId); } @@ -933,7 +924,7 @@ namespace Nz auto it = m_currentState->builtinIds.find(builtinvar.entry); assert(it != m_currentState->builtinIds.end()); - m_currentState->instructions.Append(Opcode{ SpvOpStore }, it->second.varId, result); + m_currentState->instructions.Append(SpirvOp::OpStore, it->second.varId, result); PushResultId(result); break; } @@ -944,7 +935,7 @@ namespace Nz auto it = m_currentState->outputIds.find(outputVar.name); assert(it != m_currentState->outputIds.end()); - m_currentState->instructions.Append(Opcode{ SpvOpStore }, it->second.varId, result); + m_currentState->instructions.Append(SpirvOp::OpStore, it->second.varId, result); PushResultId(result); break; } @@ -992,7 +983,7 @@ namespace Nz bool swapOperands = false; - SpvOp op = [&] + SpirvOp op = [&] { switch (node.op) { @@ -1005,13 +996,13 @@ namespace Nz case ShaderNodes::BasicType::Float3: case ShaderNodes::BasicType::Float4: case ShaderNodes::BasicType::Mat4x4: - return SpvOpFAdd; + return SpirvOp::OpFAdd; case ShaderNodes::BasicType::Int1: case ShaderNodes::BasicType::Int2: case ShaderNodes::BasicType::Int3: case ShaderNodes::BasicType::Int4: - return SpvOpIAdd; + return SpirvOp::OpIAdd; case ShaderNodes::BasicType::Boolean: case ShaderNodes::BasicType::Sampler2D: @@ -1029,13 +1020,13 @@ namespace Nz case ShaderNodes::BasicType::Float3: case ShaderNodes::BasicType::Float4: case ShaderNodes::BasicType::Mat4x4: - return SpvOpFSub; + return SpirvOp::OpFSub; case ShaderNodes::BasicType::Int1: case ShaderNodes::BasicType::Int2: case ShaderNodes::BasicType::Int3: case ShaderNodes::BasicType::Int4: - return SpvOpISub; + return SpirvOp::OpISub; case ShaderNodes::BasicType::Boolean: case ShaderNodes::BasicType::Sampler2D: @@ -1053,13 +1044,13 @@ namespace Nz case ShaderNodes::BasicType::Float3: case ShaderNodes::BasicType::Float4: case ShaderNodes::BasicType::Mat4x4: - return SpvOpFDiv; + return SpirvOp::OpFDiv; case ShaderNodes::BasicType::Int1: case ShaderNodes::BasicType::Int2: case ShaderNodes::BasicType::Int3: case ShaderNodes::BasicType::Int4: - return SpvOpSDiv; + return SpirvOp::OpSDiv; case ShaderNodes::BasicType::Boolean: case ShaderNodes::BasicType::Sampler2D: @@ -1073,20 +1064,20 @@ namespace Nz switch (leftType) { case ShaderNodes::BasicType::Boolean: - return SpvOpLogicalEqual; + return SpirvOp::OpLogicalEqual; case ShaderNodes::BasicType::Float1: case ShaderNodes::BasicType::Float2: case ShaderNodes::BasicType::Float3: case ShaderNodes::BasicType::Float4: case ShaderNodes::BasicType::Mat4x4: - return SpvOpFOrdEqual; + return SpirvOp::OpFOrdEqual; case ShaderNodes::BasicType::Int1: case ShaderNodes::BasicType::Int2: case ShaderNodes::BasicType::Int3: case ShaderNodes::BasicType::Int4: - return SpvOpIEqual; + return SpirvOp::OpIEqual; case ShaderNodes::BasicType::Sampler2D: case ShaderNodes::BasicType::Void: @@ -1103,17 +1094,17 @@ namespace Nz switch (rightType) { case ShaderNodes::BasicType::Float1: - return SpvOpFMul; + return SpirvOp::OpFMul; case ShaderNodes::BasicType::Float2: case ShaderNodes::BasicType::Float3: case ShaderNodes::BasicType::Float4: swapOperands = true; - return SpvOpVectorTimesScalar; + return SpirvOp::OpVectorTimesScalar; case ShaderNodes::BasicType::Mat4x4: swapOperands = true; - return SpvOpMatrixTimesScalar; + return SpirvOp::OpMatrixTimesScalar; default: break; @@ -1129,15 +1120,15 @@ namespace Nz switch (rightType) { case ShaderNodes::BasicType::Float1: - return SpvOpVectorTimesScalar; + return SpirvOp::OpVectorTimesScalar; case ShaderNodes::BasicType::Float2: case ShaderNodes::BasicType::Float3: case ShaderNodes::BasicType::Float4: - return SpvOpFMul; + return SpirvOp::OpFMul; case ShaderNodes::BasicType::Mat4x4: - return SpvOpVectorTimesMatrix; + return SpirvOp::OpVectorTimesMatrix; default: break; @@ -1150,15 +1141,15 @@ namespace Nz case ShaderNodes::BasicType::Int2: case ShaderNodes::BasicType::Int3: case ShaderNodes::BasicType::Int4: - return SpvOpIMul; + return SpirvOp::OpIMul; case ShaderNodes::BasicType::Mat4x4: { switch (rightType) { - case ShaderNodes::BasicType::Float1: return SpvOpMatrixTimesScalar; - case ShaderNodes::BasicType::Float4: return SpvOpMatrixTimesVector; - case ShaderNodes::BasicType::Mat4x4: return SpvOpMatrixTimesMatrix; + case ShaderNodes::BasicType::Float1: return SpirvOp::OpMatrixTimesScalar; + case ShaderNodes::BasicType::Float4: return SpirvOp::OpMatrixTimesVector; + case ShaderNodes::BasicType::Mat4x4: return SpirvOp::OpMatrixTimesMatrix; default: break; @@ -1181,7 +1172,7 @@ namespace Nz if (swapOperands) std::swap(leftOperand, rightOperand); - m_currentState->instructions.Append(Opcode{ op }, GetTypeId(resultType), resultId, leftOperand, rightOperand); + m_currentState->instructions.Append(op, GetTypeId(resultType), resultId, leftOperand, rightOperand); PushResultId(resultId); } @@ -1204,12 +1195,14 @@ namespace Nz UInt32 resultId = AllocateResultId(); - m_currentState->instructions.Append(Opcode{ SpvOpCompositeConstruct }, WordCount { static_cast(3 + exprResults.size()) }); - m_currentState->instructions.Append(GetTypeId(targetType)); - m_currentState->instructions.Append(resultId); + m_currentState->instructions.AppendVariadic(SpirvOp::OpCompositeConstruct, [&](const auto& appender) + { + appender(GetTypeId(targetType)); + appender(resultId); - for (UInt32 resultId : exprResults) - m_currentState->instructions.Append(resultId); + for (UInt32 exprResultId : exprResults) + appender(exprResultId); + }); PushResultId(resultId); } @@ -1262,7 +1255,7 @@ namespace Nz UInt32 resultId = AllocateResultId(); - m_currentState->instructions.Append(Opcode{ SpvOpDot }, typeId, resultId, vec1, vec2); + m_currentState->instructions.Append(SpirvOp::OpDot, typeId, resultId, vec1, vec2); PushResultId(resultId); break; } @@ -1283,7 +1276,7 @@ namespace Nz UInt32 coordinatesId = EvaluateExpression(node.coordinates); UInt32 resultId = AllocateResultId(); - m_currentState->instructions.Append(Opcode{ SpvOpImageSampleImplicitLod }, typeId, resultId, samplerId, coordinatesId); + m_currentState->instructions.Append(SpirvOp::OpImageSampleImplicitLod, typeId, resultId, samplerId, coordinatesId); PushResultId(resultId); } @@ -1305,22 +1298,24 @@ namespace Nz if (node.componentCount > 1) { - // Swizzling is implemented via SpvOpVectorShuffle using the same vector twice as operands - m_currentState->instructions.Append(Opcode{ SpvOpVectorShuffle }, WordCount{ static_cast(5 + node.componentCount) }); - m_currentState->instructions.Append(GetTypeId(targetType)); - m_currentState->instructions.Append(resultId); - m_currentState->instructions.Append(exprResultId); - m_currentState->instructions.Append(exprResultId); + // Swizzling is implemented via SpirvOp::OpVectorShuffle using the same vector twice as operands + m_currentState->instructions.AppendVariadic(SpirvOp::OpVectorShuffle, [&](const auto& appender) + { + appender(GetTypeId(targetType)); + appender(resultId); + appender(exprResultId); + appender(exprResultId); - for (std::size_t i = 0; i < node.componentCount; ++i) - m_currentState->instructions.Append(UInt32(node.components[0]) - UInt32(node.components[i])); + for (std::size_t i = 0; i < node.componentCount; ++i) + appender(UInt32(node.components[0]) - UInt32(node.components[i])); + }); } else { // Extract a single component from the vector assert(node.componentCount == 1); - m_currentState->instructions.Append(Opcode{ SpvOpCompositeExtract }, GetTypeId(targetType), resultId, exprResultId, UInt32(node.components[0]) - UInt32(ShaderNodes::SwizzleComponent::First) ); + m_currentState->instructions.Append(SpirvOp::OpCompositeExtract, GetTypeId(targetType), resultId, exprResultId, UInt32(node.components[0]) - UInt32(ShaderNodes::SwizzleComponent::First) ); } PushResultId(resultId); @@ -1368,48 +1363,12 @@ namespace Nz PushResultId(ReadVariable(it.value())); } - void SpirvWriter::MergeBlocks(std::vector& output, const Section& from) + void SpirvWriter::MergeBlocks(std::vector& output, const SpirvSection& from) { + const std::vector& bytecode = from.GetBytecode(); + std::size_t prevSize = output.size(); - output.resize(prevSize + from.data.size()); - std::copy(from.data.begin(), from.data.end(), output.begin() + prevSize); - } - - std::size_t SpirvWriter::Section::Append(const Opcode& opcode, const WordCount& wordCount) - { - return Append(UInt32(opcode.op) | UInt32(wordCount.wc) << 16); - } - - std::size_t SpirvWriter::Section::Append(const Raw& raw) - { - std::size_t offset = GetOutputOffset(); - - const UInt8* ptr = static_cast(raw.ptr); - - std::size_t size4 = CountWord(raw); - for (std::size_t i = 0; i < size4; ++i) - { - UInt32 codepoint = 0; - for (std::size_t j = 0; j < 4; ++j) - { -#ifdef NAZARA_BIG_ENDIAN - std::size_t pos = i * 4 + (3 - j); -#else - std::size_t pos = i * 4 + j; -#endif - - if (pos < raw.size) - codepoint |= UInt32(ptr[pos]) << (j * 8); - } - - Append(codepoint); - } - - return offset; - } - - unsigned int SpirvWriter::Section::CountWord(const Raw& raw) - { - return (raw.size + sizeof(UInt32) - 1) / sizeof(UInt32); + output.resize(prevSize + bytecode.size()); + std::copy(bytecode.begin(), bytecode.end(), output.begin() + prevSize); } } From 9df219e4027ff8a39c5bdd7f9603342318bf8683 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Thu, 20 Aug 2020 01:05:16 +0200 Subject: [PATCH 302/316] Add SpirvConstantCache And unsigned int types for shaders --- examples/bin/frag.shader | Bin 610 -> 610 bytes examples/bin/test.spirv | Bin 824 -> 1360 bytes include/Nazara/Shader/ShaderConstantValue.hpp | 32 + include/Nazara/Shader/ShaderEnums.hpp | 7 +- include/Nazara/Shader/ShaderNodes.hpp | 15 +- include/Nazara/Shader/SpirvConstantCache.hpp | 194 ++++ include/Nazara/Shader/SpirvConstantCache.inl | 12 + include/Nazara/Shader/SpirvSection.inl | 2 +- include/Nazara/Shader/SpirvWriter.hpp | 13 +- src/Nazara/Shader/GlslWriter.cpp | 6 +- src/Nazara/Shader/ShaderAstSerializer.cpp | 15 +- src/Nazara/Shader/ShaderNodes.cpp | 6 + src/Nazara/Shader/SpirvConstantCache.cpp | 897 ++++++++++++++++++ src/Nazara/Shader/SpirvWriter.cpp | 563 ++++------- 14 files changed, 1341 insertions(+), 421 deletions(-) create mode 100644 include/Nazara/Shader/ShaderConstantValue.hpp create mode 100644 include/Nazara/Shader/SpirvConstantCache.hpp create mode 100644 include/Nazara/Shader/SpirvConstantCache.inl create mode 100644 src/Nazara/Shader/SpirvConstantCache.cpp diff --git a/examples/bin/frag.shader b/examples/bin/frag.shader index cd71692bdb4ea28ccc2c395eea9cff48ef20d9e3..7ecc8951b3ed24eb9ba64553eefeae6fb464b1d8 100644 GIT binary patch delta 12 UcmaFF@`z=^7Dm>MTh}rI03(qFD*ylh delta 12 UcmaFF@`z=^7DkqhTh}rI03(bADgXcg diff --git a/examples/bin/test.spirv b/examples/bin/test.spirv index 3d47fe4e8ca7278bebda6c288f6ac90306dd15e6..b8858477532b82cee40f28bcdb11a8b7aa1776b0 100644 GIT binary patch literal 1360 zcmZ9LNpBND5QRH-#)K^)ge+{qj@ffZNQg}w$O+|uxFU!6Fv#(siA{3MUw~iB1&QzL zOrcR)DtEtE^{T3C+TG6ZQc4TSwVQuaT1}nIET?W}^sc0<`Fxk(qft2(+``te4QvzJ z!fslQ4%K{i z9+5V4<_`Y(L6tsI&sm&LC}nK@ZOo^Ir%SKk`D^~@pevm2{^7rfA5w*T08W5RE3*P literal 824 zcmYk4y-xx`5XDE}5Wf&aK}6-yQVI)WOpH?6S@>CB;>BD7r@2sA+Spq8|L{*)*pT>s zce@Eo9=mVe?97{ma_M;4Y{^)I{M)Q)r94u%avnk5w3=14H-t%)qzEg*ny?`>l#8Zf z7U+YPq_=O`BpU0eNF~or(#NNQSMz&!arzQx4^j3SPfzo_K)uYS@yC5Mc^}7Fad)xr zjcQT+3pm7a!*?h51(X9wp} z@WSuR!rPx*b+uo~AN}?O-seZT`0cqEKFDFteSsO_yxW1mn?36ez4=d&L;Tyt`Yukr VFBc1S#wXgfy7R7~Fqg{<;U7&^Dfa*X diff --git a/include/Nazara/Shader/ShaderConstantValue.hpp b/include/Nazara/Shader/ShaderConstantValue.hpp new file mode 100644 index 000000000..27c9e1d7e --- /dev/null +++ b/include/Nazara/Shader/ShaderConstantValue.hpp @@ -0,0 +1,32 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_SHADER_CONSTANTVALUE_HPP +#define NAZARA_SHADER_CONSTANTVALUE_HPP + +#include +#include +#include +#include +#include + +namespace Nz +{ + using ShaderConstantValue = std::variant< + bool, + float, + Int32, + UInt32, + Vector2f, + Vector3f, + Vector4f, + Vector2i32, + Vector3i32, + Vector4i32 + >; +} + +#endif diff --git a/include/Nazara/Shader/ShaderEnums.hpp b/include/Nazara/Shader/ShaderEnums.hpp index 2ddbb5b97..ed322e3e6 100644 --- a/include/Nazara/Shader/ShaderEnums.hpp +++ b/include/Nazara/Shader/ShaderEnums.hpp @@ -29,8 +29,11 @@ namespace Nz::ShaderNodes Int4, //< ivec4 Mat4x4, //< mat4 Sampler2D, //< sampler2D - - Void //< void + Void, //< void + UInt1, //< uint + UInt2, //< uvec2 + UInt3, //< uvec3 + UInt4 //< uvec4 }; enum class BinaryType diff --git a/include/Nazara/Shader/ShaderNodes.hpp b/include/Nazara/Shader/ShaderNodes.hpp index 833af1248..af96afeda 100644 --- a/include/Nazara/Shader/ShaderNodes.hpp +++ b/include/Nazara/Shader/ShaderNodes.hpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -222,19 +223,7 @@ namespace Nz ShaderExpressionType GetExpressionType() const override; void Visit(ShaderAstVisitor& visitor) override; - using Variant = std::variant< - bool, - float, - Int32, - Vector2f, - Vector3f, - Vector4f, - Vector2i32, - Vector3i32, - Vector4i32 - >; - - Variant value; + ShaderConstantValue value; template static std::shared_ptr Build(const T& value); }; diff --git a/include/Nazara/Shader/SpirvConstantCache.hpp b/include/Nazara/Shader/SpirvConstantCache.hpp new file mode 100644 index 000000000..95172c757 --- /dev/null +++ b/include/Nazara/Shader/SpirvConstantCache.hpp @@ -0,0 +1,194 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_SPIRVCONSTANTCACHE_HPP +#define NAZARA_SPIRVCONSTANTCACHE_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class ShaderAst; + class SpirvSection; + + class NAZARA_SHADER_API SpirvConstantCache + { + public: + SpirvConstantCache(UInt32& resultId); + SpirvConstantCache(const SpirvConstantCache& cache) = delete; + SpirvConstantCache(SpirvConstantCache&& cache) noexcept; + ~SpirvConstantCache(); + + struct Constant; + struct Type; + + using ConstantPtr = std::shared_ptr; + using TypePtr = std::shared_ptr; + + struct Bool {}; + + struct Float + { + UInt32 width; + }; + + struct Integer + { + UInt32 width; + bool signedness; + }; + + struct Void {}; + + struct Vector + { + TypePtr componentType; + UInt32 componentCount; + }; + + struct Matrix + { + TypePtr columnType; + UInt32 columnCount; + }; + + struct Image + { + std::optional qualifier; + std::optional depth; + std::optional sampled; + SpirvDim dim; + SpirvImageFormat format; + TypePtr sampledType; + bool arrayed; + bool multisampled; + }; + + struct Pointer + { + TypePtr type; + SpirvStorageClass storageClass; + }; + + struct Function + { + TypePtr returnType; + std::vector parameters; + }; + + struct SampledImage + { + TypePtr image; + }; + + struct Structure + { + struct Member + { + std::string name; + TypePtr type; + }; + + std::string name; + std::vector members; + }; + + using AnyType = std::variant; + + struct ConstantBool + { + bool value; + }; + + struct ConstantComposite + { + TypePtr type; + std::vector values; + }; + + struct ConstantScalar + { + std::variant value; + }; + + using AnyConstant = std::variant; + + struct Variable + { + std::string debugName; + TypePtr type; + SpirvStorageClass storageClass; + std::optional initializer; + }; + + using BaseType = std::variant; + using CompositeValue = std::variant; + using PointerOrBaseType = std::variant; + using PrimitiveType = std::variant; + using ScalarType = std::variant; + + struct Constant + { + Constant(AnyConstant c) : + constant(std::move(c)) + { + } + + AnyConstant constant; + }; + + struct Type + { + Type(AnyType c) : + type(std::move(c)) + { + } + + AnyType type; + }; + + UInt32 GetId(const Constant& c); + UInt32 GetId(const Type& t); + UInt32 GetId(const Variable& v); + + UInt32 Register(Constant c); + UInt32 Register(Type t); + UInt32 Register(Variable v); + + void Write(SpirvSection& annotations, SpirvSection& constants, SpirvSection& debugInfos, SpirvSection& types); + + SpirvConstantCache& operator=(const SpirvConstantCache& cache) = delete; + SpirvConstantCache& operator=(SpirvConstantCache&& cache) noexcept; + + static ConstantPtr BuildConstant(const ShaderConstantValue& value); + static TypePtr BuildPointerType(const ShaderNodes::BasicType& type, SpirvStorageClass storageClass); + static TypePtr BuildPointerType(const ShaderAst& shader, const ShaderExpressionType& type, SpirvStorageClass storageClass); + static TypePtr BuildType(const ShaderNodes::BasicType& type); + static TypePtr BuildType(const ShaderAst& shader, const ShaderExpressionType& type); + + private: + struct DepRegisterer; + struct Eq; + struct Internal; + + void WriteStruct(const Structure& structData, UInt32 resultId, SpirvSection& annotations, SpirvSection& debugInfos, SpirvSection& types); + + std::unique_ptr m_internal; + }; +} + +#include + +#endif diff --git a/include/Nazara/Shader/SpirvConstantCache.inl b/include/Nazara/Shader/SpirvConstantCache.inl new file mode 100644 index 000000000..b007dbb7f --- /dev/null +++ b/include/Nazara/Shader/SpirvConstantCache.inl @@ -0,0 +1,12 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ +} + +#include diff --git a/include/Nazara/Shader/SpirvSection.inl b/include/Nazara/Shader/SpirvSection.inl index f4770e3f3..e86eb59ff 100644 --- a/include/Nazara/Shader/SpirvSection.inl +++ b/include/Nazara/Shader/SpirvSection.inl @@ -96,7 +96,7 @@ namespace Nz } template - unsigned int SpirvSection::CountWord(const T& value) + unsigned int SpirvSection::CountWord(const T& /*value*/) { return 1; } diff --git a/include/Nazara/Shader/SpirvWriter.hpp b/include/Nazara/Shader/SpirvWriter.hpp index 71a617eaa..579ad1fef 100644 --- a/include/Nazara/Shader/SpirvWriter.hpp +++ b/include/Nazara/Shader/SpirvWriter.hpp @@ -11,9 +11,10 @@ #include #include #include +#include #include #include -#include +#include #include #include #include @@ -47,20 +48,22 @@ namespace Nz UInt32 AllocateResultId(); - void AppendConstants(); void AppendHeader(); - void AppendStructType(std::size_t structIndex, UInt32 resultId); - void AppendTypes(); UInt32 EvaluateExpression(const ShaderNodes::ExpressionPtr& expr); - UInt32 GetConstantId(const ShaderNodes::Constant::Variant& value) const; + UInt32 GetConstantId(const ShaderConstantValue& value) const; + UInt32 GetFunctionTypeId(ShaderExpressionType retType, const std::vector& parameters); + UInt32 GetPointerTypeId(const ShaderExpressionType& type, SpirvStorageClass storageClass) const; UInt32 GetTypeId(const ShaderExpressionType& type) const; void PushResultId(UInt32 value); UInt32 PopResultId(); UInt32 ReadVariable(ExtVar& var); + UInt32 RegisterConstant(const ShaderConstantValue& value); + UInt32 RegisterFunctionType(ShaderExpressionType retType, const std::vector& parameters); + UInt32 RegisterPointerType(ShaderExpressionType type, SpirvStorageClass storageClass); UInt32 RegisterType(ShaderExpressionType type); using ShaderAstVisitor::Visit; diff --git a/src/Nazara/Shader/GlslWriter.cpp b/src/Nazara/Shader/GlslWriter.cpp index b17c8d4a3..1e911ce13 100644 --- a/src/Nazara/Shader/GlslWriter.cpp +++ b/src/Nazara/Shader/GlslWriter.cpp @@ -231,6 +231,10 @@ namespace Nz case ShaderNodes::BasicType::Int4: return Append("ivec4"); case ShaderNodes::BasicType::Mat4x4: return Append("mat4"); case ShaderNodes::BasicType::Sampler2D: return Append("sampler2D"); + case ShaderNodes::BasicType::UInt1: return Append("uint"); + case ShaderNodes::BasicType::UInt2: return Append("uvec2"); + case ShaderNodes::BasicType::UInt3: return Append("uvec3"); + case ShaderNodes::BasicType::UInt4: return Append("uvec4"); case ShaderNodes::BasicType::Void: return Append("void"); } } @@ -459,7 +463,7 @@ namespace Nz if constexpr (std::is_same_v) Append((arg) ? "true" : "false"); - else if constexpr (std::is_same_v || std::is_same_v) + else if constexpr (std::is_same_v || std::is_same_v || std::is_same_v) Append(std::to_string(arg)); else if constexpr (std::is_same_v || std::is_same_v) Append("vec2(" + std::to_string(arg.x) + ", " + std::to_string(arg.y) + ")"); diff --git a/src/Nazara/Shader/ShaderAstSerializer.cpp b/src/Nazara/Shader/ShaderAstSerializer.cpp index 6d45cc711..396cd3d98 100644 --- a/src/Nazara/Shader/ShaderAstSerializer.cpp +++ b/src/Nazara/Shader/ShaderAstSerializer.cpp @@ -193,18 +193,19 @@ namespace Nz Value(value); }; - static_assert(std::variant_size_v == 9); + static_assert(std::variant_size_v == 10); switch (typeIndex) { case 0: SerializeValue(bool()); break; case 1: SerializeValue(float()); break; case 2: SerializeValue(Int32()); break; - case 3: SerializeValue(Vector2f()); break; - case 4: SerializeValue(Vector3f()); break; - case 5: SerializeValue(Vector4f()); break; - case 6: SerializeValue(Vector2i32()); break; - case 7: SerializeValue(Vector3i32()); break; - case 8: SerializeValue(Vector4i32()); break; + case 3: SerializeValue(UInt32()); break; + case 4: SerializeValue(Vector2f()); break; + case 5: SerializeValue(Vector3f()); break; + case 6: SerializeValue(Vector4f()); break; + case 7: SerializeValue(Vector2i32()); break; + case 8: SerializeValue(Vector3i32()); break; + case 9: SerializeValue(Vector4i32()); break; default: throw std::runtime_error("unexpected data type"); } } diff --git a/src/Nazara/Shader/ShaderNodes.cpp b/src/Nazara/Shader/ShaderNodes.cpp index 2f72a1ea0..15c7e40f0 100644 --- a/src/Nazara/Shader/ShaderNodes.cpp +++ b/src/Nazara/Shader/ShaderNodes.cpp @@ -114,12 +114,16 @@ namespace Nz::ShaderNodes case BasicType::Int2: case BasicType::Int3: case BasicType::Int4: + case BasicType::UInt2: + case BasicType::UInt3: + case BasicType::UInt4: exprType = leftExprType; break; case BasicType::Float1: case BasicType::Int1: case BasicType::Mat4x4: + case BasicType::UInt1: exprType = rightExprType; break; @@ -165,6 +169,8 @@ namespace Nz::ShaderNodes return ShaderNodes::BasicType::Float1; else if constexpr (std::is_same_v) return ShaderNodes::BasicType::Int1; + else if constexpr (std::is_same_v) + return ShaderNodes::BasicType::Int1; else if constexpr (std::is_same_v) return ShaderNodes::BasicType::Float2; else if constexpr (std::is_same_v) diff --git a/src/Nazara/Shader/SpirvConstantCache.cpp b/src/Nazara/Shader/SpirvConstantCache.cpp new file mode 100644 index 000000000..02f7b4f34 --- /dev/null +++ b/src/Nazara/Shader/SpirvConstantCache.cpp @@ -0,0 +1,897 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + struct SpirvConstantCache::Eq + { + bool Compare(const ConstantBool& lhs, const ConstantBool& rhs) const + { + return lhs.value == rhs.value; + } + + bool Compare(const ConstantComposite& lhs, const ConstantComposite& rhs) const + { + return Compare(lhs.type, rhs.type) && Compare(lhs.values, rhs.values); + } + + bool Compare(const ConstantScalar& lhs, const ConstantScalar& rhs) const + { + return lhs.value == rhs.value; + } + + bool Compare(const Bool& /*lhs*/, const Bool& /*rhs*/) const + { + return true; + } + + bool Compare(const Float& lhs, const Float& rhs) const + { + return lhs.width == rhs.width; + } + + bool Compare(const Function& lhs, const Function& rhs) const + { + return Compare(lhs.parameters, rhs.parameters) && Compare(lhs.returnType, rhs.returnType); + } + + bool Compare(const Image& lhs, const Image& rhs) const + { + return lhs.arrayed == rhs.arrayed + && lhs.dim == rhs.dim + && lhs.format == rhs.format + && lhs.multisampled == rhs.multisampled + && lhs.qualifier == rhs.qualifier + && Compare(lhs.sampledType, rhs.sampledType) + && lhs.depth == rhs.depth + && lhs.sampled == rhs.sampled; + } + + bool Compare(const Integer& lhs, const Integer& rhs) const + { + return lhs.width == rhs.width && lhs.signedness == rhs.signedness; + } + + bool Compare(const Matrix& lhs, const Matrix& rhs) const + { + return lhs.columnCount == rhs.columnCount && Compare(lhs.columnType, rhs.columnType); + } + + bool Compare(const Pointer& lhs, const Pointer& rhs) const + { + return lhs.storageClass == rhs.storageClass && Compare(lhs.type, rhs.type); + } + + bool Compare(const SampledImage& lhs, const SampledImage& rhs) const + { + return Compare(lhs.image, rhs.image); + } + + bool Compare(const Structure& lhs, const Structure& rhs) const + { + if (lhs.name != rhs.name) + return false; + + if (!Compare(lhs.members, rhs.members)) + return false; + + return true; + } + + bool Compare(const Structure::Member& lhs, const Structure::Member& rhs) const + { + if (!Compare(lhs.type, rhs.type)) + return false; + + if (lhs.name != rhs.name) + return false; + + return true; + } + + bool Compare(const Variable& lhs, const Variable& rhs) const + { + if (lhs.debugName != rhs.debugName) + return false; + + if (!Compare(lhs.initializer, rhs.initializer)) + return false; + + if (lhs.storageClass != rhs.storageClass) + return false; + + if (!Compare(lhs.type, rhs.type)) + return false; + + return true; + } + + bool Compare(const Vector& lhs, const Vector& rhs) const + { + return Compare(lhs.componentType, rhs.componentType) && lhs.componentCount == rhs.componentCount; + } + + bool Compare(const Void& /*lhs*/, const Void& /*rhs*/) const + { + return true; + } + + + bool Compare(const Constant& lhs, const Constant& rhs) const + { + return Compare(lhs.constant, rhs.constant); + } + + bool Compare(const Type& lhs, const Type& rhs) const + { + return Compare(lhs.type, rhs.type); + } + + + template + bool Compare(const std::optional& lhs, const std::optional& rhs) const + { + if (lhs.has_value() != rhs.has_value()) + return false; + + if (!lhs.has_value()) + return true; + + return Compare(*lhs, *rhs); + } + + template + bool Compare(const std::shared_ptr& lhs, const std::shared_ptr& rhs) const + { + if (bool(lhs) != bool(rhs)) + return false; + + if (!lhs) + return true; + + return Compare(*lhs, *rhs); + } + + template + bool Compare(const std::variant& lhs, const std::variant& rhs) const + { + if (lhs.index() != rhs.index()) + return false; + + return std::visit([&](auto&& arg) + { + using U = std::decay_t; + return Compare(arg, std::get(rhs)); + }, lhs); + } + + template + bool Compare(const std::vector& lhs, const std::vector& rhs) const + { + if (lhs.size() != rhs.size()) + return false; + + for (std::size_t i = 0; i < lhs.size(); ++i) + { + if (!Compare(lhs[i], rhs[i])) + return false; + } + + return true; + } + + template + bool Compare(const std::unique_ptr& lhs, const std::unique_ptr& rhs) const + { + if (bool(lhs) != bool(rhs)) + return false; + + if (!lhs) + return true; + + return Compare(*lhs, *rhs); + } + + template + bool operator()(const T& lhs, const T& rhs) const + { + return Compare(lhs, rhs); + } + }; + + struct SpirvConstantCache::DepRegisterer + { + DepRegisterer(SpirvConstantCache& c) : + cache(c) + { + } + + void Register(const Bool&) {} + void Register(const Float&) {} + void Register(const Integer&) {} + void Register(const Void&) {} + + void Register(const Image& image) + { + Register(image.sampledType); + } + + void Register(const Function& func) + { + Register(func.returnType); + Register(func.parameters); + } + + void Register(const Matrix& vec) + { + assert(vec.columnType); + cache.Register(*vec.columnType); + } + + void Register(const Pointer& ptr) + { + assert(ptr.type); + cache.Register(*ptr.type); + } + + void Register(const SampledImage& sampledImage) + { + assert(sampledImage.image); + cache.Register(*sampledImage.image); + } + + void Register(const Structure& s) + { + Register(s.members); + } + + void Register(const SpirvConstantCache::Structure::Member& m) + { + cache.Register(*m.type); + } + + void Register(const Variable& variable) + { + assert(variable.type); + cache.Register(*variable.type); + } + + void Register(const Vector& vec) + { + assert(vec.componentType); + cache.Register(*vec.componentType); + } + + void Register(const ConstantBool&) + { + cache.Register({ Bool{} }); + } + + void Register(const ConstantScalar& scalar) + { + std::visit([&](auto&& arg) + { + using T = std::decay_t; + + if constexpr (std::is_same_v) + cache.Register({ Float{ 64 } }); + else if constexpr (std::is_same_v) + cache.Register({ Float{ 32 } }); + else if constexpr (std::is_same_v) + cache.Register({ Integer{ 32, 1 } }); + else if constexpr (std::is_same_v) + cache.Register({ Integer{ 64, 1 } }); + else if constexpr (std::is_same_v) + cache.Register({ Integer{ 32, 0 } }); + else if constexpr (std::is_same_v) + cache.Register({ Integer{ 64, 0 } }); + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + + }, scalar.value); + } + + void Register(const ConstantComposite& composite) + { + assert(composite.type); + cache.Register(*composite.type); + + for (auto&& value : composite.values) + { + assert(value); + cache.Register(*value); + } + } + + + void Register(const Constant& c) + { + return Register(c.constant); + } + + void Register(const Type& t) + { + return Register(t.type); + } + + + template + void Register(const std::shared_ptr& ptr) + { + assert(ptr); + return Register(*ptr); + } + + template + void Register(const std::optional& opt) + { + if (opt) + Register(*opt); + } + + template + void Register(const std::variant& v) + { + return std::visit([&](auto&& arg) + { + return Register(arg); + }, v); + } + + template + void Register(const std::vector& lhs) + { + for (std::size_t i = 0; i < lhs.size(); ++i) + Register(lhs[i]); + } + + template + void Register(const std::unique_ptr& lhs) + { + assert(lhs); + return Register(*lhs); + } + + SpirvConstantCache& cache; + }; + + //< FIXME PLZ + struct AnyHasher + { + template + std::size_t operator()(const U&) const + { + return 42; + } + }; + + struct SpirvConstantCache::Internal + { + Internal(UInt32& resultId) : + nextResultId(resultId) + { + } + + tsl::ordered_map constantIds; + tsl::ordered_map typeIds; + tsl::ordered_map variableIds; + tsl::ordered_map structureSizes; + UInt32& nextResultId; + }; + + SpirvConstantCache::SpirvConstantCache(UInt32& resultId) + { + m_internal = std::make_unique(resultId); + } + + SpirvConstantCache::SpirvConstantCache(SpirvConstantCache&& cache) noexcept = default; + + SpirvConstantCache::~SpirvConstantCache() = default; + + UInt32 SpirvConstantCache::GetId(const Constant& c) + { + auto it = m_internal->constantIds.find(c.constant); + if (it == m_internal->constantIds.end()) + throw std::runtime_error("constant is not registered"); + + return it->second; + } + + UInt32 SpirvConstantCache::GetId(const Type& t) + { + auto it = m_internal->typeIds.find(t.type); + if (it == m_internal->typeIds.end()) + throw std::runtime_error("constant is not registered"); + + return it->second; + } + + UInt32 SpirvConstantCache::GetId(const Variable& v) + { + auto it = m_internal->variableIds.find(v); + if (it == m_internal->variableIds.end()) + throw std::runtime_error("variable is not registered"); + + return it->second; + } + + UInt32 SpirvConstantCache::Register(Constant c) + { + AnyConstant& constant = c.constant; + + DepRegisterer registerer(*this); + registerer.Register(constant); + + std::size_t h = m_internal->typeIds.hash_function()(constant); + auto it = m_internal->constantIds.find(constant, h); + if (it == m_internal->constantIds.end()) + { + UInt32 resultId = m_internal->nextResultId++; + it = m_internal->constantIds.emplace(std::move(constant), resultId).first; + } + + return it.value(); + } + + UInt32 SpirvConstantCache::Register(Type t) + { + AnyType& type = t.type; + + DepRegisterer registerer(*this); + registerer.Register(type); + + std::size_t h = m_internal->typeIds.hash_function()(type); + auto it = m_internal->typeIds.find(type, h); + if (it == m_internal->typeIds.end()) + { + UInt32 resultId = m_internal->nextResultId++; + it = m_internal->typeIds.emplace(std::move(type), resultId).first; + } + + return it.value(); + } + + UInt32 SpirvConstantCache::Register(Variable v) + { + DepRegisterer registerer(*this); + registerer.Register(v); + + std::size_t h = m_internal->variableIds.hash_function()(v); + auto it = m_internal->variableIds.find(v, h); + if (it == m_internal->variableIds.end()) + { + UInt32 resultId = m_internal->nextResultId++; + it = m_internal->variableIds.emplace(std::move(v), resultId).first; + } + + return it.value(); + } + + void SpirvConstantCache::Write(SpirvSection& annotations, SpirvSection& constants, SpirvSection& debugInfos, SpirvSection& types) + { + for (auto&& [type, id] : m_internal->typeIds) + { + UInt32 resultId = id; + + std::visit([&](auto&& arg) + { + using T = std::decay_t; + + if constexpr (std::is_same_v) + types.Append(SpirvOp::OpTypeBool, resultId); + else if constexpr (std::is_same_v) + types.Append(SpirvOp::OpTypeFloat, resultId, arg.width); + else if constexpr (std::is_same_v) + { + types.AppendVariadic(SpirvOp::OpTypeFunction, [&](const auto& appender) + { + appender(resultId); + appender(GetId(*arg.returnType)); + + for (const auto& param : arg.parameters) + appender(GetId(*param)); + }); + } + else if constexpr (std::is_same_v) + { + UInt32 depth; + if (arg.depth.has_value()) + depth = (*arg.depth) ? 1 : 0; + else + depth = 2; + + UInt32 sampled; + if (arg.sampled.has_value()) + sampled = (*arg.sampled) ? 1 : 0; + else + sampled = 2; + + types.AppendVariadic(SpirvOp::OpTypeImage, [&](const auto& appender) + { + appender(resultId); + appender(GetId(*arg.sampledType)); + appender(arg.dim); + appender(depth); + appender(arg.arrayed); + appender(arg.multisampled); + appender(sampled); + appender(arg.format); + + if (arg.qualifier) + appender(*arg.qualifier); + }); + } + else if constexpr (std::is_same_v) + types.Append(SpirvOp::OpTypeInt, resultId, arg.width, arg.signedness); + else if constexpr (std::is_same_v) + types.Append(SpirvOp::OpTypeMatrix, resultId, GetId(*arg.columnType), arg.columnCount); + else if constexpr (std::is_same_v) + types.Append(SpirvOp::OpTypePointer, resultId, arg.storageClass, GetId(*arg.type)); + else if constexpr (std::is_same_v) + types.Append(SpirvOp::OpTypeSampledImage, resultId, GetId(*arg.image)); + else if constexpr (std::is_same_v) + WriteStruct(arg, resultId, annotations, debugInfos, types); + else if constexpr (std::is_same_v) + types.Append(SpirvOp::OpTypeVector, resultId, GetId(*arg.componentType), arg.componentCount); + else if constexpr (std::is_same_v) + types.Append(SpirvOp::OpTypeVoid, resultId); + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + }, type); + } + + for (auto&& [constant, id] : m_internal->constantIds) + { + UInt32 resultId = id; + + std::visit([&](auto&& arg) + { + using T = std::decay_t; + + if constexpr (std::is_same_v) + constants.Append((arg.value) ? SpirvOp::OpConstantTrue : SpirvOp::OpConstantFalse, resultId); + else if constexpr (std::is_same_v) + { + constants.AppendVariadic(SpirvOp::OpConstantComposite, [&](const auto& appender) + { + appender(GetId(arg.type->type)); + appender(resultId); + + for (const auto& value : arg.values) + appender(GetId(value->constant)); + }); + } + else if constexpr (std::is_same_v) + { + std::visit([&](auto&& arg) + { + using T = std::decay_t; + + UInt32 typeId; + if constexpr (std::is_same_v) + typeId = GetId({ Float{ 64 } }); + else if constexpr (std::is_same_v) + typeId = GetId({ Float{ 32 } }); + else if constexpr (std::is_same_v) + typeId = GetId({ Integer{ 32, 1 } }); + else if constexpr (std::is_same_v) + typeId = GetId({ Integer{ 64, 1 } }); + else if constexpr (std::is_same_v) + typeId = GetId({ Integer{ 32, 0 } }); + else if constexpr (std::is_same_v) + typeId = GetId({ Integer{ 64, 0 } }); + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + + constants.Append(SpirvOp::OpConstant, typeId, resultId, SpirvSection::Raw{ &arg, sizeof(arg) }); + + }, arg.value); + } + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + }, constant); + } + + for (auto&& [variable, id] : m_internal->variableIds) + { + UInt32 resultId = id; + + if (!variable.debugName.empty()) + debugInfos.Append(SpirvOp::OpName, resultId, variable.debugName); + + constants.AppendVariadic(SpirvOp::OpVariable, [&](const auto& appender) + { + appender(GetId(*variable.type)); + appender(resultId); + appender(variable.storageClass); + + if (variable.initializer) + appender(GetId((*variable.initializer)->constant)); + }); + } + } + + SpirvConstantCache& SpirvConstantCache::operator=(SpirvConstantCache&& cache) noexcept = default; + + auto SpirvConstantCache::BuildConstant(const ShaderConstantValue& value) -> ConstantPtr + { + return std::make_shared(std::visit([&](auto&& arg) -> SpirvConstantCache::AnyConstant + { + using T = std::decay_t; + + if constexpr (std::is_same_v) + return ConstantBool{ arg }; + else if constexpr (std::is_same_v || std::is_same_v || std::is_same_v) + return ConstantScalar{ arg }; + else if constexpr (std::is_same_v || std::is_same_v) + { + return ConstantComposite{ + BuildType((std::is_same_v) ? ShaderNodes::BasicType::Float2 : ShaderNodes::BasicType::Int2), + { + BuildConstant(arg.x), + BuildConstant(arg.y) + } + }; + } + else if constexpr (std::is_same_v || std::is_same_v) + { + return ConstantComposite{ + BuildType((std::is_same_v) ? ShaderNodes::BasicType::Float3 : ShaderNodes::BasicType::Int3), + { + BuildConstant(arg.x), + BuildConstant(arg.y), + BuildConstant(arg.z) + } + }; + } + else if constexpr (std::is_same_v || std::is_same_v) + { + return ConstantComposite{ + BuildType((std::is_same_v) ? ShaderNodes::BasicType::Float4 : ShaderNodes::BasicType::Int4), + { + BuildConstant(arg.x), + BuildConstant(arg.y), + BuildConstant(arg.z), + BuildConstant(arg.w) + } + }; + } + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + }, value)); + } + + auto SpirvConstantCache::BuildPointerType(const ShaderNodes::BasicType& type, SpirvStorageClass storageClass) -> TypePtr + { + return std::make_shared(SpirvConstantCache::Pointer{ + SpirvConstantCache::BuildType(type), + storageClass + }); + } + + auto SpirvConstantCache::BuildPointerType(const ShaderAst& shader, const ShaderExpressionType& type, SpirvStorageClass storageClass) -> TypePtr + { + return std::make_shared(SpirvConstantCache::Pointer{ + SpirvConstantCache::BuildType(shader, type), + storageClass + }); + } + + auto SpirvConstantCache::BuildType(const ShaderNodes::BasicType& type) -> TypePtr + { + return std::make_shared([&]() -> AnyType + { + switch (type) + { + case ShaderNodes::BasicType::Boolean: + return Bool{}; + + case ShaderNodes::BasicType::Float1: + return Float{ 32 }; + + case ShaderNodes::BasicType::Int1: + return Integer{ 32, 1 }; + + case ShaderNodes::BasicType::Float2: + case ShaderNodes::BasicType::Float3: + case ShaderNodes::BasicType::Float4: + case ShaderNodes::BasicType::Int2: + case ShaderNodes::BasicType::Int3: + case ShaderNodes::BasicType::Int4: + case ShaderNodes::BasicType::UInt2: + case ShaderNodes::BasicType::UInt3: + case ShaderNodes::BasicType::UInt4: + { + auto vecType = BuildType(ShaderNodes::Node::GetComponentType(type)); + UInt32 componentCount = ShaderNodes::Node::GetComponentCount(type); + + return Vector{ vecType, componentCount }; + } + + case ShaderNodes::BasicType::Mat4x4: + return Matrix{ BuildType(ShaderNodes::BasicType::Float4), 4u }; + + case ShaderNodes::BasicType::UInt1: + return Integer{ 32, 0 }; + + case ShaderNodes::BasicType::Void: + return Void{}; + + case ShaderNodes::BasicType::Sampler2D: + { + auto imageType = Image{ + {}, //< qualifier + {}, //< depth + {}, //< sampled + SpirvDim::Dim2D, //< dim + SpirvImageFormat::Unknown, //< format + BuildType(ShaderNodes::BasicType::Float1), //< sampledType + false, //< arrayed, + false //< multisampled + }; + + return SampledImage{ std::make_shared(imageType) }; + } + } + + throw std::runtime_error("unexpected type"); + }()); + } + + auto SpirvConstantCache::BuildType(const ShaderAst& shader, const ShaderExpressionType& type) -> TypePtr + { + return std::visit([&](auto&& arg) -> TypePtr + { + using T = std::decay_t; + if constexpr (std::is_same_v) + return BuildType(arg); + else if constexpr (std::is_same_v) + { + // Register struct members type + const auto& structs = shader.GetStructs(); + auto it = std::find_if(structs.begin(), structs.end(), [&](const auto& s) { return s.name == arg; }); + if (it == structs.end()) + throw std::runtime_error("struct " + arg + " has not been defined"); + + const ShaderAst::Struct& s = *it; + + Structure sType; + sType.name = s.name; + + for (const auto& member : s.members) + { + auto& sMembers = sType.members.emplace_back(); + sMembers.name = member.name; + sMembers.type = BuildType(shader, member.type); + } + + return std::make_shared(std::move(sType)); + } + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + }, type); + } + + void SpirvConstantCache::WriteStruct(const Structure& structData, UInt32 resultId, SpirvSection& annotations, SpirvSection& debugInfos, SpirvSection& types) + { + types.AppendVariadic(SpirvOp::OpTypeStruct, [&](const auto& appender) + { + appender(resultId); + + for (const auto& member : structData.members) + appender(GetId(*member.type)); + }); + + debugInfos.Append(SpirvOp::OpName, resultId, structData.name); + + annotations.Append(SpirvOp::OpDecorate, resultId, SpirvDecoration::Block); + + FieldOffsets structOffsets(StructLayout_Std140); + + for (std::size_t memberIndex = 0; memberIndex < structData.members.size(); ++memberIndex) + { + const auto& member = structData.members[memberIndex]; + debugInfos.Append(SpirvOp::OpMemberName, resultId, memberIndex, member.name); + + std::size_t offset = std::visit([&](auto&& arg) -> std::size_t + { + using T = std::decay_t; + + if constexpr (std::is_same_v) + return structOffsets.AddField(StructFieldType_Bool1); + else if constexpr (std::is_same_v) + { + switch (arg.width) + { + case 32: return structOffsets.AddField(StructFieldType_Float1); + case 64: return structOffsets.AddField(StructFieldType_Double1); + default: throw std::runtime_error("unexpected float width " + std::to_string(arg.width)); + } + } + else if constexpr (std::is_same_v) + return structOffsets.AddField((arg.signedness) ? StructFieldType_Int1 : StructFieldType_UInt1); + else if constexpr (std::is_same_v) + { + assert(std::holds_alternative(arg.columnType->type)); + Vector& columnVec = std::get(arg.columnType->type); + + if (!std::holds_alternative(columnVec.componentType->type)) + throw std::runtime_error("unexpected vector type"); + + Float& vecType = std::get(columnVec.componentType->type); + + StructFieldType columnType; + switch (vecType.width) + { + case 32: columnType = StructFieldType_Float1; break; + case 64: columnType = StructFieldType_Double1; break; + default: throw std::runtime_error("unexpected float width " + std::to_string(vecType.width)); + } + + annotations.Append(SpirvOp::OpMemberDecorate, resultId, memberIndex, SpirvDecoration::ColMajor); + annotations.Append(SpirvOp::OpMemberDecorate, resultId, memberIndex, SpirvDecoration::MatrixStride, 16); + + return structOffsets.AddMatrix(columnType, arg.columnCount, columnVec.componentCount, true); + } + else if constexpr (std::is_same_v) + throw std::runtime_error("unhandled pointer in struct"); + else if constexpr (std::is_same_v) + { + auto it = m_internal->structureSizes.find(arg); + assert(it != m_internal->structureSizes.end()); + + return structOffsets.AddStruct(it->second); + } + else if constexpr (std::is_same_v) + { + if (std::holds_alternative(arg.componentType->type)) + return structOffsets.AddField(static_cast(StructFieldType_Bool1 + arg.componentCount - 1)); + else if (std::holds_alternative(arg.componentType->type)) + { + Float& floatData = std::get(arg.componentType->type); + switch (floatData.width) + { + case 32: return structOffsets.AddField(static_cast(StructFieldType_Float1 + arg.componentCount - 1)); + case 64: return structOffsets.AddField(static_cast(StructFieldType_Double1 + arg.componentCount - 1)); + default: throw std::runtime_error("unexpected float width " + std::to_string(floatData.width)); + } + } + else if (std::holds_alternative(arg.componentType->type)) + { + Integer& intData = std::get(arg.componentType->type); + if (intData.width != 32) + throw std::runtime_error("unexpected integer width " + std::to_string(intData.width)); + + if (intData.signedness) + return structOffsets.AddField(static_cast(StructFieldType_Int1 + arg.componentCount - 1)); + else + return structOffsets.AddField(static_cast(StructFieldType_UInt1 + arg.componentCount - 1)); + } + else + throw std::runtime_error("unexpected type for vector"); + } + else if constexpr (std::is_same_v) + throw std::runtime_error("unexpected function as struct member"); + else if constexpr (std::is_same_v || std::is_same_v) + throw std::runtime_error("unexpected opaque type as struct member"); + else if constexpr (std::is_same_v) + throw std::runtime_error("unexpected void as struct member"); + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + }, member.type->type); + + annotations.Append(SpirvOp::OpMemberDecorate, resultId, memberIndex, SpirvDecoration::Offset, offset); + } + + m_internal->structureSizes.emplace(structData, std::move(structOffsets)); + } +} diff --git a/src/Nazara/Shader/SpirvWriter.cpp b/src/Nazara/Shader/SpirvWriter.cpp index fb767d0e8..398ee8e71 100644 --- a/src/Nazara/Shader/SpirvWriter.cpp +++ b/src/Nazara/Shader/SpirvWriter.cpp @@ -4,10 +4,10 @@ #include #include -#include #include #include #include +#include #include #include #include @@ -24,23 +24,25 @@ namespace Nz { namespace { - using ConstantVariant = ShaderNodes::Constant::Variant; - class PreVisitor : public ShaderAstRecursiveVisitor, public ShaderVarVisitor { public: using BuiltinContainer = std::unordered_set>; - using ConstantContainer = tsl::ordered_set; using ExtInstList = std::unordered_set; using LocalContainer = std::unordered_set>; using ParameterContainer = std::unordered_set< std::shared_ptr>; + PreVisitor(SpirvConstantCache& constantCache) : + m_constantCache(constantCache) + { + } + using ShaderAstRecursiveVisitor::Visit; using ShaderVarVisitor::Visit; void Visit(ShaderNodes::AccessMember& node) override { - constants.emplace(Int32(node.memberIndex)); + m_constantCache.Register(*SpirvConstantCache::BuildConstant(UInt32(node.memberIndex))); ShaderAstRecursiveVisitor::Visit(node); } @@ -49,35 +51,8 @@ namespace Nz { std::visit([&](auto&& arg) { - using T = std::decay_t; - - if constexpr (std::is_same_v || std::is_same_v || std::is_same_v) - constants.emplace(arg); - else if constexpr (std::is_same_v || std::is_same_v) - { - constants.emplace(arg.x); - constants.emplace(arg.y); - constants.emplace(arg); - } - else if constexpr (std::is_same_v || std::is_same_v) - { - constants.emplace(arg.x); - constants.emplace(arg.y); - constants.emplace(arg.z); - constants.emplace(arg); - } - else if constexpr (std::is_same_v || std::is_same_v) - { - constants.emplace(arg.x); - constants.emplace(arg.y); - constants.emplace(arg.z); - constants.emplace(arg.w); - constants.emplace(arg); - } - else - static_assert(AlwaysFalse::value, "non-exhaustive visitor"); - }, - node.value); + m_constantCache.Register(*SpirvConstantCache::BuildConstant(arg)); + }, node.value); ShaderAstRecursiveVisitor::Visit(node); } @@ -118,7 +93,7 @@ namespace Nz builtinVars.insert(std::static_pointer_cast(var.shared_from_this())); } - void Visit(ShaderNodes::InputVariable& var) override + void Visit(ShaderNodes::InputVariable& /*var*/) override { /* Handled by ShaderAst */ } @@ -128,7 +103,7 @@ namespace Nz localVars.insert(std::static_pointer_cast(var.shared_from_this())); } - void Visit(ShaderNodes::OutputVariable& var) override + void Visit(ShaderNodes::OutputVariable& /*var*/) override { /* Handled by ShaderAst */ } @@ -138,32 +113,18 @@ namespace Nz paramVars.insert(std::static_pointer_cast(var.shared_from_this())); } - void Visit(ShaderNodes::UniformVariable& var) override + void Visit(ShaderNodes::UniformVariable& /*var*/) override { /* Handled by ShaderAst */ } BuiltinContainer builtinVars; - ConstantContainer constants; ExtInstList extInsts; LocalContainer localVars; ParameterContainer paramVars; - }; - class AssignVisitor : public ShaderAstRecursiveVisitor - { - public: - void Visit(ShaderNodes::AccessMember& node) override - { - } - - void Visit(ShaderNodes::Identifier& node) override - { - } - - void Visit(ShaderNodes::SwizzleOp& node) override - { - } + private: + SpirvConstantCache& m_constantCache; }; template @@ -202,6 +163,11 @@ namespace Nz struct SpirvWriter::State { + State() : + constantTypeCache(nextVarIndex) + { + } + struct Func { UInt32 typeId; @@ -209,18 +175,16 @@ namespace Nz std::vector paramsId; }; - std::unordered_map extensionInstructions; - std::unordered_map builtinIds; - std::unordered_map varToResult; - tsl::ordered_map constantIds; - tsl::ordered_map typeIds; - std::vector funcs; tsl::ordered_map inputIds; tsl::ordered_map outputIds; tsl::ordered_map uniformIds; - std::vector> structFields; + std::unordered_map extensionInstructions; + std::unordered_map builtinIds; + std::unordered_map varToResult; + std::vector funcs; std::vector resultIds; UInt32 nextVarIndex = 1; + SpirvConstantCache constantTypeCache; //< init after nextVarIndex // Output SpirvSection header; @@ -251,13 +215,11 @@ namespace Nz m_currentState = nullptr; }); - state.structFields.resize(shader.GetStructCount()); - std::vector functionStatements; ShaderAstCloner cloner; - PreVisitor preVisitor; + PreVisitor preVisitor(state.constantTypeCache); for (const auto& func : shader.GetFunctions()) { functionStatements.emplace_back(cloner.Clone(func.statement)); @@ -277,13 +239,16 @@ namespace Nz } for (const auto& input : shader.GetInputs()) - RegisterType(input.type); + RegisterPointerType(input.type, SpirvStorageClass::Input); for (const auto& output : shader.GetOutputs()) - RegisterType(output.type); + RegisterPointerType(output.type, SpirvStorageClass::Output); for (const auto& uniform : shader.GetUniforms()) - RegisterType(uniform.type); + RegisterPointerType(uniform.type, SpirvStorageClass::Uniform); + + for (const auto& func : shader.GetFunctions()) + RegisterFunctionType(func.returnType, func.parameters); for (const auto& local : preVisitor.localVars) RegisterType(local->type); @@ -291,104 +256,103 @@ namespace Nz for (const auto& builtin : preVisitor.builtinVars) RegisterType(builtin->type); - // Register constant types - for (const auto& constant : preVisitor.constants) - { - std::visit([&](auto&& arg) - { - using T = std::decay_t; - RegisterType(GetBasicType()); - }, constant); - } - - AppendTypes(); - // Register result id and debug infos for global variables/functions for (const auto& builtin : preVisitor.builtinVars) { - const ShaderExpressionType& builtinExprType = builtin->type; - assert(std::holds_alternative(builtinExprType)); - - ShaderNodes::BasicType builtinType = std::get(builtinExprType); - - ExtVar builtinData; - builtinData.pointerTypeId = AllocateResultId(); - builtinData.typeId = GetTypeId(builtinType); - builtinData.varId = AllocateResultId(); - - SpvBuiltIn spvBuiltin; - std::string debugName; + SpirvConstantCache::Variable variable; + SpirvBuiltIn builtinDecoration; switch (builtin->entry) { case ShaderNodes::BuiltinEntry::VertexPosition: - debugName = "builtin_VertexPosition"; - spvBuiltin = SpvBuiltInPosition; + variable.debugName = "builtin_VertexPosition"; + variable.storageClass = SpirvStorageClass::Output; + + builtinDecoration = SpirvBuiltIn::Position; break; default: throw std::runtime_error("unexpected builtin type"); } - state.debugInfo.Append(SpirvOp::OpName, builtinData.varId, debugName); - state.types.Append(SpirvOp::OpTypePointer, builtinData.pointerTypeId, SpvStorageClassOutput, builtinData.typeId); - state.types.Append(SpirvOp::OpVariable, builtinData.pointerTypeId, builtinData.varId, SpvStorageClassOutput); + const ShaderExpressionType& builtinExprType = builtin->type; + assert(std::holds_alternative(builtinExprType)); - state.annotations.Append(SpirvOp::OpDecorate, builtinData.varId, SpvDecorationBuiltIn, spvBuiltin); + ShaderNodes::BasicType builtinType = std::get(builtinExprType); + + variable.type = SpirvConstantCache::BuildPointerType(builtinType, variable.storageClass); + + UInt32 varId = m_currentState->constantTypeCache.Register(variable); + + ExtVar builtinData; + builtinData.pointerTypeId = GetPointerTypeId(builtinType, variable.storageClass); + builtinData.typeId = GetTypeId(builtinType); + builtinData.varId = varId; + + state.annotations.Append(SpirvOp::OpDecorate, builtinData.varId, SpvDecorationBuiltIn, builtinDecoration); state.builtinIds.emplace(builtin->entry, builtinData); } for (const auto& input : shader.GetInputs()) { + SpirvConstantCache::Variable variable; + variable.debugName = input.name; + variable.storageClass = SpirvStorageClass::Input; + variable.type = SpirvConstantCache::BuildPointerType(shader, input.type, variable.storageClass); + + UInt32 varId = m_currentState->constantTypeCache.Register(variable); + ExtVar inputData; - inputData.pointerTypeId = AllocateResultId(); + inputData.pointerTypeId = GetPointerTypeId(input.type, variable.storageClass); inputData.typeId = GetTypeId(input.type); - inputData.varId = AllocateResultId(); + inputData.varId = varId; - state.inputIds.emplace(input.name, inputData); - - state.debugInfo.Append(SpirvOp::OpName, inputData.varId, input.name); - state.types.Append(SpirvOp::OpTypePointer, inputData.pointerTypeId, SpvStorageClassInput, inputData.typeId); - state.types.Append(SpirvOp::OpVariable, inputData.pointerTypeId, inputData.varId, SpvStorageClassInput); + state.inputIds.emplace(input.name, std::move(inputData)); if (input.locationIndex) - state.annotations.Append(SpirvOp::OpDecorate, inputData.varId, SpvDecorationLocation, *input.locationIndex); + state.annotations.Append(SpirvOp::OpDecorate, varId, SpvDecorationLocation, *input.locationIndex); } for (const auto& output : shader.GetOutputs()) { + SpirvConstantCache::Variable variable; + variable.debugName = output.name; + variable.storageClass = SpirvStorageClass::Output; + variable.type = SpirvConstantCache::BuildPointerType(shader, output.type, variable.storageClass); + + UInt32 varId = m_currentState->constantTypeCache.Register(variable); + ExtVar outputData; - outputData.pointerTypeId = AllocateResultId(); + outputData.pointerTypeId = GetPointerTypeId(output.type, variable.storageClass); outputData.typeId = GetTypeId(output.type); - outputData.varId = AllocateResultId(); + outputData.varId = varId; - state.outputIds.emplace(output.name, outputData); - - state.debugInfo.Append(SpirvOp::OpName, outputData.varId, output.name); - state.types.Append(SpirvOp::OpTypePointer, outputData.pointerTypeId, SpvStorageClassOutput, outputData.typeId); - state.types.Append(SpirvOp::OpVariable, outputData.pointerTypeId, outputData.varId, SpvStorageClassOutput); + state.outputIds.emplace(output.name, std::move(outputData)); if (output.locationIndex) - state.annotations.Append(SpirvOp::OpDecorate, outputData.varId, SpvDecorationLocation, *output.locationIndex); + state.annotations.Append(SpirvOp::OpDecorate, varId, SpvDecorationLocation, *output.locationIndex); } for (const auto& uniform : shader.GetUniforms()) { + SpirvConstantCache::Variable variable; + variable.debugName = uniform.name; + variable.storageClass = SpirvStorageClass::Uniform; + variable.type = SpirvConstantCache::BuildPointerType(shader, uniform.type, variable.storageClass); + + UInt32 varId = m_currentState->constantTypeCache.Register(variable); + ExtVar uniformData; - uniformData.pointerTypeId = AllocateResultId(); + uniformData.pointerTypeId = GetPointerTypeId(uniform.type, variable.storageClass); uniformData.typeId = GetTypeId(uniform.type); - uniformData.varId = AllocateResultId(); + uniformData.varId = varId; - state.uniformIds.emplace(uniform.name, uniformData); - - state.debugInfo.Append(SpirvOp::OpName, uniformData.varId, uniform.name); - state.types.Append(SpirvOp::OpTypePointer, uniformData.pointerTypeId, SpvStorageClassUniform, uniformData.typeId); - state.types.Append(SpirvOp::OpVariable, uniformData.pointerTypeId, uniformData.varId, SpvStorageClassUniform); + state.uniformIds.emplace(uniform.name, std::move(uniformData)); if (uniform.bindingIndex) { - state.annotations.Append(SpirvOp::OpDecorate, uniformData.varId, SpvDecorationBinding, *uniform.bindingIndex); - state.annotations.Append(SpirvOp::OpDecorate, uniformData.varId, SpvDecorationDescriptorSet, 0); + state.annotations.Append(SpirvOp::OpDecorate, varId, SpvDecorationBinding, *uniform.bindingIndex); + state.annotations.Append(SpirvOp::OpDecorate, varId, SpvDecorationDescriptorSet, 0); } } @@ -396,26 +360,11 @@ namespace Nz { auto& funcData = state.funcs.emplace_back(); funcData.id = AllocateResultId(); - funcData.typeId = AllocateResultId(); + funcData.typeId = GetFunctionTypeId(func.returnType, func.parameters); state.debugInfo.Append(SpirvOp::OpName, funcData.id, func.name); - - state.types.AppendVariadic(SpirvOp::OpTypeFunction, [&](const auto& appender) - { - appender(funcData.typeId); - appender(GetTypeId(func.returnType)); - - for (const auto& param : func.parameters) - appender(GetTypeId(param.type)); - }); } - // Register constants - for (const auto& constant : preVisitor.constants) - state.constantIds[constant] = AllocateResultId(); - - AppendConstants(); - std::size_t entryPointIndex = std::numeric_limits::max(); for (std::size_t funcIndex = 0; funcIndex < shader.GetFunctionCount(); ++funcIndex) @@ -448,11 +397,13 @@ namespace Nz assert(entryPointIndex != std::numeric_limits::max()); + m_currentState->constantTypeCache.Write(m_currentState->annotations, m_currentState->constants, m_currentState->debugInfo, m_currentState->types); + AppendHeader(); SpvExecutionModel execModel; const auto& entryFuncData = shader.GetFunction(entryPointIndex); - const auto& entryFunc = m_currentState->funcs[entryPointIndex]; + const auto& entryFunc = state.funcs[entryPointIndex]; assert(m_context.shader); switch (m_context.shader->GetStage()) @@ -471,21 +422,19 @@ namespace Nz // OpEntryPoint Vertex %main "main" %outNormal %inNormals %outTexCoords %inTexCoord %_ %inPos - std::size_t nameSize = state.header.CountWord(entryFuncData.name); - state.header.AppendVariadic(SpirvOp::OpEntryPoint, [&](const auto& appender) { appender(execModel); appender(entryFunc.id); appender(entryFuncData.name); - for (const auto& [name, varData] : m_currentState->builtinIds) + for (const auto& [name, varData] : state.builtinIds) appender(varData.varId); - for (const auto& [name, varData] : m_currentState->inputIds) + for (const auto& [name, varData] : state.inputIds) appender(varData.varId); - for (const auto& [name, varData] : m_currentState->outputIds) + for (const auto& [name, varData] : state.outputIds) appender(varData.varId); }); @@ -513,31 +462,6 @@ namespace Nz return m_currentState->nextVarIndex++; } - void SpirvWriter::AppendConstants() - { - for (const auto& [value, resultId] : m_currentState->constantIds) - { - UInt32 constantId = resultId; - std::visit([&](auto&& arg) - { - using T = std::decay_t; - - if constexpr (std::is_same_v) - m_currentState->constants.Append((arg) ? SpirvOp::OpConstantTrue : SpirvOp::OpConstantFalse, constantId); - else if constexpr (std::is_same_v || std::is_same_v) - m_currentState->constants.Append(SpirvOp::OpConstant, GetTypeId(GetBasicType()), constantId, SpirvSection::Raw{ &arg, sizeof(arg) }); - else if constexpr (std::is_same_v || std::is_same_v) - m_currentState->constants.Append(SpirvOp::OpConstantComposite, GetTypeId(GetBasicType()), constantId, GetConstantId(arg.x), GetConstantId(arg.y)); - else if constexpr (std::is_same_v || std::is_same_v) - m_currentState->constants.Append(SpirvOp::OpConstantComposite, GetTypeId(GetBasicType()), constantId, GetConstantId(arg.x), GetConstantId(arg.y), GetConstantId(arg.z)); - else if constexpr (std::is_same_v || std::is_same_v) - m_currentState->constants.Append(SpirvOp::OpConstantComposite, GetTypeId(GetBasicType()), constantId, GetConstantId(arg.x), GetConstantId(arg.y), GetConstantId(arg.z), GetConstantId(arg.w)); - else - static_assert(AlwaysFalse::value, "non-exhaustive visitor"); - }, value); - } - } - void SpirvWriter::AppendHeader() { m_currentState->header.Append(SpvMagicNumber); //< Spir-V magic number @@ -557,180 +481,41 @@ namespace Nz m_currentState->header.Append(SpirvOp::OpMemoryModel, SpvAddressingModelLogical, SpvMemoryModelGLSL450); } - void SpirvWriter::AppendStructType(std::size_t structIndex, UInt32 resultId) - { - const ShaderAst::Struct& s = m_context.shader->GetStruct(structIndex); - - m_currentState->types.Append(SpirvOp::OpTypeStruct, SpirvSection::OpSize{ static_cast(1 + 1 + s.members.size()) }); - m_currentState->types.Append(resultId); - - m_currentState->debugInfo.Append(SpirvOp::OpName, resultId, s.name); - - m_currentState->annotations.Append(SpirvOp::OpDecorate, resultId, SpvDecorationBlock); - - FieldOffsets structOffsets(StructLayout_Std140); - - for (std::size_t memberIndex = 0; memberIndex < s.members.size(); ++memberIndex) - { - const auto& member = s.members[memberIndex]; - m_currentState->types.Append(GetTypeId(member.type)); - m_currentState->debugInfo.Append(SpirvOp::OpMemberName, resultId, memberIndex, member.name); - - std::visit([&](auto&& arg) - { - using T = std::decay_t; - if constexpr (std::is_same_v) - { - std::size_t offset = [&] { - switch (arg) - { - case ShaderNodes::BasicType::Boolean: return structOffsets.AddField(StructFieldType_Bool1); - case ShaderNodes::BasicType::Float1: return structOffsets.AddField(StructFieldType_Float1); - case ShaderNodes::BasicType::Float2: return structOffsets.AddField(StructFieldType_Float2); - case ShaderNodes::BasicType::Float3: return structOffsets.AddField(StructFieldType_Float3); - case ShaderNodes::BasicType::Float4: return structOffsets.AddField(StructFieldType_Float4); - case ShaderNodes::BasicType::Int1: return structOffsets.AddField(StructFieldType_Int1); - case ShaderNodes::BasicType::Int2: return structOffsets.AddField(StructFieldType_Int2); - case ShaderNodes::BasicType::Int3: return structOffsets.AddField(StructFieldType_Int3); - case ShaderNodes::BasicType::Int4: return structOffsets.AddField(StructFieldType_Int4); - case ShaderNodes::BasicType::Mat4x4: return structOffsets.AddMatrix(StructFieldType_Float1, 4, 4, true); - case ShaderNodes::BasicType::Sampler2D: throw std::runtime_error("unexpected sampler2D as struct member"); - case ShaderNodes::BasicType::Void: throw std::runtime_error("unexpected void as struct member"); - } - - assert(false); - throw std::runtime_error("unhandled type"); - }(); - - m_currentState->annotations.Append(SpirvOp::OpMemberDecorate, resultId, memberIndex, SpvDecorationOffset, offset); - - if (arg == ShaderNodes::BasicType::Mat4x4) - { - m_currentState->annotations.Append(SpirvOp::OpMemberDecorate, resultId, memberIndex, SpvDecorationColMajor); - m_currentState->annotations.Append(SpirvOp::OpMemberDecorate, resultId, memberIndex, SpvDecorationMatrixStride, 16); - } - } - else if constexpr (std::is_same_v) - { - // Register struct members type - const auto& structs = m_context.shader->GetStructs(); - auto it = std::find_if(structs.begin(), structs.end(), [&](const auto& s) { return s.name == arg; }); - if (it == structs.end()) - throw std::runtime_error("struct " + arg + " has not been defined"); - - std::size_t nestedStructIndex = std::distance(structs.begin(), it); - std::optional nestedFieldOffset = m_currentState->structFields[nestedStructIndex]; - if (!nestedFieldOffset) - throw std::runtime_error("struct dependency cycle"); - - structOffsets.AddStruct(nestedFieldOffset.value()); - } - else - static_assert(AlwaysFalse::value, "non-exhaustive visitor"); - }, member.type); - } - - m_currentState->structFields[structIndex] = structOffsets; - } - - void SpirvWriter::AppendTypes() - { - for (const auto& [type, typeId] : m_currentState->typeIds.values_container()) - { - UInt32 resultId = typeId; - - // Register sub-types, if any - std::visit([&](auto&& arg) - { - using T = std::decay_t; - if constexpr (std::is_same_v) - { - switch (arg) - { - case ShaderNodes::BasicType::Boolean: - m_currentState->types.Append(SpirvOp::OpTypeBool, resultId); - break; - - case ShaderNodes::BasicType::Float1: - m_currentState->types.Append(SpirvOp::OpTypeFloat, resultId, 32); - break; - - case ShaderNodes::BasicType::Float2: - case ShaderNodes::BasicType::Float3: - case ShaderNodes::BasicType::Float4: - case ShaderNodes::BasicType::Int2: - case ShaderNodes::BasicType::Int3: - case ShaderNodes::BasicType::Int4: - { - ShaderNodes::BasicType baseType = ShaderNodes::Node::GetComponentType(arg); - - UInt32 vecSize = UInt32(arg) - UInt32(baseType) + 1; - - m_currentState->types.Append(SpirvOp::OpTypeVector, resultId, GetTypeId(baseType), vecSize); - break; - } - - case ShaderNodes::BasicType::Int1: - m_currentState->types.Append(SpirvOp::OpTypeInt, resultId, 32, 1); - break; - - case ShaderNodes::BasicType::Mat4x4: - { - m_currentState->types.Append(SpirvOp::OpTypeMatrix, resultId, GetTypeId(ShaderNodes::BasicType::Float4), 4); - break; - } - - case ShaderNodes::BasicType::Sampler2D: - { - UInt32 imageTypeId = resultId - 1; - - m_currentState->types.Append(SpirvOp::OpTypeImage, imageTypeId, GetTypeId(ShaderNodes::BasicType::Float1), SpvDim2D, 0, 0, 0, 1, SpvImageFormatUnknown); - m_currentState->types.Append(SpirvOp::OpTypeSampledImage, resultId, imageTypeId); - break; - } - - case ShaderNodes::BasicType::Void: - m_currentState->types.Append(SpirvOp::OpTypeVoid, resultId); - break; - } - } - else if constexpr (std::is_same_v) - { - // Register struct members type - const auto& structs = m_context.shader->GetStructs(); - auto it = std::find_if(structs.begin(), structs.end(), [&](const auto& s) { return s.name == arg; }); - if (it == structs.end()) - throw std::runtime_error("struct " + arg + " has not been defined"); - - std::size_t structIndex = std::distance(structs.begin(), it); - AppendStructType(structIndex, resultId); - } - else - static_assert(AlwaysFalse::value, "non-exhaustive visitor"); - }, type); - } - } - UInt32 SpirvWriter::EvaluateExpression(const ShaderNodes::ExpressionPtr& expr) { Visit(expr); return PopResultId(); } - UInt32 SpirvWriter::GetConstantId(const ShaderNodes::Constant::Variant& value) const + UInt32 SpirvWriter::GetConstantId(const ShaderConstantValue& value) const { - auto typeIt = m_currentState->constantIds.find(value); - assert(typeIt != m_currentState->constantIds.end()); + return m_currentState->constantTypeCache.GetId(*SpirvConstantCache::BuildConstant(value)); + } - return typeIt->second; + UInt32 SpirvWriter::GetFunctionTypeId(ShaderExpressionType retType, const std::vector& parameters) + { + std::vector parameterTypes; + parameterTypes.reserve(parameters.size()); + + for (const auto& parameter : parameters) + parameterTypes.push_back(SpirvConstantCache::BuildType(*m_context.shader, parameter.type)); + + return m_currentState->constantTypeCache.GetId({ + SpirvConstantCache::Function { + SpirvConstantCache::BuildType(*m_context.shader, retType), + std::move(parameterTypes) + } + }); + } + + UInt32 SpirvWriter::GetPointerTypeId(const ShaderExpressionType& type, SpirvStorageClass storageClass) const + { + return m_currentState->constantTypeCache.GetId(*SpirvConstantCache::BuildPointerType(*m_context.shader, type, storageClass)); } UInt32 SpirvWriter::GetTypeId(const ShaderExpressionType& type) const { - auto typeIt = m_currentState->typeIds.find(type); - assert(typeIt != m_currentState->typeIds.end()); - - return typeIt->second; + return m_currentState->constantTypeCache.GetId(*SpirvConstantCache::BuildType(*m_context.shader, type)); } void SpirvWriter::PushResultId(UInt32 value) @@ -762,68 +547,42 @@ namespace Nz return var.valueId.value(); } + UInt32 SpirvWriter::RegisterConstant(const ShaderConstantValue& value) + { + return m_currentState->constantTypeCache.Register(*SpirvConstantCache::BuildConstant(value)); + } + + UInt32 SpirvWriter::RegisterFunctionType(ShaderExpressionType retType, const std::vector& parameters) + { + std::vector parameterTypes; + parameterTypes.reserve(parameters.size()); + + for (const auto& parameter : parameters) + parameterTypes.push_back(SpirvConstantCache::BuildType(*m_context.shader, parameter.type)); + + return m_currentState->constantTypeCache.Register({ + SpirvConstantCache::Function { + SpirvConstantCache::BuildType(*m_context.shader, retType), + std::move(parameterTypes) + } + }); + } + + UInt32 SpirvWriter::RegisterPointerType(ShaderExpressionType type, SpirvStorageClass storageClass) + { + return m_currentState->constantTypeCache.Register(*SpirvConstantCache::BuildPointerType(*m_context.shader, type, storageClass)); + } + UInt32 SpirvWriter::RegisterType(ShaderExpressionType type) { - auto it = m_currentState->typeIds.find(type); - if (it == m_currentState->typeIds.end()) - { - // Register sub-types, if any - std::visit([&](auto&& arg) - { - using T = std::decay_t; - if constexpr (std::is_same_v) - { - switch (arg) - { - case ShaderNodes::BasicType::Boolean: - case ShaderNodes::BasicType::Float1: - case ShaderNodes::BasicType::Int1: - case ShaderNodes::BasicType::Void: - break; //< Nothing to do - - // In SPIR-V, vec3 (for example) depends on float - case ShaderNodes::BasicType::Float2: - case ShaderNodes::BasicType::Float3: - case ShaderNodes::BasicType::Float4: - case ShaderNodes::BasicType::Int2: - case ShaderNodes::BasicType::Int3: - case ShaderNodes::BasicType::Int4: - case ShaderNodes::BasicType::Mat4x4: - RegisterType(ShaderNodes::Node::GetComponentType(arg)); - break; - - case ShaderNodes::BasicType::Sampler2D: - RegisterType(ShaderNodes::BasicType::Float1); - AllocateResultId(); //< Reserve a result id for the image type - break; - } - } - else if constexpr (std::is_same_v) - { - // Register struct members type - const auto& structs = m_context.shader->GetStructs(); - auto it = std::find_if(structs.begin(), structs.end(), [&](const auto& s) { return s.name == arg; }); - if (it == structs.end()) - throw std::runtime_error("struct " + arg + " has not been defined"); - - const ShaderAst::Struct& s = *it; - for (const auto& member : s.members) - RegisterType(member.type); - } - else - static_assert(AlwaysFalse::value, "non-exhaustive visitor"); - }, type); - - it = m_currentState->typeIds.emplace(std::move(type), AllocateResultId()).first; - } - - return it->second; + assert(m_currentState); + return m_currentState->constantTypeCache.Register(*SpirvConstantCache::BuildType(*m_context.shader, type)); } void SpirvWriter::Visit(ShaderNodes::AccessMember& node) { UInt32 pointerId; - SpvStorageClass storage; + SpirvStorageClass storage; switch (node.structExpr->GetType()) { @@ -848,7 +607,7 @@ namespace Nz auto it = m_currentState->inputIds.find(inputVar.name); assert(it != m_currentState->inputIds.end()); - storage = SpvStorageClassInput; + storage = SpirvStorageClass::Input; pointerId = it->second.varId; break; @@ -860,7 +619,7 @@ namespace Nz auto it = m_currentState->outputIds.find(outputVar.name); assert(it != m_currentState->outputIds.end()); - storage = SpvStorageClassOutput; + storage = SpirvStorageClass::Output; pointerId = it->second.varId; break; @@ -872,7 +631,7 @@ namespace Nz auto it = m_currentState->uniformIds.find(uniformVar.name); assert(it != m_currentState->uniformIds.end()); - storage = SpvStorageClassUniform; + storage = SpirvStorageClass::Uniform; pointerId = it->second.varId; break; @@ -892,11 +651,9 @@ namespace Nz } UInt32 memberPointerId = AllocateResultId(); - UInt32 pointerType = AllocateResultId(); + UInt32 pointerType = RegisterPointerType(node.exprType, storage); //< FIXME UInt32 typeId = GetTypeId(node.exprType); - UInt32 indexId = GetConstantId(Int32(node.memberIndex)); - - m_currentState->types.Append(SpirvOp::OpTypePointer, pointerType, storage, typeId); + UInt32 indexId = GetConstantId(UInt32(node.memberIndex)); m_currentState->instructions.Append(SpirvOp::OpAccessChain, pointerType, memberPointerId, pointerId, indexId); @@ -1002,6 +759,10 @@ namespace Nz case ShaderNodes::BasicType::Int2: case ShaderNodes::BasicType::Int3: case ShaderNodes::BasicType::Int4: + case ShaderNodes::BasicType::UInt1: + case ShaderNodes::BasicType::UInt2: + case ShaderNodes::BasicType::UInt3: + case ShaderNodes::BasicType::UInt4: return SpirvOp::OpIAdd; case ShaderNodes::BasicType::Boolean: @@ -1026,6 +787,10 @@ namespace Nz case ShaderNodes::BasicType::Int2: case ShaderNodes::BasicType::Int3: case ShaderNodes::BasicType::Int4: + case ShaderNodes::BasicType::UInt1: + case ShaderNodes::BasicType::UInt2: + case ShaderNodes::BasicType::UInt3: + case ShaderNodes::BasicType::UInt4: return SpirvOp::OpISub; case ShaderNodes::BasicType::Boolean: @@ -1052,6 +817,12 @@ namespace Nz case ShaderNodes::BasicType::Int4: return SpirvOp::OpSDiv; + case ShaderNodes::BasicType::UInt1: + case ShaderNodes::BasicType::UInt2: + case ShaderNodes::BasicType::UInt3: + case ShaderNodes::BasicType::UInt4: + return SpirvOp::OpUDiv; + case ShaderNodes::BasicType::Boolean: case ShaderNodes::BasicType::Sampler2D: case ShaderNodes::BasicType::Void: @@ -1077,6 +848,10 @@ namespace Nz case ShaderNodes::BasicType::Int2: case ShaderNodes::BasicType::Int3: case ShaderNodes::BasicType::Int4: + case ShaderNodes::BasicType::UInt1: + case ShaderNodes::BasicType::UInt2: + case ShaderNodes::BasicType::UInt3: + case ShaderNodes::BasicType::UInt4: return SpirvOp::OpIEqual; case ShaderNodes::BasicType::Sampler2D: @@ -1141,6 +916,10 @@ namespace Nz case ShaderNodes::BasicType::Int2: case ShaderNodes::BasicType::Int3: case ShaderNodes::BasicType::Int4: + case ShaderNodes::BasicType::UInt1: + case ShaderNodes::BasicType::UInt2: + case ShaderNodes::BasicType::UInt3: + case ShaderNodes::BasicType::UInt4: return SpirvOp::OpIMul; case ShaderNodes::BasicType::Mat4x4: From cd23c01ace125b4a48147667f12ce6a8e54b39ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Fri, 21 Aug 2020 22:50:30 +0200 Subject: [PATCH 303/316] Shader: AccessMember can now access nested fields --- include/Nazara/Shader/GlslWriter.hpp | 1 + include/Nazara/Shader/ShaderAstValidator.hpp | 2 ++ include/Nazara/Shader/ShaderNodes.hpp | 3 +- include/Nazara/Shader/ShaderNodes.inl | 7 +++- src/Nazara/Shader/GlslWriter.cpp | 33 +++++++++++------- src/Nazara/Shader/ShaderAstCloner.cpp | 2 +- src/Nazara/Shader/ShaderAstSerializer.cpp | 5 ++- src/Nazara/Shader/ShaderAstValidator.cpp | 35 ++++++++++++++------ src/Nazara/Shader/SpirvWriter.cpp | 16 ++++++--- src/ShaderNode/DataModels/BufferField.cpp | 9 +++-- 10 files changed, 80 insertions(+), 33 deletions(-) diff --git a/include/Nazara/Shader/GlslWriter.hpp b/include/Nazara/Shader/GlslWriter.hpp index 3212d81cd..ad76fbe18 100644 --- a/include/Nazara/Shader/GlslWriter.hpp +++ b/include/Nazara/Shader/GlslWriter.hpp @@ -51,6 +51,7 @@ namespace Nz void Append(ShaderNodes::MemoryLayout layout); template void Append(const T& param); void AppendCommentSection(const std::string& section); + void AppendField(const std::string& structName, std::size_t* memberIndex, std::size_t remainingMembers); void AppendFunction(const ShaderAst::Function& func); void AppendFunctionPrototype(const ShaderAst::Function& func); void AppendLine(const std::string& txt = {}); diff --git a/include/Nazara/Shader/ShaderAstValidator.hpp b/include/Nazara/Shader/ShaderAstValidator.hpp index 0f9e99347..8195494b6 100644 --- a/include/Nazara/Shader/ShaderAstValidator.hpp +++ b/include/Nazara/Shader/ShaderAstValidator.hpp @@ -33,6 +33,8 @@ namespace Nz void TypeMustMatch(const ShaderNodes::ExpressionPtr& left, const ShaderNodes::ExpressionPtr& right); void TypeMustMatch(const ShaderExpressionType& left, const ShaderExpressionType& right); + const ShaderAst::StructMember& CheckField(const std::string& structName, std::size_t* memberIndex, std::size_t remainingMembers); + using ShaderAstRecursiveVisitor::Visit; void Visit(ShaderNodes::AccessMember& node) override; void Visit(ShaderNodes::AssignOp& node) override; diff --git a/include/Nazara/Shader/ShaderNodes.hpp b/include/Nazara/Shader/ShaderNodes.hpp index af96afeda..15898af3f 100644 --- a/include/Nazara/Shader/ShaderNodes.hpp +++ b/include/Nazara/Shader/ShaderNodes.hpp @@ -144,11 +144,12 @@ namespace Nz ShaderExpressionType GetExpressionType() const override; void Visit(ShaderAstVisitor& visitor) override; - std::size_t memberIndex; ExpressionPtr structExpr; ShaderExpressionType exprType; + std::vector memberIndices; static inline std::shared_ptr Build(ExpressionPtr structExpr, std::size_t memberIndex, ShaderExpressionType exprType); + static inline std::shared_ptr Build(ExpressionPtr structExpr, std::vector memberIndices, ShaderExpressionType exprType); }; ////////////////////////////////////////////////////////////////////////// diff --git a/include/Nazara/Shader/ShaderNodes.inl b/include/Nazara/Shader/ShaderNodes.inl index 9265fe359..77bc813f3 100644 --- a/include/Nazara/Shader/ShaderNodes.inl +++ b/include/Nazara/Shader/ShaderNodes.inl @@ -168,10 +168,15 @@ namespace Nz::ShaderNodes } inline std::shared_ptr AccessMember::Build(ExpressionPtr structExpr, std::size_t memberIndex, ShaderExpressionType exprType) + { + return Build(std::move(structExpr), std::vector{ memberIndex }, exprType); + } + + inline std::shared_ptr AccessMember::Build(ExpressionPtr structExpr, std::vector memberIndices, ShaderExpressionType exprType) { auto node = std::make_shared(); node->exprType = std::move(exprType); - node->memberIndex = memberIndex; + node->memberIndices = std::move(memberIndices); node->structExpr = std::move(structExpr); return node; diff --git a/src/Nazara/Shader/GlslWriter.cpp b/src/Nazara/Shader/GlslWriter.cpp index 1e911ce13..39f2ec3ce 100644 --- a/src/Nazara/Shader/GlslWriter.cpp +++ b/src/Nazara/Shader/GlslWriter.cpp @@ -258,6 +258,26 @@ namespace Nz AppendLine(); } + void GlslWriter::AppendField(const std::string& structName, std::size_t* memberIndex, std::size_t remainingMembers) + { + const auto& structs = m_context.shader->GetStructs(); + auto it = std::find_if(structs.begin(), structs.end(), [&](const auto& s) { return s.name == structName; }); + assert(it != structs.end()); + + const ShaderAst::Struct& s = *it; + assert(*memberIndex < s.members.size()); + + const auto& member = s.members[*memberIndex]; + Append("."); + Append(member.name); + + if (remainingMembers > 1) + { + assert(std::holds_alternative(member.type)); + AppendField(std::get(member.type), memberIndex + 1, remainingMembers - 1); + } + } + void GlslWriter::AppendFunction(const ShaderAst::Function& func) { NazaraAssert(!m_context.currentFunction, "A function is already being processed"); @@ -345,18 +365,7 @@ namespace Nz const ShaderExpressionType& exprType = node.structExpr->GetExpressionType(); assert(std::holds_alternative(exprType)); - const std::string& structName = std::get(exprType); - - const auto& structs = m_context.shader->GetStructs(); - auto it = std::find_if(structs.begin(), structs.end(), [&](const auto& s) { return s.name == structName; }); - assert(it != structs.end()); - - const ShaderAst::Struct& s = *it; - assert(node.memberIndex < s.members.size()); - - const auto& member = s.members[node.memberIndex]; - Append("."); - Append(member.name); + AppendField(std::get(exprType), node.memberIndices.data(), node.memberIndices.size()); } void GlslWriter::Visit(ShaderNodes::AssignOp& node) diff --git a/src/Nazara/Shader/ShaderAstCloner.cpp b/src/Nazara/Shader/ShaderAstCloner.cpp index 1e0f04899..39754b7a9 100644 --- a/src/Nazara/Shader/ShaderAstCloner.cpp +++ b/src/Nazara/Shader/ShaderAstCloner.cpp @@ -47,7 +47,7 @@ namespace Nz void ShaderAstCloner::Visit(ShaderNodes::AccessMember& node) { - PushExpression(ShaderNodes::AccessMember::Build(CloneExpression(node.structExpr), node.memberIndex, node.exprType)); + PushExpression(ShaderNodes::AccessMember::Build(CloneExpression(node.structExpr), node.memberIndices, node.exprType)); } void ShaderAstCloner::Visit(ShaderNodes::AssignOp& node) diff --git a/src/Nazara/Shader/ShaderAstSerializer.cpp b/src/Nazara/Shader/ShaderAstSerializer.cpp index 396cd3d98..03cd36d8b 100644 --- a/src/Nazara/Shader/ShaderAstSerializer.cpp +++ b/src/Nazara/Shader/ShaderAstSerializer.cpp @@ -132,9 +132,12 @@ namespace Nz void ShaderAstSerializerBase::Serialize(ShaderNodes::AccessMember& node) { - Value(node.memberIndex); Node(node.structExpr); Type(node.exprType); + + Container(node.memberIndices); + for (std::size_t& index : node.memberIndices) + Value(index); } void ShaderAstSerializerBase::Serialize(ShaderNodes::AssignOp& node) diff --git a/src/Nazara/Shader/ShaderAstValidator.cpp b/src/Nazara/Shader/ShaderAstValidator.cpp index 2f3177283..b614ec4a2 100644 --- a/src/Nazara/Shader/ShaderAstValidator.cpp +++ b/src/Nazara/Shader/ShaderAstValidator.cpp @@ -83,6 +83,30 @@ namespace Nz throw AstError{ "Left expression type must match right expression type" }; } + const ShaderAst::StructMember& ShaderAstValidator::CheckField(const std::string& structName, std::size_t* memberIndex, std::size_t remainingMembers) + { + const auto& structs = m_shader.GetStructs(); + auto it = std::find_if(structs.begin(), structs.end(), [&](const auto& s) { return s.name == structName; }); + if (it == structs.end()) + throw AstError{ "invalid structure" }; + + const ShaderAst::Struct& s = *it; + if (*memberIndex >= s.members.size()) + throw AstError{ "member index out of bounds" }; + + const auto& member = s.members[*memberIndex]; + + if (remainingMembers > 1) + { + if (!std::holds_alternative(member.type)) + throw AstError{ "member type does not match node type" }; + + return CheckField(std::get(member.type), memberIndex + 1, remainingMembers - 1); + } + else + return member; + } + void ShaderAstValidator::Visit(ShaderNodes::AccessMember& node) { const ShaderExpressionType& exprType = MandatoryExpr(node.structExpr)->GetExpressionType(); @@ -91,16 +115,7 @@ namespace Nz const std::string& structName = std::get(exprType); - const auto& structs = m_shader.GetStructs(); - auto it = std::find_if(structs.begin(), structs.end(), [&](const auto& s) { return s.name == structName; }); - if (it == structs.end()) - throw AstError{ "invalid structure" }; - - const ShaderAst::Struct& s = *it; - if (node.memberIndex >= s.members.size()) - throw AstError{ "member index out of bounds" }; - - const auto& member = s.members[node.memberIndex]; + const auto& member = CheckField(structName, node.memberIndices.data(), node.memberIndices.size()); if (member.type != node.exprType) throw AstError{ "member type does not match node type" }; } diff --git a/src/Nazara/Shader/SpirvWriter.cpp b/src/Nazara/Shader/SpirvWriter.cpp index 398ee8e71..92630d506 100644 --- a/src/Nazara/Shader/SpirvWriter.cpp +++ b/src/Nazara/Shader/SpirvWriter.cpp @@ -42,7 +42,8 @@ namespace Nz void Visit(ShaderNodes::AccessMember& node) override { - m_constantCache.Register(*SpirvConstantCache::BuildConstant(UInt32(node.memberIndex))); + for (std::size_t index : node.memberIndices) + m_constantCache.Register(*SpirvConstantCache::BuildConstant(Int32(index))); ShaderAstRecursiveVisitor::Visit(node); } @@ -653,9 +654,16 @@ namespace Nz UInt32 memberPointerId = AllocateResultId(); UInt32 pointerType = RegisterPointerType(node.exprType, storage); //< FIXME UInt32 typeId = GetTypeId(node.exprType); - UInt32 indexId = GetConstantId(UInt32(node.memberIndex)); - m_currentState->instructions.Append(SpirvOp::OpAccessChain, pointerType, memberPointerId, pointerId, indexId); + m_currentState->instructions.AppendVariadic(SpirvOp::OpAccessChain, [&](const auto& appender) + { + appender(pointerType); + appender(memberPointerId); + appender(pointerId); + + for (std::size_t index : node.memberIndices) + appender(GetConstantId(Int32(index))); + }); UInt32 resultId = AllocateResultId(); @@ -1047,8 +1055,6 @@ namespace Nz void SpirvWriter::Visit(ShaderNodes::Sample2D& node) { - // OpImageSampleImplicitLod %v4float %31 %35 - UInt32 typeId = GetTypeId(ShaderNodes::BasicType::Float4); UInt32 samplerId = EvaluateExpression(node.sampler); diff --git a/src/ShaderNode/DataModels/BufferField.cpp b/src/ShaderNode/DataModels/BufferField.cpp index 2d9cde16d..3f3986fb5 100644 --- a/src/ShaderNode/DataModels/BufferField.cpp +++ b/src/ShaderNode/DataModels/BufferField.cpp @@ -76,6 +76,9 @@ Nz::ShaderNodes::ExpressionPtr BufferField::GetExpression(Nz::ShaderNodes::Expre Nz::ShaderNodes::ExpressionPtr sourceExpr = Nz::ShaderBuilder::Identifier(varPtr); + std::vector memberIndices; + memberIndices.reserve(currentField.nestedFields.size() + 1); + const ShaderGraph::StructEntry* sourceStruct = &structEntry; for (std::size_t nestedIndex : currentField.nestedFields) { @@ -86,14 +89,16 @@ Nz::ShaderNodes::ExpressionPtr BufferField::GetExpression(Nz::ShaderNodes::Expre std::size_t nestedStructIndex = std::get(memberEntry.type); sourceStruct = &graph.GetStruct(nestedStructIndex); - sourceExpr = Nz::ShaderBuilder::AccessMember(std::move(sourceExpr), 0, graph.ToShaderExpressionType(memberEntry.type)); + memberIndices.push_back(nestedIndex); } + memberIndices.push_back(currentField.finalFieldIndex); + assert(currentField.finalFieldIndex < sourceStruct->members.size()); const auto& memberEntry = sourceStruct->members[currentField.finalFieldIndex]; assert(std::holds_alternative(memberEntry.type)); - return Nz::ShaderBuilder::AccessMember(std::move(sourceExpr), currentField.finalFieldIndex, graph.ToShaderExpressionType(std::get(memberEntry.type))); + return Nz::ShaderBuilder::AccessMember(std::move(sourceExpr), std::move(memberIndices), graph.ToShaderExpressionType(std::get(memberEntry.type))); } unsigned int BufferField::nPorts(QtNodes::PortType portType) const From 66a14721cb0786e345d04d35ee39175a96822966 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Fri, 21 Aug 2020 22:51:11 +0200 Subject: [PATCH 304/316] Shader/Spirv: Put types and constants in the same section --- include/Nazara/Shader/SpirvConstantCache.hpp | 7 +- src/Nazara/Shader/SpirvConstantCache.cpp | 278 ++++++++++--------- src/Nazara/Shader/SpirvWriter.cpp | 4 +- 3 files changed, 151 insertions(+), 138 deletions(-) diff --git a/include/Nazara/Shader/SpirvConstantCache.hpp b/include/Nazara/Shader/SpirvConstantCache.hpp index 95172c757..279f71b07 100644 --- a/include/Nazara/Shader/SpirvConstantCache.hpp +++ b/include/Nazara/Shader/SpirvConstantCache.hpp @@ -167,7 +167,7 @@ namespace Nz UInt32 Register(Type t); UInt32 Register(Variable v); - void Write(SpirvSection& annotations, SpirvSection& constants, SpirvSection& debugInfos, SpirvSection& types); + void Write(SpirvSection& annotations, SpirvSection& constants, SpirvSection& debugInfos); SpirvConstantCache& operator=(const SpirvConstantCache& cache) = delete; SpirvConstantCache& operator=(SpirvConstantCache&& cache) noexcept; @@ -183,7 +183,10 @@ namespace Nz struct Eq; struct Internal; - void WriteStruct(const Structure& structData, UInt32 resultId, SpirvSection& annotations, SpirvSection& debugInfos, SpirvSection& types); + void Write(const AnyConstant& constant, UInt32 resultId, SpirvSection& constants); + void Write(const AnyType& type, UInt32 resultId, SpirvSection& annotations, SpirvSection& constants, SpirvSection& debugInfos); + + void WriteStruct(const Structure& structData, UInt32 resultId, SpirvSection& annotations, SpirvSection& constants, SpirvSection& debugInfos); std::unique_ptr m_internal; }; diff --git a/src/Nazara/Shader/SpirvConstantCache.cpp b/src/Nazara/Shader/SpirvConstantCache.cpp index 02f7b4f34..db2bdb7ee 100644 --- a/src/Nazara/Shader/SpirvConstantCache.cpp +++ b/src/Nazara/Shader/SpirvConstantCache.cpp @@ -12,6 +12,12 @@ namespace Nz { + namespace + { + template struct overloaded : Ts... { using Ts::operator()...; }; + + template overloaded(Ts...)->overloaded; + } struct SpirvConstantCache::Eq { bool Compare(const ConstantBool& lhs, const ConstantBool& rhs) const @@ -381,8 +387,7 @@ namespace Nz { } - tsl::ordered_map constantIds; - tsl::ordered_map typeIds; + tsl::ordered_map, UInt32 /*id*/, AnyHasher, Eq> ids; tsl::ordered_map variableIds; tsl::ordered_map structureSizes; UInt32& nextResultId; @@ -399,8 +404,8 @@ namespace Nz UInt32 SpirvConstantCache::GetId(const Constant& c) { - auto it = m_internal->constantIds.find(c.constant); - if (it == m_internal->constantIds.end()) + auto it = m_internal->ids.find(c.constant); + if (it == m_internal->ids.end()) throw std::runtime_error("constant is not registered"); return it->second; @@ -408,8 +413,8 @@ namespace Nz UInt32 SpirvConstantCache::GetId(const Type& t) { - auto it = m_internal->typeIds.find(t.type); - if (it == m_internal->typeIds.end()) + auto it = m_internal->ids.find(t.type); + if (it == m_internal->ids.end()) throw std::runtime_error("constant is not registered"); return it->second; @@ -431,12 +436,12 @@ namespace Nz DepRegisterer registerer(*this); registerer.Register(constant); - std::size_t h = m_internal->typeIds.hash_function()(constant); - auto it = m_internal->constantIds.find(constant, h); - if (it == m_internal->constantIds.end()) + std::size_t h = m_internal->ids.hash_function()(constant); + auto it = m_internal->ids.find(constant, h); + if (it == m_internal->ids.end()) { UInt32 resultId = m_internal->nextResultId++; - it = m_internal->constantIds.emplace(std::move(constant), resultId).first; + it = m_internal->ids.emplace(std::move(constant), resultId).first; } return it.value(); @@ -449,12 +454,12 @@ namespace Nz DepRegisterer registerer(*this); registerer.Register(type); - std::size_t h = m_internal->typeIds.hash_function()(type); - auto it = m_internal->typeIds.find(type, h); - if (it == m_internal->typeIds.end()) + std::size_t h = m_internal->ids.hash_function()(type); + auto it = m_internal->ids.find(type, h); + if (it == m_internal->ids.end()) { UInt32 resultId = m_internal->nextResultId++; - it = m_internal->typeIds.emplace(std::move(type), resultId).first; + it = m_internal->ids.emplace(std::move(type), resultId).first; } return it.value(); @@ -476,131 +481,19 @@ namespace Nz return it.value(); } - void SpirvConstantCache::Write(SpirvSection& annotations, SpirvSection& constants, SpirvSection& debugInfos, SpirvSection& types) + void SpirvConstantCache::Write(SpirvSection& annotations, SpirvSection& constants, SpirvSection& debugInfos) { - for (auto&& [type, id] : m_internal->typeIds) + for (auto&& [type, id] : m_internal->ids) { UInt32 resultId = id; - std::visit([&](auto&& arg) + std::visit(overloaded { - using T = std::decay_t; - - if constexpr (std::is_same_v) - types.Append(SpirvOp::OpTypeBool, resultId); - else if constexpr (std::is_same_v) - types.Append(SpirvOp::OpTypeFloat, resultId, arg.width); - else if constexpr (std::is_same_v) - { - types.AppendVariadic(SpirvOp::OpTypeFunction, [&](const auto& appender) - { - appender(resultId); - appender(GetId(*arg.returnType)); - - for (const auto& param : arg.parameters) - appender(GetId(*param)); - }); - } - else if constexpr (std::is_same_v) - { - UInt32 depth; - if (arg.depth.has_value()) - depth = (*arg.depth) ? 1 : 0; - else - depth = 2; - - UInt32 sampled; - if (arg.sampled.has_value()) - sampled = (*arg.sampled) ? 1 : 0; - else - sampled = 2; - - types.AppendVariadic(SpirvOp::OpTypeImage, [&](const auto& appender) - { - appender(resultId); - appender(GetId(*arg.sampledType)); - appender(arg.dim); - appender(depth); - appender(arg.arrayed); - appender(arg.multisampled); - appender(sampled); - appender(arg.format); - - if (arg.qualifier) - appender(*arg.qualifier); - }); - } - else if constexpr (std::is_same_v) - types.Append(SpirvOp::OpTypeInt, resultId, arg.width, arg.signedness); - else if constexpr (std::is_same_v) - types.Append(SpirvOp::OpTypeMatrix, resultId, GetId(*arg.columnType), arg.columnCount); - else if constexpr (std::is_same_v) - types.Append(SpirvOp::OpTypePointer, resultId, arg.storageClass, GetId(*arg.type)); - else if constexpr (std::is_same_v) - types.Append(SpirvOp::OpTypeSampledImage, resultId, GetId(*arg.image)); - else if constexpr (std::is_same_v) - WriteStruct(arg, resultId, annotations, debugInfos, types); - else if constexpr (std::is_same_v) - types.Append(SpirvOp::OpTypeVector, resultId, GetId(*arg.componentType), arg.componentCount); - else if constexpr (std::is_same_v) - types.Append(SpirvOp::OpTypeVoid, resultId); - else - static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + [&](const AnyConstant& constant) { Write(constant, resultId, constants); }, + [&](const AnyType& type) { Write(type, resultId, annotations, constants, debugInfos); }, }, type); } - for (auto&& [constant, id] : m_internal->constantIds) - { - UInt32 resultId = id; - - std::visit([&](auto&& arg) - { - using T = std::decay_t; - - if constexpr (std::is_same_v) - constants.Append((arg.value) ? SpirvOp::OpConstantTrue : SpirvOp::OpConstantFalse, resultId); - else if constexpr (std::is_same_v) - { - constants.AppendVariadic(SpirvOp::OpConstantComposite, [&](const auto& appender) - { - appender(GetId(arg.type->type)); - appender(resultId); - - for (const auto& value : arg.values) - appender(GetId(value->constant)); - }); - } - else if constexpr (std::is_same_v) - { - std::visit([&](auto&& arg) - { - using T = std::decay_t; - - UInt32 typeId; - if constexpr (std::is_same_v) - typeId = GetId({ Float{ 64 } }); - else if constexpr (std::is_same_v) - typeId = GetId({ Float{ 32 } }); - else if constexpr (std::is_same_v) - typeId = GetId({ Integer{ 32, 1 } }); - else if constexpr (std::is_same_v) - typeId = GetId({ Integer{ 64, 1 } }); - else if constexpr (std::is_same_v) - typeId = GetId({ Integer{ 32, 0 } }); - else if constexpr (std::is_same_v) - typeId = GetId({ Integer{ 64, 0 } }); - else - static_assert(AlwaysFalse::value, "non-exhaustive visitor"); - - constants.Append(SpirvOp::OpConstant, typeId, resultId, SpirvSection::Raw{ &arg, sizeof(arg) }); - - }, arg.value); - } - else - static_assert(AlwaysFalse::value, "non-exhaustive visitor"); - }, constant); - } - for (auto&& [variable, id] : m_internal->variableIds) { UInt32 resultId = id; @@ -781,9 +674,128 @@ namespace Nz }, type); } - void SpirvConstantCache::WriteStruct(const Structure& structData, UInt32 resultId, SpirvSection& annotations, SpirvSection& debugInfos, SpirvSection& types) + void SpirvConstantCache::Write(const AnyConstant& constant, UInt32 resultId, SpirvSection& constants) { - types.AppendVariadic(SpirvOp::OpTypeStruct, [&](const auto& appender) + std::visit([&](auto&& arg) + { + using T = std::decay_t; + + if constexpr (std::is_same_v) + constants.Append((arg.value) ? SpirvOp::OpConstantTrue : SpirvOp::OpConstantFalse, resultId); + else if constexpr (std::is_same_v) + { + constants.AppendVariadic(SpirvOp::OpConstantComposite, [&](const auto& appender) + { + appender(GetId(arg.type->type)); + appender(resultId); + + for (const auto& value : arg.values) + appender(GetId(value->constant)); + }); + } + else if constexpr (std::is_same_v) + { + std::visit([&](auto&& arg) + { + using T = std::decay_t; + + UInt32 typeId; + if constexpr (std::is_same_v) + typeId = GetId({ Float{ 64 } }); + else if constexpr (std::is_same_v) + typeId = GetId({ Float{ 32 } }); + else if constexpr (std::is_same_v) + typeId = GetId({ Integer{ 32, 1 } }); + else if constexpr (std::is_same_v) + typeId = GetId({ Integer{ 64, 1 } }); + else if constexpr (std::is_same_v) + typeId = GetId({ Integer{ 32, 0 } }); + else if constexpr (std::is_same_v) + typeId = GetId({ Integer{ 64, 0 } }); + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + + constants.Append(SpirvOp::OpConstant, typeId, resultId, SpirvSection::Raw{ &arg, sizeof(arg) }); + + }, arg.value); + } + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + }, constant); + } + + void SpirvConstantCache::Write(const AnyType& type, UInt32 resultId, SpirvSection& annotations, SpirvSection& constants, SpirvSection& debugInfos) + { + std::visit([&](auto&& arg) + { + using T = std::decay_t; + + if constexpr (std::is_same_v) + constants.Append(SpirvOp::OpTypeBool, resultId); + else if constexpr (std::is_same_v) + constants.Append(SpirvOp::OpTypeFloat, resultId, arg.width); + else if constexpr (std::is_same_v) + { + constants.AppendVariadic(SpirvOp::OpTypeFunction, [&](const auto& appender) + { + appender(resultId); + appender(GetId(*arg.returnType)); + + for (const auto& param : arg.parameters) + appender(GetId(*param)); + }); + } + else if constexpr (std::is_same_v) + { + UInt32 depth; + if (arg.depth.has_value()) + depth = (*arg.depth) ? 1 : 0; + else + depth = 2; + + UInt32 sampled; + if (arg.sampled.has_value()) + sampled = (*arg.sampled) ? 1 : 0; + else + sampled = 2; + + constants.AppendVariadic(SpirvOp::OpTypeImage, [&](const auto& appender) + { + appender(resultId); + appender(GetId(*arg.sampledType)); + appender(arg.dim); + appender(depth); + appender(arg.arrayed); + appender(arg.multisampled); + appender(sampled); + appender(arg.format); + + if (arg.qualifier) + appender(*arg.qualifier); + }); + } + else if constexpr (std::is_same_v) + constants.Append(SpirvOp::OpTypeInt, resultId, arg.width, arg.signedness); + else if constexpr (std::is_same_v) + constants.Append(SpirvOp::OpTypeMatrix, resultId, GetId(*arg.columnType), arg.columnCount); + else if constexpr (std::is_same_v) + constants.Append(SpirvOp::OpTypePointer, resultId, arg.storageClass, GetId(*arg.type)); + else if constexpr (std::is_same_v) + constants.Append(SpirvOp::OpTypeSampledImage, resultId, GetId(*arg.image)); + else if constexpr (std::is_same_v) + WriteStruct(arg, resultId, annotations, constants, debugInfos); + else if constexpr (std::is_same_v) + constants.Append(SpirvOp::OpTypeVector, resultId, GetId(*arg.componentType), arg.componentCount); + else if constexpr (std::is_same_v) + constants.Append(SpirvOp::OpTypeVoid, resultId); + else + static_assert(AlwaysFalse::value, "non-exhaustive visitor"); + }, type); + } + + void SpirvConstantCache::WriteStruct(const Structure& structData, UInt32 resultId, SpirvSection& annotations, SpirvSection& constants, SpirvSection& debugInfos) + { + constants.AppendVariadic(SpirvOp::OpTypeStruct, [&](const auto& appender) { appender(resultId); diff --git a/src/Nazara/Shader/SpirvWriter.cpp b/src/Nazara/Shader/SpirvWriter.cpp index 92630d506..7a1f41bff 100644 --- a/src/Nazara/Shader/SpirvWriter.cpp +++ b/src/Nazara/Shader/SpirvWriter.cpp @@ -192,7 +192,6 @@ namespace Nz SpirvSection constants; SpirvSection debugInfo; SpirvSection annotations; - SpirvSection types; SpirvSection instructions; }; @@ -398,7 +397,7 @@ namespace Nz assert(entryPointIndex != std::numeric_limits::max()); - m_currentState->constantTypeCache.Write(m_currentState->annotations, m_currentState->constants, m_currentState->debugInfo, m_currentState->types); + m_currentState->constantTypeCache.Write(m_currentState->annotations, m_currentState->constants, m_currentState->debugInfo); AppendHeader(); @@ -446,7 +445,6 @@ namespace Nz MergeBlocks(ret, state.header); MergeBlocks(ret, state.debugInfo); MergeBlocks(ret, state.annotations); - MergeBlocks(ret, state.types); MergeBlocks(ret, state.constants); MergeBlocks(ret, state.instructions); From 93de44d29304283ca2e0489269a40cf0cf33d7b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sun, 23 Aug 2020 18:32:28 +0200 Subject: [PATCH 305/316] Big SpirVWriter refactor --- include/Nazara/Shader/ShaderAstVisitor.hpp | 4 +- .../Nazara/Shader/ShaderAstVisitorExcept.hpp | 36 + .../Nazara/Shader/ShaderVarVisitorExcept.hpp | 28 + include/Nazara/Shader/SpirvExpressionLoad.hpp | 64 ++ include/Nazara/Shader/SpirvExpressionLoad.inl | 16 + .../SpirvExpressionLoadAccessMember.hpp | 62 ++ .../SpirvExpressionLoadAccessMember.inl | 16 + .../Nazara/Shader/SpirvExpressionStore.hpp | 63 ++ .../Nazara/Shader/SpirvExpressionStore.inl | 16 + include/Nazara/Shader/SpirvPrinter.hpp | 42 ++ include/Nazara/Shader/SpirvPrinter.inl | 16 + .../Nazara/Shader/SpirvStatementVisitor.hpp | 43 ++ .../Nazara/Shader/SpirvStatementVisitor.inl | 16 + include/Nazara/Shader/SpirvWriter.hpp | 57 +- src/Nazara/Shader/ShaderAstVisitorExcept.cpp | 75 ++ src/Nazara/Shader/ShaderVarVisitorExcept.cpp | 40 ++ src/Nazara/Shader/SpirvExpressionLoad.cpp | 448 ++++++++++++ .../SpirvExpressionLoadAccessMember.cpp | 116 +++ src/Nazara/Shader/SpirvExpressionStore.cpp | 104 +++ src/Nazara/Shader/SpirvPrinter.cpp | 231 ++++++ src/Nazara/Shader/SpirvStatementVisitor.cpp | 49 ++ src/Nazara/Shader/SpirvWriter.cpp | 680 +++--------------- 22 files changed, 1604 insertions(+), 618 deletions(-) create mode 100644 include/Nazara/Shader/ShaderAstVisitorExcept.hpp create mode 100644 include/Nazara/Shader/ShaderVarVisitorExcept.hpp create mode 100644 include/Nazara/Shader/SpirvExpressionLoad.hpp create mode 100644 include/Nazara/Shader/SpirvExpressionLoad.inl create mode 100644 include/Nazara/Shader/SpirvExpressionLoadAccessMember.hpp create mode 100644 include/Nazara/Shader/SpirvExpressionLoadAccessMember.inl create mode 100644 include/Nazara/Shader/SpirvExpressionStore.hpp create mode 100644 include/Nazara/Shader/SpirvExpressionStore.inl create mode 100644 include/Nazara/Shader/SpirvPrinter.hpp create mode 100644 include/Nazara/Shader/SpirvPrinter.inl create mode 100644 include/Nazara/Shader/SpirvStatementVisitor.hpp create mode 100644 include/Nazara/Shader/SpirvStatementVisitor.inl create mode 100644 src/Nazara/Shader/ShaderAstVisitorExcept.cpp create mode 100644 src/Nazara/Shader/ShaderVarVisitorExcept.cpp create mode 100644 src/Nazara/Shader/SpirvExpressionLoad.cpp create mode 100644 src/Nazara/Shader/SpirvExpressionLoadAccessMember.cpp create mode 100644 src/Nazara/Shader/SpirvExpressionStore.cpp create mode 100644 src/Nazara/Shader/SpirvPrinter.cpp create mode 100644 src/Nazara/Shader/SpirvStatementVisitor.cpp diff --git a/include/Nazara/Shader/ShaderAstVisitor.hpp b/include/Nazara/Shader/ShaderAstVisitor.hpp index a6896cb2c..64dc35559 100644 --- a/include/Nazara/Shader/ShaderAstVisitor.hpp +++ b/include/Nazara/Shader/ShaderAstVisitor.hpp @@ -4,8 +4,8 @@ #pragma once -#ifndef NAZARA_SHADERVISITOR_HPP -#define NAZARA_SHADERVISITOR_HPP +#ifndef NAZARA_SHADERASTVISITOR_HPP +#define NAZARA_SHADERASTVISITOR_HPP #include #include diff --git a/include/Nazara/Shader/ShaderAstVisitorExcept.hpp b/include/Nazara/Shader/ShaderAstVisitorExcept.hpp new file mode 100644 index 000000000..40635477c --- /dev/null +++ b/include/Nazara/Shader/ShaderAstVisitorExcept.hpp @@ -0,0 +1,36 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_SHADERASTVISITOREXCEPT_HPP +#define NAZARA_SHADERASTVISITOREXCEPT_HPP + +#include +#include +#include + +namespace Nz +{ + class NAZARA_SHADER_API ShaderAstVisitorExcept : public ShaderAstVisitor + { + public: + using ShaderAstVisitor::Visit; + void Visit(ShaderNodes::AccessMember& node) override; + void Visit(ShaderNodes::AssignOp& node) override; + void Visit(ShaderNodes::BinaryOp& node) override; + void Visit(ShaderNodes::Branch& node) override; + void Visit(ShaderNodes::Cast& node) override; + void Visit(ShaderNodes::Constant& node) override; + void Visit(ShaderNodes::DeclareVariable& node) override; + void Visit(ShaderNodes::ExpressionStatement& node) override; + void Visit(ShaderNodes::Identifier& node) override; + void Visit(ShaderNodes::IntrinsicCall& node) override; + void Visit(ShaderNodes::Sample2D& node) override; + void Visit(ShaderNodes::StatementBlock& node) override; + void Visit(ShaderNodes::SwizzleOp& node) override; + }; +} + +#endif diff --git a/include/Nazara/Shader/ShaderVarVisitorExcept.hpp b/include/Nazara/Shader/ShaderVarVisitorExcept.hpp new file mode 100644 index 000000000..3fa769e21 --- /dev/null +++ b/include/Nazara/Shader/ShaderVarVisitorExcept.hpp @@ -0,0 +1,28 @@ +// Copyright (C) 2015 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_SHADERVARVISITOREXCEPT_HPP +#define NAZARA_SHADERVARVISITOREXCEPT_HPP + +#include +#include + +namespace Nz +{ + class NAZARA_SHADER_API ShaderVarVisitorExcept : public ShaderVarVisitor + { + public: + using ShaderVarVisitor::Visit; + void Visit(ShaderNodes::BuiltinVariable& var) override; + void Visit(ShaderNodes::InputVariable& var) override; + void Visit(ShaderNodes::LocalVariable& var) override; + void Visit(ShaderNodes::OutputVariable& var) override; + void Visit(ShaderNodes::ParameterVariable& var) override; + void Visit(ShaderNodes::UniformVariable& var) override; + }; +} + +#endif diff --git a/include/Nazara/Shader/SpirvExpressionLoad.hpp b/include/Nazara/Shader/SpirvExpressionLoad.hpp new file mode 100644 index 000000000..a766e568d --- /dev/null +++ b/include/Nazara/Shader/SpirvExpressionLoad.hpp @@ -0,0 +1,64 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_SPIRVEXPRESSIONLOAD_HPP +#define NAZARA_SPIRVEXPRESSIONLOAD_HPP + +#include +#include +#include +#include +#include + +namespace Nz +{ + class SpirvWriter; + + class NAZARA_SHADER_API SpirvExpressionLoad : public ShaderAstVisitorExcept, public ShaderVarVisitorExcept + { + public: + inline SpirvExpressionLoad(SpirvWriter& writer); + SpirvExpressionLoad(const SpirvExpressionLoad&) = delete; + SpirvExpressionLoad(SpirvExpressionLoad&&) = delete; + ~SpirvExpressionLoad() = default; + + UInt32 EvaluateExpression(const ShaderNodes::ExpressionPtr& expr); + + using ShaderAstVisitorExcept::Visit; + void Visit(ShaderNodes::AccessMember& node) override; + void Visit(ShaderNodes::AssignOp& node) override; + void Visit(ShaderNodes::BinaryOp& node) override; + void Visit(ShaderNodes::Cast& node) override; + void Visit(ShaderNodes::Constant& node) override; + void Visit(ShaderNodes::DeclareVariable& node) override; + void Visit(ShaderNodes::ExpressionStatement& node) override; + void Visit(ShaderNodes::Identifier& node) override; + void Visit(ShaderNodes::IntrinsicCall& node) override; + void Visit(ShaderNodes::Sample2D& node) override; + void Visit(ShaderNodes::SwizzleOp& node) override; + + using ShaderVarVisitorExcept::Visit; + void Visit(ShaderNodes::BuiltinVariable& var) override; + void Visit(ShaderNodes::InputVariable& var) override; + void Visit(ShaderNodes::LocalVariable& var) override; + void Visit(ShaderNodes::ParameterVariable& var) override; + void Visit(ShaderNodes::UniformVariable& var) override; + + SpirvExpressionLoad& operator=(const SpirvExpressionLoad&) = delete; + SpirvExpressionLoad& operator=(SpirvExpressionLoad&&) = delete; + + private: + void PushResultId(UInt32 value); + UInt32 PopResultId(); + + std::vector m_resultIds; + SpirvWriter& m_writer; + }; +} + +#include + +#endif diff --git a/include/Nazara/Shader/SpirvExpressionLoad.inl b/include/Nazara/Shader/SpirvExpressionLoad.inl new file mode 100644 index 000000000..966aae912 --- /dev/null +++ b/include/Nazara/Shader/SpirvExpressionLoad.inl @@ -0,0 +1,16 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline SpirvExpressionLoad::SpirvExpressionLoad(SpirvWriter& writer) : + m_writer(writer) + { + } +} + +#include diff --git a/include/Nazara/Shader/SpirvExpressionLoadAccessMember.hpp b/include/Nazara/Shader/SpirvExpressionLoadAccessMember.hpp new file mode 100644 index 000000000..8e2e0ff3b --- /dev/null +++ b/include/Nazara/Shader/SpirvExpressionLoadAccessMember.hpp @@ -0,0 +1,62 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_SPIRVEXPRESSIONLOADACCESSMEMBER_HPP +#define NAZARA_SPIRVEXPRESSIONLOADACCESSMEMBER_HPP + +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + class SpirvWriter; + + class NAZARA_SHADER_API SpirvExpressionLoadAccessMember : public ShaderAstVisitorExcept, public ShaderVarVisitorExcept + { + public: + inline SpirvExpressionLoadAccessMember(SpirvWriter& writer); + SpirvExpressionLoadAccessMember(const SpirvExpressionLoadAccessMember&) = delete; + SpirvExpressionLoadAccessMember(SpirvExpressionLoadAccessMember&&) = delete; + ~SpirvExpressionLoadAccessMember() = default; + + UInt32 EvaluateExpression(ShaderNodes::AccessMember& expr); + + using ShaderAstVisitor::Visit; + void Visit(ShaderNodes::AccessMember& node) override; + void Visit(ShaderNodes::Identifier& node) override; + + using ShaderVarVisitor::Visit; + void Visit(ShaderNodes::InputVariable& var) override; + void Visit(ShaderNodes::UniformVariable& var) override; + + SpirvExpressionLoadAccessMember& operator=(const SpirvExpressionLoadAccessMember&) = delete; + SpirvExpressionLoadAccessMember& operator=(SpirvExpressionLoadAccessMember&&) = delete; + + private: + struct Pointer + { + SpirvStorageClass storage; + UInt32 resultId; + UInt32 pointedTypeId; + }; + + struct Value + { + UInt32 resultId; + }; + + SpirvWriter& m_writer; + std::variant m_value; + }; +} + +#include + +#endif diff --git a/include/Nazara/Shader/SpirvExpressionLoadAccessMember.inl b/include/Nazara/Shader/SpirvExpressionLoadAccessMember.inl new file mode 100644 index 000000000..d81cfbb9c --- /dev/null +++ b/include/Nazara/Shader/SpirvExpressionLoadAccessMember.inl @@ -0,0 +1,16 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline SpirvExpressionLoadAccessMember::SpirvExpressionLoadAccessMember(SpirvWriter& writer) : + m_writer(writer) + { + } +} + +#include diff --git a/include/Nazara/Shader/SpirvExpressionStore.hpp b/include/Nazara/Shader/SpirvExpressionStore.hpp new file mode 100644 index 000000000..d7d37e39d --- /dev/null +++ b/include/Nazara/Shader/SpirvExpressionStore.hpp @@ -0,0 +1,63 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_SPIRVEXPRESSIONSTORE_HPP +#define NAZARA_SPIRVEXPRESSIONSTORE_HPP + +#include +#include +#include +#include +#include + +namespace Nz +{ + class SpirvSection; + class SpirvWriter; + + class NAZARA_SHADER_API SpirvExpressionStore : public ShaderAstVisitorExcept, public ShaderVarVisitorExcept + { + public: + inline SpirvExpressionStore(SpirvWriter& writer); + SpirvExpressionStore(const SpirvExpressionStore&) = delete; + SpirvExpressionStore(SpirvExpressionStore&&) = delete; + ~SpirvExpressionStore() = default; + + void Store(const ShaderNodes::ExpressionPtr& node, UInt32 resultId); + + using ShaderAstVisitorExcept::Visit; + void Visit(ShaderNodes::AccessMember& node) override; + void Visit(ShaderNodes::Identifier& node) override; + void Visit(ShaderNodes::SwizzleOp& node) override; + + using ShaderVarVisitorExcept::Visit; + void Visit(ShaderNodes::BuiltinVariable& var) override; + void Visit(ShaderNodes::LocalVariable& var) override; + void Visit(ShaderNodes::OutputVariable& var) override; + + SpirvExpressionStore& operator=(const SpirvExpressionStore&) = delete; + SpirvExpressionStore& operator=(SpirvExpressionStore&&) = delete; + + private: + struct LocalVar + { + std::string varName; + }; + + struct Pointer + { + SpirvStorageClass storage; + UInt32 resultId; + }; + + SpirvWriter& m_writer; + std::variant m_value; + }; +} + +#include + +#endif diff --git a/include/Nazara/Shader/SpirvExpressionStore.inl b/include/Nazara/Shader/SpirvExpressionStore.inl new file mode 100644 index 000000000..558a2aee8 --- /dev/null +++ b/include/Nazara/Shader/SpirvExpressionStore.inl @@ -0,0 +1,16 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline SpirvExpressionStore::SpirvExpressionStore(SpirvWriter& writer) : + m_writer(writer) + { + } +} + +#include diff --git a/include/Nazara/Shader/SpirvPrinter.hpp b/include/Nazara/Shader/SpirvPrinter.hpp new file mode 100644 index 000000000..b3e359fb5 --- /dev/null +++ b/include/Nazara/Shader/SpirvPrinter.hpp @@ -0,0 +1,42 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_SPIRVPRINTER_HPP +#define NAZARA_SPIRVPRINTER_HPP + +#include +#include +#include + +namespace Nz +{ + class NAZARA_SHADER_API SpirvPrinter + { + public: + inline SpirvPrinter(); + SpirvPrinter(const SpirvPrinter&) = default; + SpirvPrinter(SpirvPrinter&&) = default; + ~SpirvPrinter() = default; + + std::string Print(const UInt32* codepoints, std::size_t count); + + SpirvPrinter& operator=(const SpirvPrinter&) = default; + SpirvPrinter& operator=(SpirvPrinter&&) = default; + + private: + void AppendInstruction(); + std::string ReadString(); + UInt32 ReadWord(); + + struct State; + + State* m_currentState; + }; +} + +#include + +#endif diff --git a/include/Nazara/Shader/SpirvPrinter.inl b/include/Nazara/Shader/SpirvPrinter.inl new file mode 100644 index 000000000..f81ee5c21 --- /dev/null +++ b/include/Nazara/Shader/SpirvPrinter.inl @@ -0,0 +1,16 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline SpirvPrinter::SpirvPrinter() : + m_currentState(nullptr) + { + } +} + +#include diff --git a/include/Nazara/Shader/SpirvStatementVisitor.hpp b/include/Nazara/Shader/SpirvStatementVisitor.hpp new file mode 100644 index 000000000..1ba88942c --- /dev/null +++ b/include/Nazara/Shader/SpirvStatementVisitor.hpp @@ -0,0 +1,43 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_SPIRVSTATEMENTVISITOR_HPP +#define NAZARA_SPIRVSTATEMENTVISITOR_HPP + +#include +#include +#include + +namespace Nz +{ + class SpirvWriter; + + class NAZARA_SHADER_API SpirvStatementVisitor : public ShaderAstVisitorExcept + { + public: + inline SpirvStatementVisitor(SpirvWriter& writer); + SpirvStatementVisitor(const SpirvStatementVisitor&) = delete; + SpirvStatementVisitor(SpirvStatementVisitor&&) = delete; + ~SpirvStatementVisitor() = default; + + using ShaderAstVisitor::Visit; + void Visit(ShaderNodes::AssignOp& node) override; + void Visit(ShaderNodes::Branch& node) override; + void Visit(ShaderNodes::DeclareVariable& node) override; + void Visit(ShaderNodes::ExpressionStatement& node) override; + void Visit(ShaderNodes::StatementBlock& node) override; + + SpirvStatementVisitor& operator=(const SpirvStatementVisitor&) = delete; + SpirvStatementVisitor& operator=(SpirvStatementVisitor&&) = delete; + + private: + SpirvWriter& m_writer; + }; +} + +#include + +#endif diff --git a/include/Nazara/Shader/SpirvStatementVisitor.inl b/include/Nazara/Shader/SpirvStatementVisitor.inl new file mode 100644 index 000000000..fc2274c10 --- /dev/null +++ b/include/Nazara/Shader/SpirvStatementVisitor.inl @@ -0,0 +1,16 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline SpirvStatementVisitor::SpirvStatementVisitor(SpirvWriter& writer) : + m_writer(writer) + { + } +} + +#include diff --git a/include/Nazara/Shader/SpirvWriter.hpp b/include/Nazara/Shader/SpirvWriter.hpp index 579ad1fef..8bb38087b 100644 --- a/include/Nazara/Shader/SpirvWriter.hpp +++ b/include/Nazara/Shader/SpirvWriter.hpp @@ -23,8 +23,13 @@ namespace Nz { class SpirvSection; - class NAZARA_SHADER_API SpirvWriter : public ShaderAstVisitor, public ShaderVarVisitor + class NAZARA_SHADER_API SpirvWriter { + friend class SpirvExpressionLoad; + friend class SpirvExpressionLoadAccessMember; + friend class SpirvExpressionStore; + friend class SpirvStatementVisitor; + public: struct Environment; @@ -45,49 +50,37 @@ namespace Nz private: struct ExtVar; + struct OnlyCache {}; UInt32 AllocateResultId(); void AppendHeader(); - UInt32 EvaluateExpression(const ShaderNodes::ExpressionPtr& expr); - UInt32 GetConstantId(const ShaderConstantValue& value) const; UInt32 GetFunctionTypeId(ShaderExpressionType retType, const std::vector& parameters); + const ExtVar& GetBuiltinVariable(ShaderNodes::BuiltinEntry builtin) const; + const ExtVar& GetInputVariable(const std::string& name) const; + const ExtVar& GetOutputVariable(const std::string& name) const; + const ExtVar& GetUniformVariable(const std::string& name) const; + SpirvSection& GetInstructions(); UInt32 GetPointerTypeId(const ShaderExpressionType& type, SpirvStorageClass storageClass) const; UInt32 GetTypeId(const ShaderExpressionType& type) const; - void PushResultId(UInt32 value); - UInt32 PopResultId(); - + UInt32 ReadInputVariable(const std::string& name); + std::optional ReadInputVariable(const std::string& name, OnlyCache); + UInt32 ReadLocalVariable(const std::string& name); + std::optional ReadLocalVariable(const std::string& name, OnlyCache); + UInt32 ReadUniformVariable(const std::string& name); + std::optional ReadUniformVariable(const std::string& name, OnlyCache); UInt32 ReadVariable(ExtVar& var); + std::optional ReadVariable(const ExtVar& var, OnlyCache); + UInt32 RegisterConstant(const ShaderConstantValue& value); UInt32 RegisterFunctionType(ShaderExpressionType retType, const std::vector& parameters); UInt32 RegisterPointerType(ShaderExpressionType type, SpirvStorageClass storageClass); UInt32 RegisterType(ShaderExpressionType type); - using ShaderAstVisitor::Visit; - void Visit(ShaderNodes::AccessMember& node) override; - void Visit(ShaderNodes::AssignOp& node) override; - void Visit(ShaderNodes::Branch& node) override; - void Visit(ShaderNodes::BinaryOp& node) override; - void Visit(ShaderNodes::Cast& node) override; - void Visit(ShaderNodes::Constant& node) override; - void Visit(ShaderNodes::DeclareVariable& node) override; - void Visit(ShaderNodes::ExpressionStatement& node) override; - void Visit(ShaderNodes::Identifier& node) override; - void Visit(ShaderNodes::IntrinsicCall& node) override; - void Visit(ShaderNodes::Sample2D& node) override; - void Visit(ShaderNodes::StatementBlock& node) override; - void Visit(ShaderNodes::SwizzleOp& node) override; - - using ShaderVarVisitor::Visit; - void Visit(ShaderNodes::BuiltinVariable& var) override; - void Visit(ShaderNodes::InputVariable& var) override; - void Visit(ShaderNodes::LocalVariable& var) override; - void Visit(ShaderNodes::OutputVariable& var) override; - void Visit(ShaderNodes::ParameterVariable& var) override; - void Visit(ShaderNodes::UniformVariable& var) override; + void WriteLocalVariable(std::string name, UInt32 resultId); static void MergeBlocks(std::vector& output, const SpirvSection& from); @@ -97,6 +90,14 @@ namespace Nz const ShaderAst::Function* currentFunction = nullptr; }; + struct ExtVar + { + UInt32 pointerTypeId; + UInt32 typeId; + UInt32 varId; + std::optional valueId; + }; + struct State; Context m_context; diff --git a/src/Nazara/Shader/ShaderAstVisitorExcept.cpp b/src/Nazara/Shader/ShaderAstVisitorExcept.cpp new file mode 100644 index 000000000..e61fcdb8c --- /dev/null +++ b/src/Nazara/Shader/ShaderAstVisitorExcept.cpp @@ -0,0 +1,75 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + void ShaderAstVisitorExcept::Visit(ShaderNodes::AccessMember& node) + { + throw std::runtime_error("unhandled AccessMember node"); + } + + void ShaderAstVisitorExcept::Visit(ShaderNodes::AssignOp& node) + { + throw std::runtime_error("unhandled AssignOp node"); + } + + void ShaderAstVisitorExcept::Visit(ShaderNodes::BinaryOp& node) + { + throw std::runtime_error("unhandled AccessMember node"); + } + + void ShaderAstVisitorExcept::Visit(ShaderNodes::Branch& node) + { + throw std::runtime_error("unhandled Branch node"); + } + + void ShaderAstVisitorExcept::Visit(ShaderNodes::Cast& node) + { + throw std::runtime_error("unhandled Cast node"); + } + + void ShaderAstVisitorExcept::Visit(ShaderNodes::Constant& node) + { + throw std::runtime_error("unhandled Constant node"); + } + + void ShaderAstVisitorExcept::Visit(ShaderNodes::DeclareVariable& node) + { + throw std::runtime_error("unhandled DeclareVariable node"); + } + + void ShaderAstVisitorExcept::Visit(ShaderNodes::ExpressionStatement& node) + { + throw std::runtime_error("unhandled ExpressionStatement node"); + } + + void ShaderAstVisitorExcept::Visit(ShaderNodes::Identifier& node) + { + throw std::runtime_error("unhandled Identifier node"); + } + + void ShaderAstVisitorExcept::Visit(ShaderNodes::IntrinsicCall& node) + { + throw std::runtime_error("unhandled IntrinsicCall node"); + } + + void ShaderAstVisitorExcept::Visit(ShaderNodes::Sample2D& node) + { + throw std::runtime_error("unhandled Sample2D node"); + } + + void ShaderAstVisitorExcept::Visit(ShaderNodes::StatementBlock& node) + { + throw std::runtime_error("unhandled StatementBlock node"); + } + + void ShaderAstVisitorExcept::Visit(ShaderNodes::SwizzleOp& node) + { + throw std::runtime_error("unhandled SwizzleOp node"); + } +} diff --git a/src/Nazara/Shader/ShaderVarVisitorExcept.cpp b/src/Nazara/Shader/ShaderVarVisitorExcept.cpp new file mode 100644 index 000000000..57b5bdddc --- /dev/null +++ b/src/Nazara/Shader/ShaderVarVisitorExcept.cpp @@ -0,0 +1,40 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include + +namespace Nz +{ + void ShaderVarVisitorExcept::Visit(ShaderNodes::BuiltinVariable& var) + { + throw std::runtime_error("unhandled BuiltinVariable"); + } + + void ShaderVarVisitorExcept::Visit(ShaderNodes::InputVariable& var) + { + throw std::runtime_error("unhandled InputVariable"); + } + + void ShaderVarVisitorExcept::Visit(ShaderNodes::LocalVariable& var) + { + throw std::runtime_error("unhandled LocalVariable"); + } + + void ShaderVarVisitorExcept::Visit(ShaderNodes::OutputVariable& var) + { + throw std::runtime_error("unhandled OutputVariable"); + } + + void ShaderVarVisitorExcept::Visit(ShaderNodes::ParameterVariable& var) + { + throw std::runtime_error("unhandled ParameterVariable"); + } + + void ShaderVarVisitorExcept::Visit(ShaderNodes::UniformVariable& var) + { + throw std::runtime_error("unhandled UniformVariable"); + } +} diff --git a/src/Nazara/Shader/SpirvExpressionLoad.cpp b/src/Nazara/Shader/SpirvExpressionLoad.cpp new file mode 100644 index 000000000..b032326fb --- /dev/null +++ b/src/Nazara/Shader/SpirvExpressionLoad.cpp @@ -0,0 +1,448 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + void SpirvExpressionLoad::Visit(ShaderNodes::AccessMember& node) + { + SpirvExpressionLoadAccessMember accessMemberVisitor(m_writer); + PushResultId(accessMemberVisitor.EvaluateExpression(node)); + } + + void SpirvExpressionLoad::Visit(ShaderNodes::AssignOp& node) + { + SpirvExpressionLoad loadVisitor(m_writer); + SpirvExpressionStore storeVisitor(m_writer); + storeVisitor.Store(node.left, EvaluateExpression(node.right)); + } + + void SpirvExpressionLoad::Visit(ShaderNodes::BinaryOp& node) + { + ShaderExpressionType resultExprType = node.GetExpressionType(); + assert(std::holds_alternative(resultExprType)); + + const ShaderExpressionType& leftExprType = node.left->GetExpressionType(); + assert(std::holds_alternative(leftExprType)); + + const ShaderExpressionType& rightExprType = node.right->GetExpressionType(); + assert(std::holds_alternative(rightExprType)); + + ShaderNodes::BasicType resultType = std::get(resultExprType); + ShaderNodes::BasicType leftType = std::get(leftExprType); + ShaderNodes::BasicType rightType = std::get(rightExprType); + + + UInt32 leftOperand = EvaluateExpression(node.left); + UInt32 rightOperand = EvaluateExpression(node.right); + UInt32 resultId = m_writer.AllocateResultId(); + + bool swapOperands = false; + + SpirvOp op = [&] + { + switch (node.op) + { + case ShaderNodes::BinaryType::Add: + { + switch (leftType) + { + case ShaderNodes::BasicType::Float1: + case ShaderNodes::BasicType::Float2: + case ShaderNodes::BasicType::Float3: + case ShaderNodes::BasicType::Float4: + case ShaderNodes::BasicType::Mat4x4: + return SpirvOp::OpFAdd; + + case ShaderNodes::BasicType::Int1: + case ShaderNodes::BasicType::Int2: + case ShaderNodes::BasicType::Int3: + case ShaderNodes::BasicType::Int4: + case ShaderNodes::BasicType::UInt1: + case ShaderNodes::BasicType::UInt2: + case ShaderNodes::BasicType::UInt3: + case ShaderNodes::BasicType::UInt4: + return SpirvOp::OpIAdd; + + case ShaderNodes::BasicType::Boolean: + case ShaderNodes::BasicType::Sampler2D: + case ShaderNodes::BasicType::Void: + break; + } + } + + case ShaderNodes::BinaryType::Substract: + { + switch (leftType) + { + case ShaderNodes::BasicType::Float1: + case ShaderNodes::BasicType::Float2: + case ShaderNodes::BasicType::Float3: + case ShaderNodes::BasicType::Float4: + case ShaderNodes::BasicType::Mat4x4: + return SpirvOp::OpFSub; + + case ShaderNodes::BasicType::Int1: + case ShaderNodes::BasicType::Int2: + case ShaderNodes::BasicType::Int3: + case ShaderNodes::BasicType::Int4: + case ShaderNodes::BasicType::UInt1: + case ShaderNodes::BasicType::UInt2: + case ShaderNodes::BasicType::UInt3: + case ShaderNodes::BasicType::UInt4: + return SpirvOp::OpISub; + + case ShaderNodes::BasicType::Boolean: + case ShaderNodes::BasicType::Sampler2D: + case ShaderNodes::BasicType::Void: + break; + } + } + + case ShaderNodes::BinaryType::Divide: + { + switch (leftType) + { + case ShaderNodes::BasicType::Float1: + case ShaderNodes::BasicType::Float2: + case ShaderNodes::BasicType::Float3: + case ShaderNodes::BasicType::Float4: + case ShaderNodes::BasicType::Mat4x4: + return SpirvOp::OpFDiv; + + case ShaderNodes::BasicType::Int1: + case ShaderNodes::BasicType::Int2: + case ShaderNodes::BasicType::Int3: + case ShaderNodes::BasicType::Int4: + return SpirvOp::OpSDiv; + + case ShaderNodes::BasicType::UInt1: + case ShaderNodes::BasicType::UInt2: + case ShaderNodes::BasicType::UInt3: + case ShaderNodes::BasicType::UInt4: + return SpirvOp::OpUDiv; + + case ShaderNodes::BasicType::Boolean: + case ShaderNodes::BasicType::Sampler2D: + case ShaderNodes::BasicType::Void: + break; + } + } + + case ShaderNodes::BinaryType::Equality: + { + switch (leftType) + { + case ShaderNodes::BasicType::Boolean: + return SpirvOp::OpLogicalEqual; + + case ShaderNodes::BasicType::Float1: + case ShaderNodes::BasicType::Float2: + case ShaderNodes::BasicType::Float3: + case ShaderNodes::BasicType::Float4: + case ShaderNodes::BasicType::Mat4x4: + return SpirvOp::OpFOrdEqual; + + case ShaderNodes::BasicType::Int1: + case ShaderNodes::BasicType::Int2: + case ShaderNodes::BasicType::Int3: + case ShaderNodes::BasicType::Int4: + case ShaderNodes::BasicType::UInt1: + case ShaderNodes::BasicType::UInt2: + case ShaderNodes::BasicType::UInt3: + case ShaderNodes::BasicType::UInt4: + return SpirvOp::OpIEqual; + + case ShaderNodes::BasicType::Sampler2D: + case ShaderNodes::BasicType::Void: + break; + } + } + + case ShaderNodes::BinaryType::Multiply: + { + switch (leftType) + { + case ShaderNodes::BasicType::Float1: + { + switch (rightType) + { + case ShaderNodes::BasicType::Float1: + return SpirvOp::OpFMul; + + case ShaderNodes::BasicType::Float2: + case ShaderNodes::BasicType::Float3: + case ShaderNodes::BasicType::Float4: + swapOperands = true; + return SpirvOp::OpVectorTimesScalar; + + case ShaderNodes::BasicType::Mat4x4: + swapOperands = true; + return SpirvOp::OpMatrixTimesScalar; + + default: + break; + } + + break; + } + + case ShaderNodes::BasicType::Float2: + case ShaderNodes::BasicType::Float3: + case ShaderNodes::BasicType::Float4: + { + switch (rightType) + { + case ShaderNodes::BasicType::Float1: + return SpirvOp::OpVectorTimesScalar; + + case ShaderNodes::BasicType::Float2: + case ShaderNodes::BasicType::Float3: + case ShaderNodes::BasicType::Float4: + return SpirvOp::OpFMul; + + case ShaderNodes::BasicType::Mat4x4: + return SpirvOp::OpVectorTimesMatrix; + + default: + break; + } + + break; + } + + case ShaderNodes::BasicType::Int1: + case ShaderNodes::BasicType::Int2: + case ShaderNodes::BasicType::Int3: + case ShaderNodes::BasicType::Int4: + case ShaderNodes::BasicType::UInt1: + case ShaderNodes::BasicType::UInt2: + case ShaderNodes::BasicType::UInt3: + case ShaderNodes::BasicType::UInt4: + return SpirvOp::OpIMul; + + case ShaderNodes::BasicType::Mat4x4: + { + switch (rightType) + { + case ShaderNodes::BasicType::Float1: return SpirvOp::OpMatrixTimesScalar; + case ShaderNodes::BasicType::Float4: return SpirvOp::OpMatrixTimesVector; + case ShaderNodes::BasicType::Mat4x4: return SpirvOp::OpMatrixTimesMatrix; + + default: + break; + } + + break; + } + + default: + break; + } + break; + } + } + + assert(false); + throw std::runtime_error("unexpected binary operation"); + }(); + + if (swapOperands) + std::swap(leftOperand, rightOperand); + + m_writer.GetInstructions().Append(op, m_writer.GetTypeId(resultType), resultId, leftOperand, rightOperand); + PushResultId(resultId); + } + + void SpirvExpressionLoad::Visit(ShaderNodes::Cast& node) + { + const ShaderExpressionType& targetExprType = node.exprType; + assert(std::holds_alternative(targetExprType)); + + ShaderNodes::BasicType targetType = std::get(targetExprType); + + StackVector exprResults = NazaraStackVector(UInt32, node.expressions.size()); + + for (const auto& exprPtr : node.expressions) + { + if (!exprPtr) + break; + + exprResults.push_back(EvaluateExpression(exprPtr)); + } + + UInt32 resultId = m_writer.AllocateResultId(); + + m_writer.GetInstructions().AppendVariadic(SpirvOp::OpCompositeConstruct, [&](const auto& appender) + { + appender(m_writer.GetTypeId(targetType)); + appender(resultId); + + for (UInt32 exprResultId : exprResults) + appender(exprResultId); + }); + + PushResultId(resultId); + } + + void SpirvExpressionLoad::Visit(ShaderNodes::Constant& node) + { + std::visit([&] (const auto& value) + { + PushResultId(m_writer.GetConstantId(value)); + }, node.value); + } + + void SpirvExpressionLoad::Visit(ShaderNodes::DeclareVariable& node) + { + if (node.expression) + { + assert(node.variable->GetType() == ShaderNodes::VariableType::LocalVariable); + + const auto& localVar = static_cast(*node.variable); + m_writer.WriteLocalVariable(localVar.name, EvaluateExpression(node.expression)); + } + } + + void SpirvExpressionLoad::Visit(ShaderNodes::ExpressionStatement& node) + { + Visit(node.expression); + PopResultId(); + } + + void SpirvExpressionLoad::Visit(ShaderNodes::Identifier& node) + { + Visit(node.var); + } + + void SpirvExpressionLoad::Visit(ShaderNodes::IntrinsicCall& node) + { + switch (node.intrinsic) + { + case ShaderNodes::IntrinsicType::DotProduct: + { + const ShaderExpressionType& vecExprType = node.parameters[0]->GetExpressionType(); + assert(std::holds_alternative(vecExprType)); + + ShaderNodes::BasicType vecType = std::get(vecExprType); + + UInt32 typeId = m_writer.GetTypeId(node.GetComponentType(vecType)); + + UInt32 vec1 = EvaluateExpression(node.parameters[0]); + UInt32 vec2 = EvaluateExpression(node.parameters[1]); + + UInt32 resultId = m_writer.AllocateResultId(); + + m_writer.GetInstructions().Append(SpirvOp::OpDot, typeId, resultId, vec1, vec2); + PushResultId(resultId); + break; + } + + case ShaderNodes::IntrinsicType::CrossProduct: + default: + throw std::runtime_error("not yet implemented"); + } + } + + void SpirvExpressionLoad::Visit(ShaderNodes::Sample2D& node) + { + UInt32 typeId = m_writer.GetTypeId(ShaderNodes::BasicType::Float4); + + UInt32 samplerId = EvaluateExpression(node.sampler); + UInt32 coordinatesId = EvaluateExpression(node.coordinates); + UInt32 resultId = m_writer.AllocateResultId(); + + m_writer.GetInstructions().Append(SpirvOp::OpImageSampleImplicitLod, typeId, resultId, samplerId, coordinatesId); + PushResultId(resultId); + } + + void SpirvExpressionLoad::Visit(ShaderNodes::SwizzleOp& node) + { + const ShaderExpressionType& targetExprType = node.GetExpressionType(); + assert(std::holds_alternative(targetExprType)); + + ShaderNodes::BasicType targetType = std::get(targetExprType); + + UInt32 exprResultId = EvaluateExpression(node.expression); + UInt32 resultId = m_writer.AllocateResultId(); + + if (node.componentCount > 1) + { + // Swizzling is implemented via SpirvOp::OpVectorShuffle using the same vector twice as operands + m_writer.GetInstructions().AppendVariadic(SpirvOp::OpVectorShuffle, [&](const auto& appender) + { + appender(m_writer.GetTypeId(targetType)); + appender(resultId); + appender(exprResultId); + appender(exprResultId); + + for (std::size_t i = 0; i < node.componentCount; ++i) + appender(UInt32(node.components[0]) - UInt32(node.components[i])); + }); + } + else + { + // Extract a single component from the vector + assert(node.componentCount == 1); + + m_writer.GetInstructions().Append(SpirvOp::OpCompositeExtract, m_writer.GetTypeId(targetType), resultId, exprResultId, UInt32(node.components[0]) - UInt32(ShaderNodes::SwizzleComponent::First) ); + } + + PushResultId(resultId); + } + + void SpirvExpressionLoad::Visit(ShaderNodes::BuiltinVariable& /*var*/) + { + throw std::runtime_error("not implemented yet"); + } + + void SpirvExpressionLoad::Visit(ShaderNodes::InputVariable& var) + { + PushResultId(m_writer.ReadInputVariable(var.name)); + } + + void SpirvExpressionLoad::Visit(ShaderNodes::LocalVariable& var) + { + PushResultId(m_writer.ReadLocalVariable(var.name)); + } + + void SpirvExpressionLoad::Visit(ShaderNodes::ParameterVariable& /*var*/) + { + throw std::runtime_error("not implemented yet"); + } + + void SpirvExpressionLoad::Visit(ShaderNodes::UniformVariable& var) + { + PushResultId(m_writer.ReadUniformVariable(var.name)); + } + + UInt32 SpirvExpressionLoad::EvaluateExpression(const ShaderNodes::ExpressionPtr& expr) + { + Visit(expr); + return PopResultId(); + } + + void SpirvExpressionLoad::PushResultId(UInt32 value) + { + m_resultIds.push_back(value); + } + + UInt32 SpirvExpressionLoad::PopResultId() + { + if (m_resultIds.empty()) + throw std::runtime_error("invalid operation"); + + UInt32 resultId = m_resultIds.back(); + m_resultIds.pop_back(); + + return resultId; + } +} diff --git a/src/Nazara/Shader/SpirvExpressionLoadAccessMember.cpp b/src/Nazara/Shader/SpirvExpressionLoadAccessMember.cpp new file mode 100644 index 000000000..c59bd806d --- /dev/null +++ b/src/Nazara/Shader/SpirvExpressionLoadAccessMember.cpp @@ -0,0 +1,116 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include + +namespace Nz +{ + namespace + { + template struct overloaded : Ts... { using Ts::operator()...; }; + template overloaded(Ts...)->overloaded; + } + + UInt32 SpirvExpressionLoadAccessMember::EvaluateExpression(ShaderNodes::AccessMember& expr) + { + Visit(expr); + + return std::visit(overloaded + { + [&](const Pointer& pointer) -> UInt32 + { + UInt32 resultId = m_writer.AllocateResultId(); + + m_writer.GetInstructions().Append(SpirvOp::OpLoad, pointer.pointedTypeId, resultId, pointer.resultId); + + return resultId; + }, + [&](const Value& value) -> UInt32 + { + return value.resultId; + }, + [this](std::monostate) -> UInt32 + { + throw std::runtime_error("an internal error occurred"); + } + }, m_value); + } + + void SpirvExpressionLoadAccessMember::Visit(ShaderNodes::AccessMember& node) + { + Visit(node.structExpr); + + std::visit(overloaded + { + [&](const Pointer& pointer) + { + UInt32 resultId = m_writer.AllocateResultId(); + UInt32 pointerType = m_writer.RegisterPointerType(node.exprType, pointer.storage); //< FIXME + UInt32 typeId = m_writer.GetTypeId(node.exprType); + + m_writer.GetInstructions().AppendVariadic(SpirvOp::OpAccessChain, [&](const auto& appender) + { + appender(pointerType); + appender(resultId); + appender(pointer.resultId); + + for (std::size_t index : node.memberIndices) + appender(m_writer.GetConstantId(Int32(index))); + }); + + m_value = Pointer { pointer.storage, resultId, typeId }; + }, + [&](const Value& value) + { + UInt32 resultId = m_writer.AllocateResultId(); + UInt32 typeId = m_writer.GetTypeId(node.exprType); + + m_writer.GetInstructions().AppendVariadic(SpirvOp::OpCompositeExtract, [&](const auto& appender) + { + appender(typeId); + appender(resultId); + appender(value.resultId); + + for (std::size_t index : node.memberIndices) + appender(m_writer.GetConstantId(Int32(index))); + }); + + m_value = Value { resultId }; + }, + [this](std::monostate) + { + throw std::runtime_error("an internal error occurred"); + } + }, m_value); + } + + void SpirvExpressionLoadAccessMember::Visit(ShaderNodes::Identifier& node) + { + Visit(node.var); + } + + void SpirvExpressionLoadAccessMember::Visit(ShaderNodes::InputVariable& var) + { + auto inputVar = m_writer.GetInputVariable(var.name); + + if (auto resultIdOpt = m_writer.ReadVariable(inputVar, SpirvWriter::OnlyCache{})) + m_value = Value{ *resultIdOpt }; + else + m_value = Pointer{ SpirvStorageClass::Input, inputVar.varId, inputVar.typeId }; + } + + void SpirvExpressionLoadAccessMember::Visit(ShaderNodes::UniformVariable& var) + { + auto uniformVar = m_writer.GetUniformVariable(var.name); + + if (auto resultIdOpt = m_writer.ReadVariable(uniformVar, SpirvWriter::OnlyCache{})) + m_value = Value{ *resultIdOpt }; + else + m_value = Pointer{ SpirvStorageClass::Uniform, uniformVar.varId, uniformVar.typeId }; + } +} diff --git a/src/Nazara/Shader/SpirvExpressionStore.cpp b/src/Nazara/Shader/SpirvExpressionStore.cpp new file mode 100644 index 000000000..109ad53c3 --- /dev/null +++ b/src/Nazara/Shader/SpirvExpressionStore.cpp @@ -0,0 +1,104 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include + +namespace Nz +{ + namespace + { + template struct overloaded : Ts... { using Ts::operator()...; }; + template overloaded(Ts...)->overloaded; + } + + void SpirvExpressionStore::Store(const ShaderNodes::ExpressionPtr& node, UInt32 resultId) + { + Visit(node); + + std::visit(overloaded + { + [&](const Pointer& pointer) + { + m_writer.GetInstructions().Append(SpirvOp::OpStore, pointer.resultId, resultId); + }, + [&](const LocalVar& value) + { + m_writer.WriteLocalVariable(value.varName, resultId); + }, + [this](std::monostate) + { + throw std::runtime_error("an internal error occurred"); + } + }, m_value); + } + + void SpirvExpressionStore::Visit(ShaderNodes::AccessMember& node) + { + Visit(node.structExpr); + + std::visit(overloaded + { + [&](const Pointer& pointer) -> UInt32 + { + UInt32 resultId = m_writer.AllocateResultId(); + UInt32 pointerType = m_writer.RegisterPointerType(node.exprType, pointer.storage); //< FIXME + UInt32 typeId = m_writer.GetTypeId(node.exprType); + + m_writer.GetInstructions().AppendVariadic(SpirvOp::OpAccessChain, [&](const auto& appender) + { + appender(pointerType); + appender(resultId); + appender(pointer.resultId); + + for (std::size_t index : node.memberIndices) + appender(m_writer.GetConstantId(Int32(index))); + }); + + m_value = Pointer{ pointer.storage, resultId }; + + return resultId; + }, + [&](const LocalVar& value) -> UInt32 + { + throw std::runtime_error("not yet implemented"); + }, + [this](std::monostate) -> UInt32 + { + throw std::runtime_error("an internal error occurred"); + } + }, m_value); + } + + void SpirvExpressionStore::Visit(ShaderNodes::Identifier& node) + { + Visit(node.var); + } + + void SpirvExpressionStore::Visit(ShaderNodes::SwizzleOp& node) + { + throw std::runtime_error("not yet implemented"); + } + + void SpirvExpressionStore::Visit(ShaderNodes::BuiltinVariable& var) + { + const auto& outputVar = m_writer.GetBuiltinVariable(var.entry); + + m_value = Pointer{ SpirvStorageClass::Output, outputVar.varId }; + } + + void SpirvExpressionStore::Visit(ShaderNodes::LocalVariable& var) + { + m_value = LocalVar{ var.name }; + } + + void SpirvExpressionStore::Visit(ShaderNodes::OutputVariable& var) + { + const auto& outputVar = m_writer.GetOutputVariable(var.name); + + m_value = Pointer{ SpirvStorageClass::Output, outputVar.varId }; + } +} diff --git a/src/Nazara/Shader/SpirvPrinter.cpp b/src/Nazara/Shader/SpirvPrinter.cpp new file mode 100644 index 000000000..4b21ed840 --- /dev/null +++ b/src/Nazara/Shader/SpirvPrinter.cpp @@ -0,0 +1,231 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + struct SpirvPrinter::State + { + const UInt32* codepoints; + std::size_t index = 0; + std::size_t count; + std::ostringstream stream; + }; + + std::string SpirvPrinter::Print(const UInt32* codepoints, std::size_t count) + { + State state; + state.codepoints = codepoints; + state.count = count; + + m_currentState = &state; + CallOnExit resetOnExit([&] { m_currentState = nullptr; }); + + UInt32 magicNumber = ReadWord(); + if (magicNumber != SpvMagicNumber) + throw std::runtime_error("invalid Spir-V: magic number didn't match"); + + m_currentState->stream << "Spir-V module\n"; + + UInt32 versionNumber = ReadWord(); + if (versionNumber > SpvVersion) + throw std::runtime_error("Spir-V is more recent than printer, dismissing"); + + UInt8 majorVersion = ((versionNumber) >> 16) & 0xFF; + UInt8 minorVersion = ((versionNumber) >> 8) & 0xFF; + + m_currentState->stream << "Version " + std::to_string(+majorVersion) << "." << std::to_string(+minorVersion) << "\n"; + + UInt32 generatorId = ReadWord(); + + m_currentState->stream << "Generator: " << std::to_string(generatorId) << "\n"; + + UInt32 bound = ReadWord(); + m_currentState->stream << "Bound: " << std::to_string(bound) << "\n"; + + UInt32 schema = ReadWord(); + m_currentState->stream << "Schema: " << std::to_string(schema) << "\n"; + + while (m_currentState->index < m_currentState->count) + AppendInstruction(); + + return m_currentState->stream.str(); + } + + void SpirvPrinter::AppendInstruction() + { + std::size_t startIndex = m_currentState->index; + + UInt32 firstWord = ReadWord(); + + UInt16 wordCount = static_cast((firstWord >> 16) & 0xFFFF); + UInt16 opcode = static_cast(firstWord & 0xFFFF); + + const SpirvInstruction* inst = GetInstructionData(opcode); + if (!inst) + throw std::runtime_error("invalid instruction"); + + m_currentState->stream << inst->name; + + std::size_t currentOperand = 0; + std::size_t instructionEnd = startIndex + wordCount; + while (m_currentState->index < instructionEnd) + { + const SpirvInstruction::Operand* operand = &inst->operands[currentOperand]; + + m_currentState->stream << " " << operand->name << "("; + + switch (operand->kind) + { + case SpirvOperandKind::ImageOperands: + case SpirvOperandKind::FPFastMathMode: + case SpirvOperandKind::SelectionControl: + case SpirvOperandKind::LoopControl: + case SpirvOperandKind::FunctionControl: + case SpirvOperandKind::MemorySemantics: + case SpirvOperandKind::MemoryAccess: + case SpirvOperandKind::KernelProfilingInfo: + case SpirvOperandKind::RayFlags: + case SpirvOperandKind::SourceLanguage: + case SpirvOperandKind::ExecutionModel: + case SpirvOperandKind::AddressingModel: + case SpirvOperandKind::MemoryModel: + case SpirvOperandKind::ExecutionMode: + case SpirvOperandKind::StorageClass: + case SpirvOperandKind::Dim: + case SpirvOperandKind::SamplerAddressingMode: + case SpirvOperandKind::SamplerFilterMode: + case SpirvOperandKind::ImageFormat: + case SpirvOperandKind::ImageChannelOrder: + case SpirvOperandKind::ImageChannelDataType: + case SpirvOperandKind::FPRoundingMode: + case SpirvOperandKind::LinkageType: + case SpirvOperandKind::AccessQualifier: + case SpirvOperandKind::FunctionParameterAttribute: + case SpirvOperandKind::Decoration: + case SpirvOperandKind::BuiltIn: + case SpirvOperandKind::Scope: + case SpirvOperandKind::GroupOperation: + case SpirvOperandKind::KernelEnqueueFlags: + case SpirvOperandKind::Capability: + case SpirvOperandKind::RayQueryIntersection: + case SpirvOperandKind::RayQueryCommittedIntersectionType: + case SpirvOperandKind::RayQueryCandidateIntersectionType: + case SpirvOperandKind::IdResultType: + case SpirvOperandKind::IdResult: + case SpirvOperandKind::IdMemorySemantics: + case SpirvOperandKind::IdScope: + case SpirvOperandKind::IdRef: + case SpirvOperandKind::LiteralInteger: + case SpirvOperandKind::LiteralExtInstInteger: + case SpirvOperandKind::LiteralSpecConstantOpInteger: + case SpirvOperandKind::LiteralContextDependentNumber: //< FIXME + { + UInt32 value = ReadWord(); + m_currentState->stream << value; + break; + } + + case SpirvOperandKind::LiteralString: + { + std::string str = ReadString(); + m_currentState->stream << "\"" << str << "\""; + + /* + std::size_t offset = GetOutputOffset(); + + std::size_t size4 = CountWord(str); + for (std::size_t i = 0; i < size4; ++i) + { + UInt32 codepoint = 0; + for (std::size_t j = 0; j < 4; ++j) + { + std::size_t pos = i * 4 + j; + if (pos < str.size()) + codepoint |= UInt32(str[pos]) << (j * 8); + } + + Append(codepoint); + } + */ + break; + } + + + case SpirvOperandKind::PairLiteralIntegerIdRef: + { + ReadWord(); + ReadWord(); + break; + } + + case SpirvOperandKind::PairIdRefLiteralInteger: + { + ReadWord(); + ReadWord(); + break; + } + + case SpirvOperandKind::PairIdRefIdRef: + { + ReadWord(); + ReadWord(); + break; + } + + /*case SpirvOperandKind::LiteralContextDependentNumber: + { + throw std::runtime_error("not yet implemented"); + }*/ + + default: + break; + + } + + m_currentState->stream << ")"; + + if (currentOperand < inst->minOperandCount - 1) + currentOperand++; + } + + m_currentState->stream << "\n"; + + assert(m_currentState->index == startIndex + wordCount); + } + + std::string SpirvPrinter::ReadString() + { + std::string str; + + for (;;) + { + UInt32 value = ReadWord(); + for (std::size_t j = 0; j < 4; ++j) + { + char c = static_cast((value >> (j * 8)) & 0xFF); + if (c == '\0') + return str; + + str.push_back(c); + } + } + } + + UInt32 SpirvPrinter::ReadWord() + { + if (m_currentState->index >= m_currentState->count) + throw std::runtime_error("unexpected end of stream"); + + return m_currentState->codepoints[m_currentState->index++]; + } +} diff --git a/src/Nazara/Shader/SpirvStatementVisitor.cpp b/src/Nazara/Shader/SpirvStatementVisitor.cpp new file mode 100644 index 000000000..312879375 --- /dev/null +++ b/src/Nazara/Shader/SpirvStatementVisitor.cpp @@ -0,0 +1,49 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include + +namespace Nz +{ + void SpirvStatementVisitor::Visit(ShaderNodes::AssignOp& node) + { + SpirvExpressionLoad loadVisitor(m_writer); + SpirvExpressionStore storeVisitor(m_writer); + storeVisitor.Store(node.left, loadVisitor.EvaluateExpression(node.right)); + } + + void SpirvStatementVisitor::Visit(ShaderNodes::Branch& node) + { + throw std::runtime_error("not yet implemented"); + } + + void SpirvStatementVisitor::Visit(ShaderNodes::DeclareVariable& node) + { + if (node.expression) + { + assert(node.variable->GetType() == ShaderNodes::VariableType::LocalVariable); + + const auto& localVar = static_cast(*node.variable); + + SpirvExpressionLoad loadVisitor(m_writer); + m_writer.WriteLocalVariable(localVar.name, loadVisitor.EvaluateExpression(node.expression)); + } + } + + void SpirvStatementVisitor::Visit(ShaderNodes::ExpressionStatement& node) + { + SpirvExpressionLoad loadVisitor(m_writer); + loadVisitor.Visit(node.expression); + } + + void SpirvStatementVisitor::Visit(ShaderNodes::StatementBlock& node) + { + for (auto& statement : node.statements) + Visit(statement); + } +} diff --git a/src/Nazara/Shader/SpirvWriter.cpp b/src/Nazara/Shader/SpirvWriter.cpp index 7a1f41bff..8412a1491 100644 --- a/src/Nazara/Shader/SpirvWriter.cpp +++ b/src/Nazara/Shader/SpirvWriter.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -154,14 +155,6 @@ namespace Nz } } - struct SpirvWriter::ExtVar - { - UInt32 pointerTypeId; - UInt32 typeId; - UInt32 varId; - std::optional valueId; - }; - struct SpirvWriter::State { State() : @@ -387,7 +380,8 @@ namespace Nz state.instructions.Append(SpirvOp::OpFunctionParameter, GetTypeId(param.type), paramResultId); } - Visit(functionStatements[funcIndex]); + SpirvStatementVisitor visitor(*this); + visitor.Visit(functionStatements[funcIndex]); if (func.returnType == ShaderNodes::BasicType::Void) state.instructions.Append(SpirvOp::OpReturn); @@ -480,12 +474,6 @@ namespace Nz m_currentState->header.Append(SpirvOp::OpMemoryModel, SpvAddressingModelLogical, SpvMemoryModelGLSL450); } - UInt32 SpirvWriter::EvaluateExpression(const ShaderNodes::ExpressionPtr& expr) - { - Visit(expr); - return PopResultId(); - } - UInt32 SpirvWriter::GetConstantId(const ShaderConstantValue& value) const { return m_currentState->constantTypeCache.GetId(*SpirvConstantCache::BuildConstant(value)); @@ -507,6 +495,43 @@ namespace Nz }); } + auto SpirvWriter::GetBuiltinVariable(ShaderNodes::BuiltinEntry builtin) const -> const ExtVar& + { + auto it = m_currentState->builtinIds.find(builtin); + assert(it != m_currentState->builtinIds.end()); + + return it->second; + } + + auto SpirvWriter::GetInputVariable(const std::string& name) const -> const ExtVar& + { + auto it = m_currentState->inputIds.find(name); + assert(it != m_currentState->inputIds.end()); + + return it->second; + } + + auto SpirvWriter::GetOutputVariable(const std::string& name) const -> const ExtVar& + { + auto it = m_currentState->outputIds.find(name); + assert(it != m_currentState->outputIds.end()); + + return it->second; + } + + auto SpirvWriter::GetUniformVariable(const std::string& name) const -> const ExtVar& + { + auto it = m_currentState->uniformIds.find(name); + assert(it != m_currentState->uniformIds.end()); + + return it.value(); + } + + SpirvSection& SpirvWriter::GetInstructions() + { + return m_currentState->instructions; + } + UInt32 SpirvWriter::GetPointerTypeId(const ShaderExpressionType& type, SpirvStorageClass storageClass) const { return m_currentState->constantTypeCache.GetId(*SpirvConstantCache::BuildPointerType(*m_context.shader, type, storageClass)); @@ -517,20 +542,53 @@ namespace Nz return m_currentState->constantTypeCache.GetId(*SpirvConstantCache::BuildType(*m_context.shader, type)); } - void SpirvWriter::PushResultId(UInt32 value) + UInt32 SpirvWriter::ReadInputVariable(const std::string& name) { - m_currentState->resultIds.push_back(value); + auto it = m_currentState->inputIds.find(name); + assert(it != m_currentState->inputIds.end()); + + return ReadVariable(it.value()); } - UInt32 SpirvWriter::PopResultId() + std::optional SpirvWriter::ReadInputVariable(const std::string& name, OnlyCache) { - if (m_currentState->resultIds.empty()) - throw std::runtime_error("invalid operation"); + auto it = m_currentState->inputIds.find(name); + assert(it != m_currentState->inputIds.end()); - UInt32 resultId = m_currentState->resultIds.back(); - m_currentState->resultIds.pop_back(); + return ReadVariable(it.value(), OnlyCache{}); + } - return resultId; + UInt32 SpirvWriter::ReadLocalVariable(const std::string& name) + { + auto it = m_currentState->varToResult.find(name); + assert(it != m_currentState->varToResult.end()); + + return it->second; + } + + std::optional SpirvWriter::ReadLocalVariable(const std::string& name, OnlyCache) + { + auto it = m_currentState->varToResult.find(name); + if (it == m_currentState->varToResult.end()) + return {}; + + return it->second; + } + + UInt32 SpirvWriter::ReadUniformVariable(const std::string& name) + { + auto it = m_currentState->uniformIds.find(name); + assert(it != m_currentState->uniformIds.end()); + + return ReadVariable(it.value()); + } + + std::optional SpirvWriter::ReadUniformVariable(const std::string& name, OnlyCache) + { + auto it = m_currentState->uniformIds.find(name); + assert(it != m_currentState->uniformIds.end()); + + return ReadVariable(it.value(), OnlyCache{}); } UInt32 SpirvWriter::ReadVariable(ExtVar& var) @@ -546,6 +604,14 @@ namespace Nz return var.valueId.value(); } + std::optional SpirvWriter::ReadVariable(const ExtVar& var, OnlyCache) + { + if (!var.valueId.has_value()) + return {}; + + return var.valueId.value(); + } + UInt32 SpirvWriter::RegisterConstant(const ShaderConstantValue& value) { return m_currentState->constantTypeCache.Register(*SpirvConstantCache::BuildConstant(value)); @@ -578,572 +644,10 @@ namespace Nz return m_currentState->constantTypeCache.Register(*SpirvConstantCache::BuildType(*m_context.shader, type)); } - void SpirvWriter::Visit(ShaderNodes::AccessMember& node) + void SpirvWriter::WriteLocalVariable(std::string name, UInt32 resultId) { - UInt32 pointerId; - SpirvStorageClass storage; - - switch (node.structExpr->GetType()) - { - case ShaderNodes::NodeType::Identifier: - { - auto& identifier = static_cast(*node.structExpr); - switch (identifier.var->GetType()) - { - case ShaderNodes::VariableType::BuiltinVariable: - { - auto& builtinvar = static_cast(*identifier.var); - auto it = m_currentState->builtinIds.find(builtinvar.entry); - assert(it != m_currentState->builtinIds.end()); - - pointerId = it->second.varId; - break; - } - - case ShaderNodes::VariableType::InputVariable: - { - auto& inputVar = static_cast(*identifier.var); - auto it = m_currentState->inputIds.find(inputVar.name); - assert(it != m_currentState->inputIds.end()); - - storage = SpirvStorageClass::Input; - - pointerId = it->second.varId; - break; - } - - case ShaderNodes::VariableType::OutputVariable: - { - auto& outputVar = static_cast(*identifier.var); - auto it = m_currentState->outputIds.find(outputVar.name); - assert(it != m_currentState->outputIds.end()); - - storage = SpirvStorageClass::Output; - - pointerId = it->second.varId; - break; - } - - case ShaderNodes::VariableType::UniformVariable: - { - auto& uniformVar = static_cast(*identifier.var); - auto it = m_currentState->uniformIds.find(uniformVar.name); - assert(it != m_currentState->uniformIds.end()); - - storage = SpirvStorageClass::Uniform; - - pointerId = it->second.varId; - break; - } - - case ShaderNodes::VariableType::LocalVariable: - case ShaderNodes::VariableType::ParameterVariable: - default: - throw std::runtime_error("not yet implemented"); - } - break; - } - - case ShaderNodes::NodeType::SwizzleOp: //< TODO - default: - throw std::runtime_error("not yet implemented"); - } - - UInt32 memberPointerId = AllocateResultId(); - UInt32 pointerType = RegisterPointerType(node.exprType, storage); //< FIXME - UInt32 typeId = GetTypeId(node.exprType); - - m_currentState->instructions.AppendVariadic(SpirvOp::OpAccessChain, [&](const auto& appender) - { - appender(pointerType); - appender(memberPointerId); - appender(pointerId); - - for (std::size_t index : node.memberIndices) - appender(GetConstantId(Int32(index))); - }); - - UInt32 resultId = AllocateResultId(); - - m_currentState->instructions.Append(SpirvOp::OpLoad, typeId, resultId, memberPointerId); - - PushResultId(resultId); - } - - void SpirvWriter::Visit(ShaderNodes::AssignOp& node) - { - UInt32 result = EvaluateExpression(node.right); - - switch (node.left->GetType()) - { - case ShaderNodes::NodeType::Identifier: - { - auto& identifier = static_cast(*node.left); - switch (identifier.var->GetType()) - { - case ShaderNodes::VariableType::BuiltinVariable: - { - auto& builtinvar = static_cast(*identifier.var); - auto it = m_currentState->builtinIds.find(builtinvar.entry); - assert(it != m_currentState->builtinIds.end()); - - m_currentState->instructions.Append(SpirvOp::OpStore, it->second.varId, result); - PushResultId(result); - break; - } - - case ShaderNodes::VariableType::OutputVariable: - { - auto& outputVar = static_cast(*identifier.var); - auto it = m_currentState->outputIds.find(outputVar.name); - assert(it != m_currentState->outputIds.end()); - - m_currentState->instructions.Append(SpirvOp::OpStore, it->second.varId, result); - PushResultId(result); - break; - } - - case ShaderNodes::VariableType::InputVariable: - case ShaderNodes::VariableType::LocalVariable: - case ShaderNodes::VariableType::ParameterVariable: - case ShaderNodes::VariableType::UniformVariable: - default: - throw std::runtime_error("not yet implemented"); - } - break; - } - - case ShaderNodes::NodeType::SwizzleOp: //< TODO - default: - throw std::runtime_error("not yet implemented"); - } - } - - void SpirvWriter::Visit(ShaderNodes::Branch& node) - { - throw std::runtime_error("not yet implemented"); - } - - void SpirvWriter::Visit(ShaderNodes::BinaryOp& node) - { - ShaderExpressionType resultExprType = node.GetExpressionType(); - assert(std::holds_alternative(resultExprType)); - - const ShaderExpressionType& leftExprType = node.left->GetExpressionType(); - assert(std::holds_alternative(leftExprType)); - - const ShaderExpressionType& rightExprType = node.right->GetExpressionType(); - assert(std::holds_alternative(rightExprType)); - - ShaderNodes::BasicType resultType = std::get(resultExprType); - ShaderNodes::BasicType leftType = std::get(leftExprType); - ShaderNodes::BasicType rightType = std::get(rightExprType); - - - UInt32 leftOperand = EvaluateExpression(node.left); - UInt32 rightOperand = EvaluateExpression(node.right); - UInt32 resultId = AllocateResultId(); - - bool swapOperands = false; - - SpirvOp op = [&] - { - switch (node.op) - { - case ShaderNodes::BinaryType::Add: - { - switch (leftType) - { - case ShaderNodes::BasicType::Float1: - case ShaderNodes::BasicType::Float2: - case ShaderNodes::BasicType::Float3: - case ShaderNodes::BasicType::Float4: - case ShaderNodes::BasicType::Mat4x4: - return SpirvOp::OpFAdd; - - case ShaderNodes::BasicType::Int1: - case ShaderNodes::BasicType::Int2: - case ShaderNodes::BasicType::Int3: - case ShaderNodes::BasicType::Int4: - case ShaderNodes::BasicType::UInt1: - case ShaderNodes::BasicType::UInt2: - case ShaderNodes::BasicType::UInt3: - case ShaderNodes::BasicType::UInt4: - return SpirvOp::OpIAdd; - - case ShaderNodes::BasicType::Boolean: - case ShaderNodes::BasicType::Sampler2D: - case ShaderNodes::BasicType::Void: - break; - } - } - - case ShaderNodes::BinaryType::Substract: - { - switch (leftType) - { - case ShaderNodes::BasicType::Float1: - case ShaderNodes::BasicType::Float2: - case ShaderNodes::BasicType::Float3: - case ShaderNodes::BasicType::Float4: - case ShaderNodes::BasicType::Mat4x4: - return SpirvOp::OpFSub; - - case ShaderNodes::BasicType::Int1: - case ShaderNodes::BasicType::Int2: - case ShaderNodes::BasicType::Int3: - case ShaderNodes::BasicType::Int4: - case ShaderNodes::BasicType::UInt1: - case ShaderNodes::BasicType::UInt2: - case ShaderNodes::BasicType::UInt3: - case ShaderNodes::BasicType::UInt4: - return SpirvOp::OpISub; - - case ShaderNodes::BasicType::Boolean: - case ShaderNodes::BasicType::Sampler2D: - case ShaderNodes::BasicType::Void: - break; - } - } - - case ShaderNodes::BinaryType::Divide: - { - switch (leftType) - { - case ShaderNodes::BasicType::Float1: - case ShaderNodes::BasicType::Float2: - case ShaderNodes::BasicType::Float3: - case ShaderNodes::BasicType::Float4: - case ShaderNodes::BasicType::Mat4x4: - return SpirvOp::OpFDiv; - - case ShaderNodes::BasicType::Int1: - case ShaderNodes::BasicType::Int2: - case ShaderNodes::BasicType::Int3: - case ShaderNodes::BasicType::Int4: - return SpirvOp::OpSDiv; - - case ShaderNodes::BasicType::UInt1: - case ShaderNodes::BasicType::UInt2: - case ShaderNodes::BasicType::UInt3: - case ShaderNodes::BasicType::UInt4: - return SpirvOp::OpUDiv; - - case ShaderNodes::BasicType::Boolean: - case ShaderNodes::BasicType::Sampler2D: - case ShaderNodes::BasicType::Void: - break; - } - } - - case ShaderNodes::BinaryType::Equality: - { - switch (leftType) - { - case ShaderNodes::BasicType::Boolean: - return SpirvOp::OpLogicalEqual; - - case ShaderNodes::BasicType::Float1: - case ShaderNodes::BasicType::Float2: - case ShaderNodes::BasicType::Float3: - case ShaderNodes::BasicType::Float4: - case ShaderNodes::BasicType::Mat4x4: - return SpirvOp::OpFOrdEqual; - - case ShaderNodes::BasicType::Int1: - case ShaderNodes::BasicType::Int2: - case ShaderNodes::BasicType::Int3: - case ShaderNodes::BasicType::Int4: - case ShaderNodes::BasicType::UInt1: - case ShaderNodes::BasicType::UInt2: - case ShaderNodes::BasicType::UInt3: - case ShaderNodes::BasicType::UInt4: - return SpirvOp::OpIEqual; - - case ShaderNodes::BasicType::Sampler2D: - case ShaderNodes::BasicType::Void: - break; - } - } - - case ShaderNodes::BinaryType::Multiply: - { - switch (leftType) - { - case ShaderNodes::BasicType::Float1: - { - switch (rightType) - { - case ShaderNodes::BasicType::Float1: - return SpirvOp::OpFMul; - - case ShaderNodes::BasicType::Float2: - case ShaderNodes::BasicType::Float3: - case ShaderNodes::BasicType::Float4: - swapOperands = true; - return SpirvOp::OpVectorTimesScalar; - - case ShaderNodes::BasicType::Mat4x4: - swapOperands = true; - return SpirvOp::OpMatrixTimesScalar; - - default: - break; - } - - break; - } - - case ShaderNodes::BasicType::Float2: - case ShaderNodes::BasicType::Float3: - case ShaderNodes::BasicType::Float4: - { - switch (rightType) - { - case ShaderNodes::BasicType::Float1: - return SpirvOp::OpVectorTimesScalar; - - case ShaderNodes::BasicType::Float2: - case ShaderNodes::BasicType::Float3: - case ShaderNodes::BasicType::Float4: - return SpirvOp::OpFMul; - - case ShaderNodes::BasicType::Mat4x4: - return SpirvOp::OpVectorTimesMatrix; - - default: - break; - } - - break; - } - - case ShaderNodes::BasicType::Int1: - case ShaderNodes::BasicType::Int2: - case ShaderNodes::BasicType::Int3: - case ShaderNodes::BasicType::Int4: - case ShaderNodes::BasicType::UInt1: - case ShaderNodes::BasicType::UInt2: - case ShaderNodes::BasicType::UInt3: - case ShaderNodes::BasicType::UInt4: - return SpirvOp::OpIMul; - - case ShaderNodes::BasicType::Mat4x4: - { - switch (rightType) - { - case ShaderNodes::BasicType::Float1: return SpirvOp::OpMatrixTimesScalar; - case ShaderNodes::BasicType::Float4: return SpirvOp::OpMatrixTimesVector; - case ShaderNodes::BasicType::Mat4x4: return SpirvOp::OpMatrixTimesMatrix; - - default: - break; - } - - break; - } - - default: - break; - } - break; - } - } - - assert(false); - throw std::runtime_error("unexpected binary operation"); - }(); - - if (swapOperands) - std::swap(leftOperand, rightOperand); - - m_currentState->instructions.Append(op, GetTypeId(resultType), resultId, leftOperand, rightOperand); - PushResultId(resultId); - } - - void SpirvWriter::Visit(ShaderNodes::Cast& node) - { - const ShaderExpressionType& targetExprType = node.exprType; - assert(std::holds_alternative(targetExprType)); - - ShaderNodes::BasicType targetType = std::get(targetExprType); - - StackVector exprResults = NazaraStackVector(UInt32, node.expressions.size()); - - for (const auto& exprPtr : node.expressions) - { - if (!exprPtr) - break; - - exprResults.push_back(EvaluateExpression(exprPtr)); - } - - UInt32 resultId = AllocateResultId(); - - m_currentState->instructions.AppendVariadic(SpirvOp::OpCompositeConstruct, [&](const auto& appender) - { - appender(GetTypeId(targetType)); - appender(resultId); - - for (UInt32 exprResultId : exprResults) - appender(exprResultId); - }); - - PushResultId(resultId); - } - - void SpirvWriter::Visit(ShaderNodes::Constant& node) - { - std::visit([&] (const auto& value) - { - PushResultId(GetConstantId(value)); - }, node.value); - } - - void SpirvWriter::Visit(ShaderNodes::DeclareVariable& node) - { - if (node.expression) - { - assert(node.variable->GetType() == ShaderNodes::VariableType::LocalVariable); - - const auto& localVar = static_cast(*node.variable); - m_currentState->varToResult[localVar.name] = EvaluateExpression(node.expression); - } - } - - void SpirvWriter::Visit(ShaderNodes::ExpressionStatement& node) - { - Visit(node.expression); - PopResultId(); - } - - void SpirvWriter::Visit(ShaderNodes::Identifier& node) - { - Visit(node.var); - } - - void SpirvWriter::Visit(ShaderNodes::IntrinsicCall& node) - { - switch (node.intrinsic) - { - case ShaderNodes::IntrinsicType::DotProduct: - { - const ShaderExpressionType& vecExprType = node.parameters[0]->GetExpressionType(); - assert(std::holds_alternative(vecExprType)); - - ShaderNodes::BasicType vecType = std::get(vecExprType); - - UInt32 typeId = GetTypeId(node.GetComponentType(vecType)); - - UInt32 vec1 = EvaluateExpression(node.parameters[0]); - UInt32 vec2 = EvaluateExpression(node.parameters[1]); - - UInt32 resultId = AllocateResultId(); - - m_currentState->instructions.Append(SpirvOp::OpDot, typeId, resultId, vec1, vec2); - PushResultId(resultId); - break; - } - - case ShaderNodes::IntrinsicType::CrossProduct: - default: - throw std::runtime_error("not yet implemented"); - } - } - - void SpirvWriter::Visit(ShaderNodes::Sample2D& node) - { - UInt32 typeId = GetTypeId(ShaderNodes::BasicType::Float4); - - UInt32 samplerId = EvaluateExpression(node.sampler); - UInt32 coordinatesId = EvaluateExpression(node.coordinates); - UInt32 resultId = AllocateResultId(); - - m_currentState->instructions.Append(SpirvOp::OpImageSampleImplicitLod, typeId, resultId, samplerId, coordinatesId); - PushResultId(resultId); - } - - void SpirvWriter::Visit(ShaderNodes::StatementBlock& node) - { - for (auto& statement : node.statements) - Visit(statement); - } - - void SpirvWriter::Visit(ShaderNodes::SwizzleOp& node) - { - const ShaderExpressionType& targetExprType = node.GetExpressionType(); - assert(std::holds_alternative(targetExprType)); - - ShaderNodes::BasicType targetType = std::get(targetExprType); - - UInt32 exprResultId = EvaluateExpression(node.expression); - UInt32 resultId = AllocateResultId(); - - if (node.componentCount > 1) - { - // Swizzling is implemented via SpirvOp::OpVectorShuffle using the same vector twice as operands - m_currentState->instructions.AppendVariadic(SpirvOp::OpVectorShuffle, [&](const auto& appender) - { - appender(GetTypeId(targetType)); - appender(resultId); - appender(exprResultId); - appender(exprResultId); - - for (std::size_t i = 0; i < node.componentCount; ++i) - appender(UInt32(node.components[0]) - UInt32(node.components[i])); - }); - } - else - { - // Extract a single component from the vector - assert(node.componentCount == 1); - - m_currentState->instructions.Append(SpirvOp::OpCompositeExtract, GetTypeId(targetType), resultId, exprResultId, UInt32(node.components[0]) - UInt32(ShaderNodes::SwizzleComponent::First) ); - } - - PushResultId(resultId); - } - - void SpirvWriter::Visit(ShaderNodes::BuiltinVariable& var) - { - throw std::runtime_error("not implemented yet"); - } - - void SpirvWriter::Visit(ShaderNodes::InputVariable& var) - { - auto it = m_currentState->inputIds.find(var.name); - assert(it != m_currentState->inputIds.end()); - - PushResultId(ReadVariable(it.value())); - } - - void SpirvWriter::Visit(ShaderNodes::LocalVariable& var) - { - auto it = m_currentState->varToResult.find(var.name); - assert(it != m_currentState->varToResult.end()); - - PushResultId(it->second); - } - - void SpirvWriter::Visit(ShaderNodes::OutputVariable& var) - { - auto it = m_currentState->outputIds.find(var.name); - assert(it != m_currentState->outputIds.end()); - - PushResultId(ReadVariable(it.value())); - } - - void SpirvWriter::Visit(ShaderNodes::ParameterVariable& var) - { - throw std::runtime_error("not implemented yet"); - } - - void SpirvWriter::Visit(ShaderNodes::UniformVariable& var) - { - auto it = m_currentState->uniformIds.find(var.name); - assert(it != m_currentState->uniformIds.end()); - - PushResultId(ReadVariable(it.value())); + assert(m_currentState); + m_currentState->varToResult.insert_or_assign(std::move(name), resultId); } void SpirvWriter::MergeBlocks(std::vector& output, const SpirvSection& from) From 6c379eff68b05a10b7c6b33911388b422f99bdde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sun, 23 Aug 2020 18:32:31 +0200 Subject: [PATCH 306/316] Update vert.shader --- examples/bin/vert.shader | Bin 695 -> 695 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/examples/bin/vert.shader b/examples/bin/vert.shader index 2d5c2daca53655ae10ead8e456b58e596ff8c89c..69183b00d8989495f81ecd69d9b201ca392f5af0 100644 GIT binary patch delta 41 ucmdnax}9~yLB`2P85J2BC+}j^VP#}sU|^cOk5L26Vw`NsWHh;$$prxJUJ0@Q delta 43 scmdnax}9~yLB`2@8C6*sfPiW8K1LNVixI?{?82l!xrb44atD(>0R89+?*IS* From 77b66620c97aaf82590e0c0a43b7c8423da46e48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Sun, 23 Aug 2020 21:56:30 +0200 Subject: [PATCH 307/316] Refactor SpirV classes SpirvStatementVisitor was merged with SpirvExpressionLoad SpirvExpressionLoadAccessMember was renamed SpirvExpressionLoad --- include/Nazara/Shader/SpirvAstVisitor.hpp | 58 +++ ...atementVisitor.inl => SpirvAstVisitor.inl} | 4 +- include/Nazara/Shader/SpirvExpressionLoad.hpp | 37 +- .../SpirvExpressionLoadAccessMember.hpp | 62 --- .../SpirvExpressionLoadAccessMember.inl | 16 - .../Nazara/Shader/SpirvStatementVisitor.hpp | 43 -- include/Nazara/Shader/SpirvWriter.hpp | 4 +- src/Nazara/Shader/SpirvAstVisitor.cpp | 433 ++++++++++++++++ src/Nazara/Shader/SpirvExpressionLoad.cpp | 479 +++--------------- .../SpirvExpressionLoadAccessMember.cpp | 116 ----- src/Nazara/Shader/SpirvStatementVisitor.cpp | 49 -- src/Nazara/Shader/SpirvWriter.cpp | 4 +- 12 files changed, 591 insertions(+), 714 deletions(-) create mode 100644 include/Nazara/Shader/SpirvAstVisitor.hpp rename include/Nazara/Shader/{SpirvStatementVisitor.inl => SpirvAstVisitor.inl} (70%) delete mode 100644 include/Nazara/Shader/SpirvExpressionLoadAccessMember.hpp delete mode 100644 include/Nazara/Shader/SpirvExpressionLoadAccessMember.inl delete mode 100644 include/Nazara/Shader/SpirvStatementVisitor.hpp create mode 100644 src/Nazara/Shader/SpirvAstVisitor.cpp delete mode 100644 src/Nazara/Shader/SpirvExpressionLoadAccessMember.cpp delete mode 100644 src/Nazara/Shader/SpirvStatementVisitor.cpp diff --git a/include/Nazara/Shader/SpirvAstVisitor.hpp b/include/Nazara/Shader/SpirvAstVisitor.hpp new file mode 100644 index 000000000..743dd5130 --- /dev/null +++ b/include/Nazara/Shader/SpirvAstVisitor.hpp @@ -0,0 +1,58 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_SPIRVEXPRESSIONLOAD_HPP +#define NAZARA_SPIRVEXPRESSIONLOAD_HPP + +#include +#include +#include +#include +#include + +namespace Nz +{ + class SpirvWriter; + + class NAZARA_SHADER_API SpirvAstVisitor : public ShaderAstVisitorExcept + { + public: + inline SpirvAstVisitor(SpirvWriter& writer); + SpirvAstVisitor(const SpirvAstVisitor&) = delete; + SpirvAstVisitor(SpirvAstVisitor&&) = delete; + ~SpirvAstVisitor() = default; + + UInt32 EvaluateExpression(const ShaderNodes::ExpressionPtr& expr); + + using ShaderAstVisitorExcept::Visit; + void Visit(ShaderNodes::AccessMember& node) override; + void Visit(ShaderNodes::AssignOp& node) override; + void Visit(ShaderNodes::BinaryOp& node) override; + void Visit(ShaderNodes::Cast& node) override; + void Visit(ShaderNodes::Constant& node) override; + void Visit(ShaderNodes::DeclareVariable& node) override; + void Visit(ShaderNodes::ExpressionStatement& node) override; + void Visit(ShaderNodes::Identifier& node) override; + void Visit(ShaderNodes::IntrinsicCall& node) override; + void Visit(ShaderNodes::Sample2D& node) override; + void Visit(ShaderNodes::StatementBlock& node) override; + void Visit(ShaderNodes::SwizzleOp& node) override; + + SpirvAstVisitor& operator=(const SpirvAstVisitor&) = delete; + SpirvAstVisitor& operator=(SpirvAstVisitor&&) = delete; + + private: + void PushResultId(UInt32 value); + UInt32 PopResultId(); + + std::vector m_resultIds; + SpirvWriter& m_writer; + }; +} + +#include + +#endif diff --git a/include/Nazara/Shader/SpirvStatementVisitor.inl b/include/Nazara/Shader/SpirvAstVisitor.inl similarity index 70% rename from include/Nazara/Shader/SpirvStatementVisitor.inl rename to include/Nazara/Shader/SpirvAstVisitor.inl index fc2274c10..87dc93a54 100644 --- a/include/Nazara/Shader/SpirvStatementVisitor.inl +++ b/include/Nazara/Shader/SpirvAstVisitor.inl @@ -2,12 +2,12 @@ // This file is part of the "Nazara Engine - Shader generator" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include namespace Nz { - inline SpirvStatementVisitor::SpirvStatementVisitor(SpirvWriter& writer) : + inline SpirvAstVisitor::SpirvAstVisitor(SpirvWriter& writer) : m_writer(writer) { } diff --git a/include/Nazara/Shader/SpirvExpressionLoad.hpp b/include/Nazara/Shader/SpirvExpressionLoad.hpp index a766e568d..b237c720a 100644 --- a/include/Nazara/Shader/SpirvExpressionLoad.hpp +++ b/include/Nazara/Shader/SpirvExpressionLoad.hpp @@ -4,13 +4,14 @@ #pragma once -#ifndef NAZARA_SPIRVEXPRESSIONLOAD_HPP -#define NAZARA_SPIRVEXPRESSIONLOAD_HPP +#ifndef NAZARA_SPIRVEXPRESSIONLOADACCESSMEMBER_HPP +#define NAZARA_SPIRVEXPRESSIONLOADACCESSMEMBER_HPP #include #include #include #include +#include #include namespace Nz @@ -25,37 +26,35 @@ namespace Nz SpirvExpressionLoad(SpirvExpressionLoad&&) = delete; ~SpirvExpressionLoad() = default; - UInt32 EvaluateExpression(const ShaderNodes::ExpressionPtr& expr); + UInt32 Evaluate(ShaderNodes::Expression& node); - using ShaderAstVisitorExcept::Visit; + using ShaderAstVisitor::Visit; void Visit(ShaderNodes::AccessMember& node) override; - void Visit(ShaderNodes::AssignOp& node) override; - void Visit(ShaderNodes::BinaryOp& node) override; - void Visit(ShaderNodes::Cast& node) override; - void Visit(ShaderNodes::Constant& node) override; - void Visit(ShaderNodes::DeclareVariable& node) override; - void Visit(ShaderNodes::ExpressionStatement& node) override; void Visit(ShaderNodes::Identifier& node) override; - void Visit(ShaderNodes::IntrinsicCall& node) override; - void Visit(ShaderNodes::Sample2D& node) override; - void Visit(ShaderNodes::SwizzleOp& node) override; - using ShaderVarVisitorExcept::Visit; - void Visit(ShaderNodes::BuiltinVariable& var) override; + using ShaderVarVisitor::Visit; void Visit(ShaderNodes::InputVariable& var) override; void Visit(ShaderNodes::LocalVariable& var) override; - void Visit(ShaderNodes::ParameterVariable& var) override; void Visit(ShaderNodes::UniformVariable& var) override; SpirvExpressionLoad& operator=(const SpirvExpressionLoad&) = delete; SpirvExpressionLoad& operator=(SpirvExpressionLoad&&) = delete; private: - void PushResultId(UInt32 value); - UInt32 PopResultId(); + struct Pointer + { + SpirvStorageClass storage; + UInt32 resultId; + UInt32 pointedTypeId; + }; + + struct Value + { + UInt32 resultId; + }; - std::vector m_resultIds; SpirvWriter& m_writer; + std::variant m_value; }; } diff --git a/include/Nazara/Shader/SpirvExpressionLoadAccessMember.hpp b/include/Nazara/Shader/SpirvExpressionLoadAccessMember.hpp deleted file mode 100644 index 8e2e0ff3b..000000000 --- a/include/Nazara/Shader/SpirvExpressionLoadAccessMember.hpp +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - Shader generator" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_SPIRVEXPRESSIONLOADACCESSMEMBER_HPP -#define NAZARA_SPIRVEXPRESSIONLOADACCESSMEMBER_HPP - -#include -#include -#include -#include -#include -#include - -namespace Nz -{ - class SpirvWriter; - - class NAZARA_SHADER_API SpirvExpressionLoadAccessMember : public ShaderAstVisitorExcept, public ShaderVarVisitorExcept - { - public: - inline SpirvExpressionLoadAccessMember(SpirvWriter& writer); - SpirvExpressionLoadAccessMember(const SpirvExpressionLoadAccessMember&) = delete; - SpirvExpressionLoadAccessMember(SpirvExpressionLoadAccessMember&&) = delete; - ~SpirvExpressionLoadAccessMember() = default; - - UInt32 EvaluateExpression(ShaderNodes::AccessMember& expr); - - using ShaderAstVisitor::Visit; - void Visit(ShaderNodes::AccessMember& node) override; - void Visit(ShaderNodes::Identifier& node) override; - - using ShaderVarVisitor::Visit; - void Visit(ShaderNodes::InputVariable& var) override; - void Visit(ShaderNodes::UniformVariable& var) override; - - SpirvExpressionLoadAccessMember& operator=(const SpirvExpressionLoadAccessMember&) = delete; - SpirvExpressionLoadAccessMember& operator=(SpirvExpressionLoadAccessMember&&) = delete; - - private: - struct Pointer - { - SpirvStorageClass storage; - UInt32 resultId; - UInt32 pointedTypeId; - }; - - struct Value - { - UInt32 resultId; - }; - - SpirvWriter& m_writer; - std::variant m_value; - }; -} - -#include - -#endif diff --git a/include/Nazara/Shader/SpirvExpressionLoadAccessMember.inl b/include/Nazara/Shader/SpirvExpressionLoadAccessMember.inl deleted file mode 100644 index d81cfbb9c..000000000 --- a/include/Nazara/Shader/SpirvExpressionLoadAccessMember.inl +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - Shader generator" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include - -namespace Nz -{ - inline SpirvExpressionLoadAccessMember::SpirvExpressionLoadAccessMember(SpirvWriter& writer) : - m_writer(writer) - { - } -} - -#include diff --git a/include/Nazara/Shader/SpirvStatementVisitor.hpp b/include/Nazara/Shader/SpirvStatementVisitor.hpp deleted file mode 100644 index 1ba88942c..000000000 --- a/include/Nazara/Shader/SpirvStatementVisitor.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - Shader generator" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#pragma once - -#ifndef NAZARA_SPIRVSTATEMENTVISITOR_HPP -#define NAZARA_SPIRVSTATEMENTVISITOR_HPP - -#include -#include -#include - -namespace Nz -{ - class SpirvWriter; - - class NAZARA_SHADER_API SpirvStatementVisitor : public ShaderAstVisitorExcept - { - public: - inline SpirvStatementVisitor(SpirvWriter& writer); - SpirvStatementVisitor(const SpirvStatementVisitor&) = delete; - SpirvStatementVisitor(SpirvStatementVisitor&&) = delete; - ~SpirvStatementVisitor() = default; - - using ShaderAstVisitor::Visit; - void Visit(ShaderNodes::AssignOp& node) override; - void Visit(ShaderNodes::Branch& node) override; - void Visit(ShaderNodes::DeclareVariable& node) override; - void Visit(ShaderNodes::ExpressionStatement& node) override; - void Visit(ShaderNodes::StatementBlock& node) override; - - SpirvStatementVisitor& operator=(const SpirvStatementVisitor&) = delete; - SpirvStatementVisitor& operator=(SpirvStatementVisitor&&) = delete; - - private: - SpirvWriter& m_writer; - }; -} - -#include - -#endif diff --git a/include/Nazara/Shader/SpirvWriter.hpp b/include/Nazara/Shader/SpirvWriter.hpp index 8bb38087b..6b21de0ba 100644 --- a/include/Nazara/Shader/SpirvWriter.hpp +++ b/include/Nazara/Shader/SpirvWriter.hpp @@ -25,10 +25,10 @@ namespace Nz class NAZARA_SHADER_API SpirvWriter { + friend class SpirvAstVisitor; friend class SpirvExpressionLoad; - friend class SpirvExpressionLoadAccessMember; friend class SpirvExpressionStore; - friend class SpirvStatementVisitor; + friend class SpirvVisitor; public: struct Environment; diff --git a/src/Nazara/Shader/SpirvAstVisitor.cpp b/src/Nazara/Shader/SpirvAstVisitor.cpp new file mode 100644 index 000000000..d66f76170 --- /dev/null +++ b/src/Nazara/Shader/SpirvAstVisitor.cpp @@ -0,0 +1,433 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Shader generator" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include +#include +#include +#include + +namespace Nz +{ + UInt32 SpirvAstVisitor::EvaluateExpression(const ShaderNodes::ExpressionPtr& expr) + { + Visit(expr); + return PopResultId(); + } + + void SpirvAstVisitor::Visit(ShaderNodes::AccessMember& node) + { + SpirvExpressionLoad accessMemberVisitor(m_writer); + PushResultId(accessMemberVisitor.Evaluate(node)); + } + + void SpirvAstVisitor::Visit(ShaderNodes::AssignOp& node) + { + UInt32 resultId = EvaluateExpression(node.right); + + SpirvExpressionStore storeVisitor(m_writer); + storeVisitor.Store(node.left, resultId); + + PushResultId(resultId); + } + + void SpirvAstVisitor::Visit(ShaderNodes::BinaryOp& node) + { + ShaderExpressionType resultExprType = node.GetExpressionType(); + assert(std::holds_alternative(resultExprType)); + + const ShaderExpressionType& leftExprType = node.left->GetExpressionType(); + assert(std::holds_alternative(leftExprType)); + + const ShaderExpressionType& rightExprType = node.right->GetExpressionType(); + assert(std::holds_alternative(rightExprType)); + + ShaderNodes::BasicType resultType = std::get(resultExprType); + ShaderNodes::BasicType leftType = std::get(leftExprType); + ShaderNodes::BasicType rightType = std::get(rightExprType); + + + UInt32 leftOperand = EvaluateExpression(node.left); + UInt32 rightOperand = EvaluateExpression(node.right); + UInt32 resultId = m_writer.AllocateResultId(); + + bool swapOperands = false; + + SpirvOp op = [&] + { + switch (node.op) + { + case ShaderNodes::BinaryType::Add: + { + switch (leftType) + { + case ShaderNodes::BasicType::Float1: + case ShaderNodes::BasicType::Float2: + case ShaderNodes::BasicType::Float3: + case ShaderNodes::BasicType::Float4: + case ShaderNodes::BasicType::Mat4x4: + return SpirvOp::OpFAdd; + + case ShaderNodes::BasicType::Int1: + case ShaderNodes::BasicType::Int2: + case ShaderNodes::BasicType::Int3: + case ShaderNodes::BasicType::Int4: + case ShaderNodes::BasicType::UInt1: + case ShaderNodes::BasicType::UInt2: + case ShaderNodes::BasicType::UInt3: + case ShaderNodes::BasicType::UInt4: + return SpirvOp::OpIAdd; + + case ShaderNodes::BasicType::Boolean: + case ShaderNodes::BasicType::Sampler2D: + case ShaderNodes::BasicType::Void: + break; + } + } + + case ShaderNodes::BinaryType::Substract: + { + switch (leftType) + { + case ShaderNodes::BasicType::Float1: + case ShaderNodes::BasicType::Float2: + case ShaderNodes::BasicType::Float3: + case ShaderNodes::BasicType::Float4: + case ShaderNodes::BasicType::Mat4x4: + return SpirvOp::OpFSub; + + case ShaderNodes::BasicType::Int1: + case ShaderNodes::BasicType::Int2: + case ShaderNodes::BasicType::Int3: + case ShaderNodes::BasicType::Int4: + case ShaderNodes::BasicType::UInt1: + case ShaderNodes::BasicType::UInt2: + case ShaderNodes::BasicType::UInt3: + case ShaderNodes::BasicType::UInt4: + return SpirvOp::OpISub; + + case ShaderNodes::BasicType::Boolean: + case ShaderNodes::BasicType::Sampler2D: + case ShaderNodes::BasicType::Void: + break; + } + } + + case ShaderNodes::BinaryType::Divide: + { + switch (leftType) + { + case ShaderNodes::BasicType::Float1: + case ShaderNodes::BasicType::Float2: + case ShaderNodes::BasicType::Float3: + case ShaderNodes::BasicType::Float4: + case ShaderNodes::BasicType::Mat4x4: + return SpirvOp::OpFDiv; + + case ShaderNodes::BasicType::Int1: + case ShaderNodes::BasicType::Int2: + case ShaderNodes::BasicType::Int3: + case ShaderNodes::BasicType::Int4: + return SpirvOp::OpSDiv; + + case ShaderNodes::BasicType::UInt1: + case ShaderNodes::BasicType::UInt2: + case ShaderNodes::BasicType::UInt3: + case ShaderNodes::BasicType::UInt4: + return SpirvOp::OpUDiv; + + case ShaderNodes::BasicType::Boolean: + case ShaderNodes::BasicType::Sampler2D: + case ShaderNodes::BasicType::Void: + break; + } + } + + case ShaderNodes::BinaryType::Equality: + { + switch (leftType) + { + case ShaderNodes::BasicType::Boolean: + return SpirvOp::OpLogicalEqual; + + case ShaderNodes::BasicType::Float1: + case ShaderNodes::BasicType::Float2: + case ShaderNodes::BasicType::Float3: + case ShaderNodes::BasicType::Float4: + case ShaderNodes::BasicType::Mat4x4: + return SpirvOp::OpFOrdEqual; + + case ShaderNodes::BasicType::Int1: + case ShaderNodes::BasicType::Int2: + case ShaderNodes::BasicType::Int3: + case ShaderNodes::BasicType::Int4: + case ShaderNodes::BasicType::UInt1: + case ShaderNodes::BasicType::UInt2: + case ShaderNodes::BasicType::UInt3: + case ShaderNodes::BasicType::UInt4: + return SpirvOp::OpIEqual; + + case ShaderNodes::BasicType::Sampler2D: + case ShaderNodes::BasicType::Void: + break; + } + } + + case ShaderNodes::BinaryType::Multiply: + { + switch (leftType) + { + case ShaderNodes::BasicType::Float1: + { + switch (rightType) + { + case ShaderNodes::BasicType::Float1: + return SpirvOp::OpFMul; + + case ShaderNodes::BasicType::Float2: + case ShaderNodes::BasicType::Float3: + case ShaderNodes::BasicType::Float4: + swapOperands = true; + return SpirvOp::OpVectorTimesScalar; + + case ShaderNodes::BasicType::Mat4x4: + swapOperands = true; + return SpirvOp::OpMatrixTimesScalar; + + default: + break; + } + + break; + } + + case ShaderNodes::BasicType::Float2: + case ShaderNodes::BasicType::Float3: + case ShaderNodes::BasicType::Float4: + { + switch (rightType) + { + case ShaderNodes::BasicType::Float1: + return SpirvOp::OpVectorTimesScalar; + + case ShaderNodes::BasicType::Float2: + case ShaderNodes::BasicType::Float3: + case ShaderNodes::BasicType::Float4: + return SpirvOp::OpFMul; + + case ShaderNodes::BasicType::Mat4x4: + return SpirvOp::OpVectorTimesMatrix; + + default: + break; + } + + break; + } + + case ShaderNodes::BasicType::Int1: + case ShaderNodes::BasicType::Int2: + case ShaderNodes::BasicType::Int3: + case ShaderNodes::BasicType::Int4: + case ShaderNodes::BasicType::UInt1: + case ShaderNodes::BasicType::UInt2: + case ShaderNodes::BasicType::UInt3: + case ShaderNodes::BasicType::UInt4: + return SpirvOp::OpIMul; + + case ShaderNodes::BasicType::Mat4x4: + { + switch (rightType) + { + case ShaderNodes::BasicType::Float1: return SpirvOp::OpMatrixTimesScalar; + case ShaderNodes::BasicType::Float4: return SpirvOp::OpMatrixTimesVector; + case ShaderNodes::BasicType::Mat4x4: return SpirvOp::OpMatrixTimesMatrix; + + default: + break; + } + + break; + } + + default: + break; + } + break; + } + } + + assert(false); + throw std::runtime_error("unexpected binary operation"); + }(); + + if (swapOperands) + std::swap(leftOperand, rightOperand); + + m_writer.GetInstructions().Append(op, m_writer.GetTypeId(resultType), resultId, leftOperand, rightOperand); + PushResultId(resultId); + } + + void SpirvAstVisitor::Visit(ShaderNodes::Cast& node) + { + const ShaderExpressionType& targetExprType = node.exprType; + assert(std::holds_alternative(targetExprType)); + + ShaderNodes::BasicType targetType = std::get(targetExprType); + + StackVector exprResults = NazaraStackVector(UInt32, node.expressions.size()); + + for (const auto& exprPtr : node.expressions) + { + if (!exprPtr) + break; + + exprResults.push_back(EvaluateExpression(exprPtr)); + } + + UInt32 resultId = m_writer.AllocateResultId(); + + m_writer.GetInstructions().AppendVariadic(SpirvOp::OpCompositeConstruct, [&](const auto& appender) + { + appender(m_writer.GetTypeId(targetType)); + appender(resultId); + + for (UInt32 exprResultId : exprResults) + appender(exprResultId); + }); + + PushResultId(resultId); + } + + void SpirvAstVisitor::Visit(ShaderNodes::Constant& node) + { + std::visit([&] (const auto& value) + { + PushResultId(m_writer.GetConstantId(value)); + }, node.value); + } + + void SpirvAstVisitor::Visit(ShaderNodes::DeclareVariable& node) + { + if (node.expression) + { + assert(node.variable->GetType() == ShaderNodes::VariableType::LocalVariable); + + const auto& localVar = static_cast(*node.variable); + m_writer.WriteLocalVariable(localVar.name, EvaluateExpression(node.expression)); + } + } + + void SpirvAstVisitor::Visit(ShaderNodes::ExpressionStatement& node) + { + Visit(node.expression); + PopResultId(); + } + + void SpirvAstVisitor::Visit(ShaderNodes::Identifier& node) + { + SpirvExpressionLoad loadVisitor(m_writer); + PushResultId(loadVisitor.Evaluate(node)); + } + + void SpirvAstVisitor::Visit(ShaderNodes::IntrinsicCall& node) + { + switch (node.intrinsic) + { + case ShaderNodes::IntrinsicType::DotProduct: + { + const ShaderExpressionType& vecExprType = node.parameters[0]->GetExpressionType(); + assert(std::holds_alternative(vecExprType)); + + ShaderNodes::BasicType vecType = std::get(vecExprType); + + UInt32 typeId = m_writer.GetTypeId(node.GetComponentType(vecType)); + + UInt32 vec1 = EvaluateExpression(node.parameters[0]); + UInt32 vec2 = EvaluateExpression(node.parameters[1]); + + UInt32 resultId = m_writer.AllocateResultId(); + + m_writer.GetInstructions().Append(SpirvOp::OpDot, typeId, resultId, vec1, vec2); + PushResultId(resultId); + break; + } + + case ShaderNodes::IntrinsicType::CrossProduct: + default: + throw std::runtime_error("not yet implemented"); + } + } + + void SpirvAstVisitor::Visit(ShaderNodes::Sample2D& node) + { + UInt32 typeId = m_writer.GetTypeId(ShaderNodes::BasicType::Float4); + + UInt32 samplerId = EvaluateExpression(node.sampler); + UInt32 coordinatesId = EvaluateExpression(node.coordinates); + UInt32 resultId = m_writer.AllocateResultId(); + + m_writer.GetInstructions().Append(SpirvOp::OpImageSampleImplicitLod, typeId, resultId, samplerId, coordinatesId); + PushResultId(resultId); + } + + void SpirvAstVisitor::Visit(ShaderNodes::StatementBlock& node) + { + for (auto& statement : node.statements) + Visit(statement); + } + + void SpirvAstVisitor::Visit(ShaderNodes::SwizzleOp& node) + { + const ShaderExpressionType& targetExprType = node.GetExpressionType(); + assert(std::holds_alternative(targetExprType)); + + ShaderNodes::BasicType targetType = std::get(targetExprType); + + UInt32 exprResultId = EvaluateExpression(node.expression); + UInt32 resultId = m_writer.AllocateResultId(); + + if (node.componentCount > 1) + { + // Swizzling is implemented via SpirvOp::OpVectorShuffle using the same vector twice as operands + m_writer.GetInstructions().AppendVariadic(SpirvOp::OpVectorShuffle, [&](const auto& appender) + { + appender(m_writer.GetTypeId(targetType)); + appender(resultId); + appender(exprResultId); + appender(exprResultId); + + for (std::size_t i = 0; i < node.componentCount; ++i) + appender(UInt32(node.components[0]) - UInt32(node.components[i])); + }); + } + else + { + // Extract a single component from the vector + assert(node.componentCount == 1); + + m_writer.GetInstructions().Append(SpirvOp::OpCompositeExtract, m_writer.GetTypeId(targetType), resultId, exprResultId, UInt32(node.components[0]) - UInt32(ShaderNodes::SwizzleComponent::First) ); + } + + PushResultId(resultId); + } + + void SpirvAstVisitor::PushResultId(UInt32 value) + { + m_resultIds.push_back(value); + } + + UInt32 SpirvAstVisitor::PopResultId() + { + if (m_resultIds.empty()) + throw std::runtime_error("invalid operation"); + + UInt32 resultId = m_resultIds.back(); + m_resultIds.pop_back(); + + return resultId; + } +} diff --git a/src/Nazara/Shader/SpirvExpressionLoad.cpp b/src/Nazara/Shader/SpirvExpressionLoad.cpp index b032326fb..00e7ad815 100644 --- a/src/Nazara/Shader/SpirvExpressionLoad.cpp +++ b/src/Nazara/Shader/SpirvExpressionLoad.cpp @@ -5,317 +5,88 @@ #include #include #include -#include -#include #include #include namespace Nz { + namespace + { + template struct overloaded : Ts... { using Ts::operator()...; }; + template overloaded(Ts...)->overloaded; + } + + UInt32 SpirvExpressionLoad::Evaluate(ShaderNodes::Expression& node) + { + node.Visit(*this); + + return std::visit(overloaded + { + [&](const Pointer& pointer) -> UInt32 + { + UInt32 resultId = m_writer.AllocateResultId(); + + m_writer.GetInstructions().Append(SpirvOp::OpLoad, pointer.pointedTypeId, resultId, pointer.resultId); + + return resultId; + }, + [&](const Value& value) -> UInt32 + { + return value.resultId; + }, + [this](std::monostate) -> UInt32 + { + throw std::runtime_error("an internal error occurred"); + } + }, m_value); + } + void SpirvExpressionLoad::Visit(ShaderNodes::AccessMember& node) { - SpirvExpressionLoadAccessMember accessMemberVisitor(m_writer); - PushResultId(accessMemberVisitor.EvaluateExpression(node)); - } + Visit(node.structExpr); - void SpirvExpressionLoad::Visit(ShaderNodes::AssignOp& node) - { - SpirvExpressionLoad loadVisitor(m_writer); - SpirvExpressionStore storeVisitor(m_writer); - storeVisitor.Store(node.left, EvaluateExpression(node.right)); - } - - void SpirvExpressionLoad::Visit(ShaderNodes::BinaryOp& node) - { - ShaderExpressionType resultExprType = node.GetExpressionType(); - assert(std::holds_alternative(resultExprType)); - - const ShaderExpressionType& leftExprType = node.left->GetExpressionType(); - assert(std::holds_alternative(leftExprType)); - - const ShaderExpressionType& rightExprType = node.right->GetExpressionType(); - assert(std::holds_alternative(rightExprType)); - - ShaderNodes::BasicType resultType = std::get(resultExprType); - ShaderNodes::BasicType leftType = std::get(leftExprType); - ShaderNodes::BasicType rightType = std::get(rightExprType); - - - UInt32 leftOperand = EvaluateExpression(node.left); - UInt32 rightOperand = EvaluateExpression(node.right); - UInt32 resultId = m_writer.AllocateResultId(); - - bool swapOperands = false; - - SpirvOp op = [&] + std::visit(overloaded { - switch (node.op) + [&](const Pointer& pointer) { - case ShaderNodes::BinaryType::Add: + UInt32 resultId = m_writer.AllocateResultId(); + UInt32 pointerType = m_writer.RegisterPointerType(node.exprType, pointer.storage); //< FIXME + UInt32 typeId = m_writer.GetTypeId(node.exprType); + + m_writer.GetInstructions().AppendVariadic(SpirvOp::OpAccessChain, [&](const auto& appender) { - switch (leftType) - { - case ShaderNodes::BasicType::Float1: - case ShaderNodes::BasicType::Float2: - case ShaderNodes::BasicType::Float3: - case ShaderNodes::BasicType::Float4: - case ShaderNodes::BasicType::Mat4x4: - return SpirvOp::OpFAdd; + appender(pointerType); + appender(resultId); + appender(pointer.resultId); - case ShaderNodes::BasicType::Int1: - case ShaderNodes::BasicType::Int2: - case ShaderNodes::BasicType::Int3: - case ShaderNodes::BasicType::Int4: - case ShaderNodes::BasicType::UInt1: - case ShaderNodes::BasicType::UInt2: - case ShaderNodes::BasicType::UInt3: - case ShaderNodes::BasicType::UInt4: - return SpirvOp::OpIAdd; + for (std::size_t index : node.memberIndices) + appender(m_writer.GetConstantId(Int32(index))); + }); - case ShaderNodes::BasicType::Boolean: - case ShaderNodes::BasicType::Sampler2D: - case ShaderNodes::BasicType::Void: - break; - } - } + m_value = Pointer { pointer.storage, resultId, typeId }; + }, + [&](const Value& value) + { + UInt32 resultId = m_writer.AllocateResultId(); + UInt32 typeId = m_writer.GetTypeId(node.exprType); - case ShaderNodes::BinaryType::Substract: + m_writer.GetInstructions().AppendVariadic(SpirvOp::OpCompositeExtract, [&](const auto& appender) { - switch (leftType) - { - case ShaderNodes::BasicType::Float1: - case ShaderNodes::BasicType::Float2: - case ShaderNodes::BasicType::Float3: - case ShaderNodes::BasicType::Float4: - case ShaderNodes::BasicType::Mat4x4: - return SpirvOp::OpFSub; + appender(typeId); + appender(resultId); + appender(value.resultId); - case ShaderNodes::BasicType::Int1: - case ShaderNodes::BasicType::Int2: - case ShaderNodes::BasicType::Int3: - case ShaderNodes::BasicType::Int4: - case ShaderNodes::BasicType::UInt1: - case ShaderNodes::BasicType::UInt2: - case ShaderNodes::BasicType::UInt3: - case ShaderNodes::BasicType::UInt4: - return SpirvOp::OpISub; + for (std::size_t index : node.memberIndices) + appender(m_writer.GetConstantId(Int32(index))); + }); - case ShaderNodes::BasicType::Boolean: - case ShaderNodes::BasicType::Sampler2D: - case ShaderNodes::BasicType::Void: - break; - } - } - - case ShaderNodes::BinaryType::Divide: - { - switch (leftType) - { - case ShaderNodes::BasicType::Float1: - case ShaderNodes::BasicType::Float2: - case ShaderNodes::BasicType::Float3: - case ShaderNodes::BasicType::Float4: - case ShaderNodes::BasicType::Mat4x4: - return SpirvOp::OpFDiv; - - case ShaderNodes::BasicType::Int1: - case ShaderNodes::BasicType::Int2: - case ShaderNodes::BasicType::Int3: - case ShaderNodes::BasicType::Int4: - return SpirvOp::OpSDiv; - - case ShaderNodes::BasicType::UInt1: - case ShaderNodes::BasicType::UInt2: - case ShaderNodes::BasicType::UInt3: - case ShaderNodes::BasicType::UInt4: - return SpirvOp::OpUDiv; - - case ShaderNodes::BasicType::Boolean: - case ShaderNodes::BasicType::Sampler2D: - case ShaderNodes::BasicType::Void: - break; - } - } - - case ShaderNodes::BinaryType::Equality: - { - switch (leftType) - { - case ShaderNodes::BasicType::Boolean: - return SpirvOp::OpLogicalEqual; - - case ShaderNodes::BasicType::Float1: - case ShaderNodes::BasicType::Float2: - case ShaderNodes::BasicType::Float3: - case ShaderNodes::BasicType::Float4: - case ShaderNodes::BasicType::Mat4x4: - return SpirvOp::OpFOrdEqual; - - case ShaderNodes::BasicType::Int1: - case ShaderNodes::BasicType::Int2: - case ShaderNodes::BasicType::Int3: - case ShaderNodes::BasicType::Int4: - case ShaderNodes::BasicType::UInt1: - case ShaderNodes::BasicType::UInt2: - case ShaderNodes::BasicType::UInt3: - case ShaderNodes::BasicType::UInt4: - return SpirvOp::OpIEqual; - - case ShaderNodes::BasicType::Sampler2D: - case ShaderNodes::BasicType::Void: - break; - } - } - - case ShaderNodes::BinaryType::Multiply: - { - switch (leftType) - { - case ShaderNodes::BasicType::Float1: - { - switch (rightType) - { - case ShaderNodes::BasicType::Float1: - return SpirvOp::OpFMul; - - case ShaderNodes::BasicType::Float2: - case ShaderNodes::BasicType::Float3: - case ShaderNodes::BasicType::Float4: - swapOperands = true; - return SpirvOp::OpVectorTimesScalar; - - case ShaderNodes::BasicType::Mat4x4: - swapOperands = true; - return SpirvOp::OpMatrixTimesScalar; - - default: - break; - } - - break; - } - - case ShaderNodes::BasicType::Float2: - case ShaderNodes::BasicType::Float3: - case ShaderNodes::BasicType::Float4: - { - switch (rightType) - { - case ShaderNodes::BasicType::Float1: - return SpirvOp::OpVectorTimesScalar; - - case ShaderNodes::BasicType::Float2: - case ShaderNodes::BasicType::Float3: - case ShaderNodes::BasicType::Float4: - return SpirvOp::OpFMul; - - case ShaderNodes::BasicType::Mat4x4: - return SpirvOp::OpVectorTimesMatrix; - - default: - break; - } - - break; - } - - case ShaderNodes::BasicType::Int1: - case ShaderNodes::BasicType::Int2: - case ShaderNodes::BasicType::Int3: - case ShaderNodes::BasicType::Int4: - case ShaderNodes::BasicType::UInt1: - case ShaderNodes::BasicType::UInt2: - case ShaderNodes::BasicType::UInt3: - case ShaderNodes::BasicType::UInt4: - return SpirvOp::OpIMul; - - case ShaderNodes::BasicType::Mat4x4: - { - switch (rightType) - { - case ShaderNodes::BasicType::Float1: return SpirvOp::OpMatrixTimesScalar; - case ShaderNodes::BasicType::Float4: return SpirvOp::OpMatrixTimesVector; - case ShaderNodes::BasicType::Mat4x4: return SpirvOp::OpMatrixTimesMatrix; - - default: - break; - } - - break; - } - - default: - break; - } - break; - } + m_value = Value { resultId }; + }, + [this](std::monostate) + { + throw std::runtime_error("an internal error occurred"); } - - assert(false); - throw std::runtime_error("unexpected binary operation"); - }(); - - if (swapOperands) - std::swap(leftOperand, rightOperand); - - m_writer.GetInstructions().Append(op, m_writer.GetTypeId(resultType), resultId, leftOperand, rightOperand); - PushResultId(resultId); - } - - void SpirvExpressionLoad::Visit(ShaderNodes::Cast& node) - { - const ShaderExpressionType& targetExprType = node.exprType; - assert(std::holds_alternative(targetExprType)); - - ShaderNodes::BasicType targetType = std::get(targetExprType); - - StackVector exprResults = NazaraStackVector(UInt32, node.expressions.size()); - - for (const auto& exprPtr : node.expressions) - { - if (!exprPtr) - break; - - exprResults.push_back(EvaluateExpression(exprPtr)); - } - - UInt32 resultId = m_writer.AllocateResultId(); - - m_writer.GetInstructions().AppendVariadic(SpirvOp::OpCompositeConstruct, [&](const auto& appender) - { - appender(m_writer.GetTypeId(targetType)); - appender(resultId); - - for (UInt32 exprResultId : exprResults) - appender(exprResultId); - }); - - PushResultId(resultId); - } - - void SpirvExpressionLoad::Visit(ShaderNodes::Constant& node) - { - std::visit([&] (const auto& value) - { - PushResultId(m_writer.GetConstantId(value)); - }, node.value); - } - - void SpirvExpressionLoad::Visit(ShaderNodes::DeclareVariable& node) - { - if (node.expression) - { - assert(node.variable->GetType() == ShaderNodes::VariableType::LocalVariable); - - const auto& localVar = static_cast(*node.variable); - m_writer.WriteLocalVariable(localVar.name, EvaluateExpression(node.expression)); - } - } - - void SpirvExpressionLoad::Visit(ShaderNodes::ExpressionStatement& node) - { - Visit(node.expression); - PopResultId(); + }, m_value); } void SpirvExpressionLoad::Visit(ShaderNodes::Identifier& node) @@ -323,126 +94,28 @@ namespace Nz Visit(node.var); } - void SpirvExpressionLoad::Visit(ShaderNodes::IntrinsicCall& node) - { - switch (node.intrinsic) - { - case ShaderNodes::IntrinsicType::DotProduct: - { - const ShaderExpressionType& vecExprType = node.parameters[0]->GetExpressionType(); - assert(std::holds_alternative(vecExprType)); - - ShaderNodes::BasicType vecType = std::get(vecExprType); - - UInt32 typeId = m_writer.GetTypeId(node.GetComponentType(vecType)); - - UInt32 vec1 = EvaluateExpression(node.parameters[0]); - UInt32 vec2 = EvaluateExpression(node.parameters[1]); - - UInt32 resultId = m_writer.AllocateResultId(); - - m_writer.GetInstructions().Append(SpirvOp::OpDot, typeId, resultId, vec1, vec2); - PushResultId(resultId); - break; - } - - case ShaderNodes::IntrinsicType::CrossProduct: - default: - throw std::runtime_error("not yet implemented"); - } - } - - void SpirvExpressionLoad::Visit(ShaderNodes::Sample2D& node) - { - UInt32 typeId = m_writer.GetTypeId(ShaderNodes::BasicType::Float4); - - UInt32 samplerId = EvaluateExpression(node.sampler); - UInt32 coordinatesId = EvaluateExpression(node.coordinates); - UInt32 resultId = m_writer.AllocateResultId(); - - m_writer.GetInstructions().Append(SpirvOp::OpImageSampleImplicitLod, typeId, resultId, samplerId, coordinatesId); - PushResultId(resultId); - } - - void SpirvExpressionLoad::Visit(ShaderNodes::SwizzleOp& node) - { - const ShaderExpressionType& targetExprType = node.GetExpressionType(); - assert(std::holds_alternative(targetExprType)); - - ShaderNodes::BasicType targetType = std::get(targetExprType); - - UInt32 exprResultId = EvaluateExpression(node.expression); - UInt32 resultId = m_writer.AllocateResultId(); - - if (node.componentCount > 1) - { - // Swizzling is implemented via SpirvOp::OpVectorShuffle using the same vector twice as operands - m_writer.GetInstructions().AppendVariadic(SpirvOp::OpVectorShuffle, [&](const auto& appender) - { - appender(m_writer.GetTypeId(targetType)); - appender(resultId); - appender(exprResultId); - appender(exprResultId); - - for (std::size_t i = 0; i < node.componentCount; ++i) - appender(UInt32(node.components[0]) - UInt32(node.components[i])); - }); - } - else - { - // Extract a single component from the vector - assert(node.componentCount == 1); - - m_writer.GetInstructions().Append(SpirvOp::OpCompositeExtract, m_writer.GetTypeId(targetType), resultId, exprResultId, UInt32(node.components[0]) - UInt32(ShaderNodes::SwizzleComponent::First) ); - } - - PushResultId(resultId); - } - - void SpirvExpressionLoad::Visit(ShaderNodes::BuiltinVariable& /*var*/) - { - throw std::runtime_error("not implemented yet"); - } - void SpirvExpressionLoad::Visit(ShaderNodes::InputVariable& var) { - PushResultId(m_writer.ReadInputVariable(var.name)); + auto inputVar = m_writer.GetInputVariable(var.name); + + if (auto resultIdOpt = m_writer.ReadVariable(inputVar, SpirvWriter::OnlyCache{})) + m_value = Value{ *resultIdOpt }; + else + m_value = Pointer{ SpirvStorageClass::Input, inputVar.varId, inputVar.typeId }; } void SpirvExpressionLoad::Visit(ShaderNodes::LocalVariable& var) { - PushResultId(m_writer.ReadLocalVariable(var.name)); - } - - void SpirvExpressionLoad::Visit(ShaderNodes::ParameterVariable& /*var*/) - { - throw std::runtime_error("not implemented yet"); + m_value = Value{ m_writer.ReadLocalVariable(var.name) }; } void SpirvExpressionLoad::Visit(ShaderNodes::UniformVariable& var) { - PushResultId(m_writer.ReadUniformVariable(var.name)); - } + auto uniformVar = m_writer.GetUniformVariable(var.name); - UInt32 SpirvExpressionLoad::EvaluateExpression(const ShaderNodes::ExpressionPtr& expr) - { - Visit(expr); - return PopResultId(); - } - - void SpirvExpressionLoad::PushResultId(UInt32 value) - { - m_resultIds.push_back(value); - } - - UInt32 SpirvExpressionLoad::PopResultId() - { - if (m_resultIds.empty()) - throw std::runtime_error("invalid operation"); - - UInt32 resultId = m_resultIds.back(); - m_resultIds.pop_back(); - - return resultId; + if (auto resultIdOpt = m_writer.ReadVariable(uniformVar, SpirvWriter::OnlyCache{})) + m_value = Value{ *resultIdOpt }; + else + m_value = Pointer{ SpirvStorageClass::Uniform, uniformVar.varId, uniformVar.typeId }; } } diff --git a/src/Nazara/Shader/SpirvExpressionLoadAccessMember.cpp b/src/Nazara/Shader/SpirvExpressionLoadAccessMember.cpp deleted file mode 100644 index c59bd806d..000000000 --- a/src/Nazara/Shader/SpirvExpressionLoadAccessMember.cpp +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - Shader generator" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include - -namespace Nz -{ - namespace - { - template struct overloaded : Ts... { using Ts::operator()...; }; - template overloaded(Ts...)->overloaded; - } - - UInt32 SpirvExpressionLoadAccessMember::EvaluateExpression(ShaderNodes::AccessMember& expr) - { - Visit(expr); - - return std::visit(overloaded - { - [&](const Pointer& pointer) -> UInt32 - { - UInt32 resultId = m_writer.AllocateResultId(); - - m_writer.GetInstructions().Append(SpirvOp::OpLoad, pointer.pointedTypeId, resultId, pointer.resultId); - - return resultId; - }, - [&](const Value& value) -> UInt32 - { - return value.resultId; - }, - [this](std::monostate) -> UInt32 - { - throw std::runtime_error("an internal error occurred"); - } - }, m_value); - } - - void SpirvExpressionLoadAccessMember::Visit(ShaderNodes::AccessMember& node) - { - Visit(node.structExpr); - - std::visit(overloaded - { - [&](const Pointer& pointer) - { - UInt32 resultId = m_writer.AllocateResultId(); - UInt32 pointerType = m_writer.RegisterPointerType(node.exprType, pointer.storage); //< FIXME - UInt32 typeId = m_writer.GetTypeId(node.exprType); - - m_writer.GetInstructions().AppendVariadic(SpirvOp::OpAccessChain, [&](const auto& appender) - { - appender(pointerType); - appender(resultId); - appender(pointer.resultId); - - for (std::size_t index : node.memberIndices) - appender(m_writer.GetConstantId(Int32(index))); - }); - - m_value = Pointer { pointer.storage, resultId, typeId }; - }, - [&](const Value& value) - { - UInt32 resultId = m_writer.AllocateResultId(); - UInt32 typeId = m_writer.GetTypeId(node.exprType); - - m_writer.GetInstructions().AppendVariadic(SpirvOp::OpCompositeExtract, [&](const auto& appender) - { - appender(typeId); - appender(resultId); - appender(value.resultId); - - for (std::size_t index : node.memberIndices) - appender(m_writer.GetConstantId(Int32(index))); - }); - - m_value = Value { resultId }; - }, - [this](std::monostate) - { - throw std::runtime_error("an internal error occurred"); - } - }, m_value); - } - - void SpirvExpressionLoadAccessMember::Visit(ShaderNodes::Identifier& node) - { - Visit(node.var); - } - - void SpirvExpressionLoadAccessMember::Visit(ShaderNodes::InputVariable& var) - { - auto inputVar = m_writer.GetInputVariable(var.name); - - if (auto resultIdOpt = m_writer.ReadVariable(inputVar, SpirvWriter::OnlyCache{})) - m_value = Value{ *resultIdOpt }; - else - m_value = Pointer{ SpirvStorageClass::Input, inputVar.varId, inputVar.typeId }; - } - - void SpirvExpressionLoadAccessMember::Visit(ShaderNodes::UniformVariable& var) - { - auto uniformVar = m_writer.GetUniformVariable(var.name); - - if (auto resultIdOpt = m_writer.ReadVariable(uniformVar, SpirvWriter::OnlyCache{})) - m_value = Value{ *resultIdOpt }; - else - m_value = Pointer{ SpirvStorageClass::Uniform, uniformVar.varId, uniformVar.typeId }; - } -} diff --git a/src/Nazara/Shader/SpirvStatementVisitor.cpp b/src/Nazara/Shader/SpirvStatementVisitor.cpp deleted file mode 100644 index 312879375..000000000 --- a/src/Nazara/Shader/SpirvStatementVisitor.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2020 Jérôme Leclercq -// This file is part of the "Nazara Engine - Shader generator" -// For conditions of distribution and use, see copyright notice in Config.hpp - -#include -#include -#include -#include -#include - -namespace Nz -{ - void SpirvStatementVisitor::Visit(ShaderNodes::AssignOp& node) - { - SpirvExpressionLoad loadVisitor(m_writer); - SpirvExpressionStore storeVisitor(m_writer); - storeVisitor.Store(node.left, loadVisitor.EvaluateExpression(node.right)); - } - - void SpirvStatementVisitor::Visit(ShaderNodes::Branch& node) - { - throw std::runtime_error("not yet implemented"); - } - - void SpirvStatementVisitor::Visit(ShaderNodes::DeclareVariable& node) - { - if (node.expression) - { - assert(node.variable->GetType() == ShaderNodes::VariableType::LocalVariable); - - const auto& localVar = static_cast(*node.variable); - - SpirvExpressionLoad loadVisitor(m_writer); - m_writer.WriteLocalVariable(localVar.name, loadVisitor.EvaluateExpression(node.expression)); - } - } - - void SpirvStatementVisitor::Visit(ShaderNodes::ExpressionStatement& node) - { - SpirvExpressionLoad loadVisitor(m_writer); - loadVisitor.Visit(node.expression); - } - - void SpirvStatementVisitor::Visit(ShaderNodes::StatementBlock& node) - { - for (auto& statement : node.statements) - Visit(statement); - } -} diff --git a/src/Nazara/Shader/SpirvWriter.cpp b/src/Nazara/Shader/SpirvWriter.cpp index 8412a1491..81f9d1d7f 100644 --- a/src/Nazara/Shader/SpirvWriter.cpp +++ b/src/Nazara/Shader/SpirvWriter.cpp @@ -7,10 +7,10 @@ #include #include #include +#include #include #include #include -#include #include #include #include @@ -380,7 +380,7 @@ namespace Nz state.instructions.Append(SpirvOp::OpFunctionParameter, GetTypeId(param.type), paramResultId); } - SpirvStatementVisitor visitor(*this); + SpirvAstVisitor visitor(*this); visitor.Visit(functionStatements[funcIndex]); if (func.returnType == ShaderNodes::BasicType::Void) From ba777ebbcac9dfad05e3511e4ee38a8ff440ee64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Mon, 24 Aug 2020 16:49:14 +0200 Subject: [PATCH 308/316] Shader/SpirvPrinter: Add settings --- include/Nazara/Shader/SpirvPrinter.hpp | 10 +- src/Nazara/Shader/SpirvPrinter.cpp | 259 +++++++++++++------------ 2 files changed, 146 insertions(+), 123 deletions(-) diff --git a/include/Nazara/Shader/SpirvPrinter.hpp b/include/Nazara/Shader/SpirvPrinter.hpp index b3e359fb5..101a49437 100644 --- a/include/Nazara/Shader/SpirvPrinter.hpp +++ b/include/Nazara/Shader/SpirvPrinter.hpp @@ -16,16 +16,24 @@ namespace Nz class NAZARA_SHADER_API SpirvPrinter { public: + struct Settings; + inline SpirvPrinter(); SpirvPrinter(const SpirvPrinter&) = default; SpirvPrinter(SpirvPrinter&&) = default; ~SpirvPrinter() = default; - std::string Print(const UInt32* codepoints, std::size_t count); + std::string Print(const UInt32* codepoints, std::size_t count, const Settings& settings = Settings()); SpirvPrinter& operator=(const SpirvPrinter&) = default; SpirvPrinter& operator=(SpirvPrinter&&) = default; + struct Settings + { + bool printHeader = true; + bool printParameters = true; + }; + private: void AppendInstruction(); std::string ReadString(); diff --git a/src/Nazara/Shader/SpirvPrinter.cpp b/src/Nazara/Shader/SpirvPrinter.cpp index 4b21ed840..964baf129 100644 --- a/src/Nazara/Shader/SpirvPrinter.cpp +++ b/src/Nazara/Shader/SpirvPrinter.cpp @@ -19,13 +19,18 @@ namespace Nz std::size_t index = 0; std::size_t count; std::ostringstream stream; + const Settings& settings; }; - std::string SpirvPrinter::Print(const UInt32* codepoints, std::size_t count) + std::string SpirvPrinter::Print(const UInt32* codepoints, std::size_t count, const Settings& settings) { - State state; - state.codepoints = codepoints; - state.count = count; + State state = { + codepoints, + 0, + count, + {}, + settings + }; m_currentState = &state; CallOnExit resetOnExit([&] { m_currentState = nullptr; }); @@ -34,7 +39,8 @@ namespace Nz if (magicNumber != SpvMagicNumber) throw std::runtime_error("invalid Spir-V: magic number didn't match"); - m_currentState->stream << "Spir-V module\n"; + if (m_currentState->settings.printHeader) + m_currentState->stream << "Spir-V module\n"; UInt32 versionNumber = ReadWord(); if (versionNumber > SpvVersion) @@ -43,17 +49,17 @@ namespace Nz UInt8 majorVersion = ((versionNumber) >> 16) & 0xFF; UInt8 minorVersion = ((versionNumber) >> 8) & 0xFF; - m_currentState->stream << "Version " + std::to_string(+majorVersion) << "." << std::to_string(+minorVersion) << "\n"; - UInt32 generatorId = ReadWord(); - - m_currentState->stream << "Generator: " << std::to_string(generatorId) << "\n"; - UInt32 bound = ReadWord(); - m_currentState->stream << "Bound: " << std::to_string(bound) << "\n"; - UInt32 schema = ReadWord(); - m_currentState->stream << "Schema: " << std::to_string(schema) << "\n"; + + if (m_currentState->settings.printHeader) + { + m_currentState->stream << "Version " + std::to_string(+majorVersion) << "." << std::to_string(+minorVersion) << "\n"; + m_currentState->stream << "Generator: " << std::to_string(generatorId) << "\n"; + m_currentState->stream << "Bound: " << std::to_string(bound) << "\n"; + m_currentState->stream << "Schema: " << std::to_string(schema) << "\n"; + } while (m_currentState->index < m_currentState->count) AppendInstruction(); @@ -76,126 +82,135 @@ namespace Nz m_currentState->stream << inst->name; - std::size_t currentOperand = 0; - std::size_t instructionEnd = startIndex + wordCount; - while (m_currentState->index < instructionEnd) + if (m_currentState->settings.printParameters) { - const SpirvInstruction::Operand* operand = &inst->operands[currentOperand]; - - m_currentState->stream << " " << operand->name << "("; - - switch (operand->kind) + std::size_t currentOperand = 0; + std::size_t instructionEnd = startIndex + wordCount; + while (m_currentState->index < instructionEnd) { - case SpirvOperandKind::ImageOperands: - case SpirvOperandKind::FPFastMathMode: - case SpirvOperandKind::SelectionControl: - case SpirvOperandKind::LoopControl: - case SpirvOperandKind::FunctionControl: - case SpirvOperandKind::MemorySemantics: - case SpirvOperandKind::MemoryAccess: - case SpirvOperandKind::KernelProfilingInfo: - case SpirvOperandKind::RayFlags: - case SpirvOperandKind::SourceLanguage: - case SpirvOperandKind::ExecutionModel: - case SpirvOperandKind::AddressingModel: - case SpirvOperandKind::MemoryModel: - case SpirvOperandKind::ExecutionMode: - case SpirvOperandKind::StorageClass: - case SpirvOperandKind::Dim: - case SpirvOperandKind::SamplerAddressingMode: - case SpirvOperandKind::SamplerFilterMode: - case SpirvOperandKind::ImageFormat: - case SpirvOperandKind::ImageChannelOrder: - case SpirvOperandKind::ImageChannelDataType: - case SpirvOperandKind::FPRoundingMode: - case SpirvOperandKind::LinkageType: - case SpirvOperandKind::AccessQualifier: - case SpirvOperandKind::FunctionParameterAttribute: - case SpirvOperandKind::Decoration: - case SpirvOperandKind::BuiltIn: - case SpirvOperandKind::Scope: - case SpirvOperandKind::GroupOperation: - case SpirvOperandKind::KernelEnqueueFlags: - case SpirvOperandKind::Capability: - case SpirvOperandKind::RayQueryIntersection: - case SpirvOperandKind::RayQueryCommittedIntersectionType: - case SpirvOperandKind::RayQueryCandidateIntersectionType: - case SpirvOperandKind::IdResultType: - case SpirvOperandKind::IdResult: - case SpirvOperandKind::IdMemorySemantics: - case SpirvOperandKind::IdScope: - case SpirvOperandKind::IdRef: - case SpirvOperandKind::LiteralInteger: - case SpirvOperandKind::LiteralExtInstInteger: - case SpirvOperandKind::LiteralSpecConstantOpInteger: - case SpirvOperandKind::LiteralContextDependentNumber: //< FIXME + const SpirvInstruction::Operand* operand = &inst->operands[currentOperand]; + + m_currentState->stream << " " << operand->name << "("; + + switch (operand->kind) { - UInt32 value = ReadWord(); - m_currentState->stream << value; - break; - } - - case SpirvOperandKind::LiteralString: - { - std::string str = ReadString(); - m_currentState->stream << "\"" << str << "\""; - - /* - std::size_t offset = GetOutputOffset(); - - std::size_t size4 = CountWord(str); - for (std::size_t i = 0; i < size4; ++i) + case SpirvOperandKind::ImageOperands: + case SpirvOperandKind::FPFastMathMode: + case SpirvOperandKind::SelectionControl: + case SpirvOperandKind::LoopControl: + case SpirvOperandKind::FunctionControl: + case SpirvOperandKind::MemorySemantics: + case SpirvOperandKind::MemoryAccess: + case SpirvOperandKind::KernelProfilingInfo: + case SpirvOperandKind::RayFlags: + case SpirvOperandKind::SourceLanguage: + case SpirvOperandKind::ExecutionModel: + case SpirvOperandKind::AddressingModel: + case SpirvOperandKind::MemoryModel: + case SpirvOperandKind::ExecutionMode: + case SpirvOperandKind::StorageClass: + case SpirvOperandKind::Dim: + case SpirvOperandKind::SamplerAddressingMode: + case SpirvOperandKind::SamplerFilterMode: + case SpirvOperandKind::ImageFormat: + case SpirvOperandKind::ImageChannelOrder: + case SpirvOperandKind::ImageChannelDataType: + case SpirvOperandKind::FPRoundingMode: + case SpirvOperandKind::LinkageType: + case SpirvOperandKind::AccessQualifier: + case SpirvOperandKind::FunctionParameterAttribute: + case SpirvOperandKind::Decoration: + case SpirvOperandKind::BuiltIn: + case SpirvOperandKind::Scope: + case SpirvOperandKind::GroupOperation: + case SpirvOperandKind::KernelEnqueueFlags: + case SpirvOperandKind::Capability: + case SpirvOperandKind::RayQueryIntersection: + case SpirvOperandKind::RayQueryCommittedIntersectionType: + case SpirvOperandKind::RayQueryCandidateIntersectionType: + case SpirvOperandKind::IdResultType: + case SpirvOperandKind::IdResult: + case SpirvOperandKind::IdMemorySemantics: + case SpirvOperandKind::IdScope: + case SpirvOperandKind::IdRef: + case SpirvOperandKind::LiteralInteger: + case SpirvOperandKind::LiteralExtInstInteger: + case SpirvOperandKind::LiteralSpecConstantOpInteger: + case SpirvOperandKind::LiteralContextDependentNumber: //< FIXME { - UInt32 codepoint = 0; - for (std::size_t j = 0; j < 4; ++j) - { - std::size_t pos = i * 4 + j; - if (pos < str.size()) - codepoint |= UInt32(str[pos]) << (j * 8); - } - - Append(codepoint); + UInt32 value = ReadWord(); + m_currentState->stream << value; + break; + } + + case SpirvOperandKind::LiteralString: + { + std::string str = ReadString(); + m_currentState->stream << "\"" << str << "\""; + + /* + std::size_t offset = GetOutputOffset(); + + std::size_t size4 = CountWord(str); + for (std::size_t i = 0; i < size4; ++i) + { + UInt32 codepoint = 0; + for (std::size_t j = 0; j < 4; ++j) + { + std::size_t pos = i * 4 + j; + if (pos < str.size()) + codepoint |= UInt32(str[pos]) << (j * 8); + } + + Append(codepoint); + } + */ + break; } - */ - break; - } - case SpirvOperandKind::PairLiteralIntegerIdRef: - { - ReadWord(); - ReadWord(); - break; + case SpirvOperandKind::PairLiteralIntegerIdRef: + { + ReadWord(); + ReadWord(); + break; + } + + case SpirvOperandKind::PairIdRefLiteralInteger: + { + ReadWord(); + ReadWord(); + break; + } + + case SpirvOperandKind::PairIdRefIdRef: + { + ReadWord(); + ReadWord(); + break; + } + + /*case SpirvOperandKind::LiteralContextDependentNumber: + { + throw std::runtime_error("not yet implemented"); + }*/ + + default: + break; + } - case SpirvOperandKind::PairIdRefLiteralInteger: - { - ReadWord(); - ReadWord(); - break; - } - - case SpirvOperandKind::PairIdRefIdRef: - { - ReadWord(); - ReadWord(); - break; - } - - /*case SpirvOperandKind::LiteralContextDependentNumber: - { - throw std::runtime_error("not yet implemented"); - }*/ - - default: - break; + m_currentState->stream << ")"; + if (currentOperand < inst->minOperandCount - 1) + currentOperand++; } - - m_currentState->stream << ")"; - - if (currentOperand < inst->minOperandCount - 1) - currentOperand++; + } + else + { + m_currentState->index += wordCount - 1; + if (m_currentState->index > m_currentState->count) + throw std::runtime_error("unexpected end of stream"); } m_currentState->stream << "\n"; From f5fa211609e1e9833aa515651a0f4869b96a7ca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Mon, 24 Aug 2020 16:49:38 +0200 Subject: [PATCH 309/316] ShaderAstCloner: Fix Swizzle case --- src/Nazara/Shader/ShaderAstCloner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Nazara/Shader/ShaderAstCloner.cpp b/src/Nazara/Shader/ShaderAstCloner.cpp index 39754b7a9..90c7c909d 100644 --- a/src/Nazara/Shader/ShaderAstCloner.cpp +++ b/src/Nazara/Shader/ShaderAstCloner.cpp @@ -140,7 +140,7 @@ namespace Nz void ShaderAstCloner::Visit(ShaderNodes::SwizzleOp& node) { - PushExpression(ShaderNodes::SwizzleOp::Build(PopExpression(), node.components.data(), node.componentCount)); + PushExpression(ShaderNodes::SwizzleOp::Build(CloneExpression(node.expression), node.components.data(), node.componentCount)); } void ShaderAstCloner::Visit(ShaderNodes::BuiltinVariable& var) From 63f259b907f6610c246b0b40b73fa36b5f352b19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Mon, 24 Aug 2020 16:49:59 +0200 Subject: [PATCH 310/316] SpirvAstVisitor: Add safety assert --- src/Nazara/Shader/SpirvAstVisitor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Nazara/Shader/SpirvAstVisitor.cpp b/src/Nazara/Shader/SpirvAstVisitor.cpp index d66f76170..6cf45cee7 100644 --- a/src/Nazara/Shader/SpirvAstVisitor.cpp +++ b/src/Nazara/Shader/SpirvAstVisitor.cpp @@ -15,6 +15,8 @@ namespace Nz UInt32 SpirvAstVisitor::EvaluateExpression(const ShaderNodes::ExpressionPtr& expr) { Visit(expr); + + assert(m_resultIds.size() == 1); return PopResultId(); } From 9b313dac2e5539e34318d9c740fb7bd027508e8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Mon, 24 Aug 2020 17:14:01 +0200 Subject: [PATCH 311/316] Quality of life improvements --- include/Nazara/Shader/ShaderAst.hpp | 6 +++--- include/Nazara/Shader/ShaderNodes.hpp | 1 + include/Nazara/Shader/ShaderNodes.inl | 5 +++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/Nazara/Shader/ShaderAst.hpp b/include/Nazara/Shader/ShaderAst.hpp index 11b39d5e9..6f384c18f 100644 --- a/include/Nazara/Shader/ShaderAst.hpp +++ b/include/Nazara/Shader/ShaderAst.hpp @@ -34,10 +34,10 @@ namespace Nz ~ShaderAst() = default; void AddFunction(std::string name, ShaderNodes::StatementPtr statement, std::vector parameters = {}, ShaderNodes::BasicType returnType = ShaderNodes::BasicType::Void); - void AddInput(std::string name, ShaderExpressionType type, std::optional locationIndex); - void AddOutput(std::string name, ShaderExpressionType type, std::optional locationIndex); + void AddInput(std::string name, ShaderExpressionType type, std::optional locationIndex = {}); + void AddOutput(std::string name, ShaderExpressionType type, std::optional locationIndex = {}); void AddStruct(std::string name, std::vector members); - void AddUniform(std::string name, ShaderExpressionType type, std::optional bindingIndex, std::optional memoryLayout); + void AddUniform(std::string name, ShaderExpressionType type, std::optional bindingIndex = {}, std::optional memoryLayout = {}); inline const Function& GetFunction(std::size_t i) const; inline std::size_t GetFunctionCount() const; diff --git a/include/Nazara/Shader/ShaderNodes.hpp b/include/Nazara/Shader/ShaderNodes.hpp index 15898af3f..b3af5f1aa 100644 --- a/include/Nazara/Shader/ShaderNodes.hpp +++ b/include/Nazara/Shader/ShaderNodes.hpp @@ -241,6 +241,7 @@ namespace Nz std::size_t componentCount; ExpressionPtr expression; + static inline std::shared_ptr Build(ExpressionPtr expressionPtr, SwizzleComponent swizzleComponent); static inline std::shared_ptr Build(ExpressionPtr expressionPtr, std::initializer_list swizzleComponents); static inline std::shared_ptr Build(ExpressionPtr expressionPtr, const SwizzleComponent* components, std::size_t componentCount); }; diff --git a/include/Nazara/Shader/ShaderNodes.inl b/include/Nazara/Shader/ShaderNodes.inl index 77bc813f3..1e0817b62 100644 --- a/include/Nazara/Shader/ShaderNodes.inl +++ b/include/Nazara/Shader/ShaderNodes.inl @@ -284,6 +284,11 @@ namespace Nz::ShaderNodes { } + inline std::shared_ptr SwizzleOp::Build(ExpressionPtr expressionPtr, SwizzleComponent swizzleComponent) + { + return Build(std::move(expressionPtr), { swizzleComponent }); + } + inline std::shared_ptr SwizzleOp::Build(ExpressionPtr expressionPtr, std::initializer_list swizzleComponents) { auto node = std::make_shared(); From f24e48e2dc955dfd0131915e501f76f0773212df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Tue, 25 Aug 2020 12:16:17 +0200 Subject: [PATCH 312/316] Rework build system to handle better external libs --- build/{config.lua => config.lua.default.lua} | 15 ++++ build/scripts/common.lua | 49 +++++++----- build/scripts/tools/shadernodes.lua | 84 ++++++++++++++++---- 3 files changed, 109 insertions(+), 39 deletions(-) rename build/{config.lua => config.lua.default.lua} (57%) diff --git a/build/config.lua b/build/config.lua.default.lua similarity index 57% rename from build/config.lua rename to build/config.lua.default.lua index 16bf08d33..b30566fcb 100644 --- a/build/config.lua +++ b/build/config.lua.default.lua @@ -24,3 +24,18 @@ ServerMode = false -- Builds modules as one united library (useless on POSIX systems) UniteModules = false + +-- Qt5 directories (required for ShaderNodes editor) +--Qt5IncludeDir = [[C:\Projets\Libs\Qt\5.15.0\msvc2019\include]] +--Qt5BinDir_x86 = [[C:\Projets\Libs\Qt\5.15.0\msvc2019\bin]] +--Qt5BinDir_x64 = [[C:\Projets\Libs\Qt\5.15.0\msvc2019_64\bin]] +--Qt5LibDir_x86 = [[C:\Projets\Libs\Qt\5.15.0\msvc2019\lib]] +--Qt5LibDir_x64 = [[C:\Projets\Libs\Qt\5.15.0\msvc2019_64\lib]] + + +-- QtNodes directories (required for ShaderNodes editor) +--QtNodesIncludeDir = [[C:\Projets\Libs\nodeeditor\include]] +--QtNodesBinDir_x86 = [[C:\Projets\Libs\nodeeditor\build32\bin\Release]] +--QtNodesBinDir_x64 = [[C:\Projets\Libs\nodeeditor\build64\bin\Release]] +--QtNodesLibDir_x86 = [[C:\Projets\Libs\nodeeditor\build32\lib\Release]] +--QtNodesLibDir_x64 = [[C:\Projets\Libs\nodeeditor\build64\lib\Release]] \ No newline at end of file diff --git a/build/scripts/common.lua b/build/scripts/common.lua index 1564b9505..1edf10fd3 100644 --- a/build/scripts/common.lua +++ b/build/scripts/common.lua @@ -699,6 +699,24 @@ local PosixOSes = { ["solaris"] = true } +local function ProcessOption(libName, option, enable) + return libName:gsub("%%" .. option .. "%((.+)%)", enable and "%1" or "") +end + +local function HandleLib(infoTable, libName) + local debugDynamic = ProcessOption(ProcessOption(libName, "d", true), "s", false) + local debugStatic = ProcessOption(ProcessOption(libName, "d", true), "s", true) + local releaseStatic = ProcessOption(ProcessOption(libName, "d", false), "s", true) + local releaseDynamic = ProcessOption(ProcessOption(libName, "d", false), "s", false) + + table.insert(infoTable.ConfigurationLibraries.DebugStatic, debugStatic) + table.insert(infoTable.ConfigurationLibraries.ReleaseStatic, releaseStatic) + table.insert(infoTable.ConfigurationLibraries.ReleaseWithDebugStatic, releaseStatic) + table.insert(infoTable.ConfigurationLibraries.DebugDynamic, debugDynamic) + table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, releaseDynamic) + table.insert(infoTable.ConfigurationLibraries.ReleaseWithDebugDynamic, releaseDynamic) +end + function NazaraBuild:Process(infoTable) if (infoTable.Excluded) then return false @@ -718,16 +736,11 @@ function NazaraBuild:Process(infoTable) if (_OPTIONS["united"]) then library = "NazaraEngine" else - library = "Nazara" .. libraryTable.Name + library = "Nazara" .. libraryTable.Name .. "%s(-s)%d(-d)" end if (not self.Config["UniteModules"] or infoTable.Type ~= "Module") then - table.insert(infoTable.ConfigurationLibraries.DebugStatic, library .. "-s-d") - table.insert(infoTable.ConfigurationLibraries.ReleaseStatic, library .. "-s") - table.insert(infoTable.ConfigurationLibraries.ReleaseWithDebugStatic, library .. "-s") - table.insert(infoTable.ConfigurationLibraries.DebugDynamic, library .. "-d") - table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library) - table.insert(infoTable.ConfigurationLibraries.ReleaseWithDebugDynamic, library) + HandleLib(infoTable, library) end elseif (libraryTable.Type == "ExternLib") then library = libraryTable.Name @@ -735,15 +748,10 @@ function NazaraBuild:Process(infoTable) if (self.Config["BuildDependencies"]) then table.insert(libraries, library) else - table.insert(infoTable.ConfigurationLibraries.DebugStatic, library .. "-s-d") - table.insert(infoTable.ConfigurationLibraries.ReleaseStatic, library .. "-s") - table.insert(infoTable.ConfigurationLibraries.ReleaseWithDebugStatic, library .. "-s") - table.insert(infoTable.ConfigurationLibraries.DebugDynamic, library .. "-s-d") - table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library .. "-s") - table.insert(infoTable.ConfigurationLibraries.ReleaseWithDebugDynamic, library .. "-s") + HandleLib(infoTable, library) end elseif (libraryTable.Type == "Tool") then - library = "Nazara" .. libraryTable.Name + library = "Nazara" .. libraryTable.Name .. "%s(-s)%d(-d)" -- Import tools includes for k,v in ipairs(libraryTable.Includes) do @@ -761,19 +769,14 @@ function NazaraBuild:Process(infoTable) end end - table.insert(infoTable.ConfigurationLibraries.DebugStatic, library .. "-s-d") - table.insert(infoTable.ConfigurationLibraries.ReleaseStatic, library .. "-s") - table.insert(infoTable.ConfigurationLibraries.ReleaseWithDebugStatic, library .. "-s") - table.insert(infoTable.ConfigurationLibraries.DebugDynamic, library .. "-d") - table.insert(infoTable.ConfigurationLibraries.ReleaseDynamic, library) - table.insert(infoTable.ConfigurationLibraries.ReleaseWithDebugDynamic, library) + HandleLib(infoTable, library) else infoTable.Excluded = true infoTable.ExcludeReason = "dependency " .. library .. " has invalid type \"" .. libraryTable.Type .. "\"" return false end else - table.insert(libraries, library) + HandleLib(infoTable, library) end end infoTable.Libraries = libraries @@ -881,9 +884,11 @@ function NazaraBuild:PreconfigGenericProject() filter("configurations:*Dynamic") kind("SharedLib") - -- Enable MSVC conformance (not required but better) + -- Enable MSVC conformance (not required but better) and some extra warnings filter("action:vs*") buildoptions({"/permissive-", "/Zc:__cplusplus", "/Zc:referenceBinding", "/Zc:throwingNew"}) + --enablewarnings("4062") -- switch case not handled + buildoptions("/w44062") -- looks like enablewarnings is broken currently for msvc -- Enable SSE math and vectorization optimizations filter({"configurations:Release*", clangGccActions}) diff --git a/build/scripts/tools/shadernodes.lua b/build/scripts/tools/shadernodes.lua index bcf9a1593..cc0b63cb3 100644 --- a/build/scripts/tools/shadernodes.lua +++ b/build/scripts/tools/shadernodes.lua @@ -12,12 +12,7 @@ TOOL.Defines = { TOOL.Includes = { "../include", "../extlibs/include", - "../src", - [[C:\Projets\Libs\Qt\5.15.0\msvc2019_64\include]], - [[C:\Projets\Libs\Qt\5.15.0\msvc2019_64\include\QtCore]], - [[C:\Projets\Libs\Qt\5.15.0\msvc2019_64\include\QtGui]], - [[C:\Projets\Libs\Qt\5.15.0\msvc2019_64\include\QtWidgets]], - [[C:\Projets\Libs\nodeeditor\include]], + "../src" } TOOL.Files = { @@ -27,16 +22,71 @@ TOOL.Files = { } TOOL.Libraries = { - "NazaraCore", - "NazaraShader", - "NazaraUtility", - "Qt5Cored", - "Qt5Guid", - "Qt5Widgetsd", - "nodes" + "NazaraCore%s(-s)%d(-d)", + "NazaraShader%s(-s)%d(-d)", + "NazaraUtility%s(-s)%d(-d)", + "Qt5Core%d(d)", + "Qt5Gui%d(d)", + "Qt5Widgets%d(d)", + "nodes%d(d)" } -TOOL.LibraryPaths.x64 = { - [[C:\Projets\Libs\Qt\5.15.0\msvc2019_64\lib]], - [[C:\Projets\Libs\nodeeditor\build\lib\Debug]] -} +local function AppendValues(tab, value) + if (type(value) == "table") then + for _, v in pairs(value) do + AppendValues(tab, v) + end + else + table.insert(tab, value) + end +end + +function TOOL:ValidateLib(libName) + local config = NazaraBuild:GetConfig() + local includes = config[libName .. "IncludeDir"] + local binDir32 = config[libName .. "BinDir_x86"] + local binDir64 = config[libName .. "BinDir_x64"] + local libDir32 = config[libName .. "LibDir_x86"] + local libDir64 = config[libName .. "LibDir_x64"] + if (not includes) then + return false, "missing " .. libName .. " includes directories in config.lua" + end + + if (not libDir32 and not libDir64) then + return false, "missing " .. libName .. " library search directories in config.lua" + end + + AppendValues(self.Includes, includes) + + if (binDir32) then + AppendValues(self.BinaryPaths.x86, binDir32) + end + + if (binDir64) then + AppendValues(self.BinaryPaths.x64, binDir64) + end + + if (libDir32) then + AppendValues(self.LibraryPaths.x86, libDir32) + end + + if (libDir64) then + AppendValues(self.LibraryPaths.x64, libDir64) + end + + return true +end + +function TOOL:Validate() + local success, err = self:ValidateLib("Qt5") + if (not success) then + return false, err + end + + local success, err = self:ValidateLib("QtNodes") + if (not success) then + return false, err + end + + return true +end \ No newline at end of file From 982d28cace08fad6557efd34bf0727ec371eceed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Tue, 25 Aug 2020 12:34:43 +0200 Subject: [PATCH 313/316] Fix infinite loop --- .../Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.inl | 8 +++++--- .../Nazara/VulkanRenderer/VulkanRenderPipelineLayout.inl | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.inl b/include/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.inl index a5646b1d9..bde85f51c 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.inl +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderPipelineLayout.inl @@ -27,10 +27,12 @@ namespace Nz std::size_t poolCount = m_descriptorPools.size(); if (poolCount >= 2 && m_descriptorPools.back().freeBindings.TestAll()) { - for (std::size_t i = poolCount - 1; i > 0; ++i) + for (std::size_t i = poolCount - 1; i > 0; --i) { - if (m_descriptorPools[i].freeBindings.TestAll()) - poolCount--; + if (!m_descriptorPools[i].freeBindings.TestAll()) + break; + + poolCount--; } m_descriptorPools.resize(poolCount); diff --git a/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.inl b/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.inl index 5dd664b5c..5b341a558 100644 --- a/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.inl +++ b/include/Nazara/VulkanRenderer/VulkanRenderPipelineLayout.inl @@ -27,10 +27,12 @@ namespace Nz std::size_t poolCount = m_descriptorPools.size(); if (poolCount >= 2 && m_descriptorPools.back().freeBindings.TestAll()) { - for (std::size_t i = poolCount - 1; i > 0; ++i) + for (std::size_t i = poolCount - 1; i > 0; --i) { - if (m_descriptorPools[i].freeBindings.TestAll()) - poolCount--; + if (!m_descriptorPools[i].freeBindings.TestAll()) + break; + + poolCount--; } m_descriptorPools.resize(poolCount); From cbdac32f5fcd092a72eb44e765a590749371916b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Thu, 27 Aug 2020 16:16:33 +0200 Subject: [PATCH 314/316] VulkanRenderer: Handle window resize --- build/scripts/tools/openglrenderer.lua | 1 + build/scripts/tools/vulkanrenderer.lua | 1 + examples/VulkanTest/main.cpp | 107 ++++++--- .../OpenGLRenderer/OpenGLRenderWindow.hpp | 9 +- .../Nazara/OpenGLRenderer/OpenGLRenderer.hpp | 2 +- include/Nazara/Renderer/RenderFrame.hpp | 54 +++++ include/Nazara/Renderer/RenderFrame.inl | 32 +++ include/Nazara/Renderer/RenderImage.hpp | 2 +- include/Nazara/Renderer/RenderWindow.hpp | 3 +- include/Nazara/Renderer/RenderWindow.inl | 7 +- include/Nazara/Renderer/RenderWindowImpl.hpp | 6 +- include/Nazara/Renderer/RendererImpl.hpp | 3 +- .../Nazara/VulkanRenderer/VkRenderWindow.hpp | 24 +- .../Nazara/VulkanRenderer/VkRenderWindow.inl | 16 +- .../Nazara/VulkanRenderer/VulkanRenderer.hpp | 2 +- .../VulkanRenderer/Wrapper/Swapchain.hpp | 2 +- .../OpenGLRenderer/OpenGLRenderWindow.cpp | 12 +- src/Nazara/OpenGLRenderer/OpenGLRenderer.cpp | 4 +- src/Nazara/Renderer/RenderFrame.cpp | 44 ++++ src/Nazara/Renderer/RenderWindow.cpp | 4 +- src/Nazara/VulkanRenderer/VkRenderWindow.cpp | 218 +++++++++++++----- src/Nazara/VulkanRenderer/VulkanRenderer.cpp | 4 +- 22 files changed, 420 insertions(+), 137 deletions(-) create mode 100644 include/Nazara/Renderer/RenderFrame.hpp create mode 100644 include/Nazara/Renderer/RenderFrame.inl create mode 100644 src/Nazara/Renderer/RenderFrame.cpp diff --git a/build/scripts/tools/openglrenderer.lua b/build/scripts/tools/openglrenderer.lua index 48b198327..2638de56d 100644 --- a/build/scripts/tools/openglrenderer.lua +++ b/build/scripts/tools/openglrenderer.lua @@ -26,6 +26,7 @@ TOOL.Files = { TOOL.Libraries = { "NazaraCore", + "NazaraPlatform", "NazaraRenderer", "NazaraShader", "NazaraUtility" diff --git a/build/scripts/tools/vulkanrenderer.lua b/build/scripts/tools/vulkanrenderer.lua index 4e7f2be10..5afe3f018 100644 --- a/build/scripts/tools/vulkanrenderer.lua +++ b/build/scripts/tools/vulkanrenderer.lua @@ -27,6 +27,7 @@ TOOL.Files = { TOOL.Libraries = { "NazaraCore", + "NazaraPlatform", "NazaraRenderer", "NazaraShader", "NazaraUtility" diff --git a/examples/VulkanTest/main.cpp b/examples/VulkanTest/main.cpp index 54c34762c..fc235ea8c 100644 --- a/examples/VulkanTest/main.cpp +++ b/examples/VulkanTest/main.cpp @@ -8,7 +8,7 @@ int main() Nz::Initializer loader; if (!loader) { - std::cout << "Failed to initialize Vulkan" << std::endl;; + std::cout << "Failed to initialize Vulkan" << std::endl; return __LINE__; } @@ -172,33 +172,41 @@ int main() Nz::AbstractBuffer* indexBufferImpl = renderBufferIB->GetHardwareBuffer(renderDevice); Nz::AbstractBuffer* vertexBufferImpl = renderBufferVB->GetHardwareBuffer(renderDevice); - std::unique_ptr drawCommandBuffer = commandPool->BuildCommandBuffer([&](Nz::CommandBufferBuilder& builder) + std::unique_ptr drawCommandBuffer; + auto RebuildCommandBuffer = [&] { - Nz::Recti renderRect(0, 0, window.GetSize().x, window.GetSize().y); + Nz::Vector2ui windowSize = window.GetSize(); - Nz::CommandBufferBuilder::ClearValues clearValues[2]; - clearValues[0].color = Nz::Color::Black; - clearValues[1].depth = 1.f; - clearValues[1].stencil = 0; - - builder.BeginDebugRegion("Main window rendering", Nz::Color::Green); + drawCommandBuffer = commandPool->BuildCommandBuffer([&](Nz::CommandBufferBuilder& builder) { - builder.BeginRenderPass(windowImpl->GetFramebuffer(), windowImpl->GetRenderPass(), renderRect, { clearValues[0], clearValues[1] }); + Nz::Recti renderRect(0, 0, window.GetSize().x, window.GetSize().y); + + Nz::CommandBufferBuilder::ClearValues clearValues[2]; + clearValues[0].color = Nz::Color::Black; + clearValues[1].depth = 1.f; + clearValues[1].stencil = 0; + + builder.BeginDebugRegion("Main window rendering", Nz::Color::Green); { - builder.BindIndexBuffer(indexBufferImpl); - builder.BindPipeline(*pipeline); - builder.BindVertexBuffer(0, vertexBufferImpl); - builder.BindShaderBinding(*shaderBinding); + builder.BeginRenderPass(windowImpl->GetFramebuffer(), windowImpl->GetRenderPass(), renderRect, { clearValues[0], clearValues[1] }); + { + builder.BindIndexBuffer(indexBufferImpl); + builder.BindPipeline(*pipeline); + builder.BindVertexBuffer(0, vertexBufferImpl); + builder.BindShaderBinding(*shaderBinding); - builder.SetScissor(Nz::Recti{ 0, 0, int(windowSize.x), int(windowSize.y) }); - builder.SetViewport(Nz::Recti{ 0, 0, int(windowSize.x), int(windowSize.y) }); + builder.SetScissor(Nz::Recti{ 0, 0, int(windowSize.x), int(windowSize.y) }); + builder.SetViewport(Nz::Recti{ 0, 0, int(windowSize.x), int(windowSize.y) }); - builder.DrawIndexed(drfreakIB->GetIndexCount()); + builder.DrawIndexed(drfreakIB->GetIndexCount()); + } + builder.EndRenderPass(); } - builder.EndRenderPass(); - } - builder.EndDebugRegion(); - }); + builder.EndDebugRegion(); + }); + }; + RebuildCommandBuffer(); + Nz::Vector3f viewerPos = Nz::Vector3f::Zero(); @@ -210,6 +218,7 @@ int main() Nz::Clock updateClock; Nz::Clock secondClock; unsigned int fps = 0; + bool uboUpdate = true; Nz::Mouse::SetRelativeMouseMode(true); @@ -236,8 +245,20 @@ int main() camAngles.pitch = Nz::Clamp(camAngles.pitch + event.mouseMove.deltaY*sensitivity, -89.f, 89.f); camQuat = camAngles; + + uboUpdate = true; + break; + + case Nz::WindowEventType_Resized: + { + Nz::Vector2ui windowSize = window.GetSize(); + ubo.projectionMatrix = Nz::Matrix4f::Perspective(70.f, float(windowSize.x) / windowSize.y, 0.1f, 1000.f); + uboUpdate = true; break; } + + default: + break; } } @@ -268,30 +289,44 @@ int main() // Contrôle (Gauche ou droite) pour descendre dans l'espace global, etc... if (Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::LControl) || Nz::Keyboard::IsKeyPressed(Nz::Keyboard::VKey::RControl)) viewerPos += Nz::Vector3f::Down() * cameraSpeed; + + uboUpdate = true; } - Nz::RenderImage& renderImage = windowImpl->Acquire(); + Nz::RenderFrame frame = windowImpl->Acquire(); + if (!frame) + continue; + + if (frame.IsFramebufferInvalidated()) + RebuildCommandBuffer(); ubo.viewMatrix = Nz::Matrix4f::ViewMatrix(viewerPos, camAngles); - auto& allocation = renderImage.GetUploadPool().Allocate(uniformSize); - - std::memcpy(allocation.mappedPtr, &ubo, sizeof(ubo)); - - renderImage.Execute([&](Nz::CommandBufferBuilder& builder) + if (uboUpdate) { - builder.BeginDebugRegion("UBO Update", Nz::Color::Yellow); + auto& allocation = frame.GetUploadPool().Allocate(uniformSize); + + std::memcpy(allocation.mappedPtr, &ubo, sizeof(ubo)); + + frame.Execute([&](Nz::CommandBufferBuilder& builder) { - builder.PreTransferBarrier(); - builder.CopyBuffer(allocation, uniformBuffer.get()); - builder.PostTransferBarrier(); - } - builder.EndDebugRegion(); - }, Nz::QueueType::Transfer); + builder.BeginDebugRegion("UBO Update", Nz::Color::Yellow); + { + builder.PreTransferBarrier(); + builder.CopyBuffer(allocation, uniformBuffer.get()); + builder.PostTransferBarrier(); + } + builder.EndDebugRegion(); + }, Nz::QueueType::Transfer); - renderImage.SubmitCommandBuffer(drawCommandBuffer.get(), Nz::QueueType::Graphics); + uboUpdate = false; + } - renderImage.Present(); + frame.SubmitCommandBuffer(drawCommandBuffer.get(), Nz::QueueType::Graphics); + + frame.Present(); + + window.Display(); // On incrémente le compteur de FPS improvisé fps++; diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp b/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp index ceb7b2489..9031a01d1 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp @@ -20,15 +20,17 @@ namespace Nz { + class RenderWindow; + class NAZARA_OPENGLRENDERER_API OpenGLRenderWindow : public RenderWindowImpl { public: - OpenGLRenderWindow(); + OpenGLRenderWindow(RenderWindow& owner); ~OpenGLRenderWindow() = default; - OpenGLRenderImage& Acquire() override; + RenderFrame Acquire() override; - bool Create(RendererImpl* renderer, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) override; + bool Create(RendererImpl* renderer, RenderSurface* surface, const RenderWindowParameters& parameters) override; std::unique_ptr CreateCommandPool(QueueType queueType) override; inline GL::Context& GetContext(); @@ -46,6 +48,7 @@ namespace Nz std::unique_ptr m_context; OpenGLRenderPass m_renderPass; OpenGLWindowFramebuffer m_framebuffer; + RenderWindow& m_owner; }; } diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderer.hpp b/include/Nazara/OpenGLRenderer/OpenGLRenderer.hpp index 0fefae4de..4fb4b13ed 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLRenderer.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderer.hpp @@ -24,7 +24,7 @@ namespace Nz ~OpenGLRenderer(); std::unique_ptr CreateRenderSurfaceImpl() override; - std::unique_ptr CreateRenderWindowImpl() override; + std::unique_ptr CreateRenderWindowImpl(RenderWindow& owner) override; std::shared_ptr InstanciateRenderDevice(std::size_t deviceIndex) override; diff --git a/include/Nazara/Renderer/RenderFrame.hpp b/include/Nazara/Renderer/RenderFrame.hpp new file mode 100644 index 000000000..1e16bd10c --- /dev/null +++ b/include/Nazara/Renderer/RenderFrame.hpp @@ -0,0 +1,54 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_RENDERFRAME_HPP +#define NAZARA_RENDERFRAME_HPP + +#include +#include +#include +#include + +namespace Nz +{ + class CommandBuffer; + class CommandBufferBuilder; + class RenderImage; + class UploadPool; + + class NAZARA_RENDERER_API RenderFrame + { + public: + inline explicit RenderFrame(); + inline explicit RenderFrame(RenderImage* renderImage, bool framebufferInvalidation); + RenderFrame(const RenderFrame&) = delete; + RenderFrame(RenderFrame&&) = delete; + ~RenderFrame() = default; + + void Execute(const std::function& callback, QueueTypeFlags queueTypeFlags); + + UploadPool& GetUploadPool(); + + inline bool IsFramebufferInvalidated() const; + + void SubmitCommandBuffer(CommandBuffer* commandBuffer, QueueTypeFlags queueTypeFlags) ; + + void Present(); + + inline explicit operator bool(); + + RenderFrame& operator=(const RenderFrame&) = delete; + RenderFrame& operator=(RenderFrame&&) = delete; + + private: + RenderImage* m_image; + bool m_framebufferInvalidation; + }; +} + +#include + +#endif diff --git a/include/Nazara/Renderer/RenderFrame.inl b/include/Nazara/Renderer/RenderFrame.inl new file mode 100644 index 000000000..6a3cd4e19 --- /dev/null +++ b/include/Nazara/Renderer/RenderFrame.inl @@ -0,0 +1,32 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + inline RenderFrame::RenderFrame() : + RenderFrame(nullptr, false) + { + } + + inline RenderFrame::RenderFrame(RenderImage* renderImage, bool framebufferInvalidation) : + m_image(renderImage), + m_framebufferInvalidation(framebufferInvalidation) + { + } + + inline bool RenderFrame::IsFramebufferInvalidated() const + { + return m_framebufferInvalidation; + } + + inline RenderFrame::operator bool() + { + return m_image != nullptr; + } +} + +#include diff --git a/include/Nazara/Renderer/RenderImage.hpp b/include/Nazara/Renderer/RenderImage.hpp index 1ab5310ff..3081ac231 100644 --- a/include/Nazara/Renderer/RenderImage.hpp +++ b/include/Nazara/Renderer/RenderImage.hpp @@ -21,7 +21,6 @@ namespace Nz class NAZARA_RENDERER_API RenderImage { public: - RenderImage() = default; virtual ~RenderImage(); virtual void Execute(const std::function& callback, QueueTypeFlags queueTypeFlags) = 0; @@ -33,6 +32,7 @@ namespace Nz virtual void Present() = 0; protected: + RenderImage() = default; RenderImage(const RenderImage&) = delete; RenderImage(RenderImage&&) = default; }; diff --git a/include/Nazara/Renderer/RenderWindow.hpp b/include/Nazara/Renderer/RenderWindow.hpp index 0d3521a00..6adcf3d66 100644 --- a/include/Nazara/Renderer/RenderWindow.hpp +++ b/include/Nazara/Renderer/RenderWindow.hpp @@ -36,8 +36,9 @@ namespace Nz void EnableVerticalSync(bool enabled); - inline RenderWindowImpl *GetImpl(); + inline RenderWindowImpl* GetImpl(); std::shared_ptr GetRenderDevice(); + inline RenderSurface* GetSurface(); inline bool IsValid() const; diff --git a/include/Nazara/Renderer/RenderWindow.inl b/include/Nazara/Renderer/RenderWindow.inl index 6b868a3b6..95b61dd8b 100644 --- a/include/Nazara/Renderer/RenderWindow.inl +++ b/include/Nazara/Renderer/RenderWindow.inl @@ -46,11 +46,16 @@ namespace Nz return Window::Create(handle); } - inline RenderWindowImpl* Nz::RenderWindow::GetImpl() + inline RenderWindowImpl* RenderWindow::GetImpl() { return m_impl.get(); } + inline RenderSurface* RenderWindow::GetSurface() + { + return m_surface.get(); + } + inline bool RenderWindow::IsValid() const { return m_impl != nullptr; diff --git a/include/Nazara/Renderer/RenderWindowImpl.hpp b/include/Nazara/Renderer/RenderWindowImpl.hpp index eb6736b74..db8a15048 100644 --- a/include/Nazara/Renderer/RenderWindowImpl.hpp +++ b/include/Nazara/Renderer/RenderWindowImpl.hpp @@ -12,6 +12,7 @@ #include #include #include +#include #include namespace Nz @@ -19,7 +20,6 @@ namespace Nz class CommandPool; class Framebuffer; class RendererImpl; - class RenderImage; class RenderPass; class RenderSurface; @@ -29,9 +29,9 @@ namespace Nz RenderWindowImpl() = default; virtual ~RenderWindowImpl(); - virtual RenderImage& Acquire() = 0; + virtual RenderFrame Acquire() = 0; - virtual bool Create(RendererImpl* renderer, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) = 0; + virtual bool Create(RendererImpl* renderer, RenderSurface* surface, const RenderWindowParameters& parameters) = 0; virtual std::unique_ptr CreateCommandPool(QueueType queueType) = 0; virtual const Framebuffer& GetFramebuffer() const = 0; diff --git a/include/Nazara/Renderer/RendererImpl.hpp b/include/Nazara/Renderer/RendererImpl.hpp index 99aefe682..8bff2d8a2 100644 --- a/include/Nazara/Renderer/RendererImpl.hpp +++ b/include/Nazara/Renderer/RendererImpl.hpp @@ -23,6 +23,7 @@ namespace Nz class RendererImpl; class RenderDevice; class RenderSurface; + class RenderWindow; class RenderWindowImpl; using CreateRendererImplFunc = RendererImpl*(*)(); @@ -34,7 +35,7 @@ namespace Nz virtual ~RendererImpl(); virtual std::unique_ptr CreateRenderSurfaceImpl() = 0; - virtual std::unique_ptr CreateRenderWindowImpl() = 0; + virtual std::unique_ptr CreateRenderWindowImpl(RenderWindow& owner) = 0; virtual std::shared_ptr InstanciateRenderDevice(std::size_t deviceIndex) = 0; diff --git a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp index 3df9c1f66..6ad0eaae8 100644 --- a/include/Nazara/VulkanRenderer/VkRenderWindow.hpp +++ b/include/Nazara/VulkanRenderer/VkRenderWindow.hpp @@ -37,24 +37,25 @@ namespace Nz class NAZARA_VULKANRENDERER_API VkRenderWindow : public VkRenderTarget, public RenderWindowImpl { public: - VkRenderWindow(); + VkRenderWindow(RenderWindow& owner); VkRenderWindow(const VkRenderWindow&) = delete; VkRenderWindow(VkRenderWindow&&) = delete; ///TODO ~VkRenderWindow(); - VulkanRenderImage& Acquire() override; + RenderFrame Acquire() override; + + bool Create(RendererImpl* renderer, RenderSurface* surface, const RenderWindowParameters& parameters) override; - bool Create(RendererImpl* renderer, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) override; std::unique_ptr CreateCommandPool(QueueType queueType) override; inline const VulkanMultipleFramebuffer& GetFramebuffer() const override; inline VulkanDevice& GetDevice(); inline const VulkanDevice& GetDevice() const; inline Vk::QueueHandle& GetGraphicsQueue(); - const VulkanRenderPass& GetRenderPass() const override; + inline const VulkanRenderPass& GetRenderPass() const override; inline const Vk::Swapchain& GetSwapchain() const; - std::shared_ptr GetRenderDevice() override; + inline std::shared_ptr GetRenderDevice() override; void Present(UInt32 imageIndex, VkSemaphore waitSemaphore = VK_NULL_HANDLE); @@ -62,17 +63,16 @@ namespace Nz VkRenderWindow& operator=(VkRenderWindow&&) = delete; ///TODO private: + bool CreateSwapchain(Vk::Surface& surface, const Vector2ui& size); bool SetupDepthBuffer(const Vector2ui& size); + bool SetupFrameBuffers(const Vector2ui& size); bool SetupRenderPass(); bool SetupSwapchain(const Vk::PhysicalDevice& deviceInfo, Vk::Surface& surface, const Vector2ui& size); - std::size_t m_currentFrame; - Clock m_clock; - VkFormat m_depthStencilFormat; - VkSurfaceFormatKHR m_surfaceFormat; std::optional m_framebuffer; std::optional m_renderPass; std::shared_ptr m_device; + std::size_t m_currentFrame; std::vector m_inflightFences; std::vector m_concurrentImageData; Vk::DeviceMemory m_depthBufferMemory; @@ -82,6 +82,12 @@ namespace Nz Vk::QueueHandle m_presentQueue; Vk::QueueHandle m_transferQueue; Vk::Swapchain m_swapchain; + Clock m_clock; + RenderWindow& m_owner; + Vector2ui m_swapchainSize; + VkFormat m_depthStencilFormat; + VkSurfaceFormatKHR m_surfaceFormat; + bool m_shouldRecreateSwapchain; }; } diff --git a/include/Nazara/VulkanRenderer/VkRenderWindow.inl b/include/Nazara/VulkanRenderer/VkRenderWindow.inl index dc6cf2206..5daff2463 100644 --- a/include/Nazara/VulkanRenderer/VkRenderWindow.inl +++ b/include/Nazara/VulkanRenderer/VkRenderWindow.inl @@ -27,24 +27,20 @@ namespace Nz return m_graphicsQueue; } + inline const VulkanRenderPass& VkRenderWindow::GetRenderPass() const + { + return *m_renderPass; + } + inline const Vk::Swapchain& VkRenderWindow::GetSwapchain() const { return m_swapchain; } - inline std::shared_ptr Nz::VkRenderWindow::GetRenderDevice() + inline std::shared_ptr VkRenderWindow::GetRenderDevice() { return m_device; } - - inline void VkRenderWindow::Present(UInt32 imageIndex, VkSemaphore waitSemaphore) - { - NazaraAssert(imageIndex < m_inflightFences.size(), "Invalid image index"); - - m_presentQueue.Present(m_swapchain, imageIndex, waitSemaphore); - - m_currentFrame = (m_currentFrame + 1) % m_inflightFences.size(); - } } #include diff --git a/include/Nazara/VulkanRenderer/VulkanRenderer.hpp b/include/Nazara/VulkanRenderer/VulkanRenderer.hpp index 8f6d66160..d0c14c6b5 100644 --- a/include/Nazara/VulkanRenderer/VulkanRenderer.hpp +++ b/include/Nazara/VulkanRenderer/VulkanRenderer.hpp @@ -26,7 +26,7 @@ namespace Nz ~VulkanRenderer(); std::unique_ptr CreateRenderSurfaceImpl() override; - std::unique_ptr CreateRenderWindowImpl() override; + std::unique_ptr CreateRenderWindowImpl(RenderWindow& owner) override; std::shared_ptr InstanciateRenderDevice(std::size_t deviceIndex) override; diff --git a/include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp b/include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp index 399ca909f..2cd24bb5b 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/Swapchain.hpp @@ -38,7 +38,7 @@ namespace Nz inline bool IsSupported() const; Swapchain& operator=(const Swapchain&) = delete; - Swapchain& operator=(Swapchain&&) = delete; + Swapchain& operator=(Swapchain&&) = default; struct Buffer { diff --git a/src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp b/src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp index 6ddb9f5bf..a4eaec923 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp @@ -7,22 +7,24 @@ #include #include #include +#include #include namespace Nz { - OpenGLRenderWindow::OpenGLRenderWindow() : + OpenGLRenderWindow::OpenGLRenderWindow(RenderWindow& owner) : m_currentFrame(0), - m_framebuffer(*this) + m_framebuffer(*this), + m_owner(owner) { } - OpenGLRenderImage& OpenGLRenderWindow::Acquire() + RenderFrame OpenGLRenderWindow::Acquire() { - return m_renderImage[m_currentFrame]; + return RenderFrame(&m_renderImage[m_currentFrame], false); } - bool OpenGLRenderWindow::Create(RendererImpl* renderer, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) + bool OpenGLRenderWindow::Create(RendererImpl* renderer, RenderSurface* surface, const RenderWindowParameters& parameters) { DummySurface* dummySurface = static_cast(surface); OpenGLRenderer* glRenderer = static_cast(renderer); diff --git a/src/Nazara/OpenGLRenderer/OpenGLRenderer.cpp b/src/Nazara/OpenGLRenderer/OpenGLRenderer.cpp index 3d6b6a109..e41eed2e8 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLRenderer.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLRenderer.cpp @@ -31,9 +31,9 @@ namespace Nz return std::make_unique(); } - std::unique_ptr OpenGLRenderer::CreateRenderWindowImpl() + std::unique_ptr OpenGLRenderer::CreateRenderWindowImpl(RenderWindow& owner) { - return std::make_unique(); + return std::make_unique(owner); } std::shared_ptr OpenGLRenderer::InstanciateRenderDevice(std::size_t deviceIndex) diff --git a/src/Nazara/Renderer/RenderFrame.cpp b/src/Nazara/Renderer/RenderFrame.cpp new file mode 100644 index 000000000..485ba2aa1 --- /dev/null +++ b/src/Nazara/Renderer/RenderFrame.cpp @@ -0,0 +1,44 @@ +// Copyright (C) 2020 Jérôme Leclercq +// This file is part of the "Nazara Engine - Renderer module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include +#include +#include + +namespace Nz +{ + void RenderFrame::Execute(const std::function& callback, QueueTypeFlags queueTypeFlags) + { + if (!m_image) + throw std::runtime_error("frame is either invalid or has already been presented"); + + return m_image->Execute(callback, queueTypeFlags); + } + + UploadPool& RenderFrame::GetUploadPool() + { + if (!m_image) + throw std::runtime_error("frame is either invalid or has already been presented"); + + return m_image->GetUploadPool(); + } + + void RenderFrame::SubmitCommandBuffer(CommandBuffer* commandBuffer, QueueTypeFlags queueTypeFlags) + { + if (!m_image) + throw std::runtime_error("frame is either invalid or has already been presented"); + + m_image->SubmitCommandBuffer(commandBuffer, queueTypeFlags); + } + + void RenderFrame::Present() + { + if (!m_image) + throw std::runtime_error("frame is either invalid or has already been presented"); + + m_image->Present(); + m_image = nullptr; + } +} diff --git a/src/Nazara/Renderer/RenderWindow.cpp b/src/Nazara/Renderer/RenderWindow.cpp index a03cf295c..25b04b0dc 100644 --- a/src/Nazara/Renderer/RenderWindow.cpp +++ b/src/Nazara/Renderer/RenderWindow.cpp @@ -46,8 +46,8 @@ namespace Nz return false; } - auto impl = rendererImpl->CreateRenderWindowImpl(); - if (!impl->Create(rendererImpl, surface.get(), GetSize(), m_parameters)) + auto impl = rendererImpl->CreateRenderWindowImpl(*this); + if (!impl->Create(rendererImpl, surface.get(), m_parameters)) { NazaraError("Failed to create render window implementation: " + Error::GetLastError()); return false; diff --git a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp index bfba96bc1..ee83084d7 100644 --- a/src/Nazara/VulkanRenderer/VkRenderWindow.cpp +++ b/src/Nazara/VulkanRenderer/VkRenderWindow.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -18,9 +19,11 @@ namespace Nz { - VkRenderWindow::VkRenderWindow() : + VkRenderWindow::VkRenderWindow(RenderWindow& owner) : m_currentFrame(0), - m_depthStencilFormat(VK_FORMAT_MAX_ENUM) + m_depthStencilFormat(VK_FORMAT_MAX_ENUM), + m_owner(owner), + m_shouldRecreateSwapchain(false) { } @@ -35,8 +38,26 @@ namespace Nz m_swapchain.Destroy(); } - VulkanRenderImage& VkRenderWindow::Acquire() + RenderFrame VkRenderWindow::Acquire() { + bool invalidateFramebuffer = false; + + Vector2ui size = m_owner.GetSize(); + // Special case: window is minimized + if (size == Nz::Vector2ui::Zero() || m_owner.IsMinimized()) + return RenderFrame(); + + if (m_shouldRecreateSwapchain || size != m_swapchainSize) + { + Vk::Surface& vulkanSurface = static_cast(m_owner.GetSurface())->GetSurface(); + + if (!CreateSwapchain(vulkanSurface, size)) + throw std::runtime_error("failed to recreate swapchain"); + + m_shouldRecreateSwapchain = false; + invalidateFramebuffer = true; + } + VulkanRenderImage& currentFrame = m_concurrentImageData[m_currentFrame]; Vk::Fence& inFlightFence = currentFrame.GetInFlightFence(); @@ -44,8 +65,33 @@ namespace Nz inFlightFence.Wait(); UInt32 imageIndex; - if (!m_swapchain.AcquireNextImage(std::numeric_limits::max(), currentFrame.GetImageAvailableSemaphore(), VK_NULL_HANDLE, &imageIndex)) - throw std::runtime_error("Failed to acquire next image: " + TranslateVulkanError(m_swapchain.GetLastErrorCode())); + m_swapchain.AcquireNextImage(std::numeric_limits::max(), currentFrame.GetImageAvailableSemaphore(), VK_NULL_HANDLE, &imageIndex); + + switch (m_swapchain.GetLastErrorCode()) + { + case VK_SUCCESS: + break; + + case VK_SUBOPTIMAL_KHR: + m_shouldRecreateSwapchain = true; //< Recreate swapchain next time + break; + + case VK_ERROR_OUT_OF_DATE_KHR: + m_shouldRecreateSwapchain = true; + return Acquire(); + + // Not expected (since timeout is infinite) + case VK_TIMEOUT: + case VK_NOT_READY: + // Unhandled errors + case VK_ERROR_DEVICE_LOST: + case VK_ERROR_OUT_OF_DEVICE_MEMORY: + case VK_ERROR_OUT_OF_HOST_MEMORY: + case VK_ERROR_SURFACE_LOST_KHR: //< TODO: Handle it by recreating the surface? + case VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT: + default: + throw std::runtime_error("Failed to acquire next image: " + TranslateVulkanError(m_swapchain.GetLastErrorCode())); + } if (m_inflightFences[imageIndex]) m_inflightFences[imageIndex]->Wait(); @@ -55,10 +101,10 @@ namespace Nz currentFrame.Reset(imageIndex); - return currentFrame; + return RenderFrame(¤tFrame, invalidateFramebuffer); } - bool VkRenderWindow::Create(RendererImpl* /*renderer*/, RenderSurface* surface, const Vector2ui& size, const RenderWindowParameters& parameters) + bool VkRenderWindow::Create(RendererImpl* /*renderer*/, RenderSurface* surface, const RenderWindowParameters& parameters) { const auto& deviceInfo = Vulkan::GetPhysicalDevices()[0]; @@ -156,61 +202,18 @@ namespace Nz } } - if (!SetupSwapchain(deviceInfo, vulkanSurface, size)) - { - NazaraError("Failed to create swapchain"); - return false; - } - - if (m_depthStencilFormat != VK_FORMAT_MAX_ENUM && !SetupDepthBuffer(size)) - { - NazaraError("Failed to create depth buffer"); - return false; - } - if (!SetupRenderPass()) { NazaraError("Failed to create render pass"); return false; } - UInt32 imageCount = m_swapchain.GetBufferCount(); - - // Framebuffers - m_inflightFences.resize(imageCount); - - Nz::StackArray framebuffers = NazaraStackArray(Vk::Framebuffer, imageCount); - for (UInt32 i = 0; i < imageCount; ++i) + if (!CreateSwapchain(vulkanSurface, m_owner.GetSize())) { - std::array attachments = { m_swapchain.GetBuffer(i).view, m_depthBufferView }; - - VkFramebufferCreateInfo frameBufferCreate = { - VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, - nullptr, - 0, - m_renderPass->GetRenderPass(), - (attachments[1] != VK_NULL_HANDLE) ? 2U : 1U, - attachments.data(), - size.x, - size.y, - 1U - }; - - if (!framebuffers[i].Create(*m_device, frameBufferCreate)) - { - NazaraError("Failed to create framebuffer for image #" + String::Number(i) + ": " + TranslateVulkanError(framebuffers[i].GetLastErrorCode())); - return false; - } + NazaraError("failed to create swapchain"); + return false; } - m_framebuffer.emplace(framebuffers.data(), framebuffers.size()); - - const std::size_t MaxConcurrentImage = imageCount; - m_concurrentImageData.reserve(MaxConcurrentImage); - - for (std::size_t i = 0; i < MaxConcurrentImage; ++i) - m_concurrentImageData.emplace_back(*this); - m_clock.Restart(); return true; @@ -237,9 +240,60 @@ namespace Nz return std::make_unique(*m_device, queueFamilyIndex); } - const VulkanRenderPass& VkRenderWindow::GetRenderPass() const + void VkRenderWindow::Present(UInt32 imageIndex, VkSemaphore waitSemaphore) { - return *m_renderPass; + NazaraAssert(imageIndex < m_inflightFences.size(), "Invalid image index"); + + m_currentFrame = (m_currentFrame + 1) % m_inflightFences.size(); + + m_presentQueue.Present(m_swapchain, imageIndex, waitSemaphore); + + switch (m_presentQueue.GetLastErrorCode()) + { + case VK_SUCCESS: + break; + + case VK_ERROR_OUT_OF_DATE_KHR: + case VK_SUBOPTIMAL_KHR: + { + // Recreate swapchain next time + m_shouldRecreateSwapchain = true; + break; + } + + // Unhandled errors + case VK_ERROR_DEVICE_LOST: + case VK_ERROR_OUT_OF_DEVICE_MEMORY: + case VK_ERROR_OUT_OF_HOST_MEMORY: + case VK_ERROR_SURFACE_LOST_KHR: //< TODO: Handle it by recreating the surface? + case VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT: + default: + throw std::runtime_error("Failed to present image: " + TranslateVulkanError(m_swapchain.GetLastErrorCode())); + } + } + + bool VkRenderWindow::CreateSwapchain(Vk::Surface& surface, const Vector2ui& size) + { + assert(m_device); + if (!SetupSwapchain(m_device->GetPhysicalDeviceInfo(), surface, size)) + { + NazaraError("Failed to create swapchain"); + return false; + } + + if (m_depthStencilFormat != VK_FORMAT_MAX_ENUM && !SetupDepthBuffer(size)) + { + NazaraError("Failed to create depth buffer"); + return false; + } + + if (!SetupFrameBuffers(size)) + { + NazaraError("failed to create framebuffers"); + return false; + } + + return true; } bool VkRenderWindow::SetupDepthBuffer(const Vector2ui& size) @@ -312,6 +366,38 @@ namespace Nz return true; } + bool VkRenderWindow::SetupFrameBuffers(const Vector2ui& size) + { + UInt32 imageCount = m_swapchain.GetBufferCount(); + + Nz::StackArray framebuffers = NazaraStackArray(Vk::Framebuffer, imageCount); + for (UInt32 i = 0; i < imageCount; ++i) + { + std::array attachments = { m_swapchain.GetBuffer(i).view, m_depthBufferView }; + + VkFramebufferCreateInfo frameBufferCreate = { + VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, + nullptr, + 0, + m_renderPass->GetRenderPass(), + (attachments[1] != VK_NULL_HANDLE) ? 2U : 1U, + attachments.data(), + size.x, + size.y, + 1U + }; + + if (!framebuffers[i].Create(*m_device, frameBufferCreate)) + { + NazaraError("Failed to create framebuffer for image #" + String::Number(i) + ": " + TranslateVulkanError(framebuffers[i].GetLastErrorCode())); + return false; + } + } + + m_framebuffer.emplace(framebuffers.data(), framebuffers.size()); + return true; + } + bool VkRenderWindow::SetupRenderPass() { std::array attachments = { @@ -468,15 +554,31 @@ namespace Nz VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR, swapchainPresentMode, VK_TRUE, - VK_NULL_HANDLE + m_swapchain }; - if (!m_swapchain.Create(*m_device, swapchainInfo)) + Vk::Swapchain newSwapchain; + if (!newSwapchain.Create(*m_device, swapchainInfo)) { - NazaraError("Failed to create swapchain"); + NazaraError("failed to create swapchain: " + TranslateVulkanError(newSwapchain.GetLastErrorCode())); return false; } + m_swapchain = std::move(newSwapchain); + m_swapchainSize = size; + + // Framebuffers + m_inflightFences.resize(imageCount); + + if (m_concurrentImageData.size() != imageCount) + { + m_concurrentImageData.clear(); + m_concurrentImageData.reserve(imageCount); + + for (std::size_t i = 0; i < imageCount; ++i) + m_concurrentImageData.emplace_back(*this); + } + return true; } } diff --git a/src/Nazara/VulkanRenderer/VulkanRenderer.cpp b/src/Nazara/VulkanRenderer/VulkanRenderer.cpp index 9eed59b0c..aa0edcb5a 100644 --- a/src/Nazara/VulkanRenderer/VulkanRenderer.cpp +++ b/src/Nazara/VulkanRenderer/VulkanRenderer.cpp @@ -25,9 +25,9 @@ namespace Nz return std::make_unique(); } - std::unique_ptr VulkanRenderer::CreateRenderWindowImpl() + std::unique_ptr VulkanRenderer::CreateRenderWindowImpl(RenderWindow& owner) { - return std::make_unique(); + return std::make_unique(owner); } std::shared_ptr VulkanRenderer::InstanciateRenderDevice(std::size_t deviceIndex) From 7c9dcdfbe490bebc72bb9867f3ea91579edbbd16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Thu, 27 Aug 2020 18:31:26 +0200 Subject: [PATCH 315/316] Allocate command buffers from pools --- .../OpenGLRenderer/OpenGLCommandBuffer.hpp | 12 +++- .../OpenGLRenderer/OpenGLCommandBuffer.inl | 29 ++++++++ .../OpenGLRenderer/OpenGLCommandPool.hpp | 24 ++++++- .../OpenGLRenderer/OpenGLCommandPool.inl | 16 +++++ include/Nazara/OpenGLRenderer/Utils.inl | 1 + include/Nazara/Renderer/CommandBuffer.hpp | 21 +++++- include/Nazara/Renderer/CommandBuffer.inl | 4 ++ include/Nazara/Renderer/CommandPool.hpp | 5 +- include/Nazara/Renderer/ShaderBinding.hpp | 8 ++- .../VulkanRenderer/VulkanCommandBuffer.hpp | 16 ++++- .../VulkanRenderer/VulkanCommandBuffer.inl | 30 +++++++- .../VulkanRenderer/VulkanCommandPool.hpp | 24 ++++++- .../VulkanRenderer/VulkanCommandPool.inl | 32 +++++++++ .../OpenGLRenderer/OpenGLCommandBuffer.cpp | 7 ++ .../OpenGLRenderer/OpenGLCommandPool.cpp | 69 ++++++++++++++++++- .../OpenGLRenderer/OpenGLRenderImage.cpp | 2 +- .../VulkanRenderer/VulkanCommandBuffer.cpp | 5 ++ .../VulkanRenderer/VulkanCommandPool.cpp | 51 +++++++++++++- 18 files changed, 333 insertions(+), 23 deletions(-) diff --git a/include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.hpp b/include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.hpp index fc80a9ada..32f216de5 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.hpp @@ -22,12 +22,14 @@ namespace Nz { + class OpenGLCommandPool; class OpenGLFramebuffer; class NAZARA_OPENGLRENDERER_API OpenGLCommandBuffer final : public CommandBuffer { public: - OpenGLCommandBuffer() = default; + inline OpenGLCommandBuffer(); + inline OpenGLCommandBuffer(OpenGLCommandPool& owner, std::size_t poolIndex, std::size_t bindingIndex); OpenGLCommandBuffer(const OpenGLCommandBuffer&) = delete; OpenGLCommandBuffer(OpenGLCommandBuffer&&) noexcept = default; ~OpenGLCommandBuffer() = default; @@ -49,6 +51,10 @@ namespace Nz void Execute(); + inline std::size_t GetBindingIndex() const; + inline std::size_t GetPoolIndex() const; + inline const OpenGLCommandPool& GetOwner() const; + inline void SetFramebuffer(const OpenGLFramebuffer& framebuffer, const RenderPass& renderPass, std::initializer_list clearValues); inline void SetScissor(Nz::Recti scissorRegion); inline void SetViewport(Nz::Recti viewportRegion); @@ -60,6 +66,7 @@ namespace Nz struct DrawStates; void ApplyStates(const GL::Context& context, const DrawStates& states); + void Release(); struct BeginDebugRegionData { @@ -139,7 +146,10 @@ namespace Nz >; DrawStates m_currentStates; + std::size_t m_bindingIndex; + std::size_t m_poolIndex; std::vector m_commands; + OpenGLCommandPool* m_owner; }; } diff --git a/include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.inl b/include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.inl index 892550d8e..bec54f598 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.inl +++ b/include/Nazara/OpenGLRenderer/OpenGLCommandBuffer.inl @@ -4,11 +4,24 @@ #include #include +#include #include #include namespace Nz { + inline OpenGLCommandBuffer::OpenGLCommandBuffer() : + m_owner(nullptr) + { + } + + inline OpenGLCommandBuffer::OpenGLCommandBuffer(OpenGLCommandPool& owner, std::size_t poolIndex, std::size_t bindingIndex) : + m_bindingIndex(bindingIndex), + m_poolIndex(poolIndex), + m_owner(&owner) + { + } + inline void OpenGLCommandBuffer::BeginDebugRegion(const std::string_view& regionName, const Nz::Color& color) { BeginDebugRegionData beginDebugRegion; @@ -104,6 +117,22 @@ namespace Nz m_commands.emplace_back(EndDebugRegionData{}); } + inline std::size_t Nz::OpenGLCommandBuffer::GetBindingIndex() const + { + return m_bindingIndex; + } + + inline std::size_t Nz::OpenGLCommandBuffer::GetPoolIndex() const + { + return m_poolIndex; + } + + inline const OpenGLCommandPool& OpenGLCommandBuffer::GetOwner() const + { + assert(m_owner); + return *m_owner; + } + inline void OpenGLCommandBuffer::SetFramebuffer(const OpenGLFramebuffer& framebuffer, const RenderPass& /*renderPass*/, std::initializer_list clearValues) { SetFrameBufferData setFramebuffer; diff --git a/include/Nazara/OpenGLRenderer/OpenGLCommandPool.hpp b/include/Nazara/OpenGLRenderer/OpenGLCommandPool.hpp index bc79593b9..81a3871af 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLCommandPool.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLCommandPool.hpp @@ -8,23 +8,45 @@ #define NAZARA_OPENGLRENDERER_OPENGLCOMMANDPOOL_HPP #include +#include #include #include +#include namespace Nz { class NAZARA_OPENGLRENDERER_API OpenGLCommandPool final : public CommandPool { + friend OpenGLCommandBuffer; + public: OpenGLCommandPool() = default; OpenGLCommandPool(const OpenGLCommandPool&) = delete; OpenGLCommandPool(OpenGLCommandPool&&) noexcept = default; ~OpenGLCommandPool() = default; - std::unique_ptr BuildCommandBuffer(const std::function& callback) override; + CommandBufferPtr BuildCommandBuffer(const std::function& callback) override; OpenGLCommandPool& operator=(const OpenGLCommandPool&) = delete; OpenGLCommandPool& operator=(OpenGLCommandPool&&) = delete; + + private: + struct CommandPool; + + CommandPool& AllocatePool(); + CommandBufferPtr AllocateFromPool(std::size_t poolIndex); + void Release(CommandBuffer& commandBuffer); + inline void TryToShrink(); + + struct CommandPool + { + using BindingStorage = std::aligned_storage_t; + + Bitset freeCommands; + std::unique_ptr storage; + }; + + std::vector m_commandPools; }; } diff --git a/include/Nazara/OpenGLRenderer/OpenGLCommandPool.inl b/include/Nazara/OpenGLRenderer/OpenGLCommandPool.inl index 3da51fb3b..d80cd3a22 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLCommandPool.inl +++ b/include/Nazara/OpenGLRenderer/OpenGLCommandPool.inl @@ -8,6 +8,22 @@ namespace Nz { + inline void OpenGLCommandPool::TryToShrink() + { + std::size_t poolCount = m_commandPools.size(); + if (poolCount >= 2 && m_commandPools.back().freeCommands.TestAll()) + { + for (std::size_t i = poolCount - 1; i > 0; --i) + { + if (!m_commandPools[i].freeCommands.TestAll()) + break; + + poolCount--; + } + + m_commandPools.resize(poolCount); + } + } } #include diff --git a/include/Nazara/OpenGLRenderer/Utils.inl b/include/Nazara/OpenGLRenderer/Utils.inl index 621704a82..61f446590 100644 --- a/include/Nazara/OpenGLRenderer/Utils.inl +++ b/include/Nazara/OpenGLRenderer/Utils.inl @@ -17,6 +17,7 @@ namespace Nz case PixelFormat_A8: return GLTextureFormat { GL_R8, GL_RED, GL_UNSIGNED_BYTE, GL_ZERO, GL_ZERO, GL_ZERO, GL_RED }; case PixelFormat_RGB8: return GLTextureFormat { GL_SRGB8, GL_RGB, GL_UNSIGNED_BYTE, GL_RED, GL_GREEN, GL_BLUE, GL_ZERO }; case PixelFormat_RGBA8: return GLTextureFormat { GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }; + default: break; } NazaraError("Unhandled PixelFormat 0x" + String::Number(UnderlyingCast(pixelFormat), 16)); diff --git a/include/Nazara/Renderer/CommandBuffer.hpp b/include/Nazara/Renderer/CommandBuffer.hpp index 547d0a3f2..6f28a3352 100644 --- a/include/Nazara/Renderer/CommandBuffer.hpp +++ b/include/Nazara/Renderer/CommandBuffer.hpp @@ -9,19 +9,36 @@ #include #include +#include namespace Nz { + class CommandBuffer; + class CommandBufferDeleter; + + using CommandBufferPtr = std::unique_ptr; + class NAZARA_RENDERER_API CommandBuffer { + friend CommandBufferDeleter; + public: CommandBuffer() = default; CommandBuffer(const CommandBuffer&) = delete; - CommandBuffer(CommandBuffer&&) = default; + CommandBuffer(CommandBuffer&&) = delete; virtual ~CommandBuffer(); CommandBuffer& operator=(const CommandBuffer&) = delete; - CommandBuffer& operator=(CommandBuffer&&) = default; + CommandBuffer& operator=(CommandBuffer&&) = delete; + + protected: + virtual void Release() = 0; + }; + + class CommandBufferDeleter + { + public: + inline void operator()(CommandBuffer* commandBuffer); }; } diff --git a/include/Nazara/Renderer/CommandBuffer.inl b/include/Nazara/Renderer/CommandBuffer.inl index be4849bd3..939582513 100644 --- a/include/Nazara/Renderer/CommandBuffer.inl +++ b/include/Nazara/Renderer/CommandBuffer.inl @@ -7,6 +7,10 @@ namespace Nz { + inline void CommandBufferDeleter::operator()(CommandBuffer* commandBuffer) + { + commandBuffer->Release(); + } } #include diff --git a/include/Nazara/Renderer/CommandPool.hpp b/include/Nazara/Renderer/CommandPool.hpp index ec52d83d2..780f43b1c 100644 --- a/include/Nazara/Renderer/CommandPool.hpp +++ b/include/Nazara/Renderer/CommandPool.hpp @@ -9,12 +9,11 @@ #include #include +#include #include -#include //< temporary namespace Nz { - class CommandBuffer; class CommandBufferBuilder; class NAZARA_RENDERER_API CommandPool @@ -25,7 +24,7 @@ namespace Nz CommandPool(CommandPool&&) = default; virtual ~CommandPool(); - virtual std::unique_ptr BuildCommandBuffer(const std::function& callback) = 0; + virtual CommandBufferPtr BuildCommandBuffer(const std::function& callback) = 0; CommandPool& operator=(const CommandPool&) = delete; CommandPool& operator=(CommandPool&&) = default; diff --git a/include/Nazara/Renderer/ShaderBinding.hpp b/include/Nazara/Renderer/ShaderBinding.hpp index 395afff5a..4105974bc 100644 --- a/include/Nazara/Renderer/ShaderBinding.hpp +++ b/include/Nazara/Renderer/ShaderBinding.hpp @@ -30,10 +30,15 @@ namespace Nz struct Binding; ShaderBinding() = default; + ShaderBinding(const ShaderBinding&) = delete; + ShaderBinding(ShaderBinding&&) = delete; virtual ~ShaderBinding(); virtual void Update(std::initializer_list bindings) = 0; + ShaderBinding& operator=(const ShaderBinding&) = delete; + ShaderBinding& operator=(ShaderBinding&&) = delete; + struct TextureBinding { Texture* texture; @@ -55,9 +60,6 @@ namespace Nz protected: virtual void Release() = 0; - - ShaderBinding(const ShaderBinding&) = delete; - ShaderBinding(ShaderBinding&&) = default; }; class ShaderBindingDeleter diff --git a/include/Nazara/VulkanRenderer/VulkanCommandBuffer.hpp b/include/Nazara/VulkanRenderer/VulkanCommandBuffer.hpp index 61607b865..04f5c560a 100644 --- a/include/Nazara/VulkanRenderer/VulkanCommandBuffer.hpp +++ b/include/Nazara/VulkanRenderer/VulkanCommandBuffer.hpp @@ -15,22 +15,34 @@ namespace Nz { + class VulkanCommandPool; + class NAZARA_VULKANRENDERER_API VulkanCommandBuffer final : public CommandBuffer { public: - inline VulkanCommandBuffer(Vk::AutoCommandBuffer commandBuffer); - inline VulkanCommandBuffer(std::vector commandBuffers); + inline VulkanCommandBuffer(VulkanCommandPool& owner, std::size_t poolIndex, std::size_t bindingIndex, Vk::AutoCommandBuffer commandBuffer); + inline VulkanCommandBuffer(VulkanCommandPool& owner, std::size_t poolIndex, std::size_t bindingIndex, std::vector commandBuffers); VulkanCommandBuffer(const VulkanCommandBuffer&) = delete; VulkanCommandBuffer(VulkanCommandBuffer&&) noexcept = default; ~VulkanCommandBuffer() = default; + inline std::size_t GetBindingIndex() const; inline Vk::CommandBuffer& GetCommandBuffer(std::size_t imageIndex = 0); + inline std::size_t GetPoolIndex() const; + inline const VulkanCommandPool& GetOwner() const; VulkanCommandBuffer& operator=(const VulkanCommandBuffer&) = delete; VulkanCommandBuffer& operator=(VulkanCommandBuffer&&) = delete; private: + inline VulkanCommandBuffer(VulkanCommandPool& owner, std::size_t poolIndex, std::size_t bindingIndex); + + void Release() override; + + std::size_t m_bindingIndex; + std::size_t m_poolIndex; std::vector m_commandBuffers; + VulkanCommandPool& m_owner; }; } diff --git a/include/Nazara/VulkanRenderer/VulkanCommandBuffer.inl b/include/Nazara/VulkanRenderer/VulkanCommandBuffer.inl index 6e0f8fdf9..27e99bce8 100644 --- a/include/Nazara/VulkanRenderer/VulkanCommandBuffer.inl +++ b/include/Nazara/VulkanRenderer/VulkanCommandBuffer.inl @@ -7,20 +7,44 @@ namespace Nz { - inline VulkanCommandBuffer::VulkanCommandBuffer(Vk::AutoCommandBuffer commandBuffer) + inline VulkanCommandBuffer::VulkanCommandBuffer(VulkanCommandPool& owner, std::size_t poolIndex, std::size_t bindingIndex, Vk::AutoCommandBuffer commandBuffer) : + VulkanCommandBuffer(owner, poolIndex, bindingIndex) { m_commandBuffers.push_back(std::move(commandBuffer)); } - inline VulkanCommandBuffer::VulkanCommandBuffer(std::vector commandBuffers) : - m_commandBuffers(std::move(commandBuffers)) + inline VulkanCommandBuffer::VulkanCommandBuffer(VulkanCommandPool& owner, std::size_t poolIndex, std::size_t bindingIndex, std::vector commandBuffers) : + VulkanCommandBuffer(owner, poolIndex, bindingIndex) { + m_commandBuffers = std::move(commandBuffers); + } + + inline VulkanCommandBuffer::VulkanCommandBuffer(VulkanCommandPool& owner, std::size_t poolIndex, std::size_t bindingIndex) : + m_bindingIndex(bindingIndex), + m_poolIndex(poolIndex), + m_owner(owner) + { + } + + inline std::size_t VulkanCommandBuffer::GetBindingIndex() const + { + return m_bindingIndex; } inline Vk::CommandBuffer& VulkanCommandBuffer::GetCommandBuffer(std::size_t imageIndex) { return m_commandBuffers[imageIndex].Get(); } + + inline std::size_t VulkanCommandBuffer::GetPoolIndex() const + { + return m_poolIndex; + } + + inline const VulkanCommandPool& VulkanCommandBuffer::GetOwner() const + { + return m_owner; + } } #include diff --git a/include/Nazara/VulkanRenderer/VulkanCommandPool.hpp b/include/Nazara/VulkanRenderer/VulkanCommandPool.hpp index 5fbdb6ab9..f45c7d1e0 100644 --- a/include/Nazara/VulkanRenderer/VulkanCommandPool.hpp +++ b/include/Nazara/VulkanRenderer/VulkanCommandPool.hpp @@ -8,14 +8,19 @@ #define NAZARA_VULKANRENDERER_VULKANCOMMANDPOOL_HPP #include +#include #include #include +#include #include +#include namespace Nz { class NAZARA_VULKANRENDERER_API VulkanCommandPool final : public CommandPool { + friend VulkanCommandBuffer; + public: inline VulkanCommandPool(Vk::Device& device, QueueType queueType); inline VulkanCommandPool(Vk::Device& device, UInt32 queueFamilyIndex); @@ -23,12 +28,29 @@ namespace Nz VulkanCommandPool(VulkanCommandPool&&) noexcept = default; ~VulkanCommandPool() = default; - std::unique_ptr BuildCommandBuffer(const std::function& callback) override; + CommandBufferPtr BuildCommandBuffer(const std::function& callback) override; VulkanCommandPool& operator=(const VulkanCommandPool&) = delete; VulkanCommandPool& operator=(VulkanCommandPool&&) = delete; private: + struct CommandPool; + + CommandPool& AllocatePool(); + template CommandBufferPtr AllocateFromPool(std::size_t poolIndex, Args&&... args); + void Release(CommandBuffer& commandBuffer); + inline void TryToShrink(); + + struct CommandPool + { + using BindingStorage = std::aligned_storage_t; + + Bitset freeCommands; + std::unique_ptr storage; + }; + + MovablePtr m_device; + std::vector m_commandPools; Vk::CommandPool m_commandPool; }; } diff --git a/include/Nazara/VulkanRenderer/VulkanCommandPool.inl b/include/Nazara/VulkanRenderer/VulkanCommandPool.inl index 77a6066a7..f6689834d 100644 --- a/include/Nazara/VulkanRenderer/VulkanCommandPool.inl +++ b/include/Nazara/VulkanRenderer/VulkanCommandPool.inl @@ -23,6 +23,38 @@ namespace Nz if (!m_commandPool.Create(device, queueFamilyIndex)) throw std::runtime_error("Failed to create command pool: " + TranslateVulkanError(m_commandPool.GetLastErrorCode())); } + + template + CommandBufferPtr VulkanCommandPool::AllocateFromPool(std::size_t poolIndex, Args&&... args) + { + auto& pool = m_commandPools[poolIndex]; + + std::size_t freeBindingId = pool.freeCommands.FindFirst(); + if (freeBindingId == pool.freeCommands.npos) + return {}; //< No free binding in this pool + + pool.freeCommands.Reset(freeBindingId); + + VulkanCommandBuffer* freeBindingMemory = reinterpret_cast(&pool.storage[freeBindingId]); + return CommandBufferPtr(PlacementNew(freeBindingMemory, *this, poolIndex, freeBindingId, std::forward(args)...)); + } + + inline void VulkanCommandPool::TryToShrink() + { + std::size_t poolCount = m_commandPools.size(); + if (poolCount >= 2 && m_commandPools.back().freeCommands.TestAll()) + { + for (std::size_t i = poolCount - 1; i > 0; --i) + { + if (!m_commandPools[i].freeCommands.TestAll()) + break; + + poolCount--; + } + + m_commandPools.resize(poolCount); + } + } } #include diff --git a/src/Nazara/OpenGLRenderer/OpenGLCommandBuffer.cpp b/src/Nazara/OpenGLRenderer/OpenGLCommandBuffer.cpp index eac73f9ca..1f9f06546 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLCommandBuffer.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLCommandBuffer.cpp @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include #include #include @@ -139,4 +140,10 @@ namespace Nz const GL::VertexArray& vao = context.GetVaoCache().Get(vaoSetup); context.BindVertexArray(vao.GetObjectId(), true); } + + void OpenGLCommandBuffer::Release() + { + assert(m_owner); + m_owner->Release(*this); + } } diff --git a/src/Nazara/OpenGLRenderer/OpenGLCommandPool.cpp b/src/Nazara/OpenGLRenderer/OpenGLCommandPool.cpp index 90bfd3593..488a8e5f9 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLCommandPool.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLCommandPool.cpp @@ -3,19 +3,82 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include #include #include namespace Nz { - std::unique_ptr OpenGLCommandPool::BuildCommandBuffer(const std::function& callback) + CommandBufferPtr OpenGLCommandPool::BuildCommandBuffer(const std::function& callback) { - std::unique_ptr commandBuffer = std::make_unique(); + CommandBufferPtr commandBuffer; + for (std::size_t i = 0; i < m_commandPools.size(); ++i) + { + commandBuffer = AllocateFromPool(i); + if (commandBuffer) + break; + } - OpenGLCommandBufferBuilder builder(*commandBuffer); + if (!commandBuffer) + { + // No allocation could be made, time to allocate a new pool + std::size_t newPoolIndex = m_commandPools.size(); + AllocatePool(); + + commandBuffer = AllocateFromPool(newPoolIndex); + assert(commandBuffer); + } + + OpenGLCommandBufferBuilder builder(static_cast(*commandBuffer.get())); callback(builder); return commandBuffer; } + + auto OpenGLCommandPool::AllocatePool() -> CommandPool& + { + constexpr UInt32 MaxSet = 128; + + CommandPool pool; + pool.freeCommands.Resize(MaxSet, true); + pool.storage = std::make_unique(MaxSet); + + return m_commandPools.emplace_back(std::move(pool)); + } + + CommandBufferPtr OpenGLCommandPool::AllocateFromPool(std::size_t poolIndex) + { + auto& pool = m_commandPools[poolIndex]; + + std::size_t freeBindingId = pool.freeCommands.FindFirst(); + if (freeBindingId == pool.freeCommands.npos) + return {}; //< No free binding in this pool + + pool.freeCommands.Reset(freeBindingId); + + OpenGLCommandBuffer* freeBindingMemory = reinterpret_cast(&pool.storage[freeBindingId]); + return CommandBufferPtr(PlacementNew(freeBindingMemory, *this, poolIndex, freeBindingId)); + } + + void OpenGLCommandPool::Release(CommandBuffer& binding) + { + OpenGLCommandBuffer& openglBinding = static_cast(binding); + + std::size_t poolIndex = openglBinding.GetPoolIndex(); + std::size_t bindingIndex = openglBinding.GetBindingIndex(); + + assert(poolIndex < m_commandPools.size()); + auto& pool = m_commandPools[poolIndex]; + assert(!pool.freeCommands.Test(bindingIndex)); + + OpenGLCommandBuffer* bindingMemory = reinterpret_cast(&pool.storage[bindingIndex]); + PlacementDestroy(bindingMemory); + + pool.freeCommands.Set(bindingIndex); + + // Try to free pool if it's one of the last one + if (poolIndex >= m_commandPools.size() - 1 && poolIndex <= m_commandPools.size()) + TryToShrink(); + } } diff --git a/src/Nazara/OpenGLRenderer/OpenGLRenderImage.cpp b/src/Nazara/OpenGLRenderer/OpenGLRenderImage.cpp index 39c2be6dd..681b4cf46 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLRenderImage.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLRenderImage.cpp @@ -19,7 +19,7 @@ namespace Nz void OpenGLRenderImage::Execute(const std::function& callback, QueueTypeFlags /*queueTypeFlags*/) { - OpenGLCommandBuffer commandBuffer; + OpenGLCommandBuffer commandBuffer; //< TODO: Use a pool and remove default constructor OpenGLCommandBufferBuilder builder(commandBuffer); callback(builder); diff --git a/src/Nazara/VulkanRenderer/VulkanCommandBuffer.cpp b/src/Nazara/VulkanRenderer/VulkanCommandBuffer.cpp index 92f60a953..d0436e030 100644 --- a/src/Nazara/VulkanRenderer/VulkanCommandBuffer.cpp +++ b/src/Nazara/VulkanRenderer/VulkanCommandBuffer.cpp @@ -3,8 +3,13 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include namespace Nz { + void VulkanCommandBuffer::Release() + { + m_owner.Release(*this); + } } diff --git a/src/Nazara/VulkanRenderer/VulkanCommandPool.cpp b/src/Nazara/VulkanRenderer/VulkanCommandPool.cpp index fd514c83e..a654c45b6 100644 --- a/src/Nazara/VulkanRenderer/VulkanCommandPool.cpp +++ b/src/Nazara/VulkanRenderer/VulkanCommandPool.cpp @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include #include #include @@ -10,14 +11,14 @@ namespace Nz { - std::unique_ptr VulkanCommandPool::BuildCommandBuffer(const std::function& callback) + CommandBufferPtr VulkanCommandPool::BuildCommandBuffer(const std::function& callback) { std::vector commandBuffers; auto BuildCommandBuffer = [&](std::size_t imageIndex) { Vk::AutoCommandBuffer& commandBuffer = commandBuffers.emplace_back(m_commandPool.AllocateCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY)); - if (!commandBuffer->Begin(VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT)) + if (!commandBuffer->Begin()) throw std::runtime_error("failed to begin command buffer: " + TranslateVulkanError(commandBuffer->GetLastErrorCode())); VulkanCommandBufferBuilder builder(commandBuffer.Get(), imageIndex); @@ -33,6 +34,50 @@ namespace Nz for (std::size_t i = 1; i < maxFramebufferCount; ++i) BuildCommandBuffer(i); - return std::make_unique(std::move(commandBuffers)); + for (std::size_t i = 0; i < m_commandPools.size(); ++i) + { + if (m_commandPools[i].freeCommands.TestNone()) + continue; + + return AllocateFromPool(i, std::move(commandBuffers)); + } + + // No allocation could be made, time to allocate a new pool + std::size_t newPoolIndex = m_commandPools.size(); + AllocatePool(); + + return AllocateFromPool(newPoolIndex, std::move(commandBuffers)); + } + + auto VulkanCommandPool::AllocatePool() -> CommandPool& + { + constexpr UInt32 MaxSet = 128; + + CommandPool pool; + pool.freeCommands.Resize(MaxSet, true); + pool.storage = std::make_unique(MaxSet); + + return m_commandPools.emplace_back(std::move(pool)); + } + + void VulkanCommandPool::Release(CommandBuffer& binding) + { + VulkanCommandBuffer& vulkanBinding = static_cast(binding); + + std::size_t poolIndex = vulkanBinding.GetPoolIndex(); + std::size_t bindingIndex = vulkanBinding.GetBindingIndex(); + + assert(poolIndex < m_commandPools.size()); + auto& pool = m_commandPools[poolIndex]; + assert(!pool.freeCommands.Test(bindingIndex)); + + VulkanCommandBuffer* bindingMemory = reinterpret_cast(&pool.storage[bindingIndex]); + PlacementDestroy(bindingMemory); + + pool.freeCommands.Set(bindingIndex); + + // Try to free pool if it's one of the last one + if (poolIndex >= m_commandPools.size() - 1 && poolIndex <= m_commandPools.size()) + TryToShrink(); } } From 51ec9741dfa46f25ea98e53e522f5391775160cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Thu, 27 Aug 2020 18:32:22 +0200 Subject: [PATCH 316/316] OpenGLRenderer: Handle resize/minimize --- .../Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp | 1 + src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp b/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp index 9031a01d1..61b0a69d8 100644 --- a/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp +++ b/include/Nazara/OpenGLRenderer/OpenGLRenderWindow.hpp @@ -49,6 +49,7 @@ namespace Nz OpenGLRenderPass m_renderPass; OpenGLWindowFramebuffer m_framebuffer; RenderWindow& m_owner; + Vector2ui m_size; }; } diff --git a/src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp b/src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp index a4eaec923..a0b561eda 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLRenderWindow.cpp @@ -21,7 +21,18 @@ namespace Nz RenderFrame OpenGLRenderWindow::Acquire() { - return RenderFrame(&m_renderImage[m_currentFrame], false); + if (m_owner.IsMinimized()) + return RenderFrame(); + + bool invalidateFramebuffer = false; + Vector2ui size = m_owner.GetSize(); + if (m_size != size) + { + invalidateFramebuffer = true; + m_size = size; + } + + return RenderFrame(&m_renderImage[m_currentFrame], invalidateFramebuffer); } bool OpenGLRenderWindow::Create(RendererImpl* renderer, RenderSurface* surface, const RenderWindowParameters& parameters) @@ -37,6 +48,8 @@ namespace Nz if (!m_context) return false; + m_size = m_owner.GetSize(); + constexpr std::size_t RenderImageCount = 2; m_renderImage.reserve(RenderImageCount);